diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2013-08-28 04:09:28 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-28 19:00:42 -0400 |
commit | 15ef17f622033455dcf03ae96256e474073a7b11 (patch) | |
tree | f3b0b6f88fffa9e9be3395d7b4d655767a608194 /drivers/tty/serial | |
parent | a416bfa2a6b4e00a7bc69641b8fc2414873a5fd9 (diff) |
tty: ar933x_uart: use the clk API to get the uart clock
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r-- | drivers/tty/serial/Kconfig | 2 | ||||
-rw-r--r-- | 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 f13624807d12..3c598e3e7156 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig | |||
@@ -1402,7 +1402,7 @@ config SERIAL_XILINX_PS_UART_CONSOLE | |||
1402 | 1402 | ||
1403 | config SERIAL_AR933X | 1403 | config SERIAL_AR933X |
1404 | bool "AR933X serial port support" | 1404 | bool "AR933X serial port support" |
1405 | depends on SOC_AR933X | 1405 | depends on HAVE_CLK && SOC_AR933X |
1406 | select SERIAL_CORE | 1406 | select SERIAL_CORE |
1407 | help | 1407 | help |
1408 | If you have an Atheros AR933X SOC based board and want to use the | 1408 | 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 78be13ac1a95..1052ee0383e0 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c | |||
@@ -24,11 +24,11 @@ | |||
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/irq.h> | 26 | #include <linux/irq.h> |
27 | #include <linux/clk.h> | ||
27 | 28 | ||
28 | #include <asm/div64.h> | 29 | #include <asm/div64.h> |
29 | 30 | ||
30 | #include <asm/mach-ath79/ar933x_uart.h> | 31 | #include <asm/mach-ath79/ar933x_uart.h> |
31 | #include <asm/mach-ath79/ar933x_uart_platform.h> | ||
32 | 32 | ||
33 | #define DRIVER_NAME "ar933x-uart" | 33 | #define DRIVER_NAME "ar933x-uart" |
34 | 34 | ||
@@ -47,6 +47,7 @@ struct ar933x_uart_port { | |||
47 | unsigned int ier; /* shadow Interrupt Enable Register */ | 47 | unsigned int ier; /* shadow Interrupt Enable Register */ |
48 | unsigned int min_baud; | 48 | unsigned int min_baud; |
49 | unsigned int max_baud; | 49 | unsigned int max_baud; |
50 | struct clk *clk; | ||
50 | }; | 51 | }; |
51 | 52 | ||
52 | static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, | 53 | static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, |
@@ -622,7 +623,6 @@ static struct uart_driver ar933x_uart_driver = { | |||
622 | 623 | ||
623 | static int ar933x_uart_probe(struct platform_device *pdev) | 624 | static int ar933x_uart_probe(struct platform_device *pdev) |
624 | { | 625 | { |
625 | struct ar933x_uart_platform_data *pdata; | ||
626 | struct ar933x_uart_port *up; | 626 | struct ar933x_uart_port *up; |
627 | struct uart_port *port; | 627 | struct uart_port *port; |
628 | struct resource *mem_res; | 628 | struct resource *mem_res; |
@@ -631,10 +631,6 @@ static int ar933x_uart_probe(struct platform_device *pdev) | |||
631 | int id; | 631 | int id; |
632 | int ret; | 632 | int ret; |
633 | 633 | ||
634 | pdata = dev_get_platdata(&pdev->dev); | ||
635 | if (!pdata) | ||
636 | return -EINVAL; | ||
637 | |||
638 | id = pdev->id; | 634 | id = pdev->id; |
639 | if (id == -1) | 635 | if (id == -1) |
640 | id = 0; | 636 | id = 0; |
@@ -653,6 +649,12 @@ static int ar933x_uart_probe(struct platform_device *pdev) | |||
653 | if (!up) | 649 | if (!up) |
654 | return -ENOMEM; | 650 | return -ENOMEM; |
655 | 651 | ||
652 | up->clk = devm_clk_get(&pdev->dev, "uart"); | ||
653 | if (IS_ERR(up->clk)) { | ||
654 | dev_err(&pdev->dev, "unable to get UART clock\n"); | ||
655 | return PTR_ERR(up->clk); | ||
656 | } | ||
657 | |||
656 | port = &up->port; | 658 | port = &up->port; |
657 | 659 | ||
658 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 660 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -660,13 +662,22 @@ static int ar933x_uart_probe(struct platform_device *pdev) | |||
660 | if (IS_ERR(port->membase)) | 662 | if (IS_ERR(port->membase)) |
661 | return PTR_ERR(port->membase); | 663 | return PTR_ERR(port->membase); |
662 | 664 | ||
665 | ret = clk_prepare_enable(up->clk); | ||
666 | if (ret) | ||
667 | return ret; | ||
668 | |||
669 | port->uartclk = clk_get_rate(up->clk); | ||
670 | if (!port->uartclk) { | ||
671 | ret = -EINVAL; | ||
672 | goto err_disable_clk; | ||
673 | } | ||
674 | |||
663 | port->mapbase = mem_res->start; | 675 | port->mapbase = mem_res->start; |
664 | port->line = id; | 676 | port->line = id; |
665 | port->irq = irq_res->start; | 677 | port->irq = irq_res->start; |
666 | port->dev = &pdev->dev; | 678 | port->dev = &pdev->dev; |
667 | port->type = PORT_AR933X; | 679 | port->type = PORT_AR933X; |
668 | port->iotype = UPIO_MEM32; | 680 | port->iotype = UPIO_MEM32; |
669 | port->uartclk = pdata->uartclk; | ||
670 | 681 | ||
671 | port->regshift = 2; | 682 | port->regshift = 2; |
672 | port->fifosize = AR933X_UART_FIFO_SIZE; | 683 | port->fifosize = AR933X_UART_FIFO_SIZE; |
@@ -682,10 +693,14 @@ static int ar933x_uart_probe(struct platform_device *pdev) | |||
682 | 693 | ||
683 | ret = uart_add_one_port(&ar933x_uart_driver, &up->port); | 694 | ret = uart_add_one_port(&ar933x_uart_driver, &up->port); |
684 | if (ret) | 695 | if (ret) |
685 | return ret; | 696 | goto err_disable_clk; |
686 | 697 | ||
687 | platform_set_drvdata(pdev, up); | 698 | platform_set_drvdata(pdev, up); |
688 | return 0; | 699 | return 0; |
700 | |||
701 | err_disable_clk: | ||
702 | clk_disable_unprepare(up->clk); | ||
703 | return ret; | ||
689 | } | 704 | } |
690 | 705 | ||
691 | static int ar933x_uart_remove(struct platform_device *pdev) | 706 | static int ar933x_uart_remove(struct platform_device *pdev) |
@@ -694,8 +709,10 @@ static int ar933x_uart_remove(struct platform_device *pdev) | |||
694 | 709 | ||
695 | up = platform_get_drvdata(pdev); | 710 | up = platform_get_drvdata(pdev); |
696 | 711 | ||
697 | if (up) | 712 | if (up) { |
698 | uart_remove_one_port(&ar933x_uart_driver, &up->port); | 713 | uart_remove_one_port(&ar933x_uart_driver, &up->port); |
714 | clk_disable_unprepare(up->clk); | ||
715 | } | ||
699 | 716 | ||
700 | return 0; | 717 | return 0; |
701 | } | 718 | } |