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

mxm8x10.c (10732B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 * linux/arch/arm/mach-pxa/mxm8x10.c
      4 *
      5 * Support for the Embedian MXM-8x10 Computer on Module
      6 *
      7 * Copyright (C) 2006 Marvell International Ltd.
      8 * Copyright (C) 2009 Embedian Inc.
      9 * Copyright (C) 2009 TMT Services & Supplies (Pty) Ltd.
     10 *
     11 * 2007-09-04: eric miao <eric.y.miao@gmail.com>
     12 *             rewrite to align with latest kernel
     13 *
     14 * 2010-01-09: Edwin Peer <epeer@tmtservices.co.za>
     15 * 	       Hennie van der Merwe <hvdmerwe@tmtservices.co.za>
     16 *             rework for upstream merge
     17 */
     18
     19#include <linux/serial_8250.h>
     20#include <linux/dm9000.h>
     21#include <linux/gpio/machine.h>
     22#include <linux/platform_data/i2c-pxa.h>
     23
     24#include <linux/platform_data/mtd-nand-pxa3xx.h>
     25
     26#include <linux/platform_data/video-pxafb.h>
     27#include <linux/platform_data/mmc-pxamci.h>
     28#include <linux/platform_data/usb-ohci-pxa27x.h>
     29#include <linux/platform_data/asoc-pxa.h>
     30#include "pxa320.h"
     31
     32#include "mxm8x10.h"
     33
     34#include "devices.h"
     35#include "generic.h"
     36
     37/* GPIO pin definition
     38
     39External device stuff   - Leave unconfigured for now...
     40---------------------
     41GPIO0   -   DREQ    (External DMA Request)
     42GPIO3   -   nGCS2   (External Chip Select) Where is nGCS0; nGCS1; nGCS4; nGCS5 ?
     43GPIO4   -   nGCS3
     44GPIO15  -   EXT_GPIO1
     45GPIO16  -   EXT_GPIO2
     46GPIO17  -   EXT_GPIO3
     47GPIO24  -   EXT_GPIO4
     48GPIO25  -   EXT_GPIO5
     49GPIO26  -   EXT_GPIO6
     50GPIO27  -   EXT_GPIO7
     51GPIO28  -   EXT_GPIO8
     52GPIO29  -   EXT_GPIO9
     53GPIO30  -   EXT_GPIO10
     54GPIO31  -   EXT_GPIO11
     55GPIO57  -   EXT_GPIO12
     56GPIO74  -   EXT_IRQ1
     57GPIO75  -   EXT_IRQ2
     58GPIO76  -   EXT_IRQ3
     59GPIO77  -   EXT_IRQ4
     60GPIO78  -   EXT_IRQ5
     61GPIO79  -   EXT_IRQ6
     62GPIO80  -   EXT_IRQ7
     63GPIO81  -   EXT_IRQ8
     64GPIO87  -   VCCIO_PWREN (External Device PWREN)
     65
     66Dallas 1-Wire   - Leave unconfigured for now...
     67-------------
     68GPIO0_2 -   DS - 1Wire
     69
     70Ethernet
     71--------
     72GPIO1   -   DM9000 PWR
     73GPIO9   -   DM9K_nIRQ
     74GPIO36  -   DM9K_RESET
     75
     76Keypad  - Leave unconfigured by for now...
     77------
     78GPIO1_2 -   KP_DKIN0
     79GPIO5_2 -   KP_MKOUT7
     80GPIO82  -   KP_DKIN1
     81GPIO85  -   KP_DKIN2
     82GPIO86  -   KP_DKIN3
     83GPIO113 -   KP_MKIN0
     84GPIO114 -   KP_MKIN1
     85GPIO115 -   KP_MKIN2
     86GPIO116 -   KP_MKIN3
     87GPIO117 -   KP_MKIN4
     88GPIO118 -   KP_MKIN5
     89GPIO119 -   KP_MKIN6
     90GPIO120 -   KP_MKIN7
     91GPIO121 -   KP_MKOUT0
     92GPIO122 -   KP_MKOUT1
     93GPIO122 -   KP_MKOUT2
     94GPIO123 -   KP_MKOUT3
     95GPIO124 -   KP_MKOUT4
     96GPIO125 -   KP_MKOUT5
     97GPIO127 -   KP_MKOUT6
     98
     99Data Bus    - Leave unconfigured for now...
    100--------
    101GPIO2   -   nWait (Data Bus)
    102
    103USB Device
    104----------
    105GPIO4_2 -   USBD_PULLUP
    106GPIO10  -   UTM_CLK (USB Device UTM Clk)
    107GPIO49  -   USB 2.0 Device UTM_DATA0
    108GPIO50  -   USB 2.0 Device UTM_DATA1
    109GPIO51  -   USB 2.0 Device UTM_DATA2
    110GPIO52  -   USB 2.0 Device UTM_DATA3
    111GPIO53  -   USB 2.0 Device UTM_DATA4
    112GPIO54  -   USB 2.0 Device UTM_DATA5
    113GPIO55  -   USB 2.0 Device UTM_DATA6
    114GPIO56  -   USB 2.0 Device UTM_DATA7
    115GPIO58  -   UTM_RXVALID (USB 2.0 Device)
    116GPIO59  -   UTM_RXACTIVE (USB 2.0 Device)
    117GPIO60  -   UTM_RXERROR
    118GPIO61  -   UTM_OPMODE0
    119GPIO62  -   UTM_OPMODE1
    120GPIO71  -   USBD_INT    (USB Device?)
    121GPIO73  -   UTM_TXREADY (USB 2.0 Device)
    122GPIO83  -   UTM_TXVALID (USB 2.0 Device)
    123GPIO98  -   UTM_RESET   (USB 2.0 device)
    124GPIO99  -   UTM_XCVR_SELECT
    125GPIO100 -   UTM_TERM_SELECT
    126GPIO101 -   UTM_SUSPENDM_X
    127GPIO102 -   UTM_LINESTATE0
    128GPIO103 -   UTM_LINESTATE1
    129
    130Card-Bus Interface  - Leave unconfigured for now...
    131------------------
    132GPIO5   -   nPIOR (I/O space output enable)
    133GPIO6   -   nPIOW (I/O space write enable)
    134GPIO7   -   nIOS16 (Input from I/O space telling size of data bus)
    135GPIO8   -   nPWAIT (Input for inserting wait states)
    136
    137LCD
    138---
    139GPIO6_2     -   LDD0
    140GPIO7_2     -   LDD1
    141GPIO8_2     -   LDD2
    142GPIO9_2     -   LDD3
    143GPIO11_2    -   LDD5
    144GPIO12_2    -   LDD6
    145GPIO13_2    -   LDD7
    146GPIO14_2    -   VSYNC
    147GPIO15_2    -   HSYNC
    148GPIO16_2    -   VCLK
    149GPIO17_2    -   HCLK
    150GPIO18_2    -   VDEN
    151GPIO63      -   LDD8    (CPU LCD)
    152GPIO64      -   LDD9    (CPU LCD)
    153GPIO65      -   LDD10   (CPU LCD)
    154GPIO66      -   LDD11   (CPU LCD)
    155GPIO67      -   LDD12   (CPU LCD)
    156GPIO68      -   LDD13   (CPU LCD)
    157GPIO69      -   LDD14   (CPU LCD)
    158GPIO70      -   LDD15   (CPU LCD)
    159GPIO88      -   VCCLCD_PWREN (LCD Panel PWREN)
    160GPIO97      -   BACKLIGHT_EN
    161GPIO104     -   LCD_PWREN
    162
    163PWM   - Leave unconfigured for now...
    164---
    165GPIO11  -   PWM0
    166GPIO12  -   PWM1
    167GPIO13  -   PWM2
    168GPIO14  -   PWM3
    169
    170SD-CARD
    171-------
    172GPIO18  -   SDDATA0
    173GPIO19  -   SDDATA1
    174GPIO20  -   SDDATA2
    175GPIO21  -   SDDATA3
    176GPIO22  -   SDCLK
    177GPIO23  -   SDCMD
    178GPIO72  -   SD_WP
    179GPIO84  -   SD_nIRQ_CD  (SD-Card)
    180
    181I2C
    182---
    183GPIO32  -   I2CSCL
    184GPIO33  -   I2CSDA
    185
    186AC97
    187----
    188GPIO35  -   AC97_SDATA_IN
    189GPIO37  -   AC97_SDATA_OUT
    190GPIO38  -   AC97_SYNC
    191GPIO39  -   AC97_BITCLK
    192GPIO40  -   AC97_nRESET
    193
    194UART1
    195-----
    196GPIO41  -   UART_RXD1
    197GPIO42  -   UART_TXD1
    198GPIO43  -   UART_CTS1
    199GPIO44  -   UART_DCD1
    200GPIO45  -   UART_DSR1
    201GPIO46  -   UART_nRI1
    202GPIO47  -   UART_DTR1
    203GPIO48  -   UART_RTS1
    204
    205UART2
    206-----
    207GPIO109 -   RTS2
    208GPIO110 -   RXD2
    209GPIO111 -   TXD2
    210GPIO112 -   nCTS2
    211
    212UART3
    213-----
    214GPIO105 -   nCTS3
    215GPIO106 -   nRTS3
    216GPIO107 -   TXD3
    217GPIO108 -   RXD3
    218
    219SSP3    - Leave unconfigured for now...
    220----
    221GPIO89  -   SSP3_CLK
    222GPIO90  -   SSP3_SFRM
    223GPIO91  -   SSP3_TXD
    224GPIO92  -   SSP3_RXD
    225
    226SSP4
    227GPIO93  -   SSP4_CLK
    228GPIO94  -   SSP4_SFRM
    229GPIO95  -   SSP4_TXD
    230GPIO96  -   SSP4_RXD
    231*/
    232
    233static mfp_cfg_t mfp_cfg[] __initdata = {
    234	/* USB */
    235	GPIO10_UTM_CLK,
    236	GPIO49_U2D_PHYDATA_0,
    237	GPIO50_U2D_PHYDATA_1,
    238	GPIO51_U2D_PHYDATA_2,
    239	GPIO52_U2D_PHYDATA_3,
    240	GPIO53_U2D_PHYDATA_4,
    241	GPIO54_U2D_PHYDATA_5,
    242	GPIO55_U2D_PHYDATA_6,
    243	GPIO56_U2D_PHYDATA_7,
    244	GPIO58_UTM_RXVALID,
    245	GPIO59_UTM_RXACTIVE,
    246	GPIO60_U2D_RXERROR,
    247	GPIO61_U2D_OPMODE0,
    248	GPIO62_U2D_OPMODE1,
    249	GPIO71_GPIO, /* USBD_INT */
    250	GPIO73_UTM_TXREADY,
    251	GPIO83_U2D_TXVALID,
    252	GPIO98_U2D_RESET,
    253	GPIO99_U2D_XCVR_SEL,
    254	GPIO100_U2D_TERM_SEL,
    255	GPIO101_U2D_SUSPEND,
    256	GPIO102_UTM_LINESTATE_0,
    257	GPIO103_UTM_LINESTATE_1,
    258	GPIO4_2_GPIO | MFP_PULL_HIGH, /* UTM_PULLUP */
    259
    260	/* DM9000 */
    261	GPIO1_GPIO,
    262	GPIO9_GPIO,
    263	GPIO36_GPIO,
    264
    265	/* AC97 */
    266	GPIO35_AC97_SDATA_IN_0,
    267	GPIO37_AC97_SDATA_OUT,
    268	GPIO38_AC97_SYNC,
    269	GPIO39_AC97_BITCLK,
    270	GPIO40_AC97_nACRESET,
    271
    272	/* UARTS */
    273	GPIO41_UART1_RXD,
    274	GPIO42_UART1_TXD,
    275	GPIO43_UART1_CTS,
    276	GPIO44_UART1_DCD,
    277	GPIO45_UART1_DSR,
    278	GPIO46_UART1_RI,
    279	GPIO47_UART1_DTR,
    280	GPIO48_UART1_RTS,
    281
    282	GPIO109_UART2_RTS,
    283	GPIO110_UART2_RXD,
    284	GPIO111_UART2_TXD,
    285	GPIO112_UART2_CTS,
    286
    287	GPIO105_UART3_CTS,
    288	GPIO106_UART3_RTS,
    289	GPIO107_UART3_TXD,
    290	GPIO108_UART3_RXD,
    291
    292	GPIO78_GPIO,
    293	GPIO79_GPIO,
    294	GPIO80_GPIO,
    295	GPIO81_GPIO,
    296
    297	/* I2C */
    298	GPIO32_I2C_SCL,
    299	GPIO33_I2C_SDA,
    300
    301	/* MMC */
    302	GPIO18_MMC1_DAT0,
    303	GPIO19_MMC1_DAT1,
    304	GPIO20_MMC1_DAT2,
    305	GPIO21_MMC1_DAT3,
    306	GPIO22_MMC1_CLK,
    307	GPIO23_MMC1_CMD,
    308	GPIO72_GPIO | MFP_PULL_HIGH, /* Card Detect */
    309	GPIO84_GPIO | MFP_PULL_LOW, /* Write Protect */
    310
    311	/* IRQ */
    312	GPIO74_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ1 */
    313	GPIO75_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ2 */
    314	GPIO76_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ3 */
    315	GPIO77_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ4 */
    316	GPIO78_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ5 */
    317	GPIO79_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ6 */
    318	GPIO80_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ7 */
    319	GPIO81_GPIO | MFP_LPM_EDGE_RISE  /* EXT_IRQ8 */
    320};
    321
    322/* MMC/MCI Support */
    323#if defined(CONFIG_MMC)
    324static struct pxamci_platform_data mxm_8x10_mci_platform_data = {
    325	.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
    326	.detect_delay_ms = 10,
    327};
    328
    329static struct gpiod_lookup_table mxm_8x10_mci_gpio_table = {
    330	.dev_id = "pxa2xx-mci.0",
    331	.table = {
    332		/* Card detect on GPIO 72 */
    333		GPIO_LOOKUP("gpio-pxa", MXM_8X10_SD_nCD,
    334			    "cd", GPIO_ACTIVE_LOW),
    335		/* Write protect on GPIO 84 */
    336		GPIO_LOOKUP("gpio-pxa", MXM_8X10_SD_WP,
    337			    "wp", GPIO_ACTIVE_LOW),
    338		{ },
    339	},
    340};
    341
    342void __init mxm_8x10_mmc_init(void)
    343{
    344	gpiod_add_lookup_table(&mxm_8x10_mci_gpio_table);
    345	pxa_set_mci_info(&mxm_8x10_mci_platform_data);
    346}
    347#endif
    348
    349/* USB Open Host Controller Interface */
    350static struct pxaohci_platform_data mxm_8x10_ohci_platform_data = {
    351	.port_mode = PMM_NPS_MODE,
    352	.flags = ENABLE_PORT_ALL
    353};
    354
    355void __init mxm_8x10_usb_host_init(void)
    356{
    357	pxa_set_ohci_info(&mxm_8x10_ohci_platform_data);
    358}
    359
    360void __init mxm_8x10_ac97_init(void)
    361{
    362	pxa_set_ac97_info(NULL);
    363}
    364
    365/* NAND flash Support */
    366#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
    367#define NAND_BLOCK_SIZE SZ_128K
    368#define NB(x)           (NAND_BLOCK_SIZE * (x))
    369static struct mtd_partition mxm_8x10_nand_partitions[] = {
    370	[0] = {
    371	       .name = "boot",
    372	       .size = NB(0x002),
    373	       .offset = NB(0x000),
    374	       .mask_flags = MTD_WRITEABLE
    375	},
    376	[1] = {
    377	       .name = "kernel",
    378	       .size = NB(0x010),
    379	       .offset = NB(0x002),
    380	       .mask_flags = MTD_WRITEABLE
    381	},
    382	[2] = {
    383	       .name = "root",
    384	       .size = NB(0x36c),
    385	       .offset = NB(0x012)
    386	},
    387	[3] = {
    388	       .name = "bbt",
    389	       .size = NB(0x082),
    390	       .offset = NB(0x37e),
    391	       .mask_flags = MTD_WRITEABLE
    392	}
    393};
    394
    395static struct pxa3xx_nand_platform_data mxm_8x10_nand_info = {
    396	.keep_config	= 1,
    397	.parts		= mxm_8x10_nand_partitions,
    398	.nr_parts	= ARRAY_SIZE(mxm_8x10_nand_partitions)
    399};
    400
    401static void __init mxm_8x10_nand_init(void)
    402{
    403	pxa3xx_set_nand_info(&mxm_8x10_nand_info);
    404}
    405#else
    406static inline void mxm_8x10_nand_init(void) {}
    407#endif /* IS_ENABLED(CONFIG_MTD_NAND_MARVELL) */
    408
    409/* Ethernet support: Davicom DM9000 */
    410static struct resource dm9k_resources[] = {
    411	[0] = {
    412	       .start = MXM_8X10_ETH_PHYS + 0x300,
    413	       .end = MXM_8X10_ETH_PHYS + 0x300,
    414	       .flags = IORESOURCE_MEM
    415	},
    416	[1] = {
    417	       .start = MXM_8X10_ETH_PHYS + 0x308,
    418	       .end = MXM_8X10_ETH_PHYS + 0x308,
    419	       .flags = IORESOURCE_MEM
    420	},
    421	[2] = {
    422	       .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO9)),
    423	       .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO9)),
    424	       .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
    425	}
    426};
    427
    428static struct dm9000_plat_data dm9k_plat_data = {
    429	.flags = DM9000_PLATF_16BITONLY
    430};
    431
    432static struct platform_device dm9k_device = {
    433	.name = "dm9000",
    434	.id = 0,
    435	.num_resources = ARRAY_SIZE(dm9k_resources),
    436	.resource = dm9k_resources,
    437	.dev = {
    438		.platform_data = &dm9k_plat_data
    439	}
    440};
    441
    442static void __init mxm_8x10_ethernet_init(void)
    443{
    444	platform_device_register(&dm9k_device);
    445}
    446
    447/* PXA UARTs */
    448static void __init mxm_8x10_uarts_init(void)
    449{
    450	pxa_set_ffuart_info(NULL);
    451	pxa_set_btuart_info(NULL);
    452	pxa_set_stuart_info(NULL);
    453}
    454
    455/* I2C and Real Time Clock */
    456static struct i2c_board_info __initdata mxm_8x10_i2c_devices[] = {
    457	{
    458		I2C_BOARD_INFO("ds1337", 0x68)
    459	}
    460};
    461
    462static void __init mxm_8x10_i2c_init(void)
    463{
    464	i2c_register_board_info(0, mxm_8x10_i2c_devices,
    465				ARRAY_SIZE(mxm_8x10_i2c_devices));
    466	pxa_set_i2c_info(NULL);
    467}
    468
    469void __init mxm_8x10_barebones_init(void)
    470{
    471	pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg));
    472
    473	mxm_8x10_uarts_init();
    474	mxm_8x10_nand_init();
    475	mxm_8x10_i2c_init();
    476	mxm_8x10_ethernet_init();
    477}