tpm_nsc.c (90dda520c1962d55a0e1d2571deed0d75fd6d6f1) tpm_nsc.c (e0dd03caf20d040a0a86b6bd74028ec9bda545f5)
1/*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Authors:
5 * Leendert van Doorn <leendert@watson.ibm.com>
6 * Dave Safford <safford@watson.ibm.com>
7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com>

--- 236 unchanged lines hidden (view full) ---

245 &dev_attr_pcrs.attr,
246 &dev_attr_caps.attr,
247 &dev_attr_cancel.attr,
248 NULL,
249};
250
251static struct attribute_group nsc_attr_grp = { .attrs = nsc_attrs };
252
1/*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Authors:
5 * Leendert van Doorn <leendert@watson.ibm.com>
6 * Dave Safford <safford@watson.ibm.com>
7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com>

--- 236 unchanged lines hidden (view full) ---

245 &dev_attr_pcrs.attr,
246 &dev_attr_caps.attr,
247 &dev_attr_cancel.attr,
248 NULL,
249};
250
251static struct attribute_group nsc_attr_grp = { .attrs = nsc_attrs };
252
253static struct tpm_vendor_specific tpm_nsc = {
253static const struct tpm_vendor_specific tpm_nsc = {
254 .recv = tpm_nsc_recv,
255 .send = tpm_nsc_send,
256 .cancel = tpm_nsc_cancel,
257 .status = tpm_nsc_status,
258 .req_complete_mask = NSC_STATUS_OBF,
259 .req_complete_val = NSC_STATUS_OBF,
260 .req_canceled = NSC_STATUS_RDY,
261 .attr_group = &nsc_attr_grp,

--- 19 unchanged lines hidden (view full) ---

281 .resume = tpm_pm_resume,
282};
283
284static int __init init_nsc(void)
285{
286 int rc = 0;
287 int lo, hi;
288 int nscAddrBase = TPM_ADDR;
254 .recv = tpm_nsc_recv,
255 .send = tpm_nsc_send,
256 .cancel = tpm_nsc_cancel,
257 .status = tpm_nsc_status,
258 .req_complete_mask = NSC_STATUS_OBF,
259 .req_complete_val = NSC_STATUS_OBF,
260 .req_canceled = NSC_STATUS_RDY,
261 .attr_group = &nsc_attr_grp,

--- 19 unchanged lines hidden (view full) ---

281 .resume = tpm_pm_resume,
282};
283
284static int __init init_nsc(void)
285{
286 int rc = 0;
287 int lo, hi;
288 int nscAddrBase = TPM_ADDR;
289 struct tpm_chip *chip;
290 unsigned long base;
289
291
290
291 /* verify that it is a National part (SID) */
292 if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) {
293 nscAddrBase = (tpm_read_index(TPM_SUPERIO_ADDR, 0x2C)<<8)|
294 (tpm_read_index(TPM_SUPERIO_ADDR, 0x2B)&0xFE);
295 if (tpm_read_index(nscAddrBase, NSC_SID_INDEX) != 0xF6)
296 return -ENODEV;
297 }
298
299 driver_register(&nsc_drv);
300
301 hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
302 lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);
292 /* verify that it is a National part (SID) */
293 if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) {
294 nscAddrBase = (tpm_read_index(TPM_SUPERIO_ADDR, 0x2C)<<8)|
295 (tpm_read_index(TPM_SUPERIO_ADDR, 0x2B)&0xFE);
296 if (tpm_read_index(nscAddrBase, NSC_SID_INDEX) != 0xF6)
297 return -ENODEV;
298 }
299
300 driver_register(&nsc_drv);
301
302 hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
303 lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);
303 tpm_nsc.base = (hi<<8) | lo;
304 base = (hi<<8) | lo;
304
305 /* enable the DPM module */
306 tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01);
307
308 pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
309 if (!pdev) {
310 rc = -ENOMEM;
311 goto err_unreg_drv;
312 }
313
314 pdev->name = "tpm_nscl0";
315 pdev->id = -1;
316 pdev->num_resources = 0;
317 pdev->dev.release = tpm_nsc_remove;
318 pdev->dev.driver = &nsc_drv;
319
320 if ((rc = platform_device_register(pdev)) < 0)
321 goto err_free_dev;
322
305
306 /* enable the DPM module */
307 tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01);
308
309 pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
310 if (!pdev) {
311 rc = -ENOMEM;
312 goto err_unreg_drv;
313 }
314
315 pdev->name = "tpm_nscl0";
316 pdev->id = -1;
317 pdev->num_resources = 0;
318 pdev->dev.release = tpm_nsc_remove;
319 pdev->dev.driver = &nsc_drv;
320
321 if ((rc = platform_device_register(pdev)) < 0)
322 goto err_free_dev;
323
323 if (request_region(tpm_nsc.base, 2, "tpm_nsc0") == NULL ) {
324 if (request_region(base, 2, "tpm_nsc0") == NULL ) {
324 rc = -EBUSY;
325 goto err_unreg_dev;
326 }
327
325 rc = -EBUSY;
326 goto err_unreg_dev;
327 }
328
328 if ((rc = tpm_register_hardware(&pdev->dev, &tpm_nsc)) < 0)
329 if (!(chip = tpm_register_hardware(&pdev->dev, &tpm_nsc))) {
330 rc = -ENODEV;
329 goto err_rel_reg;
331 goto err_rel_reg;
332 }
330
331 dev_dbg(&pdev->dev, "NSC TPM detected\n");
332 dev_dbg(&pdev->dev,
333 "NSC LDN 0x%x, SID 0x%x, SRID 0x%x\n",
334 tpm_read_index(nscAddrBase,0x07), tpm_read_index(nscAddrBase,0x20),
335 tpm_read_index(nscAddrBase,0x27));
336 dev_dbg(&pdev->dev,
337 "NSC SIOCF1 0x%x SIOCF5 0x%x SIOCF6 0x%x SIOCF8 0x%x\n",

--- 18 unchanged lines hidden (view full) ---

356 tpm_read_index(nscAddrBase,0xF4), tpm_read_index(nscAddrBase,0xF5),
357 tpm_read_index(nscAddrBase,0xF6), tpm_read_index(nscAddrBase,0xF7),
358 tpm_read_index(nscAddrBase,0xF8), tpm_read_index(nscAddrBase,0xF9));
359
360 dev_info(&pdev->dev,
361 "NSC TPM revision %d\n",
362 tpm_read_index(nscAddrBase, 0x27) & 0x1F);
363
333
334 dev_dbg(&pdev->dev, "NSC TPM detected\n");
335 dev_dbg(&pdev->dev,
336 "NSC LDN 0x%x, SID 0x%x, SRID 0x%x\n",
337 tpm_read_index(nscAddrBase,0x07), tpm_read_index(nscAddrBase,0x20),
338 tpm_read_index(nscAddrBase,0x27));
339 dev_dbg(&pdev->dev,
340 "NSC SIOCF1 0x%x SIOCF5 0x%x SIOCF6 0x%x SIOCF8 0x%x\n",

--- 18 unchanged lines hidden (view full) ---

359 tpm_read_index(nscAddrBase,0xF4), tpm_read_index(nscAddrBase,0xF5),
360 tpm_read_index(nscAddrBase,0xF6), tpm_read_index(nscAddrBase,0xF7),
361 tpm_read_index(nscAddrBase,0xF8), tpm_read_index(nscAddrBase,0xF9));
362
363 dev_info(&pdev->dev,
364 "NSC TPM revision %d\n",
365 tpm_read_index(nscAddrBase, 0x27) & 0x1F);
366
367 chip->vendor.base = base;
368
364 return 0;
365
366err_rel_reg:
369 return 0;
370
371err_rel_reg:
367 release_region(tpm_nsc.base, 2);
372 release_region(base, 2);
368err_unreg_dev:
369 platform_device_unregister(pdev);
370err_free_dev:
371 kfree(pdev);
372err_unreg_drv:
373 driver_unregister(&nsc_drv);
374 return rc;
375}

--- 20 unchanged lines hidden ---
373err_unreg_dev:
374 platform_device_unregister(pdev);
375err_free_dev:
376 kfree(pdev);
377err_unreg_drv:
378 driver_unregister(&nsc_drv);
379 return rc;
380}

--- 20 unchanged lines hidden ---