Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-15 Thread Jason Hui
On Mon, Nov 14, 2011 at 6:45 PM, Marek Vasut marek.va...@gmail.com wrote:
 On Mon, Nov 14, 2011 at 7:11 AM, Marek Vasut marek.va...@gmail.com wrote:
  i.MX6Q is freescale quad core processors with ARM cortex_a9 complex.
  This patch is to add the initial support for this processor.
 
  Signed-off-by: Jason Liu jason@linaro.org
  ---
   arch/arm/cpu/armv7/mx6/Makefile           |   48 +
   arch/arm/cpu/armv7/mx6/clock.c            |  388 +++
   arch/arm/cpu/armv7/mx6/iomux-v3.c         |   76 ++
   arch/arm/cpu/armv7/mx6/lowlevel_init.S    |   60 +
   arch/arm/cpu/armv7/mx6/soc.c              |   57 +
   arch/arm/include/asm/arch-mx6/ccm_regs.h  |  894 +++
   arch/arm/include/asm/arch-mx6/clock.h     |   50 +
   arch/arm/include/asm/arch-mx6/gpio.h      |   35 +
   arch/arm/include/asm/arch-mx6/imx-regs.h  |  233 
   arch/arm/include/asm/arch-mx6/iomux-v3.h  |  104 ++
   arch/arm/include/asm/arch-mx6/mx6x_pins.h | 1683
  + arch/arm/include/asm/arch-mx6/sys_proto.h
  | 38 +
   12 files changed, 3666 insertions(+), 0 deletions(-)
 
  [...]
 
  diff --git a/arch/arm/cpu/armv7/mx6/lowlevel_init.S
  b/arch/arm/cpu/armv7/mx6/lowlevel_init.S new file mode 100644
  index 000..7a03f59
  --- /dev/null
  +++ b/arch/arm/cpu/armv7/mx6/lowlevel_init.S
  @@ -0,0 +1,60 @@
  +/*
  + * Copyright (C) 2010-2011 Freescale Semiconductor, Inc.
  + *
  + * 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 config.h
  +#include asm/arch/imx-regs.h
  +
  +/*
  + * AIPS setup - Only setup MPROTx registers.
  + * Set all MPROTx to be non-bufferable,
  + * trusted for R/W, not forced to user-mode.
  + * The PACR default values are good.
  + */
  +.macro init_aips
  +     ldr r0, =AIPS1_ON_BASE_ADDR
  +     ldr r1, =0x
  +     str r1, [r0, #0x0]
  +     str r1, [r0, #0x4]
  +     ldr r1, =0x0
  +     str r1, [r0, #0x40]
  +     str r1, [r0, #0x44]
  +     str r1, [r0, #0x48]
  +     str r1, [r0, #0x4C]
  +     str r1, [r0, #0x50]
  +
  +     ldr r0, =AIPS2_ON_BASE_ADDR
  +     ldr r1, =0x
  +     str r1, [r0, #0x0]
  +     str r1, [r0, #0x4]
  +     ldr r1, =0x0
  +     str r1, [r0, #0x40]
  +     str r1, [r0, #0x44]
  +     str r1, [r0, #0x48]
  +     str r1, [r0, #0x4C]
  +     str r1, [r0, #0x50]
  +.endm /* init_aips */
 
  Can't this be done in C code? Why the assembly ?

 I think this should be initialized as early as possible, so I put it here.

 As early as arch_cpu_init is late (see arch/arm/lib/board.c)?

ok, Let's put it to arch_cpu_init. Thanks.


  +
  +.section .text.init, x
  +
  +.globl lowlevel_init
  +lowlevel_init:
  +
  +     init_aips
  +
  +     mov pc, lr
 
  [...]
 
  +#define MXC_CCM_CSCMR2_CAN_CLK_SEL_OFFSET            (2)
 
  Drop parenthesis around stuff similar to this.

 Yes, thanks.

  +#endif /*__ARCH_ARM_MACH_MX6_CCM_REGS_H__ */
  diff --git a/arch/arm/include/asm/arch-mx6/clock.h
  b/arch/arm/include/asm/arch-mx6/clock.h new file mode 100644
  index 000..636458f
  --- /dev/null
  +++ b/arch/arm/include/asm/arch-mx6/clock.h
  @@ -0,0 +1,50 @@
  +/*
  + * (C) Copyright 2009
  + * Stefano Babic, DENX Software Engineering, sba...@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
  + */
  +
  +#ifndef __ASM_ARCH_CLOCK_H
  +#define __ASM_ARCH_CLOCK_H
  +
  +enum mxc_clock {
  +     MXC_ARM_CLK = 0,
  +     MXC_PER_CLK,
  +     MXC_AHB_CLK,
  +     MXC_IPG_CLK,
  +     MXC_IPG_PERCLK,
  +     MXC_UART_CLK,
  +     MXC_CSPI_CLK,
  +    

Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-15 Thread Jason Hui
On Mon, Nov 14, 2011 at 7:49 PM, Stefano Babic sba...@denx.de wrote:
 On 11/14/2011 10:42 AM, Jason Hui wrote:


 All get_usdhcX function are identical, except for two masks
 (MXC_CCM_CSCDR1_USDHCx_PODF_MASK and MXC_CCM_CSCMR1_USDHCx_CLK_SEL).
 Merge them in a get_usdhc_clk(usdhc_number)


 Yes, I'm using mxc_ccm_reg.

 Ok - this structure is also used in most drivers - if I am not wrong
 (and I will better check), the struct clkctl is used only to generate
 the offsets in asm-offsets.h. If it is so, it could be drop in a future
 clean up patch...

Yes, agree!


 Maybe do we find a way to add a common include directory ? This file is
 duplicated. We can use include/asm/arch/imx-common

 I don't find one good way to add a common include directory. If I try
 to find one,
 I will put this head file to imx-common.

 The easy way is to add include/asm/arch-imx-common, and then the header
 are explicitely included as #include asm/arch-imx-common/...
 I have seen only another example in U-Boot for armv7:

 arch/arm/cpu/armv7/highbank/timer.c:#include asm/arch-armv7/systimer.h

 I am opened to other solutions, too, but I think that introducing a
 common repository for IMX include files (as Linux with plat_imx does) is
 the way to do.

ok,  thanks for the review.


 Best regards,
 Stefano Babic

 --
 =
 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: off...@denx.de
 =

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-15 Thread Stefano Babic
On 11/15/2011 11:10 AM, Jason Hui wrote:
 yes, we already had drivers/gpio/mxc_gpio.c driver. In this driver, we will
 use this structure. And it's the same as i.mx5 before.

 So why do you need to expose the structure, isn't it internal to the driver?
 Yes, it's internal to the gpio driver, but, all the soc does not have
 the same gpio_regs layout,
 so we put it here in order to have multiple #ifdef.
 Stefano, any comments for this?

We are using now the general GPIO framework - changes were done for all
iMX SOCs, and it is used in most other SOCs, too. So the general API is
exposed in include/asm/gpio.h.

We can have different implementation for each specific SOC. We want to
maintain only one driver (mxc_gpio.c), and the differences in layout are
done in arch/gpio.h (at the end, the structure we are talking about). As
you can see, there is a lot of specific implementation in asm/arch-*.
The generic API (include/asm/gpio.h) includes an arch specific file
asm/arch/gpio, and this file must be provided.

This allows us (theoretically) to adapt the driver to the specific
layout of the SOC. This helps if the layout of MX3x is differnt form the
layout of MX5x, MX6x,...

I admit that the layout for the interesting fields (data, direction) is
the same (see asm/arch-mx25/gpio.h, asm/arch-mx35/gpio.h and
asm/arch-mx5/gpio.h). There is the definition of other registers, but
they are not used. We have to provide in any case an arch specific
gpio.h, and this can contains the differences in layout, if any.

Another possibility can be to put the registers in a common place for
all IMX SOCs, and the arch specific gpio.h, required by the generic
gpio.h, will only include it. But if we go on on this solution (only if
we have *really* the same layout for all SOCs), this should be done for
all IMX in a shot, not only for one of them - I do not like to have
inconsistencies in the interface between IMX SOCs.

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: off...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-14 Thread Jason Hui
On Mon, Nov 14, 2011 at 7:11 AM, Marek Vasut marek.va...@gmail.com wrote:
 i.MX6Q is freescale quad core processors with ARM cortex_a9 complex.
 This patch is to add the initial support for this processor.

 Signed-off-by: Jason Liu jason@linaro.org
 ---
  arch/arm/cpu/armv7/mx6/Makefile           |   48 +
  arch/arm/cpu/armv7/mx6/clock.c            |  388 +++
  arch/arm/cpu/armv7/mx6/iomux-v3.c         |   76 ++
  arch/arm/cpu/armv7/mx6/lowlevel_init.S    |   60 +
  arch/arm/cpu/armv7/mx6/soc.c              |   57 +
  arch/arm/include/asm/arch-mx6/ccm_regs.h  |  894 +++
  arch/arm/include/asm/arch-mx6/clock.h     |   50 +
  arch/arm/include/asm/arch-mx6/gpio.h      |   35 +
  arch/arm/include/asm/arch-mx6/imx-regs.h  |  233 
  arch/arm/include/asm/arch-mx6/iomux-v3.h  |  104 ++
  arch/arm/include/asm/arch-mx6/mx6x_pins.h | 1683
 + arch/arm/include/asm/arch-mx6/sys_proto.h |
  38 +
  12 files changed, 3666 insertions(+), 0 deletions(-)


 [...]

 diff --git a/arch/arm/cpu/armv7/mx6/lowlevel_init.S
 b/arch/arm/cpu/armv7/mx6/lowlevel_init.S new file mode 100644
 index 000..7a03f59
 --- /dev/null
 +++ b/arch/arm/cpu/armv7/mx6/lowlevel_init.S
 @@ -0,0 +1,60 @@
 +/*
 + * Copyright (C) 2010-2011 Freescale Semiconductor, Inc.
 + *
 + * 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 config.h
 +#include asm/arch/imx-regs.h
 +
 +/*
 + * AIPS setup - Only setup MPROTx registers.
 + * Set all MPROTx to be non-bufferable,
 + * trusted for R/W, not forced to user-mode.
 + * The PACR default values are good.
 + */
 +.macro init_aips
 +     ldr r0, =AIPS1_ON_BASE_ADDR
 +     ldr r1, =0x
 +     str r1, [r0, #0x0]
 +     str r1, [r0, #0x4]
 +     ldr r1, =0x0
 +     str r1, [r0, #0x40]
 +     str r1, [r0, #0x44]
 +     str r1, [r0, #0x48]
 +     str r1, [r0, #0x4C]
 +     str r1, [r0, #0x50]
 +
 +     ldr r0, =AIPS2_ON_BASE_ADDR
 +     ldr r1, =0x
 +     str r1, [r0, #0x0]
 +     str r1, [r0, #0x4]
 +     ldr r1, =0x0
 +     str r1, [r0, #0x40]
 +     str r1, [r0, #0x44]
 +     str r1, [r0, #0x48]
 +     str r1, [r0, #0x4C]
 +     str r1, [r0, #0x50]
 +.endm /* init_aips */

 Can't this be done in C code? Why the assembly ?

I think this should be initialized as early as possible, so I put it here.


 +
 +.section .text.init, x
 +
 +.globl lowlevel_init
 +lowlevel_init:
 +
 +     init_aips
 +
 +     mov pc, lr
 [...]

 +#define MXC_CCM_CSCMR2_CAN_CLK_SEL_OFFSET            (2)

 Drop parenthesis around stuff similar to this.

Yes, thanks.


 +#endif /*__ARCH_ARM_MACH_MX6_CCM_REGS_H__ */
 diff --git a/arch/arm/include/asm/arch-mx6/clock.h
 b/arch/arm/include/asm/arch-mx6/clock.h new file mode 100644
 index 000..636458f
 --- /dev/null
 +++ b/arch/arm/include/asm/arch-mx6/clock.h
 @@ -0,0 +1,50 @@
 +/*
 + * (C) Copyright 2009
 + * Stefano Babic, DENX Software Engineering, sba...@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
 + */
 +
 +#ifndef __ASM_ARCH_CLOCK_H
 +#define __ASM_ARCH_CLOCK_H
 +
 +enum mxc_clock {
 +     MXC_ARM_CLK = 0,
 +     MXC_PER_CLK,
 +     MXC_AHB_CLK,
 +     MXC_IPG_CLK,
 +     MXC_IPG_PERCLK,
 +     MXC_UART_CLK,
 +     MXC_CSPI_CLK,
 +     MXC_AXI_CLK,
 +     MXC_EMI_SLOW_CLK,
 +     MXC_DDR_CLK,
 +     MXC_ESDHC_CLK,
 +     MXC_ESDHC2_CLK,
 +     MXC_ESDHC3_CLK,
 +     MXC_ESDHC4_CLK,
 +     MXC_SATA_CLK,
 +     MXC_NFC_CLK,
 +};
 +
 +u32 imx_get_uartclk(void);
 +u32 imx_get_fecclk(void);
 +unsigned int mxc_get_clock(enum mxc_clock clk);
 +
 +#endif /* 

Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-14 Thread Stefano Babic
On 11/12/2011 11:36 AM, Jason Liu wrote:
 i.MX6Q is freescale quad core processors with ARM cortex_a9 complex.
 This patch is to add the initial support for this processor.
 
 Signed-off-by: Jason Liu jason@linaro.org
 ---
  arch/arm/cpu/armv7/mx6/Makefile   |   48 +
  arch/arm/cpu/armv7/mx6/clock.c|  388 +++
  arch/arm/cpu/armv7/mx6/iomux-v3.c |   76 ++
  arch/arm/cpu/armv7/mx6/lowlevel_init.S|   60 +
  arch/arm/cpu/armv7/mx6/soc.c  |   57 +
  arch/arm/include/asm/arch-mx6/ccm_regs.h  |  894 +++
  arch/arm/include/asm/arch-mx6/clock.h |   50 +
  arch/arm/include/asm/arch-mx6/gpio.h  |   35 +
  arch/arm/include/asm/arch-mx6/imx-regs.h  |  233 
  arch/arm/include/asm/arch-mx6/iomux-v3.h  |  104 ++
  arch/arm/include/asm/arch-mx6/mx6x_pins.h | 1683 
 +
  arch/arm/include/asm/arch-mx6/sys_proto.h |   38 +
  12 files changed, 3666 insertions(+), 0 deletions(-)
 
 diff --git a/arch/arm/cpu/armv7/mx6/Makefile b/arch/arm/cpu/armv7/mx6/Makefile
 new file mode 100644
 index 000..b0da028
 --- /dev/null
 +++ b/arch/arm/cpu/armv7/mx6/Makefile
 @@ -0,0 +1,48 @@
 +#
 +# (C) Copyright 2000-2006
 +# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 +#
 +# (C) Copyright 2011 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 $(TOPDIR)/config.mk
 +
 +LIB  = $(obj)lib$(SOC).o
 +
 +COBJS= soc.o clock.o iomux-v3.o
 +SOBJS   = lowlevel_init.o
 +
 +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 +OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
 +
 +all: $(obj).depend $(LIB)
 +
 +$(LIB):  $(OBJS)
 + $(call cmd_link_o_target, $(OBJS))
 +
 +#
 +
 +# defines $(obj).depend target
 +include $(SRCTREE)/rules.mk
 +
 +sinclude $(obj).depend
 +
 +#
 diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
 new file mode 100644
 index 000..e0d9c6f
 --- /dev/null
 +++ b/arch/arm/cpu/armv7/mx6/clock.c
 @@ -0,0 +1,388 @@
 +/*
 + * Copyright (C) 2010-2011 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/io.h
 +#include asm/errno.h
 +#include asm/arch/imx-regs.h
 +#include asm/arch/ccm_regs.h
 +#include asm/arch/clock.h
 +
 +enum pll_clocks {
 + PLL_SYS,/* System PLL */
 + PLL_BUS,/* System Bus PLL*/
 + PLL_USBOTG, /* OTG USB PLL */
 + PLL_ENET,   /* ENET PLL */
 +};
 +
 +struct imx_ccm_reg *imx_ccm = (struct imx_ccm_reg *)CCM_BASE_ADDR;
 +
 +static u32 decode_pll(enum pll_clocks pll, u32 infreq)
 +{
 + u32 div;
 +
 + switch (pll) {
 + case PLL_SYS:
 + div = __raw_readl(imx_ccm-analog_pll_sys);
 + div = BM_ANADIG_PLL_SYS_DIV_SELECT;
 +
 + return infreq * (div  1);
 + case PLL_BUS:
 + div = __raw_readl(imx_ccm-analog_pll_528);
 + div = BM_ANADIG_PLL_528_DIV_SELECT;
 +
 + return infreq * (20 + (div  1));
 + case PLL_USBOTG:
 + div = __raw_readl(imx_ccm-analog_usb1_pll_480_ctrl);
 +div = BM_ANADIG_USB1_PLL_480_CTRL_DIV_SELECT;
 +
 + return infreq * (20 + (div  1));
 + case PLL_ENET:
 + div = __raw_readl(imx_ccm-analog_pll_enet);
 + div 

Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-14 Thread Jason Hui
On Mon, Nov 14, 2011 at 5:03 PM, Stefano Babic sba...@denx.de wrote:
 On 11/12/2011 11:36 AM, Jason Liu wrote:
 i.MX6Q is freescale quad core processors with ARM cortex_a9 complex.
 This patch is to add the initial support for this processor.

 Signed-off-by: Jason Liu jason@linaro.org
 ---
  arch/arm/cpu/armv7/mx6/Makefile           |   48 +
  arch/arm/cpu/armv7/mx6/clock.c            |  388 +++
  arch/arm/cpu/armv7/mx6/iomux-v3.c         |   76 ++
  arch/arm/cpu/armv7/mx6/lowlevel_init.S    |   60 +
  arch/arm/cpu/armv7/mx6/soc.c              |   57 +
  arch/arm/include/asm/arch-mx6/ccm_regs.h  |  894 +++
  arch/arm/include/asm/arch-mx6/clock.h     |   50 +
  arch/arm/include/asm/arch-mx6/gpio.h      |   35 +
  arch/arm/include/asm/arch-mx6/imx-regs.h  |  233 
  arch/arm/include/asm/arch-mx6/iomux-v3.h  |  104 ++
  arch/arm/include/asm/arch-mx6/mx6x_pins.h | 1683 
 +
  arch/arm/include/asm/arch-mx6/sys_proto.h |   38 +
  12 files changed, 3666 insertions(+), 0 deletions(-)

 diff --git a/arch/arm/cpu/armv7/mx6/Makefile 
 b/arch/arm/cpu/armv7/mx6/Makefile
 new file mode 100644
 index 000..b0da028
 --- /dev/null
 +++ b/arch/arm/cpu/armv7/mx6/Makefile
 @@ -0,0 +1,48 @@
 +#
 +# (C) Copyright 2000-2006
 +# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 +#
 +# (C) Copyright 2011 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 $(TOPDIR)/config.mk
 +
 +LIB  = $(obj)lib$(SOC).o
 +
 +COBJS        = soc.o clock.o iomux-v3.o
 +SOBJS   = lowlevel_init.o
 +
 +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 +OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
 +
 +all: $(obj).depend $(LIB)
 +
 +$(LIB):      $(OBJS)
 +     $(call cmd_link_o_target, $(OBJS))
 +
 +#
 +
 +# defines $(obj).depend target
 +include $(SRCTREE)/rules.mk
 +
 +sinclude $(obj).depend
 +
 +#
 diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
 new file mode 100644
 index 000..e0d9c6f
 --- /dev/null
 +++ b/arch/arm/cpu/armv7/mx6/clock.c
 @@ -0,0 +1,388 @@
 +/*
 + * Copyright (C) 2010-2011 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/io.h
 +#include asm/errno.h
 +#include asm/arch/imx-regs.h
 +#include asm/arch/ccm_regs.h
 +#include asm/arch/clock.h
 +
 +enum pll_clocks {
 +     PLL_SYS,        /* System PLL */
 +     PLL_BUS,        /* System Bus PLL*/
 +     PLL_USBOTG,     /* OTG USB PLL */
 +     PLL_ENET,       /* ENET PLL */
 +};
 +
 +struct imx_ccm_reg *imx_ccm = (struct imx_ccm_reg *)CCM_BASE_ADDR;
 +
 +static u32 decode_pll(enum pll_clocks pll, u32 infreq)
 +{
 +     u32 div;
 +
 +     switch (pll) {
 +     case PLL_SYS:
 +             div = __raw_readl(imx_ccm-analog_pll_sys);
 +             div = BM_ANADIG_PLL_SYS_DIV_SELECT;
 +
 +             return infreq * (div  1);
 +     case PLL_BUS:
 +             div = __raw_readl(imx_ccm-analog_pll_528);
 +             div = BM_ANADIG_PLL_528_DIV_SELECT;
 +
 +             return infreq * (20 + (div  1));
 +     case PLL_USBOTG:
 +             div = __raw_readl(imx_ccm-analog_usb1_pll_480_ctrl);
 +                div = BM_ANADIG_USB1_PLL_480_CTRL_DIV_SELECT;
 +
 +             return infreq * (20 + (div  1));
 +     case PLL_ENET:
 +      

Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-14 Thread Marek Vasut
 On Mon, Nov 14, 2011 at 7:11 AM, Marek Vasut marek.va...@gmail.com wrote:
  i.MX6Q is freescale quad core processors with ARM cortex_a9 complex.
  This patch is to add the initial support for this processor.
  
  Signed-off-by: Jason Liu jason@linaro.org
  ---
   arch/arm/cpu/armv7/mx6/Makefile   |   48 +
   arch/arm/cpu/armv7/mx6/clock.c|  388 +++
   arch/arm/cpu/armv7/mx6/iomux-v3.c |   76 ++
   arch/arm/cpu/armv7/mx6/lowlevel_init.S|   60 +
   arch/arm/cpu/armv7/mx6/soc.c  |   57 +
   arch/arm/include/asm/arch-mx6/ccm_regs.h  |  894 +++
   arch/arm/include/asm/arch-mx6/clock.h |   50 +
   arch/arm/include/asm/arch-mx6/gpio.h  |   35 +
   arch/arm/include/asm/arch-mx6/imx-regs.h  |  233 
   arch/arm/include/asm/arch-mx6/iomux-v3.h  |  104 ++
   arch/arm/include/asm/arch-mx6/mx6x_pins.h | 1683
  + arch/arm/include/asm/arch-mx6/sys_proto.h
  | 38 +
   12 files changed, 3666 insertions(+), 0 deletions(-)
  
  [...]
  
  diff --git a/arch/arm/cpu/armv7/mx6/lowlevel_init.S
  b/arch/arm/cpu/armv7/mx6/lowlevel_init.S new file mode 100644
  index 000..7a03f59
  --- /dev/null
  +++ b/arch/arm/cpu/armv7/mx6/lowlevel_init.S
  @@ -0,0 +1,60 @@
  +/*
  + * Copyright (C) 2010-2011 Freescale Semiconductor, Inc.
  + *
  + * 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 config.h
  +#include asm/arch/imx-regs.h
  +
  +/*
  + * AIPS setup - Only setup MPROTx registers.
  + * Set all MPROTx to be non-bufferable,
  + * trusted for R/W, not forced to user-mode.
  + * The PACR default values are good.
  + */
  +.macro init_aips
  + ldr r0, =AIPS1_ON_BASE_ADDR
  + ldr r1, =0x
  + str r1, [r0, #0x0]
  + str r1, [r0, #0x4]
  + ldr r1, =0x0
  + str r1, [r0, #0x40]
  + str r1, [r0, #0x44]
  + str r1, [r0, #0x48]
  + str r1, [r0, #0x4C]
  + str r1, [r0, #0x50]
  +
  + ldr r0, =AIPS2_ON_BASE_ADDR
  + ldr r1, =0x
  + str r1, [r0, #0x0]
  + str r1, [r0, #0x4]
  + ldr r1, =0x0
  + str r1, [r0, #0x40]
  + str r1, [r0, #0x44]
  + str r1, [r0, #0x48]
  + str r1, [r0, #0x4C]
  + str r1, [r0, #0x50]
  +.endm /* init_aips */
  
  Can't this be done in C code? Why the assembly ?
 
 I think this should be initialized as early as possible, so I put it here.

As early as arch_cpu_init is late (see arch/arm/lib/board.c)?
 
  +
  +.section .text.init, x
  +
  +.globl lowlevel_init
  +lowlevel_init:
  +
  + init_aips
  +
  + mov pc, lr
  
  [...]
  
  +#define MXC_CCM_CSCMR2_CAN_CLK_SEL_OFFSET(2)
  
  Drop parenthesis around stuff similar to this.
 
 Yes, thanks.
 
  +#endif /*__ARCH_ARM_MACH_MX6_CCM_REGS_H__ */
  diff --git a/arch/arm/include/asm/arch-mx6/clock.h
  b/arch/arm/include/asm/arch-mx6/clock.h new file mode 100644
  index 000..636458f
  --- /dev/null
  +++ b/arch/arm/include/asm/arch-mx6/clock.h
  @@ -0,0 +1,50 @@
  +/*
  + * (C) Copyright 2009
  + * Stefano Babic, DENX Software Engineering, sba...@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
  + */
  +
  +#ifndef __ASM_ARCH_CLOCK_H
  +#define __ASM_ARCH_CLOCK_H
  +
  +enum mxc_clock {
  + MXC_ARM_CLK = 0,
  + MXC_PER_CLK,
  + MXC_AHB_CLK,
  + MXC_IPG_CLK,
  + MXC_IPG_PERCLK,
  + MXC_UART_CLK,
  + MXC_CSPI_CLK,
  + MXC_AXI_CLK,
  + MXC_EMI_SLOW_CLK,
  + MXC_DDR_CLK,
  + MXC_ESDHC_CLK,
  + MXC_ESDHC2_CLK,
 

Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-14 Thread Stefano Babic
On 11/14/2011 10:42 AM, Jason Hui wrote:


 All get_usdhcX function are identical, except for two masks
 (MXC_CCM_CSCDR1_USDHCx_PODF_MASK and MXC_CCM_CSCMR1_USDHCx_CLK_SEL).
 Merge them in a get_usdhc_clk(usdhc_number)
 
 Yes, I also notice this when writing the code. At that time, I just
 think to make clear about the code.
 Now, I think your comments is also reasonable. I will change it later.

ok


 +#if defined(CONFIG_FEC_MXC)
 +void imx_get_mac_from_fuse(unsigned char *mac)
 +{
 + struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
 + struct fuse_bank *bank = iim-bank[4];
 + struct fuse_bank4_regs *fuse =
 + (struct fuse_bank4_regs *)bank-fuse_regs;
 +
 + u32 mac_lo = readl(fuse-mac_addr_low);
 + u32 mac_hi = readl(fuse-mac_addr_high);
 +
 + *(u32 *)mac = mac_lo;
 +
 + mac[4] = mac_hi  0xff;
 + mac[5] = (mac_hi  8)  0xff;
 +
 +}

 Even if the implementation is slightly different, this function (except
 for the bank number) does the same things for MX5 and MX6 - you can als
 put it into imx-common.
 
 Stefano, there is big difference for the memory layout. On i.mx5, the layout 
 is:
 
 32-bit 32-bit 32-bit 32-bit 32-bit 32-bit
 mac0 mac1 mac2 mac3 mac4 mac5
 
  but on i.mx6:
 
 32bit 32bit [low 16bit]
 mac[0-3]  mac[4-5]
 
 It's due to i.mx6q use OCOTP fuse-controller other than the fuse-box
 on the i.mx5.
 
 Thus, I think, I will keep the code as it is.

Ok - I was not aware about it.


 Checking this there something confusing in actual code. There is struct
 mxc_ccm_reg in crm_regs.h and struct clkctl in imx-regs.h. The two
 
 I did not searched the clkctl in the patch-set by using:
 grep -nR clkctl *
 
 structure are identical. I am asking myself why...it seems to me that
 someting went wrong.
 If there is no evident reason, we should even clean up this point.

 And it is better you use one of the already supplied names (mxc_ccm_reg
 or clkctl), without adding a new one.
 
 Yes, I'm using mxc_ccm_reg.

Ok - this structure is also used in most drivers - if I am not wrong
(and I will better check), the struct clkctl is used only to generate
the offsets in asm-offsets.h. If it is so, it could be drop in a future
clean up patch...

 Maybe do we find a way to add a common include directory ? This file is
 duplicated. We can use include/asm/arch/imx-common
 
 I don't find one good way to add a common include directory. If I try
 to find one,
 I will put this head file to imx-common.

The easy way is to add include/asm/arch-imx-common, and then the header
are explicitely included as #include asm/arch-imx-common/...
I have seen only another example in U-Boot for armv7:

arch/arm/cpu/armv7/highbank/timer.c:#include asm/arch-armv7/systimer.h

I am opened to other solutions, too, but I think that introducing a
common repository for IMX include files (as Linux with plat_imx does) is
the way to do.

Best regards,
Stefano Babic

-- 
=
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: off...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/6] i.mx: Add the initial support for freescale i.MX6Q processor

2011-11-13 Thread Marek Vasut
 i.MX6Q is freescale quad core processors with ARM cortex_a9 complex.
 This patch is to add the initial support for this processor.
 
 Signed-off-by: Jason Liu jason@linaro.org
 ---
  arch/arm/cpu/armv7/mx6/Makefile   |   48 +
  arch/arm/cpu/armv7/mx6/clock.c|  388 +++
  arch/arm/cpu/armv7/mx6/iomux-v3.c |   76 ++
  arch/arm/cpu/armv7/mx6/lowlevel_init.S|   60 +
  arch/arm/cpu/armv7/mx6/soc.c  |   57 +
  arch/arm/include/asm/arch-mx6/ccm_regs.h  |  894 +++
  arch/arm/include/asm/arch-mx6/clock.h |   50 +
  arch/arm/include/asm/arch-mx6/gpio.h  |   35 +
  arch/arm/include/asm/arch-mx6/imx-regs.h  |  233 
  arch/arm/include/asm/arch-mx6/iomux-v3.h  |  104 ++
  arch/arm/include/asm/arch-mx6/mx6x_pins.h | 1683
 + arch/arm/include/asm/arch-mx6/sys_proto.h | 
  38 +
  12 files changed, 3666 insertions(+), 0 deletions(-)
 

[...]

 diff --git a/arch/arm/cpu/armv7/mx6/lowlevel_init.S
 b/arch/arm/cpu/armv7/mx6/lowlevel_init.S new file mode 100644
 index 000..7a03f59
 --- /dev/null
 +++ b/arch/arm/cpu/armv7/mx6/lowlevel_init.S
 @@ -0,0 +1,60 @@
 +/*
 + * Copyright (C) 2010-2011 Freescale Semiconductor, Inc.
 + *
 + * 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 config.h
 +#include asm/arch/imx-regs.h
 +
 +/*
 + * AIPS setup - Only setup MPROTx registers.
 + * Set all MPROTx to be non-bufferable,
 + * trusted for R/W, not forced to user-mode.
 + * The PACR default values are good.
 + */
 +.macro init_aips
 + ldr r0, =AIPS1_ON_BASE_ADDR
 + ldr r1, =0x
 + str r1, [r0, #0x0]
 + str r1, [r0, #0x4]
 + ldr r1, =0x0
 + str r1, [r0, #0x40]
 + str r1, [r0, #0x44]
 + str r1, [r0, #0x48]
 + str r1, [r0, #0x4C]
 + str r1, [r0, #0x50]
 +
 + ldr r0, =AIPS2_ON_BASE_ADDR
 + ldr r1, =0x
 + str r1, [r0, #0x0]
 + str r1, [r0, #0x4]
 + ldr r1, =0x0
 + str r1, [r0, #0x40]
 + str r1, [r0, #0x44]
 + str r1, [r0, #0x48]
 + str r1, [r0, #0x4C]
 + str r1, [r0, #0x50]
 +.endm /* init_aips */

Can't this be done in C code? Why the assembly ?

 +
 +.section .text.init, x
 +
 +.globl lowlevel_init
 +lowlevel_init:
 +
 + init_aips
 +
 + mov pc, lr
[...]

 +#define MXC_CCM_CSCMR2_CAN_CLK_SEL_OFFSET(2)

Drop parenthesis around stuff similar to this.

 +#endif /*__ARCH_ARM_MACH_MX6_CCM_REGS_H__ */
 diff --git a/arch/arm/include/asm/arch-mx6/clock.h
 b/arch/arm/include/asm/arch-mx6/clock.h new file mode 100644
 index 000..636458f
 --- /dev/null
 +++ b/arch/arm/include/asm/arch-mx6/clock.h
 @@ -0,0 +1,50 @@
 +/*
 + * (C) Copyright 2009
 + * Stefano Babic, DENX Software Engineering, sba...@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
 + */
 +
 +#ifndef __ASM_ARCH_CLOCK_H
 +#define __ASM_ARCH_CLOCK_H
 +
 +enum mxc_clock {
 + MXC_ARM_CLK = 0,
 + MXC_PER_CLK,
 + MXC_AHB_CLK,
 + MXC_IPG_CLK,
 + MXC_IPG_PERCLK,
 + MXC_UART_CLK,
 + MXC_CSPI_CLK,
 + MXC_AXI_CLK,
 + MXC_EMI_SLOW_CLK,
 + MXC_DDR_CLK,
 + MXC_ESDHC_CLK,
 + MXC_ESDHC2_CLK,
 + MXC_ESDHC3_CLK,
 + MXC_ESDHC4_CLK,
 + MXC_SATA_CLK,
 + MXC_NFC_CLK,
 +};
 +
 +u32 imx_get_uartclk(void);
 +u32 imx_get_fecclk(void);
 +unsigned int mxc_get_clock(enum mxc_clock clk);
 +
 +#endif /* __ASM_ARCH_CLOCK_H */
 diff --git a/arch/arm/include/asm/arch-mx6/gpio.h
 b/arch/arm/include/asm/arch-mx6/gpio.h new file mode 100644
 index 000..1dc34e9
 ---