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

zylonite_pxa300.c (6306B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 * linux/arch/arm/mach-pxa/zylonite_pxa300.c
      4 *
      5 * PXA300/PXA310 specific support code for the
      6 * PXA3xx Development Platform (aka Zylonite)
      7 *
      8 * Copyright (C) 2007 Marvell Internation Ltd.
      9 * 2007-08-21: eric miao <eric.miao@marvell.com>
     10 *             initial version
     11 */
     12
     13#include <linux/module.h>
     14#include <linux/kernel.h>
     15#include <linux/init.h>
     16#include <linux/i2c.h>
     17#include <linux/platform_data/i2c-pxa.h>
     18#include <linux/platform_data/pca953x.h>
     19#include <linux/gpio.h>
     20#include <linux/soc/pxa/cpu.h>
     21
     22#include "pxa300.h"
     23#include "devices.h"
     24#include "zylonite.h"
     25
     26#include "generic.h"
     27
     28/* PXA300/PXA310 common configurations */
     29static mfp_cfg_t common_mfp_cfg[] __initdata = {
     30	/* LCD */
     31	GPIO54_LCD_LDD_0,
     32	GPIO55_LCD_LDD_1,
     33	GPIO56_LCD_LDD_2,
     34	GPIO57_LCD_LDD_3,
     35	GPIO58_LCD_LDD_4,
     36	GPIO59_LCD_LDD_5,
     37	GPIO60_LCD_LDD_6,
     38	GPIO61_LCD_LDD_7,
     39	GPIO62_LCD_LDD_8,
     40	GPIO63_LCD_LDD_9,
     41	GPIO64_LCD_LDD_10,
     42	GPIO65_LCD_LDD_11,
     43	GPIO66_LCD_LDD_12,
     44	GPIO67_LCD_LDD_13,
     45	GPIO68_LCD_LDD_14,
     46	GPIO69_LCD_LDD_15,
     47	GPIO70_LCD_LDD_16,
     48	GPIO71_LCD_LDD_17,
     49	GPIO72_LCD_FCLK,
     50	GPIO73_LCD_LCLK,
     51	GPIO74_LCD_PCLK,
     52	GPIO75_LCD_BIAS,
     53	GPIO76_LCD_VSYNC,
     54	GPIO127_LCD_CS_N,
     55	GPIO20_PWM3_OUT,	/* backlight */
     56
     57	/* BTUART */
     58	GPIO111_UART2_RTS,
     59	GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
     60	GPIO113_UART2_TXD,
     61	GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
     62
     63	/* STUART */
     64	GPIO109_UART3_TXD,
     65	GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
     66
     67	/* AC97 */
     68	GPIO23_AC97_nACRESET,
     69	GPIO24_AC97_SYSCLK,
     70	GPIO29_AC97_BITCLK,
     71	GPIO25_AC97_SDATA_IN_0,
     72	GPIO27_AC97_SDATA_OUT,
     73	GPIO28_AC97_SYNC,
     74	GPIO17_GPIO,	/* SDATA_IN_1 but unused - configure to GPIO */
     75
     76	/* SSP3 */
     77	GPIO91_SSP3_SCLK,
     78	GPIO92_SSP3_FRM,
     79	GPIO93_SSP3_TXD,
     80	GPIO94_SSP3_RXD,
     81
     82	/* WM9713 IRQ */
     83	GPIO26_GPIO,
     84
     85	/* Keypad */
     86	GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
     87	GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
     88	GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
     89	GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
     90	GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
     91	GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
     92	GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
     93	GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
     94	GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
     95	GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
     96	GPIO121_KP_MKOUT_0,
     97	GPIO122_KP_MKOUT_1,
     98	GPIO123_KP_MKOUT_2,
     99	GPIO124_KP_MKOUT_3,
    100	GPIO125_KP_MKOUT_4,
    101	GPIO4_2_KP_MKOUT_5,
    102	GPIO5_2_KP_MKOUT_6,
    103	GPIO6_2_KP_MKOUT_7,
    104
    105	/* MMC1 */
    106	GPIO3_MMC1_DAT0,
    107	GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
    108	GPIO5_MMC1_DAT2,
    109	GPIO6_MMC1_DAT3,
    110	GPIO7_MMC1_CLK,
    111	GPIO8_MMC1_CMD,	/* CMD0 for slot 0 */
    112	GPIO15_GPIO,	/* CMD1 default as GPIO for slot 0 */
    113
    114	/* MMC2 */
    115	GPIO9_MMC2_DAT0,
    116	GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
    117	GPIO11_MMC2_DAT2,
    118	GPIO12_MMC2_DAT3,
    119	GPIO13_MMC2_CLK,
    120	GPIO14_MMC2_CMD,
    121
    122	/* USB Host */
    123	GPIO0_2_USBH_PEN,
    124	GPIO1_2_USBH_PWR,
    125
    126	/* Standard I2C */
    127	GPIO21_I2C_SCL,
    128	GPIO22_I2C_SDA,
    129
    130	/* GPIO */
    131	GPIO18_GPIO | MFP_PULL_HIGH,	/* GPIO Expander #0 INT_N */
    132	GPIO19_GPIO | MFP_PULL_HIGH,	/* GPIO Expander #1 INT_N */
    133};
    134
    135static mfp_cfg_t pxa300_mfp_cfg[] __initdata = {
    136	/* FFUART */
    137	GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
    138	GPIO31_UART1_TXD,
    139	GPIO32_UART1_CTS,
    140	GPIO37_UART1_RTS,
    141	GPIO33_UART1_DCD,
    142	GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
    143	GPIO35_UART1_RI,
    144	GPIO36_UART1_DTR,
    145
    146	/* Ethernet */
    147	GPIO2_nCS3,
    148	GPIO99_GPIO,
    149};
    150
    151static mfp_cfg_t pxa310_mfp_cfg[] __initdata = {
    152	/* FFUART */
    153	GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL,
    154	GPIO100_UART1_TXD,
    155	GPIO101_UART1_CTS,
    156	GPIO106_UART1_RTS,
    157
    158	/* Ethernet */
    159	GPIO2_nCS3,
    160	GPIO102_GPIO,
    161
    162	/* MMC3 */
    163	GPIO7_2_MMC3_DAT0,
    164	GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH,
    165	GPIO9_2_MMC3_DAT2,
    166	GPIO10_2_MMC3_DAT3,
    167	GPIO103_MMC3_CLK,
    168	GPIO105_MMC3_CMD,
    169};
    170
    171#define NUM_LCD_DETECT_PINS	7
    172
    173static int lcd_detect_pins[] __initdata = {
    174	MFP_PIN_GPIO71,	/* LCD_LDD_17 - ORIENT */
    175	MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */
    176	MFP_PIN_GPIO75, /* LCD_BIAS   - LCDID[4] */
    177	MFP_PIN_GPIO73, /* LCD_LCLK   - LCDID[3] */
    178	MFP_PIN_GPIO72, /* LCD_FCLK   - LCDID[2] */
    179	MFP_PIN_GPIO127,/* LCD_CS_N   - LCDID[1] */
    180	MFP_PIN_GPIO76, /* LCD_VSYNC  - LCDID[0] */
    181};
    182
    183static void __init zylonite_detect_lcd_panel(void)
    184{
    185	unsigned long mfpr_save[NUM_LCD_DETECT_PINS];
    186	int i, gpio, id = 0;
    187
    188	/* save the original MFP settings of these pins and configure
    189	 * them as GPIO Input, DS01X, Pull Neither, Edge Clear
    190	 */
    191	for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
    192		mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
    193		pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440);
    194	}
    195
    196	for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
    197		id = id << 1;
    198		gpio = mfp_to_gpio(lcd_detect_pins[i]);
    199		gpio_request(gpio, "LCD_ID_PINS");
    200		gpio_direction_input(gpio);
    201
    202		if (gpio_get_value(gpio))
    203			id = id | 0x1;
    204		gpio_free(gpio);
    205	}
    206
    207	/* lcd id, flush out bit 1 */
    208	lcd_id = id & 0x3d;
    209
    210	/* lcd orientation, portrait or landscape */
    211	lcd_orientation = (id >> 6) & 0x1;
    212
    213	/* restore the original MFP settings */
    214	for (i = 0; i < NUM_LCD_DETECT_PINS; i++)
    215		pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
    216}
    217
    218#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
    219static struct pca953x_platform_data gpio_exp[] = {
    220	[0] = {
    221		.gpio_base	= 128,
    222	},
    223	[1] = {
    224		.gpio_base	= 144,
    225	},
    226};
    227
    228static struct i2c_board_info zylonite_i2c_board_info[] = {
    229	{
    230		.type		= "pca9539",
    231		.dev_name	= "pca9539-a",
    232		.addr		= 0x74,
    233		.platform_data	= &gpio_exp[0],
    234		.irq		= PXA_GPIO_TO_IRQ(18),
    235	}, {
    236		.type		= "pca9539",
    237		.dev_name	= "pca9539-b",
    238		.addr		= 0x75,
    239		.platform_data	= &gpio_exp[1],
    240		.irq		= PXA_GPIO_TO_IRQ(19),
    241	},
    242};
    243
    244static void __init zylonite_init_i2c(void)
    245{
    246	pxa_set_i2c_info(NULL);
    247	i2c_register_board_info(0, ARRAY_AND_SIZE(zylonite_i2c_board_info));
    248}
    249#else
    250static inline void zylonite_init_i2c(void) {}
    251#endif
    252
    253void __init zylonite_pxa300_init(void)
    254{
    255	if (cpu_is_pxa300() || cpu_is_pxa310()) {
    256		/* initialize MFP */
    257		pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg));
    258
    259		/* detect LCD panel */
    260		zylonite_detect_lcd_panel();
    261
    262		/* WM9713 IRQ */
    263		wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO26);
    264
    265		zylonite_init_i2c();
    266	}
    267
    268	if (cpu_is_pxa300()) {
    269		pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg));
    270		gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99);
    271	}
    272
    273	if (cpu_is_pxa310()) {
    274		pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg));
    275		gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102);
    276	}
    277
    278	/* GPIOs for Debug LEDs */
    279	gpio_debug_led1 = EXT_GPIO(25);
    280	gpio_debug_led2 = EXT_GPIO(26);
    281}