Ben Dooks | a21765a | 2007-02-11 18:31:01 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/plat-s3c24xx/common-smdk.c |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 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 | |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/types.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/list.h> |
| 19 | #include <linux/timer.h> |
| 20 | #include <linux/init.h> |
Ben Dooks | ec976d6 | 2009-05-13 22:52:24 +0100 | [diff] [blame] | 21 | #include <linux/gpio.h> |
Kay Sievers | edbaa60 | 2011-12-21 16:26:03 -0800 | [diff] [blame] | 22 | #include <linux/device.h> |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 23 | #include <linux/platform_device.h> |
| 24 | |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 25 | #include <linux/mtd/mtd.h> |
| 26 | #include <linux/mtd/nand.h> |
| 27 | #include <linux/mtd/nand_ecc.h> |
| 28 | #include <linux/mtd/partitions.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 29 | #include <linux/io.h> |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 30 | |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 31 | #include <asm/mach/arch.h> |
| 32 | #include <asm/mach/map.h> |
| 33 | #include <asm/mach/irq.h> |
| 34 | |
Ben Dooks | 42482e3 | 2007-05-20 19:58:10 +0100 | [diff] [blame] | 35 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 36 | #include <mach/hardware.h> |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 37 | #include <asm/irq.h> |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 38 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 39 | #include <mach/regs-gpio.h> |
Linus Walleij | b0161ca | 2014-01-14 14:24:24 +0100 | [diff] [blame] | 40 | #include <mach/gpio-samsung.h> |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 41 | #include <linux/platform_data/leds-s3c24xx.h> |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 42 | #include <linux/platform_data/mtd-nand-s3c2410.h> |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 43 | |
Ben Dooks | 40b956f | 2010-05-04 14:38:49 +0900 | [diff] [blame] | 44 | #include <plat/gpio-cfg.h> |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 45 | #include <plat/devs.h> |
| 46 | #include <plat/pm.h> |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 47 | |
Kukjin Kim | 4d512a9 | 2013-02-08 10:18:48 -0800 | [diff] [blame] | 48 | #include "common-smdk.h" |
| 49 | |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 50 | /* LED devices */ |
| 51 | |
| 52 | static struct s3c24xx_led_platdata smdk_pdata_led4 = { |
Ben Dooks | 070276d | 2009-05-17 22:32:23 +0100 | [diff] [blame] | 53 | .gpio = S3C2410_GPF(4), |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 54 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, |
| 55 | .name = "led4", |
| 56 | .def_trigger = "timer", |
| 57 | }; |
| 58 | |
| 59 | static struct s3c24xx_led_platdata smdk_pdata_led5 = { |
Ben Dooks | 070276d | 2009-05-17 22:32:23 +0100 | [diff] [blame] | 60 | .gpio = S3C2410_GPF(5), |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 61 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, |
| 62 | .name = "led5", |
| 63 | .def_trigger = "nand-disk", |
| 64 | }; |
| 65 | |
| 66 | static struct s3c24xx_led_platdata smdk_pdata_led6 = { |
Ben Dooks | 070276d | 2009-05-17 22:32:23 +0100 | [diff] [blame] | 67 | .gpio = S3C2410_GPF(6), |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 68 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, |
| 69 | .name = "led6", |
| 70 | }; |
| 71 | |
| 72 | static struct s3c24xx_led_platdata smdk_pdata_led7 = { |
Ben Dooks | 070276d | 2009-05-17 22:32:23 +0100 | [diff] [blame] | 73 | .gpio = S3C2410_GPF(7), |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 74 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, |
| 75 | .name = "led7", |
| 76 | }; |
| 77 | |
| 78 | static struct platform_device smdk_led4 = { |
| 79 | .name = "s3c24xx_led", |
| 80 | .id = 0, |
| 81 | .dev = { |
| 82 | .platform_data = &smdk_pdata_led4, |
| 83 | }, |
| 84 | }; |
| 85 | |
| 86 | static struct platform_device smdk_led5 = { |
| 87 | .name = "s3c24xx_led", |
| 88 | .id = 1, |
| 89 | .dev = { |
| 90 | .platform_data = &smdk_pdata_led5, |
| 91 | }, |
| 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 | |
| 102 | static struct platform_device smdk_led7 = { |
| 103 | .name = "s3c24xx_led", |
| 104 | .id = 3, |
| 105 | .dev = { |
| 106 | .platform_data = &smdk_pdata_led7, |
| 107 | }, |
| 108 | }; |
| 109 | |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 110 | /* NAND parititon from 2.4.18-swl5 */ |
| 111 | |
| 112 | static struct mtd_partition smdk_default_nand_part[] = { |
| 113 | [0] = { |
| 114 | .name = "Boot Agent", |
| 115 | .size = SZ_16K, |
| 116 | .offset = 0, |
| 117 | }, |
| 118 | [1] = { |
Ben Dooks | f683554 | 2006-04-13 09:57:15 +0100 | [diff] [blame] | 119 | .name = "S3C2410 flash partition 1", |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 120 | .offset = 0, |
| 121 | .size = SZ_2M, |
| 122 | }, |
| 123 | [2] = { |
| 124 | .name = "S3C2410 flash partition 2", |
| 125 | .offset = SZ_4M, |
| 126 | .size = SZ_4M, |
| 127 | }, |
| 128 | [3] = { |
| 129 | .name = "S3C2410 flash partition 3", |
| 130 | .offset = SZ_8M, |
| 131 | .size = SZ_2M, |
| 132 | }, |
| 133 | [4] = { |
| 134 | .name = "S3C2410 flash partition 4", |
| 135 | .offset = SZ_1M * 10, |
| 136 | .size = SZ_4M, |
| 137 | }, |
| 138 | [5] = { |
| 139 | .name = "S3C2410 flash partition 5", |
| 140 | .offset = SZ_1M * 14, |
| 141 | .size = SZ_1M * 10, |
| 142 | }, |
| 143 | [6] = { |
| 144 | .name = "S3C2410 flash partition 6", |
| 145 | .offset = SZ_1M * 24, |
| 146 | .size = SZ_1M * 24, |
| 147 | }, |
| 148 | [7] = { |
| 149 | .name = "S3C2410 flash partition 7", |
| 150 | .offset = SZ_1M * 48, |
Atul Dahiya | 66ad4ee | 2010-10-18 19:53:34 +0900 | [diff] [blame] | 151 | .size = MTDPART_SIZ_FULL, |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 152 | } |
| 153 | }; |
| 154 | |
| 155 | static struct s3c2410_nand_set smdk_nand_sets[] = { |
| 156 | [0] = { |
| 157 | .name = "NAND", |
| 158 | .nr_chips = 1, |
| 159 | .nr_partitions = ARRAY_SIZE(smdk_default_nand_part), |
| 160 | .partitions = smdk_default_nand_part, |
| 161 | }, |
| 162 | }; |
| 163 | |
| 164 | /* choose a set of timings which should suit most 512Mbit |
| 165 | * chips and beyond. |
| 166 | */ |
| 167 | |
| 168 | static struct s3c2410_platform_nand smdk_nand_info = { |
| 169 | .tacls = 20, |
| 170 | .twrph0 = 60, |
| 171 | .twrph1 = 20, |
| 172 | .nr_sets = ARRAY_SIZE(smdk_nand_sets), |
| 173 | .sets = smdk_nand_sets, |
| 174 | }; |
| 175 | |
| 176 | /* devices we initialise */ |
| 177 | |
| 178 | static struct platform_device __initdata *smdk_devs[] = { |
| 179 | &s3c_device_nand, |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 180 | &smdk_led4, |
| 181 | &smdk_led5, |
| 182 | &smdk_led6, |
| 183 | &smdk_led7, |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 184 | }; |
| 185 | |
Sylwester Nawrocki | ff40b4b | 2012-07-13 18:04:25 +0900 | [diff] [blame] | 186 | static const struct gpio smdk_led_gpios[] = { |
| 187 | { S3C2410_GPF(4), GPIOF_OUT_INIT_HIGH, NULL }, |
| 188 | { S3C2410_GPF(5), GPIOF_OUT_INIT_HIGH, NULL }, |
| 189 | { S3C2410_GPF(6), GPIOF_OUT_INIT_HIGH, NULL }, |
| 190 | { S3C2410_GPF(7), GPIOF_OUT_INIT_HIGH, NULL }, |
| 191 | }; |
| 192 | |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 193 | void __init smdk_machine_init(void) |
| 194 | { |
| 195 | /* Configure the LEDs (even if we have no LED support)*/ |
| 196 | |
Sylwester Nawrocki | ff40b4b | 2012-07-13 18:04:25 +0900 | [diff] [blame] | 197 | int ret = gpio_request_array(smdk_led_gpios, |
| 198 | ARRAY_SIZE(smdk_led_gpios)); |
| 199 | if (!WARN_ON(ret < 0)) |
| 200 | gpio_free_array(smdk_led_gpios, ARRAY_SIZE(smdk_led_gpios)); |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 201 | |
Ben Dooks | 42482e3 | 2007-05-20 19:58:10 +0100 | [diff] [blame] | 202 | if (machine_is_smdk2443()) |
| 203 | smdk_nand_info.twrph0 = 50; |
| 204 | |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 205 | s3c_nand_set_platdata(&smdk_nand_info); |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 206 | |
| 207 | platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs)); |
| 208 | |
Ben Dooks | 4e59c25 | 2008-12-12 00:24:18 +0000 | [diff] [blame] | 209 | s3c_pm_init(); |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 210 | } |