From patchwork Fri Apr 7 10:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Zanders X-Patchwork-Id: 80735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp195564vqo; Fri, 7 Apr 2023 03:42:17 -0700 (PDT) X-Google-Smtp-Source: AKy350Zt+jmf5lN8FSQ73W3k+rz6Vnjyuf2bBOt6/Dd71c5dnM42Flcz8vbgpOWNYwU2vNlORqIh X-Received: by 2002:aa7:d605:0:b0:4fa:4bc4:a911 with SMTP id c5-20020aa7d605000000b004fa4bc4a911mr1782196edr.13.1680864137279; Fri, 07 Apr 2023 03:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680864137; cv=none; d=google.com; s=arc-20160816; b=0XwjlwLWMRN6kwippERzEs37BU6kscWRpIsH5wwCV3R7jYGPqqm7swE8SUMA5W0H24 3UyZSgq4nKgCo+nOWjQ++DJAAo9fT8R7XmiQ9G5gcDCbgG2JumGAEeisWKqiSBYgFWn2 1jtf/zfWBSct8SqOS4Gr72ACocvw2Ne6tr30qz2+4l/8XNGhDckLkaDqnaUsiiVF+u2e a+q9B3DPgiZNVH6//idCvzVKRf6kCYDJ+tp5pTWZ3UMseToJ1y0GF9JjR6F65q+z0Nkw 0+wuvsO8TL3mUn/RVMFDLXezcxHfir/11hg0HyCuMPJ8rLOebfUP5OggYgIG2bZdoOCF 5trg== 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=D+qP6sIqw2JeqwkoX2od0pG8BYiMF1HbH0eIPQIxtYc=; b=xnkotOdiWzPSpCTS33sp+OJPjK1a2IzfsluOKo3+h41rIcv1vSv2WcgTxp7DLZMkxC ht01Zj0UWYSgEh+Unwk8sW22PjyNU1y7/asLVtl7OYY1kfLU1ZRegi6tR96+sJT+vB/c jWaUJ4n41HluDh1e+bdIUOOY9/k1hCmo6Aua6f3ZghOD1AGaqD2fL3nwyg/H45Fz2ic5 2fDDY8Ko3YLuXOCzvbXWCSApjLAXp8c9pj253J2rN2NUdwWgsx7rDXEvWLBQgA7FjI5n 4YvMmdxrXXTuSMHR7j8H3xY2J1dSePSTQ/ojKzgj+PTYWhJQESaakkhfkj+Cj2goj6Br K2Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mind.be header.s=google header.b=MISQ9pXx; 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 z20-20020aa7d414000000b00501d48232ecsi2981875edq.404.2023.04.07.03.41.52; Fri, 07 Apr 2023 03:42:17 -0700 (PDT) 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=MISQ9pXx; 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 S240601AbjDGKXn (ORCPT + 99 others); Fri, 7 Apr 2023 06:23:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240532AbjDGKXh (ORCPT ); Fri, 7 Apr 2023 06:23:37 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EF0F7ED3 for ; Fri, 7 Apr 2023 03:23:35 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-947abd74b10so205203566b.2 for ; Fri, 07 Apr 2023 03:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; t=1680863014; 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=D+qP6sIqw2JeqwkoX2od0pG8BYiMF1HbH0eIPQIxtYc=; b=MISQ9pXx9p/bX0BTFfQPN8k20XhK3myDqo6ukjMGi8UDpiJXcKBaVlqcDVypW97kiA 7xeK2hntMRPZxOOrUNqI0hEAm5gQmU/EJ3DkmqB7llXWvVFJ4VsDk7ZAgxTtNdx/69TY wVNmQYQDzNE8xuzf86/SqRdMeOk1wMAHQ+H99ZpfTAMkAOO+MTCSAxwcOboAxEC6bqye ul9RiERuQsiH73XEPePNRy1uCvOKkR/XtNimCuo6xug2qeZUXBeQ2Kca3KV6gpwAH0pk qn0ywdgCJyVKN3qxIIjv8zW2VtB5bl+lbd9zUVnr255kxrzBuukhlQBwICvmQg3bJKGC wziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680863014; 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=D+qP6sIqw2JeqwkoX2od0pG8BYiMF1HbH0eIPQIxtYc=; b=oSO1RaA3pg7UEoFixbrCRqvpdfLoJ73qWLBTNRt/D4Ygj+A8KYeMvgO/8Ke61XFyQn SgoPvAdBc+zXuHlj+V/NhrAyzZL70a02Exl17HkPk7Ty8iIKzE0lzFW5lQZP4hVvN4Ia KE1qz8xi+l0QW/wn+j8uGwMZGbuv+8rdDTxf06SCyLi/GXGG+I3kZc7w86LGmEiuPM77 vb8Bl5TIytJfxJpjXhwxxlIu9Xj9YVu0/WlhTx/wbMRg/eeWU2F+P2sZFKeOUL3puPdN 0oTkoeNaBkXSoYGHGAvaa9QvqgTbfimLxD2gqO/dM4gH5mGyXxPW7QBUv90BROndQnt6 +S/Q== X-Gm-Message-State: AAQBX9fsvT3LhGFtYtcJFBuntlONIXV0m63WgmKOxU5Qv7HQBlYY3Oog jB6xv79ONVq9hL+K/iYlNdzrZw== X-Received: by 2002:a05:6402:1043:b0:4fe:9689:96bb with SMTP id e3-20020a056402104300b004fe968996bbmr1797741edu.35.1680863013998; Fri, 07 Apr 2023 03:23:33 -0700 (PDT) Received: from dtpc.zanders.be (78-22-137-109.access.telenet.be. [78.22.137.109]) by smtp.gmail.com with ESMTPSA id 7-20020a170906014700b00932fa67b48fsm1892612ejh.183.2023.04.07.03.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 03:23:33 -0700 (PDT) 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, Krzysztof Kozlowski Subject: [PATCH v7 1/2] dt-bindings: leds-lp55xx: add ti,charge-pump-mode Date: Fri, 7 Apr 2023 12:23:23 +0200 Message-Id: <20230407102324.42604-2-maarten.zanders@mind.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230407102324.42604-1-maarten.zanders@mind.be> References: <20230407102324.42604-1-maarten.zanders@mind.be> MIME-Version: 1.0 X-Spam-Status: No, score=0.1 required=5.0 tests=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?1762513793885541443?= X-GMAIL-MSGID: =?utf-8?q?1762513793885541443?= Add a binding to configure the internal charge pump for lp55xx. Signed-off-by: Maarten Zanders Reviewed-by: Krzysztof Kozlowski --- Notes: v1: implement as bool to disable charge pump v2: rewrite to use string configuration, supporting all modes v3: simplification by replacing string option by u8 constant, removing previous Reviewed-by tags as it's a complete rewrite of the patch. v4: added notes v5: dual license, change property type to u32 v6: change license type for leds-lp-55xx.h to preferred tag .../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..ede9cb9ca175 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/uint32 + 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 = ; 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..a4fb4567715d --- /dev/null +++ b/include/dt-bindings/leds/leds-lp55xx.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +#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 Fri Apr 7 10: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: 80736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp196156vqo; Fri, 7 Apr 2023 03:43:56 -0700 (PDT) X-Google-Smtp-Source: AKy350aSbqwH2I1c9q7qPegVjJEpok8qiDJK3hmEkz/4Ebodg5ITR7a5IGYLnO/aZGnnqyZbRKEm X-Received: by 2002:a17:906:858c:b0:947:3330:c97e with SMTP id v12-20020a170906858c00b009473330c97emr2168368ejx.71.1680864236181; Fri, 07 Apr 2023 03:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680864236; cv=none; d=google.com; s=arc-20160816; b=LSGTVDMU4pGDq9AE64nUj+4NFzb11l6zwnKID8MRNIuqCn6veHhVMciU5VaUvz46E7 OGgSYMhzaZlIauRLSXy1IJaQ+zdaCDjsYbPDkeEe3kCtt+mvdrbjtJ66qWjQspnZ1ePj QQdeQzr1i0aMAP0Ihakwb8dxZTUgurC8zmSwzYO8o5B6JIK+uc9Q7D6Xzb4qgl9Tc2Zq bjwOqE1w64tWYwDIqeQnK0PztjuL6Cg64RmsdiUh3DsAoEYmbwnknF7HmloiIcSNUag4 lHXvwUe4GbgfF0HYB2lgIkfkmnlhPUwGGqHHfR9IqHxe8ACgoZzg15HBiopN1/BaoLzR bmEg== 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=l0j80qcSlu23/jmLhtBdxoy8KmFI9uUDrbf0yBZqqYw=; b=k1LtqKskEKnYu3r2VUIo7208oU3mY+hl2X2AUN2+OhKJcdf01EC/L2dmFujeMdFlbl FV39jAgL5ONsZN4vBHH0punRnpesSPvZ1S7xRZvL2CBelTTz1Fm22IUrGEQ2r1rh01Wr hgCnuUS4V6vFEZ39oRw+P/nLbKN3CsZ9X8n8Z/kybqryRnQZInSdB1zl3D1NcRlqFcZS 1SONk8oYIj+sLkzql3I9XyaaHmhn6OHiEb+ZJFGGD7mmHFadMcJjjpXmiZva+cUeCgIi EpaX7mdeitsIR+o8wPZ6J/CaR3g2BRQxer2plxnij4joZTs9dmRdIaOIVKsW0ITsBsL8 trSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mind.be header.s=google header.b=NcN9T7rK; 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 d16-20020aa7ce10000000b004ad0993e54esi3028152edv.487.2023.04.07.03.43.31; Fri, 07 Apr 2023 03:43:56 -0700 (PDT) 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=NcN9T7rK; 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 S240615AbjDGKXt (ORCPT + 99 others); Fri, 7 Apr 2023 06:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240560AbjDGKXi (ORCPT ); Fri, 7 Apr 2023 06:23:38 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F3E74C05 for ; Fri, 7 Apr 2023 03:23:36 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id l17so7445012ejp.8 for ; Fri, 07 Apr 2023 03:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; t=1680863015; 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=l0j80qcSlu23/jmLhtBdxoy8KmFI9uUDrbf0yBZqqYw=; b=NcN9T7rKJnBfDCrFXM0/XyvJzBNjm6BecGFBGfw4nhb6Te9Wd4bt79bWvlYZEPhpfY HqczKjYYDVL9PayzVHgQCZpttGly0tPo6PWoVjPw+FWeeBXkESf7Kxt/HBxAzawE5FPU whSZ2kWs5eRKONsiLRdZ2JLZJDL6Z80dKbhtpRvkAdpb7z4OR0fWnipvHjanE++R//+S 5IgXIzMhP59dNWL+KHzbv17M22g0vCvLlYP0suwwtNeWvFCESS82qElqfmzVlSseGpM4 RcUTtUlr9Dp7/yDuqFWOKvbMZ87DxxJ0GVWoEhbiGAkelLt4DBP0zg/dTj62VoaX7OrN W3Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680863015; 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=l0j80qcSlu23/jmLhtBdxoy8KmFI9uUDrbf0yBZqqYw=; b=Jjl+1XcL7jSYS9NHavg9T5yxzB4861ODbjFHPITyg498+rDll5aaHX52J2hWO371/Y w60ED5PpkTB5y9MelbAy9mhAjOp8kX1kgSs+TGAGPk8CYviBpAS/oQTaSjUJJLnR2loA XuJ6nlzKOj0XPJ5z1TaoaGmKVS7uUYLaj1GVsoGklkCmQ6PSy1m3QsNxSp1RenS0yFOB eU+KWaB/WVJobvLNtvpDxdNQrTy5bPS2vtgrYP1IQ555ri+YTJO++S6pM+skkL7L27uc 9ZuL8YioOB79rmnWZEXGPNFYyx2XCTyUTu7uhzEChahVVyGEeWnrdtqevnt5PlsizUjv bzWg== X-Gm-Message-State: AAQBX9cUC/uuw2J0JPzK+XAqEmZNiUWpSbjeUSAtdjo17TY9V6hyT3Ok V6ZHQfuenHHRGLCEvaXIouol4Q== X-Received: by 2002:a17:906:1957:b0:878:7a0e:5730 with SMTP id b23-20020a170906195700b008787a0e5730mr1946570eje.56.1680863014924; Fri, 07 Apr 2023 03:23:34 -0700 (PDT) Received: from dtpc.zanders.be (78-22-137-109.access.telenet.be. [78.22.137.109]) by smtp.gmail.com with ESMTPSA id 7-20020a170906014700b00932fa67b48fsm1892612ejh.183.2023.04.07.03.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 03:23:34 -0700 (PDT) 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 v7 2/2] leds: lp55xx: configure internal charge pump Date: Fri, 7 Apr 2023 12:23:24 +0200 Message-Id: <20230407102324.42604-3-maarten.zanders@mind.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230407102324.42604-1-maarten.zanders@mind.be> References: <20230407102324.42604-1-maarten.zanders@mind.be> MIME-Version: 1.0 X-Spam-Status: No, score=0.1 required=5.0 tests=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?1762513897517388586?= X-GMAIL-MSGID: =?utf-8?q?1762513897517388586?= 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 --- Notes: v1: implement as bool to disable charge pump v2: rewrite to use string configuration, supporting all modes v3: simplification by replacing string from DTS by constant v4: added notes v5: property type to u32 v6: cleanup parsing of DT paramter v7: formatting drivers/leds/leds-lp5521.c | 11 +++++------ drivers/leds/leds-lp5523.c | 14 +++++++++----- drivers/leds/leds-lp55xx-common.c | 9 +++++++++ drivers/leds/leds-lp8501.c | 8 +++++--- include/linux/platform_data/leds-lp55xx.h | 3 +++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index a004af8e22c7..acd37d0f0e26 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,8 @@ 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 55da914b8e5c..a8df22938bdb 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -57,8 +57,11 @@ #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 +128,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 +137,10 @@ 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..77bb26906ea6 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "leds-lp55xx-common.h" @@ -691,6 +692,14 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, i++; } + if (of_property_read_u32(np, "ti,charge-pump-mode", &pdata->charge_pump_mode)) + pdata->charge_pump_mode = LP55XX_CP_AUTO; + + 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 165d6423a928..878d81dace8a 100644 --- a/drivers/leds/leds-lp8501.c +++ b/drivers/leds/leds-lp8501.c @@ -53,10 +53,10 @@ #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) +#define LP8501_DEFAULT_CFG (LP8501_PWM_PSAVE | LP8501_AUTO_INC | LP8501_PWR_SAVE) #define LP8501_REG_RESET 0x3D #define LP8501_RESET 0xFF @@ -102,6 +102,8 @@ 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..3cc8db0b12b5 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 */ + u32 charge_pump_mode; + /* optional enable GPIO */ struct gpio_desc *enable_gpiod;