Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1295869imu; Wed, 16 Jan 2019 16:37:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN49jlLPsXbYkDGK35VlFpD3g27ITLAqM8yLILeIkT9zmm6q+qj3q0ebEoH+kMCkllURGLQt X-Received: by 2002:a63:134f:: with SMTP id 15mr11423217pgt.19.1547685463738; Wed, 16 Jan 2019 16:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547685463; cv=none; d=google.com; s=arc-20160816; b=sN4YAoDXVOOhGHz4YDsPk75XisMEqVdK1Dw83sF0xN64/wExsT+hp5hb7PfVh3uN6y cWr148E6vf2yjEQZsHzMYyGt4Groed2yEZjMdR3jF8y6o7B8879PEmtLpcy/9FSdXQ1x +eGYI6qN3DGwvMAMkYptUgvoPBZnUkYgo790rusR4IKXnirkHLitAaPfXTGk2SC/wMfa 415BUDx3w+yyO0awbNlzx7Ir4L/2qgY3l4uCcom+e2F9p25zkozHA5oOKMyNyGKl8dP1 BOzN/GT+QcVwTFQs3STLYIZktq5T3noJponzkz9fINBFW2GOPkTlSjTYbc0DtfQGlywP XKfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=JOfMVAOXKfX7faGG0NTzeUEvAQuesgUG1fLuu4NCrGI=; b=dgJokeBiia2C1pzRxqde99z4KEn/z2rfEtslNkPlW/TI/fAywbS4RR8Zh2DfFomVHj 0DMd1QTd5pQho5NcvX7tlC2AjsrGMblySV4Mz+dA00TZc+nW5pmcSelg7HGdMEEeOD5Y wgoagWOb3Gd/VTFIoe5+tX52/SN9LK0Uav4E9ypgnUvk3oxzwDkH7zO5G4G3YiFHqC2T UnK1Oi0laYpHtsKFm0J0gWZEBAPXrDGHhu0Co+0zgJhYaUFdh+OFZEoBHoy02cEvZQEE tGwPzMTXGNywSBBExUstloL8Ik0S9rx98QceKEgnxbduXUaCo3kUokAsUBhwOnouyh7b ilMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kemnade.info header.s=20180802 header.b=GSFLxpWV; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si7403236pgn.355.2019.01.16.16.37.27; Wed, 16 Jan 2019 16:37:43 -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=fail header.i=@kemnade.info header.s=20180802 header.b=GSFLxpWV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729104AbfAPVSy (ORCPT + 99 others); Wed, 16 Jan 2019 16:18:54 -0500 Received: from mail.andi.de1.cc ([85.214.239.24]:55584 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728963AbfAPVSy (ORCPT ); Wed, 16 Jan 2019 16:18:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JOfMVAOXKfX7faGG0NTzeUEvAQuesgUG1fLuu4NCrGI=; b=GSFLxpWVgTRsKDrh4sk5pHp+a QjSan0PVNLpqKq2JvQa0J5twDpMOJqKTXEWgyBrl+Ij3nwwuqlH5WfZ7h0dhQPe6zV3LqKjDhcfDo OEXv+jIK58SMWAcReCIkCXdco4k3aMfwhJV4UpjcUIIigibx3Tm0NQdpbfGipQwGEiGjg=; Received: from p200300ccfbcc8e007ee9d3fffe1fa246.dip0.t-ipconnect.de ([2003:cc:fbcc:8e00:7ee9:d3ff:fe1f:a246] helo=eeepc) by h2641619.stratoserver.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gjsaG-0006JL-Vl; Wed, 16 Jan 2019 22:18:49 +0100 Received: from andi by eeepc with local (Exim 4.89) (envelope-from ) id 1gjsaF-0001fG-Gd; Wed, 16 Jan 2019 22:18:47 +0100 From: Andreas Kemnade To: letux-kernel@openphoenux.org, johan@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andreas Kemnade Subject: [PATCH v3 5/6] gnss: sirf: add a separate supply for a lna Date: Wed, 16 Jan 2019 22:18:11 +0100 Message-Id: <20190116211812.6337-6-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190116211812.6337-1-andreas@kemnade.info> References: <20190116211812.6337-1-andreas@kemnade.info> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Devices might have a separate lna between antenna input of the gps chip and the antenna which might have a separate supply. Signed-off-by: Andreas Kemnade --- Changes in v3: - improved error checking - style cleanup Changes in v2: - handle lna also if there is no on-off gpio - rebase on changed 2/5 drivers/gnss/sirf.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/drivers/gnss/sirf.c b/drivers/gnss/sirf.c index 943a2ec9b708..7de98edf198a 100644 --- a/drivers/gnss/sirf.c +++ b/drivers/gnss/sirf.c @@ -41,6 +41,7 @@ struct sirf_data { struct serdev_device *serdev; speed_t speed; struct regulator *vcc; + struct regulator *lna; struct gpio_desc *on_off; struct gpio_desc *wakeup; int irq; @@ -293,21 +294,52 @@ static int sirf_set_active(struct sirf_data *data, bool active) static int sirf_runtime_suspend(struct device *dev) { struct sirf_data *data = dev_get_drvdata(dev); + int ret; - if (!data->on_off) - return regulator_disable(data->vcc); + if (data->on_off) + ret = sirf_set_active(data, false); + else + ret = regulator_disable(data->vcc); + + if (ret) + return ret; - return sirf_set_active(data, false); + ret = regulator_disable(data->lna); + if (ret) { + int reenable_ret; + + if (data->on_off) + reenable_ret = sirf_set_active(data, true); + else + reenable_ret = regulator_enable(data->vcc); + + if (reenable_ret) + dev_err(dev, + "failed to reenable power on failed suspend: %d\n", + reenable_ret); + } + + return ret; } static int sirf_runtime_resume(struct device *dev) { struct sirf_data *data = dev_get_drvdata(dev); + int ret; + + ret = regulator_enable(data->lna); + if (ret) + return ret; - if (!data->on_off) - return regulator_enable(data->vcc); + if (data->on_off) + ret = sirf_set_active(data, true); + else + ret = regulator_enable(data->vcc); - return sirf_set_active(data, true); + if (ret) + regulator_disable(data->lna); + + return ret; } static int __maybe_unused sirf_suspend(struct device *dev) @@ -395,6 +427,12 @@ static int sirf_probe(struct serdev_device *serdev) goto err_put_device; } + data->lna = devm_regulator_get(dev, "lna"); + if (IS_ERR(data->lna)) { + ret = PTR_ERR(data->lna); + goto err_put_device; + } + data->on_off = devm_gpiod_get_optional(dev, "sirf,onoff", GPIOD_OUT_LOW); if (IS_ERR(data->on_off)) -- 2.11.0