[U-Boot] [SPEAr Enhancement PATCH 1/9] spear: Add cache support

Signed-off-by: Vipin Kumar vipin.kumar@st.com --- arch/arm/cpu/arm926ejs/spear/Makefile | 7 ++++--- arch/arm/cpu/arm926ejs/spear/cache.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/spear/cache.c
diff --git a/arch/arm/cpu/arm926ejs/spear/Makefile b/arch/arm/cpu/arm926ejs/spear/Makefile index 7d11035..cf29ede 100644 --- a/arch/arm/cpu/arm926ejs/spear/Makefile +++ b/arch/arm/cpu/arm926ejs/spear/Makefile @@ -25,9 +25,10 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).o
-COBJS-y := cpu.o \ - reset.o \ - timer.o +COBJS-y += cache.o +COBJS-y += cpu.o +COBJS-y += reset.o +COBJS-y += timer.o
COBJS-$(CONFIG_ST_EMI) += emi.o COBJS-$(CONFIG_ARCH_SPEAR3XX) += spear3xx.o diff --git a/arch/arm/cpu/arm926ejs/spear/cache.c b/arch/arm/cpu/arm926ejs/spear/cache.c new file mode 100644 index 0000000..351e8cd --- /dev/null +++ b/arch/arm/cpu/arm926ejs/spear/cache.c @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com. + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> + +void enable_caches(void) +{ +#ifndef CONFIG_SYS_DCACHE_OFF + /* Enable D-cache. I-cache is already enabled in start.S */ + dcache_enable(); +#endif +}

The pinmux layer for spear family of devices exports three APIs for the board. <soc>_pins_default: This routine puts all the SoC pins in a default (safe) state. This API can be used by the respective boards to place all pins in a safe mode before going ahead with initializing with pinmux <soc>_select_mode: This routine selects a particular SoC mode. It is particularly for those SoCs which have several modes one of which can be selected. spear300 and spear320 are such SoCs. <soc>_enable_pins: This routine enables the desired pins. It accepts two arguments. First is 'ip' which indicates which controller pins are to be enabled and the second is 'mode' in which this ip has to run eg. ip can be PMX_ETH0 and mode can be PMX_ETH_RGMII/PMX_ETH_MII etc <soc> spear320_configure_pin: Configures the selected pin in GPIO, PULLDOWN/PULLUP mode <soc>_plgpio_get: Gets the value at a particular GPIO <soc>_plgpio_set(u32 plgpio, u32 val) Sets the value at a particular GPIO
Additionally, this patch also defines mdio_get_control for spear3xx which also falls in the purview of pinmux. This is defined because spear310 and spear320 devices need to control mdio lines dynamically because these are shared. Define the mdio_get_control routine to achieve this.
Signed-off-by: Vipin Kumar vipin.kumar@st.com --- arch/arm/cpu/arm926ejs/spear/Makefile | 6 +- arch/arm/cpu/arm926ejs/spear/spear300.c | 140 +++++ arch/arm/cpu/arm926ejs/spear/spear310.c | 162 ++++++ arch/arm/cpu/arm926ejs/spear/spear320.c | 860 +++++++++++++++++++++++++++++ arch/arm/cpu/arm926ejs/spear/spear3xx.c | 87 +++ arch/arm/include/asm/arch-spear/pinmux.h | 133 +++++ arch/arm/include/asm/arch-spear/spear300.h | 27 + arch/arm/include/asm/arch-spear/spear310.h | 13 + arch/arm/include/asm/arch-spear/spear320.h | 426 ++++++++++++++ arch/arm/include/asm/arch-spear/spear3xx.h | 22 + board/st/spear/spear300evb.c | 19 + board/st/spear/spear310evb.c | 16 + board/st/spear/spear320plc.c | 38 +- board/st/spear/spear600evb.c | 7 + 14 files changed, 1949 insertions(+), 7 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/spear/spear300.c create mode 100644 arch/arm/cpu/arm926ejs/spear/spear310.c create mode 100644 arch/arm/cpu/arm926ejs/spear/spear320.c create mode 100644 arch/arm/include/asm/arch-spear/pinmux.h
diff --git a/arch/arm/cpu/arm926ejs/spear/Makefile b/arch/arm/cpu/arm926ejs/spear/Makefile index cf29ede..2e026ee 100644 --- a/arch/arm/cpu/arm926ejs/spear/Makefile +++ b/arch/arm/cpu/arm926ejs/spear/Makefile @@ -32,6 +32,9 @@ COBJS-y += timer.o
COBJS-$(CONFIG_ST_EMI) += emi.o COBJS-$(CONFIG_ARCH_SPEAR3XX) += spear3xx.o +COBJS-$(CONFIG_SOC_SPEAR300) += spear300.o +COBJS-$(CONFIG_SOC_SPEAR310) += spear310.o +COBJS-$(CONFIG_SOC_SPEAR320) += spear320.o COBJS-$(CONFIG_ARCH_SPEAR6XX) += spear6xx.o
ifdef CONFIG_SPL_BUILD @@ -39,9 +42,8 @@ COBJS-y += spl.o spl_boot.o COBJS-$(CONFIG_SOC_SPEAR600) += spl-spear600.o endif
-SRCS := $(START:.o=.S) $(COBJS-y:.o=.c) +SRCS := $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(COBJS-y)) -START := $(addprefix $(obj),$(START))
all: $(obj).depend $(LIB)
diff --git a/arch/arm/cpu/arm926ejs/spear/spear300.c b/arch/arm/cpu/arm926ejs/spear/spear300.c new file mode 100644 index 0000000..11c6ae7 --- /dev/null +++ b/arch/arm/cpu/arm926ejs/spear/spear300.c @@ -0,0 +1,140 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm/io.h> +#include <asm/arch/hardware.h> +#include <asm/arch/pinmux.h> + +/* + * Pinmux support + * + * The routines are defined by the name enable_xxx_pins with xxx being the + * peripheral controller for which pins are to be enabled + * + * PS: In some cases, a multiple combination of pins can be enabled for the same + * peripheral. In those cases, the routine is defined as enable_xxx_atob_pins. + * Here, xxx is peripheral itself and a and b represent the pin numbers which + * need to be enabled for this controller + */ + +/* NAND pinmux */ +static void enable_nand_2chips_pins(void) +{ + pinmux_maskval(SPEAR300_RAS_REG1, + PMX_FIRDA_MASK, + 0); +} + +static void enable_nand_4chips_pins(void) +{ + pinmux_maskval(SPEAR300_RAS_REG1, + PMX_FIRDA_MASK | PMX_UART0_MASK, + 0); +} + +static void enable_nand_pins(u32 mode) +{ + switch (mode) { + case PMX_NAND_2CHIP: + enable_nand_2chips_pins(); + break; + case PMX_NAND_4CHIP: + enable_nand_4chips_pins(); + break; + } +} + +/* SDMMC pinmux */ +static void enable_sdmmc_4bit_pins(void) +{ + pinmux_maskval(SPEAR300_RAS_REG1, + PMX_GPIO_PIN0_MASK | PMX_GPIO_PIN1_MASK | + PMX_GPIO_PIN2_MASK | PMX_GPIO_PIN3_MASK | + PMX_GPIO_PIN4_MASK | PMX_GPIO_PIN5_MASK, + 0); +} + +static void enable_sdmmc_8bit_pins(void) +{ + pinmux_maskval(SPEAR300_RAS_REG1, + PMX_GPIO_PIN0_MASK | PMX_GPIO_PIN1_MASK | + PMX_GPIO_PIN2_MASK | PMX_GPIO_PIN3_MASK | + PMX_GPIO_PIN4_MASK | PMX_GPIO_PIN5_MASK | PMX_MII_MASK, + 0); +} + +static void enable_sdmmc_pins(u32 mode) +{ + switch (mode) { + case PMX_SDMMC_4BIT: + enable_sdmmc_4bit_pins(); + break; + case PMX_SDMMC_8BIT: + enable_sdmmc_8bit_pins(); + break; + } +} + +/** + * spear300_select_mode + * @mode: SoC mode to e selected + */ +void spear300_select_mode(u32 mode) +{ + pinmux_maskval(SPEAR300_RAS_REG2, + SPEAR300_MODE_MSK, + mode); +} + +/** + * spear300_pins_default: Select a default safe mode as startup + * Generally, all pins are enabled in input mode at initialization. This can be + * done either by + * - enabling gpio's and keeping all pins in gpio inputs + * - a platform specific way. + */ +void spear300_pins_default(void) +{ +} + +/** + * spear300_enable_pins - enable pins for fixed peripherals on spear3xx devices + * @ip: Peripheral index + * @mode: Mode in which peripheral has to run (16bit/8bit etc) + * + * Enable the pins for fixed peripherals on spear3xx devices. + * mode represents the mode in which the peripheral may work and may result in + * different pins being enabled. eg GMII mode and RGMII mode may need different + * pins on devices to be enabled + */ +void spear300_enable_pins(u32 ip, u32 mode) +{ + if (PMX_FSMCNAND == ip) + enable_nand_pins(mode); + else if (PMX_SDMMC == ip) + enable_sdmmc_pins(mode); + else if ((PMX_I2C0 == ip) || (PMX_SSP0 == ip) || \ + (PMX_ETH0 == ip) || (PMX_UART0 == ip)) + spear3xx_enable_pins(ip, mode); +} diff --git a/arch/arm/cpu/arm926ejs/spear/spear310.c b/arch/arm/cpu/arm926ejs/spear/spear310.c new file mode 100644 index 0000000..d1ab43f --- /dev/null +++ b/arch/arm/cpu/arm926ejs/spear/spear310.c @@ -0,0 +1,162 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm/io.h> +#include <asm/arch/hardware.h> +#include <asm/arch/pinmux.h> + +/* + * Function to dnamically set control of shared mdio lines to concerned + * mac controller + */ +void arch_get_mdio_control(const char *devname) +{ + u32 val; + + val = readl(SPEAR310_SMII_REG); + val &= ~SPEAR310_SMII_PHY_MASK; + + if (!strcmp(devname, "macb0")) + val |= (0x0 << SPEAR310_SMII_PHY_SHIFT); + else if (!strcmp(devname, "macb1")) + val |= (0x1 << SPEAR310_SMII_PHY_SHIFT); + else if (!strcmp(devname, "macb2")) + val |= (0x2 << SPEAR310_SMII_PHY_SHIFT); + else if (!strcmp(devname, "macb3")) + val |= (0x3 << SPEAR310_SMII_PHY_SHIFT); + else + printf("no such device:%s\n", devname); + + writel(val, SPEAR310_SMII_REG); +} + +/* + * Pinmux support + * + * The routines are defined by the name enable_xxx_pins with xxx being the + * peripheral controller for which pins are to be enabled + * + * PS: In some cases, a multiple combination of pins can be enabled for the same + * peripheral. In those cases, the routine is defined as enable_xxx_atob_pins. + * Here, xxx is peripheral itself and a and b represent the pin numbers which + * need to be enabled for this controller + */ + +/* Pinmux for EMI */ +static void enable_emi_pins(void) +{ + pinmux_maskval(SPEAR310_FUNCENB_REG, + PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK, + 0); +} + +/* Pinmux for UART1 */ +static void enable_uart1_pins(void) +{ + pinmux_maskval(SPEAR310_FUNCENB_REG, + PMX_FIRDA_MASK, + 0); +} + +/* Pinmux for UART2 */ +static void enable_uart2_pins(void) +{ + pinmux_maskval(SPEAR310_FUNCENB_REG, + PMX_TIMER_0_1_MASK, + 0); +} + +/* Pinmux for UART3 */ +static void enable_uart3_pins(void) +{ + pinmux_maskval(SPEAR310_FUNCENB_REG, + PMX_UART0_MODEM_MASK, + 0); +} + +/* Pinmux for UART4 */ +static void enable_uart4_pins(void) +{ + pinmux_maskval(SPEAR310_FUNCENB_REG, + PMX_UART0_MODEM_MASK, + 0); +} + +/* Pinmux for UART5 */ +static void enable_uart5_pins(void) +{ + pinmux_maskval(SPEAR310_FUNCENB_REG, + PMX_UART0_MODEM_MASK, + 0); +} + +/* Pinmux for NAND */ +static void enable_nand_pins(void) +{ + pinmux_maskval(SPEAR310_FUNCENB_REG, + PMX_SSP_CS_MASK, + 0); +} + +/** + * spear310_pins_default: Select a default safe mode as startup + * Generally, all pins are enabled in input mode at initialization. This can be + * done either by + * - enabling gpio's and keeping all pins in gpio inputs + * - a platform specific way. + */ +void spear310_pins_default(void) +{ +} + +/** + * spear310_enable_pins - enable pins for fixed peripherals on spear3xx devices + * @ip: Peripheral index + * @mode: Mode in which peripheral has to run (16bit/8bit etc) + * + * Enable the pins for fixed peripherals on spear3xx devices. + * mode represents the mode in which the peripheral may work and may result in + * different pins being enabled. eg GMII mode and RGMII mode may need different + * pins on devices to be enabled + */ +void spear310_enable_pins(u32 ip, u32 mode) +{ + if (PMX_FSMCNAND == ip) + enable_nand_pins(); + else if (PMX_EMI == ip) + enable_emi_pins(); + else if (PMX_UART1 == ip) + enable_uart1_pins(); + else if (PMX_UART2 == ip) + enable_uart2_pins(); + else if (PMX_UART3 == ip) + enable_uart3_pins(); + else if (PMX_UART4 == ip) + enable_uart4_pins(); + else if (PMX_UART5 == ip) + enable_uart5_pins(); + else if ((PMX_I2C0 == ip) || (PMX_SSP0 == ip) || \ + (PMX_ETH0 == ip) || (PMX_UART0 == ip)) + spear3xx_enable_pins(ip, mode); +} diff --git a/arch/arm/cpu/arm926ejs/spear/spear320.c b/arch/arm/cpu/arm926ejs/spear/spear320.c new file mode 100644 index 0000000..10c921c --- /dev/null +++ b/arch/arm/cpu/arm926ejs/spear/spear320.c @@ -0,0 +1,860 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm/io.h> +#include <asm/arch/hardware.h> +#include <asm/arch/pinmux.h> + +void arch_get_mdio_control(const char *devname) +{ + u32 val; + + val = readl(SPEAR320_CONTROL_REG); + + if (!strcmp(devname, "macb0")) + val &= ~(0x1 << MII_ENB_SHFT); + else if (!strcmp(devname, "macb1")) + val |= (0x1 << MII_ENB_SHFT); + else + printf("no such device:%s\n", devname); + + writel(val, SPEAR320_CONTROL_REG); +} + +/* + * Pinmux support + * + * The routines are defined by the name enable_xxx_pins with xxx being the + * peripheral controller for which pins are to be enabled + * + * PS: In some cases, a multiple combination of pins can be enabled for the same + * peripheral. In those cases, the routine is defined as enable_xxx_atob_pins. + * Here, xxx is peripheral itself and a and b represent the pin numbers which + * need to be enabled for this controller + */ + +/* Pinmux for EMI */ +static void enable_emi_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_40_49_REG, + PMX_PL_46_47_MASK | PMX_PL_48_49_MASK, + PMX_FSMC_EMI_PL_46_47_VAL | PMX_FSMC_EMI_PL_48_49_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_50_59_REG, + PMX_PL_50_51_MASK | PMX_PL_52_53_MASK | + PMX_PL_54_55_56_MASK | PMX_PL_58_59_MASK, + PMX_EMI_PL_50_51_VAL | PMX_EMI_PL_52_53_VAL | + PMX_FSMC_EMI_PL_54_55_56_VAL | + PMX_FSMC_EMI_PL_58_59_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_60_69_REG, + PMX_PL_69_MASK, + PMX_EMI_PL_69_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_70_79_REG, + PMX_PL_70_MASK | PMX_PL_71_72_MASK | PMX_PL_73_MASK | + PMX_PL_74_MASK | PMX_PL_75_76_MASK | + PMX_PL_77_78_79_MASK, + PMX_FSMC_EMI_PL_70_VAL | PMX_FSMC_EMI_PL_71_72_VAL | + PMX_FSMC_EMI_PL_73_VAL | PMX_EMI_PL_74_VAL | + PMX_EMI_PL_75_76_VAL | PMX_EMI_PL_77_78_79_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_80_89_REG, + PMX_PL_80_TO_85_MASK | PMX_PL_86_87_MASK | + PMX_PL_88_89_MASK, + PMX_EMI_PL_80_TO_85_VAL | PMX_EMI_PL_86_87_VAL | + PMX_EMI_PL_88_89_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_90_99_REG, + PMX_PL_90_91_MASK | PMX_PL_92_93_MASK | + PMX_PL_94_95_MASK | PMX_PL_96_97_MASK, + PMX_EMI1_PL_90_91_VAL | PMX_EMI1_PL_92_93_VAL | + PMX_EMI1_PL_94_95_VAL | PMX_EMI1_PL_96_97_VAL); + pinmux_maskval(SPEAR320_EXT_CTRL_REG, + EMI_FSMC_DYNAMIC_MUX_MASK, + EMI_FSMC_DYNAMIC_MUX_MASK); +} + +/* Pinmux for 8bit NAND interface */ +static void enable_nand8bit_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_50_59_REG, + PMX_PL_52_53_MASK | PMX_PL_54_55_56_MASK | + PMX_PL_57_MASK | PMX_PL_58_59_MASK, + PMX_FSMC_PL_52_53_VAL | PMX_FSMC_EMI_PL_54_55_56_VAL | + PMX_FSMC_PL_57_VAL | PMX_FSMC_EMI_PL_58_59_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_60_69_REG, + PMX_PL_60_MASK | PMX_PL_61_TO_64_MASK | + PMX_PL_65_TO_68_MASK, + PMX_FSMC_PL_60_VAL | PMX_FSMC_PL_61_TO_64_VAL | + PMX_FSMC_PL_65_TO_68_VAL); + pinmux_maskval(SPEAR320_EXT_CTRL_REG, + EMI_FSMC_DYNAMIC_MUX_MASK, + EMI_FSMC_DYNAMIC_MUX_MASK); +} + +/* Pinmux for 16bit NAND interface */ +static void enable_nand16bit_pins(void) +{ + enable_nand8bit_pins(); + + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_40_49_REG, + PMX_PL_46_47_MASK | PMX_PL_48_49_MASK, + PMX_FSMC_EMI_PL_46_47_VAL | PMX_FSMC_EMI_PL_48_49_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_70_79_REG, + PMX_PL_70_MASK | PMX_PL_71_72_MASK | PMX_PL_73_MASK, + PMX_FSMC_EMI_PL_70_VAL | PMX_FSMC_EMI_PL_71_72_VAL | + PMX_FSMC_EMI_PL_73_VAL); +} + +static void enable_nand_pins(u32 mode) +{ + switch (mode) { + case PMX_NAND_8BIT: + enable_nand8bit_pins(); + break; + case PMX_NAND_16BIT: + enable_nand16bit_pins(); + } +} + +/* Pinmux for sdmmc led */ +static void enable_sdmmc_led_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_SSP_CS_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_30_39_REG, + PMX_PL_34_MASK, + PMX_PWM2_PL_34_VAL); +} + +static void enable_sdmmc_common_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_40_49_REG, + PMX_PL_43_MASK | PMX_PL_44_45_MASK | PMX_PL_46_47_MASK | + PMX_PL_48_49_MASK, + PMX_SDHCI_PL_43_VAL | PMX_SDHCI_PL_44_45_VAL | + PMX_SDHCI_PL_46_47_VAL | PMX_SDHCI_PL_48_49_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_50_59_REG, + PMX_PL_50_MASK, + PMX_SDHCI_PL_50_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_90_99_REG, + PMX_PL_99_MASK, + PMX_SDHCI_PL_99_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_PL_100_101_MASK, + PMX_SDHCI_PL_100_101_VAL); +} + +static void enable_sdmmc_cd12_pins(void) +{ + enable_sdmmc_common_pins(); + + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_MII_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_10_19_REG, + PMX_PL_12_MASK, + PMX_SDHCI_CD_PL_12_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SDHCI_CD_PORT_SEL_MASK, + PMX_SDHCI_CD_PORT_12_VAL); +} + +static void enable_sdmmc_cd51_pins(void) +{ + enable_sdmmc_common_pins(); + + pinmux_maskval(SPEAR320_IP_SEL_PAD_50_59_REG, + PMX_PL_51_MASK, + PMX_SDHCI_CD_PL_51_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SDHCI_CD_PORT_SEL_MASK, + PMX_SDHCI_CD_PORT_51_VAL); +} + +static void enable_sdmmc_pins(u32 mode) +{ + switch (mode) { + case PMX_SDMMC_LED: + enable_sdmmc_led_pins(); + break; + case PMX_SDMMC_CD12: + enable_sdmmc_cd12_pins(); + break; + case PMX_SDMMC_CD51: + enable_sdmmc_cd51_pins(); + break; + } +} + +/* Pinmux for UART1 */ +static void enable_uart1simple_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_GPIO_PIN0_MASK | PMX_GPIO_PIN1_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_20_29_REG, + PMX_PL_28_29_MASK, + PMX_UART1_PL_28_29_VAL); +} + +/* Pinmux for UART1 modem */ +static void enable_uart1_modem_2to7_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_UART0_MASK | PMX_I2C_MASK | PMX_SSP_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_0_9_REG, + PMX_PL_2_3_MASK | PMX_PL_6_7_MASK, + PMX_UART1_ENH_PL_2_3_VAL | PMX_UART1_ENH_PL_4_5_VAL | + PMX_UART1_ENH_PL_6_7_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_UART1_ENH_PORT_SEL_MASK, + PMX_UART1_ENH_PORT_3_TO_5_7_VAL); +} + +static void enable_uart1_modem_31to36_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_GPIO_PIN3_MASK | PMX_GPIO_PIN4_MASK | + PMX_GPIO_PIN5_MASK | PMX_SSP_CS_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_30_39_REG, + PMX_PL_31_MASK | PMX_PL_32_33_MASK | PMX_PL_34_MASK | + PMX_PL_35_MASK | PMX_PL_36_MASK, + PMX_UART1_ENH_PL_31_VAL | PMX_UART1_ENH_PL_32_33_VAL | + PMX_UART1_ENH_PL_34_VAL | PMX_UART1_ENH_PL_35_VAL | + PMX_UART1_ENH_PL_36_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_UART1_ENH_PORT_SEL_MASK, + PMX_UART1_ENH_PORT_32_TO_34_36_VAL); +} + +static void enable_uart1_modem_34to45_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK | + PMX_SSP_CS_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_30_39_REG, + PMX_PL_34_MASK | PMX_PL_35_MASK | PMX_PL_36_MASK, + PMX_UART1_ENH_PL_34_VAL | PMX_UART1_ENH_PL_35_VAL | + PMX_UART1_ENH_PL_36_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_40_49_REG, + PMX_PL_43_MASK | PMX_PL_44_45_MASK, + PMX_UART1_ENH_PL_43_VAL | PMX_UART1_ENH_PL_44_45_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_UART1_ENH_PORT_SEL_MASK, + PMX_UART1_ENH_PORT_44_45_34_36_VAL); +} + +static void enable_uart1_modem_80to85_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_80_89_REG, + PMX_PL_80_TO_85_MASK, + PMX_UART1_ENH_PL_80_TO_85_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_40_49_REG, + PMX_PL_43_MASK | PMX_PL_44_45_MASK, + PMX_UART1_ENH_PL_43_VAL | PMX_UART1_ENH_PL_44_45_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_UART1_ENH_PORT_SEL_MASK, + PMX_UART1_ENH_PORT_81_TO_85_VAL); +} + +static void enable_uart1_pins(u32 mode) +{ + switch (mode) { + case PMX_UART_SIMPLE: + enable_uart1simple_pins(); + break; + case PMX_UART_MDM_2_7: + enable_uart1_modem_2to7_pins(); + break; + case PMX_UART_MDM_31_36: + enable_uart1_modem_31to36_pins(); + break; + case PMX_UART_MDM_34_45: + enable_uart1_modem_34to45_pins(); + break; + case PMX_UART_MDM_80_85: + enable_uart1_modem_80to85_pins(); + break; + } +} + +/* Pinmux for UART2 */ +static void enable_uart2_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_FIRDA_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_0_9_REG, + PMX_PL_0_1_MASK, + PMX_UART2_PL_0_1_VAL); +}; + +/* Pinmux for SSP1 */ +static void enable_ssp1_17to20_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_MII_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_10_19_REG, + PMX_PL_17_18_MASK | PMX_PL_19_MASK, + PMX_SSP1_PL_17_18_19_20_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_20_29_REG, + PMX_PL_20_MASK, + PMX_SSP1_PL_17_18_19_20_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP1_PORT_SEL_MASK, + PMX_SSP1_PORT_17_TO_20_VAL); +} + +static void enable_ssp1_36to39_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_UART0_MODEM_MASK | PMX_SSP_CS_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_30_39_REG, + PMX_PL_36_MASK | PMX_PL_37_38_MASK | PMX_PL_39_MASK, + PMX_SSP1_PL_36_VAL | PMX_SSP1_PL_37_38_VAL | + PMX_SSP1_PL_39_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP1_PORT_SEL_MASK, + PMX_SSP1_PORT_36_TO_39_VAL); +} + +static void enable_ssp1_48to51_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_40_49_REG, + PMX_PL_48_49_MASK, + PMX_SSP1_PL_48_49_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_50_59_REG, + PMX_PL_50_51_MASK, + PMX_SSP1_PL_50_51_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP1_PORT_SEL_MASK, + PMX_SSP1_PORT_48_TO_51_VAL); +} + +static void enable_ssp1_65to68_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_60_69_REG, + PMX_PL_65_TO_68_MASK, + PMX_SSP1_PL_65_TO_68_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP1_PORT_SEL_MASK, + PMX_SSP1_PORT_65_TO_68_VAL); +} + +static void enable_ssp1_94to97_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_90_99_REG, + PMX_PL_94_95_MASK | PMX_PL_96_97_MASK, + PMX_SSP1_PL_94_95_VAL | PMX_SSP1_PL_96_97_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP1_PORT_SEL_MASK, + PMX_SSP1_PORT_94_TO_97_VAL); +} + +static void enable_ssp1_pins(u32 mode) +{ + switch (mode) { + case PMX_SSP_17_20: + enable_ssp1_17to20_pins(); + break; + case PMX_SSP_36_39: + enable_ssp1_36to39_pins(); + break; + case PMX_SSP_48_51: + enable_ssp1_48to51_pins(); + break; + case PMX_SSP_65_68: + enable_ssp1_65to68_pins(); + break; + case PMX_SSP_94_97: + enable_ssp1_94to97_pins(); + break; + } +} + +/* Pinmux for SSP2 */ +static void enable_ssp2_13to16_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_MII_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_10_19_REG, + PMX_PL_13_14_MASK | PMX_PL_15_16_MASK, + PMX_SSP2_PL_13_14_15_16_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP2_PORT_SEL_MASK, + PMX_SSP2_PORT_13_TO_16_VAL); +} + +static void enable_ssp2_32to35_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_SSP_CS_MASK | PMX_GPIO_PIN4_MASK | + PMX_GPIO_PIN5_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_30_39_REG, + PMX_PL_32_33_MASK | PMX_PL_34_MASK | PMX_PL_35_MASK, + PMX_SSP2_PL_32_33_VAL | PMX_SSP2_PL_34_VAL | + PMX_SSP2_PL_35_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP2_PORT_SEL_MASK, + PMX_SSP2_PORT_32_TO_35_VAL); +} + +static void enable_ssp2_44to47_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_40_49_REG, + PMX_PL_44_45_MASK | PMX_PL_46_47_MASK, + PMX_SSP2_PL_44_45_VAL | PMX_SSP2_PL_46_47_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP2_PORT_SEL_MASK, + PMX_SSP2_PORT_44_TO_47_VAL); +} + +static void enable_ssp2_61to64_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_60_69_REG, + PMX_PL_61_TO_64_MASK, + PMX_SSP2_PL_61_TO_64_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP2_PORT_SEL_MASK, + PMX_SSP2_PORT_61_TO_64_VAL); +} + +static void enable_ssp2_90to93_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_90_99_REG, + PMX_PL_90_91_MASK | PMX_PL_92_93_MASK, + PMX_SSP2_PL_90_91_VAL | PMX_SSP2_PL_92_93_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_SSP2_PORT_SEL_MASK, + PMX_SSP2_PORT_90_TO_93_VAL); +} + +static void enable_ssp2_pins(u32 mode) +{ + switch (mode) { + case PMX_SSP_13_16: + enable_ssp2_13to16_pins(); + break; + case PMX_SSP_32_35: + enable_ssp2_32to35_pins(); + break; + case PMX_SSP_44_47: + enable_ssp2_44to47_pins(); + break; + case PMX_SSP_61_64: + enable_ssp2_61to64_pins(); + break; + case PMX_SSP_90_93: + enable_ssp2_90to93_pins(); + break; + } +} + +/* Pinmux for ETH2 */ +static void enable_mii2_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_80_89_REG, + PMX_PL_80_TO_85_MASK | PMX_PL_86_87_MASK | + PMX_PL_88_89_MASK, + PMX_MII2_PL_80_TO_85_VAL | PMX_MII2_PL_86_87_VAL | + PMX_MII2_PL_88_89_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_90_99_REG, + PMX_PL_90_91_MASK | PMX_PL_92_93_MASK | + PMX_PL_94_95_MASK | PMX_PL_96_97_MASK, + PMX_MII2_PL_90_91_VAL | PMX_MII2_PL_92_93_VAL | + PMX_MII2_PL_94_95_VAL | PMX_MII2_PL_96_97_VAL); + pinmux_maskval(SPEAR320_EXT_CTRL_REG, + (MAC_MODE_MASK << MAC2_MODE_SHIFT) | + (MAC_MODE_MASK << MAC1_MODE_SHIFT) | + MII_MDIO_MASK, + (MAC_MODE_MII << MAC2_MODE_SHIFT) | + (MAC_MODE_MII << MAC1_MODE_SHIFT) | + MII_MDIO_81_VAL); +} + +static void enable_smii2_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_MII_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_10_19_REG, + PMX_PL_10_11_MASK, + PMX_SMII_PL_10_11_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_20_29_REG, + PMX_PL_21_TO_27_MASK, + PMX_SMII_PL_21_TO_27_VAL); + pinmux_maskval(SPEAR320_EXT_CTRL_REG, + (MAC_MODE_MASK << MAC2_MODE_SHIFT) | + (MAC_MODE_MASK << MAC1_MODE_SHIFT) | + MII_MDIO_MASK, + (MAC_MODE_SMII << MAC2_MODE_SHIFT) + | (MAC_MODE_SMII << MAC1_MODE_SHIFT) + | MII_MDIO_10_11_VAL); +} + +static void enable_rmii2_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_MII_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_10_19_REG, + PMX_PL_10_11_MASK | PMX_PL_13_14_MASK | + PMX_PL_15_16_MASK | PMX_PL_17_18_MASK | PMX_PL_19_MASK, + PMX_RMII_PL_10_11_VAL | PMX_RMII_PL_13_14_VAL | + PMX_RMII_PL_15_16_VAL | PMX_RMII_PL_17_18_VAL | + PMX_RMII_PL_19_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_20_29_REG, + PMX_PL_20_MASK | PMX_PL_21_TO_27_MASK, + PMX_RMII_PL_20_VAL | PMX_RMII_PL_21_TO_27_VAL); + pinmux_maskval(SPEAR320_EXT_CTRL_REG, + (MAC_MODE_MASK << MAC2_MODE_SHIFT) | + (MAC_MODE_MASK << MAC1_MODE_SHIFT) | + MII_MDIO_MASK, + (MAC_MODE_RMII << MAC2_MODE_SHIFT) + | (MAC_MODE_RMII << MAC1_MODE_SHIFT) + | MII_MDIO_10_11_VAL); +} + +static void enable_eth2_pins(u32 mode) +{ + switch (mode) { + case PMX_ETH_MII: + enable_mii2_pins(); + break; + } +} + +static void enable_eth1_eth2_pins(u32 mode) +{ + switch (mode) { + case PMX_ETH_SMII: + enable_smii2_pins(); + break; + case PMX_ETH_RMII: + enable_rmii2_pins(); + break; + } +} + +/* Pinmux for I2C1 */ +static void enable_i2c1_8to9_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_SSP_CS_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_0_9_REG, + PMX_PL_8_9_MASK, + PMX_I2C1_PL_8_9_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_I2C1_PORT_SEL_MASK, + PMX_I2C1_PORT_8_9_VAL); +} + +static void enable_i2c1_98to99_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_90_99_REG, + PMX_PL_98_MASK | PMX_PL_99_MASK, + PMX_I2C1_PL_98_VAL | PMX_I2C1_PL_99_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_I2C1_PORT_SEL_MASK, + PMX_I2C1_PORT_98_99_VAL); +} + +static void enable_i2c1_pins(u32 mode) +{ + switch (mode) { + case PMX_I2C_8_9: + enable_i2c1_8to9_pins(); + break; + case PMX_I2C_98_99: + enable_i2c1_98to99_pins(); + break; + } +} + +/* Pinmux for I2C2 */ +static void enable_i2c2_0to1_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_FIRDA_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_0_9_REG, + PMX_PL_0_1_MASK, + PMX_I2C2_PL_0_1_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_I2C2_PORT_SEL_MASK, + PMX_I2C2_PORT_0_1_VAL); +} + +static void enable_i2c2_2to3_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_UART0_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_0_9_REG, + PMX_PL_2_3_MASK, + PMX_I2C2_PL_2_3_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_I2C2_PORT_SEL_MASK, + PMX_I2C2_PORT_2_3_VAL); +} + +static void enable_i2c2_19to20_pins(void) +{ + pinmux_maskval(SPEAR320_RASSELECT_REG, + PMX_MII_MASK, + 0); + pinmux_maskval(SPEAR320_IP_SEL_PAD_10_19_REG, + PMX_PL_19_MASK, + PMX_I2C2_PL_19_VAL); + pinmux_maskval(SPEAR320_IP_SEL_PAD_20_29_REG, + PMX_PL_20_MASK, + PMX_I2C2_PL_20_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_I2C2_PORT_SEL_MASK, + PMX_I2C2_PORT_19_20_VAL); +} + +static void enable_i2c2_75to76_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_70_79_REG, + PMX_PL_75_76_MASK, + PMX_I2C2_PL_75_76_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_I2C2_PORT_SEL_MASK, + PMX_I2C2_PORT_75_76_VAL); +} + +static void enable_i2c2_96to97_pins(void) +{ + pinmux_maskval(SPEAR320_IP_SEL_PAD_90_99_REG, + PMX_PL_96_97_MASK, + PMX_I2C2_PL_96_97_VAL); + pinmux_maskval(SPEAR320_IP_SEL_MIX_PAD_REG, + PMX_I2C2_PORT_SEL_MASK, + PMX_I2C2_PORT_96_97_VAL); +} + +static void enable_i2c2_pins(u32 mode) +{ + switch (mode) { + case PMX_I2C_0_1: + enable_i2c2_0to1_pins(); + break; + case PMX_I2C_2_3: + enable_i2c2_2to3_pins(); + break; + case PMX_I2C_19_20: + enable_i2c2_19to20_pins(); + break; + case PMX_I2C_75_76: + enable_i2c2_75to76_pins(); + break; + case PMX_I2C_96_97: + enable_i2c2_96to97_pins(); + break; + } +} + +/** + * spear320_select_mode + * @mode: SoC mode to e selected + */ +void spear320_select_mode(u32 mode) +{ + if (mode == SPEAR320_EXTENDED_MODE) { + pinmux_maskval(SPEAR320_EXT_CTRL_REG, + EXT_MODE_MASK, + EXT_MODE_MASK); + } else + printf("deprecated: Please run device only in ext mode\n"); +} + +/** + * spear320_pins_default: Select a default safe mode as startup + * Generally, all pins are enabled in input mode at initialization. This can be + * done either by + * - enabling gpio's and keeping all pins in gpio inputs + * - a platform specific way. + */ +void spear320_pins_default(void) +{ +} + +/** + * spear320_enable_pins - enable pins for fixed peripherals on spear3xx devices + * @ip: Peripheral index + * @mode: Mode in which peripheral has to run (16bit/8bit etc) + * + * Enable the pins for fixed peripherals on spear3xx devices. + * mode represents the mode in which the peripheral may work and may result in + * different pins being enabled. eg GMII mode and RGMII mode may need different + * pins on devices to be enabled + */ +void spear320_enable_pins(u32 ip, u32 mode) +{ + if (PMX_UART2 == ip) + enable_uart2_pins(); + else if (PMX_EMI == ip) + enable_emi_pins(); + else if (PMX_FSMCNAND == ip) + enable_nand_pins(mode); + else if (PMX_SDMMC == ip) + enable_sdmmc_pins(mode); + else if (PMX_UART1 == ip) + enable_uart1_pins(mode); + else if (PMX_I2C1 == ip) + enable_i2c1_pins(mode); + else if (PMX_I2C2 == ip) + enable_i2c2_pins(mode); + else if (PMX_SSP1 == ip) + enable_ssp1_pins(mode); + else if (PMX_SSP2 == ip) + enable_ssp2_pins(mode); + else if (PMX_ETH2 == ip) + enable_eth2_pins(mode); + else if (PMX_ETH1_ETH2 == ip) + enable_eth1_eth2_pins(mode); + else if ((PMX_I2C0 == ip) || (PMX_SSP0 == ip) || \ + (PMX_ETH0 == ip) || (PMX_UART0 == ip)) + spear3xx_enable_pins(ip, mode); +} + +static void configure_gpio(u32 plgpio) +{ + if (plgpio > SPEAR3XX_MAX_PLGPIOS) + return; + + /* Set the pin to GPIO IN mode */ + pinmux_set_bit(plgpio, SPEAR320_GPIO_EN0); + + /* Select GPIO mode */ + pinmux_set_bit(plgpio, SPEAR320_GPIO_SELECT0); + + /* Select RAS from Fixed Part / RAS */ + if (plgpio < 2) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_FIRDA_MASK, 0); + } else if (plgpio < 4) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_UART0_MASK, 0); + } else if (plgpio < 6) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_I2C_MASK, 0); + } else if (plgpio < 10) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_SSP_MASK, 0); + } else if (plgpio < 28) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_MII_MASK, 0); + } else if (plgpio < 29) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_GPIO_PIN0_MASK, 0); + } else if (plgpio < 30) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_GPIO_PIN1_MASK, 0); + } else if (plgpio < 31) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_GPIO_PIN2_MASK, 0); + } else if (plgpio < 32) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_GPIO_PIN3_MASK, 0); + } else if (plgpio < 33) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_GPIO_PIN4_MASK, 0); + } else if (plgpio < 34) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_GPIO_PIN5_MASK, 0); + } else if (plgpio < 37) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_SSP_CS_MASK, 0); + } else if (plgpio < 43) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_UART0_MODEM_MASK, 0); + } else if (plgpio < 51) { + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK, 0); + } +} + +/** + * spear320_configure_pin - Configure pin on spear320 devices + * @plgpio: Pin Number (plgpio number) + * @mode: Pull UP, Pull DOWN, plgpio IN, plgpio OUT etc + */ +void spear320_configure_pin(u32 plgpio, u32 mode) +{ + if (PMX_GPIO == mode) + configure_gpio(plgpio); +} + +/** + * spear320_plgpio_get - Get the gpio input + * @plgpio: Pin Number (plgpio number) + */ +int spear320_plgpio_get(u32 plgpio) +{ + if (plgpio > SPEAR3XX_MAX_PLGPIOS) + return -1; + + /* Set the pin to GPIO IN mode */ + pinmux_set_bit(plgpio, SPEAR320_GPIO_EN0); + + return pinmux_test_bit(plgpio, SPEAR320_GPIO_IN0); +} + +/** + * spear320_plgpio_set - Set the gpio value + * @plgpio: Pin Number (plgpio number) + */ +void spear320_plgpio_set(u32 plgpio, u32 val) +{ + if (plgpio > SPEAR3XX_MAX_PLGPIOS) + return; + + if (val & 0x1) + pinmux_set_bit(plgpio, SPEAR320_GPIO_OUT0); + else + pinmux_clear_bit(plgpio, SPEAR320_GPIO_OUT0); + + /* Set the pin to GPIO OUT mode */ + pinmux_clear_bit(plgpio, SPEAR320_GPIO_EN0); +} diff --git a/arch/arm/cpu/arm926ejs/spear/spear3xx.c b/arch/arm/cpu/arm926ejs/spear/spear3xx.c index 7a85fa9..612d237 100644 --- a/arch/arm/cpu/arm926ejs/spear/spear3xx.c +++ b/arch/arm/cpu/arm926ejs/spear/spear3xx.c @@ -25,6 +25,93 @@ #include <asm/io.h> #include <asm/arch/hardware.h> #include <asm/arch/misc.h> +#include <asm/arch/pinmux.h> + +/* Pinmux support for all fixed spear3xx devices */ + +/* Pinmux for I2C0 */ +static void enable_i2c0_pins(void) +{ + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_I2C_MASK, + PMX_I2C_MASK); +} + +/* Pinmux for SSP0 */ +static void enable_ssp0_pins(void) +{ + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_SSP_MASK, + PMX_SSP_MASK); +} + +/* Pinmux for ETH0 */ +static void enable_eth0_pins(void) +{ + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_MII_MASK, + PMX_MII_MASK); +} + +/* Pinmux for UART0 ext */ +static void enable_uart0_ext_pins(void) +{ + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_UART0_MODEM_MASK, + PMX_UART0_MODEM_MASK); + +} + +/* Pinmux for UART0 */ +static void enable_uart0_simple_pins(void) +{ + pinmux_maskval(SPEAR3XX_FUNC_ENB_REG, + PMX_UART0_MASK, + PMX_UART0_MASK); +} + +static void enable_uart0_pins(u32 mode) +{ + switch (mode) { + case PMX_UART_SIMPLE: + enable_uart0_simple_pins(); + break; + case PMX_UART_MODEM: + enable_uart0_ext_pins(); + break; + } +} + +/** + * spear3xx_enable_pins - enable pins for fixed peripherals on spear3xx devices + * @ip: Peripheral index + * @mode: Mode in which peripheral has to run (16bit/8bit etc) + * + * Enable the pins for fixed peripherals on spear3xx devices. + * mode represents the mode in which the peripheral may work and may result in + * different pins being enabled. eg GMII mode and RGMII mode may need different + * pins on devices to be enabled + */ +void spear3xx_enable_pins(u32 ip, u32 mode) +{ + switch (ip) { + case PMX_I2C0: + enable_i2c0_pins(); + break; + case PMX_SSP0: + enable_ssp0_pins(); + break; + case PMX_ETH0: + enable_eth0_pins(); + break; + case PMX_UART0: + enable_uart0_pins(mode); + break; + default: + printf("Unsupported device\n"); + break; + } +}
#if defined(CONFIG_USB_EHCI_SPEAR) void spear3xx_usbh_stop(void) diff --git a/arch/arm/include/asm/arch-spear/pinmux.h b/arch/arm/include/asm/arch-spear/pinmux.h new file mode 100644 index 0000000..faa46aa --- /dev/null +++ b/arch/arm/include/asm/arch-spear/pinmux.h @@ -0,0 +1,133 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef _ASM_ARCH_SPEAR_PINMUX_H +#define _ASM_ARCH_SPEAR_PINMUX_H + +#include <common.h> +#include <asm/io.h> +#include <asm/arch/hardware.h> + +static inline void pinmux_maskval(ulong reg, u32 mask, u32 val) +{ + u32 temp = readl((u32 *)reg); + temp &= ~mask; + temp |= val & mask; + writel(temp, (u32 *)reg); +} + +static inline void pinmux_set_bit(int nr, unsigned long addr) +{ + __set_bit(nr, (volatile unsigned long *)addr); +} + +static inline void pinmux_clear_bit(int nr, unsigned long addr) +{ + __clear_bit(nr, (volatile unsigned long *)addr); +} + +static inline int pinmux_test_bit(int nr, unsigned long addr) +{ + return __test_bit(nr, (volatile unsigned long *)addr); +} + +enum pinmux_ip { + PMX_UART0, + PMX_UART1, + PMX_UART2, + PMX_UART3, + PMX_UART4, + PMX_UART5, + PMX_I2C0, + PMX_I2C1, + PMX_I2C2, + PMX_SSP0, + PMX_SSP1, + PMX_SSP2, + PMX_ETH0, + PMX_ETH1, + PMX_ETH2, + PMX_ETH1_ETH2, + PMX_FSMCNAND, + PMX_FSMCPNOR, + PMX_SDMMC, + PMX_EMI, + PMX_SMI, +}; + +/* UART0 modem modes */ +#define PMX_UART_SIMPLE 1 +#define PMX_UART_MODEM 2 +#define PMX_UART_MDM_2_7 3 +#define PMX_UART_MDM_31_36 4 +#define PMX_UART_MDM_34_45 5 +#define PMX_UART_MDM_80_85 6 + +/* I2C modes */ +#define PMX_I2C_8_9 1 +#define PMX_I2C_98_99 2 +#define PMX_I2C_0_1 3 +#define PMX_I2C_2_3 4 +#define PMX_I2C_19_20 5 +#define PMX_I2C_75_76 6 +#define PMX_I2C_96_97 7 + +/* SSP modes */ +#define PMX_SSP_13_16 1 +#define PMX_SSP_17_20 2 +#define PMX_SSP_32_35 3 +#define PMX_SSP_36_39 4 +#define PMX_SSP_44_47 5 +#define PMX_SSP_48_51 6 +#define PMX_SSP_61_64 7 +#define PMX_SSP_65_68 8 +#define PMX_SSP_90_93 9 +#define PMX_SSP_94_97 10 + +/* ETH modes */ +#define PMX_ETH_GMII 1 +#define PMX_ETH_MII 2 +#define PMX_ETH_RGMII 3 +#define PMX_ETH_RMII 4 +#define PMX_ETH_SGMII 5 +#define PMX_ETH_SMII 6 + +/* NAND modes */ +#define PMX_NAND_8BIT 1 +#define PMX_NAND_16BIT 2 +#define PMX_NAND_2CHIP 3 +#define PMX_NAND_4CHIP 4 + +/* SDMMC modes */ +#define PMX_SDMMC_LED 1 +#define PMX_SDMMC_CD12 2 +#define PMX_SDMMC_CD51 3 +#define PMX_SDMMC_4BIT 4 +#define PMX_SDMMC_8BIT 5 + +/* PLGPIO modes */ +#define PMX_GPIO 1 +#define PMX_PULLUP 2 +#define PMX_PULLDOWN 3 + +#endif diff --git a/arch/arm/include/asm/arch-spear/spear300.h b/arch/arm/include/asm/arch-spear/spear300.h index 24faaea..4bfa619 100644 --- a/arch/arm/include/asm/arch-spear/spear300.h +++ b/arch/arm/include/asm/arch-spear/spear300.h @@ -30,4 +30,31 @@ #define CONFIG_SYS_NAND_CLE (1 << 16) #define CONFIG_SYS_NAND_ALE (1 << 17)
+/* RAS misc registers and respective bitmasks */ +#define CONFIG_SYS_RAS_BASE 0x99000000 +#define SPEAR300_RAS_REG1 CONFIG_SYS_RAS_BASE + /* Bitmaks for REG1 are in spear3xx.h */ +#define SPEAR300_RAS_REG2 (CONFIG_SYS_RAS_BASE + 0x04) + #define SPEAR300_MODE_MSK (0xF << 0) + #define SPEAR300_MODE_NAND (0x0 << 0) + #define SPEAR300_MODE_NOR (0x1 << 0) + #define SPEAR300_MODE_PHOTOFRAME (0x2 << 0) + #define SPEAR300_MODE_LENDIPFONE (0x3 << 0) + #define SPEAR300_MODE_HENDIPFONE (0x4 << 0) + #define SPEAR300_MODE_LENDWIFIFONE (0x5 << 0) + #define SPEAR300_MODE_HENDWIFIFONE (0x6 << 0) + #define SPEAR300_MODE_ATAPABXWI2S (0x7 << 0) + #define SPEAR300_MODE_ATAPABXI2S (0x8 << 0) + #define SPEAR300_MODE_CAM1LCDW (0xC << 0) + #define SPEAR300_MODE_CAMULCD (0xD << 0) + #define SPEAR300_MODE_CAMULCDW (0xE << 0) + #define SPEAR300_MODE_CAM1LCD (0xF << 0) + +#define SPEAR3XX_FUNC_ENB_REG SPEAR300_RAS_REG1 + +/* externs related to pinmux */ +extern void spear300_pins_default(void); +extern void spear300_select_mode(u32 mode); +extern void spear300_enable_pins(u32 ip, u32 mode); + #endif diff --git a/arch/arm/include/asm/arch-spear/spear310.h b/arch/arm/include/asm/arch-spear/spear310.h index 0f6223e..9d20237 100644 --- a/arch/arm/include/asm/arch-spear/spear310.h +++ b/arch/arm/include/asm/arch-spear/spear310.h @@ -37,4 +37,17 @@ #define CONFIG_SYS_MACB3_BASE 0xB1800000 #define CONFIG_SPEAR_RASBASE 0xB4000000
+/* SPEAr310 RAS misc space registers and bitmasks */ +#define SPEAR310_FUNCENB_REG (CONFIG_SPEAR_RASBASE + 0x8) + +#define SPEAR310_SMII_REG (CONFIG_SPEAR_RASBASE + 0xC) + #define SPEAR310_SMII_PHY_SHIFT 0x0 + #define SPEAR310_SMII_PHY_MASK 0x3 + +#define SPEAR3XX_FUNC_ENB_REG SPEAR310_FUNCENB_REG + +/* externs related to pinmux */ +extern void spear310_pins_default(void); +extern void spear310_enable_pins(u32 ip, u32 mode); + #endif diff --git a/arch/arm/include/asm/arch-spear/spear320.h b/arch/arm/include/asm/arch-spear/spear320.h index 110afc3..abdcda6 100644 --- a/arch/arm/include/asm/arch-spear/spear320.h +++ b/arch/arm/include/asm/arch-spear/spear320.h @@ -35,4 +35,430 @@ #define CONFIG_SYS_MACB1_BASE 0xAB000000 #define CONFIG_SPEAR_RASBASE 0xB3000000
+/* SPEAr320 SoC device modes */ +#define SPEAR320_AUTO_NET_SMII_MODE (1 << 0) +#define SPEAR320_AUTO_NET_MII_MODE (1 << 1) +#define SPEAR320_AUTO_EXP_MODE (1 << 2) +#define SPEAR320_SMALL_PRINTERS_MODE (1 << 3) +#define SPEAR320_EXTENDED_MODE (1 << 4) + +/* SPEAr320 RAS misc space registers and bitmasks */ +#define SPEAR320_RASSELECT_REG (CONFIG_SPEAR_RASBASE + 0x000C) + +#define SPEAR320_CONTROL_REG (CONFIG_SPEAR_RASBASE + 0x0010) + #define MII_ENB_SHFT 5 + +/* Extended mode registers and their offsets */ +#define SPEAR320_EXT_CTRL_REG (CONFIG_SPEAR_RASBASE + 0x0018) + #define EXT_MODE_MASK (1 << 0) + #define MII_MDIO_MASK (1 << 4) + #define MII_MDIO_10_11_VAL 0 + #define MII_MDIO_81_VAL (1 << 4) + #define EMI_FSMC_DYNAMIC_MUX_MASK (1 << 5) + #define MAC_MODE_MII 0 + #define MAC_MODE_RMII 1 + #define MAC_MODE_SMII 2 + #define MAC_MODE_SS_SMII 3 + #define MAC_MODE_MASK 0x3 + #define MAC1_MODE_SHIFT 16 + #define MAC2_MODE_SHIFT 18 + +#define SPEAR320_GPIO_SELECT0 (CONFIG_SPEAR_RASBASE + 0x0024) +#define SPEAR320_GPIO_OUT0 (CONFIG_SPEAR_RASBASE + 0x0034) +#define SPEAR320_GPIO_EN0 (CONFIG_SPEAR_RASBASE + 0x0044) +#define SPEAR320_GPIO_IN0 (CONFIG_SPEAR_RASBASE + 0x0054) + +#define SPEAR320_IP_SEL_PAD_0_9_REG (CONFIG_SPEAR_RASBASE + 0x00A4) + #define PMX_PL_0_1_MASK (0x3F << 0) + #define PMX_UART2_PL_0_1_VAL 0x0 + #define PMX_I2C2_PL_0_1_VAL (0x4 | (0x4 << 3)) + + #define PMX_PL_2_3_MASK (0x3F << 6) + #define PMX_I2C2_PL_2_3_VAL 0x0 + #define PMX_UART6_PL_2_3_VAL ((0x1 << 6) | (0x1 << 9)) + #define PMX_UART1_ENH_PL_2_3_VAL ((0x4 << 6) | (0x4 << 9)) + + #define PMX_PL_4_5_MASK (0x3F << 12) + #define PMX_UART5_PL_4_5_VAL ((0x1 << 12) | (0x1 << 15)) + #define PMX_UART1_ENH_PL_4_5_VAL ((0x4 << 12) | (0x4 << 15)) + #define PMX_PL_5_MASK (0x7 << 15) + #define PMX_TOUCH_Y_PL_5_VAL 0x0 + + #define PMX_PL_6_7_MASK (0x3F << 18) + #define PMX_PL_6_MASK (0x7 << 18) + #define PMX_PL_7_MASK (0x7 << 21) + #define PMX_UART4_PL_6_7_VAL ((0x1 << 18) | (0x1 << 21)) + #define PMX_PWM_3_PL_6_VAL (0x2 << 18) + #define PMX_PWM_2_PL_7_VAL (0x2 << 21) + #define PMX_UART1_ENH_PL_6_7_VAL ((0x4 << 18) | (0x4 << 21)) + + #define PMX_PL_8_9_MASK (0x3F << 24) + #define PMX_UART3_PL_8_9_VAL ((0x1 << 24) | (0x1 << 27)) + #define PMX_PWM_0_1_PL_8_9_VAL ((0x2 << 24) | (0x2 << 27)) + #define PMX_I2C1_PL_8_9_VAL ((0x4 << 24) | (0x4 << 27)) + +#define SPEAR320_IP_SEL_PAD_10_19_REG (CONFIG_SPEAR_RASBASE + 0x00A8) + #define PMX_PL_10_11_MASK (0x3F << 0) + #define PMX_SMII_PL_10_11_VAL 0 + #define PMX_RMII_PL_10_11_VAL ((0x4 << 0) | (0x4 << 3)) + + #define PMX_PL_12_MASK (0x7 << 6) + #define PMX_PWM3_PL_12_VAL 0 + #define PMX_SDHCI_CD_PL_12_VAL (0x4 << 6) + + #define PMX_PL_13_14_MASK (0x3F << 9) + #define PMX_PL_13_MASK (0x7 << 9) + #define PMX_PL_14_MASK (0x7 << 12) + #define PMX_SSP2_PL_13_14_15_16_VAL 0 + #define PMX_UART4_PL_13_14_VAL ((0x1 << 9) | (0x1 << 12)) + #define PMX_RMII_PL_13_14_VAL ((0x4 << 9) | (0x4 << 12)) + #define PMX_PWM2_PL_13_VAL (0x2 << 9) + #define PMX_PWM1_PL_14_VAL (0x2 << 12) + + #define PMX_PL_15_MASK (0x7 << 15) + #define PMX_PWM0_PL_15_VAL (0x2 << 15) + #define PMX_PL_15_16_MASK (0x3F << 15) + #define PMX_UART3_PL_15_16_VAL ((0x1 << 15) | (0x1 << 18)) + #define PMX_RMII_PL_15_16_VAL ((0x4 << 15) | (0x4 << 18)) + + #define PMX_PL_17_18_MASK (0x3F << 21) + #define PMX_SSP1_PL_17_18_19_20_VAL 0 + #define PMX_RMII_PL_17_18_VAL ((0x4 << 21) | (0x4 << 24)) + + #define PMX_PL_19_MASK (0x7 << 27) + #define PMX_I2C2_PL_19_VAL (0x1 << 27) + #define PMX_RMII_PL_19_VAL (0x4 << 27) + +#define SPEAR320_IP_SEL_PAD_20_29_REG (CONFIG_SPEAR_RASBASE + 0x00AC) + #define PMX_PL_20_MASK (0x7 << 0) + #define PMX_I2C2_PL_20_VAL (0x1 << 0) + #define PMX_RMII_PL_20_VAL (0x4 << 0) + + #define PMX_PL_21_TO_27_MASK (0x1FFFFF << 3) + #define PMX_SMII_PL_21_TO_27_VAL 0 + #define PMX_RMII_PL_21_TO_27_VAL ((0x4 << 3) | (0x4 << 6) | \ + (0x4 << 9) | (0x4 << 12) | \ + (0x4 << 15) | (0x4 << 18) | \ + (0x4 << 21)) + + #define PMX_PL_28_29_MASK (0x3F << 24) + #define PMX_PL_28_MASK (0x7 << 24) + #define PMX_PL_29_MASK (0x7 << 27) + #define PMX_UART1_PL_28_29_VAL 0 + #define PMX_PWM_3_PL_28_VAL (0x4 << 24) + #define PMX_PWM_2_PL_29_VAL (0x4 << 27) + +#define SPEAR320_IP_SEL_PAD_30_39_REG (CONFIG_SPEAR_RASBASE + 0x00B0) + #define PMX_PL_30_31_MASK (0x3F << 0) + #define PMX_CAN1_PL_30_31_VAL (0) + #define PMX_PL_30_MASK (0x7 << 0) + #define PMX_PL_31_MASK (0x7 << 3) + #define PMX_PWM1_EXT_PL_30_VAL (0x4 << 0) + #define PMX_PWM0_EXT_PL_31_VAL (0x4 << 3) + #define PMX_UART1_ENH_PL_31_VAL (0x3 << 3) + + #define PMX_PL_32_33_MASK (0x3F << 6) + #define PMX_CAN0_PL_32_33_VAL 0 + #define PMX_UART1_ENH_PL_32_33_VAL ((0x3 << 6) | (0x3 << 9)) + #define PMX_SSP2_PL_32_33_VAL ((0x4 << 6) | (0x4 << 9)) + + #define PMX_PL_34_MASK (0x7 << 12) + #define PMX_PWM2_PL_34_VAL 0 + #define PMX_UART1_ENH_PL_34_VAL (0x2 << 12) + #define PMX_SSP2_PL_34_VAL (0x4 << 12) + + #define PMX_PL_35_MASK (0x7 << 15) + #define PMX_I2S_REF_CLK_PL_35_VAL 0 + #define PMX_UART1_ENH_PL_35_VAL (0x2 << 15) + #define PMX_SSP2_PL_35_VAL (0x4 << 15) + + #define PMX_PL_36_MASK (0x7 << 18) + #define PMX_TOUCH_X_PL_36_VAL 0 + #define PMX_UART1_ENH_PL_36_VAL (0x2 << 18) + #define PMX_SSP1_PL_36_VAL (0x4 << 18) + + #define PMX_PL_37_38_MASK (0x3F << 21) + #define PMX_PWM0_1_PL_37_38_VAL 0 + #define PMX_UART5_PL_37_38_VAL ((0x2 << 21) | (0x2 << 24)) + #define PMX_SSP1_PL_37_38_VAL ((0x4 << 21) | (0x4 << 24)) + + #define PMX_PL_39_MASK (0x7 << 27) + #define PMX_I2S_PL_39_VAL 0 + #define PMX_UART4_PL_39_VAL (0x2 << 27) + #define PMX_SSP1_PL_39_VAL (0x4 << 27) + +#define SPEAR320_IP_SEL_PAD_40_49_REG (CONFIG_SPEAR_RASBASE + 0x00B4) + #define PMX_PL_40_MASK (0x7 << 0) + #define PMX_I2S_PL_40_VAL 0 + #define PMX_UART4_PL_40_VAL (0x2 << 0) + #define PMX_PWM3_PL_40_VAL (0x4 << 0) + + #define PMX_PL_41_42_MASK (0x3F << 3) + #define PMX_PL_41_MASK (0x7 << 3) + #define PMX_PL_42_MASK (0x7 << 6) + #define PMX_I2S_PL_41_42_VAL 0 + #define PMX_UART3_PL_41_42_VAL ((0x2 << 3) | (0x2 << 6)) + #define PMX_PWM2_PL_41_VAL (0x4 << 3) + #define PMX_PWM1_PL_42_VAL (0x4 << 6) + + #define PMX_PL_43_MASK (0x7 << 9) + #define PMX_SDHCI_PL_43_VAL 0 + #define PMX_UART1_ENH_PL_43_VAL (0x2 << 9) + #define PMX_PWM0_PL_43_VAL (0x4 << 9) + + #define PMX_PL_44_45_MASK (0x3F << 12) + #define PMX_SDHCI_PL_44_45_VAL 0 + #define PMX_UART1_ENH_PL_44_45_VAL ((0x2 << 12) | (0x2 << 15)) + #define PMX_SSP2_PL_44_45_VAL ((0x4 << 12) | (0x4 << 15)) + + #define PMX_PL_46_47_MASK (0x3F << 18) + #define PMX_SDHCI_PL_46_47_VAL 0 + #define PMX_FSMC_EMI_PL_46_47_VAL ((0x2 << 18) | (0x2 << 21)) + #define PMX_SSP2_PL_46_47_VAL ((0x4 << 18) | (0x4 << 21)) + + #define PMX_PL_48_49_MASK (0x3F << 24) + #define PMX_SDHCI_PL_48_49_VAL 0 + #define PMX_FSMC_EMI_PL_48_49_VAL ((0x2 << 24) | (0x2 << 27)) + #define PMX_SSP1_PL_48_49_VAL ((0x4 << 24) | (0x4 << 27)) + +#define SPEAR320_IP_SEL_PAD_50_59_REG (CONFIG_SPEAR_RASBASE + 0x00B8) + #define PMX_PL_50_51_MASK (0x3F << 0) + #define PMX_EMI_PL_50_51_VAL ((0x2 << 0) | (0x2 << 3)) + #define PMX_SSP1_PL_50_51_VAL ((0x4 << 0) | (0x4 << 3)) + #define PMX_PL_50_MASK (0x7 << 0) + #define PMX_PL_51_MASK (0x7 << 3) + #define PMX_SDHCI_PL_50_VAL 0 + #define PMX_SDHCI_CD_PL_51_VAL 0 + + #define PMX_PL_52_53_MASK (0x3F << 6) + #define PMX_FSMC_PL_52_53_VAL 0 + #define PMX_EMI_PL_52_53_VAL ((0x2 << 6) | (0x2 << 9)) + #define PMX_UART3_PL_52_53_VAL ((0x4 << 6) | (0x4 << 9)) + + #define PMX_PL_54_55_56_MASK (0x1FF << 12) + #define PMX_FSMC_EMI_PL_54_55_56_VAL ((0x2 << 12) | (0x2 << 15) | \ + (0x2 << 18)) + + #define PMX_PL_57_MASK (0x7 << 21) + #define PMX_FSMC_PL_57_VAL 0 + #define PMX_PWM3_PL_57_VAL (0x4 << 21) + + #define PMX_PL_58_59_MASK (0x3F << 24) + #define PMX_PL_58_MASK (0x7 << 24) + #define PMX_PL_59_MASK (0x7 << 27) + #define PMX_FSMC_EMI_PL_58_59_VAL ((0x2 << 24) | (0x2 << 27)) + #define PMX_PWM2_PL_58_VAL (0x4 << 24) + #define PMX_PWM1_PL_59_VAL (0x4 << 27) + +#define SPEAR320_IP_SEL_PAD_60_69_REG (CONFIG_SPEAR_RASBASE + 0x00BC) + #define PMX_PL_60_MASK (0x7 << 0) + #define PMX_FSMC_PL_60_VAL 0 + #define PMX_PWM0_PL_60_VAL (0x4 << 0) + + #define PMX_PL_61_TO_64_MASK (0xFFF << 3) + #define PMX_FSMC_PL_61_TO_64_VAL ((0x2 << 3) | (0x2 << 6) | \ + (0x2 << 9) | (0x2 << 12)) + #define PMX_SSP2_PL_61_TO_64_VAL ((0x4 << 3) | (0x4 << 6) | \ + (0x4 << 9) | (0x4 << 12)) + + #define PMX_PL_65_TO_68_MASK (0xFFF << 15) + #define PMX_FSMC_PL_65_TO_68_VAL ((0x2 << 15) | (0x2 << 18) | \ + (0x2 << 21) | (0x2 << 24)) + #define PMX_SSP1_PL_65_TO_68_VAL ((0x4 << 15) | (0x4 << 18) | \ + (0x4 << 21) | (0x4 << 24)) + + #define PMX_PL_69_MASK (0x7 << 27) + #define PMX_CLCD_PL_69_VAL (0) + #define PMX_EMI_PL_69_VAL (0x2 << 27) + #define PMX_SPP_PL_69_VAL (0x3 << 27) + #define PMX_UART5_PL_69_VAL (0x4 << 27) + +#define SPEAR320_IP_SEL_PAD_70_79_REG (CONFIG_SPEAR_RASBASE + 0x00C0) + #define PMX_PL_70_MASK (0x7 << 0) + #define PMX_CLCD_PL_70_VAL (0) + #define PMX_FSMC_EMI_PL_70_VAL (0x2 << 0) + #define PMX_SPP_PL_70_VAL (0x3 << 0) + #define PMX_UART5_PL_70_VAL (0x4 << 0) + + #define PMX_PL_71_72_MASK (0x3F << 3) + #define PMX_CLCD_PL_71_72_VAL (0) + #define PMX_FSMC_EMI_PL_71_72_VAL ((0x2 << 3) | (0x2 << 6)) + #define PMX_SPP_PL_71_72_VAL ((0x3 << 3) | (0x3 << 6)) + #define PMX_UART4_PL_71_72_VAL ((0x4 << 3) | (0x4 << 6)) + + #define PMX_PL_73_MASK (0x7 << 9) + #define PMX_CLCD_PL_73_VAL (0) + #define PMX_FSMC_EMI_PL_73_VAL (0x2 << 9) + #define PMX_SPP_PL_73_VAL (0x3 << 9) + #define PMX_UART3_PL_73_VAL (0x4 << 9) + + #define PMX_PL_74_MASK (0x7 << 12) + #define PMX_CLCD_PL_74_VAL (0) + #define PMX_EMI_PL_74_VAL (0x2 << 12) + #define PMX_SPP_PL_74_VAL (0x3 << 12) + #define PMX_UART3_PL_74_VAL (0x4 << 12) + + #define PMX_PL_75_76_MASK (0x3F << 15) + #define PMX_CLCD_PL_75_76_VAL (0) + #define PMX_EMI_PL_75_76_VAL ((0x2 << 15) | (0x2 << 18)) + #define PMX_SPP_PL_75_76_VAL ((0x3 << 15) | (0x3 << 18)) + #define PMX_I2C2_PL_75_76_VAL ((0x4 << 15) | (0x4 << 18)) + + #define PMX_PL_77_78_79_MASK (0x1FF << 21) + #define PMX_CLCD_PL_77_78_79_VAL (0) + #define PMX_EMI_PL_77_78_79_VAL ((0x2 << 21) | (0x2 << 24) | \ + (0x2 << 27)) + #define PMX_SPP_PL_77_78_79_VAL ((0x3 << 21) | (0x3 << 24) | \ + (0x3 << 27)) + #define PMX_RS485_PL_77_78_79_VAL ((0x4 << 21) | (0x4 << 24) | \ + (0x4 << 27)) + +#define SPEAR320_IP_SEL_PAD_80_89_REG (CONFIG_SPEAR_RASBASE + 0x00C4) + #define PMX_PL_80_TO_85_MASK (0x3FFFF << 0) + #define PMX_CLCD_PL_80_TO_85_VAL 0 + #define PMX_MII2_PL_80_TO_85_VAL ((0x1 << 0) | (0x1 << 3) | \ + (0x1 << 6) | (0x1 << 9) | \ + (0x1 << 12) | (0x1 << 15)) + #define PMX_EMI_PL_80_TO_85_VAL ((0x2 << 0) | (0x2 << 3) | \ + (0x2 << 6) | (0x2 << 9) | \ + (0x2 << 12) | (0x2 << 15)) + #define PMX_SPP_PL_80_TO_85_VAL ((0x3 << 0) | (0x3 << 3) | \ + (0x3 << 6) | (0x3 << 9) | \ + (0x3 << 12) | (0x3 << 15)) + #define PMX_UART1_ENH_PL_80_TO_85_VAL ((0x4 << 0) | (0x4 << 3) | \ + (0x4 << 6) | (0x4 << 9) | \ + (0x4 << 12) | (0x4 << 15)) + + #define PMX_PL_86_87_MASK (0x3F << 18) + #define PMX_PL_86_MASK (0x7 << 18) + #define PMX_PL_87_MASK (0x7 << 21) + #define PMX_CLCD_PL_86_87_VAL 0 + #define PMX_MII2_PL_86_87_VAL ((0x1 << 18) | (0x1 << 21)) + #define PMX_EMI_PL_86_87_VAL ((0x2 << 18) | (0x2 << 21)) + #define PMX_PWM3_PL_86_VAL (0x4 << 18) + #define PMX_PWM2_PL_87_VAL (0x4 << 21) + + #define PMX_PL_88_89_MASK (0x3F << 24) + #define PMX_CLCD_PL_88_89_VAL 0 + #define PMX_MII2_PL_88_89_VAL ((0x1 << 24) | (0x1 << 27)) + #define PMX_EMI_PL_88_89_VAL ((0x2 << 24) | (0x2 << 27)) + #define PMX_UART6_PL_88_89_VAL ((0x3 << 24) | (0x3 << 27)) + #define PMX_PWM0_1_PL_88_89_VAL ((0x4 << 24) | (0x4 << 27)) + +#define SPEAR320_IP_SEL_PAD_90_99_REG (CONFIG_SPEAR_RASBASE + 0x00C8) + #define PMX_PL_90_91_MASK (0x3F << 0) + #define PMX_CLCD_PL_90_91_VAL 0 + #define PMX_MII2_PL_90_91_VAL ((0x1 << 0) | (0x1 << 3)) + #define PMX_EMI1_PL_90_91_VAL ((0x2 << 0) | (0x2 << 3)) + #define PMX_UART5_PL_90_91_VAL ((0x3 << 0) | (0x3 << 3)) + #define PMX_SSP2_PL_90_91_VAL ((0x4 << 0) | (0x4 << 3)) + + #define PMX_PL_92_93_MASK (0x3F << 6) + #define PMX_CLCD_PL_92_93_VAL 0 + #define PMX_MII2_PL_92_93_VAL ((0x1 << 6) | (0x1 << 9)) + #define PMX_EMI1_PL_92_93_VAL ((0x2 << 6) | (0x2 << 9)) + #define PMX_UART4_PL_92_93_VAL ((0x3 << 6) | (0x3 << 9)) + #define PMX_SSP2_PL_92_93_VAL ((0x4 << 6) | (0x4 << 9)) + + #define PMX_PL_94_95_MASK (0x3F << 12) + #define PMX_CLCD_PL_94_95_VAL 0 + #define PMX_MII2_PL_94_95_VAL ((0x1 << 12) | (0x1 << 15)) + #define PMX_EMI1_PL_94_95_VAL ((0x2 << 12) | (0x2 << 15)) + #define PMX_UART3_PL_94_95_VAL ((0x3 << 12) | (0x3 << 15)) + #define PMX_SSP1_PL_94_95_VAL ((0x4 << 12) | (0x4 << 15)) + + #define PMX_PL_96_97_MASK (0x3F << 18) + #define PMX_CLCD_PL_96_97_VAL 0 + #define PMX_MII2_PL_96_97_VAL ((0x1 << 18) | (0x1 << 21)) + #define PMX_EMI1_PL_96_97_VAL ((0x2 << 18) | (0x2 << 21)) + #define PMX_I2C2_PL_96_97_VAL ((0x3 << 18) | (0x3 << 21)) + #define PMX_SSP1_PL_96_97_VAL ((0x4 << 18) | (0x4 << 21)) + + #define PMX_PL_98_MASK (0x7 << 24) + #define PMX_CLCD_PL_98_VAL 0 + #define PMX_I2C1_PL_98_VAL (0x2 << 24) + #define PMX_UART3_PL_98_VAL (0x4 << 24) + + #define PMX_PL_99_MASK (0x7 << 27) + #define PMX_SDHCI_PL_99_VAL 0 + #define PMX_I2C1_PL_99_VAL (0x2 << 27) + #define PMX_UART3_PL_99_VAL (0x4 << 27) + +#define SPEAR320_IP_SEL_MIX_PAD_REG (CONFIG_SPEAR_RASBASE + 0x00CC) + #define PMX_PL_100_101_MASK (0x3F << 0) + #define PMX_SDHCI_PL_100_101_VAL 0 + #define PMX_UART4_PL_100_101_VAL ((0x4 << 0) | (0x4 << 3)) + + #define PMX_SSP1_PORT_SEL_MASK (0x7 << 8) + #define PMX_SSP1_PORT_94_TO_97_VAL 0 + #define PMX_SSP1_PORT_65_TO_68_VAL (0x1 << 8) + #define PMX_SSP1_PORT_48_TO_51_VAL (0x2 << 8) + #define PMX_SSP1_PORT_36_TO_39_VAL (0x3 << 8) + #define PMX_SSP1_PORT_17_TO_20_VAL (0x4 << 8) + + #define PMX_SSP2_PORT_SEL_MASK (0x7 << 11) + #define PMX_SSP2_PORT_90_TO_93_VAL 0 + #define PMX_SSP2_PORT_61_TO_64_VAL (0x1 << 11) + #define PMX_SSP2_PORT_44_TO_47_VAL (0x2 << 11) + #define PMX_SSP2_PORT_32_TO_35_VAL (0x3 << 11) + #define PMX_SSP2_PORT_13_TO_16_VAL (0x4 << 11) + + #define PMX_UART1_ENH_PORT_SEL_MASK (0x3 << 14) + #define PMX_UART1_ENH_PORT_81_TO_85_VAL 0 + #define PMX_UART1_ENH_PORT_44_45_34_36_VAL (0x1 << 14) + #define PMX_UART1_ENH_PORT_32_TO_34_36_VAL (0x2 << 14) + #define PMX_UART1_ENH_PORT_3_TO_5_7_VAL (0x3 << 14) + + #define PMX_UART3_PORT_SEL_MASK (0x7 << 16) + #define PMX_UART3_PORT_94_VAL 0 + #define PMX_UART3_PORT_73_VAL (0x1 << 16) + #define PMX_UART3_PORT_52_VAL (0x2 << 16) + #define PMX_UART3_PORT_41_VAL (0x3 << 16) + #define PMX_UART3_PORT_15_VAL (0x4 << 16) + #define PMX_UART3_PORT_8_VAL (0x5 << 16) + #define PMX_UART3_PORT_99_VAL (0x6 << 16) + + #define PMX_UART4_PORT_SEL_MASK (0x7 << 19) + #define PMX_UART4_PORT_92_VAL 0 + #define PMX_UART4_PORT_71_VAL (0x1 << 19) + #define PMX_UART4_PORT_39_VAL (0x2 << 19) + #define PMX_UART4_PORT_13_VAL (0x3 << 19) + #define PMX_UART4_PORT_6_VAL (0x4 << 19) + #define PMX_UART4_PORT_101_VAL (0x5 << 19) + + #define PMX_UART5_PORT_SEL_MASK (0x3 << 22) + #define PMX_UART5_PORT_90_VAL 0 + #define PMX_UART5_PORT_69_VAL (0x1 << 22) + #define PMX_UART5_PORT_37_VAL (0x2 << 22) + #define PMX_UART5_PORT_4_VAL (0x3 << 22) + + #define PMX_UART6_PORT_SEL_MASK (0x1 << 24) + #define PMX_UART6_PORT_88_VAL 0 + #define PMX_UART6_PORT_2_VAL (0x1 << 24) + + #define PMX_I2C1_PORT_SEL_MASK (0x1 << 25) + #define PMX_I2C1_PORT_8_9_VAL 0 + #define PMX_I2C1_PORT_98_99_VAL (0x1 << 25) + + #define PMX_I2C2_PORT_SEL_MASK (0x3 << 26) + #define PMX_I2C2_PORT_96_97_VAL 0 + #define PMX_I2C2_PORT_75_76_VAL (0x1 << 26) + #define PMX_I2C2_PORT_19_20_VAL (0x2 << 26) + #define PMX_I2C2_PORT_2_3_VAL (0x3 << 26) + #define PMX_I2C2_PORT_0_1_VAL (0x4 << 26) + + #define PMX_SDHCI_CD_PORT_SEL_MASK (0x1 << 29) + #define PMX_SDHCI_CD_PORT_12_VAL 0 + #define PMX_SDHCI_CD_PORT_51_VAL (0x1 << 29) + +#define SPEAR3XX_FUNC_ENB_REG SPEAR320_RASSELECT_REG + +/* externs related to pinmux */ +extern void spear320_pins_default(void); +extern void spear320_select_mode(u32 mode); +extern void spear320_enable_pins(u32 ip, u32 mode); +extern void spear320_configure_pin(u32 plgpio, u32 mode); +extern void spear320_plgpio_set(u32 plgpio, u32 val); +extern int spear320_plgpio_get(u32 plgpio); + #endif diff --git a/arch/arm/include/asm/arch-spear/spear3xx.h b/arch/arm/include/asm/arch-spear/spear3xx.h index e0a72f0..f0df4e6 100644 --- a/arch/arm/include/asm/arch-spear/spear3xx.h +++ b/arch/arm/include/asm/arch-spear/spear3xx.h @@ -37,4 +37,26 @@ #define CONFIG_SPEAR_SYSCNTLBASE 0xFCA00000 #define CONFIG_SPEAR_MISCBASE 0xFCA80000
+/* spear3xx pinmux register and related bit masks */ +#define PMX_FIRDA_MASK (1 << 14) +#define PMX_I2C_MASK (1 << 13) +#define PMX_SSP_CS_MASK (1 << 12) +#define PMX_SSP_MASK (1 << 11) +#define PMX_MII_MASK (1 << 10) +#define PMX_GPIO_PIN0_MASK (1 << 9) +#define PMX_GPIO_PIN1_MASK (1 << 8) +#define PMX_GPIO_PIN2_MASK (1 << 7) +#define PMX_GPIO_PIN3_MASK (1 << 6) +#define PMX_GPIO_PIN4_MASK (1 << 5) +#define PMX_GPIO_PIN5_MASK (1 << 4) +#define PMX_UART0_MODEM_MASK (1 << 3) +#define PMX_UART0_MASK (1 << 2) +#define PMX_TIMER_2_3_MASK (1 << 1) +#define PMX_TIMER_0_1_MASK (1 << 0) + +#define SPEAR3XX_MAX_PLGPIOS 101 + +/* externs related to pinmux */ +extern void spear3xx_enable_pins(u32 ip, u32 mode); + #endif diff --git a/board/st/spear/spear300evb.c b/board/st/spear/spear300evb.c index 46a5922..2ea598a 100644 --- a/board/st/spear/spear300evb.c +++ b/board/st/spear/spear300evb.c @@ -30,11 +30,30 @@ #include <asm/arch/hardware.h> #include <asm/arch/generic.h> #include <asm/arch/misc.h> +#include <asm/arch/pinmux.h>
#if defined(CONFIG_CMD_NAND) static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; #endif
+#if defined(CONFIG_BOARD_EARLY_INIT_F) +int board_early_init_f(void) +{ + spear300_select_mode(SPEAR300_MODE_NAND); + + spear300_pins_default(); + spear3xx_enable_pins(PMX_I2C0, 0); + spear3xx_enable_pins(PMX_SSP0, 0); + spear3xx_enable_pins(PMX_ETH0, 0); + spear3xx_enable_pins(PMX_UART0, PMX_UART_SIMPLE); + + spear300_enable_pins(PMX_SDMMC, PMX_SDMMC_4BIT); + spear300_enable_pins(PMX_FSMCNAND, PMX_NAND_2CHIP); + + return 0; +} +#endif + #if defined(CONFIG_CMD_NAND) /* * board_nand_init - Board specific NAND initialization diff --git a/board/st/spear/spear310evb.c b/board/st/spear/spear310evb.c index 4ed8f01..7f70008 100644 --- a/board/st/spear/spear310evb.c +++ b/board/st/spear/spear310evb.c @@ -31,11 +31,27 @@ #include <asm/arch/hardware.h> #include <asm/arch/generic.h> #include <asm/arch/misc.h> +#include <asm/arch/pinmux.h>
#if defined(CONFIG_CMD_NAND) static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; #endif
+#if defined(CONFIG_BOARD_EARLY_INIT_F) +int board_early_init_f(void) +{ + spear310_pins_default(); + spear3xx_enable_pins(PMX_I2C0, 0); + spear3xx_enable_pins(PMX_SSP0, 0); + spear3xx_enable_pins(PMX_ETH0, 0); + spear3xx_enable_pins(PMX_UART0, PMX_UART_SIMPLE); + + spear310_enable_pins(PMX_ETH1, 0); + + return 0; +} +#endif + #if defined(CONFIG_CMD_NAND) /* * board_nand_init - Board specific NAND initialization diff --git a/board/st/spear/spear320plc.c b/board/st/spear/spear320plc.c index a463998..84185a5 100644 --- a/board/st/spear/spear320plc.c +++ b/board/st/spear/spear320plc.c @@ -31,9 +31,8 @@ #include <asm/arch/hardware.h> #include <asm/arch/generic.h> #include <asm/arch/misc.h> - -#define PLGPIO_SEL_36 0xb3000028 -#define PLGPIO_IO_36 0xb3000038 +#include <asm/arch/mmc.h> +#include <asm/arch/pinmux.h>
#if defined(CONFIG_CMD_NAND) static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; @@ -41,15 +40,44 @@ static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
static void spear_phy_reset(void) { - writel(0x10, PLGPIO_IO_36); - writel(0x10, PLGPIO_SEL_36); + /* GPIO36 is used to enable oscillator */ + spear320_configure_pin(36, PMX_GPIO); + spear320_plgpio_set(36, 1); + + /* GPIO76 is used to reset phy */ + spear320_configure_pin(76, PMX_GPIO); + spear320_plgpio_set(76, 0); + spear320_plgpio_set(76, 1); }
int board_init(void) { spear_phy_reset(); + + return 0; +} + +#if defined(CONFIG_BOARD_EARLY_INIT_F) +int board_early_init_f(void) +{ + spear320_select_mode(SPEAR320_EXTENDED_MODE); + + spear320_pins_default(); + + spear320_enable_pins(PMX_I2C0, 0); + spear320_enable_pins(PMX_ETH0, 0); + spear320_enable_pins(PMX_SSP0, 0); + spear320_enable_pins(PMX_UART0, PMX_UART_SIMPLE); + spear320_enable_pins(PMX_ETH2, PMX_ETH_MII); + spear320_enable_pins(PMX_SDMMC, PMX_SDMMC_CD51); + + /* GPIO61 is used for card power on */ + spear320_configure_pin(61, PMX_GPIO); + spear320_plgpio_set(61, 0); + return 0; } +#endif
#if defined(CONFIG_CMD_NAND) /* diff --git a/board/st/spear/spear600evb.c b/board/st/spear/spear600evb.c index 17828a3..add496b 100644 --- a/board/st/spear/spear600evb.c +++ b/board/st/spear/spear600evb.c @@ -35,6 +35,13 @@ static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; #endif
+#if defined(CONFIG_BOARD_EARLY_INIT_F) +int board_early_init_f(void) +{ + return 0; +} +#endif + #if defined(CONFIG_CMD_NAND) /* * board_nand_init - Board specific NAND initialization

--- board/st/spear/spear320plc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/board/st/spear/spear320plc.c b/board/st/spear/spear320plc.c index 84185a5..5a79eb6 100644 --- a/board/st/spear/spear320plc.c +++ b/board/st/spear/spear320plc.c @@ -116,8 +116,8 @@ int board_eth_init(bd_t *bis) ret++; #endif #if defined(CONFIG_MACB) - if (macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE, - CONFIG_MACB0_PHY) >= 0) + if (macb_eth_initialize(1, (void *)CONFIG_SYS_MACB1_BASE, + CONFIG_MACB1_PHY) >= 0) ret++; #endif return ret;

- Define CONFIG_SYS_EXCEPTION_VECTORS_HIGH Define CONFIG_SYS_EXCEPTION_VECTORS_HIGH and remove specific initialization of CPU as high vector - Define CONFIG_DISPLAY_BOARDINFO and print board info - Add GPIO support - Define CONFIG_BOOT_PARAMS_P for all spear boards It also makes a few board_init calls redundant so remove them from the code - Enable OTG support - Enable SPI and SDMMC support - Enable USBH EHCI support - Disable caches explicitly - Keep ATAG interface for kernel booting The older kernel needs an ATAG interface to boot. The bootloader needs to pass the information in the form of ATAGS. Keep this ATAG interface with the new DT interface for kernel booting - Remove extraneous configurations
Signed-off-by: Vipin Kumar vipin.kumar@st.com --- board/st/spear/spear_common.c | 16 +++++++++ board/st/spear/spear_lowlevel_init.S | 14 -------- include/configs/spear.h | 49 +++++++++++++++++++++++++-- include/configs/spear300-evb.h | 24 ++++++++++---- include/configs/spear310-evb.h | 24 ++++++++++---- include/configs/spear320-evb.h | 64 +++++++++++------------------------- include/configs/spear600-evb.h | 32 ++++++++++++++---- 7 files changed, 141 insertions(+), 82 deletions(-)
diff --git a/board/st/spear/spear_common.c b/board/st/spear/spear_common.c index f274b6e..2257779 100644 --- a/board/st/spear/spear_common.c +++ b/board/st/spear/spear_common.c @@ -39,6 +39,22 @@ void lowlevel_init(void) { }
+int checkboard(void) +{ +#ifdef CONFIG_MACH_SPEAR300EVB + printf("BOARD: SPEAr300-EVB\n"); +#elif defined(CONFIG_MACH_SPEAR310EVB) + printf("BOARD: SPEAr310-EVB\n"); +#elif defined(CONFIG_MACH_SPEAR320EVB) + printf("BOARD: SPEAr320-PLC\n"); +#elif defined(CONFIG_MACH_SPEAR600EVB) + printf("BOARD: SPEAr600-EVB\n"); +#else +#error BOARD not supported +#endif + return 0; +} + int dram_init(void) { /* Store complete RAM size and return */ diff --git a/board/st/spear/spear_lowlevel_init.S b/board/st/spear/spear_lowlevel_init.S index 6fbe579..77fa821 100644 --- a/board/st/spear/spear_lowlevel_init.S +++ b/board/st/spear/spear_lowlevel_init.S @@ -23,20 +23,6 @@
#include <config.h>
-/* - * platform specific initializations are already done in Xloader - * Initializations already done include - * DDR, PLLs, IP's clock enable and reset release etc - */ -.globl lowlevel_init -lowlevel_init: - /* By default, U-Boot switches CPU to low-vector */ - /* Revert this as we work in high vector even in U-Boot */ - mrc p15, 0, r0, c1, c0, 0 - orr r0, r0, #0x00002000 - mcr p15, 0, r0, c1, c0, 0 - mov pc, lr - /* void setfreq(unsigned int device, unsigned int frequency) */ .global setfreq setfreq: diff --git a/include/configs/spear.h b/include/configs/spear.h index a8ddf54..4cb551d 100644 --- a/include/configs/spear.h +++ b/include/configs/spear.h @@ -29,7 +29,7 @@ #define CONFIG_PLAT_SPEAR
#define CONFIG_SYS_TEXT_BASE 0x00700000 -#define CONFIG_BOOT_PARAMS_ADDR 0x00000100 +#define CONFIG_BOOT_PARAMS_P 0x00000100
/* Timer, HZ specific defines */ #define CONFIG_SYS_HZ 1000 @@ -38,7 +38,6 @@ #if defined(CONFIG_DESIGNWARE_ETH) || defined(CONFIG_MACB) #define CONFIG_MII #define CONFIG_NET_MULTI - #define CONFIG_PHY_GIGE
#define CONFIG_CMD_NET #define CONFIG_CMD_MII @@ -50,7 +49,7 @@ #endif
/* Generic configuration for USBD driver */ -#if defined(CONFIG_DW_UDC) +#if defined(CONFIG_DW_UDC) || defined(CONFIG_DW_OTG) #define CONFIG_USB_DEVICE #define CONFIG_USBD_HS #define CONFIG_USB_TTY @@ -87,6 +86,25 @@ #define CONFIG_CMD_I2C #endif
+/* Generic configuration for GPIO driver */ +#if defined(CONFIG_SPEAR_GPIO) + #define CONFIG_CMD_GPIO +#endif + +/* Generic configuration for USB EHCI driver */ +#if defined(CONFIG_USB_EHCI_SPEAR) + #define CONFIG_USB_EHCI + #define CONFIG_USB_STORAGE + #define CONFIG_CMD_USB +#endif + +/* Enable FAT and Partition types */ +#if defined(CONFIG_USB_STORAGE) + #define CONFIG_CMD_FAT + #define CONFIG_DOS_PARTITION + #define CONFIG_ISO_PARTITION +#endif + /* Generic configuration for ST SMI driver */ #if defined(CONFIG_ST_SMI) #define CONFIG_SYS_FLASH_ERASE_TOUT (3 * CONFIG_SYS_HZ) @@ -107,6 +125,23 @@ 57600, 115200 } #endif
+/* Generic configuration for AMBA PL022 driver */ +#if defined(CONFIG_PL022_SPI) + #define CONFIG_CMD_SPI + #if defined(CONFIG_SPI_FLASH) + #define CONFIG_CMD_SF + #define CONFIG_SPI_FLASH_STMICRO + #endif +#endif + +/* Generic configuration for Arasan SD/MMC driver */ +#if defined(CONFIG_SPEAR_SDHCI) + #define CONFIG_MMC + #define CONFIG_SDHCI + #define CONFIG_GENERIC_MMC + #define CONFIG_CMD_MMC +#endif + /* Generic configuration for FSMC NAND driver */ #if defined(CONFIG_NAND_FSMC) #define CONFIG_SYS_NAND_SELF_INIT @@ -153,12 +188,20 @@
/* Miscellaneous configurable options */ #define CONFIG_ARCH_CPU_INIT +#define CONFIG_BOARD_EARLY_INIT_F #define CONFIG_DISPLAY_CPUINFO #define CONFIG_POST CONFIG_SYS_POST_MEMORY #define CONFIG_SYS_POST_WORD_ADDR 0x0 +#define CONFIG_DISPLAY_BOARDINFO +#define CONFIG_SYS_EXCEPTION_VECTORS_HIGH + +#if !defined(CONFIG_SPL_BUILD) + #define CONFIG_SYS_DCACHE_OFF +#endif
#define CONFIG_OF_LIBFDT #define CONFIG_CMDLINE_TAG +#define CONFIG_SETUP_MEMORY_TAGS
#define CONFIG_ZERO_BOOTDELAY_CHECK #define CONFIG_AUTOBOOT_KEYED diff --git a/include/configs/spear300-evb.h b/include/configs/spear300-evb.h index cb6d764..e3f4ab4 100644 --- a/include/configs/spear300-evb.h +++ b/include/configs/spear300-evb.h @@ -54,6 +54,14 @@ #define CONFIG_SYS_I2C_SLAVE 0x02 #endif
+/* GPIO configurations */ +#define CONFIG_SPEAR_GPIO + +/* USB EHCI configurations */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_USB_EHCI_SPEAR +#endif + /* AMBA PL011 configurations */ #define CONFIG_PL011_SERIAL #define CONFIG_CONS_INDEX 0 @@ -74,17 +82,19 @@ /* Environment is in serial NOR flash */ #define CONFIG_ENV_ADDR 0xF8060000 #define CONFIG_ENV_SECT_SIZE 0x00010000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock3 " - #define CONFIG_BOOTCOMMAND "bootm 0xF8070000" + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock5 " + #define CONFIG_BOOTCOMMAND "" \ + "bootm 0xf8080000 - 0xf8070000"
#elif defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in NAND */ - #define CONFIG_ENV_OFFSET 0x00060000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock7 " + #define CONFIG_ENV_OFFSET 0x00070000 + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock11 "
- #define CONFIG_BOOTCOMMAND "nand read.jffs2 0x1600000 " \ - "0x80000 0x4C0000; " \ - "bootm 0x1600000" + #define CONFIG_BOOTCOMMAND "" \ + "nand read.jffs2 0x800000 0x78000 0x008000; " \ + "nand read.jffs2 0x900000 0x80000 0x4C0000; " \ + "bootm 0x900000 - 0x800000" #endif
#define CONFIG_BOOTARGS "console=ttyAMA0,115200 " \ diff --git a/include/configs/spear310-evb.h b/include/configs/spear310-evb.h index cb73ba7..505c8a4 100644 --- a/include/configs/spear310-evb.h +++ b/include/configs/spear310-evb.h @@ -67,6 +67,14 @@ #define CONFIG_SYS_I2C_SLAVE 0x02 #endif
+/* GPIO configurations */ +#define CONFIG_SPEAR_GPIO + +/* USB EHCI configurations */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_USB_EHCI_SPEAR +#endif + /* AMBA PL011 configurations */ #define CONFIG_PL011_SERIAL #define CONFIG_CONS_INDEX 0 @@ -105,17 +113,19 @@ /* Environment is in serial NOR flash */ #define CONFIG_ENV_ADDR 0xF8060000 #define CONFIG_ENV_SECT_SIZE 0x00010000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock3 " - #define CONFIG_BOOTCOMMAND "bootm 0xF8050000" + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock5 " + #define CONFIG_BOOTCOMMAND "" \ + "bootm 0xf8080000 - 0xf8070000" #endif #elif defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in NAND */ - #define CONFIG_ENV_OFFSET 0x00060000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock7 " + #define CONFIG_ENV_OFFSET 0x00140000 + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock11 "
- #define CONFIG_BOOTCOMMAND "nand read.jffs2 0x1600000 " \ - "0x200000 0x4C0000; " \ - "bootm 0x1600000" + #define CONFIG_BOOTCOMMAND "" \ + "nand read.jffs2 0x800000 0x180000 0x020000; " \ + "nand read.jffs2 0x900000 0x1c0000 0x4C0000; " \ + "bootm 0x900000 - 0x800000" #endif
#define CONFIG_BOOTARGS "console=ttyAMA0,115200 " \ diff --git a/include/configs/spear320-evb.h b/include/configs/spear320-evb.h index a054970..229fa83 100644 --- a/include/configs/spear320-evb.h +++ b/include/configs/spear320-evb.h @@ -28,15 +28,7 @@ #define CONFIG_SPEAR_USBTTY #endif
-#if defined(CONFIG_pnor) - #define CONFIG_FLASH_PNOR -#endif - -#if defined(CONFIG_nand) - #define CONFIG_ENV_IS_IN_NAND -#else - #define CONFIG_ENV_IS_IN_FLASH -#endif +#define CONFIG_ENV_IS_IN_FLASH
#define CONFIG_MACH_SPEAR320EVB #define CONFIG_MACH_TYPE MACH_TYPE_SPEAR320 @@ -69,51 +61,35 @@ #define CONFIG_PL011_SERIAL #define CONFIG_CONS_INDEX 0
+/* GPIO configurations */ +#define CONFIG_SPEAR_GPIO + +/* USB EHCI configurations */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_USB_EHCI_SPEAR +#endif + /* Designware UDC configurations */ #if defined(CONFIG_SPEAR_USBTTY) #define CONFIG_DW_UDC #endif
-/* FSMC NAND configurations */ -#define CONFIG_NAND_FSMC -#define CONFIG_SYS_FSMC_NAND_8BIT - /* Flash configurations */ -#if defined(CONFIG_FLASH_PNOR) - #define CONFIG_ST_EMI -#else - #define CONFIG_ST_SMI -#endif +#define CONFIG_ST_SMI
-/* CFI Driver configurations */ -#if defined(CONFIG_FLASH_PNOR) - #define CONFIG_FLASH_CFI_DRIVER - #define CONFIG_SYS_MAX_FLASH_SECT (127 + 8) -#endif +/* SPL support */ +#define CONFIG_SPL +#define CONFIG_SPEAR_DDR_2HCLK +#define CONFIG_DDR_MT47H64M16
/* Environment Variable configs */ #if defined(CONFIG_ENV_IS_IN_FLASH) - #if defined(CONFIG_FLASH_PNOR) - /* Environment is in parallel NOR flash */ - #define CONFIG_ENV_ADDR 0xF8040000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock3 " - #define CONFIG_BOOTCOMMAND "bootm 0xF8050000" - - #else - /* Environment is in serial NOR flash */ - #define CONFIG_ENV_ADDR 0xF8060000 - #define CONFIG_ENV_SECT_SIZE 0x00010000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock3 " - #define CONFIG_BOOTCOMMAND "bootm 0xF8070000" - #endif -#elif defined(CONFIG_ENV_IS_IN_NAND) - /* Environment is in NAND */ - #define CONFIG_ENV_OFFSET 0x00060000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock7 " - - #define CONFIG_BOOTCOMMAND "nand read.jffs2 0x1600000 " \ - "0x200000 0x4C0000; " \ - "bootm 0x1600000" + /* Environment is in serial NOR flash */ + #define CONFIG_ENV_ADDR 0xF8060000 + #define CONFIG_ENV_SECT_SIZE 0x00010000 + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock5 " + #define CONFIG_BOOTCOMMAND "" \ + "bootm 0xf8080000 - 0xf8070000" #endif
#define CONFIG_BOOTARGS "console=ttyAMA0,115200 " \ diff --git a/include/configs/spear600-evb.h b/include/configs/spear600-evb.h index 5fe326a..e7c5ee3 100644 --- a/include/configs/spear600-evb.h +++ b/include/configs/spear600-evb.h @@ -41,6 +41,7 @@ #if !defined(CONFIG_SPEAR_USBTTY) #define CONFIG_DESIGNWARE_ETH #define CONFIG_DW_SEARCH_PHY + #define CONFIG_PHY_GIGE #define CONFIG_DW0_PHY 1 #define CONFIG_PHY_RESET_DELAY 10000 /* in usec */ #define CONFIG_DW_AUTONEG @@ -54,6 +55,14 @@ #define CONFIG_SYS_I2C_SLAVE 0x02 #endif
+/* GPIO configurations */ +#define CONFIG_SPEAR_GPIO + +/* USB EHCI configurations */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_USB_EHCI_SPEAR +#endif + /* AMBA PL011 configurations */ #define CONFIG_PL011_SERIAL #define CONFIG_CONS_INDEX 0 @@ -70,21 +79,30 @@ /* ST SMI (Serial flash) configurations */ #define CONFIG_ST_SMI
+/* SPL support */ +#define CONFIG_SPL +#define CONFIG_SPEAR_DDR_2HCLK +#define CONFIG_DDR_MT47H32M16 +#define CONFIG_SPL_TEXT_BASE 0xD2800B00 +#define CONFIG_SYS_SNOR_BOOT_BASE 0xF8010000 + #if defined(CONFIG_ENV_IS_IN_FLASH) /* Environment is in serial NOR flash */ #define CONFIG_ENV_ADDR 0xF8060000 #define CONFIG_ENV_SECT_SIZE 0x00010000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock3 " - #define CONFIG_BOOTCOMMAND "bootm 0xF8060000" + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock5 " + #define CONFIG_BOOTCOMMAND "" \ + "bootm 0xf8080000 - 0xf8070000"
#elif defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in NAND */ - #define CONFIG_ENV_OFFSET 0x00060000 - #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock7 " + #define CONFIG_ENV_OFFSET 0x00140000 + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock11 "
- #define CONFIG_BOOTCOMMAND "nand read.jffs2 0x1600000 " \ - "0x80000 0x4C0000; " \ - "bootm 0x1600000" + #define CONFIG_BOOTCOMMAND "" \ + "nand read.jffs2 0x800000 0x180000 0x020000; " \ + "nand read.jffs2 0x900000 0x1c0000 0x4C0000; " \ + "bootm 0x900000 - 0x800000" #endif
#define CONFIG_BOOTARGS "console=ttyAMA0,115200 " \

Signed-off-by: Vipin Kumar vipin.kumar@st.com --- arch/arm/include/asm/arch-spear/mmc.h | 29 +++++++++++++++++++++++++++++ arch/arm/include/asm/arch-spear/spear320.h | 1 + board/st/spear/spear320plc.c | 12 ++++++++++++ include/configs/spear320-evb.h | 5 +++++ 4 files changed, 47 insertions(+) create mode 100644 arch/arm/include/asm/arch-spear/mmc.h
diff --git a/arch/arm/include/asm/arch-spear/mmc.h b/arch/arm/include/asm/arch-spear/mmc.h new file mode 100644 index 0000000..5c01a7e --- /dev/null +++ b/arch/arm/include/asm/arch-spear/mmc.h @@ -0,0 +1,29 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com. + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef _ASM_ARCH_MMC_H +#define _ASM_ARCH_MMC_H + +extern int spear_sdhci_init(u32 regbase, u32 max_clk, u32 min_clk, u32 quirks); + +#endif diff --git a/arch/arm/include/asm/arch-spear/spear320.h b/arch/arm/include/asm/arch-spear/spear320.h index abdcda6..a027e10 100644 --- a/arch/arm/include/asm/arch-spear/spear320.h +++ b/arch/arm/include/asm/arch-spear/spear320.h @@ -31,6 +31,7 @@ #define CONFIG_SYS_NAND_CLE (1 << 16) #define CONFIG_SYS_NAND_ALE (1 << 17)
+#define CONFIG_SYS_MMC_BASE 0x70000000 #define CONFIG_SYS_MACB0_BASE 0xAA000000 #define CONFIG_SYS_MACB1_BASE 0xAB000000 #define CONFIG_SPEAR_RASBASE 0xB3000000 diff --git a/board/st/spear/spear320plc.c b/board/st/spear/spear320plc.c index 5a79eb6..315fe2d 100644 --- a/board/st/spear/spear320plc.c +++ b/board/st/spear/spear320plc.c @@ -123,3 +123,15 @@ int board_eth_init(bd_t *bis) return ret; } #endif + +#if defined(CONFIG_CMD_MMC) +int board_mmc_init(bd_t *bis) +{ + int ret = 0; +#if defined(CONFIG_SPEAR_SDHCI) + if (spear_sdhci_init(CONFIG_SYS_MMC_BASE, 24000000, 6000000, 0) >= 0) + ret++; +#endif + return ret; +} +#endif diff --git a/include/configs/spear320-evb.h b/include/configs/spear320-evb.h index 229fa83..955266b 100644 --- a/include/configs/spear320-evb.h +++ b/include/configs/spear320-evb.h @@ -33,6 +33,11 @@ #define CONFIG_MACH_SPEAR320EVB #define CONFIG_MACH_TYPE MACH_TYPE_SPEAR320
+/* ARASAN SD MMC configuration */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_SPEAR_SDHCI +#endif + /* Designware Ethernet configurations */ #if !defined(CONFIG_SPEAR_USBTTY) #define CONFIG_DESIGNWARE_ETH

Signed-off-by: Vipin Kumar vipin.kumar@st.com --- MAINTAINERS | 1 + board/st/spear/Makefile | 1 + board/st/spear/spear320hmi.c | 120 +++++++++++++++++++++++++++++++++++++++++ board/st/spear/spear_common.c | 2 + boards.cfg | 2 + include/configs/spear320-hmi.h | 117 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 243 insertions(+) create mode 100644 board/st/spear/spear320hmi.c create mode 100644 include/configs/spear320-hmi.h
diff --git a/MAINTAINERS b/MAINTAINERS index 1b2da94..18e9b6c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -745,6 +745,7 @@ Vipin Kumar vipin.kumar@st.com spear300 ARM926EJS (spear300 Soc) spear310 ARM926EJS (spear310 Soc) spear320 ARM926EJS (spear320 Soc) + spear320-hmi ARM926EJS (spear320 SoC) spear600 ARM926EJS (spear600 Soc)
Sergey Lapin slapin@ossfans.org diff --git a/board/st/spear/Makefile b/board/st/spear/Makefile index f925c19..d2634d8 100644 --- a/board/st/spear/Makefile +++ b/board/st/spear/Makefile @@ -38,6 +38,7 @@ endif COBJS-$(CONFIG_MACH_SPEAR300EVB) += spear300evb.o COBJS-$(CONFIG_MACH_SPEAR310EVB) += spear310evb.o COBJS-$(CONFIG_MACH_SPEAR320EVB) += spear320plc.o +COBJS-$(CONFIG_MACH_SPEAR320HMI) += spear320hmi.o COBJS-$(CONFIG_MACH_SPEAR600EVB) += spear600evb.o
COBJS := $(sort $(COBJS-y)) diff --git a/board/st/spear/spear320hmi.c b/board/st/spear/spear320hmi.c new file mode 100644 index 0000000..562bdda --- /dev/null +++ b/board/st/spear/spear320hmi.c @@ -0,0 +1,120 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com. + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <miiphy.h> +#include <netdev.h> +#include <nand.h> +#include <asm/io.h> +#include <linux/mtd/fsmc_nand.h> +#include <asm/arch/hardware.h> +#include <asm/arch/generic.h> +#include <asm/arch/misc.h> +#include <asm/arch/mmc.h> +#include <asm/arch/pinmux.h> + +#if defined(CONFIG_CMD_NAND) +static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; +#endif + +#if defined(CONFIG_BOARD_EARLY_INIT_F) +int board_early_init_f(void) +{ + spear320_select_mode(SPEAR320_EXTENDED_MODE); + + spear320_pins_default(); + + spear320_enable_pins(PMX_I2C0, 0); + spear320_enable_pins(PMX_SSP0, 0); + spear320_enable_pins(PMX_UART0, PMX_UART_SIMPLE); + spear320_enable_pins(PMX_FSMCNAND, PMX_NAND_8BIT); + spear320_enable_pins(PMX_ETH1_ETH2, PMX_ETH_RMII); + spear320_enable_pins(PMX_SDMMC, PMX_SDMMC_CD12); + + /* GPIO50 is used for card power on */ + spear320_configure_pin(50, PMX_GPIO); + spear320_plgpio_set(50, 0); + + return 0; +} +#endif + +#if defined(CONFIG_CMD_NAND) +/* + * board_nand_init - Board specific NAND initialization + * @nand: mtd private chip structure + * + * Called by nand_init_chip to initialize the board specific functions + */ +void board_nand_init() +{ + struct misc_regs *const misc_regs_p = + (struct misc_regs *)CONFIG_SPEAR_MISCBASE; + struct nand_chip *nand = &nand_chip[0]; + + if (((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) == + MISC_SOCCFG30) || + ((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) == + MISC_SOCCFG31)) { + + fsmc_nand_init(nand); + } + + return; +} +#endif + +#if defined(CONFIG_CMD_NET) +int board_eth_init(bd_t *bis) +{ + int ret = 0; + +#if defined(CONFIG_DESIGNWARE_ETH) + u32 interface = PHY_INTERFACE_MODE_MII; + if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY, + interface) >= 0) + ret++; +#endif +#if defined(CONFIG_MACB) + if (macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE, + CONFIG_MACB0_PHY) >= 0) + ret++; + if (macb_eth_initialize(1, (void *)CONFIG_SYS_MACB1_BASE, + CONFIG_MACB1_PHY) >= 0) + ret++; +#endif + return ret; +} +#endif + +#if defined(CONFIG_CMD_MMC) +int board_mmc_init(bd_t *bis) +{ + int ret = 0; +#if defined(CONFIG_SPEAR_SDHCI) + if (spear_sdhci_init(CONFIG_SYS_MMC_BASE, 24000000, 6000000, 0) >= 0) + ret++; +#endif + return ret; +} +#endif diff --git a/board/st/spear/spear_common.c b/board/st/spear/spear_common.c index 2257779..9144dd8 100644 --- a/board/st/spear/spear_common.c +++ b/board/st/spear/spear_common.c @@ -47,6 +47,8 @@ int checkboard(void) printf("BOARD: SPEAr310-EVB\n"); #elif defined(CONFIG_MACH_SPEAR320EVB) printf("BOARD: SPEAr320-PLC\n"); +#elif defined(CONFIG_MACH_SPEAR320HMI) + printf("BOARD: SPEAr320-HMI\n"); #elif defined(CONFIG_MACH_SPEAR600EVB) printf("BOARD: SPEAr600-EVB\n"); #else diff --git a/boards.cfg b/boards.cfg index 3b0348a..0375e9e 100644 --- a/boards.cfg +++ b/boards.cfg @@ -210,6 +210,8 @@ spear320 arm arm926ejs spear st spear320_pnor arm arm926ejs spear st spear spear320-evb:spear320,pnor spear320_nand arm arm926ejs spear st spear spear320-evb:spear320,nand spear320_usbtty arm arm926ejs spear st spear spear320-evb:spear320,usbtty +spear320_hmi arm arm926ejs spear st spear spear320-hmi:spear320 +spear320_hmi_nand arm arm926ejs spear st spear spear320-hmi:spear320,nand spear600 arm arm926ejs spear st spear spear600-evb:spear600 spear600_nand arm arm926ejs spear st spear spear600-evb:spear600,nand spear600_usbtty arm arm926ejs spear st spear spear600-evb:spear600,usbtty diff --git a/include/configs/spear320-hmi.h b/include/configs/spear320-hmi.h new file mode 100644 index 0000000..4649ed4 --- /dev/null +++ b/include/configs/spear320-hmi.h @@ -0,0 +1,117 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, STMicroelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#if defined(CONFIG_usbtty) + #define CONFIG_SPEAR_USBTTY +#endif + +#if defined(CONFIG_nand) + #define CONFIG_ENV_IS_IN_NAND +#else + #define CONFIG_ENV_IS_IN_FLASH +#endif + +#define CONFIG_MACH_SPEAR320HMI +#define CONFIG_MACH_TYPE MACH_TYPE_SPEAR320 + +/* ARASAN SD MMC configuration */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_SPEAR_SDHCI +#endif + +/* MACB configurations */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_MACB + #define CONFIG_MACB0_PHY 0x01 + #define CONFIG_MACB1_PHY 0x00 +#endif + +/* Designware I2C configurations */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_DW_I2C + #define CONFIG_I2C_CHIPADDRESS 0x50 + #define CONFIG_SYS_I2C_SPEED 400000 + #define CONFIG_SYS_I2C_SLAVE 0x02 +#endif + +/* AMBA PL011 configurations */ +#define CONFIG_PL011_SERIAL +#define CONFIG_CONS_INDEX 0 + +/* GPIO configurations */ +#define CONFIG_SPEAR_GPIO + +/* USB EHCI configurations */ +#if !defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_USB_EHCI_SPEAR +#endif + +/* Designware UDC configurations */ +#if defined(CONFIG_SPEAR_USBTTY) + #define CONFIG_DW_UDC +#endif + +/* FSMC NAND configurations */ +#define CONFIG_NAND_FSMC +#define CONFIG_SYS_FSMC_NAND_8BIT + +/* Flash configurations */ +#define CONFIG_ST_SMI + +/* SPL support */ +#define CONFIG_SPL +#define CONFIG_SPEAR_DDR_2HCLK +#define CONFIG_DDR_MT47H64M16 + +/* Environment Variable configs */ +#if defined(CONFIG_ENV_IS_IN_FLASH) + /* Environment is in serial NOR flash */ + #define CONFIG_ENV_ADDR 0xF8060000 + #define CONFIG_ENV_SECT_SIZE 0x00010000 + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock5 " + #define CONFIG_BOOTCOMMAND \ + "bootm 0xf8080000 - 0xf8070000" +#elif defined(CONFIG_ENV_IS_IN_NAND) + /* Environment is in NAND */ + #define CONFIG_ENV_OFFSET 0x00140000 + #define CONFIG_SPEAR_ROOTFSBLK "/dev/mtdblock11 " + + #define CONFIG_BOOTCOMMAND "" \ + "nand read.jffs2 0x800000 0x180000 0x020000; " \ + "nand read.jffs2 0x900000 0x1c0000 0x4C0000; " \ + "bootm 0x900000 - 0x800000" +#endif + +#define CONFIG_BOOTARGS "console=ttyAMA0,115200 " \ + "root="CONFIG_SPEAR_ROOTFSBLK \ + "rootfstype=jffs2" + +#define CONFIG_BOARD_EXTRA_ENV "" \ + "loados=tftpboot 0x900000 $(rootpath)/spear3xx_uImage\0" \ + "loaddtb=tftpboot 0x800000 $(rootpath)/spear320-hmi.dtb\0" + +#include <configs/spear320.h> +#endif /* __CONFIG_H */

Add support for nand boot to SPL meant for spear3xx/spear6xx based boards
Signed-off-by: Vipin Kumar vipin.kumar@st.com --- arch/arm/cpu/arm926ejs/spear/Makefile | 2 +- arch/arm/cpu/arm926ejs/spear/spl_boot.c | 44 +++++- arch/arm/cpu/arm926ejs/spear/spl_nand.c | 121 ++++++++++++++++ arch/arm/include/asm/arch-spear/bootrom_table.h | 54 +++++++ arch/arm/include/asm/arch-spear/spl_nand.h | 181 ++++++++++++++++++++++++ include/configs/spear600-evb.h | 1 + 6 files changed, 400 insertions(+), 3 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/spear/spl_nand.c create mode 100644 arch/arm/include/asm/arch-spear/bootrom_table.h create mode 100644 arch/arm/include/asm/arch-spear/spl_nand.h
diff --git a/arch/arm/cpu/arm926ejs/spear/Makefile b/arch/arm/cpu/arm926ejs/spear/Makefile index 2e026ee..5ebdf65 100644 --- a/arch/arm/cpu/arm926ejs/spear/Makefile +++ b/arch/arm/cpu/arm926ejs/spear/Makefile @@ -38,7 +38,7 @@ COBJS-$(CONFIG_SOC_SPEAR320) += spear320.o COBJS-$(CONFIG_ARCH_SPEAR6XX) += spear6xx.o
ifdef CONFIG_SPL_BUILD -COBJS-y += spl.o spl_boot.o +COBJS-y += spl.o spl_boot.o spl_nand.o COBJS-$(CONFIG_SOC_SPEAR600) += spl-spear600.o endif
diff --git a/arch/arm/cpu/arm926ejs/spear/spl_boot.c b/arch/arm/cpu/arm926ejs/spear/spl_boot.c index 9742135..497aefc 100644 --- a/arch/arm/cpu/arm926ejs/spear/spl_boot.c +++ b/arch/arm/cpu/arm926ejs/spear/spl_boot.c @@ -30,6 +30,7 @@ #include <asm/io.h> #include <asm/arch/hardware.h> #include <asm/arch/generic.h> +#include <asm/arch/spl_nand.h>
uint32_t crc32(uint32_t, const unsigned char *, uint);
@@ -72,6 +73,35 @@ static int snor_image_load(u8 *load_addr, void (**image_p)(void)) return 0; }
+static int nand_image_load(u32 blkstart, void (**image_p)(void)) +{ + image_header_t header; + int ret = 0, blknum = blkstart; + size_t size; + ulong load_address; + + do { + size = sizeof(image_header_t); + ret = nand_read_skip_bad(blknum, 0, &size, (u_char *)&header); + + if ((ret >= 0) && image_check_header(&header)) { + size = image_get_data_size(&header); + load_address = image_get_load(&header); + + ret = nand_read_skip_bad(blknum, + sizeof(image_header_t), + &size, (void *)load_address); + if (image_check_data(&header)) { + /* Jump to boot image */ + *image_p = (void (*)(void))image_get_load(&header); + return 1; + } + } + } while (++blknum < blkstart + 4); + + return 0; +} + static void boot_image(void (*image)(void)) { void (*funcp)(void) __noreturn = (void *)image; @@ -124,8 +154,18 @@ u32 spl_boot(void)
if (NAND_BOOT_SUPPORTED && nand_boot_selected()) { /* NAND booting */ - /* Not ported from XLoader to SPL yet */ - return 0; + /* NAND-FSMC initialization */ + spl_nand_init(); + + /* NAND booting */ + if (nand_image_load(CONFIG_SYS_NAND_BOOT_BLK, &image)) { + /* Platform related late initialasations */ + board_lowlevel_late_init(); + + /* Jump to boot image */ + boot_image(image); + return 1; + } }
if (PNOR_BOOT_SUPPORTED && pnor_boot_selected()) { diff --git a/arch/arm/cpu/arm926ejs/spear/spl_nand.c b/arch/arm/cpu/arm926ejs/spear/spl_nand.c new file mode 100644 index 0000000..e5d5288 --- /dev/null +++ b/arch/arm/cpu/arm926ejs/spear/spl_nand.c @@ -0,0 +1,121 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com. + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <errno.h> +#include <asm/io.h> +#include <asm/arch/bootrom_table.h> +#include <asm/arch/generic.h> +#include <asm/arch/spl_nand.h> + +static struct flashtype flashtype; +static boot_flashdetectandinit_ptr_type boot_flashdetectandinit; +static boot_flashread_ptr_type boot_flashread; +static boot_nandsanitycheck_ptr_type boot_nandsanitycheck; +static struct boot_nand_page *tmp_page_p; + +void spl_nand_init(void) +{ + struct bootrom_table *romtb_p = + (struct bootrom_table *)BOOTROM_TABLE_ADDRESS; + + /* Global function pointers */ + switch (get_socrev()) { + case SOC_SPEAR300: + boot_flashdetectandinit = + (boot_flashdetectandinit_ptr_type)0xffff1774; + boot_flashread = (boot_flashread_ptr_type)0xffff1050; + boot_nandsanitycheck = + (boot_nandsanitycheck_ptr_type)0xffff193C; + tmp_page_p = (struct boot_nand_page *)0x50030CCC; + break; + case SOC_SPEAR600_BA: + case SOC_SPEAR600_BB: + /* NAND Boot does not work for Revisions SPEAr600 BA and BB */ + case SOC_SPEAR600_BC: + boot_flashdetectandinit = + (boot_flashdetectandinit_ptr_type)0xffff14ec; + boot_flashread = (boot_flashread_ptr_type)0xffff0dc4; + boot_nandsanitycheck = + (boot_nandsanitycheck_ptr_type)0xffff1628; + tmp_page_p = (struct boot_nand_page *)0xd2800844; + break; + case SOC_SPEAR310: + case SOC_SPEAR320: + case SOC_SPEAR600_BD: + boot_flashdetectandinit = + (romtb_p->table.table_1_0.boot_flashdetectandinit_ptr); + boot_flashread = (romtb_p->table.table_1_0.boot_flashread_ptr); + boot_nandsanitycheck = + (romtb_p->table.table_1_0.boot_nandsanitycheck_ptr); + tmp_page_p = (struct boot_nand_page *)0xd280084C; + break; + default: + break; + } + + if (boot_flashdetectandinit) + (*boot_flashdetectandinit) (&flashtype, 1, BOTH_8_16, + tmp_page_p); +} + +/** + * nand_read_skip_bad: Read image from NAND flash. Blocks that are marked bad + * are skipped and the next block is read instead as long as the image is short + * enough to fit even after skipping the bad blocks. + * + * @block: block number to start the read + * @offset: offset in the block number + * @length: buffer length, on return holds remaining bytes to read + * @buffer: buffer to write to + * @return 0 in case of success + */ +int nand_read_skip_bad(u32 block, size_t offset, size_t *length, + u_char *buffer) +{ + struct command_set *command = &(flashtype.comm_set); + u32 chip_off, readlen; + + if (!boot_nandsanitycheck || !boot_flashread) + return -EINVAL; + + while (*length) { + if (BOOT_OK == (*boot_nandsanitycheck) (&flashtype, block)) { + /* Block is OK */ + chip_off = command->block_size * block + offset; + readlen = min(command->block_size - offset, *length); + + if (BOOT_OK == (*boot_flashread) (&flashtype, chip_off, + buffer, readlen, tmp_page_p)) { + offset = 0; + *length -= readlen; + buffer += readlen; + } else + return -EINVAL; + } + /* Block is bad */ + block++; + } + + return 0; +} diff --git a/arch/arm/include/asm/arch-spear/bootrom_table.h b/arch/arm/include/asm/arch-spear/bootrom_table.h new file mode 100644 index 0000000..65bb369 --- /dev/null +++ b/arch/arm/include/asm/arch-spear/bootrom_table.h @@ -0,0 +1,54 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef ASM_ARCH_BOOTROM_TABLE_H +#define ASM_ARCH_BOOTROM_TABLE_H + +/* + * BootROM Table Structures + */ +#define BOOTROM_TABLE_ADDRESS 0xFFFF7F00 + +#define BOOTROM_TABLE_VERSION_1_0 1 + +struct bootrom_table_1_0 { + const void *boot_flashdetectandinit_ptr; + const void *boot_flashread_ptr; + const void *boot_nandsanitycheck_ptr; + const void *boot_nandreadpage_ptr; +}; + +/* + * Generic bootrom table structure's union. Contains the table structure for + * all versions + */ +union bootrom_ver_table { + struct bootrom_table_1_0 table_1_0; +}; + +struct bootrom_table { + const unsigned int table_version; + union bootrom_ver_table table; +}; + +#endif diff --git a/arch/arm/include/asm/arch-spear/spl_nand.h b/arch/arm/include/asm/arch-spear/spl_nand.h new file mode 100644 index 0000000..2773ea8 --- /dev/null +++ b/arch/arm/include/asm/arch-spear/spl_nand.h @@ -0,0 +1,181 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com. + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef ASM_ARCH_SPEAR_SPL_NAND_H +#define ASM_ARCH_SPEAR_SPL_NAND_H + +extern void spl_nand_init(void); +extern int nand_read_skip_bad(u32 blk, size_t off, size_t *len, u_char *buff); + +/* + * The following definitions come from BootROM library. + * Please do not change the routine names as the refrences are picked from + * BootROM library all the versions of which are also committed along with + * SPL sources + */ + +#define BOOT_OK 0 + +enum { + BOTH_8_16 = 0, + EIGHT_BITS_ONLY = 1, + SIXTEEN_BITS_ONLY = 2 +}; + +typedef enum { + NAND = 0, + NOR = 1, + ONE_NAND = 2 +} t_flash_device; + +typedef enum { + /* SMALL PAGES */ + /* 64M */ + NAND_64MS_1V_8 = 0x39, + /* 128M */ + NAND_128MS_1V_8 = 0x33, + NAND_128MS_1V_16 = 0x43, + NAND_128MS_3V_8 = 0x73, + NAND_128MS_3V_16 = 0x53, + /* 256M */ + NAND_256MS_1V_8 = 0x35, + NAND_256MS_1V_16 = 0x45, + NAND_256MS_3V_8 = 0x75, + NAND_256MS_3V_16 = 0x55, + /* 512M */ + NAND_512MS_1V_8 = 0x36, + NAND_512MS_1V_16 = 0x46, + NAND_512MS_3V_8 = 0x76, + NAND_512MS_3V_16 = 0x56, + /* 1G */ + NAND_1GS_1V_8 = 0x40, + NAND_1GS_1V_16 = 0x49, + NAND_1GS_3V_8 = 0x79, + NAND_1GS_3V_16 = 0x59, + NAND_1GS_3V_DDP_16 = 0x74, + NAND_1GS_1V_DDP_8 = 0x78, + NAND_1GS_1V_DDP_16 = 0x72, + + /* LARGE PAGES */ + /* 512M */ + NAND_512ML_1V_8 = 0xA2, + NAND_512ML_1V_16 = 0xB2, + NAND_512ML_3V_8 = 0xF2, + NAND_512ML_3V_16 = 0xC2, + /* 1G */ + NAND_1GL_1V_8 = 0xA1, + NAND_1GL_1V_16 = 0xB1, + NAND_1GL_3V_8 = 0xF1, + NAND_1GL_3V_16 = 0xC1, + /* 2G */ + NAND_2GL_1V_8 = 0xAA, + NAND_2GL_3V_8 = 0xDA, + NAND_2GL_1V_16 = 0xBA, + NAND_2GL_3V_16 = 0xCA, + /* 4G */ + NAND_4GL_1V_8 = 0xAC, + NAND_4GL_3V_8 = 0xDC, + NAND_4GL_1V_16 = 0xBC, + NAND_4GL_3V_16 = 0xCC, + /* 8G */ + NAND_8GL_1V_8 = 0xA3, + NAND_8GL_3V_8 = 0xD3, + NAND_8GL_1V_16 = 0xB3, + NAND_8GL_3V_16 = 0xC3, + /* 8G */ + NAND_16GL_1V_8 = 0xA5, + NAND_16GL_3V_8 = 0xD5, + NAND_16GL_1V_16 = 0xB5, + NAND_16GL_3V_16 = 0xC5, + /* NOR */ + NOR_8 = -1, + NOR_16 = -2, + /* NAND */ + ONE_NAND_16 = -4, + NO_VALID_ID = 0, + UNKNOWN_ID = -3 +} t_flash_command_id; + +typedef enum { + NOR_BANK_0 = 0, + NAND_BANK_0 = 1, + NAND_BANK_1 = 2, + NAND_BANK_2 = 3, + LAST_BANK +} t_flash_FSMC_bank; + +struct command_set { + u32 pagexblock; + u32 page_size; + u32 block_size; + u32 spare_size; + u32 memory_size; + u32 ecc_size; + u32 data_width; + u32 pmem_command; + u32 pmem_address[2]; + u32 patt_command; + u32 pmem_read; + u32 mem_command; + u32 att_command; + u32 mem_command_write; + u32 att_command_write; + u32 spare_command; + u8 /* t_flash_FSMC_bank */ memory_bank; + u8 padding[3]; +}; + +/* + * There is a hack while defining this structure. The bootROM interface uses the + * enum types for a few elements of the structure which it optimizes using the + * compiler flag '-fshort-enums'. Since the bootrom is fixed it can be hacked + * here and not let the flag apply to all other parts of code */ +struct flashtype { + u8 /* t_flash_device */ device; + u8 padding; + s16 /* t_flash_command_id */ read_id; + struct command_set comm_set; +}; + +typedef enum { + PAGE_OK, + PAGE_KO +} t_valid_flag; + +struct boot_nand_page { + u32 page_start_address; + u8 page[512]; + t_valid_flag page_valid; + u8 padding[3]; +}; + +typedef u32 (*boot_flashdetectandinit_ptr_type) (struct flashtype *, + u32, u32, struct boot_nand_page *); +typedef u32 (*boot_flashread_ptr_type) (struct flashtype *, u32, + u8 *, u32, struct boot_nand_page *); +typedef u32 (*boot_nandsanitycheck_ptr_type) (struct flashtype *, + u32); +typedef u32 (*boot_nandreadpage_ptr_type) (u32, struct flashtype *, + struct boot_nand_page *); + +#endif diff --git a/include/configs/spear600-evb.h b/include/configs/spear600-evb.h index e7c5ee3..35761eb 100644 --- a/include/configs/spear600-evb.h +++ b/include/configs/spear600-evb.h @@ -85,6 +85,7 @@ #define CONFIG_DDR_MT47H32M16 #define CONFIG_SPL_TEXT_BASE 0xD2800B00 #define CONFIG_SYS_SNOR_BOOT_BASE 0xF8010000 +#define CONFIG_SYS_NAND_BOOT_BLK 4
#if defined(CONFIG_ENV_IS_IN_FLASH) /* Environment is in serial NOR flash */

Parallel NOR boot is supported by all spear3xx devices. This patch adds the support to the generic spear spl framework.
Signed-off-by: Vipin Kumar vipin.kumar@st.com --- arch/arm/cpu/arm926ejs/spear/spl_boot.c | 79 +++++++++++++++++++++++++++++- arch/arm/include/asm/arch-spear/generic.h | 6 --- arch/arm/include/asm/arch-spear/spl_pnor.h | 34 +++++++++++++ include/configs/spear600-evb.h | 1 + 4 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 arch/arm/include/asm/arch-spear/spl_pnor.h
diff --git a/arch/arm/cpu/arm926ejs/spear/spl_boot.c b/arch/arm/cpu/arm926ejs/spear/spl_boot.c index 497aefc..7364ee0 100644 --- a/arch/arm/cpu/arm926ejs/spear/spl_boot.c +++ b/arch/arm/cpu/arm926ejs/spear/spl_boot.c @@ -31,6 +31,7 @@ #include <asm/arch/hardware.h> #include <asm/arch/generic.h> #include <asm/arch/spl_nand.h> +#include <asm/arch/spl_pnor.h>
uint32_t crc32(uint32_t, const unsigned char *, uint);
@@ -102,6 +103,59 @@ static int nand_image_load(u32 blkstart, void (**image_p)(void)) return 0; }
+static void pnorcopy(void *dest, const void *src, size_t len, + pnor_width_t width) +{ + const u32 *src_32 = src; + const u16 *src_16 = src; + const u8 *src_8 = src; + u32 *dest_32 = dest; + u16 *dest_16 = dest; + u8 *dest_8 = dest; + int i; + + switch (width) { + case PNOR_WIDTH_32: + for (i = 0; i < len >> 2; i++) + *dest_32++ = *src_32++; + break; + case PNOR_WIDTH_16: + for (i = 0; i < len >> 1; i++) + *dest_16++ = *src_16++; + break; + case PNOR_WIDTH_8: + default: + for (i = 0; i < len; i++) + *dest_8++ = *src_8++; + break; + } +} + +static int pnor_image_load(const void *load_addr, void (**image_p)(void), + pnor_width_t width) +{ + image_header_t header; + u32 numbytes; + + pnorcopy((void *)&header, load_addr, sizeof(header), width); + + if (image_check_header(&header)) { + numbytes = image_get_data_size(&header); + + /* Copy the image to load address */ + pnorcopy((void *)image_get_load(&header), + load_addr + sizeof(header), numbytes, width); + + if (image_check_data(&header)) { + /* Jump to boot image */ + *image_p = (void (*)(void))image_get_load(&header); + return 1; + } + } + + return 0; +} + static void boot_image(void (*image)(void)) { void (*funcp)(void) __noreturn = (void *)image; @@ -109,6 +163,13 @@ static void boot_image(void (*image)(void)) (*funcp)(); }
+static pnor_width_t __def_get_pnor_width(void) +{ + return PNOR_WIDTH_SEARCH; +} +pnor_width_t get_pnor_width(void) + __attribute__((weak, alias("__def_get_pnor_width"))); + static void __def_board_lowlevel_late_init(void) { } @@ -170,7 +231,23 @@ u32 spl_boot(void)
if (PNOR_BOOT_SUPPORTED && pnor_boot_selected()) { /* PNOR booting */ - /* Not ported from XLoader to SPL yet */ + /* PNOR initialization */ + pnor_width_t width = get_pnor_width(); + + if (width == PNOR_WIDTH_SEARCH) + width = PNOR_WIDTH_8; + + /* NAND booting */ + if (pnor_image_load((const void *)CONFIG_SYS_PNOR_BOOT_BASE, + &image, width)) { + /* Platform related late initialasations */ + board_lowlevel_late_init(); + + /* Jump to boot image */ + boot_image(image); + return 1; + } + return 0; }
diff --git a/arch/arm/include/asm/arch-spear/generic.h b/arch/arm/include/asm/arch-spear/generic.h index b7026e2..aa13b83 100644 --- a/arch/arm/include/asm/arch-spear/generic.h +++ b/arch/arm/include/asm/arch-spear/generic.h @@ -118,10 +118,4 @@ extern int get_socrev(void); #define MAC_OFF 0x2 #define MAC_LEN 0x6
-#define PNOR_WIDTH_8 0 -#define PNOR_WIDTH_16 1 -#define PNOR_WIDTH_32 2 -#define PNOR_WIDTH_NUM 3 -#define PNOR_WIDTH_SEARCH 0xff - #endif diff --git a/arch/arm/include/asm/arch-spear/spl_pnor.h b/arch/arm/include/asm/arch-spear/spl_pnor.h new file mode 100644 index 0000000..f69efc2 --- /dev/null +++ b/arch/arm/include/asm/arch-spear/spl_pnor.h @@ -0,0 +1,34 @@ +/* + * (C) Copyright 2012 + * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com. + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef ASM_ARCH_SPEAR_SPL_PNOR_H +#define ASM_ARCH_SPEAR_SPL_PNOR_H + +typedef enum { + PNOR_WIDTH_8, + PNOR_WIDTH_16, + PNOR_WIDTH_32, + PNOR_WIDTH_SEARCH +} pnor_width_t; + +#endif diff --git a/include/configs/spear600-evb.h b/include/configs/spear600-evb.h index 35761eb..51a349e 100644 --- a/include/configs/spear600-evb.h +++ b/include/configs/spear600-evb.h @@ -85,6 +85,7 @@ #define CONFIG_DDR_MT47H32M16 #define CONFIG_SPL_TEXT_BASE 0xD2800B00 #define CONFIG_SYS_SNOR_BOOT_BASE 0xF8010000 +#define CONFIG_SYS_PNOR_BOOT_BASE 0x00000000 #define CONFIG_SYS_NAND_BOOT_BLK 4
#if defined(CONFIG_ENV_IS_IN_FLASH)

This patch also adds related code for spear3xx which is later used for spear310 and spear320 based boards
Signed-off-by: Vipin Kumar vipin.kumar@st.com
spear310evb: Add SPL support
Signed-off-by: Vipin Kumar vipin.kumar@st.com
spear320evb/spear320hmi: Add SPL support
Signed-off-by: Vipin Kumar vipin.kumar@st.com --- arch/arm/cpu/arm926ejs/spear/Makefile | 1 + arch/arm/cpu/arm926ejs/spear/spl-spear3xx.c | 136 ++++++++++++++++++ arch/arm/include/asm/arch-spear/generic.h | 2 + arch/arm/include/asm/arch-spear/spear300.h | 23 ++++ arch/arm/include/asm/arch-spear/spear310.h | 22 +++ arch/arm/include/asm/arch-spear/spear320.h | 25 ++++ arch/arm/include/asm/arch-spear/spear3xx.h | 2 + board/st/spear/config.mk | 3 - board/st/spear/ddr/Makefile | 5 + board/st/spear/ddr/spr3xx_mt46h32m16_6_166_cl3.c | 140 +++++++++++++++++++ .../spear/ddr/spr3xx_mt47h64m16_3_166_cl4_async.c | 146 ++++++++++++++++++++ .../spear/ddr/spr3xx_mt47h64m16_3_266_cl5_async.c | 146 ++++++++++++++++++++ .../spear/ddr/spr3xx_mt47h64m16_3_333_cl5_async.c | 152 +++++++++++++++++++++ board/st/spear/spear300evb.c | 7 + board/st/spear/spear310evb.c | 31 +++++ board/st/spear/spear320hmi.c | 7 + board/st/spear/spear320plc.c | 7 + include/configs/spear.h | 4 + include/configs/spear300-evb.h | 5 + include/configs/spear310-evb.h | 5 + include/configs/spear3xx.h | 15 ++ 21 files changed, 881 insertions(+), 3 deletions(-) create mode 100644 board/st/spear/ddr/spr3xx_mt46h32m16_6_166_cl3.c create mode 100644 board/st/spear/ddr/spr3xx_mt47h64m16_3_166_cl4_async.c create mode 100644 board/st/spear/ddr/spr3xx_mt47h64m16_3_266_cl5_async.c create mode 100644 board/st/spear/ddr/spr3xx_mt47h64m16_3_333_cl5_async.c
diff --git a/arch/arm/cpu/arm926ejs/spear/Makefile b/arch/arm/cpu/arm926ejs/spear/Makefile index 5ebdf65..fc2e136 100644 --- a/arch/arm/cpu/arm926ejs/spear/Makefile +++ b/arch/arm/cpu/arm926ejs/spear/Makefile @@ -39,6 +39,7 @@ COBJS-$(CONFIG_ARCH_SPEAR6XX) += spear6xx.o
ifdef CONFIG_SPL_BUILD COBJS-y += spl.o spl_boot.o spl_nand.o +COBJS-$(CONFIG_ARCH_SPEAR3XX) += spl-spear3xx.o COBJS-$(CONFIG_SOC_SPEAR600) += spl-spear600.o endif
diff --git a/arch/arm/cpu/arm926ejs/spear/spl-spear3xx.c b/arch/arm/cpu/arm926ejs/spear/spl-spear3xx.c index 7e2bc98..972768d 100644 --- a/arch/arm/cpu/arm926ejs/spear/spl-spear3xx.c +++ b/arch/arm/cpu/arm926ejs/spear/spl-spear3xx.c @@ -22,6 +22,10 @@ */
#include <common.h> +#include <asm/io.h> +#include <asm/arch/hardware.h> +#include <asm/arch/generic.h> +#include <asm/arch/misc.h>
int get_socrev(void) { @@ -33,3 +37,135 @@ int get_socrev(void) return SOC_SPEAR320; #endif } + +void spear3xx_ddr_comp_init(void) +{ + struct misc_regs *misc_p = (struct misc_regs *)CONFIG_SPEAR_MISCBASE; + u32 ddrpad; + u32 core3v3, ddr1v8; + + /* DDR pad register configurations */ + ddrpad = readl(&misc_p->ddr_pad); + ddrpad &= ~MISC_DDR_PAD_CNF_MSK; + ddrpad |= 0x3AA4; + writel(ddrpad, &misc_p->ddr_pad); + + /* Compensation register configurations */ + core3v3 = readl(&misc_p->core_3v3_compensation); + core3v3 &= 0x02fffff0; + core3v3 |= 0x78000008; + writel(core3v3, &misc_p->core_3v3_compensation); + + ddr1v8 = readl(&misc_p->ddr_1v8_compensation); + ddr1v8 &= 0x02fffff0; + ddr1v8 |= 0x78000008; + writel(ddr1v8, &misc_p->ddr_1v8_compensation); +} + +/* getboottype() implementation for spear300 */ +#if defined(CONFIG_SOC_SPEAR300) +u32 getboottype(void) +{ + u32 bootmask = 0; + u32 bootstrap = (readl(CONFIG_SYS_TELECOM_BASE) >> SPEAR300_BOOTSHFT) & + SPEAR300_BOOTMASK; + + switch (bootstrap) { + case SPEAR300_USBBOOT: + bootmask |= BOOT_TYPE_USBD; + break; + case SPEAR300_TFTPI2CBOOT: + case SPEAR300_TFTPSPIBOOT: + bootmask |= BOOT_TYPE_TFTP; + break; + case SPEAR300_SNORBOOT: + bootmask |= BOOT_TYPE_SMI; + break; + case SPEAR300_PNOR8BOOT: + bootmask |= BOOT_TYPE_PNOR8; + break; + case SPEAR300_PNOR16BOOT: + bootmask |= BOOT_TYPE_PNOR16; + break; + case SPEAR300_NAND8BOOT: + case SPEAR300_NAND16BOOT: + bootmask |= BOOT_TYPE_NAND; + break; + case SPEAR300_UARTBOOT: + bootmask |= BOOT_TYPE_UART; + break; + default: + bootmask |= BOOT_TYPE_UNSUPPORTED; + break; + } + + return bootmask; +} +#elif defined(CONFIG_SOC_SPEAR310) +u32 getboottype(void) +{ + u32 bootmask = 0; + u32 bootstrap = (readl(SPEAR310_BOOT_REG) >> SPEAR310_BOOTSHFT) & + SPEAR310_BOOTMASK; + + switch (bootstrap) { + case SPEAR310_USBBOOT: + bootmask |= BOOT_TYPE_USBD; + break; + case SPEAR310_SNORBOOT: + bootmask |= BOOT_TYPE_SMI; + break; + case SPEAR310_PNORBOOT: + bootmask |= BOOT_TYPE_PNOR8 | BOOT_TYPE_PNOR16; + break; + case SPEAR310_NANDBOOT: + bootmask |= BOOT_TYPE_NAND; + break; + default: + bootmask |= BOOT_TYPE_UNSUPPORTED; + break; + } + + return bootmask; +} +#elif defined(CONFIG_SOC_SPEAR320) +u32 getboottype(void) +{ + u32 bootmask = 0; + u32 bootstrap = (readl(SPEAR320_BOOT_REG) >> SPEAR320_BOOTSHFT) & + SPEAR320_BOOTMASK; + + switch (bootstrap) { + case SPEAR320_USBBOOT: + bootmask |= BOOT_TYPE_USBD; + break; + case SPEAR320_TFTPI2CBOOT: + case SPEAR320_TFTPSPIBOOT: + bootmask |= BOOT_TYPE_TFTP; + break; + case SPEAR320_SNORBOOT: + bootmask |= BOOT_TYPE_SMI; + break; + case SPEAR320_PNOR8BOOT: + case SPEAR320_PNOR8NOACKBOOT: + bootmask |= BOOT_TYPE_PNOR8; + break; + case SPEAR320_PNOR16BOOT: + case SPEAR320_PNOR16NOACKBOOT: + bootmask |= BOOT_TYPE_PNOR16; + break; + case SPEAR320_NAND8BOOT: + case SPEAR320_NAND16BOOT: + bootmask |= BOOT_TYPE_NAND; + break; + case SPEAR320_UARTBOOT: + bootmask |= BOOT_TYPE_UART; + break; + default: + bootmask |= BOOT_TYPE_UNSUPPORTED; + break; + } + + return bootmask; +} +#endif diff --git a/arch/arm/include/asm/arch-spear/generic.h b/arch/arm/include/asm/arch-spear/generic.h index aa13b83..ffb8d4e 100644 --- a/arch/arm/include/asm/arch-spear/generic.h +++ b/arch/arm/include/asm/arch-spear/generic.h @@ -30,8 +30,10 @@ extern unsigned int setfreq_sz; extern void board_ddr_init(void); extern void board_lowlevel_late_init(void);
+/* Routines exported from SoC area */ extern void spear3xx_usbh_stop(void); extern void spear6xx_usbh_stop(void); +extern void spear3xx_ddr_comp_init(void);
extern u32 mpmc_conf_vals[];
diff --git a/arch/arm/include/asm/arch-spear/spear300.h b/arch/arm/include/asm/arch-spear/spear300.h index 4bfa619..66ed612 100644 --- a/arch/arm/include/asm/arch-spear/spear300.h +++ b/arch/arm/include/asm/arch-spear/spear300.h @@ -26,6 +26,19 @@
#include <asm/arch/spear3xx.h>
+#define CONFIG_SYS_TELECOM_BASE 0x50000000 + #define SPEAR300_BOOTSHFT 16 + #define SPEAR300_BOOTMASK 0xF + #define SPEAR300_USBBOOT 0x0 + #define SPEAR300_TFTPI2CBOOT 0x1 + #define SPEAR300_TFTPSPIBOOT 0x2 + #define SPEAR300_SNORBOOT 0x3 + #define SPEAR300_PNOR8BOOT 0x4 + #define SPEAR300_PNOR16BOOT 0x5 + #define SPEAR300_NAND8BOOT 0x6 + #define SPEAR300_NAND16BOOT 0x7 + #define SPEAR300_UARTBOOT 0xA + #define CONFIG_SYS_FSMC_BASE 0x94000000 #define CONFIG_SYS_NAND_CLE (1 << 16) #define CONFIG_SYS_NAND_ALE (1 << 17) @@ -50,6 +63,16 @@ #define SPEAR300_MODE_CAMULCDW (0xE << 0) #define SPEAR300_MODE_CAM1LCD (0xF << 0)
+#define SNOR_BOOT_SUPPORTED 1 +#define NAND_BOOT_SUPPORTED 1 +#define PNOR_BOOT_SUPPORTED 1 +#define USBD_BOOT_SUPPORTED 1 +#define TFTP_BOOT_SUPPORTED 1 +#define UART_BOOT_SUPPORTED 1 +#define MMC_BOOT_SUPPORTED 0 +#define SPI_BOOT_SUPPORTED 0 +#define I2C_BOOT_SUPPORTED 0 + #define SPEAR3XX_FUNC_ENB_REG SPEAR300_RAS_REG1
/* externs related to pinmux */ diff --git a/arch/arm/include/asm/arch-spear/spear310.h b/arch/arm/include/asm/arch-spear/spear310.h index 9d20237..91d0b53 100644 --- a/arch/arm/include/asm/arch-spear/spear310.h +++ b/arch/arm/include/asm/arch-spear/spear310.h @@ -38,12 +38,34 @@ #define CONFIG_SPEAR_RASBASE 0xB4000000
/* SPEAr310 RAS misc space registers and bitmasks */ +#define SPEAR310_BOOT_REG (CONFIG_SPEAR_RASBASE + 0x0) + #define SPEAR310_BOOTSHFT 0x0 + #define SPEAR310_BOOTMASK 0x7 + #define SPEAR310_USBBOOT 0x3 + #define SPEAR310_NANDBOOT 0x2 + #define SPEAR310_PNORBOOT 0x1 + #define SPEAR310_SNORBOOT 0x0 + #define SPEAR310_EMIBW_SHFT 0x3 + #define SPEAR310_EMIBW_MASK 0x18 + #define SPEAR310_EMIBW_8 0x0 + #define SPEAR310_EMIBW_16 0x1 + #define SPEAR310_EMIBW_32 0x2 #define SPEAR310_FUNCENB_REG (CONFIG_SPEAR_RASBASE + 0x8)
#define SPEAR310_SMII_REG (CONFIG_SPEAR_RASBASE + 0xC) #define SPEAR310_SMII_PHY_SHIFT 0x0 #define SPEAR310_SMII_PHY_MASK 0x3
+#define SNOR_BOOT_SUPPORTED 1 +#define NAND_BOOT_SUPPORTED 1 +#define PNOR_BOOT_SUPPORTED 1 +#define USBD_BOOT_SUPPORTED 1 +#define TFTP_BOOT_SUPPORTED 0 +#define UART_BOOT_SUPPORTED 0 +#define MMC_BOOT_SUPPORTED 0 +#define SPI_BOOT_SUPPORTED 0 +#define I2C_BOOT_SUPPORTED 0 + #define SPEAR3XX_FUNC_ENB_REG SPEAR310_FUNCENB_REG
/* externs related to pinmux */ diff --git a/arch/arm/include/asm/arch-spear/spear320.h b/arch/arm/include/asm/arch-spear/spear320.h index a027e10..5fe8fb0 100644 --- a/arch/arm/include/asm/arch-spear/spear320.h +++ b/arch/arm/include/asm/arch-spear/spear320.h @@ -44,6 +44,21 @@ #define SPEAR320_EXTENDED_MODE (1 << 4)
/* SPEAr320 RAS misc space registers and bitmasks */ +#define SPEAR320_BOOT_REG (CONFIG_SPEAR_RASBASE + 0x0) + #define SPEAR320_BOOTSHFT 0x0 + #define SPEAR320_BOOTMASK 0xF + #define SPEAR320_USBBOOT 0x0 + #define SPEAR320_TFTPI2CBOOT 0x1 + #define SPEAR320_TFTPSPIBOOT 0x2 + #define SPEAR320_SNORBOOT 0x3 + #define SPEAR320_PNOR8BOOT 0x4 + #define SPEAR320_PNOR16BOOT 0x5 + #define SPEAR320_NAND8BOOT 0x6 + #define SPEAR320_NAND16BOOT 0x7 + #define SPEAR320_UARTBOOT 0xA + #define SPEAR320_PNOR8NOACKBOOT 0xC + #define SPEAR320_PNOR16NOACKBOOT 0xD + #define SPEAR320_RASSELECT_REG (CONFIG_SPEAR_RASBASE + 0x000C)
#define SPEAR320_CONTROL_REG (CONFIG_SPEAR_RASBASE + 0x0010) @@ -452,6 +467,16 @@ #define PMX_SDHCI_CD_PORT_12_VAL 0 #define PMX_SDHCI_CD_PORT_51_VAL (0x1 << 29)
+#define SNOR_BOOT_SUPPORTED 1 +#define NAND_BOOT_SUPPORTED 1 +#define PNOR_BOOT_SUPPORTED 1 +#define USBD_BOOT_SUPPORTED 1 +#define TFTP_BOOT_SUPPORTED 1 +#define UART_BOOT_SUPPORTED 1 +#define MMC_BOOT_SUPPORTED 0 +#define SPI_BOOT_SUPPORTED 0 +#define I2C_BOOT_SUPPORTED 0 + #define SPEAR3XX_FUNC_ENB_REG SPEAR320_RASSELECT_REG
/* externs related to pinmux */ diff --git a/arch/arm/include/asm/arch-spear/spear3xx.h b/arch/arm/include/asm/arch-spear/spear3xx.h index f0df4e6..f63c21e 100644 --- a/arch/arm/include/asm/arch-spear/spear3xx.h +++ b/arch/arm/include/asm/arch-spear/spear3xx.h @@ -33,6 +33,8 @@ #define CONFIG_SYS_UHC0_EHCI_BASE 0xE1800000 #define CONFIG_SYS_SMI_BASE 0xFC000000 #define CONFIG_SPEAR_MPMCBASE 0xFC600000 +#define CONFIG_SPEAR_MPMCREGS 109 + #define CONFIG_SPEAR_TIMERBASE 0xFC800000 #define CONFIG_SPEAR_SYSCNTLBASE 0xFCA00000 #define CONFIG_SPEAR_MISCBASE 0xFCA80000 diff --git a/board/st/spear/config.mk b/board/st/spear/config.mk index 971d60a..49cc280 100644 --- a/board/st/spear/config.mk +++ b/board/st/spear/config.mk @@ -23,8 +23,5 @@
ifndef CONFIG_SPL_BUILD ALL-y += $(obj)u-boot.img - -ifdef CONFIG_MACH_SPEAR600EVB ALL-y += $(obj)spl/u-boot-spl.img endif -endif diff --git a/board/st/spear/ddr/Makefile b/board/st/spear/ddr/Makefile index 9f1c627..b1f975f 100644 --- a/board/st/spear/ddr/Makefile +++ b/board/st/spear/ddr/Makefile @@ -36,6 +36,11 @@ COBJS-$(CONFIG_DDR_MT47H64M16) += spear600_mt47h64m16_3_333_cl5_psync.o COBJS-$(CONFIG_DDR_MT47H32M16) += spear600_mt47h32m16_333_cl5_psync.o COBJS-$(CONFIG_DDR_MT47H32M16) += spear600_mt47h32m16_37e_166_cl4_sync.o COBJS-$(CONFIG_DDR_MT47H128M8) += spear600_mt47h128m8_3_266_cl5_async.o + +COBJS-$(CONFIG_DDR_MT46H32M16) += spr3xx_mt46h32m16_6_166_cl3.o +COBJS-$(CONFIG_DDR_MT47H64M16) += spr3xx_mt47h64m16_3_166_cl4_async.o +COBJS-$(CONFIG_DDR_MT47H64M16) += spr3xx_mt47h64m16_3_266_cl5_async.o +COBJS-$(CONFIG_DDR_MT47H64M16) += spr3xx_mt47h64m16_3_333_cl5_async.o endif
COBJS := $(sort $(COBJS-y)) diff --git a/board/st/spear/ddr/spr3xx_mt46h32m16_6_166_cl3.c b/board/st/spear/ddr/spr3xx_mt46h32m16_6_166_cl3.c new file mode 100644 index 0000000..ea2c466 --- /dev/null +++ b/board/st/spear/ddr/spr3xx_mt46h32m16_6_166_cl3.c @@ -0,0 +1,140 @@ +/* + * (C) Copyright 2000-2009 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm/arch/hardware.h> + +#if defined(CONFIG_ARCH_SPEAR3XX) && defined(CONFIG_SPEAR_DDR_HCLK) + +const u32 mpmc_conf_vals[CONFIG_SPEAR_MPMCREGS] = { + 0x00000001, + 0x00000000, + 0x01000000, + 0x00000001, + 0x00000001, + 0x01000000, + 0x00010001, + 0x00000100, + 0x00010001, + 0x00000001, + 0x02000001, + 0x04000201, + 0x02020102, + 0x03020202, + 0x02040202, + 0x00000002, + 0x00000000, + 0x01000403, + 0x02020002, + 0x01000203, + 0x0505053f, + 0x05050505, + 0x04040405, + 0x04040404, + 0x03030304, + 0x03030303, + 0x02020203, + 0x02020202, + 0x01010102, + 0x01010101, + 0x00000001, + 0x00000000, + 0x00000000, + 0x00000000, + 0x05060a00, + 0x0000023f, + 0x00030600, + 0x0a000000, + 0x00000a02, + 0x00001b1b, + 0x7f000000, + 0x001a0000, + 0x11030700, + 0x00640064, + 0x00640064, + 0x00000064, + 0x00000000, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00000000, + 0x00000000, + 0x0000050e, + 0x00000000, + 0x2d890000, + 0x00140014, + 0x00000000, + 0x00008236, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x003a0000, + 0x00010000, + 0x00200000, + 0x003c00f4, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x01010001, + 0x01010001, + 0x00000001, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000001 +}; +#endif diff --git a/board/st/spear/ddr/spr3xx_mt47h64m16_3_166_cl4_async.c b/board/st/spear/ddr/spr3xx_mt47h64m16_3_166_cl4_async.c new file mode 100644 index 0000000..42457b3 --- /dev/null +++ b/board/st/spear/ddr/spr3xx_mt47h64m16_3_166_cl4_async.c @@ -0,0 +1,146 @@ +/* + * (C) Copyright 2000-2009 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm/arch/hardware.h> + +#if defined(CONFIG_ARCH_SPEAR3XX) && defined(CONFIG_SPEAR_DDR_HCLK) + +const u32 mpmc_conf_vals[CONFIG_SPEAR_MPMCREGS] = { + 0x00000001, + 0x00000000, + 0x01000000, + 0x00000101, + 0x00000101, + 0x01000000, + 0x00010001, + 0x00000100, + 0x00010001, +#if defined(CONFIG_SPEAR_DUAL_DDR) + 0x01020003, + 0x01000102, + 0x04000202, +#else + 0x00000001, + 0x02000001, + 0x04000201, +#endif + 0x03030104, + 0x03020202, + 0x01040000, + 0x00000001, + 0x00000000, + 0x03000404, + 0x02020002, + 0x03000203, + 0x0505053f, + 0x05050505, + 0x04040405, + 0x04040404, + 0x03030304, + 0x03030303, + 0x02020203, + 0x02020202, + 0x01010102, + 0x01010101, + 0x00000001, + 0x00000000, + 0x00000000, + 0x00000000, + 0x07080a00, + 0x0000023f, + 0x00030600, + 0x09000000, + 0x00000a02, + 0x00001e1e, + 0x7F000000, + 0x005F0000, + 0x16030700, + 0x00640064, + 0x00640064, + 0x00000064, + 0x00000000, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00000000, + 0x00000000, + 0x0000050e, + 0x00000000, + 0x2d8900c8, + 0x00c80017, + 0x00000000, + 0x00008236, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x003a0000, + 0x00010000, + 0x00200000, + 0x003c00f4, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x01010001, + 0x01000000, + 0x00000001, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00430000, + 0x00000002 +}; +#endif diff --git a/board/st/spear/ddr/spr3xx_mt47h64m16_3_266_cl5_async.c b/board/st/spear/ddr/spr3xx_mt47h64m16_3_266_cl5_async.c new file mode 100644 index 0000000..fc8524d --- /dev/null +++ b/board/st/spear/ddr/spr3xx_mt47h64m16_3_266_cl5_async.c @@ -0,0 +1,146 @@ +/* + * (C) Copyright 2000-2009 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm/arch/hardware.h> + +#if defined(CONFIG_ARCH_SPEAR3XX) && defined(CONFIG_SPEAR_DDR_PLL2) + +const u32 mpmc_conf_vals[CONFIG_SPEAR_MPMCREGS] = { + 0x00000001, + 0x00000000, + 0x01000000, + 0x00000101, + 0x00000101, + 0x01000000, + 0x00010001, + 0x00000100, + 0x00010001, +#if defined(CONFIG_SPEAR_DUAL_DDR) + 0x01020003, + 0x01000102, + 0x04000202, +#else + 0x00000001, + 0x02000001, + 0x04000201, +#endif + 0x03030104, + 0x03020202, + 0x01040000, + 0x00000001, + 0x00000000, + 0x03000405, + 0x02030002, + 0x04000204, + 0x0505053f, + 0x05050505, + 0x04040405, + 0x04040404, + 0x03030304, + 0x03030303, + 0x02020203, + 0x02020202, + 0x01010102, + 0x01010101, + 0x00000001, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0a0b0a00, + 0x0000023f, + 0x00040800, + 0x0e000000, + 0x00000f02, + 0x00002020, + 0x7f000000, + 0x005f0000, + 0x22040b00, + 0x00640064, + 0x00640064, + 0x00000064, + 0x00000000, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00000000, + 0x00000000, + 0x0000081b, + 0x00000000, + 0x48e100c8, + 0x00c80025, + 0x00000000, + 0x0000d056, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00230000, + 0x001f0023, + 0x00400000, + 0x00250099, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x01010001, + 0x01000000, + 0x00000001, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x006b0000, + 0x00000002 +}; +#endif diff --git a/board/st/spear/ddr/spr3xx_mt47h64m16_3_333_cl5_async.c b/board/st/spear/ddr/spr3xx_mt47h64m16_3_333_cl5_async.c new file mode 100644 index 0000000..b8be8ae --- /dev/null +++ b/board/st/spear/ddr/spr3xx_mt47h64m16_3_333_cl5_async.c @@ -0,0 +1,152 @@ +/* + * (C) Copyright 2000-2009 + * Vipin Kumar, ST Microelectronics, vipin.kumar@st.com + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm/arch/hardware.h> + +#if defined(CONFIG_ARCH_SPEAR3XX) && \ + (defined(CONFIG_SPEAR_DDR_PLL2) || defined(CONFIG_SPEAR_DDR_2HCLK)) + +const u32 mpmc_conf_vals[CONFIG_SPEAR_MPMCREGS] = { +#if defined(CONFIG_SPEAR_DDR_PLL2) + 0x00000001, + 0x00000000, +#else + 0x02020201, + 0x00000202, +#endif + 0x01000000, + 0x00000101, + 0x00000101, + 0x01000000, + 0x00010001, + 0x00000100, + 0x00010001, +#if defined(CONFIG_SPEAR_DUAL_DDR) + 0x01020003, + 0x01000102, + 0x04000202, +#else + 0x00000001, + 0x02000001, + 0x04000201, +#endif + 0x03030104, + 0x03020202, + 0x01040000, + 0x00000001, + 0x00000000, + 0x03000405, + 0x03040002, + 0x04000305, + 0x0505053f, + 0x05050505, + 0x04040405, + 0x04040404, + 0x03030304, + 0x03030303, + 0x02020203, + 0x02020202, + 0x01010102, + 0x01010101, + 0x00000001, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0a0c0a00, + 0x0000023f, + 0x00050a00, + 0x11000000, + 0x00001302, + 0x00001c1c, + 0x7c000000, + 0x005c0000, + 0x2b050e00, + 0x00640064, + 0x00640064, + 0x00000064, + 0x00000000, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00200020, + 0x00000000, + 0x00000000, + 0x00000a24, + 0x00000000, + 0x5b1c00c8, + 0x00c8002e, + 0x00000000, + 0x0001046b, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x001c0000, + 0x0019001c, + 0x00100000, + 0x001e007a, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x01010001, + 0x01000000, + 0x00000001, + 0x00400000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00860000, + 0x00000002 +}; +#endif diff --git a/board/st/spear/spear300evb.c b/board/st/spear/spear300evb.c index 2ea598a..2f092fe 100644 --- a/board/st/spear/spear300evb.c +++ b/board/st/spear/spear300evb.c @@ -99,3 +99,10 @@ int board_eth_init(bd_t *bis) return ret; } #endif + +#if defined(CONFIG_SPL_BUILD) +void board_ddr_init(void) +{ + spear3xx_ddr_comp_init(); +} +#endif diff --git a/board/st/spear/spear310evb.c b/board/st/spear/spear310evb.c index 7f70008..fa5f5e2 100644 --- a/board/st/spear/spear310evb.c +++ b/board/st/spear/spear310evb.c @@ -32,6 +32,7 @@ #include <asm/arch/generic.h> #include <asm/arch/misc.h> #include <asm/arch/pinmux.h> +#include <asm/arch/spl_pnor.h>
#if defined(CONFIG_CMD_NAND) static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; @@ -109,3 +110,33 @@ int board_eth_init(bd_t *bis) return ret; } #endif + +#if defined(CONFIG_SPL_BUILD) +void board_ddr_init(void) +{ + spear3xx_ddr_comp_init(); +} + +/* +void soc_init(void) +{ + writel(0x2f7bc210, &misc_p->plgpio3_pad_prg); + writel(0x017bdef6, &misc_p->plgpio4_pad_prg); +} +*/ + +pnor_width_t get_pnor_width(void) +{ + u32 emi_buswidth = (readl(SPEAR310_BOOT_REG) & SPEAR310_EMIBW_MASK) >> + SPEAR310_EMIBW_SHFT; + + if (SPEAR310_EMIBW_8 == emi_buswidth) + return PNOR_WIDTH_8; + else if (SPEAR310_EMIBW_16 == emi_buswidth) + return PNOR_WIDTH_16; + else if (SPEAR310_EMIBW_32 == emi_buswidth) + return PNOR_WIDTH_32; + else + return PNOR_WIDTH_SEARCH; +} +#endif diff --git a/board/st/spear/spear320hmi.c b/board/st/spear/spear320hmi.c index 562bdda..886a79d 100644 --- a/board/st/spear/spear320hmi.c +++ b/board/st/spear/spear320hmi.c @@ -118,3 +118,10 @@ int board_mmc_init(bd_t *bis) return ret; } #endif + +#if defined(CONFIG_SPL_BUILD) +void board_ddr_init(void) +{ + spear3xx_ddr_comp_init(); +} +#endif diff --git a/board/st/spear/spear320plc.c b/board/st/spear/spear320plc.c index 315fe2d..2a408df 100644 --- a/board/st/spear/spear320plc.c +++ b/board/st/spear/spear320plc.c @@ -135,3 +135,10 @@ int board_mmc_init(bd_t *bis) return ret; } #endif + +#if defined(CONFIG_SPL_BUILD) +void board_ddr_init(void) +{ + spear3xx_ddr_comp_init(); +} +#endif diff --git a/include/configs/spear.h b/include/configs/spear.h index 4cb551d..d960d47 100644 --- a/include/configs/spear.h +++ b/include/configs/spear.h @@ -199,6 +199,10 @@ #define CONFIG_SYS_DCACHE_OFF #endif
+#ifndef CONFIG_SYS_PNOR_BOOT_BASE + #define CONFIG_SYS_PNOR_BOOT_BASE 0x0 +#endif + #define CONFIG_OF_LIBFDT #define CONFIG_CMDLINE_TAG #define CONFIG_SETUP_MEMORY_TAGS diff --git a/include/configs/spear300-evb.h b/include/configs/spear300-evb.h index e3f4ab4..2a222af 100644 --- a/include/configs/spear300-evb.h +++ b/include/configs/spear300-evb.h @@ -78,6 +78,11 @@ /* ST SMI (Serial flash) configurations */ #define CONFIG_ST_SMI
+/* SPL support */ +#define CONFIG_SPL +#define CONFIG_SPEAR_DDR_2HCLK +#define CONFIG_DDR_MT47H64M16 + #if defined(CONFIG_ENV_IS_IN_FLASH) /* Environment is in serial NOR flash */ #define CONFIG_ENV_ADDR 0xF8060000 diff --git a/include/configs/spear310-evb.h b/include/configs/spear310-evb.h index 505c8a4..12dd5eb 100644 --- a/include/configs/spear310-evb.h +++ b/include/configs/spear310-evb.h @@ -95,6 +95,11 @@ #define CONFIG_ST_SMI #endif
+/* SPL support */ +#define CONFIG_SPL +#define CONFIG_SPEAR_DDR_2HCLK +#define CONFIG_DDR_MT47H64M16 + /* CFI Driver configurations */ #if defined(CONFIG_FLASH_PNOR) #define CONFIG_FLASH_CFI_DRIVER diff --git a/include/configs/spear3xx.h b/include/configs/spear3xx.h index e89e9c2..3f53b20 100644 --- a/include/configs/spear3xx.h +++ b/include/configs/spear3xx.h @@ -46,5 +46,20 @@ #define CONFIG_SYS_INIT_SP_ADDR (0xD2800000 + 0x2000 - \ GENERATED_GBL_DATA_SIZE)
+/* SPL configurations */ +#if defined(CONFIG_SPL) + #define CONFIG_SPL_TEXT_BASE 0xD2800B00 + #define CONFIG_SYS_SNOR_BOOT_BASE 0xF8010000 + #define CONFIG_SYS_NAND_BOOT_BLK 4 + + #define CONFIG_SPL_NO_CPU_SUPPORT_CODE + #define CONFIG_SPL_LIBCOMMON_SUPPORT + #define CONFIG_SPL_LIBGENERIC_SUPPORT + #define CONFIG_SPL_MTD_SUPPORT + #define CONFIG_SPL_START_S_PATH "arch/arm/cpu/arm926ejs/spear" + #define CONFIG_SPL_LDSCRIPT \ + "arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds" +#endif + #include <configs/spear.h> #endif /* __CONFIG_SPEAR3XX_H */
participants (1)
-
Vipin Kumar