Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 1 | /* |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 2 | * DBAu1200/PBAu1200 board platform device registration |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 3 | * |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 4 | * Copyright (C) 2008-2011 Manuel Lauss |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 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/dma-mapping.h> |
| 22 | #include <linux/gpio.h> |
| 23 | #include <linux/i2c.h> |
| 24 | #include <linux/init.h> |
Paul Gortmaker | f9ded56 | 2012-02-28 19:24:46 -0500 | [diff] [blame] | 25 | #include <linux/module.h> |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 26 | #include <linux/interrupt.h> |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 27 | #include <linux/io.h> |
| 28 | #include <linux/leds.h> |
| 29 | #include <linux/mmc/host.h> |
| 30 | #include <linux/mtd/mtd.h> |
| 31 | #include <linux/mtd/nand.h> |
| 32 | #include <linux/mtd/partitions.h> |
| 33 | #include <linux/platform_device.h> |
| 34 | #include <linux/serial_8250.h> |
| 35 | #include <linux/spi/spi.h> |
| 36 | #include <linux/spi/flash.h> |
| 37 | #include <linux/smc91x.h> |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 38 | #include <asm/mach-au1x00/au1000.h> |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 39 | #include <asm/mach-au1x00/au1100_mmc.h> |
| 40 | #include <asm/mach-au1x00/au1xxx_dbdma.h> |
Manuel Lauss | a16afa5 | 2014-03-26 10:41:48 +0100 | [diff] [blame^] | 41 | #include <asm/mach-au1x00/au1xxx_psc.h> |
Manuel Lauss | a9b71a8 | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 42 | #include <asm/mach-au1x00/au1200fb.h> |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 43 | #include <asm/mach-au1x00/au1550_spi.h> |
| 44 | #include <asm/mach-db1x00/bcsr.h> |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 45 | |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 46 | #include "platform.h" |
| 47 | |
Manuel Lauss | a16afa5 | 2014-03-26 10:41:48 +0100 | [diff] [blame^] | 48 | #define BCSR_INT_IDE 0x0001 |
| 49 | #define BCSR_INT_ETH 0x0002 |
| 50 | #define BCSR_INT_PC0 0x0004 |
| 51 | #define BCSR_INT_PC0STSCHG 0x0008 |
| 52 | #define BCSR_INT_PC1 0x0010 |
| 53 | #define BCSR_INT_PC1STSCHG 0x0020 |
| 54 | #define BCSR_INT_DC 0x0040 |
| 55 | #define BCSR_INT_FLASHBUSY 0x0080 |
| 56 | #define BCSR_INT_PC0INSERT 0x0100 |
| 57 | #define BCSR_INT_PC0EJECT 0x0200 |
| 58 | #define BCSR_INT_PC1INSERT 0x0400 |
| 59 | #define BCSR_INT_PC1EJECT 0x0800 |
| 60 | #define BCSR_INT_SD0INSERT 0x1000 |
| 61 | #define BCSR_INT_SD0EJECT 0x2000 |
| 62 | #define BCSR_INT_SD1INSERT 0x4000 |
| 63 | #define BCSR_INT_SD1EJECT 0x8000 |
| 64 | |
| 65 | #define DB1200_IDE_PHYS_ADDR 0x18800000 |
| 66 | #define DB1200_IDE_REG_SHIFT 5 |
| 67 | #define DB1200_IDE_PHYS_LEN (16 << DB1200_IDE_REG_SHIFT) |
| 68 | #define DB1200_ETH_PHYS_ADDR 0x19000300 |
| 69 | #define DB1200_NAND_PHYS_ADDR 0x20000000 |
| 70 | |
| 71 | #define PB1200_IDE_PHYS_ADDR 0x0C800000 |
| 72 | #define PB1200_ETH_PHYS_ADDR 0x0D000300 |
| 73 | #define PB1200_NAND_PHYS_ADDR 0x1C000000 |
| 74 | |
| 75 | #define DB1200_INT_BEGIN (AU1000_MAX_INTR + 1) |
| 76 | #define DB1200_IDE_INT (DB1200_INT_BEGIN + 0) |
| 77 | #define DB1200_ETH_INT (DB1200_INT_BEGIN + 1) |
| 78 | #define DB1200_PC0_INT (DB1200_INT_BEGIN + 2) |
| 79 | #define DB1200_PC0_STSCHG_INT (DB1200_INT_BEGIN + 3) |
| 80 | #define DB1200_PC1_INT (DB1200_INT_BEGIN + 4) |
| 81 | #define DB1200_PC1_STSCHG_INT (DB1200_INT_BEGIN + 5) |
| 82 | #define DB1200_DC_INT (DB1200_INT_BEGIN + 6) |
| 83 | #define DB1200_FLASHBUSY_INT (DB1200_INT_BEGIN + 7) |
| 84 | #define DB1200_PC0_INSERT_INT (DB1200_INT_BEGIN + 8) |
| 85 | #define DB1200_PC0_EJECT_INT (DB1200_INT_BEGIN + 9) |
| 86 | #define DB1200_PC1_INSERT_INT (DB1200_INT_BEGIN + 10) |
| 87 | #define DB1200_PC1_EJECT_INT (DB1200_INT_BEGIN + 11) |
| 88 | #define DB1200_SD0_INSERT_INT (DB1200_INT_BEGIN + 12) |
| 89 | #define DB1200_SD0_EJECT_INT (DB1200_INT_BEGIN + 13) |
| 90 | #define PB1200_SD1_INSERT_INT (DB1200_INT_BEGIN + 14) |
| 91 | #define PB1200_SD1_EJECT_INT (DB1200_INT_BEGIN + 15) |
| 92 | #define DB1200_INT_END (DB1200_INT_BEGIN + 15) |
| 93 | |
Manuel Lauss | bd8510d | 2012-09-13 17:44:39 +0200 | [diff] [blame] | 94 | const char *get_system_type(void); |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 95 | |
Manuel Lauss | bd8510d | 2012-09-13 17:44:39 +0200 | [diff] [blame] | 96 | static int __init db1200_detect_board(void) |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 97 | { |
| 98 | int bid; |
| 99 | |
Manuel Lauss | f2711be | 2011-12-08 10:42:16 +0000 | [diff] [blame] | 100 | /* try the DB1200 first */ |
| 101 | bcsr_init(DB1200_BCSR_PHYS_ADDR, |
| 102 | DB1200_BCSR_PHYS_ADDR + DB1200_BCSR_HEXLED_OFS); |
| 103 | if (BCSR_WHOAMI_DB1200 == BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) { |
| 104 | unsigned short t = bcsr_read(BCSR_HEXLEDS); |
| 105 | bcsr_write(BCSR_HEXLEDS, ~t); |
| 106 | if (bcsr_read(BCSR_HEXLEDS) != t) { |
| 107 | bcsr_write(BCSR_HEXLEDS, t); |
| 108 | return 0; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /* okay, try the PB1200 then */ |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 113 | bcsr_init(PB1200_BCSR_PHYS_ADDR, |
| 114 | PB1200_BCSR_PHYS_ADDR + PB1200_BCSR_HEXLED_OFS); |
| 115 | bid = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)); |
| 116 | if ((bid == BCSR_WHOAMI_PB1200_DDR1) || |
Manuel Lauss | f2711be | 2011-12-08 10:42:16 +0000 | [diff] [blame] | 117 | (bid == BCSR_WHOAMI_PB1200_DDR2)) { |
| 118 | unsigned short t = bcsr_read(BCSR_HEXLEDS); |
| 119 | bcsr_write(BCSR_HEXLEDS, ~t); |
| 120 | if (bcsr_read(BCSR_HEXLEDS) != t) { |
| 121 | bcsr_write(BCSR_HEXLEDS, t); |
| 122 | return 0; |
| 123 | } |
| 124 | } |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 125 | |
Manuel Lauss | f2711be | 2011-12-08 10:42:16 +0000 | [diff] [blame] | 126 | return 1; /* it's neither */ |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Manuel Lauss | bd8510d | 2012-09-13 17:44:39 +0200 | [diff] [blame] | 129 | int __init db1200_board_setup(void) |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 130 | { |
| 131 | unsigned long freq0, clksrc, div, pfc; |
| 132 | unsigned short whoami; |
| 133 | |
Manuel Lauss | bd8510d | 2012-09-13 17:44:39 +0200 | [diff] [blame] | 134 | if (db1200_detect_board()) |
| 135 | return -ENODEV; |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 136 | |
| 137 | whoami = bcsr_read(BCSR_WHOAMI); |
Manuel Lauss | 970e268 | 2014-02-20 14:59:24 +0100 | [diff] [blame] | 138 | switch (BCSR_WHOAMI_BOARD(whoami)) { |
| 139 | case BCSR_WHOAMI_PB1200_DDR1: |
| 140 | case BCSR_WHOAMI_PB1200_DDR2: |
| 141 | case BCSR_WHOAMI_DB1200: |
| 142 | break; |
| 143 | default: |
| 144 | return -ENODEV; |
| 145 | } |
| 146 | |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 147 | printk(KERN_INFO "Alchemy/AMD/RMI %s Board, CPLD Rev %d" |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 148 | " Board-ID %d Daughtercard ID %d\n", get_system_type(), |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 149 | (whoami >> 4) & 0xf, (whoami >> 8) & 0xf, whoami & 0xf); |
| 150 | |
| 151 | /* SMBus/SPI on PSC0, Audio on PSC1 */ |
| 152 | pfc = __raw_readl((void __iomem *)SYS_PINFUNC); |
| 153 | pfc &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B); |
| 154 | pfc &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B | SYS_PINFUNC_FS3); |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 155 | pfc |= SYS_PINFUNC_P1C; /* SPI is configured later */ |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 156 | __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); |
| 157 | wmb(); |
| 158 | |
| 159 | /* Clock configurations: PSC0: ~50MHz via Clkgen0, derived from |
| 160 | * CPU clock; all other clock generators off/unused. |
| 161 | */ |
| 162 | div = (get_au1x00_speed() + 25000000) / 50000000; |
| 163 | if (div & 1) |
| 164 | div++; |
| 165 | div = ((div >> 1) - 1) & 0xff; |
| 166 | |
| 167 | freq0 = div << SYS_FC_FRDIV0_BIT; |
| 168 | __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0); |
| 169 | wmb(); |
| 170 | freq0 |= SYS_FC_FE0; /* enable F0 */ |
| 171 | __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0); |
| 172 | wmb(); |
| 173 | |
| 174 | /* psc0_intclk comes 1:1 from F0 */ |
| 175 | clksrc = SYS_CS_MUX_FQ0 << SYS_CS_ME0_BIT; |
| 176 | __raw_writel(clksrc, (void __iomem *)SYS_CLKSRC); |
| 177 | wmb(); |
Manuel Lauss | bd8510d | 2012-09-13 17:44:39 +0200 | [diff] [blame] | 178 | |
| 179 | return 0; |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /******************************************************************************/ |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 183 | |
| 184 | static struct mtd_partition db1200_spiflash_parts[] = { |
| 185 | { |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 186 | .name = "spi_flash", |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 187 | .offset = 0, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 188 | .size = MTDPART_SIZ_FULL, |
| 189 | }, |
| 190 | }; |
| 191 | |
| 192 | static struct flash_platform_data db1200_spiflash_data = { |
| 193 | .name = "s25fl001", |
| 194 | .parts = db1200_spiflash_parts, |
| 195 | .nr_parts = ARRAY_SIZE(db1200_spiflash_parts), |
| 196 | .type = "m25p10", |
| 197 | }; |
| 198 | |
| 199 | static struct spi_board_info db1200_spi_devs[] __initdata = { |
| 200 | { |
| 201 | /* TI TMP121AIDBVR temp sensor */ |
| 202 | .modalias = "tmp121", |
| 203 | .max_speed_hz = 2000000, |
| 204 | .bus_num = 0, |
| 205 | .chip_select = 0, |
| 206 | .mode = 0, |
| 207 | }, |
| 208 | { |
| 209 | /* Spansion S25FL001D0FMA SPI flash */ |
| 210 | .modalias = "m25p80", |
| 211 | .max_speed_hz = 50000000, |
| 212 | .bus_num = 0, |
| 213 | .chip_select = 1, |
| 214 | .mode = 0, |
| 215 | .platform_data = &db1200_spiflash_data, |
| 216 | }, |
| 217 | }; |
| 218 | |
| 219 | static struct i2c_board_info db1200_i2c_devs[] __initdata = { |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 220 | { I2C_BOARD_INFO("24c04", 0x52), }, /* AT24C04-10 I2C eeprom */ |
| 221 | { I2C_BOARD_INFO("ne1619", 0x2d), }, /* adm1025-compat hwmon */ |
| 222 | { I2C_BOARD_INFO("wm8731", 0x1b), }, /* I2S audio codec WM8731 */ |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 223 | }; |
| 224 | |
| 225 | /**********************************************************************/ |
| 226 | |
| 227 | static void au1200_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, |
| 228 | unsigned int ctrl) |
| 229 | { |
| 230 | struct nand_chip *this = mtd->priv; |
| 231 | unsigned long ioaddr = (unsigned long)this->IO_ADDR_W; |
| 232 | |
| 233 | ioaddr &= 0xffffff00; |
| 234 | |
| 235 | if (ctrl & NAND_CLE) { |
| 236 | ioaddr += MEM_STNAND_CMD; |
| 237 | } else if (ctrl & NAND_ALE) { |
| 238 | ioaddr += MEM_STNAND_ADDR; |
| 239 | } else { |
| 240 | /* assume we want to r/w real data by default */ |
| 241 | ioaddr += MEM_STNAND_DATA; |
| 242 | } |
| 243 | this->IO_ADDR_R = this->IO_ADDR_W = (void __iomem *)ioaddr; |
| 244 | if (cmd != NAND_CMD_NONE) { |
| 245 | __raw_writeb(cmd, this->IO_ADDR_W); |
| 246 | wmb(); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | static int au1200_nand_device_ready(struct mtd_info *mtd) |
| 251 | { |
| 252 | return __raw_readl((void __iomem *)MEM_STSTAT) & 1; |
| 253 | } |
| 254 | |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 255 | static struct mtd_partition db1200_nand_parts[] = { |
| 256 | { |
| 257 | .name = "NAND FS 0", |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 258 | .offset = 0, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 259 | .size = 8 * 1024 * 1024, |
| 260 | }, |
| 261 | { |
| 262 | .name = "NAND FS 1", |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 263 | .offset = MTDPART_OFS_APPEND, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 264 | .size = MTDPART_SIZ_FULL |
| 265 | }, |
| 266 | }; |
| 267 | |
| 268 | struct platform_nand_data db1200_nand_platdata = { |
| 269 | .chip = { |
| 270 | .nr_chips = 1, |
| 271 | .chip_offset = 0, |
| 272 | .nr_partitions = ARRAY_SIZE(db1200_nand_parts), |
| 273 | .partitions = db1200_nand_parts, |
| 274 | .chip_delay = 20, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 275 | }, |
| 276 | .ctrl = { |
| 277 | .dev_ready = au1200_nand_device_ready, |
| 278 | .cmd_ctrl = au1200_nand_cmd_ctrl, |
| 279 | }, |
| 280 | }; |
| 281 | |
| 282 | static struct resource db1200_nand_res[] = { |
| 283 | [0] = { |
| 284 | .start = DB1200_NAND_PHYS_ADDR, |
| 285 | .end = DB1200_NAND_PHYS_ADDR + 0xff, |
| 286 | .flags = IORESOURCE_MEM, |
| 287 | }, |
| 288 | }; |
| 289 | |
| 290 | static struct platform_device db1200_nand_dev = { |
| 291 | .name = "gen_nand", |
| 292 | .num_resources = ARRAY_SIZE(db1200_nand_res), |
| 293 | .resource = db1200_nand_res, |
| 294 | .id = -1, |
| 295 | .dev = { |
| 296 | .platform_data = &db1200_nand_platdata, |
| 297 | } |
| 298 | }; |
| 299 | |
| 300 | /**********************************************************************/ |
| 301 | |
| 302 | static struct smc91x_platdata db1200_eth_data = { |
| 303 | .flags = SMC91X_NOWAIT | SMC91X_USE_16BIT, |
| 304 | .leda = RPC_LED_100_10, |
| 305 | .ledb = RPC_LED_TX_RX, |
| 306 | }; |
| 307 | |
| 308 | static struct resource db1200_eth_res[] = { |
| 309 | [0] = { |
| 310 | .start = DB1200_ETH_PHYS_ADDR, |
| 311 | .end = DB1200_ETH_PHYS_ADDR + 0xf, |
| 312 | .flags = IORESOURCE_MEM, |
| 313 | }, |
| 314 | [1] = { |
| 315 | .start = DB1200_ETH_INT, |
| 316 | .end = DB1200_ETH_INT, |
| 317 | .flags = IORESOURCE_IRQ, |
| 318 | }, |
| 319 | }; |
| 320 | |
| 321 | static struct platform_device db1200_eth_dev = { |
| 322 | .dev = { |
| 323 | .platform_data = &db1200_eth_data, |
| 324 | }, |
| 325 | .name = "smc91x", |
| 326 | .id = -1, |
| 327 | .num_resources = ARRAY_SIZE(db1200_eth_res), |
| 328 | .resource = db1200_eth_res, |
| 329 | }; |
| 330 | |
| 331 | /**********************************************************************/ |
| 332 | |
| 333 | static struct resource db1200_ide_res[] = { |
| 334 | [0] = { |
| 335 | .start = DB1200_IDE_PHYS_ADDR, |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 336 | .end = DB1200_IDE_PHYS_ADDR + DB1200_IDE_PHYS_LEN - 1, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 337 | .flags = IORESOURCE_MEM, |
| 338 | }, |
| 339 | [1] = { |
| 340 | .start = DB1200_IDE_INT, |
| 341 | .end = DB1200_IDE_INT, |
| 342 | .flags = IORESOURCE_IRQ, |
Manuel Lauss | d4f07ae | 2011-08-18 11:11:58 +0200 | [diff] [blame] | 343 | }, |
| 344 | [2] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame] | 345 | .start = AU1200_DSCR_CMD0_DMA_REQ1, |
| 346 | .end = AU1200_DSCR_CMD0_DMA_REQ1, |
Manuel Lauss | d4f07ae | 2011-08-18 11:11:58 +0200 | [diff] [blame] | 347 | .flags = IORESOURCE_DMA, |
| 348 | }, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 349 | }; |
| 350 | |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 351 | static u64 au1200_ide_dmamask = DMA_BIT_MASK(32); |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 352 | |
| 353 | static struct platform_device db1200_ide_dev = { |
| 354 | .name = "au1200-ide", |
| 355 | .id = 0, |
| 356 | .dev = { |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 357 | .dma_mask = &au1200_ide_dmamask, |
FUJITA Tomonori | 25c8f83 | 2010-06-24 01:26:09 +0900 | [diff] [blame] | 358 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 359 | }, |
| 360 | .num_resources = ARRAY_SIZE(db1200_ide_res), |
| 361 | .resource = db1200_ide_res, |
| 362 | }; |
| 363 | |
| 364 | /**********************************************************************/ |
| 365 | |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 366 | /* SD carddetects: they're supposed to be edge-triggered, but ack |
| 367 | * doesn't seem to work (CPLD Rev 2). Instead, the screaming one |
| 368 | * is disabled and its counterpart enabled. The 500ms timeout is |
| 369 | * because the carddetect isn't debounced in hardware. |
| 370 | */ |
| 371 | static irqreturn_t db1200_mmc_cd(int irq, void *ptr) |
| 372 | { |
| 373 | void(*mmc_cd)(struct mmc_host *, unsigned long); |
| 374 | |
| 375 | if (irq == DB1200_SD0_INSERT_INT) { |
| 376 | disable_irq_nosync(DB1200_SD0_INSERT_INT); |
| 377 | enable_irq(DB1200_SD0_EJECT_INT); |
| 378 | } else { |
| 379 | disable_irq_nosync(DB1200_SD0_EJECT_INT); |
| 380 | enable_irq(DB1200_SD0_INSERT_INT); |
| 381 | } |
| 382 | |
| 383 | /* link against CONFIG_MMC=m */ |
| 384 | mmc_cd = symbol_get(mmc_detect_change); |
| 385 | if (mmc_cd) { |
| 386 | mmc_cd(ptr, msecs_to_jiffies(500)); |
| 387 | symbol_put(mmc_detect_change); |
| 388 | } |
| 389 | |
| 390 | return IRQ_HANDLED; |
| 391 | } |
| 392 | |
| 393 | static int db1200_mmc_cd_setup(void *mmc_host, int en) |
| 394 | { |
| 395 | int ret; |
| 396 | |
| 397 | if (en) { |
| 398 | ret = request_irq(DB1200_SD0_INSERT_INT, db1200_mmc_cd, |
Yong Zhang | 8b5690f | 2011-11-22 14:38:03 +0000 | [diff] [blame] | 399 | 0, "sd_insert", mmc_host); |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 400 | if (ret) |
| 401 | goto out; |
| 402 | |
| 403 | ret = request_irq(DB1200_SD0_EJECT_INT, db1200_mmc_cd, |
Yong Zhang | 8b5690f | 2011-11-22 14:38:03 +0000 | [diff] [blame] | 404 | 0, "sd_eject", mmc_host); |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 405 | if (ret) { |
| 406 | free_irq(DB1200_SD0_INSERT_INT, mmc_host); |
| 407 | goto out; |
| 408 | } |
| 409 | |
| 410 | if (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT) |
| 411 | enable_irq(DB1200_SD0_EJECT_INT); |
| 412 | else |
| 413 | enable_irq(DB1200_SD0_INSERT_INT); |
| 414 | |
| 415 | } else { |
| 416 | free_irq(DB1200_SD0_INSERT_INT, mmc_host); |
| 417 | free_irq(DB1200_SD0_EJECT_INT, mmc_host); |
| 418 | } |
| 419 | ret = 0; |
| 420 | out: |
| 421 | return ret; |
| 422 | } |
| 423 | |
| 424 | static void db1200_mmc_set_power(void *mmc_host, int state) |
| 425 | { |
| 426 | if (state) { |
| 427 | bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD0PWR); |
| 428 | msleep(400); /* stabilization time */ |
| 429 | } else |
| 430 | bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD0PWR, 0); |
| 431 | } |
| 432 | |
| 433 | static int db1200_mmc_card_readonly(void *mmc_host) |
| 434 | { |
| 435 | return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 1 : 0; |
| 436 | } |
| 437 | |
| 438 | static int db1200_mmc_card_inserted(void *mmc_host) |
| 439 | { |
| 440 | return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT) ? 1 : 0; |
| 441 | } |
| 442 | |
| 443 | static void db1200_mmcled_set(struct led_classdev *led, |
| 444 | enum led_brightness brightness) |
| 445 | { |
| 446 | if (brightness != LED_OFF) |
| 447 | bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0); |
| 448 | else |
| 449 | bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0); |
| 450 | } |
| 451 | |
| 452 | static struct led_classdev db1200_mmc_led = { |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 453 | .brightness_set = db1200_mmcled_set, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 454 | }; |
| 455 | |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 456 | /* -- */ |
| 457 | |
| 458 | static irqreturn_t pb1200_mmc1_cd(int irq, void *ptr) |
| 459 | { |
| 460 | void(*mmc_cd)(struct mmc_host *, unsigned long); |
| 461 | |
| 462 | if (irq == PB1200_SD1_INSERT_INT) { |
| 463 | disable_irq_nosync(PB1200_SD1_INSERT_INT); |
| 464 | enable_irq(PB1200_SD1_EJECT_INT); |
| 465 | } else { |
| 466 | disable_irq_nosync(PB1200_SD1_EJECT_INT); |
| 467 | enable_irq(PB1200_SD1_INSERT_INT); |
| 468 | } |
| 469 | |
| 470 | /* link against CONFIG_MMC=m */ |
| 471 | mmc_cd = symbol_get(mmc_detect_change); |
| 472 | if (mmc_cd) { |
| 473 | mmc_cd(ptr, msecs_to_jiffies(500)); |
| 474 | symbol_put(mmc_detect_change); |
| 475 | } |
| 476 | |
| 477 | return IRQ_HANDLED; |
| 478 | } |
| 479 | |
| 480 | static int pb1200_mmc1_cd_setup(void *mmc_host, int en) |
| 481 | { |
| 482 | int ret; |
| 483 | |
| 484 | if (en) { |
| 485 | ret = request_irq(PB1200_SD1_INSERT_INT, pb1200_mmc1_cd, 0, |
| 486 | "sd1_insert", mmc_host); |
| 487 | if (ret) |
| 488 | goto out; |
| 489 | |
| 490 | ret = request_irq(PB1200_SD1_EJECT_INT, pb1200_mmc1_cd, 0, |
| 491 | "sd1_eject", mmc_host); |
| 492 | if (ret) { |
| 493 | free_irq(PB1200_SD1_INSERT_INT, mmc_host); |
| 494 | goto out; |
| 495 | } |
| 496 | |
| 497 | if (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD1INSERT) |
| 498 | enable_irq(PB1200_SD1_EJECT_INT); |
| 499 | else |
| 500 | enable_irq(PB1200_SD1_INSERT_INT); |
| 501 | |
| 502 | } else { |
| 503 | free_irq(PB1200_SD1_INSERT_INT, mmc_host); |
| 504 | free_irq(PB1200_SD1_EJECT_INT, mmc_host); |
| 505 | } |
| 506 | ret = 0; |
| 507 | out: |
| 508 | return ret; |
| 509 | } |
| 510 | |
| 511 | static void pb1200_mmc1led_set(struct led_classdev *led, |
| 512 | enum led_brightness brightness) |
| 513 | { |
| 514 | if (brightness != LED_OFF) |
| 515 | bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED1, 0); |
| 516 | else |
| 517 | bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED1); |
| 518 | } |
| 519 | |
| 520 | static struct led_classdev pb1200_mmc1_led = { |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 521 | .brightness_set = pb1200_mmc1led_set, |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 522 | }; |
| 523 | |
| 524 | static void pb1200_mmc1_set_power(void *mmc_host, int state) |
| 525 | { |
| 526 | if (state) { |
| 527 | bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD1PWR); |
| 528 | msleep(400); /* stabilization time */ |
| 529 | } else |
| 530 | bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD1PWR, 0); |
| 531 | } |
| 532 | |
| 533 | static int pb1200_mmc1_card_readonly(void *mmc_host) |
| 534 | { |
| 535 | return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD1WP) ? 1 : 0; |
| 536 | } |
| 537 | |
| 538 | static int pb1200_mmc1_card_inserted(void *mmc_host) |
| 539 | { |
| 540 | return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD1INSERT) ? 1 : 0; |
| 541 | } |
| 542 | |
| 543 | |
| 544 | static struct au1xmmc_platform_data db1200_mmc_platdata[2] = { |
| 545 | [0] = { |
| 546 | .cd_setup = db1200_mmc_cd_setup, |
| 547 | .set_power = db1200_mmc_set_power, |
| 548 | .card_inserted = db1200_mmc_card_inserted, |
| 549 | .card_readonly = db1200_mmc_card_readonly, |
| 550 | .led = &db1200_mmc_led, |
| 551 | }, |
| 552 | [1] = { |
| 553 | .cd_setup = pb1200_mmc1_cd_setup, |
| 554 | .set_power = pb1200_mmc1_set_power, |
| 555 | .card_inserted = pb1200_mmc1_card_inserted, |
| 556 | .card_readonly = pb1200_mmc1_card_readonly, |
| 557 | .led = &pb1200_mmc1_led, |
| 558 | }, |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 559 | }; |
| 560 | |
| 561 | static struct resource au1200_mmc0_resources[] = { |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 562 | [0] = { |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 563 | .start = AU1100_SD0_PHYS_ADDR, |
| 564 | .end = AU1100_SD0_PHYS_ADDR + 0xfff, |
| 565 | .flags = IORESOURCE_MEM, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 566 | }, |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 567 | [1] = { |
| 568 | .start = AU1200_SD_INT, |
| 569 | .end = AU1200_SD_INT, |
| 570 | .flags = IORESOURCE_IRQ, |
| 571 | }, |
| 572 | [2] = { |
| 573 | .start = AU1200_DSCR_CMD0_SDMS_TX0, |
| 574 | .end = AU1200_DSCR_CMD0_SDMS_TX0, |
| 575 | .flags = IORESOURCE_DMA, |
| 576 | }, |
| 577 | [3] = { |
| 578 | .start = AU1200_DSCR_CMD0_SDMS_RX0, |
| 579 | .end = AU1200_DSCR_CMD0_SDMS_RX0, |
| 580 | .flags = IORESOURCE_DMA, |
| 581 | } |
| 582 | }; |
| 583 | |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 584 | static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32); |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 585 | |
| 586 | static struct platform_device db1200_mmc0_dev = { |
| 587 | .name = "au1xxx-mmc", |
| 588 | .id = 0, |
| 589 | .dev = { |
| 590 | .dma_mask = &au1xxx_mmc_dmamask, |
| 591 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 592 | .platform_data = &db1200_mmc_platdata[0], |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 593 | }, |
| 594 | .num_resources = ARRAY_SIZE(au1200_mmc0_resources), |
| 595 | .resource = au1200_mmc0_resources, |
| 596 | }; |
| 597 | |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 598 | static struct resource au1200_mmc1_res[] = { |
| 599 | [0] = { |
| 600 | .start = AU1100_SD1_PHYS_ADDR, |
| 601 | .end = AU1100_SD1_PHYS_ADDR + 0xfff, |
| 602 | .flags = IORESOURCE_MEM, |
| 603 | }, |
| 604 | [1] = { |
| 605 | .start = AU1200_SD_INT, |
| 606 | .end = AU1200_SD_INT, |
| 607 | .flags = IORESOURCE_IRQ, |
| 608 | }, |
| 609 | [2] = { |
| 610 | .start = AU1200_DSCR_CMD0_SDMS_TX1, |
| 611 | .end = AU1200_DSCR_CMD0_SDMS_TX1, |
| 612 | .flags = IORESOURCE_DMA, |
| 613 | }, |
| 614 | [3] = { |
| 615 | .start = AU1200_DSCR_CMD0_SDMS_RX1, |
| 616 | .end = AU1200_DSCR_CMD0_SDMS_RX1, |
| 617 | .flags = IORESOURCE_DMA, |
| 618 | } |
| 619 | }; |
| 620 | |
| 621 | static struct platform_device pb1200_mmc1_dev = { |
| 622 | .name = "au1xxx-mmc", |
| 623 | .id = 1, |
| 624 | .dev = { |
| 625 | .dma_mask = &au1xxx_mmc_dmamask, |
| 626 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 627 | .platform_data = &db1200_mmc_platdata[1], |
| 628 | }, |
| 629 | .num_resources = ARRAY_SIZE(au1200_mmc1_res), |
| 630 | .resource = au1200_mmc1_res, |
| 631 | }; |
| 632 | |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 633 | /**********************************************************************/ |
| 634 | |
Manuel Lauss | a9b71a8 | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 635 | static int db1200fb_panel_index(void) |
| 636 | { |
| 637 | return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f; |
| 638 | } |
| 639 | |
| 640 | static int db1200fb_panel_init(void) |
| 641 | { |
| 642 | /* Apply power */ |
| 643 | bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | |
| 644 | BCSR_BOARD_LCDBL); |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | static int db1200fb_panel_shutdown(void) |
| 649 | { |
| 650 | /* Remove power */ |
| 651 | bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | |
| 652 | BCSR_BOARD_LCDBL, 0); |
| 653 | return 0; |
| 654 | } |
| 655 | |
| 656 | static struct au1200fb_platdata db1200fb_pd = { |
| 657 | .panel_index = db1200fb_panel_index, |
| 658 | .panel_init = db1200fb_panel_init, |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 659 | .panel_shutdown = db1200fb_panel_shutdown, |
Manuel Lauss | a9b71a8 | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 660 | }; |
| 661 | |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 662 | static struct resource au1200_lcd_res[] = { |
| 663 | [0] = { |
| 664 | .start = AU1200_LCD_PHYS_ADDR, |
| 665 | .end = AU1200_LCD_PHYS_ADDR + 0x800 - 1, |
| 666 | .flags = IORESOURCE_MEM, |
| 667 | }, |
| 668 | [1] = { |
| 669 | .start = AU1200_LCD_INT, |
| 670 | .end = AU1200_LCD_INT, |
| 671 | .flags = IORESOURCE_IRQ, |
| 672 | } |
| 673 | }; |
| 674 | |
| 675 | static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32); |
| 676 | |
| 677 | static struct platform_device au1200_lcd_dev = { |
| 678 | .name = "au1200-lcd", |
| 679 | .id = 0, |
| 680 | .dev = { |
| 681 | .dma_mask = &au1200_lcd_dmamask, |
| 682 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Manuel Lauss | a9b71a8 | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 683 | .platform_data = &db1200fb_pd, |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 684 | }, |
| 685 | .num_resources = ARRAY_SIZE(au1200_lcd_res), |
| 686 | .resource = au1200_lcd_res, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 687 | }; |
| 688 | |
| 689 | /**********************************************************************/ |
| 690 | |
| 691 | static struct resource au1200_psc0_res[] = { |
| 692 | [0] = { |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 693 | .start = AU1550_PSC0_PHYS_ADDR, |
| 694 | .end = AU1550_PSC0_PHYS_ADDR + 0xfff, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 695 | .flags = IORESOURCE_MEM, |
| 696 | }, |
| 697 | [1] = { |
| 698 | .start = AU1200_PSC0_INT, |
| 699 | .end = AU1200_PSC0_INT, |
| 700 | .flags = IORESOURCE_IRQ, |
| 701 | }, |
| 702 | [2] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame] | 703 | .start = AU1200_DSCR_CMD0_PSC0_TX, |
| 704 | .end = AU1200_DSCR_CMD0_PSC0_TX, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 705 | .flags = IORESOURCE_DMA, |
| 706 | }, |
| 707 | [3] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame] | 708 | .start = AU1200_DSCR_CMD0_PSC0_RX, |
| 709 | .end = AU1200_DSCR_CMD0_PSC0_RX, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 710 | .flags = IORESOURCE_DMA, |
| 711 | }, |
| 712 | }; |
| 713 | |
| 714 | static struct platform_device db1200_i2c_dev = { |
| 715 | .name = "au1xpsc_smbus", |
| 716 | .id = 0, /* bus number */ |
| 717 | .num_resources = ARRAY_SIZE(au1200_psc0_res), |
| 718 | .resource = au1200_psc0_res, |
| 719 | }; |
| 720 | |
| 721 | static void db1200_spi_cs_en(struct au1550_spi_info *spi, int cs, int pol) |
| 722 | { |
| 723 | if (cs) |
| 724 | bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_SPISEL); |
| 725 | else |
| 726 | bcsr_mod(BCSR_RESETS, BCSR_RESETS_SPISEL, 0); |
| 727 | } |
| 728 | |
| 729 | static struct au1550_spi_info db1200_spi_platdata = { |
| 730 | .mainclk_hz = 50000000, /* PSC0 clock */ |
| 731 | .num_chipselect = 2, |
| 732 | .activate_cs = db1200_spi_cs_en, |
| 733 | }; |
| 734 | |
FUJITA Tomonori | 25c8f83 | 2010-06-24 01:26:09 +0900 | [diff] [blame] | 735 | static u64 spi_dmamask = DMA_BIT_MASK(32); |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 736 | |
| 737 | static struct platform_device db1200_spi_dev = { |
| 738 | .dev = { |
| 739 | .dma_mask = &spi_dmamask, |
FUJITA Tomonori | 25c8f83 | 2010-06-24 01:26:09 +0900 | [diff] [blame] | 740 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 741 | .platform_data = &db1200_spi_platdata, |
| 742 | }, |
| 743 | .name = "au1550-spi", |
| 744 | .id = 0, /* bus number */ |
| 745 | .num_resources = ARRAY_SIZE(au1200_psc0_res), |
| 746 | .resource = au1200_psc0_res, |
| 747 | }; |
| 748 | |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 749 | static struct resource au1200_psc1_res[] = { |
| 750 | [0] = { |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 751 | .start = AU1550_PSC1_PHYS_ADDR, |
| 752 | .end = AU1550_PSC1_PHYS_ADDR + 0xfff, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 753 | .flags = IORESOURCE_MEM, |
| 754 | }, |
| 755 | [1] = { |
| 756 | .start = AU1200_PSC1_INT, |
| 757 | .end = AU1200_PSC1_INT, |
| 758 | .flags = IORESOURCE_IRQ, |
| 759 | }, |
| 760 | [2] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame] | 761 | .start = AU1200_DSCR_CMD0_PSC1_TX, |
| 762 | .end = AU1200_DSCR_CMD0_PSC1_TX, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 763 | .flags = IORESOURCE_DMA, |
| 764 | }, |
| 765 | [3] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame] | 766 | .start = AU1200_DSCR_CMD0_PSC1_RX, |
| 767 | .end = AU1200_DSCR_CMD0_PSC1_RX, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 768 | .flags = IORESOURCE_DMA, |
| 769 | }, |
| 770 | }; |
| 771 | |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 772 | /* AC97 or I2S device */ |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 773 | static struct platform_device db1200_audio_dev = { |
| 774 | /* name assigned later based on switch setting */ |
| 775 | .id = 1, /* PSC ID */ |
| 776 | .num_resources = ARRAY_SIZE(au1200_psc1_res), |
| 777 | .resource = au1200_psc1_res, |
| 778 | }; |
| 779 | |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 780 | /* DB1200 ASoC card device */ |
| 781 | static struct platform_device db1200_sound_dev = { |
| 782 | /* name assigned later based on switch setting */ |
| 783 | .id = 1, /* PSC ID */ |
| 784 | }; |
| 785 | |
Manuel Lauss | ffc4fdb | 2010-08-26 14:53:51 +0200 | [diff] [blame] | 786 | static struct platform_device db1200_stac_dev = { |
| 787 | .name = "ac97-codec", |
| 788 | .id = 1, /* on PSC1 */ |
| 789 | }; |
| 790 | |
Manuel Lauss | 5b0912b | 2011-07-25 13:45:02 +0200 | [diff] [blame] | 791 | static struct platform_device db1200_audiodma_dev = { |
| 792 | .name = "au1xpsc-pcm", |
| 793 | .id = 1, /* PSC ID */ |
| 794 | }; |
| 795 | |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 796 | static struct platform_device *db1200_devs[] __initdata = { |
| 797 | NULL, /* PSC0, selected by S6.8 */ |
| 798 | &db1200_ide_dev, |
Manuel Lauss | 376638603 | 2011-08-12 11:39:45 +0200 | [diff] [blame] | 799 | &db1200_mmc0_dev, |
| 800 | &au1200_lcd_dev, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 801 | &db1200_eth_dev, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 802 | &db1200_nand_dev, |
Manuel Lauss | 5b0912b | 2011-07-25 13:45:02 +0200 | [diff] [blame] | 803 | &db1200_audiodma_dev, |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 804 | &db1200_audio_dev, |
Manuel Lauss | ffc4fdb | 2010-08-26 14:53:51 +0200 | [diff] [blame] | 805 | &db1200_stac_dev, |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 806 | &db1200_sound_dev, |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 807 | }; |
| 808 | |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 809 | static struct platform_device *pb1200_devs[] __initdata = { |
| 810 | &pb1200_mmc1_dev, |
| 811 | }; |
| 812 | |
| 813 | /* Some peripheral base addresses differ on the PB1200 */ |
| 814 | static int __init pb1200_res_fixup(void) |
| 815 | { |
| 816 | /* CPLD Revs earlier than 4 cause problems */ |
| 817 | if (BCSR_WHOAMI_CPLD(bcsr_read(BCSR_WHOAMI)) <= 3) { |
| 818 | printk(KERN_ERR "WARNING!!!\n"); |
| 819 | printk(KERN_ERR "WARNING!!!\n"); |
| 820 | printk(KERN_ERR "PB1200 must be at CPLD rev 4. Please have\n"); |
| 821 | printk(KERN_ERR "the board updated to latest revisions.\n"); |
| 822 | printk(KERN_ERR "This software will not work reliably\n"); |
| 823 | printk(KERN_ERR "on anything older than CPLD rev 4.!\n"); |
| 824 | printk(KERN_ERR "WARNING!!!\n"); |
| 825 | printk(KERN_ERR "WARNING!!!\n"); |
| 826 | return 1; |
| 827 | } |
| 828 | |
| 829 | db1200_nand_res[0].start = PB1200_NAND_PHYS_ADDR; |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 830 | db1200_nand_res[0].end = PB1200_NAND_PHYS_ADDR + 0xff; |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 831 | db1200_ide_res[0].start = PB1200_IDE_PHYS_ADDR; |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 832 | db1200_ide_res[0].end = PB1200_IDE_PHYS_ADDR + DB1200_IDE_PHYS_LEN - 1; |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 833 | db1200_eth_res[0].start = PB1200_ETH_PHYS_ADDR; |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 834 | db1200_eth_res[0].end = PB1200_ETH_PHYS_ADDR + 0xff; |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 835 | return 0; |
| 836 | } |
| 837 | |
Manuel Lauss | bd8510d | 2012-09-13 17:44:39 +0200 | [diff] [blame] | 838 | int __init db1200_dev_setup(void) |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 839 | { |
| 840 | unsigned long pfc; |
| 841 | unsigned short sw; |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 842 | int swapped, bid; |
| 843 | |
| 844 | bid = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)); |
| 845 | if ((bid == BCSR_WHOAMI_PB1200_DDR1) || |
| 846 | (bid == BCSR_WHOAMI_PB1200_DDR2)) { |
| 847 | if (pb1200_res_fixup()) |
| 848 | return -ENODEV; |
| 849 | } |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 850 | |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 851 | /* GPIO7 is low-level triggered CPLD cascade */ |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 852 | irq_set_irq_type(AU1200_GPIO7_INT, IRQ_TYPE_LEVEL_LOW); |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 853 | bcsr_init_irq(DB1200_INT_BEGIN, DB1200_INT_END, AU1200_GPIO7_INT); |
| 854 | |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 855 | /* insert/eject pairs: one of both is always screaming. To avoid |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 856 | * issues they must not be automatically enabled when initially |
| 857 | * requested. |
| 858 | */ |
| 859 | irq_set_status_flags(DB1200_SD0_INSERT_INT, IRQ_NOAUTOEN); |
| 860 | irq_set_status_flags(DB1200_SD0_EJECT_INT, IRQ_NOAUTOEN); |
| 861 | irq_set_status_flags(DB1200_PC0_INSERT_INT, IRQ_NOAUTOEN); |
| 862 | irq_set_status_flags(DB1200_PC0_EJECT_INT, IRQ_NOAUTOEN); |
| 863 | irq_set_status_flags(DB1200_PC1_INSERT_INT, IRQ_NOAUTOEN); |
| 864 | irq_set_status_flags(DB1200_PC1_EJECT_INT, IRQ_NOAUTOEN); |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 865 | |
| 866 | i2c_register_board_info(0, db1200_i2c_devs, |
| 867 | ARRAY_SIZE(db1200_i2c_devs)); |
| 868 | spi_register_board_info(db1200_spi_devs, |
| 869 | ARRAY_SIZE(db1200_i2c_devs)); |
| 870 | |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 871 | /* SWITCHES: S6.8 I2C/SPI selector (OFF=I2C ON=SPI) |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 872 | * S6.7 AC97/I2S selector (OFF=AC97 ON=I2S) |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 873 | * or S12 on the PB1200. |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 874 | */ |
| 875 | |
| 876 | /* NOTE: GPIO215 controls OTG VBUS supply. In SPI mode however |
| 877 | * this pin is claimed by PSC0 (unused though, but pinmux doesn't |
| 878 | * allow to free it without crippling the SPI interface). |
| 879 | * As a result, in SPI mode, OTG simply won't work (PSC0 uses |
| 880 | * it as an input pin which is pulled high on the boards). |
| 881 | */ |
| 882 | pfc = __raw_readl((void __iomem *)SYS_PINFUNC) & ~SYS_PINFUNC_P0A; |
| 883 | |
| 884 | /* switch off OTG VBUS supply */ |
| 885 | gpio_request(215, "otg-vbus"); |
| 886 | gpio_direction_output(215, 1); |
| 887 | |
Manuel Lauss | bd8510d | 2012-09-13 17:44:39 +0200 | [diff] [blame] | 888 | printk(KERN_INFO "%s device configuration:\n", get_system_type()); |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 889 | |
| 890 | sw = bcsr_read(BCSR_SWITCHES); |
| 891 | if (sw & BCSR_SWITCHES_DIP_8) { |
| 892 | db1200_devs[0] = &db1200_i2c_dev; |
| 893 | bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC0MUX, 0); |
| 894 | |
| 895 | pfc |= (2 << 17); /* GPIO2 block owns GPIO215 */ |
| 896 | |
| 897 | printk(KERN_INFO " S6.8 OFF: PSC0 mode I2C\n"); |
| 898 | printk(KERN_INFO " OTG port VBUS supply available!\n"); |
| 899 | } else { |
| 900 | db1200_devs[0] = &db1200_spi_dev; |
| 901 | bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_PSC0MUX); |
| 902 | |
| 903 | pfc |= (1 << 17); /* PSC0 owns GPIO215 */ |
| 904 | |
| 905 | printk(KERN_INFO " S6.8 ON : PSC0 mode SPI\n"); |
| 906 | printk(KERN_INFO " OTG port VBUS supply disabled\n"); |
| 907 | } |
| 908 | __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); |
| 909 | wmb(); |
| 910 | |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 911 | /* Audio: DIP7 selects I2S(0)/AC97(1), but need I2C for I2S! |
| 912 | * so: DIP7=1 || DIP8=0 => AC97, DIP7=0 && DIP8=1 => I2S |
| 913 | */ |
| 914 | sw &= BCSR_SWITCHES_DIP_8 | BCSR_SWITCHES_DIP_7; |
| 915 | if (sw == BCSR_SWITCHES_DIP_8) { |
| 916 | bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_PSC1MUX); |
| 917 | db1200_audio_dev.name = "au1xpsc_i2s"; |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 918 | db1200_sound_dev.name = "db1200-i2s"; |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 919 | printk(KERN_INFO " S6.7 ON : PSC1 mode I2S\n"); |
| 920 | } else { |
| 921 | bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC1MUX, 0); |
| 922 | db1200_audio_dev.name = "au1xpsc_ac97"; |
Manuel Lauss | adbc7a5 | 2011-07-25 13:45:03 +0200 | [diff] [blame] | 923 | db1200_sound_dev.name = "db1200-ac97"; |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 924 | printk(KERN_INFO " S6.7 OFF: PSC1 mode AC97\n"); |
| 925 | } |
| 926 | |
| 927 | /* Audio PSC clock is supplied externally. (FIXME: platdata!!) */ |
| 928 | __raw_writel(PSC_SEL_CLK_SERCLK, |
Manuel Lauss | 7c4b24d | 2011-11-10 12:06:21 +0000 | [diff] [blame] | 929 | (void __iomem *)KSEG1ADDR(AU1550_PSC1_PHYS_ADDR) + PSC_SEL_OFFSET); |
Manuel Lauss | 05ae323 | 2009-11-02 21:21:44 +0100 | [diff] [blame] | 930 | wmb(); |
| 931 | |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 932 | db1x_register_pcmcia_socket( |
| 933 | AU1000_PCMCIA_ATTR_PHYS_ADDR, |
| 934 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1, |
| 935 | AU1000_PCMCIA_MEM_PHYS_ADDR, |
| 936 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1, |
| 937 | AU1000_PCMCIA_IO_PHYS_ADDR, |
| 938 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1, |
| 939 | DB1200_PC0_INT, DB1200_PC0_INSERT_INT, |
| 940 | /*DB1200_PC0_STSCHG_INT*/0, DB1200_PC0_EJECT_INT, 0); |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 941 | |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 942 | db1x_register_pcmcia_socket( |
| 943 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000, |
| 944 | AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1, |
| 945 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000, |
| 946 | AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1, |
| 947 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000, |
| 948 | AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1, |
| 949 | DB1200_PC1_INT, DB1200_PC1_INSERT_INT, |
| 950 | /*DB1200_PC1_STSCHG_INT*/0, DB1200_PC1_EJECT_INT, 1); |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 951 | |
| 952 | swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1200_SWAPBOOT; |
| 953 | db1x_register_norflash(64 << 20, 2, swapped); |
| 954 | |
Manuel Lauss | 6f7c862 | 2011-11-10 12:06:22 +0000 | [diff] [blame] | 955 | platform_add_devices(db1200_devs, ARRAY_SIZE(db1200_devs)); |
| 956 | |
| 957 | /* PB1200 is a DB1200 with a 2nd MMC and Camera connector */ |
| 958 | if ((bid == BCSR_WHOAMI_PB1200_DDR1) || |
| 959 | (bid == BCSR_WHOAMI_PB1200_DDR2)) |
| 960 | platform_add_devices(pb1200_devs, ARRAY_SIZE(pb1200_devs)); |
| 961 | |
| 962 | return 0; |
Manuel Lauss | 63323ec | 2009-11-02 21:21:43 +0100 | [diff] [blame] | 963 | } |