From patchwork Mon May 6 19:16:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 163450 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp359908ilm; Mon, 6 May 2019 12:16:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLPV420S+i5fl3w0vDJYDeGlriECbhhs8W66QkSEiET2oIyLgAo/JCRUaaTnzWoA/UUmgO X-Received: by 2002:a63:3d0b:: with SMTP id k11mr13993400pga.349.1557170186624; Mon, 06 May 2019 12:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557170186; cv=none; d=google.com; s=arc-20160816; b=AFB0Ab6zjqpBHelNFKalq98R2/SdTBdAbVTFGGtf2aw9mW/x1KlwjUXhWoypVbXR2W 6EiYT7/qTQl1+yWYp4dlvqRO4eRU2WhXWoi/K/xy0vFFt4qdfF8OrTdz51BXFGnUxWI8 8BtzOtbMJjFb4EM5Z61vjx2x7BZF8gUAglzSbGrkTAR9Rm/cFdfQF52zxr1TLIBoI8j9 VQ3/GmnniSr0WtAK6iaV5qCE/J+3RV7+yFmxWdymd7Za8ORgDYi08cCh9uirZfK6cs4l CVo4P44geBfvtApKrT96X81UarOdBmjUHbOd7XtRBt1wZyaVsjwGaM238mURVHRGUjUA ON6w== 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=Zu+lGjPwb6boNQ4Zw8fC+i/x30a+FXOodEjX1XT5Cuo=; b=mFfMMhbnoELG4bH5o3IPpvh7V5RQVFSqAlYjwJUNBlTYr/rs9N4amhk0nGgYd5sLYC E1JV18lm0hYB9wNwe7Z963J8nQYZLh0eEaxsifMJOWbgEspkK78kTOQ2Q7dSZ2nfy6db 0gYS8w+o/sZwUD3Mo9RHT0vSQmQGcrmDs2SB7lbdMYkm4DJqkfOxQfENLQ5aYHLSm4/b wTzs4OjXo6oZWNLhb0TkgsY31DK5Xzsu468x2TgY9obkuVN9rsxkX+mkqbwYZzQEm9SC H8Grx33s7DXQvjQQJahKDKbVbXkdlg9DJkRTmVS4ViivisGYqHtG+w/E1YmMFmnrB1G4 wwUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="WE/hjPxz"; 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 y12si16010335pfe.99.2019.05.06.12.16.26; Mon, 06 May 2019 12:16:26 -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="WE/hjPxz"; 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 S1726448AbfEFTQY (ORCPT + 30 others); Mon, 6 May 2019 15:16:24 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:44440 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfEFTQX (ORCPT ); Mon, 6 May 2019 15:16:23 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x46JG9Aj115527; Mon, 6 May 2019 14:16:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1557170169; bh=Zu+lGjPwb6boNQ4Zw8fC+i/x30a+FXOodEjX1XT5Cuo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=WE/hjPxzaxGJ9L6p9ZMbL/WM0Qza8R8W3tk1/iM3vFkePtHOnT0uNc2zJFTNJZ3BL FsUKxHoZOxFZhV1Ec/N+1bb7cA8b4v98i1OwEzztlnwC0JkAxK6gKckMuxYRb8V0QS hdXwKCqX/i1Ms01K+r7Ev9NPO2p+/aZKtIkcREUk= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x46JG9gO074949 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 6 May 2019 14:16:09 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 6 May 2019 14:16:08 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE110.ent.ti.com (157.170.170.21) 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; Mon, 6 May 2019 14:16:08 -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 x46JG8KT077954; Mon, 6 May 2019 14:16:08 -0500 From: Dan Murphy To: , CC: , , , , Dan Murphy , Rob Herring Subject: [PATCH v4 1/7] dt-bindings: mfd: LMU: Fix lm3632 dt binding example Date: Mon, 6 May 2019 14:16:08 -0500 Message-ID: <20190506191614.25051-2-dmurphy@ti.com> X-Mailer: git-send-email 2.21.0.5.gaeb582a983 In-Reply-To: <20190506191614.25051-1-dmurphy@ti.com> References: <20190506191614.25051-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 lm3632 dt binding examples as the LCM enable GPIOs are defined as enable GPIOs per the regulator/lm363x-regulator.txt bindings document. Reviewed-by: Rob Herring Signed-off-by: Dan Murphy --- v4 - No changes - https://lore.kernel.org/patchwork/patch/1068613/ v3 - No changes added Reviewed-by Rob - https://lore.kernel.org/patchwork/patch/1058757/ v2 - There was no v2 I add this patch on top of this series Documentation/devicetree/bindings/mfd/ti-lmu.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.21.0.5.gaeb582a983 diff --git a/Documentation/devicetree/bindings/mfd/ti-lmu.txt b/Documentation/devicetree/bindings/mfd/ti-lmu.txt index 980394d701a7..86ca786d54fc 100644 --- a/Documentation/devicetree/bindings/mfd/ti-lmu.txt +++ b/Documentation/devicetree/bindings/mfd/ti-lmu.txt @@ -104,8 +104,8 @@ lm3632@11 { regulators { compatible = "ti,lm363x-regulator"; - ti,lcm-en1-gpio = <&pioC 0 GPIO_ACTIVE_HIGH>; /* PC0 */ - ti,lcm-en2-gpio = <&pioC 1 GPIO_ACTIVE_HIGH>; /* PC1 */ + enable-gpios = <&pioC 0 GPIO_ACTIVE_HIGH>, + <&pioC 1 GPIO_ACTIVE_HIGH>; vboost { regulator-name = "lcd_boost"; From patchwork Mon May 6 19:16: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: 163456 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp360294ilm; Mon, 6 May 2019 12:16:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7LCaBM+n3F9jDlv3LK9DxxGEo+UjXdUik4kDzaM9tTwUD22j0aiT47TA2HnpdY1i2G29c X-Received: by 2002:a17:902:2bc5:: with SMTP id l63mr35545627plb.202.1557170209567; Mon, 06 May 2019 12:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557170209; cv=none; d=google.com; s=arc-20160816; b=HxfApDbWzhD2g9U9lGidcERw6w6/5zCvwDQQYIgYZqsn3G3moPXHY/dvzBNOouibOr SC4v2yaaWTPDXdicQg+xGTv4djj02ATdrVm/xTSZqz7iq9cmt7QAz/GG0ituGPgmTcVN DhfFMb7wCB/Y6m+iDfCNwenY5QzUGRZQN9Zzs3LTRiVTBoVZeiDhpb+om3D/HMZ7U+1w JorHgr1vUhcotLHl9QipwlfDQTqvwDMfvL8E/GmiBH9rsuHp/M4np7m/wSi7qCTkxFJw jScDTuLXew6QSK4NvK+NvOcIIbAskgJYz12oXmg5MNQ8QHQTdekNc0wENiRT8XWZUOaI +YFQ== 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=joTM0whnuH7gzNMVxKwNKb5uWvtOKPDEYbO5LEo4NSk=; b=D3qL7KTjYvzOog7CUjI94HC8X33xqWIE7tzHwCY7Kpptj6odKQligstqWJHQjH97Mj qDLYi9BrmhOTgg5wXNzbcmrWyvpMsyTV1QxvN5cwFs5zJJ1IVNhpRxiZ1arykOg7U4XG NSTtU5Vyd/17/DIyLRJ3/acOZaqSLy+WWls1h6Hiqpa3hg37o5xDfVtil+UxPBCyNcOM 6zCrOmEwzqMpd09YnXzFl4lGUAbuxnlJe33cK/M0GSIuvrdeeaoejSJF0O6KQgR9Fvn+ 6bLxFVnEJ5VYhVN3RzOftx6gOYUnG5dEIgRL9BzztDfm1ee14sfMns0oWgOdcDhwTQB6 oJog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="t/dWa0Bk"; 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 t22si8651647pgg.292.2019.05.06.12.16.49; Mon, 06 May 2019 12:16: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="t/dWa0Bk"; 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 S1726862AbfEFTQn (ORCPT + 30 others); Mon, 6 May 2019 15:16:43 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:45158 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbfEFTQ2 (ORCPT ); Mon, 6 May 2019 15:16:28 -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 x46JGA2x023390; Mon, 6 May 2019 14:16:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1557170170; bh=joTM0whnuH7gzNMVxKwNKb5uWvtOKPDEYbO5LEo4NSk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=t/dWa0Bk6US1ij7V3cifsFKehN1cHVqXPL7VvWhWEpBNWonQsMXJR5GSZDSEyDmcp tDhk52LOh2b/4SBJUdWsAx/Dffg8tBwKIBAMGRIzZIp1YLat4pk8FmXdpsMeLgLEr2 gG3pqQ5RW6txLqqFLJP2U738HXvSs8XdMChF63Wk= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x46JGAbN092534 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 6 May 2019 14:16:10 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 6 May 2019 14:16:09 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE105.ent.ti.com (157.170.170.35) 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; Mon, 6 May 2019 14:16:08 -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 x46JG92c009526; Mon, 6 May 2019 14:16:09 -0500 From: Dan Murphy To: , CC: , , , , Dan Murphy , Rob Herring Subject: [PATCH v4 3/7] dt-bindings: mfd: LMU: Add ti,brightness-resolution Date: Mon, 6 May 2019 14:16:10 -0500 Message-ID: <20190506191614.25051-4-dmurphy@ti.com> X-Mailer: git-send-email 2.21.0.5.gaeb582a983 In-Reply-To: <20190506191614.25051-1-dmurphy@ti.com> References: <20190506191614.25051-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 ti,brightness-resolution to the TI LMU binding to define whether the device uses 8-bit brightness or 11-bit brightness. Reviewed-by: Rob Herring Signed-off-by: Dan Murphy --- v4 - No changes - https://lore.kernel.org/patchwork/patch/1068617/ v3 - No changes added Reviewed-by Rob - https://lore.kernel.org/patchwork/patch/1058763/ v2 - New patch. Add brightness resolution to ti-lmu.txt. See patch comments for context. - https://lore.kernel.org/patchwork/patch/1054501/ Documentation/devicetree/bindings/mfd/ti-lmu.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.21.0.5.gaeb582a983 diff --git a/Documentation/devicetree/bindings/mfd/ti-lmu.txt b/Documentation/devicetree/bindings/mfd/ti-lmu.txt index 160eb0a5e21a..e3efefb194c5 100644 --- a/Documentation/devicetree/bindings/mfd/ti-lmu.txt +++ b/Documentation/devicetree/bindings/mfd/ti-lmu.txt @@ -31,6 +31,16 @@ Optional properties: - ramp-down-us: Current ramping from one brightness level to the a lower brightness level. Range from 2048 us - 117.44 s + - ti,brightness-resolution - This determines whether to use 8 bit brightness + mode or 11 bit brightness mode. If this value is + not set the device is defaulted to the preferred + 8bit brightness mode per 7.3.4.1 of the data + sheet. This setting can either be in the parent + node or as part of the LED child nodes. This + is determined by the part itself if the strings + have a common brightness register or individual + brightness registers. + The values are 255 (8bit) or 2047 (11bit). Required node: - backlight: All LMU devices have backlight child nodes. @@ -217,6 +227,7 @@ lm3697@36 { compatible = "ti,lm3697-backlight"; lcd { + ti,brightness-resolution = <255>; led-sources = <0 1 2>; ramp-up-us = <200000>; ramp-down-us = <200000>; From patchwork Mon May 6 19:16: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: 163451 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp359921ilm; Mon, 6 May 2019 12:16:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9p1Z3/JS614OmYPtY3vsSSaYlTPEb6IAawGfUG2xbDwt3RvF8SKMUiPkhf8lf0tsb2iln X-Received: by 2002:a17:902:2827:: with SMTP id e36mr33687023plb.45.1557170187620; Mon, 06 May 2019 12:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557170187; cv=none; d=google.com; s=arc-20160816; b=YXWPpHz0z39VMJ0D39pwSPCjpfqUEmv3+mZdQZ2vOeGLTGGFz7+wiQcVPVnv8BQFJM XbP8oPIft10JmOtx2wPM8k+2iXHCmK2xmJlGCyGXJPAXO/zmQXntdfaJqVKWaLooUj4F ZWPz5/gHNShGkEGk0ngJ1W+q3NUD6/hS4ikvtoJvtS00qC0YeKoN1Bo94TcZs98+E0Sa spx2cF9XTTjwtTug7kWM8k+nnXlzhrZAXxFHegII3i0y0w3sVSS/+Le45Gr5RBi0yvKj f1HF8GI+G/rWbYIuciSivN57gE8jujVLg0pEgobb1Bu5bklNd415mn8Jwnzd5JXgjk/h brGQ== 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=dgf59KHjqBZq69bnFfS77oTJU1t8bIMyVwBjXQ59JHY=; b=N355cv2BYkvXWRYgkaZZ6OqQl7WobQpiBNudeZsPu4fq2obq1vTCNzsyIe801kMxGn dp9/ZtyUBME3PIotZQM9bdvpajEijnYzkCkcKsbI7OgxSs4DQXbJCypBa+u5tFpaDP9k Suw5tPZFcd/e5xHmPcNErVJUWNyjtGZQunEWFsK3jeCJNXQDmI/dSncQ9vwinkp/bt8r rEEIebSbe1LcnxHSh3STgUmYQ4RuUp/0YyoNPfEhj7uyc/eJVTC9F52RzHtJezxJ/H7D w3M8Mjg6uAGl4NQxcalAf4T/6l+dYyTpCEgSROF2L0Fp3c5WjGIgkRy90udDh9mCoErK wz/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Hw3YhKO2; 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 j8si9512944pfh.239.2019.05.06.12.16.27; Mon, 06 May 2019 12:16:27 -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=Hw3YhKO2; 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 S1726554AbfEFTQZ (ORCPT + 30 others); Mon, 6 May 2019 15:16:25 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:60790 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbfEFTQZ (ORCPT ); Mon, 6 May 2019 15:16:25 -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 x46JGALW033105; Mon, 6 May 2019 14:16:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1557170170; bh=dgf59KHjqBZq69bnFfS77oTJU1t8bIMyVwBjXQ59JHY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Hw3YhKO236wD1iGLjA3eHg/3rln3Hr5uYlfpUZoS7/5m3qdF0B14ugcKY1pD6nWHQ +0tt1irf1DRQKdp0o/vJCbt6FzR2sA+P0koAX6vqVowakmiAQNSpfGFHfzlEO461kU FMjBYxCv1zLIzy17N6TpFhSxpl5+y9VI8C3O/7yQ= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x46JGAIa094054 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 6 May 2019 14:16:10 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 6 May 2019 14:16:10 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE101.ent.ti.com (157.170.170.31) 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; Mon, 6 May 2019 14:16:10 -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 x46JG9Fj009549; Mon, 6 May 2019 14:16:10 -0500 From: Dan Murphy To: , CC: , , , , Dan Murphy Subject: [PATCH v4 6/7] mfd: ti-lmu: Remove support for LM3697 Date: Mon, 6 May 2019 14:16:13 -0500 Message-ID: <20190506191614.25051-7-dmurphy@ti.com> X-Mailer: git-send-email 2.21.0.5.gaeb582a983 In-Reply-To: <20190506191614.25051-1-dmurphy@ti.com> References: <20190506191614.25051-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove support for the LM3697 from the ti-lmu driver in favor of a dedicated LED driver. Acked-for-MFD-by: Lee Jones Signed-off-by: Dan Murphy --- v4 - No changes - https://lore.kernel.org/patchwork/patch/1068620/ v3 - No changes - https://lore.kernel.org/patchwork/patch/1058760/ v2 - Fixed commit message LF, removed leds/Kconfig from patch. - https://lore.kernel.org/patchwork/patch/1054502/ drivers/mfd/Kconfig | 2 +- drivers/mfd/ti-lmu.c | 17 ----------- include/linux/mfd/ti-lmu-register.h | 44 ----------------------------- include/linux/mfd/ti-lmu.h | 1 - 4 files changed, 1 insertion(+), 63 deletions(-) -- 2.21.0.5.gaeb582a983 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 26ad6468d13a..fcae244229b3 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1312,7 +1312,7 @@ config MFD_TI_LMU help Say yes here to enable support for TI LMU chips. - TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697. + TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, and LM3695. It consists of backlight, LED and regulator driver. It provides consistent device controls for lighting functions. diff --git a/drivers/mfd/ti-lmu.c b/drivers/mfd/ti-lmu.c index b06cb908d1aa..89b1c5b584af 100644 --- a/drivers/mfd/ti-lmu.c +++ b/drivers/mfd/ti-lmu.c @@ -111,20 +111,6 @@ static const struct mfd_cell lm3695_devices[] = { }, }; -static const struct mfd_cell lm3697_devices[] = { - { - .name = "ti-lmu-backlight", - .id = LM3697, - .of_compatible = "ti,lm3697-backlight", - }, - /* Monitoring driver for open/short circuit detection */ - { - .name = "ti-lmu-fault-monitor", - .id = LM3697, - .of_compatible = "ti,lm3697-fault-monitor", - }, -}; - #define TI_LMU_DATA(chip, max_reg) \ static const struct ti_lmu_data chip##_data = \ { \ @@ -137,7 +123,6 @@ TI_LMU_DATA(lm3631, LM3631_MAX_REG); TI_LMU_DATA(lm3632, LM3632_MAX_REG); TI_LMU_DATA(lm3633, LM3633_MAX_REG); TI_LMU_DATA(lm3695, LM3695_MAX_REG); -TI_LMU_DATA(lm3697, LM3697_MAX_REG); static int ti_lmu_probe(struct i2c_client *cl, const struct i2c_device_id *id) { @@ -206,7 +191,6 @@ static const struct of_device_id ti_lmu_of_match[] = { { .compatible = "ti,lm3632", .data = &lm3632_data }, { .compatible = "ti,lm3633", .data = &lm3633_data }, { .compatible = "ti,lm3695", .data = &lm3695_data }, - { .compatible = "ti,lm3697", .data = &lm3697_data }, { } }; MODULE_DEVICE_TABLE(of, ti_lmu_of_match); @@ -216,7 +200,6 @@ static const struct i2c_device_id ti_lmu_ids[] = { { "lm3632", LM3632 }, { "lm3633", LM3633 }, { "lm3695", LM3695 }, - { "lm3697", LM3697 }, { } }; MODULE_DEVICE_TABLE(i2c, ti_lmu_ids); diff --git a/include/linux/mfd/ti-lmu-register.h b/include/linux/mfd/ti-lmu-register.h index f09510561a55..76998b01764b 100644 --- a/include/linux/mfd/ti-lmu-register.h +++ b/include/linux/mfd/ti-lmu-register.h @@ -189,48 +189,4 @@ #define LM3695_REG_BRT_MSB 0x14 #define LM3695_MAX_REG 0x14 - -/* LM3697 */ -#define LM3697_REG_HVLED_OUTPUT_CFG 0x10 -#define LM3697_HVLED1_CFG_MASK BIT(0) -#define LM3697_HVLED2_CFG_MASK BIT(1) -#define LM3697_HVLED3_CFG_MASK BIT(2) -#define LM3697_HVLED1_CFG_SHIFT 0 -#define LM3697_HVLED2_CFG_SHIFT 1 -#define LM3697_HVLED3_CFG_SHIFT 2 - -#define LM3697_REG_BL0_RAMP 0x11 -#define LM3697_REG_BL1_RAMP 0x12 -#define LM3697_RAMPUP_MASK 0xF0 -#define LM3697_RAMPUP_SHIFT 4 -#define LM3697_RAMPDN_MASK 0x0F -#define LM3697_RAMPDN_SHIFT 0 - -#define LM3697_REG_RAMP_CONF 0x14 -#define LM3697_RAMP_MASK 0x0F -#define LM3697_RAMP_EACH 0x05 - -#define LM3697_REG_PWM_CFG 0x1C -#define LM3697_PWM_A_MASK BIT(0) -#define LM3697_PWM_B_MASK BIT(1) - -#define LM3697_REG_IMAX_A 0x17 -#define LM3697_REG_IMAX_B 0x18 - -#define LM3697_REG_FEEDBACK_ENABLE 0x19 - -#define LM3697_REG_BRT_A_LSB 0x20 -#define LM3697_REG_BRT_A_MSB 0x21 -#define LM3697_REG_BRT_B_LSB 0x22 -#define LM3697_REG_BRT_B_MSB 0x23 - -#define LM3697_REG_ENABLE 0x24 - -#define LM3697_REG_OPEN_FAULT_STATUS 0xB0 - -#define LM3697_REG_SHORT_FAULT_STATUS 0xB2 - -#define LM3697_REG_MONITOR_ENABLE 0xB4 - -#define LM3697_MAX_REG 0xB4 #endif diff --git a/include/linux/mfd/ti-lmu.h b/include/linux/mfd/ti-lmu.h index 7762c1bce55d..54e9d272e81c 100644 --- a/include/linux/mfd/ti-lmu.h +++ b/include/linux/mfd/ti-lmu.h @@ -26,7 +26,6 @@ enum ti_lmu_id { LM3632, LM3633, LM3695, - LM3697, LMU_MAX_ID, }; From patchwork Mon May 6 19:16: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: 163455 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp360235ilm; Mon, 6 May 2019 12:16:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBZSviwRNoroxia2NOG9CYP69vTssewDhlK61JLNFkz82UiUmAiGqReqibdkmA2px+omUj X-Received: by 2002:a62:38cc:: with SMTP id f195mr25100067pfa.15.1557170205404; Mon, 06 May 2019 12:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557170205; cv=none; d=google.com; s=arc-20160816; b=BPMK8dcqA8yXprDluZDZT5EslLIacRfxdw8gqQ1w819CCW60NgJC4MyJDFlVZ1rfJO 08OLD7/xq8Nx6ZTedgraGo/gSnZJVmJ0LI8xioB6N3NWHEUJww9QpWJ+staFpI5VOv1S GQnXMe47d2JHMBhPQ0jsM5h0TRQNmsDXLIshA0j6eO9H2TBqagukly7sF7Bca092eY0l KlCnAdEQjuQszS/2FYf+Vq7+kgL5OWDOxg5sqU9D/qfJOSudKO2pkvtGE/qrhftJfxNp Agzdxodoz6VoY1052Z0CxFK03qLLB9+MZMuSM+CzNozjmxoYEKBeeeKYXd+3+DDQLjDm yUZQ== 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=uXhkk3fR8NBm4kiyeQ7RzvM4oQl2voYg/J34248TiUs=; b=usakjuSgWIIYvtcxoOtckO77hPedD7RGDgp3MMaIbukFiK7LLv+As++SxWcFqJ/K25 cFuFf5o4SWYlPninjsi+9MBn24GuLWOM+kCaHHXDIn0scf4hnR2fHkndSHAtBsY6cM3P GbWcrDMeKQ7q9f1vXESAbDsJnzQu9nEX0nD5AwOtUXZIkoiDYQ+AqkvpTMm2uKkmpvq9 JITKipgtnoNgTHXVvjZWEad5onua/mAPR2o4nAkfxgAw1iOdK6wmbnSLXEB4QFuT1wfY RPFN1EKyTjzLFgmy/TXgTAOz5nkneT+xIzxaM1tU8EV7BqT0zzgXXdXtxuZFfQCY+NPL s8Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=keelLBsb; 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 e17si14691692pgv.422.2019.05.06.12.16.45; Mon, 06 May 2019 12:16:45 -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=keelLBsb; 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 S1726901AbfEFTQo (ORCPT + 30 others); Mon, 6 May 2019 15:16:44 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:52832 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbfEFTQ2 (ORCPT ); Mon, 6 May 2019 15:16:28 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x46JGAwT075445; Mon, 6 May 2019 14:16:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1557170170; bh=uXhkk3fR8NBm4kiyeQ7RzvM4oQl2voYg/J34248TiUs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=keelLBsb2ciAAW1kUYSw78/8wS74kJ55Bo9TYItggsjamfRM9RZH6IeXSN9dqfpzL PFXNmk36kya+GQwirsSxqZ95SX9iebIz+OcAqZv8YLDc68as42tHtIlQ7hcec44PsX a/A8RvcIrEvDLQ3WSxJjl6eZVmttEKRa7oaqevCo= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x46JGApa092542 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 6 May 2019 14:16:10 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) 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; Mon, 6 May 2019 14:16:10 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE104.ent.ti.com (10.64.6.25) 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; Mon, 6 May 2019 14:16:10 -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 x46JGAfn077977; Mon, 6 May 2019 14:16:10 -0500 From: Dan Murphy To: , CC: , , , , Dan Murphy Subject: [PATCH v4 7/7] leds: lm3697: Introduce the lm3697 driver Date: Mon, 6 May 2019 14:16:14 -0500 Message-ID: <20190506191614.25051-8-dmurphy@ti.com> X-Mailer: git-send-email 2.21.0.5.gaeb582a983 In-Reply-To: <20190506191614.25051-1-dmurphy@ti.com> References: <20190506191614.25051-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce the lm3697 LED driver for backlighting and display. Datasheet location: http://www.ti.com/lit/ds/symlink/lm3697.pdf Signed-off-by: Dan Murphy --- v4 - Updated common header name - https://lore.kernel.org/patchwork/patch/1068619/ v3 - Moved TI_COMMON_LMU flag above LM3697 flag for inheritance also fixed removed REGMAP dependency - v1 comments https://lore.kernel.org/patchwork/patch/1054503/ v2 comments https://lore.kernel.org/patchwork/patch/1058761/ v2 - Made changes to get max_brightness from ti_lmu common code, fixed commit message extra LF otherwise no additional changes - https://lore.kernel.org/patchwork/patch/1054503/ drivers/leds/Kconfig | 7 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3697.c | 395 +++++++++++++++++++++++++++++++++++++ 3 files changed, 403 insertions(+) create mode 100644 drivers/leds/leds-lm3697.c -- 2.21.0.5.gaeb582a983 diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index a88dad3be96c..255fdd5e8491 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -784,6 +784,13 @@ config LEDS_TI_LMU_COMMON This supports common features between the TI LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697. +config LEDS_LM3697 + tristate "LED driver for LM3697" + depends on LEDS_TI_LMU_COMMON + help + Say Y to enable the LM3697 LED driver for TI LMU devices. + This supports the LED device LM3697. + comment "LED Triggers" source "drivers/leds/trigger/Kconfig" diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 9d7cdd363603..8ab825c8b5c3 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -81,6 +81,7 @@ obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o obj-$(CONFIG_LEDS_TI_LMU_COMMON) += leds-ti-lmu-common.o +obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o # LED SPI Drivers obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c new file mode 100644 index 000000000000..54e0e35df824 --- /dev/null +++ b/drivers/leds/leds-lm3697.c @@ -0,0 +1,395 @@ +// SPDX-License-Identifier: GPL-2.0 +// TI LM3697 LED chip family driver +// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include +#include +#include +#include +#include + +#define LM3697_REV 0x0 +#define LM3697_RESET 0x1 +#define LM3697_OUTPUT_CONFIG 0x10 +#define LM3697_CTRL_A_RAMP 0x11 +#define LM3697_CTRL_B_RAMP 0x12 +#define LM3697_CTRL_A_B_RT_RAMP 0x13 +#define LM3697_CTRL_A_B_RAMP_CFG 0x14 +#define LM3697_CTRL_A_B_BRT_CFG 0x16 +#define LM3697_CTRL_A_FS_CURR_CFG 0x17 +#define LM3697_CTRL_B_FS_CURR_CFG 0x18 +#define LM3697_PWM_CFG 0x1c +#define LM3697_CTRL_A_BRT_LSB 0x20 +#define LM3697_CTRL_A_BRT_MSB 0x21 +#define LM3697_CTRL_B_BRT_LSB 0x22 +#define LM3697_CTRL_B_BRT_MSB 0x23 +#define LM3697_CTRL_ENABLE 0x24 + +#define LM3697_SW_RESET BIT(0) + +#define LM3697_CTRL_A_EN BIT(0) +#define LM3697_CTRL_B_EN BIT(1) +#define LM3697_CTRL_A_B_EN (LM3697_CTRL_A_EN | LM3697_CTRL_B_EN) + +#define LM3697_MAX_LED_STRINGS 3 + +#define LM3697_CONTROL_A 0 +#define LM3697_CONTROL_B 1 +#define LM3697_MAX_CONTROL_BANKS 2 + +/** + * struct lm3697_led - + * @hvled_strings: Array of LED strings associated with a control bank + * @label: LED label + * @led_dev: LED class device + * @priv: Pointer to the device struct + * @lmu_data: Register and setting values for common code + * @control_bank: Control bank the LED is associated to. 0 is control bank A + * 1 is control bank B + */ +struct lm3697_led { + u32 hvled_strings[LM3697_MAX_LED_STRINGS]; + char label[LED_MAX_NAME_SIZE]; + struct led_classdev led_dev; + struct lm3697 *priv; + struct ti_lmu_bank lmu_data; + int control_bank; + int enabled; + int num_leds; +}; + +/** + * struct lm3697 - + * @enable_gpio: Hardware enable gpio + * @regulator: LED supply regulator pointer + * @client: Pointer to the I2C client + * @regmap: Devices register map + * @dev: Pointer to the devices device struct + * @lock: Lock for reading/writing the device + * @leds: Array of LED strings + */ +struct lm3697 { + struct gpio_desc *enable_gpio; + struct regulator *regulator; + struct i2c_client *client; + struct regmap *regmap; + struct device *dev; + struct mutex lock; + + int bank_cfg; + + struct lm3697_led leds[]; +}; + +static const struct reg_default lm3697_reg_defs[] = { + {LM3697_OUTPUT_CONFIG, 0x6}, + {LM3697_CTRL_A_RAMP, 0x0}, + {LM3697_CTRL_B_RAMP, 0x0}, + {LM3697_CTRL_A_B_RT_RAMP, 0x0}, + {LM3697_CTRL_A_B_RAMP_CFG, 0x0}, + {LM3697_CTRL_A_B_BRT_CFG, 0x0}, + {LM3697_CTRL_A_FS_CURR_CFG, 0x13}, + {LM3697_CTRL_B_FS_CURR_CFG, 0x13}, + {LM3697_PWM_CFG, 0xc}, + {LM3697_CTRL_A_BRT_LSB, 0x0}, + {LM3697_CTRL_A_BRT_MSB, 0x0}, + {LM3697_CTRL_B_BRT_LSB, 0x0}, + {LM3697_CTRL_B_BRT_MSB, 0x0}, + {LM3697_CTRL_ENABLE, 0x0}, +}; + +static const struct regmap_config lm3697_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LM3697_CTRL_ENABLE, + .reg_defaults = lm3697_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lm3697_reg_defs), + .cache_type = REGCACHE_FLAT, +}; + +static int lm3697_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brt_val) +{ + struct lm3697_led *led = container_of(led_cdev, struct lm3697_led, + led_dev); + int ctrl_en_val = (1 << led->control_bank); + int ret; + + mutex_lock(&led->priv->lock); + + if (brt_val == LED_OFF) { + ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE, + ctrl_en_val, ~ctrl_en_val); + if (ret) { + dev_err(&led->priv->client->dev, "Cannot write ctrl register\n"); + goto brightness_out; + } + + led->enabled = LED_OFF; + } else { + ret = ti_lmu_common_set_brightness(&led->lmu_data, brt_val); + if (ret) { + dev_err(&led->priv->client->dev, + "Cannot write brightness\n"); + goto brightness_out; + } + + if (!led->enabled) { + ret = regmap_update_bits(led->priv->regmap, + LM3697_CTRL_ENABLE, + ctrl_en_val, ctrl_en_val); + if (ret) { + dev_err(&led->priv->client->dev, + "Cannot enable the device\n"); + goto brightness_out; + } + + led->enabled = brt_val; + } + } + +brightness_out: + mutex_unlock(&led->priv->lock); + return ret; +} + +static int lm3697_init(struct lm3697 *priv) +{ + struct lm3697_led *led; + int i, ret; + + if (priv->enable_gpio) { + gpiod_direction_output(priv->enable_gpio, 1); + } else { + ret = regmap_write(priv->regmap, LM3697_RESET, LM3697_SW_RESET); + if (ret) { + dev_err(&priv->client->dev, "Cannot reset the device\n"); + goto out; + } + } + + ret = regmap_write(priv->regmap, LM3697_CTRL_ENABLE, 0x0); + if (ret) { + dev_err(&priv->client->dev, "Cannot write ctrl enable\n"); + goto out; + } + + ret = regmap_write(priv->regmap, LM3697_OUTPUT_CONFIG, priv->bank_cfg); + if (ret) + dev_err(&priv->client->dev, "Cannot write OUTPUT config\n"); + + for (i = 0; i < LM3697_MAX_CONTROL_BANKS; i++) { + led = &priv->leds[i]; + ret = ti_lmu_common_set_ramp(&led->lmu_data); + if (ret) + dev_err(&priv->client->dev, "Setting the ramp rate failed\n"); + } +out: + return ret; +} + +static int lm3697_probe_dt(struct lm3697 *priv) +{ + struct fwnode_handle *child = NULL; + struct lm3697_led *led; + const char *name; + int control_bank; + size_t i = 0; + int ret = -EINVAL; + int j; + + priv->enable_gpio = devm_gpiod_get_optional(&priv->client->dev, + "enable", GPIOD_OUT_LOW); + if (IS_ERR(priv->enable_gpio)) { + ret = PTR_ERR(priv->enable_gpio); + dev_err(&priv->client->dev, "Failed to get enable gpio: %d\n", + ret); + return ret; + } + + priv->regulator = devm_regulator_get(&priv->client->dev, "vled"); + if (IS_ERR(priv->regulator)) + priv->regulator = NULL; + + device_for_each_child_node(priv->dev, child) { + ret = fwnode_property_read_u32(child, "reg", &control_bank); + if (ret) { + dev_err(&priv->client->dev, "reg property missing\n"); + fwnode_handle_put(child); + goto child_out; + } + + if (control_bank > LM3697_CONTROL_B) { + dev_err(&priv->client->dev, "reg property is invalid\n"); + ret = -EINVAL; + fwnode_handle_put(child); + goto child_out; + } + + led = &priv->leds[i]; + + ret = ti_lmu_common_get_brt_res(&priv->client->dev, + child, &led->lmu_data); + if (ret) + dev_warn(&priv->client->dev, "brightness resolution property missing\n"); + + led->control_bank = control_bank; + led->lmu_data.regmap = priv->regmap; + led->lmu_data.runtime_ramp_reg = LM3697_CTRL_A_RAMP + + control_bank; + led->lmu_data.msb_brightness_reg = LM3697_CTRL_A_BRT_MSB + + led->control_bank * 2; + led->lmu_data.lsb_brightness_reg = LM3697_CTRL_A_BRT_LSB + + led->control_bank * 2; + + led->num_leds = fwnode_property_read_u32_array(child, + "led-sources", + NULL, 0); + + if (led->num_leds > LM3697_MAX_LED_STRINGS) { + dev_err(&priv->client->dev, "To many LED strings defined\n"); + continue; + } + + ret = fwnode_property_read_u32_array(child, "led-sources", + led->hvled_strings, + led->num_leds); + if (ret) { + dev_err(&priv->client->dev, "led-sources property missing\n"); + fwnode_handle_put(child); + goto child_out; + } + + for (j = 0; j < led->num_leds; j++) + priv->bank_cfg |= + (led->control_bank << led->hvled_strings[j]); + + ret = ti_lmu_common_get_ramp_params(&priv->client->dev, + child, &led->lmu_data); + if (ret) + dev_warn(&priv->client->dev, "runtime-ramp properties missing\n"); + + fwnode_property_read_string(child, "linux,default-trigger", + &led->led_dev.default_trigger); + + ret = fwnode_property_read_string(child, "label", &name); + if (ret) + snprintf(led->label, sizeof(led->label), + "%s::", priv->client->name); + else + snprintf(led->label, sizeof(led->label), + "%s:%s", priv->client->name, name); + + led->priv = priv; + led->led_dev.name = led->label; + led->led_dev.max_brightness = led->lmu_data.max_brightness; + led->led_dev.brightness_set_blocking = lm3697_brightness_set; + + ret = devm_led_classdev_register(priv->dev, &led->led_dev); + if (ret) { + dev_err(&priv->client->dev, "led register err: %d\n", + ret); + fwnode_handle_put(child); + goto child_out; + } + + i++; + } + +child_out: + return ret; +} + +static int lm3697_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct lm3697 *led; + int count; + int ret; + + count = device_get_child_node_count(&client->dev); + if (!count) { + dev_err(&client->dev, "LEDs are not defined in device tree!"); + return -ENODEV; + } + + led = devm_kzalloc(&client->dev, struct_size(led, leds, count), + GFP_KERNEL); + if (!led) + return -ENOMEM; + + mutex_init(&led->lock); + i2c_set_clientdata(client, led); + + led->client = client; + led->dev = &client->dev; + led->regmap = devm_regmap_init_i2c(client, &lm3697_regmap_config); + if (IS_ERR(led->regmap)) { + ret = PTR_ERR(led->regmap); + dev_err(&client->dev, "Failed to allocate register map: %d\n", + ret); + return ret; + } + + ret = lm3697_probe_dt(led); + if (ret) + return ret; + + return lm3697_init(led); +} + +static int lm3697_remove(struct i2c_client *client) +{ + struct lm3697 *led = i2c_get_clientdata(client); + int ret; + + ret = regmap_update_bits(led->regmap, LM3697_CTRL_ENABLE, + LM3697_CTRL_A_B_EN, 0); + if (ret) { + dev_err(&led->client->dev, "Failed to disable the device\n"); + return ret; + } + + if (led->enable_gpio) + gpiod_direction_output(led->enable_gpio, 0); + + if (led->regulator) { + ret = regulator_disable(led->regulator); + if (ret) + dev_err(&led->client->dev, + "Failed to disable regulator\n"); + } + + mutex_destroy(&led->lock); + + return 0; +} + +static const struct i2c_device_id lm3697_id[] = { + { "lm3697", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, lm3697_id); + +static const struct of_device_id of_lm3697_leds_match[] = { + { .compatible = "ti,lm3697", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_lm3697_leds_match); + +static struct i2c_driver lm3697_driver = { + .driver = { + .name = "lm3697", + .of_match_table = of_lm3697_leds_match, + }, + .probe = lm3697_probe, + .remove = lm3697_remove, + .id_table = lm3697_id, +}; +module_i2c_driver(lm3697_driver); + +MODULE_DESCRIPTION("Texas Instruments LM3697 LED driver"); +MODULE_AUTHOR("Dan Murphy "); +MODULE_LICENSE("GPL v2");