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> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame^] | 8 | #include <asm/global_data.h> |
Chris Packham | b55b2c9 | 2019-01-10 21:01:00 +1300 | [diff] [blame] | 9 | #include <asm/gpio.h> |
| 10 | |
| 11 | DECLARE_GLOBAL_DATA_PTR; |
| 12 | |
| 13 | int gpio_hog_list(struct gpio_desc *gpiod, int max_count, |
| 14 | const char *node_name, const char *gpio_name, int value) |
| 15 | { |
| 16 | int node; |
| 17 | int count; |
| 18 | int i; |
| 19 | |
| 20 | node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, node_name); |
| 21 | if (node < 0) |
| 22 | return -ENODEV; |
| 23 | |
| 24 | if (!dm_gpio_is_valid(gpiod)) { |
| 25 | count = |
| 26 | gpio_request_list_by_name_nodev(offset_to_ofnode(node), |
| 27 | gpio_name, gpiod, max_count, |
| 28 | GPIOD_IS_OUT); |
| 29 | if (count < 0) |
| 30 | return count; |
| 31 | |
| 32 | for (i = 0; i < count; i++) |
| 33 | dm_gpio_set_value(&gpiod[i], value); |
| 34 | } |
| 35 | |
| 36 | return 0; |
| 37 | } |