Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 //
0003 // Copyright (c) 2006 American Microsystems Limited
0004 //  David Anders <danders@amltd.com>
0005 //
0006 // @History:
0007 // derived from linux/arch/arm/mach-s3c2410/mach-bast.c, written by
0008 // Ben Dooks <ben@simtec.co.uk>
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/machine.h>
0017 #include <linux/gpio.h>
0018 #include <linux/device.h>
0019 #include <linux/platform_device.h>
0020 #include <linux/proc_fs.h>
0021 #include <linux/serial_core.h>
0022 #include <linux/serial_s3c.h>
0023 #include <linux/io.h>
0024 
0025 #include <asm/mach/arch.h>
0026 #include <asm/mach/map.h>
0027 #include <asm/mach/irq.h>
0028 #include <asm/mach/flash.h>
0029 
0030 #include <asm/irq.h>
0031 #include <asm/mach-types.h>
0032 #include <linux/platform_data/fb-s3c2410.h>
0033 
0034 #include "regs-gpio.h"
0035 #include "gpio-samsung.h"
0036 
0037 #include <linux/platform_data/i2c-s3c2410.h>
0038 #include "devs.h"
0039 #include "cpu.h"
0040 #include "gpio-cfg.h"
0041 
0042 #include <linux/mtd/mtd.h>
0043 #include <linux/mtd/partitions.h>
0044 #include <linux/mtd/map.h>
0045 #include <linux/mtd/physmap.h>
0046 
0047 #include "s3c24xx.h"
0048 
0049 static struct resource amlm5900_nor_resource =
0050             DEFINE_RES_MEM(0x00000000, SZ_16M);
0051 
0052 static struct mtd_partition amlm5900_mtd_partitions[] = {
0053     {
0054         .name       = "System",
0055         .size       = 0x240000,
0056         .offset     = 0,
0057         .mask_flags     = MTD_WRITEABLE,  /* force read-only */
0058     }, {
0059         .name       = "Kernel",
0060         .size       = 0x100000,
0061         .offset     = MTDPART_OFS_APPEND,
0062     }, {
0063         .name       = "Ramdisk",
0064         .size       = 0x300000,
0065         .offset     = MTDPART_OFS_APPEND,
0066     }, {
0067         .name       = "JFFS2",
0068         .size       = 0x9A0000,
0069         .offset     = MTDPART_OFS_APPEND,
0070     }, {
0071         .name       = "Settings",
0072         .size       = MTDPART_SIZ_FULL,
0073         .offset     = MTDPART_OFS_APPEND,
0074     }
0075 };
0076 
0077 static struct physmap_flash_data amlm5900_flash_data = {
0078     .width      = 2,
0079     .parts      = amlm5900_mtd_partitions,
0080     .nr_parts   = ARRAY_SIZE(amlm5900_mtd_partitions),
0081 };
0082 
0083 static struct platform_device amlm5900_device_nor = {
0084     .name       = "physmap-flash",
0085     .id     = 0,
0086     .dev = {
0087             .platform_data = &amlm5900_flash_data,
0088         },
0089     .num_resources  = 1,
0090     .resource   = &amlm5900_nor_resource,
0091 };
0092 
0093 static struct map_desc amlm5900_iodesc[] __initdata = {
0094 };
0095 
0096 #define UCON S3C2410_UCON_DEFAULT
0097 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
0098 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
0099 
0100 static struct s3c2410_uartcfg amlm5900_uartcfgs[] = {
0101     [0] = {
0102         .hwport      = 0,
0103         .flags       = 0,
0104         .ucon        = UCON,
0105         .ulcon       = ULCON,
0106         .ufcon       = UFCON,
0107     },
0108     [1] = {
0109         .hwport      = 1,
0110         .flags       = 0,
0111         .ucon        = UCON,
0112         .ulcon       = ULCON,
0113         .ufcon       = UFCON,
0114     },
0115     [2] = {
0116         .hwport      = 2,
0117         .flags       = 0,
0118         .ucon        = UCON,
0119         .ulcon       = ULCON,
0120         .ufcon       = UFCON,
0121     }
0122 };
0123 
0124 static struct gpiod_lookup_table amlm5900_mmc_gpio_table = {
0125     .dev_id = "s3c2410-sdi",
0126     .table = {
0127         /* bus pins */
0128         GPIO_LOOKUP_IDX("GPIOE",  5, "bus", 0, GPIO_ACTIVE_HIGH),
0129         GPIO_LOOKUP_IDX("GPIOE",  6, "bus", 1, GPIO_ACTIVE_HIGH),
0130         GPIO_LOOKUP_IDX("GPIOE",  7, "bus", 2, GPIO_ACTIVE_HIGH),
0131         GPIO_LOOKUP_IDX("GPIOE",  8, "bus", 3, GPIO_ACTIVE_HIGH),
0132         GPIO_LOOKUP_IDX("GPIOE",  9, "bus", 4, GPIO_ACTIVE_HIGH),
0133         GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
0134         { },
0135     },
0136 };
0137 
0138 static struct platform_device *amlm5900_devices[] __initdata = {
0139 #ifdef CONFIG_FB_S3C2410
0140     &s3c_device_lcd,
0141 #endif
0142     &s3c_device_adc,
0143     &s3c_device_wdt,
0144     &s3c_device_i2c0,
0145     &s3c_device_ohci,
0146     &s3c_device_rtc,
0147     &s3c_device_usbgadget,
0148         &s3c_device_sdi,
0149     &amlm5900_device_nor,
0150 };
0151 
0152 static void __init amlm5900_map_io(void)
0153 {
0154     s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc));
0155     s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs));
0156     s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
0157 }
0158 
0159 static void __init amlm5900_init_time(void)
0160 {
0161     s3c2410_init_clocks(12000000);
0162     s3c24xx_timer_init();
0163 }
0164 
0165 #ifdef CONFIG_FB_S3C2410
0166 static struct s3c2410fb_display __initdata amlm5900_lcd_info = {
0167     .width      = 160,
0168     .height     = 160,
0169 
0170     .type       = S3C2410_LCDCON1_STN4,
0171 
0172     .pixclock   = 680000, /* HCLK = 100MHz */
0173     .xres       = 160,
0174     .yres       = 160,
0175     .bpp        = 4,
0176     .left_margin    = 1 << (4 + 3),
0177     .right_margin   = 8 << 3,
0178     .hsync_len  = 48,
0179     .upper_margin   = 0,
0180     .lower_margin   = 0,
0181 
0182     .lcdcon5    = 0x00000001,
0183 };
0184 
0185 static struct s3c2410fb_mach_info __initdata amlm5900_fb_info = {
0186 
0187     .displays = &amlm5900_lcd_info,
0188     .num_displays = 1,
0189     .default_display = 0,
0190 
0191     .gpccon =   0xaaaaaaaa,
0192     .gpccon_mask =  0xffffffff,
0193     .gpccon_reg =   S3C2410_GPCCON,
0194     .gpcup =    0x0000ffff,
0195     .gpcup_mask =   0xffffffff,
0196     .gpcup_reg =    S3C2410_GPCUP,
0197 
0198     .gpdcon =   0xaaaaaaaa,
0199     .gpdcon_mask =  0xffffffff,
0200     .gpdcon_reg =   S3C2410_GPDCON,
0201     .gpdup =    0x0000ffff,
0202     .gpdup_mask =   0xffffffff,
0203     .gpdup_reg =    S3C2410_GPDUP,
0204 };
0205 #endif
0206 
0207 static irqreturn_t
0208 amlm5900_wake_interrupt(int irq, void *ignored)
0209 {
0210     return IRQ_HANDLED;
0211 }
0212 
0213 static void amlm5900_init_pm(void)
0214 {
0215     int ret = 0;
0216 
0217     ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt,
0218                 IRQF_TRIGGER_RISING | IRQF_SHARED,
0219                 "amlm5900_wakeup", &amlm5900_wake_interrupt);
0220     if (ret != 0) {
0221         printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret);
0222     } else {
0223         enable_irq_wake(IRQ_EINT9);
0224         /* configure the suspend/resume status pin */
0225         s3c_gpio_cfgpin(S3C2410_GPF(2), S3C2410_GPIO_OUTPUT);
0226         s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_UP);
0227     }
0228 }
0229 static void __init amlm5900_init(void)
0230 {
0231     amlm5900_init_pm();
0232 #ifdef CONFIG_FB_S3C2410
0233     s3c24xx_fb_set_platdata(&amlm5900_fb_info);
0234 #endif
0235     s3c_i2c0_set_platdata(NULL);
0236     gpiod_add_lookup_table(&amlm5900_mmc_gpio_table);
0237     platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices));
0238 }
0239 
0240 MACHINE_START(AML_M5900, "AML_M5900")
0241     .atag_offset    = 0x100,
0242     .nr_irqs    = NR_IRQS_S3C2410,
0243     .map_io     = amlm5900_map_io,
0244     .nr_irqs    = NR_IRQS_S3C2410,
0245     .init_irq   = s3c2410_init_irq,
0246     .init_machine   = amlm5900_init,
0247     .init_time  = amlm5900_init_time,
0248 MACHINE_END