svn commit: r349059 - head/sys/arm/allwinner
Ian Lepore
ian at FreeBSD.org
Sat Jun 15 16:56:01 UTC 2019
Author: ian
Date: Sat Jun 15 16:56:00 2019
New Revision: 349059
URL: https://svnweb.freebsd.org/changeset/base/349059
Log:
Don't call pwmbus_attach_bus(), because it may not be present if this
driver is compiled into the kernel but pwmbus will be loaded as a module
when needed (and because of that, pwmbus_attach_bus() is going away in
the near future). Instead, just directly do what that function did:
register the fdt xfef handle, and attach the pwmbus.
Modified:
head/sys/arm/allwinner/aw_pwm.c
Modified: head/sys/arm/allwinner/aw_pwm.c
==============================================================================
--- head/sys/arm/allwinner/aw_pwm.c Sat Jun 15 16:36:29 2019 (r349058)
+++ head/sys/arm/allwinner/aw_pwm.c Sat Jun 15 16:56:00 2019 (r349059)
@@ -138,6 +138,7 @@ aw_pwm_attach(device_t dev)
struct aw_pwm_softc *sc;
uint64_t clk_freq;
uint32_t reg;
+ phandle_t node;
int error;
sc = device_get_softc(dev);
@@ -158,9 +159,6 @@ aw_pwm_attach(device_t dev)
goto fail;
}
- if ((sc->busdev = pwmbus_attach_bus(dev)) == NULL)
- device_printf(dev, "Cannot attach pwm bus\n");
-
/* Read the configuration left by U-Boot */
reg = AW_PWM_READ(sc, AW_PWM_CTRL);
if (reg & (AW_PWM_CTRL_GATE | AW_PWM_CTRL_EN))
@@ -170,7 +168,7 @@ aw_pwm_attach(device_t dev)
reg &= AW_PWM_CTRL_PRESCALE_MASK;
if (reg > nitems(aw_pwm_clk_prescaler)) {
device_printf(dev, "Bad prescaler %x, cannot guess current settings\n", reg);
- goto out;
+ goto skipcfg;
}
clk_freq = sc->clk_freq / aw_pwm_clk_prescaler[reg];
@@ -180,9 +178,18 @@ aw_pwm_attach(device_t dev)
sc->duty = NS_PER_SEC /
(clk_freq / ((reg >> AW_PWM_PERIOD_ACTIVE_SHIFT) & AW_PWM_PERIOD_ACTIVE_MASK));
-out:
- return (0);
+skipcfg:
+ /*
+ * Note that we don't check for failure to attach pwmbus -- even without
+ * it we can still service clients who connect via fdt xref data.
+ */
+ node = ofw_bus_get_node(dev);
+ OF_device_register_xref(OF_xref_from_node(node), dev);
+ sc->busdev = device_add_child(dev, "pwmbus", -1);
+
+ return (bus_generic_attach(dev));
+
fail:
aw_pwm_detach(dev);
return (error);
@@ -196,7 +203,7 @@ aw_pwm_detach(device_t dev)
sc = device_get_softc(dev);
- if (((error = bus_generic_detach(sc->dev)) != 0) {
+ if ((error = bus_generic_detach(sc->dev)) != 0) {
device_printf(sc->dev, "cannot detach child devices\n");
return (error);
}
More information about the svn-src-all
mailing list