From patchwork Tue Jul 3 12:46:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 1150871 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id B9E0B3FE4F for ; Tue, 3 Jul 2012 12:50:14 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sm2UR-0008Ef-6T; Tue, 03 Jul 2012 12:46:01 +0000 Received: from mail-yw0-f43.google.com ([209.85.213.43]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sm2UF-0008C6-Vp for linux-arm-kernel@lists.infradead.org; Tue, 03 Jul 2012 12:45:51 +0000 Received: by yhl10 with SMTP id 10so1248124yhl.16 for ; Tue, 03 Jul 2012 05:45:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=icX7/neVtVwYqJvZIDvkHylo1exM1/MKM1pgnKLOcZc=; b=GEmfxL7mRtEyYIdbeblsDqsp12uLOvoQvELyqkxxCZPfKk1fgdz+JieCdxCDXwSHCV VZsI8gECeydkN6d3LVwrWJ5xcokUwIK8eqNc4lFoXjpXF8aLXMjIYoxATmtThj2H3d6f EdYlGcRgPL5EcdIFaWiZZc3U2CZDc4r6rdLmL5hvjdxm1eGT6QuWz4MMaXj1RReji6Pr BZ/cZpbBca3nA58FQQ3X7/VhGl5WYNy9wSpZ0iYQkzX+wwoZJkIDA7JqqdaBwV87Ft4V 1xWe/1TqYQ1DiMw8oOTIpKUGMa2NfTAiQQr75CThG3xKnT9KWekLFl+aHDlpcHJIw7E3 0TOQ== Received: by 10.66.81.3 with SMTP id v3mr10701980pax.62.1341319543864; Tue, 03 Jul 2012 05:45:43 -0700 (PDT) Received: from localhost.localdomain ([114.216.233.161]) by mx.google.com with ESMTPS id np8sm15512561pbc.71.2012.07.03.05.45.39 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 05:45:42 -0700 (PDT) From: Shawn Guo To: Marc Kleine-Budde Subject: [PATCH] can: flexcan: add a regulator for transceiver Date: Tue, 3 Jul 2012 20:46:11 +0800 Message-Id: <1341319571-27763-1-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQnTVA1AxQCKvMe/ak+XG/z/Evrihvimjct+9llKncaWSWTmu4J4PE3DMOnLFV2q1//aynbe X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.213.43 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Shawn Guo , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Some system designs may have a controllable power supply for transceiver. Add a regulator for that, which can be turned on or off in flexcan_transceiver_switch function. Signed-off-by: Shawn Guo --- drivers/net/can/flexcan.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 81d4741..33ff7f0 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -36,6 +36,7 @@ #include #include #include +#include #define DRV_NAME "flexcan" @@ -179,6 +180,7 @@ struct flexcan_priv { u32 reg_ctrl_default; struct clk *clk; + struct regulator *reg_xcvr; struct flexcan_platform_data *pdata; }; @@ -224,6 +226,13 @@ static inline void flexcan_write(u32 val, void __iomem *addr) */ static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on) { + if (priv->reg_xcvr) { + if (on) + regulator_enable(priv->reg_xcvr); + else + regulator_disable(priv->reg_xcvr); + } + if (priv->pdata && priv->pdata->transceiver_switch) priv->pdata->transceiver_switch(on); } @@ -928,6 +937,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev) struct flexcan_priv *priv; struct resource *mem; struct clk *clk = NULL; + struct regulator *reg_xcvr; struct pinctrl *pinctrl; void __iomem *base; resource_size_t mem_size; @@ -957,6 +967,10 @@ static int __devinit flexcan_probe(struct platform_device *pdev) clock_freq = clk_get_rate(clk); } + reg_xcvr = devm_regulator_get(&pdev->dev, "xcvr"); + if (IS_ERR(reg_xcvr)) + reg_xcvr = NULL; + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); irq = platform_get_irq(pdev, 0); if (!mem || irq <= 0) { @@ -997,6 +1011,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev) priv->base = base; priv->dev = dev; priv->clk = clk; + priv->reg_xcvr = reg_xcvr; priv->pdata = pdev->dev.platform_data; netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);