From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A90720D51F for ; Tue, 1 Apr 2025 15:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522357; cv=none; b=pmVkDkIqwJO3asiyt9OA+RHZ3Eq3eBdwxSGjb32JK9Jy6rtJHDs7hfkrDJ+Z5BkBZ0duWf1p75Ul0fWbNo+Ymd7trpNGSpteLFJLGW4J13MsvR84/VA6UzLWRhFKJmjB5J8rah/19bqwJgMdPnDy0XShq4YCRpiDGgH/nmB7Adk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522357; c=relaxed/simple; bh=F8NZNfXY+db76aNNrBJbSG7T5RVx6dAyulLZqrqB6lM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jY+R/G5jjIkm9csyPlW0VKXrQ2qiIAPK9Tt7wxJ6tTPgtnkWY5gfv4KxOr7CqZIVLsa+lr/VxpgKOwdcaZK37UZ+2+8THpPmD8awOO2JrtFojzHX4xJ0pbclqnT5/s9mcL7ViY1lM929NMhN8MX24eaTpQRzFxYac/z1WxAHXf8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WY/1NiCd; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WY/1NiCd" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-43cf06eabdaso54631565e9.2 for ; Tue, 01 Apr 2025 08:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743522354; x=1744127154; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3+/ol304EYZFzmHf5qWZCvTKblJaCdBMbBu4cFrdM28=; b=WY/1NiCd2kJRy5SxqEKPHBFYnUGFapuxYjPNtwcLWfL7eRAaaqQfSiLNfaGS0uLfjc wFLdfUBe09EAnD13BfflfHZb3Usth8/JkAsopJwlsqKf2EfEkBpwA+IKk1sMeJJ6uTKa QZLi1UxhYcFIyv/BvMmaBsPCbdiAZ4kmlHgGSdkjlXLY6A79UkO4/lN1rCyvXk1Pi99l dqOgHDrTa244Uqfnf7mV6vedQLTeFO/WdrhNDsbmUBeOlMBBEF6ks27x2A+dZoZ8xIWY ZmCUDNqGCcRYFa6G90UyXm6fP8Ea4zhWbb9VOfg9RqKedgwySONzeTPr17D3BOpFydXt 18bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743522354; x=1744127154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3+/ol304EYZFzmHf5qWZCvTKblJaCdBMbBu4cFrdM28=; b=pXu+1tRbvL0OXoF1D3LlLSkqUX122ye8LGaWmGK40F9KM6S3VGSZITx/ltddJcGKUo ZgNUKsTEG8YsAmLBNH/GQIFytI0N1inmfL0MLxNQLLUKCYwwsqr2okdqs4AlDWzZDety IvBRjGXL2JEdVTsFJedQCKy7GFWuAncW+UFK5sQF9ShxCR7d9nWRFnSLKa5wm3Zpbli7 cmHrtwbkh/A7DLRKJGC/vntTh31K4lcgiG68MOdRX0qDObpxfaVVBU5JLnkC2mr3VWPh x7IIvEVrIKVe8EiKqmRuCubajNkJtki9u5/IVH+QnEGW/y5XpytlcrBifRCjWLtv+k14 TIzA== X-Forwarded-Encrypted: i=1; AJvYcCWS1pfx0Lh+bWrc3tc8CSyWKoL7wiPINtWOtAs4JT9d9E7f7Hntd3JZspcZg4NohnB0X0g=@lists.linux.dev X-Gm-Message-State: AOJu0YzBB9HEKHSf9MQKYsV+G0aoc5TpbuJ3+KMI8OJf/6opL+GVggZX lss5cdZwK/fjLMCo4rO82bX+Mw/j2NsbDFPs7UwcS9We7RRKUfYQ X-Gm-Gg: ASbGncuHgwjjQdw64FQcnPdepVQOcISlBjmIPiK1ygUgD46LC5ZYdcueF1x2Of3dFeg C57iPVUp9a9IH8C+E60m4O1ywaaq22BoD9E1UaybuTud760AZ7t/zSeaUSUu3PhI52XUcKpsv9k ch7BAr384gHzs1JvXQC1m7zFYsgvm8li4clSUvE0hffBMGXBRO1ujJHUiW8AKv836jpFbGY3vSp nM/8rsiLfcm3RSU9G6BMBN5dc99uHrQ2CLXY5YvEMmVVck3/YrDsa0giiBoCA0WrjBDId+x8sSc GgrG6b9zYjl7xkjxTx14hxgxjLmp/9dr39d/zEQnf/qA4x/vZF+aoFJUYmSptdk244s+C3M2gBn RRBKFh1U= X-Google-Smtp-Source: AGHT+IE2m9aQ7hxMdL1hcSCVBaAL9i81WJkbAFdNTU9OkqMxfa+QpMQqlgxt2/QmZqWboPf3GEwH7Q== X-Received: by 2002:a5d:64cc:0:b0:399:6dc0:f134 with SMTP id ffacd0b85a97d-39c1211de8dmr10794398f8f.51.1743522353458; Tue, 01 Apr 2025 08:45:53 -0700 (PDT) Received: from playground.localdomain ([82.79.237.110]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d8ff042bcsm158795735e9.28.2025.04.01.08.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 08:45:53 -0700 (PDT) From: Laurentiu Mihalcea To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Fabio Estevam , Daniel Baluta , Shengjiu Wang , Frank Li , Marco Felsch , Marc Kleine-Budde Cc: Pengutronix Kernel Team , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/6] bus: add driver for IMX AIPSTZ bridge Date: Tue, 1 Apr 2025 11:44:01 -0400 Message-Id: <20250401154404.45932-4-laurentiumihalcea111@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250401154404.45932-1-laurentiumihalcea111@gmail.com> References: <20250401154404.45932-1-laurentiumihalcea111@gmail.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Laurentiu Mihalcea The secure AHB to IP Slave (AIPSTZ) bus bridge provides access control configurations meant to restrict access to certain peripherals. Some of the configurations include: 1) Marking masters as trusted for R/W. Based on this (and the configuration of the accessed peripheral), the bridge may choose to abort the R/W transactions issued by certain masters. 2) Allowing/disallowing write accesses to peripherals. Add driver for this IP. Since there's currently no framework for access controllers (and since there's currently no need for having flexibility w.r.t the configurations) all this driver does is it applies a relaxed, "default" configuration, in which all masters are trusted for R/W. Note that some instances of this IP (e.g: AIPSTZ5 on i.MX8MP) may be tied to a power domain and may lose their configuration when the domain is powered off. This is why the configuration has to be restored when the domain is powered on. Co-developed-by: Daniel Baluta Signed-off-by: Daniel Baluta Signed-off-by: Laurentiu Mihalcea --- drivers/bus/Kconfig | 6 +++ drivers/bus/Makefile | 1 + drivers/bus/imx-aipstz.c | 92 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 drivers/bus/imx-aipstz.c diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig index ff669a8ccad9..fe7600283e70 100644 --- a/drivers/bus/Kconfig +++ b/drivers/bus/Kconfig @@ -87,6 +87,12 @@ config HISILICON_LPC Driver to enable I/O access to devices attached to the Low Pin Count bus on the HiSilicon Hip06/7 SoC. +config IMX_AIPSTZ + tristate "Support for IMX Secure AHB to IP Slave bus (AIPSTZ) bridge" + depends on ARCH_MXC + help + Enable support for IMX AIPSTZ bridge. + config IMX_WEIM bool "Freescale EIM DRIVER" depends on ARCH_MXC || COMPILE_TEST diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile index cddd4984d6af..8e693fe8a03a 100644 --- a/drivers/bus/Makefile +++ b/drivers/bus/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/ obj-$(CONFIG_BT1_APB) += bt1-apb.o obj-$(CONFIG_BT1_AXI) += bt1-axi.o +obj-$(CONFIG_IMX_AIPSTZ) += imx-aipstz.o obj-$(CONFIG_IMX_WEIM) += imx-weim.o obj-$(CONFIG_INTEL_IXP4XX_EB) += intel-ixp4xx-eb.o obj-$(CONFIG_MIPS_CDMM) += mips_cdmm.o diff --git a/drivers/bus/imx-aipstz.c b/drivers/bus/imx-aipstz.c new file mode 100644 index 000000000000..44db40dae71b --- /dev/null +++ b/drivers/bus/imx-aipstz.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2025 NXP + */ + +#include +#include +#include +#include +#include +#include + +#define IMX_AIPSTZ_MPR0 0x0 + +struct imx_aipstz_config { + u32 mpr0; +}; + +static void imx_aipstz_apply_default(void __iomem *base, + const struct imx_aipstz_config *default_cfg) +{ + writel(default_cfg->mpr0, base + IMX_AIPSTZ_MPR0); +} + +static int imx_aipstz_probe(struct platform_device *pdev) +{ + const struct imx_aipstz_config *default_cfg; + void __iomem *base; + + base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); + if (IS_ERR(base)) + return dev_err_probe(&pdev->dev, -ENOMEM, + "failed to get/ioremap AC memory\n"); + + default_cfg = of_device_get_match_data(&pdev->dev); + + imx_aipstz_apply_default(base, default_cfg); + + dev_set_drvdata(&pdev->dev, base); + + pm_runtime_set_active(&pdev->dev); + devm_pm_runtime_enable(&pdev->dev); + + return devm_of_platform_populate(&pdev->dev); +} + +static int imx_aipstz_runtime_resume(struct device *dev) +{ + const struct imx_aipstz_config *default_cfg; + void __iomem *base; + + base = dev_get_drvdata(dev); + default_cfg = of_device_get_match_data(dev); + + /* restore potentially lost configuration during domain power-off */ + imx_aipstz_apply_default(base, default_cfg); + + return 0; +} + +static const struct dev_pm_ops imx_aipstz_pm_ops = { + RUNTIME_PM_OPS(NULL, imx_aipstz_runtime_resume, NULL) + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) +}; + +/* + * following configuration is equivalent to: + * masters 0-7 => trusted for R/W + use AHB's HPROT[1] to det. privilege + */ +static const struct imx_aipstz_config imx8mp_aipstz_default_cfg = { + .mpr0 = 0x77777777, +}; + +static const struct of_device_id imx_aipstz_of_ids[] = { + { .compatible = "fsl,imx8mp-aipstz", .data = &imx8mp_aipstz_default_cfg }, + { } +}; +MODULE_DEVICE_TABLE(of, imx_aipstz_of_ids); + +static struct platform_driver imx_aipstz_of_driver = { + .probe = imx_aipstz_probe, + .driver = { + .name = "imx-aipstz", + .of_match_table = imx_aipstz_of_ids, + .pm = pm_ptr(&imx_aipstz_pm_ops), + }, +}; +module_platform_driver(imx_aipstz_of_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("IMX secure AHB to IP Slave bus (AIPSTZ) bridge driver"); +MODULE_AUTHOR("Laurentiu Mihalcea "); -- 2.34.1