Krzysztof Kozlowski | 84b2170 | 2017-12-25 20:54:32 +0100 | [diff] [blame] | 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/ |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 9 | |
| 10 | #include <linux/kernel.h> |
| 11 | #include <linux/types.h> |
| 12 | #include <linux/interrupt.h> |
| 13 | #include <linux/list.h> |
| 14 | #include <linux/timer.h> |
| 15 | #include <linux/init.h> |
Ben Dooks | ec976d6 | 2009-05-13 22:52:24 +0100 | [diff] [blame] | 16 | #include <linux/gpio.h> |
Linus Walleij | f7f611f | 2020-07-08 09:11:49 +0200 | [diff] [blame] | 17 | #include <linux/gpio/machine.h> |
Kay Sievers | edbaa60 | 2011-12-21 16:26:03 -0800 | [diff] [blame] | 18 | #include <linux/device.h> |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 19 | #include <linux/platform_device.h> |
| 20 | |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 21 | #include <linux/mtd/mtd.h> |
Boris Brezillon | d4092d7 | 2017-08-04 17:29:10 +0200 | [diff] [blame] | 22 | #include <linux/mtd/rawnand.h> |
Miquel Raynal | e5acf9c | 2020-09-30 01:01:15 +0200 | [diff] [blame] | 23 | #include <linux/mtd/nand-ecc-sw-hamming.h> |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 24 | #include <linux/mtd/partitions.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 25 | #include <linux/io.h> |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 26 | |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 27 | #include <asm/mach/arch.h> |
| 28 | #include <asm/mach/map.h> |
| 29 | #include <asm/mach/irq.h> |
| 30 | |
Ben Dooks | 42482e3 | 2007-05-20 19:58:10 +0100 | [diff] [blame] | 31 | #include <asm/mach-types.h> |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 32 | #include <asm/irq.h> |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 33 | |
Arnd Bergmann | c6ff132 | 2019-09-02 18:37:30 +0200 | [diff] [blame] | 34 | #include "regs-gpio.h" |
| 35 | #include "gpio-samsung.h" |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 36 | #include <linux/platform_data/leds-s3c24xx.h> |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 37 | #include <linux/platform_data/mtd-nand-s3c2410.h> |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 38 | |
Arnd Bergmann | c6ff132 | 2019-09-02 18:37:30 +0200 | [diff] [blame] | 39 | #include "gpio-cfg.h" |
| 40 | #include "devs.h" |
| 41 | #include "pm.h" |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 42 | |
Arnd Bergmann | 71b9114 | 2019-09-02 17:47:55 +0200 | [diff] [blame] | 43 | #include "common-smdk-s3c24xx.h" |
Kukjin Kim | 4d512a9 | 2013-02-08 10:18:48 -0800 | [diff] [blame] | 44 | |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 45 | /* LED devices */ |
| 46 | |
Linus Walleij | f7f611f | 2020-07-08 09:11:49 +0200 | [diff] [blame] | 47 | static struct gpiod_lookup_table smdk_led4_gpio_table = { |
| 48 | .dev_id = "s3c24xx_led.0", |
| 49 | .table = { |
| 50 | GPIO_LOOKUP("GPF", 4, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN), |
| 51 | { }, |
| 52 | }, |
| 53 | }; |
| 54 | |
| 55 | static struct gpiod_lookup_table smdk_led5_gpio_table = { |
| 56 | .dev_id = "s3c24xx_led.1", |
| 57 | .table = { |
| 58 | GPIO_LOOKUP("GPF", 5, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN), |
| 59 | { }, |
| 60 | }, |
| 61 | }; |
| 62 | |
| 63 | static struct gpiod_lookup_table smdk_led6_gpio_table = { |
| 64 | .dev_id = "s3c24xx_led.2", |
| 65 | .table = { |
| 66 | GPIO_LOOKUP("GPF", 6, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN), |
| 67 | { }, |
| 68 | }, |
| 69 | }; |
| 70 | |
| 71 | static struct gpiod_lookup_table smdk_led7_gpio_table = { |
| 72 | .dev_id = "s3c24xx_led.3", |
| 73 | .table = { |
| 74 | GPIO_LOOKUP("GPF", 7, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN), |
| 75 | { }, |
| 76 | }, |
| 77 | }; |
| 78 | |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 79 | static struct s3c24xx_led_platdata smdk_pdata_led4 = { |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 80 | .name = "led4", |
| 81 | .def_trigger = "timer", |
| 82 | }; |
| 83 | |
| 84 | static struct s3c24xx_led_platdata smdk_pdata_led5 = { |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 85 | .name = "led5", |
| 86 | .def_trigger = "nand-disk", |
| 87 | }; |
| 88 | |
| 89 | static struct s3c24xx_led_platdata smdk_pdata_led6 = { |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 90 | .name = "led6", |
| 91 | }; |
| 92 | |
| 93 | static struct s3c24xx_led_platdata smdk_pdata_led7 = { |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 94 | .name = "led7", |
| 95 | }; |
| 96 | |
| 97 | static struct platform_device smdk_led4 = { |
| 98 | .name = "s3c24xx_led", |
| 99 | .id = 0, |
| 100 | .dev = { |
| 101 | .platform_data = &smdk_pdata_led4, |
| 102 | }, |
| 103 | }; |
| 104 | |
| 105 | static struct platform_device smdk_led5 = { |
| 106 | .name = "s3c24xx_led", |
| 107 | .id = 1, |
| 108 | .dev = { |
| 109 | .platform_data = &smdk_pdata_led5, |
| 110 | }, |
| 111 | }; |
| 112 | |
| 113 | static struct platform_device smdk_led6 = { |
| 114 | .name = "s3c24xx_led", |
| 115 | .id = 2, |
| 116 | .dev = { |
| 117 | .platform_data = &smdk_pdata_led6, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | static struct platform_device smdk_led7 = { |
| 122 | .name = "s3c24xx_led", |
| 123 | .id = 3, |
| 124 | .dev = { |
| 125 | .platform_data = &smdk_pdata_led7, |
| 126 | }, |
| 127 | }; |
| 128 | |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 129 | /* NAND parititon from 2.4.18-swl5 */ |
| 130 | |
| 131 | static struct mtd_partition smdk_default_nand_part[] = { |
| 132 | [0] = { |
| 133 | .name = "Boot Agent", |
| 134 | .size = SZ_16K, |
| 135 | .offset = 0, |
| 136 | }, |
| 137 | [1] = { |
Ben Dooks | f683554 | 2006-04-13 09:57:15 +0100 | [diff] [blame] | 138 | .name = "S3C2410 flash partition 1", |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 139 | .offset = 0, |
| 140 | .size = SZ_2M, |
| 141 | }, |
| 142 | [2] = { |
| 143 | .name = "S3C2410 flash partition 2", |
| 144 | .offset = SZ_4M, |
| 145 | .size = SZ_4M, |
| 146 | }, |
| 147 | [3] = { |
| 148 | .name = "S3C2410 flash partition 3", |
| 149 | .offset = SZ_8M, |
| 150 | .size = SZ_2M, |
| 151 | }, |
| 152 | [4] = { |
| 153 | .name = "S3C2410 flash partition 4", |
| 154 | .offset = SZ_1M * 10, |
| 155 | .size = SZ_4M, |
| 156 | }, |
| 157 | [5] = { |
| 158 | .name = "S3C2410 flash partition 5", |
| 159 | .offset = SZ_1M * 14, |
| 160 | .size = SZ_1M * 10, |
| 161 | }, |
| 162 | [6] = { |
| 163 | .name = "S3C2410 flash partition 6", |
| 164 | .offset = SZ_1M * 24, |
| 165 | .size = SZ_1M * 24, |
| 166 | }, |
| 167 | [7] = { |
| 168 | .name = "S3C2410 flash partition 7", |
| 169 | .offset = SZ_1M * 48, |
Atul Dahiya | 66ad4ee | 2010-10-18 19:53:34 +0900 | [diff] [blame] | 170 | .size = MTDPART_SIZ_FULL, |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 171 | } |
| 172 | }; |
| 173 | |
| 174 | static struct s3c2410_nand_set smdk_nand_sets[] = { |
| 175 | [0] = { |
| 176 | .name = "NAND", |
| 177 | .nr_chips = 1, |
| 178 | .nr_partitions = ARRAY_SIZE(smdk_default_nand_part), |
| 179 | .partitions = smdk_default_nand_part, |
| 180 | }, |
| 181 | }; |
| 182 | |
| 183 | /* choose a set of timings which should suit most 512Mbit |
| 184 | * chips and beyond. |
| 185 | */ |
| 186 | |
| 187 | static struct s3c2410_platform_nand smdk_nand_info = { |
| 188 | .tacls = 20, |
| 189 | .twrph0 = 60, |
| 190 | .twrph1 = 20, |
| 191 | .nr_sets = ARRAY_SIZE(smdk_nand_sets), |
| 192 | .sets = smdk_nand_sets, |
Miquel Raynal | bace41f | 2020-08-27 10:51:58 +0200 | [diff] [blame] | 193 | .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 194 | }; |
| 195 | |
| 196 | /* devices we initialise */ |
| 197 | |
| 198 | static struct platform_device __initdata *smdk_devs[] = { |
| 199 | &s3c_device_nand, |
Ben Dooks | 810c894 | 2006-06-18 22:56:37 +0100 | [diff] [blame] | 200 | &smdk_led4, |
| 201 | &smdk_led5, |
| 202 | &smdk_led6, |
| 203 | &smdk_led7, |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 204 | }; |
| 205 | |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 206 | void __init smdk_machine_init(void) |
| 207 | { |
Ben Dooks | 42482e3 | 2007-05-20 19:58:10 +0100 | [diff] [blame] | 208 | if (machine_is_smdk2443()) |
| 209 | smdk_nand_info.twrph0 = 50; |
| 210 | |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 211 | s3c_nand_set_platdata(&smdk_nand_info); |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 212 | |
Linus Walleij | f7f611f | 2020-07-08 09:11:49 +0200 | [diff] [blame] | 213 | /* Disable pull-up on the LED lines */ |
| 214 | s3c_gpio_setpull(S3C2410_GPF(4), S3C_GPIO_PULL_NONE); |
| 215 | s3c_gpio_setpull(S3C2410_GPF(5), S3C_GPIO_PULL_NONE); |
| 216 | s3c_gpio_setpull(S3C2410_GPF(6), S3C_GPIO_PULL_NONE); |
| 217 | s3c_gpio_setpull(S3C2410_GPF(7), S3C_GPIO_PULL_NONE); |
| 218 | |
| 219 | /* Add lookups for the lines */ |
| 220 | gpiod_add_lookup_table(&smdk_led4_gpio_table); |
| 221 | gpiod_add_lookup_table(&smdk_led5_gpio_table); |
| 222 | gpiod_add_lookup_table(&smdk_led6_gpio_table); |
| 223 | gpiod_add_lookup_table(&smdk_led7_gpio_table); |
| 224 | |
Ben Dooks | dee9b2e | 2006-04-02 10:00:09 +0100 | [diff] [blame] | 225 | platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs)); |
| 226 | |
Ben Dooks | 4e59c25 | 2008-12-12 00:24:18 +0000 | [diff] [blame] | 227 | s3c_pm_init(); |
Ben Dooks | d3f4c57 | 2006-04-01 18:33:42 +0100 | [diff] [blame] | 228 | } |