1/*- 2 * Copyright (c) 2022 Vladimir Kondratyev <wulf@FreeBSD.org> 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26#ifndef _LINUXKPI_LINUX_PWM_H_ 27#define _LINUXKPI_LINUX_PWM_H_ 28 29#include <linux/device.h> 30#include <linux/err.h> 31 32struct pwm_state { 33 uint64_t period; 34 bool enabled; 35}; 36 37struct pwm_device { 38 struct pwm_state state; 39}; 40 41static inline struct pwm_device * 42pwm_get(struct device *dev, const char *consumer) 43{ 44 return (ERR_PTR(-ENODEV)); 45} 46 47static inline void 48pwm_put(struct pwm_device *pwm) 49{ 50} 51 52static inline int 53pwm_enable(struct pwm_device *pwm) 54{ 55 return (-EINVAL); 56} 57 58static inline void 59pwm_disable(struct pwm_device *pwm) 60{ 61} 62 63static inline bool 64pwm_is_enabled(const struct pwm_device *pwm) 65{ 66 return (false); 67} 68 69static inline unsigned int 70pwm_get_relative_duty_cycle(const struct pwm_state *state, unsigned int scale) 71{ 72 return (0); 73} 74 75static inline int 76pwm_set_relative_duty_cycle(struct pwm_state *state, unsigned int duty_cycle, 77 unsigned int scale) 78{ 79 return (0); 80} 81 82static inline void 83pwm_get_state(const struct pwm_device *pwm, struct pwm_state *state) 84{ 85 *state = pwm->state; 86} 87 88static inline int 89pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) 90{ 91 return (-ENOTSUPP); 92} 93 94#endif /* _LINUXKPI_LINUX_PWM_H_ */ 95