Lines Matching full:pwm

3  * A simple sysfs interface for the generic PWM framework
15 #include <linux/pwm.h>
19 struct pwm_device *pwm; member
33 return export->pwm; in child_to_pwm_device()
40 const struct pwm_device *pwm = child_to_pwm_device(child); in period_show() local
43 pwm_get_state(pwm, &state); in period_show()
53 struct pwm_device *pwm = export->pwm; in period_store() local
63 pwm_get_state(pwm, &state); in period_store()
65 ret = pwm_apply_state(pwm, &state); in period_store()
75 const struct pwm_device *pwm = child_to_pwm_device(child); in duty_cycle_show() local
78 pwm_get_state(pwm, &state); in duty_cycle_show()
88 struct pwm_device *pwm = export->pwm; in duty_cycle_store() local
98 pwm_get_state(pwm, &state); in duty_cycle_store()
100 ret = pwm_apply_state(pwm, &state); in duty_cycle_store()
111 const struct pwm_device *pwm = child_to_pwm_device(child); in oneshot_count_show() local
114 pwm_get_state(pwm, &state); in oneshot_count_show()
124 struct pwm_device *pwm = export->pwm; in oneshot_count_store() local
134 pwm_get_state(pwm, &state); in oneshot_count_store()
136 ret = pwm_apply_state(pwm, &state); in oneshot_count_store()
147 const struct pwm_device *pwm = child_to_pwm_device(child); in enable_show() local
150 pwm_get_state(pwm, &state); in enable_show()
160 struct pwm_device *pwm = export->pwm; in enable_store() local
170 pwm_get_state(pwm, &state); in enable_store()
184 ret = pwm_apply_state(pwm, &state); in enable_store()
195 const struct pwm_device *pwm = child_to_pwm_device(child); in polarity_show() local
199 pwm_get_state(pwm, &state); in polarity_show()
219 struct pwm_device *pwm = export->pwm; in polarity_store() local
232 pwm_get_state(pwm, &state); in polarity_store()
234 ret = pwm_apply_state(pwm, &state); in polarity_store()
244 struct pwm_device *pwm = child_to_pwm_device(child); in capture_show() local
248 ret = pwm_capture(pwm, &result, jiffies_to_msecs(HZ)); in capture_show()
259 const struct pwm_device *pwm = child_to_pwm_device(child); in output_type_show() local
263 pwm_get_state(pwm, &state); in output_type_show()
300 ATTRIBUTE_GROUPS(pwm);
309 static int pwm_export_child(struct device *parent, struct pwm_device *pwm) in pwm_export_child() argument
315 if (test_and_set_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_export_child()
320 clear_bit(PWMF_EXPORTED, &pwm->flags); in pwm_export_child()
324 export->pwm = pwm; in pwm_export_child()
331 dev_set_name(&export->child, "pwm%u", pwm->hwpwm); in pwm_export_child()
335 clear_bit(PWMF_EXPORTED, &pwm->flags); in pwm_export_child()
340 pwm_prop[0] = kasprintf(GFP_KERNEL, "EXPORT=pwm%u", pwm->hwpwm); in pwm_export_child()
353 static int pwm_unexport_child(struct device *parent, struct pwm_device *pwm) in pwm_unexport_child() argument
358 if (!test_and_clear_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_unexport_child()
361 child = device_find_child(parent, pwm, pwm_unexport_match); in pwm_unexport_child()
365 pwm_prop[0] = kasprintf(GFP_KERNEL, "UNEXPORT=pwm%u", pwm->hwpwm); in pwm_unexport_child()
373 pwm_put(pwm); in pwm_unexport_child()
383 struct pwm_device *pwm; in export_store() local
394 pwm = pwm_request_from_chip(chip, hwpwm, "sysfs"); in export_store()
395 if (IS_ERR(pwm)) in export_store()
396 return PTR_ERR(pwm); in export_store()
398 ret = pwm_export_child(parent, pwm); in export_store()
400 pwm_put(pwm); in export_store()
446 struct pwm_device *pwm, in pwm_class_get_state() argument
452 if (!test_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_class_get_state()
455 child = device_find_child(parent, pwm, pwm_unexport_match); in pwm_class_get_state()
463 pwm_get_state(pwm, state); in pwm_class_get_state()
469 struct pwm_device *pwm, in pwm_class_apply_state() argument
472 int ret = pwm_apply_state(pwm, state); in pwm_class_apply_state()
487 struct pwm_device *pwm = &chip->pwms[i]; in pwm_class_resume_npwm() local
491 export = pwm_class_get_state(parent, pwm, &state); in pwm_class_resume_npwm()
496 ret = pwm_class_apply_state(export, pwm, &state); in pwm_class_resume_npwm()
511 struct pwm_device *pwm = &chip->pwms[i]; in pwm_class_suspend() local
515 export = pwm_class_get_state(parent, pwm, &state); in pwm_class_suspend()
521 ret = pwm_class_apply_state(export, pwm, &state); in pwm_class_suspend()
524 * roll back the PWM devices that were disabled by in pwm_class_suspend()
545 .name = "pwm",
583 struct pwm_device *pwm = &chip->pwms[i]; in pwmchip_sysfs_unexport() local
585 if (test_bit(PWMF_EXPORTED, &pwm->flags)) in pwmchip_sysfs_unexport()
586 pwm_unexport_child(parent, pwm); in pwmchip_sysfs_unexport()