]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/i82527.c
More updates in the C_CAN support, but locking not reworked still.
[lincan.git] / lincan / src / i82527.c
index fb232f380725269d2fc8e0b224d6df92ea3a420e..60096c5820f5277ee26a4d3cb23637c29d199a1a 100644 (file)
@@ -131,7 +131,8 @@ int i82527_baud_rate(struct canchip_t *chip, int rate, int clock, int sjw,
        if (i82527_enable_configuration(chip))
                return -ENODEV;
 
-       clock /=2;
+       if(chip->int_cpu_reg & iCPU_DSC)
+               clock /=2;
 
        /* tseg even = round down, odd = round up */
        for (tseg=(0+0+2)*2; tseg<=(MAX_TSEG2+MAX_TSEG1+2)*2+1; tseg++) {
@@ -415,6 +416,19 @@ int i82527_stop_chip(struct canchip_t *chip)
        return 0;
 }
 
+int i82527_attach_to_chip(struct canchip_t *chip)
+{
+       return 0;
+}
+
+int i82527_release_chip(struct canchip_t *chip)
+{
+       i82527_stop_chip(chip);
+       can_write_reg(chip, (iCTL_CCE|iCTL_INI), iCTL);
+
+       return 0;
+}
+
 static inline 
 void i82527_irq_write_handler(struct canchip_t *chip, struct msgobj_t *obj)
 {
@@ -602,6 +616,8 @@ void i82527_irq_sync_activities(struct canchip_t *chip, struct msgobj_t *obj)
                        }
                }
 
+               mb();
+
                can_msgobj_clear_fl(obj,TX_LOCK);
                if(can_msgobj_test_fl(obj,TX_REQUEST))
                        continue;
@@ -635,6 +651,7 @@ int i82527_irq_handler(int irq, struct canchip_t *chip)
 
                if(!loop_cnt--) {
                        CANMSG("i82527_irq_handler IRQ %d stuck\n",irq);
+                       CANMSG("i82527_irq_register 0x%x\n",irq_register);
                        return CANCHIP_IRQ_STUCK;
                }
                
@@ -667,9 +684,7 @@ int i82527_irq_handler(int irq, struct canchip_t *chip)
                        i82527_irq_read_handler(chip, obj, object); 
                }
                
-               irq_register=i82527_seg_read_reg(chip, iIRQ);
-
-       } while(irq_register != 0);
+       } while((irq_register=i82527_seg_read_reg(chip, iIRQ)) != 0);
 
        return CANCHIP_IRQ_HANDLED;
 }
@@ -752,9 +767,12 @@ int i82527_register(struct chipspecops_t *chipspecops)
        chipspecops->enable_configuration = i82527_enable_configuration;
        chipspecops->disable_configuration = i82527_disable_configuration;
        chipspecops->set_btregs = i82527_set_btregs;
+       chipspecops->attach_to_chip = i82527_attach_to_chip;
+       chipspecops->release_chip = i82527_release_chip;
        chipspecops->start_chip = i82527_start_chip;
        chipspecops->stop_chip = i82527_stop_chip;
        chipspecops->irq_handler = i82527_irq_handler;
+       chipspecops->irq_accept = NULL;
        return 0;
 }