186a1b832SFrançois Tigeot /*
2*a85cb24fSFrançois Tigeot * Copyright (c) 2016-2020 François Tigeot <ftigeot@wolfpond.org>
386a1b832SFrançois Tigeot * All rights reserved.
486a1b832SFrançois Tigeot *
586a1b832SFrançois Tigeot * Redistribution and use in source and binary forms, with or without
686a1b832SFrançois Tigeot * modification, are permitted provided that the following conditions
786a1b832SFrançois Tigeot * are met:
886a1b832SFrançois Tigeot * 1. Redistributions of source code must retain the above copyright
986a1b832SFrançois Tigeot * notice unmodified, this list of conditions, and the following
1086a1b832SFrançois Tigeot * disclaimer.
1186a1b832SFrançois Tigeot * 2. Redistributions in binary form must reproduce the above copyright
1286a1b832SFrançois Tigeot * notice, this list of conditions and the following disclaimer in the
1386a1b832SFrançois Tigeot * documentation and/or other materials provided with the distribution.
1486a1b832SFrançois Tigeot *
1586a1b832SFrançois Tigeot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1686a1b832SFrançois Tigeot * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1786a1b832SFrançois Tigeot * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1886a1b832SFrançois Tigeot * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1986a1b832SFrançois Tigeot * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2086a1b832SFrançois Tigeot * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2186a1b832SFrançois Tigeot * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2286a1b832SFrançois Tigeot * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2386a1b832SFrançois Tigeot * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2486a1b832SFrançois Tigeot * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2586a1b832SFrançois Tigeot */
2686a1b832SFrançois Tigeot
2786a1b832SFrançois Tigeot #ifndef _LINUX_GPIO_CONSUMER_H_
2886a1b832SFrançois Tigeot #define _LINUX_GPIO_CONSUMER_H_
2986a1b832SFrançois Tigeot
3086a1b832SFrançois Tigeot #define GPIOD_FLAGS_BIT_DIR_SET 1
3186a1b832SFrançois Tigeot #define GPIOD_FLAGS_BIT_DIR_OUT 2
3286a1b832SFrançois Tigeot #define GPIOD_FLAGS_BIT_DIR_VAL 4
3386a1b832SFrançois Tigeot
3486a1b832SFrançois Tigeot enum gpiod_flags {
3586a1b832SFrançois Tigeot GPIOD_ASIS = 0,
3686a1b832SFrançois Tigeot GPIOD_IN = GPIOD_FLAGS_BIT_DIR_SET,
3786a1b832SFrançois Tigeot GPIOD_OUT_LOW = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT,
3886a1b832SFrançois Tigeot GPIOD_OUT_HIGH = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT |
3986a1b832SFrançois Tigeot GPIOD_FLAGS_BIT_DIR_VAL,
4086a1b832SFrançois Tigeot };
4186a1b832SFrançois Tigeot
4286a1b832SFrançois Tigeot static inline struct gpio_desc *
gpiod_get(struct device * dev,const char * con_id,enum gpiod_flags flags)4386a1b832SFrançois Tigeot gpiod_get(struct device *dev, const char *con_id, enum gpiod_flags flags)
4486a1b832SFrançois Tigeot {
4586a1b832SFrançois Tigeot kprintf("Stub: %s\n", __FUNCTION__);
4686a1b832SFrançois Tigeot return NULL;
4786a1b832SFrançois Tigeot }
4886a1b832SFrançois Tigeot
4986a1b832SFrançois Tigeot static inline void
gpiod_put(struct gpio_desc * desc)5086a1b832SFrançois Tigeot gpiod_put(struct gpio_desc *desc)
5186a1b832SFrançois Tigeot {
5286a1b832SFrançois Tigeot kprintf("Stub: %s\n", __FUNCTION__);
5386a1b832SFrançois Tigeot }
5486a1b832SFrançois Tigeot
5586a1b832SFrançois Tigeot static inline void
gpiod_set_value_cansleep(struct gpio_desc * desc,int value)5686a1b832SFrançois Tigeot gpiod_set_value_cansleep(struct gpio_desc *desc, int value)
5786a1b832SFrançois Tigeot {
5886a1b832SFrançois Tigeot kprintf("Stub: %s\n", __FUNCTION__);
5986a1b832SFrançois Tigeot }
6086a1b832SFrançois Tigeot
61*a85cb24fSFrançois Tigeot static inline struct gpio_desc *
devm_gpiod_get_index(struct device * dev,const char * con_id,unsigned int idx,enum gpiod_flags flags)62*a85cb24fSFrançois Tigeot devm_gpiod_get_index(struct device *dev, const char *con_id,
63*a85cb24fSFrançois Tigeot unsigned int idx, enum gpiod_flags flags)
64*a85cb24fSFrançois Tigeot {
65*a85cb24fSFrançois Tigeot return ERR_PTR(-ENOSYS);
66*a85cb24fSFrançois Tigeot }
67*a85cb24fSFrançois Tigeot
68*a85cb24fSFrançois Tigeot static inline void
gpiod_set_value(struct gpio_desc * desc,int value)69*a85cb24fSFrançois Tigeot gpiod_set_value(struct gpio_desc *desc, int value)
70*a85cb24fSFrançois Tigeot {
71*a85cb24fSFrançois Tigeot kprintf("Stub: %s\n", __FUNCTION__);
72*a85cb24fSFrançois Tigeot }
73*a85cb24fSFrançois Tigeot
7486a1b832SFrançois Tigeot #endif /* _LINUX_GPIO_CONSUMER_H_ */
75