mach-anw6410.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /* linux/arch/arm/mach-s3c64xx/mach-anw6410.c
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. * Copyright 2009 Kwangwoo Lee
  8. * Kwangwoo Lee <kwangwoo.lee@gmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. *
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/types.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/list.h>
  19. #include <linux/timer.h>
  20. #include <linux/init.h>
  21. #include <linux/serial_core.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/io.h>
  24. #include <linux/i2c.h>
  25. #include <linux/fb.h>
  26. #include <linux/gpio.h>
  27. #include <linux/delay.h>
  28. #include <linux/dm9000.h>
  29. #include <video/platform_lcd.h>
  30. #include <asm/hardware/vic.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/irq.h>
  34. #include <mach/hardware.h>
  35. #include <mach/map.h>
  36. #include <asm/irq.h>
  37. #include <asm/mach-types.h>
  38. #include <plat/regs-serial.h>
  39. #include <plat/iic.h>
  40. #include <plat/fb.h>
  41. #include <plat/regs-fb-v4.h>
  42. #include <plat/clock.h>
  43. #include <plat/devs.h>
  44. #include <plat/cpu.h>
  45. #include <mach/regs-gpio.h>
  46. #include <mach/regs-modem.h>
  47. #include "common.h"
  48. /* DM9000 */
  49. #define ANW6410_PA_DM9000 (0x18000000)
  50. /* A hardware buffer to control external devices is mapped at 0x30000000.
  51. * It can not be read. So current status must be kept in anw6410_extdev_status.
  52. */
  53. #define ANW6410_VA_EXTDEV S3C_ADDR(0x02000000)
  54. #define ANW6410_PA_EXTDEV (0x30000000)
  55. #define ANW6410_EN_DM9000 (1<<11)
  56. #define ANW6410_EN_LCD (1<<14)
  57. static __u32 anw6410_extdev_status;
  58. static struct s3c2410_uartcfg anw6410_uartcfgs[] __initdata = {
  59. [0] = {
  60. .hwport = 0,
  61. .flags = 0,
  62. .ucon = 0x3c5,
  63. .ulcon = 0x03,
  64. .ufcon = 0x51,
  65. },
  66. [1] = {
  67. .hwport = 1,
  68. .flags = 0,
  69. .ucon = 0x3c5,
  70. .ulcon = 0x03,
  71. .ufcon = 0x51,
  72. },
  73. };
  74. /* framebuffer and LCD setup. */
  75. static void __init anw6410_lcd_mode_set(void)
  76. {
  77. u32 tmp;
  78. /* set the LCD type */
  79. tmp = __raw_readl(S3C64XX_SPCON);
  80. tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
  81. tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
  82. __raw_writel(tmp, S3C64XX_SPCON);
  83. /* remove the LCD bypass */
  84. tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
  85. tmp &= ~MIFPCON_LCD_BYPASS;
  86. __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
  87. }
  88. /* GPF1 = LCD panel power
  89. * GPF4 = LCD backlight control
  90. */
  91. static void anw6410_lcd_power_set(struct plat_lcd_data *pd,
  92. unsigned int power)
  93. {
  94. if (power) {
  95. anw6410_extdev_status |= (ANW6410_EN_LCD << 16);
  96. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  97. gpio_direction_output(S3C64XX_GPF(1), 1);
  98. gpio_direction_output(S3C64XX_GPF(4), 1);
  99. } else {
  100. anw6410_extdev_status &= ~(ANW6410_EN_LCD << 16);
  101. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  102. gpio_direction_output(S3C64XX_GPF(1), 0);
  103. gpio_direction_output(S3C64XX_GPF(4), 0);
  104. }
  105. }
  106. static struct plat_lcd_data anw6410_lcd_power_data = {
  107. .set_power = anw6410_lcd_power_set,
  108. };
  109. static struct platform_device anw6410_lcd_powerdev = {
  110. .name = "platform-lcd",
  111. .dev.parent = &s3c_device_fb.dev,
  112. .dev.platform_data = &anw6410_lcd_power_data,
  113. };
  114. static struct s3c_fb_pd_win anw6410_fb_win0 = {
  115. /* this is to ensure we use win0 */
  116. .win_mode = {
  117. .left_margin = 8,
  118. .right_margin = 13,
  119. .upper_margin = 7,
  120. .lower_margin = 5,
  121. .hsync_len = 3,
  122. .vsync_len = 1,
  123. .xres = 800,
  124. .yres = 480,
  125. },
  126. .max_bpp = 32,
  127. .default_bpp = 16,
  128. };
  129. /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
  130. static struct s3c_fb_platdata anw6410_lcd_pdata __initdata = {
  131. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  132. .win[0] = &anw6410_fb_win0,
  133. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  134. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  135. };
  136. /* DM9000AEP 10/100 ethernet controller */
  137. static void __init anw6410_dm9000_enable(void)
  138. {
  139. anw6410_extdev_status |= (ANW6410_EN_DM9000 << 16);
  140. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  141. }
  142. static struct resource anw6410_dm9000_resource[] = {
  143. [0] = {
  144. .start = ANW6410_PA_DM9000,
  145. .end = ANW6410_PA_DM9000 + 3,
  146. .flags = IORESOURCE_MEM,
  147. },
  148. [1] = {
  149. .start = ANW6410_PA_DM9000 + 4,
  150. .end = ANW6410_PA_DM9000 + 4 + 500,
  151. .flags = IORESOURCE_MEM,
  152. },
  153. [2] = {
  154. .start = IRQ_EINT(15),
  155. .end = IRQ_EINT(15),
  156. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
  157. },
  158. };
  159. static struct dm9000_plat_data anw6410_dm9000_pdata = {
  160. .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
  161. /* dev_addr can be set to provide hwaddr. */
  162. };
  163. static struct platform_device anw6410_device_eth = {
  164. .name = "dm9000",
  165. .id = -1,
  166. .num_resources = ARRAY_SIZE(anw6410_dm9000_resource),
  167. .resource = anw6410_dm9000_resource,
  168. .dev = {
  169. .platform_data = &anw6410_dm9000_pdata,
  170. },
  171. };
  172. static struct map_desc anw6410_iodesc[] __initdata = {
  173. {
  174. .virtual = (unsigned long)ANW6410_VA_EXTDEV,
  175. .pfn = __phys_to_pfn(ANW6410_PA_EXTDEV),
  176. .length = SZ_64K,
  177. .type = MT_DEVICE,
  178. },
  179. };
  180. static struct platform_device *anw6410_devices[] __initdata = {
  181. &s3c_device_fb,
  182. &anw6410_lcd_powerdev,
  183. &anw6410_device_eth,
  184. };
  185. static void __init anw6410_map_io(void)
  186. {
  187. s3c64xx_init_io(anw6410_iodesc, ARRAY_SIZE(anw6410_iodesc));
  188. s3c24xx_init_clocks(12000000);
  189. s3c24xx_init_uarts(anw6410_uartcfgs, ARRAY_SIZE(anw6410_uartcfgs));
  190. anw6410_lcd_mode_set();
  191. }
  192. static void __init anw6410_machine_init(void)
  193. {
  194. s3c_fb_set_platdata(&anw6410_lcd_pdata);
  195. gpio_request(S3C64XX_GPF(1), "panel power");
  196. gpio_request(S3C64XX_GPF(4), "LCD backlight");
  197. anw6410_dm9000_enable();
  198. platform_add_devices(anw6410_devices, ARRAY_SIZE(anw6410_devices));
  199. }
  200. MACHINE_START(ANW6410, "A&W6410")
  201. /* Maintainer: Kwangwoo Lee <kwangwoo.lee@gmail.com> */
  202. .atag_offset = 0x100,
  203. .init_irq = s3c6410_init_irq,
  204. .handle_irq = vic_handle_irq,
  205. .map_io = anw6410_map_io,
  206. .init_machine = anw6410_machine_init,
  207. .timer = &s3c24xx_timer,
  208. .restart = s3c64xx_restart,
  209. MACHINE_END