Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 1 | /* |
| 2 | * CAAM control-plane driver backend |
| 3 | * Controller-level driver, kernel property detection, initialization |
| 4 | * |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 5 | * Copyright 2008-2012 Freescale Semiconductor, Inc. |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
Himangi Saraogi | 4776d38 | 2014-05-27 23:55:48 +0530 | [diff] [blame] | 8 | #include <linux/device.h> |
Rob Herring | 5af5073 | 2013-09-17 14:28:33 -0500 | [diff] [blame] | 9 | #include <linux/of_address.h> |
| 10 | #include <linux/of_irq.h> |
| 11 | |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 12 | #include "compat.h" |
| 13 | #include "regs.h" |
| 14 | #include "intern.h" |
| 15 | #include "jr.h" |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 16 | #include "desc_constr.h" |
| 17 | #include "error.h" |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 18 | |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 19 | /* |
| 20 | * Descriptor to instantiate RNG State Handle 0 in normal mode and |
| 21 | * load the JDKEK, TDKEK and TDSK registers |
| 22 | */ |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 23 | static void build_instantiation_desc(u32 *desc, int handle, int do_sk) |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 24 | { |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 25 | u32 *jump_cmd, op_flags; |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 26 | |
| 27 | init_job_desc(desc, 0); |
| 28 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 29 | op_flags = OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG | |
| 30 | (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT; |
| 31 | |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 32 | /* INIT RNG in non-test mode */ |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 33 | append_operation(desc, op_flags); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 34 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 35 | if (!handle && do_sk) { |
| 36 | /* |
| 37 | * For SH0, Secure Keys must be generated as well |
| 38 | */ |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 39 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 40 | /* wait for done */ |
| 41 | jump_cmd = append_jump(desc, JUMP_CLASS_CLASS1); |
| 42 | set_jump_tgt_here(desc, jump_cmd); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 43 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 44 | /* |
| 45 | * load 1 to clear written reg: |
| 46 | * resets the done interrrupt and returns the RNG to idle. |
| 47 | */ |
| 48 | append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW); |
| 49 | |
| 50 | /* Initialize State Handle */ |
| 51 | append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG | |
| 52 | OP_ALG_AAI_RNG4_SK); |
| 53 | } |
Alex Porosanu | d5e4e99 | 2013-09-09 18:56:28 +0300 | [diff] [blame] | 54 | |
| 55 | append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 56 | } |
| 57 | |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 58 | /* Descriptor for deinstantiation of State Handle 0 of the RNG block. */ |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 59 | static void build_deinstantiation_desc(u32 *desc, int handle) |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 60 | { |
| 61 | init_job_desc(desc, 0); |
| 62 | |
| 63 | /* Uninstantiate State Handle 0 */ |
| 64 | append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 65 | (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INITFINAL); |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 66 | |
| 67 | append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT); |
| 68 | } |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 69 | |
| 70 | /* |
| 71 | * run_descriptor_deco0 - runs a descriptor on DECO0, under direct control of |
| 72 | * the software (no JR/QI used). |
| 73 | * @ctrldev - pointer to device |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 74 | * @status - descriptor status, after being run |
| 75 | * |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 76 | * Return: - 0 if no error occurred |
| 77 | * - -ENODEV if the DECO couldn't be acquired |
| 78 | * - -EAGAIN if an error occurred while executing the descriptor |
| 79 | */ |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 80 | static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, |
| 81 | u32 *status) |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 82 | { |
Ruchika Gupta | 997ad29 | 2013-07-04 11:26:03 +0530 | [diff] [blame] | 83 | struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); |
| 84 | struct caam_full __iomem *topregs; |
| 85 | unsigned int timeout = 100000; |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 86 | u32 deco_dbg_reg, flags; |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 87 | int i; |
Ruchika Gupta | 997ad29 | 2013-07-04 11:26:03 +0530 | [diff] [blame] | 88 | |
| 89 | /* Set the bit to request direct access to DECO0 */ |
| 90 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; |
| 91 | setbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); |
| 92 | |
| 93 | while (!(rd_reg32(&topregs->ctrl.deco_rq) & DECORR_DEN0) && |
| 94 | --timeout) |
| 95 | cpu_relax(); |
| 96 | |
| 97 | if (!timeout) { |
| 98 | dev_err(ctrldev, "failed to acquire DECO 0\n"); |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 99 | clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); |
| 100 | return -ENODEV; |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 101 | } |
| 102 | |
Ruchika Gupta | 997ad29 | 2013-07-04 11:26:03 +0530 | [diff] [blame] | 103 | for (i = 0; i < desc_len(desc); i++) |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 104 | wr_reg32(&topregs->deco.descbuf[i], *(desc + i)); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 105 | |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 106 | flags = DECO_JQCR_WHL; |
| 107 | /* |
| 108 | * If the descriptor length is longer than 4 words, then the |
| 109 | * FOUR bit in JRCTRL register must be set. |
| 110 | */ |
| 111 | if (desc_len(desc) >= 4) |
| 112 | flags |= DECO_JQCR_FOUR; |
| 113 | |
| 114 | /* Instruct the DECO to execute it */ |
| 115 | wr_reg32(&topregs->deco.jr_ctl_hi, flags); |
Ruchika Gupta | 997ad29 | 2013-07-04 11:26:03 +0530 | [diff] [blame] | 116 | |
| 117 | timeout = 10000000; |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 118 | do { |
| 119 | deco_dbg_reg = rd_reg32(&topregs->deco.desc_dbg); |
| 120 | /* |
| 121 | * If an error occured in the descriptor, then |
| 122 | * the DECO status field will be set to 0x0D |
| 123 | */ |
| 124 | if ((deco_dbg_reg & DESC_DBG_DECO_STAT_MASK) == |
| 125 | DESC_DBG_DECO_STAT_HOST_ERR) |
| 126 | break; |
Ruchika Gupta | 997ad29 | 2013-07-04 11:26:03 +0530 | [diff] [blame] | 127 | cpu_relax(); |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 128 | } while ((deco_dbg_reg & DESC_DBG_DECO_STAT_VALID) && --timeout); |
Ruchika Gupta | 997ad29 | 2013-07-04 11:26:03 +0530 | [diff] [blame] | 129 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 130 | *status = rd_reg32(&topregs->deco.op_status_hi) & |
| 131 | DECO_OP_STATUS_HI_ERR_MASK; |
| 132 | |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 133 | /* Mark the DECO as free */ |
Ruchika Gupta | 997ad29 | 2013-07-04 11:26:03 +0530 | [diff] [blame] | 134 | clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 135 | |
| 136 | if (!timeout) |
| 137 | return -EAGAIN; |
| 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | /* |
| 143 | * instantiate_rng - builds and executes a descriptor on DECO0, |
| 144 | * which initializes the RNG block. |
| 145 | * @ctrldev - pointer to device |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 146 | * @state_handle_mask - bitmask containing the instantiation status |
| 147 | * for the RNG4 state handles which exist in |
| 148 | * the RNG4 block: 1 if it's been instantiated |
| 149 | * by an external entry, 0 otherwise. |
| 150 | * @gen_sk - generate data to be loaded into the JDKEK, TDKEK and TDSK; |
| 151 | * Caution: this can be done only once; if the keys need to be |
| 152 | * regenerated, a POR is required |
| 153 | * |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 154 | * Return: - 0 if no error occurred |
| 155 | * - -ENOMEM if there isn't enough memory to allocate the descriptor |
| 156 | * - -ENODEV if DECO0 couldn't be acquired |
| 157 | * - -EAGAIN if an error occurred when executing the descriptor |
| 158 | * f.i. there was a RNG hardware error due to not "good enough" |
| 159 | * entropy being aquired. |
| 160 | */ |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 161 | static int instantiate_rng(struct device *ctrldev, int state_handle_mask, |
| 162 | int gen_sk) |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 163 | { |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 164 | struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); |
| 165 | struct caam_full __iomem *topregs; |
| 166 | struct rng4tst __iomem *r4tst; |
| 167 | u32 *desc, status, rdsta_val; |
| 168 | int ret = 0, sh_idx; |
| 169 | |
| 170 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; |
| 171 | r4tst = &topregs->ctrl.r4tst[0]; |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 172 | |
| 173 | desc = kmalloc(CAAM_CMD_SZ * 7, GFP_KERNEL); |
| 174 | if (!desc) |
| 175 | return -ENOMEM; |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 176 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 177 | for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) { |
| 178 | /* |
| 179 | * If the corresponding bit is set, this state handle |
| 180 | * was initialized by somebody else, so it's left alone. |
| 181 | */ |
| 182 | if ((1 << sh_idx) & state_handle_mask) |
| 183 | continue; |
| 184 | |
| 185 | /* Create the descriptor for instantiating RNG State Handle */ |
| 186 | build_instantiation_desc(desc, sh_idx, gen_sk); |
| 187 | |
| 188 | /* Try to run it through DECO0 */ |
| 189 | ret = run_descriptor_deco0(ctrldev, desc, &status); |
| 190 | |
| 191 | /* |
| 192 | * If ret is not 0, or descriptor status is not 0, then |
| 193 | * something went wrong. No need to try the next state |
| 194 | * handle (if available), bail out here. |
| 195 | * Also, if for some reason, the State Handle didn't get |
| 196 | * instantiated although the descriptor has finished |
| 197 | * without any error (HW optimizations for later |
| 198 | * CAAM eras), then try again. |
| 199 | */ |
| 200 | rdsta_val = |
| 201 | rd_reg32(&topregs->ctrl.r4tst[0].rdsta) & RDSTA_IFMASK; |
| 202 | if (status || !(rdsta_val & (1 << sh_idx))) |
| 203 | ret = -EAGAIN; |
| 204 | if (ret) |
| 205 | break; |
| 206 | |
| 207 | dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); |
| 208 | /* Clear the contents before recreating the descriptor */ |
| 209 | memset(desc, 0x00, CAAM_CMD_SZ * 7); |
Ruchika Gupta | 997ad29 | 2013-07-04 11:26:03 +0530 | [diff] [blame] | 210 | } |
| 211 | |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 212 | kfree(desc); |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 213 | |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 214 | return ret; |
| 215 | } |
| 216 | |
| 217 | /* |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 218 | * deinstantiate_rng - builds and executes a descriptor on DECO0, |
| 219 | * which deinitializes the RNG block. |
| 220 | * @ctrldev - pointer to device |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 221 | * @state_handle_mask - bitmask containing the instantiation status |
| 222 | * for the RNG4 state handles which exist in |
| 223 | * the RNG4 block: 1 if it's been instantiated |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 224 | * |
| 225 | * Return: - 0 if no error occurred |
| 226 | * - -ENOMEM if there isn't enough memory to allocate the descriptor |
| 227 | * - -ENODEV if DECO0 couldn't be acquired |
| 228 | * - -EAGAIN if an error occurred when executing the descriptor |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 229 | */ |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 230 | static int deinstantiate_rng(struct device *ctrldev, int state_handle_mask) |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 231 | { |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 232 | u32 *desc, status; |
| 233 | int sh_idx, ret = 0; |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 234 | |
| 235 | desc = kmalloc(CAAM_CMD_SZ * 3, GFP_KERNEL); |
| 236 | if (!desc) |
| 237 | return -ENOMEM; |
| 238 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 239 | for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) { |
| 240 | /* |
| 241 | * If the corresponding bit is set, then it means the state |
| 242 | * handle was initialized by us, and thus it needs to be |
| 243 | * deintialized as well |
| 244 | */ |
| 245 | if ((1 << sh_idx) & state_handle_mask) { |
| 246 | /* |
| 247 | * Create the descriptor for deinstantating this state |
| 248 | * handle |
| 249 | */ |
| 250 | build_deinstantiation_desc(desc, sh_idx); |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 251 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 252 | /* Try to run it through DECO0 */ |
| 253 | ret = run_descriptor_deco0(ctrldev, desc, &status); |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 254 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 255 | if (ret || status) { |
| 256 | dev_err(ctrldev, |
| 257 | "Failed to deinstantiate RNG4 SH%d\n", |
| 258 | sh_idx); |
| 259 | break; |
| 260 | } |
| 261 | dev_info(ctrldev, "Deinstantiated RNG4 SH%d\n", sh_idx); |
| 262 | } |
| 263 | } |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 264 | |
| 265 | kfree(desc); |
| 266 | |
| 267 | return ret; |
| 268 | } |
| 269 | |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 270 | static int caam_remove(struct platform_device *pdev) |
| 271 | { |
| 272 | struct device *ctrldev; |
| 273 | struct caam_drv_private *ctrlpriv; |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 274 | struct caam_full __iomem *topregs; |
| 275 | int ring, ret = 0; |
| 276 | |
| 277 | ctrldev = &pdev->dev; |
| 278 | ctrlpriv = dev_get_drvdata(ctrldev); |
| 279 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; |
| 280 | |
Ruchika Gupta | 313ea29 | 2013-10-25 12:01:01 +0530 | [diff] [blame] | 281 | /* Remove platform devices for JobRs */ |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 282 | for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) { |
Ruchika Gupta | 313ea29 | 2013-10-25 12:01:01 +0530 | [diff] [blame] | 283 | if (ctrlpriv->jrpdev[ring]) |
| 284 | of_device_unregister(ctrlpriv->jrpdev[ring]); |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 285 | } |
| 286 | |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 287 | /* De-initialize RNG state handles initialized by this driver. */ |
| 288 | if (ctrlpriv->rng4_sh_init) |
| 289 | deinstantiate_rng(ctrldev, ctrlpriv->rng4_sh_init); |
Alex Porosanu | b1f996e0 | 2013-09-09 18:56:32 +0300 | [diff] [blame] | 290 | |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 291 | /* Shut down debug views */ |
| 292 | #ifdef CONFIG_DEBUG_FS |
| 293 | debugfs_remove_recursive(ctrlpriv->dfs_root); |
| 294 | #endif |
| 295 | |
| 296 | /* Unmap controller region */ |
| 297 | iounmap(&topregs->ctrl); |
| 298 | |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 299 | return ret; |
| 300 | } |
| 301 | |
| 302 | /* |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 303 | * kick_trng - sets the various parameters for enabling the initialization |
| 304 | * of the RNG4 block in CAAM |
| 305 | * @pdev - pointer to the platform device |
| 306 | * @ent_delay - Defines the length (in system clocks) of each entropy sample. |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 307 | */ |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 308 | static void kick_trng(struct platform_device *pdev, int ent_delay) |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 309 | { |
| 310 | struct device *ctrldev = &pdev->dev; |
| 311 | struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); |
| 312 | struct caam_full __iomem *topregs; |
| 313 | struct rng4tst __iomem *r4tst; |
| 314 | u32 val; |
| 315 | |
| 316 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; |
| 317 | r4tst = &topregs->ctrl.r4tst[0]; |
| 318 | |
| 319 | /* put RNG4 into program mode */ |
| 320 | setbits32(&r4tst->rtmctl, RTMCTL_PRGM); |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 321 | |
| 322 | /* |
| 323 | * Performance-wise, it does not make sense to |
| 324 | * set the delay to a value that is lower |
| 325 | * than the last one that worked (i.e. the state handles |
| 326 | * were instantiated properly. Thus, instead of wasting |
| 327 | * time trying to set the values controlling the sample |
| 328 | * frequency, the function simply returns. |
| 329 | */ |
| 330 | val = (rd_reg32(&r4tst->rtsdctl) & RTSDCTL_ENT_DLY_MASK) |
| 331 | >> RTSDCTL_ENT_DLY_SHIFT; |
| 332 | if (ent_delay <= val) { |
| 333 | /* put RNG4 into run mode */ |
| 334 | clrbits32(&r4tst->rtmctl, RTMCTL_PRGM); |
| 335 | return; |
| 336 | } |
| 337 | |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 338 | val = rd_reg32(&r4tst->rtsdctl); |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 339 | val = (val & ~RTSDCTL_ENT_DLY_MASK) | |
| 340 | (ent_delay << RTSDCTL_ENT_DLY_SHIFT); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 341 | wr_reg32(&r4tst->rtsdctl, val); |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 342 | /* min. freq. count, equal to 1/4 of the entropy sample length */ |
| 343 | wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2); |
| 344 | /* max. freq. count, equal to 8 times the entropy sample length */ |
| 345 | wr_reg32(&r4tst->rtfrqmax, ent_delay << 3); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 346 | /* put RNG4 into run mode */ |
| 347 | clrbits32(&r4tst->rtmctl, RTMCTL_PRGM); |
| 348 | } |
| 349 | |
Alex Porosanu | 82c2f96 | 2012-07-11 11:06:11 +0800 | [diff] [blame] | 350 | /** |
| 351 | * caam_get_era() - Return the ERA of the SEC on SoC, based |
Alex Porosanu | 883619a | 2014-02-06 10:27:19 +0200 | [diff] [blame] | 352 | * on "sec-era" propery in the DTS. This property is updated by u-boot. |
Alex Porosanu | 82c2f96 | 2012-07-11 11:06:11 +0800 | [diff] [blame] | 353 | **/ |
Alex Porosanu | 883619a | 2014-02-06 10:27:19 +0200 | [diff] [blame] | 354 | int caam_get_era(void) |
Alex Porosanu | 82c2f96 | 2012-07-11 11:06:11 +0800 | [diff] [blame] | 355 | { |
Alex Porosanu | 883619a | 2014-02-06 10:27:19 +0200 | [diff] [blame] | 356 | struct device_node *caam_node; |
| 357 | for_each_compatible_node(caam_node, NULL, "fsl,sec-v4.0") { |
| 358 | const uint32_t *prop = (uint32_t *)of_get_property(caam_node, |
| 359 | "fsl,sec-era", |
| 360 | NULL); |
| 361 | return prop ? *prop : -ENOTSUPP; |
| 362 | } |
Alex Porosanu | 82c2f96 | 2012-07-11 11:06:11 +0800 | [diff] [blame] | 363 | |
| 364 | return -ENOTSUPP; |
| 365 | } |
| 366 | EXPORT_SYMBOL(caam_get_era); |
| 367 | |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 368 | /* Probe routine for CAAM top (controller) level */ |
Kim Phillips | 2930d49 | 2011-05-14 22:07:55 -0500 | [diff] [blame] | 369 | static int caam_probe(struct platform_device *pdev) |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 370 | { |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 371 | int ret, ring, rspec, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN; |
Alex Porosanu | 82c2f96 | 2012-07-11 11:06:11 +0800 | [diff] [blame] | 372 | u64 caam_id; |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 373 | struct device *dev; |
| 374 | struct device_node *nprop, *np; |
| 375 | struct caam_ctrl __iomem *ctrl; |
| 376 | struct caam_full __iomem *topregs; |
| 377 | struct caam_drv_private *ctrlpriv; |
Kim Phillips | 23457bc | 2011-06-05 16:42:54 -0500 | [diff] [blame] | 378 | #ifdef CONFIG_DEBUG_FS |
| 379 | struct caam_perfmon *perfmon; |
| 380 | #endif |
Ruchika Gupta | eb1139c | 2014-06-23 15:08:28 +0530 | [diff] [blame^] | 381 | u32 cha_vid_ls; |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 382 | |
Himangi Saraogi | 4776d38 | 2014-05-27 23:55:48 +0530 | [diff] [blame] | 383 | ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(struct caam_drv_private), |
| 384 | GFP_KERNEL); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 385 | if (!ctrlpriv) |
| 386 | return -ENOMEM; |
| 387 | |
| 388 | dev = &pdev->dev; |
| 389 | dev_set_drvdata(dev, ctrlpriv); |
| 390 | ctrlpriv->pdev = pdev; |
| 391 | nprop = pdev->dev.of_node; |
| 392 | |
| 393 | /* Get configuration properties from device tree */ |
| 394 | /* First, get register page */ |
| 395 | ctrl = of_iomap(nprop, 0); |
| 396 | if (ctrl == NULL) { |
| 397 | dev_err(dev, "caam: of_iomap() failed\n"); |
| 398 | return -ENOMEM; |
| 399 | } |
| 400 | ctrlpriv->ctrl = (struct caam_ctrl __force *)ctrl; |
| 401 | |
| 402 | /* topregs used to derive pointers to CAAM sub-blocks only */ |
| 403 | topregs = (struct caam_full __iomem *)ctrl; |
| 404 | |
| 405 | /* Get the IRQ of the controller (for security violations only) */ |
Thierry Reding | f757849 | 2013-09-18 15:24:44 +0200 | [diff] [blame] | 406 | ctrlpriv->secvio_irq = irq_of_parse_and_map(nprop, 0); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 407 | |
| 408 | /* |
| 409 | * Enable DECO watchdogs and, if this is a PHYS_ADDR_T_64BIT kernel, |
Kim Phillips | e13af18 | 2012-06-22 19:48:51 -0500 | [diff] [blame] | 410 | * long pointers in master configuration register |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 411 | */ |
| 412 | setbits32(&topregs->ctrl.mcr, MCFGR_WDENABLE | |
| 413 | (sizeof(dma_addr_t) == sizeof(u64) ? MCFGR_LONG_PTR : 0)); |
| 414 | |
| 415 | if (sizeof(dma_addr_t) == sizeof(u64)) |
Kim Phillips | e13af18 | 2012-06-22 19:48:51 -0500 | [diff] [blame] | 416 | if (of_device_is_compatible(nprop, "fsl,sec-v5.0")) |
| 417 | dma_set_mask(dev, DMA_BIT_MASK(40)); |
| 418 | else |
| 419 | dma_set_mask(dev, DMA_BIT_MASK(36)); |
| 420 | else |
| 421 | dma_set_mask(dev, DMA_BIT_MASK(32)); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 422 | |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 423 | /* |
| 424 | * Detect and enable JobRs |
| 425 | * First, find out how many ring spec'ed, allocate references |
| 426 | * for all, then go probe each one. |
| 427 | */ |
| 428 | rspec = 0; |
Nitesh Lal | 0a63b09 | 2014-02-09 09:59:13 +0800 | [diff] [blame] | 429 | for_each_available_child_of_node(nprop, np) |
| 430 | if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || |
| 431 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) |
Shengzhou Liu | a0ea0f6 | 2012-03-21 14:09:10 +0800 | [diff] [blame] | 432 | rspec++; |
Shengzhou Liu | a0ea0f6 | 2012-03-21 14:09:10 +0800 | [diff] [blame] | 433 | |
Himangi Saraogi | 4776d38 | 2014-05-27 23:55:48 +0530 | [diff] [blame] | 434 | ctrlpriv->jrpdev = devm_kzalloc(&pdev->dev, |
| 435 | sizeof(struct platform_device *) * rspec, |
| 436 | GFP_KERNEL); |
Ruchika Gupta | 313ea29 | 2013-10-25 12:01:01 +0530 | [diff] [blame] | 437 | if (ctrlpriv->jrpdev == NULL) { |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 438 | iounmap(&topregs->ctrl); |
| 439 | return -ENOMEM; |
| 440 | } |
| 441 | |
| 442 | ring = 0; |
| 443 | ctrlpriv->total_jobrs = 0; |
Nitesh Lal | 0a63b09 | 2014-02-09 09:59:13 +0800 | [diff] [blame] | 444 | for_each_available_child_of_node(nprop, np) |
| 445 | if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || |
| 446 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { |
Ruchika Gupta | 313ea29 | 2013-10-25 12:01:01 +0530 | [diff] [blame] | 447 | ctrlpriv->jrpdev[ring] = |
| 448 | of_platform_device_create(np, NULL, dev); |
| 449 | if (!ctrlpriv->jrpdev[ring]) { |
| 450 | pr_warn("JR%d Platform device creation error\n", |
| 451 | ring); |
| 452 | continue; |
| 453 | } |
Shengzhou Liu | a0ea0f6 | 2012-03-21 14:09:10 +0800 | [diff] [blame] | 454 | ctrlpriv->total_jobrs++; |
| 455 | ring++; |
| 456 | } |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 457 | |
| 458 | /* Check to see if QI present. If so, enable */ |
Ruchika Gupta | eb1139c | 2014-06-23 15:08:28 +0530 | [diff] [blame^] | 459 | ctrlpriv->qi_present = |
| 460 | !!(rd_reg32(&topregs->ctrl.perfmon.comp_parms_ms) & |
| 461 | CTPR_MS_QI_MASK); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 462 | if (ctrlpriv->qi_present) { |
| 463 | ctrlpriv->qi = (struct caam_queue_if __force *)&topregs->qi; |
| 464 | /* This is all that's required to physically enable QI */ |
| 465 | wr_reg32(&topregs->qi.qi_control_lo, QICTL_DQEN); |
| 466 | } |
| 467 | |
| 468 | /* If no QI and no rings specified, quit and go home */ |
| 469 | if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) { |
| 470 | dev_err(dev, "no queues configured, terminating\n"); |
| 471 | caam_remove(pdev); |
| 472 | return -ENOMEM; |
| 473 | } |
| 474 | |
Ruchika Gupta | eb1139c | 2014-06-23 15:08:28 +0530 | [diff] [blame^] | 475 | cha_vid_ls = rd_reg32(&topregs->ctrl.perfmon.cha_id_ls); |
Ruchika Gupta | 986dfbc | 2013-04-26 15:44:54 +0530 | [diff] [blame] | 476 | |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 477 | /* |
Ruchika Gupta | 986dfbc | 2013-04-26 15:44:54 +0530 | [diff] [blame] | 478 | * If SEC has RNG version >= 4 and RNG state handle has not been |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 479 | * already instantiated, do RNG instantiation |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 480 | */ |
Ruchika Gupta | eb1139c | 2014-06-23 15:08:28 +0530 | [diff] [blame^] | 481 | if ((cha_vid_ls & CHA_ID_LS_RNG_MASK) >> CHA_ID_LS_RNG_SHIFT >= 4) { |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 482 | ctrlpriv->rng4_sh_init = |
| 483 | rd_reg32(&topregs->ctrl.r4tst[0].rdsta); |
| 484 | /* |
| 485 | * If the secure keys (TDKEK, JDKEK, TDSK), were already |
| 486 | * generated, signal this to the function that is instantiating |
| 487 | * the state handles. An error would occur if RNG4 attempts |
| 488 | * to regenerate these keys before the next POR. |
| 489 | */ |
| 490 | gen_sk = ctrlpriv->rng4_sh_init & RDSTA_SKVN ? 0 : 1; |
| 491 | ctrlpriv->rng4_sh_init &= RDSTA_IFMASK; |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 492 | do { |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 493 | int inst_handles = |
| 494 | rd_reg32(&topregs->ctrl.r4tst[0].rdsta) & |
| 495 | RDSTA_IFMASK; |
| 496 | /* |
| 497 | * If either SH were instantiated by somebody else |
| 498 | * (e.g. u-boot) then it is assumed that the entropy |
| 499 | * parameters are properly set and thus the function |
| 500 | * setting these (kick_trng(...)) is skipped. |
| 501 | * Also, if a handle was instantiated, do not change |
| 502 | * the TRNG parameters. |
| 503 | */ |
| 504 | if (!(ctrlpriv->rng4_sh_init || inst_handles)) { |
| 505 | kick_trng(pdev, ent_delay); |
| 506 | ent_delay += 400; |
| 507 | } |
| 508 | /* |
| 509 | * if instantiate_rng(...) fails, the loop will rerun |
| 510 | * and the kick_trng(...) function will modfiy the |
| 511 | * upper and lower limits of the entropy sampling |
| 512 | * interval, leading to a sucessful initialization of |
| 513 | * the RNG. |
| 514 | */ |
| 515 | ret = instantiate_rng(dev, inst_handles, |
| 516 | gen_sk); |
Alex Porosanu | 04cddbf | 2013-09-09 18:56:31 +0300 | [diff] [blame] | 517 | } while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX)); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 518 | if (ret) { |
Alex Porosanu | 84cf482 | 2013-09-09 18:56:30 +0300 | [diff] [blame] | 519 | dev_err(dev, "failed to instantiate RNG"); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 520 | caam_remove(pdev); |
| 521 | return ret; |
| 522 | } |
Alex Porosanu | 1005bcc | 2013-09-09 18:56:34 +0300 | [diff] [blame] | 523 | /* |
| 524 | * Set handles init'ed by this module as the complement of the |
| 525 | * already initialized ones |
| 526 | */ |
| 527 | ctrlpriv->rng4_sh_init = ~ctrlpriv->rng4_sh_init & RDSTA_IFMASK; |
Vakul Garg | 575c1bd | 2013-03-12 13:55:21 +0530 | [diff] [blame] | 528 | |
| 529 | /* Enable RDB bit so that RNG works faster */ |
| 530 | setbits32(&topregs->ctrl.scfgr, SCFGR_RDBENABLE); |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 531 | } |
| 532 | |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 533 | /* NOTE: RTIC detection ought to go here, around Si time */ |
| 534 | |
Ruchika Gupta | eb1139c | 2014-06-23 15:08:28 +0530 | [diff] [blame^] | 535 | caam_id = (u64)rd_reg32(&topregs->ctrl.perfmon.caam_id_ms) << 32 | |
| 536 | (u64)rd_reg32(&topregs->ctrl.perfmon.caam_id_ls); |
Alex Porosanu | 82c2f96 | 2012-07-11 11:06:11 +0800 | [diff] [blame] | 537 | |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 538 | /* Report "alive" for developer to see */ |
Alex Porosanu | 82c2f96 | 2012-07-11 11:06:11 +0800 | [diff] [blame] | 539 | dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id, |
Alex Porosanu | 883619a | 2014-02-06 10:27:19 +0200 | [diff] [blame] | 540 | caam_get_era()); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 541 | dev_info(dev, "job rings = %d, qi = %d\n", |
| 542 | ctrlpriv->total_jobrs, ctrlpriv->qi_present); |
| 543 | |
| 544 | #ifdef CONFIG_DEBUG_FS |
| 545 | /* |
| 546 | * FIXME: needs better naming distinction, as some amalgamation of |
| 547 | * "caam" and nprop->full_name. The OF name isn't distinctive, |
| 548 | * but does separate instances |
| 549 | */ |
| 550 | perfmon = (struct caam_perfmon __force *)&ctrl->perfmon; |
| 551 | |
| 552 | ctrlpriv->dfs_root = debugfs_create_dir("caam", NULL); |
| 553 | ctrlpriv->ctl = debugfs_create_dir("ctl", ctrlpriv->dfs_root); |
| 554 | |
| 555 | /* Controller-level - performance monitor counters */ |
| 556 | ctrlpriv->ctl_rq_dequeued = |
| 557 | debugfs_create_u64("rq_dequeued", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 558 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 559 | ctrlpriv->ctl, &perfmon->req_dequeued); |
| 560 | ctrlpriv->ctl_ob_enc_req = |
| 561 | debugfs_create_u64("ob_rq_encrypted", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 562 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 563 | ctrlpriv->ctl, &perfmon->ob_enc_req); |
| 564 | ctrlpriv->ctl_ib_dec_req = |
| 565 | debugfs_create_u64("ib_rq_decrypted", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 566 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 567 | ctrlpriv->ctl, &perfmon->ib_dec_req); |
| 568 | ctrlpriv->ctl_ob_enc_bytes = |
| 569 | debugfs_create_u64("ob_bytes_encrypted", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 570 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 571 | ctrlpriv->ctl, &perfmon->ob_enc_bytes); |
| 572 | ctrlpriv->ctl_ob_prot_bytes = |
| 573 | debugfs_create_u64("ob_bytes_protected", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 574 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 575 | ctrlpriv->ctl, &perfmon->ob_prot_bytes); |
| 576 | ctrlpriv->ctl_ib_dec_bytes = |
| 577 | debugfs_create_u64("ib_bytes_decrypted", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 578 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 579 | ctrlpriv->ctl, &perfmon->ib_dec_bytes); |
| 580 | ctrlpriv->ctl_ib_valid_bytes = |
| 581 | debugfs_create_u64("ib_bytes_validated", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 582 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 583 | ctrlpriv->ctl, &perfmon->ib_valid_bytes); |
| 584 | |
| 585 | /* Controller level - global status values */ |
| 586 | ctrlpriv->ctl_faultaddr = |
| 587 | debugfs_create_u64("fault_addr", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 588 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 589 | ctrlpriv->ctl, &perfmon->faultaddr); |
| 590 | ctrlpriv->ctl_faultdetail = |
| 591 | debugfs_create_u32("fault_detail", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 592 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 593 | ctrlpriv->ctl, &perfmon->faultdetail); |
| 594 | ctrlpriv->ctl_faultstatus = |
| 595 | debugfs_create_u32("fault_status", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 596 | S_IRUSR | S_IRGRP | S_IROTH, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 597 | ctrlpriv->ctl, &perfmon->status); |
| 598 | |
| 599 | /* Internal covering keys (useful in non-secure mode only) */ |
| 600 | ctrlpriv->ctl_kek_wrap.data = &ctrlpriv->ctrl->kek[0]; |
| 601 | ctrlpriv->ctl_kek_wrap.size = KEK_KEY_SIZE * sizeof(u32); |
| 602 | ctrlpriv->ctl_kek = debugfs_create_blob("kek", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 603 | S_IRUSR | |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 604 | S_IRGRP | S_IROTH, |
| 605 | ctrlpriv->ctl, |
| 606 | &ctrlpriv->ctl_kek_wrap); |
| 607 | |
| 608 | ctrlpriv->ctl_tkek_wrap.data = &ctrlpriv->ctrl->tkek[0]; |
| 609 | ctrlpriv->ctl_tkek_wrap.size = KEK_KEY_SIZE * sizeof(u32); |
| 610 | ctrlpriv->ctl_tkek = debugfs_create_blob("tkek", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 611 | S_IRUSR | |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 612 | S_IRGRP | S_IROTH, |
| 613 | ctrlpriv->ctl, |
| 614 | &ctrlpriv->ctl_tkek_wrap); |
| 615 | |
| 616 | ctrlpriv->ctl_tdsk_wrap.data = &ctrlpriv->ctrl->tdsk[0]; |
| 617 | ctrlpriv->ctl_tdsk_wrap.size = KEK_KEY_SIZE * sizeof(u32); |
| 618 | ctrlpriv->ctl_tdsk = debugfs_create_blob("tdsk", |
Al Viro | eda65cc | 2011-07-24 04:32:53 -0400 | [diff] [blame] | 619 | S_IRUSR | |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 620 | S_IRGRP | S_IROTH, |
| 621 | ctrlpriv->ctl, |
| 622 | &ctrlpriv->ctl_tdsk_wrap); |
| 623 | #endif |
| 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | static struct of_device_id caam_match[] = { |
| 628 | { |
Kim Phillips | 54e198d | 2011-03-23 21:15:44 +0800 | [diff] [blame] | 629 | .compatible = "fsl,sec-v4.0", |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 630 | }, |
Shengzhou Liu | a0ea0f6 | 2012-03-21 14:09:10 +0800 | [diff] [blame] | 631 | { |
| 632 | .compatible = "fsl,sec4.0", |
| 633 | }, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 634 | {}, |
| 635 | }; |
| 636 | MODULE_DEVICE_TABLE(of, caam_match); |
| 637 | |
Kim Phillips | 2930d49 | 2011-05-14 22:07:55 -0500 | [diff] [blame] | 638 | static struct platform_driver caam_driver = { |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 639 | .driver = { |
| 640 | .name = "caam", |
| 641 | .owner = THIS_MODULE, |
| 642 | .of_match_table = caam_match, |
| 643 | }, |
| 644 | .probe = caam_probe, |
Greg Kroah-Hartman | 49cfe4d | 2012-12-21 13:14:09 -0800 | [diff] [blame] | 645 | .remove = caam_remove, |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 646 | }; |
| 647 | |
Axel Lin | 741e8c2 | 2011-11-26 21:26:19 +0800 | [diff] [blame] | 648 | module_platform_driver(caam_driver); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 649 | |
| 650 | MODULE_LICENSE("GPL"); |
| 651 | MODULE_DESCRIPTION("FSL CAAM request backend"); |
| 652 | MODULE_AUTHOR("Freescale Semiconductor - NMG/STC"); |