Support for the DENX M28 SoM
Subsystems (11)
cover Support for the DENX M28 SoM
This series adds support for DENX M28 SoM and M28EVK kit.
This series depends on previous series:
* Support for both FEC interfaces on i.MX28
* Random NAND fixes and improvements
Marek Vasut (31):
iMX28: Initial support for iMX28 CPU
iMX28: Add basic support for DENX M28EVK board
iMX28: Add support for SSP MMC
M28EVK: Enable MMC support
iMX28: Add pinctrl and ocotp register definitions
FEC: Add support for iMX28 quirks
iMX28: Add CPU-specific FEC ethernet init
M28EVK: Enable FEC0 and FEC1
iMX28: Add PINMUX control
iMX28: Add RTC register definitions
iMX28: Add I2C register definitions
iMX28: Add I2C bus driver
M28: Enable I2C, EEPROM and RTC
iMX28: Add MMC SPL
M28: Enable MMC SPL
iMX28: Add GPIO control
M28: Enable use of GPIO configurators
iMX28: Add SPI driver
M28EVK: Enable SPI and SPI flash
iMX28: Add APBH DMA driver
iMX28: Add BCH and GPMI register definitions
iMX28: Add GPMI NAND driver
M28: Enable NAND
iMX28: Add driver for internal RTC
M28: Enable the internal RTC instead of the M41T62
M28: Enable UBI and UBIFS
M28: Save environment in NAND
iMX28: Add image header generator tool
M28: Add NAND update scripts
i.MX28: Add u-boot.sb target to Makefile
M28: Add doc/README.m28 documentation
MAINTAINERS | 1 + Makefile | 5 + arch/arm/cpu/arm926ejs/mx28/Makefile | 46 + arch/arm/cpu/arm926ejs/mx28/clock.c | 359 +++++++ arch/arm/cpu/arm926ejs/mx28/gpio.c | 108 +++ arch/arm/cpu/arm926ejs/mx28/iomux.c | 111 +++ arch/arm/cpu/arm926ejs/mx28/mx28.c | 172 ++++ arch/arm/cpu/arm926ejs/mx28/timer.c | 143 +++ arch/arm/include/asm/arch-mx28/clock.h | 48 + arch/arm/include/asm/arch-mx28/dma.h | 170 ++++ arch/arm/include/asm/arch-mx28/gpio.h | 32 + arch/arm/include/asm/arch-mx28/imx-regs.h | 33 + arch/arm/include/asm/arch-mx28/iomux-mx28.h | 537 +++++++++++ arch/arm/include/asm/arch-mx28/iomux.h | 168 ++++ arch/arm/include/asm/arch-mx28/mx28.h | 32 + arch/arm/include/asm/arch-mx28/regs-apbh.h | 462 +++++++++ arch/arm/include/asm/arch-mx28/regs-base.h | 88 ++ arch/arm/include/asm/arch-mx28/regs-bch.h | 226 +++++ arch/arm/include/asm/arch-mx28/regs-clkctrl.h | 308 ++++++ arch/arm/include/asm/arch-mx28/regs-common.h | 66 ++ arch/arm/include/asm/arch-mx28/regs-gpmi.h | 218 +++++ arch/arm/include/asm/arch-mx28/regs-i2c.h | 203 ++++ arch/arm/include/asm/arch-mx28/regs-ocotp.h | 169 ++++ arch/arm/include/asm/arch-mx28/regs-pinctrl.h | 1280 +++++++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-power.h | 409 ++++++++ arch/arm/include/asm/arch-mx28/regs-rtc.h | 143 +++ arch/arm/include/asm/arch-mx28/regs-ssp.h | 345 +++++++ arch/arm/include/asm/arch-mx28/regs-timrot.h | 167 ++++ arch/arm/include/asm/arch-mx28/regs-uartdbg.h | 182 ++++ board/denx/m28evk/Makefile | 49 + board/denx/m28evk/m28evk.c | 200 ++++ boards.cfg | 1 + doc/README.m28 | 223 +++++ drivers/dma/Makefile | 1 + drivers/dma/apbh_dma.c | 693 +++++++++++++ drivers/i2c/Makefile | 1 + drivers/i2c/mxs_i2c.c | 243 +++++ drivers/mmc/Makefile | 1 + drivers/mmc/mxsmmc.c | 354 +++++++ drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/mxs_nand.c | 1163 ++++++++++++++++++++++ drivers/net/fec_mxc.c | 44 +- drivers/rtc/Makefile | 1 + drivers/rtc/mxsrtc.c | 88 ++ drivers/spi/Makefile | 1 + drivers/spi/mxs_spi.c | 174 ++++ include/configs/m28evk.h | 276 ++++++ mmc_spl/board/denx/m28evk/Makefile | 102 ++ mmc_spl/board/denx/m28evk/m28_init.h | 36 + mmc_spl/board/denx/m28evk/mem_init.c | 218 +++++ mmc_spl/board/denx/m28evk/mmc_boot.c | 271 ++++++ mmc_spl/board/denx/m28evk/power_init.c | 915 ++++++++++++++++++ mmc_spl/board/denx/m28evk/start.S | 402 ++++++++ mmc_spl/board/denx/m28evk/u-boot.bd | 14 + mmc_spl/board/denx/m28evk/u-boot.lds | 87 ++ tools/Makefile | 6 + tools/mxsboot.c | 687 +++++++++++++ 57 files changed, 12481 insertions(+), 2 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/mx28/Makefile create mode 100644 arch/arm/cpu/arm926ejs/mx28/clock.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/gpio.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/iomux.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/mx28.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/timer.c create mode 100644 arch/arm/include/asm/arch-mx28/clock.h create mode 100644 arch/arm/include/asm/arch-mx28/dma.h create mode 100644 arch/arm/include/asm/arch-mx28/gpio.h create mode 100644 arch/arm/include/asm/arch-mx28/imx-regs.h create mode 100644 arch/arm/include/asm/arch-mx28/iomux-mx28.h create mode 100644 arch/arm/include/asm/arch-mx28/iomux.h create mode 100644 arch/arm/include/asm/arch-mx28/mx28.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-apbh.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-base.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-bch.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-clkctrl.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-common.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-gpmi.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-i2c.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-ocotp.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-pinctrl.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-power.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-rtc.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-ssp.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-timrot.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-uartdbg.h create mode 100644 board/denx/m28evk/Makefile create mode 100644 board/denx/m28evk/m28evk.c create mode 100644 doc/README.m28 create mode 100644 drivers/dma/apbh_dma.c create mode 100644 drivers/i2c/mxs_i2c.c create mode 100644 drivers/mmc/mxsmmc.c create mode 100644 drivers/mtd/nand/mxs_nand.c create mode 100644 drivers/rtc/mxsrtc.c create mode 100644 drivers/spi/mxs_spi.c create mode 100644 include/configs/m28evk.h create mode 100644 mmc_spl/board/denx/m28evk/Makefile create mode 100644 mmc_spl/board/denx/m28evk/m28_init.h create mode 100644 mmc_spl/board/denx/m28evk/mem_init.c create mode 100644 mmc_spl/board/denx/m28evk/mmc_boot.c create mode 100644 mmc_spl/board/denx/m28evk/power_init.c create mode 100644 mmc_spl/board/denx/m28evk/start.S create mode 100644 mmc_spl/board/denx/m28evk/u-boot.bd create mode 100644 mmc_spl/board/denx/m28evk/u-boot.lds create mode 100644 tools/mxsboot.c
Signature · 1 line
1.7.5.4
PATCH 1/31 iMX28: Initial support for iMX28 CPU
This patch supports:
- Timers
- Debug UART
- Clock
--- arch/arm/cpu/arm926ejs/mx28/Makefile | 46 +++ arch/arm/cpu/arm926ejs/mx28/clock.c | 359 ++++++++++++++++++++++ arch/arm/cpu/arm926ejs/mx28/mx28.c | 131 ++++++++ arch/arm/cpu/arm926ejs/mx28/timer.c | 143 +++++++++ arch/arm/include/asm/arch-mx28/clock.h | 48 +++ arch/arm/include/asm/arch-mx28/imx-regs.h | 33 ++ arch/arm/include/asm/arch-mx28/mx28.h | 30 ++ arch/arm/include/asm/arch-mx28/regs-base.h | 88 ++++++ arch/arm/include/asm/arch-mx28/regs-clkctrl.h | 308 +++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-common.h | 66 ++++ arch/arm/include/asm/arch-mx28/regs-power.h | 409 +++++++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-ssp.h | 345 +++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-timrot.h | 167 ++++++++++ arch/arm/include/asm/arch-mx28/regs-uartdbg.h | 182 +++++++++++ 14 files changed, 2355 insertions(+), 0 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/mx28/Makefile create mode 100644 arch/arm/cpu/arm926ejs/mx28/clock.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/mx28.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/timer.c create mode 100644 arch/arm/include/asm/arch-mx28/clock.h create mode 100644 arch/arm/include/asm/arch-mx28/imx-regs.h create mode 100644 arch/arm/include/asm/arch-mx28/mx28.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-base.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-clkctrl.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-common.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-power.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-ssp.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-timrot.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-uartdbg.h
arch/arm/cpu/arm926ejs/mx28/Makefile new file +46 -0
@@ -0,0 +1,46 @@ +# +# (C) Copyright 2000-2006 +# Wolfgang Denk, DENX Software Engineering, wd at denx.de. +# +# 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 $(TOPDIR)/config.mk + +LIB = $(obj)lib$(SOC).o + +COBJS = clock.o mx28.o timer.o + +SRCS := $(START:.o=.S) $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS)) +START := $(addprefix $(obj),$(START)) + +all: $(obj).depend $(LIB) + +$(LIB): $(OBJS) + $(call cmd_link_o_target, $(OBJS)) + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +#########################################################################
arch/arm/cpu/arm926ejs/mx28/clock.c new file +359 -0
359 lines not on this page · raw message
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +131 -0
131 lines not on this page · raw message
arch/arm/cpu/arm926ejs/mx28/timer.c new file +143 -0
143 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/clock.h new file +48 -0
48 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/imx-regs.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Freescale i.MX28 Registers +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 __IMX_REGS_H__ +#define __IMX_REGS_H__ + +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-ssp.h> +#include <asm/arch/regs-timrot.h> +#include <asm/arch/regs-uartdbg.h> + +#endif /* __IMX_REGS_H__ */
arch/arm/include/asm/arch-mx28/mx28.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Freescale i.MX28 MX28 specific functions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 __MX28_H__ +#define __MX28_H__ + +int mx28_reset_block (struct mx28_register *reg); +int mx28_wait_mask_set (struct mx28_register *reg,uint32_t mask,int timeout); +int mx28_wait_mask_clr (struct mx28_register *reg,uint32_t mask,int timeout); + +#endif /* __MX28_H__ */
arch/arm/include/asm/arch-mx28/regs-base.h new file +88 -0
88 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/regs-clkctrl.h new file +308 -0
308 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/regs-common.h new file +66 -0
66 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/regs-power.h new file +409 -0
409 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/regs-ssp.h new file +345 -0
345 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/regs-timrot.h new file +167 -0
167 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/regs-uartdbg.h new file +182 -0
182 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 1/31 iMX28: Initial support for iMX28 CPU
Quoted 4 lines · Marek Vasut
This patch supports:
- Timers
- Debug UART
- Clock
Hi Marek,
a general remark. It seems to me that your patchset comes directly from your development, as it looks like what I normally have when I develop a new board ;-)
However, to put into mainline and to make review easier, because this is a porting to a new SOC, I am expecting that all patches related to a new file are squashed together. It makes no sense to have several patches regarding, for example, m28evk.h, because this is a new file.
Another general remark here: we tend to have the same structure and the same files for all IMX SOC. This means that all IMX SOC have a imx-regs.h that contain the required register definitions (really a subset what we have in kernel). Is it really necessary to split the definitions in several small files ?
Quoted 27 lines
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- arch/arm/cpu/arm926ejs/mx28/Makefile | 46 +++ arch/arm/cpu/arm926ejs/mx28/clock.c | 359 ++++++++++++++++++++++ arch/arm/cpu/arm926ejs/mx28/mx28.c | 131 ++++++++ arch/arm/cpu/arm926ejs/mx28/timer.c | 143 +++++++++ arch/arm/include/asm/arch-mx28/clock.h | 48 +++ arch/arm/include/asm/arch-mx28/imx-regs.h | 33 ++ arch/arm/include/asm/arch-mx28/mx28.h | 30 ++ arch/arm/include/asm/arch-mx28/regs-base.h | 88 ++++++ arch/arm/include/asm/arch-mx28/regs-clkctrl.h | 308 +++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-common.h | 66 ++++ arch/arm/include/asm/arch-mx28/regs-power.h | 409 +++++++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-ssp.h | 345 +++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-timrot.h | 167 ++++++++++ arch/arm/include/asm/arch-mx28/regs-uartdbg.h | 182 +++++++++++ 14 files changed, 2355 insertions(+), 0 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/mx28/Makefile create mode 100644 arch/arm/cpu/arm926ejs/mx28/clock.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/mx28.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/timer.c create mode 100644 arch/arm/include/asm/arch-mx28/clock.h create mode 100644 arch/arm/include/asm/arch-mx28/imx-regs.h
Quoted 8 lines
create mode 100644 arch/arm/include/asm/arch-mx28/mx28.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-base.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-clkctrl.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-common.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-power.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-ssp.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-timrot.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-uartdbg.h
regs-uartdbg.h is used only by the driver, right ? The driver should be in the driver directory, and also its header. See drivers/serial/
arch/arm/cpu/arm926ejs/mx28/clock.c line 36
Quoted 9 lines
arch/arm/cpu/arm926ejs/mx28/clock.c new file +9
-0+ +#include <common.h> +#include <asm/errno.h> +#include <asm/io.h> +#include <asm/arch/clock.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-ssp.h>
Again, regarding file splitting for register. If you prefer to have several files, I think it is better that imx-regs.h include them. Then we have still a common header imx-regs.h that contains all needed register definitions. This is a better interface for a board maintainer.
arch/arm/cpu/arm926ejs/mx28/clock.c line 47
Quoted 11 lines
arch/arm/cpu/arm926ejs/mx28/clock.c new file +11
-0+ +/* The PLL frequency is always 480MHz, see section 10.2 in iMX28 datasheet. */ +#define PLL_FREQ_KHZ 480000 +#define PLL_FREQ_COEF 18 +/* The XTAL frequency is always 24MHz, see section 10.2 in iMX28 datasheet. */ +#define XTAL_FREQ_KHZ 24000 + +#define PLL_FREQ_MHZ (PLL_FREQ_KHZ / 1000) +#define XTAL_FREQ_MHZ (XTAL_FREQ_KHZ / 1000) + +uint32_t mx28_get_pclk (void )
This function must be static.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +uint32_t mx28_get_hclk(void)
Ditto. All *_get_some_clk are exported with mxc_get_clk(index_number)
Review
Quoted 2 lines
(quoted diff) +2
-0+ +uint32_t mx28_get_emiclk(void)
Ditto
Review
Quoted 2 lines
(quoted diff) +2
-0+static inline void enable_gpmi_clk(void) +{
Is there a reason to have inline ? And this is called only once. Do we have a enable_ without a disable_ function ? Your mx28_get_gpmiclk() enables without the caller knows the gpmi clock. Strange for a pure "get" function.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +uint32_t mx28_get_gpmiclk(void)
Also static.
arch/arm/cpu/arm926ejs/mx28/clock.c line 171
Quoted 5 lines
arch/arm/cpu/arm926ejs/mx28/clock.c new file +5
-0+/* +* Set IO clock frequency, in kHz +*/ +void mx28_set_ioclk (unsigned int io,uint32_t freq) +{
Please use an enum for io - it cannot assume any integer value, something with GATE0 and GATE1 to be the call easier to understand.
arch/arm/cpu/arm926ejs/mx28/clock.c line 212
Quoted 5 lines
arch/arm/cpu/arm926ejs/mx28/clock.c new file +5
-0+ +/* +* Get IO clock, returns IO clock in kHz +*/ +uint32_t mx28_get_ioclk (unsigned int io)
Static function. Do you think to export this function ? In this case, you need to add enums for mxc_get_clk().
arch/arm/cpu/arm926ejs/mx28/clock.c line 243
Quoted 12 lines
arch/arm/cpu/arm926ejs/mx28/clock.c new file +12
-0+ +/* +* Configure SSP clock frequency, in kHz +*/ +void mx28_set_sspclk (unsigned int ssp,uint32_t freq,int xtal) +{ +struct mx28_clkctrl_regs *clkctrl_regs = + (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE ; +uint32_t clk, clkreg; + +if (ssp >3 ) +return ;
Maybe a define in imx-regs.h setting the max number of serial ports ?
Review
Quoted 2 lines
(quoted diff) +2
-0+ + clkreg = (uint32_t)(&clkctrl_regs->hw_clkctrl_ssp0) + (ssp * 0x10);
You have a pointer to a mx28_reg structure. Replace fixed offset with a sizeof.
Review
Quoted 2 lines
(quoted diff) +2
-0+uint32_t mx28_get_sspclk(unsigned int ssp) +{
Static as other get functions.
arch/arm/cpu/arm926ejs/mx28/clock.c line 355
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/clock.c new file +10
-0+uint32_t mxc_get_clock (enum mxc_clock clk) +{ +switch (clk) { +case MXC_ARM_CLK : +return mx28_get_pclk () *1000000 ; +case MXC_GPMI_CLK : +return mx28_get_gpmiclk () *1000000 ; +case MXC_AHB_CLK : +case MXC_IPG_CLK : +return mx28_get_hclk () *1000000 ;
Probably you need to add some new enums if you want to export all your get functions, such as MXC_GET_UARTCLK for your mx28_get_sspclk (or new enums if you think there new features).
arch/arm/cpu/arm926ejs/mx28/mx28.c line 37
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +10
-0+ +#include <common.h> +#include <asm/errno.h> +#include <asm/io.h> +#include <asm/arch/clock.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-power.h> +#include <asm/arch/mx28.h>
Same comment for register definitions splitting as before.
arch/arm/cpu/arm926ejs/mx28/mx28.c line 46
Quoted 2 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +2
-0+/* Lowlevel init isn't used on i.MX28, so just have a dummy here */ +inline void lowlevel_init (void ) {}
Ok.
Quoted 7 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +7
-0+ +void reset_cpu (ulong ignored) __attribute__((noreturn)); + +void reset_cpu (ulong ignored) +{ +struct mx28_clkctrl_regs *clkctrl_regs = + (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE ;
arch/arm/cpu/arm926ejs/mx28/mx28.c line 63
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +10
-0+struct mx28_power_regs *power_regs = + (struct mx28_power_regs *)MXS_POWER_BASE ; + +writel (0 , &power_regs->hw_power_charge); +writel (0 , &power_regs->hw_power_minpwr); +writel (CLKCTRL_RESET_DIG , &clkctrl_regs->hw_clkctrl_reset); + +/* Endless loop, reset will exit from here */ +for (;;) + ;
To understand: does a reset mean on the i.MX28 a power off ? Do you turn off the power ? If this is the case, some features are not possible (as PRAM, for example) on this SOC.
Quoted 55 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +55
-0+int mx28_wait_mask_set (struct mx28_register *reg,uint32_t mask,int timeout) +{ +while (--timeout) { +if ((readl (®->reg) & mask) == mask) +break ; +udelay (1 ); + } + +return !timeout; +} + +int mx28_wait_mask_clr (struct mx28_register *reg,uint32_t mask,int timeout) +{ +while (--timeout) { +if ((readl (®->reg) & mask) ==0 ) +break ; +udelay (1 ); + } + +return !timeout; +} + +int mx28_reset_block (struct mx28_register *reg) +{ +/* Clear SFTRST */ +writel (MX28_BLOCK_SFTRST , ®->reg_clr); + +if (mx28_wait_mask_clr (reg,MX28_BLOCK_SFTRST ,RESET_MAX_TIMEOUT )) +return 1 ; + +/* Clear CLKGATE */ +writel (MX28_BLOCK_CLKGATE , ®->reg_clr); + +/* Set SFTRST */ +writel (MX28_BLOCK_SFTRST , ®->reg_set); + +/* Wait for CLKGATE being set */ +if (mx28_wait_mask_set (reg,MX28_BLOCK_CLKGATE ,RESET_MAX_TIMEOUT )) +return 1 ; + +/* Clear SFTRST */ +writel (MX28_BLOCK_SFTRST , ®->reg_clr); + +if (mx28_wait_mask_clr (reg,MX28_BLOCK_SFTRST ,RESET_MAX_TIMEOUT )) +return 1 ; + +/* Clear CLKGATE */ +writel (MX28_BLOCK_CLKGATE , ®->reg_clr); + +if (mx28_wait_mask_clr (reg,MX28_BLOCK_CLKGATE ,RESET_MAX_TIMEOUT )) +return 1 ; + +return 0 ; +} +
arch/arm/cpu/arm926ejs/mx28/mx28.c line 130
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +10
-0+#if defined(CONFIG_DISPLAY_CPUINFO ) +int print_cpuinfo (void ) +{ +printf ("Freescale i.MX28 family\n" ); +printf ("CPU: %3d MHz\n" ,mx28_get_pclk ()); +printf ("BUS: %3d MHz\n" ,mx28_get_hclk ()); +printf ("EMI: %3d MHz\n" ,mx28_get_emiclk ()); +printf ("GPMI: %3d MHz\n" ,mx28_get_gpmiclk ()); +return 0 ; +}
The function has the name "cpuinfo", but you print nothing about the cpu. Instead of that, the clock's value are printed.
After some discussion we have this common statement for the i.MX SOCs:
- the print_cpuinfo gives the revision number and the reset cause See all other i.MX implementations
- clocks are printed with a command, whose name *must* be (because we use for PowerPC also) simply "clocks". This avoid too much printing at the startup. See for example do_mx35_showclocks(), or the same for mx5.
Please follow this rule.
arch/arm/cpu/arm926ejs/mx28/timer.c line 34
Quoted 7 lines
arch/arm/cpu/arm926ejs/mx28/timer.c new file +7
-0+ +#include <common.h> +#include <asm/io.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-timrot.h> +#include <asm/arch/mx28.h>
Remark to check the register definitions. My idea is to have a simple easy to understand interface to get the register definitions for a SOC, and I would replace this stuff only with imx-regs.h. What do you think ?
Quoted 13 lines
arch/arm/cpu/arm926ejs/mx28/timer.c new file +13
-0+ulong get_timer (ulong base) +{ +struct mx28_timrot_regs *timrot_regs = + (struct mx28_timrot_regs *)MXS_TIMROT_BASE ; + +/* Current tick value */ +uint32_t now =readl (&timrot_regs->hw_timrot_running_count0); + +if (lastdec >= now) { +/* +* normal mode (non roll) +* move stamp forward with absolut diff ticks +*/
arch/arm/cpu/arm926ejs/mx28/timer.c line 109
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/timer.c new file +10
-0+ timestamp += (lastdec - now); + }else { +/* we have rollover of decrementer */ + timestamp += (TIMER_LOAD_VAL - now) + lastdec; + + } + lastdec = now; + +return tick_to_time (timestamp) - base; +}
Not sure, but it seems to me this implementation does not follow the last changes to this kind of interface. We should implement get_timer_masked(), but then get_timer is simply:
ulong get_timer(ulong base)
{
return get_timer_masked() - base;
}as I see in most SOC. However, Heiko (in CC) knows more deeply this stuff as me, and he can better explain us if this implementation is correct.
I know that other i.MX are look like your implementation, but they are quite old...
Quoted 11 lines
arch/arm/cpu/arm926ejs/mx28/timer.c new file +11
-0+ +/* We use the HW_DIGCTL_MICROSECONDS register for sub-millisecond timer. */ +#define MX28_HW_DIGCTL_MICROSECONDS 0x8001c0c0 + +void __udelay (unsigned long usec) +{ +uint32_t old, new, incr; +uint32_t counter =0 ; + + old =readl (MX28_HW_DIGCTL_MICROSECONDS ); +
arch/arm/cpu/arm926ejs/mx28/timer.c line 130
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/timer.c new file +10
-0+while (counter < usec) { + new =readl (MX28_HW_DIGCTL_MICROSECONDS ); + +/* Check if the timer wrapped. */ +if (new < old) { + incr =0xffffffff - old; + incr += new; + }else { + incr = new - old; + }
The same for __udelay. I think there is a common agreement to it, and I am expecting that the code to manage overflow is similar.
Should we export also a get_ticks() ?
Quoted 33 lines
arch/arm/include/asm/arch-mx28/clock.h new file +27
-0@@ -0,0 +1,48 @@ +/* +* Freescale i.MX28 Clock +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 __CLOCK_H__ +#define __CLOCK_H__ + +enum mxc_clock { + MXC_ARM_CLK = 0,
arch/arm/include/asm/arch-mx28/clock.h line 37
Quoted 10 lines
arch/arm/include/asm/arch-mx28/clock.h new file +10
-0+MXC_AHB_CLK , +MXC_IPG_CLK , + MXC_GPMI_CLK, +}; + +uint32_t mxc_get_clock (enum mxc_clock clk); +uint32_t mx28_get_pclk (void ); +uint32_t mx28_get_hclk (void ); +uint32_t mx28_get_emiclk (void ); +uint32_t mx28_get_gpmiclk (void );
wrong. You should export only mxc_get_clock.
arch/arm/include/asm/arch-mx28/clock.h line 40
Quoted 3 lines
arch/arm/include/asm/arch-mx28/clock.h new file +3
-0+ +void mx28_set_ioclk (unsigned int io,uint32_t freq); +uint32_t mx28_get_ioclk (unsigned int io);
Ditto.
Quoted 28 lines
arch/arm/include/asm/arch-mx28/imx-regs.h new file +22
-0@@ -0,0 +1,33 @@ +/* +* Freescale i.MX28 Registers +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 +* +*/ +
arch/arm/include/asm/arch-mx28/imx-regs.h line 32
Quoted 10 lines
arch/arm/include/asm/arch-mx28/imx-regs.h new file +10
-0+#ifndef __IMX_REGS_H__ +#define __IMX_REGS_H__ + +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-ssp.h> +#include <asm/arch/regs-timrot.h> +#include <asm/arch/regs-uartdbg.h> +
Ok, I see. Then I do not understand why you include explicitely each single file in the code instead of imx-regs.h only.
Quoted 26 lines
arch/arm/include/asm/arch-mx28/mx28.h new file +20
-0@@ -0,0 +1,30 @@ +/* +* Freescale i.MX28 MX28 specific functions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 +*
arch/arm/include/asm/arch-mx28/mx28.h line 30
Quoted 10 lines
arch/arm/include/asm/arch-mx28/mx28.h new file +10
-0+*/ + +#ifndef __MX28_H__ +#define __MX28_H__ + +int mx28_reset_block (struct mx28_register *reg); +int mx28_wait_mask_set (struct mx28_register *reg,uint32_t mask,int timeout); +int mx28_wait_mask_clr (struct mx28_register *reg,uint32_t mask,int timeout); + +#endif /* __MX28_H__ */
Should be these function available also outside the SOC directory ? If the answer is yes, the common name (copied from omap) for the header file to add such prototypes is sys_proto.h
Quoted 25 lines
arch/arm/include/asm/arch-mx28/regs-clkctrl.h new file +19
-0@@ -0,0 +1,308 @@ +/* +* Freescale i.MX28 CLKCTRL Register Definitions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* Based on code from LTIB: +* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* 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. +*
arch/arm/include/asm/arch-mx28/regs-clkctrl.h line 29
Quoted 10 lines
arch/arm/include/asm/arch-mx28/regs-clkctrl.h new file +10
-0+* 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 __REGS_CLKCTRL_H__ +#define __REGS_CLKCTRL_H__ + +struct mx28_clkctrl_regs {
I think you should protect with defined(__ASSEMBLY__). Register definitions could be included by assembly file also - even if it is not the case now with M28EVK, it could be in future.
arch/arm/include/asm/arch-mx28/regs-clkctrl.h line 30
Quoted 1 line
arch/arm/include/asm/arch-mx28/regs-clkctrl.h new file +1
-0+mx28_reg (hw_clkctrl_pll0ctrl0)/* 0x00 */
This adds an implicit order to include your file. mx28_reg is not defined here. regs-common.h must be included before this file. This is pretty bad.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 1/31 iMX28: Initial support for iMX28 CPU
Hello Stefano,
Quoted 11 lines · Stefano Babic
Quoted 4 lines · Marek Vasut
This patch supports:
- Timers
- Debug UART
- ClockHi Marek,
a general remark. It seems to me that your patchset comes directly from your development, as it looks like what I normally have when I develop a new board ;-)
I also tend to do such things ;-)
Quoted 4 lines
However, to put into mainline and to make review easier, because this is a porting to a new SOC, I am expecting that all patches related to a new file are squashed together. It makes no sense to have several patches regarding, for example,
m28evk.h, because this is a new file.
Yep, for new files, it makes sense to make only one patch.
Quoted 5 lines
Another general remark here: we tend to have the same structure and the same files for all IMX SOC. This means that all IMX SOC have a
imx-regs.hthat contain the required register definitions (really a subset what we have in kernel). Is it really necessary to split the definitions in several small files ?
Hmm... is this really a good thing? If I look in the statistic below, this results in a big (lines > 1000) file ... I don;t like such big files, but this is just a personal taste ...
Quoted 12 lines
Quoted 12 lines
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- arch/arm/cpu/arm926ejs/mx28/Makefile | 46 +++ arch/arm/cpu/arm926ejs/mx28/clock.c | 359 ++++++++++++++++++++++ arch/arm/cpu/arm926ejs/mx28/mx28.c | 131 ++++++++ arch/arm/cpu/arm926ejs/mx28/timer.c | 143 +++++++++ arch/arm/include/asm/arch-mx28/clock.h | 48 +++ arch/arm/include/asm/arch-mx28/imx-regs.h | 33 ++
Quoted 8 lines
Quoted 8 lines
arch/arm/include/asm/arch-mx28/mx28.h | 30 ++ arch/arm/include/asm/arch-mx28/regs-base.h | 88 ++++++ arch/arm/include/asm/arch-mx28/regs-clkctrl.h | 308 +++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-common.h | 66 ++++ arch/arm/include/asm/arch-mx28/regs-power.h | 409 +++++++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-ssp.h | 345 +++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-timrot.h | 167 ++++++++++ arch/arm/include/asm/arch-mx28/regs-uartdbg.h | 182 +++++++++++
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 1/31 iMX28: Initial support for iMX28 CPU
In reply to Stefano BabicQuoted 8 lines · Stefano Babic
Quoted 4 lines · Marek Vasut
This patch supports:
- Timers
- Debug UART
- ClockHi Marek,
Quoted 8 lines
a general remark. It seems to me that your patchset comes directly from your development, as it looks like what I normally have when I develop a new board ;-)
However, to put into mainline and to make review easier, because this is a porting to a new SOC, I am expecting that all patches related to a new file are squashed together. It makes no sense to have several patches regarding, for example,
m28evk.h, because this is a new file.
Done, I'll retest and send V2 of the series
Quoted 6 lines
Another general remark here: we tend to have the same structure and the same files for all IMX SOC. This means that all IMX SOC have a
imx-regs.hthat contain the required register definitions (really a subset what we have in kernel). Is it really necessary to split the definitions in several small files ?
Just like Heiko said ... it'd produce terribly big and messy file. I'd prefer to avoid that.
Quoted 39 lines
Quoted 30 lines
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
arch/arm/cpu/arm926ejs/mx28/Makefile | 46 +++ arch/arm/cpu/arm926ejs/mx28/clock.c | 359 ++++++++++++++++++++++ arch/arm/cpu/arm926ejs/mx28/mx28.c | 131 ++++++++ arch/arm/cpu/arm926ejs/mx28/timer.c | 143 +++++++++ arch/arm/include/asm/arch-mx28/clock.h | 48 +++ arch/arm/include/asm/arch-mx28/imx-regs.h | 33 ++ arch/arm/include/asm/arch-mx28/mx28.h | 30 ++ arch/arm/include/asm/arch-mx28/regs-base.h | 88 ++++++ arch/arm/include/asm/arch-mx28/regs-clkctrl.h | 308 +++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-common.h | 66 ++++ arch/arm/include/asm/arch-mx28/regs-power.h | 409 +++++++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-ssp.h | 345 +++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-timrot.h | 167 ++++++++++ arch/arm/include/asm/arch-mx28/regs-uartdbg.h | 182 +++++++++++ 14 files changed, 2355 insertions(+), 0 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/mx28/Makefile create mode 100644 arch/arm/cpu/arm926ejs/mx28/clock.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/mx28.c create mode 100644 arch/arm/cpu/arm926ejs/mx28/timer.c create mode 100644 arch/arm/include/asm/arch-mx28/clock.h create mode 100644 arch/arm/include/asm/arch-mx28/imx-regs.hQuoted 8 lines
create mode 100644 arch/arm/include/asm/arch-mx28/mx28.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-base.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-clkctrl.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-common.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-power.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-ssp.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-timrot.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-uartdbg.h
Quoted 2 lines
regs-uartdbg.his used only by the driver, right ? The driver should be in the driver directory, and also its header. Seedrivers/serial/
Honestly, I need to check if the file is used at all. We replaced the original driver with pl011 driver.
Quoted 15 lines
arch/arm/cpu/arm926ejs/mx28/clock.c line 36
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/clock.c new file +9
-0+ +#include <common.h> +#include <asm/errno.h> +#include <asm/io.h> +#include <asm/arch/clock.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-ssp.h> Again, regarding file splitting for register. If you prefer to have several files, I think it is better that
imx-regs.hinclude them. Then we have still a common headerimx-regs.hthat contains all needed register definitions. This is a better interface for a board maintainer.
Won't it make the compiler slower at compile time if it has to go through all of the included files instead of a subset ?
Quoted 15 lines
arch/arm/cpu/arm926ejs/mx28/clock.c line 47
Quoted 12 lines
(quoted diff) +2
-0+ +/* The PLL frequency is always 480MHz, see section 10.2 in iMX28datasheet. */ +#define
PLL_FREQ_KHZ480000(quoted diff) +2
-0+#define PLL_FREQ_COEF 18 +/* The XTAL frequency is always 24MHz, see section 10.2 in iMX28datasheet. */ +#define
XTAL_FREQ_KHZ24000arch/arm/cpu/arm926ejs/mx28/clock.c new file +5
-0+ +#define PLL_FREQ_MHZ (PLL_FREQ_KHZ / 1000) +#define XTAL_FREQ_MHZ (XTAL_FREQ_KHZ / 1000) + +uint32_t mx28_get_pclk (void )This function must be static.
[...]
Fixed all the stuff
Quoted 18 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c line 46
Quoted 2 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +2
-0+/* Lowlevel init isn't used on i.MX28, so just have a dummy here */ +inline void lowlevel_init (void ) {}Ok.
Quoted 13 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +13
-0+ +void reset_cpu (ulong ignored) __attribute__((noreturn)); + +void reset_cpu (ulong ignored) +{ +struct mx28_clkctrl_regs *clkctrl_regs = + (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE ; +struct mx28_power_regs *power_regs = + (struct mx28_power_regs *)MXS_POWER_BASE ; + +writel (0 , &power_regs->hw_power_charge); +writel (0 , &power_regs->hw_power_minpwr); +writel (CLKCTRL_RESET_DIG , &clkctrl_regs->hw_clkctrl_reset);
Quoted 8 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c line 63
Quoted 4 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c new file +4
-0+ +/* Endless loop, reset will exit from here */ +for (;;) + ;To understand: does a reset mean on the i.MX28 a power off ? Do you turn off the power ? If this is the case, some features are not possible (as PRAM, for example) on this SOC.
This should just reset the chip. No poweroff.
[...]
Quoted 34 lines
Quoted 14 lines
arch/arm/cpu/arm926ejs/mx28/timer.c new file +13
-0+ulong get_timer (ulong base) +{ +struct mx28_timrot_regs *timrot_regs = + (struct mx28_timrot_regs *)MXS_TIMROT_BASE ; + +/* Current tick value */ +uint32_t now =readl (&timrot_regs->hw_timrot_running_count0); + +if (lastdec >= now) { +/* +* normal mode (non roll) +* move stamp forward with absolut diff ticks +*/ arch/arm/cpu/arm926ejs/mx28/timer.c line 109
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/timer.c new file +10
-0+ timestamp += (lastdec - now); + }else { +/* we have rollover of decrementer */ + timestamp += (TIMER_LOAD_VAL - now) + lastdec; + + } + lastdec = now; + +return tick_to_time (timestamp) - base; +}Not sure, but it seems to me this implementation does not follow the last changes to this kind of interface. We should implement
get_timer_masked(), but thenget_timeris simply:ulong
get_timer(ulong base){ return get_timer_masked() - base; }
Quoted 6 lines
as I see in most SOC. However, Heiko (in CC) knows more deeply this stuff as me, and he can better explain us if this implementation is correct.
I know that other i.MX are look like your implementation, but they are quite old...
I'll probably wait for someone to clearly say how this should be to avoid reworking it for the fourth time.
[...]
Quoted 2 lines
Best regards,
Stefano Babic
Cheers
PATCH 1/31 iMX28: Initial support for iMX28 CPU
Quoted 9 lines · Marek Vasut
Quoted 6 lines
Another general remark here: we tend to have the same structure and the same files for all IMX SOC. This means that all IMX SOC have a
imx-regs.hthat contain the required register definitions (really a subset what we have in kernel). Is it really necessary to split the definitions in several small files ?Just like Heiko said ... it'd produce terribly big and messy file. I'd prefer to avoid that.
This is ok, and it is ok also that your imx-regs.h file contains only the reg-specific include files. What is not ok, is that you do not use imx-regs.h and you still includes each separate file. And as I see, they must be included in a specific order.
This order must be defined only in imx-regs.h, as you have already done and then each driver/board requires to include only imx-regs.h, without having to care of the single files.
Quoted 2 lines
Honestly, I need to check if the file is used at all. We replaced the original driver with pl011 driver.
Ok
Quoted 7 lines
Quoted 4 lines
Again, regarding file splitting for register. If you prefer to have several files, I think it is better that
imx-regs.hinclude them. Then we have still a common headerimx-regs.hthat contains all needed register definitions. This is a better interface for a board maintainer.Won't it make the compiler slower at compile time if it has to go through all of the included files instead of a subset ?
Well, I do not know if on our Intel-PC this makes a so noticeable difference ;-)
What I remark here, it is to have a clear and identical interface among the several SOCs. This is not only easier for board developers, but also removes some nasty #ifdef CONFIG_MX from the drivers.
Quoted 6 lines
Quoted 4 lines
To understand: does a reset mean on the i.MX28 a power off ? Do you turn off the power ? If this is the case, some features are not possible (as PRAM, for example) on this SOC.
This should just reset the chip. No poweroff.
Ok - thanks for clarification.
Quoted 3 lines
I'll probably wait for someone to clearly say how this should be to avoid reworking it for the fourth time.
Right.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 1/31 iMX28: Initial support for iMX28 CPU
Quoted 7 lines · Stefano Babic
Quoted 6 lines · Marek Vasut
Quoted 5 lines
Another general remark here: we tend to have the same structure and the same files for all IMX SOC. This means that all IMX SOC have a
imx-regs.hthat contain the required register definitions (really a subset what we have in kernel). Is it really necessary to split the definitions in several small files ?
Quoted 7 lines
Quoted 2 lines
Just like Heiko said ... it'd produce terribly big and messy file. I'd prefer to avoid that.
This is ok, and it is ok also that your
imx-regs.hfile contains only the reg-specific include files. What is not ok, is that you do not useimx-regs.hand you still includes each separate file. And as I see, they must be included in a specific order.
I patched the reg definition files. This should be solved.
Quoted 4 lines
This order must be defined only in
imx-regs.h, as you have already done and then each driver/board requires to include onlyimx-regs.h, without having to care of the single files.
Ok
Quoted 11 lines
Quoted 3 lines
Honestly, I need to check if the file is used at all. We replaced the original driver with pl011 driver.
Ok
Quoted 5 lines
Quoted 4 lines
Again, regarding file splitting for register. If you prefer to have several files, I think it is better that
imx-regs.hinclude them. Then we have still a common headerimx-regs.hthat contains all needed register definitions. This is a better interface for a board maintainer.
Quoted 5 lines
Quoted 2 lines
Won't it make the compiler slower at compile time if it has to go through all of the included files instead of a subset ?
Well, I do not know if on our Intel-PC this makes a so noticeable difference ;-)
It's a point-of-view question, really. But what about people compiling stuff on slower machines ?
Quoted 4 lines
What I remark here, it is to have a clear and identical interface among the several SOCs. This is not only easier for board developers, but also removes some nasty #ifdef
CONFIG_MXfrom the drivers.
Yes, I understand. btw there's no CONFIG_MX stuff.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
To understand: does a reset mean on the i.MX28 a power off ? Do you turn off the power ? If this is the case, some features are not possible (as PRAM, for example) on this SOC.
This should just reset the chip. No poweroff.
Ok - thanks for clarification.
Quoted 7 lines
Quoted 2 lines
I'll probably wait for someone to clearly say how this should be to avoid reworking it for the fourth time.
Right.
Best regards,
Stefano Babic
Cheers
PATCH 1/31 iMX28: Initial support for iMX28 CPU
Quoted 6 lines · Marek Vasut
Quoted 3 lines
Well, I do not know if on our Intel-PC this makes a so noticeable difference ;-)
It's a point-of-view question, really. But what about people compiling stuff on slower machines ?
Yes, it is a point of view, and surely, compilation time is a drawback.
However, if I compare the advantages between clear interface and compilation time, I choose the first one.
Quoted 5 lines
Quoted 3 lines
What I remark here, it is to have a clear and identical interface among the several SOCs. This is not only easier for board developers, but also removes some nasty #ifdef
CONFIG_MXfrom the drivers.Yes, I understand. btw there's no
CONFIG_MXstuff.
Not yet, but only because you are adding a new SOC without using IMX drivers. Things will be changed when the MX23 will be added. Or some newer SOC of the mxs family will be added by Freescale.
Once we had only the MX31. Drivers were done only for this SOC. After using the same driver with different SOCs, a lot of CONFIG_MX was added, and most of code was really not readable - and it tooks time to remove most of them.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 2/31 iMX28: Add basic support for DENX M28EVK board
In reply to Marek VasutThis contains support for booting the board and output via DUART.
--- MAINTAINERS | 1 + board/denx/m28evk/Makefile | 49 ++++++++++++++++++++ board/denx/m28evk/m28evk.c | 69 ++++++++++++++++++++++++++++ boards.cfg | 1 + include/configs/m28evk.h | 108 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 228 insertions(+), 0 deletions(-) create mode 100644 board/denx/m28evk/Makefile create mode 100644 board/denx/m28evk/m28evk.c create mode 100644 include/configs/m28evk.h
MAINTAINERS +1 -0
@@ -847,6 +847,7 @@ Marek Vasut <[email protected]> palmtc xscale/pxa vpac270 xscale/pxa zipitz2 xscale/pxa + m28evk i.MX28 efikamx i.MX51 Hugo Villeneuve <[email protected]>
board/denx/m28evk/Makefile new file +49 -0
49 lines not on this page · raw message
board/denx/m28evk/m28evk.c new file +69 -0
69 lines not on this page · raw message
boards.cfg +1 -0
@@ -147,6 +147,7 @@ jadecpu arm arm926ejs jadecpu syteco zmx25 arm arm926ejs zmx25 syteco mx25 imx27lite arm arm926ejs imx27lite logicpd mx27 magnesium arm arm926ejs imx27lite logicpd mx27 +m28evk arm arm926ejs - denx mx28 nhk8815 arm arm926ejs nhk8815 st nomadik nhk8815_onenand arm arm926ejs nhk8815 st nomadik nhk8815:BOOT_ONENAND omap5912osk arm arm926ejs - ti omap
include/configs/m28evk.h new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 2/31 iMX28: Add basic support for DENX M28EVK board
Quoted 7 lines · Marek Vasut
This contains support for booting the board and output via DUART.
Signed-off-by Marek Vasut<[email protected]>Cc Stefano Babic<[email protected]>Cc Wolfgang Denk<[email protected]>Cc Detlev Zundel<[email protected]>---
[...]
Quoted 5 lines
board/denx/m28evk/m28evk.c new file +0
-0
[...]
board/denx/m28evk/m28evk.c line 57
Quoted 5 lines
board/denx/m28evk/m28evk.c new file +5
-0+ +int board_init (void ) +{ +/* Will change it for MX28 EVK later */ + gd->bd->bi_arch_number =CONFIG_M28_MACHID ;
This should be done in the board config file.
Please, see the CONFIG_MACH_TYPE in the U-Boot documentation (README file).
board/denx/m28evk/m28evk.c line 62
Quoted 5 lines
board/denx/m28evk/m28evk.c new file +5
-0+/* Adress of boot parameters */ + gd->bd->bi_boot_params =PHYS_SDRAM_1 +0x100 ; + +return 0 ; +}
[...]
--
Regards,
Igor.
PATCH 2/31 iMX28: Add basic support for DENX M28EVK board
In reply to Marek VasutQuoted 45 lines · Marek Vasut
This contains support for booting the board and output via DUART.
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
board/denx/m28evk/m28evk.c new file +32
-0@@ -0,0 +1,69 @@ +/* +* DENX M28 module +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/clock.h> +#include <asm/arch/mx28.h>
board/denx/m28evk/m28evk.c line 42
Quoted 10 lines
board/denx/m28evk/m28evk.c new file +10
-0+ +DECLARE_GLOBAL_DATA_PTR ; + +/* +* Functions +*/ +int board_early_init_f (void ) +{ +/* IO0 clock at 480MHz */ +mx28_set_ioclk (0 ,480000 );
See comment in previous patch: first argument is only GATE0 or GATE1, add enum.
board/denx/m28evk/m28evk.c line 57
Quoted 4 lines
board/denx/m28evk/m28evk.c new file +4
-0+int board_init (void ) +{ +/* Will change it for MX28 EVK later */ + gd->bd->bi_arch_number =CONFIG_M28_MACHID ;
We have recently a new standard here, and the MACH ID is set into the config file.
Quoted 104 lines
include/configs/m28evk.h new file +98
-0@@ -0,0 +1,108 @@ +/* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 __M28_H__ +#define __M28_H__ + +#include <asm/arch/regs-base.h> + +/* +* SoC configurations +*/ +#define CONFIG_MX28 /* i.MX28 SoC */ +#define CONFIG_MX28_TO1_2 +#define CONFIG_SYS_HZ 1000/* Ticks per second */ + +#define CONFIG_M28_MACHID MACH_TYPE_M28EVK + +#define CONFIG_SYS_NO_FLASH +#define CONFIG_SYS_ICACHE_OFF +#define CONFIG_SYS_DCACHE_OFF +#define CONFIG_BOARD_EARLY_INIT_F + +/* +* U-Boot Commands +*/ +#include <config_cmd_default.h> +#define CONFIG_DISPLAY_CPUINFO +#define CONFIG_CMD_CACHE +#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_NET +#undef CONFIG_CMD_NFS +#undef CONFIG_CMD_PING +#define CONFIG_CMD_SETEXPR + +/* +* Memory configurations +*/ +#define CONFIG_NR_DRAM_BANKS 1/* 2 banks of DRAM */ +#define PHYS_SDRAM_1 0x40000000/* Base address */ +#define PHYS_SDRAM_1_SIZE 0x10000000/* 256 MB */ +#define CONFIG_STACKSIZE 0x00010000/* 128 KB stack */ +#define CONFIG_SYS_MALLOC_LEN 0x00400000/* 4 MB for malloc */ +#define CONFIG_SYS_GBL_DATA_SIZE 128/* Initial data */ +#define CONFIG_SYS_MEMTEST_START 0x40000000/* Memtest start adr */ +#define CONFIG_SYS_MEMTEST_END 0x40400000/* 4 MB RAM test */ +#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 +#define CONFIG_SYS_INIT_SP_ADDR 0x18000 +#define CONFIG_SYS_TEXT_BASE 0x40000000 + +/* +* U-Boot general configurations +*/ +#define CONFIG_SYS_LONGHELP +#define CONFIG_SYS_PROMPT "=> " +#define CONFIG_SYS_CBSIZE 1024/* Console I/O buffer size */ +#define CONFIG_SYS_PBSIZE \ + (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16) +/* Print buffer size */ +#define CONFIG_SYS_MAXARGS 32/* Max number of command args */ +#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE +/* Boot argument buffer size */ +#define CONFIG_VERSION_VARIABLE /* U-BOOT version */ +#define CONFIG_AUTO_COMPLETE /* Command auto complete */ +#define CONFIG_CMDLINE_EDITING /* Command history etc */ +#define CONFIG_SYS_HUSH_PARSER +#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " + +/* +* Serial Driver +*/ +#define CONFIG_PL011_SERIAL +#define CONFIG_PL011_CLOCK 24000000 +#define CONFIG_PL01x_PORTS { (void *)MXS_UARTDBG_BASE } +#define CONFIG_CONS_INDEX 0 +#define CONFIG_BAUDRATE 115200/* Default baud rate */ +#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } + +/* +* Boot Linux +*/ +#define CONFIG_CMDLINE_TAG +#define CONFIG_SETUP_MEMORY_TAGS
include/configs/m28evk.h line 108
Quoted 10 lines
include/configs/m28evk.h new file +10
-0+#define CONFIG_BOOTDELAY 3 +#define CONFIG_BOOTFILE "uImage" +#define CONFIG_BOOTARGS "console=ttyAM0,115200n8 " +#define CONFIG_BOOTCOMMAND "run bootcmd_net" +#define CONFIG_LOADADDR 0x42000000 +#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR + +#define CONFIG_ENV_IS_NOWHERE 1 + +#endif /* __M28_H__ */
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 3/31 iMX28: Add support for SSP MMC
In reply to Marek Vasut--- arch/arm/include/asm/arch-mx28/mx28.h | 2 + drivers/mmc/Makefile | 1 + drivers/mmc/mxsmmc.c | 354 +++++++++++++++++++++++++++++++++ 3 files changed, 357 insertions(+), 0 deletions(-) create mode 100644 drivers/mmc/mxsmmc.c
arch/arm/include/asm/arch-mx28/mx28.h +2 -0
@@ -27,4 +27,6 @@ int mx28_reset_block(struct mx28_register *reg);int mx28_wait_mask_set (struct mx28_register *reg,uint32_t mask,int timeout);int mx28_wait_mask_clr (struct mx28_register *reg,uint32_t mask,int timeout); +int mxsmmc_initialize (bd_t *bis,int id,int (*wp)(int )); +#endif /* __MX28_H__ */
drivers/mmc/Makefile +1 -0
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_MMC_SPI) += mmc_spi.o COBJS-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o COBJS-$(CONFIG_MV_SDHCI) += mv_sdhci.o COBJS-$(CONFIG_MXC_MMC) += mxcmmc.o +COBJS-$(CONFIG_MXS_MMC) += mxsmmc.o COBJS-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o COBJS-$(CONFIG_PXA_MMC) += pxa_mmc.o COBJS-$(CONFIG_S5P_MMC) += s5p_mmc.o
drivers/mmc/mxsmmc.c new file +354 -0
354 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 4/31 M28EVK: Enable MMC support
In reply to Marek Vasut--- board/denx/m28evk/m28evk.c | 22 ++++++++++++++++++++++ include/configs/m28evk.h | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-)
board/denx/m28evk/m28evk.c +22 -0
@@ -28,6 +28,8 @@#include <asm/arch/regs-common.h> #include <asm/arch/regs-base.h> #include <asm/arch/regs-clkctrl.h> +#include <asm/arch/iomux-mx28.h> +#include <asm/arch/gpio.h> #include <asm/arch/clock.h> #include <asm/arch/mx28.h>
@@ -67,3 +69,23 @@ int dram_init(void) gd->ram_size =get_ram_size ((long *)PHYS_SDRAM_1 ,PHYS_SDRAM_1_SIZE );return 0 ; } + +#ifdef CONFIG_CMD_MMC +static int m28_mmc_wp (int id) +{ +if (id !=0 ) { +printf ("MXS MMC: Invalid card selected (card id = %d)\n" , id); +return 1 ; + } + +return mxs_gpio_get (MX28_PAD_AUART2_CTS__GPIO_3_10 ); +} + +int board_mmc_init (bd_t *bis) +{ +/* Configure WP as output */ +mxs_gpio_direction (MX28_PAD_AUART2_CTS__GPIO_3_10 ,0 ); + +return mxsmmc_initialize (bis,0 , m28_mmc_wp); +} +#endif
include/configs/m28evk.h +14 -0
@@ -41,7 +41,12 @@*/ #include <config_cmd_default.h> #define CONFIG_DISPLAY_CPUINFO +#define CONFIG_DOS_PARTITION +#define CONFIG_CMD_CACHE +#define CONFIG_CMD_EXT2 +#define CONFIG_CMD_FAT +#define CONFIG_CMD_MMC #undef CONFIG_CMD_DHCP#undef CONFIG_CMD_NET#undef CONFIG_CMD_NFS
@@ -92,6 +97,15 @@#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }/* +* MMC Driver +*/ +#ifdef CONFIG_CMD_MMC +#define CONFIG_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_MXS_MMC +#endif + +/* * Boot Linux */ #define CONFIG_CMDLINE_TAG
Signature · 1 line
1.7.5.4
PATCH 4/31 M28EVK: Enable MMC support
Quoted 9 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Andy Fleming <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- board/denx/m28evk/m28evk.c | 22 ++++++++++++++++++++++ include/configs/m28evk.h | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-)
This is a new code. Please squash your patches regarding m28evk, so that we can review the m28evk easier.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 5/31 iMX28: Add pinctrl and ocotp register definitions
In reply to Marek Vasut--- arch/arm/include/asm/arch-mx28/regs-ocotp.h | 169 ++++ arch/arm/include/asm/arch-mx28/regs-pinctrl.h | 1280 +++++++++++++++++++++++++ 2 files changed, 1449 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-mx28/regs-ocotp.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-pinctrl.h
arch/arm/include/asm/arch-mx28/regs-ocotp.h new file +169 -0
@@ -0,0 +1,169 @@ +/* +* Freescale i.MX28 OCOTP Register Definitions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* Based on code from LTIB: +* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* 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 __REGS_OCOTP_H__ +#define __REGS_OCOTP_H__ + +struct mx28_ocotp_regs { + mx28_reg(hw_ocotp_ctrl) /* 0x0 */ + mx28_reg(hw_ocotp_data) /* 0x10 */ + mx28_reg(hw_ocotp_cust0) /* 0x20 */ + mx28_reg(hw_ocotp_cust1) /* 0x30 */ + mx28_reg(hw_ocotp_cust2) /* 0x40 */ + mx28_reg(hw_ocotp_cust3) /* 0x50 */ + mx28_reg(hw_ocotp_crypto0) /* 0x60 */ + mx28_reg(hw_ocotp_crypto1) /* 0x70 */ + mx28_reg(hw_ocotp_crypto2) /* 0x80 */ + mx28_reg(hw_ocotp_crypto3) /* 0x90 */ + mx28_reg(hw_ocotp_hwcap0) /* 0xa0 */ + mx28_reg(hw_ocotp_hwcap1) /* 0xb0 */ + mx28_reg(hw_ocotp_hwcap2) /* 0xc0 */ + mx28_reg(hw_ocotp_hwcap3) /* 0xd0 */ + mx28_reg(hw_ocotp_hwcap4) /* 0xe0 */ + mx28_reg(hw_ocotp_hwcap5) /* 0xf0 */ + mx28_reg(hw_ocotp_swcap) /* 0x100 */ + mx28_reg(hw_ocotp_custcap) /* 0x110 */ + mx28_reg(hw_ocotp_lock) /* 0x120 */ + mx28_reg(hw_ocotp_ops0) /* 0x130 */ + mx28_reg(hw_ocotp_ops1) /* 0x140 */ + mx28_reg(hw_ocotp_ops2) /* 0x150 */ + mx28_reg(hw_ocotp_ops3) /* 0x160 */ + mx28_reg(hw_ocotp_un0) /* 0x170 */ + mx28_reg(hw_ocotp_un1) /* 0x180 */ + mx28_reg(hw_ocotp_un2) /* 0x190 */ + mx28_reg(hw_ocotp_rom0) /* 0x1a0 */ + mx28_reg(hw_ocotp_rom1) /* 0x1b0 */ + mx28_reg(hw_ocotp_rom2) /* 0x1c0 */ + mx28_reg(hw_ocotp_rom3) /* 0x1d0 */ + mx28_reg(hw_ocotp_rom4) /* 0x1e0 */ + mx28_reg(hw_ocotp_rom5) /* 0x1f0 */ + mx28_reg(hw_ocotp_rom6) /* 0x200 */ + mx28_reg(hw_ocotp_rom7) /* 0x210 */ + mx28_reg(hw_ocotp_srk0) /* 0x220 */ + mx28_reg(hw_ocotp_srk1) /* 0x230 */ + mx28_reg(hw_ocotp_srk2) /* 0x240 */ + mx28_reg(hw_ocotp_srk3) /* 0x250 */ + mx28_reg(hw_ocotp_srk4) /* 0x260 */ + mx28_reg(hw_ocotp_srk5) /* 0x270 */ + mx28_reg(hw_ocotp_srk6) /* 0x280 */ + mx28_reg(hw_ocotp_srk7) /* 0x290 */ + mx28_reg(hw_ocotp_version) /* 0x2a0 */ +}; + +#define OCOTP_CTRL_WR_UNLOCK_MASK (0xffff << 16) +#define OCOTP_CTRL_WR_UNLOCK_OFFSET 16 +#define OCOTP_CTRL_WR_UNLOCK_KEY (0x3e77 << 16) +#define OCOTP_CTRL_RELOAD_SHADOWS (1 << 13) +#define OCOTP_CTRL_RD_BANK_OPEN (1 << 12) +#define OCOTP_CTRL_ERROR (1 << 9) +#define OCOTP_CTRL_BUSY (1 << 8) +#define OCOTP_CTRL_ADDR_MASK 0x3f +#define OCOTP_CTRL_ADDR_OFFSET 0 + +#define OCOTP_DATA_DATA_MASK 0xffffffff +#define OCOTP_DATA_DATA_OFFSET 0 + +#define OCOTP_CUST_BITS_MASK 0xffffffff +#define OCOTP_CUST_BITS_OFFSET 0 + +#define OCOTP_CRYPTO_BITS_MASK 0xffffffff +#define OCOTP_CRYPTO_BITS_OFFSET 0 + +#define OCOTP_HWCAP_BITS_MASK 0xffffffff +#define OCOTP_HWCAP_BITS_OFFSET 0 + +#define OCOTP_SWCAP_BITS_MASK 0xffffffff +#define OCOTP_SWCAP_BITS_OFFSET 0 + +#define OCOTP_CUSTCAP_RTC_XTAL_32768_PRESENT (1 << 2) +#define OCOTP_CUSTCAP_RTC_XTAL_32000_PRESENT (1 << 1) + +#define OCOTP_LOCK_ROM7 (1 << 31) +#define OCOTP_LOCK_ROM6 (1 << 30) +#define OCOTP_LOCK_ROM5 (1 << 29) +#define OCOTP_LOCK_ROM4 (1 << 28) +#define OCOTP_LOCK_ROM3 (1 << 27) +#define OCOTP_LOCK_ROM2 (1 << 26) +#define OCOTP_LOCK_ROM1 (1 << 25) +#define OCOTP_LOCK_ROM0 (1 << 24) +#define OCOTP_LOCK_HWSW_SHADOW_ALT (1 << 23) +#define OCOTP_LOCK_CRYPTODCP_ALT (1 << 22) +#define OCOTP_LOCK_CRYPTOKEY_ALT (1 << 21) +#define OCOTP_LOCK_PIN (1 << 20) +#define OCOTP_LOCK_OPS (1 << 19) +#define OCOTP_LOCK_UN2 (1 << 18) +#define OCOTP_LOCK_UN1 (1 << 17) +#define OCOTP_LOCK_UN0 (1 << 16) +#define OCOTP_LOCK_SRK (1 << 15) +#define OCOTP_LOCK_UNALLOCATED_MASK (0x7 << 12) +#define OCOTP_LOCK_UNALLOCATED_OFFSET 12 +#define OCOTP_LOCK_SRK_SHADOW (1 << 11) +#define OCOTP_LOCK_ROM_SHADOW (1 << 10) +#define OCOTP_LOCK_CUSTCAP (1 << 9) +#define OCOTP_LOCK_HWSW (1 << 8) +#define OCOTP_LOCK_CUSTCAP_SHADOW (1 << 7) +#define OCOTP_LOCK_HWSW_SHADOW (1 << 6) +#define OCOTP_LOCK_CRYPTODCP (1 << 5) +#define OCOTP_LOCK_CRYPTOKEY (1 << 4) +#define OCOTP_LOCK_CUST3 (1 << 3) +#define OCOTP_LOCK_CUST2 (1 << 2) +#define OCOTP_LOCK_CUST1 (1 << 1) +#define OCOTP_LOCK_CUST0 (1 << 0) + +#define OCOTP_OPS_BITS_MASK 0xffffffff +#define OCOTP_OPS_BITS_OFFSET 0 + +#define OCOTP_UN_BITS_MASK 0xffffffff +#define OCOTP_UN_BITS_OFFSET 0 + +#define OCOTP_ROM_BOOT_MODE_MASK (0xff << 24) +#define OCOTP_ROM_BOOT_MODE_OFFSET 24 +#define OCOTP_ROM_SD_MMC_MODE_MASK (0x3 << 22) +#define OCOTP_ROM_SD_MMC_MODE_OFFSET 22 +#define OCOTP_ROM_SD_POWER_GATE_GPIO_MASK (0x3 << 20) +#define OCOTP_ROM_SD_POWER_GATE_GPIO_OFFSET 20 +#define OCOTP_ROM_SD_POWER_UP_DELAY_MASK (0x3f << 14) +#define OCOTP_ROM_SD_POWER_UP_DELAY_OFFSET 14 +#define OCOTP_ROM_SD_BUS_WIDTH_MASK (0x3 << 12) +#define OCOTP_ROM_SD_BUS_WIDTH_OFFSET 12 +#define OCOTP_ROM_SSP_SCK_INDEX_MASK (0xf << 8) +#define OCOTP_ROM_SSP_SCK_INDEX_OFFSET 8 +#define OCOTP_ROM_EMMC_USE_DDR (1 << 7) +#define OCOTP_ROM_DISABLE_SPI_NOR_FAST_READ (1 << 6) +#define OCOTP_ROM_ENABLE_USB_BOOT_SERIAL_NUM (1 << 5) +#define OCOTP_ROM_ENABLE_UNENCRYPTED_BOOT (1 << 4) +#define OCOTP_ROM_SD_MBR_BOOT (1 << 3) + +#define OCOTP_SRK_BITS_MASK 0xffffffff +#define OCOTP_SRK_BITS_OFFSET 0 + +#define OCOTP_VERSION_MAJOR_MASK (0xff << 24) +#define OCOTP_VERSION_MAJOR_OFFSET 24 +#define OCOTP_VERSION_MINOR_MASK (0xff << 16) +#define OCOTP_VERSION_MINOR_OFFSET 16 +#define OCOTP_VERSION_STEP_MASK 0xffff +#define OCOTP_VERSION_STEP_OFFSET 0 + +#endif /* __REGS_OCOTP_H__ */
arch/arm/include/asm/arch-mx28/regs-pinctrl.h new file +1280 -0
1,280 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 5/31 iMX28: Add pinctrl and ocotp register definitions
Quoted 5 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
Hi Marek,
Quoted 6 lines
arch/arm/include/asm/arch-mx28/regs-ocotp.h | 169 ++++ arch/arm/include/asm/arch-mx28/regs-pinctrl.h | 1280 +++++++++++++++++++++++++ 2 files changed, 1449 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-mx28/regs-ocotp.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-pinctrl.h
This should be part of patch1/31, is not ?
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 6/31 FEC: Add support for iMX28 quirks
In reply to Marek Vasut--- drivers/net/fec_mxc.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 42 insertions(+), 2 deletions(-)
drivers/net/fec_mxc.c +42 -2
@@ -42,6 +42,14 @@ DECLARE_GLOBAL_DATA_PTR;#define CONFIG_FEC_XCV_TYPE MII100#endif +/* +* The i.MX28 operates with packets in big endian. We need to swap them before +* sending and after receiving. +*/ +#ifdef CONFIG_MX28 +#define CONFIG_FEC_MXC_SWAP_PACKET +#endif +#undef DEBUGstruct nbuf {
@@ -51,6 +59,32 @@ struct nbuf {uint8_t head[16 ];/**< MAC header(6 + 6 + 2) + 2(aligned) */ }; +#ifdef CONFIG_FEC_MXC_SWAP_PACKET +static void swap_packet (uint32_t *packet,int length) +{ +int i; + +for (i =0 ; i <DIV_ROUND_UP (length,4 ); i++) + packet[i] =__swab32 (packet[i]); +} +#endif + +/* +* The i.MX28 has two ethernet interfaces, but they are not equal. +* Only the first one can access the MDIO bus. +*/ +#ifdef CONFIG_MX28 +static inline struct ethernet_regs *fec_miiphy_fec_to_eth (struct fec_priv *fec) +{ +return (struct ethernet_regs *)MXS_ENET0_BASE ; +} +#else +static inline struct ethernet_regs *fec_miiphy_fec_to_eth (struct fec_priv *fec) +{ +return fec->eth; +} +#endif +/* * MII-interface related functions */
@@ -59,7 +93,7 @@ static int fec_miiphy_read(const char *dev, uint8_t phyAddr, uint8_t regAddr, {struct eth_device *edev =eth_get_dev_by_name (dev);struct fec_priv *fec = (struct fec_priv *)edev->priv; -struct ethernet_regs *eth = fec->eth; +struct ethernet_regs *eth =fec_miiphy_fec_to_eth (fec);uint32_t reg;/* convenient holder for the PHY register */ uint32_t phy;/* convenient holder for the PHY */
@@ -117,7 +151,7 @@ static int fec_miiphy_write(const char *dev, uint8_t phyAddr, uint8_t regAddr, {struct eth_device *edev =eth_get_dev_by_name (dev);struct fec_priv *fec = (struct fec_priv *)edev->priv; -struct ethernet_regs *eth = fec->eth; +struct ethernet_regs *eth =fec_miiphy_fec_to_eth (fec);uint32_t reg;/* convenient holder for the PHY register */ uint32_t phy;/* convenient holder for the PHY */
@@ -572,6 +606,9 @@ static int fec_send(struct eth_device *dev, volatile void* packet, int length)* Note: We are always using the first buffer for transmission, * the second will be empty and only used to stop the DMA engine */ +#ifdef CONFIG_FEC_MXC_SWAP_PACKET +swap_packet ((uint32_t *)packet, length); +#endif writew (length, &fec->tbd_base[fec->tbd_index].data_length);writel ((uint32_t )packet, &fec->tbd_base[fec->tbd_index].data_pointer);/*
@@ -668,6 +705,9 @@ static int fec_recv(struct eth_device *dev)/* * Fill the buffer and pass it to upper layers */ +#ifdef CONFIG_FEC_MXC_SWAP_PACKET +swap_packet ((uint32_t *)frame->data, frame_length); +#endif memcpy (buff, frame->data, frame_length);NetReceive (buff, frame_length); len = frame_length;
Signature · 1 line
1.7.5.4
PATCH 7/31 iMX28: Add CPU-specific FEC ethernet init
In reply to Marek Vasut--- arch/arm/cpu/arm926ejs/mx28/mx28.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
arch/arm/cpu/arm926ejs/mx28/mx28.c +31 -0
@@ -129,3 +129,34 @@ int print_cpuinfo(void) return 0; }#endif + +/* +* Initializes on-chip ethernet controllers. +*/ +#ifdef CONFIG_CMD_NET +int cpu_eth_init (bd_t *bis) +{ +struct mx28_clkctrl_regs *clkctrl_regs = + (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE ; + +/* Turn on ENET clocks */ +clrbits_le32 (&clkctrl_regs->hw_clkctrl_enet, +CLKCTRL_ENET_SLEEP |CLKCTRL_ENET_DISABLE ); + +/* Set up ENET PLL for 50 MHz */ +/* Power on ENET PLL */ +writel (CLKCTRL_PLL2CTRL0_POWER , + &clkctrl_regs->hw_clkctrl_pll2ctrl0_set); + +udelay (10 ); + +/* Gate on ENET PLL */ +writel (CLKCTRL_PLL2CTRL0_CLKGATE , + &clkctrl_regs->hw_clkctrl_pll2ctrl0_clr); + +/* Enable pad output */ +setbits_le32 (&clkctrl_regs->hw_clkctrl_enet,CLKCTRL_ENET_CLK_OUT_EN ); + +return 0 ; +} +#endif
Signature · 1 line
1.7.5.4
PATCH 8/31 M28EVK: Enable FEC0 and FEC1
In reply to Marek Vasut--- board/denx/m28evk/m28evk.c | 109 ++++++++++++++++++++++++++++++++++++++++++++ include/configs/m28evk.h | 22 +++++++-- 2 files changed, 127 insertions(+), 4 deletions(-)
board/denx/m28evk/m28evk.c +109 -0
@@ -28,10 +28,15 @@#include <asm/arch/regs-common.h> #include <asm/arch/regs-base.h> #include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-ocotp.h> #include <asm/arch/iomux-mx28.h> #include <asm/arch/gpio.h> #include <asm/arch/clock.h> #include <asm/arch/mx28.h> +#include <linux/mii.h> +#include <miiphy.h> +#include <netdev.h> +#include <errno.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -89,3 +94,107 @@ int board_mmc_init(bd_t *bis)return mxsmmc_initialize (bis,0 , m28_mmc_wp); }#endif + +#ifdef CONFIG_CMD_NET + +#define MII_OPMODE_STRAP_OVERRIDE 0x16 +#define MII_PHY_CTRL1 0x1e +#define MII_PHY_CTRL2 0x1f + +int fecmxc_mii_postcall (int phy) +{ +miiphy_write ("FEC1" , phy,MII_BMCR ,0x9000 ); +miiphy_write ("FEC1" , phy,MII_OPMODE_STRAP_OVERRIDE ,0x0202 ); +if (phy ==3 ) +miiphy_write ("FEC1" ,3 ,MII_PHY_CTRL2 ,0x8180 ); +return 0 ; +} + +int board_eth_init (bd_t *bis) +{ +struct mx28_clkctrl_regs *clkctrl_regs = + (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE ; +struct eth_device *dev; +int ret; + + ret =cpu_eth_init (bis); + +clrsetbits_le32 (&clkctrl_regs->hw_clkctrl_enet, +CLKCTRL_ENET_TIME_SEL_MASK |CLKCTRL_ENET_CLK_OUT_EN , +CLKCTRL_ENET_TIME_SEL_RMII_CLK ); + + ret =fecmxc_initialize_multi (bis,0 ,0 ,MXS_ENET0_BASE ); +if (ret) { +printf ("FEC MXS: Unable to init FEC0\n" ); +return ret; + } + + ret =fecmxc_initialize_multi (bis,1 ,3 ,MXS_ENET1_BASE ); +if (ret) { +printf ("FEC MXS: Unable to init FEC1\n" ); +return ret; + } + + dev =eth_get_dev_by_name ("FEC0" ); +if (!dev) { +printf ("FEC MXS: Unable to get FEC0 device entry\n" ); +return -EINVAL ; + } + + ret =fecmxc_register_mii_postcall (dev, fecmxc_mii_postcall); +if (ret) { +printf ("FEC MXS: Unable to register FEC0 mii postcall\n" ); +return ret; + } + + dev =eth_get_dev_by_name ("FEC1" ); +if (!dev) { +printf ("FEC MXS: Unable to get FEC1 device entry\n" ); +return -EINVAL ; + } + + ret =fecmxc_register_mii_postcall (dev, fecmxc_mii_postcall); +if (ret) { +printf ("FEC MXS: Unable to register FEC1 mii postcall\n" ); +return ret; + } + +return ret; +} + +#ifdef CONFIG_M28_FEC_MAC_IN_OCOTP + +#define MXS_OCOTP_MAX_TIMEOUT 1000000 +void imx_get_mac_from_fuse (char *mac) +{ +struct mx28_ocotp_regs *ocotp_regs = + (struct mx28_ocotp_regs *)MXS_OCOTP_BASE ; +uint32_t data; + +memset (mac,0 ,6 ); + +writel (OCOTP_CTRL_RD_BANK_OPEN , &ocotp_regs->hw_ocotp_ctrl_set); + +if (mx28_wait_mask_clr (&ocotp_regs->hw_ocotp_ctrl_reg,OCOTP_CTRL_BUSY , +MXS_OCOTP_MAX_TIMEOUT )) { +printf ("MXS FEC: Can't get MAC from OCOTP\n" ); +return ; + } + + data =readl (&ocotp_regs->hw_ocotp_cust0); + + mac[0 ] =0x00 ; + mac[1 ] =0x04 ; + mac[2 ] = (data >>24 ) &0xff ; + mac[3 ] = (data >>16 ) &0xff ; + mac[4 ] = (data >>8 ) &0xff ; + mac[5 ] = data &0xff ; +} +#else +void imx_get_mac_from_fuse (char *mac) +{ +memset (mac,0 ,6 ); +} +#endif + +#endif
include/configs/m28evk.h +18 -4
@@ -44,13 +44,14 @@#define CONFIG_DOS_PARTITION #define CONFIG_CMD_CACHE +#define CONFIG_CMD_DHCP #define CONFIG_CMD_EXT2 #define CONFIG_CMD_FAT +#define CONFIG_CMD_MII #define CONFIG_CMD_MMC -#undef CONFIG_CMD_DHCP -#undef CONFIG_CMD_NET -#undef CONFIG_CMD_NFS -#undef CONFIG_CMD_PING +#define CONFIG_CMD_NET +#define CONFIG_CMD_NFS +#define CONFIG_CMD_PING #define CONFIG_CMD_SETEXPR /*
@@ -106,6 +107,19 @@#endif /* +* Ethernet on SOC (FEC) +*/ +#ifdef CONFIG_CMD_NET +#define CONFIG_NET_MULTI +#define CONFIG_ETHPRIME "FEC0" +#define CONFIG_FEC_MXC +#define CONFIG_FEC_MXC_MULTI +#define CONFIG_MII +#define CONFIG_DISCOVER_PHY +#define CONFIG_FEC_XCV_TYPE RMII +#endif + +/* * Boot Linux */ #define CONFIG_CMDLINE_TAG
Signature · 1 line
1.7.5.4
PATCH 9/31 iMX28: Add PINMUX control
In reply to Marek VasutTaken from Linux kernel with minor modifications:
commit bf985969e27b507f734435a99df8bf745a3dbb2b
Author: Shawn Guo <[email protected]> Date: Mon Dec 20 22:57:43 2010 +0800
ARM: mxs: Add iomux support
--- arch/arm/cpu/arm926ejs/mx28/Makefile | 2 +- arch/arm/cpu/arm926ejs/mx28/iomux.c | 111 ++++++ arch/arm/include/asm/arch-mx28/iomux-mx28.h | 537 +++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx28/iomux.h | 168 +++++++++ 4 files changed, 817 insertions(+), 1 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/mx28/iomux.c create mode 100644 arch/arm/include/asm/arch-mx28/iomux-mx28.h create mode 100644 arch/arm/include/asm/arch-mx28/iomux.h
arch/arm/cpu/arm926ejs/mx28/Makefile +1 -1
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).o -COBJS = clock.o mx28.o timer.o +COBJS = clock.o mx28.o iomux.o timer.o SRCS := $(START:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
arch/arm/cpu/arm926ejs/mx28/iomux.c new file +111 -0
111 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/iomux-mx28.h new file +537 -0
537 lines not on this page · raw message
arch/arm/include/asm/arch-mx28/iomux.h new file +168 -0
168 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 10/31 iMX28: Add RTC register definitions
In reply to Marek Vasut--- arch/arm/include/asm/arch-mx28/regs-rtc.h | 143 +++++++++++++++++++++++++++++ 1 files changed, 143 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-mx28/regs-rtc.h
arch/arm/include/asm/arch-mx28/regs-rtc.h new file +143 -0
@@ -0,0 +1,143 @@ +/* +* Freescale i.MX28 RTC Register Definitions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 __REGS_RTC_H__ +#define __REGS_RTC_H__ + +struct mx28_rtc_regs { + mx28_reg(hw_rtc_ctrl) + mx28_reg(hw_rtc_stat) + mx28_reg(hw_rtc_milliseconds) + mx28_reg(hw_rtc_seconds) + mx28_reg(hw_rtc_rtc_alarm) + mx28_reg(hw_rtc_watchdog) + mx28_reg(hw_rtc_persistent0) + mx28_reg(hw_rtc_persistent1) + mx28_reg(hw_rtc_persistent2) + mx28_reg(hw_rtc_persistent3) + mx28_reg(hw_rtc_persistent4) + mx28_reg(hw_rtc_persistent5) + mx28_reg(hw_rtc_debug) + mx28_reg(hw_rtc_version) +}; + +#define RTC_CTRL_SFTRST (1 << 31) +#define RTC_CTRL_CLKGATE (1 << 30) +#define RTC_CTRL_SUPPRESS_COPY2ANALOG (1 << 6) +#define RTC_CTRL_FORCE_UPDATE (1 << 5) +#define RTC_CTRL_WATCHDOGEN (1 << 4) +#define RTC_CTRL_ONEMSEC_IRQ (1 << 3) +#define RTC_CTRL_ALARM_IRQ (1 << 2) +#define RTC_CTRL_ONEMSEC_IRQ_EN (1 << 1) +#define RTC_CTRL_ALARM_IRQ_EN (1 << 0) + +#define RTC_STAT_RTC_PRESENT (1 << 31) +#define RTC_STAT_ALARM_PRESENT (1 << 30) +#define RTC_STAT_WATCHDOG_PRESENT (1 << 29) +#define RTC_STAT_XTAL32000_PRESENT (1 << 28) +#define RTC_STAT_XTAL32768_PRESENT (1 << 27) +#define RTC_STAT_STALE_REGS_MASK (0xff << 16) +#define RTC_STAT_STALE_REGS_OFFSET 16 +#define RTC_STAT_NEW_REGS_MASK (0xff << 8) +#define RTC_STAT_NEW_REGS_OFFSET 8 + +#define RTC_MILLISECONDS_COUNT_MASK 0xffffffff +#define RTC_MILLISECONDS_COUNT_OFFSET 0 + +#define RTC_SECONDS_COUNT_MASK 0xffffffff +#define RTC_SECONDS_COUNT_OFFSET 0 + +#define RTC_ALARM_VALUE_MASK 0xffffffff +#define RTC_ALARM_VALUE_OFFSET 0 + +#define RTC_WATCHDOG_COUNT_MASK 0xffffffff +#define RTC_WATCHDOG_COUNT_OFFSET 0 + +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_MASK (0xf << 28) +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_OFFSET 28 +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_2V83 (0x0 << 28) +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_2V78 (0x1 << 28) +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_2V73 (0x2 << 28) +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_2V68 (0x3 << 28) +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_2V62 (0x4 << 28) +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_2V57 (0x5 << 28) +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_2V52 (0x6 << 28) +#define RTC_PERSISTENT0_ADJ_POSLIMITBUCK_2V48 (0x7 << 28) +#define RTC_PERSISTENT0_EXTERNAL_RESET (1 << 21) +#define RTC_PERSISTENT0_THERMAL_RESET (1 << 20) +#define RTC_PERSISTENT0_ENABLE_LRADC_PWRUP (1 << 18) +#define RTC_PERSISTENT0_AUTO_RESTART (1 << 17) +#define RTC_PERSISTENT0_DISABLE_PSWITCH (1 << 16) +#define RTC_PERSISTENT0_LOWERBIAS_MASK (0xf << 14) +#define RTC_PERSISTENT0_LOWERBIAS_OFFSET 14 +#define RTC_PERSISTENT0_LOWERBIAS_NOMINAL (0x0 << 14) +#define RTC_PERSISTENT0_LOWERBIAS_M25P (0x1 << 14) +#define RTC_PERSISTENT0_LOWERBIAS_M50P (0x3 << 14) +#define RTC_PERSISTENT0_DISABLE_XTALOK (1 << 13) +#define RTC_PERSISTENT0_MSEC_RES_MASK (0x1f << 8) +#define RTC_PERSISTENT0_MSEC_RES_OFFSET 8 +#define RTC_PERSISTENT0_MSEC_RES_1MS (0x01 << 8) +#define RTC_PERSISTENT0_MSEC_RES_2MS (0x02 << 8) +#define RTC_PERSISTENT0_MSEC_RES_4MS (0x04 << 8) +#define RTC_PERSISTENT0_MSEC_RES_8MS (0x08 << 8) +#define RTC_PERSISTENT0_MSEC_RES_16MS (0x10 << 8) +#define RTC_PERSISTENT0_ALARM_WAKE (1 << 7) +#define RTC_PERSISTENT0_XTAL32_FREQ (1 << 6) +#define RTC_PERSISTENT0_XTAL32KHZ_PWRUP (1 << 5) +#define RTC_PERSISTENT0_XTAL24KHZ_PWRUP (1 << 4) +#define RTC_PERSISTENT0_LCK_SECS (1 << 3) +#define RTC_PERSISTENT0_ALARM_EN (1 << 2) +#define RTC_PERSISTENT0_ALARM_WAKE_EN (1 << 1) +#define RTC_PERSISTENT0_CLOCKSOURCE (1 << 0) + +#define RTC_PERSISTENT1_GENERAL_MASK 0xffffffff +#define RTC_PERSISTENT1_GENERAL_OFFSET 0 +#define RTC_PERSISTENT1_GENERAL_OTG_ALT_ROLE 0x0080 +#define RTC_PERSISTENT1_GENERAL_OTG_HNP 0x0100 +#define RTC_PERSISTENT1_GENERAL_USB_LPM 0x0200 +#define RTC_PERSISTENT1_GENERAL_SKIP_CHECKDISK 0x0400 +#define RTC_PERSISTENT1_GENERAL_USB_BOOT_PLAYER 0x0800 +#define RTC_PERSISTENT1_GENERAL_ENUM_500MA_2X 0x1000 + +#define RTC_PERSISTENT2_GENERAL_MASK 0xffffffff +#define RTC_PERSISTENT2_GENERAL_OFFSET 0 + +#define RTC_PERSISTENT3_GENERAL_MASK 0xffffffff +#define RTC_PERSISTENT3_GENERAL_OFFSET 0 + +#define RTC_PERSISTENT4_GENERAL_MASK 0xffffffff +#define RTC_PERSISTENT4_GENERAL_OFFSET 0 + +#define RTC_PERSISTENT5_GENERAL_MASK 0xffffffff +#define RTC_PERSISTENT5_GENERAL_OFFSET 0 + +#define RTC_DEBUG_WATCHDOG_RESET_MASK (1 << 1) +#define RTC_DEBUG_WATCHDOG_RESET (1 << 0) + +#define RTC_VERSION_MAJOR_MASK (0xff << 24) +#define RTC_VERSION_MAJOR_OFFSET 24 +#define RTC_VERSION_MINOR_MASK (0xff << 16) +#define RTC_VERSION_MINOR_OFFSET 16 +#define RTC_VERSION_STEP_MASK 0xffff +#define RTC_VERSION_STEP_OFFSET 0 + +#endif /* __REGS_RTC_H__ */
Signature · 1 line
1.7.5.4
PATCH 11/31 iMX28: Add I2C register definitions
In reply to Marek Vasut--- arch/arm/include/asm/arch-mx28/regs-i2c.h | 203 +++++++++++++++++++++++++++++ 1 files changed, 203 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-mx28/regs-i2c.h
arch/arm/include/asm/arch-mx28/regs-i2c.h new file +203 -0
@@ -0,0 +1,203 @@ +/* +* Freescale i.MX28 I2C Register Definitions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 __REGS_I2C_H__ +#define __REGS_I2C_H__ + +struct mx28_i2c_regs { + mx28_reg(hw_i2c_ctrl0) + mx28_reg(hw_i2c_timing0) + mx28_reg(hw_i2c_timing1) + mx28_reg(hw_i2c_timing2) + mx28_reg(hw_i2c_ctrl1) + mx28_reg(hw_i2c_stat) + mx28_reg(hw_i2c_queuectrl) + mx28_reg(hw_i2c_queuestat) + mx28_reg(hw_i2c_queuecmd) + mx28_reg(hw_i2c_queuedata) + mx28_reg(hw_i2c_data) + mx28_reg(hw_i2c_debug0) + mx28_reg(hw_i2c_debug1) + mx28_reg(hw_i2c_version) +}; + +#define I2C_CTRL_SFTRST (1 << 31) +#define I2C_CTRL_CLKGATE (1 << 30) +#define I2C_CTRL_RUN (1 << 29) +#define I2C_CTRL_PREACK (1 << 27) +#define I2C_CTRL_ACKNOWLEDGE (1 << 26) +#define I2C_CTRL_SEND_NAK_ON_LAST (1 << 25) +#define I2C_CTRL_MULTI_MASTER (1 << 23) +#define I2C_CTRL_CLOCK_HELD (1 << 22) +#define I2C_CTRL_RETAIN_CLOCK (1 << 21) +#define I2C_CTRL_POST_SEND_STOP (1 << 20) +#define I2C_CTRL_PRE_SEND_START (1 << 19) +#define I2C_CTRL_SLAVE_ADDRESS_ENABLE (1 << 18) +#define I2C_CTRL_MASTER_MODE (1 << 17) +#define I2C_CTRL_DIRECTION (1 << 16) +#define I2C_CTRL_XFER_COUNT_MASK 0xffff +#define I2C_CTRL_XFER_COUNT_OFFSET 0 + +#define I2C_TIMING0_HIGH_COUNT_MASK (0x3ff << 16) +#define I2C_TIMING0_HIGH_COUNT_OFFSET 16 +#define I2C_TIMING0_RCV_COUNT_MASK 0x3ff +#define I2C_TIMING0_RCV_COUNT_OFFSET 0 + +#define I2C_TIMING1_LOW_COUNT_MASK (0x3ff << 16) +#define I2C_TIMING1_LOW_COUNT_OFFSET 16 +#define I2C_TIMING1_XMIT_COUNT_MASK 0x3ff +#define I2C_TIMING1_XMIT_COUNT_OFFSET 0 + +#define I2C_TIMING2_BUS_FREE_MASK (0x3ff << 16) +#define I2C_TIMING2_BUS_FREE_OFFSET 16 +#define I2C_TIMING2_LEADIN_COUNT_MASK 0x3ff +#define I2C_TIMING2_LEADIN_COUNT_OFFSET 0 + +#define I2C_CTRL1_RD_QUEUE_IRQ (1 << 30) +#define I2C_CTRL1_WR_QUEUE_IRQ (1 << 29) +#define I2C_CTRL1_CLR_GOT_A_NAK (1 << 28) +#define I2C_CTRL1_ACK_MODE (1 << 27) +#define I2C_CTRL1_FORCE_DATA_IDLE (1 << 26) +#define I2C_CTRL1_FORCE_CLK_IDLE (1 << 25) +#define I2C_CTRL1_BCAST_SLAVE_EN (1 << 24) +#define I2C_CTRL1_SLAVE_ADDRESS_BYTE_MASK (0xff << 16) +#define I2C_CTRL1_SLAVE_ADDRESS_BYTE_OFFSET 16 +#define I2C_CTRL1_BUS_FREE_IRQ_EN (1 << 15) +#define I2C_CTRL1_DATA_ENGINE_CMPLT_IRQ_EN (1 << 14) +#define I2C_CTRL1_NO_SLAVE_ACK_IRQ_EN (1 << 13) +#define I2C_CTRL1_OVERSIZE_XFER_TERM_IRQ_EN (1 << 12) +#define I2C_CTRL1_EARLY_TERM_IRQ_EN (1 << 11) +#define I2C_CTRL1_MASTER_LOSS_IRQ_EN (1 << 10) +#define I2C_CTRL1_SLAVE_STOP_IRQ_EN (1 << 9) +#define I2C_CTRL1_SLAVE_IRQ_EN (1 << 8) +#define I2C_CTRL1_BUS_FREE_IRQ (1 << 7) +#define I2C_CTRL1_DATA_ENGINE_CMPLT_IRQ (1 << 6) +#define I2C_CTRL1_NO_SLAVE_ACK_IRQ (1 << 5) +#define I2C_CTRL1_OVERSIZE_XFER_TERM_IRQ (1 << 4) +#define I2C_CTRL1_EARLY_TERM_IRQ (1 << 3) +#define I2C_CTRL1_MASTER_LOSS_IRQ (1 << 2) +#define I2C_CTRL1_SLAVE_STOP_IRQ (1 << 1) +#define I2C_CTRL1_SLAVE_IRQ (1 << 0) + +#define I2C_STAT_MASTER_PRESENT (1 << 31) +#define I2C_STAT_SLAVE_PRESENT (1 << 30) +#define I2C_STAT_ANY_ENABLED_IRQ (1 << 29) +#define I2C_STAT_GOT_A_NAK (1 << 28) +#define I2C_STAT_RCVD_SLAVE_ADDR_MASK (0xff << 16) +#define I2C_STAT_RCVD_SLAVE_ADDR_OFFSET 16 +#define I2C_STAT_SLAVE_ADDR_EQ_ZERO (1 << 15) +#define I2C_STAT_SLAVE_FOUND (1 << 14) +#define I2C_STAT_SLAVE_SEARCHING (1 << 13) +#define I2C_STAT_DATA_ENGING_DMA_WAIT (1 << 12) +#define I2C_STAT_BUS_BUSY (1 << 11) +#define I2C_STAT_CLK_GEN_BUSY (1 << 10) +#define I2C_STAT_DATA_ENGINE_BUSY (1 << 9) +#define I2C_STAT_SLAVE_BUSY (1 << 8) +#define I2C_STAT_BUS_FREE_IRQ_SUMMARY (1 << 7) +#define I2C_STAT_DATA_ENGINE_CMPLT_IRQ_SUMMARY (1 << 6) +#define I2C_STAT_NO_SLAVE_ACK_IRQ_SUMMARY (1 << 5) +#define I2C_STAT_OVERSIZE_XFER_TERM_IRQ_SUMMARY (1 << 4) +#define I2C_STAT_EARLY_TERM_IRQ_SUMMARY (1 << 3) +#define I2C_STAT_MASTER_LOSS_IRQ_SUMMARY (1 << 2) +#define I2C_STAT_SLAVE_STOP_IRQ_SUMMARY (1 << 1) +#define I2C_STAT_SLAVE_IRQ_SUMMARY (1 << 0) + +#define I2C_QUEUECTRL_RD_THRESH_MASK (0x1f << 16) +#define I2C_QUEUECTRL_RD_THRESH_OFFSET 16 +#define I2C_QUEUECTRL_WR_THRESH_MASK (0x1f << 8) +#define I2C_QUEUECTRL_WR_THRESH_OFFSET 8 +#define I2C_QUEUECTRL_QUEUE_RUN (1 << 5) +#define I2C_QUEUECTRL_RD_CLEAR (1 << 4) +#define I2C_QUEUECTRL_WR_CLEAR (1 << 3) +#define I2C_QUEUECTRL_PIO_QUEUE_MODE (1 << 2) +#define I2C_QUEUECTRL_RD_QUEUE_IRQ_EN (1 << 1) +#define I2C_QUEUECTRL_WR_QUEUE_IRQ_EN (1 << 0) + +#define I2C_QUEUESTAT_RD_QUEUE_FULL (1 << 14) +#define I2C_QUEUESTAT_RD_QUEUE_EMPTY (1 << 13) +#define I2C_QUEUESTAT_RD_QUEUE_CNT_MASK (0x1f << 8) +#define I2C_QUEUESTAT_RD_QUEUE_CNT_OFFSET 8 +#define I2C_QUEUESTAT_WR_QUEUE_FULL (1 << 6) +#define I2C_QUEUESTAT_WR_QUEUE_EMPTY (1 << 5) +#define I2C_QUEUESTAT_WR_QUEUE_CNT_MASK 0x1f +#define I2C_QUEUESTAT_WR_QUEUE_CNT_OFFSET 0 + +#define I2C_QUEUECMD_PREACK (1 << 27) +#define I2C_QUEUECMD_ACKNOWLEDGE (1 << 26) +#define I2C_QUEUECMD_SEND_NAK_ON_LAST (1 << 25) +#define I2C_QUEUECMD_MULTI_MASTER (1 << 23) +#define I2C_QUEUECMD_CLOCK_HELD (1 << 22) +#define I2C_QUEUECMD_RETAIN_CLOCK (1 << 21) +#define I2C_QUEUECMD_POST_SEND_STOP (1 << 20) +#define I2C_QUEUECMD_PRE_SEND_START (1 << 19) +#define I2C_QUEUECMD_SLAVE_ADDRESS_ENABLE (1 << 18) +#define I2C_QUEUECMD_MASTER_MODE (1 << 17) +#define I2C_QUEUECMD_DIRECTION (1 << 16) +#define I2C_QUEUECMD_XFER_COUNT_MASK 0xffff +#define I2C_QUEUECMD_XFER_COUNT_OFFSET 0 + +#define I2C_QUEUEDATA_DATA_MASK 0xffffffff +#define I2C_QUEUEDATA_DATA_OFFSET 0 + +#define I2C_DATA_DATA_MASK 0xffffffff +#define I2C_DATA_DATA_OFFSET 0 + +#define I2C_DEBUG0_DMAREQ (1 << 31) +#define I2C_DEBUG0_DMAENDCMD (1 << 30) +#define I2C_DEBUG0_DMAKICK (1 << 29) +#define I2C_DEBUG0_DMATERMINATE (1 << 28) +#define I2C_DEBUG0_STATE_VALUE_MASK (0x3 << 26) +#define I2C_DEBUG0_STATE_VALUE_OFFSET 26 +#define I2C_DEBUG0_DMA_STATE_MASK (0x3ff << 16) +#define I2C_DEBUG0_DMA_STATE_OFFSET 16 +#define I2C_DEBUG0_START_TOGGLE (1 << 15) +#define I2C_DEBUG0_STOP_TOGGLE (1 << 14) +#define I2C_DEBUG0_GRAB_TOGGLE (1 << 13) +#define I2C_DEBUG0_CHANGE_TOGGLE (1 << 12) +#define I2C_DEBUG0_STATE_LATCH (1 << 11) +#define I2C_DEBUG0_SLAVE_HOLD_CLK (1 << 10) +#define I2C_DEBUG0_STATE_STATE_MASK 0x3ff +#define I2C_DEBUG0_STATE_STATE_OFFSET 0 + +#define I2C_DEBUG1_I2C_CLK_IN (1 << 31) +#define I2C_DEBUG1_I2C_DATA_IN (1 << 30) +#define I2C_DEBUG1_DMA_BYTE_ENABLES_MASK (0xf << 24) +#define I2C_DEBUG1_DMA_BYTE_ENABLES_OFFSET 24 +#define I2C_DEBUG1_CLK_GEN_STATE_MASK (0xff << 16) +#define I2C_DEBUG1_CLK_GEN_STATE_OFFSET 16 +#define I2C_DEBUG1_LST_MODE_MASK (0x3 << 9) +#define I2C_DEBUG1_LST_MODE_OFFSET 9 +#define I2C_DEBUG1_LOCAL_SLAVE_TEST (1 << 8) +#define I2C_DEBUG1_FORCE_CLK_ON (1 << 4) +#define I2C_DEBUG1_FORCE_ABR_LOSS (1 << 3) +#define I2C_DEBUG1_FORCE_RCV_ACK (1 << 2) +#define I2C_DEBUG1_FORCE_I2C_DATA_OE (1 << 1) +#define I2C_DEBUG1_FORCE_I2C_CLK_OE (1 << 0) + +#define I2C_VERSION_MAJOR_MASK (0xff << 24) +#define I2C_VERSION_MAJOR_OFFSET 24 +#define I2C_VERSION_MINOR_MASK (0xff << 16) +#define I2C_VERSION_MINOR_OFFSET 16 +#define I2C_VERSION_STEP_MASK 0xffff +#define I2C_VERSION_STEP_OFFSET 0 + +#endif /* __REGS_I2C_H__ */
Signature · 1 line
1.7.5.4
PATCH 11/31 iMX28: Add I2C register definitions
Hello Marek,
Quoted 8 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- arch/arm/include/asm/arch-mx28/regs-i2c.h | 203 +++++++++++++++++++++++++++++ 1 files changed, 203 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-mx28/regs-i2c.h
Patch looks good to me, but one minor comment:
Quoted 20 lines
arch/arm/include/asm/arch-mx28/regs-i2c.h new file +14
-0@@ -0,0 +1,203 @@ +/* +* Freescale i.MX28 I2C Register Definitions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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
arch/arm/include/asm/arch-mx28/regs-i2c.h line 24
Quoted 10 lines
arch/arm/include/asm/arch-mx28/regs-i2c.h new file +10
-0+* 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 __REGS_I2C_H__ +#define __REGS_I2C_H__
Please use here a more driver specific name, for example __MX28_REGS_I2C__
If you change that, you get my:
(I think, Stefano pick up the complete Patchserie, or?)
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 12/31 iMX28: Add I2C bus driver
In reply to Marek Vasut--- drivers/i2c/Makefile | 1 + drivers/i2c/mxs_i2c.c | 243 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+), 0 deletions(-) create mode 100644 drivers/i2c/mxs_i2c.c
drivers/i2c/Makefile +1 -0
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o COBJS-$(CONFIG_I2C_MVTWSI) += mvtwsi.o COBJS-$(CONFIG_I2C_MV) += mv_i2c.o COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o +COBJS-$(CONFIG_I2C_MXS) += mxs_i2c.o COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
drivers/i2c/mxs_i2c.c new file +243 -0
243 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 12/31 iMX28: Add I2C bus driver
Hello Marek,
Quoted 10 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Heiko Schocher <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- drivers/i2c/Makefile | 1 + drivers/i2c/mxs_i2c.c | 243 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+), 0 deletions(-) create mode 100644 drivers/i2c/mxs_i2c.c
only one minor comment ...
[...]
Quoted 6 lines
drivers/i2c/mxs_i2c.c new file +0
-0@@ -0,0 +1,243 @@
[...]
Quoted 7 lines
drivers/i2c/mxs_i2c.c new file +7
-0+int mxs_i2c_wait_for_ack (void ) +{ +struct mx28_i2c_regs *i2c_regs = (struct mx28_i2c_regs *)MXS_I2C0_BASE ; +uint32_t tmp; +int timeout =MXS_I2C_MAX_TIMEOUT ; + +for (;;) {
drivers/i2c/mxs_i2c.c line 132
Quoted 10 lines
drivers/i2c/mxs_i2c.c new file +10
-0+ tmp =readl (&i2c_regs->hw_i2c_ctrl1); +if (tmp &I2C_CTRL1_NO_SLAVE_ACK_IRQ ) { +debug ("MXS I2C: No slave ACK\n" ); + goto err; + } + +if (tmp & ( +I2C_CTRL1_EARLY_TERM_IRQ |I2C_CTRL1_MASTER_LOSS_IRQ | +I2C_CTRL1_SLAVE_STOP_IRQ |I2C_CTRL1_SLAVE_IRQ + )) {
Checkpatch don;t beats here, but I think, two line are not necessary here, just do a:
I2C_CTRL1_SLAVE_STOP_IRQ | I2C_CTRL1_SLAVE_IRQ)) {Beside of that, patch looks good to me, so:
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 12/31 iMX28: Add I2C bus driver
Quoted 50 lines · Heiko Schocher
Hello Marek,
Quoted 5 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Heiko Schocher <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>Quoted 7 lines
---
drivers/i2c/Makefile | 1 + drivers/i2c/mxs_i2c.c | 243 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+), 0 deletions(-) create mode 100644 drivers/i2c/mxs_i2c.conly one minor comment ...
[...]
Quoted 6 lines
drivers/i2c/mxs_i2c.c new file +0
-0@@ -0,0 +1,243 @@[...]
Quoted 7 lines
drivers/i2c/mxs_i2c.c new file +7
-0+int mxs_i2c_wait_for_ack (void ) +{ +struct mx28_i2c_regs *i2c_regs = (struct mx28_i2c_regs *)MXS_I2C0_BASE ; +uint32_t tmp; +int timeout =MXS_I2C_MAX_TIMEOUT ; + +for (;;) {drivers/i2c/mxs_i2c.c line 132
Quoted 10 lines
drivers/i2c/mxs_i2c.c new file +10
-0+ tmp =readl (&i2c_regs->hw_i2c_ctrl1); +if (tmp &I2C_CTRL1_NO_SLAVE_ACK_IRQ ) { +debug ("MXS I2C: No slave ACK\n" ); + goto err; + } + +if (tmp & ( +I2C_CTRL1_EARLY_TERM_IRQ |I2C_CTRL1_MASTER_LOSS_IRQ | +I2C_CTRL1_SLAVE_STOP_IRQ |I2C_CTRL1_SLAVE_IRQ + )) {Checkpatch don;t beats here, but I think, two line are not necessary here, just do a:
Quoted 3 lines
I2C_CTRL1_SLAVE_STOP_IRQ | I2C_CTRL1_SLAVE_IRQ)) {Beside of that, patch looks good to me, so:
I think it's more readable as it is ... what do the others think ?
Quoted 5 lines
Acked-by Heiko Schocher<[email protected]>bye,
Heiko
PATCH 12/31 iMX28: Add I2C bus driver
Hi Marek,
Quoted 7 lines · On Friday 09 September 2011 13:18:40 Marek Vasut wrote:
Quoted 7 lines
drivers/i2c/mxs_i2c.c line 132
Quoted 4 lines
drivers/i2c/mxs_i2c.c new file +4
-0+if (tmp & ( +I2C_CTRL1_EARLY_TERM_IRQ |I2C_CTRL1_MASTER_LOSS_IRQ | +I2C_CTRL1_SLAVE_STOP_IRQ |I2C_CTRL1_SLAVE_IRQ + )) {Checkpatch don;t beats here, but I think, two line are not necessary
Quoted 5 lines
Quoted 4 lines
here, just do a:
I2C_CTRL1_SLAVE_STOP_IRQ | I2C_CTRL1_SLAVE_IRQ)) {Beside of that, patch looks good to me, so:
I think it's more readable as it is ... what do the others think ?
I'm definitely with Heiko here! ;)
Ciao,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
PATCH 12/31 iMX28: Add I2C bus driver
Quoted 5 lines · Stefan Roese
Hi Marek,
Quoted 2 lines · On Friday 09 September 2011 13:18:40 Marek Vasut wrote:
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (tmp & ( + I2C_CTRL1_EARLY_TERM_IRQ |
I2C_CTRL1_MASTER_LOSS_IRQ |
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/i2c/mxs_i2c.c line 132
Quoted 2 lines
drivers/i2c/mxs_i2c.c new file +2
-0+ I2C_CTRL1_SLAVE_STOP_IRQ | I2C_CTRL1_SLAVE_IRQ + )) {Checkpatch don;t beats here, but I think, two line are not necessary
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
here, just do a:
I2C_CTRL1_SLAVE_STOP_IRQ | I2C_CTRL1_SLAVE_IRQ)) {Beside of that, patch looks good to me, so:
I think it's more readable as it is ... what do the others think ?
I'm definitely with Heiko here! ;)
Oh youuu ... grrrr ;-) V2 on the way :-)
Quoted 8 lines
Ciao,
Stefan--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
PATCH 13/31 M28: Enable I2C, EEPROM and RTC
In reply to Marek Vasut--- include/configs/m28evk.h | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
include/configs/m28evk.h +29 -0
@@ -44,9 +44,12 @@#define CONFIG_DOS_PARTITION #define CONFIG_CMD_CACHE +#define CONFIG_CMD_DATE #define CONFIG_CMD_DHCP +#define CONFIG_CMD_EEPROM #define CONFIG_CMD_EXT2 #define CONFIG_CMD_FAT +#define CONFIG_CMD_I2C #define CONFIG_CMD_MII #define CONFIG_CMD_MMC #define CONFIG_CMD_NET
@@ -120,6 +123,32 @@#endif /* +* I2C +*/ +#ifdef CONFIG_CMD_I2C +#define CONFIG_I2C_MXS +#define CONFIG_HARD_I2C +#define CONFIG_SYS_I2C_SPEED 400000 +#endif + +/* +* EEPROM +*/ +#ifdef CONFIG_CMD_EEPROM +#define CONFIG_SYS_I2C_MULTI_EEPROMS +#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 +#endif + +/* +* RTC +*/ +#ifdef CONFIG_CMD_DATE +#define CONFIG_RTC_M41T62 +#define CONFIG_SYS_I2C_RTC_ADDR 0x68 +#define CONFIG_SYS_M41T11_BASE_YEAR 2000 +#endif + +/* * Boot Linux */ #define CONFIG_CMDLINE_TAG
Signature · 1 line
1.7.5.4
PATCH 13/31 M28: Enable I2C, EEPROM and RTC
Hello Marek,
Quoted 8 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Heiko Schocher <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- include/configs/m28evk.h | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 14/31 iMX28: Add MMC SPL
In reply to Marek Vasut--- mmc_spl/board/denx/m28evk/Makefile | 102 ++++ mmc_spl/board/denx/m28evk/m28_init.h | 36 ++ mmc_spl/board/denx/m28evk/mem_init.c | 218 ++++++++ mmc_spl/board/denx/m28evk/mmc_boot.c | 271 ++++++++++ mmc_spl/board/denx/m28evk/power_init.c | 915 ++++++++++++++++++++++++++++++++ mmc_spl/board/denx/m28evk/start.S | 402 ++++++++++++++ mmc_spl/board/denx/m28evk/u-boot.bd | 14 + mmc_spl/board/denx/m28evk/u-boot.lds | 87 +++ 8 files changed, 2045 insertions(+), 0 deletions(-) create mode 100644 mmc_spl/board/denx/m28evk/Makefile create mode 100644 mmc_spl/board/denx/m28evk/m28_init.h create mode 100644 mmc_spl/board/denx/m28evk/mem_init.c create mode 100644 mmc_spl/board/denx/m28evk/mmc_boot.c create mode 100644 mmc_spl/board/denx/m28evk/power_init.c create mode 100644 mmc_spl/board/denx/m28evk/start.S create mode 100644 mmc_spl/board/denx/m28evk/u-boot.bd create mode 100644 mmc_spl/board/denx/m28evk/u-boot.lds
mmc_spl/board/denx/m28evk/Makefile new file +102 -0
@@ -0,0 +1,102 @@ +# +# (C) Copyright 2006-2007 +# Stefan Roese, DENX Software Engineering, sr at denx.de. +# +# (C) Copyright 2008 +# Guennadi Liakhovetki, DENX Software Engineering, <[email protected]> +# +# (C) Copyright 2011 +# Chander Kashyap, Samsung Electronics, <[email protected]> +# +# 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 +# + +CONFIG_MMC_SPL = y + +include $(TOPDIR)/config.mk + +LDSCRIPT= $(TOPDIR)/mmc_spl/board/$(BOARDDIR)/u-boot.lds +LDFLAGS = -Bstatic -T $(mmcobj)u-boot.lds -Ttext 0x0 $(PLATFORM_LDFLAGS) +AFLAGS += -DCONFIG_MMC_SPL +AFLAGS += -DCONFIG_SPL_BUILD +CFLAGS += -DCONFIG_MMC_SPL +CFLAGS += -DCONFIG_SPL_BUILD + +SOBJS = start.o _udivsi3.o _divsi3.o +COBJS = mmc_boot.o iomux.o power_init.o mem_init.o div0.o + +SRCS := $($(SOBJS:.o=.S) $(COBJS:.o=.c)) +OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) +__OBJS := $(SOBJS) $(COBJS) +LNDIR := $(OBJTREE)/mmc_spl/board/$(BOARDDIR) + +mmcobj := $(OBJTREE)/mmc_spl/ + + +ALL = $(mmcobj)u-boot-spl $(mmcobj)u-boot-spl.bin $(mmcobj)u-boot-mmc-spl.bin + +all: $(obj).depend $(ALL) + +$(mmcobj)u-boot-mmc-spl.bin: $(mmcobj)u-boot-spl.bin + cp $< $@ + +$(mmcobj)u-boot-spl.bin: $(mmcobj)u-boot-spl + $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ + +$(mmcobj)u-boot-spl: $(OBJS) $(mmcobj)u-boot.lds + cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \ + -Map $(mmcobj)u-boot-spl.map \ + -o $(mmcobj)u-boot-spl + +$(mmcobj)u-boot.lds: $(LDSCRIPT) + $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + +# create symbolic links for common files + +# from cpu directory +iomux.c: + @rm -f $@ + @ln -s $(TOPDIR)/arch/arm/cpu/arm926ejs/mx28/iomux.c $@ + +_udivsi3.S: + @rm -f $@ + @ln -s $(TOPDIR)/arch/arm/lib/_udivsi3.S $@ + +_divsi3.S: + @rm -f $@ + @ln -s $(TOPDIR)/arch/arm/lib/_divsi3.S $@ + +div0.c: + @rm -f $@ + @ln -s $(TOPDIR)/arch/arm/lib/div0.c $@ + +######################################################################### + +$(obj)%.o: %.S + $(CC) $(AFLAGS) -c -o $@ $< + +$(obj)%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +#########################################################################
mmc_spl/board/denx/m28evk/m28_init.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Freescale i.MX28 SPL functions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 __M28_INIT_H__ +#define __M28_INIT_H__ + +void early_delay (int delay); + +void mx28_power_init (void ); +void mx28_power_wait_pswitch (void ); + +void mx28_mem_init (void ); + +#endif /* __M28_INIT_H__ */
mmc_spl/board/denx/m28evk/mem_init.c new file +218 -0
218 lines not on this page · raw message
mmc_spl/board/denx/m28evk/mmc_boot.c new file +271 -0
271 lines not on this page · raw message
mmc_spl/board/denx/m28evk/power_init.c new file +915 -0
915 lines not on this page · raw message
mmc_spl/board/denx/m28evk/start.S new file +402 -0
402 lines not on this page · raw message
mmc_spl/board/denx/m28evk/u-boot.bd new file +14 -0
@@ -0,0 +1,14 @@ +sources { + u_boot_spl="mmc_spl/u-boot-spl.bin"; + u_boot="u-boot.bin"; +} + +section (0) { + load u_boot_spl > 0x0000; + load ivt (entry = 0x0014) > 0x8000; + hab call 0x8000; + + load u_boot > 0x40000100; + load ivt (entry = 0x40000100) > 0x8000; + hab call 0x8000; +}
mmc_spl/board/denx/m28evk/u-boot.lds new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 14/31 iMX28: Add MMC SPL
Dear Marek Vasut,
Please use newly added spl framework to add mmc spl support.
Quoted 2,121 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Andy Fleming <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
?mmc_spl/board/denx/m28evk/Makefile ? ? | ?102 ++++ ?mmc_spl/board/denx/m28evk/m28_init.h ? | ? 36 ++ ?mmc_spl/board/denx/m28evk/mem_init.c ? | ?218 ++++++++ ?mmc_spl/board/denx/m28evk/mmc_boot.c ? | ?271 ++++++++++ ?mmc_spl/board/denx/m28evk/power_init.c | ?915 ++++++++++++++++++++++++++++++++ ?mmc_spl/board/denx/m28evk/start.S ? ? ?| ?402 ++++++++++++++ ?mmc_spl/board/denx/m28evk/u-boot.bd ? ?| ? 14 + ?mmc_spl/board/denx/m28evk/u-boot.lds ? | ? 87 +++?8 files changed, 2045 insertions(+), 0 deletions(-) ?create mode 100644 mmc_spl/board/denx/m28evk/Makefile ?create mode 100644
mmc_spl/board/denx/m28evk/m28_init.h?create mode 100644mmc_spl/board/denx/m28evk/mem_init.c?create mode 100644mmc_spl/board/denx/m28evk/mmc_boot.c?create mode 100644mmc_spl/board/denx/m28evk/power_init.c?create mode 100644mmc_spl/board/denx/m28evk/start.S?create mode 100644 mmc_spl/board/denx/m28evk/u-boot.bd ?create mode 100644mmc_spl/board/denx/m28evk/u-boot.ldsmmc_spl/board/denx/m28evk/Makefile new file +102
-0@@ -0,0 +1,102 @@ +# +# (C) Copyright 2006-2007 +# Stefan Roese, DENX Software Engineering, sr at denx.de. +# +# (C) Copyright 2008 +# Guennadi Liakhovetki, DENX Software Engineering, <[email protected]> +# +# (C) Copyright 2011 +# Chander Kashyap, Samsung Electronics, <[email protected]> +# +# 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 +# + +CONFIG_MMC_SPL = y + +include $(TOPDIR)/config.mk + +LDSCRIPT= $(TOPDIR)/mmc_spl/board/$(BOARDDIR)/u-boot.lds +LDFLAGS ? ? ? ?= -Bstatic -T $(mmcobj)u-boot.lds -Ttext 0x0 $(PLATFORM_LDFLAGS) +AFLAGS += -DCONFIG_MMC_SPL +AFLAGS += -DCONFIG_SPL_BUILD +CFLAGS += -DCONFIG_MMC_SPL +CFLAGS += -DCONFIG_SPL_BUILD + +SOBJS ?= start.o _udivsi3.o _divsi3.o +COBJS ?= mmc_boot.o iomux.o power_init.o mem_init.o div0.o + +SRCS ? := $($(SOBJS:.o=.S) $(COBJS:.o=.c)) +OBJS ? := $(addprefix $(obj),$(SOBJS) $(COBJS)) +__OBJS := $(SOBJS) $(COBJS) +LNDIR ?:= $(OBJTREE)/mmc_spl/board/$(BOARDDIR) + +mmcobj := $(OBJTREE)/mmc_spl/ + + +ALL = $(mmcobj)u-boot-spl $(mmcobj)u-boot-spl.bin ?$(mmcobj)u-boot-mmc-spl.bin + +all: ? ?$(obj).depend $(ALL) + +$(mmcobj)u-boot-mmc-spl.bin: ? $(mmcobj)u-boot-spl.bin + ? ? ? cp $< $@ + +$(mmcobj)u-boot-spl.bin: ? ? ? $(mmcobj)u-boot-spl + ? ? ? $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ + +$(mmcobj)u-boot-spl: ? $(OBJS) $(mmcobj)u-boot.lds + ? ? ? cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \ + ? ? ? ? ? ? ? -Map $(mmcobj)u-boot-spl.map \ + ? ? ? ? ? ? ? -o $(mmcobj)u-boot-spl + +$(mmcobj)u-boot.lds: $(LDSCRIPT) + ? ? ? $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + +# create symbolic links for common files + +# from cpu directory +iomux.c: + ? ? ? @rm -f $@ + ? ? ? @ln -s $(TOPDIR)/arch/arm/cpu/arm926ejs/mx28/iomux.c $@ + +_udivsi3.S: + ? ? ? @rm -f $@ + ? ? ? @ln -s $(TOPDIR)/arch/arm/lib/_udivsi3.S $@ + +_divsi3.S: + ? ? ? @rm -f $@ + ? ? ? @ln -s $(TOPDIR)/arch/arm/lib/_divsi3.S $@ + +div0.c: + ? ? ? @rm -f $@ + ? ? ? @ln -s $(TOPDIR)/arch/arm/lib/div0.c $@ + +######################################################################### + +$(obj)%.o: ? ? %.S + ? ? ? $(CC) $(AFLAGS) -c -o $@ $< + +$(obj)%.o: ? ? %.c + ? ? ? $(CC) $(CFLAGS) -c -o $@ $< + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +#########################################################################mmc_spl/board/denx/m28evk/m28_init.h new file +36
-0@@ -0,0 +1,36 @@ +/* +* Freescale i.MX28 SPL functions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 ? ? ? ?__M28_INIT_H__ +#define ? ? ? ?__M28_INIT_H__ + +void early_delay (int delay); + +void mx28_power_init (void ); +void mx28_power_wait_pswitch (void ); + +void mx28_mem_init (void ); + +#endif /* __M28_INIT_H__ */ mmc_spl/board/denx/m28evk/mem_init.c new file +218
-0@@ -0,0 +1,218 @@ +/* +* Freescale i.MX28 RAM init +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 <config.h> +#include <asm/io.h> +#include <asm/arch/iomux-mx28.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-pinctrl.h> +#include <asm/arch/regs-rtc.h> +#include <asm/arch/regs-power.h> + +#include "m28_init.h" + +uint32_t dram_vals[] = { + ? ? ? 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x00010101, 0x01010101, 0x000f0f01, 0x0f02020a, + ? ? ? 0x00000000, 0x00010101, 0x00000100, 0x00000100, 0x00000000, + ? ? ? 0x00000002, 0x01010000, 0x05060302, 0x06005003, 0x0a0000c8, + ? ? ? 0x02009c40, 0x0000030c, 0x0036a609, 0x031a0612, 0x02030202, + ? ? ? 0x00c8001c, 0x00000000, 0x00000000, 0x00012100, 0xffff0303, + ? ? ? 0x00012100, 0xffff0303, 0x00012100, 0xffff0303, 0x00012100, + ? ? ? 0xffff0303, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x00000612, 0x01000F02, 0x06120612, 0x00000200, + ? ? ? 0x00020007, 0xf5014b27, 0xf5014b27, 0xf5014b27, 0xf5014b27, + ? ? ? 0x07000300, 0x07000300, 0x07000300, 0x07000300, 0x00000006, + ? ? ? 0x00000000, 0x00000000, 0x01000000, 0x01020408, 0x08040201, + ? ? ? 0x000f1133, 0x00000000, 0x00001f04, 0x00001f04, 0x00001f04, + ? ? ? 0x00001f04, 0x00001f04, 0x00001f04, 0x00001f04, 0x00001f04, + ? ? ? 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, 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, 0x00000000, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x00000000, 0x00010000, 0x00020304, 0x00000004, + ? ? ? 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + ? ? ? 0x00000000, 0x01010000, 0x01000000, 0x03030000, 0x00010303, + ? ? ? 0x01020202, 0x00000000, 0x02040303, 0x21002103, 0x00061200, + ? ? ? 0x06120612, 0x04320432, 0x04320432, 0x00040004, 0x00040004, + ? ? ? 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010001 +}; + +void init_m28_200mhz_ddr2 (void ) +{ + ? ? ? int i; + + ? ? ? for (i = 0; i < ARRAY_SIZE(dram_vals); i++) + ? ? ? ? ? ? ? writel(dram_vals[i], MXS_DRAM_BASE + (4 * i)); +} + +void mx28_mem_init_clock (void ) +{ + ? ? ? struct mx28_clkctrl_regs *clkctrl_regs = + ? ? ? ? ? ? ? (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE; + + ? ? ? /* Gate EMI clock */ + ? ? ? writel(CLKCTRL_FRAC0_CLKGATEEMI, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_frac0_set); + + ? ? ? /* EMI = 205MHz */ + ? ? ? writel(CLKCTRL_FRAC0_EMIFRAC_MASK, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_frac0_set); + ? ? ? writel((0x2a << CLKCTRL_FRAC0_EMIFRAC_OFFSET) & + ? ? ? ? ? ? ? CLKCTRL_FRAC0_EMIFRAC_MASK, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_frac0_clr); + + ? ? ? /* Ungate EMI clock */ + ? ? ? writel(CLKCTRL_FRAC0_CLKGATEEMI, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_frac0_clr); + + ? ? ? early_delay(11000); + + ? ? ? writel((2 << CLKCTRL_EMI_DIV_EMI_OFFSET) | + ? ? ? ? ? ? ? (1 << CLKCTRL_EMI_DIV_XTAL_OFFSET), + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_emi); + + ? ? ? /* Unbypass EMI */ + ? ? ? writel(CLKCTRL_CLKSEQ_BYPASS_EMI, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_clkseq_clr); + + ? ? ? early_delay(10000); +} + +void mx28_mem_setup_cpu_and_hbus (void ) +{ + ? ? ? struct mx28_clkctrl_regs *clkctrl_regs = + ? ? ? ? ? ? ? (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE; + + ? ? ? /* CPU = 454MHz and ungate CPU clock */ + ? ? ? clrsetbits_le32(&clkctrl_regs->hw_clkctrl_frac0, + ? ? ? ? ? ? ? CLKCTRL_FRAC0_CPUFRAC_MASK | CLKCTRL_FRAC0_CLKGATECPU, + ? ? ? ? ? ? ? 19 << CLKCTRL_FRAC0_CPUFRAC_OFFSET); + + ? ? ? /* Set CPU bypass */ + ? ? ? writel(CLKCTRL_CLKSEQ_BYPASS_CPU, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_clkseq_set); + + ? ? ? /* HBUS = 151MHz */ + ? ? ? writel(CLKCTRL_HBUS_DIV_MASK, &clkctrl_regs->hw_clkctrl_hbus_set); + ? ? ? writel(((~3) << CLKCTRL_HBUS_DIV_OFFSET) & CLKCTRL_HBUS_DIV_MASK, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_hbus_clr); + + ? ? ? early_delay(10000); + + ? ? ? /* CPU clock divider = 1 */ + ? ? ? clrsetbits_le32(&clkctrl_regs->hw_clkctrl_cpu, + ? ? ? ? ? ? ? ? ? ? ? CLKCTRL_CPU_DIV_CPU_MASK, 1); + + ? ? ? /* Disable CPU bypass */ + ? ? ? writel(CLKCTRL_CLKSEQ_BYPASS_CPU, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_clkseq_clr); +} + +void mx28_mem_setup_vdda (void ) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? writel((0xc << POWER_VDDACTRL_TRG_OFFSET) | + ? ? ? ? ? ? ? (0x7 << POWER_VDDACTRL_BO_OFFSET_OFFSET) | + ? ? ? ? ? ? ? POWER_VDDACTRL_LINREG_OFFSET_1STEPS_BELOW, + ? ? ? ? ? ? ? &power_regs->hw_power_vddactrl); +} + +void mx28_mem_setup_vddd (void ) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? writel((0x1c << POWER_VDDDCTRL_TRG_OFFSET) | + ? ? ? ? ? ? ? (0x7 << POWER_VDDDCTRL_BO_OFFSET_OFFSET) | + ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_1STEPS_BELOW, + ? ? ? ? ? ? ? &power_regs->hw_power_vdddctrl); +} + +void mx28_mem_init (void ) +{ + ? ? ? struct mx28_clkctrl_regs *clkctrl_regs = + ? ? ? ? ? ? ? (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE; + ? ? ? struct mx28_pinctrl_regs *pinctrl_regs = + ? ? ? ? ? ? ? (struct mx28_pinctrl_regs *)MXS_PINCTRL_BASE; + + ? ? ? /* Set DDR2 mode */ + ? ? ? writel(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2, + ? ? ? ? ? ? ? &pinctrl_regs->hw_pinctrl_emi_ds_ctrl_set); + + ? ? ? /* Power up PLL0 */ + ? ? ? writel(CLKCTRL_PLL0CTRL0_POWER, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_pll0ctrl0_set); + + ? ? ? early_delay(11000); + + ? ? ? mx28_mem_init_clock(); + + ? ? ? mx28_mem_setup_vdda(); + + ? ? ? /* + ? ? ? ?* Configure the DRAM registers + ? ? ? ?*/ + + ? ? ? /* Clear START bit from DRAM_CTL16 */ + ? ? ? clrbits_le32(MXS_DRAM_BASE + 0x40, 1); + + ? ? ? init_m28_200mhz_ddr2(); + + ? ? ? /* Clear SREFRESH bit from DRAM_CTL17 */ + ? ? ? clrbits_le32(MXS_DRAM_BASE + 0x44, 1); + + ? ? ? /* Set START bit in DRAM_CTL16 */ + ? ? ? setbits_le32(MXS_DRAM_BASE + 0x40, 1); + + ? ? ? /* Wait for bit 20 (DRAM init complete) in DRAM_CTL58 */ + ? ? ? while (!(readl(MXS_DRAM_BASE + 0xe8) & (1 << 20))) + ? ? ? ? ? ? ? ; + + ? ? ? mx28_mem_setup_vddd(); + + ? ? ? early_delay(10000); + + ? ? ? mx28_mem_setup_cpu_and_hbus(); +}mmc_spl/board/denx/m28evk/mmc_boot.c new file +271
-0@@ -0,0 +1,271 @@ +/* +* Freescale i.MX28 Boot setup +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 <config.h> +#include <asm/io.h> +#include <asm/arch/iomux-mx28.h> + +#include "m28_init.h" + +/* +* This delay function is intended to be used only in early stage of boot, where +* clock are not set up yet. The timer used here is reset on every boot and +* takes a few seconds to roll. The boot doesn't take that long, so to keep the +* code simple, it doesn't take rolling into consideration. +*/ +#define ? ? ? ?HW_DIGCTRL_MICROSECONDS 0x8001c0c0 +void early_delay (int delay) +{ + ? ? ? uint32_t st = readl(HW_DIGCTRL_MICROSECONDS); + ? ? ? st += delay; + ? ? ? while (st > readl(HW_DIGCTRL_MICROSECONDS)) + ? ? ? ? ? ? ? ; +} + +#define ? ? ? ?MUX_CONFIG_LED ?(MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_NOPULL) +#define ? ? ? ?MUX_CONFIG_LCD ?(MXS_PAD_3V3 | MXS_PAD_4MA) +#define ? ? ? ?MUX_CONFIG_TSC ?(MXS_PAD_3V3 | MXS_PAD_8MA | MXS_PAD_PULLUP) +#define ? ? ? ?MUX_CONFIG_SSP0 (MXS_PAD_3V3 | MXS_PAD_12MA | MXS_PAD_PULLUP) +#define ? ? ? ?MUX_CONFIG_SSP2 (MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_PULLUP) +#define ? ? ? ?MUX_CONFIG_GPMI (MXS_PAD_1V8 | MXS_PAD_4MA | MXS_PAD_NOPULL) +#define ? ? ? ?MUX_CONFIG_ENET (MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_PULLUP) +#define ? ? ? ?MUX_CONFIG_EMI ?(MXS_PAD_3V3 | MXS_PAD_12MA | MXS_PAD_NOPULL) + +const iomux_cfg_t iomux_setup[] = { + ? ? ? /* LED */ + ? ? ? MX28_PAD_ENET0_RXD3__GPIO_4_10 | MUX_CONFIG_LED, + + ? ? ? /* framebuffer */ + ? ? ? MX28_PAD_LCD_D00__LCD_D0 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D01__LCD_D1 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D02__LCD_D2 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D03__LCD_D3 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D04__LCD_D4 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D05__LCD_D5 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D06__LCD_D6 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D07__LCD_D7 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D08__LCD_D8 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D09__LCD_D9 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D10__LCD_D10 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D11__LCD_D11 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D12__LCD_D12 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D13__LCD_D13 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D14__LCD_D14 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D15__LCD_D15 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D16__LCD_D16 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D17__LCD_D17 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D18__LCD_D18 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D19__LCD_D19 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D20__LCD_D20 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D21__LCD_D21 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D22__LCD_D22 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_D23__LCD_D23 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_RD_E__LCD_VSYNC | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_WR_RWN__LCD_HSYNC | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_RS__LCD_DOTCLK | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_CS__LCD_CS | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_VSYNC__LCD_VSYNC | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_HSYNC__LCD_HSYNC | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_DOTCLK__LCD_DOTCLK | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_ENABLE__GPIO_1_31 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_LCD_RESET__GPIO_3_30 | MUX_CONFIG_LCD, + ? ? ? MX28_PAD_PWM0__PWM_0 | MUX_CONFIG_LCD, + + ? ? ? /* UART1 */ + ? ? ? MX28_PAD_AUART0_CTS__DUART_RX, + ? ? ? MX28_PAD_AUART0_RTS__DUART_TX, + ? ? ? MX28_PAD_AUART0_TX__DUART_RTS, + ? ? ? MX28_PAD_AUART0_RX__DUART_CTS, + + ? ? ? /* UART2 */ + ? ? ? MX28_PAD_AUART1_RX__AUART1_RX, + ? ? ? MX28_PAD_AUART1_TX__AUART1_TX, + ? ? ? MX28_PAD_AUART1_RTS__AUART1_RTS, + ? ? ? MX28_PAD_AUART1_CTS__AUART1_CTS, + + ? ? ? /* CAN */ + ? ? ? MX28_PAD_GPMI_RDY2__CAN0_TX, + ? ? ? MX28_PAD_GPMI_RDY3__CAN0_RX, + + ? ? ? /* I2C */ + ? ? ? MX28_PAD_I2C0_SCL__I2C0_SCL, + ? ? ? MX28_PAD_I2C0_SDA__I2C0_SDA, + + ? ? ? /* TSC2007 */ + ? ? ? MX28_PAD_SAIF0_MCLK__GPIO_3_20 | MUX_CONFIG_TSC, + + ? ? ? /* MMC0 */ + ? ? ? MX28_PAD_SSP0_DATA0__SSP0_D0 | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_DATA1__SSP0_D1 | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_DATA2__SSP0_D2 | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_DATA3__SSP0_D3 | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_DATA4__SSP0_D4 | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_DATA5__SSP0_D5 | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_DATA6__SSP0_D6 | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_DATA7__SSP0_D7 | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_CMD__SSP0_CMD | MUX_CONFIG_SSP0, + ? ? ? MX28_PAD_SSP0_DETECT__SSP0_CARD_DETECT | + ? ? ? ? ? ? ? (MXS_PAD_3V3 | MXS_PAD_12MA | MXS_PAD_NOPULL), + ? ? ? MX28_PAD_SSP0_SCK__SSP0_SCK | + ? ? ? ? ? ? ? (MXS_PAD_3V3 | MXS_PAD_12MA | MXS_PAD_NOPULL), + ? ? ? MX28_PAD_PWM3__GPIO_3_28 | MUX_CONFIG_SSP0, ? ? /* Power .. FIXME */ + ? ? ? MX28_PAD_AUART2_CTS__GPIO_3_10, /* WP ... FIXME */ + + ? ? ? /* GPMI NAND */ + ? ? ? MX28_PAD_GPMI_D00__GPMI_D0 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_D01__GPMI_D1 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_D02__GPMI_D2 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_D03__GPMI_D3 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_D04__GPMI_D4 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_D05__GPMI_D5 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_D06__GPMI_D6 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_D07__GPMI_D7 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_CE0N__GPMI_CE0N | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_RDY0__GPMI_READY0 | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_RDN__GPMI_RDN | + ? ? ? ? ? ? ? (MXS_PAD_1V8 | MXS_PAD_8MA | MXS_PAD_PULLUP), + ? ? ? MX28_PAD_GPMI_WRN__GPMI_WRN | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_ALE__GPMI_ALE | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_CLE__GPMI_CLE | MUX_CONFIG_GPMI, + ? ? ? MX28_PAD_GPMI_RESETN__GPMI_RESETN | MUX_CONFIG_GPMI, + + ? ? ? /* FEC Ethernet */ + ? ? ? MX28_PAD_ENET0_MDC__ENET0_MDC | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_MDIO__ENET0_MDIO | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_RX_EN__ENET0_RX_EN | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_TX_EN__ENET0_TX_EN | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_RXD0__ENET0_RXD0 | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_RXD1__ENET0_RXD1 | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_TXD0__ENET0_TXD0 | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_TXD1__ENET0_TXD1 | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET_CLK__CLKCTRL_ENET | MUX_CONFIG_ENET, + + ? ? ? MX28_PAD_ENET0_COL__ENET1_TX_EN | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_CRS__ENET1_RX_EN | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_RXD2__ENET1_RXD0 | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_RXD3__ENET1_RXD1 | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_TXD2__ENET1_TXD0 | MUX_CONFIG_ENET, + ? ? ? MX28_PAD_ENET0_TXD3__ENET1_TXD1 | MUX_CONFIG_ENET, + + ? ? ? /* I2C */ + ? ? ? MX28_PAD_I2C0_SCL__I2C0_SCL, + ? ? ? MX28_PAD_I2C0_SDA__I2C0_SDA, + + ? ? ? /* EMI */ + ? ? ? MX28_PAD_EMI_D00__EMI_DATA0 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D01__EMI_DATA1 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D02__EMI_DATA2 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D03__EMI_DATA3 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D04__EMI_DATA4 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D05__EMI_DATA5 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D06__EMI_DATA6 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D07__EMI_DATA7 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D08__EMI_DATA8 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D09__EMI_DATA9 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D10__EMI_DATA10 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D11__EMI_DATA11 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D12__EMI_DATA12 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D13__EMI_DATA13 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D14__EMI_DATA14 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_D15__EMI_DATA15 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_ODT0__EMI_ODT0 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_DQM0__EMI_DQM0 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_ODT1__EMI_ODT1 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_DQM1__EMI_DQM1 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_DDR_OPEN_FB__EMI_DDR_OPEN_FEEDBACK | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_CLK__EMI_CLK | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_DQS0__EMI_DQS0 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_DQS1__EMI_DQS1 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_DDR_OPEN__EMI_DDR_OPEN | MUX_CONFIG_EMI, + + ? ? ? MX28_PAD_EMI_A00__EMI_ADDR0 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A01__EMI_ADDR1 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A02__EMI_ADDR2 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A03__EMI_ADDR3 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A04__EMI_ADDR4 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A05__EMI_ADDR5 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A06__EMI_ADDR6 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A07__EMI_ADDR7 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A08__EMI_ADDR8 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A09__EMI_ADDR9 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A10__EMI_ADDR10 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A11__EMI_ADDR11 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A12__EMI_ADDR12 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A13__EMI_ADDR13 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_A14__EMI_ADDR14 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_BA0__EMI_BA0 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_BA1__EMI_BA1 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_BA2__EMI_BA2 | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_CASN__EMI_CASN | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_RASN__EMI_RASN | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_WEN__EMI_WEN | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_CE0N__EMI_CE0N | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_CE1N__EMI_CE1N | MUX_CONFIG_EMI, + ? ? ? MX28_PAD_EMI_CKE__EMI_CKE | MUX_CONFIG_EMI, + + ? ? ? /* SPI2 (for flash) */ + ? ? ? MX28_PAD_SSP2_SCK__SSP2_SCK | MUX_CONFIG_SSP2, + ? ? ? MX28_PAD_SSP2_MOSI__SSP2_CMD | MUX_CONFIG_SSP2, + ? ? ? MX28_PAD_SSP2_MISO__SSP2_D0 | MUX_CONFIG_SSP2, + ? ? ? MX28_PAD_SSP2_SS0__SSP2_D3 | + ? ? ? ? ? ? ? (MXS_PAD_3V3 | MXS_PAD_8MA | MXS_PAD_PULLUP), +}; + +void board_init_ll (void ) +{ + ? ? ? mxs_iomux_setup_multiple_pads(iomux_setup, ARRAY_SIZE(iomux_setup)); + ? ? ? mx28_power_init(); + ? ? ? mx28_mem_init(); + ? ? ? mx28_power_wait_pswitch(); +} + +/* Support aparatus */ +inline void board_init_f (unsigned long bootflag) +{ + ? ? ? for (;;) + ? ? ? ? ? ? ? ; +} + +inline void board_init_r (gd_t *id,ulong dest_addr) +{ + ? ? ? for (;;) + ? ? ? ? ? ? ? ; +} + +inline void lowlevel_init (void ) {} + +inline void __coloured_LED_init (void ) {} +inline void __red_LED_on (void ) {} +void coloured_LED_init (void ) + ? ? ? __attribute__((weak, alias("__coloured_LED_init"))); +void red_LED_on (void ) + ? ? ? __attribute__((weak, alias("__red_LED_on"))); +void hang (void ) __attribute__ ((noreturn)); +void hang (void ) +{ + ? ? ? for (;;) + ? ? ? ? ? ? ? ; +}mmc_spl/board/denx/m28evk/power_init.c new file +915
-0@@ -0,0 +1,915 @@ +/* + * Freescale i.MX28 Boot PMIC init + * + * Copyright (C) 2011 Marek Vasut <[email protected]> + * on behalf of DENX Software Engineering GmbH + * + * 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 <config.h> +#include <asm/io.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-rtc.h> +#include <asm/arch/regs-power.h> + +#include "m28_init.h" + +void mx28_power_clock2xtal(void) +{ + ? ? ? struct mx28_clkctrl_regs *clkctrl_regs = + ? ? ? ? ? ? ? (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE; + + ? ? ? /* Set XTAL as CPU reference clock */ + ? ? ? writel(CLKCTRL_CLKSEQ_BYPASS_CPU, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_clkseq_set); +} + +void mx28_power_clock2pll(void) +{ + ? ? ? struct mx28_clkctrl_regs *clkctrl_regs = + ? ? ? ? ? ? ? (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE; + + ? ? ? writel(CLKCTRL_PLL0CTRL0_POWER, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_pll0ctrl0_set); + ? ? ? early_delay(100); + ? ? ? writel(CLKCTRL_CLKSEQ_BYPASS_CPU, + ? ? ? ? ? ? ? &clkctrl_regs->hw_clkctrl_clkseq_clr); +} + +void mx28_power_clear_auto_restart(void) +{ + ? ? ? struct mx28_rtc_regs *rtc_regs = + ? ? ? ? ? ? ? (struct mx28_rtc_regs *)MXS_RTC_BASE; + + ? ? ? writel(RTC_CTRL_SFTRST, &rtc_regs->hw_rtc_ctrl_clr); + ? ? ? while (readl(&rtc_regs->hw_rtc_ctrl) & RTC_CTRL_SFTRST) + ? ? ? ? ? ? ? ; + + ? ? ? writel(RTC_CTRL_CLKGATE, &rtc_regs->hw_rtc_ctrl_clr); + ? ? ? while (readl(&rtc_regs->hw_rtc_ctrl) & RTC_CTRL_CLKGATE) + ? ? ? ? ? ? ? ; + + ? ? ? /* + ? ? ? ?* Due to the hardware design bug of mx28 EVK-A + ? ? ? ?* we need to set the AUTO_RESTART bit. + ? ? ? ?*/ + ? ? ? if (readl(&rtc_regs->hw_rtc_persistent0) & RTC_PERSISTENT0_AUTO_RESTART) + ? ? ? ? ? ? ? return; + + ? ? ? while (readl(&rtc_regs->hw_rtc_stat) & RTC_STAT_NEW_REGS_MASK) + ? ? ? ? ? ? ? ; + + ? ? ? setbits_le32(&rtc_regs->hw_rtc_persistent0, + ? ? ? ? ? ? ? ? ? ? ? RTC_PERSISTENT0_AUTO_RESTART); + ? ? ? writel(RTC_CTRL_FORCE_UPDATE, &rtc_regs->hw_rtc_ctrl_set); + ? ? ? writel(RTC_CTRL_FORCE_UPDATE, &rtc_regs->hw_rtc_ctrl_clr); + ? ? ? while (readl(&rtc_regs->hw_rtc_stat) & RTC_STAT_NEW_REGS_MASK) + ? ? ? ? ? ? ? ; + ? ? ? while (readl(&rtc_regs->hw_rtc_stat) & RTC_STAT_STALE_REGS_MASK) + ? ? ? ? ? ? ? ; +} + +void mx28_power_set_linreg(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? /* Set linear regulator 25mV below switching converter */ + ? ? ? clrsetbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_MASK, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_1STEPS_BELOW); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_vddactrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDACTRL_LINREG_OFFSET_MASK, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDACTRL_LINREG_OFFSET_1STEPS_BELOW); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDIOCTRL_LINREG_OFFSET_MASK, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDIOCTRL_LINREG_OFFSET_1STEPS_BELOW); +} + +void mx28_power_setup_5v_detect(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? /* Start 5V detection */ + ? ? ? clrsetbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_VBUSVALID_TRSH_MASK, + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_VBUSVALID_TRSH_4V4 | + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_PWRUP_VBUS_CMPS); +} + +void mx28_src_power_init(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? /* Improve efficieny and reduce transient ripple */ + ? ? ? writel(POWER_LOOPCTRL_TOGGLE_DIF | POWER_LOOPCTRL_EN_CM_HYST | + ? ? ? ? ? ? ? POWER_LOOPCTRL_EN_DF_HYST, &power_regs->hw_power_loopctrl_set); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_dclimits, + ? ? ? ? ? ? ? ? ? ? ? POWER_DCLIMITS_POSLIMIT_BUCK_MASK, + ? ? ? ? ? ? ? ? ? ? ? 0x30 << POWER_DCLIMITS_POSLIMIT_BUCK_OFFSET); + + ? ? ? setbits_le32(&power_regs->hw_power_battmonitor, + ? ? ? ? ? ? ? ? ? ? ? POWER_BATTMONITOR_EN_BATADJ); + + ? ? ? /* Increase the RCSCALE level for quick DCDC response to dynamic load */ + ? ? ? clrsetbits_le32(&power_regs->hw_power_loopctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_LOOPCTRL_EN_RCSCALE_MASK, + ? ? ? ? ? ? ? ? ? ? ? POWER_LOOPCTRL_RCSCALE_THRESH | + ? ? ? ? ? ? ? ? ? ? ? POWER_LOOPCTRL_EN_RCSCALE_8X); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_minpwr, + ? ? ? ? ? ? ? ? ? ? ? POWER_MINPWR_HALFFETS, POWER_MINPWR_DOUBLE_FETS); + + ? ? ? /* 5V to battery handoff ... FIXME */ + ? ? ? setbits_le32(&power_regs->hw_power_5vctrl, POWER_5VCTRL_DCDC_XFER); + ? ? ? early_delay(30); + ? ? ? clrbits_le32(&power_regs->hw_power_5vctrl, POWER_5VCTRL_DCDC_XFER); +} + +void mx28_power_init_4p2_params(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? /* Setup 4P2 parameters */ + ? ? ? clrsetbits_le32(&power_regs->hw_power_dcdc4p2, + ? ? ? ? ? ? ? POWER_DCDC4P2_CMPTRIP_MASK | POWER_DCDC4P2_TRG_MASK, + ? ? ? ? ? ? ? POWER_DCDC4P2_TRG_4V2 | (31 << POWER_DCDC4P2_CMPTRIP_OFFSET)); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? POWER_5VCTRL_HEADROOM_ADJ_MASK, + ? ? ? ? ? ? ? 0x4 << POWER_5VCTRL_HEADROOM_ADJ_OFFSET); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_dcdc4p2, + ? ? ? ? ? ? ? POWER_DCDC4P2_DROPOUT_CTRL_MASK, + ? ? ? ? ? ? ? POWER_DCDC4P2_DROPOUT_CTRL_100MV | + ? ? ? ? ? ? ? POWER_DCDC4P2_DROPOUT_CTRL_SRC_SEL); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK, + ? ? ? ? ? ? ? 0x3f << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET); +} + +void mx28_enable_4p2_dcdc_input(int xfer) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t tmp, vbus_thresh, vbus_5vdetect, pwd_bo; + ? ? ? uint32_t prev_5v_brnout, prev_5v_droop; + + ? ? ? prev_5v_brnout = readl(&power_regs->hw_power_5vctrl) & + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_PWDN_5VBRNOUT; + ? ? ? prev_5v_droop = readl(&power_regs->hw_power_ctrl) & + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_ENIRQ_VDD5V_DROOP; + + ? ? ? clrbits_le32(&power_regs->hw_power_5vctrl, POWER_5VCTRL_PWDN_5VBRNOUT); + ? ? ? writel(POWER_RESET_UNLOCK_KEY | POWER_RESET_PWD_OFF, + ? ? ? ? ? ? ? &power_regs->hw_power_reset); + + ? ? ? clrbits_le32(&power_regs->hw_power_ctrl, POWER_CTRL_ENIRQ_VDD5V_DROOP); + + ? ? ? if (xfer && (readl(&power_regs->hw_power_5vctrl) & + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_ENABLE_DCDC)) { + ? ? ? ? ? ? ? return; + ? ? ? } + + ? ? ? /* + ? ? ? ?* Recording orignal values that will be modified temporarlily + ? ? ? ?* to handle a chip bug. See chip errata for CQ ENGR00115837 + ? ? ? ?*/ + ? ? ? tmp = readl(&power_regs->hw_power_5vctrl); + ? ? ? vbus_thresh = tmp & POWER_5VCTRL_VBUSVALID_TRSH_MASK; + ? ? ? vbus_5vdetect = tmp & POWER_5VCTRL_VBUSVALID_5VDETECT; + + ? ? ? pwd_bo = readl(&power_regs->hw_power_minpwr) & POWER_MINPWR_PWD_BO; + + ? ? ? /* + ? ? ? ?* Disable mechanisms that get erroneously tripped by when setting + ? ? ? ?* the DCDC4P2 EN_DCDC + ? ? ? ?*/ + ? ? ? clrbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? POWER_5VCTRL_VBUSVALID_5VDETECT | + ? ? ? ? ? ? ? POWER_5VCTRL_VBUSVALID_TRSH_MASK); + + ? ? ? writel(POWER_MINPWR_PWD_BO, &power_regs->hw_power_minpwr_set); + + ? ? ? if (xfer) { + ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_DCDC_XFER); + ? ? ? ? ? ? ? early_delay(20); + ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_DCDC_XFER); + + ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_ENABLE_DCDC); + ? ? ? } else { + ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_dcdc4p2, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_DCDC4P2_ENABLE_DCDC); + ? ? ? } + + ? ? ? early_delay(25); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_VBUSVALID_TRSH_MASK, vbus_thresh); + + ? ? ? if (vbus_5vdetect) + ? ? ? ? ? ? ? writel(vbus_5vdetect, &power_regs->hw_power_5vctrl_set); + + ? ? ? if (!pwd_bo) + ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_minpwr, POWER_MINPWR_PWD_BO); + + ? ? ? while (readl(&power_regs->hw_power_ctrl) & POWER_CTRL_VBUS_VALID_IRQ) + ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_ctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_VBUS_VALID_IRQ); + + ? ? ? if (prev_5v_brnout) { + ? ? ? ? ? ? ? writel(POWER_5VCTRL_PWDN_5VBRNOUT, + ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_set); + ? ? ? ? ? ? ? writel(POWER_RESET_UNLOCK_KEY, + ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_reset); + ? ? ? } else { + ? ? ? ? ? ? ? writel(POWER_5VCTRL_PWDN_5VBRNOUT, + ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_clr); + ? ? ? ? ? ? ? writel(POWER_RESET_UNLOCK_KEY | POWER_RESET_PWD_OFF, + ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_reset); + ? ? ? } + + ? ? ? while (readl(&power_regs->hw_power_ctrl) & POWER_CTRL_VDD5V_DROOP_IRQ) + ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_ctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_VDD5V_DROOP_IRQ); + + ? ? ? if (prev_5v_droop) + ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_ctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_ENIRQ_VDD5V_DROOP); + ? ? ? else + ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_ctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_ENIRQ_VDD5V_DROOP); +} + +void mx28_power_init_4p2_regulator(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t tmp, tmp2; + + ? ? ? setbits_le32(&power_regs->hw_power_dcdc4p2, POWER_DCDC4P2_ENABLE_4P2); + + ? ? ? writel(POWER_CHARGE_ENABLE_LOAD, &power_regs->hw_power_charge_set); + + ? ? ? writel(POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK, + ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_clr); + ? ? ? clrbits_le32(&power_regs->hw_power_dcdc4p2, POWER_DCDC4P2_TRG_MASK); + + ? ? ? /* Power up the 4p2 rail and logic/control */ + ? ? ? writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK, + ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_clr); + + ? ? ? /* + ? ? ? ?* Start charging up the 4p2 capacitor. We ramp of this charge + ? ? ? ?* gradually to avoid large inrush current from the 5V cable which can + ? ? ? ?* cause transients/problems + ? ? ? ?*/ + ? ? ? mx28_enable_4p2_dcdc_input(0); + + ? ? ? if (readl(&power_regs->hw_power_ctrl) & POWER_CTRL_VBUS_VALID_IRQ) { + ? ? ? ? ? ? ? /* + ? ? ? ? ? ? ? ?* If we arrived here, we were unable to recover from mx23 chip + ? ? ? ? ? ? ? ?* errata 5837. 4P2 is disabled and sufficient battery power is + ? ? ? ? ? ? ? ?* not present. Exiting to not enable DCDC power during 5V + ? ? ? ? ? ? ? ?* connected state. + ? ? ? ? ? ? ? ?*/ + ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_dcdc4p2, + ? ? ? ? ? ? ? ? ? ? ? POWER_DCDC4P2_ENABLE_DCDC); + ? ? ? ? ? ? ? writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK, + ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_set); + ? ? ? ? ? ? ? hang(); + ? ? ? } + + ? ? ? /* + ? ? ? ?* Here we set the 4p2 brownout level to something very close to 4.2V. + ? ? ? ?* We then check the brownout status. If the brownout status is false, + ? ? ? ?* the voltage is already close to the target voltage of 4.2V so we + ? ? ? ?* can go ahead and set the 4P2 current limit to our max target limit. + ? ? ? ?* If the brownout status is true, we need to ramp us the current limit + ? ? ? ?* so that we don't cause large inrush current issues. We step up the + ? ? ? ?* current limit until the brownout status is false or until we've + ? ? ? ?* reached our maximum defined 4p2 current limit. + ? ? ? ?*/ + ? ? ? clrsetbits_le32(&power_regs->hw_power_dcdc4p2, + ? ? ? ? ? ? ? ? ? ? ? POWER_DCDC4P2_BO_MASK, + ? ? ? ? ? ? ? ? ? ? ? 22 << POWER_DCDC4P2_BO_OFFSET); /* 4.15V */ + + ? ? ? if (!(readl(&power_regs->hw_power_sts) & POWER_STS_DCDC_4P2_BO)) { + ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? ? ? ? ? 0x3f << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET); + ? ? ? } else { + ? ? ? ? ? ? ? tmp = (readl(&power_regs->hw_power_5vctrl) & + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK) >> + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET; + ? ? ? ? ? ? ? while (tmp < 0x3f) { + ? ? ? ? ? ? ? ? ? ? ? if (!(readl(&power_regs->hw_power_sts) & + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_STS_DCDC_4P2_BO)) { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tmp = readl(&power_regs->hw_power_5vctrl); + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tmp |= POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK; + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? early_delay(100); + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? writel(tmp, &power_regs->hw_power_5vctrl); + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? ? ? ? ? } else { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tmp++; + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tmp2 = readl(&power_regs->hw_power_5vctrl); + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tmp2 &= ~POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK; + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tmp2 |= tmp << + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET; + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? writel(tmp2, &power_regs->hw_power_5vctrl); + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? early_delay(100); + ? ? ? ? ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? } + ? ? ? } + + ? ? ? clrbits_le32(&power_regs->hw_power_dcdc4p2, POWER_DCDC4P2_BO_MASK); + ? ? ? writel(POWER_CTRL_DCDC4P2_BO_IRQ, &power_regs->hw_power_ctrl_clr); +} + +void mx28_power_init_dcdc_4p2_source(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? if (!(readl(&power_regs->hw_power_dcdc4p2) & + ? ? ? ? ? ? ? POWER_DCDC4P2_ENABLE_DCDC)) { + ? ? ? ? ? ? ? hang(); + ? ? ? } + + ? ? ? mx28_enable_4p2_dcdc_input(1); + + ? ? ? if (readl(&power_regs->hw_power_ctrl) & POWER_CTRL_VBUS_VALID_IRQ) { + ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_dcdc4p2, + ? ? ? ? ? ? ? ? ? ? ? POWER_DCDC4P2_ENABLE_DCDC); + ? ? ? ? ? ? ? writel(POWER_5VCTRL_ENABLE_DCDC, + ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_clr); + ? ? ? ? ? ? ? writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK, + ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_set); + ? ? ? } +} + +void mx28_power_enable_4p2(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t vdddctrl, vddactrl, vddioctrl; + ? ? ? uint32_t tmp; + + ? ? ? vdddctrl = readl(&power_regs->hw_power_vdddctrl); + ? ? ? vddactrl = readl(&power_regs->hw_power_vddactrl); + ? ? ? vddioctrl = readl(&power_regs->hw_power_vddioctrl); + + ? ? ? setbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? POWER_VDDDCTRL_DISABLE_FET | POWER_VDDDCTRL_ENABLE_LINREG | + ? ? ? ? ? ? ? POWER_VDDDCTRL_PWDN_BRNOUT); + + ? ? ? setbits_le32(&power_regs->hw_power_vddactrl, + ? ? ? ? ? ? ? POWER_VDDACTRL_DISABLE_FET | POWER_VDDACTRL_ENABLE_LINREG | + ? ? ? ? ? ? ? POWER_VDDACTRL_PWDN_BRNOUT); + + ? ? ? setbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? POWER_VDDIOCTRL_DISABLE_FET | POWER_VDDIOCTRL_PWDN_BRNOUT); + + ? ? ? mx28_power_init_4p2_params(); + ? ? ? mx28_power_init_4p2_regulator(); + + ? ? ? /* Shutdown battery (none present) */ + ? ? ? clrbits_le32(&power_regs->hw_power_dcdc4p2, POWER_DCDC4P2_BO_MASK); + ? ? ? writel(POWER_CTRL_DCDC4P2_BO_IRQ, &power_regs->hw_power_ctrl_clr); + ? ? ? writel(POWER_CTRL_ENIRQ_DCDC4P2_BO, &power_regs->hw_power_ctrl_clr); + + ? ? ? mx28_power_init_dcdc_4p2_source(); + + ? ? ? writel(vdddctrl, &power_regs->hw_power_vdddctrl); + ? ? ? early_delay(20); + ? ? ? writel(vddactrl, &power_regs->hw_power_vddactrl); + ? ? ? early_delay(20); + ? ? ? writel(vddioctrl, &power_regs->hw_power_vddioctrl); + + ? ? ? /* + ? ? ? ?* Check if FET is enabled on either powerout and if so, + ? ? ? ?* disable load. + ? ? ? ?*/ + ? ? ? tmp = 0; + ? ? ? tmp |= !(readl(&power_regs->hw_power_vdddctrl) & + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_DISABLE_FET); + ? ? ? tmp |= !(readl(&power_regs->hw_power_vddactrl) & + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDACTRL_DISABLE_FET); + ? ? ? tmp |= !(readl(&power_regs->hw_power_vddioctrl) & + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDIOCTRL_DISABLE_FET); + ? ? ? if (tmp) + ? ? ? ? ? ? ? writel(POWER_CHARGE_ENABLE_LOAD, + ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_charge_clr); +} + +void mx28_boot_valid_5v(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? /* + ? ? ? ?* Use VBUSVALID level instead of VDD5V_GT_VDDIO level to trigger a 5V + ? ? ? ?* disconnect event. FIXME + ? ? ? ?*/ + ? ? ? writel(POWER_5VCTRL_VBUSVALID_5VDETECT, + ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_set); + + ? ? ? /* Configure polarity to check for 5V disconnection. */ + ? ? ? writel(POWER_CTRL_POLARITY_VBUSVALID | + ? ? ? ? ? ? ? POWER_CTRL_POLARITY_VDD5V_GT_VDDIO, + ? ? ? ? ? ? ? &power_regs->hw_power_ctrl_clr); + + ? ? ? writel(POWER_CTRL_VBUS_VALID_IRQ | POWER_CTRL_VDD5V_GT_VDDIO_IRQ, + ? ? ? ? ? ? ? &power_regs->hw_power_ctrl_clr); + + ? ? ? mx28_power_enable_4p2(); +} + +void mx28_powerdown(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? writel(POWER_RESET_UNLOCK_KEY, &power_regs->hw_power_reset); + ? ? ? writel(POWER_RESET_UNLOCK_KEY | POWER_RESET_PWD_OFF, + ? ? ? ? ? ? ? &power_regs->hw_power_reset); +} + +void mx28_handle_5v_conflict(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t tmp; + + ? ? ? setbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDIOCTRL_BO_OFFSET_MASK); + + ? ? ? for (;;) { + ? ? ? ? ? ? ? tmp = readl(&power_regs->hw_power_sts); + + ? ? ? ? ? ? ? if (tmp & POWER_STS_VDDIO_BO) { + ? ? ? ? ? ? ? ? ? ? ? mx28_powerdown(); + ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? } + + ? ? ? ? ? ? ? if (tmp & POWER_STS_VDD5V_GT_VDDIO) { + ? ? ? ? ? ? ? ? ? ? ? mx28_boot_valid_5v(); + ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? } else { + ? ? ? ? ? ? ? ? ? ? ? mx28_powerdown(); + ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? } + ? ? ? } +} + +int mx28_get_batt_volt(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t volt = readl(&power_regs->hw_power_battmonitor); + ? ? ? volt &= POWER_BATTMONITOR_BATT_VAL_MASK; + ? ? ? volt >>= POWER_BATTMONITOR_BATT_VAL_OFFSET; + ? ? ? volt *= 8; + ? ? ? return volt; +} + +int mx28_is_batt_ready(void) +{ + ? ? ? return (mx28_get_batt_volt() >= 3600); +} + +void mx28_5v_boot(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? /* + ? ? ? ?* NOTE: In original IMX-Bootlets, this also checks for VBUSVALID, + ? ? ? ?* but their implementation always returns 1 so we omit it here. + ? ? ? ?*/ + ? ? ? if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) { + ? ? ? ? ? ? ? mx28_boot_valid_5v(); + ? ? ? ? ? ? ? return; + ? ? ? } + + ? ? ? early_delay(1000); + ? ? ? if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) { + ? ? ? ? ? ? ? mx28_boot_valid_5v(); + ? ? ? ? ? ? ? return; + ? ? ? } + + ? ? ? mx28_handle_5v_conflict(); +} + +void mx28_init_batt_bo(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? /* Brownout at 3V */ + ? ? ? clrsetbits_le32(&power_regs->hw_power_battmonitor, + ? ? ? ? ? ? ? POWER_BATTMONITOR_BRWNOUT_LVL_MASK, + ? ? ? ? ? ? ? 15 << POWER_BATTMONITOR_BRWNOUT_LVL_OFFSET); + + ? ? ? writel(POWER_CTRL_BATT_BO_IRQ, &power_regs->hw_power_ctrl_clr); + ? ? ? writel(POWER_CTRL_ENIRQ_BATT_BO, &power_regs->hw_power_ctrl_clr); +} + +void mx28_switch_vddd_to_dcdc_source(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? clrsetbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_MASK, + ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_1STEPS_BELOW); + + ? ? ? clrbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? POWER_VDDDCTRL_DISABLE_FET | POWER_VDDDCTRL_ENABLE_LINREG | + ? ? ? ? ? ? ? POWER_VDDDCTRL_DISABLE_STEPPING); +} + +int mx28_is_batt_good(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t volt; + + ? ? ? volt = readl(&power_regs->hw_power_battmonitor); + ? ? ? volt &= POWER_BATTMONITOR_BATT_VAL_MASK; + ? ? ? volt >>= POWER_BATTMONITOR_BATT_VAL_OFFSET; + ? ? ? volt *= 8; + + ? ? ? if ((volt >= 2400) && (volt <= 4300)) + ? ? ? ? ? ? ? return 1; + + ? ? ? clrsetbits_le32(&power_regs->hw_power_5vctrl, + ? ? ? ? ? ? ? POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK, + ? ? ? ? ? ? ? 0x3 << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET); + ? ? ? writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK, + ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_clr); + + ? ? ? clrsetbits_le32(&power_regs->hw_power_charge, + ? ? ? ? ? ? ? POWER_CHARGE_STOP_ILIMIT_MASK | POWER_CHARGE_BATTCHRG_I_MASK, + ? ? ? ? ? ? ? POWER_CHARGE_STOP_ILIMIT_10MA | 0x3); + + ? ? ? writel(POWER_CHARGE_PWD_BATTCHRG, &power_regs->hw_power_charge_clr); + ? ? ? writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK, + ? ? ? ? ? ? ? &power_regs->hw_power_5vctrl_clr); + + ? ? ? early_delay(500000); + + ? ? ? volt = readl(&power_regs->hw_power_battmonitor); + ? ? ? volt &= POWER_BATTMONITOR_BATT_VAL_MASK; + ? ? ? volt >>= POWER_BATTMONITOR_BATT_VAL_OFFSET; + ? ? ? volt *= 8; + + ? ? ? if (volt >= 3500) + ? ? ? ? ? ? ? return 0; + + ? ? ? if (volt >= 2400) + ? ? ? ? ? ? ? return 1; + + ? ? ? writel(POWER_CHARGE_STOP_ILIMIT_MASK | POWER_CHARGE_BATTCHRG_I_MASK, + ? ? ? ? ? ? ? &power_regs->hw_power_charge_clr); + ? ? ? writel(POWER_CHARGE_PWD_BATTCHRG, &power_regs->hw_power_charge_set); + + ? ? ? return 0; +} + +void mx28_power_configure_power_source(void) +{ + ? ? ? mx28_src_power_init(); + + ? ? ? mx28_5v_boot(); + ? ? ? mx28_power_clock2pll(); + + ? ? ? mx28_init_batt_bo(); + ? ? ? mx28_switch_vddd_to_dcdc_source(); +} + +void mx28_enable_output_rail_protection(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? writel(POWER_CTRL_VDDD_BO_IRQ | POWER_CTRL_VDDA_BO_IRQ | + ? ? ? ? ? ? ? POWER_CTRL_VDDIO_BO_IRQ, &power_regs->hw_power_ctrl_clr); + + ? ? ? setbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_PWDN_BRNOUT); + + ? ? ? setbits_le32(&power_regs->hw_power_vddactrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDACTRL_PWDN_BRNOUT); + + ? ? ? setbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDIOCTRL_PWDN_BRNOUT); +} + +int mx28_get_vddio_power_source_off(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t tmp; + + ? ? ? if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) { + ? ? ? ? ? ? ? tmp = readl(&power_regs->hw_power_vddioctrl); + ? ? ? ? ? ? ? if (tmp & POWER_VDDIOCTRL_DISABLE_FET) { + ? ? ? ? ? ? ? ? ? ? ? if ((tmp & POWER_VDDIOCTRL_LINREG_OFFSET_MASK) == + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_0STEPS) { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return 1; + ? ? ? ? ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? } + + ? ? ? ? ? ? ? if (!(readl(&power_regs->hw_power_5vctrl) & + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_ENABLE_DCDC)) { + ? ? ? ? ? ? ? ? ? ? ? if ((tmp & POWER_VDDIOCTRL_LINREG_OFFSET_MASK) == + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_0STEPS) { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return 1; + ? ? ? ? ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? } + ? ? ? } + + ? ? ? return 0; + +} + +int mx28_get_vddd_power_source_off(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t tmp; + + ? ? ? tmp = readl(&power_regs->hw_power_vdddctrl); + ? ? ? if (tmp & POWER_VDDDCTRL_DISABLE_FET) { + ? ? ? ? ? ? ? if ((tmp & POWER_VDDDCTRL_LINREG_OFFSET_MASK) == + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_0STEPS) { + ? ? ? ? ? ? ? ? ? ? ? return 1; + ? ? ? ? ? ? ? } + ? ? ? } + + ? ? ? if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) { + ? ? ? ? ? ? ? if (!(readl(&power_regs->hw_power_5vctrl) & + ? ? ? ? ? ? ? ? ? ? ? POWER_5VCTRL_ENABLE_DCDC)) { + ? ? ? ? ? ? ? ? ? ? ? return 1; + ? ? ? ? ? ? ? } + ? ? ? } + + ? ? ? if (!(tmp & POWER_VDDDCTRL_ENABLE_LINREG)) { + ? ? ? ? ? ? ? if ((tmp & POWER_VDDDCTRL_LINREG_OFFSET_MASK) == + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_LINREG_OFFSET_1STEPS_BELOW) { + ? ? ? ? ? ? ? ? ? ? ? return 1; + ? ? ? ? ? ? ? } + ? ? ? } + + ? ? ? return 0; +} + +void mx28_power_set_vddio(uint32_t new_target, uint32_t new_brownout) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t cur_target, diff, bo_int = 0; + ? ? ? uint32_t powered_by_linreg = 0; + + ? ? ? new_brownout = new_target - new_brownout; + + ? ? ? cur_target = readl(&power_regs->hw_power_vddioctrl); + ? ? ? cur_target &= POWER_VDDIOCTRL_TRG_MASK; + ? ? ? cur_target *= 50; ? ? ? /* 50 mV step*/ + ? ? ? cur_target += 2800; ? ? /* 2800 mV lowest */ + + ? ? ? powered_by_linreg = mx28_get_vddio_power_source_off(); + ? ? ? if (new_target > cur_target) { + + ? ? ? ? ? ? ? if (powered_by_linreg) { + ? ? ? ? ? ? ? ? ? ? ? bo_int = readl(&power_regs->hw_power_vddioctrl); + ? ? ? ? ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_ENIRQ_VDDIO_BO); + ? ? ? ? ? ? ? } + + ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_VDDIOCTRL_BO_OFFSET_MASK); + ? ? ? ? ? ? ? do { + ? ? ? ? ? ? ? ? ? ? ? if (new_target - cur_target > 100) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diff = cur_target + 100; + ? ? ? ? ? ? ? ? ? ? ? else + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diff = new_target; + + ? ? ? ? ? ? ? ? ? ? ? diff -= 2800; + ? ? ? ? ? ? ? ? ? ? ? diff /= 50; + + ? ? ? ? ? ? ? ? ? ? ? clrsetbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_VDDIOCTRL_TRG_MASK, diff); + + ? ? ? ? ? ? ? ? ? ? ? if (powered_by_linreg) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? early_delay(1500); + ? ? ? ? ? ? ? ? ? ? ? else { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? while (!(readl(&power_regs->hw_power_sts) & + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_STS_DC_OK)) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ; + + ? ? ? ? ? ? ? ? ? ? ? } + + ? ? ? ? ? ? ? ? ? ? ? cur_target = readl(&power_regs->hw_power_vddioctrl); + ? ? ? ? ? ? ? ? ? ? ? cur_target &= POWER_VDDIOCTRL_TRG_MASK; + ? ? ? ? ? ? ? ? ? ? ? cur_target *= 50; ? ? ? /* 50 mV step*/ + ? ? ? ? ? ? ? ? ? ? ? cur_target += 2800; ? ? /* 2800 mV lowest */ + ? ? ? ? ? ? ? } while (new_target > cur_target); + + ? ? ? ? ? ? ? if (powered_by_linreg) { + ? ? ? ? ? ? ? ? ? ? ? writel(POWER_CTRL_VDDIO_BO_IRQ, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_ctrl_clr); + ? ? ? ? ? ? ? ? ? ? ? if (bo_int & POWER_CTRL_ENIRQ_VDDIO_BO) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_ENIRQ_VDDIO_BO); + ? ? ? ? ? ? ? } + ? ? ? } else { + ? ? ? ? ? ? ? do { + ? ? ? ? ? ? ? ? ? ? ? if (cur_target - new_target > 100) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diff = cur_target - 100; + ? ? ? ? ? ? ? ? ? ? ? else + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diff = new_target; + + ? ? ? ? ? ? ? ? ? ? ? diff -= 2800; + ? ? ? ? ? ? ? ? ? ? ? diff /= 50; + + ? ? ? ? ? ? ? ? ? ? ? clrsetbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_VDDIOCTRL_TRG_MASK, diff); + + ? ? ? ? ? ? ? ? ? ? ? if (powered_by_linreg) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? early_delay(1500); + ? ? ? ? ? ? ? ? ? ? ? else { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? while (!(readl(&power_regs->hw_power_sts) & + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_STS_DC_OK)) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ; + + ? ? ? ? ? ? ? ? ? ? ? } + + ? ? ? ? ? ? ? ? ? ? ? cur_target = readl(&power_regs->hw_power_vddioctrl); + ? ? ? ? ? ? ? ? ? ? ? cur_target &= POWER_VDDIOCTRL_TRG_MASK; + ? ? ? ? ? ? ? ? ? ? ? cur_target *= 50; ? ? ? /* 50 mV step*/ + ? ? ? ? ? ? ? ? ? ? ? cur_target += 2800; ? ? /* 2800 mV lowest */ + ? ? ? ? ? ? ? } while (new_target < cur_target); + ? ? ? } + + ? ? ? clrsetbits_le32(&power_regs->hw_power_vddioctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_BO_OFFSET_MASK, + ? ? ? ? ? ? ? ? ? ? ? new_brownout << POWER_VDDDCTRL_BO_OFFSET_OFFSET); +} + +void mx28_power_set_vddd(uint32_t new_target, uint32_t new_brownout) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + ? ? ? uint32_t cur_target, diff, bo_int = 0; + ? ? ? uint32_t powered_by_linreg = 0; + + ? ? ? new_brownout = new_target - new_brownout; + + ? ? ? cur_target = readl(&power_regs->hw_power_vdddctrl); + ? ? ? cur_target &= POWER_VDDDCTRL_TRG_MASK; + ? ? ? cur_target *= 25; ? ? ? /* 25 mV step*/ + ? ? ? cur_target += 800; ? ? ?/* 800 mV lowest */ + + ? ? ? powered_by_linreg = mx28_get_vddd_power_source_off(); + ? ? ? if (new_target > cur_target) { + ? ? ? ? ? ? ? if (powered_by_linreg) { + ? ? ? ? ? ? ? ? ? ? ? bo_int = readl(&power_regs->hw_power_vdddctrl); + ? ? ? ? ? ? ? ? ? ? ? clrbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_ENIRQ_VDDD_BO); + ? ? ? ? ? ? ? } + + ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_BO_OFFSET_MASK); + + ? ? ? ? ? ? ? do { + ? ? ? ? ? ? ? ? ? ? ? if (new_target - cur_target > 100) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diff = cur_target + 100; + ? ? ? ? ? ? ? ? ? ? ? else + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diff = new_target; + + ? ? ? ? ? ? ? ? ? ? ? diff -= 800; + ? ? ? ? ? ? ? ? ? ? ? diff /= 25; + + ? ? ? ? ? ? ? ? ? ? ? clrsetbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_TRG_MASK, diff); + + ? ? ? ? ? ? ? ? ? ? ? if (powered_by_linreg) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? early_delay(1500); + ? ? ? ? ? ? ? ? ? ? ? else { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? while (!(readl(&power_regs->hw_power_sts) & + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_STS_DC_OK)) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ; + + ? ? ? ? ? ? ? ? ? ? ? } + + ? ? ? ? ? ? ? ? ? ? ? cur_target = readl(&power_regs->hw_power_vdddctrl); + ? ? ? ? ? ? ? ? ? ? ? cur_target &= POWER_VDDDCTRL_TRG_MASK; + ? ? ? ? ? ? ? ? ? ? ? cur_target *= 25; ? ? ? /* 25 mV step*/ + ? ? ? ? ? ? ? ? ? ? ? cur_target += 800; ? ? ?/* 800 mV lowest */ + ? ? ? ? ? ? ? } while (new_target > cur_target); + + ? ? ? ? ? ? ? if (powered_by_linreg) { + ? ? ? ? ? ? ? ? ? ? ? writel(POWER_CTRL_VDDD_BO_IRQ, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &power_regs->hw_power_ctrl_clr); + ? ? ? ? ? ? ? ? ? ? ? if (bo_int & POWER_CTRL_ENIRQ_VDDD_BO) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? setbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_CTRL_ENIRQ_VDDD_BO); + ? ? ? ? ? ? ? } + ? ? ? } else { + ? ? ? ? ? ? ? do { + ? ? ? ? ? ? ? ? ? ? ? if (cur_target - new_target > 100) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diff = cur_target - 100; + ? ? ? ? ? ? ? ? ? ? ? else + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diff = new_target; + + ? ? ? ? ? ? ? ? ? ? ? diff -= 800; + ? ? ? ? ? ? ? ? ? ? ? diff /= 25; + + ? ? ? ? ? ? ? ? ? ? ? clrsetbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_TRG_MASK, diff); + + ? ? ? ? ? ? ? ? ? ? ? if (powered_by_linreg) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? early_delay(1500); + ? ? ? ? ? ? ? ? ? ? ? else { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? while (!(readl(&power_regs->hw_power_sts) & + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? POWER_STS_DC_OK)) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ; + + ? ? ? ? ? ? ? ? ? ? ? } + + ? ? ? ? ? ? ? ? ? ? ? cur_target = readl(&power_regs->hw_power_vdddctrl); + ? ? ? ? ? ? ? ? ? ? ? cur_target &= POWER_VDDDCTRL_TRG_MASK; + ? ? ? ? ? ? ? ? ? ? ? cur_target *= 25; ? ? ? /* 25 mV step*/ + ? ? ? ? ? ? ? ? ? ? ? cur_target += 800; ? ? ?/* 800 mV lowest */ + ? ? ? ? ? ? ? } while (new_target < cur_target); + ? ? ? } + + ? ? ? clrsetbits_le32(&power_regs->hw_power_vdddctrl, + ? ? ? ? ? ? ? ? ? ? ? POWER_VDDDCTRL_BO_OFFSET_MASK, + ? ? ? ? ? ? ? ? ? ? ? new_brownout << POWER_VDDDCTRL_BO_OFFSET_OFFSET); +} + +void mx28_power_init(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? mx28_power_clock2xtal(); + ? ? ? mx28_power_clear_auto_restart(); + ? ? ? mx28_power_set_linreg(); + ? ? ? mx28_power_setup_5v_detect(); + ? ? ? mx28_power_configure_power_source(); + ? ? ? mx28_enable_output_rail_protection(); + + ? ? ? mx28_power_set_vddio(3300, 3150); + + ? ? ? mx28_power_set_vddd(1350, 1200); + + ? ? ? writel(POWER_CTRL_VDDD_BO_IRQ | POWER_CTRL_VDDA_BO_IRQ | + ? ? ? ? ? ? ? POWER_CTRL_VDDIO_BO_IRQ | POWER_CTRL_VDD5V_DROOP_IRQ | + ? ? ? ? ? ? ? POWER_CTRL_VBUS_VALID_IRQ | POWER_CTRL_BATT_BO_IRQ | + ? ? ? ? ? ? ? POWER_CTRL_DCDC4P2_BO_IRQ, &power_regs->hw_power_ctrl_clr); + + ? ? ? writel(POWER_5VCTRL_PWDN_5VBRNOUT, &power_regs->hw_power_5vctrl_set); + + ? ? ? early_delay(1000); +} + +void mx28_power_wait_pswitch(void) +{ + ? ? ? struct mx28_power_regs *power_regs = + ? ? ? ? ? ? ? (struct mx28_power_regs *)MXS_POWER_BASE; + + ? ? ? while (!(readl(&power_regs->hw_power_sts) & POWER_STS_PSWITCH_MASK)) + ? ? ? ? ? ? ? ; +}mmc_spl/board/denx/m28evk/start.S new file +402
-0@@ -0,0 +1,402 @@ +/* + * ?armboot - Startup Code for ARM926EJS CPU-core + * + * ?Copyright (c) 2003 ?Texas Instruments + * + * ?----- Adapted for OMAP1610 OMAP730 from ARM925t code ------ + * + * ?Copyright (c) 2001 Marius Groger <[email protected]> + * ?Copyright (c) 2002 Alex Zupke <[email protected]> + * ?Copyright (c) 2002 Gary Jennejohn <[email protected]> + * ?Copyright (c) 2003 Richard Woodruff <[email protected]> + * ?Copyright (c) 2003 Kshitij <[email protected]> + * ?Copyright (c) 2010 Albert Aribaud <[email protected]> + * + * Change to support call back into iMX28 bootrom + * Copyright (c) 2011 Marek Vasut <[email protected]> + * on behalf of DENX Software Engineering GmbH + * + * 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 <asm-offsets.h> +#include <config.h> +#include <common.h> +#include <version.h> + +#if defined(CONFIG_OMAP1610) +#include <./configs/omap1510.h> +#elif defined(CONFIG_OMAP730) +#include <./configs/omap730.h> +#endif + +/* + ************************************************************************* + * + * Jump vector table as in table 3.1 in [1] + * + ************************************************************************* + */ + + +.globl _start +_start: + ? ? ? b ? ? ? reset +#ifdef CONFIG_SPL_BUILD +/* No exception handlers in preloader */ + ? ? ? ldr ? ? pc, _hang + ? ? ? ldr ? ? pc, _hang + ? ? ? ldr ? ? pc, _hang + ? ? ? ldr ? ? pc, _hang + ? ? ? b ? ? ? reset + ? ? ? ldr ? ? pc, _hang + ? ? ? ldr ? ? pc, _hang + +_hang: + ? ? ? .word ? do_hang +/* pad to 64 byte boundary */ + ? ? ? .word ? 0x12345678 + ? ? ? .word ? 0x12345678 + ? ? ? .word ? 0x12345678 + ? ? ? .word ? 0x12345678 + ? ? ? .word ? 0x12345678 + ? ? ? .word ? 0x12345678 + ? ? ? .word ? 0x12345678 +#else + ? ? ? ldr ? ? pc, _undefined_instruction + ? ? ? ldr ? ? pc, _software_interrupt + ? ? ? ldr ? ? pc, _prefetch_abort + ? ? ? ldr ? ? pc, _data_abort + ? ? ? ldr ? ? pc, _not_used + ? ? ? ldr ? ? pc, _irq + ? ? ? ldr ? ? pc, _fiq + +_undefined_instruction: + ? ? ? .word undefined_instruction +_software_interrupt: + ? ? ? .word software_interrupt +_prefetch_abort: + ? ? ? .word prefetch_abort +_data_abort: + ? ? ? .word data_abort +_not_used: + ? ? ? .word not_used +_irq: + ? ? ? .word irq +_fiq: + ? ? ? .word fiq + +#endif /* CONFIG_SPL_BUILD */ + ? ? ? .balignl 16,0xdeadbeef + + +/* + ************************************************************************* + * + * Startup Code (reset vector) + * + * do important init only if we don't start from memory! + * setup Memory and board specific bits prior to relocation. + * relocate armboot to ram + * setup stack + * + ************************************************************************* + */ + +.globl _TEXT_BASE +_TEXT_BASE: + ? ? ? .word ? CONFIG_SYS_TEXT_BASE + +/* + * These are defined in the board-specific linker script. + * Subtracting _start from them lets the linker put their + * relative position in the executable instead of leaving + * them null. + */ +.globl _bss_start_ofs +_bss_start_ofs: + ? ? ? .word __bss_start - _start + +.globl _bss_end_ofs +_bss_end_ofs: + ? ? ? .word __bss_end__ - _start + +.globl _end_ofs +_end_ofs: + ? ? ? .word _end - _start + +#ifdef CONFIG_USE_IRQ +/* IRQ stack memory (calculated at run-time) */ +.globl IRQ_STACK_START +IRQ_STACK_START: + ? ? ? .word ? 0x0badc0de + +/* IRQ stack memory (calculated at run-time) */ +.globl FIQ_STACK_START +FIQ_STACK_START: + ? ? ? .word 0x0badc0de +#endif + +/* IRQ stack memory (calculated at run-time) + 8 bytes */ +.globl IRQ_STACK_START_IN +IRQ_STACK_START_IN: + ? ? ? .word ? 0x0badc0de + +/* + * the actual reset code + */ + +reset: + ? ? ? /* + ? ? ? ?* Store all registers on old stack pointer, this will allow us later to + ? ? ? ?* return to the BootROM and let the BootROM load U-Boot into RAM. + ? ? ? ?*/ + ? ? ? push ? ?{r0-r12,r14} + + ? ? ? /* + ? ? ? ?* set the cpu to SVC32 mode + ? ? ? ?*/ + ? ? ? mrs ? ? r0,cpsr + ? ? ? bic ? ? r0,r0,#0x1f + ? ? ? orr ? ? r0,r0,#0xd3 + ? ? ? msr ? ? cpsr,r0 + + ? ? ? /* + ? ? ? ?* we do sys-critical inits only at reboot, + ? ? ? ?* not when booting from ram! + ? ? ? ?*/ +#ifndef CONFIG_SKIP_LOWLEVEL_INIT + ? ? ? bl ? ? ?cpu_init_crit +#endif + + ? ? ? bl ? ? ?board_init_ll + + ? ? ? pop ? ? {r0-r12,r14} + ? ? ? bx ? ? ?lr + +/* + ************************************************************************* + * + * CPU_init_critical registers + * + * setup important registers + * setup memory timing + * + ************************************************************************* + */ +#ifndef CONFIG_SKIP_LOWLEVEL_INIT +cpu_init_crit: + ? ? ? /* + ? ? ? ?* flush v4 I/D caches + ? ? ? ?*/ + ? ? ? mov ? ? r0, #0 + ? ? ? mcr ? ? p15, 0, r0, c7, c7, 0 ? /* flush v3/v4 cache */ + ? ? ? mcr ? ? p15, 0, r0, c8, c7, 0 ? /* flush v4 TLB */ + + ? ? ? /* + ? ? ? ?* disable MMU stuff and caches + ? ? ? ?*/ + ? ? ? mrc ? ? p15, 0, r0, c1, c0, 0 + ? ? ? bic ? ? r0, r0, #0x00002300 ? ? /* clear bits 13, 9:8 (--V- --RS) */ + ? ? ? bic ? ? r0, r0, #0x00000087 ? ? /* clear bits 7, 2:0 (B--- -CAM) */ + ? ? ? orr ? ? r0, r0, #0x00000002 ? ? /* set bit 2 (A) Align */ + ? ? ? orr ? ? r0, r0, #0x00001000 ? ? /* set bit 12 (I) I-Cache */ + ? ? ? mcr ? ? p15, 0, r0, c1, c0, 0 + + ? ? ? /* + ? ? ? ?* Go setup Memory and board specific bits prior to relocation. + ? ? ? ?*/ + ? ? ? mov ? ? ip, lr ? ? ? ? ?/* perserve link reg across call */ + ? ? ? bl ? ? ?lowlevel_init ? /* go setup pll,mux,memory */ + ? ? ? mov ? ? lr, ip ? ? ? ? ?/* restore link */ + ? ? ? mov ? ? pc, lr ? ? ? ? ?/* back to my caller */ +#endif /* CONFIG_SKIP_LOWLEVEL_INIT */ + +#ifndef CONFIG_SPL_BUILD +/* + ************************************************************************* + * + * Interrupt handling + * + ************************************************************************* + */ + +@ +@ IRQ stack frame. +@ +#define S_FRAME_SIZE ? 72 + +#define S_OLD_R0 ? ? ? 68 +#define S_PSR ? ? ? ? ?64 +#define S_PC ? ? ? ? ? 60 +#define S_LR ? ? ? ? ? 56 +#define S_SP ? ? ? ? ? 52 + +#define S_IP ? ? ? ? ? 48 +#define S_FP ? ? ? ? ? 44 +#define S_R10 ? ? ? ? ?40 +#define S_R9 ? ? ? ? ? 36 +#define S_R8 ? ? ? ? ? 32 +#define S_R7 ? ? ? ? ? 28 +#define S_R6 ? ? ? ? ? 24 +#define S_R5 ? ? ? ? ? 20 +#define S_R4 ? ? ? ? ? 16 +#define S_R3 ? ? ? ? ? 12 +#define S_R2 ? ? ? ? ? 8 +#define S_R1 ? ? ? ? ? 4 +#define S_R0 ? ? ? ? ? 0 + +#define MODE_SVC 0x13 +#define I_BIT ? 0x80 + +/* + * use bad_save_user_regs for abort/prefetch/undef/swi ... + * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling + */ + + ? ? ? .macro ?bad_save_user_regs + ? ? ? @ carve out a frame on current user stack + ? ? ? sub ? ? sp, sp, #S_FRAME_SIZE + ? ? ? stmia ? sp, {r0 - r12} ?@ Save user registers (now in svc mode) r0-r12 + ? ? ? ldr ? ? r2, IRQ_STACK_START_IN + ? ? ? @ get values for "aborted" pc and cpsr (into parm regs) + ? ? ? ldmia ? r2, {r2 - r3} + ? ? ? add ? ? r0, sp, #S_FRAME_SIZE ? ? ? ? ? @ grab pointer to old stack + ? ? ? add ? ? r5, sp, #S_SP + ? ? ? mov ? ? r1, lr + ? ? ? stmia ? r5, {r0 - r3} ? @ save sp_SVC, lr_SVC, pc, cpsr + ? ? ? mov ? ? r0, sp ? ? ? ? ?@ save current stack into r0 (param register) + ? ? ? .endm + + ? ? ? .macro ?irq_save_user_regs + ? ? ? sub ? ? sp, sp, #S_FRAME_SIZE + ? ? ? stmia ? sp, {r0 - r12} ? ? ? ? ? ? ? ? ?@ Calling r0-r12 + ? ? ? @ !!!! R8 NEEDS to be saved !!!! a reserved stack spot would be good. + ? ? ? add ? ? r8, sp, #S_PC + ? ? ? stmdb ? r8, {sp, lr}^ ? ? ? ? ? @ Calling SP, LR + ? ? ? str ? ? lr, [r8, #0] ? ? ? ? ? ?@ Save calling PC + ? ? ? mrs ? ? r6, spsr + ? ? ? str ? ? r6, [r8, #4] ? ? ? ? ? ?@ Save CPSR + ? ? ? str ? ? r0, [r8, #8] ? ? ? ? ? ?@ Save OLD_R0 + ? ? ? mov ? ? r0, sp + ? ? ? .endm + + ? ? ? .macro ?irq_restore_user_regs + ? ? ? ldmia ? sp, {r0 - lr}^ ? ? ? ? ? ? ? ? ?@ Calling r0 - lr + ? ? ? mov ? ? r0, r0 + ? ? ? ldr ? ? lr, [sp, #S_PC] ? ? ? ? ? ? ? ? @ Get PC + ? ? ? add ? ? sp, sp, #S_FRAME_SIZE + ? ? ? subs ? ?pc, lr, #4 ? ? ? ? ? ? ?@ return & move spsr_svc into cpsr + ? ? ? .endm + + ? ? ? .macro get_bad_stack + ? ? ? ldr ? ? r13, IRQ_STACK_START_IN ? ? ? ? @ setup our mode stack + + ? ? ? str ? ? lr, [r13] ? ? ? @ save caller lr in position 0 of saved stack + ? ? ? mrs ? ? lr, spsr ? ? ? ?@ get the spsr + ? ? ? str ? ? lr, [r13, #4] ? @ save spsr in position 1 of saved stack + ? ? ? mov ? ? r13, #MODE_SVC ?@ prepare SVC-Mode + ? ? ? @ msr ? spsr_c, r13 + ? ? ? msr ? ? spsr, r13 ? ? ? @ switch modes, make sure moves will execute + ? ? ? mov ? ? lr, pc ? ? ? ? ?@ capture return pc + ? ? ? movs ? ?pc, lr ? ? ? ? ?@ jump to next instruction & switch modes. + ? ? ? .endm + + ? ? ? .macro get_irq_stack ? ? ? ? ? ? ? ? ? ?@ setup IRQ stack + ? ? ? ldr ? ? sp, IRQ_STACK_START + ? ? ? .endm + + ? ? ? .macro get_fiq_stack ? ? ? ? ? ? ? ? ? ?@ setup FIQ stack + ? ? ? ldr ? ? sp, FIQ_STACK_START + ? ? ? .endm +#endif /* CONFIG_SPL_BUILD */ + +/* + * exception handlers + */ +#ifdef CONFIG_SPL_BUILD + ? ? ? .align ?5 +do_hang: + ? ? ? ldr ? ? sp, _TEXT_BASE ? ? ? ? ? ? ? ? ?/* switch to abort stack */ +1: + ? ? ? bl ? ? ?1b ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* hang and never return */ +#else ?/* !CONFIG_SPL_BUILD */ + ? ? ? .align ?5 +undefined_instruction: + ? ? ? get_bad_stack + ? ? ? bad_save_user_regs + ? ? ? bl ? ? ?do_undefined_instruction + + ? ? ? .align ?5 +software_interrupt: + ? ? ? get_bad_stack + ? ? ? bad_save_user_regs + ? ? ? bl ? ? ?do_software_interrupt + + ? ? ? .align ?5 +prefetch_abort: + ? ? ? get_bad_stack + ? ? ? bad_save_user_regs + ? ? ? bl ? ? ?do_prefetch_abort + + ? ? ? .align ?5 +data_abort: + ? ? ? get_bad_stack + ? ? ? bad_save_user_regs + ? ? ? bl ? ? ?do_data_abort + + ? ? ? .align ?5 +not_used: + ? ? ? get_bad_stack + ? ? ? bad_save_user_regs + ? ? ? bl ? ? ?do_not_used + +#ifdef CONFIG_USE_IRQ + + ? ? ? .align ?5 +irq: + ? ? ? get_irq_stack + ? ? ? irq_save_user_regs + ? ? ? bl ? ? ?do_irq + ? ? ? irq_restore_user_regs + + ? ? ? .align ?5 +fiq: + ? ? ? get_fiq_stack + ? ? ? /* someone ought to write a more effiction fiq_save_user_regs */ + ? ? ? irq_save_user_regs + ? ? ? bl ? ? ?do_fiq + ? ? ? irq_restore_user_regs + +#else + + ? ? ? .align ?5 +irq: + ? ? ? get_bad_stack + ? ? ? bad_save_user_regs + ? ? ? bl ? ? ?do_irq + + ? ? ? .align ?5 +fiq: + ? ? ? get_bad_stack + ? ? ? bad_save_user_regs + ? ? ? bl ? ? ?do_fiq + +#endif +#endif /* CONFIG_SPL_BUILD */mmc_spl/board/denx/m28evk/u-boot.bd new file +14
-0@@ -0,0 +1,14 @@ +sources { + ? ? ? u_boot_spl="mmc_spl/u-boot-spl.bin"; + ? ? ? u_boot="u-boot.bin"; +} + +section (0) { + ? ? ? ?load u_boot_spl > 0x0000; + ? ? ? ?load ivt (entry = 0x0014) > 0x8000; + ? ? ? hab call 0x8000; + + ? ? ? ?load u_boot > 0x40000100; + ? ? ? ?load ivt (entry = 0x40000100) > 0x8000; + ? ? ? hab call 0x8000; +}mmc_spl/board/denx/m28evk/u-boot.lds new file +87
-1@@ -0,0 +1,87 @@ +/* + * Copyright (C) 2011 Marek Vasut <[email protected]> + * on behalf of DENX Software Engineering GmbH + * + * January 2004 - Changed to support H4 device + * Copyright (c) 2004-2008 Texas Instruments + * + * (C) Copyright 2002 + * Gary Jennejohn, DENX Software Engineering, <[email protected]> + * + * 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 + */ + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + ? ? ? . = 0x00000000; + + ? ? ? . = ALIGN(4); + ? ? ? .text ? : + ? ? ? { + ? ? ? ? ? ? ? start.o (.text) + ? ? ? ? ? ? ? *(.text) + ? ? ? } + + ? ? ? . = ALIGN(4); + ? ? ? .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } + + ? ? ? . = ALIGN(4); + ? ? ? .data : { + ? ? ? ? ? ? ? *(.data) + ? ? ? } + + ? ? ? . = ALIGN(4); + ? ? ? __u_boot_cmd_start = .; + ? ? ? .u_boot_cmd : { *(.u_boot_cmd) } + ? ? ? __u_boot_cmd_end = .; + + ? ? ? . = ALIGN(4); + + ? ? ? .rel.dyn : { + ? ? ? ? ? ? ? __rel_dyn_start = .; + ? ? ? ? ? ? ? *(.rel*) + ? ? ? ? ? ? ? __rel_dyn_end = .; + ? ? ? } + + ? ? ? .dynsym : { + ? ? ? ? ? ? ? __dynsym_start = .; + ? ? ? ? ? ? ? *(.dynsym) + ? ? ? } + + ? ? ? _end = .; + + ? ? ? .bss __rel_dyn_start (OVERLAY) : { + ? ? ? ? ? ? ? __bss_start = .; + ? ? ? ? ? ? ? *(.bss) + ? ? ? ? ? ? ? ?. = ALIGN(4); + ? ? ? ? ? ? ? __bss_end__ = .; + ? ? ? } + + ? ? ? /DISCARD/ : { *(.bss*) } + ? ? ? /DISCARD/ : { *(.dynstr*) } + ? ? ? /DISCARD/ : { *(.dynsym*) } + ? ? ? /DISCARD/ : { *(.dynamic*) } + ? ? ? /DISCARD/ : { *(.hash*) } + ? ? ? /DISCARD/ : { *(.plt*) } + ? ? ? /DISCARD/ : { *(.interp*) } + ? ? ? /DISCARD/ : { *(.gnu*) } +} --1.7.5.4
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
--
with warm regards,
Chander Kashyap
PATCH 14/31 iMX28: Add MMC SPL
Dear Chander Kashyap,
Quoted 2 lines · In message <CANuQgHE26ewWMXqW=wwhRy6J8n3bzmvKKRVCnm_Y+79x3oKVfw@mail.gmail.com>…
Dear Marek Vasut,
Please use newly added spl framework to add mmc spl support.
Please STOP top posting / full quoting!!!
Please read http://www.netmeister.org/news/learn2quote.html
It makes _zero_ sense to quote 2500 lines just for your single line remark.
And please always send plain text only; never use HTML.
Thanks.
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Always leave room to add an explanation if it doesn't work out.
A message that is not in the archive (sent off-list or not yet received): CANuQgHH_p-_HRf_jBKiPZz=br0+aCyWROWzHDZgV47xWg97aiQ@mail.gmail.com
PATCH 14/31 iMX28: Add MMC SPL
Quoted 3 lines · Chander Kashyap
Dear Marek Vasut,
Please use newly added spl framework to add mmc spl support.
Hi,
if you could possibly elaborate more on this matter, I'd be grateful. Especially how am I supposed to convert it to new SPL framework. I don't see many examples, only an empty directory.
Cheers
PATCH 14/31 iMX28: Add MMC SPL
2011/9/9 Marek Vasut <[email protected]>:
Quoted 10 lines · Chander Kashyap
Quoted 3 lines
Dear Marek Vasut,
Please use newly added spl framework to add mmc spl support.Hi,
if you could possibly elaborate more on this matter, I'd be grateful. Especially how am I supposed to convert it to new SPL framework. I don't see many examples, only an empty directory.
Please see the implementation of origen board(board/samsung/origen). Its newly added.
May be you can move mmc_spl/board/denx/m28evk/* to board/denx/m28evk/* define CONFIG_SPL_LDSCRIPT to the ldscript you want to use (Please read spl/Makefile line 64 onward).
Quoted 3 lines
Cheers
Signature · 2 lines
with warm regards, Chander Kashyap
PATCH 14/31 iMX28: Add MMC SPL
Quoted 11 lines · Chander Kashyap
2011/9/9 Marek Vasut <[email protected]>:
Quoted 9 lines · Chander Kashyap
Quoted 2 lines
Dear Marek Vasut,
Please use newly added spl framework to add mmc spl support.Hi,
if you could possibly elaborate more on this matter, I'd be grateful. Especially how am I supposed to convert it to new SPL framework. I don't see many examples, only an empty directory.
Quoted 5 lines
Please see the implementation of origen board(board/samsung/origen). Its newly added.
May be you can move mmc_spl/board/denx/m28evk/* to board/denx/m28evk/* defineCONFIG_SPL_LDSCRIPTto the ldscript you want to use (Please read spl/Makefile line 64 onward).
Ok, I went through it (partly). Why do you create executables with .exe suffix there ? Is that some kind of a new trend in embedded linux industry?
Quoted 2 lines
Quoted 2 lines
Cheers
PATCH 14/31 iMX28: Add MMC SPL
Quoted 18 lines · Marek Vasut
Quoted 11 lines · Chander Kashyap
2011/9/9 Marek Vasut <[email protected]>:
Quoted 9 lines · Chander Kashyap
Quoted 2 lines
Dear Marek Vasut,
Please use newly added spl framework to add mmc spl support.Hi,
if you could possibly elaborate more on this matter, I'd be grateful. Especially how am I supposed to convert it to new SPL framework. I don't see many examples, only an empty directory.
Quoted 5 lines
Please see the implementation of origen board(board/samsung/origen). Its newly added.
May be you can move mmc_spl/board/denx/m28evk/* to board/denx/m28evk/* defineCONFIG_SPL_LDSCRIPTto the ldscript you want to use (Please read spl/Makefile line 64 onward).
Quoted 3 lines
Ok, I went through it (partly). Why do you create executables with .exe suffix there ? Is that some kind of a new trend in embedded linux industry?
Oh, one more thing -- is it possible to use custom start.S with the new "spl framework"? I somehow need it.
Thanks!
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Cheers
PATCH 15/31 M28: Enable MMC SPL
In reply to Marek Vasut--- include/configs/m28evk.h | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
include/configs/m28evk.h +9 -2
@@ -69,8 +69,14 @@#define CONFIG_SYS_MEMTEST_START 0x40000000/* Memtest start adr */ #define CONFIG_SYS_MEMTEST_END 0x40400000/* 4 MB RAM test */ #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 -#define CONFIG_SYS_INIT_SP_ADDR 0x18000 -#define CONFIG_SYS_TEXT_BASE 0x40000000 +/* Point initial SP in SRAM so SPL can use it too. */ +#define CONFIG_SYS_INIT_SP_ADDR 0x00002000 +/* +* We need to sacrifice first 4 bytes of RAM here to avoid triggering some +* strange BUG in ROM corrupting first 4 bytes of RAM when loading U-Boot +* binary. In case there was more of this mess, 0x100 bytes are skipped. +*/ +#define CONFIG_SYS_TEXT_BASE 0x40000100/* * U-Boot general configurations
@@ -107,6 +113,7 @@#define CONFIG_MMC #define CONFIG_GENERIC_MMC #define CONFIG_MXS_MMC +#define CONFIG_MMC_U_BOOT #endif /*
Signature · 1 line
1.7.5.4
PATCH 16/31 iMX28: Add GPIO control
In reply to Marek Vasut--- arch/arm/cpu/arm926ejs/mx28/Makefile | 2 +- arch/arm/cpu/arm926ejs/mx28/gpio.c | 108 +++++++++++++++++++++++++++++++++ arch/arm/cpu/arm926ejs/mx28/mx28.c | 10 +++ arch/arm/include/asm/arch-mx28/gpio.h | 32 ++++++++++ 4 files changed, 151 insertions(+), 1 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/mx28/gpio.c create mode 100644 arch/arm/include/asm/arch-mx28/gpio.h
arch/arm/cpu/arm926ejs/mx28/Makefile +1 -1
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).o -COBJS = clock.o mx28.o iomux.o timer.o +COBJS = clock.o mx28.o gpio.o iomux.o timer.o SRCS := $(START:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
arch/arm/cpu/arm926ejs/mx28/gpio.c new file +108 -0
108 lines not on this page · raw message
arch/arm/cpu/arm926ejs/mx28/mx28.c +10 -0
@@ -30,6 +30,8 @@#include <asm/errno.h> #include <asm/io.h> #include <asm/arch/clock.h> +#include <asm/arch/iomux.h> +#include <asm/arch/gpio.h> #include <asm/arch/regs-common.h> #include <asm/arch/regs-base.h> #include <asm/arch/regs-clkctrl.h>
@@ -118,6 +120,14 @@ int mx28_reset_block(struct mx28_register *reg)return 0 ; } +#ifdef CONFIG_ARCH_CPU_INIT +int arch_cpu_init (void ) +{ +mxs_gpio_init (); +return 0 ; +} +#endif +#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void ) {
arch/arm/include/asm/arch-mx28/gpio.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Freescale i.MX28 GPIO +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 __GPIO_H__ +#define __GPIO_H__ + +void mxs_gpio_set (iomux_cfg_t pad,int value); +int mxs_gpio_get (iomux_cfg_t pad); +void mxs_gpio_direction (iomux_cfg_t pad,int output); + +void mxs_gpio_init (void ); + +#endif /* __GPIO_H__ */
Signature · 1 line
1.7.5.4
PATCH 16/31 iMX28: Add GPIO control
arch/arm/cpu/arm926ejs/mx28/gpio.c
Quoted 27 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- arch/arm/cpu/arm926ejs/mx28/Makefile | 2 +- arch/arm/cpu/arm926ejs/mx28/gpio.c | 108 +++++++++++++++++++++++++++++++++ arch/arm/cpu/arm926ejs/mx28/mx28.c | 10 +++ arch/arm/include/asm/arch-mx28/gpio.h | 32 ++++++++++ 4 files changed, 151 insertions(+), 1 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/mx28/gpio.c create mode 100644 arch/arm/include/asm/arch-mx28/gpio.harch/arm/cpu/arm926ejs/mx28/Makefile +1
-1@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).o -COBJS = clock.o mx28.o iomux.o timer.o +COBJS = clock.o mx28.o gpio.o iomux.o timer.o SRCS := $(START:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))arch/arm/cpu/arm926ejs/mx28/gpio.c +0
-0
No. All drivers go into the drivers directory (we try to follow the Linux's rule..).
See drivers/gpio/.
As name, I suggest you steal the name from kernel (mxs_gpio.c seems to me appropriate).
As remark: in the kernel, the structure for this SOC are identified by the prefix mxs. This is valid for both MX28 and MX23. I want only to point out how it is done in the kernel, I know we have not (yet) support for MX23 in u-boot. Any chance to uniform names with the kernel ?
Quoted 30 lines
new file mode 100644
index 0000000..00d2ccaarch/arm/cpu/arm926ejs/mx28/gpio.c new file +25
-0@@ -0,0 +1,108 @@ +/* +* Freescale i.MX28 GPIO control code +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 +*/ +
arch/arm/cpu/arm926ejs/mx28/gpio.c line 35
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/gpio.c new file +10
-0+#include <common.h> +#include <netdev.h> +#include <asm/errno.h> +#include <asm/io.h> +#include <asm/arch/clock.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/iomux.h> + +#if defined(CONFIG_MX23 )
Ok. So you *want* to add support for MX23, too. Thanks for doing that !
Then probably the name "mxs" is not very far to be used....
arch/arm/cpu/arm926ejs/mx28/gpio.c line 42
Quoted 7 lines
arch/arm/cpu/arm926ejs/mx28/gpio.c new file +7
-0+#define PINCTRL_BANKS 3 +#define PINCTRL_DOUT (n) (0x0500 + ((n) * 0x10)) +#define PINCTRL_DIN (n) (0x0600 + ((n) * 0x10)) +#define PINCTRL_DOE (n) (0x0700 + ((n) * 0x10)) +#define PINCTRL_PIN2IRQ (n) (0x0800 + ((n) * 0x10)) +#define PINCTRL_IRQEN (n) (0x0900 + ((n) * 0x10)) +#define PINCTRL_IRQSTAT (n) (0x0c00 + ((n) * 0x10))
No structures for that ?
arch/arm/cpu/arm926ejs/mx28/gpio.c line 44
Quoted 2 lines
arch/arm/cpu/arm926ejs/mx28/gpio.c new file +2
-0+void mxs_gpio_direction (iomux_cfg_t pad,int output) +{
This is not correct. Blackfin addes as first a common way to use gpio, and we try to uniform the other SOC to the same rule. We should have not special SOC_something_gpio_function.
The interface is in asm/asm/gpio.h. Each SOC must implement (you can check on other i.MX SOCs) only those functions:
int gpio_request(int gp, const char *label);
void gpio_free(int gp);
void gpio_toggle_value(int gp);
int gpio_direction_input(int gp);
int gpio_direction_output(int gp, int value);
int gpio_get_value(int gp);
void gpio_set_value(int gp, int value);
This is the common interface - special definition for each SOC can be put into asm/arch/gpio.h
arch/arm/cpu/arm926ejs/mx28/gpio.c line 107
Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/gpio.c new file +10
-0+void mxs_gpio_init (void ) +{ +int i; + +for (i =0 ; i <PINCTRL_BANKS ; i++) { +writel (0 ,MXS_PINCTRL_BASE +PINCTRL_PIN2IRQ (i)); +writel (0 ,MXS_PINCTRL_BASE +PINCTRL_IRQEN (i)); +/* Use SCT address here to clear the IRQSTAT bits */ +writel (0xffffffff ,MXS_PINCTRL_BASE +PINCTRL_IRQSTAT (i) +8 ); + }
I am not sure this stuff should be done here. It should be responsibility of the board maintainer to execute it - not only, to decide how to set up the pinmux at all.
Quoted 14 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +2
-0@@ -30,6 +30,8 @@#include <asm/errno.h> #include <asm/io.h> #include <asm/arch/clock.h> +#include <asm/arch/iomux.h> +#include <asm/arch/gpio.h> #include <asm/arch/regs-common.h> #include <asm/arch/regs-base.h> #include <asm/arch/regs-clkctrl.h>
arch/arm/cpu/arm926ejs/mx28/mx28.c int mx28_reset_block(struct mx28_register *reg) · line 128
Quoted 9 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +6
-0@@ -118,6 +120,14 @@ int mx28_reset_block(struct mx28_register *reg)return 0 ; } +#ifdef CONFIG_ARCH_CPU_INIT +int arch_cpu_init (void ) +{ +mxs_gpio_init (); +return 0 ; +}
Please squash your patches - I am already confused after a few patches.
Quoted 29 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +2
-0+#endif +#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void ) {arch/arm/include/asm/arch-mx28/gpio.h new file +18
-0@@ -0,0 +1,32 @@ +/* +* Freescale i.MX28 GPIO +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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
arch/arm/include/asm/arch-mx28/gpio.h line 28
Quoted 10 lines
arch/arm/include/asm/arch-mx28/gpio.h new file +10
-0+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +*/ + +#ifndef __GPIO_H__ +#define __GPIO_H__ + +void mxs_gpio_set (iomux_cfg_t pad,int value); +int mxs_gpio_get (iomux_cfg_t pad); +void mxs_gpio_direction (iomux_cfg_t pad,int output);
No. This file should be dropped, it is not required.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 17/31 M28: Enable use of GPIO configurators
In reply to Marek Vasut--- include/configs/m28evk.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
include/configs/m28evk.h +1 -0
@@ -35,6 +35,7 @@#define CONFIG_SYS_ICACHE_OFF #define CONFIG_SYS_DCACHE_OFF #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_ARCH_CPU_INIT /* * U-Boot Commands
Signature · 1 line
1.7.5.4
PATCH 18/31 iMX28: Add SPI driver
In reply to Marek Vasut--- drivers/spi/Makefile | 1 + drivers/spi/mxs_spi.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/mxs_spi.c
drivers/spi/Makefile +1 -0
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o +COBJS-$(CONFIG_MXS_SPI) += mxs_spi.o COBJS-$(CONFIG_OC_TINY_SPI) += oc_tiny_spi.o COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/mxs_spi.c new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 18/31 iMX28: Add SPI driver
drivers/spi/mxs_spi.c
Quoted 16 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- drivers/spi/Makefile | 1 + drivers/spi/mxs_spi.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/mxs_spi.cdrivers/spi/mxs_spi.c new file +0
-0
Ok - now I am sure and I agree with your choice. Please then use mxs consequently in all files.
Quoted 26 lines
drivers/spi/mxs_spi.c new file +25
-0@@ -0,0 +1,174 @@ +/* +* Freescale i.MX28 SPI driver +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 <malloc.h> +#include <spi.h>
drivers/spi/mxs_spi.c line 35
Quoted 10 lines
drivers/spi/mxs_spi.c new file +10
-0+#include <asm/errno.h> +#include <asm/io.h> +#include <asm/arch/clock.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-ssp.h> +#include <asm/arch/iomux-mx28.h> +#include <asm/arch/gpio.h> +#include <asm/arch/mx28.h>
General comment: drop this stuff and include only imx-regs.h
Quoted 5 lines
drivers/spi/mxs_spi.c new file +5
-0+ +#define MXS_SPI_MAX_TIMEOUT 1000000 + +static inline struct mx28_ssp_regs *to_mxs_regs (struct spi_slave *slave) +{
drivers/spi/mxs_spi.c line 50
Quoted 10 lines
drivers/spi/mxs_spi.c new file +10
-0+return (struct mx28_ssp_regs *)(MXS_SSP0_BASE + (slave->bus *0x2000 )); +} + +void spi_init (void ) +{ +} + +struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, +unsigned int max_hz,unsigned int mode) +{
Only the CS supplied in the SOC are supported, it is not possible to use a GPIO. Please add a comment to explain that.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 18/31 iMX28: Add SPI driver
Quoted 71 lines · Stefano Babic
drivers/spi/mxs_spi.c
Quoted 17 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
drivers/spi/Makefile | 1 + drivers/spi/mxs_spi.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/mxs_spi.cdrivers/spi/mxs_spi.c new file +0
-0Ok - now I am sure and I agree with your choice. Please then use mxs consequently in all files.
Quoted 26 lines
drivers/spi/mxs_spi.c new file +25
-0@@ -0,0 +1,174 @@ +/* +* Freescale i.MX28 SPI driver +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* 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 <malloc.h> +#include <spi.h> drivers/spi/mxs_spi.c line 35
Quoted 10 lines
drivers/spi/mxs_spi.c new file +10
-0+#include <asm/errno.h> +#include <asm/io.h> +#include <asm/arch/clock.h> +#include <asm/arch/regs-common.h> +#include <asm/arch/regs-base.h> +#include <asm/arch/regs-clkctrl.h> +#include <asm/arch/regs-ssp.h> +#include <asm/arch/iomux-mx28.h> +#include <asm/arch/gpio.h> +#include <asm/arch/mx28.h> General comment: drop this stuff and include only
imx-regs.hQuoted 10 lines
drivers/spi/mxs_spi.c new file +10
-0+ +#define MXS_SPI_MAX_TIMEOUT 1000000 + +static inline struct mx28_ssp_regs *to_mxs_regs (struct spi_slave *slave) +{ +return (struct mx28_ssp_regs *)(MXS_SSP0_BASE + (slave->bus *0x2000 )); +} + +void spi_init (void ) +{
Quoted 8 lines
drivers/spi/mxs_spi.c line 50
Quoted 5 lines
drivers/spi/mxs_spi.c new file +5
-0+} + +struct spi_slave *spi_setup_slave (unsigned int bus,unsigned int cs, +unsigned int max_hz,unsigned int mode) +{Only the CS supplied in the SOC are supported, it is not possible to use a GPIO. Please add a comment to explain that.
I don't think I understand here.
Quoted 3 lines
Best regards,
Stefano Babic
PATCH 18/31 iMX28: Add SPI driver
Quoted 3 lines · Marek Vasut
Quoted 3 lines
Only the CS supplied in the SOC are supported, it is not possible to use a GPIO. Please add a comment to explain that.
If you see other SPI drivers (mxc_spi.c, or blackfin, and other, too) the CS is or can be implemented with a gpio. Some architecture have a board specific spi_cs_activate.
In your driver, only the CS of the SPI controller are supported. My only remark is if we can add a comment to explain this.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 18/31 iMX28: Add SPI driver
Quoted 11 lines · Stefano Babic
Quoted 2 lines · Marek Vasut
Quoted 2 lines
Only the CS supplied in the SOC are supported, it is not possible to use a GPIO. Please add a comment to explain that.
If you see other SPI drivers (
mxc_spi.c, or blackfin, and other, too) the CS is or can be implemented with a gpio. Some architecture have a board specificspi_cs_activate.In your driver, only the CS of the SPI controller are supported. My only remark is if we can add a comment to explain this.
Done,cheers
Quoted 2 lines
Best regards,
Stefano Babic
PATCH 19/31 M28EVK: Enable SPI and SPI flash
In reply to Marek Vasut--- include/configs/m28evk.h | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
include/configs/m28evk.h +27 -0
@@ -57,6 +57,8 @@#define CONFIG_CMD_NFS #define CONFIG_CMD_PING #define CONFIG_CMD_SETEXPR +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI /* * Memory configurations
@@ -157,6 +159,31 @@#endif /* +* SPI +*/ +#ifdef CONFIG_CMD_SPI +#define CONFIG_HARD_SPI +#define CONFIG_MXS_SPI +#define CONFIG_SPI_HALF_DUPLEX +#define CONFIG_DEFAULT_SPI_BUS 2 +#define CONFIG_DEFAULT_SPI_MODE SPI_MODE_0 + +/* SPI FLASH */ +#ifdef CONFIG_CMD_SF +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_STMICRO +#define CONFIG_SPI_FLASH_CS 2 +#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0 +#define CONFIG_SF_DEFAULT_SPEED 24000000 + +#define CONFIG_ENV_SPI_CS 0 +#define CONFIG_ENV_SPI_BUS 2 +#define CONFIG_ENV_SPI_MAX_HZ 24000000 +#define CONFIG_ENV_SPI_MODE SPI_MODE_0 +#endif +#endif + +/* * Boot Linux */ #define CONFIG_CMDLINE_TAG
Signature · 1 line
1.7.5.4
PATCH 20/31 iMX28: Add APBH DMA driver
In reply to Marek Vasut--- arch/arm/include/asm/arch-mx28/dma.h | 170 +++++++ arch/arm/include/asm/arch-mx28/regs-apbh.h | 462 ++++++++++++++++++ drivers/dma/Makefile | 1 + drivers/dma/apbh_dma.c | 693 ++++++++++++++++++++++++++++ 4 files changed, 1326 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-mx28/dma.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-apbh.h create mode 100644 drivers/dma/apbh_dma.c
arch/arm/include/asm/arch-mx28/dma.h new file +170 -0
@@ -0,0 +1,170 @@ +/* +* Freescale i.MX28 APBH DMA +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* Based on code from LTIB: +* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* 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 __DMA_H__ +#define __DMA_H__ + +#include <linux/list.h> + +#ifndef CONFIG_ARCH_DMA_PIO_WORDS +#define DMA_PIO_WORDS 15 +#else +#define DMA_PIO_WORDS CONFIG_ARCH_DMA_PIO_WORDS +#endif + +#define MXS_DMA_ALIGNMENT 32 + +/* +* MXS DMA channels +*/ +enum { +MXS_DMA_CHANNEL_AHB_APBH_SSP0 =0 , +MXS_DMA_CHANNEL_AHB_APBH_SSP1 , +MXS_DMA_CHANNEL_AHB_APBH_SSP2 , +MXS_DMA_CHANNEL_AHB_APBH_SSP3 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI0 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI1 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI2 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI3 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI4 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI5 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI6 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI7 , +MXS_DMA_CHANNEL_AHB_APBH_SSP , +MXS_MAX_DMA_CHANNELS , +}; + +/* +* MXS DMA hardware command. +* +* This structure describes the in-memory layout of an entire DMA command, +* including space for the maximum number of PIO accesses. See the appropriate +* reference manual for a detailed description of what these fields mean to the +* DMA hardware. +*/ +#define MXS_DMA_DESC_COMMAND_MASK 0x3 +#define MXS_DMA_DESC_COMMAND_OFFSET 0 +#define MXS_DMA_DESC_COMMAND_NO_DMAXFER 0x0 +#define MXS_DMA_DESC_COMMAND_DMA_WRITE 0x1 +#define MXS_DMA_DESC_COMMAND_DMA_READ 0x2 +#define MXS_DMA_DESC_COMMAND_DMA_SENSE 0x3 +#define MXS_DMA_DESC_CHAIN (1 << 2) +#define MXS_DMA_DESC_IRQ (1 << 3) +#define MXS_DMA_DESC_NAND_LOCK (1 << 4) +#define MXS_DMA_DESC_NAND_WAIT_4_READY (1 << 5) +#define MXS_DMA_DESC_DEC_SEM (1 << 6) +#define MXS_DMA_DESC_WAIT4END (1 << 7) +#define MXS_DMA_DESC_HALT_ON_TERMINATE (1 << 8) +#define MXS_DMA_DESC_TERMINATE_FLUSH (1 << 9) +#define MXS_DMA_DESC_PIO_WORDS_MASK (0xf << 12) +#define MXS_DMA_DESC_PIO_WORDS_OFFSET 12 +#define MXS_DMA_DESC_BYTES_MASK (0xffff << 16) +#define MXS_DMA_DESC_BYTES_OFFSET 16 + +struct mxs_dma_cmd { +unsigned long next; +unsigned long data; +union { +dma_addr_t address; +unsigned long alternate; + }; +unsigned long pio_words[DMA_PIO_WORDS ]; +}; + +/* +* MXS DMA command descriptor. +* +* This structure incorporates an MXS DMA hardware command structure, along +* with metadata. +*/ +#define MXS_DMA_DESC_FIRST (1 << 0) +#define MXS_DMA_DESC_LAST (1 << 1) +#define MXS_DMA_DESC_READY (1 << 31) + +struct mxs_dma_desc { +struct mxs_dma_cmd cmd; +unsigned int flags; +dma_addr_t address; +void *buffer; +struct list_head node; +}; + +/** +* MXS DMA channel +* +* This structure represents a single DMA channel. The MXS platform code +* maintains an array of these structures to represent every DMA channel in the +* system (see mxs_dma_channels). +*/ +#define MXS_DMA_FLAGS_IDLE 0 +#define MXS_DMA_FLAGS_BUSY (1 << 0) +#define MXS_DMA_FLAGS_FREE 0 +#define MXS_DMA_FLAGS_ALLOCATED (1 << 16) +#define MXS_DMA_FLAGS_VALID (1 << 31) + +struct mxs_dma_chan { +const char *name; +unsigned long dev; +struct mxs_dma_device *dma; +unsigned int flags; +unsigned int active_num; +unsigned int pending_num; +struct list_head active; +struct list_head done; +}; + +/* Hardware management ops */ +int mxs_dma_enable (int channel); +int mxs_dma_disable (int channel); +int mxs_dma_reset (int channel); +int mxs_dma_freeze (int channel); +int mxs_dma_unfreeze (int channel); +int mxs_dma_read_semaphore (int channel); +int mxs_dma_enable_irq (int channel,int enable); +int mxs_dma_irq_is_pending (int channel); +int mxs_dma_ack_irq (int channel); + +/* Channel management ops */ +int mxs_dma_request (int channel); +int mxs_dma_release (int channel); + +/* Descriptor management ops */ +struct mxs_dma_desc *mxs_dma_desc_alloc (void ); +void mxs_dma_desc_free (struct mxs_dma_desc *); + +unsigned int mxs_dma_cmd_address (struct mxs_dma_desc *desc); +int mxs_dma_desc_pending (struct mxs_dma_desc *pdesc); + +int mxs_dma_desc_append (int channel,struct mxs_dma_desc *pdesc); + +int mxs_dma_get_finished (int channel,struct list_head *head); +int mxs_dma_finish (int channel,struct list_head *head); + +int mxs_dma_wait_complete (uint32_t timeout,unsigned int chan); +int mxs_dma_go (int chan); + +int mxs_dma_init (void ); + +#endif /* __DMA_H__ */
arch/arm/include/asm/arch-mx28/regs-apbh.h new file +462 -0
462 lines not on this page · raw message
drivers/dma/Makefile +1 -0
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libdma.o COBJS-$(CONFIG_FSLDMAFEC) += MCD_tasksInit.o MCD_dmaApi.o MCD_tasks.o +COBJS-$(CONFIG_APBH_DMA) += apbh_dma.o COBJS-$(CONFIG_FSL_DMA) += fsl_dma.o COBJS := $(COBJS-y)
drivers/dma/apbh_dma.c new file +693 -0
693 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 21/31 iMX28: Add BCH and GPMI register definitions
In reply to Marek Vasut--- arch/arm/include/asm/arch-mx28/regs-bch.h | 226 ++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx28/regs-gpmi.h | 218 +++++++++++++++++++++++++++ 2 files changed, 444 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-mx28/regs-bch.h create mode 100644 arch/arm/include/asm/arch-mx28/regs-gpmi.h
arch/arm/include/asm/arch-mx28/regs-bch.h new file +226 -0
@@ -0,0 +1,226 @@ +/* +* Freescale i.MX28 BCH Register Definitions +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* on behalf of DENX Software Engineering GmbH +* +* Based on code from LTIB: +* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* 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 __REGS_BCH_H__ +#define __REGS_BCH_H__ + +struct mx28_bch_regs { + mx28_reg(hw_bch_ctrl) + mx28_reg(hw_bch_status0) + mx28_reg(hw_bch_mode) + mx28_reg(hw_bch_encodeptr) + mx28_reg(hw_bch_dataptr) + mx28_reg(hw_bch_metaptr) + + uint32_t reserved[4]; + + mx28_reg(hw_bch_layoutselect) + mx28_reg(hw_bch_flash0layout0) + mx28_reg(hw_bch_flash0layout1) + mx28_reg(hw_bch_flash1layout0) + mx28_reg(hw_bch_flash1layout1) + mx28_reg(hw_bch_flash2layout0) + mx28_reg(hw_bch_flash2layout1) + mx28_reg(hw_bch_flash3layout0) + mx28_reg(hw_bch_flash3layout1) + mx28_reg(hw_bch_dbgkesread) + mx28_reg(hw_bch_dbgcsferead) + mx28_reg(hw_bch_dbgsyndegread) + mx28_reg(hw_bch_dbgahbmread) + mx28_reg(hw_bch_blockname) + mx28_reg(hw_bch_version) +}; + +#define BCH_CTRL_SFTRST (1 << 31) +#define BCH_CTRL_CLKGATE (1 << 30) +#define BCH_CTRL_DEBUGSYNDROME (1 << 22) +#define BCH_CTRL_M2M_LAYOUT_MASK (0x3 << 18) +#define BCH_CTRL_M2M_LAYOUT_OFFSET 18 +#define BCH_CTRL_M2M_ENCODE (1 << 17) +#define BCH_CTRL_M2M_ENABLE (1 << 16) +#define BCH_CTRL_DEBUG_STALL_IRQ_EN (1 << 10) +#define BCH_CTRL_COMPLETE_IRQ_EN (1 << 8) +#define BCH_CTRL_BM_ERROR_IRQ (1 << 3) +#define BCH_CTRL_DEBUG_STALL_IRQ (1 << 2) +#define BCH_CTRL_COMPLETE_IRQ (1 << 0) + +#define BCH_STATUS0_HANDLE_MASK (0xfff << 20) +#define BCH_STATUS0_HANDLE_OFFSET 20 +#define BCH_STATUS0_COMPLETED_CE_MASK (0xf << 16) +#define BCH_STATUS0_COMPLETED_CE_OFFSET 16 +#define BCH_STATUS0_STATUS_BLK0_MASK (0xff << 8) +#define BCH_STATUS0_STATUS_BLK0_OFFSET 8 +#define BCH_STATUS0_STATUS_BLK0_ZERO (0x00 << 8) +#define BCH_STATUS0_STATUS_BLK0_ERROR1 (0x01 << 8) +#define BCH_STATUS0_STATUS_BLK0_ERROR2 (0x02 << 8) +#define BCH_STATUS0_STATUS_BLK0_ERROR3 (0x03 << 8) +#define BCH_STATUS0_STATUS_BLK0_ERROR4 (0x04 << 8) +#define BCH_STATUS0_STATUS_BLK0_UNCORRECTABLE (0xfe << 8) +#define BCH_STATUS0_STATUS_BLK0_ERASED (0xff << 8) +#define BCH_STATUS0_ALLONES (1 << 4) +#define BCH_STATUS0_CORRECTED (1 << 3) +#define BCH_STATUS0_UNCORRECTABLE (1 << 2) + +#define BCH_MODE_ERASE_THRESHOLD_MASK 0xff +#define BCH_MODE_ERASE_THRESHOLD_OFFSET 0 + +#define BCH_ENCODEPTR_ADDR_MASK 0xffffffff +#define BCH_ENCODEPTR_ADDR_OFFSET 0 + +#define BCH_DATAPTR_ADDR_MASK 0xffffffff +#define BCH_DATAPTR_ADDR_OFFSET 0 + +#define BCH_METAPTR_ADDR_MASK 0xffffffff +#define BCH_METAPTR_ADDR_OFFSET 0 + +#define BCH_LAYOUTSELECT_CS15_SELECT_MASK (0x3 << 30) +#define BCH_LAYOUTSELECT_CS15_SELECT_OFFSET 30 +#define BCH_LAYOUTSELECT_CS14_SELECT_MASK (0x3 << 28) +#define BCH_LAYOUTSELECT_CS14_SELECT_OFFSET 28 +#define BCH_LAYOUTSELECT_CS13_SELECT_MASK (0x3 << 26) +#define BCH_LAYOUTSELECT_CS13_SELECT_OFFSET 26 +#define BCH_LAYOUTSELECT_CS12_SELECT_MASK (0x3 << 24) +#define BCH_LAYOUTSELECT_CS12_SELECT_OFFSET 24 +#define BCH_LAYOUTSELECT_CS11_SELECT_MASK (0x3 << 22) +#define BCH_LAYOUTSELECT_CS11_SELECT_OFFSET 22 +#define BCH_LAYOUTSELECT_CS10_SELECT_MASK (0x3 << 20) +#define BCH_LAYOUTSELECT_CS10_SELECT_OFFSET 20 +#define BCH_LAYOUTSELECT_CS9_SELECT_MASK (0x3 << 18) +#define BCH_LAYOUTSELECT_CS9_SELECT_OFFSET 18 +#define BCH_LAYOUTSELECT_CS8_SELECT_MASK (0x3 << 16) +#define BCH_LAYOUTSELECT_CS8_SELECT_OFFSET 16 +#define BCH_LAYOUTSELECT_CS7_SELECT_MASK (0x3 << 14) +#define BCH_LAYOUTSELECT_CS7_SELECT_OFFSET 14 +#define BCH_LAYOUTSELECT_CS6_SELECT_MASK (0x3 << 12) +#define BCH_LAYOUTSELECT_CS6_SELECT_OFFSET 12 +#define BCH_LAYOUTSELECT_CS5_SELECT_MASK (0x3 << 10) +#define BCH_LAYOUTSELECT_CS5_SELECT_OFFSET 10 +#define BCH_LAYOUTSELECT_CS4_SELECT_MASK (0x3 << 8) +#define BCH_LAYOUTSELECT_CS4_SELECT_OFFSET 8 +#define BCH_LAYOUTSELECT_CS3_SELECT_MASK (0x3 << 6) +#define BCH_LAYOUTSELECT_CS3_SELECT_OFFSET 6 +#define BCH_LAYOUTSELECT_CS2_SELECT_MASK (0x3 << 4) +#define BCH_LAYOUTSELECT_CS2_SELECT_OFFSET 4 +#define BCH_LAYOUTSELECT_CS1_SELECT_MASK (0x3 << 2) +#define BCH_LAYOUTSELECT_CS1_SELECT_OFFSET 2 +#define BCH_LAYOUTSELECT_CS0_SELECT_MASK (0x3 << 0) +#define BCH_LAYOUTSELECT_CS0_SELECT_OFFSET 0 + +#define BCH_FLASHLAYOUT0_NBLOCKS_MASK (0xff << 24) +#define BCH_FLASHLAYOUT0_NBLOCKS_OFFSET 24 +#define BCH_FLASHLAYOUT0_META_SIZE_MASK (0xff << 16) +#define BCH_FLASHLAYOUT0_META_SIZE_OFFSET 16 +#define BCH_FLASHLAYOUT0_ECC0_MASK (0xf << 12) +#define BCH_FLASHLAYOUT0_ECC0_OFFSET 12 +#define BCH_FLASHLAYOUT0_ECC0_NONE (0x0 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC2 (0x1 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC4 (0x2 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC6 (0x3 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC8 (0x4 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC10 (0x5 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC12 (0x6 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC14 (0x7 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC16 (0x8 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC18 (0x9 << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC20 (0xa << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC22 (0xb << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC24 (0xc << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC26 (0xd << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC28 (0xe << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC30 (0xf << 12) +#define BCH_FLASHLAYOUT0_ECC0_ECC32 (0x10 << 12) +#define BCH_FLASHLAYOUT0_GF13_0_GF14_1 (1 << 10) +#define BCH_FLASHLAYOUT0_DATA0_SIZE_MASK 0xfff +#define BCH_FLASHLAYOUT0_DATA0_SIZE_OFFSET 0 + +#define BCH_FLASHLAYOUT1_PAGE_SIZE_MASK (0xffff << 16) +#define BCH_FLASHLAYOUT1_PAGE_SIZE_OFFSET 16 +#define BCH_FLASHLAYOUT1_ECCN_MASK (0xf << 12) +#define BCH_FLASHLAYOUT1_ECCN_OFFSET 12 +#define BCH_FLASHLAYOUT1_ECCN_NONE (0x0 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC2 (0x1 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC4 (0x2 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC6 (0x3 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC8 (0x4 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC10 (0x5 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC12 (0x6 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC14 (0x7 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC16 (0x8 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC18 (0x9 << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC20 (0xa << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC22 (0xb << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC24 (0xc << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC26 (0xd << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC28 (0xe << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC30 (0xf << 12) +#define BCH_FLASHLAYOUT1_ECCN_ECC32 (0x10 << 12) +#define BCH_FLASHLAYOUT1_GF13_0_GF14_1 (1 << 10) +#define BCH_FLASHLAYOUT1_DATAN_SIZE_MASK 0xfff +#define BCH_FLASHLAYOUT1_DATAN_SIZE_OFFSET 0 + +#define BCH_DEBUG0_RSVD1_MASK (0x1f << 27) +#define BCH_DEBUG0_RSVD1_OFFSET 27 +#define BCH_DEBUG0_ROM_BIST_ENABLE (1 << 26) +#define BCH_DEBUG0_ROM_BIST_COMPLETE (1 << 25) +#define BCH_DEBUG0_KES_DEBUG_SYNDROME_SYMBOL_MASK (0x1ff << 16) +#define BCH_DEBUG0_KES_DEBUG_SYNDROME_SYMBOL_OFFSET 16 +#define BCH_DEBUG0_KES_DEBUG_SYNDROME_SYMBOL_NORMAL (0x0 << 16) +#define BCH_DEBUG0_KES_DEBUG_SYNDROME_SYMBOL_TEST_MODE (0x1 << 16) +#define BCH_DEBUG0_KES_DEBUG_SHIFT_SYND (1 << 15) +#define BCH_DEBUG0_KES_DEBUG_PAYLOAD_FLAG (1 << 14) +#define BCH_DEBUG0_KES_DEBUG_MODE4K (1 << 13) +#define BCH_DEBUG0_KES_DEBUG_KICK (1 << 12) +#define BCH_DEBUG0_KES_STANDALONE (1 << 11) +#define BCH_DEBUG0_KES_DEBUG_STEP (1 << 10) +#define BCH_DEBUG0_KES_DEBUG_STALL (1 << 9) +#define BCH_DEBUG0_BM_KES_TEST_BYPASS (1 << 8) +#define BCH_DEBUG0_RSVD0_MASK (0x3 << 6) +#define BCH_DEBUG0_RSVD0_OFFSET 6 +#define BCH_DEBUG0_DEBUG_REG_SELECT_MASK 0x3f +#define BCH_DEBUG0_DEBUG_REG_SELECT_OFFSET 0 + +#define BCH_DBGKESREAD_VALUES_MASK 0xffffffff +#define BCH_DBGKESREAD_VALUES_OFFSET 0 + +#define BCH_DBGCSFEREAD_VALUES_MASK 0xffffffff +#define BCH_DBGCSFEREAD_VALUES_OFFSET 0 + +#define BCH_DBGSYNDGENREAD_VALUES_MASK 0xffffffff +#define BCH_DBGSYNDGENREAD_VALUES_OFFSET 0 + +#define BCH_DBGAHBMREAD_VALUES_MASK 0xffffffff +#define BCH_DBGAHBMREAD_VALUES_OFFSET 0 + +#define BCH_BLOCKNAME_NAME_MASK 0xffffffff +#define BCH_BLOCKNAME_NAME_OFFSET 0 + +#define BCH_VERSION_MAJOR_MASK (0xff << 24) +#define BCH_VERSION_MAJOR_OFFSET 24 +#define BCH_VERSION_MINOR_MASK (0xff << 16) +#define BCH_VERSION_MINOR_OFFSET 16 +#define BCH_VERSION_STEP_MASK 0xffff +#define BCH_VERSION_STEP_OFFSET 0 + +#endif /* __REGS_BCH_H__ */
arch/arm/include/asm/arch-mx28/regs-gpmi.h new file +218 -0
218 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 22/31 iMX28: Add GPMI NAND driver
In reply to Marek Vasut--- drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/mxs_nand.c | 1163 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1164 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/nand/mxs_nand.c
drivers/mtd/nand/Makefile +1 -0
@@ -43,6 +43,7 @@ COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o COBJS-$(CONFIG_NAND_KMETER1) += kmeter1_nand.o COBJS-$(CONFIG_NAND_MPC5121_NFC) += mpc5121_nfc.o COBJS-$(CONFIG_NAND_MXC) += mxc_nand.o +COBJS-$(CONFIG_NAND_MXS) += mxs_nand.o COBJS-$(CONFIG_NAND_NDFC) += ndfc.o COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
drivers/mtd/nand/mxs_nand.c new file +1163 -0
1,163 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 23/31 M28: Enable NAND
In reply to Marek Vasut--- include/configs/m28evk.h | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
include/configs/m28evk.h +13 -0
@@ -53,6 +53,7 @@#define CONFIG_CMD_I2C #define CONFIG_CMD_MII #define CONFIG_CMD_MMC +#define CONFIG_CMD_NAND #define CONFIG_CMD_NET #define CONFIG_CMD_NFS #define CONFIG_CMD_PING
@@ -120,6 +121,18 @@#endif /* +* NAND +*/ +#ifdef CONFIG_CMD_NAND +#define CONFIG_NAND_MXS +#define CONFIG_APBH_DMA +#define CONFIG_SYS_MAX_NAND_DEVICE 1 +#define CONFIG_SYS_NAND_BASE 0x60000000 +#define CONFIG_SYS_NAND_5_ADDR_CYCLE +#define NAND_MAX_CHIPS 8 +#endif + +/* * Ethernet on SOC (FEC) */ #ifdef CONFIG_CMD_NET
Signature · 1 line
1.7.5.4
PATCH 24/31 iMX28: Add driver for internal RTC
In reply to Marek Vasut--- drivers/rtc/Makefile | 1 + drivers/rtc/mxsrtc.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/mxsrtc.c
drivers/rtc/Makefile +1 -0
@@ -56,6 +56,7 @@ COBJS-$(CONFIG_RTC_MK48T59) += mk48t59.o COBJS-$(CONFIG_RTC_MPC5200) += mpc5xxx.o COBJS-$(CONFIG_RTC_MPC8xx) += mpc8xx.o COBJS-$(CONFIG_RTC_MV) += mvrtc.o +COBJS-$(CONFIG_RTC_MXS) += mxsrtc.o COBJS-$(CONFIG_RTC_PCF8563) += pcf8563.o COBJS-$(CONFIG_RTC_PL031) += pl031.o COBJS-$(CONFIG_RTC_PT7C4338) += pt7c4338.o
drivers/rtc/mxsrtc.c new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 25/31 M28: Enable the internal RTC instead of the M41T62
In reply to Marek Vasut--- include/configs/m28evk.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
include/configs/m28evk.h +6 -0
@@ -166,10 +166,16 @@* RTC */ #ifdef CONFIG_CMD_DATE +/* Use the internal RTC in the MXS chip */ +#define CONFIG_RTC_INTERNAL +#ifdef CONFIG_RTC_INTERNAL +#define CONFIG_RTC_MXS +#else #define CONFIG_RTC_M41T62 #define CONFIG_SYS_I2C_RTC_ADDR 0x68#define CONFIG_SYS_M41T11_BASE_YEAR 2000#endif +#endif /* * SPI
Signature · 1 line
1.7.5.4
PATCH 25/31 M28: Enable the internal RTC instead of the M41T62
Quoted 5 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
Only to remember: we have already agree you will squash your patches together regarding m28evk. I will only set this patch (and the other similar patches) in state "Change requested" on patchwork.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 25/31 M28: Enable the internal RTC instead of the M41T62
Quoted 10 lines · Stefano Babic
Quoted 5 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
Only to remember: we have already agree you will squash your patches together regarding m28evk. I will only set this patch (and the other similar patches) in state "Change requested" on patchwork.
Yea sure, I'll squash them ... have it like:
* Add CPU support
* ... drivers ...
* M28EVK
* README.m28
Quoted 3 lines
Best regards,
Stefano Babic
PATCH 25/31 M28: Enable the internal RTC instead of the M41T62
Quoted 12 lines · Marek Vasut
Quoted 10 lines · Stefano Babic
Quoted 5 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
Only to remember: we have already agree you will squash your patches together regarding m28evk. I will only set this patch (and the other similar patches) in state "Change requested" on patchwork.
Quoted 5 lines
Yea sure, I'll squash them ... have it like:
* Add CPU support
* ... drivers ...
* M28EVK
* README.m28
That's fine with me.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 26/31 M28: Enable UBI and UBIFS
In reply to Marek Vasut--- include/configs/m28evk.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
include/configs/m28evk.h +16 -0
@@ -130,6 +130,22 @@#define CONFIG_SYS_NAND_BASE 0x60000000#define CONFIG_SYS_NAND_5_ADDR_CYCLE #define NAND_MAX_CHIPS 8 + +#define CONFIG_CMD_UBI +#define CONFIG_CMD_UBIFS +#define CONFIG_CMD_MTDPARTS +#define CONFIG_RBTREE +#define CONFIG_LZO +#define CONFIG_MTD_DEVICE +#define CONFIG_MTD_PARTITIONS +#define MTDIDS_DEFAULT "nand0=gpmi-nand.0" +#define MTDPARTS_DEFAULT \ + "mtdparts=gpmi-nand.0:" \ + "3m(bootloader)ro," \ + "128k(environment)," \ + "128k(redundant-environment)," \ + "4m(kernel)," \ + "-(filesystem)"#endif /*
Signature · 1 line
1.7.5.4
PATCH 27/31 M28: Save environment in NAND
In reply to Marek Vasut--- include/configs/m28evk.h | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
include/configs/m28evk.h +9 -2
@@ -131,6 +131,15 @@#define CONFIG_SYS_NAND_5_ADDR_CYCLE #define NAND_MAX_CHIPS 8 +/* Environment is in NAND */ +#define CONFIG_ENV_IS_IN_NAND 1 +#define CONFIG_ENV_SECT_SIZE (128 * 1024) +#define CONFIG_ENV_SIZE (16 * 1024) +#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE +#define CONFIG_ENV_OFFSET 0x300000 +#define CONFIG_ENV_OFFSET_REDUND \ + (CONFIG_ENV_OFFSET + CONFIG_ENV_SECT_SIZE) +#define CONFIG_CMD_UBI #define CONFIG_CMD_UBIFS #define CONFIG_CMD_MTDPARTS
@@ -230,6 +239,4 @@#define CONFIG_LOADADDR 0x42000000#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR -#define CONFIG_ENV_IS_NOWHERE 1 -#endif /* __M28_H__ */
Signature · 1 line
1.7.5.4
PATCH 27/31 M28: Save environment in NAND
Quoted 29 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>--- include/configs/m28evk.h | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)include/configs/m28evk.h +9
-0@@ -131,6 +131,15 @@#define CONFIG_SYS_NAND_5_ADDR_CYCLE #define NAND_MAX_CHIPS 8 +/* Environment is in NAND */ +#define CONFIG_ENV_IS_IN_NAND 1 +#define CONFIG_ENV_SECT_SIZE (128 * 1024) +#define CONFIG_ENV_SIZE (16 * 1024) +#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE +#define CONFIG_ENV_OFFSET 0x300000 +#define CONFIG_ENV_OFFSET_REDUND \ + (CONFIG_ENV_OFFSET + CONFIG_ENV_SECT_SIZE) +#define CONFIG_CMD_UBI #define CONFIG_CMD_UBIFS #define CONFIG_CMD_MTDPARTS
include/configs/m28evk.h line 242
Quoted 6 lines
include/configs/m28evk.h +0
-2@@ -230,6 +239,4 @@#define CONFIG_LOADADDR 0x42000000#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR -#define CONFIG_ENV_IS_NOWHERE 1 -#endif /* __M28_H__ */
Consider using CONFIG_ENV_RANGE to allow for bad blocks.
-Scott
PATCH 27/31 M28: Save environment in NAND
Quoted 38 lines · Scott Wood
Quoted 37 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Stefano Babic <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Detlev Zundel <[email protected]>---
include/configs/m28evk.h | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)include/configs/m28evk.h +9
-0@@ -131,6 +131,15 @@#define CONFIG_SYS_NAND_5_ADDR_CYCLE #define NAND_MAX_CHIPS 8 +/* Environment is in NAND */ +#define CONFIG_ENV_IS_IN_NAND 1 +#define CONFIG_ENV_SECT_SIZE (128 * 1024) +#define CONFIG_ENV_SIZE (16 * 1024) +#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE +#define CONFIG_ENV_OFFSET 0x300000 +#define CONFIG_ENV_OFFSET_REDUND \ + (CONFIG_ENV_OFFSET + CONFIG_ENV_SECT_SIZE) +#define CONFIG_CMD_UBI #define
CONFIG_CMD_UBIFS
#defineCONFIG_CMD_MTDPARTSinclude/configs/m28evk.h +0
-0@@ -230,6 +239,4 @@#define CONFIG_LOADADDR 0x42000000#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR
Quoted 6 lines
Quoted 4 lines
include/configs/m28evk.h +0
-2-#define CONFIG_ENV_IS_NOWHERE 1 -#endif /*
__M28_H__*/Consider using
CONFIG_ENV_RANGEto allow for bad blocks.
How does this actually play with CONFIG_MTDPARTS ?
For you see -- I now haveCONFIG_MTDPARTS "...128k(environment), 128k(redundant-environment)..." and CONFIG_ENV_SECT_SIZE (128 * 1024).
So what exactly am I supposed to set into CONFIG_ENV_RANGE and do I have to modify the CONFIG_MTDPARTS?
Thanks, cheers!
Quoted 2 lines
-Scott
PATCH 27/31 M28: Save environment in NAND
Quoted 4 lines · Marek Vasut
Quoted 1 line · Scott Wood
Consider using
CONFIG_ENV_RANGEto allow for bad blocks.How does this actually play with
CONFIG_MTDPARTS?
I don't think there's any direct interaction between the environment code and mtdparts.
Quoted 6 lines
For you see -- I now have
CONFIG_MTDPARTS"...128k(environment), 128k(redundant-environment)..." andCONFIG_ENV_SECT_SIZE(128 * 1024).So what exactly am I supposed to set into
CONFIG_ENV_RANGEand do I have to modify theCONFIG_MTDPARTS?
You'd have to make the environment partitions larger -- the idea is to provide an extra block or two in case of bad blocks. CONFIG_ENV_RANGE would be set to the partition size.
-Scott
Fabio Estevam
reviewerPATCH 27/31 M28: Save environment in NAND
In reply to Marek VasutOn Thu, Sep 8, 2011 at 5:42 PM, Marek Vasut <[email protected]> wrote:
...
Review
Quoted 2 lines
(quoted diff) +2
-0+/* Environment is in NAND */ +#define ? ? ? ?CONFIG_ENV_IS_IN_NAND ? ? ? ? ? 1
You should remove the "1".
PATCH 28/31 iMX28: Add image header generator tool
In reply to Marek VasutThis tool can now generate proper image for "BootStream" files.
NOTE: This tool now works only for NAND.
--- tools/Makefile | 6 + tools/mxsboot.c | 687 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 693 insertions(+), 0 deletions(-) create mode 100644 tools/mxsboot.c
tools/Makefile +6 -0
@@ -67,6 +67,7 @@ BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX) BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX) BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX) BIN_FILES-y += mkimage$(SFX) +BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX) BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX) BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
@@ -90,6 +91,7 @@ NOPED_OBJ_FILES-y += kwbimage.o NOPED_OBJ_FILES-y += imximage.o NOPED_OBJ_FILES-y += omapimage.o NOPED_OBJ_FILES-y += mkimage.o +OBJ_FILES-$(CONFIG_MX28) += mxsboot.o OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o NOPED_OBJ_FILES-y += os_support.o OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
@@ -204,6 +206,10 @@ $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTSTRIP) $@ +$(obj)mxsboot$(SFX): $(obj)mxsboot.o + $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ + $(HOSTSTRIP) $@ + $(obj)ncb$(SFX): $(obj)ncb.o $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTSTRIP) $@
tools/mxsboot.c new file +687 -0
687 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 28/31 iMX28: Add image header generator tool
Quoted 4 lines · Marek Vasut
This tool can now generate proper image for "BootStream" files.
NOTE: This tool now works only for NAND.
Hi Marek,
I have not reviewed your patch. Before starting, I have a big remark.
This is *not* the way we are implementing in u-boot to add SOC related images. Instead of having a special tool for each SOC, we are adding new functions to mkimage to support all SOCs we have. mkimage is able now to generate images for several SOCs.
You have implemented a completely different one. Why ? Why cannot we add a new image type to mkimage ?
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 28/31 iMX28: Add image header generator tool
Quoted 9 lines · Stefano Babic
Quoted 3 lines · Marek Vasut
This tool can now generate proper image for "BootStream" files.
NOTE: This tool now works only for NAND.
Hi Marek,
I have not reviewed your patch. Before starting, I have a big remark.
Quoted 7 lines
This is *not* the way we are implementing in u-boot to add SOC related images. Instead of having a special tool for each SOC, we are adding new functions to mkimage to support all SOCs we have. mkimage is able now to generate images for several SOCs.
You have implemented a completely different one. Why ? Why cannot we add a new image type to mkimage ?
Because you run this thing only once, you don't run it every time you update your uboot in NAND.
The path is ... compile u-boot.bin -> run external tool elftosb -> run mxsboot
Most of the time, you stop in step II, which is handled by uboot makefiles.
Quoted 3 lines
Best regards,
Stefano Babic
PATCH 29/31 M28: Add NAND update scripts
In reply to Marek VasutAdd "update_nand_full" and "update_nand_firmware" scripts to make NAND bootable or update NAND firmware.
--- include/configs/m28evk.h | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-)
include/configs/m28evk.h +34 -0
@@ -239,4 +239,38 @@#define CONFIG_LOADADDR 0x42000000#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR +/* +* Extra Environments +*/ +#define CONFIG_EXTRA_ENV_SETTINGS \ + "update_nand_full_filename=u-boot.nand\0" \ + "update_nand_firmware_filename=u-boot.sb\0" \ + "update_nand_firmware_maxsz=0x100000\0" \ + "update_nand_stride=0x40\0"/* MX28 datasheet ch. 12.12 */ \ +"update_nand_count=0x4\0" /* MX28 datasheet ch. 12.12 */ \ +"update_nand_get_fcb_size=" /* Get size of FCB blocks */ \ +"nand device 0 ; " \ +"nand info ; " \ +"setexpr fcb_sz ${update_nand_stride} * ${update_nand_count};" \ +"setexpr update_nand_fcb ${fcb_sz} * ${nand_writesize}\0" \ +"update_nand_full=" /* Update FCB, DBBT and FW */ \ +"if tftp ${update_nand_full_filename} ; then " \ +"run update_nand_get_fcb_size ; " \ +"nand scrub.quiet 0x0 ${filesize} ; " \ +"nand write.raw ${loadaddr} 0x0 ${update_nand_fcb} ; " \ +"setexpr update_off ${loadaddr} + ${update_nand_fcb} ; " \ +"setexpr update_sz ${filesize} - ${update_nand_fcb} ; " \ +"nand write ${update_off} ${update_nand_fcb} ${update_sz} ; " \ +"fi\0" \ +"update_nand_firmware=" /* Update only firmware */ \ +"if tftp ${update_nand_firmware_filename} ; then " \ +"run update_nand_get_fcb_size ; " \ +"setexpr fcb_sz ${update_nand_fcb} * 2 ; " /* FCB + DBBT */ \ +"setexpr fw_sz ${update_nand_firmware_maxsz} * 2 ; " \ +"setexpr fw_off ${fcb_sz} + ${update_nand_firmware_maxsz};" \ +"nand erase ${fcb_sz} ${fw_sz} ; " \ +"nand write ${loadaddr} ${fcb_sz} ${filesize} ; " \ +"nand write ${loadaddr} ${fw_off} ${filesize} ; " \ + "fi\0" +#endif /* __M28_H__ */
Signature · 1 line
1.7.5.4
PATCH 30/31 i.MX28: Add u-boot.sb target to Makefile
In reply to Marek Vasut--- Makefile | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
Makefile +5 -0
@@ -398,6 +398,10 @@ $(obj)u-boot.ubl: $(obj)u-boot-nand.bin $(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \ -e $(CONFIG_SYS_TEXT_BASE) -d $< $@ +$(obj)u-boot.sb: $(obj)u-boot.bin $(obj)mmc_spl/u-boot-mmc-spl.bin + elftosb -zdf imx28 -c mmc_spl/board/denx/m28evk/u-boot.bd \ + -o $(obj)u-boot.sb + GEN_UBOOT = \ UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \ sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
@@ -980,6 +984,7 @@ clobber: clean @rm -f $(obj)u-boot.kwb @rm -f $(obj)u-boot.imx @rm -f $(obj)u-boot.ubl + @rm -f $(obj)u-boot.sb @rm -f $(obj)tools/{env/crc32.c,inca-swap-bytes} @rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c @rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
Signature · 1 line
1.7.5.4
PATCH 31/31 M28: Add doc/README.m28 documentation
In reply to Marek Vasut--- doc/README.m28 | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 223 insertions(+), 0 deletions(-) create mode 100644 doc/README.m28
doc/README.m28 new file +223 -0
@@ -0,0 +1,223 @@ +DENX M28EVK +=========== + +This document describes the DENX M28/M28EVK U-Boot port. This document mostly +covers topics related to making the module/board bootable. + +Terminology +----------- + +The dollar symbol ($) introduces a snipped of shell code. This shall be typed +into the unix command prompt in U-Boot source code root directory. + +The (=>) introduces a snipped of code that should by typed into U-Boot command +prompt. + +Contents +-------- + +0) Files of the M28/M28EVK port +1) Prerequisites +2) Compiling U-Boot for M28 +3) Installation of U-Boot for M28EVK to SD card +4) Installation of U-Boot for M28 to NAND flash + +0) Files of the M28/M28EVK port +------------------------------- + +arch/arm/cpu/arm926ejs/mx28/ - The CPU support code for the Freescale i.MX28 +arch/arm/include/asm/arch-mx28/ - Header files for the Freescale i.MX28 +board/denx/m28evk/ - M28EVK board specific files +include/configs/m28evk.h - M28EVK configuration file + +1) Prerequisites +---------------- + +To make the M28 module or the M28 module or M28EVK board bootable, some tools +are necessary. The first one is the "elftosb" tool distributed by Freescale +Semiconductor. The other tool is the "mxsboot" tool found in U-Boot source tree. + +Firstly, obtain the elftosb archive from the following location: + + http://foss.doredevelopment.dk/mirrors/imx/elftosb-10.12.01.tar.gz + +We use a $VER variable here to denote the current version. At the time of +writing of this document, that is "10.12.01". To obtain the file from command +line, use: + + $ VER="10.12.01" + $ wget http://foss.doredevelopment.dk/mirrors/imx/elftosb-${VER}.tar.gz + +Extract the file: + + $ tar xzf elftosb-${VER}.tar.gz + +Compile the file. We need to manually tell the linker to use also libm: + + $ cd elftosb-${VER}/ + $ make LIBS="-lstdc++ -lm" elftosb + +Optionally, remove debugging symbols from elftosb: + + $ strip bld/linux/elftosb + +Finally, install the "elftosb" binary. The "install" target is missing, so just +copy the binary by hand: + + $ sudo cp bld/linux/elftosb /usr/local/bin/ + +Make sure the "elftosb" binary can be found in your $PATH, in this case this +means "/usr/local/bin/" has to be in your $PATH. + +2) Compiling U-Boot for M28 +--------------------------- + +Compiling the U-Boot for M28 is straightforward and done as compiling U-Boot +for any other ARM device. For cross-compiler setup, please refer to ELDK5.0 +documentation. First, clean up the source code: + + $ make mrproper + +Next, configure U-Boot for M28EVK: + + $ make m28evk_config + +Lastly, compile U-Boot and prepare a "BootStream". The "BootStream" is a special +type of file, which the i.MX28 CPU can boot. This is handled by the following +command: + + $ make u-boot.sb + +HINT: To speed-up the build process, you can add -j<N>, where N is number of + compiler instances that'll run in parallel. + +The code produces "u-boot.sb" file. This file needs to be augmented with a +proper header to allow successful boot from SD or NAND. Adding the header is +discussed in the following chapters. + +3) Installation of U-Boot for M28EVK to SD card +----------------------------------------------- + +To boot an M28 from SD, set the boot mode DIP switches according to i.MX28 +manual chapter 12.2.1 (Table 12-2), PORT=SSP0, SD/MMC master on SSP0, 3.3V. + +An SD card the i.MX28 CPU can use to boot U-Boot must contain a DOS partition +table, which in turn carries a partition of special type and which contains a +special header. The rest of partitions in the DOS partition table can be used +by the user. + +To prepare such partition, use your favourite partitioning tool. The partition +must have the following parameters: + + * Start sector .......... sector 2048 + * Partition size ........ at least 1024 kb + * Partition type ........ 0x53 (sometimes "OnTrack DM6 Aux3") + +For example in Linux fdisk, the sequence for a clear card is the following: + + * o ..................... create a clear partition table + * n ..................... create new partition + * p ............. primary partition + * 1 ............. first partition + * 2048 .......... first sector is 2048 + * +1M ........... make the partition 1Mb big + * t 1 ................... change first partition ID + * 53 ............ change the ID to 0x53 (OnTrack DM6 Aux3) + * <create other partitions> + * w ..................... write partition table to disk + +The partition layout is ready, next the special partition must be filled with +proper contents. The contents is generated by running the following command (see +chapter 2)): + + $ ./tools/mxsboot sd u-boot.sb u-boot.sd + +The resulting file, "u-boot.sd", shall then be written to the partition. In this +case, we assume the first partition of the SD card is /dev/mmcblk0p1: + + $ dd if=u-boot.sd of=/dev/mmcblk0p1 + +Last step is to insert the card into M28EVK and boot. + +NOTE: If the user needs to adjust the start sector, the "mxsboot" tool contains + a "-p" switch for that purpose. The "-p" switch takes the sector number as + an argument. + +4) Installation of U-Boot for M28 to NAND flash +----------------------------------------------- + +To boot an M28 from NAND, set the boot mode DIP switches according to i.MX28 +manual chapter 12.2.1 (Table 12-2), PORT=GPMI, NAND 1.8 V. + +There are two possibilities when preparing an image writable to NAND flash. + + I) The NAND wasn't written at all yet or the BCB is broken + ---------------------------------------------------------- + In this case, both BCB (FCB and DBBT) and firmware needs to be + written to NAND. To generate NAND image containing all these, + there is a tool called "mxsboot" in the "tools/" directory. The tool + is invoked on "u-boot.sb" file from chapter 2): + + $ ./tools/mxsboot nand u-boot.sb u-boot.nand + + NOTE: The above invokation works for NAND flash with geometry of + 2048b per page, 64b OOB data, 128kb erase size. If your chip + has a different geometry, please use: + + -w <size> change page size (default 2048 b) + -o <size> change oob size (default 64 b) + -e <size> change erase size (default 131072 b) + + The geometry information can be obtained from running U-Boot + on M28 by issuing the "nand info" command. + + The resulting file, "u-boot.nand" can be written directly to NAND + from the U-Boot prompt. To simplify the process, the U-Boot default + environment contains script "update_nand_full" to update the system. + + This script expects a working TFTP server containing the file + "u-boot.nand" in it's root directory. This can be changed by + adjusting the "update_nand_full_filename" varible. + + To update the system, run the following in U-Boot prompt: + + => run update_nand_full + + In case you would only need to update the bootloader in future, + see II) below. + + II) The NAND was already written with a good BCB + ------------------------------------------------ + This part applies after the part I) above was done at least once. + + If part I) above was done correctly already, there is no need to + write the FCB and DBBT parts of NAND again. It's possible to upgrade + only the bootloader image. + + To simplify the process of firmware update, the U-Boot default + environment contains script "update_nand_firmware" to update only + the firmware, without rewriting FCB and DBBT. + + This script expects a working TFTP server containing the file + "u-boot.sb" in it's root directory. This can be changed by + adjusting the "update_nand_firmware_filename" varible. + + To update the system, run the following in U-Boot prompt: + + => run update_nand_firmware + + III) Special settings for the update scripts + -------------------------------------------- + There is a slight possibility of the user wanting to adjust the + STRIDE and COUNT options of the NAND boot. For description of these, + see i.MX28 manual section 12.12.1.2 and 12.12.1.3. + + The update scripts take this possibility into account. In case the + user changes STRIDE by blowing fuses, the user also has to change + "update_nand_stride" variable. In case the user changes COUNT by + blowing fuses, the user also has to change "update_nand_count" + variable for the update scripts to work correctly. + + In case the user needs to boot a firmware image bigger than 1Mb, the + user has to adjust the "update_nand_firmware_maxsz" variable for the + update scripts to work properly.
Signature · 1 line
1.7.5.4