18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * DBAu1200/PBAu1200 board platform device registration
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2008-2011 Manuel Lauss
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/clk.h>
98c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h>
108c2ecf20Sopenharmony_ci#include <linux/gpio.h>
118c2ecf20Sopenharmony_ci#include <linux/i2c.h>
128c2ecf20Sopenharmony_ci#include <linux/init.h>
138c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
148c2ecf20Sopenharmony_ci#include <linux/io.h>
158c2ecf20Sopenharmony_ci#include <linux/leds.h>
168c2ecf20Sopenharmony_ci#include <linux/mmc/host.h>
178c2ecf20Sopenharmony_ci#include <linux/mtd/mtd.h>
188c2ecf20Sopenharmony_ci#include <linux/mtd/platnand.h>
198c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
208c2ecf20Sopenharmony_ci#include <linux/serial_8250.h>
218c2ecf20Sopenharmony_ci#include <linux/spi/spi.h>
228c2ecf20Sopenharmony_ci#include <linux/spi/flash.h>
238c2ecf20Sopenharmony_ci#include <linux/smc91x.h>
248c2ecf20Sopenharmony_ci#include <linux/ata_platform.h>
258c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/au1000.h>
268c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/au1100_mmc.h>
278c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/au1xxx_dbdma.h>
288c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/au1xxx_psc.h>
298c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/au1200fb.h>
308c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/au1550_spi.h>
318c2ecf20Sopenharmony_ci#include <asm/mach-db1x00/bcsr.h>
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#include "platform.h"
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define BCSR_INT_IDE		0x0001
368c2ecf20Sopenharmony_ci#define BCSR_INT_ETH		0x0002
378c2ecf20Sopenharmony_ci#define BCSR_INT_PC0		0x0004
388c2ecf20Sopenharmony_ci#define BCSR_INT_PC0STSCHG	0x0008
398c2ecf20Sopenharmony_ci#define BCSR_INT_PC1		0x0010
408c2ecf20Sopenharmony_ci#define BCSR_INT_PC1STSCHG	0x0020
418c2ecf20Sopenharmony_ci#define BCSR_INT_DC		0x0040
428c2ecf20Sopenharmony_ci#define BCSR_INT_FLASHBUSY	0x0080
438c2ecf20Sopenharmony_ci#define BCSR_INT_PC0INSERT	0x0100
448c2ecf20Sopenharmony_ci#define BCSR_INT_PC0EJECT	0x0200
458c2ecf20Sopenharmony_ci#define BCSR_INT_PC1INSERT	0x0400
468c2ecf20Sopenharmony_ci#define BCSR_INT_PC1EJECT	0x0800
478c2ecf20Sopenharmony_ci#define BCSR_INT_SD0INSERT	0x1000
488c2ecf20Sopenharmony_ci#define BCSR_INT_SD0EJECT	0x2000
498c2ecf20Sopenharmony_ci#define BCSR_INT_SD1INSERT	0x4000
508c2ecf20Sopenharmony_ci#define BCSR_INT_SD1EJECT	0x8000
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define DB1200_IDE_PHYS_ADDR	0x18800000
538c2ecf20Sopenharmony_ci#define DB1200_IDE_REG_SHIFT	5
548c2ecf20Sopenharmony_ci#define DB1200_IDE_PHYS_LEN	(16 << DB1200_IDE_REG_SHIFT)
558c2ecf20Sopenharmony_ci#define DB1200_ETH_PHYS_ADDR	0x19000300
568c2ecf20Sopenharmony_ci#define DB1200_NAND_PHYS_ADDR	0x20000000
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#define PB1200_IDE_PHYS_ADDR	0x0C800000
598c2ecf20Sopenharmony_ci#define PB1200_ETH_PHYS_ADDR	0x0D000300
608c2ecf20Sopenharmony_ci#define PB1200_NAND_PHYS_ADDR	0x1C000000
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define DB1200_INT_BEGIN	(AU1000_MAX_INTR + 1)
638c2ecf20Sopenharmony_ci#define DB1200_IDE_INT		(DB1200_INT_BEGIN + 0)
648c2ecf20Sopenharmony_ci#define DB1200_ETH_INT		(DB1200_INT_BEGIN + 1)
658c2ecf20Sopenharmony_ci#define DB1200_PC0_INT		(DB1200_INT_BEGIN + 2)
668c2ecf20Sopenharmony_ci#define DB1200_PC0_STSCHG_INT	(DB1200_INT_BEGIN + 3)
678c2ecf20Sopenharmony_ci#define DB1200_PC1_INT		(DB1200_INT_BEGIN + 4)
688c2ecf20Sopenharmony_ci#define DB1200_PC1_STSCHG_INT	(DB1200_INT_BEGIN + 5)
698c2ecf20Sopenharmony_ci#define DB1200_DC_INT		(DB1200_INT_BEGIN + 6)
708c2ecf20Sopenharmony_ci#define DB1200_FLASHBUSY_INT	(DB1200_INT_BEGIN + 7)
718c2ecf20Sopenharmony_ci#define DB1200_PC0_INSERT_INT	(DB1200_INT_BEGIN + 8)
728c2ecf20Sopenharmony_ci#define DB1200_PC0_EJECT_INT	(DB1200_INT_BEGIN + 9)
738c2ecf20Sopenharmony_ci#define DB1200_PC1_INSERT_INT	(DB1200_INT_BEGIN + 10)
748c2ecf20Sopenharmony_ci#define DB1200_PC1_EJECT_INT	(DB1200_INT_BEGIN + 11)
758c2ecf20Sopenharmony_ci#define DB1200_SD0_INSERT_INT	(DB1200_INT_BEGIN + 12)
768c2ecf20Sopenharmony_ci#define DB1200_SD0_EJECT_INT	(DB1200_INT_BEGIN + 13)
778c2ecf20Sopenharmony_ci#define PB1200_SD1_INSERT_INT	(DB1200_INT_BEGIN + 14)
788c2ecf20Sopenharmony_ci#define PB1200_SD1_EJECT_INT	(DB1200_INT_BEGIN + 15)
798c2ecf20Sopenharmony_ci#define DB1200_INT_END		(DB1200_INT_BEGIN + 15)
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ciconst char *get_system_type(void);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic int __init db1200_detect_board(void)
848c2ecf20Sopenharmony_ci{
858c2ecf20Sopenharmony_ci	int bid;
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci	/* try the DB1200 first */
888c2ecf20Sopenharmony_ci	bcsr_init(DB1200_BCSR_PHYS_ADDR,
898c2ecf20Sopenharmony_ci		  DB1200_BCSR_PHYS_ADDR + DB1200_BCSR_HEXLED_OFS);
908c2ecf20Sopenharmony_ci	if (BCSR_WHOAMI_DB1200 == BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) {
918c2ecf20Sopenharmony_ci		unsigned short t = bcsr_read(BCSR_HEXLEDS);
928c2ecf20Sopenharmony_ci		bcsr_write(BCSR_HEXLEDS, ~t);
938c2ecf20Sopenharmony_ci		if (bcsr_read(BCSR_HEXLEDS) != t) {
948c2ecf20Sopenharmony_ci			bcsr_write(BCSR_HEXLEDS, t);
958c2ecf20Sopenharmony_ci			return 0;
968c2ecf20Sopenharmony_ci		}
978c2ecf20Sopenharmony_ci	}
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci	/* okay, try the PB1200 then */
1008c2ecf20Sopenharmony_ci	bcsr_init(PB1200_BCSR_PHYS_ADDR,
1018c2ecf20Sopenharmony_ci		  PB1200_BCSR_PHYS_ADDR + PB1200_BCSR_HEXLED_OFS);
1028c2ecf20Sopenharmony_ci	bid = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI));
1038c2ecf20Sopenharmony_ci	if ((bid == BCSR_WHOAMI_PB1200_DDR1) ||
1048c2ecf20Sopenharmony_ci	    (bid == BCSR_WHOAMI_PB1200_DDR2)) {
1058c2ecf20Sopenharmony_ci		unsigned short t = bcsr_read(BCSR_HEXLEDS);
1068c2ecf20Sopenharmony_ci		bcsr_write(BCSR_HEXLEDS, ~t);
1078c2ecf20Sopenharmony_ci		if (bcsr_read(BCSR_HEXLEDS) != t) {
1088c2ecf20Sopenharmony_ci			bcsr_write(BCSR_HEXLEDS, t);
1098c2ecf20Sopenharmony_ci			return 0;
1108c2ecf20Sopenharmony_ci		}
1118c2ecf20Sopenharmony_ci	}
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci	return 1;	/* it's neither */
1148c2ecf20Sopenharmony_ci}
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ciint __init db1200_board_setup(void)
1178c2ecf20Sopenharmony_ci{
1188c2ecf20Sopenharmony_ci	unsigned short whoami;
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	if (db1200_detect_board())
1218c2ecf20Sopenharmony_ci		return -ENODEV;
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	whoami = bcsr_read(BCSR_WHOAMI);
1248c2ecf20Sopenharmony_ci	switch (BCSR_WHOAMI_BOARD(whoami)) {
1258c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1200_DDR1:
1268c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1200_DDR2:
1278c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1200:
1288c2ecf20Sopenharmony_ci		break;
1298c2ecf20Sopenharmony_ci	default:
1308c2ecf20Sopenharmony_ci		return -ENODEV;
1318c2ecf20Sopenharmony_ci	}
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci	printk(KERN_INFO "Alchemy/AMD/RMI %s Board, CPLD Rev %d"
1348c2ecf20Sopenharmony_ci		"  Board-ID %d	Daughtercard ID %d\n", get_system_type(),
1358c2ecf20Sopenharmony_ci		(whoami >> 4) & 0xf, (whoami >> 8) & 0xf, whoami & 0xf);
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci	return 0;
1388c2ecf20Sopenharmony_ci}
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci/******************************************************************************/
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cistatic u64 au1200_all_dmamask = DMA_BIT_MASK(32);
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cistatic struct mtd_partition db1200_spiflash_parts[] = {
1458c2ecf20Sopenharmony_ci	{
1468c2ecf20Sopenharmony_ci		.name	= "spi_flash",
1478c2ecf20Sopenharmony_ci		.offset = 0,
1488c2ecf20Sopenharmony_ci		.size	= MTDPART_SIZ_FULL,
1498c2ecf20Sopenharmony_ci	},
1508c2ecf20Sopenharmony_ci};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistatic struct flash_platform_data db1200_spiflash_data = {
1538c2ecf20Sopenharmony_ci	.name		= "s25fl001",
1548c2ecf20Sopenharmony_ci	.parts		= db1200_spiflash_parts,
1558c2ecf20Sopenharmony_ci	.nr_parts	= ARRAY_SIZE(db1200_spiflash_parts),
1568c2ecf20Sopenharmony_ci	.type		= "m25p10",
1578c2ecf20Sopenharmony_ci};
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_cistatic struct spi_board_info db1200_spi_devs[] __initdata = {
1608c2ecf20Sopenharmony_ci	{
1618c2ecf20Sopenharmony_ci		/* TI TMP121AIDBVR temp sensor */
1628c2ecf20Sopenharmony_ci		.modalias	= "tmp121",
1638c2ecf20Sopenharmony_ci		.max_speed_hz	= 2000000,
1648c2ecf20Sopenharmony_ci		.bus_num	= 0,
1658c2ecf20Sopenharmony_ci		.chip_select	= 0,
1668c2ecf20Sopenharmony_ci		.mode		= 0,
1678c2ecf20Sopenharmony_ci	},
1688c2ecf20Sopenharmony_ci	{
1698c2ecf20Sopenharmony_ci		/* Spansion S25FL001D0FMA SPI flash */
1708c2ecf20Sopenharmony_ci		.modalias	= "m25p80",
1718c2ecf20Sopenharmony_ci		.max_speed_hz	= 50000000,
1728c2ecf20Sopenharmony_ci		.bus_num	= 0,
1738c2ecf20Sopenharmony_ci		.chip_select	= 1,
1748c2ecf20Sopenharmony_ci		.mode		= 0,
1758c2ecf20Sopenharmony_ci		.platform_data	= &db1200_spiflash_data,
1768c2ecf20Sopenharmony_ci	},
1778c2ecf20Sopenharmony_ci};
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_cistatic struct i2c_board_info db1200_i2c_devs[] __initdata = {
1808c2ecf20Sopenharmony_ci	{ I2C_BOARD_INFO("24c04", 0x52),  }, /* AT24C04-10 I2C eeprom */
1818c2ecf20Sopenharmony_ci	{ I2C_BOARD_INFO("ne1619", 0x2d), }, /* adm1025-compat hwmon */
1828c2ecf20Sopenharmony_ci	{ I2C_BOARD_INFO("wm8731", 0x1b), }, /* I2S audio codec WM8731 */
1838c2ecf20Sopenharmony_ci};
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/**********************************************************************/
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_cistatic void au1200_nand_cmd_ctrl(struct nand_chip *this, int cmd,
1888c2ecf20Sopenharmony_ci				 unsigned int ctrl)
1898c2ecf20Sopenharmony_ci{
1908c2ecf20Sopenharmony_ci	unsigned long ioaddr = (unsigned long)this->legacy.IO_ADDR_W;
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci	ioaddr &= 0xffffff00;
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	if (ctrl & NAND_CLE) {
1958c2ecf20Sopenharmony_ci		ioaddr += MEM_STNAND_CMD;
1968c2ecf20Sopenharmony_ci	} else if (ctrl & NAND_ALE) {
1978c2ecf20Sopenharmony_ci		ioaddr += MEM_STNAND_ADDR;
1988c2ecf20Sopenharmony_ci	} else {
1998c2ecf20Sopenharmony_ci		/* assume we want to r/w real data  by default */
2008c2ecf20Sopenharmony_ci		ioaddr += MEM_STNAND_DATA;
2018c2ecf20Sopenharmony_ci	}
2028c2ecf20Sopenharmony_ci	this->legacy.IO_ADDR_R = this->legacy.IO_ADDR_W = (void __iomem *)ioaddr;
2038c2ecf20Sopenharmony_ci	if (cmd != NAND_CMD_NONE) {
2048c2ecf20Sopenharmony_ci		__raw_writeb(cmd, this->legacy.IO_ADDR_W);
2058c2ecf20Sopenharmony_ci		wmb();
2068c2ecf20Sopenharmony_ci	}
2078c2ecf20Sopenharmony_ci}
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistatic int au1200_nand_device_ready(struct nand_chip *this)
2108c2ecf20Sopenharmony_ci{
2118c2ecf20Sopenharmony_ci	return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1;
2128c2ecf20Sopenharmony_ci}
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistatic struct mtd_partition db1200_nand_parts[] = {
2158c2ecf20Sopenharmony_ci	{
2168c2ecf20Sopenharmony_ci		.name	= "NAND FS 0",
2178c2ecf20Sopenharmony_ci		.offset = 0,
2188c2ecf20Sopenharmony_ci		.size	= 8 * 1024 * 1024,
2198c2ecf20Sopenharmony_ci	},
2208c2ecf20Sopenharmony_ci	{
2218c2ecf20Sopenharmony_ci		.name	= "NAND FS 1",
2228c2ecf20Sopenharmony_ci		.offset = MTDPART_OFS_APPEND,
2238c2ecf20Sopenharmony_ci		.size	= MTDPART_SIZ_FULL
2248c2ecf20Sopenharmony_ci	},
2258c2ecf20Sopenharmony_ci};
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistruct platform_nand_data db1200_nand_platdata = {
2288c2ecf20Sopenharmony_ci	.chip = {
2298c2ecf20Sopenharmony_ci		.nr_chips	= 1,
2308c2ecf20Sopenharmony_ci		.chip_offset	= 0,
2318c2ecf20Sopenharmony_ci		.nr_partitions	= ARRAY_SIZE(db1200_nand_parts),
2328c2ecf20Sopenharmony_ci		.partitions	= db1200_nand_parts,
2338c2ecf20Sopenharmony_ci		.chip_delay	= 20,
2348c2ecf20Sopenharmony_ci	},
2358c2ecf20Sopenharmony_ci	.ctrl = {
2368c2ecf20Sopenharmony_ci		.dev_ready	= au1200_nand_device_ready,
2378c2ecf20Sopenharmony_ci		.cmd_ctrl	= au1200_nand_cmd_ctrl,
2388c2ecf20Sopenharmony_ci	},
2398c2ecf20Sopenharmony_ci};
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_cistatic struct resource db1200_nand_res[] = {
2428c2ecf20Sopenharmony_ci	[0] = {
2438c2ecf20Sopenharmony_ci		.start	= DB1200_NAND_PHYS_ADDR,
2448c2ecf20Sopenharmony_ci		.end	= DB1200_NAND_PHYS_ADDR + 0xff,
2458c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
2468c2ecf20Sopenharmony_ci	},
2478c2ecf20Sopenharmony_ci};
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_cistatic struct platform_device db1200_nand_dev = {
2508c2ecf20Sopenharmony_ci	.name		= "gen_nand",
2518c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(db1200_nand_res),
2528c2ecf20Sopenharmony_ci	.resource	= db1200_nand_res,
2538c2ecf20Sopenharmony_ci	.id		= -1,
2548c2ecf20Sopenharmony_ci	.dev		= {
2558c2ecf20Sopenharmony_ci		.platform_data = &db1200_nand_platdata,
2568c2ecf20Sopenharmony_ci	}
2578c2ecf20Sopenharmony_ci};
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci/**********************************************************************/
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_cistatic struct smc91x_platdata db1200_eth_data = {
2628c2ecf20Sopenharmony_ci	.flags	= SMC91X_NOWAIT | SMC91X_USE_16BIT,
2638c2ecf20Sopenharmony_ci	.leda	= RPC_LED_100_10,
2648c2ecf20Sopenharmony_ci	.ledb	= RPC_LED_TX_RX,
2658c2ecf20Sopenharmony_ci};
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_cistatic struct resource db1200_eth_res[] = {
2688c2ecf20Sopenharmony_ci	[0] = {
2698c2ecf20Sopenharmony_ci		.start	= DB1200_ETH_PHYS_ADDR,
2708c2ecf20Sopenharmony_ci		.end	= DB1200_ETH_PHYS_ADDR + 0xf,
2718c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
2728c2ecf20Sopenharmony_ci	},
2738c2ecf20Sopenharmony_ci	[1] = {
2748c2ecf20Sopenharmony_ci		.start	= DB1200_ETH_INT,
2758c2ecf20Sopenharmony_ci		.end	= DB1200_ETH_INT,
2768c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2778c2ecf20Sopenharmony_ci	},
2788c2ecf20Sopenharmony_ci};
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_cistatic struct platform_device db1200_eth_dev = {
2818c2ecf20Sopenharmony_ci	.dev	= {
2828c2ecf20Sopenharmony_ci		.platform_data	= &db1200_eth_data,
2838c2ecf20Sopenharmony_ci	},
2848c2ecf20Sopenharmony_ci	.name		= "smc91x",
2858c2ecf20Sopenharmony_ci	.id		= -1,
2868c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(db1200_eth_res),
2878c2ecf20Sopenharmony_ci	.resource	= db1200_eth_res,
2888c2ecf20Sopenharmony_ci};
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci/**********************************************************************/
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cistatic struct pata_platform_info db1200_ide_info = {
2938c2ecf20Sopenharmony_ci	.ioport_shift	= DB1200_IDE_REG_SHIFT,
2948c2ecf20Sopenharmony_ci};
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci#define IDE_ALT_START	(14 << DB1200_IDE_REG_SHIFT)
2978c2ecf20Sopenharmony_cistatic struct resource db1200_ide_res[] = {
2988c2ecf20Sopenharmony_ci	[0] = {
2998c2ecf20Sopenharmony_ci		.start	= DB1200_IDE_PHYS_ADDR,
3008c2ecf20Sopenharmony_ci		.end	= DB1200_IDE_PHYS_ADDR + IDE_ALT_START - 1,
3018c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
3028c2ecf20Sopenharmony_ci	},
3038c2ecf20Sopenharmony_ci	[1] = {
3048c2ecf20Sopenharmony_ci		.start	= DB1200_IDE_PHYS_ADDR + IDE_ALT_START,
3058c2ecf20Sopenharmony_ci		.end	= DB1200_IDE_PHYS_ADDR + DB1200_IDE_PHYS_LEN - 1,
3068c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
3078c2ecf20Sopenharmony_ci	},
3088c2ecf20Sopenharmony_ci	[2] = {
3098c2ecf20Sopenharmony_ci		.start	= DB1200_IDE_INT,
3108c2ecf20Sopenharmony_ci		.end	= DB1200_IDE_INT,
3118c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3128c2ecf20Sopenharmony_ci	},
3138c2ecf20Sopenharmony_ci};
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_cistatic struct platform_device db1200_ide_dev = {
3168c2ecf20Sopenharmony_ci	.name		= "pata_platform",
3178c2ecf20Sopenharmony_ci	.id		= 0,
3188c2ecf20Sopenharmony_ci	.dev = {
3198c2ecf20Sopenharmony_ci		.dma_mask		= &au1200_all_dmamask,
3208c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
3218c2ecf20Sopenharmony_ci		.platform_data		= &db1200_ide_info,
3228c2ecf20Sopenharmony_ci	},
3238c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(db1200_ide_res),
3248c2ecf20Sopenharmony_ci	.resource	= db1200_ide_res,
3258c2ecf20Sopenharmony_ci};
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci/**********************************************************************/
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci#ifdef CONFIG_MMC_AU1X
3308c2ecf20Sopenharmony_ci/* SD carddetects:  they're supposed to be edge-triggered, but ack
3318c2ecf20Sopenharmony_ci * doesn't seem to work (CPLD Rev 2).  Instead, the screaming one
3328c2ecf20Sopenharmony_ci * is disabled and its counterpart enabled.  The 200ms timeout is
3338c2ecf20Sopenharmony_ci * because the carddetect usually triggers twice, after debounce.
3348c2ecf20Sopenharmony_ci */
3358c2ecf20Sopenharmony_cistatic irqreturn_t db1200_mmc_cd(int irq, void *ptr)
3368c2ecf20Sopenharmony_ci{
3378c2ecf20Sopenharmony_ci	disable_irq_nosync(irq);
3388c2ecf20Sopenharmony_ci	return IRQ_WAKE_THREAD;
3398c2ecf20Sopenharmony_ci}
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_cistatic irqreturn_t db1200_mmc_cdfn(int irq, void *ptr)
3428c2ecf20Sopenharmony_ci{
3438c2ecf20Sopenharmony_ci	mmc_detect_change(ptr, msecs_to_jiffies(200));
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci	msleep(100);	/* debounce */
3468c2ecf20Sopenharmony_ci	if (irq == DB1200_SD0_INSERT_INT)
3478c2ecf20Sopenharmony_ci		enable_irq(DB1200_SD0_EJECT_INT);
3488c2ecf20Sopenharmony_ci	else
3498c2ecf20Sopenharmony_ci		enable_irq(DB1200_SD0_INSERT_INT);
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	return IRQ_HANDLED;
3528c2ecf20Sopenharmony_ci}
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_cistatic int db1200_mmc_cd_setup(void *mmc_host, int en)
3558c2ecf20Sopenharmony_ci{
3568c2ecf20Sopenharmony_ci	int ret;
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci	if (en) {
3598c2ecf20Sopenharmony_ci		ret = request_threaded_irq(DB1200_SD0_INSERT_INT, db1200_mmc_cd,
3608c2ecf20Sopenharmony_ci				db1200_mmc_cdfn, 0, "sd_insert", mmc_host);
3618c2ecf20Sopenharmony_ci		if (ret)
3628c2ecf20Sopenharmony_ci			goto out;
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci		ret = request_threaded_irq(DB1200_SD0_EJECT_INT, db1200_mmc_cd,
3658c2ecf20Sopenharmony_ci				db1200_mmc_cdfn, 0, "sd_eject", mmc_host);
3668c2ecf20Sopenharmony_ci		if (ret) {
3678c2ecf20Sopenharmony_ci			free_irq(DB1200_SD0_INSERT_INT, mmc_host);
3688c2ecf20Sopenharmony_ci			goto out;
3698c2ecf20Sopenharmony_ci		}
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci		if (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT)
3728c2ecf20Sopenharmony_ci			enable_irq(DB1200_SD0_EJECT_INT);
3738c2ecf20Sopenharmony_ci		else
3748c2ecf20Sopenharmony_ci			enable_irq(DB1200_SD0_INSERT_INT);
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci	} else {
3778c2ecf20Sopenharmony_ci		free_irq(DB1200_SD0_INSERT_INT, mmc_host);
3788c2ecf20Sopenharmony_ci		free_irq(DB1200_SD0_EJECT_INT, mmc_host);
3798c2ecf20Sopenharmony_ci	}
3808c2ecf20Sopenharmony_ci	ret = 0;
3818c2ecf20Sopenharmony_ciout:
3828c2ecf20Sopenharmony_ci	return ret;
3838c2ecf20Sopenharmony_ci}
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_cistatic void db1200_mmc_set_power(void *mmc_host, int state)
3868c2ecf20Sopenharmony_ci{
3878c2ecf20Sopenharmony_ci	if (state) {
3888c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD0PWR);
3898c2ecf20Sopenharmony_ci		msleep(400);	/* stabilization time */
3908c2ecf20Sopenharmony_ci	} else
3918c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD0PWR, 0);
3928c2ecf20Sopenharmony_ci}
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_cistatic int db1200_mmc_card_readonly(void *mmc_host)
3958c2ecf20Sopenharmony_ci{
3968c2ecf20Sopenharmony_ci	return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 1 : 0;
3978c2ecf20Sopenharmony_ci}
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_cistatic int db1200_mmc_card_inserted(void *mmc_host)
4008c2ecf20Sopenharmony_ci{
4018c2ecf20Sopenharmony_ci	return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT) ? 1 : 0;
4028c2ecf20Sopenharmony_ci}
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_cistatic void db1200_mmcled_set(struct led_classdev *led,
4058c2ecf20Sopenharmony_ci			      enum led_brightness brightness)
4068c2ecf20Sopenharmony_ci{
4078c2ecf20Sopenharmony_ci	if (brightness != LED_OFF)
4088c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
4098c2ecf20Sopenharmony_ci	else
4108c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
4118c2ecf20Sopenharmony_ci}
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_cistatic struct led_classdev db1200_mmc_led = {
4148c2ecf20Sopenharmony_ci	.brightness_set = db1200_mmcled_set,
4158c2ecf20Sopenharmony_ci};
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci/* -- */
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_cistatic irqreturn_t pb1200_mmc1_cd(int irq, void *ptr)
4208c2ecf20Sopenharmony_ci{
4218c2ecf20Sopenharmony_ci	disable_irq_nosync(irq);
4228c2ecf20Sopenharmony_ci	return IRQ_WAKE_THREAD;
4238c2ecf20Sopenharmony_ci}
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_cistatic irqreturn_t pb1200_mmc1_cdfn(int irq, void *ptr)
4268c2ecf20Sopenharmony_ci{
4278c2ecf20Sopenharmony_ci	mmc_detect_change(ptr, msecs_to_jiffies(200));
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci	msleep(100);	/* debounce */
4308c2ecf20Sopenharmony_ci	if (irq == PB1200_SD1_INSERT_INT)
4318c2ecf20Sopenharmony_ci		enable_irq(PB1200_SD1_EJECT_INT);
4328c2ecf20Sopenharmony_ci	else
4338c2ecf20Sopenharmony_ci		enable_irq(PB1200_SD1_INSERT_INT);
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	return IRQ_HANDLED;
4368c2ecf20Sopenharmony_ci}
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistatic int pb1200_mmc1_cd_setup(void *mmc_host, int en)
4398c2ecf20Sopenharmony_ci{
4408c2ecf20Sopenharmony_ci	int ret;
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci	if (en) {
4438c2ecf20Sopenharmony_ci		ret = request_threaded_irq(PB1200_SD1_INSERT_INT, pb1200_mmc1_cd,
4448c2ecf20Sopenharmony_ci				pb1200_mmc1_cdfn, 0, "sd1_insert", mmc_host);
4458c2ecf20Sopenharmony_ci		if (ret)
4468c2ecf20Sopenharmony_ci			goto out;
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci		ret = request_threaded_irq(PB1200_SD1_EJECT_INT, pb1200_mmc1_cd,
4498c2ecf20Sopenharmony_ci				pb1200_mmc1_cdfn, 0, "sd1_eject", mmc_host);
4508c2ecf20Sopenharmony_ci		if (ret) {
4518c2ecf20Sopenharmony_ci			free_irq(PB1200_SD1_INSERT_INT, mmc_host);
4528c2ecf20Sopenharmony_ci			goto out;
4538c2ecf20Sopenharmony_ci		}
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci		if (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD1INSERT)
4568c2ecf20Sopenharmony_ci			enable_irq(PB1200_SD1_EJECT_INT);
4578c2ecf20Sopenharmony_ci		else
4588c2ecf20Sopenharmony_ci			enable_irq(PB1200_SD1_INSERT_INT);
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci	} else {
4618c2ecf20Sopenharmony_ci		free_irq(PB1200_SD1_INSERT_INT, mmc_host);
4628c2ecf20Sopenharmony_ci		free_irq(PB1200_SD1_EJECT_INT, mmc_host);
4638c2ecf20Sopenharmony_ci	}
4648c2ecf20Sopenharmony_ci	ret = 0;
4658c2ecf20Sopenharmony_ciout:
4668c2ecf20Sopenharmony_ci	return ret;
4678c2ecf20Sopenharmony_ci}
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_cistatic void pb1200_mmc1led_set(struct led_classdev *led,
4708c2ecf20Sopenharmony_ci			enum led_brightness brightness)
4718c2ecf20Sopenharmony_ci{
4728c2ecf20Sopenharmony_ci	if (brightness != LED_OFF)
4738c2ecf20Sopenharmony_ci			bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED1, 0);
4748c2ecf20Sopenharmony_ci	else
4758c2ecf20Sopenharmony_ci			bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED1);
4768c2ecf20Sopenharmony_ci}
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_cistatic struct led_classdev pb1200_mmc1_led = {
4798c2ecf20Sopenharmony_ci	.brightness_set = pb1200_mmc1led_set,
4808c2ecf20Sopenharmony_ci};
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_cistatic void pb1200_mmc1_set_power(void *mmc_host, int state)
4838c2ecf20Sopenharmony_ci{
4848c2ecf20Sopenharmony_ci	if (state) {
4858c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD1PWR);
4868c2ecf20Sopenharmony_ci		msleep(400);	/* stabilization time */
4878c2ecf20Sopenharmony_ci	} else
4888c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD1PWR, 0);
4898c2ecf20Sopenharmony_ci}
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_cistatic int pb1200_mmc1_card_readonly(void *mmc_host)
4928c2ecf20Sopenharmony_ci{
4938c2ecf20Sopenharmony_ci	return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD1WP) ? 1 : 0;
4948c2ecf20Sopenharmony_ci}
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_cistatic int pb1200_mmc1_card_inserted(void *mmc_host)
4978c2ecf20Sopenharmony_ci{
4988c2ecf20Sopenharmony_ci	return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD1INSERT) ? 1 : 0;
4998c2ecf20Sopenharmony_ci}
5008c2ecf20Sopenharmony_ci
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_cistatic struct au1xmmc_platform_data db1200_mmc_platdata[2] = {
5038c2ecf20Sopenharmony_ci	[0] = {
5048c2ecf20Sopenharmony_ci		.cd_setup	= db1200_mmc_cd_setup,
5058c2ecf20Sopenharmony_ci		.set_power	= db1200_mmc_set_power,
5068c2ecf20Sopenharmony_ci		.card_inserted	= db1200_mmc_card_inserted,
5078c2ecf20Sopenharmony_ci		.card_readonly	= db1200_mmc_card_readonly,
5088c2ecf20Sopenharmony_ci		.led		= &db1200_mmc_led,
5098c2ecf20Sopenharmony_ci	},
5108c2ecf20Sopenharmony_ci	[1] = {
5118c2ecf20Sopenharmony_ci		.cd_setup	= pb1200_mmc1_cd_setup,
5128c2ecf20Sopenharmony_ci		.set_power	= pb1200_mmc1_set_power,
5138c2ecf20Sopenharmony_ci		.card_inserted	= pb1200_mmc1_card_inserted,
5148c2ecf20Sopenharmony_ci		.card_readonly	= pb1200_mmc1_card_readonly,
5158c2ecf20Sopenharmony_ci		.led		= &pb1200_mmc1_led,
5168c2ecf20Sopenharmony_ci	},
5178c2ecf20Sopenharmony_ci};
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_cistatic struct resource au1200_mmc0_resources[] = {
5208c2ecf20Sopenharmony_ci	[0] = {
5218c2ecf20Sopenharmony_ci		.start	= AU1100_SD0_PHYS_ADDR,
5228c2ecf20Sopenharmony_ci		.end	= AU1100_SD0_PHYS_ADDR + 0xfff,
5238c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5248c2ecf20Sopenharmony_ci	},
5258c2ecf20Sopenharmony_ci	[1] = {
5268c2ecf20Sopenharmony_ci		.start	= AU1200_SD_INT,
5278c2ecf20Sopenharmony_ci		.end	= AU1200_SD_INT,
5288c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5298c2ecf20Sopenharmony_ci	},
5308c2ecf20Sopenharmony_ci	[2] = {
5318c2ecf20Sopenharmony_ci		.start	= AU1200_DSCR_CMD0_SDMS_TX0,
5328c2ecf20Sopenharmony_ci		.end	= AU1200_DSCR_CMD0_SDMS_TX0,
5338c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
5348c2ecf20Sopenharmony_ci	},
5358c2ecf20Sopenharmony_ci	[3] = {
5368c2ecf20Sopenharmony_ci		.start	= AU1200_DSCR_CMD0_SDMS_RX0,
5378c2ecf20Sopenharmony_ci		.end	= AU1200_DSCR_CMD0_SDMS_RX0,
5388c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
5398c2ecf20Sopenharmony_ci	}
5408c2ecf20Sopenharmony_ci};
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_cistatic struct platform_device db1200_mmc0_dev = {
5438c2ecf20Sopenharmony_ci	.name		= "au1xxx-mmc",
5448c2ecf20Sopenharmony_ci	.id		= 0,
5458c2ecf20Sopenharmony_ci	.dev = {
5468c2ecf20Sopenharmony_ci		.dma_mask		= &au1200_all_dmamask,
5478c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
5488c2ecf20Sopenharmony_ci		.platform_data		= &db1200_mmc_platdata[0],
5498c2ecf20Sopenharmony_ci	},
5508c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(au1200_mmc0_resources),
5518c2ecf20Sopenharmony_ci	.resource	= au1200_mmc0_resources,
5528c2ecf20Sopenharmony_ci};
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_cistatic struct resource au1200_mmc1_res[] = {
5558c2ecf20Sopenharmony_ci	[0] = {
5568c2ecf20Sopenharmony_ci		.start	= AU1100_SD1_PHYS_ADDR,
5578c2ecf20Sopenharmony_ci		.end	= AU1100_SD1_PHYS_ADDR + 0xfff,
5588c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5598c2ecf20Sopenharmony_ci	},
5608c2ecf20Sopenharmony_ci	[1] = {
5618c2ecf20Sopenharmony_ci		.start	= AU1200_SD_INT,
5628c2ecf20Sopenharmony_ci		.end	= AU1200_SD_INT,
5638c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5648c2ecf20Sopenharmony_ci	},
5658c2ecf20Sopenharmony_ci	[2] = {
5668c2ecf20Sopenharmony_ci		.start	= AU1200_DSCR_CMD0_SDMS_TX1,
5678c2ecf20Sopenharmony_ci		.end	= AU1200_DSCR_CMD0_SDMS_TX1,
5688c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
5698c2ecf20Sopenharmony_ci	},
5708c2ecf20Sopenharmony_ci	[3] = {
5718c2ecf20Sopenharmony_ci		.start	= AU1200_DSCR_CMD0_SDMS_RX1,
5728c2ecf20Sopenharmony_ci		.end	= AU1200_DSCR_CMD0_SDMS_RX1,
5738c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
5748c2ecf20Sopenharmony_ci	}
5758c2ecf20Sopenharmony_ci};
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_cistatic struct platform_device pb1200_mmc1_dev = {
5788c2ecf20Sopenharmony_ci	.name		= "au1xxx-mmc",
5798c2ecf20Sopenharmony_ci	.id		= 1,
5808c2ecf20Sopenharmony_ci	.dev = {
5818c2ecf20Sopenharmony_ci		.dma_mask		= &au1200_all_dmamask,
5828c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
5838c2ecf20Sopenharmony_ci		.platform_data		= &db1200_mmc_platdata[1],
5848c2ecf20Sopenharmony_ci	},
5858c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(au1200_mmc1_res),
5868c2ecf20Sopenharmony_ci	.resource	= au1200_mmc1_res,
5878c2ecf20Sopenharmony_ci};
5888c2ecf20Sopenharmony_ci#endif /* CONFIG_MMC_AU1X */
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci/**********************************************************************/
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_cistatic int db1200fb_panel_index(void)
5938c2ecf20Sopenharmony_ci{
5948c2ecf20Sopenharmony_ci	return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f;
5958c2ecf20Sopenharmony_ci}
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_cistatic int db1200fb_panel_init(void)
5988c2ecf20Sopenharmony_ci{
5998c2ecf20Sopenharmony_ci	/* Apply power */
6008c2ecf20Sopenharmony_ci	bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
6018c2ecf20Sopenharmony_ci				BCSR_BOARD_LCDBL);
6028c2ecf20Sopenharmony_ci	return 0;
6038c2ecf20Sopenharmony_ci}
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_cistatic int db1200fb_panel_shutdown(void)
6068c2ecf20Sopenharmony_ci{
6078c2ecf20Sopenharmony_ci	/* Remove power */
6088c2ecf20Sopenharmony_ci	bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
6098c2ecf20Sopenharmony_ci			     BCSR_BOARD_LCDBL, 0);
6108c2ecf20Sopenharmony_ci	return 0;
6118c2ecf20Sopenharmony_ci}
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_cistatic struct au1200fb_platdata db1200fb_pd = {
6148c2ecf20Sopenharmony_ci	.panel_index	= db1200fb_panel_index,
6158c2ecf20Sopenharmony_ci	.panel_init	= db1200fb_panel_init,
6168c2ecf20Sopenharmony_ci	.panel_shutdown = db1200fb_panel_shutdown,
6178c2ecf20Sopenharmony_ci};
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_cistatic struct resource au1200_lcd_res[] = {
6208c2ecf20Sopenharmony_ci	[0] = {
6218c2ecf20Sopenharmony_ci		.start	= AU1200_LCD_PHYS_ADDR,
6228c2ecf20Sopenharmony_ci		.end	= AU1200_LCD_PHYS_ADDR + 0x800 - 1,
6238c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
6248c2ecf20Sopenharmony_ci	},
6258c2ecf20Sopenharmony_ci	[1] = {
6268c2ecf20Sopenharmony_ci		.start	= AU1200_LCD_INT,
6278c2ecf20Sopenharmony_ci		.end	= AU1200_LCD_INT,
6288c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
6298c2ecf20Sopenharmony_ci	}
6308c2ecf20Sopenharmony_ci};
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_cistatic struct platform_device au1200_lcd_dev = {
6338c2ecf20Sopenharmony_ci	.name		= "au1200-lcd",
6348c2ecf20Sopenharmony_ci	.id		= 0,
6358c2ecf20Sopenharmony_ci	.dev = {
6368c2ecf20Sopenharmony_ci		.dma_mask		= &au1200_all_dmamask,
6378c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
6388c2ecf20Sopenharmony_ci		.platform_data		= &db1200fb_pd,
6398c2ecf20Sopenharmony_ci	},
6408c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(au1200_lcd_res),
6418c2ecf20Sopenharmony_ci	.resource	= au1200_lcd_res,
6428c2ecf20Sopenharmony_ci};
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_ci/**********************************************************************/
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_cistatic struct resource au1200_psc0_res[] = {
6478c2ecf20Sopenharmony_ci	[0] = {
6488c2ecf20Sopenharmony_ci		.start	= AU1550_PSC0_PHYS_ADDR,
6498c2ecf20Sopenharmony_ci		.end	= AU1550_PSC0_PHYS_ADDR + 0xfff,
6508c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
6518c2ecf20Sopenharmony_ci	},
6528c2ecf20Sopenharmony_ci	[1] = {
6538c2ecf20Sopenharmony_ci		.start	= AU1200_PSC0_INT,
6548c2ecf20Sopenharmony_ci		.end	= AU1200_PSC0_INT,
6558c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
6568c2ecf20Sopenharmony_ci	},
6578c2ecf20Sopenharmony_ci	[2] = {
6588c2ecf20Sopenharmony_ci		.start	= AU1200_DSCR_CMD0_PSC0_TX,
6598c2ecf20Sopenharmony_ci		.end	= AU1200_DSCR_CMD0_PSC0_TX,
6608c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
6618c2ecf20Sopenharmony_ci	},
6628c2ecf20Sopenharmony_ci	[3] = {
6638c2ecf20Sopenharmony_ci		.start	= AU1200_DSCR_CMD0_PSC0_RX,
6648c2ecf20Sopenharmony_ci		.end	= AU1200_DSCR_CMD0_PSC0_RX,
6658c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
6668c2ecf20Sopenharmony_ci	},
6678c2ecf20Sopenharmony_ci};
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_cistatic struct platform_device db1200_i2c_dev = {
6708c2ecf20Sopenharmony_ci	.name		= "au1xpsc_smbus",
6718c2ecf20Sopenharmony_ci	.id		= 0,	/* bus number */
6728c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(au1200_psc0_res),
6738c2ecf20Sopenharmony_ci	.resource	= au1200_psc0_res,
6748c2ecf20Sopenharmony_ci};
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_cistatic void db1200_spi_cs_en(struct au1550_spi_info *spi, int cs, int pol)
6778c2ecf20Sopenharmony_ci{
6788c2ecf20Sopenharmony_ci	if (cs)
6798c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_SPISEL);
6808c2ecf20Sopenharmony_ci	else
6818c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_RESETS, BCSR_RESETS_SPISEL, 0);
6828c2ecf20Sopenharmony_ci}
6838c2ecf20Sopenharmony_ci
6848c2ecf20Sopenharmony_cistatic struct au1550_spi_info db1200_spi_platdata = {
6858c2ecf20Sopenharmony_ci	.mainclk_hz	= 50000000,	/* PSC0 clock */
6868c2ecf20Sopenharmony_ci	.num_chipselect = 2,
6878c2ecf20Sopenharmony_ci	.activate_cs	= db1200_spi_cs_en,
6888c2ecf20Sopenharmony_ci};
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_cistatic struct platform_device db1200_spi_dev = {
6918c2ecf20Sopenharmony_ci	.dev	= {
6928c2ecf20Sopenharmony_ci		.dma_mask		= &au1200_all_dmamask,
6938c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
6948c2ecf20Sopenharmony_ci		.platform_data		= &db1200_spi_platdata,
6958c2ecf20Sopenharmony_ci	},
6968c2ecf20Sopenharmony_ci	.name		= "au1550-spi",
6978c2ecf20Sopenharmony_ci	.id		= 0,	/* bus number */
6988c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(au1200_psc0_res),
6998c2ecf20Sopenharmony_ci	.resource	= au1200_psc0_res,
7008c2ecf20Sopenharmony_ci};
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_cistatic struct resource au1200_psc1_res[] = {
7038c2ecf20Sopenharmony_ci	[0] = {
7048c2ecf20Sopenharmony_ci		.start	= AU1550_PSC1_PHYS_ADDR,
7058c2ecf20Sopenharmony_ci		.end	= AU1550_PSC1_PHYS_ADDR + 0xfff,
7068c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
7078c2ecf20Sopenharmony_ci	},
7088c2ecf20Sopenharmony_ci	[1] = {
7098c2ecf20Sopenharmony_ci		.start	= AU1200_PSC1_INT,
7108c2ecf20Sopenharmony_ci		.end	= AU1200_PSC1_INT,
7118c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
7128c2ecf20Sopenharmony_ci	},
7138c2ecf20Sopenharmony_ci	[2] = {
7148c2ecf20Sopenharmony_ci		.start	= AU1200_DSCR_CMD0_PSC1_TX,
7158c2ecf20Sopenharmony_ci		.end	= AU1200_DSCR_CMD0_PSC1_TX,
7168c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
7178c2ecf20Sopenharmony_ci	},
7188c2ecf20Sopenharmony_ci	[3] = {
7198c2ecf20Sopenharmony_ci		.start	= AU1200_DSCR_CMD0_PSC1_RX,
7208c2ecf20Sopenharmony_ci		.end	= AU1200_DSCR_CMD0_PSC1_RX,
7218c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
7228c2ecf20Sopenharmony_ci	},
7238c2ecf20Sopenharmony_ci};
7248c2ecf20Sopenharmony_ci
7258c2ecf20Sopenharmony_ci/* AC97 or I2S device */
7268c2ecf20Sopenharmony_cistatic struct platform_device db1200_audio_dev = {
7278c2ecf20Sopenharmony_ci	/* name assigned later based on switch setting */
7288c2ecf20Sopenharmony_ci	.id		= 1,	/* PSC ID */
7298c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(au1200_psc1_res),
7308c2ecf20Sopenharmony_ci	.resource	= au1200_psc1_res,
7318c2ecf20Sopenharmony_ci};
7328c2ecf20Sopenharmony_ci
7338c2ecf20Sopenharmony_ci/* DB1200 ASoC card device */
7348c2ecf20Sopenharmony_cistatic struct platform_device db1200_sound_dev = {
7358c2ecf20Sopenharmony_ci	/* name assigned later based on switch setting */
7368c2ecf20Sopenharmony_ci	.id		= 1,	/* PSC ID */
7378c2ecf20Sopenharmony_ci	.dev = {
7388c2ecf20Sopenharmony_ci		.dma_mask		= &au1200_all_dmamask,
7398c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
7408c2ecf20Sopenharmony_ci	},
7418c2ecf20Sopenharmony_ci};
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_cistatic struct platform_device db1200_stac_dev = {
7448c2ecf20Sopenharmony_ci	.name		= "ac97-codec",
7458c2ecf20Sopenharmony_ci	.id		= 1,	/* on PSC1 */
7468c2ecf20Sopenharmony_ci};
7478c2ecf20Sopenharmony_ci
7488c2ecf20Sopenharmony_cistatic struct platform_device db1200_audiodma_dev = {
7498c2ecf20Sopenharmony_ci	.name		= "au1xpsc-pcm",
7508c2ecf20Sopenharmony_ci	.id		= 1,	/* PSC ID */
7518c2ecf20Sopenharmony_ci};
7528c2ecf20Sopenharmony_ci
7538c2ecf20Sopenharmony_cistatic struct platform_device *db1200_devs[] __initdata = {
7548c2ecf20Sopenharmony_ci	NULL,		/* PSC0, selected by S6.8 */
7558c2ecf20Sopenharmony_ci	&db1200_ide_dev,
7568c2ecf20Sopenharmony_ci#ifdef CONFIG_MMC_AU1X
7578c2ecf20Sopenharmony_ci	&db1200_mmc0_dev,
7588c2ecf20Sopenharmony_ci#endif
7598c2ecf20Sopenharmony_ci	&au1200_lcd_dev,
7608c2ecf20Sopenharmony_ci	&db1200_eth_dev,
7618c2ecf20Sopenharmony_ci	&db1200_nand_dev,
7628c2ecf20Sopenharmony_ci	&db1200_audiodma_dev,
7638c2ecf20Sopenharmony_ci	&db1200_audio_dev,
7648c2ecf20Sopenharmony_ci	&db1200_stac_dev,
7658c2ecf20Sopenharmony_ci	&db1200_sound_dev,
7668c2ecf20Sopenharmony_ci};
7678c2ecf20Sopenharmony_ci
7688c2ecf20Sopenharmony_cistatic struct platform_device *pb1200_devs[] __initdata = {
7698c2ecf20Sopenharmony_ci#ifdef CONFIG_MMC_AU1X
7708c2ecf20Sopenharmony_ci	&pb1200_mmc1_dev,
7718c2ecf20Sopenharmony_ci#endif
7728c2ecf20Sopenharmony_ci};
7738c2ecf20Sopenharmony_ci
7748c2ecf20Sopenharmony_ci/* Some peripheral base addresses differ on the PB1200 */
7758c2ecf20Sopenharmony_cistatic int __init pb1200_res_fixup(void)
7768c2ecf20Sopenharmony_ci{
7778c2ecf20Sopenharmony_ci	/* CPLD Revs earlier than 4 cause problems */
7788c2ecf20Sopenharmony_ci	if (BCSR_WHOAMI_CPLD(bcsr_read(BCSR_WHOAMI)) <= 3) {
7798c2ecf20Sopenharmony_ci		printk(KERN_ERR "WARNING!!!\n");
7808c2ecf20Sopenharmony_ci		printk(KERN_ERR "WARNING!!!\n");
7818c2ecf20Sopenharmony_ci		printk(KERN_ERR "PB1200 must be at CPLD rev 4. Please have\n");
7828c2ecf20Sopenharmony_ci		printk(KERN_ERR "the board updated to latest revisions.\n");
7838c2ecf20Sopenharmony_ci		printk(KERN_ERR "This software will not work reliably\n");
7848c2ecf20Sopenharmony_ci		printk(KERN_ERR "on anything older than CPLD rev 4.!\n");
7858c2ecf20Sopenharmony_ci		printk(KERN_ERR "WARNING!!!\n");
7868c2ecf20Sopenharmony_ci		printk(KERN_ERR "WARNING!!!\n");
7878c2ecf20Sopenharmony_ci		return 1;
7888c2ecf20Sopenharmony_ci	}
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ci	db1200_nand_res[0].start = PB1200_NAND_PHYS_ADDR;
7918c2ecf20Sopenharmony_ci	db1200_nand_res[0].end	 = PB1200_NAND_PHYS_ADDR + 0xff;
7928c2ecf20Sopenharmony_ci	db1200_ide_res[0].start = PB1200_IDE_PHYS_ADDR;
7938c2ecf20Sopenharmony_ci	db1200_ide_res[0].end	= PB1200_IDE_PHYS_ADDR + DB1200_IDE_PHYS_LEN - 1;
7948c2ecf20Sopenharmony_ci	db1200_eth_res[0].start = PB1200_ETH_PHYS_ADDR;
7958c2ecf20Sopenharmony_ci	db1200_eth_res[0].end	= PB1200_ETH_PHYS_ADDR + 0xff;
7968c2ecf20Sopenharmony_ci	return 0;
7978c2ecf20Sopenharmony_ci}
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_ciint __init db1200_dev_setup(void)
8008c2ecf20Sopenharmony_ci{
8018c2ecf20Sopenharmony_ci	unsigned long pfc;
8028c2ecf20Sopenharmony_ci	unsigned short sw;
8038c2ecf20Sopenharmony_ci	int swapped, bid;
8048c2ecf20Sopenharmony_ci	struct clk *c;
8058c2ecf20Sopenharmony_ci
8068c2ecf20Sopenharmony_ci	bid = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI));
8078c2ecf20Sopenharmony_ci	if ((bid == BCSR_WHOAMI_PB1200_DDR1) ||
8088c2ecf20Sopenharmony_ci	    (bid == BCSR_WHOAMI_PB1200_DDR2)) {
8098c2ecf20Sopenharmony_ci		if (pb1200_res_fixup())
8108c2ecf20Sopenharmony_ci			return -ENODEV;
8118c2ecf20Sopenharmony_ci	}
8128c2ecf20Sopenharmony_ci
8138c2ecf20Sopenharmony_ci	/* GPIO7 is low-level triggered CPLD cascade */
8148c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1200_GPIO7_INT, IRQ_TYPE_LEVEL_LOW);
8158c2ecf20Sopenharmony_ci	bcsr_init_irq(DB1200_INT_BEGIN, DB1200_INT_END, AU1200_GPIO7_INT);
8168c2ecf20Sopenharmony_ci
8178c2ecf20Sopenharmony_ci	/* SMBus/SPI on PSC0, Audio on PSC1 */
8188c2ecf20Sopenharmony_ci	pfc = alchemy_rdsys(AU1000_SYS_PINFUNC);
8198c2ecf20Sopenharmony_ci	pfc &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B);
8208c2ecf20Sopenharmony_ci	pfc &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B | SYS_PINFUNC_FS3);
8218c2ecf20Sopenharmony_ci	pfc |= SYS_PINFUNC_P1C; /* SPI is configured later */
8228c2ecf20Sopenharmony_ci	alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
8238c2ecf20Sopenharmony_ci
8248c2ecf20Sopenharmony_ci	/* get 50MHz for I2C driver on PSC0 */
8258c2ecf20Sopenharmony_ci	c = clk_get(NULL, "psc0_intclk");
8268c2ecf20Sopenharmony_ci	if (!IS_ERR(c)) {
8278c2ecf20Sopenharmony_ci		pfc = clk_round_rate(c, 50000000);
8288c2ecf20Sopenharmony_ci		if ((pfc < 1) || (abs(50000000 - pfc) > 2500000))
8298c2ecf20Sopenharmony_ci			pr_warn("DB1200: cant get I2C close to 50MHz\n");
8308c2ecf20Sopenharmony_ci		else
8318c2ecf20Sopenharmony_ci			clk_set_rate(c, pfc);
8328c2ecf20Sopenharmony_ci		clk_prepare_enable(c);
8338c2ecf20Sopenharmony_ci		clk_put(c);
8348c2ecf20Sopenharmony_ci	}
8358c2ecf20Sopenharmony_ci
8368c2ecf20Sopenharmony_ci	/* insert/eject pairs: one of both is always screaming.	 To avoid
8378c2ecf20Sopenharmony_ci	 * issues they must not be automatically enabled when initially
8388c2ecf20Sopenharmony_ci	 * requested.
8398c2ecf20Sopenharmony_ci	 */
8408c2ecf20Sopenharmony_ci	irq_set_status_flags(DB1200_SD0_INSERT_INT, IRQ_NOAUTOEN);
8418c2ecf20Sopenharmony_ci	irq_set_status_flags(DB1200_SD0_EJECT_INT, IRQ_NOAUTOEN);
8428c2ecf20Sopenharmony_ci	irq_set_status_flags(DB1200_PC0_INSERT_INT, IRQ_NOAUTOEN);
8438c2ecf20Sopenharmony_ci	irq_set_status_flags(DB1200_PC0_EJECT_INT, IRQ_NOAUTOEN);
8448c2ecf20Sopenharmony_ci	irq_set_status_flags(DB1200_PC1_INSERT_INT, IRQ_NOAUTOEN);
8458c2ecf20Sopenharmony_ci	irq_set_status_flags(DB1200_PC1_EJECT_INT, IRQ_NOAUTOEN);
8468c2ecf20Sopenharmony_ci
8478c2ecf20Sopenharmony_ci	i2c_register_board_info(0, db1200_i2c_devs,
8488c2ecf20Sopenharmony_ci				ARRAY_SIZE(db1200_i2c_devs));
8498c2ecf20Sopenharmony_ci	spi_register_board_info(db1200_spi_devs,
8508c2ecf20Sopenharmony_ci				ARRAY_SIZE(db1200_spi_devs));
8518c2ecf20Sopenharmony_ci
8528c2ecf20Sopenharmony_ci	/* SWITCHES:	S6.8 I2C/SPI selector  (OFF=I2C	 ON=SPI)
8538c2ecf20Sopenharmony_ci	 *		S6.7 AC97/I2S selector (OFF=AC97 ON=I2S)
8548c2ecf20Sopenharmony_ci	 *		or S12 on the PB1200.
8558c2ecf20Sopenharmony_ci	 */
8568c2ecf20Sopenharmony_ci
8578c2ecf20Sopenharmony_ci	/* NOTE: GPIO215 controls OTG VBUS supply.  In SPI mode however
8588c2ecf20Sopenharmony_ci	 * this pin is claimed by PSC0 (unused though, but pinmux doesn't
8598c2ecf20Sopenharmony_ci	 * allow to free it without crippling the SPI interface).
8608c2ecf20Sopenharmony_ci	 * As a result, in SPI mode, OTG simply won't work (PSC0 uses
8618c2ecf20Sopenharmony_ci	 * it as an input pin which is pulled high on the boards).
8628c2ecf20Sopenharmony_ci	 */
8638c2ecf20Sopenharmony_ci	pfc = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PINFUNC_P0A;
8648c2ecf20Sopenharmony_ci
8658c2ecf20Sopenharmony_ci	/* switch off OTG VBUS supply */
8668c2ecf20Sopenharmony_ci	gpio_request(215, "otg-vbus");
8678c2ecf20Sopenharmony_ci	gpio_direction_output(215, 1);
8688c2ecf20Sopenharmony_ci
8698c2ecf20Sopenharmony_ci	printk(KERN_INFO "%s device configuration:\n", get_system_type());
8708c2ecf20Sopenharmony_ci
8718c2ecf20Sopenharmony_ci	sw = bcsr_read(BCSR_SWITCHES);
8728c2ecf20Sopenharmony_ci	if (sw & BCSR_SWITCHES_DIP_8) {
8738c2ecf20Sopenharmony_ci		db1200_devs[0] = &db1200_i2c_dev;
8748c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC0MUX, 0);
8758c2ecf20Sopenharmony_ci
8768c2ecf20Sopenharmony_ci		pfc |= (2 << 17);	/* GPIO2 block owns GPIO215 */
8778c2ecf20Sopenharmony_ci
8788c2ecf20Sopenharmony_ci		printk(KERN_INFO " S6.8 OFF: PSC0 mode I2C\n");
8798c2ecf20Sopenharmony_ci		printk(KERN_INFO "   OTG port VBUS supply available!\n");
8808c2ecf20Sopenharmony_ci	} else {
8818c2ecf20Sopenharmony_ci		db1200_devs[0] = &db1200_spi_dev;
8828c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_PSC0MUX);
8838c2ecf20Sopenharmony_ci
8848c2ecf20Sopenharmony_ci		pfc |= (1 << 17);	/* PSC0 owns GPIO215 */
8858c2ecf20Sopenharmony_ci
8868c2ecf20Sopenharmony_ci		printk(KERN_INFO " S6.8 ON : PSC0 mode SPI\n");
8878c2ecf20Sopenharmony_ci		printk(KERN_INFO "   OTG port VBUS supply disabled\n");
8888c2ecf20Sopenharmony_ci	}
8898c2ecf20Sopenharmony_ci	alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_ci	/* Audio: DIP7 selects I2S(0)/AC97(1), but need I2C for I2S!
8928c2ecf20Sopenharmony_ci	 * so: DIP7=1 || DIP8=0 => AC97, DIP7=0 && DIP8=1 => I2S
8938c2ecf20Sopenharmony_ci	 */
8948c2ecf20Sopenharmony_ci	sw &= BCSR_SWITCHES_DIP_8 | BCSR_SWITCHES_DIP_7;
8958c2ecf20Sopenharmony_ci	if (sw == BCSR_SWITCHES_DIP_8) {
8968c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_PSC1MUX);
8978c2ecf20Sopenharmony_ci		db1200_audio_dev.name = "au1xpsc_i2s";
8988c2ecf20Sopenharmony_ci		db1200_sound_dev.name = "db1200-i2s";
8998c2ecf20Sopenharmony_ci		printk(KERN_INFO " S6.7 ON : PSC1 mode I2S\n");
9008c2ecf20Sopenharmony_ci	} else {
9018c2ecf20Sopenharmony_ci		bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC1MUX, 0);
9028c2ecf20Sopenharmony_ci		db1200_audio_dev.name = "au1xpsc_ac97";
9038c2ecf20Sopenharmony_ci		db1200_sound_dev.name = "db1200-ac97";
9048c2ecf20Sopenharmony_ci		printk(KERN_INFO " S6.7 OFF: PSC1 mode AC97\n");
9058c2ecf20Sopenharmony_ci	}
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_ci	/* Audio PSC clock is supplied externally. (FIXME: platdata!!) */
9088c2ecf20Sopenharmony_ci	__raw_writel(PSC_SEL_CLK_SERCLK,
9098c2ecf20Sopenharmony_ci	    (void __iomem *)KSEG1ADDR(AU1550_PSC1_PHYS_ADDR) + PSC_SEL_OFFSET);
9108c2ecf20Sopenharmony_ci	wmb();
9118c2ecf20Sopenharmony_ci
9128c2ecf20Sopenharmony_ci	db1x_register_pcmcia_socket(
9138c2ecf20Sopenharmony_ci		AU1000_PCMCIA_ATTR_PHYS_ADDR,
9148c2ecf20Sopenharmony_ci		AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
9158c2ecf20Sopenharmony_ci		AU1000_PCMCIA_MEM_PHYS_ADDR,
9168c2ecf20Sopenharmony_ci		AU1000_PCMCIA_MEM_PHYS_ADDR  + 0x000400000 - 1,
9178c2ecf20Sopenharmony_ci		AU1000_PCMCIA_IO_PHYS_ADDR,
9188c2ecf20Sopenharmony_ci		AU1000_PCMCIA_IO_PHYS_ADDR   + 0x000010000 - 1,
9198c2ecf20Sopenharmony_ci		DB1200_PC0_INT, DB1200_PC0_INSERT_INT,
9208c2ecf20Sopenharmony_ci		/*DB1200_PC0_STSCHG_INT*/0, DB1200_PC0_EJECT_INT, 0);
9218c2ecf20Sopenharmony_ci
9228c2ecf20Sopenharmony_ci	db1x_register_pcmcia_socket(
9238c2ecf20Sopenharmony_ci		AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000,
9248c2ecf20Sopenharmony_ci		AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1,
9258c2ecf20Sopenharmony_ci		AU1000_PCMCIA_MEM_PHYS_ADDR  + 0x004000000,
9268c2ecf20Sopenharmony_ci		AU1000_PCMCIA_MEM_PHYS_ADDR  + 0x004400000 - 1,
9278c2ecf20Sopenharmony_ci		AU1000_PCMCIA_IO_PHYS_ADDR   + 0x004000000,
9288c2ecf20Sopenharmony_ci		AU1000_PCMCIA_IO_PHYS_ADDR   + 0x004010000 - 1,
9298c2ecf20Sopenharmony_ci		DB1200_PC1_INT, DB1200_PC1_INSERT_INT,
9308c2ecf20Sopenharmony_ci		/*DB1200_PC1_STSCHG_INT*/0, DB1200_PC1_EJECT_INT, 1);
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_ci	swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1200_SWAPBOOT;
9338c2ecf20Sopenharmony_ci	db1x_register_norflash(64 << 20, 2, swapped);
9348c2ecf20Sopenharmony_ci
9358c2ecf20Sopenharmony_ci	platform_add_devices(db1200_devs, ARRAY_SIZE(db1200_devs));
9368c2ecf20Sopenharmony_ci
9378c2ecf20Sopenharmony_ci	/* PB1200 is a DB1200 with a 2nd MMC and Camera connector */
9388c2ecf20Sopenharmony_ci	if ((bid == BCSR_WHOAMI_PB1200_DDR1) ||
9398c2ecf20Sopenharmony_ci	    (bid == BCSR_WHOAMI_PB1200_DDR2))
9408c2ecf20Sopenharmony_ci		platform_add_devices(pb1200_devs, ARRAY_SIZE(pb1200_devs));
9418c2ecf20Sopenharmony_ci
9428c2ecf20Sopenharmony_ci	return 0;
9438c2ecf20Sopenharmony_ci}
944