diff options
Diffstat (limited to 'roms/u-boot/board/alliedtelesis/common')
-rw-r--r-- | roms/u-boot/board/alliedtelesis/common/gpio_hog.c | 37 | ||||
-rw-r--r-- | roms/u-boot/board/alliedtelesis/common/gpio_hog.h | 13 |
2 files changed, 50 insertions, 0 deletions
diff --git a/roms/u-boot/board/alliedtelesis/common/gpio_hog.c b/roms/u-boot/board/alliedtelesis/common/gpio_hog.c new file mode 100644 index 000000000..4aecf7e2c --- /dev/null +++ b/roms/u-boot/board/alliedtelesis/common/gpio_hog.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Allied Telesis Labs + */ + +#include <common.h> +#include <dm.h> +#include <asm/global_data.h> +#include <asm/gpio.h> + +DECLARE_GLOBAL_DATA_PTR; + +int gpio_hog_list(struct gpio_desc *gpiod, int max_count, + const char *node_name, const char *gpio_name, int value) +{ + int node; + int count; + int i; + + node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, node_name); + if (node < 0) + return -ENODEV; + + if (!dm_gpio_is_valid(gpiod)) { + count = + gpio_request_list_by_name_nodev(offset_to_ofnode(node), + gpio_name, gpiod, max_count, + GPIOD_IS_OUT); + if (count < 0) + return count; + + for (i = 0; i < count; i++) + dm_gpio_set_value(&gpiod[i], value); + } + + return 0; +} diff --git a/roms/u-boot/board/alliedtelesis/common/gpio_hog.h b/roms/u-boot/board/alliedtelesis/common/gpio_hog.h new file mode 100644 index 000000000..edb744313 --- /dev/null +++ b/roms/u-boot/board/alliedtelesis/common/gpio_hog.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2017 Allied Telesis Labs + */ + +int gpio_hog_list(struct gpio_desc *gpiod, int max_count, const char *node_name, + const char *gpio_name, int value); + +static inline int gpio_hog(struct gpio_desc *gpiod, const char *node_name, + const char *gpio_name, int value) +{ + return gpio_hog_list(gpiod, 1, node_name, gpio_name, value); +} |