cm-x300.c 18.8 KB
Newer Older
1 2 3 4 5
/*
 * linux/arch/arm/mach-pxa/cm-x300.c
 *
 * Support for the CompuLab CM-X300 modules
 *
6
 * Copyright (C) 2008,2009 CompuLab Ltd.
7 8
 *
 * Mike Rapoport <mike@compulab.co.il>
9
 * Igor Grinberg <grinberg@compulab.co.il>
10 11 12 13 14
 *
 * 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.
 */
15
#define pr_fmt(fmt) "%s: " fmt, __func__
16 17 18 19 20

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/init.h>
21
#include <linux/delay.h>
22
#include <linux/platform_device.h>
23
#include <linux/clk.h>
24 25 26 27

#include <linux/gpio.h>
#include <linux/dm9000.h>
#include <linux/leds.h>
28
#include <linux/rtc-v3020.h>
29
#include <linux/pwm_backlight.h>
30 31 32

#include <linux/i2c.h>
#include <linux/i2c/pca953x.h>
33
#include <linux/i2c/pxa-i2c.h>
34

35
#include <linux/mfd/da903x.h>
36
#include <linux/regulator/machine.h>
37 38
#include <linux/power_supply.h>
#include <linux/apm-emulation.h>
39

40 41 42 43
#include <linux/spi/spi.h>
#include <linux/spi/spi_gpio.h>
#include <linux/spi/tdo24m.h>

44 45
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
46
#include <asm/setup.h>
47

48
#include <mach/pxa300.h>
49
#include <mach/pxa27x-udc.h>
50 51 52
#include <mach/pxafb.h>
#include <mach/mmc.h>
#include <mach/ohci.h>
53
#include <plat/pxa3xx_nand.h>
54
#include <mach/audio.h>
55
#include <mach/pxa3xx-u2d.h>
56 57 58 59

#include <asm/mach/map.h>

#include "generic.h"
60
#include "devices.h"
61 62 63

#define CM_X300_ETH_PHYS	0x08000010

64 65
#define GPIO82_MMC_IRQ		(82)
#define GPIO85_MMC_WP		(85)
66

67
#define	CM_X300_MMC_IRQ		IRQ_GPIO(GPIO82_MMC_IRQ)
68

69 70 71 72 73
#define GPIO95_RTC_CS		(95)
#define GPIO96_RTC_WR		(96)
#define GPIO97_RTC_RD		(97)
#define GPIO98_RTC_IO		(98)

74 75
#define GPIO_ULPI_PHY_RST	(127)

76
static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
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
	/* LCD */
	GPIO54_LCD_LDD_0,
	GPIO55_LCD_LDD_1,
	GPIO56_LCD_LDD_2,
	GPIO57_LCD_LDD_3,
	GPIO58_LCD_LDD_4,
	GPIO59_LCD_LDD_5,
	GPIO60_LCD_LDD_6,
	GPIO61_LCD_LDD_7,
	GPIO62_LCD_LDD_8,
	GPIO63_LCD_LDD_9,
	GPIO64_LCD_LDD_10,
	GPIO65_LCD_LDD_11,
	GPIO66_LCD_LDD_12,
	GPIO67_LCD_LDD_13,
	GPIO68_LCD_LDD_14,
	GPIO69_LCD_LDD_15,
	GPIO72_LCD_FCLK,
	GPIO73_LCD_LCLK,
	GPIO74_LCD_PCLK,
	GPIO75_LCD_BIAS,

	/* BTUART */
	GPIO111_UART2_RTS,
	GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
	GPIO113_UART2_TXD,
	GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,

	/* STUART */
	GPIO109_UART3_TXD,
	GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,

	/* AC97 */
	GPIO23_AC97_nACRESET,
	GPIO24_AC97_SYSCLK,
	GPIO29_AC97_BITCLK,
	GPIO25_AC97_SDATA_IN_0,
	GPIO27_AC97_SDATA_OUT,
	GPIO28_AC97_SYNC,

	/* Keypad */
	GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
	GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
	GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
	GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
	GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
	GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
	GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
	GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
	GPIO121_KP_MKOUT_0,
	GPIO122_KP_MKOUT_1,
	GPIO123_KP_MKOUT_2,
	GPIO124_KP_MKOUT_3,
	GPIO125_KP_MKOUT_4,
	GPIO4_2_KP_MKOUT_5,

	/* MMC1 */
	GPIO3_MMC1_DAT0,
	GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
	GPIO5_MMC1_DAT2,
	GPIO6_MMC1_DAT3,
	GPIO7_MMC1_CLK,
	GPIO8_MMC1_CMD,	/* CMD0 for slot 0 */

	/* MMC2 */
	GPIO9_MMC2_DAT0,
	GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
	GPIO11_MMC2_DAT2,
	GPIO12_MMC2_DAT3,
	GPIO13_MMC2_CLK,
	GPIO14_MMC2_CMD,

	/* FFUART */
	GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
	GPIO31_UART1_TXD,
	GPIO32_UART1_CTS,
	GPIO37_UART1_RTS,
	GPIO33_UART1_DCD,
	GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
	GPIO35_UART1_RI,
	GPIO36_UART1_DTR,

	/* GPIOs */
	GPIO82_GPIO | MFP_PULL_HIGH,	/* MMC CD */
	GPIO85_GPIO,			/* MMC WP */
	GPIO99_GPIO,			/* Ethernet IRQ */
163

164
	/* RTC GPIOs */
165 166 167 168
	GPIO95_GPIO | MFP_LPM_DRIVE_HIGH,	/* RTC CS */
	GPIO96_GPIO | MFP_LPM_DRIVE_HIGH,	/* RTC WR */
	GPIO97_GPIO | MFP_LPM_DRIVE_HIGH,	/* RTC RD */
	GPIO98_GPIO,				/* RTC IO */
169

170 171 172
	/* Standard I2C */
	GPIO21_I2C_SCL,
	GPIO22_I2C_SDA,
173 174 175

	/* PWM Backlight */
	GPIO19_PWM2_OUT,
176 177
};

178
static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
179 180 181 182 183 184
	/* GPIOs */
	GPIO79_GPIO,			/* LED */
	GPIO77_GPIO,			/* WiFi reset */
	GPIO78_GPIO,			/* BT reset */
};

185
static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
186 187 188 189 190 191
	/* GPIOs */
	GPIO76_GPIO,			/* LED */
	GPIO71_GPIO,			/* WiFi reset */
	GPIO70_GPIO,			/* BT reset */
};

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
	/* USB PORT 2 */
	ULPI_STP,
	ULPI_NXT,
	ULPI_DIR,
	GPIO30_ULPI_DATA_OUT_0,
	GPIO31_ULPI_DATA_OUT_1,
	GPIO32_ULPI_DATA_OUT_2,
	GPIO33_ULPI_DATA_OUT_3,
	GPIO34_ULPI_DATA_OUT_4,
	GPIO35_ULPI_DATA_OUT_5,
	GPIO36_ULPI_DATA_OUT_6,
	GPIO37_ULPI_DATA_OUT_7,
	GPIO38_ULPI_CLK,
	/* external PHY reset pin */
	GPIO127_GPIO,

	/* USB PORT 3 */
	GPIO77_USB_P3_1,
	GPIO78_USB_P3_2,
	GPIO79_USB_P3_3,
	GPIO80_USB_P3_4,
	GPIO81_USB_P3_5,
	GPIO82_USB_P3_6,
	GPIO0_2_USBH_PEN,
};

219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
static struct resource dm9000_resources[] = {
	[0] = {
		.start	= CM_X300_ETH_PHYS,
		.end	= CM_X300_ETH_PHYS + 0x3,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= CM_X300_ETH_PHYS + 0x4,
		.end	= CM_X300_ETH_PHYS + 0x4 + 500,
		.flags	= IORESOURCE_MEM,
	},
	[2] = {
		.start	= IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
		.end	= IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
	}
};

static struct dm9000_plat_data cm_x300_dm9000_platdata = {
239
	.flags		= DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
};

static struct platform_device dm9000_device = {
	.name		= "dm9000",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(dm9000_resources),
	.resource	= dm9000_resources,
	.dev		= {
		.platform_data = &cm_x300_dm9000_platdata,
	}

};

static void __init cm_x300_init_dm9000(void)
{
	platform_device_register(&dm9000_device);
}
#else
static inline void cm_x300_init_dm9000(void) {}
#endif

261
/* LCD */
262 263 264
#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
static struct pxafb_mode_info cm_x300_lcd_modes[] = {
	[0] = {
265
		.pixclock	= 38250,
266 267 268 269 270 271
		.bpp		= 16,
		.xres		= 480,
		.yres		= 640,
		.hsync_len	= 8,
		.vsync_len	= 2,
		.left_margin	= 8,
272
		.upper_margin	= 2,
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
		.right_margin	= 24,
		.lower_margin	= 4,
		.cmap_greyscale	= 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,
		.cmap_greyscale	= 0,
	},
};

static struct pxafb_mach_info cm_x300_lcd = {
	.modes			= cm_x300_lcd_modes,
294
	.num_modes		= ARRAY_SIZE(cm_x300_lcd_modes),
295 296 297 298 299
	.lcd_conn		= LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
};

static void __init cm_x300_init_lcd(void)
{
300
	pxa_set_fb_info(NULL, &cm_x300_lcd);
301 302 303 304 305
}
#else
static inline void cm_x300_init_lcd(void) {}
#endif

306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
static struct platform_pwm_backlight_data cm_x300_backlight_data = {
	.pwm_id		= 2,
	.max_brightness	= 100,
	.dft_brightness	= 100,
	.pwm_period_ns	= 10000,
};

static struct platform_device cm_x300_backlight_device = {
	.name		= "pwm-backlight",
	.dev		= {
		.parent = &pxa27x_device_pwm0.dev,
		.platform_data	= &cm_x300_backlight_data,
	},
};

static void cm_x300_init_bl(void)
{
	platform_device_register(&cm_x300_backlight_device);
}
#else
static inline void cm_x300_init_bl(void) {}
#endif

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 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
#if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
#define GPIO_LCD_BASE	(144)
#define GPIO_LCD_DIN	(GPIO_LCD_BASE + 8)	/* aux_gpio3_0 */
#define GPIO_LCD_DOUT	(GPIO_LCD_BASE + 9)	/* aux_gpio3_1 */
#define GPIO_LCD_SCL	(GPIO_LCD_BASE + 10)	/* aux_gpio3_2 */
#define GPIO_LCD_CS	(GPIO_LCD_BASE + 11)	/* aux_gpio3_3 */
#define LCD_SPI_BUS_NUM	(1)

static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
	.sck		= GPIO_LCD_SCL,
	.mosi		= GPIO_LCD_DIN,
	.miso		= GPIO_LCD_DOUT,
	.num_chipselect	= 1,
};

static struct platform_device cm_x300_spi_gpio = {
	.name		= "spi_gpio",
	.id		= LCD_SPI_BUS_NUM,
	.dev		= {
		.platform_data	= &cm_x300_spi_gpio_pdata,
	},
};

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

static struct spi_board_info cm_x300_spi_devices[] __initdata = {
	{
		.modalias		= "tdo24m",
		.max_speed_hz		= 1000000,
		.bus_num		= LCD_SPI_BUS_NUM,
		.chip_select		= 0,
		.controller_data	= (void *) GPIO_LCD_CS,
		.platform_data		= &cm_x300_tdo24m_pdata,
	},
};

static void __init cm_x300_init_spi(void)
{
	spi_register_board_info(cm_x300_spi_devices,
				ARRAY_SIZE(cm_x300_spi_devices));
	platform_device_register(&cm_x300_spi_gpio);
}
#else
static inline void cm_x300_init_spi(void) {}
#endif

378 379 380 381 382 383 384 385 386
#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
static void __init cm_x300_init_ac97(void)
{
	pxa_set_ac97_info(NULL);
}
#else
static inline void cm_x300_init_ac97(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
#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
static struct mtd_partition cm_x300_nand_partitions[] = {
	[0] = {
		.name        = "OBM",
		.offset      = 0,
		.size        = SZ_256K,
		.mask_flags  = MTD_WRITEABLE, /* force read-only */
	},
	[1] = {
		.name        = "U-Boot",
		.offset      = MTDPART_OFS_APPEND,
		.size        = SZ_256K,
		.mask_flags  = MTD_WRITEABLE, /* force read-only */
	},
	[2] = {
		.name        = "Environment",
		.offset      = MTDPART_OFS_APPEND,
		.size        = SZ_256K,
	},
	[3] = {
		.name        = "reserved",
		.offset      = MTDPART_OFS_APPEND,
		.size        = SZ_256K + SZ_1M,
		.mask_flags  = MTD_WRITEABLE, /* force read-only */
	},
	[4] = {
		.name        = "kernel",
		.offset      = MTDPART_OFS_APPEND,
		.size        = SZ_4M,
	},
	[5] = {
		.name        = "fs",
		.offset      = MTDPART_OFS_APPEND,
		.size        = MTDPART_SIZ_FULL,
	},
};

static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
	.enable_arbiter	= 1,
426
	.keep_config	= 1,
427 428 429 430 431 432 433 434 435 436 437 438 439
	.parts		= cm_x300_nand_partitions,
	.nr_parts	= ARRAY_SIZE(cm_x300_nand_partitions),
};

static void __init cm_x300_init_nand(void)
{
	pxa3xx_set_nand_info(&cm_x300_nand_info);
}
#else
static inline void cm_x300_init_nand(void) {}
#endif

#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
440
static struct pxamci_platform_data cm_x300_mci_platform_data = {
441
	.detect_delay_ms	= 200,
442 443 444 445 446 447 448
	.ocr_mask		= MMC_VDD_32_33|MMC_VDD_33_34,
	.gpio_card_detect	= GPIO82_MMC_IRQ,
	.gpio_card_ro		= GPIO85_MMC_WP,
	.gpio_power		= -1,
};

/* The second MMC slot of CM-X300 is hardwired to Libertas card and has
449
   no detection/ro pins */
450 451 452
static int cm_x300_mci2_init(struct device *dev,
			     irq_handler_t cm_x300_detect_int,
	void *data)
453 454 455 456
{
	return 0;
}

457
static void cm_x300_mci2_exit(struct device *dev, void *data)
458 459 460
{
}

461
static struct pxamci_platform_data cm_x300_mci2_platform_data = {
462
	.detect_delay_ms	= 200,
463
	.ocr_mask		= MMC_VDD_32_33|MMC_VDD_33_34,
464 465
	.init 			= cm_x300_mci2_init,
	.exit			= cm_x300_mci2_exit,
466 467 468
	.gpio_card_detect	= -1,
	.gpio_card_ro		= -1,
	.gpio_power		= -1,
469 470 471 472 473 474 475 476 477 478 479
};

static void __init cm_x300_init_mmc(void)
{
	pxa_set_mci_info(&cm_x300_mci_platform_data);
	pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
}
#else
static inline void cm_x300_init_mmc(void) {}
#endif

480 481 482 483 484 485 486 487
#if defined(CONFIG_PXA310_ULPI)
static struct clk *pout_clk;

static int cm_x300_ulpi_phy_reset(void)
{
	int err;

	/* reset the PHY */
I
Igor Grinberg 已提交
488 489
	err = gpio_request_one(GPIO_ULPI_PHY_RST, GPIOF_OUT_INIT_LOW,
			       "ulpi reset");
490
	if (err) {
491
		pr_err("failed to request ULPI reset GPIO: %d\n", err);
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
		return err;
	}

	msleep(10);
	gpio_set_value(GPIO_ULPI_PHY_RST, 1);
	msleep(10);

	gpio_free(GPIO_ULPI_PHY_RST);

	return 0;
}

static inline int cm_x300_u2d_init(struct device *dev)
{
	int err = 0;

	if (cpu_is_pxa310()) {
		/* CLK_POUT is connected to the ULPI PHY */
		pout_clk = clk_get(NULL, "CLK_POUT");
		if (IS_ERR(pout_clk)) {
			err = PTR_ERR(pout_clk);
513
			pr_err("failed to get CLK_POUT: %d\n", err);
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
			return err;
		}
		clk_enable(pout_clk);

		err = cm_x300_ulpi_phy_reset();
		if (err) {
			clk_disable(pout_clk);
			clk_put(pout_clk);
		}
	}

	return err;
}

static void cm_x300_u2d_exit(struct device *dev)
{
	if (cpu_is_pxa310()) {
		clk_disable(pout_clk);
		clk_put(pout_clk);
	}
}

static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
	.ulpi_mode	= ULPI_SER_6PIN,
	.init		= cm_x300_u2d_init,
	.exit		= cm_x300_u2d_exit,
};

static void cm_x300_init_u2d(void)
{
	pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
}
#else
static inline void cm_x300_init_u2d(void) {}
#endif

550
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
551 552 553 554 555 556 557 558 559
static int cm_x300_ohci_init(struct device *dev)
{
	if (cpu_is_pxa300())
		UP2OCR = UP2OCR_HXS
			| UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE;

	return 0;
}

560 561
static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
	.port_mode	= PMM_PERPORT_MODE,
562 563
	.flags		= ENABLE_PORT_ALL | POWER_CONTROL_LOW,
	.init		= cm_x300_ohci_init,
564
};
565

566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
static void __init cm_x300_init_ohci(void)
{
	pxa_set_ohci_info(&cm_x300_ohci_platform_data);
}
#else
static inline void cm_x300_init_ohci(void) {}
#endif

#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
static struct gpio_led cm_x300_leds[] = {
	[0] = {
		.name = "cm-x300:green",
		.default_trigger = "heartbeat",
		.active_low = 1,
	},
};

static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
	.num_leds = ARRAY_SIZE(cm_x300_leds),
	.leds = cm_x300_leds,
};

static struct platform_device cm_x300_led_device = {
	.name		= "leds-gpio",
	.id		= -1,
	.dev		= {
		.platform_data = &cm_x300_gpio_led_pdata,
	},
};

static void __init cm_x300_init_leds(void)
{
598 599 600 601 602
	if (system_rev < 130)
		cm_x300_leds[0].gpio = 79;
	else
		cm_x300_leds[0].gpio = 76;

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 634 635 636 637 638 639
	platform_device_register(&cm_x300_led_device);
}
#else
static inline void cm_x300_init_leds(void) {}
#endif

#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
/* PCA9555 */
static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
	.gpio_base = 128,
};

static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
	.gpio_base = 144,
};

static struct i2c_board_info cm_x300_gpio_ext_info[] = {
	[0] = {
		I2C_BOARD_INFO("pca9555", 0x24),
		.platform_data = &cm_x300_gpio_ext_pdata_0,
	},
	[1] = {
		I2C_BOARD_INFO("pca9555", 0x25),
		.platform_data = &cm_x300_gpio_ext_pdata_1,
	},
};

static void __init cm_x300_init_i2c(void)
{
	pxa_set_i2c_info(NULL);
	i2c_register_board_info(0, cm_x300_gpio_ext_info,
				ARRAY_SIZE(cm_x300_gpio_ext_info));
}
#else
static inline void cm_x300_init_i2c(void) {}
#endif

640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
struct v3020_platform_data cm_x300_v3020_pdata = {
	.use_gpio	= 1,
	.gpio_cs	= GPIO95_RTC_CS,
	.gpio_wr	= GPIO96_RTC_WR,
	.gpio_rd	= GPIO97_RTC_RD,
	.gpio_io	= GPIO98_RTC_IO,
};

static struct platform_device cm_x300_rtc_device = {
	.name		= "v3020",
	.id		= -1,
	.dev		= {
		.platform_data = &cm_x300_v3020_pdata,
	}
};

static void __init cm_x300_init_rtc(void)
{
	platform_device_register(&cm_x300_rtc_device);
}
#else
static inline void cm_x300_init_rtc(void) {}
#endif

665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
/* Battery */
struct power_supply_info cm_x300_psy_info = {
	.name = "battery",
	.technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
	.voltage_max_design = 4200000,
	.voltage_min_design = 3000000,
	.use_for_apm = 1,
};

static void cm_x300_battery_low(void)
{
#if defined(CONFIG_APM_EMULATION)
	apm_queue_event(APM_LOW_BATTERY);
#endif
}

static void cm_x300_battery_critical(void)
{
#if defined(CONFIG_APM_EMULATION)
	apm_queue_event(APM_CRITICAL_SUSPEND);
#endif
}

struct da9030_battery_info cm_x300_battery_info = {
	.battery_info = &cm_x300_psy_info,

	.charge_milliamp = 1000,
	.charge_millivolt = 4200,

	.vbat_low = 3600,
	.vbat_crit = 3400,
	.vbat_charge_start = 4100,
	.vbat_charge_stop = 4200,
	.vbat_charge_restart = 4000,

	.vcharge_min = 3200,
	.vcharge_max = 5500,

	.tbat_low = 197,
	.tbat_high = 78,
	.tbat_restart = 100,

	.batmon_interval = 0,

	.battery_low = cm_x300_battery_low,
	.battery_critical = cm_x300_battery_critical,
};

713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
static struct regulator_consumer_supply buck2_consumers[] = {
	{
		.dev = NULL,
		.supply = "vcc_core",
	},
};

static struct regulator_init_data buck2_data = {
	.constraints = {
		.min_uV = 1375000,
		.max_uV = 1375000,
		.state_mem = {
			.enabled = 0,
		},
		.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
		.apply_uV = 1,
	},
	.num_consumer_supplies = ARRAY_SIZE(buck2_consumers),
	.consumer_supplies = buck2_consumers,
};

734 735
/* DA9030 */
struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
736 737 738 739 740
	{
		.name = "da903x-battery",
		.id = DA9030_ID_BAT,
		.platform_data = &cm_x300_battery_info,
	},
741 742 743 744 745
	{
		.name = "da903x-regulator",
		.id = DA9030_ID_BUCK2,
		.platform_data = &buck2_data,
	},
746 747 748 749 750 751 752 753 754
};

static struct da903x_platform_data cm_x300_da9030_info = {
	.num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
	.subdevs = cm_x300_da9030_subdevs,
};

static struct i2c_board_info cm_x300_pmic_info = {
	I2C_BOARD_INFO("da9030", 0x49),
755
	.irq = IRQ_WAKEUP0,
756 757 758 759 760 761 762 763 764 765 766
	.platform_data = &cm_x300_da9030_info,
};

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

static void __init cm_x300_init_da9030(void)
{
	pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
	i2c_register_board_info(1, &cm_x300_pmic_info, 1);
T
Thomas Gleixner 已提交
767
	irq_set_irq_wake(IRQ_WAKEUP0, 1);
768 769
}

I
Igor Grinberg 已提交
770 771 772 773 774 775
/* wi2wi gpio setting for system_rev >= 130 */
static struct gpio cm_x300_wi2wi_gpios[] __initdata = {
	{ 71, GPIOF_OUT_INIT_HIGH, "wlan en" },
	{ 70, GPIOF_OUT_INIT_HIGH, "bt reset" },
};

776 777 778 779 780
static void __init cm_x300_init_wi2wi(void)
{
	int err;

	if (system_rev < 130) {
I
Igor Grinberg 已提交
781 782
		cm_x300_wi2wi_gpios[0].gpio = 77;	/* wlan en */
		cm_x300_wi2wi_gpios[1].gpio = 78;	/* bt reset */
783 784 785
	}

	/* Libertas and CSR reset */
I
Igor Grinberg 已提交
786
	err = gpio_request_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
787
	if (err) {
788
		pr_err("failed to request wifi/bt gpios: %d\n", err);
I
Igor Grinberg 已提交
789
		return;
790 791
	}

I
Igor Grinberg 已提交
792
	udelay(10);
793
	gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 0);
I
Igor Grinberg 已提交
794
	udelay(10);
795
	gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 1);
I
Igor Grinberg 已提交
796

797
	gpio_free_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
798 799 800
}

/* MFP */
801
static void __init cm_x300_init_mfp(void)
802 803
{
	/* board-processor specific GPIO initialization */
804
	pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
805

806
	if (system_rev < 130)
807
		pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
808
	else
809 810 811 812
		pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));

	if (cpu_is_pxa310())
		pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
813 814 815 816 817 818
}

static void __init cm_x300_init(void)
{
	cm_x300_init_mfp();

819 820
	pxa_set_btuart_info(NULL);
	pxa_set_stuart_info(NULL);
821 822
	if (cpu_is_pxa300())
		pxa_set_ffuart_info(NULL);
823

824
	cm_x300_init_da9030();
825 826
	cm_x300_init_dm9000();
	cm_x300_init_lcd();
827
	cm_x300_init_u2d();
828 829 830 831 832
	cm_x300_init_ohci();
	cm_x300_init_mmc();
	cm_x300_init_nand();
	cm_x300_init_leds();
	cm_x300_init_i2c();
833
	cm_x300_init_spi();
834
	cm_x300_init_rtc();
835
	cm_x300_init_ac97();
836
	cm_x300_init_wi2wi();
837
	cm_x300_init_bl();
838 839
}

840 841
static void __init cm_x300_fixup(struct tag *tags, char **cmdline,
				 struct meminfo *mi)
842
{
843 844 845 846 847 848 849
	/* Make sure that mi->bank[0].start = PHYS_ADDR */
	for (; tags->hdr.size; tags = tag_next(tags))
		if (tags->hdr.tag == ATAG_MEM &&
			tags->u.mem.start == 0x80000000) {
			tags->u.mem.start = 0xa0000000;
			break;
		}
850 851
}

852
MACHINE_START(CM_X300, "CM-X300 module")
853
	.atag_offset	= 0x100,
854
	.map_io		= pxa3xx_map_io,
855
	.init_irq	= pxa3xx_init_irq,
856
	.handle_irq	= pxa3xx_handle_irq,
857 858
	.timer		= &pxa_timer,
	.init_machine	= cm_x300_init,
859
	.fixup		= cm_x300_fixup,
860
MACHINE_END