pnav10.c 12.0 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 106 107 108 109 110 111 112 113 114 115 116 117 118
#include <linux/bfin_mac.h>
static const unsigned short bfin_mac_peripherals[] = P_RMII0;

static struct bfin_phydev_platform_data bfin_phydev_data[] = {
	{
		.addr = 1,
		.irq = IRQ_MAC_PHYINT,
	},
};

static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
	.phydev_number = 1,
	.phydev_data = bfin_phydev_data,
	.phy_mode = PHY_INTERFACE_MODE_RMII,
	.mac_peripherals = bfin_mac_peripherals,
};

119 120
static struct platform_device bfin_mii_bus = {
	.name = "bfin_mii_bus",
121 122 123
	.dev = {
		.platform_data = &bfin_mii_bus_data,
	}
124 125
};

B
Bryan Wu 已提交
126 127
static struct platform_device bfin_mac_device = {
	.name = "bfin_mac",
128 129 130
	.dev = {
		.platform_data = &bfin_mii_bus,
	}
B
Bryan Wu 已提交
131 132 133 134 135 136 137 138 139
};
#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,
140
	}, {
B
Bryan Wu 已提交
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
		.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[] = {
	{
162
		.name = "bootloader(spi)",
B
Bryan Wu 已提交
163 164 165
		.size = 0x00020000,
		.offset = 0,
		.mask_flags = MTD_CAP_ROM
166
	}, {
167
		.name = "linux kernel(spi)",
B
Bryan Wu 已提交
168 169
		.size = 0xe0000,
		.offset = 0x20000
170
	}, {
171
		.name = "file system(spi)",
B
Bryan Wu 已提交
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
		.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*/
};
#endif

190 191 192
#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 已提交
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
};
#endif

#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
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 */
219
		.bus_num = 0, /* Framework bus number */
B
Bryan Wu 已提交
220 221 222 223 224 225 226
		.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

227 228
#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
	|| defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
B
Bryan Wu 已提交
229
	{
230
		.modalias = "ad183x",
B
Bryan Wu 已提交
231
		.max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
232
		.bus_num = 0,
233
		.chip_select = 4,
B
Bryan Wu 已提交
234 235
	},
#endif
236
#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
B
Bryan Wu 已提交
237
	{
238
		.modalias = "mmc_spi",
B
Bryan Wu 已提交
239
		.max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
240
		.bus_num = 0,
241 242
		.chip_select = 5,
		.controller_data = &mmc_spi_chip_info,
B
Bryan Wu 已提交
243 244 245 246 247 248 249 250 251
		.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 */
252
	.bus_num		= 0,
B
Bryan Wu 已提交
253 254 255 256 257 258
	.chip_select  		= 5,
},
#endif

};

259 260 261 262 263 264 265 266 267 268
/* 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,
269 270 271 272 273
		.flags = IORESOURCE_DMA,
	},
	[2] = {
		.start = IRQ_SPI,
		.end   = IRQ_SPI,
274
		.flags = IORESOURCE_IRQ,
275
	},
276 277
};

B
Bryan Wu 已提交
278
/* SPI controller data */
279
static struct bfin5xx_spi_master bfin_spi0_info = {
B
Bryan Wu 已提交
280 281
	.num_chipselect = 8,
	.enable_dma = 1,  /* master has the ability to do dma transfer */
282
	.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
B
Bryan Wu 已提交
283 284
};

285 286 287 288 289
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 已提交
290
	.dev = {
291
		.platform_data = &bfin_spi0_info, /* Passed to driver */
B
Bryan Wu 已提交
292 293 294 295 296 297
	},
};
#endif  /* spi master and devices */

#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
static struct platform_device bfin_fb_device = {
298
	.name = "bf537-lq035",
B
Bryan Wu 已提交
299 300 301 302
};
#endif

#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
303 304
#ifdef CONFIG_SERIAL_BFIN_UART0
static struct resource bfin_uart0_resources[] = {
B
Bryan Wu 已提交
305
	{
306 307
		.start = UART0_THR,
		.end = UART0_GCTL+2,
B
Bryan Wu 已提交
308
		.flags = IORESOURCE_MEM,
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
	},
	{
		.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,
	},
};

332
static unsigned short bfin_uart0_peripherals[] = {
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
	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 已提交
351 352
		.flags = IORESOURCE_MEM,
	},
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
	{
		.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 已提交
373 374
};

375
static unsigned short bfin_uart1_peripherals[] = {
376 377 378 379
	P_UART1_TX, P_UART1_RX, 0
};

static struct platform_device bfin_uart1_device = {
B
Bryan Wu 已提交
380 381
	.name = "bfin-uart",
	.id = 1,
382 383 384 385 386
	.num_resources = ARRAY_SIZE(bfin_uart1_resources),
	.resource = bfin_uart1_resources,
	.dev = {
		.platform_data = &bfin_uart1_peripherals, /* Passed to driver */
	},
B
Bryan Wu 已提交
387 388
};
#endif
389
#endif
B
Bryan Wu 已提交
390

391 392
#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
#ifdef CONFIG_BFIN_SIR0
393
static struct resource bfin_sir0_resources[] = {
394 395 396 397 398
	{
		.start = 0xFFC00400,
		.end = 0xFFC004FF,
		.flags = IORESOURCE_MEM,
	},
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
	{
		.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,
};
417 418
#endif
#ifdef CONFIG_BFIN_SIR1
419
static struct resource bfin_sir1_resources[] = {
420 421 422 423 424
	{
		.start = 0xFFC02000,
		.end = 0xFFC020FF,
		.flags = IORESOURCE_MEM,
	},
425 426 427 428 429 430 431 432 433 434
	{
		.start = IRQ_UART1_RX,
		.end = IRQ_UART1_RX+1,
		.flags = IORESOURCE_IRQ,
	},
	{
		.start = CH_UART1_RX,
		.end = CH_UART1_RX+1,
		.flags = IORESOURCE_DMA,
	},
435 436
};

437
static struct platform_device bfin_sir1_device = {
438
	.name = "bfin_sir",
439 440 441
	.id = 1,
	.num_resources = ARRAY_SIZE(bfin_sir1_resources),
	.resource = bfin_sir1_resources,
442 443
};
#endif
444
#endif
B
Bryan Wu 已提交
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459

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)
460
	&bfin_mii_bus,
B
Bryan Wu 已提交
461 462 463 464 465 466 467 468
	&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)
469
	&bfin_spi0_device,
B
Bryan Wu 已提交
470 471 472 473 474 475 476
#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)
477 478 479 480 481 482
#ifdef CONFIG_SERIAL_BFIN_UART0
	&bfin_uart0_device,
#endif
#ifdef CONFIG_SERIAL_BFIN_UART1
	&bfin_uart1_device,
#endif
B
Bryan Wu 已提交
483
#endif
484 485

#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
486 487 488 489 490 491
#ifdef CONFIG_BFIN_SIR0
	&bfin_sir0_device,
#endif
#ifdef CONFIG_BFIN_SIR1
	&bfin_sir1_device,
#endif
492
#endif
B
Bryan Wu 已提交
493 494
};

495
static int __init pnav_init(void)
B
Bryan Wu 已提交
496
{
497
	printk(KERN_INFO "%s(): registering device resources\n", __func__);
B
Bryan Wu 已提交
498 499 500 501 502 503 504 505
	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;
}

506
arch_initcall(pnav_init);
507

508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
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));
}

526
void bfin_get_ether_addr(char *addr)
527 528 529 530
{
	random_ether_addr(addr);
	printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
}
531
EXPORT_SYMBOL(bfin_get_ether_addr);