hackkit.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * linux/arch/arm/mach-sa1100/hackkit.c
  3. *
  4. * Copyright (C) 2002 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
  5. *
  6. * This file contains all HackKit tweaks. Based on original work from
  7. * Nicolas Pitre's assabet fixes
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #include <linux/init.h>
  15. #include <linux/kernel.h>
  16. #include <linux/sched.h>
  17. #include <linux/tty.h>
  18. #include <linux/module.h>
  19. #include <linux/errno.h>
  20. #include <linux/cpufreq.h>
  21. #include <linux/platform_data/sa11x0-serial.h>
  22. #include <linux/serial_core.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <linux/tty.h>
  26. #include <linux/gpio.h>
  27. #include <linux/leds.h>
  28. #include <linux/platform_device.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/setup.h>
  31. #include <asm/page.h>
  32. #include <asm/pgtable.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/flash.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/irq.h>
  37. #include <mach/hardware.h>
  38. #include <mach/irqs.h>
  39. #include "generic.h"
  40. /**********************************************************************
  41. * prototypes
  42. */
  43. /* init funcs */
  44. static void __init hackkit_map_io(void);
  45. static u_int hackkit_get_mctrl(struct uart_port *port);
  46. static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl);
  47. static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
  48. /**********************************************************************
  49. * global data
  50. */
  51. /**********************************************************************
  52. * static data
  53. */
  54. static struct map_desc hackkit_io_desc[] __initdata = {
  55. { /* Flash bank 0 */
  56. .virtual = 0xe8000000,
  57. .pfn = __phys_to_pfn(0x00000000),
  58. .length = 0x01000000,
  59. .type = MT_DEVICE
  60. },
  61. };
  62. static struct sa1100_port_fns hackkit_port_fns __initdata = {
  63. .set_mctrl = hackkit_set_mctrl,
  64. .get_mctrl = hackkit_get_mctrl,
  65. .pm = hackkit_uart_pm,
  66. };
  67. /**********************************************************************
  68. * Static functions
  69. */
  70. static void __init hackkit_map_io(void)
  71. {
  72. sa1100_map_io();
  73. iotable_init(hackkit_io_desc, ARRAY_SIZE(hackkit_io_desc));
  74. sa1100_register_uart_fns(&hackkit_port_fns);
  75. sa1100_register_uart(0, 1); /* com port */
  76. sa1100_register_uart(1, 2);
  77. sa1100_register_uart(2, 3); /* radio module */
  78. Ser1SDCR0 |= SDCR0_SUS;
  79. }
  80. /**
  81. * hackkit_uart_pm - powermgmt callback function for system 3 UART
  82. * @port: uart port structure
  83. * @state: pm state
  84. * @oldstate: old pm state
  85. *
  86. */
  87. static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
  88. {
  89. /* TODO: switch on/off uart in powersave mode */
  90. }
  91. /*
  92. * Note! this can be called from IRQ context.
  93. * FIXME: No modem ctrl lines yet.
  94. */
  95. static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl)
  96. {
  97. #if 0
  98. if (port->mapbase == _Ser1UTCR0) {
  99. u_int set = 0, clear = 0;
  100. if (mctrl & TIOCM_RTS)
  101. set |= PT_CTRL2_RS1_RTS;
  102. else
  103. clear |= PT_CTRL2_RS1_RTS;
  104. if (mctrl & TIOCM_DTR)
  105. set |= PT_CTRL2_RS1_DTR;
  106. else
  107. clear |= PT_CTRL2_RS1_DTR;
  108. PTCTRL2_clear(clear);
  109. PTCTRL2_set(set);
  110. }
  111. #endif
  112. }
  113. static u_int hackkit_get_mctrl(struct uart_port *port)
  114. {
  115. u_int ret = 0;
  116. #if 0
  117. u_int irqsr = PT_IRQSR;
  118. /* need 2 reads to read current value */
  119. irqsr = PT_IRQSR;
  120. /* TODO: check IRQ source register for modem/com
  121. status lines and set them correctly. */
  122. #endif
  123. ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
  124. return ret;
  125. }
  126. static struct mtd_partition hackkit_partitions[] = {
  127. {
  128. .name = "BLOB",
  129. .size = 0x00040000,
  130. .offset = 0x00000000,
  131. .mask_flags = MTD_WRITEABLE, /* force read-only */
  132. }, {
  133. .name = "config",
  134. .size = 0x00040000,
  135. .offset = MTDPART_OFS_APPEND,
  136. }, {
  137. .name = "kernel",
  138. .size = 0x00100000,
  139. .offset = MTDPART_OFS_APPEND,
  140. }, {
  141. .name = "initrd",
  142. .size = 0x00180000,
  143. .offset = MTDPART_OFS_APPEND,
  144. }, {
  145. .name = "rootfs",
  146. .size = 0x700000,
  147. .offset = MTDPART_OFS_APPEND,
  148. }, {
  149. .name = "data",
  150. .size = MTDPART_SIZ_FULL,
  151. .offset = MTDPART_OFS_APPEND,
  152. }
  153. };
  154. static struct flash_platform_data hackkit_flash_data = {
  155. .map_name = "cfi_probe",
  156. .parts = hackkit_partitions,
  157. .nr_parts = ARRAY_SIZE(hackkit_partitions),
  158. };
  159. static struct resource hackkit_flash_resource =
  160. DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
  161. /* LEDs */
  162. struct gpio_led hackkit_gpio_leds[] = {
  163. {
  164. .name = "hackkit:red",
  165. .default_trigger = "cpu0",
  166. .gpio = 22,
  167. },
  168. {
  169. .name = "hackkit:green",
  170. .default_trigger = "heartbeat",
  171. .gpio = 23,
  172. },
  173. };
  174. static struct gpio_led_platform_data hackkit_gpio_led_info = {
  175. .leds = hackkit_gpio_leds,
  176. .num_leds = ARRAY_SIZE(hackkit_gpio_leds),
  177. };
  178. static struct platform_device hackkit_leds = {
  179. .name = "leds-gpio",
  180. .id = -1,
  181. .dev = {
  182. .platform_data = &hackkit_gpio_led_info,
  183. }
  184. };
  185. static void __init hackkit_init(void)
  186. {
  187. sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1);
  188. platform_device_register(&hackkit_leds);
  189. }
  190. /**********************************************************************
  191. * Exported Functions
  192. */
  193. MACHINE_START(HACKKIT, "HackKit Cpu Board")
  194. .atag_offset = 0x100,
  195. .map_io = hackkit_map_io,
  196. .nr_irqs = SA1100_NR_IRQS,
  197. .init_irq = sa1100_init_irq,
  198. .init_time = sa1100_timer_init,
  199. .init_machine = hackkit_init,
  200. .init_late = sa11x0_init_late,
  201. .restart = sa11x0_restart,
  202. MACHINE_END