aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrikanth Jampala <Jampala.Srikanth@cavium.com>2018-09-21 07:38:00 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2018-09-28 00:46:26 -0400
commit48e10548f82ea33e01ab8ed92dbcb9513463cb90 (patch)
tree983f93de07dc4aa924c7cc0c1230860eef675a71
parentdfb89ab3f0a7df2a0a44f3a46572319446671f9f (diff)
crypto: cavium/nitrox - added support to identify the NITROX device partname.
Get the device partname based on it's capabilities like, core frequency, number of cores and revision id. Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/cavium/nitrox/nitrox_csr.h111
-rw-r--r--drivers/crypto/cavium/nitrox/nitrox_dev.h17
-rw-r--r--drivers/crypto/cavium/nitrox/nitrox_hal.c57
-rw-r--r--drivers/crypto/cavium/nitrox/nitrox_hal.h1
-rw-r--r--drivers/crypto/cavium/nitrox/nitrox_main.c20
5 files changed, 184 insertions, 22 deletions
diff --git a/drivers/crypto/cavium/nitrox/nitrox_csr.h b/drivers/crypto/cavium/nitrox/nitrox_csr.h
index 9dcb7fdbe0a7..1ad27b1a87c5 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_csr.h
+++ b/drivers/crypto/cavium/nitrox/nitrox_csr.h
@@ -7,9 +7,16 @@
7 7
8/* EMU clusters */ 8/* EMU clusters */
9#define NR_CLUSTERS 4 9#define NR_CLUSTERS 4
10/* Maximum cores per cluster,
11 * varies based on partname
12 */
10#define AE_CORES_PER_CLUSTER 20 13#define AE_CORES_PER_CLUSTER 20
11#define SE_CORES_PER_CLUSTER 16 14#define SE_CORES_PER_CLUSTER 16
12 15
16#define AE_MAX_CORES (AE_CORES_PER_CLUSTER * NR_CLUSTERS)
17#define SE_MAX_CORES (SE_CORES_PER_CLUSTER * NR_CLUSTERS)
18#define ZIP_MAX_CORES 5
19
13/* BIST registers */ 20/* BIST registers */
14#define EMU_BIST_STATUSX(_i) (0x1402700 + ((_i) * 0x40000)) 21#define EMU_BIST_STATUSX(_i) (0x1402700 + ((_i) * 0x40000))
15#define UCD_BIST_STATUS 0x12C0070 22#define UCD_BIST_STATUS 0x12C0070
@@ -111,6 +118,9 @@
111#define LBC_ELM_VF65_128_INT 0x120C000 118#define LBC_ELM_VF65_128_INT 0x120C000
112#define LBC_ELM_VF65_128_INT_ENA_W1S 0x120F000 119#define LBC_ELM_VF65_128_INT_ENA_W1S 0x120F000
113 120
121#define RST_BOOT 0x10C1600
122#define FUS_DAT1 0x10C1408
123
114/* PEM registers */ 124/* PEM registers */
115#define PEM0_INT 0x1080428 125#define PEM0_INT 0x1080428
116 126
@@ -1082,4 +1092,105 @@ union lbc_inval_status {
1082 } s; 1092 } s;
1083}; 1093};
1084 1094
1095/**
1096 * struct rst_boot: RST Boot Register
1097 * @jtcsrdis: when set, internal CSR access via JTAG TAP controller
1098 * is disabled
1099 * @jt_tst_mode: JTAG test mode
1100 * @io_supply: I/O power supply setting based on IO_VDD_SELECT pin:
1101 * 0x1 = 1.8V
1102 * 0x2 = 2.5V
1103 * 0x4 = 3.3V
1104 * All other values are reserved
1105 * @pnr_mul: clock multiplier
1106 * @lboot: last boot cause mask, resets only with PLL_DC_OK
1107 * @rboot: determines whether core 0 remains in reset after
1108 * chip cold or warm or soft reset
1109 * @rboot_pin: read only access to REMOTE_BOOT pin
1110 */
1111union rst_boot {
1112 u64 value;
1113 struct {
1114#if (defined(__BIG_ENDIAN_BITFIELD))
1115 u64 raz_63 : 1;
1116 u64 jtcsrdis : 1;
1117 u64 raz_59_61 : 3;
1118 u64 jt_tst_mode : 1;
1119 u64 raz_40_57 : 18;
1120 u64 io_supply : 3;
1121 u64 raz_30_36 : 7;
1122 u64 pnr_mul : 6;
1123 u64 raz_12_23 : 12;
1124 u64 lboot : 10;
1125 u64 rboot : 1;
1126 u64 rboot_pin : 1;
1127#else
1128 u64 rboot_pin : 1;
1129 u64 rboot : 1;
1130 u64 lboot : 10;
1131 u64 raz_12_23 : 12;
1132 u64 pnr_mul : 6;
1133 u64 raz_30_36 : 7;
1134 u64 io_supply : 3;
1135 u64 raz_40_57 : 18;
1136 u64 jt_tst_mode : 1;
1137 u64 raz_59_61 : 3;
1138 u64 jtcsrdis : 1;
1139 u64 raz_63 : 1;
1140#endif
1141 };
1142};
1143
1144/**
1145 * struct fus_dat1: Fuse Data 1 Register
1146 * @pll_mul: main clock PLL multiplier hardware limit
1147 * @pll_half_dis: main clock PLL control
1148 * @efus_lck: efuse lockdown
1149 * @zip_info: ZIP information
1150 * @bar2_sz_conf: when zero, BAR2 size conforms to
1151 * PCIe specification
1152 * @efus_ign: efuse ignore
1153 * @nozip: ZIP disable
1154 * @pll_alt_matrix: select alternate PLL matrix
1155 * @pll_bwadj_denom: select CLKF denominator for
1156 * BWADJ value
1157 * @chip_id: chip ID
1158 */
1159union fus_dat1 {
1160 u64 value;
1161 struct {
1162#if (defined(__BIG_ENDIAN_BITFIELD))
1163 u64 raz_57_63 : 7;
1164 u64 pll_mul : 3;
1165 u64 pll_half_dis : 1;
1166 u64 raz_43_52 : 10;
1167 u64 efus_lck : 3;
1168 u64 raz_26_39 : 14;
1169 u64 zip_info : 5;
1170 u64 bar2_sz_conf : 1;
1171 u64 efus_ign : 1;
1172 u64 nozip : 1;
1173 u64 raz_11_17 : 7;
1174 u64 pll_alt_matrix : 1;
1175 u64 pll_bwadj_denom : 2;
1176 u64 chip_id : 8;
1177#else
1178 u64 chip_id : 8;
1179 u64 pll_bwadj_denom : 2;
1180 u64 pll_alt_matrix : 1;
1181 u64 raz_11_17 : 7;
1182 u64 nozip : 1;
1183 u64 efus_ign : 1;
1184 u64 bar2_sz_conf : 1;
1185 u64 zip_info : 5;
1186 u64 raz_26_39 : 14;
1187 u64 efus_lck : 3;
1188 u64 raz_43_52 : 10;
1189 u64 pll_half_dis : 1;
1190 u64 pll_mul : 3;
1191 u64 raz_57_63 : 7;
1192#endif
1193 };
1194};
1195
1085#endif /* __NITROX_CSR_H */ 1196#endif /* __NITROX_CSR_H */
diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h b/drivers/crypto/cavium/nitrox/nitrox_dev.h
index 4f560cedd0aa..1059495ee541 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
+++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
@@ -5,6 +5,7 @@
5#include <linux/dma-mapping.h> 5#include <linux/dma-mapping.h>
6#include <linux/interrupt.h> 6#include <linux/interrupt.h>
7#include <linux/pci.h> 7#include <linux/pci.h>
8#include <linux/if.h>
8 9
9#define VERSION_LEN 32 10#define VERSION_LEN 32
10 11
@@ -48,15 +49,27 @@ struct nitrox_cmdq {
48 dma_addr_t dma; 49 dma_addr_t dma;
49}; 50};
50 51
52/**
53 * struct nitrox_hw - NITROX hardware information
54 * @partname: partname ex: CNN55xxx-xxx
55 * @fw_name: firmware version
56 * @freq: NITROX frequency
57 * @vendor_id: vendor ID
58 * @device_id: device ID
59 * @revision_id: revision ID
60 * @se_cores: number of symmetric cores
61 * @ae_cores: number of asymmetric cores
62 * @zip_cores: number of zip cores
63 */
51struct nitrox_hw { 64struct nitrox_hw {
52 /* firmware version */ 65 char partname[IFNAMSIZ * 2];
53 char fw_name[VERSION_LEN]; 66 char fw_name[VERSION_LEN];
54 67
68 int freq;
55 u16 vendor_id; 69 u16 vendor_id;
56 u16 device_id; 70 u16 device_id;
57 u8 revision_id; 71 u8 revision_id;
58 72
59 /* CNN55XX cores */
60 u8 se_cores; 73 u8 se_cores;
61 u8 ae_cores; 74 u8 ae_cores;
62 u8 zip_cores; 75 u8 zip_cores;
diff --git a/drivers/crypto/cavium/nitrox/nitrox_hal.c b/drivers/crypto/cavium/nitrox/nitrox_hal.c
index 2b256ba36dff..4627a1976176 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_hal.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_hal.c
@@ -4,6 +4,8 @@
4#include "nitrox_dev.h" 4#include "nitrox_dev.h"
5#include "nitrox_csr.h" 5#include "nitrox_csr.h"
6 6
7#define PLL_REF_CLK 50
8
7/** 9/**
8 * emu_enable_cores - Enable EMU cluster cores. 10 * emu_enable_cores - Enable EMU cluster cores.
9 * @ndev: N5 device 11 * @ndev: N5 device
@@ -410,3 +412,58 @@ void config_nps_core_vfcfg_mode(struct nitrox_device *ndev, enum vf_mode mode)
410 412
411 nitrox_write_csr(ndev, NPS_CORE_GBL_VFCFG, vfcfg.value); 413 nitrox_write_csr(ndev, NPS_CORE_GBL_VFCFG, vfcfg.value);
412} 414}
415
416void nitrox_get_hwinfo(struct nitrox_device *ndev)
417{
418 union emu_fuse_map emu_fuse;
419 union rst_boot rst_boot;
420 union fus_dat1 fus_dat1;
421 unsigned char name[IFNAMSIZ * 2] = {};
422 int i, dead_cores;
423 u64 offset;
424
425 /* get core frequency */
426 offset = RST_BOOT;
427 rst_boot.value = nitrox_read_csr(ndev, offset);
428 ndev->hw.freq = (rst_boot.pnr_mul + 3) * PLL_REF_CLK;
429
430 for (i = 0; i < NR_CLUSTERS; i++) {
431 offset = EMU_FUSE_MAPX(i);
432 emu_fuse.value = nitrox_read_csr(ndev, offset);
433 if (emu_fuse.s.valid) {
434 dead_cores = hweight32(emu_fuse.s.ae_fuse);
435 ndev->hw.ae_cores += AE_CORES_PER_CLUSTER - dead_cores;
436 dead_cores = hweight16(emu_fuse.s.se_fuse);
437 ndev->hw.se_cores += SE_CORES_PER_CLUSTER - dead_cores;
438 }
439 }
440 /* find zip hardware availability */
441 offset = FUS_DAT1;
442 fus_dat1.value = nitrox_read_csr(ndev, offset);
443 if (!fus_dat1.nozip) {
444 dead_cores = hweight8(fus_dat1.zip_info);
445 ndev->hw.zip_cores = ZIP_MAX_CORES - dead_cores;
446 }
447
448 /* determine the partname CNN55<cores>-<freq><pincount>-<rev>*/
449 if (ndev->hw.ae_cores == AE_MAX_CORES) {
450 switch (ndev->hw.se_cores) {
451 case SE_MAX_CORES:
452 i = snprintf(name, sizeof(name), "CNN5560");
453 break;
454 case 40:
455 i = snprintf(name, sizeof(name), "CNN5560s");
456 break;
457 }
458 } else if (ndev->hw.ae_cores == (AE_MAX_CORES / 2)) {
459 i = snprintf(name, sizeof(name), "CNN5530");
460 } else {
461 i = snprintf(name, sizeof(name), "CNN5560i");
462 }
463
464 snprintf(name + i, sizeof(name) - i, "-%3dBG676-1.%u",
465 ndev->hw.freq, ndev->hw.revision_id);
466
467 /* copy partname */
468 strncpy(ndev->hw.partname, name, sizeof(ndev->hw.partname));
469}
diff --git a/drivers/crypto/cavium/nitrox/nitrox_hal.h b/drivers/crypto/cavium/nitrox/nitrox_hal.h
index 3baef865b17c..489ee64c119e 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_hal.h
+++ b/drivers/crypto/cavium/nitrox/nitrox_hal.h
@@ -18,5 +18,6 @@ void invalidate_lbc(struct nitrox_device *ndev);
18void enable_pkt_input_ring(struct nitrox_device *ndev, int ring); 18void enable_pkt_input_ring(struct nitrox_device *ndev, int ring);
19void enable_pkt_solicit_port(struct nitrox_device *ndev, int port); 19void enable_pkt_solicit_port(struct nitrox_device *ndev, int port);
20void config_nps_core_vfcfg_mode(struct nitrox_device *ndev, enum vf_mode mode); 20void config_nps_core_vfcfg_mode(struct nitrox_device *ndev, enum vf_mode mode);
21void nitrox_get_hwinfo(struct nitrox_device *ndev);
21 22
22#endif /* __NITROX_HAL_H */ 23#endif /* __NITROX_HAL_H */
diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c
index 6d7a421bddb8..acce0f0b9c7a 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_main.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
@@ -291,26 +291,6 @@ static int nitrox_bist_check(struct nitrox_device *ndev)
291 return 0; 291 return 0;
292} 292}
293 293
294static void nitrox_get_hwinfo(struct nitrox_device *ndev)
295{
296 union emu_fuse_map emu_fuse;
297 u64 offset;
298 int i;
299
300 for (i = 0; i < NR_CLUSTERS; i++) {
301 u8 dead_cores;
302
303 offset = EMU_FUSE_MAPX(i);
304 emu_fuse.value = nitrox_read_csr(ndev, offset);
305 if (emu_fuse.s.valid) {
306 dead_cores = hweight32(emu_fuse.s.ae_fuse);
307 ndev->hw.ae_cores += AE_CORES_PER_CLUSTER - dead_cores;
308 dead_cores = hweight16(emu_fuse.s.se_fuse);
309 ndev->hw.se_cores += SE_CORES_PER_CLUSTER - dead_cores;
310 }
311 }
312}
313
314static int nitrox_pf_hw_init(struct nitrox_device *ndev) 294static int nitrox_pf_hw_init(struct nitrox_device *ndev)
315{ 295{
316 int err; 296 int err;