From patchwork Mon Apr 18 22:17:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8875991 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 1D3BA9F441 for ; Mon, 18 Apr 2016 22:18:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42A8E201FA for ; Mon, 18 Apr 2016 22:18:23 +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 2EA0E201ED for ; Mon, 18 Apr 2016 22:18:22 +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 1asHUr-0007uY-18; Mon, 18 Apr 2016 22:18:21 +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 1asHUq-0007uT-DB for tpmdd-devel@lists.sourceforge.net; Mon, 18 Apr 2016 22:18:20 +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 1asHUp-0000LK-EI for tpmdd-devel@lists.sourceforge.net; Mon, 18 Apr 2016 22:18:20 +0000 Received: by mail-wm0-f66.google.com with SMTP id y144so295634wmd.0 for ; Mon, 18 Apr 2016 15:18:19 -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=d+fkyZon8ti2lpwjURlPSE7x5q5gHEeSZt1MGeYMufg=; b=cV1qA+SeLaHr4bww/QyXVWOAN+rqQHKZKS2Xwx51/DQiVh4RVZVISD4WmXq8GVxcxv 5a5uZpHs5CnVJF37FvYfsX0By3GQzD3D0o/gPOtrLRaFJ09s6nKLkk8xlhbBTcWlur1P UtFiP0x/M6huldZADOiotyuNvdPYCazP9X7GMOpbnn7dY1KfMxGq8H1/JwDlpG+GcFsW Cnjp8s1OishmQnIyPJVEfY6hjDc2AXOlCe/X+1ua3z6a70z97gttyAHPgyfoLUGl8rRN yh5mZT0D/cJoy2yG2QTU4RoYvyHb/LSpoKHzzOBzDV31fTeM5Aqt+hKIfUFepnzOr1qs /iqA== X-Gm-Message-State: AOPr4FUoCceQrtw1B9d6AE+Rc/j1piJVgX24UMC36gVRA5867GS4Tq36hfS9gcnNGrag4A== X-Received: by 10.194.103.198 with SMTP id fy6mr42819180wjb.48.1461017893477; Mon, 18 Apr 2016 15:18:13 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Apr 2016 15:18:12 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Tue, 19 Apr 2016 00:17:43 +0200 Message-Id: <1461017864-3903-12-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: 1asHUp-0000LK-EI 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 11/12] tpm: Use read/write_bytes for drivers without more specialized methods 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 Some drivers might need to implement only functions for transferring an arbitrary number of bytes. Provides a generic functions for handling of word or dword transfers to be dump into driver functions pointers. Signed-off-by: Alexander Steffen Signed-off-by: Christophe Ricard --- drivers/char/tpm/tpm_tis_core.c | 34 ++++++++++++++++++++++++++++++++++ drivers/char/tpm/tpm_tis_core.h | 4 ++++ 2 files changed, 38 insertions(+) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 09f7822..5933781 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -803,6 +803,40 @@ int tpm_tis_resume(struct device *dev) EXPORT_SYMBOL_GPL(tpm_tis_resume); #endif +int tpm_tis_common_read16(struct tpm_chip *chip, u32 addr, u16 *result) +{ + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); + int rc; + + rc = priv->phy_ops->read_bytes(chip, addr, sizeof(u16), (u8 *)result); + if (!rc) + *result = le16_to_cpu(*result); + return rc; +} +EXPORT_SYMBOL_GPL(tpm_tis_common_read16); + +int tpm_tis_common_read32(struct tpm_chip *chip, u32 addr, u32 *result) +{ + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); + int rc; + + rc = priv->phy_ops->read_bytes(chip, addr, sizeof(u32), (u8 *)result); + if (!rc) + *result = le32_to_cpu(*result); + return rc; +} +EXPORT_SYMBOL_GPL(tpm_tis_common_read32); + +int tpm_tis_common_write32(struct tpm_chip *chip, u32 addr, u32 value) +{ + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); + + value = cpu_to_le32(value); + return priv->phy_ops->write_bytes(chip, addr, sizeof(u32), + (u8 *)&value); +} +EXPORT_SYMBOL_GPL(tpm_tis_common_write32); + MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)"); MODULE_DESCRIPTION("TPM Driver"); MODULE_VERSION("2.0"); diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h index 157c5c3..6b82944 100644 --- a/drivers/char/tpm/tpm_tis_core.h +++ b/drivers/char/tpm/tpm_tis_core.h @@ -153,6 +153,10 @@ static inline int tpm_write32(struct tpm_chip *chip, u32 addr, u32 value) return priv->phy_ops->write32(chip, addr, value); } +int tpm_tis_common_read16(struct tpm_chip *chip, u32 addr, u16 *result); +int tpm_tis_common_read32(struct tpm_chip *chip, u32 addr, u32 *result); +int tpm_tis_common_write32(struct tpm_chip *chip, u32 addr, u32 value); + void tpm_tis_ready(struct tpm_chip *chip); void release_locality(struct tpm_chip *chip, int l, int force); int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len);