From patchwork Fri Oct 30 01:07:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 314743 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19451C2D0A3 for ; Fri, 30 Oct 2020 01:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF85C206FA for ; Fri, 30 Oct 2020 01:07:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YsM5NGvj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725372AbgJ3BHY (ORCPT ); Thu, 29 Oct 2020 21:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgJ3BHX (ORCPT ); Thu, 29 Oct 2020 21:07:23 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 402F8C0613CF for ; Thu, 29 Oct 2020 18:07:23 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id a9so5761362lfc.7 for ; Thu, 29 Oct 2020 18:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=svkaYU6ajBWIQXRUuQi7TLrUgDBVVF7XT8RieFVwa5U=; b=YsM5NGvjfQTAwilWsl3WGjGM5nIrqb2xs0GpR5M/nggqTK31ASTMPivCMunXBhJDFc nIVVfviYGA7kr8STx0QRbSHnsxaB3Ntz7bxgrBHa4RcBG4mRp8z6dwXn8i+FRW8FCYbd WhBMO/l/5KtfgWKQz/iCQou4XNNuftoJBuOQeUkF0QUGQuHbmT5bYylATbvNxWRJAWkT iNqn/3xrO4w0FsiJO12d6eWoLTOT2ZZFuLKYyxSu6hTXbaLaiZVpt+vDLTig1WVTn2r5 LNo5FYjCoXu1Rx0YlhjPIB30r2ExP3IwrxRkohvANR0p8cFBq56+XOIVE3l31gZY07w0 /7Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=svkaYU6ajBWIQXRUuQi7TLrUgDBVVF7XT8RieFVwa5U=; b=a24d0FGf9twfSoCF+3CkazcKwJpKKQLZrZsS5skjwd1QFXgIB9EMBHRoJ3E9MenN3/ LJb4Rm7INpgPJdvPhIDYZk2KPHkUV2ouVD9tZMAZL0PY7zZ6V1vjYDz9AtLmG6xnGPDf UouuKLj5MjpqBtvR284A2/bGiPrJgzSycQ5kGpPThqx+75TL9Hv84EqGamumZypiWKGv MivJRYv6VpS+UmcmYATQDx6bfLSvNOIFPjhahgjWTx2o8cKMlZh8YRvhZOe6gYozLupg 1WA84zyRniNOJJHXjNogCtwRt99kp8pFFaXw98dBPNhYD2BdL01tIAp+nf9wZ1vyD1ld hAuA== X-Gm-Message-State: AOAM5317VD9XAnr3BsqZAm1EAPyFhME+PKuZ7cGrI3Day6owplztwgId qWrwdh7BRHTO9JVfMkNdVpjA9w== X-Google-Smtp-Source: ABdhPJwMvsOIbT034PQyb3jOThXAm6KgIhvi9Vu+Ryv+A2byeW8wYOnhg/4P67PaGuZ5tcul8vhYag== X-Received: by 2002:a05:6512:2098:: with SMTP id t24mr2756947lfr.116.1604020041764; Thu, 29 Oct 2020 18:07:21 -0700 (PDT) Received: from eriador.lan ([188.162.64.219]) by smtp.gmail.com with ESMTPSA id c6sm447130lfm.226.2020.10.29.18.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 18:07:21 -0700 (PDT) From: Dmitry Baryshkov To: Bjorn Andersson , Pavel Machek , Dan Murphy Cc: linux-leds@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 2/5] leds: qcom-lpg: add support for pm8150[bl] leds Date: Fri, 30 Oct 2020 04:07:10 +0300 Message-Id: <20201030010713.247009-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030010713.247009-1-dmitry.baryshkov@linaro.org> References: <20201030010713.247009-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support for the LPG/PWM block found on newer PMICs: PM8150B and PM8150A/L. Signed-off-by: Dmitry Baryshkov --- drivers/leds/leds-qcom-lpg.c | 68 ++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-qcom-lpg.c b/drivers/leds/leds-qcom-lpg.c index 86131a65d2c5..4770fc46f312 100644 --- a/drivers/leds/leds-qcom-lpg.c +++ b/drivers/leds/leds-qcom-lpg.c @@ -48,6 +48,8 @@ struct lpg_data; * @lut_bitmap: allocation bitmap for LUT entries * @triled_base: base address of the TRILED block (optional) * @triled_src: power-source for the TRILED + * @triled_has_atc_ctl: true if there is TRI_LED_ATC_CTL register + * @triled_has_src_sel: true if there is TRI_LED_SRC_SEL register * @channels: list of PWM channels * @num_channels: number of @channels */ @@ -65,6 +67,8 @@ struct lpg { u32 triled_base; u32 triled_src; + bool triled_has_atc_ctl; + bool triled_has_src_sel; struct lpg_channel *channels; unsigned int num_channels; @@ -165,6 +169,8 @@ struct lpg_channel_data { * @lut_base: base address of LUT block * @lut_size: number of entries in LUT * @triled_base: base address of TRILED + * @triled_has_atc_ctl: true if there is TRI_LED_ATC_CTL register + * @triled_has_src_sel: true if there is TRI_LED_SRC_SEL register * @pwm_9bit_mask: bitmask for switching from 6bit to 9bit pwm * @num_channels: number of channels in LPG * @channels: list of channel initialization data @@ -173,6 +179,8 @@ struct lpg_data { unsigned int lut_base; unsigned int lut_size; unsigned int triled_base; + bool triled_has_atc_ctl; + bool triled_has_src_sel; unsigned int pwm_9bit_mask; int num_channels; struct lpg_channel_data *channels; @@ -986,18 +994,24 @@ static int lpg_init_triled(struct lpg *lpg) return 0; lpg->triled_base = lpg->data->triled_base; - - ret = of_property_read_u32(np, "qcom,power-source", &lpg->triled_src); - if (ret || lpg->triled_src == 2 || lpg->triled_src > 3) { - dev_err(lpg->dev, "invalid power source\n"); - return -EINVAL; + lpg->triled_has_atc_ctl = lpg->data->triled_has_atc_ctl; + lpg->triled_has_src_sel = lpg->data->triled_has_src_sel; + + if (lpg->triled_has_src_sel) { + ret = of_property_read_u32(np, "qcom,power-source", &lpg->triled_src); + if (ret || lpg->triled_src == 2 || lpg->triled_src > 3) { + dev_err(lpg->dev, "invalid power source\n"); + return -EINVAL; + } } /* Disable automatic trickle charge LED */ - regmap_write(lpg->map, lpg->triled_base + TRI_LED_ATC_CTL, 0); + if (lpg->triled_has_atc_ctl) + regmap_write(lpg->map, lpg->triled_base + TRI_LED_ATC_CTL, 0); /* Configure power source */ - regmap_write(lpg->map, lpg->triled_base + TRI_LED_SRC_SEL, lpg->triled_src); + if (lpg->triled_has_src_sel) + regmap_write(lpg->map, lpg->triled_base + TRI_LED_SRC_SEL, lpg->triled_src); /* Default all outputs to off */ regmap_write(lpg->map, lpg->triled_base + TRI_LED_EN_CTL, 0); @@ -1099,6 +1113,8 @@ static const struct lpg_data pm8941_lpg_data = { .lut_size = 64, .triled_base = 0xd000, + .triled_has_atc_ctl = true, + .triled_has_src_sel = true, .pwm_9bit_mask = 3 << 4, @@ -1137,6 +1153,8 @@ static const struct lpg_data pmi8994_lpg_data = { .lut_size = 24, .triled_base = 0xd000, + .triled_has_atc_ctl = true, + .triled_has_src_sel = true, .pwm_9bit_mask = BIT(4), @@ -1166,12 +1184,48 @@ static const struct lpg_data pmi8998_lpg_data = { }, }; +static const struct lpg_data pm8150b_lpg_data = { + .lut_base = 0xb000, + .lut_size = 49, + + .triled_base = 0xd000, + + .pwm_9bit_mask = BIT(4), + + .num_channels = 2, + .channels = (struct lpg_channel_data[]) { + { .base = 0xb100, .triled_mask = BIT(7) }, + { .base = 0xb200, .triled_mask = BIT(6) }, + }, +}; + +static const struct lpg_data pm8150l_lpg_data = { + .lut_base = 0xb000, + .lut_size = 49, + + .triled_base = 0xd000, + + .pwm_9bit_mask = BIT(4), + + .num_channels = 5, + .channels = (struct lpg_channel_data[]) { + { .base = 0xb100, .triled_mask = BIT(7) }, + { .base = 0xb200, .triled_mask = BIT(6) }, + { .base = 0xb300, .triled_mask = BIT(5) }, + { .base = 0xbc00 }, + { .base = 0xbd00 }, + + }, +}; + static const struct of_device_id lpg_of_table[] = { { .compatible = "qcom,pm8916-pwm", .data = &pm8916_pwm_data }, { .compatible = "qcom,pm8941-lpg", .data = &pm8941_lpg_data }, { .compatible = "qcom,pm8994-lpg", .data = &pm8994_lpg_data }, { .compatible = "qcom,pmi8994-lpg", .data = &pmi8994_lpg_data }, { .compatible = "qcom,pmi8998-lpg", .data = &pmi8998_lpg_data }, + { .compatible = "qcom,pm8150b-lpg", .data = &pm8150b_lpg_data }, + { .compatible = "qcom,pm8150l-lpg", .data = &pm8150l_lpg_data }, {} }; MODULE_DEVICE_TABLE(of, lpg_of_table); From patchwork Fri Oct 30 01:07:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 314742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA9C7C2D0A3 for ; Fri, 30 Oct 2020 01:07:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C9762151B for ; Fri, 30 Oct 2020 01:07:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EiSlkpd0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726140AbgJ3BH0 (ORCPT ); Thu, 29 Oct 2020 21:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbgJ3BH0 (ORCPT ); Thu, 29 Oct 2020 21:07:26 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF0CCC0613D2 for ; Thu, 29 Oct 2020 18:07:25 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id j30so5760067lfp.4 for ; Thu, 29 Oct 2020 18:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y68c1c7Z13VLVISWQSjGtMfYfdgX0kCBgReV2FtuTdM=; b=EiSlkpd0XH2unr8aJvY/q6JTRASNiATl26sdbbRIjuwr/d5hZJP6EdRnKQYTegfrpm 0mKW9u4t9m8mXIbG8sycs74KNYqwfLoHQkQ3k5GJNkUiB7a8zxQfCqG1jyrS6/qBvaTK HGx0w+GlihSwPT08jKop1iZe4IsurKZXEZXMbGeRRsHfodMn1LxmUYq4sVwXH44OfzTO LY1Ct0OJZckvjhjK+FQpKViA1g44z2XVzpAPw2qZjb8/WraH89RxrWDrwL0H8CbH6Fnw P7WieOfF9Oe5Xd25P5PA/irE3DKZ2H8knSpkok3DdgIRYTvQPj0DOXHsRPUc1sBIJnaz ZUlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y68c1c7Z13VLVISWQSjGtMfYfdgX0kCBgReV2FtuTdM=; b=j8bMYMPj89r+yHxoXwgeSJZcqSXI1i59y4UGCNOGOndKUkFZb7UMNrYIK19trVK3Oy C/sKp7dclof1qqYE2M7G4Uu+nzmHQfg4PLT6nzUrjkxlS9GCLxwwMhVHk0Ba5767hXpw r2e2bX/SDt4JR0ojO7svqXYGoLZyDRAY/DQkA1B8PMnoDBygmKw9baeHc0khGUlf5U0U pet05k2SNNRA+6DSG0ots3Mfq1+qdypi/37vWBG+5I4JgaQK65HaAPHElXXU0vu/NZ9y gck67nUyXbtk4IBn9XYpaxH8BQxJy7at/FB7OiAktrETeXYzhmxj9bOuX6rWsrmXT8Mr /iJQ== X-Gm-Message-State: AOAM532d8yFwMf+GqW4WhsLzAz2hNbjnc7F7nT/AaT7RvkAaz+vTzb8O 5wSVi1MPpkWO3pJDzgiMQ4KO6A== X-Google-Smtp-Source: ABdhPJyyl9s5LApPFxXLIlRSqMYgSw7DuZRZYl7P1j6O1xPT1cHbru5qAA46BRXkKwMt9T4WVysPIQ== X-Received: by 2002:a05:6512:2154:: with SMTP id s20mr2819398lfr.467.1604020044443; Thu, 29 Oct 2020 18:07:24 -0700 (PDT) Received: from eriador.lan ([188.162.64.219]) by smtp.gmail.com with ESMTPSA id c6sm447130lfm.226.2020.10.29.18.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 18:07:23 -0700 (PDT) From: Dmitry Baryshkov To: Bjorn Andersson , Pavel Machek , Dan Murphy Cc: linux-leds@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 4/5] arm64: dts: pm8150l: add Light Pulse Generator device node Date: Fri, 30 Oct 2020 04:07:12 +0300 Message-Id: <20201030010713.247009-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030010713.247009-1-dmitry.baryshkov@linaro.org> References: <20201030010713.247009-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add device node defining LPG/PWM block on PM8150L PMIC chip. Signed-off-by: Dmitry Baryshkov --- arch/arm64/boot/dts/qcom/pm8150l.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/pm8150l.dtsi b/arch/arm64/boot/dts/qcom/pm8150l.dtsi index 9f214ceec2b7..e8926d6c32cb 100644 --- a/arch/arm64/boot/dts/qcom/pm8150l.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150l.dtsi @@ -114,5 +114,15 @@ pmic@5 { reg = <0x5 SPMI_USID>; #address-cells = <1>; #size-cells = <0>; + + pm8150l_lpg: lpg { + compatible = "qcom,pm8150l-lpg"; + + #address-cells = <1>; + #size-cells = <0>; + + status = "disabled"; + }; + }; };