[PATCH 1/1] at91: add rtc irq fixup

2013-10-11 Thread Jean-Christophe PLAGNIOL-VILLARD
Some of the irq can still be on after a reset or power on as the IP are
powered by the backup power. This could lead to an interrupt dead lock
when the kernel boot. So disable them before booting.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
Cc: Nicolas Ferre nicolas.fe...@atmel.com
---
 arch/arm/mach-at91/at91sam9g45.c  |  2 ++
 arch/arm/mach-at91/at91sam9n12.c  |  2 ++
 arch/arm/mach-at91/at91sam9x5.c   |  2 ++
 arch/arm/mach-at91/generic.h  |  1 +
 arch/arm/mach-at91/include/mach/sama5d3.h |  1 +
 arch/arm/mach-at91/irq_fixup.c| 15 +++
 arch/arm/mach-at91/sama5d3.c  |  2 ++
 7 files changed, 25 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 9a50deb..708feb0 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -247,6 +247,8 @@ static void __init at91sam9g45_register_clocks(void)
 
 static void at91sam9g45_initialize(void)
 {
+   at91_rtc_irq_fixup(IOMEM(AT91SAM9G45_BASE_RTC));
+
/* Register the processor-specific clocks */
at91sam9g45_register_clocks();
 
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index 2a825b4..3574bf4 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -207,6 +207,8 @@ static void __init at91sam9n12_register_clocks(void)
 
 static void at91sam9n12_initialize(void)
 {
+   at91_rtc_irq_fixup(IOMEM(AT91SAM9N12_BASE_RTC));
+
/* Register the processor-specific clocks */
at91sam9n12_register_clocks();
 
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 9ddd592..eeeb069 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -293,6 +293,8 @@ static void __init at91sam9x5_register_clocks(void)
 
 static void at91sam9x5_initialize(void)
 {
+   at91_rtc_irq_fixup(IOMEM(AT91SAM9X5_BASE_RTC));
+
/* Register the processor-specific clocks */
at91sam9x5_register_clocks();
 
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index a47bcb2..4750c5b 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -37,3 +37,4 @@ static inline struct device_d *at91_add_sam9_smc(int id, 
resource_size_t start,
 }
 
 void at91_rtt_irq_fixup(void *base);
+void at91_rtc_irq_fixup(void *base);
diff --git a/arch/arm/mach-at91/include/mach/sama5d3.h 
b/arch/arm/mach-at91/include/mach/sama5d3.h
index 6884ff6..c3fe5b0 100644
--- a/arch/arm/mach-at91/include/mach/sama5d3.h
+++ b/arch/arm/mach-at91/include/mach/sama5d3.h
@@ -102,6 +102,7 @@
 #defineSAMA5D3_BASE_HSMC   0xc000
 #define SAMA5D3_BASE_PIT   0xfe30
 #define SAMA5D3_BASE_WDT   0xfe40
+#define SAMA5D3_BASE_RTC   0xfeb0
 
 #define SAMA5D3_BASE_PMECC 0xc070
 #define SAMA5D3_BASE_PMERRLOC  0xc500
diff --git a/arch/arm/mach-at91/irq_fixup.c b/arch/arm/mach-at91/irq_fixup.c
index a9eebd7..ba09756 100644
--- a/arch/arm/mach-at91/irq_fixup.c
+++ b/arch/arm/mach-at91/irq_fixup.c
@@ -20,3 +20,18 @@ void at91_rtt_irq_fixup(void *base)
 
writel(mr  ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN), reg);
 }
+
+#defineAT91_RTC_IDR0x24/* Interrupt 
Disable Register */
+
+/*
+ * As the RTC is powered by the backup power so if the interrupt
+ * is still on when the kernel start, the kernel will end up with
+ * dead lock interrupt that it can not clear. Because the interrupt line is
+ * shared with the basic timer (PIT) on AT91_ID_SYS.
+ */
+void at91_rtc_irq_fixup(void *base)
+{
+   void *reg = base + AT91_RTC_IDR;
+
+   writel(0x5, reg);
+}
diff --git a/arch/arm/mach-at91/sama5d3.c b/arch/arm/mach-at91/sama5d3.c
index aa681aa..079fb66 100644
--- a/arch/arm/mach-at91/sama5d3.c
+++ b/arch/arm/mach-at91/sama5d3.c
@@ -375,6 +375,8 @@ static void __init sama5d3_register_clocks(void)
 
 static void sama5d3_initialize(void)
 {
+   at91_rtc_irq_fixup(IOMEM(SAMA5D3_BASE_RTC));
+
/* Register the processor-specific clocks */
sama5d3_register_clocks();
 
-- 
1.8.4.rc3


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


bareboxenv-target and spi nor flash crc problem

2013-10-11 Thread Vanhauwaert Wouter
Hi, I want to use bareboxenv-target on my operating system
My environment settings are stored on a m25p32 spi nor flash.
I can load them perfectly by issueing command:
bareboxenv-target -l /tmp/barebox /dev/mtd1 
I change something and afterwards I do: bareboxenv-target -s /tmp/barebox 
/dev/mtd1
No problems so far
However
If I reboot, I get a wrong crc on env superblock and default environment is 
loaded
My barebox is latest v2013.10.0 and my kernel is 2.6.35.3 (freescale git 
maintain version)
As a sidenote, I also still have problems with nand flash written with barebox, 
which is corrupt in linux and vica versa...

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


RE: bareboxenv on userspace - wrong crc on env

2013-10-11 Thread Vanhauwaert Wouter
 -Original Message-
 From: Sascha Hauer [mailto:s.ha...@pengutronix.de]
 Sent: donderdag 29 augustus 2013 20:44
 To: Vanhauwaert Wouter
 Cc: barebox@lists.infradead.org
 Subject: Re: bareboxenv on userspace - wrong crc on env
 
 On Thu, Aug 29, 2013 at 11:24:41AM +0200, Vanhauwaert Wouter wrote:
  Hello all,
 
  I'm having issues accessing my barebox environment from within linux
 
  My barebox and environment are located on a SPI NOR flash.
  This boots ok, and barebox is able to save its environment to it.
 
  When I want to load it in userspace through:
 
  $ bareboxenv -l /mnt /dev/mtd1
  Or
  $ dd if=/dev/mtd1 /tmp/barebox
  Or
  $ dd if=/dev/mdtblock1 /tmp/barebox
 
  Result is:
  Wrong crc on env
 
  However it's working fine in barebox itself
 
  What can be wron?
 
 The only idea I have is that /dev/mtd1 might not be the place where barebox
 stores it's environment, maybe because of different probe order in the kernel 
 or
 different partition layout. Could you send a hexdump of the first 256 bytes 
 or so
 of /dev/mtd1?
 
 Sascha

I had general issues reading and writing spi nor flash in userspace (without 
being aware of it). Now it works, I can read / write from nor flash from within 
linux.
I can copy the barebox bootloader and uImage to it through dd and this works 
fine. I can also load my barebox environment, change things and write it back 
and read it back out.
However, when I restart my board afterwards, I get an invalid crc on superblock.

(Sorry, some kind of double post with my new topic today)

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: bareboxenv-target and spi nor flash crc problem

2013-10-11 Thread Jan Lübbe
On Fri, 2013-10-11 at 14:57 +0200, Vanhauwaert Wouter wrote:
 Hi, I want to use bareboxenv-target on my operating system
 My environment settings are stored on a m25p32 spi nor flash.
 I can load them perfectly by issueing command:
 bareboxenv-target -l /tmp/barebox /dev/mtd1 
 I change something and afterwards I do: bareboxenv-target -s /tmp/barebox 
 /dev/mtd1
 No problems so far
 However
 If I reboot, I get a wrong crc on env superblock and default environment is 
 loaded

You should use flash_erase (from mtd-utils) on the mtd partition before
writing to it.

Regards,
Jan Lübbe
-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


RE: bareboxenv-target and spi nor flash crc problem

2013-10-11 Thread Vanhauwaert Wouter
 -Original Message-
 From: Vanhauwaert Wouter
 Sent: vrijdag 11 oktober 2013 14:58
 To: barebox@lists.infradead.org
 Subject: bareboxenv-target and spi nor flash crc problem
 
 Hi, I want to use bareboxenv-target on my operating system My environment
 settings are stored on a m25p32 spi nor flash.
 I can load them perfectly by issueing command:
 bareboxenv-target -l /tmp/barebox /dev/mtd1 I change something and
 afterwards I do: bareboxenv-target -s /tmp/barebox /dev/mtd1 No problems so
 far However If I reboot, I get a wrong crc on env superblock and default
 environment is loaded My barebox is latest v2013.10.0 and my kernel is 
 2.6.35.3
 (freescale git maintain version) As a sidenote, I also still have problems 
 with
 nand flash written with barebox, which is corrupt in linux and vica versa...

I think I figured it out. I need to erase the spi nor flash first. I assumed 
the bareboxenv-target application did that for me...
Am I correct?

Grtz,
Wouter

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox