blob: 433c4b9a9f0a92af20e31f1f16f9be5cde955b12 [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 Lauss6b1889c2014-07-23 16:36:54 +020022#include <linux/clk.h>
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000023#include <linux/dma-mapping.h>
24#include <linux/gpio.h>
Manuel Lauss27dd65a2009-10-04 14:55:28 +020025#include <linux/init.h>
Manuel Laussb2ce3052011-07-25 13:44:46 +020026#include <linux/interrupt.h>
Manuel Laussc9af5142011-11-10 12:06:22 +000027#include <linux/leds.h>
28#include <linux/mmc/host.h>
29#include <linux/module.h>
Manuel Lauss27dd65a2009-10-04 14:55:28 +020030#include <linux/platform_device.h>
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000031#include <linux/pm.h>
Manuel Lauss2a32daf2011-12-08 10:42:15 +000032#include <linux/spi/spi.h>
33#include <linux/spi/spi_gpio.h>
34#include <linux/spi/ads7846.h>
Manuel Laussb2ce3052011-07-25 13:44:46 +020035#include <asm/mach-au1x00/au1000.h>
Alban Bedel832f5da2015-08-02 18:30:11 +020036#include <asm/mach-au1x00/gpio-au1000.h>
Manuel Laussb2ce3052011-07-25 13:44:46 +020037#include <asm/mach-au1x00/au1000_dma.h>
Manuel Laussc9af5142011-11-10 12:06:22 +000038#include <asm/mach-au1x00/au1100_mmc.h>
Manuel Lauss206aa6c2009-10-19 12:53:37 +020039#include <asm/mach-db1x00/bcsr.h>
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000040#include <asm/reboot.h>
41#include <prom.h>
42#include "platform.h"
Manuel Lauss27dd65a2009-10-04 14:55:28 +020043
Manuel Laussf59c8112011-11-10 12:06:22 +000044#define F_SWAPPED (bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT)
45
Manuel Lauss970e2682014-02-20 14:59:24 +010046const char *get_system_type(void);
Manuel Lauss7517de32011-08-12 11:39:44 +020047
Manuel Lauss970e2682014-02-20 14:59:24 +010048int __init db1000_board_setup(void)
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000049{
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000050 /* initialize board register space */
51 bcsr_init(DB1000_BCSR_PHYS_ADDR,
52 DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS);
53
Manuel Lauss970e2682014-02-20 14:59:24 +010054 switch (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) {
55 case BCSR_WHOAMI_DB1000:
56 case BCSR_WHOAMI_DB1500:
57 case BCSR_WHOAMI_DB1100:
58 case BCSR_WHOAMI_PB1500:
59 case BCSR_WHOAMI_PB1500R2:
60 case BCSR_WHOAMI_PB1100:
61 pr_info("AMD Alchemy %s Board\n", get_system_type());
62 return 0;
63 }
64 return -ENODEV;
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000065}
66
Manuel Laussf869d422011-11-10 12:06:16 +000067static int db1500_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
Manuel Lauss7517de32011-08-12 11:39:44 +020068{
69 if ((slot < 12) || (slot > 13) || pin == 0)
70 return -1;
71 if (slot == 12)
72 return (pin == 1) ? AU1500_PCI_INTA : 0xff;
73 if (slot == 13) {
74 switch (pin) {
75 case 1: return AU1500_PCI_INTA;
76 case 2: return AU1500_PCI_INTB;
77 case 3: return AU1500_PCI_INTC;
78 case 4: return AU1500_PCI_INTD;
79 }
80 }
81 return -1;
82}
Manuel Lauss7517de32011-08-12 11:39:44 +020083
Manuel Lauss7517de32011-08-12 11:39:44 +020084static struct resource alchemy_pci_host_res[] = {
85 [0] = {
86 .start = AU1500_PCI_PHYS_ADDR,
87 .end = AU1500_PCI_PHYS_ADDR + 0xfff,
88 .flags = IORESOURCE_MEM,
89 },
90};
91
Manuel Laussf869d422011-11-10 12:06:16 +000092static struct alchemy_pci_platdata db1500_pci_pd = {
93 .board_map_irq = db1500_map_pci_irq,
Manuel Lauss7517de32011-08-12 11:39:44 +020094};
95
Manuel Laussf869d422011-11-10 12:06:16 +000096static struct platform_device db1500_pci_host_dev = {
97 .dev.platform_data = &db1500_pci_pd,
Manuel Lauss7517de32011-08-12 11:39:44 +020098 .name = "alchemy-pci",
99 .id = 0,
100 .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
101 .resource = alchemy_pci_host_res,
102};
103
Manuel Lauss970e2682014-02-20 14:59:24 +0100104int __init db1500_pci_setup(void)
Manuel Lauss7517de32011-08-12 11:39:44 +0200105{
Manuel Lauss970e2682014-02-20 14:59:24 +0100106 return platform_device_register(&db1500_pci_host_dev);
Manuel Lauss7517de32011-08-12 11:39:44 +0200107}
Manuel Laussf59c8112011-11-10 12:06:22 +0000108
Manuel Lauss3766386032011-08-12 11:39:45 +0200109static 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
122static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32);
123
124static 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};
Manuel Lauss3766386032011-08-12 11:39:45 +0200134
Manuel Laussb2ce3052011-07-25 13:44:46 +0200135static struct resource alchemy_ac97c_res[] = {
136 [0] = {
137 .start = AU1000_AC97_PHYS_ADDR,
138 .end = AU1000_AC97_PHYS_ADDR + 0xfff,
139 .flags = IORESOURCE_MEM,
140 },
141 [1] = {
142 .start = DMA_ID_AC97C_TX,
143 .end = DMA_ID_AC97C_TX,
144 .flags = IORESOURCE_DMA,
145 },
146 [2] = {
147 .start = DMA_ID_AC97C_RX,
148 .end = DMA_ID_AC97C_RX,
149 .flags = IORESOURCE_DMA,
150 },
151};
152
153static struct platform_device alchemy_ac97c_dev = {
154 .name = "alchemy-ac97c",
155 .id = -1,
156 .resource = alchemy_ac97c_res,
157 .num_resources = ARRAY_SIZE(alchemy_ac97c_res),
158};
159
160static struct platform_device alchemy_ac97c_dma_dev = {
161 .name = "alchemy-pcm-dma",
162 .id = 0,
163};
164
165static struct platform_device db1x00_codec_dev = {
166 .name = "ac97-codec",
167 .id = -1,
168};
169
170static struct platform_device db1x00_audio_dev = {
171 .name = "db1000-audio",
172};
173
Manuel Laussc9af5142011-11-10 12:06:22 +0000174/******************************************************************************/
175
176static irqreturn_t db1100_mmc_cd(int irq, void *ptr)
177{
178 void (*mmc_cd)(struct mmc_host *, unsigned long);
179 /* link against CONFIG_MMC=m */
180 mmc_cd = symbol_get(mmc_detect_change);
181 mmc_cd(ptr, msecs_to_jiffies(500));
182 symbol_put(mmc_detect_change);
183
184 return IRQ_HANDLED;
185}
186
187static int db1100_mmc_cd_setup(void *mmc_host, int en)
188{
Manuel Lauss851d4f52012-09-14 18:25:00 +0200189 int ret = 0, irq;
190
191 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1100)
192 irq = AU1100_GPIO19_INT;
193 else
194 irq = AU1100_GPIO14_INT; /* PB1100 SD0 CD# */
Manuel Laussc9af5142011-11-10 12:06:22 +0000195
196 if (en) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200197 irq_set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
198 ret = request_irq(irq, db1100_mmc_cd, 0,
Manuel Laussc9af5142011-11-10 12:06:22 +0000199 "sd0_cd", mmc_host);
200 } else
Manuel Lauss851d4f52012-09-14 18:25:00 +0200201 free_irq(irq, mmc_host);
Manuel Laussc9af5142011-11-10 12:06:22 +0000202 return ret;
203}
204
205static int db1100_mmc1_cd_setup(void *mmc_host, int en)
206{
Manuel Lauss851d4f52012-09-14 18:25:00 +0200207 int ret = 0, irq;
208
209 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1100)
210 irq = AU1100_GPIO20_INT;
211 else
212 irq = AU1100_GPIO15_INT; /* PB1100 SD1 CD# */
Manuel Laussc9af5142011-11-10 12:06:22 +0000213
214 if (en) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200215 irq_set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
216 ret = request_irq(irq, db1100_mmc_cd, 0,
Manuel Laussc9af5142011-11-10 12:06:22 +0000217 "sd1_cd", mmc_host);
218 } else
Manuel Lauss851d4f52012-09-14 18:25:00 +0200219 free_irq(irq, mmc_host);
Manuel Laussc9af5142011-11-10 12:06:22 +0000220 return ret;
221}
222
223static int db1100_mmc_card_readonly(void *mmc_host)
224{
225 /* testing suggests that this bit is inverted */
226 return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 0 : 1;
227}
228
229static int db1100_mmc_card_inserted(void *mmc_host)
230{
231 return !alchemy_gpio_get_value(19);
232}
233
234static void db1100_mmc_set_power(void *mmc_host, int state)
235{
Manuel Lauss851d4f52012-09-14 18:25:00 +0200236 int bit;
237
238 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1100)
239 bit = BCSR_BOARD_SD0PWR;
240 else
241 bit = BCSR_BOARD_PB1100_SD0PWR;
242
Manuel Laussc9af5142011-11-10 12:06:22 +0000243 if (state) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200244 bcsr_mod(BCSR_BOARD, 0, bit);
Manuel Laussc9af5142011-11-10 12:06:22 +0000245 msleep(400); /* stabilization time */
246 } else
Manuel Lauss851d4f52012-09-14 18:25:00 +0200247 bcsr_mod(BCSR_BOARD, bit, 0);
Manuel Laussc9af5142011-11-10 12:06:22 +0000248}
249
250static void db1100_mmcled_set(struct led_classdev *led, enum led_brightness b)
251{
252 if (b != LED_OFF)
253 bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
254 else
255 bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
256}
257
258static struct led_classdev db1100_mmc_led = {
Ralf Baechle70342282013-01-22 12:59:30 +0100259 .brightness_set = db1100_mmcled_set,
Manuel Laussc9af5142011-11-10 12:06:22 +0000260};
261
262static int db1100_mmc1_card_readonly(void *mmc_host)
263{
264 return (bcsr_read(BCSR_BOARD) & BCSR_BOARD_SD1WP) ? 1 : 0;
265}
266
267static int db1100_mmc1_card_inserted(void *mmc_host)
268{
269 return !alchemy_gpio_get_value(20);
270}
271
272static void db1100_mmc1_set_power(void *mmc_host, int state)
273{
Manuel Lauss851d4f52012-09-14 18:25:00 +0200274 int bit;
275
276 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1100)
277 bit = BCSR_BOARD_SD1PWR;
278 else
279 bit = BCSR_BOARD_PB1100_SD1PWR;
280
Manuel Laussc9af5142011-11-10 12:06:22 +0000281 if (state) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200282 bcsr_mod(BCSR_BOARD, 0, bit);
Manuel Laussc9af5142011-11-10 12:06:22 +0000283 msleep(400); /* stabilization time */
284 } else
Manuel Lauss851d4f52012-09-14 18:25:00 +0200285 bcsr_mod(BCSR_BOARD, bit, 0);
Manuel Laussc9af5142011-11-10 12:06:22 +0000286}
287
288static void db1100_mmc1led_set(struct led_classdev *led, enum led_brightness b)
289{
290 if (b != LED_OFF)
291 bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED1, 0);
292 else
293 bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED1);
294}
295
296static struct led_classdev db1100_mmc1_led = {
Ralf Baechle70342282013-01-22 12:59:30 +0100297 .brightness_set = db1100_mmc1led_set,
Manuel Laussc9af5142011-11-10 12:06:22 +0000298};
299
300static struct au1xmmc_platform_data db1100_mmc_platdata[2] = {
301 [0] = {
302 .cd_setup = db1100_mmc_cd_setup,
303 .set_power = db1100_mmc_set_power,
304 .card_inserted = db1100_mmc_card_inserted,
305 .card_readonly = db1100_mmc_card_readonly,
306 .led = &db1100_mmc_led,
307 },
308 [1] = {
309 .cd_setup = db1100_mmc1_cd_setup,
310 .set_power = db1100_mmc1_set_power,
311 .card_inserted = db1100_mmc1_card_inserted,
312 .card_readonly = db1100_mmc1_card_readonly,
313 .led = &db1100_mmc1_led,
314 },
315};
316
317static struct resource au1100_mmc0_resources[] = {
318 [0] = {
319 .start = AU1100_SD0_PHYS_ADDR,
320 .end = AU1100_SD0_PHYS_ADDR + 0xfff,
321 .flags = IORESOURCE_MEM,
322 },
323 [1] = {
324 .start = AU1100_SD_INT,
325 .end = AU1100_SD_INT,
326 .flags = IORESOURCE_IRQ,
327 },
328 [2] = {
329 .start = DMA_ID_SD0_TX,
330 .end = DMA_ID_SD0_TX,
331 .flags = IORESOURCE_DMA,
332 },
333 [3] = {
334 .start = DMA_ID_SD0_RX,
335 .end = DMA_ID_SD0_RX,
336 .flags = IORESOURCE_DMA,
337 }
338};
339
Ralf Baechle70342282013-01-22 12:59:30 +0100340static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32);
Manuel Laussc9af5142011-11-10 12:06:22 +0000341
342static struct platform_device db1100_mmc0_dev = {
343 .name = "au1xxx-mmc",
344 .id = 0,
345 .dev = {
346 .dma_mask = &au1xxx_mmc_dmamask,
347 .coherent_dma_mask = DMA_BIT_MASK(32),
348 .platform_data = &db1100_mmc_platdata[0],
349 },
350 .num_resources = ARRAY_SIZE(au1100_mmc0_resources),
351 .resource = au1100_mmc0_resources,
352};
353
354static struct resource au1100_mmc1_res[] = {
355 [0] = {
356 .start = AU1100_SD1_PHYS_ADDR,
357 .end = AU1100_SD1_PHYS_ADDR + 0xfff,
358 .flags = IORESOURCE_MEM,
359 },
360 [1] = {
361 .start = AU1100_SD_INT,
362 .end = AU1100_SD_INT,
363 .flags = IORESOURCE_IRQ,
364 },
365 [2] = {
366 .start = DMA_ID_SD1_TX,
367 .end = DMA_ID_SD1_TX,
368 .flags = IORESOURCE_DMA,
369 },
370 [3] = {
371 .start = DMA_ID_SD1_RX,
372 .end = DMA_ID_SD1_RX,
373 .flags = IORESOURCE_DMA,
374 }
375};
376
377static struct platform_device db1100_mmc1_dev = {
378 .name = "au1xxx-mmc",
379 .id = 1,
380 .dev = {
381 .dma_mask = &au1xxx_mmc_dmamask,
382 .coherent_dma_mask = DMA_BIT_MASK(32),
383 .platform_data = &db1100_mmc_platdata[1],
384 },
385 .num_resources = ARRAY_SIZE(au1100_mmc1_res),
386 .resource = au1100_mmc1_res,
387};
388
Manuel Lausse734ae12011-12-08 10:42:15 +0000389/******************************************************************************/
390
391static void db1000_irda_set_phy_mode(int mode)
392{
393 unsigned short mask = BCSR_RESETS_IRDA_MODE_MASK | BCSR_RESETS_FIR_SEL;
394
395 switch (mode) {
396 case AU1000_IRDA_PHY_MODE_OFF:
397 bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_OFF);
398 break;
399 case AU1000_IRDA_PHY_MODE_SIR:
400 bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_FULL);
401 break;
402 case AU1000_IRDA_PHY_MODE_FIR:
403 bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_FULL |
404 BCSR_RESETS_FIR_SEL);
405 break;
406 }
407}
408
409static struct au1k_irda_platform_data db1000_irda_platdata = {
410 .set_phy_mode = db1000_irda_set_phy_mode,
411};
412
413static struct resource au1000_irda_res[] = {
414 [0] = {
415 .start = AU1000_IRDA_PHYS_ADDR,
416 .end = AU1000_IRDA_PHYS_ADDR + 0x0fff,
417 .flags = IORESOURCE_MEM,
418 },
419 [1] = {
420 .start = AU1000_IRDA_TX_INT,
421 .end = AU1000_IRDA_TX_INT,
422 .flags = IORESOURCE_IRQ,
423 },
424 [2] = {
425 .start = AU1000_IRDA_RX_INT,
426 .end = AU1000_IRDA_RX_INT,
427 .flags = IORESOURCE_IRQ,
428 },
429};
430
431static struct platform_device db1000_irda_dev = {
432 .name = "au1000-irda",
433 .id = -1,
434 .dev = {
435 .platform_data = &db1000_irda_platdata,
436 },
437 .resource = au1000_irda_res,
438 .num_resources = ARRAY_SIZE(au1000_irda_res),
439};
Manuel Laussc9af5142011-11-10 12:06:22 +0000440
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000441/******************************************************************************/
442
443static struct ads7846_platform_data db1100_touch_pd = {
444 .model = 7846,
445 .vref_mv = 3300,
446 .gpio_pendown = 21,
447};
448
449static struct spi_gpio_platform_data db1100_spictl_pd = {
450 .sck = 209,
451 .mosi = 208,
452 .miso = 207,
453 .num_chipselect = 1,
454};
455
456static struct spi_board_info db1100_spi_info[] __initdata = {
457 [0] = {
458 .modalias = "ads7846",
459 .max_speed_hz = 3250000,
460 .bus_num = 0,
461 .chip_select = 0,
462 .mode = 0,
463 .irq = AU1100_GPIO21_INT,
464 .platform_data = &db1100_touch_pd,
Ralf Baechle70342282013-01-22 12:59:30 +0100465 .controller_data = (void *)210, /* for spi_gpio: CS# GPIO210 */
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000466 },
467};
468
469static struct platform_device db1100_spi_dev = {
470 .name = "spi_gpio",
471 .id = 0,
472 .dev = {
473 .platform_data = &db1100_spictl_pd,
474 },
475};
476
477
Manuel Laussf59c8112011-11-10 12:06:22 +0000478static struct platform_device *db1x00_devs[] = {
479 &db1x00_codec_dev,
480 &alchemy_ac97c_dma_dev,
481 &alchemy_ac97c_dev,
482 &db1x00_audio_dev,
483};
484
Manuel Lausse734ae12011-12-08 10:42:15 +0000485static struct platform_device *db1000_devs[] = {
486 &db1000_irda_dev,
487};
488
Manuel Laussf59c8112011-11-10 12:06:22 +0000489static struct platform_device *db1100_devs[] = {
490 &au1100_lcd_device,
Manuel Laussc9af5142011-11-10 12:06:22 +0000491 &db1100_mmc0_dev,
492 &db1100_mmc1_dev,
Manuel Lausse734ae12011-12-08 10:42:15 +0000493 &db1000_irda_dev,
Manuel Laussf59c8112011-11-10 12:06:22 +0000494};
495
Manuel Lauss970e2682014-02-20 14:59:24 +0100496int __init db1000_dev_setup(void)
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200497{
Manuel Laussf59c8112011-11-10 12:06:22 +0000498 int board = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI));
Manuel Lauss851d4f52012-09-14 18:25:00 +0200499 int c0, c1, d0, d1, s0, s1, flashsize = 32, twosocks = 1;
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000500 unsigned long pfc;
Manuel Lauss6b1889c2014-07-23 16:36:54 +0200501 struct clk *c, *p;
Manuel Laussf59c8112011-11-10 12:06:22 +0000502
503 if (board == BCSR_WHOAMI_DB1500) {
504 c0 = AU1500_GPIO2_INT;
505 c1 = AU1500_GPIO5_INT;
Manuel Lausse34b6fc2016-03-02 10:34:43 +0100506 d0 = 0; /* GPIO number, NOT irq! */
507 d1 = 3; /* GPIO number, NOT irq! */
Manuel Laussf59c8112011-11-10 12:06:22 +0000508 s0 = AU1500_GPIO1_INT;
509 s1 = AU1500_GPIO4_INT;
510 } else if (board == BCSR_WHOAMI_DB1100) {
511 c0 = AU1100_GPIO2_INT;
512 c1 = AU1100_GPIO5_INT;
Manuel Lausse34b6fc2016-03-02 10:34:43 +0100513 d0 = 0; /* GPIO number, NOT irq! */
514 d1 = 3; /* GPIO number, NOT irq! */
Manuel Laussf59c8112011-11-10 12:06:22 +0000515 s0 = AU1100_GPIO1_INT;
516 s1 = AU1100_GPIO4_INT;
Manuel Laussc9af5142011-11-10 12:06:22 +0000517
Manuel Lauss4294ad12014-01-29 19:11:46 +0100518 gpio_request(19, "sd0_cd");
519 gpio_request(20, "sd1_cd");
Manuel Laussc9af5142011-11-10 12:06:22 +0000520 gpio_direction_input(19); /* sd0 cd# */
521 gpio_direction_input(20); /* sd1 cd# */
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000522
523 /* spi_gpio on SSI0 pins */
Manuel Lauss1d09de72014-07-23 16:36:24 +0200524 pfc = alchemy_rdsys(AU1000_SYS_PINFUNC);
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000525 pfc |= (1 << 0); /* SSI0 pins as GPIOs */
Manuel Lauss1d09de72014-07-23 16:36:24 +0200526 alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
Manuel Lauss2a32daf2011-12-08 10:42:15 +0000527
528 spi_register_board_info(db1100_spi_info,
529 ARRAY_SIZE(db1100_spi_info));
Manuel Laussc9af5142011-11-10 12:06:22 +0000530
Manuel Lauss6b1889c2014-07-23 16:36:54 +0200531 /* link LCD clock to AUXPLL */
532 p = clk_get(NULL, "auxpll_clk");
533 c = clk_get(NULL, "lcd_intclk");
534 if (!IS_ERR(c) && !IS_ERR(p)) {
535 clk_set_parent(c, p);
536 clk_set_rate(c, clk_get_rate(p));
537 }
538 if (!IS_ERR(c))
539 clk_put(c);
540 if (!IS_ERR(p))
541 clk_put(p);
542
Manuel Laussf59c8112011-11-10 12:06:22 +0000543 platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs));
Manuel Lauss851d4f52012-09-14 18:25:00 +0200544 platform_device_register(&db1100_spi_dev);
Manuel Laussf59c8112011-11-10 12:06:22 +0000545 } else if (board == BCSR_WHOAMI_DB1000) {
546 c0 = AU1000_GPIO2_INT;
547 c1 = AU1000_GPIO5_INT;
Manuel Lausse34b6fc2016-03-02 10:34:43 +0100548 d0 = 0; /* GPIO number, NOT irq! */
549 d1 = 3; /* GPIO number, NOT irq! */
Manuel Laussf59c8112011-11-10 12:06:22 +0000550 s0 = AU1000_GPIO1_INT;
551 s1 = AU1000_GPIO4_INT;
Manuel Lausse734ae12011-12-08 10:42:15 +0000552 platform_add_devices(db1000_devs, ARRAY_SIZE(db1000_devs));
Manuel Lauss851d4f52012-09-14 18:25:00 +0200553 } else if ((board == BCSR_WHOAMI_PB1500) ||
554 (board == BCSR_WHOAMI_PB1500R2)) {
555 c0 = AU1500_GPIO203_INT;
Manuel Lausse34b6fc2016-03-02 10:34:43 +0100556 d0 = 1; /* GPIO number, NOT irq! */
Manuel Lauss851d4f52012-09-14 18:25:00 +0200557 s0 = AU1500_GPIO202_INT;
558 twosocks = 0;
559 flashsize = 64;
560 /* RTC and daughtercard irqs */
561 irq_set_irq_type(AU1500_GPIO204_INT, IRQ_TYPE_LEVEL_LOW);
562 irq_set_irq_type(AU1500_GPIO205_INT, IRQ_TYPE_LEVEL_LOW);
563 /* EPSON S1D13806 0x1b000000
Ralf Baechle70342282013-01-22 12:59:30 +0100564 * SRAM 1MB/2MB 0x1a000000
Manuel Lauss851d4f52012-09-14 18:25:00 +0200565 * DS1693 RTC 0x0c000000
566 */
567 } else if (board == BCSR_WHOAMI_PB1100) {
568 c0 = AU1100_GPIO11_INT;
Manuel Lausse34b6fc2016-03-02 10:34:43 +0100569 d0 = 9; /* GPIO number, NOT irq! */
Manuel Lauss851d4f52012-09-14 18:25:00 +0200570 s0 = AU1100_GPIO10_INT;
571 twosocks = 0;
572 flashsize = 64;
573 /* pendown, rtc, daughtercard irqs */
574 irq_set_irq_type(AU1100_GPIO8_INT, IRQ_TYPE_LEVEL_LOW);
575 irq_set_irq_type(AU1100_GPIO12_INT, IRQ_TYPE_LEVEL_LOW);
576 irq_set_irq_type(AU1100_GPIO13_INT, IRQ_TYPE_LEVEL_LOW);
577 /* EPSON S1D13806 0x1b000000
Ralf Baechle70342282013-01-22 12:59:30 +0100578 * SRAM 1MB/2MB 0x1a000000
Manuel Lauss851d4f52012-09-14 18:25:00 +0200579 * DiskOnChip 0x0d000000
580 * DS1693 RTC 0x0c000000
581 */
582 platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs));
Manuel Laussf59c8112011-11-10 12:06:22 +0000583 } else
584 return 0; /* unknown board, no further dev setup to do */
585
Manuel Laussf59c8112011-11-10 12:06:22 +0000586 irq_set_irq_type(c0, IRQ_TYPE_LEVEL_LOW);
Manuel Laussf59c8112011-11-10 12:06:22 +0000587 irq_set_irq_type(s0, IRQ_TYPE_LEVEL_LOW);
Manuel Lauss7c4b24d2011-11-10 12:06:21 +0000588
Manuel Lauss7cc2e272011-08-12 11:39:40 +0200589 db1x_register_pcmcia_socket(
590 AU1000_PCMCIA_ATTR_PHYS_ADDR,
591 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
592 AU1000_PCMCIA_MEM_PHYS_ADDR,
593 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
594 AU1000_PCMCIA_IO_PHYS_ADDR,
595 AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
Ralf Baechle70342282013-01-22 12:59:30 +0100596 c0, d0, /*s0*/0, 0, 0);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200597
Manuel Lauss851d4f52012-09-14 18:25:00 +0200598 if (twosocks) {
Manuel Lauss851d4f52012-09-14 18:25:00 +0200599 irq_set_irq_type(c1, IRQ_TYPE_LEVEL_LOW);
600 irq_set_irq_type(s1, IRQ_TYPE_LEVEL_LOW);
601
602 db1x_register_pcmcia_socket(
603 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000,
604 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1,
605 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000,
606 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1,
607 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000,
608 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1,
Ralf Baechle70342282013-01-22 12:59:30 +0100609 c1, d1, /*s1*/0, 0, 1);
Manuel Lauss851d4f52012-09-14 18:25:00 +0200610 }
Manuel Laussb2ce3052011-07-25 13:44:46 +0200611
Manuel Laussf59c8112011-11-10 12:06:22 +0000612 platform_add_devices(db1x00_devs, ARRAY_SIZE(db1x00_devs));
Manuel Lauss851d4f52012-09-14 18:25:00 +0200613 db1x_register_norflash(flashsize << 20, 4 /* 32bit */, F_SWAPPED);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200614 return 0;
615}