From patchwork Tue Aug 13 18:11:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 171206 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1236925ily; Tue, 13 Aug 2019 11:12:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQbsjXIBXBpVsJMIIIneqUIutyN2gKx2DCy9KcpCFZRhhiapYIWuo4ApY43c8SBQgKBiMP X-Received: by 2002:a65:6458:: with SMTP id s24mr35040658pgv.158.1565719934314; Tue, 13 Aug 2019 11:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565719934; cv=none; d=google.com; s=arc-20160816; b=tC9OKsTrdfQjIMlCeyKm32CztxVSXzzf7I1m51Yws/6PJGEqE9GE8wtx2fG72RU4jc 2FF/UWxe7u+nd+vnvgW8/m7KFZRs9NOKdNHi6xQ22Hpn0hDHEICofAEWgrZ34sPOlcGj ukNPRRE9qTuSNPdLZpsEy1pdVd+fpRCPuXl0WkQ+OAOobaMP3LrXOJZdwsWraXuSy/CO LiMJR2PM0+EVaGk7IYiVKDnIxBZYQPx/GGYMDXek+yKGRq9MVxZlEn66CJkfuVxtTCm0 iP8wS1HXwUEMH5gkAcG0mx04Yqm8YBdtqhR0ggPHN907irFhBkAOinNHf1L1AmWc11RT uIow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6IElY7mu7NaowaOQQQSPP6rPLthYZQitAQKvQcMKjKE=; b=E0m2R/J0W8Z3v/RfNb7kI3CxMgykyFlwKY4BbEdBv+dU5YJfQH9MFJ2m0X8C0JbzmC xmBalpen3izgw47w9Ccgt17QzenrNKN1uU1xCcGHvykF1rG+bKBKmPCaFqHzg/jR5F66 f+SbMpfR47mrwuEVmUUO1TTJC5TuoSbtzLyR9DnEgCsxHeg0aiIHPFvo/WEkaoL8Y/DA ZkoanDouN6GxotNSFZe4jC93RsQthdrrz8Od7dpU/v8W4GN9s2bMpHRzmP8873OZbEkk MrnmPESuOoKUg08JPuYAAyYidTwtpK/ZGtcSzNF2TMjKhMh4h6tLr+YerkUXhWs4uJCK 1Hrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JrpWH2mS; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u9si53959179pgr.196.2019.08.13.11.12.14; Tue, 13 Aug 2019 11:12:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JrpWH2mS; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728442AbfHMSMM (ORCPT + 1 other); Tue, 13 Aug 2019 14:12:12 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:53536 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728389AbfHMSML (ORCPT ); Tue, 13 Aug 2019 14:12:11 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7DIBxGC093394; Tue, 13 Aug 2019 13:11:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1565719919; bh=6IElY7mu7NaowaOQQQSPP6rPLthYZQitAQKvQcMKjKE=; h=From:To:CC:Subject:Date; b=JrpWH2mS9kUG9vn0WkYsW2nxuloDCDK1QZkLLHB6wFi3wPsC3mVQUc2/Dh2M22QA5 qf9tF+9/dgkJpl94W7LpuahhxBumzbUwhJgiMh/gZIu6pabhuJqKR+cGiov0o6yR/z Cq3pRGKcjslAiwb/ZujyVwnk4l689bsuju1uDTNs= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7DIBxw8004227 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Aug 2019 13:11:59 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 13 Aug 2019 13:11:59 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 13 Aug 2019 13:11:59 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x7DIBwNM051016; Tue, 13 Aug 2019 13:11:59 -0500 From: Dan Murphy To: , , , , , , CC: , , Dan Murphy Subject: [PATCH v2 1/4] leds: lm3532: Fix brightness control for i2c mode Date: Tue, 13 Aug 2019 13:11:51 -0500 Message-ID: <20190813181154.6614-1-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Fix the brightness control for I2C mode. Instead of changing the full scale current register update the ALS target register for the appropriate banks. In addition clean up some code errors and random misspellings found during coding. Tested on Droid4 as well as LM3532 EVM connected to a BeagleBoneBlack Fixes: e37a7f8d77e1 ("leds: lm3532: Introduce the lm3532 LED driver") Reported-by: Pavel Machek Signed-off-by: Dan Murphy --- v2 - Separated out random fixes and brightness control fix - https://lore.kernel.org/patchwork/patch/1109502/ drivers/leds/leds-lm3532.c | 56 ++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 20 deletions(-) -- 2.22.0.214.g8dca754b1e Acked-by: Pavel Machek diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index 646100724971..b28b7f63198b 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -23,11 +23,11 @@ #define LM3532_REG_PWM_B_CFG 0x14 #define LM3532_REG_PWM_C_CFG 0x15 #define LM3532_REG_ZONE_CFG_A 0x16 -#define LM3532_REG_CTRL_A_BRT 0x17 +#define LM3532_REG_CTRL_A_FS_CURR 0x17 #define LM3532_REG_ZONE_CFG_B 0x18 -#define LM3532_REG_CTRL_B_BRT 0x19 +#define LM3532_REG_CTRL_B_FS_CURR 0x19 #define LM3532_REG_ZONE_CFG_C 0x1a -#define LM3532_REG_CTRL_C_BRT 0x1b +#define LM3532_REG_CTRL_C_FS_CURR 0x1b #define LM3532_REG_ENABLE 0x1d #define LM3532_ALS_CONFIG 0x23 #define LM3532_REG_ZN_0_HI 0x60 @@ -38,6 +38,9 @@ #define LM3532_REG_ZN_2_LO 0x65 #define LM3532_REG_ZN_3_HI 0x66 #define LM3532_REG_ZN_3_LO 0x67 +#define LM3532_REG_ZONE_TRGT_A 0x70 +#define LM3532_REG_ZONE_TRGT_B 0x75 +#define LM3532_REG_ZONE_TRGT_C 0x7a #define LM3532_REG_MAX 0x7e /* Contorl Enable */ @@ -116,6 +119,7 @@ struct lm3532_als_data { * @priv - Pointer the device data structure * @control_bank - Control bank the LED is associated to * @mode - Mode of the LED string + * @ctrl_brt_pointer - Zone target register that controls the sink * @num_leds - Number of LED strings are supported in this array * @led_strings - The LED strings supported in this array * @label - LED label @@ -126,6 +130,7 @@ struct lm3532_led { int control_bank; int mode; + int ctrl_brt_pointer; int num_leds; u32 led_strings[LM3532_MAX_CONTROL_BANKS]; char label[LED_MAX_NAME_SIZE]; @@ -168,11 +173,11 @@ static const struct reg_default lm3532_reg_defs[] = { {LM3532_REG_PWM_B_CFG, 0x82}, {LM3532_REG_PWM_C_CFG, 0x82}, {LM3532_REG_ZONE_CFG_A, 0xf1}, - {LM3532_REG_CTRL_A_BRT, 0xf3}, + {LM3532_REG_CTRL_A_FS_CURR, 0x13}, {LM3532_REG_ZONE_CFG_B, 0xf1}, - {LM3532_REG_CTRL_B_BRT, 0xf3}, + {LM3532_REG_CTRL_B_FS_CURR, 0x13}, {LM3532_REG_ZONE_CFG_C, 0xf1}, - {LM3532_REG_CTRL_C_BRT, 0xf3}, + {LM3532_REG_CTRL_C_FS_CURR, 0x13}, {LM3532_REG_ENABLE, 0xf8}, {LM3532_ALS_CONFIG, 0x44}, {LM3532_REG_ZN_0_HI, 0x35}, @@ -339,8 +344,8 @@ static int lm3532_brightness_set(struct led_classdev *led_cdev, if (ret) goto unlock; - brightness_reg = LM3532_REG_CTRL_A_BRT + led->control_bank * 2; - brt_val = brt_val / LM3532_BRT_VAL_ADJUST; + brightness_reg = LM3532_REG_ZONE_TRGT_A + led->control_bank * 5 + + (led->ctrl_brt_pointer >> 2); ret = regmap_write(led->priv->regmap, brightness_reg, brt_val); @@ -356,8 +361,30 @@ static int lm3532_init_registers(struct lm3532_led *led) unsigned int output_cfg_val = 0; unsigned int output_cfg_shift = 0; unsigned int output_cfg_mask = 0; + unsigned int brightness_config_reg; + unsigned int brightness_config_val; int ret, i; + if (drvdata->enable_gpio) + gpiod_direction_output(drvdata->enable_gpio, 1); + + brightness_config_reg = LM3532_REG_ZONE_CFG_A + led->control_bank * 2; + /* + * This could be hard coded to the default value but the control + * brightness register may have changed during boot. + */ + ret = regmap_read(drvdata->regmap, brightness_config_reg, + &led->ctrl_brt_pointer); + if (ret) + return ret; + + led->ctrl_brt_pointer &= LM3532_ZONE_MASK; + brightness_config_val = led->ctrl_brt_pointer | led->mode; + ret = regmap_write(drvdata->regmap, brightness_config_reg, + brightness_config_val); + if (ret) + return ret; + for (i = 0; i < led->num_leds; i++) { output_cfg_shift = led->led_strings[i] * 2; output_cfg_val |= (led->control_bank << output_cfg_shift); @@ -382,7 +409,6 @@ static int lm3532_als_configure(struct lm3532_data *priv, struct lm3532_als_data *als = priv->als_data; u32 als_vmin, als_vmax, als_vstep; int zone_reg = LM3532_REG_ZN_0_HI; - int brightnes_config_reg; int ret; int i; @@ -411,14 +437,7 @@ static int lm3532_als_configure(struct lm3532_data *priv, als->config = (als->als_avrg_time | (LM3532_ENABLE_ALS) | (als->als_input_mode << LM3532_ALS_SEL_SHIFT)); - ret = regmap_write(priv->regmap, LM3532_ALS_CONFIG, als->config); - if (ret) - return ret; - - brightnes_config_reg = LM3532_REG_ZONE_CFG_A + led->control_bank * 2; - - return regmap_update_bits(priv->regmap, brightnes_config_reg, - LM3532_I2C_CTRL, LM3532_ALS_CTRL); + return regmap_write(priv->regmap, LM3532_ALS_CONFIG, als->config); } static int lm3532_parse_als(struct lm3532_data *priv) @@ -634,9 +653,6 @@ static int lm3532_probe(struct i2c_client *client, return ret; } - if (drvdata->enable_gpio) - gpiod_direction_output(drvdata->enable_gpio, 1); - return ret; } From patchwork Tue Aug 13 18:11:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 171205 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1236865ily; Tue, 13 Aug 2019 11:12:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDrIhHQk5VyiLugSTA2b68K6cRwRkvydllV2JX1KGoOlzByqxR6hi44JCnRp9+roWFRjtf X-Received: by 2002:a63:2887:: with SMTP id o129mr28943669pgo.179.1565719931066; Tue, 13 Aug 2019 11:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565719931; cv=none; d=google.com; s=arc-20160816; b=KHg6mMFMSjFKuI+pfxefnV0925lOvAlc0pyHqTUVMhK5PVhKq2EAm107irhX7mS6Io WXBZTafL5Mc+S9ZK6R1ippE5ntA7lllUZo7YuwLaT5Hk16sTaFY2GFlxOb45bDauT4Ss Riaqq4Ri1usqyn8og/XurxwgOpFyi0zy3m3uB9ISuLwUFROxLu1bg7Ct5Ly/1aPNTUmg tSRiN8i7WUdaAA/M6pdY8lPIdO0vgCVmJ4QdC6ESBOJrpeJxmJCsluvls8Z7A4zaN87k xtpFyOUDfoWxgFnBGiwZeBXTb1Q8GfrH4MP0DOyOtdNMCljh0Yap9SiMq/4tCWtkRSqM g3BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I/IFBZHJxBn9bBq7cBF0dvoXV8U66cz6/84fF3yjhzY=; b=plyNnnuCZG9NigSBWkF6AJOOUrsyQpCM41GWagdf8OyC51u7weLLMpWaivOq+TT526 fp7gtWvoLBE5mUE3Mvp65IwyzCnVL2bJWGrpuWiJOeSpEJFjjhmSAYlMaZ28y/J3VSVZ IG8dB4zIvV0T/tMOwsqokesLToIb1O9YFMkl/gfPVV0Nceb0dwUNlcInSZRtIFP0qKZ6 HMXMoha3Yx8ZLeHmxZ/0OxqCQIj9Zakhy8DjTFJ04oFMAynU+AhlHLavFIXRDsWjWI8P uIQPiLdePidiM68QYjDTg6bxiD7kzjNhYGDWG6q2XQRHUzdQcDnAqp8V/uzYwS1pTOkb QtnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CSKoW6X7; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4si64715998pgh.350.2019.08.13.11.12.10; Tue, 13 Aug 2019 11:12:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CSKoW6X7; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728345AbfHMSMK (ORCPT + 1 other); Tue, 13 Aug 2019 14:12:10 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:33206 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727517AbfHMSMK (ORCPT ); Tue, 13 Aug 2019 14:12:10 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7DIBx0o013157; Tue, 13 Aug 2019 13:11:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1565719919; bh=I/IFBZHJxBn9bBq7cBF0dvoXV8U66cz6/84fF3yjhzY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CSKoW6X7HPWwS89l7MXgLiHGIQgJqolBzYS4OFxTZ3Nhr0D8h708kMusV4DWZUw6/ IkHYDhudbXN9LpXpnF4Z9PXV8REZxyO0wCbNIc1SEOL99XTScSGeZykccXqz4i9f8/ GcFP4Z4zQw2yNs/HA94qu9aTFxq3c2CG+fTm7cmk= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7DIBx79004380 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Aug 2019 13:11:59 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 13 Aug 2019 13:11:59 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 13 Aug 2019 13:11:59 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x7DIBxgn013188; Tue, 13 Aug 2019 13:11:59 -0500 From: Dan Murphy To: , , , , , , CC: , , Dan Murphy Subject: [PATCH v2 2/4] leds: lm3532: Fixes for the driver for stability Date: Tue, 13 Aug 2019 13:11:52 -0500 Message-ID: <20190813181154.6614-2-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190813181154.6614-1-dmurphy@ti.com> References: <20190813181154.6614-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Fixed misspelled words, added error check during probe on the init of the registers, and fixed ALS/I2C control mode. Fixes: e37a7f8d77e1 ("leds: lm3532: Introduce the lm3532 LED driver") Reported-by: Pavel Machek Signed-off-by: Dan Murphy --- v2 - New patch due to separating out random fixes and brightness control fix - https://lore.kernel.org/patchwork/patch/1109502/ drivers/leds/leds-lm3532.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 2.22.0.214.g8dca754b1e diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index b28b7f63198b..ef4c74cbcdc0 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -43,7 +43,7 @@ #define LM3532_REG_ZONE_TRGT_C 0x7a #define LM3532_REG_MAX 0x7e -/* Contorl Enable */ +/* Control Enable */ #define LM3532_CTRL_A_ENABLE BIT(0) #define LM3532_CTRL_B_ENABLE BIT(1) #define LM3532_CTRL_C_ENABLE BIT(2) @@ -307,7 +307,7 @@ static int lm3532_led_disable(struct lm3532_led *led_data) int ret; ret = regmap_update_bits(led_data->priv->regmap, LM3532_REG_ENABLE, - ctrl_en_val, ~ctrl_en_val); + ctrl_en_val, 0); if (ret) { dev_err(led_data->priv->dev, "Failed to set ctrl:%d\n", ret); return ret; @@ -326,7 +326,7 @@ static int lm3532_brightness_set(struct led_classdev *led_cdev, mutex_lock(&led->priv->lock); - if (led->mode == LM3532_BL_MODE_ALS) { + if (led->mode == LM3532_ALS_CTRL) { if (brt_val > LED_OFF) ret = lm3532_led_enable(led); else @@ -561,11 +561,14 @@ static int lm3532_parse_node(struct lm3532_data *priv) } if (led->mode == LM3532_BL_MODE_ALS) { + led->mode = LM3532_ALS_CTRL; ret = lm3532_parse_als(priv); if (ret) dev_err(&priv->client->dev, "Failed to parse als\n"); else lm3532_als_configure(priv, led); + } else { + led->mode = LM3532_I2C_CTRL; } led->num_leds = fwnode_property_count_u32(child, "led-sources"); @@ -606,7 +609,13 @@ static int lm3532_parse_node(struct lm3532_data *priv) goto child_out; } - lm3532_init_registers(led); + ret = lm3532_init_registers(led); + if (ret) { + dev_err(&priv->client->dev, "register init err: %d\n", + ret); + fwnode_handle_put(child); + goto child_out; + } i++; } From patchwork Tue Aug 13 18:11:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 171204 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1236858ily; Tue, 13 Aug 2019 11:12:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfiNYwIuTLmd4tYKX8Kf5YSeEfjea0vwpPltHtXZJI8FYsawSkSY9p0xzkMxzU5Fj4lwsF X-Received: by 2002:aa7:9197:: with SMTP id x23mr41779183pfa.95.1565719930760; Tue, 13 Aug 2019 11:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565719930; cv=none; d=google.com; s=arc-20160816; b=X5X7FM+1d45fC5q4bcND+kz+mO1c5bPEkKTndDvq95t34wzUAjNf19JeT9rQdOQYI2 d6Tkssi3cVc4nJ0vjct9dvPuzK49r0tAyjwZDo9zwwc4bWVyeO0uxkctq3RuEHT/hrxU aAhPGNKAn/mTiuV+IrmKTRmXgzFZzaZzI4CpF0USiuZUWxU3m1HF2v0h6tkkzfqWHhMm csDe/BR0khAsbo7hzOh1IeZSoQrGnFcEAmlf9Ur+XA8JA3vf6zGGPEbR+HGnd400TB6K IK/CxRxEHTYcNG7RS5AuBLiTQ2MxeA0UuQNq0vQUQ5H8EyxXX0H5h2v/dPDDZevVn+8i q2Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rcJORkZ6Sdyk2JGl2jXoFIyuGmwVg+r6vi7peaiEtlw=; b=Pd0nTqLuorWZBDCpiyDVa4S4nZDjKeaj0dnNXUKSLEd8s7SJeEzuKFm07Jetxvd7Qc 0TluTIz2/alK+AEVn/uEpB9vSXWrbyB5YCl8av39Ygs+/WVYFLrEl/o/OSpTTjE9k1bI JII8uq6Y4uUUIcJrAPY/+PbiXStEfYrqqDB4KjlZRZ2tOYSP/Y3+xIz5nYtXJHDj6o8L 4kTDxanUUditK42l+OpPIClFgnh8HWPXduQudIEiGD2KXueH9QfGX3QBjUEYuaSg2wac MQ6vBILLPiChTBFENM/mv+UZE2+KVqlmuTBk8vUbSC9+blYg1bAaSUxR59Fe6u2FRodz 5IEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=IcH5DOon; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4si64715998pgh.350.2019.08.13.11.12.10; Tue, 13 Aug 2019 11:12:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=IcH5DOon; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728393AbfHMSMK (ORCPT + 1 other); Tue, 13 Aug 2019 14:12:10 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:39772 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728345AbfHMSMJ (ORCPT ); Tue, 13 Aug 2019 14:12:09 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7DIC0Ih061504; Tue, 13 Aug 2019 13:12:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1565719920; bh=rcJORkZ6Sdyk2JGl2jXoFIyuGmwVg+r6vi7peaiEtlw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=IcH5DOonvzv3nLDM3nm1vW+BUC0irajM0A9YqwmHZa+LIzbOfEjHwrdFn/Rrk9L2T ekD2KMtoXmjE95vzRZVTO3yF+iwXryCu4MVwEJF45c3h2qE4xOf/0ErrPdTFTHU2/K whAHXPbqHlmuEEkEg6V80NZATq+cLAN3M1StgEYw= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7DIC0QR004387 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Aug 2019 13:12:00 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 13 Aug 2019 13:11:59 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 13 Aug 2019 13:11:59 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x7DIBxNe051021; Tue, 13 Aug 2019 13:11:59 -0500 From: Dan Murphy To: , , , , , , CC: , , Dan Murphy Subject: [PATCH v2 3/4] dt: lm3532: Add property for full scale current. Date: Tue, 13 Aug 2019 13:11:53 -0500 Message-ID: <20190813181154.6614-3-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190813181154.6614-1-dmurphy@ti.com> References: <20190813181154.6614-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Add a property for each control bank to configure the full scale current setting for the device. Signed-off-by: Dan Murphy --- v2 - Change ti,fs-current to led-max-microamp - https://lore.kernel.org/patchwork/patch/1109501/ Documentation/devicetree/bindings/leds/leds-lm3532.txt | 4 ++++ 1 file changed, 4 insertions(+) -- 2.22.0.214.g8dca754b1e diff --git a/Documentation/devicetree/bindings/leds/leds-lm3532.txt b/Documentation/devicetree/bindings/leds/leds-lm3532.txt index c087f85ddddc..53793213dd52 100644 --- a/Documentation/devicetree/bindings/leds/leds-lm3532.txt +++ b/Documentation/devicetree/bindings/leds/leds-lm3532.txt @@ -62,6 +62,9 @@ Optional LED child properties: - label : see Documentation/devicetree/bindings/leds/common.txt - linux,default-trigger : see Documentation/devicetree/bindings/leds/common.txt + - led-max-microamp : Defines the full scale current value for each control + bank. The range is from 5000uA-29800uA in increments + of 800uA. Example: led-controller@38 { @@ -85,6 +88,7 @@ led-controller@38 { reg = <0>; led-sources = <2>; ti,led-mode = <1>; + led-max-microamp = <21800>; label = ":backlight"; linux,default-trigger = "backlight"; }; From patchwork Tue Aug 13 18:11:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 171207 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1237076ily; Tue, 13 Aug 2019 11:12:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxx0qhKksEIi7UsypBlkgnmRWhb1KBSh5qACwfRlB1mWFXuCqramslBuKTkVlT+lTkhEZEH X-Received: by 2002:a17:90a:c70e:: with SMTP id o14mr3432742pjt.56.1565719943447; Tue, 13 Aug 2019 11:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565719943; cv=none; d=google.com; s=arc-20160816; b=NwLP8QaDfutFUEt2joZij/0DNRc2Y+XRbmfVOqbr7fvgeJrebv2jVoiz5x4G5dSnIw O27ho6p3v39Cb7p680iWr7ihMl7cvDJhnYjzO8ZMAFg1iPe/vYc9rdl/7RBb+aP9jbgD AkGlOs+RMSSzSc3KqDBZHH201uYbWCHOAhZFFTVyb71UsPGJ1wfkkamrHiQDVpP/bcrV mHBG5Bvp3X4l833AaoOWnOMeop1/o76FbK1d+W4sxFmZ8u7kqhP/SlC8RoBn/EU4OmHT 9W8qoffcwmpIoRWfRYC/85bv2mYYDpae+17Sajr2oPo0f6SIjmsO945h1BlJpZElf0Cv hF4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T8YhRhrUnmvguCG9ZbI6QXVwTo4aPfyMVmxa6iApDGM=; b=ILBOaG2DM23SizU/VbIinQB+SaQnLvxonG7IPbJ4fT4ITZeBovU+Zk2C3QDLCyICBH siElg4C6i45DzNqpybqjooKfRSs3x3M/qyZmtjJHrHj4MIvUvruowxasOFA8pF04DqAK 2H6nwwyO/NXJ2U83HPannKZZeRc1wZxu0crtQXkTKJpdmEfZi3MZtoJonQb67mau9c+C oMWuXpBhNMsoIRiW7ZWm14a/IwSVbgFa/+o7rbfKlBH/DccD6+nM6SuTSHuZEB9b6lTC 1YIJXC6GfwQP9etJtgZ7husCi4Ypo2BrUtQSroh65JNalr3up9h7PtG+rWGY6cFpzz9T vdfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="vc/E1EEm"; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 77si71354028pge.315.2019.08.13.11.12.23; Tue, 13 Aug 2019 11:12:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="vc/E1EEm"; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727491AbfHMSMW (ORCPT + 1 other); Tue, 13 Aug 2019 14:12:22 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:53534 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728387AbfHMSMK (ORCPT ); Tue, 13 Aug 2019 14:12:10 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7DIC0xJ093399; Tue, 13 Aug 2019 13:12:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1565719920; bh=T8YhRhrUnmvguCG9ZbI6QXVwTo4aPfyMVmxa6iApDGM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=vc/E1EEmhkXDcReMvUqdtA3Zasbbe59Wkkgb7yzmudJdHseGr+Lz/OPb2f4MjjfU7 hBd4YlWVVdho3bj007VV+hoam3dsok/IGhTz9JempUZvnWjfyuC2nGe0cEhsQ+Petr jRM9q6wVnFMumMQ180ibVj2brldVKETIQyxzBBgs= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7DIC0ov004393 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Aug 2019 13:12:00 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 13 Aug 2019 13:11:59 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 13 Aug 2019 13:11:59 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x7DIBxaZ013200; Tue, 13 Aug 2019 13:11:59 -0500 From: Dan Murphy To: , , , , , , CC: , , Dan Murphy Subject: [PATCH v2 4/4] leds: lm3532: Add full scale current configuration Date: Tue, 13 Aug 2019 13:11:54 -0500 Message-ID: <20190813181154.6614-4-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190813181154.6614-1-dmurphy@ti.com> References: <20190813181154.6614-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Allow the full scale current to be configured at init. Valid rangles are 5mA->29.8mA. Signed-off-by: Dan Murphy --- v2 - Change ti,fs-current to led-max-microamp - https://lore.kernel.org/patchwork/patch/1109503/ drivers/leds/leds-lm3532.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) -- 2.22.0.214.g8dca754b1e diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index ef4c74cbcdc0..dabf4be1e8c8 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -89,6 +89,10 @@ #define LM3532_NUM_AVG_VALS 8 #define LM3532_NUM_IMP_VALS 32 +#define LM3532_FS_CURR_MIN 5000 +#define LM3532_FS_CURR_MAX 29800 +#define LM3532_FS_CURR_STEP 800 + /* * struct lm3532_als_data * @config - value of ALS configuration register @@ -121,6 +125,7 @@ struct lm3532_als_data { * @mode - Mode of the LED string * @ctrl_brt_pointer - Zone target register that controls the sink * @num_leds - Number of LED strings are supported in this array + * @full_scale_current - The full-scale current setting for the current sink. * @led_strings - The LED strings supported in this array * @label - LED label */ @@ -130,8 +135,9 @@ struct lm3532_led { int control_bank; int mode; - int ctrl_brt_pointer; int num_leds; + int ctrl_brt_pointer; + int full_scale_current; u32 led_strings[LM3532_MAX_CONTROL_BANKS]; char label[LED_MAX_NAME_SIZE]; }; @@ -363,6 +369,8 @@ static int lm3532_init_registers(struct lm3532_led *led) unsigned int output_cfg_mask = 0; unsigned int brightness_config_reg; unsigned int brightness_config_val; + int fs_current_reg; + int fs_current_val; int ret, i; if (drvdata->enable_gpio) @@ -385,6 +393,16 @@ static int lm3532_init_registers(struct lm3532_led *led) if (ret) return ret; + if (led->full_scale_current) { + fs_current_reg = LM3532_REG_CTRL_A_FS_CURR + led->control_bank * 2; + fs_current_val = led->full_scale_current - LM3532_FS_CURR_MIN / + LM3532_FS_CURR_STEP; + ret = regmap_write(drvdata->regmap, fs_current_reg, + fs_current_val); + if (ret) + return ret; + } + for (i = 0; i < led->num_leds; i++) { output_cfg_shift = led->led_strings[i] * 2; output_cfg_val |= (led->control_bank << output_cfg_shift); @@ -560,6 +578,12 @@ static int lm3532_parse_node(struct lm3532_data *priv) goto child_out; } + ret = fwnode_property_read_u32(child, "led-max-microamp", + &led->full_scale_current); + + if (led->full_scale_current > LM3532_FS_CURR_MAX) + led->full_scale_current = LM3532_FS_CURR_MAX; + if (led->mode == LM3532_BL_MODE_ALS) { led->mode = LM3532_ALS_CTRL; ret = lm3532_parse_als(priv);