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

pmac-zilog: add platform driver

Add platform driver support to the pmac-zilog driver, for m68k macs.
Place the powermac-specific code inside #ifdef CONFIG_PPC_PMAC.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

authored by

Finn Thain and committed by
Geert Uytterhoeven
ec9cbe09 1f7b5fff

+166 -25
+5
arch/m68k/configs/mac_defconfig
··· 701 701 # 702 702 # Non-8250 serial port support 703 703 # 704 + CONFIG_SERIAL_CORE=y 705 + CONFIG_SERIAL_CORE_CONSOLE=y 706 + CONFIG_SERIAL_PMACZILOG=y 707 + CONFIG_SERIAL_PMACZILOG_TTYS=y 708 + CONFIG_SERIAL_PMACZILOG_CONSOLE=y 704 709 CONFIG_UNIX98_PTYS=y 705 710 # CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set 706 711 CONFIG_LEGACY_PTYS=y
+5
arch/m68k/configs/multi_defconfig
··· 822 822 # 823 823 # Non-8250 serial port support 824 824 # 825 + CONFIG_SERIAL_CORE=y 826 + CONFIG_SERIAL_CORE_CONSOLE=y 827 + CONFIG_SERIAL_PMACZILOG=y 828 + CONFIG_SERIAL_PMACZILOG_TTYS=y 829 + CONFIG_SERIAL_PMACZILOG_CONSOLE=y 825 830 CONFIG_UNIX98_PTYS=y 826 831 # CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set 827 832 CONFIG_LEGACY_PTYS=y
+6 -6
drivers/serial/Kconfig
··· 1086 1086 default y 1087 1087 1088 1088 config SERIAL_PMACZILOG 1089 - tristate "PowerMac z85c30 ESCC support" 1090 - depends on PPC_OF && PPC_PMAC 1089 + tristate "Mac or PowerMac z85c30 ESCC support" 1090 + depends on (M68K && MAC) || (PPC_OF && PPC_PMAC) 1091 1091 select SERIAL_CORE 1092 1092 help 1093 1093 This driver supports the Zilog z85C30 serial ports found on 1094 - PowerMac machines. 1094 + (Power)Mac machines. 1095 1095 Say Y or M if you want to be able to these serial ports. 1096 1096 1097 1097 config SERIAL_PMACZILOG_TTYS ··· 1116 1116 unable to use the 8250 module for PCMCIA or other 16C550-style 1117 1117 UARTs. 1118 1118 1119 - Say N unless you need the z85c30 ports on your powermac 1119 + Say N unless you need the z85c30 ports on your (Power)Mac 1120 1120 to appear as /dev/ttySn. 1121 1121 1122 1122 config SERIAL_PMACZILOG_CONSOLE 1123 - bool "Console on PowerMac z85c30 serial port" 1123 + bool "Console on Mac or PowerMac z85c30 serial port" 1124 1124 depends on SERIAL_PMACZILOG=y 1125 1125 select SERIAL_CORE_CONSOLE 1126 1126 help 1127 1127 If you would like to be able to use the z85c30 serial port 1128 - on your PowerMac as the console, you can do so by answering 1128 + on your (Power)Mac as the console, you can do so by answering 1129 1129 Y to this option. 1130 1130 1131 1131 config SERIAL_LH7A40X
+136 -19
drivers/serial/pmac_zilog.c
··· 63 63 #include <asm/sections.h> 64 64 #include <asm/io.h> 65 65 #include <asm/irq.h> 66 + 67 + #ifdef CONFIG_PPC_PMAC 66 68 #include <asm/prom.h> 67 69 #include <asm/machdep.h> 68 70 #include <asm/pmac_feature.h> 69 71 #include <asm/dbdma.h> 70 72 #include <asm/macio.h> 73 + #else 74 + #include <linux/platform_device.h> 75 + #define of_machine_is_compatible(x) (0) 76 + #endif 71 77 72 78 #if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 73 79 #define SUPPORT_SYSRQ ··· 89 83 90 84 static char version[] __initdata = "pmac_zilog: 0.6 (Benjamin Herrenschmidt <benh@kernel.crashing.org>)"; 91 85 MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>"); 92 - MODULE_DESCRIPTION("Driver for the PowerMac serial ports."); 86 + MODULE_DESCRIPTION("Driver for the Mac and PowerMac serial ports."); 93 87 MODULE_LICENSE("GPL"); 94 - 95 - #define PWRDBG(fmt, arg...) printk(KERN_DEBUG fmt , ## arg) 96 88 97 89 #ifdef CONFIG_SERIAL_PMACZILOG_TTYS 98 90 #define PMACZILOG_MAJOR TTY_MAJOR ··· 345 341 uap->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK); 346 342 write_zsreg(uap, R1, uap->curregs[R1]); 347 343 zssync(uap); 348 - dev_err(&uap->dev->ofdev.dev, "pmz: rx irq flood !\n"); 344 + pmz_error("pmz: rx irq flood !\n"); 349 345 return tty; 350 346 } 351 347 ··· 761 757 spin_unlock_irqrestore(&port->lock, flags); 762 758 } 763 759 760 + #ifdef CONFIG_PPC_PMAC 761 + 764 762 /* 765 763 * Turn power on or off to the SCC and associated stuff 766 764 * (port drivers, modem, IR port, etc.) ··· 797 791 } 798 792 return delay; 799 793 } 794 + 795 + #else 796 + 797 + static int pmz_set_scc_power(struct uart_pmac_port *uap, int state) 798 + { 799 + return 0; 800 + } 801 + 802 + #endif /* !CONFIG_PPC_PMAC */ 800 803 801 804 /* 802 805 * FixZeroBug....Works around a bug in the SCC receving channel. ··· 969 954 } 970 955 971 956 pmz_get_port_A(uap)->flags |= PMACZILOG_FLAG_IS_IRQ_ON; 972 - if (request_irq(uap->port.irq, pmz_interrupt, IRQF_SHARED, "PowerMac Zilog", uap)) { 973 - dev_err(&uap->dev->ofdev.dev, 974 - "Unable to register zs interrupt handler.\n"); 957 + if (request_irq(uap->port.irq, pmz_interrupt, IRQF_SHARED, 958 + "SCC", uap)) { 959 + pmz_error("Unable to register zs interrupt handler.\n"); 975 960 pmz_set_scc_power(uap, 0); 976 961 mutex_unlock(&pmz_irq_mutex); 977 962 return -ENXIO; ··· 1211 1196 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0 1212 1197 || (read_zsreg(uap, R1) & ALL_SNT) == 0) { 1213 1198 if (--t <= 0) { 1214 - dev_err(&uap->dev->ofdev.dev, "transmitter didn't drain\n"); 1199 + pmz_error("transmitter didn't drain\n"); 1215 1200 return; 1216 1201 } 1217 1202 udelay(10); ··· 1227 1212 read_zsdata(uap); 1228 1213 mdelay(10); 1229 1214 if (--t <= 0) { 1230 - dev_err(&uap->dev->ofdev.dev, "receiver didn't drain\n"); 1215 + pmz_error("receiver didn't drain\n"); 1231 1216 return; 1232 1217 } 1233 1218 } ··· 1248 1233 t = 5000; 1249 1234 while ((read_zsreg(uap, R0) & Rx_CH_AV) == 0) { 1250 1235 if (--t <= 0) { 1251 - dev_err(&uap->dev->ofdev.dev, 1252 - "irda_setup timed out on get_version byte\n"); 1236 + pmz_error("irda_setup timed out on get_version byte\n"); 1253 1237 goto out; 1254 1238 } 1255 1239 udelay(10); ··· 1256 1242 version = read_zsdata(uap); 1257 1243 1258 1244 if (version < 4) { 1259 - dev_info(&uap->dev->ofdev.dev, "IrDA: dongle version %d not supported\n", 1260 - version); 1245 + pmz_info("IrDA: dongle version %d not supported\n", version); 1261 1246 goto out; 1262 1247 } 1263 1248 ··· 1265 1252 t = 5000; 1266 1253 while ((read_zsreg(uap, R0) & Rx_CH_AV) == 0) { 1267 1254 if (--t <= 0) { 1268 - dev_err(&uap->dev->ofdev.dev, 1269 - "irda_setup timed out on speed mode byte\n"); 1255 + pmz_error("irda_setup timed out on speed mode byte\n"); 1270 1256 goto out; 1271 1257 } 1272 1258 udelay(10); 1273 1259 } 1274 1260 t = read_zsdata(uap); 1275 1261 if (t != cmdbyte) 1276 - dev_err(&uap->dev->ofdev.dev, 1277 - "irda_setup speed mode byte = %x (%x)\n", t, cmdbyte); 1262 + pmz_error("irda_setup speed mode byte = %x (%x)\n", t, cmdbyte); 1278 1263 1279 - dev_info(&uap->dev->ofdev.dev, "IrDA setup for %ld bps, dongle version: %d\n", 1264 + pmz_info("IrDA setup for %ld bps, dongle version: %d\n", 1280 1265 *baud, version); 1281 1266 1282 1267 (void)read_zsdata(uap); ··· 1424 1413 write_zsdata(uap, c); 1425 1414 } 1426 1415 1427 - #endif 1416 + #endif /* CONFIG_CONSOLE_POLL */ 1428 1417 1429 1418 static struct uart_ops pmz_pops = { 1430 1419 .tx_empty = pmz_tx_empty, ··· 1448 1437 .poll_put_char = pmz_poll_put_char, 1449 1438 #endif 1450 1439 }; 1440 + 1441 + #ifdef CONFIG_PPC_PMAC 1451 1442 1452 1443 /* 1453 1444 * Setup one port structure after probing, HW is down at this point, ··· 1847 1834 return 0; 1848 1835 } 1849 1836 1837 + #else 1838 + 1839 + extern struct platform_device scc_a_pdev, scc_b_pdev; 1840 + 1841 + static int __init pmz_init_port(struct uart_pmac_port *uap) 1842 + { 1843 + struct resource *r_ports; 1844 + int irq; 1845 + 1846 + r_ports = platform_get_resource(uap->node, IORESOURCE_MEM, 0); 1847 + irq = platform_get_irq(uap->node, 0); 1848 + if (!r_ports || !irq) 1849 + return -ENODEV; 1850 + 1851 + uap->port.mapbase = r_ports->start; 1852 + uap->port.membase = (unsigned char __iomem *) r_ports->start; 1853 + uap->port.iotype = UPIO_MEM; 1854 + uap->port.irq = irq; 1855 + uap->port.uartclk = ZS_CLOCK; 1856 + uap->port.fifosize = 1; 1857 + uap->port.ops = &pmz_pops; 1858 + uap->port.type = PORT_PMAC_ZILOG; 1859 + uap->port.flags = 0; 1860 + 1861 + uap->control_reg = uap->port.membase; 1862 + uap->data_reg = uap->control_reg + 4; 1863 + uap->port_type = 0; 1864 + 1865 + pmz_convert_to_zs(uap, CS8, 0, 9600); 1866 + 1867 + return 0; 1868 + } 1869 + 1870 + static int __init pmz_probe(void) 1871 + { 1872 + int err; 1873 + 1874 + pmz_ports_count = 0; 1875 + 1876 + pmz_ports[0].mate = &pmz_ports[1]; 1877 + pmz_ports[0].port.line = 0; 1878 + pmz_ports[0].flags = PMACZILOG_FLAG_IS_CHANNEL_A; 1879 + pmz_ports[0].node = &scc_a_pdev; 1880 + err = pmz_init_port(&pmz_ports[0]); 1881 + if (err) 1882 + return err; 1883 + pmz_ports_count++; 1884 + 1885 + pmz_ports[1].mate = &pmz_ports[0]; 1886 + pmz_ports[1].port.line = 1; 1887 + pmz_ports[1].flags = 0; 1888 + pmz_ports[1].node = &scc_b_pdev; 1889 + err = pmz_init_port(&pmz_ports[1]); 1890 + if (err) 1891 + return err; 1892 + pmz_ports_count++; 1893 + 1894 + return 0; 1895 + } 1896 + 1897 + static void pmz_dispose_port(struct uart_pmac_port *uap) 1898 + { 1899 + memset(uap, 0, sizeof(struct uart_pmac_port)); 1900 + } 1901 + 1902 + static int __init pmz_attach(struct platform_device *pdev) 1903 + { 1904 + int i; 1905 + 1906 + for (i = 0; i < pmz_ports_count; i++) 1907 + if (pmz_ports[i].node == pdev) 1908 + return 0; 1909 + return -ENODEV; 1910 + } 1911 + 1912 + static int __exit pmz_detach(struct platform_device *pdev) 1913 + { 1914 + return 0; 1915 + } 1916 + 1917 + #endif /* !CONFIG_PPC_PMAC */ 1918 + 1850 1919 #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE 1851 1920 1852 1921 static void pmz_console_write(struct console *con, const char *s, unsigned int count); ··· 1989 1894 return rc; 1990 1895 } 1991 1896 1897 + #ifdef CONFIG_PPC_PMAC 1898 + 1992 1899 static struct of_device_id pmz_match[] = 1993 1900 { 1994 1901 { ··· 2011 1914 .suspend = pmz_suspend, 2012 1915 .resume = pmz_resume, 2013 1916 }; 1917 + 1918 + #else 1919 + 1920 + static struct platform_driver pmz_driver = { 1921 + .remove = __exit_p(pmz_detach), 1922 + .driver = { 1923 + .name = "scc", 1924 + .owner = THIS_MODULE, 1925 + }, 1926 + }; 1927 + 1928 + #endif /* !CONFIG_PPC_PMAC */ 2014 1929 2015 1930 static int __init init_pmz(void) 2016 1931 { ··· 2062 1953 /* 2063 1954 * Then we register the macio driver itself 2064 1955 */ 1956 + #ifdef CONFIG_PPC_PMAC 2065 1957 return macio_register_driver(&pmz_driver); 1958 + #else 1959 + return platform_driver_probe(&pmz_driver, pmz_attach); 1960 + #endif 2066 1961 } 2067 1962 2068 1963 static void __exit exit_pmz(void) 2069 1964 { 2070 1965 int i; 2071 1966 1967 + #ifdef CONFIG_PPC_PMAC 2072 1968 /* Get rid of macio-driver (detach from macio) */ 2073 1969 macio_unregister_driver(&pmz_driver); 1970 + #else 1971 + platform_driver_unregister(&pmz_driver); 1972 + #endif 2074 1973 2075 1974 for (i = 0; i < pmz_ports_count; i++) { 2076 1975 struct uart_pmac_port *uport = &pmz_ports[i];
+14
drivers/serial/pmac_zilog.h
··· 1 1 #ifndef __PMAC_ZILOG_H__ 2 2 #define __PMAC_ZILOG_H__ 3 3 4 + #ifdef CONFIG_PPC_PMAC 4 5 #define pmz_debug(fmt, arg...) dev_dbg(&uap->dev->ofdev.dev, fmt, ## arg) 6 + #define pmz_error(fmt, arg...) dev_err(&uap->dev->ofdev.dev, fmt, ## arg) 7 + #define pmz_info(fmt, arg...) dev_info(&uap->dev->ofdev.dev, fmt, ## arg) 8 + #else 9 + #define pmz_debug(fmt, arg...) dev_dbg(&uap->node->dev, fmt, ## arg) 10 + #define pmz_error(fmt, arg...) dev_err(&uap->node->dev, fmt, ## arg) 11 + #define pmz_info(fmt, arg...) dev_info(&uap->node->dev, fmt, ## arg) 12 + #endif 5 13 6 14 /* 7 15 * At most 2 ESCCs with 2 ports each ··· 25 17 struct uart_port port; 26 18 struct uart_pmac_port *mate; 27 19 20 + #ifdef CONFIG_PPC_PMAC 28 21 /* macio_dev for the escc holding this port (maybe be null on 29 22 * early inited port) 30 23 */ ··· 34 25 * of "escc" node (ie. ch-a or ch-b) 35 26 */ 36 27 struct device_node *node; 28 + #else 29 + struct platform_device *node; 30 + #endif 37 31 38 32 /* Port type as obtained from device tree (IRDA, modem, ...) */ 39 33 int port_type; ··· 67 55 volatile u8 __iomem *control_reg; 68 56 volatile u8 __iomem *data_reg; 69 57 58 + #ifdef CONFIG_PPC_PMAC 70 59 unsigned int tx_dma_irq; 71 60 unsigned int rx_dma_irq; 72 61 volatile struct dbdma_regs __iomem *tx_dma_regs; 73 62 volatile struct dbdma_regs __iomem *rx_dma_regs; 63 + #endif 74 64 75 65 struct ktermios termios_cache; 76 66 };