diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/blackfin/mach-bf537/boards/stamp.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index 671f9d67f23a..7e4b9d95674b 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c | |||
@@ -29,9 +29,12 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/device.h> | 31 | #include <linux/device.h> |
32 | #include <linux/kernel.h> | ||
32 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
33 | #include <linux/mtd/mtd.h> | 34 | #include <linux/mtd/mtd.h> |
35 | #include <linux/mtd/nand.h> | ||
34 | #include <linux/mtd/partitions.h> | 36 | #include <linux/mtd/partitions.h> |
37 | #include <linux/mtd/plat-ram.h> | ||
35 | #include <linux/mtd/physmap.h> | 38 | #include <linux/mtd/physmap.h> |
36 | #include <linux/spi/spi.h> | 39 | #include <linux/spi/spi.h> |
37 | #include <linux/spi/flash.h> | 40 | #include <linux/spi/flash.h> |
@@ -355,6 +358,84 @@ static struct platform_device net2272_bfin_device = { | |||
355 | }; | 358 | }; |
356 | #endif | 359 | #endif |
357 | 360 | ||
361 | #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE) | ||
362 | #ifdef CONFIG_MTD_PARTITIONS | ||
363 | const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL }; | ||
364 | |||
365 | static struct mtd_partition bfin_plat_nand_partitions[] = { | ||
366 | { | ||
367 | .name = "linux kernel", | ||
368 | .size = 0x400000, | ||
369 | .offset = 0, | ||
370 | }, { | ||
371 | .name = "file system", | ||
372 | .size = MTDPART_SIZ_FULL, | ||
373 | .offset = MTDPART_OFS_APPEND, | ||
374 | }, | ||
375 | }; | ||
376 | #endif | ||
377 | |||
378 | #define BFIN_NAND_PLAT_CLE 2 | ||
379 | #define BFIN_NAND_PLAT_ALE 1 | ||
380 | static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) | ||
381 | { | ||
382 | struct nand_chip *this = mtd->priv; | ||
383 | |||
384 | if (cmd == NAND_CMD_NONE) | ||
385 | return; | ||
386 | |||
387 | if (ctrl & NAND_CLE) | ||
388 | writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE)); | ||
389 | else | ||
390 | writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE)); | ||
391 | } | ||
392 | |||
393 | #define BFIN_NAND_PLAT_READY GPIO_PF3 | ||
394 | static int bfin_plat_nand_dev_ready(struct mtd_info *mtd) | ||
395 | { | ||
396 | return gpio_get_value(BFIN_NAND_PLAT_READY); | ||
397 | } | ||
398 | |||
399 | static struct platform_nand_data bfin_plat_nand_data = { | ||
400 | .chip = { | ||
401 | .chip_delay = 30, | ||
402 | #ifdef CONFIG_MTD_PARTITIONS | ||
403 | .part_probe_types = part_probes, | ||
404 | .partitions = bfin_plat_nand_partitions, | ||
405 | .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions), | ||
406 | #endif | ||
407 | }, | ||
408 | .ctrl = { | ||
409 | .cmd_ctrl = bfin_plat_nand_cmd_ctrl, | ||
410 | .dev_ready = bfin_plat_nand_dev_ready, | ||
411 | }, | ||
412 | }; | ||
413 | |||
414 | #define MAX(x, y) (x > y ? x : y) | ||
415 | static struct resource bfin_plat_nand_resources = { | ||
416 | .start = 0x20212000, | ||
417 | .end = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)), | ||
418 | .flags = IORESOURCE_IO, | ||
419 | }; | ||
420 | |||
421 | static struct platform_device bfin_async_nand_device = { | ||
422 | .name = "gen_nand", | ||
423 | .id = -1, | ||
424 | .num_resources = 1, | ||
425 | .resource = &bfin_plat_nand_resources, | ||
426 | .dev = { | ||
427 | .platform_data = &bfin_plat_nand_data, | ||
428 | }, | ||
429 | }; | ||
430 | |||
431 | static void bfin_plat_nand_init(void) | ||
432 | { | ||
433 | gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat"); | ||
434 | } | ||
435 | #else | ||
436 | static void bfin_plat_nand_init(void) {} | ||
437 | #endif | ||
438 | |||
358 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) | 439 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) |
359 | static struct mtd_partition stamp_partitions[] = { | 440 | static struct mtd_partition stamp_partitions[] = { |
360 | { | 441 | { |
@@ -922,6 +1003,10 @@ static struct platform_device *stamp_devices[] __initdata = { | |||
922 | 1003 | ||
923 | &bfin_gpios_device, | 1004 | &bfin_gpios_device, |
924 | 1005 | ||
1006 | #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE) | ||
1007 | &bfin_async_nand_device, | ||
1008 | #endif | ||
1009 | |||
925 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) | 1010 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) |
926 | &stamp_flash_device, | 1011 | &stamp_flash_device, |
927 | #endif | 1012 | #endif |
@@ -936,6 +1021,7 @@ static int __init stamp_init(void) | |||
936 | ARRAY_SIZE(bfin_i2c_board_info)); | 1021 | ARRAY_SIZE(bfin_i2c_board_info)); |
937 | #endif | 1022 | #endif |
938 | 1023 | ||
1024 | bfin_plat_nand_init(); | ||
939 | platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); | 1025 | platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); |
940 | spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); | 1026 | spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); |
941 | 1027 | ||