From patchwork Fri Mar 31 11:46:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Zanders X-Patchwork-Id: 669326 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 989CDC6FD18 for ; Fri, 31 Mar 2023 11:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbjCaLq2 (ORCPT ); Fri, 31 Mar 2023 07:46:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbjCaLq1 (ORCPT ); Fri, 31 Mar 2023 07:46:27 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 816721880F for ; Fri, 31 Mar 2023 04:46:24 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id l37so12712039wms.2 for ; Fri, 31 Mar 2023 04:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; t=1680263183; 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=tp0bQBGHYjKTuRic3MsMDsz+T3FR9akl0OtuVCzd3i4=; b=JedSWSOfZZ24OTE4VJks/iYjrqIdejInO2k/lAoN8EmAtHt8c5tBwqAyCYDsPMNgZP KoHrGpJo9aDHSFmHh1aiByqEfpcBXPlkj3hbFX+lWAXNiTal41v6St+3e8qdKOPZwVi0 FgU1TtlH/rXf/iwMgaY7kDX+qP1LIwWAG6K8CEs8d/g2BekLhVnTmWBcG9koHiI43240 epCM1eMNfvYtrmoa+82xO2Pblw6xwGPIGT4vsIICQ9efDFNbRUlPAT2a101oB7MJMW8j /cg0229nrzv4qAQ73hzA171fOahp6upneR9ImT4lcnf5FqXCuezkdQLhhtEVm97aI34r tiPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680263183; 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=tp0bQBGHYjKTuRic3MsMDsz+T3FR9akl0OtuVCzd3i4=; b=nRHpT+Mv/5ELUKwwFql8TjRoysylsEqEPhvQW07gLLULBOj8JCe11RbJdoV5TcLekI Fy37i8I2VFdZmXuWATgCh/QF3hDmaUn2RU3ZkAJiiU1VuLo+6c+hipk3C54ZQItv55S8 dvUfJS9gUnIcvEh6xjxsfADnGGq/COSGDGnj0TwRR3VIutJrd2b0hNtI40h/HIFIpv18 J0cBpwYFeTE+fI5JQzjjXsAmBBnzhHRiHxcTCgQm5WS0rE5DBn/a+MhV6uXfg678NwsB h9eMFC+gLDv1RuFIQ2G7R2n9dPWzJu0Snwq362MuXoiosAfW6Jj4Gx1RNMjE6GSMLuW+ R7lQ== X-Gm-Message-State: AO0yUKW/5qCIfzkg4BZw1yeGUamgqbrlQloJStj66alkD3M/U8CtHSDz xZikxSUrdK5ct7KViS/JnkI7+BGBa3EwehOOPzA= X-Google-Smtp-Source: AK7set9zfciG1AVfHJnlG1MQ7hAvTulifoxLjTy5rrmaqLodSY17MQXtxHB75C+UTkto5RdQWThAyw== X-Received: by 2002:a05:600c:2214:b0:3ee:289a:43a7 with SMTP id z20-20020a05600c221400b003ee289a43a7mr23073173wml.22.1680263183009; Fri, 31 Mar 2023 04:46:23 -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 s17-20020a7bc391000000b003edef091b17sm2404017wmj.37.2023.03.31.04.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 04:46:22 -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 v6 1/2] dt-bindings: leds-lp55xx: add ti,charge-pump-mode Date: Fri, 31 Mar 2023 13:46:09 +0200 Message-Id: <20230331114610.48111-2-maarten.zanders@mind.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230331114610.48111-1-maarten.zanders@mind.be> References: <20230331114610.48111-1-maarten.zanders@mind.be> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org 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..e2256312714b --- /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 Mar 31 11:46:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Zanders X-Patchwork-Id: 669941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A485CC76196 for ; Fri, 31 Mar 2023 11:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbjCaLqc (ORCPT ); Fri, 31 Mar 2023 07:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231722AbjCaLqb (ORCPT ); Fri, 31 Mar 2023 07:46:31 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 758E71BF5C for ; Fri, 31 Mar 2023 04:46:25 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id l37so12712067wms.2 for ; Fri, 31 Mar 2023 04:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; t=1680263184; 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=vsntl9VyZ1WBCTPEmSMfSmA0WsJwJPeY+ZORBqnW36M=; b=GEGEAC8yl/LYBGzYoAI+k0nZW2mrk1FBTb1bwxVGmD7+cAT44NBlD+rEODwd65z7ku kdw4o2KZjDRnt+/TCXlnUs1IiAwObSOn1hsCSuKIBRn+l9ycsr9h0WH+Z+Z1pubPgEOO O+TsMk8to1963Cv2nQL24NNtv9Aj/OIHTPtX/GRmIHjQLpXfOGYrc1KFbdiPygxYrW3H DwtPpLDuo0hljmCWs++dd7AHjJA/6MgLUD/GU2kIv02xylJX7KT3oEDhNmQrsRaVUKyz gHrgBGonyjhhWIbwGnb5v0X7yG9gdJIvVvleGSxwiCGcnbMjvuOtrVo21MykhLdvZfbA h+3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680263184; 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=vsntl9VyZ1WBCTPEmSMfSmA0WsJwJPeY+ZORBqnW36M=; b=cxBCvE9IiMwkBEpmE18zqOxXf/JVGSqIQRMumPMLe9ogcvnJanvWFRhRxXOfZlUcdK 8f1rIDmND8PDMWfEQWq7pUbNSJI4WULQgxYRBbv20v8x7yB4thf9zvnwxweiizsoQYqG Q9R7ZUORSVIlavZdzrBfhKtmh9MZt/nEEvTzhqldiSTFPaCrHa7/mgtnH5EVr1Kef9T+ ErMiWLWzHcAT3DayS+kwn/8vrY45RHQRvWgYQ+vK7W/w8mZE5DiHBDfRUUSx/ieXhIt5 PvX6etEXvi2/VzV+3DoiI8QAqkX+ifIA/0OGAXsV2Zhq61cRG2xQMoWG3FAmh3Y/SBLh qWrA== X-Gm-Message-State: AO0yUKWreyIYBGa/V4Q6hi8ebnaS3TuMaaOIaTQOgesEkS6YrxvfYfVQ +Djs7Eb65HGm2xxuHPd28HMHPQ== X-Google-Smtp-Source: AK7set8OTi2Xa7XPGd5RLBUaiux40QYVJVfSiZxMzcsvVGXqfJX5D6GfPMKqU/PlU7lINC8hPFXp0A== X-Received: by 2002:a7b:cbcc:0:b0:3ee:1afc:c14 with SMTP id n12-20020a7bcbcc000000b003ee1afc0c14mr20499187wmi.11.1680263183955; Fri, 31 Mar 2023 04:46:23 -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 s17-20020a7bc391000000b003edef091b17sm2404017wmj.37.2023.03.31.04.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 04:46:23 -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 v6 2/2] leds: lp55xx: configure internal charge pump Date: Fri, 31 Mar 2023 13:46:10 +0200 Message-Id: <20230331114610.48111-3-maarten.zanders@mind.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230331114610.48111-1-maarten.zanders@mind.be> References: <20230331114610.48111-1-maarten.zanders@mind.be> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org 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 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, 39 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..5a02c4a4ec98 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,16 @@ 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 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..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;