From 89ebc82137bebb11a8191f8b9cbf08f2533ae8bc Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Wed, 4 Mar 2015 13:13:03 +0100 Subject: ARM: mx6: move to a standard arch/board approach Freescale boards are currently all defined in arch/arm/Kconfig, which makes them hard to detect. Moreover the MX6 SoC variant (Q, D, DL, S, SL) selection is currently done via the SYS_EXTRA_OPTIONS option which marked as deprecated. Move to a more standard way to select sub-architecture and board by creating a Kconfig under arch/arm/cpu/armv7/mx6 and a new ARCH_MX6 option. Existing MX6 board definitions should be moved in this new Kconfig in choice menu, and new boards should be directly declared in this menu. Signed-off-by: Boris Brezillon diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b9ebee1..2145557 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -433,6 +433,10 @@ config ARCH_KEYSTONE select CPU_V7 select SUPPORT_SPL +config ARCH_MX6 + bool "Freescale MX6" + select CPU_V7 + config TARGET_M53EVK bool "Support m53evk" select CPU_V7 @@ -735,6 +739,8 @@ source "arch/arm/mach-keystone/Kconfig" source "arch/arm/mach-kirkwood/Kconfig" +source "arch/arm/cpu/armv7/mx6/Kconfig" + source "arch/arm/mach-nomadik/Kconfig" source "arch/arm/cpu/armv7/omap3/Kconfig" diff --git a/arch/arm/cpu/armv7/mx6/Kconfig b/arch/arm/cpu/armv7/mx6/Kconfig new file mode 100644 index 0000000..a32fd87 --- /dev/null +++ b/arch/arm/cpu/armv7/mx6/Kconfig @@ -0,0 +1,31 @@ +if ARCH_MX6 + +config MX6 + bool + default y + +config MX6D + bool + +config MX6DL + bool + +config MX6Q + bool + +config MX6QDL + bool + +config MX6S + bool + +config MX6SL + bool + +config MX6SX + bool + +config SYS_SOC + default "mx6" + +endif -- cgit v0.10.2 From a05a6045d5bc1c0b6b4b2d95380cefb0a664beb4 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Wed, 4 Mar 2015 13:13:04 +0100 Subject: ARM: iMX: define an IMX_CONFIG Kconfig option IMX_CONFIG is currently passed via the SYS_EXTRA_OPTIONS which is marked as deprecated. Add a new Kconfig file under arch/arm/imx-common and define the IMX_CONFIG Kconfig in there. Each board is supposed to provide a default value pointing to the appropriate imximage.cfg file. Signed-off-by: Boris Brezillon diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2145557..c0a0fd8 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -767,6 +767,8 @@ source "arch/arm/cpu/armv7/Kconfig" source "arch/arm/cpu/armv8/Kconfig" +source "arch/arm/imx-common/Kconfig" + source "board/aristainetos/Kconfig" source "board/BuR/kwb/Kconfig" source "board/BuR/tseries/Kconfig" diff --git a/arch/arm/imx-common/Kconfig b/arch/arm/imx-common/Kconfig new file mode 100644 index 0000000..37b3752 --- /dev/null +++ b/arch/arm/imx-common/Kconfig @@ -0,0 +1,2 @@ +config IMX_CONFIG + string -- cgit v0.10.2 From 058d23168752c2a2ec0a6c3b50296cb5b91ec6d0 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Wed, 4 Mar 2015 13:13:05 +0100 Subject: board/seco: Add mx6q-uq7 basic board support Add basic SECO MX6Q/uQ7 board support (Ethernet, UART, SD are supported). It also adds a Kconfig skeleton to later add more SECO board (supporting SoC and board variants). Signed-off-by: Boris Brezillon diff --git a/arch/arm/cpu/armv7/mx6/Kconfig b/arch/arm/cpu/armv7/mx6/Kconfig index a32fd87..076ba52 100644 --- a/arch/arm/cpu/armv7/mx6/Kconfig +++ b/arch/arm/cpu/armv7/mx6/Kconfig @@ -25,7 +25,18 @@ config MX6SL config MX6SX bool +choice + prompt "MX6 board select" + +config TARGET_SECOMX6 + bool "Support secomx6 boards" + select CPU_V7 + +endchoice + config SYS_SOC default "mx6" +source "board/seco/Kconfig" + endif diff --git a/board/seco/Kconfig b/board/seco/Kconfig new file mode 100644 index 0000000..dcb1ac8 --- /dev/null +++ b/board/seco/Kconfig @@ -0,0 +1,63 @@ +if TARGET_SECOMX6 + +choice + prompt "SECO i.MX6 Board variant" + +config SECOMX6_Q7 + bool "Q7" + +config SECOMX6_UQ7 + bool "uQ7" + +config SECOMX6_USBC + bool "uSBC" + +endchoice + +choice + prompt "SECO i.MX6 SoC variant" + +config SECOMX6Q + bool "i.MX6Q" + select MX6Q + +config SECOMX6DL + bool "i.MX6DL" + select MX6DL + +config SECOMX6S + bool "i.MX6S" + select MX6S + +endchoice + +choice + prompt "DDR size" + +config SECOMX6_512MB + bool "512MB" + +config SECOMX6_1GB + bool "1GB" + +config SECOMX6_2GB + bool "2GB" + +config SECOMX6_4GB + bool "4GB" + +endchoice + +config IMX_CONFIG + default "board/seco/mx6quq7/mx6quq7-2g.cfg" if SECOMX6_UQ7 && SECOMX6Q && SECOMX6_2GB + +config SYS_BOARD + default "mx6quq7" if SECOMX6_UQ7 && SECOMX6Q + +config SYS_VENDOR + default "seco" + +config SYS_CONFIG_NAME + default "secomx6quq7" if SECOMX6_UQ7 && SECOMX6Q + +endif diff --git a/board/seco/common/Makefile b/board/seco/common/Makefile new file mode 100644 index 0000000..9e37ebb --- /dev/null +++ b/board/seco/common/Makefile @@ -0,0 +1,2 @@ + +obj-$(CONFIG_TARGET_SECOMX6) += mx6.o diff --git a/board/seco/common/mx6.c b/board/seco/common/mx6.c new file mode 100644 index 0000000..2f14f59 --- /dev/null +++ b/board/seco/common/mx6.c @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2013 Freescale Semiconductor, Inc. + * Copyright (C) 2015 ECA Sinters + * + * Author: Fabio Estevam + * Modified by: Boris Brezillon + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ + PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ + PAD_CTL_SRE_FAST | PAD_CTL_HYS) + +static iomux_v3_cfg_t const uart2_pads[] = { + MX6_PAD_EIM_D26__UART2_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL), + MX6_PAD_EIM_D27__UART2_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL), +}; + +void seco_mx6_setup_uart_iomux(void) +{ + imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads)); +} + +#define ENET_PAD_CTRL (PAD_CTL_PUS_47K_UP | \ + PAD_CTL_SPEED_MED | \ + PAD_CTL_DSE_40ohm | \ + PAD_CTL_HYS) + +static iomux_v3_cfg_t const enet_pads[] = { + MX6_PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), + MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), +}; + +void seco_mx6_setup_enet_iomux(void) +{ + imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads)); +} + +int seco_mx6_rgmii_rework(struct phy_device *phydev) +{ + /* control data pad skew - devaddr = 0x02, register = 0x04 */ + ksz9031_phy_extended_write(phydev, 0x02, + MII_KSZ9031_EXT_RGMII_CTRL_SIG_SKEW, + MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000); + /* rx data pad skew - devaddr = 0x02, register = 0x05 */ + ksz9031_phy_extended_write(phydev, 0x02, + MII_KSZ9031_EXT_RGMII_RX_DATA_SKEW, + MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000); + /* tx data pad skew - devaddr = 0x02, register = 0x05 */ + ksz9031_phy_extended_write(phydev, 0x02, + MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW, + MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000); + + /* gtx and rx clock pad skew - devaddr = 0x02, register = 0x08 */ + ksz9031_phy_extended_write(phydev, 0x02, + MII_KSZ9031_EXT_RGMII_CLOCK_SKEW, + MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x03FF); + return 0; +} + +#define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP | \ + PAD_CTL_SPEED_LOW | \ + PAD_CTL_DSE_80ohm | \ + PAD_CTL_SRE_FAST | \ + PAD_CTL_HYS) + +static iomux_v3_cfg_t const usdhc3_pads[] = { + MX6_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), +}; + +static iomux_v3_cfg_t const usdhc4_pads[] = { + MX6_PAD_SD4_CLK__SD4_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD4_CMD__SD4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD4_DAT0__SD4_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD4_DAT1__SD4_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD4_DAT2__SD4_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD4_DAT3__SD4_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), +}; + +void seco_mx6_setup_usdhc_iomux(int id) +{ + switch (id) { + case 3: + imx_iomux_v3_setup_multiple_pads(usdhc3_pads, + ARRAY_SIZE(usdhc3_pads)); + break; + + case 4: + imx_iomux_v3_setup_multiple_pads(usdhc4_pads, + ARRAY_SIZE(usdhc4_pads)); + break; + + default: + printf("Warning: invalid usdhc id (%d)\n", id); + break; + } +} diff --git a/board/seco/common/mx6.h b/board/seco/common/mx6.h new file mode 100644 index 0000000..a05db67 --- /dev/null +++ b/board/seco/common/mx6.h @@ -0,0 +1,9 @@ +#ifndef __SECO_COMMON_MX6_H +#define __SECO_COMMON_MX6_H + +void seco_mx6_setup_uart_iomux(void); +void seco_mx6_setup_enet_iomux(void); +int seco_mx6_rgmii_rework(struct phy_device *phydev); +void seco_mx6_setup_usdhc_iomux(int id); + +#endif /* __SECO_COMMON_MX6_H */ diff --git a/board/seco/mx6quq7/MAINTAINERS b/board/seco/mx6quq7/MAINTAINERS new file mode 100644 index 0000000..60fd4ca --- /dev/null +++ b/board/seco/mx6quq7/MAINTAINERS @@ -0,0 +1,6 @@ +MX6QUQ7 BOARD +M: Boris Brezillon +S: Maintained +F: board/seco/mx6quq7/ +F: include/configs/secomx6quq7.h +F: configs/secomx6quq7_defconfig diff --git a/board/seco/mx6quq7/Makefile b/board/seco/mx6quq7/Makefile new file mode 100644 index 0000000..bbf1d68 --- /dev/null +++ b/board/seco/mx6quq7/Makefile @@ -0,0 +1,7 @@ +# +# (C) Copyright 2015 ECA Sinters +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y := mx6quq7.o diff --git a/board/seco/mx6quq7/mx6quq7-2g.cfg b/board/seco/mx6quq7/mx6quq7-2g.cfg new file mode 100644 index 0000000..159120e --- /dev/null +++ b/board/seco/mx6quq7/mx6quq7-2g.cfg @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2013 Seco USA Inc + * + * SPDX-License-Identifier: GPL-2.0 + * + * Refer doc/README.imximage for more details about how-to configure + * and create imximage boot image + * + * The syntax is taken as close as possible with the kwbimage + */ + +/* image version */ +IMAGE_VERSION 2 + +/* + * Boot Device : one of + * spi, sd (the board has no nand neither onenand) + */ +BOOT_FROM sd + +#define __ASSEMBLY__ +#include +#include "asm/arch/mx6-ddr.h" +#include "asm/arch/iomux.h" +#include "asm/arch/crm_regs.h" + +/* DDR IO TYPE */ +DATA 4, MX6_IOM_GRP_DDRPKE, 0x00000000 +DATA 4, MX6_IOM_GRP_DDR_TYPE, 0x000C0000 + +/* DATA STROBE */ +DATA 4, MX6_IOM_DDRMODE_CTL, 0x00020000 +DATA 4, MX6_IOM_DRAM_SDQS0, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDQS1, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDQS2, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDQS3, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDQS4, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDQS5, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDQS6, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDQS7, 0x00000028 + +/* DATA */ +DATA 4, MX6_IOM_GRP_DDRMODE, 0x00020000 +DATA 4, MX6_IOM_GRP_B0DS, 0x00000028 +DATA 4, MX6_IOM_GRP_B1DS, 0x00000028 +DATA 4, MX6_IOM_GRP_B2DS, 0x00000028 +DATA 4, MX6_IOM_GRP_B3DS, 0x00000028 +DATA 4, MX6_IOM_GRP_B4DS, 0x00000028 +DATA 4, MX6_IOM_GRP_B5DS, 0x00000028 +DATA 4, MX6_IOM_GRP_B6DS, 0x00000028 +DATA 4, MX6_IOM_GRP_B7DS, 0x00000028 +DATA 4, MX6_IOM_DRAM_DQM0, 0x00000028 +DATA 4, MX6_IOM_DRAM_DQM1, 0x00000028 +DATA 4, MX6_IOM_DRAM_DQM2, 0x00000028 +DATA 4, MX6_IOM_DRAM_DQM3, 0x00000028 +DATA 4, MX6_IOM_DRAM_DQM4, 0x00000028 +DATA 4, MX6_IOM_DRAM_DQM5, 0x00000028 +DATA 4, MX6_IOM_DRAM_DQM6, 0x00000028 +DATA 4, MX6_IOM_DRAM_DQM7, 0x00000028 +/* ADDRESS */ +DATA 4, MX6_IOM_GRP_ADDDS, 0x00000028 +DATA 4, MX6_IOM_DRAM_CAS, 0x00000028 +DATA 4, MX6_IOM_DRAM_RAS, 0x00000028 + +/* CONTROL */ +DATA 4, MX6_IOM_GRP_CTLDS, 0x00000030 +DATA 4, MX6_IOM_DRAM_RESET, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDBA2, 0x00000000 +DATA 4, MX6_IOM_DRAM_SDODT0, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDODT1, 0x00000028 + +/* CLOCK */ +DATA 4, MX6_IOM_DRAM_SDCLK_0, 0x00000028 +DATA 4, MX6_IOM_DRAM_SDCLK_1, 0x00000028 + +/* + * DDR3 SETTINGS + * Read Data Bit Delay + */ +DATA 4, MX6_MMDC_P0_MPRDDQBY0DL, 0x33333333 +DATA 4, MX6_MMDC_P0_MPRDDQBY1DL, 0x33333333 +DATA 4, MX6_MMDC_P0_MPRDDQBY2DL, 0x33333333 +DATA 4, MX6_MMDC_P0_MPRDDQBY3DL, 0x33333333 +DATA 4, MX6_MMDC_P1_MPRDDQBY0DL, 0x33333333 +DATA 4, MX6_MMDC_P1_MPRDDQBY1DL, 0x33333333 +DATA 4, MX6_MMDC_P1_MPRDDQBY2DL, 0x33333333 +DATA 4, MX6_MMDC_P1_MPRDDQBY3DL, 0x33333333 + + +/* Write Leveling */ +DATA 4, MX6_MMDC_P0_MPWLDECTRL0, 0x001F001F +DATA 4, MX6_MMDC_P0_MPWLDECTRL1, 0x001F001F +DATA 4, MX6_MMDC_P1_MPWLDECTRL0, 0x001F0001 +DATA 4, MX6_MMDC_P1_MPWLDECTRL1, 0x001F001F + +/* DQS gating, read delay, write delay calibration values */ +DATA 4, MX6_MMDC_P0_MPDGCTRL0, 0x431A0326 +DATA 4, MX6_MMDC_P0_MPDGCTRL1, 0x0323031B +DATA 4, MX6_MMDC_P1_MPDGCTRL0, 0x433F0340 +DATA 4, MX6_MMDC_P1_MPDGCTRL1, 0x0345031C + +/* Read calibration */ +DATA 4, MX6_MMDC_P0_MPRDDLCTL, 0x40343137 +DATA 4, MX6_MMDC_P1_MPRDDLCTL, 0x40372F45 + +/* write calibration */ +DATA 4, MX6_MMDC_P0_MPWRDLCTL, 0x32414741 +DATA 4, MX6_MMDC_P1_MPWRDLCTL, 0x4731473C + +/* Complete calibration by forced measurement: */ +DATA 4, MX6_MMDC_P0_MPMUR0, 0x00000800 +DATA 4, MX6_MMDC_P1_MPMUR0, 0x00000800 + +/* + * MMDC init: + * in DDR3, 64-bit mode, only MMDC0 is init + */ +DATA 4, MX6_MMDC_P0_MDPDC, 0x00020036 +DATA 4, MX6_MMDC_P0_MDOTC, 0x09444040 + +DATA 4, MX6_MMDC_P0_MDCFG0, 0x898E7955 +DATA 4, MX6_MMDC_P0_MDCFG1, 0xFF328F64 +DATA 4, MX6_MMDC_P0_MDCFG2, 0x01FF00DB + +DATA 4, MX6_MMDC_P0_MDMISC, 0x00001740 +DATA 4, MX6_MMDC_P0_MDSCR, 0x00008000 +DATA 4, MX6_MMDC_P0_MDRWD, 0x000026D2 +DATA 4, MX6_MMDC_P0_MDOR, 0x008E1023 + +/* CS0_END = 2304MB in step da 256Mb -> [(2304*8/256) - 1] */ +DATA 4, MX6_MMDC_P0_MDASP, 0x00000047 + +/* SDE_1=0; ROW=3; BL=1; DSIZ=2 -> 64 bit */ +DATA 4, MX6_MMDC_P0_MDCTL, 0x841A0000 + +/* Initialize DDR3 on CS_0 and CS_1 */ +DATA 4, MX6_MMDC_P0_MDSCR, 0x02088032 +DATA 4, MX6_MMDC_P0_MDSCR, 0x00008033 +DATA 4, MX6_MMDC_P0_MDSCR, 0x00048031 + +/* P0 01c */ +/* write 0x0940 to MR0 bank_0 (Burst Type=1 (Interlived)) */ +DATA 4, MX6_MMDC_P0_MDSCR, 0x09408030 + +/*ZQ - Calibrationi */ +DATA 4, MX6_MMDC_P0_MPZQHWCTRL, 0xa1390003 +DATA 4, MX6_MMDC_P0_MDSCR, 0x04008040 +DATA 4, MX6_MMDC_P0_MDREF, 0x00007800 + +DATA 4, MX6_MMDC_P0_MPODTCTRL, 0x00022227 +DATA 4, MX6_MMDC_P1_MPODTCTRL, 0x00022227 + +DATA 4, MX6_MMDC_P0_MDPDC, 0x00025576 + +DATA 4, MX6_MMDC_P0_MAPSR, 0x00011006 +DATA 4, MX6_MMDC_P0_MDSCR, 0x00000000 + +/* set the default clock gate to save power */ +DATA 4, CCM_CCGR0, 0x00C03F3F +DATA 4, CCM_CCGR1, 0x0030FC03 +DATA 4, CCM_CCGR2, 0x0FFFC000 +DATA 4, CCM_CCGR3, 0x3FF00000 +DATA 4, CCM_CCGR4, 0x00FFF300 +DATA 4, CCM_CCGR5, 0x0F0000C3 +DATA 4, CCM_CCGR6, 0x000003FF + +/* enable AXI cache for VDOA/VPU/IPU */ +DATA 4, MX6_IOMUXC_GPR4, 0xF00000FF + +/* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */ +DATA 4, MX6_IOMUXC_GPR6, 0x007F007F +DATA 4, MX6_IOMUXC_GPR7, 0x007F007F + diff --git a/board/seco/mx6quq7/mx6quq7.c b/board/seco/mx6quq7/mx6quq7.c new file mode 100644 index 0000000..ea1d4b8 --- /dev/null +++ b/board/seco/mx6quq7/mx6quq7.c @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2013 Freescale Semiconductor, Inc. + * Copyright (C) 2015 ECA Sinters + * + * Author: Fabio Estevam + * Modified by: Boris Brezillon + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../common/mx6.h" + +DECLARE_GLOBAL_DATA_PTR; + +int dram_init(void) +{ + gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE); + + return 0; +} + +int board_early_init_f(void) +{ + seco_mx6_setup_uart_iomux(); + + return 0; +} + +int board_phy_config(struct phy_device *phydev) +{ + seco_mx6_rgmii_rework(phydev); + if (phydev->drv->config) + phydev->drv->config(phydev); + + return 0; +} + +int board_eth_init(bd_t *bis) +{ + uint32_t base = IMX_FEC_BASE; + struct mii_dev *bus = NULL; + struct phy_device *phydev = NULL; + int ret = 0; + + seco_mx6_setup_enet_iomux(); + +#ifdef CONFIG_FEC_MXC + bus = fec_get_miibus(base, -1); + if (!bus) + return -ENOMEM; + + /* scan phy 4,5,6,7 */ + phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII); + if (!phydev) { + free(bus); + return -ENOMEM; + } + + printf("using phy at %d\n", phydev->addr); + ret = fec_probe(bis, -1, base, bus, phydev); + if (ret) { + free(phydev); + free(bus); + printf("FEC MXC: %s:failed\n", __func__); + } +#endif + + return ret; +} + +static struct fsl_esdhc_cfg usdhc_cfg[2] = { + {USDHC3_BASE_ADDR}, + {USDHC2_BASE_ADDR}, +}; + +int board_mmc_init(bd_t *bis) +{ + u32 index = 0; + int ret; + + /* + * Following map is done: + * (U-boot device node) (Physical Port) + * mmc0 eMMC on Board + * mmc1 Ext SD + */ + for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) { + switch (index) { + case 0: + seco_mx6_setup_usdhc_iomux(3); + usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); + usdhc_cfg[0].max_bus_width = 4; + break; + case 1: + seco_mx6_setup_usdhc_iomux(4); + usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK); + usdhc_cfg[1].max_bus_width = 4; + break; + + default: + printf("Warning: %d exceed maximum number of SD ports %d\n", + index + 1, CONFIG_SYS_FSL_USDHC_NUM); + return -EINVAL; + } + + ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]); + if (ret) + return ret; + } + + return 0; +} + +int board_init(void) +{ + /* address of boot parameters */ + gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; + + imx_iomux_v3_setup_pad(MX6_PAD_NANDF_D4__GPIO2_IO04 | + MUX_PAD_CTRL(NO_PAD_CTRL)); + + gpio_direction_output(IMX_GPIO_NR(2, 4), 0); + + /* Set Low */ + gpio_set_value(IMX_GPIO_NR(2, 4), 0); + udelay(1000); + + /* Set High */ + gpio_set_value(IMX_GPIO_NR(2, 4), 1); + + return 0; +} + +int checkboard(void) +{ + puts("Board: SECO uQ7\n"); + + return 0; +} diff --git a/configs/secomx6quq7_defconfig b/configs/secomx6quq7_defconfig new file mode 100644 index 0000000..dcd681d --- /dev/null +++ b/configs/secomx6quq7_defconfig @@ -0,0 +1,7 @@ +CONFIG_SYS_EXTRA_OPTIONS="ENV_IS_IN_MMC" +CONFIG_ARM=y +CONFIG_ARCH_MX6=y +CONFIG_TARGET_SECOMX6=y +CONFIG_SECOMX6_UQ7=y +CONFIG_SECOMX6Q=y +CONFIG_SECOMX6_2GB=y diff --git a/include/configs/secomx6quq7.h b/include/configs/secomx6quq7.h new file mode 100644 index 0000000..46ffb7a --- /dev/null +++ b/include/configs/secomx6quq7.h @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2013 Seco S.r.l + * + * Configuration settings for the Seco Boards. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#include "mx6_common.h" +#include +#include +#include + +#define CONFIG_SYS_GENERIC_BOARD +#define CONFIG_DISPLAY_CPUINFO +#define CONFIG_DISPLAY_BOARDINFO + +#define CONFIG_CMDLINE_TAG +#define CONFIG_SETUP_MEMORY_TAGS +#define CONFIG_INITRD_TAG +#define CONFIG_REVISION_TAG +#define CONFIG_BOARD_REVISION_TAG + +/* Size of malloc() pool */ +#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M) + +#define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_MXC_GPIO + +#define CONFIG_MXC_UART +#define CONFIG_MXC_UART_BASE UART2_BASE + +/* allow to overwrite serial and ethaddr */ +#define CONFIG_ENV_OVERWRITE +#define CONFIG_CONS_INDEX 1 +#define CONFIG_BAUDRATE 115200 + +/* Command definition */ +#include + +#undef CONFIG_CMD_IMLS + +#define CONFIG_CMD_BMODE +#define CONFIG_CMD_SETEXPR + +#define CONFIG_BOOTDELAY 3 + +#define CONFIG_SYS_MEMTEST_START 0x10000000 +#define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 500 * SZ_1M) +#define CONFIG_LOADADDR 0x12000000 +#define CONFIG_SYS_TEXT_BASE 0x17800000 + +/* MMC Configuration */ +#define CONFIG_FSL_ESDHC +#define CONFIG_FSL_USDHC +#define CONFIG_SYS_FSL_USDHC_NUM 2 +#define CONFIG_SYS_FSL_ESDHC_ADDR 0 + +#define CONFIG_MMC +#define CONFIG_CMD_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_BOUNCE_BUFFER +#define CONFIG_CMD_EXT2 +#define CONFIG_CMD_FAT +#define CONFIG_DOS_PARTITION + +/* Ethernet Configuration */ +#define CONFIG_CMD_PING +#define CONFIG_CMD_DHCP +#define CONFIG_CMD_MII +#define CONFIG_CMD_NET +#define CONFIG_FEC_MXC +#define CONFIG_MII +#define IMX_FEC_BASE ENET_BASE_ADDR +#define CONFIG_FEC_XCV_TYPE RGMII +#define CONFIG_ETHPRIME "FEC" +#define CONFIG_FEC_MXC_PHYADDR 6 +#define CONFIG_PHYLIB +#define CONFIG_PHY_MICREL + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "netdev=eth0\0" \ + "ethprime=FEC0\0" \ + "netdev=eth0\0" \ + "ethprime=FEC0\0" \ + "uboot=u-boot.bin\0" \ + "kernel=uImage\0" \ + "nfsroot=/opt/eldk/arm\0" \ + "ip_local=10.0.0.5::10.0.0.1:255.255.255.0::eth0:off\0" \ + "ip_server=10.0.0.1\0" \ + "nfs_path=/targetfs \0" \ + "memory=mem=1024M\0" \ + "bootdev=mmc dev 0; ext2load mmc 0:1\0" \ + "root=root=/dev/mmcblk0p1\0" \ + "option=rootwait rw fixrtc rootflags=barrier=1\0" \ + "cpu_freq=arm_freq=996\0" \ + "setbootargs=setenv bootargs console=ttymxc1,115200 ${root}" \ + " ${option} ${memory} ${cpu_freq}\0" \ + "setbootargs_nfs=setenv bootargs console=ttymxc1,115200" \ + " root=/dev/nfs nfsroot=${ip_server}:${nfs_path}" \ + " nolock,wsize=4096,rsize=4096 ip=:::::eth0:dhcp" \ + " ${memory} ${cpu_freq}\0" \ + "setbootdev=setenv boot_dev ${bootdev} 10800000 /boot/uImage\0" \ + "bootcmd=run setbootargs; run setbootdev; run boot_dev;" \ + " bootm 0x10800000\0" \ + "stdin=serial\0" \ + "stdout=serial\0" \ + "stderr=serial\0" + + +/* Miscellaneous configurable options */ +#define CONFIG_SYS_LONGHELP +#define CONFIG_SYS_HUSH_PARSER +#define CONFIG_SYS_PROMPT "SECO MX6Q uQ7 U-Boot > " + +#define CONFIG_AUTO_COMPLETE +#define CONFIG_SYS_CBSIZE 256 + +/* Print Buffer Size */ +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ + sizeof(CONFIG_SYS_PROMPT) + 16) +#define CONFIG_SYS_MAXARGS 16 +#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE + +#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR +#define CONFIG_SYS_HZ 1000 + +#define CONFIG_CMDLINE_EDITING + + +/* Physical Memory Map */ +#define CONFIG_NR_DRAM_BANKS 1 +#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR +#define PHYS_SDRAM_SIZE (2u * 1024 * 1024 * 1024) + +#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM +#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR +#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE + +#define CONFIG_SYS_INIT_SP_OFFSET \ + (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE) +#define CONFIG_SYS_INIT_SP_ADDR \ + (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET) + +/* FLASH and environment organization */ +#define CONFIG_SYS_NO_FLASH + +#define CONFIG_ENV_SIZE (8 * 1024) + +#if defined(CONFIG_ENV_IS_IN_MMC) + #define CONFIG_ENV_OFFSET (6 * 128 * 1024) + #define CONFIG_SYS_MMC_ENV_DEV 0 + #define CONFIG_DYNAMIC_MMC_DEVNO +#endif + +#define CONFIG_OF_LIBFDT +#define CONFIG_CMD_BOOTZ + +#ifndef CONFIG_SYS_DCACHE_OFF +#define CONFIG_CMD_CACHE +#endif + +#endif /* __CONFIG_H */ -- cgit v0.10.2 From b02d9acb3c38033e2803fdb81a5c067e6ae841a7 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 10 Mar 2015 15:33:24 +0800 Subject: imx:mx6dlsabresd fix error detecting thermal Before add CONFIG_SYS_MALLOC_F and CONFIG_SYS_MALLOC_F_LEN, uboot will complains "CPU: Temperature: Can't find sensor device". This is because DM and DM_THERMAL are enabled, but SYS_MALLOC_F is not configured. After applying this patch, uboot can correctly detect the temperature. " U-Boot 2015.04-rc2-00146-g48b6e30-dirty (Mar 09 2015 - 13:04:36) CPU: Freescale i.MX6DL rev1.1 at 792 MHz CPU: Temperature 44 C " Signed-off-by: Peng Fan diff --git a/configs/mx6dlsabresd_defconfig b/configs/mx6dlsabresd_defconfig index 6adfd55..cde0d70 100644 --- a/configs/mx6dlsabresd_defconfig +++ b/configs/mx6dlsabresd_defconfig @@ -1,5 +1,7 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sabresd/mx6dlsabresd.cfg,MX6DL" CONFIG_ARM=y CONFIG_TARGET_MX6SABRESD=y +CONFIG_SYS_MALLOC_F=y +CONFIG_SYS_MALLOC_F_LEN=0x400 CONFIG_DM=y CONFIG_DM_THERMAL=y -- cgit v0.10.2 From 27d3608076b37f372b9ba59e1eb00114291d6558 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 10 Mar 2015 15:33:25 +0800 Subject: imx:mx6slevk support reading temperature This patch is to support reading temperature for mx6slevk board. Signed-off-by: Peng Fan diff --git a/configs/mx6slevk_defconfig b/configs/mx6slevk_defconfig index fb8c4de..c6b3108 100644 --- a/configs/mx6slevk_defconfig +++ b/configs/mx6slevk_defconfig @@ -1,3 +1,7 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6slevk/imximage.cfg,MX6SL" CONFIG_ARM=y CONFIG_TARGET_MX6SLEVK=y +CONFIG_SYS_MALLOC_F=y +CONFIG_SYS_MALLOC_F_LEN=0x400 +CONFIG_DM=y +CONFIG_DM_THERMAL=y diff --git a/configs/mx6slevk_spinor_defconfig b/configs/mx6slevk_spinor_defconfig index 93efe73..454cb40 100644 --- a/configs/mx6slevk_spinor_defconfig +++ b/configs/mx6slevk_spinor_defconfig @@ -1,3 +1,7 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6slevk/imximage.cfg,MX6SL,SYS_BOOT_SPINOR" CONFIG_ARM=y CONFIG_TARGET_MX6SLEVK=y +CONFIG_SYS_MALLOC_F=y +CONFIG_SYS_MALLOC_F_LEN=0x400 +CONFIG_DM=y +CONFIG_DM_THERMAL=y diff --git a/include/configs/mx6slevk.h b/include/configs/mx6slevk.h index 21c654b..dad49f9 100644 --- a/include/configs/mx6slevk.h +++ b/include/configs/mx6slevk.h @@ -249,4 +249,11 @@ #define CONFIG_SYS_MMC_ENV_DEV 1 /* SDHC2*/ #endif +#define CONFIG_IMX6_THERMAL + +#define CONFIG_CMD_FUSE +#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX6_THERMAL) +#define CONFIG_MXC_OCOTP +#endif + #endif /* __CONFIG_H */ -- cgit v0.10.2 From 312cc39e270170b37a992b2d57773c828dcb9c6b Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 10 Mar 2015 18:31:20 +0800 Subject: x86: quark: MRC codes clean up This patch cleans up the quark MRC codes coding style by: - Remove BIT0/1../31 defines from mrc_util.h - Create names for the documented BITs and use them - For undocumented single BITs, use (1 << n) directly - For undocumented ORed BITs, use the hex number directly - Remove redundancy parenthesis all over the codes - Replace to use lower case hex numbers Signed-off-by: Bin Meng diff --git a/arch/x86/cpu/quark/hte.c b/arch/x86/cpu/quark/hte.c index 372815d..db601e4 100644 --- a/arch/x86/cpu/quark/hte.c +++ b/arch/x86/cpu/quark/hte.c @@ -20,9 +20,9 @@ */ static void hte_enable_all_errors(void) { - msg_port_write(HTE, 0x000200A2, 0xFFFFFFFF); - msg_port_write(HTE, 0x000200A3, 0x000000FF); - msg_port_write(HTE, 0x000200A4, 0x00000000); + msg_port_write(HTE, 0x000200a2, 0xffffffff); + msg_port_write(HTE, 0x000200a3, 0x000000ff); + msg_port_write(HTE, 0x000200a4, 0x00000000); } /** @@ -32,7 +32,7 @@ static void hte_enable_all_errors(void) */ static u32 hte_check_errors(void) { - return msg_port_read(HTE, 0x000200A7); + return msg_port_read(HTE, 0x000200a7); } /** @@ -44,11 +44,11 @@ static void hte_wait_for_complete(void) ENTERFN(); - do {} while ((msg_port_read(HTE, 0x00020012) & BIT30) != 0); + do {} while ((msg_port_read(HTE, 0x00020012) & (1 << 30)) != 0); tmp = msg_port_read(HTE, 0x00020011); - tmp |= BIT9; - tmp &= ~(BIT12 | BIT13); + tmp |= (1 << 9); + tmp &= ~((1 << 12) | (1 << 13)); msg_port_write(HTE, 0x00020011, tmp); LEAVEFN(); @@ -65,9 +65,9 @@ static void hte_clear_error_regs(void) * Clear all HTE errors and enable error checking * for burst and chunk. */ - tmp = msg_port_read(HTE, 0x000200A1); - tmp |= BIT8; - msg_port_write(HTE, 0x000200A1, tmp); + tmp = msg_port_read(HTE, 0x000200a1); + tmp |= (1 << 8); + msg_port_write(HTE, 0x000200a1, tmp); } /** @@ -91,25 +91,25 @@ static u16 hte_basic_data_cmp(struct mrc_params *mrc_params, u32 addr, u32 offset; if (first_run) { - msg_port_write(HTE, 0x00020020, 0x01B10021); + msg_port_write(HTE, 0x00020020, 0x01b10021); msg_port_write(HTE, 0x00020021, 0x06000000); msg_port_write(HTE, 0x00020022, addr >> 6); msg_port_write(HTE, 0x00020062, 0x00800015); - msg_port_write(HTE, 0x00020063, 0xAAAAAAAA); - msg_port_write(HTE, 0x00020064, 0xCCCCCCCC); - msg_port_write(HTE, 0x00020065, 0xF0F0F0F0); + msg_port_write(HTE, 0x00020063, 0xaaaaaaaa); + msg_port_write(HTE, 0x00020064, 0xcccccccc); + msg_port_write(HTE, 0x00020065, 0xf0f0f0f0); msg_port_write(HTE, 0x00020061, 0x00030008); if (mode == WRITE_TRAIN) - pattern = 0xC33C0000; + pattern = 0xc33c0000; else /* READ_TRAIN */ - pattern = 0xAA5555AA; + pattern = 0xaa5555aa; - for (offset = 0x80; offset <= 0x8F; offset++) + for (offset = 0x80; offset <= 0x8f; offset++) msg_port_write(HTE, offset, pattern); } - msg_port_write(HTE, 0x000200A1, 0xFFFF1000); + msg_port_write(HTE, 0x000200a1, 0xffff1000); msg_port_write(HTE, 0x00020011, 0x00011000); msg_port_write(HTE, 0x00020011, 0x00011100); @@ -119,7 +119,7 @@ static u16 hte_basic_data_cmp(struct mrc_params *mrc_params, u32 addr, * Return bits 15:8 of HTE_CH0_ERR_XSTAT to check for * any bytelane errors. */ - return (hte_check_errors() >> 8) & 0xFF; + return (hte_check_errors() >> 8) & 0xff; } /** @@ -153,7 +153,7 @@ static u16 hte_rw_data_cmp(struct mrc_params *mrc_params, u32 addr, msg_port_write(HTE, 0x00020024, 0x06070000); msg_port_write(HTE, 0x00020022, addr >> 6); msg_port_write(HTE, 0x00020025, addr >> 6); - msg_port_write(HTE, 0x00020062, 0x0000002A); + msg_port_write(HTE, 0x00020062, 0x0000002a); msg_port_write(HTE, 0x00020063, seed_victim); msg_port_write(HTE, 0x00020064, seed_aggressor); msg_port_write(HTE, 0x00020065, seed_victim); @@ -163,21 +163,21 @@ static u16 hte_rw_data_cmp(struct mrc_params *mrc_params, u32 addr, * * Start with bit0 */ - for (offset = 0x80; offset <= 0x8F; offset++) { + for (offset = 0x80; offset <= 0x8f; offset++) { if ((offset % 8) == victim_bit) msg_port_write(HTE, offset, 0x55555555); else - msg_port_write(HTE, offset, 0xCCCCCCCC); + msg_port_write(HTE, offset, 0xcccccccc); } msg_port_write(HTE, 0x00020061, 0x00000000); msg_port_write(HTE, 0x00020066, 0x03440000); - msg_port_write(HTE, 0x000200A1, 0xFFFF1000); + msg_port_write(HTE, 0x000200a1, 0xffff1000); } tmp = 0x10001000 | (loop_cnt << 16); msg_port_write(HTE, 0x00020011, tmp); - msg_port_write(HTE, 0x00020011, tmp | BIT8); + msg_port_write(HTE, 0x00020011, tmp | (1 << 8)); hte_wait_for_complete(); @@ -185,7 +185,7 @@ static u16 hte_rw_data_cmp(struct mrc_params *mrc_params, u32 addr, * Return bits 15:8 of HTE_CH0_ERR_XSTAT to check for * any bytelane errors. */ - return (hte_check_errors() >> 8) & 0xFF; + return (hte_check_errors() >> 8) & 0xff; } /** @@ -219,14 +219,14 @@ u32 hte_mem_init(struct mrc_params *mrc_params, u8 flag) msg_port_write(HTE, 0x00020062, 0x00000015); - for (offset = 0x80; offset <= 0x8F; offset++) - msg_port_write(HTE, offset, ((offset & 1) ? 0xA55A : 0x5AA5)); + for (offset = 0x80; offset <= 0x8f; offset++) + msg_port_write(HTE, offset, ((offset & 1) ? 0xa55a : 0x5aa5)); msg_port_write(HTE, 0x00020021, 0x00000000); msg_port_write(HTE, 0x00020022, (mrc_params->mem_size >> 6) - 1); - msg_port_write(HTE, 0x00020063, 0xAAAAAAAA); - msg_port_write(HTE, 0x00020064, 0xCCCCCCCC); - msg_port_write(HTE, 0x00020065, 0xF0F0F0F0); + msg_port_write(HTE, 0x00020063, 0xaaaaaaaa); + msg_port_write(HTE, 0x00020064, 0xcccccccc); + msg_port_write(HTE, 0x00020065, 0xf0f0f0f0); msg_port_write(HTE, 0x00020066, 0x03000000); switch (flag) { @@ -243,7 +243,7 @@ u32 hte_mem_init(struct mrc_params *mrc_params, u8 flag) break; default: DPF(D_INFO, "Unknown parameter for flag: %d\n", flag); - return 0xFFFFFFFF; + return 0xffffffff; } DPF(D_INFO, "hte_mem_init"); @@ -379,16 +379,16 @@ void hte_mem_op(u32 addr, u8 first_run, u8 is_write) msg_port_write(HTE, 0x00020021, 0x06000000); msg_port_write(HTE, 0x00020022, addr >> 6); msg_port_write(HTE, 0x00020062, 0x00800015); - msg_port_write(HTE, 0x00020063, 0xAAAAAAAA); - msg_port_write(HTE, 0x00020064, 0xCCCCCCCC); - msg_port_write(HTE, 0x00020065, 0xF0F0F0F0); + msg_port_write(HTE, 0x00020063, 0xaaaaaaaa); + msg_port_write(HTE, 0x00020064, 0xcccccccc); + msg_port_write(HTE, 0x00020065, 0xf0f0f0f0); msg_port_write(HTE, 0x00020061, 0x00030008); - for (offset = 0x80; offset <= 0x8F; offset++) - msg_port_write(HTE, offset, 0xC33C0000); + for (offset = 0x80; offset <= 0x8f; offset++) + msg_port_write(HTE, offset, 0xc33c0000); } - msg_port_write(HTE, 0x000200A1, 0xFFFF1000); + msg_port_write(HTE, 0x000200a1, 0xffff1000); msg_port_write(HTE, 0x00020011, 0x00011000); msg_port_write(HTE, 0x00020011, 0x00011100); diff --git a/arch/x86/cpu/quark/hte.h b/arch/x86/cpu/quark/hte.h index 6577796..e98c7ef 100644 --- a/arch/x86/cpu/quark/hte.h +++ b/arch/x86/cpu/quark/hte.h @@ -29,10 +29,10 @@ enum { #define HTE_LOOP_CNT 5 /* random seed for victim */ -#define HTE_LFSR_VICTIM_SEED 0xF294BA21 +#define HTE_LFSR_VICTIM_SEED 0xf294ba21 /* random seed for aggressor */ -#define HTE_LFSR_AGRESSOR_SEED 0xEBA7492D +#define HTE_LFSR_AGRESSOR_SEED 0xeba7492d u32 hte_mem_init(struct mrc_params *mrc_params, u8 flag); u16 hte_basic_write_read(struct mrc_params *mrc_params, u32 addr, diff --git a/arch/x86/cpu/quark/mrc.c b/arch/x86/cpu/quark/mrc.c index 7eb34c5..65734e9 100644 --- a/arch/x86/cpu/quark/mrc.c +++ b/arch/x86/cpu/quark/mrc.c @@ -105,8 +105,8 @@ static void mrc_adjust_params(struct mrc_params *mrc_params) * Column: 11 for 8Gbx8, else 10 */ mrc_params->column_bits[0] = - ((dram_params[0].density == 4) && - (dram_width == X8)) ? (11) : (10); + (dram_params[0].density == 4) && + (dram_width == X8) ? 11 : 10; /* * Determine row bits: @@ -117,9 +117,9 @@ static void mrc_adjust_params(struct mrc_params *mrc_params) * 4Gbx16=15 4Gbx8=16 * 8Gbx16=16 8Gbx8=16 */ - mrc_params->row_bits[0] = 12 + (dram_params[0].density) + - (((dram_params[0].density < 4) && - (dram_width == X8)) ? (1) : (0)); + mrc_params->row_bits[0] = 12 + dram_params[0].density + + (dram_params[0].density < 4) && + (dram_width == X8) ? 1 : 0; /* * Determine per-channel memory size: @@ -137,7 +137,7 @@ static void mrc_adjust_params(struct mrc_params *mrc_params) * 4Gb x16 0x040000000 (1024MB) * 4Gb x8 0x080000000 (2048MB) */ - mrc_params->channel_size[0] = (1 << dram_params[0].density); + mrc_params->channel_size[0] = 1 << dram_params[0].density; mrc_params->channel_size[0] *= (dram_width == X8) ? 2 : 1; mrc_params->channel_size[0] *= (rank_enables == 0x3) ? 2 : 1; mrc_params->channel_size[0] *= (channel_width == X16) ? 1 : 2; diff --git a/arch/x86/cpu/quark/mrc_util.c b/arch/x86/cpu/quark/mrc_util.c index 3a79ae5..49d803d 100644 --- a/arch/x86/cpu/quark/mrc_util.c +++ b/arch/x86/cpu/quark/mrc_util.c @@ -18,14 +18,14 @@ static const uint8_t vref_codes[64] = { /* lowest to highest */ - 0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38, + 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, - 0x2F, 0x2E, 0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x28, + 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; void mrc_write_mask(u32 unit, u32 addr, u32 data, u32 mask) @@ -80,7 +80,7 @@ void select_mem_mgr(void) ENTERFN(); dco = msg_port_read(MEM_CTLR, DCO); - dco &= ~BIT28; + dco &= ~DCO_PMICTL; msg_port_write(MEM_CTLR, DCO, dco); LEAVEFN(); @@ -94,7 +94,7 @@ void select_hte(void) ENTERFN(); dco = msg_port_read(MEM_CTLR, DCO); - dco |= BIT28; + dco |= DCO_PMICTL; msg_port_write(MEM_CTLR, DCO, dco); LEAVEFN(); @@ -151,26 +151,25 @@ void set_rcvn(uint8_t channel, uint8_t rank, * BL0 -> B01PTRCTL0[11:08] (0x0-0xF) * BL1 -> B01PTRCTL0[23:20] (0x0-0xF) */ - reg = B01PTRCTL0 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); - msk = (byte_lane & BIT0) ? (BIT23 | BIT22 | BIT21 | BIT20) : - (BIT11 | BIT10 | BIT9 | BIT8); - temp = (byte_lane & BIT0) ? ((pi_count / HALF_CLK) << 20) : - ((pi_count / HALF_CLK) << 8); + reg = B01PTRCTL0 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; + msk = (byte_lane & 1) ? 0xf00000 : 0xf00; + temp = (byte_lane & 1) ? (pi_count / HALF_CLK) << 20 : + (pi_count / HALF_CLK) << 8; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* Adjust PI_COUNT */ - pi_count -= ((pi_count / HALF_CLK) & 0xF) * HALF_CLK; + pi_count -= ((pi_count / HALF_CLK) & 0xf) * HALF_CLK; /* * PI (1/64 MCLK, 1 PIs) * BL0 -> B0DLLPICODER0[29:24] (0x00-0x3F) * BL1 -> B1DLLPICODER0[29:24] (0x00-0x3F) */ - reg = (byte_lane & BIT0) ? B1DLLPICODER0 : B0DLLPICODER0; - reg += (((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)); - msk = (BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | BIT24); + reg = (byte_lane & 1) ? B1DLLPICODER0 : B0DLLPICODER0; + reg += ((byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); + msk = 0x3f000000; temp = pi_count << 24; mrc_alt_write_mask(DDRPHY, reg, temp, msk); @@ -179,25 +178,25 @@ void set_rcvn(uint8_t channel, uint8_t rank, * BL0/1 -> B01DBCTL1[08/11] (+1 select) * BL0/1 -> B01DBCTL1[02/05] (enable) */ - reg = B01DBCTL1 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); + reg = B01DBCTL1 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; msk = 0x00; temp = 0x00; /* enable */ - msk |= (byte_lane & BIT0) ? BIT5 : BIT2; + msk |= (byte_lane & 1) ? (1 << 5) : (1 << 2); if ((pi_count < EARLY_DB) || (pi_count > LATE_DB)) temp |= msk; /* select */ - msk |= (byte_lane & BIT0) ? BIT11 : BIT8; + msk |= (byte_lane & 1) ? (1 << 11) : (1 << 8); if (pi_count < EARLY_DB) temp |= msk; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* error check */ - if (pi_count > 0x3F) { + if (pi_count > 0x3f) { training_message(channel, rank, byte_lane); mrc_post_code(0xee, 0xe0); } @@ -224,11 +223,11 @@ uint32_t get_rcvn(uint8_t channel, uint8_t rank, uint8_t byte_lane) * BL0 -> B01PTRCTL0[11:08] (0x0-0xF) * BL1 -> B01PTRCTL0[23:20] (0x0-0xF) */ - reg = B01PTRCTL0 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); + reg = B01PTRCTL0 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; temp = msg_port_alt_read(DDRPHY, reg); - temp >>= (byte_lane & BIT0) ? 20 : 8; - temp &= 0xF; + temp >>= (byte_lane & 1) ? 20 : 8; + temp &= 0xf; /* Adjust PI_COUNT */ pi_count = temp * HALF_CLK; @@ -238,12 +237,12 @@ uint32_t get_rcvn(uint8_t channel, uint8_t rank, uint8_t byte_lane) * BL0 -> B0DLLPICODER0[29:24] (0x00-0x3F) * BL1 -> B1DLLPICODER0[29:24] (0x00-0x3F) */ - reg = (byte_lane & BIT0) ? B1DLLPICODER0 : B0DLLPICODER0; - reg += (((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)); + reg = (byte_lane & 1) ? B1DLLPICODER0 : B0DLLPICODER0; + reg += ((byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); temp = msg_port_alt_read(DDRPHY, reg); temp >>= 24; - temp &= 0x3F; + temp &= 0x3f; /* Adjust PI_COUNT */ pi_count += temp; @@ -275,10 +274,10 @@ void set_rdqs(uint8_t channel, uint8_t rank, * BL0 -> B0RXDQSPICODE[06:00] (0x00-0x47) * BL1 -> B1RXDQSPICODE[06:00] (0x00-0x47) */ - reg = (byte_lane & BIT0) ? B1RXDQSPICODE : B0RXDQSPICODE; - reg += (((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)); - msk = (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0); + reg = (byte_lane & 1) ? B1RXDQSPICODE : B0RXDQSPICODE; + reg += ((byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); + msk = 0x7f; temp = pi_count << 0; mrc_alt_write_mask(DDRPHY, reg, temp, msk); @@ -310,13 +309,13 @@ uint32_t get_rdqs(uint8_t channel, uint8_t rank, uint8_t byte_lane) * BL0 -> B0RXDQSPICODE[06:00] (0x00-0x47) * BL1 -> B1RXDQSPICODE[06:00] (0x00-0x47) */ - reg = (byte_lane & BIT0) ? B1RXDQSPICODE : B0RXDQSPICODE; - reg += (((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)); + reg = (byte_lane & 1) ? B1RXDQSPICODE : B0RXDQSPICODE; + reg += ((byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); temp = msg_port_alt_read(DDRPHY, reg); /* Adjust PI_COUNT */ - pi_count = temp & 0x7F; + pi_count = temp & 0x7f; LEAVEFN(); @@ -346,26 +345,25 @@ void set_wdqs(uint8_t channel, uint8_t rank, * BL0 -> B01PTRCTL0[07:04] (0x0-0xF) * BL1 -> B01PTRCTL0[19:16] (0x0-0xF) */ - reg = B01PTRCTL0 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); - msk = (byte_lane & BIT0) ? (BIT19 | BIT18 | BIT17 | BIT16) : - (BIT7 | BIT6 | BIT5 | BIT4); + reg = B01PTRCTL0 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; + msk = (byte_lane & 1) ? 0xf0000 : 0xf0; temp = pi_count / HALF_CLK; - temp <<= (byte_lane & BIT0) ? 16 : 4; + temp <<= (byte_lane & 1) ? 16 : 4; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* Adjust PI_COUNT */ - pi_count -= ((pi_count / HALF_CLK) & 0xF) * HALF_CLK; + pi_count -= ((pi_count / HALF_CLK) & 0xf) * HALF_CLK; /* * PI (1/64 MCLK, 1 PIs) * BL0 -> B0DLLPICODER0[21:16] (0x00-0x3F) * BL1 -> B1DLLPICODER0[21:16] (0x00-0x3F) */ - reg = (byte_lane & BIT0) ? B1DLLPICODER0 : B0DLLPICODER0; - reg += (((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)); - msk = (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | BIT16); + reg = (byte_lane & 1) ? B1DLLPICODER0 : B0DLLPICODER0; + reg += ((byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); + msk = 0x3f0000; temp = pi_count << 16; mrc_alt_write_mask(DDRPHY, reg, temp, msk); @@ -374,25 +372,25 @@ void set_wdqs(uint8_t channel, uint8_t rank, * BL0/1 -> B01DBCTL1[07/10] (+1 select) * BL0/1 -> B01DBCTL1[01/04] (enable) */ - reg = B01DBCTL1 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); + reg = B01DBCTL1 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; msk = 0x00; temp = 0x00; /* enable */ - msk |= (byte_lane & BIT0) ? BIT4 : BIT1; + msk |= (byte_lane & 1) ? (1 << 4) : (1 << 1); if ((pi_count < EARLY_DB) || (pi_count > LATE_DB)) temp |= msk; /* select */ - msk |= (byte_lane & BIT0) ? BIT10 : BIT7; + msk |= (byte_lane & 1) ? (1 << 10) : (1 << 7); if (pi_count < EARLY_DB) temp |= msk; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* error check */ - if (pi_count > 0x3F) { + if (pi_count > 0x3f) { training_message(channel, rank, byte_lane); mrc_post_code(0xee, 0xe2); } @@ -419,11 +417,11 @@ uint32_t get_wdqs(uint8_t channel, uint8_t rank, uint8_t byte_lane) * BL0 -> B01PTRCTL0[07:04] (0x0-0xF) * BL1 -> B01PTRCTL0[19:16] (0x0-0xF) */ - reg = B01PTRCTL0 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); + reg = B01PTRCTL0 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; temp = msg_port_alt_read(DDRPHY, reg); - temp >>= (byte_lane & BIT0) ? 16 : 4; - temp &= 0xF; + temp >>= (byte_lane & 1) ? 16 : 4; + temp &= 0xf; /* Adjust PI_COUNT */ pi_count = (temp * HALF_CLK); @@ -433,12 +431,12 @@ uint32_t get_wdqs(uint8_t channel, uint8_t rank, uint8_t byte_lane) * BL0 -> B0DLLPICODER0[21:16] (0x00-0x3F) * BL1 -> B1DLLPICODER0[21:16] (0x00-0x3F) */ - reg = (byte_lane & BIT0) ? B1DLLPICODER0 : B0DLLPICODER0; - reg += (((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)); + reg = (byte_lane & 1) ? B1DLLPICODER0 : B0DLLPICODER0; + reg += ((byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); temp = msg_port_alt_read(DDRPHY, reg); temp >>= 16; - temp &= 0x3F; + temp &= 0x3f; /* Adjust PI_COUNT */ pi_count += temp; @@ -471,26 +469,25 @@ void set_wdq(uint8_t channel, uint8_t rank, * BL0 -> B01PTRCTL0[03:00] (0x0-0xF) * BL1 -> B01PTRCTL0[15:12] (0x0-0xF) */ - reg = B01PTRCTL0 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); - msk = (byte_lane & BIT0) ? (BIT15 | BIT14 | BIT13 | BIT12) : - (BIT3 | BIT2 | BIT1 | BIT0); + reg = B01PTRCTL0 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; + msk = (byte_lane & 1) ? 0xf000 : 0xf; temp = pi_count / HALF_CLK; - temp <<= (byte_lane & BIT0) ? 12 : 0; + temp <<= (byte_lane & 1) ? 12 : 0; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* Adjust PI_COUNT */ - pi_count -= ((pi_count / HALF_CLK) & 0xF) * HALF_CLK; + pi_count -= ((pi_count / HALF_CLK) & 0xf) * HALF_CLK; /* * PI (1/64 MCLK, 1 PIs) * BL0 -> B0DLLPICODER0[13:08] (0x00-0x3F) * BL1 -> B1DLLPICODER0[13:08] (0x00-0x3F) */ - reg = (byte_lane & BIT0) ? B1DLLPICODER0 : B0DLLPICODER0; - reg += (((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)); - msk = (BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8); + reg = (byte_lane & 1) ? B1DLLPICODER0 : B0DLLPICODER0; + reg += ((byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); + msk = 0x3f00; temp = pi_count << 8; mrc_alt_write_mask(DDRPHY, reg, temp, msk); @@ -499,25 +496,25 @@ void set_wdq(uint8_t channel, uint8_t rank, * BL0/1 -> B01DBCTL1[06/09] (+1 select) * BL0/1 -> B01DBCTL1[00/03] (enable) */ - reg = B01DBCTL1 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); + reg = B01DBCTL1 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; msk = 0x00; temp = 0x00; /* enable */ - msk |= (byte_lane & BIT0) ? BIT3 : BIT0; + msk |= (byte_lane & 1) ? (1 << 3) : (1 << 0); if ((pi_count < EARLY_DB) || (pi_count > LATE_DB)) temp |= msk; /* select */ - msk |= (byte_lane & BIT0) ? BIT9 : BIT6; + msk |= (byte_lane & 1) ? (1 << 9) : (1 << 6); if (pi_count < EARLY_DB) temp |= msk; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* error check */ - if (pi_count > 0x3F) { + if (pi_count > 0x3f) { training_message(channel, rank, byte_lane); mrc_post_code(0xee, 0xe3); } @@ -544,11 +541,11 @@ uint32_t get_wdq(uint8_t channel, uint8_t rank, uint8_t byte_lane) * BL0 -> B01PTRCTL0[03:00] (0x0-0xF) * BL1 -> B01PTRCTL0[15:12] (0x0-0xF) */ - reg = B01PTRCTL0 + ((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET); + reg = B01PTRCTL0 + (byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET; temp = msg_port_alt_read(DDRPHY, reg); - temp >>= (byte_lane & BIT0) ? (12) : (0); - temp &= 0xF; + temp >>= (byte_lane & 1) ? 12 : 0; + temp &= 0xf; /* Adjust PI_COUNT */ pi_count = temp * HALF_CLK; @@ -558,12 +555,12 @@ uint32_t get_wdq(uint8_t channel, uint8_t rank, uint8_t byte_lane) * BL0 -> B0DLLPICODER0[13:08] (0x00-0x3F) * BL1 -> B1DLLPICODER0[13:08] (0x00-0x3F) */ - reg = (byte_lane & BIT0) ? B1DLLPICODER0 : B0DLLPICODER0; - reg += (((byte_lane >> 1) * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)); + reg = (byte_lane & 1) ? B1DLLPICODER0 : B0DLLPICODER0; + reg += ((byte_lane >> 1) * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); temp = msg_port_alt_read(DDRPHY, reg); temp >>= 8; - temp &= 0x3F; + temp &= 0x3f; /* Adjust PI_COUNT */ pi_count += temp; @@ -589,14 +586,14 @@ void set_wcmd(uint8_t channel, uint32_t pi_count) * RDPTR (1/2 MCLK, 64 PIs) * CMDPTRREG[11:08] (0x0-0xF) */ - reg = CMDPTRREG + (channel * DDRIOCCC_CH_OFFSET); - msk = (BIT11 | BIT10 | BIT9 | BIT8); + reg = CMDPTRREG + channel * DDRIOCCC_CH_OFFSET; + msk = 0xf00; temp = pi_count / HALF_CLK; temp <<= 8; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* Adjust PI_COUNT */ - pi_count -= ((pi_count / HALF_CLK) & 0xF) * HALF_CLK; + pi_count -= ((pi_count / HALF_CLK) & 0xf) * HALF_CLK; /* * PI (1/64 MCLK, 1 PIs) @@ -609,18 +606,13 @@ void set_wcmd(uint8_t channel, uint32_t pi_count) * CMDDLLPICODER1[13:08] -> CMDSLICE R0 (unused) * CMDDLLPICODER1[05:00] -> CMDSLICE L0 (unused) */ - reg = CMDDLLPICODER1 + (channel * DDRIOCCC_CH_OFFSET); - - msk = (BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | BIT24 | - BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | BIT16 | - BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8 | - BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0); - + reg = CMDDLLPICODER1 + channel * DDRIOCCC_CH_OFFSET; + msk = 0x3f3f3f3f; temp = (pi_count << 24) | (pi_count << 16) | (pi_count << 8) | (pi_count << 0); mrc_alt_write_mask(DDRPHY, reg, temp, msk); - reg = CMDDLLPICODER0 + (channel * DDRIOCCC_CH_OFFSET); /* PO */ + reg = CMDDLLPICODER0 + channel * DDRIOCCC_CH_OFFSET; /* PO */ mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* @@ -628,24 +620,24 @@ void set_wcmd(uint8_t channel, uint32_t pi_count) * CMDCFGREG0[17] (+1 select) * CMDCFGREG0[16] (enable) */ - reg = CMDCFGREG0 + (channel * DDRIOCCC_CH_OFFSET); + reg = CMDCFGREG0 + channel * DDRIOCCC_CH_OFFSET; msk = 0x00; temp = 0x00; /* enable */ - msk |= BIT16; + msk |= (1 << 16); if ((pi_count < EARLY_DB) || (pi_count > LATE_DB)) temp |= msk; /* select */ - msk |= BIT17; + msk |= (1 << 17); if (pi_count < EARLY_DB) temp |= msk; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* error check */ - if (pi_count > 0x3F) + if (pi_count > 0x3f) mrc_post_code(0xee, 0xe4); LEAVEFN(); @@ -667,10 +659,10 @@ uint32_t get_wcmd(uint8_t channel) * RDPTR (1/2 MCLK, 64 PIs) * CMDPTRREG[11:08] (0x0-0xF) */ - reg = CMDPTRREG + (channel * DDRIOCCC_CH_OFFSET); + reg = CMDPTRREG + channel * DDRIOCCC_CH_OFFSET; temp = msg_port_alt_read(DDRPHY, reg); temp >>= 8; - temp &= 0xF; + temp &= 0xf; /* Adjust PI_COUNT */ pi_count = temp * HALF_CLK; @@ -686,10 +678,10 @@ uint32_t get_wcmd(uint8_t channel) * CMDDLLPICODER1[13:08] -> CMDSLICE R0 (unused) * CMDDLLPICODER1[05:00] -> CMDSLICE L0 (unused) */ - reg = CMDDLLPICODER1 + (channel * DDRIOCCC_CH_OFFSET); + reg = CMDDLLPICODER1 + channel * DDRIOCCC_CH_OFFSET; temp = msg_port_alt_read(DDRPHY, reg); temp >>= 16; - temp &= 0x3F; + temp &= 0x3f; /* Adjust PI_COUNT */ pi_count += temp; @@ -716,13 +708,13 @@ void set_wclk(uint8_t channel, uint8_t rank, uint32_t pi_count) * CCPTRREG[15:12] -> CLK1 (0x0-0xF) * CCPTRREG[11:08] -> CLK0 (0x0-0xF) */ - reg = CCPTRREG + (channel * DDRIOCCC_CH_OFFSET); - msk = (BIT15 | BIT14 | BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8); + reg = CCPTRREG + channel * DDRIOCCC_CH_OFFSET; + msk = 0xff00; temp = ((pi_count / HALF_CLK) << 12) | ((pi_count / HALF_CLK) << 8); mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* Adjust PI_COUNT */ - pi_count -= ((pi_count / HALF_CLK) & 0xF) * HALF_CLK; + pi_count -= ((pi_count / HALF_CLK) & 0xf) * HALF_CLK; /* * PI (1/64 MCLK, 1 PIs) @@ -731,16 +723,18 @@ void set_wclk(uint8_t channel, uint8_t rank, uint32_t pi_count) */ reg = rank ? ECCB1DLLPICODER0 : ECCB1DLLPICODER0; reg += (channel * DDRIOCCC_CH_OFFSET); - msk = (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | BIT16 | - BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8); + msk = 0x3f3f00; temp = (pi_count << 16) | (pi_count << 8); mrc_alt_write_mask(DDRPHY, reg, temp, msk); + reg = rank ? ECCB1DLLPICODER1 : ECCB1DLLPICODER1; reg += (channel * DDRIOCCC_CH_OFFSET); mrc_alt_write_mask(DDRPHY, reg, temp, msk); + reg = rank ? ECCB1DLLPICODER2 : ECCB1DLLPICODER2; reg += (channel * DDRIOCCC_CH_OFFSET); mrc_alt_write_mask(DDRPHY, reg, temp, msk); + reg = rank ? ECCB1DLLPICODER3 : ECCB1DLLPICODER3; reg += (channel * DDRIOCCC_CH_OFFSET); mrc_alt_write_mask(DDRPHY, reg, temp, msk); @@ -750,24 +744,24 @@ void set_wclk(uint8_t channel, uint8_t rank, uint32_t pi_count) * CCCFGREG1[11:08] (+1 select) * CCCFGREG1[03:00] (enable) */ - reg = CCCFGREG1 + (channel * DDRIOCCC_CH_OFFSET); + reg = CCCFGREG1 + channel * DDRIOCCC_CH_OFFSET; msk = 0x00; temp = 0x00; /* enable */ - msk |= (BIT3 | BIT2 | BIT1 | BIT0); + msk |= 0xf; if ((pi_count < EARLY_DB) || (pi_count > LATE_DB)) temp |= msk; /* select */ - msk |= (BIT11 | BIT10 | BIT9 | BIT8); + msk |= 0xf00; if (pi_count < EARLY_DB) temp |= msk; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* error check */ - if (pi_count > 0x3F) + if (pi_count > 0x3f) mrc_post_code(0xee, 0xe5); LEAVEFN(); @@ -790,10 +784,10 @@ uint32_t get_wclk(uint8_t channel, uint8_t rank) * CCPTRREG[15:12] -> CLK1 (0x0-0xF) * CCPTRREG[11:08] -> CLK0 (0x0-0xF) */ - reg = CCPTRREG + (channel * DDRIOCCC_CH_OFFSET); + reg = CCPTRREG + channel * DDRIOCCC_CH_OFFSET; temp = msg_port_alt_read(DDRPHY, reg); temp >>= rank ? 12 : 8; - temp &= 0xF; + temp &= 0xf; /* Adjust PI_COUNT */ pi_count = temp * HALF_CLK; @@ -807,7 +801,7 @@ uint32_t get_wclk(uint8_t channel, uint8_t rank) reg += (channel * DDRIOCCC_CH_OFFSET); temp = msg_port_alt_read(DDRPHY, reg); temp >>= rank ? 16 : 8; - temp &= 0x3F; + temp &= 0x3f; pi_count += temp; @@ -835,28 +829,31 @@ void set_wctl(uint8_t channel, uint8_t rank, uint32_t pi_count) * CCPTRREG[31:28] (0x0-0xF) * CCPTRREG[27:24] (0x0-0xF) */ - reg = CCPTRREG + (channel * DDRIOCCC_CH_OFFSET); - msk = (BIT31 | BIT30 | BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | BIT24); + reg = CCPTRREG + channel * DDRIOCCC_CH_OFFSET; + msk = 0xff000000; temp = ((pi_count / HALF_CLK) << 28) | ((pi_count / HALF_CLK) << 24); mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* Adjust PI_COUNT */ - pi_count -= ((pi_count / HALF_CLK) & 0xF) * HALF_CLK; + pi_count -= ((pi_count / HALF_CLK) & 0xf) * HALF_CLK; /* * PI (1/64 MCLK, 1 PIs) * ECCB1DLLPICODER?[29:24] (0x00-0x3F) * ECCB1DLLPICODER?[29:24] (0x00-0x3F) */ - reg = ECCB1DLLPICODER0 + (channel * DDRIOCCC_CH_OFFSET); - msk = (BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | BIT24); + reg = ECCB1DLLPICODER0 + channel * DDRIOCCC_CH_OFFSET; + msk = 0x3f000000; temp = (pi_count << 24); mrc_alt_write_mask(DDRPHY, reg, temp, msk); - reg = ECCB1DLLPICODER1 + (channel * DDRIOCCC_CH_OFFSET); + + reg = ECCB1DLLPICODER1 + channel * DDRIOCCC_CH_OFFSET; mrc_alt_write_mask(DDRPHY, reg, temp, msk); - reg = ECCB1DLLPICODER2 + (channel * DDRIOCCC_CH_OFFSET); + + reg = ECCB1DLLPICODER2 + channel * DDRIOCCC_CH_OFFSET; mrc_alt_write_mask(DDRPHY, reg, temp, msk); - reg = ECCB1DLLPICODER3 + (channel * DDRIOCCC_CH_OFFSET); + + reg = ECCB1DLLPICODER3 + channel * DDRIOCCC_CH_OFFSET; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* @@ -864,24 +861,24 @@ void set_wctl(uint8_t channel, uint8_t rank, uint32_t pi_count) * CCCFGREG1[13:12] (+1 select) * CCCFGREG1[05:04] (enable) */ - reg = CCCFGREG1 + (channel * DDRIOCCC_CH_OFFSET); + reg = CCCFGREG1 + channel * DDRIOCCC_CH_OFFSET; msk = 0x00; temp = 0x00; /* enable */ - msk |= (BIT5 | BIT4); + msk |= 0x30; if ((pi_count < EARLY_DB) || (pi_count > LATE_DB)) temp |= msk; /* select */ - msk |= (BIT13 | BIT12); + msk |= 0x3000; if (pi_count < EARLY_DB) temp |= msk; mrc_alt_write_mask(DDRPHY, reg, temp, msk); /* error check */ - if (pi_count > 0x3F) + if (pi_count > 0x3f) mrc_post_code(0xee, 0xe6); LEAVEFN(); @@ -906,10 +903,10 @@ uint32_t get_wctl(uint8_t channel, uint8_t rank) * CCPTRREG[31:28] (0x0-0xF) * CCPTRREG[27:24] (0x0-0xF) */ - reg = CCPTRREG + (channel * DDRIOCCC_CH_OFFSET); + reg = CCPTRREG + channel * DDRIOCCC_CH_OFFSET; temp = msg_port_alt_read(DDRPHY, reg); temp >>= 24; - temp &= 0xF; + temp &= 0xf; /* Adjust PI_COUNT */ pi_count = temp * HALF_CLK; @@ -919,10 +916,10 @@ uint32_t get_wctl(uint8_t channel, uint8_t rank) * ECCB1DLLPICODER?[29:24] (0x00-0x3F) * ECCB1DLLPICODER?[29:24] (0x00-0x3F) */ - reg = ECCB1DLLPICODER0 + (channel * DDRIOCCC_CH_OFFSET); + reg = ECCB1DLLPICODER0 + channel * DDRIOCCC_CH_OFFSET; temp = msg_port_alt_read(DDRPHY, reg); temp >>= 24; - temp &= 0x3F; + temp &= 0x3f; /* Adjust PI_COUNT */ pi_count += temp; @@ -938,17 +935,16 @@ uint32_t get_wctl(uint8_t channel, uint8_t rank) */ void set_vref(uint8_t channel, uint8_t byte_lane, uint32_t setting) { - uint32_t reg = (byte_lane & 0x1) ? (B1VREFCTL) : (B0VREFCTL); + uint32_t reg = (byte_lane & 0x1) ? B1VREFCTL : B0VREFCTL; ENTERFN(); DPF(D_TRN, "Vref ch%d ln%d : val=%03X\n", channel, byte_lane, setting); - mrc_alt_write_mask(DDRPHY, (reg + (channel * DDRIODQ_CH_OFFSET) + - ((byte_lane >> 1) * DDRIODQ_BL_OFFSET)), - (vref_codes[setting] << 2), - (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)); + mrc_alt_write_mask(DDRPHY, reg + channel * DDRIODQ_CH_OFFSET + + (byte_lane >> 1) * DDRIODQ_BL_OFFSET, + vref_codes[setting] << 2, 0xfc); /* * need to wait ~300ns for Vref to settle @@ -969,15 +965,15 @@ uint32_t get_vref(uint8_t channel, uint8_t byte_lane) { uint8_t j; uint32_t ret_val = sizeof(vref_codes) / 2; - uint32_t reg = (byte_lane & 0x1) ? (B1VREFCTL) : (B0VREFCTL); + uint32_t reg = (byte_lane & 0x1) ? B1VREFCTL : B0VREFCTL; uint32_t temp; ENTERFN(); - temp = msg_port_alt_read(DDRPHY, (reg + (channel * DDRIODQ_CH_OFFSET) + - ((byte_lane >> 1) * DDRIODQ_BL_OFFSET))); + temp = msg_port_alt_read(DDRPHY, reg + channel * DDRIODQ_CH_OFFSET + + (byte_lane >> 1) * DDRIODQ_BL_OFFSET); temp >>= 2; - temp &= 0x3F; + temp &= 0x3f; for (j = 0; j < sizeof(vref_codes); j++) { if (vref_codes[j] == temp) { @@ -997,7 +993,7 @@ uint32_t get_vref(uint8_t channel, uint8_t byte_lane) */ uint32_t get_addr(uint8_t channel, uint8_t rank) { - uint32_t offset = 0x02000000; /* 32MB */ + uint32_t offset = 32 * 1024 * 1024; /* 32MB */ /* Begin product specific code */ if (channel > 0) { @@ -1040,8 +1036,8 @@ uint32_t sample_dqs(struct mrc_params *mrc_params, uint8_t channel, uint32_t address = get_addr(channel, rank); /* initialise msk[] */ - msk[0] = rcvn ? BIT1 : BIT9; /* BL0 */ - msk[1] = rcvn ? BIT0 : BIT8; /* BL1 */ + msk[0] = rcvn ? (1 << 1) : (1 << 9); /* BL0 */ + msk[1] = rcvn ? (1 << 0) : (1 << 8); /* BL1 */ /* cycle through each byte lane group */ for (bl_grp = 0; bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2; bl_grp++) { @@ -1056,9 +1052,9 @@ uint32_t sample_dqs(struct mrc_params *mrc_params, uint8_t channel, * DQTRAINSTS register */ sampled_val[j] = msg_port_alt_read(DDRPHY, - (DQTRAINSTS + - (bl_grp * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET))); + DQTRAINSTS + + bl_grp * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET); } /* @@ -1076,7 +1072,7 @@ uint32_t sample_dqs(struct mrc_params *mrc_params, uint8_t channel, num_0s++; } if (num_1s > num_0s) - ret_val |= (1 << (bl + (bl_grp * 2))); + ret_val |= (1 << (bl + bl_grp * 2)); } } @@ -1116,10 +1112,10 @@ void find_rising_edge(struct mrc_params *mrc_params, uint32_t delay[], /* increase sample delay by 26 PI (0.2 CLK) */ if (rcvn) { set_rcvn(channel, rank, bl, - delay[bl] + (sample * SAMPLE_DLY)); + delay[bl] + sample * SAMPLE_DLY); } else { set_wdqs(channel, rank, bl, - delay[bl] + (sample * SAMPLE_DLY)); + delay[bl] + sample * SAMPLE_DLY); } } @@ -1129,7 +1125,7 @@ void find_rising_edge(struct mrc_params *mrc_params, uint32_t delay[], DPF(D_TRN, "Find rising edge %s ch%d rnk%d: #%d dly=%d dqs=%02X\n", - (rcvn ? "RCVN" : "WDQS"), channel, rank, sample, + rcvn ? "RCVN" : "WDQS", channel, rank, sample, sample * SAMPLE_DLY, sample_result[sample]); } @@ -1137,7 +1133,7 @@ void find_rising_edge(struct mrc_params *mrc_params, uint32_t delay[], * This pattern will help determine where we landed and ultimately * how to place RCVEN/WDQS. */ - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { /* build transition_pattern (MSB is 1st sample) */ transition_pattern = 0; for (sample = 0; sample < SAMPLE_CNT; sample++) { @@ -1202,7 +1198,7 @@ void find_rising_edge(struct mrc_params *mrc_params, uint32_t delay[], /* take a sample */ temp = sample_dqs(mrc_params, channel, rank, rcvn); /* check all each byte lane for proper edge */ - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { if (temp & (1 << bl)) { /* sampled "1" */ if (direction[bl] == BACKWARD) { @@ -1340,10 +1336,10 @@ void lfsr32(uint32_t *lfsr_ptr) lfsr = *lfsr_ptr; for (i = 0; i < 32; i++) { - bit = 1 ^ (lfsr & BIT0); - bit = bit ^ ((lfsr & BIT1) >> 1); - bit = bit ^ ((lfsr & BIT2) >> 2); - bit = bit ^ ((lfsr & BIT22) >> 22); + bit = 1 ^ (lfsr & 1); + bit = bit ^ ((lfsr & 2) >> 1); + bit = bit ^ ((lfsr & 4) >> 2); + bit = bit ^ ((lfsr & 0x400000) >> 22); lfsr = ((lfsr >> 1) | (bit << 31)); } @@ -1362,16 +1358,16 @@ void clear_pointers(void) for (channel = 0; channel < NUM_CHANNELS; channel++) { for (bl = 0; bl < NUM_BYTE_LANES; bl++) { mrc_alt_write_mask(DDRPHY, - (B01PTRCTL1 + - (channel * DDRIODQ_CH_OFFSET) + - ((bl >> 1) * DDRIODQ_BL_OFFSET)), - ~BIT8, BIT8); + B01PTRCTL1 + + channel * DDRIODQ_CH_OFFSET + + (bl >> 1) * DDRIODQ_BL_OFFSET, + ~(1 << 8), (1 << 8)); mrc_alt_write_mask(DDRPHY, - (B01PTRCTL1 + - (channel * DDRIODQ_CH_OFFSET) + - ((bl >> 1) * DDRIODQ_BL_OFFSET)), - BIT8, BIT8); + B01PTRCTL1 + + channel * DDRIODQ_CH_OFFSET + + (bl >> 1) * DDRIODQ_BL_OFFSET, + (1 << 8), (1 << 8)); } } @@ -1412,7 +1408,7 @@ static void print_timings_internal(uint8_t algo, uint8_t channel, uint8_t rank, break; } - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { switch (algo) { case RCVN: DPF(D_INFO, " %03d", get_rcvn(channel, rank, bl)); diff --git a/arch/x86/cpu/quark/mrc_util.h b/arch/x86/cpu/quark/mrc_util.h index f0ddbce..a63d1f9 100644 --- a/arch/x86/cpu/quark/mrc_util.h +++ b/arch/x86/cpu/quark/mrc_util.h @@ -41,40 +41,6 @@ #define LEAVEFN(...) debug_cond(D_FCALL, "\n", __func__) #define REPORTFN(...) debug_cond(D_FCALL, "<%s/>\n", __func__) -/* Generic Register Bits */ -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 - /* Message Bus Port */ #define MEM_CTLR 0x01 #define HOST_BRIDGE 0x03 diff --git a/arch/x86/cpu/quark/smc.c b/arch/x86/cpu/quark/smc.c index e34bec4..3ffe92b 100644 --- a/arch/x86/cpu/quark/smc.c +++ b/arch/x86/cpu/quark/smc.c @@ -60,7 +60,7 @@ void clear_self_refresh(struct mrc_params *mrc_params) ENTERFN(); /* clear the PMSTS Channel Self Refresh bits */ - mrc_write_mask(MEM_CTLR, PMSTS, BIT0, BIT0); + mrc_write_mask(MEM_CTLR, PMSTS, PMSTS_DISR, PMSTS_DISR); LEAVEFN(); } @@ -101,47 +101,47 @@ void prog_ddr_timing_control(struct mrc_params *mrc_params) wl = 5 + mrc_params->ddr_speed; - dtr0 &= ~(BIT0 | BIT1); + dtr0 &= ~DTR0_DFREQ_MASK; dtr0 |= mrc_params->ddr_speed; - dtr0 &= ~(BIT12 | BIT13 | BIT14); + dtr0 &= ~DTR0_TCL_MASK; tmp1 = tcl - 5; dtr0 |= ((tcl - 5) << 12); - dtr0 &= ~(BIT4 | BIT5 | BIT6 | BIT7); + dtr0 &= ~DTR0_TRP_MASK; dtr0 |= ((trp - 5) << 4); /* 5 bit DRAM Clock */ - dtr0 &= ~(BIT8 | BIT9 | BIT10 | BIT11); + dtr0 &= ~DTR0_TRCD_MASK; dtr0 |= ((trcd - 5) << 8); /* 5 bit DRAM Clock */ - dtr1 &= ~(BIT0 | BIT1 | BIT2); + dtr1 &= ~DTR1_TWCL_MASK; tmp2 = wl - 3; dtr1 |= (wl - 3); - dtr1 &= ~(BIT8 | BIT9 | BIT10 | BIT11); + dtr1 &= ~DTR1_TWTP_MASK; dtr1 |= ((wl + 4 + twr - 14) << 8); /* Change to tWTP */ - dtr1 &= ~(BIT28 | BIT29 | BIT30); + dtr1 &= ~DTR1_TRTP_MASK; dtr1 |= ((MMAX(trtp, 4) - 3) << 28); /* 4 bit DRAM Clock */ - dtr1 &= ~(BIT24 | BIT25); + dtr1 &= ~DTR1_TRRD_MASK; dtr1 |= ((trrd - 4) << 24); /* 4 bit DRAM Clock */ - dtr1 &= ~(BIT4 | BIT5); + dtr1 &= ~DTR1_TCMD_MASK; dtr1 |= (1 << 4); - dtr1 &= ~(BIT20 | BIT21 | BIT22 | BIT23); + dtr1 &= ~DTR1_TRAS_MASK; dtr1 |= ((tras - 14) << 20); /* 6 bit DRAM Clock */ - dtr1 &= ~(BIT16 | BIT17 | BIT18 | BIT19); + dtr1 &= ~DTR1_TFAW_MASK; dtr1 |= ((((tfaw + 1) >> 1) - 5) << 16);/* 4 bit DRAM Clock */ /* Set 4 Clock CAS to CAS delay (multi-burst) */ - dtr1 &= ~(BIT12 | BIT13); + dtr1 &= ~DTR1_TCCD_MASK; - dtr2 &= ~(BIT0 | BIT1 | BIT2); + dtr2 &= ~DTR2_TRRDR_MASK; dtr2 |= 1; - dtr2 &= ~(BIT8 | BIT9 | BIT10); + dtr2 &= ~DTR2_TWWDR_MASK; dtr2 |= (2 << 8); - dtr2 &= ~(BIT16 | BIT17 | BIT18 | BIT19); + dtr2 &= ~DTR2_TRWDR_MASK; dtr2 |= (2 << 16); - dtr3 &= ~(BIT0 | BIT1 | BIT2); + dtr3 &= ~DTR3_TWRDR_MASK; dtr3 |= 2; - dtr3 &= ~(BIT4 | BIT5 | BIT6); + dtr3 &= ~DTR3_TXXXX_MASK; dtr3 |= (2 << 4); - dtr3 &= ~(BIT8 | BIT9 | BIT10 | BIT11); + dtr3 &= ~DTR3_TRWSR_MASK; if (mrc_params->ddr_speed == DDRFREQ_800) { /* Extended RW delay (+1) */ dtr3 |= ((tcl - 5 + 1) << 8); @@ -150,24 +150,24 @@ void prog_ddr_timing_control(struct mrc_params *mrc_params) dtr3 |= ((tcl - 5 + 1) << 8); } - dtr3 &= ~(BIT13 | BIT14 | BIT15 | BIT16); + dtr3 &= ~DTR3_TWRSR_MASK; dtr3 |= ((4 + wl + twtr - 11) << 13); - dtr3 &= ~(BIT22 | BIT23); + dtr3 &= ~DTR3_TXP_MASK; if (mrc_params->ddr_speed == DDRFREQ_800) dtr3 |= ((MMAX(0, 1 - 1)) << 22); else dtr3 |= ((MMAX(0, 2 - 1)) << 22); - dtr4 &= ~(BIT0 | BIT1); + dtr4 &= ~DTR4_WRODTSTRT_MASK; dtr4 |= 1; - dtr4 &= ~(BIT4 | BIT5 | BIT6); + dtr4 &= ~DTR4_WRODTSTOP_MASK; dtr4 |= (1 << 4); - dtr4 &= ~(BIT8 | BIT9 | BIT10); + dtr4 &= ~DTR4_XXXX1_MASK; dtr4 |= ((1 + tmp1 - tmp2 + 2) << 8); - dtr4 &= ~(BIT12 | BIT13 | BIT14); + dtr4 &= ~DTR4_XXXX2_MASK; dtr4 |= ((1 + tmp1 - tmp2 + 2) << 12); - dtr4 &= ~(BIT15 | BIT16); + dtr4 &= ~(DTR4_ODTDIS | DTR4_TRGSTRDIS); msg_port_write(MEM_CTLR, DTR0, dtr0); msg_port_write(MEM_CTLR, DTR1, dtr1); @@ -191,25 +191,25 @@ void prog_decode_before_jedec(struct mrc_params *mrc_params) /* Disable power saving features */ dpmc0 = msg_port_read(MEM_CTLR, DPMC0); - dpmc0 |= (BIT24 | BIT25); - dpmc0 &= ~(BIT16 | BIT17 | BIT18); - dpmc0 &= ~BIT23; + dpmc0 |= (DPMC0_CLKGTDIS | DPMC0_DISPWRDN); + dpmc0 &= ~DPMC0_PCLSTO_MASK; + dpmc0 &= ~DPMC0_DYNSREN; msg_port_write(MEM_CTLR, DPMC0, dpmc0); /* Disable out of order transactions */ dsch = msg_port_read(MEM_CTLR, DSCH); - dsch |= (BIT8 | BIT12); + dsch |= (DSCH_OOODIS | DSCH_NEWBYPDIS); msg_port_write(MEM_CTLR, DSCH, dsch); /* Disable issuing the REF command */ drfc = msg_port_read(MEM_CTLR, DRFC); - drfc &= ~(BIT12 | BIT13 | BIT14); + drfc &= ~DRFC_TREFI_MASK; msg_port_write(MEM_CTLR, DRFC, drfc); /* Disable ZQ calibration short */ dcal = msg_port_read(MEM_CTLR, DCAL); - dcal &= ~(BIT8 | BIT9 | BIT10); - dcal &= ~(BIT12 | BIT13); + dcal &= ~DCAL_ZQCINT_MASK; + dcal &= ~DCAL_SRXZQCL_MASK; msg_port_write(MEM_CTLR, DCAL, dcal); /* @@ -218,9 +218,9 @@ void prog_decode_before_jedec(struct mrc_params *mrc_params) */ drp = 0; if (mrc_params->rank_enables & 1) - drp |= BIT0; + drp |= DRP_RKEN0; if (mrc_params->rank_enables & 2) - drp |= BIT1; + drp |= DRP_RKEN1; msg_port_write(MEM_CTLR, DRP, drp); LEAVEFN(); @@ -238,14 +238,14 @@ void perform_ddr_reset(struct mrc_params *mrc_params) ENTERFN(); /* Set COLDWAKE bit before sending the WAKE message */ - mrc_write_mask(MEM_CTLR, DRMC, BIT16, BIT16); + mrc_write_mask(MEM_CTLR, DRMC, DRMC_COLDWAKE, DRMC_COLDWAKE); /* Send wake command to DUNIT (MUST be done before JEDEC) */ dram_wake_command(); /* Set default value */ msg_port_write(MEM_CTLR, DRMC, - (mrc_params->rd_odt_value == 0 ? BIT12 : 0)); + mrc_params->rd_odt_value == 0 ? DRMC_ODTMODE : 0); LEAVEFN(); } @@ -263,7 +263,7 @@ void ddrphy_init(struct mrc_params *mrc_params) uint8_t bl_grp; /* byte lane group counter (2 BLs per module) */ uint8_t bl_divisor = 1; /* byte lane divisor */ /* For DDR3 --> 0 == 800, 1 == 1066, 2 == 1333 */ - uint8_t speed = mrc_params->ddr_speed & (BIT1 | BIT0); + uint8_t speed = mrc_params->ddr_speed & 3; uint8_t cas; uint8_t cwl; @@ -286,21 +286,21 @@ void ddrphy_init(struct mrc_params *mrc_params) if (mrc_params->channel_enables & (1 << ch)) { /* Deassert DDRPHY Initialization Complete */ mrc_alt_write_mask(DDRPHY, - (CMDPMCONFIG0 + (ch * DDRIOCCC_CH_OFFSET)), - ~BIT20, BIT20); /* SPID_INIT_COMPLETE=0 */ + CMDPMCONFIG0 + ch * DDRIOCCC_CH_OFFSET, + ~(1 << 20), 1 << 20); /* SPID_INIT_COMPLETE=0 */ /* Deassert IOBUFACT */ mrc_alt_write_mask(DDRPHY, - (CMDCFGREG0 + (ch * DDRIOCCC_CH_OFFSET)), - ~BIT2, BIT2); /* IOBUFACTRST_N=0 */ + CMDCFGREG0 + ch * DDRIOCCC_CH_OFFSET, + ~(1 << 2), 1 << 2); /* IOBUFACTRST_N=0 */ /* Disable WRPTR */ mrc_alt_write_mask(DDRPHY, - (CMDPTRREG + (ch * DDRIOCCC_CH_OFFSET)), - ~BIT0, BIT0); /* WRPTRENABLE=0 */ + CMDPTRREG + ch * DDRIOCCC_CH_OFFSET, + ~(1 << 0), 1 << 0); /* WRPTRENABLE=0 */ } } /* Put PHY in reset */ - mrc_alt_write_mask(DDRPHY, MASTERRSTN, 0, BIT0); + mrc_alt_write_mask(DDRPHY, MASTERRSTN, 0, 1); /* Initialize DQ01, DQ23, CMD, CLK-CTL, COMP modules */ @@ -310,14 +310,14 @@ void ddrphy_init(struct mrc_params *mrc_params) if (mrc_params->channel_enables & (1 << ch)) { /* DQ01-DQ23 */ for (bl_grp = 0; - bl_grp < ((NUM_BYTE_LANES / bl_divisor) / 2); + bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2; bl_grp++) { /* Analog MUX select - IO2xCLKSEL */ mrc_alt_write_mask(DDRPHY, - (DQOBSCKEBBCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - ((bl_grp) ? (0x00) : (BIT22)), (BIT22)); + DQOBSCKEBBCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + bl_grp ? 0 : (1 << 22), 1 << 22); /* ODT Strength */ switch (mrc_params->rd_odt_value) { @@ -337,20 +337,20 @@ void ddrphy_init(struct mrc_params *mrc_params) /* ODT strength */ mrc_alt_write_mask(DDRPHY, - (B0RXIOBUFCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (temp << 5), (BIT6 | BIT5)); + B0RXIOBUFCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + temp << 5, 0x60); /* ODT strength */ mrc_alt_write_mask(DDRPHY, - (B1RXIOBUFCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (temp << 5), (BIT6 | BIT5)); + B1RXIOBUFCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + temp << 5, 0x60); /* Dynamic ODT/DIFFAMP */ - temp = (((cas) << 24) | ((cas) << 16) | - ((cas) << 8) | ((cas) << 0)); + temp = (cas << 24) | (cas << 16) | + (cas << 8) | (cas << 0); switch (speed) { case 0: temp -= 0x01010101; @@ -368,247 +368,199 @@ void ddrphy_init(struct mrc_params *mrc_params) /* Launch Time: ODT, DIFFAMP, ODT, DIFFAMP */ mrc_alt_write_mask(DDRPHY, - (B01LATCTL1 + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - temp, - (BIT28 | BIT27 | BIT26 | BIT25 | BIT24 | - BIT20 | BIT19 | BIT18 | BIT17 | BIT16 | - BIT12 | BIT11 | BIT10 | BIT9 | BIT8 | - BIT4 | BIT3 | BIT2 | BIT1 | BIT0)); + B01LATCTL1 + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + temp, 0x1f1f1f1f); switch (speed) { /* HSD#234715 */ case 0: - temp = ((0x06 << 16) | (0x07 << 8)); + temp = (0x06 << 16) | (0x07 << 8); break; /* 800 */ case 1: - temp = ((0x07 << 16) | (0x08 << 8)); + temp = (0x07 << 16) | (0x08 << 8); break; /* 1066 */ case 2: - temp = ((0x09 << 16) | (0x0A << 8)); + temp = (0x09 << 16) | (0x0a << 8); break; /* 1333 */ case 3: - temp = ((0x0A << 16) | (0x0B << 8)); + temp = (0x0a << 16) | (0x0b << 8); break; /* 1600 */ } /* On Duration: ODT, DIFFAMP */ mrc_alt_write_mask(DDRPHY, - (B0ONDURCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - temp, - (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | - BIT16 | BIT13 | BIT12 | BIT11 | BIT10 | - BIT9 | BIT8)); + B0ONDURCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + temp, 0x003f3f00); /* On Duration: ODT, DIFFAMP */ mrc_alt_write_mask(DDRPHY, - (B1ONDURCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - temp, - (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | - BIT16 | BIT13 | BIT12 | BIT11 | BIT10 | - BIT9 | BIT8)); + B1ONDURCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + temp, 0x003f3f00); switch (mrc_params->rd_odt_value) { case 0: /* override DIFFAMP=on, ODT=off */ - temp = ((0x3F << 16) | (0x3f << 10)); + temp = (0x3f << 16) | (0x3f << 10); break; default: /* override DIFFAMP=on, ODT=on */ - temp = ((0x3F << 16) | (0x2A << 10)); + temp = (0x3f << 16) | (0x2a << 10); break; } /* Override: DIFFAMP, ODT */ mrc_alt_write_mask(DDRPHY, - (B0OVRCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - temp, - (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | - BIT16 | BIT15 | BIT14 | BIT13 | BIT12 | - BIT11 | BIT10)); + B0OVRCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + temp, 0x003ffc00); /* Override: DIFFAMP, ODT */ mrc_alt_write_mask(DDRPHY, - (B1OVRCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - temp, - (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | - BIT16 | BIT15 | BIT14 | BIT13 | BIT12 | - BIT11 | BIT10)); + B1OVRCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + temp, 0x003ffc00); /* DLL Setup */ /* 1xCLK Domain Timings: tEDP,RCVEN,WDQS (PO) */ mrc_alt_write_mask(DDRPHY, - (B0LATCTL0 + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (((cas + 7) << 16) | ((cas - 4) << 8) | - ((cwl - 2) << 0)), - (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | - BIT16 | BIT12 | BIT11 | BIT10 | BIT9 | - BIT8 | BIT4 | BIT3 | BIT2 | BIT1 | - BIT0)); + B0LATCTL0 + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + ((cas + 7) << 16) | ((cas - 4) << 8) | + ((cwl - 2) << 0), 0x003f1f1f); mrc_alt_write_mask(DDRPHY, - (B1LATCTL0 + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (((cas + 7) << 16) | ((cas - 4) << 8) | - ((cwl - 2) << 0)), - (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | - BIT16 | BIT12 | BIT11 | BIT10 | BIT9 | - BIT8 | BIT4 | BIT3 | BIT2 | BIT1 | - BIT0)); + B1LATCTL0 + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + ((cas + 7) << 16) | ((cas - 4) << 8) | + ((cwl - 2) << 0), 0x003f1f1f); /* RCVEN Bypass (PO) */ mrc_alt_write_mask(DDRPHY, - (B0RXIOBUFCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - ((0x0 << 7) | (0x0 << 0)), - (BIT7 | BIT0)); + B0RXIOBUFCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 0, 0x81); mrc_alt_write_mask(DDRPHY, - (B1RXIOBUFCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - ((0x0 << 7) | (0x0 << 0)), - (BIT7 | BIT0)); + B1RXIOBUFCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 0, 0x81); /* TX */ mrc_alt_write_mask(DDRPHY, - (DQCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (BIT16), (BIT16)); + DQCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 1 << 16, 1 << 16); mrc_alt_write_mask(DDRPHY, - (B01PTRCTL1 + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (BIT8), (BIT8)); + B01PTRCTL1 + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 1 << 8, 1 << 8); /* RX (PO) */ /* Internal Vref Code, Enable#, Ext_or_Int (1=Ext) */ mrc_alt_write_mask(DDRPHY, - (B0VREFCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - ((0x03 << 2) | (0x0 << 1) | (0x0 << 0)), - (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | - BIT2 | BIT1 | BIT0)); + B0VREFCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + (0x03 << 2) | (0x0 << 1) | (0x0 << 0), + 0xff); /* Internal Vref Code, Enable#, Ext_or_Int (1=Ext) */ mrc_alt_write_mask(DDRPHY, - (B1VREFCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - ((0x03 << 2) | (0x0 << 1) | (0x0 << 0)), - (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | - BIT2 | BIT1 | BIT0)); + B1VREFCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + (0x03 << 2) | (0x0 << 1) | (0x0 << 0), + 0xff); /* Per-Bit De-Skew Enable */ mrc_alt_write_mask(DDRPHY, - (B0RXIOBUFCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (0), (BIT4)); + B0RXIOBUFCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 0, 0x10); /* Per-Bit De-Skew Enable */ mrc_alt_write_mask(DDRPHY, - (B1RXIOBUFCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (0), (BIT4)); + B1RXIOBUFCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 0, 0x10); } /* CLKEBB */ mrc_alt_write_mask(DDRPHY, - (CMDOBSCKEBBCTL + (ch * DDRIOCCC_CH_OFFSET)), - 0, (BIT23)); + CMDOBSCKEBBCTL + ch * DDRIOCCC_CH_OFFSET, + 0, 1 << 23); /* Enable tristate control of cmd/address bus */ mrc_alt_write_mask(DDRPHY, - (CMDCFGREG0 + (ch * DDRIOCCC_CH_OFFSET)), - 0, (BIT1 | BIT0)); + CMDCFGREG0 + ch * DDRIOCCC_CH_OFFSET, + 0, 0x03); /* ODT RCOMP */ mrc_alt_write_mask(DDRPHY, - (CMDRCOMPODT + (ch * DDRIOCCC_CH_OFFSET)), - ((0x03 << 5) | (0x03 << 0)), - (BIT9 | BIT8 | BIT7 | BIT6 | BIT5 | BIT4 | - BIT3 | BIT2 | BIT1 | BIT0)); + CMDRCOMPODT + ch * DDRIOCCC_CH_OFFSET, + (0x03 << 5) | (0x03 << 0), 0x3ff); /* CMDPM* registers must be programmed in this order */ /* Turn On Delays: SFR (regulator), MPLL */ mrc_alt_write_mask(DDRPHY, - (CMDPMDLYREG4 + (ch * DDRIOCCC_CH_OFFSET)), - ((0xFFFFU << 16) | (0xFFFF << 0)), - 0xFFFFFFFF); + CMDPMDLYREG4 + ch * DDRIOCCC_CH_OFFSET, + 0xffffffff, 0xffffffff); /* * Delays: ASSERT_IOBUFACT_to_ALLON0_for_PM_MSG_3, * VREG (MDLL) Turn On, ALLON0_to_DEASSERT_IOBUFACT * for_PM_MSG_gt0, MDLL Turn On */ mrc_alt_write_mask(DDRPHY, - (CMDPMDLYREG3 + (ch * DDRIOCCC_CH_OFFSET)), - ((0xFU << 28) | (0xFFF << 16) | (0xF << 12) | - (0x616 << 0)), 0xFFFFFFFF); + CMDPMDLYREG3 + ch * DDRIOCCC_CH_OFFSET, + 0xfffff616, 0xffffffff); /* MPLL Divider Reset Delays */ mrc_alt_write_mask(DDRPHY, - (CMDPMDLYREG2 + (ch * DDRIOCCC_CH_OFFSET)), - ((0xFFU << 24) | (0xFF << 16) | (0xFF << 8) | - (0xFF << 0)), 0xFFFFFFFF); + CMDPMDLYREG2 + ch * DDRIOCCC_CH_OFFSET, + 0xffffffff, 0xffffffff); /* Turn Off Delays: VREG, Staggered MDLL, MDLL, PI */ mrc_alt_write_mask(DDRPHY, - (CMDPMDLYREG1 + (ch * DDRIOCCC_CH_OFFSET)), - ((0xFFU << 24) | (0xFF << 16) | (0xFF << 8) | - (0xFF << 0)), 0xFFFFFFFF); + CMDPMDLYREG1 + ch * DDRIOCCC_CH_OFFSET, + 0xffffffff, 0xffffffff); /* Turn On Delays: MPLL, Staggered MDLL, PI, IOBUFACT */ mrc_alt_write_mask(DDRPHY, - (CMDPMDLYREG0 + (ch * DDRIOCCC_CH_OFFSET)), - ((0xFFU << 24) | (0xFF << 16) | (0xFF << 8) | - (0xFF << 0)), 0xFFFFFFFF); + CMDPMDLYREG0 + ch * DDRIOCCC_CH_OFFSET, + 0xffffffff, 0xffffffff); /* Allow PUnit signals */ mrc_alt_write_mask(DDRPHY, - (CMDPMCONFIG0 + (ch * DDRIOCCC_CH_OFFSET)), - ((0x6 << 8) | BIT6 | (0x4 << 0)), - (BIT31 | BIT30 | BIT29 | BIT28 | BIT27 | BIT26 | - BIT25 | BIT24 | BIT23 | BIT22 | BIT21 | BIT11 | - BIT10 | BIT9 | BIT8 | BIT6 | BIT3 | BIT2 | - BIT1 | BIT0)); + CMDPMCONFIG0 + ch * DDRIOCCC_CH_OFFSET, + (0x6 << 8) | (0x1 << 6) | (0x4 << 0), + 0xffe00f4f); /* DLL_VREG Bias Trim, VREF Tuning for DLL_VREG */ mrc_alt_write_mask(DDRPHY, - (CMDMDLLCTL + (ch * DDRIOCCC_CH_OFFSET)), - ((0x3 << 4) | (0x7 << 0)), - (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | - BIT0)); + CMDMDLLCTL + ch * DDRIOCCC_CH_OFFSET, + (0x3 << 4) | (0x7 << 0), 0x7f); /* CLK-CTL */ mrc_alt_write_mask(DDRPHY, - (CCOBSCKEBBCTL + (ch * DDRIOCCC_CH_OFFSET)), - 0, BIT24); /* CLKEBB */ + CCOBSCKEBBCTL + ch * DDRIOCCC_CH_OFFSET, + 0, 1 << 24); /* CLKEBB */ /* Buffer Enable: CS,CKE,ODT,CLK */ mrc_alt_write_mask(DDRPHY, - (CCCFGREG0 + (ch * DDRIOCCC_CH_OFFSET)), - ((0x0 << 16) | (0x0 << 12) | (0x0 << 8) | - (0xF << 4) | BIT0), - (BIT19 | BIT18 | BIT17 | BIT16 | BIT15 | BIT14 | - BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8 | - BIT7 | BIT6 | BIT5 | BIT4 | BIT0)); + CCCFGREG0 + ch * DDRIOCCC_CH_OFFSET, + 0x1f, 0x000ffff1); /* ODT RCOMP */ mrc_alt_write_mask(DDRPHY, - (CCRCOMPODT + (ch * DDRIOCCC_CH_OFFSET)), - ((0x03 << 8) | (0x03 << 0)), - (BIT12 | BIT11 | BIT10 | BIT9 | BIT8 | BIT4 | - BIT3 | BIT2 | BIT1 | BIT0)); + CCRCOMPODT + ch * DDRIOCCC_CH_OFFSET, + (0x03 << 8) | (0x03 << 0), 0x00001f1f); /* DLL_VREG Bias Trim, VREF Tuning for DLL_VREG */ mrc_alt_write_mask(DDRPHY, - (CCMDLLCTL + (ch * DDRIOCCC_CH_OFFSET)), - ((0x3 << 4) | (0x7 << 0)), - (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | - BIT0)); + CCMDLLCTL + ch * DDRIOCCC_CH_OFFSET, + (0x3 << 4) | (0x7 << 0), 0x7f); /* * COMP (RON channel specific) @@ -618,66 +570,43 @@ void ddrphy_init(struct mrc_params *mrc_params) */ /* RCOMP Vref PU/PD */ mrc_alt_write_mask(DDRPHY, - (DQVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x08 << 24) | (0x03 << 16)), - (BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | - BIT24 | BIT21 | BIT20 | BIT19 | BIT18 | - BIT17 | BIT16)); + DQVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x08 << 24) | (0x03 << 16), 0x3f3f0000); /* RCOMP Vref PU/PD */ mrc_alt_write_mask(DDRPHY, - (CMDVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x0C << 24) | (0x03 << 16)), - (BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | - BIT24 | BIT21 | BIT20 | BIT19 | BIT18 | - BIT17 | BIT16)); + CMDVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x0C << 24) | (0x03 << 16), 0x3f3f0000); /* RCOMP Vref PU/PD */ mrc_alt_write_mask(DDRPHY, - (CLKVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x0F << 24) | (0x03 << 16)), - (BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | - BIT24 | BIT21 | BIT20 | BIT19 | BIT18 | - BIT17 | BIT16)); + CLKVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x0F << 24) | (0x03 << 16), 0x3f3f0000); /* RCOMP Vref PU/PD */ mrc_alt_write_mask(DDRPHY, - (DQSVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x08 << 24) | (0x03 << 16)), - (BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | - BIT24 | BIT21 | BIT20 | BIT19 | BIT18 | - BIT17 | BIT16)); + DQSVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x08 << 24) | (0x03 << 16), 0x3f3f0000); /* RCOMP Vref PU/PD */ mrc_alt_write_mask(DDRPHY, - (CTLVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x0C << 24) | (0x03 << 16)), - (BIT29 | BIT28 | BIT27 | BIT26 | BIT25 | - BIT24 | BIT21 | BIT20 | BIT19 | BIT18 | - BIT17 | BIT16)); + CTLVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x0C << 24) | (0x03 << 16), 0x3f3f0000); /* DQS Swapped Input Enable */ mrc_alt_write_mask(DDRPHY, - (COMPEN1CH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT19 | BIT17), - (BIT31 | BIT30 | BIT19 | BIT17 | - BIT15 | BIT14)); + COMPEN1CH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 19) | (1 << 17), 0xc00ac000); /* ODT VREF = 1.5 x 274/360+274 = 0.65V (code of ~50) */ /* ODT Vref PU/PD */ mrc_alt_write_mask(DDRPHY, - (DQVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x32 << 8) | (0x03 << 0)), - (BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8 | - BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)); + DQVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x32 << 8) | (0x03 << 0), 0x00003f3f); /* ODT Vref PU/PD */ mrc_alt_write_mask(DDRPHY, - (DQSVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x32 << 8) | (0x03 << 0)), - (BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8 | - BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)); + DQSVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x32 << 8) | (0x03 << 0), 0x00003f3f); /* ODT Vref PU/PD */ mrc_alt_write_mask(DDRPHY, - (CLKVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x0E << 8) | (0x05 << 0)), - (BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8 | - BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)); + CLKVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x0E << 8) | (0x05 << 0), 0x00003f3f); /* * Slew rate settings are frequency specific, @@ -685,273 +614,227 @@ void ddrphy_init(struct mrc_params *mrc_params) * - DQ/DQS/DM/CLK SR: 4V/ns, * - CTRL/CMD SR: 1.5V/ns */ - temp = (0x0E << 16) | (0x0E << 12) | (0x08 << 8) | - (0x0B << 4) | (0x0B << 0); + temp = (0x0e << 16) | (0x0e << 12) | (0x08 << 8) | + (0x0b << 4) | (0x0b << 0); /* DCOMP Delay Select: CTL,CMD,CLK,DQS,DQ */ mrc_alt_write_mask(DDRPHY, - (DLYSELCH0 + (ch * DDRCOMP_CH_OFFSET)), - temp, - (BIT19 | BIT18 | BIT17 | BIT16 | BIT15 | - BIT14 | BIT13 | BIT12 | BIT11 | BIT10 | - BIT9 | BIT8 | BIT7 | BIT6 | BIT5 | BIT4 | - BIT3 | BIT2 | BIT1 | BIT0)); + DLYSELCH0 + ch * DDRCOMP_CH_OFFSET, + temp, 0x000fffff); /* TCO Vref CLK,DQS,DQ */ mrc_alt_write_mask(DDRPHY, - (TCOVREFCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x05 << 16) | (0x05 << 8) | (0x05 << 0)), - (BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | - BIT16 | BIT13 | BIT12 | BIT11 | BIT10 | - BIT9 | BIT8 | BIT5 | BIT4 | BIT3 | BIT2 | - BIT1 | BIT0)); + TCOVREFCH0 + ch * DDRCOMP_CH_OFFSET, + (0x05 << 16) | (0x05 << 8) | (0x05 << 0), + 0x003f3f3f); /* ODTCOMP CMD/CTL PU/PD */ mrc_alt_write_mask(DDRPHY, - (CCBUFODTCH0 + (ch * DDRCOMP_CH_OFFSET)), - ((0x03 << 8) | (0x03 << 0)), - (BIT12 | BIT11 | BIT10 | BIT9 | BIT8 | - BIT4 | BIT3 | BIT2 | BIT1 | BIT0)); + CCBUFODTCH0 + ch * DDRCOMP_CH_OFFSET, + (0x03 << 8) | (0x03 << 0), + 0x00001f1f); /* COMP */ mrc_alt_write_mask(DDRPHY, - (COMPEN0CH0 + (ch * DDRCOMP_CH_OFFSET)), - 0, (BIT31 | BIT30 | BIT8)); + COMPEN0CH0 + ch * DDRCOMP_CH_OFFSET, + 0, 0xc0000100); #ifdef BACKUP_COMPS /* DQ COMP Overrides */ /* RCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQDRVPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0A << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0a << 16), + 0x801f0000); /* RCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQDRVPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0A << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0a << 16), + 0x801f0000); /* DCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQDLYPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x10 << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x10 << 16), + 0x801f0000); /* DCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQDLYPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x10 << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x10 << 16), + 0x801f0000); /* ODTCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQODTPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQODTPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0b << 16), + 0x801f0000); /* ODTCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQODTPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQODTPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0b << 16), + 0x801f0000); /* TCOCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQTCOPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31), (BIT31)); + DQTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + 1 << 31, 1 << 31); /* TCOCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQTCOPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31), (BIT31)); + DQTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + 1 << 31, 1 << 31); /* DQS COMP Overrides */ /* RCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQSDRVPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0A << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQSDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0a << 16), + 0x801f0000); /* RCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQSDRVPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0A << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQSDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0a << 16), + 0x801f0000); /* DCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQSDLYPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x10 << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQSDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x10 << 16), + 0x801f0000); /* DCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQSDLYPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x10 << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQSDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x10 << 16), + 0x801f0000); /* ODTCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQSODTPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQSODTPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0b << 16), + 0x801f0000); /* ODTCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQSODTPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQSODTPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0b << 16), + 0x801f0000); /* TCOCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQSTCOPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31), (BIT31)); + DQSTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + 1 << 31, 1 << 31); /* TCOCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQSTCOPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31), (BIT31)); + DQSTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + 1 << 31, 1 << 31); /* CLK COMP Overrides */ /* RCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CLKDRVPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0C << 16)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CLKDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0c << 16), + 0x801f0000); /* RCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CLKDRVPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0C << 16)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CLKDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0c << 16), + 0x801f0000); /* DCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CLKDLYPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x07 << 16)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CLKDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x07 << 16), + 0x801f0000); /* DCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CLKDLYPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x07 << 16)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CLKDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x07 << 16), + 0x801f0000); /* ODTCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CLKODTPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0B << 16)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CLKODTPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0b << 16), + 0x801f0000); /* ODTCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CLKODTPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0B << 16)), - (BIT31 | (0x0B << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CLKODTPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0b << 16), + 0x801f0000); /* TCOCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CLKTCOPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31), (BIT31)); + CLKTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + 1 << 31, 1 << 31); /* TCOCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CLKTCOPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31), (BIT31)); + CLKTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + 1 << 31, 1 << 31); /* CMD COMP Overrides */ /* RCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CMDDRVPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0D << 16)), - (BIT31 | BIT21 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CMDDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0d << 16), + 0x803f0000); /* RCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CMDDRVPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0D << 16)), - (BIT31 | BIT21 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CMDDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0d << 16), + 0x803f0000); /* DCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CMDDLYPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0A << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CMDDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0a << 16), + 0x801f0000); /* DCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CMDDLYPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0A << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CMDDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0a << 16), + 0x801f0000); /* CTL COMP Overrides */ /* RCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CTLDRVPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0D << 16)), - (BIT31 | BIT21 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CTLDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0d << 16), + 0x803f0000); /* RCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CTLDRVPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0D << 16)), - (BIT31 | BIT21 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CTLDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0d << 16), + 0x803f0000); /* DCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CTLDLYPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0A << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CTLDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0a << 16), + 0x801f0000); /* DCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CTLDLYPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x0A << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CTLDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x0a << 16), + 0x801f0000); #else /* DQ TCOCOMP Overrides */ /* TCOCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQTCOPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x1F << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x1f << 16), + 0x801f0000); /* TCOCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQTCOPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x1F << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x1f << 16), + 0x801f0000); /* DQS TCOCOMP Overrides */ /* TCOCOMP PU */ mrc_alt_write_mask(DDRPHY, - (DQSTCOPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x1F << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQSTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x1f << 16), + 0x801f0000); /* TCOCOMP PD */ mrc_alt_write_mask(DDRPHY, - (DQSTCOPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x1F << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + DQSTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x1f << 16), + 0x801f0000); /* CLK TCOCOMP Overrides */ /* TCOCOMP PU */ mrc_alt_write_mask(DDRPHY, - (CLKTCOPUCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x1F << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CLKTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x1f << 16), + 0x801f0000); /* TCOCOMP PD */ mrc_alt_write_mask(DDRPHY, - (CLKTCOPDCTLCH0 + (ch * DDRCOMP_CH_OFFSET)), - (BIT31 | (0x1F << 16)), - (BIT31 | BIT20 | BIT19 | - BIT18 | BIT17 | BIT16)); + CLKTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET, + (1 << 31) | (0x1f << 16), + 0x801f0000); #endif /* program STATIC delays */ @@ -962,7 +845,7 @@ void ddrphy_init(struct mrc_params *mrc_params) #endif for (rk = 0; rk < NUM_RANKS; rk++) { - if (mrc_params->rank_enables & (1<rank_enables & (1 << rk)) { set_wclk(ch, rk, ddr_wclk[PLATFORM_ID]); #ifdef BACKUP_WCTL set_wctl(ch, rk, ddr_wctl[PLATFORM_ID]); @@ -976,86 +859,80 @@ void ddrphy_init(struct mrc_params *mrc_params) /* COMP (non channel specific) */ /* RCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (DQANADRVPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQANADRVPUCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (DQANADRVPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQANADRVPDCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (CMDANADRVPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CMDANADRVPUCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (CMDANADRVPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CMDANADRVPDCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (CLKANADRVPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CLKANADRVPUCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (CLKANADRVPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CLKANADRVPDCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (DQSANADRVPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQSANADRVPUCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (DQSANADRVPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQSANADRVPDCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (CTLANADRVPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CTLANADRVPUCTL, 1 << 30, 1 << 30); /* RCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (CTLANADRVPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CTLANADRVPDCTL, 1 << 30, 1 << 30); /* ODT: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (DQANAODTPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQANAODTPUCTL, 1 << 30, 1 << 30); /* ODT: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (DQANAODTPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQANAODTPDCTL, 1 << 30, 1 << 30); /* ODT: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (CLKANAODTPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CLKANAODTPUCTL, 1 << 30, 1 << 30); /* ODT: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (CLKANAODTPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CLKANAODTPDCTL, 1 << 30, 1 << 30); /* ODT: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (DQSANAODTPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQSANAODTPUCTL, 1 << 30, 1 << 30); /* ODT: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (DQSANAODTPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQSANAODTPDCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (DQANADLYPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQANADLYPUCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (DQANADLYPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQANADLYPDCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (CMDANADLYPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CMDANADLYPUCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (CMDANADLYPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CMDANADLYPDCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (CLKANADLYPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CLKANADLYPUCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (CLKANADLYPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CLKANADLYPDCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (DQSANADLYPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQSANADLYPUCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (DQSANADLYPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQSANADLYPDCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (CTLANADLYPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CTLANADLYPUCTL, 1 << 30, 1 << 30); /* DCOMP: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (CTLANADLYPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CTLANADLYPDCTL, 1 << 30, 1 << 30); /* TCO: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (DQANATCOPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQANATCOPUCTL, 1 << 30, 1 << 30); /* TCO: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (DQANATCOPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQANATCOPDCTL, 1 << 30, 1 << 30); /* TCO: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (CLKANATCOPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CLKANATCOPUCTL, 1 << 30, 1 << 30); /* TCO: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (CLKANATCOPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, CLKANATCOPDCTL, 1 << 30, 1 << 30); /* TCO: Dither PU Enable */ - mrc_alt_write_mask(DDRPHY, (DQSANATCOPUCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQSANATCOPUCTL, 1 << 30, 1 << 30); /* TCO: Dither PD Enable */ - mrc_alt_write_mask(DDRPHY, (DQSANATCOPDCTL), (BIT30), (BIT30)); + mrc_alt_write_mask(DDRPHY, DQSANATCOPDCTL, 1 << 30, 1 << 30); /* TCOCOMP: Pulse Count */ - mrc_alt_write_mask(DDRPHY, (TCOCNTCTRL), (0x1 << 0), (BIT1 | BIT0)); + mrc_alt_write_mask(DDRPHY, TCOCNTCTRL, 1, 3); /* ODT: CMD/CTL PD/PU */ - mrc_alt_write_mask(DDRPHY, - (CHNLBUFSTATIC), ((0x03 << 24) | (0x03 << 16)), - (BIT28 | BIT27 | BIT26 | BIT25 | BIT24 | - BIT20 | BIT19 | BIT18 | BIT17 | BIT16)); + mrc_alt_write_mask(DDRPHY, CHNLBUFSTATIC, + (0x03 << 24) | (0x03 << 16), 0x1f1f0000); /* Set 1us counter */ - mrc_alt_write_mask(DDRPHY, - (MSCNTR), (0x64 << 0), - (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)); - mrc_alt_write_mask(DDRPHY, - (LATCH1CTL), (0x1 << 28), - (BIT30 | BIT29 | BIT28)); + mrc_alt_write_mask(DDRPHY, MSCNTR, 0x64, 0xff); + mrc_alt_write_mask(DDRPHY, LATCH1CTL, 0x1 << 28, 0x70000000); /* Release PHY from reset */ - mrc_alt_write_mask(DDRPHY, MASTERRSTN, BIT0, BIT0); + mrc_alt_write_mask(DDRPHY, MASTERRSTN, 1, 1); /* STEP1 */ mrc_post_code(0x03, 0x11); @@ -1064,30 +941,30 @@ void ddrphy_init(struct mrc_params *mrc_params) if (mrc_params->channel_enables & (1 << ch)) { /* DQ01-DQ23 */ for (bl_grp = 0; - bl_grp < ((NUM_BYTE_LANES / bl_divisor) / 2); + bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2; bl_grp++) { mrc_alt_write_mask(DDRPHY, - (DQMDLLCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (BIT13), - (BIT13)); /* Enable VREG */ + DQMDLLCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 1 << 13, + 1 << 13); /* Enable VREG */ delay_n(3); } /* ECC */ - mrc_alt_write_mask(DDRPHY, (ECCMDLLCTL), - (BIT13), (BIT13)); /* Enable VREG */ + mrc_alt_write_mask(DDRPHY, ECCMDLLCTL, + 1 << 13, 1 << 13); /* Enable VREG */ delay_n(3); /* CMD */ mrc_alt_write_mask(DDRPHY, - (CMDMDLLCTL + (ch * DDRIOCCC_CH_OFFSET)), - (BIT13), (BIT13)); /* Enable VREG */ + CMDMDLLCTL + ch * DDRIOCCC_CH_OFFSET, + 1 << 13, 1 << 13); /* Enable VREG */ delay_n(3); /* CLK-CTL */ mrc_alt_write_mask(DDRPHY, - (CCMDLLCTL + (ch * DDRIOCCC_CH_OFFSET)), - (BIT13), (BIT13)); /* Enable VREG */ + CCMDLLCTL + ch * DDRIOCCC_CH_OFFSET, + 1 << 13, 1 << 13); /* Enable VREG */ delay_n(3); } } @@ -1100,30 +977,30 @@ void ddrphy_init(struct mrc_params *mrc_params) if (mrc_params->channel_enables & (1 << ch)) { /* DQ01-DQ23 */ for (bl_grp = 0; - bl_grp < ((NUM_BYTE_LANES / bl_divisor) / 2); + bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2; bl_grp++) { mrc_alt_write_mask(DDRPHY, - (DQMDLLCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (BIT17), - (BIT17)); /* Enable MCDLL */ + DQMDLLCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 1 << 17, + 1 << 17); /* Enable MCDLL */ delay_n(50); } /* ECC */ - mrc_alt_write_mask(DDRPHY, (ECCMDLLCTL), - (BIT17), (BIT17)); /* Enable MCDLL */ + mrc_alt_write_mask(DDRPHY, ECCMDLLCTL, + 1 << 17, 1 << 17); /* Enable MCDLL */ delay_n(50); /* CMD */ mrc_alt_write_mask(DDRPHY, - (CMDMDLLCTL + (ch * DDRIOCCC_CH_OFFSET)), - (BIT18), (BIT18)); /* Enable MCDLL */ + CMDMDLLCTL + ch * DDRIOCCC_CH_OFFSET, + 1 << 18, 1 << 18); /* Enable MCDLL */ delay_n(50); /* CLK-CTL */ mrc_alt_write_mask(DDRPHY, - (CCMDLLCTL + (ch * DDRIOCCC_CH_OFFSET)), - (BIT18), (BIT18)); /* Enable MCDLL */ + CCMDLLCTL + ch * DDRIOCCC_CH_OFFSET, + 1 << 18, 1 << 18); /* Enable MCDLL */ delay_n(50); } } @@ -1136,54 +1013,47 @@ void ddrphy_init(struct mrc_params *mrc_params) if (mrc_params->channel_enables & (1 << ch)) { /* DQ01-DQ23 */ for (bl_grp = 0; - bl_grp < ((NUM_BYTE_LANES / bl_divisor) / 2); + bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2; bl_grp++) { #ifdef FORCE_16BIT_DDRIO - temp = ((bl_grp) && + temp = (bl_grp && (mrc_params->channel_width == X16)) ? - ((0x1 << 12) | (0x1 << 8) | - (0xF << 4) | (0xF << 0)) : - ((0xF << 12) | (0xF << 8) | - (0xF << 4) | (0xF << 0)); + 0x11ff : 0xffff; #else - temp = ((0xF << 12) | (0xF << 8) | - (0xF << 4) | (0xF << 0)); + temp = 0xffff; #endif /* Enable TXDLL */ mrc_alt_write_mask(DDRPHY, - (DQDLLTXCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - temp, 0xFFFF); + DQDLLTXCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + temp, 0xffff); delay_n(3); /* Enable RXDLL */ mrc_alt_write_mask(DDRPHY, - (DQDLLRXCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (BIT3 | BIT2 | BIT1 | BIT0), - (BIT3 | BIT2 | BIT1 | BIT0)); + DQDLLRXCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 0xf, 0xf); delay_n(3); /* Enable RXDLL Overrides BL0 */ mrc_alt_write_mask(DDRPHY, - (B0OVRCTL + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (BIT3 | BIT2 | BIT1 | BIT0), - (BIT3 | BIT2 | BIT1 | BIT0)); + B0OVRCTL + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 0xf, 0xf); } /* ECC */ - temp = ((0xF << 12) | (0xF << 8) | - (0xF << 4) | (0xF << 0)); - mrc_alt_write_mask(DDRPHY, (ECCDLLTXCTL), - temp, 0xFFFF); + temp = 0xffff; + mrc_alt_write_mask(DDRPHY, ECCDLLTXCTL, + temp, 0xffff); delay_n(3); /* CMD (PO) */ mrc_alt_write_mask(DDRPHY, - (CMDDLLTXCTL + (ch * DDRIOCCC_CH_OFFSET)), - temp, 0xFFFF); + CMDDLLTXCTL + ch * DDRIOCCC_CH_OFFSET, + temp, 0xffff); delay_n(3); } } @@ -1195,94 +1065,85 @@ void ddrphy_init(struct mrc_params *mrc_params) if (mrc_params->channel_enables & (1 << ch)) { /* Host To Memory Clock Alignment (HMC) for 800/1066 */ for (bl_grp = 0; - bl_grp < ((NUM_BYTE_LANES / bl_divisor) / 2); + bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2; bl_grp++) { /* CLK_ALIGN_MOD_ID */ mrc_alt_write_mask(DDRPHY, - (DQCLKALIGNREG2 + - (bl_grp * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - (bl_grp) ? (0x3) : (0x1), - (BIT3 | BIT2 | BIT1 | BIT0)); + DQCLKALIGNREG2 + + bl_grp * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + bl_grp ? 3 : 1, + 0xf); } mrc_alt_write_mask(DDRPHY, - (ECCCLKALIGNREG2 + (ch * DDRIODQ_CH_OFFSET)), - 0x2, - (BIT3 | BIT2 | BIT1 | BIT0)); + ECCCLKALIGNREG2 + ch * DDRIODQ_CH_OFFSET, + 0x2, 0xf); mrc_alt_write_mask(DDRPHY, - (CMDCLKALIGNREG2 + (ch * DDRIODQ_CH_OFFSET)), - 0x0, - (BIT3 | BIT2 | BIT1 | BIT0)); + CMDCLKALIGNREG2 + ch * DDRIODQ_CH_OFFSET, + 0x0, 0xf); mrc_alt_write_mask(DDRPHY, - (CCCLKALIGNREG2 + (ch * DDRIODQ_CH_OFFSET)), - 0x2, - (BIT3 | BIT2 | BIT1 | BIT0)); + CCCLKALIGNREG2 + ch * DDRIODQ_CH_OFFSET, + 0x2, 0xf); mrc_alt_write_mask(DDRPHY, - (CMDCLKALIGNREG0 + (ch * DDRIOCCC_CH_OFFSET)), - (0x2 << 4), (BIT5 | BIT4)); + CMDCLKALIGNREG0 + ch * DDRIOCCC_CH_OFFSET, + 0x20, 0x30); /* * NUM_SAMPLES, MAX_SAMPLES, * MACRO_PI_STEP, MICRO_PI_STEP */ mrc_alt_write_mask(DDRPHY, - (CMDCLKALIGNREG1 + (ch * DDRIOCCC_CH_OFFSET)), - ((0x18 << 16) | (0x10 << 8) | - (0x8 << 2) | (0x1 << 0)), - (BIT22 | BIT21 | BIT20 | BIT19 | BIT18 | BIT17 | - BIT16 | BIT14 | BIT13 | BIT12 | BIT11 | BIT10 | - BIT9 | BIT8 | BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | - BIT2 | BIT1 | BIT0)); + CMDCLKALIGNREG1 + ch * DDRIOCCC_CH_OFFSET, + (0x18 << 16) | (0x10 << 8) | + (0x8 << 2) | (0x1 << 0), + 0x007f7fff); /* TOTAL_NUM_MODULES, FIRST_U_PARTITION */ mrc_alt_write_mask(DDRPHY, - (CMDCLKALIGNREG2 + (ch * DDRIOCCC_CH_OFFSET)), - ((0x10 << 16) | (0x4 << 8) | (0x2 << 4)), - (BIT20 | BIT19 | BIT18 | BIT17 | BIT16 | - BIT11 | BIT10 | BIT9 | BIT8 | BIT7 | BIT6 | - BIT5 | BIT4)); + CMDCLKALIGNREG2 + ch * DDRIOCCC_CH_OFFSET, + (0x10 << 16) | (0x4 << 8) | (0x2 << 4), + 0x001f0ff0); #ifdef HMC_TEST /* START_CLK_ALIGN=1 */ mrc_alt_write_mask(DDRPHY, - (CMDCLKALIGNREG0 + (ch * DDRIOCCC_CH_OFFSET)), - BIT24, BIT24); + CMDCLKALIGNREG0 + ch * DDRIOCCC_CH_OFFSET, + 1 << 24, 1 << 24); while (msg_port_alt_read(DDRPHY, - (CMDCLKALIGNREG0 + (ch * DDRIOCCC_CH_OFFSET))) & - BIT24) + CMDCLKALIGNREG0 + ch * DDRIOCCC_CH_OFFSET) & + (1 << 24)) ; /* wait for START_CLK_ALIGN=0 */ #endif /* Set RD/WR Pointer Seperation & COUNTEN & FIFOPTREN */ mrc_alt_write_mask(DDRPHY, - (CMDPTRREG + (ch * DDRIOCCC_CH_OFFSET)), - BIT0, BIT0); /* WRPTRENABLE=1 */ + CMDPTRREG + ch * DDRIOCCC_CH_OFFSET, + 1, 1); /* WRPTRENABLE=1 */ /* COMP initial */ /* enable bypass for CLK buffer (PO) */ mrc_alt_write_mask(DDRPHY, - (COMPEN0CH0 + (ch * DDRCOMP_CH_OFFSET)), - BIT5, BIT5); + COMPEN0CH0 + ch * DDRCOMP_CH_OFFSET, + 1 << 5, 1 << 5); /* Initial COMP Enable */ - mrc_alt_write_mask(DDRPHY, (CMPCTRL), - (BIT0), (BIT0)); + mrc_alt_write_mask(DDRPHY, CMPCTRL, 1, 1); /* wait for Initial COMP Enable = 0 */ - while (msg_port_alt_read(DDRPHY, (CMPCTRL)) & BIT0) + while (msg_port_alt_read(DDRPHY, CMPCTRL) & 1) ; /* disable bypass for CLK buffer (PO) */ mrc_alt_write_mask(DDRPHY, - (COMPEN0CH0 + (ch * DDRCOMP_CH_OFFSET)), - ~BIT5, BIT5); + COMPEN0CH0 + ch * DDRCOMP_CH_OFFSET, + ~(1 << 5), 1 << 5); /* IOBUFACT */ /* STEP4a */ mrc_alt_write_mask(DDRPHY, - (CMDCFGREG0 + (ch * DDRIOCCC_CH_OFFSET)), - BIT2, BIT2); /* IOBUFACTRST_N=1 */ + CMDCFGREG0 + ch * DDRIOCCC_CH_OFFSET, + 1 << 2, 1 << 2); /* IOBUFACTRST_N=1 */ /* DDRPHY initialization complete */ mrc_alt_write_mask(DDRPHY, - (CMDPMCONFIG0 + (ch * DDRIOCCC_CH_OFFSET)), - BIT20, BIT20); /* SPID_INIT_COMPLETE=1 */ + CMDPMCONFIG0 + ch * DDRIOCCC_CH_OFFSET, + 1 << 20, 1 << 20); /* SPID_INIT_COMPLETE=1 */ } } @@ -1308,13 +1169,13 @@ void perform_jedec_init(struct mrc_params *mrc_params) mrc_post_code(0x04, 0x00); /* DDR3_RESET_SET=0, DDR3_RESET_RESET=1 */ - mrc_alt_write_mask(DDRPHY, CCDDR3RESETCTL, BIT1, (BIT8 | BIT1)); + mrc_alt_write_mask(DDRPHY, CCDDR3RESETCTL, 2, 0x102); /* Assert RESET# for 200us */ delay_u(200); /* DDR3_RESET_SET=1, DDR3_RESET_RESET=0 */ - mrc_alt_write_mask(DDRPHY, CCDDR3RESETCTL, BIT8, (BIT8 | BIT1)); + mrc_alt_write_mask(DDRPHY, CCDDR3RESETCTL, 0x100, 0x102); dtr0 = msg_port_read(MEM_CTLR, DTR0); @@ -1327,8 +1188,8 @@ void perform_jedec_init(struct mrc_params *mrc_params) drp &= 0x3; drmc = msg_port_read(MEM_CTLR, DRMC); - drmc &= 0xFFFFFFFC; - drmc |= (BIT4 | drp); + drmc &= 0xfffffffc; + drmc |= (DRMC_CKEMODE | drp); msg_port_write(MEM_CTLR, DRMC, drmc); @@ -1341,7 +1202,7 @@ void perform_jedec_init(struct mrc_params *mrc_params) } msg_port_write(MEM_CTLR, DRMC, - (mrc_params->rd_odt_value == 0 ? BIT12 : 0)); + (mrc_params->rd_odt_value == 0 ? DRMC_ODTMODE : 0)); /* * setup for emrs 2 @@ -1392,12 +1253,12 @@ void perform_jedec_init(struct mrc_params *mrc_params) * 1** --> RESERVED */ emrs1_cmd |= (1 << 3); - emrs1_cmd &= ~BIT6; + emrs1_cmd &= ~(1 << 6); if (mrc_params->ron_value == 0) - emrs1_cmd |= BIT7; + emrs1_cmd |= (1 << 7); else - emrs1_cmd &= ~BIT7; + emrs1_cmd &= ~(1 << 7); if (mrc_params->rtt_nom_value == 0) emrs1_cmd |= (DDR3_EMRS1_RTTNOM_40 << 6); @@ -1432,8 +1293,8 @@ void perform_jedec_init(struct mrc_params *mrc_params) * BIT[02:02] "0" if oem_tCAS <= 11 (1866?) * BIT[06:04] use oem_tCAS-4 */ - mrs0_cmd |= BIT14; - mrs0_cmd |= BIT18; + mrs0_cmd |= (1 << 14); + mrs0_cmd |= (1 << 18); mrs0_cmd |= ((((dtr0 >> 12) & 7) + 1) << 10); tck = t_ck[mrc_params->ddr_speed]; @@ -1480,8 +1341,8 @@ void set_ddr_init_complete(struct mrc_params *mrc_params) ENTERFN(); dco = msg_port_read(MEM_CTLR, DCO); - dco &= ~BIT28; - dco |= BIT31; + dco &= ~DCO_PMICTL; + dco |= DCO_IC; msg_port_write(MEM_CTLR, DCO, dco); LEAVEFN(); @@ -1577,7 +1438,7 @@ void rcvn_cal(struct mrc_params *mrc_params) /* need separate burst to sample DQS preamble */ dtr1 = msg_port_read(MEM_CTLR, DTR1); dtr1_save = dtr1; - dtr1 |= BIT12; + dtr1 |= DTR1_TCCD_12CLK; msg_port_write(MEM_CTLR, DTR1, dtr1); #endif @@ -1596,7 +1457,7 @@ void rcvn_cal(struct mrc_params *mrc_params) * POST_CODE here indicates the current * channel and rank being calibrated */ - mrc_post_code(0x05, (0x10 + ((ch << 4) | rk))); + mrc_post_code(0x05, 0x10 + ((ch << 4) | rk)); #ifdef BACKUP_RCVN /* et hard-coded timing values */ @@ -1606,10 +1467,10 @@ void rcvn_cal(struct mrc_params *mrc_params) /* enable FIFORST */ for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl += 2) { mrc_alt_write_mask(DDRPHY, - (B01PTRCTL1 + - ((bl >> 1) * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - 0, BIT8); + B01PTRCTL1 + + (bl >> 1) * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 0, 1 << 8); } /* initialize the starting delay to 128 PI (cas +1 CLK) */ for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { @@ -1638,11 +1499,11 @@ void rcvn_cal(struct mrc_params *mrc_params) } else { /* not enough delay */ training_message(ch, rk, bl); - mrc_post_code(0xEE, 0x50); + mrc_post_code(0xee, 0x50); } } } - } while (temp & 0xFF); + } while (temp & 0xff); #ifdef R2R_SHARING /* increment "num_ranks_enabled" */ @@ -1653,7 +1514,7 @@ void rcvn_cal(struct mrc_params *mrc_params) /* add "delay[]" values to "final_delay[][]" for rolling average */ final_delay[ch][bl] += delay[bl]; /* set timing based on rolling average values */ - set_rcvn(ch, rk, bl, ((final_delay[ch][bl]) / num_ranks_enabled)); + set_rcvn(ch, rk, bl, final_delay[ch][bl] / num_ranks_enabled); } #else /* Finally increment delay by 32 PI (1/4 CLK) to place in center of preamble */ @@ -1666,10 +1527,10 @@ void rcvn_cal(struct mrc_params *mrc_params) /* disable FIFORST */ for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl += 2) { mrc_alt_write_mask(DDRPHY, - (B01PTRCTL1 + - ((bl >> 1) * DDRIODQ_BL_OFFSET) + - (ch * DDRIODQ_CH_OFFSET)), - BIT8, BIT8); + B01PTRCTL1 + + (bl >> 1) * DDRIODQ_BL_OFFSET + + ch * DDRIODQ_CH_OFFSET, + 1 << 8, 1 << 8); } #endif } @@ -1742,12 +1603,12 @@ void wr_level(struct mrc_params *mrc_params) * POST_CODE here indicates the current * rank and channel being calibrated */ - mrc_post_code(0x06, (0x10 + ((ch << 4) | rk))); + mrc_post_code(0x06, 0x10 + ((ch << 4) | rk)); #ifdef BACKUP_WDQS for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { set_wdqs(ch, rk, bl, ddr_wdqs[PLATFORM_ID]); - set_wdq(ch, rk, bl, (ddr_wdqs[PLATFORM_ID] - QRTR_CLK)); + set_wdq(ch, rk, bl, ddr_wdqs[PLATFORM_ID] - QRTR_CLK); } #else /* @@ -1760,7 +1621,7 @@ void wr_level(struct mrc_params *mrc_params) * enable Write Levelling Mode * (EMRS1 w/ Write Levelling Mode Enable) */ - dram_init_command(DCMD_MRS1(rk, 0x0082)); + dram_init_command(DCMD_MRS1(rk, 0x82)); /* * set ODT DRAM Full Time Termination @@ -1769,24 +1630,24 @@ void wr_level(struct mrc_params *mrc_params) dtr4 = msg_port_read(MEM_CTLR, DTR4); dtr4_save = dtr4; - dtr4 |= BIT15; + dtr4 |= DTR4_ODTDIS; msg_port_write(MEM_CTLR, DTR4, dtr4); - for (bl = 0; bl < ((NUM_BYTE_LANES / bl_divisor) / 2); bl++) { + for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor) / 2; bl++) { /* * Enable Sandy Bridge Mode (WDQ Tri-State) & * Ensure 5 WDQS pulses during Write Leveling */ mrc_alt_write_mask(DDRPHY, - DQCTL + (DDRIODQ_BL_OFFSET * bl) + (DDRIODQ_CH_OFFSET * ch), - (BIT28 | BIT8 | BIT6 | BIT4 | BIT2), - (BIT28 | BIT9 | BIT8 | BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)); + DQCTL + DDRIODQ_BL_OFFSET * bl + DDRIODQ_CH_OFFSET * ch, + 0x10000154, + 0x100003fc); } /* Write Leveling Mode enabled in IO */ mrc_alt_write_mask(DDRPHY, - CCDDR3RESETCTL + (DDRIOCCC_CH_OFFSET * ch), - BIT16, BIT16); + CCDDR3RESETCTL + DDRIOCCC_CH_OFFSET * ch, + 1 << 16, 1 << 16); /* Initialize the starting delay to WCLK */ for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { @@ -1804,15 +1665,15 @@ void wr_level(struct mrc_params *mrc_params) /* disable Write Levelling Mode */ mrc_alt_write_mask(DDRPHY, - CCDDR3RESETCTL + (DDRIOCCC_CH_OFFSET * ch), - 0, BIT16); + CCDDR3RESETCTL + DDRIOCCC_CH_OFFSET * ch, + 0, 1 << 16); - for (bl = 0; bl < ((NUM_BYTE_LANES / bl_divisor) / 2); bl++) { + for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor) / 2; bl++) { /* Disable Sandy Bridge Mode & Ensure 4 WDQS pulses during normal operation */ mrc_alt_write_mask(DDRPHY, - DQCTL + (DDRIODQ_BL_OFFSET * bl) + (DDRIODQ_CH_OFFSET * ch), - (BIT8 | BIT6 | BIT4 | BIT2), - (BIT28 | BIT9 | BIT8 | BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)); + DQCTL + DDRIODQ_BL_OFFSET * bl + DDRIODQ_CH_OFFSET * ch, + 0x00000154, + 0x100003fc); } /* restore original DTR4 */ @@ -1830,7 +1691,7 @@ void wr_level(struct mrc_params *mrc_params) */ dram_init_command(DCMD_PREA(rk)); - mrc_post_code(0x06, (0x30 + ((ch << 4) | rk))); + mrc_post_code(0x06, 0x30 + ((ch << 4) | rk)); /* * COARSE WRITE LEVEL: @@ -1863,13 +1724,13 @@ void wr_level(struct mrc_params *mrc_params) coarse_result = check_rw_coarse(mrc_params, address); /* check for failures and margin the byte lane back 128 PI (1 CLK) */ - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { if (coarse_result & (coarse_result_mask << bl)) { all_edges_found = false; delay[bl] -= FULL_CLK; set_wdqs(ch, rk, bl, delay[bl]); /* program WDQ timings based on WDQS (WDQ = WDQS - 32 PI) */ - set_wdq(ch, rk, bl, (delay[bl] - QRTR_CLK)); + set_wdq(ch, rk, bl, delay[bl] - QRTR_CLK); } } } while (!all_edges_found); @@ -1878,11 +1739,11 @@ void wr_level(struct mrc_params *mrc_params) /* increment "num_ranks_enabled" */ num_ranks_enabled++; /* accumulate "final_delay[][]" values from "delay[]" values for rolling average */ - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { final_delay[ch][bl] += delay[bl]; - set_wdqs(ch, rk, bl, ((final_delay[ch][bl]) / num_ranks_enabled)); + set_wdqs(ch, rk, bl, final_delay[ch][bl] / num_ranks_enabled); /* program WDQ timings based on WDQS (WDQ = WDQS - 32 PI) */ - set_wdq(ch, rk, bl, ((final_delay[ch][bl]) / num_ranks_enabled) - QRTR_CLK); + set_wdq(ch, rk, bl, final_delay[ch][bl] / num_ranks_enabled - QRTR_CLK); } #endif #endif @@ -1901,9 +1762,9 @@ void prog_page_ctrl(struct mrc_params *mrc_params) ENTERFN(); dpmc0 = msg_port_read(MEM_CTLR, DPMC0); - dpmc0 &= ~(BIT16 | BIT17 | BIT18); + dpmc0 &= ~DPMC0_PCLSTO_MASK; dpmc0 |= (4 << 16); - dpmc0 |= BIT21; + dpmc0 |= DPMC0_PREAPWDEN; msg_port_write(MEM_CTLR, DPMC0, dpmc0); } @@ -1966,7 +1827,7 @@ void rd_train(struct mrc_params *mrc_params) for (rk = 0; rk < NUM_RANKS; rk++) { if (mrc_params->rank_enables & (1 << rk)) { for (bl = 0; - bl < (NUM_BYTE_LANES / bl_divisor); + bl < NUM_BYTE_LANES / bl_divisor; bl++) { set_rdqs(ch, rk, bl, ddr_rdqs[PLATFORM_ID]); } @@ -1981,7 +1842,7 @@ void rd_train(struct mrc_params *mrc_params) for (rk = 0; rk < NUM_RANKS; rk++) { if (mrc_params->rank_enables & (1 << rk)) { for (bl = 0; - bl < (NUM_BYTE_LANES / bl_divisor); + bl < NUM_BYTE_LANES / bl_divisor; bl++) { /* x_coordinate */ x_coordinate[L][B][ch][rk][bl] = RDQS_MIN; @@ -2011,7 +1872,7 @@ void rd_train(struct mrc_params *mrc_params) /* look for passing coordinates */ for (side_y = B; side_y <= T; side_y++) { for (side_x = L; side_x <= R; side_x++) { - mrc_post_code(0x07, (0x10 + (side_y * 2) + (side_x))); + mrc_post_code(0x07, 0x10 + side_y * 2 + side_x); /* find passing values */ for (ch = 0; ch < NUM_CHANNELS; ch++) { @@ -2021,7 +1882,7 @@ void rd_train(struct mrc_params *mrc_params) (0x1 << rk)) { /* set x/y_coordinate search starting settings */ for (bl = 0; - bl < (NUM_BYTE_LANES / bl_divisor); + bl < NUM_BYTE_LANES / bl_divisor; bl++) { set_rdqs(ch, rk, bl, x_coordinate[side_x][side_y][ch][rk][bl]); @@ -2041,9 +1902,9 @@ void rd_train(struct mrc_params *mrc_params) result = check_bls_ex(mrc_params, address); /* check for failures */ - if (result & 0xFF) { + if (result & 0xff) { /* at least 1 byte lane failed */ - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { if (result & (bl_mask << bl)) { /* adjust the RDQS values accordingly */ @@ -2072,13 +1933,13 @@ void rd_train(struct mrc_params *mrc_params) (y_coordinate[side_x][B][ch][bl] == y_coordinate[side_x][T][ch][bl])) { /* VREF_EYE collapsed below MIN_VREF_EYE */ training_message(ch, rk, bl); - mrc_post_code(0xEE, (0x70 + (side_y * 2) + (side_x))); + mrc_post_code(0xEE, 0x70 + side_y * 2 + side_x); } else { /* update the VREF setting */ set_vref(ch, bl, y_coordinate[side_x][side_y][ch][bl]); /* reset the X coordinate to begin the search at the new VREF */ x_coordinate[side_x][side_y][ch][rk][bl] = - (side_x == L) ? (RDQS_MIN) : (RDQS_MAX); + (side_x == L) ? RDQS_MIN : RDQS_MAX; } } @@ -2087,7 +1948,7 @@ void rd_train(struct mrc_params *mrc_params) } } } - } while (result & 0xFF); + } while (result & 0xff); } } } @@ -2147,23 +2008,23 @@ void rd_train(struct mrc_params *mrc_params) /* perform an eye check */ for (side_y = B; side_y <= T; side_y++) { for (side_x = L; side_x <= R; side_x++) { - mrc_post_code(0x07, (0x30 + (side_y * 2) + (side_x))); + mrc_post_code(0x07, 0x30 + side_y * 2 + side_x); /* update the settings for the eye check */ for (ch = 0; ch < NUM_CHANNELS; ch++) { if (mrc_params->channel_enables & (1 << ch)) { for (rk = 0; rk < NUM_RANKS; rk++) { if (mrc_params->rank_enables & (1 << rk)) { - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { if (side_x == L) - set_rdqs(ch, rk, bl, (x_center[ch][rk][bl] - (MIN_RDQS_EYE / 2))); + set_rdqs(ch, rk, bl, x_center[ch][rk][bl] - (MIN_RDQS_EYE / 2)); else - set_rdqs(ch, rk, bl, (x_center[ch][rk][bl] + (MIN_RDQS_EYE / 2))); + set_rdqs(ch, rk, bl, x_center[ch][rk][bl] + (MIN_RDQS_EYE / 2)); if (side_y == B) - set_vref(ch, bl, (y_center[ch][bl] - (MIN_VREF_EYE / 2))); + set_vref(ch, bl, y_center[ch][bl] - (MIN_VREF_EYE / 2)); else - set_vref(ch, bl, (y_center[ch][bl] + (MIN_VREF_EYE / 2))); + set_vref(ch, bl, y_center[ch][bl] + (MIN_VREF_EYE / 2)); } } } @@ -2174,9 +2035,9 @@ void rd_train(struct mrc_params *mrc_params) mrc_params->hte_setup = 1; /* check the eye */ - if (check_bls_ex(mrc_params, address) & 0xFF) { + if (check_bls_ex(mrc_params, address) & 0xff) { /* one or more byte lanes failed */ - mrc_post_code(0xEE, (0x74 + (side_x * 2) + (side_y))); + mrc_post_code(0xee, 0x74 + side_x * 2 + side_y); } } } @@ -2197,7 +2058,7 @@ void rd_train(struct mrc_params *mrc_params) /* x_coordinate */ #ifdef R2R_SHARING final_delay[ch][bl] += x_center[ch][rk][bl]; - set_rdqs(ch, rk, bl, ((final_delay[ch][bl]) / num_ranks_enabled)); + set_rdqs(ch, rk, bl, final_delay[ch][bl] / num_ranks_enabled); #else set_rdqs(ch, rk, bl, x_center[ch][rk][bl]); #endif @@ -2258,7 +2119,7 @@ void wr_train(struct mrc_params *mrc_params) for (rk = 0; rk < NUM_RANKS; rk++) { if (mrc_params->rank_enables & (1 << rk)) { for (bl = 0; - bl < (NUM_BYTE_LANES / bl_divisor); + bl < NUM_BYTE_LANES / bl_divisor; bl++) { set_wdq(ch, rk, bl, ddr_wdq[PLATFORM_ID]); } @@ -2273,7 +2134,7 @@ void wr_train(struct mrc_params *mrc_params) for (rk = 0; rk < NUM_RANKS; rk++) { if (mrc_params->rank_enables & (1 << rk)) { for (bl = 0; - bl < (NUM_BYTE_LANES / bl_divisor); + bl < NUM_BYTE_LANES / bl_divisor; bl++) { /* * want to start with @@ -2303,7 +2164,7 @@ void wr_train(struct mrc_params *mrc_params) * until no failures are observed, then repeat for the RIGHT side. */ for (side = L; side <= R; side++) { - mrc_post_code(0x08, (0x10 + (side))); + mrc_post_code(0x08, 0x10 + side); /* set starting values */ for (ch = 0; ch < NUM_CHANNELS; ch++) { @@ -2312,7 +2173,7 @@ void wr_train(struct mrc_params *mrc_params) if (mrc_params->rank_enables & (1 << rk)) { for (bl = 0; - bl < (NUM_BYTE_LANES / bl_divisor); + bl < NUM_BYTE_LANES / bl_divisor; bl++) { set_wdq(ch, rk, bl, delay[side][ch][rk][bl]); } @@ -2338,9 +2199,9 @@ void wr_train(struct mrc_params *mrc_params) /* result[07:00] == failing byte lane (MAX 8) */ result = check_bls_ex(mrc_params, address); /* check for failures */ - if (result & 0xFF) { + if (result & 0xff) { /* at least 1 byte lane failed */ - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { if (result & (bl_mask << bl)) { if (side == L) @@ -2362,13 +2223,13 @@ void wr_train(struct mrc_params *mrc_params) * notify the user and halt */ training_message(ch, rk, bl); - mrc_post_code(0xEE, (0x80 + side)); + mrc_post_code(0xee, 0x80 + side); } } } } /* stop when all byte lanes pass */ - } while (result & 0xFF); + } while (result & 0xff); } } } @@ -2384,7 +2245,7 @@ void wr_train(struct mrc_params *mrc_params) /* increment "num_ranks_enabled" */ num_ranks_enabled++; #endif - for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) { + for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) { DPF(D_INFO, "WDQ eye rank%d lane%d : %d-%d\n", rk, bl, @@ -2396,7 +2257,7 @@ void wr_train(struct mrc_params *mrc_params) #ifdef R2R_SHARING final_delay[ch][bl] += temp; set_wdq(ch, rk, bl, - ((final_delay[ch][bl]) / num_ranks_enabled)); + final_delay[ch][bl] / num_ranks_enabled); #else set_wdq(ch, rk, bl, temp); #endif @@ -2470,7 +2331,7 @@ void enable_scrambling(struct mrc_params *mrc_params) * get seed from system clock * and make sure it is not all 1's */ - lfsr = rdtsc() & 0x0FFFFFFF; + lfsr = rdtsc() & 0x0fffffff; } else { /* * Need to replace scrambler @@ -2491,10 +2352,10 @@ void enable_scrambling(struct mrc_params *mrc_params) * In cold boot, we have the last 32bit LFSR which is the new seed. */ lfsr32(&lfsr); /* shift to next value */ - msg_port_write(MEM_CTLR, SCRMSEED, (lfsr & 0x0003FFFF)); + msg_port_write(MEM_CTLR, SCRMSEED, (lfsr & 0x0003ffff)); for (i = 0; i < 2; i++) - msg_port_write(MEM_CTLR, SCRMLO + i, (lfsr & 0xAAAAAAAA)); + msg_port_write(MEM_CTLR, SCRMLO + i, (lfsr & 0xaaaaaaaa)); LEAVEFN(); } @@ -2511,20 +2372,20 @@ void prog_ddr_control(struct mrc_params *mrc_params) ENTERFN(); dsch = msg_port_read(MEM_CTLR, DSCH); - dsch &= ~(BIT8 | BIT9 | BIT12); + dsch &= ~(DSCH_OOODIS | DSCH_OOOST3DIS | DSCH_NEWBYPDIS); msg_port_write(MEM_CTLR, DSCH, dsch); dpmc0 = msg_port_read(MEM_CTLR, DPMC0); - dpmc0 &= ~BIT25; + dpmc0 &= ~DPMC0_DISPWRDN; dpmc0 |= (mrc_params->power_down_disable << 25); - dpmc0 &= ~BIT24; - dpmc0 &= ~(BIT16 | BIT17 | BIT18); + dpmc0 &= ~DPMC0_CLKGTDIS; + dpmc0 &= ~DPMC0_PCLSTO_MASK; dpmc0 |= (4 << 16); - dpmc0 |= BIT21; + dpmc0 |= DPMC0_PREAPWDEN; msg_port_write(MEM_CTLR, DPMC0, dpmc0); /* CMDTRIST = 2h - CMD/ADDR are tristated when no valid command */ - mrc_write_mask(MEM_CTLR, DPMC1, 2 << 4, BIT4 | BIT5); + mrc_write_mask(MEM_CTLR, DPMC1, 0x20, 0x30); LEAVEFN(); } @@ -2542,14 +2403,14 @@ void prog_dra_drb(struct mrc_params *mrc_params) ENTERFN(); dco = msg_port_read(MEM_CTLR, DCO); - dco &= ~BIT31; + dco &= ~DCO_IC; msg_port_write(MEM_CTLR, DCO, dco); drp = 0; if (mrc_params->rank_enables & 1) - drp |= BIT0; + drp |= DRP_RKEN0; if (mrc_params->rank_enables & 2) - drp |= BIT1; + drp |= DRP_RKEN1; if (mrc_params->dram_width == X16) { drp |= (1 << 4); drp |= (1 << 9); @@ -2570,8 +2431,8 @@ void prog_dra_drb(struct mrc_params *mrc_params) msg_port_write(MEM_CTLR, DRP, drp); - dco &= ~BIT28; - dco |= BIT31; + dco &= ~DCO_PMICTL; + dco |= DCO_IC; msg_port_write(MEM_CTLR, DCO, dco); LEAVEFN(); @@ -2600,18 +2461,18 @@ void change_refresh_period(struct mrc_params *mrc_params) ENTERFN(); drfc = msg_port_read(MEM_CTLR, DRFC); - drfc &= ~(BIT12 | BIT13 | BIT14); + drfc &= ~DRFC_TREFI_MASK; drfc |= (mrc_params->refresh_rate << 12); - drfc |= BIT21; + drfc |= DRFC_REFDBTCLR; msg_port_write(MEM_CTLR, DRFC, drfc); dcal = msg_port_read(MEM_CTLR, DCAL); - dcal &= ~(BIT8 | BIT9 | BIT10); + dcal &= ~DCAL_ZQCINT_MASK; dcal |= (3 << 8); /* 63ms */ msg_port_write(MEM_CTLR, DCAL, dcal); dpmc0 = msg_port_read(MEM_CTLR, DPMC0); - dpmc0 |= (BIT23 | BIT29); + dpmc0 |= (DPMC0_DYNSREN | DPMC0_ENPHYCLKGATE); msg_port_write(MEM_CTLR, DPMC0, dpmc0); LEAVEFN(); @@ -2638,36 +2499,32 @@ void set_auto_refresh(struct mrc_params *mrc_params) for (channel = 0; channel < NUM_CHANNELS; channel++) { if (mrc_params->channel_enables & (1 << channel)) { /* Enable Periodic RCOMPS */ - mrc_alt_write_mask(DDRPHY, CMPCTRL, BIT1, BIT1); + mrc_alt_write_mask(DDRPHY, CMPCTRL, 2, 2); /* Enable Dynamic DiffAmp & Set Read ODT Value */ switch (mrc_params->rd_odt_value) { case 0: - temp = 0x3F; /* OFF */ + temp = 0x3f; /* OFF */ break; default: temp = 0x00; /* Auto */ break; } - for (bl = 0; bl < ((NUM_BYTE_LANES / bl_divisor) / 2); bl++) { + for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor) / 2; bl++) { /* Override: DIFFAMP, ODT */ mrc_alt_write_mask(DDRPHY, - (B0OVRCTL + (bl * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)), - (0x00 << 16) | (temp << 10), - (BIT21 | BIT20 | BIT19 | BIT18 | - BIT17 | BIT16 | BIT15 | BIT14 | - BIT13 | BIT12 | BIT11 | BIT10)); + B0OVRCTL + bl * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET, + temp << 10, + 0x003ffc00); /* Override: DIFFAMP, ODT */ mrc_alt_write_mask(DDRPHY, - (B1OVRCTL + (bl * DDRIODQ_BL_OFFSET) + - (channel * DDRIODQ_CH_OFFSET)), - (0x00 << 16) | (temp << 10), - (BIT21 | BIT20 | BIT19 | BIT18 | - BIT17 | BIT16 | BIT15 | BIT14 | - BIT13 | BIT12 | BIT11 | BIT10)); + B1OVRCTL + bl * DDRIODQ_BL_OFFSET + + channel * DDRIODQ_CH_OFFSET, + temp << 10, + 0x003ffc00); } /* Issue ZQCS command */ @@ -2702,18 +2559,18 @@ void ecc_enable(struct mrc_params *mrc_params) /* Configuration required in ECC mode */ drp = msg_port_read(MEM_CTLR, DRP); - drp &= ~(BIT14 | BIT15); - drp |= BIT15; - drp |= BIT13; + drp &= ~DRP_ADDRMAP_MASK; + drp |= DRP_ADDRMAP_MAP1; + drp |= DRP_PRI64BSPLITEN; msg_port_write(MEM_CTLR, DRP, drp); /* Disable new request bypass */ dsch = msg_port_read(MEM_CTLR, DSCH); - dsch |= BIT12; + dsch |= DSCH_NEWBYPDIS; msg_port_write(MEM_CTLR, DSCH, dsch); /* Enable ECC */ - ecc_ctrl = (BIT0 | BIT1 | BIT17); + ecc_ctrl = (DECCCTRL_SBEEN | DECCCTRL_DBEEN | DECCCTRL_ENCBGEN); msg_port_write(MEM_CTLR, DECCCTRL, ecc_ctrl); /* Assume 8 bank memory, one bank is gone for ECC */ @@ -2756,8 +2613,8 @@ void lock_registers(struct mrc_params *mrc_params) ENTERFN(); dco = msg_port_read(MEM_CTLR, DCO); - dco &= ~(BIT28 | BIT29); - dco |= (BIT0 | BIT8); + dco &= ~(DCO_PMICTL | DCO_PMIDIS); + dco |= (DCO_DRPLOCK | DCO_CPGCLOCK); msg_port_write(MEM_CTLR, DCO, dco); LEAVEFN(); diff --git a/arch/x86/cpu/quark/smc.h b/arch/x86/cpu/quark/smc.h index 46017a1..1582b87 100644 --- a/arch/x86/cpu/quark/smc.h +++ b/arch/x86/cpu/quark/smc.h @@ -24,46 +24,133 @@ #define DPMC1 0x07 #define DRFC 0x08 #define DSCH 0x09 -#define DCAL 0x0A -#define DRMC 0x0B -#define PMSTS 0x0C -#define DCO 0x0F +#define DCAL 0x0a +#define DRMC 0x0b +#define PMSTS 0x0c +#define DCO 0x0f #define DSTAT 0x20 -#define SSKPD0 0x4A -#define SSKPD1 0x4B +#define SSKPD0 0x4a +#define SSKPD1 0x4b #define DECCCTRL 0x60 #define DECCSTAT 0x61 #define DECCSBECNT 0x62 #define DECCSBECA 0x68 #define DECCSBECS 0x69 -#define DECCDBECA 0x6A -#define DECCDBECS 0x6B +#define DECCDBECA 0x6a +#define DECCDBECS 0x6b #define DFUSESTAT 0x70 #define SCRMSEED 0x80 #define SCRMLO 0x81 #define SCRMHI 0x82 +/* DRP register defines */ +#define DRP_RKEN0 (1 << 0) +#define DRP_RKEN1 (1 << 1) +#define DRP_PRI64BSPLITEN (1 << 13) +#define DRP_ADDRMAP_MAP0 (1 << 14) +#define DRP_ADDRMAP_MAP1 (1 << 15) +#define DRP_ADDRMAP_MASK 0x0000c000 + +/* DTR0 register defines */ +#define DTR0_DFREQ_MASK 0x00000003 +#define DTR0_TRP_MASK 0x000000f0 +#define DTR0_TRCD_MASK 0x00000f00 +#define DTR0_TCL_MASK 0x00007000 + +/* DTR1 register defines */ +#define DTR1_TWCL_MASK 0x00000007 +#define DTR1_TCMD_MASK 0x00000030 +#define DTR1_TWTP_MASK 0x00000f00 +#define DTR1_TCCD_12CLK (1 << 12) +#define DTR1_TCCD_18CLK (1 << 13) +#define DTR1_TCCD_MASK 0x00003000 +#define DTR1_TFAW_MASK 0x000f0000 +#define DTR1_TRAS_MASK 0x00f00000 +#define DTR1_TRRD_MASK 0x03000000 +#define DTR1_TRTP_MASK 0x70000000 + +/* DTR2 register defines */ +#define DTR2_TRRDR_MASK 0x00000007 +#define DTR2_TWWDR_MASK 0x00000700 +#define DTR2_TRWDR_MASK 0x000f0000 + +/* DTR3 register defines */ +#define DTR3_TWRDR_MASK 0x00000007 +#define DTR3_TXXXX_MASK 0x00000070 +#define DTR3_TRWSR_MASK 0x00000f00 +#define DTR3_TWRSR_MASK 0x0001e000 +#define DTR3_TXP_MASK 0x00c00000 + +/* DTR4 register defines */ +#define DTR4_WRODTSTRT_MASK 0x00000003 +#define DTR4_WRODTSTOP_MASK 0x00000070 +#define DTR4_XXXX1_MASK 0x00000700 +#define DTR4_XXXX2_MASK 0x00007000 +#define DTR4_ODTDIS (1 << 15) +#define DTR4_TRGSTRDIS (1 << 16) + +/* DPMC0 register defines */ +#define DPMC0_PCLSTO_MASK 0x00070000 +#define DPMC0_PREAPWDEN (1 << 21) +#define DPMC0_DYNSREN (1 << 23) +#define DPMC0_CLKGTDIS (1 << 24) +#define DPMC0_DISPWRDN (1 << 25) +#define DPMC0_ENPHYCLKGATE (1 << 29) + +/* DRFC register defines */ +#define DRFC_TREFI_MASK 0x00007000 +#define DRFC_REFDBTCLR (1 << 21) + +/* DSCH register defines */ +#define DSCH_OOODIS (1 << 8) +#define DSCH_OOOST3DIS (1 << 9) +#define DSCH_NEWBYPDIS (1 << 12) + +/* DCAL register defines */ +#define DCAL_ZQCINT_MASK 0x00000700 +#define DCAL_SRXZQCL_MASK 0x00003000 + +/* DRMC register defines */ +#define DRMC_CKEMODE (1 << 4) +#define DRMC_ODTMODE (1 << 12) +#define DRMC_COLDWAKE (1 << 16) + +/* PMSTS register defines */ +#define PMSTS_DISR (1 << 0) + +/* DCO register defines */ +#define DCO_DRPLOCK (1 << 0) +#define DCO_CPGCLOCK (1 << 8) +#define DCO_PMICTL (1 << 28) +#define DCO_PMIDIS (1 << 29) +#define DCO_IC (1 << 31) + +/* DECCCTRL register defines */ +#define DECCCTRL_SBEEN (1 << 0) +#define DECCCTRL_DBEEN (1 << 1) +#define DECCCTRL_ENCBGEN (1 << 17) + /* DRAM init command */ #define DCMD_MRS1(rnk, dat) (0 | ((rnk) << 22) | (1 << 3) | ((dat) << 6)) #define DCMD_REF(rnk) (1 | ((rnk) << 22)) #define DCMD_PRE(rnk) (2 | ((rnk) << 22)) -#define DCMD_PREA(rnk) (2 | ((rnk) << 22) | (BIT10 << 6)) +#define DCMD_PREA(rnk) (2 | ((rnk) << 22) | (0x400 << 6)) #define DCMD_ACT(rnk, row) (3 | ((rnk) << 22) | ((row) << 6)) #define DCMD_WR(rnk, col) (4 | ((rnk) << 22) | ((col) << 6)) #define DCMD_RD(rnk, col) (5 | ((rnk) << 22) | ((col) << 6)) #define DCMD_ZQCS(rnk) (6 | ((rnk) << 22)) -#define DCMD_ZQCL(rnk) (6 | ((rnk) << 22) | (BIT10 << 6)) +#define DCMD_ZQCL(rnk) (6 | ((rnk) << 22) | (0x400 << 6)) #define DCMD_NOP(rnk) (7 | ((rnk) << 22)) -#define DDR3_EMRS1_DIC_40 (0) -#define DDR3_EMRS1_DIC_34 (1) +#define DDR3_EMRS1_DIC_40 0 +#define DDR3_EMRS1_DIC_34 1 -#define DDR3_EMRS1_RTTNOM_0 (0) -#define DDR3_EMRS1_RTTNOM_60 (0x04) -#define DDR3_EMRS1_RTTNOM_120 (0x40) -#define DDR3_EMRS1_RTTNOM_40 (0x44) -#define DDR3_EMRS1_RTTNOM_20 (0x200) -#define DDR3_EMRS1_RTTNOM_30 (0x204) +#define DDR3_EMRS1_RTTNOM_0 0 +#define DDR3_EMRS1_RTTNOM_60 0x04 +#define DDR3_EMRS1_RTTNOM_120 0x40 +#define DDR3_EMRS1_RTTNOM_40 0x44 +#define DDR3_EMRS1_RTTNOM_20 0x200 +#define DDR3_EMRS1_RTTNOM_30 0x204 #define DDR3_EMRS2_RTTWR_60 (1 << 9) #define DDR3_EMRS2_RTTWR_120 (1 << 10) @@ -80,87 +167,87 @@ #define DQOBSCKEBBCTL 0x0000 #define DQDLLTXCTL 0x0004 #define DQDLLRXCTL 0x0008 -#define DQMDLLCTL 0x000C +#define DQMDLLCTL 0x000c #define B0RXIOBUFCTL 0x0010 #define B0VREFCTL 0x0014 #define B0RXOFFSET1 0x0018 -#define B0RXOFFSET0 0x001C +#define B0RXOFFSET0 0x001c #define B1RXIOBUFCTL 0x0020 #define B1VREFCTL 0x0024 #define B1RXOFFSET1 0x0028 -#define B1RXOFFSET0 0x002C +#define B1RXOFFSET0 0x002c #define DQDFTCTL 0x0030 #define DQTRAINSTS 0x0034 #define B1DLLPICODER0 0x0038 -#define B0DLLPICODER0 0x003C +#define B0DLLPICODER0 0x003c #define B1DLLPICODER1 0x0040 #define B0DLLPICODER1 0x0044 #define B1DLLPICODER2 0x0048 -#define B0DLLPICODER2 0x004C +#define B0DLLPICODER2 0x004c #define B1DLLPICODER3 0x0050 #define B0DLLPICODER3 0x0054 #define B1RXDQSPICODE 0x0058 -#define B0RXDQSPICODE 0x005C +#define B0RXDQSPICODE 0x005c #define B1RXDQPICODER32 0x0060 #define B1RXDQPICODER10 0x0064 #define B0RXDQPICODER32 0x0068 -#define B0RXDQPICODER10 0x006C +#define B0RXDQPICODER10 0x006c #define B01PTRCTL0 0x0070 #define B01PTRCTL1 0x0074 #define B01DBCTL0 0x0078 -#define B01DBCTL1 0x007C +#define B01DBCTL1 0x007c #define B0LATCTL0 0x0080 #define B1LATCTL0 0x0084 #define B01LATCTL1 0x0088 -#define B0ONDURCTL 0x008C +#define B0ONDURCTL 0x008c #define B1ONDURCTL 0x0090 #define B0OVRCTL 0x0094 #define B1OVRCTL 0x0098 -#define DQCTL 0x009C -#define B0RK2RKCHGPTRCTRL 0x00A0 -#define B1RK2RKCHGPTRCTRL 0x00A4 -#define DQRK2RKCTL 0x00A8 -#define DQRK2RKPTRCTL 0x00AC -#define B0RK2RKLAT 0x00B0 -#define B1RK2RKLAT 0x00B4 -#define DQCLKALIGNREG0 0x00B8 -#define DQCLKALIGNREG1 0x00BC -#define DQCLKALIGNREG2 0x00C0 -#define DQCLKALIGNSTS0 0x00C4 -#define DQCLKALIGNSTS1 0x00C8 -#define DQCLKGATE 0x00CC -#define B0COMPSLV1 0x00D0 -#define B1COMPSLV1 0x00D4 -#define B0COMPSLV2 0x00D8 -#define B1COMPSLV2 0x00DC -#define B0COMPSLV3 0x00E0 -#define B1COMPSLV3 0x00E4 -#define DQVISALANECR0TOP 0x00E8 -#define DQVISALANECR1TOP 0x00EC -#define DQVISACONTROLCRTOP 0x00F0 -#define DQVISALANECR0BL 0x00F4 -#define DQVISALANECR1BL 0x00F8 -#define DQVISACONTROLCRBL 0x00FC -#define DQTIMINGCTRL 0x010C +#define DQCTL 0x009c +#define B0RK2RKCHGPTRCTRL 0x00a0 +#define B1RK2RKCHGPTRCTRL 0x00a4 +#define DQRK2RKCTL 0x00a8 +#define DQRK2RKPTRCTL 0x00ac +#define B0RK2RKLAT 0x00b0 +#define B1RK2RKLAT 0x00b4 +#define DQCLKALIGNREG0 0x00b8 +#define DQCLKALIGNREG1 0x00bc +#define DQCLKALIGNREG2 0x00c0 +#define DQCLKALIGNSTS0 0x00c4 +#define DQCLKALIGNSTS1 0x00c8 +#define DQCLKGATE 0x00cc +#define B0COMPSLV1 0x00d0 +#define B1COMPSLV1 0x00d4 +#define B0COMPSLV2 0x00d8 +#define B1COMPSLV2 0x00dc +#define B0COMPSLV3 0x00e0 +#define B1COMPSLV3 0x00e4 +#define DQVISALANECR0TOP 0x00e8 +#define DQVISALANECR1TOP 0x00ec +#define DQVISACONTROLCRTOP 0x00f0 +#define DQVISALANECR0BL 0x00f4 +#define DQVISALANECR1BL 0x00f8 +#define DQVISACONTROLCRBL 0x00fc +#define DQTIMINGCTRL 0x010c /* CH0-ECC */ #define ECCDLLTXCTL 0x2004 #define ECCDLLRXCTL 0x2008 -#define ECCMDLLCTL 0x200C +#define ECCMDLLCTL 0x200c #define ECCB1DLLPICODER0 0x2038 #define ECCB1DLLPICODER1 0x2040 #define ECCB1DLLPICODER2 0x2048 #define ECCB1DLLPICODER3 0x2050 #define ECCB01DBCTL0 0x2078 -#define ECCB01DBCTL1 0x207C -#define ECCCLKALIGNREG0 0x20B8 -#define ECCCLKALIGNREG1 0x20BC -#define ECCCLKALIGNREG2 0x20C0 +#define ECCB01DBCTL1 0x207c +#define ECCCLKALIGNREG0 0x20b8 +#define ECCCLKALIGNREG1 0x20bc +#define ECCCLKALIGNREG2 0x20c0 /* CH0-CMD */ #define CMDOBSCKEBBCTL 0x4800 #define CMDDLLTXCTL 0x4808 -#define CMDDLLRXCTL 0x480C +#define CMDDLLRXCTL 0x480c #define CMDMDLLCTL 0x4810 #define CMDRCOMPODT 0x4814 #define CMDDLLPICODER0 0x4820 @@ -170,30 +257,30 @@ #define CMDCLKALIGNREG0 0x4850 #define CMDCLKALIGNREG1 0x4854 #define CMDCLKALIGNREG2 0x4858 -#define CMDPMCONFIG0 0x485C +#define CMDPMCONFIG0 0x485c #define CMDPMDLYREG0 0x4860 #define CMDPMDLYREG1 0x4864 #define CMDPMDLYREG2 0x4868 -#define CMDPMDLYREG3 0x486C +#define CMDPMDLYREG3 0x486c #define CMDPMDLYREG4 0x4870 #define CMDCLKALIGNSTS0 0x4874 #define CMDCLKALIGNSTS1 0x4878 -#define CMDPMSTS0 0x487C +#define CMDPMSTS0 0x487c #define CMDPMSTS1 0x4880 #define CMDCOMPSLV 0x4884 -#define CMDBONUS0 0x488C +#define CMDBONUS0 0x488c #define CMDBONUS1 0x4890 #define CMDVISALANECR0 0x4894 #define CMDVISALANECR1 0x4898 -#define CMDVISACONTROLCR 0x489C -#define CMDCLKGATE 0x48A0 -#define CMDTIMINGCTRL 0x48A4 +#define CMDVISACONTROLCR 0x489c +#define CMDCLKGATE 0x48a0 +#define CMDTIMINGCTRL 0x48a4 /* CH0-CLK-CTL */ #define CCOBSCKEBBCTL 0x5800 #define CCRCOMPIO 0x5804 #define CCDLLTXCTL 0x5808 -#define CCDLLRXCTL 0x580C +#define CCDLLRXCTL 0x580c #define CCMDLLCTL 0x5810 #define CCRCOMPODT 0x5814 #define CCDLLPICODER0 0x5820 @@ -205,123 +292,123 @@ #define CCCLKALIGNREG0 0x5850 #define CCCLKALIGNREG1 0x5854 #define CCCLKALIGNREG2 0x5858 -#define CCPMCONFIG0 0x585C +#define CCPMCONFIG0 0x585c #define CCPMDLYREG0 0x5860 #define CCPMDLYREG1 0x5864 #define CCPMDLYREG2 0x5868 -#define CCPMDLYREG3 0x586C +#define CCPMDLYREG3 0x586c #define CCPMDLYREG4 0x5870 #define CCCLKALIGNSTS0 0x5874 #define CCCLKALIGNSTS1 0x5878 -#define CCPMSTS0 0x587C +#define CCPMSTS0 0x587c #define CCPMSTS1 0x5880 #define CCCOMPSLV1 0x5884 #define CCCOMPSLV2 0x5888 -#define CCCOMPSLV3 0x588C +#define CCCOMPSLV3 0x588c #define CCBONUS0 0x5894 #define CCBONUS1 0x5898 -#define CCVISALANECR0 0x589C -#define CCVISALANECR1 0x58A0 -#define CCVISACONTROLCR 0x58A4 -#define CCCLKGATE 0x58A8 -#define CCTIMINGCTL 0x58AC +#define CCVISALANECR0 0x589c +#define CCVISALANECR1 0x58a0 +#define CCVISACONTROLCR 0x58a4 +#define CCCLKGATE 0x58a8 +#define CCTIMINGCTL 0x58ac /* COMP */ #define CMPCTRL 0x6800 #define SOFTRSTCNTL 0x6804 #define MSCNTR 0x6808 -#define NMSCNTRL 0x680C +#define NMSCNTRL 0x680c #define LATCH1CTL 0x6814 -#define COMPVISALANECR0 0x681C +#define COMPVISALANECR0 0x681c #define COMPVISALANECR1 0x6820 #define COMPVISACONTROLCR 0x6824 #define COMPBONUS0 0x6830 -#define TCOCNTCTRL 0x683C +#define TCOCNTCTRL 0x683c #define DQANAODTPUCTL 0x6840 #define DQANAODTPDCTL 0x6844 #define DQANADRVPUCTL 0x6848 -#define DQANADRVPDCTL 0x684C +#define DQANADRVPDCTL 0x684c #define DQANADLYPUCTL 0x6850 #define DQANADLYPDCTL 0x6854 #define DQANATCOPUCTL 0x6858 -#define DQANATCOPDCTL 0x685C +#define DQANATCOPDCTL 0x685c #define CMDANADRVPUCTL 0x6868 -#define CMDANADRVPDCTL 0x686C +#define CMDANADRVPDCTL 0x686c #define CMDANADLYPUCTL 0x6870 #define CMDANADLYPDCTL 0x6874 #define CLKANAODTPUCTL 0x6880 #define CLKANAODTPDCTL 0x6884 #define CLKANADRVPUCTL 0x6888 -#define CLKANADRVPDCTL 0x688C +#define CLKANADRVPDCTL 0x688c #define CLKANADLYPUCTL 0x6890 #define CLKANADLYPDCTL 0x6894 #define CLKANATCOPUCTL 0x6898 -#define CLKANATCOPDCTL 0x689C -#define DQSANAODTPUCTL 0x68A0 -#define DQSANAODTPDCTL 0x68A4 -#define DQSANADRVPUCTL 0x68A8 -#define DQSANADRVPDCTL 0x68AC -#define DQSANADLYPUCTL 0x68B0 -#define DQSANADLYPDCTL 0x68B4 -#define DQSANATCOPUCTL 0x68B8 -#define DQSANATCOPDCTL 0x68BC -#define CTLANADRVPUCTL 0x68C8 -#define CTLANADRVPDCTL 0x68CC -#define CTLANADLYPUCTL 0x68D0 -#define CTLANADLYPDCTL 0x68D4 -#define CHNLBUFSTATIC 0x68F0 -#define COMPOBSCNTRL 0x68F4 -#define COMPBUFFDBG0 0x68F8 -#define COMPBUFFDBG1 0x68FC +#define CLKANATCOPDCTL 0x689c +#define DQSANAODTPUCTL 0x68a0 +#define DQSANAODTPDCTL 0x68a4 +#define DQSANADRVPUCTL 0x68a8 +#define DQSANADRVPDCTL 0x68ac +#define DQSANADLYPUCTL 0x68b0 +#define DQSANADLYPDCTL 0x68b4 +#define DQSANATCOPUCTL 0x68b8 +#define DQSANATCOPDCTL 0x68bc +#define CTLANADRVPUCTL 0x68c8 +#define CTLANADRVPDCTL 0x68cc +#define CTLANADLYPUCTL 0x68d0 +#define CTLANADLYPDCTL 0x68d4 +#define CHNLBUFSTATIC 0x68f0 +#define COMPOBSCNTRL 0x68f4 +#define COMPBUFFDBG0 0x68f8 +#define COMPBUFFDBG1 0x68fc #define CFGMISCCH0 0x6900 #define COMPEN0CH0 0x6904 #define COMPEN1CH0 0x6908 -#define COMPEN2CH0 0x690C +#define COMPEN2CH0 0x690c #define STATLEGEN0CH0 0x6910 #define STATLEGEN1CH0 0x6914 #define DQVREFCH0 0x6918 -#define CMDVREFCH0 0x691C +#define CMDVREFCH0 0x691c #define CLKVREFCH0 0x6920 #define DQSVREFCH0 0x6924 #define CTLVREFCH0 0x6928 -#define TCOVREFCH0 0x692C +#define TCOVREFCH0 0x692c #define DLYSELCH0 0x6930 #define TCODRAMBUFODTCH0 0x6934 #define CCBUFODTCH0 0x6938 -#define RXOFFSETCH0 0x693C +#define RXOFFSETCH0 0x693c #define DQODTPUCTLCH0 0x6940 #define DQODTPDCTLCH0 0x6944 #define DQDRVPUCTLCH0 0x6948 -#define DQDRVPDCTLCH0 0x694C +#define DQDRVPDCTLCH0 0x694c #define DQDLYPUCTLCH0 0x6950 #define DQDLYPDCTLCH0 0x6954 #define DQTCOPUCTLCH0 0x6958 -#define DQTCOPDCTLCH0 0x695C +#define DQTCOPDCTLCH0 0x695c #define CMDDRVPUCTLCH0 0x6968 -#define CMDDRVPDCTLCH0 0x696C +#define CMDDRVPDCTLCH0 0x696c #define CMDDLYPUCTLCH0 0x6970 #define CMDDLYPDCTLCH0 0x6974 #define CLKODTPUCTLCH0 0x6980 #define CLKODTPDCTLCH0 0x6984 #define CLKDRVPUCTLCH0 0x6988 -#define CLKDRVPDCTLCH0 0x698C +#define CLKDRVPDCTLCH0 0x698c #define CLKDLYPUCTLCH0 0x6990 #define CLKDLYPDCTLCH0 0x6994 #define CLKTCOPUCTLCH0 0x6998 -#define CLKTCOPDCTLCH0 0x699C -#define DQSODTPUCTLCH0 0x69A0 -#define DQSODTPDCTLCH0 0x69A4 -#define DQSDRVPUCTLCH0 0x69A8 -#define DQSDRVPDCTLCH0 0x69AC -#define DQSDLYPUCTLCH0 0x69B0 -#define DQSDLYPDCTLCH0 0x69B4 -#define DQSTCOPUCTLCH0 0x69B8 -#define DQSTCOPDCTLCH0 0x69BC -#define CTLDRVPUCTLCH0 0x69C8 -#define CTLDRVPDCTLCH0 0x69CC -#define CTLDLYPUCTLCH0 0x69D0 -#define CTLDLYPDCTLCH0 0x69D4 -#define FNLUPDTCTLCH0 0x69F0 +#define CLKTCOPDCTLCH0 0x699c +#define DQSODTPUCTLCH0 0x69a0 +#define DQSODTPDCTLCH0 0x69a4 +#define DQSDRVPUCTLCH0 0x69a8 +#define DQSDRVPDCTLCH0 0x69ac +#define DQSDLYPUCTLCH0 0x69b0 +#define DQSDLYPDCTLCH0 0x69b4 +#define DQSTCOPUCTLCH0 0x69b8 +#define DQSTCOPDCTLCH0 0x69bc +#define CTLDRVPUCTLCH0 0x69c8 +#define CTLDRVPDCTLCH0 0x69cc +#define CTLDLYPUCTLCH0 0x69d0 +#define CTLDLYPDCTLCH0 0x69d4 +#define FNLUPDTCTLCH0 0x69f0 /* PLL */ #define MPLLCTRL0 0x7800 @@ -332,17 +419,17 @@ #define MPLLDFT 0x7828 #define MPLLMON0CTL 0x7830 #define MPLLMON1CTL 0x7838 -#define MPLLMON2CTL 0x783C +#define MPLLMON2CTL 0x783c #define SFRTRIM 0x7850 #define MPLLDFTOUT0 0x7858 -#define MPLLDFTOUT1 0x785C +#define MPLLDFTOUT1 0x785c #define MASTERRSTN 0x7880 #define PLLLOCKDEL 0x7884 #define SFRDEL 0x7888 -#define CRUVISALANECR0 0x78F0 -#define CRUVISALANECR1 0x78F4 -#define CRUVISACONTROLCR 0x78F8 -#define IOSFVISALANECR0 0x78FC +#define CRUVISALANECR0 0x78f0 +#define CRUVISALANECR1 0x78f4 +#define CRUVISACONTROLCR 0x78f8 +#define IOSFVISALANECR0 0x78fc #define IOSFVISALANECR1 0x7900 #define IOSFVISACONTROLCR 0x7904 @@ -350,7 +437,7 @@ /* DRAM Specific Message Bus OpCodes */ #define MSG_OP_DRAM_INIT 0x68 -#define MSG_OP_DRAM_WAKE 0xCA +#define MSG_OP_DRAM_WAKE 0xca #define SAMPLE_SIZE 6 @@ -377,9 +464,9 @@ /* offset into "vref_codes[]" for minimum allowed VREF setting */ #define VREF_MIN 0x00 /* offset into "vref_codes[]" for maximum allowed VREF setting */ -#define VREF_MAX 0x3F +#define VREF_MAX 0x3f #define RDQS_MIN 0x00 /* minimum RDQS delay value */ -#define RDQS_MAX 0x3F /* maximum RDQS delay value */ +#define RDQS_MAX 0x3f /* maximum RDQS delay value */ /* how many WDQ codes to jump while margining */ #define WDQ_STEP 1 -- cgit v0.10.2 From 1c854dc5d4d4ce3ddec08a319d1c094ade8dabe7 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 19 Feb 2015 06:58:57 -0500 Subject: arch/x86/cpu/quark/mrc.c: Switch to U_BOOT_DATE / U_BOOT_TIME Using __DATE__ and __TIME__ results in an error due to -Werror=date-time with gcc-4.9 (__DATE__ / __TIME__ might prevent reproducible builds) so switch these over to U_BOOT_DATE / U_BOOT_TIME Cc: Bin Meng Cc: Simon Glass Signed-off-by: Tom Rini Acked-by: Simon Glass diff --git a/arch/x86/cpu/quark/mrc.c b/arch/x86/cpu/quark/mrc.c index 65734e9..6e774cb 100644 --- a/arch/x86/cpu/quark/mrc.c +++ b/arch/x86/cpu/quark/mrc.c @@ -34,6 +34,7 @@ */ #include +#include #include #include #include "mrc_util.h" @@ -192,7 +193,7 @@ void mrc_init(struct mrc_params *mrc_params) ENTERFN(); DPF(D_INFO, "MRC Version %04x %s %s\n", MRC_VERSION, - __DATE__, __TIME__); + U_BOOT_DATE, U_BOOT_TIME); /* Set up the data structures used by mrc_mem_init() */ mrc_adjust_params(mrc_params); -- cgit v0.10.2 From 0eb9dc76e2987a07de9101e026ff26b28fa7496b Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 4 Mar 2015 15:08:26 +0800 Subject: fdtdec: Improve fdtdec_get_pci_bdf() documentation Add the description that how the compatible property is involved in the fdtdec_get_pci_bdf() documentation. Signed-off-by: Bin Meng Acked-by: Simon Glass diff --git a/include/fdtdec.h b/include/fdtdec.h index 5ac515d..11a7b86 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -347,7 +347,10 @@ int fdtdec_get_pci_vendev(const void *blob, int node, /** * Look at the pci address of a device node that represents a PCI device - * and parse the bus, device and function number from it. + * and parse the bus, device and function number from it. For some cases + * like the bus number encoded in reg property is not correct after pci + * enumeration, this function looks through the node's compatible strings + * to get these numbers extracted instead. * * @param blob FDT blob * @param node node to examine -- cgit v0.10.2 From 83d9712e70dcd704462a3dc53254a05087c231f0 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Thu, 5 Mar 2015 11:21:03 +0800 Subject: x86: Add queensbay fsp patch information in README.x86 The FSP release version 001 for Intel Queensbay has a bug which could cause random endless loop during the FspInit call. This bug was published by Intel although Intel did not describe any details. Describe this information in the x86 doc so that U-Boot Queensbay support is invulnerable. Signed-off-by: Bin Meng Acked-by: Simon Glass diff --git a/doc/README.x86 b/doc/README.x86 index fb87682..0355d1c 100644 --- a/doc/README.x86 +++ b/doc/README.x86 @@ -105,6 +105,13 @@ in this FSP package too. Rename the first one to fsp.bin and second one to cmc.bin and put them in the board directory. +Note the FSP release version 001 has a bug which could cause random endless +loop during the FspInit call. This bug was published by Intel although Intel +did not describe any details. We need manually apply the patch to the FSP +binary using any hex editor (eg: bvi). Go to the offset 0x1fcd8 of the FSP +binary, change the following five bytes values from orginally E8 42 FF FF FF +to B8 00 80 0B 00. + Now you can build U-Boot and obtain u-boot.rom $ make crownbay_defconfig -- cgit v0.10.2 From e4ad6031a79fb3182613f95423ebcd771309679d Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Mar 2015 11:25:56 +0800 Subject: x86: quark: Enable on-chip ethernet controllers Intel Quark SoC integrates two 10/100 ethernet controllers which can be connected to an external RMII PHY. The MAC IP is from Designware. Enable this support with the existing U-Boot Designware MAC driver so that the ethernet port on Intel Galileo board can be used. Signed-off-by: Bin Meng Acked-by: Simon Glass diff --git a/arch/x86/cpu/quark/quark.c b/arch/x86/cpu/quark/quark.c index dccf7ac..25edcf7 100644 --- a/arch/x86/cpu/quark/quark.c +++ b/arch/x86/cpu/quark/quark.c @@ -6,6 +6,8 @@ #include #include +#include +#include #include #include #include @@ -116,3 +118,20 @@ int cpu_mmc_init(bd_t *bis) return pci_mmc_init("Quark SDHCI", mmc_supported, ARRAY_SIZE(mmc_supported)); } + +int cpu_eth_init(bd_t *bis) +{ + u32 base; + int ret0, ret1; + + pci_read_config_dword(QUARK_EMAC0, PCI_BASE_ADDRESS_0, &base); + ret0 = designware_initialize(base, PHY_INTERFACE_MODE_RMII); + + pci_read_config_dword(QUARK_EMAC1, PCI_BASE_ADDRESS_0, &base); + ret1 = designware_initialize(base, PHY_INTERFACE_MODE_RMII); + + if (ret0 < 0 && ret1 < 0) + return -1; + else + return 0; +} diff --git a/include/configs/galileo.h b/include/configs/galileo.h index d745f4e..65a2c3e 100644 --- a/include/configs/galileo.h +++ b/include/configs/galileo.h @@ -57,4 +57,9 @@ #define CONFIG_MMC_SDMA #define CONFIG_CMD_MMC +/* 10/100M Ethernet support */ +#define CONFIG_DESIGNWARE_ETH +#define CONFIG_DW_ALTDESCRIPTOR +#define CONFIG_PHYLIB + #endif /* __CONFIG_H */ -- cgit v0.10.2 From a7c3d5e2a9f4d0feb1e21733434e6d29f5ac566b Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Fri, 20 Mar 2015 17:12:18 +0800 Subject: net: Add ethernet FCS length macro in net.h Some ethernet drivers use their own version of ethernet FCS length macro which is really common. We define ETH_FCS_LEN in net.h and replace those custom versions in various places. Signed-off-by: Bin Meng Acked-by: Joe Hershberger diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h index 6d110eb..f3b77b1 100644 --- a/drivers/net/e1000.h +++ b/drivers/net/e1000.h @@ -430,12 +430,11 @@ struct e1000_phy_stats { #define ENET_HEADER_SIZE 14 #define MAXIMUM_ETHERNET_FRAME_SIZE 1518 /* With FCS */ #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ -#define ETHERNET_FCS_SIZE 4 #define MAXIMUM_ETHERNET_PACKET_SIZE \ - (MAXIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE) + (MAXIMUM_ETHERNET_FRAME_SIZE - ETH_FCS_LEN) #define MINIMUM_ETHERNET_PACKET_SIZE \ - (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE) -#define CRC_LENGTH ETHERNET_FCS_SIZE + (MINIMUM_ETHERNET_FRAME_SIZE - ETH_FCS_LEN) +#define CRC_LENGTH ETH_FCS_LEN #define MAX_JUMBO_FRAME_SIZE 0x3F00 /* 802.1q VLAN Packet Sizes */ diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index ba442d5..8f03a6b 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -68,7 +68,6 @@ unsigned packet_received, packet_sent; #define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ #define ETH_DATA_LEN 1500 /* Max. octets in payload */ #define ETH_FRAME_LEN PKTSIZE_ALIGN /* Max. octets in frame sans FCS */ -#define ETH_FCS_LEN 4 /* Octets in the FCS */ #define DRIVER_DESC "Ethernet Gadget" /* Based on linux 2.6.27 version */ diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 404a7b9..62c9b2e 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -43,7 +43,6 @@ #define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ #define ETH_DATA_LEN 1500 /* Max. octets in payload */ #define ETH_FRAME_LEN PKTSIZE_ALIGN /* Max. octets in frame sans FCS */ -#define ETH_FCS_LEN 4 /* Octets in the FCS */ #define ENOTSUPP 524 /* Operation is not supported */ diff --git a/include/net.h b/include/net.h index 43e3d28..237c932 100644 --- a/include/net.h +++ b/include/net.h @@ -191,6 +191,8 @@ struct ethernet_hdr { /* Ethernet header size */ #define ETHER_HDR_SIZE (sizeof(struct ethernet_hdr)) +#define ETH_FCS_LEN 4 /* Octets in the FCS */ + struct e802_hdr { uchar et_dest[6]; /* Destination node */ uchar et_src[6]; /* Source node */ diff --git a/include/usb_ether.h b/include/usb_ether.h index b38d037..23507e1 100644 --- a/include/usb_ether.h +++ b/include/usb_ether.h @@ -18,7 +18,6 @@ #define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ #define ETH_DATA_LEN 1500 /* Max. octets in payload */ #define ETH_FRAME_LEN PKTSIZE_ALIGN /* Max. octets in frame sans FCS */ -#define ETH_FCS_LEN 4 /* Octets in the FCS */ struct ueth_data { /* eth info */ -- cgit v0.10.2 From c58ea6cb8c01b4e43e414cdc26bc29ad52284f21 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Fri, 20 Mar 2015 17:12:19 +0800 Subject: net: Update README.drivers.eth to mention latest APIs README.drivers.eth still refers to the deprecated miiphy_register(). Update the doc to mention new APIs mdio_alloc() and mdio_register(). Signed-off-by: Bin Meng Acked-by: Joe Hershberger diff --git a/doc/README.drivers.eth b/doc/README.drivers.eth index eb83038..42af442 100644 --- a/doc/README.drivers.eth +++ b/doc/README.drivers.eth @@ -43,15 +43,16 @@ int ape_register(bd_t *bis, int iobase) { struct ape_priv *priv; struct eth_device *dev; + struct mii_dev *bus; priv = malloc(sizeof(*priv)); if (priv == NULL) - return 1; + return -ENOMEM; dev = malloc(sizeof(*dev)); if (dev == NULL) { free(priv); - return 1; + return -ENOMEM; } /* setup whatever private state you need */ @@ -59,7 +60,8 @@ int ape_register(bd_t *bis, int iobase) memset(dev, 0, sizeof(*dev)); sprintf(dev->name, "APE"); - /* if your device has dedicated hardware storage for the + /* + * if your device has dedicated hardware storage for the * MAC, read it and initialize dev->enetaddr with it */ ape_mac_read(dev->enetaddr); @@ -74,8 +76,17 @@ int ape_register(bd_t *bis, int iobase) eth_register(dev); -#ifdef CONFIG_CMD_MII) - miiphy_register(dev->name, ape_mii_read, ape_mii_write); +#ifdef CONFIG_PHYLIB + bus = mdio_alloc(); + if (!bus) { + free(priv); + free(dev); + return -ENOMEM; + } + + bus->read = ape_mii_read; + bus->write = ape_mii_write; + mdio_register(bus); #endif return 1; @@ -166,25 +177,33 @@ some net operation (ping / tftp / whatever...) eth_halt() dev->halt() ------------------------------ - CONFIG_MII / CONFIG_CMD_MII ------------------------------ +-------------------------------- + CONFIG_PHYLIB / CONFIG_CMD_MII +-------------------------------- If your device supports banging arbitrary values on the MII bus (pretty much every device does), you should add support for the mii command. Doing so is fairly trivial and makes debugging mii issues a lot easier at runtime. After you have called eth_register() in your driver's register function, add -a call to miiphy_register() like so: -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) - miiphy_register(dev->name, mii_read, mii_write); -#endif +a call to mdio_alloc() and mdio_register() like so: + bus = mdio_alloc(); + if (!bus) { + free(priv); + free(dev); + return -ENOMEM; + } + + bus->read = ape_mii_read; + bus->write = ape_mii_write; + mdio_register(bus); And then define the mii_read and mii_write functions if you haven't already. Their syntax is straightforward: - int mii_read(char *devname, uchar addr, uchar reg, ushort *val); - int mii_write(char *devname, uchar addr, uchar reg, ushort val); + int mii_read(struct mii_dev *bus, int addr, int devad, int reg); + int mii_write(struct mii_dev *bus, int addr, int devad, int reg, + u16 val); The read function should read the register 'reg' from the phy at address 'addr' -and store the result in the pointer 'val'. The implementation for the write -function should logically follow. +and return the result to its caller. The implementation for the write function +should logically follow. -- cgit v0.10.2 From 8ee443b8ebb6f533e5f42d8da05600a1996a4dfd Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Fri, 20 Mar 2015 17:12:20 +0800 Subject: net: Add Intel Topcliff GMAC driver Add a new driver for the Gigabit Ethernet MAC found on Intel Topcliff Platform Controller Hub. Tested under 10/100 half/full duplex and 1000 full duplex modes using ping and tftpboot commands. Signed-off-by: Bin Meng Acked-by: Joe Hershberger diff --git a/drivers/net/Makefile b/drivers/net/Makefile index b8b0803..3ff86b7 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o obj-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o obj-$(CONFIG_NETCONSOLE) += netconsole.o obj-$(CONFIG_NS8382X) += ns8382x.o +obj-$(CONFIG_PCH_GBE) += pch_gbe.o obj-$(CONFIG_PCNET) += pcnet.o obj-$(CONFIG_RTL8139) += rtl8139.o obj-$(CONFIG_RTL8169) += rtl8169.o diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c new file mode 100644 index 0000000..976848d --- /dev/null +++ b/drivers/net/pch_gbe.c @@ -0,0 +1,466 @@ +/* + * Copyright (C) 2015, Bin Meng + * + * Intel Platform Controller Hub EG20T (codename Topcliff) GMAC Driver + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include "pch_gbe.h" + +#if !defined(CONFIG_PHYLIB) +# error "PCH Gigabit Ethernet driver requires PHYLIB - missing CONFIG_PHYLIB" +#endif + +static struct pci_device_id supported[] = { + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_GBE }, + { } +}; + +static void pch_gbe_mac_read(struct pch_gbe_regs *mac_regs, u8 *addr) +{ + u32 macid_hi, macid_lo; + + macid_hi = readl(&mac_regs->mac_adr[0].high); + macid_lo = readl(&mac_regs->mac_adr[0].low) & 0xffff; + debug("pch_gbe: macid_hi %#x macid_lo %#x\n", macid_hi, macid_lo); + + addr[0] = (u8)(macid_hi & 0xff); + addr[1] = (u8)((macid_hi >> 8) & 0xff); + addr[2] = (u8)((macid_hi >> 16) & 0xff); + addr[3] = (u8)((macid_hi >> 24) & 0xff); + addr[4] = (u8)(macid_lo & 0xff); + addr[5] = (u8)((macid_lo >> 8) & 0xff); +} + +static int pch_gbe_mac_write(struct pch_gbe_regs *mac_regs, u8 *addr) +{ + u32 macid_hi, macid_lo; + ulong start; + + macid_hi = addr[0] + (addr[1] << 8) + (addr[2] << 16) + (addr[3] << 24); + macid_lo = addr[4] + (addr[5] << 8); + + writel(macid_hi, &mac_regs->mac_adr[0].high); + writel(macid_lo, &mac_regs->mac_adr[0].low); + writel(0xfffe, &mac_regs->addr_mask); + + start = get_timer(0); + while (get_timer(start) < PCH_GBE_TIMEOUT) { + if (!(readl(&mac_regs->addr_mask) & PCH_GBE_BUSY)) + return 0; + + udelay(10); + } + + return -ETIME; +} + +static int pch_gbe_reset(struct eth_device *dev) +{ + struct pch_gbe_priv *priv = dev->priv; + struct pch_gbe_regs *mac_regs = priv->mac_regs; + ulong start; + + priv->rx_idx = 0; + priv->tx_idx = 0; + + writel(PCH_GBE_ALL_RST, &mac_regs->reset); + + /* + * Configure the MAC to RGMII mode after reset + * + * For some unknown reason, we must do the configuration here right + * after resetting the whole MAC, otherwise the reset bit in the RESET + * register will never be cleared by the hardware. And there is another + * way of having the same magic, that is to configure the MODE register + * to have the MAC work in MII/GMII mode, which is how current Linux + * pch_gbe driver does. Since anyway we need program the MAC to RGMII + * mode in the driver, we just do it here. + * + * Note: this behavior is not documented in the hardware manual. + */ + writel(PCH_GBE_RGMII_MODE_RGMII | PCH_GBE_CHIP_TYPE_INTERNAL, + &mac_regs->rgmii_ctrl); + + start = get_timer(0); + while (get_timer(start) < PCH_GBE_TIMEOUT) { + if (!(readl(&mac_regs->reset) & PCH_GBE_ALL_RST)) { + /* + * Soft reset clears hardware MAC address registers, + * so we have to reload MAC address here in order to + * make linux pch_gbe driver happy. + */ + return pch_gbe_mac_write(mac_regs, dev->enetaddr); + } + + udelay(10); + } + + debug("pch_gbe: reset timeout\n"); + return -ETIME; +} + +static void pch_gbe_rx_descs_init(struct eth_device *dev) +{ + struct pch_gbe_priv *priv = dev->priv; + struct pch_gbe_regs *mac_regs = priv->mac_regs; + struct pch_gbe_rx_desc *rx_desc = &priv->rx_desc[0]; + int i; + + memset(rx_desc, 0, sizeof(struct pch_gbe_rx_desc) * PCH_GBE_DESC_NUM); + for (i = 0; i < PCH_GBE_DESC_NUM; i++) + rx_desc->buffer_addr = pci_phys_to_mem(priv->bdf, + (u32)(priv->rx_buff[i])); + + writel(pci_phys_to_mem(priv->bdf, (u32)rx_desc), + &mac_regs->rx_dsc_base); + writel(sizeof(struct pch_gbe_rx_desc) * (PCH_GBE_DESC_NUM - 1), + &mac_regs->rx_dsc_size); + + writel(pci_phys_to_mem(priv->bdf, (u32)(rx_desc + 1)), + &mac_regs->rx_dsc_sw_p); +} + +static void pch_gbe_tx_descs_init(struct eth_device *dev) +{ + struct pch_gbe_priv *priv = dev->priv; + struct pch_gbe_regs *mac_regs = priv->mac_regs; + struct pch_gbe_tx_desc *tx_desc = &priv->tx_desc[0]; + + memset(tx_desc, 0, sizeof(struct pch_gbe_tx_desc) * PCH_GBE_DESC_NUM); + + writel(pci_phys_to_mem(priv->bdf, (u32)tx_desc), + &mac_regs->tx_dsc_base); + writel(sizeof(struct pch_gbe_tx_desc) * (PCH_GBE_DESC_NUM - 1), + &mac_regs->tx_dsc_size); + writel(pci_phys_to_mem(priv->bdf, (u32)(tx_desc + 1)), + &mac_regs->tx_dsc_sw_p); +} + +static void pch_gbe_adjust_link(struct pch_gbe_regs *mac_regs, + struct phy_device *phydev) +{ + if (!phydev->link) { + printf("%s: No link.\n", phydev->dev->name); + return; + } + + clrbits_le32(&mac_regs->rgmii_ctrl, + PCH_GBE_RGMII_RATE_2_5M | PCH_GBE_CRS_SEL); + clrbits_le32(&mac_regs->mode, + PCH_GBE_MODE_GMII_ETHER | PCH_GBE_MODE_FULL_DUPLEX); + + switch (phydev->speed) { + case 1000: + setbits_le32(&mac_regs->rgmii_ctrl, PCH_GBE_RGMII_RATE_125M); + setbits_le32(&mac_regs->mode, PCH_GBE_MODE_GMII_ETHER); + break; + case 100: + setbits_le32(&mac_regs->rgmii_ctrl, PCH_GBE_RGMII_RATE_25M); + setbits_le32(&mac_regs->mode, PCH_GBE_MODE_MII_ETHER); + break; + case 10: + setbits_le32(&mac_regs->rgmii_ctrl, PCH_GBE_RGMII_RATE_2_5M); + setbits_le32(&mac_regs->mode, PCH_GBE_MODE_MII_ETHER); + break; + } + + if (phydev->duplex) { + setbits_le32(&mac_regs->rgmii_ctrl, PCH_GBE_CRS_SEL); + setbits_le32(&mac_regs->mode, PCH_GBE_MODE_FULL_DUPLEX); + } + + printf("Speed: %d, %s duplex\n", phydev->speed, + (phydev->duplex) ? "full" : "half"); + + return; +} + +static int pch_gbe_init(struct eth_device *dev, bd_t *bis) +{ + struct pch_gbe_priv *priv = dev->priv; + struct pch_gbe_regs *mac_regs = priv->mac_regs; + + if (pch_gbe_reset(dev)) + return -1; + + pch_gbe_rx_descs_init(dev); + pch_gbe_tx_descs_init(dev); + + /* Enable frame bursting */ + writel(PCH_GBE_MODE_FR_BST, &mac_regs->mode); + /* Disable TCP/IP accelerator */ + writel(PCH_GBE_RX_TCPIPACC_OFF, &mac_regs->tcpip_acc); + /* Disable RX flow control */ + writel(0, &mac_regs->rx_fctrl); + /* Configure RX/TX mode */ + writel(PCH_GBE_RH_ALM_EMP_16 | PCH_GBE_RH_ALM_FULL_16 | + PCH_GBE_RH_RD_TRG_32, &mac_regs->rx_mode); + writel(PCH_GBE_TM_TH_TX_STRT_32 | PCH_GBE_TM_TH_ALM_EMP_16 | + PCH_GBE_TM_TH_ALM_FULL_32 | PCH_GBE_TM_ST_AND_FD | + PCH_GBE_TM_SHORT_PKT, &mac_regs->tx_mode); + + /* Start up the PHY */ + if (phy_startup(priv->phydev)) { + printf("Could not initialize PHY %s\n", + priv->phydev->dev->name); + return -1; + } + + pch_gbe_adjust_link(mac_regs, priv->phydev); + + if (!priv->phydev->link) + return -1; + + /* Enable TX & RX */ + writel(PCH_GBE_RX_DMA_EN | PCH_GBE_TX_DMA_EN, &mac_regs->dma_ctrl); + writel(PCH_GBE_MRE_MAC_RX_EN, &mac_regs->mac_rx_en); + + return 0; +} + +static void pch_gbe_halt(struct eth_device *dev) +{ + struct pch_gbe_priv *priv = dev->priv; + + pch_gbe_reset(dev); + + phy_shutdown(priv->phydev); +} + +static int pch_gbe_send(struct eth_device *dev, void *packet, int length) +{ + struct pch_gbe_priv *priv = dev->priv; + struct pch_gbe_regs *mac_regs = priv->mac_regs; + struct pch_gbe_tx_desc *tx_head, *tx_desc; + u16 frame_ctrl = 0; + u32 int_st; + ulong start; + + tx_head = &priv->tx_desc[0]; + tx_desc = &priv->tx_desc[priv->tx_idx]; + + if (length < 64) + frame_ctrl |= PCH_GBE_TXD_CTRL_APAD; + + tx_desc->buffer_addr = pci_phys_to_mem(priv->bdf, (u32)packet); + tx_desc->length = length; + tx_desc->tx_words_eob = length + 3; + tx_desc->tx_frame_ctrl = frame_ctrl; + tx_desc->dma_status = 0; + tx_desc->gbec_status = 0; + + /* Test the wrap-around condition */ + if (++priv->tx_idx >= PCH_GBE_DESC_NUM) + priv->tx_idx = 0; + + writel(pci_phys_to_mem(priv->bdf, (u32)(tx_head + priv->tx_idx)), + &mac_regs->tx_dsc_sw_p); + + start = get_timer(0); + while (get_timer(start) < PCH_GBE_TIMEOUT) { + int_st = readl(&mac_regs->int_st); + if (int_st & PCH_GBE_INT_TX_CMPLT) + return 0; + + udelay(10); + } + + debug("pch_gbe: sent failed\n"); + return -ETIME; +} + +static int pch_gbe_recv(struct eth_device *dev) +{ + struct pch_gbe_priv *priv = dev->priv; + struct pch_gbe_regs *mac_regs = priv->mac_regs; + struct pch_gbe_rx_desc *rx_head, *rx_desc; + u32 hw_desc, buffer_addr, length; + int rx_swp; + + rx_head = &priv->rx_desc[0]; + rx_desc = &priv->rx_desc[priv->rx_idx]; + + readl(&mac_regs->int_st); + hw_desc = readl(&mac_regs->rx_dsc_hw_p_hld); + + /* Just return if not receiving any packet */ + if ((u32)rx_desc == hw_desc) + return 0; + + buffer_addr = pci_mem_to_phys(priv->bdf, rx_desc->buffer_addr); + length = rx_desc->rx_words_eob - 3 - ETH_FCS_LEN; + NetReceive((uchar *)buffer_addr, length); + + /* Test the wrap-around condition */ + if (++priv->rx_idx >= PCH_GBE_DESC_NUM) + priv->rx_idx = 0; + rx_swp = priv->rx_idx; + if (++rx_swp >= PCH_GBE_DESC_NUM) + rx_swp = 0; + + writel(pci_phys_to_mem(priv->bdf, (u32)(rx_head + rx_swp)), + &mac_regs->rx_dsc_sw_p); + + return length; +} + +static int pch_gbe_mdio_ready(struct pch_gbe_regs *mac_regs) +{ + ulong start = get_timer(0); + + while (get_timer(start) < PCH_GBE_TIMEOUT) { + if (readl(&mac_regs->miim) & PCH_GBE_MIIM_OPER_READY) + return 0; + + udelay(10); + } + + return -ETIME; +} + +static int pch_gbe_mdio_read(struct mii_dev *bus, int addr, int devad, int reg) +{ + struct pch_gbe_regs *mac_regs = bus->priv; + u32 miim; + + if (pch_gbe_mdio_ready(mac_regs)) + return -ETIME; + + miim = (addr << PCH_GBE_MIIM_PHY_ADDR_SHIFT) | + (reg << PCH_GBE_MIIM_REG_ADDR_SHIFT) | + PCH_GBE_MIIM_OPER_READ; + writel(miim, &mac_regs->miim); + + if (pch_gbe_mdio_ready(mac_regs)) + return -ETIME; + + return readl(&mac_regs->miim) & 0xffff; +} + +static int pch_gbe_mdio_write(struct mii_dev *bus, int addr, int devad, + int reg, u16 val) +{ + struct pch_gbe_regs *mac_regs = bus->priv; + u32 miim; + + if (pch_gbe_mdio_ready(mac_regs)) + return -ETIME; + + miim = (addr << PCH_GBE_MIIM_PHY_ADDR_SHIFT) | + (reg << PCH_GBE_MIIM_REG_ADDR_SHIFT) | + PCH_GBE_MIIM_OPER_WRITE | val; + writel(miim, &mac_regs->miim); + + if (pch_gbe_mdio_ready(mac_regs)) + return -ETIME; + else + return 0; +} + +static int pch_gbe_mdio_init(char *name, struct pch_gbe_regs *mac_regs) +{ + struct mii_dev *bus; + + bus = mdio_alloc(); + if (!bus) { + debug("pch_gbe: failed to allocate MDIO bus\n"); + return -ENOMEM; + } + + bus->read = pch_gbe_mdio_read; + bus->write = pch_gbe_mdio_write; + sprintf(bus->name, name); + + bus->priv = (void *)mac_regs; + + return mdio_register(bus); +} + +static int pch_gbe_phy_init(struct eth_device *dev) +{ + struct pch_gbe_priv *priv = dev->priv; + struct phy_device *phydev; + int mask = 0xffffffff; + + phydev = phy_find_by_mask(priv->bus, mask, priv->interface); + if (!phydev) { + printf("pch_gbe: cannot find the phy\n"); + return -1; + } + + phy_connect_dev(phydev, dev); + + phydev->supported &= PHY_GBIT_FEATURES; + phydev->advertising = phydev->supported; + + priv->phydev = phydev; + phy_config(phydev); + + return 1; +} + +int pch_gbe_register(bd_t *bis) +{ + struct eth_device *dev; + struct pch_gbe_priv *priv; + pci_dev_t devno; + u32 iobase; + + devno = pci_find_devices(supported, 0); + if (devno == -1) + return -ENODEV; + + dev = (struct eth_device *)malloc(sizeof(*dev)); + if (!dev) + return -ENOMEM; + memset(dev, 0, sizeof(*dev)); + + /* + * The priv structure contains the descriptors and frame buffers which + * need a strict buswidth alignment (64 bytes) + */ + priv = (struct pch_gbe_priv *)memalign(PCH_GBE_ALIGN_SIZE, + sizeof(*priv)); + if (!priv) { + free(dev); + return -ENOMEM; + } + memset(priv, 0, sizeof(*priv)); + + dev->priv = priv; + priv->dev = dev; + priv->bdf = devno; + + pci_read_config_dword(devno, PCI_BASE_ADDRESS_1, &iobase); + iobase &= PCI_BASE_ADDRESS_MEM_MASK; + iobase = pci_mem_to_phys(devno, iobase); + + dev->iobase = iobase; + priv->mac_regs = (struct pch_gbe_regs *)iobase; + + sprintf(dev->name, "pch_gbe.%x", iobase); + + /* Read MAC address from SROM and initialize dev->enetaddr with it */ + pch_gbe_mac_read(priv->mac_regs, dev->enetaddr); + + dev->init = pch_gbe_init; + dev->halt = pch_gbe_halt; + dev->send = pch_gbe_send; + dev->recv = pch_gbe_recv; + + eth_register(dev); + + priv->interface = PHY_INTERFACE_MODE_RGMII; + pch_gbe_mdio_init(dev->name, priv->mac_regs); + priv->bus = miiphy_get_dev_by_name(dev->name); + + return pch_gbe_phy_init(dev); +} diff --git a/drivers/net/pch_gbe.h b/drivers/net/pch_gbe.h new file mode 100644 index 0000000..11329d4 --- /dev/null +++ b/drivers/net/pch_gbe.h @@ -0,0 +1,300 @@ +/* + * Copyright (C) 2015, Bin Meng + * + * Intel Platform Controller Hub EG20T (codename Topcliff) GMAC Driver + * Adapted from linux drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _PCH_GBE_H_ +#define _PCH_GBE_H_ + +#define PCH_GBE_TIMEOUT (3 * CONFIG_SYS_HZ) + +#define PCH_GBE_DESC_NUM 4 +#define PCH_GBE_ALIGN_SIZE 64 + +/* + * Topcliff GBE MAC supports receiving ethernet frames with normal frame size + * (64-1518 bytes) as well as up to 10318 bytes, however it does not have a + * register bit to turn off receiving 'jumbo frame', so we have to allocate + * our own buffer to store the received frames instead of using U-Boot's own. + */ +#define PCH_GBE_RX_FRAME_LEN ROUND(10318, PCH_GBE_ALIGN_SIZE) + +/* Interrupt Status */ +/* Interrupt Status Hold */ +/* Interrupt Enable */ +#define PCH_GBE_INT_RX_DMA_CMPLT 0x00000001 +#define PCH_GBE_INT_RX_VALID 0x00000002 +#define PCH_GBE_INT_RX_FRAME_ERR 0x00000004 +#define PCH_GBE_INT_RX_FIFO_ERR 0x00000008 +#define PCH_GBE_INT_RX_DMA_ERR 0x00000010 +#define PCH_GBE_INT_RX_DSC_EMP 0x00000020 +#define PCH_GBE_INT_TX_CMPLT 0x00000100 +#define PCH_GBE_INT_TX_DMA_CMPLT 0x00000200 +#define PCH_GBE_INT_TX_FIFO_ERR 0x00000400 +#define PCH_GBE_INT_TX_DMA_ERR 0x00000800 +#define PCH_GBE_INT_PAUSE_CMPLT 0x00001000 +#define PCH_GBE_INT_MIIM_CMPLT 0x00010000 +#define PCH_GBE_INT_PHY_INT 0x00100000 +#define PCH_GBE_INT_WOL_DET 0x01000000 +#define PCH_GBE_INT_TCPIP_ERR 0x10000000 + +/* Mode */ +#define PCH_GBE_MODE_MII_ETHER 0x00000000 +#define PCH_GBE_MODE_GMII_ETHER 0x80000000 +#define PCH_GBE_MODE_HALF_DUPLEX 0x00000000 +#define PCH_GBE_MODE_FULL_DUPLEX 0x40000000 +#define PCH_GBE_MODE_FR_BST 0x04000000 + +/* Reset */ +#define PCH_GBE_ALL_RST 0x80000000 +#define PCH_GBE_TX_RST 0x00008000 +#define PCH_GBE_RX_RST 0x00004000 + +/* TCP/IP Accelerator Control */ +#define PCH_GBE_EX_LIST_EN 0x00000008 +#define PCH_GBE_RX_TCPIPACC_OFF 0x00000004 +#define PCH_GBE_TX_TCPIPACC_EN 0x00000002 +#define PCH_GBE_RX_TCPIPACC_EN 0x00000001 + +/* MAC RX Enable */ +#define PCH_GBE_MRE_MAC_RX_EN 0x00000001 + +/* RX Flow Control */ +#define PCH_GBE_FL_CTRL_EN 0x80000000 + +/* RX Mode */ +#define PCH_GBE_ADD_FIL_EN 0x80000000 +#define PCH_GBE_MLT_FIL_EN 0x40000000 +#define PCH_GBE_RH_ALM_EMP_4 0x00000000 +#define PCH_GBE_RH_ALM_EMP_8 0x00004000 +#define PCH_GBE_RH_ALM_EMP_16 0x00008000 +#define PCH_GBE_RH_ALM_EMP_32 0x0000c000 +#define PCH_GBE_RH_ALM_FULL_4 0x00000000 +#define PCH_GBE_RH_ALM_FULL_8 0x00001000 +#define PCH_GBE_RH_ALM_FULL_16 0x00002000 +#define PCH_GBE_RH_ALM_FULL_32 0x00003000 +#define PCH_GBE_RH_RD_TRG_4 0x00000000 +#define PCH_GBE_RH_RD_TRG_8 0x00000200 +#define PCH_GBE_RH_RD_TRG_16 0x00000400 +#define PCH_GBE_RH_RD_TRG_32 0x00000600 +#define PCH_GBE_RH_RD_TRG_64 0x00000800 +#define PCH_GBE_RH_RD_TRG_128 0x00000a00 +#define PCH_GBE_RH_RD_TRG_256 0x00000c00 +#define PCH_GBE_RH_RD_TRG_512 0x00000e00 + +/* TX Mode */ +#define PCH_GBE_TM_NO_RTRY 0x80000000 +#define PCH_GBE_TM_LONG_PKT 0x40000000 +#define PCH_GBE_TM_ST_AND_FD 0x20000000 +#define PCH_GBE_TM_SHORT_PKT 0x10000000 +#define PCH_GBE_TM_LTCOL_RETX 0x08000000 +#define PCH_GBE_TM_TH_TX_STRT_4 0x00000000 +#define PCH_GBE_TM_TH_TX_STRT_8 0x00004000 +#define PCH_GBE_TM_TH_TX_STRT_16 0x00008000 +#define PCH_GBE_TM_TH_TX_STRT_32 0x0000c000 +#define PCH_GBE_TM_TH_ALM_EMP_4 0x00000000 +#define PCH_GBE_TM_TH_ALM_EMP_8 0x00000800 +#define PCH_GBE_TM_TH_ALM_EMP_16 0x00001000 +#define PCH_GBE_TM_TH_ALM_EMP_32 0x00001800 +#define PCH_GBE_TM_TH_ALM_EMP_64 0x00002000 +#define PCH_GBE_TM_TH_ALM_EMP_128 0x00002800 +#define PCH_GBE_TM_TH_ALM_EMP_256 0x00003000 +#define PCH_GBE_TM_TH_ALM_EMP_512 0x00003800 +#define PCH_GBE_TM_TH_ALM_FULL_4 0x00000000 +#define PCH_GBE_TM_TH_ALM_FULL_8 0x00000200 +#define PCH_GBE_TM_TH_ALM_FULL_16 0x00000400 +#define PCH_GBE_TM_TH_ALM_FULL_32 0x00000600 + +/* MAC Address Mask */ +#define PCH_GBE_BUSY 0x80000000 + +/* MIIM */ +#define PCH_GBE_MIIM_OPER_WRITE 0x04000000 +#define PCH_GBE_MIIM_OPER_READ 0x00000000 +#define PCH_GBE_MIIM_OPER_READY 0x04000000 +#define PCH_GBE_MIIM_PHY_ADDR_SHIFT 21 +#define PCH_GBE_MIIM_REG_ADDR_SHIFT 16 + +/* RGMII Control */ +#define PCH_GBE_CRS_SEL 0x00000010 +#define PCH_GBE_RGMII_RATE_125M 0x00000000 +#define PCH_GBE_RGMII_RATE_25M 0x00000008 +#define PCH_GBE_RGMII_RATE_2_5M 0x0000000c +#define PCH_GBE_RGMII_MODE_GMII 0x00000000 +#define PCH_GBE_RGMII_MODE_RGMII 0x00000002 +#define PCH_GBE_CHIP_TYPE_EXTERNAL 0x00000000 +#define PCH_GBE_CHIP_TYPE_INTERNAL 0x00000001 + +/* DMA Control */ +#define PCH_GBE_RX_DMA_EN 0x00000002 +#define PCH_GBE_TX_DMA_EN 0x00000001 + +/* Receive Descriptor bit definitions */ +#define PCH_GBE_RXD_ACC_STAT_BCAST 0x00000400 +#define PCH_GBE_RXD_ACC_STAT_MCAST 0x00000200 +#define PCH_GBE_RXD_ACC_STAT_UCAST 0x00000100 +#define PCH_GBE_RXD_ACC_STAT_TCPIPOK 0x000000c0 +#define PCH_GBE_RXD_ACC_STAT_IPOK 0x00000080 +#define PCH_GBE_RXD_ACC_STAT_TCPOK 0x00000040 +#define PCH_GBE_RXD_ACC_STAT_IP6ERR 0x00000020 +#define PCH_GBE_RXD_ACC_STAT_OFLIST 0x00000010 +#define PCH_GBE_RXD_ACC_STAT_TYPEIP 0x00000008 +#define PCH_GBE_RXD_ACC_STAT_MACL 0x00000004 +#define PCH_GBE_RXD_ACC_STAT_PPPOE 0x00000002 +#define PCH_GBE_RXD_ACC_STAT_VTAGT 0x00000001 +#define PCH_GBE_RXD_GMAC_STAT_PAUSE 0x0200 +#define PCH_GBE_RXD_GMAC_STAT_MARBR 0x0100 +#define PCH_GBE_RXD_GMAC_STAT_MARMLT 0x0080 +#define PCH_GBE_RXD_GMAC_STAT_MARIND 0x0040 +#define PCH_GBE_RXD_GMAC_STAT_MARNOTMT 0x0020 +#define PCH_GBE_RXD_GMAC_STAT_TLONG 0x0010 +#define PCH_GBE_RXD_GMAC_STAT_TSHRT 0x0008 +#define PCH_GBE_RXD_GMAC_STAT_NOTOCTAL 0x0004 +#define PCH_GBE_RXD_GMAC_STAT_NBLERR 0x0002 +#define PCH_GBE_RXD_GMAC_STAT_CRCERR 0x0001 + +/* Transmit Descriptor bit definitions */ +#define PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF 0x0008 +#define PCH_GBE_TXD_CTRL_ITAG 0x0004 +#define PCH_GBE_TXD_CTRL_ICRC 0x0002 +#define PCH_GBE_TXD_CTRL_APAD 0x0001 +#define PCH_GBE_TXD_WORDS_SHIFT 2 +#define PCH_GBE_TXD_GMAC_STAT_CMPLT 0x2000 +#define PCH_GBE_TXD_GMAC_STAT_ABT 0x1000 +#define PCH_GBE_TXD_GMAC_STAT_EXCOL 0x0800 +#define PCH_GBE_TXD_GMAC_STAT_SNGCOL 0x0400 +#define PCH_GBE_TXD_GMAC_STAT_MLTCOL 0x0200 +#define PCH_GBE_TXD_GMAC_STAT_CRSER 0x0100 +#define PCH_GBE_TXD_GMAC_STAT_TLNG 0x0080 +#define PCH_GBE_TXD_GMAC_STAT_TSHRT 0x0040 +#define PCH_GBE_TXD_GMAC_STAT_LTCOL 0x0020 +#define PCH_GBE_TXD_GMAC_STAT_TFUNDFLW 0x0010 + +/** + * struct pch_gbe_rx_desc - Receive Descriptor + * @buffer_addr: RX Frame Buffer Address + * @tcp_ip_status: TCP/IP Accelerator Status + * @rx_words_eob: RX word count and Byte position + * @gbec_status: GMAC Status + * @dma_status: DMA Status + * @reserved1: Reserved + * @reserved2: Reserved + */ +struct pch_gbe_rx_desc { + u32 buffer_addr; + u32 tcp_ip_status; + u16 rx_words_eob; + u16 gbec_status; + u8 dma_status; + u8 reserved1; + u16 reserved2; +}; + +/** + * struct pch_gbe_tx_desc - Transmit Descriptor + * @buffer_addr: TX Frame Buffer Address + * @length: Data buffer length + * @reserved1: Reserved + * @tx_words_eob: TX word count and Byte position + * @tx_frame_ctrl: TX Frame Control + * @dma_status: DMA Status + * @reserved2: Reserved + * @gbec_status: GMAC Status + */ +struct pch_gbe_tx_desc { + u32 buffer_addr; + u16 length; + u16 reserved1; + u16 tx_words_eob; + u16 tx_frame_ctrl; + u8 dma_status; + u8 reserved2; + u16 gbec_status; +}; + +/** + * pch_gbe_regs_mac_adr - structure holding values of mac address registers + * + * @high Denotes the 1st to 4th byte from the initial of MAC address + * @low Denotes the 5th to 6th byte from the initial of MAC address + */ +struct pch_gbe_regs_mac_adr { + u32 high; + u32 low; +}; + +/** + * pch_gbe_regs - structure holding values of MAC registers + */ +struct pch_gbe_regs { + u32 int_st; + u32 int_en; + u32 mode; + u32 reset; + u32 tcpip_acc; + u32 ex_list; + u32 int_st_hold; + u32 phy_int_ctrl; + u32 mac_rx_en; + u32 rx_fctrl; + u32 pause_req; + u32 rx_mode; + u32 tx_mode; + u32 rx_fifo_st; + u32 tx_fifo_st; + u32 tx_fid; + u32 tx_result; + u32 pause_pkt1; + u32 pause_pkt2; + u32 pause_pkt3; + u32 pause_pkt4; + u32 pause_pkt5; + u32 reserve[2]; + struct pch_gbe_regs_mac_adr mac_adr[16]; + u32 addr_mask; + u32 miim; + u32 mac_addr_load; + u32 rgmii_st; + u32 rgmii_ctrl; + u32 reserve3[3]; + u32 dma_ctrl; + u32 reserve4[3]; + u32 rx_dsc_base; + u32 rx_dsc_size; + u32 rx_dsc_hw_p; + u32 rx_dsc_hw_p_hld; + u32 rx_dsc_sw_p; + u32 reserve5[3]; + u32 tx_dsc_base; + u32 tx_dsc_size; + u32 tx_dsc_hw_p; + u32 tx_dsc_hw_p_hld; + u32 tx_dsc_sw_p; + u32 reserve6[3]; + u32 rx_dma_st; + u32 tx_dma_st; + u32 reserve7[2]; + u32 wol_st; + u32 wol_ctrl; + u32 wol_addr_mask; +}; + +struct pch_gbe_priv { + struct pch_gbe_rx_desc rx_desc[PCH_GBE_DESC_NUM]; + struct pch_gbe_tx_desc tx_desc[PCH_GBE_DESC_NUM]; + char rx_buff[PCH_GBE_DESC_NUM][PCH_GBE_RX_FRAME_LEN]; + struct eth_device *dev; + struct phy_device *phydev; + struct mii_dev *bus; + struct pch_gbe_regs *mac_regs; + pci_dev_t bdf; + u32 interface; + int rx_idx; + int tx_idx; +}; + +#endif /* _PCH_GBE_H_ */ diff --git a/include/netdev.h b/include/netdev.h index 90140bd..c69533e 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -69,6 +69,7 @@ int natsemi_initialize(bd_t *bis); int ne2k_register(void); int npe_initialize(bd_t *bis); int ns8382x_initialize(bd_t *bis); +int pch_gbe_register(bd_t *bis); int pcnet_initialize(bd_t *bis); int ppc_4xx_eth_initialize (bd_t *bis); int rtl8139_initialize(bd_t *bis); @@ -123,6 +124,9 @@ static inline int pci_eth_init(bd_t *bis) #ifdef CONFIG_E1000 num += e1000_initialize(bis); #endif +#ifdef CONFIG_PCH_GBE + num += pch_gbe_register(bis); +#endif #ifdef CONFIG_PCNET num += pcnet_initialize(bis); #endif -- cgit v0.10.2 From a84134f72147bc31babba8006f8a9bdc55bc5a03 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Fri, 20 Mar 2015 17:12:21 +0800 Subject: x86: crownbay: Enable Intel Topcliff GMAC support Intel Crown Bay board has one ethernet port connected from Intel Topcliff PCH. Enable it in the board configuration. Signed-off-by: Bin Meng Reviewed-by: Joe Hershberger diff --git a/include/configs/crownbay.h b/include/configs/crownbay.h index b927b1c..b1cfc8b 100644 --- a/include/configs/crownbay.h +++ b/include/configs/crownbay.h @@ -52,6 +52,10 @@ #define CONFIG_MMC_SDMA #define CONFIG_CMD_MMC +/* Topcliff Gigabit Ethernet */ +#define CONFIG_PCH_GBE +#define CONFIG_PHYLIB + /* Video is not supported */ #undef CONFIG_VIDEO #undef CONFIG_CFB_CONSOLE -- cgit v0.10.2 From fba02d69c6fc7f7861ada6181ab6097d20495027 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Mar 2015 17:22:28 +0800 Subject: x86: crownbay: Enable saving environment in SPI flash Saving U-Boot's environment in SPI flash on Intel CrownBay board. Signed-off-by: Bin Meng Acked-by: Simon Glass diff --git a/include/configs/crownbay.h b/include/configs/crownbay.h index b1cfc8b..df32f2a 100644 --- a/include/configs/crownbay.h +++ b/include/configs/crownbay.h @@ -60,4 +60,12 @@ #undef CONFIG_VIDEO #undef CONFIG_CFB_CONSOLE +/* Environment configuration */ +#undef CONFIG_ENV_IS_NOWHERE +#undef CONFIG_ENV_SIZE +#define CONFIG_ENV_IS_IN_SPI_FLASH +#define CONFIG_ENV_SIZE 0x1000 +#define CONFIG_ENV_SECT_SIZE 0x1000 +#define CONFIG_ENV_OFFSET 0 + #endif /* __CONFIG_H */ -- cgit v0.10.2 From bea59393c88ba86f6433f8c277478f312ff0acf3 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Mar 2015 17:22:29 +0800 Subject: x86: galileo: Enable saving environment in SPI flash Saving U-Boot's environment in SPI flash on Intel Galileo board. Signed-off-by: Bin Meng Acked-by: Simon Glass diff --git a/include/configs/galileo.h b/include/configs/galileo.h index 65a2c3e..288acf3 100644 --- a/include/configs/galileo.h +++ b/include/configs/galileo.h @@ -62,4 +62,12 @@ #define CONFIG_DW_ALTDESCRIPTOR #define CONFIG_PHYLIB +/* Environment configuration */ +#undef CONFIG_ENV_IS_NOWHERE +#undef CONFIG_ENV_SIZE +#define CONFIG_ENV_IS_IN_SPI_FLASH +#define CONFIG_ENV_SIZE 0x1000 +#define CONFIG_ENV_SECT_SIZE 0x1000 +#define CONFIG_ENV_OFFSET 0 + #endif /* __CONFIG_H */ -- cgit v0.10.2 From 6f1eba49a558421e3fcb06ab0addc12b9a3804c6 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Thu, 12 Mar 2015 13:08:46 +0800 Subject: x86: Add ramboot and nfsboot commands in x86-common.h It is very common in the debug stage to test U-Boot loading a linux kernel. The commands to boot linux kernel with ramdisk and nfs as the root are common to all x86 targets, so it makes sense to add them as the U-Boot default environment in x86-common.h. Signed-off-by: Bin Meng Acked-by: Simon Glass diff --git a/include/configs/x86-common.h b/include/configs/x86-common.h index 994874c..b7dd63e 100644 --- a/include/configs/x86-common.h +++ b/include/configs/x86-common.h @@ -243,7 +243,34 @@ #define CONFIG_CMD_USB -#define CONFIG_EXTRA_ENV_SETTINGS \ - CONFIG_STD_DEVICES_SETTINGS +/* Default environment */ +#define CONFIG_ROOTPATH "/opt/nfsroot" +#define CONFIG_HOSTNAME "x86" +#define CONFIG_BOOTFILE "bzImage" +#define CONFIG_LOADADDR 0x1000000 + +#define CONFIG_EXTRA_ENV_SETTINGS \ + CONFIG_STD_DEVICES_SETTINGS \ + "netdev=eth0\0" \ + "consoledev=ttyS0\0" \ + "othbootargs=acpi=off\0" \ + "ramdiskaddr=0x2000000\0" \ + "ramdiskfile=initramfs.gz\0" + +#define CONFIG_RAMBOOTCOMMAND \ + "setenv bootargs root=/dev/ram rw " \ + "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off " \ + "console=$consoledev,$baudrate $othbootargs;" \ + "tftpboot $loadaddr $bootfile;" \ + "tftpboot $ramdiskaddr $ramdiskfile;" \ + "zboot $loadaddr 0 $ramdiskaddr $filesize" + +#define CONFIG_NFSBOOTCOMMAND \ + "setenv bootargs root=/dev/nfs rw " \ + "nfsroot=$serverip:$rootpath " \ + "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off " \ + "console=$consoledev,$baudrate $othbootargs;" \ + "tftpboot $loadaddr $bootfile;" \ + "zboot $loadaddr" #endif /* __CONFIG_H */ -- cgit v0.10.2 From 5cab874052614fb130cd9b16fc6a3d27cae0741e Mon Sep 17 00:00:00 2001 From: Sebastian Siewior Date: Tue, 3 Mar 2015 17:45:43 +0100 Subject: watchdog/imx_watchdog: do not set WCR_WDW with WCR_WDW set, the watchdog won't trigger if we bootet linux and idle around while the watchdog is not triggered. It seems the timer makes progress very slowly if at all. I managed to remain 20minutes alive while the timeout was set to 60secs. It reboots within 60secs if I start a busyloop in userland (something like "while (1) { }"). While I don't see a reason why the WDT should not be running while the CPU is in idle, I'm dropping this bit. Signed-off-by: Sebastian Andrzej Siewior Acked-by: Stefano Babic diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index d5993b4..1d18d4b 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -20,7 +20,6 @@ struct watchdog_regs { #define WCR_WDE 0x04 /* WDOG enable */ #define WCR_WDT 0x08 #define WCR_SRS 0x10 -#define WCR_WDW 0x80 #define SET_WCR_WT(x) (x << 8) #ifdef CONFIG_IMX_WATCHDOG @@ -47,7 +46,7 @@ void hw_watchdog_init(void) #endif timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1; writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT | WCR_SRS | - WCR_WDW | SET_WCR_WT(timeout), &wdog->wcr); + SET_WCR_WT(timeout), &wdog->wcr); hw_watchdog_reset(); } #endif -- cgit v0.10.2 From 891ee87e2b4586012ce5bacd9149177f61de4ad5 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 20 Mar 2015 13:24:45 +0900 Subject: dm: serial: remove bogus include Serial-uclass should be generically implemented without depending a particular hardware. Fortunately, nothing in include/ns16550.h is referenced from drivers/serial/serial-uclass.c, so remove this bogus include. Signed-off-by: Masahiro Yamada Reviewed-by: Tom Rini Acked-by: Simon Glass diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 3fc7104..2de3737 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -16,8 +16,6 @@ #include #include -#include - DECLARE_GLOBAL_DATA_PTR; /* -- cgit v0.10.2 From a923abc2d3044324e3c88af7776469a31edf3121 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 25 Mar 2015 13:39:05 +0000 Subject: sunxi: set GMAC TX delay = 0x1 on Cubietruck. Of 4 boards in our automated test system 2 do not have reliable networking with the default TX delay of 0x0. Increasing to 0x1 seems to make things reliable on all 4 boards. Some previous ad-hpoc tests with tx delay set to 0, 1, 2 and 3 on one of the problematic boards showed: 0: mw.l 0x1c20164 0x006 1 -- t/o in 4/5 tftp runs 1: mw.l 0x1c20164 0x406 1 -- t/o in 1/5 tftp runs 2: mw.l 0x1c20164 0x806 1 -- t/o in 1/5 tftp runs 3: mw.l 0x1c20164 0xc06 1 -- t/o many times in first tftp run For 0, 1 and 2 "t/o" means one or two "T" glitches in the download, but it did complete. For 3 those were basically continuous and it couldn't complete. tftp was of a 16M initrd. Signed-off-by: Ian Campbell Acked-by: Hans de Goede Signed-off-by: Hans de Goede diff --git a/configs/Cubietruck_defconfig b/configs/Cubietruck_defconfig index 5c23bc7..fa48331 100644 --- a/configs/Cubietruck_defconfig +++ b/configs/Cubietruck_defconfig @@ -1,6 +1,7 @@ CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPH(12),USB_EHCI" CONFIG_FDTFILE="sun7i-a20-cubietruck.dtb" +CONFIG_GMAC_TX_DELAY=1 CONFIG_VIDEO_VGA=y CONFIG_ARM=y CONFIG_ARCH_SUNXI=y -- cgit v0.10.2 From 99deda1dff206d679fcc87949b7151df0d47ea73 Mon Sep 17 00:00:00 2001 From: Iain Paton Date: Wed, 25 Mar 2015 16:03:26 +0000 Subject: sunxi: axp209: fix incorrect limits on ldo3 board/sunxi/board.c tries to set ldo3 to 2.8v however drivers/power/axp209.c contains an incorrect limit on ldo3 of 2.275v The origin of the incorrect limit seems likely due to some inconsistencies in the axp209 datasheet. ldo3 is described with different limits in different sections. register 0x29 uses 7 bits for voltage configuration while the 2.275v limit would apply if only 6 bits were used. Probably this is a cut&paste error from register 0x23 The linux kernel driver has the correct limit and operation up to the 2.8v required by my board has been physically verified with a multimeter. Signed-off-by: Iain Paton Acked-by: Hans de Goede Signed-off-by: Hans de Goede diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c index 4565398..f8c9b77 100644 --- a/drivers/power/axp209.c +++ b/drivers/power/axp209.c @@ -119,7 +119,7 @@ int axp209_set_ldo3(int mvolt) if (mvolt == -1) cfg = 0x80; /* determined by LDO3IN pin */ else - cfg = axp209_mvolt_to_cfg(mvolt, 700, 2275, 25); + cfg = axp209_mvolt_to_cfg(mvolt, 700, 3500, 25); return axp209_write(AXP209_LDO3_VOLTAGE, cfg); } -- cgit v0.10.2 From 97ec89e5012510ca0d86e994740eab2e697dd047 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 13 Mar 2015 18:08:54 +0900 Subject: kbuild: remove "*_felconfig" target This target was added by commit cbdd9a9737cc (sunxi: kconfig: Add %_felconfig rule to enable FEL build of sunxi platforms.). At that time, U-Boot used separate .config files for U-Boot proper and SPL. I understood the pain to modify both .config and spl/.config. Now, we have switched to single .config configuration. It seems acceptable to run "make menuconfig" or friends to enable CONFIG_SPL_FEL, as we do for other CONFIGs. Signed-off-by: Masahiro Yamada Cc: Ian Campbell Cc: Hans de Goede Reviewed-by: Simon Glass diff --git a/scripts/multiconfig.sh b/scripts/multiconfig.sh index cc8a787..9c6b256 100755 --- a/scripts/multiconfig.sh +++ b/scripts/multiconfig.sh @@ -70,16 +70,6 @@ do_board_defconfig () { cleanup_after_defconfig } -do_board_felconfig () { - do_board_defconfig ${1%%_felconfig}_defconfig - if ! grep -q CONFIG_ARCH_SUNXI=y .config || ! grep -q CONFIG_SPL=y .config ; then - echo "$progname: Cannot felconfig a non-sunxi or non-SPL platform" >&2 - exit 1 - fi - sed -i -e 's/\# CONFIG_SPL_FEL is not set/CONFIG_SPL_FEL=y\nCONFIG_UART0_PORT_F=n/g' \ - .config -} - do_others () { run_make_config $1 } @@ -90,8 +80,6 @@ target=$1 case $target in *_defconfig) do_board_defconfig $target;; -*_felconfig) - do_board_felconfig $target;; *_config) # backward compatibility do_board_defconfig ${target%_config}_defconfig;; -- cgit v0.10.2 From 5f9eb2207500f16a598866884f8ee5343ae8949f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 13 Mar 2015 18:08:55 +0900 Subject: kbuild: remove scripts/multiconfig.sh We have switched to the single .config configuration system, the same one as used in Linux Kernel. The necessary glue code is small enough now, so move it to the top-level Makefile and scripts/kconfig/Makefile, and then delete scripts/multiconfig.sh. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass diff --git a/Makefile b/Makefile index 1b3ebe7..346ea27 100644 --- a/Makefile +++ b/Makefile @@ -469,10 +469,10 @@ KBUILD_DEFCONFIG := sandbox_defconfig export KBUILD_DEFCONFIG KBUILD_KCONFIG config: scripts_basic outputmakefile FORCE - +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@ + $(Q)$(MAKE) $(build)=scripts/kconfig $@ %config: scripts_basic outputmakefile FORCE - +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@ + $(Q)$(MAKE) $(build)=scripts/kconfig $@ else # =========================================================================== @@ -496,6 +496,15 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; # we execute the config step to be sure to catch updated Kconfig files include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig + @# If the following part fails, include/config/auto.conf should be + @# deleted so "make silentoldconfig" will be re-run on the next build. + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf || \ + { rm -f include/config/auto.conf; false; } + @# include/config.h has been updated after "make silentoldconfig". + @# We need to touch include/config/auto.conf so it gets newer + @# than include/config.h. + @# Otherwise, 'make silentoldconfig' would be invoked twice. + $(Q)touch include/config/auto.conf -include include/autoconf.mk -include include/autoconf.mk.dep diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 349f770..ff4ce6e 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -5,6 +5,12 @@ PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \ localmodconfig localyesconfig +# Added for U-Boot +# Linux has defconfig files in arch/$(SRCARCH)/configs/, +# on the other hand, U-Boot does in configs/. +# Set SRCARCH to .. fake this Makefile. +SRCARCH := .. + ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG) else @@ -104,6 +110,10 @@ endif %_defconfig: $(obj)/conf $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) +# Added for U-Boot (backward compatibility) +%_config: %_defconfig + @: + configfiles=$(wildcard $(srctree)/kernel/configs/$(1).config $(srctree)/arch/$(SRCARCH)/configs/$(1).config) define mergeconfig diff --git a/scripts/multiconfig.sh b/scripts/multiconfig.sh deleted file mode 100755 index 9c6b256..0000000 --- a/scripts/multiconfig.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -# -# A wrapper script to adjust Kconfig for U-Boot -# -# This file will be removed after cleaning up defconfig files -# -# Copyright (C) 2014, Masahiro Yamada -# -# SPDX-License-Identifier: GPL-2.0+ -# - -set -e - -# Make a configuration target -# Usage: -# run_make_config -# : Make target such as "config", "menuconfig", "defconfig", etc. -run_make_config () { - # Linux expects defconfig files in arch/$(SRCARCH)/configs/ directory, - # but U-Boot has them in configs/ directory. - # Give SRCARCH=.. to fake scripts/kconfig/Makefile. - $MAKE -f $srctree/scripts/Makefile.build obj=scripts/kconfig SRCARCH=.. $1 -} - -do_silentoldconfig () { - run_make_config silentoldconfig - - # If the following part fails, include/config/auto.conf should be - # deleted so "make silentoldconfig" will be re-run on the next build. - $MAKE -f $srctree/scripts/Makefile.autoconf || { - rm -f include/config/auto.conf - exit 1 - } - - # include/config.h has been updated after "make silentoldconfig". - # We need to touch include/config/auto.conf so it gets newer - # than include/config.h. - # Otherwise, 'make silentoldconfig' would be invoked twice. - touch include/config/auto.conf -} - -cleanup_after_defconfig () { - rm -f configs/.tmp_defconfig - # ignore 'Directory not empty' error - # without using non-POSIX option '--ignore-fail-on-non-empty' - rmdir arch configs 2>/dev/null || true -} - -# Usage: -# do_board_defconfig _defconfig -do_board_defconfig () { - defconfig_path=$srctree/configs/$1 - - if [ ! -r $defconfig_path ]; then - echo >&2 "***" - echo >&2 "*** Can't find default configuration \"configs/$1\"!" - echo >&2 "***" - exit 1 - fi - - mkdir -p arch configs - # prefix "*:" is deprecated. Drop it simply. - sed -e 's/^[+A-Z]*://' $defconfig_path > configs/.tmp_defconfig - - run_make_config .tmp_defconfig || { - cleanup_after_defconfig - exit 1 - } - - cleanup_after_defconfig -} - -do_others () { - run_make_config $1 -} - -progname=$(basename $0) -target=$1 - -case $target in -*_defconfig) - do_board_defconfig $target;; -*_config) - # backward compatibility - do_board_defconfig ${target%_config}_defconfig;; -silentoldconfig) - do_silentoldconfig;; -*) - do_others $target;; -esac -- cgit v0.10.2 From 0a12e6872ea2b79c9b3862e7b6c08cc4c1889408 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Mar 2015 19:42:51 +0900 Subject: generic-board: move __HAVE_ARCH_GENERIC_BOARD to Kconfig Move the option to Kconfig renaming it to CONFIG_HAVE_GENERIC_BOARD. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass Reviewed-by: Alexey Brodkin diff --git a/Makefile b/Makefile index 346ea27..0d160c9 100644 --- a/Makefile +++ b/Makefile @@ -1163,7 +1163,7 @@ prepare2: prepare3 outputmakefile prepare1: prepare2 $(version_h) $(timestamp_h) \ include/config/auto.conf -ifeq ($(__HAVE_ARCH_GENERIC_BOARD),) +ifeq ($(CONFIG_HAVE_GENERIC_BOARD),) ifeq ($(CONFIG_SYS_GENERIC_BOARD),y) @echo >&2 " Your architecture does not support generic board." @echo >&2 " Please undefine CONFIG_SYS_GENERIC_BOARD in your board config file." diff --git a/README b/README index b0124d6..5d57eb9 100644 --- a/README +++ b/README @@ -4190,9 +4190,9 @@ Configuration Settings: to this new framework over time. Defining this will disable the arch/foo/lib/board.c file and use common/board_f.c and common/board_r.c instead. To use this option your architecture - must support it (i.e. must define __HAVE_ARCH_GENERIC_BOARD in - its config.mk file). If you find problems enabling this option on - your board please report the problem and send patches! + must support it (i.e. must select HAVE_GENERIC_BOARD in arch/Kconfig). + If you find problems enabling this option on your board please report + the problem and send patches! - CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC (OMAP only) This is set by OMAP boards for the max time that reset should diff --git a/arch/Kconfig b/arch/Kconfig index 3d419bc..cdd1662 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1,3 +1,6 @@ +config HAVE_GENERIC_BOARD + bool + choice prompt "Architecture select" default SANDBOX @@ -5,34 +8,42 @@ choice config ARC bool "ARC architecture" select HAVE_PRIVATE_LIBGCC + select HAVE_GENERIC_BOARD config ARM bool "ARM architecture" select HAVE_PRIVATE_LIBGCC + select HAVE_GENERIC_BOARD select SUPPORT_OF_CONTROL config AVR32 bool "AVR32 architecture" + select HAVE_GENERIC_BOARD config BLACKFIN bool "Blackfin architecture" + select HAVE_GENERIC_BOARD config M68K bool "M68000 architecture" + select HAVE_GENERIC_BOARD config MICROBLAZE bool "MicroBlaze architecture" + select HAVE_GENERIC_BOARD select SUPPORT_OF_CONTROL config MIPS bool "MIPS architecture" select HAVE_PRIVATE_LIBGCC + select HAVE_GENERIC_BOARD config NDS32 bool "NDS32 architecture" config NIOS2 bool "Nios II architecture" + select HAVE_GENERIC_BOARD config OPENRISC bool "OpenRISC architecture" @@ -40,10 +51,12 @@ config OPENRISC config PPC bool "PowerPC architecture" select HAVE_PRIVATE_LIBGCC + select HAVE_GENERIC_BOARD select SUPPORT_OF_CONTROL config SANDBOX bool "Sandbox" + select HAVE_GENERIC_BOARD select SUPPORT_OF_CONTROL config SH @@ -56,6 +69,7 @@ config SPARC config X86 bool "x86 architecture" select HAVE_PRIVATE_LIBGCC + select HAVE_GENERIC_BOARD select SUPPORT_OF_CONTROL endchoice diff --git a/arch/arc/config.mk b/arch/arc/config.mk index 4fcd407..04c034b 100644 --- a/arch/arc/config.mk +++ b/arch/arc/config.mk @@ -57,6 +57,3 @@ LDFLAGS_FINAL += -pie # Load address for standalone apps CONFIG_STANDALONE_LOAD_ADDR ?= 0x82000000 - -# Support generic board on ARC -__HAVE_ARCH_GENERIC_BOARD := y diff --git a/arch/arm/config.mk b/arch/arm/config.mk index 0667984..c005ce4 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -19,9 +19,6 @@ PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \ PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \ $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -# Support generic board on ARM -__HAVE_ARCH_GENERIC_BOARD := y - PLATFORM_CPPFLAGS += -D__ARM__ # Choose between ARM/Thumb instruction sets diff --git a/arch/avr32/config.mk b/arch/avr32/config.mk index 8252f59..469185e 100644 --- a/arch/avr32/config.mk +++ b/arch/avr32/config.mk @@ -9,9 +9,6 @@ ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := avr32-linux- endif -# avr32 has generic board support -__HAVE_ARCH_GENERIC_BOARD := y - CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 PLATFORM_RELFLAGS += -ffixed-r5 -fPIC -mno-init-got -mrelax diff --git a/arch/blackfin/config.mk b/arch/blackfin/config.mk index 584b38b..7b17b75 100644 --- a/arch/blackfin/config.mk +++ b/arch/blackfin/config.mk @@ -20,9 +20,6 @@ CONFIG_BFIN_CPU := $(strip $(CONFIG_BFIN_CPU:"%"=%)) endif CONFIG_BFIN_BOOT_MODE := $(strip $(CONFIG_BFIN_BOOT_MODE:"%"=%)) -# Support generic board on Blackfin -__HAVE_ARCH_GENERIC_BOARD := y - PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic LDFLAGS_FINAL += --gc-sections diff --git a/arch/m68k/config.mk b/arch/m68k/config.mk index a629b68..3b3a7e8 100644 --- a/arch/m68k/config.mk +++ b/arch/m68k/config.mk @@ -11,9 +11,6 @@ endif CONFIG_STANDALONE_LOAD_ADDR ?= 0x20000 -# Support generic board on m68k -__HAVE_ARCH_GENERIC_BOARD := y - PLATFORM_CPPFLAGS += -D__M68K__ PLATFORM_LDFLAGS += -n PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk index 2b817be..e7a3477 100644 --- a/arch/microblaze/config.mk +++ b/arch/microblaze/config.mk @@ -19,4 +19,3 @@ PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__ ifeq ($(CONFIG_SPL_BUILD),) PLATFORM_CPPFLAGS += -fPIC endif -__HAVE_ARCH_GENERIC_BOARD := y diff --git a/arch/mips/config.mk b/arch/mips/config.mk index 4dc88f4..52e28f2 100644 --- a/arch/mips/config.mk +++ b/arch/mips/config.mk @@ -43,8 +43,6 @@ PLATFORM_CPPFLAGS += $(cpuflags-y) PLATFORM_CPPFLAGS += -D__MIPS__ -__HAVE_ARCH_GENERIC_BOARD := y - # # From Linux arch/mips/Makefile # diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk index 9b7c56d..82bd887 100644 --- a/arch/nios2/config.mk +++ b/arch/nios2/config.mk @@ -17,5 +17,3 @@ PLATFORM_CPPFLAGS += -G0 LDFLAGS_FINAL += --gc-sections PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections - -__HAVE_ARCH_GENERIC_BOARD := y diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk index 4110396..83b49b5 100644 --- a/arch/powerpc/config.mk +++ b/arch/powerpc/config.mk @@ -18,9 +18,6 @@ PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections \ PLATFORM_CPPFLAGS += -D__powerpc__ -ffixed-r2 -m32 PLATFORM_LDFLAGS += -m32 -melf32ppclinux -# Support generic board on PPC -__HAVE_ARCH_GENERIC_BOARD := y - # # When cross-compiling on NetBSD, we have to define __PPC__ or else we # will pick up a va_list declaration that is incompatible with the diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 7b84f02..e477a84 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -16,9 +16,6 @@ PLATFORM_CPPFLAGS += $(shell sdl-config --cflags) endif endif -# Support generic board on sandbox -__HAVE_ARCH_GENERIC_BOARD := y - cmd_u-boot__ = $(CC) -o $@ -T u-boot.lds \ -Wl,--start-group $(u-boot-main) -Wl,--end-group \ $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map diff --git a/arch/x86/config.mk b/arch/x86/config.mk index bb2da46..999143e 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -17,9 +17,6 @@ PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86) PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm PLATFORM_CPPFLAGS += -march=i386 -m32 -# Support generic board on x86 -__HAVE_ARCH_GENERIC_BOARD := y - PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions -m elf_i386 diff --git a/doc/README.generic-board b/doc/README.generic-board index 37c1b03..bd8eae1 100644 --- a/doc/README.generic-board +++ b/doc/README.generic-board @@ -44,16 +44,18 @@ The following architectures are supported now: arc arm + avr32 + blackfin + m68k + microblaze mips + nios2 powerpc sandbox x86 -If your architecture is not supported, you need to adjust your -arch//config.mk file to include: - - __HAVE_ARCH_GENERIC_BOARD := y - +If your architecture is not supported, you need to select +HAVE_GENERIC_BOARD in arch/Kconfig and test it with a suitable board, as follows. -- cgit v0.10.2 From 0a9e7ee5bd61507eed40070f4fed238f5a0485b8 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Mar 2015 19:42:52 +0900 Subject: generic-board: select SYS_GENERIC_BOARD for some architectures We have done with the generic board conversion for all the boards of ARC, Blackfin, M68000, MicroBlaze, MIPS, NIOS2, Sandbox, X86. Let's select SYS_GENERIC_BOARD for those architectures, so we can tell which architecture has finished the conversion at a glance. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass Reviewed-by: Alexey Brodkin diff --git a/arch/Kconfig b/arch/Kconfig index cdd1662..ca617e7 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1,6 +1,10 @@ config HAVE_GENERIC_BOARD bool +config SYS_GENERIC_BOARD + bool + depends on HAVE_GENERIC_BOARD + choice prompt "Architecture select" default SANDBOX @@ -9,6 +13,7 @@ config ARC bool "ARC architecture" select HAVE_PRIVATE_LIBGCC select HAVE_GENERIC_BOARD + select SYS_GENERIC_BOARD config ARM bool "ARM architecture" @@ -23,20 +28,24 @@ config AVR32 config BLACKFIN bool "Blackfin architecture" select HAVE_GENERIC_BOARD + select SYS_GENERIC_BOARD config M68K bool "M68000 architecture" select HAVE_GENERIC_BOARD + select SYS_GENERIC_BOARD config MICROBLAZE bool "MicroBlaze architecture" select HAVE_GENERIC_BOARD + select SYS_GENERIC_BOARD select SUPPORT_OF_CONTROL config MIPS bool "MIPS architecture" select HAVE_PRIVATE_LIBGCC select HAVE_GENERIC_BOARD + select SYS_GENERIC_BOARD config NDS32 bool "NDS32 architecture" @@ -44,6 +53,7 @@ config NDS32 config NIOS2 bool "Nios II architecture" select HAVE_GENERIC_BOARD + select SYS_GENERIC_BOARD config OPENRISC bool "OpenRISC architecture" @@ -57,6 +67,7 @@ config PPC config SANDBOX bool "Sandbox" select HAVE_GENERIC_BOARD + select SYS_GENERIC_BOARD select SUPPORT_OF_CONTROL config SH @@ -70,6 +81,7 @@ config X86 bool "x86 architecture" select HAVE_PRIVATE_LIBGCC select HAVE_GENERIC_BOARD + select SYS_GENERIC_BOARD select SUPPORT_OF_CONTROL endchoice diff --git a/arch/arc/include/asm/config.h b/arch/arc/include/asm/config.h index b4e9099..8936f5c 100644 --- a/arch/arc/include/asm/config.h +++ b/arch/arc/include/asm/config.h @@ -7,7 +7,6 @@ #ifndef __ASM_ARC_CONFIG_H_ #define __ASM_ARC_CONFIG_H_ -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_SYS_GENERIC_GLOBAL_DATA #define CONFIG_SYS_BOOT_RAMDISK_HIGH #define CONFIG_ARCH_EARLY_INIT_R diff --git a/arch/blackfin/include/asm/config.h b/arch/blackfin/include/asm/config.h index 73cbfa2..d2cf71b 100644 --- a/arch/blackfin/include/asm/config.h +++ b/arch/blackfin/include/asm/config.h @@ -174,7 +174,6 @@ } #endif -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_CPUINFO #define CONFIG_ARCH_MISC_INIT diff --git a/arch/m68k/include/asm/config.h b/arch/m68k/include/asm/config.h index 7590842..e1458ac 100644 --- a/arch/m68k/include/asm/config.h +++ b/arch/m68k/include/asm/config.h @@ -7,7 +7,6 @@ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_SYS_GENERIC_GLOBAL_DATA #define CONFIG_NEEDS_MANUAL_RELOC diff --git a/arch/microblaze/include/asm/config.h b/arch/microblaze/include/asm/config.h index 32fd636..4af408a 100644 --- a/arch/microblaze/include/asm/config.h +++ b/arch/microblaze/include/asm/config.h @@ -12,6 +12,5 @@ #endif #define CONFIG_NR_DRAM_BANKS 1 -#define CONFIG_SYS_GENERIC_BOARD #endif diff --git a/arch/nios2/include/asm/config.h b/arch/nios2/include/asm/config.h index 476a32b..9c13848 100644 --- a/arch/nios2/include/asm/config.h +++ b/arch/nios2/include/asm/config.h @@ -7,7 +7,6 @@ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_SYS_GENERIC_GLOBAL_DATA #endif diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index e477a84..b05a90f 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-2.0+ PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE -PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM -DCONFIG_SYS_GENERIC_BOARD +PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM PLATFORM_LIBS += -lrt # Define this to avoid linking with SDL, which requires SDL libraries diff --git a/arch/x86/include/asm/config.h b/arch/x86/include/asm/config.h index ff15828..3a891ba 100644 --- a/arch/x86/include/asm/config.h +++ b/arch/x86/include/asm/config.h @@ -7,7 +7,6 @@ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_LMB #define CONFIG_SYS_BOOT_RAMDISK_HIGH diff --git a/include/configs/amcore.h b/include/configs/amcore.h index 2a785b3..37aa124 100644 --- a/include/configs/amcore.h +++ b/include/configs/amcore.h @@ -12,8 +12,6 @@ #define CONFIG_AMCORE #define CONFIG_HOSTNAME AMCORE -#define CONFIG_SYS_GENERIC_BOARD - #define CONFIG_MCF530x #define CONFIG_M5307 diff --git a/include/configs/dbau1x00.h b/include/configs/dbau1x00.h index 8a7447d..56317ef 100644 --- a/include/configs/dbau1x00.h +++ b/include/configs/dbau1x00.h @@ -15,7 +15,6 @@ #define CONFIG_DBAU1X00 1 #define CONFIG_SOC_AU1X00 1 /* alchemy series cpu */ -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_BOARDINFO #ifdef CONFIG_DBAU1000 diff --git a/include/configs/malta.h b/include/configs/malta.h index 354672e..9445c9b 100644 --- a/include/configs/malta.h +++ b/include/configs/malta.h @@ -14,7 +14,6 @@ * System configuration */ #define CONFIG_MALTA -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_BOARD_EARLY_INIT_F #define CONFIG_DISPLAY_BOARDINFO diff --git a/include/configs/pb1x00.h b/include/configs/pb1x00.h index 61e6af3..a1926bb 100644 --- a/include/configs/pb1x00.h +++ b/include/configs/pb1x00.h @@ -15,7 +15,6 @@ #define CONFIG_PB1X00 1 #define CONFIG_SOC_AU1X00 1 /* alchemy series cpu */ -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_BOARDINFO #ifdef CONFIG_PB1000 diff --git a/include/configs/qemu-mips.h b/include/configs/qemu-mips.h index 1548d3e..75da8a1 100644 --- a/include/configs/qemu-mips.h +++ b/include/configs/qemu-mips.h @@ -14,7 +14,6 @@ #define CONFIG_QEMU_MIPS -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_BOARDINFO #define CONFIG_MISC_INIT_R diff --git a/include/configs/qemu-mips64.h b/include/configs/qemu-mips64.h index 61cafad..b07ca4e 100644 --- a/include/configs/qemu-mips64.h +++ b/include/configs/qemu-mips64.h @@ -14,7 +14,6 @@ #define CONFIG_QEMU_MIPS -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_BOARDINFO #define CONFIG_MISC_INIT_R diff --git a/include/configs/vct.h b/include/configs/vct.h index 83e4163..88e58ec 100644 --- a/include/configs/vct.h +++ b/include/configs/vct.h @@ -25,7 +25,6 @@ #ifndef __CONFIG_H #define __CONFIG_H -#define CONFIG_SYS_GENERIC_BOARD #define CONFIG_DISPLAY_BOARDINFO #define CPU_CLOCK_RATE 324000000 /* Clock for the MIPS core */ -- cgit v0.10.2 From 6eb6f132e6dbeeb0ce41202ba42e0496a5d2438b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Mar 2015 19:42:53 +0900 Subject: m68k: remove arch/m68k/lib/board.c All the M68000 boards have switched to Generic Board. This file is no longer necessary. Signed-off-by: Masahiro Yamada Cc: Huan Wang Cc: Angelo Dureghello Reviewed-by: Simon Glass diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile index d0e1a84..73d40bd 100644 --- a/arch/m68k/lib/Makefile +++ b/arch/m68k/lib/Makefile @@ -5,9 +5,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -ifndef CONFIG_SYS_GENERIC_BOARD -obj-y += board.o -endif obj-$(CONFIG_CMD_BOOTM) += bootm.o obj-y += cache.o obj-y += interrupts.o diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c deleted file mode 100644 index 9caff73..0000000 --- a/arch/m68k/lib/board.c +++ /dev/null @@ -1,642 +0,0 @@ -/* - * (C) Copyright 2003 - * Josef Baumgartner - * - * (C) Copyright 2000-2002 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include -#include -#include -#include - -#include - -#if defined(CONFIG_CMD_IDE) -#include -#endif -#if defined(CONFIG_CMD_SCSI) -#include -#endif -#if defined(CONFIG_CMD_KGDB) -#include -#endif -#ifdef CONFIG_STATUS_LED -#include -#endif -#include -#include -#ifdef CONFIG_SYS_ALLOC_DPRAM -#include -#endif -#include - -#if defined(CONFIG_HARD_I2C) || \ - defined(CONFIG_SYS_I2C) -#include -#endif - -#ifdef CONFIG_CMD_SPI -#include -#endif - -#ifdef CONFIG_BITBANGMII -#include -#endif - -#include - -DECLARE_GLOBAL_DATA_PTR; - -static char *failed = "*** failed ***\n"; - -#include - -extern ulong __init_end; -extern ulong __bss_end; - -#if defined(CONFIG_WATCHDOG) -# undef INIT_FUNC_WATCHDOG_INIT -# define INIT_FUNC_WATCHDOG_INIT watchdog_init, -# define WATCHDOG_DISABLE watchdog_disable - -extern int watchdog_init(void); -extern int watchdog_disable(void); -#else -# define INIT_FUNC_WATCHDOG_INIT /* undef */ -# define WATCHDOG_DISABLE /* undef */ -#endif /* CONFIG_WATCHDOG */ - -ulong monitor_flash_len; - -/************************************************************************ - * Utilities * - ************************************************************************ - */ - -/* - * All attempts to come up with a "common" initialization sequence - * that works for all boards and architectures failed: some of the - * requirements are just _too_ different. To get rid of the resulting - * mess of board dependend #ifdef'ed code we now make the whole - * initialization sequence configurable to the user. - * - * The requirements for any new initalization function is simple: it - * receives a pointer to the "global data" structure as it's only - * argument, and returns an integer return code, where 0 means - * "continue" and != 0 means "fatal error, hang the system". - */ -typedef int (init_fnc_t) (void); - -/************************************************************************ - * Init Utilities - ************************************************************************ - * Some of this code should be moved into the core functions, - * but let's get it working (again) first... - */ - -static int init_baudrate (void) -{ - gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); - return 0; -} - -/***********************************************************************/ - -static int init_func_ram (void) -{ - int board_type = 0; /* use dummy arg */ - puts ("DRAM: "); - - if ((gd->ram_size = initdram (board_type)) > 0) { - print_size (gd->ram_size, "\n"); - return (0); - } - puts (failed); - return (1); -} - -/***********************************************************************/ - -#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C) -static int init_func_i2c (void) -{ - puts ("I2C: "); -#ifdef CONFIG_SYS_I2C - i2c_init_all(); -#else - i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); -#endif - puts ("ready\n"); - return (0); -} -#endif - -#if defined(CONFIG_HARD_SPI) -static int init_func_spi (void) -{ - puts ("SPI: "); - spi_init (); - puts ("ready\n"); - return (0); -} -#endif - -/***********************************************************************/ - -/************************************************************************ - * Initialization sequence * - ************************************************************************ - */ - -init_fnc_t *init_sequence[] = { - get_clocks, - env_init, - init_baudrate, - serial_init, - console_init_f, - display_options, - checkcpu, - checkboard, -#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C) - init_func_i2c, -#endif -#if defined(CONFIG_HARD_SPI) - init_func_spi, -#endif - init_func_ram, -#if defined(CONFIG_SYS_DRAM_TEST) - testdram, -#endif /* CONFIG_SYS_DRAM_TEST */ - INIT_FUNC_WATCHDOG_INIT - NULL, /* Terminate this list */ -}; - - -/************************************************************************ - * - * This is the first part of the initialization sequence that is - * implemented in C, but still running from ROM. - * - * The main purpose is to provide a (serial) console interface as - * soon as possible (so we can see any error messages), and to - * initialize the RAM so that we can relocate the monitor code to - * RAM. - * - * Be aware of the restrictions: global data is read-only, BSS is not - * initialized, and stack space is limited to a few kB. - * - ************************************************************************ - */ - -void -board_init_f (ulong bootflag) -{ - bd_t *bd; - ulong len, addr, addr_sp; - ulong *paddr; - gd_t *id; - init_fnc_t **init_fnc_ptr; -#ifdef CONFIG_PRAM - ulong reg; -#endif - - /* Pointer is writable since we allocated a register for it */ - gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); - /* compiler optimization barrier needed for GCC >= 3.4 */ - __asm__ __volatile__("": : :"memory"); - - /* Clear initial global data */ - memset ((void *) gd, 0, sizeof (gd_t)); - - for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { - if ((*init_fnc_ptr)() != 0) { - hang (); - } - } - - /* - * Now that we have DRAM mapped and working, we can - * relocate the code and continue running from DRAM. - * - * Reserve memory at end of RAM for (top down in that order): - * - protected RAM - * - LCD framebuffer - * - monitor code - * - board info struct - */ - len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE; - - addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size; - -#ifdef CONFIG_LOGBUFFER - /* reserve kernel log buffer */ - addr -= (LOGBUFF_RESERVE); - debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); -#endif - -#ifdef CONFIG_PRAM - /* - * reserve protected RAM - */ - reg = getenv_ulong("pram", 10, CONFIG_PRAM); - addr -= (reg << 10); /* size is in kB */ - debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); -#endif /* CONFIG_PRAM */ - - /* round down to next 4 kB limit */ - addr &= ~(4096 - 1); - debug ("Top of RAM usable for U-Boot at: %08lx\n", addr); - -#ifdef CONFIG_LCD -#ifdef CONFIG_FB_ADDR - gd->fb_base = CONFIG_FB_ADDR; -#else - /* reserve memory for LCD display (always full pages) */ - addr = lcd_setmem (addr); - gd->fb_base = addr; -#endif /* CONFIG_FB_ADDR */ -#endif /* CONFIG_LCD */ - - /* - * reserve memory for U-Boot code, data & bss - * round down to next 4 kB limit - */ - addr -= len; - addr &= ~(4096 - 1); - - debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); - - /* - * reserve memory for malloc() arena - */ - addr_sp = addr - TOTAL_MALLOC_LEN; - debug ("Reserving %dk for malloc() at: %08lx\n", - TOTAL_MALLOC_LEN >> 10, addr_sp); - - /* - * (permanently) allocate a Board Info struct - * and a permanent copy of the "global" data - */ - addr_sp -= sizeof (bd_t); - bd = (bd_t *) addr_sp; - gd->bd = bd; - debug ("Reserving %zu Bytes for Board Info at: %08lx\n", - sizeof (bd_t), addr_sp); - addr_sp -= sizeof (gd_t); - id = (gd_t *) addr_sp; - debug ("Reserving %zu Bytes for Global Data at: %08lx\n", - sizeof (gd_t), addr_sp); - - /* Reserve memory for boot params. */ - addr_sp -= CONFIG_SYS_BOOTPARAMS_LEN; - bd->bi_boot_params = addr_sp; - debug ("Reserving %dk for boot parameters at: %08lx\n", - CONFIG_SYS_BOOTPARAMS_LEN >> 10, addr_sp); - - /* - * Finally, we set up a new (bigger) stack. - * - * Leave some safety gap for SP, force alignment on 16 byte boundary - * Clear initial stack frame - */ - addr_sp -= 16; - addr_sp &= ~0xF; - - paddr = (ulong *)addr_sp; - *paddr-- = 0; - *paddr-- = 0; - addr_sp = (ulong)paddr; - - debug ("Stack Pointer at: %08lx\n", addr_sp); - - /* - * Save local variables to board info struct - */ - bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM memory */ - bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ -#ifdef CONFIG_SYS_INIT_RAM_ADDR - bd->bi_sramstart = CONFIG_SYS_INIT_RAM_ADDR; /* start of SRAM memory */ - bd->bi_sramsize = CONFIG_SYS_INIT_RAM_SIZE; /* size of SRAM memory */ -#endif - bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */ - - bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ - - WATCHDOG_RESET (); - bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ - bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ -#ifdef CONFIG_PCI - bd->bi_pcifreq = gd->pci_clk; /* PCI Freq in Hz */ -#endif -#ifdef CONFIG_EXTRA_CLOCK - bd->bi_inpfreq = gd->arch.inp_clk; /* input Freq in Hz */ - bd->bi_vcofreq = gd->arch.vco_clk; /* vco Freq in Hz */ - bd->bi_flbfreq = gd->arch.flb_clk; /* flexbus Freq in Hz */ -#endif - -#ifdef CONFIG_SYS_EXTBDINFO - strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); - strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); -#endif - - WATCHDOG_RESET (); - -#ifdef CONFIG_POST - post_bootmode_init(); - post_run (NULL, POST_ROM | post_bootmode_get(0)); -#endif - - WATCHDOG_RESET(); - - memcpy (id, (void *)gd, sizeof (gd_t)); - - debug ("Start relocate of code from %08x to %08lx\n", CONFIG_SYS_MONITOR_BASE, addr); - relocate_code (addr_sp, id, addr); - - /* NOTREACHED - jump_to_ram() does not return */ -} - -/************************************************************************ - * - * This is the next part if the initialization sequence: we are now - * running from RAM and have a "normal" C environment, i. e. global - * data can be written, BSS has been cleared, the stack size in not - * that critical any more, etc. - * - ************************************************************************ - */ -void board_init_r (gd_t *id, ulong dest_addr) -{ - char *s __maybe_unused; - bd_t *bd; - -#ifndef CONFIG_ENV_IS_NOWHERE - extern char * env_name_spec; -#endif -#ifndef CONFIG_SYS_NO_FLASH - ulong flash_size; -#endif - gd = id; /* initialize RAM version of global data */ - bd = gd->bd; - - gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ - - WATCHDOG_RESET (); - - gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE; - - serial_initialize(); - - debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); - - monitor_flash_len = (ulong)&__init_end - dest_addr; - -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - /* - * We have to relocate the command table manually - */ - fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd), - ll_entry_count(cmd_tbl_t, cmd)); -#endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */ - - /* there are some other pointer constants we must deal with */ -#ifndef CONFIG_ENV_IS_NOWHERE - env_name_spec += gd->reloc_off; -#endif - - WATCHDOG_RESET (); - -#ifdef CONFIG_LOGBUFFER - logbuff_init_ptrs (); -#endif -#ifdef CONFIG_POST - post_output_backlog (); - post_reloc (); -#endif - WATCHDOG_RESET(); - -#if 0 - /* instruction cache enabled in cpu_init_f() for faster relocation */ - icache_enable (); /* it's time to enable the instruction cache */ -#endif - - /* - * Setup trap handlers - */ - trap_init (CONFIG_SYS_SDRAM_BASE); - - /* The Malloc area is immediately below the monitor copy in DRAM */ - mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off - - TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN); - -#if !defined(CONFIG_SYS_NO_FLASH) - puts ("Flash: "); - - if ((flash_size = flash_init ()) > 0) { -# ifdef CONFIG_SYS_FLASH_CHECKSUM - print_size (flash_size, ""); - /* - * Compute and print flash CRC if flashchecksum is set to 'y' - * - * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX - */ - if (getenv_yesno("flashchecksum") == 1) { - printf (" CRC: %08X", - crc32 (0, - (const unsigned char *) CONFIG_SYS_FLASH_BASE, - flash_size) - ); - } - putc ('\n'); -# else /* !CONFIG_SYS_FLASH_CHECKSUM */ - print_size (flash_size, "\n"); -# endif /* CONFIG_SYS_FLASH_CHECKSUM */ - } else { - puts (failed); - hang (); - } - - bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */ - bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ - bd->bi_flashoffset = 0; -#else /* CONFIG_SYS_NO_FLASH */ - bd->bi_flashsize = 0; - bd->bi_flashstart = 0; - bd->bi_flashoffset = 0; -#endif /* !CONFIG_SYS_NO_FLASH */ - - WATCHDOG_RESET (); - - /* initialize higher level parts of CPU like time base and timers */ - cpu_init_r (); - - WATCHDOG_RESET (); - -#ifdef CONFIG_SPI -# if !defined(CONFIG_ENV_IS_IN_EEPROM) - spi_init_f (); -# endif - spi_init_r (); -#endif - -#if defined(CONFIG_SYS_I2C) - /* Adjust I2C subsystem pointers after relocation */ - i2c_reloc_fixup(); -#endif - - /* relocate environment function pointers etc. */ - env_relocate (); - - WATCHDOG_RESET (); - -#if defined(CONFIG_PCI) - /* - * Do pci configuration - */ - pci_init (); -#endif - - /** leave this here (after malloc(), environment and PCI are working) **/ - /* Initialize stdio devices */ - stdio_init (); - - /* Initialize the jump table for applications */ - jumptable_init (); - - /* Initialize the console (after the relocation and devices init) */ - console_init_r (); - -#if defined(CONFIG_MISC_INIT_R) - /* miscellaneous platform dependent initialisations */ - misc_init_r (); -#endif - -#if defined(CONFIG_CMD_KGDB) - WATCHDOG_RESET (); - puts ("KGDB: "); - kgdb_init (); -#endif - - debug ("U-Boot relocated to %08lx\n", dest_addr); - - /* - * Enable Interrupts - */ - interrupt_init (); - - /* Must happen after interrupts are initialized since - * an irq handler gets installed - */ - timer_init(); - -#ifdef CONFIG_STATUS_LED - status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); -#endif - - udelay (20); - - /* Insert function pointers now that we have relocated the code */ - - /* Initialize from environment */ - load_addr = getenv_ulong("loadaddr", 16, load_addr); - - WATCHDOG_RESET (); - -#if defined(CONFIG_CMD_DOC) - WATCHDOG_RESET (); - puts ("DOC: "); - doc_init (); -#endif - -#if defined(CONFIG_CMD_NAND) - WATCHDOG_RESET (); - puts ("NAND: "); - nand_init(); /* go init the NAND */ -#endif - -#ifdef CONFIG_BITBANGMII - bb_miiphy_init(); -#endif -#if defined(CONFIG_CMD_NET) - WATCHDOG_RESET(); -#if defined(FEC_ENET) - eth_init(bd); -#endif - puts ("Net: "); - eth_initialize (bd); -#endif - -#ifdef CONFIG_POST - post_run (NULL, POST_RAM | post_bootmode_get(0)); -#endif - -#if defined(CONFIG_CMD_PCMCIA) \ - && !defined(CONFIG_CMD_IDE) - WATCHDOG_RESET (); - puts ("PCMCIA:"); - pcmcia_init (); -#endif - -#if defined(CONFIG_CMD_IDE) - WATCHDOG_RESET (); - puts ("IDE: "); - ide_init (); -#endif - -#ifdef CONFIG_LAST_STAGE_INIT - WATCHDOG_RESET (); - /* - * Some parts can be only initialized if all others (like - * Interrupts) are up and running (i.e. the PC-style ISA - * keyboard). - */ - last_stage_init (); -#endif - -#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) - /* - * Export available size of memory for Linux, - * taking into account the protected RAM at top of memory - */ - { - ulong pram = 0; - char memsz[32]; - -#ifdef CONFIG_PRAM - pram = getenv_ulong("pram", 10, CONFIG_PRAM); -#endif -#ifdef CONFIG_LOGBUFFER - /* Also take the logbuffer into account (pram is in kB) */ - pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024; -#endif - sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram); - setenv ("mem", memsz); - } -#endif - -#ifdef CONFIG_WATCHDOG - /* disable watchdog if environment is set */ - if ((s = getenv ("watchdog")) != NULL) { - if (strncmp (s, "off", 3) == 0) { - WATCHDOG_DISABLE (); - } - } -#endif /* CONFIG_WATCHDOG*/ - - - /* Initialization complete - start the monitor */ - - /* main_loop() can return to retry autoboot, if so just run it again. */ - for (;;) { - WATCHDOG_RESET (); - main_loop (); - } - - /* NOTREACHED - no way out of command loop except booting */ -} -- cgit v0.10.2 From 91405b7fa9a7e53f238d55a17730933f43871fc1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Mar 2015 19:42:54 +0900 Subject: malloc_f: remove redundant defalut values of CONFIG_SYS_MALLOC_F_LEN The default value of CONFIG_SYS_MALLOC_F_LEN is defined by ./Kconfig as 0x400. Each defconfig or Kconfig need not repeat the same value. Signed-off-by: Masahiro Yamada Acked-by: Stephen Warren Reviewed-by: Simon Glass Acked-by: Robert Baldyga diff --git a/arch/arm/cpu/armv7/exynos/Kconfig b/arch/arm/cpu/armv7/exynos/Kconfig index eb86a7f..9e47ed3 100644 --- a/arch/arm/cpu/armv7/exynos/Kconfig +++ b/arch/arm/cpu/armv7/exynos/Kconfig @@ -83,9 +83,6 @@ config DM_GPIO config SYS_MALLOC_F default y -config SYS_MALLOC_F_LEN - default 0x400 - source "board/samsung/smdkv310/Kconfig" source "board/samsung/trats/Kconfig" source "board/samsung/universal_c210/Kconfig" diff --git a/arch/arm/cpu/armv7/omap3/Kconfig b/arch/arm/cpu/armv7/omap3/Kconfig index 65da6e2..aa2ff46 100644 --- a/arch/arm/cpu/armv7/omap3/Kconfig +++ b/arch/arm/cpu/armv7/omap3/Kconfig @@ -109,9 +109,6 @@ config DM_SERIAL config SYS_MALLOC_F default y if DM -config SYS_MALLOC_F_LEN - default 0x400 if DM - config SYS_SOC default "omap3" diff --git a/arch/arm/mach-uniphier/Kconfig b/arch/arm/mach-uniphier/Kconfig index 73f2659..7fc26dd 100644 --- a/arch/arm/mach-uniphier/Kconfig +++ b/arch/arm/mach-uniphier/Kconfig @@ -48,9 +48,6 @@ endchoice config SYS_MALLOC_F default y -config SYS_MALLOC_F_LEN - default 0x400 - config CMD_PINMON bool "Enable boot mode pins monitor command" default y diff --git a/board/amcc/canyonlands/Kconfig b/board/amcc/canyonlands/Kconfig index 848e08f..c0dbd18 100644 --- a/board/amcc/canyonlands/Kconfig +++ b/board/amcc/canyonlands/Kconfig @@ -43,8 +43,4 @@ config SYS_MALLOC_F bool default y -config SYS_MALLOC_F_LEN - hex - default 0x400 - endif diff --git a/board/ti/am335x/Kconfig b/board/ti/am335x/Kconfig index 722f9d5..8c45892 100644 --- a/board/ti/am335x/Kconfig +++ b/board/ti/am335x/Kconfig @@ -50,7 +50,4 @@ config DM_SERIAL config SYS_MALLOC_F default y if DM -config SYS_MALLOC_F_LEN - default 0x400 if DM - endif diff --git a/configs/Linksprite_pcDuino3_fdt_defconfig b/configs/Linksprite_pcDuino3_fdt_defconfig index 1504664..87dd38f 100644 --- a/configs/Linksprite_pcDuino3_fdt_defconfig +++ b/configs/Linksprite_pcDuino3_fdt_defconfig @@ -14,4 +14,3 @@ CONFIG_DRAM_CLK=480 CONFIG_DRAM_ZQ=122 CONFIG_DRAM_EMR1=4 CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/am335x_igep0033_defconfig b/configs/am335x_igep0033_defconfig index 8d38e26..a439298 100644 --- a/configs/am335x_igep0033_defconfig +++ b/configs/am335x_igep0033_defconfig @@ -4,4 +4,3 @@ CONFIG_SPL_STACK_R_ADDR=0x82000000 CONFIG_ARM=y CONFIG_TARGET_AM335X_IGEP0033=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig index 2fd21cf..00cbdd2 100644 --- a/configs/cm_fx6_defconfig +++ b/configs/cm_fx6_defconfig @@ -6,4 +6,3 @@ CONFIG_DM=y CONFIG_DM_GPIO=y CONFIG_DM_SERIAL=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/cm_t335_defconfig b/configs/cm_t335_defconfig index 086e526..31705f2 100644 --- a/configs/cm_t335_defconfig +++ b/configs/cm_t335_defconfig @@ -2,4 +2,3 @@ CONFIG_SPL=y CONFIG_ARM=y CONFIG_TARGET_CM_T335=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/gwventana_defconfig b/configs/gwventana_defconfig index 6eab019..d6bbdc1 100644 --- a/configs/gwventana_defconfig +++ b/configs/gwventana_defconfig @@ -3,4 +3,3 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/imx-common/spl_sd.cfg,MX6QDL" CONFIG_ARM=y CONFIG_TARGET_GW_VENTANA=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/mx6dlsabreauto_defconfig b/configs/mx6dlsabreauto_defconfig index 47f3f87..b3816ec 100644 --- a/configs/mx6dlsabreauto_defconfig +++ b/configs/mx6dlsabreauto_defconfig @@ -2,6 +2,5 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6dl.cfg,MX6 CONFIG_ARM=y CONFIG_TARGET_MX6QSABREAUTO=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 CONFIG_DM=y CONFIG_DM_THERMAL=y diff --git a/configs/mx6qsabreauto_defconfig b/configs/mx6qsabreauto_defconfig index ab72942..df09296 100644 --- a/configs/mx6qsabreauto_defconfig +++ b/configs/mx6qsabreauto_defconfig @@ -2,6 +2,5 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg, CONFIG_ARM=y CONFIG_TARGET_MX6QSABREAUTO=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 CONFIG_DM=y CONFIG_DM_THERMAL=y diff --git a/configs/mx6qsabresd_defconfig b/configs/mx6qsabresd_defconfig index 112918b..cad4281 100644 --- a/configs/mx6qsabresd_defconfig +++ b/configs/mx6qsabresd_defconfig @@ -2,6 +2,5 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sabresd/mx6q_4x_mt41j128 CONFIG_ARM=y CONFIG_TARGET_MX6SABRESD=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 CONFIG_DM=y CONFIG_DM_THERMAL=y diff --git a/configs/mx6sxsabresd_defconfig b/configs/mx6sxsabresd_defconfig index cc82322..12a9bdc 100644 --- a/configs/mx6sxsabresd_defconfig +++ b/configs/mx6sxsabresd_defconfig @@ -2,6 +2,5 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sxsabresd/imximage.cfg,M CONFIG_ARM=y CONFIG_TARGET_MX6SXSABRESD=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 CONFIG_DM=y CONFIG_DM_THERMAL=y diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig index 1bb7664..48a1b29 100644 --- a/configs/nokia_rx51_defconfig +++ b/configs/nokia_rx51_defconfig @@ -5,4 +5,3 @@ CONFIG_DM=n CONFIG_DM_SERIAL=n CONFIG_DM_GPIO=n CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/pcm051_rev1_defconfig b/configs/pcm051_rev1_defconfig index f417aac..a8b10d4 100644 --- a/configs/pcm051_rev1_defconfig +++ b/configs/pcm051_rev1_defconfig @@ -3,4 +3,3 @@ CONFIG_SYS_EXTRA_OPTIONS="REV1" CONFIG_ARM=y CONFIG_TARGET_PCM051=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/pcm051_rev3_defconfig b/configs/pcm051_rev3_defconfig index cc6f3f5..ef307d9 100644 --- a/configs/pcm051_rev3_defconfig +++ b/configs/pcm051_rev3_defconfig @@ -3,4 +3,3 @@ CONFIG_SYS_EXTRA_OPTIONS="REV3" CONFIG_ARM=y CONFIG_TARGET_PCM051=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/pengwyn_defconfig b/configs/pengwyn_defconfig index 9c6ddf4..86f8bbb 100644 --- a/configs/pengwyn_defconfig +++ b/configs/pengwyn_defconfig @@ -2,4 +2,3 @@ CONFIG_SPL=y CONFIG_ARM=y CONFIG_TARGET_PENGWYN=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/pepper_defconfig b/configs/pepper_defconfig index e14b008..438d886 100644 --- a/configs/pepper_defconfig +++ b/configs/pepper_defconfig @@ -2,4 +2,3 @@ CONFIG_SPL=y CONFIG_ARM=y CONFIG_TARGET_PEPPER=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig index b539d4a..69723d5 100644 --- a/configs/rpi_2_defconfig +++ b/configs/rpi_2_defconfig @@ -1,4 +1,3 @@ CONFIG_ARM=y CONFIG_TARGET_RPI_2=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig index 98d3199..1a5a8e2 100644 --- a/configs/rpi_defconfig +++ b/configs/rpi_defconfig @@ -1,4 +1,3 @@ CONFIG_ARM=y CONFIG_TARGET_RPI=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/s5p_goni_defconfig b/configs/s5p_goni_defconfig index 33e6fb8..5815667 100644 --- a/configs/s5p_goni_defconfig +++ b/configs/s5p_goni_defconfig @@ -3,4 +3,3 @@ CONFIG_ARCH_S5PC1XX=y CONFIG_TARGET_S5P_GONI=y CONFIG_DEFAULT_DEVICE_TREE="s5pc1xx-goni" CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 70f5b86..a0e19ad 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -6,7 +6,6 @@ CONFIG_FIT_SIGNATURE=y CONFIG_DM=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 CONFIG_CROS_EC=y CONFIG_DM_CROS_EC=y CONFIG_CROS_EC_SANDBOX=y diff --git a/configs/smdkc100_defconfig b/configs/smdkc100_defconfig index e933a32..585fea6 100644 --- a/configs/smdkc100_defconfig +++ b/configs/smdkc100_defconfig @@ -3,4 +3,3 @@ CONFIG_TARGET_SMDKC100=y CONFIG_ARCH_S5PC1XX=y CONFIG_DEFAULT_DEVICE_TREE="s5pc1xx-smdkc100" CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/snapper9260_defconfig b/configs/snapper9260_defconfig index 3a47505..9a0d0ad 100644 --- a/configs/snapper9260_defconfig +++ b/configs/snapper9260_defconfig @@ -6,4 +6,3 @@ CONFIG_DM=y CONFIG_DM_GPIO=y CONFIG_DM_SERIAL=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 diff --git a/configs/snapper9g20_defconfig b/configs/snapper9g20_defconfig index 1f0244b..82f7a07 100644 --- a/configs/snapper9g20_defconfig +++ b/configs/snapper9g20_defconfig @@ -6,4 +6,3 @@ CONFIG_DM=y CONFIG_DM_GPIO=y CONFIG_DM_SERIAL=y CONFIG_SYS_MALLOC_F=y -CONFIG_SYS_MALLOC_F_LEN=0x400 -- cgit v0.10.2 From 326a682358c16afcf2c7a9617e9811e72a1f0929 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Mar 2015 19:42:55 +0900 Subject: malloc_f: enable SYS_MALLOC_F by default if DM is on This option has a bool type, not hex. Fix it and enable it if CONFIG_DM is on because Driver Model always requires malloc memory. Devices are scanned twice, before/after relocation. CONFIG_SYS_MALLOC_F should be enabled to use malloc memory before relocation. As it is board-independent, handle it globally. Signed-off-by: Masahiro Yamada Acked-by: Stephen Warren Reviewed-by: Simon Glass Acked-by: Robert Baldyga diff --git a/Kconfig b/Kconfig index 8f96c94..b5968d7 100644 --- a/Kconfig +++ b/Kconfig @@ -54,7 +54,7 @@ config CC_OPTIMIZE_FOR_SIZE config SYS_MALLOC_F bool "Enable malloc() pool before relocation" - default 0x400 + default y if DM help Before relocation memory is very limited on many platforms. Still, we can provide a small malloc() pool if needed. Driver model in diff --git a/arch/arm/cpu/armv7/exynos/Kconfig b/arch/arm/cpu/armv7/exynos/Kconfig index 9e47ed3..bd7540a 100644 --- a/arch/arm/cpu/armv7/exynos/Kconfig +++ b/arch/arm/cpu/armv7/exynos/Kconfig @@ -80,9 +80,6 @@ config DM_SPI_FLASH config DM_GPIO default y -config SYS_MALLOC_F - default y - source "board/samsung/smdkv310/Kconfig" source "board/samsung/trats/Kconfig" source "board/samsung/universal_c210/Kconfig" diff --git a/arch/arm/cpu/armv7/omap3/Kconfig b/arch/arm/cpu/armv7/omap3/Kconfig index aa2ff46..1f96498 100644 --- a/arch/arm/cpu/armv7/omap3/Kconfig +++ b/arch/arm/cpu/armv7/omap3/Kconfig @@ -106,9 +106,6 @@ config DM_GPIO config DM_SERIAL default y if DM -config SYS_MALLOC_F - default y if DM - config SYS_SOC default "omap3" diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig index fccfd79..fce1c1d 100644 --- a/arch/arm/mach-tegra/Kconfig +++ b/arch/arm/mach-tegra/Kconfig @@ -17,9 +17,6 @@ config TEGRA124 endchoice -config SYS_MALLOC_F - default y - config SYS_MALLOC_F_LEN default 0x1800 diff --git a/arch/arm/mach-uniphier/Kconfig b/arch/arm/mach-uniphier/Kconfig index 7fc26dd..288e6ab 100644 --- a/arch/arm/mach-uniphier/Kconfig +++ b/arch/arm/mach-uniphier/Kconfig @@ -45,9 +45,6 @@ config DCC_MICRO_SUPPORT_CARD endchoice -config SYS_MALLOC_F - default y - config CMD_PINMON bool "Enable boot mode pins monitor command" default y diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 35d24e4..da27115 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -76,9 +76,6 @@ config DM_GPIO config DM_SERIAL default y -config SYS_MALLOC_F - default y - config SYS_MALLOC_F_LEN default 0x800 diff --git a/board/amcc/canyonlands/Kconfig b/board/amcc/canyonlands/Kconfig index c0dbd18..46efa7a 100644 --- a/board/amcc/canyonlands/Kconfig +++ b/board/amcc/canyonlands/Kconfig @@ -39,8 +39,4 @@ config DM config DM_SERIAL default y -config SYS_MALLOC_F - bool - default y - endif diff --git a/board/ti/am335x/Kconfig b/board/ti/am335x/Kconfig index 8c45892..7cb006f 100644 --- a/board/ti/am335x/Kconfig +++ b/board/ti/am335x/Kconfig @@ -47,7 +47,4 @@ config DM_GPIO config DM_SERIAL default y if DM -config SYS_MALLOC_F - default y if DM - endif diff --git a/configs/Linksprite_pcDuino3_fdt_defconfig b/configs/Linksprite_pcDuino3_fdt_defconfig index 87dd38f..7690d1e 100644 --- a/configs/Linksprite_pcDuino3_fdt_defconfig +++ b/configs/Linksprite_pcDuino3_fdt_defconfig @@ -13,4 +13,3 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=480 CONFIG_DRAM_ZQ=122 CONFIG_DRAM_EMR1=4 -CONFIG_SYS_MALLOC_F=y diff --git a/configs/am335x_igep0033_defconfig b/configs/am335x_igep0033_defconfig index a439298..7ff0a13 100644 --- a/configs/am335x_igep0033_defconfig +++ b/configs/am335x_igep0033_defconfig @@ -3,4 +3,3 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_ADDR=0x82000000 CONFIG_ARM=y CONFIG_TARGET_AM335X_IGEP0033=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig index 00cbdd2..f10a5c2 100644 --- a/configs/cm_fx6_defconfig +++ b/configs/cm_fx6_defconfig @@ -5,4 +5,3 @@ CONFIG_TARGET_CM_FX6=y CONFIG_DM=y CONFIG_DM_GPIO=y CONFIG_DM_SERIAL=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/cm_t335_defconfig b/configs/cm_t335_defconfig index 31705f2..d189799 100644 --- a/configs/cm_t335_defconfig +++ b/configs/cm_t335_defconfig @@ -1,4 +1,3 @@ CONFIG_SPL=y CONFIG_ARM=y CONFIG_TARGET_CM_T335=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/mx6dlsabreauto_defconfig b/configs/mx6dlsabreauto_defconfig index b3816ec..8bc5e8b 100644 --- a/configs/mx6dlsabreauto_defconfig +++ b/configs/mx6dlsabreauto_defconfig @@ -1,6 +1,5 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6dl.cfg,MX6DL" CONFIG_ARM=y CONFIG_TARGET_MX6QSABREAUTO=y -CONFIG_SYS_MALLOC_F=y CONFIG_DM=y CONFIG_DM_THERMAL=y diff --git a/configs/mx6qsabreauto_defconfig b/configs/mx6qsabreauto_defconfig index df09296..ba9e512 100644 --- a/configs/mx6qsabreauto_defconfig +++ b/configs/mx6qsabreauto_defconfig @@ -1,6 +1,5 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q" CONFIG_ARM=y CONFIG_TARGET_MX6QSABREAUTO=y -CONFIG_SYS_MALLOC_F=y CONFIG_DM=y CONFIG_DM_THERMAL=y diff --git a/configs/mx6qsabresd_defconfig b/configs/mx6qsabresd_defconfig index cad4281..1764b39 100644 --- a/configs/mx6qsabresd_defconfig +++ b/configs/mx6qsabresd_defconfig @@ -1,6 +1,5 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sabresd/mx6q_4x_mt41j128.cfg,MX6Q" CONFIG_ARM=y CONFIG_TARGET_MX6SABRESD=y -CONFIG_SYS_MALLOC_F=y CONFIG_DM=y CONFIG_DM_THERMAL=y diff --git a/configs/mx6sxsabresd_defconfig b/configs/mx6sxsabresd_defconfig index 12a9bdc..5c862cf 100644 --- a/configs/mx6sxsabresd_defconfig +++ b/configs/mx6sxsabresd_defconfig @@ -1,6 +1,5 @@ CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sxsabresd/imximage.cfg,MX6SX" CONFIG_ARM=y CONFIG_TARGET_MX6SXSABRESD=y -CONFIG_SYS_MALLOC_F=y CONFIG_DM=y CONFIG_DM_THERMAL=y diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig index 48a1b29..20a51e1 100644 --- a/configs/nokia_rx51_defconfig +++ b/configs/nokia_rx51_defconfig @@ -4,4 +4,3 @@ CONFIG_TARGET_NOKIA_RX51=y CONFIG_DM=n CONFIG_DM_SERIAL=n CONFIG_DM_GPIO=n -CONFIG_SYS_MALLOC_F=y diff --git a/configs/pcm051_rev1_defconfig b/configs/pcm051_rev1_defconfig index a8b10d4..08075e7 100644 --- a/configs/pcm051_rev1_defconfig +++ b/configs/pcm051_rev1_defconfig @@ -2,4 +2,3 @@ CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="REV1" CONFIG_ARM=y CONFIG_TARGET_PCM051=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/pcm051_rev3_defconfig b/configs/pcm051_rev3_defconfig index ef307d9..56deb48 100644 --- a/configs/pcm051_rev3_defconfig +++ b/configs/pcm051_rev3_defconfig @@ -2,4 +2,3 @@ CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="REV3" CONFIG_ARM=y CONFIG_TARGET_PCM051=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/pengwyn_defconfig b/configs/pengwyn_defconfig index 86f8bbb..6346b57 100644 --- a/configs/pengwyn_defconfig +++ b/configs/pengwyn_defconfig @@ -1,4 +1,3 @@ CONFIG_SPL=y CONFIG_ARM=y CONFIG_TARGET_PENGWYN=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/pepper_defconfig b/configs/pepper_defconfig index 438d886..3b042ec 100644 --- a/configs/pepper_defconfig +++ b/configs/pepper_defconfig @@ -1,4 +1,3 @@ CONFIG_SPL=y CONFIG_ARM=y CONFIG_TARGET_PEPPER=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig index 69723d5..3075321 100644 --- a/configs/rpi_2_defconfig +++ b/configs/rpi_2_defconfig @@ -1,3 +1,2 @@ CONFIG_ARM=y CONFIG_TARGET_RPI_2=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig index 1a5a8e2..9379cf0 100644 --- a/configs/rpi_defconfig +++ b/configs/rpi_defconfig @@ -1,3 +1,2 @@ CONFIG_ARM=y CONFIG_TARGET_RPI=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/s5p_goni_defconfig b/configs/s5p_goni_defconfig index 5815667..618e590 100644 --- a/configs/s5p_goni_defconfig +++ b/configs/s5p_goni_defconfig @@ -2,4 +2,3 @@ CONFIG_ARM=y CONFIG_ARCH_S5PC1XX=y CONFIG_TARGET_S5P_GONI=y CONFIG_DEFAULT_DEVICE_TREE="s5pc1xx-goni" -CONFIG_SYS_MALLOC_F=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index a0e19ad..a216039 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -5,7 +5,6 @@ CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y CONFIG_DM=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" -CONFIG_SYS_MALLOC_F=y CONFIG_CROS_EC=y CONFIG_DM_CROS_EC=y CONFIG_CROS_EC_SANDBOX=y diff --git a/configs/smdkc100_defconfig b/configs/smdkc100_defconfig index 585fea6..041030f 100644 --- a/configs/smdkc100_defconfig +++ b/configs/smdkc100_defconfig @@ -2,4 +2,3 @@ CONFIG_ARM=y CONFIG_TARGET_SMDKC100=y CONFIG_ARCH_S5PC1XX=y CONFIG_DEFAULT_DEVICE_TREE="s5pc1xx-smdkc100" -CONFIG_SYS_MALLOC_F=y diff --git a/configs/snapper9260_defconfig b/configs/snapper9260_defconfig index 9a0d0ad..576d9c5 100644 --- a/configs/snapper9260_defconfig +++ b/configs/snapper9260_defconfig @@ -5,4 +5,3 @@ CONFIG_TARGET_SNAPPER9260=y CONFIG_DM=y CONFIG_DM_GPIO=y CONFIG_DM_SERIAL=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/snapper9g20_defconfig b/configs/snapper9g20_defconfig index 82f7a07..07a2643 100644 --- a/configs/snapper9g20_defconfig +++ b/configs/snapper9g20_defconfig @@ -5,4 +5,3 @@ CONFIG_TARGET_SNAPPER9260=y CONFIG_DM=y CONFIG_DM_GPIO=y CONFIG_DM_SERIAL=y -CONFIG_SYS_MALLOC_F=y diff --git a/configs/stv0991_defconfig b/configs/stv0991_defconfig index 1c9ba88..e8cf311 100644 --- a/configs/stv0991_defconfig +++ b/configs/stv0991_defconfig @@ -1,7 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="stv0991" CONFIG_ARM=y CONFIG_TARGET_STV0991=y -CONFIG_SYS_MALLOC_F=y CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_DM=y CONFIG_DM_SERIAL=y diff --git a/include/configs/rcar-gen2-common.h b/include/configs/rcar-gen2-common.h index e9ef7cc..c33f1cb 100644 --- a/include/configs/rcar-gen2-common.h +++ b/include/configs/rcar-gen2-common.h @@ -35,8 +35,6 @@ #define CONFIG_SYS_THUMB_BUILD #define CONFIG_SYS_GENERIC_BOARD -#define CONFIG_SYS_MALLOC_F_LEN (1 << 10) - /* Support File sytems */ #define CONFIG_FAT_WRITE #define CONFIG_DOS_PARTITION -- cgit v0.10.2 From ddf6bd4876a1838bdf3202b34f5a36f165c279b1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Mar 2015 19:42:56 +0900 Subject: ARM: bcm283x: merge BCM2835/BCM2836 directories into mach-bcm283x BCM2835 (used on Raspberry Pi) and BCM2836 (used on Raspberry Pi 2) are similar enough. One of the biggest differences is the ARM processor. It is reasonable to collect the source files into a single place, arch/arm/mach-bcm283x/. Signed-off-by: Masahiro Yamada Acked-by: Stephen Warren diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b9ebee1..9292e98 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -286,13 +286,8 @@ config TARGET_MX35PDK bool "Support mx35pdk" select CPU_ARM1136 -config TARGET_RPI - bool "Support rpi" - select CPU_ARM1176 - -config TARGET_RPI_2 - bool "Support rpi_2" - select CPU_V7 +config ARCH_BCM283X + bool "Broadcom BCM283X family" config TARGET_INTEGRATORAP_CM946ES bool "Support integratorap_cm946es" @@ -723,9 +718,9 @@ endchoice source "arch/arm/mach-at91/Kconfig" -source "arch/arm/mach-davinci/Kconfig" +source "arch/arm/mach-bcm283x/Kconfig" -source "arch/arm/cpu/arm1176/bcm2835/Kconfig" +source "arch/arm/mach-davinci/Kconfig" source "arch/arm/cpu/armv7/exynos/Kconfig" @@ -834,8 +829,6 @@ source "board/palmtreo680/Kconfig" source "board/phytec/pcm051/Kconfig" source "board/ppcag/bg0900/Kconfig" source "board/pxa255_idp/Kconfig" -source "board/raspberrypi/rpi/Kconfig" -source "board/raspberrypi/rpi_2/Kconfig" source "board/samsung/smdk2410/Kconfig" source "board/sandisk/sansa_fuze_plus/Kconfig" source "board/scb9328/Kconfig" diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 08946de..bac3cb2 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -5,6 +5,7 @@ # Machine directory name. This list is sorted alphanumerically # by CONFIG_* macro name. machine-$(CONFIG_ARCH_AT91) += at91 +machine-$(CONFIG_ARCH_BCM283X) += bcm283x machine-$(CONFIG_ARCH_DAVINCI) += davinci machine-$(CONFIG_ARCH_HIGHBANK) += highbank machine-$(CONFIG_ARCH_KEYSTONE) += keystone diff --git a/arch/arm/cpu/arm1176/Makefile b/arch/arm/cpu/arm1176/Makefile index 480e130..deec427 100644 --- a/arch/arm/cpu/arm1176/Makefile +++ b/arch/arm/cpu/arm1176/Makefile @@ -10,5 +10,3 @@ extra-y = start.o obj-y = cpu.o - -obj-$(CONFIG_BCM2835) += bcm2835/ diff --git a/arch/arm/cpu/arm1176/bcm2835/Kconfig b/arch/arm/cpu/arm1176/bcm2835/Kconfig deleted file mode 100644 index 73cc72b..0000000 --- a/arch/arm/cpu/arm1176/bcm2835/Kconfig +++ /dev/null @@ -1,12 +0,0 @@ -if TARGET_RPI || TARGET_RPI_2 - -config DM - default y - -config DM_SERIAL - default y - -config DM_GPIO - default y - -endif diff --git a/arch/arm/cpu/arm1176/bcm2835/Makefile b/arch/arm/cpu/arm1176/bcm2835/Makefile deleted file mode 100644 index 7e5dbe1..0000000 --- a/arch/arm/cpu/arm1176/bcm2835/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# -# (C) Copyright 2012 Stephen Warren -# -# SPDX-License-Identifier: GPL-2.0 -# - -obj-y := lowlevel_init.o -obj-y += init.o reset.o timer.o mbox.o diff --git a/arch/arm/cpu/arm1176/bcm2835/init.c b/arch/arm/cpu/arm1176/bcm2835/init.c deleted file mode 100644 index e90d3bb..0000000 --- a/arch/arm/cpu/arm1176/bcm2835/init.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * (C) Copyright 2012 Stephen Warren - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include - -int arch_cpu_init(void) -{ - icache_enable(); - - return 0; -} diff --git a/arch/arm/cpu/arm1176/bcm2835/lowlevel_init.S b/arch/arm/cpu/arm1176/bcm2835/lowlevel_init.S deleted file mode 100644 index c7b0843..0000000 --- a/arch/arm/cpu/arm1176/bcm2835/lowlevel_init.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * (C) Copyright 2012 Stephen Warren - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -.globl lowlevel_init -lowlevel_init: - mov pc, lr diff --git a/arch/arm/cpu/arm1176/bcm2835/mbox.c b/arch/arm/cpu/arm1176/bcm2835/mbox.c deleted file mode 100644 index 3b17a31..0000000 --- a/arch/arm/cpu/arm1176/bcm2835/mbox.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * (C) Copyright 2012 Stephen Warren - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include - -#define TIMEOUT 1000 /* ms */ - -int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv) -{ - struct bcm2835_mbox_regs *regs = - (struct bcm2835_mbox_regs *)BCM2835_MBOX_PHYSADDR; - ulong endtime = get_timer(0) + TIMEOUT; - u32 val; - - debug("time: %lu timeout: %lu\n", get_timer(0), endtime); - - if (send & BCM2835_CHAN_MASK) { - printf("mbox: Illegal mbox data 0x%08x\n", send); - return -1; - } - - /* Drain any stale responses */ - - for (;;) { - val = readl(®s->status); - if (val & BCM2835_MBOX_STATUS_RD_EMPTY) - break; - if (get_timer(0) >= endtime) { - printf("mbox: Timeout draining stale responses\n"); - return -1; - } - val = readl(®s->read); - } - - /* Wait for space to send */ - - for (;;) { - val = readl(®s->status); - if (!(val & BCM2835_MBOX_STATUS_WR_FULL)) - break; - if (get_timer(0) >= endtime) { - printf("mbox: Timeout waiting for send space\n"); - return -1; - } - } - - /* Send the request */ - - val = BCM2835_MBOX_PACK(chan, send); - debug("mbox: TX raw: 0x%08x\n", val); - writel(val, ®s->write); - - /* Wait for the response */ - - for (;;) { - val = readl(®s->status); - if (!(val & BCM2835_MBOX_STATUS_RD_EMPTY)) - break; - if (get_timer(0) >= endtime) { - printf("mbox: Timeout waiting for response\n"); - return -1; - } - } - - /* Read the response */ - - val = readl(®s->read); - debug("mbox: RX raw: 0x%08x\n", val); - - /* Validate the response */ - - if (BCM2835_MBOX_UNPACK_CHAN(val) != chan) { - printf("mbox: Response channel mismatch\n"); - return -1; - } - - *recv = BCM2835_MBOX_UNPACK_DATA(val); - - return 0; -} - -#ifdef DEBUG -void dump_buf(struct bcm2835_mbox_hdr *buffer) -{ - u32 *p; - u32 words; - int i; - - p = (u32 *)buffer; - words = buffer->buf_size / 4; - for (i = 0; i < words; i++) - printf(" 0x%04x: 0x%08x\n", i * 4, p[i]); -} -#endif - -int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer) -{ - int ret; - u32 rbuffer; - struct bcm2835_mbox_tag_hdr *tag; - int tag_index; - -#ifdef DEBUG - printf("mbox: TX buffer\n"); - dump_buf(buffer); -#endif - - ret = bcm2835_mbox_call_raw(chan, (u32)buffer, &rbuffer); - if (ret) - return ret; - if (rbuffer != (u32)buffer) { - printf("mbox: Response buffer mismatch\n"); - return -1; - } - -#ifdef DEBUG - printf("mbox: RX buffer\n"); - dump_buf(buffer); -#endif - - /* Validate overall response status */ - - if (buffer->code != BCM2835_MBOX_RESP_CODE_SUCCESS) { - printf("mbox: Header response code invalid\n"); - return -1; - } - - /* Validate each tag's response status */ - - tag = (void *)(buffer + 1); - tag_index = 0; - while (tag->tag) { - if (!(tag->val_len & BCM2835_MBOX_TAG_VAL_LEN_RESPONSE)) { - printf("mbox: Tag %d missing val_len response bit\n", - tag_index); - return -1; - } - /* - * Clear the reponse bit so clients can just look right at the - * length field without extra processing - */ - tag->val_len &= ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE; - tag = (void *)(((u8 *)tag) + sizeof(*tag) + tag->val_buf_size); - tag_index++; - } - - return 0; -} diff --git a/arch/arm/cpu/arm1176/bcm2835/reset.c b/arch/arm/cpu/arm1176/bcm2835/reset.c deleted file mode 100644 index 8c37ad9..0000000 --- a/arch/arm/cpu/arm1176/bcm2835/reset.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (C) Copyright 2012 Stephen Warren - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include - -#define RESET_TIMEOUT 10 - -void reset_cpu(ulong addr) -{ - struct bcm2835_wdog_regs *regs = - (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR; - uint32_t rstc; - - rstc = readl(®s->rstc); - rstc &= ~BCM2835_WDOG_RSTC_WRCFG_MASK; - rstc |= BCM2835_WDOG_RSTC_WRCFG_FULL_RESET; - - writel(BCM2835_WDOG_PASSWORD | RESET_TIMEOUT, ®s->wdog); - writel(BCM2835_WDOG_PASSWORD | rstc, ®s->rstc); -} diff --git a/arch/arm/cpu/arm1176/bcm2835/timer.c b/arch/arm/cpu/arm1176/bcm2835/timer.c deleted file mode 100644 index 017907c..0000000 --- a/arch/arm/cpu/arm1176/bcm2835/timer.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (C) Copyright 2012 Stephen Warren - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include - -ulong get_timer_us(ulong base) -{ - struct bcm2835_timer_regs *regs = - (struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR; - - return readl(®s->clo) - base; -} - -ulong get_timer(ulong base) -{ - ulong us = get_timer_us(0); - us /= (1000000 / CONFIG_SYS_HZ); - us -= base; - return us; -} - -unsigned long long get_ticks(void) -{ - return get_timer(0); -} - -ulong get_tbclk(void) -{ - return CONFIG_SYS_HZ; -} - -void __udelay(unsigned long usec) -{ - ulong endtime; - signed long diff; - - endtime = get_timer_us(0) + usec; - - do { - ulong now = get_timer_us(0); - diff = endtime - now; - } while (diff >= 0); -} diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index 1312a9d..21fc03b 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -39,7 +39,6 @@ endif obj-$(if $(filter am33xx,$(SOC)),y) += am33xx/ obj-$(if $(filter armada-xp,$(SOC)),y) += armada-xp/ -obj-$(CONFIG_BCM2835) += bcm2835/ obj-$(if $(filter bcm281xx,$(SOC)),y) += bcm281xx/ obj-$(if $(filter bcmcygnus,$(SOC)),y) += bcmcygnus/ obj-$(if $(filter bcmnsp,$(SOC)),y) += bcmnsp/ diff --git a/arch/arm/cpu/armv7/bcm2835/Makefile b/arch/arm/cpu/armv7/bcm2835/Makefile deleted file mode 100644 index ed1ee47..0000000 --- a/arch/arm/cpu/armv7/bcm2835/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# -# (C) Copyright 2012 Stephen Warren -# -# SPDX-License-Identifier: GPL-2.0+ -# - -src_dir := ../../arm1176/bcm2835/ - -obj-y := -obj-y += $(src_dir)/init.o -obj-y += $(src_dir)/reset.o -obj-y += $(src_dir)/timer.o -obj-y += $(src_dir)/mbox.o diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig new file mode 100644 index 0000000..d5e09e8 --- /dev/null +++ b/arch/arm/mach-bcm283x/Kconfig @@ -0,0 +1,40 @@ +menu "Broadcom BCM283X family" + depends on ARCH_BCM283X + +choice + prompt "Broadcom BCM283X board select" + +config TARGET_RPI + bool "Raspberry Pi" + select CPU_ARM1176 + +config TARGET_RPI_2 + bool "Raspberry Pi 2" + select CPU_V7 + +endchoice + +config DM + default y + +config DM_SERIAL + default y + +config DM_GPIO + default y + +config SYS_BOARD + default "rpi" if TARGET_RPI + default "rpi_2" if TARGET_RPI_2 + +config SYS_VENDOR + default "raspberrypi" + +config SYS_SOC + default "bcm2835" + +config SYS_CONFIG_NAME + default "rpi" if TARGET_RPI + default "rpi_2" if TARGET_RPI_2 + +endmenu diff --git a/arch/arm/mach-bcm283x/Makefile b/arch/arm/mach-bcm283x/Makefile new file mode 100644 index 0000000..2505428 --- /dev/null +++ b/arch/arm/mach-bcm283x/Makefile @@ -0,0 +1,8 @@ +# +# (C) Copyright 2012 Stephen Warren +# +# SPDX-License-Identifier: GPL-2.0 +# + +obj-$(CONFIG_TARGET_RPI) += lowlevel_init.o +obj-y += init.o reset.o timer.o mbox.o diff --git a/arch/arm/mach-bcm283x/init.c b/arch/arm/mach-bcm283x/init.c new file mode 100644 index 0000000..e90d3bb --- /dev/null +++ b/arch/arm/mach-bcm283x/init.c @@ -0,0 +1,24 @@ +/* + * (C) Copyright 2012 Stephen Warren + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include + +int arch_cpu_init(void) +{ + icache_enable(); + + return 0; +} diff --git a/arch/arm/mach-bcm283x/lowlevel_init.S b/arch/arm/mach-bcm283x/lowlevel_init.S new file mode 100644 index 0000000..c7b0843 --- /dev/null +++ b/arch/arm/mach-bcm283x/lowlevel_init.S @@ -0,0 +1,19 @@ +/* + * (C) Copyright 2012 Stephen Warren + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +.globl lowlevel_init +lowlevel_init: + mov pc, lr diff --git a/arch/arm/mach-bcm283x/mbox.c b/arch/arm/mach-bcm283x/mbox.c new file mode 100644 index 0000000..3b17a31 --- /dev/null +++ b/arch/arm/mach-bcm283x/mbox.c @@ -0,0 +1,153 @@ +/* + * (C) Copyright 2012 Stephen Warren + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +#define TIMEOUT 1000 /* ms */ + +int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv) +{ + struct bcm2835_mbox_regs *regs = + (struct bcm2835_mbox_regs *)BCM2835_MBOX_PHYSADDR; + ulong endtime = get_timer(0) + TIMEOUT; + u32 val; + + debug("time: %lu timeout: %lu\n", get_timer(0), endtime); + + if (send & BCM2835_CHAN_MASK) { + printf("mbox: Illegal mbox data 0x%08x\n", send); + return -1; + } + + /* Drain any stale responses */ + + for (;;) { + val = readl(®s->status); + if (val & BCM2835_MBOX_STATUS_RD_EMPTY) + break; + if (get_timer(0) >= endtime) { + printf("mbox: Timeout draining stale responses\n"); + return -1; + } + val = readl(®s->read); + } + + /* Wait for space to send */ + + for (;;) { + val = readl(®s->status); + if (!(val & BCM2835_MBOX_STATUS_WR_FULL)) + break; + if (get_timer(0) >= endtime) { + printf("mbox: Timeout waiting for send space\n"); + return -1; + } + } + + /* Send the request */ + + val = BCM2835_MBOX_PACK(chan, send); + debug("mbox: TX raw: 0x%08x\n", val); + writel(val, ®s->write); + + /* Wait for the response */ + + for (;;) { + val = readl(®s->status); + if (!(val & BCM2835_MBOX_STATUS_RD_EMPTY)) + break; + if (get_timer(0) >= endtime) { + printf("mbox: Timeout waiting for response\n"); + return -1; + } + } + + /* Read the response */ + + val = readl(®s->read); + debug("mbox: RX raw: 0x%08x\n", val); + + /* Validate the response */ + + if (BCM2835_MBOX_UNPACK_CHAN(val) != chan) { + printf("mbox: Response channel mismatch\n"); + return -1; + } + + *recv = BCM2835_MBOX_UNPACK_DATA(val); + + return 0; +} + +#ifdef DEBUG +void dump_buf(struct bcm2835_mbox_hdr *buffer) +{ + u32 *p; + u32 words; + int i; + + p = (u32 *)buffer; + words = buffer->buf_size / 4; + for (i = 0; i < words; i++) + printf(" 0x%04x: 0x%08x\n", i * 4, p[i]); +} +#endif + +int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer) +{ + int ret; + u32 rbuffer; + struct bcm2835_mbox_tag_hdr *tag; + int tag_index; + +#ifdef DEBUG + printf("mbox: TX buffer\n"); + dump_buf(buffer); +#endif + + ret = bcm2835_mbox_call_raw(chan, (u32)buffer, &rbuffer); + if (ret) + return ret; + if (rbuffer != (u32)buffer) { + printf("mbox: Response buffer mismatch\n"); + return -1; + } + +#ifdef DEBUG + printf("mbox: RX buffer\n"); + dump_buf(buffer); +#endif + + /* Validate overall response status */ + + if (buffer->code != BCM2835_MBOX_RESP_CODE_SUCCESS) { + printf("mbox: Header response code invalid\n"); + return -1; + } + + /* Validate each tag's response status */ + + tag = (void *)(buffer + 1); + tag_index = 0; + while (tag->tag) { + if (!(tag->val_len & BCM2835_MBOX_TAG_VAL_LEN_RESPONSE)) { + printf("mbox: Tag %d missing val_len response bit\n", + tag_index); + return -1; + } + /* + * Clear the reponse bit so clients can just look right at the + * length field without extra processing + */ + tag->val_len &= ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE; + tag = (void *)(((u8 *)tag) + sizeof(*tag) + tag->val_buf_size); + tag_index++; + } + + return 0; +} diff --git a/arch/arm/mach-bcm283x/reset.c b/arch/arm/mach-bcm283x/reset.c new file mode 100644 index 0000000..8c37ad9 --- /dev/null +++ b/arch/arm/mach-bcm283x/reset.c @@ -0,0 +1,35 @@ +/* + * (C) Copyright 2012 Stephen Warren + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +#define RESET_TIMEOUT 10 + +void reset_cpu(ulong addr) +{ + struct bcm2835_wdog_regs *regs = + (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR; + uint32_t rstc; + + rstc = readl(®s->rstc); + rstc &= ~BCM2835_WDOG_RSTC_WRCFG_MASK; + rstc |= BCM2835_WDOG_RSTC_WRCFG_FULL_RESET; + + writel(BCM2835_WDOG_PASSWORD | RESET_TIMEOUT, ®s->wdog); + writel(BCM2835_WDOG_PASSWORD | rstc, ®s->rstc); +} diff --git a/arch/arm/mach-bcm283x/timer.c b/arch/arm/mach-bcm283x/timer.c new file mode 100644 index 0000000..017907c --- /dev/null +++ b/arch/arm/mach-bcm283x/timer.c @@ -0,0 +1,58 @@ +/* + * (C) Copyright 2012 Stephen Warren + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +ulong get_timer_us(ulong base) +{ + struct bcm2835_timer_regs *regs = + (struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR; + + return readl(®s->clo) - base; +} + +ulong get_timer(ulong base) +{ + ulong us = get_timer_us(0); + us /= (1000000 / CONFIG_SYS_HZ); + us -= base; + return us; +} + +unsigned long long get_ticks(void) +{ + return get_timer(0); +} + +ulong get_tbclk(void) +{ + return CONFIG_SYS_HZ; +} + +void __udelay(unsigned long usec) +{ + ulong endtime; + signed long diff; + + endtime = get_timer_us(0) + usec; + + do { + ulong now = get_timer_us(0); + diff = endtime - now; + } while (diff >= 0); +} diff --git a/board/raspberrypi/rpi/Kconfig b/board/raspberrypi/rpi/Kconfig deleted file mode 100644 index 6a538cf..0000000 --- a/board/raspberrypi/rpi/Kconfig +++ /dev/null @@ -1,15 +0,0 @@ -if TARGET_RPI - -config SYS_BOARD - default "rpi" - -config SYS_VENDOR - default "raspberrypi" - -config SYS_SOC - default "bcm2835" - -config SYS_CONFIG_NAME - default "rpi" - -endif diff --git a/board/raspberrypi/rpi_2/Kconfig b/board/raspberrypi/rpi_2/Kconfig deleted file mode 100644 index 032184d..0000000 --- a/board/raspberrypi/rpi_2/Kconfig +++ /dev/null @@ -1,15 +0,0 @@ -if TARGET_RPI_2 - -config SYS_BOARD - default "rpi_2" - -config SYS_VENDOR - default "raspberrypi" - -config SYS_SOC - default "bcm2835" - -config SYS_CONFIG_NAME - default "rpi_2" - -endif diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig index 3075321..965fcae 100644 --- a/configs/rpi_2_defconfig +++ b/configs/rpi_2_defconfig @@ -1,2 +1,3 @@ CONFIG_ARM=y +CONFIG_ARCH_BCM283X=y CONFIG_TARGET_RPI_2=y diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig index 9379cf0..8de1d9f 100644 --- a/configs/rpi_defconfig +++ b/configs/rpi_defconfig @@ -1,2 +1,3 @@ CONFIG_ARM=y +CONFIG_ARCH_BCM283X=y CONFIG_TARGET_RPI=y -- cgit v0.10.2 From d6c418e4b8036038505ac67bf5d85a19ca2c650d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Mar 2015 19:42:57 +0900 Subject: ARM: bcm283x: move SoC headers to mach-bcm283x/include/mach Move arch/arm/include/asm/arch-bcm283x/* -> arch/arm/mach-bcm283x/include/mach/* Signed-off-by: Masahiro Yamada Acked-by: Stephen Warren diff --git a/arch/arm/include/asm/arch-bcm2835/gpio.h b/arch/arm/include/asm/arch-bcm2835/gpio.h deleted file mode 100644 index c8ef8f5..0000000 --- a/arch/arm/include/asm/arch-bcm2835/gpio.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2012 Vikram Narayananan - * - * (C) Copyright 2012,2015 Stephen Warren - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef _BCM2835_GPIO_H_ -#define _BCM2835_GPIO_H_ - -#ifdef CONFIG_BCM2836 -#define BCM2835_GPIO_BASE 0x3f200000 -#else -#define BCM2835_GPIO_BASE 0x20200000 -#endif -#define BCM2835_GPIO_COUNT 54 - -#define BCM2835_GPIO_FSEL_MASK 0x7 -#define BCM2835_GPIO_INPUT 0x0 -#define BCM2835_GPIO_OUTPUT 0x1 -#define BCM2835_GPIO_ALT0 0x4 -#define BCM2835_GPIO_ALT1 0x5 -#define BCM2835_GPIO_ALT2 0x6 -#define BCM2835_GPIO_ALT3 0x7 -#define BCM2835_GPIO_ALT4 0x3 -#define BCM2835_GPIO_ALT5 0x2 - -#define BCM2835_GPIO_COMMON_BANK(gpio) ((gpio < 32) ? 0 : 1) -#define BCM2835_GPIO_COMMON_SHIFT(gpio) (gpio & 0x1f) - -#define BCM2835_GPIO_FSEL_BANK(gpio) (gpio / 10) -#define BCM2835_GPIO_FSEL_SHIFT(gpio) ((gpio % 10) * 3) - -struct bcm2835_gpio_regs { - u32 gpfsel[6]; - u32 reserved1; - u32 gpset[2]; - u32 reserved2; - u32 gpclr[2]; - u32 reserved3; - u32 gplev[2]; - u32 reserved4; - u32 gpeds[2]; - u32 reserved5; - u32 gpren[2]; - u32 reserved6; - u32 gpfen[2]; - u32 reserved7; - u32 gphen[2]; - u32 reserved8; - u32 gplen[2]; - u32 reserved9; - u32 gparen[2]; - u32 reserved10; - u32 gppud; - u32 gppudclk[2]; -}; - -/** - * struct bcm2835_gpio_platdata - GPIO platform description - * - * @base: Base address of GPIO controller - */ -struct bcm2835_gpio_platdata { - unsigned long base; -}; - -#endif /* _BCM2835_GPIO_H_ */ diff --git a/arch/arm/include/asm/arch-bcm2835/mbox.h b/arch/arm/include/asm/arch-bcm2835/mbox.h deleted file mode 100644 index 04bf480..0000000 --- a/arch/arm/include/asm/arch-bcm2835/mbox.h +++ /dev/null @@ -1,527 +0,0 @@ -/* - * (C) Copyright 2012,2015 Stephen Warren - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef _BCM2835_MBOX_H -#define _BCM2835_MBOX_H - -#include - -/* - * The BCM2835 SoC contains (at least) two CPUs; the VideoCore (a/k/a "GPU") - * and the ARM CPU. The ARM CPU is often thought of as the main CPU. - * However, the VideoCore actually controls the initial SoC boot, and hides - * much of the hardware behind a protocol. This protocol is transported - * using the SoC's mailbox hardware module. - * - * The mailbox hardware supports passing 32-bit values back and forth. - * Presumably by software convention of the firmware, the bottom 4 bits of the - * value are used to indicate a logical channel, and the upper 28 bits are the - * actual payload. Various channels exist using these simple raw messages. See - * https://github.com/raspberrypi/firmware/wiki/Mailboxes for a list. As an - * example, the messages on the power management channel are a bitmask of - * devices whose power should be enabled. - * - * The property mailbox channel passes messages that contain the (16-byte - * aligned) ARM physical address of a memory buffer. This buffer is passed to - * the VC for processing, is modified in-place by the VC, and the address then - * passed back to the ARM CPU as the response mailbox message to indicate - * request completion. The buffers have a generic and extensible format; each - * buffer contains a standard header, a list of "tags", and a terminating zero - * entry. Each tag contains an ID indicating its type, and length fields for - * generic parsing. With some limitations, an arbitrary set of tags may be - * combined together into a single message buffer. This file defines structs - * representing the header and many individual tag layouts and IDs. - */ - -/* Raw mailbox HW */ - -#ifdef CONFIG_BCM2836 -#define BCM2835_MBOX_PHYSADDR 0x3f00b880 -#else -#define BCM2835_MBOX_PHYSADDR 0x2000b880 -#endif - -struct bcm2835_mbox_regs { - u32 read; - u32 rsvd0[5]; - u32 status; - u32 config; - u32 write; -}; - -#define BCM2835_MBOX_STATUS_WR_FULL 0x80000000 -#define BCM2835_MBOX_STATUS_RD_EMPTY 0x40000000 - -/* Lower 4-bits are channel ID */ -#define BCM2835_CHAN_MASK 0xf -#define BCM2835_MBOX_PACK(chan, data) (((data) & (~BCM2835_CHAN_MASK)) | \ - (chan & BCM2835_CHAN_MASK)) -#define BCM2835_MBOX_UNPACK_CHAN(val) ((val) & BCM2835_CHAN_MASK) -#define BCM2835_MBOX_UNPACK_DATA(val) ((val) & (~BCM2835_CHAN_MASK)) - -/* Property mailbox buffer structures */ - -#define BCM2835_MBOX_PROP_CHAN 8 - -/* All message buffers must start with this header */ -struct bcm2835_mbox_hdr { - u32 buf_size; - u32 code; -}; - -#define BCM2835_MBOX_REQ_CODE 0 -#define BCM2835_MBOX_RESP_CODE_SUCCESS 0x80000000 - -#define BCM2835_MBOX_INIT_HDR(_m_) { \ - memset((_m_), 0, sizeof(*(_m_))); \ - (_m_)->hdr.buf_size = sizeof(*(_m_)); \ - (_m_)->hdr.code = 0; \ - (_m_)->end_tag = 0; \ - } - -/* - * A message buffer contains a list of tags. Each tag must also start with - * a standardized header. - */ -struct bcm2835_mbox_tag_hdr { - u32 tag; - u32 val_buf_size; - u32 val_len; -}; - -#define BCM2835_MBOX_INIT_TAG(_t_, _id_) { \ - (_t_)->tag_hdr.tag = BCM2835_MBOX_TAG_##_id_; \ - (_t_)->tag_hdr.val_buf_size = sizeof((_t_)->body); \ - (_t_)->tag_hdr.val_len = sizeof((_t_)->body.req); \ - } - -#define BCM2835_MBOX_INIT_TAG_NO_REQ(_t_, _id_) { \ - (_t_)->tag_hdr.tag = BCM2835_MBOX_TAG_##_id_; \ - (_t_)->tag_hdr.val_buf_size = sizeof((_t_)->body); \ - (_t_)->tag_hdr.val_len = 0; \ - } - -/* When responding, the VC sets this bit in val_len to indicate a response */ -#define BCM2835_MBOX_TAG_VAL_LEN_RESPONSE 0x80000000 - -/* - * Below we define the ID and struct for many possible tags. This header only - * defines individual tag structs, not entire message structs, since in - * general an arbitrary set of tags may be combined into a single message. - * Clients of the mbox API are expected to define their own overall message - * structures by combining the header, a set of tags, and a terminating - * entry. For example, - * - * struct msg { - * struct bcm2835_mbox_hdr hdr; - * struct bcm2835_mbox_tag_get_arm_mem get_arm_mem; - * ... perhaps other tags here ... - * u32 end_tag; - * }; - */ - -#define BCM2835_MBOX_TAG_GET_BOARD_REV 0x00010002 - -#ifdef CONFIG_BCM2836 -#define BCM2836_BOARD_REV_2_B 0x4 -#else -/* - * 0x2..0xf from: - * http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/ - * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=32733 - * 0x10, 0x11 from swarren's testing - */ -#define BCM2835_BOARD_REV_B_I2C0_2 0x2 -#define BCM2835_BOARD_REV_B_I2C0_3 0x3 -#define BCM2835_BOARD_REV_B_I2C1_4 0x4 -#define BCM2835_BOARD_REV_B_I2C1_5 0x5 -#define BCM2835_BOARD_REV_B_I2C1_6 0x6 -#define BCM2835_BOARD_REV_A_7 0x7 -#define BCM2835_BOARD_REV_A_8 0x8 -#define BCM2835_BOARD_REV_A_9 0x9 -#define BCM2835_BOARD_REV_B_REV2_d 0xd -#define BCM2835_BOARD_REV_B_REV2_e 0xe -#define BCM2835_BOARD_REV_B_REV2_f 0xf -#define BCM2835_BOARD_REV_B_PLUS 0x10 -#define BCM2835_BOARD_REV_CM 0x11 -#define BCM2835_BOARD_REV_A_PLUS 0x12 -#endif - -struct bcm2835_mbox_tag_get_board_rev { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - } req; - struct { - u32 rev; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_MAC_ADDRESS 0x00010003 - -struct bcm2835_mbox_tag_get_mac_address { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - } req; - struct { - u8 mac[6]; - u8 pad[2]; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_ARM_MEMORY 0x00010005 - -struct bcm2835_mbox_tag_get_arm_mem { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - } req; - struct { - u32 mem_base; - u32 mem_size; - } resp; - } body; -}; - -#define BCM2835_MBOX_POWER_DEVID_SDHCI 0 -#define BCM2835_MBOX_POWER_DEVID_UART0 1 -#define BCM2835_MBOX_POWER_DEVID_UART1 2 -#define BCM2835_MBOX_POWER_DEVID_USB_HCD 3 -#define BCM2835_MBOX_POWER_DEVID_I2C0 4 -#define BCM2835_MBOX_POWER_DEVID_I2C1 5 -#define BCM2835_MBOX_POWER_DEVID_I2C2 6 -#define BCM2835_MBOX_POWER_DEVID_SPI 7 -#define BCM2835_MBOX_POWER_DEVID_CCP2TX 8 - -#define BCM2835_MBOX_POWER_STATE_RESP_ON (1 << 0) -/* Device doesn't exist */ -#define BCM2835_MBOX_POWER_STATE_RESP_NODEV (1 << 1) - -#define BCM2835_MBOX_TAG_GET_POWER_STATE 0x00020001 - -struct bcm2835_mbox_tag_get_power_state { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - u32 device_id; - } req; - struct { - u32 device_id; - u32 state; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_SET_POWER_STATE 0x00028001 - -#define BCM2835_MBOX_SET_POWER_STATE_REQ_ON (1 << 0) -#define BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT (1 << 1) - -struct bcm2835_mbox_tag_set_power_state { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - u32 device_id; - u32 state; - } req; - struct { - u32 device_id; - u32 state; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_CLOCK_RATE 0x00030002 - -#define BCM2835_MBOX_CLOCK_ID_EMMC 1 -#define BCM2835_MBOX_CLOCK_ID_UART 2 -#define BCM2835_MBOX_CLOCK_ID_ARM 3 -#define BCM2835_MBOX_CLOCK_ID_CORE 4 -#define BCM2835_MBOX_CLOCK_ID_V3D 5 -#define BCM2835_MBOX_CLOCK_ID_H264 6 -#define BCM2835_MBOX_CLOCK_ID_ISP 7 -#define BCM2835_MBOX_CLOCK_ID_SDRAM 8 -#define BCM2835_MBOX_CLOCK_ID_PIXEL 9 -#define BCM2835_MBOX_CLOCK_ID_PWM 10 - -struct bcm2835_mbox_tag_get_clock_rate { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - u32 clock_id; - } req; - struct { - u32 clock_id; - u32 rate_hz; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_ALLOCATE_BUFFER 0x00040001 - -struct bcm2835_mbox_tag_allocate_buffer { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - u32 alignment; - } req; - struct { - u32 fb_address; - u32 fb_size; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_RELEASE_BUFFER 0x00048001 - -struct bcm2835_mbox_tag_release_buffer { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - } req; - struct { - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_BLANK_SCREEN 0x00040002 - -struct bcm2835_mbox_tag_blank_screen { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - /* bit 0 means on, other bots reserved */ - u32 state; - } req; - struct { - u32 state; - } resp; - } body; -}; - -/* Physical means output signal */ -#define BCM2835_MBOX_TAG_GET_PHYSICAL_W_H 0x00040003 -#define BCM2835_MBOX_TAG_TEST_PHYSICAL_W_H 0x00044003 -#define BCM2835_MBOX_TAG_SET_PHYSICAL_W_H 0x00048003 - -struct bcm2835_mbox_tag_physical_w_h { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - /* req not used for get */ - struct { - u32 width; - u32 height; - } req; - struct { - u32 width; - u32 height; - } resp; - } body; -}; - -/* Virtual means display buffer */ -#define BCM2835_MBOX_TAG_GET_VIRTUAL_W_H 0x00040004 -#define BCM2835_MBOX_TAG_TEST_VIRTUAL_W_H 0x00044004 -#define BCM2835_MBOX_TAG_SET_VIRTUAL_W_H 0x00048004 - -struct bcm2835_mbox_tag_virtual_w_h { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - /* req not used for get */ - struct { - u32 width; - u32 height; - } req; - struct { - u32 width; - u32 height; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_DEPTH 0x00040005 -#define BCM2835_MBOX_TAG_TEST_DEPTH 0x00044005 -#define BCM2835_MBOX_TAG_SET_DEPTH 0x00048005 - -struct bcm2835_mbox_tag_depth { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - /* req not used for get */ - struct { - u32 bpp; - } req; - struct { - u32 bpp; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_PIXEL_ORDER 0x00040006 -#define BCM2835_MBOX_TAG_TEST_PIXEL_ORDER 0x00044005 -#define BCM2835_MBOX_TAG_SET_PIXEL_ORDER 0x00048006 - -#define BCM2835_MBOX_PIXEL_ORDER_BGR 0 -#define BCM2835_MBOX_PIXEL_ORDER_RGB 1 - -struct bcm2835_mbox_tag_pixel_order { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - /* req not used for get */ - struct { - u32 order; - } req; - struct { - u32 order; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_ALPHA_MODE 0x00040007 -#define BCM2835_MBOX_TAG_TEST_ALPHA_MODE 0x00044007 -#define BCM2835_MBOX_TAG_SET_ALPHA_MODE 0x00048007 - -#define BCM2835_MBOX_ALPHA_MODE_0_OPAQUE 0 -#define BCM2835_MBOX_ALPHA_MODE_0_TRANSPARENT 1 -#define BCM2835_MBOX_ALPHA_MODE_IGNORED 2 - -struct bcm2835_mbox_tag_alpha_mode { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - /* req not used for get */ - struct { - u32 alpha; - } req; - struct { - u32 alpha; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_PITCH 0x00040008 - -struct bcm2835_mbox_tag_pitch { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - } req; - struct { - u32 pitch; - } resp; - } body; -}; - -/* Offset of display window within buffer */ -#define BCM2835_MBOX_TAG_GET_VIRTUAL_OFFSET 0x00040009 -#define BCM2835_MBOX_TAG_TEST_VIRTUAL_OFFSET 0x00044009 -#define BCM2835_MBOX_TAG_SET_VIRTUAL_OFFSET 0x00048009 - -struct bcm2835_mbox_tag_virtual_offset { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - /* req not used for get */ - struct { - u32 x; - u32 y; - } req; - struct { - u32 x; - u32 y; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_OVERSCAN 0x0004000a -#define BCM2835_MBOX_TAG_TEST_OVERSCAN 0x0004400a -#define BCM2835_MBOX_TAG_SET_OVERSCAN 0x0004800a - -struct bcm2835_mbox_tag_overscan { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - /* req not used for get */ - struct { - u32 top; - u32 bottom; - u32 left; - u32 right; - } req; - struct { - u32 top; - u32 bottom; - u32 left; - u32 right; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_GET_PALETTE 0x0004000b - -struct bcm2835_mbox_tag_get_palette { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - } req; - struct { - u32 data[1024]; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_TEST_PALETTE 0x0004400b - -struct bcm2835_mbox_tag_test_palette { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - u32 offset; - u32 num_entries; - u32 data[256]; - } req; - struct { - u32 is_invalid; - } resp; - } body; -}; - -#define BCM2835_MBOX_TAG_SET_PALETTE 0x0004800b - -struct bcm2835_mbox_tag_set_palette { - struct bcm2835_mbox_tag_hdr tag_hdr; - union { - struct { - u32 offset; - u32 num_entries; - u32 data[256]; - } req; - struct { - u32 is_invalid; - } resp; - } body; -}; - -/* - * Pass a raw u32 message to the VC, and receive a raw u32 back. - * - * Returns 0 for success, any other value for error. - */ -int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv); - -/* - * Pass a complete property-style buffer to the VC, and wait until it has - * been processed. - * - * This function expects a pointer to the mbox_hdr structure in an attempt - * to ensure some degree of type safety. However, some number of tags and - * a termination value are expected to immediately follow the header in - * memory, as required by the property protocol. - * - * Returns 0 for success, any other value for error. - */ -int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer); - -#endif diff --git a/arch/arm/include/asm/arch-bcm2835/sdhci.h b/arch/arm/include/asm/arch-bcm2835/sdhci.h deleted file mode 100644 index 2a21ccb..0000000 --- a/arch/arm/include/asm/arch-bcm2835/sdhci.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * (C) Copyright 2012,2015 Stephen Warren - * - * SPDX-License-Identifier: GPL-2.0 - */ - -#ifndef _BCM2835_SDHCI_H_ -#define _BCM2835_SDHCI_H_ - -#ifdef CONFIG_BCM2836 -#define BCM2835_SDHCI_BASE 0x3f300000 -#else -#define BCM2835_SDHCI_BASE 0x20300000 -#endif - -int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq); - -#endif diff --git a/arch/arm/include/asm/arch-bcm2835/timer.h b/arch/arm/include/asm/arch-bcm2835/timer.h deleted file mode 100644 index fc7aec7..0000000 --- a/arch/arm/include/asm/arch-bcm2835/timer.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * (C) Copyright 2012,2015 Stephen Warren - * - * SPDX-License-Identifier: GPL-2.0 - */ - -#ifndef _BCM2835_TIMER_H -#define _BCM2835_TIMER_H - -#ifdef CONFIG_BCM2836 -#define BCM2835_TIMER_PHYSADDR 0x3f003000 -#else -#define BCM2835_TIMER_PHYSADDR 0x20003000 -#endif - -struct bcm2835_timer_regs { - u32 cs; - u32 clo; - u32 chi; - u32 c0; - u32 c1; - u32 c2; - u32 c3; -}; - -#define BCM2835_TIMER_CS_M3 (1 << 3) -#define BCM2835_TIMER_CS_M2 (1 << 2) -#define BCM2835_TIMER_CS_M1 (1 << 1) -#define BCM2835_TIMER_CS_M0 (1 << 0) - -extern ulong get_timer_us(ulong base); - -#endif diff --git a/arch/arm/include/asm/arch-bcm2835/wdog.h b/arch/arm/include/asm/arch-bcm2835/wdog.h deleted file mode 100644 index beb6a08..0000000 --- a/arch/arm/include/asm/arch-bcm2835/wdog.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * (C) Copyright 2012,2015 Stephen Warren - * - * SPDX-License-Identifier: GPL-2.0 - */ - -#ifndef _BCM2835_TIMER_H -#define _BCM2835_TIMER_H - -#ifdef CONFIG_BCM2836 -#define BCM2835_WDOG_PHYSADDR 0x3f100000 -#else -#define BCM2835_WDOG_PHYSADDR 0x20100000 -#endif - -struct bcm2835_wdog_regs { - u32 unknown0[7]; - u32 rstc; - u32 unknown1; - u32 wdog; -}; - -#define BCM2835_WDOG_PASSWORD 0x5a000000 - -#define BCM2835_WDOG_RSTC_WRCFG_MASK 0x00000030 -#define BCM2835_WDOG_RSTC_WRCFG_FULL_RESET 0x00000020 - -#define BCM2835_WDOG_WDOG_TIMEOUT_MASK 0x0000ffff - -#endif diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig index d5e09e8..b43f2d9 100644 --- a/arch/arm/mach-bcm283x/Kconfig +++ b/arch/arm/mach-bcm283x/Kconfig @@ -31,7 +31,7 @@ config SYS_VENDOR default "raspberrypi" config SYS_SOC - default "bcm2835" + default "bcm283x" config SYS_CONFIG_NAME default "rpi" if TARGET_RPI diff --git a/arch/arm/mach-bcm283x/include/mach/gpio.h b/arch/arm/mach-bcm283x/include/mach/gpio.h new file mode 100644 index 0000000..c8ef8f5 --- /dev/null +++ b/arch/arm/mach-bcm283x/include/mach/gpio.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 Vikram Narayananan + * + * (C) Copyright 2012,2015 Stephen Warren + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _BCM2835_GPIO_H_ +#define _BCM2835_GPIO_H_ + +#ifdef CONFIG_BCM2836 +#define BCM2835_GPIO_BASE 0x3f200000 +#else +#define BCM2835_GPIO_BASE 0x20200000 +#endif +#define BCM2835_GPIO_COUNT 54 + +#define BCM2835_GPIO_FSEL_MASK 0x7 +#define BCM2835_GPIO_INPUT 0x0 +#define BCM2835_GPIO_OUTPUT 0x1 +#define BCM2835_GPIO_ALT0 0x4 +#define BCM2835_GPIO_ALT1 0x5 +#define BCM2835_GPIO_ALT2 0x6 +#define BCM2835_GPIO_ALT3 0x7 +#define BCM2835_GPIO_ALT4 0x3 +#define BCM2835_GPIO_ALT5 0x2 + +#define BCM2835_GPIO_COMMON_BANK(gpio) ((gpio < 32) ? 0 : 1) +#define BCM2835_GPIO_COMMON_SHIFT(gpio) (gpio & 0x1f) + +#define BCM2835_GPIO_FSEL_BANK(gpio) (gpio / 10) +#define BCM2835_GPIO_FSEL_SHIFT(gpio) ((gpio % 10) * 3) + +struct bcm2835_gpio_regs { + u32 gpfsel[6]; + u32 reserved1; + u32 gpset[2]; + u32 reserved2; + u32 gpclr[2]; + u32 reserved3; + u32 gplev[2]; + u32 reserved4; + u32 gpeds[2]; + u32 reserved5; + u32 gpren[2]; + u32 reserved6; + u32 gpfen[2]; + u32 reserved7; + u32 gphen[2]; + u32 reserved8; + u32 gplen[2]; + u32 reserved9; + u32 gparen[2]; + u32 reserved10; + u32 gppud; + u32 gppudclk[2]; +}; + +/** + * struct bcm2835_gpio_platdata - GPIO platform description + * + * @base: Base address of GPIO controller + */ +struct bcm2835_gpio_platdata { + unsigned long base; +}; + +#endif /* _BCM2835_GPIO_H_ */ diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h new file mode 100644 index 0000000..04bf480 --- /dev/null +++ b/arch/arm/mach-bcm283x/include/mach/mbox.h @@ -0,0 +1,527 @@ +/* + * (C) Copyright 2012,2015 Stephen Warren + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _BCM2835_MBOX_H +#define _BCM2835_MBOX_H + +#include + +/* + * The BCM2835 SoC contains (at least) two CPUs; the VideoCore (a/k/a "GPU") + * and the ARM CPU. The ARM CPU is often thought of as the main CPU. + * However, the VideoCore actually controls the initial SoC boot, and hides + * much of the hardware behind a protocol. This protocol is transported + * using the SoC's mailbox hardware module. + * + * The mailbox hardware supports passing 32-bit values back and forth. + * Presumably by software convention of the firmware, the bottom 4 bits of the + * value are used to indicate a logical channel, and the upper 28 bits are the + * actual payload. Various channels exist using these simple raw messages. See + * https://github.com/raspberrypi/firmware/wiki/Mailboxes for a list. As an + * example, the messages on the power management channel are a bitmask of + * devices whose power should be enabled. + * + * The property mailbox channel passes messages that contain the (16-byte + * aligned) ARM physical address of a memory buffer. This buffer is passed to + * the VC for processing, is modified in-place by the VC, and the address then + * passed back to the ARM CPU as the response mailbox message to indicate + * request completion. The buffers have a generic and extensible format; each + * buffer contains a standard header, a list of "tags", and a terminating zero + * entry. Each tag contains an ID indicating its type, and length fields for + * generic parsing. With some limitations, an arbitrary set of tags may be + * combined together into a single message buffer. This file defines structs + * representing the header and many individual tag layouts and IDs. + */ + +/* Raw mailbox HW */ + +#ifdef CONFIG_BCM2836 +#define BCM2835_MBOX_PHYSADDR 0x3f00b880 +#else +#define BCM2835_MBOX_PHYSADDR 0x2000b880 +#endif + +struct bcm2835_mbox_regs { + u32 read; + u32 rsvd0[5]; + u32 status; + u32 config; + u32 write; +}; + +#define BCM2835_MBOX_STATUS_WR_FULL 0x80000000 +#define BCM2835_MBOX_STATUS_RD_EMPTY 0x40000000 + +/* Lower 4-bits are channel ID */ +#define BCM2835_CHAN_MASK 0xf +#define BCM2835_MBOX_PACK(chan, data) (((data) & (~BCM2835_CHAN_MASK)) | \ + (chan & BCM2835_CHAN_MASK)) +#define BCM2835_MBOX_UNPACK_CHAN(val) ((val) & BCM2835_CHAN_MASK) +#define BCM2835_MBOX_UNPACK_DATA(val) ((val) & (~BCM2835_CHAN_MASK)) + +/* Property mailbox buffer structures */ + +#define BCM2835_MBOX_PROP_CHAN 8 + +/* All message buffers must start with this header */ +struct bcm2835_mbox_hdr { + u32 buf_size; + u32 code; +}; + +#define BCM2835_MBOX_REQ_CODE 0 +#define BCM2835_MBOX_RESP_CODE_SUCCESS 0x80000000 + +#define BCM2835_MBOX_INIT_HDR(_m_) { \ + memset((_m_), 0, sizeof(*(_m_))); \ + (_m_)->hdr.buf_size = sizeof(*(_m_)); \ + (_m_)->hdr.code = 0; \ + (_m_)->end_tag = 0; \ + } + +/* + * A message buffer contains a list of tags. Each tag must also start with + * a standardized header. + */ +struct bcm2835_mbox_tag_hdr { + u32 tag; + u32 val_buf_size; + u32 val_len; +}; + +#define BCM2835_MBOX_INIT_TAG(_t_, _id_) { \ + (_t_)->tag_hdr.tag = BCM2835_MBOX_TAG_##_id_; \ + (_t_)->tag_hdr.val_buf_size = sizeof((_t_)->body); \ + (_t_)->tag_hdr.val_len = sizeof((_t_)->body.req); \ + } + +#define BCM2835_MBOX_INIT_TAG_NO_REQ(_t_, _id_) { \ + (_t_)->tag_hdr.tag = BCM2835_MBOX_TAG_##_id_; \ + (_t_)->tag_hdr.val_buf_size = sizeof((_t_)->body); \ + (_t_)->tag_hdr.val_len = 0; \ + } + +/* When responding, the VC sets this bit in val_len to indicate a response */ +#define BCM2835_MBOX_TAG_VAL_LEN_RESPONSE 0x80000000 + +/* + * Below we define the ID and struct for many possible tags. This header only + * defines individual tag structs, not entire message structs, since in + * general an arbitrary set of tags may be combined into a single message. + * Clients of the mbox API are expected to define their own overall message + * structures by combining the header, a set of tags, and a terminating + * entry. For example, + * + * struct msg { + * struct bcm2835_mbox_hdr hdr; + * struct bcm2835_mbox_tag_get_arm_mem get_arm_mem; + * ... perhaps other tags here ... + * u32 end_tag; + * }; + */ + +#define BCM2835_MBOX_TAG_GET_BOARD_REV 0x00010002 + +#ifdef CONFIG_BCM2836 +#define BCM2836_BOARD_REV_2_B 0x4 +#else +/* + * 0x2..0xf from: + * http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/ + * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=32733 + * 0x10, 0x11 from swarren's testing + */ +#define BCM2835_BOARD_REV_B_I2C0_2 0x2 +#define BCM2835_BOARD_REV_B_I2C0_3 0x3 +#define BCM2835_BOARD_REV_B_I2C1_4 0x4 +#define BCM2835_BOARD_REV_B_I2C1_5 0x5 +#define BCM2835_BOARD_REV_B_I2C1_6 0x6 +#define BCM2835_BOARD_REV_A_7 0x7 +#define BCM2835_BOARD_REV_A_8 0x8 +#define BCM2835_BOARD_REV_A_9 0x9 +#define BCM2835_BOARD_REV_B_REV2_d 0xd +#define BCM2835_BOARD_REV_B_REV2_e 0xe +#define BCM2835_BOARD_REV_B_REV2_f 0xf +#define BCM2835_BOARD_REV_B_PLUS 0x10 +#define BCM2835_BOARD_REV_CM 0x11 +#define BCM2835_BOARD_REV_A_PLUS 0x12 +#endif + +struct bcm2835_mbox_tag_get_board_rev { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + u32 rev; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_MAC_ADDRESS 0x00010003 + +struct bcm2835_mbox_tag_get_mac_address { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + u8 mac[6]; + u8 pad[2]; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_ARM_MEMORY 0x00010005 + +struct bcm2835_mbox_tag_get_arm_mem { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + u32 mem_base; + u32 mem_size; + } resp; + } body; +}; + +#define BCM2835_MBOX_POWER_DEVID_SDHCI 0 +#define BCM2835_MBOX_POWER_DEVID_UART0 1 +#define BCM2835_MBOX_POWER_DEVID_UART1 2 +#define BCM2835_MBOX_POWER_DEVID_USB_HCD 3 +#define BCM2835_MBOX_POWER_DEVID_I2C0 4 +#define BCM2835_MBOX_POWER_DEVID_I2C1 5 +#define BCM2835_MBOX_POWER_DEVID_I2C2 6 +#define BCM2835_MBOX_POWER_DEVID_SPI 7 +#define BCM2835_MBOX_POWER_DEVID_CCP2TX 8 + +#define BCM2835_MBOX_POWER_STATE_RESP_ON (1 << 0) +/* Device doesn't exist */ +#define BCM2835_MBOX_POWER_STATE_RESP_NODEV (1 << 1) + +#define BCM2835_MBOX_TAG_GET_POWER_STATE 0x00020001 + +struct bcm2835_mbox_tag_get_power_state { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + u32 device_id; + } req; + struct { + u32 device_id; + u32 state; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_SET_POWER_STATE 0x00028001 + +#define BCM2835_MBOX_SET_POWER_STATE_REQ_ON (1 << 0) +#define BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT (1 << 1) + +struct bcm2835_mbox_tag_set_power_state { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + u32 device_id; + u32 state; + } req; + struct { + u32 device_id; + u32 state; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_CLOCK_RATE 0x00030002 + +#define BCM2835_MBOX_CLOCK_ID_EMMC 1 +#define BCM2835_MBOX_CLOCK_ID_UART 2 +#define BCM2835_MBOX_CLOCK_ID_ARM 3 +#define BCM2835_MBOX_CLOCK_ID_CORE 4 +#define BCM2835_MBOX_CLOCK_ID_V3D 5 +#define BCM2835_MBOX_CLOCK_ID_H264 6 +#define BCM2835_MBOX_CLOCK_ID_ISP 7 +#define BCM2835_MBOX_CLOCK_ID_SDRAM 8 +#define BCM2835_MBOX_CLOCK_ID_PIXEL 9 +#define BCM2835_MBOX_CLOCK_ID_PWM 10 + +struct bcm2835_mbox_tag_get_clock_rate { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + u32 clock_id; + } req; + struct { + u32 clock_id; + u32 rate_hz; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_ALLOCATE_BUFFER 0x00040001 + +struct bcm2835_mbox_tag_allocate_buffer { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + u32 alignment; + } req; + struct { + u32 fb_address; + u32 fb_size; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_RELEASE_BUFFER 0x00048001 + +struct bcm2835_mbox_tag_release_buffer { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_BLANK_SCREEN 0x00040002 + +struct bcm2835_mbox_tag_blank_screen { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + /* bit 0 means on, other bots reserved */ + u32 state; + } req; + struct { + u32 state; + } resp; + } body; +}; + +/* Physical means output signal */ +#define BCM2835_MBOX_TAG_GET_PHYSICAL_W_H 0x00040003 +#define BCM2835_MBOX_TAG_TEST_PHYSICAL_W_H 0x00044003 +#define BCM2835_MBOX_TAG_SET_PHYSICAL_W_H 0x00048003 + +struct bcm2835_mbox_tag_physical_w_h { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + /* req not used for get */ + struct { + u32 width; + u32 height; + } req; + struct { + u32 width; + u32 height; + } resp; + } body; +}; + +/* Virtual means display buffer */ +#define BCM2835_MBOX_TAG_GET_VIRTUAL_W_H 0x00040004 +#define BCM2835_MBOX_TAG_TEST_VIRTUAL_W_H 0x00044004 +#define BCM2835_MBOX_TAG_SET_VIRTUAL_W_H 0x00048004 + +struct bcm2835_mbox_tag_virtual_w_h { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + /* req not used for get */ + struct { + u32 width; + u32 height; + } req; + struct { + u32 width; + u32 height; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_DEPTH 0x00040005 +#define BCM2835_MBOX_TAG_TEST_DEPTH 0x00044005 +#define BCM2835_MBOX_TAG_SET_DEPTH 0x00048005 + +struct bcm2835_mbox_tag_depth { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + /* req not used for get */ + struct { + u32 bpp; + } req; + struct { + u32 bpp; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_PIXEL_ORDER 0x00040006 +#define BCM2835_MBOX_TAG_TEST_PIXEL_ORDER 0x00044005 +#define BCM2835_MBOX_TAG_SET_PIXEL_ORDER 0x00048006 + +#define BCM2835_MBOX_PIXEL_ORDER_BGR 0 +#define BCM2835_MBOX_PIXEL_ORDER_RGB 1 + +struct bcm2835_mbox_tag_pixel_order { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + /* req not used for get */ + struct { + u32 order; + } req; + struct { + u32 order; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_ALPHA_MODE 0x00040007 +#define BCM2835_MBOX_TAG_TEST_ALPHA_MODE 0x00044007 +#define BCM2835_MBOX_TAG_SET_ALPHA_MODE 0x00048007 + +#define BCM2835_MBOX_ALPHA_MODE_0_OPAQUE 0 +#define BCM2835_MBOX_ALPHA_MODE_0_TRANSPARENT 1 +#define BCM2835_MBOX_ALPHA_MODE_IGNORED 2 + +struct bcm2835_mbox_tag_alpha_mode { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + /* req not used for get */ + struct { + u32 alpha; + } req; + struct { + u32 alpha; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_PITCH 0x00040008 + +struct bcm2835_mbox_tag_pitch { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + u32 pitch; + } resp; + } body; +}; + +/* Offset of display window within buffer */ +#define BCM2835_MBOX_TAG_GET_VIRTUAL_OFFSET 0x00040009 +#define BCM2835_MBOX_TAG_TEST_VIRTUAL_OFFSET 0x00044009 +#define BCM2835_MBOX_TAG_SET_VIRTUAL_OFFSET 0x00048009 + +struct bcm2835_mbox_tag_virtual_offset { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + /* req not used for get */ + struct { + u32 x; + u32 y; + } req; + struct { + u32 x; + u32 y; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_OVERSCAN 0x0004000a +#define BCM2835_MBOX_TAG_TEST_OVERSCAN 0x0004400a +#define BCM2835_MBOX_TAG_SET_OVERSCAN 0x0004800a + +struct bcm2835_mbox_tag_overscan { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + /* req not used for get */ + struct { + u32 top; + u32 bottom; + u32 left; + u32 right; + } req; + struct { + u32 top; + u32 bottom; + u32 left; + u32 right; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_GET_PALETTE 0x0004000b + +struct bcm2835_mbox_tag_get_palette { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + u32 data[1024]; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_TEST_PALETTE 0x0004400b + +struct bcm2835_mbox_tag_test_palette { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + u32 offset; + u32 num_entries; + u32 data[256]; + } req; + struct { + u32 is_invalid; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_SET_PALETTE 0x0004800b + +struct bcm2835_mbox_tag_set_palette { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + u32 offset; + u32 num_entries; + u32 data[256]; + } req; + struct { + u32 is_invalid; + } resp; + } body; +}; + +/* + * Pass a raw u32 message to the VC, and receive a raw u32 back. + * + * Returns 0 for success, any other value for error. + */ +int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv); + +/* + * Pass a complete property-style buffer to the VC, and wait until it has + * been processed. + * + * This function expects a pointer to the mbox_hdr structure in an attempt + * to ensure some degree of type safety. However, some number of tags and + * a termination value are expected to immediately follow the header in + * memory, as required by the property protocol. + * + * Returns 0 for success, any other value for error. + */ +int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer); + +#endif diff --git a/arch/arm/mach-bcm283x/include/mach/sdhci.h b/arch/arm/mach-bcm283x/include/mach/sdhci.h new file mode 100644 index 0000000..2a21ccb --- /dev/null +++ b/arch/arm/mach-bcm283x/include/mach/sdhci.h @@ -0,0 +1,18 @@ +/* + * (C) Copyright 2012,2015 Stephen Warren + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef _BCM2835_SDHCI_H_ +#define _BCM2835_SDHCI_H_ + +#ifdef CONFIG_BCM2836 +#define BCM2835_SDHCI_BASE 0x3f300000 +#else +#define BCM2835_SDHCI_BASE 0x20300000 +#endif + +int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq); + +#endif diff --git a/arch/arm/mach-bcm283x/include/mach/timer.h b/arch/arm/mach-bcm283x/include/mach/timer.h new file mode 100644 index 0000000..fc7aec7 --- /dev/null +++ b/arch/arm/mach-bcm283x/include/mach/timer.h @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2012,2015 Stephen Warren + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef _BCM2835_TIMER_H +#define _BCM2835_TIMER_H + +#ifdef CONFIG_BCM2836 +#define BCM2835_TIMER_PHYSADDR 0x3f003000 +#else +#define BCM2835_TIMER_PHYSADDR 0x20003000 +#endif + +struct bcm2835_timer_regs { + u32 cs; + u32 clo; + u32 chi; + u32 c0; + u32 c1; + u32 c2; + u32 c3; +}; + +#define BCM2835_TIMER_CS_M3 (1 << 3) +#define BCM2835_TIMER_CS_M2 (1 << 2) +#define BCM2835_TIMER_CS_M1 (1 << 1) +#define BCM2835_TIMER_CS_M0 (1 << 0) + +extern ulong get_timer_us(ulong base); + +#endif diff --git a/arch/arm/mach-bcm283x/include/mach/wdog.h b/arch/arm/mach-bcm283x/include/mach/wdog.h new file mode 100644 index 0000000..beb6a08 --- /dev/null +++ b/arch/arm/mach-bcm283x/include/mach/wdog.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2012,2015 Stephen Warren + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef _BCM2835_TIMER_H +#define _BCM2835_TIMER_H + +#ifdef CONFIG_BCM2836 +#define BCM2835_WDOG_PHYSADDR 0x3f100000 +#else +#define BCM2835_WDOG_PHYSADDR 0x20100000 +#endif + +struct bcm2835_wdog_regs { + u32 unknown0[7]; + u32 rstc; + u32 unknown1; + u32 wdog; +}; + +#define BCM2835_WDOG_PASSWORD 0x5a000000 + +#define BCM2835_WDOG_RSTC_WRCFG_MASK 0x00000030 +#define BCM2835_WDOG_RSTC_WRCFG_FULL_RESET 0x00000020 + +#define BCM2835_WDOG_WDOG_TIMEOUT_MASK 0x0000ffff + +#endif diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c index 92f7d89..4ec2968 100644 --- a/drivers/mmc/bcm2835_sdhci.c +++ b/drivers/mmc/bcm2835_sdhci.c @@ -39,8 +39,8 @@ #include #include #include -#include -#include +#include +#include /* 400KHz is max freq for card ID etc. Use that as min */ #define MIN_FREQ 400000 -- cgit v0.10.2 From 490cf5f0c9edef119baa477a62f9f92188931a4f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 10:59:01 +0900 Subject: kbuild: merge generic-asm-offsets.h and asm-offsets.h rules The rules "cmd_generic-offsets" and "cmd_offsets" are almost the same. (The difference is only the include guards.) They can be merged. This commit is mostly inspired by the following commit of Linux. commit 39664e2f3cdef98f42437e903159a6044a1d99d6 Author: Masahiro Yamada Date: Mon Jan 5 15:57:15 2015 +0900 kbuild: merge bounds.h and asm-offsets.h rules Signed-off-by: Masahiro Yamada diff --git a/Kbuild b/Kbuild index ef97787..979555f 100644 --- a/Kbuild +++ b/Kbuild @@ -4,19 +4,20 @@ # 1) Generate generic-asm-offsets.h # 2) Generate asm-offsets.h -##### -# 1) Generate generic-asm-offsets.h - -generic-offsets-file := include/generated/generic-asm-offsets.h - -always := $(generic-offsets-file) -targets := $(generic-offsets-file) lib/asm-offsets.s +# Default sed regexp - multiline due to syntax constraints +define sed-y + "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \ + /^->/{s:->#\(.*\):/* \1 */:; \ + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:->::; p;}" +endef -quiet_cmd_generic-offsets = GEN $@ -define cmd_generic-offsets +quiet_cmd_offsets = GEN $@ +define cmd_offsets (set -e; \ - echo "#ifndef __GENERIC_ASM_OFFSETS_H__"; \ - echo "#define __GENERIC_ASM_OFFSETS_H__"; \ + echo "#ifndef $2"; \ + echo "#define $2"; \ echo "/*"; \ echo " * DO NOT MODIFY."; \ echo " *"; \ @@ -29,6 +30,14 @@ define cmd_generic-offsets echo "#endif" ) > $@ endef +##### +# 1) Generate generic-asm-offsets.h + +generic-offsets-file := include/generated/generic-asm-offsets.h + +always := $(generic-offsets-file) +targets := $(generic-offsets-file) lib/asm-offsets.s + # We use internal kbuild rules to avoid the "is up to date" message from make lib/asm-offsets.s: lib/asm-offsets.c FORCE $(Q)mkdir -p $(dir $@) @@ -36,7 +45,7 @@ lib/asm-offsets.s: lib/asm-offsets.c FORCE $(obj)/$(generic-offsets-file): lib/asm-offsets.s Kbuild $(Q)mkdir -p $(dir $@) - $(call cmd,generic-offsets) + $(call cmd,offsets,__GENERIC_ASM_OFFSETS_H__) ##### # 2) Generate asm-offsets.h @@ -50,39 +59,12 @@ always += $(offsets-file) targets += $(offsets-file) targets += arch/$(ARCH)/lib/asm-offsets.s - -# Default sed regexp - multiline due to syntax constraints -define sed-y - "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \ - /^->/{s:->#\(.*\):/* \1 */:; \ - s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:->::; p;}" -endef - CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY -quiet_cmd_offsets = GEN $@ -define cmd_offsets - (set -e; \ - echo "#ifndef __ASM_OFFSETS_H__"; \ - echo "#define __ASM_OFFSETS_H__"; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was generated by Kbuild"; \ - echo " *"; \ - echo " */"; \ - echo ""; \ - sed -ne $(sed-y) $<; \ - echo ""; \ - echo "#endif" ) > $@ -endef - # We use internal kbuild rules to avoid the "is up to date" message from make arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE $(Q)mkdir -p $(dir $@) $(call if_changed_dep,cc_s_c) $(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s Kbuild - $(call cmd,offsets) + $(call cmd,offsets,__ASM_OFFSETS_H__) -- cgit v0.10.2 From d99cd32f05597f18fa1691404e112827972a8868 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 10:59:02 +0900 Subject: kbuild: remove redundant line from (generic-)asm-offsets.h This line produces an extra comment line for generic-asm-offsets.h and asm-offsets.h. Signed-off-by: Masahiro Yamada Signed-off-by: Michal Marek [ imported from Linux Kernel, commit 343d3e6cc861, with modification of commit description ] Signed-off-by: Masahiro Yamada diff --git a/Kbuild b/Kbuild index 979555f..51f7433 100644 --- a/Kbuild +++ b/Kbuild @@ -22,7 +22,6 @@ define cmd_offsets echo " * DO NOT MODIFY."; \ echo " *"; \ echo " * This file was generated by Kbuild"; \ - echo " *"; \ echo " */"; \ echo ""; \ sed -ne $(sed-y) $<; \ -- cgit v0.10.2 From 3a4f6b60db1b3fd43ca0449f9259ebdf4f5d4b62 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 27 Mar 2015 10:59:03 +0900 Subject: kbuild: Don't reset timestamps in include/generated if not needed Use filechk to generate asm-offsets.h and generic-asm-offsets.h. Based on a patch by Valdis Kletnieks. Reported-by: Valdis Kletnieks Acked-by: Valdis Kletnieks Reviewed-by: Masahiro Yamada Signed-off-by: Michal Marek [ imported from Linux Kernel, commit 70a4fd6c56d0, with adjustment for U-Boot ] Signed-off-by: Masahiro Yamada diff --git a/Kbuild b/Kbuild index 51f7433..465b930 100644 --- a/Kbuild +++ b/Kbuild @@ -13,8 +13,9 @@ define sed-y s:->::; p;}" endef -quiet_cmd_offsets = GEN $@ -define cmd_offsets +# Use filechk to avoid rebuilds when a header changes, but the resulting file +# does not +define filechk_offsets (set -e; \ echo "#ifndef $2"; \ echo "#define $2"; \ @@ -24,9 +25,9 @@ define cmd_offsets echo " * This file was generated by Kbuild"; \ echo " */"; \ echo ""; \ - sed -ne $(sed-y) $<; \ + sed -ne $(sed-y); \ echo ""; \ - echo "#endif" ) > $@ + echo "#endif" ) endef ##### @@ -42,9 +43,8 @@ lib/asm-offsets.s: lib/asm-offsets.c FORCE $(Q)mkdir -p $(dir $@) $(call if_changed_dep,cc_s_c) -$(obj)/$(generic-offsets-file): lib/asm-offsets.s Kbuild - $(Q)mkdir -p $(dir $@) - $(call cmd,offsets,__GENERIC_ASM_OFFSETS_H__) +$(obj)/$(generic-offsets-file): lib/asm-offsets.s FORCE + $(call filechk,offsets,__GENERIC_ASM_OFFSETS_H__) ##### # 2) Generate asm-offsets.h @@ -65,5 +65,5 @@ arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE $(Q)mkdir -p $(dir $@) $(call if_changed_dep,cc_s_c) -$(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s Kbuild - $(call cmd,offsets,__ASM_OFFSETS_H__) +$(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s FORCE + $(call filechk,offsets,__ASM_OFFSETS_H__) -- cgit v0.10.2 From d4a9b17df590c1b0b2a187e1491ea7e946a06a07 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 17:01:06 +0900 Subject: m68k: mcf52x2: move CPU type to Kconfig and refactor config.mk This commit intends to stop grepping CPU type in arch/m68k/cpu/mcf52x2/config.mk. Move the CPU type config options from include/configs/*.h to arch/m68k/Kconfig and refactor the CPU flags select in arch/m68k/cpu/mcf52x2/config.mk. Signed-off-by: Masahiro Yamada Cc: Alison Wang Cc: Angelo Dureghello diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 53c4aab..0bd780a 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -4,6 +4,42 @@ menu "M68000 architecture" config SYS_ARCH default "m68k" +# processor family +config MCF520x + bool + +config MCF52x2 + bool + +# processor type +config M5208 + bool + select MCF520x + +config M5249 + bool + select MCF52x2 + +config M5253 + bool + select MCF52x2 + +config M5271 + bool + select MCF52x2 + +config M5272 + bool + select MCF52x2 + +config M5275 + bool + select MCF52x2 + +config M5282 + bool + select MCF52x2 + choice prompt "Target select" @@ -15,30 +51,39 @@ config TARGET_M5235EVB config TARGET_COBRA5272 bool "Support cobra5272" + select M5272 config TARGET_EB_CPU5282 bool "Support eb_cpu5282" + select M5282 config TARGET_M5208EVBE bool "Support M5208EVBE" + select M5208 config TARGET_M5249EVB bool "Support M5249EVB" + select M5249 config TARGET_M5253DEMO bool "Support M5253DEMO" + select M5253 config TARGET_M5253EVBE bool "Support M5253EVBE" + select M5253 config TARGET_M5272C3 bool "Support M5272C3" + select M5272 config TARGET_M5275EVB bool "Support M5275EVB" + select M5275 config TARGET_M5282EVB bool "Support M5282EVB" + select M5282 config TARGET_ASTRO_MCF5373L bool "Support astro_mcf5373l" diff --git a/arch/m68k/cpu/mcf52x2/config.mk b/arch/m68k/cpu/mcf52x2/config.mk index f66000b..f8fdefd 100644 --- a/arch/m68k/cpu/mcf52x2/config.mk +++ b/arch/m68k/cpu/mcf52x2/config.mk @@ -7,33 +7,12 @@ # SPDX-License-Identifier: GPL-2.0+ # -cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h -is5208:=$(shell grep CONFIG_M5208 $(cfg)) -is5249:=$(shell grep CONFIG_M5249 $(cfg)) -is5253:=$(shell grep CONFIG_M5253 $(cfg)) -is5271:=$(shell grep CONFIG_M5271 $(cfg)) -is5272:=$(shell grep CONFIG_M5272 $(cfg)) -is5275:=$(shell grep CONFIG_M5275 $(cfg)) -is5282:=$(shell grep CONFIG_M5282 $(cfg)) +cpuflags-$(CONFIG_M5208) := -mcpu=5208 +cpuflags-$(CONFIG_M5249) := -mcpu=5249 +cpuflags-$(CONFIG_M5253) := -mcpu=5253 +cpuflags-$(CONFIG_M5271) := -mcpu=5271 +cpuflags-$(CONFIG_M5272) := -mcpu=5272 +cpuflags-$(CONFIG_M5275) := -mcpu=5275 +cpuflags-$(CONFIG_M5282) := -mcpu=5282 -ifneq (,$(findstring CONFIG_M5208,$(is5208))) -PLATFORM_CPPFLAGS += -mcpu=5208 -endif -ifneq (,$(findstring CONFIG_M5249,$(is5249))) -PLATFORM_CPPFLAGS += -mcpu=5249 -endif -ifneq (,$(findstring CONFIG_M5253,$(is5253))) -PLATFORM_CPPFLAGS += -mcpu=5253 -endif -ifneq (,$(findstring CONFIG_M5271,$(is5271))) -PLATFORM_CPPFLAGS += -mcpu=5271 -endif -ifneq (,$(findstring CONFIG_M5272,$(is5272))) -PLATFORM_CPPFLAGS += -mcpu=5272 -endif -ifneq (,$(findstring CONFIG_M5275,$(is5275))) -PLATFORM_CPPFLAGS += -mcpu=5275 -endif -ifneq (,$(findstring CONFIG_M5282,$(is5282))) -PLATFORM_CPPFLAGS += -mcpu=5282 -endif +PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/include/configs/M5208EVBE.h b/include/configs/M5208EVBE.h index 6630377..9390464 100644 --- a/include/configs/M5208EVBE.h +++ b/include/configs/M5208EVBE.h @@ -14,9 +14,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF520x /* define processor family */ -#define CONFIG_M5208 /* define processor type */ - #define CONFIG_MCFUART #define CONFIG_SYS_UART_PORT (0) #define CONFIG_BAUDRATE 115200 diff --git a/include/configs/M5249EVB.h b/include/configs/M5249EVB.h index ae4fe45..60e5b45 100644 --- a/include/configs/M5249EVB.h +++ b/include/configs/M5249EVB.h @@ -18,9 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF52x2 /* define processor family */ -#define CONFIG_M5249 /* define processor type */ - #define CONFIG_MCFTMR #define CONFIG_MCFUART diff --git a/include/configs/M5253DEMO.h b/include/configs/M5253DEMO.h index 3a1cbca..7421b57 100644 --- a/include/configs/M5253DEMO.h +++ b/include/configs/M5253DEMO.h @@ -7,8 +7,6 @@ #ifndef _M5253DEMO_H #define _M5253DEMO_H -#define CONFIG_MCF52x2 /* define processor family */ -#define CONFIG_M5253 /* define processor type */ #define CONFIG_M5253DEMO /* define board type */ #define CONFIG_MCFTMR diff --git a/include/configs/M5253EVBE.h b/include/configs/M5253EVBE.h index fabfdb9..8fd3907 100644 --- a/include/configs/M5253EVBE.h +++ b/include/configs/M5253EVBE.h @@ -8,8 +8,6 @@ #ifndef _M5253EVBE_H #define _M5253EVBE_H -#define CONFIG_MCF52x2 /* define processor family */ -#define CONFIG_M5253 /* define processor type */ #define CONFIG_M5253EVBE /* define board type */ #define CONFIG_MCFTMR diff --git a/include/configs/M5272C3.h b/include/configs/M5272C3.h index 4c84126..2c056b1 100644 --- a/include/configs/M5272C3.h +++ b/include/configs/M5272C3.h @@ -17,9 +17,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF52x2 /* define processor family */ -#define CONFIG_M5272 /* define processor type */ - #define CONFIG_MCFTMR #define CONFIG_MCFUART diff --git a/include/configs/M5275EVB.h b/include/configs/M5275EVB.h index 4dddab7..7eb3172 100644 --- a/include/configs/M5275EVB.h +++ b/include/configs/M5275EVB.h @@ -21,8 +21,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF52x2 /* define processor family */ -#define CONFIG_M5275 /* define processor type */ #define CONFIG_M5275EVB /* define board type */ #define CONFIG_MCFTMR diff --git a/include/configs/M5282EVB.h b/include/configs/M5282EVB.h index fd970d0..569ad42 100644 --- a/include/configs/M5282EVB.h +++ b/include/configs/M5282EVB.h @@ -17,9 +17,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF52x2 /* define processor family */ -#define CONFIG_M5282 /* define processor type */ - #define CONFIG_MCFTMR #define CONFIG_MCFUART diff --git a/include/configs/cobra5272.h b/include/configs/cobra5272.h index 4644369..b9f0b0b 100644 --- a/include/configs/cobra5272.h +++ b/include/configs/cobra5272.h @@ -25,16 +25,6 @@ #define _CONFIG_COBRA5272_H /* --- - * Define processor - * possible values for Sentec board: only Coldfire M5272 processor supported - * (please do not change) - * --- - */ - -#define CONFIG_MCF52x2 /* define processor family */ -#define CONFIG_M5272 /* define processor type */ - -/* --- * Defines processor clock - important for correct timings concerning serial * interface etc. * --- diff --git a/include/configs/eb_cpu5282.h b/include/configs/eb_cpu5282.h index bdca705..e2b9326 100644 --- a/include/configs/eb_cpu5282.h +++ b/include/configs/eb_cpu5282.h @@ -15,9 +15,6 @@ * High Level Configuration Options (easy to change) * *----------------------------------------------------------------------*/ -#define CONFIG_MCF52x2 /* define processor family */ -#define CONFIG_M5282 /* define processor type */ - #define CONFIG_MISC_INIT_R #define CONFIG_MCFUART -- cgit v0.10.2 From bdde65951659fb78d3b4bbf99743a74522f03a05 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 17:01:07 +0900 Subject: m68k: mcf530x: move CPU type to Kconfig and refactor config.mk This commit intends to stop grepping CPU type in arch/m68k/cpu/mcf530x/config.mk. Move the CPU type config options from include/configs/amcore.h to arch/m68k/Kconfig and refactor the CPU flags select in arch/m68k/cpu/mcf530x/config.mk. Signed-off-by: Masahiro Yamada Cc: Alison Wang Cc: Angelo Dureghello diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 0bd780a..8f9b4a7 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -11,6 +11,9 @@ config MCF520x config MCF52x2 bool +config MCF530x + bool + # processor type config M5208 bool @@ -40,6 +43,10 @@ config M5282 bool select MCF52x2 +config M5307 + bool + select MCF530x + choice prompt "Target select" @@ -114,6 +121,7 @@ config TARGET_M5485EVB config TARGET_AMCORE bool "Support AMCORE" + select M5307 endchoice diff --git a/arch/m68k/cpu/mcf530x/config.mk b/arch/m68k/cpu/mcf530x/config.mk index aef72d7..25845aa 100644 --- a/arch/m68k/cpu/mcf530x/config.mk +++ b/arch/m68k/cpu/mcf530x/config.mk @@ -4,9 +4,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h -is5307:=$(shell grep CONFIG_M5307 $(cfg)) +cpuflags-$(CONFIG_M5307) := -mcpu=5307 -ifneq (,$(findstring CONFIG_M5307,$(is5307))) -PLATFORM_CPPFLAGS += -mcpu=5307 -endif +PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/include/configs/amcore.h b/include/configs/amcore.h index 37aa124..229fa5a 100644 --- a/include/configs/amcore.h +++ b/include/configs/amcore.h @@ -12,9 +12,6 @@ #define CONFIG_AMCORE #define CONFIG_HOSTNAME AMCORE -#define CONFIG_MCF530x -#define CONFIG_M5307 - #define CONFIG_MCFTMR #define CONFIG_MCFUART #define CONFIG_SYS_UART_PORT 0 -- cgit v0.10.2 From c155ab74f78794979944e5a49d87776cc460c6c9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 17:01:08 +0900 Subject: m68k: mcf532x: move CPU type to Kconfig and refactor config.mk This commit intends to stop grepping CPU type in arch/m68k/cpu/mcf532x/config.mk. Move the CPU type config options from include/configs/*.h to arch/m68k/Kconfig and refactor the CPU flags select in arch/m68k/cpu/mcf532x/config.mk. Signed-off-by: Masahiro Yamada Cc: Alison Wang Cc: Angelo Dureghello diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 8f9b4a7..67308eb 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -14,6 +14,15 @@ config MCF52x2 config MCF530x bool +config MCF5301x + bool + +config MCF532x + bool + +config MCF537x + bool + # processor type config M5208 bool @@ -47,6 +56,19 @@ config M5307 bool select MCF530x +config M53015 + bool + select MCF5301x + +config M5329 + bool + select MCF532x + +config M5373 + bool + select MCF532x + select MCF537x + choice prompt "Target select" @@ -94,15 +116,19 @@ config TARGET_M5282EVB config TARGET_ASTRO_MCF5373L bool "Support astro_mcf5373l" + select M5373 config TARGET_M53017EVB bool "Support M53017EVB" + select M53015 config TARGET_M5329EVB bool "Support M5329EVB" + select M5329 config TARGET_M5373EVB bool "Support M5373EVB" + select M5373 config TARGET_M54418TWR bool "Support M54418TWR" diff --git a/arch/m68k/cpu/mcf532x/config.mk b/arch/m68k/cpu/mcf532x/config.mk index 2efb60f..470d22f 100644 --- a/arch/m68k/cpu/mcf532x/config.mk +++ b/arch/m68k/cpu/mcf532x/config.mk @@ -7,13 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ # -cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h -is5301x:=$(shell grep CONFIG_MCF5301x $(cfg)) -is532x:=$(shell grep CONFIG_MCF532x $(cfg)) +cpuflags-$(CONFIG_MCF5301x) := -mcpu=53015 -fPIC +cpuflags-$(CONFIG_MCF532x) := -mcpu=5329 -fPIC -ifneq (,$(findstring CONFIG_MCF5301x,$(is5301x))) -PLATFORM_CPPFLAGS += -mcpu=53015 -fPIC -endif -ifneq (,$(findstring CONFIG_MCF532x,$(is532x))) -PLATFORM_CPPFLAGS += -mcpu=5329 -fPIC -endif +PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/include/configs/M53017EVB.h b/include/configs/M53017EVB.h index a100d9f..83ac70f 100644 --- a/include/configs/M53017EVB.h +++ b/include/configs/M53017EVB.h @@ -18,8 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF5301x /* define processor family */ -#define CONFIG_M53015 /* define processor type */ #define CONFIG_MCFUART #define CONFIG_SYS_UART_PORT (0) diff --git a/include/configs/M5329EVB.h b/include/configs/M5329EVB.h index 78ea384..795f359 100644 --- a/include/configs/M5329EVB.h +++ b/include/configs/M5329EVB.h @@ -18,8 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF532x /* define processor family */ -#define CONFIG_M5329 /* define processor type */ #define CONFIG_MCFUART #define CONFIG_SYS_UART_PORT (0) diff --git a/include/configs/M5373EVB.h b/include/configs/M5373EVB.h index 849c265..d75b43c 100644 --- a/include/configs/M5373EVB.h +++ b/include/configs/M5373EVB.h @@ -18,8 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF532x /* define processor family */ -#define CONFIG_M5373 /* define processor type */ #define CONFIG_MCFUART #define CONFIG_SYS_UART_PORT (0) diff --git a/include/configs/astro_mcf5373l.h b/include/configs/astro_mcf5373l.h index fa64a68..de837cf 100644 --- a/include/configs/astro_mcf5373l.h +++ b/include/configs/astro_mcf5373l.h @@ -39,16 +39,6 @@ #error No card type defined! #endif -/* - * Define processor - * possible values for Urmel board: only Coldfire M5373 processor supported - * (please do not change) - */ - -/* it seems not clear yet which processor defines we should use */ -#define CONFIG_MCF537x /* define processor family */ -#define CONFIG_MCF532x /* define processor family */ -#define CONFIG_M5373 /* define processor type */ #define CONFIG_ASTRO5373L /* define board type */ /* Command line configuration */ -- cgit v0.10.2 From 7f8ebbf0956818c06be6e28e1c869a1240a3110c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 17:01:09 +0900 Subject: m68k: mcf5445x: move CPU type to Kconfig and refactor config.mk This commit intends to stop grepping CPU type in arch/m68k/cpu/mcf5445x/config.mk. Move the CPU type config options from include/configs/*.h to arch/m68k/Kconfig and refactor the CPU flags select in arch/m68k/cpu/mcf5445x/config.mk. Signed-off-by: Masahiro Yamada Cc: Alison Wang Cc: Angelo Dureghello diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 67308eb..eecef95 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -23,6 +23,12 @@ config MCF532x config MCF537x bool +config MCF5441x + bool + +config MCF5445x + bool + # processor type config M5208 bool @@ -69,6 +75,18 @@ config M5373 select MCF532x select MCF537x +config M54418 + bool + select MCF5441x + +config M54451 + bool + select MCF5445x + +config M54455 + bool + select MCF5445x + choice prompt "Target select" @@ -132,12 +150,15 @@ config TARGET_M5373EVB config TARGET_M54418TWR bool "Support M54418TWR" + select M54418 config TARGET_M54451EVB bool "Support M54451EVB" + select M54451 config TARGET_M54455EVB bool "Support M54455EVB" + select M54455 config TARGET_M5475EVB bool "Support M5475EVB" diff --git a/arch/m68k/cpu/mcf5445x/config.mk b/arch/m68k/cpu/mcf5445x/config.mk index 13f8a9f..c3923c6 100644 --- a/arch/m68k/cpu/mcf5445x/config.mk +++ b/arch/m68k/cpu/mcf5445x/config.mk @@ -9,14 +9,8 @@ # SPDX-License-Identifier: GPL-2.0+ # -cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h -is5441x:=$(shell grep CONFIG_MCF5441x $(cfg)) - -ifneq (,$(findstring CONFIG_MCF5441x,$(is5441x))) -PLATFORM_CPPFLAGS += -mcpu=54418 -fPIC -else -PLATFORM_CPPFLAGS += -mcpu=54455 -fPIC -endif +cpuflags-$(CONFIG_MCF5441x) := -mcpu=54418 -fPIC +cpuflags-$(CONFIG_MCF5445x) := -mcpu=54455 -fPIC ifneq (,$(findstring -linux-,$(shell $(CC) --version))) ifneq (,$(findstring GOT,$(shell $(LD) --help))) diff --git a/include/configs/M54418TWR.h b/include/configs/M54418TWR.h index 3d7dc1f..be1750f 100644 --- a/include/configs/M54418TWR.h +++ b/include/configs/M54418TWR.h @@ -18,8 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF5441x /* define processor family */ -#define CONFIG_M54418 /* define processor type */ #define CONFIG_M54418TWR /* M54418TWR board */ #define CONFIG_MCFUART diff --git a/include/configs/M54451EVB.h b/include/configs/M54451EVB.h index 734a77f..1b3598a 100644 --- a/include/configs/M54451EVB.h +++ b/include/configs/M54451EVB.h @@ -18,8 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF5445x /* define processor family */ -#define CONFIG_M54451 /* define processor type */ #define CONFIG_M54451EVB /* M54451EVB board */ #define CONFIG_DISPLAY_BOARDINFO diff --git a/include/configs/M54455EVB.h b/include/configs/M54455EVB.h index 2faf581..2288bff 100644 --- a/include/configs/M54455EVB.h +++ b/include/configs/M54455EVB.h @@ -18,8 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF5445x /* define processor family */ -#define CONFIG_M54455 /* define processor type */ #define CONFIG_M54455EVB /* M54455EVB board */ #define CONFIG_DISPLAY_BOARDINFO -- cgit v0.10.2 From 2bb1cd53e97f996bc13df425602b85f9f1159db8 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 17:01:10 +0900 Subject: m68k: mcf5227x: move CPU type to Kconfig and refactor config.mk Move the CPU type config options from include/configs/M52277EVB.h to arch/m68k/Kconfig and refactor the CPU flags select in arch/m68k/cpu/mcf5227x/config.mk. Signed-off-by: Masahiro Yamada Cc: Alison Wang Cc: Angelo Dureghello diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index eecef95..a645d95 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -29,6 +29,9 @@ config MCF5441x config MCF5445x bool +config MCF5227x + bool + # processor type config M5208 bool @@ -87,11 +90,16 @@ config M54455 bool select MCF5445x +config M52277 + bool + select MCF5227x + choice prompt "Target select" config TARGET_M52277EVB bool "Support M52277EVB" + select M52277 config TARGET_M5235EVB bool "Support M5235EVB" diff --git a/arch/m68k/cpu/mcf5227x/config.mk b/arch/m68k/cpu/mcf5227x/config.mk index b5c26e4..a6814d8 100644 --- a/arch/m68k/cpu/mcf5227x/config.mk +++ b/arch/m68k/cpu/mcf5227x/config.mk @@ -7,4 +7,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -PLATFORM_CPPFLAGS += -mcpu=52277 -fPIC +cpuflags-$(CONFIG_M52277) := -mcpu=52277 -fPIC + +PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/include/configs/M52277EVB.h b/include/configs/M52277EVB.h index cde7305..e9424b4 100644 --- a/include/configs/M52277EVB.h +++ b/include/configs/M52277EVB.h @@ -18,8 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF5227x /* define processor family */ -#define CONFIG_M52277 /* define processor type */ #define CONFIG_M52277EVB /* M52277EVB board */ #define CONFIG_MCFUART -- cgit v0.10.2 From f47fb6b4a0082d1a9da03cec86150a5af4131eb3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 17:01:11 +0900 Subject: m68k: mcf523x: move CPU type to Kconfig and refactor config.mk Move the CPU type config options from include/configs/M5235EVB.h to arch/m68k/Kconfig and refactor the CPU flags select in arch/m68k/cpu/mcf523x/config.mk. Signed-off-by: Masahiro Yamada Cc: Alison Wang Cc: Angelo Dureghello diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index a645d95..a3f0cbc 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -11,6 +11,9 @@ config MCF520x config MCF52x2 bool +config MCF523x + bool + config MCF530x bool @@ -37,6 +40,10 @@ config M5208 bool select MCF520x +config M5235 + bool + select MCF523x + config M5249 bool select MCF52x2 @@ -103,6 +110,7 @@ config TARGET_M52277EVB config TARGET_M5235EVB bool "Support M5235EVB" + select M5235 config TARGET_COBRA5272 bool "Support cobra5272" diff --git a/arch/m68k/cpu/mcf523x/config.mk b/arch/m68k/cpu/mcf523x/config.mk index c9435ab..4795f6a 100644 --- a/arch/m68k/cpu/mcf523x/config.mk +++ b/arch/m68k/cpu/mcf523x/config.mk @@ -7,4 +7,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -PLATFORM_CPPFLAGS += -mcpu=5235 -fPIC +cpuflags-$(CONFIG_M5235) := -mcpu=5235 -fPIC + +PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/include/configs/M5235EVB.h b/include/configs/M5235EVB.h index 0f6e2f7..883347b 100644 --- a/include/configs/M5235EVB.h +++ b/include/configs/M5235EVB.h @@ -18,8 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF523x /* define processor family */ -#define CONFIG_M5235 /* define processor type */ #define CONFIG_MCFUART #define CONFIG_SYS_UART_PORT (0) -- cgit v0.10.2 From 4cbd29284dcf5c1da9e7bc170e4c3c6a52c988f3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 17:01:12 +0900 Subject: m68k: mcf547x_8x: move CPU type to Kconfig and refactor config.mk Move the CPU type config options from include/configs/*.h to arch/m68k/Kconfig and refactor the CPU flags select in arch/m68k/cpu/mcf547x_8x/config.mk. Signed-off-by: Masahiro Yamada Cc: Alison Wang Cc: Angelo Dureghello diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index a3f0cbc..69cb0f7 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -35,6 +35,9 @@ config MCF5445x config MCF5227x bool +config MCF547x_8x + bool + # processor type config M5208 bool @@ -101,6 +104,14 @@ config M52277 bool select MCF5227x +config M547x + bool + select MCF547x_8x + +config M548x + bool + select MCF547x_8x + choice prompt "Target select" @@ -178,9 +189,11 @@ config TARGET_M54455EVB config TARGET_M5475EVB bool "Support M5475EVB" + select M547x config TARGET_M5485EVB bool "Support M5485EVB" + select M548x config TARGET_AMCORE bool "Support AMCORE" diff --git a/arch/m68k/cpu/mcf547x_8x/config.mk b/arch/m68k/cpu/mcf547x_8x/config.mk index 825f6cc..240dd27 100644 --- a/arch/m68k/cpu/mcf547x_8x/config.mk +++ b/arch/m68k/cpu/mcf547x_8x/config.mk @@ -7,7 +7,9 @@ # SPDX-License-Identifier: GPL-2.0+ # -PLATFORM_CPPFLAGS += -mcpu=5485 -fPIC +cpuflags-$(CONFIG_MCF547x_8x) := -mcpu=5485 -fPIC + +PLATFORM_CPPFLAGS += $(cpuflags-y) ifneq (,$(findstring -linux-,$(shell $(CC) --version))) ifneq (,$(findstring GOT,$(shell $(LD) --help))) diff --git a/include/configs/M5475EVB.h b/include/configs/M5475EVB.h index 2f4549f..91d6a1a 100644 --- a/include/configs/M5475EVB.h +++ b/include/configs/M5475EVB.h @@ -18,9 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF547x_8x /* define processor family */ -#define CONFIG_M547x /* define processor type */ -#define CONFIG_M5475 /* define processor type */ #define CONFIG_DISPLAY_BOARDINFO diff --git a/include/configs/M5485EVB.h b/include/configs/M5485EVB.h index 9aa02f7..ce9f3b0 100644 --- a/include/configs/M5485EVB.h +++ b/include/configs/M5485EVB.h @@ -18,9 +18,6 @@ * High Level Configuration Options * (easy to change) */ -#define CONFIG_MCF547x_8x /* define processor family */ -#define CONFIG_M548x /* define processor type */ -#define CONFIG_M5485 /* define processor type */ #define CONFIG_DISPLAY_BOARDINFO -- cgit v0.10.2 From aa63387a399bdf9e06e4918322b23a112a5b8f97 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 27 Mar 2015 17:01:13 +0900 Subject: m68k: merge per-CPU config.mk into arch/m68k/Makefile Collect CPU specific flags into the single place. Signed-off-by: Masahiro Yamada Cc: Alison Wang Cc: Angelo Dureghello diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index aa3d2fa..e6f3b48 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile @@ -6,3 +6,32 @@ head-y := arch/m68k/cpu/$(CPU)/start.o libs-y += arch/m68k/cpu/$(CPU)/ libs-y += arch/m68k/lib/ + +cpuflags-$(CONFIG_M5208) := -mcpu=5208 +cpuflags-$(CONFIG_M5235) := -mcpu=5235 -fPIC +cpuflags-$(CONFIG_M52277) := -mcpu=52277 -fPIC +cpuflags-$(CONFIG_M5249) := -mcpu=5249 +cpuflags-$(CONFIG_M5253) := -mcpu=5253 +cpuflags-$(CONFIG_M5271) := -mcpu=5271 +cpuflags-$(CONFIG_M5272) := -mcpu=5272 +cpuflags-$(CONFIG_M5275) := -mcpu=5275 +cpuflags-$(CONFIG_M5282) := -mcpu=5282 +cpuflags-$(CONFIG_M5307) := -mcpu=5307 +cpuflags-$(CONFIG_MCF5301x) := -mcpu=53015 -fPIC +cpuflags-$(CONFIG_MCF532x) := -mcpu=5329 -fPIC +cpuflags-$(CONFIG_MCF5441x) := -mcpu=54418 -fPIC +cpuflags-$(CONFIG_MCF5445x) := -mcpu=54455 -fPIC +cpuflags-$(CONFIG_MCF547x_8x) := -mcpu=5485 -fPIC + +PLATFORM_CPPFLAGS += $(cpuflags-y) + + +ldflags-$(CONFIG_MCF5441x) := --got=single +ldflags-$(CONFIG_MCF5445x) := --got=single +ldflags-$(CONFIG_MCF547x_8x) := --got=single + +ifneq (,$(findstring -linux-,$(shell $(CC) --version))) +ifneq (,$(findstring GOT,$(shell $(LD) --help))) +PLATFORM_LDFLAGS += $(ldflags-y) +endif +endif diff --git a/arch/m68k/cpu/mcf5227x/config.mk b/arch/m68k/cpu/mcf5227x/config.mk deleted file mode 100644 index a6814d8..0000000 --- a/arch/m68k/cpu/mcf5227x/config.mk +++ /dev/null @@ -1,12 +0,0 @@ -# -# (C) Copyright 2003 Josef Baumgartner -# -# (C) Copyright 2000-2004 -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. -# -# SPDX-License-Identifier: GPL-2.0+ -# - -cpuflags-$(CONFIG_M52277) := -mcpu=52277 -fPIC - -PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/arch/m68k/cpu/mcf523x/config.mk b/arch/m68k/cpu/mcf523x/config.mk deleted file mode 100644 index 4795f6a..0000000 --- a/arch/m68k/cpu/mcf523x/config.mk +++ /dev/null @@ -1,12 +0,0 @@ -# -# (C) Copyright 2003 Josef Baumgartner -# -# (C) Copyright 2000-2004 -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. -# -# SPDX-License-Identifier: GPL-2.0+ -# - -cpuflags-$(CONFIG_M5235) := -mcpu=5235 -fPIC - -PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/arch/m68k/cpu/mcf52x2/config.mk b/arch/m68k/cpu/mcf52x2/config.mk deleted file mode 100644 index f8fdefd..0000000 --- a/arch/m68k/cpu/mcf52x2/config.mk +++ /dev/null @@ -1,18 +0,0 @@ -# -# (C) Copyright 2003 Josef Baumgartner -# -# (C) Copyright 2000-2004 -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. -# -# SPDX-License-Identifier: GPL-2.0+ -# - -cpuflags-$(CONFIG_M5208) := -mcpu=5208 -cpuflags-$(CONFIG_M5249) := -mcpu=5249 -cpuflags-$(CONFIG_M5253) := -mcpu=5253 -cpuflags-$(CONFIG_M5271) := -mcpu=5271 -cpuflags-$(CONFIG_M5272) := -mcpu=5272 -cpuflags-$(CONFIG_M5275) := -mcpu=5275 -cpuflags-$(CONFIG_M5282) := -mcpu=5282 - -PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/arch/m68k/cpu/mcf530x/config.mk b/arch/m68k/cpu/mcf530x/config.mk deleted file mode 100644 index 25845aa..0000000 --- a/arch/m68k/cpu/mcf530x/config.mk +++ /dev/null @@ -1,9 +0,0 @@ -# -# (C) Copyright 2014 Angelo Dureghello -# -# SPDX-License-Identifier: GPL-2.0+ -# - -cpuflags-$(CONFIG_M5307) := -mcpu=5307 - -PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/arch/m68k/cpu/mcf532x/config.mk b/arch/m68k/cpu/mcf532x/config.mk deleted file mode 100644 index 470d22f..0000000 --- a/arch/m68k/cpu/mcf532x/config.mk +++ /dev/null @@ -1,13 +0,0 @@ -# -# (C) Copyright 2003 Josef Baumgartner -# -# (C) Copyright 2000-2004 -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. -# -# SPDX-License-Identifier: GPL-2.0+ -# - -cpuflags-$(CONFIG_MCF5301x) := -mcpu=53015 -fPIC -cpuflags-$(CONFIG_MCF532x) := -mcpu=5329 -fPIC - -PLATFORM_CPPFLAGS += $(cpuflags-y) diff --git a/arch/m68k/cpu/mcf5445x/config.mk b/arch/m68k/cpu/mcf5445x/config.mk deleted file mode 100644 index c3923c6..0000000 --- a/arch/m68k/cpu/mcf5445x/config.mk +++ /dev/null @@ -1,19 +0,0 @@ -# -# (C) Copyright 2003 Josef Baumgartner -# -# (C) Copyright 2000-2004 -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. -# -# Copyright 2011-2012 Freescale Semiconductor, Inc. -# -# SPDX-License-Identifier: GPL-2.0+ -# - -cpuflags-$(CONFIG_MCF5441x) := -mcpu=54418 -fPIC -cpuflags-$(CONFIG_MCF5445x) := -mcpu=54455 -fPIC - -ifneq (,$(findstring -linux-,$(shell $(CC) --version))) -ifneq (,$(findstring GOT,$(shell $(LD) --help))) -PLATFORM_LDFLAGS += --got=single -endif -endif diff --git a/arch/m68k/cpu/mcf547x_8x/config.mk b/arch/m68k/cpu/mcf547x_8x/config.mk deleted file mode 100644 index 240dd27..0000000 --- a/arch/m68k/cpu/mcf547x_8x/config.mk +++ /dev/null @@ -1,18 +0,0 @@ -# -# (C) Copyright 2003 Josef Baumgartner -# -# (C) Copyright 2000-2004 -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. -# -# SPDX-License-Identifier: GPL-2.0+ -# - -cpuflags-$(CONFIG_MCF547x_8x) := -mcpu=5485 -fPIC - -PLATFORM_CPPFLAGS += $(cpuflags-y) - -ifneq (,$(findstring -linux-,$(shell $(CC) --version))) -ifneq (,$(findstring GOT,$(shell $(LD) --help))) -PLATFORM_LDFLAGS += --got=single -endif -endif -- cgit v0.10.2 From 3b6e4841225c60aa1bd0212754ba0edc1822393d Mon Sep 17 00:00:00 2001 From: "maxin.john@enea.com" Date: Wed, 18 Mar 2015 10:51:47 +0100 Subject: ARM: omap4_panda: enable saveenv command Enable saveenv command and the configs to store environment persistently in the SD card. Tested on OMAP4 Panda (OMAP4460 ES1.1) Signed-off-by: Maxin B. John Acked-by: Lokesh Vutla diff --git a/include/configs/omap4_panda.h b/include/configs/omap4_panda.h index 7378acd..e97c5e3 100644 --- a/include/configs/omap4_panda.h +++ b/include/configs/omap4_panda.h @@ -43,8 +43,13 @@ #define CONFIG_CMD_GPIO /* ENV related config options */ -#define CONFIG_ENV_IS_NOWHERE #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +#define CONFIG_ENV_IS_IN_FAT +#define FAT_ENV_INTERFACE "mmc" +#define FAT_ENV_DEVICE_AND_PART "0:1" +#define FAT_ENV_FILE "uboot.env" +#define CONFIG_CMD_SAVEENV +#define CONFIG_ENV_OVERWRITE #endif /* __CONFIG_PANDA_H */ -- cgit v0.10.2 From 2b5b2be5e9444688e5d8bd0e2d263fccd1f2eee4 Mon Sep 17 00:00:00 2001 From: Hannes Petermaier Date: Thu, 19 Mar 2015 10:43:15 +0100 Subject: board/BuR/common: move I2C initialization from common part to board-specific At this time I2C and responsible pin-mux is setup during PMIC initialziation within common.c, this is possible because today PMIC is always connected on I2C0. In Future this will be changed, PMIC isn't anymore connected to bus0 in call cases. So we do following: - rename enable_i2c_pin_mux0 to enable_i2c_pin_mux to be generic for enabling pin-mux on different or more busses. - move the call to i2c_pin_mux and i2c_init from common.c to the specific board.c Signed-off-by: Hannes Petermaier Signed-off-by: Hannes Petermaier diff --git a/board/BuR/common/bur_common.h b/board/BuR/common/bur_common.h index 39afbba..3061e4c 100644 --- a/board/BuR/common/bur_common.h +++ b/board/BuR/common/bur_common.h @@ -19,7 +19,7 @@ void br_summaryscreen(void); void blink(u32 blinks, u32 intervall, u32 pin); void pmicsetup(u32 mpupll); void enable_uart0_pin_mux(void); -void enable_i2c0_pin_mux(void); +void enable_i2c_pin_mux(void); void enable_board_pin_mux(void); int board_eth_init(bd_t *bis); diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c index 5ff8a7e..91834eb 100644 --- a/board/BuR/common/common.c +++ b/board/BuR/common/common.c @@ -461,10 +461,6 @@ void pmicsetup(u32 mpupll) int mpu_vdd; int usb_cur_lim; - /* setup I2C */ - enable_i2c0_pin_mux(); - i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); - if (i2c_probe(TPS65217_CHIP_PM)) { puts("PMIC (0x24) not found! skip further initalization.\n"); return; diff --git a/board/BuR/kwb/board.c b/board/BuR/kwb/board.c index 892311e..6eed7e0 100644 --- a/board/BuR/kwb/board.c +++ b/board/BuR/kwb/board.c @@ -124,7 +124,8 @@ void am33xx_spl_board_init(void) gpio_direction_output(LCD_PWR, 0); /* setup I2C */ - enable_i2c0_pin_mux(); + enable_i2c_pin_mux(); + i2c_set_bus_num(0); i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); /* power-ON 3V3 via Resetcontroller */ diff --git a/board/BuR/kwb/mux.c b/board/BuR/kwb/mux.c index 9f89b5e..2b1d8d3 100644 --- a/board/BuR/kwb/mux.c +++ b/board/BuR/kwb/mux.c @@ -180,7 +180,7 @@ void enable_uart0_pin_mux(void) configure_module_pin_mux(uart0_pin_mux); } -void enable_i2c0_pin_mux(void) +void enable_i2c_pin_mux(void) { configure_module_pin_mux(i2c0_pin_mux); } diff --git a/board/BuR/tseries/board.c b/board/BuR/tseries/board.c index 9402aa4..89e989f 100644 --- a/board/BuR/tseries/board.c +++ b/board/BuR/tseries/board.c @@ -123,6 +123,10 @@ void am33xx_spl_board_init(void) /* setup LCD-Pixel Clock */ writel(0x2, &cmdpll->clklcdcpixelclk); /* clock comes from perPLL M2 */ + /* setup I2C */ + enable_i2c_pin_mux(); + i2c_set_bus_num(0); + i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); pmicsetup(0); } diff --git a/board/BuR/tseries/mux.c b/board/BuR/tseries/mux.c index 2c87a63..ac7e885 100644 --- a/board/BuR/tseries/mux.c +++ b/board/BuR/tseries/mux.c @@ -226,7 +226,7 @@ void enable_uart0_pin_mux(void) configure_module_pin_mux(uart0_pin_mux); } -void enable_i2c0_pin_mux(void) +void enable_i2c_pin_mux(void) { configure_module_pin_mux(i2c0_pin_mux); } -- cgit v0.10.2 From 750461887efacb53caec0fb048d1070ee54180e2 Mon Sep 17 00:00:00 2001 From: Hannes Petermaier Date: Thu, 19 Mar 2015 10:43:16 +0100 Subject: board/BuR/common: remove unused function 'blink' since we have possibility to write out on lcd whats going on, we don't need the gpio blink functionality anymore. Signed-off-by: Hannes Petermaier Signed-off-by: Hannes Petermaier diff --git a/board/BuR/common/bur_common.h b/board/BuR/common/bur_common.h index 3061e4c..e4896fb 100644 --- a/board/BuR/common/bur_common.h +++ b/board/BuR/common/bur_common.h @@ -16,7 +16,6 @@ int load_lcdtiming(struct am335x_lcdpanel *panel); void br_summaryscreen(void); -void blink(u32 blinks, u32 intervall, u32 pin); void pmicsetup(u32 mpupll); void enable_uart0_pin_mux(void); void enable_i2c_pin_mux(void); diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c index 91834eb..ccaa9c6 100644 --- a/board/BuR/common/common.c +++ b/board/BuR/common/common.c @@ -441,20 +441,6 @@ void lcd_enable(void) #error "LCD-support with a suitable FB-Driver is mandatory !" #endif /* CONFIG_LCD */ -void blink(u32 blinks, u32 intervall, u32 pin) -{ - gpio_direction_output(pin, 0); - int val = 0; - - do { - val ^= 0x01; - gpio_set_value(pin, val); - mdelay(intervall); - } while (blinks--); - - gpio_set_value(pin, 0); -} - #ifdef CONFIG_SPL_BUILD void pmicsetup(u32 mpupll) { -- cgit v0.10.2 From e2a5d55642712f3c5a95b148cd1c94be801c4c4f Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 20 Mar 2015 12:56:17 +0100 Subject: config: Use booti instead of bootz on 64-bit ARM The bootz command doesn't work with Linux kernel images on 64-bit ARM. The replacement command with the same interface and functionality is booti. Cc: Dennis Gilmore Cc: Tom Rini Signed-off-by: Thierry Reding diff --git a/include/config_distro_defaults.h b/include/config_distro_defaults.h index 1ecc0bb..f4a01ba 100644 --- a/include/config_distro_defaults.h +++ b/include/config_distro_defaults.h @@ -31,7 +31,11 @@ #define CONFIG_OF_LIBFDT +#ifdef CONFIG_ARM64 +#define CONFIG_CMD_BOOTI +#else #define CONFIG_CMD_BOOTZ +#endif #define CONFIG_CMD_DHCP #define CONFIG_CMD_ELF #define CONFIG_CMD_EXT2 -- cgit v0.10.2 From 1344bd7ebec4e0d2c0e2da0133b957d3cf93357b Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 20 Mar 2015 13:11:58 +0100 Subject: config: Define BOOTP client architecture and VCI for ARMv8 Reuse the 32-bit ARM client architecture and identify ARMv8 specifically by setting the BOOTP VCI string. Cc: Dennis Gilmore Cc: Tom Rini Signed-off-by: Thierry Reding diff --git a/include/config_distro_defaults.h b/include/config_distro_defaults.h index f4a01ba..8237239 100644 --- a/include/config_distro_defaults.h +++ b/include/config_distro_defaults.h @@ -20,10 +20,12 @@ #define CONFIG_BOOTP_PXE #define CONFIG_BOOTP_SUBNETMASK -#if defined(__arm__) +#if defined(__arm__) || defined(__aarch64__) #define CONFIG_BOOTP_PXE_CLIENTARCH 0x100 #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) #define CONFIG_BOOTP_VCI_STRING "U-boot.armv7" +#elif defined(__aarch64__) +#define CONFIG_BOOTP_VCI_STRING "U-boot.armv8" #else #define CONFIG_BOOTP_VCI_STRING "U-boot.arm" #endif -- cgit v0.10.2 From 8c2492901998a76e083ed0875372c141da084d86 Mon Sep 17 00:00:00 2001 From: Karsten Merker Date: Sat, 21 Mar 2015 14:15:38 +0100 Subject: Document config_distro_bootcmd environment variables for interactive booting. config_distro_bootcmd.h defines a common boot environment for multiple platforms, including several environment variables that are intended for interactive use by an end-user. Document which variables are considered public interfaces that must remain compatible in future u-boot versions. Signed-off-by: Karsten Merker Acked-by: Stephen Warren diff --git a/doc/README.distro b/doc/README.distro index dd0f1c7..0308a4c 100644 --- a/doc/README.distro +++ b/doc/README.distro @@ -1,6 +1,7 @@ /* * (C) Copyright 2014 Red Hat Inc. * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. + * Copyright (C) 2015 K. Merker * * SPDX-License-Identifier: GPL-2.0+ */ @@ -339,3 +340,49 @@ scan_dev_for_scripts: If you want to disable boot.scr on all disks, set the value to something innocuous, e.g. setenv scan_dev_for_scripts true. + + +Interactively booting from a specific device at the u-boot prompt +================================================================= + +For interactively booting from a user-selected device at the u-boot command +prompt, the environment provides predefined bootcmd_ variables for +every target defined in boot_targets, which can be run be the user. + +If the target is a storage device, the format of the target is always +, e.g. mmc0. Specifying the device number is +mandatory for storage devices, even if only support for a single instance +of the storage device is actually implemented. + +For network targets (dhcp, pxe), only the device type gets specified; +they do not have a device number. + +Examples: + + - run bootcmd_usb0 + boots from the first USB mass storage device + + - run bootcmd_mmc1 + boots from the second MMC device + + - run bootcmd_pxe + boots by tftp using a pxelinux.cfg + +The list of possible targets consists of: + +- network targets + * dhcp + * pxe + +- storage targets (to which a device number must be appended) + * mmc + * sata + * scsi + * ide + * usb + +Other *boot* variables than the ones defined above are only for internal use +of the boot environment and are not guaranteed to exist or work in the same +way in future u-boot versions. In particular the _boot +variables (e.g. mmc_boot, usb_boot) are a strictly internal implementation +detail and must not be used as a public interface. -- cgit v0.10.2 From e769f68613ee4f84c8e2aea784335df74ceea397 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 23 Mar 2015 11:06:10 +0100 Subject: armv8: semihosting: do not inline trap call The semihosting trap call does not like being inlined, probably because that will mean register reordering screwing up the return value in r0, so tag this function "noinline". Signed-off-by: Linus Walleij diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c index fd6d857..d3f724b 100644 --- a/arch/arm/lib/semihosting.c +++ b/arch/arm/lib/semihosting.c @@ -26,7 +26,7 @@ /* * Call the handler */ -static long smh_trap(unsigned int sysnum, void *addr) +static noinline long smh_trap(unsigned int sysnum, void *addr) { register long result asm("r0"); #if defined(CONFIG_ARM64) -- cgit v0.10.2 From 202a674bb8b7d7867503224857a2b0e04617d9b3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 23 Mar 2015 11:06:11 +0100 Subject: armv8: semihosting: add a command to load semihosted images Instead of sprinkling custom code and calls over the Vexpress64 boardfile, create a command that loads images using semihosting just like we would load from flash memory of over the network, using a special command: smhload
This will make it possible to remove some custom calls and code and make the boot easier. Signed-off-by: Linus Walleij diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c index d3f724b..edacb11 100644 --- a/arch/arm/lib/semihosting.c +++ b/arch/arm/lib/semihosting.c @@ -13,6 +13,7 @@ * for them. */ #include +#include #include #define SYSOPEN 0x01 @@ -234,3 +235,72 @@ long smh_len(const char *fname) /* Return the file length (or -1 error indication) */ return len; } + +static int smh_load_file(const char * const name, ulong load_addr, + ulong *end_addr) +{ + long fd; + long len; + long ret; + + fd = smh_open(name, "rb"); + if (fd == -1) + return -1; + + len = smh_len_fd(fd); + if (len < 0) { + smh_close(fd); + return -1; + } + + ret = smh_read(fd, (void *)load_addr, len); + smh_close(fd); + + if (ret == 0) { + *end_addr = load_addr + len - 1; + printf("loaded file %s from %08lX to %08lX, %08lX bytes\n", + name, + load_addr, + *end_addr, + len); + } else { + printf("read failed\n"); + return 0; + } + + return 0; +} + +static int do_smhload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + if (argc == 3 || argc == 4) { + ulong load_addr; + ulong end_addr = 0; + ulong ret; + char end_str[64]; + + load_addr = simple_strtoul(argv[2], NULL, 16); + if (!load_addr) + return -1; + + ret = smh_load_file(argv[1], load_addr, &end_addr); + if (ret < 0) + return 1; + + /* Optionally save returned end to the environment */ + if (argc == 4) { + sprintf(end_str, "0x%08lx", end_addr); + setenv(argv[3], end_str); + } + } else { + return CMD_RET_USAGE; + } + return 0; +} + +U_BOOT_CMD(smhload, 4, 0, do_smhload, "load a file using semihosting", + " 0x
[end var]\n" + " - load a semihosted file to the address specified\n" + " if the optional [end var] is specified, the end\n" + " address of the file will be stored in this environment\n" + " variable.\n"); diff --git a/doc/README.semihosting b/doc/README.semihosting index 7248560..c016a4f 100644 --- a/doc/README.semihosting +++ b/doc/README.semihosting @@ -30,25 +30,10 @@ vexpress_aemv8a.h but differentiate the two models by the presence or absence of CONFIG_BASE_FVP. This change is tested and works on both the Foundation and Base fastmodel simulators. -The level of semihosting support is minimal, restricted to just what it -takes to load images to memory. If more semihosting functionality is -required, such as file seek, outputting strings, reading characters, etc, -then it can be easily added later. +The semihosting code adds a command: -We require that the board include file define these env variables: -- kernel_name e.g. "uImage" -- kernel_addr_r e.g. "0x80000000" -- initrd_name e.g. "ramdisk.img" -- initrd_addr_r e.g. "0x88000000" -- fdt_name e.g. "devtree.dtb" -- fdt_addr_r e.g. "0x83000000" + smhload
[env var] -Optionally, "fdt_high" and "initrd_high" can be specified as per -their rules for allowing or preventing copying of these images. - -For the "fdt chosen" startup macro, this code will then define: -- initrd_end (based on retrieving initrd_addr_r plus actual initrd_size) - -We will then load the kernel, initrd, and fdt into the specified -locations in memory in a similar way that the ATF fastmodel code -uses semihosting calls to load other boot stages and u-boot itself. +That will load an image from the host filesystem into RAM at the specified +address and optionally store the load end address in the specified +environment variable. -- cgit v0.10.2 From 49995ffe81c266304bf9612fa2964b94d44a6c1c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 23 Mar 2015 11:06:12 +0100 Subject: vexpress64: remove board late init, use smhload This removes the kludgy late board init from the FVP simulator version of Versatile Express 64bit (ARMv8), and replace it with a default boot command using the new smhload command to load the files using semihosting. Tested on the Foundation Model. Signed-off-by: Linus Walleij diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c index de62864..876cb67 100644 --- a/board/armltd/vexpress64/vexpress64.c +++ b/board/armltd/vexpress64/vexpress64.c @@ -11,7 +11,6 @@ #include #include #include -#include DECLARE_GLOBAL_DATA_PTR; @@ -33,101 +32,6 @@ void reset_cpu(ulong addr) { } -#ifdef CONFIG_BOARD_LATE_INIT -int board_late_init(void) -{ -#ifdef CONFIG_SEMIHOSTING - /* - * Please refer to doc/README.semihosting for a more complete - * description. - * - * We require that the board include file defines these env variables: - * - kernel_name - * - kernel_addr_r - * - initrd_name - * - initrd_addr_r - * - fdt_name - * - fdt_addr_r - * - * For the "fdt chosen" startup macro, this code will then define: - * - initrd_end (based on initrd_addr_r plus actual initrd_size) - * - * We will then load the kernel, initrd, and fdt into the specified - * locations in memory in a similar way that the ATF fastmodel code - * uses semihosting calls to load other boot stages and u-boot itself. - */ - - /* Env variable strings */ - char *kernel_name = getenv("kernel_name"); - char *kernel_addr_str = getenv("kernel_addr_r"); - char *initrd_name = getenv("initrd_name"); - char *initrd_addr_str = getenv("initrd_addr_r"); - char *fdt_name = getenv("fdt_name"); - char *fdt_addr_str = getenv("fdt_addr_r"); - char initrd_end_str[64]; - - /* Actual addresses converted from env variables */ - void *kernel_addr_r; - void *initrd_addr_r; - void *fdt_addr_r; - - /* Actual initrd base and size */ - unsigned long initrd_base; - unsigned long initrd_size; - - /* Space available */ - int avail; - - /* Make sure the environment variables needed are set */ - if (!(kernel_addr_str && initrd_addr_str && fdt_addr_str)) { - printf("%s: Define {kernel/initrd/fdt}_addr_r\n", __func__); - return -1; - } - if (!(kernel_name && initrd_name && fdt_name)) { - printf("%s: Define {kernel/initrd/fdt}_name\n", __func__); - return -1; - } - - /* Get exact initrd_size */ - initrd_size = smh_len(initrd_name); - if (initrd_size == -1) { - printf("%s: Can't get file size for \'%s\'\n", __func__, - initrd_name); - return -1; - } - - /* Set initrd_end */ - initrd_base = simple_strtoul(initrd_addr_str, NULL, 16); - initrd_addr_r = (void *)initrd_base; - sprintf(initrd_end_str, "0x%lx", initrd_base + initrd_size - 1); - setenv("initrd_end", initrd_end_str); - - /* Load kernel to memory */ - fdt_addr_r = (void *)simple_strtoul(fdt_addr_str, NULL, 16); - kernel_addr_r = (void *)simple_strtoul(kernel_addr_str, NULL, 16); - - /* - * The kernel must be lower in memory than fdt and loading the - * kernel must not trample the fdt or vice versa. - */ - avail = fdt_addr_r - kernel_addr_r; - if (avail < 0) { - printf("%s: fdt must be after kernel\n", __func__); - return -1; - } - smh_load(kernel_name, kernel_addr_r, avail, 1); - - /* Load fdt to memory */ - smh_load(fdt_name, fdt_addr_r, 0x20000, 1); - - /* Load initrd to memory */ - smh_load(initrd_name, initrd_addr_r, initrd_size, 1); - -#endif /* CONFIG_SEMIHOSTING */ - return 0; -} -#endif /* CONFIG_BOARD_LATE_INIT */ - /* * Board specific ethernet initialization routine. */ diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h index 810eef1..5792461 100644 --- a/include/configs/vexpress_aemv8a.h +++ b/include/configs/vexpress_aemv8a.h @@ -15,7 +15,6 @@ #ifndef CONFIG_SEMIHOSTING #error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING #endif -#define CONFIG_BOARD_LATE_INIT #define CONFIG_ARMV8_SWITCH_TO_EL1 #endif @@ -200,12 +199,12 @@ /* Initial environment variables */ #ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP #define CONFIG_EXTRA_ENV_SETTINGS \ - "kernel_name=uImage\0" \ - "kernel_addr_r=0x80000000\0" \ + "kernel_name=uImage\0" \ + "kernel_addr=0x80000000\0" \ "initrd_name=ramdisk.img\0" \ - "initrd_addr_r=0x88000000\0" \ - "fdt_name=devtree.dtb\0" \ - "fdt_addr_r=0x83000000\0" \ + "initrd_addr=0x88000000\0" \ + "fdt_name=devtree.dtb\0" \ + "fdt_addr=0x83000000\0" \ "fdt_high=0xffffffffffffffff\0" \ "initrd_high=0xffffffffffffffff\0" @@ -213,9 +212,12 @@ "0x1c090000 debug user_debug=31 "\ "loglevel=9" -#define CONFIG_BOOTCOMMAND "fdt addr $fdt_addr_r; fdt resize; " \ - "fdt chosen $initrd_addr_r $initrd_end; " \ - "bootm $kernel_addr_r - $fdt_addr_r" +#define CONFIG_BOOTCOMMAND "smhload ${kernel_name} ${kernel_addr}; " \ + "smhload ${fdt_name} $fdt_addr; " \ + "smhload ${initrd_name} $initrd_addr initrd_end; " \ + "fdt addr $fdt_addr; fdt resize; " \ + "fdt chosen $initrd_addr $initrd_end; " \ + "bootm $kernel_addr - $fdt_addr" #define CONFIG_BOOTDELAY 1 -- cgit v0.10.2 From d5f3d17ca6b6272d9096912579778b67fa40a164 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 23 Mar 2015 11:06:13 +0100 Subject: armv8: semihosting: delete external interface Now that loading files using semihosting can be done using a command in standard scripts, and we have rewritten the boardfile and added it to the Vexpress64, let's delete the external interface to the semihosting file retrieveal and rely solely on these commands, and staticize them inside that file so the whole business is self-contained. Signed-off-by: Linus Walleij diff --git a/arch/arm/include/asm/semihosting.h b/arch/arm/include/asm/semihosting.h deleted file mode 100644 index 835ca7e..0000000 --- a/arch/arm/include/asm/semihosting.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2014 Broadcom Corporation - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef __SEMIHOSTING_H__ -#define __SEMIHOSTING_H__ - -/* - * ARM semihosting functions for loading images to memory. See the source - * code for more information. - */ -int smh_load(const char *fname, void *memp, int avail, int verbose); -long smh_len(const char *fname); - -#endif /* __SEMIHOSTING_H__ */ diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c index edacb11..c3e964e 100644 --- a/arch/arm/lib/semihosting.c +++ b/arch/arm/lib/semihosting.c @@ -14,7 +14,6 @@ */ #include #include -#include #define SYSOPEN 0x01 #define SYSCLOSE 0x02 @@ -145,97 +144,6 @@ static long smh_len_fd(long fd) return ret; } -/* - * Open, load a file into memory, and close it. Check that the available space - * is sufficient to store the entire file. Return the bytes actually read from - * the file as seen by the read function. The verbose flag enables some extra - * printing of successful read status. - */ -int smh_load(const char *fname, void *memp, int avail, int verbose) -{ - long ret; - long fd; - size_t len; - - ret = -1; - - debug("%s: fname \'%s\', avail %u, memp %p\n", __func__, fname, - avail, memp); - - /* Open the file */ - fd = smh_open(fname, "rb"); - if (fd == -1) - return -1; - - /* Get the file length */ - ret = smh_len_fd(fd); - if (ret == -1) { - smh_close(fd); - return -1; - } - - /* Check that the file will fit in the supplied buffer */ - if (ret > avail) { - printf("%s: ERROR ret %ld, avail %u\n", __func__, ret, - avail); - smh_close(fd); - return -1; - } - - len = ret; - - /* Read the file into the buffer */ - ret = smh_read(fd, memp, len); - if (ret == 0) { - /* Print successful load information if requested */ - if (verbose) { - printf("\n%s\n", fname); - printf(" 0x%8p dest\n", memp); - printf(" 0x%08lx size\n", len); - printf(" 0x%08x avail\n", avail); - } - } - - /* Close the file */ - smh_close(fd); - - return ret; -} - -/* - * Get the file length from the filename - */ -long smh_len(const char *fname) -{ - long ret; - long fd; - long len; - - debug("%s: file \'%s\'\n", __func__, fname); - - /* Open the file */ - fd = smh_open(fname, "rb"); - if (fd < 0) - return fd; - - /* Get the file length */ - len = smh_len_fd(fd); - if (len < 0) { - smh_close(fd); - return len; - } - - /* Close the file */ - ret = smh_close(fd); - if (ret < 0) - return ret; - - debug("%s: returning len %ld\n", __func__, len); - - /* Return the file length (or -1 error indication) */ - return len; -} - static int smh_load_file(const char * const name, ulong load_addr, ulong *end_addr) { -- cgit v0.10.2 From 03314f0e248ed8685ee6bfe36bd0f607f38e2cfb Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 23 Mar 2015 11:06:14 +0100 Subject: vexpress64: cut config and defaults for unclear variant This variant that is neither FVP / Base Model or Juno Versatile Express 64bit is confusing. Get rid of it unless someone can point out what machine that really is. Seems to be an evolutional artifact in the config base. Signed-off-by: Linus Walleij diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig index 7d5e7be..f5693ae 100644 --- a/board/armltd/vexpress64/Kconfig +++ b/board/armltd/vexpress64/Kconfig @@ -1,16 +1,3 @@ -if TARGET_VEXPRESS64_AEMV8A - -config SYS_BOARD - default "vexpress64" - -config SYS_VENDOR - default "armltd" - -config SYS_CONFIG_NAME - default "vexpress_aemv8a" - -endif - if TARGET_VEXPRESS64_BASE_FVP config SYS_BOARD diff --git a/configs/vexpress_aemv8a_defconfig b/configs/vexpress_aemv8a_defconfig deleted file mode 100644 index 9f4b876..0000000 --- a/configs/vexpress_aemv8a_defconfig +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_ARM=y -CONFIG_TARGET_VEXPRESS64_AEMV8A=y -CONFIG_DEFAULT_DEVICE_TREE="vexpress64" diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h index 5792461..c472143 100644 --- a/include/configs/vexpress_aemv8a.h +++ b/include/configs/vexpress_aemv8a.h @@ -20,14 +20,6 @@ #define CONFIG_REMAKE_ELF -#if !defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP) && \ - !defined(CONFIG_TARGET_VEXPRESS64_JUNO) -/* Base FVP and Juno not using GICv3 yet */ -#define CONFIG_GICV3 -#endif - -/*#define CONFIG_ARMV8_SWITCH_TO_EL1*/ - #define CONFIG_SUPPORT_RAW_INITRD /* Cache Definitions */ @@ -46,8 +38,7 @@ #define CONFIG_SYS_TEXT_BASE 0xe0000000 #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x7fff0) #else -#define CONFIG_SYS_TEXT_BASE 0x80000000 -#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x7fff0) +#error "Unknown board variant" #endif /* Flat Device Tree Definitions */ @@ -117,10 +108,9 @@ #define GICD_BASE (0x2C010000) #define GICC_BASE (0x2C02f000) #else -#define GICD_BASE (0x2C001000) -#define GICC_BASE (0x2C002000) -#endif +#error "Unknown board variant" #endif +#endif /* !CONFIG_GICV3 */ #define CONFIG_SYS_MEMTEST_START V2M_BASE #define CONFIG_SYS_MEMTEST_END (V2M_BASE + 0x80000000) @@ -222,17 +212,7 @@ #define CONFIG_BOOTDELAY 1 #else - -#define CONFIG_EXTRA_ENV_SETTINGS \ - "kernel_addr_r=0x80000000\0" \ - "initrd_addr_r=0x88000000\0" \ - "fdt_addr_r=0x83000000\0" \ - "fdt_high=0xa0000000\0" - -#define CONFIG_BOOTARGS "console=ttyAMA0,115200n8 root=/dev/ram0" -#define CONFIG_BOOTCOMMAND "bootm $kernel_addr_r " \ - "$initrd_addr_r:$initrd_size $fdt_addr_r" -#define CONFIG_BOOTDELAY -1 +#error "Unknown board variant" #endif /* Do not preserve environment */ -- cgit v0.10.2 From 5bcd19aa299bf6832e943e3531400c1499f2c04d Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 24 Mar 2015 11:12:47 +0300 Subject: common/board_f: move board_init_f_mem() from #else CONFIG_X86 Purpose of this change is to make it possible to re-use code currently used on X86 solely for other architectures. For example: * init_sequence_f_r * board_init_f_r Even though board_init_f_mem() has nothing to do with any particular architecture it won't work (at least in current implementation) for X86. This is because on X86 "gd" is an alias to function get_fs_gd_ptr(), thus we cannot assign anything to it. So this change separates selection of board_init_f_mem() from X86 while keeping it disabled for X86 still. Signed-off-by: Alexey Brodkin Cc: Simon Glass Cc: Tom Rini diff --git a/common/board_f.c b/common/board_f.c index 55ede07..e537cd1 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -1080,7 +1080,9 @@ void board_init_f_r(void) /* NOTREACHED - board_init_r() does not return */ hang(); } -#else +#endif /* CONFIG_X86 */ + +#ifndef CONFIG_X86 ulong board_init_f_mem(ulong top) { /* Leave space for the stack we are running with now */ @@ -1098,4 +1100,4 @@ ulong board_init_f_mem(ulong top) return top; } -#endif /* CONFIG_X86 */ +#endif /* !CONFIG_X86 */ -- cgit v0.10.2 From 944ab340b6d98faf5f1e30d223d52d6d24c2f858 Mon Sep 17 00:00:00 2001 From: "angelo@sysam.it" Date: Sat, 28 Mar 2015 11:34:52 +0100 Subject: m68k: fix 3 broken boards Fix eb_cpu5282 and eb_cpu5282_internal unresolved external error. These boards have video but don't need any ppc related video_setmem(). Fix M53017EVB moving away embedded env to a different offset, as in M52277EVB. Signed-off-by: Angelo Dureghello diff --git a/board/freescale/m53017evb/u-boot.lds b/board/freescale/m53017evb/u-boot.lds index de8d09b..b1cae59 100644 --- a/board/freescale/m53017evb/u-boot.lds +++ b/board/freescale/m53017evb/u-boot.lds @@ -13,8 +13,6 @@ SECTIONS .text : { arch/m68k/cpu/mcf532x/start.o (.text*) - arch/m68k/cpu/mcf532x/built-in.o (.text*) - arch/m68k/lib/built-in.o (.text*) . = DEFINED(env_offset) ? env_offset : .; common/env_embedded.o (.text*) diff --git a/common/board_f.c b/common/board_f.c index e537cd1..f7ffa54 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -494,7 +494,7 @@ static int reserve_trace(void) #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \ !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \ - !defined(CONFIG_BLACKFIN) + !defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K) static int reserve_video(void) { /* reserve memory for video display (always full pages) */ @@ -968,7 +968,7 @@ static init_fnc_t init_sequence_f[] = { /* TODO: Why the dependency on CONFIG_8xx? */ #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \ !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \ - !defined(CONFIG_BLACKFIN) + !defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K) reserve_video, #endif #if !defined(CONFIG_BLACKFIN) && !defined(CONFIG_NIOS2) diff --git a/include/configs/M53017EVB.h b/include/configs/M53017EVB.h index 83ac70f..e3fa856 100644 --- a/include/configs/M53017EVB.h +++ b/include/configs/M53017EVB.h @@ -200,7 +200,7 @@ /* Configuration for environment * Environment is embedded in u-boot in the second sector of the flash */ -#define CONFIG_ENV_OFFSET 0x8000 +#define CONFIG_ENV_OFFSET (CONFIG_SYS_FLASH_BASE + 0x40000) #define CONFIG_ENV_SIZE 0x1000 #define CONFIG_ENV_SECT_SIZE 0x8000 #define CONFIG_ENV_IS_IN_FLASH 1 -- cgit v0.10.2 From 80ee0196a63d5f1bc013b0dddc830cda464c075f Mon Sep 17 00:00:00 2001 From: Brian McFarland Date: Thu, 12 Mar 2015 11:52:49 -0400 Subject: Patch to mkenvimage to handle text files with length that exceed env size The current head revision of mkenvimage (e72be8947e129f5ab274c0a9f235d2cc0014b2ea) will prevent you from creating an env image from a text file that is larger than the env length specified by the '-s' option. That doesn't make sense given that the tool now allows comments and blank lines. This patch removes that limitation and allows longer text files to be used. I don't have time / desire at the moment to figure out "patman" and could really care less if this is adopted up stream. Just figured I would share in case anybody else finds it useful enough to take time to do a proper patch. >From 39ff30190c2bf687861f4b4b33230f1944fb64f9 Mon Sep 17 00:00:00 2001 From: Brian McFarland Date: Thu, 12 Mar 2015 11:37:19 -0400 Subject: [PATCH] In mkenvimage, removed the check that prevented using a source text file larger than the output environment image. Instead, the main parsing loop checks to see if the environment buffer is full, and quits if it is. After the main parse loop, a second loop swallows comments and whitespace until either the EOF is reached or more env vars are found, in which case an error will be thrown. diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 6971b91..8eee72e 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -214,14 +214,10 @@ int main(int argc, char **argv) } ret = close(txt_fd); } - /* The +1 is for the additionnal ending \0. See below. */ - if (filesize + 1 > envsize) { - fprintf(stderr, "The input file is larger than the environment partition size\n"); - return EXIT_FAILURE; - } - /* Replace newlines separating variables with \0 */ - for (fp = 0, ep = 0 ; fp < filesize ; fp++) { + /* Parse a byte at time until reaching the file OR until the environment fills + * up. Check ep against envsize - 1 to allow for extra trailing '\0'. */ + for (fp = 0, ep = 0 ; fp < filesize && ep < envsize - 1; fp++) { if (filebuf[fp] == '\n') { if (fp == 0 || filebuf[fp-1] == '\n') { /* @@ -249,6 +245,25 @@ int main(int argc, char **argv) envptr[ep++] = filebuf[fp]; } } + /* If there are more bytes in the file still, it means the env filled up + * before parsing the whole file. Eat comments & whitespace here to see if + * there was anything meaning full left in the file, and if so, throw a error + * and exit. */ + for( ; fp < filesize; fp++ ) + { + if (filebuf[fp] == '\n') { + if (fp == 0 || filebuf[fp-1] == '\n') { + /* Ignore blank lines */ + continue; + } + } else if ((fp == 0 || filebuf[fp-1] == '\n') && filebuf[fp] == '#') { + while (++fp < filesize && filebuf[fp] != '\n') + continue; + } else { + fprintf(stderr, "The environment file is too large for the target environment storage\n"); + return EXIT_FAILURE; + } + } /* * Make sure there is a final '\0' * And do it again on the next byte to mark the end of the environment. -- cgit v0.10.2 From 5db752353b6a19c50db4a30692efb7e845fb8a6e Mon Sep 17 00:00:00 2001 From: Anatolij Gustschin Date: Sat, 28 Mar 2015 16:49:47 +0100 Subject: powerpc: ppc4xx: convert AMCC boards to generic board Add CONFIG_SYS_GENERIC_BOARD to amcc-common.h and CONFIG_DISPLAY_BOARDINFO to Kconfig files. canyonlands.h includes amcc-common.h, so remove CONFIG_SYS_GENERIC_BOARD definition there. Signed-off-by: Anatolij Gustschin Cc: Stefan Roese Cc: Feng Kan Cc: Masahiro Yamada Cc: Tom Rini diff --git a/board/amcc/acadia/Kconfig b/board/amcc/acadia/Kconfig index 033deaf..7c0ef53 100644 --- a/board/amcc/acadia/Kconfig +++ b/board/amcc/acadia/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "acadia" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/bamboo/Kconfig b/board/amcc/bamboo/Kconfig index c0bd40a..d44a36a 100644 --- a/board/amcc/bamboo/Kconfig +++ b/board/amcc/bamboo/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "bamboo" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/bubinga/Kconfig b/board/amcc/bubinga/Kconfig index 540d9b6..fc40f6e 100644 --- a/board/amcc/bubinga/Kconfig +++ b/board/amcc/bubinga/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "bubinga" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/ebony/Kconfig b/board/amcc/ebony/Kconfig index 62394b6..ba73148 100644 --- a/board/amcc/ebony/Kconfig +++ b/board/amcc/ebony/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "ebony" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/katmai/Kconfig b/board/amcc/katmai/Kconfig index fc606cf..59d3ef5 100644 --- a/board/amcc/katmai/Kconfig +++ b/board/amcc/katmai/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "katmai" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/kilauea/Kconfig b/board/amcc/kilauea/Kconfig index 3f2f434..5dfd9eb 100644 --- a/board/amcc/kilauea/Kconfig +++ b/board/amcc/kilauea/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kilauea" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/luan/Kconfig b/board/amcc/luan/Kconfig index 3df90af..36b44ff 100644 --- a/board/amcc/luan/Kconfig +++ b/board/amcc/luan/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "luan" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/makalu/Kconfig b/board/amcc/makalu/Kconfig index 31ce5f1..7f8498a 100644 --- a/board/amcc/makalu/Kconfig +++ b/board/amcc/makalu/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "makalu" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/ocotea/Kconfig b/board/amcc/ocotea/Kconfig index 18c1a15..489e8a4 100644 --- a/board/amcc/ocotea/Kconfig +++ b/board/amcc/ocotea/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "ocotea" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/redwood/Kconfig b/board/amcc/redwood/Kconfig index d710590..fee6441 100644 --- a/board/amcc/redwood/Kconfig +++ b/board/amcc/redwood/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "redwood" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/sequoia/Kconfig b/board/amcc/sequoia/Kconfig index 67ee3ca..6e6e408 100644 --- a/board/amcc/sequoia/Kconfig +++ b/board/amcc/sequoia/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "sequoia" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/taihu/Kconfig b/board/amcc/taihu/Kconfig index fc5cb1d..faafb08 100644 --- a/board/amcc/taihu/Kconfig +++ b/board/amcc/taihu/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "taihu" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/taishan/Kconfig b/board/amcc/taishan/Kconfig index abd07f5..9ad8a4c 100644 --- a/board/amcc/taishan/Kconfig +++ b/board/amcc/taishan/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "taishan" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/walnut/Kconfig b/board/amcc/walnut/Kconfig index 94e3dc9..d4c451d 100644 --- a/board/amcc/walnut/Kconfig +++ b/board/amcc/walnut/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "walnut" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/yosemite/Kconfig b/board/amcc/yosemite/Kconfig index dfa1068..ec51236 100644 --- a/board/amcc/yosemite/Kconfig +++ b/board/amcc/yosemite/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "yosemite" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/board/amcc/yucca/Kconfig b/board/amcc/yucca/Kconfig index 61d9589..338b6a9 100644 --- a/board/amcc/yucca/Kconfig +++ b/board/amcc/yucca/Kconfig @@ -9,4 +9,8 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "yucca" +config DISPLAY_BOARDINFO + bool + default y + endif diff --git a/include/configs/amcc-common.h b/include/configs/amcc-common.h index 73e1b0a..d5b6e37 100644 --- a/include/configs/amcc-common.h +++ b/include/configs/amcc-common.h @@ -10,6 +10,8 @@ #ifndef __AMCC_COMMON_H #define __AMCC_COMMON_H +#define CONFIG_SYS_GENERIC_BOARD + #define CONFIG_SYS_SDRAM_BASE 0x00000000 /* _must_ be 0 */ #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE /* Start of U-Boot */ #define CONFIG_SYS_MONITOR_LEN (0xFFFFFFFF - CONFIG_SYS_MONITOR_BASE + 1) diff --git a/include/configs/canyonlands.h b/include/configs/canyonlands.h index 7a1499d..ed790cc 100644 --- a/include/configs/canyonlands.h +++ b/include/configs/canyonlands.h @@ -13,8 +13,6 @@ #include -#define CONFIG_SYS_GENERIC_BOARD - /*----------------------------------------------------------------------- * High Level Configuration Options *----------------------------------------------------------------------*/ -- cgit v0.10.2 From 246e3b87870aaa774769267012f624757f28d873 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 27 Mar 2015 20:54:25 +0100 Subject: sunxi: musb: Fix some lo speed devices not working with musb host The usb0 / otg phy on sunxi boards has a bug where it wrongly detects a high speed squelch on usb reset deassert when a lo speed device is plugged in. The android kernel has a work around for this in the form of temporary disabling the phy's squelch detection on reset deassert, this commit adds the same workaround to the u-boot sunxi musb code, thereby fixing various usb lo speed devices not working. Tested with a (before non working) usb keyboard and a usb 2.4 GHz wireless keyboard/mouse combo receiver. Signed-off-by: Hans de Goede Acked-by: Ian Campbell diff --git a/arch/arm/cpu/armv7/sunxi/usbc.c b/arch/arm/cpu/armv7/sunxi/usbc.c index 14de9f9..524f25c 100644 --- a/arch/arm/cpu/armv7/sunxi/usbc.c +++ b/arch/arm/cpu/armv7/sunxi/usbc.c @@ -182,6 +182,13 @@ static void sunxi_usb_passby(struct sunxi_usbc_hcd *sunxi_usbc, int enable) return; } +void sunxi_usbc_enable_squelch_detect(int index, int enable) +{ + struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index]; + + usb_phy_write(sunxi_usbc, 0x3c, enable ? 0 : 2, 2); +} + int sunxi_usbc_request_resources(int index) { struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index]; diff --git a/arch/arm/include/asm/arch-sunxi/usbc.h b/arch/arm/include/asm/arch-sunxi/usbc.h index cb538cd..1330733 100644 --- a/arch/arm/include/asm/arch-sunxi/usbc.h +++ b/arch/arm/include/asm/arch-sunxi/usbc.h @@ -20,3 +20,4 @@ void sunxi_usbc_enable(int index); void sunxi_usbc_disable(int index); void sunxi_usbc_vbus_enable(int index); void sunxi_usbc_vbus_disable(int index); +void sunxi_usbc_enable_squelch_detect(int index, int enable); diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 6e58ddf..51fb3fd 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -1,5 +1,8 @@ #include #include +#ifdef CONFIG_ARCH_SUNXI +#include +#endif #include #include #include @@ -186,8 +189,19 @@ void usb_reset_root_port(void) power &= 0xf0; musb_writeb(mbase, MUSB_POWER, MUSB_POWER_RESET | power); mdelay(50); +#ifdef CONFIG_ARCH_SUNXI + /* + * sunxi phy has a bug and it will wrongly detect high speed squelch + * when clearing reset on low-speed devices, temporary disable + * squelch detection to work around this. + */ + sunxi_usbc_enable_squelch_detect(0, 0); +#endif power = musb_readb(mbase, MUSB_POWER); musb_writeb(mbase, MUSB_POWER, ~MUSB_POWER_RESET & power); +#ifdef CONFIG_ARCH_SUNXI + sunxi_usbc_enable_squelch_detect(0, 1); +#endif host->isr(0, host); host_speed = (musb_readb(mbase, MUSB_POWER) & MUSB_POWER_HSMODE) ? USB_SPEED_HIGH : -- cgit v0.10.2 From 7a140117ef5081e8dfef95150c788c93dabb8124 Mon Sep 17 00:00:00 2001 From: Iain Paton Date: Sat, 28 Mar 2015 10:25:28 +0000 Subject: sunxi: sun4i: improve cpu clock selection method clock_set_pll1 would pick the next highest available cpu clock speed if a value not in the pre defined table was selected. this potentially results in overclocking the soc. reverse the selection method so that we select the next lowest speed and add the missing 912Mhz setting that's requested by sun7i which also uses the sun4i clock code. Signed-off-by: Iain Paton Acked-by: Hans de Goede Signed-off-by: Hans de Goede diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c index 49f4032..c3e04af 100644 --- a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c @@ -100,22 +100,23 @@ static struct { unsigned int freq; } pll1_para[] = { /* This array must be ordered by frequency. */ - { PLL1_CFG(16, 0, 0, 0), 384000000 }, - { PLL1_CFG(16, 1, 0, 0), 768000000 }, - { PLL1_CFG(20, 1, 0, 0), 960000000 }, - { PLL1_CFG(21, 1, 0, 0), 1008000000}, - { PLL1_CFG(22, 1, 0, 0), 1056000000}, - { PLL1_CFG(23, 1, 0, 0), 1104000000}, - { PLL1_CFG(24, 1, 0, 0), 1152000000}, - { PLL1_CFG(25, 1, 0, 0), 1200000000}, - { PLL1_CFG(26, 1, 0, 0), 1248000000}, - { PLL1_CFG(27, 1, 0, 0), 1296000000}, - { PLL1_CFG(28, 1, 0, 0), 1344000000}, - { PLL1_CFG(29, 1, 0, 0), 1392000000}, - { PLL1_CFG(30, 1, 0, 0), 1440000000}, { PLL1_CFG(31, 1, 0, 0), 1488000000}, - /* Final catchall entry */ - { PLL1_CFG(31, 1, 0, 0), ~0}, + { PLL1_CFG(30, 1, 0, 0), 1440000000}, + { PLL1_CFG(29, 1, 0, 0), 1392000000}, + { PLL1_CFG(28, 1, 0, 0), 1344000000}, + { PLL1_CFG(27, 1, 0, 0), 1296000000}, + { PLL1_CFG(26, 1, 0, 0), 1248000000}, + { PLL1_CFG(25, 1, 0, 0), 1200000000}, + { PLL1_CFG(24, 1, 0, 0), 1152000000}, + { PLL1_CFG(23, 1, 0, 0), 1104000000}, + { PLL1_CFG(22, 1, 0, 0), 1056000000}, + { PLL1_CFG(21, 1, 0, 0), 1008000000}, + { PLL1_CFG(20, 1, 0, 0), 960000000 }, + { PLL1_CFG(19, 1, 0, 0), 912000000 }, + { PLL1_CFG(16, 1, 0, 0), 768000000 }, + /* Final catchall entry 384MHz*/ + { PLL1_CFG(16, 0, 0, 0), 0 }, + }; void clock_set_pll1(unsigned int hz) @@ -126,10 +127,12 @@ void clock_set_pll1(unsigned int hz) (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; /* Find target frequency */ - while (pll1_para[i].freq < hz) + while (pll1_para[i].freq > hz) i++; hz = pll1_para[i].freq; + if (! hz) + hz = 384000000; /* Calculate system clock divisors */ axi = DIV_ROUND_UP(hz, 432000000); /* Max 450MHz */ -- cgit v0.10.2 From e71b422bd71b03868abfc5e2087281710a0d52ee Mon Sep 17 00:00:00 2001 From: Iain Paton Date: Sat, 28 Mar 2015 10:26:38 +0000 Subject: sunxi: use CONFIG_SYS_CLK_FREQ to set cpu clock make the CPU clock selectable via Kconfig this removes the sunxi specific CONFIG_CLK_FULL_SPEED defined in each soc header and replaces it's use in board/sunxi/board.c with CONFIG_SYS_CLK_FREQ from Kconfig which allows us to configure board specific frequency on boot Signed-off-by: Iain Paton [hdegoede@redhat.com s/CONFIG_SYS_CLK_FREQ/CONFIG_TIMER_CLK_FREQ/ for the arch-timer clk speed on sun7i to fix mis-compile on sun7i] Acked-by: Hans de Goede Signed-off-by: Hans de Goede diff --git a/Kconfig b/Kconfig index b5968d7..41d4784 100644 --- a/Kconfig +++ b/Kconfig @@ -184,7 +184,7 @@ config SYS_TEXT_BASE TODO: Move CONFIG_SYS_TEXT_BASE for all the architecture config SYS_CLK_FREQ - depends on ARC + depends on ARC || ARCH_SUNXI int "CPU clock frequency" help TODO: Move CONFIG_SYS_CLK_FREQ for all the architecture diff --git a/arch/arm/cpu/armv7/sunxi/psci.S b/arch/arm/cpu/armv7/sunxi/psci.S index 5be497b..e0a524e 100644 --- a/arch/arm/cpu/armv7/sunxi/psci.S +++ b/arch/arm/cpu/armv7/sunxi/psci.S @@ -37,7 +37,7 @@ .arch_extension sec -#define ONE_MS (CONFIG_SYS_CLK_FREQ / 1000) +#define ONE_MS (CONFIG_TIMER_CLK_FREQ / 1000) #define TEN_MS (10 * ONE_MS) #define GICD_BASE 0x1c81000 #define GICC_BASE 0x1c82000 diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 9d0eb91..2fcab60 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -132,6 +132,10 @@ endchoice endif +config SYS_CLK_FREQ + default 912000000 if MACH_SUN7I + default 1008000000 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN8I + config SYS_CONFIG_NAME default "sun4i" if MACH_SUN4I default "sun5i" if MACH_SUN5I diff --git a/board/sunxi/board.c b/board/sunxi/board.c index e1891d1..808bf82 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -215,7 +215,7 @@ void sunxi_board_init(void) * assured it's being powered with suitable core voltage */ if (!power_failed) - clock_set_pll1(CONFIG_CLK_FULL_SPEED); + clock_set_pll1(CONFIG_SYS_CLK_FREQ); else printf("Failed to set core voltage! Can't set CPU frequency\n"); } diff --git a/include/configs/sun4i.h b/include/configs/sun4i.h index 1537e53..7cd5c69 100644 --- a/include/configs/sun4i.h +++ b/include/configs/sun4i.h @@ -11,7 +11,6 @@ /* * A10 specific configuration */ -#define CONFIG_CLK_FULL_SPEED 1008000000 #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI diff --git a/include/configs/sun5i.h b/include/configs/sun5i.h index e755531..e0470d4 100644 --- a/include/configs/sun5i.h +++ b/include/configs/sun5i.h @@ -11,7 +11,6 @@ /* * High Level Configuration Options */ -#define CONFIG_CLK_FULL_SPEED 1008000000 #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI diff --git a/include/configs/sun6i.h b/include/configs/sun6i.h index f5e11dd..617c1cd 100644 --- a/include/configs/sun6i.h +++ b/include/configs/sun6i.h @@ -14,7 +14,6 @@ /* * A31 specific configuration */ -#define CONFIG_CLK_FULL_SPEED 1008000000 #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI diff --git a/include/configs/sun7i.h b/include/configs/sun7i.h index f817f73..7fa7cec 100644 --- a/include/configs/sun7i.h +++ b/include/configs/sun7i.h @@ -12,7 +12,6 @@ /* * A20 specific configuration */ -#define CONFIG_CLK_FULL_SPEED 912000000 #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI @@ -21,8 +20,7 @@ #define CONFIG_ARMV7_PSCI 1 #define CONFIG_ARMV7_SECURE_BASE SUNXI_SRAM_B_BASE -#define CONFIG_SYS_CLK_FREQ 24000000 -#define CONFIG_TIMER_CLK_FREQ CONFIG_SYS_CLK_FREQ +#define CONFIG_TIMER_CLK_FREQ 24000000 /* * Include common sunxi configuration where most the settings are diff --git a/include/configs/sun8i.h b/include/configs/sun8i.h index 3bdedb3..79796d7 100644 --- a/include/configs/sun8i.h +++ b/include/configs/sun8i.h @@ -12,7 +12,6 @@ /* * A23 specific configuration */ -#define CONFIG_CLK_FULL_SPEED 1008000000 #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI -- cgit v0.10.2 From 961e77712bbf14a6797bc0d725aed956cd06bce1 Mon Sep 17 00:00:00 2001 From: Iain Paton Date: Sat, 28 Mar 2015 10:27:40 +0000 Subject: sunxi: a10-LIME set the cpu clock at boot to 912MHz following kernel patches to reduce the cpu clock to 912MHz due to reported instability at 1008MHz, select 912MHz as the boot speed for the a10-lime Signed-off-by: Iain Paton Acked-by: Hans de Goede Signed-off-by: Hans de Goede diff --git a/configs/A10-OLinuXino-Lime_defconfig b/configs/A10-OLinuXino-Lime_defconfig index 48a0705..3e19424 100644 --- a/configs/A10-OLinuXino-Lime_defconfig +++ b/configs/A10-OLinuXino-Lime_defconfig @@ -7,3 +7,4 @@ CONFIG_MACH_SUN4I=y CONFIG_DRAM_CLK=480 CONFIG_DRAM_ZQ=123 CONFIG_DRAM_EMR1=4 +CONFIG_SYS_CLK_FREQ=912000000 -- cgit v0.10.2 From 662e2acb46250881ec26bc8366fc9eb1856cb7c2 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 29 Mar 2015 14:55:18 +0200 Subject: sunxi: UTOO_P66: Add missing MAINTAINERS entry Signed-off-by: Hans de Goede diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS index ef3c937..be48213 100644 --- a/board/sunxi/MAINTAINERS +++ b/board/sunxi/MAINTAINERS @@ -21,6 +21,7 @@ F: configs/A13-OLinuXinoM_defconfig F: configs/Auxtek-T004_defconfig F: configs/mk802_a10s_defconfig F: configs/r7-tv-dongle_defconfig +F: configs/UTOO_P66_defconfig F: include/configs/sun6i.h F: configs/CSQ_CS908_defconfig F: configs/Mele_M9_defconfig -- cgit v0.10.2 From a46988f11f7fad3043c6db1169f05d10f002d12c Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 15 Jan 2015 13:32:55 +0800 Subject: spi: cf_qspi: Fixup to_cf_qspi_slave macro The third parameter of container_of is the name of the member within the struct. Current code only works if the parameter passed to to_cf_qspi_slave named slave. Fix it. Signed-off-by: Axel Lin Reviewed-by: Jagannadha Sutradharudu Teki diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c index 6b85633..834c5bd 100644 --- a/drivers/spi/cf_qspi.c +++ b/drivers/spi/cf_qspi.c @@ -20,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR; #define clamp(x, low, high) (min(max(low, x), high)) -#define to_cf_qspi_slave(s) container_of(s, struct cf_qspi_slave, s) +#define to_cf_qspi_slave(s) container_of(s, struct cf_qspi_slave, slave) struct cf_qspi_slave { struct spi_slave slave; /* Specific bus:cs ID for each device */ -- cgit v0.10.2 From aa8306a90e398e5667ccd03ef8512837116bcc51 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 13 Jan 2015 09:01:19 +0800 Subject: spi: davinci: Remove duplicate code to set bus and cs for slave It's done in spi_alloc_slave(). Signed-off-by: Axel Lin Reviewed-by: Jagannadha Sutradharudu Teki diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index 0ec5b9d..bf18362 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -32,9 +32,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, if (!ds) return NULL; - ds->slave.bus = bus; - ds->slave.cs = cs; - switch (bus) { case SPI0_BUS: ds->regs = (struct davinci_spi_regs *)SPI0_BASE; -- cgit v0.10.2 From 81a66446c319225c4a8f0c4c0d9cf4ee10f8c2b9 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 9 Feb 2015 15:11:09 +0800 Subject: spi: ftssp010_spi: Use to_ftssp010_spi() to ensure free correct address Don't assume slave is always the first member of struct ftssp010_spi. Use to_ftssp010_spi() to ensure free correct address in spi_free_slave(). Signed-off-by: Axel Lin Reviewed-by: Jagannadha Sutradharudu Teki diff --git a/drivers/spi/ftssp010_spi.c b/drivers/spi/ftssp010_spi.c index 267e4d8..c7d6480 100644 --- a/drivers/spi/ftssp010_spi.c +++ b/drivers/spi/ftssp010_spi.c @@ -431,7 +431,9 @@ free_out: void spi_free_slave(struct spi_slave *slave) { - free(slave); + struct ftssp010_spi *chip = to_ftssp010_spi(slave); + + free(chip); } int spi_claim_bus(struct spi_slave *slave) -- cgit v0.10.2 From 46122960f0e7bac8cbb97bcccf8dc788c3a0beeb Mon Sep 17 00:00:00 2001 From: Ravi Babu Date: Wed, 11 Feb 2015 18:54:29 -0500 Subject: qspi: dra7x: enable quad mode read for ti-qspi driver This patch enables QUAD read mode for qspi to improve the read performace while loading the binaries from qspi. Signed-off-by: Ravi Babu Reviewed-by: Jagannadha Sutradharudu Teki diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c index 857b604..3356c0f 100644 --- a/drivers/spi/ti_qspi.c +++ b/drivers/spi/ti_qspi.c @@ -109,10 +109,17 @@ static void ti_spi_setup_spi_register(struct ti_qspi_slave *qslave) slave->op_mode_rx = 8; #endif +#ifdef CONFIG_QSPI_QUAD_SUPPORT + memval |= (QSPI_CMD_READ_QUAD | QSPI_SETUP0_NUM_A_BYTES | + QSPI_SETUP0_NUM_D_BYTES_8_BITS | + QSPI_SETUP0_READ_QUAD | QSPI_CMD_WRITE | + QSPI_NUM_DUMMY_BITS); +#else memval |= QSPI_CMD_READ | QSPI_SETUP0_NUM_A_BYTES | QSPI_SETUP0_NUM_D_BYTES_NO_BITS | QSPI_SETUP0_READ_NORMAL | QSPI_CMD_WRITE | QSPI_NUM_DUMMY_BITS; +#endif writel(memval, &qslave->base->setup0); } diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h index dee2b11..8fe0e6c 100644 --- a/include/configs/dra7xx_evm.h +++ b/include/configs/dra7xx_evm.h @@ -77,6 +77,7 @@ #define CONFIG_TI_SPI_MMAP #define CONFIG_SF_DEFAULT_SPEED 48000000 #define CONFIG_DEFAULT_SPI_MODE SPI_MODE_3 +#define CONFIG_QSPI_QUAD_SUPPORT /* * Default to using SPI for environment, etc. -- cgit v0.10.2 From bb1662760eb0ec2eb88253cb95e2d423b2c2bb44 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 21 Feb 2015 00:17:47 +0800 Subject: spi: cf_spi: Use to_cf_spi_slave to resolve cfslave from slave Don't assume slave is always the first member of struct cf_spi_slave. Use container_of instead of casting first structure member. Signed-off-by: Axel Lin Reviewed-by: Jagannadha Sutradharudu Teki diff --git a/drivers/spi/cf_spi.c b/drivers/spi/cf_spi.c index 879a809..7453538 100644 --- a/drivers/spi/cf_spi.c +++ b/drivers/spi/cf_spi.c @@ -46,6 +46,11 @@ DECLARE_GLOBAL_DATA_PTR; #define SPI_MODE_MOD 0x00200000 #define SPI_DBLRATE 0x00100000 +static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave) +{ + return container_of(slave, struct cf_spi_slave, slave); +} + void cfspi_init(void) { volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI; @@ -105,7 +110,7 @@ u16 cfspi_rx(void) int cfspi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, ulong flags) { - struct cf_spi_slave *cfslave = (struct cf_spi_slave *)slave; + struct cf_spi_slave *cfslave = to_cf_spi_slave(slave); u16 *spi_rd16 = NULL, *spi_wr16 = NULL; u8 *spi_rd = NULL, *spi_wr = NULL; static u32 ctrl = 0; @@ -326,7 +331,9 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, void spi_free_slave(struct spi_slave *slave) { - free(slave); + struct cf_spi_slave *cfslave = to_cf_spi_slave(slave); + + free(cfslave); } int spi_claim_bus(struct spi_slave *slave) -- cgit v0.10.2 From 1478aeb32dcf57fdd01fd9efc3e3ab0083450cc3 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 21 Feb 2015 00:19:28 +0800 Subject: spi: cf_spi: Staticize local functions Make local functions static and remove unneeded forward declarations. Signed-off-by: Axel Lin Reviewed-by: Jagannadha Sutradharudu Teki diff --git a/drivers/spi/cf_spi.c b/drivers/spi/cf_spi.c index 7453538..6ce1101 100644 --- a/drivers/spi/cf_spi.c +++ b/drivers/spi/cf_spi.c @@ -20,13 +20,6 @@ struct cf_spi_slave { int charbit; }; -int cfspi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, - void *din, ulong flags); -struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, uint mode); -void cfspi_init(void); -void cfspi_tx(u32 ctrl, u16 data); -u16 cfspi_rx(void); - extern void cfspi_port_conf(void); extern int cfspi_claim_bus(uint bus, uint cs); extern void cfspi_release_bus(uint bus, uint cs); @@ -51,7 +44,7 @@ static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave) return container_of(slave, struct cf_spi_slave, slave); } -void cfspi_init(void) +static void cfspi_init(void) { volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI; @@ -89,7 +82,7 @@ void cfspi_init(void) #endif } -void cfspi_tx(u32 ctrl, u16 data) +static void cfspi_tx(u32 ctrl, u16 data) { volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI; @@ -98,7 +91,7 @@ void cfspi_tx(u32 ctrl, u16 data) dspi->tfr = (ctrl | data); } -u16 cfspi_rx(void) +static u16 cfspi_rx(void) { volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI; @@ -107,8 +100,8 @@ u16 cfspi_rx(void) return (dspi->rfr & 0xFFFF); } -int cfspi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, - void *din, ulong flags) +static int cfspi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, + void *din, ulong flags) { struct cf_spi_slave *cfslave = to_cf_spi_slave(slave); u16 *spi_rd16 = NULL, *spi_wr16 = NULL; @@ -181,7 +174,8 @@ int cfspi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, return 0; } -struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, uint mode) +static struct spi_slave *cfspi_setup_slave(struct cf_spi_slave *cfslave, + uint mode) { /* * bit definition for mode: -- cgit v0.10.2 From 52091ad146d766cdc5ccd65430b2a4e5cb7aec32 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 26 Feb 2015 10:45:22 +0800 Subject: spi: designware_spi: revisit FIFO size detection again By specification the FIFO size would be in a range 2-256 bytes. From TX Level prospective it means we can set threshold in the range 0-(FIFO size - 1) bytes. Hence there are currently two issues: a) FIFO size 2 bytes is actually skipped since TX Level is 1 bit and could be either 0 or 1 byte; b) FIFO size is incorrectly decreased by 1 which already done by meaning of TX Level register. Fixes: 501943696ea4 (spi: designware_spi: Fix detecting FIFO depth) Signed-off-by: Andy Shevchenko Signed-off-by: Axel Lin Acked-by: Pavel Machek Reviewed-by: Jagannadha Sutradharudu Teki diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c index 2624844..8f5c0fc 100644 --- a/drivers/spi/designware_spi.c +++ b/drivers/spi/designware_spi.c @@ -164,13 +164,13 @@ static void spi_hw_init(struct dw_spi_priv *priv) if (!priv->fifo_len) { u32 fifo; - for (fifo = 2; fifo <= 256; fifo++) { + for (fifo = 1; fifo < 256; fifo++) { dw_writew(priv, DW_SPI_TXFLTR, fifo); if (fifo != dw_readw(priv, DW_SPI_TXFLTR)) break; } - priv->fifo_len = (fifo == 2) ? 0 : fifo - 1; + priv->fifo_len = (fifo == 1) ? 0 : fifo; dw_writew(priv, DW_SPI_TXFLTR, 0); } debug("%s: fifo_len=%d\n", __func__, priv->fifo_len); -- cgit v0.10.2 From 0edb3a8ec9a48725bf323e99b2167318fae4315a Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 25 Mar 2015 12:04:34 -0600 Subject: ARM: tegra: pinctrl: move Tegra210 code to the correct dir Patches that added the Tegra210 pinctrl driver and renamed directories arch/arm/cpu/tegra{$soc}-common -> arch/arm/mach-tegra/tegra-${soc} crossed. Move the Tegra210 pinctrl driver to the correct location. This wasn't detected since Tegra210 support is in the process of being added, and isn't buildable yet. Signed-off-by: Stephen Warren Signed-off-by: Tom Warren diff --git a/arch/arm/cpu/tegra210-common/pinmux.c b/arch/arm/cpu/tegra210-common/pinmux.c deleted file mode 100644 index a29c76b..0000000 --- a/arch/arm/cpu/tegra210-common/pinmux.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include - -#define PIN(pin, f0, f1, f2, f3) \ - { \ - .funcs = { \ - PMUX_FUNC_##f0, \ - PMUX_FUNC_##f1, \ - PMUX_FUNC_##f2, \ - PMUX_FUNC_##f3, \ - }, \ - } - -#define PIN_RESERVED {} - -static const struct pmux_pingrp_desc tegra210_pingroups[] = { - /* pin, f0, f1, f2, f3 */ - /* Offset 0x3000 */ - PIN(SDMMC1_CLK_PM0, SDMMC1, RSVD1, RSVD2, RSVD3), - PIN(SDMMC1_CMD_PM1, SDMMC1, SPI3, RSVD2, RSVD3), - PIN(SDMMC1_DAT3_PM2, SDMMC1, SPI3, RSVD2, RSVD3), - PIN(SDMMC1_DAT2_PM3, SDMMC1, SPI3, RSVD2, RSVD3), - PIN(SDMMC1_DAT1_PM4, SDMMC1, SPI3, RSVD2, RSVD3), - PIN(SDMMC1_DAT0_PM5, SDMMC1, RSVD1, RSVD2, RSVD3), - PIN_RESERVED, - /* Offset 0x301c */ - PIN(SDMMC3_CLK_PP0, SDMMC3, RSVD1, RSVD2, RSVD3), - PIN(SDMMC3_CMD_PP1, SDMMC3, RSVD1, RSVD2, RSVD3), - PIN(SDMMC3_DAT0_PP5, SDMMC3, RSVD1, RSVD2, RSVD3), - PIN(SDMMC3_DAT1_PP4, SDMMC3, RSVD1, RSVD2, RSVD3), - PIN(SDMMC3_DAT2_PP3, SDMMC3, RSVD1, RSVD2, RSVD3), - PIN(SDMMC3_DAT3_PP2, SDMMC3, RSVD1, RSVD2, RSVD3), - PIN_RESERVED, - /* Offset 0x3038 */ - PIN(PEX_L0_RST_N_PA0, PE0, RSVD1, RSVD2, RSVD3), - PIN(PEX_L0_CLKREQ_N_PA1, PE0, RSVD1, RSVD2, RSVD3), - PIN(PEX_WAKE_N_PA2, PE, RSVD1, RSVD2, RSVD3), - PIN(PEX_L1_RST_N_PA3, PE1, RSVD1, RSVD2, RSVD3), - PIN(PEX_L1_CLKREQ_N_PA4, PE1, RSVD1, RSVD2, RSVD3), - PIN(SATA_LED_ACTIVE_PA5, SATA, RSVD1, RSVD2, RSVD3), - PIN(SPI1_MOSI_PC0, SPI1, RSVD1, RSVD2, RSVD3), - PIN(SPI1_MISO_PC1, SPI1, RSVD1, RSVD2, RSVD3), - PIN(SPI1_SCK_PC2, SPI1, RSVD1, RSVD2, RSVD3), - PIN(SPI1_CS0_PC3, SPI1, RSVD1, RSVD2, RSVD3), - PIN(SPI1_CS1_PC4, SPI1, RSVD1, RSVD2, RSVD3), - PIN(SPI2_MOSI_PB4, SPI2, DTV, RSVD2, RSVD3), - PIN(SPI2_MISO_PB5, SPI2, DTV, RSVD2, RSVD3), - PIN(SPI2_SCK_PB6, SPI2, DTV, RSVD2, RSVD3), - PIN(SPI2_CS0_PB7, SPI2, DTV, RSVD2, RSVD3), - PIN(SPI2_CS1_PDD0, SPI2, RSVD1, RSVD2, RSVD3), - PIN(SPI4_MOSI_PC7, SPI4, RSVD1, RSVD2, RSVD3), - PIN(SPI4_MISO_PD0, SPI4, RSVD1, RSVD2, RSVD3), - PIN(SPI4_SCK_PC5, SPI4, RSVD1, RSVD2, RSVD3), - PIN(SPI4_CS0_PC6, SPI4, RSVD1, RSVD2, RSVD3), - PIN(QSPI_SCK_PEE0, QSPI, RSVD1, RSVD2, RSVD3), - PIN(QSPI_CS_N_PEE1, QSPI, RSVD1, RSVD2, RSVD3), - PIN(QSPI_IO0_PEE2, QSPI, RSVD1, RSVD2, RSVD3), - PIN(QSPI_IO1_PEE3, QSPI, RSVD1, RSVD2, RSVD3), - PIN(QSPI_IO2_PEE4, QSPI, RSVD1, RSVD2, RSVD3), - PIN(QSPI_IO3_PEE5, QSPI, RSVD1, RSVD2, RSVD3), - PIN_RESERVED, - /* Offset 0x30a4 */ - PIN(DMIC1_CLK_PE0, DMIC1, I2S3, RSVD2, RSVD3), - PIN(DMIC1_DAT_PE1, DMIC1, I2S3, RSVD2, RSVD3), - PIN(DMIC2_CLK_PE2, DMIC2, I2S3, RSVD2, RSVD3), - PIN(DMIC2_DAT_PE3, DMIC2, I2S3, RSVD2, RSVD3), - PIN(DMIC3_CLK_PE4, DMIC3, I2S5A, RSVD2, RSVD3), - PIN(DMIC3_DAT_PE5, DMIC3, I2S5A, RSVD2, RSVD3), - PIN(GEN1_I2C_SCL_PJ1, I2C1, RSVD1, RSVD2, RSVD3), - PIN(GEN1_I2C_SDA_PJ0, I2C1, RSVD1, RSVD2, RSVD3), - PIN(GEN2_I2C_SCL_PJ2, I2C2, RSVD1, RSVD2, RSVD3), - PIN(GEN2_I2C_SDA_PJ3, I2C2, RSVD1, RSVD2, RSVD3), - PIN(GEN3_I2C_SCL_PF0, I2C3, RSVD1, RSVD2, RSVD3), - PIN(GEN3_I2C_SDA_PF1, I2C3, RSVD1, RSVD2, RSVD3), - PIN(CAM_I2C_SCL_PS2, I2C3, I2CVI, RSVD2, RSVD3), - PIN(CAM_I2C_SDA_PS3, I2C3, I2CVI, RSVD2, RSVD3), - PIN(PWR_I2C_SCL_PY3, I2CPMU, RSVD1, RSVD2, RSVD3), - PIN(PWR_I2C_SDA_PY4, I2CPMU, RSVD1, RSVD2, RSVD3), - PIN(UART1_TX_PU0, UARTA, RSVD1, RSVD2, RSVD3), - PIN(UART1_RX_PU1, UARTA, RSVD1, RSVD2, RSVD3), - PIN(UART1_RTS_PU2, UARTA, RSVD1, RSVD2, RSVD3), - PIN(UART1_CTS_PU3, UARTA, RSVD1, RSVD2, RSVD3), - PIN(UART2_TX_PG0, UARTB, I2S4A, SPDIF, UART), - PIN(UART2_RX_PG1, UARTB, I2S4A, SPDIF, UART), - PIN(UART2_RTS_PG2, UARTB, I2S4A, RSVD2, UART), - PIN(UART2_CTS_PG3, UARTB, I2S4A, RSVD2, UART), - PIN(UART3_TX_PD1, UARTC, SPI4, RSVD2, RSVD3), - PIN(UART3_RX_PD2, UARTC, SPI4, RSVD2, RSVD3), - PIN(UART3_RTS_PD3, UARTC, SPI4, RSVD2, RSVD3), - PIN(UART3_CTS_PD4, UARTC, SPI4, RSVD2, RSVD3), - PIN(UART4_TX_PI4, UARTD, UART, RSVD2, RSVD3), - PIN(UART4_RX_PI5, UARTD, UART, RSVD2, RSVD3), - PIN(UART4_RTS_PI6, UARTD, UART, RSVD2, RSVD3), - PIN(UART4_CTS_PI7, UARTD, UART, RSVD2, RSVD3), - PIN(DAP1_FS_PB0, I2S1, RSVD1, RSVD2, RSVD3), - PIN(DAP1_DIN_PB1, I2S1, RSVD1, RSVD2, RSVD3), - PIN(DAP1_DOUT_PB2, I2S1, RSVD1, RSVD2, RSVD3), - PIN(DAP1_SCLK_PB3, I2S1, RSVD1, RSVD2, RSVD3), - PIN(DAP2_FS_PAA0, I2S2, RSVD1, RSVD2, RSVD3), - PIN(DAP2_DIN_PAA2, I2S2, RSVD1, RSVD2, RSVD3), - PIN(DAP2_DOUT_PAA3, I2S2, RSVD1, RSVD2, RSVD3), - PIN(DAP2_SCLK_PAA1, I2S2, RSVD1, RSVD2, RSVD3), - PIN(DAP4_FS_PJ4, I2S4B, RSVD1, RSVD2, RSVD3), - PIN(DAP4_DIN_PJ5, I2S4B, RSVD1, RSVD2, RSVD3), - PIN(DAP4_DOUT_PJ6, I2S4B, RSVD1, RSVD2, RSVD3), - PIN(DAP4_SCLK_PJ7, I2S4B, RSVD1, RSVD2, RSVD3), - PIN(CAM1_MCLK_PS0, EXTPERIPH3, RSVD1, RSVD2, RSVD3), - PIN(CAM2_MCLK_PS1, EXTPERIPH3, RSVD1, RSVD2, RSVD3), - PIN(JTAG_RTCK, JTAG, RSVD1, RSVD2, RSVD3), - PIN(CLK_32K_IN, CLK, RSVD1, RSVD2, RSVD3), - PIN(CLK_32K_OUT_PY5, SOC, BLINK, RSVD2, RSVD3), - PIN(BATT_BCL, BCL, RSVD1, RSVD2, RSVD3), - PIN(CLK_REQ, SYS, RSVD1, RSVD2, RSVD3), - PIN(CPU_PWR_REQ, CPU, RSVD1, RSVD2, RSVD3), - PIN(PWR_INT_N, PMI, RSVD1, RSVD2, RSVD3), - PIN(SHUTDOWN, SHUTDOWN, RSVD1, RSVD2, RSVD3), - PIN(CORE_PWR_REQ, CORE, RSVD1, RSVD2, RSVD3), - PIN(AUD_MCLK_PBB0, AUD, RSVD1, RSVD2, RSVD3), - PIN(DVFS_PWM_PBB1, RSVD0, CLDVFS, SPI3, RSVD3), - PIN(DVFS_CLK_PBB2, RSVD0, CLDVFS, SPI3, RSVD3), - PIN(GPIO_X1_AUD_PBB3, RSVD0, RSVD1, SPI3, RSVD3), - PIN(GPIO_X3_AUD_PBB4, RSVD0, RSVD1, SPI3, RSVD3), - PIN(PCC7, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(HDMI_CEC_PCC0, CEC, RSVD1, RSVD2, RSVD3), - PIN(HDMI_INT_DP_HPD_PCC1, DP, RSVD1, RSVD2, RSVD3), - PIN(SPDIF_OUT_PCC2, SPDIF, RSVD1, RSVD2, RSVD3), - PIN(SPDIF_IN_PCC3, SPDIF, RSVD1, RSVD2, RSVD3), - PIN(USB_VBUS_EN0_PCC4, USB, RSVD1, RSVD2, RSVD3), - PIN(USB_VBUS_EN1_PCC5, USB, RSVD1, RSVD2, RSVD3), - PIN(DP_HPD0_PCC6, DP, RSVD1, RSVD2, RSVD3), - PIN(WIFI_EN_PH0, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(WIFI_RST_PH1, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(WIFI_WAKE_AP_PH2, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(AP_WAKE_BT_PH3, RSVD0, UARTB, SPDIF, RSVD3), - PIN(BT_RST_PH4, RSVD0, UARTB, SPDIF, RSVD3), - PIN(BT_WAKE_AP_PH5, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(AP_WAKE_NFC_PH7, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(NFC_EN_PI0, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(NFC_INT_PI1, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(GPS_EN_PI2, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(GPS_RST_PI3, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(CAM_RST_PS4, VGP1, RSVD1, RSVD2, RSVD3), - PIN(CAM_AF_EN_PS5, VIMCLK, VGP2, RSVD2, RSVD3), - PIN(CAM_FLASH_EN_PS6, VIMCLK, VGP3, RSVD2, RSVD3), - PIN(CAM1_PWDN_PS7, VGP4, RSVD1, RSVD2, RSVD3), - PIN(CAM2_PWDN_PT0, VGP5, RSVD1, RSVD2, RSVD3), - PIN(CAM1_STROBE_PT1, VGP6, RSVD1, RSVD2, RSVD3), - PIN(LCD_TE_PY2, DISPLAYA, RSVD1, RSVD2, RSVD3), - PIN(LCD_BL_PWM_PV0, DISPLAYA, PWM0, SOR0, RSVD3), - PIN(LCD_BL_EN_PV1, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(LCD_RST_PV2, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(LCD_GPIO1_PV3, DISPLAYB, RSVD1, RSVD2, RSVD3), - PIN(LCD_GPIO2_PV4, DISPLAYB, PWM1, RSVD2, SOR1), - PIN(AP_READY_PV5, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(TOUCH_RST_PV6, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(TOUCH_CLK_PV7, TOUCH, RSVD1, RSVD2, RSVD3), - PIN(MODEM_WAKE_AP_PX0, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(TOUCH_INT_PX1, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(MOTION_INT_PX2, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(ALS_PROX_INT_PX3, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(TEMP_ALERT_PX4, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(BUTTON_POWER_ON_PX5, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(BUTTON_VOL_UP_PX6, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(BUTTON_VOL_DOWN_PX7, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(BUTTON_SLIDE_SW_PY0, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(BUTTON_HOME_PY1, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(PA6, SATA, RSVD1, RSVD2, RSVD3), - PIN(PE6, RSVD0, I2S5A, PWM2, RSVD3), - PIN(PE7, RSVD0, I2S5A, PWM3, RSVD3), - PIN(PH6, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(PK0, IQC0, I2S5B, RSVD2, RSVD3), - PIN(PK1, IQC0, I2S5B, RSVD2, RSVD3), - PIN(PK2, IQC0, I2S5B, RSVD2, RSVD3), - PIN(PK3, IQC0, I2S5B, RSVD2, RSVD3), - PIN(PK4, IQC1, RSVD1, RSVD2, RSVD3), - PIN(PK5, IQC1, RSVD1, RSVD2, RSVD3), - PIN(PK6, IQC1, RSVD1, RSVD2, RSVD3), - PIN(PK7, IQC1, RSVD1, RSVD2, RSVD3), - PIN(PL0, RSVD0, RSVD1, RSVD2, RSVD3), - PIN(PL1, SOC, RSVD1, RSVD2, RSVD3), - PIN(PZ0, VIMCLK2, RSVD1, RSVD2, RSVD3), - PIN(PZ1, VIMCLK2, SDMMC1, RSVD2, RSVD3), - PIN(PZ2, SDMMC3, CCLA, RSVD2, RSVD3), - PIN(PZ3, SDMMC3, RSVD1, RSVD2, RSVD3), - PIN(PZ4, SDMMC1, RSVD1, RSVD2, RSVD3), - PIN(PZ5, SOC, RSVD1, RSVD2, RSVD3), -}; -const struct pmux_pingrp_desc *tegra_soc_pingroups = tegra210_pingroups; diff --git a/arch/arm/mach-tegra/tegra210/pinmux.c b/arch/arm/mach-tegra/tegra210/pinmux.c new file mode 100644 index 0000000..a29c76b --- /dev/null +++ b/arch/arm/mach-tegra/tegra210/pinmux.c @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +#define PIN(pin, f0, f1, f2, f3) \ + { \ + .funcs = { \ + PMUX_FUNC_##f0, \ + PMUX_FUNC_##f1, \ + PMUX_FUNC_##f2, \ + PMUX_FUNC_##f3, \ + }, \ + } + +#define PIN_RESERVED {} + +static const struct pmux_pingrp_desc tegra210_pingroups[] = { + /* pin, f0, f1, f2, f3 */ + /* Offset 0x3000 */ + PIN(SDMMC1_CLK_PM0, SDMMC1, RSVD1, RSVD2, RSVD3), + PIN(SDMMC1_CMD_PM1, SDMMC1, SPI3, RSVD2, RSVD3), + PIN(SDMMC1_DAT3_PM2, SDMMC1, SPI3, RSVD2, RSVD3), + PIN(SDMMC1_DAT2_PM3, SDMMC1, SPI3, RSVD2, RSVD3), + PIN(SDMMC1_DAT1_PM4, SDMMC1, SPI3, RSVD2, RSVD3), + PIN(SDMMC1_DAT0_PM5, SDMMC1, RSVD1, RSVD2, RSVD3), + PIN_RESERVED, + /* Offset 0x301c */ + PIN(SDMMC3_CLK_PP0, SDMMC3, RSVD1, RSVD2, RSVD3), + PIN(SDMMC3_CMD_PP1, SDMMC3, RSVD1, RSVD2, RSVD3), + PIN(SDMMC3_DAT0_PP5, SDMMC3, RSVD1, RSVD2, RSVD3), + PIN(SDMMC3_DAT1_PP4, SDMMC3, RSVD1, RSVD2, RSVD3), + PIN(SDMMC3_DAT2_PP3, SDMMC3, RSVD1, RSVD2, RSVD3), + PIN(SDMMC3_DAT3_PP2, SDMMC3, RSVD1, RSVD2, RSVD3), + PIN_RESERVED, + /* Offset 0x3038 */ + PIN(PEX_L0_RST_N_PA0, PE0, RSVD1, RSVD2, RSVD3), + PIN(PEX_L0_CLKREQ_N_PA1, PE0, RSVD1, RSVD2, RSVD3), + PIN(PEX_WAKE_N_PA2, PE, RSVD1, RSVD2, RSVD3), + PIN(PEX_L1_RST_N_PA3, PE1, RSVD1, RSVD2, RSVD3), + PIN(PEX_L1_CLKREQ_N_PA4, PE1, RSVD1, RSVD2, RSVD3), + PIN(SATA_LED_ACTIVE_PA5, SATA, RSVD1, RSVD2, RSVD3), + PIN(SPI1_MOSI_PC0, SPI1, RSVD1, RSVD2, RSVD3), + PIN(SPI1_MISO_PC1, SPI1, RSVD1, RSVD2, RSVD3), + PIN(SPI1_SCK_PC2, SPI1, RSVD1, RSVD2, RSVD3), + PIN(SPI1_CS0_PC3, SPI1, RSVD1, RSVD2, RSVD3), + PIN(SPI1_CS1_PC4, SPI1, RSVD1, RSVD2, RSVD3), + PIN(SPI2_MOSI_PB4, SPI2, DTV, RSVD2, RSVD3), + PIN(SPI2_MISO_PB5, SPI2, DTV, RSVD2, RSVD3), + PIN(SPI2_SCK_PB6, SPI2, DTV, RSVD2, RSVD3), + PIN(SPI2_CS0_PB7, SPI2, DTV, RSVD2, RSVD3), + PIN(SPI2_CS1_PDD0, SPI2, RSVD1, RSVD2, RSVD3), + PIN(SPI4_MOSI_PC7, SPI4, RSVD1, RSVD2, RSVD3), + PIN(SPI4_MISO_PD0, SPI4, RSVD1, RSVD2, RSVD3), + PIN(SPI4_SCK_PC5, SPI4, RSVD1, RSVD2, RSVD3), + PIN(SPI4_CS0_PC6, SPI4, RSVD1, RSVD2, RSVD3), + PIN(QSPI_SCK_PEE0, QSPI, RSVD1, RSVD2, RSVD3), + PIN(QSPI_CS_N_PEE1, QSPI, RSVD1, RSVD2, RSVD3), + PIN(QSPI_IO0_PEE2, QSPI, RSVD1, RSVD2, RSVD3), + PIN(QSPI_IO1_PEE3, QSPI, RSVD1, RSVD2, RSVD3), + PIN(QSPI_IO2_PEE4, QSPI, RSVD1, RSVD2, RSVD3), + PIN(QSPI_IO3_PEE5, QSPI, RSVD1, RSVD2, RSVD3), + PIN_RESERVED, + /* Offset 0x30a4 */ + PIN(DMIC1_CLK_PE0, DMIC1, I2S3, RSVD2, RSVD3), + PIN(DMIC1_DAT_PE1, DMIC1, I2S3, RSVD2, RSVD3), + PIN(DMIC2_CLK_PE2, DMIC2, I2S3, RSVD2, RSVD3), + PIN(DMIC2_DAT_PE3, DMIC2, I2S3, RSVD2, RSVD3), + PIN(DMIC3_CLK_PE4, DMIC3, I2S5A, RSVD2, RSVD3), + PIN(DMIC3_DAT_PE5, DMIC3, I2S5A, RSVD2, RSVD3), + PIN(GEN1_I2C_SCL_PJ1, I2C1, RSVD1, RSVD2, RSVD3), + PIN(GEN1_I2C_SDA_PJ0, I2C1, RSVD1, RSVD2, RSVD3), + PIN(GEN2_I2C_SCL_PJ2, I2C2, RSVD1, RSVD2, RSVD3), + PIN(GEN2_I2C_SDA_PJ3, I2C2, RSVD1, RSVD2, RSVD3), + PIN(GEN3_I2C_SCL_PF0, I2C3, RSVD1, RSVD2, RSVD3), + PIN(GEN3_I2C_SDA_PF1, I2C3, RSVD1, RSVD2, RSVD3), + PIN(CAM_I2C_SCL_PS2, I2C3, I2CVI, RSVD2, RSVD3), + PIN(CAM_I2C_SDA_PS3, I2C3, I2CVI, RSVD2, RSVD3), + PIN(PWR_I2C_SCL_PY3, I2CPMU, RSVD1, RSVD2, RSVD3), + PIN(PWR_I2C_SDA_PY4, I2CPMU, RSVD1, RSVD2, RSVD3), + PIN(UART1_TX_PU0, UARTA, RSVD1, RSVD2, RSVD3), + PIN(UART1_RX_PU1, UARTA, RSVD1, RSVD2, RSVD3), + PIN(UART1_RTS_PU2, UARTA, RSVD1, RSVD2, RSVD3), + PIN(UART1_CTS_PU3, UARTA, RSVD1, RSVD2, RSVD3), + PIN(UART2_TX_PG0, UARTB, I2S4A, SPDIF, UART), + PIN(UART2_RX_PG1, UARTB, I2S4A, SPDIF, UART), + PIN(UART2_RTS_PG2, UARTB, I2S4A, RSVD2, UART), + PIN(UART2_CTS_PG3, UARTB, I2S4A, RSVD2, UART), + PIN(UART3_TX_PD1, UARTC, SPI4, RSVD2, RSVD3), + PIN(UART3_RX_PD2, UARTC, SPI4, RSVD2, RSVD3), + PIN(UART3_RTS_PD3, UARTC, SPI4, RSVD2, RSVD3), + PIN(UART3_CTS_PD4, UARTC, SPI4, RSVD2, RSVD3), + PIN(UART4_TX_PI4, UARTD, UART, RSVD2, RSVD3), + PIN(UART4_RX_PI5, UARTD, UART, RSVD2, RSVD3), + PIN(UART4_RTS_PI6, UARTD, UART, RSVD2, RSVD3), + PIN(UART4_CTS_PI7, UARTD, UART, RSVD2, RSVD3), + PIN(DAP1_FS_PB0, I2S1, RSVD1, RSVD2, RSVD3), + PIN(DAP1_DIN_PB1, I2S1, RSVD1, RSVD2, RSVD3), + PIN(DAP1_DOUT_PB2, I2S1, RSVD1, RSVD2, RSVD3), + PIN(DAP1_SCLK_PB3, I2S1, RSVD1, RSVD2, RSVD3), + PIN(DAP2_FS_PAA0, I2S2, RSVD1, RSVD2, RSVD3), + PIN(DAP2_DIN_PAA2, I2S2, RSVD1, RSVD2, RSVD3), + PIN(DAP2_DOUT_PAA3, I2S2, RSVD1, RSVD2, RSVD3), + PIN(DAP2_SCLK_PAA1, I2S2, RSVD1, RSVD2, RSVD3), + PIN(DAP4_FS_PJ4, I2S4B, RSVD1, RSVD2, RSVD3), + PIN(DAP4_DIN_PJ5, I2S4B, RSVD1, RSVD2, RSVD3), + PIN(DAP4_DOUT_PJ6, I2S4B, RSVD1, RSVD2, RSVD3), + PIN(DAP4_SCLK_PJ7, I2S4B, RSVD1, RSVD2, RSVD3), + PIN(CAM1_MCLK_PS0, EXTPERIPH3, RSVD1, RSVD2, RSVD3), + PIN(CAM2_MCLK_PS1, EXTPERIPH3, RSVD1, RSVD2, RSVD3), + PIN(JTAG_RTCK, JTAG, RSVD1, RSVD2, RSVD3), + PIN(CLK_32K_IN, CLK, RSVD1, RSVD2, RSVD3), + PIN(CLK_32K_OUT_PY5, SOC, BLINK, RSVD2, RSVD3), + PIN(BATT_BCL, BCL, RSVD1, RSVD2, RSVD3), + PIN(CLK_REQ, SYS, RSVD1, RSVD2, RSVD3), + PIN(CPU_PWR_REQ, CPU, RSVD1, RSVD2, RSVD3), + PIN(PWR_INT_N, PMI, RSVD1, RSVD2, RSVD3), + PIN(SHUTDOWN, SHUTDOWN, RSVD1, RSVD2, RSVD3), + PIN(CORE_PWR_REQ, CORE, RSVD1, RSVD2, RSVD3), + PIN(AUD_MCLK_PBB0, AUD, RSVD1, RSVD2, RSVD3), + PIN(DVFS_PWM_PBB1, RSVD0, CLDVFS, SPI3, RSVD3), + PIN(DVFS_CLK_PBB2, RSVD0, CLDVFS, SPI3, RSVD3), + PIN(GPIO_X1_AUD_PBB3, RSVD0, RSVD1, SPI3, RSVD3), + PIN(GPIO_X3_AUD_PBB4, RSVD0, RSVD1, SPI3, RSVD3), + PIN(PCC7, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(HDMI_CEC_PCC0, CEC, RSVD1, RSVD2, RSVD3), + PIN(HDMI_INT_DP_HPD_PCC1, DP, RSVD1, RSVD2, RSVD3), + PIN(SPDIF_OUT_PCC2, SPDIF, RSVD1, RSVD2, RSVD3), + PIN(SPDIF_IN_PCC3, SPDIF, RSVD1, RSVD2, RSVD3), + PIN(USB_VBUS_EN0_PCC4, USB, RSVD1, RSVD2, RSVD3), + PIN(USB_VBUS_EN1_PCC5, USB, RSVD1, RSVD2, RSVD3), + PIN(DP_HPD0_PCC6, DP, RSVD1, RSVD2, RSVD3), + PIN(WIFI_EN_PH0, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(WIFI_RST_PH1, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(WIFI_WAKE_AP_PH2, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(AP_WAKE_BT_PH3, RSVD0, UARTB, SPDIF, RSVD3), + PIN(BT_RST_PH4, RSVD0, UARTB, SPDIF, RSVD3), + PIN(BT_WAKE_AP_PH5, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(AP_WAKE_NFC_PH7, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(NFC_EN_PI0, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(NFC_INT_PI1, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(GPS_EN_PI2, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(GPS_RST_PI3, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(CAM_RST_PS4, VGP1, RSVD1, RSVD2, RSVD3), + PIN(CAM_AF_EN_PS5, VIMCLK, VGP2, RSVD2, RSVD3), + PIN(CAM_FLASH_EN_PS6, VIMCLK, VGP3, RSVD2, RSVD3), + PIN(CAM1_PWDN_PS7, VGP4, RSVD1, RSVD2, RSVD3), + PIN(CAM2_PWDN_PT0, VGP5, RSVD1, RSVD2, RSVD3), + PIN(CAM1_STROBE_PT1, VGP6, RSVD1, RSVD2, RSVD3), + PIN(LCD_TE_PY2, DISPLAYA, RSVD1, RSVD2, RSVD3), + PIN(LCD_BL_PWM_PV0, DISPLAYA, PWM0, SOR0, RSVD3), + PIN(LCD_BL_EN_PV1, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(LCD_RST_PV2, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(LCD_GPIO1_PV3, DISPLAYB, RSVD1, RSVD2, RSVD3), + PIN(LCD_GPIO2_PV4, DISPLAYB, PWM1, RSVD2, SOR1), + PIN(AP_READY_PV5, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(TOUCH_RST_PV6, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(TOUCH_CLK_PV7, TOUCH, RSVD1, RSVD2, RSVD3), + PIN(MODEM_WAKE_AP_PX0, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(TOUCH_INT_PX1, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(MOTION_INT_PX2, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(ALS_PROX_INT_PX3, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(TEMP_ALERT_PX4, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(BUTTON_POWER_ON_PX5, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(BUTTON_VOL_UP_PX6, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(BUTTON_VOL_DOWN_PX7, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(BUTTON_SLIDE_SW_PY0, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(BUTTON_HOME_PY1, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(PA6, SATA, RSVD1, RSVD2, RSVD3), + PIN(PE6, RSVD0, I2S5A, PWM2, RSVD3), + PIN(PE7, RSVD0, I2S5A, PWM3, RSVD3), + PIN(PH6, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(PK0, IQC0, I2S5B, RSVD2, RSVD3), + PIN(PK1, IQC0, I2S5B, RSVD2, RSVD3), + PIN(PK2, IQC0, I2S5B, RSVD2, RSVD3), + PIN(PK3, IQC0, I2S5B, RSVD2, RSVD3), + PIN(PK4, IQC1, RSVD1, RSVD2, RSVD3), + PIN(PK5, IQC1, RSVD1, RSVD2, RSVD3), + PIN(PK6, IQC1, RSVD1, RSVD2, RSVD3), + PIN(PK7, IQC1, RSVD1, RSVD2, RSVD3), + PIN(PL0, RSVD0, RSVD1, RSVD2, RSVD3), + PIN(PL1, SOC, RSVD1, RSVD2, RSVD3), + PIN(PZ0, VIMCLK2, RSVD1, RSVD2, RSVD3), + PIN(PZ1, VIMCLK2, SDMMC1, RSVD2, RSVD3), + PIN(PZ2, SDMMC3, CCLA, RSVD2, RSVD3), + PIN(PZ3, SDMMC3, RSVD1, RSVD2, RSVD3), + PIN(PZ4, SDMMC1, RSVD1, RSVD2, RSVD3), + PIN(PZ5, SOC, RSVD1, RSVD2, RSVD3), +}; +const struct pmux_pingrp_desc *tegra_soc_pingroups = tegra210_pingroups; -- cgit v0.10.2 From c21478bc6e527f57cb2e3251c7d6baa3e54514c2 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 25 Mar 2015 12:04:35 -0600 Subject: ARM: tegra: pinctrl: minor cleanup Move struct pmux_pingrp_desc type and tegra_soc_pingroups variable declaration together with other pin/mux level definitions. Now the whole file is grouped/ordered pin/mux-related then drvgrp-related definitions. Fix typo in ifdef comment. Signed-off-by: Stephen Warren Signed-off-by: Tom Warren diff --git a/arch/arm/include/asm/arch-tegra/pinmux.h b/arch/arm/include/asm/arch-tegra/pinmux.h index 4212e57..e3eb706 100644 --- a/arch/arm/include/asm/arch-tegra/pinmux.h +++ b/arch/arm/include/asm/arch-tegra/pinmux.h @@ -170,6 +170,16 @@ void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io); void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config, int len); +struct pmux_pingrp_desc { + u8 funcs[4]; +#if defined(CONFIG_TEGRA20) + u8 ctl_id; + u8 pull_id; +#endif /* CONFIG_TEGRA20 */ +}; + +extern const struct pmux_pingrp_desc *tegra_soc_pingroups; + #ifdef TEGRA_PMX_SOC_HAS_DRVGRPS #define PMUX_SLWF_MIN 0 @@ -219,14 +229,4 @@ void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config, #endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */ -struct pmux_pingrp_desc { - u8 funcs[4]; -#if defined(CONFIG_TEGRA20) - u8 ctl_id; - u8 pull_id; -#endif /* CONFIG_TEGRA20 */ -}; - -extern const struct pmux_pingrp_desc *tegra_soc_pingroups; - #endif /* _TEGRA_PINMUX_H_ */ diff --git a/arch/arm/mach-tegra/pinmux-common.c b/arch/arm/mach-tegra/pinmux-common.c index 912f65e..96dbb5e 100644 --- a/arch/arm/mach-tegra/pinmux-common.c +++ b/arch/arm/mach-tegra/pinmux-common.c @@ -695,4 +695,4 @@ void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config, for (i = 0; i < len; i++) pinmux_config_drvgrp(&config[i]); } -#endif /* TEGRA_PMX_HAS_DRVGRPS */ +#endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */ -- cgit v0.10.2 From 5ee7ec7bafe6d02ebacdde06bb536f55cff4cdd8 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 25 Mar 2015 12:04:36 -0600 Subject: ARM: tegra: pinctrl: add support for MIPI PAD control groups Some pinmux controls are in a different register set. Add support for manipulating those in a similar way to existing pins/groups. Signed-off-by: Stephen Warren Signed-off-by: Tom Warren diff --git a/arch/arm/include/asm/arch-tegra/pinmux.h b/arch/arm/include/asm/arch-tegra/pinmux.h index e3eb706..3cc52dd 100644 --- a/arch/arm/include/asm/arch-tegra/pinmux.h +++ b/arch/arm/include/asm/arch-tegra/pinmux.h @@ -229,4 +229,20 @@ void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config, #endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */ +#ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS +struct pmux_mipipadctrlgrp_config { + u32 grp:16; /* pin group PMUX_MIPIPADCTRLGRP_x */ + u32 func:8; /* function to assign PMUX_FUNC_... */ +}; + +void pinmux_config_mipipadctrlgrp_table( + const struct pmux_mipipadctrlgrp_config *config, int len); + +struct pmux_mipipadctrlgrp_desc { + u8 funcs[2]; +}; + +extern const struct pmux_mipipadctrlgrp_desc *tegra_soc_mipipadctrl_groups; +#endif /* TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS */ + #endif /* _TEGRA_PINMUX_H_ */ diff --git a/arch/arm/mach-tegra/pinmux-common.c b/arch/arm/mach-tegra/pinmux-common.c index 96dbb5e..b4a1432 100644 --- a/arch/arm/mach-tegra/pinmux-common.c +++ b/arch/arm/mach-tegra/pinmux-common.c @@ -108,6 +108,8 @@ #define DRV_REG(group) _R(TEGRA_PMX_SOC_DRV_GROUP_BASE_REG + ((group) * 4)) +#define MIPIPADCTRL_REG(group) _R(TEGRA_PMX_SOC_MIPIPADCTRL_BASE_REG + ((group) * 4)) + /* * We could force arch-tegraNN/pinmux.h to define all of these. However, * that's a lot of defines, and for now it's manageable to just put a @@ -696,3 +698,58 @@ void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config, pinmux_config_drvgrp(&config[i]); } #endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */ + +#ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS + +#define pmux_mipipadctrlgrp_isvalid(pd) (((pd) >= 0) && ((pd) < PMUX_MIPIPADCTRLGRP_COUNT)) + +static void pinmux_mipipadctrl_set_func(enum pmux_mipipadctrlgrp grp, + enum pmux_func func) +{ + u32 *reg = MIPIPADCTRL_REG(grp); + int i, mux = -1; + u32 val; + + if (func == PMUX_FUNC_DEFAULT) + return; + + /* Error check grp and func */ + assert(pmux_mipipadctrlgrp_isvalid(grp)); + assert(pmux_func_isvalid(func)); + + if (func >= PMUX_FUNC_RSVD1) { + mux = (func - PMUX_FUNC_RSVD1) & 1; + } else { + /* Search for the appropriate function */ + for (i = 0; i < 2; i++) { + if (tegra_soc_mipipadctrl_groups[grp].funcs[i] + == func) { + mux = i; + break; + } + } + } + assert(mux != -1); + + val = readl(reg); + val &= ~(1 << 1); + val |= (mux << 1); + writel(val, reg); +} + +static void pinmux_config_mipipadctrlgrp(const struct pmux_mipipadctrlgrp_config *config) +{ + enum pmux_mipipadctrlgrp grp = config->grp; + + pinmux_mipipadctrl_set_func(grp, config->func); +} + +void pinmux_config_mipipadctrlgrp_table( + const struct pmux_mipipadctrlgrp_config *config, int len) +{ + int i; + + for (i = 0; i < len; i++) + pinmux_config_mipipadctrlgrp(&config[i]); +} +#endif /* TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS */ -- cgit v0.10.2 From 89d9437356ce9121f99889c11b55ed28fb8851b2 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 25 Mar 2015 12:04:37 -0600 Subject: ARM: tegra: enable MIPI PAD CTRL support for Tegra124 This allows selection between CSI and DSI_B on the MIPI pads. Signed-off-by: Stephen Warren Signed-off-by: Tom Warren diff --git a/arch/arm/include/asm/arch-tegra124/pinmux.h b/arch/arm/include/asm/arch-tegra124/pinmux.h index 78bc9e6..9fcbb0f 100644 --- a/arch/arm/include/asm/arch-tegra124/pinmux.h +++ b/arch/arm/include/asm/arch-tegra124/pinmux.h @@ -246,6 +246,11 @@ enum pmux_drvgrp { PMUX_DRVGRP_COUNT, }; +enum pmux_mipipadctrlgrp { + PMUX_MIPIPADCTRLGRP_DSI_B, + PMUX_MIPIPADCTRLGRP_COUNT, +}; + enum pmux_func { PMUX_FUNC_DEFAULT, PMUX_FUNC_BLINK, @@ -255,6 +260,7 @@ enum pmux_func { PMUX_FUNC_CLK, PMUX_FUNC_CLK12, PMUX_FUNC_CPU, + PMUX_FUNC_CSI, PMUX_FUNC_DAP, PMUX_FUNC_DAP1, PMUX_FUNC_DAP2, @@ -263,6 +269,7 @@ enum pmux_func { PMUX_FUNC_DISPLAYA_ALT, PMUX_FUNC_DISPLAYB, PMUX_FUNC_DP, + PMUX_FUNC_DSI_B, PMUX_FUNC_DTV, PMUX_FUNC_EXTPERIPH1, PMUX_FUNC_EXTPERIPH2, @@ -336,8 +343,10 @@ enum pmux_func { }; #define TEGRA_PMX_SOC_DRV_GROUP_BASE_REG 0x868 +#define TEGRA_PMX_SOC_MIPIPADCTRL_BASE_REG 0x820 #define TEGRA_PMX_SOC_HAS_IO_CLAMPING #define TEGRA_PMX_SOC_HAS_DRVGRPS +#define TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS #define TEGRA_PMX_GRPS_HAVE_LPMD #define TEGRA_PMX_GRPS_HAVE_SCHMT #define TEGRA_PMX_GRPS_HAVE_HSM diff --git a/arch/arm/mach-tegra/tegra124/pinmux.c b/arch/arm/mach-tegra/tegra124/pinmux.c index c6685ea..4629b46 100644 --- a/arch/arm/mach-tegra/tegra124/pinmux.c +++ b/arch/arm/mach-tegra/tegra124/pinmux.c @@ -304,3 +304,20 @@ static const struct pmux_pingrp_desc tegra124_pingroups[] = { PIN(DP_HPD_PFF0, DP, RSVD2, RSVD3, RSVD4), }; const struct pmux_pingrp_desc *tegra_soc_pingroups = tegra124_pingroups; + +#define MIPIPADCTRL_GRP(grp, f0, f1) \ + { \ + .funcs = { \ + PMUX_FUNC_##f0, \ + PMUX_FUNC_##f1, \ + }, \ + } + +#define MIPIPADCTRL_RESERVED {} + +static const struct pmux_mipipadctrlgrp_desc tegra124_mipipadctrl_groups[] = { + /* pin, f0, f1 */ + /* Offset 0x820 */ + MIPIPADCTRL_GRP(DSI_B, CSI, DSI_B), +}; +const struct pmux_mipipadctrlgrp_desc *tegra_soc_mipipadctrl_groups = tegra124_mipipadctrl_groups; -- cgit v0.10.2 From a101638ece27fe8c4b42c654c047d0eacc92b1a8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 9 Mar 2015 19:12:56 -0600 Subject: tegra: seaboard: Remove unused CONFIG_UART_DISABLE_GPIO This CONFIG is not used, so drop it. Signed-off-by: Simon Glass Tested-by: Stephen Warren Acked-by: Stephen Warren Signed-off-by: Tom Warren diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h index 4442064..78ff651 100644 --- a/include/configs/seaboard.h +++ b/include/configs/seaboard.h @@ -27,9 +27,6 @@ #define CONFIG_TEGRA_ENABLE_UARTD #define CONFIG_SYS_NS16550_COM1 NV_PA_APB_UARTD_BASE -/* On Seaboard: GPIO_PI3 = Port I = 8, bit = 3 */ -#define CONFIG_UART_DISABLE_GPIO GPIO_PI3 - #define CONFIG_MACH_TYPE MACH_TYPE_SEABOARD /* I2C */ -- cgit v0.10.2 From 37220efab846ece7cdfc7a8fba3d8294adc6093d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 9 Mar 2015 19:12:57 -0600 Subject: tegra: seaboard: Correct the gpio_request() call Requesting a GPIO without a name is not supposed anymore. This causes the request to fail. Add a name so that the serial console works on seaboard. Signed-off-by: Simon Glass Reported-by: Stephen Warren Signed-off-by: Tom Warren diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c index 25480e4..2d07001 100644 --- a/board/nvidia/seaboard/seaboard.c +++ b/board/nvidia/seaboard/seaboard.c @@ -20,7 +20,7 @@ void gpio_early_init_uart(void) { /* Enable UART via GPIO_PI3 (port 8, bit 3) so serial console works */ - gpio_request(GPIO_PI3, NULL); + gpio_request(GPIO_PI3, "uart_en"); gpio_direction_output(GPIO_PI3, 0); } #endif -- cgit v0.10.2 From d1db97aaa43d6ae5e1e790e872f79d36d8809660 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Thu, 26 Mar 2015 01:31:53 +0100 Subject: ARM: tegra: get rid of colibri_t20-common As a preparatory step to renaming the board folder as well first get rid of the colibri_t20-common after having integrated it into colibri_t20_iris for now. While at it also migrate to using NVIDIA's common.mk magic. Signed-off-by: Marcel Ziswiler Signed-off-by: Tom Warren diff --git a/board/toradex/colibri_t20-common/colibri_t20-common.c b/board/toradex/colibri_t20-common/colibri_t20-common.c deleted file mode 100644 index 58a9916..0000000 --- a/board/toradex/colibri_t20-common/colibri_t20-common.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2012 Lucas Stach - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include -#include -#include - -#include "colibri_t20-common.h" - -#ifdef CONFIG_USB_EHCI_TEGRA -void colibri_t20_common_pin_mux_usb(void) -{ - /* module internal USB bus to connect ethernet chipset */ - funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI); - /* ULPI reference clock output */ - pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4); - pinmux_tristate_disable(PMUX_PINGRP_CDEV2); - /* PHY reset GPIO */ - pinmux_tristate_disable(PMUX_PINGRP_UAC); - /* VBus GPIO */ - pinmux_tristate_disable(PMUX_PINGRP_DTE); -} -#endif - -#ifdef CONFIG_TEGRA_NAND -void pin_mux_nand(void) -{ - funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT); -} -#endif diff --git a/board/toradex/colibri_t20-common/colibri_t20-common.h b/board/toradex/colibri_t20-common/colibri_t20-common.h deleted file mode 100644 index 1fe53f6..0000000 --- a/board/toradex/colibri_t20-common/colibri_t20-common.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright (C) 2012 Lucas Stach - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -void colibri_t20_common_pin_mux_usb(void); diff --git a/board/toradex/colibri_t20_iris/Makefile b/board/toradex/colibri_t20_iris/Makefile index ebeac70..f286aec 100644 --- a/board/toradex/colibri_t20_iris/Makefile +++ b/board/toradex/colibri_t20_iris/Makefile @@ -4,6 +4,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y := ../../nvidia/common/board.o -obj-y += ../colibri_t20-common/colibri_t20-common.o +include $(srctree)/board/nvidia/common/common.mk + obj-y += colibri_t20_iris.o diff --git a/board/toradex/colibri_t20_iris/colibri_t20_iris.c b/board/toradex/colibri_t20_iris/colibri_t20_iris.c index 49c74f3..4656094 100644 --- a/board/toradex/colibri_t20_iris/colibri_t20_iris.c +++ b/board/toradex/colibri_t20_iris/colibri_t20_iris.c @@ -5,23 +5,11 @@ */ #include -#include #include #include #include #include - -#include "../colibri_t20-common/colibri_t20-common.h" - -#ifdef CONFIG_USB_EHCI_TEGRA -void pin_mux_usb(void) -{ - colibri_t20_common_pin_mux_usb(); - - /* USB 1 aka Tegra USB port 3 VBus*/ - pinmux_tristate_disable(PMUX_PINGRP_SPIG); -} -#endif +#include #ifdef CONFIG_TEGRA_MMC /* @@ -34,3 +22,31 @@ void pin_mux_mmc(void) pinmux_tristate_disable(PMUX_PINGRP_GMB); } #endif + +#ifdef CONFIG_TEGRA_NAND +void pin_mux_nand(void) +{ + funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT); +} +#endif + +#ifdef CONFIG_USB_EHCI_TEGRA +void pin_mux_usb(void) +{ + /* module internal USB bus to connect ethernet chipset */ + funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI); + + /* ULPI reference clock output */ + pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4); + pinmux_tristate_disable(PMUX_PINGRP_CDEV2); + + /* PHY reset GPIO */ + pinmux_tristate_disable(PMUX_PINGRP_UAC); + + /* VBus GPIO */ + pinmux_tristate_disable(PMUX_PINGRP_DTE); + + /* USB 1 aka Tegra USB port 3 VBus */ + pinmux_tristate_disable(PMUX_PINGRP_SPIG); +} +#endif -- cgit v0.10.2 From e57c6e5b50d330516e30f61b824613d551316086 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Thu, 26 Mar 2015 01:31:54 +0100 Subject: ARM: tegra: rename colibri_t20 board/configuration/device-tree In accordance with our other modules supported by U-Boot and as agreed upon for Apalis/Colibri T30 get rid of the carrier board in the board/ configuration/device-tree naming. While at it also bring the prompt more in line with our other products. Signed-off-by: Marcel Ziswiler Signed-off-by: Tom Warren diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index cbe5b86..f897e6d 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -24,7 +24,7 @@ dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \ tegra20-trimslice.dtb \ tegra20-ventana.dtb \ tegra20-whistler.dtb \ - tegra20-colibri_t20_iris.dtb \ + tegra20-colibri.dtb \ tegra30-apalis.dtb \ tegra30-beaver.dtb \ tegra30-cardhu.dtb \ diff --git a/arch/arm/dts/tegra20-colibri.dts b/arch/arm/dts/tegra20-colibri.dts new file mode 100644 index 0000000..3131b92 --- /dev/null +++ b/arch/arm/dts/tegra20-colibri.dts @@ -0,0 +1,49 @@ +/dts-v1/; + +#include "tegra20.dtsi" + +/ { + model = "Toradex Colibri T20"; + compatible = "toradex,t20", "nvidia,tegra20"; + + chosen { + stdout-path = &uarta; + }; + + aliases { + usb0 = "/usb@c5008000"; + usb1 = "/usb@c5000000"; + usb2 = "/usb@c5004000"; + sdhci0 = "/sdhci@c8000600"; + }; + + usb@c5000000 { + dr_mode = "otg"; + }; + + usb@c5004000 { + nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1) GPIO_ACTIVE_HIGH>; + nvidia,vbus-gpio = <&gpio TEGRA_GPIO(BB, 1) GPIO_ACTIVE_HIGH>; + }; + + usb@c5008000 { + nvidia,vbus-gpio = <&gpio TEGRA_GPIO(W, 2) GPIO_ACTIVE_LOW>; + }; + + nand-controller@70008000 { + nvidia,wp-gpios = <&gpio TEGRA_GPIO(S, 0) GPIO_ACTIVE_HIGH>; + nvidia,width = <8>; + nvidia,timing = <15 100 25 80 25 10 15 10 100>; + + nand@0 { + reg = <0>; + compatible = "nand-flash"; + }; + }; + + sdhci@c8000600 { + status = "okay"; + cd-gpios = <&gpio TEGRA_GPIO(C, 7) GPIO_ACTIVE_LOW>; + bus-width = <4>; + }; +}; diff --git a/arch/arm/dts/tegra20-colibri_t20_iris.dts b/arch/arm/dts/tegra20-colibri_t20_iris.dts deleted file mode 100644 index 3131b92..0000000 --- a/arch/arm/dts/tegra20-colibri_t20_iris.dts +++ /dev/null @@ -1,49 +0,0 @@ -/dts-v1/; - -#include "tegra20.dtsi" - -/ { - model = "Toradex Colibri T20"; - compatible = "toradex,t20", "nvidia,tegra20"; - - chosen { - stdout-path = &uarta; - }; - - aliases { - usb0 = "/usb@c5008000"; - usb1 = "/usb@c5000000"; - usb2 = "/usb@c5004000"; - sdhci0 = "/sdhci@c8000600"; - }; - - usb@c5000000 { - dr_mode = "otg"; - }; - - usb@c5004000 { - nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1) GPIO_ACTIVE_HIGH>; - nvidia,vbus-gpio = <&gpio TEGRA_GPIO(BB, 1) GPIO_ACTIVE_HIGH>; - }; - - usb@c5008000 { - nvidia,vbus-gpio = <&gpio TEGRA_GPIO(W, 2) GPIO_ACTIVE_LOW>; - }; - - nand-controller@70008000 { - nvidia,wp-gpios = <&gpio TEGRA_GPIO(S, 0) GPIO_ACTIVE_HIGH>; - nvidia,width = <8>; - nvidia,timing = <15 100 25 80 25 10 15 10 100>; - - nand@0 { - reg = <0>; - compatible = "nand-flash"; - }; - }; - - sdhci@c8000600 { - status = "okay"; - cd-gpios = <&gpio TEGRA_GPIO(C, 7) GPIO_ACTIVE_LOW>; - bus-width = <4>; - }; -}; diff --git a/arch/arm/mach-tegra/tegra20/Kconfig b/arch/arm/mach-tegra/tegra20/Kconfig index a354e2a..7f09f81 100644 --- a/arch/arm/mach-tegra/tegra20/Kconfig +++ b/arch/arm/mach-tegra/tegra20/Kconfig @@ -30,7 +30,7 @@ config TARGET_VENTANA config TARGET_WHISTLER bool "NVIDIA Tegra20 Whistler evaluation board" -config TARGET_COLIBRI_T20_IRIS +config TARGET_COLIBRI_T20 bool "Toradex Colibri T20 board" endchoice @@ -47,6 +47,6 @@ source "board/avionic-design/tec/Kconfig" source "board/compulab/trimslice/Kconfig" source "board/nvidia/ventana/Kconfig" source "board/nvidia/whistler/Kconfig" -source "board/toradex/colibri_t20_iris/Kconfig" +source "board/toradex/colibri_t20/Kconfig" endif diff --git a/board/toradex/colibri_t20/Kconfig b/board/toradex/colibri_t20/Kconfig new file mode 100644 index 0000000..7f373b2 --- /dev/null +++ b/board/toradex/colibri_t20/Kconfig @@ -0,0 +1,12 @@ +if TARGET_COLIBRI_T20 + +config SYS_BOARD + default "colibri_t20" + +config SYS_VENDOR + default "toradex" + +config SYS_CONFIG_NAME + default "colibri_t20" + +endif diff --git a/board/toradex/colibri_t20/MAINTAINERS b/board/toradex/colibri_t20/MAINTAINERS new file mode 100644 index 0000000..b251c00 --- /dev/null +++ b/board/toradex/colibri_t20/MAINTAINERS @@ -0,0 +1,7 @@ +COLIBRI_T20 +M: Lucas Stach +S: Maintained +F: board/toradex/colibri_t20/ +F: include/configs/colibri_t20.h +F: configs/colibri_t20_defconfig +F: arch/arm/dts/tegra20-colibri.dtb diff --git a/board/toradex/colibri_t20/Makefile b/board/toradex/colibri_t20/Makefile new file mode 100644 index 0000000..86f78d9 --- /dev/null +++ b/board/toradex/colibri_t20/Makefile @@ -0,0 +1,9 @@ +# +# (C) Copyright 2012 Lucas Stach +# +# SPDX-License-Identifier: GPL-2.0+ +# + +include $(srctree)/board/nvidia/common/common.mk + +obj-y += colibri_t20.o diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c new file mode 100644 index 0000000..4656094 --- /dev/null +++ b/board/toradex/colibri_t20/colibri_t20.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2012 Lucas Stach + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_TEGRA_MMC +/* + * Routine: pin_mux_mmc + * Description: setup the pin muxes/tristate values for the SDMMC(s) + */ +void pin_mux_mmc(void) +{ + funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT); + pinmux_tristate_disable(PMUX_PINGRP_GMB); +} +#endif + +#ifdef CONFIG_TEGRA_NAND +void pin_mux_nand(void) +{ + funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT); +} +#endif + +#ifdef CONFIG_USB_EHCI_TEGRA +void pin_mux_usb(void) +{ + /* module internal USB bus to connect ethernet chipset */ + funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI); + + /* ULPI reference clock output */ + pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4); + pinmux_tristate_disable(PMUX_PINGRP_CDEV2); + + /* PHY reset GPIO */ + pinmux_tristate_disable(PMUX_PINGRP_UAC); + + /* VBus GPIO */ + pinmux_tristate_disable(PMUX_PINGRP_DTE); + + /* USB 1 aka Tegra USB port 3 VBus */ + pinmux_tristate_disable(PMUX_PINGRP_SPIG); +} +#endif diff --git a/board/toradex/colibri_t20_iris/Kconfig b/board/toradex/colibri_t20_iris/Kconfig deleted file mode 100644 index 4bf7278..0000000 --- a/board/toradex/colibri_t20_iris/Kconfig +++ /dev/null @@ -1,12 +0,0 @@ -if TARGET_COLIBRI_T20_IRIS - -config SYS_BOARD - default "colibri_t20_iris" - -config SYS_VENDOR - default "toradex" - -config SYS_CONFIG_NAME - default "colibri_t20_iris" - -endif diff --git a/board/toradex/colibri_t20_iris/MAINTAINERS b/board/toradex/colibri_t20_iris/MAINTAINERS deleted file mode 100644 index c68955b..0000000 --- a/board/toradex/colibri_t20_iris/MAINTAINERS +++ /dev/null @@ -1,6 +0,0 @@ -COLIBRI_T20_IRIS BOARD -M: Lucas Stach -S: Maintained -F: board/toradex/colibri_t20_iris/ -F: include/configs/colibri_t20_iris.h -F: configs/colibri_t20_iris_defconfig diff --git a/board/toradex/colibri_t20_iris/Makefile b/board/toradex/colibri_t20_iris/Makefile deleted file mode 100644 index f286aec..0000000 --- a/board/toradex/colibri_t20_iris/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# -# (C) Copyright 2012 Lucas Stach -# -# SPDX-License-Identifier: GPL-2.0+ -# - -include $(srctree)/board/nvidia/common/common.mk - -obj-y += colibri_t20_iris.o diff --git a/board/toradex/colibri_t20_iris/colibri_t20_iris.c b/board/toradex/colibri_t20_iris/colibri_t20_iris.c deleted file mode 100644 index 4656094..0000000 --- a/board/toradex/colibri_t20_iris/colibri_t20_iris.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2012 Lucas Stach - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_TEGRA_MMC -/* - * Routine: pin_mux_mmc - * Description: setup the pin muxes/tristate values for the SDMMC(s) - */ -void pin_mux_mmc(void) -{ - funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT); - pinmux_tristate_disable(PMUX_PINGRP_GMB); -} -#endif - -#ifdef CONFIG_TEGRA_NAND -void pin_mux_nand(void) -{ - funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT); -} -#endif - -#ifdef CONFIG_USB_EHCI_TEGRA -void pin_mux_usb(void) -{ - /* module internal USB bus to connect ethernet chipset */ - funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI); - - /* ULPI reference clock output */ - pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4); - pinmux_tristate_disable(PMUX_PINGRP_CDEV2); - - /* PHY reset GPIO */ - pinmux_tristate_disable(PMUX_PINGRP_UAC); - - /* VBus GPIO */ - pinmux_tristate_disable(PMUX_PINGRP_DTE); - - /* USB 1 aka Tegra USB port 3 VBus */ - pinmux_tristate_disable(PMUX_PINGRP_SPIG); -} -#endif diff --git a/configs/colibri_t20_defconfig b/configs/colibri_t20_defconfig new file mode 100644 index 0000000..8987567 --- /dev/null +++ b/configs/colibri_t20_defconfig @@ -0,0 +1,5 @@ +CONFIG_ARM=y +CONFIG_TEGRA=y +CONFIG_TEGRA20=y +CONFIG_TARGET_COLIBRI_T20=y +CONFIG_DEFAULT_DEVICE_TREE="tegra20-colibri" diff --git a/configs/colibri_t20_iris_defconfig b/configs/colibri_t20_iris_defconfig deleted file mode 100644 index a14d55a..0000000 --- a/configs/colibri_t20_iris_defconfig +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_ARM=y -CONFIG_TEGRA=y -CONFIG_TEGRA20=y -CONFIG_TARGET_COLIBRI_T20_IRIS=y -CONFIG_DEFAULT_DEVICE_TREE="tegra20-colibri_t20_iris" diff --git a/include/configs/colibri_t20.h b/include/configs/colibri_t20.h new file mode 100644 index 0000000..e80e9ed --- /dev/null +++ b/include/configs/colibri_t20.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2012 Lucas Stach + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#include "tegra20-common.h" + +/* High-level configuration options */ +#define V_PROMPT "Colibri T20 # " +#define CONFIG_TEGRA_BOARD_STRING "Toradex Colibri T20" + +/* Board-specific serial config */ +#define CONFIG_TEGRA_ENABLE_UARTA +#define CONFIG_TEGRA_UARTA_SDIO1 +#define CONFIG_SYS_NS16550_COM1 NV_PA_APB_UARTA_BASE + +/* SD/MMC support */ +#define CONFIG_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_TEGRA_MMC +#define CONFIG_CMD_MMC + +/* USB host support */ +#define CONFIG_USB_EHCI +#define CONFIG_USB_EHCI_TEGRA +#define CONFIG_USB_ULPI +#define CONFIG_USB_ULPI_VIEWPORT +#define CONFIG_USB_STORAGE +#define CONFIG_USB_MAX_CONTROLLER_COUNT 3 +#define CONFIG_CMD_USB + +/* USB networking support */ +#define CONFIG_USB_HOST_ETHER +#define CONFIG_USB_ETHER_ASIX +#define CONFIG_CMD_NET +#define CONFIG_CMD_DHCP +#define CONFIG_CMD_NFS +#define CONFIG_CMD_PING + +/* NAND support */ +#define CONFIG_CMD_NAND +#define CONFIG_TEGRA_NAND +#define CONFIG_SYS_MAX_NAND_DEVICE 1 + +/* Environment in NAND, 64K is a bit excessive but erase block is 512K anyway */ +#define CONFIG_ENV_IS_IN_NAND +#define CONFIG_ENV_OFFSET (SZ_2M) +#undef CONFIG_ENV_SIZE /* undef size from tegra20-common.h */ +#define CONFIG_ENV_SIZE (SZ_64K) + +/* Debug commands */ +#define CONFIG_CMD_BDI +#define CONFIG_CMD_CACHE + +#include "tegra-common-post.h" + +#endif /* __CONFIG_H */ diff --git a/include/configs/colibri_t20_iris.h b/include/configs/colibri_t20_iris.h deleted file mode 100644 index 4888c94..0000000 --- a/include/configs/colibri_t20_iris.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2012 Lucas Stach - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#include "tegra20-common.h" - -/* High-level configuration options */ -#define V_PROMPT "Tegra20 (Colibri) # " -#define CONFIG_TEGRA_BOARD_STRING "Toradex Colibri T20 on Iris" - -/* Board-specific serial config */ -#define CONFIG_TEGRA_ENABLE_UARTA -#define CONFIG_TEGRA_UARTA_SDIO1 -#define CONFIG_SYS_NS16550_COM1 NV_PA_APB_UARTA_BASE - -/* SD/MMC support */ -#define CONFIG_MMC -#define CONFIG_GENERIC_MMC -#define CONFIG_TEGRA_MMC -#define CONFIG_CMD_MMC - -/* USB host support */ -#define CONFIG_USB_EHCI -#define CONFIG_USB_EHCI_TEGRA -#define CONFIG_USB_ULPI -#define CONFIG_USB_ULPI_VIEWPORT -#define CONFIG_USB_STORAGE -#define CONFIG_USB_MAX_CONTROLLER_COUNT 3 -#define CONFIG_CMD_USB - -/* USB networking support */ -#define CONFIG_USB_HOST_ETHER -#define CONFIG_USB_ETHER_ASIX -#define CONFIG_CMD_NET -#define CONFIG_CMD_DHCP -#define CONFIG_CMD_NFS -#define CONFIG_CMD_PING - -/* NAND support */ -#define CONFIG_CMD_NAND -#define CONFIG_TEGRA_NAND -#define CONFIG_SYS_MAX_NAND_DEVICE 1 - -/* Environment in NAND, 64K is a bit excessive but erase block is 512K anyway */ -#define CONFIG_ENV_IS_IN_NAND -#define CONFIG_ENV_OFFSET (SZ_2M) -#undef CONFIG_ENV_SIZE /* undef size from tegra20-common.h */ -#define CONFIG_ENV_SIZE (SZ_64K) - -/* Debug commands */ -#define CONFIG_CMD_BDI -#define CONFIG_CMD_CACHE - -#include "tegra-common-post.h" - -#endif /* __CONFIG_H */ diff --git a/tools/buildman/README b/tools/buildman/README index cf7bf5c..e870d54 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -613,7 +613,7 @@ $ ./tools/buildman/buildman -b us-mem4 -sSdB run_list_real 1996 2000 +4 do_nandboot 760 756 -4 do_mem_crc 168 68 -100 - colibri_t20_iris: all -9 rodata -29 text +20 + colibri_t20 : all -9 rodata -29 text +20 u-boot: add: 1/0, grow: 2/-3 bytes: 140/-112 (28) function old new delta hash_command 80 160 +80 -- cgit v0.10.2 From 1ed056e84db0ea5c4365a5e0a79dd94ff1bc4b0b Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Thu, 26 Mar 2015 02:16:33 +0100 Subject: ARM: tegra: fix colibri_t20 machine type A while ago I got Russell to change the machine type of our Colibri T20 from COLIBRI_TEGRA2 to COLIBRI_T20 which at least in parts is also reflected in his machine registry: http://www.arm.linux.org.uk/developer/machines/list.php?id=3323 For us it is really very beneficial to actually still be able to boot downstream L4T kernel with its working hardware accelerated graphics/multimedia stack albeit it being proprietary/closed-source. Signed-off-by: Marcel Ziswiler Acked-by: Stephen Warren Signed-off-by: Tom Warren diff --git a/arch/arm/include/asm/mach-types.h b/arch/arm/include/asm/mach-types.h index d4a447b..c424a22 100644 --- a/arch/arm/include/asm/mach-types.h +++ b/arch/arm/include/asm/mach-types.h @@ -936,7 +936,7 @@ extern unsigned int __machine_arch_type; #define MACH_TYPE_CWME9210 3320 #define MACH_TYPE_CWME9210JS 3321 #define MACH_TYPE_PGS_SITARA 3322 -#define MACH_TYPE_COLIBRI_TEGRA2 3323 +#define MACH_TYPE_COLIBRI_T20 3323 #define MACH_TYPE_W21 3324 #define MACH_TYPE_POLYSAT1 3325 #define MACH_TYPE_DATAWAY 3326 @@ -12197,16 +12197,16 @@ extern unsigned int __machine_arch_type; # define machine_is_pgs_v1() (0) #endif -#ifdef CONFIG_MACH_COLIBRI_TEGRA2 +#ifdef CONFIG_MACH_COLIBRI_T20 # ifdef machine_arch_type # undef machine_arch_type # define machine_arch_type __machine_arch_type # else -# define machine_arch_type MACH_TYPE_COLIBRI_TEGRA2 +# define machine_arch_type MACH_TYPE_COLIBRI_T20 # endif -# define machine_is_colibri_tegra2() (machine_arch_type == MACH_TYPE_COLIBRI_TEGRA2) +# define machine_is_colibri_t20() (machine_arch_type == MACH_TYPE_COLIBRI_T20) #else -# define machine_is_colibri_tegra2() (0) +# define machine_is_colibri_t20() (0) #endif #ifdef CONFIG_MACH_W21 -- cgit v0.10.2 From 00a5270bd843f436d2c60d2a8512a302061596f5 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Thu, 26 Mar 2015 02:17:07 +0100 Subject: ARM: tegra: fix colibri_t20 asix reset Fix ASIX USB to Ethernet chip reset. Signed-off-by: Marcel Ziswiler Acked-by: Stephen Warren Signed-off-by: Tom Warren diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c index 4656094..5d8bdec 100644 --- a/board/toradex/colibri_t20/colibri_t20.c +++ b/board/toradex/colibri_t20/colibri_t20.c @@ -46,7 +46,14 @@ void pin_mux_usb(void) /* VBus GPIO */ pinmux_tristate_disable(PMUX_PINGRP_DTE); - /* USB 1 aka Tegra USB port 3 VBus */ + /* Reset ASIX using LAN_RESET */ + gpio_request(GPIO_PV4, "LAN_RESET"); + gpio_direction_output(GPIO_PV4, 0); + pinmux_tristate_disable(PMUX_PINGRP_GPV); + udelay(5); + gpio_set_value(GPIO_PV4, 1); + + /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */ pinmux_tristate_disable(PMUX_PINGRP_SPIG); } #endif -- cgit v0.10.2 From e979a808612f0209ce43eddbb8bf46fe2bdf9fb8 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Thu, 26 Mar 2015 02:17:27 +0100 Subject: ARM: tegra: update colibri_t20 configuration Bring the Colibri T20 configuration in-line with Apalis/Colibri T30. Signed-off-by: Marcel Ziswiler Signed-off-by: Tom Warren diff --git a/include/configs/colibri_t20.h b/include/configs/colibri_t20.h index e80e9ed..c17f245 100644 --- a/include/configs/colibri_t20.h +++ b/include/configs/colibri_t20.h @@ -14,9 +14,12 @@ #define CONFIG_TEGRA_BOARD_STRING "Toradex Colibri T20" /* Board-specific serial config */ +#define CONFIG_SERIAL_MULTI #define CONFIG_TEGRA_ENABLE_UARTA #define CONFIG_TEGRA_UARTA_SDIO1 -#define CONFIG_SYS_NS16550_COM1 NV_PA_APB_UARTA_BASE +#define CONFIG_SYS_NS16550_COM1 NV_PA_APB_UARTA_BASE + +#define CONFIG_MACH_TYPE MACH_TYPE_COLIBRI_T20 /* SD/MMC support */ #define CONFIG_MMC @@ -29,17 +32,17 @@ #define CONFIG_USB_EHCI_TEGRA #define CONFIG_USB_ULPI #define CONFIG_USB_ULPI_VIEWPORT -#define CONFIG_USB_STORAGE #define CONFIG_USB_MAX_CONTROLLER_COUNT 3 +#define CONFIG_USB_STORAGE #define CONFIG_CMD_USB /* USB networking support */ #define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX + +/* General networking support */ #define CONFIG_CMD_NET #define CONFIG_CMD_DHCP -#define CONFIG_CMD_NFS -#define CONFIG_CMD_PING /* NAND support */ #define CONFIG_CMD_NAND @@ -56,6 +59,26 @@ #define CONFIG_CMD_BDI #define CONFIG_CMD_CACHE +/* Miscellaneous commands */ +#define CONFIG_CMD_SETEXPR +#define CONFIG_FAT_WRITE + +/* Increase console I/O buffer size */ +#undef CONFIG_SYS_CBSIZE +#define CONFIG_SYS_CBSIZE 1024 + +/* Increase arguments buffer size */ +#undef CONFIG_SYS_BARGSIZE +#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE + +/* Increase print buffer size */ +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16) + +/* Increase maximum number of arguments */ +#undef CONFIG_SYS_MAXARGS +#define CONFIG_SYS_MAXARGS 32 + +#include "tegra-common-usb-gadget.h" #include "tegra-common-post.h" #endif /* __CONFIG_H */ -- cgit v0.10.2 From 9b219d4dfb1f358fa0dfa03f6e529c82f9299dd2 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Fri, 27 Mar 2015 01:31:44 +0100 Subject: tegra: pinmux: fix FUNCMUX_NDFLASH_KBC_8_BIT Even the 8-bit case needs KBCB configured, as pin D7 is located in this pingroup. Please note that pingroup ATC seems to come out of reset with its config set to NAND so one needs to explicitly configure some other function to this group in order to avoid clashing settings which is outside the scope of this patch. Signed-off-by: Lucas Stach Signed-off-by: Marcel Ziswiler Tested-by: Marcel Ziswiler Signed-off-by: Tom Warren diff --git a/arch/arm/mach-tegra/tegra20/funcmux.c b/arch/arm/mach-tegra/tegra20/funcmux.c index 0df4a07..44a85c5 100644 --- a/arch/arm/mach-tegra/tegra20/funcmux.c +++ b/arch/arm/mach-tegra/tegra20/funcmux.c @@ -252,12 +252,14 @@ int funcmux_select(enum periph_id id, int config) break; case FUNCMUX_NDFLASH_KBC_8_BIT: pinmux_set_func(PMUX_PINGRP_KBCA, PMUX_FUNC_NAND); + pinmux_set_func(PMUX_PINGRP_KBCB, PMUX_FUNC_NAND); pinmux_set_func(PMUX_PINGRP_KBCC, PMUX_FUNC_NAND); pinmux_set_func(PMUX_PINGRP_KBCD, PMUX_FUNC_NAND); pinmux_set_func(PMUX_PINGRP_KBCE, PMUX_FUNC_NAND); pinmux_set_func(PMUX_PINGRP_KBCF, PMUX_FUNC_NAND); pinmux_tristate_disable(PMUX_PINGRP_KBCA); + pinmux_tristate_disable(PMUX_PINGRP_KBCB); pinmux_tristate_disable(PMUX_PINGRP_KBCC); pinmux_tristate_disable(PMUX_PINGRP_KBCD); pinmux_tristate_disable(PMUX_PINGRP_KBCE); -- cgit v0.10.2 From 76a30fedd44428c7108084266389c9b4ba5678c8 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Fri, 27 Mar 2015 01:31:45 +0100 Subject: ARM: tegra: colibri_t20: fix nand pinmux Pingroup ATC seems to come out of reset with config set to NAND, so we need to explicitly configure some other function to this group in order to avoid clashing settings. Signed-off-by: Marcel Ziswiler Signed-off-by: Tom Warren diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c index 5d8bdec..8ae9ccf 100644 --- a/board/toradex/colibri_t20/colibri_t20.c +++ b/board/toradex/colibri_t20/colibri_t20.c @@ -27,6 +27,12 @@ void pin_mux_mmc(void) void pin_mux_nand(void) { funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT); + + /* + * configure pingroup ATC to something unrelated to + * avoid ATC overriding KBC + */ + pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI); } #endif -- cgit v0.10.2 From 5263a02e8b5034dfe962ed2ce9892a617bac8583 Mon Sep 17 00:00:00 2001 From: Luca Ellero Date: Tue, 16 Dec 2014 15:36:14 +0100 Subject: mtd: nand: mxs: fix PIO_WORDs in mxs_nand_read_buf() There is only one pio_word in this DMA transaction so data field must be 1. Signed-off-by: Luca Ellero diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c index 7a064ab..8c6954b 100644 --- a/drivers/mtd/nand/mxs_nand.c +++ b/drivers/mtd/nand/mxs_nand.c @@ -453,7 +453,7 @@ static void mxs_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int length) d->cmd.data = MXS_DMA_DESC_COMMAND_NO_DMAXFER | MXS_DMA_DESC_IRQ | MXS_DMA_DESC_NAND_WAIT_4_READY | MXS_DMA_DESC_DEC_SEM | - MXS_DMA_DESC_WAIT4END | (4 << MXS_DMA_DESC_PIO_WORDS_OFFSET); + MXS_DMA_DESC_WAIT4END | (1 << MXS_DMA_DESC_PIO_WORDS_OFFSET); d->cmd.address = 0; -- cgit v0.10.2 From 88a2cbb2aeb34c7c91f7cd30b59066368063bd07 Mon Sep 17 00:00:00 2001 From: Luca Ellero Date: Tue, 16 Dec 2014 15:36:15 +0100 Subject: mtd: nand: mxs: fix PIO_WORDs in mxs_nand_write_buf() There is only one pio_word in this DMA transaction so data field must be 1. Signed-off-by: Luca Ellero diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c index 8c6954b..2d2b938 100644 --- a/drivers/mtd/nand/mxs_nand.c +++ b/drivers/mtd/nand/mxs_nand.c @@ -510,7 +510,7 @@ static void mxs_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, d->cmd.data = MXS_DMA_DESC_COMMAND_DMA_READ | MXS_DMA_DESC_IRQ | MXS_DMA_DESC_DEC_SEM | MXS_DMA_DESC_WAIT4END | - (4 << MXS_DMA_DESC_PIO_WORDS_OFFSET) | + (1 << MXS_DMA_DESC_PIO_WORDS_OFFSET) | (length << MXS_DMA_DESC_BYTES_OFFSET); d->cmd.address = (dma_addr_t)nand_info->data_buf; -- cgit v0.10.2 From aff092ed13dd1e26f0bed24dddaccf2b91275c89 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 3 Feb 2015 10:11:59 -0600 Subject: nand: Remove unused CONFIG_MTD_NAND_ECC_JFFS2 option This option was removed along with legacy NAND support in be33b046b549ad88c204c209508cd7657232ffbd. Clean up some remnants. Signed-off-by: Peter Tyser diff --git a/doc/README.nand b/doc/README.nand index dee0e00..46d7edd 100644 --- a/doc/README.nand +++ b/doc/README.nand @@ -99,12 +99,6 @@ Configuration Options: CONFIG_CMD_NAND_TORTURE Enables the torture command (see description of this command below). - CONFIG_MTD_NAND_ECC_JFFS2 - Define this if you want the Error Correction Code information in - the out-of-band data to be formatted to match the JFFS2 file system. - CONFIG_MTD_NAND_ECC_YAFFS would be another useful choice for - someone to implement. - CONFIG_SYS_MAX_NAND_DEVICE The maximum number of NAND devices you want to support. @@ -312,12 +306,6 @@ Platform specific options NOTE: ===== -The current NAND implementation is based on what is in recent -Linux kernels. The old legacy implementation has been removed. - -If you have board code which used CONFIG_NAND_LEGACY, you'll need -to convert to the current NAND interface for it to continue to work. - The Disk On Chip driver is currently broken and has been for some time. There is a driver in drivers/mtd/nand, taken from Linux, that works with the current NAND system but has not yet been adapted to the u-boot diff --git a/include/configs/ethernut5.h b/include/configs/ethernut5.h index ce61a16..b79000e 100644 --- a/include/configs/ethernut5.h +++ b/include/configs/ethernut5.h @@ -153,7 +153,6 @@ /* JFFS2 */ #ifdef CONFIG_CMD_JFFS2 -#define CONFIG_MTD_NAND_ECC_JFFS2 #define CONFIG_JFFS2_CMDLINE #define CONFIG_JFFS2_NAND #endif -- cgit v0.10.2 From 800772a1a6530c31509d65d8e9672fe209a35066 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 3 Feb 2015 10:24:05 -0600 Subject: nand: Remove unused read/write structures The use of the nand_write_options and nand_read_options structures were removed in commit dfbf617ff055e4216f78d358b0867c548916d14b. Remove the now-unused structures too. Signed-off-by: Peter Tyser diff --git a/include/nand.h b/include/nand.h index 15e31ab..673597e 100644 --- a/include/nand.h +++ b/include/nand.h @@ -82,34 +82,8 @@ static inline int nand_erase(nand_info_t *info, loff_t off, size_t size) * declarations from nand_util.c ****************************************************************************/ -struct nand_write_options { - u_char *buffer; /* memory block containing image to write */ - ulong length; /* number of bytes to write */ - ulong offset; /* start address in NAND */ - int quiet; /* don't display progress messages */ - int autoplace; /* if true use auto oob layout */ - int forcejffs2; /* force jffs2 oob layout */ - int forceyaffs; /* force yaffs oob layout */ - int noecc; /* write without ecc */ - int writeoob; /* image contains oob data */ - int pad; /* pad to page size */ - int blockalign; /* 1|2|4 set multiple of eraseblocks - * to align to */ -}; - -typedef struct nand_write_options nand_write_options_t; typedef struct mtd_oob_ops mtd_oob_ops_t; -struct nand_read_options { - u_char *buffer; /* memory block in which read image is written*/ - ulong length; /* number of bytes to read */ - ulong offset; /* start address in NAND */ - int quiet; /* don't display progress messages */ - int readoob; /* put oob data in image */ -}; - -typedef struct nand_read_options nand_read_options_t; - struct nand_erase_options { loff_t length; /* number of bytes to erase */ loff_t offset; /* first address in NAND to erase */ -- cgit v0.10.2 From 59b5a2ad83dfefae75011a839e94d4880ff02933 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 3 Feb 2015 11:58:12 -0600 Subject: nand: Add verification functions Add nand_verify() and nand_verify_page_oob(). nand_verify() verifies NAND contents against an arbitrarily sized buffer using ECC while nand_verify_page_oob() verifies a NAND page's contents and OOB. Signed-off-by: Peter Tyser Tested-by: Heiko Schocher Acked-by: Heiko Schocher diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index afdd160..f487756 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -464,6 +464,87 @@ static size_t drop_ffs(const nand_info_t *nand, const u_char *buf, #endif /** + * nand_verify_page_oob: + * + * Verify a page of NAND flash, including the OOB. + * Reads page of NAND and verifies the contents and OOB against the + * values in ops. + * + * @param nand NAND device + * @param ops MTD operations, including data to verify + * @param ofs offset in flash + * @return 0 in case of success + */ +int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs) +{ + int rval; + struct mtd_oob_ops vops; + size_t verlen = nand->writesize + nand->oobsize; + + memcpy(&vops, ops, sizeof(vops)); + + vops.datbuf = malloc(verlen); + + if (!vops.datbuf) + return -ENOMEM; + + vops.oobbuf = vops.datbuf + nand->writesize; + + rval = mtd_read_oob(nand, ofs, &vops); + if (!rval) + rval = memcmp(ops->datbuf, vops.datbuf, vops.len); + if (!rval) + rval = memcmp(ops->oobbuf, vops.oobbuf, vops.ooblen); + + free(vops.datbuf); + + return rval ? -EIO : 0; +} + +/** + * nand_verify: + * + * Verify a region of NAND flash. + * Reads NAND in page-sized chunks and verifies the contents against + * the contents of a buffer. The offset into the NAND must be + * page-aligned, and the function doesn't handle skipping bad blocks. + * + * @param nand NAND device + * @param ofs offset in flash + * @param len buffer length + * @param buf buffer to read from + * @return 0 in case of success + */ +int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf) +{ + int rval = 0; + size_t verofs; + size_t verlen = nand->writesize; + uint8_t *verbuf = malloc(verlen); + + if (!verbuf) + return -ENOMEM; + + /* Read the NAND back in page-size groups to limit malloc size */ + for (verofs = ofs; verofs < ofs + len; + verofs += verlen, buf += verlen) { + verlen = min(nand->writesize, (uint32_t)(ofs + len - verofs)); + rval = nand_read(nand, verofs, &verlen, verbuf); + if (!rval || (rval == -EUCLEAN)) + rval = memcmp(buf, verbuf, verlen); + + if (rval) + break; + } + + free(verbuf); + + return rval ? -EIO : 0; +} + + + +/** * nand_write_skip_bad: * * Write image to NAND flash. @@ -501,7 +582,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, #ifdef CONFIG_CMD_NAND_YAFFS if (flags & WITH_YAFFS_OOB) { - if (flags & ~WITH_YAFFS_OOB) + if (flags & (~WITH_YAFFS_OOB & ~WITH_WR_VERIFY)) return -EINVAL; int pages; @@ -554,6 +635,10 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, if (!need_skip && !(flags & WITH_DROP_FFS)) { rval = nand_write(nand, offset, length, buffer); + + if ((flags & WITH_WR_VERIFY) && !rval) + rval = nand_verify(nand, offset, *length, buffer); + if (rval == 0) return 0; @@ -601,6 +686,11 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, ops.oobbuf = ops.datbuf + pagesize; rval = mtd_write_oob(nand, offset, &ops); + + if ((flags & WITH_WR_VERIFY) && !rval) + rval = nand_verify_page_oob(nand, + &ops, offset); + if (rval != 0) break; @@ -620,6 +710,11 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, rval = nand_write(nand, offset, &truncated_write_size, p_buffer); + + if ((flags & WITH_WR_VERIFY) && !rval) + rval = nand_verify(nand, offset, + truncated_write_size, p_buffer); + offset += write_size; p_buffer += write_size; } diff --git a/include/nand.h b/include/nand.h index 673597e..8ea4d5d 100644 --- a/include/nand.h +++ b/include/nand.h @@ -108,11 +108,15 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, * is a 'mode' meaning it cannot be mixed with * other flags */ #define WITH_DROP_FFS (1 << 1) /* drop trailing all-0xff pages */ +#define WITH_WR_VERIFY (1 << 2) /* verify data was written correctly */ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, size_t *actual, loff_t lim, u_char *buffer, int flags); int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts); int nand_torture(nand_info_t *nand, loff_t offset); +int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, + loff_t ofs); +int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf); #define NAND_LOCK_STATUS_TIGHT 0x01 #define NAND_LOCK_STATUS_UNLOCK 0x04 -- cgit v0.10.2 From 6b94f118a213583ada80bab25fedacc08562392d Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 3 Feb 2015 11:58:13 -0600 Subject: cmd_nand: Verify writes to NAND Previously NAND writes were only verified when CONFIG_MTD_NAND_VERIFY_WRITE was defined. On boards without this define writes could fail silently. Boards with CONFIG_MTD_NAND_VERIFY_WRITE could prematurely report failures which ECC could correct. Add a verification step after all "nand write[.x]" commands to ensure the writes were successful. The verification uses ECC for for "normal" writes, but does not for raw and yaffs writes. Some test cases which inject fake bad bits on a 2K page flash are below. Test cases with CONFIG_MTD_NAND_VERIFY_WRITE defined: Example of an ECC write which previously failed when CONFIG_MTD_NAND_VERIFY_WRITE was defined, but now succeeds because ECC is used during verification: nand erase 0 0x10000 dhcp /somefile mw.b 0x10000 0xff 0x2000 mw.b 0x10020 0xfe 1 nand write.raw 0x10000 0x800 1 mw.b 0x1000020 0x01 1 nand write 0x1000000 0x800 0x1800 Test cases without CONFIG_MTD_NAND_VERIFY_WRITE defined: Example of an ECC write which previously silently failed: nand erase 0 0x10000 dhcp /somefile mw.b 0x10000 0xff 0x2000 mw.b 0x10020 0x00 1 nand write.raw 0x10000 0x800 1 mw.b 0x1000020 0xff 1 nand write 0x1000000 0x800 0x1800 Example of a raw write which previously failed silently due to stuck data bit, but now errors out: nand erase 0 0x10000 dhcp /somefile mw.b 0x10000 0xff 0x2000 mw.b 0x10020 0xfe 1 nand write.raw 0x10000 0x800 1 mw.b 0x1000020 0x01 1 nand write.raw 0x1000000 0x800 3 Example of a raw write which previously failed silently due to stuck OOB bit, but now errors out: nand erase 0 0x10000 dhcp /somefile mw.b 0x10000 0xff 0x2000 mw.b 0x10810 0xfe 1 nand write.raw 0x10000 0x800 1 mw.b 0x1000810 0x01 1 nand write.raw 0x1000000 0x800 3 Signed-off-by: Peter Tyser Tested-by: Heiko Schocher Acked-by: Heiko Schocher diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 7f962dc..bada28c 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -419,10 +419,13 @@ static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count, .mode = MTD_OPS_RAW }; - if (read) + if (read) { ret = mtd_read_oob(nand, off, &ops); - else + } else { ret = mtd_write_oob(nand, off, &ops); + if (!ret) + ret = nand_verify_page_oob(nand, &ops, off); + } if (ret) { printf("%s: error at offset %llx, ret %d\n", @@ -690,7 +693,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) else ret = nand_write_skip_bad(nand, off, &rwsize, NULL, maxsize, - (u_char *)addr, 0); + (u_char *)addr, + WITH_WR_VERIFY); #ifdef CONFIG_CMD_NAND_TRIMFFS } else if (!strcmp(s, ".trimffs")) { if (read) { @@ -699,7 +703,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } ret = nand_write_skip_bad(nand, off, &rwsize, NULL, maxsize, (u_char *)addr, - WITH_DROP_FFS); + WITH_DROP_FFS | WITH_WR_VERIFY); #endif #ifdef CONFIG_CMD_NAND_YAFFS } else if (!strcmp(s, ".yaffs")) { @@ -709,7 +713,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } ret = nand_write_skip_bad(nand, off, &rwsize, NULL, maxsize, (u_char *)addr, - WITH_YAFFS_OOB); + WITH_YAFFS_OOB | WITH_WR_VERIFY); #endif } else if (!strcmp(s, ".oob")) { /* out-of-band data */ -- cgit v0.10.2 From 9ac71f112eb3cffc42e012fcdf5009e5b3b01a1d Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 3 Feb 2015 11:58:14 -0600 Subject: dfu: nand: Verify writes Previously NAND writes were not verified and could fail silently. Add a verification step after all writes to NAND. Signed-off-by: Peter Tyser Reviewed-by: Lukasz Majewski Tested-by: Heiko Schocher Acked-by: Heiko Schocher diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c index f9ee189..a975492 100644 --- a/drivers/dfu/dfu_nand.c +++ b/drivers/dfu/dfu_nand.c @@ -64,7 +64,7 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu, return ret; /* then write */ ret = nand_write_skip_bad(nand, start, &count, &actual, - lim, buf, 0); + lim, buf, WITH_WR_VERIFY); } if (ret != 0) { -- cgit v0.10.2 From 073adf987e8251ad934fcac4fd1bf20d4f34f96e Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 3 Feb 2015 11:58:15 -0600 Subject: nand: Remove CONFIG_MTD_NAND_VERIFY_WRITE The CONFIG_MTD_NAND_VERIFY_WRITE has been removed from Linux for some time and a more generic method of NAND verification now exists in U-Boot. Signed-off-by: Peter Tyser Tested-by: Heiko Schocher Acked-by: Heiko Schocher diff --git a/README b/README index 5d57eb9..b7c2a17 100644 --- a/README +++ b/README @@ -3483,9 +3483,6 @@ FIT uImage format: Adds the MTD partitioning infrastructure from the Linux kernel. Needed for UBI support. - CONFIG_MTD_NAND_VERIFY_WRITE - verify if the written data is correct reread. - - UBI support CONFIG_CMD_UBI diff --git a/board/prodrive/alpr/nand.c b/board/prodrive/alpr/nand.c index 5427de5..ca40cea 100644 --- a/board/prodrive/alpr/nand.c +++ b/board/prodrive/alpr/nand.c @@ -93,19 +93,6 @@ static void alpr_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) } } -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -static int alpr_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) -{ - int i; - - for (i = 0; i < len; i++) - if (buf[i] != readb(&(alpr_ndfc->data))) - return i; - - return 0; -} -#endif - static int alpr_nand_dev_ready(struct mtd_info *mtd) { /* @@ -130,9 +117,6 @@ int board_nand_init(struct nand_chip *nand) nand->read_byte = alpr_nand_read_byte; nand->write_buf = alpr_nand_write_buf; nand->read_buf = alpr_nand_read_buf; -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - nand->verify_buf = alpr_nand_verify_buf; -#endif nand->dev_ready = alpr_nand_dev_ready; return 0; diff --git a/board/socrates/nand.c b/board/socrates/nand.c index 7394478..15e6ea6 100644 --- a/board/socrates/nand.c +++ b/board/socrates/nand.c @@ -18,9 +18,6 @@ static void sc_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len); static u_char sc_nand_read_byte(struct mtd_info *mtd); static u16 sc_nand_read_word(struct mtd_info *mtd); static void sc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -static int sc_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); -#endif static int sc_nand_device_ready(struct mtd_info *mtdinfo); #define FPGA_NAND_CMD_MASK (0x7 << 28) @@ -102,25 +99,6 @@ static void sc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) } } -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -/** - * sc_nand_verify_buf - Verify chip data against buffer - * @mtd: MTD device structure - * @buf: buffer containing the data to compare - * @len: number of bytes to compare - */ -static int sc_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) -{ - int i; - - for (i = 0; i < len; i++) { - if (buf[i] != sc_nand_read_byte(mtd)); - return -EFAULT; - } - return 0; -} -#endif - /** * sc_nand_device_ready - Check the NAND device is ready for next command. * @mtd: MTD device structure @@ -178,9 +156,6 @@ int board_nand_init(struct nand_chip *nand) nand->read_word = sc_nand_read_word; nand->write_buf = sc_nand_write_buf; nand->read_buf = sc_nand_read_buf; -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - nand->verify_buf = sc_nand_verify_buf; -#endif return 0; } diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c index 41689b5..a397074 100644 --- a/drivers/mtd/nand/davinci_nand.c +++ b/drivers/mtd/nand/davinci_nand.c @@ -405,18 +405,6 @@ static int nand_davinci_write_page(struct mtd_info *mtd, struct nand_chip *chip, goto err; } -#ifdef CONFIG_MTD_NAND_VERIFY_WRITE - /* Send command to read back the data */ - chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); - - if (chip->verify_buf(mtd, buf, mtd->writesize)) { - ret = -EIO; - goto err; - } - - /* Make sure the next page prog is preceded by a status read */ - chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); -#endif err: /* restore ECC layout */ if (page < CONFIG_KEYSTONE_NAND_MAX_RBL_PAGE) { diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c index 3372b64..e85832d 100644 --- a/drivers/mtd/nand/fsl_elbc_nand.c +++ b/drivers/mtd/nand/fsl_elbc_nand.c @@ -561,41 +561,6 @@ static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len) len, avail); } -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -/* - * Verify buffer against the FCM Controller Data Buffer - */ -static int fsl_elbc_verify_buf(struct mtd_info *mtd, - const u_char *buf, int len) -{ - struct nand_chip *chip = mtd->priv; - struct fsl_elbc_mtd *priv = chip->priv; - struct fsl_elbc_ctrl *ctrl = priv->ctrl; - int i; - - if (len < 0) { - printf("write_buf of %d bytes", len); - return -EINVAL; - } - - if ((unsigned int)len > ctrl->read_bytes - ctrl->index) { - printf("verify_buf beyond end of buffer " - "(%d requested, %u available)\n", - len, ctrl->read_bytes - ctrl->index); - - ctrl->index = ctrl->read_bytes; - return -EINVAL; - } - - for (i = 0; i < len; i++) - if (in_8(&ctrl->addr[ctrl->index + i]) != buf[i]) - break; - - ctrl->index += len; - return i == len && ctrl->status == LTESR_CC ? 0 : -EIO; -} -#endif - /* This function is called after Program and Erase Operations to * check for success or failure. */ @@ -727,9 +692,6 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr) nand->read_byte = fsl_elbc_read_byte; nand->write_buf = fsl_elbc_write_buf; nand->read_buf = fsl_elbc_read_buf; -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - nand->verify_buf = fsl_elbc_verify_buf; -#endif nand->select_chip = fsl_elbc_select_chip; nand->cmdfunc = fsl_elbc_cmdfunc; nand->waitfunc = fsl_elbc_wait; diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index b283eae..7903eeb 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -683,41 +683,6 @@ static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len) __func__, len, avail); } -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -/* - * Verify buffer against the IFC Controller Data Buffer - */ -static int fsl_ifc_verify_buf(struct mtd_info *mtd, - const u_char *buf, int len) -{ - struct nand_chip *chip = mtd->priv; - struct fsl_ifc_mtd *priv = chip->priv; - struct fsl_ifc_ctrl *ctrl = priv->ctrl; - int i; - - if (len < 0) { - printf("%s of %d bytes", __func__, len); - return -EINVAL; - } - - if ((unsigned int)len > ctrl->read_bytes - ctrl->index) { - printf("%s beyond end of buffer " - "(%d requested, %u available)\n", - __func__, len, ctrl->read_bytes - ctrl->index); - - ctrl->index = ctrl->read_bytes; - return -EINVAL; - } - - for (i = 0; i < len; i++) - if (in_8(&ctrl->addr[ctrl->index + i]) != buf[i]) - break; - - ctrl->index += len; - return i == len && ctrl->status == IFC_NAND_EVTER_STAT_OPC ? 0 : -EIO; -} -#endif - /* This function is called after Program and Erase Operations to * check for success or failure. */ @@ -940,9 +905,6 @@ static int fsl_ifc_chip_init(int devnum, u8 *addr) nand->write_buf = fsl_ifc_write_buf; nand->read_buf = fsl_ifc_read_buf; -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - nand->verify_buf = fsl_ifc_verify_buf; -#endif nand->select_chip = fsl_ifc_select_chip; nand->cmdfunc = fsl_ifc_cmdfunc; nand->waitfunc = fsl_ifc_wait; diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c index 65ce98a..5426c32 100644 --- a/drivers/mtd/nand/fsl_upm.c +++ b/drivers/mtd/nand/fsl_upm.c @@ -153,21 +153,6 @@ static void upm_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) buf[i] = in_8(chip->IO_ADDR_R); } -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -static int upm_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) -{ - int i; - struct nand_chip *chip = mtd->priv; - - for (i = 0; i < len; i++) { - if (buf[i] != in_8(chip->IO_ADDR_R)) - return -EFAULT; - } - - return 0; -} -#endif - static int nand_dev_ready(struct mtd_info *mtd) { struct nand_chip *chip = mtd->priv; @@ -193,9 +178,6 @@ int fsl_upm_nand_init(struct nand_chip *chip, struct fsl_upm_nand *fun) chip->read_byte = upm_nand_read_byte; chip->read_buf = upm_nand_read_buf; chip->write_buf = upm_nand_write_buf; -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - chip->verify_buf = upm_nand_verify_buf; -#endif if (fun->dev_ready) chip->dev_ready = nand_dev_ready; diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c index 7233bfc..e621c36 100644 --- a/drivers/mtd/nand/mpc5121_nfc.c +++ b/drivers/mtd/nand/mpc5121_nfc.c @@ -459,29 +459,6 @@ static void mpc5121_nfc_write_buf(struct mtd_info *mtd, mpc5121_nfc_buf_copy(mtd, (u_char *) buf, len, 1); } -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -/* Compare buffer with NAND flash */ -static int mpc5121_nfc_verify_buf(struct mtd_info *mtd, - const u_char * buf, int len) -{ - u_char tmp[256]; - uint bsize; - - while (len) { - bsize = min(len, 256); - mpc5121_nfc_read_buf(mtd, tmp, bsize); - - if (memcmp(buf, tmp, bsize)) - return 1; - - buf += bsize; - len -= bsize; - } - - return 0; -} -#endif - /* Read byte from NFC buffers */ static u8 mpc5121_nfc_read_byte(struct mtd_info *mtd) { @@ -609,9 +586,6 @@ int board_nand_init(struct nand_chip *chip) chip->read_word = mpc5121_nfc_read_word; chip->read_buf = mpc5121_nfc_read_buf; chip->write_buf = mpc5121_nfc_write_buf; -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - chip->verify_buf = mpc5121_nfc_verify_buf; -#endif chip->select_chip = mpc5121_nfc_select_chip; chip->bbt_options = NAND_BBT_USE_FLASH; chip->ecc.mode = NAND_ECC_SOFT; diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 2e5b5b9..f12b07e 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -949,34 +949,6 @@ static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) host->col_addr = col; } -#ifdef __UBOOT__ -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -/* - * Used by the upper layer to verify the data in NAND Flash - * with the data in the buf. - */ -static int mxc_nand_verify_buf(struct mtd_info *mtd, - const u_char *buf, int len) -{ - u_char tmp[256]; - uint bsize; - - while (len) { - bsize = min(len, 256); - mxc_nand_read_buf(mtd, tmp, bsize); - - if (memcmp(buf, tmp, bsize)) - return 1; - - buf += bsize; - len -= bsize; - } - - return 0; -} -#endif -#endif - /* * This function is used by upper layer for select and * deselect of the NAND chip @@ -1207,11 +1179,6 @@ int board_nand_init(struct nand_chip *this) this->read_word = mxc_nand_read_word; this->write_buf = mxc_nand_write_buf; this->read_buf = mxc_nand_read_buf; -#ifdef __UBOOT__ -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - this->verify_buf = mxc_nand_verify_buf; -#endif -#endif host->regs = (struct mxc_nand_regs __iomem *)CONFIG_MXC_NAND_REGS_BASE; #ifdef MXC_NFC_V3_2 diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 6db6566..c0e381a 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -361,51 +361,6 @@ void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) ioread8_rep(chip->IO_ADDR_R, buf, len); } -#ifdef __UBOOT__ -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -/** - * nand_verify_buf - [DEFAULT] Verify chip data against buffer - * @mtd: MTD device structure - * @buf: buffer containing the data to compare - * @len: number of bytes to compare - * - * Default verify function for 8bit buswidth. - */ -static int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len) -{ - int i; - struct nand_chip *chip = mtd->priv; - - for (i = 0; i < len; i++) - if (buf[i] != readb(chip->IO_ADDR_R)) - return -EFAULT; - return 0; -} - -/** - * nand_verify_buf16 - [DEFAULT] Verify chip data against buffer - * @mtd: MTD device structure - * @buf: buffer containing the data to compare - * @len: number of bytes to compare - * - * Default verify function for 16bit buswidth. - */ -static int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) -{ - int i; - struct nand_chip *chip = mtd->priv; - u16 *p = (u16 *) buf; - len >>= 1; - - for (i = 0; i < len; i++) - if (p[i] != readw(chip->IO_ADDR_R)) - return -EFAULT; - - return 0; -} -#endif -#endif - /** * nand_write_buf16 - [DEFAULT] write buffer to chip * @mtd: MTD device structure @@ -2435,20 +2390,6 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, status = chip->waitfunc(mtd, chip); } - -#ifdef __UBOOT__ -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - /* Send command to read back the data */ - chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); - - if (chip->verify_buf(mtd, buf, mtd->writesize)) - return -EIO; - - /* Make sure the next page prog is preceded by a status read */ - chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); -#endif -#endif - return 0; } @@ -3139,12 +3080,6 @@ static void nand_set_defaults(struct nand_chip *chip, int busw) chip->read_buf = busw ? nand_read_buf16 : nand_read_buf; if (!chip->scan_bbt) chip->scan_bbt = nand_default_bbt; -#ifdef __UBOOT__ -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - if (!chip->verify_buf) - chip->verify_buf = busw ? nand_verify_buf16 : nand_verify_buf; -#endif -#endif if (!chip->controller) { chip->controller = &chip->hwcontrol; diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c index 2659595..8a68cb0 100644 --- a/drivers/mtd/nand/ndfc.c +++ b/drivers/mtd/nand/ndfc.c @@ -118,21 +118,6 @@ static void ndfc_write_buf(struct mtd_info *mtdinfo, const uint8_t *buf, int len out_be32((u32 *)(base + NDFC_DATA), *p++); } -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) -static int ndfc_verify_buf(struct mtd_info *mtdinfo, const uint8_t *buf, int len) -{ - struct nand_chip *this = mtdinfo->priv; - ulong base = (ulong) this->IO_ADDR_W & 0xffffff00; - uint32_t *p = (uint32_t *) buf; - - for (; len > 0; len -= 4) - if (*p++ != in_be32((u32 *)(base + NDFC_DATA))) - return -1; - - return 0; -} -#endif - /* * Read a byte from the NDFC. */ @@ -207,9 +192,6 @@ int board_nand_init(struct nand_chip *nand) #endif nand->write_buf = ndfc_write_buf; -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - nand->verify_buf = ndfc_verify_buf; -#endif nand->read_byte = ndfc_read_byte; chip++; diff --git a/include/configs/B4860QDS.h b/include/configs/B4860QDS.h index 838a0b1..dca1ca5 100644 --- a/include/configs/B4860QDS.h +++ b/include/configs/B4860QDS.h @@ -391,7 +391,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/BSC9131RDB.h b/include/configs/BSC9131RDB.h index 6aaaaa4..047ed8b 100644 --- a/include/configs/BSC9131RDB.h +++ b/include/configs/BSC9131RDB.h @@ -198,7 +198,6 @@ extern unsigned long get_sdram_size(void); #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/BSC9132QDS.h b/include/configs/BSC9132QDS.h index 59a8d1b..ceee0e4 100644 --- a/include/configs/BSC9132QDS.h +++ b/include/configs/BSC9132QDS.h @@ -320,7 +320,6 @@ combinations. this should be removed later /* NAND */ #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/C29XPCIE.h b/include/configs/C29XPCIE.h index e24b923..7c45c36 100644 --- a/include/configs/C29XPCIE.h +++ b/include/configs/C29XPCIE.h @@ -234,7 +234,6 @@ #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (1024 * 1024) diff --git a/include/configs/MPC8313ERDB.h b/include/configs/MPC8313ERDB.h index d9a19c3..9cea76a 100644 --- a/include/configs/MPC8313ERDB.h +++ b/include/configs/MPC8313ERDB.h @@ -272,7 +272,6 @@ "mtdparts=e2800000.flash:512k(uboot),128k(env),3m@1m(kernel),-(fs)" #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND 1 #define CONFIG_NAND_FSL_ELBC 1 #define CONFIG_SYS_NAND_BLOCK_SIZE 16384 diff --git a/include/configs/MPC8315ERDB.h b/include/configs/MPC8315ERDB.h index 1384f36..fbf38c8 100644 --- a/include/configs/MPC8315ERDB.h +++ b/include/configs/MPC8315ERDB.h @@ -245,7 +245,6 @@ "mtdparts=e0600000.flash:512k(uboot),128k(env),3m@1m(kernel),-(fs)" #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE 1 #define CONFIG_CMD_NAND 1 #define CONFIG_NAND_FSL_ELBC 1 #define CONFIG_SYS_NAND_BLOCK_SIZE 16384 diff --git a/include/configs/MPC837XEMDS.h b/include/configs/MPC837XEMDS.h index 85f5c40..521904d 100644 --- a/include/configs/MPC837XEMDS.h +++ b/include/configs/MPC837XEMDS.h @@ -283,7 +283,6 @@ * NAND Flash on the Local Bus */ #define CONFIG_CMD_NAND 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE 1 #define CONFIG_SYS_MAX_NAND_DEVICE 1 #define CONFIG_NAND_FSL_ELBC 1 diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h index 2722164..dc09b1f 100644 --- a/include/configs/MPC8536DS.h +++ b/include/configs/MPC8536DS.h @@ -308,7 +308,6 @@ CONFIG_SYS_NAND_BASE + 0x80000, \ CONFIG_SYS_NAND_BASE + 0xC0000} #define CONFIG_SYS_MAX_NAND_DEVICE 4 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND 1 #define CONFIG_NAND_FSL_ELBC 1 #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/MPC8569MDS.h b/include/configs/MPC8569MDS.h index 4da247c..e624c71 100644 --- a/include/configs/MPC8569MDS.h +++ b/include/configs/MPC8569MDS.h @@ -194,7 +194,6 @@ extern unsigned long get_clock_freq(void); #define CONFIG_SYS_NAND_BASE_PHYS CONFIG_SYS_NAND_BASE #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE, } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE 1 #define CONFIG_CMD_NAND 1 #define CONFIG_NAND_FSL_ELBC 1 #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h index 0b07876..5e7bc49 100644 --- a/include/configs/MPC8572DS.h +++ b/include/configs/MPC8572DS.h @@ -303,7 +303,6 @@ CONFIG_SYS_NAND_BASE + 0x80000,\ CONFIG_SYS_NAND_BASE + 0xC0000} #define CONFIG_SYS_MAX_NAND_DEVICE 4 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND 1 #define CONFIG_NAND_FSL_ELBC 1 #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h index cd6a39c..ccf3ce3 100644 --- a/include/configs/P1010RDB.h +++ b/include/configs/P1010RDB.h @@ -444,7 +444,6 @@ extern unsigned long get_sdram_size(void); #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #if defined(CONFIG_P1010RDB_PA) diff --git a/include/configs/P1022DS.h b/include/configs/P1022DS.h index 4371110..795e3b5 100644 --- a/include/configs/P1022DS.h +++ b/include/configs/P1022DS.h @@ -290,7 +290,6 @@ #define CONFIG_SYS_NAND_BASE_LIST {CONFIG_SYS_NAND_BASE} #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND 1 #define CONFIG_SYS_NAND_BLOCK_SIZE (256 * 1024) #define CONFIG_ELBC_NAND_SPL_STATIC_PGSIZE diff --git a/include/configs/P1023RDB.h b/include/configs/P1023RDB.h index a8b7817..d65c461 100644 --- a/include/configs/P1023RDB.h +++ b/include/configs/P1023RDB.h @@ -136,7 +136,6 @@ extern unsigned long get_clock_freq(void); #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_NAND_FSL_ELBC #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/P2041RDB.h b/include/configs/P2041RDB.h index d8d30bb..f99da65 100644 --- a/include/configs/P2041RDB.h +++ b/include/configs/P2041RDB.h @@ -251,7 +251,6 @@ unsigned long get_board_sys_clk(unsigned long dummy); #define CONFIG_SYS_NAND_BASE_LIST {CONFIG_SYS_NAND_BASE} #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/T102xQDS.h b/include/configs/T102xQDS.h index 3f02ced..2927043 100644 --- a/include/configs/T102xQDS.h +++ b/include/configs/T102xQDS.h @@ -398,7 +398,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_DDR_LAW 11 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/T102xRDB.h b/include/configs/T102xRDB.h index bd40d6a..84e8336 100644 --- a/include/configs/T102xRDB.h +++ b/include/configs/T102xRDB.h @@ -379,7 +379,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_DDR_LAW 11 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (512 * 1024) diff --git a/include/configs/T1040QDS.h b/include/configs/T1040QDS.h index 92f5f56..faf8c9d 100644 --- a/include/configs/T1040QDS.h +++ b/include/configs/T1040QDS.h @@ -308,7 +308,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_DDR_LAW 11 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index 5263318..6cc95ef 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -341,7 +341,6 @@ #define CONFIG_SYS_NAND_DDR_LAW 11 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (512 * 1024) diff --git a/include/configs/T208xQDS.h b/include/configs/T208xQDS.h index ff6d2c1..046aa48 100644 --- a/include/configs/T208xQDS.h +++ b/include/configs/T208xQDS.h @@ -357,7 +357,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_DDR_LAW 11 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/T208xRDB.h b/include/configs/T208xRDB.h index db6b42e..faaf22c 100644 --- a/include/configs/T208xRDB.h +++ b/include/configs/T208xRDB.h @@ -328,7 +328,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_DDR_LAW 11 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (512 * 1024) diff --git a/include/configs/T4240QDS.h b/include/configs/T4240QDS.h index dd7d52f..cfe6557 100644 --- a/include/configs/T4240QDS.h +++ b/include/configs/T4240QDS.h @@ -281,7 +281,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/T4240RDB.h b/include/configs/T4240RDB.h index b644a6c..c1ad35a 100644 --- a/include/configs/T4240RDB.h +++ b/include/configs/T4240RDB.h @@ -467,7 +467,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_DDR_LAW 11 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (512 * 1024) diff --git a/include/configs/corenet_ds.h b/include/configs/corenet_ds.h index 225ffdd..8e27ae4 100644 --- a/include/configs/corenet_ds.h +++ b/include/configs/corenet_ds.h @@ -248,7 +248,6 @@ #define CONFIG_SYS_NAND_BASE_LIST {CONFIG_SYS_NAND_BASE} #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/ids8313.h b/include/configs/ids8313.h index 2384864..c1ca56c 100644 --- a/include/configs/ids8313.h +++ b/include/configs/ids8313.h @@ -214,7 +214,6 @@ #define CONFIG_SYS_NAND_BASE 0xE1000000 #define CONFIG_SYS_MAX_NAND_DEVICE 1 #define CONFIG_SYS_NAND_MAX_CHIPS 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_NAND_FSL_ELBC #define CONFIG_SYS_NAND_PAGE_SIZE (2048) #define CONFIG_SYS_NAND_BLOCK_SIZE (128 << 10) diff --git a/include/configs/km/kmp204x-common.h b/include/configs/km/kmp204x-common.h index 949b3da..b70b5b1 100644 --- a/include/configs/km/kmp204x-common.h +++ b/include/configs/km/kmp204x-common.h @@ -167,7 +167,6 @@ unsigned long get_board_sys_clk(unsigned long dummy); #define CONFIG_SYS_NAND_BASE_LIST {CONFIG_SYS_NAND_BASE} #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/ls1021aqds.h b/include/configs/ls1021aqds.h index 3dc4da3..5de416d 100644 --- a/include/configs/ls1021aqds.h +++ b/include/configs/ls1021aqds.h @@ -251,7 +251,6 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/ls2085a_common.h b/include/configs/ls2085a_common.h index f80efed..e0435cc 100644 --- a/include/configs/ls2085a_common.h +++ b/include/configs/ls2085a_common.h @@ -191,7 +191,6 @@ #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h index 5f27c2a..a5f9717 100644 --- a/include/configs/p1_p2_rdb_pc.h +++ b/include/configs/p1_p2_rdb_pc.h @@ -494,7 +494,6 @@ #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE } #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND #if defined(CONFIG_P1020RDB_PD) #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) diff --git a/include/configs/ve8313.h b/include/configs/ve8313.h index bce94b3..107f01a 100644 --- a/include/configs/ve8313.h +++ b/include/configs/ve8313.h @@ -186,7 +186,6 @@ */ #define CONFIG_SYS_NAND_BASE 0x61000000 #define CONFIG_SYS_MAX_NAND_DEVICE 1 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_CMD_NAND 1 #define CONFIG_NAND_FSL_ELBC 1 #define CONFIG_SYS_NAND_BLOCK_SIZE 16384 diff --git a/include/configs/xpedite537x.h b/include/configs/xpedite537x.h index d6b6143..988a2e8 100644 --- a/include/configs/xpedite537x.h +++ b/include/configs/xpedite537x.h @@ -131,7 +131,6 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy); #define CONFIG_SYS_NAND_BASE_LIST {CONFIG_SYS_NAND_BASE, \ CONFIG_SYS_NAND_BASE2} #define CONFIG_SYS_MAX_NAND_DEVICE 2 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_SYS_NAND_QUIET_TEST /* 2nd NAND flash not always populated */ #define CONFIG_NAND_FSL_ELBC diff --git a/include/configs/xpedite550x.h b/include/configs/xpedite550x.h index 4536b94..ac3f4f1 100644 --- a/include/configs/xpedite550x.h +++ b/include/configs/xpedite550x.h @@ -122,7 +122,6 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy); #define CONFIG_SYS_NAND_BASE_LIST {CONFIG_SYS_NAND_BASE, \ CONFIG_SYS_NAND_BASE2} #define CONFIG_SYS_MAX_NAND_DEVICE 2 -#define CONFIG_MTD_NAND_VERIFY_WRITE #define CONFIG_SYS_NAND_QUIET_TEST /* 2nd NAND flash not always populated */ #define CONFIG_NAND_FSL_ELBC diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 8438490..bc927ec 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -678,11 +678,6 @@ struct nand_chip { void (*write_byte)(struct mtd_info *mtd, uint8_t byte); void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len); -#ifdef __UBOOT__ -#if defined(CONFIG_MTD_NAND_VERIFY_WRITE) - int (*verify_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); -#endif -#endif void (*select_chip)(struct mtd_info *mtd, int chip); int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); -- cgit v0.10.2 From 004a1fdb45fb06ee2faf6e50945ceb79d43a2f41 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 3 Feb 2015 11:58:16 -0600 Subject: nand: yaffs: Remove the "nand write.yaffs" command This command is only enabled by one board, complicates the NAND code, and doesn't appear to have been functioning properly for several years. If there are no bad blocks in the NAND region being written nand_write_skip_bad() will take the shortcut of calling nand_write() which bypasses the special yaffs handling. This causes invalid YAFFS data to be written. See http://lists.denx.de/pipermail/u-boot/2011-September/102830.html for an example and a potential workaround. U-Boot still retains the ability to mount and access YAFFS partitions via CONFIG_YAFFS2. Signed-off-by: Peter Tyser diff --git a/common/cmd_nand.c b/common/cmd_nand.c index bada28c..17fa7ea 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -705,16 +705,6 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) maxsize, (u_char *)addr, WITH_DROP_FFS | WITH_WR_VERIFY); #endif -#ifdef CONFIG_CMD_NAND_YAFFS - } else if (!strcmp(s, ".yaffs")) { - if (read) { - printf("Unknown nand command suffix '%s'.\n", s); - return 1; - } - ret = nand_write_skip_bad(nand, off, &rwsize, NULL, - maxsize, (u_char *)addr, - WITH_YAFFS_OOB | WITH_WR_VERIFY); -#endif } else if (!strcmp(s, ".oob")) { /* out-of-band data */ mtd_oob_ops_t ops = { @@ -857,11 +847,6 @@ static char nand_help_text[] = " 'addr', skipping bad blocks and dropping any pages at the end\n" " of eraseblocks that contain only 0xFF\n" #endif -#ifdef CONFIG_CMD_NAND_YAFFS - "nand write.yaffs - addr off|partition size\n" - " write 'size' bytes starting at offset 'off' with yaffs format\n" - " from memory address 'addr', skipping bad blocks.\n" -#endif "nand erase[.spread] [clean] off size - erase 'size' bytes " "from offset 'off'\n" " With '.spread', erase enough for given file size, otherwise,\n" diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index f487756..12dd26a 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -580,24 +580,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, if (actual) *actual = 0; -#ifdef CONFIG_CMD_NAND_YAFFS - if (flags & WITH_YAFFS_OOB) { - if (flags & (~WITH_YAFFS_OOB & ~WITH_WR_VERIFY)) - return -EINVAL; - - int pages; - pages = nand->erasesize / nand->writesize; - blocksize = (pages * nand->oobsize) + nand->erasesize; - if (*length % (nand->writesize + nand->oobsize)) { - printf("Attempt to write incomplete page" - " in yaffs mode\n"); - return -EINVAL; - } - } else -#endif - { - blocksize = nand->erasesize; - } + blocksize = nand->erasesize; /* * nand_write() handles unaligned, partial page writes. @@ -666,58 +649,22 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, else write_size = blocksize - block_offset; -#ifdef CONFIG_CMD_NAND_YAFFS - if (flags & WITH_YAFFS_OOB) { - int page, pages; - size_t pagesize = nand->writesize; - size_t pagesize_oob = pagesize + nand->oobsize; - struct mtd_oob_ops ops; - - ops.len = pagesize; - ops.ooblen = nand->oobsize; - ops.mode = MTD_OPS_AUTO_OOB; - ops.ooboffs = 0; - - pages = write_size / pagesize_oob; - for (page = 0; page < pages; page++) { - WATCHDOG_RESET(); - - ops.datbuf = p_buffer; - ops.oobbuf = ops.datbuf + pagesize; - - rval = mtd_write_oob(nand, offset, &ops); - - if ((flags & WITH_WR_VERIFY) && !rval) - rval = nand_verify_page_oob(nand, - &ops, offset); - - if (rval != 0) - break; - - offset += pagesize; - p_buffer += pagesize_oob; - } - } - else -#endif - { - truncated_write_size = write_size; + truncated_write_size = write_size; #ifdef CONFIG_CMD_NAND_TRIMFFS - if (flags & WITH_DROP_FFS) - truncated_write_size = drop_ffs(nand, p_buffer, - &write_size); + if (flags & WITH_DROP_FFS) + truncated_write_size = drop_ffs(nand, p_buffer, + &write_size); #endif - rval = nand_write(nand, offset, &truncated_write_size, - p_buffer); + rval = nand_write(nand, offset, &truncated_write_size, + p_buffer); - if ((flags & WITH_WR_VERIFY) && !rval) - rval = nand_verify(nand, offset, - truncated_write_size, p_buffer); + if ((flags & WITH_WR_VERIFY) && !rval) + rval = nand_verify(nand, offset, + truncated_write_size, p_buffer); - offset += write_size; - p_buffer += write_size; - } + offset += write_size; + p_buffer += write_size; if (rval != 0) { printf("NAND write to offset %llx failed %d\n", diff --git a/include/configs/M54418TWR.h b/include/configs/M54418TWR.h index be1750f..3a6e981 100644 --- a/include/configs/M54418TWR.h +++ b/include/configs/M54418TWR.h @@ -53,7 +53,6 @@ #define CONFIG_CMD_MISC #define CONFIG_CMD_MII #undef CONFIG_CMD_NAND -#undef CONFIG_CMD_NAND_YAFFS #define CONFIG_CMD_NET #define CONFIG_CMD_NFS #define CONFIG_CMD_PING diff --git a/include/configs/VCMA9.h b/include/configs/VCMA9.h index 94078f5..6aee6db 100644 --- a/include/configs/VCMA9.h +++ b/include/configs/VCMA9.h @@ -62,7 +62,6 @@ #define CONFIG_CMD_PING #define CONFIG_CMD_BSP #define CONFIG_CMD_NAND -#define CONFIG_CMD_NAND_YAFFS #define CONFIG_BOARD_LATE_INIT diff --git a/include/nand.h b/include/nand.h index 8ea4d5d..d2a53ab 100644 --- a/include/nand.h +++ b/include/nand.h @@ -104,11 +104,8 @@ typedef struct nand_erase_options nand_erase_options_t; int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, size_t *actual, loff_t lim, u_char *buffer); -#define WITH_YAFFS_OOB (1 << 0) /* whether write with yaffs format. This flag - * is a 'mode' meaning it cannot be mixed with - * other flags */ -#define WITH_DROP_FFS (1 << 1) /* drop trailing all-0xff pages */ -#define WITH_WR_VERIFY (1 << 2) /* verify data was written correctly */ +#define WITH_DROP_FFS (1 << 0) /* drop trailing all-0xff pages */ +#define WITH_WR_VERIFY (1 << 1) /* verify data was written correctly */ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, size_t *actual, loff_t lim, u_char *buffer, int flags); -- cgit v0.10.2 From 7653fc288a964ce5bb0cff9176444260731d0f90 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 24 Mar 2015 17:54:19 +0100 Subject: mtd: vf610_nfc: mark page as dirty on block erase The driver tries to re-use the page buffer by storing the page number of the current page in the buffer. The page is only read if the requested page number is not currently in the buffer. When a block is erased, the page number is marked as invalid if the erased page equals the one currently in the cache. However, since a erase block consists of multiple pages, also other page numbers could be affected. The commands to reproduce this issue (on a written page): > nand dump 0x800 > nand erase 0x0 0x20000 > nand dump 0x800 The second nand dump command returns the data from the buffer, while in fact the page is erased (0xff). Avoid the hassle to calculate whether the page is affected or not, but set the page buffer unconditionally to invalid instead. Signed-off-by: Stefan Agner diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 928d58b..9de971c 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c @@ -369,8 +369,7 @@ static void vf610_nfc_command(struct mtd_info *mtd, unsigned command, break; case NAND_CMD_ERASE1: - if (nfc->page == page) - nfc->page = -1; + nfc->page = -1; vf610_nfc_send_commands(nfc->regs, command, NAND_CMD_ERASE2, ERASE_CMD_CODE); vf610_nfc_addr_cycle(mtd, column, page); -- cgit v0.10.2 From 55765b1842e7dcf22efa8d973c7d1b7498dd99fa Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 24 Mar 2015 17:54:20 +0100 Subject: mtd: vf610_nfc: specify transfer size before each transfer Testing showed, that commands like STATUS made the buffer dirty when executed with NFC_SECSZ set to the page size. It looks like the controller transfers bogus data when this register is configured. When setting it to 0, the buffer does not get altered while the status command still seems to work flawless. Signed-off-by: Stefan Agner diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 9de971c..d98dd28 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c @@ -146,6 +146,7 @@ struct vf610_nfc { void __iomem *regs; uint column; int spareonly; + int page_sz; int page; /* Status and ID are in alternate locations. */ int alt_buf; @@ -329,6 +330,11 @@ static void vf610_nfc_addr_cycle(struct mtd_info *mtd, int column, int page) ROW_ADDR_SHIFT, page); } +static inline void vf610_nfc_transfer_size(void __iomem *regbase, int size) +{ + __raw_writel(size, regbase + NFC_SECTOR_SIZE); +} + /* Send command to NAND chip */ static void vf610_nfc_command(struct mtd_info *mtd, unsigned command, int column, int page) @@ -342,12 +348,14 @@ static void vf610_nfc_command(struct mtd_info *mtd, unsigned command, switch (command) { case NAND_CMD_PAGEPROG: nfc->page = -1; + vf610_nfc_transfer_size(nfc->regs, nfc->page_sz); vf610_nfc_send_commands(nfc->regs, NAND_CMD_SEQIN, command, PROGRAM_PAGE_CMD_CODE); vf610_nfc_addr_cycle(mtd, column, page); break; case NAND_CMD_RESET: + vf610_nfc_transfer_size(nfc->regs, 0); vf610_nfc_send_command(nfc->regs, command, RESET_CMD_CODE); break; /* @@ -363,6 +371,7 @@ static void vf610_nfc_command(struct mtd_info *mtd, unsigned command, if (nfc->page == page) return; nfc->page = page; + vf610_nfc_transfer_size(nfc->regs, nfc->page_sz); vf610_nfc_send_commands(nfc->regs, NAND_CMD_READ0, NAND_CMD_READSTART, READ_PAGE_CMD_CODE); vf610_nfc_addr_cycle(mtd, column, page); @@ -370,6 +379,7 @@ static void vf610_nfc_command(struct mtd_info *mtd, unsigned command, case NAND_CMD_ERASE1: nfc->page = -1; + vf610_nfc_transfer_size(nfc->regs, 0); vf610_nfc_send_commands(nfc->regs, command, NAND_CMD_ERASE2, ERASE_CMD_CODE); vf610_nfc_addr_cycle(mtd, column, page); @@ -377,11 +387,13 @@ static void vf610_nfc_command(struct mtd_info *mtd, unsigned command, case NAND_CMD_READID: nfc->alt_buf = ALT_BUF_ID; + vf610_nfc_transfer_size(nfc->regs, 0); vf610_nfc_send_command(nfc->regs, command, READ_ID_CMD_CODE); break; case NAND_CMD_STATUS: nfc->alt_buf = ALT_BUF_STAT; + vf610_nfc_transfer_size(nfc->regs, 0); vf610_nfc_send_command(nfc->regs, command, STATUS_READ_CMD_CODE); break; @@ -579,7 +591,6 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr) struct nand_chip *chip; struct vf610_nfc *nfc; int err = 0; - int page_sz; struct vf610_nfc_config cfg = { .hardware_ecc = 1, #ifdef CONFIG_SYS_NAND_BUSWIDTH_16BIT @@ -633,9 +644,8 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr) chip->bbt_td = &bbt_main_descr; chip->bbt_md = &bbt_mirror_descr; - page_sz = PAGE_2K + OOB_64; - page_sz += cfg.width == 16 ? 1 : 0; - vf610_nfc_write(mtd, NFC_SECTOR_SIZE, page_sz); + nfc->page_sz = PAGE_2K + OOB_64; + nfc->page_sz += cfg.width == 16 ? 1 : 0; /* Set configuration register. */ vf610_nfc_clear(mtd, NFC_FLASH_CONFIG, CONFIG_ADDR_AUTO_INCR_BIT); @@ -664,16 +674,15 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr) chip->ecc.mode = NAND_ECC_SOFT; /* default */ - page_sz = mtd->writesize + mtd->oobsize; + nfc->page_sz = mtd->writesize + mtd->oobsize; /* Single buffer only, max 256 OOB minus ECC status */ - if (page_sz > PAGE_2K + 256 - 8) { + if (nfc->page_sz > PAGE_2K + 256 - 8) { dev_err(nfc->dev, "Unsupported flash size\n"); err = -ENXIO; goto error; } - page_sz += cfg.width == 16 ? 1 : 0; - vf610_nfc_write(mtd, NFC_SECTOR_SIZE, page_sz); + nfc->page_sz += cfg.width == 16 ? 1 : 0; if (cfg.hardware_ecc) { if (mtd->writesize != PAGE_2K && mtd->oobsize < 64) { -- cgit v0.10.2 From 02fc64d1d98be7801e6b21dbf0d67555b0e05213 Mon Sep 17 00:00:00 2001 From: "Wu, Josh" Date: Wed, 4 Feb 2015 11:03:32 +0800 Subject: ARM: at91: sama5d4: display the U-Boot version on LCD This patch will display the U-Boot version on LCD. Signed-off-by: Josh Wu Acked-by: Bo Shen diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c b/board/atmel/sama5d4_xplained/sama5d4_xplained.c index e7f225a..7d447fe 100644 --- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c +++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.c @@ -24,6 +24,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -179,6 +180,7 @@ void lcd_show_board_info(void) int i; char temp[32]; + lcd_printf("%s\n", U_BOOT_VERSION); lcd_printf("2014 ATMEL Corp\n"); lcd_printf("%s CPU at %s MHz\n", get_cpu_name(), strmhz(temp, get_cpu_clk_rate())); diff --git a/board/atmel/sama5d4ek/sama5d4ek.c b/board/atmel/sama5d4ek/sama5d4ek.c index 46e5041..e9bbb4b 100644 --- a/board/atmel/sama5d4ek/sama5d4ek.c +++ b/board/atmel/sama5d4ek/sama5d4ek.c @@ -24,6 +24,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -174,6 +175,7 @@ void lcd_show_board_info(void) int i; char temp[32]; + lcd_printf("%s\n", U_BOOT_VERSION); lcd_printf("2014 ATMEL Corp\n"); lcd_printf("at91@atmel.com\n"); lcd_printf("%s CPU at %s MHz\n", get_cpu_name(), -- cgit v0.10.2 From a02c8a31bd34d0f771503783c7e4221e37ebd6d6 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Wed, 4 Feb 2015 15:53:01 +0800 Subject: ARM: atmel: arm9: switch to use common timer functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bo Shen [rebase on current master] Signed-off-by: Andreas Bießmann diff --git a/arch/arm/mach-at91/arm926ejs/timer.c b/arch/arm/mach-at91/arm926ejs/timer.c index b0b7fb9..31ce646 100644 --- a/arch/arm/mach-at91/arm926ejs/timer.c +++ b/arch/arm/mach-at91/arm926ejs/timer.c @@ -33,22 +33,6 @@ DECLARE_GLOBAL_DATA_PTR; #define TIMER_LOAD_VAL 0xfffff -static inline unsigned long long tick_to_time(unsigned long long tick) -{ - tick *= CONFIG_SYS_HZ; - do_div(tick, gd->arch.timer_rate_hz); - - return tick; -} - -static inline unsigned long long usec_to_tick(unsigned long long usec) -{ - usec *= gd->arch.timer_rate_hz; - do_div(usec, 1000000); - - return usec; -} - /* * Use the PITC in full 32 bit incrementing mode */ @@ -64,54 +48,11 @@ int timer_init(void) writel(TIMER_LOAD_VAL | AT91_PIT_MR_EN , &pit->mr); gd->arch.timer_rate_hz = gd->arch.mck_rate_hz / 16; - gd->arch.tbu = gd->arch.tbl = 0; return 0; } /* - * Get the current 64 bit timer tick count - */ -unsigned long long get_ticks(void) -{ - at91_pit_t *pit = (at91_pit_t *) ATMEL_BASE_PIT; - - ulong now = readl(&pit->piir); - - /* increment tbu if tbl has rolled over */ - if (now < gd->arch.tbl) - gd->arch.tbu++; - gd->arch.tbl = now; - return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl; -} - -void __udelay(unsigned long usec) -{ - unsigned long long start; - ulong tmo; - - start = get_ticks(); /* get current timestamp */ - tmo = usec_to_tick(usec); /* convert usecs to ticks */ - while ((get_ticks() - start) < tmo) - ; /* loop till time has passed */ -} - -/* - * get_timer(base) can be used to check for timeouts or - * to measure elasped time relative to an event: - * - * ulong start_time = get_timer(0) sets start_time to the current - * time value. - * get_timer(start_time) returns the time elapsed since then. - * - * The time is used in CONFIG_SYS_HZ units! - */ -ulong get_timer(ulong base) -{ - return tick_to_time(get_ticks()) - base; -} - -/* * Return the number of timer ticks per second. */ ulong get_tbclk(void) diff --git a/arch/arm/mach-at91/include/mach/at91sam9260.h b/arch/arm/mach-at91/include/mach/at91sam9260.h index 8950d67..1a4e84b 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9260.h +++ b/arch/arm/mach-at91/include/mach/at91sam9260.h @@ -133,6 +133,9 @@ #define ATMEL_BASE_CS6 0x70000000 #define ATMEL_BASE_CS7 0x80000000 +/* Timer */ +#define CONFIG_SYS_TIMER_COUNTER 0xfffffd3c + /* * Other misc defines */ diff --git a/arch/arm/mach-at91/include/mach/at91sam9261.h b/arch/arm/mach-at91/include/mach/at91sam9261.h index 6dfcf4c..914a3b0 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9261.h +++ b/arch/arm/mach-at91/include/mach/at91sam9261.h @@ -117,6 +117,9 @@ #define ATMEL_BASE_CS6 0x70000000 #define ATMEL_BASE_CS7 0x80000000 +/* Timer */ +#define CONFIG_SYS_TIMER_COUNTER 0xfffffd3c + /* * Other misc defines */ diff --git a/arch/arm/mach-at91/include/mach/at91sam9263.h b/arch/arm/mach-at91/include/mach/at91sam9263.h index 64a3888..71675ab 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9263.h +++ b/arch/arm/mach-at91/include/mach/at91sam9263.h @@ -132,6 +132,9 @@ #define ATMEL_BASE_CS6 0x70000000 #define ATMEL_BASE_CS7 0x80000000 +/* Timer */ +#define CONFIG_SYS_TIMER_COUNTER 0xfffffd3c + /* * Other misc defines */ diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45.h b/arch/arm/mach-at91/include/mach/at91sam9g45.h index 6df8cdb..cf1c73f 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9g45.h +++ b/arch/arm/mach-at91/include/mach/at91sam9g45.h @@ -136,6 +136,9 @@ #define ATMEL_BASE_CS6 0x70000000 #define ATMEL_BASE_CS7 0x80000000 +/* Timer */ +#define CONFIG_SYS_TIMER_COUNTER 0xfffffd3c + /* * Other misc defines */ diff --git a/arch/arm/mach-at91/include/mach/at91sam9rl.h b/arch/arm/mach-at91/include/mach/at91sam9rl.h index 3a8e6d6..70bbf4e 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9rl.h +++ b/arch/arm/mach-at91/include/mach/at91sam9rl.h @@ -116,6 +116,9 @@ #define ATMEL_BASE_CS4 0x50000000 /* Compact Flash Slot 0 */ #define ATMEL_BASE_CS5 0x60000000 /* Compact Flash Slot 1 */ +/* Timer */ +#define CONFIG_SYS_TIMER_COUNTER 0xfffffd3c + /* * Other misc defines */ diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5.h b/arch/arm/mach-at91/include/mach/at91sam9x5.h index 36a5cdf..7e7b531 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9x5.h +++ b/arch/arm/mach-at91/include/mach/at91sam9x5.h @@ -154,6 +154,9 @@ #define ATMEL_CPU_NAME get_cpu_name() #endif +/* Timer */ +#define CONFIG_SYS_TIMER_COUNTER 0xfffffe3c + /* * Other misc defines */ -- cgit v0.10.2 From a2df3a37d78583f40e2d2053e5cf0ff689ac4aa4 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Wed, 4 Feb 2015 15:53:02 +0800 Subject: ARM: atmel: armv7: switch to use common timer functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The commit 8dfafdd (Introduce common timer functions), add common timer functions, we can use them directly. Signed-off-by: Bo Shen [rebase on current master] Sigend-off-by: Andreas Bießmann diff --git a/arch/arm/mach-at91/armv7/timer.c b/arch/arm/mach-at91/armv7/timer.c index 19bf80b..a4a3817 100644 --- a/arch/arm/mach-at91/armv7/timer.c +++ b/arch/arm/mach-at91/armv7/timer.c @@ -36,22 +36,6 @@ DECLARE_GLOBAL_DATA_PTR; #define TIMER_LOAD_VAL 0xfffff -static inline unsigned long long tick_to_time(unsigned long long tick) -{ - tick *= CONFIG_SYS_HZ; - do_div(tick, gd->arch.timer_rate_hz); - - return tick; -} - -static inline unsigned long long usec_to_tick(unsigned long long usec) -{ - usec *= gd->arch.timer_rate_hz; - do_div(usec, 1000000); - - return usec; -} - /* * Use the PITC in full 32 bit incrementing mode */ @@ -67,55 +51,10 @@ int timer_init(void) gd->arch.timer_rate_hz = get_pit_clk_rate() / 16; - gd->arch.tbu = 0; - gd->arch.tbl = 0; - return 0; } /* - * Get the current 64 bit timer tick count - */ -unsigned long long get_ticks(void) -{ - at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT; - - ulong now = readl(&pit->piir); - - /* increment tbu if tbl has rolled over */ - if (now < gd->arch.tbl) - gd->arch.tbu++; - gd->arch.tbl = now; - return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl; -} - -void __udelay(unsigned long usec) -{ - unsigned long long start; - ulong tmo; - - start = get_ticks(); /* get current timestamp */ - tmo = usec_to_tick(usec); /* convert usecs to ticks */ - while ((get_ticks() - start) < tmo) - ; /* loop till time has passed */ -} - -/* - * get_timer(base) can be used to check for timeouts or - * to measure elasped time relative to an event: - * - * ulong start_time = get_timer(0) sets start_time to the current - * time value. - * get_timer(start_time) returns the time elapsed since then. - * - * The time is used in CONFIG_SYS_HZ units! - */ -ulong get_timer(ulong base) -{ - return tick_to_time(get_ticks()) - base; -} - -/* * Return the number of timer ticks per second. */ ulong get_tbclk(void) diff --git a/arch/arm/mach-at91/include/mach/sama5d3.h b/arch/arm/mach-at91/include/mach/sama5d3.h index 227ba80..b749cb3 100644 --- a/arch/arm/mach-at91/include/mach/sama5d3.h +++ b/arch/arm/mach-at91/include/mach/sama5d3.h @@ -189,6 +189,9 @@ #define PIO_SCDR_DIV 0x3fff #define CPU_HAS_PCR +/* Timer */ +#define CONFIG_SYS_TIMER_COUNTER 0xfffffe3c + /* * PMECC table in ROM */ diff --git a/arch/arm/mach-at91/include/mach/sama5d4.h b/arch/arm/mach-at91/include/mach/sama5d4.h index f30cb5f..7773ace 100644 --- a/arch/arm/mach-at91/include/mach/sama5d4.h +++ b/arch/arm/mach-at91/include/mach/sama5d4.h @@ -193,6 +193,9 @@ #define cpu_is_sama5d44() (cpu_is_sama5d4() && \ (get_extension_chip_id() == ARCH_EXID_SAMA5D44)) +/* Timer */ +#define CONFIG_SYS_TIMER_COUNTER 0xfc06863c + /* * No PMECC Galois table in ROM */ -- cgit v0.10.2 From e755d54392554b82ce140cb96bca81ac52f69f43 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 10 Feb 2015 19:07:22 -0500 Subject: spl_atmel.c: Switch s_init to board_init_f MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To facilitate changing lowlevel_init to become s_init, move the current contents of s_init into board_init_f and add the rest of what board_init_f does here. In order to compile clean without CONFIG_SKIP_LOWLEVEL_INIT set, leave an empty stub of s_init(). It can be removed when lowlevel_init becomes s_init. Cc: Bo Shen Cc: Andreas Bießmann Tested-by: Matt Porter on sama5d3_xplained Signed-off-by: Tom Rini [rebased on current master, leave s_init() as empty stub] Signed-off-by: Andreas Bießmann diff --git a/arch/arm/mach-at91/spl_atmel.c b/arch/arm/mach-at91/spl_atmel.c index 9cc1111..8ac5335 100644 --- a/arch/arm/mach-at91/spl_atmel.c +++ b/arch/arm/mach-at91/spl_atmel.c @@ -70,8 +70,13 @@ __weak void redirect_int_from_saic_to_aic(void) /* This only be used for sama5d4 soc now */ } +/* empty stub to satisfy current lowlevel_init, can be removed any time */ void s_init(void) { +} + +void board_init_f(ulong dummy) +{ switch_to_main_crystal_osc(); /* disable watchdog */ @@ -93,4 +98,9 @@ void s_init(void) preloader_console_init(); mem_init(); + + /* Clear the BSS. */ + memset(__bss_start, 0, __bss_end - __bss_start); + + board_init_r(NULL, 0); } -- cgit v0.10.2 From 55ebd0c1ca41ddb1ccf6f7d172e867cfb8c68708 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Tue, 17 Mar 2015 08:26:11 +0100 Subject: arm, at91: corvus: move MACH_TYPE to defconfig move MACH_TYPE into defconfig Signed-off-by: Heiko Schocher diff --git a/configs/corvus_defconfig b/configs/corvus_defconfig index 266a2ab..0427e9e 100644 --- a/configs/corvus_defconfig +++ b/configs/corvus_defconfig @@ -1,5 +1,5 @@ CONFIG_SPL=y -CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9M10G45,SYS_USE_NANDFLASH" +CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9M10G45,MACH_TYPE=2066,SYS_USE_NANDFLASH" CONFIG_ARM=y CONFIG_ARCH_AT91=y CONFIG_TARGET_CORVUS=y diff --git a/include/configs/corvus.h b/include/configs/corvus.h index ace511f..f5b8f9b 100644 --- a/include/configs/corvus.h +++ b/include/configs/corvus.h @@ -16,9 +16,6 @@ #include -#define MACH_TYPE_CORVUS 2066 - -#define CONFIG_MACH_TYPE MACH_TYPE_CORVUS #define CONFIG_SYS_GENERIC_BOARD /* * Warning: changing CONFIG_SYS_TEXT_BASE requires -- cgit v0.10.2 From da78fb541494ac778a0fe66cc02e2fea33e228d9 Mon Sep 17 00:00:00 2001 From: David Dueck Date: Fri, 20 Mar 2015 10:52:49 +0100 Subject: ARM: at91: atmel_nand: Support flash based BBT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for on-flash bad block table. This makes U-Boot handle an existing BBT correctly. Signed-off-by: David Dueck Reviewed-by: Boris BREZILLON CC: Boris BREZILLON CC: Josh Wu CC: Andreas Bießmann CC: Scott Wood Acked-by: Josh Wu diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index b16e3aa..a2016e7 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -1456,6 +1456,9 @@ int board_nand_init(struct nand_chip *nand) nand->dev_ready = at91_nand_wait_ready; #endif nand->chip_delay = 20; +#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT + nand->bbt_options |= NAND_BBT_USE_FLASH; +#endif #ifdef CONFIG_ATMEL_NAND_HWECC #ifdef CONFIG_ATMEL_NAND_HW_PMECC @@ -1522,6 +1525,9 @@ int atmel_nand_chip_init(int devnum, ulong base_addr) nand->dev_ready = at91_nand_ready; #endif nand->chip_delay = 75; +#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT + nand->bbt_options |= NAND_BBT_USE_FLASH; +#endif ret = nand_scan_ident(mtd, CONFIG_SYS_NAND_MAX_CHIPS, NULL); if (ret) -- cgit v0.10.2 From 23ac62d4c72c9be762cb8613b8269599295f7c88 Mon Sep 17 00:00:00 2001 From: "Wu, Josh" Date: Tue, 24 Mar 2015 17:07:22 +0800 Subject: ARM: at91: at91sam9n12ek: save the environment to a fat file in MMC card Insteading in mmc's raw sectors, this patch will save the environment in a fat file (uboot.env) in mmc card's first FAT patition by default. If you want to save in mmc's raw sectors, you only need to define CONFIG_ENV_IS_IN_MMC. Signed-off-by: Josh Wu Acked-by: Bo Shen diff --git a/include/configs/at91sam9n12ek.h b/include/configs/at91sam9n12ek.h index f02fce9..058e0e4 100644 --- a/include/configs/at91sam9n12ek.h +++ b/include/configs/at91sam9n12ek.h @@ -201,11 +201,22 @@ #else /* CONFIG_SYS_USE_MMC */ /* bootstrap + u-boot + env + linux in mmc */ -#define CONFIG_ENV_IS_IN_MMC -/* For FAT system, most cases it should be in the reserved sector */ + +#ifdef CONFIG_ENV_IS_IN_MMC +/* Use raw reserved sectors to save environment */ #define CONFIG_ENV_OFFSET 0x2000 #define CONFIG_ENV_SIZE 0x1000 #define CONFIG_SYS_MMC_ENV_DEV 0 +#else +/* Use file in FAT file to save environment */ +#define CONFIG_ENV_IS_IN_FAT +#define CONFIG_FAT_WRITE +#define FAT_ENV_INTERFACE "mmc" +#define FAT_ENV_FILE "uboot.env" +#define FAT_ENV_DEVICE_AND_PART "0" +#define CONFIG_ENV_SIZE 0x4000 +#endif + #define CONFIG_BOOTCOMMAND \ "setenv bootargs ${console} ${mtdparts} ${bootargs_mmc};" \ "fatload mmc 0:1 0x21000000 dtb;" \ -- cgit v0.10.2 From 72cb3b6b54e99959f84456e448aa3db9f776f8a5 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Fri, 27 Mar 2015 14:23:33 +0800 Subject: ARM: atmel: arm926ejs: fix clock configuration Config MCKR according to the datasheet sequence, or else it will cause the MCKR configuration failed. Remove timeout checking for clock configuration, if configure the clock failed, let the system hang while not run in wrong clock configuration. Signed-off-by: Bo Shen Tested-by: Heiko Schocher diff --git a/arch/arm/mach-at91/arm926ejs/clock.c b/arch/arm/mach-at91/arm926ejs/clock.c index f363982..8d6934e 100644 --- a/arch/arm/mach-at91/arm926ejs/clock.c +++ b/arch/arm/mach-at91/arm926ejs/clock.c @@ -195,50 +195,52 @@ int at91_clock_init(unsigned long main_clock) void at91_plla_init(u32 pllar) { struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; - int timeout = AT91_PLL_LOCK_TIMEOUT; writel(pllar, &pmc->pllar); - while (!(readl(&pmc->sr) & (AT91_PMC_LOCKA | AT91_PMC_MCKRDY))) { - timeout--; - if (timeout == 0) - break; - } + while (!(readl(&pmc->sr) & AT91_PMC_LOCKA)) + ; } void at91_pllb_init(u32 pllbr) { struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; - int timeout = AT91_PLL_LOCK_TIMEOUT; writel(pllbr, &pmc->pllbr); - while (!(readl(&pmc->sr) & (AT91_PMC_LOCKB | AT91_PMC_MCKRDY))) { - timeout--; - if (timeout == 0) - break; - } + while (!(readl(&pmc->sr) & AT91_PMC_LOCKB)) + ; } void at91_mck_init(u32 mckr) { struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; - int timeout = AT91_PLL_LOCK_TIMEOUT; u32 tmp; tmp = readl(&pmc->mckr); - tmp &= ~(AT91_PMC_MCKR_PRES_MASK | - AT91_PMC_MCKR_MDIV_MASK | - AT91_PMC_MCKR_PLLADIV_MASK | - AT91_PMC_MCKR_CSS_MASK); - tmp |= mckr & (AT91_PMC_MCKR_PRES_MASK | - AT91_PMC_MCKR_MDIV_MASK | - AT91_PMC_MCKR_PLLADIV_MASK | - AT91_PMC_MCKR_CSS_MASK); + tmp &= ~AT91_PMC_MCKR_PRES_MASK; + tmp |= mckr & AT91_PMC_MCKR_PRES_MASK; writel(tmp, &pmc->mckr); + while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY)) + ; - while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY)) { - timeout--; - if (timeout == 0) - break; - } + tmp = readl(&pmc->mckr); + tmp &= ~AT91_PMC_MCKR_MDIV_MASK; + tmp |= mckr & AT91_PMC_MCKR_MDIV_MASK; + writel(tmp, &pmc->mckr); + while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY)) + ; + + tmp = readl(&pmc->mckr); + tmp &= ~AT91_PMC_MCKR_PLLADIV_MASK; + tmp |= mckr & AT91_PMC_MCKR_PLLADIV_MASK; + writel(tmp, &pmc->mckr); + while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY)) + ; + + tmp = readl(&pmc->mckr); + tmp &= ~AT91_PMC_MCKR_CSS_MASK; + tmp |= mckr & AT91_PMC_MCKR_CSS_MASK; + writel(tmp, &pmc->mckr); + while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY)) + ; } void at91_periph_clk_enable(int id) -- cgit v0.10.2 From 41d41a93fb5600b0cbfdbfae88b0d8403bd650b7 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Fri, 27 Mar 2015 14:23:34 +0800 Subject: ARM: atmel: at91sam9m10g45ek: enable spl support Supports boot up from NAND flash with software ECC eanbled. And supports boot up from SD/MMC card with FAT file system. As the boot from SD/MMC card with FAT file system, the BSS segment is too big to fit into SRAM, so, use the lds to put it into SDRAM. Signed-off-by: Bo Shen diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 30945c1..25da926 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -66,6 +66,7 @@ config TARGET_STAMP9G20 config TARGET_AT91SAM9M10G45EK bool "Atmel AT91SAM9M10G45-EK board" select CPU_ARM926EJS + select SUPPORT_SPL config TARGET_PM9G45 bool "Ronetix pm9g45 board" diff --git a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds new file mode 100644 index 0000000..acadd1d --- /dev/null +++ b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2015 Atmel Corporation + * Bo Shen + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \ + LENGTH = CONFIG_SPL_MAX_SIZE } +MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \ + LENGTH = CONFIG_SPL_BSS_MAX_SIZE } + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + .text : + { + __start = .; + *(.vectors) + arch/arm/cpu/arm926ejs/start.o (.text*) + *(.text*) + } >.sram + + . = ALIGN(4); + .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram + + . = ALIGN(4); + .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram + + . = ALIGN(4); + __image_copy_end = .; + + .end : + { + *(.__end) + } >.sram + + .bss : + { + . = ALIGN(4); + __bss_start = .; + *(.bss*) + . = ALIGN(4); + __bss_end = .; + } >.sdram +} diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c index 89f588b..af6fc0d 100644 --- a/arch/arm/mach-at91/spl_at91.c +++ b/arch/arm/mach-at91/spl_at91.c @@ -71,7 +71,11 @@ void __weak at91_spl_board_init(void) { } -void spl_board_init(void) +void __weak spl_board_init(void) +{ +} + +void board_init_f(ulong dummy) { struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; diff --git a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c index b807ef9..4289179 100644 --- a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c +++ b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #include #include #if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB) @@ -71,6 +73,84 @@ void at91sam9m10g45ek_nand_hw_init(void) } #endif +#if defined(CONFIG_SPL_BUILD) +#include +#include + +void at91_spl_board_init(void) +{ + /* + * On the at91sam9m10g45ek board, the chip wm9711 stays in the + * test mode, so it needs do some action to exit test mode. + */ + at91_periph_clk_enable(ATMEL_ID_PIODE); + at91_set_gpio_output(AT91_PIN_PD7, 0); + at91_set_gpio_output(AT91_PIN_PD8, 0); + at91_set_pio_pullup(AT91_PIO_PORTD, 7, 1); + at91_set_pio_pullup(AT91_PIO_PORTD, 8, 1); + +#ifdef CONFIG_SYS_USE_MMC + at91_mci_hw_init(); +#elif CONFIG_SYS_USE_NANDFLASH + at91sam9m10g45ek_nand_hw_init(); +#endif +} + +#include +static void ddr2_conf(struct atmel_mpddr *ddr2) +{ + ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM); + + ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 | + ATMEL_MPDDRC_CR_NR_ROW_14 | + ATMEL_MPDDRC_CR_DQMS_SHARED | + ATMEL_MPDDRC_CR_CAS_DDR_CAS3); + + ddr2->rtr = 0x24b; + + ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |/* 6*7.5 = 45 ns */ + 2 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET |/* 2*7.5 = 15 ns */ + 2 << ATMEL_MPDDRC_TPR0_TWR_OFFSET | /* 2*7.5 = 15 ns */ + 8 << ATMEL_MPDDRC_TPR0_TRC_OFFSET | /* 8*7.5 = 60 ns */ + 2 << ATMEL_MPDDRC_TPR0_TRP_OFFSET | /* 2*7.5 = 15 ns */ + 1 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET | /* 1*7.5= 7.5 ns*/ + 1 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET | /* 1 clk cycle */ + 2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET); /* 2 clk cycles */ + + ddr2->tpr1 = (2 << ATMEL_MPDDRC_TPR1_TXP_OFFSET | /* 2*7.5 = 15 ns */ + 200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET | + 16 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET | + 14 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET); + + ddr2->tpr2 = (1 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET | + 0 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET | + 7 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET | + 2 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET); +} + +void mem_init(void) +{ + struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; + struct at91_matrix *mat = (struct at91_matrix *)ATMEL_BASE_MATRIX; + struct atmel_mpddr ddr2; + unsigned long csa; + + ddr2_conf(&ddr2); + + /* enable DDR2 clock */ + writel(0x4, &pmc->scer); + + /* Chip select 1 is for DDR2/SDRAM */ + csa = readl(&mat->ebicsa); + csa |= AT91_MATRIX_EBI_CS1A_SDRAMC; + csa &= ~AT91_MATRIX_EBI_VDDIOMSEL_3_3V; + writel(csa, &mat->ebicsa); + + /* DDRAM2 Controller initialize */ + ddr2_init(ATMEL_BASE_CS6, &ddr2); +} +#endif + #ifdef CONFIG_CMD_USB static void at91sam9m10g45ek_usb_hw_init(void) { diff --git a/configs/at91sam9m10g45ek_mmc_defconfig b/configs/at91sam9m10g45ek_mmc_defconfig index 6949d3a..f3e1ebe 100644 --- a/configs/at91sam9m10g45ek_mmc_defconfig +++ b/configs/at91sam9m10g45ek_mmc_defconfig @@ -1,3 +1,4 @@ +CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9M10G45,SYS_USE_MMC" CONFIG_ARM=y CONFIG_ARCH_AT91=y diff --git a/configs/at91sam9m10g45ek_nandflash_defconfig b/configs/at91sam9m10g45ek_nandflash_defconfig index 30967e3..5e0b16e 100644 --- a/configs/at91sam9m10g45ek_nandflash_defconfig +++ b/configs/at91sam9m10g45ek_nandflash_defconfig @@ -1,3 +1,4 @@ +CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9M10G45,SYS_USE_NANDFLASH" CONFIG_ARM=y CONFIG_ARCH_AT91=y diff --git a/include/configs/at91sam9m10g45ek.h b/include/configs/at91sam9m10g45ek.h index db5d5ea..e4c49f4 100644 --- a/include/configs/at91sam9m10g45ek.h +++ b/include/configs/at91sam9m10g45ek.h @@ -203,4 +203,62 @@ */ #define CONFIG_SYS_MALLOC_LEN ROUND(3 * CONFIG_ENV_SIZE + 128*1024, 0x1000) +/* Defines for SPL */ +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_TEXT_BASE 0x300000 +#define CONFIG_SPL_MAX_SIZE 0x010000 +#define CONFIG_SPL_STACK 0x310000 + +#define CONFIG_SPL_LIBCOMMON_SUPPORT +#define CONFIG_SPL_LIBGENERIC_SUPPORT +#define CONFIG_SPL_SERIAL_SUPPORT +#define CONFIG_SPL_GPIO_SUPPORT + +#define CONFIG_SYS_MONITOR_LEN 0x80000 + +#ifdef CONFIG_SYS_USE_MMC + +#define CONFIG_SPL_BSS_START_ADDR 0x70000000 +#define CONFIG_SPL_BSS_MAX_SIZE 0x00080000 +#define CONFIG_SYS_SPL_MALLOC_START 0x70080000 +#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00080000 + +#define CONFIG_SPL_LDSCRIPT arch/arm/mach-at91/arm926ejs/u-boot-spl.lds +#define CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400 +#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200 +#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img" +#define CONFIG_SPL_FAT_SUPPORT +#define CONFIG_SPL_LIBDISK_SUPPORT + +#elif CONFIG_SYS_USE_NANDFLASH +#define CONFIG_SPL_NAND_SUPPORT +#define CONFIG_SPL_NAND_DRIVERS +#define CONFIG_SPL_NAND_BASE +#define CONFIG_SPL_NAND_ECC +#define CONFIG_SPL_NAND_SOFTECC +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x40000 +#define CONFIG_SYS_NAND_U_BOOT_SIZE 0x80000 +#define CONFIG_SYS_NAND_5_ADDR_CYCLE + +#define CONFIG_SYS_NAND_PAGE_SIZE 0x800 +#define CONFIG_SYS_NAND_BLOCK_SIZE 0x20000 +#define CONFIG_SYS_NAND_PAGE_COUNT 64 +#define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS +#define CONFIG_SYS_NAND_ECCSIZE 256 +#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_SYS_NAND_OOBSIZE 64 +#define CONFIG_SYS_NAND_ECCPOS { 40, 41, 42, 43, 44, 45, 46, 47, \ + 48, 49, 50, 51, 52, 53, 54, 55, \ + 56, 57, 58, 59, 60, 61, 62, 63, } +#endif + +#define CONFIG_SPL_ATMEL_SIZE +#define CONFIG_SYS_MASTER_CLOCK 132096000 +#define CONFIG_SYS_AT91_PLLA 0x20c73f03 +#define CONFIG_SYS_MCKR 0x1301 +#define CONFIG_SYS_MCKR_CSS 0x1302 + +#define ATMEL_BASE_MPDDRC ATMEL_BASE_DDRSDRC0 #endif -- cgit v0.10.2 From d85e8914b379eb3c4d66be241fee29da50166aa2 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Fri, 27 Mar 2015 14:23:35 +0800 Subject: ARM: atmel: at91sam9x5ek: enable spl support Enable SPL support for at91sam9x5ek board. Now, it supports boot up from NAND flash and SPI flash. Signed-off-by: Bo Shen diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 25da926..bdf87f9 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -83,6 +83,7 @@ config TARGET_AT91SAM9RLEK config TARGET_AT91SAM9X5EK bool "Atmel AT91SAM9X5-EK board" select CPU_ARM926EJS + select SUPPORT_SPL config TARGET_SAMA5D3_XPLAINED bool "SAMA5D3 Xplained board" diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index e596ba6..ba83616 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_AT91_WANTS_COMMON_PHY) += phy.o ifneq ($(CONFIG_SPL_BUILD),) obj-$(CONFIG_AT91SAM9G20) += sdram.o spl_at91.o obj-$(CONFIG_AT91SAM9M10G45) += mpddrc.o spl_at91.o +obj-$(CONFIG_AT91SAM9X5) += mpddrc.o spl_at91.o obj-$(CONFIG_SAMA5D3) += mpddrc.o spl_atmel.o obj-$(CONFIG_SAMA5D4) += mpddrc.o spl_atmel.o obj-y += spl.o diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h index 65691ab..c903260 100644 --- a/arch/arm/mach-at91/include/mach/at91_pmc.h +++ b/arch/arm/mach-at91/include/mach/at91_pmc.h @@ -97,7 +97,8 @@ typedef struct at91_pmc { #define AT91_PMC_MCKR_CSS_PLLB 0x00000003 #define AT91_PMC_MCKR_CSS_MASK 0x00000003 -#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) +#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \ + defined(CONFIG_AT91SAM9X5) #define AT91_PMC_MCKR_PRES_1 0x00000000 #define AT91_PMC_MCKR_PRES_2 0x00000010 #define AT91_PMC_MCKR_PRES_4 0x00000020 @@ -126,7 +127,8 @@ typedef struct at91_pmc { #else #define AT91_PMC_MCKR_MDIV_1 0x00000000 #define AT91_PMC_MCKR_MDIV_2 0x00000100 -#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) +#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \ + defined(CONFIG_AT91SAM9X5) #define AT91_PMC_MCKR_MDIV_3 0x00000300 #endif #define AT91_PMC_MCKR_MDIV_4 0x00000200 diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5.h b/arch/arm/mach-at91/include/mach/at91sam9x5.h index 7e7b531..8100ebe 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9x5.h +++ b/arch/arm/mach-at91/include/mach/at91sam9x5.h @@ -124,6 +124,16 @@ #define ATMEL_BASE_EHCI 0x00700000 /* USB Host controller (EHCI) */ #endif +/* + * External memory + */ +#define ATMEL_BASE_CS0 0x10000000 +#define ATMEL_BASE_CS1 0x20000000 +#define ATMEL_BASE_CS2 0x30000000 +#define ATMEL_BASE_CS3 0x40000000 +#define ATMEL_BASE_CS4 0x50000000 +#define ATMEL_BASE_CS5 0x60000000 + /* 9x5 series chip id definitions */ #define ARCH_ID_AT91SAM9X5 0x819a05a0 #define ARCH_ID_VERSION_MASK 0x1f diff --git a/arch/arm/mach-at91/mpddrc.c b/arch/arm/mach-at91/mpddrc.c index beec13d..24d5fcd 100644 --- a/arch/arm/mach-at91/mpddrc.c +++ b/arch/arm/mach-at91/mpddrc.c @@ -19,7 +19,8 @@ static inline void atmel_mpddr_op(int mode, u32 ram_address) static int ddr2_decodtype_is_seq(u32 cr) { -#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) +#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \ + defined(CONFIG_AT91SAM9X5) if (cr & ATMEL_MPDDRC_CR_DECOD_INTERLEAVED) return 0; #endif diff --git a/arch/arm/mach-at91/spl.c b/arch/arm/mach-at91/spl.c index aaa5eec..27a405a 100644 --- a/arch/arm/mach-at91/spl.c +++ b/arch/arm/mach-at91/spl.c @@ -29,7 +29,7 @@ u32 spl_boot_device(void) return BOOT_DEVICE_MMC1; #elif CONFIG_SYS_USE_NANDFLASH return BOOT_DEVICE_NAND; -#elif CONFIG_SYS_USE_SERIALFLASH +#elif CONFIG_SYS_USE_SERIALFLASH || CONFIG_SYS_USE_SPIFLASH return BOOT_DEVICE_SPI; #endif return BOOT_DEVICE_NONE; diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c index af6fc0d..e28e568 100644 --- a/arch/arm/mach-at91/spl_at91.c +++ b/arch/arm/mach-at91/spl_at91.c @@ -115,9 +115,14 @@ void board_init_f(ulong dummy) timer_init(); /* enable clocks for all PIOs */ +#ifdef CONFIG_AT91SAM9X5 + at91_periph_clk_enable(ATMEL_ID_PIOAB); + at91_periph_clk_enable(ATMEL_ID_PIOCD); +#else at91_periph_clk_enable(ATMEL_ID_PIOA); at91_periph_clk_enable(ATMEL_ID_PIOB); at91_periph_clk_enable(ATMEL_ID_PIOC); +#endif /* init console */ at91_seriald_hw_init(); preloader_console_init(); diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c index 17a2a40..114ac5c 100644 --- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c +++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c @@ -293,3 +293,77 @@ int dram_init(void) CONFIG_SYS_SDRAM_SIZE); return 0; } + +#if defined(CONFIG_SPL_BUILD) +#include +#include + +void at91_spl_board_init(void) +{ +#ifdef CONFIG_SYS_USE_MMC + at91_mci_hw_init(); +#elif CONFIG_SYS_USE_NANDFLASH + at91sam9x5ek_nand_hw_init(); +#elif CONFIG_SYS_USE_SPIFLASH + at91_spi0_hw_init(1 << 4); +#endif +} + +#include +static void ddr2_conf(struct atmel_mpddr *ddr2) +{ + ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM); + + ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 | + ATMEL_MPDDRC_CR_NR_ROW_13 | + ATMEL_MPDDRC_CR_CAS_DDR_CAS3 | + ATMEL_MPDDRC_CR_NB_8BANKS | + ATMEL_MPDDRC_CR_DECOD_INTERLEAVED); + + ddr2->rtr = 0x411; + + ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TWR_OFFSET | + 8 << ATMEL_MPDDRC_TPR0_TRC_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TRP_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET); + + ddr2->tpr1 = (2 << ATMEL_MPDDRC_TPR1_TXP_OFFSET | + 200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET | + 19 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET | + 18 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET); + + ddr2->tpr2 = (7 << ATMEL_MPDDRC_TPR2_TFAW_OFFSET | + 2 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET | + 3 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET | + 7 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET | + 2 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET); +} + +void mem_init(void) +{ + struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; + struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX; + struct atmel_mpddr ddr2; + unsigned long csa; + + ddr2_conf(&ddr2); + + /* enable DDR2 clock */ + writel(0x4, &pmc->scer); + + /* Chip select 1 is for DDR2/SDRAM */ + csa = readl(&matrix->ebicsa); + csa |= AT91_MATRIX_EBI_CS1A_SDRAMC; + csa &= ~AT91_MATRIX_EBI_DBPU_OFF; + csa |= AT91_MATRIX_EBI_DBPD_OFF; + csa |= AT91_MATRIX_EBI_EBI_IOSR_NORMAL; + writel(csa, &matrix->ebicsa); + + /* DDRAM2 Controller initialize */ + ddr2_init(ATMEL_BASE_CS1, &ddr2); +} +#endif diff --git a/configs/at91sam9x5ek_nandflash_defconfig b/configs/at91sam9x5ek_nandflash_defconfig index c2ebb00..6eea1af 100644 --- a/configs/at91sam9x5ek_nandflash_defconfig +++ b/configs/at91sam9x5ek_nandflash_defconfig @@ -1,3 +1,4 @@ +CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9X5,SYS_USE_NANDFLASH" CONFIG_ARM=y CONFIG_ARCH_AT91=y diff --git a/configs/at91sam9x5ek_spiflash_defconfig b/configs/at91sam9x5ek_spiflash_defconfig index 76f68a6..7ef1534 100644 --- a/configs/at91sam9x5ek_spiflash_defconfig +++ b/configs/at91sam9x5ek_spiflash_defconfig @@ -1,3 +1,4 @@ +CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9X5,SYS_USE_SPIFLASH" CONFIG_ARM=y CONFIG_ARCH_AT91=y diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h index 6d8b71d..1a481b3 100644 --- a/include/configs/at91sam9x5ek.h +++ b/include/configs/at91sam9x5ek.h @@ -243,4 +243,61 @@ */ #define CONFIG_SYS_MALLOC_LEN (512 * 1024 + 0x1000) +/* SPL */ +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_TEXT_BASE 0x300000 +#define CONFIG_SPL_MAX_SIZE 0x6000 +#define CONFIG_SPL_STACK 0x308000 + +#define CONFIG_SPL_BSS_START_ADDR 0x20000000 +#define CONFIG_SPL_BSS_MAX_SIZE 0x80000 +#define CONFIG_SYS_SPL_MALLOC_START 0x20080000 +#define CONFIG_SYS_SPL_MALLOC_SIZE 0x80000 + +#define CONFIG_SPL_LIBCOMMON_SUPPORT +#define CONFIG_SPL_LIBGENERIC_SUPPORT +#define CONFIG_SPL_GPIO_SUPPORT +#define CONFIG_SPL_SERIAL_SUPPORT + +#define CONFIG_SPL_BOARD_INIT +#define CONFIG_SYS_MONITOR_LEN (512 << 10) + +#define CONFIG_SYS_MASTER_CLOCK 132096000 +#define CONFIG_SYS_AT91_PLLA 0x20c73f03 +#define CONFIG_SYS_MCKR 0x1301 +#define CONFIG_SYS_MCKR_CSS 0x1302 + +#define ATMEL_BASE_MPDDRC ATMEL_BASE_DDRSDRC + +#ifdef CONFIG_SYS_USE_MMC +#define CONFIG_SPL_LDSCRIPT arch/arm/mach-at91/arm926ejs/u-boot-spl.lds +#define CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400 +#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200 +#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img" +#define CONFIG_SPL_FAT_SUPPORT +#define CONFIG_SPL_LIBDISK_SUPPORT + +#elif CONFIG_SYS_USE_NANDFLASH +#define CONFIG_SPL_NAND_SUPPORT +#define CONFIG_SPL_NAND_DRIVERS +#define CONFIG_SPL_NAND_BASE +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x40000 +#define CONFIG_SYS_NAND_5_ADDR_CYCLE +#define CONFIG_SYS_NAND_PAGE_SIZE 0x800 +#define CONFIG_SYS_NAND_PAGE_COUNT 64 +#define CONFIG_SYS_NAND_OOBSIZE 64 +#define CONFIG_SYS_NAND_BLOCK_SIZE 0x20000 +#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0x0 +#define CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER + +#elif CONFIG_SYS_USE_SPIFLASH +#define CONFIG_SPL_SPI_SUPPORT +#define CONFIG_SPL_SPI_FLASH_SUPPORT +#define CONFIG_SPL_SPI_LOAD +#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x8400 + +#endif + #endif -- cgit v0.10.2 From ff255e836a3a6cd52bd51a192af96ac5f224dc22 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Fri, 27 Mar 2015 14:23:36 +0800 Subject: ARM: atmel: at91sam9n12ek: enable spl support Enable SPL support for at91sam9n12ek boards, now it supports boot up from NAND flash, serial flash. Signed-off-by: Bo Shen diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index bdf87f9..30c4e17 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -75,6 +75,7 @@ config TARGET_PM9G45 config TARGET_AT91SAM9N12EK bool "Atmel AT91SAM9N12-EK board" select CPU_ARM926EJS + select SUPPORT_SPL config TARGET_AT91SAM9RLEK bool "Atmel at91sam9rl reference board" diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index ba83616..0d3ee48 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_AT91_WANTS_COMMON_PHY) += phy.o ifneq ($(CONFIG_SPL_BUILD),) obj-$(CONFIG_AT91SAM9G20) += sdram.o spl_at91.o obj-$(CONFIG_AT91SAM9M10G45) += mpddrc.o spl_at91.o +obj-$(CONFIG_AT91SAM9N12) += mpddrc.o spl_at91.o obj-$(CONFIG_AT91SAM9X5) += mpddrc.o spl_at91.o obj-$(CONFIG_SAMA5D3) += mpddrc.o spl_atmel.o obj-$(CONFIG_SAMA5D4) += mpddrc.o spl_atmel.o diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h index c903260..ebb7dec 100644 --- a/arch/arm/mach-at91/include/mach/at91_pmc.h +++ b/arch/arm/mach-at91/include/mach/at91_pmc.h @@ -98,7 +98,7 @@ typedef struct at91_pmc { #define AT91_PMC_MCKR_CSS_MASK 0x00000003 #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \ - defined(CONFIG_AT91SAM9X5) + defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12) #define AT91_PMC_MCKR_PRES_1 0x00000000 #define AT91_PMC_MCKR_PRES_2 0x00000010 #define AT91_PMC_MCKR_PRES_4 0x00000020 @@ -128,7 +128,7 @@ typedef struct at91_pmc { #define AT91_PMC_MCKR_MDIV_1 0x00000000 #define AT91_PMC_MCKR_MDIV_2 0x00000100 #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \ - defined(CONFIG_AT91SAM9X5) + defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12) #define AT91_PMC_MCKR_MDIV_3 0x00000300 #endif #define AT91_PMC_MCKR_MDIV_4 0x00000200 diff --git a/arch/arm/mach-at91/mpddrc.c b/arch/arm/mach-at91/mpddrc.c index 24d5fcd..e2b6a49 100644 --- a/arch/arm/mach-at91/mpddrc.c +++ b/arch/arm/mach-at91/mpddrc.c @@ -20,7 +20,7 @@ static inline void atmel_mpddr_op(int mode, u32 ram_address) static int ddr2_decodtype_is_seq(u32 cr) { #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \ - defined(CONFIG_AT91SAM9X5) + defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12) if (cr & ATMEL_MPDDRC_CR_DECOD_INTERLEAVED) return 0; #endif diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c index e28e568..a79a9dc 100644 --- a/arch/arm/mach-at91/spl_at91.c +++ b/arch/arm/mach-at91/spl_at91.c @@ -115,7 +115,7 @@ void board_init_f(ulong dummy) timer_init(); /* enable clocks for all PIOs */ -#ifdef CONFIG_AT91SAM9X5 +#if defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12) at91_periph_clk_enable(ATMEL_ID_PIOAB); at91_periph_clk_enable(ATMEL_ID_PIOCD); #else diff --git a/board/atmel/at91sam9n12ek/at91sam9n12ek.c b/board/atmel/at91sam9n12ek/at91sam9n12ek.c index 9adc992..4f46a03 100644 --- a/board/atmel/at91sam9n12ek/at91sam9n12ek.c +++ b/board/atmel/at91sam9n12ek/at91sam9n12ek.c @@ -257,3 +257,76 @@ int dram_init(void) CONFIG_SYS_SDRAM_SIZE); return 0; } + +#if defined(CONFIG_SPL_BUILD) +#include +#include + +void at91_spl_board_init(void) +{ +#ifdef CONFIG_SYS_USE_MMC + at91_mci_hw_init(); +#elif CONFIG_SYS_USE_NANDFLASH + at91sam9n12ek_nand_hw_init(); +#elif CONFIG_SYS_USE_SPIFLASH + at91_spi0_hw_init(1 << 4); +#endif +} + +#include +static void ddr2_conf(struct atmel_mpddr *ddr2) +{ + ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM); + + ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 | + ATMEL_MPDDRC_CR_NR_ROW_13 | + ATMEL_MPDDRC_CR_CAS_DDR_CAS3 | + ATMEL_MPDDRC_CR_NB_8BANKS | + ATMEL_MPDDRC_CR_DECOD_INTERLEAVED); + + ddr2->rtr = 0x411; + + ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TWR_OFFSET | + 8 << ATMEL_MPDDRC_TPR0_TRC_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TRP_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET | + 2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET); + + ddr2->tpr1 = (2 << ATMEL_MPDDRC_TPR1_TXP_OFFSET | + 200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET | + 19 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET | + 18 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET); + + ddr2->tpr2 = (2 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET | + 3 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET | + 7 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET | + 2 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET); +} + +void mem_init(void) +{ + struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; + struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX; + struct atmel_mpddr ddr2; + unsigned long csa; + + ddr2_conf(&ddr2); + + /* enable DDR2 clock */ + writel(0x4, &pmc->scer); + + /* Chip select 1 is for DDR2/SDRAM */ + csa = readl(&matrix->ebicsa); + csa |= AT91_MATRIX_EBI_CS1A_SDRAMC; + csa &= ~AT91_MATRIX_EBI_DBPU_OFF; + csa |= AT91_MATRIX_EBI_DBPD_OFF; + csa |= AT91_MATRIX_EBI_EBI_IOSR_NORMAL; + writel(csa, &matrix->ebicsa); + + /* DDRAM2 Controller initialize */ + ddr2_init(ATMEL_BASE_CS1, &ddr2); +} +#endif diff --git a/configs/at91sam9n12ek_nandflash_defconfig b/configs/at91sam9n12ek_nandflash_defconfig index f908246..11b42d4 100644 --- a/configs/at91sam9n12ek_nandflash_defconfig +++ b/configs/at91sam9n12ek_nandflash_defconfig @@ -1,3 +1,4 @@ +CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9N12,SYS_USE_NANDFLASH" CONFIG_ARM=y CONFIG_ARCH_AT91=y diff --git a/configs/at91sam9n12ek_spiflash_defconfig b/configs/at91sam9n12ek_spiflash_defconfig index d106b5a..5426bcd 100644 --- a/configs/at91sam9n12ek_spiflash_defconfig +++ b/configs/at91sam9n12ek_spiflash_defconfig @@ -1,3 +1,4 @@ +CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9N12,SYS_USE_SPIFLASH" CONFIG_ARM=y CONFIG_ARCH_AT91=y diff --git a/include/configs/at91sam9n12ek.h b/include/configs/at91sam9n12ek.h index 058e0e4..c44da1c 100644 --- a/include/configs/at91sam9n12ek.h +++ b/include/configs/at91sam9n12ek.h @@ -239,6 +239,62 @@ * Size of malloc() pool */ #define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024) -#define CONFIG_STACKSIZE (32 * 1024) /* regular stack */ + +/* SPL */ +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_TEXT_BASE 0x300000 +#define CONFIG_SPL_MAX_SIZE 0x6000 +#define CONFIG_SPL_STACK 0x308000 + +#define CONFIG_SPL_BSS_START_ADDR 0x20000000 +#define CONFIG_SPL_BSS_MAX_SIZE 0x80000 +#define CONFIG_SYS_SPL_MALLOC_START 0x20080000 +#define CONFIG_SYS_SPL_MALLOC_SIZE 0x80000 + +#define CONFIG_SPL_LIBCOMMON_SUPPORT +#define CONFIG_SPL_LIBGENERIC_SUPPORT +#define CONFIG_SPL_GPIO_SUPPORT +#define CONFIG_SPL_SERIAL_SUPPORT + +#define CONFIG_SPL_BOARD_INIT +#define CONFIG_SYS_MONITOR_LEN (512 << 10) + +#define CONFIG_SYS_MASTER_CLOCK 132096000 +#define CONFIG_SYS_AT91_PLLA 0x20953f03 +#define CONFIG_SYS_MCKR 0x1301 +#define CONFIG_SYS_MCKR_CSS 0x1302 + +#define ATMEL_BASE_MPDDRC ATMEL_BASE_DDRSDRC + +#ifdef CONFIG_SYS_USE_MMC +#define CONFIG_SPL_LDSCRIPT arch/arm/mach-at91/arm926ejs/u-boot-spl.lds +#define CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400 +#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200 +#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img" +#define CONFIG_SPL_FAT_SUPPORT +#define CONFIG_SPL_LIBDISK_SUPPORT + +#elif CONFIG_SYS_USE_NANDFLASH +#define CONFIG_SPL_NAND_SUPPORT +#define CONFIG_SPL_NAND_DRIVERS +#define CONFIG_SPL_NAND_BASE +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x40000 +#define CONFIG_SYS_NAND_5_ADDR_CYCLE +#define CONFIG_SYS_NAND_PAGE_SIZE 0x800 +#define CONFIG_SYS_NAND_PAGE_COUNT 64 +#define CONFIG_SYS_NAND_OOBSIZE 64 +#define CONFIG_SYS_NAND_BLOCK_SIZE 0x20000 +#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0x0 +#define CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER + +#elif CONFIG_SYS_USE_SPIFLASH +#define CONFIG_SPL_SPI_SUPPORT +#define CONFIG_SPL_SPI_FLASH_SUPPORT +#define CONFIG_SPL_SPI_LOAD +#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x8400 + +#endif #endif -- cgit v0.10.2 From b2d387bcebba352ca64b781486507800964d7ffd Mon Sep 17 00:00:00 2001 From: "Wu, Josh" Date: Mon, 30 Mar 2015 14:51:19 +0800 Subject: ARM: at91: sama5: move the common part of configurations to at91-sama5_common.h Create a new configuration file: at91-sama5_common.h. Which includes the configurations that reused by all SAMA5 chips. at91-sama5_common.h includes: - hw macros (clock, text_base and etc.) - default commands. - BOOTARGS - U-Boot common configs. NOTE: NOR flash definition should be put before including the common header. For sama5d3-xplained: - add CMD_SETEXPR For sama5d3xek: - add CMD_SETEXPR - change CONFIG_SYS_MALLOC_LEN to (4*1024*1024) Signed-off-by: Josh Wu diff --git a/include/configs/at91-sama5_common.h b/include/configs/at91-sama5_common.h new file mode 100644 index 0000000..dedb785 --- /dev/null +++ b/include/configs/at91-sama5_common.h @@ -0,0 +1,87 @@ +/* + * Common part of configuration settings for the AT91 SAMA5 board. + * + * Copyright (C) 2015 Atmel Corporation + * Josh Wu + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __AT91_SAMA5_COMMON_H +#define __AT91_SAMA5_COMMON_H + +#include + +#define CONFIG_SYS_TEXT_BASE 0x26f00000 + +/* ARM asynchronous clock */ +#define CONFIG_SYS_AT91_SLOW_CLOCK 32768 +#define CONFIG_SYS_AT91_MAIN_CLOCK 12000000 /* from 12 MHz crystal */ + +#define CONFIG_ARCH_CPU_INIT + +#ifndef CONFIG_SPL_BUILD +#define CONFIG_SKIP_LOWLEVEL_INIT +#endif + +#define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_DISPLAY_CPUINFO + +#define CONFIG_CMD_BOOTZ +#define CONFIG_OF_LIBFDT /* Device Tree support */ + +#define CONFIG_SYS_GENERIC_BOARD + +/* general purpose I/O */ +#define CONFIG_AT91_GPIO + +#define CONFIG_BOOTDELAY 3 + +/* + * BOOTP options + */ +#define CONFIG_BOOTP_BOOTFILESIZE +#define CONFIG_BOOTP_BOOTPATH +#define CONFIG_BOOTP_GATEWAY +#define CONFIG_BOOTP_HOSTNAME + +/* + * Command line configuration. + */ +#include +#undef CONFIG_CMD_FPGA +#undef CONFIG_CMD_IMI +#undef CONFIG_CMD_LOADS +#define CONFIG_CMD_PING +#define CONFIG_CMD_DHCP +#define CONFIG_CMD_SETEXPR + +#ifdef CONFIG_SYS_USE_MMC +#define CONFIG_BOOTARGS \ + "console=ttyS0,115200 earlyprintk " \ + "root=/dev/mmcblk0p2 rw rootwait" +#else +#define CONFIG_BOOTARGS \ + "console=ttyS0,115200 earlyprintk " \ + "mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro," \ + "256K(env),256k(evn_redundent),256k(spare)," \ + "512k(dtb),6M(kernel)ro,-(rootfs) " \ + "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs" +#endif + +#define CONFIG_BAUDRATE 115200 + +#define CONFIG_SYS_PROMPT "U-Boot> " +#define CONFIG_SYS_CBSIZE 256 +#define CONFIG_SYS_MAXARGS 16 +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ + sizeof(CONFIG_SYS_PROMPT) + 16) +#define CONFIG_SYS_LONGHELP +#define CONFIG_CMDLINE_EDITING +#define CONFIG_AUTO_COMPLETE +#define CONFIG_SYS_HUSH_PARSER + +/* Size of malloc() pool */ +#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024) + +#endif diff --git a/include/configs/sama5d3_xplained.h b/include/configs/sama5d3_xplained.h index c82728e..bfd8aa7 100644 --- a/include/configs/sama5d3_xplained.h +++ b/include/configs/sama5d3_xplained.h @@ -10,30 +10,10 @@ #ifndef __CONFIG_H #define __CONFIG_H -#include - -#define CONFIG_SYS_TEXT_BASE 0x26f00000 - -/* ARM asynchronous clock */ -#define CONFIG_SYS_AT91_SLOW_CLOCK 32768 -#define CONFIG_SYS_AT91_MAIN_CLOCK 12000000 /* from 12 MHz crystal */ - -#define CONFIG_ARCH_CPU_INIT - -#ifndef CONFIG_SPL_BUILD -#define CONFIG_SKIP_LOWLEVEL_INIT -#endif - -#define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_DISPLAY_CPUINFO - -#define CONFIG_CMD_BOOTZ -#define CONFIG_OF_LIBFDT /* Device Tree support */ - -#define CONFIG_SYS_GENERIC_BOARD +/* No NOR flash, this definition should put before common header */ +#define CONFIG_SYS_NO_FLASH -/* general purpose I/O */ -#define CONFIG_AT91_GPIO +#include "at91-sama5_common.h" /* serial console */ #define CONFIG_ATMEL_USART @@ -51,29 +31,6 @@ */ #define ATMEL_PMC_UHP AT91SAM926x_PMC_UHP -#define CONFIG_BOOTDELAY 3 - -/* - * BOOTP options - */ -#define CONFIG_BOOTP_BOOTFILESIZE -#define CONFIG_BOOTP_BOOTPATH -#define CONFIG_BOOTP_GATEWAY -#define CONFIG_BOOTP_HOSTNAME - -/* No NOR flash */ -#define CONFIG_SYS_NO_FLASH - -/* - * Command line configuration. - */ -#include -#undef CONFIG_CMD_FPGA -#undef CONFIG_CMD_IMI -#undef CONFIG_CMD_LOADS -#define CONFIG_CMD_PING -#define CONFIG_CMD_DHCP - /* SDRAM */ #define CONFIG_NR_DRAM_BANKS 1 #define CONFIG_SYS_SDRAM_BASE ATMEL_BASE_DDRCS @@ -181,34 +138,6 @@ #define CONFIG_ENV_IS_NOWHERE #endif -#ifdef CONFIG_SYS_USE_MMC -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk " \ - "root=/dev/mmcblk0p2 rw rootwait" -#else -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk " \ - "mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro," \ - "256K(env),256k(evn_redundent),256k(spare)," \ - "512k(dtb),6M(kernel)ro,-(rootfs) " \ - "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs" -#endif - -#define CONFIG_BAUDRATE 115200 - -#define CONFIG_SYS_PROMPT "U-Boot> " -#define CONFIG_SYS_CBSIZE 256 -#define CONFIG_SYS_MAXARGS 16 -#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ - sizeof(CONFIG_SYS_PROMPT) + 16) -#define CONFIG_SYS_LONGHELP -#define CONFIG_CMDLINE_EDITING -#define CONFIG_AUTO_COMPLETE -#define CONFIG_SYS_HUSH_PARSER - -/* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024) - /* SPL */ #define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_TEXT_BASE 0x300000 diff --git a/include/configs/sama5d3xek.h b/include/configs/sama5d3xek.h index a99b559..d933a9e 100644 --- a/include/configs/sama5d3xek.h +++ b/include/configs/sama5d3xek.h @@ -13,30 +13,11 @@ #ifndef __CONFIG_H #define __CONFIG_H -#include - -#define CONFIG_SYS_TEXT_BASE 0x26f00000 - -/* ARM asynchronous clock */ -#define CONFIG_SYS_AT91_SLOW_CLOCK 32768 -#define CONFIG_SYS_AT91_MAIN_CLOCK 12000000 /* from 12 MHz crystal */ - -#define CONFIG_ARCH_CPU_INIT - -#ifndef CONFIG_SPL_BUILD -#define CONFIG_SKIP_LOWLEVEL_INIT -#endif - -#define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_DISPLAY_CPUINFO - -#define CONFIG_CMD_BOOTZ -#define CONFIG_OF_LIBFDT /* Device Tree support */ - -#define CONFIG_SYS_GENERIC_BOARD - -/* general purpose I/O */ -#define CONFIG_AT91_GPIO +/* + * If has No NOR flash, please put the definition: CONFIG_SYS_NO_FLASH + * before the common header. + */ +#include "at91-sama5_common.h" /* serial console */ #define CONFIG_ATMEL_USART @@ -69,40 +50,17 @@ /* board specific (not enough SRAM) */ #define CONFIG_SAMA5D3_LCD_BASE 0x23E00000 -#define CONFIG_BOOTDELAY 3 - -/* - * BOOTP options - */ -#define CONFIG_BOOTP_BOOTFILESIZE -#define CONFIG_BOOTP_BOOTPATH -#define CONFIG_BOOTP_GATEWAY -#define CONFIG_BOOTP_HOSTNAME - /* NOR flash */ +#ifndef CONFIG_SYS_NO_FLASH #define CONFIG_CMD_FLASH - -#ifdef CONFIG_CMD_FLASH #define CONFIG_FLASH_CFI_DRIVER #define CONFIG_SYS_FLASH_CFI #define CONFIG_SYS_FLASH_PROTECTION #define CONFIG_SYS_FLASH_BASE 0x10000000 #define CONFIG_SYS_MAX_FLASH_SECT 131 #define CONFIG_SYS_MAX_FLASH_BANKS 1 -#else -#define CONFIG_SYS_NO_FLASH #endif -/* - * Command line configuration. - */ -#include -#undef CONFIG_CMD_FPGA -#undef CONFIG_CMD_IMI -#undef CONFIG_CMD_LOADS -#define CONFIG_CMD_PING -#define CONFIG_CMD_DHCP - /* SDRAM */ #define CONFIG_NR_DRAM_BANKS 1 #define CONFIG_SYS_SDRAM_BASE ATMEL_BASE_DDRCS @@ -228,34 +186,6 @@ #define CONFIG_ENV_IS_NOWHERE #endif -#ifdef CONFIG_SYS_USE_MMC -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk " \ - "root=/dev/mmcblk0p2 rw rootwait" -#else -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk " \ - "mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro," \ - "256K(env),256k(evn_redundent),256k(spare)," \ - "512k(dtb),6M(kernel)ro,-(rootfs) " \ - "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs" -#endif - -#define CONFIG_BAUDRATE 115200 - -#define CONFIG_SYS_PROMPT "U-Boot> " -#define CONFIG_SYS_CBSIZE 256 -#define CONFIG_SYS_MAXARGS 16 -#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ - sizeof(CONFIG_SYS_PROMPT) + 16) -#define CONFIG_SYS_LONGHELP -#define CONFIG_CMDLINE_EDITING -#define CONFIG_AUTO_COMPLETE -#define CONFIG_SYS_HUSH_PARSER - -/* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (1024 * 1024) - /* SPL */ #define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_TEXT_BASE 0x300000 diff --git a/include/configs/sama5d4_xplained.h b/include/configs/sama5d4_xplained.h index 4cb0761..5fb621e 100644 --- a/include/configs/sama5d4_xplained.h +++ b/include/configs/sama5d4_xplained.h @@ -10,59 +10,16 @@ #ifndef __CONFIG_H #define __CONFIG_H -#include - -#define CONFIG_SYS_TEXT_BASE 0x26f00000 - -/* ARM asynchronous clock */ -#define CONFIG_SYS_AT91_SLOW_CLOCK 32768 -#define CONFIG_SYS_AT91_MAIN_CLOCK 12000000 /* from 12 MHz crystal */ - -#define CONFIG_ARCH_CPU_INIT - -#ifndef CONFIG_SPL_BUILD -#define CONFIG_SKIP_LOWLEVEL_INIT -#endif -#define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_DISPLAY_CPUINFO - -#define CONFIG_CMD_BOOTZ -#define CONFIG_OF_LIBFDT /* Device Tree support */ - -#define CONFIG_SYS_GENERIC_BOARD +/* No NOR flash, this definition should put before common header */ +#define CONFIG_SYS_NO_FLASH -/* general purpose I/O */ -#define CONFIG_AT91_GPIO +#include "at91-sama5_common.h" /* serial console */ #define CONFIG_ATMEL_USART #define CONFIG_USART_BASE ATMEL_BASE_USART3 #define CONFIG_USART_ID ATMEL_ID_USART3 -#define CONFIG_BOOTDELAY 3 - -/* - * BOOTP options - */ -#define CONFIG_BOOTP_BOOTFILESIZE -#define CONFIG_BOOTP_BOOTPATH -#define CONFIG_BOOTP_GATEWAY -#define CONFIG_BOOTP_HOSTNAME - -/* No NOR flash */ -#define CONFIG_SYS_NO_FLASH - -/* - * Command line configuration. - */ -#include -#undef CONFIG_CMD_FPGA -#undef CONFIG_CMD_IMI -#undef CONFIG_CMD_LOADS -#define CONFIG_CMD_PING -#define CONFIG_CMD_DHCP -#define CONFIG_CMD_SETEXPR - /* SDRAM */ #define CONFIG_NR_DRAM_BANKS 1 #define CONFIG_SYS_SDRAM_BASE ATMEL_BASE_DDRCS @@ -199,33 +156,6 @@ "bootz 0x22000000 - 0x21000000" #endif -#ifdef CONFIG_SYS_USE_MMC -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk " \ - "root=/dev/mmcblk0p2 rw rootwait" -#else -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk " \ - "mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro," \ - "256K(env),256k(evn_redundent),256k(spare)," \ - "512k(dtb),6M(kernel)ro,-(rootfs) " \ - "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs" -#endif - -#define CONFIG_BAUDRATE 115200 - -#define CONFIG_SYS_PROMPT "U-Boot> " -#define CONFIG_SYS_CBSIZE 256 -#define CONFIG_SYS_MAXARGS 16 -#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ - sizeof(CONFIG_SYS_PROMPT) + 16) -#define CONFIG_SYS_LONGHELP -#define CONFIG_CMDLINE_EDITING -#define CONFIG_AUTO_COMPLETE -#define CONFIG_SYS_HUSH_PARSER - -/* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024) /* SPL */ diff --git a/include/configs/sama5d4ek.h b/include/configs/sama5d4ek.h index 897d481..546d7a3 100644 --- a/include/configs/sama5d4ek.h +++ b/include/configs/sama5d4ek.h @@ -10,59 +10,16 @@ #ifndef __CONFIG_H #define __CONFIG_H -#include - -#define CONFIG_SYS_TEXT_BASE 0x26f00000 - -/* ARM asynchronous clock */ -#define CONFIG_SYS_AT91_SLOW_CLOCK 32768 -#define CONFIG_SYS_AT91_MAIN_CLOCK 12000000 /* from 12 MHz crystal */ - -#define CONFIG_ARCH_CPU_INIT - -#ifndef CONFIG_SPL_BUILD -#define CONFIG_SKIP_LOWLEVEL_INIT -#endif -#define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_DISPLAY_CPUINFO - -#define CONFIG_CMD_BOOTZ -#define CONFIG_OF_LIBFDT /* Device Tree support */ - -#define CONFIG_SYS_GENERIC_BOARD +/* No NOR flash, this definition should put before common header */ +#define CONFIG_SYS_NO_FLASH -/* general purpose I/O */ -#define CONFIG_AT91_GPIO +#include "at91-sama5_common.h" /* serial console */ #define CONFIG_ATMEL_USART #define CONFIG_USART_BASE ATMEL_BASE_USART3 #define CONFIG_USART_ID ATMEL_ID_USART3 -#define CONFIG_BOOTDELAY 3 - -/* - * BOOTP options - */ -#define CONFIG_BOOTP_BOOTFILESIZE -#define CONFIG_BOOTP_BOOTPATH -#define CONFIG_BOOTP_GATEWAY -#define CONFIG_BOOTP_HOSTNAME - -/* No NOR flash */ -#define CONFIG_SYS_NO_FLASH - -/* - * Command line configuration. - */ -#include -#undef CONFIG_CMD_FPGA -#undef CONFIG_CMD_IMI -#undef CONFIG_CMD_LOADS -#define CONFIG_CMD_PING -#define CONFIG_CMD_DHCP -#define CONFIG_CMD_SETEXPR - /* SDRAM */ #define CONFIG_NR_DRAM_BANKS 1 #define CONFIG_SYS_SDRAM_BASE ATMEL_BASE_DDRCS @@ -197,35 +154,6 @@ "bootz 0x22000000 - 0x21000000" #endif -#ifdef CONFIG_SYS_USE_MMC -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk " \ - "root=/dev/mmcblk0p2 rw rootwait" -#else -#define CONFIG_BOOTARGS \ - "console=ttyS0,115200 earlyprintk " \ - "mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro," \ - "256K(env),256k(evn_redundent),256k(spare)," \ - "512k(dtb),6M(kernel)ro,-(rootfs) " \ - "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs" -#endif - -#define CONFIG_BAUDRATE 115200 - -#define CONFIG_SYS_PROMPT "U-Boot> " -#define CONFIG_SYS_CBSIZE 256 -#define CONFIG_SYS_MAXARGS 16 -#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ - sizeof(CONFIG_SYS_PROMPT) + 16) -#define CONFIG_SYS_LONGHELP -#define CONFIG_CMDLINE_EDITING -#define CONFIG_AUTO_COMPLETE -#define CONFIG_SYS_HUSH_PARSER - -/* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024) - - /* SPL */ #define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_TEXT_BASE 0x200000 -- cgit v0.10.2 From 8a5c9ca4d0b8aa13a1bb321494d24f656a9a7d72 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 31 Mar 2015 20:53:59 -0400 Subject: Prepare v2015.04-rc5 Signed-off-by: Tom Rini diff --git a/Makefile b/Makefile index 0d160c9..f1bce44 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 2015 PATCHLEVEL = 04 SUBLEVEL = -EXTRAVERSION = -rc4 +EXTRAVERSION = -rc5 NAME = # *DOCUMENTATION* -- cgit v0.10.2 From 36d68668e33191d55b2a23c9f0ec0c1ffecd6897 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 24 Feb 2015 19:31:51 +0300 Subject: serial/serial_arc: set registers address during compilation Being global variable with 0 value it falls into .bss area which we may only use after relocation to RAM. And right afetr relocation we zero .bss - effectively cleaing register address set for early console. Now with pre-set value "regs" variable is no longer in .bss and this way safely survives relocation. Signed-off-by: Alexey Brodkin diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 2ddbf32..0ee8ce5 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -28,7 +28,7 @@ struct arc_serial_regs { #define UART_OVERFLOW_ERR (1 << 1) #define UART_TXEMPTY (1 << 7) -struct arc_serial_regs *regs; +struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_ARC_UART_BASE; static void arc_serial_setbrg(void) { @@ -60,7 +60,6 @@ static void arc_serial_setbrg(void) static int arc_serial_init(void) { - regs = (struct arc_serial_regs *)CONFIG_ARC_UART_BASE; serial_setbrg(); return 0; } -- cgit v0.10.2 From ae4a351ad9e3b800e8eb55b27c302d8be256540e Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Fri, 27 Mar 2015 12:47:29 +0300 Subject: arc: cache - build invalidate_icache_all() and invalidate_dcache_all() always Make both invalidate_icache_all() and invalidate_dcache_all() available even if U-Boot is configured with CONFIG_SYS_DCACHE_OFF and/or CONFIG_SYS_ICACHE_OFF. This is useful because configuration of U-Boot may not match actual hardware features. Real board may have cache(s) but for some reason we may want to run U-Boot with cache(s) disabled (for example if some peripherals work improperly with existing drivers if data cache is enabled). So board may start with cache(s) enabled (that's the case for ARC cores with built-in caches) but early in U-Boot we disable cache(s) and make sure all contents of data cache gets flushed in RAM. Signed-off-by: Alexey Brodkin diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c index a227723..30f045a 100644 --- a/arch/arc/lib/cache.c +++ b/arch/arc/lib/cache.c @@ -49,10 +49,12 @@ void icache_disable(void) void invalidate_icache_all(void) { -#ifndef CONFIG_SYS_ICACHE_OFF + /* If no cache in CPU exit immediately */ + if (!(read_aux_reg(ARC_BCR_IC_BUILD) & CACHE_VER_NUM_MASK)) + return; + /* Any write to IC_IVIC register triggers invalidation of entire I$ */ write_aux_reg(ARC_AUX_IC_IVIC, 1); -#endif /* CONFIG_SYS_ICACHE_OFF */ } int dcache_status(void) @@ -156,10 +158,12 @@ void invalidate_dcache_range(unsigned long start, unsigned long end) void invalidate_dcache_all(void) { -#ifndef CONFIG_SYS_DCACHE_OFF + /* If no cache in CPU exit immediately */ + if (!(read_aux_reg(ARC_BCR_DC_BUILD) & CACHE_VER_NUM_MASK)) + return; + /* Write 1 to DC_IVDC register triggers invalidation of entire D$ */ write_aux_reg(ARC_AUX_DC_IVDC, 1); -#endif /* CONFIG_SYS_DCACHE_OFF */ } void flush_cache(unsigned long start, unsigned long size) -- cgit v0.10.2 From 4d93617d87285f01f450a30584520369ff3585d2 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Thu, 19 Feb 2015 18:40:58 +0300 Subject: arc: merge common start-up code between ARC and ARCv2 Even though ARCompact and ARCv2 are not binary compatible most of assembly instructions are used in both. With this change we'll get rid of duplicate code. Still IVTs are implemented differently so we're keeping them in separate files. Signed-off-by: Alexey Brodkin diff --git a/arch/arc/cpu/arcv1/Makefile b/arch/arc/cpu/arcv1/Makefile index 3704ebe..6d17ab2 100644 --- a/arch/arc/cpu/arcv1/Makefile +++ b/arch/arc/cpu/arcv1/Makefile @@ -4,4 +4,4 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += start.o +obj-y += ivt.o diff --git a/arch/arc/cpu/arcv1/ivt.S b/arch/arc/cpu/arcv1/ivt.S new file mode 100644 index 0000000..7df47a2 --- /dev/null +++ b/arch/arc/cpu/arcv1/ivt.S @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +.section .ivt, "ax",@progbits +.align 4 +_ivt: + /* Critical system events */ + j _start /* 0 - 0x000 */ + j memory_error /* 1 - 0x008 */ + j instruction_error /* 2 - 0x010 */ + + /* Device interrupts */ +.rept 29 + j interrupt_handler /* 3:31 - 0x018:0xF8 */ +.endr + /* Exceptions */ + j EV_MachineCheck /* 0x100, Fatal Machine check (0x20) */ + j EV_TLBMissI /* 0x108, Intruction TLB miss (0x21) */ + j EV_TLBMissD /* 0x110, Data TLB miss (0x22) */ + j EV_TLBProtV /* 0x118, Protection Violation (0x23) + or Misaligned Access */ + j EV_PrivilegeV /* 0x120, Privilege Violation (0x24) */ + j EV_Trap /* 0x128, Trap exception (0x25) */ + j EV_Extension /* 0x130, Extn Intruction Excp (0x26) */ diff --git a/arch/arc/cpu/arcv1/start.S b/arch/arc/cpu/arcv1/start.S deleted file mode 100644 index 01cfba4..0000000 --- a/arch/arc/cpu/arcv1/start.S +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include - -/* - * Note on the LD/ST addressing modes with address register write-back - * - * LD.a same as LD.aw - * - * LD.a reg1, [reg2, x] => Pre Incr - * Eff Addr for load = [reg2 + x] - * - * LD.ab reg1, [reg2, x] => Post Incr - * Eff Addr for load = [reg2] - */ - -.macro PUSH reg - st.a \reg, [%sp, -4] -.endm - -.macro PUSHAX aux - lr %r9, [\aux] - PUSH %r9 -.endm - -.macro SAVE_R1_TO_R24 - PUSH %r1 - PUSH %r2 - PUSH %r3 - PUSH %r4 - PUSH %r5 - PUSH %r6 - PUSH %r7 - PUSH %r8 - PUSH %r9 - PUSH %r10 - PUSH %r11 - PUSH %r12 - PUSH %r13 - PUSH %r14 - PUSH %r15 - PUSH %r16 - PUSH %r17 - PUSH %r18 - PUSH %r19 - PUSH %r20 - PUSH %r21 - PUSH %r22 - PUSH %r23 - PUSH %r24 -.endm - -.macro SAVE_ALL_SYS - /* saving %r0 to reg->r0 in advance since we read %ecr into it */ - st %r0, [%sp, -8] - lr %r0, [%ecr] /* all stack addressing is manual so far */ - st %r0, [%sp] - st %sp, [%sp, -4] - /* now move %sp to reg->r0 position so we can do "push" automatically */ - sub %sp, %sp, 8 - - SAVE_R1_TO_R24 - PUSH %r25 - PUSH %gp - PUSH %fp - PUSH %blink - PUSHAX %eret - PUSHAX %erstatus - PUSH %lp_count - PUSHAX %lp_end - PUSHAX %lp_start - PUSHAX %erbta -.endm - -.macro SAVE_EXCEPTION_SOURCE -#ifdef CONFIG_MMU - /* If MMU exists exception faulting address is loaded in EFA reg */ - lr %r0, [%efa] -#else - /* Otherwise in ERET (exception return) reg */ - lr %r0, [%eret] -#endif -.endm - -.section .ivt, "ax",@progbits -.align 4 -_ivt: - /* Critical system events */ - j _start /* 0 - 0x000 */ - j memory_error /* 1 - 0x008 */ - j instruction_error /* 2 - 0x010 */ - - /* Device interrupts */ -.rept 29 - j interrupt_handler /* 3:31 - 0x018:0xF8 */ -.endr - /* Exceptions */ - j EV_MachineCheck /* 0x100, Fatal Machine check (0x20) */ - j EV_TLBMissI /* 0x108, Intruction TLB miss (0x21) */ - j EV_TLBMissD /* 0x110, Data TLB miss (0x22) */ - j EV_TLBProtV /* 0x118, Protection Violation (0x23) - or Misaligned Access */ - j EV_PrivilegeV /* 0x120, Privilege Violation (0x24) */ - j EV_Trap /* 0x128, Trap exception (0x25) */ - j EV_Extension /* 0x130, Extn Intruction Excp (0x26) */ - -.text -.globl _start -_start: - /* Setup interrupt vector base that matches "__text_start" */ - sr __ivt_start, [ARC_AUX_INTR_VEC_BASE] - - /* Setup stack pointer */ - mov %sp, CONFIG_SYS_INIT_SP_ADDR - mov %fp, %sp - - /* Clear bss */ - mov %r0, __bss_start - mov %r1, __bss_end - -clear_bss: - st.ab 0, [%r0, 4] - brlt %r0, %r1, clear_bss - - /* Zero the one and only argument of "board_init_f" */ - mov_s %r0, 0 - j board_init_f - -memory_error: - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_memory_error - -instruction_error: - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_instruction_error - -interrupt_handler: - /* Todo - save and restore CPU context when interrupts will be in use */ - bl do_interrupt_handler - rtie - -EV_MachineCheck: - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_machine_check_fault - -EV_TLBMissI: - SAVE_ALL_SYS - mov %r0, %sp - j do_itlb_miss - -EV_TLBMissD: - SAVE_ALL_SYS - mov %r0, %sp - j do_dtlb_miss - -EV_TLBProtV: - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_tlb_prot_violation - -EV_PrivilegeV: - SAVE_ALL_SYS - mov %r0, %sp - j do_privilege_violation - -EV_Trap: - SAVE_ALL_SYS - mov %r0, %sp - j do_trap - -EV_Extension: - SAVE_ALL_SYS - mov %r0, %sp - j do_extension - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - * r0 = start_addr_sp - * r1 = new__gd - * r2 = relocaddr - */ -.align 4 -.globl relocate_code -relocate_code: - /* - * r0-r12 might be clobbered by C functions - * so we use r13-r16 for storage here - */ - mov %r13, %r0 /* save addr_sp */ - mov %r14, %r1 /* save addr of gd */ - mov %r15, %r2 /* save addr of destination */ - - mov %r16, %r2 /* %r9 - relocation offset */ - sub %r16, %r16, __image_copy_start - -/* Set up the stack */ -stack_setup: - mov %sp, %r13 - mov %fp, %sp - -/* Check if monitor is loaded right in place for relocation */ - mov %r0, __image_copy_start - cmp %r0, %r15 /* skip relocation if code loaded */ - bz do_board_init_r /* in target location already */ - -/* Copy data (__image_copy_start - __image_copy_end) to new location */ - mov %r1, %r15 - mov %r2, __image_copy_end - sub %r2, %r2, %r0 /* r3 <- amount of bytes to copy */ - asr %r2, %r2, 2 /* r3 <- amount of words to copy */ - mov %lp_count, %r2 - lp copy_end - ld.ab %r2,[%r0,4] - st.ab %r2,[%r1,4] -copy_end: - -/* Fix relocations related issues */ - bl do_elf_reloc_fixups -#ifndef CONFIG_SYS_ICACHE_OFF - bl invalidate_icache_all -#endif -#ifndef CONFIG_SYS_DCACHE_OFF - bl flush_dcache_all -#endif - -/* Update position of intterupt vector table */ - lr %r0, [ARC_AUX_INTR_VEC_BASE] /* Read current position */ - add %r0, %r0, %r16 /* Update address */ - sr %r0, [ARC_AUX_INTR_VEC_BASE] /* Write new position */ - -do_board_init_r: -/* Prepare for exection of "board_init_r" in relocated monitor */ - mov %r2, board_init_r /* old address of "board_init_r()" */ - add %r2, %r2, %r16 /* new address of "board_init_r()" */ - mov %r0, %r14 /* 1-st parameter: gd_t */ - mov %r1, %r15 /* 2-nd parameter: dest_addr */ - j [%r2] diff --git a/arch/arc/cpu/arcv2/Makefile b/arch/arc/cpu/arcv2/Makefile index cc69e5a..e338a0a 100644 --- a/arch/arc/cpu/arcv2/Makefile +++ b/arch/arc/cpu/arcv2/Makefile @@ -4,4 +4,4 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += start.o +obj-y += ivt.o diff --git a/arch/arc/cpu/arcv2/ivt.S b/arch/arc/cpu/arcv2/ivt.S new file mode 100644 index 0000000..d110b5b --- /dev/null +++ b/arch/arc/cpu/arcv2/ivt.S @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +.section .ivt, "a",@progbits +.align 4 + /* Critical system events */ +.word _start /* 0 - 0x000 */ +.word memory_error /* 1 - 0x008 */ +.word instruction_error /* 2 - 0x010 */ + + /* Exceptions */ +.word EV_MachineCheck /* 0x100, Fatal Machine check (0x20) */ +.word EV_TLBMissI /* 0x108, Intruction TLB miss (0x21) */ +.word EV_TLBMissD /* 0x110, Data TLB miss (0x22) */ +.word EV_TLBProtV /* 0x118, Protection Violation (0x23) + or Misaligned Access */ +.word EV_PrivilegeV /* 0x120, Privilege Violation (0x24) */ +.word EV_Trap /* 0x128, Trap exception (0x25) */ +.word EV_Extension /* 0x130, Extn Intruction Excp (0x26) */ + + /* Device interrupts */ +.rept 29 + j interrupt_handler /* 3:31 - 0x018:0xF8 */ +.endr diff --git a/arch/arc/cpu/arcv2/start.S b/arch/arc/cpu/arcv2/start.S deleted file mode 100644 index 3ce6896..0000000 --- a/arch/arc/cpu/arcv2/start.S +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include - -/* - * Note on the LD/ST addressing modes with address register write-back - * - * LD.a same as LD.aw - * - * LD.a reg1, [reg2, x] => Pre Incr - * Eff Addr for load = [reg2 + x] - * - * LD.ab reg1, [reg2, x] => Post Incr - * Eff Addr for load = [reg2] - */ - -.macro PUSH reg - st.a \reg, [%sp, -4] -.endm - -.macro PUSHAX aux - lr %r9, [\aux] - PUSH %r9 -.endm - -.macro SAVE_R1_TO_R24 - PUSH %r1 - PUSH %r2 - PUSH %r3 - PUSH %r4 - PUSH %r5 - PUSH %r6 - PUSH %r7 - PUSH %r8 - PUSH %r9 - PUSH %r10 - PUSH %r11 - PUSH %r12 - PUSH %r13 - PUSH %r14 - PUSH %r15 - PUSH %r16 - PUSH %r17 - PUSH %r18 - PUSH %r19 - PUSH %r20 - PUSH %r21 - PUSH %r22 - PUSH %r23 - PUSH %r24 -.endm - -.macro SAVE_ALL_SYS - /* saving %r0 to reg->r0 in advance since weread %ecr into it */ - st %r0, [%sp, -8] - lr %r0, [%ecr] /* all stack addressing is manual so far */ - st %r0, [%sp] - st %sp, [%sp, -4] - /* now move %sp to reg->r0 position so we can do "push" automatically */ - sub %sp, %sp, 8 - - SAVE_R1_TO_R24 - PUSH %r25 - PUSH %gp - PUSH %fp - PUSH %blink - PUSHAX %eret - PUSHAX %erstatus - PUSH %lp_count - PUSHAX %lp_end - PUSHAX %lp_start - PUSHAX %erbta -.endm - -.macro SAVE_EXCEPTION_SOURCE -#ifdef CONFIG_MMU - /* If MMU exists exception faulting address is loaded in EFA reg */ - lr %r0, [%efa] -#else - /* Otherwise in ERET (exception return) reg */ - lr %r0, [%eret] -#endif -.endm - -.section .ivt, "a",@progbits -.align 4 - /* Critical system events */ -.word _start /* 0 - 0x000 */ -.word memory_error /* 1 - 0x008 */ -.word instruction_error /* 2 - 0x010 */ - - /* Exceptions */ -.word EV_MachineCheck /* 0x100, Fatal Machine check (0x20) */ -.word EV_TLBMissI /* 0x108, Intruction TLB miss (0x21) */ -.word EV_TLBMissD /* 0x110, Data TLB miss (0x22) */ -.word EV_TLBProtV /* 0x118, Protection Violation (0x23) - or Misaligned Access */ -.word EV_PrivilegeV /* 0x120, Privilege Violation (0x24) */ -.word EV_Trap /* 0x128, Trap exception (0x25) */ -.word EV_Extension /* 0x130, Extn Intruction Excp (0x26) */ - - /* Device interrupts */ -.rept 29 - j interrupt_handler /* 3:31 - 0x018:0xF8 */ -.endr - -.text -.globl _start -_start: - /* Setup interrupt vector base that matches "__text_start" */ - sr __ivt_start, [ARC_AUX_INTR_VEC_BASE] - - /* Setup stack pointer */ - mov %sp, CONFIG_SYS_INIT_SP_ADDR - mov %fp, %sp - - /* Clear bss */ - mov %r0, __bss_start - mov %r1, __bss_end - -clear_bss: - st.ab 0, [%r0, 4] - brlt %r0, %r1, clear_bss - - /* Zero the one and only argument of "board_init_f" */ - mov_s %r0, 0 - j board_init_f - -memory_error: - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_memory_error - -instruction_error: - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_instruction_error - -interrupt_handler: - /* Todo - save and restore CPU context when interrupts will be in use */ - bl do_interrupt_handler - rtie - -EV_MachineCheck: - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_machine_check_fault - -EV_TLBMissI: - SAVE_ALL_SYS - mov %r0, %sp - j do_itlb_miss - -EV_TLBMissD: - SAVE_ALL_SYS - mov %r0, %sp - j do_dtlb_miss - -EV_TLBProtV: - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_tlb_prot_violation - -EV_PrivilegeV: - SAVE_ALL_SYS - mov %r0, %sp - j do_privilege_violation - -EV_Trap: - SAVE_ALL_SYS - mov %r0, %sp - j do_trap - -EV_Extension: - SAVE_ALL_SYS - mov %r0, %sp - j do_extension - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - * r0 = start_addr_sp - * r1 = new__gd - * r2 = relocaddr - */ -.align 4 -.globl relocate_code -relocate_code: - /* - * r0-r12 might be clobbered by C functions - * so we use r13-r16 for storage here - */ - mov %r13, %r0 /* save addr_sp */ - mov %r14, %r1 /* save addr of gd */ - mov %r15, %r2 /* save addr of destination */ - - mov %r16, %r2 /* %r9 - relocation offset */ - sub %r16, %r16, __image_copy_start - -/* Set up the stack */ -stack_setup: - mov %sp, %r13 - mov %fp, %sp - -/* Check if monitor is loaded right in place for relocation */ - mov %r0, __image_copy_start - cmp %r0, %r15 /* skip relocation if code loaded */ - bz do_board_init_r /* in target location already */ - -/* Copy data (__image_copy_start - __image_copy_end) to new location */ - mov %r1, %r15 - mov %r2, __image_copy_end - sub %r2, %r2, %r0 /* r3 <- amount of bytes to copy */ - asr %r2, %r2, 2 /* r3 <- amount of words to copy */ - mov %lp_count, %r2 - lp copy_end - ld.ab %r2,[%r0,4] - st.ab %r2,[%r1,4] -copy_end: - -/* Fix relocations related issues */ - bl do_elf_reloc_fixups -#ifndef CONFIG_SYS_ICACHE_OFF - bl invalidate_icache_all -#endif -#ifndef CONFIG_SYS_DCACHE_OFF - bl flush_dcache_all -#endif - -/* Update position of intterupt vector table */ - lr %r0, [ARC_AUX_INTR_VEC_BASE] /* Read current position */ - add %r0, %r0, %r16 /* Update address */ - sr %r0, [ARC_AUX_INTR_VEC_BASE] /* Write new position */ - -do_board_init_r: -/* Prepare for exection of "board_init_r" in relocated monitor */ - mov %r2, board_init_r /* old address of "board_init_r()" */ - add %r2, %r2, %r16 /* new address of "board_init_r()" */ - mov %r0, %r14 /* 1-st parameter: gd_t */ - mov %r1, %r15 /* 2-nd parameter: dest_addr */ - j [%r2] diff --git a/arch/arc/lib/Makefile b/arch/arc/lib/Makefile index b8028c9..ad66ac2 100644 --- a/arch/arc/lib/Makefile +++ b/arch/arc/lib/Makefile @@ -18,6 +18,7 @@ obj-y += memcpy-700.o obj-y += memset.o obj-y += reset.o obj-y += timer.o +obj-y += start.o obj-$(CONFIG_CMD_BOOTM) += bootm.o diff --git a/arch/arc/lib/start.S b/arch/arc/lib/start.S new file mode 100644 index 0000000..39eace3 --- /dev/null +++ b/arch/arc/lib/start.S @@ -0,0 +1,241 @@ +/* + * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include + +/* + * Note on the LD/ST addressing modes with address register write-back + * + * LD.a same as LD.aw + * + * LD.a reg1, [reg2, x] => Pre Incr + * Eff Addr for load = [reg2 + x] + * + * LD.ab reg1, [reg2, x] => Post Incr + * Eff Addr for load = [reg2] + */ + +.macro PUSH reg + st.a \reg, [%sp, -4] +.endm + +.macro PUSHAX aux + lr %r9, [\aux] + PUSH %r9 +.endm + +.macro SAVE_R1_TO_R24 + PUSH %r1 + PUSH %r2 + PUSH %r3 + PUSH %r4 + PUSH %r5 + PUSH %r6 + PUSH %r7 + PUSH %r8 + PUSH %r9 + PUSH %r10 + PUSH %r11 + PUSH %r12 + PUSH %r13 + PUSH %r14 + PUSH %r15 + PUSH %r16 + PUSH %r17 + PUSH %r18 + PUSH %r19 + PUSH %r20 + PUSH %r21 + PUSH %r22 + PUSH %r23 + PUSH %r24 +.endm + +.macro SAVE_ALL_SYS + /* saving %r0 to reg->r0 in advance since we read %ecr into it */ + st %r0, [%sp, -8] + lr %r0, [%ecr] /* all stack addressing is manual so far */ + st %r0, [%sp] + st %sp, [%sp, -4] + /* now move %sp to reg->r0 position so we can do "push" automatically */ + sub %sp, %sp, 8 + + SAVE_R1_TO_R24 + PUSH %r25 + PUSH %gp + PUSH %fp + PUSH %blink + PUSHAX %eret + PUSHAX %erstatus + PUSH %lp_count + PUSHAX %lp_end + PUSHAX %lp_start + PUSHAX %erbta +.endm + +.macro SAVE_EXCEPTION_SOURCE +#ifdef CONFIG_MMU + /* If MMU exists exception faulting address is loaded in EFA reg */ + lr %r0, [%efa] +#else + /* Otherwise in ERET (exception return) reg */ + lr %r0, [%eret] +#endif +.endm + +ENTRY(_start) + /* Setup interrupt vector base that matches "__text_start" */ + sr __ivt_start, [ARC_AUX_INTR_VEC_BASE] + + /* Setup stack pointer */ + mov %sp, CONFIG_SYS_INIT_SP_ADDR + mov %fp, %sp + + /* Clear bss */ + mov %r0, __bss_start + mov %r1, __bss_end + +clear_bss: + st.ab 0, [%r0, 4] + brlt %r0, %r1, clear_bss + + /* Zero the one and only argument of "board_init_f" */ + mov_s %r0, 0 + j board_init_f +ENDPROC(_start) + +ENTRY(memory_error) + SAVE_ALL_SYS + SAVE_EXCEPTION_SOURCE + mov %r1, %sp + j do_memory_error +ENDPROC(memory_error) + +ENTRY(instruction_error) + SAVE_ALL_SYS + SAVE_EXCEPTION_SOURCE + mov %r1, %sp + j do_instruction_error +ENDPROC(instruction_error) + +ENTRY(interrupt_handler) + /* Todo - save and restore CPU context when interrupts will be in use */ + bl do_interrupt_handler + rtie +ENDPROC(interrupt_handler) + +ENTRY(EV_MachineCheck) + SAVE_ALL_SYS + SAVE_EXCEPTION_SOURCE + mov %r1, %sp + j do_machine_check_fault +ENDPROC(EV_MachineCheck) + +ENTRY(EV_TLBMissI) + SAVE_ALL_SYS + mov %r0, %sp + j do_itlb_miss +ENDPROC(EV_TLBMissI) + +ENTRY(EV_TLBMissD) + SAVE_ALL_SYS + mov %r0, %sp + j do_dtlb_miss +ENDPROC(EV_TLBMissD) + +ENTRY(EV_TLBProtV) + SAVE_ALL_SYS + SAVE_EXCEPTION_SOURCE + mov %r1, %sp + j do_tlb_prot_violation +ENDPROC(EV_TLBProtV) + +ENTRY(EV_PrivilegeV) + SAVE_ALL_SYS + mov %r0, %sp + j do_privilege_violation +ENDPROC(EV_PrivilegeV) + +ENTRY(EV_Trap) + SAVE_ALL_SYS + mov %r0, %sp + j do_trap +ENDPROC(EV_Trap) + +ENTRY(EV_Extension) + SAVE_ALL_SYS + mov %r0, %sp + j do_extension +ENDPROC(EV_Extension) + +/* + * void relocate_code (addr_sp, gd, addr_moni) + * + * This "function" does not return, instead it continues in RAM + * after relocating the monitor code. + * + * r0 = start_addr_sp + * r1 = new__gd + * r2 = relocaddr + */ +ENTRY(relocate_code) + /* + * r0-r12 might be clobbered by C functions + * so we use r13-r16 for storage here + */ + mov %r13, %r0 /* save addr_sp */ + mov %r14, %r1 /* save addr of gd */ + mov %r15, %r2 /* save addr of destination */ + + mov %r16, %r2 /* %r9 - relocation offset */ + sub %r16, %r16, __image_copy_start + +/* Set up the stack */ +stack_setup: + mov %sp, %r13 + mov %fp, %sp + +/* Check if monitor is loaded right in place for relocation */ + mov %r0, __image_copy_start + cmp %r0, %r15 /* skip relocation if code loaded */ + bz do_board_init_r /* in target location already */ + +/* Copy data (__image_copy_start - __image_copy_end) to new location */ + mov %r1, %r15 + mov %r2, __image_copy_end + sub %r2, %r2, %r0 /* r3 <- amount of bytes to copy */ + asr %r2, %r2, 2 /* r3 <- amount of words to copy */ + mov %lp_count, %r2 + lp copy_end + ld.ab %r2,[%r0,4] + st.ab %r2,[%r1,4] +copy_end: + +/* Fix relocations related issues */ + bl do_elf_reloc_fixups +#ifndef CONFIG_SYS_ICACHE_OFF + bl invalidate_icache_all +#endif +#ifndef CONFIG_SYS_DCACHE_OFF + bl flush_dcache_all +#endif + +/* Update position of intterupt vector table */ + lr %r0, [ARC_AUX_INTR_VEC_BASE] /* Read current position */ + add %r0, %r0, %r16 /* Update address */ + sr %r0, [ARC_AUX_INTR_VEC_BASE] /* Write new position */ + +do_board_init_r: +/* Prepare for exection of "board_init_r" in relocated monitor */ + mov %r2, board_init_r /* old address of "board_init_r()" */ + add %r2, %r2, %r16 /* new address of "board_init_r()" */ + mov %r0, %r14 /* 1-st parameter: gd_t */ + mov %r1, %r15 /* 2-nd parameter: dest_addr */ + j [%r2] +ENDPROC(relocate_code) -- cgit v0.10.2 From 8ee28251d95e237302c7c44929e59a813e147622 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 24 Feb 2015 17:08:44 +0300 Subject: arc: move low-level interrupt and exception handlers in a separate file This separation makes maintenance of code easier because those low-level interrupt- or exception handling routines are pretty static and usually require not much care while start-up code is a subject of modifications and enhancements. Signed-off-by: Alexey Brodkin diff --git a/arch/arc/lib/Makefile b/arch/arc/lib/Makefile index ad66ac2..b1f1fbe 100644 --- a/arch/arc/lib/Makefile +++ b/arch/arc/lib/Makefile @@ -19,6 +19,7 @@ obj-y += memset.o obj-y += reset.o obj-y += timer.o obj-y += start.o +obj-y += ints_low.o obj-$(CONFIG_CMD_BOOTM) += bootm.o diff --git a/arch/arc/lib/ints_low.S b/arch/arc/lib/ints_low.S new file mode 100644 index 0000000..161cf37 --- /dev/null +++ b/arch/arc/lib/ints_low.S @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include + +/* + * Note on the LD/ST addressing modes with address register write-back + * + * LD.a same as LD.aw + * + * LD.a reg1, [reg2, x] => Pre Incr + * Eff Addr for load = [reg2 + x] + * + * LD.ab reg1, [reg2, x] => Post Incr + * Eff Addr for load = [reg2] + */ + +.macro PUSH reg + st.a \reg, [%sp, -4] +.endm + +.macro PUSHAX aux + lr %r9, [\aux] + PUSH %r9 +.endm + +.macro SAVE_R1_TO_R24 + PUSH %r1 + PUSH %r2 + PUSH %r3 + PUSH %r4 + PUSH %r5 + PUSH %r6 + PUSH %r7 + PUSH %r8 + PUSH %r9 + PUSH %r10 + PUSH %r11 + PUSH %r12 + PUSH %r13 + PUSH %r14 + PUSH %r15 + PUSH %r16 + PUSH %r17 + PUSH %r18 + PUSH %r19 + PUSH %r20 + PUSH %r21 + PUSH %r22 + PUSH %r23 + PUSH %r24 +.endm + +.macro SAVE_ALL_SYS + /* saving %r0 to reg->r0 in advance since we read %ecr into it */ + st %r0, [%sp, -8] + lr %r0, [%ecr] /* all stack addressing is manual so far */ + st %r0, [%sp] + st %sp, [%sp, -4] + /* now move %sp to reg->r0 position so we can do "push" automatically */ + sub %sp, %sp, 8 + + SAVE_R1_TO_R24 + PUSH %r25 + PUSH %gp + PUSH %fp + PUSH %blink + PUSHAX %eret + PUSHAX %erstatus + PUSH %lp_count + PUSHAX %lp_end + PUSHAX %lp_start + PUSHAX %erbta +.endm + +.macro SAVE_EXCEPTION_SOURCE +#ifdef CONFIG_MMU + /* If MMU exists exception faulting address is loaded in EFA reg */ + lr %r0, [%efa] +#else + /* Otherwise in ERET (exception return) reg */ + lr %r0, [%eret] +#endif +.endm + +ENTRY(memory_error) + SAVE_ALL_SYS + SAVE_EXCEPTION_SOURCE + mov %r1, %sp + j do_memory_error +ENDPROC(memory_error) + +ENTRY(instruction_error) + SAVE_ALL_SYS + SAVE_EXCEPTION_SOURCE + mov %r1, %sp + j do_instruction_error +ENDPROC(instruction_error) + +ENTRY(interrupt_handler) + /* Todo - save and restore CPU context when interrupts will be in use */ + bl do_interrupt_handler + rtie +ENDPROC(interrupt_handler) + +ENTRY(EV_MachineCheck) + SAVE_ALL_SYS + SAVE_EXCEPTION_SOURCE + mov %r1, %sp + j do_machine_check_fault +ENDPROC(EV_MachineCheck) + +ENTRY(EV_TLBMissI) + SAVE_ALL_SYS + mov %r0, %sp + j do_itlb_miss +ENDPROC(EV_TLBMissI) + +ENTRY(EV_TLBMissD) + SAVE_ALL_SYS + mov %r0, %sp + j do_dtlb_miss +ENDPROC(EV_TLBMissD) + +ENTRY(EV_TLBProtV) + SAVE_ALL_SYS + SAVE_EXCEPTION_SOURCE + mov %r1, %sp + j do_tlb_prot_violation +ENDPROC(EV_TLBProtV) + +ENTRY(EV_PrivilegeV) + SAVE_ALL_SYS + mov %r0, %sp + j do_privilege_violation +ENDPROC(EV_PrivilegeV) + +ENTRY(EV_Trap) + SAVE_ALL_SYS + mov %r0, %sp + j do_trap +ENDPROC(EV_Trap) + +ENTRY(EV_Extension) + SAVE_ALL_SYS + mov %r0, %sp + j do_extension +ENDPROC(EV_Extension) diff --git a/arch/arc/lib/start.S b/arch/arc/lib/start.S index 39eace3..3408f45 100644 --- a/arch/arc/lib/start.S +++ b/arch/arc/lib/start.S @@ -9,86 +9,6 @@ #include #include -/* - * Note on the LD/ST addressing modes with address register write-back - * - * LD.a same as LD.aw - * - * LD.a reg1, [reg2, x] => Pre Incr - * Eff Addr for load = [reg2 + x] - * - * LD.ab reg1, [reg2, x] => Post Incr - * Eff Addr for load = [reg2] - */ - -.macro PUSH reg - st.a \reg, [%sp, -4] -.endm - -.macro PUSHAX aux - lr %r9, [\aux] - PUSH %r9 -.endm - -.macro SAVE_R1_TO_R24 - PUSH %r1 - PUSH %r2 - PUSH %r3 - PUSH %r4 - PUSH %r5 - PUSH %r6 - PUSH %r7 - PUSH %r8 - PUSH %r9 - PUSH %r10 - PUSH %r11 - PUSH %r12 - PUSH %r13 - PUSH %r14 - PUSH %r15 - PUSH %r16 - PUSH %r17 - PUSH %r18 - PUSH %r19 - PUSH %r20 - PUSH %r21 - PUSH %r22 - PUSH %r23 - PUSH %r24 -.endm - -.macro SAVE_ALL_SYS - /* saving %r0 to reg->r0 in advance since we read %ecr into it */ - st %r0, [%sp, -8] - lr %r0, [%ecr] /* all stack addressing is manual so far */ - st %r0, [%sp] - st %sp, [%sp, -4] - /* now move %sp to reg->r0 position so we can do "push" automatically */ - sub %sp, %sp, 8 - - SAVE_R1_TO_R24 - PUSH %r25 - PUSH %gp - PUSH %fp - PUSH %blink - PUSHAX %eret - PUSHAX %erstatus - PUSH %lp_count - PUSHAX %lp_end - PUSHAX %lp_start - PUSHAX %erbta -.endm - -.macro SAVE_EXCEPTION_SOURCE -#ifdef CONFIG_MMU - /* If MMU exists exception faulting address is loaded in EFA reg */ - lr %r0, [%efa] -#else - /* Otherwise in ERET (exception return) reg */ - lr %r0, [%eret] -#endif -.endm - ENTRY(_start) /* Setup interrupt vector base that matches "__text_start" */ sr __ivt_start, [ARC_AUX_INTR_VEC_BASE] @@ -110,70 +30,6 @@ clear_bss: j board_init_f ENDPROC(_start) -ENTRY(memory_error) - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_memory_error -ENDPROC(memory_error) - -ENTRY(instruction_error) - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_instruction_error -ENDPROC(instruction_error) - -ENTRY(interrupt_handler) - /* Todo - save and restore CPU context when interrupts will be in use */ - bl do_interrupt_handler - rtie -ENDPROC(interrupt_handler) - -ENTRY(EV_MachineCheck) - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_machine_check_fault -ENDPROC(EV_MachineCheck) - -ENTRY(EV_TLBMissI) - SAVE_ALL_SYS - mov %r0, %sp - j do_itlb_miss -ENDPROC(EV_TLBMissI) - -ENTRY(EV_TLBMissD) - SAVE_ALL_SYS - mov %r0, %sp - j do_dtlb_miss -ENDPROC(EV_TLBMissD) - -ENTRY(EV_TLBProtV) - SAVE_ALL_SYS - SAVE_EXCEPTION_SOURCE - mov %r1, %sp - j do_tlb_prot_violation -ENDPROC(EV_TLBProtV) - -ENTRY(EV_PrivilegeV) - SAVE_ALL_SYS - mov %r0, %sp - j do_privilege_violation -ENDPROC(EV_PrivilegeV) - -ENTRY(EV_Trap) - SAVE_ALL_SYS - mov %r0, %sp - j do_trap -ENDPROC(EV_Trap) - -ENTRY(EV_Extension) - SAVE_ALL_SYS - mov %r0, %sp - j do_extension -ENDPROC(EV_Extension) - /* * void relocate_code (addr_sp, gd, addr_moni) * -- cgit v0.10.2 From 3fb8016360d5433f3c4da51f8dd57550e7ef9018 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 24 Feb 2015 19:40:36 +0300 Subject: arc: clean-up init procedure Intention behind this work was elimination of as much assembly-written code as it is possible. In case of ARC we already have relocation fix-up implemented in C so why don't we use C for U-Boot copying, .bss zeroing etc. It turned out x86 uses pretty similar approach so we re-used parts of code in "board_f.c" initially implemented for x86. Now assembly usage during init is limited to stack- and frame-pointer setup before and after relocation. Signed-off-by: Alexey Brodkin Cc: Simon Glass diff --git a/arch/arc/include/asm/init_helpers.h b/arch/arc/include/asm/init_helpers.h new file mode 100644 index 0000000..7607e19 --- /dev/null +++ b/arch/arc/include/asm/init_helpers.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _ASM_ARC_INIT_HELPERS_H +#define _ASM_ARC_INIT_HELPERS_H + +int init_cache_f_r(void); + +#endif /* _ASM_ARC_INIT_HELPERS_H */ diff --git a/arch/arc/include/asm/relocate.h b/arch/arc/include/asm/relocate.h new file mode 100644 index 0000000..4c5f923 --- /dev/null +++ b/arch/arc/include/asm/relocate.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _ASM_ARC_RELOCATE_H +#define _ASM_ARC_RELOCATE_H + +#include + +int copy_uboot_to_ram(void); +int clear_bss(void); +int do_elf_reloc_fixups(void); + +#endif /* _ASM_ARC_RELOCATE_H */ diff --git a/arch/arc/include/asm/u-boot-arc.h b/arch/arc/include/asm/u-boot-arc.h index 0c0e8e6..a56ccf1 100644 --- a/arch/arc/include/asm/u-boot-arc.h +++ b/arch/arc/include/asm/u-boot-arc.h @@ -9,4 +9,7 @@ int arch_early_init_r(void); +void board_init_f_r_trampoline(ulong) __attribute__ ((noreturn)); +void board_init_f_r(void) __attribute__ ((noreturn)); + #endif /* __ASM_ARC_U_BOOT_ARC_H__ */ diff --git a/arch/arc/lib/Makefile b/arch/arc/lib/Makefile index b1f1fbe..b887904 100644 --- a/arch/arc/lib/Makefile +++ b/arch/arc/lib/Makefile @@ -20,6 +20,7 @@ obj-y += reset.o obj-y += timer.o obj-y += start.o obj-y += ints_low.o +obj-y += init_helpers.o obj-$(CONFIG_CMD_BOOTM) += bootm.o diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c index 50634b8..3c930bc 100644 --- a/arch/arc/lib/cpu.c +++ b/arch/arc/lib/cpu.c @@ -12,19 +12,6 @@ DECLARE_GLOBAL_DATA_PTR; int arch_cpu_init(void) { -#ifdef CONFIG_SYS_ICACHE_OFF - icache_disable(); -#else - icache_enable(); - invalidate_icache_all(); -#endif - - flush_dcache_all(); -#ifdef CONFIG_SYS_DCACHE_OFF - dcache_disable(); -#else - dcache_enable(); -#endif timer_init(); /* In simulation (ISS) "CHIPID" and "ARCNUM" are all "ff" */ diff --git a/arch/arc/lib/init_helpers.c b/arch/arc/lib/init_helpers.c new file mode 100644 index 0000000..25690ee --- /dev/null +++ b/arch/arc/lib/init_helpers.c @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include + +DECLARE_GLOBAL_DATA_PTR; + +int init_cache_f_r(void) +{ +#ifndef CONFIG_SYS_ICACHE_OFF + icache_enable(); + /* Make sure no stale entries persist from before we disabled cache */ + invalidate_icache_all(); +#endif + +#ifndef CONFIG_SYS_DCACHE_OFF + dcache_enable(); + /* Make sure no stale entries persist from before we disabled cache */ + invalidate_dcache_all(); +#endif + return 0; +} diff --git a/arch/arc/lib/relocate.c b/arch/arc/lib/relocate.c index 7797782..5c2c2d1 100644 --- a/arch/arc/lib/relocate.c +++ b/arch/arc/lib/relocate.c @@ -10,6 +10,25 @@ DECLARE_GLOBAL_DATA_PTR; +int copy_uboot_to_ram(void) +{ + size_t len = (size_t)&__image_copy_end - (size_t)&__image_copy_start; + + memcpy((void *)gd->relocaddr, (void *)&__image_copy_start, len); + + return 0; +} + +int clear_bss(void) +{ + ulong dst_addr = (ulong)&__bss_start + gd->reloc_off; + size_t len = (size_t)&__bss_end - (size_t)&__bss_start; + + memset((void *)dst_addr, 0x00, len); + + return 0; +} + /* * Base functionality is taken from x86 version with added ARC-specifics */ diff --git a/arch/arc/lib/start.S b/arch/arc/lib/start.S index 3408f45..82045ae 100644 --- a/arch/arc/lib/start.S +++ b/arch/arc/lib/start.S @@ -13,17 +13,14 @@ ENTRY(_start) /* Setup interrupt vector base that matches "__text_start" */ sr __ivt_start, [ARC_AUX_INTR_VEC_BASE] - /* Setup stack pointer */ + /* Setup stack- and frame-pointers */ mov %sp, CONFIG_SYS_INIT_SP_ADDR mov %fp, %sp - /* Clear bss */ - mov %r0, __bss_start - mov %r1, __bss_end - -clear_bss: - st.ab 0, [%r0, 4] - brlt %r0, %r1, clear_bss + /* Unconditionally disable caches */ + bl flush_dcache_all + bl dcache_disable + bl icache_disable /* Zero the one and only argument of "board_init_f" */ mov_s %r0, 0 @@ -31,67 +28,24 @@ clear_bss: ENDPROC(_start) /* - * void relocate_code (addr_sp, gd, addr_moni) + * void board_init_f_r_trampoline(stack-pointer address) * * This "function" does not return, instead it continues in RAM * after relocating the monitor code. * - * r0 = start_addr_sp - * r1 = new__gd - * r2 = relocaddr + * r0 = new stack-pointer */ -ENTRY(relocate_code) - /* - * r0-r12 might be clobbered by C functions - * so we use r13-r16 for storage here - */ - mov %r13, %r0 /* save addr_sp */ - mov %r14, %r1 /* save addr of gd */ - mov %r15, %r2 /* save addr of destination */ - - mov %r16, %r2 /* %r9 - relocation offset */ - sub %r16, %r16, __image_copy_start - -/* Set up the stack */ -stack_setup: - mov %sp, %r13 +ENTRY(board_init_f_r_trampoline) + /* Set up the stack- and frame-pointers */ + mov %sp, %r0 mov %fp, %sp -/* Check if monitor is loaded right in place for relocation */ - mov %r0, __image_copy_start - cmp %r0, %r15 /* skip relocation if code loaded */ - bz do_board_init_r /* in target location already */ - -/* Copy data (__image_copy_start - __image_copy_end) to new location */ - mov %r1, %r15 - mov %r2, __image_copy_end - sub %r2, %r2, %r0 /* r3 <- amount of bytes to copy */ - asr %r2, %r2, 2 /* r3 <- amount of words to copy */ - mov %lp_count, %r2 - lp copy_end - ld.ab %r2,[%r0,4] - st.ab %r2,[%r1,4] -copy_end: - -/* Fix relocations related issues */ - bl do_elf_reloc_fixups -#ifndef CONFIG_SYS_ICACHE_OFF - bl invalidate_icache_all -#endif -#ifndef CONFIG_SYS_DCACHE_OFF - bl flush_dcache_all -#endif - -/* Update position of intterupt vector table */ - lr %r0, [ARC_AUX_INTR_VEC_BASE] /* Read current position */ - add %r0, %r0, %r16 /* Update address */ - sr %r0, [ARC_AUX_INTR_VEC_BASE] /* Write new position */ + /* Update position of intterupt vector table */ + lr %r0, [ARC_AUX_INTR_VEC_BASE] + ld %r1, [%r25, GD_RELOC_OFF] + add %r0, %r0, %r1 + sr %r0, [ARC_AUX_INTR_VEC_BASE] -do_board_init_r: -/* Prepare for exection of "board_init_r" in relocated monitor */ - mov %r2, board_init_r /* old address of "board_init_r()" */ - add %r2, %r2, %r16 /* new address of "board_init_r()" */ - mov %r0, %r14 /* 1-st parameter: gd_t */ - mov %r1, %r15 /* 2-nd parameter: dest_addr */ - j [%r2] -ENDPROC(relocate_code) + /* Re-enter U-Boot by calling board_init_f_r */ + j board_init_f_r +ENDPROC(board_init_f_r_trampoline) diff --git a/common/board_f.c b/common/board_f.c index f7ffa54..cb956b8 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -47,7 +47,7 @@ #include #include #include -#ifdef CONFIG_X86 +#if defined(CONFIG_X86) || defined(CONFIG_ARC) #include #include #endif @@ -761,7 +761,7 @@ static int jump_to_copy(void) * similarly for all archs. When we do generic relocation, hopefully * we can make all archs enable the dcache prior to relocation. */ -#ifdef CONFIG_X86 +#if defined(CONFIG_X86) || defined(CONFIG_ARC) /* * SDRAM and console are now initialised. The final stack can now * be setup in SDRAM. Code execution will continue in Flash, but @@ -997,7 +997,7 @@ static init_fnc_t init_sequence_f[] = { INIT_FUNC_WATCHDOG_RESET reloc_fdt, setup_reloc, -#ifdef CONFIG_X86 +#if defined(CONFIG_X86) || defined(CONFIG_ARC) copy_uboot_to_ram, clear_bss, do_elf_reloc_fixups, @@ -1041,7 +1041,7 @@ void board_init_f(ulong boot_flags) #endif } -#ifdef CONFIG_X86 +#if defined(CONFIG_X86) || defined(CONFIG_ARC) /* * For now this code is only used on x86. * -- cgit v0.10.2 From 97ee47bdaba7421261d8568cd517f89275a42319 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 17 Mar 2015 14:30:59 +0300 Subject: arc: re-generate defconfigs Before that moment our defconfigs were manually modified with addition of new options. That means once anybody wants to add another option and re-genarate defconfig with "make defconfig" there will be lots of differences. So to make future modifications more clean we'll do bulk re-generation right away. Signed-off-by: Alexey Brodkin diff --git a/configs/arcangel4-be_defconfig b/configs/arcangel4-be_defconfig index 979f26e..990c74a 100644 --- a/configs/arcangel4-be_defconfig +++ b/configs/arcangel4-be_defconfig @@ -1,5 +1,5 @@ CONFIG_ARC=y -CONFIG_TARGET_ARCANGEL4=y -CONFIG_SYS_CLK_FREQ=70000000 CONFIG_CPU_BIG_ENDIAN=y +CONFIG_TARGET_ARCANGEL4=y CONFIG_SYS_TEXT_BASE=0x81000000 +CONFIG_SYS_CLK_FREQ=70000000 diff --git a/configs/arcangel4_defconfig b/configs/arcangel4_defconfig index 797595f..fbc0ffe 100644 --- a/configs/arcangel4_defconfig +++ b/configs/arcangel4_defconfig @@ -1,4 +1,4 @@ CONFIG_ARC=y CONFIG_TARGET_ARCANGEL4=y -CONFIG_SYS_CLK_FREQ=70000000 CONFIG_SYS_TEXT_BASE=0x81000000 +CONFIG_SYS_CLK_FREQ=70000000 diff --git a/configs/axs101_defconfig b/configs/axs101_defconfig index 34ed963..e5e1d87 100644 --- a/configs/axs101_defconfig +++ b/configs/axs101_defconfig @@ -1,6 +1,6 @@ CONFIG_ARC=y +CONFIG_SYS_DCACHE_OFF=y +CONFIG_ARC_CACHE_LINE_SHIFT=5 CONFIG_TARGET_AXS101=y +CONFIG_SYS_TEXT_BASE=0x81000000 CONFIG_SYS_CLK_FREQ=750000000 -CONFIG_ARC_CACHE_LINE_SHIFT=5 -CONFIG_SYS_DCACHE_OFF=y -CONFIG_SYS_TEXT_BASE=0x81000000 \ No newline at end of file diff --git a/configs/axs103_defconfig b/configs/axs103_defconfig index c63dd4a..7d662ad 100644 --- a/configs/axs103_defconfig +++ b/configs/axs103_defconfig @@ -1,5 +1,5 @@ -CONFIG_SYS_TEXT_BASE=0x81000000 -CONFIG_SYS_CLK_FREQ=50000000 CONFIG_ARC=y CONFIG_ISA_ARCV2=y CONFIG_TARGET_AXS101=y +CONFIG_SYS_TEXT_BASE=0x81000000 +CONFIG_SYS_CLK_FREQ=50000000 diff --git a/configs/tb100_defconfig b/configs/tb100_defconfig index b0e8c9f..c964272 100644 --- a/configs/tb100_defconfig +++ b/configs/tb100_defconfig @@ -1,5 +1,5 @@ CONFIG_ARC=y -CONFIG_TARGET_TB100=y -CONFIG_SYS_CLK_FREQ=500000000 CONFIG_ARC_CACHE_LINE_SHIFT=5 +CONFIG_TARGET_TB100=y CONFIG_SYS_TEXT_BASE=0x84000000 +CONFIG_SYS_CLK_FREQ=500000000 -- cgit v0.10.2 From f56d625ee07a1ffb424e6c9278dd84b534e0bc1e Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Wed, 25 Feb 2015 18:10:18 +0300 Subject: arc: get rid of CONFIG_SYS_GENERIC_GLOBAL_DATA As discussed on mailing list we're drifting away from CONFIG_SYS_GENERIC_GLOBAL_DATA in favour to use of board_init_f_mem() for global data. So do this for ARC architecture. Signed-off-by: Alexey Brodkin diff --git a/arch/arc/include/asm/config.h b/arch/arc/include/asm/config.h index 8936f5c..d2d7919 100644 --- a/arch/arc/include/asm/config.h +++ b/arch/arc/include/asm/config.h @@ -7,7 +7,6 @@ #ifndef __ASM_ARC_CONFIG_H_ #define __ASM_ARC_CONFIG_H_ -#define CONFIG_SYS_GENERIC_GLOBAL_DATA #define CONFIG_SYS_BOOT_RAMDISK_HIGH #define CONFIG_ARCH_EARLY_INIT_R diff --git a/arch/arc/lib/start.S b/arch/arc/lib/start.S index 82045ae..48ee86e 100644 --- a/arch/arc/lib/start.S +++ b/arch/arc/lib/start.S @@ -22,6 +22,14 @@ ENTRY(_start) bl dcache_disable bl icache_disable + /* Allocate and zero GD, update SP */ + mov %r0, %sp + bl board_init_f_mem + + /* Update stack- and frame-pointers */ + mov %sp, %r0 + mov %fp, %sp + /* Zero the one and only argument of "board_init_f" */ mov_s %r0, 0 j board_init_f -- cgit v0.10.2 From b903792e4492a710d6a58ccd136c9b3a2f684180 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 17 Mar 2015 14:26:43 +0300 Subject: arc: minor fixes in Kconfig [1] Fix misspeling in ARC_CACHE_LINE_SHIFT dependency, now cache-line lenth selection is correctly enabled if either I$ or D$ are enabled. [2] Add dummy entry to target list to make sure target type is always mentioned in defconfig. Otherwise defconfig for the first target in the list will not have target name and later on with addition of the new target on top of the list in Kconfig will lead to corrupted configuration expanded from defconfig. Signed-off-by: Alexey Brodkin diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 24f5c02..c044ad4 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -123,7 +123,7 @@ config ARC_CACHE_LINE_SHIFT int "Cache Line Length (as power of 2)" range 5 7 default "6" - depends on !SYS_DCACHE_OFF || !SYS_DCACHE_OFF + depends on !SYS_DCACHE_OFF || !SYS_ICACHE_OFF help Starting with ARC700 4.9, Cache line length is configurable, This option specifies "N", with Line-len = 2 power N @@ -133,6 +133,14 @@ config ARC_CACHE_LINE_SHIFT choice prompt "Target select" +config TARGET_DUMMY + bool "Dummy target" + help + Please select one of real target boards below! + This target is only meant to force "makedefconfig" to put + TARGET_xxx in defconfig even this is the first target from the list + below. + config TARGET_TB100 bool "Support tb100" -- cgit v0.10.2 From 01496c4fac227221e67d93cb9cc14f48fb98a2b6 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 17 Mar 2015 14:55:14 +0300 Subject: serial-arc: switch to DM Now when all infrastructure in ARC is ready for it let's switch ARC UART to driver model. Signed-off-by: Alexey Brodkin Cc: Masahiro Yamada Cc: Simon Glass diff --git a/arch/Kconfig b/arch/Kconfig index ca617e7..2ca5305 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -14,6 +14,7 @@ config ARC select HAVE_PRIVATE_LIBGCC select HAVE_GENERIC_BOARD select SYS_GENERIC_BOARD + select SUPPORT_OF_CONTROL config ARM bool "ARM architecture" diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile new file mode 100644 index 0000000..a155311 --- /dev/null +++ b/arch/arc/dts/Makefile @@ -0,0 +1,11 @@ +dtb-$(CONFIG_TARGET_ARCANGEL4) += arcangel4.dtb + +targets += $(dtb-y) + +DTC_FLAGS += -R 4 -p 0x1000 + +PHONY += dtbs +dtbs: $(addprefix $(obj)/, $(dtb-y)) + @: + +clean-files := *.dtb diff --git a/arch/arc/dts/arcangel4.dts b/arch/arc/dts/arcangel4.dts new file mode 100644 index 0000000..bfcb9d8 --- /dev/null +++ b/arch/arc/dts/arcangel4.dts @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 Synopsys, Inc. (www.synopsys.com) + * + * SPDX-License-Identifier: GPL-2.0+ + */ +/dts-v1/; + +#include "skeleton.dtsi" + +/ { + #address-cells = <1>; + #size-cells = <1>; + + aliases { + console = &arcuart0; + }; + + arcuart0: serial@0xc0fc1000 { + compatible = "snps,arc-uart"; + reg = <0xc0fc1000 0x100>; + clock-frequency = <80000000>; + }; + +}; diff --git a/arch/arc/dts/skeleton.dtsi b/arch/arc/dts/skeleton.dtsi new file mode 100644 index 0000000..b41d241 --- /dev/null +++ b/arch/arc/dts/skeleton.dtsi @@ -0,0 +1,13 @@ +/* + * Skeleton device tree; the bare minimum needed to boot; just include and + * add a compatible value. The bootloader will typically populate the memory + * node. + */ + +/ { + #address-cells = <1>; + #size-cells = <1>; + chosen { }; + aliases { }; + memory { device_type = "memory"; reg = <0 0>; }; +}; diff --git a/configs/arcangel4-be_defconfig b/configs/arcangel4-be_defconfig index 990c74a..36ea6be 100644 --- a/configs/arcangel4-be_defconfig +++ b/configs/arcangel4-be_defconfig @@ -1,5 +1,10 @@ CONFIG_ARC=y CONFIG_CPU_BIG_ENDIAN=y CONFIG_TARGET_ARCANGEL4=y +CONFIG_DM=y +CONFIG_DM_SERIAL=y +CONFIG_DEFAULT_DEVICE_TREE="arcangel4" CONFIG_SYS_TEXT_BASE=0x81000000 CONFIG_SYS_CLK_FREQ=70000000 +CONFIG_OF_CONTROL=y +CONFIG_OF_EMBED=y diff --git a/configs/arcangel4_defconfig b/configs/arcangel4_defconfig index fbc0ffe..75a91c8 100644 --- a/configs/arcangel4_defconfig +++ b/configs/arcangel4_defconfig @@ -1,4 +1,9 @@ CONFIG_ARC=y CONFIG_TARGET_ARCANGEL4=y +CONFIG_DM=y +CONFIG_DM_SERIAL=y +CONFIG_DEFAULT_DEVICE_TREE="arcangel4" CONFIG_SYS_TEXT_BASE=0x81000000 CONFIG_SYS_CLK_FREQ=70000000 +CONFIG_OF_CONTROL=y +CONFIG_OF_EMBED=y diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 0ee8ce5..54e596c 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -8,6 +8,7 @@ */ #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -23,21 +24,23 @@ struct arc_serial_regs { unsigned int baudh; }; + +struct arc_serial_platdata { + struct arc_serial_regs *reg; + unsigned int uartclk; +}; + /* Bit definitions of STATUS register */ #define UART_RXEMPTY (1 << 5) #define UART_OVERFLOW_ERR (1 << 1) #define UART_TXEMPTY (1 << 7) -struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_ARC_UART_BASE; - -static void arc_serial_setbrg(void) +static int arc_serial_setbrg(struct udevice *dev, int baudrate) { - int arc_console_baud; + struct arc_serial_platdata *plat = dev->platdata; + struct arc_serial_regs *const regs = plat->reg; + int arc_console_baud = gd->cpu_clk / (baudrate * 4) - 1; - if (!gd->baudrate) - gd->baudrate = CONFIG_BAUDRATE; - - arc_console_baud = gd->cpu_clk / (gd->baudrate * 4) - 1; writeb(arc_console_baud & 0xff, ®s->baudl); #ifdef CONFIG_ARC @@ -56,33 +59,49 @@ static void arc_serial_setbrg(void) #else writeb((arc_console_baud & 0xff00) >> 8, ®s->baudh); #endif -} -static int arc_serial_init(void) -{ - serial_setbrg(); return 0; } -static void arc_serial_putc(const char c) +static int arc_serial_putc(struct udevice *dev, const char c) { + struct arc_serial_platdata *plat = dev->platdata; + struct arc_serial_regs *const regs = plat->reg; + if (c == '\n') - arc_serial_putc('\r'); + arc_serial_putc(dev, '\r'); while (!(readb(®s->status) & UART_TXEMPTY)) ; writeb(c, ®s->data); + + return 0; } -static int arc_serial_tstc(void) +static int arc_serial_tstc(struct arc_serial_regs *const regs) { return !(readb(®s->status) & UART_RXEMPTY); } -static int arc_serial_getc(void) +static int arc_serial_pending(struct udevice *dev, bool input) +{ + struct arc_serial_platdata *plat = dev->platdata; + struct arc_serial_regs *const regs = plat->reg; + uint32_t status = readb(®s->status); + + if (input) + return status & UART_RXEMPTY ? 0 : 1; + else + return status & UART_TXEMPTY ? 0 : 1; +} + +static int arc_serial_getc(struct udevice *dev) { - while (!arc_serial_tstc()) + struct arc_serial_platdata *plat = dev->platdata; + struct arc_serial_regs *const regs = plat->reg; + + while (!arc_serial_tstc(regs)) ; /* Check for overflow errors */ @@ -92,23 +111,42 @@ static int arc_serial_getc(void) return readb(®s->data) & 0xFF; } -static struct serial_device arc_serial_drv = { - .name = "arc_serial", - .start = arc_serial_init, - .stop = NULL, - .setbrg = arc_serial_setbrg, - .putc = arc_serial_putc, - .puts = default_serial_puts, - .getc = arc_serial_getc, - .tstc = arc_serial_tstc, -}; - -void arc_serial_initialize(void) +static int arc_serial_probe(struct udevice *dev) { - serial_register(&arc_serial_drv); + return 0; } -__weak struct serial_device *default_serial_console(void) +static const struct dm_serial_ops arc_serial_ops = { + .putc = arc_serial_putc, + .pending = arc_serial_pending, + .getc = arc_serial_getc, + .setbrg = arc_serial_setbrg, +}; + +static const struct udevice_id arc_serial_ids[] = { + { .compatible = "snps,arc-uart" }, + { } +}; + +static int arc_serial_ofdata_to_platdata(struct udevice *dev) { - return &arc_serial_drv; + struct arc_serial_platdata *plat = dev_get_platdata(dev); + DECLARE_GLOBAL_DATA_PTR; + + plat->reg = (struct arc_serial_regs *)fdtdec_get_addr(gd->fdt_blob, + dev->of_offset, "reg"); + plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + "clock-frequency", 0); + + return 0; } + +U_BOOT_DRIVER(serial_arc) = { + .name = "serial_arc", + .id = UCLASS_SERIAL, + .of_match = arc_serial_ids, + .ofdata_to_platdata = arc_serial_ofdata_to_platdata, + .probe = arc_serial_probe, + .ops = &arc_serial_ops, + .flags = DM_FLAG_PRE_RELOC, +}; -- cgit v0.10.2 From 09424d11192cffd4793b7bc922c5b47d4fe88a4d Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Fri, 27 Mar 2015 13:24:35 +0300 Subject: board: Switch Abilis TB-100 board to Driver Model for serial port Signed-off-by: Alexey Brodkin Cc: Masahiro Yamada Cc: Simon Glass diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile index a155311..5bc6f44 100644 --- a/arch/arc/dts/Makefile +++ b/arch/arc/dts/Makefile @@ -1,4 +1,5 @@ dtb-$(CONFIG_TARGET_ARCANGEL4) += arcangel4.dtb +dtb-$(CONFIG_TARGET_TB100) += abilis_tb100.dtb targets += $(dtb-y) diff --git a/arch/arc/dts/abilis_tb100.dts b/arch/arc/dts/abilis_tb100.dts new file mode 100644 index 0000000..cf395c4 --- /dev/null +++ b/arch/arc/dts/abilis_tb100.dts @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 Synopsys, Inc. (www.synopsys.com) + * + * SPDX-License-Identifier: GPL-2.0+ + */ +/dts-v1/; + +#include "skeleton.dtsi" + +/ { + #address-cells = <1>; + #size-cells = <1>; + + aliases { + console = &uart0; + }; + + uart0: serial@ff100000 { + compatible = "snps,dw-apb-uart"; + reg = <0xff100000 0x1000>; + reg-shift = <2>; + reg-io-width = <4>; + }; +}; diff --git a/configs/tb100_defconfig b/configs/tb100_defconfig index c964272..59f09d9 100644 --- a/configs/tb100_defconfig +++ b/configs/tb100_defconfig @@ -1,5 +1,10 @@ CONFIG_ARC=y CONFIG_ARC_CACHE_LINE_SHIFT=5 CONFIG_TARGET_TB100=y +CONFIG_DM=y +CONFIG_DM_SERIAL=y +CONFIG_DEFAULT_DEVICE_TREE="abilis_tb100" CONFIG_SYS_TEXT_BASE=0x84000000 CONFIG_SYS_CLK_FREQ=500000000 +CONFIG_OF_CONTROL=y +CONFIG_OF_EMBED=y diff --git a/include/configs/tb100.h b/include/configs/tb100.h index 46df406..501449a 100644 --- a/include/configs/tb100.h +++ b/include/configs/tb100.h @@ -35,14 +35,10 @@ /* * UART configuration */ -#define CONFIG_CONS_INDEX 1 +#define CONFIG_DW_SERIAL #define CONFIG_SYS_NS16550 #define CONFIG_SYS_NS16550_SERIAL -#define CONFIG_SYS_NS16550_REG_SIZE -4 #define CONFIG_SYS_NS16550_CLK 166666666 -#define CONFIG_SYS_NS16550_COM1 0xFF100000 -#define CONFIG_SYS_NS16550_MEM32 - #define CONFIG_BAUDRATE 115200 /* -- cgit v0.10.2 From 6eb15e50f48927c65a67371555b5afc24b3c7d21 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Mon, 30 Mar 2015 13:36:04 +0300 Subject: arc: add support for SLC (System Level Cache, AKA L2-cache) ARCv2 cores may have built-in SLC (System Level Cache, AKA L2-cache). This change adds functions required for controlling SLC: * slc_enable/disable * slc_flush/invalidate For now we just disable SLC to escape DMA coherency issues until either: * SLC flush/invalidate is supported in DMA APIin U-Boot * hardware DMA coherency is implemented (that might be board specific so probably we'll need to have a separate Kconfig option for controlling SLC explicitly) Signed-off-by: Alexey Brodkin diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h index 6a36a81..0e11dcc 100644 --- a/arch/arc/include/asm/arcregs.h +++ b/arch/arc/include/asm/arcregs.h @@ -46,6 +46,10 @@ #define ARC_AUX_DC_PTAG 0x5C #endif #define ARC_BCR_DC_BUILD 0x72 +#define ARC_BCR_SLC 0xce +#define ARC_AUX_SLC_CONTROL 0x903 +#define ARC_AUX_SLC_FLUSH 0x904 +#define ARC_AUX_SLC_INVALIDATE 0x905 #ifndef __ASSEMBLY__ /* Accessors for auxiliary registers */ diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h index 8a77cd9..0b3ebd9 100644 --- a/arch/arc/include/asm/cache.h +++ b/arch/arc/include/asm/cache.h @@ -27,4 +27,15 @@ #define CONFIG_ARC_MMU_VER 4 #endif +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_ISA_ARCV2 +void slc_enable(void); +void slc_disable(void); +void slc_flush(void); +void slc_invalidate(void); +#endif + +#endif /* __ASSEMBLY__ */ + #endif /* __ASM_ARC_CACHE_H */ diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c index 30f045a..e369e5a 100644 --- a/arch/arc/lib/cache.c +++ b/arch/arc/lib/cache.c @@ -16,6 +16,7 @@ #define DC_CTRL_INV_MODE_FLUSH (1 << 6) #define DC_CTRL_FLUSH_STATUS (1 << 8) #define CACHE_VER_NUM_MASK 0xF +#define SLC_CTRL_SB (1 << 2) int icache_status(void) { @@ -170,3 +171,48 @@ void flush_cache(unsigned long start, unsigned long size) { flush_dcache_range(start, start + size); } + +#ifdef CONFIG_ISA_ARCV2 +void slc_enable(void) +{ + /* If SLC ver = 0, no SLC present in CPU */ + if (!(read_aux_reg(ARC_BCR_SLC) & 0xff)) + return; + + write_aux_reg(ARC_AUX_SLC_CONTROL, + read_aux_reg(ARC_AUX_SLC_CONTROL) & ~1); +} + +void slc_disable(void) +{ + /* If SLC ver = 0, no SLC present in CPU */ + if (!(read_aux_reg(ARC_BCR_SLC) & 0xff)) + return; + + write_aux_reg(ARC_AUX_SLC_CONTROL, + read_aux_reg(ARC_AUX_SLC_CONTROL) | 1); +} + +void slc_flush(void) +{ + /* If SLC ver = 0, no SLC present in CPU */ + if (!(read_aux_reg(ARC_BCR_SLC) & 0xff)) + return; + + write_aux_reg(ARC_AUX_SLC_FLUSH, 1); + + /* Wait flush end */ + while (read_aux_reg(ARC_AUX_SLC_CONTROL) & SLC_CTRL_SB) + ; +} + +void slc_invalidate(void) +{ + /* If SLC ver = 0, no SLC present in CPU */ + if (!(read_aux_reg(ARC_BCR_SLC) & 0xff)) + return; + + write_aux_reg(ARC_AUX_SLC_INVALIDATE, 1); +} + +#endif /* CONFIG_ISA_ARCV2 */ diff --git a/arch/arc/lib/start.S b/arch/arc/lib/start.S index 48ee86e..e1ef19c 100644 --- a/arch/arc/lib/start.S +++ b/arch/arc/lib/start.S @@ -18,6 +18,10 @@ ENTRY(_start) mov %fp, %sp /* Unconditionally disable caches */ +#ifdef CONFIG_ISA_ARCV2 + bl slc_flush + bl slc_disable +#endif bl flush_dcache_all bl dcache_disable bl icache_disable -- cgit v0.10.2 From d5717e894497124fd44289a37f818ee301640c70 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Thu, 2 Apr 2015 10:19:12 +0300 Subject: board: AXS10x - update SDIO clock value With the most recent board firmware correct SDIO clock is 50MHz as opposed to 25 MHz before. Also set max frequency of MMC data exchange equal to SDIO clock - because there's no way to transfer data faster than interface clock. Signed-off-by: Alexey Brodkin diff --git a/board/synopsys/axs101/axs101.c b/board/synopsys/axs101/axs101.c index d1271ff..7742049 100644 --- a/board/synopsys/axs101/axs101.c +++ b/board/synopsys/axs101/axs101.c @@ -27,9 +27,9 @@ int board_mmc_init(bd_t *bis) host->ioaddr = (void *)ARC_DWMMC_BASE; host->buswidth = 4; host->dev_index = 0; - host->bus_hz = 25000000; + host->bus_hz = 50000000; - add_dwmci(host, 52000000, 400000); + add_dwmci(host, host->bus_hz, 400000); return 0; } -- cgit v0.10.2 From 47bdb9f892667904aeab831b622d4a52b90b4de0 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 4 Apr 2015 10:37:44 +0200 Subject: sunxi: Fix Orangepi_mini dtb filename The Orangepi_mini is different enough from the regular Orangepi that it needs its own dtb, but when it got added a copy and paste error was made and it got the same dtb filename, fix this. While at it also add a short description of both Orangepi boards to the defconfig files for them. Signed-off-by: Hans de Goede Acked-by: Ian Campbell diff --git a/configs/Orangepi_defconfig b/configs/Orangepi_defconfig index 28fadcd..0c39f70 100644 --- a/configs/Orangepi_defconfig +++ b/configs/Orangepi_defconfig @@ -1,3 +1,10 @@ +# The Orangepi is a development board using the Allwinner A20 SoC, with 1G +# RAM, microsd slot, HDMI, 1Gbit ethernet, USB wifi, Micro USB (otg), sata, +# 4 USB A ports, ir receiver and a headphones jack. +# +# Also see: +# http://linux-sunxi.org/Xunlong_Orange_Pi +# http://www.orangepi.org/ CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHCI,USB_EHCI" CONFIG_FDTFILE="sun7i-a20-orangepi.dtb" diff --git a/configs/Orangepi_mini_defconfig b/configs/Orangepi_mini_defconfig index 330679b..733e07f 100644 --- a/configs/Orangepi_mini_defconfig +++ b/configs/Orangepi_mini_defconfig @@ -1,6 +1,14 @@ +# The Orangepi mini is a development board using the Allwinner A20 SoC, +# with 1G RAM, 2 microsd slots (use the top side one for booting), HDMI, +# 1Gbit ethernet, USB wifi, Micro USB (otg), sata, 2 USB A ports, +# ir receiver and a headphones jack. +# +# Also see: +# http://linux-sunxi.org/Xunlong_Orange_Pi_Mini +# http://www.orangepi.org/ CONFIG_SPL=y CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHCI,USB_EHCI" -CONFIG_FDTFILE="sun7i-a20-orangepi.dtb" +CONFIG_FDTFILE="sun7i-a20-orangepi-mini.dtb" CONFIG_MMC_SUNXI_SLOT_EXTRA=3 CONFIG_MMC0_CD_PIN="PH10" CONFIG_MMC3_CD_PIN="PH11" -- cgit v0.10.2 From 0467faf555022fa5447a037b753b150448217239 Mon Sep 17 00:00:00 2001 From: Guillaume GARDET Date: Wed, 11 Mar 2015 10:34:27 +0100 Subject: Exynos: Clock: Fix exynos5_get_periph_rate for I2C. Commit 2e82e9252695a612ab0cbf40fa0c7368515f6506 'Exynos: Clock: Cleanup soc_get_periph_rate' introduced a bug in I2C config. This patch makes cros_ec keyboard working again on Samsung Chromebook (snow). Changes in V2: reorder lines as requested by Joonyoung Shim. Signed-off-by: Guillaume GARDET Cc: Akshay Saraswat Cc: Minkyu Kang Cc: Joonyoung Shim Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c index c6455c2..2984867 100644 --- a/arch/arm/cpu/armv7/exynos/clock.c +++ b/arch/arm/cpu/armv7/exynos/clock.c @@ -423,8 +423,8 @@ static unsigned long exynos5_get_periph_rate(int peripheral) case PERIPH_ID_I2C6: case PERIPH_ID_I2C7: src = EXYNOS_SRC_MPLL; - div = readl(&clk->div_top0); - sub_div = readl(&clk->div_top1); + div = readl(&clk->div_top1); + sub_div = readl(&clk->div_top0); break; default: debug("%s: invalid peripheral %d", __func__, peripheral); -- cgit v0.10.2 From f44ef7d60c7349c0eed5d2363a2649badaae2610 Mon Sep 17 00:00:00 2001 From: Inha Song Date: Fri, 13 Mar 2015 17:48:35 +0900 Subject: exynos5: add trace feature #ifdef in exynos5-common.h We can enable / disable trace feature from the FTRACE config options. To enable, compile U-Boot with FTRACE=1. This patch add #ifdef FTRACE in exynos5-common.h for enable/disable to use FTRACE configs instead of having to change board config files. Signed-off-by: Inha Song Acked-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/include/configs/exynos5-common.h b/include/configs/exynos5-common.h index 3ab8d55..2eddb07 100644 --- a/include/configs/exynos5-common.h +++ b/include/configs/exynos5-common.h @@ -16,14 +16,14 @@ #define CONFIG_SYS_CACHELINE_SIZE 64 #define CONFIG_EXYNOS_SPL -/* Allow tracing to be enabled */ +#ifdef FTRACE #define CONFIG_TRACE #define CONFIG_CMD_TRACE #define CONFIG_TRACE_BUFFER_SIZE (16 << 20) #define CONFIG_TRACE_EARLY_SIZE (8 << 20) #define CONFIG_TRACE_EARLY #define CONFIG_TRACE_EARLY_ADDR 0x50000000 - +#endif /* Enable ACE acceleration for SHA1 and SHA256 */ #define CONFIG_EXYNOS_ACE_SHA -- cgit v0.10.2 From d7e1f02efc8e5272015afed596c395b5a4f8e196 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 12 Mar 2015 22:33:29 +0100 Subject: config: peach: Correct memory layout environment settings The peach boards have their SDRAM start address at 0x20000000 instead of 0x40000000 which seems common for all other exynos5 based boards. This means the layout set in exynos5-common.h causes the kernel be loaded more then 128MB (at 0x42000000) away from memory start which breaks booting kernels with CONFIG_AUTO_ZRELADDR Define a custom MEM_LAYOUT_ENV_SETTINGS for both peach boards which uses the same offsets from start of memory as the common exynos5 settings. This fixes booting via bootz and PXE Signed-off-by: Sjoerd Simons Reviewed-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/include/configs/peach-pi.h b/include/configs/peach-pi.h index f04f061..e3cb09e 100644 --- a/include/configs/peach-pi.h +++ b/include/configs/peach-pi.h @@ -16,6 +16,14 @@ #define CONFIG_ENV_OFFSET (FLASH_SIZE - CONFIG_BL2_SIZE) #define CONFIG_SPI_BOOTING +#define MEM_LAYOUT_ENV_SETTINGS \ + "bootm_size=0x10000000\0" \ + "kernel_addr_r=0x22000000\0" \ + "fdt_addr_r=0x23000000\0" \ + "ramdisk_addr_r=0x23300000\0" \ + "scriptaddr=0x30000000\0" \ + "pxefile_addr_r=0x31000000\0" + #include #include diff --git a/include/configs/peach-pit.h b/include/configs/peach-pit.h index b5efbdc..3ee42ef 100644 --- a/include/configs/peach-pit.h +++ b/include/configs/peach-pit.h @@ -16,6 +16,14 @@ #define CONFIG_ENV_OFFSET (FLASH_SIZE - CONFIG_BL2_SIZE) #define CONFIG_SPI_BOOTING +#define MEM_LAYOUT_ENV_SETTINGS \ + "bootm_size=0x10000000\0" \ + "kernel_addr_r=0x22000000\0" \ + "fdt_addr_r=0x23000000\0" \ + "ramdisk_addr_r=0x23300000\0" \ + "scriptaddr=0x30000000\0" \ + "pxefile_addr_r=0x31000000\0" + #include #include -- cgit v0.10.2 From 70b4fb660df25d4a150833f7487a0059d1827fee Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Wed, 4 Mar 2015 19:05:24 +0530 Subject: arm: exynos: add display clocks for Exynos5800 Add get_lcd_clk and set_lcd_clk callbacks for Exynos5800 needed by exynos video driver. Signed-off-by: Ajay Kumar Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c index 2984867..df4d473 100644 --- a/arch/arm/cpu/armv7/exynos/clock.c +++ b/arch/arm/cpu/armv7/exynos/clock.c @@ -14,7 +14,6 @@ #define PLL_DIV_1024 1024 #define PLL_DIV_65535 65535 #define PLL_DIV_65536 65536 - /* * * This structure is to store the src bit, div bit and prediv bit * positions of the peripheral clocks of the src and div registers @@ -1028,6 +1027,40 @@ static unsigned long exynos5420_get_lcd_clk(void) return pclk; } +static unsigned long exynos5800_get_lcd_clk(void) +{ + struct exynos5420_clock *clk = + (struct exynos5420_clock *)samsung_get_base_clock(); + unsigned long sclk; + unsigned int sel; + unsigned int ratio; + + /* + * CLK_SRC_DISP10 + * CLKMUX_FIMD1 [6:4] + */ + sel = (readl(&clk->src_disp10) >> 4) & 0x7; + + if (sel) { + /* + * Mapping of CLK_SRC_DISP10 CLKMUX_FIMD1 [6:4] values into + * PLLs. The first element is a placeholder to bypass the + * default settig. + */ + const int reg_map[] = {0, CPLL, DPLL, MPLL, SPLL, IPLL, EPLL, + RPLL}; + sclk = get_pll_clk(reg_map[sel]); + } else + sclk = CONFIG_SYS_CLK_FREQ; + /* + * CLK_DIV_DISP10 + * FIMD1_RATIO [3:0] + */ + ratio = readl(&clk->div_disp10) & 0xf; + + return sclk / (ratio + 1); +} + void exynos4_set_lcd_clk(void) { struct exynos4_clock *clk = @@ -1159,6 +1192,28 @@ void exynos5420_set_lcd_clk(void) writel(cfg, &clk->div_disp10); } +void exynos5800_set_lcd_clk(void) +{ + struct exynos5420_clock *clk = + (struct exynos5420_clock *)samsung_get_base_clock(); + unsigned int cfg; + + /* + * Use RPLL for pixel clock + * CLK_SRC_DISP10 CLKMUX_FIMD1 [6:4] + * ================== + * 111: SCLK_RPLL + */ + cfg = readl(&clk->src_disp10) | (0x7 << 4); + writel(cfg, &clk->src_disp10); + + /* + * CLK_DIV_DISP10 + * FIMD1_RATIO [3:0] + */ + clrsetbits_le32(&clk->div_disp10, 0xf << 0, 0x0 << 0); +} + void exynos4_set_mipi_clk(void) { struct exynos4_clock *clk = @@ -1646,8 +1701,10 @@ unsigned long get_lcd_clk(void) if (cpu_is_exynos4()) return exynos4_get_lcd_clk(); else { - if (proid_is_exynos5420() || proid_is_exynos5800()) + if (proid_is_exynos5420()) return exynos5420_get_lcd_clk(); + else if (proid_is_exynos5800()) + return exynos5800_get_lcd_clk(); else return exynos5_get_lcd_clk(); } @@ -1660,8 +1717,10 @@ void set_lcd_clk(void) else { if (proid_is_exynos5250()) exynos5_set_lcd_clk(); - else if (proid_is_exynos5420() || proid_is_exynos5800()) + else if (proid_is_exynos5420()) exynos5420_set_lcd_clk(); + else + exynos5800_set_lcd_clk(); } } diff --git a/arch/arm/include/asm/arch-exynos/clk.h b/arch/arm/include/asm/arch-exynos/clk.h index 2a17dfc..d20b7d2 100644 --- a/arch/arm/include/asm/arch-exynos/clk.h +++ b/arch/arm/include/asm/arch-exynos/clk.h @@ -16,6 +16,9 @@ #define BPLL 5 #define RPLL 6 #define SPLL 7 +#define CPLL 8 +#define DPLL 9 +#define IPLL 10 #define MASK_PRE_RATIO(x) (0xff << ((x << 4) + 8)) #define MASK_RATIO(x) (0xf << (x << 4)) -- cgit v0.10.2 From 6102560891d09db79196654aa414afc5acfa7911 Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Wed, 4 Mar 2015 19:05:25 +0530 Subject: Exynos5: Fix rpll_sdiv to support both peach-pit and peach-pi panels The existing setting for rpll_sdiv generates 70.5Mhz RPLL video clock to drive 1366x768 panel on peach_pit. This clock rate is not sufficient to drive 1920x1080 panel on peach-pi. So, we adjust rpll_sdiv to 3 so that it generates 141Mhz pixel clock which can drive peach-pi LCD. This change doesn't break peach-pit LCD since 141/2=70.5Mhz, i.e FIMD divider at IP level will get set to 1(the required divider setting will be calculated and set by exynos_fimd_set_clock()) and hence peach-pit LCD still works fine. Signed-off-by: Ajay Kumar Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/arch/arm/cpu/armv7/exynos/clock_init_exynos5.c b/arch/arm/cpu/armv7/exynos/clock_init_exynos5.c index 0aff3d0..0200fd1 100644 --- a/arch/arm/cpu/armv7/exynos/clock_init_exynos5.c +++ b/arch/arm/cpu/armv7/exynos/clock_init_exynos5.c @@ -179,10 +179,10 @@ struct mem_timings mem_timings[] = { .spll_mdiv = 0xc8, .spll_pdiv = 0x3, .spll_sdiv = 0x2, - /* RPLL @70.5Mhz */ + /* RPLL @141Mhz */ .rpll_mdiv = 0x5E, .rpll_pdiv = 0x2, - .rpll_sdiv = 0x4, + .rpll_sdiv = 0x3, .direct_cmd_msr = { 0x00020018, 0x00030000, 0x00010046, 0x00000d70, -- cgit v0.10.2 From 9018efa7e227bc7041a98f5c5efebaa7ecfcfd0d Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Wed, 4 Mar 2015 19:05:26 +0530 Subject: video: exynos_fb: configure backlight GPIOs if specified in DT Add support to configure PWM_OUT(PWM output) GPIO and BL_EN(backlight enable) GPIO, if provided in FIMD DT node. Signed-off-by: Ajay Kumar Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/doc/device-tree-bindings/video/exynos-fb.txt b/doc/device-tree-bindings/video/exynos-fb.txt index dc4e44f..b022f61 100644 --- a/doc/device-tree-bindings/video/exynos-fb.txt +++ b/doc/device-tree-bindings/video/exynos-fb.txt @@ -61,6 +61,8 @@ Board(panel specific): disabled with compatible string "samsung,sysmmu-v3.3", with a "reg" property holding the register address of FIMD sysmmu. + samsung,pwm-out-gpio: PWM output GPIO. + samsung,bl-en-gpio: backlight enable GPIO. Example: SOC specific part: diff --git a/drivers/video/exynos_fb.c b/drivers/video/exynos_fb.c index c5d7330..8f3b826 100644 --- a/drivers/video/exynos_fb.c +++ b/drivers/video/exynos_fb.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "exynos_fb.h" @@ -102,6 +103,10 @@ __weak int exynos_lcd_misc_init(vidinfo_t *vid) static void lcd_panel_on(vidinfo_t *vid) { + struct gpio_desc pwm_out_gpio; + struct gpio_desc bl_en_gpio; + unsigned int node; + udelay(vid->init_delay); exynos_backlight_reset(); @@ -121,6 +126,22 @@ static void lcd_panel_on(vidinfo_t *vid) exynos_backlight_on(1); +#ifdef CONFIG_OF_CONTROL + node = fdtdec_next_compatible(gd->fdt_blob, 0, + COMPAT_SAMSUNG_EXYNOS_FIMD); + if (node <= 0) { + debug("FIMD: Can't get device node for FIMD\n"); + return; + } + gpio_request_by_name_nodev(gd->fdt_blob, node, "samsung,pwm-out-gpio", + 0, &pwm_out_gpio, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + + gpio_request_by_name_nodev(gd->fdt_blob, node, "samsung,bl-en-gpio", 0, + &bl_en_gpio, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + +#endif exynos_cfg_ldo(); exynos_enable_ldo(1); -- cgit v0.10.2 From 55e70929b83bc512721d08cb32a7523458d9122d Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Wed, 4 Mar 2015 19:05:27 +0530 Subject: video: parade: configure SLP and RST GPIOs if specified in DT Add support to configure EDP_RST GPIO and EDP_SLP GPIO, if provided in parade DT node. Signed-off-by: Ajay Kumar Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/drivers/video/parade.c b/drivers/video/parade.c index 0f543f6..ae50971 100644 --- a/drivers/video/parade.c +++ b/drivers/video/parade.c @@ -12,6 +12,7 @@ #include #include #include +#include /* * Initialization of the chip is a process of writing certaing values into @@ -180,6 +181,8 @@ static int parade_write_regs(int base_addr, const struct reg_data *table) int parade_init(const void *blob) { + struct gpio_desc rst_gpio; + struct gpio_desc slp_gpio; int bus, old_bus; int parent; int node; @@ -201,6 +204,14 @@ int parade_init(const void *blob) return -1; } + gpio_request_by_name_nodev(blob, node, "sleep-gpio", 0, &slp_gpio, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + + mdelay(10); + + gpio_request_by_name_nodev(blob, node, "reset-gpio", 0, &rst_gpio, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + bus = i2c_get_bus_num_fdt(parent); old_bus = i2c_get_bus_num(); -- cgit v0.10.2 From e549234d698406099e8bbeda4a345d8c77250cf1 Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Wed, 4 Mar 2015 19:05:28 +0530 Subject: dts: exynos54xx: Add samsung, pwm-out-gpio property to FIMD node Now that the exynos_fb driver supports handling backlight GPIO via DT, specify pwm output property via FIMD DT node. Signed-off-by: Ajay Kumar Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/arch/arm/dts/exynos54xx.dtsi b/arch/arm/dts/exynos54xx.dtsi index 916cf3a..31fabb1 100644 --- a/arch/arm/dts/exynos54xx.dtsi +++ b/arch/arm/dts/exynos54xx.dtsi @@ -168,6 +168,7 @@ fimd@14400000 { /* sysmmu is not used in U-Boot */ samsung,disable-sysmmu; + samsung,pwm-out-gpio = <&gpb2 0 GPIO_ACTIVE_HIGH>; }; dp@145b0000 { -- cgit v0.10.2 From b798177736f006125b4769986f232e4b0a4f9a84 Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Wed, 4 Mar 2015 19:05:29 +0530 Subject: dts: peach_pit: Add SLP and RST GPIO properties in parade DT node Now that parade driver supports reading SLP and RST GPIO from DT, specify the same in parade DT node. Signed-off-by: Ajay Kumar Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/arch/arm/dts/exynos5420-peach-pit.dts b/arch/arm/dts/exynos5420-peach-pit.dts index b801de9..3ad4728 100644 --- a/arch/arm/dts/exynos5420-peach-pit.dts +++ b/arch/arm/dts/exynos5420-peach-pit.dts @@ -67,6 +67,8 @@ edp-lvds-bridge@48 { compatible = "parade,ps8625"; reg = <0x48>; + sleep-gpio = <&gpx3 5 GPIO_ACTIVE_HIGH>; + reset-gpio = <&gpy7 7 GPIO_ACTIVE_HIGH>; }; }; -- cgit v0.10.2 From 607eff62ce99da2a528be1678b0bade67df01cc1 Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Wed, 4 Mar 2015 19:05:30 +0530 Subject: dts: peach_pi: Add DT properties needed for display Add backlight enable GPIO, and delay needed for panel powerup via FIMD DT node. Signed-off-by: Ajay Kumar Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/arch/arm/dts/exynos5800-peach-pi.dts b/arch/arm/dts/exynos5800-peach-pi.dts index e4bc100..494f764 100644 --- a/arch/arm/dts/exynos5800-peach-pi.dts +++ b/arch/arm/dts/exynos5800-peach-pi.dts @@ -144,10 +144,13 @@ samsung,vl-vfpd = <10>; samsung,vl-cmd-allow-len = <0xf>; + samsung,power-on-delay = <30000>; samsung,winid = <3>; samsung,interface-mode = <1>; samsung,dp-enabled = <1>; samsung,dual-lcd-enabled = <0>; + + samsung,bl-en-gpio = <&gpx2 2 GPIO_ACTIVE_HIGH>; }; }; -- cgit v0.10.2 From 0f00c38f017feb7f7e710b320e22560d1bd4add7 Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Wed, 4 Mar 2015 19:05:31 +0530 Subject: smdk5420: Remove GPIO enums Remove GPIOs from smdk5420 board file and because the same is already specified via DT. Signed-off-by: Ajay Kumar Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Minkyu Kang diff --git a/board/samsung/smdk5420/smdk5420.c b/board/samsung/smdk5420/smdk5420.c index 1aca9fa..82f607b 100644 --- a/board/samsung/smdk5420/smdk5420.c +++ b/board/samsung/smdk5420/smdk5420.c @@ -58,16 +58,6 @@ void exynos_lcd_power_on(void) mdelay(5); - /* TODO(ajaykumar.rs@samsung.com): Use device tree */ - gpio_request(EXYNOS5420_GPIO_X35, "edp_slp#"); - gpio_direction_output(EXYNOS5420_GPIO_X35, 1); /* EDP_SLP# */ - mdelay(10); - gpio_request(EXYNOS5420_GPIO_Y77, "edp_rst#"); - gpio_direction_output(EXYNOS5420_GPIO_Y77, 1); /* EDP_RST# */ - gpio_request(EXYNOS5420_GPIO_X26, "edp_hpd"); - gpio_direction_input(EXYNOS5420_GPIO_X26); /* EDP_HPD */ - gpio_set_pull(EXYNOS5420_GPIO_X26, S5P_GPIO_PULL_NONE); - if (has_edp_bridge()) if (parade_init(gd->fdt_blob)) printf("%s: ps8625_init() failed\n", __func__); @@ -75,11 +65,6 @@ void exynos_lcd_power_on(void) void exynos_backlight_on(unsigned int onoff) { - /* For PWM */ - gpio_request(EXYNOS5420_GPIO_B20, "backlight_on"); - gpio_cfg_pin(EXYNOS5420_GPIO_B20, S5P_GPIO_FUNC(0x1)); - gpio_set_value(EXYNOS5420_GPIO_B20, 1); - #ifdef CONFIG_POWER_TPS65090 tps65090_fet_enable(1); #endif -- cgit v0.10.2 From f26cc7d4edc2f6d5adb35e8e4ce8ae0549e09f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Majewski?= Date: Wed, 1 Apr 2015 12:34:28 +0200 Subject: config: exynos: common: Provide env variables to support Image.itb This change allows using Image.itb image format with Exynos4 devices (especially trats and trats2). Such change facilitates automated testing since only one binary needs to be prepared. Signed-off-by: Lukasz Majewski Signed-off-by: Minkyu Kang diff --git a/include/configs/exynos4-common.h b/include/configs/exynos4-common.h index 41631c7..577afe7 100644 --- a/include/configs/exynos4-common.h +++ b/include/configs/exynos4-common.h @@ -66,4 +66,58 @@ #define CONFIG_CMD_USB_MASS_STORAGE #define CONFIG_USB_GADGET_MASS_STORAGE +/* Common environment variables */ +#define CONFIG_EXTRA_ENV_ITB \ + "loadkernel=load mmc ${mmcbootdev}:${mmcbootpart} ${kerneladdr} " \ + "${kernelname}\0" \ + "loadinitrd=load mmc ${mmcbootdev}:${mmcbootpart} ${initrdaddr} " \ + "${initrdname}\0" \ + "loaddtb=load mmc ${mmcbootdev}:${mmcbootpart} ${fdtaddr} " \ + "${fdtfile}\0" \ + "check_ramdisk=" \ + "if run loadinitrd; then " \ + "setenv initrd_addr ${initrdaddr};" \ + "else " \ + "setenv initrd_addr -;" \ + "fi;\0" \ + "check_dtb=" \ + "if run loaddtb; then " \ + "setenv fdt_addr ${fdtaddr};" \ + "else " \ + "setenv fdt_addr;" \ + "fi;\0" \ + "kernel_args=" \ + "setenv bootargs root=/dev/mmcblk${mmcdev}p${mmcrootpart}" \ + " ${lpj} rootwait ${console} ${meminfo} ${opts} ${lcdinfo};\0" \ + "boot_fit=" \ + "setenv kerneladdr 0x42000000;" \ + "setenv kernelname Image.itb;" \ + "run loadkernel;" \ + "run kernel_args;" \ + "bootm ${kerneladdr}#${board_name}\0" \ + "boot_uimg=" \ + "setenv kerneladdr 0x40007FC0;" \ + "setenv kernelname uImage;" \ + "run check_dtb;" \ + "run check_ramdisk;" \ + "run loadkernel;" \ + "run kernel_args;" \ + "bootm ${kerneladdr} ${initrd_addr} ${fdt_addr};\0" \ + "boot_zimg=" \ + "setenv kerneladdr 0x40007FC0;" \ + "setenv kernelname zImage;" \ + "run check_dtb;" \ + "run check_ramdisk;" \ + "run loadkernel;" \ + "run kernel_args;" \ + "bootz ${kerneladdr} ${initrd_addr} ${fdt_addr};\0" \ + "autoboot=" \ + "if test -e mmc ${mmcdev}:${mmcbootpart} Image.itb; then; " \ + "run boot_fit;" \ + "elif test -e mmc ${mmcdev}:${mmcbootpart} zImage; then; " \ + "run boot_zimg;" \ + "elif test -e mmc ${mmcdev}:${mmcbootpart} uImage; then; " \ + "run boot_uimg;" \ + "fi;\0" + #endif /* __CONFIG_EXYNOS4_COMMON_H */ -- cgit v0.10.2 From 0a1387bf1b8beaa336b6e8991520904ff6f2dc98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Majewski?= Date: Wed, 1 Apr 2015 12:34:29 +0200 Subject: config: exynos: trats: Enable support for Image.itb at trats device After this change it is possible to boot trats device with Image.itb, which facilitates automated testing, since only one file is necessary. Signed-off-by: Lukasz Majewski Signed-off-by: Minkyu Kang diff --git a/include/configs/trats.h b/include/configs/trats.h index b21ea2d..6808e78 100644 --- a/include/configs/trats.h +++ b/include/configs/trats.h @@ -51,8 +51,10 @@ #define MACH_TYPE_TRATS 3928 #define CONFIG_MACH_TYPE MACH_TYPE_TRATS +#define CONFIG_FIT +#define CONFIG_FIT_VERBOSE #define CONFIG_BOOTARGS "Please use defined boot" -#define CONFIG_BOOTCOMMAND "run mmcboot" +#define CONFIG_BOOTCOMMAND "run autoboot" #define CONFIG_DEFAULT_CONSOLE "console=ttySAC2,115200n8\0" #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_LOAD_ADDR \ @@ -106,7 +108,8 @@ ""PARTS_ROOT" part 0 5;" \ ""PARTS_DATA" part 0 6;" \ ""PARTS_UMS" part 0 7;" \ - "params.bin raw 0x38 0x8\0" + "params.bin raw 0x38 0x8;" \ + "/Image.itb ext4 0 2\0" #define CONFIG_EXTRA_ENV_SETTINGS \ "bootk=" \ @@ -172,6 +175,7 @@ "setenv spl_imgsize;" \ "setenv spl_imgaddr;" \ "setenv spl_addr_tmp;\0" \ + CONFIG_EXTRA_ENV_ITB \ "fdtaddr=40800000\0" \ /* Falcon mode definitions */ -- cgit v0.10.2 From 1018b0a56a4719a64fb6867337a72d6a9343008b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Majewski?= Date: Wed, 1 Apr 2015 12:34:30 +0200 Subject: config: exynos: trats2: Enable support for Image.itb at trats2 device After this change it is possible to boot trats2 device with Image.itb, which facilitates automated testing, since only one file is necessary. Signed-off-by: Lukasz Majewski Signed-off-by: Minkyu Kang diff --git a/include/configs/trats2.h b/include/configs/trats2.h index 42481ab..94c31fb 100644 --- a/include/configs/trats2.h +++ b/include/configs/trats2.h @@ -44,8 +44,10 @@ #define CONFIG_SYS_CONSOLE_INFO_QUIET #define CONFIG_SYS_CONSOLE_IS_IN_ENV +#define CONFIG_FIT +#define CONFIG_FIT_VERBOSE #define CONFIG_BOOTARGS "Please use defined boot" -#define CONFIG_BOOTCOMMAND "run mmcboot" +#define CONFIG_BOOTCOMMAND "run autoboot" #define CONFIG_DEFAULT_CONSOLE "console=ttySAC2,115200n8\0" #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_LOAD_ADDR \ @@ -96,7 +98,8 @@ ""PARTS_ROOT" part 0 5;" \ ""PARTS_DATA" part 0 6;" \ ""PARTS_UMS" part 0 7;" \ - "params.bin raw 0x38 0x8\0" + "params.bin raw 0x38 0x8;" \ + "/Image.itb ext4 0 2\0" #define CONFIG_EXTRA_ENV_SETTINGS \ "bootk=" \ @@ -153,6 +156,7 @@ "setenv spl_imgsize;" \ "setenv spl_imgaddr;" \ "setenv spl_addr_tmp;\0" \ + CONFIG_EXTRA_ENV_ITB \ "fdtaddr=40800000\0" \ /* GPT */ -- cgit v0.10.2 From 5e8397dd94a1b55cd7577cdc24f271b71f660e7e Mon Sep 17 00:00:00 2001 From: Mario Schuknecht Date: Tue, 24 Mar 2015 08:59:00 +0100 Subject: env_sf: Fix recovery default The u-boot environment is redundantly stored in a NOR flash on our boards. Redundant means that there are two places to store the environment. But only one of the two is active. I discovered that on one board the u-boot (env_sf) uses the environment from the second place and the Kernel (fw_printenv) uses the environment from the first place. To decide which is the active environment there is a byte inside the environment. 1 means active and 0 means obsolete. But on that board both environments had have a 1. This can happen if a power loss or reset occurs during writing the environment. In this situation the u-boot (env_sf) implementation uses the second environment as default. But the Kernel (fw_printenv) implementation uses the first environment as default. This commit corrects the default in the u-boot env_sf implementation when a problem was detected. Now the recovery default is the same like in all other environment implementations. E.g. fw_printenv and env_flash. This ensures that u-boot and Kernel use the same environment. Signed-off-by: Mario Schuknecht diff --git a/common/env_sf.c b/common/env_sf.c index 5e3729c..e928f57 100644 --- a/common/env_sf.c +++ b/common/env_sf.c @@ -188,15 +188,17 @@ void env_relocate_spec(void) tmp_env2->flags == ACTIVE_FLAG) { gd->env_valid = 2; } else if (tmp_env1->flags == tmp_env2->flags) { - gd->env_valid = 2; + gd->env_valid = 1; } else if (tmp_env1->flags == 0xFF) { + gd->env_valid = 1; + } else if (tmp_env2->flags == 0xFF) { gd->env_valid = 2; } else { /* * this differs from code in env_flash.c, but I think a sane * default path is desirable. */ - gd->env_valid = 2; + gd->env_valid = 1; } if (gd->env_valid == 1) -- cgit v0.10.2 From 8f6e18385a5afd9aa6d63e5ea3f7658193087851 Mon Sep 17 00:00:00 2001 From: Tang Yuantian Date: Tue, 31 Mar 2015 15:02:43 +0800 Subject: ahci: Fix a wrong parameter pass In stead of user_buffer_size, transfer_size should be used to pass to ahci_device_data_io(). transfer_size is the length that we want the low level function to transfer each time. If we use user_buffer_size which is the totally data length as parameter, low level function will actually create many SGs to transfer as many data as possible each time. That will produce many redundant data transfer. Signed-off-by: Tang Yuantian Reviewed-by: Simon Glass diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c index c908fab..88b90e0 100644 --- a/drivers/block/ahci.c +++ b/drivers/block/ahci.c @@ -785,7 +785,7 @@ static int ata_scsiop_read_write(ccb *pccb, u8 is_write) /* Read/Write from ahci */ if (ahci_device_data_io(pccb->target, (u8 *) &fis, sizeof(fis), - user_buffer, user_buffer_size, + user_buffer, transfer_size, is_write)) { debug("scsi_ahci: SCSI %s10 command failure.\n", is_write ? "WRITE" : "READ"); -- cgit v0.10.2 From e37f1eb45c9f7da7e3463a27f2c2020fc35604b7 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Wed, 1 Apr 2015 13:50:41 +0200 Subject: cmd_mem: cleanups, catch bad usage Currently, memtest will silently accept bad data. Perform error checking on user intput. Signed-off-by: Pavel Machek diff --git a/common/cmd_mem.c b/common/cmd_mem.c index bcb3ee3..20a875c 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -999,10 +999,10 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, { ulong start, end; vu_long *buf, *dummy; - int iteration_limit; + int iteration_limit = 0; int ret; ulong errs = 0; /* number of errors, or -1 if interrupted */ - ulong pattern; + ulong pattern = 0; int iteration; #if defined(CONFIG_SYS_ALT_MEMTEST) const int alt_test = 1; @@ -1010,25 +1010,29 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, const int alt_test = 0; #endif + start = CONFIG_SYS_MEMTEST_START; + end = CONFIG_SYS_MEMTEST_END; + if (argc > 1) - start = simple_strtoul(argv[1], NULL, 16); - else - start = CONFIG_SYS_MEMTEST_START; + if (strict_strtoul(argv[1], 16, &start) < 0) + return CMD_RET_USAGE; if (argc > 2) - end = simple_strtoul(argv[2], NULL, 16); - else - end = CONFIG_SYS_MEMTEST_END; + if (strict_strtoul(argv[2], 16, &end) < 0) + return CMD_RET_USAGE; if (argc > 3) - pattern = (ulong)simple_strtoul(argv[3], NULL, 16); - else - pattern = 0; + if (strict_strtoul(argv[3], 16, &pattern) < 0) + return CMD_RET_USAGE; if (argc > 4) - iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16); - else - iteration_limit = 0; + if (strict_strtoul(argv[4], 16, &iteration_limit) < 0) + return CMD_RET_USAGE; + + if (end < start) { + printf("Refusing to do empty test\n"); + return -1; + } printf("Testing %08x ... %08x:\n", (uint)start, (uint)end); debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__, @@ -1079,7 +1083,7 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, ret = errs != 0; } - return ret; /* not reached */ + return ret; } #endif /* CONFIG_CMD_MEMTEST */ -- cgit v0.10.2 From e049b772ae21e6698b65ebb3bc3afc61c8b13f39 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 2 Apr 2015 16:01:33 -0400 Subject: am33xx/ddr.c: Fix regression on DDR2 platforms Back in fc46bae a "clean up" was introduced that intended to reconcile some of the AM335x codepaths based on how AM43xx operates. Unfortunately this introduced a regression on the DDR2 platforms. This was un-noticed on DDR3 (everything except for Beaglebone White) as we had already populated sdram_config correctly in sequence. This change brings us back to the older behavior and is fine on all platforms. Tested on Beaglebone White, Beaglebone Black and AM335x GP EVM Reported-by: Matt Ranostay Signed-off-by: Tom Rini diff --git a/arch/arm/cpu/armv7/am33xx/ddr.c b/arch/arm/cpu/armv7/am33xx/ddr.c index 85cceae..f5b16b4 100644 --- a/arch/arm/cpu/armv7/am33xx/ddr.c +++ b/arch/arm/cpu/armv7/am33xx/ddr.c @@ -164,9 +164,9 @@ void config_sdram(const struct emif_regs *regs, int nr) writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl); writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl_shdw); } - writel(regs->sdram_config, &emif_reg[nr]->emif_sdram_config); writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl); writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl_shdw); + writel(regs->sdram_config, &emif_reg[nr]->emif_sdram_config); } /** -- cgit v0.10.2 From cffcd2861310855130db52c93f7bf4d9b511741d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 3 Apr 2015 12:30:25 +0900 Subject: kbuild: include config.mk when auto.conf is not older than .config Since the Kconfig conversion, config.mk has been included only when include/config/auto.conf is newer than the .config file. It causes build error if both files have the same time-stamps. It is actually possible because EXT* file systems have a 1s time-stamp resolution. The config.mk should be included when include/config/auto.conf is *not older* than the .config file. Signed-off-by: Masahiro Yamada Reported-by: Tom Rini Reported-by: York Sun Reported-by: Stephen Warren Reported-by: Matthew Gerlach Tested-by: Stephen Warren diff --git a/Makefile b/Makefile index f1bce44..53ad450 100644 --- a/Makefile +++ b/Makefile @@ -513,12 +513,16 @@ include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd # is up-to-date. When we switch to a different board configuration, old CONFIG # macros are still remaining in include/config/auto.conf. Without the following # gimmick, wrong config.mk would be included leading nasty warnings/errors. -autoconf_is_current := $(if $(wildcard $(KCONFIG_CONFIG)),$(shell find . \ - -path ./include/config/auto.conf -newer $(KCONFIG_CONFIG))) -ifneq ($(autoconf_is_current),) +ifneq ($(wildcard $(KCONFIG_CONFIG)),) +ifneq ($(wildcard include/config/auto.conf),) +autoconf_is_old := $(shell find . -path ./$(KCONFIG_CONFIG) -newer \ + include/config/auto.conf) +ifeq ($(autoconf_is_old),) include $(srctree)/config.mk include $(srctree)/arch/$(ARCH)/Makefile endif +endif +endif # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use # that (or fail if absent). Otherwise, search for a linker script in a -- cgit v0.10.2 From bf678dfd426f0bc2eb6488fb56acc57d39d07b95 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 6 Apr 2015 11:12:28 +0900 Subject: MAKEALL: fix get_target_arch() to adjust to '-' in Status field Since the Kconfig conversion, boards.cfg scanned by MAKEALL is generated by tools/genboardscfg.py. Every board is supposed to have its own MAINTAINERS that contains maintainer and status information, but, in fact, MAINTAINERS is missing from some boards. For such boards, the first field, Status, is filled with '-'. It causes a problem for "set" command, which ignores '-' in its arguments. Consequently, get_target_arch() returns a wrong field and MAKEALL fails to get a correct toolchain. Signed-off-by: Masahiro Yamada diff --git a/MAKEALL b/MAKEALL index 5483b38..a6e378f 100755 --- a/MAKEALL +++ b/MAKEALL @@ -551,13 +551,7 @@ get_target_maintainers() { get_target_arch() { local target=$1 - # Automatic mode - local line=`awk '\$7 == "'"$target"'" { print \$0 }' boards.cfg` - - if [ -z "${line}" ] ; then echo "" ; return ; fi - - set ${line} - echo "$2" + awk '$7 == "'$target'" { print $2 }' boards.cfg } list_target() { -- cgit v0.10.2 From c4aaf2e0a6b6d215b5b6146b5502200f67d2ad0a Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Mon, 6 Apr 2015 15:46:44 +0200 Subject: fix makefiles to respect DTC setting Top-level Makefile has option to select dtc binary, but it is ignored due to bug in Makefile.lib. Fix it. Signed-off-by: Pavel Machek diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 13af604..8731fc6 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -275,7 +275,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb quiet_cmd_dtc = DTC $@ # Modified for U-Boot cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ - dtc -O dtb -o $@ -b 0 \ + $(DTC) -O dtb -o $@ -b 0 \ -i $(dir $<) $(DTC_FLAGS) \ -d $(depfile).dtc.tmp $(dtc-tmp) ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) -- cgit v0.10.2 From adcc5705991ce3162fc204da9a673d9fe2cc5bf0 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 7 Apr 2015 09:38:54 -0400 Subject: cmd_mem.c: Update 'iteration_limit' to unsigned long With e37f1eb we now use strict_strtoul() in do_mem_mtest() and this gives us a warning: ../include/vsprintf.h:38:5: note: expected 'long unsigned int *' but argument is of type 'int *' Signed-off-by: Tom Rini diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 20a875c..3f85c1a 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -999,7 +999,7 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, { ulong start, end; vu_long *buf, *dummy; - int iteration_limit = 0; + ulong iteration_limit = 0; int ret; ulong errs = 0; /* number of errors, or -1 if interrupted */ ulong pattern = 0; -- cgit v0.10.2 From 321f86e18d6aae9f7b7ba3ef1eb0cec769481874 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 8 Apr 2015 14:25:50 +0900 Subject: ARM: zynq: disable CONFIG_SYS_MALLOC_F to fix MMC boot Since commit 326a682358c1 (malloc_f: enable SYS_MALLOC_F by default if DM is on), Zynq MMC boot hangs up after printing the following: U-Boot SPL 2015.04-rc5-00053-gadcc570 (Apr 08 2015 - 12:59:11) mmc boot reading system.dtb Prior to commit 326a682358c1, Zynq boards enabled CONFIG_DM, but not CONFIG_SYS_MALLOC_F. That commit forcibly turned on CONFIG_SYS_MALLOC_F. I have not figured out the root cause, but anyway it looks like CONFIG_SYS_MALLOC_F gave a bad impact on the Zynq MMC boot. We are planning to have the v2015.04 release in a few days. I know this is a defensive fixup, but what I can do now is to add # CONFIG_SYS_MALLOC_F is not set to every Zynq defconfig file to get back the original behavior. Tested on: - Zedboard - ZC706 board Signed-off-by: Masahiro Yamada Tested-by: Michal Simek Cc: Simon Glass diff --git a/configs/zynq_microzed_defconfig b/configs/zynq_microzed_defconfig index 39a7f6b..b6bca82 100644 --- a/configs/zynq_microzed_defconfig +++ b/configs/zynq_microzed_defconfig @@ -3,6 +3,7 @@ CONFIG_ARM=y CONFIG_ZYNQ=y CONFIG_TARGET_ZYNQ_MICROZED=y CONFIG_OF_CONTROL=y +# CONFIG_SYS_MALLOC_F is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y diff --git a/configs/zynq_zc70x_defconfig b/configs/zynq_zc70x_defconfig index a8ef97f..44f3ae0 100644 --- a/configs/zynq_zc70x_defconfig +++ b/configs/zynq_zc70x_defconfig @@ -4,6 +4,7 @@ CONFIG_ZYNQ=y CONFIG_TARGET_ZYNQ_ZC70X=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="zynq-zc702" +# CONFIG_SYS_MALLOC_F is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y diff --git a/configs/zynq_zc770_xm010_defconfig b/configs/zynq_zc770_xm010_defconfig index ecd245a..d689857 100644 --- a/configs/zynq_zc770_xm010_defconfig +++ b/configs/zynq_zc770_xm010_defconfig @@ -5,6 +5,7 @@ CONFIG_ZYNQ=y CONFIG_TARGET_ZYNQ_ZC770=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm010" +# CONFIG_SYS_MALLOC_F is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y diff --git a/configs/zynq_zc770_xm012_defconfig b/configs/zynq_zc770_xm012_defconfig index 341a4d8..9745d21 100644 --- a/configs/zynq_zc770_xm012_defconfig +++ b/configs/zynq_zc770_xm012_defconfig @@ -5,6 +5,7 @@ CONFIG_ZYNQ=y CONFIG_TARGET_ZYNQ_ZC770=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm012" +# CONFIG_SYS_MALLOC_F is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y diff --git a/configs/zynq_zc770_xm013_defconfig b/configs/zynq_zc770_xm013_defconfig index ee08a9f..924efb4 100644 --- a/configs/zynq_zc770_xm013_defconfig +++ b/configs/zynq_zc770_xm013_defconfig @@ -5,6 +5,7 @@ CONFIG_ZYNQ=y CONFIG_TARGET_ZYNQ_ZC770=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm013" +# CONFIG_SYS_MALLOC_F is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y diff --git a/configs/zynq_zed_defconfig b/configs/zynq_zed_defconfig index 2500d84..01fa723 100644 --- a/configs/zynq_zed_defconfig +++ b/configs/zynq_zed_defconfig @@ -4,6 +4,7 @@ CONFIG_ZYNQ=y CONFIG_TARGET_ZYNQ_ZED=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="zynq-zed" +# CONFIG_SYS_MALLOC_F is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y diff --git a/configs/zynq_zybo_defconfig b/configs/zynq_zybo_defconfig index c9d0121..f1001f1 100644 --- a/configs/zynq_zybo_defconfig +++ b/configs/zynq_zybo_defconfig @@ -4,6 +4,7 @@ CONFIG_ZYNQ=y CONFIG_TARGET_ZYNQ_ZYBO=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="zynq-zybo" +# CONFIG_SYS_MALLOC_F is not set CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y -- cgit v0.10.2 From 385a08a60f042061b004642d6b9bb6cfb794ad5a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 8 Apr 2015 10:07:20 +0200 Subject: ARM: zynq: Remove Jagan from list of maintainers Email address is not longer valid that's why remove it. Signed-off-by: Michal Simek diff --git a/board/xilinx/zynq/MAINTAINERS b/board/xilinx/zynq/MAINTAINERS index 382e921..e0dc4fe 100644 --- a/board/xilinx/zynq/MAINTAINERS +++ b/board/xilinx/zynq/MAINTAINERS @@ -1,6 +1,5 @@ ZYNQ BOARD M: Michal Simek -M: Jagannadha Sutradharudu Teki S: Maintained F: board/xilinx/zynq/ F: include/configs/zynq*.h -- cgit v0.10.2