From patchwork Sun Apr 10 21:23:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 608581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3qjmQd3hD7z9t3p for ; Mon, 11 Apr 2016 07:23:37 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1apMpR-0006PA-PB; Sun, 10 Apr 2016 21:23:33 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1apMpQ-0006Oy-C5 for tpmdd-devel@lists.sourceforge.net; Sun, 10 Apr 2016 21:23:32 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.45 as permitted sender) client-ip=74.125.82.45; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f45.google.com; Received: from mail-wm0-f45.google.com ([74.125.82.45]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1apMpO-0003Ub-L4 for tpmdd-devel@lists.sourceforge.net; Sun, 10 Apr 2016 21:23:32 +0000 Received: by mail-wm0-f45.google.com with SMTP id f198so122462518wme.0 for ; Sun, 10 Apr 2016 14:23:30 -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=03CS4T7UgMf7B+owT2tQKTubrD+lrxDcqGRVS7iszdI=; b=KT9LPaG/bUz3jBimzKXbS9a6AxLEFGIVq1jBzgTvTLMRYemR9aBWjKj6n+dVviNGAJ fb3Bb81qBHqWTeIFwtJ9w2YkPJHOVgzw8d/0fmuP4XryHrchKYy/NlQBYNAwZFy+PX4T 9eSBs1DUuKn/vhvUp2Poghcch+9tL228GfxkXgfYEhrqHM3DUCsn8ZlNXH6/EKONhwL8 JefvQ96TUH2ka8EkwqHvPy667+HfZ+GO3OCNeHDE+d7sp4nxdIWd9hVjx6OWN76KXaKO cGWhwRLVo/XzFutod45+qvCxJFI4YhmTv7ZzWdza76yrsZVyphRYEbSwXZj/VQjy3zM1 PGTw== X-Gm-Message-State: AD7BkJL9oLp/M83+WjvUuixTDrBRkLnjlxsGcGAxR7L7SEpVTKvD4flT+fhxXS0AAF9xDA== X-Received: by 10.28.16.141 with SMTP id 135mr15321583wmq.67.1460323404686; Sun, 10 Apr 2016 14:23:24 -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 kj9sm24537597wjb.14.2016.04.10.14.23.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Apr 2016 14:23:23 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Sun, 10 Apr 2016 23:23:01 +0200 Message-Id: <1460323386-16892-6-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460323386-16892-1-git-send-email-christophe-h.ricard@st.com> References: <1460323386-16892-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (christophe.ricard[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1apMpO-0003Ub-L4 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 05/10] 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 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 | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 5b3eb26..2267093 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -96,6 +96,7 @@ struct tpm_info { struct tpm_tis_phy_ops { u8 data_expect_mask; u8 data_expect_val; + int (*post_probe)(struct tpm_chip *chip); }; struct priv_data { @@ -619,6 +620,7 @@ static const struct tpm_class_ops tpm_tis = { static struct tpm_tis_phy_ops tis_phy_ops = { .data_expect_mask = TPM_STS_DATA_EXPECT, .data_expect_val = TPM_STS_DATA_EXPECT, + .post_probe = tpm_tis_post_probe, }; static int tpm_mem_read_bytes(struct tpm_chip *chip, u32 addr, u16 len, @@ -810,6 +812,23 @@ 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 bool interrupts = true; module_param(interrupts, bool, 0444); MODULE_PARM_DESC(interrupts, "Enable interrupts"); @@ -906,19 +925,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 (priv->phy_ops && priv->phy_ops->post_probe) { + rc = 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(priv->locality), &intfcaps); if (rc < 0)