Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // Copyright (c) 2006 Simtec Electronics
0004 //  Ben Dooks <ben@simtec.co.uk>
0005 //
0006 // Common code for SMDK2410 and SMDK2440 boards
0007 //
0008 // http://www.fluff.org/ben/smdk2440/
0009 
0010 #include <linux/kernel.h>
0011 #include <linux/types.h>
0012 #include <linux/interrupt.h>
0013 #include <linux/list.h>
0014 #include <linux/timer.h>
0015 #include <linux/init.h>
0016 #include <linux/gpio.h>
0017 #include <linux/gpio/machine.h>
0018 #include <linux/device.h>
0019 #include <linux/platform_device.h>
0020 
0021 #include <linux/mtd/mtd.h>
0022 #include <linux/mtd/rawnand.h>
0023 #include <linux/mtd/nand-ecc-sw-hamming.h>
0024 #include <linux/mtd/partitions.h>
0025 #include <linux/io.h>
0026 
0027 #include <asm/mach/arch.h>
0028 #include <asm/mach/map.h>
0029 #include <asm/mach/irq.h>
0030 
0031 #include <asm/mach-types.h>
0032 #include <asm/irq.h>
0033 
0034 #include "regs-gpio.h"
0035 #include "gpio-samsung.h"
0036 #include <linux/platform_data/leds-s3c24xx.h>
0037 #include <linux/platform_data/mtd-nand-s3c2410.h>
0038 
0039 #include "gpio-cfg.h"
0040 #include "devs.h"
0041 #include "pm.h"
0042 
0043 #include "common-smdk-s3c24xx.h"
0044 
0045 /* LED devices */
0046 
0047 static struct gpiod_lookup_table smdk_led4_gpio_table = {
0048     .dev_id = "s3c24xx_led.0",
0049     .table = {
0050         GPIO_LOOKUP("GPF", 4, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
0051         { },
0052     },
0053 };
0054 
0055 static struct gpiod_lookup_table smdk_led5_gpio_table = {
0056     .dev_id = "s3c24xx_led.1",
0057     .table = {
0058         GPIO_LOOKUP("GPF", 5, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
0059         { },
0060     },
0061 };
0062 
0063 static struct gpiod_lookup_table smdk_led6_gpio_table = {
0064     .dev_id = "s3c24xx_led.2",
0065     .table = {
0066         GPIO_LOOKUP("GPF", 6, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
0067         { },
0068     },
0069 };
0070 
0071 static struct gpiod_lookup_table smdk_led7_gpio_table = {
0072     .dev_id = "s3c24xx_led.3",
0073     .table = {
0074         GPIO_LOOKUP("GPF", 7, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
0075         { },
0076     },
0077 };
0078 
0079 static struct s3c24xx_led_platdata smdk_pdata_led4 = {
0080     .name       = "led4",
0081     .def_trigger    = "timer",
0082 };
0083 
0084 static struct s3c24xx_led_platdata smdk_pdata_led5 = {
0085     .name       = "led5",
0086     .def_trigger    = "nand-disk",
0087 };
0088 
0089 static struct s3c24xx_led_platdata smdk_pdata_led6 = {
0090     .name       = "led6",
0091 };
0092 
0093 static struct s3c24xx_led_platdata smdk_pdata_led7 = {
0094     .name       = "led7",
0095 };
0096 
0097 static struct platform_device smdk_led4 = {
0098     .name       = "s3c24xx_led",
0099     .id     = 0,
0100     .dev        = {
0101         .platform_data = &smdk_pdata_led4,
0102     },
0103 };
0104 
0105 static struct platform_device smdk_led5 = {
0106     .name       = "s3c24xx_led",
0107     .id     = 1,
0108     .dev        = {
0109         .platform_data = &smdk_pdata_led5,
0110     },
0111 };
0112 
0113 static struct platform_device smdk_led6 = {
0114     .name       = "s3c24xx_led",
0115     .id     = 2,
0116     .dev        = {
0117         .platform_data = &smdk_pdata_led6,
0118     },
0119 };
0120 
0121 static struct platform_device smdk_led7 = {
0122     .name       = "s3c24xx_led",
0123     .id     = 3,
0124     .dev        = {
0125         .platform_data = &smdk_pdata_led7,
0126     },
0127 };
0128 
0129 /* NAND parititon from 2.4.18-swl5 */
0130 
0131 static struct mtd_partition smdk_default_nand_part[] = {
0132     [0] = {
0133         .name   = "Boot Agent",
0134         .size   = SZ_16K,
0135         .offset = 0,
0136     },
0137     [1] = {
0138         .name   = "S3C2410 flash partition 1",
0139         .offset = 0,
0140         .size   = SZ_2M,
0141     },
0142     [2] = {
0143         .name   = "S3C2410 flash partition 2",
0144         .offset = SZ_4M,
0145         .size   = SZ_4M,
0146     },
0147     [3] = {
0148         .name   = "S3C2410 flash partition 3",
0149         .offset = SZ_8M,
0150         .size   = SZ_2M,
0151     },
0152     [4] = {
0153         .name   = "S3C2410 flash partition 4",
0154         .offset = SZ_1M * 10,
0155         .size   = SZ_4M,
0156     },
0157     [5] = {
0158         .name   = "S3C2410 flash partition 5",
0159         .offset = SZ_1M * 14,
0160         .size   = SZ_1M * 10,
0161     },
0162     [6] = {
0163         .name   = "S3C2410 flash partition 6",
0164         .offset = SZ_1M * 24,
0165         .size   = SZ_1M * 24,
0166     },
0167     [7] = {
0168         .name   = "S3C2410 flash partition 7",
0169         .offset = SZ_1M * 48,
0170         .size   = MTDPART_SIZ_FULL,
0171     }
0172 };
0173 
0174 static struct s3c2410_nand_set smdk_nand_sets[] = {
0175     [0] = {
0176         .name       = "NAND",
0177         .nr_chips   = 1,
0178         .nr_partitions  = ARRAY_SIZE(smdk_default_nand_part),
0179         .partitions = smdk_default_nand_part,
0180     },
0181 };
0182 
0183 /* choose a set of timings which should suit most 512Mbit
0184  * chips and beyond.
0185 */
0186 
0187 static struct s3c2410_platform_nand smdk_nand_info = {
0188     .tacls      = 20,
0189     .twrph0     = 60,
0190     .twrph1     = 20,
0191     .nr_sets    = ARRAY_SIZE(smdk_nand_sets),
0192     .sets       = smdk_nand_sets,
0193     .engine_type    = NAND_ECC_ENGINE_TYPE_SOFT,
0194 };
0195 
0196 /* devices we initialise */
0197 
0198 static struct platform_device __initdata *smdk_devs[] = {
0199     &s3c_device_nand,
0200     &smdk_led4,
0201     &smdk_led5,
0202     &smdk_led6,
0203     &smdk_led7,
0204 };
0205 
0206 void __init smdk_machine_init(void)
0207 {
0208     if (machine_is_smdk2443())
0209         smdk_nand_info.twrph0 = 50;
0210 
0211     s3c_nand_set_platdata(&smdk_nand_info);
0212 
0213     /* Disable pull-up on the LED lines */
0214     s3c_gpio_setpull(S3C2410_GPF(4), S3C_GPIO_PULL_NONE);
0215     s3c_gpio_setpull(S3C2410_GPF(5), S3C_GPIO_PULL_NONE);
0216     s3c_gpio_setpull(S3C2410_GPF(6), S3C_GPIO_PULL_NONE);
0217     s3c_gpio_setpull(S3C2410_GPF(7), S3C_GPIO_PULL_NONE);
0218 
0219     /* Add lookups for the lines */
0220     gpiod_add_lookup_table(&smdk_led4_gpio_table);
0221     gpiod_add_lookup_table(&smdk_led5_gpio_table);
0222     gpiod_add_lookup_table(&smdk_led6_gpio_table);
0223     gpiod_add_lookup_table(&smdk_led7_gpio_table);
0224 
0225     platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
0226 
0227     s3c_pm_init();
0228 }