From patchwork Mon Apr 1 10:30:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10881203 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 60D281800 for ; Tue, 2 Apr 2019 07:44:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F3C2286DD for ; Tue, 2 Apr 2019 07:44:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 411E1286F7; Tue, 2 Apr 2019 07:44:08 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0535286DD for ; Tue, 2 Apr 2019 07:44:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D44BF6E6EE; Tue, 2 Apr 2019 07:43:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from onstation.org (onstation.org [52.200.56.107]) by gabe.freedesktop.org (Postfix) with ESMTPS id 632E36E13A for ; Mon, 1 Apr 2019 10:30:40 +0000 (UTC) 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 59EFB45712; Mon, 1 Apr 2019 10:30:39 +0000 (UTC) From: Brian Masney To: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, robh+dt@kernel.org Subject: [PATCH v2 1/3] backlight: lm3630a: return 0 on success in update_status functions Date: Mon, 1 Apr 2019 06:30:32 -0400 Message-Id: <20190401103034.21062-2-masneyb@onstation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190401103034.21062-1-masneyb@onstation.org> References: <20190401103034.21062-1-masneyb@onstation.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 02 Apr 2019 07:43:52 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=onstation.org; s=default; t=1554114639; bh=5GNMZuMutWpblu70V4TMNrWXVAEYx9h9YFO5aRXMzqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LtlAlEUNBmTjf1qIQM9kN05r/AKlgQJhRquKuqhfgyQA/nQ5pXzO85ERQCDF+0n13 hk1HKd9aA+nfArMs+ajbU2iG1PDA/mUwBvGyXJgkHDlenCJeobUHMBDJbygR8WYhfn flxGRmHnH2skbxVGDkBjANMTFHHfe8Q9CEr/Os2c= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org, jonathan@marek.ca, b.zolnierkie@samsung.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, jacek.anaszewski@gmail.com, pavel@ucw.cz, linux-leds@vger.kernel.org, dmurphy@ti.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP lm3630a_bank_a_update_status() and lm3630a_bank_b_update_status() both return the brightness value if the brightness was successfully updated. Writing to these attributes via sysfs would cause a 'Bad address' error to be returned. These functions should return 0 on success, so let's change it to correct that error. Signed-off-by: Brian Masney Fixes: 28e64a68a2ef ("backlight: lm3630: apply chip revision") --- drivers/video/backlight/lm3630a_bl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index 2030a6b77a09..ef2553f452ca 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -201,7 +201,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl) LM3630A_LEDA_ENABLE, LM3630A_LEDA_ENABLE); if (ret < 0) goto out_i2c_err; - return bl->props.brightness; + return 0; out_i2c_err: dev_err(pchip->dev, "i2c failed to access\n"); @@ -278,7 +278,7 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl) LM3630A_LEDB_ENABLE, LM3630A_LEDB_ENABLE); if (ret < 0) goto out_i2c_err; - return bl->props.brightness; + return 0; out_i2c_err: dev_err(pchip->dev, "i2c failed to access REG_CTRL\n"); From patchwork Mon Apr 1 10:30:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10881209 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 2A5B2922 for ; Tue, 2 Apr 2019 07:44:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14071286DD for ; Tue, 2 Apr 2019 07:44:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04AE3286F7; Tue, 2 Apr 2019 07:44:32 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9161B286DD for ; Tue, 2 Apr 2019 07:44:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3CD706E6FD; Tue, 2 Apr 2019 07:43:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from onstation.org (onstation.org [52.200.56.107]) by gabe.freedesktop.org (Postfix) with ESMTPS id DAAFE6E13A for ; Mon, 1 Apr 2019 10:30:40 +0000 (UTC) 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 D6E334571C; Mon, 1 Apr 2019 10:30:39 +0000 (UTC) From: Brian Masney To: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, robh+dt@kernel.org Subject: [PATCH v2 2/3] dt-bindings: backlight: add lm3630a bindings Date: Mon, 1 Apr 2019 06:30:33 -0400 Message-Id: <20190401103034.21062-3-masneyb@onstation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190401103034.21062-1-masneyb@onstation.org> References: <20190401103034.21062-1-masneyb@onstation.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 02 Apr 2019 07:43:52 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=onstation.org; s=default; t=1554114640; bh=MaQ72dM4520+ySIKlG5tbgDHj3EHxaDHTUGUZDJs7gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frMLJ+LOQ/SwroHGCUpg9OTXbwgFUiGZnos5PezPrXobFvwocjUeB+b23o7W/9faR FEIoUsjCbrJ1dw34VEBEz1521GLZtujVsJtgz5wuuZiwCNoKVDjRIWlscLvsfm2UiP uUrnIvynAMMKlODDwT2QD8w5cGiMwfLdS5LQJDXg= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org, jonathan@marek.ca, b.zolnierkie@samsung.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, jacek.anaszewski@gmail.com, pavel@ucw.cz, linux-leds@vger.kernel.org, dmurphy@ti.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add new backlight bindings for the TI LM3630A dual-string white LED. Signed-off-by: Brian Masney --- .../leds/backlight/lm3630a-backlight.yaml | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml diff --git a/Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml b/Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml new file mode 100644 index 000000000000..42a8c59d237a --- /dev/null +++ b/Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml @@ -0,0 +1,112 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/backlight/lm3630a-backlight.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI LM3630A High-Efficiency Dual-String White LED + +maintainers: + - Lee Jones + - Daniel Thompson + - Jingoo Han + +description: | + The LM3630A is a current-mode boost converter which supplies the power and + controls the current in up to two strings of 10 LEDs per string. + https://www.ti.com/product/LM3630A + +properties: + compatible: + const: ti,lm3630a + + reg: + maxItems: 1 + + ti,linear-mapping-mode: + description: | + Enable linear mapping mode. If disabled, then it will use exponential + mapping mode in which the ramp up/down appears to have a more uniform + tranisiton to the human eye. + type: boolean + +required: + - compatible + - reg + +patternProperties: + "^led*$": + type: object + description: | + Properties for a string of connected LEDs. + + properties: + label: + description: | + The label for this LED. If omitted, the label is taken from the node + name (excluding the unit address). It has to uniquely identify a + device, i.e. no other LED class device can be assigned the same label. + + led-sources: + description: | + List of device current outputs the LED is connected to. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 1 + maxItems: 2 + items: + minimum: 0 + maximum: 1 + + default-brightness: + description: Default brightness level on boot. + minimum: 0 + maximum: 255 + + max-brightness: + description: Maximum brightness level on boot. + minimum: 0 + maximum: 255 + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + lm3630a_bl@38 { + compatible = "ti,lm3630a"; + status = "ok"; + reg = <0x38>; + + led { + label = "main-lcd"; + led-sources = <0 1>; + default-brightness = <200>; + max-brightness = <255>; + }; + }; + }; + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + lm3630a_bl@38 { + compatible = "ti,lm3630a"; + status = "ok"; + reg = <0x38>; + + led-bank-a { + led-sources = <0>; + default-brightness = <150>; + ti,linear-mapping-mode; + }; + + led-bank-b { + led-sources = <1>; + default-brightness = <225>; + ti,linear-mapping-mode; + }; + }; + }; From patchwork Mon Apr 1 10:30:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10881207 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 A8DAB17EE for ; Tue, 2 Apr 2019 07:44:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96E2E286DD for ; Tue, 2 Apr 2019 07:44:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AF6B286F7; Tue, 2 Apr 2019 07:44:30 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 32604286DD for ; Tue, 2 Apr 2019 07:44:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE0756E6FA; Tue, 2 Apr 2019 07:43:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from onstation.org (onstation.org [52.200.56.107]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6BF986E13A for ; Mon, 1 Apr 2019 10:30:41 +0000 (UTC) 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 613424571E; Mon, 1 Apr 2019 10:30:40 +0000 (UTC) From: Brian Masney To: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, robh+dt@kernel.org Subject: [PATCH v2 3/3] backlight: lm3630a: add device tree supprt Date: Mon, 1 Apr 2019 06:30:34 -0400 Message-Id: <20190401103034.21062-4-masneyb@onstation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190401103034.21062-1-masneyb@onstation.org> References: <20190401103034.21062-1-masneyb@onstation.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 02 Apr 2019 07:43:52 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=onstation.org; s=default; t=1554114640; bh=LKI5QutWjmEa9X7MXO2InBl2G8mvzCmPoaPQ3bHxYAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LMynH7DlcvOvu14NthY5tN6clcMCTcg0O7jv3CYS8OCNLJ+dIyPBsCkaNxqat5toQ x5R93Dk8CNtHhH6oiZ4zmJWm3aHcTNKykJoxWVf1t2vixo7RYaC/2e3BlcDcRJ0wYs anqbw5OjWEGd+3s01pqwwS4DS8R5UcBX0EHWyUpo= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org, jonathan@marek.ca, b.zolnierkie@samsung.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, jacek.anaszewski@gmail.com, pavel@ucw.cz, linux-leds@vger.kernel.org, dmurphy@ti.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add device tree support to the lm3630a driver and allow configuring independently on both banks the mapping mode (linear or exponential), initial and maximum LED brightness. Driver was tested on a LG Nexus 5 (hammerhead) phone. Signed-off-by: Brian Masney --- drivers/video/backlight/lm3630a_bl.c | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index ef2553f452ca..96fbc1273dda 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -35,6 +35,9 @@ #define REG_MAX 0x50 #define INT_DEBOUNCE_MSEC 10 + +#define LM3630A_MAX_SOURCES 2 + struct lm3630a_chip { struct device *dev; struct delayed_work work; @@ -364,6 +367,64 @@ static const struct regmap_config lm3630a_regmap = { .max_register = REG_MAX, }; +static void lm3630a_parse_dt(struct lm3630a_chip *pchip) +{ + u32 sources[LM3630A_MAX_SOURCES], val; + struct device_node *child_node; + int num_sources, ret, i; + bool linear; + + for_each_available_child_of_node(pchip->dev->of_node, child_node) { + num_sources = of_property_count_u32_elems(child_node, + "led-sources"); + if (num_sources < 0) + continue; + + if (num_sources > LM3630A_MAX_SOURCES) + num_sources = LM3630A_MAX_SOURCES; + + ret = of_property_read_u32_array(child_node, "led-sources", + sources, num_sources); + if (ret) { + dev_err(pchip->dev, + "Error parsing led-sources node: %d\n", ret); + return; + } + + linear = of_property_read_bool(child_node, + "ti,linear-mapping-mode"); + + for (i = 0; i < num_sources; i++) { + if (sources[i] == 0) + pchip->pdata->leda_ctrl = linear ? + LM3630A_LEDA_ENABLE_LINEAR : + LM3630A_LEDA_ENABLE; + else if (sources[i] == 1) + pchip->pdata->ledb_ctrl = linear ? + LM3630A_LEDB_ENABLE_LINEAR : + LM3630A_LEDB_ENABLE; + + ret = of_property_read_u32(child_node, + "default-brightness", &val); + if (!ret) { + if (sources[i] == 0) + pchip->pdata->leda_init_brt = val; + else if (sources[i] == 1) + pchip->pdata->ledb_init_brt = val; + } + + ret = of_property_read_u32(child_node, "max-brightness", + &val); + if (!ret) { + if (sources[i] == 0) + pchip->pdata->leda_max_brt = val; + else if (sources[i] == 1) + pchip->pdata->ledb_max_brt = val; + } + } + }; +} + static int lm3630a_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -405,6 +466,7 @@ static int lm3630a_probe(struct i2c_client *client, pdata->ledb_init_brt = LM3630A_MAX_BRIGHTNESS; } pchip->pdata = pdata; + lm3630a_parse_dt(pchip); /* chip initialize */ rval = lm3630a_chip_init(pchip); @@ -470,11 +532,18 @@ static const struct i2c_device_id lm3630a_id[] = { {} }; +static const struct of_device_id lm3630a_match_table[] = { + { .compatible = "ti,lm3630a", }, + { }, +}; + + MODULE_DEVICE_TABLE(i2c, lm3630a_id); static struct i2c_driver lm3630a_i2c_driver = { .driver = { .name = LM3630A_NAME, + .of_match_table = lm3630a_match_table, }, .probe = lm3630a_probe, .remove = lm3630a_remove,