simpad.c 4.5 KB

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