From patchwork Mon Dec 28 12:02:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uri Mashiach X-Patchwork-Id: 7925851 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C7691BEEE5 for ; Mon, 28 Dec 2015 12:03:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2D1620256 for ; Mon, 28 Dec 2015 12:02:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8CC92025A for ; Mon, 28 Dec 2015 12:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752103AbbL1MC5 (ORCPT ); Mon, 28 Dec 2015 07:02:57 -0500 Received: from softlayer.compulab.co.il ([50.23.254.55]:47853 "EHLO compulab.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbbL1MCz (ORCPT ); Mon, 28 Dec 2015 07:02:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=compulab.co.il; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From; bh=ypQv1hj1k3yz4UsQjxOgkCq+A6VKMipIWDxpCdDT3Vc=; b=bT67Uq1EoVJfG ijszMoOjqnXY8eRwhxSDwZwBYWC9tiIhku8wJYBVolL19BQKxjm6SW1/yenDvPSmgWXKxQHUJDXJ7 sY6csyfjPn8loI2LWfHdbS0T5ojl5jvpyDrCQozUyPh2sACdn9sa3VZLnfRcCVYwLPTRZvbHFjIlJ dylU=; Received: from [82.166.188.245] (port=48775 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.86) (envelope-from ) id 1aDWVp-0002Ak-Ma; Mon, 28 Dec 2015 14:02:53 +0200 Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 881EC481F95; Mon, 28 Dec 2015 14:02:52 +0200 (IST) Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8yaJMG3Nt1J5; Mon, 28 Dec 2015 14:02:52 +0200 (IST) Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 181B4481F96; Mon, 28 Dec 2015 14:02:52 +0200 (IST) X-Virus-Scanned: amavisd-new at zimbra-mta.compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1T59fqgKslQI; Mon, 28 Dec 2015 14:02:52 +0200 (IST) Received: from urim-desk.compulab.local (uri-ipc.compulab.local [192.168.11.218]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id D645F481F95; Mon, 28 Dec 2015 14:02:51 +0200 (IST) From: Uri Mashiach To: Kalle Valo , Rob Herring , Tony Lindgren Cc: Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , bcousson@baylibre.com, Igor Grinberg , Eliad Peller , devicetree@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, Uri Mashiach Subject: [PATCH v3 1/3] wlcore/wl12xx: spi: add power operation function Date: Mon, 28 Dec 2015 14:02:17 +0200 Message-Id: <1451304139-10899-2-git-send-email-uri.mashiach@compulab.co.il> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1451304139-10899-1-git-send-email-uri.mashiach@compulab.co.il> References: <1451304139-10899-1-git-send-email-uri.mashiach@compulab.co.il> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Get-Message-Sender-Via: softlayer.compulab.co.il: acl_c_recent_authed_mail_ips_text_entry: uri.mashiach@compulab.co.il|compulab.co.il X-Authenticated-Sender: softlayer.compulab.co.il: uri.mashiach@compulab.co.il Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The power function uses a consumer regulator access to update the WiFi enable GPIO value. Signed-off-by: Uri Mashiach --- v1 -> v2: oops fix was removed to a separate fix. v2 -> v3: no changes drivers/net/wireless/ti/wlcore/spi.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c index 44f059f..d3a4bcb 100644 --- a/drivers/net/wireless/ti/wlcore/spi.c +++ b/drivers/net/wireless/ti/wlcore/spi.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "wlcore.h" #include "wl12xx_80211.h" @@ -81,6 +82,7 @@ struct wl12xx_spi_glue { struct device *dev; struct platform_device *core; + struct regulator *reg; /* Power regulator */ }; static void wl12xx_spi_reset(struct device *child) @@ -318,11 +320,40 @@ static int __must_check wl12xx_spi_raw_write(struct device *child, int addr, return 0; } +/** + * wl12xx_spi_set_power - power on/off the wl12xx unit + * @child: wl12xx device handle. + * @enable: true/false to power on/off the unit. + * + * use the WiFi enable regulator to enable/disable the WiFi unit. + */ +static int wl12xx_spi_set_power(struct device *child, bool enable) +{ + int ret = 0; + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); + + WARN_ON(!glue->reg); + + /* Update regulator state */ + if (enable) { + ret = regulator_enable(glue->reg); + if (ret) + dev_err(child, "Power enable failure\n"); + } else { + ret = regulator_disable(glue->reg); + if (ret) + dev_err(child, "Power disable failure\n"); + } + + return ret; +} + static struct wl1271_if_operations spi_ops = { .read = wl12xx_spi_raw_read, .write = wl12xx_spi_raw_write, .reset = wl12xx_spi_reset, .init = wl12xx_spi_init, + .power = wl12xx_spi_set_power, .set_block_size = NULL, }; @@ -353,6 +384,12 @@ static int wl1271_probe(struct spi_device *spi) * comes from the board-peripherals file */ spi->bits_per_word = 32; + glue->reg = devm_regulator_get(&spi->dev, "vwlan"); + if (IS_ERR(glue->reg)) { + dev_err(glue->dev, "can't get regulator\n"); + return PTR_ERR(glue->reg); + } + ret = spi_setup(spi); if (ret < 0) { dev_err(glue->dev, "spi_setup failed\n");