lubbock.c 13.7 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 *  linux/arch/arm/mach-pxa/lubbock.c
 *
 *  Support for the Intel DBPXA250 Development Platform.
 *
 *  Author:	Nicolas Pitre
 *  Created:	Jun 15, 2001
 *  Copyright:	MontaVista Software Inc.
 *
 *  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.
 */
14
#include <linux/clkdev.h>
15
#include <linux/gpio.h>
16
#include <linux/gpio/machine.h>
L
Linus Torvalds 已提交
17 18 19
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
B
Bryan Wu 已提交
20
#include <linux/io.h>
21
#include <linux/platform_device.h>
22
#include <linux/syscore_ops.h>
L
Linus Torvalds 已提交
23 24 25
#include <linux/major.h>
#include <linux/fb.h>
#include <linux/interrupt.h>
26 27
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
28
#include <linux/smc91x.h>
B
Bryan Wu 已提交
29 30
#include <linux/slab.h>
#include <linux/leds.h>
L
Linus Torvalds 已提交
31

32 33
#include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
34
#include <linux/spi/pxa2xx_spi.h>
35

L
Linus Torvalds 已提交
36 37 38
#include <asm/setup.h>
#include <asm/memory.h>
#include <asm/mach-types.h>
39
#include <mach/hardware.h>
L
Linus Torvalds 已提交
40
#include <asm/irq.h>
41
#include <asm/sizes.h>
L
Linus Torvalds 已提交
42 43 44 45

#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
46
#include <asm/mach/flash.h>
L
Linus Torvalds 已提交
47 48 49

#include <asm/hardware/sa1111.h>

50
#include <mach/pxa25x.h>
51 52 53
#include <mach/audio.h>
#include <mach/lubbock.h>
#include <mach/udc.h>
54 55 56
#include <linux/platform_data/irda-pxaficp.h>
#include <linux/platform_data/video-pxafb.h>
#include <linux/platform_data/mmc-pxamci.h>
57
#include <mach/pm.h>
58
#include <mach/smemc.h>
L
Linus Torvalds 已提交
59 60

#include "generic.h"
61
#include "devices.h"
L
Linus Torvalds 已提交
62

63 64
static unsigned long lubbock_pin_config[] __initdata = {
	GPIO15_nCS_1,	/* CS1 - Flash */
65
	GPIO78_nCS_2,	/* CS2 - Baseboard FGPA */
66
	GPIO79_nCS_3,	/* CS3 - SMC ethernet */
67
	GPIO80_nCS_4,	/* CS4 - SA1111 */
68 69 70 71 72 73

	/* SSP data pins */
	GPIO23_SSP1_SCLK,
	GPIO25_SSP1_TXD,
	GPIO26_SSP1_RXD,

74 75 76 77 78 79
	/* AC97 */
	GPIO28_AC97_BITCLK,
	GPIO29_AC97_SDATA_IN_0,
	GPIO30_AC97_SDATA_OUT,
	GPIO31_AC97_SYNC,

80
	/* LCD - 16bpp DSTN */
81
	GPIOxx_LCD_DSTN_16BPP,
82

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
	/* BTUART */
	GPIO42_BTUART_RXD,
	GPIO43_BTUART_TXD,
	GPIO44_BTUART_CTS,
	GPIO45_BTUART_RTS,

	/* PC Card */
	GPIO48_nPOE,
	GPIO49_nPWE,
	GPIO50_nPIOR,
	GPIO51_nPIOW,
	GPIO52_nPCE_1,
	GPIO53_nPCE_2,
	GPIO54_nPSKTSEL,
	GPIO55_nPREG,
	GPIO56_nPWAIT,
	GPIO57_nIOIS16,

	/* MMC */
	GPIO6_MMC_CLK,
	GPIO8_MMC_CS0,

105 106 107
	/* SA1111 chip */
	GPIO11_3_6MHz,

108 109 110
	/* wakeup */
	GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
};
L
Linus Torvalds 已提交
111

112
#define LUB_HEXLED		__LUB_REG(LUBBOCK_FPGA_PHYS + 0x010)
L
Linus Torvalds 已提交
113 114
#define LUB_MISC_WR		__LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)

115 116 117 118 119
void lubbock_set_hexled(uint32_t value)
{
	LUB_HEXLED = value;
}

L
Linus Torvalds 已提交
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
void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
{
	unsigned long flags;

	local_irq_save(flags);
	LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
	local_irq_restore(flags);
}
EXPORT_SYMBOL(lubbock_set_misc_wr);

static int lubbock_udc_is_connected(void)
{
	return (LUB_MISC_RD & (1 << 9)) == 0;
}

static struct pxa2xx_udc_mach_info udc_info __initdata = {
	.udc_is_connected	= lubbock_udc_is_connected,
	// no D+ pullup; lubbock can't connect/disconnect in software
};

static struct resource sa1111_resources[] = {
	[0] = {
		.start	= 0x10000000,
		.end	= 0x10001fff,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= LUBBOCK_SA1111_IRQ,
		.end	= LUBBOCK_SA1111_IRQ,
		.flags	= IORESOURCE_IRQ,
	},
};

153
static struct sa1111_platform_data sa1111_info = {
154
	.irq_base	= LUBBOCK_SA1111_IRQ_BASE,
155
	.disable_devs	= SA1111_DEVID_SAC,
156 157
};

L
Linus Torvalds 已提交
158 159 160 161 162
static struct platform_device sa1111_device = {
	.name		= "sa1111",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(sa1111_resources),
	.resource	= sa1111_resources,
163 164 165
	.dev		= {
		.platform_data	= &sa1111_info,
	},
L
Linus Torvalds 已提交
166 167
};

168 169 170 171 172 173
/* ADS7846 is connected through SSP ... and if your board has J5 populated,
 * you can select it to replace the ucb1400 by switching the touchscreen cable
 * (to J5) and poking board registers (as done below).  Else it's only useful
 * for the temperature sensors.
 */
static struct pxa2xx_spi_master pxa_ssp_master_info = {
174
	.num_chipselect	= 1,
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
};

static int lubbock_ads7846_pendown_state(void)
{
	/* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
	return 0;
}

static struct ads7846_platform_data ads_info = {
	.model			= 7846,
	.vref_delay_usecs	= 100,		/* internal, no cap */
	.get_pendown_state	= lubbock_ads7846_pendown_state,
	// .x_plate_ohms		= 500,	/* GUESS! */
	// .y_plate_ohms		= 500,	/* GUESS! */
};

static void ads7846_cs(u32 command)
{
	static const unsigned	TS_nCS = 1 << 11;
	lubbock_set_misc_wr(TS_nCS, (command == PXA2XX_CS_ASSERT) ? 0 : TS_nCS);
}

static struct pxa2xx_spi_chip ads_hw = {
	.tx_threshold		= 1,
	.rx_threshold		= 2,
	.cs_control		= ads7846_cs,
};

static struct spi_board_info spi_board_info[] __initdata = { {
	.modalias	= "ads7846",
	.platform_data	= &ads_info,
	.controller_data = &ads_hw,
	.irq		= LUBBOCK_BB_IRQ,
	.max_speed_hz	= 120000 /* max sample rate at 3V */
				* 26 /* command + data + overhead */,
	.bus_num	= 1,
	.chip_select	= 0,
},
};

215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
static struct resource smc91x_resources[] = {
	[0] = {
		.name	= "smc91x-regs",
		.start	= 0x0c000c00,
		.end	= 0x0c0fffff,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= LUBBOCK_ETH_IRQ,
		.end	= LUBBOCK_ETH_IRQ,
		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
	},
	[2] = {
		.name	= "smc91x-attrib",
		.start	= 0x0e000000,
		.end	= 0x0e0fffff,
		.flags	= IORESOURCE_MEM,
	},
};

235 236 237 238
static struct smc91x_platdata lubbock_smc91x_info = {
	.flags	= SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_IO_SHIFT_2,
};

L
Linus Torvalds 已提交
239 240 241 242 243
static struct platform_device smc91x_device = {
	.name		= "smc91x",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(smc91x_resources),
	.resource	= smc91x_resources,
244 245 246
	.dev		= {
		.platform_data = &lubbock_smc91x_info,
	},
L
Linus Torvalds 已提交
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 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 308 309 310 311
static struct resource flash_resources[] = {
	[0] = {
		.start	= 0x00000000,
		.end	= SZ_64M - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= 0x04000000,
		.end	= 0x04000000 + SZ_64M - 1,
		.flags	= IORESOURCE_MEM,
	},
};

static struct mtd_partition lubbock_partitions[] = {
	{
		.name =		"Bootloader",
		.size =		0x00040000,
		.offset =	0,
		.mask_flags =	MTD_WRITEABLE  /* force read-only */
	},{
		.name =		"Kernel",
		.size =		0x00100000,
		.offset =	0x00040000,
	},{
		.name =		"Filesystem",
		.size =		MTDPART_SIZ_FULL,
		.offset =	0x00140000
	}
};

static struct flash_platform_data lubbock_flash_data[2] = {
	{
		.map_name	= "cfi_probe",
		.parts		= lubbock_partitions,
		.nr_parts	= ARRAY_SIZE(lubbock_partitions),
	}, {
		.map_name	= "cfi_probe",
		.parts		= NULL,
		.nr_parts	= 0,
	}
};

static struct platform_device lubbock_flash_device[2] = {
	{
		.name		= "pxa2xx-flash",
		.id		= 0,
		.dev = {
			.platform_data = &lubbock_flash_data[0],
		},
		.resource = &flash_resources[0],
		.num_resources = 1,
	},
	{
		.name		= "pxa2xx-flash",
		.id		= 1,
		.dev = {
			.platform_data = &lubbock_flash_data[1],
		},
		.resource = &flash_resources[1],
		.num_resources = 1,
	},
};

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
static struct resource lubbock_cplds_resources[] = {
	[0] = {
		.start	= LUBBOCK_FPGA_PHYS + 0xc0,
		.end	= LUBBOCK_FPGA_PHYS + 0xe0 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= PXA_GPIO_TO_IRQ(0),
		.end	= PXA_GPIO_TO_IRQ(0),
		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
	},
	[2] = {
		.start	= LUBBOCK_IRQ(0),
		.end	= LUBBOCK_IRQ(6),
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device lubbock_cplds_device = {
	.name		= "pxa_cplds_irqs",
	.id		= -1,
	.resource	= &lubbock_cplds_resources[0],
	.num_resources	= 3,
};


L
Linus Torvalds 已提交
338 339 340
static struct platform_device *devices[] __initdata = {
	&sa1111_device,
	&smc91x_device,
341 342
	&lubbock_flash_device[0],
	&lubbock_flash_device[1],
343
	&lubbock_cplds_device,
L
Linus Torvalds 已提交
344 345
};

346
static struct pxafb_mode_info sharp_lm8v31_mode = {
L
Linus Torvalds 已提交
347 348 349 350 351 352 353 354 355 356 357 358
	.pixclock	= 270000,
	.xres		= 640,
	.yres		= 480,
	.bpp		= 16,
	.hsync_len	= 1,
	.left_margin	= 3,
	.right_margin	= 3,
	.vsync_len	= 1,
	.upper_margin	= 0,
	.lower_margin	= 0,
	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
	.cmap_greyscale	= 0,
359 360 361 362 363
};

static struct pxafb_mach_info sharp_lm8v31 = {
	.modes		= &sharp_lm8v31_mode,
	.num_modes	= 1,
L
Linus Torvalds 已提交
364 365
	.cmap_inverse	= 0,
	.cmap_static	= 0,
366
	.lcd_conn	= LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
A
Alexey Dobriyan 已提交
367
			  LCD_AC_BIAS_FREQ(255),
L
Linus Torvalds 已提交
368 369
};

370 371 372
#define	MMC_POLL_RATE		msecs_to_jiffies(1000)

static void lubbock_mmc_poll(unsigned long);
373
static irq_handler_t mmc_detect_int;
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391

static struct timer_list mmc_timer = {
	.function	= lubbock_mmc_poll,
};

static void lubbock_mmc_poll(unsigned long data)
{
	unsigned long flags;

	/* clear any previous irq state, then ... */
	local_irq_save(flags);
	LUB_IRQ_SET_CLR &= ~(1 << 0);
	local_irq_restore(flags);

	/* poll until mmc/sd card is removed */
	if (LUB_IRQ_SET_CLR & (1 << 0))
		mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
	else {
392
		(void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
393 394 395 396
		enable_irq(LUBBOCK_SD_IRQ);
	}
}

397
static irqreturn_t lubbock_detect_int(int irq, void *data)
398 399 400 401 402
{
	/* IRQ is level triggered; disable, and poll for removal */
	disable_irq(irq);
	mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);

403
	return mmc_detect_int(irq, data);
404 405 406
}

static int lubbock_mci_init(struct device *dev,
407
		irq_handler_t detect_int,
408
		void *data)
L
Linus Torvalds 已提交
409
{
410 411 412 413 414
	/* detect card insert/eject */
	mmc_detect_int = detect_int;
	init_timer(&mmc_timer);
	mmc_timer.data = (unsigned long) data;
	return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
415
			   0, "lubbock-sd-detect", data);
416 417 418 419 420 421 422 423 424 425 426
}

static int lubbock_mci_get_ro(struct device *dev)
{
	return (LUB_MISC_RD & (1 << 2)) != 0;
}

static void lubbock_mci_exit(struct device *dev, void *data)
{
	free_irq(LUBBOCK_SD_IRQ, data);
	del_timer_sync(&mmc_timer);
L
Linus Torvalds 已提交
427 428 429
}

static struct pxamci_platform_data lubbock_mci_platform_data = {
430
	.ocr_mask		= MMC_VDD_32_33|MMC_VDD_33_34,
431
	.detect_delay_ms	= 10,
432 433 434 435 436 437
	.init 			= lubbock_mci_init,
	.get_ro			= lubbock_mci_get_ro,
	.exit 			= lubbock_mci_exit,
	.gpio_card_detect	= -1,
	.gpio_card_ro		= -1,
	.gpio_power		= -1,
L
Linus Torvalds 已提交
438 439
};

N
Nicolas Pitre 已提交
440 441 442 443 444 445 446 447 448 449
static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
{
	unsigned long flags;

	local_irq_save(flags);
	if (mode & IR_SIRMODE) {
		LUB_MISC_WR &= ~(1 << 4);
	} else if (mode & IR_FIRMODE) {
		LUB_MISC_WR |= 1 << 4;
	}
450
	pxa2xx_transceiver_mode(dev, mode);
N
Nicolas Pitre 已提交
451 452 453 454
	local_irq_restore(flags);
}

static struct pxaficp_platform_data lubbock_ficp_platform_data = {
455 456 457
	.gpio_pwdown		= -1,
	.transceiver_cap	= IR_SIRMODE | IR_FIRMODE,
	.transceiver_mode	= lubbock_irda_transceiver_mode,
N
Nicolas Pitre 已提交
458 459
};

L
Linus Torvalds 已提交
460 461
static void __init lubbock_init(void)
{
462 463
	int flashboot = (LUB_CONF_SWITCHES & 1);

464 465
	pxa2xx_mfp_config(ARRAY_AND_SIZE(lubbock_pin_config));

466 467 468 469
	pxa_set_ffuart_info(NULL);
	pxa_set_btuart_info(NULL);
	pxa_set_stuart_info(NULL);

470
	clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL);
L
Linus Torvalds 已提交
471
	pxa_set_udc_info(&udc_info);
472
	pxa_set_fb_info(NULL, &sharp_lm8v31);
L
Linus Torvalds 已提交
473
	pxa_set_mci_info(&lubbock_mci_platform_data);
N
Nicolas Pitre 已提交
474
	pxa_set_ficp_info(&lubbock_ficp_platform_data);
475
	pxa_set_ac97_info(NULL);
476 477

	lubbock_flash_data[0].width = lubbock_flash_data[1].width =
478
		(__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
479 480 481 482 483 484
	/* Compensate for the nROMBT switch which swaps the flash banks */
	printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
	       flashboot?"Flash":"ROM", flashboot);

	lubbock_flash_data[flashboot^1].name = "application-flash";
	lubbock_flash_data[flashboot].name = "boot-rom";
L
Linus Torvalds 已提交
485
	(void) platform_add_devices(devices, ARRAY_SIZE(devices));
486

487
	pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
488
	spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
L
Linus Torvalds 已提交
489 490 491
}

static struct map_desc lubbock_io_desc[] __initdata = {
492 493 494 495 496 497
  	{	/* CPLD */
		.virtual	=  LUBBOCK_FPGA_VIRT,
		.pfn		= __phys_to_pfn(LUBBOCK_FPGA_PHYS),
		.length		= 0x00100000,
		.type		= MT_DEVICE
	}
L
Linus Torvalds 已提交
498 499 500 501
};

static void __init lubbock_map_io(void)
{
502
	pxa25x_map_io();
L
Linus Torvalds 已提交
503 504 505 506 507
	iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));

	PCFR |= PCFR_OPDE;
}

B
Bryan Wu 已提交
508 509 510 511 512 513 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 550 551 552 553 554 555 556 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 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
/*
 * Driver for the 8 discrete LEDs available for general use:
 * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
 * so be sure to not monkey with them here.
 */

#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
struct lubbock_led {
	struct led_classdev	cdev;
	u8			mask;
};

/*
 * The triggers lines up below will only be used if the
 * LED triggers are compiled in.
 */
static const struct {
	const char *name;
	const char *trigger;
} lubbock_leds[] = {
	{ "lubbock:D28", "default-on", },
	{ "lubbock:D27", "cpu0", },
	{ "lubbock:D26", "heartbeat" },
	{ "lubbock:D25", },
	{ "lubbock:D24", },
	{ "lubbock:D23", },
	{ "lubbock:D22", },
	{ "lubbock:D21", },
};

static void lubbock_led_set(struct led_classdev *cdev,
			      enum led_brightness b)
{
	struct lubbock_led *led = container_of(cdev,
					 struct lubbock_led, cdev);
	u32 reg = LUB_DISC_BLNK_LED;

	if (b != LED_OFF)
		reg |= led->mask;
	else
		reg &= ~led->mask;

	LUB_DISC_BLNK_LED = reg;
}

static enum led_brightness lubbock_led_get(struct led_classdev *cdev)
{
	struct lubbock_led *led = container_of(cdev,
					 struct lubbock_led, cdev);
	u32 reg = LUB_DISC_BLNK_LED;

	return (reg & led->mask) ? LED_FULL : LED_OFF;
}

static int __init lubbock_leds_init(void)
{
	int i;

	if (!machine_is_lubbock())
		return -ENODEV;

	/* All ON */
	LUB_DISC_BLNK_LED |= 0xff;
	for (i = 0; i < ARRAY_SIZE(lubbock_leds); i++) {
		struct lubbock_led *led;

		led = kzalloc(sizeof(*led), GFP_KERNEL);
		if (!led)
			break;

		led->cdev.name = lubbock_leds[i].name;
		led->cdev.brightness_set = lubbock_led_set;
		led->cdev.brightness_get = lubbock_led_get;
		led->cdev.default_trigger = lubbock_leds[i].trigger;
		led->mask = BIT(i);

		if (led_classdev_register(NULL, &led->cdev) < 0) {
			kfree(led);
			break;
		}
	}

	return 0;
}

/*
 * Since we may have triggers on any subsystem, defer registration
 * until after subsystem_init.
 */
fs_initcall(lubbock_leds_init);
#endif

L
Linus Torvalds 已提交
600
MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
601 602
	/* Maintainer: MontaVista Software Inc. */
	.map_io		= lubbock_map_io,
603
	.nr_irqs	= LUBBOCK_NR_IRQS,
604
	.init_irq	= pxa25x_init_irq,
605
	.handle_irq	= pxa25x_handle_irq,
S
Stephen Warren 已提交
606
	.init_time	= pxa_timer_init,
607
	.init_machine	= lubbock_init,
608
	.restart	= pxa_restart,
L
Linus Torvalds 已提交
609
MACHINE_END