Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 IBM Corporation |
| 3 | * |
Ashley Lai | 1a0f1b2 | 2014-12-04 21:01:51 -0600 | [diff] [blame] | 4 | * Author: Ashley Lai <ashleydlai@gmail.com> |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 5 | * |
| 6 | * Maintained by: <tpmdd-devel@lists.sourceforge.net> |
| 7 | * |
| 8 | * Device driver for TCG/TCPA TPM (trusted platform module). |
| 9 | * Specifications at www.trustedcomputinggroup.org |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation, version 2 of the |
| 14 | * License. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #include <linux/dma-mapping.h> |
| 19 | #include <linux/dmapool.h> |
| 20 | #include <linux/slab.h> |
| 21 | #include <asm/vio.h> |
| 22 | #include <asm/irq.h> |
| 23 | #include <linux/types.h> |
| 24 | #include <linux/list.h> |
| 25 | #include <linux/spinlock.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/wait.h> |
| 28 | #include <asm/prom.h> |
| 29 | |
| 30 | #include "tpm.h" |
| 31 | #include "tpm_ibmvtpm.h" |
| 32 | |
| 33 | static const char tpm_ibmvtpm_driver_name[] = "tpm_ibmvtpm"; |
| 34 | |
Bill Pemberton | 0bbed20 | 2012-11-19 13:24:36 -0500 | [diff] [blame] | 35 | static struct vio_device_id tpm_ibmvtpm_device_table[] = { |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 36 | { "IBM,vtpm", "IBM,vtpm"}, |
| 37 | { "", "" } |
| 38 | }; |
| 39 | MODULE_DEVICE_TABLE(vio, tpm_ibmvtpm_device_table); |
| 40 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 41 | /** |
| 42 | * ibmvtpm_send_crq - Send a CRQ request |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 43 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 44 | * @vdev: vio device struct |
| 45 | * @w1: first word |
| 46 | * @w2: second word |
| 47 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 48 | * Return: |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 49 | * 0 -Sucess |
| 50 | * Non-zero - Failure |
| 51 | */ |
| 52 | static int ibmvtpm_send_crq(struct vio_dev *vdev, u64 w1, u64 w2) |
| 53 | { |
| 54 | return plpar_hcall_norets(H_SEND_CRQ, vdev->unit_address, w1, w2); |
| 55 | } |
| 56 | |
| 57 | /** |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 58 | * tpm_ibmvtpm_recv - Receive data after send |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 59 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 60 | * @chip: tpm chip struct |
| 61 | * @buf: buffer to read |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 62 | * @count: size of buffer |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 63 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 64 | * Return: |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 65 | * Number of bytes read |
| 66 | */ |
| 67 | static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) |
| 68 | { |
Christophe Ricard | 9e0d39d | 2016-03-31 22:57:00 +0200 | [diff] [blame] | 69 | struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 70 | u16 len; |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 71 | int sig; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 72 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 73 | if (!ibmvtpm->rtce_buf) { |
| 74 | dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n"); |
| 75 | return 0; |
| 76 | } |
| 77 | |
Stefan Berger | 6674ff1 | 2015-12-09 08:52:01 -0500 | [diff] [blame] | 78 | sig = wait_event_interruptible(ibmvtpm->wq, !ibmvtpm->tpm_processing_cmd); |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 79 | if (sig) |
| 80 | return -EINTR; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 81 | |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 82 | len = ibmvtpm->res_len; |
| 83 | |
| 84 | if (count < len) { |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 85 | dev_err(ibmvtpm->dev, |
Jason Gunthorpe | 37ab034 | 2013-09-14 16:57:58 -0600 | [diff] [blame] | 86 | "Invalid size in recv: count=%zd, crq_size=%d\n", |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 87 | count, len); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 88 | return -EIO; |
| 89 | } |
| 90 | |
| 91 | spin_lock(&ibmvtpm->rtce_lock); |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 92 | memcpy((void *)buf, (void *)ibmvtpm->rtce_buf, len); |
| 93 | memset(ibmvtpm->rtce_buf, 0, len); |
| 94 | ibmvtpm->res_len = 0; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 95 | spin_unlock(&ibmvtpm->rtce_lock); |
| 96 | return len; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * tpm_ibmvtpm_send - Send tpm request |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 101 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 102 | * @chip: tpm chip struct |
| 103 | * @buf: buffer contains data to send |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 104 | * @count: size of buffer |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 105 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 106 | * Return: |
| 107 | * Number of bytes sent or < 0 on error. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 108 | */ |
| 109 | static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) |
| 110 | { |
Christophe Ricard | 9e0d39d | 2016-03-31 22:57:00 +0200 | [diff] [blame] | 111 | struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 112 | struct ibmvtpm_crq crq; |
jmlatten@linux.vnet.ibm.com | 62dfd91 | 2015-02-20 18:11:24 -0600 | [diff] [blame] | 113 | __be64 *word = (__be64 *)&crq; |
Stefan Berger | 6674ff1 | 2015-12-09 08:52:01 -0500 | [diff] [blame] | 114 | int rc, sig; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 115 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 116 | if (!ibmvtpm->rtce_buf) { |
| 117 | dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n"); |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | if (count > ibmvtpm->rtce_size) { |
| 122 | dev_err(ibmvtpm->dev, |
Jason Gunthorpe | 37ab034 | 2013-09-14 16:57:58 -0600 | [diff] [blame] | 123 | "Invalid size in send: count=%zd, rtce_size=%d\n", |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 124 | count, ibmvtpm->rtce_size); |
| 125 | return -EIO; |
| 126 | } |
| 127 | |
Stefan Berger | 6674ff1 | 2015-12-09 08:52:01 -0500 | [diff] [blame] | 128 | if (ibmvtpm->tpm_processing_cmd) { |
| 129 | dev_info(ibmvtpm->dev, |
| 130 | "Need to wait for TPM to finish\n"); |
| 131 | /* wait for previous command to finish */ |
| 132 | sig = wait_event_interruptible(ibmvtpm->wq, !ibmvtpm->tpm_processing_cmd); |
| 133 | if (sig) |
| 134 | return -EINTR; |
| 135 | } |
| 136 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 137 | spin_lock(&ibmvtpm->rtce_lock); |
Stefan Berger | 6674ff1 | 2015-12-09 08:52:01 -0500 | [diff] [blame] | 138 | ibmvtpm->res_len = 0; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 139 | memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count); |
| 140 | crq.valid = (u8)IBMVTPM_VALID_CMD; |
| 141 | crq.msg = (u8)VTPM_TPM_COMMAND; |
jmlatten@linux.vnet.ibm.com | 62dfd91 | 2015-02-20 18:11:24 -0600 | [diff] [blame] | 142 | crq.len = cpu_to_be16(count); |
| 143 | crq.data = cpu_to_be32(ibmvtpm->rtce_dma_handle); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 144 | |
Stefan Berger | 6674ff1 | 2015-12-09 08:52:01 -0500 | [diff] [blame] | 145 | /* |
| 146 | * set the processing flag before the Hcall, since we may get the |
| 147 | * result (interrupt) before even being able to check rc. |
| 148 | */ |
| 149 | ibmvtpm->tpm_processing_cmd = true; |
| 150 | |
jmlatten@linux.vnet.ibm.com | 62dfd91 | 2015-02-20 18:11:24 -0600 | [diff] [blame] | 151 | rc = ibmvtpm_send_crq(ibmvtpm->vdev, be64_to_cpu(word[0]), |
| 152 | be64_to_cpu(word[1])); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 153 | if (rc != H_SUCCESS) { |
| 154 | dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc); |
| 155 | rc = 0; |
Stefan Berger | 6674ff1 | 2015-12-09 08:52:01 -0500 | [diff] [blame] | 156 | ibmvtpm->tpm_processing_cmd = false; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 157 | } else |
| 158 | rc = count; |
| 159 | |
| 160 | spin_unlock(&ibmvtpm->rtce_lock); |
| 161 | return rc; |
| 162 | } |
| 163 | |
| 164 | static void tpm_ibmvtpm_cancel(struct tpm_chip *chip) |
| 165 | { |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | static u8 tpm_ibmvtpm_status(struct tpm_chip *chip) |
| 170 | { |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * ibmvtpm_crq_get_rtce_size - Send a CRQ request to get rtce size |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 176 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 177 | * @ibmvtpm: vtpm device struct |
| 178 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 179 | * Return: |
| 180 | * 0 on success. |
| 181 | * Non-zero on failure. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 182 | */ |
| 183 | static int ibmvtpm_crq_get_rtce_size(struct ibmvtpm_dev *ibmvtpm) |
| 184 | { |
| 185 | struct ibmvtpm_crq crq; |
| 186 | u64 *buf = (u64 *) &crq; |
| 187 | int rc; |
| 188 | |
| 189 | crq.valid = (u8)IBMVTPM_VALID_CMD; |
| 190 | crq.msg = (u8)VTPM_GET_RTCE_BUFFER_SIZE; |
| 191 | |
honclo | eb71f8a | 2015-02-12 21:02:24 -0500 | [diff] [blame] | 192 | rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]), |
| 193 | cpu_to_be64(buf[1])); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 194 | if (rc != H_SUCCESS) |
| 195 | dev_err(ibmvtpm->dev, |
| 196 | "ibmvtpm_crq_get_rtce_size failed rc=%d\n", rc); |
| 197 | |
| 198 | return rc; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * ibmvtpm_crq_get_version - Send a CRQ request to get vtpm version |
| 203 | * - Note that this is vtpm version and not tpm version |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 204 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 205 | * @ibmvtpm: vtpm device struct |
| 206 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 207 | * Return: |
| 208 | * 0 on success. |
| 209 | * Non-zero on failure. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 210 | */ |
| 211 | static int ibmvtpm_crq_get_version(struct ibmvtpm_dev *ibmvtpm) |
| 212 | { |
| 213 | struct ibmvtpm_crq crq; |
| 214 | u64 *buf = (u64 *) &crq; |
| 215 | int rc; |
| 216 | |
| 217 | crq.valid = (u8)IBMVTPM_VALID_CMD; |
| 218 | crq.msg = (u8)VTPM_GET_VERSION; |
| 219 | |
honclo | eb71f8a | 2015-02-12 21:02:24 -0500 | [diff] [blame] | 220 | rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]), |
| 221 | cpu_to_be64(buf[1])); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 222 | if (rc != H_SUCCESS) |
| 223 | dev_err(ibmvtpm->dev, |
| 224 | "ibmvtpm_crq_get_version failed rc=%d\n", rc); |
| 225 | |
| 226 | return rc; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * ibmvtpm_crq_send_init_complete - Send a CRQ initialize complete message |
| 231 | * @ibmvtpm: vtpm device struct |
| 232 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 233 | * Return: |
| 234 | * 0 on success. |
| 235 | * Non-zero on failure. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 236 | */ |
| 237 | static int ibmvtpm_crq_send_init_complete(struct ibmvtpm_dev *ibmvtpm) |
| 238 | { |
| 239 | int rc; |
| 240 | |
| 241 | rc = ibmvtpm_send_crq(ibmvtpm->vdev, INIT_CRQ_COMP_CMD, 0); |
| 242 | if (rc != H_SUCCESS) |
| 243 | dev_err(ibmvtpm->dev, |
| 244 | "ibmvtpm_crq_send_init_complete failed rc=%d\n", rc); |
| 245 | |
| 246 | return rc; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * ibmvtpm_crq_send_init - Send a CRQ initialize message |
| 251 | * @ibmvtpm: vtpm device struct |
| 252 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 253 | * Return: |
| 254 | * 0 on success. |
| 255 | * Non-zero on failure. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 256 | */ |
| 257 | static int ibmvtpm_crq_send_init(struct ibmvtpm_dev *ibmvtpm) |
| 258 | { |
| 259 | int rc; |
| 260 | |
| 261 | rc = ibmvtpm_send_crq(ibmvtpm->vdev, INIT_CRQ_CMD, 0); |
| 262 | if (rc != H_SUCCESS) |
| 263 | dev_err(ibmvtpm->dev, |
| 264 | "ibmvtpm_crq_send_init failed rc=%d\n", rc); |
| 265 | |
| 266 | return rc; |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * tpm_ibmvtpm_remove - ibm vtpm remove entry point |
| 271 | * @vdev: vio device struct |
| 272 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 273 | * Return: Always 0. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 274 | */ |
Bill Pemberton | 39af33f | 2012-11-19 13:26:26 -0500 | [diff] [blame] | 275 | static int tpm_ibmvtpm_remove(struct vio_dev *vdev) |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 276 | { |
Christophe Ricard | 9e0d39d | 2016-03-31 22:57:00 +0200 | [diff] [blame] | 277 | struct tpm_chip *chip = dev_get_drvdata(&vdev->dev); |
| 278 | struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 279 | int rc = 0; |
| 280 | |
Jarkko Sakkinen | afb5abc | 2014-12-12 11:46:34 -0800 | [diff] [blame] | 281 | tpm_chip_unregister(chip); |
| 282 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 283 | free_irq(vdev->irq, ibmvtpm); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 284 | |
| 285 | do { |
| 286 | if (rc) |
| 287 | msleep(100); |
| 288 | rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address); |
| 289 | } while (rc == H_BUSY || H_IS_LONG_BUSY(rc)); |
| 290 | |
| 291 | dma_unmap_single(ibmvtpm->dev, ibmvtpm->crq_dma_handle, |
| 292 | CRQ_RES_BUF_SIZE, DMA_BIDIRECTIONAL); |
| 293 | free_page((unsigned long)ibmvtpm->crq_queue.crq_addr); |
| 294 | |
| 295 | if (ibmvtpm->rtce_buf) { |
| 296 | dma_unmap_single(ibmvtpm->dev, ibmvtpm->rtce_dma_handle, |
| 297 | ibmvtpm->rtce_size, DMA_BIDIRECTIONAL); |
| 298 | kfree(ibmvtpm->rtce_buf); |
| 299 | } |
| 300 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 301 | kfree(ibmvtpm); |
| 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * tpm_ibmvtpm_get_desired_dma - Get DMA size needed by this driver |
| 308 | * @vdev: vio device struct |
| 309 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 310 | * Return: |
| 311 | * Number of bytes the driver needs to DMA map. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 312 | */ |
| 313 | static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev) |
| 314 | { |
Christophe Ricard | 9e0d39d | 2016-03-31 22:57:00 +0200 | [diff] [blame] | 315 | struct tpm_chip *chip = dev_get_drvdata(&vdev->dev); |
| 316 | struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); |
Hon Ching (Vicky) Lo | 84eb186 | 2014-11-30 15:01:28 +0100 | [diff] [blame] | 317 | |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 318 | /* |
| 319 | * ibmvtpm initializes at probe time, so the data we are |
| 320 | * asking for may not be set yet. Estimate that 4K required |
| 321 | * for TCE-mapped buffer in addition to CRQ. |
| 322 | */ |
Hon Ching (Vicky) Lo | 84eb186 | 2014-11-30 15:01:28 +0100 | [diff] [blame] | 323 | if (!ibmvtpm) |
| 324 | return CRQ_RES_BUF_SIZE + PAGE_SIZE; |
| 325 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 326 | return CRQ_RES_BUF_SIZE + ibmvtpm->rtce_size; |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * tpm_ibmvtpm_suspend - Suspend |
| 331 | * @dev: device struct |
| 332 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 333 | * Return: Always 0. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 334 | */ |
| 335 | static int tpm_ibmvtpm_suspend(struct device *dev) |
| 336 | { |
Christophe Ricard | 9e0d39d | 2016-03-31 22:57:00 +0200 | [diff] [blame] | 337 | struct tpm_chip *chip = dev_get_drvdata(dev); |
| 338 | struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 339 | struct ibmvtpm_crq crq; |
| 340 | u64 *buf = (u64 *) &crq; |
| 341 | int rc = 0; |
| 342 | |
| 343 | crq.valid = (u8)IBMVTPM_VALID_CMD; |
| 344 | crq.msg = (u8)VTPM_PREPARE_TO_SUSPEND; |
| 345 | |
honclo | eb71f8a | 2015-02-12 21:02:24 -0500 | [diff] [blame] | 346 | rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]), |
| 347 | cpu_to_be64(buf[1])); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 348 | if (rc != H_SUCCESS) |
| 349 | dev_err(ibmvtpm->dev, |
| 350 | "tpm_ibmvtpm_suspend failed rc=%d\n", rc); |
| 351 | |
| 352 | return rc; |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * ibmvtpm_reset_crq - Reset CRQ |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 357 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 358 | * @ibmvtpm: ibm vtpm struct |
| 359 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 360 | * Return: |
| 361 | * 0 on success. |
| 362 | * Non-zero on failure. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 363 | */ |
| 364 | static int ibmvtpm_reset_crq(struct ibmvtpm_dev *ibmvtpm) |
| 365 | { |
| 366 | int rc = 0; |
| 367 | |
| 368 | do { |
| 369 | if (rc) |
| 370 | msleep(100); |
| 371 | rc = plpar_hcall_norets(H_FREE_CRQ, |
| 372 | ibmvtpm->vdev->unit_address); |
| 373 | } while (rc == H_BUSY || H_IS_LONG_BUSY(rc)); |
| 374 | |
| 375 | memset(ibmvtpm->crq_queue.crq_addr, 0, CRQ_RES_BUF_SIZE); |
| 376 | ibmvtpm->crq_queue.index = 0; |
| 377 | |
| 378 | return plpar_hcall_norets(H_REG_CRQ, ibmvtpm->vdev->unit_address, |
| 379 | ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE); |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * tpm_ibmvtpm_resume - Resume from suspend |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 384 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 385 | * @dev: device struct |
| 386 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 387 | * Return: Always 0. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 388 | */ |
| 389 | static int tpm_ibmvtpm_resume(struct device *dev) |
| 390 | { |
Christophe Ricard | 9e0d39d | 2016-03-31 22:57:00 +0200 | [diff] [blame] | 391 | struct tpm_chip *chip = dev_get_drvdata(dev); |
| 392 | struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 393 | int rc = 0; |
| 394 | |
| 395 | do { |
| 396 | if (rc) |
| 397 | msleep(100); |
| 398 | rc = plpar_hcall_norets(H_ENABLE_CRQ, |
| 399 | ibmvtpm->vdev->unit_address); |
| 400 | } while (rc == H_IN_PROGRESS || rc == H_BUSY || H_IS_LONG_BUSY(rc)); |
| 401 | |
| 402 | if (rc) { |
| 403 | dev_err(dev, "Error enabling ibmvtpm rc=%d\n", rc); |
| 404 | return rc; |
| 405 | } |
| 406 | |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 407 | rc = vio_enable_interrupts(ibmvtpm->vdev); |
| 408 | if (rc) { |
| 409 | dev_err(dev, "Error vio_enable_interrupts rc=%d\n", rc); |
| 410 | return rc; |
| 411 | } |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 412 | |
| 413 | rc = ibmvtpm_crq_send_init(ibmvtpm); |
| 414 | if (rc) |
| 415 | dev_err(dev, "Error send_init rc=%d\n", rc); |
| 416 | |
| 417 | return rc; |
| 418 | } |
| 419 | |
Stefan Berger | 1f86605 | 2013-01-22 13:52:35 -0600 | [diff] [blame] | 420 | static bool tpm_ibmvtpm_req_canceled(struct tpm_chip *chip, u8 status) |
| 421 | { |
| 422 | return (status == 0); |
| 423 | } |
| 424 | |
Jason Gunthorpe | 01ad1fa | 2013-11-26 13:30:43 -0700 | [diff] [blame] | 425 | static const struct tpm_class_ops tpm_ibmvtpm = { |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 426 | .recv = tpm_ibmvtpm_recv, |
| 427 | .send = tpm_ibmvtpm_send, |
| 428 | .cancel = tpm_ibmvtpm_cancel, |
| 429 | .status = tpm_ibmvtpm_status, |
| 430 | .req_complete_mask = 0, |
| 431 | .req_complete_val = 0, |
Stefan Berger | 1f86605 | 2013-01-22 13:52:35 -0600 | [diff] [blame] | 432 | .req_canceled = tpm_ibmvtpm_req_canceled, |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 433 | }; |
| 434 | |
| 435 | static const struct dev_pm_ops tpm_ibmvtpm_pm_ops = { |
| 436 | .suspend = tpm_ibmvtpm_suspend, |
| 437 | .resume = tpm_ibmvtpm_resume, |
| 438 | }; |
| 439 | |
| 440 | /** |
| 441 | * ibmvtpm_crq_get_next - Get next responded crq |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 442 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 443 | * @ibmvtpm: vtpm device struct |
| 444 | * |
| 445 | * Return: vtpm crq pointer or NULL. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 446 | */ |
| 447 | static struct ibmvtpm_crq *ibmvtpm_crq_get_next(struct ibmvtpm_dev *ibmvtpm) |
| 448 | { |
| 449 | struct ibmvtpm_crq_queue *crq_q = &ibmvtpm->crq_queue; |
| 450 | struct ibmvtpm_crq *crq = &crq_q->crq_addr[crq_q->index]; |
| 451 | |
| 452 | if (crq->valid & VTPM_MSG_RES) { |
| 453 | if (++crq_q->index == crq_q->num_entry) |
| 454 | crq_q->index = 0; |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 455 | smp_rmb(); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 456 | } else |
| 457 | crq = NULL; |
| 458 | return crq; |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * ibmvtpm_crq_process - Process responded crq |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 463 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 464 | * @crq: crq to be processed |
| 465 | * @ibmvtpm: vtpm device struct |
| 466 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 467 | */ |
| 468 | static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq, |
| 469 | struct ibmvtpm_dev *ibmvtpm) |
| 470 | { |
| 471 | int rc = 0; |
| 472 | |
| 473 | switch (crq->valid) { |
| 474 | case VALID_INIT_CRQ: |
| 475 | switch (crq->msg) { |
| 476 | case INIT_CRQ_RES: |
| 477 | dev_info(ibmvtpm->dev, "CRQ initialized\n"); |
| 478 | rc = ibmvtpm_crq_send_init_complete(ibmvtpm); |
| 479 | if (rc) |
| 480 | dev_err(ibmvtpm->dev, "Unable to send CRQ init complete rc=%d\n", rc); |
| 481 | return; |
| 482 | case INIT_CRQ_COMP_RES: |
| 483 | dev_info(ibmvtpm->dev, |
| 484 | "CRQ initialization completed\n"); |
| 485 | return; |
| 486 | default: |
| 487 | dev_err(ibmvtpm->dev, "Unknown crq message type: %d\n", crq->msg); |
| 488 | return; |
| 489 | } |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 490 | case IBMVTPM_VALID_CMD: |
| 491 | switch (crq->msg) { |
| 492 | case VTPM_GET_RTCE_BUFFER_SIZE_RES: |
honclo | eb71f8a | 2015-02-12 21:02:24 -0500 | [diff] [blame] | 493 | if (be16_to_cpu(crq->len) <= 0) { |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 494 | dev_err(ibmvtpm->dev, "Invalid rtce size\n"); |
| 495 | return; |
| 496 | } |
honclo | eb71f8a | 2015-02-12 21:02:24 -0500 | [diff] [blame] | 497 | ibmvtpm->rtce_size = be16_to_cpu(crq->len); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 498 | ibmvtpm->rtce_buf = kmalloc(ibmvtpm->rtce_size, |
Hon Ching \(Vicky\) Lo | 60ecd86 | 2015-10-07 20:11:51 -0400 | [diff] [blame] | 499 | GFP_ATOMIC); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 500 | if (!ibmvtpm->rtce_buf) { |
| 501 | dev_err(ibmvtpm->dev, "Failed to allocate memory for rtce buffer\n"); |
| 502 | return; |
| 503 | } |
| 504 | |
| 505 | ibmvtpm->rtce_dma_handle = dma_map_single(ibmvtpm->dev, |
| 506 | ibmvtpm->rtce_buf, ibmvtpm->rtce_size, |
| 507 | DMA_BIDIRECTIONAL); |
| 508 | |
| 509 | if (dma_mapping_error(ibmvtpm->dev, |
| 510 | ibmvtpm->rtce_dma_handle)) { |
| 511 | kfree(ibmvtpm->rtce_buf); |
| 512 | ibmvtpm->rtce_buf = NULL; |
| 513 | dev_err(ibmvtpm->dev, "Failed to dma map rtce buffer\n"); |
| 514 | } |
| 515 | |
| 516 | return; |
| 517 | case VTPM_GET_VERSION_RES: |
honclo | eb71f8a | 2015-02-12 21:02:24 -0500 | [diff] [blame] | 518 | ibmvtpm->vtpm_version = be32_to_cpu(crq->data); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 519 | return; |
| 520 | case VTPM_TPM_COMMAND_RES: |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 521 | /* len of the data in rtce buffer */ |
honclo | eb71f8a | 2015-02-12 21:02:24 -0500 | [diff] [blame] | 522 | ibmvtpm->res_len = be16_to_cpu(crq->len); |
Stefan Berger | 6674ff1 | 2015-12-09 08:52:01 -0500 | [diff] [blame] | 523 | ibmvtpm->tpm_processing_cmd = false; |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 524 | wake_up_interruptible(&ibmvtpm->wq); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 525 | return; |
| 526 | default: |
| 527 | return; |
| 528 | } |
| 529 | } |
| 530 | return; |
| 531 | } |
| 532 | |
| 533 | /** |
| 534 | * ibmvtpm_interrupt - Interrupt handler |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 535 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 536 | * @irq: irq number to handle |
| 537 | * @vtpm_instance: vtpm that received interrupt |
| 538 | * |
| 539 | * Returns: |
| 540 | * IRQ_HANDLED |
| 541 | **/ |
| 542 | static irqreturn_t ibmvtpm_interrupt(int irq, void *vtpm_instance) |
| 543 | { |
| 544 | struct ibmvtpm_dev *ibmvtpm = (struct ibmvtpm_dev *) vtpm_instance; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 545 | struct ibmvtpm_crq *crq; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 546 | |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 547 | /* while loop is needed for initial setup (get version and |
| 548 | * get rtce_size). There should be only one tpm request at any |
| 549 | * given time. |
| 550 | */ |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 551 | while ((crq = ibmvtpm_crq_get_next(ibmvtpm)) != NULL) { |
| 552 | ibmvtpm_crq_process(crq, ibmvtpm); |
| 553 | crq->valid = 0; |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 554 | smp_wmb(); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 555 | } |
| 556 | |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 557 | return IRQ_HANDLED; |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | /** |
| 561 | * tpm_ibmvtpm_probe - ibm vtpm initialize entry point |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 562 | * |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 563 | * @vio_dev: vio device struct |
| 564 | * @id: vio device id struct |
| 565 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 566 | * Return: |
| 567 | * 0 on success. |
| 568 | * Non-zero on failure. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 569 | */ |
Bill Pemberton | afc6d36 | 2012-11-19 13:22:42 -0500 | [diff] [blame] | 570 | static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev, |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 571 | const struct vio_device_id *id) |
| 572 | { |
| 573 | struct ibmvtpm_dev *ibmvtpm; |
| 574 | struct device *dev = &vio_dev->dev; |
| 575 | struct ibmvtpm_crq_queue *crq_q; |
| 576 | struct tpm_chip *chip; |
| 577 | int rc = -ENOMEM, rc1; |
| 578 | |
Jarkko Sakkinen | afb5abc | 2014-12-12 11:46:34 -0800 | [diff] [blame] | 579 | chip = tpmm_chip_alloc(dev, &tpm_ibmvtpm); |
| 580 | if (IS_ERR(chip)) |
| 581 | return PTR_ERR(chip); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 582 | |
| 583 | ibmvtpm = kzalloc(sizeof(struct ibmvtpm_dev), GFP_KERNEL); |
| 584 | if (!ibmvtpm) { |
| 585 | dev_err(dev, "kzalloc for ibmvtpm failed\n"); |
| 586 | goto cleanup; |
| 587 | } |
| 588 | |
Hon Ching \(Vicky\) Lo | 9d75f08 | 2015-05-22 13:23:02 -0400 | [diff] [blame] | 589 | ibmvtpm->dev = dev; |
| 590 | ibmvtpm->vdev = vio_dev; |
| 591 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 592 | crq_q = &ibmvtpm->crq_queue; |
| 593 | crq_q->crq_addr = (struct ibmvtpm_crq *)get_zeroed_page(GFP_KERNEL); |
| 594 | if (!crq_q->crq_addr) { |
| 595 | dev_err(dev, "Unable to allocate memory for crq_addr\n"); |
| 596 | goto cleanup; |
| 597 | } |
| 598 | |
| 599 | crq_q->num_entry = CRQ_RES_BUF_SIZE / sizeof(*crq_q->crq_addr); |
| 600 | ibmvtpm->crq_dma_handle = dma_map_single(dev, crq_q->crq_addr, |
| 601 | CRQ_RES_BUF_SIZE, |
| 602 | DMA_BIDIRECTIONAL); |
| 603 | |
| 604 | if (dma_mapping_error(dev, ibmvtpm->crq_dma_handle)) { |
| 605 | dev_err(dev, "dma mapping failed\n"); |
| 606 | goto cleanup; |
| 607 | } |
| 608 | |
| 609 | rc = plpar_hcall_norets(H_REG_CRQ, vio_dev->unit_address, |
| 610 | ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE); |
| 611 | if (rc == H_RESOURCE) |
| 612 | rc = ibmvtpm_reset_crq(ibmvtpm); |
| 613 | |
| 614 | if (rc) { |
| 615 | dev_err(dev, "Unable to register CRQ rc=%d\n", rc); |
| 616 | goto reg_crq_cleanup; |
| 617 | } |
| 618 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 619 | rc = request_irq(vio_dev->irq, ibmvtpm_interrupt, 0, |
| 620 | tpm_ibmvtpm_driver_name, ibmvtpm); |
| 621 | if (rc) { |
| 622 | dev_err(dev, "Error %d register irq 0x%x\n", rc, vio_dev->irq); |
| 623 | goto init_irq_cleanup; |
| 624 | } |
| 625 | |
| 626 | rc = vio_enable_interrupts(vio_dev); |
| 627 | if (rc) { |
| 628 | dev_err(dev, "Error %d enabling interrupts\n", rc); |
| 629 | goto init_irq_cleanup; |
| 630 | } |
| 631 | |
Ashley Lai | b566650 | 2012-09-12 12:49:50 -0500 | [diff] [blame] | 632 | init_waitqueue_head(&ibmvtpm->wq); |
| 633 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 634 | crq_q->index = 0; |
| 635 | |
Stephen Rothwell | 7525455 | 2016-04-28 15:27:17 +1000 | [diff] [blame] | 636 | dev_set_drvdata(&chip->dev, ibmvtpm); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 637 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 638 | spin_lock_init(&ibmvtpm->rtce_lock); |
| 639 | |
| 640 | rc = ibmvtpm_crq_send_init(ibmvtpm); |
| 641 | if (rc) |
| 642 | goto init_irq_cleanup; |
| 643 | |
| 644 | rc = ibmvtpm_crq_get_version(ibmvtpm); |
| 645 | if (rc) |
| 646 | goto init_irq_cleanup; |
| 647 | |
| 648 | rc = ibmvtpm_crq_get_rtce_size(ibmvtpm); |
| 649 | if (rc) |
| 650 | goto init_irq_cleanup; |
| 651 | |
Jarkko Sakkinen | afb5abc | 2014-12-12 11:46:34 -0800 | [diff] [blame] | 652 | return tpm_chip_register(chip); |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 653 | init_irq_cleanup: |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 654 | do { |
| 655 | rc1 = plpar_hcall_norets(H_FREE_CRQ, vio_dev->unit_address); |
| 656 | } while (rc1 == H_BUSY || H_IS_LONG_BUSY(rc1)); |
| 657 | reg_crq_cleanup: |
| 658 | dma_unmap_single(dev, ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE, |
| 659 | DMA_BIDIRECTIONAL); |
| 660 | cleanup: |
| 661 | if (ibmvtpm) { |
| 662 | if (crq_q->crq_addr) |
| 663 | free_page((unsigned long)crq_q->crq_addr); |
| 664 | kfree(ibmvtpm); |
| 665 | } |
| 666 | |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 667 | return rc; |
| 668 | } |
| 669 | |
| 670 | static struct vio_driver ibmvtpm_driver = { |
| 671 | .id_table = tpm_ibmvtpm_device_table, |
| 672 | .probe = tpm_ibmvtpm_probe, |
| 673 | .remove = tpm_ibmvtpm_remove, |
| 674 | .get_desired_dma = tpm_ibmvtpm_get_desired_dma, |
| 675 | .name = tpm_ibmvtpm_driver_name, |
| 676 | .pm = &tpm_ibmvtpm_pm_ops, |
| 677 | }; |
| 678 | |
| 679 | /** |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 680 | * ibmvtpm_module_init - Initialize ibm vtpm module. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 681 | * |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 682 | * |
| 683 | * Return: |
| 684 | * 0 on success. |
| 685 | * Non-zero on failure. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 686 | */ |
| 687 | static int __init ibmvtpm_module_init(void) |
| 688 | { |
| 689 | return vio_register_driver(&ibmvtpm_driver); |
| 690 | } |
| 691 | |
| 692 | /** |
Winkler, Tomas | 93c12f2 | 2016-11-23 12:04:14 +0200 | [diff] [blame] | 693 | * ibmvtpm_module_exit - Tear down ibm vtpm module. |
Ashley Lai | 132f762 | 2012-08-22 16:17:43 -0500 | [diff] [blame] | 694 | */ |
| 695 | static void __exit ibmvtpm_module_exit(void) |
| 696 | { |
| 697 | vio_unregister_driver(&ibmvtpm_driver); |
| 698 | } |
| 699 | |
| 700 | module_init(ibmvtpm_module_init); |
| 701 | module_exit(ibmvtpm_module_exit); |
| 702 | |
| 703 | MODULE_AUTHOR("adlai@us.ibm.com"); |
| 704 | MODULE_DESCRIPTION("IBM vTPM Driver"); |
| 705 | MODULE_VERSION("1.0"); |
| 706 | MODULE_LICENSE("GPL"); |