From patchwork Thu Feb 2 09:23:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Zanders X-Patchwork-Id: 51821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp185191dyf; Thu, 2 Feb 2023 01:28:13 -0800 (PST) X-Google-Smtp-Source: AK7set8f/uZTAx9j5o7OPCcXgx46mH5zHhweXGs1gAVtYD9ue+RtaBrzqYgdR6e00auEsT9YsyXH X-Received: by 2002:aa7:d785:0:b0:4a2:43a7:c922 with SMTP id s5-20020aa7d785000000b004a243a7c922mr5620231edq.1.1675330093495; Thu, 02 Feb 2023 01:28:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675330093; cv=none; d=google.com; s=arc-20160816; b=VBlO33et8sfCeTZ8YQ+DOByXjGsr1gMnw2amRhEOjOnzv3xO8f+a068GXevYjNAnbe DhetJdnWRZ3/IrYVBbh4Zkbr54rUWv8gbbZJc9vnoRABMEzELQvp98MYLVs7ArzxTuVR 9TbmtGfKrkkZj1/Dyid55ZpGb+Dp9nusrFqQ/q6CS3ETxQzIGIF8/VRXI3ryjLrAfUVs 4O5rCQN+Cyhiu9JqoYrgZbWvC4v+ZbrmDviGrdhnWJUY6HeW3qV0iTGfINCG09rZq/Gd XZqWNj4BHjcIoEKi8zaWW9pDsEeBeVPEkQFE2jPzVCtQqUxDdxhwpfTHNNoCeB9q+0yG hHIA== 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=a+895vSqqhP2PRbIGa0xaBQ6CuDJr2raP8r23AovQRk=; b=V7Yd2/vo6osfwamPOUKWrBatiiWZKguaKbzr1PfkkYRvT3fONmiLASObenELW81dMz sz/XPdVeDqSWnPzCt2Wy4Asc8aUDiQjZrZSGO3i5jIRp2vivGJWPQM9yeh+CMJHqJAs9 Z54vDqKV8Gwf7gt6rxqzHj3x0nWwUoVemkP1UUSpha5t3+Yu6uB5lA06DPmYy5QTEjhD 0dv3SCWklQMmxsWzp7E/tAxpmCVvr4GpacDXzr1k8zjXXnF5j7qeaPDKNChN7s+VfUMw gJjog5Tsbwq5m44KgnADxmxYoAUwwll8I2ucD6Dd1OnDNZ/t5TobFp2cwrccdNoqmeLH WNVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mind.be header.s=google header.b=cVZq4U7j; 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 dz17-20020a0564021d5100b004a75a6c9d85si1148764edb.384.2023.02.02.01.27.49; Thu, 02 Feb 2023 01:28:13 -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=cVZq4U7j; 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 S232059AbjBBJYE (ORCPT + 99 others); Thu, 2 Feb 2023 04:24:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbjBBJX6 (ORCPT ); Thu, 2 Feb 2023 04:23:58 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B3D06F706 for ; Thu, 2 Feb 2023 01:23:56 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id lu11so4182819ejb.3 for ; Thu, 02 Feb 2023 01:23:56 -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=a+895vSqqhP2PRbIGa0xaBQ6CuDJr2raP8r23AovQRk=; b=cVZq4U7jNfYXgMVU/53hG/SLEZlJ3VACL1yopNshey8SZArqPpFNsGRs6NPIhl7Foi h+qV2nw2xCQOb7qJ8a/Yh9q3TA/f67Koi3HVxazOs6GIaTBDSm2W/9k2lY/ussVcR49w EnIgw2361jZzHuGq5i31DYNSOxPepEwBWO0FCjnxMOFgqf7NfJnhY4sSEEF0XOalbDsP i0HfXbIzAlirXhfioNHW3J6mEwLOvo07DfHh8evqZThgsppmRgMqBCRyfOysU1kDIJNi DHwUbK6sxkkzIB/xo6g4ZrSb4r3ock6M3DUrCqGsaN9NSajPVsSdb8a49LGuCGKqq4+Z x/Aw== 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=a+895vSqqhP2PRbIGa0xaBQ6CuDJr2raP8r23AovQRk=; b=1mLNtiWZlSSA7qksaaDdwPLzSxZWkL+440btCxtZ3hF4FfweHMZC70ov9soBHb8P3z eg0xHGDTLisx+3LI6zHj/iY1IaWEXIHi+3eTV2PgWoh8b9+rdfgMYaRDMr/sFmIRQ0RV HzQ9PklYQ+s2H56c77nrLnV/puwOie/g6XhUAOIF1litHeO9pmc8un+WKM02c3xahSxh 6BbvveOg0vNlOWk66ndVn0DPIVB8yF1PnaPdEB+AOVOWfpJri0ALVNOmRtAJ05TGqt7C RCQNigNCXQTq6ZtMPOktSuXbcEY2qUO5W/IrKBYc6qQdKAWulwNbuJHesIAuhA8mwi2j YD6Q== X-Gm-Message-State: AO0yUKUFkgsfvBCtoL1cXgHgMHXGMx7CfhmHBPrg7sPyV+qUNAOH+Gkg Z+AqMID0ES+zBKdcCcM877xJNw== X-Received: by 2002:a17:906:f190:b0:888:6ae0:d12e with SMTP id gs16-20020a170906f19000b008886ae0d12emr5678697ejb.36.1675329835051; Thu, 02 Feb 2023 01:23:55 -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 j4-20020a170906474400b00856ad9108e7sm11372658ejs.70.2023.02.02.01.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:23:54 -0800 (PST) From: Maarten Zanders To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Jacek Anaszewski Cc: Maarten Zanders , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] dt-bindings: leds-lp55xx: add ti,charge-pump-mode Date: Thu, 2 Feb 2023 10:23:24 +0100 Message-Id: <20230202092325.21241-2-maarten.zanders@mind.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230202092325.21241-1-maarten.zanders@mind.be> References: <20230202092325.21241-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?1756710928092075675?= X-GMAIL-MSGID: =?utf-8?q?1756710928092075675?= Add a binding to configure the internal charge pump for lp55xx. Signed-off-by: Maarten Zanders --- .../devicetree/bindings/leds/leds-lp55xx.yaml | 8 ++++++++ include/dt-bindings/leds/leds-lp55xx.h | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 include/dt-bindings/leds/leds-lp55xx.h diff --git a/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml b/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml index ae607911f1db..22e63d89d770 100644 --- a/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml +++ b/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml @@ -66,6 +66,12 @@ properties: '#size-cells': const: 0 + ti,charge-pump-mode: + description: + Set the operating mode of the internal charge pump as defined in + . Defaults to auto. + $ref: /schemas/types.yaml#/definitions/uint8 + patternProperties: '^multi-led@[0-8]$': type: object @@ -152,6 +158,7 @@ additionalProperties: false examples: - | #include + #include i2c { #address-cells = <1>; @@ -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 = /bits/ 8 ; led@0 { reg = <0>; diff --git a/include/dt-bindings/leds/leds-lp55xx.h b/include/dt-bindings/leds/leds-lp55xx.h new file mode 100644 index 000000000000..8f59c1c12dee --- /dev/null +++ b/include/dt-bindings/leds/leds-lp55xx.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _DT_BINDINGS_LEDS_LP55XX_H +#define _DT_BINDINGS_LEDS_LP55XX_H + +#define LP55XX_CP_OFF 0 +#define LP55XX_CP_BYPASS 1 +#define LP55XX_CP_BOOST 2 +#define LP55XX_CP_AUTO 3 + +#endif /* _DT_BINDINGS_LEDS_LP55XX_H */ From patchwork Thu Feb 2 09:23:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Zanders X-Patchwork-Id: 51819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp184871dyf; Thu, 2 Feb 2023 01:27:38 -0800 (PST) X-Google-Smtp-Source: AK7set84kbjJ1Sz33ZMdAD0lnkwwF+0hj2H+govGBeG1N7YEPw/7Ai4N/HzAV9p10pX3umF+07Y+ X-Received: by 2002:a17:902:ea0d:b0:196:7664:39b with SMTP id s13-20020a170902ea0d00b001967664039bmr7346813plg.4.1675330058008; Thu, 02 Feb 2023 01:27:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675330057; cv=none; d=google.com; s=arc-20160816; b=JalLzeJIWbQRvt9rL2BCFei3+59mbzZr1ZmuGN8VAnHXr9hp7KqP7RYlE2pXHp6eA5 SAN9nku1G9tmK3upUC9Ocsx5uAs8QGABqDZkIUDYYIboPhGniCejRBWxAUtkVH0xDgDz c0iu/E707cxSIz7rz8T7D556t6fGOZpcwHIJbAARANSd84IJp3rPS6rCBEhgeIifCe6e MlbUdaK/oede98/39K1i/rf9484PI31esWljqjFNPHxNuLXm2OpQW96cLN7rLvSaoyPb EYqmqMh3/CxOo5XNhHRkrAR1g65TI8kZDge6xnQBMgm3ByLiemCg9sMOZTaSsW+GaPjb BRxA== 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=eJR3j7UgcHI8drkrJokvDJuY/mtil1DqdGHf4t4Su9s=; b=D7Ir4Vymsl+Xl9PhgB7QMMroe8dLHbKF/reVkehmY3HnvD0OFDhNJsq0VZXTyPAkui PAlhsAn3FbOk9brN8umt8/e54GCATAf3BJlQ/Yt/yLFwzVvQvJWFaYeDcBPiPHG9d3a+ ZbDm8tgmSk4H45PRRfSGWGTzTG0hWyLe8l8+BCnBf68kOLQiODGZS54UGMkz2mc4KQ3n 0ndO6Lq9klei558/1hgEII5D1enCVuMQh5j/mtXXwblQMIRR/Z8vJlzFv5ImDwKbQs7J rKWcz9NNmXFmnUFg5tpbLjt7FVBPedPqeP/dmK2b8rUaMiUmvoERyLLaDno4dmTG/lxT QQzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mind.be header.s=google header.b=HFf1Yg0h; 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 ik9-20020a170902ab0900b00193353fb077si22365466plb.346.2023.02.02.01.27.03; Thu, 02 Feb 2023 01:27:37 -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=HFf1Yg0h; 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 S232161AbjBBJYI (ORCPT + 99 others); Thu, 2 Feb 2023 04:24:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232004AbjBBJX7 (ORCPT ); Thu, 2 Feb 2023 04:23:59 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61BEC6F702 for ; Thu, 2 Feb 2023 01:23:57 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id lu11so4182908ejb.3 for ; Thu, 02 Feb 2023 01:23:57 -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=eJR3j7UgcHI8drkrJokvDJuY/mtil1DqdGHf4t4Su9s=; b=HFf1Yg0hiyf7Ud6/Vt8BibDYkQo2daDFPEzRUHOyb+CttMOo56Ev8Nw0q1kBnA3tly 5fKuFv3zk5LcnqlGRNae5lfl+iE+GKVrR92DTUpj1bTcj6OnZVbxXRYfRlxP6bsFBWli hHcAmvRRw9hjAG64KlevLHERnv3rn1OcuV68ak7avmw4DN7QQWIJBlr/6xpwQTYstimw tdRDqek2jERGQrZS6/hEUt2mSmUu9ugJInRStSh43SRza+qnsyPXNMApfDJzcJml6DKy /XQ5IzagkYFix8fFKXDE+2lpgr3zqzmauGMhL83Oi0IolTGUZi/aV7Fiu1tqKGwcVPa2 M1Rg== 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=eJR3j7UgcHI8drkrJokvDJuY/mtil1DqdGHf4t4Su9s=; b=mQUWZQ0jGhWq7QPgc67F+3Aw/NF6p9fdzaf5ujEl0g5XL9cG4GODHTlg7z8grtmynf h0PTDuVzljqIdnd2Mjpb/Yy8Z/FGNYWoAceMW1H3XdKyRQ55igET6dplWEbQkjJn63M0 rmmzOFWPrOjrxOLiQH3MdhTdSr5mr9QpvqGzQGFep0DAyArgW/qoO4V0hvvOHmgBG7cE jI7nSzXlNHW3zJUOCDK5v5+XkxAmthl4Y6icrq/o+eVFYaLQfFhsEij8N5HyiREFxPTt WF2h868XO2Mrnfp27YsAjyse2RXJcIWULB3jQfVBuhv+VKUUdHyiYNGNzZRQu0r4raF+ dxEA== X-Gm-Message-State: AO0yUKXDMzSf4TDQ8EPa4n187AEcrqw3FYkKUq+rxT47VZChgIFG6efg vKJnvQx6Ha4MyIl9MZYRCV41l2coGURdbAly X-Received: by 2002:a17:906:2a50:b0:888:c0b4:7f08 with SMTP id k16-20020a1709062a5000b00888c0b47f08mr5537360eje.29.1675329835902; Thu, 02 Feb 2023 01:23:55 -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 j4-20020a170906474400b00856ad9108e7sm11372658ejs.70.2023.02.02.01.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:23:55 -0800 (PST) From: Maarten Zanders To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Jacek Anaszewski Cc: Maarten Zanders , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] leds: lp55xx: configure internal charge pump Date: Thu, 2 Feb 2023 10:23:25 +0100 Message-Id: <20230202092325.21241-3-maarten.zanders@mind.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230202092325.21241-1-maarten.zanders@mind.be> References: <20230202092325.21241-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?1756710888225541385?= X-GMAIL-MSGID: =?utf-8?q?1756710891116995002?= 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 | 14 ++++++++++++++ drivers/leds/leds-lp8501.c | 8 ++++++-- include/linux/platform_data/leds-lp55xx.h | 3 +++ 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 19478d9c19a7..76c6b81afb38 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..086033860a6f 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -19,6 +19,8 @@ #include #include +#include + #include "leds-lp55xx-common.h" /* External clock rate */ @@ -691,6 +693,18 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, i++; } + ret = of_property_read_u8(np, "ti,charge-pump-mode", + &pdata->charge_pump_mode); + if (ret) { + pdata->charge_pump_mode = LP55XX_CP_AUTO; + } else { + if (pdata->charge_pump_mode > LP55XX_CP_AUTO) { + dev_err(dev, "invalid charge pump mode %d\n", + pdata->charge_pump_mode); + return ERR_PTR(-EINVAL); + } + } + 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..9a738979e1ce 100644 --- a/include/linux/platform_data/leds-lp55xx.h +++ b/include/linux/platform_data/leds-lp55xx.h @@ -73,6 +73,9 @@ struct lp55xx_platform_data { /* Clock configuration */ u8 clock_mode; + /* Charge pump mode */ + u8 charge_pump_mode; + /* optional enable GPIO */ struct gpio_desc *enable_gpiod;