Lines Matching +full:slave +full:- +full:addr
1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 // Copyright(c) 2015-17 Intel Corporation.
13 struct sdw_slave *slave = dev_to_sdw_dev(dev); in sdw_slave_release() local
15 mutex_destroy(&slave->sdw_dev_lock); in sdw_slave_release()
16 kfree(slave); in sdw_slave_release()
28 struct sdw_slave *slave; in sdw_slave_add() local
32 slave = kzalloc(sizeof(*slave), GFP_KERNEL); in sdw_slave_add()
33 if (!slave) in sdw_slave_add()
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:%01x:%04x:%04x:%02x", in sdw_slave_add()
44 bus->controller_id, 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:%01x:%04x:%04x:%02x:%01x", in sdw_slave_add()
49 bus->controller_id, 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()
88 sdw_slave_debugfs_init(slave); in sdw_slave_add()
101 u64 addr; in find_slave() local
104 ret = acpi_get_local_u64_address(adev->handle, &addr); in find_slave()
108 if (bus->ops->override_adr) in find_slave()
109 addr = bus->ops->override_adr(bus, addr); in find_slave()
111 if (!addr) in find_slave()
115 link_id = SDW_DISCO_LINK_ID(addr); in find_slave()
118 if (link_id != bus->link_id) in find_slave()
121 sdw_extract_slave_id(bus, addr, id); in find_slave()
136 struct sdw_bus *bus = cwd->bus; in sdw_acpi_check_duplicate()
139 if (adev == cwd->adev) in sdw_acpi_check_duplicate()
145 if (cwd->id.sdw_version != id.sdw_version || cwd->id.mfg_id != id.mfg_id || in sdw_acpi_check_duplicate()
146 cwd->id.part_id != id.part_id || cwd->id.class_id != id.class_id) in sdw_acpi_check_duplicate()
149 if (cwd->id.unique_id != id.unique_id) { in sdw_acpi_check_duplicate()
150 dev_dbg(bus->dev, in sdw_acpi_check_duplicate()
151 "Valid unique IDs 0x%x 0x%x for Slave mfg_id 0x%04x, part_id 0x%04x\n", in sdw_acpi_check_duplicate()
152 cwd->id.unique_id, id.unique_id, cwd->id.mfg_id, in sdw_acpi_check_duplicate()
153 cwd->id.part_id); in sdw_acpi_check_duplicate()
154 cwd->ignore_unique_id = false; in sdw_acpi_check_duplicate()
158 dev_err(bus->dev, in sdw_acpi_check_duplicate()
159 "Invalid unique IDs 0x%x 0x%x for Slave mfg_id 0x%04x, part_id 0x%04x\n", in sdw_acpi_check_duplicate()
160 cwd->id.unique_id, id.unique_id, cwd->id.mfg_id, cwd->id.part_id); in sdw_acpi_check_duplicate()
161 return -ENODEV; in sdw_acpi_check_duplicate()
177 /* Brute-force O(N^2) search for duplicates. */ in sdw_acpi_find_one()
178 ret = acpi_dev_for_each_child(ACPI_COMPANION(bus->dev), in sdw_acpi_find_one()
192 * sdw_acpi_find_slaves() - Find Slave devices in Master ACPI node
195 * Scans Master ACPI node for SDW child Slave devices and registers it.
201 parent = ACPI_COMPANION(bus->dev); in sdw_acpi_find_slaves()
203 dev_err(bus->dev, "Can't find parent for acpi bind\n"); in sdw_acpi_find_slaves()
204 return -ENODEV; in sdw_acpi_find_slaves()
213 * sdw_of_find_slaves() - Find Slave devices in master device tree node
216 * Scans Master DT node for SDW child Slave devices and registers it.
220 struct device *dev = bus->dev; in sdw_of_find_slaves()
223 for_each_child_of_node(bus->dev->of_node, node) { in sdw_of_find_slaves()
228 const __be32 *addr; in sdw_of_find_slaves() local
243 addr = of_get_property(node, "reg", &len); in sdw_of_find_slaves()
244 if (!addr || (len < 2 * sizeof(u32))) { in sdw_of_find_slaves()
249 link_id = be32_to_cpup(addr++); in sdw_of_find_slaves()
250 id.unique_id = be32_to_cpup(addr); in sdw_of_find_slaves()
254 if (link_id != bus->link_id) in sdw_of_find_slaves()