From patchwork Mon Aug 28 21:23:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Breck X-Patchwork-Id: 9926219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 123FD60383 for ; Mon, 28 Aug 2017 21:25:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 050C7287D4 for ; Mon, 28 Aug 2017 21:25:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDFEF287CE; Mon, 28 Aug 2017 21:25:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38FF3287D4 for ; Mon, 28 Aug 2017 21:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751286AbdH1VYY (ORCPT ); Mon, 28 Aug 2017 17:24:24 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35563 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182AbdH1VYX (ORCPT ); Mon, 28 Aug 2017 17:24:23 -0400 Received: by mail-pf0-f195.google.com with SMTP id g13so1046521pfm.2 for ; Mon, 28 Aug 2017 14:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jQgGHTcdMWSUMX2AJ2LC4WdbJ/5wMLH+QC3hqdIc7F4=; b=Sz86INMIXnWkqfxyKvB4IT1M46NCrixeqP3NePPhPB5spXsELHf+W0ILK4Jlz7BOBm YK81wWNLA3rt0ymiD31FEPBWDKLVOEvLsxNgUmIYfobSc//YM9z1Pqsg45HylwUI7Pap Lzyoo+o6c3LcehharyXZOuNhmX51lWGM0TynvGHgn1wqrBdBpddt5zbE8aj4gtJFWhfS UnNv1k0urEXP1575IOEc/YIo/tNXTZniSj/Y690/gHpS1yb+yW3RsAWFomgT6cVOlJKv rWyxMEJZgc3Cd6UoUI5Q7xFstHnzZDIjyP8ATeVWSndtgJNHWGLEzAN6Bt45cxTX/pjS g0rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=jQgGHTcdMWSUMX2AJ2LC4WdbJ/5wMLH+QC3hqdIc7F4=; b=IlkjeUPDZ06Wdp34g44uGkkBz6Dc5MKRHW53yu5i7dS//w7sU4P1FIE2nGjFn1RDez n86HDtoQ4/TPDKgYv60xREaztSx45vOe9AcXAH1hL65YoXoZNZ3z4gdwQ51wwUACgK00 KD+xmtZeaQLhteK1WZ37XqjMs2n9ZLUasHZfG1Wg2ZYO9ywBug5WzQhnU/JCoP3fzur2 5IUYd6/F4lP8xcqugvpO+2DqVIXiW9xIOqQ5pi0o+QYqE5OqgPusHUMpvapsvdcpHT46 H5hDowfQodKwNH0hKikTmI/9RjLZXbT9LMERyWal8cCo8el6OG+QfDqzNnYxEl6aTkOT I4Uw== X-Gm-Message-State: AHYfb5hCnATPu1ti0vcGHPX82bQxHnT6P3rsQtj9l/E9n4xk/uIUj2u4 bPO8d2t2v2VLHw7eMbQ= X-Received: by 10.99.1.136 with SMTP id 130mr1825899pgb.447.1503955463211; Mon, 28 Aug 2017 14:24:23 -0700 (PDT) Received: from localhost.localdomain (c-73-223-93-234.hsd1.ca.comcast.net. [73.223.93.234]) by smtp.gmail.com with ESMTPSA id t29sm2155952pgo.4.2017.08.28.14.24.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 14:24:22 -0700 (PDT) From: Liam Breck To: Sebastian Reichel , linux-pm@vger.kernel.org Cc: Tony Lindgren , Hans de Goede , Liam Breck Subject: [PATCH v4 4/5] power: bq24190_charger: Add property system-minimum-microvolt Date: Mon, 28 Aug 2017 14:23:48 -0700 Message-Id: <20170828212349.19037-5-liam@networkimprov.net> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170828212349.19037-1-liam@networkimprov.net> References: <20170828212349.19037-1-liam@networkimprov.net> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Liam Breck Set minimum system voltage limit obtained from device property. Cc: Tony Lindgren Cc: Hans de Goede Signed-off-by: Liam Breck Acked-by: Tony Lindgren --- drivers/power/supply/bq24190_charger.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index af4688db..c0b23db8 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -43,6 +43,8 @@ #define BQ24190_REG_POC_CHG_CONFIG_OTG 0x2 #define BQ24190_REG_POC_SYS_MIN_MASK (BIT(3) | BIT(2) | BIT(1)) #define BQ24190_REG_POC_SYS_MIN_SHIFT 1 +#define BQ24190_REG_POC_SYS_MIN_MIN 3000 +#define BQ24190_REG_POC_SYS_MIN_MAX 3700 #define BQ24190_REG_POC_BOOST_LIM_MASK BIT(0) #define BQ24190_REG_POC_BOOST_LIM_SHIFT 0 @@ -159,6 +161,7 @@ struct bq24190_dev_info { char model_name[I2C_NAME_SIZE]; bool initialized; bool irq_event; + u16 sys_min; struct mutex f_reg_lock; u8 f_reg; u8 ss_reg; @@ -530,6 +533,16 @@ static int bq24190_set_config(struct bq24190_dev_info *bdi) if (ret < 0) return ret; + if (bdi->sys_min) { + v = bdi->sys_min / 100 - 30; // manual section 9.5.1.2, table 9 + ret = bq24190_write_mask(bdi, BQ24190_REG_POC, + BQ24190_REG_POC_SYS_MIN_MASK, + BQ24190_REG_POC_SYS_MIN_SHIFT, + v); + if (ret < 0) + return ret; + } + return 0; } @@ -1470,6 +1483,18 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi) static int bq24190_get_config(struct bq24190_dev_info *bdi) { + const char * const s = "ti,system-minimum-microvolt"; + int v; + + if (device_property_read_u32(bdi->dev, s, &v) == 0) { + v /= 1000; + if (v >= BQ24190_REG_POC_SYS_MIN_MIN + && v <= BQ24190_REG_POC_SYS_MIN_MAX) + bdi->sys_min = v; + else + dev_warn(bdi->dev, "invalid value for %s: %u\n", s, v); + } + return 0; }