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 | 376638603 | 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 |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 37 | */ |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 38 | |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 39 | #define F_SWAPPED (bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT) |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 40 | |
| 41 | #if defined(CONFIG_MIPS_DB1000) |
| 42 | #define DB1XXX_PCMCIA_CD0 AU1000_GPIO0_INT |
| 43 | #define DB1XXX_PCMCIA_STSCHG0 AU1000_GPIO1_INT |
| 44 | #define DB1XXX_PCMCIA_CARD0 AU1000_GPIO2_INT |
| 45 | #define DB1XXX_PCMCIA_CD1 AU1000_GPIO3_INT |
| 46 | #define DB1XXX_PCMCIA_STSCHG1 AU1000_GPIO4_INT |
| 47 | #define DB1XXX_PCMCIA_CARD1 AU1000_GPIO5_INT |
| 48 | #elif defined(CONFIG_MIPS_DB1100) |
| 49 | #define DB1XXX_PCMCIA_CD0 AU1100_GPIO0_INT |
| 50 | #define DB1XXX_PCMCIA_STSCHG0 AU1100_GPIO1_INT |
| 51 | #define DB1XXX_PCMCIA_CARD0 AU1100_GPIO2_INT |
| 52 | #define DB1XXX_PCMCIA_CD1 AU1100_GPIO3_INT |
| 53 | #define DB1XXX_PCMCIA_STSCHG1 AU1100_GPIO4_INT |
| 54 | #define DB1XXX_PCMCIA_CARD1 AU1100_GPIO5_INT |
| 55 | #elif defined(CONFIG_MIPS_DB1500) |
| 56 | #define DB1XXX_PCMCIA_CD0 AU1500_GPIO0_INT |
| 57 | #define DB1XXX_PCMCIA_STSCHG0 AU1500_GPIO1_INT |
| 58 | #define DB1XXX_PCMCIA_CARD0 AU1500_GPIO2_INT |
| 59 | #define DB1XXX_PCMCIA_CD1 AU1500_GPIO3_INT |
| 60 | #define DB1XXX_PCMCIA_STSCHG1 AU1500_GPIO4_INT |
| 61 | #define DB1XXX_PCMCIA_CARD1 AU1500_GPIO5_INT |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 62 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame^] | 63 | static int db1500_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin) |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 64 | { |
| 65 | if ((slot < 12) || (slot > 13) || pin == 0) |
| 66 | return -1; |
| 67 | if (slot == 12) |
| 68 | return (pin == 1) ? AU1500_PCI_INTA : 0xff; |
| 69 | if (slot == 13) { |
| 70 | switch (pin) { |
| 71 | case 1: return AU1500_PCI_INTA; |
| 72 | case 2: return AU1500_PCI_INTB; |
| 73 | case 3: return AU1500_PCI_INTC; |
| 74 | case 4: return AU1500_PCI_INTD; |
| 75 | } |
| 76 | } |
| 77 | return -1; |
| 78 | } |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 79 | |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 80 | static struct resource alchemy_pci_host_res[] = { |
| 81 | [0] = { |
| 82 | .start = AU1500_PCI_PHYS_ADDR, |
| 83 | .end = AU1500_PCI_PHYS_ADDR + 0xfff, |
| 84 | .flags = IORESOURCE_MEM, |
| 85 | }, |
| 86 | }; |
| 87 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame^] | 88 | static struct alchemy_pci_platdata db1500_pci_pd = { |
| 89 | .board_map_irq = db1500_map_pci_irq, |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 90 | }; |
| 91 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame^] | 92 | static struct platform_device db1500_pci_host_dev = { |
| 93 | .dev.platform_data = &db1500_pci_pd, |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 94 | .name = "alchemy-pci", |
| 95 | .id = 0, |
| 96 | .num_resources = ARRAY_SIZE(alchemy_pci_host_res), |
| 97 | .resource = alchemy_pci_host_res, |
| 98 | }; |
| 99 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame^] | 100 | static int __init db1500_pci_init(void) |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 101 | { |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame^] | 102 | return platform_device_register(&db1500_pci_host_dev); |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 103 | } |
| 104 | /* must be arch_initcall; MIPS PCI scans busses in a subsys_initcall */ |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame^] | 105 | arch_initcall(db1500_pci_init); |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 106 | #endif |
| 107 | |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 108 | #ifdef CONFIG_MIPS_DB1100 |
| 109 | static struct resource au1100_lcd_resources[] = { |
| 110 | [0] = { |
| 111 | .start = AU1100_LCD_PHYS_ADDR, |
| 112 | .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1, |
| 113 | .flags = IORESOURCE_MEM, |
| 114 | }, |
| 115 | [1] = { |
| 116 | .start = AU1100_LCD_INT, |
| 117 | .end = AU1100_LCD_INT, |
| 118 | .flags = IORESOURCE_IRQ, |
| 119 | } |
| 120 | }; |
| 121 | |
| 122 | static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32); |
| 123 | |
| 124 | static struct platform_device au1100_lcd_device = { |
| 125 | .name = "au1100-lcd", |
| 126 | .id = 0, |
| 127 | .dev = { |
| 128 | .dma_mask = &au1100_lcd_dmamask, |
| 129 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 130 | }, |
| 131 | .num_resources = ARRAY_SIZE(au1100_lcd_resources), |
| 132 | .resource = au1100_lcd_resources, |
| 133 | }; |
| 134 | #endif |
| 135 | |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 136 | static struct resource alchemy_ac97c_res[] = { |
| 137 | [0] = { |
| 138 | .start = AU1000_AC97_PHYS_ADDR, |
| 139 | .end = AU1000_AC97_PHYS_ADDR + 0xfff, |
| 140 | .flags = IORESOURCE_MEM, |
| 141 | }, |
| 142 | [1] = { |
| 143 | .start = DMA_ID_AC97C_TX, |
| 144 | .end = DMA_ID_AC97C_TX, |
| 145 | .flags = IORESOURCE_DMA, |
| 146 | }, |
| 147 | [2] = { |
| 148 | .start = DMA_ID_AC97C_RX, |
| 149 | .end = DMA_ID_AC97C_RX, |
| 150 | .flags = IORESOURCE_DMA, |
| 151 | }, |
| 152 | }; |
| 153 | |
| 154 | static struct platform_device alchemy_ac97c_dev = { |
| 155 | .name = "alchemy-ac97c", |
| 156 | .id = -1, |
| 157 | .resource = alchemy_ac97c_res, |
| 158 | .num_resources = ARRAY_SIZE(alchemy_ac97c_res), |
| 159 | }; |
| 160 | |
| 161 | static struct platform_device alchemy_ac97c_dma_dev = { |
| 162 | .name = "alchemy-pcm-dma", |
| 163 | .id = 0, |
| 164 | }; |
| 165 | |
| 166 | static struct platform_device db1x00_codec_dev = { |
| 167 | .name = "ac97-codec", |
| 168 | .id = -1, |
| 169 | }; |
| 170 | |
| 171 | static struct platform_device db1x00_audio_dev = { |
| 172 | .name = "db1000-audio", |
| 173 | }; |
| 174 | |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 175 | static int __init db1xxx_dev_init(void) |
| 176 | { |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 177 | db1x_register_pcmcia_socket( |
| 178 | AU1000_PCMCIA_ATTR_PHYS_ADDR, |
| 179 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1, |
| 180 | AU1000_PCMCIA_MEM_PHYS_ADDR, |
| 181 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1, |
| 182 | AU1000_PCMCIA_IO_PHYS_ADDR, |
| 183 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1, |
| 184 | DB1XXX_PCMCIA_CARD0, DB1XXX_PCMCIA_CD0, |
| 185 | /*DB1XXX_PCMCIA_STSCHG0*/0, 0, 0); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 186 | |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 187 | db1x_register_pcmcia_socket( |
| 188 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000, |
| 189 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1, |
| 190 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000, |
| 191 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1, |
| 192 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000, |
| 193 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1, |
| 194 | DB1XXX_PCMCIA_CARD1, DB1XXX_PCMCIA_CD1, |
| 195 | /*DB1XXX_PCMCIA_STSCHG1*/0, 0, 1); |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 196 | #ifdef CONFIG_MIPS_DB1100 |
| 197 | platform_device_register(&au1100_lcd_device); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 198 | #endif |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 199 | platform_device_register(&db1x00_codec_dev); |
| 200 | platform_device_register(&alchemy_ac97c_dma_dev); |
| 201 | platform_device_register(&alchemy_ac97c_dev); |
| 202 | platform_device_register(&db1x00_audio_dev); |
| 203 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame^] | 204 | db1x_register_norflash(0x02000000, 4 /* 32bit */, F_SWAPPED); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 205 | return 0; |
| 206 | } |
| 207 | device_initcall(db1xxx_dev_init); |