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_pxa320.c (5003B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 * linux/arch/arm/mach-pxa/zylonite_pxa320.c
      4 *
      5 * PXA320 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/gpio.h>
     17#include <linux/soc/pxa/cpu.h>
     18
     19#include "pxa320.h"
     20#include "zylonite.h"
     21
     22#include "generic.h"
     23
     24static mfp_cfg_t mfp_cfg[] __initdata = {
     25	/* LCD */
     26	GPIO6_2_LCD_LDD_0,
     27	GPIO7_2_LCD_LDD_1,
     28	GPIO8_2_LCD_LDD_2,
     29	GPIO9_2_LCD_LDD_3,
     30	GPIO10_2_LCD_LDD_4,
     31	GPIO11_2_LCD_LDD_5,
     32	GPIO12_2_LCD_LDD_6,
     33	GPIO13_2_LCD_LDD_7,
     34	GPIO63_LCD_LDD_8,
     35	GPIO64_LCD_LDD_9,
     36	GPIO65_LCD_LDD_10,
     37	GPIO66_LCD_LDD_11,
     38	GPIO67_LCD_LDD_12,
     39	GPIO68_LCD_LDD_13,
     40	GPIO69_LCD_LDD_14,
     41	GPIO70_LCD_LDD_15,
     42	GPIO71_LCD_LDD_16,
     43	GPIO72_LCD_LDD_17,
     44	GPIO73_LCD_CS_N,
     45	GPIO74_LCD_VSYNC,
     46	GPIO14_2_LCD_FCLK,
     47	GPIO15_2_LCD_LCLK,
     48	GPIO16_2_LCD_PCLK,
     49	GPIO17_2_LCD_BIAS,
     50	GPIO14_PWM3_OUT,	/* backlight */
     51
     52	/* FFUART */
     53	GPIO41_UART1_RXD | MFP_LPM_EDGE_FALL,
     54	GPIO42_UART1_TXD,
     55	GPIO43_UART1_CTS,
     56	GPIO44_UART1_DCD,
     57	GPIO45_UART1_DSR | MFP_LPM_EDGE_FALL,
     58	GPIO46_UART1_RI,
     59	GPIO47_UART1_DTR,
     60	GPIO48_UART1_RTS,
     61
     62	/* AC97 */
     63	GPIO34_AC97_SYSCLK,
     64	GPIO35_AC97_SDATA_IN_0,
     65	GPIO37_AC97_SDATA_OUT,
     66	GPIO38_AC97_SYNC,
     67	GPIO39_AC97_BITCLK,
     68	GPIO40_AC97_nACRESET,
     69	GPIO36_GPIO,	/* SDATA_IN_1 but unused - configure to GPIO */
     70
     71	/* SSP3 */
     72	GPIO89_SSP3_SCLK,
     73	GPIO90_SSP3_FRM,
     74	GPIO91_SSP3_TXD,
     75	GPIO92_SSP3_RXD,
     76
     77	/* WM9713 IRQ */
     78	GPIO15_GPIO,
     79
     80	/* I2C */
     81	GPIO32_I2C_SCL,
     82	GPIO33_I2C_SDA,
     83
     84	/* Keypad */
     85	GPIO105_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
     86	GPIO106_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
     87	GPIO113_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
     88	GPIO114_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
     89	GPIO115_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
     90	GPIO116_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
     91	GPIO117_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
     92	GPIO118_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
     93	GPIO119_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
     94	GPIO120_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
     95	GPIO121_KP_MKOUT_0,
     96	GPIO122_KP_MKOUT_1,
     97	GPIO123_KP_MKOUT_2,
     98	GPIO124_KP_MKOUT_3,
     99	GPIO125_KP_MKOUT_4,
    100	GPIO126_KP_MKOUT_5,
    101	GPIO127_KP_MKOUT_6,
    102	GPIO5_2_KP_MKOUT_7,
    103
    104	/* Ethernet */
    105	GPIO4_nCS3,
    106	GPIO90_GPIO,
    107
    108	/* MMC1 */
    109	GPIO18_MMC1_DAT0,
    110	GPIO19_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
    111	GPIO20_MMC1_DAT2,
    112	GPIO21_MMC1_DAT3,
    113	GPIO22_MMC1_CLK,
    114	GPIO23_MMC1_CMD,/* CMD0 for slot 0 */
    115	GPIO31_GPIO,	/* CMD1 default as GPIO for slot 0 */
    116
    117	/* MMC2 */
    118	GPIO24_MMC2_DAT0,
    119	GPIO25_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
    120	GPIO26_MMC2_DAT2,
    121	GPIO27_MMC2_DAT3,
    122	GPIO28_MMC2_CLK,
    123	GPIO29_MMC2_CMD,
    124
    125	/* USB Host */
    126	GPIO2_2_USBH_PEN,
    127	GPIO3_2_USBH_PWR,
    128
    129	/* Debug LEDs */
    130	GPIO1_2_GPIO | MFP_LPM_DRIVE_HIGH,
    131	GPIO4_2_GPIO | MFP_LPM_DRIVE_HIGH,
    132};
    133
    134#define NUM_LCD_DETECT_PINS	7
    135
    136static int lcd_detect_pins[] __initdata = {
    137	MFP_PIN_GPIO72,   /* LCD_LDD_17 - ORIENT */
    138	MFP_PIN_GPIO71,   /* LCD_LDD_16 - LCDID[5] */
    139	MFP_PIN_GPIO17_2, /* LCD_BIAS   - LCDID[4] */
    140	MFP_PIN_GPIO15_2, /* LCD_LCLK   - LCDID[3] */
    141	MFP_PIN_GPIO14_2, /* LCD_FCLK   - LCDID[2] */
    142	MFP_PIN_GPIO73,   /* LCD_CS_N   - LCDID[1] */
    143	MFP_PIN_GPIO74,   /* LCD_VSYNC  - LCDID[0] */
    144	/*
    145	 * set the MFP_PIN_GPIO 14/15/17 to alternate function other than
    146	 * GPIO to avoid input level confliction with 14_2, 15_2, 17_2
    147	 */
    148	MFP_PIN_GPIO14,
    149	MFP_PIN_GPIO15,
    150	MFP_PIN_GPIO17,
    151};
    152
    153static int lcd_detect_mfpr[] __initdata = {
    154	/* AF0, DS 1X, Pull Neither, Edge Clear */
    155	0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440,
    156	0xc442, /* Backlight, Pull-Up, AF2 */
    157	0x8445, /* AF5 */
    158	0x8445, /* AF5 */
    159};
    160
    161static void __init zylonite_detect_lcd_panel(void)
    162{
    163	unsigned long mfpr_save[ARRAY_SIZE(lcd_detect_pins)];
    164	int i, gpio, id = 0;
    165
    166	/* save the original MFP settings of these pins and configure them
    167	 * as GPIO Input, DS01X, Pull Neither, Edge Clear
    168	 */
    169	for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) {
    170		mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
    171		pxa3xx_mfp_write(lcd_detect_pins[i], lcd_detect_mfpr[i]);
    172	}
    173
    174	for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
    175		id = id << 1;
    176		gpio = mfp_to_gpio(lcd_detect_pins[i]);
    177		gpio_request(gpio, "LCD_ID_PINS");
    178		gpio_direction_input(gpio);
    179
    180		if (gpio_get_value(gpio))
    181			id = id | 0x1;
    182		gpio_free(gpio);
    183	}
    184
    185	/* lcd id, flush out bit 1 */
    186	lcd_id = id & 0x3d;
    187
    188	/* lcd orientation, portrait or landscape */
    189	lcd_orientation = (id >> 6) & 0x1;
    190
    191	/* restore the original MFP settings */
    192	for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++)
    193		pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
    194}
    195
    196void __init zylonite_pxa320_init(void)
    197{
    198	if (cpu_is_pxa320()) {
    199		/* initialize MFP */
    200		pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg));
    201
    202		/* detect LCD panel */
    203		zylonite_detect_lcd_panel();
    204
    205		/* GPIO pin assignment */
    206		gpio_eth_irq	= mfp_to_gpio(MFP_PIN_GPIO9);
    207		gpio_debug_led1	= mfp_to_gpio(MFP_PIN_GPIO1_2);
    208		gpio_debug_led2	= mfp_to_gpio(MFP_PIN_GPIO4_2);
    209
    210		/* WM9713 IRQ */
    211		wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO15);
    212	}
    213}