From patchwork Wed Sep 11 18:01:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 173634 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1102787oce; Wed, 11 Sep 2019 11:01:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy360PgybSAJd+WNe5ymw4Z43ez94jvtxh17pq07jLoTOt+S95Etf7GAakivb7Dsd12TV4K X-Received: by 2002:a17:906:32c3:: with SMTP id k3mr3313788ejk.117.1568224915745; Wed, 11 Sep 2019 11:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568224915; cv=none; d=google.com; s=arc-20160816; b=oErMCsCC2f/oUhH/QmHCarMPsxwIzI/457ZsNmbVvwpaqXAxHVgXwwcKMe393pkHUX FqjJkpKd2lFT6tEh/WscxA26yQfZyIXciKi7GT9EjyW0UnIMS8HV9+5pqdd9/0wb7NP/ cO8pYZCo3psIfasiT4IM7nkFl8Fq0orqJTxmMKVzpEQ3YsKQi8nMh+vDR9Yr9rCuifsK rm+rUtk1MPYx5/McKWs1LglpNO4c7+IPnqA3qUXbTWSjRF6SXEGmrCTVaQP1Ox2g5ysM smTjkDF+xgvzkTmX0Il8anMdF1y+A44Q3BlBKA+LMps4QVl8lAgQHQwl46tJuExPFlzK N+0A== 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=oUljA5ErHiv3YWcu3yuKsuunIS40fEW3qS+g1aItKiw=; b=mA7msB8OJ6seiyL8LOBjl48etMWR5cRPTi54LpB8g3lelg9Pv4LsvcGB926zEbmU70 U3E+L13f6bRB18M8uzl/nT2WzUdKv7cYI7IwQktbPAX1s8TpmKVYz03Bkuav7pPykYti 8oZSXgPXndUKHrx5N9IsbXIUlUaBGgXAf+mrJRr4G6IUBskqnfDxK8rnWivLq81cuLCN nrHPc6dx7dFoX21czH11DJf6yeacwyf1B7kQEaSyVNd63eYFkH3zxvC8c3CrTME3FtkD vrC1FYENP+zz/wfuKMwK/mqb2V6cChSOQww2agjLJmCrlK9SbhHMqJPTOeAw/0d5o0qU R18w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UChTsU1d; 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 h2si13885454edb.346.2019.09.11.11.01.55; Wed, 11 Sep 2019 11:01:55 -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=UChTsU1d; 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 S1729978AbfIKSBv (ORCPT + 27 others); Wed, 11 Sep 2019 14:01:51 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:52580 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729769AbfIKSBX (ORCPT ); Wed, 11 Sep 2019 14:01:23 -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 x8BI1H9n088970; Wed, 11 Sep 2019 13:01:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568224877; bh=oUljA5ErHiv3YWcu3yuKsuunIS40fEW3qS+g1aItKiw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UChTsU1dCAtXaIyQ71deQGp1W/ZAu97k1O0muKusVMoUrsyU/4x1jEKCmyBrsvBQB 9aBLxWdKhZ9OtcUdC74uE492ZoXVZk9GknEFyu33rEaoegfdTYqMRSgAZdbluictvB fEYLDllfPQ4z7N0Ciy1VnKP3nFLCmTFF833nVimU= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8BI1HXw009326 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Sep 2019 13:01:17 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) 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.1713.5; Wed, 11 Sep 2019 13:01:17 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE108.ent.ti.com (10.64.6.29) 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; Wed, 11 Sep 2019 13:01:16 -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 x8BI1GMV040976; Wed, 11 Sep 2019 13:01:16 -0500 From: Dan Murphy To: , CC: , , , Dan Murphy Subject: [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition Date: Wed, 11 Sep 2019 13:01:07 -0500 Message-ID: <20190911180115.21035-2-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190911180115.21035-1-dmurphy@ti.com> References: <20190911180115.21035-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 a documentation of LED Multicolor LED class specific sysfs attributes. Signed-off-by: Dan Murphy --- .../ABI/testing/sysfs-class-led-multicolor | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor -- 2.22.0.214.g8dca754b1e diff --git a/Documentation/ABI/testing/sysfs-class-led-multicolor b/Documentation/ABI/testing/sysfs-class-led-multicolor new file mode 100644 index 000000000000..4ea54c2ad4c8 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-led-multicolor @@ -0,0 +1,73 @@ +What: /sys/class/leds//brightness +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy +Description: read/write + The multicolor class will redirect the device drivers call back + function for brightness control to the multicolor class + brightness control function. + + Writing to this file will update all LEDs within the group to a + calculated percentage of what each color LED in the group is set + to. The percentage is calculated via the equation below: + + led_brightness = requested_value * led_color_intensity/led_color_max_intensity + + For additional details please refer to + Documentation/leds/leds-class-multicolor.rst. + + The value of the color is from 0 to + /sys/class/leds//max_brightness. + +What: /sys/class/leds//colors/color_mix +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy +Description: read/write + The values written to this file should contain the intensity + values of each multicolor LED within the colors directory. The + index of given color is reported by the color_id file present in + colors/ directory. The index determines the position in + the sequence of intensities on which the related intensity + should be passed to this file. + + For additional details please refer to + Documentation/leds/leds-class-multicolor.rst. + +What: /sys/class/leds//colors//color_id +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy +Description: read only + This file when read will return the index of the color in the + color_mix. + + For additional details please refer to + Documentation/leds/leds-class-multicolor.rst. + +What: /sys/class/leds//colors//intensity +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy +Description: read/write + The led_color directory is dynamically created based on the + colors defined by the registrar of the class. + The led_color can be but not limited to red, green, blue, + white, amber, yellow and violet. There is one directory per color + presented. The brightness file is created under each + led_color directory and controls the individual LED color + setting. + + The value of the color is from 0 to + /sys/class/leds//colors//max_intensity. + +What: /sys/class/leds//colors//max_intensity +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy +Description: read only + Maximum intensity level for the LED color, default is + 255 (LED_FULL). + + If the LED does not support different intensity levels, this + should be 1. From patchwork Wed Sep 11 18:01:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 173633 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1102775oce; Wed, 11 Sep 2019 11:01:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyszDO7FQZogFXPhrm/+h/1reZy/XdDtb2M6IqfT/BRahqgozWkZkumyHUWw+pdz1Kohb01 X-Received: by 2002:a17:906:1385:: with SMTP id f5mr31419789ejc.145.1568224915285; Wed, 11 Sep 2019 11:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568224915; cv=none; d=google.com; s=arc-20160816; b=LZVBROcWuznri1vJ8FDYtxd8BIl65VsMoP96OSDpFWJLm2989gnQGyTbKeAjnXZ+71 Ph4LwdEPl1UGBMdK/sWGbCYFjuPqBlJ4xp3HEY9WiEiqz3J0ZjF8vEBySv5vPoejWE8r 4QcksPqADEMT9iwNxCNAqR/Qj5thrAFsMLSges5t4lV+SzyQF7qzzp9dy50jWRBioKZF 95ZFADBroRZSOtA/dgAvZ19RB0gO5Zsf7iciZzcDt/juwo3xSCms7jJfk77ice+1ApOM os6ka2c6v7LbO8/6VHKXB0G7vJQb5tvQfd25+0DobHX2AVibvEFpqe1k+9HuQxBSWzHi J1RA== 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=FmX84wdoIvKOF4QfyScCM6+x89vt6CsCWXDGcqUhLqw=; b=XQXK3Hgr3tk1Eh4kWdG5e1ny65AzyPVD/uZOgQyxoj07EXw80oCn48CgGr95EjWLbe TTu8BvgXWDg50Ik/WC3fdEZUwTuxgSgi3pUjSGaGgT/4/Ue2rZYp9z+KLD8CgXJnYsst anSCGF6iJ/o+DMQGD+QJs5Gau0v+S9Wo2szJDTgikKMiKgnF+BxoAMc7h2e1mmQ4agBW XzBNO4KvqfH+W8bJODJwx6SUkGX3bymb60n2nh3wFrhEaCFuIjuI2ZNLX/vNntdj5MC1 MDvirUMLASv0j/E4erCODzxVLN2thVJ297p/E6kY0KRabZkYvNhTDlnhNSETHfNKvJnd vyWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=q06ncsND; 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 h2si13885454edb.346.2019.09.11.11.01.54; Wed, 11 Sep 2019 11:01:55 -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=q06ncsND; 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 S1729990AbfIKSBw (ORCPT + 27 others); Wed, 11 Sep 2019 14:01:52 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:55974 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729727AbfIKSBX (ORCPT ); Wed, 11 Sep 2019 14:01:23 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8BI1H8u000904; Wed, 11 Sep 2019 13:01:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568224877; bh=FmX84wdoIvKOF4QfyScCM6+x89vt6CsCWXDGcqUhLqw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=q06ncsNDgn4TyFv8BrgKqptSB419/FBge+C95IAVTWOfDXA9YBs5Poo7wVVqCUfHd QvcE4ZZXvMAIrmyJRddj9CCrpMa9GYPjHp0K5iSOFo0zh6mk11SEaaogQBLaXVIvst xHaspIacKmgt+dbqgXMgUqGVzVoSE7UZBTgOTFTA= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8BI1H7o102539; Wed, 11 Sep 2019 13:01:17 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 11 Sep 2019 13:01:17 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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 via Frontend Transport; Wed, 11 Sep 2019 13:01:17 -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 x8BI1Hrd040990; Wed, 11 Sep 2019 13:01:17 -0500 From: Dan Murphy To: , CC: , , , Dan Murphy Subject: [PATCH v5 3/9] dt: bindings: Add multicolor class dt bindings documention Date: Wed, 11 Sep 2019 13:01:09 -0500 Message-ID: <20190911180115.21035-4-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190911180115.21035-1-dmurphy@ti.com> References: <20190911180115.21035-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 DT bindings for the LEDs multicolor class framework. Signed-off-by: Dan Murphy --- .../bindings/leds/leds-class-multicolor.txt | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-class-multicolor.txt -- 2.22.0.214.g8dca754b1e diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt b/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt new file mode 100644 index 000000000000..5d36327b18fc --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt @@ -0,0 +1,96 @@ +* Multicolor LED properties + +Multicolor LEDs can consist of a RGB, RGBW or a RGBA LED clusters. These devices +can be grouped together and also provide a modeling mechanism so that the +cluster LEDs can vary in hue and intensity to produce a wide range of colors. + +The nodes and properties defined in this document are unique to the multicolor +LED class. Common LED nodes and properties are inherited from the common.txt +within this documentation directory. + +Required LED Child properties: + - color : For multicolor LED support this property should be defined as + LED_COLOR_ID_MULTI and further definition can be found in + include/linux/leds/common.h. + +led-controller@30 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "ti,lp5024"; + reg = <0x29>; + + multi-led@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + color = ; + function = LED_FUNCTION_; + + + led@3 { + reg = <3>; + color = ; + }; + + led@4 { + reg = <4>; + color = ; + }; + + led@5 { + reg = <5>; + color = ; + }; + }; + + multi-led@2 { + #address-cells = <1>; + #size-cells = <0>; + color = ; + function = LED_FUNCTION_ACTIVITY; + reg = <2>; + ti,led-bank = <2 3 5>; + + led@6 { + reg = <0x6>; + color = ; + led-sources = <6 9 15>; + }; + + led@7 { + reg = <0x7>; + color = ; + led-sources = <7 10 16>; + }; + + led@8 { + reg = <0x8>; + color = ; + led-sources = <8 11 17>; + }; + }; + + multi-led@4 { + #address-cells = <1>; + #size-cells = <0>; + reg = <4>; + color = ; + function = LED_FUNCTION_ACTIVITY; + + led@12 { + reg = <12>; + color = ; + }; + + led@13 { + reg = <13>; + color = ; + }; + + led@14 { + reg = <14>; + color = ; + }; + }; + +}; From patchwork Wed Sep 11 18:01:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 173629 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1102321oce; Wed, 11 Sep 2019 11:01:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBmZ2dox0OCGLc/LR13oAiJRGIUZSW8OK4h4xD6loN/b3LxeIxO/2rVqGFDiGzMO2SzOga X-Received: by 2002:a17:906:1d11:: with SMTP id n17mr31154852ejh.68.1568224895210; Wed, 11 Sep 2019 11:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568224895; cv=none; d=google.com; s=arc-20160816; b=TPoNKNy7f99lPwLmCzAwrydILGhgadGr7i5Cy71eBrVVgSasEgraQvQSoWfdYCaUZq Uxpr6nCwDHf9LO0WZmVPIqikBkwZxUeDS0kM8G96ywBMpVh3RilbfORANixCy7faFPoV Uj+03E04bCgETfrl86Tsd7SX54li8x/I9Udob2iPKEbg/l6hM5eyME600IRdWo8yikam euAbugd6LslsF4sOT7yChdoHAwryk1Qnc6yE/txqXJE9u7daGIxcb3G3rrQFg2u6lJp4 a26fcgGWfYD6rp0h5RlaZEzJySQkgWpsk1FtaGPptKKUHDFvY5AstiEAwRlKXqgCX3e4 byPQ== 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=zV3cVdmjhCBXzQdA/5xCOaiT1n6XKbwdMaP1jdy4goo=; b=z3l5L86HAVzeVvsG6JE0VhVpuBPwDYzK7bj+wSw35Bt/X3oVzmsU1CXShljIGJuh21 7GeAqpRDcKFiwEZ3kLUnvPLglliqDzmtOSp3JX0JC8PflzPHUblLM0iqOQm0eHdiTUTg HqRriYZmFkhnrIRKcxagASqc33W9pfwWWvuwamKAANYYj2MFQPM5qJOJxapYK4vWNZEu yWYdjXTPfpRhzh8GrgbRD4VK4rxOtw/Zw4waNc/+2VqHcPho9MsfOp6dDRLzhF/3aN6R h0Rv1GQ0NpzbHe2s7WWkELFTxtTfwlcIVzbItLh+gaqT1DqSj64o5nhEbvgwU9lRqOUT lGNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=izDoS0H7; 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 t10si7434074eds.369.2019.09.11.11.01.34; Wed, 11 Sep 2019 11:01:35 -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=izDoS0H7; 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 S1729871AbfIKSBX (ORCPT + 27 others); Wed, 11 Sep 2019 14:01:23 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:36750 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729768AbfIKSBW (ORCPT ); Wed, 11 Sep 2019 14:01:22 -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 x8BI1HgO040449; Wed, 11 Sep 2019 13:01:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568224877; bh=zV3cVdmjhCBXzQdA/5xCOaiT1n6XKbwdMaP1jdy4goo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=izDoS0H7sk8s4u2EdHj4oEVVPes6xWxGWNvRgvnt8LiyCg6JA3oFe7p7qySW60gBh Tpdci3gS1ooP3xMdhLIjjJqgr1C4g21bqmHvJAQpvW6Qo+leMjyNKUwbrvq6DZSjRe jJUqtdrRLFK9Jrei5oKYUCe1KhnvMZ2pzcvlVzEc= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8BI1H5A007256 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Sep 2019 13:01:17 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 11 Sep 2019 13:01:17 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) 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.1713.5 via Frontend Transport; Wed, 11 Sep 2019 13:01:17 -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 x8BI1HO5063862; Wed, 11 Sep 2019 13:01:17 -0500 From: Dan Murphy To: , CC: , , , Dan Murphy Subject: [PATCH v5 4/9] dt-bindings: leds: Add multicolor ID to the color ID list Date: Wed, 11 Sep 2019 13:01:10 -0500 Message-ID: <20190911180115.21035-5-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190911180115.21035-1-dmurphy@ti.com> References: <20190911180115.21035-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 a new color ID that is declared as MULTICOLOR as with the multicolor framework declaring a definitive color is not accurate as the node can contain multiple colors. Signed-off-by: Dan Murphy --- include/dt-bindings/leds/common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.22.0.214.g8dca754b1e diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 9e1256a7c1bf..7006d15f71e8 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -29,7 +29,8 @@ #define LED_COLOR_ID_VIOLET 5 #define LED_COLOR_ID_YELLOW 6 #define LED_COLOR_ID_IR 7 -#define LED_COLOR_ID_MAX 8 +#define LED_COLOR_ID_MULTI 8 +#define LED_COLOR_ID_MAX 9 /* Standard LED functions */ #define LED_FUNCTION_ACTIVITY "activity" From patchwork Wed Sep 11 18:01:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 173632 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1102637oce; Wed, 11 Sep 2019 11:01:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqysS0zv0WPGojUxm/8gKXYkgjJRLgX53DgPIBQXZ+bc0flO4xAEo0FaMfK//VTjGcPYkBDT X-Received: by 2002:a17:906:fad4:: with SMTP id lu20mr30104379ejb.87.1568224909203; Wed, 11 Sep 2019 11:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568224909; cv=none; d=google.com; s=arc-20160816; b=H6oQwn3WUh7bphgyecQLyNOiMLVUdQu6kdcIKCV/I5wZ43Y/Qm6/2uEot42fVDHxyA Vwb7Ug7qtK8I1TtMolVqefKkvmDoCvgLUct8HE1E94QG260aCmNqq43RoDx5Bc1qd++i ljwde1gQUAYH/Rc+yAJnpIBylv/Qe1ag30eGpPp67yEkCkNeP25e/Y84dMi6/z1q+w3G BmWWKp4++VauKaOcY2ZbbfvcicMk61d8YAaNcsv1fFqt45KbxwqqoCCr7AuSWRamRk2F LqBcuKFZcNR27/Oyj2dP8GSd3Wu3Dg7Se0uVXEt2po+31XjRh4cA/X2VnvJr02K3KnkU gcUQ== 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=7rskmsTiAzvQ4NF4+vWKavl0uEPi2s+cxTAi1MuphJk=; b=Ryp5KzzALdx3G2+98dZmf0AUjw5os+X4pxpYI+ZRRB+SV8UKUrXc4dNE/PYsB0ach9 /U27nyGP5PxEOf6GVZjx2AeCJpDAVOZTDkI3HBBCbX8/d1KVjhdNVHbMwSQgzUZM+OVb aeZMxlKO/wEKSzz8xJ9EC7NS/qZYsN7tkftVV1f48SbDrgB7pOQHIaaCPAIBdBZqmvKW ko6j5MEONtIGtmpSkv1UrrJZtZRLCw/GamAg1ssSony8EhGmifG6B/8JLGAOwpduGujr 8a5kw/Kn33uu9Yab3mx9lzNYsdnCHxwPhYqjcJilrr36784l0eQPtPkJMjitPujl1C/Q 8XLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V1IfLia3; 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 jp5si11314294ejb.258.2019.09.11.11.01.48; Wed, 11 Sep 2019 11:01:49 -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=V1IfLia3; 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 S1729968AbfIKSBp (ORCPT + 27 others); Wed, 11 Sep 2019 14:01:45 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:33064 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729788AbfIKSBX (ORCPT ); Wed, 11 Sep 2019 14:01:23 -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 x8BI1I1k006894; Wed, 11 Sep 2019 13:01:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568224878; bh=7rskmsTiAzvQ4NF4+vWKavl0uEPi2s+cxTAi1MuphJk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=V1IfLia3FQRuIEQCR92NUkfcLKlYJPqLyyMTXMtUG2TNBFfnfTFFeaEQLbYQFLwaj NpksfBklZozMN9htJRge214pYhW89IYPL5Bf4ukozsjLBTltsbERZweuqOkZ+Of2JX 7FF9TZC0P/XFfokhiAmpeeGH9aw1T7rRxTtryYrQ= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8BI1IYa007271 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Sep 2019 13:01:18 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) 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; Wed, 11 Sep 2019 13:01:18 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE102.ent.ti.com (10.64.6.23) 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; Wed, 11 Sep 2019 13:01:18 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8BI1Im7052630; Wed, 11 Sep 2019 13:01:18 -0500 From: Dan Murphy To: , CC: , , , Dan Murphy Subject: [PATCH v5 7/9] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Date: Wed, 11 Sep 2019 13:01:13 -0500 Message-ID: <20190911180115.21035-8-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190911180115.21035-1-dmurphy@ti.com> References: <20190911180115.21035-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 bindings for the Texas Instruments LP5036, LP5030, LP5024, LP5018, LP5012 and LP5009 RGB LED device driver. The LP5036/30/24/18/12/9 can control RGB LEDs individually or as part of a control bank group. These devices have the ability to adjust the mixing control for the RGB LEDs to obtain different colors independent of the overall brightness of the LED grouping. Datasheet: http://www.ti.com/lit/ds/symlink/lp5012.pdf http://www.ti.com/lit/ds/symlink/lp5024.pdf http://www.ti.com/lit/ds/symlink/lp5036.pdf Signed-off-by: Dan Murphy --- .../devicetree/bindings/leds/leds-lp50xx.txt | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-lp50xx.txt -- 2.22.0.214.g8dca754b1e diff --git a/Documentation/devicetree/bindings/leds/leds-lp50xx.txt b/Documentation/devicetree/bindings/leds/leds-lp50xx.txt new file mode 100644 index 000000000000..9d05f43042e0 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-lp50xx.txt @@ -0,0 +1,148 @@ +* Texas Instruments - LP5009/12/18/24/30/36 RGB LED driver + +The LP50XX is multi-channel, I2C RGB LED Drivers that can group RGB LEDs into +a LED group or control them individually. + +The difference in these RGB LED drivers is the number of supported RGB modules. + +Required parent properties: + - compatible: + "ti,lp5009" + "ti,lp5012" + "ti,lp5018" + "ti,lp5024" + "ti,lp5030" + "ti,lp5036" + - reg : I2C slave address + lp5009/12 - 0x28 + lp5018/24 - 0x28 + lp5030/36 - 0x30 + - #address-cells : 1 + - #size-cells : 0 + +Optional parent properties: + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + +Required child properties: + - #address-cells : 1 + - #size-cells : 0 + - reg : This is the LED module number. + - color : see Documentation/devicetree/bindings/leds/common.txt + - function : see Documentation/devicetree/bindings/leds/common.txt + +Required child properties only is LED modules will be banked: + - ti,led-bank : This property denotes the LED module numbers that will + be controlled as a single RGB cluster. Each LED module + number will be controlled by a single LED class instance. + There can only be one instance of the ti,led-bank + property for each device node. + +Required grandchildren properties: + - reg : A single entry denoting the LED module that controls + the RGB cluster. + - color : see Documentation/devicetree/bindings/leds/leds-multicolor.txt + - led-sources : see Documentation/devicetree/bindings/leds/common.txt + +The LED outputs associated with the LED modules are defined in Table 1 of the +corresponding data sheets. + +LP5009 - 2 Total RGB cluster LED outputs 0-1 +LP5012 - 4 Total RGB cluster LED outputs 0-3 +LP5018 - 6 Total RGB cluster LED outputs 0-5 +LP5024 - 8 Total RGB cluster LED outputs 0-7 +LP5030 - 10 Total RGB cluster LED outputs 0-9 +LP5036 - 12 Total RGB cluster LED outputs 0-11 + +Optional child properties: + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Examples: +led-controller@29 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "ti,lp5024"; + reg = <0x29>; + enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + vled-supply = <&vmmcsd_fixed>; + + multi-led@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + color = ; + function = LED_FUNCTION_STATUS; + + led@3 { + reg = <3>; + color = ; + }; + + led@4 { + reg = <4>; + color = ; + }; + + led@5 { + reg = <5>; + color = ; + }; + }; + + multi-led@2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + color = ; + function = LED_FUNCTION_STANDBY; + ti,led-bank = <2 3 5>; + + led@6 { + reg = <0x6>; + color = ; + led-sources = <6 9 15>; + }; + + led@7 { + reg = <0x7>; + color = ; + led-sources = <7 10 16>; + }; + + led@8 { + reg = <0x8>; + color = ; + led-sources = <8 11 17>; + }; + }; + + multi-led@4 { + #address-cells = <1>; + #size-cells = <0>; + reg = <4>; + color = ; + function = LED_FUNCTION_ACTIVITY; + + led@12 { + reg = <12>; + color = ; + }; + + led@13 { + reg = <13>; + color = ; + }; + + led@14 { + reg = <14>; + color = ; + }; + }; +}; + +For more product information please see the link below: +http://www.ti.com/lit/ds/symlink/lp5012.pdf +http://www.ti.com/lit/ds/symlink/lp5024.pdf +http://www.ti.com/lit/ds/symlink/lp5036.pdf From patchwork Wed Sep 11 18:01:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 173631 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1102461oce; Wed, 11 Sep 2019 11:01:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8D2rRDZ5YotfgPIN2XhhfIzGUHkM987mWmxocImzz/BD5r4agsav7tULoSuwPiO5BD1nX X-Received: by 2002:a17:906:d29b:: with SMTP id ay27mr30337373ejb.141.1568224901259; Wed, 11 Sep 2019 11:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568224901; cv=none; d=google.com; s=arc-20160816; b=c+023RSPbCz+t72wlUUL/C1dbBBcjXa2LBs6VYKWBHiuZs1RcBYNnSGIzLWqbZ7UqP vD2FJ5tf0wGKMwZVwO0xu3/lcuV8u+vZBj+iGyRDWyiaK0la4+QzV3cuYKG9OwNzNEkf Ld1CjEMj+k1pNZLDNbJuWtjOtPC6tphJu+/lle40UlZ7NRKiENN9VQeZW7eeZDHzCGlv /2vQaMOKw7JXEJ66YJS4NxHzzQPBv5mxgPhY69Uzly5wm2zv7C/i1w0HEmc4elL8/grH /sOA4Er5BtTjEhidAfHCScM5b9KE2cvA/0tJyYiLQDvd1MaAs9EPwiEFRvKFb+0L5Wfw +0Fg== 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=WAwXg/3AkePdT8YXqiwMjosgCdkY4MKxgDgTqj5RVm8=; b=VyC7Gn62w500hn+rtjNtlT1OEXhBW+LjUwByFGU74DetpkGyPtcu/u5IC2MyVFc3zy pACRtXUVLseITYvyRkUNENFoFfiGa3rsoekgQCbSl0MmuE1RpY6agVvdYbq538l1xw2C 15ay9rrZW9V+xTupegL6v3khwqVuhfvlgep+6P9C2pFKVXI4OOSj7efPZF6U6Vx59GzZ Io1fpWs5X5x7j64Vs2aiRtmJ+AfnXm+aOWHP/UnPPavrK0D4Ilr0uc5TJWCyGhr0HP5R vnIxLYtvDGfvj05jkXdkTBMigf+SBk2+CIqaUByKFys2h32ZVqwXgkjr2MuqHD53Ro3m Oykg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ENdEDcAo; 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 l5si10931101ejc.23.2019.09.11.11.01.40; Wed, 11 Sep 2019 11:01:41 -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=ENdEDcAo; 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 S1729943AbfIKSBg (ORCPT + 27 others); Wed, 11 Sep 2019 14:01:36 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:36756 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729780AbfIKSBX (ORCPT ); Wed, 11 Sep 2019 14:01:23 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8BI1IWK040461; Wed, 11 Sep 2019 13:01:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568224878; bh=WAwXg/3AkePdT8YXqiwMjosgCdkY4MKxgDgTqj5RVm8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ENdEDcAosQ/1wgQjtMi/qFLxhGr/rFdL2tfhw8TJ/CS7QlAOZHMDjbDeQcrB5MtGN 7h4qkMeiTqV3zqRJL+OiI5aXuP/BT6Hq0QGsjt+F11PgiKSnY0jtYmPQ20VnCy8e7u cNaaDJSqUOxh+XN9PPOa37nxyJyNXKN5l9duUi4I= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8BI1IEZ102582; Wed, 11 Sep 2019 13:01:18 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 11 Sep 2019 13:01:18 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE105.ent.ti.com (10.64.6.26) 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; Wed, 11 Sep 2019 13:01:18 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8BI1Ixf011144; Wed, 11 Sep 2019 13:01:18 -0500 From: Dan Murphy To: , CC: , , , Dan Murphy Subject: [PATCH v5 8/9] leds: lp50xx: Add the LP50XX family of the RGB LED driver Date: Wed, 11 Sep 2019 13:01:14 -0500 Message-ID: <20190911180115.21035-9-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190911180115.21035-1-dmurphy@ti.com> References: <20190911180115.21035-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 LP5036/30/24/18/12/9 RGB LED driver. The difference in these parts are the number of LED outputs where the: LP5036 can control 36 LEDs LP5030 can control 30 LEDs LP5024 can control 24 LEDs LP5018 can control 18 LEDs LP5012 can control 12 LEDs LP509 can control 9 LEDs The device has the ability to group LED output into control banks so that multiple LED banks can be controlled with the same mixing and brightness. Inversely the LEDs can also be controlled independently. Signed-off-by: Dan Murphy --- drivers/leds/Kconfig | 7 + drivers/leds/Makefile | 1 + drivers/leds/leds-lp50xx.c | 807 +++++++++++++++++++++++++++++++++++++ 3 files changed, 815 insertions(+) create mode 100644 drivers/leds/leds-lp50xx.c -- 2.22.0.214.g8dca754b1e diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 71e7fd4f6f15..1041dfe8e354 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -350,6 +350,13 @@ config LEDS_LP3952 To compile this driver as a module, choose M here: the module will be called leds-lp3952. +config LEDS_LP50XX + tristate "LED Support for TI LP5036/30/24/18 LED driver chip" + depends on LEDS_CLASS && REGMAP_I2C + help + If you say yes here you get support for the Texas Instruments + LP5036, LP5030, LP5024 and LP5018 LED driver. + config LEDS_LP55XX_COMMON tristate "Common Driver for TI/National LP5521/5523/55231/5562/8501" depends on LEDS_LP5521 || LEDS_LP5523 || LEDS_LP5562 || LEDS_LP8501 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 897b810257dd..438a5499f3ee 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o obj-$(CONFIG_LEDS_LP3952) += leds-lp3952.o +obj-$(CONFIG_LEDS_LP50XX) += leds-lp50xx.o obj-$(CONFIG_LEDS_LP55XX_COMMON) += leds-lp55xx-common.o obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o obj-$(CONFIG_LEDS_LP5523) += leds-lp5523.o diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c new file mode 100644 index 000000000000..8a6cb559112f --- /dev/null +++ b/drivers/leds/leds-lp50xx.c @@ -0,0 +1,807 @@ +// SPDX-License-Identifier: GPL-2.0 +// TI LP50XX 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 + +#include + +#define LP50XX_DEV_CFG0 0x00 +#define LP50XX_DEV_CFG1 0x01 +#define LP50XX_LED_CFG0 0x02 + +/* LP5009 and LP5012 registers */ +#define LP5012_BNK_BRT 0x03 +#define LP5012_BNKA_CLR 0x04 +#define LP5012_BNKB_CLR 0x05 +#define LP5012_BNKC_CLR 0x06 +#define LP5012_LED0_BRT 0x07 +#define LP5012_LED1_BRT 0x08 +#define LP5012_LED2_BRT 0x09 +#define LP5012_LED3_BRT 0x0a +#define LP5012_OUT0_CLR 0x0b +#define LP5012_OUT1_CLR 0x0c +#define LP5012_OUT2_CLR 0x0d +#define LP5012_OUT3_CLR 0x0e +#define LP5012_OUT4_CLR 0x0f +#define LP5012_OUT5_CLR 0x10 +#define LP5012_OUT6_CLR 0x11 +#define LP5012_OUT7_CLR 0x12 +#define LP5012_OUT8_CLR 0x13 +#define LP5012_OUT9_CLR 0x14 +#define LP5012_OUT10_CLR 0x15 +#define LP5012_OUT11_CLR 0x16 +#define LP5012_RESET 0x17 + +/* LP5018 and LP5024 registers */ +#define LP5024_BNK_BRT 0x03 +#define LP5024_BNKA_CLR 0x04 +#define LP5024_BNKB_CLR 0x05 +#define LP5024_BNKC_CLR 0x06 +#define LP5024_LED0_BRT 0x07 +#define LP5024_LED1_BRT 0x08 +#define LP5024_LED2_BRT 0x09 +#define LP5024_LED3_BRT 0x0a +#define LP5024_LED4_BRT 0x0b +#define LP5024_LED5_BRT 0x0c +#define LP5024_LED6_BRT 0x0d +#define LP5024_LED7_BRT 0x0e + +#define LP5024_OUT0_CLR 0x0f +#define LP5024_OUT1_CLR 0x10 +#define LP5024_OUT2_CLR 0x11 +#define LP5024_OUT3_CLR 0x12 +#define LP5024_OUT4_CLR 0x13 +#define LP5024_OUT5_CLR 0x14 +#define LP5024_OUT6_CLR 0x15 +#define LP5024_OUT7_CLR 0x16 +#define LP5024_OUT8_CLR 0x17 +#define LP5024_OUT9_CLR 0x18 +#define LP5024_OUT10_CLR 0x19 +#define LP5024_OUT11_CLR 0x1a +#define LP5024_OUT12_CLR 0x1b +#define LP5024_OUT13_CLR 0x1c +#define LP5024_OUT14_CLR 0x1d +#define LP5024_OUT15_CLR 0x1e +#define LP5024_OUT16_CLR 0x1f +#define LP5024_OUT17_CLR 0x20 +#define LP5024_OUT18_CLR 0x21 +#define LP5024_OUT19_CLR 0x22 +#define LP5024_OUT20_CLR 0x23 +#define LP5024_OUT21_CLR 0x24 +#define LP5024_OUT22_CLR 0x25 +#define LP5024_OUT23_CLR 0x26 +#define LP5024_RESET 0x27 + +/* LP5030 and LP5036 registers */ +#define LP5036_LED_CFG1 0x03 +#define LP5036_BNK_BRT 0x04 +#define LP5036_BNKA_CLR 0x05 +#define LP5036_BNKB_CLR 0x06 +#define LP5036_BNKC_CLR 0x07 +#define LP5036_LED0_BRT 0x08 +#define LP5036_LED1_BRT 0x09 +#define LP5036_LED2_BRT 0x0a +#define LP5036_LED3_BRT 0x0b +#define LP5036_LED4_BRT 0x0c +#define LP5036_LED5_BRT 0x0d +#define LP5036_LED6_BRT 0x0e +#define LP5036_LED7_BRT 0x0f +#define LP5036_LED8_BRT 0x10 +#define LP5036_LED9_BRT 0x11 +#define LP5036_LED10_BRT 0x12 +#define LP5036_LED11_BRT 0x13 + +#define LP5036_OUT0_CLR 0x14 +#define LP5036_OUT1_CLR 0x15 +#define LP5036_OUT2_CLR 0x16 +#define LP5036_OUT3_CLR 0x17 +#define LP5036_OUT4_CLR 0x18 +#define LP5036_OUT5_CLR 0x19 +#define LP5036_OUT6_CLR 0x1a +#define LP5036_OUT7_CLR 0x1b +#define LP5036_OUT8_CLR 0x1c +#define LP5036_OUT9_CLR 0x1d +#define LP5036_OUT10_CLR 0x1e +#define LP5036_OUT11_CLR 0x1f +#define LP5036_OUT12_CLR 0x20 +#define LP5036_OUT13_CLR 0x21 +#define LP5036_OUT14_CLR 0x22 +#define LP5036_OUT15_CLR 0x23 +#define LP5036_OUT16_CLR 0x24 +#define LP5036_OUT17_CLR 0x25 +#define LP5036_OUT18_CLR 0x26 +#define LP5036_OUT19_CLR 0x27 +#define LP5036_OUT20_CLR 0x28 +#define LP5036_OUT21_CLR 0x29 +#define LP5036_OUT22_CLR 0x2a +#define LP5036_OUT23_CLR 0x2b +#define LP5036_OUT24_CLR 0x2c +#define LP5036_OUT25_CLR 0x2d +#define LP5036_OUT26_CLR 0x2e +#define LP5036_OUT27_CLR 0x2f +#define LP5036_OUT28_CLR 0x30 +#define LP5036_OUT29_CLR 0x31 +#define LP5036_OUT30_CLR 0x32 +#define LP5036_OUT31_CLR 0x33 +#define LP5036_OUT32_CLR 0x34 +#define LP5036_OUT33_CLR 0x35 +#define LP5036_OUT34_CLR 0x36 +#define LP5036_OUT35_CLR 0x37 +#define LP5036_RESET 0x38 + +#define LP50XX_SW_RESET 0xff +#define LP50XX_CHIP_EN BIT(6) + +#define LP5009_MAX_LED_MODULES 2 +#define LP5012_MAX_LED_MODULES 4 +#define LP5018_MAX_LED_MODULES 6 +#define LP5024_MAX_LED_MODULES 8 +#define LP5030_MAX_LED_MODULES 10 +#define LP5036_MAX_LED_MODULES 12 + +struct lp50xx_led { + struct led_classdev led_dev; + struct led_classdev_mc mc_cdev; + struct lp50xx *priv; + unsigned long bank_modules; + char label[LED_MAX_NAME_SIZE]; + u8 ctrl_bank_enabled; + u32 available_leds; + int led_number; +}; + +/** + * struct lp50xx - + * @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 + * @chip_info: chip specific information (ie num_leds) + * @num_of_banked_leds: holds the number of banked LEDs + * @leds: Array of LED strings + */ +struct lp50xx { + struct gpio_desc *enable_gpio; + struct regulator *regulator; + struct i2c_client *client; + struct regmap *regmap; + struct device *dev; + struct mutex lock; + const struct lp50xx_chip_info *chip_info; + int num_of_banked_leds; + + /* This needs to be at the end of the struct */ + struct lp50xx_led leds[]; +}; + +static const struct reg_default lp5012_reg_defs[] = { + {LP50XX_DEV_CFG0, 0x0}, + {LP50XX_DEV_CFG1, 0x3c}, + {LP50XX_LED_CFG0, 0x0}, + {LP5012_BNK_BRT, 0xff}, + {LP5012_BNKA_CLR, 0x0f}, + {LP5012_BNKB_CLR, 0x0f}, + {LP5012_BNKC_CLR, 0x0f}, + {LP5012_LED0_BRT, 0x0f}, + {LP5012_LED1_BRT, 0xff}, + {LP5012_LED2_BRT, 0xff}, + {LP5012_LED3_BRT, 0xff}, + {LP5012_OUT0_CLR, 0x0f}, + {LP5012_OUT1_CLR, 0x00}, + {LP5012_OUT2_CLR, 0x00}, + {LP5012_OUT3_CLR, 0x00}, + {LP5012_OUT4_CLR, 0x00}, + {LP5012_OUT5_CLR, 0x00}, + {LP5012_OUT6_CLR, 0x00}, + {LP5012_OUT7_CLR, 0x00}, + {LP5012_OUT8_CLR, 0x00}, + {LP5012_OUT9_CLR, 0x00}, + {LP5012_OUT10_CLR, 0x00}, + {LP5012_OUT11_CLR, 0x00}, + {LP5012_RESET, 0x00} +}; + +static const struct reg_default lp5024_reg_defs[] = { + {LP50XX_DEV_CFG0, 0x0}, + {LP50XX_DEV_CFG1, 0x3c}, + {LP50XX_LED_CFG0, 0x0}, + {LP5024_BNK_BRT, 0xff}, + {LP5024_BNKA_CLR, 0x0f}, + {LP5024_BNKB_CLR, 0x0f}, + {LP5024_BNKC_CLR, 0x0f}, + {LP5024_LED0_BRT, 0x0f}, + {LP5024_LED1_BRT, 0xff}, + {LP5024_LED2_BRT, 0xff}, + {LP5024_LED3_BRT, 0xff}, + {LP5024_LED4_BRT, 0xff}, + {LP5024_LED5_BRT, 0xff}, + {LP5024_LED6_BRT, 0xff}, + {LP5024_LED7_BRT, 0xff}, + {LP5024_OUT0_CLR, 0x0f}, + {LP5024_OUT1_CLR, 0x00}, + {LP5024_OUT2_CLR, 0x00}, + {LP5024_OUT3_CLR, 0x00}, + {LP5024_OUT4_CLR, 0x00}, + {LP5024_OUT5_CLR, 0x00}, + {LP5024_OUT6_CLR, 0x00}, + {LP5024_OUT7_CLR, 0x00}, + {LP5024_OUT8_CLR, 0x00}, + {LP5024_OUT9_CLR, 0x00}, + {LP5024_OUT10_CLR, 0x00}, + {LP5024_OUT11_CLR, 0x00}, + {LP5024_OUT12_CLR, 0x00}, + {LP5024_OUT13_CLR, 0x00}, + {LP5024_OUT14_CLR, 0x00}, + {LP5024_OUT15_CLR, 0x00}, + {LP5024_OUT16_CLR, 0x00}, + {LP5024_OUT17_CLR, 0x00}, + {LP5024_OUT18_CLR, 0x00}, + {LP5024_OUT19_CLR, 0x00}, + {LP5024_OUT20_CLR, 0x00}, + {LP5024_OUT21_CLR, 0x00}, + {LP5024_OUT22_CLR, 0x00}, + {LP5024_OUT23_CLR, 0x00}, + {LP5024_RESET, 0x00} +}; + +static const struct reg_default lp5036_reg_defs[] = { + {LP50XX_DEV_CFG0, 0x0}, + {LP50XX_DEV_CFG1, 0x3c}, + {LP50XX_LED_CFG0, 0x0}, + {LP5036_LED_CFG1, 0x0}, + {LP5036_BNK_BRT, 0xff}, + {LP5036_BNKA_CLR, 0x0f}, + {LP5036_BNKB_CLR, 0x0f}, + {LP5036_BNKC_CLR, 0x0f}, + {LP5036_LED0_BRT, 0x0f}, + {LP5036_LED1_BRT, 0xff}, + {LP5036_LED2_BRT, 0xff}, + {LP5036_LED3_BRT, 0xff}, + {LP5036_LED4_BRT, 0xff}, + {LP5036_LED5_BRT, 0xff}, + {LP5036_LED6_BRT, 0xff}, + {LP5036_LED7_BRT, 0xff}, + {LP5036_OUT0_CLR, 0x0f}, + {LP5036_OUT1_CLR, 0x00}, + {LP5036_OUT2_CLR, 0x00}, + {LP5036_OUT3_CLR, 0x00}, + {LP5036_OUT4_CLR, 0x00}, + {LP5036_OUT5_CLR, 0x00}, + {LP5036_OUT6_CLR, 0x00}, + {LP5036_OUT7_CLR, 0x00}, + {LP5036_OUT8_CLR, 0x00}, + {LP5036_OUT9_CLR, 0x00}, + {LP5036_OUT10_CLR, 0x00}, + {LP5036_OUT11_CLR, 0x00}, + {LP5036_OUT12_CLR, 0x00}, + {LP5036_OUT13_CLR, 0x00}, + {LP5036_OUT14_CLR, 0x00}, + {LP5036_OUT15_CLR, 0x00}, + {LP5036_OUT16_CLR, 0x00}, + {LP5036_OUT17_CLR, 0x00}, + {LP5036_OUT18_CLR, 0x00}, + {LP5036_OUT19_CLR, 0x00}, + {LP5036_OUT20_CLR, 0x00}, + {LP5036_OUT21_CLR, 0x00}, + {LP5036_OUT22_CLR, 0x00}, + {LP5036_OUT23_CLR, 0x00}, + {LP5036_OUT24_CLR, 0x00}, + {LP5036_OUT25_CLR, 0x00}, + {LP5036_OUT26_CLR, 0x00}, + {LP5036_OUT27_CLR, 0x00}, + {LP5036_OUT28_CLR, 0x00}, + {LP5036_OUT29_CLR, 0x00}, + {LP5036_OUT30_CLR, 0x00}, + {LP5036_OUT31_CLR, 0x00}, + {LP5036_OUT32_CLR, 0x00}, + {LP5036_OUT33_CLR, 0x00}, + {LP5036_OUT34_CLR, 0x00}, + {LP5036_OUT35_CLR, 0x00}, + {LP5036_RESET, 0x00} +}; + +static const struct regmap_config lp5012_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LP5012_RESET, + .reg_defaults = lp5012_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lp5012_reg_defs), + .cache_type = REGCACHE_RBTREE, +}; + +static const struct regmap_config lp5024_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LP5024_RESET, + .reg_defaults = lp5024_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lp5024_reg_defs), + .cache_type = REGCACHE_RBTREE, +}; + +static const struct regmap_config lp5036_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LP5036_RESET, + .reg_defaults = lp5036_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lp5036_reg_defs), + .cache_type = REGCACHE_RBTREE, +}; + +enum lp50xx_model { + LP5009, + LP5012, + LP5018, + LP5024, + LP5030, + LP5036, +}; + +/* + * struct lp50xx_chip_info - + * @num_leds: number of LED outputs available on the device + * @led_brightness0_reg: first brightness register of the device + * @mix_out0_reg: first color mix register of the device + * @bank_brt_reg: bank brightness register + * @bank_mix_reg: color mix register + * @reset_reg: devices reset register + */ +struct lp50xx_chip_info { + struct regmap_config lp50xx_regmap_config; + u8 num_leds; + u8 led_brightness0_reg; + u8 mix_out0_reg; + u8 bank_brt_reg; + u8 bank_mix_reg; + u8 reset_reg; +}; + +static const struct lp50xx_chip_info lp50xx_chip_info_tbl[] = { + [LP5009] = { + .num_leds = LP5009_MAX_LED_MODULES, + .led_brightness0_reg = LP5012_LED0_BRT, + .mix_out0_reg = LP5012_OUT0_CLR, + .bank_brt_reg = LP5012_BNK_BRT, + .bank_mix_reg = LP5012_BNKA_CLR, + .reset_reg = LP5012_RESET, + .lp50xx_regmap_config = lp5012_regmap_config, + }, + [LP5012] = { + .num_leds = LP5012_MAX_LED_MODULES, + .led_brightness0_reg = LP5012_LED0_BRT, + .mix_out0_reg = LP5012_OUT0_CLR, + .bank_brt_reg = LP5012_BNK_BRT, + .bank_mix_reg = LP5012_BNKA_CLR, + .reset_reg = LP5012_RESET, + .lp50xx_regmap_config = lp5012_regmap_config, + }, + [LP5018] = { + .num_leds = LP5018_MAX_LED_MODULES, + .led_brightness0_reg = LP5024_LED0_BRT, + .mix_out0_reg = LP5024_OUT0_CLR, + .bank_brt_reg = LP5024_BNK_BRT, + .bank_mix_reg = LP5024_BNKA_CLR, + .reset_reg = LP5024_RESET, + .lp50xx_regmap_config = lp5024_regmap_config, + }, + [LP5024] = { + .num_leds = LP5024_MAX_LED_MODULES, + .led_brightness0_reg = LP5024_LED0_BRT, + .mix_out0_reg = LP5024_OUT0_CLR, + .bank_brt_reg = LP5024_BNK_BRT, + .bank_mix_reg = LP5024_BNKA_CLR, + .reset_reg = LP5024_RESET, + .lp50xx_regmap_config = lp5024_regmap_config, + }, + [LP5030] = { + .num_leds = LP5030_MAX_LED_MODULES, + .led_brightness0_reg = LP5036_LED0_BRT, + .mix_out0_reg = LP5036_OUT0_CLR, + .bank_brt_reg = LP5036_BNK_BRT, + .bank_mix_reg = LP5036_BNKA_CLR, + .reset_reg = LP5036_RESET, + .lp50xx_regmap_config = lp5036_regmap_config, + }, + [LP5036] = { + .num_leds = LP5036_MAX_LED_MODULES, + .led_brightness0_reg = LP5036_LED0_BRT, + .mix_out0_reg = LP5036_OUT0_CLR, + .bank_brt_reg = LP5036_BNK_BRT, + .bank_mix_reg = LP5036_BNKA_CLR, + .reset_reg = LP5036_RESET, + .lp50xx_regmap_config = lp5036_regmap_config, + }, +}; + +static struct lp50xx_led *mcled_cdev_to_led(struct led_classdev_mc *mcled_cdev) +{ + return container_of(mcled_cdev, struct lp50xx_led, mc_cdev); +} + +static int lp50xx_brightness_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct lp50xx_led *led = container_of(cdev, struct lp50xx_led, led_dev); + int ret = 0; + u8 reg_val; + + mutex_lock(&led->priv->lock); + + if (led->ctrl_bank_enabled) + reg_val = led->priv->chip_info->bank_brt_reg; + else + reg_val = led->priv->chip_info->led_brightness0_reg + + led->led_number; + + ret = regmap_write(led->priv->regmap, reg_val, brightness); + + mutex_unlock(&led->priv->lock); + + return ret; +} + +static enum led_brightness lp50xx_brightness_get(struct led_classdev *cdev) +{ + struct lp50xx_led *led = container_of(cdev, struct lp50xx_led, led_dev); + unsigned int brt_val; + u8 reg_val; + int ret; + + mutex_lock(&led->priv->lock); + + if (led->ctrl_bank_enabled) + reg_val = led->priv->chip_info->bank_brt_reg; + else + reg_val = led->priv->chip_info->led_brightness0_reg + led->led_number; + + ret = regmap_read(led->priv->regmap, reg_val, &brt_val); + + mutex_unlock(&led->priv->lock); + + return brt_val; +} + +static int lp50xx_get_color(struct led_classdev_mc *mcled_cdev, int color) +{ + struct lp50xx_led *led = mcled_cdev_to_led(mcled_cdev); + struct lp50xx *priv = led->priv; + u8 led_offset, reg_number, reg_color_off; + unsigned int value; + int ret; + + if (color == LED_COLOR_ID_RED) + reg_color_off = 0; + else if (color == LED_COLOR_ID_GREEN) + reg_color_off = 1; + else if (color == LED_COLOR_ID_BLUE) + reg_color_off = 2; + else + goto out; + + if (led->ctrl_bank_enabled) { + reg_number = priv->chip_info->bank_mix_reg + reg_color_off; + } else { + led_offset = (led->led_number * 3) + reg_color_off; + reg_number = priv->chip_info->mix_out0_reg + led_offset; + } + + ret = regmap_read(led->priv->regmap, reg_number, &value); + if (ret) { + dev_err(&priv->client->dev, "Cannot write LED value\n"); + goto out; + } +out: + return value; +} + +static int lp50xx_set_color(struct led_classdev_mc *mcled_cdev, + int color, int value) +{ + struct lp50xx_led *led = mcled_cdev_to_led(mcled_cdev); + struct lp50xx *priv = led->priv; + u8 led_offset, reg_number, reg_color_off; + int ret = -EINVAL; + + if (color == LED_COLOR_ID_RED) + reg_color_off = 0; + else if (color == LED_COLOR_ID_GREEN) + reg_color_off = 1; + else if (color == LED_COLOR_ID_BLUE) + reg_color_off = 2; + else + goto out; + + if (led->ctrl_bank_enabled) { + reg_number = priv->chip_info->bank_mix_reg + reg_color_off; + } else { + led_offset = (led->led_number * 3) + reg_color_off; + reg_number = priv->chip_info->mix_out0_reg + led_offset; + } + + ret = regmap_write(priv->regmap, reg_number, value); + if (ret) { + dev_err(&priv->client->dev, "Cannot write LED value\n"); + goto out; + } +out: + return ret; +} + +static struct led_multicolor_ops lp50xx_mc_ops = { + .set_color_brightness = lp50xx_set_color, + .get_color_brightness = lp50xx_get_color, +}; + +static int lp50xx_set_banks(struct lp50xx *priv, u32 led_strings[]) +{ + u8 led_ctrl_enable = 0; + u8 led1_ctrl_enable = 0; + u8 ctrl_ext = 0; + int ret; + int j; + + for (j = 0; j <= priv->chip_info->num_leds - 1; j++) { + if (led_strings[j] > (LP5024_MAX_LED_MODULES - 1)) { + ctrl_ext = led_strings[j] - LP5024_MAX_LED_MODULES; + led1_ctrl_enable |= (1 << ctrl_ext); + } else { + led_ctrl_enable |= (1 << led_strings[j]); + } + } + + ret = regmap_write(priv->regmap, LP50XX_LED_CFG0, led_ctrl_enable); + + if (led1_ctrl_enable) + ret = regmap_write(priv->regmap, LP5036_LED_CFG1, + led1_ctrl_enable); + + return ret; +} + +static int lp50xx_reset(struct lp50xx *priv) +{ + if (priv->enable_gpio) + return gpiod_direction_output(priv->enable_gpio, 1); + else + return regmap_write(priv->regmap, priv->chip_info->reset_reg, + LP50XX_SW_RESET); +} + +static int lp50xx_enable_disable(struct lp50xx *priv, u8 enable_disable) +{ + return regmap_write(priv->regmap, LP50XX_DEV_CFG0, enable_disable); +} + +static int lp50xx_probe_dt(struct lp50xx *priv) +{ + u32 led_strings[LP5036_MAX_LED_MODULES]; + struct fwnode_handle *child = NULL; + struct fwnode_handle *led_node = NULL; + struct led_init_data init_data; + struct lp50xx_led *led; + int num_colors; + u32 color_id; + int led_number; + 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->client->dev, child) { + led = &priv->leds[i]; + if (fwnode_property_present(child, "ti,led-bank")) { + ret = fwnode_property_read_u32_array(child, + "ti,led-bank", + NULL, 0); + ret = fwnode_property_read_u32_array(child, + "ti,led-bank", + led_strings, + ret); + + priv->num_of_banked_leds = ARRAY_SIZE(led_strings); + + ret = lp50xx_set_banks(priv, led_strings); + if (ret) { + dev_err(&priv->client->dev, + "Cannot setup banked LEDs\n"); + fwnode_handle_put(child); + goto child_out; + } + led->ctrl_bank_enabled = 1; + + } else { + ret = fwnode_property_read_u32(child, "reg", + &led_number); + + led->led_number = led_number; + } + if (ret) { + dev_err(&priv->client->dev, + "led sourcing property missing\n"); + fwnode_handle_put(child); + goto child_out; + } + + if (led_number > priv->chip_info->num_leds) { + dev_err(&priv->client->dev, + "led-sources property is invalid\n"); + ret = -EINVAL; + fwnode_handle_put(child); + goto child_out; + } + + init_data.fwnode = child; + init_data.devicename = priv->client->name; + init_data.default_label = ":"; + + fwnode_property_read_string(child, "linux,default-trigger", + &led->led_dev.default_trigger); + num_colors = 0; + + fwnode_for_each_child_node(child, led_node) { + ret = fwnode_property_read_u32(led_node, "color", + &color_id); + if (ret) + dev_err(&priv->client->dev, + "Cannot read color\n"); + + set_bit(color_id, &led->mc_cdev.available_colors); + num_colors++; + + } + + led->priv = priv; + led->mc_cdev.ops = &lp50xx_mc_ops; + led->mc_cdev.num_leds = num_colors; + led->mc_cdev.led_cdev = &led->led_dev; + led->led_dev.brightness_set_blocking = lp50xx_brightness_set; + led->led_dev.brightness_get = lp50xx_brightness_get; + ret = led_classdev_multicolor_register_ext(&priv->client->dev, + &led->mc_cdev, + &init_data); + 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 lp50xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct lp50xx *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); + led->client = client; + led->dev = &client->dev; + led->chip_info = &lp50xx_chip_info_tbl[id->driver_data]; + i2c_set_clientdata(client, led); + + led->regmap = devm_regmap_init_i2c(client, + &led->chip_info->lp50xx_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 = lp50xx_reset(led); + if (ret) + return ret; + + ret = lp50xx_probe_dt(led); + if (ret) + return ret; + + return lp50xx_enable_disable(led, LP50XX_CHIP_EN); +} + +static int lp50xx_remove(struct i2c_client *client) +{ + struct lp50xx *led = i2c_get_clientdata(client); + int ret; + + ret = lp50xx_enable_disable(led, LP50XX_CHIP_EN); + if (ret) { + dev_err(&led->client->dev, "Failed to disable regulator\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 lp50xx_id[] = { + { "lp5009", LP5009 }, + { "lp5012", LP5012 }, + { "lp5018", LP5018 }, + { "lp5024", LP5024 }, + { "lp5030", LP5030 }, + { "lp5036", LP5036 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, lp50xx_id); + +static const struct of_device_id of_lp50xx_leds_match[] = { + { .compatible = "ti,lp5009", .data = (void *)LP5009 }, + { .compatible = "ti,lp5012", .data = (void *)LP5012 }, + { .compatible = "ti,lp5018", .data = (void *)LP5018 }, + { .compatible = "ti,lp5024", .data = (void *)LP5024 }, + { .compatible = "ti,lp5030", .data = (void *)LP5030 }, + { .compatible = "ti,lp5036", .data = (void *)LP5036 }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_lp50xx_leds_match); + +static struct i2c_driver lp50xx_driver = { + .driver = { + .name = "lp50xx", + .of_match_table = of_lp50xx_leds_match, + }, + .probe = lp50xx_probe, + .remove = lp50xx_remove, + .id_table = lp50xx_id, +}; +module_i2c_driver(lp50xx_driver); + +MODULE_DESCRIPTION("Texas Instruments LP50XX LED driver"); +MODULE_AUTHOR("Dan Murphy "); +MODULE_LICENSE("GPL v2"); From patchwork Wed Sep 11 18:01:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 173627 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1102162oce; Wed, 11 Sep 2019 11:01:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXqq4dF50ccqzzDUpPsSmMWw26dlv13BYgURXHFdqWY8OwZ1Eh3+y7Gnrq2FSzvwikPHQw X-Received: by 2002:aa7:d40c:: with SMTP id z12mr37954410edq.30.1568224889106; Wed, 11 Sep 2019 11:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568224889; cv=none; d=google.com; s=arc-20160816; b=UqeJEF4ppL6GCGIp97qsZD/iY/XpzvQ4Hw03E2qJIumdNUEuwkpdEXxuH8MDZTTKdQ hZYCBqGrj7O74nHaIWBu51PCQxivMqcLMP2QfoAiLfIopmcDJu5f9JdiuPtfSbFNj+xT YvUz3eHCAPzs7XD88sE+IPdHa3KigqTox+CtjlBKlZWojGEegkLvESXE0QL6T+sd2ayX xDyEkvh+A/RHDvOnKvmyds0e2Y2gLrC2nT/J2EHrO4QL4izCZt3ehhGp6JnTwEO9Xsjn dOO8GlEXygeXQ7tw5VAIORfYxjDYQIJW4Ngpp76lPMM34UV9Pe2MzGcd56vo0Nr5jxQ0 05Aw== 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=coD1uOdxeWd8XAcB+R0bOihiQUQwg0Kf1020vJsHpZg=; b=IxBmp8q9rhRO4DCht8SXWIWxebWn/ajGP2kTP6yOceA/t/Dhd54Qmw0kEGeA+1Vxfq bcAwyhOF6ARf7j5IobFo5T6NeCIiJmIoN+6f0JlztpTfEJkptk3c+8Lz7ZaxYYt+Bzl8 MA3U0DngFw2C0D06S34bx80ultlGqGQk8AYecZNLM3t/cCg4fbRAgwsNo2r9nrUevGpK Kafa5aSGC8LcZswqr082v/rIWTmE26YTZmpyIE6oWfEp7XSqhamML6tFE8/MU/Bz9n+A +qZzJ8myXK/fbjOM90wKCHZfpXgJwnO9Ooe9eLX2qktnO2X/YbL1Zma1if4dgyOdXmYg GFng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="t/vtKpft"; 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 gy24si11079999ejb.166.2019.09.11.11.01.28; Wed, 11 Sep 2019 11:01:29 -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="t/vtKpft"; 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 S1729911AbfIKSB0 (ORCPT + 27 others); Wed, 11 Sep 2019 14:01:26 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:36758 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729794AbfIKSBY (ORCPT ); Wed, 11 Sep 2019 14:01:24 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8BI1JHT040469; Wed, 11 Sep 2019 13:01:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568224879; bh=coD1uOdxeWd8XAcB+R0bOihiQUQwg0Kf1020vJsHpZg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=t/vtKpftOUya76eG8Tur4ApoLK6nFIe9b8k+kx8k+oAG/+K1ltw70M02/KgVGMIdU c1tm7itEAgffKREwNVvEPZBScHhsMMfvUzLC7A/yfZSEJ/Pf+buSElqJLD/jJJa16u MaAadTjK6FuSvTPCM9jV0PvjRFeWdPS/xJEntp2w= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8BI1Jvf043774 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Sep 2019 13:01:19 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) 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.1713.5; Wed, 11 Sep 2019 13:01:18 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE108.ent.ti.com (10.64.6.29) 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; Wed, 11 Sep 2019 13:01:18 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8BI1IjE011148; Wed, 11 Sep 2019 13:01:18 -0500 From: Dan Murphy To: , CC: , , , Dan Murphy Subject: [PATCH v5 9/9] leds: Update the lp55xx to use the multi color framework Date: Wed, 11 Sep 2019 13:01:15 -0500 Message-ID: <20190911180115.21035-10-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190911180115.21035-1-dmurphy@ti.com> References: <20190911180115.21035-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 Update the lp5523 to use the multi color framework. Signed-off-by: Dan Murphy --- drivers/leds/leds-lp5523.c | 13 +++ drivers/leds/leds-lp55xx-common.c | 131 ++++++++++++++++++---- drivers/leds/leds-lp55xx-common.h | 9 ++ include/linux/platform_data/leds-lp55xx.h | 6 + modules.builtin.modinfo | Bin 0 -> 43550 bytes 5 files changed, 137 insertions(+), 22 deletions(-) create mode 100644 modules.builtin.modinfo diff --git a/modules.builtin.modinfo b/modules.builtin.modinfo new file mode 100644 index 0000000000000000000000000000000000000000..e528d8f57796621b6cfef52ad0da44551a482481 GIT binary patch literal 43550 zcmcJ2?Q+|=(x(2ta}}twKjNIV|YGNXqfd?pCE75g*+RpaC?x8;w!ycl>2BO|zrh@WId3MUofUG7gi1 zeg~})3e2M*O!DyPegBfbM`0dh(V~dbwg7R&B1P3KKT7wLVNdEs~*1raD&TW%EP{%{_8 z$ujnJp?sMy!eqo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H0BqhF)jJXj@d#^n7B;m4gm8iS8V9FF@il|M@pdYg1~?n2a*RUlWr^8%qGA! z0EFaWoW&mTi?dF0Drtb$tdj@29+!}74Gc}z7sD>CEl!h#qQ%`o1uoWGO5_y>t5k}X zjBUh-i~ijKMR&q@=-^wFSw?igBw%q0ZP7;~+71jT?#>b%wYJPUGNDR5N-1NrFsh#c zbZRyNb>V4S9Te?QHNaqvYy0?@bI^HfJ%nIcQpQ9Z9L&X>Q|mvu12EaVf#EhRErM_* zr|H9XC=J;x{XJq6Y`vrO2b9+>sK8bO0fDrQgl&uK zJnZ8L&UKki%#ufsNU*(nqxv|@_P46lXzoIWYpPmF zURzzDcrI1~jj3=)k2-YePmPoq?o>ekweiwM0jq@xPAv&-?7VtPGk=BfGN1({W#-0c3dAJu4;QdEO0l@z1IR+A>JDoMP))W~AJPPOQfrW_nXY=VNFuyT2qw6y*YD|Q#s literal 0 HcmV?d00001 -- 2.22.0.214.g8dca754b1e diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index d0b931a136b9..8b2cdb98fed6 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -791,6 +791,18 @@ static ssize_t store_master_fader_leds(struct device *dev, return ret; } +static int lp5523_led_intensity(struct lp55xx_led *led, int chan_num) +{ + struct lp55xx_chip *chip = led->chip; + int ret; + + mutex_lock(&chip->lock); + ret = lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + chan_num, + led->brightness); + mutex_unlock(&chip->lock); + return ret; +} + static int lp5523_led_brightness(struct lp55xx_led *led) { struct lp55xx_chip *chip = led->chip; @@ -857,6 +869,7 @@ static struct lp55xx_device_config lp5523_cfg = { .max_channel = LP5523_MAX_LEDS, .post_init_device = lp5523_post_init_device, .brightness_fn = lp5523_led_brightness, + .color_intensity_fn = lp5523_led_intensity, .set_led_current = lp5523_set_led_current, .firmware_cb = lp5523_firmware_loaded, .run_engine = lp5523_run_engine, diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 44ced02b49f9..8408d625f8da 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -136,9 +136,26 @@ static int lp55xx_set_brightness(struct led_classdev *cdev, { struct lp55xx_led *led = cdev_to_lp55xx_led(cdev); struct lp55xx_device_config *cfg = led->chip->cfg; + int adj_value[LED_COLOR_ID_MAX]; + int ret; + int i; + + if (led->mc_cdev.num_leds > 1) { + led_mc_set_cluster_brightness(&led->mc_cdev, + brightness, adj_value); + for (i = 0; i < led->mc_cdev.num_leds; i++) { + led->brightness = adj_value[i]; + ret = cfg->color_intensity_fn(led, + led->grouped_channels[i]); + if (ret) + break; + } + } else { + led->brightness = (u8)brightness; + ret = cfg->brightness_fn(led); + } - led->brightness = (u8)brightness; - return cfg->brightness_fn(led); + return ret; } static int lp55xx_init_led(struct lp55xx_led *led, @@ -147,9 +164,9 @@ static int lp55xx_init_led(struct lp55xx_led *led, struct lp55xx_platform_data *pdata = chip->pdata; struct lp55xx_device_config *cfg = chip->cfg; struct device *dev = &chip->cl->dev; + int max_channel = cfg->max_channel; char name[32]; int ret; - int max_channel = cfg->max_channel; if (chan >= max_channel) { dev_err(dev, "invalid channel: %d / %d\n", chan, max_channel); @@ -159,10 +176,35 @@ static int lp55xx_init_led(struct lp55xx_led *led, if (pdata->led_config[chan].led_current == 0) return 0; + if (pdata->led_config[chan].name) { + led->cdev.name = pdata->led_config[chan].name; + } else { + snprintf(name, sizeof(name), "%s:channel%d", + pdata->label ? : chip->cl->name, chan); + led->cdev.name = name; + } + + if (pdata->led_config[chan].num_colors > 1) { + led->mc_cdev.led_cdev = &led->cdev; + led->cdev.brightness_set_blocking = lp55xx_set_brightness; + led->cdev.groups = lp55xx_led_groups; + led->mc_cdev.num_leds = pdata->led_config[chan].num_colors; + led->mc_cdev.available_colors = pdata->led_config[chan].available_colors; + memcpy(led->channel_color, + pdata->led_config[chan].channel_color, + sizeof(led->channel_color)); + memcpy(led->grouped_channels, + pdata->led_config[chan].grouped_channels, + sizeof(led->grouped_channels)); + } else { + + led->cdev.default_trigger = pdata->led_config[chan].default_trigger; + led->cdev.brightness_set_blocking = lp55xx_set_brightness; + } led->cdev.groups = lp55xx_led_groups; + led->led_current = pdata->led_config[chan].led_current; led->max_current = pdata->led_config[chan].max_current; led->chan_nr = pdata->led_config[chan].chan_nr; - led->cdev.default_trigger = pdata->led_config[chan].default_trigger; if (led->chan_nr >= max_channel) { dev_err(dev, "Use channel numbers between 0 and %d\n", @@ -170,18 +212,11 @@ static int lp55xx_init_led(struct lp55xx_led *led, return -EINVAL; } - led->cdev.brightness_set_blocking = lp55xx_set_brightness; - led->cdev.groups = lp55xx_led_groups; + if (pdata->led_config[chan].num_colors > 1) + ret = led_classdev_multicolor_register(dev, &led->mc_cdev); + else + ret = led_classdev_register(dev, &led->cdev); - if (pdata->led_config[chan].name) { - led->cdev.name = pdata->led_config[chan].name; - } else { - snprintf(name, sizeof(name), "%s:channel%d", - pdata->label ? : chip->cl->name, chan); - led->cdev.name = name; - } - - ret = led_classdev_register(dev, &led->cdev); if (ret) { dev_err(dev, "led register err: %d\n", ret); return ret; @@ -466,7 +501,6 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) dev_err(&chip->cl->dev, "empty brightness configuration\n"); return -EINVAL; } - for (i = 0; i < num_channels; i++) { /* do not initialize channels that are not connected */ @@ -538,6 +572,38 @@ void lp55xx_unregister_sysfs(struct lp55xx_chip *chip) } EXPORT_SYMBOL_GPL(lp55xx_unregister_sysfs); +static int lp5xx_parse_channel_child(struct device_node *np, + struct lp55xx_led_config *cfg, + int chan_num) +{ + struct device_node *child; + int num_colors = 0; + u32 color_id; + u32 led_number; + int ret; + + cfg[chan_num].default_trigger = + of_get_property(np, "linux,default-trigger", NULL); + + for_each_child_of_node(np, child) { + of_property_read_string(child, "chan-name", + &cfg[chan_num].name); + of_property_read_u8(child, "led-cur", + &cfg[chan_num].led_current); + of_property_read_u8(child, "max-cur", + &cfg[chan_num].max_current); + of_property_read_u32(child, "color", &color_id); + cfg[chan_num].channel_color[num_colors] = color_id; + set_bit(color_id, &cfg[chan_num].available_colors); + ret = of_property_read_u32(child, "reg", &led_number); + cfg[chan_num].grouped_channels[num_colors] = led_number; + num_colors++; + } + cfg[chan_num].num_colors = num_colors; + + return 0; +} + struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, struct device_node *np) { @@ -545,7 +611,10 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, struct lp55xx_platform_data *pdata; struct lp55xx_led_config *cfg; int num_channels; + int channel_color; + u32 led_number; int i = 0; + int ret; pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) @@ -565,13 +634,31 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, pdata->num_channels = num_channels; for_each_child_of_node(np, child) { - cfg[i].chan_nr = i; + ret = of_property_read_u32(child, "color", &channel_color); + if (ret) { + dev_err(dev,"Missing color property setting white\n"); + channel_color = LED_COLOR_ID_WHITE; + } - of_property_read_string(child, "chan-name", &cfg[i].name); - of_property_read_u8(child, "led-cur", &cfg[i].led_current); - of_property_read_u8(child, "max-cur", &cfg[i].max_current); - cfg[i].default_trigger = - of_get_property(child, "linux,default-trigger", NULL); + if (channel_color == LED_COLOR_ID_MULTI) + lp5xx_parse_channel_child(child, cfg, i); + else { + of_property_read_string(child, "chan-name", + &cfg[i].name); + of_property_read_u8(child, "led-cur", + &cfg[i].led_current); + of_property_read_u8(child, "max-cur", + &cfg[i].max_current); + cfg[i].default_trigger = + of_get_property(child, "linux,default-trigger", + NULL); + of_property_read_u32(child, "reg", &led_number); + + if (led_number < 0 || led_number > 6) + return ERR_PTR(EINVAL); + + cfg[i].chan_nr = led_number; + } i++; } diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h index 783ed5103ce5..d9c114259dcb 100644 --- a/drivers/leds/leds-lp55xx-common.h +++ b/drivers/leds/leds-lp55xx-common.h @@ -12,6 +12,8 @@ #ifndef _LEDS_LP55XX_COMMON_H #define _LEDS_LP55XX_COMMON_H +#include + enum lp55xx_engine_index { LP55XX_ENGINE_INVALID, LP55XX_ENGINE_1, @@ -109,6 +111,9 @@ struct lp55xx_device_config { /* access brightness register */ int (*brightness_fn)(struct lp55xx_led *led); + /* access specific brightness register */ + int (*color_intensity_fn)(struct lp55xx_led *led, int chan_num); + /* current setting function */ void (*set_led_current) (struct lp55xx_led *led, u8 led_current); @@ -159,6 +164,7 @@ struct lp55xx_chip { * struct lp55xx_led * @chan_nr : Channel number * @cdev : LED class device + * @mc_cdev : Multi color class device * @led_current : Current setting at each led channel * @max_current : Maximun current at each led channel * @brightness : Brightness value @@ -167,9 +173,12 @@ struct lp55xx_chip { struct lp55xx_led { int chan_nr; struct led_classdev cdev; + struct led_classdev_mc mc_cdev; u8 led_current; u8 max_current; u8 brightness; + int channel_color[LED_COLOR_ID_MAX]; + int grouped_channels[LED_COLOR_ID_MAX]; struct lp55xx_chip *chip; }; diff --git a/include/linux/platform_data/leds-lp55xx.h b/include/linux/platform_data/leds-lp55xx.h index 96a787100fda..0ac29f537ab6 100644 --- a/include/linux/platform_data/leds-lp55xx.h +++ b/include/linux/platform_data/leds-lp55xx.h @@ -12,6 +12,8 @@ #ifndef _LEDS_LP55XX_H #define _LEDS_LP55XX_H +#include + /* Clock configuration */ #define LP55XX_CLOCK_AUTO 0 #define LP55XX_CLOCK_INT 1 @@ -23,6 +25,10 @@ struct lp55xx_led_config { u8 chan_nr; u8 led_current; /* mA x10, 0 if led is not connected */ u8 max_current; + int num_colors; + unsigned long available_colors; + u32 channel_color[LED_COLOR_ID_MAX]; + int grouped_channels[LED_COLOR_ID_MAX]; }; struct lp55xx_predef_pattern {