em-x270.c 20.7 KB
Newer Older
1
/*
M
Mike Rapoport 已提交
2
 * Support for CompuLab EM-X270 platform
3
 *
M
Mike Rapoport 已提交
4
 * Copyright (C) 2007, 2008 CompuLab, Ltd.
5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Author: Mike Rapoport <mike@compulab.co.il>
 *
 * 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
 * published by the Free Software Foundation.
 */

#include <linux/irq.h>
#include <linux/platform_device.h>

#include <linux/dm9000.h>
#include <linux/rtc-v3020.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
19
#include <linux/mtd/physmap.h>
M
Mike Rapoport 已提交
20 21 22
#include <linux/input.h>
#include <linux/gpio_keys.h>
#include <linux/gpio.h>
23 24 25 26 27 28
#include <linux/mfd/da903x.h>
#include <linux/regulator/machine.h>
#include <linux/spi/spi.h>
#include <linux/spi/tdo24m.h>

#include <media/soc_camera.h>
29 30 31 32

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

33 34 35 36 37 38 39 40
#include <mach/mfp-pxa27x.h>
#include <mach/pxa-regs.h>
#include <mach/pxa27x-udc.h>
#include <mach/audio.h>
#include <mach/pxafb.h>
#include <mach/ohci.h>
#include <mach/mmc.h>
#include <mach/pxa27x_keypad.h>
41 42 43
#include <mach/i2c.h>
#include <mach/camera.h>
#include <mach/pxa2xx_spi.h>
44 45

#include "generic.h"
46
#include "devices.h"
47 48

/* GPIO IRQ usage */
M
Mike Rapoport 已提交
49 50 51 52 53 54 55 56
#define GPIO41_ETHIRQ		(41)
#define GPIO13_MMC_CD		(13)
#define EM_X270_ETHIRQ		IRQ_GPIO(GPIO41_ETHIRQ)

/* NAND control GPIOs */
#define GPIO11_NAND_CS	(11)
#define GPIO56_NAND_RB	(56)

57 58
/* Miscelaneous GPIOs */
#define GPIO93_CAM_RESET	(93)
59
#define GPIO95_MMC_WP		(95)
60

M
Mike Rapoport 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
static unsigned long em_x270_pin_config[] = {
	/* AC'97 */
	GPIO28_AC97_BITCLK,
	GPIO29_AC97_SDATA_IN_0,
	GPIO30_AC97_SDATA_OUT,
	GPIO31_AC97_SYNC,
	GPIO98_AC97_SYSCLK,
	GPIO113_AC97_nRESET,

	/* BTUART */
	GPIO42_BTUART_RXD,
	GPIO43_BTUART_TXD,
	GPIO44_BTUART_CTS,
	GPIO45_BTUART_RTS,

	/* STUART */
	GPIO46_STUART_RXD,
	GPIO47_STUART_TXD,

	/* MCI controller */
	GPIO32_MMC_CLK,
	GPIO112_MMC_CMD,
	GPIO92_MMC_DAT_0,
	GPIO109_MMC_DAT_1,
	GPIO110_MMC_DAT_2,
	GPIO111_MMC_DAT_3,

	/* LCD */
	GPIO58_LCD_LDD_0,
	GPIO59_LCD_LDD_1,
	GPIO60_LCD_LDD_2,
	GPIO61_LCD_LDD_3,
	GPIO62_LCD_LDD_4,
	GPIO63_LCD_LDD_5,
	GPIO64_LCD_LDD_6,
	GPIO65_LCD_LDD_7,
	GPIO66_LCD_LDD_8,
	GPIO67_LCD_LDD_9,
	GPIO68_LCD_LDD_10,
	GPIO69_LCD_LDD_11,
	GPIO70_LCD_LDD_12,
	GPIO71_LCD_LDD_13,
	GPIO72_LCD_LDD_14,
	GPIO73_LCD_LDD_15,
	GPIO74_LCD_FCLK,
	GPIO75_LCD_LCLK,
	GPIO76_LCD_PCLK,
	GPIO77_LCD_BIAS,

	/* QCI */
	GPIO84_CIF_FV,
	GPIO25_CIF_LV,
	GPIO53_CIF_MCLK,
	GPIO54_CIF_PCLK,
	GPIO81_CIF_DD_0,
	GPIO55_CIF_DD_1,
	GPIO51_CIF_DD_2,
	GPIO50_CIF_DD_3,
	GPIO52_CIF_DD_4,
	GPIO48_CIF_DD_5,
	GPIO17_CIF_DD_6,
	GPIO12_CIF_DD_7,

	/* I2C */
	GPIO117_I2C_SCL,
	GPIO118_I2C_SDA,

	/* Keypad */
	GPIO100_KP_MKIN_0	| WAKEUP_ON_LEVEL_HIGH,
	GPIO101_KP_MKIN_1	| WAKEUP_ON_LEVEL_HIGH,
	GPIO102_KP_MKIN_2	| WAKEUP_ON_LEVEL_HIGH,
	GPIO34_KP_MKIN_3	| WAKEUP_ON_LEVEL_HIGH,
	GPIO39_KP_MKIN_4	| WAKEUP_ON_LEVEL_HIGH,
	GPIO99_KP_MKIN_5	| WAKEUP_ON_LEVEL_HIGH,
	GPIO91_KP_MKIN_6	| WAKEUP_ON_LEVEL_HIGH,
	GPIO36_KP_MKIN_7	| WAKEUP_ON_LEVEL_HIGH,
	GPIO103_KP_MKOUT_0,
	GPIO104_KP_MKOUT_1,
	GPIO105_KP_MKOUT_2,
	GPIO106_KP_MKOUT_3,
	GPIO107_KP_MKOUT_4,
	GPIO108_KP_MKOUT_5,
	GPIO96_KP_MKOUT_6,
	GPIO22_KP_MKOUT_7,

	/* SSP1 */
	GPIO26_SSP1_RXD,
	GPIO23_SSP1_SCLK,
	GPIO24_SSP1_SFRM,
	GPIO57_SSP1_TXD,

	/* SSP2 */
	GPIO19_SSP2_SCLK,
	GPIO14_SSP2_SFRM,
	GPIO89_SSP2_TXD,
	GPIO88_SSP2_RXD,

	/* SDRAM and local bus */
	GPIO15_nCS_1,
	GPIO78_nCS_2,
	GPIO79_nCS_3,
	GPIO80_nCS_4,
	GPIO49_nPWE,
	GPIO18_RDY,

	/* GPIO */
167 168
	GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,	/* sleep/resume button */
	GPIO95_GPIO,				/* MMC Write protect */
M
Mike Rapoport 已提交
169 170 171

	/* power controls */
	GPIO20_GPIO	| MFP_LPM_DRIVE_LOW,	/* GPRS_PWEN */
172
	GPIO93_GPIO	| MFP_LPM_DRIVE_LOW,	/* Camera reset */
M
Mike Rapoport 已提交
173 174 175 176 177 178 179 180 181 182
	GPIO115_GPIO	| MFP_LPM_DRIVE_LOW,	/* WLAN_PWEN */

	/* NAND controls */
	GPIO11_GPIO	| MFP_LPM_DRIVE_HIGH,	/* NAND CE# */
	GPIO56_GPIO,				/* NAND Ready/Busy */

	/* interrupts */
	GPIO13_GPIO,	/* MMC card detect */
	GPIO41_GPIO,	/* DM9000 interrupt */
};
183

M
Mike Rapoport 已提交
184 185
#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
static struct resource em_x270_dm9000_resource[] = {
186 187 188 189 190 191 192 193 194 195 196 197 198
	[0] = {
		.start = PXA_CS2_PHYS,
		.end   = PXA_CS2_PHYS + 3,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = PXA_CS2_PHYS + 8,
		.end   = PXA_CS2_PHYS + 8 + 0x3f,
		.flags = IORESOURCE_MEM,
	},
	[2] = {
		.start = EM_X270_ETHIRQ,
		.end   = EM_X270_ETHIRQ,
M
Mike Rapoport 已提交
199
		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
200 201 202
	}
};

M
Mike Rapoport 已提交
203
static struct dm9000_plat_data em_x270_dm9000_platdata = {
204 205 206
	.flags		= DM9000_PLATF_32BITONLY,
};

M
Mike Rapoport 已提交
207
static struct platform_device em_x270_dm9000 = {
208 209
	.name		= "dm9000",
	.id		= 0,
M
Mike Rapoport 已提交
210 211
	.num_resources	= ARRAY_SIZE(em_x270_dm9000_resource),
	.resource	= em_x270_dm9000_resource,
212
	.dev		= {
M
Mike Rapoport 已提交
213
		.platform_data = &em_x270_dm9000_platdata,
214 215 216
	}
};

M
Mike Rapoport 已提交
217 218 219 220 221 222 223
static void __init em_x270_init_dm9000(void)
{
	platform_device_register(&em_x270_dm9000);
}
#else
static inline void em_x270_init_dm9000(void) {}
#endif
224

M
Mike Rapoport 已提交
225 226
/* V3020 RTC */
#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
static struct resource em_x270_v3020_resource[] = {
	[0] = {
		.start = PXA_CS4_PHYS,
		.end   = PXA_CS4_PHYS + 3,
		.flags = IORESOURCE_MEM,
	},
};

static struct v3020_platform_data em_x270_v3020_platdata = {
	.leftshift = 0,
};

static struct platform_device em_x270_rtc = {
	.name		= "v3020",
	.num_resources	= ARRAY_SIZE(em_x270_v3020_resource),
	.resource	= em_x270_v3020_resource,
	.id		= -1,
	.dev		= {
		.platform_data = &em_x270_v3020_platdata,
	}
};

M
Mike Rapoport 已提交
249 250 251 252 253 254 255
static void __init em_x270_init_rtc(void)
{
	platform_device_register(&em_x270_rtc);
}
#else
static inline void em_x270_init_rtc(void) {}
#endif
256

M
Mike Rapoport 已提交
257 258
/* NAND flash */
#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
259 260
static inline void nand_cs_on(void)
{
M
Mike Rapoport 已提交
261
	gpio_set_value(GPIO11_NAND_CS, 0);
262 263 264 265 266 267
}

static void nand_cs_off(void)
{
	dsb();

M
Mike Rapoport 已提交
268
	gpio_set_value(GPIO11_NAND_CS, 1);
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
}

/* hardware specific access to control-lines */
static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
				 unsigned int ctrl)
{
	struct nand_chip *this = mtd->priv;
	unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;

	dsb();

	if (ctrl & NAND_CTRL_CHANGE) {
		if (ctrl & NAND_ALE)
			nandaddr |=  (1 << 3);
		else
			nandaddr &= ~(1 << 3);
		if (ctrl & NAND_CLE)
			nandaddr |=  (1 << 2);
		else
			nandaddr &= ~(1 << 2);
		if (ctrl & NAND_NCE)
			nand_cs_on();
		else
			nand_cs_off();
	}

	dsb();
	this->IO_ADDR_W = (void __iomem *)nandaddr;
	if (dat != NAND_CMD_NONE)
		writel(dat, this->IO_ADDR_W);

	dsb();
}

/* read device ready pin */
static int em_x270_nand_device_ready(struct mtd_info *mtd)
{
	dsb();

M
Mike Rapoport 已提交
308
	return gpio_get_value(GPIO56_NAND_RB);
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
}

static struct mtd_partition em_x270_partition_info[] = {
	[0] = {
		.name	= "em_x270-0",
		.offset	= 0,
		.size	= SZ_4M,
	},
	[1] = {
		.name	= "em_x270-1",
		.offset	= MTDPART_OFS_APPEND,
		.size	= MTDPART_SIZ_FULL
	},
};

static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };

struct platform_nand_data em_x270_nand_platdata = {
	.chip = {
		.nr_chips = 1,
		.chip_offset = 0,
		.nr_partitions = ARRAY_SIZE(em_x270_partition_info),
		.partitions = em_x270_partition_info,
		.chip_delay = 20,
		.part_probe_types = em_x270_part_probes,
	},
	.ctrl = {
		.hwcontrol = 0,
		.dev_ready = em_x270_nand_device_ready,
		.select_chip = 0,
		.cmd_ctrl = em_x270_nand_cmd_ctl,
	},
};

static struct resource em_x270_nand_resource[] = {
	[0] = {
		.start = PXA_CS1_PHYS,
		.end   = PXA_CS1_PHYS + 12,
		.flags = IORESOURCE_MEM,
	},
};

static struct platform_device em_x270_nand = {
	.name		= "gen_nand",
	.num_resources	= ARRAY_SIZE(em_x270_nand_resource),
	.resource	= em_x270_nand_resource,
	.id		= -1,
	.dev		= {
		.platform_data = &em_x270_nand_platdata,
	}
};

M
Mike Rapoport 已提交
361 362 363
static void __init em_x270_init_nand(void)
{
	int err;
364

M
Mike Rapoport 已提交
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
	err = gpio_request(GPIO11_NAND_CS, "NAND CS");
	if (err) {
		pr_warning("EM-X270: failed to request NAND CS gpio\n");
		return;
	}

	gpio_direction_output(GPIO11_NAND_CS, 1);

	err = gpio_request(GPIO56_NAND_RB, "NAND R/B");
	if (err) {
		pr_warning("EM-X270: failed to request NAND R/B gpio\n");
		gpio_free(GPIO11_NAND_CS);
		return;
	}

	gpio_direction_input(GPIO56_NAND_RB);

	platform_device_register(&em_x270_nand);
}
#else
static inline void em_x270_init_nand(void) {}
#endif
387

388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
static struct mtd_partition em_x270_nor_parts[] = {
	{
		.name =		"Bootloader",
		.offset =	0x00000000,
		.size =		0x00050000,
		.mask_flags =	MTD_WRITEABLE  /* force read-only */
	}, {
		.name =		"Environment",
		.offset =	0x00050000,
		.size =		0x00010000,
	}, {
		.name =		"Reserved",
		.offset =	0x00060000,
		.size =		0x00050000,
		.mask_flags =	MTD_WRITEABLE  /* force read-only */
	}, {
		.name =		"Splashscreen",
		.offset =	0x000b0000,
		.size =		0x00050000,
	}
};

static struct physmap_flash_data em_x270_nor_data[] = {
	[0] = {
		.width = 2,
		.parts = em_x270_nor_parts,
		.nr_parts = ARRAY_SIZE(em_x270_nor_parts),
	},
};

static struct resource em_x270_nor_flash_resource = {
	.start	= PXA_CS0_PHYS,
	.end	= PXA_CS0_PHYS + SZ_1M - 1,
	.flags	= IORESOURCE_MEM,
};

static struct platform_device em_x270_physmap_flash = {
	.name		= "physmap-flash",
	.id		= 0,
	.num_resources	= 1,
	.resource	= &em_x270_nor_flash_resource,
	.dev		= {
		.platform_data	= &em_x270_nor_data,
	},
};

static void __init em_x270_init_nor(void)
{
	platform_device_register(&em_x270_physmap_flash);
}
#else
static inline void em_x270_init_nor(void) {}
#endif

443
/* PXA27x OHCI controller setup */
M
Mike Rapoport 已提交
444
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
445 446 447 448 449 450 451 452 453 454
static int em_x270_ohci_init(struct device *dev)
{
	/* enable port 2 transiever */
	UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;

	return 0;
}

static struct pxaohci_platform_data em_x270_ohci_platform_data = {
	.port_mode	= PMM_PERPORT_MODE,
455
	.flags		= ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
456 457 458
	.init		= em_x270_ohci_init,
};

M
Mike Rapoport 已提交
459 460 461 462 463 464 465
static void __init em_x270_init_ohci(void)
{
	pxa_set_ohci_info(&em_x270_ohci_platform_data);
}
#else
static inline void em_x270_init_ohci(void) {}
#endif
466

M
Mike Rapoport 已提交
467 468
/* MCI controller setup */
#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
469 470
static struct regulator *em_x270_sdio_ldo;

471 472 473 474
static int em_x270_mci_init(struct device *dev,
			    irq_handler_t em_x270_detect_int,
			    void *data)
{
475 476 477 478 479 480 481 482 483 484 485 486
	int err;

	em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
	if (IS_ERR(em_x270_sdio_ldo)) {
		dev_err(dev, "can't request SDIO power supply: %ld\n",
			PTR_ERR(em_x270_sdio_ldo));
		return PTR_ERR(em_x270_sdio_ldo);
	}

	err = request_irq(gpio_to_irq(GPIO13_MMC_CD), em_x270_detect_int,
			      IRQF_DISABLED | IRQF_TRIGGER_RISING |
			      IRQF_TRIGGER_FALLING,
M
Mike Rapoport 已提交
487
			      "MMC card detect", data);
488
	if (err) {
489 490 491 492 493 494 495 496
		dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
		goto err_irq;
	}

	err = gpio_request(GPIO95_MMC_WP, "MMC WP");
	if (err) {
		dev_err(dev, "can't request MMC write protect: %d\n", err);
		goto err_gpio_wp;
497 498
	}

499 500
	gpio_direction_input(GPIO95_MMC_WP);

501
	return 0;
502 503 504 505 506 507 508

err_gpio_wp:
	free_irq(gpio_to_irq(GPIO13_MMC_CD), data);
err_irq:
	regulator_put(em_x270_sdio_ldo);

	return err;
509 510 511 512
}

static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
{
513 514 515 516 517 518 519 520 521 522
	struct pxamci_platform_data* p_d = dev->platform_data;

	if ((1 << vdd) & p_d->ocr_mask) {
		int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;

		regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
		regulator_enable(em_x270_sdio_ldo);
	} else {
		regulator_disable(em_x270_sdio_ldo);
	}
523 524 525 526
}

static void em_x270_mci_exit(struct device *dev, void *data)
{
527 528 529 530 531 532
	free_irq(gpio_to_irq(GPIO13_MMC_CD), data);
}

static int em_x270_mci_get_ro(struct device *dev)
{
	return gpio_get_value(GPIO95_MMC_WP);
533 534 535
}

static struct pxamci_platform_data em_x270_mci_platform_data = {
536 537 538 539
	.ocr_mask	= MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
			  MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
			  MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
			  MMC_VDD_30_31|MMC_VDD_31_32,
540 541
	.init 		= em_x270_mci_init,
	.setpower 	= em_x270_mci_setpower,
542
	.get_ro		= em_x270_mci_get_ro,
543 544 545
	.exit		= em_x270_mci_exit,
};

M
Mike Rapoport 已提交
546 547
static void __init em_x270_init_mmc(void)
{
548
	em_x270_mci_platform_data.detect_delay	= msecs_to_jiffies(250);
M
Mike Rapoport 已提交
549 550 551 552 553 554
	pxa_set_mci_info(&em_x270_mci_platform_data);
}
#else
static inline void em_x270_init_mmc(void) {}
#endif

555
/* LCD */
M
Mike Rapoport 已提交
556
#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
static struct pxafb_mode_info em_x270_lcd_modes[] = {
	[0] = {
		.pixclock	= 38250,
		.bpp		= 16,
		.xres		= 480,
		.yres		= 640,
		.hsync_len	= 8,
		.vsync_len	= 2,
		.left_margin	= 8,
		.upper_margin	= 2,
		.right_margin	= 24,
		.lower_margin	= 4,
		.sync		= 0,
	},
	[1] = {
		.pixclock       = 153800,
		.bpp		= 16,
		.xres		= 240,
		.yres		= 320,
		.hsync_len	= 8,
		.vsync_len	= 2,
		.left_margin	= 8,
		.upper_margin	= 2,
		.right_margin	= 88,
		.lower_margin	= 2,
		.sync		= 0,
	},
584 585 586
};

static struct pxafb_mach_info em_x270_lcd = {
587 588
	.modes		= em_x270_lcd_modes,
	.num_modes	= 2,
M
Mike Rapoport 已提交
589
	.lcd_conn	= LCD_COLOR_TFT_16BPP,
590
};
591

M
Mike Rapoport 已提交
592
static void __init em_x270_init_lcd(void)
593 594
{
	set_pxa_fb_info(&em_x270_lcd);
M
Mike Rapoport 已提交
595 596 597 598
}
#else
static inline void em_x270_init_lcd(void) {}
#endif
599

600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
static struct pxa2xx_spi_master em_x270_spi_info = {
	.num_chipselect	= 1,
};

static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
	.rx_threshold = 1,
	.tx_threshold = 1,
};

static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
	.model = TDO35S,
};

static struct spi_board_info em_x270_spi_devices[] __initdata = {
	{
		.modalias = "tdo24m",
		.max_speed_hz = 1000000,
		.bus_num = 1,
		.chip_select = 0,
		.controller_data = &em_x270_tdo24m_chip,
		.platform_data = &em_x270_tdo24m_pdata,
	},
};

static void __init em_x270_init_spi(void)
{
	pxa2xx_set_spi_info(1, &em_x270_spi_info);
	spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
}
#else
static inline void em_x270_init_spi(void) {}
#endif

M
Mike Rapoport 已提交
634 635 636
#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
static void __init em_x270_init_ac97(void)
{
637
	pxa_set_ac97_info(NULL);
M
Mike Rapoport 已提交
638 639 640 641 642 643 644 645 646 647 648
}
#else
static inline void em_x270_init_ac97(void) {}
#endif

#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
static unsigned int em_x270_matrix_keys[] = {
	KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
	KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
	KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
};
649

M
Mike Rapoport 已提交
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
struct pxa27x_keypad_platform_data em_x270_keypad_info = {
	/* code map for the matrix keys */
	.matrix_key_rows	= 3,
	.matrix_key_cols	= 3,
	.matrix_key_map		= em_x270_matrix_keys,
	.matrix_key_map_size	= ARRAY_SIZE(em_x270_matrix_keys),
};

static void __init em_x270_init_keypad(void)
{
	pxa_set_keypad_info(&em_x270_keypad_info);
}
#else
static inline void em_x270_init_keypad(void) {}
#endif
665

M
Mike Rapoport 已提交
666 667 668 669 670 671 672 673 674 675
#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
static struct gpio_keys_button gpio_keys_button[] = {
	[0] = {
		.desc	= "sleep/wakeup",
		.code	= KEY_SUSPEND,
		.type	= EV_PWR,
		.gpio	= 1,
		.wakeup	= 1,
	},
};
676

M
Mike Rapoport 已提交
677 678 679 680
static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
	.buttons	= gpio_keys_button,
	.nbuttons	= 1,
};
681

M
Mike Rapoport 已提交
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
static struct platform_device em_x270_gpio_keys = {
	.name		= "gpio-keys",
	.id		= -1,
	.dev		= {
		.platform_data	= &em_x270_gpio_keys_data,
	},
};

static void __init em_x270_init_gpio_keys(void)
{
	platform_device_register(&em_x270_gpio_keys);
}
#else
static inline void em_x270_init_gpio_keys(void) {}
#endif

698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800
/* Quick Capture Interface and sensor setup */
#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
static struct regulator *em_x270_camera_ldo;

static int em_x270_sensor_init(struct device *dev)
{
	int ret;

	ret = gpio_request(GPIO93_CAM_RESET, "camera reset");
	if (ret)
		return ret;

	gpio_direction_output(GPIO93_CAM_RESET, 0);

	em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
	if (em_x270_camera_ldo == NULL) {
		gpio_free(GPIO93_CAM_RESET);
		return -ENODEV;
	}

	ret = regulator_enable(em_x270_camera_ldo);
	if (ret) {
		regulator_put(em_x270_camera_ldo);
		gpio_free(GPIO93_CAM_RESET);
		return ret;
	}

	gpio_set_value(GPIO93_CAM_RESET, 1);

	return 0;
}

struct pxacamera_platform_data em_x270_camera_platform_data = {
	.init	= em_x270_sensor_init,
	.flags  = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
		PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
	.mclk_10khz = 2600,
};

static int em_x270_sensor_power(struct device *dev, int on)
{
	int ret;
	int is_on = regulator_is_enabled(em_x270_camera_ldo);

	if (on == is_on)
		return 0;

	gpio_set_value(GPIO93_CAM_RESET, !on);

	if (on)
		ret = regulator_enable(em_x270_camera_ldo);
	else
		ret = regulator_disable(em_x270_camera_ldo);

	if (ret)
		return ret;

	gpio_set_value(GPIO93_CAM_RESET, on);

	return 0;
}

static struct soc_camera_link iclink = {
	.bus_id	= 0,
	.power = em_x270_sensor_power,
};

static struct i2c_board_info em_x270_i2c_cam_info[] = {
	{
		I2C_BOARD_INFO("mt9m111", 0x48),
		.platform_data = &iclink,
	},
};

static struct i2c_pxa_platform_data em_x270_i2c_info = {
	.fast_mode = 1,
};

static void  __init em_x270_init_camera(void)
{
	pxa_set_i2c_info(&em_x270_i2c_info);
	i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
	pxa_set_camera_info(&em_x270_camera_platform_data);
}
#else
static inline void em_x270_init_camera(void) {}
#endif

/* DA9030 related initializations */
static struct regulator_consumer_supply ldo3_consumers[] = {
	{
		.dev = NULL,
		.supply = "vcc gps",
	},
};

static struct regulator_consumer_supply ldo5_consumers[] = {
	{
		.dev = NULL,
		.supply = "vcc cam",
	},
};

801 802 803 804 805 806 807
static struct regulator_consumer_supply ldo10_consumers[] = {
	{
		.dev = &pxa_device_mci.dev,
		.supply = "vcc sdio",
	},
};

808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845
static struct regulator_consumer_supply ldo12_consumers[] = {
	{
		.dev = NULL,
		.supply = "vcc usb",
	},
};

static struct regulator_consumer_supply ldo19_consumers[] = {
	{
		.dev = NULL,
		.supply = "vcc gprs",
	},
};

static struct regulator_init_data ldo3_data = {
	.constraints = {
		.min_uV = 3200000,
		.max_uV = 3200000,
		.state_mem = {
			.enabled = 0,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
	.consumer_supplies = ldo3_consumers,
};

static struct regulator_init_data ldo5_data = {
	.constraints = {
		.min_uV = 3000000,
		.max_uV = 3000000,
		.state_mem = {
			.enabled = 0,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
	.consumer_supplies = ldo5_consumers,
};

846 847 848 849 850 851 852 853 854 855 856 857 858
static struct regulator_init_data ldo10_data = {
	.constraints = {
		.min_uV = 2000000,
		.max_uV = 3200000,
		.state_mem = {
			.enabled = 0,
		},
		.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS,
	},
	.num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
	.consumer_supplies = ldo10_consumers,
};

859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896
static struct regulator_init_data ldo12_data = {
	.constraints = {
		.min_uV = 3000000,
		.max_uV = 3000000,
		.state_mem = {
			.enabled = 0,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(ldo12_consumers),
	.consumer_supplies = ldo12_consumers,
};

static struct regulator_init_data ldo19_data = {
	.constraints = {
		.min_uV = 3200000,
		.max_uV = 3200000,
		.state_mem = {
			.enabled = 0,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(ldo19_consumers),
	.consumer_supplies = ldo19_consumers,
};

struct led_info em_x270_led_info = {
	.name = "em-x270:orange",
	.default_trigger = "battery-charging-or-full",
};

struct da903x_subdev_info em_x270_da9030_subdevs[] = {
	{
		.name = "da903x-regulator",
		.id = DA9030_ID_LDO3,
		.platform_data = &ldo3_data,
	}, {
		.name = "da903x-regulator",
		.id = DA9030_ID_LDO5,
		.platform_data = &ldo5_data,
897 898 899 900
	}, {
		.name = "da903x-regulator",
		.id = DA9030_ID_LDO10,
		.platform_data = &ldo10_data,
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
	}, {
		.name = "da903x-regulator",
		.id = DA9030_ID_LDO12,
		.platform_data = &ldo12_data,
	}, {
		.name = "da903x-regulator",
		.id = DA9030_ID_LDO19,
		.platform_data = &ldo19_data,
	}, {
		.name = "da903x-led",
		.id = DA9030_ID_LED_PC,
		.platform_data = &em_x270_led_info,
	}, {
		.name = "da903x-backlight",
		.id = DA9030_ID_WLED,
	}
};

static struct da903x_platform_data em_x270_da9030_info = {
	.num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
	.subdevs = em_x270_da9030_subdevs,
};

static struct i2c_board_info em_x270_i2c_pmic_info = {
	I2C_BOARD_INFO("da9030", 0x49),
	.irq = IRQ_GPIO(0),
	.platform_data = &em_x270_da9030_info,
};

static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
	.use_pio = 1,
};

static void __init em_x270_init_da9030(void)
{
	pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
	i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
}

M
Mike Rapoport 已提交
940 941 942 943
static void __init em_x270_init(void)
{
	pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));

944
	em_x270_init_da9030();
M
Mike Rapoport 已提交
945 946 947
	em_x270_init_dm9000();
	em_x270_init_rtc();
	em_x270_init_nand();
948
	em_x270_init_nor();
M
Mike Rapoport 已提交
949 950 951 952 953 954
	em_x270_init_lcd();
	em_x270_init_mmc();
	em_x270_init_ohci();
	em_x270_init_keypad();
	em_x270_init_gpio_keys();
	em_x270_init_ac97();
955 956
	em_x270_init_camera();
	em_x270_init_spi();
957 958
}

M
Mike Rapoport 已提交
959
MACHINE_START(EM_X270, "Compulab EM-X270")
960 961 962 963 964 965 966 967
	.boot_params	= 0xa0000100,
	.phys_io	= 0x40000000,
	.io_pg_offst	= (io_p2v(0x40000000) >> 18) & 0xfffc,
	.map_io		= pxa_map_io,
	.init_irq	= pxa27x_init_irq,
	.timer		= &pxa_timer,
	.init_machine	= em_x270_init,
MACHINE_END