mach-anw6410.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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/serial_s3c.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/io.h>
  25. #include <linux/i2c.h>
  26. #include <linux/fb.h>
  27. #include <linux/gpio.h>
  28. #include <linux/delay.h>
  29. #include <linux/dm9000.h>
  30. #include <video/platform_lcd.h>
  31. #include <video/samsung_fimd.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <asm/mach/irq.h>
  35. #include <mach/hardware.h>
  36. #include <mach/map.h>
  37. #include <asm/irq.h>
  38. #include <asm/mach-types.h>
  39. #include <linux/platform_data/i2c-s3c2410.h>
  40. #include <plat/fb.h>
  41. #include <plat/devs.h>
  42. #include <plat/cpu.h>
  43. #include <mach/irqs.h>
  44. #include <mach/regs-gpio.h>
  45. #include <mach/gpio-samsung.h>
  46. #include <plat/samsung-time.h>
  47. #include "common.h"
  48. #include "regs-modem.h"
  49. /* DM9000 */
  50. #define ANW6410_PA_DM9000 (0x18000000)
  51. /* A hardware buffer to control external devices is mapped at 0x30000000.
  52. * It can not be read. So current status must be kept in anw6410_extdev_status.
  53. */
  54. #define ANW6410_VA_EXTDEV S3C_ADDR(0x02000000)
  55. #define ANW6410_PA_EXTDEV (0x30000000)
  56. #define ANW6410_EN_DM9000 (1<<11)
  57. #define ANW6410_EN_LCD (1<<14)
  58. static __u32 anw6410_extdev_status;
  59. static struct s3c2410_uartcfg anw6410_uartcfgs[] __initdata = {
  60. [0] = {
  61. .hwport = 0,
  62. .flags = 0,
  63. .ucon = 0x3c5,
  64. .ulcon = 0x03,
  65. .ufcon = 0x51,
  66. },
  67. [1] = {
  68. .hwport = 1,
  69. .flags = 0,
  70. .ucon = 0x3c5,
  71. .ulcon = 0x03,
  72. .ufcon = 0x51,
  73. },
  74. };
  75. /* framebuffer and LCD setup. */
  76. static void __init anw6410_lcd_mode_set(void)
  77. {
  78. u32 tmp;
  79. /* set the LCD type */
  80. tmp = __raw_readl(S3C64XX_SPCON);
  81. tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
  82. tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
  83. __raw_writel(tmp, S3C64XX_SPCON);
  84. /* remove the LCD bypass */
  85. tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
  86. tmp &= ~MIFPCON_LCD_BYPASS;
  87. __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
  88. }
  89. /* GPF1 = LCD panel power
  90. * GPF4 = LCD backlight control
  91. */
  92. static void anw6410_lcd_power_set(struct plat_lcd_data *pd,
  93. unsigned int power)
  94. {
  95. if (power) {
  96. anw6410_extdev_status |= (ANW6410_EN_LCD << 16);
  97. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  98. gpio_direction_output(S3C64XX_GPF(1), 1);
  99. gpio_direction_output(S3C64XX_GPF(4), 1);
  100. } else {
  101. anw6410_extdev_status &= ~(ANW6410_EN_LCD << 16);
  102. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  103. gpio_direction_output(S3C64XX_GPF(1), 0);
  104. gpio_direction_output(S3C64XX_GPF(4), 0);
  105. }
  106. }
  107. static struct plat_lcd_data anw6410_lcd_power_data = {
  108. .set_power = anw6410_lcd_power_set,
  109. };
  110. static struct platform_device anw6410_lcd_powerdev = {
  111. .name = "platform-lcd",
  112. .dev.parent = &s3c_device_fb.dev,
  113. .dev.platform_data = &anw6410_lcd_power_data,
  114. };
  115. static struct s3c_fb_pd_win anw6410_fb_win0 = {
  116. .max_bpp = 32,
  117. .default_bpp = 16,
  118. .xres = 800,
  119. .yres = 480,
  120. };
  121. static struct fb_videomode anw6410_lcd_timing = {
  122. .left_margin = 8,
  123. .right_margin = 13,
  124. .upper_margin = 7,
  125. .lower_margin = 5,
  126. .hsync_len = 3,
  127. .vsync_len = 1,
  128. .xres = 800,
  129. .yres = 480,
  130. };
  131. /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
  132. static struct s3c_fb_platdata anw6410_lcd_pdata __initdata = {
  133. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  134. .vtiming = &anw6410_lcd_timing,
  135. .win[0] = &anw6410_fb_win0,
  136. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  137. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  138. };
  139. /* DM9000AEP 10/100 ethernet controller */
  140. static void __init anw6410_dm9000_enable(void)
  141. {
  142. anw6410_extdev_status |= (ANW6410_EN_DM9000 << 16);
  143. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  144. }
  145. static struct resource anw6410_dm9000_resource[] = {
  146. [0] = DEFINE_RES_MEM(ANW6410_PA_DM9000, 4),
  147. [1] = DEFINE_RES_MEM(ANW6410_PA_DM9000 + 4, 501),
  148. [2] = DEFINE_RES_NAMED(IRQ_EINT(15), 1, NULL, IORESOURCE_IRQ \
  149. | IRQF_TRIGGER_HIGH),
  150. };
  151. static struct dm9000_plat_data anw6410_dm9000_pdata = {
  152. .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
  153. /* dev_addr can be set to provide hwaddr. */
  154. };
  155. static struct platform_device anw6410_device_eth = {
  156. .name = "dm9000",
  157. .id = -1,
  158. .num_resources = ARRAY_SIZE(anw6410_dm9000_resource),
  159. .resource = anw6410_dm9000_resource,
  160. .dev = {
  161. .platform_data = &anw6410_dm9000_pdata,
  162. },
  163. };
  164. static struct map_desc anw6410_iodesc[] __initdata = {
  165. {
  166. .virtual = (unsigned long)ANW6410_VA_EXTDEV,
  167. .pfn = __phys_to_pfn(ANW6410_PA_EXTDEV),
  168. .length = SZ_64K,
  169. .type = MT_DEVICE,
  170. },
  171. };
  172. static struct platform_device *anw6410_devices[] __initdata = {
  173. &s3c_device_fb,
  174. &anw6410_lcd_powerdev,
  175. &anw6410_device_eth,
  176. };
  177. static void __init anw6410_map_io(void)
  178. {
  179. s3c64xx_init_io(anw6410_iodesc, ARRAY_SIZE(anw6410_iodesc));
  180. s3c64xx_set_xtal_freq(12000000);
  181. s3c24xx_init_uarts(anw6410_uartcfgs, ARRAY_SIZE(anw6410_uartcfgs));
  182. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  183. anw6410_lcd_mode_set();
  184. }
  185. static void __init anw6410_machine_init(void)
  186. {
  187. s3c_fb_set_platdata(&anw6410_lcd_pdata);
  188. gpio_request(S3C64XX_GPF(1), "panel power");
  189. gpio_request(S3C64XX_GPF(4), "LCD backlight");
  190. anw6410_dm9000_enable();
  191. platform_add_devices(anw6410_devices, ARRAY_SIZE(anw6410_devices));
  192. }
  193. MACHINE_START(ANW6410, "A&W6410")
  194. /* Maintainer: Kwangwoo Lee <kwangwoo.lee@gmail.com> */
  195. .atag_offset = 0x100,
  196. .nr_irqs = S3C64XX_NR_IRQS,
  197. .init_irq = s3c6410_init_irq,
  198. .map_io = anw6410_map_io,
  199. .init_machine = anw6410_machine_init,
  200. .init_time = samsung_timer_init,
  201. .restart = s3c64xx_restart,
  202. MACHINE_END