ts72xx.c 5.1 KB

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