xref: /linux/arch/mips/bcm47xx/serial.c (revision 0cce284537fb42d9c28b9b31038ffc9b464555f5)
11c0c13ebSAurelien Jarno /*
2*191084bcSPaul Gortmaker  * 8250 UART probe driver for the BCM47XX platforms
3*191084bcSPaul Gortmaker  * Author: Aurelien Jarno
4*191084bcSPaul Gortmaker  *
51c0c13ebSAurelien Jarno  * This file is subject to the terms and conditions of the GNU General Public
61c0c13ebSAurelien Jarno  * License.  See the file "COPYING" in the main directory of this archive
71c0c13ebSAurelien Jarno  * for more details.
81c0c13ebSAurelien Jarno  *
91c0c13ebSAurelien Jarno  * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
101c0c13ebSAurelien Jarno  */
111c0c13ebSAurelien Jarno 
121c0c13ebSAurelien Jarno #include <linux/init.h>
131c0c13ebSAurelien Jarno #include <linux/serial.h>
141c0c13ebSAurelien Jarno #include <linux/serial_8250.h>
151c0c13ebSAurelien Jarno #include <linux/ssb/ssb.h>
161c0c13ebSAurelien Jarno #include <bcm47xx.h>
171c0c13ebSAurelien Jarno 
181c0c13ebSAurelien Jarno static struct plat_serial8250_port uart8250_data[5];
191c0c13ebSAurelien Jarno 
201c0c13ebSAurelien Jarno static struct platform_device uart8250_device = {
211c0c13ebSAurelien Jarno 	.name			= "serial8250",
221c0c13ebSAurelien Jarno 	.id			= PLAT8250_DEV_PLATFORM,
231c0c13ebSAurelien Jarno 	.dev			= {
241c0c13ebSAurelien Jarno 		.platform_data	= uart8250_data,
251c0c13ebSAurelien Jarno 	},
261c0c13ebSAurelien Jarno };
271c0c13ebSAurelien Jarno 
28a656ffcbSHauke Mehrtens #ifdef CONFIG_BCM47XX_SSB
uart8250_init_ssb(void)2908ccf572SHauke Mehrtens static int __init uart8250_init_ssb(void)
301c0c13ebSAurelien Jarno {
311c0c13ebSAurelien Jarno 	int i;
3208ccf572SHauke Mehrtens 	struct ssb_mipscore *mcore = &(bcm47xx_bus.ssb.mipscore);
331c0c13ebSAurelien Jarno 
341c0c13ebSAurelien Jarno 	memset(&uart8250_data, 0,  sizeof(uart8250_data));
351c0c13ebSAurelien Jarno 
369cbeac05SHauke Mehrtens 	for (i = 0; i < mcore->nr_serial_ports &&
379cbeac05SHauke Mehrtens 		    i < ARRAY_SIZE(uart8250_data) - 1; i++) {
381c0c13ebSAurelien Jarno 		struct plat_serial8250_port *p = &(uart8250_data[i]);
391c0c13ebSAurelien Jarno 		struct ssb_serial_port *ssb_port = &(mcore->serial_ports[i]);
401c0c13ebSAurelien Jarno 
411c0c13ebSAurelien Jarno 		p->mapbase = (unsigned int)ssb_port->regs;
421c0c13ebSAurelien Jarno 		p->membase = (void *)ssb_port->regs;
431c0c13ebSAurelien Jarno 		p->irq = ssb_port->irq + 2;
441c0c13ebSAurelien Jarno 		p->uartclk = ssb_port->baud_base;
451c0c13ebSAurelien Jarno 		p->regshift = ssb_port->reg_shift;
461c0c13ebSAurelien Jarno 		p->iotype = UPIO_MEM;
471c0c13ebSAurelien Jarno 		p->flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
481c0c13ebSAurelien Jarno 	}
491c0c13ebSAurelien Jarno 	return platform_device_register(&uart8250_device);
501c0c13ebSAurelien Jarno }
51a656ffcbSHauke Mehrtens #endif
521c0c13ebSAurelien Jarno 
53c1d1c5d4SHauke Mehrtens #ifdef CONFIG_BCM47XX_BCMA
uart8250_init_bcma(void)54c1d1c5d4SHauke Mehrtens static int __init uart8250_init_bcma(void)
55c1d1c5d4SHauke Mehrtens {
56c1d1c5d4SHauke Mehrtens 	int i;
57c1d1c5d4SHauke Mehrtens 	struct bcma_drv_cc *cc = &(bcm47xx_bus.bcma.bus.drv_cc);
58c1d1c5d4SHauke Mehrtens 
59c1d1c5d4SHauke Mehrtens 	memset(&uart8250_data, 0,  sizeof(uart8250_data));
60c1d1c5d4SHauke Mehrtens 
619cbeac05SHauke Mehrtens 	for (i = 0; i < cc->nr_serial_ports &&
629cbeac05SHauke Mehrtens 		    i < ARRAY_SIZE(uart8250_data) - 1; i++) {
63c1d1c5d4SHauke Mehrtens 		struct plat_serial8250_port *p = &(uart8250_data[i]);
64c1d1c5d4SHauke Mehrtens 		struct bcma_serial_port *bcma_port;
65c1d1c5d4SHauke Mehrtens 		bcma_port = &(cc->serial_ports[i]);
66c1d1c5d4SHauke Mehrtens 
67c1d1c5d4SHauke Mehrtens 		p->mapbase = (unsigned int)bcma_port->regs;
68c1d1c5d4SHauke Mehrtens 		p->membase = (void *)bcma_port->regs;
69e2aa19faSNathan Hintz 		p->irq = bcma_port->irq;
70c1d1c5d4SHauke Mehrtens 		p->uartclk = bcma_port->baud_base;
71c1d1c5d4SHauke Mehrtens 		p->regshift = bcma_port->reg_shift;
72c1d1c5d4SHauke Mehrtens 		p->iotype = UPIO_MEM;
73c1d1c5d4SHauke Mehrtens 		p->flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
74c1d1c5d4SHauke Mehrtens 	}
75c1d1c5d4SHauke Mehrtens 	return platform_device_register(&uart8250_device);
76c1d1c5d4SHauke Mehrtens }
77c1d1c5d4SHauke Mehrtens #endif
78c1d1c5d4SHauke Mehrtens 
uart8250_init(void)7908ccf572SHauke Mehrtens static int __init uart8250_init(void)
8008ccf572SHauke Mehrtens {
8108ccf572SHauke Mehrtens 	switch (bcm47xx_bus_type) {
82a656ffcbSHauke Mehrtens #ifdef CONFIG_BCM47XX_SSB
8308ccf572SHauke Mehrtens 	case BCM47XX_BUS_TYPE_SSB:
8408ccf572SHauke Mehrtens 		return uart8250_init_ssb();
85a656ffcbSHauke Mehrtens #endif
86c1d1c5d4SHauke Mehrtens #ifdef CONFIG_BCM47XX_BCMA
87c1d1c5d4SHauke Mehrtens 	case BCM47XX_BUS_TYPE_BCMA:
88c1d1c5d4SHauke Mehrtens 		return uart8250_init_bcma();
89c1d1c5d4SHauke Mehrtens #endif
9008ccf572SHauke Mehrtens 	}
9108ccf572SHauke Mehrtens 	return -EINVAL;
9208ccf572SHauke Mehrtens }
93*191084bcSPaul Gortmaker device_initcall(uart8250_init);
94