From nobody Sun May 19 11:31:13 2024 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 204B520319; Fri, 26 Apr 2024 19:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159119; cv=none; b=PjFZ3z2kJYg8Z/1IBbF9Rk/UQoswXm6WSNpqhLHfs2ZrzJ/O+U4TE46Q+1M0vC9ydLiaUqf3FHNLCtoNlEz7sr9ib8zTOoVXE9+OW3V9pXoOBzVLftLvZjqM73dUBWn6S4bQoFt9J+dBjpwdsfn1BmNFY9lp85OzdNtzKOoTqyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159119; c=relaxed/simple; bh=4kah5gW4Qm+rCRloM1GoVSyBRZsMrK2hpdctAHE2n7c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gINAYZIQtORpW2SBtPdj5zGAWdhBwsM50byVuvX+8cRKporMEBHnsMOpZJxB3yOwXcTounEiXinTVzftNerK8js9Pebeq/7H6CNUhmdfgOi0SyAT1VoGdS9iEEMAm2/AgotWf0l/oEXudWzD0fkmAjQgZUIhkHL/35o35BKuzVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Q3MdVtT2; arc=none smtp.client-ip=198.47.19.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Q3MdVtT2" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43QJICDX116100; Fri, 26 Apr 2024 14:18:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714159092; bh=9j5bnO7OtFB7GG/h+OkYgySHAA0rpWDExuuXCrmfifA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Q3MdVtT2QFxVakZC7uPbm7Rvu0JF090Aa6N4EednLyItEalTncYuF1NemZYzG3nOq zmIE9xd3oKmbgaGEfeF/Pg2OX9Zst5uZpr7ywv52xq6WTMQDrA1jUcxR60vdZv2NhZ eFr39raZguDubUIR4sNmjwJcOTrvVaHj24nE+PvA= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43QJIC1M053568 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Apr 2024 14:18:12 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 26 Apr 2024 14:18:11 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 26 Apr 2024 14:18:11 -0500 Received: from ula0226330.dhcp.ti.com (ula0226330.dhcp.ti.com [128.247.81.8]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43QJIB7K028593; Fri, 26 Apr 2024 14:18:11 -0500 From: Andrew Davis To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Philipp Zabel , Hari Nagalla CC: , , , , Andrew Davis Subject: [PATCH v9 1/5] dt-bindings: remoteproc: k3-m4f: Add K3 AM64x SoCs Date: Fri, 26 Apr 2024 14:18:07 -0500 Message-ID: <20240426191811.32414-2-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426191811.32414-1-afd@ti.com> References: <20240426191811.32414-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" From: Hari Nagalla K3 AM64x SoC has a Cortex M4F subsystem in the MCU voltage domain. The remote processor's life cycle management and IPC mechanisms are similar across the R5F and M4F cores from remote processor driver point of view. However, there are subtle differences in image loading and starting the M4F subsystems. The YAML binding document provides the various node properties to be configured by the consumers of the M4F subsystem. Signed-off-by: Martyn Welch Signed-off-by: Hari Nagalla Signed-off-by: Andrew Davis Reviewed-by: Conor Dooley --- .../bindings/remoteproc/ti,k3-m4f-rproc.yaml | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,k3-m4f-= rproc.yaml diff --git a/Documentation/devicetree/bindings/remoteproc/ti,k3-m4f-rproc.y= aml b/Documentation/devicetree/bindings/remoteproc/ti,k3-m4f-rproc.yaml new file mode 100644 index 0000000000000..2bd0752b6ba9e --- /dev/null +++ b/Documentation/devicetree/bindings/remoteproc/ti,k3-m4f-rproc.yaml @@ -0,0 +1,125 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/remoteproc/ti,k3-m4f-rproc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI K3 M4F processor subsystems + +maintainers: + - Hari Nagalla + - Mathieu Poirier + +description: | + Some K3 family SoCs have Arm Cortex M4F cores. AM64x is a SoC in K3 + family with a M4F core. Typically safety oriented applications may use + the M4F core in isolation without an IPC. Where as some industrial and + home automation applications, may use the M4F core as a remote processor + with IPC communications. + +$ref: /schemas/arm/keystone/ti,k3-sci-common.yaml# + +properties: + compatible: + enum: + - ti,am64-m4fss + + power-domains: + maxItems: 1 + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + reg: + items: + - description: IRAM internal memory region + - description: DRAM internal memory region + + reg-names: + items: + - const: iram + - const: dram + + resets: + maxItems: 1 + + firmware-name: + maxItems: 1 + description: Name of firmware to load for the M4F core + + mboxes: + description: + OMAP Mailbox specifier denoting the sub-mailbox, to be used for + communication with the remote processor. This property should match + with the sub-mailbox node used in the firmware image. + maxItems: 1 + + memory-region: + description: + phandle to the reserved memory nodes to be associated with the + remoteproc device. Optional memory regions available for firmware + specific purposes. + (see reserved-memory/reserved-memory.yaml in dtschema project) + maxItems: 8 + items: + - description: regions used for DMA allocations like vrings, vring b= uffers + and memory dedicated to firmware's specific purposes. + additionalItems: true + +required: + - compatible + - reg + - reg-names + - ti,sci + - ti,sci-dev-id + - ti,sci-proc-ids + - resets + - firmware-name + +unevaluatedProperties: false + +examples: + - | + reserved-memory { + #address-cells =3D <2>; + #size-cells =3D <2>; + + mcu_m4fss_dma_memory_region: m4f-dma-memory@9cb00000 { + compatible =3D "shared-dma-pool"; + reg =3D <0x00 0x9cb00000 0x00 0x100000>; + no-map; + }; + + mcu_m4fss_memory_region: m4f-memory@9cc00000 { + compatible =3D "shared-dma-pool"; + reg =3D <0x00 0x9cc00000 0x00 0xe00000>; + no-map; + }; + }; + + soc { + #address-cells =3D <2>; + #size-cells =3D <2>; + + mailbox0_cluster0: mailbox-0 { + #mbox-cells =3D <1>; + }; + + remoteproc@5000000 { + compatible =3D "ti,am64-m4fss"; + reg =3D <0x00 0x5000000 0x00 0x30000>, + <0x00 0x5040000 0x00 0x10000>; + reg-names =3D "iram", "dram"; + resets =3D <&k3_reset 9 1>; + firmware-name =3D "am62-mcu-m4f0_0-fw"; + mboxes =3D <&mailbox0_cluster0>, <&mbox_m4_0>; + memory-region =3D <&mcu_m4fss_dma_memory_region>, + <&mcu_m4fss_memory_region>; + ti,sci =3D <&dmsc>; + ti,sci-dev-id =3D <9>; + ti,sci-proc-ids =3D <0x18 0xff>; + }; + }; --=20 2.39.2 From nobody Sun May 19 11:31:13 2024 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 B3E48208CA; Fri, 26 Apr 2024 19:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159121; cv=none; b=exlM5kCK7Guu8TAz4wC9uj/dWbGmNVPQdhgjpwugu58al1zrqPR0HjohpY0OkUeb1a1fQKuC4igF5gZi7nAflCbHU5NW5V19qEACIXZQy9jAUFTeiSPd6i0l5tpiuPyDUU+nS+zmHRMr4maKieiaRHHZ1oD4ByZQf3rntwKyOxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159121; c=relaxed/simple; bh=+tWZM+kFVU3kdNkclUAicKkoeFFVvb//PslMDqI7Jk8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZVOsgGQN1V0Es7UNyj0fk6ru7Qc4BwjrM34UGKk8iIVkQA813ex8ZfzU8kisG1rFnxdBd1Y/O4CHixOMHElT4qVtlVNYyEwbGmcVhmX7oBjLWqTr+bsdBxYL7VOURuh6O2NYJ0E7Q7+2+7e8a/R+G7CN0IuO7vLBbfSXl7E4VXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=kN0ITWTo; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="kN0ITWTo" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43QJICsi099380; Fri, 26 Apr 2024 14:18:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714159092; bh=bSdQyaWl8Zol4kmPf0+LNXQwuSAiQE8WhbT1BIkoCZs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kN0ITWToCvijS94d39rAvZ2iknRsbZ9ss8aiPkTf2duPerHONPp97ZN2CnehH08jl 7GZ62yf4C0wBvrPY9CS+bY7iOd0nbGNAw5c9Pj3kBb5GNDCSVphREdihnBhTjQ4/9W nIduPgAMAVWVbHk/ksJDCrh1AziI3MDw3A26WLGY= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43QJICoe001741 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Apr 2024 14:18:12 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 26 Apr 2024 14:18:11 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 26 Apr 2024 14:18:11 -0500 Received: from ula0226330.dhcp.ti.com (ula0226330.dhcp.ti.com [128.247.81.8]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43QJIB7L028593; Fri, 26 Apr 2024 14:18:11 -0500 From: Andrew Davis To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Philipp Zabel , Hari Nagalla CC: , , , , Andrew Davis Subject: [PATCH v9 2/5] remoteproc: k3-m4: Add a remoteproc driver for M4F subsystem Date: Fri, 26 Apr 2024 14:18:08 -0500 Message-ID: <20240426191811.32414-3-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426191811.32414-1-afd@ti.com> References: <20240426191811.32414-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" From: Martyn Welch The AM62x and AM64x SoCs of the TI K3 family has a Cortex M4F core in the MCU domain. This core is typically used for safety applications in a stand alone mode. However, some application (non safety related) may want to use the M4F core as a generic remote processor with IPC to the host processor. The M4F core has internal IRAM and DRAM memories and are exposed to the system bus for code and data loading. A remote processor driver is added to support this subsystem, including being able to load and boot the M4F core. Loading includes to M4F internal memories and predefined external code/data memories. The carve outs for external contiguous memory is defined in the M4F device node and should match with the external memory declarations in the M4F image binary. The M4F subsystem has two resets. One reset is for the entire subsystem i.e including the internal memories and the other, a local reset is only for the M4F processing core. When loading the image, the driver first releases the subsystem reset, loads the firmware image and then releases the local reset to let the M4F processing core run. Signed-off-by: Martyn Welch Signed-off-by: Hari Nagalla Signed-off-by: Andrew Davis --- drivers/remoteproc/Kconfig | 13 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/ti_k3_m4_remoteproc.c | 785 +++++++++++++++++++++++ 3 files changed, 799 insertions(+) create mode 100644 drivers/remoteproc/ti_k3_m4_remoteproc.c diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 48845dc8fa852..1a7c0330c91a9 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -339,6 +339,19 @@ config TI_K3_DSP_REMOTEPROC It's safe to say N here if you're not interested in utilizing the DSP slave processors. =20 +config TI_K3_M4_REMOTEPROC + tristate "TI K3 M4 remoteproc support" + depends on ARCH_K3 || COMPILE_TEST + select MAILBOX + select OMAP2PLUS_MBOX + help + Say m here to support TI's M4 remote processor subsystems + on various TI K3 family of SoCs through the remote processor + framework. + + It's safe to say N here if you're not interested in utilizing + a remote processor. + config TI_K3_R5_REMOTEPROC tristate "TI K3 R5 remoteproc support" depends on ARCH_K3 diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 91314a9b43cef..5ff4e2fee4abd 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -37,5 +37,6 @@ obj-$(CONFIG_ST_REMOTEPROC) +=3D st_remoteproc.o obj-$(CONFIG_ST_SLIM_REMOTEPROC) +=3D st_slim_rproc.o obj-$(CONFIG_STM32_RPROC) +=3D stm32_rproc.o obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) +=3D ti_k3_dsp_remoteproc.o +obj-$(CONFIG_TI_K3_M4_REMOTEPROC) +=3D ti_k3_m4_remoteproc.o obj-$(CONFIG_TI_K3_R5_REMOTEPROC) +=3D ti_k3_r5_remoteproc.o obj-$(CONFIG_XLNX_R5_REMOTEPROC) +=3D xlnx_r5_remoteproc.o diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/= ti_k3_m4_remoteproc.c new file mode 100644 index 0000000000000..0030e509f6b5d --- /dev/null +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -0,0 +1,785 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * TI K3 Cortex-M4 Remote Processor(s) driver + * + * Copyright (C) 2021-2024 Texas Instruments Incorporated - https://www.ti= .com/ + * Hari Nagalla + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "omap_remoteproc.h" +#include "remoteproc_internal.h" +#include "ti_sci_proc.h" + +/** + * struct k3_m4_rproc_mem - internal memory structure + * @cpu_addr: MPU virtual address of the memory region + * @bus_addr: Bus address used to access the memory region + * @dev_addr: Device address of the memory region from remote processor vi= ew + * @size: Size of the memory region + */ +struct k3_m4_rproc_mem { + void __iomem *cpu_addr; + phys_addr_t bus_addr; + u32 dev_addr; + size_t size; +}; + +/** + * struct k3_m4_rproc_mem_data - memory definitions for a remote processor + * @name: name for this memory entry + * @dev_addr: device address for the memory entry + */ +struct k3_m4_rproc_mem_data { + const char *name; + const u32 dev_addr; +}; + +/** + * struct k3_m4_rproc_dev_data - device data structure for a remote proces= sor + * @mems: pointer to memory definitions for a remote processor + * @num_mems: number of memory regions in @mems + * @uses_lreset: flag to denote the need for local reset management + */ +struct k3_m4_rproc_dev_data { + const struct k3_m4_rproc_mem_data *mems; + u32 num_mems; + bool uses_lreset; +}; + +/** + * struct k3_m4_rproc - k3 remote processor driver structure + * @dev: cached device pointer + * @rproc: remoteproc device handle + * @mem: internal memory regions data + * @num_mems: number of internal memory regions + * @rmem: reserved memory regions data + * @num_rmems: number of reserved memory regions + * @reset: reset control handle + * @data: pointer to device data + * @tsp: TI-SCI processor control handle + * @ti_sci: TI-SCI handle + * @ti_sci_id: TI-SCI device identifier + * @mbox: mailbox channel handle + * @client: mailbox client to request the mailbox channel + */ +struct k3_m4_rproc { + struct device *dev; + struct rproc *rproc; + struct k3_m4_rproc_mem *mem; + int num_mems; + struct k3_m4_rproc_mem *rmem; + int num_rmems; + struct reset_control *reset; + const struct k3_m4_rproc_dev_data *data; + struct ti_sci_proc *tsp; + const struct ti_sci_handle *ti_sci; + u32 ti_sci_id; + struct mbox_chan *mbox; + struct mbox_client client; +}; + +/** + * k3_m4_rproc_mbox_callback() - inbound mailbox message handler + * @client: mailbox client pointer used for requesting the mailbox channel + * @data: mailbox payload + * + * This handler is invoked by the K3 mailbox driver whenever a mailbox + * message is received. Usually, the mailbox payload simply contains + * the index of the virtqueue that is kicked by the remote processor, + * and we let remoteproc core handle it. + * + * In addition to virtqueue indices, we also have some out-of-band values + * that indicate different events. Those values are deliberately very + * large so they don't coincide with virtqueue indices. + */ +static void k3_m4_rproc_mbox_callback(struct mbox_client *client, void *da= ta) +{ + struct k3_m4_rproc *kproc =3D container_of(client, struct k3_m4_rproc, + client); + struct device *dev =3D kproc->rproc->dev.parent; + const char *name =3D kproc->rproc->name; + u32 msg =3D (u32)(uintptr_t)(data); + + dev_dbg(dev, "mbox msg: 0x%x\n", msg); + + switch (msg) { + case RP_MBOX_CRASH: + /* + * remoteproc detected an exception, but error recovery is not + * supported. So, just log this for now + */ + dev_err(dev, "K3 rproc %s crashed\n", name); + break; + case RP_MBOX_ECHO_REPLY: + dev_info(dev, "received echo reply from %s\n", name); + break; + default: + /* silently handle all other valid messages */ + if (msg >=3D RP_MBOX_READY && msg < RP_MBOX_END_MSG) + return; + if (msg > kproc->rproc->max_notifyid) { + dev_dbg(dev, "dropping unknown message 0x%x", msg); + return; + } + /* msg contains the index of the triggered vring */ + if (rproc_vq_interrupt(kproc->rproc, msg) =3D=3D IRQ_NONE) + dev_dbg(dev, "no message was found in vqid %d\n", msg); + } +} + +/* + * Kick the remote processor to notify about pending unprocessed messages. + * The vqid usage is not used and is inconsequential, as the kick is perfo= rmed + * through a simulated GPIO (a bit in an IPC interrupt-triggering register= ), + * the remote processor is expected to process both its Tx and Rx virtqueu= es. + */ +static void k3_m4_rproc_kick(struct rproc *rproc, int vqid) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + struct device *dev =3D rproc->dev.parent; + u32 msg =3D (u32)vqid; + int ret; + + /* send the index of the triggered virtqueue in the mailbox payload */ + ret =3D mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg); + if (ret < 0) + dev_err(dev, "failed to send mailbox message, status =3D %d\n", + ret); +} + +/* Put the remote processor into reset */ +static int k3_m4_rproc_reset(struct k3_m4_rproc *kproc) +{ + struct device *dev =3D kproc->dev; + int ret; + + ret =3D reset_control_assert(kproc->reset); + if (ret) { + dev_err(dev, "local-reset assert failed, ret =3D %d\n", ret); + return ret; + } + + if (kproc->data->uses_lreset) + return ret; + + ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) { + dev_err(dev, "module-reset assert failed, ret =3D %d\n", ret); + if (reset_control_deassert(kproc->reset)) + dev_warn(dev, "local-reset deassert back failed\n"); + } + + return ret; +} + +/* Release the remote processor from reset */ +static int k3_m4_rproc_release(struct k3_m4_rproc *kproc) +{ + struct device *dev =3D kproc->dev; + int ret; + + if (kproc->data->uses_lreset) + goto lreset; + + ret =3D kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) { + dev_err(dev, "module-reset deassert failed, ret =3D %d\n", ret); + return ret; + } + +lreset: + ret =3D reset_control_deassert(kproc->reset); + if (ret) { + dev_err(dev, "local-reset deassert failed, ret =3D %d\n", ret); + if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, + kproc->ti_sci_id)) + dev_warn(dev, "module-reset assert back failed\n"); + } + + return ret; +} + +static int k3_m4_rproc_request_mbox(struct rproc *rproc) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + struct mbox_client *client =3D &kproc->client; + struct device *dev =3D kproc->dev; + int ret; + + client->dev =3D dev; + client->tx_done =3D NULL; + client->rx_callback =3D k3_m4_rproc_mbox_callback; + client->tx_block =3D false; + client->knows_txdone =3D false; + + kproc->mbox =3D mbox_request_channel(client, 0); + if (IS_ERR(kproc->mbox)) { + ret =3D -EBUSY; + dev_err(dev, "mbox_request_channel failed: %ld\n", + PTR_ERR(kproc->mbox)); + return ret; + } + + /* + * Ping the remote processor, this is only for sanity-sake for now; + * there is no functional effect whatsoever. + * + * Note that the reply will _not_ arrive immediately: this message + * will wait in the mailbox fifo until the remote processor is booted. + */ + ret =3D mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); + if (ret < 0) { + dev_err(dev, "mbox_send_message failed: %d\n", ret); + mbox_free_channel(kproc->mbox); + return ret; + } + + return 0; +} + +/* + * The M4 cores have a local reset that affects only the CPU, and a + * generic module reset that powers on the device and allows the internal + * memories to be accessed while the local reset is asserted. This functio= n is + * used to release the global reset on remote cores to allow loading into = the + * internal RAMs. The .prepare() ops is invoked by remoteproc core before = any + * firmware loading, and is followed by the .start() ops after loading to + * actually let the remote cores to run. This callback is invoked only in + * remoteproc mode. + */ +static int k3_m4_rproc_prepare(struct rproc *rproc) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + struct device *dev =3D kproc->dev; + int ret; + + ret =3D kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) + dev_err(dev, "module-reset deassert failed, cannot enable internal RAM l= oading, ret =3D %d\n", + ret); + + return ret; +} + +/* + * This function implements the .unprepare() ops and performs the complime= ntary + * operations to that of the .prepare() ops. The function is used to asser= t the + * global reset on applicable cores. This completes the second portion of + * powering down the remote core. The cores themselves are only halted in = the + * .stop() callback through the local reset, and the .unprepare() ops is i= nvoked + * by the remoteproc core after the remoteproc is stopped to balance the g= lobal + * reset. This callback is invoked only in remoteproc mode. + */ +static int k3_m4_rproc_unprepare(struct rproc *rproc) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + struct device *dev =3D kproc->dev; + int ret; + + ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) + dev_err(dev, "module-reset assert failed, ret =3D %d\n", ret); + + return ret; +} + +/* + * This function implements the .get_loaded_rsc_table() callback and is us= ed + * to provide the resource table for a booted remote processor in IPC-only + * mode. The remote processor firmwares follow a design-by-contract approa= ch + * and are expected to have the resource table at the base of the DDR regi= on + * reserved for firmware usage. This provides flexibility for the remote + * processor to be booted by different bootloaders that may or may not hav= e the + * ability to publish the resource table address and size through a DT + * property. + */ +static struct resource_table *k3_m4_get_loaded_rsc_table(struct rproc *rpr= oc, + size_t *rsc_table_sz) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + struct device *dev =3D kproc->dev; + + if (!kproc->rmem[0].cpu_addr) { + dev_err(dev, "memory-region #1 does not exist, loaded rsc table can't be= found"); + return ERR_PTR(-ENOMEM); + } + + /* + * NOTE: The resource table size is currently hard-coded to a maximum + * of 256 bytes. The most common resource table usage for K3 firmwares + * is to only have the vdev resource entry and an optional trace entry. + * The exact size could be computed based on resource table address, but + * the hard-coded value suffices to support the IPC-only mode. + */ + *rsc_table_sz =3D 256; + return (__force struct resource_table *)kproc->rmem[0].cpu_addr; +} + +/* + * Custom function to translate a remote processor device address (internal + * RAMs only) to a kernel virtual address. The remote processors can acce= ss + * their RAMs at either an internal address visible only from a remote + * processor, or at the SoC-level bus address. Both these addresses need t= o be + * looked through for translation. The translated addresses can be used ei= ther + * by the remoteproc core for loading (when using kernel remoteproc loader= ), or + * by any rpmsg bus drivers. + */ +static void *k3_m4_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len,= bool *is_iomem) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + void __iomem *va =3D NULL; + phys_addr_t bus_addr; + u32 dev_addr, offset; + size_t size; + int i; + + if (len =3D=3D 0) + return NULL; + + for (i =3D 0; i < kproc->num_mems; i++) { + bus_addr =3D kproc->mem[i].bus_addr; + dev_addr =3D kproc->mem[i].dev_addr; + size =3D kproc->mem[i].size; + + /* handle M4-view addresses */ + if (da >=3D dev_addr && ((da + len) <=3D (dev_addr + size))) { + offset =3D da - dev_addr; + va =3D kproc->mem[i].cpu_addr + offset; + return (__force void *)va; + } + + /* handle SoC-view addresses */ + if (da >=3D bus_addr && ((da + len) <=3D (bus_addr + size))) { + offset =3D da - bus_addr; + va =3D kproc->mem[i].cpu_addr + offset; + return (__force void *)va; + } + } + + /* handle static DDR reserved memory regions */ + for (i =3D 0; i < kproc->num_rmems; i++) { + dev_addr =3D kproc->rmem[i].dev_addr; + size =3D kproc->rmem[i].size; + + if (da >=3D dev_addr && ((da + len) <=3D (dev_addr + size))) { + offset =3D da - dev_addr; + va =3D kproc->rmem[i].cpu_addr + offset; + return (__force void *)va; + } + } + + return NULL; +} + +static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, + struct k3_m4_rproc *kproc) +{ + const struct k3_m4_rproc_dev_data *data =3D kproc->data; + struct device *dev =3D &pdev->dev; + struct resource *res; + int num_mems =3D 0; + int i; + + num_mems =3D kproc->data->num_mems; + kproc->mem =3D devm_kcalloc(kproc->dev, num_mems, + sizeof(*kproc->mem), GFP_KERNEL); + if (!kproc->mem) + return -ENOMEM; + + for (i =3D 0; i < num_mems; i++) { + res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, + data->mems[i].name); + if (!res) { + dev_err(dev, "found no memory resource for %s\n", + data->mems[i].name); + return -EINVAL; + } + if (!devm_request_mem_region(dev, res->start, + resource_size(res), + dev_name(dev))) { + dev_err(dev, "could not request %s region for resource\n", + data->mems[i].name); + return -EBUSY; + } + + kproc->mem[i].cpu_addr =3D devm_ioremap_wc(dev, res->start, + resource_size(res)); + if (!kproc->mem[i].cpu_addr) { + dev_err(dev, "failed to map %s memory\n", + data->mems[i].name); + return -ENOMEM; + } + kproc->mem[i].bus_addr =3D res->start; + kproc->mem[i].dev_addr =3D data->mems[i].dev_addr; + kproc->mem[i].size =3D resource_size(res); + + dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n", + data->mems[i].name, &kproc->mem[i].bus_addr, + kproc->mem[i].size, kproc->mem[i].cpu_addr, + kproc->mem[i].dev_addr); + } + kproc->num_mems =3D num_mems; + + return 0; +} + +static void k3_m4_rproc_dev_mem_release(void *data) +{ + struct device *dev =3D data; + + of_reserved_mem_device_release(dev); +} + +static int k3_m4_reserved_mem_init(struct k3_m4_rproc *kproc) +{ + struct device *dev =3D kproc->dev; + struct device_node *np =3D dev->of_node; + struct device_node *rmem_np; + struct reserved_mem *rmem; + int num_rmems; + int ret, i; + + num_rmems =3D of_property_count_elems_of_size(np, "memory-region", + sizeof(phandle)); + if (num_rmems < 0) { + dev_err(dev, "device does not reserved memory regions (%pe)\n", + ERR_PTR(num_rmems)); + return -EINVAL; + } + if (num_rmems < 2) { + dev_err(dev, "device needs at least two memory regions to be defined, nu= m =3D %d\n", + num_rmems); + return -EINVAL; + } + + /* use reserved memory region 0 for vring DMA allocations */ + ret =3D of_reserved_mem_device_init_by_idx(dev, np, 0); + if (ret) { + dev_err(dev, "device cannot initialize DMA pool (%pe)\n", + ERR_PTR(ret)); + return ret; + } + ret =3D devm_add_action_or_reset(dev, k3_m4_rproc_dev_mem_release, dev); + if (ret) + return ret; + + num_rmems--; + kproc->rmem =3D devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KE= RNEL); + if (!kproc->rmem) + return -ENOMEM; + + /* use remaining reserved memory regions for static carveouts */ + for (i =3D 0; i < num_rmems; i++) { + rmem_np =3D of_parse_phandle(np, "memory-region", i + 1); + if (!rmem_np) + return -EINVAL; + + rmem =3D of_reserved_mem_lookup(rmem_np); + if (!rmem) { + of_node_put(rmem_np); + return -EINVAL; + } + of_node_put(rmem_np); + + kproc->rmem[i].bus_addr =3D rmem->base; + /* 64-bit address regions currently not supported */ + kproc->rmem[i].dev_addr =3D (u32)rmem->base; + kproc->rmem[i].size =3D rmem->size; + kproc->rmem[i].cpu_addr =3D devm_ioremap_wc(dev, rmem->base, rmem->size); + if (!kproc->rmem[i].cpu_addr) { + dev_err(dev, "failed to map reserved memory#%d at %pa of size %pa\n", + i + 1, &rmem->base, &rmem->size); + return -ENOMEM; + } + + dev_dbg(dev, "reserved memory%d: bus addr %pa size 0x%zx va %pK da 0x%x\= n", + i + 1, &kproc->rmem[i].bus_addr, + kproc->rmem[i].size, kproc->rmem[i].cpu_addr, + kproc->rmem[i].dev_addr); + } + kproc->num_rmems =3D num_rmems; + + return 0; +} + +static struct ti_sci_proc *k3_m4_rproc_of_get_tsp(struct device *dev, + const struct ti_sci_handle *sci) +{ + struct ti_sci_proc *tsp; + u32 temp[2]; + int ret; + + ret =3D of_property_read_u32_array(dev->of_node, "ti,sci-proc-ids", + temp, 2); + if (ret < 0) + return ERR_PTR(ret); + + tsp =3D devm_kzalloc(dev, sizeof(*tsp), GFP_KERNEL); + if (!tsp) + return ERR_PTR(-ENOMEM); + + tsp->dev =3D dev; + tsp->sci =3D sci; + tsp->ops =3D &sci->ops.proc_ops; + tsp->proc_id =3D temp[0]; + tsp->host_id =3D temp[1]; + + return tsp; +} + +static void k3_m4_release_tsp(void *data) +{ + struct ti_sci_proc *tsp =3D data; + + ti_sci_proc_release(tsp); +} + +/* + * Power up the M4F remote processor. + * + * This function will be invoked only after the firmware for this rproc + * was loaded, parsed successfully, and all of its resource requirements + * were met. This callback is invoked only in remoteproc mode. + */ +static int k3_m4_rproc_start(struct rproc *rproc) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + int ret; + + ret =3D k3_m4_rproc_request_mbox(rproc); + if (ret) + return ret; + + ret =3D k3_m4_rproc_release(kproc); + if (ret) + goto put_mbox; + + return 0; + +put_mbox: + mbox_free_channel(kproc->mbox); + return ret; +} + +/* + * Stop the M4 remote processor. + * + * This function puts the M4 processor into reset, and finishes processing + * of any pending messages. This callback is invoked only in remoteproc mo= de. + */ +static int k3_m4_rproc_stop(struct rproc *rproc) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + + mbox_free_channel(kproc->mbox); + + k3_m4_rproc_reset(kproc); + + return 0; +} + +/* + * Attach to a running M4 remote processor (IPC-only mode) + * + * This rproc attach callback only needs to request the mailbox, the remote + * processor is already booted, so there is no need to issue any TI-SCI + * commands to boot the M4 core. This callback is used only in IPC-only mo= de. + */ +static int k3_m4_rproc_attach(struct rproc *rproc) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + struct device *dev =3D kproc->dev; + int ret; + + ret =3D k3_m4_rproc_request_mbox(rproc); + if (ret) + return ret; + + dev_info(dev, "M4 initialized in IPC-only mode\n"); + return 0; +} + +/* + * Detach from a running M4 remote processor (IPC-only mode) + * + * This rproc detach callback performs the opposite operation to attach ca= llback + * and only needs to release the mailbox, the M4 core is not stopped and w= ill + * be left to continue to run its booted firmware. This callback is invoke= d only in + * IPC-only mode. + */ +static int k3_m4_rproc_detach(struct rproc *rproc) +{ + struct k3_m4_rproc *kproc =3D rproc->priv; + struct device *dev =3D kproc->dev; + + mbox_free_channel(kproc->mbox); + dev_info(dev, "M4 deinitialized in IPC-only mode\n"); + return 0; +} + +static const struct rproc_ops k3_m4_rproc_ops =3D { + .start =3D k3_m4_rproc_start, + .stop =3D k3_m4_rproc_stop, + .attach =3D k3_m4_rproc_attach, + .detach =3D k3_m4_rproc_detach, + .kick =3D k3_m4_rproc_kick, + .da_to_va =3D k3_m4_rproc_da_to_va, + .get_loaded_rsc_table =3D k3_m4_get_loaded_rsc_table, +}; + +static int k3_m4_rproc_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct device_node *np =3D dev->of_node; + const struct k3_m4_rproc_dev_data *data; + struct k3_m4_rproc *kproc; + struct rproc *rproc; + const char *fw_name; + bool r_state =3D false; + bool p_state =3D false; + int ret =3D 0; + + data =3D device_get_match_data(dev); + if (!data) + return -ENODEV; + + ret =3D rproc_of_parse_firmware(dev, 0, &fw_name); + if (ret) + return dev_err_probe(dev, ret, "failed to parse firmware-name property\n= "); + + rproc =3D devm_rproc_alloc(dev, dev_name(dev), &k3_m4_rproc_ops, fw_name, + sizeof(*kproc)); + if (!rproc) + return -ENOMEM; + + rproc->has_iommu =3D false; + rproc->recovery_disabled =3D true; + if (data->uses_lreset) { + rproc->ops->prepare =3D k3_m4_rproc_prepare; + rproc->ops->unprepare =3D k3_m4_rproc_unprepare; + } + kproc =3D rproc->priv; + kproc->rproc =3D rproc; + kproc->dev =3D dev; + kproc->data =3D data; + + kproc->ti_sci =3D devm_ti_sci_get_by_phandle(dev, "ti,sci"); + if (IS_ERR(kproc->ti_sci)) + return dev_err_probe(dev, PTR_ERR(kproc->ti_sci), + "failed to get ti-sci handle\n"); + + ret =3D of_property_read_u32(np, "ti,sci-dev-id", &kproc->ti_sci_id); + if (ret) + return dev_err_probe(dev, ret, "missing 'ti,sci-dev-id' property\n"); + + kproc->reset =3D devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(kproc->reset)) + return dev_err_probe(dev, PTR_ERR(kproc->reset), "failed to get reset\n"= ); + + kproc->tsp =3D k3_m4_rproc_of_get_tsp(dev, kproc->ti_sci); + if (IS_ERR(kproc->tsp)) + return dev_err_probe(dev, PTR_ERR(kproc->tsp), + "failed to construct ti-sci proc control\n"); + + ret =3D ti_sci_proc_request(kproc->tsp); + if (ret < 0) + return dev_err_probe(dev, ret, "ti_sci_proc_request failed\n"); + ret =3D devm_add_action_or_reset(dev, k3_m4_release_tsp, kproc->tsp); + if (ret) + return ret; + + ret =3D k3_m4_rproc_of_get_memories(pdev, kproc); + if (ret) + return ret; + + ret =3D k3_m4_reserved_mem_init(kproc); + if (ret) + return dev_err_probe(dev, ret, "reserved memory init failed\n"); + + ret =3D kproc->ti_sci->ops.dev_ops.is_on(kproc->ti_sci, kproc->ti_sci_id, + &r_state, &p_state); + if (ret) + return dev_err_probe(dev, ret, + "failed to get initial state, mode cannot be determined\n"); + + /* configure devices for either remoteproc or IPC-only mode */ + if (p_state) { + dev_info(dev, "configured M4 for IPC-only mode\n"); + rproc->state =3D RPROC_DETACHED; + /* override rproc ops with only required IPC-only mode ops */ + rproc->ops->prepare =3D NULL; + rproc->ops->unprepare =3D NULL; + rproc->ops->start =3D NULL; + rproc->ops->stop =3D NULL; + rproc->ops->attach =3D k3_m4_rproc_attach; + rproc->ops->detach =3D k3_m4_rproc_detach; + rproc->ops->get_loaded_rsc_table =3D k3_m4_get_loaded_rsc_table; + } else { + dev_info(dev, "configured M4 for remoteproc mode\n"); + /* + * ensure the M4 local reset is asserted to ensure the core + * doesn't execute bogus code in .prepare() when the module + * reset is released. + */ + if (data->uses_lreset) { + ret =3D reset_control_status(kproc->reset); + if (ret < 0) { + return dev_err_probe(dev, ret, "failed to get reset status\n"); + } else if (ret =3D=3D 0) { + dev_warn(dev, "local reset is deasserted for device\n"); + k3_m4_rproc_reset(kproc); + } + } + } + + ret =3D devm_rproc_add(dev, rproc); + if (ret) + return dev_err_probe(dev, ret, + "failed to add register device with remoteproc core\n"); + + return 0; +} + +static const struct k3_m4_rproc_mem_data am64_m4_mems[] =3D { + { .name =3D "iram", .dev_addr =3D 0x0 }, + { .name =3D "dram", .dev_addr =3D 0x30000 }, +}; + +static const struct k3_m4_rproc_dev_data am64_m4_data =3D { + .mems =3D am64_m4_mems, + .num_mems =3D ARRAY_SIZE(am64_m4_mems), + .uses_lreset =3D true, +}; + +static const struct of_device_id k3_m4_of_match[] =3D { + { .compatible =3D "ti,am64-m4fss", .data =3D &am64_m4_data, }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, k3_m4_of_match); + +static struct platform_driver k3_m4_rproc_driver =3D { + .probe =3D k3_m4_rproc_probe, + .driver =3D { + .name =3D "k3-m4-rproc", + .of_match_table =3D k3_m4_of_match, + }, +}; +module_platform_driver(k3_m4_rproc_driver); + +MODULE_AUTHOR("Hari Nagalla "); +MODULE_DESCRIPTION("TI K3 M4 Remoteproc driver"); +MODULE_LICENSE("GPL"); --=20 2.39.2 From nobody Sun May 19 11:31:13 2024 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 1A99F200D2; Fri, 26 Apr 2024 19:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159120; cv=none; b=nkHWmSUBi2UtYQmuWGG2yjygsjsFDbctPUf9JP3vhA0gGOafcR2V8hftqcfHZSp703gA7xhNAEnpO4DnfzvGICK8k8osgXvrJ3AFxwpM7kahVJoAcCgvGE58N0rLOVTCY4n0tBvS1yAN6Tb6n2zgFNknFp3diFZUaEWFiBpmPu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159120; c=relaxed/simple; bh=wJsCI19agUS/+MDtWAcxAkIEF3QnROOx2B5PuQc8Zzs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RmJr8XdDtLrv/lTIJFtUSeHVIiml5aLxpUZWNMCMGJthApA1OYSIgSWuArY/FFnv0OhjLqMEb2ccBMFedEvX/h+khidRH3Tuv5VRK9EnrQWGyZJ2SQzk9BjXiDRwGdu9bZHbxA4LAn87Xb00yHUKDQTbR1NOslPiuy6m4z061m0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=usX6ZvE5; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="usX6ZvE5" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43QJICTt019122; Fri, 26 Apr 2024 14:18:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714159092; bh=p1qJqUmMe3OjDBoC0B0IMbNgNhv2d238EMpmqMU4dbg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=usX6ZvE57JMAnAn3MWaDCUK6DJH7s+niOT134bzurzvx3LonLN4gVA8u7Y5h3Fs4z IfRDfnuacYBRk0b2tv2akUcGgzWbTWUmq9B3YeIpCm87DVmp0WxFSdXvzlpkEQm5ur Oh5rRzProKV6aCAD3DnifvwO///GVsOrEa1wowsc= Received: from DFLE101.ent.ti.com (dfle101.ent.ti.com [10.64.6.22]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43QJICMt053572 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Apr 2024 14:18:12 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 26 Apr 2024 14:18:11 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 26 Apr 2024 14:18:11 -0500 Received: from ula0226330.dhcp.ti.com (ula0226330.dhcp.ti.com [128.247.81.8]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43QJIB7M028593; Fri, 26 Apr 2024 14:18:11 -0500 From: Andrew Davis To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Philipp Zabel , Hari Nagalla CC: , , , , Andrew Davis Subject: [PATCH v9 3/5] arm64: dts: ti: k3-am62: Add M4F remoteproc node Date: Fri, 26 Apr 2024 14:18:09 -0500 Message-ID: <20240426191811.32414-4-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426191811.32414-1-afd@ti.com> References: <20240426191811.32414-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" From: Hari Nagalla The AM62x SoCs of the TI K3 family have a Cortex M4F core in the MCU domain. This core can be used by non safety applications as a remote processor. When used as a remote processor with virtio/rpmessage IPC, two carveout reserved memory nodes are needed. Disable by default as this node is not complete until mailbox data is provided in the board level DT. Signed-off-by: Hari Nagalla Signed-off-by: Andrew Davis --- arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi b/arch/arm64/boot/dts/= ti/k3-am62-mcu.dtsi index e66d486ef1f21..7f6f0007e8e81 100644 --- a/arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi +++ b/arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi @@ -173,4 +173,17 @@ mcu_mcan1: can@4e18000 { bosch,mram-cfg =3D <0x0 128 64 64 64 64 32 32>; status =3D "disabled"; }; + + mcu_m4fss: m4fss@5000000 { + compatible =3D "ti,am64-m4fss"; + reg =3D <0x00 0x5000000 0x00 0x30000>, + <0x00 0x5040000 0x00 0x10000>; + reg-names =3D "iram", "dram"; + resets =3D <&k3_reset 9 1>; + firmware-name =3D "am62-mcu-m4f0_0-fw"; + ti,sci =3D <&dmsc>; + ti,sci-dev-id =3D <9>; + ti,sci-proc-ids =3D <0x18 0xff>; + status =3D "disabled"; + }; }; --=20 2.39.2 From nobody Sun May 19 11:31:13 2024 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 204E02032A; Fri, 26 Apr 2024 19:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159119; cv=none; b=OxBi/D2MULNfLTuKr+1fxO4DYgItbJ71WJN/caMhn9pYjRMRI1c9mO2qahkdE7X4DaOxOrwUcTocxPU8cCcGZwj3QJJR3qd0Jd5cxw7wIfY9c5FBwp2qkh8S5BIZB9TVx+hj8rmM3gzyTj5bETTY4XKZnVoF6fgjoZTv4TfdpGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159119; c=relaxed/simple; bh=nsZCppXmh8lxPmCUagHvnCSHS+UbJBgIFsgwfI9awYY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NJ5Bwt5zHXjVWEyBgv3lt6repFCDUl23CigZYwnouw3tO3I2DvF1suu95DBbccmiiYeFk3QpKuD5LpGJ9H6TvzabUYJhum/2i+S0DmI4/o4tJ+aWvzxBVVVx7safyGHLsDxNL762sqP4XXc4Hn0PsS9FcqZvY5ilrUHp/HdFq2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Pl28dfna; arc=none smtp.client-ip=198.47.19.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Pl28dfna" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43QJICN6116104; Fri, 26 Apr 2024 14:18:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714159092; bh=IUAoumEhy+wq6Tu6vsgEuKclmExrdXZar+JrMRHsA5Q=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Pl28dfnaRKqoau+A+nDvWZM6lkRvR75DV5kO2Hcl8YHk57ydFfDn/+JbIU2wvhfOp +Tww68PBw/G/teKRmbDiA+B1CZhqWIKgqgtcd1wYy1nKmvJhLQdeCK1VKlvhgaMrfX IyCBEnLHGPcKQ9wWlIDaHKpaGaxuzLVq86TrEcfE= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43QJICTk001742 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Apr 2024 14:18:12 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 26 Apr 2024 14:18:12 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 26 Apr 2024 14:18:12 -0500 Received: from ula0226330.dhcp.ti.com (ula0226330.dhcp.ti.com [128.247.81.8]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43QJIB7N028593; Fri, 26 Apr 2024 14:18:12 -0500 From: Andrew Davis To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Philipp Zabel , Hari Nagalla CC: , , , , Andrew Davis Subject: [PATCH v9 4/5] arm64: dts: ti: k3-am625-sk: Add M4F remoteproc node Date: Fri, 26 Apr 2024 14:18:10 -0500 Message-ID: <20240426191811.32414-5-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426191811.32414-1-afd@ti.com> References: <20240426191811.32414-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" From: Hari Nagalla The AM62x SoCs of the TI K3 family have a Cortex M4F core in the MCU domain. This core can be used by non safety applications as a remote processor. When used as a remote processor with virtio/rpmessage IPC, two carveout reserved memory nodes are needed. The first region is used as a DMA pool for the rproc device, and the second region will furnish the static carveout regions for the firmware memory. The current carveout addresses and sizes are defined statically for each rproc device. The M4F processor does not have an MMU, and as such requires the exact memory used by the firmware to be set-aside. Signed-off-by: Hari Nagalla Signed-off-by: Andrew Davis --- .../arm64/boot/dts/ti/k3-am62x-sk-common.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi b/arch/arm64/bo= ot/dts/ti/k3-am62x-sk-common.dtsi index 3c45782ab2b78..167bec5c80006 100644 --- a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi +++ b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi @@ -48,6 +48,18 @@ ramoops@9ca00000 { pmsg-size =3D <0x8000>; }; =20 + mcu_m4fss_dma_memory_region: m4f-dma-memory@9cb00000 { + compatible =3D "shared-dma-pool"; + reg =3D <0x00 0x9cb00000 0x00 0x100000>; + no-map; + }; + + mcu_m4fss_memory_region: m4f-memory@9cc00000 { + compatible =3D "shared-dma-pool"; + reg =3D <0x00 0x9cc00000 0x00 0xe00000>; + no-map; + }; + secure_tfa_ddr: tfa@9e780000 { reg =3D <0x00 0x9e780000 0x00 0x80000>; alignment =3D <0x1000>; @@ -457,6 +469,13 @@ mbox_m4_0: mbox-m4-0 { }; }; =20 +&mcu_m4fss { + mboxes =3D <&mailbox0_cluster0 &mbox_m4_0>; + memory-region =3D <&mcu_m4fss_dma_memory_region>, + <&mcu_m4fss_memory_region>; + status =3D "okay"; +}; + &usbss0 { bootph-all; status =3D "okay"; --=20 2.39.2 From nobody Sun May 19 11:31:13 2024 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 B55AA208D6; Fri, 26 Apr 2024 19:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159120; cv=none; b=HoGgpzF+drTpAsDZ5Zwj2vx40cbQgVJyP2U6UvspG/VvEW+Gh9VjEsxVNYytzgPsXW1Zby0SkCBc7/rv80hE8fVDvUy6WilXfFre2A3nNSeZf5cXAkM2tqpnPEAlq/uCRlObA87cjHc2yZYrp9VQeyxPNmXZH6oOE588RYFeVTo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714159120; c=relaxed/simple; bh=LjOOh654N028PKm9hKjjINIwDhnYd4OGHM8FU+b5J68=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z3C5JdsdJNZ0yn8O6lDR9bOCymFztCYsREKBXIFxJX73OMUDgQFPottHr/rJgT64OrsOrW90TM4Qv2jGkILVJl1xHzSB+3QbhozzB6MfGaPdUDaqSsL5As6vZJgJymOvF86rLHpjoWZlRvecEiaGxhcbeFxi9H1WoBqG/EMOpmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=u7guXwcG; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="u7guXwcG" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43QJICTW099384; Fri, 26 Apr 2024 14:18:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714159092; bh=EeEnTqm3oLoWS+b5dZcuC693obg0Ef8ytBl/uzoDfOk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=u7guXwcGuzEUdmIcJoD4OGP2xPPre4gy/A53rrjjC1D21VJC4b/HaVTkXACnY0i91 4Zgy1B9IsUDt1c9+FCg+BnOz9hPYi1V/VKk8huCjmArWis6AmsiZrAxpvgVlLa4OR5 vI4JVqkPP4ipji1TivS6kq4dTgPHf6g7APbEaET8= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43QJICLE040924 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Apr 2024 14:18:12 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 26 Apr 2024 14:18:12 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 26 Apr 2024 14:18:12 -0500 Received: from ula0226330.dhcp.ti.com (ula0226330.dhcp.ti.com [128.247.81.8]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43QJIB7O028593; Fri, 26 Apr 2024 14:18:12 -0500 From: Andrew Davis To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Philipp Zabel , Hari Nagalla CC: , , , , Andrew Davis Subject: [PATCH v9 5/5] arm64: defconfig: Enable TI K3 M4 remoteproc driver Date: Fri, 26 Apr 2024 14:18:11 -0500 Message-ID: <20240426191811.32414-6-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426191811.32414-1-afd@ti.com> References: <20240426191811.32414-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" From: Hari Nagalla Some K3 platform devices (AM64x, AM62x) have a Cortex M4 core. Build the M4 remote proc driver as a module for these platforms. Signed-off-by: Hari Nagalla Signed-off-by: Andrew Davis --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 2c30d617e1802..04e8e2ca4aa10 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -1352,6 +1352,7 @@ CONFIG_QCOM_Q6V5_PAS=3Dm CONFIG_QCOM_SYSMON=3Dm CONFIG_QCOM_WCNSS_PIL=3Dm CONFIG_TI_K3_DSP_REMOTEPROC=3Dm +CONFIG_TI_K3_M4_REMOTEPROC=3Dm CONFIG_TI_K3_R5_REMOTEPROC=3Dm CONFIG_RPMSG_CHAR=3Dm CONFIG_RPMSG_CTRL=3Dm --=20 2.39.2