Skip to contentSkip to conversation

ppc4xx: Initialize magnetic coupler on VOM405 boards

PATCH New Matthias Fuchs 2 participants 2 messages Oct 27, 2009 – Nov 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc4xx: Initialize magnetic coupler on VOM405 boards

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

---
 board/esd/vom405/vom405.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
board/esd/vom405/vom405.c +35 -0
index fb48022..de35036 100644
@@ -26,11 +26,40 @@
 #include <asm/io.h>
 #include <command.h>
 #include <malloc.h>
+#include <sja1000.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 extern void lxt971_no_sleep(void);
 
+/*
+ * 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);
+}
+
 int board_early_init_f (void)
 {
 	/*
@@ -77,6 +106,12 @@ int misc_init_r (void)
 	gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
 	gd->bd->bi_flashoffset = 0;
 
+	/*
+	 * Init magnetic coupler
+	 */
+	if (!getenv("noinitcoupler"))
+		init_coupler(CAN_BA);
+
 	return (0);
 }
 
Signature · 1 line
1.6.1
#1 lore raw

PATCH 1/1 ppc4xx: Initialize magnetic coupler on VOM405 boards

Quoted 3 lines · On Tuesday 27 October 2009 19:58:09 Matthias Fuchs wrote:

This patch fixes an ugly behavior of the IL712 magnetic coupler as used on VOM405. 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