simpad.c 4.7 KB

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