Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  linux/arch/arm/mach-pxa/littleton.c
0004  *
0005  *  Support for the Marvell Littleton Development Platform.
0006  *
0007  *  Author: Jason Chagas (largely modified code)
0008  *  Created:    Nov 20, 2006
0009  *  Copyright:  (C) Copyright 2006 Marvell International Ltd.
0010  *
0011  *  2007-11-22  modified to align with latest kernel
0012  *              eric miao <eric.miao@marvell.com>
0013  */
0014 
0015 #include <linux/init.h>
0016 #include <linux/interrupt.h>
0017 #include <linux/delay.h>
0018 #include <linux/platform_device.h>
0019 #include <linux/clk.h>
0020 #include <linux/gpio/machine.h>
0021 #include <linux/spi/spi.h>
0022 #include <linux/spi/pxa2xx_spi.h>
0023 #include <linux/smc91x.h>
0024 #include <linux/i2c.h>
0025 #include <linux/leds.h>
0026 #include <linux/mfd/da903x.h>
0027 #include <linux/platform_data/max732x.h>
0028 #include <linux/platform_data/i2c-pxa.h>
0029 
0030 #include <asm/types.h>
0031 #include <asm/setup.h>
0032 #include <asm/memory.h>
0033 #include <asm/mach-types.h>
0034 #include <asm/irq.h>
0035 
0036 #include <asm/mach/arch.h>
0037 #include <asm/mach/map.h>
0038 #include <asm/mach/irq.h>
0039 
0040 #include "pxa300.h"
0041 #include "devices.h"
0042 #include <linux/platform_data/video-pxafb.h>
0043 #include <linux/platform_data/mmc-pxamci.h>
0044 #include <linux/platform_data/keypad-pxa27x.h>
0045 #include "littleton.h"
0046 #include <linux/platform_data/mtd-nand-pxa3xx.h>
0047 
0048 #include "generic.h"
0049 
0050 /* Littleton MFP configurations */
0051 static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
0052     /* LCD */
0053     GPIO54_LCD_LDD_0,
0054     GPIO55_LCD_LDD_1,
0055     GPIO56_LCD_LDD_2,
0056     GPIO57_LCD_LDD_3,
0057     GPIO58_LCD_LDD_4,
0058     GPIO59_LCD_LDD_5,
0059     GPIO60_LCD_LDD_6,
0060     GPIO61_LCD_LDD_7,
0061     GPIO62_LCD_LDD_8,
0062     GPIO63_LCD_LDD_9,
0063     GPIO64_LCD_LDD_10,
0064     GPIO65_LCD_LDD_11,
0065     GPIO66_LCD_LDD_12,
0066     GPIO67_LCD_LDD_13,
0067     GPIO68_LCD_LDD_14,
0068     GPIO69_LCD_LDD_15,
0069     GPIO70_LCD_LDD_16,
0070     GPIO71_LCD_LDD_17,
0071     GPIO72_LCD_FCLK,
0072     GPIO73_LCD_LCLK,
0073     GPIO74_LCD_PCLK,
0074     GPIO75_LCD_BIAS,
0075 
0076     /* SSP2 */
0077     GPIO25_SSP2_SCLK,
0078     GPIO27_SSP2_TXD,
0079     GPIO17_GPIO,    /* SFRM as chip-select */
0080 
0081     /* Debug Ethernet */
0082     GPIO90_GPIO,
0083 
0084     /* Keypad */
0085     GPIO107_KP_DKIN_0,
0086     GPIO108_KP_DKIN_1,
0087     GPIO115_KP_MKIN_0,
0088     GPIO116_KP_MKIN_1,
0089     GPIO117_KP_MKIN_2,
0090     GPIO118_KP_MKIN_3,
0091     GPIO119_KP_MKIN_4,
0092     GPIO120_KP_MKIN_5,
0093     GPIO121_KP_MKOUT_0,
0094     GPIO122_KP_MKOUT_1,
0095     GPIO123_KP_MKOUT_2,
0096     GPIO124_KP_MKOUT_3,
0097     GPIO125_KP_MKOUT_4,
0098 
0099     /* MMC1 */
0100     GPIO3_MMC1_DAT0,
0101     GPIO4_MMC1_DAT1,
0102     GPIO5_MMC1_DAT2,
0103     GPIO6_MMC1_DAT3,
0104     GPIO7_MMC1_CLK,
0105     GPIO8_MMC1_CMD,
0106     GPIO15_GPIO, /* card detect */
0107 
0108     /* UART3 */
0109     GPIO107_UART3_CTS,
0110     GPIO108_UART3_RTS,
0111     GPIO109_UART3_TXD,
0112     GPIO110_UART3_RXD,
0113 };
0114 
0115 static struct resource smc91x_resources[] = {
0116     [0] = {
0117         .start  = (LITTLETON_ETH_PHYS + 0x300),
0118         .end    = (LITTLETON_ETH_PHYS + 0xfffff),
0119         .flags  = IORESOURCE_MEM,
0120     },
0121     [1] = {
0122         .start  = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO90)),
0123         .end    = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO90)),
0124         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
0125     }
0126 };
0127 
0128 static struct smc91x_platdata littleton_smc91x_info = {
0129     .flags  = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
0130           SMC91X_NOWAIT | SMC91X_USE_DMA,
0131 };
0132 
0133 static struct platform_device smc91x_device = {
0134     .name       = "smc91x",
0135     .id     = 0,
0136     .num_resources  = ARRAY_SIZE(smc91x_resources),
0137     .resource   = smc91x_resources,
0138     .dev        = {
0139         .platform_data = &littleton_smc91x_info,
0140     },
0141 };
0142 
0143 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
0144 static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
0145     [0] = {
0146         /* VGA */
0147         .pixclock   = 38250,
0148         .xres       = 480,
0149         .yres       = 640,
0150         .bpp        = 16,
0151         .hsync_len  = 8,
0152         .left_margin    = 8,
0153         .right_margin   = 24,
0154         .vsync_len  = 2,
0155         .upper_margin   = 2,
0156         .lower_margin   = 4,
0157         .sync       = 0,
0158     },
0159     [1] = {
0160         /* QVGA */
0161         .pixclock   = 153000,
0162         .xres       = 240,
0163         .yres       = 320,
0164         .bpp        = 16,
0165         .hsync_len  = 8,
0166         .left_margin    = 8,
0167         .right_margin   = 88,
0168         .vsync_len  = 2,
0169         .upper_margin   = 2,
0170         .lower_margin   = 2,
0171         .sync       = 0,
0172     },
0173 };
0174 
0175 static struct pxafb_mach_info littleton_lcd_info = {
0176     .modes          = tpo_tdo24mtea1_modes,
0177     .num_modes      = 2,
0178     .lcd_conn       = LCD_COLOR_TFT_16BPP,
0179 };
0180 
0181 static void __init littleton_init_lcd(void)
0182 {
0183     pxa_set_fb_info(NULL, &littleton_lcd_info);
0184 }
0185 #else
0186 static inline void littleton_init_lcd(void) {};
0187 #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
0188 
0189 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
0190 static struct pxa2xx_spi_controller littleton_spi_info = {
0191     .num_chipselect     = 1,
0192 };
0193 
0194 static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
0195     .rx_threshold   = 1,
0196     .tx_threshold   = 1,
0197 };
0198 
0199 static struct spi_board_info littleton_spi_devices[] __initdata = {
0200     {
0201         .modalias   = "tdo24m",
0202         .max_speed_hz   = 1000000,
0203         .bus_num    = 2,
0204         .chip_select    = 0,
0205         .controller_data= &littleton_tdo24m_chip,
0206     },
0207 };
0208 
0209 static struct gpiod_lookup_table littleton_spi_gpio_table = {
0210     .dev_id = "spi2",
0211     .table = {
0212         GPIO_LOOKUP_IDX("gpio-pxa", LITTLETON_GPIO_LCD_CS, "cs", 0, GPIO_ACTIVE_LOW),
0213         { },
0214     },
0215 };
0216 
0217 static void __init littleton_init_spi(void)
0218 {
0219     gpiod_add_lookup_table(&littleton_spi_gpio_table);
0220     pxa2xx_set_spi_info(2, &littleton_spi_info);
0221     spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
0222 }
0223 #else
0224 static inline void littleton_init_spi(void) {}
0225 #endif
0226 
0227 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
0228 static const unsigned int littleton_matrix_key_map[] = {
0229     /* KEY(row, col, key_code) */
0230     KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3),
0231     KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7),
0232     KEY(1, 2, KEY_8), KEY(2, 2, KEY_9),
0233 
0234     KEY(0, 3, KEY_KPASTERISK),  /* * */
0235     KEY(2, 3, KEY_KPDOT),       /* # */
0236 
0237     KEY(5, 4, KEY_ENTER),
0238 
0239     KEY(5, 0, KEY_UP),
0240     KEY(5, 1, KEY_DOWN),
0241     KEY(5, 2, KEY_LEFT),
0242     KEY(5, 3, KEY_RIGHT),
0243     KEY(3, 2, KEY_HOME),
0244     KEY(4, 1, KEY_END),
0245     KEY(3, 3, KEY_BACK),
0246 
0247     KEY(4, 0, KEY_SEND),
0248     KEY(4, 2, KEY_VOLUMEUP),
0249     KEY(4, 3, KEY_VOLUMEDOWN),
0250 
0251     KEY(3, 0, KEY_F22), /* soft1 */
0252     KEY(3, 1, KEY_F23), /* soft2 */
0253 };
0254 
0255 static struct matrix_keymap_data littleton_matrix_keymap_data = {
0256     .keymap         = littleton_matrix_key_map,
0257     .keymap_size        = ARRAY_SIZE(littleton_matrix_key_map),
0258 };
0259 
0260 static struct pxa27x_keypad_platform_data littleton_keypad_info = {
0261     .matrix_key_rows    = 6,
0262     .matrix_key_cols    = 5,
0263     .matrix_keymap_data = &littleton_matrix_keymap_data,
0264 
0265     .enable_rotary0     = 1,
0266     .rotary0_up_key     = KEY_UP,
0267     .rotary0_down_key   = KEY_DOWN,
0268 
0269     .debounce_interval  = 30,
0270 };
0271 static void __init littleton_init_keypad(void)
0272 {
0273     pxa_set_keypad_info(&littleton_keypad_info);
0274 }
0275 #else
0276 static inline void littleton_init_keypad(void) {}
0277 #endif
0278 
0279 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
0280 static struct pxamci_platform_data littleton_mci_platform_data = {
0281     .detect_delay_ms    = 200,
0282     .ocr_mask       = MMC_VDD_32_33 | MMC_VDD_33_34,
0283 };
0284 
0285 static struct gpiod_lookup_table littleton_mci_gpio_table = {
0286     .dev_id = "pxa2xx-mci.0",
0287     .table = {
0288         /* Card detect on MFP (gpio-pxa) GPIO 15 */
0289         GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO15,
0290                 "cd", GPIO_ACTIVE_LOW),
0291         { },
0292     },
0293 };
0294 
0295 static void __init littleton_init_mmc(void)
0296 {
0297     gpiod_add_lookup_table(&littleton_mci_gpio_table);
0298     pxa_set_mci_info(&littleton_mci_platform_data);
0299 }
0300 #else
0301 static inline void littleton_init_mmc(void) {}
0302 #endif
0303 
0304 #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
0305 static struct mtd_partition littleton_nand_partitions[] = {
0306     [0] = {
0307         .name        = "Bootloader",
0308         .offset      = 0,
0309         .size        = 0x060000,
0310         .mask_flags  = MTD_WRITEABLE, /* force read-only */
0311     },
0312     [1] = {
0313         .name        = "Kernel",
0314         .offset      = 0x060000,
0315         .size        = 0x200000,
0316         .mask_flags  = MTD_WRITEABLE, /* force read-only */
0317     },
0318     [2] = {
0319         .name        = "Filesystem",
0320         .offset      = 0x0260000,
0321         .size        = 0x3000000,     /* 48M - rootfs */
0322     },
0323     [3] = {
0324         .name        = "MassStorage",
0325         .offset      = 0x3260000,
0326         .size        = 0x3d40000,
0327     },
0328     [4] = {
0329         .name        = "BBT",
0330         .offset      = 0x6FA0000,
0331         .size        = 0x80000,
0332         .mask_flags  = MTD_WRITEABLE,  /* force read-only */
0333     },
0334     /* NOTE: we reserve some blocks at the end of the NAND flash for
0335      * bad block management, and the max number of relocation blocks
0336      * differs on different platforms. Please take care with it when
0337      * defining the partition table.
0338      */
0339 };
0340 
0341 static struct pxa3xx_nand_platform_data littleton_nand_info = {
0342     .parts      = littleton_nand_partitions,
0343     .nr_parts   = ARRAY_SIZE(littleton_nand_partitions),
0344 };
0345 
0346 static void __init littleton_init_nand(void)
0347 {
0348     pxa3xx_set_nand_info(&littleton_nand_info);
0349 }
0350 #else
0351 static inline void littleton_init_nand(void) {}
0352 #endif /* IS_ENABLED(CONFIG_MTD_NAND_MARVELL) */
0353 
0354 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
0355 static struct led_info littleton_da9034_leds[] = {
0356     [0] = {
0357         .name   = "littleton:keypad1",
0358         .flags  = DA9034_LED_RAMP,
0359     },
0360     [1] = {
0361         .name   = "littleton:keypad2",
0362         .flags  = DA9034_LED_RAMP,
0363     },
0364     [2] = {
0365         .name   = "littleton:vibra",
0366         .flags  = 0,
0367     },
0368 };
0369 
0370 static struct da9034_touch_pdata littleton_da9034_touch = {
0371     .x_inverted     = 1,
0372     .interval_ms    = 20,
0373 };
0374 
0375 static struct da903x_subdev_info littleton_da9034_subdevs[] = {
0376     {
0377         .name       = "da903x-led",
0378         .id     = DA9034_ID_LED_1,
0379         .platform_data  = &littleton_da9034_leds[0],
0380     }, {
0381         .name       = "da903x-led",
0382         .id     = DA9034_ID_LED_2,
0383         .platform_data  = &littleton_da9034_leds[1],
0384     }, {
0385         .name       = "da903x-led",
0386         .id     = DA9034_ID_VIBRA,
0387         .platform_data  = &littleton_da9034_leds[2],
0388     }, {
0389         .name       = "da903x-backlight",
0390         .id     = DA9034_ID_WLED,
0391     }, {
0392         .name       = "da9034-touch",
0393         .id     = DA9034_ID_TOUCH,
0394         .platform_data  = &littleton_da9034_touch,
0395     },
0396 };
0397 
0398 static struct da903x_platform_data littleton_da9034_info = {
0399     .num_subdevs    = ARRAY_SIZE(littleton_da9034_subdevs),
0400     .subdevs    = littleton_da9034_subdevs,
0401 };
0402 
0403 static struct max732x_platform_data littleton_max7320_info = {
0404     .gpio_base  = EXT0_GPIO_BASE,
0405 };
0406 
0407 static struct i2c_board_info littleton_i2c_info[] = {
0408     [0] = {
0409         .type       = "da9034",
0410         .addr       = 0x34,
0411         .platform_data  = &littleton_da9034_info,
0412         .irq        = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO18)),
0413     },
0414     [1] = {
0415         .type       = "max7320",
0416         .addr       = 0x50,
0417         .platform_data  = &littleton_max7320_info,
0418     },
0419 };
0420 
0421 static void __init littleton_init_i2c(void)
0422 {
0423     pxa_set_i2c_info(NULL);
0424     i2c_register_board_info(0, ARRAY_AND_SIZE(littleton_i2c_info));
0425 }
0426 #else
0427 static inline void littleton_init_i2c(void) {}
0428 #endif /* CONFIG_I2C_PXA || CONFIG_I2C_PXA_MODULE */
0429 
0430 static void __init littleton_init(void)
0431 {
0432     /* initialize MFP configurations */
0433     pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
0434 
0435     pxa_set_ffuart_info(NULL);
0436     pxa_set_btuart_info(NULL);
0437     pxa_set_stuart_info(NULL);
0438 
0439     /*
0440      * Note: we depend bootloader set the correct
0441      * value to MSC register for SMC91x.
0442      */
0443     platform_device_register(&smc91x_device);
0444 
0445     littleton_init_spi();
0446     littleton_init_i2c();
0447     littleton_init_mmc();
0448     littleton_init_lcd();
0449     littleton_init_keypad();
0450     littleton_init_nand();
0451 }
0452 
0453 MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
0454     .atag_offset    = 0x100,
0455     .map_io     = pxa3xx_map_io,
0456     .nr_irqs    = LITTLETON_NR_IRQS,
0457     .init_irq   = pxa3xx_init_irq,
0458     .handle_irq = pxa3xx_handle_irq,
0459     .init_time  = pxa_timer_init,
0460     .init_machine   = littleton_init,
0461     .restart    = pxa_restart,
0462 MACHINE_END