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;
47 return -ENODEV;
63 return ERR_PTR(-EINVAL);
65 return ac97_ctrl->codecs[codec_num];
74 char compat[] = "ac97,0000,0000";
76 snprintf(compat, sizeof(compat), "ac97,%04x,%04x",
79 for_each_child_of_node(ac97_ctrl->parent->of_node, node) {
95 ac97_ctrl = adev->ac97_ctrl;
96 ac97_ctrl->codecs[adev->num] = NULL;
97 of_node_put(dev->of_node);
109 return -ENOMEM;
110 ac97_ctrl->codecs[idx] = codec;
111 codec->vendor_id = vendor_id;
112 codec->dev.release = ac97_codec_release;
113 codec->dev.bus = &ac97_bus_type;
114 codec->dev.parent = &ac97_ctrl->adap;
115 codec->num = idx;
116 codec->ac97_ctrl = ac97_ctrl;
118 device_initialize(&codec->dev);
119 dev_set_name(&codec->dev, "%s:%u", dev_name(ac97_ctrl->parent), idx);
120 codec->dev.of_node = ac97_of_get_child_device(ac97_ctrl, idx,
123 ret = device_add(&codec->dev);
125 put_device(&codec->dev);
138 ret = adrv->ops->read(adrv, codec_num, AC97_VENDOR_ID1);
143 ret = adrv->ops->read(adrv, codec_num, AC97_VENDOR_ID2);
148 dev_dbg(&adrv->adap, "%s(codec_num=%u): vendor_id=0x%08x\n",
161 if (!(ac97_ctrl->slots_available & BIT(i)))
176 ac97_ctrl->ops->reset(ac97_ctrl);
182 * snd_ac97_codec_driver_register - register an AC97 codec driver
183 * @drv: 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;
193 return driver_register(&drv->driver);
198 * snd_ac97_codec_driver_unregister - unregister an AC97 codec driver
199 * @drv: AC97 codec driver to unregister
201 * Unregister a previously registered ac97 codec driver.
205 driver_unregister(&drv->driver);
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;
223 return ac97_ctrl->codecs_pdata[adev->num];
232 if (ac97_ctrl->codecs[i]) {
233 ac97_ctrl->codecs[i]->ac97_ctrl = &ac97_unbound_ctrl;
234 device_unregister(&ac97_ctrl->codecs[i]->dev);
246 ac97_ctrl->ops->reset(ac97_ctrl);
259 return -ENODEV;
263 ac97_ctrl->ops->warm_reset(ac97_ctrl);
289 list_del(&ac97_ctrl->controllers);
292 device_unregister(&ac97_ctrl->adap);
300 idr_remove(&ac97_adapter_idr, ac97_ctrl->nr);
301 dev_dbg(&ac97_ctrl->adap, "adapter unregistered by %s\n",
302 dev_name(ac97_ctrl->parent));
316 ac97_ctrl->nr = ret;
318 dev_set_name(&ac97_ctrl->adap, "ac97-%d", ret);
319 ac97_ctrl->adap.type = &ac97_adapter_type;
320 ac97_ctrl->adap.parent = ac97_ctrl->parent;
321 ret = device_register(&ac97_ctrl->adap);
323 put_device(&ac97_ctrl->adap);
326 list_add(&ac97_ctrl->controllers, &ac97_controllers);
330 dev_dbg(&ac97_ctrl->adap, "adapter registered by %s\n",
331 dev_name(ac97_ctrl->parent));
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
343 * Register a digital controller which can control up to 4 ac97 codecs. This is
344 * the controller side of the AC97 AC-link, while the slave side are the codecs.
346 * Returns a valid controller upon success, negative pointer value upon error
357 return ERR_PTR(-ENOMEM);
360 ac97_ctrl->codecs_pdata[i] = codecs_pdata[i];
362 ac97_ctrl->ops = ops;
363 ac97_ctrl->slots_available = slots_available;
364 ac97_ctrl->parent = dev;
380 * snd_ac97_controller_unregister - unregister an ac97 controller
396 if (ret == 0 && dev->driver) {
398 clk_disable(codec->clk);
400 clk_disable_unprepare(codec->clk);
411 if (dev->driver) {
413 ret = clk_enable(codec->clk);
415 ret = clk_prepare_enable(codec->clk);
441 adev->clk = clk_get(&adev->dev, "ac97_clk");
442 if (IS_ERR(adev->clk))
443 return PTR_ERR(adev->clk);
445 ret = clk_prepare_enable(adev->clk);
447 clk_put(adev->clk);
454 clk_disable_unprepare(adev->clk);
455 clk_put(adev->clk);
463 return sysfs_emit(buf, "%08x", codec->vendor_id);
477 const struct ac97_id *id = adrv->id_table;
480 if (adev->vendor_id == 0x0 || adev->vendor_id == 0xffffffff)
484 if (ac97_ids_match(id[i].id, adev->vendor_id, id[i].mask))
494 struct ac97_codec_driver *adrv = to_ac97_driver(dev->driver);
505 ret = adrv->probe(adev);
520 struct ac97_codec_driver *adrv = to_ac97_driver(dev->driver);
527 adrv->remove(adev);
555 MODULE_DESCRIPTION("AC97 bus interface");