mach-smartq7.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * linux/arch/arm/mach-s3c64xx/mach-smartq7.c
  3. *
  4. * Copyright (C) 2010 Maurus Cuelenaere
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/fb.h>
  12. #include <linux/gpio.h>
  13. #include <linux/gpio_keys.h>
  14. #include <linux/i2c-gpio.h>
  15. #include <linux/init.h>
  16. #include <linux/input.h>
  17. #include <linux/leds.h>
  18. #include <linux/platform_device.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/mach/arch.h>
  21. #include <mach/map.h>
  22. #include <mach/regs-fb.h>
  23. #include <mach/regs-gpio.h>
  24. #include <mach/s3c6410.h>
  25. #include <plat/cpu.h>
  26. #include <plat/devs.h>
  27. #include <plat/fb.h>
  28. #include <plat/gpio-cfg.h>
  29. #include "mach-smartq.h"
  30. static void __init smartq7_lcd_setup_gpio(void)
  31. {
  32. gpio_request(S3C64XX_GPM(0), "LCD CSB pin");
  33. gpio_request(S3C64XX_GPM(3), "LCD power");
  34. gpio_request(S3C64XX_GPM(4), "LCD power status");
  35. /* turn power off */
  36. gpio_direction_output(S3C64XX_GPM(0), 1);
  37. gpio_direction_output(S3C64XX_GPM(3), 0);
  38. gpio_direction_input(S3C64XX_GPM(4));
  39. }
  40. static struct i2c_gpio_platform_data smartq7_lcd_control = {
  41. .sda_pin = S3C64XX_GPM(2),
  42. .scl_pin = S3C64XX_GPM(1),
  43. .sda_is_open_drain = 1,
  44. .scl_is_open_drain = 1,
  45. };
  46. static struct platform_device smartq7_lcd_control_device = {
  47. .name = "i2c-gpio",
  48. .id = 1,
  49. .dev.platform_data = &smartq7_lcd_control,
  50. };
  51. static struct gpio_led smartq7_leds[] __initdata = {
  52. {
  53. .name = "smartq7:red",
  54. .active_low = 1,
  55. .gpio = S3C64XX_GPN(8),
  56. },
  57. {
  58. .name = "smartq7:green",
  59. .active_low = 1,
  60. .gpio = S3C64XX_GPN(9),
  61. },
  62. };
  63. static struct gpio_led_platform_data smartq7_led_data = {
  64. .num_leds = ARRAY_SIZE(smartq7_leds),
  65. .leds = smartq7_leds,
  66. };
  67. static struct platform_device smartq7_leds_device = {
  68. .name = "leds-gpio",
  69. .id = -1,
  70. .dev.platform_data = &smartq7_led_data,
  71. };
  72. /* Labels according to the SmartQ manual */
  73. static struct gpio_keys_button smartq7_buttons[] = {
  74. {
  75. .gpio = S3C64XX_GPL(14),
  76. .code = KEY_POWER,
  77. .desc = "Power",
  78. .active_low = 1,
  79. .debounce_interval = 5,
  80. .type = EV_KEY,
  81. },
  82. {
  83. .gpio = S3C64XX_GPN(2),
  84. .code = KEY_FN,
  85. .desc = "Function",
  86. .active_low = 1,
  87. .debounce_interval = 5,
  88. .type = EV_KEY,
  89. },
  90. {
  91. .gpio = S3C64XX_GPN(3),
  92. .code = KEY_KPMINUS,
  93. .desc = "Minus",
  94. .active_low = 1,
  95. .debounce_interval = 5,
  96. .type = EV_KEY,
  97. },
  98. {
  99. .gpio = S3C64XX_GPN(4),
  100. .code = KEY_KPPLUS,
  101. .desc = "Plus",
  102. .active_low = 1,
  103. .debounce_interval = 5,
  104. .type = EV_KEY,
  105. },
  106. {
  107. .gpio = S3C64XX_GPN(12),
  108. .code = KEY_ENTER,
  109. .desc = "Enter",
  110. .active_low = 1,
  111. .debounce_interval = 5,
  112. .type = EV_KEY,
  113. },
  114. {
  115. .gpio = S3C64XX_GPN(15),
  116. .code = KEY_ESC,
  117. .desc = "Cancel",
  118. .active_low = 1,
  119. .debounce_interval = 5,
  120. .type = EV_KEY,
  121. },
  122. };
  123. static struct gpio_keys_platform_data smartq7_buttons_data = {
  124. .buttons = smartq7_buttons,
  125. .nbuttons = ARRAY_SIZE(smartq7_buttons),
  126. };
  127. static struct platform_device smartq7_buttons_device = {
  128. .name = "gpio-keys",
  129. .id = 0,
  130. .num_resources = 0,
  131. .dev = {
  132. .platform_data = &smartq7_buttons_data,
  133. }
  134. };
  135. static struct s3c_fb_pd_win smartq7_fb_win0 = {
  136. .win_mode = {
  137. .pixclock = 1000000000000ULL /
  138. ((3+10+5+800)*(1+3+20+480)*80),
  139. .left_margin = 3,
  140. .right_margin = 5,
  141. .upper_margin = 1,
  142. .lower_margin = 20,
  143. .hsync_len = 10,
  144. .vsync_len = 3,
  145. .xres = 800,
  146. .yres = 480,
  147. },
  148. .max_bpp = 32,
  149. .default_bpp = 16,
  150. };
  151. static struct s3c_fb_platdata smartq7_lcd_pdata __initdata = {
  152. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  153. .win[0] = &smartq7_fb_win0,
  154. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  155. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC |
  156. VIDCON1_INV_VCLK,
  157. };
  158. static struct platform_device *smartq7_devices[] __initdata = {
  159. &smartq7_leds_device,
  160. &smartq7_buttons_device,
  161. &smartq7_lcd_control_device,
  162. };
  163. static void __init smartq7_machine_init(void)
  164. {
  165. s3c_fb_set_platdata(&smartq7_lcd_pdata);
  166. smartq_machine_init();
  167. smartq7_lcd_setup_gpio();
  168. platform_add_devices(smartq7_devices, ARRAY_SIZE(smartq7_devices));
  169. }
  170. MACHINE_START(SMARTQ7, "SmartQ 7")
  171. /* Maintainer: Maurus Cuelenaere <mcuelenaere AT gmail DOT com> */
  172. .phys_io = S3C_PA_UART & 0xfff00000,
  173. .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
  174. .boot_params = S3C64XX_PA_SDRAM + 0x100,
  175. .init_irq = s3c6410_init_irq,
  176. .map_io = smartq_map_io,
  177. .init_machine = smartq7_machine_init,
  178. .timer = &s3c24xx_timer,
  179. MACHINE_END