common-smdk-s3c24xx.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2006 Simtec Electronics
  4. // Ben Dooks <[email protected]>
  5. //
  6. // Common code for SMDK2410 and SMDK2440 boards
  7. //
  8. // http://www.fluff.org/ben/smdk2440/
  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/gpio/machine.h>
  17. #include <linux/device.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/rawnand.h>
  21. #include <linux/mtd/nand-ecc-sw-hamming.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <linux/io.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #include <asm/mach/irq.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/irq.h>
  29. #include "regs-gpio.h"
  30. #include "gpio-samsung.h"
  31. #include <linux/platform_data/leds-s3c24xx.h>
  32. #include <linux/platform_data/mtd-nand-s3c2410.h>
  33. #include "gpio-cfg.h"
  34. #include "devs.h"
  35. #include "pm.h"
  36. #include "common-smdk-s3c24xx.h"
  37. /* LED devices */
  38. static struct gpiod_lookup_table smdk_led4_gpio_table = {
  39. .dev_id = "s3c24xx_led.0",
  40. .table = {
  41. GPIO_LOOKUP("GPF", 4, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
  42. { },
  43. },
  44. };
  45. static struct gpiod_lookup_table smdk_led5_gpio_table = {
  46. .dev_id = "s3c24xx_led.1",
  47. .table = {
  48. GPIO_LOOKUP("GPF", 5, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
  49. { },
  50. },
  51. };
  52. static struct gpiod_lookup_table smdk_led6_gpio_table = {
  53. .dev_id = "s3c24xx_led.2",
  54. .table = {
  55. GPIO_LOOKUP("GPF", 6, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
  56. { },
  57. },
  58. };
  59. static struct gpiod_lookup_table smdk_led7_gpio_table = {
  60. .dev_id = "s3c24xx_led.3",
  61. .table = {
  62. GPIO_LOOKUP("GPF", 7, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
  63. { },
  64. },
  65. };
  66. static struct s3c24xx_led_platdata smdk_pdata_led4 = {
  67. .name = "led4",
  68. .def_trigger = "timer",
  69. };
  70. static struct s3c24xx_led_platdata smdk_pdata_led5 = {
  71. .name = "led5",
  72. .def_trigger = "nand-disk",
  73. };
  74. static struct s3c24xx_led_platdata smdk_pdata_led6 = {
  75. .name = "led6",
  76. };
  77. static struct s3c24xx_led_platdata smdk_pdata_led7 = {
  78. .name = "led7",
  79. };
  80. static struct platform_device smdk_led4 = {
  81. .name = "s3c24xx_led",
  82. .id = 0,
  83. .dev = {
  84. .platform_data = &smdk_pdata_led4,
  85. },
  86. };
  87. static struct platform_device smdk_led5 = {
  88. .name = "s3c24xx_led",
  89. .id = 1,
  90. .dev = {
  91. .platform_data = &smdk_pdata_led5,
  92. },
  93. };
  94. static struct platform_device smdk_led6 = {
  95. .name = "s3c24xx_led",
  96. .id = 2,
  97. .dev = {
  98. .platform_data = &smdk_pdata_led6,
  99. },
  100. };
  101. static struct platform_device smdk_led7 = {
  102. .name = "s3c24xx_led",
  103. .id = 3,
  104. .dev = {
  105. .platform_data = &smdk_pdata_led7,
  106. },
  107. };
  108. /* NAND parititon from 2.4.18-swl5 */
  109. static struct mtd_partition smdk_default_nand_part[] = {
  110. [0] = {
  111. .name = "Boot Agent",
  112. .size = SZ_16K,
  113. .offset = 0,
  114. },
  115. [1] = {
  116. .name = "S3C2410 flash partition 1",
  117. .offset = 0,
  118. .size = SZ_2M,
  119. },
  120. [2] = {
  121. .name = "S3C2410 flash partition 2",
  122. .offset = SZ_4M,
  123. .size = SZ_4M,
  124. },
  125. [3] = {
  126. .name = "S3C2410 flash partition 3",
  127. .offset = SZ_8M,
  128. .size = SZ_2M,
  129. },
  130. [4] = {
  131. .name = "S3C2410 flash partition 4",
  132. .offset = SZ_1M * 10,
  133. .size = SZ_4M,
  134. },
  135. [5] = {
  136. .name = "S3C2410 flash partition 5",
  137. .offset = SZ_1M * 14,
  138. .size = SZ_1M * 10,
  139. },
  140. [6] = {
  141. .name = "S3C2410 flash partition 6",
  142. .offset = SZ_1M * 24,
  143. .size = SZ_1M * 24,
  144. },
  145. [7] = {
  146. .name = "S3C2410 flash partition 7",
  147. .offset = SZ_1M * 48,
  148. .size = MTDPART_SIZ_FULL,
  149. }
  150. };
  151. static struct s3c2410_nand_set smdk_nand_sets[] = {
  152. [0] = {
  153. .name = "NAND",
  154. .nr_chips = 1,
  155. .nr_partitions = ARRAY_SIZE(smdk_default_nand_part),
  156. .partitions = smdk_default_nand_part,
  157. },
  158. };
  159. /* choose a set of timings which should suit most 512Mbit
  160. * chips and beyond.
  161. */
  162. static struct s3c2410_platform_nand smdk_nand_info = {
  163. .tacls = 20,
  164. .twrph0 = 60,
  165. .twrph1 = 20,
  166. .nr_sets = ARRAY_SIZE(smdk_nand_sets),
  167. .sets = smdk_nand_sets,
  168. .engine_type = NAND_ECC_ENGINE_TYPE_SOFT,
  169. };
  170. /* devices we initialise */
  171. static struct platform_device __initdata *smdk_devs[] = {
  172. &s3c_device_nand,
  173. &smdk_led4,
  174. &smdk_led5,
  175. &smdk_led6,
  176. &smdk_led7,
  177. };
  178. void __init smdk_machine_init(void)
  179. {
  180. if (machine_is_smdk2443())
  181. smdk_nand_info.twrph0 = 50;
  182. s3c_nand_set_platdata(&smdk_nand_info);
  183. /* Disable pull-up on the LED lines */
  184. s3c_gpio_setpull(S3C2410_GPF(4), S3C_GPIO_PULL_NONE);
  185. s3c_gpio_setpull(S3C2410_GPF(5), S3C_GPIO_PULL_NONE);
  186. s3c_gpio_setpull(S3C2410_GPF(6), S3C_GPIO_PULL_NONE);
  187. s3c_gpio_setpull(S3C2410_GPF(7), S3C_GPIO_PULL_NONE);
  188. /* Add lookups for the lines */
  189. gpiod_add_lookup_table(&smdk_led4_gpio_table);
  190. gpiod_add_lookup_table(&smdk_led5_gpio_table);
  191. gpiod_add_lookup_table(&smdk_led6_gpio_table);
  192. gpiod_add_lookup_table(&smdk_led7_gpio_table);
  193. platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
  194. s3c_pm_init();
  195. }