]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ppc4xx: Initialize magnetic couplers in PLU405
authorMatthias Fuchs <matthias.fuchs@esd.eu>
Mon, 26 Oct 2009 08:58:45 +0000 (09:58 +0100)
committerStefan Roese <sr@denx.de>
Tue, 17 Nov 2009 12:25:30 +0000 (13:25 +0100)
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>
Signed-off-by: Stefan Roese <sr@denx.de>
board/esd/plu405/plu405.c
include/configs/PLU405.h

index f14ef7a20f843a88ff0f48e34ae22f2b11301a0e..c733587b2a8557016b69ff8e46d32d026140ff6c 100644 (file)
@@ -26,6 +26,7 @@
 #include <asm/io.h>
 #include <command.h>
 #include <malloc.h>
+#include <sja1000.h>
 
 #undef FPGA_DEBUG
 
@@ -61,6 +62,34 @@ au_image_t au_image[] = {
 
 int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0]));
 
+/*
+ * 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 *);
 
@@ -214,6 +243,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;
 }
 
index 2e41526afe4ca2d0643a3ff1009335227c88f616..2f84f7fcb6681a623320154ee8e020f1771cb13e 100644 (file)
 /*
  * 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         */