mach-amlm5900.c 5.7 KB

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