[U-Boot] [PATCH] ARM: stm32f7: fix prescaler calculation of timer

2017-10-02 Thread Bo Shen
As the timer 2 is on APB1 bus, the maximum of clock frequency of APB1 timer
clock is half of SYSCLK. Then to calculate the timer prescaler for timer 2
which need to be divided by 2.

Signed-off-by: Bo Shen 
---
 arch/arm/mach-stm32/stm32f7/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-stm32/stm32f7/timer.c 
b/arch/arm/mach-stm32/stm32f7/timer.c
index c15f8bb..b04c101 100644
--- a/arch/arm/mach-stm32/stm32f7/timer.c
+++ b/arch/arm/mach-stm32/stm32f7/timer.c
@@ -26,7 +26,7 @@ int timer_init(void)
/* Stop the timer */
writel(readl(&gpt1_regs_ptr->cr1) & ~GPT_CR1_CEN, &gpt1_regs_ptr->cr1);
 
-   writel((CONFIG_SYS_CLK_FREQ/CONFIG_SYS_HZ_CLOCK) - 1,
+   writel((CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ_CLOCK) - 1,
&gpt1_regs_ptr->psc);
 
/* Configure timer for auto-reload */
-- 
2.7.4

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


Re: [U-Boot] [PATCH v1 5/6] serial: stm32x7: add STM32F4 support

2017-09-29 Thread Bo Shen

Hi Patrice,

On 09/29/2017 04:52 AM, Patrice CHOTARD wrote:

diff --git a/drivers/serial/serial_stm32x7.c
b/drivers/serial/serial_stm32x7.c
index 19697e3..44e8b42 100644
--- a/drivers/serial/serial_stm32x7.c
+++ b/drivers/serial/serial_stm32x7.c
@@ -127,6 +127,7 @@ static int stm32_serial_probe(struct udevice *dev)
   #if CONFIG_IS_ENABLED(OF_CONTROL)
   static const struct udevice_id stm32_serial_id[] = {
+    { .compatible = "st,stm32-uart", .data = (ulong)&stm32f4_info},

s/st,stm32-uart/st,stm32f4-uart/ (?)

We use the same DT bindings than kernel one and we want to keep aligned.


I'd suggest to send a patch to kernel to rename it.


Historically stm32-uart is dedicated for F4, which was introduced first.
And then with introduction of F7 and H7, new compatible string
(stm32f7-uart and stm32h7-uart) was added.


If we have patch in kernel to rename it, then it will be more clear.

Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 5/6] serial: stm32x7: add STM32F4 support

2017-09-28 Thread Bo Shen

Hi Patrice,

On 09/27/2017 06:44 AM, patrice.chot...@st.com wrote:

From: Patrice Chotard 

stm32f4 doesn't support FIFO and OVERRUN feature.
The enable bit is not at the same location in CR1
register than for STM32F7 and STM32H7.

Signed-off-by: Patrice Chotard 
---
  drivers/serial/Kconfig  | 4 ++--
  drivers/serial/serial_stm32x7.c | 1 +
  drivers/serial/serial_stm32x7.h | 7 +++
  3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 9bf2e26..7c54a49 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -531,9 +531,9 @@ config STI_ASC_SERIAL
  
  config STM32X7_SERIAL

bool "STMicroelectronics STM32 SoCs on-chip UART"
-   depends on DM_SERIAL && (STM32F7 || STM32H7)
+   depends on DM_SERIAL && (STM32F4 || STM32F7 || STM32H7)
help
- If you have a machine based on a STM32 F7 or H7 SoC you can
+ If you have a machine based on a STM32 F4, F7 or H7 SoC you can
  enable its onboard serial ports, say Y to this option.
  If unsure, say N.
  
diff --git a/drivers/serial/serial_stm32x7.c b/drivers/serial/serial_stm32x7.c

index 19697e3..44e8b42 100644
--- a/drivers/serial/serial_stm32x7.c
+++ b/drivers/serial/serial_stm32x7.c
@@ -127,6 +127,7 @@ static int stm32_serial_probe(struct udevice *dev)
  
  #if CONFIG_IS_ENABLED(OF_CONTROL)

  static const struct udevice_id stm32_serial_id[] = {
+   { .compatible = "st,stm32-uart", .data = (ulong)&stm32f4_info},


s/st,stm32-uart/st,stm32f4-uart/ (?)


{ .compatible = "st,stm32f7-uart", .data = (ulong)&stm32f7_info},
{ .compatible = "st,stm32h7-uart", .data = (ulong)&stm32h7_info},
{}
diff --git a/drivers/serial/serial_stm32x7.h b/drivers/serial/serial_stm32x7.h
index ed8a3ee..b914edf 100644
--- a/drivers/serial/serial_stm32x7.h
+++ b/drivers/serial/serial_stm32x7.h
@@ -27,6 +27,13 @@ struct stm32_uart_info {
bool has_fifo;
  };
  
+struct stm32_uart_info stm32f4_info = {

+   .stm32f4 = true,
+   .uart_enable_bit = 13,
+   .has_overrun_disable = false,
+   .has_fifo = false,
+};
+
  struct stm32_uart_info stm32f7_info = {
    .uart_enable_bit = 0,
.stm32f4 = false,



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 3/6] serial: stm32x7: prepare the ground to STM32F4 support

2017-09-28 Thread Bo Shen

Hi Patrice,
  For this patch, overall I think you can use more generic method like 
define the parameter called ip_version in stm32_uart_info structure, and 
according to this information to covert base to different register map 
as following, then we can get rid of "stm32f4" in stm32_uart_info 
structure, and easy to extend if you have more versions.


--->8---
  struct stm32_usart_v1 { }; (version 1 register map)
  struct stm32_usart_v2 { }; (version 2 register map)

  switch (ip_version) {
  case v1:
struct stm32_usart_v1 *ptr = (struct stm32_usart_v1 *)base;
break;
  case v2:
struct stm32_usart_v1 *ptr = (struct stm32_usart_v1 *)base;
break;
  }
---8<---

Best Regards,
Bo Shen

On 09/27/2017 06:44 AM, patrice.chot...@st.com wrote:

From: Patrice Chotard 

STM32F4 serial IP is similar to F7 and H7, but registers
are not located at the same offset and some feature are
only supported by F7 and H7 version.

Registers offset must be added for each version and also
some flags indicated the supported feature.

Update registers name to match with datasheet (sr to isr,
rx_dr to rdr and tx_dr to tdr) and remove unused regs
(cr2, gtpr, rtor, and rqr).

Signed-off-by: Patrice Chotard 
---
  drivers/serial/serial_stm32x7.c | 72 -
  drivers/serial/serial_stm32x7.h | 38 ++
  2 files changed, 66 insertions(+), 44 deletions(-)

diff --git a/drivers/serial/serial_stm32x7.c b/drivers/serial/serial_stm32x7.c
index bafcc36..81a2308 100644
--- a/drivers/serial/serial_stm32x7.c
+++ b/drivers/serial/serial_stm32x7.c
@@ -17,67 +17,79 @@ DECLARE_GLOBAL_DATA_PTR;
  
  static int stm32_serial_setbrg(struct udevice *dev, int baudrate)

  {
-   struct stm32x7_serial_platdata *plat = dev->platdata;
-   struct stm32_usart *const usart = plat->base;
+   struct stm32x7_serial_platdata *plat = dev_get_platdata(dev);
+   bool stm32f4 = plat->uart_info->stm32f4;
+   fdt_addr_t base = plat->base;
u32 int_div, mantissa, fraction, oversampling;
  
  	int_div = DIV_ROUND_CLOSEST(plat->clock_rate, baudrate);
  
  	if (int_div < 16) {

oversampling = 8;
-   setbits_le32(&usart->cr1, USART_CR1_OVER8);
+   setbits_le32(base + CR1_OFFSET(stm32f4), USART_CR1_OVER8);
} else {
oversampling = 16;
-   clrbits_le32(&usart->cr1, USART_CR1_OVER8);
+   clrbits_le32(base + CR1_OFFSET(stm32f4), USART_CR1_OVER8);
}
  
  	mantissa = (int_div / oversampling) << USART_BRR_M_SHIFT;

fraction = int_div % oversampling;
  
-	writel(mantissa | fraction, &usart->brr);

+   writel(mantissa | fraction, base + BRR_OFFSET(stm32f4));
  
  	return 0;

  }
  
  static int stm32_serial_getc(struct udevice *dev)

  {
-   struct stm32x7_serial_platdata *plat = dev->platdata;
-   struct stm32_usart *const usart = plat->base;
+   struct stm32x7_serial_platdata *plat = dev_get_platdata(dev);
+   bool stm32f4 = plat->uart_info->stm32f4;
+   fdt_addr_t base = plat->base;
  
-	if ((readl(&usart->sr) & USART_SR_FLAG_RXNE) == 0)

+   if ((readl(base + ISR_OFFSET(stm32f4)) & USART_SR_FLAG_RXNE) == 0)
return -EAGAIN;
  
-	return readl(&usart->rd_dr);

+   return readl(base + RDR_OFFSET(stm32f4));
  }
  
  static int stm32_serial_putc(struct udevice *dev, const char c)

  {
-   struct stm32x7_serial_platdata *plat = dev->platdata;
-   struct stm32_usart *const usart = plat->base;
+   struct stm32x7_serial_platdata *plat = dev_get_platdata(dev);
+   bool stm32f4 = plat->uart_info->stm32f4;
+   fdt_addr_t base = plat->base;
  
-	if ((readl(&usart->sr) & USART_SR_FLAG_TXE) == 0)

+   if ((readl(base + ISR_OFFSET(stm32f4)) & USART_SR_FLAG_TXE) == 0)
return -EAGAIN;
  
-	writel(c, &usart->tx_dr);

+   writel(c, base + TDR_OFFSET(stm32f4));
  
  	return 0;

  }
  
  static int stm32_serial_pending(struct udevice *dev, bool input)

  {
-   struct stm32x7_serial_platdata *plat = dev->platdata;
-   struct stm32_usart *const usart = plat->base;
+   struct stm32x7_serial_platdata *plat = dev_get_platdata(dev);
+   bool stm32f4 = plat->uart_info->stm32f4;
+   fdt_addr_t base = plat->base;
  
  	if (input)

-   return readl(&usart->sr) & USART_SR_FLAG_RXNE ? 1 : 0;
+   return readl(base + ISR_OFFSET(stm32f4)) &
+   USART_SR_FLAG_RXNE ? 1 : 0;
else
-   return readl(&usart->sr) & USART_SR_FLAG_TXE ? 0 : 1;
+   return readl(base + ISR_OFFSET(stm32f4)) &
+   USART_SR_FLAG_TXE ? 0 : 1;
  }
  
  static int stm32_serial_probe(struct udevice *dev)

  {
-   struct stm32x7_serial_platdata *plat = dev->platda

Re: [U-Boot] [PATCH v1 1/6] serial: stm32x7: cleanup code

2017-09-28 Thread Bo Shen

Hi Patrice,

On 09/27/2017 06:44 AM, patrice.chot...@st.com wrote:

From: Patrice Chotard 

Use BIT() macro and GENMASK() macro

Signed-off-by: Patrice Chotard 
Reviewed-by: Vikas Manocha 
---
  drivers/serial/serial_stm32x7.h | 18 +-
  1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/serial/serial_stm32x7.h b/drivers/serial/serial_stm32x7.h
index 9fe37af..6d36b74 100644
--- a/drivers/serial/serial_stm32x7.h
+++ b/drivers/serial/serial_stm32x7.h
@@ -28,18 +28,18 @@ struct stm32x7_serial_platdata {
unsigned long int clock_rate;
  };
  
-#define USART_CR1_OVER8			(1 << 15)

-#define USART_CR1_TE   (1 << 3)
-#define USART_CR1_RE   (1 << 2)
-#define USART_CR1_UE   (1 << 0)
+#define USART_CR1_OVER8BIT(15)
+#define USART_CR1_TE   BIT(3)
+#define USART_CR1_RE   BIT(2)
+#define USART_CR1_UE   BIT(0)
  
-#define USART_CR3_OVRDIS		(1 << 12)

+#define USART_CR3_OVRDIS   BIT(12)
  
-#define USART_SR_FLAG_RXNE		(1 << 5)

-#define USART_SR_FLAG_TXE  (1 << 7)
+#define USART_SR_FLAG_RXNE BIT(5)
+#define USART_SR_FLAG_TXE  BIT(7)
  
-#define USART_BRR_F_MASK		0xFF

+#define USART_BRR_F_MASK   GENMASK(7, 0)
  #define USART_BRR_M_SHIFT 4
-#define USART_BRR_M_MASK   0xFFF0
+#define USART_BRR_M_MASK   GENMASK(15, 4)


In stm32f7, according to the datasheet, there is no fraction and 
mantissa. Would you please confirm that?


At the same time, it makes me thinking the BRR is calculated differently 
between stm32f7 and stm32f4, would you please check it also in the 
driver code?


  
  #endif




Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/7] stm32: stm32f7: add spl build support

2017-08-19 Thread Bo Shen

Hi Vikas,


On 08/18/2017 02:28 PM, Vikas MANOCHA wrote:

I'd suggest to add a follow-up patch to move all the
selected SPL related configuration from "arch/arm/mach-stm32/Kconfig" under 
STM32F7 to default configuration file (stm32f746-
disco_defconfig). Then if the people want just boot up u-boot itself, what they need to 
do is just run "make menuconfig" and then de-
select "Activate Falcon Mode"
(SPL_OS_BOOT). Then everything will be fine.

Yes, Agree. How about using "imply" instead of "select" for SPL_OS_BOOT to make 
it configurable.


I don't realize this option before. For sure, it's a great option. I'd 
like it. :)


Thanks.

Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/7] stm32: stm32f7: add spl build support

2017-08-17 Thread Bo Shen


Hi Vikas,
  Try to remove this magic (press 'c' on the keyboard when at the boot 
time), I'd suggest to add a follow-up patch to move all the selected SPL 
related configuration from "arch/arm/mach-stm32/Kconfig" under STM32F7 
to default configuration file (stm32f746-disco_defconfig). Then if the 
people want just boot up u-boot itself, what they need to do is just run 
"make menuconfig" and then de-select "Activate Falcon Mode" 
(SPL_OS_BOOT). Then everything will be fine.


  Thanks.

Best Regards,
Bo Shen

On 08/10/2017 11:36 AM, Robert Nelson wrote:

On Thu, Aug 10, 2017 at 1:10 PM, Vikas Manocha  wrote:

One other point,

On 08/10/2017 11:07 AM, Vikas Manocha wrote:

Hi Robert,

On 08/10/2017 11:03 AM, Robert Nelson wrote:

Hi Vikas,

On Sun, May 28, 2017 at 2:55 PM, Vikas Manocha  wrote:

This commit supports booting from stm32 internal nor flash. spl U-Boot
initializes the sdram memory, copies next image (e.g. standard U-Boot)
to sdram & then jumps to entry point.

Here are the flash memory addresses for U-Boot-spl & standard U-Boot:
 - spl U-Boot: 0x0800_
 - standard U-Boot   : 0x0800_8000

Is there another patchset missing on mainline for booting via spl?

No, you just need to flash spl & next image at above mentioned addresses. By 
default spl expects kernel image.

To boot u-boot, press keyboard character 'c'.
you might need to keep on pressing 'c' it for some time as the keyboard entry 
acceptance & detection window is very small.

Cheers,
Vikas


on mainline with the stm32f746-disco board:

U-Boot SPL 2017.09-rc1-00177-gd529124fdc (Aug 10 2017 - 12:33:35)
Trying to boot from XIP
Hard fault
pc : 08008008lr : 08000adbxPSR : 2100
r12 : 2004f338   r3 : 0005r2 : 081c
r1 : ff9ar0 : 
Resetting CPU ...

resetting ...

I'm using openocd to program

openocd -f board/stm32f7discovery.cfg \
   -c "init" \
   -c "reset init" \
   -c "flash probe 0" \
   -c "flash write_image erase ./spl/u-boot-spl.bin 0x0800" \
   -c "flash write_image erase ./u-boot.img 0x08008000" \

it should be u-boot-dtb.bin.

Bingo!

Thanks Vikas!!

U-Boot SPL 2017.09-rc1-00177-gd529124fdc (Aug 10 2017 - 12:33:35)
Trying to boot from XIP


U-Boot 2017.09-rc1-00177-gd529124fdc (Aug 10 2017 - 12:33:35 -0500)

Model: STMicroelectronics STM32F746-DISCO board
DRAM:  8 MiB
Flash: 1 MiB
Using default environment

In:serial@40011000
Out:   serial@40011000
Err:   serial@40011000
usr button is at LOW LEVEL
Net:
Warning: ethernet@40028000 (eth0) using random MAC address - 02:4a:de:c3:c8:80
eth0: ethernet@40028000
Hit SPACE in 3 seconds to stop autoboot.
U-Boot >

Regards,



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


Re: [U-Boot] [PATCH v2] arm: at91: clock: Add the generated clock support

2015-10-28 Thread Bo Shen

Hi Wenyou,

On 10/28/2015 13:25 PM, Yang, Wenyou wrote:

@@ -173,3 +174,67 @@ void at91_periph_clk_disable(int id)
> >
> >   writel(regval, &pmc->pcr);
> >   }
> >+
> >+void at91_enable_periph_generated_clk(u32 id) {
> >+  struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> >+  u32 regval, status;
> >+  u32 timeout = 1000;
> >+
> >+  if (id > AT91_PMC_PCR_PID_MASK)
> >+  return;
> >+
> >+  writel(id, &pmc->pcr);
> >+  regval = readl(&pmc->pcr);
> >+  regval &= ~AT91_PMC_PCR_GCKCSS;
> >+  regval &= ~AT91_PMC_PCR_GCKDIV;
> >+  regval |= AT91_PMC_PCR_GCKCSS_PLLA_CLK |
> >+AT91_PMC_PCR_CMD_WRITE |
> >+AT91_PMC_PCR_GCKDIV_(1) |
> >+AT91_PMC_PCR_GCKEN;

>
>You hard code the GCKCSS and GCKDIV. Would it be OK for all peripheral which
>need this kind of clock? Can you make it as a parameter?

As you know,  our use-case is not complex, it is only used for one or two 
peripherals for now,
So to make it simple, use hard-code.

Maybe we will improve it in the future, but now it is enough.


I think if this can be dealt now, that will be better.


Anyway, thank you for your advice.


You are welcome.

Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4] arm: atmel: Add SAMA5D2 Xplained board

2015-10-28 Thread Bo Shen

Hi Wenyou,

On 10/28/2015 13:59 PM, Yang, Wenyou wrote:

+char *get_cpu_name()
> >+{
> >+  unsigned int extension_id = get_extension_chip_id();
> >+
> >+  if (cpu_is_sama5d2()) {
> >+  switch (extension_id) {
> >+  case ARCH_EXID_SAMA5D21CU:
> >+  return "SAMA5D21";
> >+  case ARCH_EXID_SAMA5D22CU:
> >+  return "SAMA5D22-CU";
> >+  case ARCH_EXID_SAMA5D22CN:
> >+  return "SAMA5D22-CN";
> >+  case ARCH_EXID_SAMA5D23CU:
> >+  return "SAMA5D23-CU";
> >+  case ARCH_EXID_SAMA5D24CX:
> >+  return "SAMA5D24-CX";
> >+  case ARCH_EXID_SAMA5D24CU:
> >+  return "SAMA5D24-CU";
> >+  case ARCH_EXID_SAMA5D26CU:
> >+  return "SAMA5D26-CU";
> >+  case ARCH_EXID_SAMA5D27CU:
> >+  return "SAMA5D27-CU";
> >+  case ARCH_EXID_SAMA5D27CN:
> >+  return "SAMA5D27-CN";
> >+  case ARCH_EXID_SAMA5D28CU:
> >+  return "SAMA5D28-CU";
> >+  case ARCH_EXID_SAMA5D28CN:
> >+  return "SAMA5D28-CN";
> >+  default:
> >+  ;
> >+  }
> >+  }
> >+
> >+  return "Unknown CPU type";
> >+}

>
>You don't explain why it needs to keep the default option. I think it can be 
removed.

Switch-cases should almost always have a default case.
The reason to use a default is to 'catch' an unexpected value. It is necessary 
for this function.


Yes, as usual, we use default to catch the exceptions. However, here we 
don't need it as the final return is used to catch these exceptions.


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4] mmc: atmel: Add atmel sdhci support

2015-10-28 Thread Bo Shen

Hi Wenyou,

On 10/28/2015 13:52 PM, Wenyou Yang wrote:

The SDHCI is introduced by sama5d2, named as Secure Digital Multimedia
Card Controller(SDMMC). It supports the embedded MultiMedia Card (e.MMC)
Specification V4.41, the SD Memory Card Specification V3.0, and the SDIO
V3.0 specification. It is compliant with the SD Host Controller Standard
V3.0 specification.

Signed-off-by: Wenyou Yang 


Reviewed-by: Bo Shen 

Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] arm: at91: clock: Add the generated clock support

2015-10-27 Thread Bo Shen

Hi Wenyou,

On 10/26/2015 11:31 AM, Wenyou Yang wrote:

Some peripherals may need a second clock source that may be different
from the system clock. This second clock is the generated clock (GCK)
and is managed by the PMC via PMC_PCR.

For simplicity, the clock source of the GCK is fixed to PLLA_CLK.

Signed-off-by: Wenyou Yang 
---
Hi Andreas, Bo Shen,

Thank you for your so many advices.
Bo Shen, sorry for forgetting version 2 to send for your comments.


It's OK, don't worry.

At that time the datasheet is not available, now it is available now. 
So, add one more comment.



Please help review, thank you in advance.

Best Regards,
Wenyou Yang

Changes in v2:
1./ add timeout to wait for GCK ready.
2./ add warning for timeout to wait for GCK ready.
3./ add printout when the improper GCK clock source is selected.
4./ rework AT91_PMC_PCR_GCKDIV_(x) macro to make sure x is right.

  arch/arm/mach-at91/armv7/clock.c   |   65 
  arch/arm/mach-at91/include/mach/at91_pmc.h |   13 ++
  arch/arm/mach-at91/include/mach/clk.h  |3 ++
  3 files changed, 81 insertions(+)

diff --git a/arch/arm/mach-at91/armv7/clock.c b/arch/arm/mach-at91/armv7/clock.c
index 0bf453e..de95d6b 100644
--- a/arch/arm/mach-at91/armv7/clock.c
+++ b/arch/arm/mach-at91/armv7/clock.c
@@ -5,6 +5,7 @@
   * Copyright (C) 2005 Ivan Kokshaysky
   * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD 
   * Copyright (C) 2013 Bo Shen 
+ * Copyright (C) 2015 Wenyou Yang 
   *
   * SPDX-License-Identifier:   GPL-2.0+
   */
@@ -173,3 +174,67 @@ void at91_periph_clk_disable(int id)

writel(regval, &pmc->pcr);
  }
+
+void at91_enable_periph_generated_clk(u32 id)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   u32 regval, status;
+   u32 timeout = 1000;
+
+   if (id > AT91_PMC_PCR_PID_MASK)
+   return;
+
+   writel(id, &pmc->pcr);
+   regval = readl(&pmc->pcr);
+   regval &= ~AT91_PMC_PCR_GCKCSS;
+   regval &= ~AT91_PMC_PCR_GCKDIV;
+   regval |= AT91_PMC_PCR_GCKCSS_PLLA_CLK |
+ AT91_PMC_PCR_CMD_WRITE |
+ AT91_PMC_PCR_GCKDIV_(1) |
+ AT91_PMC_PCR_GCKEN;


You hard code the GCKCSS and GCKDIV. Would it be OK for all peripheral 
which need this kind of clock? Can you make it as a parameter?



+
+   writel(regval, &pmc->pcr);
+
+   do {
+   udelay(1);
+   status = readl(&pmc->sr);
+   } while ((!!(--timeout)) && (!(status & AT91_PMC_GCKRDY)));
+
+   if (!timeout)
+   printf("Timeout waiting for GCK ready!\n");
+}
+
+u32 at91_get_periph_generated_clk(u32 id)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   u32 regval, clk_source, div;
+   u32 freq;
+
+   if (id > AT91_PMC_PCR_PID_MASK)
+   return 0;
+
+   writel(id, &pmc->pcr);
+   regval = readl(&pmc->pcr);
+
+   clk_source = regval & AT91_PMC_PCR_GCKCSS;
+   switch (clk_source) {
+   case AT91_PMC_PCR_GCKCSS_SLOW_CLK:
+   freq = CONFIG_SYS_AT91_SLOW_CLOCK;
+   break;
+   case AT91_PMC_PCR_GCKCSS_MAIN_CLK:
+   freq = gd->arch.main_clk_rate_hz;
+   break;
+   case AT91_PMC_PCR_GCKCSS_PLLA_CLK:
+   freq = gd->arch.plla_rate_hz;
+   break;
+   default:
+   printf("Improper GCK clock source selection!\n");
+   freq = 0;
+   break;
+   }
+
+   div = ((regval & AT91_PMC_PCR_GCKDIV) >> AT91_PMC_PCR_GCKDIV_OFFSET);
+   div += 1;
+
+   return freq / div;
+}
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index 8a3fb94..5a51be6 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -153,8 +153,20 @@ typedef struct at91_pmc {
  #define AT91_PMC_IXR_MOSCSELS 0x0001

  #define AT91_PMC_PCR_PID_MASK (0x3f)
+#define AT91_PMC_PCR_GCKCSS(0x7 << 8)
+#defineAT91_PMC_PCR_GCKCSS_SLOW_CLK(0x0 << 8)
+#defineAT91_PMC_PCR_GCKCSS_MAIN_CLK(0x1 << 8)
+#defineAT91_PMC_PCR_GCKCSS_PLLA_CLK(0x2 << 8)
+#defineAT91_PMC_PCR_GCKCSS_UPLL_CLK(0x3 << 8)
+#defineAT91_PMC_PCR_GCKCSS_MCK_CLK (0x4 << 8)
+#defineAT91_PMC_PCR_GCKCSS_AUDIO_CLK   (0x5 << 8)
  #define AT91_PMC_PCR_CMD_WRITE(0x1 << 12)
+#define AT91_PMC_PCR_DIV   (0x3 << 16)
+#define AT91_PMC_PCR_GCKDIV(0xff << 20)
+#defineAT91_PMC_PCR_GCKDIV_(x) ((x & 0xff) << 20)
+#defineAT91_PMC_PCR_GCKDIV_OFFSET  20
  #define AT91_P

Re: [U-Boot] [PATCH v4] arm: atmel: Add SAMA5D2 Xplained board

2015-10-27 Thread Bo Shen
ot set
+# CONFIG_CMD_LOADS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_SF=y
+# CONFIG_CMD_FPGA is not set
+CONFIG_SPI_FLASH=y
diff --git a/include/configs/sama5d2_xplained.h 
b/include/configs/sama5d2_xplained.h
new file mode 100644
index 000..ae5ba3d
--- /dev/null
+++ b/include/configs/sama5d2_xplained.h
@@ -0,0 +1,122 @@
+/*
+ * Configuration file for the SAMA5D2 Xplained Board.
+ *
+ * Copyright (C) 2015 Atmel Corporation
+ *   Wenyou Yang 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/* No NOR flash, this definition should put before common header */
+#define CONFIG_SYS_NO_FLASH
+
+#include "at91-sama5_common.h"
+
+/* serial console */
+#define CONFIG_ATMEL_USART
+#define CONFIG_USART_BASE  ATMEL_BASE_UART1
+#define CONFIG_USART_IDATMEL_ID_UART1
+
+/* SDRAM */
+#define CONFIG_NR_DRAM_BANKS   1
+#define CONFIG_SYS_SDRAM_BASE   ATMEL_BASE_DDRCS
+#define CONFIG_SYS_SDRAM_SIZE  0x2000
+
+#define CONFIG_SYS_INIT_SP_ADDR \
+   (CONFIG_SYS_SDRAM_BASE + 4 * 1024 - GENERATED_GBL_DATA_SIZE)
+
+#define CONFIG_SYS_LOAD_ADDR   0x2200 /* load address */
+
+#undef CONFIG_AT91_GPIO
+#define CONFIG_ATMEL_PIO4
+
+/* SerialFlash */
+#ifdef CONFIG_CMD_SF
+#define CONFIG_ATMEL_SPI
+#define CONFIG_ATMEL_SPI0
+#define CONFIG_SPI_FLASH_ATMEL
+#define CONFIG_SF_DEFAULT_BUS  0
+#define CONFIG_SF_DEFAULT_CS   0
+#define CONFIG_SF_DEFAULT_SPEED3000
+#endif
+
+/* NAND flash */
+#undef CONFIG_CMD_NAND
+
+/* MMC */
+#define CONFIG_CMD_MMC
+
+#ifdef CONFIG_CMD_MMC
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_SDHCI
+#define CONFIG_ATMEL_SDHCI
+#define CONFIG_ATMEL_SDHCI0
+#define CONFIG_ATMEL_SDHCI1
+#define CONFIG_SUPPORT_EMMC_BOOT
+#endif
+
+/* USB */
+#define CONFIG_CMD_USB
+
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_ATMEL
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
+#define CONFIG_USB_STORAGE
+#endif
+
+/* USB device */
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_ATMEL_USBA
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_RNDIS
+#define CONFIG_USBNET_MANUFACTURER  "Atmel SAMA5D2 XPlained"
+
+#if defined(CONFIG_CMD_USB) || defined(CONFIG_CMD_MMC)
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+#endif
+
+/* Ethernet Hardware */
+#define CONFIG_MACB
+#define CONFIG_RMII
+#define CONFIG_NET_RETRY_COUNT 20
+#define CONFIG_MACB_SEARCH_PHY
+
+/* LCD */
+/* #define CONFIG_LCD */
+
+#ifdef CONFIG_LCD
+#define LCD_BPPLCD_COLOR16
+#define LCD_OUTPUT_BPP  24
+#define CONFIG_LCD_LOGO
+#define CONFIG_LCD_INFO
+#define CONFIG_LCD_INFO_BELOW_LOGO
+#define CONFIG_SYS_WHITE_ON_BLACK
+#define CONFIG_ATMEL_HLCD
+#define CONFIG_ATMEL_LCD_RGB565
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#endif
+
+#ifdef CONFIG_SYS_USE_MMC
+
+/* bootstrap + u-boot + env in sd card */
+#undef FAT_ENV_DEVICE_AND_PART
+#undef CONFIG_BOOTCOMMAND
+
+#define FAT_ENV_DEVICE_AND_PART"1"
+#define CONFIG_BOOTCOMMAND "fatload mmc 1:1 0x2100 
at91-sama5d2_xplained.dtb; " \
+   "fatload mmc 1:1 0x2200 zImage; " \
+   "bootz 0x2200 - 0x2100"
+#undef CONFIG_BOOTARGS
+#define CONFIG_BOOTARGS \
+   "console=ttyS0,115200 earlyprintk root=/dev/mmcblk1p2 rw rootwait"
+
+#endif
+
+#endif



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3] mmc: atmel: Add atmel sdhci support

2015-10-27 Thread Bo Shen

Hi Wenyou,

On 10/26/2015 11:38 AM, Wenyou Yang wrote:

The SDHCI is introduced by sama5d2, named as Secure Digital Multimedia
Card Controller(SDMMC). It supports the embedded MultiMedia Card (e.MMC)
Specification V4.41, the SD Memory Card Specification V3.0, and the SDIO
V3.0 specification. It is compliant with the SD Host Controller Standard
V3.0 specification.

Signed-off-by: Wenyou Yang 
---

Changes in v3:
  1./ return -ENODEV instead of -1, when failing to get proper clock.
  2./ add free host instance when failing to get proper clock.

Changes in v2:
  - According to Bo Shen's comments,
  1./ change the macro ATMEL_SDHC_MIN_FRQ -> ATMEL_SDHC_MIN_FREQ.
  2./ change the return value to -ENOMEM and print log for malloc failure.
  3./ add the failed return and log for getting improper clock.
  4./ add more commit log.

  arch/arm/mach-at91/include/mach/atmel_sdhci.h |   13 
  drivers/mmc/Makefile  |1 +
  drivers/mmc/atmel_sdhci.c |   40 +
  3 files changed, 54 insertions(+)
  create mode 100644 arch/arm/mach-at91/include/mach/atmel_sdhci.h
  create mode 100644 drivers/mmc/atmel_sdhci.c

diff --git a/arch/arm/mach-at91/include/mach/atmel_sdhci.h 
b/arch/arm/mach-at91/include/mach/atmel_sdhci.h
new file mode 100644
index 000..9652bc2
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/atmel_sdhci.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2015 Atmel Corporation
+ *   Wenyou.Yang 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __ATMEL_SDHCI_H
+#define __ATMEL_SDHCI_H
+
+int atmel_sdhci_init(void *regbase, u32 id);
+
+#endif
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 99d0295..5d35705 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -8,6 +8,7 @@
  obj-$(CONFIG_DM_MMC) += mmc-uclass.o

  obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
+obj-$(CONFIG_ATMEL_SDHCI) += atmel_sdhci.o
  obj-$(CONFIG_BCM2835_SDHCI) += bcm2835_sdhci.o
  obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
  obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
new file mode 100644
index 000..185a36e
--- /dev/null
+++ b/drivers/mmc/atmel_sdhci.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *   Wenyou.Yang 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#define ATMEL_SDHC_MIN_FREQ40
+
+int atmel_sdhci_init(void *regbase, u32 id)


I think the regbase type should be u32, if you keep it as "void *", then 
the following don't need to be covert to "void *".



+{
+   struct sdhci_host *host = NULL;


I think it is no need to pass NULL to host.


+   u32 max_clk, min_clk = ATMEL_SDHC_MIN_FREQ;
+
+   host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));


Maybe calloc will be better.


+   if (!host) {
+   printf("%s: sdhci_host malloc failed\n", __func__);
+   return -ENOMEM;
+   }
+
+   host->name = "atmel_sdhci";
+   host->ioaddr = (void *)regbase;


Here no need to do covert if the original type is the same.


+   host->quirks = 0;
+   host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
+   max_clk = at91_get_periph_generated_clk(id);
+   if (!max_clk) {
+   printf("%s: Failed to get the proper clock\n", __func__);
+   free(host);
+   return -ENODEV;
+   }
+
+   add_sdhci(host, max_clk, min_clk);
+
+   return 0;
+}



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] arm: atmel: Add SAMA5D2 Xplained board

2015-10-27 Thread Bo Shen

Hi Wenyou,

On 10/27/2015 14:48 PM, Yang, Wenyou wrote:

Hi Shen Bo,

Thank you very much for your review.



-Original Message-
From: Bo Shen [mailto:voice.s...@gmail.com]
Sent: 2015年10月27日 11:09
To: Yang, Wenyou; andreas.de...@googlemail.com
Cc: U-Boot Mailing List
Subject: Re: [U-Boot] [PATCH v2] arm: atmel: Add SAMA5D2 Xplained board

Hi Wenyou,
+ Andreas

On 10/27/2015 08:59 AM, Wenyou Yang wrote:

The board supports following features:
   - Boot media support: SD card/e.MMC/SPI flash,
   - Support LCD display (optional, disabled by default),
   - Support ethernet,
   - Support USB mass storage.

Signed-off-by: Wenyou Yang 
---
The patch is based on the following patches sent in mailing list.
[PATCH] gpio: atmel: Add the PIO4 driver support
[PATCH] arm: at91: Change the Chip ID registers' addresses
[PATCH v3] mmc: atmel: Add atmel sdhci support
[PATCH v2] arm: at91: clock: Add the generated clock support

Changes in v2:
   1./ re-order SAMA5D2 statements alphabetically.
   2./ remove redundant "Unknown CPU type".
   3./ rework sama5d2's macros.
   4./ remove some #ifdef before functions.
   5./ move CONFIG_CMD_SF to Kconfig.
   6./ remove NAND macros from config file.
   7./ CONFIG_BOOTCOMMAND for sf uses defines in at91-sama5_common.h.

   arch/arm/mach-at91/Kconfig   |5 +
   arch/arm/mach-at91/armv7/Makefile|1 +
   arch/arm/mach-at91/armv7/sama5d2_devices.c   |   60 +
   arch/arm/mach-at91/include/mach/at91_pmc.h   |9 +-
   arch/arm/mach-at91/include/mach/atmel_usba_udc.h |3 +-
   arch/arm/mach-at91/include/mach/hardware.h   |2 +
   arch/arm/mach-at91/include/mach/sama5d2.h|  224

+

   board/atmel/sama5d2_xplained/Kconfig |   15 ++
   board/atmel/sama5d2_xplained/MAINTAINERS |7 +
   board/atmel/sama5d2_xplained/Makefile|8 +
   board/atmel/sama5d2_xplained/sama5d2_xplained.c  |  282

++

   configs/sama5d2_xplained_mmc_defconfig   |   11 +
   configs/sama5d2_xplained_spiflash_defconfig  |   11 +
   include/configs/sama5d2_xplained.h   |  126 ++
   14 files changed, 758 insertions(+), 6 deletions(-)
   create mode 100644 arch/arm/mach-at91/armv7/sama5d2_devices.c
   create mode 100644 arch/arm/mach-at91/include/mach/sama5d2.h
   create mode 100644 board/atmel/sama5d2_xplained/Kconfig
   create mode 100644 board/atmel/sama5d2_xplained/MAINTAINERS
   create mode 100644 board/atmel/sama5d2_xplained/Makefile
   create mode 100644 board/atmel/sama5d2_xplained/sama5d2_xplained.c
   create mode 100644 configs/sama5d2_xplained_mmc_defconfig
   create mode 100644 configs/sama5d2_xplained_spiflash_defconfig
   create mode 100644 include/configs/sama5d2_xplained.h

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index fdaf328..c333647 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -71,6 +71,10 @@ config TARGET_AT91SAM9X5EK
select CPU_ARM926EJS
select SUPPORT_SPL

+config TARGET_SAMA5D2_XPLAINED
+   bool "SAMA5D2 Xplained board"
+   select CPU_V7
+
   config TARGET_SAMA5D3_XPLAINED
bool "SAMA5D3 Xplained board"
select CPU_V7
@@ -123,6 +127,7 @@ source "board/atmel/at91sam9m10g45ek/Kconfig"
   source "board/atmel/at91sam9n12ek/Kconfig"
   source "board/atmel/at91sam9rlek/Kconfig"
   source "board/atmel/at91sam9x5ek/Kconfig"
+source "board/atmel/sama5d2_xplained/Kconfig"
   source "board/atmel/sama5d3_xplained/Kconfig"
   source "board/atmel/sama5d3xek/Kconfig"
   source "board/atmel/sama5d4_xplained/Kconfig"
diff --git a/arch/arm/mach-at91/armv7/Makefile
b/arch/arm/mach-at91/armv7/Makefile
index f4f35a4..9538bc1 100644
--- a/arch/arm/mach-at91/armv7/Makefile
+++ b/arch/arm/mach-at91/armv7/Makefile
@@ -8,6 +8,7 @@
   # SPDX-License-Identifier:   GPL-2.0+
   #

+obj-$(CONFIG_SAMA5D2)  += sama5d2_devices.o
   obj-$(CONFIG_SAMA5D3)+= sama5d3_devices.o
   obj-$(CONFIG_SAMA5D4)+= sama5d4_devices.o
   obj-y += clock.o
diff --git a/arch/arm/mach-at91/armv7/sama5d2_devices.c
b/arch/arm/mach-at91/armv7/sama5d2_devices.c
new file mode 100644
index 000..26883fc
--- /dev/null
+++ b/arch/arm/mach-at91/armv7/sama5d2_devices.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *   Wenyou Yang 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+char *get_cpu_name()
+{
+   unsigned int extension_id = get_extension_chip_id();
+
+   if (cpu_is_sama5d2()) {
+   switch (extension_id) {
+   case ARCH_EXID_SAMA5D21CU:
+   return "SAMA5D21";
+   case ARCH_EXID_SAMA5D22CU:
+   return "SAMA5D22-

Re: [U-Boot] [PATCH v2] arm: atmel: Add SAMA5D2 Xplained board

2015-10-26 Thread Bo Shen
 return 0;
+}
+
+int dram_init(void)
+{
+   gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+   CONFIG_SYS_SDRAM_SIZE);
+   return 0;
+}
+
+int board_eth_init(bd_t *bis)
+{
+   int rc = 0;
+
+#ifdef CONFIG_MACB
+   rc = macb_eth_initialize(0, (void *)ATMEL_BASE_GMAC, 0x00);
+#endif
+
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+   usba_udc_probe(&pdata);
+#ifdef CONFIG_USB_ETH_RNDIS
+   usb_eth_initialize(bis);
+#endif
+#endif


Here, I think you'd better address the comments from Andreas.


+
+   return rc;
+}
diff --git a/configs/sama5d2_xplained_mmc_defconfig 
b/configs/sama5d2_xplained_mmc_defconfig
new file mode 100644
index 000..c1dcbef
--- /dev/null
+++ b/configs/sama5d2_xplained_mmc_defconfig
@@ -0,0 +1,11 @@
+CONFIG_ARM=y
+CONFIG_ARCH_AT91=y
+CONFIG_TARGET_SAMA5D2_XPLAINED=y
+CONFIG_SYS_EXTRA_OPTIONS="SAMA5D2,SYS_USE_MMC"
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_LOADS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_SF=y
+# CONFIG_CMD_FPGA is not set
+CONFIG_SPI_FLASH=y
diff --git a/configs/sama5d2_xplained_spiflash_defconfig 
b/configs/sama5d2_xplained_spiflash_defconfig
new file mode 100644
index 000..0271e8e
--- /dev/null
+++ b/configs/sama5d2_xplained_spiflash_defconfig
@@ -0,0 +1,11 @@
+CONFIG_ARM=y
+CONFIG_ARCH_AT91=y
+CONFIG_TARGET_SAMA5D2_XPLAINED=y
+CONFIG_SYS_EXTRA_OPTIONS="SAMA5D2,SYS_USE_SERIALFLASH"
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_LOADS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_SF=y
+# CONFIG_CMD_FPGA is not set
+CONFIG_SPI_FLASH=y
diff --git a/include/configs/sama5d2_xplained.h 
b/include/configs/sama5d2_xplained.h
new file mode 100644
index 000..ff9e79c
--- /dev/null
+++ b/include/configs/sama5d2_xplained.h
@@ -0,0 +1,126 @@
+/*
+ * Configuration file for the SAMA5D2 Xplained Board.
+ *
+ * Copyright (C) 2015 Atmel Corporation
+ *   Wenyou Yang 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/* No NOR flash, this definition should put before common header */
+#define CONFIG_SYS_NO_FLASH
+
+#include "at91-sama5_common.h"
+
+/* serial console */
+#define CONFIG_ATMEL_USART
+#define CONFIG_USART_BASE  ATMEL_BASE_UART1
+#define CONFIG_USART_IDATMEL_ID_UART1
+
+/* SDRAM */
+#define CONFIG_NR_DRAM_BANKS   1
+#define CONFIG_SYS_SDRAM_BASE   ATMEL_BASE_DDRCS
+#define CONFIG_SYS_SDRAM_SIZE  0x2000
+
+#ifdef CONFIG_SPL_BUILD


As you don't support SPL, can you add this later? (The same time when 
add spl support)



+#define CONFIG_SYS_INIT_SP_ADDR0x21
+#else
+#define CONFIG_SYS_INIT_SP_ADDR \
+   (CONFIG_SYS_SDRAM_BASE + 4 * 1024 - GENERATED_GBL_DATA_SIZE)
+#endif
+
+#define CONFIG_SYS_LOAD_ADDR   0x2200 /* load address */
+
+#undef CONFIG_AT91_GPIO
+#define CONFIG_ATMEL_PIO4
+
+/* SerialFlash */
+#ifdef CONFIG_CMD_SF
+#define CONFIG_ATMEL_SPI
+#define CONFIG_ATMEL_SPI0
+#define CONFIG_SPI_FLASH_ATMEL
+#define CONFIG_SF_DEFAULT_BUS  0
+#define CONFIG_SF_DEFAULT_CS   0
+#define CONFIG_SF_DEFAULT_SPEED3000
+#endif
+
+/* NAND flash */
+#undef CONFIG_CMD_NAND
+
+/* MMC */
+#define CONFIG_CMD_MMC
+
+#ifdef CONFIG_CMD_MMC
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_SDHCI
+#define CONFIG_ATMEL_SDHCI
+#define CONFIG_ATMEL_SDHCI0
+#define CONFIG_ATMEL_SDHCI1
+#define CONFIG_SUPPORT_EMMC_BOOT
+#endif
+
+/* USB */
+#define CONFIG_CMD_USB
+
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_ATMEL
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
+#define CONFIG_USB_STORAGE
+#endif
+
+/* USB device */
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_ATMEL_USBA
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_RNDIS
+#define CONFIG_USBNET_MANUFACTURER  "Atmel SAMA5D2 XPlained"
+
+#if defined(CONFIG_CMD_USB) || defined(CONFIG_CMD_MMC)
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+#endif
+
+/* Ethernet Hardware */
+#define CONFIG_MACB
+#define CONFIG_RMII
+#define CONFIG_NET_RETRY_COUNT 20
+#define CONFIG_MACB_SEARCH_PHY
+
+/* LCD */
+/* #define CONFIG_LCD */
+
+#ifdef CONFIG_LCD
+#define LCD_BPPLCD_COLOR16
+#define LCD_OUTPUT_BPP  24
+#define CONFIG_LCD_LOGO
+#define CONFIG_LCD_INFO
+#define CONFIG_LCD_INFO_BELOW_LOGO
+#define CONFIG_SYS_WHITE_ON_BLACK
+#define CONFIG_ATMEL_HLCD
+#define CONFIG_ATMEL_LCD_RGB565
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#endif
+
+#ifdef CONFIG_SYS_USE_MMC
+
+/* bootstrap + u-boot + env in sd card */
+#undef FAT_ENV_DEVICE_AND_PART
+#undef CONFIG_BOOTCOMMAND
+
+#define FAT_ENV_DEVICE_AND_PART"1"
+#define CONFIG_BOOTCOMMAND "fatload mmc 1:1 0x2100 
at91-sama5d2_xplained.dtb; " \
+   "fatload mmc 1:1 0x2200 zImage; " \
+   "bootz 0x2200 - 0x2100"
+#undef CONFIG_BOOTARGS
+#define CONFIG_BOOTARGS \
+   "console=ttyS0,115200 earlyprintk root=/dev/mmcblk1p2 rw rootwait"
+
+#endif


This part also present in at91-sama5_common.h, can it be used?


+
+#endif



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: at91: sama5: change the environment address to 0x6000

2015-10-26 Thread Bo Shen

Hi Josh,

On 10/26/2015 16:41 PM, Josh Wu wrote:

Hi, Bo

On 10/26/2015 2:43 PM, Bo Shen wrote:

Hi Josh,

On 10/23/2015 17:18 PM, Josh Wu wrote:

As sama5 board has 32k sram size, so the at91bootstrap and spl for sama5
boards is bigger than 16k (0x4000). That will overlap the U-Boot


Just curious about from which commit the spl binary size bigger than 16k?


 From a rough test, I found v2015.07 have spls which is bigger than 16k.
but in v2015.04 all are smaller than 16k (very close).

➜  temp  cd v2015.04
➜  v2015.04  ls *spi*spl.bin -l
-rwxrwxr-x 1 josh josh 15540 Oct 26 15:38
at91sam9n12ek_spiflash_defconfig_u-boot-spl.bin
-rwxrwxr-x 1 josh josh 15704 Oct 26 15:38
at91sam9x5ek_spiflash_defconfig_u-boot-spl.bin
-rwxrwxr-x 1 josh josh 16064 Oct 26 15:34
sama5d3xek_spiflash_defconfig_u-boot-spl.bin
-rwxrwxr-x 1 josh josh 16304 Oct 26 15:35
sama5d4ek_spiflash_defconfig_u-boot-spl.bin
-rwxrwxr-x 1 josh josh 16304 Oct 26 15:37
sama5d4_xplained_spiflash_defconfig_u-boot-spl.bin
➜  v2015.04  cd ../v2015.07
➜  v2015.07  ls *spi*spl.bin -l
-rwxrwxr-x 1 josh josh 16136 Oct 26 15:30
at91sam9n12ek_spiflash_defconfig_u-boot-spl.bin
-rwxrwxr-x 1 josh josh 16300 Oct 26 15:30
at91sam9x5ek_spiflash_defconfig_u-boot-spl.bin
-rwxrwxr-x 1 josh josh 16664 Oct 26 15:25
sama5d3xek_spiflash_defconfig_u-boot-spl.bin
-rwxrwxr-x 1 josh josh 16904 Oct 26 15:26
sama5d4ek_spiflash_defconfig_u-boot-spl.bin
-rwxrwxr-x 1 josh josh 16904 Oct 26 15:28
sama5d4_xplained_spiflash_defconfig_u-boot-spl.bin


Thanks for these information. So, I regard this patch as a fix. If this 
information can be added into commit message I think that will be better.


Acked-by: Bo Shen 

Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: at91: sama5: change the environment address to 0x6000

2015-10-25 Thread Bo Shen

Hi Josh,

On 10/23/2015 17:18 PM, Josh Wu wrote:

As sama5 board has 32k sram size, so the at91bootstrap and spl for sama5
boards is bigger than 16k (0x4000). That will overlap the U-Boot


Just curious about from which commit the spl binary size bigger than 16k?

Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: atmel: Add support fo atmel sdhci

2015-09-16 Thread Bo Shen

Hi Wenyou,

On 09/16/2015 04:23 PM, Wenyou Yang wrote:

I think you should add commit message here.


Signed-off-by: Wenyou Yang 
---

  arch/arm/mach-at91/include/mach/atmel_sdhci.h |   13 +
  drivers/mmc/Makefile  |1 +
  drivers/mmc/atmel_sdhci.c |   35 +
  3 files changed, 49 insertions(+)
  create mode 100644 arch/arm/mach-at91/include/mach/atmel_sdhci.h
  create mode 100644 drivers/mmc/atmel_sdhci.c

diff --git a/arch/arm/mach-at91/include/mach/atmel_sdhci.h 
b/arch/arm/mach-at91/include/mach/atmel_sdhci.h
new file mode 100644
index 000..cf3bf89
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/atmel_sdhci.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2015 Atmel Corporation
+ *   Wenyou.Yang 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef__ATMEL_SDHCI_H
+#define__ATMEL_SDHCI_H
+
+int atmel_sdhci_init(void *regbase, u32 id);
+
+#endif
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 99d0295..5d35705 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -8,6 +8,7 @@
  obj-$(CONFIG_DM_MMC) += mmc-uclass.o

  obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
+obj-$(CONFIG_ATMEL_SDHCI) += atmel_sdhci.o
  obj-$(CONFIG_BCM2835_SDHCI) += bcm2835_sdhci.o
  obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
  obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
new file mode 100644
index 000..64776a1
--- /dev/null
+++ b/drivers/mmc/atmel_sdhci.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *   Wenyou.Yang 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#define ATMEL_SDHC_MIN_FRQ 40


Nit: maybe FREQ is better than FRQ?


+
+int atmel_sdhci_init(void *regbase, u32 id)
+{
+   struct sdhci_host *host = NULL;
+   u32 max_clk, min_clk = ATMEL_SDHC_MIN_FRQ;
+
+   host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));


How about "host = malloc(sizeof(*host));"?


+   if (!host) {
+   printf("atmel_sdhci_init: sdhci_host malloc fail\n");
+   return -1;


Maybe use -ENOMEM replace -1?


+   }
+
+   host->name = "atmel_sdhci";
+   host->ioaddr = (void *)regbase;
+   host->quirks = 0;
+   host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
+   max_clk = at91_get_periph_generated_clk(id);


As we discussed with your patch for "at91_get_periph_generated_clk", 
this function may failed. So, I think you need add error check here.



+   add_sdhci(host, max_clk, min_clk);
+
+   return 0;
+}



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: at91: sama5: add support for CONFIG_ENV_IS_IN_MMC

2015-09-16 Thread Bo Shen

Hi Josh

On 09/16/2015 11:34 AM, Josh Wu wrote:

If defined CONFIG_ENV_IS_IN_MMC, then u-boot environment is saved in
mmc's raw sectors. Otherwise, u-boot environment is saved as a file:
uboot.env.

Signed-off-by: Josh Wu 


Reviewed-by: Bo Shen 

Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: at91: clock: Add the generated clock support

2015-09-11 Thread Bo Shen

Hi Wenyou,

On 09/11/2015 10:01 AM, Yang, Wenyou wrote:

+
> >+void at91_enable_periph_generated_clk(u32 id) {
> >+  struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> >+  u32 regval;
> >+
> >+  if (id > AT91_PMC_PCR_PID_MASK)
> >+  return;
> >+
> >+  writel(id, &pmc->pcr);
> >+  regval = readl(&pmc->pcr);
> >+  regval &= ~AT91_PMC_PCR_GCKCSS;
> >+  regval &= ~AT91_PMC_PCR_GCKDIV;
> >+  regval |= AT91_PMC_PCR_GCKCSS_PLLA_CLK |
> >+AT91_PMC_PCR_CMD_WRITE |
> >+AT91_PMC_PCR_GCKDIV_(1) |
> >+AT91_PMC_PCR_GCKEN;
> >+
> >+  writel(regval, &pmc->pcr);
> >+
> >+  while (!(readl(&pmc->sr) & AT91_PMC_GCKRDY))
> >+  ;

>
>Here, do we need to hang the whole system?

Do you mean, add the timeout to while()?


Yes, something like that.


But we think if the clock can't reach to a stable state, the system must be in 
wrong condition.
So, I don't think this timeout is necessary.


As no datasheet for this. According to the code, the clock is for the 
peripheral which want to use the generated clock. So, it only affect 
this peripheral while not whole system, am I right?


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: at91: clock: Add the generated clock support

2015-09-09 Thread Bo Shen

Hi Wenyou,

On 09/09/2015 10:29 AM, Wenyou Yang wrote:

Some peripherals may need a second clock source that may be different
from the system clock. This second clock is the generated clock (GCK)
and is managed by the PMC via PMC_PCR.

For simplicity, the source of the GCK is fixed to PLLA_CLK.

Signed-off-by: Wenyou Yang 
---

  arch/arm/mach-at91/armv7/clock.c   |   57 
  arch/arm/mach-at91/include/mach/at91_pmc.h |   13 +++
  arch/arm/mach-at91/include/mach/clk.h  |3 ++
  3 files changed, 73 insertions(+)

diff --git a/arch/arm/mach-at91/armv7/clock.c b/arch/arm/mach-at91/armv7/clock.c
index 0bf453e..84418a3 100644
--- a/arch/arm/mach-at91/armv7/clock.c
+++ b/arch/arm/mach-at91/armv7/clock.c
@@ -5,6 +5,7 @@
   * Copyright (C) 2005 Ivan Kokshaysky
   * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD 
   * Copyright (C) 2013 Bo Shen 
+ * Copyright (C) 2015 Wenyou Yang 
   *
   * SPDX-License-Identifier:   GPL-2.0+
   */
@@ -173,3 +174,59 @@ void at91_periph_clk_disable(int id)

writel(regval, &pmc->pcr);
  }
+
+void at91_enable_periph_generated_clk(u32 id)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   u32 regval;
+
+   if (id > AT91_PMC_PCR_PID_MASK)
+   return;
+
+   writel(id, &pmc->pcr);
+   regval = readl(&pmc->pcr);
+   regval &= ~AT91_PMC_PCR_GCKCSS;
+   regval &= ~AT91_PMC_PCR_GCKDIV;
+   regval |= AT91_PMC_PCR_GCKCSS_PLLA_CLK |
+ AT91_PMC_PCR_CMD_WRITE |
+ AT91_PMC_PCR_GCKDIV_(1) |
+ AT91_PMC_PCR_GCKEN;
+
+   writel(regval, &pmc->pcr);
+
+   while (!(readl(&pmc->sr) & AT91_PMC_GCKRDY))
+   ;


Here, do we need to hang the whole system?


+}
+
+u32 at91_get_periph_generated_clk(u32 id)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   u32 regval, clk_source, div;
+   u32 freq = 0;
+
+   if (id > AT91_PMC_PCR_PID_MASK)
+   return 0;
+
+   writel(id, &pmc->pcr);
+   regval = readl(&pmc->pcr);
+
+   clk_source = regval & AT91_PMC_PCR_GCKCSS;
+   switch (clk_source) {
+   case AT91_PMC_PCR_GCKCSS_SLOW_CLK:
+   freq = CONFIG_SYS_AT91_SLOW_CLOCK;
+   break;
+   case AT91_PMC_PCR_GCKCSS_MAIN_CLK:
+   freq = gd->arch.main_clk_rate_hz;
+   break;
+   case AT91_PMC_PCR_GCKCSS_PLLA_CLK:
+   freq = gd->arch.plla_rate_hz;
+   break;
+   default:
+   break;


For the default, is it valuable to add error information? Or return an 
invalid value?



+   }
+
+   div = ((regval & AT91_PMC_PCR_GCKDIV) >> AT91_PMC_PCR_GCKDIV_OFFSET);
+   div += 1;
+
+   return freq / div;
+}
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index 8a3fb94..dcd6e36 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -153,8 +153,20 @@ typedef struct at91_pmc {
  #define AT91_PMC_IXR_MOSCSELS 0x0001

  #define AT91_PMC_PCR_PID_MASK (0x3f)
+#define AT91_PMC_PCR_GCKCSS(0x7 << 8)
+#defineAT91_PMC_PCR_GCKCSS_SLOW_CLK(0x0 << 8)
+#defineAT91_PMC_PCR_GCKCSS_MAIN_CLK(0x1 << 8)
+#defineAT91_PMC_PCR_GCKCSS_PLLA_CLK(0x2 << 8)
+#defineAT91_PMC_PCR_GCKCSS_UPLL_CLK(0x3 << 8)
+#defineAT91_PMC_PCR_GCKCSS_MCK_CLK (0x4 << 8)
+#defineAT91_PMC_PCR_GCKCSS_AUDIO_CLK   (0x5 << 8)
  #define AT91_PMC_PCR_CMD_WRITE(0x1 << 12)
+#define AT91_PMC_PCR_DIV   (0x3 << 16)
+#define AT91_PMC_PCR_GCKDIV(0xff << 20)
+#defineAT91_PMC_PCR_GCKDIV_(x) ((x) << 20)


It is dangerous here, if "x = 0xfff", then what will happen?


+#defineAT91_PMC_PCR_GCKDIV_OFFSET  20
  #define AT91_PMC_PCR_EN   (0x1 << 28)
+#define AT91_PMC_PCR_GCKEN (0x1 << 29)

  #define   AT91_PMC_PCK(1 <<  0) /* Processor 
Clock */
  #define   AT91RM9200_PMC_UDP  (1 <<  1) /* USB 
Devcice Port Clock [AT91RM9200 only] */
@@ -236,6 +248,7 @@ typedef struct at91_pmc {
  #define   AT91_PMC_PCK1RDY(1 <<  9) /* 
Programmable Clock 1 */
  #define   AT91_PMC_PCK2RDY(1 << 10) /* 
Programmable Clock 2 */
  #define   AT91_PMC_PCK3RDY(1 << 11) /* 
Programmable Clock 3 */
+#defineAT91_PMC_GCKRDY (1 << 24)

  #define   AT91_PMC_PROTKEY0x504d4301  /* Activation 
Code */
  #endif
diff --git a/ar

Re: [U-Boot] Fastboot is not detected

2015-09-09 Thread Bo Shen

Hi Fabio,

On 09/10/2015 05:02 AM, Fabio Estevam wrote:

Hi,

I am trying to add fastboot support for mx6qsabresd and I did the
following changes on against top of head U-boot:

--- a/include/configs/mx6sabre_common.h
+++ b/include/configs/mx6sabre_common.h
@@ -238,6 +238,12 @@
  #define CONFIG_G_DNL_VENDOR_NUM0x0525
  #define CONFIG_G_DNL_PRODUCT_NUM0xa4a5
  #define CONFIG_G_DNL_MANUFACTURER"FSL"
+
+#define CONFIG_USB_FUNCTION_FASTBOOT
+#define CONFIG_CMD_FASTBOOT
+#define CONFIG_ANDROID_BOOT_IMAGE
+#define CONFIG_FASTBOOT_BUF_ADDR   CONFIG_SYS_LOAD_ADDR
+#define CONFIG_FASTBOOT_BUF_SIZE   0x0700
  #endif

  #endif /* __MX6QSABRE_COMMON_CONFIG_H */

On the U-boot prompt I run:

=> fastboot 0

and then in the host PC I try to read the bootloader version:

$ fastboot getvar bootloader-version
< waiting for device >


Please check whether the fastboot application supports your vendor ID. 
If not, add "-i  in your command line.


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Regression in usb-storage in u-boot 2015.04 ???

2015-03-26 Thread Bo Shen

Hi Hans,

On 03/27/2015 03:08 AM, Hans de Goede wrote:

Hi,

First of all I'm not sure this is a regression, but I'm afraid
I do not have time to dig deeper so I thought I should report
it anyways and then others can try to reproduce it.

I'm seeing the following happen when using a usb stick
with a musb-new otg controller in host mode on an allwinner
tablet:

sunxi# usb reset
resetting USB...
USB0:   scanning bus 0 for devices... 1 USB Device(s) found
scanning usb for storage devices... error in inquiry
0 Storage Device(s) found

The interesting thing is that, the first "usb start" works
fine, this only happens on the second usb start (triggered
through a usb reset).

This may be specific to using musb on sunxi, or to the
flashdrive I have but I thought I should report this
anyways. Esp. since usb otherwise works fine after a
usb reset, other devices (usb keyboards) continue to
work, and the descriptors of the usb drive do get read
correctly:


sunxi# usb info
1: Mass Storage,  USB Revision 2.0
  - USB Flash Disk 4C0E960F
  - Class: (from Interface) Mass Storage
  - PacketSize: 64  Configurations: 1
  - Vendor: 0x058f  Product 0x6387 Version 1.3
Configuration: 1
- Interfaces: 1 Bus Powered 100mA
  Interface: 0
  - Alternate Setting 0, Endpoints: 2
  - Class Mass Storage, Transp. SCSI, Bulk only
  - Endpoint 1 Out Bulk MaxPacket 512
  - Endpoint 2 In Bulk MaxPacket 512


Perhaps someone can test the reproducer on another board
with usb:

1) plug in a usb drive
2) do "usb start"
3) should print that 1 storage device is found
4) do "usb reset"
5) should still print that 1 storage device is found,
but for me gives the error I mentioned above.


I tested it OK with EHCI on Atmel sama5d4ek board. The following 
information for your reference.

--->8---
U-Boot SPL 2015.04-rc4-00067-gf643d92 (Mar 27 2015 - 14:31:49)


U-Boot 2015.04-rc4-00067-gf643d92 (Mar 27 2015 - 14:31:49)

CPU: SAMA5D44
Crystal frequency:   12 MHz
CPU clock:  528 MHz
Master clock :  176 MHz
DRAM:  512 MiB
NAND:  512 MiB
MMC:   mci: 0
In:serial
Out:   serial
Err:   serial
Net:   gmac0, usb_ether
Error: usb_ether address not set.

Hit any key to stop autoboot:  0
U-Boot> usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
   scanning usb for storage devices... 1 Storage Device(s) found
U-Boot> usb reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
   scanning usb for storage devices... 1 Storage Device(s) found
U-Boot>
---8<---


Regards,

Hans


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 4/4] ARM: atmel: at91sam9n12ek: enable spl support

2015-03-26 Thread Bo Shen
Enable SPL support for at91sam9n12ek boards, now it supports
boot up from NAND flash, serial flash.

Signed-off-by: Bo Shen 
---

Changes in v2:
  - Remove the meaningless prefix "+S:" in configuration file.

 arch/arm/mach-at91/Kconfig |  1 +
 arch/arm/mach-at91/Makefile|  1 +
 arch/arm/mach-at91/include/mach/at91_pmc.h |  4 +-
 arch/arm/mach-at91/mpddrc.c|  2 +-
 arch/arm/mach-at91/spl_at91.c  |  2 +-
 board/atmel/at91sam9n12ek/at91sam9n12ek.c  | 73 ++
 configs/at91sam9n12ek_nandflash_defconfig  |  1 +
 configs/at91sam9n12ek_spiflash_defconfig   |  1 +
 include/configs/at91sam9n12ek.h| 58 +++-
 9 files changed, 138 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index bdf87f9..30c4e17 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -75,6 +75,7 @@ config TARGET_PM9G45
 config TARGET_AT91SAM9N12EK
bool "Atmel AT91SAM9N12-EK board"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_AT91SAM9RLEK
bool "Atmel at91sam9rl reference board"
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index ba83616..0d3ee48 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_AT91_WANTS_COMMON_PHY) += phy.o
 ifneq ($(CONFIG_SPL_BUILD),)
 obj-$(CONFIG_AT91SAM9G20) += sdram.o spl_at91.o
 obj-$(CONFIG_AT91SAM9M10G45) += mpddrc.o spl_at91.o
+obj-$(CONFIG_AT91SAM9N12) += mpddrc.o spl_at91.o
 obj-$(CONFIG_AT91SAM9X5) += mpddrc.o spl_at91.o
 obj-$(CONFIG_SAMA5D3) += mpddrc.o spl_atmel.o
 obj-$(CONFIG_SAMA5D4) += mpddrc.o spl_atmel.o
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index c903260..ebb7dec 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -98,7 +98,7 @@ typedef struct at91_pmc {
 #define AT91_PMC_MCKR_CSS_MASK 0x0003
 
 #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
-   defined(CONFIG_AT91SAM9X5)
+   defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)
 #define AT91_PMC_MCKR_PRES_1   0x
 #define AT91_PMC_MCKR_PRES_2   0x0010
 #define AT91_PMC_MCKR_PRES_4   0x0020
@@ -128,7 +128,7 @@ typedef struct at91_pmc {
 #define AT91_PMC_MCKR_MDIV_1   0x
 #define AT91_PMC_MCKR_MDIV_2   0x0100
 #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
-   defined(CONFIG_AT91SAM9X5)
+   defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)
 #define AT91_PMC_MCKR_MDIV_3   0x0300
 #endif
 #define AT91_PMC_MCKR_MDIV_4   0x0200
diff --git a/arch/arm/mach-at91/mpddrc.c b/arch/arm/mach-at91/mpddrc.c
index 24d5fcd..e2b6a49 100644
--- a/arch/arm/mach-at91/mpddrc.c
+++ b/arch/arm/mach-at91/mpddrc.c
@@ -20,7 +20,7 @@ static inline void atmel_mpddr_op(int mode, u32 ram_address)
 static int ddr2_decodtype_is_seq(u32 cr)
 {
 #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
-   defined(CONFIG_AT91SAM9X5)
+   defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)
if (cr & ATMEL_MPDDRC_CR_DECOD_INTERLEAVED)
return 0;
 #endif
diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c
index e28e568..a79a9dc 100644
--- a/arch/arm/mach-at91/spl_at91.c
+++ b/arch/arm/mach-at91/spl_at91.c
@@ -115,7 +115,7 @@ void board_init_f(ulong dummy)
timer_init();
 
/* enable clocks for all PIOs */
-#ifdef CONFIG_AT91SAM9X5
+#if defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)
at91_periph_clk_enable(ATMEL_ID_PIOAB);
at91_periph_clk_enable(ATMEL_ID_PIOCD);
 #else
diff --git a/board/atmel/at91sam9n12ek/at91sam9n12ek.c 
b/board/atmel/at91sam9n12ek/at91sam9n12ek.c
index 9adc992..4f46a03 100644
--- a/board/atmel/at91sam9n12ek/at91sam9n12ek.c
+++ b/board/atmel/at91sam9n12ek/at91sam9n12ek.c
@@ -257,3 +257,76 @@ int dram_init(void)
CONFIG_SYS_SDRAM_SIZE);
return 0;
 }
+
+#if defined(CONFIG_SPL_BUILD)
+#include 
+#include 
+
+void at91_spl_board_init(void)
+{
+#ifdef CONFIG_SYS_USE_MMC
+   at91_mci_hw_init();
+#elif CONFIG_SYS_USE_NANDFLASH
+   at91sam9n12ek_nand_hw_init();
+#elif CONFIG_SYS_USE_SPIFLASH
+   at91_spi0_hw_init(1 << 4);
+#endif
+}
+
+#include 
+static void ddr2_conf(struct atmel_mpddr *ddr2)
+{
+   ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+   ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+   ATMEL_MPDDRC_CR_NR_ROW_13 |
+   ATMEL_MPDDRC_CR_CAS_DDR_CAS3 |
+   ATMEL_MPDDRC_CR_NB_8BANKS |
+   ATMEL_MPDDRC_CR_DECOD_INTERLEAVED);
+
+   ddr2->rtr = 0x411;
+
+   ddr2->tpr0 = (6 <&l

[U-Boot] [PATCH v2 1/4] ARM: atmel: arm926ejs: fix clock configuration

2015-03-26 Thread Bo Shen
Config MCKR according to the datasheet sequence, or else it
will cause the MCKR configuration failed.

Remove timeout checking for clock configuration, if configure
the clock failed, let the system hang while not run in wrong
clock configuration.

Signed-off-by: Bo Shen 
Tested-by: Heiko Schocher 
---

Changes in v2: None

 arch/arm/mach-at91/arm926ejs/clock.c | 54 +++-
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-at91/arm926ejs/clock.c 
b/arch/arm/mach-at91/arm926ejs/clock.c
index f363982..8d6934e 100644
--- a/arch/arm/mach-at91/arm926ejs/clock.c
+++ b/arch/arm/mach-at91/arm926ejs/clock.c
@@ -195,50 +195,52 @@ int at91_clock_init(unsigned long main_clock)
 void at91_plla_init(u32 pllar)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-   int timeout = AT91_PLL_LOCK_TIMEOUT;
 
writel(pllar, &pmc->pllar);
-   while (!(readl(&pmc->sr) & (AT91_PMC_LOCKA | AT91_PMC_MCKRDY))) {
-   timeout--;
-   if (timeout == 0)
-   break;
-   }
+   while (!(readl(&pmc->sr) & AT91_PMC_LOCKA))
+   ;
 }
 void at91_pllb_init(u32 pllbr)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-   int timeout = AT91_PLL_LOCK_TIMEOUT;
 
writel(pllbr, &pmc->pllbr);
-   while (!(readl(&pmc->sr) & (AT91_PMC_LOCKB | AT91_PMC_MCKRDY))) {
-   timeout--;
-   if (timeout == 0)
-   break;
-   }
+   while (!(readl(&pmc->sr) & AT91_PMC_LOCKB))
+   ;
 }
 
 void at91_mck_init(u32 mckr)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-   int timeout = AT91_PLL_LOCK_TIMEOUT;
u32 tmp;
 
tmp = readl(&pmc->mckr);
-   tmp &= ~(AT91_PMC_MCKR_PRES_MASK |
-AT91_PMC_MCKR_MDIV_MASK |
-AT91_PMC_MCKR_PLLADIV_MASK |
-AT91_PMC_MCKR_CSS_MASK);
-   tmp |= mckr & (AT91_PMC_MCKR_PRES_MASK |
-  AT91_PMC_MCKR_MDIV_MASK |
-  AT91_PMC_MCKR_PLLADIV_MASK |
-  AT91_PMC_MCKR_CSS_MASK);
+   tmp &= ~AT91_PMC_MCKR_PRES_MASK;
+   tmp |= mckr & AT91_PMC_MCKR_PRES_MASK;
writel(tmp, &pmc->mckr);
+   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+   ;
 
-   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY)) {
-   timeout--;
-   if (timeout == 0)
-   break;
-   }
+   tmp = readl(&pmc->mckr);
+   tmp &= ~AT91_PMC_MCKR_MDIV_MASK;
+   tmp |= mckr & AT91_PMC_MCKR_MDIV_MASK;
+   writel(tmp, &pmc->mckr);
+   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+   ;
+
+   tmp = readl(&pmc->mckr);
+   tmp &= ~AT91_PMC_MCKR_PLLADIV_MASK;
+   tmp |= mckr & AT91_PMC_MCKR_PLLADIV_MASK;
+   writel(tmp, &pmc->mckr);
+   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+   ;
+
+   tmp = readl(&pmc->mckr);
+   tmp &= ~AT91_PMC_MCKR_CSS_MASK;
+   tmp |= mckr & AT91_PMC_MCKR_CSS_MASK;
+   writel(tmp, &pmc->mckr);
+   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+   ;
 }
 
 void at91_periph_clk_enable(int id)
-- 
2.3.3.220.g9ab698f

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


[U-Boot] [PATCH v2 2/4] ARM: atmel: at91sam9m10g45ek: enable spl support

2015-03-26 Thread Bo Shen
Supports boot up from NAND flash with software ECC eanbled.
And supports boot up from SD/MMC card with FAT file system.

As the boot from SD/MMC card with FAT file system, the BSS
segment is too big to fit into SRAM, so, use the lds to put
it into SDRAM.

Signed-off-by: Bo Shen 
---

Changes in v2:
  - Remove the meaningless prefix "+S:" in configuration file.

 arch/arm/mach-at91/Kconfig  |  1 +
 arch/arm/mach-at91/arm926ejs/u-boot-spl.lds | 48 +++
 arch/arm/mach-at91/spl_at91.c   |  6 +-
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80 +
 configs/at91sam9m10g45ek_mmc_defconfig  |  1 +
 configs/at91sam9m10g45ek_nandflash_defconfig|  1 +
 include/configs/at91sam9m10g45ek.h  | 58 ++
 7 files changed, 194 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-at91/arm926ejs/u-boot-spl.lds

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 30945c1..25da926 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -66,6 +66,7 @@ config TARGET_STAMP9G20
 config TARGET_AT91SAM9M10G45EK
bool "Atmel AT91SAM9M10G45-EK board"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_PM9G45
bool "Ronetix pm9g45 board"
diff --git a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds 
b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
new file mode 100644
index 000..acadd1d
--- /dev/null
+++ b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *   Bo Shen 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \
+   LENGTH = CONFIG_SPL_MAX_SIZE }
+MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
+   LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+   .text  :
+   {
+   __start = .;
+   *(.vectors)
+   arch/arm/cpu/arm926ejs/start.o  (.text*)
+   *(.text*)
+   } >.sram
+
+   . = ALIGN(4);
+   .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
+
+   . = ALIGN(4);
+   .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
+
+   . = ALIGN(4);
+   __image_copy_end = .;
+
+   .end :
+   {
+   *(.__end)
+   } >.sram
+
+   .bss :
+   {
+   . = ALIGN(4);
+   __bss_start = .;
+   *(.bss*)
+   . = ALIGN(4);
+   __bss_end = .;
+   } >.sdram
+}
diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c
index 89f588b..af6fc0d 100644
--- a/arch/arm/mach-at91/spl_at91.c
+++ b/arch/arm/mach-at91/spl_at91.c
@@ -71,7 +71,11 @@ void __weak at91_spl_board_init(void)
 {
 }
 
-void spl_board_init(void)
+void __weak spl_board_init(void)
+{
+}
+
+void board_init_f(ulong dummy)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
diff --git a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c 
b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
index b807ef9..4289179 100644
--- a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
+++ b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -15,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
@@ -71,6 +73,84 @@ void at91sam9m10g45ek_nand_hw_init(void)
 }
 #endif
 
+#if defined(CONFIG_SPL_BUILD)
+#include 
+#include 
+
+void at91_spl_board_init(void)
+{
+   /*
+* On the at91sam9m10g45ek board, the chip wm9711 stays in the
+* test mode, so it needs do some action to exit test mode.
+*/
+   at91_periph_clk_enable(ATMEL_ID_PIODE);
+   at91_set_gpio_output(AT91_PIN_PD7, 0);
+   at91_set_gpio_output(AT91_PIN_PD8, 0);
+   at91_set_pio_pullup(AT91_PIO_PORTD, 7, 1);
+   at91_set_pio_pullup(AT91_PIO_PORTD, 8, 1);
+
+#ifdef CONFIG_SYS_USE_MMC
+   at91_mci_hw_init();
+#elif CONFIG_SYS_USE_NANDFLASH
+   at91sam9m10g45ek_nand_hw_init();
+#endif
+}
+
+#include 
+static void ddr2_conf(struct atmel_mpddr *ddr2)
+{
+   ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+   ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+   ATMEL_MPDDRC_CR_NR_ROW_14 |
+   ATMEL_MPDDRC_CR_DQMS_SHARED |
+   ATMEL_MPDDRC_CR_CAS_DDR_CAS3);
+
+   ddr2->rtr = 0x24b;
+
+   ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |/* 6*7.5 = 45 ns */
+ 2 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET |/* 2*7.5 = 15 ns */
+ 2 << ATMEL_MPDDRC_TPR0_TWR_OFFSET | /* 2*7.5

[U-Boot] [PATCH v2 3/4] ARM: atmel: at91sam9x5ek: enable spl support

2015-03-26 Thread Bo Shen
Enable SPL support for at91sam9x5ek board. Now, it supports
boot up from NAND flash and SPI flash.

Signed-off-by: Bo Shen 
---

Changes in v2:
  - Remove the meaningless prefix "+S:" in configuration file.

 arch/arm/mach-at91/Kconfig   |  1 +
 arch/arm/mach-at91/Makefile  |  1 +
 arch/arm/mach-at91/include/mach/at91_pmc.h   |  6 ++-
 arch/arm/mach-at91/include/mach/at91sam9x5.h | 10 
 arch/arm/mach-at91/mpddrc.c  |  3 +-
 arch/arm/mach-at91/spl.c |  2 +-
 arch/arm/mach-at91/spl_at91.c|  5 ++
 board/atmel/at91sam9x5ek/at91sam9x5ek.c  | 74 
 configs/at91sam9x5ek_nandflash_defconfig |  1 +
 configs/at91sam9x5ek_spiflash_defconfig  |  1 +
 include/configs/at91sam9x5ek.h   | 57 +
 11 files changed, 157 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 25da926..bdf87f9 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -83,6 +83,7 @@ config TARGET_AT91SAM9RLEK
 config TARGET_AT91SAM9X5EK
bool "Atmel AT91SAM9X5-EK board"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_SAMA5D3_XPLAINED
bool "SAMA5D3 Xplained board"
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index e596ba6..ba83616 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_AT91_WANTS_COMMON_PHY) += phy.o
 ifneq ($(CONFIG_SPL_BUILD),)
 obj-$(CONFIG_AT91SAM9G20) += sdram.o spl_at91.o
 obj-$(CONFIG_AT91SAM9M10G45) += mpddrc.o spl_at91.o
+obj-$(CONFIG_AT91SAM9X5) += mpddrc.o spl_at91.o
 obj-$(CONFIG_SAMA5D3) += mpddrc.o spl_atmel.o
 obj-$(CONFIG_SAMA5D4) += mpddrc.o spl_atmel.o
 obj-y += spl.o
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index 65691ab..c903260 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -97,7 +97,8 @@ typedef struct at91_pmc {
 #define AT91_PMC_MCKR_CSS_PLLB 0x0003
 #define AT91_PMC_MCKR_CSS_MASK 0x0003
 
-#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4)
+#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
+   defined(CONFIG_AT91SAM9X5)
 #define AT91_PMC_MCKR_PRES_1   0x
 #define AT91_PMC_MCKR_PRES_2   0x0010
 #define AT91_PMC_MCKR_PRES_4   0x0020
@@ -126,7 +127,8 @@ typedef struct at91_pmc {
 #else
 #define AT91_PMC_MCKR_MDIV_1   0x
 #define AT91_PMC_MCKR_MDIV_2   0x0100
-#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4)
+#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
+   defined(CONFIG_AT91SAM9X5)
 #define AT91_PMC_MCKR_MDIV_3   0x0300
 #endif
 #define AT91_PMC_MCKR_MDIV_4   0x0200
diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5.h 
b/arch/arm/mach-at91/include/mach/at91sam9x5.h
index 36a5cdf..d18c936 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9x5.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9x5.h
@@ -124,6 +124,16 @@
 #define ATMEL_BASE_EHCI0x0070 /* USB Host controller 
(EHCI) */
 #endif
 
+/*
+ * External memory
+ */
+#define ATMEL_BASE_CS0 0x1000
+#define ATMEL_BASE_CS1 0x2000
+#define ATMEL_BASE_CS2 0x3000
+#define ATMEL_BASE_CS3 0x4000
+#define ATMEL_BASE_CS4 0x5000
+#define ATMEL_BASE_CS5 0x6000
+
 /* 9x5 series chip id definitions */
 #define ARCH_ID_AT91SAM9X5 0x819a05a0
 #define ARCH_ID_VERSION_MASK   0x1f
diff --git a/arch/arm/mach-at91/mpddrc.c b/arch/arm/mach-at91/mpddrc.c
index beec13d..24d5fcd 100644
--- a/arch/arm/mach-at91/mpddrc.c
+++ b/arch/arm/mach-at91/mpddrc.c
@@ -19,7 +19,8 @@ static inline void atmel_mpddr_op(int mode, u32 ram_address)
 
 static int ddr2_decodtype_is_seq(u32 cr)
 {
-#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4)
+#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
+   defined(CONFIG_AT91SAM9X5)
if (cr & ATMEL_MPDDRC_CR_DECOD_INTERLEAVED)
return 0;
 #endif
diff --git a/arch/arm/mach-at91/spl.c b/arch/arm/mach-at91/spl.c
index aaa5eec..27a405a 100644
--- a/arch/arm/mach-at91/spl.c
+++ b/arch/arm/mach-at91/spl.c
@@ -29,7 +29,7 @@ u32 spl_boot_device(void)
return BOOT_DEVICE_MMC1;
 #elif CONFIG_SYS_USE_NANDFLASH
return BOOT_DEVICE_NAND;
-#elif CONFIG_SYS_USE_SERIALFLASH
+#elif CONFIG_SYS_USE_SERIALFLASH || CONFIG_SYS_USE_SPIFLASH
return BOOT_DEVICE_SPI;
 #endif
return BOOT_DEVICE_NONE;
diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c
index af6fc0d..e28e568 100644
--- a/arch/arm/mach-at91/spl_at91.c
+++ b/arch/arm/mach-at91/spl_at91.c
@@ -115,9 +115,14 @@ void board_init_f(ulong dummy)
timer_init();
 
/* ena

[U-Boot] [PATCH v2 0/4] ARM: atmel: boards: enable SPL support

2015-03-26 Thread Bo Shen
This patch series enable SPL support for following boards:
  - at91sam9m10g45ek
- NAND flash boot support
- SD card boot support
  - at91sam9n12ek
- NAND flash boot support
- SPI flash boot support
  - at91sam9x5ek
- NAND flash boot support
- SPI flash boot support

Changes in v2:
  - Remove the meaningless prefix "+S:" in configuration file.

Bo Shen (4):
  ARM: atmel: arm926ejs: fix clock configuration
  ARM: atmel: at91sam9m10g45ek: enable spl support
  ARM: atmel: at91sam9x5ek: enable spl support
  ARM: atmel: at91sam9n12ek: enable spl support

 arch/arm/mach-at91/Kconfig  |  3 +
 arch/arm/mach-at91/Makefile |  2 +
 arch/arm/mach-at91/arm926ejs/clock.c| 54 +
 arch/arm/mach-at91/arm926ejs/u-boot-spl.lds | 48 +++
 arch/arm/mach-at91/include/mach/at91_pmc.h  |  6 +-
 arch/arm/mach-at91/include/mach/at91sam9x5.h| 10 
 arch/arm/mach-at91/mpddrc.c |  3 +-
 arch/arm/mach-at91/spl.c|  2 +-
 arch/arm/mach-at91/spl_at91.c   | 11 +++-
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80 +
 board/atmel/at91sam9n12ek/at91sam9n12ek.c   | 73 ++
 board/atmel/at91sam9x5ek/at91sam9x5ek.c | 74 +++
 configs/at91sam9m10g45ek_mmc_defconfig  |  1 +
 configs/at91sam9m10g45ek_nandflash_defconfig|  1 +
 configs/at91sam9n12ek_nandflash_defconfig   |  1 +
 configs/at91sam9n12ek_spiflash_defconfig|  1 +
 configs/at91sam9x5ek_nandflash_defconfig|  1 +
 configs/at91sam9x5ek_spiflash_defconfig |  1 +
 include/configs/at91sam9m10g45ek.h  | 58 ++
 include/configs/at91sam9n12ek.h | 58 +-
 include/configs/at91sam9x5ek.h  | 57 ++
 21 files changed, 513 insertions(+), 32 deletions(-)
 create mode 100644 arch/arm/mach-at91/arm926ejs/u-boot-spl.lds

-- 
2.3.3.220.g9ab698f

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


Re: [U-Boot] [PATCH v2] ARM: at91: at91sam9n12ek: save the environment to a fat file in MMC card

2015-03-24 Thread Bo Shen

Hi Josh,

On 03/24/2015 05:07 PM, Josh Wu wrote:

Insteading in mmc's raw sectors, this patch will save the environment
in a fat file (uboot.env) in mmc card's first FAT patition by default.

If you want to save in mmc's raw sectors, you only need to define
CONFIG_ENV_IS_IN_MMC.

Signed-off-by: Josh Wu 


Thanks for your patch. I think this one is better than v1.

Acked-by: Bo Shen 


---

Changes in v2:
- not remove the code to save env in mmc's raw sectors.
- we can define CONFIG_ENV_IS_IN_MMC to enable raw sectors saving.

  include/configs/at91sam9n12ek.h | 15 +--
  1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/configs/at91sam9n12ek.h b/include/configs/at91sam9n12ek.h
index f02fce9..058e0e4 100644
--- a/include/configs/at91sam9n12ek.h
+++ b/include/configs/at91sam9n12ek.h
@@ -201,11 +201,22 @@
  #else /* CONFIG_SYS_USE_MMC */

  /* bootstrap + u-boot + env + linux in mmc */
-#define CONFIG_ENV_IS_IN_MMC
-/* For FAT system, most cases it should be in the reserved sector */
+
+#ifdef CONFIG_ENV_IS_IN_MMC
+/* Use raw reserved sectors to save environment */
  #define CONFIG_ENV_OFFSET 0x2000
  #define CONFIG_ENV_SIZE   0x1000
  #define CONFIG_SYS_MMC_ENV_DEV0
+#else
+/* Use file in FAT file to save environment */
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE
+#define FAT_ENV_INTERFACE  "mmc"
+#define FAT_ENV_FILE   "uboot.env"
+#define FAT_ENV_DEVICE_AND_PART"0"
+#define CONFIG_ENV_SIZE0x4000
+#endif
+
  #define CONFIG_BOOTCOMMAND\
"setenv bootargs ${console} ${mtdparts} ${bootargs_mmc};" \
"fatload mmc 0:1 0x2100 dtb;" \



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: at91: at91sam9n12ek: save the environment to a fat file in MMC card

2015-03-24 Thread Bo Shen

Hi Josh,

On 03/24/2015 04:10 PM, Josh Wu wrote:

Insteading in mmc's raw sectors, this patch will save the environment
in a fat file (uboot.env) in mmc card's first FAT patition.

Signed-off-by: Josh Wu 


Thanks for your patch.

Acked-by: Bo Shen 


---

  include/configs/at91sam9n12ek.h | 11 ++-
  1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/configs/at91sam9n12ek.h b/include/configs/at91sam9n12ek.h
index f02fce9..94ba37c 100644
--- a/include/configs/at91sam9n12ek.h
+++ b/include/configs/at91sam9n12ek.h
@@ -201,11 +201,12 @@
  #else /* CONFIG_SYS_USE_MMC */

  /* bootstrap + u-boot + env + linux in mmc */
-#define CONFIG_ENV_IS_IN_MMC
-/* For FAT system, most cases it should be in the reserved sector */
-#define CONFIG_ENV_OFFSET  0x2000
-#define CONFIG_ENV_SIZE0x1000
-#define CONFIG_SYS_MMC_ENV_DEV 0
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE
+#define FAT_ENV_INTERFACE  "mmc"
+#define FAT_ENV_FILE   "uboot.env"
+#define FAT_ENV_DEVICE_AND_PART"0"
+#define CONFIG_ENV_SIZE0x4000
  #define CONFIG_BOOTCOMMAND\
"setenv bootargs ${console} ${mtdparts} ${bootargs_mmc};" \
"fatload mmc 0:1 0x2100 dtb;" \



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] question about software i2c multi instance

2015-03-23 Thread Bo Shen

Hi Przemyslaw Marczak,

On 03/23/2015 04:47 PM, Przemyslaw Marczak wrote:




Please look into the Trats2 board code in:

board/samsung/trats2/trats2.c lines 130-145
include/configs/trats2.h lines 180-185

It doesn't require i2c driver modifications. But anyway I recommend to
use the code of my patches, which Lukasz mentioned.


Thanks for your information. I will try this method.
Thanks again.


Best regards,
--
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marc...@samsung.com


Best Regards,
Bo shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] question about software i2c multi instance

2015-03-23 Thread Bo Shen

Hi Lukasz,

On 03/23/2015 04:28 PM, Lukasz Majewski wrote:

Hi Bo,


Hi Heiko,
After check the software i2c code, I found it can not support
multi instances, although it has I2C_SOFT_DECLARATIONS2,
I2C_SOFT_DECLARATIONS3, I2C_SOFT_DECLARATIONS4.
Because, when do GPIO operation, there is only one pair of
CONFIG_SOFT_I2C_GPIO_SCL and CONFIG_SOFT_I2C_GPIO_SDA.
So, if want to support multi instances, it needs to extend the
GPIO configuration for SCL/SDA, am I right?


Some time ago we had a similar problem with SW I2C code. Please look
into Samsung's trats board implementation.

However, such approach might be outdated, since Przemek is working on
porting this functionality to device model:

https://patchwork.ozlabs.org/patch/448460/


Thanks for your information.
Now, I just do it as following to make it work. For next step, I will 
try to switch to use DM.


--->8---
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index db9b402..b9cfbb8 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -126,6 +126,13 @@ DECLARE_GLOBAL_DATA_PTR;
 #define PRINTD(fmt,args...)
 #endif

+#ifdef I2C_READ_ADAP
+static int soft_i2c_read_sda(void)
+{
+   I2C_READ_ADAP;
+}
+#endif
+
 /*---
  * Local functions
  */
@@ -256,7 +263,11 @@ static int write_byte(uchar data)
I2C_SCL(1);
I2C_DELAY;
I2C_DELAY;
+#ifdef I2C_READ_ADAP
+   nack = soft_i2c_read_sda();
+#else
nack = I2C_READ;
+#endif
I2C_SCL(0);
I2C_DELAY;
I2C_ACTIVE;
@@ -286,7 +297,11 @@ static uchar read_byte(int ack)
I2C_SCL(1);
I2C_DELAY;
data <<= 1;
+#ifdef I2C_READ_ADAP
+   data |= soft_i2c_read_sda();
+#else
data |= I2C_READ;
+#endif
I2C_DELAY;
}
send_ack(ack);
---8<---

Thanks again.

Best Regards,
Bo Shen

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


Re: [U-Boot] question about software i2c multi instance

2015-03-22 Thread Bo Shen

Hi Heiko,

On 03/20/2015 06:10 PM, Heiko Schocher wrote:

Hello Bo,

Am 20.03.2015 10:44, schrieb Bo Shen:

Hi Heiko,
   After check the software i2c code, I found it can not support multi
instances, although it has I2C_SOFT_DECLARATIONS2,
I2C_SOFT_DECLARATIONS3, I2C_SOFT_DECLARATIONS4.
   Because, when do GPIO operation, there is only one pair of
CONFIG_SOFT_I2C_GPIO_SCL and CONFIG_SOFT_I2C_GPIO_SDA.
   So, if want to support multi instances, it needs to extend the GPIO
configuration for SCL/SDA, am I right?


Prefered way should be to use DM, Przemyslaw posted patches
for the soft-i2c driver, see
http://lists.denx.de/pipermail/u-boot/2015-March/207641.html

maybe you can try this?


Thanks for your information.
As I try to use the old version of U-Boot, it doesn't support DM well.


If not, you are right, you must define your own
I2C_SCL/I2C_SDA/I2C_READ/I2C_INIT
defines, for example:

#  define I2C_SCL(bit) \
 do { \
 switch(I2C_ADAP_HWNR) {
 case 0:

gpio_direction_output(CONFIG_SOFT_I2C_GPIO_SCL_0, bit); \
 break;
 case 1:

gpio_direction_output(CONFIG_SOFT_I2C_GPIO_SCL_1, bit); \
 break;
 [...]
 I2C_GPIO_SYNC; \
 } while (0)


For this, the I2C_SCL and I2C_SDA working, however for I2C_READ, it 
maybe need to modify the definition from micro to function, as the 
I2C_READ can not use do {} while.


Thanks again.


bye,
Heiko


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] question about software i2c multi instance

2015-03-20 Thread Bo Shen

Hi Heiko,
  After check the software i2c code, I found it can not support multi 
instances, although it has I2C_SOFT_DECLARATIONS2, 
I2C_SOFT_DECLARATIONS3, I2C_SOFT_DECLARATIONS4.
  Because, when do GPIO operation, there is only one pair of 
CONFIG_SOFT_I2C_GPIO_SCL and CONFIG_SOFT_I2C_GPIO_SDA.
  So, if want to support multi instances, it needs to extend the GPIO 
configuration for SCL/SDA, am I right?


  Thanks.

Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/4] ARM: atmel: arm926ejs: fix clock configuration

2015-03-17 Thread Bo Shen

Hi Heiko,

On 03/17/2015 03:45 PM, Heiko Schocher wrote:

Hello Bo,

Am 13.03.2015 10:19, schrieb Bo Shen:

Config MCKR according to the datasheet sequence, or else it
will cause the MCKR configuration failed.

Remove timeout checking for clock configuration, if configure
the clock failed, let the system hang while not run in wrong
clock configuration.

Signed-off-by: Bo Shen 
---

  arch/arm/mach-at91/arm926ejs/clock.c | 54
+++-
  1 file changed, 28 insertions(+), 26 deletions(-)


Tested on the corvus and taurus board.

Tested-by: Heiko Schocher 


Thanks.


diff --git a/arch/arm/mach-at91/arm926ejs/clock.c
b/arch/arm/mach-at91/arm926ejs/clock.c
index f363982..8d6934e 100644
--- a/arch/arm/mach-at91/arm926ejs/clock.c
+++ b/arch/arm/mach-at91/arm926ejs/clock.c
@@ -195,50 +195,52 @@ int at91_clock_init(unsigned long main_clock)
  void at91_plla_init(u32 pllar)
  {
  struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-int timeout = AT91_PLL_LOCK_TIMEOUT;

  writel(pllar, &pmc->pllar);
-while (!(readl(&pmc->sr) & (AT91_PMC_LOCKA | AT91_PMC_MCKRDY))) {
-timeout--;
-if (timeout == 0)
-break;
-}
+while (!(readl(&pmc->sr) & AT91_PMC_LOCKA))
+;


just hanging is maybe also bad ... could we hang with adding a

 if (timeout == 0) {
 debug("could not set PLL(A|B)\n");
 timeout = AT91_PLL_LOCK_TIMEOUT;
 }

Thinking about it ... have we setup here the debug uart already?
If not, forget my comment


Yes the uart is not ready. And one more thing, if the clock is not setup 
correctly, then the system will run in abnormal status. So, I remove the 
timeout check here.


Best Regards,
Bo Shen


bye,
Heiko

  }
  void at91_pllb_init(u32 pllbr)
  {
  struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-int timeout = AT91_PLL_LOCK_TIMEOUT;

  writel(pllbr, &pmc->pllbr);
-while (!(readl(&pmc->sr) & (AT91_PMC_LOCKB | AT91_PMC_MCKRDY))) {
-timeout--;
-if (timeout == 0)
-break;
-}
+while (!(readl(&pmc->sr) & AT91_PMC_LOCKB))
+;
  }

  void at91_mck_init(u32 mckr)
  {
  struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-int timeout = AT91_PLL_LOCK_TIMEOUT;
  u32 tmp;

  tmp = readl(&pmc->mckr);
-tmp &= ~(AT91_PMC_MCKR_PRES_MASK |
- AT91_PMC_MCKR_MDIV_MASK |
- AT91_PMC_MCKR_PLLADIV_MASK |
- AT91_PMC_MCKR_CSS_MASK);
-tmp |= mckr & (AT91_PMC_MCKR_PRES_MASK |
-   AT91_PMC_MCKR_MDIV_MASK |
-   AT91_PMC_MCKR_PLLADIV_MASK |
-   AT91_PMC_MCKR_CSS_MASK);
+tmp &= ~AT91_PMC_MCKR_PRES_MASK;
+tmp |= mckr & AT91_PMC_MCKR_PRES_MASK;
  writel(tmp, &pmc->mckr);
+while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+;

-while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY)) {
-timeout--;
-if (timeout == 0)
-break;
-}
+tmp = readl(&pmc->mckr);
+tmp &= ~AT91_PMC_MCKR_MDIV_MASK;
+tmp |= mckr & AT91_PMC_MCKR_MDIV_MASK;
+writel(tmp, &pmc->mckr);
+while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+;
+
+tmp = readl(&pmc->mckr);
+tmp &= ~AT91_PMC_MCKR_PLLADIV_MASK;
+tmp |= mckr & AT91_PMC_MCKR_PLLADIV_MASK;
+writel(tmp, &pmc->mckr);
+while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+;
+
+tmp = readl(&pmc->mckr);
+tmp &= ~AT91_PMC_MCKR_CSS_MASK;
+tmp |= mckr & AT91_PMC_MCKR_CSS_MASK;
+writel(tmp, &pmc->mckr);
+while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+;
  }

  void at91_periph_clk_enable(int id)





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


Re: [U-Boot] [PATCH 2/4] ARM: atmel: at91sam9m10g45ek: enable spl support

2015-03-13 Thread Bo Shen

Hi Masahiro,

On 03/13/2015 05:34 PM, Masahiro Yamada wrote:

Hi Bo,


2015-03-13 18:19 GMT+09:00 Bo Shen :


diff --git a/configs/at91sam9m10g45ek_mmc_defconfig 
b/configs/at91sam9m10g45ek_mmc_defconfig
index 6949d3a..84d3133 100644
--- a/configs/at91sam9m10g45ek_mmc_defconfig
+++ b/configs/at91sam9m10g45ek_mmc_defconfig
@@ -1,4 +1,5 @@
+CONFIG_SPL=y
  CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9M10G45,SYS_USE_MMC"
-CONFIG_ARM=y
-CONFIG_ARCH_AT91=y
-CONFIG_TARGET_AT91SAM9M10G45EK=y
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_AT91=y
++S:CONFIG_TARGET_AT91SAM9M10G45EK=y


I abolished the prefixes such "+S".
Now they are harmless, but meaningless.

I am ripping off all of them:
http://patchwork.ozlabs.org/patch/449347/

Could you please not change those three lines?


Thanks.

I will remove this change in next version.
Thanks again.

Best Regards,
Bo Shen

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


[U-Boot] [PATCH 4/4] ARM: atmel: at91sam9n12ek: enable spl support

2015-03-13 Thread Bo Shen
Enable SPL support for at91sam9n12ek boards, now it supports
boot up from NAND flash, serial flash.

Signed-off-by: Bo Shen 
---

 arch/arm/mach-at91/Kconfig |  1 +
 arch/arm/mach-at91/Makefile|  1 +
 arch/arm/mach-at91/include/mach/at91_pmc.h |  4 +-
 arch/arm/mach-at91/mpddrc.c|  2 +-
 arch/arm/mach-at91/spl_at91.c  |  2 +-
 board/atmel/at91sam9n12ek/at91sam9n12ek.c  | 73 ++
 configs/at91sam9n12ek_nandflash_defconfig  |  7 +--
 configs/at91sam9n12ek_spiflash_defconfig   |  7 +--
 include/configs/at91sam9n12ek.h| 58 +++-
 9 files changed, 144 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index bdf87f9..30c4e17 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -75,6 +75,7 @@ config TARGET_PM9G45
 config TARGET_AT91SAM9N12EK
bool "Atmel AT91SAM9N12-EK board"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_AT91SAM9RLEK
bool "Atmel at91sam9rl reference board"
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index ba83616..0d3ee48 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_AT91_WANTS_COMMON_PHY) += phy.o
 ifneq ($(CONFIG_SPL_BUILD),)
 obj-$(CONFIG_AT91SAM9G20) += sdram.o spl_at91.o
 obj-$(CONFIG_AT91SAM9M10G45) += mpddrc.o spl_at91.o
+obj-$(CONFIG_AT91SAM9N12) += mpddrc.o spl_at91.o
 obj-$(CONFIG_AT91SAM9X5) += mpddrc.o spl_at91.o
 obj-$(CONFIG_SAMA5D3) += mpddrc.o spl_atmel.o
 obj-$(CONFIG_SAMA5D4) += mpddrc.o spl_atmel.o
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index c903260..ebb7dec 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -98,7 +98,7 @@ typedef struct at91_pmc {
 #define AT91_PMC_MCKR_CSS_MASK 0x0003
 
 #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
-   defined(CONFIG_AT91SAM9X5)
+   defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)
 #define AT91_PMC_MCKR_PRES_1   0x
 #define AT91_PMC_MCKR_PRES_2   0x0010
 #define AT91_PMC_MCKR_PRES_4   0x0020
@@ -128,7 +128,7 @@ typedef struct at91_pmc {
 #define AT91_PMC_MCKR_MDIV_1   0x
 #define AT91_PMC_MCKR_MDIV_2   0x0100
 #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
-   defined(CONFIG_AT91SAM9X5)
+   defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)
 #define AT91_PMC_MCKR_MDIV_3   0x0300
 #endif
 #define AT91_PMC_MCKR_MDIV_4   0x0200
diff --git a/arch/arm/mach-at91/mpddrc.c b/arch/arm/mach-at91/mpddrc.c
index 24d5fcd..e2b6a49 100644
--- a/arch/arm/mach-at91/mpddrc.c
+++ b/arch/arm/mach-at91/mpddrc.c
@@ -20,7 +20,7 @@ static inline void atmel_mpddr_op(int mode, u32 ram_address)
 static int ddr2_decodtype_is_seq(u32 cr)
 {
 #if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
-   defined(CONFIG_AT91SAM9X5)
+   defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)
if (cr & ATMEL_MPDDRC_CR_DECOD_INTERLEAVED)
return 0;
 #endif
diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c
index e28e568..a79a9dc 100644
--- a/arch/arm/mach-at91/spl_at91.c
+++ b/arch/arm/mach-at91/spl_at91.c
@@ -115,7 +115,7 @@ void board_init_f(ulong dummy)
timer_init();
 
/* enable clocks for all PIOs */
-#ifdef CONFIG_AT91SAM9X5
+#if defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)
at91_periph_clk_enable(ATMEL_ID_PIOAB);
at91_periph_clk_enable(ATMEL_ID_PIOCD);
 #else
diff --git a/board/atmel/at91sam9n12ek/at91sam9n12ek.c 
b/board/atmel/at91sam9n12ek/at91sam9n12ek.c
index 9adc992..4f46a03 100644
--- a/board/atmel/at91sam9n12ek/at91sam9n12ek.c
+++ b/board/atmel/at91sam9n12ek/at91sam9n12ek.c
@@ -257,3 +257,76 @@ int dram_init(void)
CONFIG_SYS_SDRAM_SIZE);
return 0;
 }
+
+#if defined(CONFIG_SPL_BUILD)
+#include 
+#include 
+
+void at91_spl_board_init(void)
+{
+#ifdef CONFIG_SYS_USE_MMC
+   at91_mci_hw_init();
+#elif CONFIG_SYS_USE_NANDFLASH
+   at91sam9n12ek_nand_hw_init();
+#elif CONFIG_SYS_USE_SPIFLASH
+   at91_spi0_hw_init(1 << 4);
+#endif
+}
+
+#include 
+static void ddr2_conf(struct atmel_mpddr *ddr2)
+{
+   ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+   ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+   ATMEL_MPDDRC_CR_NR_ROW_13 |
+   ATMEL_MPDDRC_CR_CAS_DDR_CAS3 |
+   ATMEL_MPDDRC_CR_NB_8BANKS |
+   ATMEL_MPDDRC_CR_DECOD_INTERLEAVED);
+
+   ddr2->rtr = 0x411;
+
+   ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |
+ 2 << A

[U-Boot] [PATCH 3/4] ARM: atmel: at91sam9x5ek: enable spl support

2015-03-13 Thread Bo Shen
Enable SPL support for at91sam9x5ek board. Now, it supports
boot up from NAND flash and SPI flash.

Signed-off-by: Bo Shen 
---

 arch/arm/mach-at91/Kconfig   |  1 +
 arch/arm/mach-at91/Makefile  |  1 +
 arch/arm/mach-at91/include/mach/at91_pmc.h   |  6 ++-
 arch/arm/mach-at91/include/mach/at91sam9x5.h | 10 
 arch/arm/mach-at91/mpddrc.c  |  3 +-
 arch/arm/mach-at91/spl.c |  2 +-
 arch/arm/mach-at91/spl_at91.c|  5 ++
 board/atmel/at91sam9x5ek/at91sam9x5ek.c  | 74 
 configs/at91sam9x5ek_nandflash_defconfig |  7 +--
 configs/at91sam9x5ek_spiflash_defconfig  |  7 +--
 include/configs/at91sam9x5ek.h   | 57 +
 11 files changed, 163 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 25da926..bdf87f9 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -83,6 +83,7 @@ config TARGET_AT91SAM9RLEK
 config TARGET_AT91SAM9X5EK
bool "Atmel AT91SAM9X5-EK board"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_SAMA5D3_XPLAINED
bool "SAMA5D3 Xplained board"
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index e596ba6..ba83616 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_AT91_WANTS_COMMON_PHY) += phy.o
 ifneq ($(CONFIG_SPL_BUILD),)
 obj-$(CONFIG_AT91SAM9G20) += sdram.o spl_at91.o
 obj-$(CONFIG_AT91SAM9M10G45) += mpddrc.o spl_at91.o
+obj-$(CONFIG_AT91SAM9X5) += mpddrc.o spl_at91.o
 obj-$(CONFIG_SAMA5D3) += mpddrc.o spl_atmel.o
 obj-$(CONFIG_SAMA5D4) += mpddrc.o spl_atmel.o
 obj-y += spl.o
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index 65691ab..c903260 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -97,7 +97,8 @@ typedef struct at91_pmc {
 #define AT91_PMC_MCKR_CSS_PLLB 0x0003
 #define AT91_PMC_MCKR_CSS_MASK 0x0003
 
-#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4)
+#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
+   defined(CONFIG_AT91SAM9X5)
 #define AT91_PMC_MCKR_PRES_1   0x
 #define AT91_PMC_MCKR_PRES_2   0x0010
 #define AT91_PMC_MCKR_PRES_4   0x0020
@@ -126,7 +127,8 @@ typedef struct at91_pmc {
 #else
 #define AT91_PMC_MCKR_MDIV_1   0x
 #define AT91_PMC_MCKR_MDIV_2   0x0100
-#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4)
+#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
+   defined(CONFIG_AT91SAM9X5)
 #define AT91_PMC_MCKR_MDIV_3   0x0300
 #endif
 #define AT91_PMC_MCKR_MDIV_4   0x0200
diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5.h 
b/arch/arm/mach-at91/include/mach/at91sam9x5.h
index 36a5cdf..d18c936 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9x5.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9x5.h
@@ -124,6 +124,16 @@
 #define ATMEL_BASE_EHCI0x0070 /* USB Host controller 
(EHCI) */
 #endif
 
+/*
+ * External memory
+ */
+#define ATMEL_BASE_CS0 0x1000
+#define ATMEL_BASE_CS1 0x2000
+#define ATMEL_BASE_CS2 0x3000
+#define ATMEL_BASE_CS3 0x4000
+#define ATMEL_BASE_CS4 0x5000
+#define ATMEL_BASE_CS5 0x6000
+
 /* 9x5 series chip id definitions */
 #define ARCH_ID_AT91SAM9X5 0x819a05a0
 #define ARCH_ID_VERSION_MASK   0x1f
diff --git a/arch/arm/mach-at91/mpddrc.c b/arch/arm/mach-at91/mpddrc.c
index beec13d..24d5fcd 100644
--- a/arch/arm/mach-at91/mpddrc.c
+++ b/arch/arm/mach-at91/mpddrc.c
@@ -19,7 +19,8 @@ static inline void atmel_mpddr_op(int mode, u32 ram_address)
 
 static int ddr2_decodtype_is_seq(u32 cr)
 {
-#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4)
+#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4) || \
+   defined(CONFIG_AT91SAM9X5)
if (cr & ATMEL_MPDDRC_CR_DECOD_INTERLEAVED)
return 0;
 #endif
diff --git a/arch/arm/mach-at91/spl.c b/arch/arm/mach-at91/spl.c
index aaa5eec..27a405a 100644
--- a/arch/arm/mach-at91/spl.c
+++ b/arch/arm/mach-at91/spl.c
@@ -29,7 +29,7 @@ u32 spl_boot_device(void)
return BOOT_DEVICE_MMC1;
 #elif CONFIG_SYS_USE_NANDFLASH
return BOOT_DEVICE_NAND;
-#elif CONFIG_SYS_USE_SERIALFLASH
+#elif CONFIG_SYS_USE_SERIALFLASH || CONFIG_SYS_USE_SPIFLASH
return BOOT_DEVICE_SPI;
 #endif
return BOOT_DEVICE_NONE;
diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c
index af6fc0d..e28e568 100644
--- a/arch/arm/mach-at91/spl_at91.c
+++ b/arch/arm/mach-at91/spl_at91.c
@@ -115,9 +115,14 @@ void board_init_f(ulong dummy)
timer_init();
 
/* enable clocks for all PIOs */
+#ifdef CONFIG_AT91SAM9X5
+   at91_periph_c

[U-Boot] [PATCH 1/4] ARM: atmel: arm926ejs: fix clock configuration

2015-03-13 Thread Bo Shen
Config MCKR according to the datasheet sequence, or else it
will cause the MCKR configuration failed.

Remove timeout checking for clock configuration, if configure
the clock failed, let the system hang while not run in wrong
clock configuration.

Signed-off-by: Bo Shen 
---

 arch/arm/mach-at91/arm926ejs/clock.c | 54 +++-
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-at91/arm926ejs/clock.c 
b/arch/arm/mach-at91/arm926ejs/clock.c
index f363982..8d6934e 100644
--- a/arch/arm/mach-at91/arm926ejs/clock.c
+++ b/arch/arm/mach-at91/arm926ejs/clock.c
@@ -195,50 +195,52 @@ int at91_clock_init(unsigned long main_clock)
 void at91_plla_init(u32 pllar)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-   int timeout = AT91_PLL_LOCK_TIMEOUT;
 
writel(pllar, &pmc->pllar);
-   while (!(readl(&pmc->sr) & (AT91_PMC_LOCKA | AT91_PMC_MCKRDY))) {
-   timeout--;
-   if (timeout == 0)
-   break;
-   }
+   while (!(readl(&pmc->sr) & AT91_PMC_LOCKA))
+   ;
 }
 void at91_pllb_init(u32 pllbr)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-   int timeout = AT91_PLL_LOCK_TIMEOUT;
 
writel(pllbr, &pmc->pllbr);
-   while (!(readl(&pmc->sr) & (AT91_PMC_LOCKB | AT91_PMC_MCKRDY))) {
-   timeout--;
-   if (timeout == 0)
-   break;
-   }
+   while (!(readl(&pmc->sr) & AT91_PMC_LOCKB))
+   ;
 }
 
 void at91_mck_init(u32 mckr)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-   int timeout = AT91_PLL_LOCK_TIMEOUT;
u32 tmp;
 
tmp = readl(&pmc->mckr);
-   tmp &= ~(AT91_PMC_MCKR_PRES_MASK |
-AT91_PMC_MCKR_MDIV_MASK |
-AT91_PMC_MCKR_PLLADIV_MASK |
-AT91_PMC_MCKR_CSS_MASK);
-   tmp |= mckr & (AT91_PMC_MCKR_PRES_MASK |
-  AT91_PMC_MCKR_MDIV_MASK |
-  AT91_PMC_MCKR_PLLADIV_MASK |
-  AT91_PMC_MCKR_CSS_MASK);
+   tmp &= ~AT91_PMC_MCKR_PRES_MASK;
+   tmp |= mckr & AT91_PMC_MCKR_PRES_MASK;
writel(tmp, &pmc->mckr);
+   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+   ;
 
-   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY)) {
-   timeout--;
-   if (timeout == 0)
-   break;
-   }
+   tmp = readl(&pmc->mckr);
+   tmp &= ~AT91_PMC_MCKR_MDIV_MASK;
+   tmp |= mckr & AT91_PMC_MCKR_MDIV_MASK;
+   writel(tmp, &pmc->mckr);
+   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+   ;
+
+   tmp = readl(&pmc->mckr);
+   tmp &= ~AT91_PMC_MCKR_PLLADIV_MASK;
+   tmp |= mckr & AT91_PMC_MCKR_PLLADIV_MASK;
+   writel(tmp, &pmc->mckr);
+   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+   ;
+
+   tmp = readl(&pmc->mckr);
+   tmp &= ~AT91_PMC_MCKR_CSS_MASK;
+   tmp |= mckr & AT91_PMC_MCKR_CSS_MASK;
+   writel(tmp, &pmc->mckr);
+   while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+   ;
 }
 
 void at91_periph_clk_enable(int id)
-- 
2.3.0

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


[U-Boot] [PATCH 0/4] ARM: atmel: boards: enable SPL support

2015-03-13 Thread Bo Shen
This patch series enable SPL support for following boards:
  - at91sam9m10g45ek
- NAND flash boot support
- SD card boot support
  - at91sam9n12ek
- NAND flash boot support
- SPI flash boot support
  - at91sam9x5ek
- NAND flash boot support
- SPI flash boot support


Bo Shen (4):
  ARM: atmel: arm926ejs: fix clock configuration
  ARM: atmel: at91sam9m10g45ek: enable spl support
  ARM: atmel: at91sam9x5ek: enable spl support
  ARM: atmel: at91sam9n12ek: enable spl support

 arch/arm/mach-at91/Kconfig  |  3 +
 arch/arm/mach-at91/Makefile |  2 +
 arch/arm/mach-at91/arm926ejs/clock.c| 54 +
 arch/arm/mach-at91/arm926ejs/u-boot-spl.lds | 48 +++
 arch/arm/mach-at91/include/mach/at91_pmc.h  |  6 +-
 arch/arm/mach-at91/include/mach/at91sam9x5.h| 10 
 arch/arm/mach-at91/mpddrc.c |  3 +-
 arch/arm/mach-at91/spl.c|  2 +-
 arch/arm/mach-at91/spl_at91.c   | 11 +++-
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80 +
 board/atmel/at91sam9n12ek/at91sam9n12ek.c   | 73 ++
 board/atmel/at91sam9x5ek/at91sam9x5ek.c | 74 +++
 configs/at91sam9m10g45ek_mmc_defconfig  |  7 ++-
 configs/at91sam9m10g45ek_nandflash_defconfig|  7 ++-
 configs/at91sam9n12ek_nandflash_defconfig   |  7 ++-
 configs/at91sam9n12ek_spiflash_defconfig|  7 ++-
 configs/at91sam9x5ek_nandflash_defconfig|  7 ++-
 configs/at91sam9x5ek_spiflash_defconfig |  7 ++-
 include/configs/at91sam9m10g45ek.h  | 58 ++
 include/configs/at91sam9n12ek.h | 58 +-
 include/configs/at91sam9x5ek.h  | 57 ++
 21 files changed, 531 insertions(+), 50 deletions(-)
 create mode 100644 arch/arm/mach-at91/arm926ejs/u-boot-spl.lds

-- 
2.3.0

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


[U-Boot] [PATCH 2/4] ARM: atmel: at91sam9m10g45ek: enable spl support

2015-03-13 Thread Bo Shen
Supports boot up from NAND flash with software ECC eanbled.
And supports boot up from SD/MMC card with FAT file system.

As the boot from SD/MMC card with FAT file system, the BSS
segment is too big to fit into SRAM, so, use the lds to put
it into SDRAM.

Signed-off-by: Bo Shen 
---

 arch/arm/mach-at91/Kconfig  |  1 +
 arch/arm/mach-at91/arm926ejs/u-boot-spl.lds | 48 +++
 arch/arm/mach-at91/spl_at91.c   |  6 +-
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80 +
 configs/at91sam9m10g45ek_mmc_defconfig  |  7 ++-
 configs/at91sam9m10g45ek_nandflash_defconfig|  7 ++-
 include/configs/at91sam9m10g45ek.h  | 58 ++
 7 files changed, 200 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/mach-at91/arm926ejs/u-boot-spl.lds

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 30945c1..25da926 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -66,6 +66,7 @@ config TARGET_STAMP9G20
 config TARGET_AT91SAM9M10G45EK
bool "Atmel AT91SAM9M10G45-EK board"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_PM9G45
bool "Ronetix pm9g45 board"
diff --git a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds 
b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
new file mode 100644
index 000..acadd1d
--- /dev/null
+++ b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *   Bo Shen 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \
+   LENGTH = CONFIG_SPL_MAX_SIZE }
+MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
+   LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+   .text  :
+   {
+   __start = .;
+   *(.vectors)
+   arch/arm/cpu/arm926ejs/start.o  (.text*)
+   *(.text*)
+   } >.sram
+
+   . = ALIGN(4);
+   .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
+
+   . = ALIGN(4);
+   .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
+
+   . = ALIGN(4);
+   __image_copy_end = .;
+
+   .end :
+   {
+   *(.__end)
+   } >.sram
+
+   .bss :
+   {
+   . = ALIGN(4);
+   __bss_start = .;
+   *(.bss*)
+   . = ALIGN(4);
+   __bss_end = .;
+   } >.sdram
+}
diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c
index 89f588b..af6fc0d 100644
--- a/arch/arm/mach-at91/spl_at91.c
+++ b/arch/arm/mach-at91/spl_at91.c
@@ -71,7 +71,11 @@ void __weak at91_spl_board_init(void)
 {
 }
 
-void spl_board_init(void)
+void __weak spl_board_init(void)
+{
+}
+
+void board_init_f(ulong dummy)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
diff --git a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c 
b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
index b807ef9..4289179 100644
--- a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
+++ b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -15,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
@@ -71,6 +73,84 @@ void at91sam9m10g45ek_nand_hw_init(void)
 }
 #endif
 
+#if defined(CONFIG_SPL_BUILD)
+#include 
+#include 
+
+void at91_spl_board_init(void)
+{
+   /*
+* On the at91sam9m10g45ek board, the chip wm9711 stays in the
+* test mode, so it needs do some action to exit test mode.
+*/
+   at91_periph_clk_enable(ATMEL_ID_PIODE);
+   at91_set_gpio_output(AT91_PIN_PD7, 0);
+   at91_set_gpio_output(AT91_PIN_PD8, 0);
+   at91_set_pio_pullup(AT91_PIO_PORTD, 7, 1);
+   at91_set_pio_pullup(AT91_PIO_PORTD, 8, 1);
+
+#ifdef CONFIG_SYS_USE_MMC
+   at91_mci_hw_init();
+#elif CONFIG_SYS_USE_NANDFLASH
+   at91sam9m10g45ek_nand_hw_init();
+#endif
+}
+
+#include 
+static void ddr2_conf(struct atmel_mpddr *ddr2)
+{
+   ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+   ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+   ATMEL_MPDDRC_CR_NR_ROW_14 |
+   ATMEL_MPDDRC_CR_DQMS_SHARED |
+   ATMEL_MPDDRC_CR_CAS_DDR_CAS3);
+
+   ddr2->rtr = 0x24b;
+
+   ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |/* 6*7.5 = 45 ns */
+ 2 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET |/* 2*7.5 = 15 ns */
+ 2 << ATMEL_MPDDRC_TPR0_TWR_OFFSET | /* 2*7.5 = 15 ns */
+ 8 << ATMEL_MPDDRC_TPR0_TRC_OFFSET | /* 8*7.5 = 6

[U-Boot] [RFC PATCH] PMIC: add act8865 series support

2015-03-12 Thread Bo Shen
Add Active-Semi act8865 series PMU support.

Signed-off-by: Bo Shen 
---

 drivers/power/Makefile  |   1 +
 drivers/power/act8865.c | 104 
 include/act8865.h   |  54 +
 3 files changed, 159 insertions(+)
 create mode 100644 drivers/power/act8865.c
 create mode 100644 include/act8865.h

diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 2145652..0c2a8cf 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+obj-$(CONFIG_ACT8865_POWER)+= act8865.o
 obj-$(CONFIG_AS3722_POWER) += as3722.o
 obj-$(CONFIG_AXP152_POWER) += axp152.o
 obj-$(CONFIG_AXP209_POWER) += axp209.o
diff --git a/drivers/power/act8865.c b/drivers/power/act8865.c
new file mode 100644
index 000..c36f7bd
--- /dev/null
+++ b/drivers/power/act8865.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *   Bo Shen 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+static int act8865_read(u32 reg, uchar *val)
+{
+   return i2c_read(ACT8865_I2C_ADDR, reg, 1, val, 1);
+}
+
+static int act8865_write(u32 reg, uchar val)
+{
+   return i2c_write(ACT8865_I2C_ADDR, reg, 1, &val, 1);
+}
+
+int act8865_disable_i2c_interface(void)
+{
+   uchar val;
+
+   /* Check the I2C interface is disabled or not */
+   if (act8865_read(ACT8865_SYS_CONTROL0, &val)) {
+   debug("ACT8865: i2c interface has been disabled\n");
+   return 0;
+   }
+
+   /*
+* As the ACT8865 don't have ID register, so we try one by one
+* to disable the exist chips (303, 304, 305) in this series.
+*/
+
+   /* Try to disable ACT8865QI303 */
+   act8865_write(0x0B, 0xE9);
+   act8865_write(0x02, 0x07);
+   if (act8865_write(0x03, 0x01)) {
+   debug("ACT8865: subtype 303 has been disabled\n");
+   return 0;
+   }
+
+   /* Try to disable ACT8865QI304 */
+   act8865_write(0x0B, 0xEE);
+   act8865_write(0x02, 0x07);
+   if (act8865_write(0x03, 0x01)) {
+   debug("ACT8865: subtype 304 has been disabled\n");
+   return 0;
+   }
+
+   /* Try to disable ACT8865QI305 */
+   act8865_write(0x0B, 0xEE);
+   act8865_write(0x02, 0x07);
+   if (act8865_write(0x03, 0x01)) {
+   debug("ACT8865: subtype 305 has been disabled\n");
+   return 0;
+   }
+
+   debug("ACT8865: the chip can not be disabled\n");
+
+   return 0;
+}
+
+int act8865_enable_ldo_output(enum act8865_ldo ldo, enum act8865_volt volt)
+{
+   u32 conf_reg, ctrl_reg;
+   uchar val;
+
+   switch (ldo) {
+   case ACT8865_LDO_REG4:
+   conf_reg = ACT8865_REG4_CONFIG0;
+   ctrl_reg = ACT8865_REG4_CONTROL;
+   break;
+
+   case ACT8865_LDO_REG5:
+   conf_reg = ACT8865_REG5_CONFIG0;
+   ctrl_reg = ACT8865_REG5_CONTROL;
+   break;
+
+   case ACT8865_LDO_REG6:
+   conf_reg = ACT8865_REG6_CONFIG0;
+   ctrl_reg = ACT8865_REG6_CONTROL;
+   break;
+
+   case ACT8865_LDO_REG7:
+   conf_reg = ACT8865_REG7_CONFIG0;
+   ctrl_reg = ACT8865_REG7_CONTROL;
+   break;
+   default:
+   error("ACT8865: unsupported LDO\n");
+   return -1;
+   }
+
+   /* Set the LDO output voltage */
+   act8865_write(conf_reg, 0x18);
+   /* Enable the LDO */
+   act8865_read(ctrl_reg, &val);
+   val |= ACT8865_OUTPUT_ENABLE;
+   act8865_write(ctrl_reg, val);
+
+   return 0;
+}
diff --git a/include/act8865.h b/include/act8865.h
new file mode 100644
index 000..f6053ac
--- /dev/null
+++ b/include/act8865.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *   Bo Shen 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#define ACT8865_SYS_CONTROL0   0x00
+#define ACT8865_SYS_CONTROL1   0x01
+
+#define ACT8865_REG1_CONFIG0   0x20
+#define ACT8865_REG1_CONFIG1   0x21
+#define ACT8865_REG1_CONTROL   0x22
+
+#define ACT8865_REG2_CONFIG0   0x30
+#define ACT8865_REG2_CONFIG1   0x31
+#define ACT8865_REG2_CONTROL   0x32
+
+#define ACT8865_REG3_CONFIG0   0x40
+#define ACT8865_REG3_CONFIG1   0x41
+#define ACT8865_REG3_CONTROL   0x42
+
+#define ACT8865_REG4_CONFIG0   0x50
+#define ACT8865_REG4_CONTROL   0x51
+
+#define ACT8865_REG5_CONFIG0   0x54
+#define ACT8865_REG5_CONTROL   0x55
+
+#define ACT8865_REG6_CONFIG0   0x60
+#define ACT8865_REG6_CONTROL   0x61
+
+#define ACT8865_REG7_CONFIG0   0x64
+#define ACT8865_REG7_CONTROL   0x65
+
+#define ACT8865_OUTPUT_ENABLE  (0x01 << 7)
+
+#define ACT8865_I2C_ADDR   0x5B
+
+enum act8865_ldo {
+   ACT8865_LDO_REG4 = 4,
+   ACT8865_LDO

[U-Boot] [PATCH] ARM: atmel: sama5d4: set non-secured for peripherals

2015-03-03 Thread Bo Shen
When access the programmable secure peripherals address space,
it needs set them to non-secured.

Signed-off-by: Bo Shen 
---

 arch/arm/mach-at91/armv7/sama5d4_devices.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/mach-at91/armv7/sama5d4_devices.c 
b/arch/arm/mach-at91/armv7/sama5d4_devices.c
index ef39cb7..76301d6 100644
--- a/arch/arm/mach-at91/armv7/sama5d4_devices.c
+++ b/arch/arm/mach-at91/armv7/sama5d4_devices.c
@@ -75,6 +75,15 @@ void matrix_init(void)
writel(0x0001, &h32mx->sassr[4]);
writel(0x0001, &h32mx->srtsr[4]);
 
+   /* Configure Programmable Security peripherals on matrix 64 */
+   writel(readl(&h64mx->spselr[0]) | 0x0008, &h64mx->spselr[0]);
+   writel(readl(&h64mx->spselr[1]) | 0x0018, &h64mx->spselr[1]);
+   writel(readl(&h64mx->spselr[2]) | 0x0008, &h64mx->spselr[2]);
+
+   /* Configure Programmable Security peripherals on matrix 32 */
+   writel(readl(&h32mx->spselr[0]) | 0xFFC0, &h32mx->spselr[0]);
+   writel(readl(&h32mx->spselr[1]) | 0x60E3, &h32mx->spselr[1]);
+
/* Enable the write protect */
writel(ATMEL_MATRIX_WPMR_WPKEY | ATMEL_MATRIX_WPMR_WPEN, &h64mx->wpmr);
writel(ATMEL_MATRIX_WPMR_WPKEY | ATMEL_MATRIX_WPMR_WPEN, &h32mx->wpmr);
-- 
2.3.0

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


[U-Boot] [PATCH] Net: macb: reset GBE bit when fallback checking

2015-03-03 Thread Bo Shen
If the GBE bit is set, when do next time autonegotiation,
if the result is not 1000Mbps, it will fallback to 100Mbps
checking. So, we need to clear the GBE bit.

Signed-off-by: Bo Shen 
---

 drivers/net/macb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 9c2ff48..170ff06 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -515,7 +515,7 @@ static int macb_phy_init(struct macb_device *macb)
   lpa);
 
ncfgr = macb_readl(macb, NCFGR);
-   ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
+   ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD) | GEM_BIT(GBE));
if (speed)
ncfgr |= MACB_BIT(SPD);
if (duplex)
-- 
2.3.0

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


[U-Boot] [PATCH 2/2] ARM: atmel: armv7: move spl lds to armv7 directory

2015-03-03 Thread Bo Shen
As the u-boot-spl.lds is used only for armv7 SoCs (includes
sama5d3 and sama5d4), so move it to armv7 directory.

Signed-off-by: Bo Shen 
---

 arch/arm/mach-at91/{ => armv7}/u-boot-spl.lds | 0
 include/configs/sama5d3_xplained.h| 2 +-
 include/configs/sama5d3xek.h  | 2 +-
 include/configs/sama5d4_xplained.h| 2 +-
 include/configs/sama5d4ek.h   | 2 +-
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename arch/arm/mach-at91/{ => armv7}/u-boot-spl.lds (100%)

diff --git a/arch/arm/mach-at91/u-boot-spl.lds 
b/arch/arm/mach-at91/armv7/u-boot-spl.lds
similarity index 100%
rename from arch/arm/mach-at91/u-boot-spl.lds
rename to arch/arm/mach-at91/armv7/u-boot-spl.lds
diff --git a/include/configs/sama5d3_xplained.h 
b/include/configs/sama5d3_xplained.h
index 5dab61d..c82728e 100644
--- a/include/configs/sama5d3_xplained.h
+++ b/include/configs/sama5d3_xplained.h
@@ -227,7 +227,7 @@
 #define CONFIG_SYS_MONITOR_LEN (512 << 10)
 
 #ifdef CONFIG_SYS_USE_MMC
-#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/u-boot-spl.lds
+#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/armv7/u-boot-spl.lds
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
diff --git a/include/configs/sama5d3xek.h b/include/configs/sama5d3xek.h
index bd288be..a99b559 100644
--- a/include/configs/sama5d3xek.h
+++ b/include/configs/sama5d3xek.h
@@ -274,7 +274,7 @@
 #define CONFIG_SYS_MONITOR_LEN (512 << 10)
 
 #ifdef CONFIG_SYS_USE_MMC
-#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/u-boot-spl.lds
+#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/armv7/u-boot-spl.lds
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
diff --git a/include/configs/sama5d4_xplained.h 
b/include/configs/sama5d4_xplained.h
index 349f1bc..4cb0761 100644
--- a/include/configs/sama5d4_xplained.h
+++ b/include/configs/sama5d4_xplained.h
@@ -246,7 +246,7 @@
 #define CONFIG_SYS_MONITOR_LEN (512 << 10)
 
 #ifdef CONFIG_SYS_USE_MMC
-#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/u-boot-spl.lds
+#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/armv7/u-boot-spl.lds
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
diff --git a/include/configs/sama5d4ek.h b/include/configs/sama5d4ek.h
index 4a16b8e..897d481 100644
--- a/include/configs/sama5d4ek.h
+++ b/include/configs/sama5d4ek.h
@@ -244,7 +244,7 @@
 #define CONFIG_SYS_MONITOR_LEN (512 << 10)
 
 #ifdef CONFIG_SYS_USE_MMC
-#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/u-boot-spl.lds
+#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/armv7/u-boot-spl.lds
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
-- 
2.3.0

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


[U-Boot] [PATCH 1/2] ARM: atmel: sama5d4 boards: fix spl lds location

2015-03-03 Thread Bo Shen
As the u-boot-spl.lds is moved to  directory.
So, correct the path for sama5d4 related boards.

Signed-off-by: Bo Shen 
---

 include/configs/sama5d4_xplained.h | 2 +-
 include/configs/sama5d4ek.h| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/sama5d4_xplained.h 
b/include/configs/sama5d4_xplained.h
index 6493d56..349f1bc 100644
--- a/include/configs/sama5d4_xplained.h
+++ b/include/configs/sama5d4_xplained.h
@@ -246,7 +246,7 @@
 #define CONFIG_SYS_MONITOR_LEN (512 << 10)
 
 #ifdef CONFIG_SYS_USE_MMC
-#define CONFIG_SPL_LDSCRIPTarch/arm/cpu/at91-common/u-boot-spl.lds
+#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/u-boot-spl.lds
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
diff --git a/include/configs/sama5d4ek.h b/include/configs/sama5d4ek.h
index 9e1b86a..4a16b8e 100644
--- a/include/configs/sama5d4ek.h
+++ b/include/configs/sama5d4ek.h
@@ -244,7 +244,7 @@
 #define CONFIG_SYS_MONITOR_LEN (512 << 10)
 
 #ifdef CONFIG_SYS_USE_MMC
-#define CONFIG_SPL_LDSCRIPTarch/arm/cpu/at91-common/u-boot-spl.lds
+#define CONFIG_SPL_LDSCRIPTarch/arm/mach-at91/u-boot-spl.lds
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
-- 
2.3.0

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


[U-Boot] [PATCH] ARM: atmel: sama5d4 xplained: enable mmc power

2015-02-12 Thread Bo Shen
Enable the power for MMC/SD port.

Signed-off-by: Bo Shen 
---

 board/atmel/sama5d4_xplained/sama5d4_xplained.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c 
b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
index bc2aa38..e7f225a 100644
--- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c
+++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
@@ -228,6 +228,9 @@ void sama5d4_xplained_mci1_hw_init(void)
 
 int board_mmc_init(bd_t *bis)
 {
+   /* Enable the power supply */
+   at91_set_pio_output(AT91_PIO_PORTE, 4, 0);
+
return atmel_mci_init((void *)ATMEL_BASE_MCI1);
 }
 #endif /* CONFIG_GENERIC_ATMEL_MCI */
-- 
2.3.0

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


Re: [U-Boot] [PATCH V2 02/13] lcd: split configuration_get_cmap

2015-02-08 Thread Bo Shen

Hi Nikita Kiryanov,

On 02/08/2015 07:35 PM, Nikita Kiryanov wrote:

Hi Bo,

On 02/04/2015 09:25 AM, Bo Shen wrote:

Hi Nikita Kiryanov,

On 02/03/2015 07:32 PM, Nikita Kiryanov wrote:


[..]


  #ifdef CONFIG_LCD_LOGO
  void bitmap_plot(int x, int y)
diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c
index 935ae42..0ce2370 100644
--- a/drivers/video/atmel_hlcdfb.c
+++ b/drivers/video/atmel_hlcdfb.c
@@ -13,6 +13,10 @@
  #include 
  #include 

+#if defined(CONFIG_LCD_LOGO)
+#include 
+#endif


I think we can include this file directly.


bmp_logo.h does not exist without CONFIG_LCD_LOGO.


Oh yes, my bad.




  /* configurable parameters */
  #define ATMEL_LCDC_CVAL_DEFAULT0xc8
  #define ATMEL_LCDC_DMA_BURST_LEN8
@@ -37,6 +41,15 @@ void lcd_setcolreg(ushort regno, ushort red,
ushort green, ushort blue)
  panel_info.mmio + ATMEL_LCDC_LUT(regno));
  }

+ushort *configuration_get_cmap(void)
+{
+#if defined(CONFIG_LCD_LOGO)
+return bmp_logo_palette;
+#else
+return NULL;
+#endif
+}


Here, I think no need to do the CONFIG_LCD_LOGO check, return
bmp_logo_palette directly, as it will be used when use bmp command in
8 bit mode. However, no hardware to test LCDC work or not in 8 bit
mode :(


This would make CONFIG_LCD_LOGO a prerequisite for this driver
(bmp_logo_palette does not exist otherwise), and I don't think it's
right to couple the two.


OK. let's keep this as is.




  void lcd_ctrl_init(void *lcdbase)
  {
  unsigned long value;
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 3cf008c..fa6a82c 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -29,6 +29,11 @@
  #define lcdc_readl(mmio, reg)__raw_readl((mmio)+(reg))
  #define lcdc_writel(mmio, reg, val)__raw_writel((val),
(mmio)+(reg))





Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] ARM: atmel: armv7: switch to use common timer functions

2015-02-04 Thread Bo Shen
The commit 8dfafdd (Introduce common timer functions), add common
timer functions, we can use them directly.

Signed-off-by: Bo Shen 
---

Changes in v2:
 - correct the timer register for sama5d4.

 arch/arm/cpu/armv7/at91/timer.c  | 61 
 arch/arm/include/asm/arch-at91/sama5d3.h |  3 ++
 arch/arm/include/asm/arch-at91/sama5d4.h |  3 ++
 3 files changed, 6 insertions(+), 61 deletions(-)

diff --git a/arch/arm/cpu/armv7/at91/timer.c b/arch/arm/cpu/armv7/at91/timer.c
index 19bf80b..a4a3817 100644
--- a/arch/arm/cpu/armv7/at91/timer.c
+++ b/arch/arm/cpu/armv7/at91/timer.c
@@ -36,22 +36,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define TIMER_LOAD_VAL 0xf
 
-static inline unsigned long long tick_to_time(unsigned long long tick)
-{
-   tick *= CONFIG_SYS_HZ;
-   do_div(tick, gd->arch.timer_rate_hz);
-
-   return tick;
-}
-
-static inline unsigned long long usec_to_tick(unsigned long long usec)
-{
-   usec *= gd->arch.timer_rate_hz;
-   do_div(usec, 100);
-
-   return usec;
-}
-
 /*
  * Use the PITC in full 32 bit incrementing mode
  */
@@ -67,55 +51,10 @@ int timer_init(void)
 
gd->arch.timer_rate_hz = get_pit_clk_rate() / 16;
 
-   gd->arch.tbu = 0;
-   gd->arch.tbl = 0;
-
return 0;
 }
 
 /*
- * Get the current 64 bit timer tick count
- */
-unsigned long long get_ticks(void)
-{
-   at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT;
-
-   ulong now = readl(&pit->piir);
-
-   /* increment tbu if tbl has rolled over */
-   if (now < gd->arch.tbl)
-   gd->arch.tbu++;
-   gd->arch.tbl = now;
-   return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
-}
-
-void __udelay(unsigned long usec)
-{
-   unsigned long long start;
-   ulong tmo;
-
-   start = get_ticks();/* get current timestamp */
-   tmo = usec_to_tick(usec);   /* convert usecs to ticks */
-   while ((get_ticks() - start) < tmo)
-   ;   /* loop till time has passed */
-}
-
-/*
- * get_timer(base) can be used to check for timeouts or
- * to measure elasped time relative to an event:
- *
- * ulong start_time = get_timer(0) sets start_time to the current
- * time value.
- * get_timer(start_time) returns the time elapsed since then.
- *
- * The time is used in CONFIG_SYS_HZ units!
- */
-ulong get_timer(ulong base)
-{
-   return tick_to_time(get_ticks()) - base;
-}
-
-/*
  * Return the number of timer ticks per second.
  */
 ulong get_tbclk(void)
diff --git a/arch/arm/include/asm/arch-at91/sama5d3.h 
b/arch/arm/include/asm/arch-at91/sama5d3.h
index 227ba80..b749cb3 100644
--- a/arch/arm/include/asm/arch-at91/sama5d3.h
+++ b/arch/arm/include/asm/arch-at91/sama5d3.h
@@ -189,6 +189,9 @@
 #define PIO_SCDR_DIV   0x3fff
 #define CPU_HAS_PCR
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfe3c
+
 /*
  * PMECC table in ROM
  */
diff --git a/arch/arm/include/asm/arch-at91/sama5d4.h 
b/arch/arm/include/asm/arch-at91/sama5d4.h
index d851568..716b253 100644
--- a/arch/arm/include/asm/arch-at91/sama5d4.h
+++ b/arch/arm/include/asm/arch-at91/sama5d4.h
@@ -191,6 +191,9 @@
 #define cpu_is_sama5d44()  (cpu_is_sama5d4() && \
(get_extension_chip_id() == ARCH_EXID_SAMA5D44))
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfc06863c
+
 /*
  * No PMECC Galois table in ROM
  */
-- 
2.3.0.rc0

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


Re: [U-Boot] [PATCH V2 00/13] common lcd refactor

2015-02-04 Thread Bo Shen

Hi Nikita Kiryanov,

On 02/03/2015 07:32 PM, Nikita Kiryanov wrote:

This series is part of my ongoing efforts to cleanup common/lcd code (and at
some point merge it with the CONFIG_VIDEO code).
This series focuses on eliminating platform specific #defines from lcd.c code,
and then adds a few platform independent code refactors and cleanups on top of
that. A small note on the series:

- The patch "lcd: split configuration_get_cmap" turned out to be a little
problematic: the goal was to move all platform specific code to the appropriate
lcd/fb drivers, and keep the generic case in lcd.c as a weak function.
This was not possible to do for configuration_get_cmap(), because the weak
version still has to compile even if it is overridden, and unfortunately the
generic case references panel_info, which is a struct that varies depending on
the configuration, and does not always have a cmap field. This demonstrated that
the visibility of panel_info should be reviewed, and that there might be a need
for some kind of lcd_generic driver.
Since this may warrant a series of its own, I opted to tentatively implement
the generic configuration_get_cmap() function in lcd.h as static function, and
plan to revisit it in the next series.

The end result was compile tested on arm and powerpc, and tested on cm_t35
(splash screen feature). Rebased on current mainline.

Changes in V2:
- Minor commit message changes (such as s/platform specific/platform-specific/,
   s/Raspberry Pi config file is updated to compile the new file/Raspberry Pi 
is updated to accommodate the changes/)
- patch 2: define configuration_get_cmap() prototype only once.

Cc: Bo Shen 
Cc: Simon Glass 
Cc: Anatolij Gustschin 

Nikita Kiryanov (13):
   lcd: move platform-specific structs to their own headers
   lcd: split configuration_get_cmap
   lcd: atmel: move atmel-specific fb_put_word to atmel_lcdfb
   lcd: mpc8xx: move mpc823-specific fb_put_byte to mpc8xx_lcd.c
   lcd: atmel: introduce lcd_logo_set_cmap
   lcd: mpc823: move mpc823-specific lcd_logo_set_cmap code to
 mpc8xx_lcd.c
   lcd: logo: move generic cmap setting to lcd_logo_set_cmap()
   lcd: introduce lcd_set_cmap
   lcd: remove unused includes
   lcd: various cleanups
   lcd: rename bitmap_plot to better represent its functionality
   lcd: dt: extract simplefb support
   lcd: split splash code into its own function


Tested OK on at91sam9g10ek, at91sam9x5ek boards.

Tested-by: Bo Shen 


  board/raspberrypi/rpi/rpi.c  |   1 +
  common/Makefile  |   1 +
  common/lcd.c | 358 ++-
  common/lcd_simplefb.c|  59 +++
  common/splash.c  |  16 ++
  drivers/video/atmel_hlcdfb.c |  13 ++
  drivers/video/atmel_lcdfb.c  |  51 ++
  drivers/video/exynos_fb.c|   9 ++
  drivers/video/mpc8xx_lcd.c   |  29 
  drivers/video/pxa_lcd.c  |   6 +
  include/atmel_lcd.h  |  38 +
  include/exynos_lcd.h |  81 ++
  include/fdt_simplefb.h   |  14 ++
  include/lcd.h| 311 ++---
  include/mpc823_lcd.h |  43 ++
  include/pxa_lcd.h|  80 ++
  include/splash.h |  11 +-
  17 files changed, 574 insertions(+), 547 deletions(-)
  create mode 100644 common/lcd_simplefb.c
  create mode 100644 include/atmel_lcd.h
  create mode 100644 include/exynos_lcd.h
  create mode 100644 include/fdt_simplefb.h
  create mode 100644 include/mpc823_lcd.h
  create mode 100644 include/pxa_lcd.h



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/2] ARM: atmel: arm9: switch to use common timer functions

2015-02-04 Thread Bo Shen
Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/cpu/arm926ejs/at91/timer.c  | 59 
 arch/arm/include/asm/arch-at91/at91sam9260.h |  3 ++
 arch/arm/include/asm/arch-at91/at91sam9261.h |  3 ++
 arch/arm/include/asm/arch-at91/at91sam9263.h |  3 ++
 arch/arm/include/asm/arch-at91/at91sam9g45.h |  3 ++
 arch/arm/include/asm/arch-at91/at91sam9rl.h  |  3 ++
 arch/arm/include/asm/arch-at91/at91sam9x5.h  |  3 ++
 7 files changed, 18 insertions(+), 59 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/at91/timer.c 
b/arch/arm/cpu/arm926ejs/at91/timer.c
index b0b7fb9..31ce646 100644
--- a/arch/arm/cpu/arm926ejs/at91/timer.c
+++ b/arch/arm/cpu/arm926ejs/at91/timer.c
@@ -33,22 +33,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define TIMER_LOAD_VAL 0xf
 
-static inline unsigned long long tick_to_time(unsigned long long tick)
-{
-   tick *= CONFIG_SYS_HZ;
-   do_div(tick, gd->arch.timer_rate_hz);
-
-   return tick;
-}
-
-static inline unsigned long long usec_to_tick(unsigned long long usec)
-{
-   usec *= gd->arch.timer_rate_hz;
-   do_div(usec, 100);
-
-   return usec;
-}
-
 /*
  * Use the PITC in full 32 bit incrementing mode
  */
@@ -64,54 +48,11 @@ int timer_init(void)
writel(TIMER_LOAD_VAL | AT91_PIT_MR_EN , &pit->mr);
 
gd->arch.timer_rate_hz = gd->arch.mck_rate_hz / 16;
-   gd->arch.tbu = gd->arch.tbl = 0;
 
return 0;
 }
 
 /*
- * Get the current 64 bit timer tick count
- */
-unsigned long long get_ticks(void)
-{
-   at91_pit_t *pit = (at91_pit_t *) ATMEL_BASE_PIT;
-
-   ulong now = readl(&pit->piir);
-
-   /* increment tbu if tbl has rolled over */
-   if (now < gd->arch.tbl)
-   gd->arch.tbu++;
-   gd->arch.tbl = now;
-   return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
-}
-
-void __udelay(unsigned long usec)
-{
-   unsigned long long start;
-   ulong tmo;
-
-   start = get_ticks();/* get current timestamp */
-   tmo = usec_to_tick(usec);   /* convert usecs to ticks */
-   while ((get_ticks() - start) < tmo)
-   ;   /* loop till time has passed */
-}
-
-/*
- * get_timer(base) can be used to check for timeouts or
- * to measure elasped time relative to an event:
- *
- * ulong start_time = get_timer(0) sets start_time to the current
- * time value.
- * get_timer(start_time) returns the time elapsed since then.
- *
- * The time is used in CONFIG_SYS_HZ units!
- */
-ulong get_timer(ulong base)
-{
-   return tick_to_time(get_ticks()) - base;
-}
-
-/*
  * Return the number of timer ticks per second.
  */
 ulong get_tbclk(void)
diff --git a/arch/arm/include/asm/arch-at91/at91sam9260.h 
b/arch/arm/include/asm/arch-at91/at91sam9260.h
index 8950d67..1a4e84b 100644
--- a/arch/arm/include/asm/arch-at91/at91sam9260.h
+++ b/arch/arm/include/asm/arch-at91/at91sam9260.h
@@ -133,6 +133,9 @@
 #define ATMEL_BASE_CS6 0x7000
 #define ATMEL_BASE_CS7 0x8000
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfd3c
+
 /*
  * Other misc defines
  */
diff --git a/arch/arm/include/asm/arch-at91/at91sam9261.h 
b/arch/arm/include/asm/arch-at91/at91sam9261.h
index 6dfcf4c..914a3b0 100644
--- a/arch/arm/include/asm/arch-at91/at91sam9261.h
+++ b/arch/arm/include/asm/arch-at91/at91sam9261.h
@@ -117,6 +117,9 @@
 #define ATMEL_BASE_CS6 0x7000
 #define ATMEL_BASE_CS7 0x8000
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfd3c
+
 /*
  * Other misc defines
  */
diff --git a/arch/arm/include/asm/arch-at91/at91sam9263.h 
b/arch/arm/include/asm/arch-at91/at91sam9263.h
index 64a3888..71675ab 100644
--- a/arch/arm/include/asm/arch-at91/at91sam9263.h
+++ b/arch/arm/include/asm/arch-at91/at91sam9263.h
@@ -132,6 +132,9 @@
 #define ATMEL_BASE_CS6 0x7000
 #define ATMEL_BASE_CS7 0x8000
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfd3c
+
 /*
  * Other misc defines
  */
diff --git a/arch/arm/include/asm/arch-at91/at91sam9g45.h 
b/arch/arm/include/asm/arch-at91/at91sam9g45.h
index 6df8cdb..cf1c73f 100644
--- a/arch/arm/include/asm/arch-at91/at91sam9g45.h
+++ b/arch/arm/include/asm/arch-at91/at91sam9g45.h
@@ -136,6 +136,9 @@
 #define ATMEL_BASE_CS6 0x7000
 #define ATMEL_BASE_CS7 0x8000
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfd3c
+
 /*
  * Other misc defines
  */
diff --git a/arch/arm/include/asm/arch-at91/at91sam9rl.h 
b/arch/arm/include/asm/arch-at91/at91sam9rl.h
index 3a8e6d6..70bbf4e 100644
--- a/arch/arm/include/asm/arch-at91/at91sam9rl.h
+++ b/arch/arm/include/asm/arch-at91/at91sam9rl.h
@@ -116,6 +116,9 @@
 #define ATMEL_BASE_CS4 0x5000  /* Compact Flash Slot 0 */
 #define ATMEL_BASE_CS5 0x6000  /* Compact Flash Slot 1 */
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfd3c
+
 /*
  * Oth

Re: [U-Boot] [PATCH V2 03/13] lcd: atmel: move atmel-specific fb_put_word to atmel_lcdfb

2015-02-04 Thread Bo Shen

On 02/03/2015 07:32 PM, Nikita Kiryanov wrote:

Reduce the amount of platform-specific code in common/lcd.c by moving Atmel
implementation of fb_put_word() to atmel_lcdfb.c. Since we must also have a
default implementation for everybody else, make the remainder of the code
into a weak function.

Signed-off-by: Nikita Kiryanov 
Reviewed-by: Simon Glass 
Cc: Bo Shen 
Cc: Simon Glass 
Cc: Anatolij Gustschin 


Acked-by: Bo Shen 


---
Changes in V2:
- Minor commit message update

  common/lcd.c| 11 +--
  drivers/video/atmel_lcdfb.c |  9 +
  2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/lcd.c b/common/lcd.c
index 0f6c2e4..f17b35b 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -642,20 +642,11 @@ static void lcd_display_rle8_bitmap(bmp_image_t *bmp, 
ushort *cmap, uchar *fb,
  #endif

  #if defined(CONFIG_BMP_16BPP)
-#if defined(CONFIG_ATMEL_LCD_BGR555)
-static inline void fb_put_word(uchar **fb, uchar **from)
-{
-   *(*fb)++ = (((*from)[0] & 0x1f) << 2) | ((*from)[1] & 0x03);
-   *(*fb)++ = ((*from)[0] & 0xe0) | (((*from)[1] & 0x7c) >> 2);
-   *from += 2;
-}
-#else
-static inline void fb_put_word(uchar **fb, uchar **from)
+__weak void fb_put_word(uchar **fb, uchar **from)
  {
*(*fb)++ = *(*from)++;
*(*fb)++ = *(*from)++;
  }
-#endif
  #endif /* CONFIG_BMP_16BPP */

  int lcd_display_bitmap(ulong bmp_image, int x, int y)
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index fa6a82c..c7991cd 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -34,6 +34,15 @@ ushort *configuration_get_cmap(void)
return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0));
  }

+#if defined(CONFIG_BMP_16BPP) && defined(CONFIG_ATMEL_LCD_BGR555)
+void fb_put_word(uchar **fb, uchar **from)
+{
+   *(*fb)++ = (((*from)[0] & 0x1f) << 2) | ((*from)[1] & 0x03);
+   *(*fb)++ = ((*from)[0] & 0xe0) | (((*from)[1] & 0x7c) >> 2);
+   *from += 2;
+}
+#endif
+
  void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
  {
  #if defined(CONFIG_ATMEL_LCD_BGR555)



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


Re: [U-Boot] [PATCH V2 02/13] lcd: split configuration_get_cmap

2015-02-04 Thread Bo Shen

Hi Nikita Kiryanov,

On 02/03/2015 07:32 PM, Nikita Kiryanov wrote:

configuration_get_cmap() is multiple platform-specific functions stuffed into
one function. Split it into multiple versions, and move each version to the
appropriate driver to reduce the #ifdef complexity.

Signed-off-by: Nikita Kiryanov 
Reviewed-by: Simon Glass 
Cc: Bo Shen 
Cc: Simon Glass 
Cc: Anatolij Gustschin 
---
Changes in V2:
- Minor commit message update
- ushort *configuration_get_cmap(void) prototype is defined only once
  instead of for each #ifdef CONFIG_*

  common/lcd.c | 19 ---
  drivers/video/atmel_hlcdfb.c | 13 +
  drivers/video/atmel_lcdfb.c  |  5 +
  drivers/video/exynos_fb.c|  9 +
  drivers/video/mpc8xx_lcd.c   |  7 +++
  drivers/video/pxa_lcd.c  |  6 ++
  include/lcd.h|  7 +++
  7 files changed, 47 insertions(+), 19 deletions(-)

diff --git a/common/lcd.c b/common/lcd.c
index 1195a54..0f6c2e4 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -383,25 +383,6 @@ int lcd_getbgcolor(void)
  //
  /* ** Chipset depending Bitmap / Logo stuff...  */
  //
-static inline ushort *configuration_get_cmap(void)
-{
-#if defined CONFIG_CPU_PXA
-   struct pxafb_info *fbi = &panel_info.pxa;
-   return (ushort *)fbi->palette;
-#elif defined(CONFIG_MPC823)
-   immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
-   cpm8xx_t *cp = &(immr->im_cpm);
-   return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]);
-#elif defined(CONFIG_ATMEL_LCD)
-   return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0));
-#elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB)
-   return panel_info.cmap;
-#elif defined(CONFIG_LCD_LOGO)
-   return bmp_logo_palette;
-#else
-   return NULL;
-#endif
-}

  #ifdef CONFIG_LCD_LOGO
  void bitmap_plot(int x, int y)
diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c
index 935ae42..0ce2370 100644
--- a/drivers/video/atmel_hlcdfb.c
+++ b/drivers/video/atmel_hlcdfb.c
@@ -13,6 +13,10 @@
  #include 
  #include 

+#if defined(CONFIG_LCD_LOGO)
+#include 
+#endif


I think we can include this file directly.


  /* configurable parameters */
  #define ATMEL_LCDC_CVAL_DEFAULT   0xc8
  #define ATMEL_LCDC_DMA_BURST_LEN  8
@@ -37,6 +41,15 @@ void lcd_setcolreg(ushort regno, ushort red, ushort green, 
ushort blue)
panel_info.mmio + ATMEL_LCDC_LUT(regno));
  }

+ushort *configuration_get_cmap(void)
+{
+#if defined(CONFIG_LCD_LOGO)
+   return bmp_logo_palette;
+#else
+   return NULL;
+#endif
+}


Here, I think no need to do the CONFIG_LCD_LOGO check, return 
bmp_logo_palette directly, as it will be used when use bmp command in 8 
bit mode. However, no hardware to test LCDC work or not in 8 bit mode :(



  void lcd_ctrl_init(void *lcdbase)
  {
unsigned long value;
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 3cf008c..fa6a82c 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -29,6 +29,11 @@
  #define lcdc_readl(mmio, reg) __raw_readl((mmio)+(reg))
  #define lcdc_writel(mmio, reg, val)   __raw_writel((val), (mmio)+(reg))

+ushort *configuration_get_cmap(void)
+{
+   return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0));
+}
+
  void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
  {
  #if defined(CONFIG_ATMEL_LCD_BGR555)
diff --git a/drivers/video/exynos_fb.c b/drivers/video/exynos_fb.c
index be35b98..c5d7330 100644
--- a/drivers/video/exynos_fb.c
+++ b/drivers/video/exynos_fb.c
@@ -37,6 +37,15 @@ vidinfo_t panel_info  = {
  };
  #endif

+ushort *configuration_get_cmap(void)
+{
+#if defined(CONFIG_LCD_LOGO)
+   return bmp_logo_palette;
+#else
+   return NULL;
+#endif
+}
+
  static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
  {
unsigned long palette_size;
diff --git a/drivers/video/mpc8xx_lcd.c b/drivers/video/mpc8xx_lcd.c
index add7215..9d2e5ed 100644
--- a/drivers/video/mpc8xx_lcd.c
+++ b/drivers/video/mpc8xx_lcd.c
@@ -357,6 +357,13 @@ lcd_setcolreg (ushort regno, ushort red, ushort green, 
ushort blue)

  /*--*/

+ushort *configuration_get_cmap(void)
+{
+   immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
+   cpm8xx_t *cp = &(immr->im_cpm);
+   return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]);
+}
+
  void lcd_enable (void)
  {
volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c
index f66f615..04105d4 100644
--- a/drivers/video/pxa_lcd.c
+++ b/drivers/video/pxa_lcd.c
@@ -342,6 +342,12 @@ static int pxafb_init (vidinfo_t *vid);
  /* 

Re: [U-Boot] [PATCH V2 01/13] lcd: move platform-specific structs to their own headers

2015-02-04 Thread Bo Shen

On 02/03/2015 07:32 PM, Nikita Kiryanov wrote:

common/lcd code is full of platform-specific code and definitions, which
ideally should reside with the respective driver code. Take a step towards that
goal by moving platform-specific structs from lcd.h to their own header files.

The structs for the generic case (the #else for all the platform-specific
cases) is retained in lcd.h as the default case.

Signed-off-by: Nikita Kiryanov 
Reviewed-by: Simon Glass 
Cc: Bo Shen 
Cc: Simon Glass 
Cc: Anatolij Gustschin 


For Atmel part, tested ok on at91sam9g35ek.

Tested-by: Bo Shen 


---
Changes in V2:
- Minor commit message update

  include/atmel_lcd.h  |  38 ++
  include/exynos_lcd.h |  81 +
  include/lcd.h| 201 ++-
  include/mpc823_lcd.h |  43 +++
  include/pxa_lcd.h|  80 
  5 files changed, 247 insertions(+), 196 deletions(-)
  create mode 100644 include/atmel_lcd.h
  create mode 100644 include/exynos_lcd.h
  create mode 100644 include/mpc823_lcd.h
  create mode 100644 include/pxa_lcd.h

diff --git a/include/atmel_lcd.h b/include/atmel_lcd.h
new file mode 100644
index 000..fa8aa29
--- /dev/null
+++ b/include/atmel_lcd.h
@@ -0,0 +1,38 @@
+/*
+ * atmel_lcd.h - Atmel LCD Controller structures
+ *
+ * (C) Copyright 2001
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _ATMEL_LCD_H_
+#define _ATMEL_LCD_H_
+
+typedef struct vidinfo {
+   ushort vl_col;  /* Number of columns (i.e. 640) */
+   ushort vl_row;  /* Number of rows (i.e. 480) */
+   u_long vl_clk;  /* pixel clock in ps*/
+
+   /* LCD configuration register */
+   u_long vl_sync; /* Horizontal / vertical sync */
+   u_long vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16 */
+   u_long vl_tft;  /* 0 = passive, 1 = TFT */
+   u_long vl_cont_pol_low; /* contrast polarity is low */
+   u_long vl_clk_pol;  /* clock polarity */
+
+   /* Horizontal control register. */
+   u_long vl_hsync_len;/* Length of horizontal sync */
+   u_long vl_left_margin;  /* Time from sync to picture */
+   u_long vl_right_margin; /* Time from picture to sync */
+
+   /* Vertical control register. */
+   u_long vl_vsync_len;/* Length of vertical sync */
+   u_long vl_upper_margin; /* Time from sync to picture */
+   u_long vl_lower_margin; /* Time from picture to sync */
+
+   u_long  mmio;   /* Memory mapped registers */
+} vidinfo_t;
+
+#endif
diff --git a/include/exynos_lcd.h b/include/exynos_lcd.h
new file mode 100644
index 000..cf389da
--- /dev/null
+++ b/include/exynos_lcd.h
@@ -0,0 +1,81 @@
+/*
+ * exynos_lcd.h - Exynos LCD Controller structures
+ *
+ * (C) Copyright 2001
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _EXYNOS_LCD_H_
+#define _EXYNOS_LCD_H_
+
+enum {
+   FIMD_RGB_INTERFACE = 1,
+   FIMD_CPU_INTERFACE = 2,
+};
+
+enum exynos_fb_rgb_mode_t {
+   MODE_RGB_P = 0,
+   MODE_BGR_P = 1,
+   MODE_RGB_S = 2,
+   MODE_BGR_S = 3,
+};
+
+typedef struct vidinfo {
+   ushort vl_col;  /* Number of columns (i.e. 640) */
+   ushort vl_row;  /* Number of rows (i.e. 480) */
+   ushort vl_width;/* Width of display area in millimeters */
+   ushort vl_height;   /* Height of display area in millimeters */
+
+   /* LCD configuration register */
+   u_char vl_freq; /* Frequency */
+   u_char vl_clkp; /* Clock polarity */
+   u_char vl_oep;  /* Output Enable polarity */
+   u_char vl_hsp;  /* Horizontal Sync polarity */
+   u_char vl_vsp;  /* Vertical Sync polarity */
+   u_char vl_dp;   /* Data polarity */
+   u_char vl_bpix; /* Bits per pixel */
+
+   /* Horizontal control register. Timing from data sheet */
+   u_char vl_hspw; /* Horz sync pulse width */
+   u_char vl_hfpd; /* Wait before of line */
+   u_char vl_hbpd; /* Wait end of line */
+
+   /* Vertical control register. */
+   u_char  vl_vspw;/* Vertical sync pulse width */
+   u_char  vl_vfpd;/* Wait before of frame */
+   u_char  vl_vbpd;/* Wait end of frame */
+   u_char  vl_cmd_allow_len; /* Wait end of frame */
+
+   unsigned int win_id;
+   unsigned int init_delay;
+   unsigned int power_on_delay;
+   unsigned int reset_delay;
+   unsigned int interface_mode;
+   unsigned int mipi_enabled;
+   unsigned int dp_enabled;
+   unsigned int cs_setup;
+   unsigned int wr_setup;
+   unsigned int wr_act;
+   unsigned int wr_hold;
+   unsigned int logo_on;
+   unsigned int logo_width;
+   unsigned int logo_height

Re: [U-Boot] [PATCH] ARM: at91: sama5d4: display the U-Boot version on LCD

2015-02-04 Thread Bo Shen

Hi Josh,

On 02/04/2015 11:03 AM, Josh Wu wrote:

This patch will display the U-Boot version on LCD.


To be frankly, I have no idea what should be put on LCD to display. No 
objection for this patch.



Signed-off-by: Josh Wu 


Acked-by: Bo Shen 


---

  board/atmel/sama5d4_xplained/sama5d4_xplained.c | 2 ++
  board/atmel/sama5d4ek/sama5d4ek.c   | 2 ++
  2 files changed, 4 insertions(+)

diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c 
b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
index 1c5b92c..a8c476b 100644
--- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c
+++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
@@ -23,6 +23,7 @@
  #include 
  #include 
  #include 
+#include 

  DECLARE_GLOBAL_DATA_PTR;

@@ -178,6 +179,7 @@ void lcd_show_board_info(void)
int i;
char temp[32];

+   lcd_printf("%s\n", U_BOOT_VERSION);
lcd_printf("2014 ATMEL Corp\n");
lcd_printf("%s CPU at %s MHz\n", get_cpu_name(),
   strmhz(temp, get_cpu_clk_rate()));
diff --git a/board/atmel/sama5d4ek/sama5d4ek.c 
b/board/atmel/sama5d4ek/sama5d4ek.c
index d8ff648..b55db06 100644
--- a/board/atmel/sama5d4ek/sama5d4ek.c
+++ b/board/atmel/sama5d4ek/sama5d4ek.c
@@ -23,6 +23,7 @@
  #include 
  #include 
  #include 
+#include 

  DECLARE_GLOBAL_DATA_PTR;

@@ -173,6 +174,7 @@ void lcd_show_board_info(void)
int i;
char temp[32];

+   lcd_printf("%s\n", U_BOOT_VERSION);
lcd_printf("2014 ATMEL Corp\n");
lcd_printf("a...@atmel.com\n");
lcd_printf("%s CPU at %s MHz\n", get_cpu_name(),



Best Regards,
Bo Shen

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


Re: [U-Boot] [PATCH] ARM: at91: at91sam9rlek: add hush parser to defconfig

2015-02-04 Thread Bo Shen

Hi Josh,

On 02/03/2015 06:19 PM, Josh Wu wrote:

HUSH parser will handle the variable easier. That will be helpful for
write a complicated U-Boot commands or varaibles.


You are on the way to Kconfig. :)
Thanks.


Signed-off-by: Josh Wu 


Acked-by: Bo Shen 


---

  configs/at91sam9rlek_dataflash_defconfig | 1 +
  configs/at91sam9rlek_mmc_defconfig   | 1 +
  configs/at91sam9rlek_nandflash_defconfig | 1 +
  3 files changed, 3 insertions(+)

diff --git a/configs/at91sam9rlek_dataflash_defconfig 
b/configs/at91sam9rlek_dataflash_defconfig
index 90516e0..c811ad5 100644
--- a/configs/at91sam9rlek_dataflash_defconfig
+++ b/configs/at91sam9rlek_dataflash_defconfig
@@ -1,3 +1,4 @@
  CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9RL,SYS_USE_DATAFLASH"
  CONFIG_ARM=y
  CONFIG_TARGET_AT91SAM9RLEK=y
+CONFIG_HUSH_PARSER=y
diff --git a/configs/at91sam9rlek_mmc_defconfig 
b/configs/at91sam9rlek_mmc_defconfig
index b93c881..8704140 100644
--- a/configs/at91sam9rlek_mmc_defconfig
+++ b/configs/at91sam9rlek_mmc_defconfig
@@ -1,3 +1,4 @@
  CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9RL,SYS_USE_MMC"
  CONFIG_ARM=y
  CONFIG_TARGET_AT91SAM9RLEK=y
+CONFIG_HUSH_PARSER=y
diff --git a/configs/at91sam9rlek_nandflash_defconfig 
b/configs/at91sam9rlek_nandflash_defconfig
index 0e2edfd..e3de043 100644
--- a/configs/at91sam9rlek_nandflash_defconfig
+++ b/configs/at91sam9rlek_nandflash_defconfig
@@ -1,3 +1,4 @@
  CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9RL,SYS_USE_NANDFLASH"
  CONFIG_ARM=y
  CONFIG_TARGET_AT91SAM9RLEK=y
+CONFIG_HUSH_PARSER=y



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 0/2] ARM: at91: at91sam9rlek: add mmc config for at91sam9rlek

2015-02-02 Thread Bo Shen

Hi Josh,

On 02/02/2015 05:50 PM, Josh Wu wrote:

This patch series will enable mmc support on at91sam9rlek board. And
also add a MMC config for it.


Josh Wu (2):
   ARM: at91: at91sam9rlek: add mci support
   ARM: at91: at91sam9rlek: add mmc environment configuration


For this series:

Acked-by: Bo Shen 


  arch/arm/cpu/arm926ejs/at91/at91sam9rl_devices.c | 17 ++
  board/atmel/at91sam9rlek/at91sam9rlek.c  | 10 
  configs/at91sam9rlek_mmc_defconfig   |  3 +++
  include/configs/at91sam9rlek.h   | 29 +++-
  4 files changed, 58 insertions(+), 1 deletion(-)
  create mode 100644 configs/at91sam9rlek_mmc_defconfig



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: at91: at91sam9rlek: update the default nand flash configs

2015-02-02 Thread Bo Shen

Hi Josh

On 02/02/2015 05:31 PM, Josh Wu wrote:

Update the nand flash offset mapping, default nand bootcmand and
bootargs to align with linux4sam.org.

Signed-off-by: Josh Wu 


except the following concern:

Acked-by: Bo Shen 


---

  include/configs/at91sam9rlek.h | 16 +---
  1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/configs/at91sam9rlek.h b/include/configs/at91sam9rlek.h
index d5f0197..f790fcf 100644
--- a/include/configs/at91sam9rlek.h
+++ b/include/configs/at91sam9rlek.h
@@ -151,14 +151,16 @@

  /* bootstrap + u-boot + env + linux in nandflash */
  #define CONFIG_ENV_IS_IN_NAND 1
-#define CONFIG_ENV_OFFSET  0x6
-#define CONFIG_ENV_OFFSET_REDUND   0x8
+#define CONFIG_ENV_OFFSET  0xc
+#define CONFIG_ENV_OFFSET_REDUND   0x10
  #define CONFIG_ENV_SIZE   0x2 /* 1 sector = 128 kB */
-#define CONFIG_BOOTCOMMAND "nand read 0x2200 0xA 0x20; bootm"
-#define CONFIG_BOOTARGS"console=ttyS0,115200 " \
-   "root=/dev/mtdblock5 " \
-   
"mtdparts=atmel_nand:128k(bootstrap)ro,256k(uboot)ro,128k(env1)ro,128k(env2)ro,2M(linux),-(root)
 " \
-   "rw rootfstype=jffs2"
+#define CONFIG_BOOTCOMMAND "nand read 0x2200 0x20 0x30; bootz 
0x2200"


The kernel partition is 6MiB, as here only read 3MiB. As the Linux 
kernel is switch to multi-platform support. The Linux kernel size is 
bigger than 3MiB now.



+#define CONFIG_BOOTARGS\
+   "console=ttyS0,115200 earlyprintk " 
  \
+   
"mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro,"\
+   "256K(env),256k(evn_redundent),256k(spare),"
  \
+   "512k(dtb),6M(kernel)ro,-(rootfs) " 
  \
+       "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs"

  #endif




Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] lcd: fix console address is not initialized

2015-01-29 Thread Bo Shen

Hi Anatolij,

On 01/29/2015 04:51 PM, Anatolij Gustschin wrote:

Hi,

On Wed, 28 Jan 2015 09:13:22 +0800
Bo Shen  wrote:


This commit 904672e (lcd: refactor lcd console stuff into its
own file), which cause lcd console address is not initialized.

This patch initialize the lcd console use the default value,
will be update when splash screen is enabled.

Signed-off-by: Bo Shen 
---
Hi Tom,
   If no objection of this patch, can you apply it as soon as possible.
Or else most Atmel SoC based boards (which enable lcd info) will be
broken.
   Thanks.

  common/lcd.c | 1 +
  1 file changed, 1 insertion(+)


Slightly modified the commit log and applied to u-boot-video/master.


Thanks.


Thanks!

Anatolij



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Makefile: clean boot.bin

2015-01-27 Thread Bo Shen

On 01/23/2015 03:44 PM, Masahiro Yamada wrote:


On Fri, 23 Jan 2015 15:34:08 +0800
Bo Shen  wrote:


+ Tom, Masahiro,

On 01/15/2015 10:03 AM, Bo Shen wrote:

When build for Atmel related boards which support SPL,
it will generate boot.bin, also clean when it when do
"make clean" operation.

Signed-off-by: Bo Shen 


Hi Tom,

Can this patch be applied? Thanks.



Acked-by: Masahiro Yamada 


Hi Masahiro,
  Thanks.



I think this patch should be applied by Tom,
because I am a contributer of the build system
but am not the custodian.


Best Regards,
Bo Shen

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


[U-Boot] [PATCH] lcd: fix console address is not initialized

2015-01-27 Thread Bo Shen
This commit 904672e (lcd: refactor lcd console stuff into its
own file), which cause lcd console address is not initialized.

This patch initialize the lcd console use the default value,
will be update when splash screen is enabled.

Signed-off-by: Bo Shen 
---
Hi Tom,
  If no objection of this patch, can you apply it as soon as possible. 
Or else most Atmel SoC based boards (which enable lcd info) will be
broken.
  Thanks.

 common/lcd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/lcd.c b/common/lcd.c
index cc34b8a..1195a54 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -268,6 +268,7 @@ void lcd_clear(void)
console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT;
 #endif
console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH;
+   lcd_init_console(lcd_base, console_rows, console_cols);
lcd_init_console(lcd_logo(), console_rows, console_cols);
lcd_sync();
 }
-- 
2.3.0.rc0

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


Re: [U-Boot] [PATCH] lcd: fix console address is not initialized

2015-01-27 Thread Bo Shen

Hi Nikita Kiryanov,

On 01/27/2015 10:45 PM, Nikita Kiryanov wrote:

Can we use the following patch to fix this issue?
--->8---
diff --git a/common/lcd.c b/common/lcd.c
index cc34b8a..1195a54 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -268,6 +268,7 @@ void lcd_clear(void)
 console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT;
  #endif
 console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH;
+   lcd_init_console(lcd_base, console_rows, console_cols);
 lcd_init_console(lcd_logo(), console_rows, console_cols);
 lcd_sync();
  }
---8<---

It first initializes the lcd console with LCD base, if the splash
screen is used, new address is updated.



I think this is the best approach. I am very close to posting the next


Thanks for review. I think send this fix patch first, and then you can 
based on this patch for your next step, or else, we can not know how 
long it will break most Atmel SoC related boards on master branch. So, I 
will send this patch and try to get it applied as soon as possible.


Thanks again.


step in my refactor of lcd.c, and I can
incorporate it in the series. I will greatly appreciate your help in
testing this series, since it involves Atmel
related changes.



I need this kind of fix to be applied as soon as possible, or else,
most Atmel related board are broken on u-boot master branch.

Best Regards,
Bo Shen


--
Regards,
Nikita Kiryanov


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] lcd: fix console address is not initialized

2015-01-25 Thread Bo Shen

Hi Nikita Kiryanov,
 + Andreas, Tom

On 01/23/2015 09:20 AM, Bo Shen wrote:

Hi Nikita Kiryanov,

On 01/22/2015 09:10 PM, Nikita Kiryanov wrote:

Hi Bo,

On 01/21/2015 06:37 AM, Bo Shen wrote:

This commit 904672e (lcd: refactor lcd console stuff into its
own file), which cause lcd console address is not initialized.


Based on your fix, I'm certain that the bug was introduced in a
previous patch, perhaps 140beb9 (lcd: expand console api).

Also, can you provide a more detailed explanation of when this
happens and how?


It will cause the system hang.

Before this patch, lcd_logo -> lcd_show_board_info (CONFIG_LCD_INFO) ->
.. -> lcd_drawchars. It has the following lines:
--->8---
dest = (uchar *)(lcd_base + y * lcd_line_length + x * NBITS(LCD_BPP)/8);
---8<---

while with the patch,
--->8---
dest = (uchar *)(lcd_console_address +
  y * lcd_line_length + x * NBITS(LCD_BPP) / 8);
---8<---

As the lcd_console_address is initialized after lcd_logo return, so the
lcd_console_address is not initialized, it is 0. When try to write to
address 0, the system hang.



This patch split lcd console address initialize and lcd logo
display into two functions.

Signed-off-by: Bo Shen 
---

  common/lcd.c | 11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/lcd.c b/common/lcd.c
index cc34b8a..f435e2a 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -82,7 +82,8 @@ DECLARE_GLOBAL_DATA_PTR;

  static int lcd_init(void *lcdbase);

-static void *lcd_logo(void);
+static void lcd_logo(void);
+static void *lcd_console_address(void);

  static void lcd_setfgcolor(int color);
  static void lcd_setbgcolor(int color);
@@ -268,7 +269,8 @@ void lcd_clear(void)
  console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT;
  #endif
  console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH;
-lcd_init_console(lcd_logo(), console_rows, console_cols);
+lcd_init_console(lcd_console_address(), console_rows,
console_cols);
+lcd_logo();
  lcd_sync();
  }

@@ -849,7 +851,7 @@ int lcd_display_bitmap(ulong bmp_image, int x,
int y)
  }
  #endif

-static void *lcd_logo(void)
+static void lcd_logo(void)
  {
  #ifdef CONFIG_SPLASH_SCREEN
  char *s;
@@ -879,7 +881,10 @@ static void *lcd_logo(void)
  lcd_set_row(LCD_INFO_Y / VIDEO_FONT_HEIGHT);
  lcd_show_board_info();
  #endif /* CONFIG_LCD_INFO */
+}

+static void *lcd_console_address(void)
+{
  #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
  return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT *
lcd_line_length);
  #else



I would like to see some mention of why it's ok to redefine the console
address in such a way. At first glance it looks like there is a slight
change of
behavior (the value no longer depends on whether splash image was loaded
or not), but it seems to be ok if you go over the various cases. The only
instance where I see the difference could manifest itself is if lcd
console
would start writing to the frame buffer while the splash screen is still
on,
but that doesn't look good regardless of where the console starts, so
I'm ok
with that.



Thanks for reminder this, I will check whether this will break the
splash screen.


Can we use the following patch to fix this issue?
--->8---
diff --git a/common/lcd.c b/common/lcd.c
index cc34b8a..1195a54 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -268,6 +268,7 @@ void lcd_clear(void)
console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT;
 #endif
console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH;
+   lcd_init_console(lcd_base, console_rows, console_cols);
lcd_init_console(lcd_logo(), console_rows, console_cols);
lcd_sync();
 }
---8<---

It first initializes the lcd console with LCD base, if the splash screen 
is used, new address is updated.


I need this kind of fix to be applied as soon as possible, or else, most 
Atmel related board are broken on u-boot master branch.


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Makefile: clean boot.bin

2015-01-22 Thread Bo Shen

+ Tom, Masahiro,

On 01/15/2015 10:03 AM, Bo Shen wrote:

When build for Atmel related boards which support SPL,
it will generate boot.bin, also clean when it when do
"make clean" operation.

Signed-off-by: Bo Shen 
---

  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


Ping?


diff --git a/Makefile b/Makefile
index 36a9a28..ea5ae8f 100644
--- a/Makefile
+++ b/Makefile
@@ -1278,7 +1278,7 @@ CLEAN_DIRS  += $(MODVERDIR) \
$(filter-out include, $(shell ls -1 $d 2>/dev/null

  CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
-  u-boot* MLO* SPL System.map
+  boot* u-boot* MLO* SPL System.map

  # Directories & files removed with 'make mrproper'
  MRPROPER_DIRS  += include/config include/generated spl tpl \



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] lcd: fix console address is not initialized

2015-01-22 Thread Bo Shen

Hi Nikita Kiryanov,

On 01/22/2015 09:10 PM, Nikita Kiryanov wrote:

Hi Bo,

On 01/21/2015 06:37 AM, Bo Shen wrote:

This commit 904672e (lcd: refactor lcd console stuff into its
own file), which cause lcd console address is not initialized.


Based on your fix, I'm certain that the bug was introduced in a
previous patch, perhaps 140beb9 (lcd: expand console api).

Also, can you provide a more detailed explanation of when this
happens and how?


It will cause the system hang.

Before this patch, lcd_logo -> lcd_show_board_info (CONFIG_LCD_INFO) -> 
.. -> lcd_drawchars. It has the following lines:

--->8---
dest = (uchar *)(lcd_base + y * lcd_line_length + x * NBITS(LCD_BPP)/8);
---8<---

while with the patch,
--->8---
dest = (uchar *)(lcd_console_address +
 y * lcd_line_length + x * NBITS(LCD_BPP) / 8);
---8<---

As the lcd_console_address is initialized after lcd_logo return, so the 
lcd_console_address is not initialized, it is 0. When try to write to 
address 0, the system hang.




This patch split lcd console address initialize and lcd logo
display into two functions.

Signed-off-by: Bo Shen 
---

  common/lcd.c | 11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/lcd.c b/common/lcd.c
index cc34b8a..f435e2a 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -82,7 +82,8 @@ DECLARE_GLOBAL_DATA_PTR;

  static int lcd_init(void *lcdbase);

-static void *lcd_logo(void);
+static void lcd_logo(void);
+static void *lcd_console_address(void);

  static void lcd_setfgcolor(int color);
  static void lcd_setbgcolor(int color);
@@ -268,7 +269,8 @@ void lcd_clear(void)
  console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT;
  #endif
  console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH;
-lcd_init_console(lcd_logo(), console_rows, console_cols);
+lcd_init_console(lcd_console_address(), console_rows, console_cols);
+lcd_logo();
  lcd_sync();
  }

@@ -849,7 +851,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
  }
  #endif

-static void *lcd_logo(void)
+static void lcd_logo(void)
  {
  #ifdef CONFIG_SPLASH_SCREEN
  char *s;
@@ -879,7 +881,10 @@ static void *lcd_logo(void)
  lcd_set_row(LCD_INFO_Y / VIDEO_FONT_HEIGHT);
  lcd_show_board_info();
  #endif /* CONFIG_LCD_INFO */
+}

+static void *lcd_console_address(void)
+{
  #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
  return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT *
lcd_line_length);
  #else



I would like to see some mention of why it's ok to redefine the console
address in such a way. At first glance it looks like there is a slight
change of
behavior (the value no longer depends on whether splash image was loaded
or not), but it seems to be ok if you go over the various cases. The only
instance where I see the difference could manifest itself is if lcd console
would start writing to the frame buffer while the splash screen is still
on,
but that doesn't look good regardless of where the console starts, so
I'm ok
with that.



Thanks for reminder this, I will check whether this will break the 
splash screen.


Best Regards,
Bo Shen

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


Re: [U-Boot] [PATCH v2] ARM: atmel: at91sam9m10g45ek: enable SPL

2015-01-21 Thread Bo Shen

Hi Heiko,

On 01/21/2015 07:01 PM, Heiko Schocher wrote:

Hello Bo,

Am 21.01.2015 10:45, schrieb Bo Shen:

Supports boot up from NAND flash with software ECC eanbled.
And supports boot up from SD/MMC card with FAT file system.

As the boot from SD/MMC card with FAT file system, the BSS
segment is too big to fit into SRAM, so, use the lds to put
it into SDRAM.

Signed-off-by: Bo Shen 
---

Changes in v2:
   - This patch based on one patch from Simon Glass
 - http://patchwork.ozlabs.org/patch/430240/
   - remove the low level init code.
   - correct the stack of corvus board.


You do not change, nor need to change now with the patch from Simon
something for the corvus board!


Oops, forget to remove the last line.


Beside of that:

Acked-by: Heiko Schocher 


Thanks.


bye,
Heiko


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: spl: Allow board_init_r() to run with a larger stack

2015-01-21 Thread Bo Shen

Hi Simon Glass,

On 01/19/2015 02:55 AM, Simon Glass wrote:

At present SPL uses a single stack, either CONFIG_SPL_STACK or
CONFIG_SYS_INIT_SP_ADDR. Since some SPL features (such as MMC and
environment) require a lot of stack, some boards set CONFIG_SPL_STACK to
point into SDRAM. They then set up SDRAM very early, before board_init_f(),
so that the larger stack can be used.

This is an abuse of lowlevel_init(). That function should only be used for
essential start-up code which cannot be delayed. An example of a valid use is
when only part of the SPL code is visible/executable, and the SoC must be set
up so that board_init_f() can be reached. It should not be used for SDRAM
init, console init, etc.

Add a CONFIG_SPL_STACK_R option, which allows the stack to be moved to a new
address before board_init_r() is called in SPL.

The expected SPL flow (for CONFIG_SPL_FRAMEWORK) is now:

Execution starts with start.S. Two main functions can be provided by the
board implementation. The purpose and limitations of each is described below.
After that, the common board_init_r() is called to perform the SPL task.

lowlevel_init():
- purpose: essential init to permit execution to reach board_init_f()
- no global_data, but there is a stack
- must not set up SDRAM or use console
- must only do the bare minimum to allow execution to continue to
board_init_f()
- this is almost never needed
- return normally from this function

board_init_f():
- purpose: set up the machine ready for running board_init_r():
i.e. SDRAM and serial UART
- global_data is available
- preloader_console_init() can be called here in extremis
- stack is in SRAM
- should set up SDRAM, and anything needed to make the UART work
- these is no need to clear BSS, it will be done by crt0.S
- must return normally from this function (don't call board_init_r()
directly)

Here the BSS is cleared. If CONFIG_SPL_STACK_R is defined, then at this point
the stack and global_data are relocated to below that address.

board_init_r():
- purpose: main execution, common code
- global_data is available
- SDRAM is available
- stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined and
points into SDRAM
- preloader_console_init() can be called here - typically this is
done by defining CONFIG_SPL_BOARD_INIT and then supplying a
spl_board_init() function containing this call
- loads U-Boot or (in falcon mode) Linux

Note: This patch is intended to apply over the top of Tom's SPL changes and
this series:

https://patchwork.ozlabs.org/patch/423785/

Signed-off-by: Simon Glass 


Tested-by: Bo Shen 
Acked-by: Bo Shen 


---

  arch/arm/lib/crt0.S | 13 ++---
  common/spl/spl.c| 35 +++
  doc/README.SPL  | 42 ++
  3 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
index 22df3e5..7939ced 100644
--- a/arch/arm/lib/crt0.S
+++ b/arch/arm/lib/crt0.S
@@ -113,7 +113,14 @@ here:
  /* Set up final (full) environment */

bl  c_runtime_cpu_setup /* we still call old routine here */
-
+#endif
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_FRAMEWORK)
+# ifdef CONFIG_SPL_BUILD
+   /* Use a DRAM stack for the rest of SPL, if requested */
+   bl  spl_relocate_stack_gd
+   cmp r0, #0
+   movne   sp, r0
+# endif
ldr r0, =__bss_start/* this is auto-relocated! */
ldr r1, =__bss_end  /* this is auto-relocated! */

@@ -124,9 +131,10 @@ clbss_l:cmpr0, r1  /* while not at 
end of BSS */
addlo   r0, r0, #4  /* move to next */
blo clbss_l

+#if ! defined(CONFIG_SPL_BUILD)
bl coloured_LED_init
bl red_led_on
-
+#endif
/* call board_init_r(gd_t *id, ulong dest_addr) */
mov r0, r9  /* gd_t */
ldr r1, [r9, #GD_RELOCADDR] /* dest_addr */
@@ -134,7 +142,6 @@ clbss_l:cmp r0, r1  /* while not at end of 
BSS */
ldr pc, =board_init_r   /* this is auto-relocated! */

/* we should not return here. */
-
  #endif

  ENDPROC(_main)
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 1826c47..78bb279 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -276,3 +276,38 @@ void preloader_console_init(void)
spl_display_print();
  #endif
  }
+
+/**
+ * spl_relocate_stack_gd() - Relocate stack ready for board_init_r() execution
+ *
+ * Sometimes board_init_f() runs with a stack in SRAM but we want to use SDRAM
+ * for the main board_init_r() execution. This is typically because we need
+ * more stack space for things like the MMC sub-system.
+ *
+ * This function calculates

[U-Boot] [PATCH v2] ARM: atmel: at91sam9m10g45ek: enable SPL

2015-01-21 Thread Bo Shen
Supports boot up from NAND flash with software ECC eanbled.
And supports boot up from SD/MMC card with FAT file system.

As the boot from SD/MMC card with FAT file system, the BSS
segment is too big to fit into SRAM, so, use the lds to put
it into SDRAM.

Signed-off-by: Bo Shen 
---

Changes in v2:
  - This patch based on one patch from Simon Glass
- http://patchwork.ozlabs.org/patch/430240/
  - remove the low level init code.
  - correct the stack of corvus board.

 arch/arm/Kconfig|  1 +
 arch/arm/cpu/at91-common/spl_at91.c |  6 +-
 arch/arm/cpu/at91-common/u-boot-spl-arm9.lds| 48 +++
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80 +
 configs/at91sam9m10g45ek_mmc_defconfig  |  5 +-
 configs/at91sam9m10g45ek_nandflash_defconfig|  5 +-
 include/configs/at91sam9m10g45ek.h  | 58 ++
 7 files changed, 198 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/cpu/at91-common/u-boot-spl-arm9.lds

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5eb1d03..f4788c6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -141,6 +141,7 @@ config TARGET_AT91SAM9263EK
 config TARGET_AT91SAM9M10G45EK
bool "Support at91sam9m10g45ek"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_AT91SAM9N12EK
bool "Support at91sam9n12ek"
diff --git a/arch/arm/cpu/at91-common/spl_at91.c 
b/arch/arm/cpu/at91-common/spl_at91.c
index 89f588b..af6fc0d 100644
--- a/arch/arm/cpu/at91-common/spl_at91.c
+++ b/arch/arm/cpu/at91-common/spl_at91.c
@@ -71,7 +71,11 @@ void __weak at91_spl_board_init(void)
 {
 }
 
-void spl_board_init(void)
+void __weak spl_board_init(void)
+{
+}
+
+void board_init_f(ulong dummy)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
diff --git a/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds 
b/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds
new file mode 100644
index 000..6f350a9
--- /dev/null
+++ b/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 Atmel Corporation
+ *   Bo Shen 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \
+   LENGTH = CONFIG_SPL_MAX_SIZE }
+MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
+   LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+   .text  :
+   {
+   __start = .;
+   *(.vectors)
+   arch/arm/cpu/arm926ejs/start.o  (.text*)
+   *(.text*)
+   } >.sram
+
+   . = ALIGN(4);
+   .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
+
+   . = ALIGN(4);
+   .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
+
+   . = ALIGN(4);
+   __image_copy_end = .;
+
+   .end :
+   {
+   *(.__end)
+   } >.sram
+
+   .bss :
+   {
+   . = ALIGN(4);
+   __bss_start = .;
+   *(.bss*)
+   . = ALIGN(4);
+   __bss_end = .;
+   } >.sdram
+}
diff --git a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c 
b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
index b807ef9..4289179 100644
--- a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
+++ b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -15,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
@@ -71,6 +73,84 @@ void at91sam9m10g45ek_nand_hw_init(void)
 }
 #endif
 
+#if defined(CONFIG_SPL_BUILD)
+#include 
+#include 
+
+void at91_spl_board_init(void)
+{
+   /*
+* On the at91sam9m10g45ek board, the chip wm9711 stays in the
+* test mode, so it needs do some action to exit test mode.
+*/
+   at91_periph_clk_enable(ATMEL_ID_PIODE);
+   at91_set_gpio_output(AT91_PIN_PD7, 0);
+   at91_set_gpio_output(AT91_PIN_PD8, 0);
+   at91_set_pio_pullup(AT91_PIO_PORTD, 7, 1);
+   at91_set_pio_pullup(AT91_PIO_PORTD, 8, 1);
+
+#ifdef CONFIG_SYS_USE_MMC
+   at91_mci_hw_init();
+#elif CONFIG_SYS_USE_NANDFLASH
+   at91sam9m10g45ek_nand_hw_init();
+#endif
+}
+
+#include 
+static void ddr2_conf(struct atmel_mpddr *ddr2)
+{
+   ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+   ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+   ATMEL_MPDDRC_CR_NR_ROW_14 |
+   ATMEL_MPDDRC_CR_DQMS_SHARED |
+   ATMEL_MPDDRC_CR_CAS_DDR_CAS3);
+
+   ddr2->rtr = 0x24b;
+
+   ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |/* 6*7.5 = 45 ns */
+ 2 << ATMEL_MPDDRC_TPR0_TRCD_OF

Re: [U-Boot] [PATCH] arm, at91: add reset controller status register

2015-01-21 Thread Bo Shen

Hi Heiko,

On 01/21/2015 03:42 PM, Heiko Schocher wrote:

add reset controller status register

Signed-off-by: Heiko Schocher 


Acked-by: Bo Shen 


---

  arch/arm/include/asm/arch-at91/at91_rstc.h | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/arch/arm/include/asm/arch-at91/at91_rstc.h 
b/arch/arm/include/asm/arch-at91/at91_rstc.h
index a942342..e4eb3da 100644
--- a/arch/arm/include/asm/arch-at91/at91_rstc.h
+++ b/arch/arm/include/asm/arch-at91/at91_rstc.h
@@ -13,6 +13,8 @@
  #ifndef AT91_RSTC_H
  #define AT91_RSTC_H

+/* Reset Controller Status Register */
+#define AT91_ASM_RSTC_SR   (ATMEL_BASE_RSTC + 0x04)
  #define AT91_ASM_RSTC_MR  (ATMEL_BASE_RSTC + 0x08)

  #ifndef __ASSEMBLY__



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] lcd: fix console address is not initialized

2015-01-20 Thread Bo Shen
This commit 904672e (lcd: refactor lcd console stuff into its
own file), which cause lcd console address is not initialized.

This patch split lcd console address initialize and lcd logo
display into two functions.

Signed-off-by: Bo Shen 
---

 common/lcd.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/lcd.c b/common/lcd.c
index cc34b8a..f435e2a 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -82,7 +82,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static int lcd_init(void *lcdbase);
 
-static void *lcd_logo(void);
+static void lcd_logo(void);
+static void *lcd_console_address(void);
 
 static void lcd_setfgcolor(int color);
 static void lcd_setbgcolor(int color);
@@ -268,7 +269,8 @@ void lcd_clear(void)
console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT;
 #endif
console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH;
-   lcd_init_console(lcd_logo(), console_rows, console_cols);
+   lcd_init_console(lcd_console_address(), console_rows, console_cols);
+   lcd_logo();
lcd_sync();
 }
 
@@ -849,7 +851,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 }
 #endif
 
-static void *lcd_logo(void)
+static void lcd_logo(void)
 {
 #ifdef CONFIG_SPLASH_SCREEN
char *s;
@@ -879,7 +881,10 @@ static void *lcd_logo(void)
lcd_set_row(LCD_INFO_Y / VIDEO_FONT_HEIGHT);
lcd_show_board_info();
 #endif /* CONFIG_LCD_INFO */
+}
 
+static void *lcd_console_address(void)
+{
 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length);
 #else
-- 
2.3.0.rc0

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


Re: [U-Boot] [PATCH] ARM: at91: mmc portA support is only for at91sam9g20ek_2mmc board

2015-01-19 Thread Bo Shen

Hi Josh,

On 01/19/2015 03:25 PM, Josh Wu wrote:

Current the MMC support will enable MCI port A, Which is only exist
for 2mmc board.
So by default we need to disable MMC (port A) support. And only enable
it for 2mmc board. Otherwise, dataflash won't work in at91sam9260ek board
as MMC has confliction with Dataflash in the CLK pin.

Signed-off-by: Josh Wu 
---

  configs/at91sam9g20ek_2mmc_defconfig | 3 +++
  configs/at91sam9g20ek_mmc_defconfig  | 3 ---
  include/configs/at91sam9260ek.h  | 6 --
  3 files changed, 7 insertions(+), 5 deletions(-)
  create mode 100644 configs/at91sam9g20ek_2mmc_defconfig
  delete mode 100644 configs/at91sam9g20ek_mmc_defconfig

diff --git a/configs/at91sam9g20ek_2mmc_defconfig 
b/configs/at91sam9g20ek_2mmc_defconfig
new file mode 100644
index 000..4eef04f
--- /dev/null
+++ b/configs/at91sam9g20ek_2mmc_defconfig
@@ -0,0 +1,3 @@
+CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9G20,AT91SAM9G20EK_2MMC,SYS_USE_MMC"
+CONFIG_ARM=y
+CONFIG_TARGET_AT91SAM9260EK=y
diff --git a/configs/at91sam9g20ek_mmc_defconfig 
b/configs/at91sam9g20ek_mmc_defconfig
deleted file mode 100644
index 8cca2e5..000
--- a/configs/at91sam9g20ek_mmc_defconfig
+++ /dev/null


If removed this default configuration file, we can not use mmc at all, 
am I right?



@@ -1,3 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9G20,SYS_USE_MMC"
-CONFIG_ARM=y
-CONFIG_TARGET_AT91SAM9260EK=y
diff --git a/include/configs/at91sam9260ek.h b/include/configs/at91sam9260ek.h
index a6a80de..c4b2e16 100644
--- a/include/configs/at91sam9260ek.h
+++ b/include/configs/at91sam9260ek.h
@@ -90,7 +90,6 @@
  #define CONFIG_CMD_PING   1
  #define CONFIG_CMD_DHCP   1
  #define CONFIG_CMD_NAND   1
-#define CONFIG_CMD_MMC
  #define CONFIG_CMD_FAT
  #define CONFIG_CMD_USB1

@@ -133,14 +132,17 @@
  # define CONFIG_MACH_TYPE MACH_TYPE_AT91SAM9260EK
  #endif

-/* DataFlash */
  #ifndef CONFIG_AT91SAM9G20EK_2MMC
+/* DataFlash */
  #define CONFIG_ATMEL_DATAFLASH_SPI
  #define CONFIG_HAS_DATAFLASH  1
  #define CONFIG_SYS_MAX_DATAFLASH_BANKS2
  #define CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0   0xC000  /* CS0 */
  #define CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1   0xD000  /* CS1 */
  #define AT91_SPI_CLK  1500
+#else
+/* Enable MMC. The MCCK is conflicted with DataFlash */
+#define CONFIG_CMD_MMC
  #endif

  #ifdef CONFIG_AT91SAM9G20EK



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/3] ARM: at91: at91sam9x5: save environment to a FAT file in MMC card

2015-01-19 Thread Bo Shen

Hi Josh,

On 01/19/2015 03:06 PM, Josh Wu wrote:

This patch will save U-Boot environment as a file: uboot.env, in FAT partition
instead of saving it in raw sector of MMC card.

This make us easier to manage the environment file.

Signed-off-by: Josh Wu 


Acked-by: Bo Shen 


---

  include/configs/at91sam9x5ek.h | 11 ++-
  1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
index b1d4baa..6d8b71d 100644
--- a/include/configs/at91sam9x5ek.h
+++ b/include/configs/at91sam9x5ek.h
@@ -203,11 +203,12 @@
"bootm 0x2200"
  #else /* CONFIG_SYS_USE_MMC */
  /* bootstrap + u-boot + env + linux in mmc */
-#define CONFIG_ENV_IS_IN_MMC
-/* For FAT system, most cases it should be in the reserved sector */
-#define CONFIG_ENV_OFFSET  0x2000
-#define CONFIG_ENV_SIZE0x1000
-#define CONFIG_SYS_MMC_ENV_DEV 0
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE
+#define FAT_ENV_INTERFACE  "mmc"
+#define FAT_ENV_FILE   "uboot.env"
+#define FAT_ENV_DEVICE_AND_PART "0"
+#define CONFIG_ENV_SIZE0x4000
  #endif

  #ifdef CONFIG_SYS_USE_MMC



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/3] ARM: at91: sama5d3xek: save enviroment as a FAT file in MMC card

2015-01-19 Thread Bo Shen

Hi Josh,

On 01/19/2015 03:06 PM, Josh Wu wrote:

This patch will save U-Boot environment as a file: uboot.env, in FAT partition
instead of in raw sector of MMC card.

This make us easier to manage the environment file.

Signed-off-by: Josh Wu 


Ackey-by: Bo Shen 


---

  include/configs/sama5d3xek.h | 10 ++
  1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/configs/sama5d3xek.h b/include/configs/sama5d3xek.h
index f2849d7..c29f25b 100644
--- a/include/configs/sama5d3xek.h
+++ b/include/configs/sama5d3xek.h
@@ -215,13 +215,15 @@
"bootm 0x2200 - 0x2100"
  #elif CONFIG_SYS_USE_MMC
  /* bootstrap + u-boot + env in sd card */
-#define CONFIG_ENV_IS_IN_MMC
-#define CONFIG_ENV_OFFSET  0x2000
-#define CONFIG_ENV_SIZE0x1000
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE


Nitpick:
Can you move in the following condition include?
--->8---
#if defined(CONFIG_CMD_USB) || defined(CONFIG_CMD_MMC)
#define CONFIG_CMD_FAT
#endif
---8<---


+#define FAT_ENV_INTERFACE  "mmc"
+#define FAT_ENV_FILE   "uboot.env"
+#define FAT_ENV_DEVICE_AND_PART"0"
+#define CONFIG_ENV_SIZE0x4000
  #define CONFIG_BOOTCOMMAND"fatload mmc 0:1 0x2100 dtb; " \
"fatload mmc 0:1 0x2200 uImage; " \
"bootm 0x2200 - 0x2100"
-#define CONFIG_SYS_MMC_ENV_DEV 0
  #else
  #define CONFIG_ENV_IS_NOWHERE
  #endif



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/3] ARM: at91: sama5d3_xplained: save environment in a FAT file in MMC card

2015-01-19 Thread Bo Shen

Hi Josh,

On 01/19/2015 03:06 PM, Josh Wu wrote:

This patch will save U-Boot environment as a file: uboot.env, in FAT partition
instead of saving it in raw sector of MMC card.

This make us easier to manage the environment file.

Signed-off-by: Josh Wu 


After you remove the duplicated definition.

Acked-by: Bo Shen 


---

  include/configs/sama5d3_xplained.h | 10 ++
  1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/configs/sama5d3_xplained.h 
b/include/configs/sama5d3_xplained.h
index d5588b1..a697035 100644
--- a/include/configs/sama5d3_xplained.h
+++ b/include/configs/sama5d3_xplained.h
@@ -169,13 +169,15 @@
"bootz 0x2200 - 0x2100"
  #elif CONFIG_SYS_USE_MMC
  /* bootstrap + u-boot + env in sd card */
-#define CONFIG_ENV_IS_IN_MMC
-#define CONFIG_ENV_OFFSET  0x2000
-#define CONFIG_ENV_SIZE0x1000
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE


This has been defined in
--->8---
#if defined(CONFIG_CMD_USB) || defined(CONFIG_CMD_MMC)
#define CONFIG_CMD_FAT
#define CONFIG_FAT_WRITE
---<8---


+#define FAT_ENV_INTERFACE  "mmc"
+#define FAT_ENV_FILE   "uboot.env"
+#define FAT_ENV_DEVICE_AND_PART"0"
+#define CONFIG_ENV_SIZE0x4000
  #define CONFIG_BOOTCOMMAND"fatload mmc 0:1 0x2100 
at91-sama5d3_xplained.dtb; " \
"fatload mmc 0:1 0x2200 zImage; " \
"bootz 0x2200 - 0x2100"
-#define CONFIG_SYS_MMC_ENV_DEV 0
  #else
  #define CONFIG_ENV_IS_NOWHERE
  #endif



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: atmel: at91sam9m10g45ek: enable SPL

2015-01-18 Thread Bo Shen

Hi Andreas,

On 01/16/2015 06:16 PM, Andreas Bießmann wrote:

Hi Bo,

On 01/16/2015 10:30 AM, Bo Shen wrote:

On 01/16/2015 05:10 PM, Andreas Bießmann wrote:

On 01/16/2015 03:53 AM, Bo Shen wrote:



--- a/arch/arm/cpu/arm926ejs/at91/Makefile
+++ b/arch/arm/cpu/arm926ejs/at91/Makefile
@@ -25,5 +25,9 @@ obj-y+= reset.o
   obj-y+= timer.o

   ifndef CONFIG_SKIP_LOWLEVEL_INIT
+ifdef CONFIG_SPL_BUILD
+obj-y+= spl_lowlevel_init.o
+else
   obj-y+= lowlevel_init.o
   endif
+endif


I'm fine with having two variants of lowlevel_init for a time, but we
should consolidate this and use C-style initialisation of SDRAM and
stuff for the other armv5 at91 devices in future. AFAIK the
a/a/c/arm926ejs/at91/lowlevel_init.S is mainly used for NOR Flash boots,
so using the SPL code (but not necessarily the two binary mechanism) for
the NOR Flash boots in future is appreciated.


OK, when all the arm9 at91 related board has SPL support, then I will do
this.


Can we achieve this in this MW?


I will try, but not sure. As I don't have this kind of board :(
I need to check whether we still have this kind of board.


+ENTRY(lowlevel_init)
+/*
+ * Setup a temporary stack
+ */
+ldrsp, =CONFIG_SYS_INIT_SP_ADDR
+bicsp, sp, #7 /* 8-byte alignment for ABI compliance */
+
+ldrr9, =gdata


I remember some patches removing the SPL gdata stuff, is that true?


Thanks.

Yes, just search for it, the following patch do this.
http://patchwork.ozlabs.org/patch/423789/ (arm: Reduce the scope of
lowlevel_init())


I think we should use the function provided there. What do you think?


OK. I will do it in next version.
Thanks.


Best regards

Andreas Bießmann



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: atmel: at91sam9m10g45ek: enable SPL

2015-01-18 Thread Bo Shen

Hi Heiko,

On 01/16/2015 07:35 PM, Heiko Schocher wrote:

Hello Bo

Am 16.01.2015 03:53, schrieb Bo Shen:

Supports boot up from NAND flash with software ECC eanbled.
And supports boot up from SD/MMC card with FAT file system.

As the boot from SD/MMC card with FAT file system, the BSS
segment is too big to fit into SRAM, so, use the lds to put
it into SDRAM. So, we need to initialize the SDRAM as soon
as possible. Borrow the low level init code from
 for this purpose.

As there is a little change, which need lowlevel init, so
also change taurus board based on at91sam9260, corvus board
based on at91sam9g45.
(CONFIG_SPL_STACK is replaced by CONFIG_SYS_INIT_SP_ADDR)

Signed-off-by: Bo Shen 
---

  arch/arm/Kconfig|  1 +
  arch/arm/cpu/arm926ejs/at91/Makefile|  4 ++
  arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S | 37 
  arch/arm/cpu/at91-common/spl_at91.c |  7 +--
  arch/arm/cpu/at91-common/u-boot-spl-arm9.lds| 48 +++
  board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80
+
  configs/at91sam9m10g45ek_mmc_defconfig  |  5 +-
  configs/at91sam9m10g45ek_nandflash_defconfig|  5 +-
  include/configs/at91sam9m10g45ek.h  | 65

  include/configs/corvus.h|  7 ++-
  include/configs/taurus.h|  7 ++-
  11 files changed, 256 insertions(+), 10 deletions(-)
  create mode 100644 arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
  create mode 100644 arch/arm/cpu/at91-common/u-boot-spl-arm9.lds


Acked-by: Heiko Schocher 


Thanks.


but it does not boot on the corvus board ... please add this fix to
your patch:

diff --git a/include/configs/corvus.h b/include/configs/corvus.h
index efc8ce5..dc25d95 100644
--- a/include/configs/corvus.h
+++ b/include/configs/corvus.h
@@ -90,7 +90,7 @@
  #define CONFIG_SYS_SDRAM_SIZE  0x0800

  #ifdef CONFIG_SPL_BUILD
-#define CONFIG_SYS_INIT_SP_ADDR0x31
+#define CONFIG_SYS_INIT_SP_ADDR(16 * 1024)
  #else
  #define CONFIG_SYS_INIT_SP_ADDR \
 (CONFIG_SYS_SDRAM_BASE + 4 * 1024 - GENERATED_GBL_DATA_SIZE)


Tested your patch also on the taurus board, there it boots fine!

so, after you fixed the corvus board, you can add my:
Tested-by: Heiko Schocher 


Thanks, I will add this fix into next version.


Thanks! And one question ...

[...]

diff --git a/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
b/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
new file mode 100644
index 000..f1b2ec9
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
@@ -0,0 +1,37 @@
+/*
+ * A lowlevel_init function that sets up the stack to call a C
function to
+ * perform further init.
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, 
+ *
+ * Author :
+ *Aneesh V
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+ENTRY(lowlevel_init)
+/*
+ * Setup a temporary stack
+ */
+ldrsp, =CONFIG_SYS_INIT_SP_ADDR


Could we use here a new define (saying CONFIG_SYS_INIT_SP_LOWLEVEL)?

Benefit would be, we can setup first the stack in sram, and after RAM
init, which is done with your patch very early, we can set the stack
with CONFIG_SYS_INIT_SP_ADDR into RAM!

With using CONFIG_SYS_INIT_SP_ADDR here, the stack gets set twice
to CONFIG_SYS_INIT_SP_ADDR ... I just try to get SPL on an atsam9260
based board working with only 4k sram ... so it would be nice to
have stack also optionally in RAM ... but we have problems with the
debugger adapter on the board ... so I have to wait some more days to
try this part ...


  This just for the at91sam9260 based boards, not for others. Or else, 
we also need to add this definition for other boards. Can you do the 
following check?


#ifdef CONFIG_SYS_INIT_SP_LOWLEVEL
ldr sp, =CONFIG_SYS_INIT_SP_LOWLEVEL
#else
ldr sp, =CONFIG_SYS_INIT_SP_ADDR
#endif

  If it is acceptable, can you add through your patches, as I my patch 
nowhere will use it.



bye,
Heiko


Best Regards,
Bo Shen

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


Re: [U-Boot] [PATCH] ARM: atmel: at91sam9m10g45ek: enable SPL

2015-01-16 Thread Bo Shen

Hi Andreas,

On 01/16/2015 05:10 PM, Andreas Bießmann wrote:

Hi Bo,

just a short review, more will follow this weekend.

On 01/16/2015 03:53 AM, Bo Shen wrote:

Supports boot up from NAND flash with software ECC eanbled.
And supports boot up from SD/MMC card with FAT file system.

As the boot from SD/MMC card with FAT file system, the BSS
segment is too big to fit into SRAM, so, use the lds to put
it into SDRAM. So, we need to initialize the SDRAM as soon
as possible. Borrow the low level init code from
 for this purpose.

As there is a little change, which need lowlevel init, so
also change taurus board based on at91sam9260, corvus board
based on at91sam9g45.
(CONFIG_SPL_STACK is replaced by CONFIG_SYS_INIT_SP_ADDR)

Signed-off-by: Bo Shen 
---

  arch/arm/Kconfig|  1 +
  arch/arm/cpu/arm926ejs/at91/Makefile|  4 ++
  arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S | 37 
  arch/arm/cpu/at91-common/spl_at91.c |  7 +--
  arch/arm/cpu/at91-common/u-boot-spl-arm9.lds| 48 +++
  board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80 +
  configs/at91sam9m10g45ek_mmc_defconfig  |  5 +-
  configs/at91sam9m10g45ek_nandflash_defconfig|  5 +-
  include/configs/at91sam9m10g45ek.h  | 65 
  include/configs/corvus.h|  7 ++-
  include/configs/taurus.h|  7 ++-
  11 files changed, 256 insertions(+), 10 deletions(-)
  create mode 100644 arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
  create mode 100644 arch/arm/cpu/at91-common/u-boot-spl-arm9.lds

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5eb1d03..f4788c6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -141,6 +141,7 @@ config TARGET_AT91SAM9263EK
  config TARGET_AT91SAM9M10G45EK
bool "Support at91sam9m10g45ek"
select CPU_ARM926EJS
+   select SUPPORT_SPL

  config TARGET_AT91SAM9N12EK
bool "Support at91sam9n12ek"
diff --git a/arch/arm/cpu/arm926ejs/at91/Makefile 
b/arch/arm/cpu/arm926ejs/at91/Makefile
index 698a28d..238434b 100644
--- a/arch/arm/cpu/arm926ejs/at91/Makefile
+++ b/arch/arm/cpu/arm926ejs/at91/Makefile
@@ -25,5 +25,9 @@ obj-y += reset.o
  obj-y += timer.o

  ifndef CONFIG_SKIP_LOWLEVEL_INIT
+ifdef CONFIG_SPL_BUILD
+obj-y  += spl_lowlevel_init.o
+else
  obj-y += lowlevel_init.o
  endif
+endif


I'm fine with having two variants of lowlevel_init for a time, but we
should consolidate this and use C-style initialisation of SDRAM and
stuff for the other armv5 at91 devices in future. AFAIK the
a/a/c/arm926ejs/at91/lowlevel_init.S is mainly used for NOR Flash boots,
so using the SPL code (but not necessarily the two binary mechanism) for
the NOR Flash boots in future is appreciated.


OK, when all the arm9 at91 related board has SPL support, then I will do 
this.



diff --git a/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S 
b/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
new file mode 100644
index 000..f1b2ec9
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
@@ -0,0 +1,37 @@
+/*
+ * A lowlevel_init function that sets up the stack to call a C function to
+ * perform further init.
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, 
+ *
+ * Author :
+ * Aneesh V
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+ENTRY(lowlevel_init)
+   /*
+* Setup a temporary stack
+*/
+   ldr sp, =CONFIG_SYS_INIT_SP_ADDR
+   bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
+
+   ldr r9, =gdata


I remember some patches removing the SPL gdata stuff, is that true?


Thanks.

Yes, just search for it, the following patch do this.
http://patchwork.ozlabs.org/patch/423789/ (arm: Reduce the scope of 
lowlevel_init())



+
+   /*
+* Save the old lr(passed in ip) and the current lr to stack
+*/
+   push{ip, lr}
+
+   /*
+* go setup pll, mux, memory
+*/
+   bl  s_init
+   pop {ip, pc}
+ENDPROC(lowlevel_init)


Rest of this patch will be reviewed later.


Thanks.


Best regards

Andreas Bießmann



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] mtd: atmel_nand: according to pmecc version to perform 0xff page correction

2015-01-15 Thread Bo Shen

Hi Josh,

On 01/16/2015 11:54 AM, Josh Wu wrote:

As the PMECC hardware has different version. In SAMA5D4 chip, the PMECC ip
can generate 0xff pmecc ECC value for all 0xff sector.

According to this, add PMECC version check, if it's SAMA5D4 then we always
let PMECC hardware to correct it.

Signed-off-by: Josh Wu 


except the nitpick.

Acked-by: Bo Shen 



---

  drivers/mtd/nand/atmel_nand.c |  9 +
  drivers/mtd/nand/atmel_nand_ecc.h | 20 
  2 files changed, 29 insertions(+)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 620b6e8..b16e3aa 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -44,6 +44,7 @@ struct atmel_nand_host {
u8  pmecc_corr_cap;
u16 pmecc_sector_size;
u32 pmecc_index_table_offset;
+   u32 pmecc_version;

int pmecc_bytes_per_sector;
int pmecc_sector_number;
@@ -486,6 +487,10 @@ static int pmecc_correction(struct mtd_info *mtd, u32 
pmecc_stat, uint8_t *buf,
int i, err_nbr, eccbytes;
uint8_t *buf_pos;

+   /* SAMA5D4 PMECC IP can correct errors for all 0xff page */
+   if (host->pmecc_version >= PMECC_VERSION_SAMA5D4)


I think we can hard coded here, then we can drop the definition in 
header file.



+   goto normal_check;
+
eccbytes = nand_chip->ecc.bytes;
for (i = 0; i < eccbytes; i++)
if (ecc[i] != 0xff)
@@ -961,6 +966,10 @@ static int atmel_pmecc_nand_init_params(struct nand_chip 
*nand,
nand->ecc.write_page = atmel_nand_pmecc_write_page;
nand->ecc.strength = cap;

+   /* Check the PMECC ip version */
+   host->pmecc_version = pmecc_readl(host->pmerrloc, version);
+   dev_dbg(host->dev, "PMECC IP version is: %x\n", host->pmecc_version);
+
atmel_pmecc_core_init(mtd);

return 0;
diff --git a/drivers/mtd/nand/atmel_nand_ecc.h 
b/drivers/mtd/nand/atmel_nand_ecc.h
index eac860d..b2d2682 100644
--- a/drivers/mtd/nand/atmel_nand_ecc.h
+++ b/drivers/mtd/nand/atmel_nand_ecc.h
@@ -123,6 +123,20 @@ struct pmecc_errloc_regs {
u32 sigma[25];  /* 0x28-0x88 Error Location Sigma Registers */
u32 el[24]; /* 0x8C-0xE8 Error Location Registers */
u32 reserved1[5];   /* 0xEC-0xFC Reserved */
+
+   /*
+* 0x100-0x1F8:
+*   Reserved for AT91SAM9X5, AT91SAM9N12.
+*   HSMC registers for SAMA5D3, SAMA5D4.
+*/


I think no need to add this.


+   u32 reserved2[63];
+
+   /*
+* 0x1FC:
+*   PMECC version for AT91SAM9X5, AT91SAM9N12.
+*   HSMC version for SAMA5D3, SAMA5D4. Can refer as PMECC version.
+*/


ditto.


+   u32 version;
  };

  /* For Error Location Configuration Register */
@@ -137,6 +151,12 @@ struct pmecc_errloc_regs {
  #define   PMERRLOC_ERR_NUM_MASK   (0x1f << 8)
  #define   PMERRLOC_CALC_DONE  (1 << 0)

+/* PMECC IP version */
+#define PMECC_VERSION_SAMA5D4  0x113
+#define PMECC_VERSION_SAMA5D3  0x112
+#define PMECC_VERSION_AT91SAM9N12  0x102


No where will use the upper three definitions, we can drop them.


+#define PMECC_VERSION_AT91SAM9X5   0x101


If hard coded, we can drop it also.


+
  /* Galois field dimension */
  #define PMECC_GF_DIMENSION_13 13
  #define PMECC_GF_DIMENSION_14 14



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ARM: atmel: switch to use common timer functions

2015-01-15 Thread Bo Shen
The commit 8dfafdd (Introduce common timer functions), add common
timer functions, we can use them directly.

Signed-off-by: Bo Shen 
---

 arch/arm/cpu/armv7/at91/timer.c  | 61 
 arch/arm/include/asm/arch-at91/sama5d3.h |  3 ++
 arch/arm/include/asm/arch-at91/sama5d4.h |  3 ++
 3 files changed, 6 insertions(+), 61 deletions(-)

diff --git a/arch/arm/cpu/armv7/at91/timer.c b/arch/arm/cpu/armv7/at91/timer.c
index 19bf80b..a4a3817 100644
--- a/arch/arm/cpu/armv7/at91/timer.c
+++ b/arch/arm/cpu/armv7/at91/timer.c
@@ -36,22 +36,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define TIMER_LOAD_VAL 0xf
 
-static inline unsigned long long tick_to_time(unsigned long long tick)
-{
-   tick *= CONFIG_SYS_HZ;
-   do_div(tick, gd->arch.timer_rate_hz);
-
-   return tick;
-}
-
-static inline unsigned long long usec_to_tick(unsigned long long usec)
-{
-   usec *= gd->arch.timer_rate_hz;
-   do_div(usec, 100);
-
-   return usec;
-}
-
 /*
  * Use the PITC in full 32 bit incrementing mode
  */
@@ -67,55 +51,10 @@ int timer_init(void)
 
gd->arch.timer_rate_hz = get_pit_clk_rate() / 16;
 
-   gd->arch.tbu = 0;
-   gd->arch.tbl = 0;
-
return 0;
 }
 
 /*
- * Get the current 64 bit timer tick count
- */
-unsigned long long get_ticks(void)
-{
-   at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT;
-
-   ulong now = readl(&pit->piir);
-
-   /* increment tbu if tbl has rolled over */
-   if (now < gd->arch.tbl)
-   gd->arch.tbu++;
-   gd->arch.tbl = now;
-   return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
-}
-
-void __udelay(unsigned long usec)
-{
-   unsigned long long start;
-   ulong tmo;
-
-   start = get_ticks();/* get current timestamp */
-   tmo = usec_to_tick(usec);   /* convert usecs to ticks */
-   while ((get_ticks() - start) < tmo)
-   ;   /* loop till time has passed */
-}
-
-/*
- * get_timer(base) can be used to check for timeouts or
- * to measure elasped time relative to an event:
- *
- * ulong start_time = get_timer(0) sets start_time to the current
- * time value.
- * get_timer(start_time) returns the time elapsed since then.
- *
- * The time is used in CONFIG_SYS_HZ units!
- */
-ulong get_timer(ulong base)
-{
-   return tick_to_time(get_ticks()) - base;
-}
-
-/*
  * Return the number of timer ticks per second.
  */
 ulong get_tbclk(void)
diff --git a/arch/arm/include/asm/arch-at91/sama5d3.h 
b/arch/arm/include/asm/arch-at91/sama5d3.h
index 227ba80..b749cb3 100644
--- a/arch/arm/include/asm/arch-at91/sama5d3.h
+++ b/arch/arm/include/asm/arch-at91/sama5d3.h
@@ -189,6 +189,9 @@
 #define PIO_SCDR_DIV   0x3fff
 #define CPU_HAS_PCR
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfe3c
+
 /*
  * PMECC table in ROM
  */
diff --git a/arch/arm/include/asm/arch-at91/sama5d4.h 
b/arch/arm/include/asm/arch-at91/sama5d4.h
index d851568..990846a 100644
--- a/arch/arm/include/asm/arch-at91/sama5d4.h
+++ b/arch/arm/include/asm/arch-at91/sama5d4.h
@@ -191,6 +191,9 @@
 #define cpu_is_sama5d44()  (cpu_is_sama5d4() && \
(get_extension_chip_id() == ARCH_EXID_SAMA5D44))
 
+/* Timer */
+#define CONFIG_SYS_TIMER_COUNTER   0xfe3c
+
 /*
  * No PMECC Galois table in ROM
  */
-- 
2.3.0.rc0

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


[U-Boot] [PATCH] ARM: atmel: cleanup: remove at91cap9 related code

2015-01-15 Thread Bo Shen
As the at91cap9adk board is removed by commit: b5508344
(ARM: remove broken "at91cap9adk" board), so the at91cap9
code is not used anymore, and also the document for
at91cap9 can not be found on www.atmel.com, so remove the
at91cap9 related code.

Signed-off-by: Bo Shen 
---

 arch/arm/cpu/arm926ejs/at91/Makefile |   1 -
 arch/arm/cpu/arm926ejs/at91/at91cap9_devices.c   | 189 ---
 arch/arm/include/asm/arch-at91/at91_pmc.h|   9 +-
 arch/arm/include/asm/arch-at91/at91cap9.h|  78 --
 arch/arm/include/asm/arch-at91/at91cap9_matrix.h | 129 
 arch/arm/include/asm/arch-at91/at91sam9_matrix.h |   2 -
 arch/arm/include/asm/arch-at91/hardware.h|   2 -
 drivers/video/atmel_lcdfb.c  |   2 +-
 8 files changed, 4 insertions(+), 408 deletions(-)
 delete mode 100644 arch/arm/cpu/arm926ejs/at91/at91cap9_devices.c
 delete mode 100644 arch/arm/include/asm/arch-at91/at91cap9.h
 delete mode 100644 arch/arm/include/asm/arch-at91/at91cap9_matrix.h

diff --git a/arch/arm/cpu/arm926ejs/at91/Makefile 
b/arch/arm/cpu/arm926ejs/at91/Makefile
index 698a28d..ddc323f 100644
--- a/arch/arm/cpu/arm926ejs/at91/Makefile
+++ b/arch/arm/cpu/arm926ejs/at91/Makefile
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
-obj-$(CONFIG_AT91CAP9) += at91cap9_devices.o
 obj-$(CONFIG_AT91SAM9260)  += at91sam9260_devices.o
 obj-$(CONFIG_AT91SAM9G20)  += at91sam9260_devices.o
 obj-$(CONFIG_AT91SAM9XE)   += at91sam9260_devices.o
diff --git a/arch/arm/cpu/arm926ejs/at91/at91cap9_devices.c 
b/arch/arm/cpu/arm926ejs/at91/at91cap9_devices.c
deleted file mode 100644
index 16eeca7..000
--- a/arch/arm/cpu/arm926ejs/at91/at91cap9_devices.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * (C) Copyright 2007-2008
- * Stelian Pop 
- * Lead Tech Design 
- *
- * (C) Copyright 2009
- * Daniel Gorsulowski 
- * esd electronic system design gmbh 
- *
- * SPDX-License-Identifier:GPL-2.0+
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-void at91_serial0_hw_init(void)
-{
-   at91_pmc_t  *pmc= (at91_pmc_t *) AT91_PMC_BASE;
-
-   at91_set_a_periph(AT91_PIO_PORTA, 22, 1);   /* TXD0 */
-   at91_set_a_periph(AT91_PIO_PORTA, 23, 0);   /* RXD0 */
-   writel(1 << AT91CAP9_ID_US0, &pmc->pcer);
-}
-
-void at91_serial1_hw_init(void)
-{
-   at91_pmc_t  *pmc= (at91_pmc_t *) AT91_PMC_BASE;
-
-   at91_set_a_periph(AT91_PIO_PORTD, 0, 1);/* TXD1 */
-   at91_set_a_periph(AT91_PIO_PORTD, 1, 0);/* RXD1 */
-   writel(1 << AT91CAP9_ID_US1, &pmc->pcer);
-}
-
-void at91_serial2_hw_init(void)
-{
-   at91_pmc_t  *pmc= (at91_pmc_t *) AT91_PMC_BASE;
-
-   at91_set_a_periph(AT91_PIO_PORTD, 2, 1);/* TXD2 */
-   at91_set_a_periph(AT91_PIO_PORTD, 3, 0);/* RXD2 */
-   writel(1 << AT91CAP9_ID_US2, &pmc->pcer);
-}
-
-void at91_serial3_hw_init(void)
-{
-   at91_pmc_t  *pmc= (at91_pmc_t *) AT91_PMC_BASE;
-
-   at91_set_a_periph(AT91_PIO_PORTC, 30, 0);   /* DRXD */
-   at91_set_a_periph(AT91_PIO_PORTC, 31, 1);   /* DTXD */
-   writel(1 << AT91_ID_SYS, &pmc->pcer);
-}
-
-void at91_serial_hw_init(void)
-{
-#ifdef CONFIG_USART0
-   at91_serial0_hw_init();
-#endif
-
-#ifdef CONFIG_USART1
-   at91_serial1_hw_init();
-#endif
-
-#ifdef CONFIG_USART2
-   at91_serial2_hw_init();
-#endif
-
-#ifdef CONFIG_USART3   /* DBGU */
-   at91_serial3_hw_init();
-#endif
-}
-
-#ifdef CONFIG_HAS_DATAFLASH
-void at91_spi0_hw_init(unsigned long cs_mask)
-{
-   at91_pmc_t  *pmc= (at91_pmc_t *) AT91_PMC_BASE;
-
-   at91_set_b_periph(AT91_PIO_PORTA, 0, 0);/* SPI0_MISO */
-   at91_set_b_periph(AT91_PIO_PORTA, 1, 0);/* SPI0_MOSI */
-   at91_set_b_periph(AT91_PIO_PORTA, 2, 0);/* SPI0_SPCK */
-
-   /* Enable clock */
-   writel(1 << AT91CAP9_ID_SPI0, &pmc->pcer);
-
-   if (cs_mask & (1 << 0)) {
-   at91_set_b_periph(AT91_PIO_PORTA, 5, 1);
-   }
-   if (cs_mask & (1 << 1)) {
-   at91_set_b_periph(AT91_PIO_PORTA, 3, 1);
-   }
-   if (cs_mask & (1 << 2)) {
-   at91_set_b_periph(AT91_PIO_PORTD, 0, 1);
-   }
-   if (cs_mask & (1 << 3)) {
-   at91_set_b_periph(AT91_PIO_PORTD, 1, 1);
-   }
-   if (cs_mask & (1 << 4)) {
-   at91_set_pio_output(AT91_PIO_PORTA, 5, 1);
-   }
-   if (cs_mask & (1 << 5)) {
-   at91_set_pio_output(AT91_PIO_PORTA, 3, 1);
-   }
-   if (cs_mask & (1 << 6)) {
-   at91_set_pio_output(AT91_PIO_PORTD, 0, 1);
-   }
-   if (cs_mask & (1 << 7)) {
-   at91_set_pio_output(AT91_PIO_PORTD, 1, 1);
-   }
-}
-
-void at

[U-Boot] [PATCH] ARM: atmel: at91sam9m10g45ek: enable SPL

2015-01-15 Thread Bo Shen
Supports boot up from NAND flash with software ECC eanbled.
And supports boot up from SD/MMC card with FAT file system.

As the boot from SD/MMC card with FAT file system, the BSS
segment is too big to fit into SRAM, so, use the lds to put
it into SDRAM. So, we need to initialize the SDRAM as soon
as possible. Borrow the low level init code from
 for this purpose.

As there is a little change, which need lowlevel init, so
also change taurus board based on at91sam9260, corvus board
based on at91sam9g45.
(CONFIG_SPL_STACK is replaced by CONFIG_SYS_INIT_SP_ADDR)

Signed-off-by: Bo Shen 
---

 arch/arm/Kconfig|  1 +
 arch/arm/cpu/arm926ejs/at91/Makefile|  4 ++
 arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S | 37 
 arch/arm/cpu/at91-common/spl_at91.c |  7 +--
 arch/arm/cpu/at91-common/u-boot-spl-arm9.lds| 48 +++
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80 +
 configs/at91sam9m10g45ek_mmc_defconfig  |  5 +-
 configs/at91sam9m10g45ek_nandflash_defconfig|  5 +-
 include/configs/at91sam9m10g45ek.h  | 65 
 include/configs/corvus.h|  7 ++-
 include/configs/taurus.h|  7 ++-
 11 files changed, 256 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
 create mode 100644 arch/arm/cpu/at91-common/u-boot-spl-arm9.lds

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5eb1d03..f4788c6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -141,6 +141,7 @@ config TARGET_AT91SAM9263EK
 config TARGET_AT91SAM9M10G45EK
bool "Support at91sam9m10g45ek"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_AT91SAM9N12EK
bool "Support at91sam9n12ek"
diff --git a/arch/arm/cpu/arm926ejs/at91/Makefile 
b/arch/arm/cpu/arm926ejs/at91/Makefile
index 698a28d..238434b 100644
--- a/arch/arm/cpu/arm926ejs/at91/Makefile
+++ b/arch/arm/cpu/arm926ejs/at91/Makefile
@@ -25,5 +25,9 @@ obj-y += reset.o
 obj-y  += timer.o
 
 ifndef CONFIG_SKIP_LOWLEVEL_INIT
+ifdef CONFIG_SPL_BUILD
+obj-y  += spl_lowlevel_init.o
+else
 obj-y  += lowlevel_init.o
 endif
+endif
diff --git a/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S 
b/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
new file mode 100644
index 000..f1b2ec9
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
@@ -0,0 +1,37 @@
+/*
+ * A lowlevel_init function that sets up the stack to call a C function to
+ * perform further init.
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, 
+ *
+ * Author :
+ * Aneesh V
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+ENTRY(lowlevel_init)
+   /*
+* Setup a temporary stack
+*/
+   ldr sp, =CONFIG_SYS_INIT_SP_ADDR
+   bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
+
+   ldr r9, =gdata
+
+   /*
+* Save the old lr(passed in ip) and the current lr to stack
+*/
+   push{ip, lr}
+
+   /*
+* go setup pll, mux, memory
+*/
+   bl  s_init
+   pop {ip, pc}
+ENDPROC(lowlevel_init)
diff --git a/arch/arm/cpu/at91-common/spl_at91.c 
b/arch/arm/cpu/at91-common/spl_at91.c
index 89f588b..04abc29 100644
--- a/arch/arm/cpu/at91-common/spl_at91.c
+++ b/arch/arm/cpu/at91-common/spl_at91.c
@@ -67,11 +67,12 @@ void __weak matrix_init(void)
 {
 }
 
-void __weak at91_spl_board_init(void)
+void spl_board_init(void)
 {
+   at91_spl_board_init();
 }
 
-void spl_board_init(void)
+void s_init(void)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
@@ -119,6 +120,4 @@ void spl_board_init(void)
preloader_console_init();
 
mem_init();
-
-   at91_spl_board_init();
 }
diff --git a/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds 
b/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds
new file mode 100644
index 000..6f350a9
--- /dev/null
+++ b/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 Atmel Corporation
+ *   Bo Shen 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \
+   LENGTH = CONFIG_SPL_MAX_SIZE }
+MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
+   LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+   .text  :
+   {
+   __start = .;
+   *(.vectors)
+   arch/arm/cpu/arm926ejs/start.o  (.text*)
+   *(.text*)
+   } >.sram
+
+   . = ALIGN(4);
+   .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
+
+   . = ALIGN(4);
+   .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
+
+  

[U-Boot] [PATCH] Makefile: clean boot.bin

2015-01-14 Thread Bo Shen
When build for Atmel related boards which support SPL,
it will generate boot.bin, also clean when it when do
"make clean" operation.

Signed-off-by: Bo Shen 
---

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 36a9a28..ea5ae8f 100644
--- a/Makefile
+++ b/Makefile
@@ -1278,7 +1278,7 @@ CLEAN_DIRS  += $(MODVERDIR) \
$(filter-out include, $(shell ls -1 $d 2>/dev/null
 
 CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
-  u-boot* MLO* SPL System.map
+  boot* u-boot* MLO* SPL System.map
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include/generated spl tpl \
-- 
2.3.0.rc0

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


Re: [U-Boot] [PATCH v3 2/9] sf: Update Atmel flash params

2015-01-09 Thread Bo Shen

Hi Meng,

On 12/10/2014 08:51 PM, Bin Meng wrote:

Update flash sector size to 4KiB as long as flash supports sector
erase (20h) command. Correct AT25DF321 JEDEC ID and bulk erase
command to 50h instead of D8h. Also add AT25DF321A params per
datasheet.

Signed-off-by: Bin Meng 
---

  drivers/mtd/spi/sf_internal.h |  5 +
  drivers/mtd/spi/sf_params.c   | 17 +
  drivers/mtd/spi/sf_probe.c|  4 
  3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 785f7a9..8010fc5 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -106,6 +106,11 @@ enum {
  #define SPI_FLASH_PAGE_ERASE_TIMEOUT  (5 * CONFIG_SYS_HZ)
  #define SPI_FLASH_SECTOR_ERASE_TIMEOUT(10 * CONFIG_SYS_HZ)

+/* Atmel specific */
+#ifdef CONFIG_SPI_FLASH_ATMEL
+# define CMD_ATMEL_BLK_ERASE   0x50
+#endif
+
  /* SST specific */
  #ifdef CONFIG_SPI_FLASH_SST
  # define CMD_SST_BP   0x02/* Byte Program */
diff --git a/drivers/mtd/spi/sf_params.c b/drivers/mtd/spi/sf_params.c
index 5482700..cc4cd60 100644
--- a/drivers/mtd/spi/sf_params.c
+++ b/drivers/mtd/spi/sf_params.c
@@ -15,14 +15,15 @@
  /* SPI/QSPI flash device params structure */
  const struct spi_flash_params spi_flash_params_table[] = {
  #ifdef CONFIG_SPI_FLASH_ATMEL /* ATMEL */
-   {"AT45DB011D",   0x1f2200, 0x0,   64 * 1024, 4, 
RD_NORM,  SECT_4K},
-   {"AT45DB021D",   0x1f2300, 0x0,   64 * 1024, 8, 
RD_NORM,  SECT_4K},
-   {"AT45DB041D",   0x1f2400, 0x0,   64 * 1024, 8, 
RD_NORM,  SECT_4K},
-   {"AT45DB081D",   0x1f2500, 0x0,   64 * 1024,16, 
RD_NORM,  SECT_4K},
-   {"AT45DB161D",   0x1f2600, 0x0,   64 * 1024,32, 
RD_NORM,  SECT_4K},
-   {"AT45DB321D",   0x1f2700, 0x0,   64 * 1024,64, 
RD_NORM,  SECT_4K},
-   {"AT45DB641D",   0x1f2800, 0x0,   64 * 1024,   128, 
RD_NORM,  SECT_4K},
-   {"AT25DF321",  0x1f4701, 0x0, 64 * 1024,64, RD_NORM,
  SECT_4K},
+   {"AT45DB011D",   0x1f2200, 0x0,2 * 1024,64, 
RD_NORM,0},
+   {"AT45DB021D",   0x1f2300, 0x0,2 * 1024,   128, 
RD_NORM,0},
+   {"AT45DB041D",   0x1f2400, 0x0,2 * 1024,   256, 
RD_NORM,0},
+   {"AT45DB081D",   0x1f2500, 0x0,2 * 1024,   512, 
RD_NORM,0},
+   {"AT45DB161D",   0x1f2600, 0x0,4 * 1024,   512, 
RD_NORM,0},
+   {"AT45DB321D",   0x1f2700, 0x0,4 * 1024,  1024, 
RD_NORM,0},


In datasheet, the id is 0x1f2701. Doc number is: 3597Q-DFLASH-6/11. I 
can not find any new datasheet.


And I test on at91sam9m10g45ek board, it also read as this ID (0x1f2701).

So, if you plan to send new version, can you help add this ID? If not, 
maybe follow up patch will be better.


Thanks.


+   {"AT45DB641D",   0x1f2800, 0x0,2 * 1024,  4096, 
RD_NORM,0},
+   {"AT25DF321",  0x1f4700, 0x0,  4 * 1024,  1024, RD_NORM,
  SECT_4K},
+   {"AT25DF321A", 0x1f4701, 0x0,  4 * 1024,  1024, RD_NORM,
  SECT_4K},
  #endif
  #ifdef CONFIG_SPI_FLASH_EON   /* EON */
{"EN25Q32B", 0x1c3016, 0x0,   64 * 1024,64, RD_NORM,
0},
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index ce9987f..13fda44 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -179,7 +179,11 @@ static int spi_flash_validate_params(struct spi_slave 
*spi, u8 *idcode,
flash->erase_cmd = CMD_ERASE_32K;
flash->erase_size = 32768 << flash->shift;
} else {
+#ifdef CONFIG_SPI_FLASH_ATMEL
+       flash->erase_cmd = CMD_ATMEL_BLK_ERASE;
+#else
flash->erase_cmd = CMD_ERASE_64K;
+#endif
flash->erase_size = flash->sector_size;
}




Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/3] ARM: atmel: sama5d4 xplained: fix the LCD parameters

2015-01-07 Thread Bo Shen
Correct the LCD pixel clock, remove unused vsync parameter,
and also correct the include file.

Signed-off-by: Bo Shen 
---

 board/atmel/sama5d4_xplained/sama5d4_xplained.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c 
b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
index de0baad..2758c5c 100644
--- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c
+++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
@@ -14,7 +14,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -109,10 +109,8 @@ static void sama5d4_xplained_usb_hw_init(void)
 vidinfo_t panel_info = {
.vl_col = 480,
.vl_row = 272,
-   .vl_clk = 9000,
-   .vl_sync = ATMEL_LCDC_INVLINE_NORMAL | ATMEL_LCDC_INVFRAME_NORMAL,
+   .vl_clk = 900,
.vl_bpix = LCD_BPP,
-   .vl_bpox = LCD_OUTPUT_BPP,
.vl_tft = 1,
.vl_hsync_len = 41,
.vl_left_margin = 2,
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH 3/3] ARM: atmel: sama5d3xek: fix the LCD parameters

2015-01-07 Thread Bo Shen
Remove unused vsync parameter, and correct the include file.

Signed-off-by: Bo Shen 
---

 board/atmel/sama5d3xek/sama5d3xek.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/board/atmel/sama5d3xek/sama5d3xek.c 
b/board/atmel/sama5d3xek/sama5d3xek.c
index ca4f79d..cf6ed8b 100644
--- a/board/atmel/sama5d3xek/sama5d3xek.c
+++ b/board/atmel/sama5d3xek/sama5d3xek.c
@@ -15,7 +15,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -146,7 +146,6 @@ vidinfo_t panel_info = {
.vl_col = 800,
.vl_row = 480,
.vl_clk = 2400,
-   .vl_sync = ATMEL_LCDC_INVLINE_NORMAL | ATMEL_LCDC_INVFRAME_NORMAL,
.vl_bpix = LCD_BPP,
.vl_tft = 1,
.vl_hsync_len = 128,
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH 2/3] ARM: atmel: sama5d4xek: fix the LCD parameters

2015-01-07 Thread Bo Shen
Remove unused vsync parameter, and correct the include file.

Signed-off-by: Bo Shen 
---

 board/atmel/sama5d4ek/sama5d4ek.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/board/atmel/sama5d4ek/sama5d4ek.c 
b/board/atmel/sama5d4ek/sama5d4ek.c
index f8394f5..d3039c0 100644
--- a/board/atmel/sama5d4ek/sama5d4ek.c
+++ b/board/atmel/sama5d4ek/sama5d4ek.c
@@ -14,7 +14,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -111,7 +111,6 @@ vidinfo_t panel_info = {
.vl_col = 800,
.vl_row = 480,
.vl_clk = 3326,
-   .vl_sync = ATMEL_LCDC_INVLINE_NORMAL | ATMEL_LCDC_INVFRAME_NORMAL,
.vl_bpix = LCD_BPP,
.vl_tft = 1,
.vl_hsync_len = 5,
-- 
2.1.0.24.g4109c28

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


Re: [U-Boot] [RFC PATCH] ARM: atmel: at91sam9m10g45ek: enable SPL

2015-01-05 Thread Bo Shen

Hi Heiko,

On 01/05/2015 03:59 PM, Heiko Schocher wrote:

+#ifdef CONFIG_SKIP_LOWLEVEL_INIT
  void spl_board_init(void)
+#else
+void s_init(void)
+#endif
  {
  struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;


... and adding this "ifdefs" could be prevented ...

What do you think?

Ah! you wrote:

 > As the boot from SD/MMC card with FAT file system, the BSS
 > segment is too big to fit into SRAM, so, use the lds to put
 > it into SDRAM. So, we need to initialize the SDRAM as soon
 > as possible. Borrow the low level init code from
 >  for this purpose.

Hmm... maybe we can include this in the existing code? So we


The existed code is located in  directory, I think 
it is difficult to include it.


I think we can put it into  directory, I am not 
sure it will help others. As other SoC has low level init code. Or, as 
the patch, put it into  directory for at91 
series only.



have BSS for all at91 boards in RAM?


It depends, we still can put the BSS into SRAM use the common 
u-boot-spl.lds.

Only put BSS into SDRAM/DDR, when use u-boot-spl-arm9.lds.



Or, if not possible, we should convert the existing boards into
your framework ... if you can prepare such a patch I can test it
on  the corvus, taurus and axm boards ...


If the upper method for low level initialize code is chosen, I will 
prepare such patch for the boards you mentioned.



bye,
Heiko


Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH] ARM: atmel: at91sam9m10g45ek: enable SPL

2014-12-28 Thread Bo Shen
Supports boot up from NAND flash with software ECC eanbled.
And supports boot up from SD/MMC card with FAT file system.

As the boot from SD/MMC card with FAT file system, the BSS
segment is too big to fit into SRAM, so, use the lds to put
it into SDRAM. So, we need to initialize the SDRAM as soon
as possible. Borrow the low level init code from
 for this purpose.

Signed-off-by: Bo Shen 
---

 arch/arm/Kconfig|  1 +
 arch/arm/cpu/arm926ejs/at91/Makefile|  4 ++
 arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S | 37 
 arch/arm/cpu/at91-common/spl_at91.c | 10 
 arch/arm/cpu/at91-common/u-boot-spl-arm9.lds| 48 +++
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 80 +
 configs/at91sam9m10g45ek_mmc_defconfig  |  5 +-
 configs/at91sam9m10g45ek_nandflash_defconfig|  5 +-
 include/configs/at91sam9m10g45ek.h  | 64 
 9 files changed, 250 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
 create mode 100644 arch/arm/cpu/at91-common/u-boot-spl-arm9.lds

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5eb1d03..f4788c6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -141,6 +141,7 @@ config TARGET_AT91SAM9263EK
 config TARGET_AT91SAM9M10G45EK
bool "Support at91sam9m10g45ek"
select CPU_ARM926EJS
+   select SUPPORT_SPL
 
 config TARGET_AT91SAM9N12EK
bool "Support at91sam9n12ek"
diff --git a/arch/arm/cpu/arm926ejs/at91/Makefile 
b/arch/arm/cpu/arm926ejs/at91/Makefile
index 698a28d..238434b 100644
--- a/arch/arm/cpu/arm926ejs/at91/Makefile
+++ b/arch/arm/cpu/arm926ejs/at91/Makefile
@@ -25,5 +25,9 @@ obj-y += reset.o
 obj-y  += timer.o
 
 ifndef CONFIG_SKIP_LOWLEVEL_INIT
+ifdef CONFIG_SPL_BUILD
+obj-y  += spl_lowlevel_init.o
+else
 obj-y  += lowlevel_init.o
 endif
+endif
diff --git a/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S 
b/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
new file mode 100644
index 000..f1b2ec9
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/at91/spl_lowlevel_init.S
@@ -0,0 +1,37 @@
+/*
+ * A lowlevel_init function that sets up the stack to call a C function to
+ * perform further init.
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, 
+ *
+ * Author :
+ * Aneesh V
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+ENTRY(lowlevel_init)
+   /*
+* Setup a temporary stack
+*/
+   ldr sp, =CONFIG_SYS_INIT_SP_ADDR
+   bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
+
+   ldr r9, =gdata
+
+   /*
+* Save the old lr(passed in ip) and the current lr to stack
+*/
+   push{ip, lr}
+
+   /*
+* go setup pll, mux, memory
+*/
+   bl  s_init
+   pop {ip, pc}
+ENDPROC(lowlevel_init)
diff --git a/arch/arm/cpu/at91-common/spl_at91.c 
b/arch/arm/cpu/at91-common/spl_at91.c
index 89f588b..f044117 100644
--- a/arch/arm/cpu/at91-common/spl_at91.c
+++ b/arch/arm/cpu/at91-common/spl_at91.c
@@ -71,7 +71,17 @@ void __weak at91_spl_board_init(void)
 {
 }
 
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+__weak void spl_board_init(void)
+{
+}
+#endif
+
+#ifdef CONFIG_SKIP_LOWLEVEL_INIT
 void spl_board_init(void)
+#else
+void s_init(void)
+#endif
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
diff --git a/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds 
b/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds
new file mode 100644
index 000..6f350a9
--- /dev/null
+++ b/arch/arm/cpu/at91-common/u-boot-spl-arm9.lds
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 Atmel Corporation
+ *   Bo Shen 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \
+   LENGTH = CONFIG_SPL_MAX_SIZE }
+MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
+   LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+   .text  :
+   {
+   __start = .;
+   *(.vectors)
+   arch/arm/cpu/arm926ejs/start.o  (.text*)
+   *(.text*)
+   } >.sram
+
+   . = ALIGN(4);
+   .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
+
+   . = ALIGN(4);
+   .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
+
+   . = ALIGN(4);
+   __image_copy_end = .;
+
+   .end :
+   {
+   *(.__end)
+   } >.sram
+
+   .bss :
+   {
+   . = ALIGN(4);
+   __bss_start = .;
+   *(.bss*)
+   . = ALIGN(4);
+   __bss_end = .;
+   } >.sdram
+}
diff --git a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c 
b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c

Re: [U-Boot] [PATCH] ARM: remove redudant information from Kconfig files

2014-12-18 Thread Bo Shen

Hi Masahiro Yamada,

On 12/19/2014 01:27 PM, Masahiro Yamada wrote:

  - "string" type for SYS_* is defined in arch/Kconfig
  - SYS_CPU "armv7" has been replaced with "select CPU_V7"
  - SYS_SOC "tegra124" is already defined in tegra124/Kconfig

Signed-off-by: Masahiro Yamada 


For sama5d4ek and sama5d4 xplained board.
Acked-by: Bo Shen 


---

  board/atmel/sama5d4_xplained/Kconfig |  3 ---
  board/atmel/sama5d4ek/Kconfig|  3 ---
  board/nvidia/nyan-big/Kconfig| 12 
  board/samsung/smdk5420/Kconfig   |  3 ---
  board/st/stv0991/Kconfig |  8 
  board/sunxi/Kconfig  |  1 -
  6 files changed, 30 deletions(-)

diff --git a/board/atmel/sama5d4_xplained/Kconfig 
b/board/atmel/sama5d4_xplained/Kconfig
index f6440c0..f320a68 100644
--- a/board/atmel/sama5d4_xplained/Kconfig
+++ b/board/atmel/sama5d4_xplained/Kconfig
@@ -1,8 +1,5 @@
  if TARGET_SAMA5D4_XPLAINED

-config SYS_CPU
-   default "armv7"
-
  config SYS_BOARD
default "sama5d4_xplained"

diff --git a/board/atmel/sama5d4ek/Kconfig b/board/atmel/sama5d4ek/Kconfig
index a889895..7dc569c 100644
--- a/board/atmel/sama5d4ek/Kconfig
+++ b/board/atmel/sama5d4ek/Kconfig
@@ -1,8 +1,5 @@
  if TARGET_SAMA5D4EK

-config SYS_CPU
-   default "armv7"
-
  config SYS_BOARD
default "sama5d4ek"

diff --git a/board/nvidia/nyan-big/Kconfig b/board/nvidia/nyan-big/Kconfig
index 6c42bb9..341c8d7 100644
--- a/board/nvidia/nyan-big/Kconfig
+++ b/board/nvidia/nyan-big/Kconfig
@@ -1,24 +1,12 @@
  if TARGET_NYAN_BIG

-config SYS_CPU
-   string
-   default "arm720t" if SPL_BUILD
-   default "armv7" if !SPL_BUILD
-
  config SYS_BOARD
-   string
default "nyan-big"

  config SYS_VENDOR
-   string
default "nvidia"

-config SYS_SOC
-   string
-   default "tegra124"
-
  config SYS_CONFIG_NAME
-   string
default "nyan-big"

  endif
diff --git a/board/samsung/smdk5420/Kconfig b/board/samsung/smdk5420/Kconfig
index e7aafe5..2f382cd 100644
--- a/board/samsung/smdk5420/Kconfig
+++ b/board/samsung/smdk5420/Kconfig
@@ -1,15 +1,12 @@
  if TARGET_PEACH_PI

  config SYS_BOARD
-   string
default "smdk5420"

  config SYS_VENDOR
-   string
default "samsung"

  config SYS_CONFIG_NAME
-   string
default "peach-pi"

  endif
diff --git a/board/st/stv0991/Kconfig b/board/st/stv0991/Kconfig
index 8bda349..007712f 100644
--- a/board/st/stv0991/Kconfig
+++ b/board/st/stv0991/Kconfig
@@ -1,23 +1,15 @@
  if TARGET_STV0991

-config SYS_CPU
-   string
-   default "armv7"
-
  config SYS_BOARD
-   string
default "stv0991"

  config SYS_VENDOR
-   string
default "st"

  config SYS_SOC
-   string
default "stv0991"

  config SYS_CONFIG_NAME
-   string
default "stv0991"

  endif
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 246cd9a..5ae491d 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -33,7 +33,6 @@ config MACH_SUN8I
  endchoice

  config SYS_CONFIG_NAME
-   string
default "sun4i" if MACH_SUN4I
default "sun5i" if MACH_SUN5I
default "sun6i" if MACH_SUN6I



Best Regards,
Bo Shen
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] USB: gadget: atmel_usba_udc: fix transfer hang issue

2014-12-15 Thread Bo Shen
When receive data, the RXRDY in status register set by hardware
after a new packet has been stored in the endpoint FIFO. After,
we copy from FIFO, we clear it, make the FIFO can be accessed
again.
In the receive_data() function, this bit RXRDY has been cleared.
So, after the receive_data() function return, this bit should
not be cleared again, or else it will cause the accessing FIFO
corrupt, which will make the data loss.

Signed-off-by: Bo Shen 
---

 drivers/usb/gadget/atmel_usba_udc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
b/drivers/usb/gadget/atmel_usba_udc.c
index 12628ef..fbc74f3 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1062,7 +1062,6 @@ static void usba_ep_irq(struct usba_udc *udc, struct 
usba_ep *ep)
if ((epstatus & epctrl) & USBA_RX_BK_RDY) {
DBG(DBG_BUS, "%s: RX data ready\n", ep->ep.name);
receive_data(ep);
-   usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY);
}
 }
 
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH v2 09/13] ARM: atmel: sama5d4: add interrupt redirec function

2014-12-14 Thread Bo Shen
Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/cpu/armv7/at91/sama5d4_devices.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/cpu/armv7/at91/sama5d4_devices.c 
b/arch/arm/cpu/armv7/at91/sama5d4_devices.c
index 9c63e99..ef39cb7 100644
--- a/arch/arm/cpu/armv7/at91/sama5d4_devices.c
+++ b/arch/arm/cpu/armv7/at91/sama5d4_devices.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 char *get_cpu_name()
@@ -78,4 +79,15 @@ void matrix_init(void)
writel(ATMEL_MATRIX_WPMR_WPKEY | ATMEL_MATRIX_WPMR_WPEN, &h64mx->wpmr);
writel(ATMEL_MATRIX_WPMR_WPKEY | ATMEL_MATRIX_WPMR_WPEN, &h32mx->wpmr);
 }
+
+void redirect_int_from_saic_to_aic(void)
+{
+   struct atmel_sfr *sfr = (struct atmel_sfr *)ATMEL_BASE_SFR;
+   u32 key32;
+
+   if (!(readl(&sfr->aicredir) & ATMEL_SFR_AICREDIR_NSAIC)) {
+   key32 = readl(&sfr->sn1) ^ ATMEL_SFR_AICREDIR_KEY;
+   writel((key32 | ATMEL_SFR_AICREDIR_NSAIC), &sfr->aicredir);
+   }
+}
 #endif
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH v2 12/13] ARM: atmel: sama5d4ek: enable SPL support

2014-12-14 Thread Bo Shen
The sama5d4ek support boot up from NAND flash, SD/MMC card and
also the SPI flash.

Signed-off-by: Bo Shen 
---

Changes in v2:
- change CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION to 
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION

 arch/arm/Kconfig  |  1 +
 board/atmel/sama5d4ek/sama5d4ek.c | 85 +++
 configs/sama5d4ek_mmc_defconfig   |  1 +
 configs/sama5d4ek_nandflash_defconfig |  1 +
 configs/sama5d4ek_spiflash_defconfig  |  1 +
 include/configs/sama5d4ek.h   | 56 +++
 6 files changed, 145 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 2b0d2c9..9a39e09 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -522,6 +522,7 @@ config TARGET_SAMA5D4_XPLAINED
 config TARGET_SAMA5D4EK
bool "Support sama5d4ek"
select CPU_V7
+   select SUPPORT_SPL
 
 config TARGET_BCM28155_AP
bool "Support bcm28155_ap"
diff --git a/board/atmel/sama5d4ek/sama5d4ek.c 
b/board/atmel/sama5d4ek/sama5d4ek.c
index e014e0a..f8cff68 100644
--- a/board/atmel/sama5d4ek/sama5d4ek.c
+++ b/board/atmel/sama5d4ek/sama5d4ek.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -326,3 +327,87 @@ int board_eth_init(bd_t *bis)
 
return rc;
 }
+
+/* SPL */
+#ifdef CONFIG_SPL_BUILD
+void spl_board_init(void)
+{
+#ifdef CONFIG_SYS_USE_MMC
+   sama5d4ek_mci1_hw_init();
+#elif CONFIG_SYS_USE_NANDFLASH
+   sama5d4ek_nand_hw_init();
+#elif CONFIG_SYS_USE_SERIALFLASH
+   sama5d4ek_spi0_hw_init();
+#endif
+}
+
+static void ddr2_conf(struct atmel_mpddr *ddr2)
+{
+   ddr2->md = (ATMEL_MPDDRC_MD_DBW_32_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+   ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+   ATMEL_MPDDRC_CR_NR_ROW_14 |
+   ATMEL_MPDDRC_CR_CAS_DDR_CAS3 |
+   ATMEL_MPDDRC_CR_NB_8BANKS |
+   ATMEL_MPDDRC_CR_NDQS_DISABLED |
+   ATMEL_MPDDRC_CR_DECOD_INTERLEAVED |
+   ATMEL_MPDDRC_CR_UNAL_SUPPORTED);
+
+   ddr2->rtr = 0x2b0;
+
+   ddr2->tpr0 = (8 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |
+ 3 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET |
+ 3 << ATMEL_MPDDRC_TPR0_TWR_OFFSET |
+ 10 << ATMEL_MPDDRC_TPR0_TRC_OFFSET |
+ 3 << ATMEL_MPDDRC_TPR0_TRP_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET);
+
+   ddr2->tpr1 = (2 << ATMEL_MPDDRC_TPR1_TXP_OFFSET |
+ 200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET |
+ 25 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET |
+ 23 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET);
+
+   ddr2->tpr2 = (7 << ATMEL_MPDDRC_TPR2_TFAW_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET |
+ 3 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET |
+ 8 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET);
+}
+
+void mem_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   struct atmel_mpddr ddr2;
+
+   ddr2_conf(&ddr2);
+
+   /* enable MPDDR clock */
+   at91_periph_clk_enable(ATMEL_ID_MPDDRC);
+   writel(0x4, &pmc->scer);
+
+   /* DDRAM2 Controller initialize */
+   ddr2_init(ATMEL_BASE_DDRCS, &ddr2);
+}
+
+void at91_pmc_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   u32 tmp;
+
+   tmp = AT91_PMC_PLLAR_29 |
+ AT91_PMC_PLLXR_PLLCOUNT(0x3f) |
+ AT91_PMC_PLLXR_MUL(87) |
+ AT91_PMC_PLLXR_DIV(1);
+   at91_plla_init(tmp);
+
+   writel(0x0 << 8, &pmc->pllicpr);
+
+   tmp = AT91_PMC_MCKR_H32MXDIV |
+ AT91_PMC_MCKR_PLLADIV_2 |
+ AT91_PMC_MCKR_MDIV_3 |
+ AT91_PMC_MCKR_CSS_PLLA;
+   at91_mck_init(tmp);
+}
+#endif
diff --git a/configs/sama5d4ek_mmc_defconfig b/configs/sama5d4ek_mmc_defconfig
index 16a5ed7..aafb4c2 100644
--- a/configs/sama5d4ek_mmc_defconfig
+++ b/configs/sama5d4ek_mmc_defconfig
@@ -1,3 +1,4 @@
+CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="SAMA5D4,SYS_USE_MMC"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SAMA5D4EK=y
diff --git a/configs/sama5d4ek_nandflash_defconfig 
b/configs/sama5d4ek_nandflash_defconfig
index 8b7fbc3..d430fa7 100644
--- a/configs/sama5d4ek_nandflash_defconfig
+++ b/configs/sama5d4ek_nandflash_defconfig
@@ -1,3 +1,4 @@
+CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="SAMA5D4,SYS_USE_NANDFLASH"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SAMA5D4EK=y
diff --git a/configs/sama5d4ek_spiflash_defconfig 
b/configs/sama5d4ek_spiflash_defconfig
index 63e9b6c..796fa4b 100644
--- a/configs/sama5d4ek_spifla

[U-Boot] [PATCH v2 13/13] ARM: atmel: sama5d4_xplained: enable spl support

2014-12-14 Thread Bo Shen
Signed-off-by: Bo Shen 
---

Changes in v2:
- change CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION to 
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION

 arch/arm/Kconfig|  1 +
 board/atmel/sama5d4_xplained/sama5d4_xplained.c | 85 +
 configs/sama5d4_xplained_mmc_defconfig  |  1 +
 configs/sama5d4_xplained_nandflash_defconfig|  1 +
 configs/sama5d4_xplained_spiflash_defconfig |  1 +
 include/configs/sama5d4_xplained.h  | 56 
 6 files changed, 145 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9a39e09..a2aaebf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -518,6 +518,7 @@ config TARGET_SAMA5D3XEK
 config TARGET_SAMA5D4_XPLAINED
bool "Support sama5d4_xplained"
select CPU_V7
+   select SUPPORT_SPL
 
 config TARGET_SAMA5D4EK
bool "Support sama5d4ek"
diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c 
b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
index 93bebd4..d64d320 100644
--- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c
+++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -328,3 +329,87 @@ int board_eth_init(bd_t *bis)
 
return rc;
 }
+
+/* SPL */
+#ifdef CONFIG_SPL_BUILD
+void spl_board_init(void)
+{
+#ifdef CONFIG_SYS_USE_MMC
+   sama5d4_xplained_mci1_hw_init();
+#elif CONFIG_SYS_USE_NANDFLASH
+   sama5d4_xplained_nand_hw_init();
+#elif CONFIG_SYS_USE_SERIALFLASH
+   sama5d4_xplained_spi0_hw_init();
+#endif
+}
+
+static void ddr2_conf(struct atmel_mpddr *ddr2)
+{
+   ddr2->md = (ATMEL_MPDDRC_MD_DBW_32_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+   ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+   ATMEL_MPDDRC_CR_NR_ROW_14 |
+   ATMEL_MPDDRC_CR_CAS_DDR_CAS3 |
+   ATMEL_MPDDRC_CR_NB_8BANKS |
+   ATMEL_MPDDRC_CR_NDQS_DISABLED |
+   ATMEL_MPDDRC_CR_DECOD_INTERLEAVED |
+   ATMEL_MPDDRC_CR_UNAL_SUPPORTED);
+
+   ddr2->rtr = 0x2b0;
+
+   ddr2->tpr0 = (8 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |
+ 3 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET |
+ 3 << ATMEL_MPDDRC_TPR0_TWR_OFFSET |
+ 10 << ATMEL_MPDDRC_TPR0_TRC_OFFSET |
+ 3 << ATMEL_MPDDRC_TPR0_TRP_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET);
+
+   ddr2->tpr1 = (2 << ATMEL_MPDDRC_TPR1_TXP_OFFSET |
+ 200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET |
+ 25 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET |
+ 23 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET);
+
+   ddr2->tpr2 = (7 << ATMEL_MPDDRC_TPR2_TFAW_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET |
+ 3 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET |
+ 2 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET |
+ 8 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET);
+}
+
+void mem_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   struct atmel_mpddr ddr2;
+
+   ddr2_conf(&ddr2);
+
+   /* enable MPDDR clock */
+   at91_periph_clk_enable(ATMEL_ID_MPDDRC);
+   writel(0x4, &pmc->scer);
+
+   /* DDRAM2 Controller initialize */
+   ddr2_init(ATMEL_BASE_DDRCS, &ddr2);
+}
+
+void at91_pmc_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   u32 tmp;
+
+   tmp = AT91_PMC_PLLAR_29 |
+ AT91_PMC_PLLXR_PLLCOUNT(0x3f) |
+ AT91_PMC_PLLXR_MUL(87) |
+ AT91_PMC_PLLXR_DIV(1);
+   at91_plla_init(tmp);
+
+   writel(0x0 << 8, &pmc->pllicpr);
+
+   tmp = AT91_PMC_MCKR_H32MXDIV |
+ AT91_PMC_MCKR_PLLADIV_2 |
+ AT91_PMC_MCKR_MDIV_3 |
+ AT91_PMC_MCKR_CSS_PLLA;
+   at91_mck_init(tmp);
+}
+#endif
diff --git a/configs/sama5d4_xplained_mmc_defconfig 
b/configs/sama5d4_xplained_mmc_defconfig
index 3720f3c..73df28c 100644
--- a/configs/sama5d4_xplained_mmc_defconfig
+++ b/configs/sama5d4_xplained_mmc_defconfig
@@ -1,3 +1,4 @@
+CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="SAMA5D4,SYS_USE_MMC"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SAMA5D4_XPLAINED=y
diff --git a/configs/sama5d4_xplained_nandflash_defconfig 
b/configs/sama5d4_xplained_nandflash_defconfig
index 5e13da7..046fe06 100644
--- a/configs/sama5d4_xplained_nandflash_defconfig
+++ b/configs/sama5d4_xplained_nandflash_defconfig
@@ -1,3 +1,4 @@
+CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="SAMA5D4,SYS_USE_NANDFLASH"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SAMA5D4_XPLAINED=y
diff --gi

[U-Boot] [PATCH v2 11/13] ARM: atmel: sama5d4: build related file when enable SPL

2014-12-14 Thread Bo Shen
Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/cpu/at91-common/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/cpu/at91-common/Makefile 
b/arch/arm/cpu/at91-common/Makefile
index 89e1577..03614d4 100644
--- a/arch/arm/cpu/at91-common/Makefile
+++ b/arch/arm/cpu/at91-common/Makefile
@@ -13,5 +13,6 @@ ifneq ($(CONFIG_SPL_BUILD),)
 obj-$(CONFIG_AT91SAM9G20) += sdram.o spl_at91.o
 obj-$(CONFIG_AT91SAM9M10G45) += mpddrc.o spl_at91.o
 obj-$(CONFIG_SAMA5D3) += mpddrc.o spl_atmel.o
+obj-$(CONFIG_SAMA5D4) += mpddrc.o spl_atmel.o
 obj-y += spl.o
 endif
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH v2 08/13] ARM: atmel: sama5d4: add bus matrix init function

2014-12-14 Thread Bo Shen
Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/cpu/armv7/at91/sama5d4_devices.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/cpu/armv7/at91/sama5d4_devices.c 
b/arch/arm/cpu/armv7/at91/sama5d4_devices.c
index 7469825..9c63e99 100644
--- a/arch/arm/cpu/armv7/at91/sama5d4_devices.c
+++ b/arch/arm/cpu/armv7/at91/sama5d4_devices.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 char *get_cpu_name()
@@ -44,3 +45,37 @@ void at91_udp_hw_init(void)
at91_periph_clk_enable(ATMEL_ID_UDPHS);
 }
 #endif
+
+#ifdef CONFIG_SPL_BUILD
+void matrix_init(void)
+{
+   struct atmel_matrix *h64mx = (struct atmel_matrix *)ATMEL_BASE_MATRIX0;
+   struct atmel_matrix *h32mx = (struct atmel_matrix *)ATMEL_BASE_MATRIX1;
+   int i;
+
+   /* Disable the write protect */
+   writel(ATMEL_MATRIX_WPMR_WPKEY & ~ATMEL_MATRIX_WPMR_WPEN, &h64mx->wpmr);
+   writel(ATMEL_MATRIX_WPMR_WPKEY & ~ATMEL_MATRIX_WPMR_WPEN, &h32mx->wpmr);
+
+   /* DDR port 1 ~ poart 7, slave number is: 4 ~ 10 */
+   for (i = 4; i <= 10; i++) {
+   writel(0x000f0f0f, &h64mx->ssr[i]);
+   writel(0x, &h64mx->sassr[i]);
+   writel(0x000f, &h64mx->srtsr[i]);
+   }
+
+   /* CS3 */
+   writel(0x00c0c0c0, &h32mx->ssr[3]);
+   writel(0xff00, &h32mx->sassr[3]);
+   writel(0xff00, &h32mx->srtsr[3]);
+
+   /* NFC SRAM */
+   writel(0x00010101, &h32mx->ssr[4]);
+   writel(0x0001, &h32mx->sassr[4]);
+   writel(0x0001, &h32mx->srtsr[4]);
+
+   /* Enable the write protect */
+   writel(ATMEL_MATRIX_WPMR_WPKEY | ATMEL_MATRIX_WPMR_WPEN, &h64mx->wpmr);
+   writel(ATMEL_MATRIX_WPMR_WPKEY | ATMEL_MATRIX_WPMR_WPEN, &h32mx->wpmr);
+}
+#endif
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH v2 05/13] ARM: atmel: spl: add saic to aic redirect function

2014-12-14 Thread Bo Shen
Some SoC need to redirect the saic to aic to make the interrupt to
work, here add a weak function to be replaced by real function.

Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/cpu/at91-common/spl_atmel.c | 7 +++
 arch/arm/include/asm/arch-at91/at91_common.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/cpu/at91-common/spl_atmel.c 
b/arch/arm/cpu/at91-common/spl_atmel.c
index 9cb5770..fdea466 100644
--- a/arch/arm/cpu/at91-common/spl_atmel.c
+++ b/arch/arm/cpu/at91-common/spl_atmel.c
@@ -63,6 +63,11 @@ __weak void matrix_init(void)
/* This only be used for sama5d4 soc now */
 }
 
+__weak void redirect_int_from_saic_to_aic(void)
+{
+   /* This only be used for sama5d4 soc now */
+}
+
 void s_init(void)
 {
switch_to_main_crystal_osc();
@@ -77,6 +82,8 @@ void s_init(void)
 
matrix_init();
 
+   redirect_int_from_saic_to_aic();
+
timer_init();
 
board_early_init_f();
diff --git a/arch/arm/include/asm/arch-at91/at91_common.h 
b/arch/arm/include/asm/arch-at91/at91_common.h
index 912e55c..efcd74e 100644
--- a/arch/arm/include/asm/arch-at91/at91_common.h
+++ b/arch/arm/include/asm/arch-at91/at91_common.h
@@ -33,5 +33,6 @@ void at91_mck_init(u32 mckr);
 void at91_spl_board_init(void);
 void at91_disable_wdt(void);
 void matrix_init(void);
+void redirect_int_from_saic_to_aic(void);
 
 #endif /* AT91_COMMON_H */
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH v2 06/13] ARM: atmel: spl: can not disable osc for sama5d4

2014-12-14 Thread Bo Shen
The SAMA5D4 SoC on chip rc oscillator can not be disabled.

Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/cpu/at91-common/spl_atmel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/cpu/at91-common/spl_atmel.c 
b/arch/arm/cpu/at91-common/spl_atmel.c
index fdea466..9cc 100644
--- a/arch/arm/cpu/at91-common/spl_atmel.c
+++ b/arch/arm/cpu/at91-common/spl_atmel.c
@@ -51,11 +51,13 @@ static void switch_to_main_crystal_osc(void)
while (!(readl(&pmc->mcfr) & AT91_PMC_MAINRDY))
;
 
+#ifndef CONFIG_SAMA5D4
tmp = readl(&pmc->mor);
tmp &= ~AT91_PMC_MOR_MOSCRCEN;
tmp &= ~AT91_PMC_MOR_KEY(0xff);
tmp |= AT91_PMC_MOR_KEY(0x37);
writel(tmp, &pmc->mor);
+#endif
 }
 
 __weak void matrix_init(void)
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH v2 10/13] ARM: atmel: sama5d4: can access DDR in interleave mode

2014-12-14 Thread Bo Shen
The SAMAA5D4 SoC can access DDR in interleave mode.

Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/cpu/at91-common/mpddrc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/at91-common/mpddrc.c 
b/arch/arm/cpu/at91-common/mpddrc.c
index 44798e6..beec13d 100644
--- a/arch/arm/cpu/at91-common/mpddrc.c
+++ b/arch/arm/cpu/at91-common/mpddrc.c
@@ -19,7 +19,7 @@ static inline void atmel_mpddr_op(int mode, u32 ram_address)
 
 static int ddr2_decodtype_is_seq(u32 cr)
 {
-#if defined(CONFIG_SAMA5D3)
+#if defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4)
if (cr & ATMEL_MPDDRC_CR_DECOD_INTERLEAVED)
return 0;
 #endif
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH v2 07/13] ARM: atmel: sama5d4: add matrix1 base addr definition

2014-12-14 Thread Bo Shen
Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/include/asm/arch-at91/sama5d4.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/include/asm/arch-at91/sama5d4.h 
b/arch/arm/include/asm/arch-at91/sama5d4.h
index d851568..f30cb5f 100644
--- a/arch/arm/include/asm/arch-at91/sama5d4.h
+++ b/arch/arm/include/asm/arch-at91/sama5d4.h
@@ -126,6 +126,8 @@
 #define ATMEL_BASE_ADC 0xfc034000
 #define ATMEL_BASE_TWI30xfc038000
 
+#define ATMEL_BASE_MATRIX1 0xfc054000
+
 #define ATMEL_BASE_SMC 0xfc05c000
 #define ATMEL_BASE_PMECC   (ATMEL_BASE_SMC + 0x070)
 #define ATMEL_BASE_PMERRLOC(ATMEL_BASE_SMC + 0x500)
-- 
2.1.0.24.g4109c28

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


[U-Boot] [PATCH v2 03/13] ARM: atmel: sama5: add sfr register header file

2014-12-14 Thread Bo Shen
The SFR (special function registers) can be shared bwteen
sama5d3 and sama5d4 soc.

Signed-off-by: Bo Shen 
---

Changes in v2: None

 arch/arm/include/asm/arch-at91/sama5_sfr.h | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-at91/sama5_sfr.h

diff --git a/arch/arm/include/asm/arch-at91/sama5_sfr.h 
b/arch/arm/include/asm/arch-at91/sama5_sfr.h
new file mode 100644
index 000..d3d2439
--- /dev/null
+++ b/arch/arm/include/asm/arch-at91/sama5_sfr.h
@@ -0,0 +1,38 @@
+/*
+ * Special Function Register (SFR)
+ *
+ * Copyright (C) 2014 Atmel
+ *   Bo Shen 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __SAMA5_SFR_H
+#define __SAMA5_SFR_H
+
+struct atmel_sfr {
+   u32 reserved1;  /* 0x00 */
+   u32 ddrcfg; /* 0x04: DDR Configuration Register */
+   u32 reserved2;  /* 0x08 */
+   u32 reserved3;  /* 0x0c */
+   u32 ohciicr;/* 0x10: OHCI Interrupt Configuration Register 
*/
+   u32 ohciisr;/* 0x14: OHCI Interrupt Status Register */
+   u32 reserved4[4];   /* 0x18 ~ 0x24 */
+   u32 secure; /* 0x28: Security Configuration Register */
+   u32 reserved5[5];   /* 0x2c ~ 0x3c */
+   u32 ebicfg; /* 0x40: EBI Configuration Register */
+   u32 reserved6[2];   /* 0x44 ~ 0x48 */
+   u32 sn0;/* 0x4c */
+   u32 sn1;/* 0x50 */
+   u32 aicredir;   /* 0x54 */
+};
+
+/* Bit field in DDRCFG */
+#define ATMEL_SFR_DDRCFG_FDQIEN0x0001
+#define ATMEL_SFR_DDRCFG_FDQSIEN   0x0002
+
+/* Bit field in AICREDIR */
+#define ATMEL_SFR_AICREDIR_KEY 0x5F67B102
+#define ATMEL_SFR_AICREDIR_NSAIC   0x0001
+
+#endif
-- 
2.1.0.24.g4109c28

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


  1   2   3   4   5   6   >