Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * DBAu1xxx board platform device registration |
| 3 | * |
| 4 | * Copyright (C) 2009 Manuel Lauss |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include <linux/init.h> |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 22 | #include <linux/interrupt.h> |
Manuel Lauss | 3766386 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 23 | #include <linux/dma-mapping.h> |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
| 25 | |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 26 | #include <asm/mach-au1x00/au1000.h> |
| 27 | #include <asm/mach-au1x00/au1000_dma.h> |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 28 | #include <asm/mach-db1x00/bcsr.h> |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 29 | #include "../platform.h" |
| 30 | |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 31 | struct pci_dev; |
| 32 | |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 33 | /* DB1xxx PCMCIA interrupt sources: |
| 34 | * CD0/1 GPIO0/3 |
| 35 | * STSCHG0/1 GPIO1/4 |
| 36 | * CARD0/1 GPIO2/5 |
| 37 | * Db1550: 0/1, 21/22, 3/5 |
| 38 | */ |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 39 | |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 40 | #define F_SWAPPED (bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT) |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 41 | |
| 42 | #if defined(CONFIG_MIPS_DB1000) |
| 43 | #define DB1XXX_PCMCIA_CD0 AU1000_GPIO0_INT |
| 44 | #define DB1XXX_PCMCIA_STSCHG0 AU1000_GPIO1_INT |
| 45 | #define DB1XXX_PCMCIA_CARD0 AU1000_GPIO2_INT |
| 46 | #define DB1XXX_PCMCIA_CD1 AU1000_GPIO3_INT |
| 47 | #define DB1XXX_PCMCIA_STSCHG1 AU1000_GPIO4_INT |
| 48 | #define DB1XXX_PCMCIA_CARD1 AU1000_GPIO5_INT |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 49 | #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */ |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 50 | #elif defined(CONFIG_MIPS_DB1100) |
| 51 | #define DB1XXX_PCMCIA_CD0 AU1100_GPIO0_INT |
| 52 | #define DB1XXX_PCMCIA_STSCHG0 AU1100_GPIO1_INT |
| 53 | #define DB1XXX_PCMCIA_CARD0 AU1100_GPIO2_INT |
| 54 | #define DB1XXX_PCMCIA_CD1 AU1100_GPIO3_INT |
| 55 | #define DB1XXX_PCMCIA_STSCHG1 AU1100_GPIO4_INT |
| 56 | #define DB1XXX_PCMCIA_CARD1 AU1100_GPIO5_INT |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 57 | #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */ |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 58 | #elif defined(CONFIG_MIPS_DB1500) |
| 59 | #define DB1XXX_PCMCIA_CD0 AU1500_GPIO0_INT |
| 60 | #define DB1XXX_PCMCIA_STSCHG0 AU1500_GPIO1_INT |
| 61 | #define DB1XXX_PCMCIA_CARD0 AU1500_GPIO2_INT |
| 62 | #define DB1XXX_PCMCIA_CD1 AU1500_GPIO3_INT |
| 63 | #define DB1XXX_PCMCIA_STSCHG1 AU1500_GPIO4_INT |
| 64 | #define DB1XXX_PCMCIA_CARD1 AU1500_GPIO5_INT |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 65 | #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */ |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 66 | #elif defined(CONFIG_MIPS_DB1550) |
| 67 | #define DB1XXX_PCMCIA_CD0 AU1550_GPIO0_INT |
| 68 | #define DB1XXX_PCMCIA_STSCHG0 AU1550_GPIO21_INT |
| 69 | #define DB1XXX_PCMCIA_CARD0 AU1550_GPIO3_INT |
| 70 | #define DB1XXX_PCMCIA_CD1 AU1550_GPIO1_INT |
| 71 | #define DB1XXX_PCMCIA_STSCHG1 AU1550_GPIO22_INT |
| 72 | #define DB1XXX_PCMCIA_CARD1 AU1550_GPIO5_INT |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 73 | #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */ |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 74 | #endif |
| 75 | |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 76 | #ifdef CONFIG_PCI |
| 77 | #ifdef CONFIG_MIPS_DB1500 |
| 78 | static int db1xxx_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin) |
| 79 | { |
| 80 | if ((slot < 12) || (slot > 13) || pin == 0) |
| 81 | return -1; |
| 82 | if (slot == 12) |
| 83 | return (pin == 1) ? AU1500_PCI_INTA : 0xff; |
| 84 | if (slot == 13) { |
| 85 | switch (pin) { |
| 86 | case 1: return AU1500_PCI_INTA; |
| 87 | case 2: return AU1500_PCI_INTB; |
| 88 | case 3: return AU1500_PCI_INTC; |
| 89 | case 4: return AU1500_PCI_INTD; |
| 90 | } |
| 91 | } |
| 92 | return -1; |
| 93 | } |
| 94 | #endif |
| 95 | |
| 96 | #ifdef CONFIG_MIPS_DB1550 |
| 97 | static int db1xxx_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin) |
| 98 | { |
| 99 | if ((slot < 11) || (slot > 13) || pin == 0) |
| 100 | return -1; |
| 101 | if (slot == 11) |
| 102 | return (pin == 1) ? AU1550_PCI_INTC : 0xff; |
| 103 | if (slot == 12) { |
| 104 | switch (pin) { |
| 105 | case 1: return AU1550_PCI_INTB; |
| 106 | case 2: return AU1550_PCI_INTC; |
| 107 | case 3: return AU1550_PCI_INTD; |
| 108 | case 4: return AU1550_PCI_INTA; |
| 109 | } |
| 110 | } |
| 111 | if (slot == 13) { |
| 112 | switch (pin) { |
| 113 | case 1: return AU1550_PCI_INTA; |
| 114 | case 2: return AU1550_PCI_INTB; |
| 115 | case 3: return AU1550_PCI_INTC; |
| 116 | case 4: return AU1550_PCI_INTD; |
| 117 | } |
| 118 | } |
| 119 | return -1; |
| 120 | } |
| 121 | #endif |
| 122 | |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 123 | static struct resource alchemy_pci_host_res[] = { |
| 124 | [0] = { |
| 125 | .start = AU1500_PCI_PHYS_ADDR, |
| 126 | .end = AU1500_PCI_PHYS_ADDR + 0xfff, |
| 127 | .flags = IORESOURCE_MEM, |
| 128 | }, |
| 129 | }; |
| 130 | |
| 131 | static struct alchemy_pci_platdata db1xxx_pci_pd = { |
| 132 | .board_map_irq = db1xxx_map_pci_irq, |
| 133 | }; |
| 134 | |
| 135 | static struct platform_device db1xxx_pci_host_dev = { |
| 136 | .dev.platform_data = &db1xxx_pci_pd, |
| 137 | .name = "alchemy-pci", |
| 138 | .id = 0, |
| 139 | .num_resources = ARRAY_SIZE(alchemy_pci_host_res), |
| 140 | .resource = alchemy_pci_host_res, |
| 141 | }; |
| 142 | |
| 143 | static int __init db15x0_pci_init(void) |
| 144 | { |
| 145 | return platform_device_register(&db1xxx_pci_host_dev); |
| 146 | } |
| 147 | /* must be arch_initcall; MIPS PCI scans busses in a subsys_initcall */ |
| 148 | arch_initcall(db15x0_pci_init); |
| 149 | #endif |
| 150 | |
Manuel Lauss | 3766386 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 151 | #ifdef CONFIG_MIPS_DB1100 |
| 152 | static struct resource au1100_lcd_resources[] = { |
| 153 | [0] = { |
| 154 | .start = AU1100_LCD_PHYS_ADDR, |
| 155 | .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1, |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | }, |
| 158 | [1] = { |
| 159 | .start = AU1100_LCD_INT, |
| 160 | .end = AU1100_LCD_INT, |
| 161 | .flags = IORESOURCE_IRQ, |
| 162 | } |
| 163 | }; |
| 164 | |
| 165 | static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32); |
| 166 | |
| 167 | static struct platform_device au1100_lcd_device = { |
| 168 | .name = "au1100-lcd", |
| 169 | .id = 0, |
| 170 | .dev = { |
| 171 | .dma_mask = &au1100_lcd_dmamask, |
| 172 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 173 | }, |
| 174 | .num_resources = ARRAY_SIZE(au1100_lcd_resources), |
| 175 | .resource = au1100_lcd_resources, |
| 176 | }; |
| 177 | #endif |
| 178 | |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 179 | static struct resource alchemy_ac97c_res[] = { |
| 180 | [0] = { |
| 181 | .start = AU1000_AC97_PHYS_ADDR, |
| 182 | .end = AU1000_AC97_PHYS_ADDR + 0xfff, |
| 183 | .flags = IORESOURCE_MEM, |
| 184 | }, |
| 185 | [1] = { |
| 186 | .start = DMA_ID_AC97C_TX, |
| 187 | .end = DMA_ID_AC97C_TX, |
| 188 | .flags = IORESOURCE_DMA, |
| 189 | }, |
| 190 | [2] = { |
| 191 | .start = DMA_ID_AC97C_RX, |
| 192 | .end = DMA_ID_AC97C_RX, |
| 193 | .flags = IORESOURCE_DMA, |
| 194 | }, |
| 195 | }; |
| 196 | |
| 197 | static struct platform_device alchemy_ac97c_dev = { |
| 198 | .name = "alchemy-ac97c", |
| 199 | .id = -1, |
| 200 | .resource = alchemy_ac97c_res, |
| 201 | .num_resources = ARRAY_SIZE(alchemy_ac97c_res), |
| 202 | }; |
| 203 | |
| 204 | static struct platform_device alchemy_ac97c_dma_dev = { |
| 205 | .name = "alchemy-pcm-dma", |
| 206 | .id = 0, |
| 207 | }; |
| 208 | |
| 209 | static struct platform_device db1x00_codec_dev = { |
| 210 | .name = "ac97-codec", |
| 211 | .id = -1, |
| 212 | }; |
| 213 | |
| 214 | static struct platform_device db1x00_audio_dev = { |
| 215 | .name = "db1000-audio", |
| 216 | }; |
| 217 | |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 218 | static int __init db1xxx_dev_init(void) |
| 219 | { |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 220 | db1x_register_pcmcia_socket( |
| 221 | AU1000_PCMCIA_ATTR_PHYS_ADDR, |
| 222 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1, |
| 223 | AU1000_PCMCIA_MEM_PHYS_ADDR, |
| 224 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1, |
| 225 | AU1000_PCMCIA_IO_PHYS_ADDR, |
| 226 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1, |
| 227 | DB1XXX_PCMCIA_CARD0, DB1XXX_PCMCIA_CD0, |
| 228 | /*DB1XXX_PCMCIA_STSCHG0*/0, 0, 0); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 229 | |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 230 | db1x_register_pcmcia_socket( |
| 231 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000, |
| 232 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1, |
| 233 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000, |
| 234 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1, |
| 235 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000, |
| 236 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1, |
| 237 | DB1XXX_PCMCIA_CARD1, DB1XXX_PCMCIA_CD1, |
| 238 | /*DB1XXX_PCMCIA_STSCHG1*/0, 0, 1); |
Manuel Lauss | 3766386 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 239 | #ifdef CONFIG_MIPS_DB1100 |
| 240 | platform_device_register(&au1100_lcd_device); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 241 | #endif |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 242 | platform_device_register(&db1x00_codec_dev); |
| 243 | platform_device_register(&alchemy_ac97c_dma_dev); |
| 244 | platform_device_register(&alchemy_ac97c_dev); |
| 245 | platform_device_register(&db1x00_audio_dev); |
| 246 | |
Manuel Lauss | 435037c | 2011-11-01 20:03:28 +0100 | [diff] [blame^] | 247 | db1x_register_norflash(BOARD_FLASH_SIZE, 4 /* 32bit */, F_SWAPPED); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 248 | return 0; |
| 249 | } |
| 250 | device_initcall(db1xxx_dev_init); |