Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1115159pxb; Wed, 6 Apr 2022 09:04:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvUTItGPKtVpfCSkMBTfEatu1VzkbBYZ0s1Evve5LhcxGAZW/rxYEq6hmzCdlLVVSJzSUG X-Received: by 2002:a63:1d07:0:b0:398:e6d3:8e22 with SMTP id d7-20020a631d07000000b00398e6d38e22mr7527643pgd.8.1649261071701; Wed, 06 Apr 2022 09:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649261071; cv=none; d=google.com; s=arc-20160816; b=o/cuDI0xSn7BxEgarknjf+D0o0x7yVHhguNdvO1TNQl8N3hLQA2d6X2v/WVri0nf1P jw9gyv49jVwzkJfYY6PDX/KEI4hMY0FV7nqcdcKgAUfrPeq33OA7ru561Qgd1euyvEIu ibWEm1FFILTQCgWrEtPl+rUSjSSnxJC1BGu/FlXm4iiQcsr54DZef+G0ROCJIEBtYHJ2 mENW5RjXZOqJupn9nDwATYkSggccSE4ivhLj9Vh7NKjnK1in4Nl1ES6tuyso2WmdgqsM FyGZ59Ri3Wa+87bWP4CWA5TM3KxV8sgWIJNBd99S8jGV24FBsQto0a8Omm9lIBOYmJYJ 6qkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bOueUZzyW20sYdI3Y7AsG+jWAy7mLl38rubmozgTXVo=; b=r68jhPuLqvGisWSO/Jh6doV1nFBTnyhQ2QpmtYWjHG4PoH0vbeOo39GSMX7DGBvkZc G3zzJGPxDDwxOemOgjYMaQX0Uejncrewiyf+7cqgeU0Vcti3iid1CfC8d2jZVbU/8Sf8 KDMBi2u5PzYPFOESDqa5W2wKfyASXRG481YCO3HhLRdTCLRjaBq8JqANhE1rg1qD8Pde pSpE2Op+NDC7CWd1DYWzCcLgzN5mCvxvItZLKzEFaRijbgKUzVIRx8lBhEza3VBnpKR/ td4b7fhpUwvSBOs3vDvtIiXDYYnNkhqx6IX8NywruQ58JSoT5SO/iB03iun/3g+Nh1QY zDXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DEdUB0rY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ob8-20020a17090b390800b001bf6d2ed1a3si5904091pjb.31.2022.04.06.09.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:04:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DEdUB0rY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 439F54B1962; Wed, 6 Apr 2022 07:29:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234666AbiDFOas (ORCPT + 99 others); Wed, 6 Apr 2022 10:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234936AbiDFOaU (ORCPT ); Wed, 6 Apr 2022 10:30:20 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87B3123C0F1; Wed, 6 Apr 2022 03:46:27 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2369iTYO059331; Wed, 6 Apr 2022 04:44:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1649238269; bh=bOueUZzyW20sYdI3Y7AsG+jWAy7mLl38rubmozgTXVo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DEdUB0rYvXnBUEhJftLPZACNDQDHdhCdDL6JjR5pq5uJTTJ7ELfg9WQXqqIbNf+1h UrA1nv5WIXbOBAkgfiAjnUPZxv5OiV9eICC6Qa510Xm4zlT7FjPCQsFrdBLy4nZ2mp AtZLt23AMf04VDbsbaH62xFIXxkNfaViIbV6LRd0= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2369iTbP014883 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 6 Apr 2022 04:44:29 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Wed, 6 Apr 2022 04:44:28 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Wed, 6 Apr 2022 04:44:28 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2369iRg1025885; Wed, 6 Apr 2022 04:44:28 -0500 From: Puranjay Mohan To: CC: , , , , , , , , , , , , , , Subject: [RFC 10/13] soc: ti: pruss: Add helper function to enable OCP master ports Date: Wed, 6 Apr 2022 15:13:55 +0530 Message-ID: <20220406094358.7895-11-p-mohan@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220406094358.7895-1-p-mohan@ti.com> References: <20220406094358.7895-1-p-mohan@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suman Anna The PRU-ICSS subsystem on OMAP-architecture based SoCS (AM33xx, AM437x and AM57xx SoCs) has a control bit STANDBY_INIT in the PRUSS_CFG register to initiate a Standby sequence (when set) and trigger a MStandby request to the SoC's PRCM module. This same bit is also used to enable the OCP master ports (when cleared). The clearing of the STANDBY_INIT bit requires an acknowledgment from PRCM and is done through the monitoring of the PRUSS_SYSCFG.SUB_MWAIT bit. Add a helper function pruss_cfg_ocp_master_ports() to allow the PRU client drivers to control this bit and enable or disable the firmware running on PRU cores access to any peripherals or memory to achieve desired functionality. The access is disabled by default on power-up and on any suspend (context is not maintained). Signed-off-by: Suman Anna Co-developed-by: Grzegorz Jaszczyk Signed-off-by: Grzegorz Jaszczyk Signed-off-by: Puranjay Mohan --- drivers/soc/ti/pruss.c | 81 ++++++++++++++++++++++++++++++++++++++++-- include/linux/pruss.h | 6 ++++ 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c index 9ef15daa405a..dbc1700d3176 100644 --- a/drivers/soc/ti/pruss.c +++ b/drivers/soc/ti/pruss.c @@ -22,14 +22,19 @@ #include #include +#define SYSCFG_STANDBY_INIT BIT(4) +#define SYSCFG_SUB_MWAIT_READY BIT(5) + /** * struct pruss_private_data - PRUSS driver private data * @has_no_sharedram: flag to indicate the absence of PRUSS Shared Data RAM * @has_core_mux_clock: flag to indicate the presence of PRUSS core clock + * @has_ocp_syscfg: flag to indicate if OCP SYSCFG is present */ struct pruss_private_data { bool has_no_sharedram; bool has_core_mux_clock; + bool has_ocp_syscfg; }; /** @@ -205,6 +210,72 @@ int pruss_cfg_update(struct pruss *pruss, unsigned int reg, } EXPORT_SYMBOL_GPL(pruss_cfg_update); +/** + * pruss_cfg_ocp_master_ports() - configure PRUSS OCP master ports + * @pruss: the pruss instance handle + * @enable: set to true for enabling or false for disabling the OCP master ports + * + * This function programs the PRUSS_SYSCFG.STANDBY_INIT bit either to enable or + * disable the OCP master ports (applicable only on SoCs using OCP interconnect + * like the OMAP family). Clearing the bit achieves dual functionalities - one + * is to deassert the MStandby signal to the device PRCM, and the other is to + * enable OCP master ports to allow accesses outside of the PRU-ICSS. The + * function has to wait for the PRCM to acknowledge through the monitoring of + * the PRUSS_SYSCFG.SUB_MWAIT bit when enabling master ports. Setting the bit + * disables the master access, and also signals the PRCM that the PRUSS is ready + * for Standby. + * + * Return: 0 on success, or an error code otherwise. ETIMEDOUT is returned + * when the ready-state fails. + */ +int pruss_cfg_ocp_master_ports(struct pruss *pruss, bool enable) +{ + int ret; + u32 syscfg_val, i; + const struct pruss_private_data *data; + + if (IS_ERR_OR_NULL(pruss)) + return -EINVAL; + + data = of_device_get_match_data(pruss->dev); + + /* nothing to do on non OMAP-SoCs */ + if (!data || !data->has_ocp_syscfg) + return 0; + + /* assert the MStandby signal during disable path */ + if (!enable) + return pruss_cfg_update(pruss, PRUSS_CFG_SYSCFG, + SYSCFG_STANDBY_INIT, + SYSCFG_STANDBY_INIT); + + /* enable the OCP master ports and disable MStandby */ + ret = pruss_cfg_update(pruss, PRUSS_CFG_SYSCFG, SYSCFG_STANDBY_INIT, 0); + if (ret) + return ret; + + /* wait till we are ready for transactions - delay is arbitrary */ + for (i = 0; i < 10; i++) { + ret = pruss_cfg_read(pruss, PRUSS_CFG_SYSCFG, &syscfg_val); + if (ret) + goto disable; + + if (!(syscfg_val & SYSCFG_SUB_MWAIT_READY)) + return 0; + + udelay(5); + } + + dev_err(pruss->dev, "timeout waiting for SUB_MWAIT_READY\n"); + ret = -ETIMEDOUT; + +disable: + pruss_cfg_update(pruss, PRUSS_CFG_SYSCFG, SYSCFG_STANDBY_INIT, + SYSCFG_STANDBY_INIT); + return ret; +} +EXPORT_SYMBOL_GPL(pruss_cfg_ocp_master_ports); + static void pruss_of_free_clk_provider(void *data) { struct device_node *clk_mux_np = data; @@ -496,10 +567,16 @@ static int pruss_remove(struct platform_device *pdev) /* instance-specific driver private data */ static const struct pruss_private_data am437x_pruss1_data = { .has_no_sharedram = false, + .has_ocp_syscfg = true, }; static const struct pruss_private_data am437x_pruss0_data = { .has_no_sharedram = true, + .has_ocp_syscfg = false, +}; + +static const struct pruss_private_data am33xx_am57xx_data = { + .has_ocp_syscfg = true, }; static const struct pruss_private_data am65x_j721e_pruss_data = { @@ -507,10 +584,10 @@ static const struct pruss_private_data am65x_j721e_pruss_data = { }; static const struct of_device_id pruss_of_match[] = { - { .compatible = "ti,am3356-pruss" }, + { .compatible = "ti,am3356-pruss", .data = &am33xx_am57xx_data }, { .compatible = "ti,am4376-pruss0", .data = &am437x_pruss0_data, }, { .compatible = "ti,am4376-pruss1", .data = &am437x_pruss1_data, }, - { .compatible = "ti,am5728-pruss" }, + { .compatible = "ti,am5728-pruss", .data = &am33xx_am57xx_data }, { .compatible = "ti,k2g-pruss" }, { .compatible = "ti,am654-icssg", .data = &am65x_j721e_pruss_data, }, { .compatible = "ti,j721e-icssg", .data = &am65x_j721e_pruss_data, }, diff --git a/include/linux/pruss.h b/include/linux/pruss.h index 84e95eb884e9..7e5e904521ac 100644 --- a/include/linux/pruss.h +++ b/include/linux/pruss.h @@ -163,6 +163,7 @@ int pruss_release_mem_region(struct pruss *pruss, int pruss_cfg_read(struct pruss *pruss, unsigned int reg, unsigned int *val); int pruss_cfg_update(struct pruss *pruss, unsigned int reg, unsigned int mask, unsigned int val); +int pruss_cfg_ocp_master_ports(struct pruss *pruss, bool enable); #else @@ -198,6 +199,11 @@ static inline int pruss_cfg_update(struct pruss *pruss, unsigned int reg, return -EOPNOTSUPP; } +static inline int pruss_cfg_ocp_master_ports(struct pruss *pruss, bool enable) +{ + return -EOPNOTSUPP; +} + #endif /* CONFIG_TI_PRUSS */ #if IS_ENABLED(CONFIG_PRU_REMOTEPROC) -- 2.17.1