From patchwork Wed Mar 23 20:17:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8654161 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D2C5CC0553 for ; Wed, 23 Mar 2016 20:17:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 134AB201C0 for ; Wed, 23 Mar 2016 20:17:40 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 314F720148 for ; Wed, 23 Mar 2016 20:17:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aipDk-000356-NR; Wed, 23 Mar 2016 20:17:36 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aipDj-00034z-1g for tpmdd-devel@lists.sourceforge.net; Wed, 23 Mar 2016 20:17:35 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.66 as permitted sender) client-ip=74.125.82.66; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f66.google.com; Received: from mail-wm0-f66.google.com ([74.125.82.66]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1aipDg-0006Ti-Us for tpmdd-devel@lists.sourceforge.net; Wed, 23 Mar 2016 20:17:35 +0000 Received: by mail-wm0-f66.google.com with SMTP id l68so7029224wml.3 for ; Wed, 23 Mar 2016 13:17:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YHbi9prX6qZxPfBwsnVmbnzj/MVTpYPHeiZVm63JccI=; b=ZevtmDwXDlY021k4Rke3ozfIm1V+WiW1WfVVvRajsFYpA9kmGD8lDYS6Wppp3GT4Hg YyrxWI2C68U46dL3S1g/WJkPS99Ur7SESkAiNK9LCbw9aUToXlwSrYFx5FVBqO36dcZz Vc11HK43BFNpyr8OQ6RXwKfCu/qm0TVUTsyJu4CXmSSVeIlzj9zUlT8/moPA7spglVBD a0BA7y0wN+QXTkVvCqYzYHLhT+OAgBXyUnacgvbVZ/FJvejtcHo+9W2+EG3IiT5bUBmE AnMoACq+qs0EBa/patdxlRoJVvV/bD5fCN3Y5KOy13yNIrhgMOZT4445+eww1LT8Qdpf CjDw== X-Gm-Message-State: AD7BkJKUsXic32iIGBailwq5S5Id/ANrnkKdIWVs8G54wwmtq9qgD3teeUad0gtVtJIWEQ== X-Received: by 10.194.120.229 with SMTP id lf5mr5896603wjb.151.1458764246827; Wed, 23 Mar 2016 13:17:26 -0700 (PDT) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by smtp.gmail.com with ESMTPSA id xx3sm4155165wjc.32.2016.03.23.13.17.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Mar 2016 13:17:25 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Wed, 23 Mar 2016 21:17:16 +0100 Message-Id: <1458764240-24185-2-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458764240-24185-1-git-send-email-christophe-h.ricard@st.com> References: <1458764240-24185-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1aipDg-0006Ti-Us Cc: jean-luc.blanc@st.com, ashley@ashleylai.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, benoit.houyere@st.com Subject: [tpmdd-devel] [PATCH 1/5] tpm: drop 'iobase' from struct tpm_vendor_specific X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dropped the field 'iobase' from struct tpm_vendor_specific and migrated it to the private structures of tpm_atmel and tpm_tis. Signed-off-by: Christophe Ricard Reviewed-by: Jason Gunthorpe Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm.h | 2 - drivers/char/tpm/tpm_atmel.c | 29 +++++++----- drivers/char/tpm/tpm_tis.c | 104 +++++++++++++++++++++++++------------------ 3 files changed, 78 insertions(+), 57 deletions(-) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 7317bec..0d1b7e6 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -131,8 +131,6 @@ enum tpm2_startup_types { struct tpm_chip; struct tpm_vendor_specific { - void __iomem *iobase; /* ioremapped address */ - int irq; struct list_head list; diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c index c6daf6c..242d6c6 100644 --- a/drivers/char/tpm/tpm_atmel.c +++ b/drivers/char/tpm/tpm_atmel.c @@ -36,6 +36,7 @@ enum tpm_atmel_read_status { }; struct tpm_atmel_priv { + void __iomem *iobase; unsigned long base; int region_size; int have_region; @@ -43,6 +44,7 @@ struct tpm_atmel_priv { static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) { + struct tpm_atmel_priv *priv = chip->vendor.priv; u8 status, *hdr = buf; u32 size; int i; @@ -53,12 +55,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) return -EIO; for (i = 0; i < 6; i++) { - status = ioread8(chip->vendor.iobase + 1); + status = ioread8(priv->iobase + 1); if ((status & ATML_STATUS_DATA_AVAIL) == 0) { dev_err(&chip->dev, "error reading header\n"); return -EIO; } - *buf++ = ioread8(chip->vendor.iobase); + *buf++ = ioread8(priv->iobase); } /* size of the data received */ @@ -69,7 +71,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) dev_err(&chip->dev, "Recv size(%d) less than available space\n", size); for (; i < size; i++) { /* clear the waiting data anyway */ - status = ioread8(chip->vendor.iobase + 1); + status = ioread8(priv->iobase + 1); if ((status & ATML_STATUS_DATA_AVAIL) == 0) { dev_err(&chip->dev, "error reading data\n"); return -EIO; @@ -80,16 +82,16 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) /* read all the data available */ for (; i < size; i++) { - status = ioread8(chip->vendor.iobase + 1); + status = ioread8(priv->iobase + 1); if ((status & ATML_STATUS_DATA_AVAIL) == 0) { dev_err(&chip->dev, "error reading data\n"); return -EIO; } - *buf++ = ioread8(chip->vendor.iobase); + *buf++ = ioread8(priv->iobase); } /* make sure data available is gone */ - status = ioread8(chip->vendor.iobase + 1); + status = ioread8(priv->iobase + 1); if (status & ATML_STATUS_DATA_AVAIL) { dev_err(&chip->dev, "data available is stuck\n"); @@ -101,12 +103,13 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) { + struct tpm_atmel_priv *priv = chip->vendor.priv; int i; dev_dbg(&chip->dev, "tpm_atml_send:\n"); for (i = 0; i < count; i++) { dev_dbg(&chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]); - iowrite8(buf[i], chip->vendor.iobase); + iowrite8(buf[i], priv->iobase); } return count; @@ -114,12 +117,16 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) static void tpm_atml_cancel(struct tpm_chip *chip) { - iowrite8(ATML_STATUS_ABORT, chip->vendor.iobase + 1); + struct tpm_atmel_priv *priv = chip->vendor.priv; + + iowrite8(ATML_STATUS_ABORT, priv->iobase + 1); } static u8 tpm_atml_status(struct tpm_chip *chip) { - return ioread8(chip->vendor.iobase + 1); + struct tpm_atmel_priv *priv = chip->vendor.priv; + + return ioread8(priv->iobase + 1); } static bool tpm_atml_req_canceled(struct tpm_chip *chip, u8 status) @@ -148,7 +155,7 @@ static void atml_plat_remove(void) tpm_chip_unregister(chip); if (priv->have_region) atmel_release_region(priv->base, priv->region_size); - atmel_put_base_addr(chip->vendor.iobase); + atmel_put_base_addr(priv->iobase); platform_device_unregister(pdev); } } @@ -196,6 +203,7 @@ static int __init init_atmel(void) goto err_unreg_dev; } + priv->iobase = iobase; priv->base = base; priv->have_region = have_region; priv->region_size = region_size; @@ -206,7 +214,6 @@ static int __init init_atmel(void) goto err_unreg_dev; } - chip->vendor.iobase = iobase; chip->vendor.priv = priv; rc = tpm_chip_register(chip); diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 068f021..19dac62 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -94,6 +94,7 @@ struct tpm_info { #define TPM_RID(l) (0x0F04 | ((l) << 12)) struct priv_data { + void __iomem *iobase; u16 manufacturer_id; bool irq_tested; wait_queue_head_t int_queue; @@ -128,9 +129,10 @@ static inline int is_itpm(struct acpi_device *dev) * correct values in the other bits.' */ static int wait_startup(struct tpm_chip *chip, int l) { + struct priv_data *priv = chip->vendor.priv; unsigned long stop = jiffies + chip->vendor.timeout_a; do { - if (ioread8(chip->vendor.iobase + TPM_ACCESS(l)) & + if (ioread8(priv->iobase + TPM_ACCESS(l)) & TPM_ACCESS_VALID) return 0; msleep(TPM_TIMEOUT); @@ -140,7 +142,9 @@ static int wait_startup(struct tpm_chip *chip, int l) static int check_locality(struct tpm_chip *chip, int l) { - if ((ioread8(chip->vendor.iobase + TPM_ACCESS(l)) & + struct priv_data *priv = chip->vendor.priv; + + if ((ioread8(priv->iobase + TPM_ACCESS(l)) & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) return chip->vendor.locality = l; @@ -150,11 +154,13 @@ static int check_locality(struct tpm_chip *chip, int l) static void release_locality(struct tpm_chip *chip, int l, int force) { - if (force || (ioread8(chip->vendor.iobase + TPM_ACCESS(l)) & + struct priv_data *priv = chip->vendor.priv; + + if (force || (ioread8(priv->iobase + TPM_ACCESS(l)) & (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) == (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) iowrite8(TPM_ACCESS_ACTIVE_LOCALITY, - chip->vendor.iobase + TPM_ACCESS(l)); + priv->iobase + TPM_ACCESS(l)); } static int request_locality(struct tpm_chip *chip, int l) @@ -167,7 +173,7 @@ static int request_locality(struct tpm_chip *chip, int l) return l; iowrite8(TPM_ACCESS_REQUEST_USE, - chip->vendor.iobase + TPM_ACCESS(l)); + priv->iobase + TPM_ACCESS(l)); stop = jiffies + chip->vendor.timeout_a; @@ -200,19 +206,24 @@ again: static u8 tpm_tis_status(struct tpm_chip *chip) { - return ioread8(chip->vendor.iobase + + struct priv_data *priv = chip->vendor.priv; + + return ioread8(priv->iobase + TPM_STS(chip->vendor.locality)); } static void tpm_tis_ready(struct tpm_chip *chip) { + struct priv_data *priv = chip->vendor.priv; + /* this causes the current command to be aborted */ iowrite8(TPM_STS_COMMAND_READY, - chip->vendor.iobase + TPM_STS(chip->vendor.locality)); + priv->iobase + TPM_STS(chip->vendor.locality)); } static int get_burstcount(struct tpm_chip *chip) { + struct priv_data *priv = chip->vendor.priv; unsigned long stop; int burstcnt; @@ -220,9 +231,9 @@ static int get_burstcount(struct tpm_chip *chip) /* which timeout value, spec has 2 answers (c & d) */ stop = jiffies + chip->vendor.timeout_d; do { - burstcnt = ioread8(chip->vendor.iobase + + burstcnt = ioread8(priv->iobase + TPM_STS(chip->vendor.locality) + 1); - burstcnt += ioread8(chip->vendor.iobase + + burstcnt += ioread8(priv->iobase + TPM_STS(chip->vendor.locality) + 2) << 8; if (burstcnt) @@ -234,6 +245,7 @@ static int get_burstcount(struct tpm_chip *chip) static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) { + struct priv_data *priv = chip->vendor.priv; int size = 0, burstcnt; while (size < count && wait_for_tpm_stat(chip, @@ -243,7 +255,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) == 0) { burstcnt = get_burstcount(chip); for (; burstcnt > 0 && size < count; burstcnt--) - buf[size++] = ioread8(chip->vendor.iobase + + buf[size++] = ioread8(priv->iobase + TPM_DATA_FIFO(chip->vendor. locality)); } @@ -329,7 +341,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len) while (count < len - 1) { burstcnt = get_burstcount(chip); for (; burstcnt > 0 && count < len - 1; burstcnt--) { - iowrite8(buf[count], chip->vendor.iobase + + iowrite8(buf[count], priv->iobase + TPM_DATA_FIFO(chip->vendor.locality)); count++; } @@ -345,7 +357,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len) /* write last byte */ iowrite8(buf[count], - chip->vendor.iobase + TPM_DATA_FIFO(chip->vendor.locality)); + priv->iobase + TPM_DATA_FIFO(chip->vendor.locality)); wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &priv->int_queue, false); status = tpm_tis_status(chip); @@ -364,15 +376,15 @@ out_err: static void disable_interrupts(struct tpm_chip *chip) { + struct priv_data *priv = chip->vendor.priv; u32 intmask; intmask = - ioread32(chip->vendor.iobase + + ioread32(priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); intmask &= ~TPM_GLOBAL_INT_ENABLE; iowrite32(intmask, - chip->vendor.iobase + - TPM_INT_ENABLE(chip->vendor.locality)); + priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); devm_free_irq(&chip->dev, chip->vendor.irq, chip); chip->vendor.irq = 0; } @@ -384,6 +396,7 @@ static void disable_interrupts(struct tpm_chip *chip) */ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len) { + struct priv_data *priv = chip->vendor.priv; int rc; u32 ordinal; unsigned long dur; @@ -394,7 +407,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len) /* go and do it */ iowrite8(TPM_STS_GO, - chip->vendor.iobase + TPM_STS(chip->vendor.locality)); + priv->iobase + TPM_STS(chip->vendor.locality)); if (chip->vendor.irq) { ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); @@ -453,10 +466,11 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = { static bool tpm_tis_update_timeouts(struct tpm_chip *chip, unsigned long *timeout_cap) { + struct priv_data *priv = chip->vendor.priv; int i; u32 did_vid; - did_vid = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); + did_vid = ioread32(priv->iobase + TPM_DID_VID(0)); for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) { if (vendor_timeout_overrides[i].did_vid != did_vid) @@ -476,6 +490,7 @@ static bool tpm_tis_update_timeouts(struct tpm_chip *chip, */ static int probe_itpm(struct tpm_chip *chip) { + struct priv_data *priv = chip->vendor.priv; int rc = 0; u8 cmd_getticks[] = { 0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a, @@ -483,7 +498,7 @@ static int probe_itpm(struct tpm_chip *chip) }; size_t len = sizeof(cmd_getticks); bool rem_itpm = itpm; - u16 vendor = ioread16(chip->vendor.iobase + TPM_DID_VID(0)); + u16 vendor = ioread16(priv->iobase + TPM_DID_VID(0)); /* probe only iTPMS */ if (vendor != TPM_VID_INTEL) @@ -548,7 +563,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) u32 interrupt; int i; - interrupt = ioread32(chip->vendor.iobase + + interrupt = ioread32(priv->iobase + TPM_INT_STATUS(chip->vendor.locality)); if (interrupt == 0) @@ -568,9 +583,9 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) /* Clear interrupts handled with TPM_EOI */ iowrite32(interrupt, - chip->vendor.iobase + + priv->iobase + TPM_INT_STATUS(chip->vendor.locality)); - ioread32(chip->vendor.iobase + TPM_INT_STATUS(chip->vendor.locality)); + ioread32(priv->iobase + TPM_INT_STATUS(chip->vendor.locality)); return IRQ_HANDLED; } @@ -592,19 +607,19 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, } chip->vendor.irq = irq; - original_int_vec = ioread8(chip->vendor.iobase + + original_int_vec = ioread8(priv->iobase + TPM_INT_VECTOR(chip->vendor.locality)); iowrite8(irq, - chip->vendor.iobase + TPM_INT_VECTOR(chip->vendor.locality)); + priv->iobase + TPM_INT_VECTOR(chip->vendor.locality)); /* Clear all existing */ - iowrite32(ioread32(chip->vendor.iobase + + iowrite32(ioread32(priv->iobase + TPM_INT_STATUS(chip->vendor.locality)), - chip->vendor.iobase + TPM_INT_STATUS(chip->vendor.locality)); + priv->iobase + TPM_INT_STATUS(chip->vendor.locality)); /* Turn on */ iowrite32(intmask | TPM_GLOBAL_INT_ENABLE, - chip->vendor.iobase + TPM_INT_ENABLE(chip->vendor.locality)); + priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); priv->irq_tested = false; @@ -621,8 +636,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, */ if (!chip->vendor.irq) { iowrite8(original_int_vec, - chip->vendor.iobase + - TPM_INT_VECTOR(chip->vendor.locality)); + priv->iobase + TPM_INT_VECTOR(chip->vendor.locality)); return 1; } @@ -635,10 +649,11 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, */ static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask) { + struct priv_data *priv = chip->vendor.priv; u8 original_int_vec; int i; - original_int_vec = ioread8(chip->vendor.iobase + + original_int_vec = ioread8(priv->iobase + TPM_INT_VECTOR(chip->vendor.locality)); if (!original_int_vec) { @@ -658,15 +673,16 @@ MODULE_PARM_DESC(interrupts, "Enable interrupts"); static void tpm_tis_remove(struct tpm_chip *chip) { + struct priv_data *priv = chip->vendor.priv; + if (chip->flags & TPM_CHIP_FLAG_TPM2) tpm2_shutdown(chip, TPM2_SU_CLEAR); iowrite32(~TPM_GLOBAL_INT_ENABLE & - ioread32(chip->vendor.iobase + + ioread32(priv->iobase + TPM_INT_ENABLE(chip->vendor. locality)), - chip->vendor.iobase + - TPM_INT_ENABLE(chip->vendor.locality)); + priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); release_locality(chip, chip->vendor.locality, 1); } @@ -691,9 +707,9 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, chip->acpi_dev_handle = acpi_dev_handle; #endif - chip->vendor.iobase = devm_ioremap_resource(dev, &tpm_info->res); - if (IS_ERR(chip->vendor.iobase)) - return PTR_ERR(chip->vendor.iobase); + priv->iobase = devm_ioremap_resource(dev, &tpm_info->res); + if (IS_ERR(priv->iobase)) + return PTR_ERR(priv->iobase); /* Maximum timeouts */ chip->vendor.timeout_a = TIS_TIMEOUT_A_MAX; @@ -707,13 +723,13 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, } /* Take control of the TPM's interrupt hardware and shut it off */ - intmask = ioread32(chip->vendor.iobase + + intmask = ioread32(priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT; intmask &= ~TPM_GLOBAL_INT_ENABLE; iowrite32(intmask, - chip->vendor.iobase + TPM_INT_ENABLE(chip->vendor.locality)); + priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); if (request_locality(chip, 0) != 0) { rc = -ENODEV; @@ -724,12 +740,12 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, if (rc) goto out_err; - vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); + vendor = ioread32(priv->iobase + TPM_DID_VID(0)); priv->manufacturer_id = vendor; dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n", (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2", - vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0))); + vendor >> 16, ioread8(priv->iobase + TPM_RID(0))); if (!itpm) { probe = probe_itpm(chip); @@ -746,7 +762,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, /* Figure out the capabilities */ intfcaps = - ioread32(chip->vendor.iobase + + ioread32(priv->iobase + TPM_INTF_CAPS(chip->vendor.locality)); dev_dbg(dev, "TPM interface capabilities (0x%x):\n", intfcaps); @@ -825,23 +841,23 @@ out_err: #ifdef CONFIG_PM_SLEEP static void tpm_tis_reenable_interrupts(struct tpm_chip *chip) { + struct priv_data *priv = chip->vendor.priv; u32 intmask; /* reenable interrupts that device may have lost or BIOS/firmware may have disabled */ - iowrite8(chip->vendor.irq, chip->vendor.iobase + + iowrite8(chip->vendor.irq, priv->iobase + TPM_INT_VECTOR(chip->vendor.locality)); intmask = - ioread32(chip->vendor.iobase + - TPM_INT_ENABLE(chip->vendor.locality)); + ioread32(priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT | TPM_GLOBAL_INT_ENABLE; iowrite32(intmask, - chip->vendor.iobase + TPM_INT_ENABLE(chip->vendor.locality)); + priv->iobase + TPM_INT_ENABLE(chip->vendor.locality)); } static int tpm_tis_resume(struct device *dev)