aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/alchemy/devboards/db1200.c
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2011-11-10 07:06:21 -0500
committerRalf Baechle <ralf@linux-mips.org>2011-12-07 17:02:06 -0500
commit7c4b24da07d99b5473de7cc7ba3f67d85b889bc0 (patch)
treeec1369de73ee0e682c07377b933706600a6725ff /arch/mips/alchemy/devboards/db1200.c
parent8e026910fcd46c3cfcdf5cff7ebba013bb8ec85c (diff)
MIPS: Alchemy: merge devboard code into single per-board files.
Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com> To: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/2884/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/alchemy/devboards/db1200.c')
-rw-r--r--arch/mips/alchemy/devboards/db1200.c705
1 files changed, 705 insertions, 0 deletions
diff --git a/arch/mips/alchemy/devboards/db1200.c b/arch/mips/alchemy/devboards/db1200.c
new file mode 100644
index 000000000000..43f5f1be9d68
--- /dev/null
+++ b/arch/mips/alchemy/devboards/db1200.c
@@ -0,0 +1,705 @@
1/*
2 * DBAu1200 board platform device registration
3 *
4 * Copyright (C) 2008-2011 Manuel Lauss
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <linux/dma-mapping.h>
22#include <linux/gpio.h>
23#include <linux/i2c.h>
24#include <linux/init.h>
25#include <linux/interrupt.h>
26#include <linux/io.h>
27#include <linux/leds.h>
28#include <linux/mmc/host.h>
29#include <linux/mtd/mtd.h>
30#include <linux/mtd/nand.h>
31#include <linux/mtd/partitions.h>
32#include <linux/platform_device.h>
33#include <linux/serial_8250.h>
34#include <linux/spi/spi.h>
35#include <linux/spi/flash.h>
36#include <linux/smc91x.h>
37#include <asm/mach-au1x00/au1000.h>
38#include <asm/mach-au1x00/au1100_mmc.h>
39#include <asm/mach-au1x00/au1xxx_dbdma.h>
40#include <asm/mach-au1x00/au1550_spi.h>
41#include <asm/mach-db1x00/bcsr.h>
42#include <asm/mach-db1x00/db1200.h>
43
44#include "platform.h"
45
46
47const char *get_system_type(void)
48{
49 return "DB1200";
50}
51
52void __init board_setup(void)
53{
54 unsigned long freq0, clksrc, div, pfc;
55 unsigned short whoami;
56
57 bcsr_init(DB1200_BCSR_PHYS_ADDR,
58 DB1200_BCSR_PHYS_ADDR + DB1200_BCSR_HEXLED_OFS);
59
60 whoami = bcsr_read(BCSR_WHOAMI);
61 printk(KERN_INFO "Alchemy/AMD/RMI DB1200 Board, CPLD Rev %d"
62 " Board-ID %d Daughtercard ID %d\n",
63 (whoami >> 4) & 0xf, (whoami >> 8) & 0xf, whoami & 0xf);
64
65 /* SMBus/SPI on PSC0, Audio on PSC1 */
66 pfc = __raw_readl((void __iomem *)SYS_PINFUNC);
67 pfc &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B);
68 pfc &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B | SYS_PINFUNC_FS3);
69 pfc |= SYS_PINFUNC_P1C; /* SPI is configured later */
70 __raw_writel(pfc, (void __iomem *)SYS_PINFUNC);
71 wmb();
72
73 /* Clock configurations: PSC0: ~50MHz via Clkgen0, derived from
74 * CPU clock; all other clock generators off/unused.
75 */
76 div = (get_au1x00_speed() + 25000000) / 50000000;
77 if (div & 1)
78 div++;
79 div = ((div >> 1) - 1) & 0xff;
80
81 freq0 = div << SYS_FC_FRDIV0_BIT;
82 __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0);
83 wmb();
84 freq0 |= SYS_FC_FE0; /* enable F0 */
85 __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0);
86 wmb();
87
88 /* psc0_intclk comes 1:1 from F0 */
89 clksrc = SYS_CS_MUX_FQ0 << SYS_CS_ME0_BIT;
90 __raw_writel(clksrc, (void __iomem *)SYS_CLKSRC);
91 wmb();
92}
93
94/******************************************************************************/
95
96static struct mtd_partition db1200_spiflash_parts[] = {
97 {
98 .name = "DB1200 SPI flash",
99 .offset = 0,
100 .size = MTDPART_SIZ_FULL,
101 },
102};
103
104static struct flash_platform_data db1200_spiflash_data = {
105 .name = "s25fl001",
106 .parts = db1200_spiflash_parts,
107 .nr_parts = ARRAY_SIZE(db1200_spiflash_parts),
108 .type = "m25p10",
109};
110
111static struct spi_board_info db1200_spi_devs[] __initdata = {
112 {
113 /* TI TMP121AIDBVR temp sensor */
114 .modalias = "tmp121",
115 .max_speed_hz = 2000000,
116 .bus_num = 0,
117 .chip_select = 0,
118 .mode = 0,
119 },
120 {
121 /* Spansion S25FL001D0FMA SPI flash */
122 .modalias = "m25p80",
123 .max_speed_hz = 50000000,
124 .bus_num = 0,
125 .chip_select = 1,
126 .mode = 0,
127 .platform_data = &db1200_spiflash_data,
128 },
129};
130
131static struct i2c_board_info db1200_i2c_devs[] __initdata = {
132 { I2C_BOARD_INFO("24c04", 0x52), }, /* AT24C04-10 I2C eeprom */
133 { I2C_BOARD_INFO("ne1619", 0x2d), }, /* adm1025-compat hwmon */
134 { I2C_BOARD_INFO("wm8731", 0x1b), }, /* I2S audio codec WM8731 */
135};
136
137/**********************************************************************/
138
139static void au1200_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
140 unsigned int ctrl)
141{
142 struct nand_chip *this = mtd->priv;
143 unsigned long ioaddr = (unsigned long)this->IO_ADDR_W;
144
145 ioaddr &= 0xffffff00;
146
147 if (ctrl & NAND_CLE) {
148 ioaddr += MEM_STNAND_CMD;
149 } else if (ctrl & NAND_ALE) {
150 ioaddr += MEM_STNAND_ADDR;
151 } else {
152 /* assume we want to r/w real data by default */
153 ioaddr += MEM_STNAND_DATA;
154 }
155 this->IO_ADDR_R = this->IO_ADDR_W = (void __iomem *)ioaddr;
156 if (cmd != NAND_CMD_NONE) {
157 __raw_writeb(cmd, this->IO_ADDR_W);
158 wmb();
159 }
160}
161
162static int au1200_nand_device_ready(struct mtd_info *mtd)
163{
164 return __raw_readl((void __iomem *)MEM_STSTAT) & 1;
165}
166
167static const char *db1200_part_probes[] = { "cmdlinepart", NULL };
168
169static struct mtd_partition db1200_nand_parts[] = {
170 {
171 .name = "NAND FS 0",
172 .offset = 0,
173 .size = 8 * 1024 * 1024,
174 },
175 {
176 .name = "NAND FS 1",
177 .offset = MTDPART_OFS_APPEND,
178 .size = MTDPART_SIZ_FULL
179 },
180};
181
182struct platform_nand_data db1200_nand_platdata = {
183 .chip = {
184 .nr_chips = 1,
185 .chip_offset = 0,
186 .nr_partitions = ARRAY_SIZE(db1200_nand_parts),
187 .partitions = db1200_nand_parts,
188 .chip_delay = 20,
189 .part_probe_types = db1200_part_probes,
190 },
191 .ctrl = {
192 .dev_ready = au1200_nand_device_ready,
193 .cmd_ctrl = au1200_nand_cmd_ctrl,
194 },
195};
196
197static struct resource db1200_nand_res[] = {
198 [0] = {
199 .start = DB1200_NAND_PHYS_ADDR,
200 .end = DB1200_NAND_PHYS_ADDR + 0xff,
201 .flags = IORESOURCE_MEM,
202 },
203};
204
205static struct platform_device db1200_nand_dev = {
206 .name = "gen_nand",
207 .num_resources = ARRAY_SIZE(db1200_nand_res),
208 .resource = db1200_nand_res,
209 .id = -1,
210 .dev = {
211 .platform_data = &db1200_nand_platdata,
212 }
213};
214
215/**********************************************************************/
216
217static struct smc91x_platdata db1200_eth_data = {
218 .flags = SMC91X_NOWAIT | SMC91X_USE_16BIT,
219 .leda = RPC_LED_100_10,
220 .ledb = RPC_LED_TX_RX,
221};
222
223static struct resource db1200_eth_res[] = {
224 [0] = {
225 .start = DB1200_ETH_PHYS_ADDR,
226 .end = DB1200_ETH_PHYS_ADDR + 0xf,
227 .flags = IORESOURCE_MEM,
228 },
229 [1] = {
230 .start = DB1200_ETH_INT,
231 .end = DB1200_ETH_INT,
232 .flags = IORESOURCE_IRQ,
233 },
234};
235
236static struct platform_device db1200_eth_dev = {
237 .dev = {
238 .platform_data = &db1200_eth_data,
239 },
240 .name = "smc91x",
241 .id = -1,
242 .num_resources = ARRAY_SIZE(db1200_eth_res),
243 .resource = db1200_eth_res,
244};
245
246/**********************************************************************/
247
248static struct resource db1200_ide_res[] = {
249 [0] = {
250 .start = DB1200_IDE_PHYS_ADDR,
251 .end = DB1200_IDE_PHYS_ADDR + DB1200_IDE_PHYS_LEN - 1,
252 .flags = IORESOURCE_MEM,
253 },
254 [1] = {
255 .start = DB1200_IDE_INT,
256 .end = DB1200_IDE_INT,
257 .flags = IORESOURCE_IRQ,
258 },
259 [2] = {
260 .start = AU1200_DSCR_CMD0_DMA_REQ1,
261 .end = AU1200_DSCR_CMD0_DMA_REQ1,
262 .flags = IORESOURCE_DMA,
263 },
264};
265
266static u64 au1200_ide_dmamask = DMA_BIT_MASK(32);
267
268static struct platform_device db1200_ide_dev = {
269 .name = "au1200-ide",
270 .id = 0,
271 .dev = {
272 .dma_mask = &au1200_ide_dmamask,
273 .coherent_dma_mask = DMA_BIT_MASK(32),
274 },
275 .num_resources = ARRAY_SIZE(db1200_ide_res),
276 .resource = db1200_ide_res,
277};
278
279/**********************************************************************/
280
281static struct platform_device db1200_rtc_dev = {
282 .name = "rtc-au1xxx",
283 .id = -1,
284};
285
286/**********************************************************************/
287
288/* SD carddetects: they're supposed to be edge-triggered, but ack
289 * doesn't seem to work (CPLD Rev 2). Instead, the screaming one
290 * is disabled and its counterpart enabled. The 500ms timeout is
291 * because the carddetect isn't debounced in hardware.
292 */
293static irqreturn_t db1200_mmc_cd(int irq, void *ptr)
294{
295 void(*mmc_cd)(struct mmc_host *, unsigned long);
296
297 if (irq == DB1200_SD0_INSERT_INT) {
298 disable_irq_nosync(DB1200_SD0_INSERT_INT);
299 enable_irq(DB1200_SD0_EJECT_INT);
300 } else {
301 disable_irq_nosync(DB1200_SD0_EJECT_INT);
302 enable_irq(DB1200_SD0_INSERT_INT);
303 }
304
305 /* link against CONFIG_MMC=m */
306 mmc_cd = symbol_get(mmc_detect_change);
307 if (mmc_cd) {
308 mmc_cd(ptr, msecs_to_jiffies(500));
309 symbol_put(mmc_detect_change);
310 }
311
312 return IRQ_HANDLED;
313}
314
315static int db1200_mmc_cd_setup(void *mmc_host, int en)
316{
317 int ret;
318
319 if (en) {
320 ret = request_irq(DB1200_SD0_INSERT_INT, db1200_mmc_cd,
321 IRQF_DISABLED, "sd_insert", mmc_host);
322 if (ret)
323 goto out;
324
325 ret = request_irq(DB1200_SD0_EJECT_INT, db1200_mmc_cd,
326 IRQF_DISABLED, "sd_eject", mmc_host);
327 if (ret) {
328 free_irq(DB1200_SD0_INSERT_INT, mmc_host);
329 goto out;
330 }
331
332 if (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT)
333 enable_irq(DB1200_SD0_EJECT_INT);
334 else
335 enable_irq(DB1200_SD0_INSERT_INT);
336
337 } else {
338 free_irq(DB1200_SD0_INSERT_INT, mmc_host);
339 free_irq(DB1200_SD0_EJECT_INT, mmc_host);
340 }
341 ret = 0;
342out:
343 return ret;
344}
345
346static void db1200_mmc_set_power(void *mmc_host, int state)
347{
348 if (state) {
349 bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD0PWR);
350 msleep(400); /* stabilization time */
351 } else
352 bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD0PWR, 0);
353}
354
355static int db1200_mmc_card_readonly(void *mmc_host)
356{
357 return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 1 : 0;
358}
359
360static int db1200_mmc_card_inserted(void *mmc_host)
361{
362 return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT) ? 1 : 0;
363}
364
365static void db1200_mmcled_set(struct led_classdev *led,
366 enum led_brightness brightness)
367{
368 if (brightness != LED_OFF)
369 bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
370 else
371 bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
372}
373
374static struct led_classdev db1200_mmc_led = {
375 .brightness_set = db1200_mmcled_set,
376};
377
378static struct au1xmmc_platform_data db1200mmc_platdata = {
379 .cd_setup = db1200_mmc_cd_setup,
380 .set_power = db1200_mmc_set_power,
381 .card_inserted = db1200_mmc_card_inserted,
382 .card_readonly = db1200_mmc_card_readonly,
383 .led = &db1200_mmc_led,
384};
385
386static struct resource au1200_mmc0_resources[] = {
387 [0] = {
388 .start = AU1100_SD0_PHYS_ADDR,
389 .end = AU1100_SD0_PHYS_ADDR + 0xfff,
390 .flags = IORESOURCE_MEM,
391 },
392 [1] = {
393 .start = AU1200_SD_INT,
394 .end = AU1200_SD_INT,
395 .flags = IORESOURCE_IRQ,
396 },
397 [2] = {
398 .start = AU1200_DSCR_CMD0_SDMS_TX0,
399 .end = AU1200_DSCR_CMD0_SDMS_TX0,
400 .flags = IORESOURCE_DMA,
401 },
402 [3] = {
403 .start = AU1200_DSCR_CMD0_SDMS_RX0,
404 .end = AU1200_DSCR_CMD0_SDMS_RX0,
405 .flags = IORESOURCE_DMA,
406 }
407};
408
409static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32);
410
411static struct platform_device db1200_mmc0_dev = {
412 .name = "au1xxx-mmc",
413 .id = 0,
414 .dev = {
415 .dma_mask = &au1xxx_mmc_dmamask,
416 .coherent_dma_mask = DMA_BIT_MASK(32),
417 .platform_data = &db1200mmc_platdata,
418 },
419 .num_resources = ARRAY_SIZE(au1200_mmc0_resources),
420 .resource = au1200_mmc0_resources,
421};
422
423/**********************************************************************/
424
425static struct resource au1200_lcd_res[] = {
426 [0] = {
427 .start = AU1200_LCD_PHYS_ADDR,
428 .end = AU1200_LCD_PHYS_ADDR + 0x800 - 1,
429 .flags = IORESOURCE_MEM,
430 },
431 [1] = {
432 .start = AU1200_LCD_INT,
433 .end = AU1200_LCD_INT,
434 .flags = IORESOURCE_IRQ,
435 }
436};
437
438static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32);
439
440static struct platform_device au1200_lcd_dev = {
441 .name = "au1200-lcd",
442 .id = 0,
443 .dev = {
444 .dma_mask = &au1200_lcd_dmamask,
445 .coherent_dma_mask = DMA_BIT_MASK(32),
446 },
447 .num_resources = ARRAY_SIZE(au1200_lcd_res),
448 .resource = au1200_lcd_res,
449};
450
451/**********************************************************************/
452
453static struct resource au1200_psc0_res[] = {
454 [0] = {
455 .start = AU1550_PSC0_PHYS_ADDR,
456 .end = AU1550_PSC0_PHYS_ADDR + 0xfff,
457 .flags = IORESOURCE_MEM,
458 },
459 [1] = {
460 .start = AU1200_PSC0_INT,
461 .end = AU1200_PSC0_INT,
462 .flags = IORESOURCE_IRQ,
463 },
464 [2] = {
465 .start = AU1200_DSCR_CMD0_PSC0_TX,
466 .end = AU1200_DSCR_CMD0_PSC0_TX,
467 .flags = IORESOURCE_DMA,
468 },
469 [3] = {
470 .start = AU1200_DSCR_CMD0_PSC0_RX,
471 .end = AU1200_DSCR_CMD0_PSC0_RX,
472 .flags = IORESOURCE_DMA,
473 },
474};
475
476static struct platform_device db1200_i2c_dev = {
477 .name = "au1xpsc_smbus",
478 .id = 0, /* bus number */
479 .num_resources = ARRAY_SIZE(au1200_psc0_res),
480 .resource = au1200_psc0_res,
481};
482
483static void db1200_spi_cs_en(struct au1550_spi_info *spi, int cs, int pol)
484{
485 if (cs)
486 bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_SPISEL);
487 else
488 bcsr_mod(BCSR_RESETS, BCSR_RESETS_SPISEL, 0);
489}
490
491static struct au1550_spi_info db1200_spi_platdata = {
492 .mainclk_hz = 50000000, /* PSC0 clock */
493 .num_chipselect = 2,
494 .activate_cs = db1200_spi_cs_en,
495};
496
497static u64 spi_dmamask = DMA_BIT_MASK(32);
498
499static struct platform_device db1200_spi_dev = {
500 .dev = {
501 .dma_mask = &spi_dmamask,
502 .coherent_dma_mask = DMA_BIT_MASK(32),
503 .platform_data = &db1200_spi_platdata,
504 },
505 .name = "au1550-spi",
506 .id = 0, /* bus number */
507 .num_resources = ARRAY_SIZE(au1200_psc0_res),
508 .resource = au1200_psc0_res,
509};
510
511static struct resource au1200_psc1_res[] = {
512 [0] = {
513 .start = AU1550_PSC1_PHYS_ADDR,
514 .end = AU1550_PSC1_PHYS_ADDR + 0xfff,
515 .flags = IORESOURCE_MEM,
516 },
517 [1] = {
518 .start = AU1200_PSC1_INT,
519 .end = AU1200_PSC1_INT,
520 .flags = IORESOURCE_IRQ,
521 },
522 [2] = {
523 .start = AU1200_DSCR_CMD0_PSC1_TX,
524 .end = AU1200_DSCR_CMD0_PSC1_TX,
525 .flags = IORESOURCE_DMA,
526 },
527 [3] = {
528 .start = AU1200_DSCR_CMD0_PSC1_RX,
529 .end = AU1200_DSCR_CMD0_PSC1_RX,
530 .flags = IORESOURCE_DMA,
531 },
532};
533
534/* AC97 or I2S device */
535static struct platform_device db1200_audio_dev = {
536 /* name assigned later based on switch setting */
537 .id = 1, /* PSC ID */
538 .num_resources = ARRAY_SIZE(au1200_psc1_res),
539 .resource = au1200_psc1_res,
540};
541
542/* DB1200 ASoC card device */
543static struct platform_device db1200_sound_dev = {
544 /* name assigned later based on switch setting */
545 .id = 1, /* PSC ID */
546};
547
548static struct platform_device db1200_stac_dev = {
549 .name = "ac97-codec",
550 .id = 1, /* on PSC1 */
551};
552
553static struct platform_device db1200_audiodma_dev = {
554 .name = "au1xpsc-pcm",
555 .id = 1, /* PSC ID */
556};
557
558static struct platform_device *db1200_devs[] __initdata = {
559 NULL, /* PSC0, selected by S6.8 */
560 &db1200_ide_dev,
561 &db1200_mmc0_dev,
562 &au1200_lcd_dev,
563 &db1200_eth_dev,
564 &db1200_rtc_dev,
565 &db1200_nand_dev,
566 &db1200_audiodma_dev,
567 &db1200_audio_dev,
568 &db1200_stac_dev,
569 &db1200_sound_dev,
570};
571
572static int __init db1200_dev_init(void)
573{
574 unsigned long pfc;
575 unsigned short sw;
576 int swapped;
577
578 /* GPIO7 is low-level triggered CPLD cascade */
579 irq_set_irq_type(AU1200_GPIO7_INT, IRQF_TRIGGER_LOW);
580 bcsr_init_irq(DB1200_INT_BEGIN, DB1200_INT_END, AU1200_GPIO7_INT);
581
582 /* insert/eject pairs: one of both is always screaming. To avoid
583 * issues they must not be automatically enabled when initially
584 * requested.
585 */
586 irq_set_status_flags(DB1200_SD0_INSERT_INT, IRQ_NOAUTOEN);
587 irq_set_status_flags(DB1200_SD0_EJECT_INT, IRQ_NOAUTOEN);
588 irq_set_status_flags(DB1200_PC0_INSERT_INT, IRQ_NOAUTOEN);
589 irq_set_status_flags(DB1200_PC0_EJECT_INT, IRQ_NOAUTOEN);
590 irq_set_status_flags(DB1200_PC1_INSERT_INT, IRQ_NOAUTOEN);
591 irq_set_status_flags(DB1200_PC1_EJECT_INT, IRQ_NOAUTOEN);
592
593 i2c_register_board_info(0, db1200_i2c_devs,
594 ARRAY_SIZE(db1200_i2c_devs));
595 spi_register_board_info(db1200_spi_devs,
596 ARRAY_SIZE(db1200_i2c_devs));
597
598 /* SWITCHES: S6.8 I2C/SPI selector (OFF=I2C ON=SPI)
599 * S6.7 AC97/I2S selector (OFF=AC97 ON=I2S)
600 */
601
602 /* NOTE: GPIO215 controls OTG VBUS supply. In SPI mode however
603 * this pin is claimed by PSC0 (unused though, but pinmux doesn't
604 * allow to free it without crippling the SPI interface).
605 * As a result, in SPI mode, OTG simply won't work (PSC0 uses
606 * it as an input pin which is pulled high on the boards).
607 */
608 pfc = __raw_readl((void __iomem *)SYS_PINFUNC) & ~SYS_PINFUNC_P0A;
609
610 /* switch off OTG VBUS supply */
611 gpio_request(215, "otg-vbus");
612 gpio_direction_output(215, 1);
613
614 printk(KERN_INFO "DB1200 device configuration:\n");
615
616 sw = bcsr_read(BCSR_SWITCHES);
617 if (sw & BCSR_SWITCHES_DIP_8) {
618 db1200_devs[0] = &db1200_i2c_dev;
619 bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC0MUX, 0);
620
621 pfc |= (2 << 17); /* GPIO2 block owns GPIO215 */
622
623 printk(KERN_INFO " S6.8 OFF: PSC0 mode I2C\n");
624 printk(KERN_INFO " OTG port VBUS supply available!\n");
625 } else {
626 db1200_devs[0] = &db1200_spi_dev;
627 bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_PSC0MUX);
628
629 pfc |= (1 << 17); /* PSC0 owns GPIO215 */
630
631 printk(KERN_INFO " S6.8 ON : PSC0 mode SPI\n");
632 printk(KERN_INFO " OTG port VBUS supply disabled\n");
633 }
634 __raw_writel(pfc, (void __iomem *)SYS_PINFUNC);
635 wmb();
636
637 /* Audio: DIP7 selects I2S(0)/AC97(1), but need I2C for I2S!
638 * so: DIP7=1 || DIP8=0 => AC97, DIP7=0 && DIP8=1 => I2S
639 */
640 sw &= BCSR_SWITCHES_DIP_8 | BCSR_SWITCHES_DIP_7;
641 if (sw == BCSR_SWITCHES_DIP_8) {
642 bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_PSC1MUX);
643 db1200_audio_dev.name = "au1xpsc_i2s";
644 db1200_sound_dev.name = "db1200-i2s";
645 printk(KERN_INFO " S6.7 ON : PSC1 mode I2S\n");
646 } else {
647 bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC1MUX, 0);
648 db1200_audio_dev.name = "au1xpsc_ac97";
649 db1200_sound_dev.name = "db1200-ac97";
650 printk(KERN_INFO " S6.7 OFF: PSC1 mode AC97\n");
651 }
652
653 /* Audio PSC clock is supplied externally. (FIXME: platdata!!) */
654 __raw_writel(PSC_SEL_CLK_SERCLK,
655 (void __iomem *)KSEG1ADDR(AU1550_PSC1_PHYS_ADDR) + PSC_SEL_OFFSET);
656 wmb();
657
658 db1x_register_pcmcia_socket(
659 AU1000_PCMCIA_ATTR_PHYS_ADDR,
660 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
661 AU1000_PCMCIA_MEM_PHYS_ADDR,
662 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
663 AU1000_PCMCIA_IO_PHYS_ADDR,
664 AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
665 DB1200_PC0_INT, DB1200_PC0_INSERT_INT,
666 /*DB1200_PC0_STSCHG_INT*/0, DB1200_PC0_EJECT_INT, 0);
667
668 db1x_register_pcmcia_socket(
669 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000,
670 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1,
671 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000,
672 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1,
673 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000,
674 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1,
675 DB1200_PC1_INT, DB1200_PC1_INSERT_INT,
676 /*DB1200_PC1_STSCHG_INT*/0, DB1200_PC1_EJECT_INT, 1);
677
678 swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1200_SWAPBOOT;
679 db1x_register_norflash(64 << 20, 2, swapped);
680
681 return platform_add_devices(db1200_devs, ARRAY_SIZE(db1200_devs));
682}
683device_initcall(db1200_dev_init);
684
685/* au1200fb calls these: STERBT EINEN TRAGISCHEN TOD!!! */
686int board_au1200fb_panel(void)
687{
688 return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f;
689}
690
691int board_au1200fb_panel_init(void)
692{
693 /* Apply power */
694 bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
695 BCSR_BOARD_LCDBL);
696 return 0;
697}
698
699int board_au1200fb_panel_shutdown(void)
700{
701 /* Remove power */
702 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
703 BCSR_BOARD_LCDBL, 0);
704 return 0;
705}