Lines Matching full:pwm

9 #define DEFAULT_SYMBOL_NAMESPACE "PWM"
15 #include <linux/pwm.h>
24 #include <dt-bindings/pwm/pwm.h>
27 #include <trace/events/pwm.h>
163 static int __pwm_round_waveform_tohw(struct pwm_chip *chip, struct pwm_device *pwm, in __pwm_round_waveform_tohw() argument
169 ret = ops->round_waveform_tohw(chip, pwm, wf, wfhw); in __pwm_round_waveform_tohw()
170 trace_pwm_round_waveform_tohw(pwm, wf, wfhw, ret); in __pwm_round_waveform_tohw()
175 static int __pwm_round_waveform_fromhw(struct pwm_chip *chip, struct pwm_device *pwm, in __pwm_round_waveform_fromhw() argument
181 ret = ops->round_waveform_fromhw(chip, pwm, wfhw, wf); in __pwm_round_waveform_fromhw()
182 trace_pwm_round_waveform_fromhw(pwm, wfhw, wf, ret); in __pwm_round_waveform_fromhw()
187 static int __pwm_read_waveform(struct pwm_chip *chip, struct pwm_device *pwm, void *wfhw) in __pwm_read_waveform() argument
192 ret = ops->read_waveform(chip, pwm, wfhw); in __pwm_read_waveform()
193 trace_pwm_read_waveform(pwm, wfhw, ret); in __pwm_read_waveform()
198 static int __pwm_write_waveform(struct pwm_chip *chip, struct pwm_device *pwm, const void *wfhw) in __pwm_write_waveform() argument
203 ret = ops->write_waveform(chip, pwm, wfhw); in __pwm_write_waveform()
204 trace_pwm_write_waveform(pwm, wfhw, ret); in __pwm_write_waveform()
214 * @pwm: PWM device
233 * the input waveform under the PWM rounding rules or a negative errno.
235 int pwm_round_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf) in pwm_round_waveform_might_sleep() argument
237 struct pwm_chip *chip = pwm->chip; in pwm_round_waveform_might_sleep()
256 ret_tohw = __pwm_round_waveform_tohw(chip, pwm, wf, wfhw); in pwm_round_waveform_might_sleep()
264 ret_fromhw = __pwm_round_waveform_fromhw(chip, pwm, wfhw, wf); in pwm_round_waveform_might_sleep()
285 * @pwm: PWM device
288 * Stores the current configuration of the PWM in @wf. Note this is the
291 int pwm_get_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf) in pwm_get_waveform_might_sleep() argument
293 struct pwm_chip *chip = pwm->chip; in pwm_get_waveform_might_sleep()
308 err = __pwm_read_waveform(chip, pwm, &wfhw); in pwm_get_waveform_might_sleep()
312 return __pwm_round_waveform_fromhw(chip, pwm, &wfhw, wf); in pwm_get_waveform_might_sleep()
317 static int __pwm_set_waveform(struct pwm_device *pwm, in __pwm_set_waveform() argument
321 struct pwm_chip *chip = pwm->chip; in __pwm_set_waveform()
335 err = __pwm_round_waveform_tohw(chip, pwm, wf, &wfhw); in __pwm_set_waveform()
340 err = __pwm_round_waveform_fromhw(chip, pwm, &wfhw, &wf_rounded); in __pwm_set_waveform()
358 err = __pwm_write_waveform(chip, pwm, &wfhw); in __pwm_set_waveform()
363 pwm_wf2state(wf, &pwm->state); in __pwm_set_waveform()
368 err = __pwm_read_waveform(chip, pwm, &wfhw); in __pwm_set_waveform()
373 err = __pwm_round_waveform_fromhw(chip, pwm, &wfhw, &wf_set); in __pwm_set_waveform()
391 * @pwm: PWM device
405 int pwm_set_waveform_might_sleep(struct pwm_device *pwm, in pwm_set_waveform_might_sleep() argument
408 struct pwm_chip *chip = pwm->chip; in pwm_set_waveform_might_sleep()
424 err = __pwm_set_waveform(pwm, wf, exact); in pwm_set_waveform_might_sleep()
427 err = __pwm_set_waveform(pwm, wf, exact); in pwm_set_waveform_might_sleep()
434 static void pwm_apply_debug(struct pwm_device *pwm, in pwm_apply_debug() argument
437 struct pwm_state *last = &pwm->last; in pwm_apply_debug()
438 struct pwm_chip *chip = pwm->chip; in pwm_apply_debug()
454 err = chip->ops->get_state(chip, pwm, &s1); in pwm_apply_debug()
455 trace_pwm_get(pwm, &s1, err); in pwm_apply_debug()
517 err = chip->ops->apply(chip, pwm, &s1); in pwm_apply_debug()
518 trace_pwm_apply(pwm, &s1, err); in pwm_apply_debug()
526 err = chip->ops->get_state(chip, pwm, last); in pwm_apply_debug()
527 trace_pwm_get(pwm, last, err); in pwm_apply_debug()
564 * __pwm_apply() - atomically apply a new state to a PWM device
565 * @pwm: PWM device
568 static int __pwm_apply(struct pwm_device *pwm, const struct pwm_state *state) in __pwm_apply() argument
574 if (!pwm || !state) in __pwm_apply()
586 if (!pwm_state_valid(&pwm->state)) { in __pwm_apply()
587 pwm->state = *state; in __pwm_apply()
594 chip = pwm->chip; in __pwm_apply()
597 if (state->period == pwm->state.period && in __pwm_apply()
598 state->duty_cycle == pwm->state.duty_cycle && in __pwm_apply()
599 state->polarity == pwm->state.polarity && in __pwm_apply()
600 state->enabled == pwm->state.enabled && in __pwm_apply()
601 state->usage_power == pwm->state.usage_power) in __pwm_apply()
616 * .round_waveform_tohw() rounds down the time the PWM is high. in __pwm_apply()
621 err = __pwm_round_waveform_tohw(chip, pwm, &wf, &wfhw); in __pwm_apply()
637 err = __pwm_round_waveform_fromhw(chip, pwm, &wfhw, &wf_rounded); in __pwm_apply()
647 err = __pwm_write_waveform(chip, pwm, &wfhw); in __pwm_apply()
651 pwm->state = *state; in __pwm_apply()
654 err = ops->apply(chip, pwm, state); in __pwm_apply()
655 trace_pwm_apply(pwm, state, err); in __pwm_apply()
659 pwm->state = *state; in __pwm_apply()
662 * only do this after pwm->state was applied as some in __pwm_apply()
665 pwm_apply_debug(pwm, state); in __pwm_apply()
672 * pwm_apply_might_sleep() - atomically apply a new state to a PWM device
674 * @pwm: PWM device
677 int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) in pwm_apply_might_sleep() argument
680 struct pwm_chip *chip = pwm->chip; in pwm_apply_might_sleep()
702 err = __pwm_apply(pwm, state); in pwm_apply_might_sleep()
705 err = __pwm_apply(pwm, state); in pwm_apply_might_sleep()
713 * pwm_apply_atomic() - apply a new state to a PWM device from atomic context
714 * Not all PWM devices support this function, check with pwm_might_sleep().
715 * @pwm: PWM device
718 int pwm_apply_atomic(struct pwm_device *pwm, const struct pwm_state *state) in pwm_apply_atomic() argument
720 struct pwm_chip *chip = pwm->chip; in pwm_apply_atomic()
723 "sleeping PWM driver used in atomic context\n"); in pwm_apply_atomic()
730 return __pwm_apply(pwm, state); in pwm_apply_atomic()
735 * pwm_get_state_hw() - get the current PWM state from hardware
736 * @pwm: PWM device
737 * @state: state to fill with the current PWM state
739 * Similar to pwm_get_state() but reads the current PWM state from hardware
745 int pwm_get_state_hw(struct pwm_device *pwm, struct pwm_state *state) in pwm_get_state_hw() argument
747 struct pwm_chip *chip = pwm->chip; in pwm_get_state_hw()
764 ret = __pwm_read_waveform(chip, pwm, &wfhw); in pwm_get_state_hw()
768 ret = __pwm_round_waveform_fromhw(chip, pwm, &wfhw, &wf); in pwm_get_state_hw()
775 ret = ops->get_state(chip, pwm, state); in pwm_get_state_hw()
776 trace_pwm_get(pwm, state, ret); in pwm_get_state_hw()
784 * pwm_adjust_config() - adjust the current PWM config to the PWM arguments
785 * @pwm: PWM device
787 * This function will adjust the PWM config to the PWM arguments provided
788 * by the DT or PWM lookup table. This is particularly useful to adapt
791 int pwm_adjust_config(struct pwm_device *pwm) in pwm_adjust_config() argument
796 pwm_get_args(pwm, &pargs); in pwm_adjust_config()
797 pwm_get_state(pwm, &state); in pwm_adjust_config()
800 * If the current period is zero it means that either the PWM driver in pwm_adjust_config()
801 * does not support initial state retrieval or the PWM has not yet in pwm_adjust_config()
812 return pwm_apply_might_sleep(pwm, &state); in pwm_adjust_config()
816 * Adjust the PWM duty cycle/period based on the period value provided in pwm_adjust_config()
817 * in PWM args. in pwm_adjust_config()
835 return pwm_apply_might_sleep(pwm, &state); in pwm_adjust_config()
840 * pwm_capture() - capture and report a PWM signal
841 * @pwm: PWM device
847 static int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result, in pwm_capture() argument
850 struct pwm_chip *chip = pwm->chip; in pwm_capture()
868 return ops->capture(chip, pwm, result, timeout); in pwm_capture()
889 static int pwm_device_request(struct pwm_device *pwm, const char *label) in pwm_device_request() argument
892 struct pwm_chip *chip = pwm->chip; in pwm_device_request()
895 if (test_bit(PWMF_REQUESTED, &pwm->flags)) in pwm_device_request()
915 err = ops->request(chip, pwm); in pwm_device_request()
934 err = pwm_get_state_hw(pwm, &state); in pwm_device_request()
936 pwm->state = state; in pwm_device_request()
939 pwm->last = pwm->state; in pwm_device_request()
942 set_bit(PWMF_REQUESTED, &pwm->flags); in pwm_device_request()
943 pwm->label = label; in pwm_device_request()
949 * pwm_request_from_chip() - request a PWM device relative to a PWM chip
950 * @chip: PWM chip
951 * @index: per-chip index of the PWM to request
952 * @label: a literal description string of this PWM
954 * Returns: A pointer to the PWM device at the given index of the given PWM
956 * specified PWM chip or if the PWM device cannot be requested.
962 struct pwm_device *pwm; in pwm_request_from_chip() local
970 pwm = &chip->pwms[index]; in pwm_request_from_chip()
972 err = pwm_device_request(pwm, label); in pwm_request_from_chip()
976 return pwm; in pwm_request_from_chip()
982 struct pwm_device *pwm; in of_pwm_xlate_with_flags() local
988 pwm = pwm_request_from_chip(chip, args->args[0], NULL); in of_pwm_xlate_with_flags()
989 if (IS_ERR(pwm)) in of_pwm_xlate_with_flags()
990 return pwm; in of_pwm_xlate_with_flags()
993 pwm->args.period = args->args[1]; in of_pwm_xlate_with_flags()
995 pwm->args.polarity = PWM_POLARITY_NORMAL; in of_pwm_xlate_with_flags()
997 pwm->args.polarity = PWM_POLARITY_INVERSED; in of_pwm_xlate_with_flags()
999 return pwm; in of_pwm_xlate_with_flags()
1006 struct pwm_device *pwm; in of_pwm_single_xlate() local
1008 pwm = pwm_request_from_chip(chip, 0, NULL); in of_pwm_single_xlate()
1009 if (IS_ERR(pwm)) in of_pwm_single_xlate()
1010 return pwm; in of_pwm_single_xlate()
1013 pwm->args.period = args->args[0]; in of_pwm_single_xlate()
1015 pwm->args.polarity = PWM_POLARITY_NORMAL; in of_pwm_single_xlate()
1017 pwm->args.polarity = PWM_POLARITY_INVERSED; in of_pwm_single_xlate()
1019 return pwm; in of_pwm_single_xlate()
1025 struct pwm_device *pwm; member
1044 return export->pwm; in pwm_from_dev()
1051 const struct pwm_device *pwm = pwm_from_dev(pwm_dev); in period_show() local
1054 pwm_get_state(pwm, &state); in period_show()
1064 struct pwm_device *pwm = export->pwm; in period_store() local
1075 pwm_get_state(pwm, &state); in period_store()
1077 ret = pwm_apply_might_sleep(pwm, &state); in period_store()
1086 const struct pwm_device *pwm = pwm_from_dev(pwm_dev); in duty_cycle_show() local
1089 pwm_get_state(pwm, &state); in duty_cycle_show()
1099 struct pwm_device *pwm = export->pwm; in duty_cycle_store() local
1110 pwm_get_state(pwm, &state); in duty_cycle_store()
1112 ret = pwm_apply_might_sleep(pwm, &state); in duty_cycle_store()
1121 const struct pwm_device *pwm = pwm_from_dev(pwm_dev); in enable_show() local
1124 pwm_get_state(pwm, &state); in enable_show()
1134 struct pwm_device *pwm = export->pwm; in enable_store() local
1144 pwm_get_state(pwm, &state); in enable_store()
1157 ret = pwm_apply_might_sleep(pwm, &state); in enable_store()
1166 const struct pwm_device *pwm = pwm_from_dev(pwm_dev); in polarity_show() local
1170 pwm_get_state(pwm, &state); in polarity_show()
1190 struct pwm_device *pwm = export->pwm; in polarity_store() local
1204 pwm_get_state(pwm, &state); in polarity_store()
1206 ret = pwm_apply_might_sleep(pwm, &state); in polarity_store()
1215 struct pwm_device *pwm = pwm_from_dev(pwm_dev); in capture_show() local
1219 ret = pwm_capture(pwm, &result, jiffies_to_msecs(HZ)); in capture_show()
1240 ATTRIBUTE_GROUPS(pwm);
1249 static int pwm_export_child(struct device *pwmchip_dev, struct pwm_device *pwm) in pwm_export_child() argument
1255 if (test_and_set_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_export_child()
1260 clear_bit(PWMF_EXPORTED, &pwm->flags); in pwm_export_child()
1264 export->pwm = pwm; in pwm_export_child()
1271 dev_set_name(&export->pwm_dev, "pwm%u", pwm->hwpwm); in pwm_export_child()
1275 clear_bit(PWMF_EXPORTED, &pwm->flags); in pwm_export_child()
1280 pwm_prop[0] = kasprintf(GFP_KERNEL, "EXPORT=pwm%u", pwm->hwpwm); in pwm_export_child()
1293 static int pwm_unexport_child(struct device *pwmchip_dev, struct pwm_device *pwm) in pwm_unexport_child() argument
1298 if (!test_and_clear_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_unexport_child()
1301 pwm_dev = device_find_child(pwmchip_dev, pwm, pwm_unexport_match); in pwm_unexport_child()
1305 pwm_prop[0] = kasprintf(GFP_KERNEL, "UNEXPORT=pwm%u", pwm->hwpwm); in pwm_unexport_child()
1313 pwm_put(pwm); in pwm_unexport_child()
1323 struct pwm_device *pwm; in export_store() local
1334 pwm = pwm_request_from_chip(chip, hwpwm, "sysfs"); in export_store()
1335 if (IS_ERR(pwm)) in export_store()
1336 return PTR_ERR(pwm); in export_store()
1338 ret = pwm_export_child(pwmchip_dev, pwm); in export_store()
1340 pwm_put(pwm); in export_store()
1386 struct pwm_device *pwm, in pwm_class_get_state() argument
1392 if (!test_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_class_get_state()
1395 pwm_dev = device_find_child(pwmchip_dev, pwm, pwm_unexport_match); in pwm_class_get_state()
1403 pwm_get_state(pwm, state); in pwm_class_get_state()
1409 struct pwm_device *pwm, in pwm_class_apply_state() argument
1412 int ret = pwm_apply_might_sleep(pwm, state); in pwm_class_apply_state()
1427 struct pwm_device *pwm = &chip->pwms[i]; in pwm_class_resume_npwm() local
1431 export = pwm_class_get_state(pwmchip_dev, pwm, &state); in pwm_class_resume_npwm()
1443 ret = pwm_class_apply_state(export, pwm, &state); in pwm_class_resume_npwm()
1458 struct pwm_device *pwm = &chip->pwms[i]; in pwm_class_suspend() local
1462 export = pwm_class_get_state(pwmchip_dev, pwm, &state); in pwm_class_suspend()
1478 ret = pwm_class_apply_state(export, pwm, &state); in pwm_class_suspend()
1481 * roll back the PWM devices that were disabled by in pwm_class_suspend()
1502 .name = "pwm",
1512 struct pwm_device *pwm = &chip->pwms[i]; in pwmchip_sysfs_unexport() local
1514 if (test_bit(PWMF_EXPORTED, &pwm->flags)) in pwmchip_sysfs_unexport()
1515 pwm_unexport_child(&chip->dev, pwm); in pwmchip_sysfs_unexport()
1567 struct pwm_device *pwm = &chip->pwms[i]; in pwmchip_alloc() local
1568 pwm->chip = chip; in pwmchip_alloc()
1569 pwm->hwpwm = i; in pwmchip_alloc()
1644 struct pwm_device *pwm) in pwm_device_link_add() argument
1650 * No device for the PWM consumer has been provided. It may in pwm_device_link_add()
1651 * impact the PM sequence ordering: the PWM supplier may get in pwm_device_link_add()
1654 dev_warn(pwmchip_parent(pwm->chip), in pwm_device_link_add()
1659 dl = device_link_add(dev, pwmchip_parent(pwm->chip), DL_FLAG_AUTOREMOVE_CONSUMER); in pwm_device_link_add()
1662 dev_name(pwmchip_parent(pwm->chip))); in pwm_device_link_add()
1684 * of_pwm_get() - request a PWM via the PWM framework
1685 * @dev: device for PWM consumer
1686 * @np: device node to get the PWM from
1689 * Returns the PWM device parsed from the phandle and index specified in the
1691 * Values parsed from the device tree are stored in the returned PWM device
1694 * If con_id is NULL, the first PWM device listed in the "pwms" property will
1695 * be requested. Otherwise the "pwm-names" property is used to do a reverse
1696 * lookup of the PWM index. This also means that the "pwm-names" property
1697 * becomes mandatory for devices that look up the PWM device via the con_id
1700 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
1706 struct pwm_device *pwm = NULL; in of_pwm_get() local
1714 index = of_property_match_string(np, "pwm-names", con_id); in of_pwm_get()
1719 err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index, in of_pwm_get()
1729 pr_err("%s(): PWM chip not found\n", __func__); in of_pwm_get()
1731 pwm = ERR_CAST(chip); in of_pwm_get()
1735 pwm = chip->of_xlate(chip, &args); in of_pwm_get()
1736 if (IS_ERR(pwm)) in of_pwm_get()
1739 dl = pwm_device_link_add(dev, pwm); in of_pwm_get()
1742 pwm_put(pwm); in of_pwm_get()
1743 pwm = ERR_CAST(dl); in of_pwm_get()
1749 * "pwm-names" property if it exists. Otherwise use the name of in of_pwm_get()
1753 err = of_property_read_string_index(np, "pwm-names", index, in of_pwm_get()
1759 pwm->label = con_id; in of_pwm_get()
1764 return pwm; in of_pwm_get()
1768 * acpi_pwm_get() - request a PWM via parsing "pwms" property in ACPI
1771 * Returns the PWM device parsed from the fwnode and index specified in the
1773 * Values parsed from the device tree are stored in the returned PWM device
1779 * { <PWM device reference>, <PWM index>, <PWM period> [, <PWM flags>]}}
1781 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
1786 struct pwm_device *pwm; in acpi_pwm_get() local
1804 pwm = pwm_request_from_chip(chip, args.args[0], NULL); in acpi_pwm_get()
1805 if (IS_ERR(pwm)) in acpi_pwm_get()
1806 return pwm; in acpi_pwm_get()
1808 pwm->args.period = args.args[1]; in acpi_pwm_get()
1809 pwm->args.polarity = PWM_POLARITY_NORMAL; in acpi_pwm_get()
1812 pwm->args.polarity = PWM_POLARITY_INVERSED; in acpi_pwm_get()
1814 return pwm; in acpi_pwm_get()
1821 * pwm_get() - look up and request a PWM device
1822 * @dev: device for PWM consumer
1826 * a device tree, a PWM chip and a relative index is looked up via a table
1829 * Once a PWM chip has been found the specified PWM device will be requested
1832 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
1839 struct pwm_device *pwm; in pwm_get() local
1853 pwm = acpi_pwm_get(fwnode); in pwm_get()
1854 if (!IS_ERR(pwm) || PTR_ERR(pwm) != -ENOENT) in pwm_get()
1855 return pwm; in pwm_get()
1865 * If a match is found, the provider PWM chip is looked up by name in pwm_get()
1866 * and a PWM device is requested using the PWM device per-chip index. in pwm_get()
1913 * the PWM chip lookup. This can be used to work around driver load in pwm_get()
1926 pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id); in pwm_get()
1927 if (IS_ERR(pwm)) in pwm_get()
1928 return pwm; in pwm_get()
1930 dl = pwm_device_link_add(dev, pwm); in pwm_get()
1932 pwm_put(pwm); in pwm_get()
1936 pwm->args.period = chosen->period; in pwm_get()
1937 pwm->args.polarity = chosen->polarity; in pwm_get()
1939 return pwm; in pwm_get()
1944 * pwm_put() - release a PWM device
1945 * @pwm: PWM device
1947 void pwm_put(struct pwm_device *pwm) in pwm_put() argument
1951 if (!pwm) in pwm_put()
1954 chip = pwm->chip; in pwm_put()
1963 if (chip->operational && !test_and_clear_bit(PWMF_REQUESTED, &pwm->flags)) { in pwm_put()
1964 pr_warn("PWM device already freed\n"); in pwm_put()
1969 pwm->chip->ops->free(pwm->chip, pwm); in pwm_put()
1971 pwm->label = NULL; in pwm_put()
1979 static void devm_pwm_release(void *pwm) in devm_pwm_release() argument
1981 pwm_put(pwm); in devm_pwm_release()
1986 * @dev: device for PWM consumer
1989 * This function performs like pwm_get() but the acquired PWM device will
1992 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
1997 struct pwm_device *pwm; in devm_pwm_get() local
2000 pwm = pwm_get(dev, con_id); in devm_pwm_get()
2001 if (IS_ERR(pwm)) in devm_pwm_get()
2002 return pwm; in devm_pwm_get()
2004 ret = devm_add_action_or_reset(dev, devm_pwm_release, pwm); in devm_pwm_get()
2008 return pwm; in devm_pwm_get()
2013 * devm_fwnode_pwm_get() - request a resource managed PWM from firmware node
2014 * @dev: device for PWM consumer
2015 * @fwnode: firmware node to get the PWM from
2018 * Returns the PWM device parsed from the firmware node. See of_pwm_get() and
2021 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
2028 struct pwm_device *pwm = ERR_PTR(-ENODEV); in devm_fwnode_pwm_get() local
2032 pwm = of_pwm_get(dev, to_of_node(fwnode), con_id); in devm_fwnode_pwm_get()
2034 pwm = acpi_pwm_get(fwnode); in devm_fwnode_pwm_get()
2035 if (IS_ERR(pwm)) in devm_fwnode_pwm_get()
2036 return pwm; in devm_fwnode_pwm_get()
2038 ret = devm_add_action_or_reset(dev, devm_pwm_release, pwm); in devm_fwnode_pwm_get()
2042 return pwm; in devm_fwnode_pwm_get()
2047 * __pwmchip_add() - register a new PWM chip
2048 * @chip: the PWM chip to add
2051 * Register a new PWM chip. @owner is supposed to be THIS_MODULE, use the
2118 * pwmchip_remove() - remove a PWM chip
2119 * @chip: the PWM chip to remove
2121 * Removes a PWM chip.
2134 struct pwm_device *pwm = &chip->pwms[i]; in pwmchip_remove() local
2136 if (test_and_clear_bit(PWMF_REQUESTED, &pwm->flags)) { in pwmchip_remove()
2137 dev_warn(&chip->dev, "Freeing requested PWM #%u\n", i); in pwmchip_remove()
2138 if (pwm->chip->ops->free) in pwmchip_remove()
2139 pwm->chip->ops->free(pwm->chip, pwm); in pwmchip_remove()
2173 * pwm_add_table() - register PWM device consumers
2188 * pwm_remove_table() - unregister PWM device consumers
2207 struct pwm_device *pwm = &chip->pwms[i]; in pwm_dbg_show() local
2210 pwm_get_state(pwm, &state); in pwm_dbg_show()
2212 seq_printf(s, " pwm-%-3d (%-20.20s):", i, pwm->label); in pwm_dbg_show()
2214 if (test_bit(PWMF_REQUESTED, &pwm->flags)) in pwm_dbg_show()
2266 seq_printf(s, "%s%d: %s/%s, %d PWM device%s\n", in pwm_seq_show()
2292 pr_err("Failed to initialize PWM class (%pe)\n", ERR_PTR(ret)); in pwm_init()
2297 debugfs_create_file("pwm", 0444, NULL, NULL, &pwm_debugfs_fops); in pwm_init()