Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2677221pxb; Mon, 18 Apr 2022 06:08:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx0g1T4Dz09q85iaAPRmIk6+8wZN59V6txufwwFnq9H+SzLfq86tPpq8OcZVnWWU7o8RR2 X-Received: by 2002:a05:6e02:1486:b0:2cc:3ee4:f27f with SMTP id n6-20020a056e02148600b002cc3ee4f27fmr245159ilk.67.1650287332141; Mon, 18 Apr 2022 06:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650287332; cv=none; d=google.com; s=arc-20160816; b=RMrqcUUIkhY52ZgyovkXSx2ftsFtNHm+44YmIK1Wwcibkes535j2Qprk1aHOV3uNzx lyVXbmUEPvXoZfo5k6ROK3W+TzDVZXieFgQtAh8meM7EbiqAeu0z+lGFJ1POfoxSrtV5 jcknUZy19Q7oZ0BQgaf0X1XoFiS8TXOnh0Fsjh/tkfdUclGeeVbmtndyJEk7GYa2x0l0 S2q2w2piRb3EsOgALAvoRMOqmbzhdVkLEwM+pjIFGm46sn89hNSeQlWV+XS7O87hbDG+ DktIneP48ctjAx8VeHIOhr+iTTwVgC8o8cDJ40UJgPVpNSedgwplsaCw47NdXl4g55i5 z08A== 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=FttItEc/bCeQMaeGDWpIEf0Eh6tDrC3LzX+ZGvAr92A=; b=S/fWWK6ANW8u6dYuCPlgSjC/Skf5MItBrlIvanETdP3NMKYFZJrQw+bYq5+FNtCLVy BU+BOM710kMLOOEGpgn97Ov2wRZ292BTc2iwl4QHkNGMhwm6vx3y5HK8D6rSgY8XlFrh QTMXJrHA53Zv0fQTBmv0rjiRM3aHfOs0p5CociwIUA/TrcRC4iLHDgKxcpLkJbDClSmz 90GJWpQ9v4SxzcqjfI9GxdJ132HomnywOXi5EowHC4HXJZsKHCTNzm4MzPzKEBFDGKAT BwXeGgEgNXIrQITPXLFKtNfXy4r89F+Lll725eToSVWL8ltqGWW3eZ9vqj97s5V8Yier 3DIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=t08DvcSi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay36-20020a056638412400b003285d3ab003si5436317jab.27.2022.04.18.06.08.37; Mon, 18 Apr 2022 06:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=t08DvcSi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237453AbiDRMu1 (ORCPT + 99 others); Mon, 18 Apr 2022 08:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240738AbiDRMjf (ORCPT ); Mon, 18 Apr 2022 08:39:35 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9CB1A3AF; Mon, 18 Apr 2022 05:30:21 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23ICUHfg072073; Mon, 18 Apr 2022 07:30:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650285017; bh=FttItEc/bCeQMaeGDWpIEf0Eh6tDrC3LzX+ZGvAr92A=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=t08DvcSiNqju5l4+ABD2NSmAa6cEjQ3SaKKtVIFmF/bngpyOUPkWBr3pUkrOssgCZ CohGSWfigDJTGTjIXoCe+amtA1sO2P++lYy1S7FcxvRj6UqfgTwEwqCxaOSsd4/SNx 3ZO6sS/1QHlyu33xQdpY/tULkEAWqNaQ2DlnAP84= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23ICUHKg060835 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Apr 2022 07:30:17 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 18 Apr 2022 07:30:16 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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.2308.14 via Frontend Transport; Mon, 18 Apr 2022 07:30:16 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23ICUFT0084245; Mon, 18 Apr 2022 07:30:16 -0500 From: Puranjay Mohan To: CC: , , , , , , , , , , , , , Subject: [PATCH v2 4/6] soc: ti: pruss: Add helper functions to set GPI mode, MII_RT_event and XFR Date: Mon, 18 Apr 2022 18:00:02 +0530 Message-ID: <20220418123004.9332-5-p-mohan@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220418123004.9332-1-p-mohan@ti.com> References: <20220418123004.9332-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=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 PRUSS CFG module is represented as a syscon node and is currently managed by the PRUSS platform driver. Add easy accessor functions to set GPI mode, MII_RT event enable/disable and XFR (XIN XOUT) enable/disable to enable the PRUSS Ethernet usecase. These functions reuse the generic pruss_cfg_update() API function. Signed-off-by: Suman Anna Co-developed-by: Grzegorz Jaszczyk Signed-off-by: Grzegorz Jaszczyk Signed-off-by: Puranjay Mohan --- include/linux/pruss.h | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/include/linux/pruss.h b/include/linux/pruss.h index eb2f974eef9c..84e95eb884e9 100644 --- a/include/linux/pruss.h +++ b/include/linux/pruss.h @@ -235,4 +235,59 @@ static inline bool is_pru_rproc(struct device *dev) return true; } +/** + * pruss_cfg_gpimode() - set the GPI mode of the PRU + * @pruss: the pruss instance handle + * @pru_id: id of the PRU core within the PRUSS + * @mode: GPI mode to set + * + * Sets the GPI mode for a given PRU by programming the + * corresponding PRUSS_CFG_GPCFGx register + * + * Return: 0 on success, or an error code otherwise + */ +static inline int pruss_cfg_gpimode(struct pruss *pruss, + enum pruss_pru_id pru_id, + enum pruss_gpi_mode mode) +{ + if (pru_id < 0 || pru_id >= PRUSS_NUM_PRUS) + return -EINVAL; + + return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(pru_id), + PRUSS_GPCFG_PRU_GPI_MODE_MASK, + mode << PRUSS_GPCFG_PRU_GPI_MODE_SHIFT); +} + +/** + * pruss_cfg_miirt_enable() - Enable/disable MII RT Events + * @pruss: the pruss instance + * @enable: enable/disable + * + * Enable/disable the MII RT Events for the PRUSS. + * + * Return: 0 on success, or an error code otherwise + */ +static inline int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable) +{ + u32 set = enable ? PRUSS_MII_RT_EVENT_EN : 0; + + return pruss_cfg_update(pruss, PRUSS_CFG_MII_RT, + PRUSS_MII_RT_EVENT_EN, set); +} + +/** + * pruss_cfg_xfr_enable() - Enable/disable XIN XOUT shift functionality + * @pruss: the pruss instance + * @enable: enable/disable + * + * Return: 0 on success, or an error code otherwise + */ +static inline int pruss_cfg_xfr_enable(struct pruss *pruss, bool enable) +{ + u32 set = enable ? PRUSS_SPP_XFER_SHIFT_EN : 0; + + return pruss_cfg_update(pruss, PRUSS_CFG_SPP, + PRUSS_SPP_XFER_SHIFT_EN, set); +} + #endif /* __LINUX_PRUSS_H */ -- 2.17.1