Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp616770rdb; Tue, 23 Jan 2024 09:18:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmjLsNwqcw4LHZe0QJLIozVFcqlcaDxiggWDdViJfmUngbvAqgutvhlQbUr48xnlHpSA5S X-Received: by 2002:a05:6a20:8410:b0:196:6d16:6db4 with SMTP id c16-20020a056a20841000b001966d166db4mr8252088pzd.53.1706030320809; Tue, 23 Jan 2024 09:18:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706030320; cv=pass; d=google.com; s=arc-20160816; b=ObUcUsfqp7rx7UnkJf4ahE3172LFj8YWa2970uDyaR+qcroxflITYk57vJN228nYMH 90sPmwdeYzca0rkgrGD3wzkLsglwnScWN+9O8LQxjnJEPH/IbxtsV+8u8vNKs1KyPXvS WRi4TjvaGyZf0A6b20bi5UNiko3qFiQjsQceNv6nGNGQkF/5kLd7I/9DYKwSM4thcCd8 OBrCSYZFKaXIQXBsS9g6TkglX80D8Ijn8o7XTXXnE13WZz/GQF3+unAOGJpairsNogqo lIL4GBaEvDTmDzkSlt6Cv0xQRhQ7omPVS0sBjXezzrK1cQpA2/6ESTsa79BW/Qvtly3t sljw== 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=Q+PZn0uSnXMyLTv5l3wL3wJzXqK46WUfq/ODn3JvIco=; fh=sWLzCHBGAMV8YmCmzANlKtNZ6o4a+v+Uz9J5hgSC3iE=; b=qrPL0OCHNX/nZgDuozejbDvg04PPB9osHnmKpgW2DeirRLjOMngD87qenNDyaTjsLm PMboPzETriQt0HNbacl5g/0k6+kufDjgFdGb+x3sEda4i8+vzqrHT0QVUn6q6NYzKfnd 6HaBnPVy4Q0zMEMB6Dgc85i8gKYAzHOkxw30Ht7PNWKBMjGIflm1O1aSp4MhKCHyztuQ 7ZjOypzpn5W12OoeZAkcROjPTl8312OBT7rRs3eol0NPx/jS8GbRR4ukWaoPJTjgZ/6U NkVsz5putxlh1+KTTparvQhgxkPqQcO7BnSlYG0kXmgsNIiXbaIq6EnePekeixVLX10q RMGQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="ezeJH/9I"; 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-kernel+bounces-35753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f8-20020a056a00228800b006dbdae29518si4624251pfe.150.2024.01.23.09.18.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 09:18:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="ezeJH/9I"; 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-kernel+bounces-35753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35753-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 04A6D28DA14 for ; Tue, 23 Jan 2024 17:09:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38AA7811FE; Tue, 23 Jan 2024 17:08:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="ezeJH/9I" 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 E31D37FBB1; Tue, 23 Jan 2024 17:08:22 +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=1706029706; cv=none; b=ltu1VQm7MVtpLhQVKzxeguO0HyV3eXTusIWD3T71Hg6laiUJ+MXmlhlZaTJTXxCp4X9CSVCAtvnLtKL/Rcica+iraAgzHRaEdKJYqGkqQMbpqwPxiA7P1Vug5lL7udlJneomKdxosDQVcrf6hHwg9rNdyZw4JFukpztmc7FxjK0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706029706; c=relaxed/simple; bh=xDXaPYdvjDzj9ikQqCRL1iEZKKMnUpAnYfcPwuRMRoE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KaHcs5eGWwG8zfXkGv6RWCP6IwZLxCL3r89iH5pepH356zTm0uRPLnSZW8xRNepxx2qM01XLt4ufDQTsAy7P8qrilFiR1GK5STcbsuUsXU1VpkxRfvxDQaNXbRCJqn2zV+I0tFvH9QizPhQHDEpJFfaCO6pCzA1gZY2T/jk478U= 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=ezeJH/9I; 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 8126910000A; Tue, 23 Jan 2024 19:58:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 8126910000A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1706029124; bh=Q+PZn0uSnXMyLTv5l3wL3wJzXqK46WUfq/ODn3JvIco=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ezeJH/9IwTRSkodqEhd1PzZ7Pg3JC+wE8guupW5VchkJQ5gF4uIkZZw+0rXLRMepD Ic8BGjOUV39t7ioIERQrKjcaEaJaAnP0TWlWuFX5OFCpgNsCm2jiEbagYsP/pwv8Xj N30NXIIyXDRZRvTjXSD0C1co9GfarsUfMocjhtrao27wcOqIBNbgvPJ+yEyF/Zipqg F8tJV4o43Q3y3QD4ZjJTJ0zvUy935nPh24eV+h1n4qC0TXvjmdR9a/Ti5Ua8uOkXQm At1HnICp6z70aGXpDmpAjiMtNifVT/eQX7wv/PS7RB34FuDl/7Z9x7edFyl96rj7DU 7MOHG8j9aJ/Sw== 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; Tue, 23 Jan 2024 19:58:44 +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; Tue, 23 Jan 2024 19:58:44 +0300 From: Alexey Romanov To: , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v2 03/20] drviers: crypto: meson: add platform data Date: Tue, 23 Jan 2024 19:58:14 +0300 Message-ID: <20240123165831.970023-4-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123165831.970023-1-avromanov@salutedevices.com> References: <20240123165831.970023-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-kernel@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: 182873 [Jan 23 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;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;smtp.sberdevices.ru:7.1.1,5.0.1;salutedevices.com:7.1.1, 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/01/23 13:53:00 #23383939 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 | 31 +++++++++++++++------ drivers/crypto/amlogic/amlogic-gxl.h | 11 ++++++++ 3 files changed, 35 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 a58644be76e9..2be381e157c4 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,34 @@ 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, + }, + {}, +}; + 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); @@ -312,12 +333,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