From patchwork Fri Dec 11 18:48:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 341979 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp810576jai; Fri, 11 Dec 2020 10:52:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQPiZQ9EV4ydXsfU6WNG49hx1ZIO6HB+oeCoA75ml+Ih4N+pYp8FQAgjG36f1Rs80dF1ZD X-Received: by 2002:a50:d888:: with SMTP id p8mr13361981edj.147.1607712779629; Fri, 11 Dec 2020 10:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607712779; cv=none; d=google.com; s=arc-20160816; b=eeQXx59acuX+YbcVH+mbMPjSL2HwSXZ6F5Q2uEraI+z9K84I/wwQb+j38msuihwpc4 wvaDtLdXCaKZAOqcAw7anxIemXz20gaDdFq7wmpC1ghSWbwBfPeCtNOuBoA5aq6e9dwD uX8sJ6WVQBTJVNdV36Ph9OIGwTfo0BOzTWfIvUJCTgKR/WgwwLTJj/uVlk4YbWOIeopf Cp4gvYeGqdms3xwnChM1XXrtU4pAeNfKftHP8YXkKToFyJVlCmnAlUETKyZgTUVe7Aji RqEBVxpD6J+jJCJuo78U3/UJDrJy1q4ka0I1pDMep2kAkjdq5xCX05OwQe8nIGb+uIbr UtEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=23e4OtAdhS6/eJqfaLbIjryiFMaMMoJbdSAg/gW4lu0=; b=OH339+3agRSEdppFU8oH+W1IYTn7GAOhK90H8sEsHE62KAUo7qTJ6o3P3w9s2fgP7Z P6gbWO4MZsB/uPjzJyJE4q97sHMJS7k0tjlhw6BnYggWk/zrarbvtFRzqfCkG6hwRr3U EIsvzblj49G9C/MFv6qdCRxo6jUCkVreJbVgDnWAp4Mmi10D3sKu8QUDdgpgRyfyPHi/ d42tidyIg7rhFDGx74HdXMgHDvgMwNH5MFrGyZPPup6GbCj+qMoBPUnWU/FW3HmpdcCf GCB8kVh1ti1FrbCIPO06TnSsIOs3SDXa52beQwvdEZTkjB4PxLrZi9rQ2Lr9ZiY7+yR1 yh1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q79X2koi; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si5431033edr.152.2020.12.11.10.52.59; Fri, 11 Dec 2020 10:52:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q79X2koi; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727714AbgLKSw0 (ORCPT + 3 others); Fri, 11 Dec 2020 13:52:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391175AbgLKStS (ORCPT ); Fri, 11 Dec 2020 13:49:18 -0500 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8086CC0611D0 for ; Fri, 11 Dec 2020 10:48:38 -0800 (PST) Received: by mail-lf1-x142.google.com with SMTP id u18so14696985lfd.9 for ; Fri, 11 Dec 2020 10:48:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=23e4OtAdhS6/eJqfaLbIjryiFMaMMoJbdSAg/gW4lu0=; b=q79X2koiMjIHXybLkIW4FWzjM/9/iZFbs+VMBdG6rVDGEHSeJh7EPaE+HbHzPrq7oU CigCr/VHSjXJfVgBpTI05X1oJY0g2BT7jjhHlm8w95330FvCWsMNYmSxXdDpJVmFmPCr e44f0E+2RX6RkzuqcEu7hYqwHNCk0Fgt/1stP62U0Bf9vCOmyivfbb5QoggKNVfBRwDq tyVkLBum85kpO75FYOeuReJgHBG/cTqxY6ZQ7d6g4B6GFz9YYlnKzo2ZmTKZ2oKf6Jth JorAl48lb+ppozzchngCQK6trkAGU1w+3jFsWLCbO/BO503e01IXfdV/PMFSpRF/8/RR MBCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=23e4OtAdhS6/eJqfaLbIjryiFMaMMoJbdSAg/gW4lu0=; b=rR6cameEQlmWegm12WhXswqaoLb8Dmfcw/7KsKZRWYNiaSjvpV6gNvQl8bgkQ5iqXn 7fj0+Tq5ztJZqEyz0gWqvOki/tDsEdDXPrz2VXrDooZt7m1/HmDb/IXselYUX4z0zqsM oNNd1mrySNX7S+ich4BBfht+fSDpXbJzac93PeZVw5d1IarzXAfEiRlnXJauPB7Ply/E y6fgUZLa8+VGRNndds8eNObMgaDyYuuD/QEdfRpzlppUsJhJ8xQsqdm0lrcpBOePwDeT TAjw2F3/kjKHMRQjWEgVc5wrp+Qh2uQcJU206w02sMlzSn/+W55TWasYG7plDkZdMNRo bAjQ== X-Gm-Message-State: AOAM5326gA6DKSLh/679P8TFxwNxHVktru28OHaa1iFAQcCFkAEKtjLt YFQDhu/EykuEoKZ38E0bnw5XTA== X-Received: by 2002:ac2:5451:: with SMTP id d17mr2678709lfn.222.1607712517070; Fri, 11 Dec 2020 10:48:37 -0800 (PST) Received: from gilgamesh.semihalf.com (193-106-246-138.noc.fibertech.net.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id b12sm903316lfb.139.2020.12.11.10.48.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Dec 2020 10:48:36 -0800 (PST) From: Grzegorz Jaszczyk To: ssantosh@kernel.org, s-anna@ti.com Cc: grzegorz.jaszczyk@linaro.org, santosh.shilimkar@oracle.com, lee.jones@linaro.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, praneeth@ti.com, tony@atomide.com, linux-remoteproc@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH 6/6] soc: ti: pruss: Add helper functions to get/set PRUSS_CFG_GPMUX Date: Fri, 11 Dec 2020 19:48:11 +0100 Message-Id: <20201211184811.6490-7-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20201211184811.6490-1-grzegorz.jaszczyk@linaro.org> References: <20201211184811.6490-1-grzegorz.jaszczyk@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@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 --- include/linux/pruss_driver.h | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.29.0 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_ */