blob: 8201f00d575b23e687b88f1d505c85c450e85522 [file] [log] [blame]
Manuel Lauss27dd65a2009-10-04 14:55:28 +02001/*
Manuel Lauss851d4f52012-09-14 18:25:00 +02002 * DBAu1000/1500/1100 PBAu1100/1500 board support
Manuel Lauss27dd65a2009-10-04 14:55:28 +02003 *
Manuel Lauss7c4b24d2011-11-10 12:06:21 +00004 * Copyright 2000, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. <source@mvista.com>
Manuel Lauss27dd65a2009-10-04 14:55:28 +02006 *
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 Lauss7c4b24d2011-11-10 12:06:21 +000022#include <linux/dma-mapping.h>
23#include <linux/gpio.h>
Manuel Lauss27dd65a2009-10-04 14:55:28 +020024#include <linux/init.h>
Manuel Laussb2ce3052011-07-25 13:44:46 +020025#include <linux/interrupt.h>
Manuel Laussc9af5142011-11-10 12:06:22 +000026#include <linux/leds.h>
27#include <linux/mmc/host.h>
28#include <linux/module.h>
Manuel Lauss27dd65a2009-10-04 14:55:28 +020029#include <linux/platform_device.h>
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000030#include <linux/pm.h>
Manuel Lauss2a32daf2011-12-08 10:42:15 +000031#include <linux/spi/spi.h>
32#include <linux/spi/spi_gpio.h>
33#include <linux/spi/ads7846.h>
Manuel Laussb2ce3052011-07-25 13:44:46 +020034#include <asm/mach-au1x00/au1000.h>
35#include <asm/mach-au1x00/au1000_dma.h>
Manuel Laussc9af5142011-11-10 12:06:22 +000036#include <asm/mach-au1x00/au1100_mmc.h>
Manuel Lauss206aa6c2009-10-19 12:53:37 +020037#include <asm/mach-db1x00/bcsr.h>
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000038#include <asm/reboot.h>
39#include <prom.h>
40#include "platform.h"
Manuel Lauss27dd65a2009-10-04 14:55:28 +020041
Manuel Laussf59c8112011-11-10 12:06:22 +000042#define F_SWAPPED (bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT)
43
Manuel Lauss970e2682014-02-20 14:59:24 +010044const char *get_system_type(void);
Manuel Lauss7517de32011-08-12 11:39:44 +020045
Manuel Lauss970e2682014-02-20 14:59:24 +010046int __init db1000_board_setup(void)
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000047{
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000048 /* initialize board register space */
49 bcsr_init(DB1000_BCSR_PHYS_ADDR,
50 DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS);
51
Manuel Lauss970e2682014-02-20 14:59:24 +010052 switch (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) {
53 case BCSR_WHOAMI_DB1000:
54 case BCSR_WHOAMI_DB1500:
55 case BCSR_WHOAMI_DB1100:
56 case BCSR_WHOAMI_PB1500:
57 case BCSR_WHOAMI_PB1500R2:
58 case BCSR_WHOAMI_PB1100:
59 pr_info("AMD Alchemy %s Board\n", get_system_type());
60 return 0;
61 }
62 return -ENODEV;
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000063}
64
Manuel Laussf869d422011-11-10 12:06:16 +000065static int db1500_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
Manuel Lauss7517de32011-08-12 11:39:44 +020066{
67 if ((slot < 12) || (slot > 13) || pin == 0)
68 return -1;
69 if (slot == 12)
70 return (pin == 1) ? AU1500_PCI_INTA : 0xff;
71 if (slot == 13) {
72 switch (pin) {
73 case 1: return AU1500_PCI_INTA;
74 case 2: return AU1500_PCI_INTB;
75 case 3: return AU1500_PCI_INTC;
76 case 4: return AU1500_PCI_INTD;
77 }
78 }
79 return -1;
80}
Manuel Lauss7517de32011-08-12 11:39:44 +020081
Manuel Lauss7517de32011-08-12 11:39:44 +020082static struct resource alchemy_pci_host_res[] = {
83 [0] = {
84 .start = AU1500_PCI_PHYS_ADDR,
85 .end = AU1500_PCI_PHYS_ADDR + 0xfff,
86 .flags = IORESOURCE_MEM,
87 },
88};
89
Manuel Laussf869d422011-11-10 12:06:16 +000090static struct alchemy_pci_platdata db1500_pci_pd = {
91 .board_map_irq = db1500_map_pci_irq,
Manuel Lauss7517de32011-08-12 11:39:44 +020092};
93
Manuel Laussf869d422011-11-10 12:06:16 +000094static struct platform_device db1500_pci_host_dev = {
95 .dev.platform_data = &db1500_pci_pd,
Manuel Lauss7517de32011-08-12 11:39:44 +020096 .name = "alchemy-pci",
97 .id = 0,
98 .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
99 .resource = alchemy_pci_host_res,
100};
101
Manuel Lauss970e2682014-02-20 14:59:24 +0100102int __init db1500_pci_setup(void)
Manuel Lauss7517de32011-08-12 11:39:44 +0200103{
Manuel Lauss970e2682014-02-20 14:59:24 +0100104 return platform_device_register(&db1500_pci_host_dev);
Manuel Lauss7517de32011-08-12 11:39:44 +0200105}
Manuel Laussf59c8112011-11-10 12:06:22 +0000106
Manuel Lauss3766386032011-08-12 11:39:45 +0200107static struct resource au1100_lcd_resources[] = {
108 [0] = {
109 .start = AU1100_LCD_PHYS_ADDR,
110 .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1,
111 .flags = IORESOURCE_MEM,
112 },
113 [1] = {
114 .start = AU1100_LCD_INT,
115 .end = AU1100_LCD_INT,
116 .flags = IORESOURCE_IRQ,
117 }
118};
119
120static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32);
121
122static struct platform_device au1100_lcd_device = {
123 .name = "au1100-lcd",
124 .id = 0,
125 .dev = {
126 .dma_mask = &au1100_lcd_dmamask,
127 .coherent_dma_mask = DMA_BIT_MASK(32),
128 },
129 .num_resources = ARRAY_SIZE(au1100_lcd_resources),
130 .resource = au1100_lcd_resources,
131};
Manuel Lauss3766386032011-08-12 11:39:45 +0200132
Manuel Laussb2ce3052011-07-25 13:44:46 +0200133static struct resource alchemy_ac97c_res[] = {
134 [0] = {
135 .start = AU1000_AC97_PHYS_ADDR,
136 .end = AU1000_AC97_PHYS_ADDR + 0xfff,
137 .flags = IORESOURCE_MEM,
138 },
139 [1] = {
140 .start = DMA_ID_AC97C_TX,
141 .end = DMA_ID_AC97C_TX,
142 .flags = IORESOURCE_DMA,
143 },
144 [2] = {
145 .start = DMA_ID_AC97C_RX,
146 .end = DMA_ID_AC97C_RX,
147 .flags = IORESOURCE_DMA,
148 },
149};
150
151static struct platform_device alchemy_ac97c_dev = {
152 .name = "alchemy-ac97c",
153 .id = -1,
154 .resource = alchemy_ac97c_res,
155 .num_resources = ARRAY_SIZE(alchemy_ac97c_res),
156};
157
158static struct platform_device alchemy_ac97c_dma_dev = {
159 .name = "alchemy-pcm-dma",
160 .id = 0,
161};
162
163static struct platform_device db1x00_codec_dev = {
164 .name = "ac97-codec",
165 .id = -1,
166};
167
168static struct platform_device db1x00_audio_dev = {
169 .name = "db1000-audio",
170};
171
Manuel Laussc9af5142011-11-10 12:06:22 +0000172/******************************************************************************/
173
174static irqreturn_t db1100_mmc_cd(int irq, void *ptr)
175{
176 void (*mmc_cd)(struct mmc_host *, unsigned long);
177 /* link against CONFIG_MMC=m */
178 mmc_cd = symbol_get(mmc_detect_change);
179 mmc_cd(ptr, msecs_to_jiffies(500));
180 symbol_put(mmc_detect_change);
181
182 return IRQ_HANDLED;
183}
184
185static int db1100_mmc_cd_setup(void *mmc_host, int en)
186{
Manuel Lauss851d4f52012-09-14 18:25:00 +0200187 int ret = 0, irq;
188
189 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1100)
190 irq = AU1100_GPIO19_INT;
191 else
192 irq = AU1100_GPIO14_INT; /* PB1100 SD0 CD# */
Manuel Laussc9af5142011-11-10 12:06:22 +0000193
194 if (en) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200195 irq_set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
196 ret = request_irq(irq, db1100_mmc_cd, 0,
Manuel Laussc9af5142011-11-10 12:06:22 +0000197 "sd0_cd", mmc_host);
198 } else
Manuel Lauss851d4f52012-09-14 18:25:00 +0200199 free_irq(irq, mmc_host);
Manuel Laussc9af5142011-11-10 12:06:22 +0000200 return ret;
201}
202
203static int db1100_mmc1_cd_setup(void *mmc_host, int en)
204{
Manuel Lauss851d4f52012-09-14 18:25:00 +0200205 int ret = 0, irq;
206
207 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1100)
208 irq = AU1100_GPIO20_INT;
209 else
210 irq = AU1100_GPIO15_INT; /* PB1100 SD1 CD# */
Manuel Laussc9af5142011-11-10 12:06:22 +0000211
212 if (en) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200213 irq_set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
214 ret = request_irq(irq, db1100_mmc_cd, 0,
Manuel Laussc9af5142011-11-10 12:06:22 +0000215 "sd1_cd", mmc_host);
216 } else
Manuel Lauss851d4f52012-09-14 18:25:00 +0200217 free_irq(irq, mmc_host);
Manuel Laussc9af5142011-11-10 12:06:22 +0000218 return ret;
219}
220
221static int db1100_mmc_card_readonly(void *mmc_host)
222{
223 /* testing suggests that this bit is inverted */
224 return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 0 : 1;
225}
226
227static int db1100_mmc_card_inserted(void *mmc_host)
228{
229 return !alchemy_gpio_get_value(19);
230}
231
232static void db1100_mmc_set_power(void *mmc_host, int state)
233{
Manuel Lauss851d4f52012-09-14 18:25:00 +0200234 int bit;
235
236 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1100)
237 bit = BCSR_BOARD_SD0PWR;
238 else
239 bit = BCSR_BOARD_PB1100_SD0PWR;
240
Manuel Laussc9af5142011-11-10 12:06:22 +0000241 if (state) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200242 bcsr_mod(BCSR_BOARD, 0, bit);
Manuel Laussc9af5142011-11-10 12:06:22 +0000243 msleep(400); /* stabilization time */
244 } else
Manuel Lauss851d4f52012-09-14 18:25:00 +0200245 bcsr_mod(BCSR_BOARD, bit, 0);
Manuel Laussc9af5142011-11-10 12:06:22 +0000246}
247
248static void db1100_mmcled_set(struct led_classdev *led, enum led_brightness b)
249{
250 if (b != LED_OFF)
251 bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
252 else
253 bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
254}
255
256static struct led_classdev db1100_mmc_led = {
Ralf Baechle70342282013-01-22 12:59:30 +0100257 .brightness_set = db1100_mmcled_set,
Manuel Laussc9af5142011-11-10 12:06:22 +0000258};
259
260static int db1100_mmc1_card_readonly(void *mmc_host)
261{
262 return (bcsr_read(BCSR_BOARD) & BCSR_BOARD_SD1WP) ? 1 : 0;
263}
264
265static int db1100_mmc1_card_inserted(void *mmc_host)
266{
267 return !alchemy_gpio_get_value(20);
268}
269
270static void db1100_mmc1_set_power(void *mmc_host, int state)
271{
Manuel Lauss851d4f52012-09-14 18:25:00 +0200272 int bit;
273
274 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1100)
275 bit = BCSR_BOARD_SD1PWR;
276 else
277 bit = BCSR_BOARD_PB1100_SD1PWR;
278
Manuel Laussc9af5142011-11-10 12:06:22 +0000279 if (state) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200280 bcsr_mod(BCSR_BOARD, 0, bit);
Manuel Laussc9af5142011-11-10 12:06:22 +0000281 msleep(400); /* stabilization time */
282 } else
Manuel Lauss851d4f52012-09-14 18:25:00 +0200283 bcsr_mod(BCSR_BOARD, bit, 0);
Manuel Laussc9af5142011-11-10 12:06:22 +0000284}
285
286static void db1100_mmc1led_set(struct led_classdev *led, enum led_brightness b)
287{
288 if (b != LED_OFF)
289 bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED1, 0);
290 else
291 bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED1);
292}
293
294static struct led_classdev db1100_mmc1_led = {
Ralf Baechle70342282013-01-22 12:59:30 +0100295 .brightness_set = db1100_mmc1led_set,
Manuel Laussc9af5142011-11-10 12:06:22 +0000296};
297
298static struct au1xmmc_platform_data db1100_mmc_platdata[2] = {
299 [0] = {
300 .cd_setup = db1100_mmc_cd_setup,
301 .set_power = db1100_mmc_set_power,
302 .card_inserted = db1100_mmc_card_inserted,
303 .card_readonly = db1100_mmc_card_readonly,
304 .led = &db1100_mmc_led,
305 },
306 [1] = {
307 .cd_setup = db1100_mmc1_cd_setup,
308 .set_power = db1100_mmc1_set_power,
309 .card_inserted = db1100_mmc1_card_inserted,
310 .card_readonly = db1100_mmc1_card_readonly,
311 .led = &db1100_mmc1_led,
312 },
313};
314
315static struct resource au1100_mmc0_resources[] = {
316 [0] = {
317 .start = AU1100_SD0_PHYS_ADDR,
318 .end = AU1100_SD0_PHYS_ADDR + 0xfff,
319 .flags = IORESOURCE_MEM,
320 },
321 [1] = {
322 .start = AU1100_SD_INT,
323 .end = AU1100_SD_INT,
324 .flags = IORESOURCE_IRQ,
325 },
326 [2] = {
327 .start = DMA_ID_SD0_TX,
328 .end = DMA_ID_SD0_TX,
329 .flags = IORESOURCE_DMA,
330 },
331 [3] = {
332 .start = DMA_ID_SD0_RX,
333 .end = DMA_ID_SD0_RX,
334 .flags = IORESOURCE_DMA,
335 }
336};
337
Ralf Baechle70342282013-01-22 12:59:30 +0100338static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32);
Manuel Laussc9af5142011-11-10 12:06:22 +0000339
340static struct platform_device db1100_mmc0_dev = {
341 .name = "au1xxx-mmc",
342 .id = 0,
343 .dev = {
344 .dma_mask = &au1xxx_mmc_dmamask,
345 .coherent_dma_mask = DMA_BIT_MASK(32),
346 .platform_data = &db1100_mmc_platdata[0],
347 },
348 .num_resources = ARRAY_SIZE(au1100_mmc0_resources),
349 .resource = au1100_mmc0_resources,
350};
351
352static struct resource au1100_mmc1_res[] = {
353 [0] = {
354 .start = AU1100_SD1_PHYS_ADDR,
355 .end = AU1100_SD1_PHYS_ADDR + 0xfff,
356 .flags = IORESOURCE_MEM,
357 },
358 [1] = {
359 .start = AU1100_SD_INT,
360 .end = AU1100_SD_INT,
361 .flags = IORESOURCE_IRQ,
362 },
363 [2] = {
364 .start = DMA_ID_SD1_TX,
365 .end = DMA_ID_SD1_TX,
366 .flags = IORESOURCE_DMA,
367 },
368 [3] = {
369 .start = DMA_ID_SD1_RX,
370 .end = DMA_ID_SD1_RX,
371 .flags = IORESOURCE_DMA,
372 }
373};
374
375static struct platform_device db1100_mmc1_dev = {
376 .name = "au1xxx-mmc",
377 .id = 1,
378 .dev = {
379 .dma_mask = &au1xxx_mmc_dmamask,
380 .coherent_dma_mask = DMA_BIT_MASK(32),
381 .platform_data = &db1100_mmc_platdata[1],
382 },
383 .num_resources = ARRAY_SIZE(au1100_mmc1_res),
384 .resource = au1100_mmc1_res,
385};
386
Manuel Lausse734ae12011-12-08 10:42:15 +0000387/******************************************************************************/
388
389static void db1000_irda_set_phy_mode(int mode)
390{
391 unsigned short mask = BCSR_RESETS_IRDA_MODE_MASK | BCSR_RESETS_FIR_SEL;
392
393 switch (mode) {
394 case AU1000_IRDA_PHY_MODE_OFF:
395 bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_OFF);
396 break;
397 case AU1000_IRDA_PHY_MODE_SIR:
398 bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_FULL);
399 break;
400 case AU1000_IRDA_PHY_MODE_FIR:
401 bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_FULL |
402 BCSR_RESETS_FIR_SEL);
403 break;
404 }
405}
406
407static struct au1k_irda_platform_data db1000_irda_platdata = {
408 .set_phy_mode = db1000_irda_set_phy_mode,
409};
410
411static struct resource au1000_irda_res[] = {
412 [0] = {
413 .start = AU1000_IRDA_PHYS_ADDR,
414 .end = AU1000_IRDA_PHYS_ADDR + 0x0fff,
415 .flags = IORESOURCE_MEM,
416 },
417 [1] = {
418 .start = AU1000_IRDA_TX_INT,
419 .end = AU1000_IRDA_TX_INT,
420 .flags = IORESOURCE_IRQ,
421 },
422 [2] = {
423 .start = AU1000_IRDA_RX_INT,
424 .end = AU1000_IRDA_RX_INT,
425 .flags = IORESOURCE_IRQ,
426 },
427};
428
429static struct platform_device db1000_irda_dev = {
430 .name = "au1000-irda",
431 .id = -1,
432 .dev = {
433 .platform_data = &db1000_irda_platdata,
434 },
435 .resource = au1000_irda_res,
436 .num_resources = ARRAY_SIZE(au1000_irda_res),
437};
Manuel Laussc9af5142011-11-10 12:06:22 +0000438
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000439/******************************************************************************/
440
441static struct ads7846_platform_data db1100_touch_pd = {
442 .model = 7846,
443 .vref_mv = 3300,
444 .gpio_pendown = 21,
445};
446
447static struct spi_gpio_platform_data db1100_spictl_pd = {
448 .sck = 209,
449 .mosi = 208,
450 .miso = 207,
451 .num_chipselect = 1,
452};
453
454static struct spi_board_info db1100_spi_info[] __initdata = {
455 [0] = {
456 .modalias = "ads7846",
457 .max_speed_hz = 3250000,
458 .bus_num = 0,
459 .chip_select = 0,
460 .mode = 0,
461 .irq = AU1100_GPIO21_INT,
462 .platform_data = &db1100_touch_pd,
Ralf Baechle70342282013-01-22 12:59:30 +0100463 .controller_data = (void *)210, /* for spi_gpio: CS# GPIO210 */
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000464 },
465};
466
467static struct platform_device db1100_spi_dev = {
468 .name = "spi_gpio",
469 .id = 0,
470 .dev = {
471 .platform_data = &db1100_spictl_pd,
472 },
473};
474
475
Manuel Laussf59c8112011-11-10 12:06:22 +0000476static struct platform_device *db1x00_devs[] = {
477 &db1x00_codec_dev,
478 &alchemy_ac97c_dma_dev,
479 &alchemy_ac97c_dev,
480 &db1x00_audio_dev,
481};
482
Manuel Lausse734ae12011-12-08 10:42:15 +0000483static struct platform_device *db1000_devs[] = {
484 &db1000_irda_dev,
485};
486
Manuel Laussf59c8112011-11-10 12:06:22 +0000487static struct platform_device *db1100_devs[] = {
488 &au1100_lcd_device,
Manuel Laussc9af5142011-11-10 12:06:22 +0000489 &db1100_mmc0_dev,
490 &db1100_mmc1_dev,
Manuel Lausse734ae12011-12-08 10:42:15 +0000491 &db1000_irda_dev,
Manuel Laussf59c8112011-11-10 12:06:22 +0000492};
493
Manuel Lauss970e2682014-02-20 14:59:24 +0100494int __init db1000_dev_setup(void)
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200495{
Manuel Laussf59c8112011-11-10 12:06:22 +0000496 int board = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI));
Manuel Lauss851d4f52012-09-14 18:25:00 +0200497 int c0, c1, d0, d1, s0, s1, flashsize = 32, twosocks = 1;
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000498 unsigned long pfc;
Manuel Laussf59c8112011-11-10 12:06:22 +0000499
500 if (board == BCSR_WHOAMI_DB1500) {
501 c0 = AU1500_GPIO2_INT;
502 c1 = AU1500_GPIO5_INT;
503 d0 = AU1500_GPIO0_INT;
504 d1 = AU1500_GPIO3_INT;
505 s0 = AU1500_GPIO1_INT;
506 s1 = AU1500_GPIO4_INT;
507 } else if (board == BCSR_WHOAMI_DB1100) {
508 c0 = AU1100_GPIO2_INT;
509 c1 = AU1100_GPIO5_INT;
510 d0 = AU1100_GPIO0_INT;
511 d1 = AU1100_GPIO3_INT;
512 s0 = AU1100_GPIO1_INT;
513 s1 = AU1100_GPIO4_INT;
Manuel Laussc9af5142011-11-10 12:06:22 +0000514
Manuel Lauss4294ad12014-01-29 19:11:46 +0100515 gpio_request(19, "sd0_cd");
516 gpio_request(20, "sd1_cd");
Manuel Laussc9af5142011-11-10 12:06:22 +0000517 gpio_direction_input(19); /* sd0 cd# */
518 gpio_direction_input(20); /* sd1 cd# */
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000519
520 /* spi_gpio on SSI0 pins */
Manuel Lauss1d09de72014-07-23 16:36:24 +0200521 pfc = alchemy_rdsys(AU1000_SYS_PINFUNC);
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000522 pfc |= (1 << 0); /* SSI0 pins as GPIOs */
Manuel Lauss1d09de72014-07-23 16:36:24 +0200523 alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000524
525 spi_register_board_info(db1100_spi_info,
526 ARRAY_SIZE(db1100_spi_info));
Manuel Laussc9af5142011-11-10 12:06:22 +0000527
Manuel Laussf59c8112011-11-10 12:06:22 +0000528 platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs));
Manuel Lauss851d4f52012-09-14 18:25:00 +0200529 platform_device_register(&db1100_spi_dev);
Manuel Laussf59c8112011-11-10 12:06:22 +0000530 } else if (board == BCSR_WHOAMI_DB1000) {
531 c0 = AU1000_GPIO2_INT;
532 c1 = AU1000_GPIO5_INT;
533 d0 = AU1000_GPIO0_INT;
534 d1 = AU1000_GPIO3_INT;
535 s0 = AU1000_GPIO1_INT;
536 s1 = AU1000_GPIO4_INT;
Manuel Lausse734ae12011-12-08 10:42:15 +0000537 platform_add_devices(db1000_devs, ARRAY_SIZE(db1000_devs));
Manuel Lauss851d4f52012-09-14 18:25:00 +0200538 } else if ((board == BCSR_WHOAMI_PB1500) ||
539 (board == BCSR_WHOAMI_PB1500R2)) {
540 c0 = AU1500_GPIO203_INT;
541 d0 = AU1500_GPIO201_INT;
542 s0 = AU1500_GPIO202_INT;
543 twosocks = 0;
544 flashsize = 64;
545 /* RTC and daughtercard irqs */
546 irq_set_irq_type(AU1500_GPIO204_INT, IRQ_TYPE_LEVEL_LOW);
547 irq_set_irq_type(AU1500_GPIO205_INT, IRQ_TYPE_LEVEL_LOW);
548 /* EPSON S1D13806 0x1b000000
Ralf Baechle70342282013-01-22 12:59:30 +0100549 * SRAM 1MB/2MB 0x1a000000
Manuel Lauss851d4f52012-09-14 18:25:00 +0200550 * DS1693 RTC 0x0c000000
551 */
552 } else if (board == BCSR_WHOAMI_PB1100) {
553 c0 = AU1100_GPIO11_INT;
554 d0 = AU1100_GPIO9_INT;
555 s0 = AU1100_GPIO10_INT;
556 twosocks = 0;
557 flashsize = 64;
558 /* pendown, rtc, daughtercard irqs */
559 irq_set_irq_type(AU1100_GPIO8_INT, IRQ_TYPE_LEVEL_LOW);
560 irq_set_irq_type(AU1100_GPIO12_INT, IRQ_TYPE_LEVEL_LOW);
561 irq_set_irq_type(AU1100_GPIO13_INT, IRQ_TYPE_LEVEL_LOW);
562 /* EPSON S1D13806 0x1b000000
Ralf Baechle70342282013-01-22 12:59:30 +0100563 * SRAM 1MB/2MB 0x1a000000
Manuel Lauss851d4f52012-09-14 18:25:00 +0200564 * DiskOnChip 0x0d000000
565 * DS1693 RTC 0x0c000000
566 */
567 platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs));
Manuel Laussf59c8112011-11-10 12:06:22 +0000568 } else
569 return 0; /* unknown board, no further dev setup to do */
570
571 irq_set_irq_type(d0, IRQ_TYPE_EDGE_BOTH);
Manuel Laussf59c8112011-11-10 12:06:22 +0000572 irq_set_irq_type(c0, IRQ_TYPE_LEVEL_LOW);
Manuel Laussf59c8112011-11-10 12:06:22 +0000573 irq_set_irq_type(s0, IRQ_TYPE_LEVEL_LOW);
Manuel Lauss7c4b24d2011-11-10 12:06:21 +0000574
Manuel Lauss7cc2e272011-08-12 11:39:40 +0200575 db1x_register_pcmcia_socket(
576 AU1000_PCMCIA_ATTR_PHYS_ADDR,
577 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
578 AU1000_PCMCIA_MEM_PHYS_ADDR,
579 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
580 AU1000_PCMCIA_IO_PHYS_ADDR,
581 AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
Ralf Baechle70342282013-01-22 12:59:30 +0100582 c0, d0, /*s0*/0, 0, 0);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200583
Manuel Lauss851d4f52012-09-14 18:25:00 +0200584 if (twosocks) {
585 irq_set_irq_type(d1, IRQ_TYPE_EDGE_BOTH);
586 irq_set_irq_type(c1, IRQ_TYPE_LEVEL_LOW);
587 irq_set_irq_type(s1, IRQ_TYPE_LEVEL_LOW);
588
589 db1x_register_pcmcia_socket(
590 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000,
591 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1,
592 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000,
593 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1,
594 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000,
595 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1,
Ralf Baechle70342282013-01-22 12:59:30 +0100596 c1, d1, /*s1*/0, 0, 1);
Manuel Lauss851d4f52012-09-14 18:25:00 +0200597 }
Manuel Laussb2ce3052011-07-25 13:44:46 +0200598
Manuel Laussf59c8112011-11-10 12:06:22 +0000599 platform_add_devices(db1x00_devs, ARRAY_SIZE(db1x00_devs));
Manuel Lauss851d4f52012-09-14 18:25:00 +0200600 db1x_register_norflash(flashsize << 20, 4 /* 32bit */, F_SWAPPED);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200601 return 0;
602}