From patchwork Mon Apr 18 22:17:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8875961 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 D79369F443 for ; Mon, 18 Apr 2016 22:18:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 81CEC20222 for ; Mon, 18 Apr 2016 22:18:15 +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 E40BA201BC for ; Mon, 18 Apr 2016 22:18:13 +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 1asHUi-0003xR-R0; Mon, 18 Apr 2016 22:18:12 +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 1asHUi-0003xM-J8 for tpmdd-devel@lists.sourceforge.net; Mon, 18 Apr 2016 22:18:12 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.65 as permitted sender) client-ip=74.125.82.65; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f65.google.com; Received: from mail-wm0-f65.google.com ([74.125.82.65]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1asHUh-0001Y4-NT for tpmdd-devel@lists.sourceforge.net; Mon, 18 Apr 2016 22:18:12 +0000 Received: by mail-wm0-f65.google.com with SMTP id n3so287045wmn.1 for ; Mon, 18 Apr 2016 15:18:11 -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=I/k3LyuuIUOYus41FqreZ3accBcwZ1JsuwB2Hts8zgUyR97+/59Mwd8UWyzuglZcNm dXIFZD1bwtNawGRde5iquesGW9e88dkzhHY/lx312zO8Wfp1seX+T+k7fnFqyFBuTVtK MwEZTTq3MVQm2l1MlkC2kcezHkzTaxmiA+2+Gg1rlW7ma6KWQH8uUscPHaKgPPDGQEwP uXrNsZHImxjNaiZrtLkn+/hKjyNQXYi4blbowjnCTAWfMM+87YEz71lHhP53ziS85sLl 2RworJFtValqnI5yaQ0pagGkxj0AyLWCxuBwcXwBA5+5BPmMh4LmaFMey3nySbgDbUSi 55tQ== X-Gm-Message-State: AOPr4FUsTKtCqvavHPANAscEDLYT4Qydka+x5wy82+scGukyirGJ4Nt6/sbFdH3lFKb7vA== X-Received: by 10.28.26.73 with SMTP id a70mr102631wma.89.1461017885702; Mon, 18 Apr 2016 15:18:05 -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 i11sm66187860wjn.36.2016.04.18.15.18.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Apr 2016 15:18:04 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Tue, 19 Apr 2016 00:17:39 +0200 Message-Id: <1461017864-3903-8-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1461017864-3903-1-git-send-email-christophe-h.ricard@st.com> References: <1461017864-3903-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1asHUh-0001Y4-NT 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 v4 07/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)