Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2462522rdb; Mon, 12 Feb 2024 05:57:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU3qcDYNUZviqPQDZP+sRs1f7PYNKEdlEbUS/nmrC2uyRXBnN9dopc77EavBBOXqouE0C3IuLf2aM6927+J0oq5qIcZ1U1uNEz7pCLByw== X-Google-Smtp-Source: AGHT+IE7qaigMKjVqPgQl63mjF6gp5oLOjjkmlth9q/cYDLCU3pxaBtBnVGl3U2fuSkeJNsQLjc0 X-Received: by 2002:ac8:5891:0:b0:42c:6b3d:dba with SMTP id t17-20020ac85891000000b0042c6b3d0dbamr6160152qta.9.1707746245561; Mon, 12 Feb 2024 05:57:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707746245; cv=pass; d=google.com; s=arc-20160816; b=arXHN72TeCA085ocbw5cD7oMY6ksac4kPfKvxvLh9Tc9zrZeH4IVQB31fwncIeE8aO RZu7G22rq/OlA7Xj2L5whnwrprqYrQrh/fAORXxJ+k6VungPUqeH09Ks3fCdRhKGvWNZ EdVR3x3abpkihFneWdyJ3YJMvKU0CpkcgMGyGP+WoU7cCNWlgWkW34zv+s8neSRL/HE9 0yCSH3tQeTLxtw0bn3rYaqujPkwTk+wHU9ok21kTcSUraqfVIJOxlTBJNH8iWx5SQwPA pK3O2rjkS6LE6vN4DTBssW3AHxNqA3dkBg3wGBfqDInEu4w3tEDw7bdiaxHsZ25CFDpL X4dQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=Kggh0mx1qq/xwtSS+ahNNuEm9ZI5KGYt1FdkI7ZDCCI=; fh=M3O3xsaUAUqaMR5AlvuWx6ktMI2+RL+SZzH4S8D2o/w=; b=NJUEcwJc6fCY+OLjmSMYg1zNkkD8sNS7cB2X4Ehj2s6wvUjljCnINkAqrl63WTps4n bRs9Fk9NMNJdVtEqPWxj3USbdoywL34WQln13ctjEHunTWd2XG0DD7gSHR8eCKSPq2KT SkXAaaNwjRsi047z7ESIWDj2JP1pJSZfhLSGG7Nt/cxyB1OYumin1x8mKWZnTPjizKPm p1GZmz6gSQA08DEyMu+/pG3GHBytmPMQUBrNtlJLVdFD21NCyVZmakSVEe6iTyrxwqeH Mg7tkMT5JBjulbpIETvpiuozrgrAWTI5eETNghIpoUJFOTmFFn/8enY9ARUpAumiFt5n 3zHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=oIVsPLKd; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-crypto+bounces-1965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com X-Forwarded-Encrypted: i=2; AJvYcCX8TbX3LaAVwFlgUA5O9Nz8U1GTEZttMntK2ZYCdx7wstWIyq1xIjswmN0ODUGOKGosYLlyeN4XQY3lTCN0ADKXkpX0A1lPAMK76dcaQQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t3-20020a05622a148300b0042c4e4c4f62si436844qtx.797.2024.02.12.05.57.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:57:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=oIVsPLKd; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-crypto+bounces-1965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 31A981C235AE for ; Mon, 12 Feb 2024 13:57:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 756A03B194; Mon, 12 Feb 2024 13:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="oIVsPLKd" X-Original-To: linux-crypto@vger.kernel.org Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AA613A8CA; Mon, 12 Feb 2024 13:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707745895; cv=none; b=kKE8XJiXB2hOy9vOtyVXNlFdVhF2KzkoKmolkJxtMVf35WNu7wwbZeJw+gdot31tU2qUPm0fcRzGhASyUkUdMBlsfnZ10EXpX01Q90kbiZ2NPlqCdJu4telnPf7/Jec9M9YLabU3l+V9F8utv8h2vlWVbIPDqpjNIIVHZT1o3iU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707745895; c=relaxed/simple; bh=bR8br+Tqjcysy5ILarsJGbafjXWsDhsUD6VrlwYJ5p0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lr++QftSNL1V+gawQJig7C1+MeDkVyMEGw9qY14AA6fuRHCkanKX2FufsegTCwcWjeSSC3ZmYWNcWnNAi0v3+QIrbkT1aauk8IDGAE7nUwrSM3rMcOAkwNC91bE0BMVrvTfM4laE27Yoo6/Q2yfQMc2aZOrVZx3NaSRqvQYuahc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=salutedevices.com; spf=pass smtp.mailfrom=salutedevices.com; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b=oIVsPLKd; arc=none smtp.client-ip=37.18.73.165 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 2E933100015; Mon, 12 Feb 2024 16:51:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 2E933100015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1707745889; bh=Kggh0mx1qq/xwtSS+ahNNuEm9ZI5KGYt1FdkI7ZDCCI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=oIVsPLKdKPnRBbobAAuq9ytwTycpqAewvPSLgyeQaXLOJ3Mk8uzR30tO5y+WnNjw7 p3BhtompWOlWvJFI7Uo9/12MK68zXZ5ZA5jn41vLKgJSl/IfLbJ5eyazvhr9wo7YYF iwSxl6KfgvmxSw6UN+ItSgYI4TrOsa6BeBLbYtXV/B8u+TNXqO/CAjnwilIZk8i3eW mC3y7f4Ch47lJIeQN3kYiBOMEL5xj6HEVs+Hc+thNIzuPtGMfIHGsb+Qo84bjfDZgw SfgafoQUmCfSKxc40SO5tNvjWIou0XFqACqQPt6Y1i9qpu1+ikmQq0o/L+vXNLWm0s g/sirP98ijHiw== Received: from smtp.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Mon, 12 Feb 2024 16:51:29 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 12 Feb 2024 16:51:28 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v4 02/20] drviers: crypto: meson: add platform data Date: Mon, 12 Feb 2024 16:50:50 +0300 Message-ID: <20240212135108.549755-3-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240212135108.549755-1-avromanov@salutedevices.com> References: <20240212135108.549755-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 183368 [Feb 12 2024] X-KSMG-AntiSpam-Version: 6.1.0.3 X-KSMG-AntiSpam-Envelope-From: avromanov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_from_domain_doesnt_match_to}, 100.64.160.123:7.1.2;smtp.sberdevices.ru:7.1.1,5.0.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;salutedevices.com:7.1.1;127.0.0.199:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/02/12 07:49:00 #23556813 X-KSMG-AntiVirus-Status: Clean, skipped To support other Amlogic SoC's we have to use platform data: descriptors and status registers offsets are individual for each SoC series. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 2 +- drivers/crypto/amlogic/amlogic-gxl-core.c | 32 +++++++++++++++------ drivers/crypto/amlogic/amlogic-gxl.h | 11 +++++++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index b19032f92415..7eff3ae7356f 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -225,7 +225,7 @@ static int meson_cipher(struct skcipher_request *areq) reinit_completion(&mc->chanlist[flow].complete); mc->chanlist[flow].status = 0; - writel(mc->chanlist[flow].t_phy | 2, mc->base + (flow << 2)); + writel(mc->chanlist[flow].t_phy | 2, mc->base + ((mc->pdata->descs_reg + flow) << 2)); wait_for_completion_interruptible_timeout(&mc->chanlist[flow].complete, msecs_to_jiffies(500)); if (mc->chanlist[flow].status == 0) { diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 35ec64df5b3a..4d1b1d5b7a54 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "amlogic-gxl.h" @@ -30,9 +31,10 @@ static irqreturn_t meson_irq_handler(int irq, void *data) for (flow = 0; flow < mc->flow_cnt; flow++) { if (mc->chanlist[flow].irq == irq) { - p = readl(mc->base + ((0x04 + flow) << 2)); + p = readl(mc->base + ((mc->pdata->status_reg + flow) << 2)); if (p) { - writel_relaxed(0xF, mc->base + ((0x4 + flow) << 2)); + writel_relaxed(0xF, mc->base + + ((mc->pdata->status_reg + flow) << 2)); mc->chanlist[flow].status = 1; complete(&mc->chanlist[flow].complete); return IRQ_HANDLED; @@ -245,15 +247,35 @@ static void meson_unregister_algs(struct meson_dev *mc) } } +static const struct meson_pdata meson_gxl_pdata = { + .descs_reg = 0x0, + .status_reg = 0x4, +}; + +static const struct of_device_id meson_crypto_of_match_table[] = { + { + .compatible = "amlogic,gxl-crypto", + .data = &meson_gxl_pdata, + }, + {}, +}; +MODULE_DEVICE_TABLE(of, meson_crypto_of_match_table); + static int meson_crypto_probe(struct platform_device *pdev) { + const struct of_device_id *match; struct meson_dev *mc; int err; + match = of_match_device(meson_crypto_of_match_table, &pdev->dev); + if (!match) + return -EINVAL; + mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL); if (!mc) return -ENOMEM; + mc->pdata = match->data; mc->dev = &pdev->dev; platform_set_drvdata(pdev, mc); @@ -319,12 +341,6 @@ static void meson_crypto_remove(struct platform_device *pdev) clk_disable_unprepare(mc->busclk); } -static const struct of_device_id meson_crypto_of_match_table[] = { - { .compatible = "amlogic,gxl-crypto", }, - {} -}; -MODULE_DEVICE_TABLE(of, meson_crypto_of_match_table); - static struct platform_driver meson_crypto_driver = { .probe = meson_crypto_probe, .remove_new = meson_crypto_remove, diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 79177cfa8b88..9ad75da214ff 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -78,6 +78,16 @@ struct meson_flow { #endif }; +/* + * struct meson_pdata - SoC series dependent data. + * @reg_descs: offset to descriptors register + * @reg_status: offset to status register + */ +struct meson_pdata { + u32 descs_reg; + u32 status_reg; +}; + /* * struct meson_dev - main container for all this driver information * @base: base address of amlogic-crypto @@ -93,6 +103,7 @@ struct meson_dev { void __iomem *base; struct clk *busclk; struct device *dev; + const struct meson_pdata *pdata; struct meson_flow *chanlist; atomic_t flow; int flow_cnt; -- 2.34.1