ts72xx.c 4.8 KB

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