aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/sni/a20r.c1
-rw-r--r--drivers/tty/serial/sccnxp.c36
-rw-r--r--include/linux/platform_data/serial-sccnxp.h3
3 files changed, 22 insertions, 18 deletions
diff --git a/arch/mips/sni/a20r.c b/arch/mips/sni/a20r.c
index dd0ab982d77e..f9407e170476 100644
--- a/arch/mips/sni/a20r.c
+++ b/arch/mips/sni/a20r.c
@@ -122,7 +122,6 @@ static struct resource sc26xx_rsrc[] = {
122 122
123static struct sccnxp_pdata sccnxp_data = { 123static struct sccnxp_pdata sccnxp_data = {
124 .reg_shift = 2, 124 .reg_shift = 2,
125 .frequency = 3686400,
126 .mctrl_cfg[0] = MCTRL_SIG(DTR_OP, LINE_OP7) | 125 .mctrl_cfg[0] = MCTRL_SIG(DTR_OP, LINE_OP7) |
127 MCTRL_SIG(RTS_OP, LINE_OP3) | 126 MCTRL_SIG(RTS_OP, LINE_OP3) |
128 MCTRL_SIG(DSR_IP, LINE_IP5) | 127 MCTRL_SIG(DSR_IP, LINE_IP5) |
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 */
diff --git a/include/linux/platform_data/serial-sccnxp.h b/include/linux/platform_data/serial-sccnxp.h
index bdc510d03245..af0c8c3b89ae 100644
--- a/include/linux/platform_data/serial-sccnxp.h
+++ b/include/linux/platform_data/serial-sccnxp.h
@@ -60,7 +60,6 @@
60 * }; 60 * };
61 * 61 *
62 * static struct sccnxp_pdata sc2892_info = { 62 * static struct sccnxp_pdata sc2892_info = {
63 * .frequency = 3686400,
64 * .mctrl_cfg[0] = MCTRL_SIG(DIR_OP, LINE_OP0), 63 * .mctrl_cfg[0] = MCTRL_SIG(DIR_OP, LINE_OP0),
65 * .mctrl_cfg[1] = MCTRL_SIG(DIR_OP, LINE_OP1), 64 * .mctrl_cfg[1] = MCTRL_SIG(DIR_OP, LINE_OP1),
66 * }; 65 * };
@@ -78,8 +77,6 @@
78 77
79/* SCCNXP platform data structure */ 78/* SCCNXP platform data structure */
80struct sccnxp_pdata { 79struct sccnxp_pdata {
81 /* Frequency (extrenal clock or crystal) */
82 int frequency;
83 /* Shift for A0 line */ 80 /* Shift for A0 line */
84 const u8 reg_shift; 81 const u8 reg_shift;
85 /* Modem control lines configuration */ 82 /* Modem control lines configuration */