Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1554669imm; Thu, 12 Jul 2018 04:04:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/RnMC2gCo41nOM46n4K6HLX/KyhAM9b8Z1+fETpxSqFlEbUx3Oq5FIsn1JeF8k5OP+KCJ X-Received: by 2002:a62:c410:: with SMTP id y16-v6mr1872492pff.161.1531393468436; Thu, 12 Jul 2018 04:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531393468; cv=none; d=google.com; s=arc-20160816; b=GjJqWtcm0cUjOoVpbswZhptSIGMzB88R5sVwZ/qO66xmTljD6SZPn2S4VCFcPygO+i mAoiQDFMP6vOj7ksn6fBCgYMggYXT/6PMaxntG6MVlaciDtncHY4BaCK1tmWLazXIORK lU2sEqnBUGRU9EqgvmpyY43FkjR20Io336NiY7WTj99aDTKQhBrzB7fEJDsDxVJx5Yo2 yfqCGPHtiu1Dig8fR/CvEdVl1ytDIVxdrl6MBBkDqp0h0xGVkmljiHfir/noPafOq0PA 3IGGb9tmIznwKSBiX49sfztim7Xpl7qATXLlk+7mjYvw4I53V2o6p8vNkE8n+rtqx66S URHg== 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:arc-authentication-results; bh=742+UtZULJ5QzYGiumfLa8eo1C/5Wb+3q+y2Pw2LEY4=; b=aKLuBDBOdiV1SdoJjYQ9k5AFida5pR8STdn7U2dXHDpojwy2tXLrxU46AamH60hvcZ ILHpzmKeMXQtvFQbKFt9iZCTH/nETJSwTphsMnv+gVRgKesmu4w3yZxDwYGg32z1nZQ2 krRZoDpbo8rAc3C/cZgk6Xa/5TF7/exWbAR5OiR1SzWJLTpLdZRaSNhBl2oNS55hZ0Vd dMQMFesarJvFhQjwYPUliOqJBEXg3Wo58GV2eg8qMmwJG9GNQgUbEmNOZEPBXShuerL4 XGJqTydcwcxCMv/7zR4xKQ6LBQ2I1nNilqie2MeJ7PZqd2ZoM2urOQWph/guqL52FIla RT7Q== ARC-Authentication-Results: i=1; mx.google.com; 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 p17-v6si23816223pfd.76.2018.07.12.04.04.07; Thu, 12 Jul 2018 04:04:28 -0700 (PDT) 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; 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 S1732412AbeGLLMD (ORCPT + 99 others); Thu, 12 Jul 2018 07:12:03 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:33597 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726782AbeGLLLx (ORCPT ); Thu, 12 Jul 2018 07:11:53 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdZMy-00068a-Rr; Thu, 12 Jul 2018 13:02:44 +0200 Received: from mfe by dude.hi.pengutronix.de with local (Exim 4.91) (envelope-from ) id 1fdZMy-00014e-2H; Thu, 12 Jul 2018 13:02:44 +0200 From: Marco Felsch To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: fabio.estevam@nxp.com, Anson.Huang@nxp.com, kernel@pengutronix.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] regulator: pfuze100: add support to en-/disable switch regulators Date: Thu, 12 Jul 2018 13:02:40 +0200 Message-Id: <20180712110240.3006-3-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180712110240.3006-1-m.felsch@pengutronix.de> References: <20180712110240.3006-1-m.felsch@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add enable/disable support for switch regulators on pfuze100. Based on commit 5fe156f1cab4 ("regulator: pfuze100: add enable/disable for switch") which is reverted due to boot regressions by commit 464a5686e6c9 ("regulator: Revert "regulator: pfuze100: add enable/disable for switch""). Disabling the switch regulators will only be done if the user specifies "pfuze-disable-sw" in its device tree to keep backward compatibility with current dtb's [1]. Otherwise the regulators are marked as 'disabled', but the driver keeps them on. So it's more like a simulated disable. [1] https://patchwork.kernel.org/patch/10490381/ Signed-off-by: Marco Felsch --- Changes since https://patchwork.kernel.org/patch/10405723/ - Use DT property to keep backward compatibility - Use the default register val 0x8 as enable_val drivers/regulator/pfuze100-regulator.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index cde6eda1d283..2f5f3eb43e42 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c @@ -17,6 +17,8 @@ #include #include +#define PFUZE_FLAG_DISABLE_SW BIT(1) + #define PFUZE_NUMREGS 128 #define PFUZE100_VOL_OFFSET 0 #define PFUZE100_STANDBY_OFFSET 1 @@ -54,6 +56,7 @@ struct pfuze_regulator { struct pfuze_chip { int chip_id; + int flags; struct regmap *regmap; struct device *dev; struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; @@ -106,6 +109,18 @@ static const struct of_device_id pfuze_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, pfuze_dt_ids); +static int pfuze100_disable(struct regulator_dev *rdev) +{ + struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev); + + /* + * Only disable the regulator if the user really wants it, else simulate + * a disabled regulator but leave the regulator on. + */ + return (pfuze100->flags & PFUZE_FLAG_DISABLE_SW) ? + regulator_disable_regmap(rdev) : 0; +} + static int pfuze100_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) { struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev); @@ -163,6 +178,9 @@ static const struct regulator_ops pfuze100_fixed_regulator_ops = { }; static const struct regulator_ops pfuze100_sw_regulator_ops = { + .enable = regulator_enable_regmap, + .disable = pfuze100_disable, + .is_enabled = regulator_is_enabled_regmap, .list_voltage = regulator_list_voltage_linear, .set_voltage_sel = regulator_set_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap, @@ -209,6 +227,11 @@ static const struct regulator_ops pfuze100_swb_regulator_ops = { .uV_step = (step), \ .vsel_reg = (base) + PFUZE100_VOL_OFFSET, \ .vsel_mask = 0x3f, \ + .enable_reg = (base) + PFUZE100_MODE_OFFSET, \ + .enable_val = 0x8, \ + .disable_val = 0x0, \ + .enable_mask = 0xf, \ + .enable_time = 500, \ }, \ .stby_reg = (base) + PFUZE100_STANDBY_OFFSET, \ .stby_mask = 0x3f, \ @@ -471,6 +494,9 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip) if (!np) return -EINVAL; + if (of_property_read_bool(np, "pfuze-disable-sw")) + chip->flags |= PFUZE_FLAG_DISABLE_SW; + parent = of_get_child_by_name(np, "regulators"); if (!parent) { dev_err(dev, "regulators node not found\n"); -- 2.18.0