diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2013-07-31 06:56:30 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-31 21:08:01 -0400 |
commit | 90efa75f7ab0be5677f0cca155dbf0b39eacdd03 (patch) | |
tree | ac34963f6bf548224e5ac484832be5089d3943c7 /drivers/tty/serial/sccnxp.c | |
parent | e087ab74f3dd30105041e1c68db209f235b63042 (diff) |
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>
Diffstat (limited to 'drivers/tty/serial/sccnxp.c')
-rw-r--r-- | drivers/tty/serial/sccnxp.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c index 12a5c265f43a..81e70477e6fd 100644 --- a/drivers/tty/serial/sccnxp.c +++ b/drivers/tty/serial/sccnxp.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #define SUPPORT_SYSRQ | 15 | #define SUPPORT_SYSRQ |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | #include <linux/clk.h> | ||
18 | #include <linux/err.h> | 19 | #include <linux/err.h> |
19 | #include <linux/module.h> | 20 | #include <linux/module.h> |
20 | #include <linux/device.h> | 21 | #include <linux/device.h> |
@@ -783,9 +784,10 @@ static int sccnxp_probe(struct platform_device *pdev) | |||
783 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 784 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
784 | int chiptype = pdev->id_entry->driver_data; | 785 | int chiptype = pdev->id_entry->driver_data; |
785 | struct sccnxp_pdata *pdata = dev_get_platdata(&pdev->dev); | 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 | struct sccnxp_port *s; | 788 | struct sccnxp_port *s; |
788 | void __iomem *membase; | 789 | void __iomem *membase; |
790 | struct clk *clk; | ||
789 | 791 | ||
790 | membase = devm_ioremap_resource(&pdev->dev, res); | 792 | membase = devm_ioremap_resource(&pdev->dev, res); |
791 | if (IS_ERR(membase)) | 793 | if (IS_ERR(membase)) |
@@ -898,11 +900,25 @@ static int sccnxp_probe(struct platform_device *pdev) | |||
898 | } else if (PTR_ERR(s->regulator) == -EPROBE_DEFER) | 900 | } else if (PTR_ERR(s->regulator) == -EPROBE_DEFER) |
899 | return -EPROBE_DEFER; | 901 | return -EPROBE_DEFER; |
900 | 902 | ||
901 | if (!pdata) { | 903 | clk = devm_clk_get(&pdev->dev, NULL); |
902 | dev_warn(&pdev->dev, | 904 | if (IS_ERR(clk)) { |
903 | "No platform data supplied, using defaults\n"); | 905 | if (PTR_ERR(clk) == -EPROBE_DEFER) { |
904 | s->pdata.frequency = s->freq_std; | 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 | } else | 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 | memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata)); | 922 | memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata)); |
907 | 923 | ||
908 | if (s->pdata.poll_time_us) { | 924 | if (s->pdata.poll_time_us) { |
@@ -920,14 +936,6 @@ static int sccnxp_probe(struct platform_device *pdev) | |||
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 | s->uart.owner = THIS_MODULE; | 939 | s->uart.owner = THIS_MODULE; |
932 | s->uart.dev_name = "ttySC"; | 940 | s->uart.dev_name = "ttySC"; |
933 | s->uart.major = SCCNXP_MAJOR; | 941 | s->uart.major = SCCNXP_MAJOR; |
@@ -959,7 +967,7 @@ static int sccnxp_probe(struct platform_device *pdev) | |||
959 | s->port[i].mapbase = res->start; | 967 | s->port[i].mapbase = res->start; |
960 | s->port[i].membase = membase; | 968 | s->port[i].membase = membase; |
961 | s->port[i].regshift = s->pdata.reg_shift; | 969 | s->port[i].regshift = s->pdata.reg_shift; |
962 | s->port[i].uartclk = s->pdata.frequency; | 970 | s->port[i].uartclk = uartclk; |
963 | s->port[i].ops = &sccnxp_ops; | 971 | s->port[i].ops = &sccnxp_ops; |
964 | uart_add_one_port(&s->uart, &s->port[i]); | 972 | uart_add_one_port(&s->uart, &s->port[i]); |
965 | /* Set direction to input */ | 973 | /* Set direction to input */ |