tpm_infineon.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) | tpm_infineon.c (8cfffc9d4d3786d3b496a021d7224e06328bac7d) |
---|---|
1/* 2 * Description: 3 * Device Driver for the Infineon Technologies 4 * SLD 9630 TT 1.1 and SLB 9635 TT 1.2 Trusted Platform Module 5 * Specifications at www.trustedcomputinggroup.org 6 * 7 * Copyright (C) 2005, Marcel Selhorst <tpmdd@selhorst.net> 8 * Sirrix AG - security technologies <tpmdd@sirrix.com> and --- 181 unchanged lines hidden (view full) --- 190 status = tpm_data_in(STAT); 191 /* check the status-register if wait_for_bit is set */ 192 if (status & 1 << wait_for_bit) 193 break; 194 msleep(TPM_MSLEEP_TIME); 195 } 196 if (i == TPM_MAX_TRIES) { /* timeout occurs */ 197 if (wait_for_bit == STAT_XFE) | 1/* 2 * Description: 3 * Device Driver for the Infineon Technologies 4 * SLD 9630 TT 1.1 and SLB 9635 TT 1.2 Trusted Platform Module 5 * Specifications at www.trustedcomputinggroup.org 6 * 7 * Copyright (C) 2005, Marcel Selhorst <tpmdd@selhorst.net> 8 * Sirrix AG - security technologies <tpmdd@sirrix.com> and --- 181 unchanged lines hidden (view full) --- 190 status = tpm_data_in(STAT); 191 /* check the status-register if wait_for_bit is set */ 192 if (status & 1 << wait_for_bit) 193 break; 194 msleep(TPM_MSLEEP_TIME); 195 } 196 if (i == TPM_MAX_TRIES) { /* timeout occurs */ 197 if (wait_for_bit == STAT_XFE) |
198 dev_err(chip->pdev, "Timeout in wait(STAT_XFE)\n"); | 198 dev_err(&chip->dev, "Timeout in wait(STAT_XFE)\n"); |
199 if (wait_for_bit == STAT_RDA) | 199 if (wait_for_bit == STAT_RDA) |
200 dev_err(chip->pdev, "Timeout in wait(STAT_RDA)\n"); | 200 dev_err(&chip->dev, "Timeout in wait(STAT_RDA)\n"); |
201 return -EIO; 202 } 203 return 0; 204}; 205 206static void wait_and_send(struct tpm_chip *chip, u8 sendbyte) 207{ 208 wait(chip, STAT_XFE); --- 6 unchanged lines hidden (view full) --- 215 creation. Set the maximum number of WTX-packages in the definitions 216 above, if the number is reached, the waiting-time will be denied 217 and the TPM command has to be resend. 218 */ 219 220static void tpm_wtx(struct tpm_chip *chip) 221{ 222 number_of_wtx++; | 201 return -EIO; 202 } 203 return 0; 204}; 205 206static void wait_and_send(struct tpm_chip *chip, u8 sendbyte) 207{ 208 wait(chip, STAT_XFE); --- 6 unchanged lines hidden (view full) --- 215 creation. Set the maximum number of WTX-packages in the definitions 216 above, if the number is reached, the waiting-time will be denied 217 and the TPM command has to be resend. 218 */ 219 220static void tpm_wtx(struct tpm_chip *chip) 221{ 222 number_of_wtx++; |
223 dev_info(chip->pdev, "Granting WTX (%02d / %02d)\n", | 223 dev_info(&chip->dev, "Granting WTX (%02d / %02d)\n", |
224 number_of_wtx, TPM_MAX_WTX_PACKAGES); 225 wait_and_send(chip, TPM_VL_VER); 226 wait_and_send(chip, TPM_CTRL_WTX); 227 wait_and_send(chip, 0x00); 228 wait_and_send(chip, 0x00); 229 msleep(TPM_WTX_MSLEEP_TIME); 230} 231 232static void tpm_wtx_abort(struct tpm_chip *chip) 233{ | 224 number_of_wtx, TPM_MAX_WTX_PACKAGES); 225 wait_and_send(chip, TPM_VL_VER); 226 wait_and_send(chip, TPM_CTRL_WTX); 227 wait_and_send(chip, 0x00); 228 wait_and_send(chip, 0x00); 229 msleep(TPM_WTX_MSLEEP_TIME); 230} 231 232static void tpm_wtx_abort(struct tpm_chip *chip) 233{ |
234 dev_info(chip->pdev, "Aborting WTX\n"); | 234 dev_info(&chip->dev, "Aborting WTX\n"); |
235 wait_and_send(chip, TPM_VL_VER); 236 wait_and_send(chip, TPM_CTRL_WTX_ABORT); 237 wait_and_send(chip, 0x00); 238 wait_and_send(chip, 0x00); 239 number_of_wtx = 0; 240 msleep(TPM_WTX_MSLEEP_TIME); 241} 242 --- 9 unchanged lines hidden (view full) --- 252 for (i = 0; i < 4; i++) { 253 ret = wait(chip, STAT_RDA); 254 if (ret) 255 return -EIO; 256 buf[i] = tpm_data_in(RDFIFO); 257 } 258 259 if (buf[0] != TPM_VL_VER) { | 235 wait_and_send(chip, TPM_VL_VER); 236 wait_and_send(chip, TPM_CTRL_WTX_ABORT); 237 wait_and_send(chip, 0x00); 238 wait_and_send(chip, 0x00); 239 number_of_wtx = 0; 240 msleep(TPM_WTX_MSLEEP_TIME); 241} 242 --- 9 unchanged lines hidden (view full) --- 252 for (i = 0; i < 4; i++) { 253 ret = wait(chip, STAT_RDA); 254 if (ret) 255 return -EIO; 256 buf[i] = tpm_data_in(RDFIFO); 257 } 258 259 if (buf[0] != TPM_VL_VER) { |
260 dev_err(chip->pdev, | 260 dev_err(&chip->dev, |
261 "Wrong transport protocol implementation!\n"); 262 return -EIO; 263 } 264 265 if (buf[1] == TPM_CTRL_DATA) { 266 /* size of the data received */ 267 size = ((buf[2] << 8) | buf[3]); 268 269 for (i = 0; i < size; i++) { 270 wait(chip, STAT_RDA); 271 buf[i] = tpm_data_in(RDFIFO); 272 } 273 274 if ((size == 0x6D00) && (buf[1] == 0x80)) { | 261 "Wrong transport protocol implementation!\n"); 262 return -EIO; 263 } 264 265 if (buf[1] == TPM_CTRL_DATA) { 266 /* size of the data received */ 267 size = ((buf[2] << 8) | buf[3]); 268 269 for (i = 0; i < size; i++) { 270 wait(chip, STAT_RDA); 271 buf[i] = tpm_data_in(RDFIFO); 272 } 273 274 if ((size == 0x6D00) && (buf[1] == 0x80)) { |
275 dev_err(chip->pdev, "Error handling on vendor layer!\n"); | 275 dev_err(&chip->dev, "Error handling on vendor layer!\n"); |
276 return -EIO; 277 } 278 279 for (i = 0; i < size; i++) 280 buf[i] = buf[i + 6]; 281 282 size = size - 6; 283 return size; 284 } 285 286 if (buf[1] == TPM_CTRL_WTX) { | 276 return -EIO; 277 } 278 279 for (i = 0; i < size; i++) 280 buf[i] = buf[i + 6]; 281 282 size = size - 6; 283 return size; 284 } 285 286 if (buf[1] == TPM_CTRL_WTX) { |
287 dev_info(chip->pdev, "WTX-package received\n"); | 287 dev_info(&chip->dev, "WTX-package received\n"); |
288 if (number_of_wtx < TPM_MAX_WTX_PACKAGES) { 289 tpm_wtx(chip); 290 goto recv_begin; 291 } else { 292 tpm_wtx_abort(chip); 293 goto recv_begin; 294 } 295 } 296 297 if (buf[1] == TPM_CTRL_WTX_ABORT_ACK) { | 288 if (number_of_wtx < TPM_MAX_WTX_PACKAGES) { 289 tpm_wtx(chip); 290 goto recv_begin; 291 } else { 292 tpm_wtx_abort(chip); 293 goto recv_begin; 294 } 295 } 296 297 if (buf[1] == TPM_CTRL_WTX_ABORT_ACK) { |
298 dev_info(chip->pdev, "WTX-abort acknowledged\n"); | 298 dev_info(&chip->dev, "WTX-abort acknowledged\n"); |
299 return size; 300 } 301 302 if (buf[1] == TPM_CTRL_ERROR) { | 299 return size; 300 } 301 302 if (buf[1] == TPM_CTRL_ERROR) { |
303 dev_err(chip->pdev, "ERROR-package received:\n"); | 303 dev_err(&chip->dev, "ERROR-package received:\n"); |
304 if (buf[4] == TPM_INF_NAK) | 304 if (buf[4] == TPM_INF_NAK) |
305 dev_err(chip->pdev, | 305 dev_err(&chip->dev, |
306 "-> Negative acknowledgement" 307 " - retransmit command!\n"); 308 return -EIO; 309 } 310 return -EIO; 311} 312 313static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count) 314{ 315 int i; 316 int ret; 317 u8 count_high, count_low, count_4, count_3, count_2, count_1; 318 319 /* Disabling Reset, LP and IRQC */ 320 tpm_data_out(RESET_LP_IRQC_DISABLE, CMD); 321 322 ret = empty_fifo(chip, 1); 323 if (ret) { | 306 "-> Negative acknowledgement" 307 " - retransmit command!\n"); 308 return -EIO; 309 } 310 return -EIO; 311} 312 313static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count) 314{ 315 int i; 316 int ret; 317 u8 count_high, count_low, count_4, count_3, count_2, count_1; 318 319 /* Disabling Reset, LP and IRQC */ 320 tpm_data_out(RESET_LP_IRQC_DISABLE, CMD); 321 322 ret = empty_fifo(chip, 1); 323 if (ret) { |
324 dev_err(chip->pdev, "Timeout while clearing FIFO\n"); | 324 dev_err(&chip->dev, "Timeout while clearing FIFO\n"); |
325 return -EIO; 326 } 327 328 ret = wait(chip, STAT_XFE); 329 if (ret) 330 return -EIO; 331 332 count_4 = (count & 0xff000000) >> 24; --- 297 unchanged lines hidden --- | 325 return -EIO; 326 } 327 328 ret = wait(chip, STAT_XFE); 329 if (ret) 330 return -EIO; 331 332 count_4 = (count & 0xff000000) >> 24; --- 297 unchanged lines hidden --- |