From patchwork Sat Apr 16 06:35:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8861171 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C81B19FB88 for ; Sat, 16 Apr 2016 06:36:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D990B20222 for ; Sat, 16 Apr 2016 06:36:11 +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 BCFC620221 for ; Sat, 16 Apr 2016 06:36:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1arJpx-0002KN-91; Sat, 16 Apr 2016 06:36:09 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1arJpw-0002KB-4H for tpmdd-devel@lists.sourceforge.net; Sat, 16 Apr 2016 06:36:08 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.42 as permitted sender) client-ip=74.125.82.42; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f42.google.com; Received: from mail-wm0-f42.google.com ([74.125.82.42]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1arJpv-0007MZ-3t for tpmdd-devel@lists.sourceforge.net; Sat, 16 Apr 2016 06:36:08 +0000 Received: by mail-wm0-f42.google.com with SMTP id u206so58059289wme.1 for ; Fri, 15 Apr 2016 23:36:07 -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=iBlEcMGUoJVFogEMCifaYCAmxf4A3B+9CyrXJdnxUA0=; b=X/gAjjJiEMVJTe+xAjOaEuas/BhvnbwWG1mNRdZHcK79Bi5IDkbNgOrgEc7XJpF0KN s+ab/j1KRgcw9Eo9fe4yD1qtYnOyfw3OD8WvDDHaDJcNE7po5b+Ls18y7Vvb4lLx4SDE rp+juXQSvyvjeRSv1Lc/HL4J0sWskS/ShciRdAyc4zbZHDQVTCO9ftmAvj0MAY7T+CFE gkduhjNJkJPzCfBsYJTwzKPEPRJmJH6mCTlcK6BKh0ljFK2K0tODYMVbf4urqLZelLuT rhYbBwfwKfZe9cpbyC89U47hVX8vA1vCOniy916KIJxY3ecrSTL6jiSarZa6ULlK+CHb naVQ== X-Gm-Message-State: AOPr4FUChML9hT81rVcZ027WXx1dWyPLUUE7r/NZ4S+G3npRcXLwsYfbkMBp4+0NvXqsNQ== X-Received: by 10.28.32.199 with SMTP id g190mr8492779wmg.62.1460788561093; Fri, 15 Apr 2016 23:36:01 -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 wr2sm52541996wjc.49.2016.04.15.23.35.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Apr 2016 23:36:00 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Sat, 16 Apr 2016 08:35:38 +0200 Message-Id: <1460788542-2455-9-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460788542-2455-1-git-send-email-christophe-h.ricard@st.com> References: <1460788542-2455-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1arJpv-0007MZ-3t 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 v3 08/12] tpm: tpm_tis: Add post_probe phy handler 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=-7.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_HI,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 Add post_probe phy handler in order to execute additional proprietary operations after tpm2_probe. For the case of tpm_tis using LPC, itpm workaround probing. Signed-off-by: Christophe Ricard --- drivers/char/tpm/tpm_tis.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index ea95a82..236f644 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -657,14 +657,6 @@ static int tpm_mem_write32(struct tpm_chip *chip, u32 addr, u32 value) return 0; } -static const struct tpm_tis_phy_ops tpm_mem = { - .read_bytes = tpm_mem_read_bytes, - .write_bytes = tpm_mem_write_bytes, - .read16 = tpm_mem_read16, - .read32 = tpm_mem_read32, - .write32 = tpm_mem_write32, -}; - static irqreturn_t tis_int_handler(int dummy, void *dev_id) { struct tpm_chip *chip = dev_id; @@ -793,6 +785,32 @@ static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask) return; } +static int tpm_tis_post_probe(struct tpm_chip *chip) +{ + int probe; + + if (!itpm) { + probe = probe_itpm(chip); + if (probe < 0) + return -ENODEV; + itpm = !!probe; + } + + if (itpm) + dev_info(chip->dev.parent, "Intel iTPM workaround enabled\n"); + + return 0; +} + +static const struct tpm_tis_phy_ops tpm_mem = { + .read_bytes = tpm_mem_read_bytes, + .write_bytes = tpm_mem_write_bytes, + .read16 = tpm_mem_read16, + .read32 = tpm_mem_read32, + .write32 = tpm_mem_write32, + .post_probe = tpm_tis_post_probe, +}; + static bool interrupts = true; module_param(interrupts, bool, 0444); MODULE_PARM_DESC(interrupts, "Enable interrupts"); @@ -817,7 +835,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, { u32 vendor, intfcaps, intmask; u8 rid; - int rc, probe; + int rc; struct tpm_chip *chip; struct tpm_tis_lpc_phy *phy; @@ -887,18 +905,14 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2", vendor >> 16, rid); - if (!itpm) { - probe = probe_itpm(chip); - if (probe < 0) { + if (phy->priv.phy_ops->post_probe) { + rc = phy->priv.phy_ops->post_probe(chip); + if (rc < 0) { rc = -ENODEV; goto out_err; } - itpm = !!probe; } - if (itpm) - dev_info(dev, "Intel iTPM workaround enabled\n"); - /* Figure out the capabilities */ rc = tpm_read32(chip, TPM_INTF_CAPS(phy->priv.locality), &intfcaps); if (rc < 0)