common-smdk.c 4.5 KB

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