aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorLoic Poulain <loic.poulain@intel.com>2014-04-24 05:46:14 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-24 19:13:01 -0400
commitc439c33d85e252d3b2b454ab7ba38b62d6e0a830 (patch)
treeddd02313e4e32aaade754035a1366e575cb0389f /drivers/tty
parent50d16ca29bd2ccbca08e4f74fe1d9618c735c22f (diff)
8250_dw: Support all baudrates on baytrail
In the same manner as 8250_pci, 8250_dw needs some baytrail specific quirks to be used. The reference clock needs to be adjusted before divided in order to have the minimum error rate on the baudrate. The specific byt set termios function is stored in the driver_data field of the acpi device id via the dw8250_acpi_desc structure. Remove the uartclk field which is no longer delivered as driver data. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/8250/8250_dw.c81
1 files changed, 77 insertions, 4 deletions
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index ed3113576740..51b307aab75e 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -62,6 +62,70 @@ struct dw8250_data {
62 struct uart_8250_dma dma; 62 struct uart_8250_dma dma;
63}; 63};
64 64
65struct dw8250_acpi_desc {
66 void (*set_termios)(struct uart_port *p, struct ktermios *termios,
67 struct ktermios *old);
68};
69
70#define BYT_PRV_CLK 0x800
71#define BYT_PRV_CLK_EN (1 << 0)
72#define BYT_PRV_CLK_M_VAL_SHIFT 1
73#define BYT_PRV_CLK_N_VAL_SHIFT 16
74#define BYT_PRV_CLK_UPDATE (1 << 31)
75
76static void byt_set_termios(struct uart_port *p, struct ktermios *termios,
77 struct ktermios *old)
78{
79 unsigned int baud = tty_termios_baud_rate(termios);
80 unsigned int m, n;
81 u32 reg;
82
83 /*
84 * For baud rates 0.5M, 1M, 1.5M, 2M, 2.5M, 3M, 3.5M and 4M the
85 * dividers must be adjusted.
86 *
87 * uartclk = (m / n) * 100 MHz, where m <= n
88 */
89 switch (baud) {
90 case 500000:
91 case 1000000:
92 case 2000000:
93 case 4000000:
94 m = 64;
95 n = 100;
96 p->uartclk = 64000000;
97 break;
98 case 3500000:
99 m = 56;
100 n = 100;
101 p->uartclk = 56000000;
102 break;
103 case 1500000:
104 case 3000000:
105 m = 48;
106 n = 100;
107 p->uartclk = 48000000;
108 break;
109 case 2500000:
110 m = 40;
111 n = 100;
112 p->uartclk = 40000000;
113 break;
114 default:
115 m = 2304;
116 n = 3125;
117 p->uartclk = 73728000;
118 }
119
120 /* Reset the clock */
121 reg = (m << BYT_PRV_CLK_M_VAL_SHIFT) | (n << BYT_PRV_CLK_N_VAL_SHIFT);
122 writel(reg, p->membase + BYT_PRV_CLK);
123 reg |= BYT_PRV_CLK_EN | BYT_PRV_CLK_UPDATE;
124 writel(reg, p->membase + BYT_PRV_CLK);
125
126 serial8250_do_set_termios(p, termios, old);
127}
128
65static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value) 129static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
66{ 130{
67 struct dw8250_data *d = p->private_data; 131 struct dw8250_data *d = p->private_data;
@@ -278,6 +342,7 @@ static int dw8250_probe_acpi(struct uart_8250_port *up,
278{ 342{
279 const struct acpi_device_id *id; 343 const struct acpi_device_id *id;
280 struct uart_port *p = &up->port; 344 struct uart_port *p = &up->port;
345 struct dw8250_acpi_desc *acpi_desc;
281 346
282 dw8250_setup_port(up); 347 dw8250_setup_port(up);
283 348
@@ -290,14 +355,18 @@ static int dw8250_probe_acpi(struct uart_8250_port *up,
290 p->serial_out = dw8250_serial_out32; 355 p->serial_out = dw8250_serial_out32;
291 p->regshift = 2; 356 p->regshift = 2;
292 357
293 if (!p->uartclk)
294 p->uartclk = (unsigned int)id->driver_data;
295
296 up->dma = &data->dma; 358 up->dma = &data->dma;
297 359
298 up->dma->rxconf.src_maxburst = p->fifosize / 4; 360 up->dma->rxconf.src_maxburst = p->fifosize / 4;
299 up->dma->txconf.dst_maxburst = p->fifosize / 4; 361 up->dma->txconf.dst_maxburst = p->fifosize / 4;
300 362
363 acpi_desc = (struct dw8250_acpi_desc *)id->driver_data;
364 if (!acpi_desc)
365 return 0;
366
367 if (acpi_desc->set_termios)
368 p->set_termios = acpi_desc->set_termios;
369
301 return 0; 370 return 0;
302} 371}
303 372
@@ -445,12 +514,16 @@ static const struct of_device_id dw8250_of_match[] = {
445}; 514};
446MODULE_DEVICE_TABLE(of, dw8250_of_match); 515MODULE_DEVICE_TABLE(of, dw8250_of_match);
447 516
517static struct dw8250_acpi_desc byt_8250_desc = {
518 .set_termios = byt_set_termios,
519};
520
448static const struct acpi_device_id dw8250_acpi_match[] = { 521static const struct acpi_device_id dw8250_acpi_match[] = {
449 { "INT33C4", 0 }, 522 { "INT33C4", 0 },
450 { "INT33C5", 0 }, 523 { "INT33C5", 0 },
451 { "INT3434", 0 }, 524 { "INT3434", 0 },
452 { "INT3435", 0 }, 525 { "INT3435", 0 },
453 { "80860F0A", 0 }, 526 { "80860F0A", (kernel_ulong_t)&byt_8250_desc},
454 { }, 527 { },
455}; 528};
456MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match); 529MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);