0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/init.h>
0013 #include <linux/serial.h>
0014 #include <linux/serial_8250.h>
0015 #include <linux/ssb/ssb.h>
0016 #include <bcm47xx.h>
0017
0018 static struct plat_serial8250_port uart8250_data[5];
0019
0020 static struct platform_device uart8250_device = {
0021 .name = "serial8250",
0022 .id = PLAT8250_DEV_PLATFORM,
0023 .dev = {
0024 .platform_data = uart8250_data,
0025 },
0026 };
0027
0028 #ifdef CONFIG_BCM47XX_SSB
0029 static int __init uart8250_init_ssb(void)
0030 {
0031 int i;
0032 struct ssb_mipscore *mcore = &(bcm47xx_bus.ssb.mipscore);
0033
0034 memset(&uart8250_data, 0, sizeof(uart8250_data));
0035
0036 for (i = 0; i < mcore->nr_serial_ports &&
0037 i < ARRAY_SIZE(uart8250_data) - 1; i++) {
0038 struct plat_serial8250_port *p = &(uart8250_data[i]);
0039 struct ssb_serial_port *ssb_port = &(mcore->serial_ports[i]);
0040
0041 p->mapbase = (unsigned int)ssb_port->regs;
0042 p->membase = (void *)ssb_port->regs;
0043 p->irq = ssb_port->irq + 2;
0044 p->uartclk = ssb_port->baud_base;
0045 p->regshift = ssb_port->reg_shift;
0046 p->iotype = UPIO_MEM;
0047 p->flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
0048 }
0049 return platform_device_register(&uart8250_device);
0050 }
0051 #endif
0052
0053 #ifdef CONFIG_BCM47XX_BCMA
0054 static int __init uart8250_init_bcma(void)
0055 {
0056 int i;
0057 struct bcma_drv_cc *cc = &(bcm47xx_bus.bcma.bus.drv_cc);
0058
0059 memset(&uart8250_data, 0, sizeof(uart8250_data));
0060
0061 for (i = 0; i < cc->nr_serial_ports &&
0062 i < ARRAY_SIZE(uart8250_data) - 1; i++) {
0063 struct plat_serial8250_port *p = &(uart8250_data[i]);
0064 struct bcma_serial_port *bcma_port;
0065 bcma_port = &(cc->serial_ports[i]);
0066
0067 p->mapbase = (unsigned int)bcma_port->regs;
0068 p->membase = (void *)bcma_port->regs;
0069 p->irq = bcma_port->irq;
0070 p->uartclk = bcma_port->baud_base;
0071 p->regshift = bcma_port->reg_shift;
0072 p->iotype = UPIO_MEM;
0073 p->flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
0074 }
0075 return platform_device_register(&uart8250_device);
0076 }
0077 #endif
0078
0079 static int __init uart8250_init(void)
0080 {
0081 switch (bcm47xx_bus_type) {
0082 #ifdef CONFIG_BCM47XX_SSB
0083 case BCM47XX_BUS_TYPE_SSB:
0084 return uart8250_init_ssb();
0085 #endif
0086 #ifdef CONFIG_BCM47XX_BCMA
0087 case BCM47XX_BUS_TYPE_BCMA:
0088 return uart8250_init_bcma();
0089 #endif
0090 }
0091 return -EINVAL;
0092 }
0093 device_initcall(uart8250_init);