cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

littleton.c (10985B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 *  linux/arch/arm/mach-pxa/littleton.c
      4 *
      5 *  Support for the Marvell Littleton Development Platform.
      6 *
      7 *  Author:	Jason Chagas (largely modified code)
      8 *  Created:	Nov 20, 2006
      9 *  Copyright:	(C) Copyright 2006 Marvell International Ltd.
     10 *
     11 *  2007-11-22  modified to align with latest kernel
     12 *              eric miao <eric.miao@marvell.com>
     13 */
     14
     15#include <linux/init.h>
     16#include <linux/interrupt.h>
     17#include <linux/delay.h>
     18#include <linux/platform_device.h>
     19#include <linux/clk.h>
     20#include <linux/gpio/machine.h>
     21#include <linux/spi/spi.h>
     22#include <linux/spi/pxa2xx_spi.h>
     23#include <linux/smc91x.h>
     24#include <linux/i2c.h>
     25#include <linux/leds.h>
     26#include <linux/mfd/da903x.h>
     27#include <linux/platform_data/max732x.h>
     28#include <linux/platform_data/i2c-pxa.h>
     29
     30#include <asm/types.h>
     31#include <asm/setup.h>
     32#include <asm/memory.h>
     33#include <asm/mach-types.h>
     34#include <asm/irq.h>
     35
     36#include <asm/mach/arch.h>
     37#include <asm/mach/map.h>
     38#include <asm/mach/irq.h>
     39
     40#include "pxa300.h"
     41#include "devices.h"
     42#include <linux/platform_data/video-pxafb.h>
     43#include <linux/platform_data/mmc-pxamci.h>
     44#include <linux/platform_data/keypad-pxa27x.h>
     45#include "littleton.h"
     46#include <linux/platform_data/mtd-nand-pxa3xx.h>
     47
     48#include "generic.h"
     49
     50/* Littleton MFP configurations */
     51static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
     52	/* LCD */
     53	GPIO54_LCD_LDD_0,
     54	GPIO55_LCD_LDD_1,
     55	GPIO56_LCD_LDD_2,
     56	GPIO57_LCD_LDD_3,
     57	GPIO58_LCD_LDD_4,
     58	GPIO59_LCD_LDD_5,
     59	GPIO60_LCD_LDD_6,
     60	GPIO61_LCD_LDD_7,
     61	GPIO62_LCD_LDD_8,
     62	GPIO63_LCD_LDD_9,
     63	GPIO64_LCD_LDD_10,
     64	GPIO65_LCD_LDD_11,
     65	GPIO66_LCD_LDD_12,
     66	GPIO67_LCD_LDD_13,
     67	GPIO68_LCD_LDD_14,
     68	GPIO69_LCD_LDD_15,
     69	GPIO70_LCD_LDD_16,
     70	GPIO71_LCD_LDD_17,
     71	GPIO72_LCD_FCLK,
     72	GPIO73_LCD_LCLK,
     73	GPIO74_LCD_PCLK,
     74	GPIO75_LCD_BIAS,
     75
     76	/* SSP2 */
     77	GPIO25_SSP2_SCLK,
     78	GPIO27_SSP2_TXD,
     79	GPIO17_GPIO,	/* SFRM as chip-select */
     80
     81	/* Debug Ethernet */
     82	GPIO90_GPIO,
     83
     84	/* Keypad */
     85	GPIO107_KP_DKIN_0,
     86	GPIO108_KP_DKIN_1,
     87	GPIO115_KP_MKIN_0,
     88	GPIO116_KP_MKIN_1,
     89	GPIO117_KP_MKIN_2,
     90	GPIO118_KP_MKIN_3,
     91	GPIO119_KP_MKIN_4,
     92	GPIO120_KP_MKIN_5,
     93	GPIO121_KP_MKOUT_0,
     94	GPIO122_KP_MKOUT_1,
     95	GPIO123_KP_MKOUT_2,
     96	GPIO124_KP_MKOUT_3,
     97	GPIO125_KP_MKOUT_4,
     98
     99	/* MMC1 */
    100	GPIO3_MMC1_DAT0,
    101	GPIO4_MMC1_DAT1,
    102	GPIO5_MMC1_DAT2,
    103	GPIO6_MMC1_DAT3,
    104	GPIO7_MMC1_CLK,
    105	GPIO8_MMC1_CMD,
    106	GPIO15_GPIO, /* card detect */
    107
    108	/* UART3 */
    109	GPIO107_UART3_CTS,
    110	GPIO108_UART3_RTS,
    111	GPIO109_UART3_TXD,
    112	GPIO110_UART3_RXD,
    113};
    114
    115static struct resource smc91x_resources[] = {
    116	[0] = {
    117		.start	= (LITTLETON_ETH_PHYS + 0x300),
    118		.end	= (LITTLETON_ETH_PHYS + 0xfffff),
    119		.flags	= IORESOURCE_MEM,
    120	},
    121	[1] = {
    122		.start	= PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO90)),
    123		.end	= PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO90)),
    124		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
    125	}
    126};
    127
    128static struct smc91x_platdata littleton_smc91x_info = {
    129	.flags	= SMC91X_USE_8BIT | SMC91X_USE_16BIT |
    130		  SMC91X_NOWAIT | SMC91X_USE_DMA,
    131};
    132
    133static struct platform_device smc91x_device = {
    134	.name		= "smc91x",
    135	.id		= 0,
    136	.num_resources	= ARRAY_SIZE(smc91x_resources),
    137	.resource	= smc91x_resources,
    138	.dev		= {
    139		.platform_data = &littleton_smc91x_info,
    140	},
    141};
    142
    143#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
    144static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
    145	[0] = {
    146		/* VGA */
    147		.pixclock	= 38250,
    148		.xres		= 480,
    149		.yres		= 640,
    150		.bpp		= 16,
    151		.hsync_len	= 8,
    152		.left_margin	= 8,
    153		.right_margin	= 24,
    154		.vsync_len	= 2,
    155		.upper_margin	= 2,
    156		.lower_margin	= 4,
    157		.sync		= 0,
    158	},
    159	[1] = {
    160		/* QVGA */
    161		.pixclock	= 153000,
    162		.xres		= 240,
    163		.yres		= 320,
    164		.bpp		= 16,
    165		.hsync_len	= 8,
    166		.left_margin	= 8,
    167		.right_margin	= 88,
    168		.vsync_len	= 2,
    169		.upper_margin	= 2,
    170		.lower_margin	= 2,
    171		.sync		= 0,
    172	},
    173};
    174
    175static struct pxafb_mach_info littleton_lcd_info = {
    176	.modes			= tpo_tdo24mtea1_modes,
    177	.num_modes		= 2,
    178	.lcd_conn		= LCD_COLOR_TFT_16BPP,
    179};
    180
    181static void __init littleton_init_lcd(void)
    182{
    183	pxa_set_fb_info(NULL, &littleton_lcd_info);
    184}
    185#else
    186static inline void littleton_init_lcd(void) {};
    187#endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
    188
    189#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
    190static struct pxa2xx_spi_controller littleton_spi_info = {
    191	.num_chipselect		= 1,
    192};
    193
    194static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
    195	.rx_threshold	= 1,
    196	.tx_threshold	= 1,
    197};
    198
    199static struct spi_board_info littleton_spi_devices[] __initdata = {
    200	{
    201		.modalias	= "tdo24m",
    202		.max_speed_hz	= 1000000,
    203		.bus_num	= 2,
    204		.chip_select	= 0,
    205		.controller_data= &littleton_tdo24m_chip,
    206	},
    207};
    208
    209static struct gpiod_lookup_table littleton_spi_gpio_table = {
    210	.dev_id = "pxa2xx-spi.2",
    211	.table = {
    212		GPIO_LOOKUP_IDX("gpio-pxa", LITTLETON_GPIO_LCD_CS, "cs", 0, GPIO_ACTIVE_LOW),
    213		{ },
    214	},
    215};
    216
    217static void __init littleton_init_spi(void)
    218{
    219	gpiod_add_lookup_table(&littleton_spi_gpio_table);
    220	pxa2xx_set_spi_info(2, &littleton_spi_info);
    221	spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
    222}
    223#else
    224static inline void littleton_init_spi(void) {}
    225#endif
    226
    227#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
    228static const unsigned int littleton_matrix_key_map[] = {
    229	/* KEY(row, col, key_code) */
    230	KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3),
    231	KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7),
    232	KEY(1, 2, KEY_8), KEY(2, 2, KEY_9),
    233
    234	KEY(0, 3, KEY_KPASTERISK), 	/* * */
    235	KEY(2, 3, KEY_KPDOT), 		/* # */
    236
    237	KEY(5, 4, KEY_ENTER),
    238
    239	KEY(5, 0, KEY_UP),
    240	KEY(5, 1, KEY_DOWN),
    241	KEY(5, 2, KEY_LEFT),
    242	KEY(5, 3, KEY_RIGHT),
    243	KEY(3, 2, KEY_HOME),
    244	KEY(4, 1, KEY_END),
    245	KEY(3, 3, KEY_BACK),
    246
    247	KEY(4, 0, KEY_SEND),
    248	KEY(4, 2, KEY_VOLUMEUP),
    249	KEY(4, 3, KEY_VOLUMEDOWN),
    250
    251	KEY(3, 0, KEY_F22),	/* soft1 */
    252	KEY(3, 1, KEY_F23),	/* soft2 */
    253};
    254
    255static struct matrix_keymap_data littleton_matrix_keymap_data = {
    256	.keymap			= littleton_matrix_key_map,
    257	.keymap_size		= ARRAY_SIZE(littleton_matrix_key_map),
    258};
    259
    260static struct pxa27x_keypad_platform_data littleton_keypad_info = {
    261	.matrix_key_rows	= 6,
    262	.matrix_key_cols	= 5,
    263	.matrix_keymap_data	= &littleton_matrix_keymap_data,
    264
    265	.enable_rotary0		= 1,
    266	.rotary0_up_key		= KEY_UP,
    267	.rotary0_down_key	= KEY_DOWN,
    268
    269	.debounce_interval	= 30,
    270};
    271static void __init littleton_init_keypad(void)
    272{
    273	pxa_set_keypad_info(&littleton_keypad_info);
    274}
    275#else
    276static inline void littleton_init_keypad(void) {}
    277#endif
    278
    279#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
    280static struct pxamci_platform_data littleton_mci_platform_data = {
    281	.detect_delay_ms	= 200,
    282	.ocr_mask		= MMC_VDD_32_33 | MMC_VDD_33_34,
    283};
    284
    285static struct gpiod_lookup_table littleton_mci_gpio_table = {
    286	.dev_id = "pxa2xx-mci.0",
    287	.table = {
    288		/* Card detect on MFP (gpio-pxa) GPIO 15 */
    289		GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO15,
    290			    "cd", GPIO_ACTIVE_LOW),
    291		{ },
    292	},
    293};
    294
    295static void __init littleton_init_mmc(void)
    296{
    297	gpiod_add_lookup_table(&littleton_mci_gpio_table);
    298	pxa_set_mci_info(&littleton_mci_platform_data);
    299}
    300#else
    301static inline void littleton_init_mmc(void) {}
    302#endif
    303
    304#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
    305static struct mtd_partition littleton_nand_partitions[] = {
    306	[0] = {
    307		.name        = "Bootloader",
    308		.offset      = 0,
    309		.size        = 0x060000,
    310		.mask_flags  = MTD_WRITEABLE, /* force read-only */
    311	},
    312	[1] = {
    313		.name        = "Kernel",
    314		.offset      = 0x060000,
    315		.size        = 0x200000,
    316		.mask_flags  = MTD_WRITEABLE, /* force read-only */
    317	},
    318	[2] = {
    319		.name        = "Filesystem",
    320		.offset      = 0x0260000,
    321		.size        = 0x3000000,     /* 48M - rootfs */
    322	},
    323	[3] = {
    324		.name        = "MassStorage",
    325		.offset      = 0x3260000,
    326		.size        = 0x3d40000,
    327	},
    328	[4] = {
    329		.name        = "BBT",
    330		.offset      = 0x6FA0000,
    331		.size        = 0x80000,
    332		.mask_flags  = MTD_WRITEABLE,  /* force read-only */
    333	},
    334	/* NOTE: we reserve some blocks at the end of the NAND flash for
    335	 * bad block management, and the max number of relocation blocks
    336	 * differs on different platforms. Please take care with it when
    337	 * defining the partition table.
    338	 */
    339};
    340
    341static struct pxa3xx_nand_platform_data littleton_nand_info = {
    342	.parts		= littleton_nand_partitions,
    343	.nr_parts	= ARRAY_SIZE(littleton_nand_partitions),
    344};
    345
    346static void __init littleton_init_nand(void)
    347{
    348	pxa3xx_set_nand_info(&littleton_nand_info);
    349}
    350#else
    351static inline void littleton_init_nand(void) {}
    352#endif /* IS_ENABLED(CONFIG_MTD_NAND_MARVELL) */
    353
    354#if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
    355static struct led_info littleton_da9034_leds[] = {
    356	[0] = {
    357		.name	= "littleton:keypad1",
    358		.flags	= DA9034_LED_RAMP,
    359	},
    360	[1] = {
    361		.name	= "littleton:keypad2",
    362		.flags	= DA9034_LED_RAMP,
    363	},
    364	[2] = {
    365		.name	= "littleton:vibra",
    366		.flags	= 0,
    367	},
    368};
    369
    370static struct da9034_touch_pdata littleton_da9034_touch = {
    371	.x_inverted     = 1,
    372	.interval_ms    = 20,
    373};
    374
    375static struct da903x_subdev_info littleton_da9034_subdevs[] = {
    376	{
    377		.name		= "da903x-led",
    378		.id		= DA9034_ID_LED_1,
    379		.platform_data	= &littleton_da9034_leds[0],
    380	}, {
    381		.name		= "da903x-led",
    382		.id		= DA9034_ID_LED_2,
    383		.platform_data	= &littleton_da9034_leds[1],
    384	}, {
    385		.name		= "da903x-led",
    386		.id		= DA9034_ID_VIBRA,
    387		.platform_data	= &littleton_da9034_leds[2],
    388	}, {
    389		.name		= "da903x-backlight",
    390		.id		= DA9034_ID_WLED,
    391	}, {
    392		.name		= "da9034-touch",
    393		.id		= DA9034_ID_TOUCH,
    394		.platform_data	= &littleton_da9034_touch,
    395	},
    396};
    397
    398static struct da903x_platform_data littleton_da9034_info = {
    399	.num_subdevs	= ARRAY_SIZE(littleton_da9034_subdevs),
    400	.subdevs	= littleton_da9034_subdevs,
    401};
    402
    403static struct max732x_platform_data littleton_max7320_info = {
    404	.gpio_base	= EXT0_GPIO_BASE,
    405};
    406
    407static struct i2c_board_info littleton_i2c_info[] = {
    408	[0] = {
    409		.type		= "da9034",
    410		.addr		= 0x34,
    411		.platform_data	= &littleton_da9034_info,
    412		.irq		= PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO18)),
    413	},
    414	[1] = {
    415		.type		= "max7320",
    416		.addr		= 0x50,
    417		.platform_data	= &littleton_max7320_info,
    418	},
    419};
    420
    421static void __init littleton_init_i2c(void)
    422{
    423	pxa_set_i2c_info(NULL);
    424	i2c_register_board_info(0, ARRAY_AND_SIZE(littleton_i2c_info));
    425}
    426#else
    427static inline void littleton_init_i2c(void) {}
    428#endif /* CONFIG_I2C_PXA || CONFIG_I2C_PXA_MODULE */
    429
    430static void __init littleton_init(void)
    431{
    432	/* initialize MFP configurations */
    433	pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
    434
    435	pxa_set_ffuart_info(NULL);
    436	pxa_set_btuart_info(NULL);
    437	pxa_set_stuart_info(NULL);
    438
    439	/*
    440	 * Note: we depend bootloader set the correct
    441	 * value to MSC register for SMC91x.
    442	 */
    443	platform_device_register(&smc91x_device);
    444
    445	littleton_init_spi();
    446	littleton_init_i2c();
    447	littleton_init_mmc();
    448	littleton_init_lcd();
    449	littleton_init_keypad();
    450	littleton_init_nand();
    451}
    452
    453MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
    454	.atag_offset	= 0x100,
    455	.map_io		= pxa3xx_map_io,
    456	.nr_irqs	= LITTLETON_NR_IRQS,
    457	.init_irq	= pxa3xx_init_irq,
    458	.handle_irq	= pxa3xx_handle_irq,
    459	.init_time	= pxa_timer_init,
    460	.init_machine	= littleton_init,
    461	.restart	= pxa_restart,
    462MACHINE_END