From patchwork Thu Nov 1 00:11:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10663407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6279614E2 for ; Thu, 1 Nov 2018 00:12:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C2A12BB21 for ; Thu, 1 Nov 2018 00:12:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CDB32BB84; Thu, 1 Nov 2018 00:12:55 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 0B3D42BB6A for ; Thu, 1 Nov 2018 00:12:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726370AbeKAJMl (ORCPT ); Thu, 1 Nov 2018 05:12:41 -0400 Received: from onstation.org ([52.200.56.107]:44726 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbeKAJMk (ORCPT ); Thu, 1 Nov 2018 05:12:40 -0400 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id E60BCB08; Thu, 1 Nov 2018 00:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1541031130; bh=SNQg8lSVkSCyyyeJf7CLWF0oAF1ltzx0/skv5/3GDV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j/fpPcuQcA7BIfPlttXKJLnhc1CktLNhhvbpEFCFOXnyt5g7nfMitcnXaF58+YQ/s TXfAf6+15GPX+N1jm/OYqATjVbyapPYVDv1KO7s+T48ouqCvtwSn7ySrJBCMaQekbS BDsFZXzNmNIvAKoRgHrtyBKrQqrZACFgol8QeW8M= From: Brian Masney To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, david.brown@linaro.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-gpio@vger.kernel.org, jonathan@marek.ca, masneyb@onstation.org Subject: [PATCH v2 1/7] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus Date: Wed, 31 Oct 2018 20:11:43 -0400 Message-Id: <20181101001149.13453-2-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181101001149.13453-1-masneyb@onstation.org> References: <20181101001149.13453-1-masneyb@onstation.org> 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 Add support for the ti,bq24192 variant and a child node for the usb-otg-vbus regulator. Signed-off-by: Brian Masney Reviewed-by: Rob Herring --- .../devicetree/bindings/power/supply/bq24190.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt index 9e517d307070..c8ac028bd3c7 100644 --- a/Documentation/devicetree/bindings/power/supply/bq24190.txt +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt @@ -3,6 +3,7 @@ TI BQ24190 Li-Ion Battery Charger Required properties: - compatible: contains one of the following: * "ti,bq24190" + * "ti,bq24192" * "ti,bq24192i" - reg: integer, I2C address of the charger. - interrupts[-extended]: configuration for charger INT pin. @@ -19,6 +20,12 @@ Optional properties: - ti,system-minimum-microvolt: when power is connected and the battery is below minimum system voltage, the system will be regulated above this setting. +child nodes: +- usb-otg-vbus: + Usage: optional + Description: Regulator that is used to control the VBUS voltage direction for + either USB host mode or for charging on the OTG port. + Notes: - Some circuit boards wire the chip's "OTG" pin high (enabling 500mA default charge current on USB SDP ports, among other features). To simulate this on @@ -39,6 +46,8 @@ Example: interrupts-extended = <&gpiochip 10 IRQ_TYPE_EDGE_FALLING>; monitored-battery = <&bat>; ti,system-minimum-microvolt = <3200000>; + + usb_otg_vbus: usb-otg-vbus { }; }; &twl_gpio { From patchwork Thu Nov 1 00:11:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10663409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47F7017DB for ; Thu, 1 Nov 2018 00:12:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35F372BB21 for ; Thu, 1 Nov 2018 00:12:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 291092BB84; Thu, 1 Nov 2018 00:12:57 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 D33F92BB21 for ; Thu, 1 Nov 2018 00:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727616AbeKAJNU (ORCPT ); Thu, 1 Nov 2018 05:13:20 -0400 Received: from onstation.org ([52.200.56.107]:44736 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725823AbeKAJMl (ORCPT ); Thu, 1 Nov 2018 05:12:41 -0400 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id 802CAB0C; Thu, 1 Nov 2018 00:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1541031131; bh=iezGjImedq/LkxrzjpD62LOtq1MXGldLnWtale4QFC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NipsQLyXdupZtXv21zSjgnBJGQO2a8x7yt+mm9dFaDTPJwk4aJhZ0Anvm/Btd/mS+ KjdgRR/hJEhgDKixHY7akj+/feQXhtwmREvvfy2R3ZF1g/2Ev5ejeAuwCx3PRmdB+U 01DhWGdu5R/ieQcy5wBOl5b8N1TGNlvR3vL+RpQ0= From: Brian Masney To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, david.brown@linaro.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-gpio@vger.kernel.org, jonathan@marek.ca, masneyb@onstation.org Subject: [PATCH v2 2/7] power: supply: bq24190_charger: add support for bq24192 variant Date: Wed, 31 Oct 2018 20:11:44 -0400 Message-Id: <20181101001149.13453-3-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181101001149.13453-1-masneyb@onstation.org> References: <20181101001149.13453-1-masneyb@onstation.org> 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: Jonathan Marek This patch adds support for the bq24192 variant to bq24190_charger. Signed-off-by: Jonathan Marek [masneyb@onstation.org: Changed if statement to a switch based on feedback from Sebastian Reichel.] Signed-off-by: Brian Masney --- drivers/power/supply/bq24190_charger.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index b58df04d03b3..44d3aff32885 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -1637,8 +1637,12 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi) if (ret < 0) return ret; - if (v != BQ24190_REG_VPRS_PN_24190 && - v != BQ24190_REG_VPRS_PN_24192I) { + switch (v) { + case BQ24190_REG_VPRS_PN_24190: + case BQ24190_REG_VPRS_PN_24192: + case BQ24190_REG_VPRS_PN_24192I: + break; + default: dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v); return -ENODEV; } @@ -1931,6 +1935,7 @@ static const struct dev_pm_ops bq24190_pm_ops = { static const struct i2c_device_id bq24190_i2c_ids[] = { { "bq24190" }, + { "bq24192" }, { "bq24192i" }, { }, }; @@ -1939,6 +1944,7 @@ MODULE_DEVICE_TABLE(i2c, bq24190_i2c_ids); #ifdef CONFIG_OF static const struct of_device_id bq24190_of_match[] = { { .compatible = "ti,bq24190", }, + { .compatible = "ti,bq24192", }, { .compatible = "ti,bq24192i", }, { }, }; From patchwork Thu Nov 1 00:11:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10663383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1CC317DB for ; Thu, 1 Nov 2018 00:12:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CCF52BB21 for ; Thu, 1 Nov 2018 00:12:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 909B12BB84; Thu, 1 Nov 2018 00:12:15 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 335972BB21 for ; Thu, 1 Nov 2018 00:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726503AbeKAJMm (ORCPT ); Thu, 1 Nov 2018 05:12:42 -0400 Received: from onstation.org ([52.200.56.107]:44742 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbeKAJMm (ORCPT ); Thu, 1 Nov 2018 05:12:42 -0400 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id 1EECAB0E; Thu, 1 Nov 2018 00:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1541031131; bh=JKRzn4hB51JavjKXAcCuu9R+loG5zy8+v/t1MioEhq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XC5CzHrlOyHyi8sc7r6JiF5rWhGGMy5PqWYd29mhskp+d2PNQQVDJMztjP0tlS9qC G+FfiT+Xh7Hp9ngLgHaHaJ0L8Nh4nIkK003femI4V4oMhIf6bbwriu4K2HKEzerOXm I3a030/oHtQZ9WSakxojpyILuFybw9UNXipcLz+o= From: Brian Masney To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, david.brown@linaro.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-gpio@vger.kernel.org, jonathan@marek.ca, masneyb@onstation.org Subject: [PATCH v2 3/7] power: supply: bq24190_charger: add of_match for usb-otg-vbus regulator Date: Wed, 31 Oct 2018 20:11:45 -0400 Message-Id: <20181101001149.13453-4-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181101001149.13453-1-masneyb@onstation.org> References: <20181101001149.13453-1-masneyb@onstation.org> 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: Jonathan Marek This patch adds an of_match for the usb-otg-vbus regulator to bq24190_charger. Signed-off-by: Jonathan Marek Signed-off-by: Brian Masney --- drivers/power/supply/bq24190_charger.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index 44d3aff32885..9e7f3e33458a 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -577,6 +577,7 @@ static const struct regulator_ops bq24190_vbus_ops = { static const struct regulator_desc bq24190_vbus_desc = { .name = "usb_otg_vbus", + .of_match = "usb-otg-vbus", .type = REGULATOR_VOLTAGE, .owner = THIS_MODULE, .ops = &bq24190_vbus_ops, From patchwork Thu Nov 1 00:11:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10663397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2029614E2 for ; Thu, 1 Nov 2018 00:12:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CB9F2BB21 for ; Thu, 1 Nov 2018 00:12:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 010E82BB84; Thu, 1 Nov 2018 00:12:46 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 934F62BB21 for ; Thu, 1 Nov 2018 00:12:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727598AbeKAJNM (ORCPT ); Thu, 1 Nov 2018 05:13:12 -0400 Received: from onstation.org ([52.200.56.107]:44756 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726322AbeKAJMm (ORCPT ); Thu, 1 Nov 2018 05:12:42 -0400 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id BB9ADB12; Thu, 1 Nov 2018 00:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1541031132; bh=nd62Lix9kepB8HvNJdVZyApb/XrXmBdkuO7lgcPCO9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ri7E5TzMG3eRtJzt7IqOTkMgRTmZffohvRy2N2PHKkYczWc/xuanaqXtiAnty0XQw blbd4D3eaJYB7Zb9GWzLO4lZ4zSFjHn5M95cRC+S/U6byFmH7CB+wEwFp/ci3jJfAg o4+ENdGDS/tVyZ4SKQzdUZSCxdxFdsM/gICBDu7c= From: Brian Masney To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, david.brown@linaro.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-gpio@vger.kernel.org, jonathan@marek.ca, masneyb@onstation.org Subject: [PATCH v2 4/7] power: supply: bq24190_charger: add extcon support for USB OTG Date: Wed, 31 Oct 2018 20:11:46 -0400 Message-Id: <20181101001149.13453-5-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181101001149.13453-1-masneyb@onstation.org> References: <20181101001149.13453-1-masneyb@onstation.org> 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 Add extcon support so that we can notify USB drivers of cable state changes. Based on work from Jonathan Marek. USB OTG was tested on a LG Nexus 5 (hammerhead) phone. Signed-off-by: Brian Masney --- drivers/power/supply/bq24190_charger.c | 37 +++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index 9e7f3e33458a..4e64e6ac95c5 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -21,6 +21,7 @@ #include #include #include +#include #define BQ24190_MANUFACTURER "Texas Instruments" @@ -159,6 +160,7 @@ struct bq24190_dev_info { struct i2c_client *client; struct device *dev; + struct extcon_dev *edev; struct power_supply *charger; struct power_supply *battery; struct delayed_work input_current_limit_work; @@ -174,6 +176,11 @@ struct bq24190_dev_info { u8 watchdog; }; +static const unsigned int bq24190_usb_extcon_cable[] = { + EXTCON_USB, + EXTCON_NONE, +}; + /* * The tables below provide a 2-way mapping for the value that goes in * the register field and the real-world value that it represents. @@ -1528,6 +1535,20 @@ static const struct power_supply_desc bq24190_battery_desc = { .property_is_writeable = bq24190_battery_property_is_writeable, }; +static int bq24190_configure_usb_otg(struct bq24190_dev_info *bdi, u8 ss_reg) +{ + bool otg_enabled; + int ret; + + otg_enabled = !!(ss_reg & BQ24190_REG_SS_VBUS_STAT_MASK); + ret = extcon_set_state_sync(bdi->edev, EXTCON_USB, otg_enabled); + if (ret < 0) + dev_err(bdi->dev, "Can't set extcon state to %d: %d\n", + otg_enabled, ret); + + return ret; +} + static void bq24190_check_status(struct bq24190_dev_info *bdi) { const u8 battery_mask_ss = BQ24190_REG_SS_CHRG_STAT_MASK; @@ -1597,8 +1618,10 @@ static void bq24190_check_status(struct bq24190_dev_info *bdi) bdi->ss_reg = ss_reg; } - if (alert_charger || alert_battery) + if (alert_charger || alert_battery) { power_supply_changed(bdi->charger); + bq24190_configure_usb_otg(bdi, ss_reg); + } if (alert_battery && bdi->battery) power_supply_changed(bdi->battery); @@ -1732,6 +1755,14 @@ static int bq24190_probe(struct i2c_client *client, return -EINVAL; } + bdi->edev = devm_extcon_dev_allocate(dev, bq24190_usb_extcon_cable); + if (IS_ERR(bdi->edev)) + return PTR_ERR(bdi->edev); + + ret = devm_extcon_dev_register(dev, bdi->edev); + if (ret < 0) + return ret; + pm_runtime_enable(dev); pm_runtime_use_autosuspend(dev); pm_runtime_set_autosuspend_delay(dev, 600); @@ -1778,6 +1809,10 @@ static int bq24190_probe(struct i2c_client *client, goto out_charger; } + ret = bq24190_configure_usb_otg(bdi, bdi->ss_reg); + if (ret < 0) + goto out_charger; + ret = bq24190_sysfs_create_group(bdi); if (ret < 0) { dev_err(dev, "Can't create sysfs entries\n"); From patchwork Thu Nov 1 00:11:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10663395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D26C3CF1 for ; Thu, 1 Nov 2018 00:12:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A64A2BB21 for ; Thu, 1 Nov 2018 00:12:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DBD22BB84; Thu, 1 Nov 2018 00:12:39 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 01FB02BB21 for ; Thu, 1 Nov 2018 00:12:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbeKAJMn (ORCPT ); Thu, 1 Nov 2018 05:12:43 -0400 Received: from onstation.org ([52.200.56.107]:44736 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbeKAJMn (ORCPT ); Thu, 1 Nov 2018 05:12:43 -0400 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id 53749B16; Thu, 1 Nov 2018 00:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1541031132; bh=8BWQWQ+xr3McwXDoUVN3CB+hNGPKWAbseZvEW6eyT2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bAMB2Y/Lbro5JxhZIq9EddvsglrnJaDjjPb4xZXSSL+1w/nEMoCntMVrsmnf614kt N4q8OzNKTHrCNoxkf3Xx58oTPfQ7X4mkSUVhZjcIhKcrpHcW8AETjeu79JXMgzM7pM hI1x5MtfKUtV3f4BU8mE9Y9Glg3ZoIGMTFUDQFXE= From: Brian Masney To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, david.brown@linaro.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-gpio@vger.kernel.org, jonathan@marek.ca, masneyb@onstation.org Subject: [PATCH v2 5/7] pinctrl: qcom: spmi-gpio: fix gpio-hog related boot issues Date: Wed, 31 Oct 2018 20:11:47 -0400 Message-Id: <20181101001149.13453-6-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181101001149.13453-1-masneyb@onstation.org> References: <20181101001149.13453-1-masneyb@onstation.org> 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 When attempting to setup up a gpio hog, device probing would repeatedly fail with -EPROBE_DEFERED errors. It was caused by a circular dependency between the gpio and pinctrl frameworks. If the gpio-ranges property is present in device tree, then the gpio framework will handle the gpio pin registration and eliminate the circular dependency. See Christian Lamparter's commit a86caa9ba5d7 ("pinctrl: msm: fix gpio-hog related boot issues") for a detailed commit message that explains the issue in much more detail. The code comment in this commit came from Christian's commit. Signed-off-by: Brian Masney --- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index a29efbe08f48..4c1ff9a1d156 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -1028,10 +1028,23 @@ static int pmic_gpio_probe(struct platform_device *pdev) return ret; } - ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins); - if (ret) { - dev_err(dev, "failed to add pin range\n"); - goto err_range; + /* + * For DeviceTree-supported systems, the gpio core checks the + * pinctrl's device node for the "gpio-ranges" property. + * If it is present, it takes care of adding the pin ranges + * for the driver. In this case the driver can skip ahead. + * + * In order to remain compatible with older, existing DeviceTree + * files which don't set the "gpio-ranges" property or systems that + * utilize ACPI the driver has to call gpiochip_add_pin_range(). + */ + if (!of_property_read_bool(dev->of_node, "gpio-ranges")) { + ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, + npins); + if (ret) { + dev_err(dev, "failed to add pin range\n"); + goto err_range; + } } return 0; From patchwork Thu Nov 1 00:11:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10663393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA77614E2 for ; Thu, 1 Nov 2018 00:12:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B72012BB21 for ; Thu, 1 Nov 2018 00:12:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAA412BB84; Thu, 1 Nov 2018 00:12:38 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 54C292BB21 for ; Thu, 1 Nov 2018 00:12:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726008AbeKAJNB (ORCPT ); Thu, 1 Nov 2018 05:13:01 -0400 Received: from onstation.org ([52.200.56.107]:44742 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbeKAJMn (ORCPT ); Thu, 1 Nov 2018 05:12:43 -0400 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id F1FA3B1B; Thu, 1 Nov 2018 00:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1541031133; bh=4mmS8g3BUwANY5KeH5yJhJC1zVPkZ6l5KTXXz7Tg69Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sSF5ZIhNOKdWaxDA4QbmkpCFfR99MzccqlyD/ylA29aZiqevKX5ZXQc64DeGcs1HS OIIEWsp7Exjkx1KC4NeOf6agbbH0Md4cxEH1Cqsq4hqFO5gzU4YQo3L1mo4gW4fmuD 2+QPvNK5RtbzVUYNTCg5CForNYjdgOs6ChTiA0yI= From: Brian Masney To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, david.brown@linaro.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-gpio@vger.kernel.org, jonathan@marek.ca, masneyb@onstation.org Subject: [PATCH v2 6/7] ARM: dts: qcom: msm8974: add gpio-ranges Date: Wed, 31 Oct 2018 20:11:48 -0400 Message-Id: <20181101001149.13453-7-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181101001149.13453-1-masneyb@onstation.org> References: <20181101001149.13453-1-masneyb@onstation.org> 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 This adds the gpio-ranges property to pm8941_gpios so that the GPIO pins are initialized by the GPIO framework and not pinctrl. This fixes a circular dependency so GPIO hogging can be used on this board. Signed-off-by: Brian Masney --- arch/arm/boot/dts/qcom-pm8941.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/qcom-pm8941.dtsi b/arch/arm/boot/dts/qcom-pm8941.dtsi index 2515c5c217ac..9a91b758f7aa 100644 --- a/arch/arm/boot/dts/qcom-pm8941.dtsi +++ b/arch/arm/boot/dts/qcom-pm8941.dtsi @@ -63,6 +63,7 @@ compatible = "qcom,pm8941-gpio", "qcom,spmi-gpio"; reg = <0xc000>; gpio-controller; + gpio-ranges = <&pm8941_gpios 0 0 36>; #gpio-cells = <2>; interrupts = <0 0xc0 0 IRQ_TYPE_NONE>, <0 0xc1 0 IRQ_TYPE_NONE>, From patchwork Thu Nov 1 00:11:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10663387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2600D3CF1 for ; Thu, 1 Nov 2018 00:12:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13EDD2BB21 for ; Thu, 1 Nov 2018 00:12:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 071782BB84; Thu, 1 Nov 2018 00:12:25 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 9E3C52BB6A for ; Thu, 1 Nov 2018 00:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727386AbeKAJMr (ORCPT ); Thu, 1 Nov 2018 05:12:47 -0400 Received: from onstation.org ([52.200.56.107]:44756 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726754AbeKAJMo (ORCPT ); Thu, 1 Nov 2018 05:12:44 -0400 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id 97E9EB1E; Thu, 1 Nov 2018 00:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1541031134; bh=XUFaoN3spf9OjBDDG9iABnkQ23WtmWxSIkMyZk2mwAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TlDy1FzB+z5XdK3+SaWpfaXiD9wjUajaqiBQtHhJpD/GcR/Hpni2OjCxpFDP+cEuH ANhbOz6yCDfBTocCBe2C9K3qUxAR1EkgD3juubc3d3xaGr/Qcmd570WwS9msqDyJ9B R1zuBC2DDbqGw3Gabxaqvz5KlxZzfOaKVX2DF84c= From: Brian Masney To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, david.brown@linaro.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-gpio@vger.kernel.org, jonathan@marek.ca, masneyb@onstation.org Subject: [PATCH v2 7/7] ARM: dts: qcom: msm8974-hammerhead: add USB OTG support Date: Wed, 31 Oct 2018 20:11:49 -0400 Message-Id: <20181101001149.13453-8-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181101001149.13453-1-masneyb@onstation.org> References: <20181101001149.13453-1-masneyb@onstation.org> 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 Add the device tree bindings for USB OTG support. Driver was tested using on a LG Nexus 5 (hammerhead) phone. This patch is based on work from Jonathan Marek and from the other msm8974 devices. Signed-off-by: Brian Masney --- .../qcom-msm8974-lge-nexus5-hammerhead.dts | 60 +++++++++++++++++++ arch/arm/boot/dts/qcom-msm8974.dtsi | 11 ++++ 2 files changed, 71 insertions(+) diff --git a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts index ed8f064d0895..f67ab43956dc 100644 --- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts +++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts @@ -242,6 +242,16 @@ }; }; + i2c1_pins: i2c1 { + mux { + pins = "gpio2", "gpio3"; + function = "blsp_i2c1"; + + drive-strength = <2>; + bias-disable; + }; + }; + i2c3_pins: i2c3 { mux { pins = "gpio10", "gpio11"; @@ -343,6 +353,24 @@ }; }; + i2c@f9923000 { + status = "ok"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins>; + clock-frequency = <100000>; + qcom,src-freq = <50000000>; + + charger: bq24192@6b { + compatible = "ti,bq24192"; + reg = <0x6b>; + interrupts-extended = <&spmi_bus 0 0xd5 0 IRQ_TYPE_EDGE_FALLING>; + + omit-battery-class; + + usb_otg_vbus: usb-otg-vbus { }; + }; + }; + i2c@f9925000 { status = "ok"; pinctrl-names = "default"; @@ -360,6 +388,31 @@ amstaos,proximity-diodes = <0>; }; }; + + usb@f9a55000 { + status = "ok"; + + phys = <&usb_hs1_phy>; + phy-select = <&tcsr 0xb000 0>; + + extcon = <&charger>, <&usb_id>; + vbus-supply = <&usb_otg_vbus>; + + hnp-disable; + srp-disable; + adp-disable; + + ulpi { + phy@a { + status = "ok"; + + v1p8-supply = <&pm8941_l6>; + v3p3-supply = <&pm8941_l24>; + + qcom,init-seq = /bits/ 8 <0x1 0x64>; + }; + }; + }; }; &spmi_bus { @@ -372,6 +425,13 @@ bias-pull-up; power-source = ; }; + + otg { + gpio-hog; + gpios = <35 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "otg-gpio"; + }; }; }; }; diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi b/arch/arm/boot/dts/qcom-msm8974.dtsi index aba159d5a95a..8294192db9eb 100644 --- a/arch/arm/boot/dts/qcom-msm8974.dtsi +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi @@ -704,6 +704,17 @@ interrupts = ; }; + i2c@f9923000 { + status = "disabled"; + compatible = "qcom,i2c-qup-v2.1.1"; + reg = <0xf9923000 0x1000>; + interrupts = <0 95 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&gcc GCC_BLSP1_QUP1_I2C_APPS_CLK>, <&gcc GCC_BLSP1_AHB_CLK>; + clock-names = "core", "iface"; + #address-cells = <1>; + #size-cells = <0>; + }; + i2c@f9924000 { status = "disabled"; compatible = "qcom,i2c-qup-v2.1.1";