flash.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * MIMC200 board-specific flash initialization
  3. *
  4. * Copyright (C) 2008 Mercury IMC Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <mach/smc.h>
  16. static struct smc_timing flash_timing __initdata = {
  17. .ncs_read_setup = 0,
  18. .nrd_setup = 15,
  19. .ncs_write_setup = 0,
  20. .nwe_setup = 0,
  21. .ncs_read_pulse = 115,
  22. .nrd_pulse = 110,
  23. .ncs_write_pulse = 60,
  24. .nwe_pulse = 60,
  25. .read_cycle = 115,
  26. .write_cycle = 100,
  27. };
  28. static struct smc_config flash_config __initdata = {
  29. .bus_width = 2,
  30. .nrd_controlled = 1,
  31. .nwe_controlled = 1,
  32. .byte_write = 1,
  33. };
  34. /* system flash definition */
  35. static struct mtd_partition flash_parts_system[] = {
  36. {
  37. .name = "u-boot",
  38. .offset = 0x00000000,
  39. .size = 0x00020000, /* 128 KiB */
  40. .mask_flags = MTD_WRITEABLE,
  41. },
  42. {
  43. .name = "root",
  44. .offset = 0x00020000,
  45. .size = 0x007c0000,
  46. },
  47. {
  48. .name = "splash",
  49. .offset = 0x007e0000,
  50. .size = 0x00010000, /* 64KiB */
  51. },
  52. {
  53. .name = "env",
  54. .offset = 0x007f0000,
  55. .size = 0x00010000,
  56. .mask_flags = MTD_WRITEABLE,
  57. },
  58. };
  59. static struct physmap_flash_data flash_system = {
  60. .width = 2,
  61. .nr_parts = ARRAY_SIZE(flash_parts_system),
  62. .parts = flash_parts_system,
  63. };
  64. static struct resource flash_resource_system = {
  65. .start = 0x00000000,
  66. .end = 0x007fffff,
  67. .flags = IORESOURCE_MEM,
  68. };
  69. static struct platform_device flash_device_system = {
  70. .name = "physmap-flash",
  71. .id = 0,
  72. .resource = &flash_resource_system,
  73. .num_resources = 1,
  74. .dev = {
  75. .platform_data = &flash_system,
  76. },
  77. };
  78. /* data flash definition */
  79. static struct mtd_partition flash_parts_data[] = {
  80. {
  81. .name = "data",
  82. .offset = 0x00000000,
  83. .size = 0x00800000,
  84. },
  85. };
  86. static struct physmap_flash_data flash_data = {
  87. .width = 2,
  88. .nr_parts = ARRAY_SIZE(flash_parts_data),
  89. .parts = flash_parts_data,
  90. };
  91. static struct resource flash_resource_data = {
  92. .start = 0x08000000,
  93. .end = 0x087fffff,
  94. .flags = IORESOURCE_MEM,
  95. };
  96. static struct platform_device flash_device_data = {
  97. .name = "physmap-flash",
  98. .id = 1,
  99. .resource = &flash_resource_data,
  100. .num_resources = 1,
  101. .dev = {
  102. .platform_data = &flash_data,
  103. },
  104. };
  105. /* This needs to be called after the SMC has been initialized */
  106. static int __init mimc200_flash_init(void)
  107. {
  108. int ret;
  109. smc_set_timing(&flash_config, &flash_timing);
  110. ret = smc_set_configuration(0, &flash_config);
  111. if (ret < 0) {
  112. printk(KERN_ERR "mimc200: failed to set 'System' NOR flash timing\n");
  113. return ret;
  114. }
  115. ret = smc_set_configuration(1, &flash_config);
  116. if (ret < 0) {
  117. printk(KERN_ERR "mimc200: failed to set 'Data' NOR flash timing\n");
  118. return ret;
  119. }
  120. platform_device_register(&flash_device_system);
  121. platform_device_register(&flash_device_data);
  122. return 0;
  123. }
  124. device_initcall(mimc200_flash_init);