simpad.c 4.7 KB

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