flags = can_read_reg(chip, iCTL) & (iCTL_IE|iCTL_SIE|iCTL_EIE);
can_write_reg(chip, flags|iCTL_CCE, iCTL);
flags = can_read_reg(chip, iCTL) & (iCTL_IE|iCTL_SIE|iCTL_EIE);
can_write_reg(chip, flags|iCTL_CCE, iCTL);
{
can_write_reg(chip,chip->int_cpu_reg,iCPU); // Configure cpu interface
can_write_reg(chip,(iCTL_CCE|iCTL_INI),iCTL); // Enable configuration
{
can_write_reg(chip,chip->int_cpu_reg,iCPU); // Configure cpu interface
can_write_reg(chip,(iCTL_CCE|iCTL_INI),iCTL); // Enable configuration
i82527_seg_write_reg(chip,chip->int_bus_reg,iBUS); /* Bus configuration */
can_write_reg(chip,0x00,iSTAT); /* Clear error status register */
i82527_seg_write_reg(chip,chip->int_bus_reg,iBUS); /* Bus configuration */
can_write_reg(chip,0x00,iSTAT); /* Clear error status register */
* card. If we can not, the card is not properly configured!
*/
canobj_write_reg(chip,chip->msgobj[1],0x25,iMSGDAT1);
* card. If we can not, the card is not properly configured!
*/
canobj_write_reg(chip,chip->msgobj[1],0x25,iMSGDAT1);
int best_error = 1000000000, error;
int best_tseg=0, best_brp=0, best_rate=0, brp=0;
int tseg=0, tseg1=0, tseg2=0;
int best_error = 1000000000, error;
int best_tseg=0, best_brp=0, best_rate=0, brp=0;
int tseg=0, tseg1=0, tseg2=0;
DEBUGMSG("brp=%d, best_tseg=%d, tseg1=%d, tseg2=%d, sampl_pt=%d\n",
best_brp, best_tseg, tseg1, tseg2,
(100*(best_tseg-tseg2)/(best_tseg+1)));
DEBUGMSG("brp=%d, best_tseg=%d, tseg1=%d, tseg2=%d, sampl_pt=%d\n",
best_brp, best_tseg, tseg1, tseg2,
(100*(best_tseg-tseg2)/(best_tseg+1)));
i82527_seg_write_reg(chip, sjw<<6 | best_brp, iBT0);
can_write_reg(chip, ((flags & BTR1_SAM) != 0)<<7 | tseg2<<4 | tseg1,
iBT1);
DEBUGMSG("Writing 0x%x to iBT0\n",(sjw<<6 | best_brp));
i82527_seg_write_reg(chip, sjw<<6 | best_brp, iBT0);
can_write_reg(chip, ((flags & BTR1_SAM) != 0)<<7 | tseg2<<4 | tseg1,
iBT1);
DEBUGMSG("Writing 0x%x to iBT0\n",(sjw<<6 | best_brp));
can_write_reg(chip,mask0,iSGM0);
can_write_reg(chip,mask1,iSGM1);
can_write_reg(chip,mask0,iSGM0);
can_write_reg(chip,mask1,iSGM1);
{
int i=0,id0=0,id1=0,id2=0,id3=0;
int len;
{
int i=0,id0=0,id1=0,id2=0,id3=0;
int len;
{
canobj_write_reg(chip,obj,(MVAL_SET|TXIE_RES|RXIE_SET|INTPD_RES),iMSGCTL0);
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_SET|MLST_RES|NEWD_RES),iMSGCTL1);
{
canobj_write_reg(chip,obj,(MVAL_SET|TXIE_RES|RXIE_SET|INTPD_RES),iMSGCTL0);
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_SET|MLST_RES|NEWD_RES),iMSGCTL1);
flags = can_read_reg(chip, iCTL) & (iCTL_IE|iCTL_SIE|iCTL_EIE);
can_write_reg(chip, flags, iCTL);
flags = can_read_reg(chip, iCTL) & (iCTL_IE|iCTL_SIE|iCTL_EIE);
can_write_reg(chip, flags, iCTL);
do {
if(objnum != 14) {
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_RES|MLST_UNC|NEWD_RES),iMSGCTL1);
do {
if(objnum != 14) {
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_RES|MLST_UNC|NEWD_RES),iMSGCTL1);
for (i=0; i < obj->rx_msg.length; i++)
obj->rx_msg.data[i] = canobj_read_reg(chip,obj,iMSGDAT0+i);
for (i=0; i < obj->rx_msg.length; i++)
obj->rx_msg.data[i] = canobj_read_reg(chip,obj,iMSGDAT0+i);
if(objnum != 14) {
/* if NEWD is set after data read, then read data are likely inconsistent */
msgctl1=canobj_read_reg(chip,obj,iMSGCTL1);
if(objnum != 14) {
/* if NEWD is set after data read, then read data are likely inconsistent */
msgctl1=canobj_read_reg(chip,obj,iMSGCTL1);
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_RES|MLST_UNC|NEWD_RES),iMSGCTL1);
msgctl1=canobj_read_reg(chip,obj,iMSGCTL1);
}
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_RES|MLST_UNC|NEWD_RES),iMSGCTL1);
msgctl1=canobj_read_reg(chip,obj,iMSGCTL1);
}
/* fill CAN message timestamp */
can_filltimestamp(&obj->rx_msg.timestamp);
canque_filter_msg2edges(obj->qends, &obj->rx_msg);
/* fill CAN message timestamp */
can_filltimestamp(&obj->rx_msg.timestamp);
canque_filter_msg2edges(obj->qends, &obj->rx_msg);
if (msgctl1 & MLST_SET) {
canobj_write_reg(chip,obj,(RMPD_UNC|TXRQ_UNC|MLST_RES|NEWD_UNC),iMSGCTL1);
CANMSG("i82527_irq_read_handler: object %d message lost\n",objnum);
}
if (msgctl1 & MLST_SET) {
canobj_write_reg(chip,obj,(RMPD_UNC|TXRQ_UNC|MLST_RES|NEWD_UNC),iMSGCTL1);
CANMSG("i82527_irq_read_handler: object %d message lost\n",objnum);
}
if ((rtr_search!=NULL) && (rtr_search->id==message_id))
i82527_irq_rtr_handler(chip, obj, rtr_search, message_id);
else
if ((rtr_search!=NULL) && (rtr_search->id==message_id))
i82527_irq_rtr_handler(chip, obj, rtr_search, message_id);
else
CANMSG("i82527_irq_register 0x%x\n",irq_register);
return CANCHIP_IRQ_STUCK;
}
CANMSG("i82527_irq_register 0x%x\n",irq_register);
return CANCHIP_IRQ_STUCK;
}
if (irq_register == 0x01) {
status_register=can_read_reg(chip, iSTAT);
CANMSG("Status register: 0x%x\n",status_register);
continue;
/*return CANCHIP_IRQ_NONE;*/
}
if (irq_register == 0x01) {
status_register=can_read_reg(chip, iSTAT);
CANMSG("Status register: 0x%x\n",status_register);
continue;
/*return CANCHIP_IRQ_NONE;*/
}
msgcfg = canobj_read_reg(chip,obj,iMSGCFG);
if (msgcfg & MCFG_DIR) {
can_msgobj_set_fl(obj,TX_REQUEST);
msgcfg = canobj_read_reg(chip,obj,iMSGCFG);
if (msgcfg & MCFG_DIR) {
can_msgobj_set_fl(obj,TX_REQUEST);
/* calls i82527_irq_write_handler synchronized with other invocations */
if(i82527_irq_sync_activities(chip, obj)<=0){
/* The interrupt has to be cleared anyway */
canobj_write_reg(chip,obj,(MVAL_UNC|TXIE_UNC|RXIE_UNC|INTPD_RES),iMSGCTL0);
/* calls i82527_irq_write_handler synchronized with other invocations */
if(i82527_irq_sync_activities(chip, obj)<=0){
/* The interrupt has to be cleared anyway */
canobj_write_reg(chip,obj,(MVAL_UNC|TXIE_UNC|RXIE_UNC|INTPD_RES),iMSGCTL0);
* Rerun for case, that parallel activity on SMP or fully-preemptive
* kernel result in preparation and finished sending of message
* between above if and canobj_write_reg.
* Rerun for case, that parallel activity on SMP or fully-preemptive
* kernel result in preparation and finished sending of message
* between above if and canobj_write_reg.
} while((irq_register=i82527_seg_read_reg(chip, iIRQ)) != 0);
return CANCHIP_IRQ_HANDLED;
} while((irq_register=i82527_seg_read_reg(chip, iIRQ)) != 0);
return CANCHIP_IRQ_HANDLED;
canobj_write_reg(chip,obj,(MVAL_RES|TXIE_RES|RXIE_RES|INTPD_RES),iMSGCTL0);
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_RES|MLST_RES|NEWD_RES),iMSGCTL1);
canobj_write_reg(chip,obj,(MVAL_RES|TXIE_RES|RXIE_RES|INTPD_RES),iMSGCTL0);
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_RES|MLST_RES|NEWD_RES),iMSGCTL1);
can_spin_lock(&hardware_p->rtr_lock);
rtr_search->rtr_message->id=message_id;
rtr_search->rtr_message->length=(canobj_read_reg(chip,obj,iMSGCFG) & 0xf0)>>4;
for (i=0; i<rtr_search->rtr_message->length; i++)
rtr_search->rtr_message->data[i]=canobj_read_reg(chip,obj,iMSGDAT0+i);
can_spin_lock(&hardware_p->rtr_lock);
rtr_search->rtr_message->id=message_id;
rtr_search->rtr_message->length=(canobj_read_reg(chip,obj,iMSGCFG) & 0xf0)>>4;
for (i=0; i<rtr_search->rtr_message->length; i++)
rtr_search->rtr_message->data[i]=canobj_read_reg(chip,obj,iMSGDAT0+i);
can_msgobj_set_fl(obj,TX_REQUEST);
/* calls i82527_irq_write_handler synchronized with other invocations
can_msgobj_set_fl(obj,TX_REQUEST);
/* calls i82527_irq_write_handler synchronized with other invocations
can_msgobj_set_fl(obj,FILTCH_REQUEST);
/* setups filter synchronized with other invocations from kernel and IRQ context */
can_msgobj_set_fl(obj,FILTCH_REQUEST);
/* setups filter synchronized with other invocations from kernel and IRQ context */