Commit 90efa75f7ab0be5677f0cca155dbf0b39eacdd03
Committed by
Greg Kroah-Hartman
1 parent
e087ab74f3
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
serial: sccnxp: Using CLK API for getting UART clock
This patch removes "frequency" parameter from SCCNXP platform_data and uses CLK API for getting clock. If CLK ommited, default IC frequency will be used instead. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 3 changed files with 22 additions and 18 deletions Side-by-side Diff
arch/mips/sni/a20r.c
drivers/tty/serial/sccnxp.c
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | #define SUPPORT_SYSRQ |
16 | 16 | #endif |
17 | 17 | |
18 | +#include <linux/clk.h> | |
18 | 19 | #include <linux/err.h> |
19 | 20 | #include <linux/module.h> |
20 | 21 | #include <linux/device.h> |
21 | 22 | |
... | ... | @@ -783,9 +784,10 @@ |
783 | 784 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
784 | 785 | int chiptype = pdev->id_entry->driver_data; |
785 | 786 | struct sccnxp_pdata *pdata = dev_get_platdata(&pdev->dev); |
786 | - int i, ret, fifosize, freq_min, freq_max; | |
787 | + int i, ret, fifosize, freq_min, freq_max, uartclk; | |
787 | 788 | struct sccnxp_port *s; |
788 | 789 | void __iomem *membase; |
790 | + struct clk *clk; | |
789 | 791 | |
790 | 792 | membase = devm_ioremap_resource(&pdev->dev, res); |
791 | 793 | if (IS_ERR(membase)) |
792 | 794 | |
... | ... | @@ -898,11 +900,25 @@ |
898 | 900 | } else if (PTR_ERR(s->regulator) == -EPROBE_DEFER) |
899 | 901 | return -EPROBE_DEFER; |
900 | 902 | |
901 | - if (!pdata) { | |
902 | - dev_warn(&pdev->dev, | |
903 | - "No platform data supplied, using defaults\n"); | |
904 | - s->pdata.frequency = s->freq_std; | |
903 | + clk = devm_clk_get(&pdev->dev, NULL); | |
904 | + if (IS_ERR(clk)) { | |
905 | + if (PTR_ERR(clk) == -EPROBE_DEFER) { | |
906 | + ret = -EPROBE_DEFER; | |
907 | + goto err_out; | |
908 | + } | |
909 | + dev_notice(&pdev->dev, "Using default clock frequency\n"); | |
910 | + uartclk = s->freq_std; | |
905 | 911 | } else |
912 | + uartclk = clk_get_rate(clk); | |
913 | + | |
914 | + /* Check input frequency */ | |
915 | + if ((uartclk < freq_min) || (uartclk > freq_max)) { | |
916 | + dev_err(&pdev->dev, "Frequency out of bounds\n"); | |
917 | + ret = -EINVAL; | |
918 | + goto err_out; | |
919 | + } | |
920 | + | |
921 | + if (pdata) | |
906 | 922 | memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata)); |
907 | 923 | |
908 | 924 | if (s->pdata.poll_time_us) { |
... | ... | @@ -920,14 +936,6 @@ |
920 | 936 | } |
921 | 937 | } |
922 | 938 | |
923 | - /* Check input frequency */ | |
924 | - if ((s->pdata.frequency < freq_min) || | |
925 | - (s->pdata.frequency > freq_max)) { | |
926 | - dev_err(&pdev->dev, "Frequency out of bounds\n"); | |
927 | - ret = -EINVAL; | |
928 | - goto err_out; | |
929 | - } | |
930 | - | |
931 | 939 | s->uart.owner = THIS_MODULE; |
932 | 940 | s->uart.dev_name = "ttySC"; |
933 | 941 | s->uart.major = SCCNXP_MAJOR; |
... | ... | @@ -959,7 +967,7 @@ |
959 | 967 | s->port[i].mapbase = res->start; |
960 | 968 | s->port[i].membase = membase; |
961 | 969 | s->port[i].regshift = s->pdata.reg_shift; |
962 | - s->port[i].uartclk = s->pdata.frequency; | |
970 | + s->port[i].uartclk = uartclk; | |
963 | 971 | s->port[i].ops = &sccnxp_ops; |
964 | 972 | uart_add_one_port(&s->uart, &s->port[i]); |
965 | 973 | /* Set direction to input */ |
include/linux/platform_data/serial-sccnxp.h
... | ... | @@ -60,7 +60,6 @@ |
60 | 60 | * }; |
61 | 61 | * |
62 | 62 | * static struct sccnxp_pdata sc2892_info = { |
63 | - * .frequency = 3686400, | |
64 | 63 | * .mctrl_cfg[0] = MCTRL_SIG(DIR_OP, LINE_OP0), |
65 | 64 | * .mctrl_cfg[1] = MCTRL_SIG(DIR_OP, LINE_OP1), |
66 | 65 | * }; |
... | ... | @@ -78,8 +77,6 @@ |
78 | 77 | |
79 | 78 | /* SCCNXP platform data structure */ |
80 | 79 | struct sccnxp_pdata { |
81 | - /* Frequency (extrenal clock or crystal) */ | |
82 | - int frequency; | |
83 | 80 | /* Shift for A0 line */ |
84 | 81 | const u8 reg_shift; |
85 | 82 | /* Modem control lines configuration */ |