setup.c 2.7 KB

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