setup.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #include <linux/mtd/map.h>
  19. #include <asm/machvec.h>
  20. #include <asm/io.h>
  21. static const char *probes[] = { "cmdlinepart", NULL };
  22. static struct mtd_partition *parsed_partitions;
  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. .width = 2,
  41. };
  42. static struct resource flash_resource = {
  43. .start = 0x20000000,
  44. .end = 0x20400000,
  45. .flags = IORESOURCE_MEM,
  46. };
  47. static struct platform_device flash_device = {
  48. .name = "physmap-flash",
  49. .id = -1,
  50. .resource = &flash_resource,
  51. .num_resources = 1,
  52. .dev = {
  53. .platform_data = &flash_data,
  54. },
  55. };
  56. static struct mtd_info *flash_mtd;
  57. static struct map_info rsk_flash_map = {
  58. .name = "RSK+ Flash",
  59. .size = 0x400000,
  60. .bankwidth = 2,
  61. };
  62. static void __init set_mtd_partitions(void)
  63. {
  64. int nr_parts = 0;
  65. simple_map_init(&rsk_flash_map);
  66. flash_mtd = do_map_probe("cfi_probe", &rsk_flash_map);
  67. nr_parts = parse_mtd_partitions(flash_mtd, probes,
  68. &parsed_partitions, 0);
  69. /* If there is no partition table, used the hard coded table */
  70. if (nr_parts <= 0) {
  71. flash_data.parts = rsk_partitions;
  72. flash_data.nr_parts = ARRAY_SIZE(rsk_partitions);
  73. } else {
  74. flash_data.nr_parts = nr_parts;
  75. flash_data.parts = parsed_partitions;
  76. }
  77. }
  78. static struct platform_device *rsk_devices[] __initdata = {
  79. &flash_device,
  80. };
  81. static int __init rsk_devices_setup(void)
  82. {
  83. set_mtd_partitions();
  84. return platform_add_devices(rsk_devices,
  85. ARRAY_SIZE(rsk_devices));
  86. }
  87. device_initcall(rsk_devices_setup);
  88. /*
  89. * The Machine Vector
  90. */
  91. static struct sh_machine_vector mv_rsk __initmv = {
  92. .mv_name = "RSK+",
  93. };