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