Lines Matching +full:bus +full:- +full:addr

1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 // Copyright(c) 2015-17 Intel Corporation.
8 #include "bus.h"
15 mutex_destroy(&slave->sdw_dev_lock); in sdw_slave_release()
25 int sdw_slave_add(struct sdw_bus *bus, in sdw_slave_add() argument
34 return -ENOMEM; in sdw_slave_add()
37 memcpy(&slave->id, id, sizeof(*id)); in sdw_slave_add()
38 slave->dev.parent = bus->dev; in sdw_slave_add()
39 slave->dev.fwnode = fwnode; in sdw_slave_add()
41 if (id->unique_id == SDW_IGNORED_UNIQUE_ID) { in sdw_slave_add()
43 dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x", in sdw_slave_add()
44 bus->link_id, id->mfg_id, id->part_id, in sdw_slave_add()
45 id->class_id); in sdw_slave_add()
48 dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x:%01x", in sdw_slave_add()
49 bus->link_id, id->mfg_id, id->part_id, in sdw_slave_add()
50 id->class_id, id->unique_id); in sdw_slave_add()
53 slave->dev.bus = &sdw_bus_type; in sdw_slave_add()
54 slave->dev.of_node = of_node_get(to_of_node(fwnode)); in sdw_slave_add()
55 slave->dev.type = &sdw_slave_type; in sdw_slave_add()
56 slave->dev.groups = sdw_slave_status_attr_groups; in sdw_slave_add()
57 slave->bus = bus; in sdw_slave_add()
58 slave->status = SDW_SLAVE_UNATTACHED; in sdw_slave_add()
59 init_completion(&slave->enumeration_complete); in sdw_slave_add()
60 init_completion(&slave->initialization_complete); in sdw_slave_add()
61 slave->dev_num = 0; in sdw_slave_add()
62 slave->probed = false; in sdw_slave_add()
63 slave->first_interrupt_done = false; in sdw_slave_add()
64 mutex_init(&slave->sdw_dev_lock); in sdw_slave_add()
67 init_completion(&slave->port_ready[i]); in sdw_slave_add()
69 mutex_lock(&bus->bus_lock); in sdw_slave_add()
70 list_add_tail(&slave->node, &bus->slaves); in sdw_slave_add()
71 mutex_unlock(&bus->bus_lock); in sdw_slave_add()
73 ret = device_register(&slave->dev); in sdw_slave_add()
75 dev_err(bus->dev, "Failed to add slave: ret %d\n", ret); in sdw_slave_add()
81 mutex_lock(&bus->bus_lock); in sdw_slave_add()
82 list_del(&slave->node); in sdw_slave_add()
83 mutex_unlock(&bus->bus_lock); in sdw_slave_add()
84 put_device(&slave->dev); in sdw_slave_add()
96 static bool find_slave(struct sdw_bus *bus, in find_slave() argument
100 u64 addr; in find_slave() local
104 status = acpi_evaluate_integer(adev->handle, in find_slave()
105 METHOD_NAME__ADR, NULL, &addr); in find_slave()
108 dev_err(bus->dev, "_ADR resolution failed: %x\n", in find_slave()
113 if (bus->ops->override_adr) in find_slave()
114 addr = bus->ops->override_adr(bus, addr); in find_slave()
116 if (!addr) in find_slave()
120 link_id = SDW_DISCO_LINK_ID(addr); in find_slave()
123 if (link_id != bus->link_id) in find_slave()
126 sdw_extract_slave_id(bus, addr, id); in find_slave()
132 struct sdw_bus *bus; member
141 struct sdw_bus *bus = cwd->bus; in sdw_acpi_check_duplicate() local
144 if (adev == cwd->adev) in sdw_acpi_check_duplicate()
147 if (!find_slave(bus, adev, &id)) in sdw_acpi_check_duplicate()
150 if (cwd->id.sdw_version != id.sdw_version || cwd->id.mfg_id != id.mfg_id || in sdw_acpi_check_duplicate()
151 cwd->id.part_id != id.part_id || cwd->id.class_id != id.class_id) in sdw_acpi_check_duplicate()
154 if (cwd->id.unique_id != id.unique_id) { in sdw_acpi_check_duplicate()
155 dev_dbg(bus->dev, in sdw_acpi_check_duplicate()
157 cwd->id.unique_id, id.unique_id, cwd->id.mfg_id, in sdw_acpi_check_duplicate()
158 cwd->id.part_id); in sdw_acpi_check_duplicate()
159 cwd->ignore_unique_id = false; in sdw_acpi_check_duplicate()
163 dev_err(bus->dev, in sdw_acpi_check_duplicate()
165 cwd->id.unique_id, id.unique_id, cwd->id.mfg_id, cwd->id.part_id); in sdw_acpi_check_duplicate()
166 return -ENODEV; in sdw_acpi_check_duplicate()
171 struct sdw_bus *bus = data; in sdw_acpi_find_one() local
173 .bus = bus, in sdw_acpi_find_one()
179 if (!find_slave(bus, adev, &cwd.id)) in sdw_acpi_find_one()
182 /* Brute-force O(N^2) search for duplicates. */ in sdw_acpi_find_one()
183 ret = acpi_dev_for_each_child(ACPI_COMPANION(bus->dev), in sdw_acpi_find_one()
192 sdw_slave_add(bus, &cwd.id, acpi_fwnode_handle(adev)); in sdw_acpi_find_one()
197 * sdw_acpi_find_slaves() - Find Slave devices in Master ACPI node
198 * @bus: SDW bus instance
202 int sdw_acpi_find_slaves(struct sdw_bus *bus) in sdw_acpi_find_slaves() argument
206 parent = ACPI_COMPANION(bus->dev); in sdw_acpi_find_slaves()
208 dev_err(bus->dev, "Can't find parent for acpi bind\n"); in sdw_acpi_find_slaves()
209 return -ENODEV; in sdw_acpi_find_slaves()
212 return acpi_dev_for_each_child(parent, sdw_acpi_find_one, bus); in sdw_acpi_find_slaves()
218 * sdw_of_find_slaves() - Find Slave devices in master device tree node
219 * @bus: SDW bus instance
223 int sdw_of_find_slaves(struct sdw_bus *bus) in sdw_of_find_slaves() argument
225 struct device *dev = bus->dev; in sdw_of_find_slaves()
228 for_each_child_of_node(bus->dev->of_node, node) { in sdw_of_find_slaves()
233 const __be32 *addr; in sdw_of_find_slaves() local
248 addr = of_get_property(node, "reg", &len); in sdw_of_find_slaves()
249 if (!addr || (len < 2 * sizeof(u32))) { in sdw_of_find_slaves()
254 link_id = be32_to_cpup(addr++); in sdw_of_find_slaves()
255 id.unique_id = be32_to_cpup(addr); in sdw_of_find_slaves()
259 if (link_id != bus->link_id) in sdw_of_find_slaves()
262 sdw_slave_add(bus, &id, of_fwnode_handle(node)); in sdw_of_find_slaves()