mach-amlm5900.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. // SPDX-License-Identifier: GPL-2.0+
  2. //
  3. // Copyright (c) 2006 American Microsystems Limited
  4. // David Anders <danders@amltd.com>
  5. //
  6. // @History:
  7. // derived from linux/arch/arm/mach-s3c2410/mach-bast.c, written by
  8. // Ben Dooks <ben@simtec.co.uk>
  9. #include <linux/kernel.h>
  10. #include <linux/types.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/list.h>
  13. #include <linux/timer.h>
  14. #include <linux/init.h>
  15. #include <linux/gpio.h>
  16. #include <linux/device.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/proc_fs.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/serial_s3c.h>
  21. #include <linux/io.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/mach/map.h>
  24. #include <asm/mach/irq.h>
  25. #include <asm/mach/flash.h>
  26. #include <mach/hardware.h>
  27. #include <asm/irq.h>
  28. #include <asm/mach-types.h>
  29. #include <mach/fb.h>
  30. #include <mach/regs-lcd.h>
  31. #include <mach/regs-gpio.h>
  32. #include <mach/gpio-samsung.h>
  33. #include <linux/platform_data/i2c-s3c2410.h>
  34. #include <plat/devs.h>
  35. #include <plat/cpu.h>
  36. #include <plat/gpio-cfg.h>
  37. #include <linux/mtd/mtd.h>
  38. #include <linux/mtd/partitions.h>
  39. #include <linux/mtd/map.h>
  40. #include <linux/mtd/physmap.h>
  41. #include <plat/samsung-time.h>
  42. #include "common.h"
  43. static struct resource amlm5900_nor_resource =
  44. DEFINE_RES_MEM(0x00000000, SZ_16M);
  45. static struct mtd_partition amlm5900_mtd_partitions[] = {
  46. {
  47. .name = "System",
  48. .size = 0x240000,
  49. .offset = 0,
  50. .mask_flags = MTD_WRITEABLE, /* force read-only */
  51. }, {
  52. .name = "Kernel",
  53. .size = 0x100000,
  54. .offset = MTDPART_OFS_APPEND,
  55. }, {
  56. .name = "Ramdisk",
  57. .size = 0x300000,
  58. .offset = MTDPART_OFS_APPEND,
  59. }, {
  60. .name = "JFFS2",
  61. .size = 0x9A0000,
  62. .offset = MTDPART_OFS_APPEND,
  63. }, {
  64. .name = "Settings",
  65. .size = MTDPART_SIZ_FULL,
  66. .offset = MTDPART_OFS_APPEND,
  67. }
  68. };
  69. static struct physmap_flash_data amlm5900_flash_data = {
  70. .width = 2,
  71. .parts = amlm5900_mtd_partitions,
  72. .nr_parts = ARRAY_SIZE(amlm5900_mtd_partitions),
  73. };
  74. static struct platform_device amlm5900_device_nor = {
  75. .name = "physmap-flash",
  76. .id = 0,
  77. .dev = {
  78. .platform_data = &amlm5900_flash_data,
  79. },
  80. .num_resources = 1,
  81. .resource = &amlm5900_nor_resource,
  82. };
  83. static struct map_desc amlm5900_iodesc[] __initdata = {
  84. };
  85. #define UCON S3C2410_UCON_DEFAULT
  86. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  87. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  88. static struct s3c2410_uartcfg amlm5900_uartcfgs[] = {
  89. [0] = {
  90. .hwport = 0,
  91. .flags = 0,
  92. .ucon = UCON,
  93. .ulcon = ULCON,
  94. .ufcon = UFCON,
  95. },
  96. [1] = {
  97. .hwport = 1,
  98. .flags = 0,
  99. .ucon = UCON,
  100. .ulcon = ULCON,
  101. .ufcon = UFCON,
  102. },
  103. [2] = {
  104. .hwport = 2,
  105. .flags = 0,
  106. .ucon = UCON,
  107. .ulcon = ULCON,
  108. .ufcon = UFCON,
  109. }
  110. };
  111. static struct platform_device *amlm5900_devices[] __initdata = {
  112. #ifdef CONFIG_FB_S3C2410
  113. &s3c_device_lcd,
  114. #endif
  115. &s3c_device_adc,
  116. &s3c_device_wdt,
  117. &s3c_device_i2c0,
  118. &s3c_device_ohci,
  119. &s3c_device_rtc,
  120. &s3c_device_usbgadget,
  121. &s3c_device_sdi,
  122. &amlm5900_device_nor,
  123. };
  124. static void __init amlm5900_map_io(void)
  125. {
  126. s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc));
  127. s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs));
  128. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  129. }
  130. static void __init amlm5900_init_time(void)
  131. {
  132. s3c2410_init_clocks(12000000);
  133. samsung_timer_init();
  134. }
  135. #ifdef CONFIG_FB_S3C2410
  136. static struct s3c2410fb_display __initdata amlm5900_lcd_info = {
  137. .width = 160,
  138. .height = 160,
  139. .type = S3C2410_LCDCON1_STN4,
  140. .pixclock = 680000, /* HCLK = 100MHz */
  141. .xres = 160,
  142. .yres = 160,
  143. .bpp = 4,
  144. .left_margin = 1 << (4 + 3),
  145. .right_margin = 8 << 3,
  146. .hsync_len = 48,
  147. .upper_margin = 0,
  148. .lower_margin = 0,
  149. .lcdcon5 = 0x00000001,
  150. };
  151. static struct s3c2410fb_mach_info __initdata amlm5900_fb_info = {
  152. .displays = &amlm5900_lcd_info,
  153. .num_displays = 1,
  154. .default_display = 0,
  155. .gpccon = 0xaaaaaaaa,
  156. .gpccon_mask = 0xffffffff,
  157. .gpcup = 0x0000ffff,
  158. .gpcup_mask = 0xffffffff,
  159. .gpdcon = 0xaaaaaaaa,
  160. .gpdcon_mask = 0xffffffff,
  161. .gpdup = 0x0000ffff,
  162. .gpdup_mask = 0xffffffff,
  163. };
  164. #endif
  165. static irqreturn_t
  166. amlm5900_wake_interrupt(int irq, void *ignored)
  167. {
  168. return IRQ_HANDLED;
  169. }
  170. static void amlm5900_init_pm(void)
  171. {
  172. int ret = 0;
  173. ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt,
  174. IRQF_TRIGGER_RISING | IRQF_SHARED,
  175. "amlm5900_wakeup", &amlm5900_wake_interrupt);
  176. if (ret != 0) {
  177. printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret);
  178. } else {
  179. enable_irq_wake(IRQ_EINT9);
  180. /* configure the suspend/resume status pin */
  181. s3c_gpio_cfgpin(S3C2410_GPF(2), S3C2410_GPIO_OUTPUT);
  182. s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_UP);
  183. }
  184. }
  185. static void __init amlm5900_init(void)
  186. {
  187. amlm5900_init_pm();
  188. #ifdef CONFIG_FB_S3C2410
  189. s3c24xx_fb_set_platdata(&amlm5900_fb_info);
  190. #endif
  191. s3c_i2c0_set_platdata(NULL);
  192. platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices));
  193. }
  194. MACHINE_START(AML_M5900, "AML_M5900")
  195. .atag_offset = 0x100,
  196. .map_io = amlm5900_map_io,
  197. .init_irq = s3c2410_init_irq,
  198. .init_machine = amlm5900_init,
  199. .init_time = amlm5900_init_time,
  200. MACHINE_END