simpad.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * linux/arch/arm/mach-sa1100/simpad.c
  3. */
  4. #include <linux/config.h>
  5. #include <linux/module.h>
  6. #include <linux/init.h>
  7. #include <linux/kernel.h>
  8. #include <linux/tty.h>
  9. #include <linux/proc_fs.h>
  10. #include <linux/string.h>
  11. #include <linux/pm.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <asm/irq.h>
  16. #include <asm/hardware.h>
  17. #include <asm/setup.h>
  18. #include <asm/mach-types.h>
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/flash.h>
  21. #include <asm/mach/map.h>
  22. #include <asm/mach/serial_sa1100.h>
  23. #include <asm/arch/mcp.h>
  24. #include <asm/arch/simpad.h>
  25. #include <linux/serial_core.h>
  26. #include <linux/ioport.h>
  27. #include <asm/io.h>
  28. #include "generic.h"
  29. long cs3_shadow;
  30. long get_cs3_shadow(void)
  31. {
  32. return cs3_shadow;
  33. }
  34. void set_cs3(long value)
  35. {
  36. *(CS3BUSTYPE *)(CS3_BASE) = cs3_shadow = value;
  37. }
  38. void set_cs3_bit(int value)
  39. {
  40. cs3_shadow |= value;
  41. *(CS3BUSTYPE *)(CS3_BASE) = cs3_shadow;
  42. }
  43. void clear_cs3_bit(int value)
  44. {
  45. cs3_shadow &= ~value;
  46. *(CS3BUSTYPE *)(CS3_BASE) = cs3_shadow;
  47. }
  48. EXPORT_SYMBOL(set_cs3_bit);
  49. EXPORT_SYMBOL(clear_cs3_bit);
  50. static struct map_desc simpad_io_desc[] __initdata = {
  51. { /* MQ200 */
  52. .virtual = 0xf2800000,
  53. .pfn = __phys_to_pfn(0x4b800000),
  54. .length = 0x00800000,
  55. .type = MT_DEVICE
  56. }, { /* Paules CS3, write only */
  57. .virtual = 0xf1000000,
  58. .pfn = __phys_to_pfn(0x18000000),
  59. .length = 0x00100000,
  60. .type = MT_DEVICE
  61. },
  62. };
  63. static void simpad_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
  64. {
  65. if (port->mapbase == (u_int)&Ser1UTCR0) {
  66. if (state)
  67. {
  68. clear_cs3_bit(RS232_ON);
  69. clear_cs3_bit(DECT_POWER_ON);
  70. }else
  71. {
  72. set_cs3_bit(RS232_ON);
  73. set_cs3_bit(DECT_POWER_ON);
  74. }
  75. }
  76. }
  77. static struct sa1100_port_fns simpad_port_fns __initdata = {
  78. .pm = simpad_uart_pm,
  79. };
  80. static struct mtd_partition simpad_partitions[] = {
  81. {
  82. .name = "SIMpad boot firmware",
  83. .size = 0x00080000,
  84. .offset = 0,
  85. .mask_flags = MTD_WRITEABLE,
  86. }, {
  87. .name = "SIMpad kernel",
  88. .size = 0x0010000,
  89. .offset = MTDPART_OFS_APPEND,
  90. }, {
  91. .name = "SIMpad root jffs2",
  92. .size = MTDPART_SIZ_FULL,
  93. .offset = MTDPART_OFS_APPEND,
  94. }
  95. };
  96. static struct flash_platform_data simpad_flash_data = {
  97. .map_name = "cfi_probe",
  98. .parts = simpad_partitions,
  99. .nr_parts = ARRAY_SIZE(simpad_partitions),
  100. };
  101. static struct resource simpad_flash_resources [] = {
  102. {
  103. .start = SA1100_CS0_PHYS,
  104. .end = SA1100_CS0_PHYS + SZ_16M -1,
  105. .flags = IORESOURCE_MEM,
  106. }, {
  107. .start = SA1100_CS1_PHYS,
  108. .end = SA1100_CS1_PHYS + SZ_16M -1,
  109. .flags = IORESOURCE_MEM,
  110. }
  111. };
  112. static struct mcp_plat_data simpad_mcp_data = {
  113. .mccr0 = MCCR0_ADM,
  114. .sclk_rate = 11981000,
  115. };
  116. static void __init simpad_map_io(void)
  117. {
  118. sa1100_map_io();
  119. iotable_init(simpad_io_desc, ARRAY_SIZE(simpad_io_desc));
  120. set_cs3_bit (EN1 | EN0 | LED2_ON | DISPLAY_ON | RS232_ON |
  121. ENABLE_5V | RESET_SIMCARD | DECT_POWER_ON);
  122. sa1100_register_uart_fns(&simpad_port_fns);
  123. sa1100_register_uart(0, 3); /* serial interface */
  124. sa1100_register_uart(1, 1); /* DECT */
  125. // Reassign UART 1 pins
  126. GAFR |= GPIO_UART_TXD | GPIO_UART_RXD;
  127. GPDR |= GPIO_UART_TXD | GPIO_LDD13 | GPIO_LDD15;
  128. GPDR &= ~GPIO_UART_RXD;
  129. PPAR |= PPAR_UPR;
  130. /*
  131. * Set up registers for sleep mode.
  132. */
  133. PWER = PWER_GPIO0| PWER_RTC;
  134. PGSR = 0x818;
  135. PCFR = 0;
  136. PSDR = 0;
  137. sa11x0_set_flash_data(&simpad_flash_data, simpad_flash_resources,
  138. ARRAY_SIZE(simpad_flash_resources));
  139. sa11x0_set_mcp_data(&simpad_mcp_data);
  140. }
  141. static void simpad_power_off(void)
  142. {
  143. local_irq_disable(); // was cli
  144. set_cs3(0x800); /* only SD_MEDIAQ */
  145. /* disable internal oscillator, float CS lines */
  146. PCFR = (PCFR_OPDE | PCFR_FP | PCFR_FS);
  147. /* enable wake-up on GPIO0 (Assabet...) */
  148. PWER = GFER = GRER = 1;
  149. /*
  150. * set scratchpad to zero, just in case it is used as a
  151. * restart address by the bootloader.
  152. */
  153. PSPR = 0;
  154. PGSR = 0;
  155. /* enter sleep mode */
  156. PMCR = PMCR_SF;
  157. while(1);
  158. local_irq_enable(); /* we won't ever call it */
  159. }
  160. /*
  161. * MediaQ Video Device
  162. */
  163. static struct platform_device simpad_mq200fb = {
  164. .name = "simpad-mq200",
  165. .id = 0,
  166. };
  167. static struct platform_device *devices[] __initdata = {
  168. &simpad_mq200fb
  169. };
  170. static int __init simpad_init(void)
  171. {
  172. int ret;
  173. pm_power_off = simpad_power_off;
  174. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  175. if(ret)
  176. printk(KERN_WARNING "simpad: Unable to register mq200 framebuffer device");
  177. return 0;
  178. }
  179. arch_initcall(simpad_init);
  180. MACHINE_START(SIMPAD, "Simpad")
  181. /* Maintainer: Holger Freyther */
  182. .phys_io = 0x80000000,
  183. .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
  184. .boot_params = 0xc0000100,
  185. .map_io = simpad_map_io,
  186. .init_irq = sa1100_init_irq,
  187. .timer = &sa1100_timer,
  188. MACHINE_END