1b2441318SGreg 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"
6*cd078cb6SHerbert Xu #include "nitrox_hal.h"
714fa93cdSSrikanth Jampala
848e10548SSrikanth Jampala #define PLL_REF_CLK 50
9cf718eaaSSrikanth, Jampala #define MAX_CSR_RETRIES 10
1048e10548SSrikanth Jampala
1114fa93cdSSrikanth Jampala /**
1214fa93cdSSrikanth Jampala * emu_enable_cores - Enable EMU cluster cores.
13cf718eaaSSrikanth, Jampala * @ndev: NITROX device
1414fa93cdSSrikanth Jampala */
emu_enable_cores(struct nitrox_device * ndev)1514fa93cdSSrikanth Jampala static void emu_enable_cores(struct nitrox_device *ndev)
1614fa93cdSSrikanth Jampala {
1714fa93cdSSrikanth Jampala union emu_se_enable emu_se;
1814fa93cdSSrikanth Jampala union emu_ae_enable emu_ae;
1914fa93cdSSrikanth Jampala int i;
2014fa93cdSSrikanth Jampala
2114fa93cdSSrikanth Jampala /* AE cores 20 per cluster */
2214fa93cdSSrikanth Jampala emu_ae.value = 0;
2314fa93cdSSrikanth Jampala emu_ae.s.enable = 0xfffff;
2414fa93cdSSrikanth Jampala
2514fa93cdSSrikanth Jampala /* SE cores 16 per cluster */
2614fa93cdSSrikanth Jampala emu_se.value = 0;
2714fa93cdSSrikanth Jampala emu_se.s.enable = 0xffff;
2814fa93cdSSrikanth Jampala
2914fa93cdSSrikanth Jampala /* enable per cluster cores */
3014fa93cdSSrikanth Jampala for (i = 0; i < NR_CLUSTERS; i++) {
3114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, EMU_AE_ENABLEX(i), emu_ae.value);
3214fa93cdSSrikanth Jampala nitrox_write_csr(ndev, EMU_SE_ENABLEX(i), emu_se.value);
3314fa93cdSSrikanth Jampala }
3414fa93cdSSrikanth Jampala }
3514fa93cdSSrikanth Jampala
3614fa93cdSSrikanth Jampala /**
3714fa93cdSSrikanth Jampala * nitrox_config_emu_unit - configure EMU unit.
38cf718eaaSSrikanth, Jampala * @ndev: NITROX device
3914fa93cdSSrikanth Jampala */
nitrox_config_emu_unit(struct nitrox_device * ndev)4014fa93cdSSrikanth Jampala void nitrox_config_emu_unit(struct nitrox_device *ndev)
4114fa93cdSSrikanth Jampala {
4214fa93cdSSrikanth Jampala union emu_wd_int_ena_w1s emu_wd_int;
4314fa93cdSSrikanth Jampala union emu_ge_int_ena_w1s emu_ge_int;
4414fa93cdSSrikanth Jampala u64 offset;
4514fa93cdSSrikanth Jampala int i;
4614fa93cdSSrikanth Jampala
4714fa93cdSSrikanth Jampala /* enable cores */
4814fa93cdSSrikanth Jampala emu_enable_cores(ndev);
4914fa93cdSSrikanth Jampala
5014fa93cdSSrikanth Jampala /* enable general error and watch dog interrupts */
5114fa93cdSSrikanth Jampala emu_ge_int.value = 0;
5214fa93cdSSrikanth Jampala emu_ge_int.s.se_ge = 0xffff;
5314fa93cdSSrikanth Jampala emu_ge_int.s.ae_ge = 0xfffff;
5414fa93cdSSrikanth Jampala emu_wd_int.value = 0;
5514fa93cdSSrikanth Jampala emu_wd_int.s.se_wd = 1;
5614fa93cdSSrikanth Jampala
5714fa93cdSSrikanth Jampala for (i = 0; i < NR_CLUSTERS; i++) {
5814fa93cdSSrikanth Jampala offset = EMU_WD_INT_ENA_W1SX(i);
5914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, emu_wd_int.value);
6014fa93cdSSrikanth Jampala offset = EMU_GE_INT_ENA_W1SX(i);
6114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, emu_ge_int.value);
6214fa93cdSSrikanth Jampala }
6314fa93cdSSrikanth Jampala }
6414fa93cdSSrikanth Jampala
reset_pkt_input_ring(struct nitrox_device * ndev,int ring)6514fa93cdSSrikanth Jampala static void reset_pkt_input_ring(struct nitrox_device *ndev, int ring)
6614fa93cdSSrikanth Jampala {
6714fa93cdSSrikanth Jampala union nps_pkt_in_instr_ctl pkt_in_ctl;
6814fa93cdSSrikanth Jampala union nps_pkt_in_done_cnts pkt_in_cnts;
69cf718eaaSSrikanth, Jampala int max_retries = MAX_CSR_RETRIES;
7014fa93cdSSrikanth Jampala u64 offset;
7114fa93cdSSrikanth Jampala
72cf718eaaSSrikanth, Jampala /* step 1: disable the ring, clear enable bit */
7314fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_CTLX(ring);
7414fa93cdSSrikanth Jampala pkt_in_ctl.value = nitrox_read_csr(ndev, offset);
7514fa93cdSSrikanth Jampala pkt_in_ctl.s.enb = 0;
7614fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_ctl.value);
7714fa93cdSSrikanth Jampala
78cf718eaaSSrikanth, Jampala /* step 2: wait to clear [ENB] */
79cf718eaaSSrikanth, Jampala usleep_range(100, 150);
8014fa93cdSSrikanth Jampala do {
8114fa93cdSSrikanth Jampala pkt_in_ctl.value = nitrox_read_csr(ndev, offset);
82cf718eaaSSrikanth, Jampala if (!pkt_in_ctl.s.enb)
83cf718eaaSSrikanth, Jampala break;
84cf718eaaSSrikanth, Jampala udelay(50);
85cf718eaaSSrikanth, Jampala } while (max_retries--);
8614fa93cdSSrikanth Jampala
87cf718eaaSSrikanth, Jampala /* step 3: clear done counts */
8814fa93cdSSrikanth Jampala offset = NPS_PKT_IN_DONE_CNTSX(ring);
8914fa93cdSSrikanth Jampala pkt_in_cnts.value = nitrox_read_csr(ndev, offset);
9014fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_cnts.value);
9114fa93cdSSrikanth Jampala usleep_range(50, 100);
9214fa93cdSSrikanth Jampala }
9314fa93cdSSrikanth Jampala
enable_pkt_input_ring(struct nitrox_device * ndev,int ring)9414fa93cdSSrikanth Jampala void enable_pkt_input_ring(struct nitrox_device *ndev, int ring)
9514fa93cdSSrikanth Jampala {
9614fa93cdSSrikanth Jampala union nps_pkt_in_instr_ctl pkt_in_ctl;
97cf718eaaSSrikanth, Jampala int max_retries = MAX_CSR_RETRIES;
9814fa93cdSSrikanth Jampala u64 offset;
9914fa93cdSSrikanth Jampala
10014fa93cdSSrikanth Jampala /* 64-byte instruction size */
10114fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_CTLX(ring);
10214fa93cdSSrikanth Jampala pkt_in_ctl.value = nitrox_read_csr(ndev, offset);
10314fa93cdSSrikanth Jampala pkt_in_ctl.s.is64b = 1;
10414fa93cdSSrikanth Jampala pkt_in_ctl.s.enb = 1;
10514fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_ctl.value);
10614fa93cdSSrikanth Jampala
10714fa93cdSSrikanth Jampala /* wait for set [ENB] */
10814fa93cdSSrikanth Jampala do {
10914fa93cdSSrikanth Jampala pkt_in_ctl.value = nitrox_read_csr(ndev, offset);
110cf718eaaSSrikanth, Jampala if (pkt_in_ctl.s.enb)
111cf718eaaSSrikanth, Jampala break;
112cf718eaaSSrikanth, Jampala udelay(50);
113cf718eaaSSrikanth, Jampala } while (max_retries--);
11414fa93cdSSrikanth Jampala }
11514fa93cdSSrikanth Jampala
11614fa93cdSSrikanth Jampala /**
11714fa93cdSSrikanth Jampala * nitrox_config_pkt_input_rings - configure Packet Input Rings
118cf718eaaSSrikanth, Jampala * @ndev: NITROX device
11914fa93cdSSrikanth Jampala */
nitrox_config_pkt_input_rings(struct nitrox_device * ndev)12014fa93cdSSrikanth Jampala void nitrox_config_pkt_input_rings(struct nitrox_device *ndev)
12114fa93cdSSrikanth Jampala {
12214fa93cdSSrikanth Jampala int i;
12314fa93cdSSrikanth Jampala
12414fa93cdSSrikanth Jampala for (i = 0; i < ndev->nr_queues; i++) {
125e7892dd6SSrikanth Jampala struct nitrox_cmdq *cmdq = &ndev->pkt_inq[i];
12614fa93cdSSrikanth Jampala union nps_pkt_in_instr_rsize pkt_in_rsize;
127cf718eaaSSrikanth, Jampala union nps_pkt_in_instr_baoff_dbell pkt_in_dbell;
12814fa93cdSSrikanth Jampala u64 offset;
12914fa93cdSSrikanth Jampala
13014fa93cdSSrikanth Jampala reset_pkt_input_ring(ndev, i);
13114fa93cdSSrikanth Jampala
132cf718eaaSSrikanth, Jampala /**
133cf718eaaSSrikanth, Jampala * step 4:
134cf718eaaSSrikanth, Jampala * configure ring base address 16-byte aligned,
13514fa93cdSSrikanth Jampala * size and interrupt threshold.
13614fa93cdSSrikanth Jampala */
13714fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_BADDRX(i);
1382f1fedcaSColin Ian King nitrox_write_csr(ndev, offset, cmdq->dma);
13914fa93cdSSrikanth Jampala
14014fa93cdSSrikanth Jampala /* configure ring size */
14114fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INSTR_RSIZEX(i);
14214fa93cdSSrikanth Jampala pkt_in_rsize.value = 0;
14314fa93cdSSrikanth Jampala pkt_in_rsize.s.rsize = ndev->qlen;
14414fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_in_rsize.value);
14514fa93cdSSrikanth Jampala
14614fa93cdSSrikanth Jampala /* set high threshold for pkt input ring interrupts */
14714fa93cdSSrikanth Jampala offset = NPS_PKT_IN_INT_LEVELSX(i);
14814fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, 0xffffffff);
14914fa93cdSSrikanth Jampala
150cf718eaaSSrikanth, Jampala /* step 5: clear off door bell counts */
151cf718eaaSSrikanth, Jampala offset = NPS_PKT_IN_INSTR_BAOFF_DBELLX(i);
152cf718eaaSSrikanth, Jampala pkt_in_dbell.value = 0;
153cf718eaaSSrikanth, Jampala pkt_in_dbell.s.dbell = 0xffffffff;
154cf718eaaSSrikanth, Jampala nitrox_write_csr(ndev, offset, pkt_in_dbell.value);
155cf718eaaSSrikanth, Jampala
156cf718eaaSSrikanth, Jampala /* enable the ring */
15714fa93cdSSrikanth Jampala enable_pkt_input_ring(ndev, i);
15814fa93cdSSrikanth Jampala }
15914fa93cdSSrikanth Jampala }
16014fa93cdSSrikanth Jampala
reset_pkt_solicit_port(struct nitrox_device * ndev,int port)16114fa93cdSSrikanth Jampala static void reset_pkt_solicit_port(struct nitrox_device *ndev, int port)
16214fa93cdSSrikanth Jampala {
16314fa93cdSSrikanth Jampala union nps_pkt_slc_ctl pkt_slc_ctl;
16414fa93cdSSrikanth Jampala union nps_pkt_slc_cnts pkt_slc_cnts;
165cf718eaaSSrikanth, Jampala int max_retries = MAX_CSR_RETRIES;
16614fa93cdSSrikanth Jampala u64 offset;
16714fa93cdSSrikanth Jampala
168cf718eaaSSrikanth, Jampala /* step 1: disable slc port */
16914fa93cdSSrikanth Jampala offset = NPS_PKT_SLC_CTLX(port);
17014fa93cdSSrikanth Jampala pkt_slc_ctl.value = nitrox_read_csr(ndev, offset);
17114fa93cdSSrikanth Jampala pkt_slc_ctl.s.enb = 0;
17214fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_slc_ctl.value);
17314fa93cdSSrikanth Jampala
174cf718eaaSSrikanth, Jampala /* step 2 */
175cf718eaaSSrikanth, Jampala usleep_range(100, 150);
17614fa93cdSSrikanth Jampala /* wait to clear [ENB] */
17714fa93cdSSrikanth Jampala do {
17814fa93cdSSrikanth Jampala pkt_slc_ctl.value = nitrox_read_csr(ndev, offset);
179cf718eaaSSrikanth, Jampala if (!pkt_slc_ctl.s.enb)
180cf718eaaSSrikanth, Jampala break;
181cf718eaaSSrikanth, Jampala udelay(50);
182cf718eaaSSrikanth, Jampala } while (max_retries--);
18314fa93cdSSrikanth Jampala
184cf718eaaSSrikanth, Jampala /* step 3: clear slc counters */
18514fa93cdSSrikanth Jampala offset = NPS_PKT_SLC_CNTSX(port);
18614fa93cdSSrikanth Jampala pkt_slc_cnts.value = nitrox_read_csr(ndev, offset);
18714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_slc_cnts.value);
18814fa93cdSSrikanth Jampala usleep_range(50, 100);
18914fa93cdSSrikanth Jampala }
19014fa93cdSSrikanth Jampala
enable_pkt_solicit_port(struct nitrox_device * ndev,int port)19114fa93cdSSrikanth Jampala void enable_pkt_solicit_port(struct nitrox_device *ndev, int port)
19214fa93cdSSrikanth Jampala {
19314fa93cdSSrikanth Jampala union nps_pkt_slc_ctl pkt_slc_ctl;
194cf718eaaSSrikanth, Jampala int max_retries = MAX_CSR_RETRIES;
19514fa93cdSSrikanth Jampala u64 offset;
19614fa93cdSSrikanth Jampala
19714fa93cdSSrikanth Jampala offset = NPS_PKT_SLC_CTLX(port);
19814fa93cdSSrikanth Jampala pkt_slc_ctl.value = 0;
19914fa93cdSSrikanth Jampala pkt_slc_ctl.s.enb = 1;
20014fa93cdSSrikanth Jampala /*
20114fa93cdSSrikanth Jampala * 8 trailing 0x00 bytes will be added
20214fa93cdSSrikanth Jampala * to the end of the outgoing packet.
20314fa93cdSSrikanth Jampala */
20414fa93cdSSrikanth Jampala pkt_slc_ctl.s.z = 1;
20514fa93cdSSrikanth Jampala /* enable response header */
20614fa93cdSSrikanth Jampala pkt_slc_ctl.s.rh = 1;
20714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_slc_ctl.value);
20814fa93cdSSrikanth Jampala
20914fa93cdSSrikanth Jampala /* wait to set [ENB] */
21014fa93cdSSrikanth Jampala do {
21114fa93cdSSrikanth Jampala pkt_slc_ctl.value = nitrox_read_csr(ndev, offset);
212cf718eaaSSrikanth, Jampala if (pkt_slc_ctl.s.enb)
213cf718eaaSSrikanth, Jampala break;
214cf718eaaSSrikanth, Jampala udelay(50);
215cf718eaaSSrikanth, Jampala } while (max_retries--);
21614fa93cdSSrikanth Jampala }
21714fa93cdSSrikanth Jampala
config_pkt_solicit_port(struct nitrox_device * ndev,int port)218cf718eaaSSrikanth, Jampala static void config_pkt_solicit_port(struct nitrox_device *ndev, int port)
21914fa93cdSSrikanth Jampala {
22014fa93cdSSrikanth Jampala union nps_pkt_slc_int_levels pkt_slc_int;
22114fa93cdSSrikanth Jampala u64 offset;
22214fa93cdSSrikanth Jampala
22314fa93cdSSrikanth Jampala reset_pkt_solicit_port(ndev, port);
22414fa93cdSSrikanth Jampala
225cf718eaaSSrikanth, Jampala /* step 4: configure interrupt levels */
22614fa93cdSSrikanth Jampala offset = NPS_PKT_SLC_INT_LEVELSX(port);
22714fa93cdSSrikanth Jampala pkt_slc_int.value = 0;
22814fa93cdSSrikanth Jampala /* time interrupt threshold */
22914fa93cdSSrikanth Jampala pkt_slc_int.s.timet = 0x3fffff;
23014fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, pkt_slc_int.value);
23114fa93cdSSrikanth Jampala
232cf718eaaSSrikanth, Jampala /* enable the solicit port */
23314fa93cdSSrikanth Jampala enable_pkt_solicit_port(ndev, port);
23414fa93cdSSrikanth Jampala }
23514fa93cdSSrikanth Jampala
nitrox_config_pkt_solicit_ports(struct nitrox_device * ndev)23614fa93cdSSrikanth Jampala void nitrox_config_pkt_solicit_ports(struct nitrox_device *ndev)
23714fa93cdSSrikanth Jampala {
23814fa93cdSSrikanth Jampala int i;
23914fa93cdSSrikanth Jampala
24014fa93cdSSrikanth Jampala for (i = 0; i < ndev->nr_queues; i++)
241cf718eaaSSrikanth, Jampala config_pkt_solicit_port(ndev, i);
24214fa93cdSSrikanth Jampala }
24314fa93cdSSrikanth Jampala
24414fa93cdSSrikanth Jampala /**
2455f05cdcaSPhani Kiran Hemadri * enable_nps_core_interrupts - enable NPS core interrutps
246cf718eaaSSrikanth, Jampala * @ndev: NITROX device.
24714fa93cdSSrikanth Jampala *
2485f05cdcaSPhani Kiran Hemadri * This includes NPS core interrupts.
24914fa93cdSSrikanth Jampala */
enable_nps_core_interrupts(struct nitrox_device * ndev)2505f05cdcaSPhani Kiran Hemadri static void enable_nps_core_interrupts(struct nitrox_device *ndev)
25114fa93cdSSrikanth Jampala {
25214fa93cdSSrikanth Jampala union nps_core_int_ena_w1s core_int;
25314fa93cdSSrikanth Jampala
25414fa93cdSSrikanth Jampala /* NPS core interrutps */
25514fa93cdSSrikanth Jampala core_int.value = 0;
25614fa93cdSSrikanth Jampala core_int.s.host_wr_err = 1;
25714fa93cdSSrikanth Jampala core_int.s.host_wr_timeout = 1;
25814fa93cdSSrikanth Jampala core_int.s.exec_wr_timeout = 1;
25914fa93cdSSrikanth Jampala core_int.s.npco_dma_malform = 1;
26014fa93cdSSrikanth Jampala core_int.s.host_nps_wr_err = 1;
26114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_CORE_INT_ENA_W1S, core_int.value);
26214fa93cdSSrikanth Jampala }
26314fa93cdSSrikanth Jampala
nitrox_config_nps_core_unit(struct nitrox_device * ndev)2645f05cdcaSPhani Kiran Hemadri void nitrox_config_nps_core_unit(struct nitrox_device *ndev)
26514fa93cdSSrikanth Jampala {
26614fa93cdSSrikanth Jampala union nps_core_gbl_vfcfg core_gbl_vfcfg;
26714fa93cdSSrikanth Jampala
26814fa93cdSSrikanth Jampala /* endian control information */
26914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_CORE_CONTROL, 1ULL);
27014fa93cdSSrikanth Jampala
27114fa93cdSSrikanth Jampala /* disable ILK interface */
27214fa93cdSSrikanth Jampala core_gbl_vfcfg.value = 0;
27314fa93cdSSrikanth Jampala core_gbl_vfcfg.s.ilk_disable = 1;
27441a9aca6SSrikanth Jampala core_gbl_vfcfg.s.cfg = __NDEV_MODE_PF;
27514fa93cdSSrikanth Jampala nitrox_write_csr(ndev, NPS_CORE_GBL_VFCFG, core_gbl_vfcfg.value);
2765f05cdcaSPhani Kiran Hemadri
2775f05cdcaSPhani Kiran Hemadri /* enable nps core interrupts */
2785f05cdcaSPhani Kiran Hemadri enable_nps_core_interrupts(ndev);
2795f05cdcaSPhani Kiran Hemadri }
2805f05cdcaSPhani Kiran Hemadri
2815f05cdcaSPhani Kiran Hemadri /**
2825f05cdcaSPhani Kiran Hemadri * enable_nps_pkt_interrupts - enable NPS packet interrutps
2835f05cdcaSPhani Kiran Hemadri * @ndev: NITROX device.
2845f05cdcaSPhani Kiran Hemadri *
2855f05cdcaSPhani Kiran Hemadri * This includes NPS packet in and slc interrupts.
2865f05cdcaSPhani Kiran Hemadri */
enable_nps_pkt_interrupts(struct nitrox_device * ndev)2875f05cdcaSPhani Kiran Hemadri static void enable_nps_pkt_interrupts(struct nitrox_device *ndev)
2885f05cdcaSPhani Kiran Hemadri {
2895f05cdcaSPhani Kiran Hemadri /* NPS packet in ring interrupts */
2905f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, NPS_PKT_IN_RERR_LO_ENA_W1S, (~0ULL));
2915f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, NPS_PKT_IN_RERR_HI_ENA_W1S, (~0ULL));
2925f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, NPS_PKT_IN_ERR_TYPE_ENA_W1S, (~0ULL));
2935f05cdcaSPhani Kiran Hemadri /* NPS packet slc port interrupts */
2945f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, NPS_PKT_SLC_RERR_HI_ENA_W1S, (~0ULL));
2955f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, NPS_PKT_SLC_RERR_LO_ENA_W1S, (~0ULL));
2965f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, NPS_PKT_SLC_ERR_TYPE_ENA_W1S, (~0uLL));
2975f05cdcaSPhani Kiran Hemadri }
2985f05cdcaSPhani Kiran Hemadri
nitrox_config_nps_pkt_unit(struct nitrox_device * ndev)2995f05cdcaSPhani Kiran Hemadri void nitrox_config_nps_pkt_unit(struct nitrox_device *ndev)
3005f05cdcaSPhani Kiran Hemadri {
30114fa93cdSSrikanth Jampala /* config input and solicit ports */
30214fa93cdSSrikanth Jampala nitrox_config_pkt_input_rings(ndev);
30314fa93cdSSrikanth Jampala nitrox_config_pkt_solicit_ports(ndev);
30414fa93cdSSrikanth Jampala
3055f05cdcaSPhani Kiran Hemadri /* enable nps packet interrupts */
3065f05cdcaSPhani Kiran Hemadri enable_nps_pkt_interrupts(ndev);
3075f05cdcaSPhani Kiran Hemadri }
3085f05cdcaSPhani Kiran Hemadri
reset_aqm_ring(struct nitrox_device * ndev,int ring)3095f05cdcaSPhani Kiran Hemadri static void reset_aqm_ring(struct nitrox_device *ndev, int ring)
3105f05cdcaSPhani Kiran Hemadri {
3115f05cdcaSPhani Kiran Hemadri union aqmq_en aqmq_en_reg;
3125f05cdcaSPhani Kiran Hemadri union aqmq_activity_stat activity_stat;
3135f05cdcaSPhani Kiran Hemadri union aqmq_cmp_cnt cmp_cnt;
3145f05cdcaSPhani Kiran Hemadri int max_retries = MAX_CSR_RETRIES;
3155f05cdcaSPhani Kiran Hemadri u64 offset;
3165f05cdcaSPhani Kiran Hemadri
3175f05cdcaSPhani Kiran Hemadri /* step 1: disable the queue */
3185f05cdcaSPhani Kiran Hemadri offset = AQMQ_ENX(ring);
3195f05cdcaSPhani Kiran Hemadri aqmq_en_reg.value = 0;
3205f05cdcaSPhani Kiran Hemadri aqmq_en_reg.queue_enable = 0;
3215f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, offset, aqmq_en_reg.value);
3225f05cdcaSPhani Kiran Hemadri
3235f05cdcaSPhani Kiran Hemadri /* step 2: wait for AQMQ_ACTIVITY_STATX[QUEUE_ACTIVE] to clear */
3245f05cdcaSPhani Kiran Hemadri usleep_range(100, 150);
3255f05cdcaSPhani Kiran Hemadri offset = AQMQ_ACTIVITY_STATX(ring);
3265f05cdcaSPhani Kiran Hemadri do {
3275f05cdcaSPhani Kiran Hemadri activity_stat.value = nitrox_read_csr(ndev, offset);
3285f05cdcaSPhani Kiran Hemadri if (!activity_stat.queue_active)
3295f05cdcaSPhani Kiran Hemadri break;
3305f05cdcaSPhani Kiran Hemadri udelay(50);
3315f05cdcaSPhani Kiran Hemadri } while (max_retries--);
3325f05cdcaSPhani Kiran Hemadri
3335f05cdcaSPhani Kiran Hemadri /* step 3: clear commands completed count */
3345f05cdcaSPhani Kiran Hemadri offset = AQMQ_CMP_CNTX(ring);
3355f05cdcaSPhani Kiran Hemadri cmp_cnt.value = nitrox_read_csr(ndev, offset);
3365f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, offset, cmp_cnt.value);
3375f05cdcaSPhani Kiran Hemadri usleep_range(50, 100);
3385f05cdcaSPhani Kiran Hemadri }
3395f05cdcaSPhani Kiran Hemadri
enable_aqm_ring(struct nitrox_device * ndev,int ring)3405f05cdcaSPhani Kiran Hemadri void enable_aqm_ring(struct nitrox_device *ndev, int ring)
3415f05cdcaSPhani Kiran Hemadri {
3425f05cdcaSPhani Kiran Hemadri union aqmq_en aqmq_en_reg;
3435f05cdcaSPhani Kiran Hemadri u64 offset;
3445f05cdcaSPhani Kiran Hemadri
3455f05cdcaSPhani Kiran Hemadri offset = AQMQ_ENX(ring);
3465f05cdcaSPhani Kiran Hemadri aqmq_en_reg.value = 0;
3475f05cdcaSPhani Kiran Hemadri aqmq_en_reg.queue_enable = 1;
3485f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, offset, aqmq_en_reg.value);
3495f05cdcaSPhani Kiran Hemadri usleep_range(50, 100);
3505f05cdcaSPhani Kiran Hemadri }
3515f05cdcaSPhani Kiran Hemadri
nitrox_config_aqm_rings(struct nitrox_device * ndev)3525f05cdcaSPhani Kiran Hemadri void nitrox_config_aqm_rings(struct nitrox_device *ndev)
3535f05cdcaSPhani Kiran Hemadri {
3545f05cdcaSPhani Kiran Hemadri int ring;
3555f05cdcaSPhani Kiran Hemadri
3565f05cdcaSPhani Kiran Hemadri for (ring = 0; ring < ndev->nr_queues; ring++) {
3575f05cdcaSPhani Kiran Hemadri struct nitrox_cmdq *cmdq = ndev->aqmq[ring];
3585f05cdcaSPhani Kiran Hemadri union aqmq_drbl drbl;
3595f05cdcaSPhani Kiran Hemadri union aqmq_qsz qsize;
3605f05cdcaSPhani Kiran Hemadri union aqmq_cmp_thr cmp_thr;
3615f05cdcaSPhani Kiran Hemadri u64 offset;
3625f05cdcaSPhani Kiran Hemadri
3635f05cdcaSPhani Kiran Hemadri /* steps 1 - 3 */
3645f05cdcaSPhani Kiran Hemadri reset_aqm_ring(ndev, ring);
3655f05cdcaSPhani Kiran Hemadri
3665f05cdcaSPhani Kiran Hemadri /* step 4: clear doorbell count of ring */
3675f05cdcaSPhani Kiran Hemadri offset = AQMQ_DRBLX(ring);
3685f05cdcaSPhani Kiran Hemadri drbl.value = 0;
3695f05cdcaSPhani Kiran Hemadri drbl.dbell_count = 0xFFFFFFFF;
3705f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, offset, drbl.value);
3715f05cdcaSPhani Kiran Hemadri
3725f05cdcaSPhani Kiran Hemadri /* step 5: configure host ring details */
3735f05cdcaSPhani Kiran Hemadri
3745f05cdcaSPhani Kiran Hemadri /* set host address for next command of ring */
3755f05cdcaSPhani Kiran Hemadri offset = AQMQ_NXT_CMDX(ring);
3765f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, offset, 0ULL);
3775f05cdcaSPhani Kiran Hemadri
3785f05cdcaSPhani Kiran Hemadri /* set host address of ring base */
3795f05cdcaSPhani Kiran Hemadri offset = AQMQ_BADRX(ring);
3805f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, offset, cmdq->dma);
3815f05cdcaSPhani Kiran Hemadri
3825f05cdcaSPhani Kiran Hemadri /* set ring size */
3835f05cdcaSPhani Kiran Hemadri offset = AQMQ_QSZX(ring);
3845f05cdcaSPhani Kiran Hemadri qsize.value = 0;
3855f05cdcaSPhani Kiran Hemadri qsize.host_queue_size = ndev->qlen;
3865f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, offset, qsize.value);
3875f05cdcaSPhani Kiran Hemadri
3885f05cdcaSPhani Kiran Hemadri /* set command completion threshold */
3895f05cdcaSPhani Kiran Hemadri offset = AQMQ_CMP_THRX(ring);
3905f05cdcaSPhani Kiran Hemadri cmp_thr.value = 0;
3915f05cdcaSPhani Kiran Hemadri cmp_thr.commands_completed_threshold = 1;
3925f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, offset, cmp_thr.value);
3935f05cdcaSPhani Kiran Hemadri
3945f05cdcaSPhani Kiran Hemadri /* step 6: enable the queue */
3955f05cdcaSPhani Kiran Hemadri enable_aqm_ring(ndev, ring);
3965f05cdcaSPhani Kiran Hemadri }
3975f05cdcaSPhani Kiran Hemadri }
3985f05cdcaSPhani Kiran Hemadri
enable_aqm_interrupts(struct nitrox_device * ndev)3995f05cdcaSPhani Kiran Hemadri static void enable_aqm_interrupts(struct nitrox_device *ndev)
4005f05cdcaSPhani Kiran Hemadri {
4015f05cdcaSPhani Kiran Hemadri /* clear interrupt enable bits */
4025f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, AQM_DBELL_OVF_LO_ENA_W1S, (~0ULL));
4035f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, AQM_DBELL_OVF_HI_ENA_W1S, (~0ULL));
4045f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, AQM_DMA_RD_ERR_LO_ENA_W1S, (~0ULL));
4055f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, AQM_DMA_RD_ERR_HI_ENA_W1S, (~0ULL));
4065f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, AQM_EXEC_NA_LO_ENA_W1S, (~0ULL));
4075f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, AQM_EXEC_NA_HI_ENA_W1S, (~0ULL));
4085f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, AQM_EXEC_ERR_LO_ENA_W1S, (~0ULL));
4095f05cdcaSPhani Kiran Hemadri nitrox_write_csr(ndev, AQM_EXEC_ERR_HI_ENA_W1S, (~0ULL));
4105f05cdcaSPhani Kiran Hemadri }
4115f05cdcaSPhani Kiran Hemadri
nitrox_config_aqm_unit(struct nitrox_device * ndev)4125f05cdcaSPhani Kiran Hemadri void nitrox_config_aqm_unit(struct nitrox_device *ndev)
4135f05cdcaSPhani Kiran Hemadri {
4145f05cdcaSPhani Kiran Hemadri /* config aqm command queues */
4155f05cdcaSPhani Kiran Hemadri nitrox_config_aqm_rings(ndev);
4165f05cdcaSPhani Kiran Hemadri
4175f05cdcaSPhani Kiran Hemadri /* enable aqm interrupts */
4185f05cdcaSPhani Kiran Hemadri enable_aqm_interrupts(ndev);
41914fa93cdSSrikanth Jampala }
42014fa93cdSSrikanth Jampala
nitrox_config_pom_unit(struct nitrox_device * ndev)42114fa93cdSSrikanth Jampala void nitrox_config_pom_unit(struct nitrox_device *ndev)
42214fa93cdSSrikanth Jampala {
42314fa93cdSSrikanth Jampala union pom_int_ena_w1s pom_int;
42414fa93cdSSrikanth Jampala int i;
42514fa93cdSSrikanth Jampala
42614fa93cdSSrikanth Jampala /* enable pom interrupts */
42714fa93cdSSrikanth Jampala pom_int.value = 0;
42814fa93cdSSrikanth Jampala pom_int.s.illegal_dport = 1;
42914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, POM_INT_ENA_W1S, pom_int.value);
43014fa93cdSSrikanth Jampala
43114fa93cdSSrikanth Jampala /* enable perf counters */
43214fa93cdSSrikanth Jampala for (i = 0; i < ndev->hw.se_cores; i++)
43314fa93cdSSrikanth Jampala nitrox_write_csr(ndev, POM_PERF_CTL, BIT_ULL(i));
43414fa93cdSSrikanth Jampala }
43514fa93cdSSrikanth Jampala
43614fa93cdSSrikanth Jampala /**
437cf718eaaSSrikanth, Jampala * nitrox_config_rand_unit - enable NITROX random number unit
438cf718eaaSSrikanth, Jampala * @ndev: NITROX device
43914fa93cdSSrikanth Jampala */
nitrox_config_rand_unit(struct nitrox_device * ndev)44014fa93cdSSrikanth Jampala void nitrox_config_rand_unit(struct nitrox_device *ndev)
44114fa93cdSSrikanth Jampala {
44214fa93cdSSrikanth Jampala union efl_rnm_ctl_status efl_rnm_ctl;
44314fa93cdSSrikanth Jampala u64 offset;
44414fa93cdSSrikanth Jampala
44514fa93cdSSrikanth Jampala offset = EFL_RNM_CTL_STATUS;
44614fa93cdSSrikanth Jampala efl_rnm_ctl.value = nitrox_read_csr(ndev, offset);
44714fa93cdSSrikanth Jampala efl_rnm_ctl.s.ent_en = 1;
44814fa93cdSSrikanth Jampala efl_rnm_ctl.s.rng_en = 1;
44914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, efl_rnm_ctl.value);
45014fa93cdSSrikanth Jampala }
45114fa93cdSSrikanth Jampala
nitrox_config_efl_unit(struct nitrox_device * ndev)45214fa93cdSSrikanth Jampala void nitrox_config_efl_unit(struct nitrox_device *ndev)
45314fa93cdSSrikanth Jampala {
45414fa93cdSSrikanth Jampala int i;
45514fa93cdSSrikanth Jampala
45614fa93cdSSrikanth Jampala for (i = 0; i < NR_CLUSTERS; i++) {
45714fa93cdSSrikanth Jampala union efl_core_int_ena_w1s efl_core_int;
45814fa93cdSSrikanth Jampala u64 offset;
45914fa93cdSSrikanth Jampala
46014fa93cdSSrikanth Jampala /* EFL core interrupts */
46114fa93cdSSrikanth Jampala offset = EFL_CORE_INT_ENA_W1SX(i);
46214fa93cdSSrikanth Jampala efl_core_int.value = 0;
46314fa93cdSSrikanth Jampala efl_core_int.s.len_ovr = 1;
46414fa93cdSSrikanth Jampala efl_core_int.s.d_left = 1;
46514fa93cdSSrikanth Jampala efl_core_int.s.epci_decode_err = 1;
46614fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, efl_core_int.value);
46714fa93cdSSrikanth Jampala
46814fa93cdSSrikanth Jampala offset = EFL_CORE_VF_ERR_INT0_ENA_W1SX(i);
46914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL));
47014fa93cdSSrikanth Jampala offset = EFL_CORE_VF_ERR_INT1_ENA_W1SX(i);
47114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL));
47214fa93cdSSrikanth Jampala }
47314fa93cdSSrikanth Jampala }
47414fa93cdSSrikanth Jampala
nitrox_config_bmi_unit(struct nitrox_device * ndev)47514fa93cdSSrikanth Jampala void nitrox_config_bmi_unit(struct nitrox_device *ndev)
47614fa93cdSSrikanth Jampala {
47714fa93cdSSrikanth Jampala union bmi_ctl bmi_ctl;
47814fa93cdSSrikanth Jampala union bmi_int_ena_w1s bmi_int_ena;
47914fa93cdSSrikanth Jampala u64 offset;
48014fa93cdSSrikanth Jampala
48114fa93cdSSrikanth Jampala /* no threshold limits for PCIe */
48214fa93cdSSrikanth Jampala offset = BMI_CTL;
48314fa93cdSSrikanth Jampala bmi_ctl.value = nitrox_read_csr(ndev, offset);
48414fa93cdSSrikanth Jampala bmi_ctl.s.max_pkt_len = 0xff;
48514fa93cdSSrikanth Jampala bmi_ctl.s.nps_free_thrsh = 0xff;
48614fa93cdSSrikanth Jampala bmi_ctl.s.nps_hdrq_thrsh = 0x7a;
48714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, bmi_ctl.value);
48814fa93cdSSrikanth Jampala
48914fa93cdSSrikanth Jampala /* enable interrupts */
49014fa93cdSSrikanth Jampala offset = BMI_INT_ENA_W1S;
49114fa93cdSSrikanth Jampala bmi_int_ena.value = 0;
49214fa93cdSSrikanth Jampala bmi_int_ena.s.max_len_err_nps = 1;
49314fa93cdSSrikanth Jampala bmi_int_ena.s.pkt_rcv_err_nps = 1;
49414fa93cdSSrikanth Jampala bmi_int_ena.s.fpf_undrrn = 1;
49514fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, bmi_int_ena.value);
49614fa93cdSSrikanth Jampala }
49714fa93cdSSrikanth Jampala
nitrox_config_bmo_unit(struct nitrox_device * ndev)49814fa93cdSSrikanth Jampala void nitrox_config_bmo_unit(struct nitrox_device *ndev)
49914fa93cdSSrikanth Jampala {
50014fa93cdSSrikanth Jampala union bmo_ctl2 bmo_ctl2;
50114fa93cdSSrikanth Jampala u64 offset;
50214fa93cdSSrikanth Jampala
50314fa93cdSSrikanth Jampala /* no threshold limits for PCIe */
50414fa93cdSSrikanth Jampala offset = BMO_CTL2;
50514fa93cdSSrikanth Jampala bmo_ctl2.value = nitrox_read_csr(ndev, offset);
50614fa93cdSSrikanth Jampala bmo_ctl2.s.nps_slc_buf_thrsh = 0xff;
50714fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, bmo_ctl2.value);
50814fa93cdSSrikanth Jampala }
50914fa93cdSSrikanth Jampala
invalidate_lbc(struct nitrox_device * ndev)51014fa93cdSSrikanth Jampala void invalidate_lbc(struct nitrox_device *ndev)
51114fa93cdSSrikanth Jampala {
51214fa93cdSSrikanth Jampala union lbc_inval_ctl lbc_ctl;
51314fa93cdSSrikanth Jampala union lbc_inval_status lbc_stat;
514cf718eaaSSrikanth, Jampala int max_retries = MAX_CSR_RETRIES;
51514fa93cdSSrikanth Jampala u64 offset;
51614fa93cdSSrikanth Jampala
51714fa93cdSSrikanth Jampala /* invalidate LBC */
51814fa93cdSSrikanth Jampala offset = LBC_INVAL_CTL;
51914fa93cdSSrikanth Jampala lbc_ctl.value = nitrox_read_csr(ndev, offset);
52014fa93cdSSrikanth Jampala lbc_ctl.s.cam_inval_start = 1;
52114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, lbc_ctl.value);
52214fa93cdSSrikanth Jampala
52314fa93cdSSrikanth Jampala offset = LBC_INVAL_STATUS;
52414fa93cdSSrikanth Jampala do {
52514fa93cdSSrikanth Jampala lbc_stat.value = nitrox_read_csr(ndev, offset);
526cf718eaaSSrikanth, Jampala if (lbc_stat.s.done)
527cf718eaaSSrikanth, Jampala break;
528cf718eaaSSrikanth, Jampala udelay(50);
529cf718eaaSSrikanth, Jampala } while (max_retries--);
53014fa93cdSSrikanth Jampala }
53114fa93cdSSrikanth Jampala
nitrox_config_lbc_unit(struct nitrox_device * ndev)53214fa93cdSSrikanth Jampala void nitrox_config_lbc_unit(struct nitrox_device *ndev)
53314fa93cdSSrikanth Jampala {
53414fa93cdSSrikanth Jampala union lbc_int_ena_w1s lbc_int_ena;
53514fa93cdSSrikanth Jampala u64 offset;
53614fa93cdSSrikanth Jampala
53714fa93cdSSrikanth Jampala invalidate_lbc(ndev);
53814fa93cdSSrikanth Jampala
53914fa93cdSSrikanth Jampala /* enable interrupts */
54014fa93cdSSrikanth Jampala offset = LBC_INT_ENA_W1S;
54114fa93cdSSrikanth Jampala lbc_int_ena.value = 0;
54214fa93cdSSrikanth Jampala lbc_int_ena.s.dma_rd_err = 1;
54314fa93cdSSrikanth Jampala lbc_int_ena.s.over_fetch_err = 1;
54414fa93cdSSrikanth Jampala lbc_int_ena.s.cam_inval_abort = 1;
54514fa93cdSSrikanth Jampala lbc_int_ena.s.cam_hard_err = 1;
54614fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, lbc_int_ena.value);
54714fa93cdSSrikanth Jampala
54814fa93cdSSrikanth Jampala offset = LBC_PLM_VF1_64_INT_ENA_W1S;
54914fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL));
55014fa93cdSSrikanth Jampala offset = LBC_PLM_VF65_128_INT_ENA_W1S;
55114fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL));
55214fa93cdSSrikanth Jampala
55314fa93cdSSrikanth Jampala offset = LBC_ELM_VF1_64_INT_ENA_W1S;
55414fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL));
55514fa93cdSSrikanth Jampala offset = LBC_ELM_VF65_128_INT_ENA_W1S;
55614fa93cdSSrikanth Jampala nitrox_write_csr(ndev, offset, (~0ULL));
55714fa93cdSSrikanth Jampala }
55841a9aca6SSrikanth Jampala
config_nps_core_vfcfg_mode(struct nitrox_device * ndev,enum vf_mode mode)55941a9aca6SSrikanth Jampala void config_nps_core_vfcfg_mode(struct nitrox_device *ndev, enum vf_mode mode)
56041a9aca6SSrikanth Jampala {
56141a9aca6SSrikanth Jampala union nps_core_gbl_vfcfg vfcfg;
56241a9aca6SSrikanth Jampala
56341a9aca6SSrikanth Jampala vfcfg.value = nitrox_read_csr(ndev, NPS_CORE_GBL_VFCFG);
56441a9aca6SSrikanth Jampala vfcfg.s.cfg = mode & 0x7;
56541a9aca6SSrikanth Jampala
56641a9aca6SSrikanth Jampala nitrox_write_csr(ndev, NPS_CORE_GBL_VFCFG, vfcfg.value);
56741a9aca6SSrikanth Jampala }
56848e10548SSrikanth Jampala
get_core_option(u8 se_cores,u8 ae_cores)569bee7bdf1SNagadheeraj Rottela static const char *get_core_option(u8 se_cores, u8 ae_cores)
570bee7bdf1SNagadheeraj Rottela {
571bee7bdf1SNagadheeraj Rottela const char *option = "";
572bee7bdf1SNagadheeraj Rottela
573bee7bdf1SNagadheeraj Rottela if (ae_cores == AE_MAX_CORES) {
574bee7bdf1SNagadheeraj Rottela switch (se_cores) {
575bee7bdf1SNagadheeraj Rottela case SE_MAX_CORES:
576bee7bdf1SNagadheeraj Rottela option = "60";
577bee7bdf1SNagadheeraj Rottela break;
578bee7bdf1SNagadheeraj Rottela case 40:
579bee7bdf1SNagadheeraj Rottela option = "60s";
580bee7bdf1SNagadheeraj Rottela break;
581bee7bdf1SNagadheeraj Rottela }
582bee7bdf1SNagadheeraj Rottela } else if (ae_cores == (AE_MAX_CORES / 2)) {
583bee7bdf1SNagadheeraj Rottela option = "30";
584bee7bdf1SNagadheeraj Rottela } else {
585bee7bdf1SNagadheeraj Rottela option = "60i";
586bee7bdf1SNagadheeraj Rottela }
587bee7bdf1SNagadheeraj Rottela
588bee7bdf1SNagadheeraj Rottela return option;
589bee7bdf1SNagadheeraj Rottela }
590bee7bdf1SNagadheeraj Rottela
get_feature_option(u8 zip_cores,int core_freq)591bee7bdf1SNagadheeraj Rottela static const char *get_feature_option(u8 zip_cores, int core_freq)
592bee7bdf1SNagadheeraj Rottela {
593bee7bdf1SNagadheeraj Rottela if (zip_cores == 0)
594bee7bdf1SNagadheeraj Rottela return "";
595bee7bdf1SNagadheeraj Rottela else if (zip_cores < ZIP_MAX_CORES)
596bee7bdf1SNagadheeraj Rottela return "-C15";
597bee7bdf1SNagadheeraj Rottela
598bee7bdf1SNagadheeraj Rottela if (core_freq >= 850)
599bee7bdf1SNagadheeraj Rottela return "-C45";
600bee7bdf1SNagadheeraj Rottela else if (core_freq >= 750)
601bee7bdf1SNagadheeraj Rottela return "-C35";
602bee7bdf1SNagadheeraj Rottela else if (core_freq >= 550)
603bee7bdf1SNagadheeraj Rottela return "-C25";
604bee7bdf1SNagadheeraj Rottela
605bee7bdf1SNagadheeraj Rottela return "";
606bee7bdf1SNagadheeraj Rottela }
607bee7bdf1SNagadheeraj Rottela
nitrox_get_hwinfo(struct nitrox_device * ndev)60848e10548SSrikanth Jampala void nitrox_get_hwinfo(struct nitrox_device *ndev)
60948e10548SSrikanth Jampala {
61048e10548SSrikanth Jampala union emu_fuse_map emu_fuse;
61148e10548SSrikanth Jampala union rst_boot rst_boot;
61248e10548SSrikanth Jampala union fus_dat1 fus_dat1;
61348e10548SSrikanth Jampala unsigned char name[IFNAMSIZ * 2] = {};
61448e10548SSrikanth Jampala int i, dead_cores;
61548e10548SSrikanth Jampala u64 offset;
61648e10548SSrikanth Jampala
61748e10548SSrikanth Jampala /* get core frequency */
61848e10548SSrikanth Jampala offset = RST_BOOT;
61948e10548SSrikanth Jampala rst_boot.value = nitrox_read_csr(ndev, offset);
62048e10548SSrikanth Jampala ndev->hw.freq = (rst_boot.pnr_mul + 3) * PLL_REF_CLK;
62148e10548SSrikanth Jampala
62248e10548SSrikanth Jampala for (i = 0; i < NR_CLUSTERS; i++) {
62348e10548SSrikanth Jampala offset = EMU_FUSE_MAPX(i);
62448e10548SSrikanth Jampala emu_fuse.value = nitrox_read_csr(ndev, offset);
62548e10548SSrikanth Jampala if (emu_fuse.s.valid) {
62648e10548SSrikanth Jampala dead_cores = hweight32(emu_fuse.s.ae_fuse);
62748e10548SSrikanth Jampala ndev->hw.ae_cores += AE_CORES_PER_CLUSTER - dead_cores;
62848e10548SSrikanth Jampala dead_cores = hweight16(emu_fuse.s.se_fuse);
62948e10548SSrikanth Jampala ndev->hw.se_cores += SE_CORES_PER_CLUSTER - dead_cores;
63048e10548SSrikanth Jampala }
63148e10548SSrikanth Jampala }
63248e10548SSrikanth Jampala /* find zip hardware availability */
63348e10548SSrikanth Jampala offset = FUS_DAT1;
63448e10548SSrikanth Jampala fus_dat1.value = nitrox_read_csr(ndev, offset);
63548e10548SSrikanth Jampala if (!fus_dat1.nozip) {
63648e10548SSrikanth Jampala dead_cores = hweight8(fus_dat1.zip_info);
63748e10548SSrikanth Jampala ndev->hw.zip_cores = ZIP_MAX_CORES - dead_cores;
63848e10548SSrikanth Jampala }
63948e10548SSrikanth Jampala
640bee7bdf1SNagadheeraj Rottela /* determine the partname
641bee7bdf1SNagadheeraj Rottela * CNN55<core option>-<freq><pincount>-<feature option>-<rev>
642bee7bdf1SNagadheeraj Rottela */
643bee7bdf1SNagadheeraj Rottela snprintf(name, sizeof(name), "CNN55%s-%3dBG676%s-1.%u",
644bee7bdf1SNagadheeraj Rottela get_core_option(ndev->hw.se_cores, ndev->hw.ae_cores),
645bee7bdf1SNagadheeraj Rottela ndev->hw.freq,
646bee7bdf1SNagadheeraj Rottela get_feature_option(ndev->hw.zip_cores, ndev->hw.freq),
647bee7bdf1SNagadheeraj Rottela ndev->hw.revision_id);
64848e10548SSrikanth Jampala
64948e10548SSrikanth Jampala /* copy partname */
65048e10548SSrikanth Jampala strncpy(ndev->hw.partname, name, sizeof(ndev->hw.partname));
65148e10548SSrikanth Jampala }
652cf718eaaSSrikanth, Jampala
enable_pf2vf_mbox_interrupts(struct nitrox_device * ndev)653cf718eaaSSrikanth, Jampala void enable_pf2vf_mbox_interrupts(struct nitrox_device *ndev)
654cf718eaaSSrikanth, Jampala {
655cf718eaaSSrikanth, Jampala u64 value = ~0ULL;
656cf718eaaSSrikanth, Jampala u64 reg_addr;
657cf718eaaSSrikanth, Jampala
658cf718eaaSSrikanth, Jampala /* Mailbox interrupt low enable set register */
659cf718eaaSSrikanth, Jampala reg_addr = NPS_PKT_MBOX_INT_LO_ENA_W1S;
660cf718eaaSSrikanth, Jampala nitrox_write_csr(ndev, reg_addr, value);
661cf718eaaSSrikanth, Jampala
662cf718eaaSSrikanth, Jampala /* Mailbox interrupt high enable set register */
663cf718eaaSSrikanth, Jampala reg_addr = NPS_PKT_MBOX_INT_HI_ENA_W1S;
664cf718eaaSSrikanth, Jampala nitrox_write_csr(ndev, reg_addr, value);
665cf718eaaSSrikanth, Jampala }
666cf718eaaSSrikanth, Jampala
disable_pf2vf_mbox_interrupts(struct nitrox_device * ndev)667cf718eaaSSrikanth, Jampala void disable_pf2vf_mbox_interrupts(struct nitrox_device *ndev)
668cf718eaaSSrikanth, Jampala {
669cf718eaaSSrikanth, Jampala u64 value = ~0ULL;
670cf718eaaSSrikanth, Jampala u64 reg_addr;
671cf718eaaSSrikanth, Jampala
672cf718eaaSSrikanth, Jampala /* Mailbox interrupt low enable clear register */
673cf718eaaSSrikanth, Jampala reg_addr = NPS_PKT_MBOX_INT_LO_ENA_W1C;
674cf718eaaSSrikanth, Jampala nitrox_write_csr(ndev, reg_addr, value);
675cf718eaaSSrikanth, Jampala
676cf718eaaSSrikanth, Jampala /* Mailbox interrupt high enable clear register */
677cf718eaaSSrikanth, Jampala reg_addr = NPS_PKT_MBOX_INT_HI_ENA_W1C;
678cf718eaaSSrikanth, Jampala nitrox_write_csr(ndev, reg_addr, value);
679cf718eaaSSrikanth, Jampala }
680