Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: sh-sci: Dynamic clock management depends on HAVE_CLK.

Presently this is conditionalized on sh, and disabled for sh64.
Now that SH-5 ties in to the clock framework, the sh64 exception
can be dropped. Additionally, ARM will want to use the same hooks
once SH-Mobile G3 grows clock framework support, so switch these
paths over to HAVE_CLK now.

Once the H8 and ARM sh-sci users hook up HAVE_CLK, the driver can
be switched over to having an outright dependency on it and the
ifdefs can go away.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

+16 -31
+15 -28
drivers/serial/sh-sci.c
··· 78 78 struct timer_list break_timer; 79 79 int break_flag; 80 80 81 - #ifdef CONFIG_SUPERH 81 + #ifdef CONFIG_HAVE_CLK 82 82 /* Port clock */ 83 83 struct clk *clk; 84 84 #endif ··· 831 831 return IRQ_HANDLED; 832 832 } 833 833 834 - #ifdef CONFIG_CPU_FREQ 834 + #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_HAVE_CLK) 835 835 /* 836 836 * Here we define a transistion notifier so that we can update all of our 837 837 * ports' baud rate when the peripheral clock changes. ··· 860 860 * Clean this up later.. 861 861 */ 862 862 clk = clk_get(NULL, "module_clk"); 863 - port->uartclk = clk_get_rate(clk) * 16; 863 + port->uartclk = clk_get_rate(clk); 864 864 clk_put(clk); 865 865 } 866 866 ··· 873 873 } 874 874 875 875 static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 }; 876 - #endif /* CONFIG_CPU_FREQ */ 876 + #endif /* CONFIG_CPU_FREQ && CONFIG_HAVE_CLK */ 877 877 878 878 static int sci_request_irq(struct sci_port *port) 879 879 { ··· 1008 1008 if (s->enable) 1009 1009 s->enable(port); 1010 1010 1011 - #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 1011 + #ifdef CONFIG_HAVE_CLK 1012 1012 s->clk = clk_get(NULL, "module_clk"); 1013 1013 #endif 1014 1014 ··· 1030 1030 if (s->disable) 1031 1031 s->disable(port); 1032 1032 1033 - #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 1033 + #ifdef CONFIG_HAVE_CLK 1034 1034 clk_put(s->clk); 1035 1035 s->clk = NULL; 1036 1036 #endif ··· 1041 1041 { 1042 1042 struct sci_port *s = &sci_ports[port->line]; 1043 1043 unsigned int status, baud, smr_val; 1044 - int t; 1044 + int t = -1; 1045 1045 1046 1046 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 1047 - 1048 - switch (baud) { 1049 - case 0: 1050 - t = -1; 1051 - break; 1052 - default: 1053 - { 1054 - #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 1055 - t = SCBRR_VALUE(baud, clk_get_rate(s->clk)); 1056 - #else 1057 - t = SCBRR_VALUE(baud); 1058 - #endif 1059 - break; 1060 - } 1061 - } 1047 + if (likely(baud)) 1048 + t = SCBRR_VALUE(baud, port->uartclk); 1062 1049 1063 1050 do { 1064 1051 status = sci_in(port, SCxSR); ··· 1194 1207 sci_ports[i].disable = h8300_sci_disable; 1195 1208 #endif 1196 1209 sci_ports[i].port.uartclk = CONFIG_CPU_CLOCK; 1197 - #elif defined(CONFIG_SUPERH64) 1198 - sci_ports[i].port.uartclk = current_cpu_data.module_clock * 16; 1199 - #else 1210 + #elif defined(CONFIG_HAVE_CLK) 1200 1211 /* 1201 1212 * XXX: We should use a proper SCI/SCIF clock 1202 1213 */ 1203 1214 { 1204 1215 struct clk *clk = clk_get(NULL, "module_clk"); 1205 - sci_ports[i].port.uartclk = clk_get_rate(clk) * 16; 1216 + sci_ports[i].port.uartclk = clk_get_rate(clk); 1206 1217 clk_put(clk); 1207 1218 } 1219 + #else 1220 + #error "Need a valid uartclk" 1208 1221 #endif 1209 1222 1210 1223 sci_ports[i].break_timer.data = (unsigned long)&sci_ports[i]; ··· 1272 1285 1273 1286 port->type = serial_console_port->type; 1274 1287 1275 - #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 1288 + #ifdef CONFIG_HAVE_CLK 1276 1289 if (!serial_console_port->clk) 1277 1290 serial_console_port->clk = clk_get(NULL, "module_clk"); 1278 1291 #endif ··· 1466 1479 kgdb_putchar = kgdb_sci_putchar; 1467 1480 #endif 1468 1481 1469 - #ifdef CONFIG_CPU_FREQ 1482 + #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_HAVE_CLK) 1470 1483 cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER); 1471 1484 dev_info(&dev->dev, "CPU frequency notifier registered\n"); 1472 1485 #endif
+1 -3
drivers/serial/sh-sci.h
··· 793 793 #elif defined(CONFIG_CPU_SUBTYPE_SH7723) 794 794 #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(16*bps)-1) 795 795 #elif defined(__H8300H__) || defined(__H8300S__) 796 - #define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1) 797 - #elif defined(CONFIG_SUPERH64) 798 - #define SCBRR_VALUE(bps) ((current_cpu_data.module_clock+16*bps)/(32*bps)-1) 796 + #define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1) 799 797 #else /* Generic SH */ 800 798 #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) 801 799 #endif