Lines Matching +full:d +full:- +full:bus

1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 // Copyright(c) 2015-22 Intel Corporation.
22 #include "bus.h"
32 * flags reused in each byte, with master0 using the ls-byte, etc.
71 if (slave->id.part_id == wake_capable_list[i].part_id && in is_wake_capable()
72 slave->id.mfg_id == wake_capable_list[i].mfg_id) in is_wake_capable()
77 static int generic_pre_bank_switch(struct sdw_bus *bus) in generic_pre_bank_switch() argument
79 struct sdw_cdns *cdns = bus_to_cdns(bus); in generic_pre_bank_switch()
82 return sdw->link_res->hw_ops->pre_bank_switch(sdw); in generic_pre_bank_switch()
85 static int generic_post_bank_switch(struct sdw_bus *bus) in generic_post_bank_switch() argument
87 struct sdw_cdns *cdns = bus_to_cdns(bus); in generic_post_bank_switch()
90 return sdw->link_res->hw_ops->post_bank_switch(sdw); in generic_post_bank_switch()
93 static void generic_new_peripheral_assigned(struct sdw_bus *bus, in generic_new_peripheral_assigned() argument
97 struct sdw_cdns *cdns = bus_to_cdns(bus); in generic_new_peripheral_assigned()
101 bool wake_capable = slave->prop.wake_capable || is_wake_capable(slave); in generic_new_peripheral_assigned()
108 dev_num_max = SDW_INTEL_DEV_NUM_IDA_MIN - 1; in generic_new_peripheral_assigned()
113 dev_err(bus->dev, "%s: invalid dev_num %d, wake supported %d\n", in generic_new_peripheral_assigned()
114 __func__, dev_num, slave->prop.wake_capable); in generic_new_peripheral_assigned()
118 if (sdw->link_res->hw_ops->program_sdi && wake_capable) in generic_new_peripheral_assigned()
119 sdw->link_res->hw_ops->program_sdi(sdw, dev_num); in generic_new_peripheral_assigned()
122 static int sdw_master_read_intel_prop(struct sdw_bus *bus) in sdw_master_read_intel_prop() argument
124 struct sdw_master_prop *prop = &bus->prop; in sdw_master_read_intel_prop()
131 "mipi-sdw-link-%d-subproperties", bus->link_id); in sdw_master_read_intel_prop()
133 link = device_get_named_child_node(bus->dev, name); in sdw_master_read_intel_prop()
135 dev_err(bus->dev, "Master node %s not found\n", name); in sdw_master_read_intel_prop()
136 return -EIO; in sdw_master_read_intel_prop()
140 "intel-sdw-ip-clock", in sdw_master_read_intel_prop()
141 &prop->mclk_freq); in sdw_master_read_intel_prop()
143 /* the values reported by BIOS are the 2x clock, not the bus clock */ in sdw_master_read_intel_prop()
144 prop->mclk_freq /= 2; in sdw_master_read_intel_prop()
147 "intel-quirk-mask", in sdw_master_read_intel_prop()
151 prop->hw_disabled = true; in sdw_master_read_intel_prop()
153 prop->quirks = SDW_MASTER_QUIRKS_CLEAR_INITIAL_CLASH | in sdw_master_read_intel_prop()
159 static int intel_prop_read(struct sdw_bus *bus) in intel_prop_read() argument
162 sdw_master_read_prop(bus); in intel_prop_read()
164 /* read Intel-specific properties */ in intel_prop_read()
165 sdw_master_read_intel_prop(bus); in intel_prop_read()
172 static int intel_get_device_num_ida(struct sdw_bus *bus, struct sdw_slave *slave) in intel_get_device_num_ida() argument
176 if (slave->prop.wake_capable || is_wake_capable(slave)) in intel_get_device_num_ida()
181 bit = find_first_zero_bit(slave->bus->assigned, SDW_MAX_DEVICES); in intel_get_device_num_ida()
183 return -ENODEV; in intel_get_device_num_ida()
188 static void intel_put_device_num_ida(struct sdw_bus *bus, struct sdw_slave *slave) in intel_put_device_num_ida() argument
190 if (slave->prop.wake_capable || is_wake_capable(slave)) in intel_put_device_num_ida()
191 ida_free(&intel_peripheral_ida, slave->dev_num); in intel_put_device_num_ida()
215 struct device *dev = &auxdev->dev; in intel_link_probe()
219 struct sdw_bus *bus; in intel_link_probe() local
224 return -ENOMEM; in intel_link_probe()
226 cdns = &sdw->cdns; in intel_link_probe()
227 bus = &cdns->bus; in intel_link_probe()
229 sdw->instance = auxdev->id; in intel_link_probe()
230 sdw->link_res = &ldev->link_res; in intel_link_probe()
231 cdns->dev = dev; in intel_link_probe()
232 cdns->registers = sdw->link_res->registers; in intel_link_probe()
233 cdns->ip_offset = sdw->link_res->ip_offset; in intel_link_probe()
234 cdns->instance = sdw->instance; in intel_link_probe()
235 cdns->msg_count = 0; in intel_link_probe()
238 bus->controller_id = 0; in intel_link_probe()
240 bus->link_id = auxdev->id; in intel_link_probe()
241 bus->clk_stop_timeout = 1; in intel_link_probe()
246 bus->ops = &sdw_intel_ops; in intel_link_probe()
252 sdw->cdns.bus.compute_params = sdw_compute_params; in intel_link_probe()
257 ret = sdw_bus_master_add(bus, dev, dev->fwnode); in intel_link_probe()
259 dev_err(dev, "sdw_bus_master_add fail: %d\n", ret); in intel_link_probe()
263 if (bus->prop.hw_disabled) in intel_link_probe()
265 "SoundWire master %d is disabled, will be ignored\n", in intel_link_probe()
266 bus->link_id); in intel_link_probe()
271 bus->prop.err_threshold = 0; in intel_link_probe()
278 struct device *dev = &auxdev->dev; in intel_link_startup()
281 struct sdw_bus *bus = &cdns->bus; in intel_link_startup() local
287 if (bus->prop.hw_disabled) { in intel_link_startup()
289 "SoundWire master %d is disabled, ignoring\n", in intel_link_startup()
290 sdw->instance); in intel_link_startup()
294 link_flags = md_flags >> (bus->link_id * 8); in intel_link_startup()
297 dev_dbg(dev, "Multi-link is disabled\n"); in intel_link_startup()
300 * hardware-based synchronization is required regardless in intel_link_startup()
301 * of the number of segments used by a stream: SSP-based in intel_link_startup()
302 * synchronization is gated by gsync when the multi-master in intel_link_startup()
305 bus->hw_sync_min_links = 1; in intel_link_startup()
307 bus->multi_link = multi_link; in intel_link_startup()
317 dev_err(dev, "DAI registration failed: %d\n", ret); in intel_link_startup()
333 pm_runtime_resume(bus->dev); in intel_link_startup()
336 /* start bus */ in intel_link_startup()
339 dev_err(dev, "bus start failed: %d\n", ret); in intel_link_startup()
343 clock_stop_quirks = sdw->link_res->clock_stop_quirks; in intel_link_startup()
360 * there are no Slave devices populated or if the power-on is in intel_link_startup()
364 * Conditionally force the pm_runtime core to re-evaluate the in intel_link_startup()
371 pm_runtime_mark_last_busy(bus->dev); in intel_link_startup()
376 sdw->startup_done = true; in intel_link_startup()
392 struct sdw_bus *bus = &cdns->bus; in intel_link_remove() local
399 if (!bus->prop.hw_disabled) { in intel_link_remove()
401 cancel_delayed_work_sync(&cdns->attach_dwork); in intel_link_remove()
404 sdw_bus_master_delete(bus); in intel_link_remove()
409 struct device *dev = &auxdev->dev; in intel_link_process_wakeen_event()
411 struct sdw_bus *bus; in intel_link_process_wakeen_event() local
414 bus = &sdw->cdns.bus; in intel_link_process_wakeen_event()
416 if (bus->prop.hw_disabled || !sdw->startup_done) { in intel_link_process_wakeen_event()
417 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n", in intel_link_process_wakeen_event()
418 bus->link_id); in intel_link_process_wakeen_event()
429 * resume the Master, which will generate a bus reset and result in in intel_link_process_wakeen_event()
430 * Slaves re-attaching and be re-enumerated. The SoundWire physical in intel_link_process_wakeen_event()
449 if (!slave->probed) { in intel_resume_child_device()
453 if (!slave->dev_num_sticky) { in intel_resume_child_device()
454 dev_dbg(dev, "skipping device, never detected on bus\n"); in intel_resume_child_device()
460 dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret); in intel_resume_child_device()
471 struct sdw_bus *bus = &cdns->bus; in intel_pm_prepare() local
475 if (bus->prop.hw_disabled || !sdw->startup_done) { in intel_pm_prepare()
476 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n", in intel_pm_prepare()
477 bus->link_id); in intel_pm_prepare()
481 clock_stop_quirks = sdw->link_res->clock_stop_quirks; in intel_pm_prepare()
484 pm_runtime_suspended(dev->parent) && in intel_pm_prepare()
490 * The only solution is to resume the entire bus to full power in intel_pm_prepare()
505 dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret); in intel_pm_prepare()
510 * Continue resuming the entire bus (parent + child devices) to exit in intel_pm_prepare()
512 * this is a no-op. in intel_pm_prepare()
515 * of code to handle an Intel-specific corner case. It is simpler in in intel_pm_prepare()
518 ret = device_for_each_child(bus->dev, NULL, intel_resume_child_device); in intel_pm_prepare()
521 dev_err(dev, "%s: intel_resume_child_device failed: %d\n", __func__, ret); in intel_pm_prepare()
531 struct sdw_bus *bus = &cdns->bus; in intel_suspend() local
535 if (bus->prop.hw_disabled || !sdw->startup_done) { in intel_suspend()
536 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n", in intel_suspend()
537 bus->link_id); in intel_suspend()
544 clock_stop_quirks = sdw->link_res->clock_stop_quirks; in intel_suspend()
549 if (pm_runtime_suspended(dev->parent)) { in intel_suspend()
565 dev_err(dev, "%s: cannot stop bus: %d\n", __func__, ret); in intel_suspend()
576 struct sdw_bus *bus = &cdns->bus; in intel_suspend_runtime() local
580 if (bus->prop.hw_disabled || !sdw->startup_done) { in intel_suspend_runtime()
581 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n", in intel_suspend_runtime()
582 bus->link_id); in intel_suspend_runtime()
586 clock_stop_quirks = sdw->link_res->clock_stop_quirks; in intel_suspend_runtime()
591 dev_err(dev, "%s: cannot stop bus during teardown: %d\n", in intel_suspend_runtime()
598 dev_err(dev, "%s: cannot stop bus during clock_stop: %d\n", in intel_suspend_runtime()
605 ret = -EINVAL; in intel_suspend_runtime()
615 struct sdw_bus *bus = &cdns->bus; in intel_resume() local
619 if (bus->prop.hw_disabled || !sdw->startup_done) { in intel_resume()
620 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n", in intel_resume()
621 bus->link_id); in intel_resume()
625 link_flags = md_flags >> (bus->link_id * 8); in intel_resume()
636 pm_runtime_resume(bus->dev); in intel_resume()
638 link_flags = md_flags >> (bus->link_id * 8); in intel_resume()
646 dev_err(dev, "%s failed: %d\n", __func__, ret); in intel_resume()
654 sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET); in intel_resume()
658 dev_err(dev, "cannot start bus during resume\n"); in intel_resume()
667 * routines is not really possible, since it'd prevent the in intel_resume()
673 pm_runtime_mark_last_busy(bus->dev); in intel_resume()
683 struct sdw_bus *bus = &cdns->bus; in intel_resume_runtime() local
687 if (bus->prop.hw_disabled || !sdw->startup_done) { in intel_resume_runtime()
688 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n", in intel_resume_runtime()
689 bus->link_id); in intel_resume_runtime()
696 clock_stop_quirks = sdw->link_res->clock_stop_quirks; in intel_resume_runtime()
701 dev_err(dev, "%s: power_up failed after teardown: %d\n", __func__, ret); in intel_resume_runtime()
709 sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET); in intel_resume_runtime()
713 dev_err(dev, "%s: cannot start bus after teardown: %d\n", __func__, ret); in intel_resume_runtime()
721 dev_err(dev, "%s: power_up failed after bus reset: %d\n", __func__, ret); in intel_resume_runtime()
727 dev_err(dev, "%s: cannot start bus after reset: %d\n", __func__, ret); in intel_resume_runtime()
737 dev_err(dev, "%s: power_up failed: %d\n", __func__, ret); in intel_resume_runtime()
743 dev_err(dev, "%s: cannot start bus after clock stop: %d\n", __func__, ret); in intel_resume_runtime()
750 ret = -EINVAL; in intel_resume_runtime()