Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 1 | /* |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 2 | * DBAu1000/1500/1100 board support |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 3 | * |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 4 | * Copyright 2000, 2008 MontaVista Software Inc. |
| 5 | * Author: MontaVista Software, Inc. <source@mvista.com> |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 22 | #include <linux/dma-mapping.h> |
| 23 | #include <linux/gpio.h> |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 24 | #include <linux/init.h> |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 25 | #include <linux/interrupt.h> |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 26 | #include <linux/platform_device.h> |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 27 | #include <linux/pm.h> |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 28 | #include <asm/mach-au1x00/au1000.h> |
| 29 | #include <asm/mach-au1x00/au1000_dma.h> |
Manuel Lauss | 206aa6c | 2009-10-19 12:53:37 +0200 | [diff] [blame] | 30 | #include <asm/mach-db1x00/bcsr.h> |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 31 | #include <asm/reboot.h> |
| 32 | #include <prom.h> |
| 33 | #include "platform.h" |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 34 | |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 35 | #define F_SWAPPED (bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT) |
| 36 | |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 37 | struct pci_dev; |
| 38 | |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 39 | static const char *board_type_str(void) |
| 40 | { |
| 41 | switch (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) { |
| 42 | case BCSR_WHOAMI_DB1000: |
| 43 | return "DB1000"; |
| 44 | case BCSR_WHOAMI_DB1500: |
| 45 | return "DB1500"; |
| 46 | case BCSR_WHOAMI_DB1100: |
| 47 | return "DB1100"; |
| 48 | default: |
| 49 | return "(unknown)"; |
| 50 | } |
| 51 | } |
| 52 | |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 53 | const char *get_system_type(void) |
| 54 | { |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 55 | return board_type_str(); |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void __init board_setup(void) |
| 59 | { |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 60 | /* initialize board register space */ |
| 61 | bcsr_init(DB1000_BCSR_PHYS_ADDR, |
| 62 | DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS); |
| 63 | |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 64 | printk(KERN_INFO "AMD Alchemy %s Board\n", board_type_str()); |
| 65 | |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 66 | #if defined(CONFIG_IRDA) && defined(CONFIG_AU1000_FIR) |
| 67 | { |
| 68 | u32 pin_func; |
| 69 | |
| 70 | /* Set IRFIRSEL instead of GPIO15 */ |
| 71 | pin_func = au_readl(SYS_PINFUNC) | SYS_PF_IRF; |
| 72 | au_writel(pin_func, SYS_PINFUNC); |
| 73 | /* Power off until the driver is in use */ |
| 74 | bcsr_mod(BCSR_RESETS, BCSR_RESETS_IRDA_MODE_MASK, |
| 75 | BCSR_RESETS_IRDA_MODE_OFF); |
| 76 | } |
| 77 | #endif |
| 78 | bcsr_write(BCSR_PCMCIA, 0); /* turn off PCMCIA power */ |
| 79 | |
| 80 | /* Enable GPIO[31:0] inputs */ |
| 81 | alchemy_gpio1_input_enable(); |
| 82 | } |
| 83 | |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 84 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 85 | 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] | 86 | { |
| 87 | if ((slot < 12) || (slot > 13) || pin == 0) |
| 88 | return -1; |
| 89 | if (slot == 12) |
| 90 | return (pin == 1) ? AU1500_PCI_INTA : 0xff; |
| 91 | if (slot == 13) { |
| 92 | switch (pin) { |
| 93 | case 1: return AU1500_PCI_INTA; |
| 94 | case 2: return AU1500_PCI_INTB; |
| 95 | case 3: return AU1500_PCI_INTC; |
| 96 | case 4: return AU1500_PCI_INTD; |
| 97 | } |
| 98 | } |
| 99 | return -1; |
| 100 | } |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 101 | |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 102 | static struct resource alchemy_pci_host_res[] = { |
| 103 | [0] = { |
| 104 | .start = AU1500_PCI_PHYS_ADDR, |
| 105 | .end = AU1500_PCI_PHYS_ADDR + 0xfff, |
| 106 | .flags = IORESOURCE_MEM, |
| 107 | }, |
| 108 | }; |
| 109 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 110 | static struct alchemy_pci_platdata db1500_pci_pd = { |
| 111 | .board_map_irq = db1500_map_pci_irq, |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 112 | }; |
| 113 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 114 | static struct platform_device db1500_pci_host_dev = { |
| 115 | .dev.platform_data = &db1500_pci_pd, |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 116 | .name = "alchemy-pci", |
| 117 | .id = 0, |
| 118 | .num_resources = ARRAY_SIZE(alchemy_pci_host_res), |
| 119 | .resource = alchemy_pci_host_res, |
| 120 | }; |
| 121 | |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 122 | static int __init db1500_pci_init(void) |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 123 | { |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 124 | if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1500) |
| 125 | return platform_device_register(&db1500_pci_host_dev); |
| 126 | return 0; |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 127 | } |
| 128 | /* must be arch_initcall; MIPS PCI scans busses in a subsys_initcall */ |
Manuel Lauss | f869d42 | 2011-11-10 12:06:16 +0000 | [diff] [blame] | 129 | arch_initcall(db1500_pci_init); |
Manuel Lauss | 7517de3 | 2011-08-12 11:39:44 +0200 | [diff] [blame] | 130 | |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 131 | |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 132 | static struct resource au1100_lcd_resources[] = { |
| 133 | [0] = { |
| 134 | .start = AU1100_LCD_PHYS_ADDR, |
| 135 | .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1, |
| 136 | .flags = IORESOURCE_MEM, |
| 137 | }, |
| 138 | [1] = { |
| 139 | .start = AU1100_LCD_INT, |
| 140 | .end = AU1100_LCD_INT, |
| 141 | .flags = IORESOURCE_IRQ, |
| 142 | } |
| 143 | }; |
| 144 | |
| 145 | static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32); |
| 146 | |
| 147 | static struct platform_device au1100_lcd_device = { |
| 148 | .name = "au1100-lcd", |
| 149 | .id = 0, |
| 150 | .dev = { |
| 151 | .dma_mask = &au1100_lcd_dmamask, |
| 152 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 153 | }, |
| 154 | .num_resources = ARRAY_SIZE(au1100_lcd_resources), |
| 155 | .resource = au1100_lcd_resources, |
| 156 | }; |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 157 | |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 158 | static struct resource alchemy_ac97c_res[] = { |
| 159 | [0] = { |
| 160 | .start = AU1000_AC97_PHYS_ADDR, |
| 161 | .end = AU1000_AC97_PHYS_ADDR + 0xfff, |
| 162 | .flags = IORESOURCE_MEM, |
| 163 | }, |
| 164 | [1] = { |
| 165 | .start = DMA_ID_AC97C_TX, |
| 166 | .end = DMA_ID_AC97C_TX, |
| 167 | .flags = IORESOURCE_DMA, |
| 168 | }, |
| 169 | [2] = { |
| 170 | .start = DMA_ID_AC97C_RX, |
| 171 | .end = DMA_ID_AC97C_RX, |
| 172 | .flags = IORESOURCE_DMA, |
| 173 | }, |
| 174 | }; |
| 175 | |
| 176 | static struct platform_device alchemy_ac97c_dev = { |
| 177 | .name = "alchemy-ac97c", |
| 178 | .id = -1, |
| 179 | .resource = alchemy_ac97c_res, |
| 180 | .num_resources = ARRAY_SIZE(alchemy_ac97c_res), |
| 181 | }; |
| 182 | |
| 183 | static struct platform_device alchemy_ac97c_dma_dev = { |
| 184 | .name = "alchemy-pcm-dma", |
| 185 | .id = 0, |
| 186 | }; |
| 187 | |
| 188 | static struct platform_device db1x00_codec_dev = { |
| 189 | .name = "ac97-codec", |
| 190 | .id = -1, |
| 191 | }; |
| 192 | |
| 193 | static struct platform_device db1x00_audio_dev = { |
| 194 | .name = "db1000-audio", |
| 195 | }; |
| 196 | |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 197 | static struct platform_device *db1x00_devs[] = { |
| 198 | &db1x00_codec_dev, |
| 199 | &alchemy_ac97c_dma_dev, |
| 200 | &alchemy_ac97c_dev, |
| 201 | &db1x00_audio_dev, |
| 202 | }; |
| 203 | |
| 204 | static struct platform_device *db1100_devs[] = { |
| 205 | &au1100_lcd_device, |
| 206 | }; |
| 207 | |
| 208 | static int __init db1000_dev_init(void) |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 209 | { |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 210 | int board = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)); |
| 211 | int c0, c1, d0, d1, s0, s1; |
| 212 | |
| 213 | if (board == BCSR_WHOAMI_DB1500) { |
| 214 | c0 = AU1500_GPIO2_INT; |
| 215 | c1 = AU1500_GPIO5_INT; |
| 216 | d0 = AU1500_GPIO0_INT; |
| 217 | d1 = AU1500_GPIO3_INT; |
| 218 | s0 = AU1500_GPIO1_INT; |
| 219 | s1 = AU1500_GPIO4_INT; |
| 220 | } else if (board == BCSR_WHOAMI_DB1100) { |
| 221 | c0 = AU1100_GPIO2_INT; |
| 222 | c1 = AU1100_GPIO5_INT; |
| 223 | d0 = AU1100_GPIO0_INT; |
| 224 | d1 = AU1100_GPIO3_INT; |
| 225 | s0 = AU1100_GPIO1_INT; |
| 226 | s1 = AU1100_GPIO4_INT; |
| 227 | platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs)); |
| 228 | } else if (board == BCSR_WHOAMI_DB1000) { |
| 229 | c0 = AU1000_GPIO2_INT; |
| 230 | c1 = AU1000_GPIO5_INT; |
| 231 | d0 = AU1000_GPIO0_INT; |
| 232 | d1 = AU1000_GPIO3_INT; |
| 233 | s0 = AU1000_GPIO1_INT; |
| 234 | s1 = AU1000_GPIO4_INT; |
| 235 | } else |
| 236 | return 0; /* unknown board, no further dev setup to do */ |
| 237 | |
| 238 | irq_set_irq_type(d0, IRQ_TYPE_EDGE_BOTH); |
| 239 | irq_set_irq_type(d1, IRQ_TYPE_EDGE_BOTH); |
| 240 | irq_set_irq_type(c0, IRQ_TYPE_LEVEL_LOW); |
| 241 | irq_set_irq_type(c1, IRQ_TYPE_LEVEL_LOW); |
| 242 | irq_set_irq_type(s0, IRQ_TYPE_LEVEL_LOW); |
| 243 | irq_set_irq_type(s1, IRQ_TYPE_LEVEL_LOW); |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 244 | |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 245 | db1x_register_pcmcia_socket( |
| 246 | AU1000_PCMCIA_ATTR_PHYS_ADDR, |
| 247 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1, |
| 248 | AU1000_PCMCIA_MEM_PHYS_ADDR, |
| 249 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1, |
| 250 | AU1000_PCMCIA_IO_PHYS_ADDR, |
| 251 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1, |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 252 | c0, d0, /*s0*/0, 0, 0); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 253 | |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 254 | db1x_register_pcmcia_socket( |
| 255 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000, |
| 256 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1, |
| 257 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000, |
| 258 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1, |
| 259 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000, |
| 260 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1, |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 261 | c1, d1, /*s1*/0, 0, 1); |
Manuel Lauss | b2ce305 | 2011-07-25 13:44:46 +0200 | [diff] [blame] | 262 | |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 263 | platform_add_devices(db1x00_devs, ARRAY_SIZE(db1x00_devs)); |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 264 | db1x_register_norflash(32 << 20, 4 /* 32bit */, F_SWAPPED); |
Manuel Lauss | 27dd65a | 2009-10-04 14:55:28 +0200 | [diff] [blame] | 265 | return 0; |
| 266 | } |
Manuel Lauss | f59c811 | 2011-11-10 12:06:22 +0000 | [diff] [blame^] | 267 | device_initcall(db1000_dev_init); |