setup.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Renesas Technology Europe RSK+ Support.
  3. *
  4. * Copyright (C) 2008 Paul Mundt
  5. * Copyright (C) 2008 Peter Griffin <pgriffin@mpc-data.co.uk>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/types.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/mtd/mtd.h>
  16. #include <linux/mtd/partitions.h>
  17. #include <linux/mtd/physmap.h>
  18. #ifdef CONFIG_MTD
  19. #include <linux/mtd/map.h>
  20. #endif
  21. #include <asm/machvec.h>
  22. #include <asm/io.h>
  23. static struct mtd_partition rsk_partitions[] = {
  24. {
  25. .name = "Bootloader",
  26. .offset = 0x00000000,
  27. .size = 0x00040000,
  28. .mask_flags = MTD_WRITEABLE,
  29. }, {
  30. .name = "Kernel",
  31. .offset = MTDPART_OFS_NXTBLK,
  32. .size = 0x001c0000,
  33. }, {
  34. .name = "Flash_FS",
  35. .offset = MTDPART_OFS_NXTBLK,
  36. .size = MTDPART_SIZ_FULL,
  37. }
  38. };
  39. static struct physmap_flash_data flash_data = {
  40. .parts = rsk_partitions,
  41. .nr_parts = ARRAY_SIZE(rsk_partitions),
  42. .width = 2,
  43. };
  44. static struct resource flash_resource = {
  45. .start = 0x20000000,
  46. .end = 0x20400000,
  47. .flags = IORESOURCE_MEM,
  48. };
  49. static struct platform_device flash_device = {
  50. .name = "physmap-flash",
  51. .id = -1,
  52. .resource = &flash_resource,
  53. .num_resources = 1,
  54. .dev = {
  55. .platform_data = &flash_data,
  56. },
  57. };
  58. #ifdef CONFIG_MTD
  59. static const char *probes[] = { "cmdlinepart", NULL };
  60. static struct map_info rsk_flash_map = {
  61. .name = "RSK+ Flash",
  62. .size = 0x400000,
  63. .bankwidth = 2,
  64. };
  65. static struct mtd_info *flash_mtd;
  66. static struct mtd_partition *parsed_partitions;
  67. static void __init set_mtd_partitions(void)
  68. {
  69. int nr_parts = 0;
  70. simple_map_init(&rsk_flash_map);
  71. flash_mtd = do_map_probe("cfi_probe", &rsk_flash_map);
  72. nr_parts = parse_mtd_partitions(flash_mtd, probes,
  73. &parsed_partitions, 0);
  74. /* If there is no partition table, used the hard coded table */
  75. if (nr_parts > 0) {
  76. flash_data.nr_parts = nr_parts;
  77. flash_data.parts = parsed_partitions;
  78. }
  79. }
  80. #else
  81. static inline void set_mtd_partitions(void) {}
  82. #endif
  83. static struct platform_device *rsk_devices[] __initdata = {
  84. &flash_device,
  85. };
  86. static int __init rsk_devices_setup(void)
  87. {
  88. set_mtd_partitions();
  89. return platform_add_devices(rsk_devices,
  90. ARRAY_SIZE(rsk_devices));
  91. }
  92. device_initcall(rsk_devices_setup);
  93. /*
  94. * The Machine Vector
  95. */
  96. static struct sh_machine_vector mv_rsk __initmv = {
  97. .mv_name = "RSK+",
  98. };