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 ret_tohw = __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()
392 * @pwm: PWM device
406 int pwm_set_waveform_might_sleep(struct pwm_device *pwm, in pwm_set_waveform_might_sleep() argument
409 struct pwm_chip *chip = pwm->chip; in pwm_set_waveform_might_sleep()
425 err = __pwm_set_waveform(pwm, wf, exact); in pwm_set_waveform_might_sleep()
428 err = __pwm_set_waveform(pwm, wf, exact); in pwm_set_waveform_might_sleep()
435 static void pwm_apply_debug(struct pwm_device *pwm, in pwm_apply_debug() argument
438 struct pwm_state *last = &pwm->last; in pwm_apply_debug()
439 struct pwm_chip *chip = pwm->chip; in pwm_apply_debug()
455 err = chip->ops->get_state(chip, pwm, &s1); in pwm_apply_debug()
456 trace_pwm_get(pwm, &s1, err); in pwm_apply_debug()
518 err = chip->ops->apply(chip, pwm, &s1); in pwm_apply_debug()
519 trace_pwm_apply(pwm, &s1, err); in pwm_apply_debug()
527 err = chip->ops->get_state(chip, pwm, last); in pwm_apply_debug()
528 trace_pwm_get(pwm, last, err); in pwm_apply_debug()
565 * __pwm_apply() - atomically apply a new state to a PWM device
566 * @pwm: PWM device
569 static int __pwm_apply(struct pwm_device *pwm, const struct pwm_state *state) in __pwm_apply() argument
575 if (!pwm || !state) in __pwm_apply()
587 if (!pwm_state_valid(&pwm->state)) { in __pwm_apply()
588 pwm->state = *state; in __pwm_apply()
595 chip = pwm->chip; in __pwm_apply()
598 if (state->period == pwm->state.period && in __pwm_apply()
599 state->duty_cycle == pwm->state.duty_cycle && in __pwm_apply()
600 state->polarity == pwm->state.polarity && in __pwm_apply()
601 state->enabled == pwm->state.enabled && in __pwm_apply()
602 state->usage_power == pwm->state.usage_power) in __pwm_apply()
617 * .round_waveform_tohw() rounds down the time the PWM is high. in __pwm_apply()
622 err = __pwm_round_waveform_tohw(chip, pwm, &wf, &wfhw); in __pwm_apply()
638 err = __pwm_round_waveform_fromhw(chip, pwm, &wfhw, &wf_rounded); in __pwm_apply()
648 err = __pwm_write_waveform(chip, pwm, &wfhw); in __pwm_apply()
652 pwm->state = *state; in __pwm_apply()
655 err = ops->apply(chip, pwm, state); in __pwm_apply()
656 trace_pwm_apply(pwm, state, err); in __pwm_apply()
660 pwm->state = *state; in __pwm_apply()
663 * only do this after pwm->state was applied as some in __pwm_apply()
666 pwm_apply_debug(pwm, state); in __pwm_apply()
673 * pwm_apply_might_sleep() - atomically apply a new state to a PWM device
675 * @pwm: PWM device
678 int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) in pwm_apply_might_sleep() argument
681 struct pwm_chip *chip = pwm->chip; in pwm_apply_might_sleep()
703 err = __pwm_apply(pwm, state); in pwm_apply_might_sleep()
706 err = __pwm_apply(pwm, state); in pwm_apply_might_sleep()
714 * pwm_apply_atomic() - apply a new state to a PWM device from atomic context
715 * Not all PWM devices support this function, check with pwm_might_sleep().
716 * @pwm: PWM device
719 int pwm_apply_atomic(struct pwm_device *pwm, const struct pwm_state *state) in pwm_apply_atomic() argument
721 struct pwm_chip *chip = pwm->chip; in pwm_apply_atomic()
724 "sleeping PWM driver used in atomic context\n"); in pwm_apply_atomic()
731 return __pwm_apply(pwm, state); in pwm_apply_atomic()
736 * pwm_get_state_hw() - get the current PWM state from hardware
737 * @pwm: PWM device
738 * @state: state to fill with the current PWM state
740 * Similar to pwm_get_state() but reads the current PWM state from hardware
746 int pwm_get_state_hw(struct pwm_device *pwm, struct pwm_state *state) in pwm_get_state_hw() argument
748 struct pwm_chip *chip = pwm->chip; in pwm_get_state_hw()
765 ret = __pwm_read_waveform(chip, pwm, &wfhw); in pwm_get_state_hw()
769 ret = __pwm_round_waveform_fromhw(chip, pwm, &wfhw, &wf); in pwm_get_state_hw()
776 ret = ops->get_state(chip, pwm, state); in pwm_get_state_hw()
777 trace_pwm_get(pwm, state, ret); in pwm_get_state_hw()
785 * pwm_adjust_config() - adjust the current PWM config to the PWM arguments
786 * @pwm: PWM device
788 * This function will adjust the PWM config to the PWM arguments provided
789 * by the DT or PWM lookup table. This is particularly useful to adapt
792 int pwm_adjust_config(struct pwm_device *pwm) in pwm_adjust_config() argument
797 pwm_get_args(pwm, &pargs); in pwm_adjust_config()
798 pwm_get_state(pwm, &state); in pwm_adjust_config()
801 * If the current period is zero it means that either the PWM driver in pwm_adjust_config()
802 * does not support initial state retrieval or the PWM has not yet in pwm_adjust_config()
813 return pwm_apply_might_sleep(pwm, &state); in pwm_adjust_config()
817 * Adjust the PWM duty cycle/period based on the period value provided in pwm_adjust_config()
818 * in PWM args. in pwm_adjust_config()
836 return pwm_apply_might_sleep(pwm, &state); in pwm_adjust_config()
841 * pwm_capture() - capture and report a PWM signal
842 * @pwm: PWM device
848 static int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result, in pwm_capture() argument
851 struct pwm_chip *chip = pwm->chip; in pwm_capture()
869 return ops->capture(chip, pwm, result, timeout); in pwm_capture()
890 static int pwm_device_request(struct pwm_device *pwm, const char *label) in pwm_device_request() argument
893 struct pwm_chip *chip = pwm->chip; in pwm_device_request()
896 if (test_bit(PWMF_REQUESTED, &pwm->flags)) in pwm_device_request()
916 err = ops->request(chip, pwm); in pwm_device_request()
935 err = pwm_get_state_hw(pwm, &state); in pwm_device_request()
937 pwm->state = state; in pwm_device_request()
940 pwm->last = pwm->state; in pwm_device_request()
943 set_bit(PWMF_REQUESTED, &pwm->flags); in pwm_device_request()
944 pwm->label = label; in pwm_device_request()
950 * pwm_request_from_chip() - request a PWM device relative to a PWM chip
951 * @chip: PWM chip
952 * @index: per-chip index of the PWM to request
953 * @label: a literal description string of this PWM
955 * Returns: A pointer to the PWM device at the given index of the given PWM
957 * specified PWM chip or if the PWM device cannot be requested.
963 struct pwm_device *pwm; in pwm_request_from_chip() local
971 pwm = &chip->pwms[index]; in pwm_request_from_chip()
973 err = pwm_device_request(pwm, label); in pwm_request_from_chip()
977 return pwm; in pwm_request_from_chip()
983 struct pwm_device *pwm; in of_pwm_xlate_with_flags() local
989 pwm = pwm_request_from_chip(chip, args->args[0], NULL); in of_pwm_xlate_with_flags()
990 if (IS_ERR(pwm)) in of_pwm_xlate_with_flags()
991 return pwm; in of_pwm_xlate_with_flags()
994 pwm->args.period = args->args[1]; in of_pwm_xlate_with_flags()
996 pwm->args.polarity = PWM_POLARITY_NORMAL; in of_pwm_xlate_with_flags()
998 pwm->args.polarity = PWM_POLARITY_INVERSED; in of_pwm_xlate_with_flags()
1000 return pwm; in of_pwm_xlate_with_flags()
1005 * This callback is used for PXA PWM chips that only have a single PWM line.
1011 * Note that if #pwm-cells = <3>, the semantic is the same as for
1013 * #pwm-cells = <3> without breaking the legacy binding.
1020 struct pwm_device *pwm; in of_pwm_single_xlate() local
1025 pwm = pwm_request_from_chip(chip, 0, NULL); in of_pwm_single_xlate()
1026 if (IS_ERR(pwm)) in of_pwm_single_xlate()
1027 return pwm; in of_pwm_single_xlate()
1030 pwm->args.period = args->args[0]; in of_pwm_single_xlate()
1032 pwm->args.polarity = PWM_POLARITY_NORMAL; in of_pwm_single_xlate()
1034 pwm->args.polarity = PWM_POLARITY_INVERSED; in of_pwm_single_xlate()
1036 return pwm; in of_pwm_single_xlate()
1042 struct pwm_device *pwm; member
1061 return export->pwm; in pwm_from_dev()
1068 const struct pwm_device *pwm = pwm_from_dev(pwm_dev); in period_show() local
1071 pwm_get_state(pwm, &state); in period_show()
1081 struct pwm_device *pwm = export->pwm; in period_store() local
1092 pwm_get_state(pwm, &state); in period_store()
1094 ret = pwm_apply_might_sleep(pwm, &state); in period_store()
1103 const struct pwm_device *pwm = pwm_from_dev(pwm_dev); in duty_cycle_show() local
1106 pwm_get_state(pwm, &state); in duty_cycle_show()
1116 struct pwm_device *pwm = export->pwm; in duty_cycle_store() local
1127 pwm_get_state(pwm, &state); in duty_cycle_store()
1129 ret = pwm_apply_might_sleep(pwm, &state); in duty_cycle_store()
1138 const struct pwm_device *pwm = pwm_from_dev(pwm_dev); in enable_show() local
1141 pwm_get_state(pwm, &state); in enable_show()
1151 struct pwm_device *pwm = export->pwm; in enable_store() local
1161 pwm_get_state(pwm, &state); in enable_store()
1174 ret = pwm_apply_might_sleep(pwm, &state); in enable_store()
1183 const struct pwm_device *pwm = pwm_from_dev(pwm_dev); in polarity_show() local
1187 pwm_get_state(pwm, &state); in polarity_show()
1207 struct pwm_device *pwm = export->pwm; in polarity_store() local
1221 pwm_get_state(pwm, &state); in polarity_store()
1223 ret = pwm_apply_might_sleep(pwm, &state); in polarity_store()
1232 struct pwm_device *pwm = pwm_from_dev(pwm_dev); in capture_show() local
1236 ret = pwm_capture(pwm, &result, jiffies_to_msecs(HZ)); in capture_show()
1257 ATTRIBUTE_GROUPS(pwm);
1266 static int pwm_export_child(struct device *pwmchip_dev, struct pwm_device *pwm) in pwm_export_child() argument
1272 if (test_and_set_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_export_child()
1277 clear_bit(PWMF_EXPORTED, &pwm->flags); in pwm_export_child()
1281 export->pwm = pwm; in pwm_export_child()
1288 dev_set_name(&export->pwm_dev, "pwm%u", pwm->hwpwm); in pwm_export_child()
1292 clear_bit(PWMF_EXPORTED, &pwm->flags); in pwm_export_child()
1297 pwm_prop[0] = kasprintf(GFP_KERNEL, "EXPORT=pwm%u", pwm->hwpwm); in pwm_export_child()
1310 static int pwm_unexport_child(struct device *pwmchip_dev, struct pwm_device *pwm) in pwm_unexport_child() argument
1315 if (!test_and_clear_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_unexport_child()
1318 pwm_dev = device_find_child(pwmchip_dev, pwm, pwm_unexport_match); in pwm_unexport_child()
1322 pwm_prop[0] = kasprintf(GFP_KERNEL, "UNEXPORT=pwm%u", pwm->hwpwm); in pwm_unexport_child()
1330 pwm_put(pwm); in pwm_unexport_child()
1340 struct pwm_device *pwm; in export_store() local
1351 pwm = pwm_request_from_chip(chip, hwpwm, "sysfs"); in export_store()
1352 if (IS_ERR(pwm)) in export_store()
1353 return PTR_ERR(pwm); in export_store()
1355 ret = pwm_export_child(pwmchip_dev, pwm); in export_store()
1357 pwm_put(pwm); in export_store()
1403 struct pwm_device *pwm, in pwm_class_get_state() argument
1409 if (!test_bit(PWMF_EXPORTED, &pwm->flags)) in pwm_class_get_state()
1412 pwm_dev = device_find_child(pwmchip_dev, pwm, pwm_unexport_match); in pwm_class_get_state()
1420 pwm_get_state(pwm, state); in pwm_class_get_state()
1426 struct pwm_device *pwm, in pwm_class_apply_state() argument
1429 int ret = pwm_apply_might_sleep(pwm, state); in pwm_class_apply_state()
1444 struct pwm_device *pwm = &chip->pwms[i]; in pwm_class_resume_npwm() local
1448 export = pwm_class_get_state(pwmchip_dev, pwm, &state); in pwm_class_resume_npwm()
1460 ret = pwm_class_apply_state(export, pwm, &state); in pwm_class_resume_npwm()
1475 struct pwm_device *pwm = &chip->pwms[i]; in pwm_class_suspend() local
1479 export = pwm_class_get_state(pwmchip_dev, pwm, &state); in pwm_class_suspend()
1495 ret = pwm_class_apply_state(export, pwm, &state); in pwm_class_suspend()
1498 * roll back the PWM devices that were disabled by in pwm_class_suspend()
1519 .name = "pwm",
1529 struct pwm_device *pwm = &chip->pwms[i]; in pwmchip_sysfs_unexport() local
1531 if (test_bit(PWMF_EXPORTED, &pwm->flags)) in pwmchip_sysfs_unexport()
1532 pwm_unexport_child(&chip->dev, pwm); in pwmchip_sysfs_unexport()
1584 struct pwm_device *pwm = &chip->pwms[i]; in pwmchip_alloc() local
1585 pwm->chip = chip; in pwmchip_alloc()
1586 pwm->hwpwm = i; in pwmchip_alloc()
1661 struct pwm_device *pwm) in pwm_device_link_add() argument
1667 * No device for the PWM consumer has been provided. It may in pwm_device_link_add()
1668 * impact the PM sequence ordering: the PWM supplier may get in pwm_device_link_add()
1671 dev_warn(pwmchip_parent(pwm->chip), in pwm_device_link_add()
1676 dl = device_link_add(dev, pwmchip_parent(pwm->chip), DL_FLAG_AUTOREMOVE_CONSUMER); in pwm_device_link_add()
1679 dev_name(pwmchip_parent(pwm->chip))); in pwm_device_link_add()
1701 * of_pwm_get() - request a PWM via the PWM framework
1702 * @dev: device for PWM consumer
1703 * @np: device node to get the PWM from
1706 * Returns the PWM device parsed from the phandle and index specified in the
1708 * Values parsed from the device tree are stored in the returned PWM device
1711 * If con_id is NULL, the first PWM device listed in the "pwms" property will
1712 * be requested. Otherwise the "pwm-names" property is used to do a reverse
1713 * lookup of the PWM index. This also means that the "pwm-names" property
1714 * becomes mandatory for devices that look up the PWM device via the con_id
1717 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
1723 struct pwm_device *pwm = NULL; in of_pwm_get() local
1731 index = of_property_match_string(np, "pwm-names", con_id); in of_pwm_get()
1736 err = of_parse_phandle_with_args_map(np, "pwms", "pwm", index, &args); in of_pwm_get()
1745 pr_err("%s(): PWM chip not found\n", __func__); in of_pwm_get()
1747 pwm = ERR_CAST(chip); in of_pwm_get()
1751 pwm = chip->of_xlate(chip, &args); in of_pwm_get()
1752 if (IS_ERR(pwm)) in of_pwm_get()
1755 dl = pwm_device_link_add(dev, pwm); in of_pwm_get()
1758 pwm_put(pwm); in of_pwm_get()
1759 pwm = ERR_CAST(dl); in of_pwm_get()
1765 * "pwm-names" property if it exists. Otherwise use the name of in of_pwm_get()
1769 err = of_property_read_string_index(np, "pwm-names", index, in of_pwm_get()
1775 pwm->label = con_id; in of_pwm_get()
1780 return pwm; in of_pwm_get()
1784 * acpi_pwm_get() - request a PWM via parsing "pwms" property in ACPI
1787 * Returns the PWM device parsed from the fwnode and index specified in the
1789 * Values parsed from the device tree are stored in the returned PWM device
1795 * { <PWM device reference>, <PWM index>, <PWM period> [, <PWM flags>]}}
1797 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
1802 struct pwm_device *pwm; in acpi_pwm_get() local
1820 pwm = pwm_request_from_chip(chip, args.args[0], NULL); in acpi_pwm_get()
1821 if (IS_ERR(pwm)) in acpi_pwm_get()
1822 return pwm; in acpi_pwm_get()
1824 pwm->args.period = args.args[1]; in acpi_pwm_get()
1825 pwm->args.polarity = PWM_POLARITY_NORMAL; in acpi_pwm_get()
1828 pwm->args.polarity = PWM_POLARITY_INVERSED; in acpi_pwm_get()
1830 return pwm; in acpi_pwm_get()
1837 * pwm_get() - look up and request a PWM device
1838 * @dev: device for PWM consumer
1842 * a device tree, a PWM chip and a relative index is looked up via a table
1845 * Once a PWM chip has been found the specified PWM device will be requested
1848 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
1855 struct pwm_device *pwm; in pwm_get() local
1869 pwm = acpi_pwm_get(fwnode); in pwm_get()
1870 if (!IS_ERR(pwm) || PTR_ERR(pwm) != -ENOENT) in pwm_get()
1871 return pwm; in pwm_get()
1881 * If a match is found, the provider PWM chip is looked up by name in pwm_get()
1882 * and a PWM device is requested using the PWM device per-chip index. in pwm_get()
1929 * the PWM chip lookup. This can be used to work around driver load in pwm_get()
1942 pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id); in pwm_get()
1943 if (IS_ERR(pwm)) in pwm_get()
1944 return pwm; in pwm_get()
1946 dl = pwm_device_link_add(dev, pwm); in pwm_get()
1948 pwm_put(pwm); in pwm_get()
1952 pwm->args.period = chosen->period; in pwm_get()
1953 pwm->args.polarity = chosen->polarity; in pwm_get()
1955 return pwm; in pwm_get()
1960 * pwm_put() - release a PWM device
1961 * @pwm: PWM device
1963 void pwm_put(struct pwm_device *pwm) in pwm_put() argument
1967 if (!pwm) in pwm_put()
1970 chip = pwm->chip; in pwm_put()
1979 if (chip->operational && !test_and_clear_bit(PWMF_REQUESTED, &pwm->flags)) { in pwm_put()
1980 pr_warn("PWM device already freed\n"); in pwm_put()
1985 pwm->chip->ops->free(pwm->chip, pwm); in pwm_put()
1987 pwm->label = NULL; in pwm_put()
1995 static void devm_pwm_release(void *pwm) in devm_pwm_release() argument
1997 pwm_put(pwm); in devm_pwm_release()
2002 * @dev: device for PWM consumer
2005 * This function performs like pwm_get() but the acquired PWM device will
2008 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
2013 struct pwm_device *pwm; in devm_pwm_get() local
2016 pwm = pwm_get(dev, con_id); in devm_pwm_get()
2017 if (IS_ERR(pwm)) in devm_pwm_get()
2018 return pwm; in devm_pwm_get()
2020 ret = devm_add_action_or_reset(dev, devm_pwm_release, pwm); in devm_pwm_get()
2024 return pwm; in devm_pwm_get()
2029 * devm_fwnode_pwm_get() - request a resource managed PWM from firmware node
2030 * @dev: device for PWM consumer
2031 * @fwnode: firmware node to get the PWM from
2034 * Returns the PWM device parsed from the firmware node. See of_pwm_get() and
2037 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
2044 struct pwm_device *pwm = ERR_PTR(-ENODEV); in devm_fwnode_pwm_get() local
2048 pwm = of_pwm_get(dev, to_of_node(fwnode), con_id); in devm_fwnode_pwm_get()
2050 pwm = acpi_pwm_get(fwnode); in devm_fwnode_pwm_get()
2051 if (IS_ERR(pwm)) in devm_fwnode_pwm_get()
2052 return pwm; in devm_fwnode_pwm_get()
2054 ret = devm_add_action_or_reset(dev, devm_pwm_release, pwm); in devm_fwnode_pwm_get()
2058 return pwm; in devm_fwnode_pwm_get()
2063 * __pwmchip_add() - register a new PWM chip
2064 * @chip: the PWM chip to add
2067 * Register a new PWM chip. @owner is supposed to be THIS_MODULE, use the
2134 * pwmchip_remove() - remove a PWM chip
2135 * @chip: the PWM chip to remove
2137 * Removes a PWM chip.
2150 struct pwm_device *pwm = &chip->pwms[i]; in pwmchip_remove() local
2152 if (test_and_clear_bit(PWMF_REQUESTED, &pwm->flags)) { in pwmchip_remove()
2153 dev_warn(&chip->dev, "Freeing requested PWM #%u\n", i); in pwmchip_remove()
2154 if (pwm->chip->ops->free) in pwmchip_remove()
2155 pwm->chip->ops->free(pwm->chip, pwm); in pwmchip_remove()
2189 * pwm_add_table() - register PWM device consumers
2204 * pwm_remove_table() - unregister PWM device consumers
2223 struct pwm_device *pwm = &chip->pwms[i]; in pwm_dbg_show() local
2226 pwm_get_state(pwm, &state); in pwm_dbg_show()
2228 seq_printf(s, " pwm-%-3d (%-20.20s):", i, pwm->label); in pwm_dbg_show()
2230 if (test_bit(PWMF_REQUESTED, &pwm->flags)) in pwm_dbg_show()
2282 seq_printf(s, "%s%d: %s/%s, %d PWM device%s\n", in pwm_seq_show()
2308 pr_err("Failed to initialize PWM class (%pe)\n", ERR_PTR(ret)); in pwm_init()
2313 debugfs_create_file("pwm", 0444, NULL, NULL, &pwm_debugfs_fops); in pwm_init()