ts72xx.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * arch/arm/mach-ep93xx/ts72xx.c
  3. * Technologic Systems TS72xx SBC support.
  4. *
  5. * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/io.h>
  16. #include <linux/m48t86.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <mach/hardware.h>
  19. #include <mach/ts72xx.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/map.h>
  22. #include <asm/mach/arch.h>
  23. static struct map_desc ts72xx_io_desc[] __initdata = {
  24. {
  25. .virtual = TS72XX_MODEL_VIRT_BASE,
  26. .pfn = __phys_to_pfn(TS72XX_MODEL_PHYS_BASE),
  27. .length = TS72XX_MODEL_SIZE,
  28. .type = MT_DEVICE,
  29. }, {
  30. .virtual = TS72XX_OPTIONS_VIRT_BASE,
  31. .pfn = __phys_to_pfn(TS72XX_OPTIONS_PHYS_BASE),
  32. .length = TS72XX_OPTIONS_SIZE,
  33. .type = MT_DEVICE,
  34. }, {
  35. .virtual = TS72XX_OPTIONS2_VIRT_BASE,
  36. .pfn = __phys_to_pfn(TS72XX_OPTIONS2_PHYS_BASE),
  37. .length = TS72XX_OPTIONS2_SIZE,
  38. .type = MT_DEVICE,
  39. }, {
  40. .virtual = TS72XX_RTC_INDEX_VIRT_BASE,
  41. .pfn = __phys_to_pfn(TS72XX_RTC_INDEX_PHYS_BASE),
  42. .length = TS72XX_RTC_INDEX_SIZE,
  43. .type = MT_DEVICE,
  44. }, {
  45. .virtual = TS72XX_RTC_DATA_VIRT_BASE,
  46. .pfn = __phys_to_pfn(TS72XX_RTC_DATA_PHYS_BASE),
  47. .length = TS72XX_RTC_DATA_SIZE,
  48. .type = MT_DEVICE,
  49. }
  50. };
  51. static struct map_desc ts72xx_nand_io_desc[] __initdata = {
  52. {
  53. .virtual = TS72XX_NAND_DATA_VIRT_BASE,
  54. .pfn = __phys_to_pfn(TS72XX_NAND1_DATA_PHYS_BASE),
  55. .length = TS72XX_NAND_DATA_SIZE,
  56. .type = MT_DEVICE,
  57. }, {
  58. .virtual = TS72XX_NAND_CONTROL_VIRT_BASE,
  59. .pfn = __phys_to_pfn(TS72XX_NAND1_CONTROL_PHYS_BASE),
  60. .length = TS72XX_NAND_CONTROL_SIZE,
  61. .type = MT_DEVICE,
  62. }, {
  63. .virtual = TS72XX_NAND_BUSY_VIRT_BASE,
  64. .pfn = __phys_to_pfn(TS72XX_NAND1_BUSY_PHYS_BASE),
  65. .length = TS72XX_NAND_BUSY_SIZE,
  66. .type = MT_DEVICE,
  67. }
  68. };
  69. static struct map_desc ts72xx_alternate_nand_io_desc[] __initdata = {
  70. {
  71. .virtual = TS72XX_NAND_DATA_VIRT_BASE,
  72. .pfn = __phys_to_pfn(TS72XX_NAND2_DATA_PHYS_BASE),
  73. .length = TS72XX_NAND_DATA_SIZE,
  74. .type = MT_DEVICE,
  75. }, {
  76. .virtual = TS72XX_NAND_CONTROL_VIRT_BASE,
  77. .pfn = __phys_to_pfn(TS72XX_NAND2_CONTROL_PHYS_BASE),
  78. .length = TS72XX_NAND_CONTROL_SIZE,
  79. .type = MT_DEVICE,
  80. }, {
  81. .virtual = TS72XX_NAND_BUSY_VIRT_BASE,
  82. .pfn = __phys_to_pfn(TS72XX_NAND2_BUSY_PHYS_BASE),
  83. .length = TS72XX_NAND_BUSY_SIZE,
  84. .type = MT_DEVICE,
  85. }
  86. };
  87. static void __init ts72xx_map_io(void)
  88. {
  89. ep93xx_map_io();
  90. iotable_init(ts72xx_io_desc, ARRAY_SIZE(ts72xx_io_desc));
  91. /*
  92. * The TS-7200 has NOR flash, the other models have NAND flash.
  93. */
  94. if (!board_is_ts7200()) {
  95. if (is_ts9420_installed()) {
  96. iotable_init(ts72xx_alternate_nand_io_desc,
  97. ARRAY_SIZE(ts72xx_alternate_nand_io_desc));
  98. } else {
  99. iotable_init(ts72xx_nand_io_desc,
  100. ARRAY_SIZE(ts72xx_nand_io_desc));
  101. }
  102. }
  103. }
  104. /*************************************************************************
  105. * NOR flash (TS-7200 only)
  106. *************************************************************************/
  107. static struct physmap_flash_data ts72xx_flash_data = {
  108. .width = 2,
  109. };
  110. static struct resource ts72xx_flash_resource = {
  111. .start = EP93XX_CS6_PHYS_BASE,
  112. .end = EP93XX_CS6_PHYS_BASE + SZ_16M - 1,
  113. .flags = IORESOURCE_MEM,
  114. };
  115. static struct platform_device ts72xx_flash = {
  116. .name = "physmap-flash",
  117. .id = 0,
  118. .dev = {
  119. .platform_data = &ts72xx_flash_data,
  120. },
  121. .num_resources = 1,
  122. .resource = &ts72xx_flash_resource,
  123. };
  124. static void __init ts72xx_register_flash(void)
  125. {
  126. if (board_is_ts7200())
  127. platform_device_register(&ts72xx_flash);
  128. }
  129. static unsigned char ts72xx_rtc_readbyte(unsigned long addr)
  130. {
  131. __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE);
  132. return __raw_readb(TS72XX_RTC_DATA_VIRT_BASE);
  133. }
  134. static void ts72xx_rtc_writebyte(unsigned char value, unsigned long addr)
  135. {
  136. __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE);
  137. __raw_writeb(value, TS72XX_RTC_DATA_VIRT_BASE);
  138. }
  139. static struct m48t86_ops ts72xx_rtc_ops = {
  140. .readbyte = ts72xx_rtc_readbyte,
  141. .writebyte = ts72xx_rtc_writebyte,
  142. };
  143. static struct platform_device ts72xx_rtc_device = {
  144. .name = "rtc-m48t86",
  145. .id = -1,
  146. .dev = {
  147. .platform_data = &ts72xx_rtc_ops,
  148. },
  149. .num_resources = 0,
  150. };
  151. static struct ep93xx_eth_data ts72xx_eth_data = {
  152. .phy_id = 1,
  153. };
  154. static void __init ts72xx_init_machine(void)
  155. {
  156. ep93xx_init_devices();
  157. ts72xx_register_flash();
  158. platform_device_register(&ts72xx_rtc_device);
  159. ep93xx_register_eth(&ts72xx_eth_data, 1);
  160. }
  161. MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
  162. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  163. .phys_io = EP93XX_APB_PHYS_BASE,
  164. .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
  165. .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
  166. .map_io = ts72xx_map_io,
  167. .init_irq = ep93xx_init_irq,
  168. .timer = &ep93xx_timer,
  169. .init_machine = ts72xx_init_machine,
  170. MACHINE_END