blob: a12e115c72cbb89bdbba8c867bde1e46a382315b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dirk Eibachfb605942017-02-22 16:07:23 +01002/*
3 * (C) Copyright 2016
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
Dirk Eibachfb605942017-02-22 16:07:23 +01005 */
6
Dirk Eibachfb605942017-02-22 16:07:23 +01007#include <i2c.h>
8#include <fdt_support.h>
9#include <asm-generic/gpio.h>
10#include <dm.h>
11
12int 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
19bool 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
27int 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}