From patchwork Tue Nov 19 13:07:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 13879861 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2084.outbound.protection.outlook.com [40.107.22.84]) (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 BD2061C2454 for ; Tue, 19 Nov 2024 13:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732021591; cv=fail; b=qqefMeckgqq5cMN/qPH7DFnSOCtqkWX+EsC+Sf8+cUWIepXo50JjJZUISnYo6CnOvyXpV/7MtTe/KdgeijZOEQn22JYv8H/rZXddqJyCuvR0HNP2nf1lmY6JrqB5w8YRvVkuFZYoG1qNWw3E/xrPyxJq02wGYF/ZmgQSxLuUpkc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732021591; c=relaxed/simple; bh=9n1l4mlV+/2Yi9zZ4MJH0v6ah7sH8HmBSRJG0J1sczc=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=Tmx87pG9b4EHy6eOAqFOKFxrJpgFjoN4aCSkJxDsBJ8vaeFFbpT7AADGpOwi++N50Jhp/5XhIIIo5KW+NjruhvbDZ7Vi4VuYddQ8b60GuwT4fJtZ3DLUJ2vrPEbGuP3cYPg1obtr3Fvoedm2rZnD/5mVISwJOiUPm8ngB0OjdvY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=lx40ZW3e; arc=fail smtp.client-ip=40.107.22.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="lx40ZW3e" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pA49WGpKLMQljpAI1BiTNAqz5gqxGeLvEJXGysJEEf0ezt1zJM3PSk6PywN8f9uESKTGLvHQSbC14taU6h3rvddoGnSEA2V/OElTUC0pTh7cVIe6+JpSETRLJFjiGyfPrbX3DgYwHsc7Dup8h4Ye3bhrE8j0QujOA3k6f1v35wP/xIP+k3VVdxEYvzamYOSlQ6/gE3YwxOVtqJcbtx1A6vgJQz/eOeJXxtFrRv+rsaAo2Ow1y5U9/H+WsCaHBUo2B+d71L8OSGWJghBATzOl8yD8mBqCXAfGvmn2S5U24OJooTXi55CWMTUy5ld3lBDxMURxSRBui1jINPWmVg0hFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1oDz3vJb62xJD0+rLWqFj6vddTBOSGL4WKjZfCy4h+A=; b=Tle29o1xBfL5bkXJFyzl3baRO755EIZPmw38yBBninho8pTVJBMTqwLLvufXi+rg1WD746PQDU31Q5Q/oPEvzwDZeZH0dPxGK4kpkGubrQ8J21MZq4zSECR6ypqK0pAj/w32gZweQyTnq9rDMVGi0iMsTj6SuWGQYJxTSCOehB2aP99wIBjjG7q5NTbavlI5QtcaZpB8HVIPnUVJkPzXDAKvHkdhPZdJ6I+H1RMc8gmz5sKWZ10cwRCIneHjvUaQG28GogAGmf8XoOg6zOnqdR+gfzOzCYuR1Nd0BiaZHsujXJWRY4/DCfpbC6Dai1I58sKHcAcfuVJ+iVSnzdozxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1oDz3vJb62xJD0+rLWqFj6vddTBOSGL4WKjZfCy4h+A=; b=lx40ZW3eDUwYVP+vbrZGzVc6KPMBiQFdfzreJUt566/Kvs5BIMN/hNVSE9+a1PoIog9YCtuy3sIM/1XGSujGN3hQcCSeAS85I6a8mpNEezWotrTa4uXDN8RcSM0OSMkPeR8bs35HLFp1Z64S3SG9COmftSfOrJCQgPCPqh3IH4N4x+/66Qi8mPinOc3Puv6TcxBNcd5hJs89Qnf2BHhx4pKuxzVfSOGIvdRsOSGY5fvOXRtD1f6p7KuaQk2JyjZl1S4/ympC1MPr5GB23fPVhpm57BwUY18dEoqB8AEaosbnswlj8DBo2amN46P7NRmlGUCU1gydwzeCPRy97RB0MQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8247.eurprd04.prod.outlook.com (2603:10a6:20b:3f2::13) by AM8PR04MB7284.eurprd04.prod.outlook.com (2603:10a6:20b:1dc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 13:06:25 +0000 Received: from AS8PR04MB8247.eurprd04.prod.outlook.com ([fe80::84f7:e2c3:ceed:c0a6]) by AS8PR04MB8247.eurprd04.prod.outlook.com ([fe80::84f7:e2c3:ceed:c0a6%4]) with mapi id 15.20.8158.023; Tue, 19 Nov 2024 13:06:24 +0000 From: Daniel Baluta To: conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, imx@lists.linux.dev Cc: robh@kernel.org, krzk+dt@kernel.org, kernel@pengutronix.de, daniel.baluta@gmail.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, aisheng.dong@nxp.com, peng.fan@nxp.com, iuliana.prodan@nxp.com, laurentiu.mihalcea@nxp.com, shengjiu.wang@nxp.com, Daniel Baluta Subject: [RFC PATCH] soc: imx: Add AHB to IP Bridge configuration driver Date: Tue, 19 Nov 2024 15:07:26 +0200 Message-ID: <20241119130726.2761726-1-daniel.baluta@nxp.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: AS4P195CA0025.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5d6::20) To AS8PR04MB8247.eurprd04.prod.outlook.com (2603:10a6:20b:3f2::13) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8247:EE_|AM8PR04MB7284:EE_ X-MS-Office365-Filtering-Correlation-Id: 41c052d7-9873-4f49-6fdc-08dd089af830 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|7416014|38350700014; X-Microsoft-Antispam-Message-Info: 7UQ7XFMP6/SXWFAkcy1XYt+GLRX+vJmASw+2KMiCA4LeV5M9SuZNYdKXMlv92Q5e+IhqkM8CVRIc+/ZOejQdFM5kY3Rrjo9gaEOph/jTOT3Et5gjjPo89h2I24gfb/6AjjeLu7WGbYUWTrnlZssJMRzz5mDwq0w15T0I0Ru+LusZ65gDM5F6PE5U9wQRgTyhv/n/S2nrDAmFlGNnjKumCRpWTROqI/LWI5THhiwp1IHSBHp3nj+dpPIE3ROHhiFrewFozkzI1I/MLyikoUbgAG/YAe6dc9/EmRvdk3ge80VZhJqyL525GbjoUgDvsJ+/VN8/n9pR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P:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8247.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /RB+UETIxtH9XD/lG2OgXfFaTxktwjtuYiwhB/UDEVJs/7o9o9Z9wwswz3uxp4HAouKreyOhPocodHB++WGyAxBL+bgCfk/K8H1dzI4C8ESEVpYwilVQ1oE6SI6fJiyFQ80tFBFY7YWcz7eAh6Wwt+ZKXHzUK8XdmLb+Jswtra6bTV+KLc0qCh+O95onhLT1o4+ddMWwdqSDiZu3yI0VBpD+ROLHNZLyyR7xtnaUQU6JAW8BSqgUicrbanvFaMSeQ44SOKe0prttLUfDXjHaDlnbv7YyEUSiS3t8+1GNxMqPzeqKr2nKUJelPxHW7fSLz5aNVQEBenXJRmXvitxfu3aZedysUKfsjTVssFrxKjImzqSvnTGvNSiojxEDoWUpK9QW5qh/B6ADdMdG945IGmCsfipoG6bfnz63o15bP0GOe0aRmSbTPCRgOrBZxXZUYMsm/ykc3+4jzN14nIANQECi0NFDH5elcrGX/ansOqTyC6VQj5GFEgN48+OJF9zxoRH0FlsSC4luXmbYEabUGnfi+AM2kzUOWFWjHIcvziXY73pVLOGB48IiVEjw4tfC3JGB1BBIumT5OqAvfd8a72VRJSql8seWjLyMRphpxc4tQnEk+GrOwOaVdU6W+MaPR0uRuItyFTMgGwv8mbknv1G8DUi6S0TCR9osnBgb37dnqQu7mHQnxvInuiA3qG+9wTTep9dNnXdCIuAWav0yEncP7H3X9O+pwNfNzv80hHF5BZCXprIgvzzpvsAERcVbW5WQ1MARSpy4lZtJV+YKDWjp5n1AdQl7NUwMm7IWQ736ofeikYiwZGFVA+sqXAUf6lu/VJxAdIRtPIM/Bwvx3mdbmhdYBPc5ICyQyJgr7rgPWyfPPuiK+aO/XrZxB8NwcP3fGz09vte5/2YcJ3/zlRsuNfYxQ6Hq+DbfAEQZqwVV8noJeQVR/ODn716jVDSyqYauB0gk7LcRVfsMR0ZPaHd1QsoPxPns1lPQ9/M0S7AZZO3nWKwRDQ1po2NvL/xroett9mmMopKLaVfSk2rHZahEx5kSTi+16lND5IAHaveoUNVxuZ6qx/q2wJUNMFczM6tNuCXRGJKNf8TUWaImbufpiKPMl4YHUj9feJww71zav2Nob7mGQtwGPMq/5KccwFP8NfdmRRT+eEto5FI/EX4gHSns4FLbdckztHVXGdR6BMUjJvqjXxtZe4GIjvsNvRRwaZAgEMwCxDBmi87Cdf5e6BZwBBIGoVxlgcco9U/YwiXQDlpeTarwSXiYRiR938dOfH8WDlOBGhlBgLDgoiTE7wGNCNUI5gPh3yHQaxVCuxt53zzZNNCFu8WntW81kObPa4WATz9r0z0xyf53yDcC3+I4ODrO3h7K0kC5UHc+uZ+z1a+4uAtPJ83dequh9nDtU/GQEwTjHShrUlswtnDyeHqy4hY4UfyzriH1BxOj67ESfRQZf0rSCKPUcKbhKlN7DMpZCMP8wcb0TXME2IHrLg8wFzSjvorPwq61BmrPVqo/T6x1VWT7VaGEj8p+HO49ig7JMa4EBibIezj6BcPDKuGXuE5+yKbwvAWWVELUpmYp4DAgtA3C76e6Krto X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41c052d7-9873-4f49-6fdc-08dd089af830 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8247.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 13:06:24.0644 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J581ZOHHKYXqq43+ChvA5THjZtuPGk0NBdem47Zd8oszLVdKHHeiojU4k2R1SrEKX43lBe+YOG57FxQWKHR30w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7284 This is a RFC patch in order to allow AHB to IP Bridge (AIPSTZ) configuration to be restored after a suspend/resume operation. This is particularly useful for aips5 bus where the aipstz configuration is lost at suspend. In order to configure aipstz bridge we register a platform driver that will set default configuration permission at probe. Because AIPS configuration is lost at suspend/resume time we register a power notifier callback that will take care of re-initializing the configuration at resume. More details about AHB to IP Bridge: This peripheral is designated as the bridge between AHB bus and peripherals with the lower bandwidth IP Slave (IPS) buses. The bridge is responsible for indicating to IPS peripherals if an access is in supervisor or user mode. It may block user mode accesses to certain IPS peripherals or it may allow the individual IPS peripherals to determine if user mode accesses are allowed. The bridge supports the notion of "trusted" masters for security purposes. Masters may be individually designated as trusted for reads, writes or both. Even more details (including register description) can be found in Chapter 4.7 AHB to IP Bridge (AIPSTZ) of i.MX8M Plus Application Processor Reference Manual. Signed-off-by: Daniel Baluta --- This RFC patch is to get your opinion on the direction on how should we proceed with handling configuration registers for this kind of device. It registers itself as a platform driver at boot time and then is probed once the dts node is discovered. TBD: - device tree binding file - enhance error checking - is this the correct way to handle this kind of "peripheral". arch/arm64/boot/dts/freescale/imx8mp.dtsi | 7 ++ drivers/soc/imx/aipstz.c | 114 ++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 drivers/soc/imx/aipstz.c diff --git a/arch/arm64/boot/dts/freescale/imx8mp.dtsi b/arch/arm64/boot/dts/freescale/imx8mp.dtsi index e0d3b8cba221..7775f5f58036 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mp.dtsi @@ -1406,6 +1406,13 @@ aips5: bus@30c00000 { #size-cells = <1>; ranges; + aipstz5: bridge@30df0000 { + compatible = "fsl,imx8mp-aipstz"; + reg = <0x30df0000 0x10000>; + power-domains = <&pgc_audio>; + status = "okay"; + }; + spba-bus@30c00000 { compatible = "fsl,spba-bus", "simple-bus"; reg = <0x30c00000 0x100000>; diff --git a/drivers/soc/imx/aipstz.c b/drivers/soc/imx/aipstz.c new file mode 100644 index 000000000000..49a619f17dda --- /dev/null +++ b/drivers/soc/imx/aipstz.c @@ -0,0 +1,114 @@ +#include +#include +#include +#include +#include +#include +#include + +#define DRV_NAME "aips-bridge" + +#define AIPSTZ_MPR0 0x0 +#define AIPSTZ_MPR1 0x4 + +#define AIPSTZ_OPACR_NUM (0x5) +#define OPACR_OFFSET(i) ((i) * 4 + 0x40) + +struct aipstz_drv { + void __iomem *base; + struct notifier_block power_nb; + struct aipstz_cfg *cfg; +}; + +struct aipstz_cfg { + uint32_t mpr0; + uint32_t mpr1; + uint32_t opacr[AIPSTZ_OPACR_NUM]; +}; + +static struct aipstz_cfg aipstz5 = { + 0x77777777, + 0x77777777, + .opacr = {0x0, 0x0, 0x0, 0x0, 0x0} +}; + +static void imx_aipstz_config_init(const struct aipstz_drv *drv) + +{ + const struct aipstz_cfg *aipstz = drv->cfg; + + writel(aipstz->mpr0, drv->base + AIPSTZ_MPR0); + writel(aipstz->mpr1, drv->base + AIPSTZ_MPR1); + + for (int i = 0; i < AIPSTZ_OPACR_NUM; i++) + writel(aipstz->opacr[i], drv->base + OPACR_OFFSET(i)); +} + +static int aipstz_power_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct aipstz_drv *drv = container_of(nb, struct aipstz_drv, power_nb); + + if (action != GENPD_NOTIFY_ON) + return NOTIFY_OK; + + imx_aipstz_config_init(drv); + + return NOTIFY_OK; +} + +static int aipstz_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct aipstz_drv *drv; + + drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL); + if (!drv) + return -ENOMEM; + + drv->base = of_iomap(pdev->dev.of_node, 0); + drv->power_nb.notifier_call = aipstz_power_notifier; + drv->cfg = &aipstz5; + + imx_aipstz_config_init(drv); + + if (dev->pm_domain) + dev_pm_genpd_add_notifier(dev, &drv->power_nb); + + dev_set_drvdata(dev, drv); + + return 0; +} + +static const struct of_device_id aipstz_of_match[] = { + {.compatible = "fsl,imx8mp-aipstz", }, + {} +}; + +static struct platform_driver aipstz_driver = { + .probe = aipstz_probe, + .driver = { + .name = DRV_NAME, + .of_match_table = of_match_ptr(aipstz_of_match), + }, +}; + +static int __init aipstz_driver_init(void) +{ + int ret; + + ret = platform_driver_register(&aipstz_driver); + if (ret) { + pr_err("Failed to register aipstz platform driver\n"); + return ret; + } + + return 0; +} + +device_initcall(aipstz_driver_init); + +MODULE_DESCRIPTION("i.MX8 AIPS bus configuration driver"); +MODULE_AUTHOR("Daniel Baluta "); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRV_NAME);