hackkit.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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/serial_core.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <mach/hardware.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/setup.h>
  27. #include <asm/page.h>
  28. #include <asm/pgtable.h>
  29. #include <asm/irq.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/flash.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/irq.h>
  34. #include <asm/mach/serial_sa1100.h>
  35. #include "generic.h"
  36. /**********************************************************************
  37. * prototypes
  38. */
  39. /* init funcs */
  40. static void __init hackkit_map_io(void);
  41. static u_int hackkit_get_mctrl(struct uart_port *port);
  42. static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl);
  43. static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
  44. /**********************************************************************
  45. * global data
  46. */
  47. /**********************************************************************
  48. * static data
  49. */
  50. static struct map_desc hackkit_io_desc[] __initdata = {
  51. { /* Flash bank 0 */
  52. .virtual = 0xe8000000,
  53. .pfn = __phys_to_pfn(0x00000000),
  54. .length = 0x01000000,
  55. .type = MT_DEVICE
  56. },
  57. };
  58. static struct sa1100_port_fns hackkit_port_fns __initdata = {
  59. .set_mctrl = hackkit_set_mctrl,
  60. .get_mctrl = hackkit_get_mctrl,
  61. .pm = hackkit_uart_pm,
  62. };
  63. /**********************************************************************
  64. * Static functions
  65. */
  66. static void __init hackkit_map_io(void)
  67. {
  68. sa1100_map_io();
  69. iotable_init(hackkit_io_desc, ARRAY_SIZE(hackkit_io_desc));
  70. sa1100_register_uart_fns(&hackkit_port_fns);
  71. sa1100_register_uart(0, 1); /* com port */
  72. sa1100_register_uart(1, 2);
  73. sa1100_register_uart(2, 3); /* radio module */
  74. Ser1SDCR0 |= SDCR0_SUS;
  75. }
  76. /**
  77. * hackkit_uart_pm - powermgmt callback function for system 3 UART
  78. * @port: uart port structure
  79. * @state: pm state
  80. * @oldstate: old pm state
  81. *
  82. */
  83. static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
  84. {
  85. /* TODO: switch on/off uart in powersave mode */
  86. }
  87. /*
  88. * Note! this can be called from IRQ context.
  89. * FIXME: No modem ctrl lines yet.
  90. */
  91. static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl)
  92. {
  93. #if 0
  94. if (port->mapbase == _Ser1UTCR0) {
  95. u_int set = 0, clear = 0;
  96. if (mctrl & TIOCM_RTS)
  97. set |= PT_CTRL2_RS1_RTS;
  98. else
  99. clear |= PT_CTRL2_RS1_RTS;
  100. if (mctrl & TIOCM_DTR)
  101. set |= PT_CTRL2_RS1_DTR;
  102. else
  103. clear |= PT_CTRL2_RS1_DTR;
  104. PTCTRL2_clear(clear);
  105. PTCTRL2_set(set);
  106. }
  107. #endif
  108. }
  109. static u_int hackkit_get_mctrl(struct uart_port *port)
  110. {
  111. u_int ret = 0;
  112. #if 0
  113. u_int irqsr = PT_IRQSR;
  114. /* need 2 reads to read current value */
  115. irqsr = PT_IRQSR;
  116. /* TODO: check IRQ source register for modem/com
  117. status lines and set them correctly. */
  118. #endif
  119. ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
  120. return ret;
  121. }
  122. static struct mtd_partition hackkit_partitions[] = {
  123. {
  124. .name = "BLOB",
  125. .size = 0x00040000,
  126. .offset = 0x00000000,
  127. .mask_flags = MTD_WRITEABLE, /* force read-only */
  128. }, {
  129. .name = "config",
  130. .size = 0x00040000,
  131. .offset = MTDPART_OFS_APPEND,
  132. }, {
  133. .name = "kernel",
  134. .size = 0x00100000,
  135. .offset = MTDPART_OFS_APPEND,
  136. }, {
  137. .name = "initrd",
  138. .size = 0x00180000,
  139. .offset = MTDPART_OFS_APPEND,
  140. }, {
  141. .name = "rootfs",
  142. .size = 0x700000,
  143. .offset = MTDPART_OFS_APPEND,
  144. }, {
  145. .name = "data",
  146. .size = MTDPART_SIZ_FULL,
  147. .offset = MTDPART_OFS_APPEND,
  148. }
  149. };
  150. static struct flash_platform_data hackkit_flash_data = {
  151. .map_name = "cfi_probe",
  152. .parts = hackkit_partitions,
  153. .nr_parts = ARRAY_SIZE(hackkit_partitions),
  154. };
  155. static struct resource hackkit_flash_resource = {
  156. .start = SA1100_CS0_PHYS,
  157. .end = SA1100_CS0_PHYS + SZ_32M,
  158. .flags = IORESOURCE_MEM,
  159. };
  160. static void __init hackkit_init(void)
  161. {
  162. sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1);
  163. }
  164. /**********************************************************************
  165. * Exported Functions
  166. */
  167. MACHINE_START(HACKKIT, "HackKit Cpu Board")
  168. .boot_params = 0xc0000100,
  169. .map_io = hackkit_map_io,
  170. .init_irq = sa1100_init_irq,
  171. .timer = &sa1100_timer,
  172. .init_machine = hackkit_init,
  173. MACHINE_END