public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 2/2 V3] ppc4xx: Initialize magnetic couplers in PLU405
@ 2009-10-26  8:58 Matthias Fuchs
  2009-11-17 12:27 ` Stefan Roese
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Fuchs @ 2009-10-26  8:58 UTC (permalink / raw)
  To: u-boot

This patch fixes an ugly behavior of the IL712 magnetic couplers
as used on PLU405. These parts will remember their last state
over a power cycle which might cause unwanted behavior.

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd.eu>
---
V2:
 - use C struct to access CAN controller registes

V3:
 - move SJA1000 stuff into separate header
   (see preceding patch)
 - some renaming

 board/esd/plu405/plu405.c |   36 ++++++++++++++++++++++++++++++++++++
 include/configs/PLU405.h  |    3 ++-
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/board/esd/plu405/plu405.c b/board/esd/plu405/plu405.c
index 1841cda..fea7b26 100644
--- a/board/esd/plu405/plu405.c
+++ b/board/esd/plu405/plu405.c
@@ -26,6 +26,7 @@
 #include <asm/io.h>
 #include <command.h>
 #include <malloc.h>
+#include <sja1000.h>
 
 #undef FPGA_DEBUG
 
@@ -45,6 +46,34 @@ const unsigned char fpgadata[] =
  */
 #include "../common/fpga.c"
 
+/*
+ * generate a short spike on the CAN tx line
+ * to bring the couplers in sync
+ */
+void init_coupler(u32 addr)
+{
+	struct sja1000_basic_s *ctrl = (struct sja1000_basic_s *)addr;
+
+	/* reset */
+	out_8(&ctrl->cr, CR_RR);
+
+	/* dominant */
+	out_8(&ctrl->btr0, 0x00); /* btr setup is required */
+	out_8(&ctrl->btr1, 0x14); /* we use 1Mbit/s */
+	out_8(&ctrl->oc, OC_TP1 | OC_TN1 | OC_POL1 |
+	      OC_TP0 | OC_TN0 | OC_POL0 | OC_MODE1);
+	out_8(&ctrl->cr, 0x00);
+
+	/* delay */
+	in_8(&ctrl->cr);
+	in_8(&ctrl->cr);
+	in_8(&ctrl->cr);
+	in_8(&ctrl->cr);
+
+	/* reset */
+	out_8(&ctrl->cr, CR_RR);
+}
+
 /* Prototypes */
 int gunzip(void *, int, unsigned char *, unsigned long *);
 
@@ -198,6 +227,13 @@ int misc_init_r(void)
 	out_8((void *)DUART1_BA + 1, fctr); /* write FCTR */
 	out_8((void *)DUART1_BA + 3, 0);    /* write LCR */
 
+	/*
+	 * Init magnetic couplers
+	 */
+	if (!getenv("noinitcoupler")) {
+		init_coupler(CAN0_BA);
+		init_coupler(CAN1_BA);
+	}
 	return 0;
 }
 
diff --git a/include/configs/PLU405.h b/include/configs/PLU405.h
index 07fc715..b6740de 100644
--- a/include/configs/PLU405.h
+++ b/include/configs/PLU405.h
@@ -298,7 +298,8 @@
 /*
  * External Bus Controller (EBC) Setup
  */
-#define CAN_BA		0xF0000000	    /* CAN Base Address	        */
+#define CAN0_BA		0xF0000000	    /* CAN0 Base Address	*/
+#define CAN1_BA		0xF0000100	    /* CAN1 Base Address	*/
 #define DUART0_BA	0xF0000400	    /* DUART Base Address       */
 #define DUART1_BA	0xF0000408	    /* DUART Base Address       */
 #define RTC_BA		0xF0000500	    /* RTC Base Address         */
-- 
1.6.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH 2/2 V3] ppc4xx: Initialize magnetic couplers in PLU405
  2009-10-26  8:58 [U-Boot] [PATCH 2/2 V3] ppc4xx: Initialize magnetic couplers in PLU405 Matthias Fuchs
@ 2009-11-17 12:27 ` Stefan Roese
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Roese @ 2009-11-17 12:27 UTC (permalink / raw)
  To: u-boot

On Monday 26 October 2009 09:58:45 Matthias Fuchs wrote:
> This patch fixes an ugly behavior of the IL712 magnetic couplers
> as used on PLU405. These parts will remember their last state
> over a power cycle which might cause unwanted behavior.

Applied to u-boot-ppc4xx/master. Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-11-17 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-26  8:58 [U-Boot] [PATCH 2/2 V3] ppc4xx: Initialize magnetic couplers in PLU405 Matthias Fuchs
2009-11-17 12:27 ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox