pnav10.c 12.6 KB
Newer Older
B
Bryan Wu 已提交
1
/*
2 3 4
 * Copyright 2004-2009 Analog Devices Inc.
 *                2005 National ICT Australia (NICTA)
 *                      Aidan Williams <aidan@nicta.com.au>
B
Bryan Wu 已提交
5
 *
6
 * Licensed under the GPL-2 or later.
B
Bryan Wu 已提交
7 8 9
 */

#include <linux/device.h>
10
#include <linux/etherdevice.h>
B
Bryan Wu 已提交
11 12 13 14 15
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
16
#include <linux/irq.h>
17
#include <asm/dma.h>
B
Bryan Wu 已提交
18
#include <asm/bfin5xx_spi.h>
19
#include <asm/portmux.h>
B
Bryan Wu 已提交
20 21 22 23 24 25

#include <linux/spi/ad7877.h>

/*
 * Name the Board for the /proc/cpuinfo
 */
26
const char bfin_board_name[] = "ADI PNAV-1.0";
B
Bryan Wu 已提交
27 28 29 30 31 32 33 34 35 36 37

/*
 *  Driver needs to know address, irq and flag pin.
 */

#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
static struct resource bfin_pcmcia_cf_resources[] = {
	{
		.start = 0x20310000, /* IO PORT */
		.end = 0x20312000,
		.flags = IORESOURCE_MEM,
38
	}, {
S
Simon Arlott 已提交
39
		.start = 0x20311000, /* Attribute Memory */
B
Bryan Wu 已提交
40 41
		.end = 0x20311FFF,
		.flags = IORESOURCE_MEM,
42
	}, {
B
Bryan Wu 已提交
43 44 45
		.start = IRQ_PF4,
		.end = IRQ_PF4,
		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
46
	}, {
B
Bryan Wu 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
		.start = 6, /* Card Detect PF6 */
		.end = 6,
		.flags = IORESOURCE_IRQ,
	},
};

static struct platform_device bfin_pcmcia_cf_device = {
	.name = "bfin_cf_pcmcia",
	.id = -1,
	.num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
	.resource = bfin_pcmcia_cf_resources,
};
#endif

#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
static struct platform_device rtc_device = {
	.name = "rtc-bfin",
	.id   = -1,
};
#endif

#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
69 70 71 72 73 74 75 76
#include <linux/smc91x.h>

static struct smc91x_platdata smc91x_info = {
	.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
	.leda = RPC_LED_100_10,
	.ledb = RPC_LED_TX_RX,
};

B
Bryan Wu 已提交
77 78 79 80 81 82
static struct resource smc91x_resources[] = {
	{
		.name = "smc91x-regs",
		.start = 0x20300300,
		.end = 0x20300300 + 16,
		.flags = IORESOURCE_MEM,
83
	}, {
B
Bryan Wu 已提交
84 85 86 87 88 89 90 91 92 93 94

		.start = IRQ_PF7,
		.end = IRQ_PF7,
		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
	},
};
static struct platform_device smc91x_device = {
	.name = "smc91x",
	.id = 0,
	.num_resources = ARRAY_SIZE(smc91x_resources),
	.resource = smc91x_resources,
95 96 97
	.dev	= {
		.platform_data	= &smc91x_info,
	},
B
Bryan Wu 已提交
98 99 100 101
};
#endif

#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
102 103 104 105
static struct platform_device bfin_mii_bus = {
	.name = "bfin_mii_bus",
};

B
Bryan Wu 已提交
106 107
static struct platform_device bfin_mac_device = {
	.name = "bfin_mac",
108
	.dev.platform_data = &bfin_mii_bus,
B
Bryan Wu 已提交
109 110 111 112 113 114 115 116 117
};
#endif

#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
static struct resource net2272_bfin_resources[] = {
	{
		.start = 0x20300000,
		.end = 0x20300000 + 0x100,
		.flags = IORESOURCE_MEM,
118
	}, {
B
Bryan Wu 已提交
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
		.start = IRQ_PF7,
		.end = IRQ_PF7,
		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
	},
};

static struct platform_device net2272_bfin_device = {
	.name = "net2272",
	.id = -1,
	.num_resources = ARRAY_SIZE(net2272_bfin_resources),
	.resource = net2272_bfin_resources,
};
#endif

#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
/* all SPI peripherals info goes here */

#if defined(CONFIG_MTD_M25P80) \
	|| defined(CONFIG_MTD_M25P80_MODULE)
static struct mtd_partition bfin_spi_flash_partitions[] = {
	{
140
		.name = "bootloader(spi)",
B
Bryan Wu 已提交
141 142 143
		.size = 0x00020000,
		.offset = 0,
		.mask_flags = MTD_CAP_ROM
144
	}, {
145
		.name = "linux kernel(spi)",
B
Bryan Wu 已提交
146 147
		.size = 0xe0000,
		.offset = 0x20000
148
	}, {
149
		.name = "file system(spi)",
B
Bryan Wu 已提交
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
		.size = 0x700000,
		.offset = 0x00100000,
	}
};

static struct flash_platform_data bfin_spi_flash_data = {
	.name = "m25p80",
	.parts = bfin_spi_flash_partitions,
	.nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
	.type = "m25p64",
};

/* SPI flash chip (m25p64) */
static struct bfin5xx_spi_chip spi_flash_chip_info = {
	.enable_dma = 0,         /* use dma transfer with this chip*/
	.bits_per_word = 8,
};
#endif

169 170
#if defined(CONFIG_BFIN_SPI_ADC) \
	|| defined(CONFIG_BFIN_SPI_ADC_MODULE)
B
Bryan Wu 已提交
171 172 173 174 175 176 177
/* SPI ADC chip */
static struct bfin5xx_spi_chip spi_adc_chip_info = {
	.enable_dma = 1,         /* use dma transfer with this chip*/
	.bits_per_word = 16,
};
#endif

178 179
#if defined(CONFIG_SND_BLACKFIN_AD183X) \
	|| defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
B
Bryan Wu 已提交
180 181 182 183 184 185
static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
	.enable_dma = 0,
	.bits_per_word = 16,
};
#endif

186 187 188
#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
static struct bfin5xx_spi_chip mmc_spi_chip_info = {
	.enable_dma = 0,
B
Bryan Wu 已提交
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 215 216 217 218 219 220
	.bits_per_word = 8,
};
#endif

#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
	.enable_dma = 0,
	.bits_per_word = 16,
};

static const struct ad7877_platform_data bfin_ad7877_ts_info = {
	.model			= 7877,
	.vref_delay_usecs	= 50,	/* internal, no capacitor */
	.x_plate_ohms		= 419,
	.y_plate_ohms		= 486,
	.pressure_max		= 1000,
	.pressure_min		= 0,
	.stopacq_polarity 	= 1,
	.first_conversion_delay = 3,
	.acquisition_time 	= 1,
	.averaging 		= 1,
	.pen_down_acc_interval 	= 1,
};
#endif

static struct spi_board_info bfin_spi_board_info[] __initdata = {
#if defined(CONFIG_MTD_M25P80) \
	|| defined(CONFIG_MTD_M25P80_MODULE)
	{
		/* the modalias must be the same as spi device driver name */
		.modalias = "m25p80", /* Name of spi_driver for this device */
		.max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
221
		.bus_num = 0, /* Framework bus number */
B
Bryan Wu 已提交
222 223 224 225 226 227 228
		.chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
		.platform_data = &bfin_spi_flash_data,
		.controller_data = &spi_flash_chip_info,
		.mode = SPI_MODE_3,
	},
#endif

229 230
#if defined(CONFIG_BFIN_SPI_ADC) \
	|| defined(CONFIG_BFIN_SPI_ADC_MODULE)
B
Bryan Wu 已提交
231 232 233
	{
		.modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
		.max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
234
		.bus_num = 0, /* Framework bus number */
B
Bryan Wu 已提交
235 236 237 238 239 240
		.chip_select = 1, /* Framework chip select. */
		.platform_data = NULL, /* No spi_driver specific config */
		.controller_data = &spi_adc_chip_info,
	},
#endif

241 242
#if defined(CONFIG_SND_BLACKFIN_AD183X) \
	|| defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
B
Bryan Wu 已提交
243
	{
244
		.modalias = "ad1836",
B
Bryan Wu 已提交
245
		.max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
246
		.bus_num = 0,
B
Bryan Wu 已提交
247 248 249 250
		.chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
		.controller_data = &ad1836_spi_chip_info,
	},
#endif
251
#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
B
Bryan Wu 已提交
252
	{
253
		.modalias = "mmc_spi",
B
Bryan Wu 已提交
254
		.max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
255
		.bus_num = 0,
256 257
		.chip_select = 5,
		.controller_data = &mmc_spi_chip_info,
B
Bryan Wu 已提交
258 259 260 261 262 263 264 265 266
		.mode = SPI_MODE_3,
	},
#endif
#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
{
	.modalias		= "ad7877",
	.platform_data		= &bfin_ad7877_ts_info,
	.irq			= IRQ_PF2,
	.max_speed_hz		= 12500000,     /* max spi clock (SCK) speed in HZ */
267
	.bus_num		= 0,
B
Bryan Wu 已提交
268 269 270 271 272 273 274
	.chip_select  		= 5,
	.controller_data = &spi_ad7877_chip_info,
},
#endif

};

275 276 277 278 279 280 281 282 283 284
/* SPI (0) */
static struct resource bfin_spi0_resource[] = {
	[0] = {
		.start = SPI0_REGBASE,
		.end   = SPI0_REGBASE + 0xFF,
		.flags = IORESOURCE_MEM,
		},
	[1] = {
		.start = CH_SPI,
		.end   = CH_SPI,
285 286 287 288 289
		.flags = IORESOURCE_DMA,
	},
	[2] = {
		.start = IRQ_SPI,
		.end   = IRQ_SPI,
290
		.flags = IORESOURCE_IRQ,
291
	},
292 293
};

B
Bryan Wu 已提交
294
/* SPI controller data */
295
static struct bfin5xx_spi_master bfin_spi0_info = {
B
Bryan Wu 已提交
296 297
	.num_chipselect = 8,
	.enable_dma = 1,  /* master has the ability to do dma transfer */
298
	.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
B
Bryan Wu 已提交
299 300
};

301 302 303 304 305
static struct platform_device bfin_spi0_device = {
	.name = "bfin-spi",
	.id = 0, /* Bus number */
	.num_resources = ARRAY_SIZE(bfin_spi0_resource),
	.resource = bfin_spi0_resource,
B
Bryan Wu 已提交
306
	.dev = {
307
		.platform_data = &bfin_spi0_info, /* Passed to driver */
B
Bryan Wu 已提交
308 309 310 311 312 313
	},
};
#endif  /* spi master and devices */

#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
static struct platform_device bfin_fb_device = {
314
	.name = "bf537-lq035",
B
Bryan Wu 已提交
315 316 317 318
};
#endif

#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
319 320
#ifdef CONFIG_SERIAL_BFIN_UART0
static struct resource bfin_uart0_resources[] = {
B
Bryan Wu 已提交
321
	{
322 323
		.start = UART0_THR,
		.end = UART0_GCTL+2,
B
Bryan Wu 已提交
324
		.flags = IORESOURCE_MEM,
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 361 362 363 364 365 366
	},
	{
		.start = IRQ_UART0_RX,
		.end = IRQ_UART0_RX+1,
		.flags = IORESOURCE_IRQ,
	},
	{
		.start = IRQ_UART0_ERROR,
		.end = IRQ_UART0_ERROR,
		.flags = IORESOURCE_IRQ,
	},
	{
		.start = CH_UART0_TX,
		.end = CH_UART0_TX,
		.flags = IORESOURCE_DMA,
	},
	{
		.start = CH_UART0_RX,
		.end = CH_UART0_RX,
		.flags = IORESOURCE_DMA,
	},
};

unsigned short bfin_uart0_peripherals[] = {
	P_UART0_TX, P_UART0_RX, 0
};

static struct platform_device bfin_uart0_device = {
	.name = "bfin-uart",
	.id = 0,
	.num_resources = ARRAY_SIZE(bfin_uart0_resources),
	.resource = bfin_uart0_resources,
	.dev = {
		.platform_data = &bfin_uart0_peripherals, /* Passed to driver */
	},
};
#endif
#ifdef CONFIG_SERIAL_BFIN_UART1
static struct resource bfin_uart1_resources[] = {
	{
		.start = UART1_THR,
		.end = UART1_GCTL+2,
B
Bryan Wu 已提交
367 368
		.flags = IORESOURCE_MEM,
	},
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
	{
		.start = IRQ_UART1_RX,
		.end = IRQ_UART1_RX+1,
		.flags = IORESOURCE_IRQ,
	},
	{
		.start = IRQ_UART1_ERROR,
		.end = IRQ_UART1_ERROR,
		.flags = IORESOURCE_IRQ,
	},
	{
		.start = CH_UART1_TX,
		.end = CH_UART1_TX,
		.flags = IORESOURCE_DMA,
	},
	{
		.start = CH_UART1_RX,
		.end = CH_UART1_RX,
		.flags = IORESOURCE_DMA,
	},
B
Bryan Wu 已提交
389 390
};

391 392 393 394 395
unsigned short bfin_uart1_peripherals[] = {
	P_UART1_TX, P_UART1_RX, 0
};

static struct platform_device bfin_uart1_device = {
B
Bryan Wu 已提交
396 397
	.name = "bfin-uart",
	.id = 1,
398 399 400 401 402
	.num_resources = ARRAY_SIZE(bfin_uart1_resources),
	.resource = bfin_uart1_resources,
	.dev = {
		.platform_data = &bfin_uart1_peripherals, /* Passed to driver */
	},
B
Bryan Wu 已提交
403 404
};
#endif
405
#endif
B
Bryan Wu 已提交
406

407 408
#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
#ifdef CONFIG_BFIN_SIR0
409
static struct resource bfin_sir0_resources[] = {
410 411 412 413 414
	{
		.start = 0xFFC00400,
		.end = 0xFFC004FF,
		.flags = IORESOURCE_MEM,
	},
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
	{
		.start = IRQ_UART0_RX,
		.end = IRQ_UART0_RX+1,
		.flags = IORESOURCE_IRQ,
	},
	{
		.start = CH_UART0_RX,
		.end = CH_UART0_RX+1,
		.flags = IORESOURCE_DMA,
	},
};

static struct platform_device bfin_sir0_device = {
	.name = "bfin_sir",
	.id = 0,
	.num_resources = ARRAY_SIZE(bfin_sir0_resources),
	.resource = bfin_sir0_resources,
};
433 434
#endif
#ifdef CONFIG_BFIN_SIR1
435
static struct resource bfin_sir1_resources[] = {
436 437 438 439 440
	{
		.start = 0xFFC02000,
		.end = 0xFFC020FF,
		.flags = IORESOURCE_MEM,
	},
441 442 443 444 445 446 447 448 449 450
	{
		.start = IRQ_UART1_RX,
		.end = IRQ_UART1_RX+1,
		.flags = IORESOURCE_IRQ,
	},
	{
		.start = CH_UART1_RX,
		.end = CH_UART1_RX+1,
		.flags = IORESOURCE_DMA,
	},
451 452
};

453
static struct platform_device bfin_sir1_device = {
454
	.name = "bfin_sir",
455 456 457
	.id = 1,
	.num_resources = ARRAY_SIZE(bfin_sir1_resources),
	.resource = bfin_sir1_resources,
458 459
};
#endif
460
#endif
B
Bryan Wu 已提交
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475

static struct platform_device *stamp_devices[] __initdata = {
#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
	&bfin_pcmcia_cf_device,
#endif

#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
	&rtc_device,
#endif

#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
	&smc91x_device,
#endif

#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
476
	&bfin_mii_bus,
B
Bryan Wu 已提交
477 478 479 480 481 482 483 484
	&bfin_mac_device,
#endif

#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
	&net2272_bfin_device,
#endif

#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
485
	&bfin_spi0_device,
B
Bryan Wu 已提交
486 487 488 489 490 491 492
#endif

#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
	&bfin_fb_device,
#endif

#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
493 494 495 496 497 498
#ifdef CONFIG_SERIAL_BFIN_UART0
	&bfin_uart0_device,
#endif
#ifdef CONFIG_SERIAL_BFIN_UART1
	&bfin_uart1_device,
#endif
B
Bryan Wu 已提交
499
#endif
500 501

#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
502 503 504 505 506 507
#ifdef CONFIG_BFIN_SIR0
	&bfin_sir0_device,
#endif
#ifdef CONFIG_BFIN_SIR1
	&bfin_sir1_device,
#endif
508
#endif
B
Bryan Wu 已提交
509 510
};

511
static int __init pnav_init(void)
B
Bryan Wu 已提交
512
{
513
	printk(KERN_INFO "%s(): registering device resources\n", __func__);
B
Bryan Wu 已提交
514 515 516 517 518 519 520 521
	platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
	spi_register_board_info(bfin_spi_board_info,
				ARRAY_SIZE(bfin_spi_board_info));
#endif
	return 0;
}

522
arch_initcall(pnav_init);
523

524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
static struct platform_device *stamp_early_devices[] __initdata = {
#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
#ifdef CONFIG_SERIAL_BFIN_UART0
	&bfin_uart0_device,
#endif
#ifdef CONFIG_SERIAL_BFIN_UART1
	&bfin_uart1_device,
#endif
#endif
};

void __init native_machine_early_platform_add_devices(void)
{
	printk(KERN_INFO "register early platform devices\n");
	early_platform_add_devices(stamp_early_devices,
		ARRAY_SIZE(stamp_early_devices));
}

542
void bfin_get_ether_addr(char *addr)
543 544 545 546
{
	random_ether_addr(addr);
	printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
}
547
EXPORT_SYMBOL(bfin_get_ether_addr);