ttc_dkb.c 7.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 *  linux/arch/arm/mach-mmp/ttc_dkb.c
 *
 *  Support for the Marvell PXA910-based TTC_DKB Development Platform.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  publishhed by the Free Software Foundation.
 */

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
14 15 16
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/onenand.h>
H
Haojian Zhuang 已提交
17
#include <linux/interrupt.h>
18
#include <linux/platform_data/pca953x.h>
19
#include <linux/gpio.h>
20
#include <linux/gpio-pxa.h>
C
Chao Xie 已提交
21
#include <linux/mfd/88pm860x.h>
22
#include <linux/platform_data/mv_usb.h>
Z
Zhou Zhu 已提交
23 24
#include <linux/spi/spi.h>
#include <linux/delay.h>
25 26 27

#include <asm/mach-types.h>
#include <asm/mach/arch.h>
28
#include <asm/mach/flash.h>
29 30 31
#include <mach/addr-map.h>
#include <mach/mfp-pxa910.h>
#include <mach/pxa910.h>
H
Haojian Zhuang 已提交
32
#include <mach/irqs.h>
33
#include <mach/regs-usb.h>
34 35 36

#include "common.h"

H
Haojian Zhuang 已提交
37
#define TTCDKB_GPIO_EXT0(x)	(MMP_NR_BUILTIN_GPIO + ((x < 0) ? 0 :	\
38
				((x < 16) ? x : 15)))
H
Haojian Zhuang 已提交
39
#define TTCDKB_GPIO_EXT1(x)	(MMP_NR_BUILTIN_GPIO + 16 + ((x < 0) ? 0 : \
40 41 42 43 44 45 46
				((x < 16) ? x : 15)))

/*
 * 16 board interrupts -- MAX7312 GPIO expander
 * 16 board interrupts -- PCA9575 GPIO expander
 * 24 board interrupts -- 88PM860x PMIC
 */
R
Rob Herring 已提交
47
#define TTCDKB_NR_IRQS		(MMP_NR_IRQS + 16 + 16 + 24)
H
Haojian Zhuang 已提交
48

49 50 51 52
static unsigned long ttc_dkb_pin_config[] __initdata = {
	/* UART2 */
	GPIO47_UART2_RXD,
	GPIO48_UART2_TXD,
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

	/* DFI */
	DF_IO0_ND_IO0,
	DF_IO1_ND_IO1,
	DF_IO2_ND_IO2,
	DF_IO3_ND_IO3,
	DF_IO4_ND_IO4,
	DF_IO5_ND_IO5,
	DF_IO6_ND_IO6,
	DF_IO7_ND_IO7,
	DF_IO8_ND_IO8,
	DF_IO9_ND_IO9,
	DF_IO10_ND_IO10,
	DF_IO11_ND_IO11,
	DF_IO12_ND_IO12,
	DF_IO13_ND_IO13,
	DF_IO14_ND_IO14,
	DF_IO15_ND_IO15,
	DF_nCS0_SM_nCS2_nCS0,
	DF_ALE_SM_WEn_ND_ALE,
	DF_CLE_SM_OEn_ND_CLE,
	DF_WEn_DF_WEn,
	DF_REn_DF_REn,
	DF_RDY0_DF_RDY0,
};

79 80 81 82
static struct pxa_gpio_platform_data pxa910_gpio_pdata = {
	.irq_base	= MMP_GPIO_TO_IRQ(0),
};

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
static struct mtd_partition ttc_dkb_onenand_partitions[] = {
	{
		.name		= "bootloader",
		.offset		= 0,
		.size		= SZ_1M,
		.mask_flags	= MTD_WRITEABLE,
	}, {
		.name		= "reserved",
		.offset		= MTDPART_OFS_APPEND,
		.size		= SZ_128K,
		.mask_flags	= MTD_WRITEABLE,
	}, {
		.name		= "reserved",
		.offset		= MTDPART_OFS_APPEND,
		.size		= SZ_8M,
		.mask_flags	= MTD_WRITEABLE,
	}, {
		.name		= "kernel",
		.offset		= MTDPART_OFS_APPEND,
		.size		= (SZ_2M + SZ_1M),
		.mask_flags	= 0,
	}, {
		.name		= "filesystem",
		.offset		= MTDPART_OFS_APPEND,
107
		.size		= SZ_32M + SZ_16M,
108 109 110 111
		.mask_flags	= 0,
	}
};

112
static struct onenand_platform_data ttc_dkb_onenand_info = {
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
	.parts		= ttc_dkb_onenand_partitions,
	.nr_parts	= ARRAY_SIZE(ttc_dkb_onenand_partitions),
};

static struct resource ttc_dkb_resource_onenand[] = {
	[0] = {
		.start	= SMC_CS0_PHYS_BASE,
		.end	= SMC_CS0_PHYS_BASE + SZ_1M,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device ttc_dkb_device_onenand = {
	.name		= "onenand-flash",
	.id		= -1,
	.resource	= ttc_dkb_resource_onenand,
	.num_resources	= ARRAY_SIZE(ttc_dkb_resource_onenand),
	.dev		= {
		.platform_data	= &ttc_dkb_onenand_info,
	},
};

static struct platform_device *ttc_dkb_devices[] = {
136
	&pxa910_device_gpio,
H
Haojian Zhuang 已提交
137
	&pxa910_device_rtc,
138
	&ttc_dkb_device_onenand,
139 140
};

141 142 143
static struct pca953x_platform_data max7312_data[] = {
	{
		.gpio_base	= TTCDKB_GPIO_EXT0(0),
R
Rob Herring 已提交
144
		.irq_base	= MMP_NR_IRQS,
145 146 147
	},
};

C
Chao Xie 已提交
148 149 150 151
static struct pm860x_platform_data ttc_dkb_pm8607_info = {
	.irq_base       = IRQ_BOARD_START,
};

152
static struct i2c_board_info ttc_dkb_i2c_info[] = {
C
Chao Xie 已提交
153 154 155 156 157 158
	{
		.type           = "88PM860x",
		.addr           = 0x34,
		.platform_data  = &ttc_dkb_pm8607_info,
		.irq            = IRQ_PXA910_PMIC_INT,
	},
159 160 161
	{
		.type		= "max7312",
		.addr		= 0x23,
H
Haojian Zhuang 已提交
162
		.irq		= MMP_GPIO_TO_IRQ(80),
163 164 165 166
		.platform_data	= &max7312_data,
	},
};

167 168 169 170 171 172 173 174 175 176 177 178 179 180
#ifdef CONFIG_USB_SUPPORT
#if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O)

static struct mv_usb_platform_data ttc_usb_pdata = {
	.vbus		= NULL,
	.mode		= MV_USB_MODE_OTG,
	.otg_force_a_bus_req = 1,
	.phy_init	= pxa_usb_phy_init,
	.phy_deinit	= pxa_usb_phy_deinit,
	.set_vbus	= NULL,
};
#endif
#endif

L
Lei Wen 已提交
181 182 183 184 185 186 187
#ifdef CONFIG_MTD_NAND_PXA3xx
static struct pxa3xx_nand_platform_data dkb_nand_info = {
	.enable_arbiter = 1,
	.num_cs = 1,
};
#endif

Z
Zhou Zhu 已提交
188 189 190 191 192 193 194 195 196 197 198 199 200
#ifdef CONFIG_MMP_DISP
/* path config */
#define CFG_IOPADMODE(iopad)   (iopad)  /* 0x0 ~ 0xd */
#define SCLK_SOURCE_SELECT(x)  (x << 30) /* 0x0 ~ 0x3 */
/* link config */
#define CFG_DUMBMODE(mode)     (mode << 28) /* 0x0 ~ 0x6*/
static struct mmp_mach_path_config dkb_disp_config[] = {
	[0] = {
		.name = "mmp-parallel",
		.overlay_num = 2,
		.output_type = PATH_OUT_PARALLEL,
		.path_config = CFG_IOPADMODE(0x1)
			| SCLK_SOURCE_SELECT(0x1),
201
		.link_config = CFG_DUMBMODE(0x2),
Z
Zhou Zhu 已提交
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
	},
};

static struct mmp_mach_plat_info dkb_disp_info = {
	.name = "mmp-disp",
	.clk_name = "disp0",
	.path_num = 1,
	.paths = dkb_disp_config,
};

static struct mmp_buffer_driver_mach_info dkb_fb_info = {
	.name = "mmp-fb",
	.path_name = "mmp-parallel",
	.overlay_id = 0,
	.dmafetch_id = 1,
	.default_pixfmt = PIXFMT_RGB565,
};

static void dkb_tpo_panel_power(int on)
{
	int err;
	u32 spi_reset = mfp_to_gpio(MFP_PIN_GPIO106);

	if (on) {
		err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
		if (err) {
			pr_err("failed to request GPIO for TPO LCD RESET\n");
			return;
		}
		gpio_direction_output(spi_reset, 0);
		udelay(100);
		gpio_set_value(spi_reset, 1);
		gpio_free(spi_reset);
	} else {
		err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
		if (err) {
			pr_err("failed to request LCD RESET gpio\n");
			return;
		}
		gpio_set_value(spi_reset, 0);
		gpio_free(spi_reset);
	}
}

static struct mmp_mach_panel_info dkb_tpo_panel_info = {
	.name = "tpo-hvga",
	.plat_path_name = "mmp-parallel",
	.plat_set_onoff = dkb_tpo_panel_power,
};

static struct spi_board_info spi_board_info[] __initdata = {
	{
		.modalias       = "tpo-hvga",
		.platform_data  = &dkb_tpo_panel_info,
		.bus_num        = 5,
	}
};

static void __init add_disp(void)
{
	pxa_register_device(&pxa910_device_disp,
		&dkb_disp_info, sizeof(dkb_disp_info));
	spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
	pxa_register_device(&pxa910_device_fb,
		&dkb_fb_info, sizeof(dkb_fb_info));
	pxa_register_device(&pxa910_device_panel,
		&dkb_tpo_panel_info, sizeof(dkb_tpo_panel_info));
}
#endif

272 273 274 275 276 277
static void __init ttc_dkb_init(void)
{
	mfp_config(ARRAY_AND_SIZE(ttc_dkb_pin_config));

	/* on-chip devices */
	pxa910_add_uart(1);
L
Lei Wen 已提交
278 279 280
#ifdef CONFIG_MTD_NAND_PXA3xx
	pxa910_add_nand(&dkb_nand_info);
#endif
281 282

	/* off-chip devices */
283
	pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
284 285
	platform_device_add_data(&pxa910_device_gpio, &pxa910_gpio_pdata,
				 sizeof(struct pxa_gpio_platform_data));
286
	platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301

#ifdef CONFIG_USB_MV_UDC
	pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
	platform_device_register(&pxa168_device_u2o);
#endif

#ifdef CONFIG_USB_EHCI_MV_U2O
	pxa168_device_u2oehci.dev.platform_data = &ttc_usb_pdata;
	platform_device_register(&pxa168_device_u2oehci);
#endif

#ifdef CONFIG_USB_MV_OTG
	pxa168_device_u2ootg.dev.platform_data = &ttc_usb_pdata;
	platform_device_register(&pxa168_device_u2ootg);
#endif
Z
Zhou Zhu 已提交
302 303 304 305

#ifdef CONFIG_MMP_DISP
	add_disp();
#endif
306 307 308
}

MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform")
309
	.map_io		= mmp_map_io,
H
Haojian Zhuang 已提交
310
	.nr_irqs	= TTCDKB_NR_IRQS,
311
	.init_irq       = pxa910_init_irq,
S
Stephen Warren 已提交
312
	.init_time	= pxa910_timer_init,
313
	.init_machine   = ttc_dkb_init,
314
	.restart	= mmp_restart,
315
MACHINE_END