Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2677100pxb; Mon, 18 Apr 2022 06:08:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgx6zx9tCVXdChaQylPeVTj6XG4AJ5CsENAseHstXAlZLhsN2pR3cUTsmzOR3+2cIbr3PN X-Received: by 2002:a05:6808:1719:b0:2f9:ab58:73db with SMTP id bc25-20020a056808171900b002f9ab5873dbmr4964572oib.201.1650287325358; Mon, 18 Apr 2022 06:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650287325; cv=none; d=google.com; s=arc-20160816; b=pmiUlIy/V2J3j30/HErSGEOvbm8KZTA4oQa76p2KdZJlb1HvELkjNMP7l40/JLkZGP cEIbbCZvpr9S/PTBo7BUJ90PL2sRnfJAS7gk+5I0rVOy3cGHFE8aagYC/vYVzVR3aUD3 QTTjvABWtxr0lfuZDzI4VjoZejDMe7zW8nQ9u3cN0Xx/EjDRaQ+gmKooansh67j8WqH2 L0gAfRitnNz8pHj5cPdWl/3T3D2hB5g3qHYu40/ZybzDkU31/vuYTVVpdUEBhWRpo1q2 D4B2OTvboOZ/iQCWbZxzH6xv7XCAeIErhtfdkh6q5Q5IGyPG8ws+coGOSSxDFN3ETbzK 0vyg== 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=V24Pg9flw1bNbkBXpcqZ1XDD4yowcEtZAzI4rpfzD24=; b=WmozN0JccQghUbxZ3f4hzrBJ/+XNGHNnRkBxjYI7DLc1QAcsiKcgKOgubyqH89slpy 8JC/sc2y9RRHqjrdl36YD2HQ4azJomimSYJ6tJrIatfvUl6sshdsOqGBWn6GX1WtUqIK +Wr321boCM4YtpCllpPSvemmViVsM55x2VbkQGIiIWX9Irs8g/zqReADfNibgArnGH2S wRuUdgrQzPxwh2b3oqZucGqskengUTEGYIm1IiSTmelYa+WRYI+bl0Juc/2bjd4IkIFV p13H0nvDhD0Us0N7Idei6YqppfU7zKfmL68wK2zVzJYqCBSVbMLq8QiBHVUZ1XVIP0hE BPPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HM7pxqH4; 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 p128-20020acad886000000b002ef0c347618si4253185oig.152.2022.04.18.06.08.30; Mon, 18 Apr 2022 06:08:45 -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=HM7pxqH4; 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 S240157AbiDRMwq (ORCPT + 99 others); Mon, 18 Apr 2022 08:52:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240756AbiDRMjg (ORCPT ); Mon, 18 Apr 2022 08:39:36 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0164B12627; Mon, 18 Apr 2022 05:30:26 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23ICULIK120040; Mon, 18 Apr 2022 07:30:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650285021; bh=V24Pg9flw1bNbkBXpcqZ1XDD4yowcEtZAzI4rpfzD24=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HM7pxqH4EpECKH9mLgBhzBdlvQSeWZqPpWuu8+laRvVipNu7r2pPFrE5uWuTaqw+R a3EytiP4bIwXUZbtP19jVsJCk+mpgQT1QuvfIELQU6X2cQTd4MMwnFoN7LSeV5IXg5 bvIuwNwkTH2Os7IB1TXl6OCX/ItiXLIpB2aUjQ7A= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23ICUL66015761 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Apr 2022 07:30:21 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE115.ent.ti.com (157.170.170.26) 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:20 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE108.ent.ti.com (157.170.170.38) 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:20 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23ICUJRH032161; Mon, 18 Apr 2022 07:30:20 -0500 From: Puranjay Mohan To: CC: , , , , , , , , , , , , , Subject: [PATCH v2 6/6] soc: ti: pruss: Add helper functions to get/set PRUSS_CFG_GPMUX Date: Mon, 18 Apr 2022 18:00:04 +0530 Message-ID: <20220418123004.9332-7-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: Tero Kristo Add two new helper functions pruss_cfg_get_gpmux() & pruss_cfg_set_gpmux() to get and set the GP MUX mode for programming the PRUSS internal wrapper mux functionality as needed by usecases. Co-developed-by: Suman Anna Signed-off-by: Suman Anna Signed-off-by: Tero Kristo Co-developed-by: Grzegorz Jaszczyk Signed-off-by: Grzegorz Jaszczyk Signed-off-by: Puranjay Mohan --- include/linux/pruss_driver.h | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/include/linux/pruss_driver.h b/include/linux/pruss_driver.h index e2d5477225c6..3312281ef4c1 100644 --- a/include/linux/pruss_driver.h +++ b/include/linux/pruss_driver.h @@ -35,4 +35,48 @@ struct pruss { struct clk *iep_clk_mux; }; +/** + * pruss_cfg_get_gpmux() - get the current GPMUX value for a PRU device + * @pruss: pruss instance + * @pru_id: PRU identifier (0-1) + * @mux: pointer to store the current mux value into + * + * Return: 0 on success, or an error code otherwise + */ +static inline int pruss_cfg_get_gpmux(struct pruss *pruss, + enum pruss_pru_id pru_id, u8 *mux) +{ + int ret = 0; + u32 val; + + if (pru_id < 0 || pru_id >= PRUSS_NUM_PRUS) + return -EINVAL; + + ret = pruss_cfg_read(pruss, PRUSS_CFG_GPCFG(pru_id), &val); + if (!ret) + *mux = (u8)((val & PRUSS_GPCFG_PRU_MUX_SEL_MASK) >> + PRUSS_GPCFG_PRU_MUX_SEL_SHIFT); + return ret; +} + +/** + * pruss_cfg_set_gpmux() - set the GPMUX value for a PRU device + * @pruss: pruss instance + * @pru_id: PRU identifier (0-1) + * @mux: new mux value for PRU + * + * Return: 0 on success, or an error code otherwise + */ +static inline int pruss_cfg_set_gpmux(struct pruss *pruss, + enum pruss_pru_id pru_id, u8 mux) +{ + if (mux >= PRUSS_GP_MUX_SEL_MAX || + pru_id < 0 || pru_id >= PRUSS_NUM_PRUS) + return -EINVAL; + + return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(pru_id), + PRUSS_GPCFG_PRU_MUX_SEL_MASK, + (u32)mux << PRUSS_GPCFG_PRU_MUX_SEL_SHIFT); +} + #endif /* _PRUSS_DRIVER_H_ */ -- 2.17.1