mach-n30.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* Machine specific code for the Acer n30 PDA.
  2. *
  3. * Copyright (c) 2003-2005 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * Copyright (c) 2005-2008 Christer Weinigel <christer@weinigel.se>
  7. *
  8. * There is a wiki with more information about the n30 port at
  9. * http://handhelds.org/moin/moin.cgi/AcerN30Documentation .
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/types.h>
  17. #include <linux/delay.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/init.h>
  20. #include <linux/input.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/serial_core.h>
  24. #include <linux/timer.h>
  25. #include <asm/hardware.h>
  26. #include <asm/io.h>
  27. #include <asm/irq.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/arch/regs-gpio.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/irq.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/plat-s3c/iic.h>
  34. #include <asm/plat-s3c/regs-serial.h>
  35. #include <asm/plat-s3c24xx/clock.h>
  36. #include <asm/plat-s3c24xx/cpu.h>
  37. #include <asm/plat-s3c24xx/devs.h>
  38. #include <asm/plat-s3c24xx/s3c2410.h>
  39. #include <asm/plat-s3c24xx/udc.h>
  40. static struct map_desc n30_iodesc[] __initdata = {
  41. /* nothing here yet */
  42. };
  43. static struct s3c2410_uartcfg n30_uartcfgs[] = {
  44. /* Normal serial port */
  45. [0] = {
  46. .hwport = 0,
  47. .flags = 0,
  48. .ucon = 0x2c5,
  49. .ulcon = 0x03,
  50. .ufcon = 0x51,
  51. },
  52. /* IR port */
  53. [1] = {
  54. .hwport = 1,
  55. .flags = 0,
  56. .uart_flags = UPF_CONS_FLOW,
  57. .ucon = 0x2c5,
  58. .ulcon = 0x43,
  59. .ufcon = 0x51,
  60. },
  61. /* The BlueTooth controller is connected to port 2 */
  62. [2] = {
  63. .hwport = 2,
  64. .flags = 0,
  65. .ucon = 0x2c5,
  66. .ulcon = 0x03,
  67. .ufcon = 0x51,
  68. },
  69. };
  70. static void n30_udc_pullup(enum s3c2410_udc_cmd_e cmd)
  71. {
  72. switch (cmd)
  73. {
  74. case S3C2410_UDC_P_ENABLE :
  75. s3c2410_gpio_setpin(S3C2410_GPB3, 1);
  76. break;
  77. case S3C2410_UDC_P_DISABLE :
  78. s3c2410_gpio_setpin(S3C2410_GPB3, 0);
  79. break;
  80. case S3C2410_UDC_P_RESET :
  81. break;
  82. default:
  83. break;
  84. }
  85. }
  86. static struct s3c2410_udc_mach_info n30_udc_cfg __initdata = {
  87. .udc_command = n30_udc_pullup,
  88. .vbus_pin = S3C2410_GPG1,
  89. .vbus_pin_inverted = 0,
  90. };
  91. static struct gpio_keys_button n30_buttons[] = {
  92. {
  93. .gpio = S3C2410_GPF0,
  94. .code = KEY_POWER,
  95. .desc = "Power",
  96. .active_low = 0,
  97. },
  98. {
  99. .gpio = S3C2410_GPG9,
  100. .code = KEY_UP,
  101. .desc = "Thumbwheel Up",
  102. .active_low = 0,
  103. },
  104. {
  105. .gpio = S3C2410_GPG8,
  106. .code = KEY_DOWN,
  107. .desc = "Thumbwheel Down",
  108. .active_low = 0,
  109. },
  110. {
  111. .gpio = S3C2410_GPG7,
  112. .code = KEY_ENTER,
  113. .desc = "Thumbwheel Press",
  114. .active_low = 0,
  115. },
  116. {
  117. .gpio = S3C2410_GPF7,
  118. .code = KEY_HOMEPAGE,
  119. .desc = "Home",
  120. .active_low = 0,
  121. },
  122. {
  123. .gpio = S3C2410_GPF6,
  124. .code = KEY_CALENDAR,
  125. .desc = "Calendar",
  126. .active_low = 0,
  127. },
  128. {
  129. .gpio = S3C2410_GPF5,
  130. .code = KEY_ADDRESSBOOK,
  131. .desc = "Contacts",
  132. .active_low = 0,
  133. },
  134. {
  135. .gpio = S3C2410_GPF4,
  136. .code = KEY_MAIL,
  137. .desc = "Mail",
  138. .active_low = 0,
  139. },
  140. };
  141. static struct gpio_keys_platform_data n30_button_data = {
  142. .buttons = n30_buttons,
  143. .nbuttons = ARRAY_SIZE(n30_buttons),
  144. };
  145. static struct platform_device n30_button_device = {
  146. .name = "gpio-keys",
  147. .id = -1,
  148. .dev = {
  149. .platform_data = &n30_button_data,
  150. }
  151. };
  152. static struct platform_device *n30_devices[] __initdata = {
  153. &s3c_device_lcd,
  154. &s3c_device_wdt,
  155. &s3c_device_i2c,
  156. &s3c_device_iis,
  157. &s3c_device_usb,
  158. &s3c_device_usbgadget,
  159. &n30_button_device,
  160. };
  161. static struct s3c2410_platform_i2c n30_i2ccfg = {
  162. .flags = 0,
  163. .slave_addr = 0x10,
  164. .bus_freq = 10*1000,
  165. .max_freq = 10*1000,
  166. };
  167. static void __init n30_map_io(void)
  168. {
  169. s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
  170. s3c24xx_init_clocks(0);
  171. s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
  172. }
  173. static void __init n30_init_irq(void)
  174. {
  175. s3c24xx_init_irq();
  176. }
  177. /* GPB3 is the line that controls the pull-up for the USB D+ line */
  178. static void __init n30_init(void)
  179. {
  180. s3c_device_i2c.dev.platform_data = &n30_i2ccfg;
  181. s3c24xx_udc_set_platdata(&n30_udc_cfg);
  182. /* Turn off suspend on both USB ports, and switch the
  183. * selectable USB port to USB device mode. */
  184. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  185. S3C2410_MISCCR_USBSUSPND0 |
  186. S3C2410_MISCCR_USBSUSPND1, 0x0);
  187. platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
  188. }
  189. MACHINE_START(N30, "Acer-N30")
  190. /* Maintainer: Christer Weinigel <christer@weinigel.se>,
  191. Ben Dooks <ben-linux@fluff.org>
  192. */
  193. .phys_io = S3C2410_PA_UART,
  194. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  195. .boot_params = S3C2410_SDRAM_PA + 0x100,
  196. .timer = &s3c24xx_timer,
  197. .init_machine = n30_init,
  198. .init_irq = n30_init_irq,
  199. .map_io = n30_map_io,
  200. MACHINE_END