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: 611928 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 3qpjG10T6bz9snm for ; Tue, 19 Apr 2016 08:18:17 +1000 (AEST) 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-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 0.0 AWL AWL: Adjusted score from AWL reputation of From: address 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 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)