blob: c859024a28bb5f3e7471caf7881ac66d2db88363 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dirk Eibach60083262017-02-22 16:07:23 +01002/*
3 * (C) Copyright 2016
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
Dirk Eibach60083262017-02-22 16:07:23 +01005 */
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
13int 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
20bool 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
28int 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