amcore.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * amcore.c -- Support for Sysam AMCORE open board
  3. *
  4. * (C) Copyright 2016, Angelo Dureghello <angelo@sysam.it>
  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/device.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/dm9000.h>
  13. #include <linux/irq.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/mtd/mtd.h>
  16. #include <linux/mtd/map.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/i2c.h>
  20. #include <asm/coldfire.h>
  21. #include <asm/mcfsim.h>
  22. #include <asm/io.h>
  23. #if IS_ENABLED(CONFIG_DM9000)
  24. #define DM9000_IRQ 25
  25. #define DM9000_ADDR 0x30000000
  26. /*
  27. * DEVICES and related device RESOURCES
  28. */
  29. static struct resource dm9000_resources[] = {
  30. /* physical address of the address register (CMD [A2] to 0)*/
  31. [0] = {
  32. .start = DM9000_ADDR,
  33. .end = DM9000_ADDR,
  34. .flags = IORESOURCE_MEM,
  35. },
  36. /*
  37. * physical address of the data register (CMD [A2] to 1),
  38. * driver wants a range >=4 to assume a 32bit data bus
  39. */
  40. [1] = {
  41. .start = DM9000_ADDR + 4,
  42. .end = DM9000_ADDR + 7,
  43. .flags = IORESOURCE_MEM,
  44. },
  45. /* IRQ line the device's interrupt pin is connected to */
  46. [2] = {
  47. .start = DM9000_IRQ,
  48. .end = DM9000_IRQ,
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. };
  52. static struct dm9000_plat_data dm9000_platdata = {
  53. .flags = DM9000_PLATF_32BITONLY,
  54. };
  55. static struct platform_device dm9000_device = {
  56. .name = "dm9000",
  57. .id = 0,
  58. .num_resources = ARRAY_SIZE(dm9000_resources),
  59. .resource = dm9000_resources,
  60. .dev = {
  61. .platform_data = &dm9000_platdata,
  62. }
  63. };
  64. #endif
  65. static void __init dm9000_pre_init(void)
  66. {
  67. /* Set the dm9000 interrupt to be auto-vectored */
  68. mcf_autovector(DM9000_IRQ);
  69. }
  70. /*
  71. * Partitioning of parallel NOR flash (39VF3201B)
  72. */
  73. static struct mtd_partition amcore_partitions[] = {
  74. {
  75. .name = "U-Boot (128K)",
  76. .size = 0x20000,
  77. .offset = 0x0
  78. },
  79. {
  80. .name = "Kernel+ROMfs (2994K)",
  81. .size = 0x2E0000,
  82. .offset = MTDPART_OFS_APPEND
  83. },
  84. {
  85. .name = "Flash Free Space (1024K)",
  86. .size = MTDPART_SIZ_FULL,
  87. .offset = MTDPART_OFS_APPEND
  88. }
  89. };
  90. static struct physmap_flash_data flash_data = {
  91. .parts = amcore_partitions,
  92. .nr_parts = ARRAY_SIZE(amcore_partitions),
  93. .width = 2,
  94. };
  95. static struct resource flash_resource = {
  96. .start = 0xffc00000,
  97. .end = 0xffffffff,
  98. .flags = IORESOURCE_MEM,
  99. };
  100. static struct platform_device flash_device = {
  101. .name = "physmap-flash",
  102. .id = -1,
  103. .resource = &flash_resource,
  104. .num_resources = 1,
  105. .dev = {
  106. .platform_data = &flash_data,
  107. },
  108. };
  109. static struct platform_device rtc_device = {
  110. .name = "rtc-ds1307",
  111. .id = -1,
  112. };
  113. static struct i2c_board_info amcore_i2c_info[] __initdata = {
  114. {
  115. I2C_BOARD_INFO("ds1338", 0x68),
  116. },
  117. };
  118. static struct platform_device *amcore_devices[] __initdata = {
  119. #if IS_ENABLED(CONFIG_DM9000)
  120. &dm9000_device,
  121. #endif
  122. &flash_device,
  123. &rtc_device,
  124. };
  125. static int __init init_amcore(void)
  126. {
  127. #if IS_ENABLED(CONFIG_DM9000)
  128. dm9000_pre_init();
  129. #endif
  130. /* Add i2c RTC Dallas chip supprt */
  131. i2c_register_board_info(0, amcore_i2c_info,
  132. ARRAY_SIZE(amcore_i2c_info));
  133. platform_add_devices(amcore_devices, ARRAY_SIZE(amcore_devices));
  134. return 0;
  135. }
  136. arch_initcall(init_amcore);