Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: caam - ERA retrieval and printing for SEC device

This patch adds support for retrieving and printing of
SEC ERA information. It is useful for knowing beforehand
what features exist from the SEC point of view on a
certain SoC. Only era-s 1 to 4 are currently supported;
other eras will appear as unknown.

Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com>

- rebased onto current cryptodev master
- made caam_eras static

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Alex Porosanu and committed by
Herbert Xu
82c2f960 1af8ea86

+58 -2
+39 -2
drivers/crypto/caam/ctrl.c
··· 11 11 #include "jr.h" 12 12 #include "desc_constr.h" 13 13 #include "error.h" 14 + #include "ctrl.h" 14 15 15 16 static int caam_remove(struct platform_device *pdev) 16 17 { ··· 156 155 clrbits32(&r4tst->rtmctl, RTMCTL_PRGM); 157 156 } 158 157 158 + /** 159 + * caam_get_era() - Return the ERA of the SEC on SoC, based 160 + * on the SEC_VID register. 161 + * Returns the ERA number (1..4) or -ENOTSUPP if the ERA is unknown. 162 + * @caam_id - the value of the SEC_VID register 163 + **/ 164 + int caam_get_era(u64 caam_id) 165 + { 166 + struct sec_vid *sec_vid = (struct sec_vid *)&caam_id; 167 + static const struct { 168 + u16 ip_id; 169 + u8 maj_rev; 170 + u8 era; 171 + } caam_eras[] = { 172 + {0x0A10, 1, 1}, 173 + {0x0A10, 2, 2}, 174 + {0x0A12, 1, 3}, 175 + {0x0A14, 1, 3}, 176 + {0x0A14, 2, 4}, 177 + {0x0A16, 1, 4}, 178 + {0x0A11, 1, 4} 179 + }; 180 + int i; 181 + 182 + for (i = 0; i < ARRAY_SIZE(caam_eras); i++) 183 + if (caam_eras[i].ip_id == sec_vid->ip_id && 184 + caam_eras[i].maj_rev == sec_vid->maj_rev) 185 + return caam_eras[i].era; 186 + 187 + return -ENOTSUPP; 188 + } 189 + EXPORT_SYMBOL(caam_get_era); 190 + 159 191 /* Probe routine for CAAM top (controller) level */ 160 192 static int caam_probe(struct platform_device *pdev) 161 193 { 162 194 int ret, ring, rspec; 195 + u64 caam_id; 163 196 struct device *dev; 164 197 struct device_node *nprop, *np; 165 198 struct caam_ctrl __iomem *ctrl; ··· 311 276 /* Initialize queue allocator lock */ 312 277 spin_lock_init(&ctrlpriv->jr_alloc_lock); 313 278 279 + caam_id = rd_reg64(&topregs->ctrl.perfmon.caam_id); 280 + 314 281 /* Report "alive" for developer to see */ 315 - dev_info(dev, "device ID = 0x%016llx\n", 316 - rd_reg64(&topregs->ctrl.perfmon.caam_id)); 282 + dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id, 283 + caam_get_era(caam_id)); 317 284 dev_info(dev, "job rings = %d, qi = %d\n", 318 285 ctrlpriv->total_jobrs, ctrlpriv->qi_present); 319 286
+13
drivers/crypto/caam/ctrl.h
··· 1 + /* 2 + * CAAM control-plane driver backend public-level include definitions 3 + * 4 + * Copyright 2012 Freescale Semiconductor, Inc. 5 + */ 6 + 7 + #ifndef CTRL_H 8 + #define CTRL_H 9 + 10 + /* Prototypes for backend-level services exposed to APIs */ 11 + int caam_get_era(u64 caam_id); 12 + 13 + #endif /* CTRL_H */
+6
drivers/crypto/caam/regs.h
··· 117 117 #define CHA_NUM_DECONUM_SHIFT 56 118 118 #define CHA_NUM_DECONUM_MASK (0xfull << CHA_NUM_DECONUM_SHIFT) 119 119 120 + struct sec_vid { 121 + u16 ip_id; 122 + u8 maj_rev; 123 + u8 min_rev; 124 + }; 125 + 120 126 struct caam_perfmon { 121 127 /* Performance Monitor Registers f00-f9f */ 122 128 u64 req_dequeued; /* PC_REQ_DEQ - Dequeued Requests */