From: Lokesh Vutla <lokeshvutla@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 22/25] remoteproc: Introduce K3 remoteproc driver
Date: Tue, 21 Aug 2018 20:02:00 +0530 [thread overview]
Message-ID: <20180821143203.29142-23-lokeshvutla@ti.com> (raw)
In-Reply-To: <20180821143203.29142-1-lokeshvutla@ti.com>
Add support for K3 based remoteproc driver that
communicates with TISCI to start start a remote processor.
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
.../remoteproc/k3-rproc.txt | 50 ++++
drivers/remoteproc/Kconfig | 9 +
drivers/remoteproc/Makefile | 1 +
drivers/remoteproc/k3_rproc.c | 244 ++++++++++++++++++
4 files changed, 304 insertions(+)
create mode 100644 doc/device-tree-bindings/remoteproc/k3-rproc.txt
create mode 100644 drivers/remoteproc/k3_rproc.c
diff --git a/doc/device-tree-bindings/remoteproc/k3-rproc.txt b/doc/device-tree-bindings/remoteproc/k3-rproc.txt
new file mode 100644
index 0000000000..0a1e858225
--- /dev/null
+++ b/doc/device-tree-bindings/remoteproc/k3-rproc.txt
@@ -0,0 +1,50 @@
+Texas Instruments' K3 Remote processor driver
+=============================================
+
+In K3 generation Socs, loading an image on any processing entity
+cannot be done directly from U-Boot. In order to load an image,
+remoteproc driver should communicate to SYSFW with a specific sequence.
+Also enable the timer required for this remotecore.
+
+Required properties:
+--------------------
+- compatible: Shall be: "ti,am654-rproc"
+- reg: base address of the remoteproc timer.
+- power-domains: Should contain two sets of entries:
+ First set corresponds to pm domain of the
+ remotecore timer. Seconf entry corresponds to the
+ remoteproc to start.
+ This property is as per the binding,
+ doc/device-tree-bindings/power/ti,sci-pm-domain.txt
+- resets: Should contain a phandle to a reset controller node
+ and an args specifier containing the remote code
+ device id and reset mask value. This is as per the
+ doc/device-tree-bindings/reset/ti,sci-reset.txt
+- ti,sci: Phandle to TI-SCI compatible System controller node.
+- ti,sci-proc-id: Processor id as identified by TISCI
+
+Optional properties:
+--------------------
+- assigned-clocks: Should contain a phandle to clock node and an args
+ specifier containing the remote core device id and
+ the clock id within the remote core. This is as per
+ doc/device-tree-bindings/clock/ti,sci-clk.txt
+- assigned-clock-rates: One entry for each entry of assigned-clocks. This is
+ the frequency at which the corresponding clock needs
+ to be assigned.
+- ti,sci-host-id: Host ID to which the processor control is transferred to
+
+Example:
+---------
+
+a53_0: a53 at 0 {
+ compatible = "ti,am654-rproc";
+ power-domains = <&k3_pds 61>,
+ <&k3_pds 202>;
+ resets = <&k3_reset 202 0>;
+ assigned-clocks = <&k3_clks 202 0>;
+ assigned-clock-rates = <800000000>;
+ ti,sci = <&dmsc>;
+ ti,sci-proc-id = <32>;
+ ti,sci-host-id = <10>;
+};
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 812d30153b..9eb532bc7a 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -22,6 +22,15 @@ config K3_SYSTEM_CONTROLLER
help
Say 'y' here to add support for TI' K3 System Controller.
+config REMOTEPROC_K3
+ bool "Support for TI's K3 based remoteproc driver"
+ select REMOTEPROC
+ depends on DM
+ depends on ARCH_K3
+ depends on OF_CONTROL
+ help
+ Say 'y' here to add support for TI' K3 remoteproc driver.
+
config REMOTEPROC_SANDBOX
bool "Support for Test processor for Sandbox"
select REMOTEPROC
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index bfd02ad52d..87ef9e61a7 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -8,5 +8,6 @@ obj-$(CONFIG_REMOTEPROC) += rproc-uclass.o
# Remote proc drivers - Please keep this list alphabetically sorted.
obj-$(CONFIG_K3_SYSTEM_CONTROLLER) += k3_system_controller.o
+obj-$(CONFIG_REMOTEPROC_K3) += k3_rproc.o
obj-$(CONFIG_REMOTEPROC_SANDBOX) += sandbox_testproc.o
obj-$(CONFIG_REMOTEPROC_TI_POWER) += ti_power_proc.o
diff --git a/drivers/remoteproc/k3_rproc.c b/drivers/remoteproc/k3_rproc.c
new file mode 100644
index 0000000000..4028d4aa66
--- /dev/null
+++ b/drivers/remoteproc/k3_rproc.c
@@ -0,0 +1,244 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Texas Instruments' K3 Remoteproc driver
+ *
+ * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+ * Lokesh Vutla <lokeshvutla@ti.com>
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <remoteproc.h>
+#include <errno.h>
+#include <clk.h>
+#include <reset.h>
+#include <asm/io.h>
+#include <power-domain.h>
+#include <linux/soc/ti/ti_sci_protocol.h>
+
+#define INVALID_ID 0xffff
+
+#define GTC_CNTCR_REG 0x0
+#define GTC_CNTR_EN 0x3
+
+/**
+ * struct k3_rproc_privdata - Structure representing Remote processor data.
+ * @rproc_pwrdmn: rproc power domain data
+ * @rproc_rst: rproc reset control data
+ * @sci: Pointer to TISCI handle
+ * @gtc_base: Timer base address.
+ * @proc_id: TISCI processor ID
+ * @host_id: TISCI host id to which the processor gets assigned to.
+ */
+struct k3_rproc_privdata {
+ struct power_domain rproc_pwrdmn;
+ struct power_domain gtc_pwrdmn;
+ struct reset_ctl rproc_rst;
+ const struct ti_sci_handle *sci;
+ void *gtc_base;
+ u16 proc_id;
+ u16 host_id;
+};
+
+/**
+ * k3_rproc_load() - Load up the Remote processor image
+ * @dev: rproc device pointer
+ * @addr: Address at which image is available
+ * @size: size of the image
+ *
+ * Return: 0 if all goes good, else appropriate error message.
+ */
+static int k3_rproc_load(struct udevice *dev, ulong addr, ulong size)
+{
+ struct k3_rproc_privdata *rproc = dev_get_priv(dev);
+ const struct ti_sci_proc_ops *pops = &rproc->sci->ops.proc_ops;
+ int ret;
+
+ dev_dbg(dev, "%s addr = 0x%lx, size = 0x%lx\n", __func__, addr, size);
+
+ /* request for the processor */
+ ret = pops->proc_request(rproc->sci, rproc->proc_id);
+ if (ret) {
+ dev_err(dev, "Requesting processor failed %d\n", ret);
+ return ret;
+ }
+
+ ret = pops->set_proc_boot_cfg(rproc->sci, rproc->proc_id, addr, 0, 0);
+ if (ret) {
+ dev_err(dev, "set_proc_boot_cfg failed %d\n", ret);
+ return ret;
+ }
+
+ dev_dbg(dev, "%s: rproc successfully loaded\n", __func__);
+
+ return 0;
+}
+
+/**
+ * k3_rproc_start() - Start the remote processor
+ * @dev: rproc device pointer
+ *
+ * Return: 0 if all went ok, else return appropriate error
+ */
+static int k3_rproc_start(struct udevice *dev)
+{
+ struct k3_rproc_privdata *rproc = dev_get_priv(dev);
+ const struct ti_sci_proc_ops *pops = &rproc->sci->ops.proc_ops;
+ int ret;
+
+ dev_dbg(dev, "%s\n", __func__);
+
+ ret = power_domain_on(&rproc->gtc_pwrdmn);
+ if (ret) {
+ dev_err(dev, "power_domain_on() failed: %d\n", ret);
+ return ret;
+ }
+
+ /* Enable the timer before starting remote core */
+ writel(GTC_CNTR_EN, rproc->gtc_base + GTC_CNTCR_REG);
+
+ /*
+ * Setting the right clock frequency would have taken care by
+ * assigned-clock-rates during the device probe. So no need to
+ * set the frequency again here.
+ */
+ ret = power_domain_on(&rproc->rproc_pwrdmn);
+ if (ret) {
+ dev_err(dev, "power_domain_on() failed: %d\n", ret);
+ return ret;
+ }
+
+ if (rproc->host_id != INVALID_ID) {
+ ret = pops->proc_handover(rproc->sci, rproc->proc_id,
+ rproc->host_id);
+ if (ret) {
+ dev_err(dev, "Handover processor failed %d\n", ret);
+ return ret;
+ }
+ } else {
+ ret = pops->proc_release(rproc->sci, rproc->proc_id);
+ if (ret) {
+ dev_err(dev, "Processor release failed %d\n", ret);
+ return ret;
+ }
+ }
+
+ dev_dbg(dev, "%s: rproc successfully started\n", __func__);
+
+ return 0;
+}
+
+/**
+ * k3_rproc_init() - Initialize the remote processor
+ * @dev: rproc device pointer
+ *
+ * Return: 0 if all went ok, else return appropriate error
+ */
+static int k3_rproc_init(struct udevice *dev)
+{
+ dev_dbg(dev, "%s\n", __func__);
+
+ /* Enable the module */
+ dev_dbg(dev, "%s: rproc successfully initialized\n", __func__);
+
+ return 0;
+}
+
+static const struct dm_rproc_ops k3_rproc_ops = {
+ .init = k3_rproc_init,
+ .load = k3_rproc_load,
+ .start = k3_rproc_start,
+};
+
+/**
+ * k3_of_to_priv() - generate private data from device tree
+ * @dev: corresponding k3 remote processor device
+ * @priv: pointer to driver specific private data
+ *
+ * Return: 0 if all goes good, else appropriate error message.
+ */
+static int k3_rproc_of_to_priv(struct udevice *dev,
+ struct k3_rproc_privdata *rproc)
+{
+ int ret;
+
+ dev_dbg(dev, "%s\n", __func__);
+
+ ret = power_domain_get_by_index(dev, &rproc->rproc_pwrdmn, 1);
+ if (ret) {
+ dev_err(dev, "power_domain_get() failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = power_domain_get_by_index(dev, &rproc->gtc_pwrdmn, 0);
+ if (ret) {
+ dev_err(dev, "power_domain_get() failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = reset_get_by_index(dev, 0, &rproc->rproc_rst);
+ if (ret) {
+ dev_err(dev, "reset_get() failed: %d\n", ret);
+ return ret;
+ }
+
+ rproc->sci = ti_sci_get_by_phandle(dev, "ti,sci");
+ if (IS_ERR(rproc->sci)) {
+ dev_err(dev, "ti_sci get failed: %d\n", ret);
+ return PTR_ERR(rproc->sci);
+ }
+
+ rproc->gtc_base = dev_read_addr_ptr(dev);
+ if (!rproc->gtc_base) {
+ dev_err(dev, "Get address failed\n");
+ return -ENODEV;
+ }
+
+ rproc->proc_id = dev_read_u32_default(dev, "ti,sci-proc-id",
+ INVALID_ID);
+ rproc->host_id = dev_read_u32_default(dev, "ti,sci-host-id",
+ INVALID_ID);
+
+ return 0;
+}
+
+/**
+ * k3_rproc_probe() - Basic probe
+ * @dev: corresponding k3 remote processor device
+ *
+ * Return: 0 if all goes good, else appropriate error message.
+ */
+static int k3_rproc_probe(struct udevice *dev)
+{
+ struct k3_rproc_privdata *priv;
+ int ret;
+
+ dev_dbg(dev, "%s\n", __func__);
+
+ priv = dev_get_priv(dev);
+
+ ret = k3_rproc_of_to_priv(dev, priv);
+ if (ret) {
+ dev_dbg(dev, "%s: Probe failed with error %d\n", __func__, ret);
+ return ret;
+ }
+
+ dev_dbg(dev, "Remoteproc successfully probed\n");
+
+ return 0;
+}
+
+static const struct udevice_id k3_rproc_ids[] = {
+ { .compatible = "ti,am654-rproc"},
+ {}
+};
+
+U_BOOT_DRIVER(k3_rproc) = {
+ .name = "k3_rproc",
+ .of_match = k3_rproc_ids,
+ .id = UCLASS_REMOTEPROC,
+ .ops = &k3_rproc_ops,
+ .probe = k3_rproc_probe,
+ .priv_auto_alloc_size = sizeof(struct k3_rproc_privdata),
+};
--
2.18.0
next prev parent reply other threads:[~2018-08-21 14:32 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-21 14:31 [U-Boot] [PATCH 00/25] [2/3] Initial support Texas Instrument's AM654 Platform Lokesh Vutla
2018-08-21 14:31 ` [U-Boot] [PATCH 01/25] firmware: Add basic support for TI System Control Interface (TI SCI) protocol Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-24 15:00 ` Lokesh Vutla
2018-08-21 14:31 ` [U-Boot] [PATCH 02/25] firmware: ti_sci: Add support for board configuration Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 03/25] firmware: ti_sci: Add support for device control Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 04/25] firmware: ti_sci: Add support for clock control Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 05/25] firmware: ti_sci: Add support for reboot core service Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 06/25] firmware: ti_sci: Add support for processor control services Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 07/25] dm: firmware: Automatically bind child devices Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 08/25] dm: reset: Update uclass to allow querying reset status Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 09/25] reset: Extend reset control with an optional data field Lokesh Vutla
2018-08-24 14:11 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 10/25] reset: Introduce TI System Control Interface (TI SCI) reset driver Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 11/25] clk: Allow clock defaults to be set also during re-reloc state Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-24 14:42 ` Dr. Philipp Tomsich
2018-08-24 15:54 ` Andreas Dannenberg
2018-08-24 16:00 ` Dr. Philipp Tomsich
2018-08-24 16:28 ` Andreas Dannenberg
2018-08-27 3:26 ` Kever Yang
2018-08-27 16:06 ` Andreas Dannenberg
2018-08-28 9:12 ` Lokesh Vutla
2018-08-27 6:02 ` Lokesh Vutla
2018-08-21 14:31 ` [U-Boot] [PATCH 12/25] clk: Extend clock control with an optional data field Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 13/25] clk: Introduce TI System Control Interface (TI SCI) clock driver Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 14/25] power domain: Add support for multiple powerdomains per device Lokesh Vutla
2018-08-22 9:21 ` Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 15/25] power domain: Introduce TI System Control Interface (TI SCI) power domain driver Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 16/25] sysreset: Add TI System Control Interface (TI SCI) sysreset driver Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 17/25] mailbox: Allow attaching private data for mbox_chan Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 18/25] mailbox: Introduce K3 Secure Proxy Driver Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 19/25] spl: Allow mailbox drivers to be used within SPL Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 20/25] remoteproc: Allow for individual remoteproc initialization Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 21/25] remoteproc: Introduce K3 system controller Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-24 15:02 ` Lokesh Vutla
2018-08-21 14:32 ` Lokesh Vutla [this message]
2018-08-24 14:12 ` [U-Boot] [PATCH 22/25] remoteproc: Introduce K3 remoteproc driver Tom Rini
2018-08-21 14:32 ` [U-Boot] [PATCH 23/25] spl: Allow remoteproc drivers to be used within SPL Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:32 ` [U-Boot] [PATCH 24/25] mmc: k3_arasan: Add sdhci driver support for K3 family SoCs Lokesh Vutla
2018-08-24 14:12 ` Tom Rini
2018-08-21 14:32 ` [U-Boot] [PATCH 25/25] gpio: do not include <asm/arch/gpio.h> for ARCH_K3 Lokesh Vutla
2018-08-24 14:13 ` Tom Rini
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=20180821143203.29142-23-lokeshvutla@ti.com \
--to=lokeshvutla@ti.com \
--cc=u-boot@lists.denx.de \
/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