From patchwork Tue Jan 10 09:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Zanders X-Patchwork-Id: 41378 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2646759wrt; Tue, 10 Jan 2023 01:32:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtf9zDam0z9qJDa0vnHD7KB1zc1cwMSKnqNisnSqECSxk2F8tHrfudl1DmCBsc0vQBVfYM1 X-Received: by 2002:a17:907:9625:b0:7ad:9455:d57d with SMTP id gb37-20020a170907962500b007ad9455d57dmr65818308ejc.74.1673343125768; Tue, 10 Jan 2023 01:32:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673343125; cv=none; d=google.com; s=arc-20160816; b=OSg7m79c9lBwfsF0ZPAJLikKlnMOsJvk/vZGn53QNtqen3DYD/grFAQ01zrIKievZl pkfoIFcnShyO515jCvhPJ1Q8LiNbGsIPBwDEQbhw+4dfbL3OUpF7Y5D0IvY2rum1sCOa XlB2o5uQrtSW9InrAMqlFnKsKovQk1jeMsCCDJN8pC7G3D33mPpTHTSAdISIObIHRNOH KqCD4M9SpL+ikbO9ct/nqKUik7KDMT4Uw5Y42hT0VifOh0v1E+LYHTj84sfnuDLO4Fhe lzJ/tYudArNQoXlY8mCgO9rN6B0x766oRe8IcCBQhR7WnciNQChYpmdOh2N2Xjsz8PJR bN4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wiGeG2pWJxpESvGj47RLxzq7ucQ3N2fre9bCitRo4xg=; b=M7OptSQBbSdhv5+q/Jh23kkTJ1oYTicVL4n6aq7pjFLA9USQ+QNhnrk+W3+jp49oIa 0R46eZUT4DH3tIn7ldmXfCh0UJ6Eti+ROx/aFNYWw1cox9lviE8yyD1UDCoFCLLwfCpf Ut2jxq7xfi2T9OVrYWrbpqm0Xeohsr+nZ6ch22uGxWKjNu8GC6AE/QKxWdaKOv4awuVt Y+VY3L3OZqye19YG2KVsmzjaPU62sphG1umX3yLXrIbFc4AH+1Htw0g+JzFlp+g91M8s uB60twAvpmuCTZYvsV/kID/3fMCEkPRRvEI9QDMtYyRruNjyYy0vau8ALaOiUdBmX/gW 0K+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mind.be header.s=google header.b=GLG7O8EM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji1-20020a170907980100b0084514612c2fsi11510675ejc.613.2023.01.10.01.31.41; Tue, 10 Jan 2023 01:32:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mind.be header.s=google header.b=GLG7O8EM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238101AbjAJJZO (ORCPT + 99 others); Tue, 10 Jan 2023 04:25:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238091AbjAJJYw (ORCPT ); Tue, 10 Jan 2023 04:24:52 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84787551DE for ; Tue, 10 Jan 2023 01:24:50 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id k26-20020a05600c1c9a00b003d972646a7dso11281426wms.5 for ; Tue, 10 Jan 2023 01:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wiGeG2pWJxpESvGj47RLxzq7ucQ3N2fre9bCitRo4xg=; b=GLG7O8EM8nh8j0ke8ExuUCxC0tBSLVi8oe5BXgEJkqUpxYNWgeq9j9QybkhiOZ9Hd4 ANOouiGawElwsyFQRZ+Z47x+6fsn4/BFzae6cM8kOxvzB50Js3ed3BFLt62coqATpPSw uiW2fjnGmKA99io43ajJuWVJihyA4/E3CqHZN+vm8kJGa2gzIisdPklY84KAINRgJIVI ABPyEg0Cx899cH8YA+2lMcK+ffv1og+2IvvCgljBLhDzS8XpU2fboEZDXmglrISvzTON muDUlwNdiXanTUQ4ueuI18fhuVK7QYc91Ysvsho/Fzz5eQ46Kqhi0T9kWQ0E1iyESxaa MqDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wiGeG2pWJxpESvGj47RLxzq7ucQ3N2fre9bCitRo4xg=; b=vC1csy2cOMW1/nRTE4OYSqhrNjAKCpYM02XxLXKCq+Nc8dkkjKuDcjg2BSroYB/xtx YieuUlS1q8sbJTk0kloWWqp4lncbfcqDJevM5CHxSGd/BckUKBAsHdrJQ1LIV7PXBteQ 6DRD8JYFuPKYTMhOSPkhwtjKwD/sSh4rFCH8anpMVnxYziN0OyW3oYbv4gk0iDGGeStX ZuU7js8WSEVIWfVoJAENlnBNeNL7FCJuQYssNKxU+BMnpeGdFjx8FF8rVLRZIZWqZAXA DR/Dpb14Def2d1IC4Qo9kfICqYCFnhiH4+IBsZJzcep0LEw4uhBH86LK6TpNz5KQJMbf Cf1g== X-Gm-Message-State: AFqh2krZoc1spB/6N2jKNRdfTa47XkKpCxCNQfbHoQTPrgI9ygv1Rmid etDXeCPFNximIUeEJa+wi+IMmw== X-Received: by 2002:a05:600c:47d1:b0:3d3:496b:de9d with SMTP id l17-20020a05600c47d100b003d3496bde9dmr48696449wmo.34.1673342689012; Tue, 10 Jan 2023 01:24:49 -0800 (PST) Received: from dtpc.zanders.be (78-22-137-109.access.telenet.be. [78.22.137.109]) by smtp.gmail.com with ESMTPSA id q22-20020a05600c331600b003d9dd62deedsm13149433wmp.30.2023.01.10.01.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 01:24:48 -0800 (PST) From: Maarten Zanders To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Jacek Anaszewski Cc: krzysztof.kozlowski@linaro.org, Maarten Zanders , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] dt-bindings: leds-lp55xx: add ti,charge-pump-mode Date: Tue, 10 Jan 2023 10:23:39 +0100 Message-Id: <20230110092342.24132-2-maarten.zanders@mind.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230110092342.24132-1-maarten.zanders@mind.be> References: <20230110092342.24132-1-maarten.zanders@mind.be> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754627441227416158?= X-GMAIL-MSGID: =?utf-8?q?1754627441227416158?= Add a binding to configure the internal charge pump for lp55xx. Signed-off-by: Maarten Zanders Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/leds/leds-lp55xx.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml b/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml index ae607911f1db..40ab3cf597a4 100644 --- a/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml +++ b/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml @@ -66,6 +66,13 @@ properties: '#size-cells': const: 0 + ti,charge-pump-mode: + description: + Set the operating mode of the internal charge pump. + $ref: /schemas/types.yaml#/definitions/string + enum: [off, auto, bypass, boost] + default: auto + patternProperties: '^multi-led@[0-8]$': type: object @@ -164,6 +171,7 @@ examples: reg = <0x32>; clock-mode = /bits/ 8 <2>; pwr-sel = /bits/ 8 <3>; /* D1~9 connected to VOUT */ + ti,charge-pump-mode = "bypass"; led@0 { reg = <0>; From patchwork Tue Jan 10 09:23:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Zanders X-Patchwork-Id: 41379 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2646923wrt; Tue, 10 Jan 2023 01:32:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXtjg+HSaAfALHc8j61Ohc04lC9vou7Yhw3PmTfa2w073FyjNm+UvKryt16nkDPYPNfwFH+/ X-Received: by 2002:a17:907:6d0b:b0:83f:1f64:c1e with SMTP id sa11-20020a1709076d0b00b0083f1f640c1emr66571553ejc.47.1673343150352; Tue, 10 Jan 2023 01:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673343150; cv=none; d=google.com; s=arc-20160816; b=KHFavXzEOU7/SNVmMYBtjGUo3CbDkphJovSAGYFuvekee7faoD4JIjA3663yIChWdZ U++puajJ5LQnZP1QMwP8lSYpl3EePuJyVc9JUNr8OZKCxoeSfvBLTLENw7WgthKSfAPI SrSnSaMAk21F6d+PS6Fq/6UYkPXmcd+QsP3Vl7x/9Z2cU4o6/TkQQqUcpWcBefVnf9Vg mOSM7Kwdfn4lmg4v2zLPRGxmmTRYHs/RdSUk/3MjLDiahh5aUDFIh4N/Fi6x/zN41J2V yKTXbx0Dd6KyRaZfzUwC2+uPAuZMcMpMn/RHf3PucQbUwSxWCCfIF3Zho+P6wHBFon+a ARSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/dh0bQBvL1MAQ79eqgTbgReBtIQtpA+XQbsleX01n6Q=; b=eN0h9QY9AanqCsiexmXankegHWPCnmTVMHs/Jpvf0uRno6+72QNN+xsRMoWAuLW5+O xNu8Y8yQygFogMsUa8iaxsLwA+WWzQeIxoMtGiPiLVvsg5U/Bd3hbkNlN329XXYoVb2M vPIrtymNhyFac9UOsNa5JorGOtIhyxm+Gf5A75ICULghLMESLfhdmgwWiRACaUtDS5ib MX2xtUKXrJd7ehh8mp9NOX4r3jBvM4SWDVdYH/6rKiUGRy07NKlKN43xYOfB5l54tiSN CLbDlofFRF5imkN6jbQ3ZIgmDWjjV4tzlJLMBwjryrKFqfxinOeXpNNAAWQlvD1P/Pt/ 5PIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mind.be header.s=google header.b=OYRLNBuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020a170906595900b007c4f6c371b0si9035646ejr.230.2023.01.10.01.32.07; Tue, 10 Jan 2023 01:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mind.be header.s=google header.b=OYRLNBuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238113AbjAJJZS (ORCPT + 99 others); Tue, 10 Jan 2023 04:25:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235319AbjAJJYz (ORCPT ); Tue, 10 Jan 2023 04:24:55 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 805D626CD for ; Tue, 10 Jan 2023 01:24:53 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id m26-20020a05600c3b1a00b003d9811fcaafso9312375wms.5 for ; Tue, 10 Jan 2023 01:24:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/dh0bQBvL1MAQ79eqgTbgReBtIQtpA+XQbsleX01n6Q=; b=OYRLNBuMGyBJ1A3K7H9KUEr8xAGnzk1e4IUwZTWWAvxYhrvkniINIi83jyqFxY+yfj wdCs/lCSWTL1kTtYDlCgy3CcugbQuztkSPMVN5a56RPhvwOOuRGO+5bG4noqypRQDfd7 k8X64xyiMmipBva84Xm/qZxbPIa8qbcqTQb4mexEbdpXYDneJv7ivfUh037XcK1XYVQT L4w2W2bywLJoiTCEzdJODxL56dtMncw9bV7AXmlS5pPZH49Ty16Y00cUIGk2Ckcd9pPM aYu7qdz0YKMb0NnHD0Ecetw2DDQU0ic0QjN0t4kBhcZQAYJU7SaPk8qpJnA4CYC4yzPW fgzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/dh0bQBvL1MAQ79eqgTbgReBtIQtpA+XQbsleX01n6Q=; b=GijJt+XEZQfN1pKW6RzMGDoKSh7/jwbHxhwuCLGKeWsS9K9vLJ7HtQFmAKulth0YY7 Cyrm92L4pvVICISe76/pSQnY+Kx715MZhR846GfCwIez2LxkxUy/xEzjWHz0NlLLxaF9 KIYIOm55t82/L3faI1AS9sSYb29gbZzEdcg9enLjsYf504RuRqYtiZrnj8q7HQuPn5Nr hZL/vNHtD1zQgZYveeRSblQ7/jTXyPfIBx1mzpVvIPkXMO7/3Zc3qra3ZQN+jjUpAUwv xj97IVfqOkUpMZz3g9QHVkyzTBTNOyuBpYLS/1kuPOh/1A9to0VqwF5A280RCQu6Oyw4 o0iQ== X-Gm-Message-State: AFqh2kp5o26LXRWenr2P3+YfW8WTdkzyy4H2ZIZo6D1Qb23BFhE6fNQh 7R7Unz0SnjsZLc6VbanXywhP1g== X-Received: by 2002:a05:600c:4da0:b0:3d3:5027:4cce with SMTP id v32-20020a05600c4da000b003d350274ccemr50798040wmp.10.1673342692099; Tue, 10 Jan 2023 01:24:52 -0800 (PST) Received: from dtpc.zanders.be (78-22-137-109.access.telenet.be. [78.22.137.109]) by smtp.gmail.com with ESMTPSA id q22-20020a05600c331600b003d9dd62deedsm13149433wmp.30.2023.01.10.01.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 01:24:51 -0800 (PST) From: Maarten Zanders To: Pavel Machek , Lee Jones Cc: krzysztof.kozlowski@linaro.org, Maarten Zanders , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] leds: lp55xx: configure internal charge pump Date: Tue, 10 Jan 2023 10:23:40 +0100 Message-Id: <20230110092342.24132-3-maarten.zanders@mind.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230110092342.24132-1-maarten.zanders@mind.be> References: <20230110092342.24132-1-maarten.zanders@mind.be> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754627425517734233?= X-GMAIL-MSGID: =?utf-8?q?1754627466966305339?= The LP55xx range of devices have an internal charge pump which can (automatically) increase the output voltage towards the LED's, boosting the output voltage to 4.5V. Implement this option from the devicetree. When the setting is not present it will operate in automatic mode as before. Tested on LP55231. Datasheet analysis shows that LP5521, LP5523 and LP8501 are identical in topology and are modified in the same way. Signed-off-by: Maarten Zanders --- drivers/leds/leds-lp5521.c | 12 ++++++------ drivers/leds/leds-lp5523.c | 18 +++++++++++++----- drivers/leds/leds-lp55xx-common.c | 22 ++++++++++++++++++++++ drivers/leds/leds-lp8501.c | 8 ++++++-- include/linux/platform_data/leds-lp55xx.h | 9 +++++++++ 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 19478d9c19a7..ee1c72cffdab 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c @@ -58,14 +58,11 @@ /* CONFIG register */ #define LP5521_PWM_HF 0x40 /* PWM: 0 = 256Hz, 1 = 558Hz */ #define LP5521_PWRSAVE_EN 0x20 /* 1 = Power save mode */ -#define LP5521_CP_MODE_OFF 0 /* Charge pump (CP) off */ -#define LP5521_CP_MODE_BYPASS 8 /* CP forced to bypass mode */ -#define LP5521_CP_MODE_1X5 0x10 /* CP forced to 1.5x mode */ -#define LP5521_CP_MODE_AUTO 0x18 /* Automatic mode selection */ +#define LP5521_CP_MODE_MASK 0x18 /* Charge pump mode */ +#define LP5521_CP_MODE_SHIFT 3 #define LP5521_R_TO_BATT 0x04 /* R out: 0 = CP, 1 = Vbat */ #define LP5521_CLK_INT 0x01 /* Internal clock */ -#define LP5521_DEFAULT_CFG \ - (LP5521_PWM_HF | LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO) +#define LP5521_DEFAULT_CFG (LP5521_PWM_HF | LP5521_PWRSAVE_EN) /* Status */ #define LP5521_EXT_CLK_USED 0x08 @@ -310,6 +307,9 @@ static int lp5521_post_init_device(struct lp55xx_chip *chip) if (!lp55xx_is_extclk_used(chip)) val |= LP5521_CLK_INT; + val |= (chip->pdata->charge_pump_mode << LP5521_CP_MODE_SHIFT) & + LP5521_CP_MODE_MASK; + ret = lp55xx_write(chip, LP5521_REG_CONFIG, val); if (ret) return ret; diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index e08e3de1428d..b5d10d4252e6 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -57,8 +57,12 @@ #define LP5523_AUTO_INC 0x40 #define LP5523_PWR_SAVE 0x20 #define LP5523_PWM_PWR_SAVE 0x04 -#define LP5523_CP_AUTO 0x18 +#define LP5523_CP_MODE_MASK 0x18 +#define LP5523_CP_MODE_SHIFT 3 #define LP5523_AUTO_CLK 0x02 +#define LP5523_DEFAULT_CONFIG \ + (LP5523_AUTO_INC | LP5523_PWR_SAVE |\ + LP5523_AUTO_CLK | LP5523_PWM_PWR_SAVE) #define LP5523_EN_LEDTEST 0x80 #define LP5523_LEDTEST_DONE 0x80 @@ -125,6 +129,7 @@ static void lp5523_set_led_current(struct lp55xx_led *led, u8 led_current) static int lp5523_post_init_device(struct lp55xx_chip *chip) { int ret; + int val; ret = lp55xx_write(chip, LP5523_REG_ENABLE, LP5523_ENABLE); if (ret) @@ -133,10 +138,13 @@ static int lp5523_post_init_device(struct lp55xx_chip *chip) /* Chip startup time is 500 us, 1 - 2 ms gives some margin */ usleep_range(1000, 2000); - ret = lp55xx_write(chip, LP5523_REG_CONFIG, - LP5523_AUTO_INC | LP5523_PWR_SAVE | - LP5523_CP_AUTO | LP5523_AUTO_CLK | - LP5523_PWM_PWR_SAVE); + val = LP5523_DEFAULT_CONFIG; + + val |= (chip->pdata->charge_pump_mode << LP5523_CP_MODE_SHIFT) & + LP5523_CP_MODE_MASK; + + ret = lp55xx_write(chip, LP5523_REG_CONFIG, val); + if (ret) return ret; diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index c1940964067a..a690a484fd7b 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -653,6 +653,13 @@ static int lp55xx_parse_logical_led(struct device_node *np, return ret; } +static const char * const charge_pump_modes[] = { + [LP55XX_CP_OFF] = "off", + [LP55XX_CP_BYPASS] = "bypass", + [LP55XX_CP_BOOST] = "boost", + [LP55XX_CP_AUTO] = "auto", +}; + struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, struct device_node *np, struct lp55xx_chip *chip) @@ -661,6 +668,8 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, struct lp55xx_platform_data *pdata; struct lp55xx_led_config *cfg; int num_channels; + enum lp55xx_charge_pump_mode cp_mode; + const char *pm; int i = 0; int ret; @@ -691,6 +700,19 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, i++; } + pdata->charge_pump_mode = LP55XX_CP_AUTO; + ret = of_property_read_string(np, "ti,charge-pump-mode", &pm); + if (!ret) { + for (cp_mode = LP55XX_CP_OFF; + cp_mode < ARRAY_SIZE(charge_pump_modes); + cp_mode++) { + if (!strcasecmp(pm, charge_pump_modes[cp_mode])) { + pdata->charge_pump_mode = cp_mode; + break; + } + } + } + of_property_read_string(np, "label", &pdata->label); of_property_read_u8(np, "clock-mode", &pdata->clock_mode); diff --git a/drivers/leds/leds-lp8501.c b/drivers/leds/leds-lp8501.c index ae11a02c0ab2..f0e70e116919 100644 --- a/drivers/leds/leds-lp8501.c +++ b/drivers/leds/leds-lp8501.c @@ -53,10 +53,11 @@ #define LP8501_PWM_PSAVE BIT(7) #define LP8501_AUTO_INC BIT(6) #define LP8501_PWR_SAVE BIT(5) -#define LP8501_CP_AUTO 0x18 +#define LP8501_CP_MODE_MASK 0x18 +#define LP8501_CP_MODE_SHIFT 3 #define LP8501_INT_CLK BIT(0) #define LP8501_DEFAULT_CFG \ - (LP8501_PWM_PSAVE | LP8501_AUTO_INC | LP8501_PWR_SAVE | LP8501_CP_AUTO) + (LP8501_PWM_PSAVE | LP8501_AUTO_INC | LP8501_PWR_SAVE) #define LP8501_REG_RESET 0x3D #define LP8501_RESET 0xFF @@ -102,6 +103,9 @@ static int lp8501_post_init_device(struct lp55xx_chip *chip) if (chip->pdata->clock_mode != LP55XX_CLOCK_EXT) val |= LP8501_INT_CLK; + val |= (chip->pdata->charge_pump_mode << LP8501_CP_MODE_SHIFT) & + LP8501_CP_MODE_MASK; + ret = lp55xx_write(chip, LP8501_REG_CONFIG, val); if (ret) return ret; diff --git a/include/linux/platform_data/leds-lp55xx.h b/include/linux/platform_data/leds-lp55xx.h index 3441064713a3..6ea1a74f94e4 100644 --- a/include/linux/platform_data/leds-lp55xx.h +++ b/include/linux/platform_data/leds-lp55xx.h @@ -50,6 +50,13 @@ enum lp8501_pwr_sel { LP8501_ALL_VOUT, /* D1~9 are connected to VOUT */ }; +enum lp55xx_charge_pump_mode { + LP55XX_CP_OFF = 0, + LP55XX_CP_BYPASS = 1, + LP55XX_CP_BOOST = 2, + LP55XX_CP_AUTO = 3, +}; + /* * struct lp55xx_platform_data * @led_config : Configurable led class device @@ -73,6 +80,8 @@ struct lp55xx_platform_data { /* Clock configuration */ u8 clock_mode; + enum lp55xx_charge_pump_mode charge_pump_mode; + /* optional enable GPIO */ struct gpio_desc *enable_gpiod;