OSCAR reset update
authorppisa <ppisa>
Fri, 1 Oct 2004 01:23:43 +0000 (01:23 +0000)
committerppisa <ppisa>
Fri, 1 Oct 2004 01:23:43 +0000 (01:23 +0000)
lincan/src/oscar.c

index 00f3616..9f36166 100644 (file)
@@ -15,7 +15,7 @@
 #include "../include/main.h"
 #include "../include/oscar.h"
 #include "../include/i82527.h"
-#include "../include/sja1000.h"
+#include "../include/sja1000p.h"
 
 #define IO_RANGE 0x80 // allow both basic CAN and PeliCAN modes for sja1000
 
@@ -39,8 +39,32 @@ int oscar_release_io(struct candevice_t *candev)
 
 int oscar_reset(struct candevice_t *candev)
 {
-    DEBUGMSG("Cannot issue a hardware reset to the CAN chip.");
-    return -ENODEV;
+       int i;
+       struct canchip_t *chip=candev->chip[0];
+       unsigned cdr;
+
+       oscar_write_register(sjaMOD_RM, chip->chip_base_addr+SJAMOD);
+       udelay(1000);
+
+       cdr=oscar_read_register(chip->chip_base_addr+SJACDR);
+       oscar_write_register(cdr|sjaCDR_PELICAN, chip->chip_base_addr+SJACDR);
+
+       oscar_write_register(0, chip->chip_base_addr+SJAIER);
+
+       i=20;
+       oscar_write_register(0, chip->chip_base_addr+SJAMOD);
+       while (oscar_read_register(chip->chip_base_addr+SJAMOD)&sjaMOD_RM){
+               if(!i--) return -ENODEV;
+               udelay(1000);
+               oscar_write_register(0, chip->chip_base_addr+SJAMOD);
+       }
+
+       cdr=oscar_read_register(chip->chip_base_addr+SJACDR);
+       oscar_write_register(cdr|sjaCDR_PELICAN, chip->chip_base_addr+SJACDR);
+
+       oscar_write_register(0, chip->chip_base_addr+SJAIER);
+
+       return 0;
 }
 
 int oscar_init_hw_data(struct candevice_t *candev) 
@@ -57,8 +81,8 @@ int oscar_init_hw_data(struct candevice_t *candev)
 int oscar_init_chip_data(struct candevice_t *candev, int chipnr)
 {
     // i82527_fill_chipspecops(candev->chip[chipnr]);
-    sja1000_fill_chipspecops(candev->chip[chipnr]);
-    // sja1000p_fill_chipspecops(candev->chip[chipnr]);
+    // sja1000_fill_chipspecops(candev->chip[chipnr]);
+    sja1000p_fill_chipspecops(candev->chip[chipnr]);
        
     candev->chip[chipnr]->chip_base_addr = candev->io_addr;
     candev->chip[chipnr]->clock = 12000000;