imx51:Add support basic boot code of freescale imx51 bbg board
Subsystems (2)
PATCH 1/1 imx51:Add support basic boot code of freescale imx51 bbg board
This patch just supports boot into u-boot from mmc or spi-nor flash. It just implements console, iomux and clock. There are no ethernet, nor-flash, mmc or other peripheral drivers.
--- MAINTAINERS | 4 + MAKEALL | 1 + Makefile | 3 + board/freescale/mx51_babbage/Makefile | 49 ++ board/freescale/mx51_babbage/board-mx51_babbage.h | 64 ++ board/freescale/mx51_babbage/config.mk | 2 + board/freescale/mx51_babbage/flash_header.S | 119 ++++ board/freescale/mx51_babbage/lowlevel_init.S | 245 ++++++++ board/freescale/mx51_babbage/mx51_babbage.c | 237 ++++++++ board/freescale/mx51_babbage/u-boot.lds | 72 +++ cpu/arm_cortexa8/mx51/Makefile | 50 ++ cpu/arm_cortexa8/mx51/clock.c | 237 ++++++++ cpu/arm_cortexa8/mx51/crm_regs.h | 673 +++++++++++++++++++++ cpu/arm_cortexa8/mx51/interrupts.c | 33 + cpu/arm_cortexa8/mx51/iomux.c | 199 ++++++ cpu/arm_cortexa8/mx51/soc.c | 66 ++ cpu/arm_cortexa8/mx51/timer.c | 112 ++++ drivers/serial/serial_mxc.c | 6 + include/asm-arm/arch-mx51/iomux.h | 240 ++++++++ include/asm-arm/arch-mx51/mx51.h | 416 +++++++++++++ include/asm-arm/arch-mx51/mx51_pins.h | 370 +++++++++++ include/configs/mx51_babbage.h | 174 ++++++ 22 files changed, 3372 insertions(+), 0 deletions(-)
MAINTAINERS +4 -0
@@ -549,6 +549,10 @@ Fabio Estevam <[email protected]> mx31pdk i.MX31 +Fred Fan <[email protected]> + + mx51_babbage i.MX51 + Peter Figuli <[email protected]> wepep250 xscale
MAKEALL +1 -0
@@ -581,6 +581,7 @@ LIST_ARM_CORTEX_A8=" \ omap3_pandora \ omap3_zoom1 \ omap3_zoom2 \ + mx51_babbage \ " #########################################################################
Makefile +3 -0
@@ -3229,6 +3229,9 @@ mx31pdk_nand_config : unconfig fi @$(MKCONFIG) -a mx31pdk arm arm1136 mx31pdk freescale mx31 +mx51_babbage_config : unconfig + @$(MKCONFIG) $(@:_config=) arm arm_cortexa8 mx51_babbage freescale mx51 + omap2420h4_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm1136 omap2420h4 NULL omap24xx
board/freescale/mx51_babbage/Makefile new file +49 -0
49 lines not on this page · raw message
board/freescale/mx51_babbage/board-mx51_babbage.h new file +64 -0
64 lines not on this page · raw message
board/freescale/mx51_babbage/config.mk new file +2 -0
@@ -0,0 +1,2 @@ +LDSCRIPT = board/$(VENDOR)/$(BOARD)/u-boot.lds +TEXT_BASE = 0x97800000
board/freescale/mx51_babbage/flash_header.S new file +119 -0
119 lines not on this page · raw message
board/freescale/mx51_babbage/lowlevel_init.S new file +245 -0
245 lines not on this page · raw message
board/freescale/mx51_babbage/mx51_babbage.c new file +237 -0
237 lines not on this page · raw message
board/freescale/mx51_babbage/u-boot.lds new file +72 -0
72 lines not on this page · raw message
cpu/arm_cortexa8/mx51/Makefile new file +50 -0
50 lines not on this page · raw message
cpu/arm_cortexa8/mx51/clock.c new file +237 -0
237 lines not on this page · raw message
cpu/arm_cortexa8/mx51/crm_regs.h new file +673 -0
673 lines not on this page · raw message
cpu/arm_cortexa8/mx51/interrupts.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* (C) Copyright 2007 +* Sascha Hauer, Pengutronix +* +* (C) Copyright 2009 Freescale Semiconductor, Inc. +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#include <common.h> +#include <asm/arch/mx51.h> + +/* nothing really to do with interrupts. */ +int interrupt_init (void ) +{ +return 0 ; +}
cpu/arm_cortexa8/mx51/iomux.c new file +199 -0
199 lines not on this page · raw message
cpu/arm_cortexa8/mx51/soc.c new file +66 -0
66 lines not on this page · raw message
cpu/arm_cortexa8/mx51/timer.c new file +112 -0
112 lines not on this page · raw message
drivers/serial/serial_mxc.c +6 -0
@@ -20,6 +20,8 @@#include <common.h> #ifdef CONFIG_MX31 #include <asm/arch/mx31.h> +#elif defined(CONFIG_MX51 ) +#include <asm/arch/mx51.h> #else #include <asm/arch/imx-regs.h> #include <asm/arch/clock.h>
@@ -37,6 +39,8 @@#define UART_PHYS 0x43fb0000#elif defined(CONFIG_SYS_MX31_UART5 )#define UART_PHYS 0x43fb4000 +#elif defined(CONFIG_SYS_MX51_UART1 ) +#define UART_PHYS UART1_BASE_ADDR#elif defined(CONFIG_SYS_MX27_UART1 )#define UART_PHYS 0x1000a000#elif defined(CONFIG_SYS_MX27_UART2 )
@@ -168,6 +172,8 @@ void serial_setbrg (void) {#ifdef CONFIG_MX31 u32 clk =mx31_get_ipg_clk (); +#elif defined(CONFIG_MX51 ) +u32 clk =mxc_get_clock (MXC_UART_CLK );#else u32 clk =imx_get_perclk1 ();#endif
include/asm-arm/arch-mx51/iomux.h new file +240 -0
240 lines not on this page · raw message
include/asm-arm/arch-mx51/mx51.h new file +416 -0
416 lines not on this page · raw message
include/asm-arm/arch-mx51/mx51_pins.h new file +370 -0
136 lines not on this page · raw message
include/configs/mx51_babbage.h new file +174 -0
174 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.0.4
Part of the diff is not shown here. View the raw message.
PATCH 1/1 imx51:Add support basic boot code of freescale imx51 bbg board
Dear Fred Fan,
Quoted 6 lines · In message <[email protected]> you wrote:
This patch just supports boot into u-boot from mmc or spi-nor flash. It just implements console, iomux and clock. There are no ethernet, nor-flash, mmc or other peripheral drivers.
Signed-off-by Fred.Fan <[email protected]>Signed-off-by Fred.Fan <[email protected]>
Please use a shorter subject (it gets tructaed), something like:
mx51_babbage: add support for Freescale iMX51 board
MAKEALL LIST_ARM_CORTEX_A8=" \ · line 584
Quoted 9 lines
MAKEALL +1
-0@@ -581,6 +581,7 @@ LIST_ARM_CORTEX_A8=" \ omap3_pandora \ omap3_zoom1 \ omap3_zoom2 \ + mx51_babbage \
Please keep lists sorted.
board/freescale/mx51_babbage/board-mx51_babbage.h
Quoted 5 lines
board/freescale/mx51_babbage/board-mx51_babbage.h new file +0
-0
Please drop the "board-" part of the file name.
Quoted 4 lines
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
Please use correct licnese terms. Specify which version of the license applies, i. e. use something like:
This code is licensed under the GPL, version 2 (or any later version).
Quoted 4 lines
+/*!
+ * @defgroupBRDCFG_MX51_BABBAGEBoard Configuration Options
+ * @ingroupMSL_MX51_BABBAGE
+ */
Please get rid of this "!", "@defgroup", "@ingroup" etc. stuff.
Quoted 2 lines
+/*!
+ * @filemx51_babbage/board-mx51_babbage.h
Drop this line. It carries no information.
Quoted 2 lines
+ * @brief This file contains all the board level configuration options.
+ *
Drop the blank line.
Quoted 3 lines
+ * It currently hold the options defined for MX51 babbage Platform.
+ *
+ * @ingroupBRDCFG_MX51_BABBAGE
Drop this line, Please apply similar to the rest of the code.
board/freescale/mx51_babbage/board-mx51_babbage.h line 42
Quoted 11 lines
board/freescale/mx51_babbage/board-mx51_babbage.h new file +11
-0+/* CPLD offsets */ +#define PBC_LED_CTRL (0x20000) +#define PBC_SB_STAT (0x20008) +#define PBC_ID_AAAA (0x20040) +#define PBC_ID_5555 (0x20048) +#define PBC_VERSION (0x20050) +#define PBC_ID_CAFE (0x20058) +#define PBC_INT_STAT (0x20010) +#define PBC_INT_MASK (0x20038) +#define PBC_INT_REST (0x20020) +#define PBC_SW_RESET (0x20060)
Don't use base address + offsets, but declare proper C structures to describe the register layout. Then use I/O accessors to access registers.
board/freescale/mx51_babbage/config.mk line 2
Quoted 8 lines
board/freescale/mx51_babbage/config.mk new file +2
-0@@ -0,0 +1,2 @@ +LDSCRIPT = board/$(VENDOR)/$(BOARD)/u-boot.lds +TEXT_BASE = 0x97800000
Even though the file is short, please add a (C) and license header.
Quoted 5 lines
board/freescale/mx51_babbage/flash_header.S new file +0
-0
...
Quoted 3 lines
+/*!
+ * @filemx51_babbage/flash_head.S
+ * @brief Thie file contains the information as the image header for boot.
S/Thie/This/ ?
Please explain what "image header" means. U-Boot has an image geader, too, but you probably refer to something different.
Quoted 3 lines
+ * The boot rom code will parse this structure , load image and initial
+ * hardware as the description of hardware setting.
+ */
I read: "The ROM code will ... load ... initial hardware" ?
Something seems to be missing, or do you mean s/initial/initialize/ ?
Please clean up.
board/freescale/mx51_babbage/flash_header.S line 32
Quoted 6 lines
board/freescale/mx51_babbage/flash_header.S new file +6
-0+#include <config.h> +#include <asm/arch/mx51.h> +#include "board-mx51_babbage.h" + +#ifdef CONFIG_FLASH_HEADER +#ifndef CONFIG_FLASH_HEADER_OFFSET
It seems this is a iMX51 specific thing, right? Then please make this clear in the name oif the file and the macro names. "FLASH_HEADER" or "flash_head" is way too generic.
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 5 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +0
-0
How much of this is really board specific code, or how much of it should be moved to the CPU directory instead?
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 4 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +4
-0+int dram_init(void) +{ + gd->bd->bi_dram[0].start = PHYS_SDRAM_1; + gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
Please use get_ram_size() for autosizing and (simple) RAM test.
Quoted 5 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +5
-0+} + +static void setup_uart(void) +{ + unsigned int pad = PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE |
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 10 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +10
-0+ PAD_CTL_PUE_PULL | PAD_CTL_DRV_HIGH; + + mxc_request_iomux(MX51_PIN_UART1_RXD, IOMUX_CONFIG_ALT0); + mxc_iomux_set_pad(MX51_PIN_UART1_RXD, pad | PAD_CTL_SRE_FAST); + mxc_request_iomux(MX51_PIN_UART1_TXD, IOMUX_CONFIG_ALT0); + mxc_iomux_set_pad(MX51_PIN_UART1_TXD, pad | PAD_CTL_SRE_FAST); + mxc_request_iomux(MX51_PIN_UART1_RTS, IOMUX_CONFIG_ALT0); + mxc_iomux_set_pad(MX51_PIN_UART1_RTS, pad); + mxc_request_iomux(MX51_PIN_UART1_CTS, IOMUX_CONFIG_ALT0); + mxc_iomux_set_pad(MX51_PIN_UART1_CTS, pad);
Hmm... the comment in the code for mxc_request_iomux() reads:
* Request ownership for an IO pin. This function has to be the first one
* being called before that pin is used. The caller has to check the
* return value to make sure it returns 0.
I do not see any such checks in your code?
Either they are missing here, or the whole mxc_request_iomux() is not needed at all.
Quoted 2 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +2
-0+static void setup_expio(void) +{
...
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 3 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +3
-0+ /* WAL=0, WBED=1, WWSC=50, WADVA=2, WADVN=6, WEA=0, + * WEN=0, WCSA=0, WCSN=0 + */
Incorrect multiline comment. Please fix globally.
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 4 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +4
-0+ /* Reset interrupt status reg */ + writew(0x1F, mx51_io_base_addr + PBC_INT_REST); + writew(0x00, mx51_io_base_addr + PBC_INT_REST); + writew(0xFFFF, mx51_io_base_addr + PBC_INT_MASK);
As mentioned above: do not use base address plus offset, but use a proper C structure to define the register map.
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 6 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +6
-0+#ifdef BOARD_LATE_INIT +int board_late_init(void) +{ + return 0; +} +#endif
If the function is not needed, then don't implement it. Don;t add dead code.
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 12 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +12
-0+int checkboard(void) +{ + printf("Board: MX51 BABBAGE "); + + if (system_rev & CHIP_REV_2_5) + printf("2.5 ["); + else if (system_rev & CHIP_REV_2_0) + printf("2.0 ["); + else if (system_rev & CHIP_REV_1_1) + printf("1.1 ["); + else + printf("1.0 [");
Please use puts() for constant strings that don;t need any formatting.
board/freescale/mx51_babbage/u-boot.lds
Quoted 5 lines
board/freescale/mx51_babbage/u-boot.lds new file +0
-0
Does this board really need a specific linker script? Can we not use a generic one for all (or most of the) i.MX51 boards?
board/freescale/mx51_babbage/u-boot.lds line 40
Quoted 5 lines
board/freescale/mx51_babbage/u-boot.lds new file +5
-0+ . = ALIGN(4); + .text : + { + /* WARNING - the following is hand-optimized to fit within */ + /* the sector layout of our flash chips! XXX FIXME XXX */
Why is this needed / useful? It doesn't seem to match the environment definitions in your board config file.
...
Quoted 5 lines
cpu/arm_cortexa8/mx51/clock.c new file +0
-0
...
Quoted 1 line
+static u32
__decode_pll(enum pll_clocks pll, u32 infreq)
...
Quoted 1 line
+u32
__get_mcu_main_clk(void)
...
Quoted 1 line
+static u32
__get_periph_clk(void)
Is there any special reason for the "__" pat in all these names? You are aware that this has a special meaning in standard conforming C code, aren't you?
Please also add comments what all these functions are doing.
Hey, and add comments what the code is doing. It's not exactly obvious to me.
Quoted 6 lines
cpu/arm_cortexa8/mx51/clock.c new file +6
-0+u32 reg; + + reg =__raw_readl (MXC_CCM_CBCDR ); +if (reg &MXC_CCM_CBCDR_PERIPH_CLK_SEL ) { + reg =__raw_readl (MXC_CCM_CBCMR ); + switch ((reg & MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK) >>
cpu/arm_cortexa8/mx51/clock.c line 85
Quoted 10 lines
cpu/arm_cortexa8/mx51/clock.c new file +10
-0+ MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET) { +case 0 : +return __decode_pll (PLL1_CLK ,CONFIG_MX51_HCLK_FREQ ); +case 1 : +return __decode_pll (PLL3_CLK ,CONFIG_MX51_HCLK_FREQ ); +default : +return 0 ; + } + } +return __decode_pll (PLL2_CLK ,CONFIG_MX51_HCLK_FREQ );
In such cases it's better to turn around the logig, i. e. write:
if ((reg & MXC_CCM_CBCDR_PERIPH_CLK_SEL) == 0)
return __decode_pll(PLL2_CLK, CONFIG_MX51_HCLK_FREQ);
reg = __raw_readl(MXC_CCM_CBCMR);
switch ((reg & MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK) >>
MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET) {
case 0:
return __decode_pll(PLL1_CLK, CONFIG_MX51_HCLK_FREQ);
case 1:
return __decode_pll(PLL3_CLK, CONFIG_MX51_HCLK_FREQ);
default:
return 0;
}
/* NOTREACHED */You see? Less indentation = easier to read.
...
Quoted 4 lines
cpu/arm_cortexa8/mx51/clock.c new file +4
-0+void mxc_show_clocks (void ) +{ +u32 freq; +
cpu/arm_cortexa8/mx51/clock.c line 236
Quoted 10 lines
cpu/arm_cortexa8/mx51/clock.c new file +10
-0+ freq =__decode_pll (PLL1_CLK ,CONFIG_MX51_HCLK_FREQ ); +printf ("mx51 pll1: %dMHz\n" , freq /1000000 ); + freq =__decode_pll (PLL2_CLK ,CONFIG_MX51_HCLK_FREQ ); +printf ("mx51 pll2: %dMHz\n" , freq /1000000 ); + freq =__decode_pll (PLL3_CLK ,CONFIG_MX51_HCLK_FREQ ); +printf ("mx51 pll3: %dMHz\n" , freq /1000000 ); +printf ("ipg clock : %dHz\n" ,mxc_get_clock (MXC_IPG_CLK )); +printf ("ipg per clock : %dHz\n" ,mxc_get_clock (MXC_IPG_PERCLK )); +printf ("uart clock : %dHz\n" ,mxc_get_clock (MXC_UART_CLK )); +printf ("cspi clock : %dHz\n" ,mxc_get_clock (MXC_CSPI_CLK ));
Please don't print too much during regular boot. Either make this debug() code, or provide a separate command so the user can print this if he is interested in this information. Standard boot output shall be terse, as it affects boot ime.
cpu/arm_cortexa8/mx51/crm_regs.h
Quoted 5 lines
cpu/arm_cortexa8/mx51/crm_regs.h new file +0
-0
Should this file go to include/... ?
cpu/arm_cortexa8/mx51/crm_regs.h
Quoted 8 lines
cpu/arm_cortexa8/mx51/crm_regs.h new file +8
-0+/* +* Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved. +*/ + +/* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations:
See license header comments above.
Quoted 14 lines
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */cpu/arm_cortexa8/mx51/crm_regs.h new file +11
-0+#ifndef __ARCH_ARM_MACH_MX51_CRM_REGS_H__ +#define __ARCH_ARM_MACH_MX51_CRM_REGS_H__ + +#define MXC_CCM_BASE CCM_BASE_ADDR +#define MXC_DPLL1_BASE PLL1_BASE_ADDR +#define MXC_DPLL2_BASE PLL2_BASE_ADDR +#define MXC_DPLL3_BASE PLL3_BASE_ADDR + +/* PLL Register Offsets */ +#define MXC_PLL_DP_CTL 0x00 +#define MXC_PLL_DP_CONFIG 0x04
cpu/arm_cortexa8/mx51/crm_regs.h line 33
Quoted 10 lines
cpu/arm_cortexa8/mx51/crm_regs.h new file +10
-0+#define MXC_PLL_DP_OP 0x08 +#define MXC_PLL_DP_MFD 0x0C +#define MXC_PLL_DP_MFN 0x10 +#define MXC_PLL_DP_MFNMINUS 0x14 +#define MXC_PLL_DP_MFNPLUS 0x18 +#define MXC_PLL_DP_HFS_OP 0x1C +#define MXC_PLL_DP_HFS_MFD 0x20 +#define MXC_PLL_DP_HFS_MFN 0x24 +#define MXC_PLL_DP_MFN_TOGC 0x28 +#define MXC_PLL_DP_DESTAT 0x2c
See comments above - use C structs instead of offset definitions.
Quoted 5 lines
cpu/arm_cortexa8/mx51/iomux.c new file +0
-0
...
Quoted 10 lines
cpu/arm_cortexa8/mx51/iomux.c new file +10
-0+static inline u32 _get_mux_reg (iomux_pin_name_t pin) +{ +u32 mux_reg =PIN_TO_IOMUX_MUX (pin); + +if (is_soc_rev (CHIP_REV_2_0 ) <0 ) { +if ((pin ==MX51_PIN_NANDF_RB5 ) || + (pin ==MX51_PIN_NANDF_RB6 ) || + (pin ==MX51_PIN_NANDF_RB7 )) + ;/* Do nothing */ +else if (mux_reg >=0x2FC )
cpu/arm_cortexa8/mx51/iomux.c line 64
Quoted 10 lines
cpu/arm_cortexa8/mx51/iomux.c new file +10
-0+ mux_reg +=8 ; + else if (mux_reg >= 0x130) + mux_reg += 0xC; + } + mux_reg +=IOMUXSW_MUX_CTL ; +return mux_reg; +} + +static inline u32 _get_pad_reg (iomux_pin_name_t pin) +{
Please add comments what all this stuff is supposed to do.
Quoted 8 lines
cpu/arm_cortexa8/mx51/iomux.c new file +8
-0+ +if (is_soc_rev (CHIP_REV_2_0 ) <0 ) { +if ((pin ==MX51_PIN_NANDF_RB5 ) || + (pin ==MX51_PIN_NANDF_RB6 ) || + (pin ==MX51_PIN_NANDF_RB7 )) + ;/* Do nothing */ +else if (pad_reg ==0x4D0 -PAD_I_START ) + pad_reg +=0x4C ;
cpu/arm_cortexa8/mx51/iomux.c line 83
Quoted 10 lines
cpu/arm_cortexa8/mx51/iomux.c new file +10
-0+else if (pad_reg ==0x860 -PAD_I_START ) + pad_reg +=0x9C ; +else if (pad_reg >=0x804 -PAD_I_START ) + pad_reg +=0xB0 ; +else if (pad_reg >=0x7FC -PAD_I_START ) + pad_reg +=0xB4 ; +else if (pad_reg >=0x4E4 -PAD_I_START ) + pad_reg +=0xCC ; +else + pad_reg +=8 ;
You may also want to explain suchblack magic like the code here.
And please add parens around the (0x??? - PAD_I_START) parts.
...
Quoted 3 lines
+/*!
+ * This function is used to configure a pin through the IOMUX module.
+ * FIXED ME: for backward compatible. Will be static function!
I don't understand what this means. Please explain.
Quoted 6 lines
+ * @param pin a pin number as defined in \b #iomux_pin_name_t
+ * @param cfg an output function as defined in \b #iomux_pin_cfg_t
+ *
+ * @return 0 if successful; Non-zero otherwise
+ */
+static intiomux_config_mux(iomux_pin_name_t pin, iomux_pin_cfg_t cfg)
...
cpu/arm_cortexa8/mx51/iomux.c
Quoted 8 lines
cpu/arm_cortexa8/mx51/iomux.c new file +8
-0+#if defined(CONFIG_DISPLAY_CPUINFO ) +int print_cpuinfo (void ) +{ +printf ("CPU: Freescale i.MX51 family %d.%dV at %d MHz\n" , + (get_board_rev () &0xFF ) >>4 , + (get_board_rev () &0xF ), +__get_mcu_main_clk () /1000000 ); +mxc_show_clocks ();
Please see above - please be terse.
Quoted 5 lines
cpu/arm_cortexa8/mx51/timer.c new file +0
-0
...
cpu/arm_cortexa8/mx51/timer.c line 40
Quoted 11 lines
cpu/arm_cortexa8/mx51/timer.c new file +11
-0+/* General purpose timers registers */ +#define GPTCR GPT1_BASE_ADDR/* Control register */ +#define GPTPR (GPT1_BASE_ADDR + 0x4)/* Prescaler register */ +#define GPTSR (GPT1_BASE_ADDR + 0x8)/* Status register */ +#define GPTCNT (GPT1_BASE_ADDR + 0x24)/* Counter register */ + +/* General purpose timers bitfields */ +#define GPTCR_SWR (1<<15)/* Software reset */ +#define GPTCR_FRR (1<<9)/* Freerun / restart */ +#define GPTCR_CLKSOURCE_32 (4<<6)/* Clock source */ +#define GPTCR_TEN (1)/* Timer enable */
Move to header file. Use C struct instead of base addr + offsets.
...
Quoted 5 lines
cpu/arm_cortexa8/mx51/timer.c new file +5
-0+/*! +* defines for SPBA modules +*/ +#define SPBA_SDHC1 0x04 +#define SPBA_SDHC2 0x08
cpu/arm_cortexa8/mx51/timer.c
Quoted 10 lines
cpu/arm_cortexa8/mx51/timer.c new file +10
-0+#define SPBA_UART3 0x0C +#define SPBA_CSPI1 0x10 +#define SPBA_SSI2 0x14 +#define SPBA_SDHC3 0x20 +#define SPBA_SDHC4 0x24 +#define SPBA_SPDIF 0x28 +#define SPBA_ATA 0x30 +#define SPBA_SLIM 0x34 +#define SPBA_HSI2C 0x38 +#define SPBA_CTRL 0x3C
Use C struct ?
Quoted 99 lines
cpu/arm_cortexa8/mx51/timer.c new file +99
-0+/* +* Interrupt numbers +*/ +#define MXC_INT_BASE 0 +#define MXC_INT_RESV0 0 +#define MXC_INT_MMC_SDHC1 1 +#define MXC_INT_MMC_SDHC2 2 +#define MXC_INT_MMC_SDHC3 3 +#define MXC_INT_MMC_SDHC4 4 +#define MXC_INT_RESV5 5 +#define MXC_INT_SDMA 6 +#define MXC_INT_IOMUX 7 +#define MXC_INT_NFC 8 +#define MXC_INT_VPU 9 +#define MXC_INT_IPU_ERR 10 +#define MXC_INT_IPU_SYN 11 +#define MXC_INT_GPU 12 +#define MXC_INT_RESV13 13 +#define MXC_INT_USB_H1 14 +#define MXC_INT_EMI 15 +#define MXC_INT_USB_H2 16 +#define MXC_INT_USB_H3 17 +#define MXC_INT_USB_OTG 18 +#define MXC_INT_SAHARA_H0 19 +#define MXC_INT_SAHARA_H1 20 +#define MXC_INT_SCC_SMN 21 +#define MXC_INT_SCC_STZ 22 +#define MXC_INT_SCC_SCM 23 +#define MXC_INT_SRTC_NTZ 24 +#define MXC_INT_SRTC_TZ 25 +#define MXC_INT_RTIC 26 +#define MXC_INT_CSU 27 +#define MXC_INT_SLIM_B 28 +#define MXC_INT_SSI1 29 +#define MXC_INT_SSI2 30 +#define MXC_INT_UART1 31 +#define MXC_INT_UART2 32 +#define MXC_INT_UART3 33 +#define MXC_INT_RESV34 34 +#define MXC_INT_RESV35 35 +#define MXC_INT_CSPI1 36 +#define MXC_INT_CSPI2 37 +#define MXC_INT_CSPI 38 +#define MXC_INT_GPT 39 +#define MXC_INT_EPIT1 40 +#define MXC_INT_EPIT2 41 +#define MXC_INT_GPIO1_INT7 42 +#define MXC_INT_GPIO1_INT6 43 +#define MXC_INT_GPIO1_INT5 44 +#define MXC_INT_GPIO1_INT4 45 +#define MXC_INT_GPIO1_INT3 46 +#define MXC_INT_GPIO1_INT2 47 +#define MXC_INT_GPIO1_INT1 48 +#define MXC_INT_GPIO1_INT0 49 +#define MXC_INT_GPIO1_LOW 50 +#define MXC_INT_GPIO1_HIGH 51 +#define MXC_INT_GPIO2_LOW 52 +#define MXC_INT_GPIO2_HIGH 53 +#define MXC_INT_GPIO3_LOW 54 +#define MXC_INT_GPIO3_HIGH 55 +#define MXC_INT_GPIO4_LOW 56 +#define MXC_INT_GPIO4_HIGH 57 +#define MXC_INT_WDOG1 58 +#define MXC_INT_WDOG2 59 +#define MXC_INT_KPP 60 +#define MXC_INT_PWM1 61 +#define MXC_INT_I2C1 62 +#define MXC_INT_I2C2 63 +#define MXC_INT_HS_I2C 64 +#define MXC_INT_RESV65 65 +#define MXC_INT_RESV66 66 +#define MXC_INT_SIM_IPB 67 +#define MXC_INT_SIM_DAT 68 +#define MXC_INT_IIM 69 +#define MXC_INT_ATA 70 +#define MXC_INT_CCM1 71 +#define MXC_INT_CCM2 72 +#define MXC_INT_GPC1 73 +#define MXC_INT_GPC2 74 +#define MXC_INT_SRC 75 +#define MXC_INT_NM 76 +#define MXC_INT_PMU 77 +#define MXC_INT_CTI_IRQ 78 +#define MXC_INT_CTI1_TG0 79 +#define MXC_INT_CTI1_TG1 80 +#define MXC_INT_MCG_ERR 81 +#define MXC_INT_MCG_TMR 82 +#define MXC_INT_MCG_FUNC 83 +#define MXC_INT_RESV84 84 +#define MXC_INT_RESV85 85 +#define MXC_INT_RESV86 86 +#define MXC_INT_FEC 87 +#define MXC_INT_OWIRE 88 +#define MXC_INT_CTI1_TG2 89 +#define MXC_INT_SJC 90 +#define MXC_INT_SPDIF 91 +#define MXC_INT_TVE 92 +#define MXC_INT_FIRI 93 +#define MXC_INT_PWM2 94
cpu/arm_cortexa8/mx51/timer.c
Quoted 10 lines
cpu/arm_cortexa8/mx51/timer.c new file +10
-0+#define MXC_INT_SLIM_EXP 95 +#define MXC_INT_SSI3 96 +#define MXC_INT_RESV97 97 +#define MXC_INT_CTI1_TG3 98 +#define MXC_INT_SMC_RX 99 +#define MXC_INT_VPU_IDLE 100 +#define MXC_INT_RESV101 101 +#define MXC_INT_GPU_IDLE 102 + +#define MXC_MAX_INT_LINES 128
Use C struct ?
And so on and on ...
Quoted 5 lines
include/configs/mx51_babbage.h new file +0
-0
...
Quoted 1 line
+#define
BOARD_LATE_INIT
Why do you #define this, when you don't need it at all?
include/configs/mx51_babbage.h line 123
Quoted 2 lines
include/configs/mx51_babbage.h new file +2
-0+#define CONFIG_SYS_MEMTEST_START 0/* memtest works on */ +#define CONFIG_SYS_MEMTEST_END 0x10000
That's not exactly a thorough testing, then. And is low memory really unused? Please check!
Quoted 1 line
+#undef
CONFIG_SYS_CLKS_IN_HZ/* everything, incl board info, in Hz */
Don't undef what doesn't exist.
include/configs/mx51_babbage.h line 129
Quoted 3 lines
include/configs/mx51_babbage.h new file +3
-0+#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR + +#define CONFIG_SYS_HZ CONFIG_MX51_CLK32/* use 32kHz clock as source */
CONFIG_SYS_HZ must be 1000.
Best regards,
Wolfgang Denk
Signature · 6 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 Voodoo Programming: Things programmers do that they know shouldn't work but they try anyway, and which sometimes actually work, such as recompiling everything. - Karl Lehenbauer
PATCH 1/1 imx51:Add support basic boot code of freescale imx51 bbg board
Dear wolfgang,
I almost fixed all of your comments.
By some of them I can not fix them now.
1) Copyright block. It defined freescale other team. I can not change them
directly.
2) iomux module can not use C structure to access registers. Because
register has
encoded in to pin definition.
When I tested the new code on target board, I will send out to review
again.
Best Regards
Fred
2009/9/24 Wolfgang Denk <[email protected]>
Quoted 40 lines
Dear Fred Fan,
Quoted 6 lines · In message <[email protected]> you wrote:
This patch just supports boot into u-boot from mmc or spi-nor flash. It just implements console, iomux and clock. There are no ethernet, nor-flash, mmc or other peripheral drivers.
Signed-off-by Fred.Fan <[email protected]>Signed-off-by Fred.Fan <[email protected]>Please use a shorter subject (it gets tructaed), something like:
mx51_babbage: add support for Freescale iMX51 board [Fred] okMAKEALL LIST_ARM_CORTEX_A8=" \ · line 584
Quoted 9 lines
MAKEALL +1
-0@@ -581,6 +581,7 @@ LIST_ARM_CORTEX_A8=" \ omap3_pandora \ omap3_zoom1 \ omap3_zoom2 \ + mx51_babbage \Please keep lists sorted.
[Fred] ok.Review
Quoted 1 line
(quoted diff) +0
-0
b/board/freescale/mx51_babbage/board-mx51_babbage.hboard/freescale/mx51_babbage/board-mx51_babbage.h
Quoted 4 lines
new file mode 100644
index 0000000..31e3875board/freescale/mx51_babbage/board-mx51_babbage.h new file +0
-0Please drop the "board-" part of the file name.
[Fred] ok.Quoted 4 lines
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
Quoted 6 lines
Please use correct licnese terms. Specify which version of the license applies, i. e. use something like:
This code is licensed under the GPL, version 2 (or any later version). [Fred] Thanks. But this copyright block is defined by freescale.
It is used at the latest freescale's source or header file in linux
kernel.
I will tell our team about this comment.
Could I keep the block until it is changed by freescale?
Quoted 69 lines
Quoted 4 lines
+/*!
+ * @defgroupBRDCFG_MX51_BABBAGEBoard Configuration Options
+ * @ingroupMSL_MX51_BABBAGE
+ */Please get rid of this "!", "@defgroup", "@ingroup" etc. stuff. [Fred] ok
Quoted 2 lines
+/*!
+ * @filemx51_babbage/board-mx51_babbage.hDrop this line. It carries no information.
[Fred] okQuoted 2 lines
+ * @brief This file contains all the board level configuration options.
+ *Drop the blank line.
[Fred] ok.Quoted 3 lines
+ * It currently hold the options defined for MX51 babbage Platform.
+ *
+ * @ingroupBRDCFG_MX51_BABBAGEDrop this line, Please apply similar to the rest of the code. [Fred] ok.
board/freescale/mx51_babbage/board-mx51_babbage.h line 42
Quoted 11 lines
board/freescale/mx51_babbage/board-mx51_babbage.h new file +11
-0+/* CPLD offsets */ +#define PBC_LED_CTRL (0x20000) +#define PBC_SB_STAT (0x20008) +#define PBC_ID_AAAA (0x20040) +#define PBC_ID_5555 (0x20048) +#define PBC_VERSION (0x20050) +#define PBC_ID_CAFE (0x20058) +#define PBC_INT_STAT (0x20010) +#define PBC_INT_MASK (0x20038) +#define PBC_INT_REST (0x20020) +#define PBC_SW_RESET (0x20060)Don't use base address + offsets, but declare proper C structures to describe the register layout. Then use I/O accessors to access registers.
[Fred] okReview
Quoted 1 line
(quoted diff) +0
-0config.mk
board/freescale/mx51_babbage/config.mk line 2
Quoted 7 lines
new file mode 100644
index 0000000..d8b0f10board/freescale/mx51_babbage/config.mk new file +2
-0@@ -0,0 +1,2 @@ +LDSCRIPT = board/$(VENDOR)/$(BOARD)/u-boot.lds +TEXT_BASE = 0x97800000Even though the file is short, please add a (C) and license header. [Fred] ok
Review
Quoted 1 line
(quoted diff) +0
-0
b/board/freescale/mx51_babbage/flash_header.SQuoted 4 lines
new file mode 100644
index 0000000..bbac2c1board/freescale/mx51_babbage/flash_header.S new file +0
-0...
Quoted 3 lines
+/*!
+ * @filemx51_babbage/flash_head.S
+ * @brief Thie file contains the information as the image header forboot.
S/Thie/This/ ?
[Fred] ok
Please explain what "image header" means. U-Boot has an image geader, too, but you probably refer to something different.
Quoted 8 lines
Quoted 3 lines
+ * The boot rom code will parse this structure , load image and initial
+ * hardware as the description of hardware setting.
+ */I read: "The ROM code will ... load ... initial hardware" ? [Fred] MX family soc has internal boot mode. At this mode, the rom code in soc will
read the setting array to initial hardware.
Something seems to be missing, or do you mean s/initial/initialize/ ?
Quoted 23 lines
Please clean up.
[Fred] Changedboard/freescale/mx51_babbage/flash_header.S line 32
Quoted 6 lines
board/freescale/mx51_babbage/flash_header.S new file +6
-0+#include <config.h> +#include <asm/arch/mx51.h> +#include "board-mx51_babbage.h" + +#ifdef CONFIG_FLASH_HEADER +#ifndef CONFIG_FLASH_HEADER_OFFSETIt seems this is a iMX51 specific thing, right? Then please make this clear in the name oif the file and the macro names. "
FLASH_HEADER" or "flash_head" is way too generic.
[Fred] It is coming from freescale spec. It is the header of boot image for freescale internal boot mode.Review
Quoted 1 line
(quoted diff) +0
-0
b/board/freescale/mx51_babbage/lowlevel_init.S
Quoted 10 lines
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 4 lines
new file mode 100644
index 0000000..bf536b1board/freescale/mx51_babbage/lowlevel_init.S new file +0
-0How much of this is really board specific code, or how much of it should be moved to the CPU directory instead?
[Fred] Although freescale's boards use same configuration about M4IF, AIPS or others.
we can not sure other boards will use same configuration use freescale
boards.
Quoted 30 lines
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 5 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +4
-0+int dram_init(void) +{ + gd->bd->bi_dram[0].start = PHYS_SDRAM_1; + gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;Please use
get_ram_size()for autosizing and (simple) RAM test. [Fred] okQuoted 5 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +5
-0+} + +static void setup_uart(void) +{ + unsigned int pad = PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE |board/freescale/mx51_babbage/lowlevel_init.S
Quoted 10 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +10
-0+ PAD_CTL_PUE_PULL | PAD_CTL_DRV_HIGH; + + mxc_request_iomux(MX51_PIN_UART1_RXD, IOMUX_CONFIG_ALT0); + mxc_iomux_set_pad(MX51_PIN_UART1_RXD, pad | PAD_CTL_SRE_FAST); + mxc_request_iomux(MX51_PIN_UART1_TXD, IOMUX_CONFIG_ALT0); + mxc_iomux_set_pad(MX51_PIN_UART1_TXD, pad | PAD_CTL_SRE_FAST); + mxc_request_iomux(MX51_PIN_UART1_RTS, IOMUX_CONFIG_ALT0); + mxc_iomux_set_pad(MX51_PIN_UART1_RTS, pad); + mxc_request_iomux(MX51_PIN_UART1_CTS, IOMUX_CONFIG_ALT0); + mxc_iomux_set_pad(MX51_PIN_UART1_CTS, pad);Hmm... the comment in the code for
mxc_request_iomux()reads:* Request ownership for an IO pin. This function has to be the first one
* being called before that pin is used. The caller has to check the
* return value to make sure it returns 0.
Quoted 6 lines
I do not see any such checks in your code?
Either they are missing here, or the whole
mxc_request_iomux()is not needed at all.
[Fred] OK. I changed these functions to non return function.
Because boot load is not dynamic active or modules, there are no modules with muxed pins.
Quoted 50 lines
Quoted 2 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +2
-0+static void setup_expio(void) +{...
board/freescale/mx51_babbage/lowlevel_init.S
Quoted 3 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +3
-0+ /* WAL=0, WBED=1, WWSC=50, WADVA=2, WADVN=6, WEA=0, + * WEN=0, WCSA=0, WCSN=0 + */Incorrect multiline comment. Please fix globally.
[Fred] oKboard/freescale/mx51_babbage/lowlevel_init.S
Quoted 4 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +4
-0+ /* Reset interrupt status reg */ + writew(0x1F, mx51_io_base_addr + PBC_INT_REST); + writew(0x00, mx51_io_base_addr + PBC_INT_REST); + writew(0xFFFF, mx51_io_base_addr + PBC_INT_MASK);As mentioned above: do not use base address plus offset, but use a proper C structure to define the register map.
[Fred] ok.board/freescale/mx51_babbage/lowlevel_init.S
Quoted 6 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +6
-0+#ifdef BOARD_LATE_INIT +int board_late_init(void) +{ + return 0; +} +#endifIf the function is not needed, then don't implement it. Don;t add dead code.
[Fred] ok.board/freescale/mx51_babbage/lowlevel_init.S
Quoted 12 lines
board/freescale/mx51_babbage/lowlevel_init.S new file +12
-0+int checkboard(void) +{ + printf("Board: MX51 BABBAGE "); + + if (system_rev & CHIP_REV_2_5) + printf("2.5 ["); + else if (system_rev & CHIP_REV_2_0) + printf("2.0 ["); + else if (system_rev & CHIP_REV_1_1) + printf("1.1 ["); + else + printf("1.0 [");Please use
puts()for constant strings that don;t need any formatting. [Fred] ok.Review
Quoted 1 line
(quoted diff) +0
-0
b/board/freescale/mx51_babbage/u-boot.lds
Quoted 9 lines
board/freescale/mx51_babbage/u-boot.lds
Quoted 4 lines
new file mode 100644
index 0000000..f608a6dboard/freescale/mx51_babbage/u-boot.lds new file +0
-0Does this board really need a specific linker script? Can we not use a generic one for all (or most of the) i.MX51 boards?
[Fred] Need link flash header at the top of image.
Later tefano Babic will fix it.
Quoted 196 lines
board/freescale/mx51_babbage/u-boot.lds line 40
Quoted 5 lines
board/freescale/mx51_babbage/u-boot.lds new file +5
-0+ . = ALIGN(4); + .text : + { + /* WARNING - the following is hand-optimized to fit within */ + /* the sector layout of our flash chips! XXX FIXME XXX */Why is this needed / useful? It doesn't seem to match the environment definitions in your board config file.
[Fred] i.MX51 babbage no such issue.
...Review
Quoted 1 line
(quoted diff) +0
-0
b/cpu/arm_cortexa8/mx51/clock.cQuoted 4 lines
new file mode 100644
index 0000000..3abcdc8cpu/arm_cortexa8/mx51/clock.c new file +0
-0...
Quoted 1 line
+static u32
__decode_pll(enum pll_clocks pll, u32 infreq)...
Quoted 1 line
+u32
__get_mcu_main_clk(void)...
Quoted 1 line
+static u32
__get_periph_clk(void)Is there any special reason for the "__" pat in all these names? You are aware that this has a special meaning in standard conforming C code, aren't you?
Please also add comments what all these functions are doing.
Hey, and add comments what the code is doing. It's not exactly obvious to me.
[Fred] OK.cpu/arm_cortexa8/mx51/clock.c
Quoted 9 lines
cpu/arm_cortexa8/mx51/clock.c new file +9
-0+u32 reg; + + reg =__raw_readl (MXC_CCM_CBCDR ); +if (reg &MXC_CCM_CBCDR_PERIPH_CLK_SEL ) { + reg =__raw_readl (MXC_CCM_CBCMR ); +switch ((reg &MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK ) >> +MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET ) { +case 0 : + return __decode_pll(PLL1_CLK,
CONFIG_MX51_HCLK_FREQ);cpu/arm_cortexa8/mx51/clock.c
Quoted 2 lines
cpu/arm_cortexa8/mx51/clock.c new file +2
-0+case 1 : + return __decode_pll(PLL3_CLK,
CONFIG_MX51_HCLK_FREQ);cpu/arm_cortexa8/mx51/clock.c line 85
Quoted 5 lines
cpu/arm_cortexa8/mx51/clock.c new file +5
-0+default : +return 0 ; + } + } +return __decode_pll (PLL2_CLK ,CONFIG_MX51_HCLK_FREQ );In such cases it's better to turn around the logig, i. e. write:
if ((reg & MXC_CCM_CBCDR_PERIPH_CLK_SEL) == 0) return __decode_pll(PLL2_CLK, CONFIG_MX51_HCLK_FREQ); reg = __raw_readl(MXC_CCM_CBCMR); switch ((reg & MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK) >> MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET) { case 0: return __decode_pll(PLL1_CLK, CONFIG_MX51_HCLK_FREQ); case 1: return __decode_pll(PLL3_CLK, CONFIG_MX51_HCLK_FREQ); default: return 0; } /* NOTREACHED */You see? Less indentation = easier to read.
[Fred] Thanks very mush.
...Quoted 4 lines
cpu/arm_cortexa8/mx51/clock.c new file +4
-0+void mxc_show_clocks (void ) +{ +u32 freq; +cpu/arm_cortexa8/mx51/clock.c line 236
Quoted 10 lines
cpu/arm_cortexa8/mx51/clock.c new file +10
-0+ freq =__decode_pll (PLL1_CLK ,CONFIG_MX51_HCLK_FREQ ); +printf ("mx51 pll1: %dMHz\n" , freq /1000000 ); + freq =__decode_pll (PLL2_CLK ,CONFIG_MX51_HCLK_FREQ ); +printf ("mx51 pll2: %dMHz\n" , freq /1000000 ); + freq =__decode_pll (PLL3_CLK ,CONFIG_MX51_HCLK_FREQ ); +printf ("mx51 pll3: %dMHz\n" , freq /1000000 ); +printf ("ipg clock : %dHz\n" ,mxc_get_clock (MXC_IPG_CLK )); +printf ("ipg per clock : %dHz\n" ,mxc_get_clock (MXC_IPG_PERCLK )); +printf ("uart clock : %dHz\n" ,mxc_get_clock (MXC_UART_CLK )); +printf ("cspi clock : %dHz\n" ,mxc_get_clock (MXC_CSPI_CLK ));Please don't print too much during regular boot. Either make this
debug()code, or provide a separate command so the user can print this if he is interested in this information. Standard boot output shall be terse, as it affects boot ime.
[Fred] OK. I just keep some core clock.Review
Quoted 1 line
(quoted diff) +0
-0
b/cpu/arm_cortexa8/mx51/crm_regs.hcpu/arm_cortexa8/mx51/crm_regs.h
Quoted 4 lines
new file mode 100644
index 0000000..6436bedcpu/arm_cortexa8/mx51/crm_regs.h new file +0
-0Should this file go to
include/... ?
[Fred] ok.cpu/arm_cortexa8/mx51/crm_regs.h
Quoted 8 lines
cpu/arm_cortexa8/mx51/crm_regs.h new file +8
-0+/* +* Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved. +*/ + +/* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: See license header comments above.
[Fred] Could I keep our block until freescale agree to change them?Quoted 13 lines
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html> + */cpu/arm_cortexa8/mx51/crm_regs.h new file +11
-0+#ifndef __ARCH_ARM_MACH_MX51_CRM_REGS_H__ +#define __ARCH_ARM_MACH_MX51_CRM_REGS_H__ + +#define MXC_CCM_BASE CCM_BASE_ADDR +#define MXC_DPLL1_BASE PLL1_BASE_ADDR +#define MXC_DPLL2_BASE PLL2_BASE_ADDR +#define MXC_DPLL3_BASE PLL3_BASE_ADDR + +/* PLL Register Offsets */ +#define MXC_PLL_DP_CTL 0x00 +#define MXC_PLL_DP_CONFIG 0x04cpu/arm_cortexa8/mx51/crm_regs.h line 33
Quoted 10 lines
cpu/arm_cortexa8/mx51/crm_regs.h new file +10
-0+#define MXC_PLL_DP_OP 0x08 +#define MXC_PLL_DP_MFD 0x0C +#define MXC_PLL_DP_MFN 0x10 +#define MXC_PLL_DP_MFNMINUS 0x14 +#define MXC_PLL_DP_MFNPLUS 0x18 +#define MXC_PLL_DP_HFS_OP 0x1C +#define MXC_PLL_DP_HFS_MFD 0x20 +#define MXC_PLL_DP_HFS_MFN 0x24 +#define MXC_PLL_DP_MFN_TOGC 0x28 +#define MXC_PLL_DP_DESTAT 0x2cSee comments above - use C structs instead of offset definitions.
Review
Quoted 1 line
(quoted diff) +0
-0
b/cpu/arm_cortexa8/mx51/iomux.cQuoted 4 lines
new file mode 100644
index 0000000..80082aacpu/arm_cortexa8/mx51/iomux.c new file +0
-0...
Quoted 10 lines
cpu/arm_cortexa8/mx51/iomux.c new file +10
-0+static inline u32 _get_mux_reg (iomux_pin_name_t pin) +{ +u32 mux_reg =PIN_TO_IOMUX_MUX (pin); + +if (is_soc_rev (CHIP_REV_2_0 ) <0 ) { +if ((pin ==MX51_PIN_NANDF_RB5 ) || + (pin ==MX51_PIN_NANDF_RB6 ) || + (pin ==MX51_PIN_NANDF_RB7 )) + ;/* Do nothing */ +else if (mux_reg >=0x2FC )cpu/arm_cortexa8/mx51/iomux.c line 64
Quoted 10 lines
cpu/arm_cortexa8/mx51/iomux.c new file +10
-0+ mux_reg +=8 ; + else if (mux_reg >= 0x130) + mux_reg += 0xC; + } + mux_reg +=IOMUXSW_MUX_CTL ; +return mux_reg; +} + +static inline u32 _get_pad_reg (iomux_pin_name_t pin) +{Please add comments what all this stuff is supposed to do. [Fred] OK.
Quoted 8 lines
cpu/arm_cortexa8/mx51/iomux.c new file +8
-0+ +if (is_soc_rev (CHIP_REV_2_0 ) <0 ) { +if ((pin ==MX51_PIN_NANDF_RB5 ) || + (pin ==MX51_PIN_NANDF_RB6 ) || + (pin ==MX51_PIN_NANDF_RB7 )) + ;/* Do nothing */ +else if (pad_reg ==0x4D0 -PAD_I_START ) + pad_reg +=0x4C ;cpu/arm_cortexa8/mx51/iomux.c line 83
Quoted 10 lines
cpu/arm_cortexa8/mx51/iomux.c new file +10
-0+else if (pad_reg ==0x860 -PAD_I_START ) + pad_reg +=0x9C ; +else if (pad_reg >=0x804 -PAD_I_START ) + pad_reg +=0xB0 ; +else if (pad_reg >=0x7FC -PAD_I_START ) + pad_reg +=0xB4 ; +else if (pad_reg >=0x4E4 -PAD_I_START ) + pad_reg +=0xCC ; +else + pad_reg +=8 ;
Quoted 6 lines
You may also want to explain suchblack magic like the code here.
And please add parens around the (0x??? -
PAD_I_START) parts. [Fred] OK.
iomux also use base + offset to access register. Because freescale
encode the register information into the pin definition. It is not easy to change to structure access.
Quoted 7 lines
+/*!
Quoted 2 lines
+ * This function is used to configure a pin through the IOMUX module.
+ * FIXED ME: for backward compatible. Will be static function!I don't understand what this means. Please explain.
[Fred] It is copied from kernel source code. At the old version in kernel,
there are different implementation.
Quoted 11 lines
Quoted 1 line
+ * @param pin a pin number as defined in \b
#iomux_pin_name_t
Quoted 1 line
+ * @param cfg an output function as defined in \b
#iomux_pin_cfg_t
Quoted 4 lines
+ *
+ * @return 0 if successful; Non-zero otherwise
+ */
+static intiomux_config_mux(iomux_pin_name_t pin, iomux_pin_cfg_t cfg)...
Quoted 12 lines
cpu/arm_cortexa8/mx51/iomux.c
Quoted 8 lines
cpu/arm_cortexa8/mx51/iomux.c new file +8
-0+#if defined(CONFIG_DISPLAY_CPUINFO ) +int print_cpuinfo (void ) +{ +printf ("CPU: Freescale i.MX51 family %d.%dV at %d MHz\n" , + (get_board_rev () &0xFF ) >>4 , + (get_board_rev () &0xF ), +__get_mcu_main_clk () /1000000 ); +mxc_show_clocks ();Please see above - please be terse.
[Fred] We want to show the chip version: TO1 version or TO2, etc.
So customer get the hardware information about soc level.
Quoted 152 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/cpu/arm_cortexa8/mx51/timer.cQuoted 4 lines
new file mode 100644
index 0000000..5201768cpu/arm_cortexa8/mx51/timer.c new file +0
-0...
cpu/arm_cortexa8/mx51/timer.c line 40
Quoted 11 lines
cpu/arm_cortexa8/mx51/timer.c new file +11
-0+/* General purpose timers registers */ +#define GPTCR GPT1_BASE_ADDR/* Control register */ +#define GPTPR (GPT1_BASE_ADDR + 0x4)/* Prescaler register */ +#define GPTSR (GPT1_BASE_ADDR + 0x8)/* Status register */ +#define GPTCNT (GPT1_BASE_ADDR + 0x24)/* Counter register */ + +/* General purpose timers bitfields */ +#define GPTCR_SWR (1<<15)/* Software reset */ +#define GPTCR_FRR (1<<9)/* Freerun / restart */ +#define GPTCR_CLKSOURCE_32 (4<<6)/* Clock source */ +#define GPTCR_TEN (1)/* Timer enable */ Move to header file. Use C struct instead of base addr + offsets. [Fred] ok.
...Quoted 5 lines
cpu/arm_cortexa8/mx51/timer.c new file +5
-0+/*! +* defines for SPBA modules +*/ +#define SPBA_SDHC1 0x04 +#define SPBA_SDHC2 0x08cpu/arm_cortexa8/mx51/timer.c
Quoted 10 lines
cpu/arm_cortexa8/mx51/timer.c new file +10
-0+#define SPBA_UART3 0x0C +#define SPBA_CSPI1 0x10 +#define SPBA_SSI2 0x14 +#define SPBA_SDHC3 0x20 +#define SPBA_SDHC4 0x24 +#define SPBA_SPDIF 0x28 +#define SPBA_ATA 0x30 +#define SPBA_SLIM 0x34 +#define SPBA_HSI2C 0x38 +#define SPBA_CTRL 0x3CUse C struct ?
[Fred] ok.Quoted 99 lines
cpu/arm_cortexa8/mx51/timer.c new file +99
-0+/* +* Interrupt numbers +*/ +#define MXC_INT_BASE 0 +#define MXC_INT_RESV0 0 +#define MXC_INT_MMC_SDHC1 1 +#define MXC_INT_MMC_SDHC2 2 +#define MXC_INT_MMC_SDHC3 3 +#define MXC_INT_MMC_SDHC4 4 +#define MXC_INT_RESV5 5 +#define MXC_INT_SDMA 6 +#define MXC_INT_IOMUX 7 +#define MXC_INT_NFC 8 +#define MXC_INT_VPU 9 +#define MXC_INT_IPU_ERR 10 +#define MXC_INT_IPU_SYN 11 +#define MXC_INT_GPU 12 +#define MXC_INT_RESV13 13 +#define MXC_INT_USB_H1 14 +#define MXC_INT_EMI 15 +#define MXC_INT_USB_H2 16 +#define MXC_INT_USB_H3 17 +#define MXC_INT_USB_OTG 18 +#define MXC_INT_SAHARA_H0 19 +#define MXC_INT_SAHARA_H1 20 +#define MXC_INT_SCC_SMN 21 +#define MXC_INT_SCC_STZ 22 +#define MXC_INT_SCC_SCM 23 +#define MXC_INT_SRTC_NTZ 24 +#define MXC_INT_SRTC_TZ 25 +#define MXC_INT_RTIC 26 +#define MXC_INT_CSU 27 +#define MXC_INT_SLIM_B 28 +#define MXC_INT_SSI1 29 +#define MXC_INT_SSI2 30 +#define MXC_INT_UART1 31 +#define MXC_INT_UART2 32 +#define MXC_INT_UART3 33 +#define MXC_INT_RESV34 34 +#define MXC_INT_RESV35 35 +#define MXC_INT_CSPI1 36 +#define MXC_INT_CSPI2 37 +#define MXC_INT_CSPI 38 +#define MXC_INT_GPT 39 +#define MXC_INT_EPIT1 40 +#define MXC_INT_EPIT2 41 +#define MXC_INT_GPIO1_INT7 42 +#define MXC_INT_GPIO1_INT6 43 +#define MXC_INT_GPIO1_INT5 44 +#define MXC_INT_GPIO1_INT4 45 +#define MXC_INT_GPIO1_INT3 46 +#define MXC_INT_GPIO1_INT2 47 +#define MXC_INT_GPIO1_INT1 48 +#define MXC_INT_GPIO1_INT0 49 +#define MXC_INT_GPIO1_LOW 50 +#define MXC_INT_GPIO1_HIGH 51 +#define MXC_INT_GPIO2_LOW 52 +#define MXC_INT_GPIO2_HIGH 53 +#define MXC_INT_GPIO3_LOW 54 +#define MXC_INT_GPIO3_HIGH 55 +#define MXC_INT_GPIO4_LOW 56 +#define MXC_INT_GPIO4_HIGH 57 +#define MXC_INT_WDOG1 58 +#define MXC_INT_WDOG2 59 +#define MXC_INT_KPP 60 +#define MXC_INT_PWM1 61 +#define MXC_INT_I2C1 62 +#define MXC_INT_I2C2 63 +#define MXC_INT_HS_I2C 64 +#define MXC_INT_RESV65 65 +#define MXC_INT_RESV66 66 +#define MXC_INT_SIM_IPB 67 +#define MXC_INT_SIM_DAT 68 +#define MXC_INT_IIM 69 +#define MXC_INT_ATA 70 +#define MXC_INT_CCM1 71 +#define MXC_INT_CCM2 72 +#define MXC_INT_GPC1 73 +#define MXC_INT_GPC2 74 +#define MXC_INT_SRC 75 +#define MXC_INT_NM 76 +#define MXC_INT_PMU 77 +#define MXC_INT_CTI_IRQ 78 +#define MXC_INT_CTI1_TG0 79 +#define MXC_INT_CTI1_TG1 80 +#define MXC_INT_MCG_ERR 81 +#define MXC_INT_MCG_TMR 82 +#define MXC_INT_MCG_FUNC 83 +#define MXC_INT_RESV84 84 +#define MXC_INT_RESV85 85 +#define MXC_INT_RESV86 86 +#define MXC_INT_FEC 87 +#define MXC_INT_OWIRE 88 +#define MXC_INT_CTI1_TG2 89 +#define MXC_INT_SJC 90 +#define MXC_INT_SPDIF 91 +#define MXC_INT_TVE 92 +#define MXC_INT_FIRI 93 +#define MXC_INT_PWM2 94cpu/arm_cortexa8/mx51/timer.c
Quoted 10 lines
cpu/arm_cortexa8/mx51/timer.c new file +10
-0+#define MXC_INT_SLIM_EXP 95 +#define MXC_INT_SSI3 96 +#define MXC_INT_RESV97 97 +#define MXC_INT_CTI1_TG3 98 +#define MXC_INT_SMC_RX 99 +#define MXC_INT_VPU_IDLE 100 +#define MXC_INT_RESV101 101 +#define MXC_INT_GPU_IDLE 102 + +#define MXC_MAX_INT_LINES 128Use C struct ?
Quoted 4 lines
And so on and on ...
[Fred] It is not register definitions. It is irq number. But uboot is not enable them.
I will remove them.
And there are some definitions will be used in assemble code. Must keep them.
Quoted 47 lines
include/configs/mx51_babbage.h +0
-0Quoted 4 lines
new file mode 100644
index 0000000..a24b39binclude/configs/mx51_babbage.h new file +0
-0...
Quoted 1 line
+#define
BOARD_LATE_INITWhy do you #define this, when you don't need it at all? [Fred] I removed. But it will be added in the furture for power supply operation.
include/configs/mx51_babbage.h line 123
Quoted 2 lines
include/configs/mx51_babbage.h new file +2
-0+#define CONFIG_SYS_MEMTEST_START 0/* memtest works on */ +#define CONFIG_SYS_MEMTEST_END 0x10000That's not exactly a thorough testing, then. And is low memory really unused? Please check!
[Fred] yes. It is not used. We just the bottom of ram.Quoted 1 line
+#undef
CONFIG_SYS_CLKS_IN_HZ/* everything, incl boardinfo, in Hz */
Don't undef what doesn't exist.
[Fred] OK. I will fix them.include/configs/mx51_babbage.h
Quoted 3 lines
include/configs/mx51_babbage.h new file +3
-0+#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR + +#define CONFIG_SYS_HZ CONFIG_MX51_CLK32/* use 32kHz clock as source */
CONFIG_SYS_HZmust be 1000.
[Fred] done.Best regards,
Wolfgang Denk
--
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 Voodoo Programming: Things programmers do that they know shouldn't work but they try anyway, and which sometimes actually work, such as
recompiling everything. - Karl Lehenbauer
PATCH 1/1 imx51:Add support basic boot code of freescale imx51 bbg board
Dear Fred Fan,
Quoted 5 lines · In message <[email protected]> you…
I almost fixed all of your comments.
By some of them I can not fix them now.
1) Copyright block. It defined freescale other team. I can not change them
directly.
I see. We will have to wait for this change, then.
Quoted 3 lines
2) iomux module can not use C structure to access registers. Because
register has
encoded in to pin definition.
I don't understand this statement. Why do you think this cannot be done with C structs and I/O accessors?
Quoted 2 lines
When I tested the new code on target board, I will send out to review
again.
I'm looking forward to get this mainlined, but please fix all issues first. Thanks.
Best regards,
Wolfgang Denk
Signature · 6 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 Even if you can deceive people about a product through misleading statements, sooner or later the product will speak for itself. - Hajime Karatsu
PATCH 1/1 imx51:Add support basic boot code of freescale imx51 bbg board
In reply to Fred FanQuoted 2 lines · Fred Fan
Dear wolfgang,
I almost fixed all of your comments.
Hi Fred,
I have already tested your patch on the babbage2 board and I would ask you about the status. The boot loader does not start (I have tried flashing the SPI NOR, and this seems ok. The code seems loaded from the flash) but the board hangs. With the debugger seems that it hangs in the init_clock assemby routine in lowlevel_init.S.
Have you seen the same behavior or do you think it depens on my environment ?
Regards,
Stefano
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/1 imx51:Add support basic boot code of freescale imx51 bbg board
HI Stefano Babic,
Sorry, I just see your and wolfgang's mail. In this days, I am prepare
new soc's kernel MSL code.
When I just finished my coding, I have same issue too. But during I identify this issue, the issue is
disappeared.
I does not change lowlevel_init.s. Maybe I removed some definitions of
clock register.
I will check it ASAP.
Best Regard
Fred
2009/12/4 Stefano Babic <[email protected]>
Quoted 25 lines
Quoted 2 lines · Fred Fan
Dear wolfgang,
I almost fixed all of your comments.Hi Fred,
I have already tested your patch on the babbage2 board and I would ask you about the status. The boot loader does not start (I have tried flashing the SPI NOR, and this seems ok. The code seems loaded from the flash) but the board hangs. With the debugger seems that it hangs in the
init_clockassemby routine inlowlevel_init.S.Have you seen the same behavior or do you think it depens on my environment ?
Regards,
Stefano--
=====================================================================
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/1 imx51:Add support basic boot code of freescale imx51 bbg board
Quoted 9 lines · Fred Fan
HI Stefano Babic,
Sorry, I just see your and wolfgang's mail. In this days, I am
prepare new soc's kernel MSL code.
When I just finished my coding, I have same issue too. But during I identify this issue, the issue is
disappeared.
I does not change lowlevel_init.s. Maybe I removed some definitions
of clock register.
I will check it ASAP.
Hi Fred,
do not worry, I could find where the problem is located. I started from the IMX51 BSP, changing code to adapt for the u-boot top of tree, and then I applied all changes you sent in your patchset. So I could check step by step where I had to look.
I do not find any issue in the cpu/mx51/clock.c and in the clock definitions, that you rearranged after the first review, so in this file everything seems ok ;)
Definitely I checked with the debugger that the problem arises in the first initialization of the clock registers in lowlevel_init.S (after the init_clock label).
I replaced the file with the one I found in the BSP and the board runs now flawlessly.
I have already removed the flashHeader.S, adding a new image format to support the i.MX51 processor and its DCD table.
I have opened another issue, too. I have seen that the name "babbage" is quite disappeared and on the Freescale's website this board is named now "mx51evk". I know you have already changed the name of the board, but I think the name "babbage" can confuse. Better should be to rename the board with the name we find in the official documentation. I know you already did this job, I can only volunteer myself to do that...
What do you think if I take over the job and I will resend all patches to the ML ? In this way I can easier integrate my changes, if you agree. Should be ok for you ?
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/1 imx51:Add support basic boot code of freescale imx51 bbg board
In reply to Fred FanQuoted 11 lines
-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Fred Fan
Sent: Wednesday, September 23, 2009 8:17 PM
To: u-boot at lists.denx.de
Cc: Fred.Fan
Subject: [U-Boot] [PATCH] imx51:Add support basic boot code of freescale imx51 bbg board
Quoted 6 lines
This patch just supports boot into u-boot from mmc or spi-nor flash. It just implements console, iomux and clock. There are no ethernet, nor-flash, mmc or other peripheral drivers.
Signed-off-by Fred.Fan <[email protected]>Signed-off-by Fred.Fan <[email protected]>
Do you really need two email references for the same person here?
Regards..
Prafulla . .
PATCH 1/1 imx51:Add support basic boot code of freescaleimx51 bbg board
Hi Prafulla:
if just one mail is permitted, I prefer to use
"fanyefeng at gmail.com".
Best Regards
Fred
-----Original Message-----
From: Prafulla Wadaskar [mailto:prafulla at marvell.com]
Sent: Thursday, September 24, 2009 12:35 PM
To: Fred Fan; u-boot at lists.denx.de
Cc: Fan YeFeng-R01011
Subject: RE: [U-Boot] [PATCH] imx51:Add support basic boot code of freescaleimx51 bbg board
Quoted 9 lines
-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Fred Fan
Sent: Wednesday, September 23, 2009 8:17 PM
To: u-boot at lists.denx.de
Cc: Fred.Fan
Subject: [U-Boot] [PATCH] imx51:Add support basic boot code of freescale imx51 bbg board
Quoted 6 lines
This patch just supports boot into u-boot from mmc or spi-nor flash. It just implements console, iomux and clock. There are no ethernet, nor-flash, mmc or other peripheral drivers.
Signed-off-by Fred.Fan <[email protected]>Signed-off-by Fred.Fan <[email protected]>
Do you really need two email references for the same person here?
Regards..
Prafulla . .