in platform/nephos/sonic-platform-modules-cig/cs6436-56p/modules/x86-64-cig-cs6436-56p-cpld.c [1696:2055]
static void irq_inter_wapper(struct work_struct * work)
{
u8 m_data = 0;
u8 data_high8 = 0,data_low8 = 0;
u16 data_16 = 0;
u8 status = 0;
u8 i = 0;
char kmsg[64]={0};
u8 tmp[3] = {0};
DEB2(printk("CPLD_MASTER_INTERRUPT\r\n"));
m_data = lpc_iic_getbyte(NULL,CPLD_MASTER_INTERRUPT_STATUS_REG);
lpc_iic_setbyte(NULL,CPLD_MASTER_INTERRUPT_STATUS_REG,0xff);
cig_cpld_write_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_MASK_REG,0xff);
cig_cpld_write_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_MASK_REG,0xff);
if(!(m_data & CPLD_MASTER_INTERRUPT_CPLD1))
{
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_STATUS_H_REG,&data_high8);
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_STATUS_L_REG,&data_low8);
data_16 = data_low8 | data_high8 << 8;
if(
!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT08) ||
!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT16) ||
!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT24)
)
{
if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT08))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT08\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT08_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,0,status);
}
else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT16))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT16\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT16_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,8,status);
}
else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_PRESENT24))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT24\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_PRESENT24_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_present_status_low_current,16,status);
}
DEB2(printk("irq_present_status_low_next = %08x irq_present_status_low_current = %08x \n",irq_present_status_low_next,irq_present_status_low_current));
}
if(
!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08) ||
!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16) ||
!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24)
)
{
if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_RX_LOST08\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST08_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,0,status);
}
else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT16\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST16_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,8,status);
}
else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_PRESENT24\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_RX_LOST24_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_low_current,16,status);
}
DEB2(printk("irq_rx_lost_status_low_next = %08x irq_rx_lost_status_low_current = %08x \n",irq_rx_lost_status_low_next,irq_rx_lost_status_low_current));
}
if(
!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST08) ||
!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST16) ||
!(data_16 & CPLD_SLAVE1_INTERRUPT_RX_LOST24)
)
{
if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT08))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT08\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT08_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,0,status);
}
else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT16))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT16\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT16_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,8,status);
}
else if(!(data_16 & CPLD_SLAVE1_INTERRUPT_TX_FAULT24))
{
DEB2(printk("CPLD_SLAVE1_INTERRUPT_TX_FAULT24\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE1_TX_FAULT24_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_low_current,16,status);
}
DEB2(printk("irq_tx_fault_status_low_next = %08x irq_tx_fault_status_low_current = %08x \n",irq_tx_fault_status_low_next,irq_tx_fault_status_low_current));
}
}
else if(!(m_data & CPLD_MASTER_INTERRUPT_CPLD2))
{
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_STATUS_H_REG,&data_high8);
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_STATUS_L_REG,&data_low8);
data_16 = data_low8 | data_high8 << 8;
if(
!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT32) ||
!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT40) ||
!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT48)
)
{
if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT32))
{
DEB2(printk("CPLD_SLAVE2_PRESENT32_REG\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT32_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,0,status);
}
else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT40))
{
DEB2(printk("CPLD_SLAVE2_PRESENT40_REG\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT40_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,8,status);
}
else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT48))
{
DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT48_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_present_status_high_current,16,status);
}
}
if(
!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST32) ||
!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST40) ||
!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST48)
)
{
if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST32))
{
DEB2(printk("CPLD_SLAVE2_INTERRUPT_RX_LOST32\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST32_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,0,status);
}
else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST40))
{
DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT40\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST40_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,8,status);
}
else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_RX_LOST48))
{
DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_RX_LOST48_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_rx_lost_status_high_current,16,status);
}
}
if(
!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT32) ||
!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT40) ||
!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT48)
)
{
if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT32))
{
DEB2(printk("CPLD_SLAVE2_INTERRUPT_RX_LOST32\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT32_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,0,status);
}
else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT40))
{
DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT40\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT40_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,8,status);
}
else if(!(data_16 & CPLD_SLAVE2_INTERRUPT_TX_FAULT48))
{
DEB2(printk("CPLD_SLAVE2_INTERRUPT_PRESENT48\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_TX_FAULT48_REG,&status);
RANGE_OF_BYTE_SHIFT(irq_tx_fault_status_high_current,16,status);
}
}
if(!(data_16 & CPLD_SLAVE2_INTERRUPT_PRESENT56))
{
DEB2(printk("CPLD_SLAVE2_PRESENT56_REG\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_PRESENT56_REG,&status);
irq_present_qsfp_current = status;
}
if(!(data_16 & CPLD_SLAVE2_INTERRUPT_QSFP_CR56))
{
DEB2(printk("CPLD_SLAVE2_QSFP_CR56_REG\r\n"));
cig_cpld_read_slave_cpld_register(CPLD_SLAVE2_QSFP_CR56_REG,&status);
irq_interrupt_qsfp_current = status;
}
}
else if(!(m_data & CPLD_MASTER_INTERRUPT_LSW))
{
DEB2(printk("CPLD_MASTER_INTERRUPT_LSW\r\n"));
}
else if(!(m_data & CPLD_MASTER_INTERRUPT_PSU1))
{
DEB2(printk("CPLD_MASTER_INTERRUPT_PSU1\r\n"));
}
else if(!(m_data & CPLD_MASTER_INTERRUPT_PSU2))
{
DEB2(printk("CPLD_MASTER_INTERRUPT_PSU2\r\n"));
}
else if(!(m_data & CPLD_MASTER_INTERRUPT_6320))
{
DEB2(printk("CPLD_MASTER_INTERRUPT_6320\r\n"));
}
cig_cpld_write_slave_cpld_register(CPLD_SLAVE1_INTERRUPT_MASK_REG,0x0);
cig_cpld_write_slave_cpld_register(CPLD_SLAVE2_INTERRUPT_MASK_REG,0x0);
memset(tmp,0xff,sizeof(tmp));
for(i = 0;i < 24;i++)
{
if(!(irq_present_status_low_current & (0x1 << i)) && (irq_present_status_low_next & (0x1 << i)))
{
DEB2(printk("SFP%d is present\r\n",i+1));
tmp[0] = 1;
}
else if((irq_present_status_low_current & (0x1 << i)) && !(irq_present_status_low_next & (0x1 << i)))
{
DEB2(printk("SFP%d is absent\r\n",i+1));
tmp[0] = 0;
}
if(!(irq_tx_fault_status_low_current & (0x1 << i)) && (irq_tx_fault_status_low_next & (0x1 << i)))
{
DEB2(printk("SFP%d transmission is right\r\n",i+1));
tmp[1] = 1;
}
else if((irq_tx_fault_status_low_current & (0x1 << i)) && !(irq_tx_fault_status_low_next & (0x1 << i)))
{
DEB2(printk("SFP%d transmission is fault\r\n",i+1));
tmp[1] = 0;
}
if(!(irq_rx_lost_status_low_current & (0x1 << i)) && (irq_rx_lost_status_low_next & (0x1 << i)))
{
DEB2(printk("SFP%d optical is meet\r\n",i+1));
tmp[2] = 1;
}
else if((irq_rx_lost_status_low_current & (0x1 << i)) && !(irq_rx_lost_status_low_next & (0x1 << i)))
{
DEB2(printk("SFP%d optical is lost\r\n",i+1));
tmp[2] = 0;
}
if((tmp[0] != 0xff) || (tmp[1] != 0xff) || (tmp[2] != 0xff))
{
memset(kmsg,0xff,sizeof(kmsg));
snprintf(kmsg,sizeof(kmsg),"sfp%02d:%1d:%1d:%1d ",i+1,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],(tmp[2] == 0xff) ? 0:tmp[2]);
break;
}
}
memset(tmp,0xff,sizeof(tmp));
for(i = 0;i < 24;i++)
{
if(!(irq_present_status_high_current & (0x1 << i)) && (irq_present_status_high_next & (0x1 << i)))
{
DEB2(printk("SFP%d is present\r\n",i+25));
tmp[0] = 1;
}
else if((irq_present_status_high_current & (0x1 << i)) && !(irq_present_status_high_next & (0x1 << i)))
{
DEB2(printk("SFP%d is absent\r\n",i+25));
tmp[0] = 0;
}
if(!(irq_rx_lost_status_high_current & (0x1 << i)) && (irq_rx_lost_status_high_next & (0x1 << i)))
{
DEB2(printk("SFP%d optical is meet\r\n",i+25));
tmp[1] = 1;
}
else if((irq_rx_lost_status_high_current & (0x1 << i)) && !(irq_rx_lost_status_high_next & (0x1 << i)))
{
DEB2(printk("SFP%d optical is lost\r\n",i+25));
tmp[1] = 0;
}
if(!(irq_tx_fault_status_high_current & (0x1 << i)) && (irq_tx_fault_status_high_next & (0x1 << i)))
{
DEB2(printk("SFP%d transmission is right\r\n",i+25));
tmp[2] = 1;
}
else if((irq_tx_fault_status_high_current & (0x1 << i)) && !(irq_tx_fault_status_high_next & (0x1 << i)))
{
DEB2(printk("SFP%d transmission is fault\r\n",i+25));
tmp[2] = 0;
}
if((tmp[0] != 0xff) || (tmp[1] != 0xff) || (tmp[2] != 0xff))
{
memset(kmsg,0xff,sizeof(kmsg));
snprintf(kmsg,sizeof(kmsg),"sfp%02d:%1d:%1d:%1d ",i+25,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],(tmp[2] == 0xff) ? 0:tmp[2]);
break;
}
}
memset(tmp,0xff,sizeof(tmp));
for(i = 0 ; i < 8; i++)
{
if(!(irq_present_qsfp_current & (0x1 << i)) && (irq_present_qsfp_next & (0x1 << i)))
{
DEB2(printk("SFP%d is present\r\n",i+49));
tmp[0] = 1;
}
else if((irq_present_qsfp_current & (0x1 << i)) && !(irq_present_qsfp_next & (0x1 << i)))
{
DEB2(printk("SFP%d is absent\r\n",i+49));
tmp[0] = 0;
}
if(!(irq_interrupt_qsfp_current & (0x1 << i)) && (irq_interrupt_qsfp_next & (0x1 << i)))
{
DEB2(printk("SFP%d interrupt is occured \r\n",i+49));
tmp[1] = 1;
}
else if((irq_interrupt_qsfp_current & (0x1 << i)) && !(irq_interrupt_qsfp_next & (0x1 << i)))
{
DEB2(printk("SFP%d interrupt is cleaned\r\n",i+49));
tmp[1] = 0;
}
if((tmp[0] != 0xff) || (tmp[1] != 0xff))
{
memset(kmsg,0xff,sizeof(kmsg));
snprintf(kmsg,sizeof(kmsg),"qsfp%02d:%1d:%1d:%1d ",i+49,(tmp[0] == 0xff) ? 0:tmp[0],(tmp[1] == 0xff) ? 0:tmp[1],0);
break;
}
}
irq_present_status_low_next = irq_present_status_low_current;
irq_rx_lost_status_low_next = irq_rx_lost_status_low_current;
irq_tx_fault_status_low_next = irq_tx_fault_status_low_current;
irq_present_status_high_next = irq_present_status_high_current;
irq_rx_lost_status_high_next = irq_rx_lost_status_high_current;
irq_tx_fault_status_high_next = irq_tx_fault_status_high_current;
irq_present_qsfp_next = irq_present_qsfp_current;
irq_interrupt_qsfp_next = irq_interrupt_qsfp_current;
send_usrmsg(kmsg, strlen(kmsg));
}