From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
Pavel Machek <pavel@ucw.cz>, Dan Murphy <dmurphy@ti.com>
Cc: Rob Herring <robh+dt@kernel.org>,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-msm@vger.kernel.org
Subject: [PATCH 2/5] leds: qcom-lpg: add support for pm8150[bl] leds
Date: Thu, 22 Oct 2020 01:50:57 +0300 [thread overview]
Message-ID: <20201021225100.162795-3-dmitry.baryshkov@linaro.org> (raw)
In-Reply-To: <20201021225100.162795-1-dmitry.baryshkov@linaro.org>
Add support for the LPG/PWM block found on newer PMICs: PM8150B and
PM8150A/L.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
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..4d24e0c973d6 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_no_atc_ctl: true if there is no TRI_LED_ATC_CTL register
+ * @triled_no_src_sel: true if there is no 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_no_atc_ctl;
+ bool triled_no_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_no_atc_ctl: true if there is no TRI_LED_ATC_CTL register
+ * @triled_no_src_sel: true if there is no 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_no_atc_ctl;
+ bool triled_no_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_no_atc_ctl = lpg->data->triled_no_atc_ctl;
+ lpg->triled_no_src_sel = lpg->data->triled_no_src_sel;
+
+ if (!lpg->triled_no_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_no_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_no_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);
@@ -1166,12 +1180,52 @@ 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,
+ .triled_no_atc_ctl = true,
+ .triled_no_src_sel = true,
+
+ .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,
+ .triled_no_atc_ctl = true,
+ .triled_no_src_sel = true,
+
+ .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);
--
2.28.0
next prev parent reply other threads:[~2020-10-21 22:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 22:50 [PATCH 0/5] Qualcomm LPG support for PM8150b/l Dmitry Baryshkov
2020-10-21 22:50 ` [PATCH 1/5] dt-bindings: leds: leds-qcom-lpg: add pm8150[bl] compatible strings Dmitry Baryshkov
2020-10-23 16:28 ` Rob Herring
2020-10-21 22:50 ` Dmitry Baryshkov [this message]
2020-10-29 18:16 ` [PATCH 2/5] leds: qcom-lpg: add support for pm8150[bl] leds Pavel Machek
2020-10-21 22:50 ` [PATCH 3/5] arm64: dts: pm8150b: add Light Pulse Generator device node Dmitry Baryshkov
2020-10-21 22:50 ` [PATCH 4/5] arm64: dts: pm8150l: " Dmitry Baryshkov
2020-10-21 22:51 ` [PATCH 5/5] arm64: dts: qrb5165-rb5: declare tri-led user leds Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201021225100.162795-3-dmitry.baryshkov@linaro.org \
--to=dmitry.baryshkov@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dmurphy@ti.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).