Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Eibach | fb60594 | 2017-02-22 16:07:23 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2016 |
| 4 | * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc |
Dirk Eibach | fb60594 | 2017-02-22 16:07:23 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Dirk Eibach | fb60594 | 2017-02-22 16:07:23 +0100 | [diff] [blame] | 7 | #include <i2c.h> |
| 8 | #include <fdt_support.h> |
| 9 | #include <asm-generic/gpio.h> |
| 10 | #include <dm.h> |
| 11 | |
| 12 | int fdt_disable_by_ofname(void *rw_fdt_blob, char *ofname) |
| 13 | { |
| 14 | int offset = fdt_path_offset(rw_fdt_blob, ofname); |
| 15 | |
| 16 | return fdt_status_disabled(rw_fdt_blob, offset); |
| 17 | } |
| 18 | |
| 19 | bool dm_i2c_simple_probe(struct udevice *bus, uint chip_addr) |
| 20 | { |
| 21 | struct udevice *dev; |
| 22 | |
| 23 | return !dm_i2c_probe(bus, chip_addr, DM_I2C_CHIP_RD_ADDRESS | |
| 24 | DM_I2C_CHIP_WR_ADDRESS, &dev); |
| 25 | } |
| 26 | |
| 27 | int request_gpio_by_name(struct gpio_desc *gpio, const char *gpio_dev_name, |
| 28 | uint offset, char *gpio_name) |
| 29 | { |
| 30 | struct udevice *gpio_dev = NULL; |
| 31 | |
| 32 | if (uclass_get_device_by_name(UCLASS_GPIO, gpio_dev_name, &gpio_dev)) |
| 33 | return 1; |
| 34 | |
| 35 | gpio->dev = gpio_dev; |
| 36 | gpio->offset = offset; |
| 37 | gpio->flags = 0; |
| 38 | |
| 39 | return dm_gpio_request(gpio, gpio_name); |
| 40 | } |