Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e76a4c58 authored by Fenglin Wu's avatar Fenglin Wu Committed by Subbaraman Narayanamurthy
Browse files

pwm: qti-lpg: Specify LPG channel numbers with a property



Instead of parsing the LPG channel numbers from the register size cell,
define a property to specify the LPG channel numbers directly.

Change-Id: Ia41def7179440432625210831b6e621dd61c8985
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 81ea5e28
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -345,6 +345,7 @@
			reg = <0xb100 0x200>;
			reg-names = "lpg-base";
			#pwm-cells = <2>;
			qcom,num-lpg-channels = <2>;
		};

		pm8150b_hr_led: qcom,leds@d000 {
+1 −0
Original line number Diff line number Diff line
@@ -266,6 +266,7 @@
			reg = <0xb100 0x300>, <0xb000 0x100>;
			reg-names = "lpg-base", "lut-base";
			#pwm-cells = <2>;
			qcom,num-lpg-channels = <3>;
			qcom,lut-patterns = <0 10 20 30 40 50 60 70 80 90 100
						90 80 70 60 50 40 30 20 10 0>;
			lpg1 {
+32 −10
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "%s: " fmt, __func__
@@ -1022,13 +1022,9 @@ static const struct pwm_ops qpnp_lpg_pwm_ops = {
	.owner = THIS_MODULE,
};

static int qpnp_lpg_parse_dt(struct qpnp_lpg_chip *chip)
static int qpnp_get_lpg_channels(struct qpnp_lpg_chip *chip, u32 *base)
{
	struct device_node *child;
	struct qpnp_lpg_channel *lpg;
	struct lpg_ramp_config *ramp;
	int rc = 0, i;
	u32 base, length, lpg_chan_id, tmp;
	int rc;
	const __be32 *addr;

	addr = of_get_address(chip->dev->of_node, 0, NULL, NULL);
@@ -1037,10 +1033,36 @@ static int qpnp_lpg_parse_dt(struct qpnp_lpg_chip *chip)
		return -EINVAL;
	}

	base = be32_to_cpu(addr[0]);
	length = be32_to_cpu(addr[1]);
	*base = be32_to_cpu(addr[0]);
	rc = of_property_read_u32(chip->dev->of_node, "qcom,num-lpg-channels",
						&chip->num_lpgs);
	if (rc < 0) {
		dev_err(chip->dev, "Failed to get qcom,num-lpg-channels, rc=%d\n",
				rc);
		return rc;
	}

	if (chip->num_lpgs == 0) {
		dev_err(chip->dev, "No LPG channels specified\n");
		return -EINVAL;
	}

	return 0;
}

static int qpnp_lpg_parse_dt(struct qpnp_lpg_chip *chip)
{
	struct device_node *child;
	struct qpnp_lpg_channel *lpg;
	struct lpg_ramp_config *ramp;
	int rc = 0, i;
	u32 base, length, lpg_chan_id, tmp;
	const __be32 *addr;

	rc = qpnp_get_lpg_channels(chip, &base);
	if (rc < 0)
		return rc;

	chip->num_lpgs = length / REG_SIZE_PER_LPG;
	chip->lpgs = devm_kcalloc(chip->dev, chip->num_lpgs,
			sizeof(*chip->lpgs), GFP_KERNEL);
	if (!chip->lpgs)