From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Linus Walleij <linus.walleij@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Lee Jones <lee@kernel.org>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-mips@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
linux-gpio@vger.kernel.org,
"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
"Théo Lebrun" <theo.lebrun@bootlin.com>
Subject: [PATCH v2 06/11] mfd: olb: Add support for Mobileye OLB system-controller
Date: Fri, 03 May 2024 16:20:51 +0200 [thread overview]
Message-ID: <20240503-mbly-olb-v2-6-95ce5a1e18fe@bootlin.com> (raw)
In-Reply-To: <20240503-mbly-olb-v2-0-95ce5a1e18fe@bootlin.com>
Mobileye OLB system-controller gets used in EyeQ5, EyeQ6L and EyeQ6H
platforms. It hosts clock, reset and pinctrl functionality.
Tiny iomem resources are declared for all cells. Some features are
spread apart. Pinctrl is only used on EyeQ5.
EyeQ6H is special: it hosts seven OLB controllers, each with a
compatible. That means many clock and reset cells. Use cell->devname
for explicit device names rather than clk-eyeq.ID or clk-eyeq.ID.auto.
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/mfd/Kconfig | 10 +++
drivers/mfd/Makefile | 2 +
drivers/mfd/mobileye-olb.c | 180 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 192 insertions(+)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 4b023ee229cf..d004a3f4d493 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1030,6 +1030,16 @@ config MFD_OCELOT
If unsure, say N.
+config MFD_OLB
+ bool "Mobileye EyeQ OLB System Controller Support"
+ select MFD_CORE
+ depends on MACH_EYEQ5 || MACH_EYEQ6H || COMPILE_TEST
+ default MACH_EYEQ5 || MACH_EYEQ6H
+ help
+ Say yes here to add support for EyeQ platforms (EyeQ5, EyeQ6L and
+ EyeQ6H). This core MFD platform driver provides clock, reset and
+ pinctrl (only EyeQ5) support.
+
config EZX_PCAP
bool "Motorola EZXPCAP Support"
depends on SPI_MASTER
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index c66f07edcd0e..d872833966a8 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -120,6 +120,8 @@ obj-$(CONFIG_MFD_CORE) += mfd-core.o
ocelot-soc-objs := ocelot-core.o ocelot-spi.o
obj-$(CONFIG_MFD_OCELOT) += ocelot-soc.o
+obj-$(CONFIG_MFD_OLB) += mobileye-olb.o
+
obj-$(CONFIG_EZX_PCAP) += ezx-pcap.o
obj-$(CONFIG_MFD_CPCAP) += motorola-cpcap.o
diff --git a/drivers/mfd/mobileye-olb.c b/drivers/mfd/mobileye-olb.c
new file mode 100644
index 000000000000..1640d63a3ddd
--- /dev/null
+++ b/drivers/mfd/mobileye-olb.c
@@ -0,0 +1,180 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * System controller multi-function device for EyeQ platforms.
+ *
+ * Mobileye EyeQ5, EyeQ6L and EyeQ6H platforms have MMIO mapped registers
+ * controlling core platform clocks, resets and pin control. Many other
+ * features are present and not yet exposed.
+ *
+ * Declare cells for each compatible. Only EyeQ5 has pinctrl.
+ * EyeQ6H has seven OLB instances; each has a name which we propagate to
+ * sub-devices using cell->devname.
+ *
+ * Copyright (C) 2024 Mobileye Vision Technologies Ltd.
+ */
+
+#include <linux/array_size.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/mfd/core.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+
+#define OLB_MFD_CELL(_name, _res, _devname) \
+ MFD_CELL_ALL(_name, _res, NULL, 0, 0, NULL, 0, false, NULL, _devname)
+
+struct olb_match_data {
+ const struct mfd_cell *cells;
+ int nb_cells; /* int to match devm_mfd_add_devices() argument */
+};
+
+#define OLB_DATA(_cells) { .cells = (_cells), .nb_cells = ARRAY_SIZE(_cells) }
+
+static int olb_probe(struct platform_device *pdev)
+{
+ const struct olb_match_data *match_data;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+
+ match_data = device_get_match_data(dev);
+ if (!match_data)
+ return -ENODEV;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENODEV;
+
+ return devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE,
+ match_data->cells, match_data->nb_cells,
+ res, 0, NULL);
+}
+
+static const struct resource olb_eyeq5_clk_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x02C, 10 * 8, "pll"),
+ DEFINE_RES_MEM_NAMED(0x11C, 1 * 4, "ospi"),
+};
+
+static const struct resource olb_eyeq5_reset_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x004, 2 * 4, "d0"),
+ DEFINE_RES_MEM_NAMED(0x200, 13 * 4, "d1"),
+ DEFINE_RES_MEM_NAMED(0x120, 1 * 4, "d2"),
+};
+
+static const struct resource olb_eyeq5_pinctrl_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x0B0, 12 * 4, "pinctrl"),
+};
+
+static const struct mfd_cell olb_eyeq5_cells[] = {
+ OLB_MFD_CELL("clk-eyeq", olb_eyeq5_clk_resources, NULL),
+ OLB_MFD_CELL("reset-eyeq", olb_eyeq5_reset_resources, NULL),
+ OLB_MFD_CELL("eyeq5-pinctrl", olb_eyeq5_pinctrl_resources, NULL),
+};
+
+static const struct olb_match_data olb_eyeq5_match_data = OLB_DATA(olb_eyeq5_cells);
+
+static const struct resource olb_eyeq6l_clk_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x02C, 4 * 8, "pll"),
+};
+
+static const struct resource olb_eyeq6l_reset_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x004, 2 * 4, "d0"),
+ DEFINE_RES_MEM_NAMED(0x200, 13 * 4, "d1"),
+};
+
+static const struct mfd_cell olb_eyeq6l_cells[] = {
+ OLB_MFD_CELL("clk-eyeq", olb_eyeq6l_clk_resources, NULL),
+ OLB_MFD_CELL("reset-eyeq", olb_eyeq6l_reset_resources, NULL),
+};
+
+static const struct olb_match_data olb_eyeq6l_match_data = OLB_DATA(olb_eyeq6l_cells);
+
+static const struct resource olb_eyeq6h_acc_clk_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x040, 7 * 8, "pll"),
+};
+
+static const struct resource olb_eyeq6h_acc_reset_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x000, 15 * 4, "d0"),
+};
+
+static const struct mfd_cell olb_eyeq6h_acc_cells[] = {
+ OLB_MFD_CELL("clk-eyeq", olb_eyeq6h_acc_clk_resources, "clk-eyeq-acc"),
+ OLB_MFD_CELL("reset-eyeq", olb_eyeq6h_acc_reset_resources, "reset-eyeq-acc"),
+};
+
+static const struct olb_match_data olb_eyeq6h_acc_match_data = OLB_DATA(olb_eyeq6h_acc_cells);
+
+static const struct resource olb_eyeq6h_we_clk_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x074, 1 * 8, "pll"),
+};
+
+static const struct resource olb_eyeq6h_we_reset_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x004, 4 * 4, "d0"),
+};
+
+static const struct mfd_cell olb_eyeq6h_west_cells[] = {
+ OLB_MFD_CELL("clk-eyeq", olb_eyeq6h_we_clk_resources, "clk-eyeq-west"),
+ OLB_MFD_CELL("reset-eyeq", olb_eyeq6h_we_reset_resources, "reset-eyeq-west"),
+};
+
+static const struct olb_match_data olb_eyeq6h_west_match_data = OLB_DATA(olb_eyeq6h_west_cells);
+
+static const struct mfd_cell olb_eyeq6h_east_cells[] = {
+ OLB_MFD_CELL("clk-eyeq", olb_eyeq6h_we_clk_resources, "clk-eyeq-east"),
+ OLB_MFD_CELL("reset-eyeq", olb_eyeq6h_we_reset_resources, "reset-eyeq-east"),
+};
+
+static const struct olb_match_data olb_eyeq6h_east_match_data = OLB_DATA(olb_eyeq6h_east_cells);
+
+static const struct resource olb_eyeq6h_south_clk_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x000, 4 * 8, "pll"),
+ DEFINE_RES_MEM_NAMED(0x070, 1 * 4, "emmc"),
+ DEFINE_RES_MEM_NAMED(0x090, 1 * 4, "ospi"),
+ DEFINE_RES_MEM_NAMED(0x098, 1 * 4, "tsu"),
+};
+
+static const struct mfd_cell olb_eyeq6h_south_cells[] = {
+ OLB_MFD_CELL("clk-eyeq", olb_eyeq6h_south_clk_resources, "clk-eyeq-south"),
+};
+
+static const struct olb_match_data olb_eyeq6h_south_match_data = OLB_DATA(olb_eyeq6h_south_cells);
+
+static const struct resource olb_eyeq6h_ddr_clk_resources[] = {
+ DEFINE_RES_MEM_NAMED(0x074, 1 * 8, "pll"),
+};
+
+static const struct mfd_cell olb_eyeq6h_ddr0_cells[] = {
+ OLB_MFD_CELL("clk-eyeq", olb_eyeq6h_ddr_clk_resources, "clk-eyeq-ddr0"),
+};
+
+static const struct olb_match_data olb_eyeq6h_ddr0_match_data = OLB_DATA(olb_eyeq6h_ddr0_cells);
+
+static const struct mfd_cell olb_eyeq6h_ddr1_cells[] = {
+ OLB_MFD_CELL("clk-eyeq", olb_eyeq6h_ddr_clk_resources, "clk-eyeq-ddr1"),
+};
+
+static const struct olb_match_data olb_eyeq6h_ddr1_match_data = OLB_DATA(olb_eyeq6h_ddr1_cells);
+
+static const struct of_device_id olb_of_match[] = {
+ { .compatible = "mobileye,eyeq5-olb", .data = &olb_eyeq5_match_data },
+ { .compatible = "mobileye,eyeq6l-olb", .data = &olb_eyeq6l_match_data },
+ { .compatible = "mobileye,eyeq6h-acc-olb", .data = &olb_eyeq6h_acc_match_data },
+ /* No central: it only has an early clock handled using CLK_OF_DECLARE_DRIVER(). */
+ { .compatible = "mobileye,eyeq6h-east-olb", .data = &olb_eyeq6h_east_match_data },
+ { .compatible = "mobileye,eyeq6h-west-olb", .data = &olb_eyeq6h_west_match_data },
+ { .compatible = "mobileye,eyeq6h-south-olb", .data = &olb_eyeq6h_south_match_data },
+ { .compatible = "mobileye,eyeq6h-ddr0-olb", .data = &olb_eyeq6h_ddr0_match_data },
+ { .compatible = "mobileye,eyeq6h-ddr1-olb", .data = &olb_eyeq6h_ddr1_match_data },
+ {},
+};
+MODULE_DEVICE_TABLE(of, olb_of_match);
+
+static struct platform_driver olb_driver = {
+ .probe = olb_probe,
+ .driver = {
+ .name = "olb",
+ .of_match_table = olb_of_match,
+ },
+};
+builtin_platform_driver(olb_driver);
--
2.45.0
next prev parent reply other threads:[~2024-05-03 14:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 14:20 [PATCH v2 00/11] Add Mobileye EyeQ system controller support (clk, reset, pinctrl) Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 01/11] dt-bindings: clock: mobileye,eyeq5-clk: drop bindings Théo Lebrun
2024-05-03 15:57 ` Krzysztof Kozlowski
2024-05-03 16:05 ` Krzysztof Kozlowski
2024-05-07 15:07 ` Théo Lebrun
2024-05-07 15:34 ` Krzysztof Kozlowski
2024-06-20 17:39 ` Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 02/11] dt-bindings: clock: mobileye,eyeq5-reset: " Théo Lebrun
2024-05-03 15:35 ` Rob Herring (Arm)
2024-05-03 14:20 ` [PATCH v2 03/11] dt-bindings: soc: mobileye: add EyeQ OLB system controller Théo Lebrun
2024-05-03 15:35 ` Rob Herring (Arm)
2024-05-07 12:51 ` Rob Herring
2024-06-20 17:41 ` Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 04/11] driver core: platform: Introduce platform_device_add_with_name() Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 05/11] mfd: Add cell device name Théo Lebrun
2024-05-03 14:20 ` Théo Lebrun [this message]
2024-05-31 11:05 ` [PATCH v2 06/11] mfd: olb: Add support for Mobileye OLB system-controller Lee Jones
2024-06-20 17:48 ` Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 07/11] clk: divider: Introduce CLK_DIVIDER_EVEN_INTEGERS flag Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 08/11] clk: eyeq: add driver Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 09/11] reset: eyeq: add platform driver Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 10/11] pinctrl: eyeq5: " Théo Lebrun
2024-05-03 14:20 ` [PATCH v2 11/11] MIPS: mobileye: eyeq5: add OLB system-controller node Théo Lebrun
2024-05-04 2:34 ` [PATCH v2 00/11] Add Mobileye EyeQ system controller support (clk, reset, pinctrl) Stephen Boyd
2024-05-07 14:52 ` Théo Lebrun
2024-05-07 15:14 ` Théo Lebrun
2024-05-07 21:48 ` Stephen Boyd
2024-06-20 18:00 ` Théo Lebrun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240503-mbly-olb-v2-6-95ce5a1e18fe@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.clement@bootlin.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=tawfik.bayouk@mobileye.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tsbogend@alpha.franken.de \
--cc=vladimir.kondratiev@mobileye.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox