From patchwork Tue Sep 20 08:01:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Harliman Liem X-Patchwork-Id: 607761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 991A1ECAAD8 for ; Tue, 20 Sep 2022 08:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbiITIDR (ORCPT ); Tue, 20 Sep 2022 04:03:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230513AbiITIBv (ORCPT ); Tue, 20 Sep 2022 04:01:51 -0400 Received: from us-smtp-delivery-115.mimecast.com (us-smtp-delivery-115.mimecast.com [170.10.129.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9112642C4 for ; Tue, 20 Sep 2022 01:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maxlinear.com; s=selector; t=1663660909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pZCOZe3LJQX2wc3TOLjSwHgnPXH4/Vrg5ziu0+q0SZU=; b=lrH4gH5pHYEjlWISbas+8NCpezL+henDSbdSEdHE3BhjlBErgSz3ZvEopXgvOwHVVjpVF0 cKtCu2/WMf+HoOqs5qcYC+JwPv7urpqMgMM3TJq8vT4xawwdSm0Dl1PiXoa3sPUqoaAZi/ t8EVodx9oKvEV8oSgqDgQeVv/wSkC2iZ5GOIW8RIX+2T5BoOUYb3stjGXvnUyYqyRU8JUp 1Z9CLHqBuvINgs4IupbWxLwlBm6hT4mGY65MUZqlU6x4fd0VQHyQ0diJdHC6cR6Gv1hJ/F n4jAZTiXb00i/F35AVLDuXrksD+s3sKOJZFiBa7N+J8pnuchR2xZBzNx76HAjg== Received: from mail.maxlinear.com (174-47-1-84.static.ctl.one [174.47.1.84]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id us-mta-235-INmaW5GAOMSQsX9AhldYzA-2; Tue, 20 Sep 2022 04:01:47 -0400 X-MC-Unique: INmaW5GAOMSQsX9AhldYzA-2 Received: from sgsxdev002.isng.phoenix.local (10.226.81.112) by mail.maxlinear.com (10.23.38.119) with Microsoft SMTP Server id 15.1.2375.24; Tue, 20 Sep 2022 01:01:42 -0700 From: Peter Harliman Liem To: , CC: , , "Peter Harliman Liem" Subject: [PATCH 1/3] crypto: inside-secure - Expand soc data structure Date: Tue, 20 Sep 2022 16:01:37 +0800 Message-ID: <131f0d802d4e251dd8f98672260a04c2f649440c.1663660578.git.pliem@maxlinear.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: maxlinear.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Currently platform data is assigned directly to version string(instead of struct). To make it more scalable, we move it to use data struct instead. This allows customization for individual platforms other than version string. Signed-off-by: Peter Harliman Liem --- drivers/crypto/inside-secure/safexcel.c | 49 +++++++++++++++++-------- drivers/crypto/inside-secure/safexcel.h | 6 ++- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c index ad0d8c4a71ac..02c103da09a9 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c @@ -410,20 +410,25 @@ static int eip197_load_firmwares(struct safexcel_crypto_priv *priv) int i, j, ret = 0, pe; int ipuesz, ifppsz, minifw = 0; - if (priv->version == EIP197D_MRVL) - dir = "eip197d"; - else if (priv->version == EIP197B_MRVL || - priv->version == EIP197_DEVBRD) + switch (priv->data->version) { + case EIP197_DEVBRD: + case EIP197B_MRVL: dir = "eip197b"; - else - return -ENODEV; + break; + case EIP197D_MRVL: + dir = "eip197d"; + break; + default: + /* generic case */ + dir = ""; + } retry_fw: for (i = 0; i < FW_NB; i++) { snprintf(fw_path, 37, "inside-secure/%s/%s", dir, fw_name[i]); ret = firmware_request_nowarn(&fw[i], fw_path, priv->dev); if (ret) { - if (minifw || priv->version != EIP197B_MRVL) + if (minifw || priv->data->version != EIP197B_MRVL) goto release_fw; /* Fallback to the old firmware location for the @@ -1597,7 +1602,7 @@ static int safexcel_probe_generic(void *pdev, safexcel_configure(priv); - if (IS_ENABLED(CONFIG_PCI) && priv->version == EIP197_DEVBRD) { + if (IS_ENABLED(CONFIG_PCI) && priv->data->version == EIP197_DEVBRD) { /* * Request MSI vectors for global + 1 per ring - * or just 1 for older dev images @@ -1731,7 +1736,7 @@ static int safexcel_probe(struct platform_device *pdev) return -ENOMEM; priv->dev = dev; - priv->version = (enum safexcel_eip_version)of_device_get_match_data(dev); + priv->data = (struct safexcel_of_data *)of_device_get_match_data(dev); platform_set_drvdata(pdev, priv); @@ -1806,27 +1811,39 @@ static int safexcel_remove(struct platform_device *pdev) return 0; } +static const struct safexcel_of_data eip97ies_mrvl_data = { + .version = EIP97IES_MRVL, +}; + +static const struct safexcel_of_data eip197b_mrvl_data = { + .version = EIP197B_MRVL, +}; + +static const struct safexcel_of_data eip197d_mrvl_data = { + .version = EIP197D_MRVL, +}; + static const struct of_device_id safexcel_of_match_table[] = { { .compatible = "inside-secure,safexcel-eip97ies", - .data = (void *)EIP97IES_MRVL, + .data = &eip97ies_mrvl_data, }, { .compatible = "inside-secure,safexcel-eip197b", - .data = (void *)EIP197B_MRVL, + .data = &eip197b_mrvl_data, }, { .compatible = "inside-secure,safexcel-eip197d", - .data = (void *)EIP197D_MRVL, + .data = &eip197d_mrvl_data, }, /* For backward compatibility and intended for generic use */ { .compatible = "inside-secure,safexcel-eip97", - .data = (void *)EIP97IES_MRVL, + .data = &eip97ies_mrvl_data, }, { .compatible = "inside-secure,safexcel-eip197", - .data = (void *)EIP197B_MRVL, + .data = &eip197b_mrvl_data, }, {}, }; @@ -1862,7 +1879,7 @@ static int safexcel_pci_probe(struct pci_dev *pdev, return -ENOMEM; priv->dev = dev; - priv->version = (enum safexcel_eip_version)ent->driver_data; + priv->data = (struct safexcel_of_data *)ent->driver_data; pci_set_drvdata(pdev, priv); @@ -1881,7 +1898,7 @@ static int safexcel_pci_probe(struct pci_dev *pdev, } priv->base = pcim_iomap_table(pdev)[0]; - if (priv->version == EIP197_DEVBRD) { + if (priv->data->version == EIP197_DEVBRD) { dev_dbg(dev, "Device identified as FPGA based development board - applying HW reset\n"); rc = pcim_iomap_regions(pdev, 4, "crypto_safexcel"); diff --git a/drivers/crypto/inside-secure/safexcel.h b/drivers/crypto/inside-secure/safexcel.h index 797ff91512e0..1b8ccb33202b 100644 --- a/drivers/crypto/inside-secure/safexcel.h +++ b/drivers/crypto/inside-secure/safexcel.h @@ -733,6 +733,10 @@ enum safexcel_eip_version { EIP197_DEVBRD }; +struct safexcel_of_data { + enum safexcel_eip_version version; +}; + /* Priority we use for advertising our algorithms */ #define SAFEXCEL_CRA_PRIORITY 300 @@ -815,7 +819,7 @@ struct safexcel_crypto_priv { struct clk *reg_clk; struct safexcel_config config; - enum safexcel_eip_version version; + struct safexcel_of_data *data; struct safexcel_register_offsets offsets; struct safexcel_hwconfig hwconfig; u32 flags; From patchwork Tue Sep 20 08:01:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Harliman Liem X-Patchwork-Id: 608036 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D842C54EE9 for ; Tue, 20 Sep 2022 08:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230490AbiITIDQ (ORCPT ); Tue, 20 Sep 2022 04:03:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230515AbiITIBv (ORCPT ); Tue, 20 Sep 2022 04:01:51 -0400 Received: from us-smtp-delivery-115.mimecast.com (us-smtp-delivery-115.mimecast.com [170.10.129.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7146642C2 for ; Tue, 20 Sep 2022 01:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maxlinear.com; s=selector; t=1663660909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UBElztSxJ1rdBS50z2Hh+xljndSP253b3OPRrTnscxQ=; b=ByzcBrxRaf8bYEPI7zE7VITvzf/7AzLipeLGJfeP8P56neBdKN3xd38PtTRGqm6I/lBOuA GHNvkGmgmm11Yc2gvvYDskTs1m+J2f0/FxgWt4EutXOznSD/XcN9vC95cMj8cO2u1r6vKD bf5akZXfPfmksV0VFimHSiYQNHrXvthbcFnooEc/eGsPKW1AOWzKcJTFo3IVWyw0gg/NnD 9lMkdpLkJgvMglYCeG+PhIohgg0FTNZ4aWMf+nUk0453Hh1BSbWun4Dg3j+f4+n8X3x5o6 FcLfk+/J4Qpung2wifqhe3xBcaU69OUeqvnVI7FWx3T2kT4ovKI4BgtxBa987w== Received: from mail.maxlinear.com (174-47-1-84.static.ctl.one [174.47.1.84]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id us-mta-235-nEWdcjjDOR-NiH6cM9J8hQ-3; Tue, 20 Sep 2022 04:01:48 -0400 X-MC-Unique: nEWdcjjDOR-NiH6cM9J8hQ-3 Received: from sgsxdev002.isng.phoenix.local (10.226.81.112) by mail.maxlinear.com (10.23.38.119) with Microsoft SMTP Server id 15.1.2375.24; Tue, 20 Sep 2022 01:01:44 -0700 From: Peter Harliman Liem To: , CC: , , "Peter Harliman Liem" Subject: [PATCH 2/3] crypto: inside-secure - Add fw_little_endian option Date: Tue, 20 Sep 2022 16:01:38 +0800 Message-ID: <29cf210c9adce088bc50248ad46255d883bd5edc.1663660578.git.pliem@maxlinear.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: maxlinear.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This is to add fw_little_endian option, which can be used for platform which firmware is using little-endian (instead of big-endian). Signed-off-by: Peter Harliman Liem --- drivers/crypto/inside-secure/safexcel.c | 15 +++++++++++---- drivers/crypto/inside-secure/safexcel.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c index 02c103da09a9..955170d2dd7c 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c @@ -316,14 +316,21 @@ static void eip197_init_firmware(struct safexcel_crypto_priv *priv) static int eip197_write_firmware(struct safexcel_crypto_priv *priv, const struct firmware *fw) { - const __be32 *data = (const __be32 *)fw->data; + const u32 *data = (const u32 *)fw->data; + u32 val; int i; /* Write the firmware */ - for (i = 0; i < fw->size / sizeof(u32); i++) - writel(be32_to_cpu(data[i]), + for (i = 0; i < fw->size / sizeof(u32); i++) { + if (priv->data->fw_little_endian) + val = le32_to_cpu(data[i]); + else + val = be32_to_cpu(data[i]); + + writel(val, priv->base + EIP197_CLASSIFICATION_RAMS + - i * sizeof(__be32)); + i * sizeof(*data)); + } /* Exclude final 2 NOPs from size */ return i - EIP197_FW_TERMINAL_NOPS; diff --git a/drivers/crypto/inside-secure/safexcel.h b/drivers/crypto/inside-secure/safexcel.h index 1b8ccb33202b..a89dd8dc1ddd 100644 --- a/drivers/crypto/inside-secure/safexcel.h +++ b/drivers/crypto/inside-secure/safexcel.h @@ -735,6 +735,7 @@ enum safexcel_eip_version { struct safexcel_of_data { enum safexcel_eip_version version; + bool fw_little_endian; }; /* Priority we use for advertising our algorithms */ From patchwork Tue Sep 20 08:01:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Harliman Liem X-Patchwork-Id: 607760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6896BC6FA92 for ; Tue, 20 Sep 2022 08:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbiITIDV (ORCPT ); Tue, 20 Sep 2022 04:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230522AbiITIBy (ORCPT ); Tue, 20 Sep 2022 04:01:54 -0400 Received: from us-smtp-delivery-115.mimecast.com (us-smtp-delivery-115.mimecast.com [170.10.129.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D68A642C8 for ; Tue, 20 Sep 2022 01:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maxlinear.com; s=selector; t=1663660910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ouPEC3kvQ0ao0uh8YN4F3GFPf1No8spzAha5/ht5RO0=; b=HGTNXCJK11DAo+e0DUnVri9yf1s6tjip0JyFT7ezYNqkCfQsr9P1hmsmJ119soMBDi7NQU kbeFulUmlS5ZQqMKQNcLl0rxzfcvFC//Ld3iUh0nPFFa58kKitIOr6M4Rc+O922yq2sV0a noa0EeV3F548Zytt1Ux+PCeahc5lx5DGWc7vqTgXbaHJ2EzVxg2fn/T6rxMVCIbQhzBAR2 8fPlYMLFqEzhe0byacCXeSqR/B1ObK+woQdgQqHcjZt8Fe6YaPkvb6vlXn+94HnHb8UJNm uvryYkSDEknLgv1Bx5Fnw1srKfCJnOGSoMriKWbrqbICcRbrfsm/XKaKp9LmXA== Received: from mail.maxlinear.com (174-47-1-84.static.ctl.one [174.47.1.84]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id us-mta-235-qkySXk_lNHylBziHljehCg-4; Tue, 20 Sep 2022 04:01:49 -0400 X-MC-Unique: qkySXk_lNHylBziHljehCg-4 Received: from sgsxdev002.isng.phoenix.local (10.226.81.112) by mail.maxlinear.com (10.23.38.119) with Microsoft SMTP Server id 15.1.2375.24; Tue, 20 Sep 2022 01:01:45 -0700 From: Peter Harliman Liem To: , CC: , , "Peter Harliman Liem" Subject: [PATCH 3/3] crypto: inside-secure - Add MaxLinear platform Date: Tue, 20 Sep 2022 16:01:39 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: maxlinear.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This is to add MaxLinear platform into compatible id. Firmware endianness option is added since MaxLinear firmware is in little endian format. Signed-off-by: Peter Harliman Liem --- drivers/crypto/inside-secure/safexcel.c | 9 +++++++++ drivers/crypto/inside-secure/safexcel.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c index 955170d2dd7c..4b7c18db290c 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c @@ -1830,6 +1830,11 @@ static const struct safexcel_of_data eip197d_mrvl_data = { .version = EIP197D_MRVL, }; +static const struct safexcel_of_data eip197_mxl_data = { + .version = EIP197_MXL, + .fw_little_endian = true, +}; + static const struct of_device_id safexcel_of_match_table[] = { { .compatible = "inside-secure,safexcel-eip97ies", @@ -1843,6 +1848,10 @@ static const struct of_device_id safexcel_of_match_table[] = { .compatible = "inside-secure,safexcel-eip197d", .data = &eip197d_mrvl_data, }, + { + .compatible = "inside-secure,safexcel-eip197-mxl", + .data = &eip197_mxl_data, + }, /* For backward compatibility and intended for generic use */ { .compatible = "inside-secure,safexcel-eip97", diff --git a/drivers/crypto/inside-secure/safexcel.h b/drivers/crypto/inside-secure/safexcel.h index a89dd8dc1ddd..078dbfb2b094 100644 --- a/drivers/crypto/inside-secure/safexcel.h +++ b/drivers/crypto/inside-secure/safexcel.h @@ -730,7 +730,8 @@ enum safexcel_eip_version { EIP97IES_MRVL, EIP197B_MRVL, EIP197D_MRVL, - EIP197_DEVBRD + EIP197_DEVBRD, + EIP197_MXL, }; struct safexcel_of_data {