lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241012025603.1644451-3-florian.fainelli@broadcom.com>
Date: Fri, 11 Oct 2024 19:56:03 -0700
From: Florian Fainelli <florian.fainelli@...adcom.com>
To: linux-kernel@...r.kernel.org
Cc: Florian Fainelli <florian.fainelli@...adcom.com>,
	Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
	Rob Herring <robh+dt@...nel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>,
	Thierry Reding <thierry.reding@...il.com>,
	linux-pwm@...r.kernel.org (open list:PWM SUBSYSTEM),
	devicetree@...r.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS),
	linux-arm-kernel@...ts.infradead.org (moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE),
	justin.chen@...adcom.com
Subject: [PATCH 2/2] pwm: brcmstb: Do not assume open drain configuration

Read the 'open-drain' property to determine whether the PWM controller
output(s) should be configured in open-drain versus totem pole mode.

Fixes: 3a9f5957020f ("pwm: Add Broadcom BCM7038 PWM controller support")
Signed-off-by: Florian Fainelli <florian.fainelli@...adcom.com>
---
 drivers/pwm/pwm-brcmstb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-brcmstb.c b/drivers/pwm/pwm-brcmstb.c
index 0fdeb0b2dbf3..b7cecd36ed57 100644
--- a/drivers/pwm/pwm-brcmstb.c
+++ b/drivers/pwm/pwm-brcmstb.c
@@ -55,6 +55,7 @@ struct brcmstb_pwm {
 	void __iomem *base;
 	struct clk *clk;
 	struct pwm_chip chip;
+	bool open_drain;
 };
 
 static inline u32 brcmstb_pwm_readl(struct brcmstb_pwm *p,
@@ -176,6 +177,7 @@ static int brcmstb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 static inline void brcmstb_pwm_enable_set(struct brcmstb_pwm *p,
 					  unsigned int channel, bool enable)
 {
+	u32 oe_mask = p->open_drain ? CTRL_OPENDRAIN : 0;
 	unsigned int shift = channel * CTRL_CHAN_OFFS;
 	u32 value;
 
@@ -183,9 +185,9 @@ static inline void brcmstb_pwm_enable_set(struct brcmstb_pwm *p,
 
 	if (enable) {
 		value &= ~(CTRL_OEB << shift);
-		value |= (CTRL_START | CTRL_OPENDRAIN) << shift;
+		value |= (CTRL_START | oe_mask) << shift;
 	} else {
-		value &= ~((CTRL_START | CTRL_OPENDRAIN) << shift);
+		value &= ~((CTRL_START | oe_mask) << shift);
 		value |= CTRL_OEB << shift;
 	}
 
@@ -244,6 +246,7 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, p);
 
+	p->open_drain = device_property_read_bool(&pdev->dev, "open-drain");
 	p->chip.dev = &pdev->dev;
 	p->chip.ops = &brcmstb_pwm_ops;
 	p->chip.npwm = 2;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ