From patchwork Fri Dec 1 16:56:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 120358 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1382903qgn; Fri, 1 Dec 2017 08:56:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMZyuVKWQahA/HYCNMXuB1HcHjZTYg2AJgIQiowDdwo1iP+gNgUwCM3d9MpN5e3sVuKGjRhw X-Received: by 10.98.49.130 with SMTP id x124mr10980768pfx.149.1512147413030; Fri, 01 Dec 2017 08:56:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512147413; cv=none; d=google.com; s=arc-20160816; b=X0WKsES/YJkfhra/BKRAdc8ojnsJwH3ZGv9zm/Xrnn/qqAAGCQaCVEkJ+dNrL9Btn8 ZdZe9CHe6vtpD2BbbG3saC9R4lEQ6sNXSN1DoTjMdCZDCK7iwiXJ7vJWRts3bXym/E3t D5oWloVqETzQoQqQ9/ZL1dulc5rtGuWgWrl++HDg0aVd7CnobioNKXUH5oNXeHJCwbys 3bvLJzyx0LIiezHmCxe5Fy3mRq1yU0K7fRACWncL968qHIj/gYlk9uTvB2wGastNTP6E ah2/WXhgKzDApSE7BSykTwJLYVlVC1NXXVJPx+OFQAiTl/X7hxZthAk52NiBQjSSGKl8 xlUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=cV0NDzZSAVtWML0gD1lQ+zXhXLkA9W0oVnw7jQgjaFA=; b=ZKx1KqiKeBKJ8rrRfWEPR1dkE+oq6TeNjOdNSAO9WO3nOWjxGJxRVx91oClH+2eZka 0RZUXHAplCXrPhY6jYggcICIG3lfC1OrVyK+IVdWLFWONBv5OxvyBmyXqk45Cs4zOlpT t9lEvqu3CL32rL2daS9OP1oiIxLQwAtllHyBc7nYIivHR5oJIoSDntgBb/Z5adrVSEh8 Eqztd6spsUnJrQpOcEdAVhqPpJLCqMqWYkkZJnvaA42dscR8n25Q49l29jK43unMq245 P+yGe7KCUN6N7rEI9rsYdWtR9AlCV9icmJTcG/nkpCfwOscAyapshFkoIE3AX8TPO5+P uEDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=oWBNnZEx; 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 d8si5116816pgu.56.2017.12.01.08.56.52; Fri, 01 Dec 2017 08:56:53 -0800 (PST) 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=oWBNnZEx; 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 S1751573AbdLAQ4u (ORCPT + 28 others); Fri, 1 Dec 2017 11:56:50 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:25816 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988AbdLAQ4o (ORCPT ); Fri, 1 Dec 2017 11:56:44 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id vB1GuOc7015274; Fri, 1 Dec 2017 10:56:24 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1512147384; bh=LKWcK7CY837YXgVN9ftVBrzEoTtr4y57uV2TqeMP4mk=; h=From:To:CC:Subject:Date; b=oWBNnZExnDVCw/WmSIj/Lpovd6zodKmeaWorgyuAee29ek3Pf0Xiwf3A0rkuKuqkL SYZvs63FKHp9saRwgnDDycWqXZ82dEA9xoYaWYujPyQ0qXrS2BYZzisaf4VGbsHMJY me1QC9Ih76A7GCAkGRgTUOHch2cmr04k6s6C42vk= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id vB1GuOJt013889; Fri, 1 Dec 2017 10:56:24 -0600 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Fri, 1 Dec 2017 10:56:23 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Fri, 1 Dec 2017 10:56:23 -0600 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 vB1GuNOs030492; Fri, 1 Dec 2017 10:56:23 -0600 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.70.55]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id vB1GuN303169; Fri, 1 Dec 2017 10:56:23 -0600 (CST) From: Dan Murphy To: , , CC: , , Dan Murphy Subject: [PATCH v6 1/6] leds: Add new API to derive a LED name Date: Fri, 1 Dec 2017 10:56:08 -0600 Message-ID: <20171201165613.10358-1-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 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 Create an API that is called to derive the LED name from either the DT label in the child node or if that does not exist from the parent node name and an alternate label that is passed in. Signed-off-by: Dan Murphy --- v6 - New patch to add the api to generate a LED label drivers/leds/led-class.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/leds.h | 6 ++++++ 2 files changed, 40 insertions(+) -- 2.15.0.124.g7668cbc60 diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index b0e2d55acbd6..d3e035488737 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -243,6 +244,39 @@ static int led_classdev_next_name(const char *init_name, char *name, return i; } +/** + * of_led_compose_name - derive the LED name based on DT or alternate name. + * + * @parent: parent of LED device + * @child: child node of LED device + * @alt_name: an alternate name if the label node is not found + * @len: length of the alt_name + * @led_name: derived name from either DT label or alt_name + */ +void of_led_compose_name(struct device_node *parent, + struct device_node *child, + const char *alt_name, + size_t len, + char *led_name) +{ + int ret; + int length; + const char *name; + + if (len == 0 || alt_name == NULL) + return; + + ret = of_property_read_string(child, "label", &name); + if (!ret) { + strlcpy(led_name, name, sizeof(led_name)); + } else { + length = len + strlen(parent->name) + 1; + snprintf(led_name, len, "%s:%s", parent->name, alt_name); + } + +} +EXPORT_SYMBOL_GPL(of_led_compose_name); + /** * of_led_classdev_register - register a new object of led_classdev class. * diff --git a/include/linux/leds.h b/include/linux/leds.h index 5579c64c8fd6..9e18dbe196e2 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -123,6 +123,12 @@ struct led_classdev { struct mutex led_access; }; +extern void of_led_compose_name(struct device_node *parent, + struct device_node *child, + const char *alt_name, + size_t len, + char *led_name); + extern int of_led_classdev_register(struct device *parent, struct device_node *np, struct led_classdev *led_cdev); From patchwork Fri Dec 1 16:56:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 120360 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1383584qgn; Fri, 1 Dec 2017 08:57:32 -0800 (PST) X-Google-Smtp-Source: AGs4zMbmvrB+LOsBEimW3n6gL2uM+ciFQq9z6Q1uaWZRbfQywEwX+i4HjHCbBdnveH9zEi5AMvjZ X-Received: by 10.84.143.162 with SMTP id 31mr6726212plz.254.1512147452243; Fri, 01 Dec 2017 08:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512147452; cv=none; d=google.com; s=arc-20160816; b=fYzqlEOQMrZgwWaWK8zk8crbZD8lKklpIqjvCDaDZK85NTKyXoXRyPlqxqwQz/Wq2X Sd6ukIQruwNesX/UuiyJs9s5+RBGTXPQ0SEGORFBfJ+SQ/5gHsORA4nUNt2qPkvWhDmV KUYUDlGQVTEXjVNm47NJ/lvaP6Q4M2fw78coW2E5+4RO318jFVWQOfBKSVIQ2I4ADACN rB+CwjNsvCEBGtUKpmcewgBALBVX+qQiVkQjHhfdZC65JuwA9D1fMLONv/apM1uRqWot lbGR8fhBEUShhzepfz9Xi9glJs8mycCO0O7dC42t/Sp69l2xb8L+z0iscNSC6H2xCfc3 u41g== 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 :arc-authentication-results; bh=5sq0mxem9aXnwP1Ja+W1wSG2Bzv5Hb47VDD9PPke2Zg=; b=o0+RvqQbCHCHz8dwiwYO1Yuo2D4+mhQYVIQrvXnomDsVh0PsYLGXqCmz7He3R7dmvn Pkt2aqAoW6DQqT8e0j9sgcjE/ZQJPJgWUdbnZszZ+1QTqXznUEOFbyJimFxiAn2C6uzn kGoc4Hu1qRcR8/36SXIHACQYS3Vn95YXjRAuX5uC0KiYhavJYRUU8eHEmPgHjqvkCOUD u29lBbzcCSmiHC0m5LtQoUUEskVTvoig8FVaRcnPHsaGrZm+3xO4uhx/chqdlnXMdWBw iPHoSoKOZFReXtweBOcN3RrVBvwrshu2CTdApOcL4F6Dn0M4q/eh85LgPy4V+T8LsCUV tT5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=dZL4r5fc; 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 j6si1825365pgs.459.2017.12.01.08.57.31; Fri, 01 Dec 2017 08:57:32 -0800 (PST) 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=dZL4r5fc; 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 S1751848AbdLAQ5a (ORCPT + 28 others); Fri, 1 Dec 2017 11:57:30 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:28291 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751790AbdLAQ52 (ORCPT ); Fri, 1 Dec 2017 11:57:28 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id vB1GuTeo032694; Fri, 1 Dec 2017 10:56:29 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1512147389; bh=E50lepu+DkALMOeBfdzvLm3luZBNbm9RtyMoY4I933A=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=dZL4r5fcERP4WdQXXGYRtaOuidLhUtWCUuN9Yltpb1XQsEWe6osQobUkmOhyo3s+S bVokj2EniDrrBEZTMpUHq2KTDr9xU9zQ0jqnOE1CyG6zkqmBH5dUJWFIvtGsLpBIyI ynHINkIbpI8QAiX37zsfPsP9rvnjTOb1vJbx6agg= 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 vB1GuOiV016928; Fri, 1 Dec 2017 10:56:24 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Fri, 1 Dec 2017 10:56:24 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Fri, 1 Dec 2017 10:56:24 -0600 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 vB1GuO19013206; Fri, 1 Dec 2017 10:56:24 -0600 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.70.55]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id vB1GuN303173; Fri, 1 Dec 2017 10:56:24 -0600 (CST) From: Dan Murphy To: , , CC: , , Dan Murphy Subject: [PATCH v6 2/6] dt: bindings: lm3692x: Add bindings for lm3692x LED driver Date: Fri, 1 Dec 2017 10:56:09 -0600 Message-ID: <20171201165613.10358-2-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20171201165613.10358-1-dmurphy@ti.com> References: <20171201165613.10358-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 This adds the devicetree bindings for the LM3692x I2C LED string driver. Acked-by: Pavel Machek Signed-off-by: Dan Murphy --- .../devicetree/bindings/leds/leds-lm3692x.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt -- 2.15.0.124.g7668cbc60 diff --git a/Documentation/devicetree/bindings/leds/leds-lm3692x.txt b/Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file mode 100644 index 000000000000..c259cde2226f --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-lm3692x.txt @@ -0,0 +1,39 @@ +* Texas Instruments - LM3692x Highly Efficient White LED Driver + +The LM3692x is an ultra-compact, highly efficient, +white-LED driver designed for LCD display backlighting. + +The main difference between the LM36922 and LM36923 is the number of +LED strings it supports. The LM36922 supports two strings while the LM36923 +supports three strings. + +Required properties: + - compatible: + "ti,lm36922" + "ti,lm36923" + - reg : I2C slave address + +Optional properties: + - label : see Documentation/devicetree/bindings/leds/common.txt + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + - linux,default-trigger : (optional) + see Documentation/devicetree/bindings/leds/common.txt + +Example: + +lm3692x@36 { + compatible = "ti,lm3692x"; + reg = <0x36>; + + enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + vled-supply = <&vbatt>; + + backlight: backlight@0 { + label = "backlight_cluster"; + linux,default-trigger = "backlight"; + }; +} + +For more product information please see the link below: +http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf From patchwork Fri Dec 1 16:56:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 120359 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1383374qgn; Fri, 1 Dec 2017 08:57:19 -0800 (PST) X-Google-Smtp-Source: AGs4zMY/i2Ej+6oMt0HsBI45Hm1+t8a5P0uEIRmQlH1OSvvFgFfJtoeY8LoqMlS7ByD8FAEknh7a X-Received: by 10.98.31.7 with SMTP id f7mr11020064pff.235.1512147439499; Fri, 01 Dec 2017 08:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512147439; cv=none; d=google.com; s=arc-20160816; b=E2mYx7lbZAvdRztf/aTTQbLhBsUw3YZ7HPq2L7qSIPgH10dhKsNC+RY18QNPdVnf2q 8PZ4+bgsi3dvjaQq1Lk3LltLbujroC1n/sxo/HTNe3OPAvyVv3SU+PJUdYJJYcGQd/aZ SBAVT+Hz3MkyffIpBBi9hWmpkDjt3goepVqIriROS+AI6RUR0IGo0T2dsJRWgGDU8977 A3eVkZvrLrQwym4kdSMzADaLYmhq382lzzI+7EDiA6yzKFOg/ynZ7wXRVAIBc3WqtrDv HUsxumP7mkUQJg6B+2AY8RQa0ygtaPQDSQtACV1puiAP2Sq2vtFRdi+Im4YdKHOEWWGt trHw== 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 :arc-authentication-results; bh=KlNKmBvrtIKS2RqrXxWac/6ph4zDPgQfGfIM2lUBgtM=; b=PBDEeffW792y62RiVuIqP/ubX2ovkYqN5Imtt8RoJbnuSYPidkK+j9Kw5Kr96jKq71 eigLl5m9Pb/z01Qgq6cqUF9FxAqIBAelQ2CWNz8iY9VaGTRExpo5lfg80B5ssVwvL0fC DKPqc62+0wXdFCQimzjPcGM98wa0MEvu3/LSpDPst1TdH8mDY+PaqN7qI8JekCi6176c SjHUvbhFigZ7gPL6PYWKPuFTe9nkg3RUC5Tkfu0qXGMq5AGIM+lUBtv7GYKhyH/vevU5 3TF58hDHM6omsrgAZCszKP6LNQDP8FkmDtSEQfJhw5EFfQaizBBbAcyur7Yc4gDwJs0z 9xAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xgEn56vM; 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 n128si5022935pgn.752.2017.12.01.08.57.19; Fri, 01 Dec 2017 08:57:19 -0800 (PST) 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=xgEn56vM; 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 S1751786AbdLAQ5R (ORCPT + 28 others); Fri, 1 Dec 2017 11:57:17 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:20271 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751254AbdLAQ4r (ORCPT ); Fri, 1 Dec 2017 11:56:47 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id vB1GuPYm020848; Fri, 1 Dec 2017 10:56:25 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1512147385; bh=XcOq1vgXEhVc3RTKNOSBBz056umBrKMrWpjMTUpZmuY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xgEn56vMzhE42FCGvK0HH02T2r5NxxMfTBg5jp7SXVohXhhgaRVpmAfLLeWypY85F RmYJV0iz6UhMJIUelFYebhJ4jdZA63krWaCevh4vA+frzc0aVke53Tqq8lrVTBcefk sy+dob3M7kAzlTG0HVkGbwBbNSOif/Uv60YVpHm4= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id vB1GuPX3013911; Fri, 1 Dec 2017 10:56:25 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Fri, 1 Dec 2017 10:56:24 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Fri, 1 Dec 2017 10:56:24 -0600 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 vB1GuOgO013211; Fri, 1 Dec 2017 10:56:24 -0600 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.70.55]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id vB1GuO303177; Fri, 1 Dec 2017 10:56:24 -0600 (CST) From: Dan Murphy To: , , CC: , , Dan Murphy Subject: [PATCH v6 3/6] leds: lm3692x: Introduce LM3692x dual string driver Date: Fri, 1 Dec 2017 10:56:10 -0600 Message-ID: <20171201165613.10358-3-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20171201165613.10358-1-dmurphy@ti.com> References: <20171201165613.10358-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 Introducing the LM3692x Dual-String white LED driver. Data sheet is located http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf Signed-off-by: Dan Murphy --- v6 - Use new LED API to compose LED label as opposed to creating it. - https://patchwork.kernel.org/patch/10085565/ v5 - Added OF dependency in Kconfig, added extra fault flag read to ensure that if a fault exists and it is not a artifact, fixed LED class label to be derived from either the DT child "label" node or create a label based on parent_node_name:led color:trigger, removed ifdef for CONFIG_OF and removed of_match_ptr - https://patchwork.kernel.org/patch/10081073/ v4 - Converted to devm led class register, changed MODULE_LICENSE to GPL v2, set the led name based on child node name or label entry, removed fault and returned read_buf for fault checking, added mutex_destroy to remove function, and removed LED_FULL - https://patchwork.kernel.org/patch/10060109/ v3 - Add missing Makefile and Kconfig from v1 and v2 - https://patchwork.kernel.org/patch/10060075/ v2 - Added data sheet link, fixed linuxdoc format, returned on failure in init routine, return on fault_check failure, updated brightness calculation and fixed capitalization issue - https://patchwork.kernel.org/patch/10056675/ drivers/leds/Kconfig | 7 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3692x.c | 388 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 396 insertions(+) create mode 100644 drivers/leds/leds-lm3692x.c -- 2.15.0.124.g7668cbc60 diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 318a28fd58fe..1d215b39cefd 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -137,6 +137,13 @@ config LEDS_LM3642 converter plus 1.5A constant current driver for a high-current white LED. +config LEDS_LM3692X + tristate "LED support for LM3692x Chips" + depends on LEDS_CLASS && I2C && OF + select REGMAP_I2C + help + This option enables support for the TI LM3692x family + of white LED string drivers used for backlighting. config LEDS_LOCOMO tristate "LED Support for Locomo device" diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index a2a6b5a4f86d..987884a5b9a5 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -74,6 +74,7 @@ obj-$(CONFIG_LEDS_PM8058) += leds-pm8058.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c new file mode 100644 index 000000000000..ba32d2e6367a --- /dev/null +++ b/drivers/leds/leds-lm3692x.c @@ -0,0 +1,388 @@ +/* + * TI lm3692x LED Driver + * + * Copyright (C) 2017 Texas Instruments + * + * Author: Dan Murphy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * Data sheet is located + * http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LM3692X_REV 0x0 +#define LM3692X_RESET 0x1 +#define LM3692X_EN 0x10 +#define LM3692X_BRT_CTRL 0x11 +#define LM3692X_PWM_CTRL 0x12 +#define LM3692X_BOOST_CTRL 0x13 +#define LM3692X_AUTO_FREQ_HI 0x15 +#define LM3692X_AUTO_FREQ_LO 0x16 +#define LM3692X_BL_ADJ_THRESH 0x17 +#define LM3692X_BRT_LSB 0x18 +#define LM3692X_BRT_MSB 0x19 +#define LM3692X_FAULT_CTRL 0x1e +#define LM3692X_FAULT_FLAGS 0x1f + +#define LM3692X_SW_RESET BIT(0) +#define LM3692X_DEVICE_EN BIT(0) +#define LM3692X_LED1_EN BIT(1) +#define LM3692X_LED2_EN BIT(2) + +/* Brightness Control Bits */ +#define LM3692X_BL_ADJ_POL BIT(0) +#define LM3692X_RAMP_RATE_125us 0x00 +#define LM3692X_RAMP_RATE_250us BIT(1) +#define LM3692X_RAMP_RATE_500us BIT(2) +#define LM3692X_RAMP_RATE_1ms (BIT(1) | BIT(2)) +#define LM3692X_RAMP_RATE_2ms BIT(3) +#define LM3692X_RAMP_RATE_4ms (BIT(3) | BIT(1)) +#define LM3692X_RAMP_RATE_8ms (BIT(2) | BIT(3)) +#define LM3692X_RAMP_RATE_16ms (BIT(1) | BIT(2) | BIT(3)) +#define LM3692X_RAMP_EN BIT(4) +#define LM3692X_BRHT_MODE_REG 0x00 +#define LM3692X_BRHT_MODE_PWM BIT(5) +#define LM3692X_BRHT_MODE_MULTI_RAMP BIT(6) +#define LM3692X_BRHT_MODE_RAMP_MULTI (BIT(5) | BIT(6)) +#define LM3692X_MAP_MODE_EXP BIT(7) + +/* PWM Register Bits */ +#define LM3692X_PWM_FILTER_100 BIT(0) +#define LM3692X_PWM_FILTER_150 BIT(1) +#define LM3692X_PWM_FILTER_200 (BIT(0) | BIT(1)) +#define LM3692X_PWM_HYSTER_1LSB BIT(2) +#define LM3692X_PWM_HYSTER_2LSB BIT(3) +#define LM3692X_PWM_HYSTER_3LSB (BIT(3) | BIT(2)) +#define LM3692X_PWM_HYSTER_4LSB BIT(4) +#define LM3692X_PWM_HYSTER_5LSB (BIT(4) | BIT(2)) +#define LM3692X_PWM_HYSTER_6LSB (BIT(4) | BIT(3)) +#define LM3692X_PWM_POLARITY BIT(5) +#define LM3692X_PWM_SAMP_4MHZ BIT(6) +#define LM3692X_PWM_SAMP_24MHZ BIT(7) + +/* Boost Control Bits */ +#define LM3692X_OCP_PROT_1A BIT(0) +#define LM3692X_OCP_PROT_1_25A BIT(1) +#define LM3692X_OCP_PROT_1_5A (BIT(0) | BIT(1)) +#define LM3692X_OVP_21V BIT(2) +#define LM3692X_OVP_25V BIT(3) +#define LM3692X_OVP_29V (BIT(2) | BIT(3)) +#define LM3692X_MIN_IND_22UH BIT(4) +#define LM3692X_BOOST_SW_1MHZ BIT(5) +#define LM3692X_BOOST_SW_NO_SHIFT BIT(6) + +/* Fault Control Bits */ +#define LM3692X_FAULT_CTRL_OVP BIT(0) +#define LM3692X_FAULT_CTRL_OCP BIT(1) +#define LM3692X_FAULT_CTRL_TSD BIT(2) +#define LM3692X_FAULT_CTRL_OPEN BIT(3) + +/* Fault Flag Bits */ +#define LM3692X_FAULT_FLAG_OVP BIT(0) +#define LM3692X_FAULT_FLAG_OCP BIT(1) +#define LM3692X_FAULT_FLAG_TSD BIT(2) +#define LM3692X_FAULT_FLAG_SHRT BIT(3) +#define LM3692X_FAULT_FLAG_OPEN BIT(4) + +/** + * struct lm3692x_led - + * @lock - Lock for reading/writing the device + * @client - Pointer to the I2C client + * @led_dev - LED class device pointer + * @regmap - Devices register map + * @enable_gpio - VDDIO/EN gpio to enable communication interface + * @regulator - LED supply regulator pointer + * @label - LED label + */ +struct lm3692x_led { + struct mutex lock; + struct i2c_client *client; + struct led_classdev led_dev; + struct regmap *regmap; + struct gpio_desc *enable_gpio; + struct regulator *regulator; + char label[LED_MAX_NAME_SIZE]; +}; + +static const struct reg_default lm3692x_reg_defs[] = { + {LM3692X_EN, 0xf}, + {LM3692X_BRT_CTRL, 0x61}, + {LM3692X_PWM_CTRL, 0x73}, + {LM3692X_BOOST_CTRL, 0x6f}, + {LM3692X_AUTO_FREQ_HI, 0x0}, + {LM3692X_AUTO_FREQ_LO, 0x0}, + {LM3692X_BL_ADJ_THRESH, 0x0}, + {LM3692X_BRT_LSB, 0x7}, + {LM3692X_BRT_MSB, 0xff}, + {LM3692X_FAULT_CTRL, 0x7}, +}; + +static const struct regmap_config lm3692x_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LM3692X_FAULT_FLAGS, + .reg_defaults = lm3692x_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lm3692x_reg_defs), + .cache_type = REGCACHE_RBTREE, +}; + +static int lm3692x_fault_check(struct lm3692x_led *led) +{ + int ret; + unsigned int read_buf; + + ret = regmap_read(led->regmap, LM3692X_FAULT_FLAGS, &read_buf); + if (ret) + return ret; + + if (read_buf) + dev_err(&led->client->dev, "Detected a fault 0x%X\n", read_buf); + + /* The first read may clear the fault. Check again to see if the fault + * still exits and return that value. + */ + regmap_read(led->regmap, LM3692X_FAULT_FLAGS, &read_buf); + if (read_buf) + dev_err(&led->client->dev, "Second read of fault flags 0x%X\n", + read_buf); + + return read_buf; +} + +static int lm3692x_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brt_val) +{ + struct lm3692x_led *led = + container_of(led_cdev, struct lm3692x_led, led_dev); + int ret; + int led_brightness_lsb = (brt_val >> 5); + + mutex_lock(&led->lock); + + ret = lm3692x_fault_check(led); + if (ret) { + dev_err(&led->client->dev, "Cannot read/clear faults\n"); + goto out; + } + + ret = regmap_write(led->regmap, LM3692X_BRT_MSB, brt_val); + if (ret) { + dev_err(&led->client->dev, "Cannot write MSB\n"); + goto out; + } + + ret = regmap_write(led->regmap, LM3692X_BRT_LSB, led_brightness_lsb); + if (ret) { + dev_err(&led->client->dev, "Cannot write LSB\n"); + goto out; + } +out: + mutex_unlock(&led->lock); + return ret; +} + +static int lm3692x_init(struct lm3692x_led *led) +{ + int ret; + + if (led->regulator) { + ret = regulator_enable(led->regulator); + if (ret) { + dev_err(&led->client->dev, + "Failed to enable regulator\n"); + return ret; + } + } + + if (led->enable_gpio) + gpiod_direction_output(led->enable_gpio, 1); + + ret = lm3692x_fault_check(led); + if (ret) { + dev_err(&led->client->dev, "Cannot read/clear faults\n"); + goto out; + } + + ret = regmap_write(led->regmap, LM3692X_BRT_CTRL, 0x00); + if (ret) + goto out; + + /* + * For glitch free operation, the following data should + * only be written while device enable bit is 0 + * per Section 7.5.14 of the data sheet + */ + ret = regmap_write(led->regmap, LM3692X_PWM_CTRL, + LM3692X_PWM_FILTER_100 | LM3692X_PWM_SAMP_24MHZ); + if (ret) + goto out; + + ret = regmap_write(led->regmap, LM3692X_BOOST_CTRL, + LM3692X_BRHT_MODE_RAMP_MULTI | + LM3692X_BL_ADJ_POL | + LM3692X_RAMP_RATE_250us); + if (ret) + goto out; + + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00); + if (ret) + goto out; + + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_LO, 0x00); + if (ret) + goto out; + + ret = regmap_write(led->regmap, LM3692X_BL_ADJ_THRESH, 0x00); + if (ret) + goto out; + + ret = regmap_write(led->regmap, LM3692X_BRT_CTRL, + LM3692X_BL_ADJ_POL | LM3692X_PWM_HYSTER_4LSB); + if (ret) + goto out; + + return ret; +out: + dev_err(&led->client->dev, "Fail writing initialization values\n"); + + 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"); + } + + return ret; +} + +static int lm3692x_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct lm3692x_led *led; + struct device_node *np = client->dev.of_node; + struct device_node *child_node; + char default_name[LED_MAX_NAME_SIZE] = "white:backlight_cluster"; + + led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); + if (!led) + return -ENOMEM; + + for_each_available_child_of_node(np, child_node) { + led->led_dev.default_trigger = of_get_property(child_node, + "linux,default-trigger", + NULL); + of_led_compose_name(np, child_node, default_name, + sizeof(default_name), + led->label); + }; + + led->enable_gpio = devm_gpiod_get_optional(&client->dev, + "enable", GPIOD_OUT_LOW); + if (IS_ERR(led->enable_gpio)) { + ret = PTR_ERR(led->enable_gpio); + dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret); + return ret; + } + + led->regulator = devm_regulator_get(&client->dev, "vled"); + if (IS_ERR(led->regulator)) + led->regulator = NULL; + + led->client = client; + led->led_dev.name = led->label; + led->led_dev.brightness_set_blocking = lm3692x_brightness_set; + + mutex_init(&led->lock); + + i2c_set_clientdata(client, led); + + led->regmap = devm_regmap_init_i2c(client, &lm3692x_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 = lm3692x_init(led); + if (ret) + return ret; + + ret = devm_led_classdev_register(&client->dev, &led->led_dev); + if (ret) { + dev_err(&client->dev, "led register err: %d\n", ret); + return ret; + } + + return 0; +} + +static int lm3692x_remove(struct i2c_client *client) +{ + struct lm3692x_led *led = i2c_get_clientdata(client); + int 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 lm3692x_id[] = { + { "lm36922", 0 }, + { "lm36923", 1 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, lm3692x_id); + +static const struct of_device_id of_lm3692x_leds_match[] = { + { .compatible = "ti,lm36922", }, + { .compatible = "ti,lm36923", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_lm3692x_leds_match); + +static struct i2c_driver lm3692x_driver = { + .driver = { + .name = "lm3692x", + .of_match_table = of_lm3692x_leds_match, + }, + .probe = lm3692x_probe, + .remove = lm3692x_remove, + .id_table = lm3692x_id, +}; +module_i2c_driver(lm3692x_driver); + +MODULE_DESCRIPTION("Texas Instruments LM3692X LED driver"); +MODULE_AUTHOR("Dan Murphy "); +MODULE_LICENSE("GPL v2"); From patchwork Fri Dec 1 16:56:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 120356 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1382864qgn; Fri, 1 Dec 2017 08:56:50 -0800 (PST) X-Google-Smtp-Source: AGs4zMYpwY/XkTMU4f3PHsngjsxkyNyTIylbBnSBINBjRmUTQuPbK0SOk3F7OqWm1sDRHPCb/U/M X-Received: by 10.84.140.131 with SMTP id 3mr6742930plt.394.1512147410683; Fri, 01 Dec 2017 08:56:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512147410; cv=none; d=google.com; s=arc-20160816; b=EiieTHJR+aJZuJ3jncWA6Wdwp4AMNhpigWbH9E1+agQv/2hkDLGw+Bvo0PbBd92ar0 SJgfm7U7BTAWXw3ZVhXD82K/ciRumI48BPiv//yS6KgfQUGaz9/iG4v4wRTh88NhdA3C I7TzeMZQ1EGMLOYOwlry1jnyrmj8ejLP3o15YXLGwf8qh6VhUUHvaKxZsIMk7gHqM6JF WYAPCMUqi81SKI8T7o6Qdu0h3uaeAq5OaPnhjWeFZ4rlWhLkX5JqvyuiLI3JOvmEHLqy 4U+KTKVrgwGv2AN/+cltpXH41lz/Ky0gbTcCfv604LgR20ZY62/S0uc4zphwRO1W/2An VnAw== 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 :arc-authentication-results; bh=LbCtAtHHqZZ+Qwkm/GCRgOsHSffwqnZLDkYxvokxr6U=; b=OnHzn1VT1jDzh+66IYYnN82gXgeqTPAAZXqOsLcEdMRBIRq94XHqItYFQJ5Objptw3 hRzhul1LVb9AZHnGX9ldU0wD86DPgdesvVbGJDAZwBxFUMgv/Jcf3IBLiI2irBt66Tem Zv2L5zH2xHbNQlP24d+D8/jE7sI2LALrK31i7llEQ+ZLLoTD0eoyX2RsyG/M63dTJv8V X27PSnEdh/Jz9cUTncD88n9AMNiFLjQAs/0RBb5mBxnPOVYeL5uZIJItd0f9wUP7hkdN 9EBL2ujZ5aEN8m/pwUwqBO3PsX/FJ/aG27DPtrvMH4CwmRdyh4+YW3rI4GDZfzUEPNWK WuVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eCs3UCU/; 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 a7si5038785pgq.277.2017.12.01.08.56.50; Fri, 01 Dec 2017 08:56:50 -0800 (PST) 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=eCs3UCU/; 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 S1751443AbdLAQ4r (ORCPT + 28 others); Fri, 1 Dec 2017 11:56:47 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:20269 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751254AbdLAQ4o (ORCPT ); Fri, 1 Dec 2017 11:56:44 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id vB1GuQCV020852; Fri, 1 Dec 2017 10:56:26 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1512147386; bh=TrByKF+VHIq64vJTo3s6xKAgNvSs7NJ4NOQOEwd4I+s=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eCs3UCU/52D9OJkHZ6rDRSvDiji8EzxEhAw+MJuxO1guH2KHZepk1OWLWsaMgddaA LZPFkTe/EtVCMEV/Ic6jLaf1Q0wl1nIIwF1n7ASHld4zvUjAqRVvOI75uPe9v40mON 9BWISBxNp8i1SO7L9QsR0DI16QocfEoSwqK7H8MU= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id vB1GuQ5t016949; Fri, 1 Dec 2017 10:56:26 -0600 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Fri, 1 Dec 2017 10:56:25 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Fri, 1 Dec 2017 10:56:25 -0600 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 vB1GuPDK013228; Fri, 1 Dec 2017 10:56:25 -0600 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.70.55]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id vB1GuP303185; Fri, 1 Dec 2017 10:56:25 -0600 (CST) From: Dan Murphy To: , , CC: , , Dan Murphy Subject: [PATCH v6 5/6] leds: lp8860: Update the LED label generation Date: Fri, 1 Dec 2017 10:56:12 -0600 Message-ID: <20171201165613.10358-5-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20171201165613.10358-1-dmurphy@ti.com> References: <20171201165613.10358-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 Fix the LED label generation for the LP8860 to conform with the Documentation/devicetree/bindings/leds/common.txt document indicating the LED label should be part of a child node to the device parent. If no label is in the child node then the LED label is created based on the parent node name and the alternate name passed in. Signed-off-by: Dan Murphy --- v6 - New patch to use the new LED class API drivers/leds/leds-lp8860.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) -- 2.15.0.124.g7668cbc60 diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index 3e70775a2d54..26bbfa144402 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -22,6 +22,7 @@ #include #include #include +#include #define LP8860_DISP_CL1_BRT_MSB 0x00 #define LP8860_DISP_CL1_BRT_LSB 0x01 @@ -86,8 +87,6 @@ #define LP8860_CLEAR_FAULTS 0x01 -#define LP8860_DISP_LED_NAME "display_cluster" - /** * struct lp8860_led - * @lock - Lock for reading/writing the device @@ -107,7 +106,7 @@ struct lp8860_led { struct regmap *eeprom_regmap; struct gpio_desc *enable_gpio; struct regulator *regulator; - const char *label; + char label[LED_MAX_NAME_SIZE]; }; struct lp8860_eeprom_reg { @@ -318,7 +317,7 @@ static const struct regmap_config lp8860_regmap_config = { .max_register = LP8860_EEPROM_UNLOCK, .reg_defaults = lp8860_reg_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_reg_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static const struct reg_default lp8860_eeprom_defs[] = { @@ -356,7 +355,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = { .max_register = LP8860_EEPROM_REG_24, .reg_defaults = lp8860_eeprom_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_eeprom_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static int lp8860_probe(struct i2c_client *client, @@ -365,19 +364,23 @@ static int lp8860_probe(struct i2c_client *client, int ret; struct lp8860_led *led; struct device_node *np = client->dev.of_node; + struct device_node *child_node; + + if (!client->dev.of_node) + return -ENODEV; led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; - led->label = LP8860_DISP_LED_NAME; + for_each_available_child_of_node(np, child_node) { + led->led_dev.default_trigger = of_get_property(child_node, + "linux,default-trigger", + NULL); - if (client->dev.of_node) { - ret = of_property_read_string(np, "label", &led->label); - if (ret) { - dev_err(&client->dev, "Missing label in dt\n"); - return -EINVAL; - } + of_led_compose_name(np, child_node, "white:backlight", + sizeof("white:backlight"), + led->label); } led->enable_gpio = devm_gpiod_get_optional(&client->dev,