Chris Packham | b55b2c9 | 2019-01-10 21:01:00 +1300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2018 Allied Telesis Labs |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <asm/gpio.h> |
| 9 | |
| 10 | DECLARE_GLOBAL_DATA_PTR; |
| 11 | |
| 12 | int gpio_hog_list(struct gpio_desc *gpiod, int max_count, |
| 13 | const char *node_name, const char *gpio_name, int value) |
| 14 | { |
| 15 | int node; |
| 16 | int count; |
| 17 | int i; |
| 18 | |
| 19 | node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, node_name); |
| 20 | if (node < 0) |
| 21 | return -ENODEV; |
| 22 | |
| 23 | if (!dm_gpio_is_valid(gpiod)) { |
| 24 | count = |
| 25 | gpio_request_list_by_name_nodev(offset_to_ofnode(node), |
| 26 | gpio_name, gpiod, max_count, |
| 27 | GPIOD_IS_OUT); |
| 28 | if (count < 0) |
| 29 | return count; |
| 30 | |
| 31 | for (i = 0; i < count; i++) |
| 32 | dm_gpio_set_value(&gpiod[i], value); |
| 33 | } |
| 34 | |
| 35 | return 0; |
| 36 | } |