common-smdk.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2006 Simtec Electronics
  4. // Ben Dooks <ben@simtec.co.uk>
  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/device.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/mtd/mtd.h>
  19. #include <linux/mtd/rawnand.h>
  20. #include <linux/mtd/nand_ecc.h>
  21. #include <linux/mtd/partitions.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-types.h>
  27. #include <mach/hardware.h>
  28. #include <asm/irq.h>
  29. #include <mach/regs-gpio.h>
  30. #include <mach/gpio-samsung.h>
  31. #include <linux/platform_data/leds-s3c24xx.h>
  32. #include <linux/platform_data/mtd-nand-s3c2410.h>
  33. #include <plat/gpio-cfg.h>
  34. #include <plat/devs.h>
  35. #include <plat/pm.h>
  36. #include "common-smdk.h"
  37. /* LED devices */
  38. static struct s3c24xx_led_platdata smdk_pdata_led4 = {
  39. .gpio = S3C2410_GPF(4),
  40. .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
  41. .name = "led4",
  42. .def_trigger = "timer",
  43. };
  44. static struct s3c24xx_led_platdata smdk_pdata_led5 = {
  45. .gpio = S3C2410_GPF(5),
  46. .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
  47. .name = "led5",
  48. .def_trigger = "nand-disk",
  49. };
  50. static struct s3c24xx_led_platdata smdk_pdata_led6 = {
  51. .gpio = S3C2410_GPF(6),
  52. .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
  53. .name = "led6",
  54. };
  55. static struct s3c24xx_led_platdata smdk_pdata_led7 = {
  56. .gpio = S3C2410_GPF(7),
  57. .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
  58. .name = "led7",
  59. };
  60. static struct platform_device smdk_led4 = {
  61. .name = "s3c24xx_led",
  62. .id = 0,
  63. .dev = {
  64. .platform_data = &smdk_pdata_led4,
  65. },
  66. };
  67. static struct platform_device smdk_led5 = {
  68. .name = "s3c24xx_led",
  69. .id = 1,
  70. .dev = {
  71. .platform_data = &smdk_pdata_led5,
  72. },
  73. };
  74. static struct platform_device smdk_led6 = {
  75. .name = "s3c24xx_led",
  76. .id = 2,
  77. .dev = {
  78. .platform_data = &smdk_pdata_led6,
  79. },
  80. };
  81. static struct platform_device smdk_led7 = {
  82. .name = "s3c24xx_led",
  83. .id = 3,
  84. .dev = {
  85. .platform_data = &smdk_pdata_led7,
  86. },
  87. };
  88. /* NAND parititon from 2.4.18-swl5 */
  89. static struct mtd_partition smdk_default_nand_part[] = {
  90. [0] = {
  91. .name = "Boot Agent",
  92. .size = SZ_16K,
  93. .offset = 0,
  94. },
  95. [1] = {
  96. .name = "S3C2410 flash partition 1",
  97. .offset = 0,
  98. .size = SZ_2M,
  99. },
  100. [2] = {
  101. .name = "S3C2410 flash partition 2",
  102. .offset = SZ_4M,
  103. .size = SZ_4M,
  104. },
  105. [3] = {
  106. .name = "S3C2410 flash partition 3",
  107. .offset = SZ_8M,
  108. .size = SZ_2M,
  109. },
  110. [4] = {
  111. .name = "S3C2410 flash partition 4",
  112. .offset = SZ_1M * 10,
  113. .size = SZ_4M,
  114. },
  115. [5] = {
  116. .name = "S3C2410 flash partition 5",
  117. .offset = SZ_1M * 14,
  118. .size = SZ_1M * 10,
  119. },
  120. [6] = {
  121. .name = "S3C2410 flash partition 6",
  122. .offset = SZ_1M * 24,
  123. .size = SZ_1M * 24,
  124. },
  125. [7] = {
  126. .name = "S3C2410 flash partition 7",
  127. .offset = SZ_1M * 48,
  128. .size = MTDPART_SIZ_FULL,
  129. }
  130. };
  131. static struct s3c2410_nand_set smdk_nand_sets[] = {
  132. [0] = {
  133. .name = "NAND",
  134. .nr_chips = 1,
  135. .nr_partitions = ARRAY_SIZE(smdk_default_nand_part),
  136. .partitions = smdk_default_nand_part,
  137. },
  138. };
  139. /* choose a set of timings which should suit most 512Mbit
  140. * chips and beyond.
  141. */
  142. static struct s3c2410_platform_nand smdk_nand_info = {
  143. .tacls = 20,
  144. .twrph0 = 60,
  145. .twrph1 = 20,
  146. .nr_sets = ARRAY_SIZE(smdk_nand_sets),
  147. .sets = smdk_nand_sets,
  148. .ecc_mode = NAND_ECC_SOFT,
  149. };
  150. /* devices we initialise */
  151. static struct platform_device __initdata *smdk_devs[] = {
  152. &s3c_device_nand,
  153. &smdk_led4,
  154. &smdk_led5,
  155. &smdk_led6,
  156. &smdk_led7,
  157. };
  158. static const struct gpio smdk_led_gpios[] = {
  159. { S3C2410_GPF(4), GPIOF_OUT_INIT_HIGH, NULL },
  160. { S3C2410_GPF(5), GPIOF_OUT_INIT_HIGH, NULL },
  161. { S3C2410_GPF(6), GPIOF_OUT_INIT_HIGH, NULL },
  162. { S3C2410_GPF(7), GPIOF_OUT_INIT_HIGH, NULL },
  163. };
  164. void __init smdk_machine_init(void)
  165. {
  166. /* Configure the LEDs (even if we have no LED support)*/
  167. int ret = gpio_request_array(smdk_led_gpios,
  168. ARRAY_SIZE(smdk_led_gpios));
  169. if (!WARN_ON(ret < 0))
  170. gpio_free_array(smdk_led_gpios, ARRAY_SIZE(smdk_led_gpios));
  171. if (machine_is_smdk2443())
  172. smdk_nand_info.twrph0 = 50;
  173. s3c_nand_set_platdata(&smdk_nand_info);
  174. platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
  175. s3c_pm_init();
  176. }