Lines Matching +full:- +full:36000

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
67 { "allwinner,sun5i-a13-pwm", 1 },
68 { "allwinner,sun8i-h3-pwm", 1 },
74 { -1, 0 }
101 36000,
109 #define AW_PWM_READ(sc, reg) bus_read_4((sc)->res, (reg))
110 #define AW_PWM_WRITE(sc, reg, val) bus_write_4((sc)->res, (reg), (val))
122 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) in aw_pwm_probe()
139 sc->dev = dev; in aw_pwm_attach()
141 error = clk_get_by_ofw_index(dev, 0, 0, &sc->clk); in aw_pwm_attach()
146 error = clk_enable(sc->clk); in aw_pwm_attach()
152 error = clk_get_freq(sc->clk, &sc->clk_freq); in aw_pwm_attach()
158 if (bus_alloc_resources(dev, aw_pwm_spec, &sc->res) != 0) { in aw_pwm_attach()
164 /* Read the configuration left by U-Boot */ in aw_pwm_attach()
167 sc->enabled = true; in aw_pwm_attach()
175 clk_freq = sc->clk_freq / aw_pwm_clk_prescaler[reg]; in aw_pwm_attach()
178 sc->period = NS_PER_SEC / in aw_pwm_attach()
180 sc->duty = NS_PER_SEC / in aw_pwm_attach()
185 * Note that we don't check for failure to attach pwmbus -- even without in aw_pwm_attach()
191 sc->busdev = device_add_child(dev, "pwmbus", DEVICE_UNIT_ANY); in aw_pwm_attach()
209 if ((error = bus_generic_detach(sc->dev)) != 0) { in aw_pwm_detach()
210 device_printf(sc->dev, "cannot detach child devices\n"); in aw_pwm_detach()
214 if (sc->busdev != NULL) in aw_pwm_detach()
215 device_delete_child(dev, sc->busdev); in aw_pwm_detach()
217 if (sc->res != NULL) in aw_pwm_detach()
218 bus_release_resources(dev, aw_pwm_spec, &sc->res); in aw_pwm_detach()
260 * FIXME. The hardware is capable of sub-Hz frequencies, that is, in aw_pwm_channel_config()
274 device_printf(sc->dev, "duty < period\n"); in aw_pwm_channel_config()
282 if ((div - 1) > AW_PWM_PERIOD_TOTAL_MASK) { in aw_pwm_channel_config()
288 if ((div - 1) < AW_PWM_PERIOD_TOTAL_MASK ) { in aw_pwm_channel_config()
313 reg = ((clk_rate / period_freq - 1) << AW_PWM_PERIOD_TOTAL_SHIFT) | in aw_pwm_channel_config()
317 sc->period = period; in aw_pwm_channel_config()
318 sc->duty = duty; in aw_pwm_channel_config()
330 *period = sc->period; in aw_pwm_channel_get_config()
331 *duty = sc->duty; in aw_pwm_channel_get_config()
344 if (enable && sc->enabled) in aw_pwm_channel_enable()
355 sc->enabled = enable; in aw_pwm_channel_enable()
367 *enabled = sc->enabled; in aw_pwm_channel_is_enabled()