* [PATCH] tty: ar933x_uart: use the clk API to get the uart clock
@ 2013-08-27 20:14 Gabor Juhos
2013-08-27 23:27 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Gabor Juhos @ 2013-08-27 20:14 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-serial, Gabor Juhos
The AR933x UARTs are only used on the Atheros AR933x
SoCs. The base clock frequency of the UART is passed
to the driver via platform data. The SoC support code
implements the generic clock API, and the clock rate
can be retrieved via that.
Update the code to get the clock rate via the generic
clock API instead of using the platform data.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
Note:
Because the driver specific platform data only contains
the clock frequency it can be removed. In order to avoid
merge conflicts between different trees, it will be removed
by a later patch once this one is merged upstream.
-Gabor
---
drivers/tty/serial/Kconfig | 2 +-
drivers/tty/serial/ar933x_uart.c | 35 ++++++++++++++++++++++++++---------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 1456673..d5803f5 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1402,7 +1402,7 @@ config SERIAL_XILINX_PS_UART_CONSOLE
config SERIAL_AR933X
bool "AR933X serial port support"
- depends on SOC_AR933X
+ depends on HAVE_CLK && SOC_AR933X
select SERIAL_CORE
help
If you have an Atheros AR933X SOC based board and want to use the
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index 470993e..bc56cab 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -24,11 +24,11 @@
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/irq.h>
+#include <linux/clk.h>
#include <asm/div64.h>
#include <asm/mach-ath79/ar933x_uart.h>
-#include <asm/mach-ath79/ar933x_uart_platform.h>
#define DRIVER_NAME "ar933x-uart"
@@ -47,6 +47,7 @@ struct ar933x_uart_port {
unsigned int ier; /* shadow Interrupt Enable Register */
unsigned int min_baud;
unsigned int max_baud;
+ struct clk *clk;
};
static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
@@ -620,7 +621,6 @@ static struct uart_driver ar933x_uart_driver = {
static int ar933x_uart_probe(struct platform_device *pdev)
{
- struct ar933x_uart_platform_data *pdata;
struct ar933x_uart_port *up;
struct uart_port *port;
struct resource *mem_res;
@@ -629,10 +629,6 @@ static int ar933x_uart_probe(struct platform_device *pdev)
int id;
int ret;
- pdata = pdev->dev.platform_data;
- if (!pdata)
- return -EINVAL;
-
id = pdev->id;
if (id == -1)
id = 0;
@@ -657,19 +653,34 @@ static int ar933x_uart_probe(struct platform_device *pdev)
if (!up)
return -ENOMEM;
+ up->clk = devm_clk_get(&pdev->dev, "uart");
+ if (IS_ERR(up->clk)) {
+ dev_err(&pdev->dev, "unable to get UART clock\n");
+ return PTR_ERR(up->clk);
+ }
+
port = &up->port;
port->membase = devm_ioremap_resource(&pdev->dev, mem_res);
if (IS_ERR(port->membase))
return PTR_ERR(port->membase);
+ ret = clk_prepare_enable(up->clk);
+ if (ret)
+ return ret;
+
+ port->uartclk = clk_get_rate(up->clk);
+ if (!port->uartclk) {
+ ret = -EINVAL;
+ goto err_disable_clk;
+ }
+
port->mapbase = mem_res->start;
port->line = id;
port->irq = irq_res->start;
port->dev = &pdev->dev;
port->type = PORT_AR933X;
port->iotype = UPIO_MEM32;
- port->uartclk = pdata->uartclk;
port->regshift = 2;
port->fifosize = AR933X_UART_FIFO_SIZE;
@@ -685,10 +696,14 @@ static int ar933x_uart_probe(struct platform_device *pdev)
ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
if (ret)
- return ret;
+ goto err_disable_clk;
platform_set_drvdata(pdev, up);
return 0;
+
+err_disable_clk:
+ clk_disable_unprepare(up->clk);
+ return ret;
}
static int ar933x_uart_remove(struct platform_device *pdev)
@@ -698,8 +713,10 @@ static int ar933x_uart_remove(struct platform_device *pdev)
up = platform_get_drvdata(pdev);
platform_set_drvdata(pdev, NULL);
- if (up)
+ if (up) {
uart_remove_one_port(&ar933x_uart_driver, &up->port);
+ clk_disable_unprepare(up->clk);
+ }
return 0;
}
--
1.7.10
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tty: ar933x_uart: use the clk API to get the uart clock
2013-08-27 20:14 [PATCH] tty: ar933x_uart: use the clk API to get the uart clock Gabor Juhos
@ 2013-08-27 23:27 ` Greg Kroah-Hartman
2013-08-28 8:02 ` Gabor Juhos
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2013-08-27 23:27 UTC (permalink / raw)
To: Gabor Juhos; +Cc: linux-serial
On Tue, Aug 27, 2013 at 10:14:25PM +0200, Gabor Juhos wrote:
> The AR933x UARTs are only used on the Atheros AR933x
> SoCs. The base clock frequency of the UART is passed
> to the driver via platform data. The SoC support code
> implements the generic clock API, and the clock rate
> can be retrieved via that.
>
> Update the code to get the clock rate via the generic
> clock API instead of using the platform data.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> ---
> Note:
>
> Because the driver specific platform data only contains
> the clock frequency it can be removed. In order to avoid
> merge conflicts between different trees, it will be removed
> by a later patch once this one is merged upstream.
I don't understand what you mean by this.
Also, this patch doesn't even apply to my tty-next tree, so I can't
accept it as-is, so please fix it up, work with the people whose patches
yours is conflicting with, and figure out how to do this with the least
amount of merge issues.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tty: ar933x_uart: use the clk API to get the uart clock
2013-08-27 23:27 ` Greg Kroah-Hartman
@ 2013-08-28 8:02 ` Gabor Juhos
0 siblings, 0 replies; 3+ messages in thread
From: Gabor Juhos @ 2013-08-28 8:02 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-serial
2013.08.28. 1:27 keltezéssel, Greg Kroah-Hartman írta:
> On Tue, Aug 27, 2013 at 10:14:25PM +0200, Gabor Juhos wrote:
>> The AR933x UARTs are only used on the Atheros AR933x
>> SoCs. The base clock frequency of the UART is passed
>> to the driver via platform data. The SoC support code
>> implements the generic clock API, and the clock rate
>> can be retrieved via that.
>>
>> Update the code to get the clock rate via the generic
>> clock API instead of using the platform data.
>>
>> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
>> ---
>> Note:
>>
>> Because the driver specific platform data only contains
>> the clock frequency it can be removed. In order to avoid
>> merge conflicts between different trees, it will be removed
>> by a later patch once this one is merged upstream.
>
> I don't understand what you mean by this.
Currently the clock frequency is passed to the driver through platform data and
the platform data is initialized via platform specific setup code in
'arch/mips/ath79/dev-common.c'.
After this patch, the platform data is not used by the driver, so the
initialization will be superfluous and it can be removed along with the
'arch/mips/include/asm/mach-ath79/ar933x_uart_platform.h' header file.
However those changes would cause merge conflicts with my other patches which
are going through the MIPS tree so I kept out that part from the patch.
> Also, this patch doesn't even apply to my tty-next tree, so I can't
> accept it as-is, so please fix it up,
Sorry, it was based on 3.11-rc7. Will rebase it against the tty-next tree.
> work with the people whose patches yours is conflicting with, and figure out
> how to do this with the least amount of merge issues.
Ok.
Thanks,
Gabor
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-28 8:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-27 20:14 [PATCH] tty: ar933x_uart: use the clk API to get the uart clock Gabor Juhos
2013-08-27 23:27 ` Greg Kroah-Hartman
2013-08-28 8:02 ` Gabor Juhos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox