1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 214fa93cdSSrikanth Jampala #include <linux/delay.h> 314fa93cdSSrikanth Jampala 414fa93cdSSrikanth Jampala #include "nitrox_dev.h" 514fa93cdSSrikanth Jampala #include "nitrox_csr.h" 614fa93cdSSrikanth Jampala 714fa93cdSSrikanth Jampala /** 814fa93cdSSrikanth Jampala * emu_enable_cores - Enable EMU cluster cores. 914fa93cdSSrikanth Jampala * @ndev: N5 device 1014fa93cdSSrikanth Jampala */ 1114fa93cdSSrikanth Jampala static void emu_enable_cores(struct nitrox_device *ndev) 1214fa93cdSSrikanth Jampala { 1314fa93cdSSrikanth Jampala union emu_se_enable emu_se; 1414fa93cdSSrikanth Jampala union emu_ae_enable emu_ae; 1514fa93cdSSrikanth Jampala int i; 1614fa93cdSSrikanth Jampala 1714fa93cdSSrikanth Jampala /* AE cores 20 per cluster */ 1814fa93cdSSrikanth Jampala emu_ae.value = 0; 1914fa93cdSSrikanth Jampala emu_ae.s.enable = 0xfffff; 2014fa93cdSSrikanth Jampala 2114fa93cdSSrikanth Jampala /* SE cores 16 per cluster */ 2214fa93cdSSrikanth Jampala emu_se.value = 0; 2314fa93cdSSrikanth Jampala emu_se.s.enable = 0xffff; 2414fa93cdSSrikanth Jampala 2514fa93cdSSrikanth Jampala /* enable per cluster cores */ 2614fa93cdSSrikanth Jampala for (i = 0; i < NR_CLUSTERS; i++) { 2714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, EMU_AE_ENABLEX(i), emu_ae.value); 2814fa93cdSSrikanth Jampala nitrox_write_csr(ndev, EMU_SE_ENABLEX(i), emu_se.value); 2914fa93cdSSrikanth Jampala } 3014fa93cdSSrikanth Jampala } 3114fa93cdSSrikanth Jampala 3214fa93cdSSrikanth Jampala /** 3314fa93cdSSrikanth Jampala * nitrox_config_emu_unit - configure EMU unit. 3414fa93cdSSrikanth Jampala * @ndev: N5 device 3514fa93cdSSrikanth Jampala */ 3614fa93cdSSrikanth Jampala void nitrox_config_emu_unit(struct nitrox_device *ndev) 3714fa93cdSSrikanth Jampala { 3814fa93cdSSrikanth Jampala union emu_wd_int_ena_w1s emu_wd_int; 3914fa93cdSSrikanth Jampala union emu_ge_int_ena_w1s emu_ge_int; 4014fa93cdSSrikanth Jampala u64 offset; 4114fa93cdSSrikanth Jampala int i; 4214fa93cdSSrikanth Jampala 4314fa93cdSSrikanth Jampala /* enable cores */ 4414fa93cdSSrikanth Jampala emu_enable_cores(ndev); 4514fa93cdSSrikanth Jampala 4614fa93cdSSrikanth Jampala /* enable general error and watch dog interrupts */ 4714fa93cdSSrikanth Jampala emu_ge_int.value = 0; 4814fa93cdSSrikanth Jampala emu_ge_int.s.se_ge = 0xffff; 4914fa93cdSSrikanth Jampala emu_ge_int.s.ae_ge = 0xfffff; 5014fa93cdSSrikanth Jampala emu_wd_int.value = 0; 5114fa93cdSSrikanth Jampala emu_wd_int.s.se_wd = 1; 5214fa93cdSSrikanth Jampala 5314fa93cdSSrikanth Jampala for (i = 0; i < NR_CLUSTERS; i++) { 5414fa93cdSSrikanth Jampala offset = EMU_WD_INT_ENA_W1SX(i); 5514fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, emu_wd_int.value); 5614fa93cdSSrikanth Jampala offset = EMU_GE_INT_ENA_W1SX(i); 5714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, emu_ge_int.value); 5814fa93cdSSrikanth Jampala } 5914fa93cdSSrikanth Jampala } 6014fa93cdSSrikanth Jampala 6114fa93cdSSrikanth Jampala static void reset_pkt_input_ring(struct nitrox_device *ndev, int ring) 6214fa93cdSSrikanth Jampala { 6314fa93cdSSrikanth Jampala union nps_pkt_in_instr_ctl pkt_in_ctl; 6414fa93cdSSrikanth Jampala union nps_pkt_in_instr_baoff_dbell pkt_in_dbell; 6514fa93cdSSrikanth Jampala union nps_pkt_in_done_cnts pkt_in_cnts; 6614fa93cdSSrikanth Jampala u64 offset; 6714fa93cdSSrikanth Jampala 6814fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_CTLX(ring); 6914fa93cdSSrikanth Jampala /* disable the ring */ 7014fa93cdSSrikanth Jampala pkt_in_ctl.value = nitrox_read_csr(ndev, offset); 7114fa93cdSSrikanth Jampala pkt_in_ctl.s.enb = 0; 7214fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_ctl.value); 7314fa93cdSSrikanth Jampala usleep_range(100, 150); 7414fa93cdSSrikanth Jampala 7514fa93cdSSrikanth Jampala /* wait to clear [ENB] */ 7614fa93cdSSrikanth Jampala do { 7714fa93cdSSrikanth Jampala pkt_in_ctl.value = nitrox_read_csr(ndev, offset); 7814fa93cdSSrikanth Jampala } while (pkt_in_ctl.s.enb); 7914fa93cdSSrikanth Jampala 8014fa93cdSSrikanth Jampala /* clear off door bell counts */ 8114fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_BAOFF_DBELLX(ring); 8214fa93cdSSrikanth Jampala pkt_in_dbell.value = 0; 8314fa93cdSSrikanth Jampala pkt_in_dbell.s.dbell = 0xffffffff; 8414fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_dbell.value); 8514fa93cdSSrikanth Jampala 8614fa93cdSSrikanth Jampala /* clear done counts */ 8714fa93cdSSrikanth Jampala offset = NPS_PKT_IN_DONE_CNTSX(ring); 8814fa93cdSSrikanth Jampala pkt_in_cnts.value = nitrox_read_csr(ndev, offset); 8914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_cnts.value); 9014fa93cdSSrikanth Jampala usleep_range(50, 100); 9114fa93cdSSrikanth Jampala } 9214fa93cdSSrikanth Jampala 9314fa93cdSSrikanth Jampala void enable_pkt_input_ring(struct nitrox_device *ndev, int ring) 9414fa93cdSSrikanth Jampala { 9514fa93cdSSrikanth Jampala union nps_pkt_in_instr_ctl pkt_in_ctl; 9614fa93cdSSrikanth Jampala u64 offset; 9714fa93cdSSrikanth Jampala 9814fa93cdSSrikanth Jampala /* 64-byte instruction size */ 9914fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_CTLX(ring); 10014fa93cdSSrikanth Jampala pkt_in_ctl.value = nitrox_read_csr(ndev, offset); 10114fa93cdSSrikanth Jampala pkt_in_ctl.s.is64b = 1; 10214fa93cdSSrikanth Jampala pkt_in_ctl.s.enb = 1; 10314fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_ctl.value); 10414fa93cdSSrikanth Jampala 10514fa93cdSSrikanth Jampala /* wait for set [ENB] */ 10614fa93cdSSrikanth Jampala do { 10714fa93cdSSrikanth Jampala pkt_in_ctl.value = nitrox_read_csr(ndev, offset); 10814fa93cdSSrikanth Jampala } while (!pkt_in_ctl.s.enb); 10914fa93cdSSrikanth Jampala } 11014fa93cdSSrikanth Jampala 11114fa93cdSSrikanth Jampala /** 11214fa93cdSSrikanth Jampala * nitrox_config_pkt_input_rings - configure Packet Input Rings 11314fa93cdSSrikanth Jampala * @ndev: N5 device 11414fa93cdSSrikanth Jampala */ 11514fa93cdSSrikanth Jampala void nitrox_config_pkt_input_rings(struct nitrox_device *ndev) 11614fa93cdSSrikanth Jampala { 11714fa93cdSSrikanth Jampala int i; 11814fa93cdSSrikanth Jampala 11914fa93cdSSrikanth Jampala for (i = 0; i < ndev->nr_queues; i++) { 12014fa93cdSSrikanth Jampala struct nitrox_cmdq *cmdq = &ndev->pkt_cmdqs[i]; 12114fa93cdSSrikanth Jampala union nps_pkt_in_instr_rsize pkt_in_rsize; 12214fa93cdSSrikanth Jampala u64 offset; 12314fa93cdSSrikanth Jampala 12414fa93cdSSrikanth Jampala reset_pkt_input_ring(ndev, i); 12514fa93cdSSrikanth Jampala 12614fa93cdSSrikanth Jampala /* configure ring base address 16-byte aligned, 12714fa93cdSSrikanth Jampala * size and interrupt threshold. 12814fa93cdSSrikanth Jampala */ 12914fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_BADDRX(i); 13014fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_PKT_IN_INSTR_BADDRX(i), cmdq->dma); 13114fa93cdSSrikanth Jampala 13214fa93cdSSrikanth Jampala /* configure ring size */ 13314fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_RSIZEX(i); 13414fa93cdSSrikanth Jampala pkt_in_rsize.value = 0; 13514fa93cdSSrikanth Jampala pkt_in_rsize.s.rsize = ndev->qlen; 13614fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_rsize.value); 13714fa93cdSSrikanth Jampala 13814fa93cdSSrikanth Jampala /* set high threshold for pkt input ring interrupts */ 13914fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INT_LEVELSX(i); 14014fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, 0xffffffff); 14114fa93cdSSrikanth Jampala 14214fa93cdSSrikanth Jampala enable_pkt_input_ring(ndev, i); 14314fa93cdSSrikanth Jampala } 14414fa93cdSSrikanth Jampala } 14514fa93cdSSrikanth Jampala 14614fa93cdSSrikanth Jampala static void reset_pkt_solicit_port(struct nitrox_device *ndev, int port) 14714fa93cdSSrikanth Jampala { 14814fa93cdSSrikanth Jampala union nps_pkt_slc_ctl pkt_slc_ctl; 14914fa93cdSSrikanth Jampala union nps_pkt_slc_cnts pkt_slc_cnts; 15014fa93cdSSrikanth Jampala u64 offset; 15114fa93cdSSrikanth Jampala 15214fa93cdSSrikanth Jampala /* disable slc port */ 15314fa93cdSSrikanth Jampala offset = NPS_PKT_SLC_CTLX(port); 15414fa93cdSSrikanth Jampala pkt_slc_ctl.value = nitrox_read_csr(ndev, offset); 15514fa93cdSSrikanth Jampala pkt_slc_ctl.s.enb = 0; 15614fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_slc_ctl.value); 15714fa93cdSSrikanth Jampala usleep_range(100, 150); 15814fa93cdSSrikanth Jampala 15914fa93cdSSrikanth Jampala /* wait to clear [ENB] */ 16014fa93cdSSrikanth Jampala do { 16114fa93cdSSrikanth Jampala pkt_slc_ctl.value = nitrox_read_csr(ndev, offset); 16214fa93cdSSrikanth Jampala } while (pkt_slc_ctl.s.enb); 16314fa93cdSSrikanth Jampala 16414fa93cdSSrikanth Jampala /* clear slc counters */ 16514fa93cdSSrikanth Jampala offset = NPS_PKT_SLC_CNTSX(port); 16614fa93cdSSrikanth Jampala pkt_slc_cnts.value = nitrox_read_csr(ndev, offset); 16714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_slc_cnts.value); 16814fa93cdSSrikanth Jampala usleep_range(50, 100); 16914fa93cdSSrikanth Jampala } 17014fa93cdSSrikanth Jampala 17114fa93cdSSrikanth Jampala void enable_pkt_solicit_port(struct nitrox_device *ndev, int port) 17214fa93cdSSrikanth Jampala { 17314fa93cdSSrikanth Jampala union nps_pkt_slc_ctl pkt_slc_ctl; 17414fa93cdSSrikanth Jampala u64 offset; 17514fa93cdSSrikanth Jampala 17614fa93cdSSrikanth Jampala offset = NPS_PKT_SLC_CTLX(port); 17714fa93cdSSrikanth Jampala pkt_slc_ctl.value = 0; 17814fa93cdSSrikanth Jampala pkt_slc_ctl.s.enb = 1; 17914fa93cdSSrikanth Jampala 18014fa93cdSSrikanth Jampala /* 18114fa93cdSSrikanth Jampala * 8 trailing 0x00 bytes will be added 18214fa93cdSSrikanth Jampala * to the end of the outgoing packet. 18314fa93cdSSrikanth Jampala */ 18414fa93cdSSrikanth Jampala pkt_slc_ctl.s.z = 1; 18514fa93cdSSrikanth Jampala /* enable response header */ 18614fa93cdSSrikanth Jampala pkt_slc_ctl.s.rh = 1; 18714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_slc_ctl.value); 18814fa93cdSSrikanth Jampala 18914fa93cdSSrikanth Jampala /* wait to set [ENB] */ 19014fa93cdSSrikanth Jampala do { 19114fa93cdSSrikanth Jampala pkt_slc_ctl.value = nitrox_read_csr(ndev, offset); 19214fa93cdSSrikanth Jampala } while (!pkt_slc_ctl.s.enb); 19314fa93cdSSrikanth Jampala } 19414fa93cdSSrikanth Jampala 19514fa93cdSSrikanth Jampala static void config_single_pkt_solicit_port(struct nitrox_device *ndev, 19614fa93cdSSrikanth Jampala int port) 19714fa93cdSSrikanth Jampala { 19814fa93cdSSrikanth Jampala union nps_pkt_slc_int_levels pkt_slc_int; 19914fa93cdSSrikanth Jampala u64 offset; 20014fa93cdSSrikanth Jampala 20114fa93cdSSrikanth Jampala reset_pkt_solicit_port(ndev, port); 20214fa93cdSSrikanth Jampala 20314fa93cdSSrikanth Jampala offset = NPS_PKT_SLC_INT_LEVELSX(port); 20414fa93cdSSrikanth Jampala pkt_slc_int.value = 0; 20514fa93cdSSrikanth Jampala /* time interrupt threshold */ 20614fa93cdSSrikanth Jampala pkt_slc_int.s.timet = 0x3fffff; 20714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_slc_int.value); 20814fa93cdSSrikanth Jampala 20914fa93cdSSrikanth Jampala enable_pkt_solicit_port(ndev, port); 21014fa93cdSSrikanth Jampala } 21114fa93cdSSrikanth Jampala 21214fa93cdSSrikanth Jampala void nitrox_config_pkt_solicit_ports(struct nitrox_device *ndev) 21314fa93cdSSrikanth Jampala { 21414fa93cdSSrikanth Jampala int i; 21514fa93cdSSrikanth Jampala 21614fa93cdSSrikanth Jampala for (i = 0; i < ndev->nr_queues; i++) 21714fa93cdSSrikanth Jampala config_single_pkt_solicit_port(ndev, i); 21814fa93cdSSrikanth Jampala } 21914fa93cdSSrikanth Jampala 22014fa93cdSSrikanth Jampala /** 22114fa93cdSSrikanth Jampala * enable_nps_interrupts - enable NPS interrutps 22214fa93cdSSrikanth Jampala * @ndev: N5 device. 22314fa93cdSSrikanth Jampala * 22414fa93cdSSrikanth Jampala * This includes NPS core, packet in and slc interrupts. 22514fa93cdSSrikanth Jampala */ 22614fa93cdSSrikanth Jampala static void enable_nps_interrupts(struct nitrox_device *ndev) 22714fa93cdSSrikanth Jampala { 22814fa93cdSSrikanth Jampala union nps_core_int_ena_w1s core_int; 22914fa93cdSSrikanth Jampala 23014fa93cdSSrikanth Jampala /* NPS core interrutps */ 23114fa93cdSSrikanth Jampala core_int.value = 0; 23214fa93cdSSrikanth Jampala core_int.s.host_wr_err = 1; 23314fa93cdSSrikanth Jampala core_int.s.host_wr_timeout = 1; 23414fa93cdSSrikanth Jampala core_int.s.exec_wr_timeout = 1; 23514fa93cdSSrikanth Jampala core_int.s.npco_dma_malform = 1; 23614fa93cdSSrikanth Jampala core_int.s.host_nps_wr_err = 1; 23714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_CORE_INT_ENA_W1S, core_int.value); 23814fa93cdSSrikanth Jampala 23914fa93cdSSrikanth Jampala /* NPS packet in ring interrupts */ 24014fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_PKT_IN_RERR_LO_ENA_W1S, (~0ULL)); 24114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_PKT_IN_RERR_HI_ENA_W1S, (~0ULL)); 24214fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_PKT_IN_ERR_TYPE_ENA_W1S, (~0ULL)); 24314fa93cdSSrikanth Jampala /* NPS packet slc port interrupts */ 24414fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_PKT_SLC_RERR_HI_ENA_W1S, (~0ULL)); 24514fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_PKT_SLC_RERR_LO_ENA_W1S, (~0ULL)); 24614fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_PKT_SLC_ERR_TYPE_ENA_W1S, (~0uLL)); 24714fa93cdSSrikanth Jampala } 24814fa93cdSSrikanth Jampala 24914fa93cdSSrikanth Jampala void nitrox_config_nps_unit(struct nitrox_device *ndev) 25014fa93cdSSrikanth Jampala { 25114fa93cdSSrikanth Jampala union nps_core_gbl_vfcfg core_gbl_vfcfg; 25214fa93cdSSrikanth Jampala 25314fa93cdSSrikanth Jampala /* endian control information */ 25414fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_CORE_CONTROL, 1ULL); 25514fa93cdSSrikanth Jampala 25614fa93cdSSrikanth Jampala /* disable ILK interface */ 25714fa93cdSSrikanth Jampala core_gbl_vfcfg.value = 0; 25814fa93cdSSrikanth Jampala core_gbl_vfcfg.s.ilk_disable = 1; 25914fa93cdSSrikanth Jampala core_gbl_vfcfg.s.cfg = PF_MODE; 26014fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_CORE_GBL_VFCFG, core_gbl_vfcfg.value); 26114fa93cdSSrikanth Jampala /* config input and solicit ports */ 26214fa93cdSSrikanth Jampala nitrox_config_pkt_input_rings(ndev); 26314fa93cdSSrikanth Jampala nitrox_config_pkt_solicit_ports(ndev); 26414fa93cdSSrikanth Jampala 26514fa93cdSSrikanth Jampala /* enable interrupts */ 26614fa93cdSSrikanth Jampala enable_nps_interrupts(ndev); 26714fa93cdSSrikanth Jampala } 26814fa93cdSSrikanth Jampala 26914fa93cdSSrikanth Jampala void nitrox_config_pom_unit(struct nitrox_device *ndev) 27014fa93cdSSrikanth Jampala { 27114fa93cdSSrikanth Jampala union pom_int_ena_w1s pom_int; 27214fa93cdSSrikanth Jampala int i; 27314fa93cdSSrikanth Jampala 27414fa93cdSSrikanth Jampala /* enable pom interrupts */ 27514fa93cdSSrikanth Jampala pom_int.value = 0; 27614fa93cdSSrikanth Jampala pom_int.s.illegal_dport = 1; 27714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, POM_INT_ENA_W1S, pom_int.value); 27814fa93cdSSrikanth Jampala 27914fa93cdSSrikanth Jampala /* enable perf counters */ 28014fa93cdSSrikanth Jampala for (i = 0; i < ndev->hw.se_cores; i++) 28114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, POM_PERF_CTL, BIT_ULL(i)); 28214fa93cdSSrikanth Jampala } 28314fa93cdSSrikanth Jampala 28414fa93cdSSrikanth Jampala /** 28514fa93cdSSrikanth Jampala * nitrox_config_rand_unit - enable N5 random number unit 28614fa93cdSSrikanth Jampala * @ndev: N5 device 28714fa93cdSSrikanth Jampala */ 28814fa93cdSSrikanth Jampala void nitrox_config_rand_unit(struct nitrox_device *ndev) 28914fa93cdSSrikanth Jampala { 29014fa93cdSSrikanth Jampala union efl_rnm_ctl_status efl_rnm_ctl; 29114fa93cdSSrikanth Jampala u64 offset; 29214fa93cdSSrikanth Jampala 29314fa93cdSSrikanth Jampala offset = EFL_RNM_CTL_STATUS; 29414fa93cdSSrikanth Jampala efl_rnm_ctl.value = nitrox_read_csr(ndev, offset); 29514fa93cdSSrikanth Jampala efl_rnm_ctl.s.ent_en = 1; 29614fa93cdSSrikanth Jampala efl_rnm_ctl.s.rng_en = 1; 29714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, efl_rnm_ctl.value); 29814fa93cdSSrikanth Jampala } 29914fa93cdSSrikanth Jampala 30014fa93cdSSrikanth Jampala void nitrox_config_efl_unit(struct nitrox_device *ndev) 30114fa93cdSSrikanth Jampala { 30214fa93cdSSrikanth Jampala int i; 30314fa93cdSSrikanth Jampala 30414fa93cdSSrikanth Jampala for (i = 0; i < NR_CLUSTERS; i++) { 30514fa93cdSSrikanth Jampala union efl_core_int_ena_w1s efl_core_int; 30614fa93cdSSrikanth Jampala u64 offset; 30714fa93cdSSrikanth Jampala 30814fa93cdSSrikanth Jampala /* EFL core interrupts */ 30914fa93cdSSrikanth Jampala offset = EFL_CORE_INT_ENA_W1SX(i); 31014fa93cdSSrikanth Jampala efl_core_int.value = 0; 31114fa93cdSSrikanth Jampala efl_core_int.s.len_ovr = 1; 31214fa93cdSSrikanth Jampala efl_core_int.s.d_left = 1; 31314fa93cdSSrikanth Jampala efl_core_int.s.epci_decode_err = 1; 31414fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, efl_core_int.value); 31514fa93cdSSrikanth Jampala 31614fa93cdSSrikanth Jampala offset = EFL_CORE_VF_ERR_INT0_ENA_W1SX(i); 31714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL)); 31814fa93cdSSrikanth Jampala offset = EFL_CORE_VF_ERR_INT1_ENA_W1SX(i); 31914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL)); 32014fa93cdSSrikanth Jampala } 32114fa93cdSSrikanth Jampala } 32214fa93cdSSrikanth Jampala 32314fa93cdSSrikanth Jampala void nitrox_config_bmi_unit(struct nitrox_device *ndev) 32414fa93cdSSrikanth Jampala { 32514fa93cdSSrikanth Jampala union bmi_ctl bmi_ctl; 32614fa93cdSSrikanth Jampala union bmi_int_ena_w1s bmi_int_ena; 32714fa93cdSSrikanth Jampala u64 offset; 32814fa93cdSSrikanth Jampala 32914fa93cdSSrikanth Jampala /* no threshold limits for PCIe */ 33014fa93cdSSrikanth Jampala offset = BMI_CTL; 33114fa93cdSSrikanth Jampala bmi_ctl.value = nitrox_read_csr(ndev, offset); 33214fa93cdSSrikanth Jampala bmi_ctl.s.max_pkt_len = 0xff; 33314fa93cdSSrikanth Jampala bmi_ctl.s.nps_free_thrsh = 0xff; 33414fa93cdSSrikanth Jampala bmi_ctl.s.nps_hdrq_thrsh = 0x7a; 33514fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, bmi_ctl.value); 33614fa93cdSSrikanth Jampala 33714fa93cdSSrikanth Jampala /* enable interrupts */ 33814fa93cdSSrikanth Jampala offset = BMI_INT_ENA_W1S; 33914fa93cdSSrikanth Jampala bmi_int_ena.value = 0; 34014fa93cdSSrikanth Jampala bmi_int_ena.s.max_len_err_nps = 1; 34114fa93cdSSrikanth Jampala bmi_int_ena.s.pkt_rcv_err_nps = 1; 34214fa93cdSSrikanth Jampala bmi_int_ena.s.fpf_undrrn = 1; 34314fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, bmi_int_ena.value); 34414fa93cdSSrikanth Jampala } 34514fa93cdSSrikanth Jampala 34614fa93cdSSrikanth Jampala void nitrox_config_bmo_unit(struct nitrox_device *ndev) 34714fa93cdSSrikanth Jampala { 34814fa93cdSSrikanth Jampala union bmo_ctl2 bmo_ctl2; 34914fa93cdSSrikanth Jampala u64 offset; 35014fa93cdSSrikanth Jampala 35114fa93cdSSrikanth Jampala /* no threshold limits for PCIe */ 35214fa93cdSSrikanth Jampala offset = BMO_CTL2; 35314fa93cdSSrikanth Jampala bmo_ctl2.value = nitrox_read_csr(ndev, offset); 35414fa93cdSSrikanth Jampala bmo_ctl2.s.nps_slc_buf_thrsh = 0xff; 35514fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, bmo_ctl2.value); 35614fa93cdSSrikanth Jampala } 35714fa93cdSSrikanth Jampala 35814fa93cdSSrikanth Jampala void invalidate_lbc(struct nitrox_device *ndev) 35914fa93cdSSrikanth Jampala { 36014fa93cdSSrikanth Jampala union lbc_inval_ctl lbc_ctl; 36114fa93cdSSrikanth Jampala union lbc_inval_status lbc_stat; 36214fa93cdSSrikanth Jampala u64 offset; 36314fa93cdSSrikanth Jampala 36414fa93cdSSrikanth Jampala /* invalidate LBC */ 36514fa93cdSSrikanth Jampala offset = LBC_INVAL_CTL; 36614fa93cdSSrikanth Jampala lbc_ctl.value = nitrox_read_csr(ndev, offset); 36714fa93cdSSrikanth Jampala lbc_ctl.s.cam_inval_start = 1; 36814fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, lbc_ctl.value); 36914fa93cdSSrikanth Jampala 37014fa93cdSSrikanth Jampala offset = LBC_INVAL_STATUS; 37114fa93cdSSrikanth Jampala 37214fa93cdSSrikanth Jampala do { 37314fa93cdSSrikanth Jampala lbc_stat.value = nitrox_read_csr(ndev, offset); 37414fa93cdSSrikanth Jampala } while (!lbc_stat.s.done); 37514fa93cdSSrikanth Jampala } 37614fa93cdSSrikanth Jampala 37714fa93cdSSrikanth Jampala void nitrox_config_lbc_unit(struct nitrox_device *ndev) 37814fa93cdSSrikanth Jampala { 37914fa93cdSSrikanth Jampala union lbc_int_ena_w1s lbc_int_ena; 38014fa93cdSSrikanth Jampala u64 offset; 38114fa93cdSSrikanth Jampala 38214fa93cdSSrikanth Jampala invalidate_lbc(ndev); 38314fa93cdSSrikanth Jampala 38414fa93cdSSrikanth Jampala /* enable interrupts */ 38514fa93cdSSrikanth Jampala offset = LBC_INT_ENA_W1S; 38614fa93cdSSrikanth Jampala lbc_int_ena.value = 0; 38714fa93cdSSrikanth Jampala lbc_int_ena.s.dma_rd_err = 1; 38814fa93cdSSrikanth Jampala lbc_int_ena.s.over_fetch_err = 1; 38914fa93cdSSrikanth Jampala lbc_int_ena.s.cam_inval_abort = 1; 39014fa93cdSSrikanth Jampala lbc_int_ena.s.cam_hard_err = 1; 39114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, lbc_int_ena.value); 39214fa93cdSSrikanth Jampala 39314fa93cdSSrikanth Jampala offset = LBC_PLM_VF1_64_INT_ENA_W1S; 39414fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL)); 39514fa93cdSSrikanth Jampala offset = LBC_PLM_VF65_128_INT_ENA_W1S; 39614fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL)); 39714fa93cdSSrikanth Jampala 39814fa93cdSSrikanth Jampala offset = LBC_ELM_VF1_64_INT_ENA_W1S; 39914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL)); 40014fa93cdSSrikanth Jampala offset = LBC_ELM_VF65_128_INT_ENA_W1S; 40114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL)); 40214fa93cdSSrikanth Jampala } 403