Lines Matching +full:i2c +full:- +full:bus +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Linux I2C core OF support code
11 #include <dt-bindings/i2c/i2c.h>
14 #include <linux/i2c.h>
20 #include "i2c-core.h"
30 if (of_alias_from_compatible(node, info->type, sizeof(info->type)) < 0) { in of_i2c_get_board_info()
32 return -EINVAL; in of_i2c_get_board_info()
43 info->flags |= I2C_CLIENT_TEN; in of_i2c_get_board_info()
48 info->flags |= I2C_CLIENT_SLAVE; in of_i2c_get_board_info()
51 info->addr = addr; in of_i2c_get_board_info()
52 info->of_node = node; in of_i2c_get_board_info()
53 info->fwnode = of_fwnode_handle(node); in of_i2c_get_board_info()
55 if (of_property_read_bool(node, "host-notify")) in of_i2c_get_board_info()
56 info->flags |= I2C_CLIENT_HOST_NOTIFY; in of_i2c_get_board_info()
58 if (of_property_read_bool(node, "wakeup-source")) in of_i2c_get_board_info()
59 info->flags |= I2C_CLIENT_WAKE; in of_i2c_get_board_info()
72 dev_dbg(&adap->dev, "of_i2c: register %pOF\n", node); in of_i2c_register_device()
74 ret = of_i2c_get_board_info(&adap->dev, node, &info); in of_i2c_register_device()
80 dev_err(&adap->dev, "of_i2c: Failure registering %pOF\n", node); in of_i2c_register_device()
87 struct device_node *bus, *node; in of_i2c_register_devices() local
91 if (!adap->dev.of_node) in of_i2c_register_devices()
94 dev_dbg(&adap->dev, "of_i2c: walking child nodes\n"); in of_i2c_register_devices()
96 bus = of_get_child_by_name(adap->dev.of_node, "i2c-bus"); in of_i2c_register_devices()
97 if (!bus) in of_i2c_register_devices()
98 bus = of_node_get(adap->dev.of_node); in of_i2c_register_devices()
100 for_each_available_child_of_node(bus, node) { in of_i2c_register_devices()
106 dev_err(&adap->dev, in of_i2c_register_devices()
107 "Failed to create I2C device for %pOF\n", in of_i2c_register_devices()
113 of_node_put(bus); in of_i2c_register_devices()
120 const char *name; in i2c_of_match_device_sysfs() local
122 for (; matches->compatible[0]; matches++) { in i2c_of_match_device_sysfs()
124 * Adding devices through the i2c sysfs interface provides us in i2c_of_match_device_sysfs()
129 if (sysfs_streq(client->name, matches->compatible)) in i2c_of_match_device_sysfs()
132 name = strchr(matches->compatible, ','); in i2c_of_match_device_sysfs()
133 if (!name) in i2c_of_match_device_sysfs()
134 name = matches->compatible; in i2c_of_match_device_sysfs()
136 name++; in i2c_of_match_device_sysfs()
138 if (sysfs_streq(client->name, name)) in i2c_of_match_device_sysfs()
154 match = of_match_device(matches, &client->dev); in i2c_of_match_device()
172 adap = of_find_i2c_adapter_by_node(rd->dn->parent); in of_i2c_notify()
176 if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) { in of_i2c_notify()
177 put_device(&adap->dev); in of_i2c_notify()
185 rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; in of_i2c_notify()
186 client = of_i2c_register_device(adap, rd->dn); in of_i2c_notify()
188 dev_err(&adap->dev, "failed to create client for '%pOF'\n", in of_i2c_notify()
189 rd->dn); in of_i2c_notify()
190 put_device(&adap->dev); in of_i2c_notify()
191 of_node_clear_flag(rd->dn, OF_POPULATED); in of_i2c_notify()
194 put_device(&adap->dev); in of_i2c_notify()
198 if (!of_node_check_flag(rd->dn, OF_POPULATED)) in of_i2c_notify()
202 client = of_find_i2c_device_by_node(rd->dn); in of_i2c_notify()
210 put_device(&client->dev); in of_i2c_notify()