summaryrefslogtreecommitdiff
path: root/include/gpiod.h
Commit message (Collapse)AuthorAgeFilesLines
* gpiolib: implement gpio_direction_input/outputAhmad Fatoum2023-01-231-1/+11
| | | | | | | | | These are straight wrappers around existing functions, but with a name that's more like their Linux counterparts. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230116134501.2006391-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* gpiolib: implement gpiod_get_valueAhmad Fatoum2023-01-101-0/+8
| | | | | | | | | | The gpiod_ family of kernel functions always assume the logical state for values (i.e. taking active low/high into account). We already have gpio_set_value, so add gpiod_get_value for symmetry. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230109155836.2220277-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* gpiolib: implement dev_gpiod_get_indexAhmad Fatoum2023-01-101-1/+35
| | | | | | | | | | | Linux devm_gpiod_get_index is a superset of devm_gpiod_get. We already support gpiod_get to simplify kernel code porting, so reimplement it in terms of a new dev_gpiod_get_index to simplify porting kernel code using that as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230109155836.2220277-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* gpiolib: use signed int for gpio in gpiod_set_valueAhmad Fatoum2023-01-101-1/+1
| | | | | | | | | barebox gpio identifiers are always in the range of non-negative signed integers with negative values reserved for errors. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230109155836.2220277-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-101-1/+1
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* gpiolib: implement gpiod_set_valueAhmad Fatoum2022-02-071-1/+7
| | | | | | | | | | | | | Linux gpiod_set_value is silent if the GPIO descriptor is NULL, but barebox warns about it. Also having gpio_set_value not respect active low/high, while Linux gpiod_set_value respects it is error-prone. Add a new gpiod_set_value function that covers this. gpio == -ENOENT is taken as the dummy value for optional GPIOs. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220202223023.341817-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* gpiolib: add Linux-like gpiod_get() helperAhmad Fatoum2021-04-131-0/+26
Many Linux drivers use [devm_]gpiod_get to get appropriately configured GPIO descriptors out with little code. Make porting such Linux code easier by providing a semi-compatible gpiod_get function. Main differences: - It returns a gpio index, so it can be passed to any gpio_ function - It's device-tree only, so it should only be used from drivers that themselves probe from device tree. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.pengutronix.de/20210410103511.2073504-1-ahmad@a3f.at