From patchwork Mon Nov 26 07:52:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 151982 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5329070ljp; Sun, 25 Nov 2018 23:53:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/Up/mu8n5YAs2YiqO+Wjlzk/aP9rLz7FE+z0JHw+eUWlGv43s5Eao+ZnyH6+LjkbGO6qr6b X-Received: by 2002:a17:902:7b91:: with SMTP id w17mr26610062pll.111.1543218825844; Sun, 25 Nov 2018 23:53:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543218825; cv=none; d=google.com; s=arc-20160816; b=N9utiJbkEinpzFbPT43hUuZDEIr4fY47gdy1/+NENFfNSWewUDY387064/dlpR8n7B YjOe/y+hbcndkJzxFyEiYqBwNWBtnP9rxdjyBJh9ttxEECkTsVtYxo4OmxDQibNeb8su nC+CvVhkWHgpX6iO2itq6lWbijEOkdAPbcTclZ8oWBbApW+vrch5LnvnEDFMMgnM36Gd CfrCWTiIozyMuqKV791XmK5Sh6bSZxUznssYjKLGHg5wn3Cntn1mVVcepLj/+6fCIvj9 ibNYo89s6iGub+lNq4mZ8nq/sMe7Flz69PnBaUHkvZq3gejUzizSErEug5YxUO6fhwl5 lPWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=l0MhL2S79mZ5X3JBIlhYX7eDB29eRWidkIFQRsLrfoc=; b=vaUjObx12n43ZtHHT7DBD8FSXSNPoq45LAhqKAc0w0UdMHjBZqsB2DQPAnODX0Lty6 d6tjnQtHkkeHQIU/3HA51ga4/SsGccq7evrzXyOwzXM78nbMkbwceeCEVwubIVc0Cjkr EsaocYzIQOVka8Z3IHddCFNnCvBTJqUXKFgVBK8XhgOYzSYQMQkUwOF2ikdt9LEf+6Y6 P6g+b4aeUPMYW6tw02x0IMFu+QFQT76G8+LHZ+k8vP968Zjr9TsRYVBUQhCNxZH5VIwB xm/JUnQnnOgQQTYyXcIC9UvReOU42nSNNaYlas4cCqo48F69h+oTAT0Zj8AQTT3xnGjD sqdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ohHL1fKE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb2si44444721plb.298.2018.11.25.23.53.45; Sun, 25 Nov 2018 23:53:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ohHL1fKE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726708AbeKZSrA (ORCPT + 32 others); Mon, 26 Nov 2018 13:47:00 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:49494 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbeKZSq7 (ORCPT ); Mon, 26 Nov 2018 13:46:59 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ7rdME115949; Mon, 26 Nov 2018 01:53:39 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543218819; bh=l0MhL2S79mZ5X3JBIlhYX7eDB29eRWidkIFQRsLrfoc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ohHL1fKEgCpZ5AQVzPEBhrOIjmwBKCAk3VNscuxLFEMNRkTOWMLjwtrM8LMNN1L28 2Z2foSJziUCi1jWb44opbNHVPUiKUOgxtyN0ppIZl7del8KijeeAb15t83hiv8KcVy ahlwtkQUyV5IydV1YwnywxsmRynb8eo87Fz+h1jk= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ7rdvV103711 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 01:53:39 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 26 Nov 2018 01:53:39 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 26 Nov 2018 01:53:39 -0600 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7rdKU002632; Mon, 26 Nov 2018 01:53:39 -0600 Received: from localhost.localdomain (vboxa0400828d.dhcp.ti.com [172.22.237.3]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ7qn1P024490; Mon, 26 Nov 2018 01:53:35 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 11/16] soc: ti: pruss: add helper functions to set GPI mode, MII_RT_event and XFR Date: Mon, 26 Nov 2018 09:52:44 +0200 Message-ID: <1543218769-5507-12-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com> References: <1543218769-5507-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org 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_regmap_update() API function. Signed-off-by: Suman Anna --- include/linux/pruss.h | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/include/linux/pruss.h b/include/linux/pruss.h index c0a3b3e..7227aae 100644 --- a/include/linux/pruss.h +++ b/include/linux/pruss.h @@ -204,6 +204,69 @@ int pruss_intc_configure(struct pruss *pruss, int pruss_intc_unconfigure(struct pruss *pruss, struct pruss_intc_config *intc_config); +/** + * pruss_cfg_get_gpmux() - get the current GPMUX value for a PRU device + * @pruss: pruss instance + * @id: PRU identifier (0-1) + * @mux: pointer to store the current mux value into + */ +static inline int pruss_cfg_get_gpmux(struct pruss *pruss, + enum pruss_pru_id id, u8 *mux) +{ + int ret = 0; + u32 val; + + ret = pruss_cfg_read(pruss, PRUSS_CFG_GPCFG(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 + */ +static inline int pruss_cfg_set_gpmux(struct pruss *pruss, + enum pruss_pru_id id, u8 mux) +{ + if (mux >= PRUSS_GP_MUX_SEL_MAX) + return -EINVAL; + + return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(id), + PRUSS_GPCFG_PRU_MUX_SEL_MASK, + (u32)mux << PRUSS_GPCFG_PRU_MUX_SEL_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. + */ +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 + */ +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); +} #else static inline struct pruss *pruss_get(struct rproc *rproc) @@ -254,6 +317,28 @@ int pruss_intc_unconfigure(struct pruss *pruss, return -ENOTSUPP; } +static inline int pruss_cfg_get_gpmux(struct pruss *pruss, + enum pruss_pru_id id, u8 *mux) +{ + return -ENOTSUPP; +} + +static inline int pruss_cfg_set_gpmux(struct pruss *pruss, + enum pruss_pru_id id, u8 mux) +{ + return -ENOTSUPP; +} + +static inline int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable) +{ + return -ENOTSUPP; +} + +static inline int pruss_cfg_xfr_enable(struct pruss *pruss, bool enable) +{ + return -ENOTSUPP; +} + #endif /* CONFIG_TI_PRUSS */ #if IS_ENABLED(CONFIG_PRUSS_REMOTEPROC) @@ -263,6 +348,30 @@ void pru_rproc_put(struct rproc *rproc); enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc); int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr); +/** + * pruss_cfg_gpimode() - set the GPI mode of the PRU + * @pruss: the pruss instance handle + * @pru: the rproc instance handle of the PRU + * @mode: GPI mode to set + * + * Sets the GPI mode for a given PRU by programming the + * corresponding PRUSS_CFG_GPCFGx register + * + * Returns 0 on success, or an error code otherwise + */ +static inline int pruss_cfg_gpimode(struct pruss *pruss, struct rproc *pru, + enum pruss_gpi_mode mode) +{ + enum pruss_pru_id id = pru_rproc_get_id(pru); + + if (id < 0) + return -EINVAL; + + return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(id), + PRUSS_GPCFG_PRU_GPI_MODE_MASK, + mode << PRUSS_GPCFG_PRU_GPI_MODE_SHIFT); +} + #else static inline struct rproc *pru_rproc_get(struct device_node *node, int index) @@ -283,6 +392,12 @@ static inline int pru_rproc_set_ctable(struct rproc *rproc, return -ENOTSUPP; } +static inline int pruss_cfg_gpimode(struct pruss *pruss, struct rproc *pru, + enum pruss_gpi_mode mode) +{ + return -ENOTSUPP; +} + #endif /* CONFIG_PRUSS_REMOTEPROC */ #endif /* __LINUX_PRUSS_H */