Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9688BC47082 for ; Mon, 7 Jun 2021 14:18:44 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF62761029 for ; Mon, 7 Jun 2021 14:18:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF62761029 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B57482E7C; Mon, 7 Jun 2021 16:18:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="SOuCibwR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 594F7814A4; Mon, 7 Jun 2021 16:18:09 +0200 (CEST) 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 phobos.denx.de (Postfix) with ESMTPS id 956A980EC0 for ; Mon, 7 Jun 2021 16:18:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vigneshr@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 157EI3Ns087313 for ; Mon, 7 Jun 2021 09:18:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1623075483; bh=VMcDm9ls+t/6titgvV5yliIWz+b/eiJrF24PwADfc20=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SOuCibwRYeFrHoJZShllXnV503xWgOcsyddS3lfWgMoSr28xFgXXUrTfRJvhXY3Cf vQnYw+F8yrWvQmBHjsC+ONDH9dlNrlFJeDQEdaqwRzc03tzcXFbZUyGkQdd7eljezN 3x0QDqpCMv9EArPRPCpA8gLti9R4RrfOBysinVwg= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 157EI3tV122780 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 7 Jun 2021 09:18:03 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 7 Jun 2021 09:18:03 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Mon, 7 Jun 2021 09:18:03 -0500 Received: from ula0132425.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 157EHtHf111045; Mon, 7 Jun 2021 09:18:01 -0500 From: Vignesh Raghavendra To: Lokesh Vutla CC: Vignesh Raghavendra , Subject: [PATCH v2 3/7] firmware: ti_sci: Add support for Resoure Management at R5 SPL stage. Date: Mon, 7 Jun 2021 19:47:49 +0530 Message-ID: <20210607141753.28796-4-vigneshr@ti.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210607141753.28796-1-vigneshr@ti.com> References: <20210607141753.28796-1-vigneshr@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean On J721e and J7200, MCU R5 core (boot master) itself would run Device Manager (DM) Firmware and interact with TI Foundational Security (TIFS) firmware to enable DMA and such other Resource Management (RM) services. So, during R5 SPL stage there is no such RM service available and ti_sci driver will have to directly interact with TIFS using DM to DMSC channels to request RM resources. Therefore add DT binding and driver for the same. This driver will handle Resource Management services at R5 SPL stage. Signed-off-by: Vignesh Raghavendra --- .../firmware/ti,j721e-dm-sci.txt | 32 +++++++ drivers/firmware/ti_sci.c | 91 +++++++++++++++++-- 2 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 doc/device-tree-bindings/firmware/ti,j721e-dm-sci.txt diff --git a/doc/device-tree-bindings/firmware/ti,j721e-dm-sci.txt b/doc/device-tree-bindings/firmware/ti,j721e-dm-sci.txt new file mode 100644 index 0000000000..0217341f0c --- /dev/null +++ b/doc/device-tree-bindings/firmware/ti,j721e-dm-sci.txt @@ -0,0 +1,32 @@ +Bindings for Texas Instruments System Control Interface (TI-SCI) Message +Protocol for Device Manager(DM) to TI Foundational Security(TIFS) +Firmware communication + +Required properties: +-------------------- +- compatible: should be "ti,j721e-dm-sci" +- mbox-names: + "rx" - Mailbox corresponding to receive path + "tx" - Mailbox corresponding to transmit path + +- mboxes: Mailboxes corresponding to the mbox-names. Each value of the mboxes + property should contain a phandle to the mailbox controller device + node and an args specifier that will be the phandle to the intended + sub-mailbox child node to be used for communication. + +- ti,host-id: Host ID to use for communication. + +Optional Properties: +-------------------- +- ti,secure-host: If the host is defined as secure. + +Example: +-------- + dm_tifs: dm-tifs { + compatible = "ti,j721e-dm-sci"; + ti,host-id = <3>; + ti,secure-host; + mbox-names = "rx", "tx"; + mboxes= <&mcu_secproxy 21>, + <&mcu_secproxy 23>; + }; diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 0318da208e..0b6ba35b59 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -1670,8 +1670,9 @@ fail: } static int __maybe_unused -ti_sci_get_resource_range_static(u32 dev_id, u8 subtype, u16 *range_start, - u16 *range_num) +ti_sci_cmd_get_resource_range_static(const struct ti_sci_handle *handle, + u32 dev_id, u8 subtype, + u16 *range_start, u16 *range_num) { struct ti_sci_resource_static_data *data; int i = 0; @@ -1712,11 +1713,6 @@ static int ti_sci_cmd_get_resource_range(const struct ti_sci_handle *handle, u32 dev_id, u8 subtype, u16 *range_start, u16 *range_num) { - if (CONFIG_IS_ENABLED(TI_K3_RAW_RM)) - return ti_sci_get_resource_range_static(dev_id, subtype, - range_start, - range_num); - return ti_sci_get_resource_range(handle, dev_id, subtype, TI_SCI_IRQ_SECONDARY_HOST_INVALID, range_start, range_num); @@ -1740,9 +1736,6 @@ int ti_sci_cmd_get_resource_range_from_shost(const struct ti_sci_handle *handle, u32 dev_id, u8 subtype, u8 s_host, u16 *range_start, u16 *range_num) { - if (CONFIG_IS_ENABLED(TI_K3_RAW_RM)) - return -EINVAL; - return ti_sci_get_resource_range(handle, dev_id, subtype, s_host, range_start, range_num); } @@ -3052,6 +3045,58 @@ static int ti_sci_probe(struct udevice *dev) return ret; } +/** + * ti_sci_dm_probe() - Basic probe for DM to TIFS SCI + * @dev: corresponding system controller interface device + * + * Return: 0 if all goes good, else appropriate error message. + */ +static __maybe_unused int ti_sci_dm_probe(struct udevice *dev) +{ + struct ti_sci_rm_core_ops *rm_core_ops; + struct ti_sci_rm_udmap_ops *udmap_ops; + struct ti_sci_rm_ringacc_ops *rops; + struct ti_sci_rm_psil_ops *psilops; + struct ti_sci_ops *ops; + struct ti_sci_info *info; + int ret; + + debug("%s(dev=%p)\n", __func__, dev); + + info = dev_get_priv(dev); + info->desc = (void *)dev_get_driver_data(dev); + + ret = ti_sci_of_to_info(dev, info); + if (ret) { + dev_err(dev, "%s: Probe failed with error %d\n", __func__, ret); + return ret; + } + + info->dev = dev; + info->seq = 0xA; + + list_add_tail(&info->list, &ti_sci_list); + + ops = &info->handle.ops; + + rm_core_ops = &ops->rm_core_ops; + rm_core_ops->get_range = ti_sci_cmd_get_resource_range_static; + + rops = &ops->rm_ring_ops; + rops->config = ti_sci_cmd_ring_config; + + psilops = &ops->rm_psil_ops; + psilops->pair = ti_sci_cmd_rm_psil_pair; + psilops->unpair = ti_sci_cmd_rm_psil_unpair; + + udmap_ops = &ops->rm_udmap_ops; + udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg; + udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg; + udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg; + + return ret; +} + /* * ti_sci_get_free_resource() - Get a free resource from TISCI resource. * @res: Pointer to the TISCI resource @@ -3189,6 +3234,14 @@ static const struct ti_sci_desc ti_sci_pmmc_am654_desc = { .max_msg_size = 60, }; +/* Description for J721e DM to DMSC communication */ +static const struct ti_sci_desc ti_sci_dm_j721e_desc = { + .default_host_id = 3, + .max_rx_timeout_ms = 10000, + .max_msgs = 20, + .max_msg_size = 60, +}; + static const struct udevice_id ti_sci_ids[] = { { .compatible = "ti,k2g-sci", @@ -3201,6 +3254,14 @@ static const struct udevice_id ti_sci_ids[] = { { /* Sentinel */ }, }; +static __maybe_unused const struct udevice_id ti_sci_dm_ids[] = { + { + .compatible = "ti,j721e-dm-sci", + .data = (ulong)&ti_sci_dm_j721e_desc + }, + { /* Sentinel */ }, +}; + U_BOOT_DRIVER(ti_sci) = { .name = "ti_sci", .id = UCLASS_FIRMWARE, @@ -3208,3 +3269,13 @@ U_BOOT_DRIVER(ti_sci) = { .probe = ti_sci_probe, .priv_auto = sizeof(struct ti_sci_info), }; + +#if IS_ENABLED(CONFIG_K3_DM_FW) +U_BOOT_DRIVER(ti_sci_dm) = { + .name = "ti_sci_dm", + .id = UCLASS_FIRMWARE, + .of_match = ti_sci_dm_ids, + .probe = ti_sci_dm_probe, + .priv_auto = sizeof(struct ti_sci_info), +}; +#endif -- 2.31.1