Lines Matching +full:data +full:- +full:rate
4 * SPDX-License-Identifier: Apache-2.0
15 #include <zephyr/dt-bindings/pwm/pwm.h>
39 struct clock_control_pwm_data *data = dev->data; in clock_control_pwm_on() local
40 const struct clock_control_pwm_config *config = dev->config; in clock_control_pwm_on()
46 return -EINVAL; in clock_control_pwm_on()
49 spec = &config->pwm_dt; in clock_control_pwm_on()
50 if (data->clock_frequency == 0) { in clock_control_pwm_on()
51 ret = pwm_set_dt(spec, spec->period, spec->period / 2); in clock_control_pwm_on()
56 ret = pwm_get_cycles_per_sec(spec->dev, spec->channel, &cycles_per_sec); in clock_control_pwm_on()
61 if (cycles_per_sec % data->clock_frequency > 0) { in clock_control_pwm_on()
65 period_cycles = cycles_per_sec / data->clock_frequency; in clock_control_pwm_on()
66 ret = pwm_set_cycles(spec->dev, spec->channel, period_cycles, period_cycles / 2, in clock_control_pwm_on()
67 spec->flags); in clock_control_pwm_on()
74 k_busy_wait(config->pwm_on_delay); in clock_control_pwm_on()
76 data->is_enabled = true; in clock_control_pwm_on()
82 uint32_t *rate) in clock_control_pwm_get_rate() argument
84 struct clock_control_pwm_data *data = dev->data; in clock_control_pwm_get_rate() local
85 const struct clock_control_pwm_config *config = dev->config; in clock_control_pwm_get_rate()
89 return -EINVAL; in clock_control_pwm_get_rate()
92 if (data->clock_frequency > 0) { in clock_control_pwm_get_rate()
93 *rate = data->clock_frequency; in clock_control_pwm_get_rate()
95 *rate = NSEC_PER_SEC / config->pwm_dt.period; in clock_control_pwm_get_rate()
102 clock_control_subsys_rate_t rate) in clock_control_pwm_set_rate() argument
104 struct clock_control_pwm_data *data = dev->data; in clock_control_pwm_set_rate() local
105 uint32_t rate_hz = (uint32_t)rate; in clock_control_pwm_set_rate()
109 return -EINVAL; in clock_control_pwm_set_rate()
112 if (data->clock_frequency == rate_hz && data->is_enabled) { in clock_control_pwm_set_rate()
113 return -EALREADY; in clock_control_pwm_set_rate()
116 data->clock_frequency = rate_hz; in clock_control_pwm_set_rate()
123 const struct clock_control_pwm_config *config = dev->config; in clock_control_pwm_init()
125 if (!device_is_ready(config->pwm_dt.dev)) { in clock_control_pwm_init()
126 return -ENODEV; in clock_control_pwm_init()
144 "Maximum pwm-on-delay is 65535 usec"); \