Lines Matching +full:ac97 +full:- +full:controller
1 // SPDX-License-Identifier: GPL-2.0-only
19 #include <sound/ac97/codec.h>
20 #include <sound/ac97/controller.h>
21 #include <sound/ac97/regs.h>
41 return -ENODEV; in ac97_unbound_ctrl_write()
47 return -ENODEV; in ac97_unbound_ctrl_read()
63 return ERR_PTR(-EINVAL); in ac97_codec_find()
65 return ac97_ctrl->codecs[codec_num]; in ac97_codec_find()
74 char compat[] = "ac97,0000,0000"; in ac97_of_get_child_device()
76 snprintf(compat, sizeof(compat), "ac97,%04x,%04x", in ac97_of_get_child_device()
79 for_each_child_of_node(ac97_ctrl->parent->of_node, node) { in ac97_of_get_child_device()
95 ac97_ctrl = adev->ac97_ctrl; in ac97_codec_release()
96 ac97_ctrl->codecs[adev->num] = NULL; in ac97_codec_release()
97 of_node_put(dev->of_node); in ac97_codec_release()
109 return -ENOMEM; in ac97_codec_add()
110 ac97_ctrl->codecs[idx] = codec; in ac97_codec_add()
111 codec->vendor_id = vendor_id; in ac97_codec_add()
112 codec->dev.release = ac97_codec_release; in ac97_codec_add()
113 codec->dev.bus = &ac97_bus_type; in ac97_codec_add()
114 codec->dev.parent = &ac97_ctrl->adap; in ac97_codec_add()
115 codec->num = idx; in ac97_codec_add()
116 codec->ac97_ctrl = ac97_ctrl; in ac97_codec_add()
118 device_initialize(&codec->dev); in ac97_codec_add()
119 dev_set_name(&codec->dev, "%s:%u", dev_name(ac97_ctrl->parent), idx); in ac97_codec_add()
120 codec->dev.of_node = ac97_of_get_child_device(ac97_ctrl, idx, in ac97_codec_add()
123 ret = device_add(&codec->dev); in ac97_codec_add()
125 put_device(&codec->dev); in ac97_codec_add()
138 ret = adrv->ops->read(adrv, codec_num, AC97_VENDOR_ID1); in snd_ac97_bus_scan_one()
143 ret = adrv->ops->read(adrv, codec_num, AC97_VENDOR_ID2); in snd_ac97_bus_scan_one()
148 dev_dbg(&adrv->adap, "%s(codec_num=%u): vendor_id=0x%08x\n", in snd_ac97_bus_scan_one()
161 if (!(ac97_ctrl->slots_available & BIT(i))) in ac97_bus_scan()
176 ac97_ctrl->ops->reset(ac97_ctrl); in ac97_bus_reset()
182 * snd_ac97_codec_driver_register - register an AC97 codec driver
183 * @dev: AC97 driver codec to register
185 * Register an AC97 codec driver to the ac97 bus driver, aka. the AC97 digital
186 * controller.
192 drv->driver.bus = &ac97_bus_type; in snd_ac97_codec_driver_register()
193 return driver_register(&drv->driver); in snd_ac97_codec_driver_register()
198 * snd_ac97_codec_driver_unregister - unregister an AC97 codec driver
199 * @dev: AC97 codec driver to unregister
201 * Unregister a previously registered ac97 codec driver.
205 driver_unregister(&drv->driver); in snd_ac97_codec_driver_unregister()
210 * snd_ac97_codec_get_platdata - get platform_data
211 * @adev: the ac97 codec device
214 * available, while ac97 device are auto-created upon probe, this retrieves the
215 * platdata which was setup on ac97 controller registration.
221 struct ac97_controller *ac97_ctrl = adev->ac97_ctrl; in snd_ac97_codec_get_platdata()
223 return ac97_ctrl->codecs_pdata[adev->num]; in snd_ac97_codec_get_platdata()
232 if (ac97_ctrl->codecs[i]) { in ac97_ctrl_codecs_unregister()
233 ac97_ctrl->codecs[i]->ac97_ctrl = &ac97_unbound_ctrl; in ac97_ctrl_codecs_unregister()
234 device_unregister(&ac97_ctrl->codecs[i]->dev); in ac97_ctrl_codecs_unregister()
246 ac97_ctrl->ops->reset(ac97_ctrl); in cold_reset_store()
259 return -ENODEV; in warm_reset_store()
263 ac97_ctrl->ops->warm_reset(ac97_ctrl); in warm_reset_store()
289 list_del(&ac97_ctrl->controllers); in ac97_del_adapter()
292 device_unregister(&ac97_ctrl->adap); in ac97_del_adapter()
300 idr_remove(&ac97_adapter_idr, ac97_ctrl->nr); in ac97_adapter_release()
301 dev_dbg(&ac97_ctrl->adap, "adapter unregistered by %s\n", in ac97_adapter_release()
302 dev_name(ac97_ctrl->parent)); in ac97_adapter_release()
316 ac97_ctrl->nr = ret; in ac97_add_adapter()
318 dev_set_name(&ac97_ctrl->adap, "ac97-%d", ret); in ac97_add_adapter()
319 ac97_ctrl->adap.type = &ac97_adapter_type; in ac97_add_adapter()
320 ac97_ctrl->adap.parent = ac97_ctrl->parent; in ac97_add_adapter()
321 ret = device_register(&ac97_ctrl->adap); in ac97_add_adapter()
323 put_device(&ac97_ctrl->adap); in ac97_add_adapter()
326 list_add(&ac97_ctrl->controllers, &ac97_controllers); in ac97_add_adapter()
330 dev_dbg(&ac97_ctrl->adap, "adapter registered by %s\n", in ac97_add_adapter()
331 dev_name(ac97_ctrl->parent)); in ac97_add_adapter()
336 * snd_ac97_controller_register - register an ac97 controller
337 * @ops: the ac97 bus operations
338 * @dev: the device providing the ac97 DC function
339 * @slots_available: mask of the ac97 codecs that can be scanned and probed
342 * Register a digital controller which can control up to 4 ac97 codecs. This is
343 * the controller side of the AC97 AC-link, while the slave side are the codecs.
345 * Returns a valid controller upon success, negative pointer value upon error
356 return ERR_PTR(-ENOMEM); in snd_ac97_controller_register()
359 ac97_ctrl->codecs_pdata[i] = codecs_pdata[i]; in snd_ac97_controller_register()
361 ac97_ctrl->ops = ops; in snd_ac97_controller_register()
362 ac97_ctrl->slots_available = slots_available; in snd_ac97_controller_register()
363 ac97_ctrl->parent = dev; in snd_ac97_controller_register()
379 * snd_ac97_controller_unregister - unregister an ac97 controller
395 if (ret == 0 && dev->driver) { in ac97_pm_runtime_suspend()
397 clk_disable(codec->clk); in ac97_pm_runtime_suspend()
399 clk_disable_unprepare(codec->clk); in ac97_pm_runtime_suspend()
410 if (dev->driver) { in ac97_pm_runtime_resume()
412 ret = clk_enable(codec->clk); in ac97_pm_runtime_resume()
414 ret = clk_prepare_enable(codec->clk); in ac97_pm_runtime_resume()
440 adev->clk = clk_get(&adev->dev, "ac97_clk"); in ac97_get_enable_clk()
441 if (IS_ERR(adev->clk)) in ac97_get_enable_clk()
442 return PTR_ERR(adev->clk); in ac97_get_enable_clk()
444 ret = clk_prepare_enable(adev->clk); in ac97_get_enable_clk()
446 clk_put(adev->clk); in ac97_get_enable_clk()
453 clk_disable_unprepare(adev->clk); in ac97_put_disable_clk()
454 clk_put(adev->clk); in ac97_put_disable_clk()
462 return sysfs_emit(buf, "%08x", codec->vendor_id); in vendor_id_show()
476 const struct ac97_id *id = adrv->id_table; in ac97_bus_match()
479 if (adev->vendor_id == 0x0 || adev->vendor_id == 0xffffffff) in ac97_bus_match()
483 if (ac97_ids_match(id[i].id, adev->vendor_id, id[i].mask)) in ac97_bus_match()
493 struct ac97_codec_driver *adrv = to_ac97_driver(dev->driver); in ac97_bus_probe()
504 ret = adrv->probe(adev); in ac97_bus_probe()
519 struct ac97_codec_driver *adrv = to_ac97_driver(dev->driver); in ac97_bus_remove()
526 adrv->remove(adev); in ac97_bus_remove()
554 MODULE_DESCRIPTION("AC97 bus interface");