From patchwork Tue Sep 11 17:08:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 146471 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3867904ljw; Tue, 11 Sep 2018 10:08:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbbbXwTQ3b6XSru6ST0AvReC6Hu9sWdMVdMgaAKNX7dMHE5Xuz+BNHcpaXoUdYKcLwElS9T X-Received: by 2002:a17:902:33c2:: with SMTP id b60-v6mr28045115plc.11.1536685724886; Tue, 11 Sep 2018 10:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536685724; cv=none; d=google.com; s=arc-20160816; b=kDzn3XLCAFg0BMdqB/68AWCNbm4zO3D2Td6w7VydHy3Kr6wAgk/nK1sPXs8T19IFSN gFra2F+qXyA9LGtjPWAEbo8KXX/asrmbeh7HCGgKr+3ZudgjFzB34PQ7OjUYdX1R1WlN n8u3IjcSR62xqCUwuH+WNzHUhEnhYASDzgz6j5rsEjul8THGjI6WruEee/g/9gO8Hkcn U4ej9sWF+XPfFYCQ/LzPcZzcdtYdsFV4IAcsmDz22L/ogMUOwyrJIPzrLaBhBm/0s4C3 fg5MX3Vq0Fvn6ovt32tzYftAhkSb1V3k1YYSS4sTJyW5J6rqNVV6B2NP2lI2MEYewsPS gRlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kh2l01P4zerw70aSFs4dPPkG7P09E5LHBe8WyPeQPtg=; b=OM8Yb8A//uL4qllRYuMOj4bSHs+ZVKbutjqtGeMD4Y9vZSXsSEfgARFT6qSUUpnK+W +NbG7TovB5ikR0zQVefdGTHdLCbbimQxV6e2HSOQrvteYIU6yuGmzVyya3RbEaIduMEj wYGgaxuSaSL72E7q6pUN331R6rIeDmDx2Wk3Tw7Vxr9lWo9kAyhPbH4+jn70KMuz5wlx y8IUstyxJJCZhM3mAQNE+fH443g3cPEP9xe2Dn2M77rXQer0M/sFfvAvcBxSE4fuCglK xLvmSY0h7e446z4XNi3ce5FQX8ErtNV67e6VC3vVHkbH6AjBPUdPoIXsmnBTRpkcmylc 7V2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZtGMTntR; 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; 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 d13-v6si21819463plj.286.2018.09.11.10.08.44; Tue, 11 Sep 2018 10:08:44 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZtGMTntR; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728218AbeIKWI4 (ORCPT + 32 others); Tue, 11 Sep 2018 18:08:56 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:55094 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727150AbeIKWIz (ORCPT ); Tue, 11 Sep 2018 18:08:55 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8BH8Zdg036284; Tue, 11 Sep 2018 12:08:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536685715; bh=kh2l01P4zerw70aSFs4dPPkG7P09E5LHBe8WyPeQPtg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ZtGMTntR+zsvPyqQEmeHarjHZq1Q7Nx6wiaIurzR6QBbO/9ZLqnQf/dV+Hl50Hpmz DDCU5mNx7XcZijTBhIGmO7BfKjdq9U0QCfGNZwy3KiMOnDEEor3oc0jZ0D4uQYRURR 2DjVEsmWSXomPmlyq0Qb0leykDJm5/GgjVEqpEC4= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8BH8ZYg031438; Tue, 11 Sep 2018 12:08:35 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 11 Sep 2018 12:08:35 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 11 Sep 2018 12:08:35 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8BH8ZfW000958; Tue, 11 Sep 2018 12:08:35 -0500 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.156.248]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8BH8Yx21193; Tue, 11 Sep 2018 12:08:35 -0500 (CDT) From: Dan Murphy To: , , CC: , , , , , Dan Murphy Subject: [PATCH v7 2/6] mfd: ti-lmu: Remove support for LM3697 Date: Tue, 11 Sep 2018 12:08:21 -0500 Message-ID: <20180911170825.17789-3-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20180911170825.17789-1-dmurphy@ti.com> References: <20180911170825.17789-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove support for the LM3697 from the ti-lmu driver in favor of a dedicated LED driver. Signed-off-by: Dan Murphy --- v7 - New change for the series based on the comments in https://lore.kernel.org/patchwork/patch/982550/ drivers/mfd/Kconfig | 2 +- drivers/mfd/ti-lmu.c | 17 ----------- include/linux/mfd/ti-lmu-register.h | 44 ----------------------------- include/linux/mfd/ti-lmu.h | 1 - 4 files changed, 1 insertion(+), 63 deletions(-) -- 2.17.0.1855.g63749b2dea diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 11841f4b7b2b..9b04dd527c68 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1293,7 +1293,7 @@ config MFD_TI_LMU help Say yes here to enable support for TI LMU chips. - TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697. + TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, and LM3695. It consists of backlight, LED and regulator driver. It provides consistent device controls for lighting functions. diff --git a/drivers/mfd/ti-lmu.c b/drivers/mfd/ti-lmu.c index cfb411cde51c..b6bfa99a29dd 100644 --- a/drivers/mfd/ti-lmu.c +++ b/drivers/mfd/ti-lmu.c @@ -128,20 +128,6 @@ static struct mfd_cell lm3695_devices[] = { }, }; -static struct mfd_cell lm3697_devices[] = { - { - .name = "ti-lmu-backlight", - .id = LM3697, - .of_compatible = "ti,lm3697-backlight", - }, - /* Monitoring driver for open/short circuit detection */ - { - .name = "ti-lmu-fault-monitor", - .id = LM3697, - .of_compatible = "ti,lm3697-fault-monitor", - }, -}; - #define TI_LMU_DATA(chip, max_reg) \ static const struct ti_lmu_data chip##_data = \ { \ @@ -155,7 +141,6 @@ TI_LMU_DATA(lm3631, LM3631_MAX_REG); TI_LMU_DATA(lm3632, LM3632_MAX_REG); TI_LMU_DATA(lm3633, LM3633_MAX_REG); TI_LMU_DATA(lm3695, LM3695_MAX_REG); -TI_LMU_DATA(lm3697, LM3697_MAX_REG); static const struct of_device_id ti_lmu_of_match[] = { { .compatible = "ti,lm3532", .data = &lm3532_data }, @@ -163,7 +148,6 @@ static const struct of_device_id ti_lmu_of_match[] = { { .compatible = "ti,lm3632", .data = &lm3632_data }, { .compatible = "ti,lm3633", .data = &lm3633_data }, { .compatible = "ti,lm3695", .data = &lm3695_data }, - { .compatible = "ti,lm3697", .data = &lm3697_data }, { } }; MODULE_DEVICE_TABLE(of, ti_lmu_of_match); @@ -237,7 +221,6 @@ static const struct i2c_device_id ti_lmu_ids[] = { { "lm3632", LM3632 }, { "lm3633", LM3633 }, { "lm3695", LM3695 }, - { "lm3697", LM3697 }, { } }; MODULE_DEVICE_TABLE(i2c, ti_lmu_ids); diff --git a/include/linux/mfd/ti-lmu-register.h b/include/linux/mfd/ti-lmu-register.h index 2125c7c02818..99711ff4b809 100644 --- a/include/linux/mfd/ti-lmu-register.h +++ b/include/linux/mfd/ti-lmu-register.h @@ -233,48 +233,4 @@ #define LM3695_REG_BRT_MSB 0x14 #define LM3695_MAX_REG 0x14 - -/* LM3697 */ -#define LM3697_REG_HVLED_OUTPUT_CFG 0x10 -#define LM3697_HVLED1_CFG_MASK BIT(0) -#define LM3697_HVLED2_CFG_MASK BIT(1) -#define LM3697_HVLED3_CFG_MASK BIT(2) -#define LM3697_HVLED1_CFG_SHIFT 0 -#define LM3697_HVLED2_CFG_SHIFT 1 -#define LM3697_HVLED3_CFG_SHIFT 2 - -#define LM3697_REG_BL0_RAMP 0x11 -#define LM3697_REG_BL1_RAMP 0x12 -#define LM3697_RAMPUP_MASK 0xF0 -#define LM3697_RAMPUP_SHIFT 4 -#define LM3697_RAMPDN_MASK 0x0F -#define LM3697_RAMPDN_SHIFT 0 - -#define LM3697_REG_RAMP_CONF 0x14 -#define LM3697_RAMP_MASK 0x0F -#define LM3697_RAMP_EACH 0x05 - -#define LM3697_REG_PWM_CFG 0x1C -#define LM3697_PWM_A_MASK BIT(0) -#define LM3697_PWM_B_MASK BIT(1) - -#define LM3697_REG_IMAX_A 0x17 -#define LM3697_REG_IMAX_B 0x18 - -#define LM3697_REG_FEEDBACK_ENABLE 0x19 - -#define LM3697_REG_BRT_A_LSB 0x20 -#define LM3697_REG_BRT_A_MSB 0x21 -#define LM3697_REG_BRT_B_LSB 0x22 -#define LM3697_REG_BRT_B_MSB 0x23 - -#define LM3697_REG_ENABLE 0x24 - -#define LM3697_REG_OPEN_FAULT_STATUS 0xB0 - -#define LM3697_REG_SHORT_FAULT_STATUS 0xB2 - -#define LM3697_REG_MONITOR_ENABLE 0xB4 - -#define LM3697_MAX_REG 0xB4 #endif diff --git a/include/linux/mfd/ti-lmu.h b/include/linux/mfd/ti-lmu.h index 09d5f30384e5..bc9272f08f47 100644 --- a/include/linux/mfd/ti-lmu.h +++ b/include/linux/mfd/ti-lmu.h @@ -26,7 +26,6 @@ enum ti_lmu_id { LM3632, LM3633, LM3695, - LM3697, LMU_MAX_ID, }; From patchwork Tue Sep 11 17:08:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 146474 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3868229ljw; Tue, 11 Sep 2018 10:09:04 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbMfeV2otp9IoQT1sK8y/M/RCNkPtbh83D62ebPkfmdgDSPNCfI6pYXGRRpl2EtPEFAjr7U X-Received: by 2002:a63:904a:: with SMTP id a71-v6mr29207077pge.339.1536685744514; Tue, 11 Sep 2018 10:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536685744; cv=none; d=google.com; s=arc-20160816; b=SfUlEqPkJR8QEipkhbRS7p9v6cKcdi9AGfHsA834HCjXvfEguaqlNy+7kI0lrWd2u4 ovPdJt9ffYN2WLvoM5tXcuFvMFMnm0pU/KABq11mNCz72Rp1o4xfuWDNi0Zi3Fu5P32X 4kz1791e8UdWn2uruaLrOCOp7A6xBzwdFio16nfAWyDUq4FiRJ3YNX2dWGX8qNDkeDj6 3wnaHRTDk1Qb69FeHLkWEUZApV3WJ4v+K3M/YphplD5M5tsfD31YCOp2OqElCN8yhSUk vxsGmYNjD7en2sVigg5Zmek1hhqSpo4Jlbsx3VuDauEFSuK62E+EOaw4iPbcKUKFM/Xx OTHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=vBT7eYOl/b/GfkzDoUUC59i4nMi6Z6A7h3GkQz6c1UA=; b=zF4Lujpp6+TVL6hwWbxRkODmVPuP4uzQ+Gb3Kb8bSdTZPXEsfb/CmCkBftfHXaBWHs JISytGk+XVp0Ny4lGVnhV7HI4ze2Dnsn9l4pdPWy+TMW+5OD4NyIzulumgcOXt8MoDCh z42tDXUsWFaGXvRimBIu8bBoY+afeQDtvkR73xNdHV1WDDnw64p3tJQWmihRTo19Vdol /pfVtoHBnDbUiftzjq+PmFYSZpqAD5gVhV3twPJFQ+NoU9zoiLuAC7zoFXoQaClbH11L H/mHMa4JtbfnSmzwzRK/D4/pKn+lWWyDa4BhMxVCuoMgYhB70zZCFittEBDnx/Idj2h3 DC0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DuTjDGrO; 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; 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 29-v6si21240848pgv.292.2018.09.11.10.09.04; Tue, 11 Sep 2018 10:09:04 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DuTjDGrO; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728242AbeIKWJG (ORCPT + 32 others); Tue, 11 Sep 2018 18:09:06 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:39256 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727332AbeIKWIz (ORCPT ); Tue, 11 Sep 2018 18:08:55 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8BH8aaP082830; Tue, 11 Sep 2018 12:08:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536685716; bh=vBT7eYOl/b/GfkzDoUUC59i4nMi6Z6A7h3GkQz6c1UA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DuTjDGrOY16w7OEtr+CeVr65hd054HhVpShy71diaHvXrGYFLEH7ZKkcEvpG/hf5W 4CoYJ5LgQONYkAVQ0lz8rVvjJAUq7zxAWyBAT2OQXDj1NTV1FnbvU4TXiHopFckV1m yXwXEi8GvsEjZOdTYgzshbYS6pTmTX9P7ZeEtuAQ= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8BH8a7V031473; Tue, 11 Sep 2018 12:08:36 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 11 Sep 2018 12:08:37 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 11 Sep 2018 12:08:36 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8BH8a45027290; Tue, 11 Sep 2018 12:08:36 -0500 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.156.248]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8BH8Zx21201; Tue, 11 Sep 2018 12:08:36 -0500 (CDT) From: Dan Murphy To: , , CC: , , , , , Dan Murphy Subject: [PATCH v7 4/6] leds: lm3697: Introduce the lm3697 driver Date: Tue, 11 Sep 2018 12:08:23 -0500 Message-ID: <20180911170825.17789-5-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20180911170825.17789-1-dmurphy@ti.com> References: <20180911170825.17789-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce the lm3697 LED driver for backlighting and display. Datasheet location: http://www.ti.com/lit/ds/symlink/lm3697.pdf Signed-off-by: Dan Murphy --- v7 - No change - https://lore.kernel.org/patchwork/patch/982551/ v6 - Fix nitpicks - https://lore.kernel.org/patchwork/patch/975388/ v5 - Fix nitpick issues with code - https://lore.kernel.org/patchwork/patch/975061/ v4 - Made modifications to the control bank routine to accomodate the DT changes https://lore.kernel.org/patchwork/patch/974811/ v3 - Add code to support led-sources and control bank configuration also fix other miscellaneous issues reported- https://lore.kernel.org/patchwork/patch/972336/ v2 - Removed unneed 'of' calls in dt_parse, fixed comment, fixed checkpatch error, and change led registration - https://lore.kernel.org/patchwork/patch/971327/ drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3697.c | 377 +++++++++++++++++++++++++++++++++++++ 3 files changed, 387 insertions(+) create mode 100644 drivers/leds/leds-lm3697.c -- 2.17.0.1855.g63749b2dea diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 44097a3e0fcc..784cbe375724 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -151,6 +151,15 @@ config LEDS_LM3642 converter plus 1.5A constant current driver for a high-current white LED. +config LEDS_LM3697 + tristate "LED support for LM3697 Chip" + depends on LEDS_CLASS && I2C + select REGMAP_I2C + help + This option enables support for LEDs connected to LM3697. + The LM3697 is an 11 bit high performance backlight driver for + keypad and display lighting. + config LEDS_LM3692X tristate "LED support for LM3692x Chips" depends on LEDS_CLASS && I2C && OF diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 420b5d2cfa62..2813f089f3db 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o obj-$(CONFIG_LEDS_LM3533) += leds-lm3533.o obj-$(CONFIG_LEDS_LM3642) += leds-lm3642.o +obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c new file mode 100644 index 000000000000..7416c545ec59 --- /dev/null +++ b/drivers/leds/leds-lm3697.c @@ -0,0 +1,377 @@ +// SPDX-License-Identifier: GPL-2.0 +// TI LM3697 LED chip family driver +// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LM3697_REV 0x0 +#define LM3697_RESET 0x1 +#define LM3697_OUTPUT_CONFIG 0x10 +#define LM3697_CTRL_A_RAMP 0x11 +#define LM3697_CTRL_B_RAMP 0x12 +#define LM3697_CTRL_A_B_RT_RAMP 0x13 +#define LM3697_CTRL_A_B_RAMP_CFG 0x14 +#define LM3697_CTRL_A_B_BRT_CFG 0x16 +#define LM3697_CTRL_A_FS_CURR_CFG 0x17 +#define LM3697_CTRL_B_FS_CURR_CFG 0x18 +#define LM3697_PWM_CFG 0x1c +#define LM3697_CTRL_A_BRT_LSB 0x20 +#define LM3697_CTRL_A_BRT_MSB 0x21 +#define LM3697_CTRL_B_BRT_LSB 0x22 +#define LM3697_CTRL_B_BRT_MSB 0x23 +#define LM3697_CTRL_ENABLE 0x24 + +#define LM3697_SW_RESET BIT(0) + +#define LM3697_CTRL_A_EN BIT(0) +#define LM3697_CTRL_B_EN BIT(1) +#define LM3697_CTRL_A_B_EN (LM3697_CTRL_A_EN | LM3697_CTRL_B_EN) + +#define LM3697_MAX_LED_STRINGS 3 + +#define LM3697_CONTROL_A 0 +#define LM3697_CONTROL_B 1 +#define LM3697_HVLED_ASSIGNMENT 1 + +/** + * struct lm3697_led - + * @hvled_strings - Array of LED strings associated with a control bank + * @label - LED label + * @led_dev - LED class device + * @priv - Pointer to the device struct + * @control_bank - Control bank the LED is associated to. 0 is control bank A + * 1 is control bank B + */ +struct lm3697_led { + u32 hvled_strings[LM3697_MAX_LED_STRINGS]; + char label[LED_MAX_NAME_SIZE]; + struct led_classdev led_dev; + struct lm3697 *priv; + int control_bank; +}; + +/** + * struct lm3697 - + * @enable_gpio - Hardware enable gpio + * @regulator - LED supply regulator pointer + * @client - Pointer to the I2C client + * @regmap - Devices register map + * @dev - Pointer to the devices device struct + * @lock - Lock for reading/writing the device + * @leds - Array of LED strings + */ +struct lm3697 { + struct gpio_desc *enable_gpio; + struct regulator *regulator; + struct i2c_client *client; + struct regmap *regmap; + struct device *dev; + struct mutex lock; + struct lm3697_led leds[]; +}; + +static const struct reg_default lm3697_reg_defs[] = { + {LM3697_OUTPUT_CONFIG, 0x6}, + {LM3697_CTRL_A_RAMP, 0x0}, + {LM3697_CTRL_B_RAMP, 0x0}, + {LM3697_CTRL_A_B_RT_RAMP, 0x0}, + {LM3697_CTRL_A_B_RAMP_CFG, 0x0}, + {LM3697_CTRL_A_B_BRT_CFG, 0x0}, + {LM3697_CTRL_A_FS_CURR_CFG, 0x13}, + {LM3697_CTRL_B_FS_CURR_CFG, 0x13}, + {LM3697_PWM_CFG, 0xc}, + {LM3697_CTRL_A_BRT_LSB, 0x0}, + {LM3697_CTRL_A_BRT_MSB, 0x0}, + {LM3697_CTRL_B_BRT_LSB, 0x0}, + {LM3697_CTRL_B_BRT_MSB, 0x0}, + {LM3697_CTRL_ENABLE, 0x0}, +}; + +static const struct regmap_config lm3697_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LM3697_CTRL_ENABLE, + .reg_defaults = lm3697_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lm3697_reg_defs), + .cache_type = REGCACHE_FLAT, +}; + +static int lm3697_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brt_val) +{ + struct lm3697_led *led = container_of(led_cdev, struct lm3697_led, + led_dev); + int brt_msb_reg, brt_lsb_reg, ctrl_en_val; + int led_brightness_lsb = (brt_val >> 5); + int ret; + + mutex_lock(&led->priv->lock); + + if (led->control_bank == LM3697_CONTROL_A) { + brt_msb_reg = LM3697_CTRL_A_BRT_MSB; + brt_lsb_reg = LM3697_CTRL_A_BRT_LSB; + ctrl_en_val = LM3697_CTRL_A_EN; + } else { + brt_msb_reg = LM3697_CTRL_B_BRT_MSB; + brt_lsb_reg = LM3697_CTRL_B_BRT_LSB; + ctrl_en_val = LM3697_CTRL_B_EN; + } + + if (brt_val == LED_OFF) + ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE, + ctrl_en_val, ~ctrl_en_val); + else + ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE, + ctrl_en_val, ctrl_en_val); + + if (ret) { + dev_err(&led->priv->client->dev, "Cannot write CTRL enable\n"); + goto out; + } + + ret = regmap_write(led->priv->regmap, brt_lsb_reg, led_brightness_lsb); + if (ret) { + dev_err(&led->priv->client->dev, "Cannot write LSB\n"); + goto out; + } + + ret = regmap_write(led->priv->regmap, brt_msb_reg, brt_val); + if (ret) + dev_err(&led->priv->client->dev, "Cannot write MSB\n"); + +out: + mutex_unlock(&led->priv->lock); + return ret; +} + +static int lm3697_set_control_bank(struct lm3697 *priv) +{ + u8 control_bank_config = 0; + struct lm3697_led *led; + int ret, i; + + led = &priv->leds[0]; + if (led->control_bank == LM3697_CONTROL_A) + led = &priv->leds[1]; + + for (i = 0; i < LM3697_MAX_LED_STRINGS; i++) + if (led->hvled_strings[i] == LM3697_HVLED_ASSIGNMENT) + control_bank_config |= 1 << i; + + ret = regmap_write(priv->regmap, LM3697_OUTPUT_CONFIG, + control_bank_config); + if (ret) + dev_err(&priv->client->dev, "Cannot write OUTPUT config\n"); + + return ret; +} + +static int lm3697_init(struct lm3697 *priv) +{ + int ret; + + if (priv->enable_gpio) { + gpiod_direction_output(priv->enable_gpio, 1); + } else { + ret = regmap_write(priv->regmap, LM3697_RESET, LM3697_SW_RESET); + if (ret) { + dev_err(&priv->client->dev, "Cannot reset the device\n"); + goto out; + } + } + + ret = regmap_write(priv->regmap, LM3697_CTRL_ENABLE, 0x0); + if (ret) { + dev_err(&priv->client->dev, "Cannot write ctrl enable\n"); + goto out; + } + + ret = lm3697_set_control_bank(priv); + if (ret) + dev_err(&priv->client->dev, "Setting the CRTL bank failed\n"); + +out: + return ret; +} + +static int lm3697_probe_dt(struct lm3697 *priv) +{ + struct fwnode_handle *child = NULL; + struct lm3697_led *led; + const char *name; + int control_bank; + size_t i = 0; + int ret; + + priv->enable_gpio = devm_gpiod_get_optional(&priv->client->dev, + "enable", GPIOD_OUT_LOW); + if (IS_ERR(priv->enable_gpio)) { + ret = PTR_ERR(priv->enable_gpio); + dev_err(&priv->client->dev, "Failed to get enable gpio: %d\n", + ret); + return ret; + } + + priv->regulator = devm_regulator_get(&priv->client->dev, "vled"); + if (IS_ERR(priv->regulator)) + priv->regulator = NULL; + + device_for_each_child_node(priv->dev, child) { + ret = fwnode_property_read_u32(child, "reg", &control_bank); + if (ret) { + dev_err(&priv->client->dev, "reg property missing\n"); + fwnode_handle_put(child); + goto child_out; + } + + if (control_bank > LM3697_CONTROL_B) { + dev_err(&priv->client->dev, "reg property is invalid\n"); + ret = -EINVAL; + fwnode_handle_put(child); + goto child_out; + } + + led = &priv->leds[i]; + led->control_bank = control_bank; + ret = fwnode_property_read_u32_array(child, "led-sources", + led->hvled_strings, + LM3697_MAX_LED_STRINGS); + if (ret) { + dev_err(&priv->client->dev, "led-sources property missing\n"); + fwnode_handle_put(child); + goto child_out; + } + + fwnode_property_read_string(child, "linux,default-trigger", + &led->led_dev.default_trigger); + + ret = fwnode_property_read_string(child, "label", &name); + if (ret) + snprintf(led->label, sizeof(led->label), + "%s::", priv->client->name); + else + snprintf(led->label, sizeof(led->label), + "%s:%s", priv->client->name, name); + + led->priv = priv; + led->led_dev.name = led->label; + led->led_dev.brightness_set_blocking = lm3697_brightness_set; + + ret = devm_led_classdev_register(priv->dev, &led->led_dev); + if (ret) { + dev_err(&priv->client->dev, "led register err: %d\n", + ret); + fwnode_handle_put(child); + goto child_out; + } + + i++; + } + +child_out: + return ret; +} + +static int lm3697_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct lm3697 *led; + int count; + int ret; + + count = device_get_child_node_count(&client->dev); + if (!count) { + dev_err(&client->dev, "LEDs are not defined in device tree!"); + return -ENODEV; + } + + led = devm_kzalloc(&client->dev, struct_size(led, leds, count), + GFP_KERNEL); + if (!led) + return -ENOMEM; + + mutex_init(&led->lock); + i2c_set_clientdata(client, led); + + led->client = client; + led->dev = &client->dev; + led->regmap = devm_regmap_init_i2c(client, &lm3697_regmap_config); + if (IS_ERR(led->regmap)) { + ret = PTR_ERR(led->regmap); + dev_err(&client->dev, "Failed to allocate register map: %d\n", + ret); + return ret; + } + + ret = lm3697_probe_dt(led); + if (ret) + return ret; + + return lm3697_init(led); +} + +static int lm3697_remove(struct i2c_client *client) +{ + struct lm3697 *led = i2c_get_clientdata(client); + int ret; + + ret = regmap_update_bits(led->regmap, LM3697_CTRL_ENABLE, + LM3697_CTRL_A_B_EN, 0); + if (ret) { + dev_err(&led->client->dev, "Failed to disable the device\n"); + return ret; + } + + if (led->enable_gpio) + gpiod_direction_output(led->enable_gpio, 0); + + if (led->regulator) { + ret = regulator_disable(led->regulator); + if (ret) + dev_err(&led->client->dev, + "Failed to disable regulator\n"); + } + + mutex_destroy(&led->lock); + + return 0; +} + +static const struct i2c_device_id lm3697_id[] = { + { "lm3697", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, lm3697_id); + +static const struct of_device_id of_lm3697_leds_match[] = { + { .compatible = "ti,lm3697", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_lm3697_leds_match); + +static struct i2c_driver lm3697_driver = { + .driver = { + .name = "lm3697", + .of_match_table = of_lm3697_leds_match, + }, + .probe = lm3697_probe, + .remove = lm3697_remove, + .id_table = lm3697_id, +}; +module_i2c_driver(lm3697_driver); + +MODULE_DESCRIPTION("Texas Instruments LM3697 LED driver"); +MODULE_AUTHOR("Dan Murphy "); +MODULE_LICENSE("GPL v2"); From patchwork Tue Sep 11 17:08:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 146473 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3868067ljw; Tue, 11 Sep 2018 10:08:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbBPMFZEe3oBjbIXLmRgf84VLOnw6sMB0Z7YTJyatU2/xIBPJDeyEoQ2XI+qEBa18k3TpLx X-Received: by 2002:a62:e218:: with SMTP id a24-v6mr30164811pfi.75.1536685733928; Tue, 11 Sep 2018 10:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536685733; cv=none; d=google.com; s=arc-20160816; b=DfgE3uzbk6EZYTkfq/Eaf43eMwNY+9NdADsDbMzdKyt4X1M+ct471sXtfmg3Qqx7pU IToWGkrwWXgLJ8ayqjOO9/SFb/M51hrDu/x7WERwtc6/7hmKWTyHLL3KatQUG0lmBKXA rmPSkYoCN8xb9j+uFRqTTbb7X7JTKgHTW6Zr8AOBnbMOsxW204rlj2xaHvrdYx8Pn0vq TS3kqAy8qJG998d2r8ISuzOS4KtNBSAqBCzPITckWrDtDNM2/RjLMsINld6G7N5HWuiW bq1uTjjTIFUsa3IWO5jlX0XBegj0bzXMVwsgOwKxZ65w8HRAJExnhuMCK99b4nKvKAFF KhTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=PK/7NWCVTG8nsW2kpAy3E+E5fedwIgzEJ4d1himThi8=; b=sHYFyubDhcMCXDNIZxzcvllQJmNPJ8jVPD7BurzwTo55HxOcn4jZVB7hW8I1oslo7v YRfZ2FUKUicfNQzfbyoMQYas7xndePGEmesUBDegiF0XihEa3rT0tuT1O6Njp8cvbc3a ak3Izf746K1ezbtgPZrPWT8UwCC7zARM48uxM/JWEhyQR8ie/ZR/N3hVpb0NhNXA25py kyhJ9lVZRseQ2kF+F7KRJIVXaNFwRRGSESmhkplNsewn8Di4Ov0dtUoM55xpifBO792v oc2elVJjhU6CsZmtDfSoV3BchNpQtKoU+RgqynKBP1rF8eTEgTVwnRwu8ZO/QyI2acCj zVxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bfgxvQG2; 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; 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 d13-v6si21819463plj.286.2018.09.11.10.08.53; Tue, 11 Sep 2018 10:08:53 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bfgxvQG2; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728261AbeIKWJG (ORCPT + 32 others); Tue, 11 Sep 2018 18:09:06 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:50216 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727034AbeIKWIz (ORCPT ); Tue, 11 Sep 2018 18:08:55 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8BH8bU3035774; Tue, 11 Sep 2018 12:08:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536685717; bh=PK/7NWCVTG8nsW2kpAy3E+E5fedwIgzEJ4d1himThi8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bfgxvQG2Wj2i+j5cvlEhJSTbKyf47MBoQgJnXcgrdNXfOHJZmG1SXY+5Zne0FDMpn d4CfD6x9unynLU6q0xLdbASqj01blfD5cwzmwUUB0Ult9CFymdtdG05xWfYKUi5LnL C7arf36H4AZjol3NXHZCJxhZu8n7oYiFkHjg19uc= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8BH8bfq031485; Tue, 11 Sep 2018 12:08:37 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 11 Sep 2018 12:08:37 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 11 Sep 2018 12:08:37 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8BH8aD1015313; Tue, 11 Sep 2018 12:08:36 -0500 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.156.248]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8BH8ax21205; Tue, 11 Sep 2018 12:08:36 -0500 (CDT) From: Dan Murphy To: , , CC: , , , , , Dan Murphy Subject: [PATCH v7 5/6] dt-bindings: leds: Add runtime ramp node for LM3697 Date: Tue, 11 Sep 2018 12:08:24 -0500 Message-ID: <20180911170825.17789-6-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20180911170825.17789-1-dmurphy@ti.com> References: <20180911170825.17789-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add runtime ramp rates for the LM3697 LED driver. This LED driver supports separate runtime ramp rates for going from a higher or lower level of brightnesses Signed-off-by: Dan Murphy --- v7 - New change for the series to support feature in ti-lmu .../devicetree/bindings/leds/leds-lm3697.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.17.0.1855.g63749b2dea diff --git a/Documentation/devicetree/bindings/leds/leds-lm3697.txt b/Documentation/devicetree/bindings/leds/leds-lm3697.txt index 85ae075f6677..4bb2ed51025b 100644 --- a/Documentation/devicetree/bindings/leds/leds-lm3697.txt +++ b/Documentation/devicetree/bindings/leds/leds-lm3697.txt @@ -30,6 +30,12 @@ Required child properties: 1 - HVLED string is controlled by this control bank Optional child properties: + - runtime-ramp-up-msec: Current ramping from one brightness level to + the a higher brightness level. + Range from 2048 us - 117.44 s + - runtime-ramp-down-msec: Current ramping from one brightness level to + the a lower brightness level. + Range from 2048 us - 117.44 s - label : see Documentation/devicetree/bindings/leds/common.txt - linux,default-trigger : see Documentation/devicetree/bindings/leds/common.txt @@ -51,6 +57,8 @@ led-controller@36 { led@0 { reg = <0>; led-sources = <1 0 1>; + runtime-ramp-up-msec = <5000>; + runtime-ramp-down-msec = <1000>; label = "white:first_backlight_cluster"; linux,default-trigger = "backlight"; }; @@ -58,6 +66,8 @@ led-controller@36 { led@1 { reg = <1>; led-sources = <0 1 0>; + runtime-ramp-up-msec = <500>; + runtime-ramp-down-msec = <1000>; label = "white:second_backlight_cluster"; linux,default-trigger = "backlight"; }; @@ -77,6 +87,8 @@ led-controller@36 { led@0 { reg = <0>; led-sources = <1 1 1>; + runtime-ramp-up-msec = <500>; + runtime-ramp-down-msec = <1000>; label = "white:backlight_cluster"; linux,default-trigger = "backlight"; }; From patchwork Tue Sep 11 17:08:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 146475 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3868529ljw; Tue, 11 Sep 2018 10:09:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZWZr6Myw5EnCkisRUSpo60z3ov/nnF10vFkBfKkwx5M1jG9wVC/AgC47JwAucPt4Ol4lsn X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr28396213plg.153.1536685759662; Tue, 11 Sep 2018 10:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536685759; cv=none; d=google.com; s=arc-20160816; b=vXGWYYf6OCQ7dmCUAf8UJRwscAMqQwlWwYEXpuPNk17TyXGoyuq36nKrQ7LUI/0Owu 9jBTb1uXQ7/oC8MPHypZPHoigmbdBzwF+ylQK0aWZF66Qbl/ji8/lnjRHc61TLRcOiHi 9Nb9bxNbU+jWBgxd+y/9f4LFtoEnvFITqDS3LOfzZqDcmO6eFrr3CndAyZ/SB68lvhus SbO4jcPvRDD+y4AqhVdE4Jj5V0ud8WXMTSZLtrMbIdQnZi2TMq/oNTj7NiwRi9w6UQsL /whmgB2lOg4lsotMh2z33Xx6WWf7FNvPkf4J/Ff3du8a9V28wNxCZJwVUQ8rBruCPFkI NCkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Pff6VZKUoQSAkQoyDdee2vuNXRPxf7o05IPGv0EMvY0=; b=Fv0jtpz8Nn3Ho3LExBav9vgvpjYDq6ZLQvVRIOPRi59p+zQmkfFwxxFIrEf1ByejcF m6TINMUvRj1ox4/ZqDtKPKXLJQdJOoUfI8c2l5ZTrRLGwVgi/hWUd55hMj2fzmJciFNn vMEXNBtyzdgeNhvd57WlzvvU81FuwbgPkDyX6No/mhaMDKXbCzh9Jw6TkzkI/eYm13/8 S9iyi+LMKeyCJEr2lFayLX4d+sh9xJcsFcGR2+XoQY7RMVkF1Gj2DBN0EcqmNhUipryK GtMFTikn0BLBO85sWQ/1iL0Yk7CrVhCwHPuoSal/wnT5pBuSIbro4JZdL1sxXcl7lwgr /fEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=oPd3uaDm; 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; 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 x69-v6si21335589pfe.318.2018.09.11.10.09.19; Tue, 11 Sep 2018 10:09:19 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=oPd3uaDm; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728294AbeIKWJb (ORCPT + 32 others); Tue, 11 Sep 2018 18:09:31 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:39258 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbeIKWIz (ORCPT ); Tue, 11 Sep 2018 18:08:55 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8BH8bYF082840; Tue, 11 Sep 2018 12:08:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536685717; bh=Pff6VZKUoQSAkQoyDdee2vuNXRPxf7o05IPGv0EMvY0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=oPd3uaDmUr6SyyQ/ZsswOw+LVkfcKbDS+HT5stFGErXOEacE4xD4cecXjpYwsVOU7 EhQlFnCny3v71EvH+0rQyUddZdkBqYs4JfGLjIgr0G7D9eqE8JWcRTjXSUk8edGlIB R/QsvImCZVy39mmRUDyOIOJRzHtoSxk/MSWTcREg= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8BH8bZh017631; Tue, 11 Sep 2018 12:08:37 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 11 Sep 2018 12:08:37 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 11 Sep 2018 12:08:37 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8BH8bUf000986; Tue, 11 Sep 2018 12:08:37 -0500 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.156.248]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8BH8ax21209; Tue, 11 Sep 2018 12:08:37 -0500 (CDT) From: Dan Murphy To: , , CC: , , , , , Dan Murphy Subject: [PATCH v7 6/6] leds: lm3697: Add ramp rate feature Date: Tue, 11 Sep 2018 12:08:25 -0500 Message-ID: <20180911170825.17789-7-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20180911170825.17789-1-dmurphy@ti.com> References: <20180911170825.17789-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the runtime ramp up and down of the LEDs in the specific control bank. Each control bank can have separate ramp up and ramp down values for the lighting zones the control banks manage. Signed-off-by: Dan Murphy --- v7 - New change for the series to support feature in ti-lmu drivers/leds/leds-lm3697.c | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) -- 2.17.0.1855.g63749b2dea diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 7416c545ec59..997c270a46b5 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -59,6 +59,8 @@ struct lm3697_led { struct led_classdev led_dev; struct lm3697 *priv; int control_bank; + int ramp_up_rate; + int ramp_down_rate; }; /** @@ -178,6 +180,62 @@ static int lm3697_set_control_bank(struct lm3697 *priv) return ret; } +static int lm3697_find_ramp_reg_val(int rate) +{ + const static int lookup[16] = { 2, 262, 524, 1049, 2090, 4194, 8389, + 16780, 33550, 41940, 50330, 58720, + 67110, 83880, 100660, 117440}; + int i; + + for (i = 1; i < ARRAY_SIZE(lookup); i++) { + if (rate == lookup[i]) + return i; + + if (rate > lookup[i - 1] && rate < lookup[i]) { + if (rate - lookup[i - 1] < lookup[i] - rate) + return i - 1; + else + return i; + } + } + + return -EINVAL; +} + +static int lm3697_set_ramp_rates(struct lm3697 *priv) +{ + u8 ramp, ramp_up, ramp_down; + struct lm3697_led *led; + u8 ramp_reg; + int i, ret = 0; + + for (i = 0; i < 2; i++) { + led = &priv->leds[i]; + if (led->ramp_up_rate == 0 && led->ramp_down_rate == 0) + continue; + + if (led->control_bank == LM3697_CONTROL_A) + ramp_reg = LM3697_CTRL_A_RAMP; + else + ramp_reg = LM3697_CTRL_B_RAMP; + + ramp_up = lm3697_find_ramp_reg_val(led->ramp_up_rate); + ramp_down = lm3697_find_ramp_reg_val(led->ramp_down_rate); + + if (ramp_up < 0 || ramp_down < 0) { + dev_err(&priv->client->dev, "Cannot find ramp rate\n"); + continue; + } + + ramp = (ramp_up << 4) | ramp_down; + ret = regmap_write(priv->regmap, ramp_reg, ramp); + if (ret) + dev_err(&priv->client->dev, "Cannot write ramp config\n"); + } + + return ret; +} + static int lm3697_init(struct lm3697 *priv) { int ret; @@ -202,6 +260,9 @@ static int lm3697_init(struct lm3697 *priv) if (ret) dev_err(&priv->client->dev, "Setting the CRTL bank failed\n"); + ret = lm3697_set_ramp_rates(priv); + if (ret) + dev_err(&priv->client->dev, "Setting the ramp rate failed\n"); out: return ret; } @@ -254,6 +315,17 @@ static int lm3697_probe_dt(struct lm3697 *priv) goto child_out; } + ret = fwnode_property_read_u32(child, "runtime-ramp-up-msec", + &led->ramp_up_rate); + if (ret) + dev_warn(&priv->client->dev, "runtime-ramp-up-msec property missing\n"); + + ret = fwnode_property_read_u32(child, "runtime-ramp-down-msec", + &led->ramp_down_rate); + if (ret) + dev_warn(&priv->client->dev, "runtime-ramp-down-msec property missing\n"); + + fwnode_property_read_string(child, "linux,default-trigger", &led->led_dev.default_trigger);