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