| 1 | |
| 2 | |
| 3 | |
| 4 |
|
| 5 | |
| 6 | * The MIPI SDCA specification is available for public downloads at
|
| 7 | * https://www.mipi.org/mipi-sdca-v1-0-download
|
| 8 |
|
| 9 |
|
| 10 | #include <linux/auxiliary_bus.h>
|
| 11 | #include <linux/cleanup.h>
|
| 12 | #include <linux/minmax.h>
|
| 13 | #include <linux/module.h>
|
| 14 | #include <linux/pm.h>
|
| 15 | #include <linux/pm_runtime.h>
|
| 16 | #include <linux/soundwire/sdw.h>
|
| 17 | #include <linux/soundwire/sdw_registers.h>
|
| 18 | #include <sound/pcm.h>
|
| 19 | #include <sound/sdca_asoc.h>
|
| 20 | #include <sound/sdca_fdl.h>
|
| 21 | #include <sound/sdca_function.h>
|
| 22 | #include <sound/sdca_interrupts.h>
|
| 23 | #include <sound/sdca_jack.h>
|
| 24 | #include <sound/sdca_regmap.h>
|
| 25 | #include <sound/sdw.h>
|
| 26 | #include <sound/soc-component.h>
|
| 27 | #include <sound/soc-dai.h>
|
| 28 | #include <sound/soc.h>
|
| 29 | #include "sdca_class.h"
|
| 30 | #include "sdca_function_device.h"
|
| 31 |
|
| 32 | struct class_function_drv {
|
| 33 | struct device *dev;
|
| 34 | struct regmap *regmap;
|
| 35 | struct sdca_class_drv *core;
|
| 36 |
|
| 37 | struct sdca_function_data *function;
|
| 38 | bool suspended;
|
| 39 | };
|
| 40 |
|
| 41 | static void class_function_regmap_lock(void *data)
|
| 42 | {
|
| 43 | struct mutex *lock = data;
|
| 44 |
|
| 45 | mutex_lock(lock);
|
| 46 | }
|
| 47 |
|
| 48 | static void class_function_regmap_unlock(void *data)
|
| 49 | {
|
| 50 | struct mutex *lock = data;
|
| 51 |
|
| 52 | mutex_unlock(lock);
|
| 53 | }
|
| 54 |
|
| 55 | static bool class_function_regmap_writeable(struct device *dev, unsigned int reg)
|
| 56 | {
|
| 57 | struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
|
| 58 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 59 |
|
| 60 | return sdca_regmap_writeable(drv->function, reg);
|
| 61 | }
|
| 62 |
|
| 63 | static bool class_function_regmap_readable(struct device *dev, unsigned int reg)
|
| 64 | {
|
| 65 | struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
|
| 66 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 67 |
|
| 68 | return sdca_regmap_readable(drv->function, reg);
|
| 69 | }
|
| 70 |
|
| 71 | static bool class_function_regmap_volatile(struct device *dev, unsigned int reg)
|
| 72 | {
|
| 73 | struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
|
| 74 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 75 |
|
| 76 | return sdca_regmap_volatile(drv->function, reg);
|
| 77 | }
|
| 78 |
|
| 79 | static const struct regmap_config class_function_regmap_config = {
|
| 80 | .name = "sdca",
|
| 81 | .reg_bits = 32,
|
| 82 | .val_bits = 32,
|
| 83 | .reg_format_endian = REGMAP_ENDIAN_LITTLE,
|
| 84 | .val_format_endian = REGMAP_ENDIAN_LITTLE,
|
| 85 |
|
| 86 | .max_register = SDW_SDCA_MAX_REGISTER,
|
| 87 | .readable_reg = class_function_regmap_readable,
|
| 88 | .writeable_reg = class_function_regmap_writeable,
|
| 89 | .volatile_reg = class_function_regmap_volatile,
|
| 90 |
|
| 91 | .cache_type = REGCACHE_MAPLE,
|
| 92 |
|
| 93 | .lock = class_function_regmap_lock,
|
| 94 | .unlock = class_function_regmap_unlock,
|
| 95 | };
|
| 96 |
|
| 97 | static int class_function_regmap_mbq_size(struct device *dev, unsigned int reg)
|
| 98 | {
|
| 99 | struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
|
| 100 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 101 |
|
| 102 | return sdca_regmap_mbq_size(drv->function, reg);
|
| 103 | }
|
| 104 |
|
| 105 | static bool class_function_regmap_deferrable(struct device *dev, unsigned int reg)
|
| 106 | {
|
| 107 | struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
|
| 108 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 109 |
|
| 110 | return sdca_regmap_deferrable(drv->function, reg);
|
| 111 | }
|
| 112 |
|
| 113 | static const struct regmap_sdw_mbq_cfg class_function_mbq_config = {
|
| 114 | .mbq_size = class_function_regmap_mbq_size,
|
| 115 | .deferrable = class_function_regmap_deferrable,
|
| 116 | .retry_us = 1000,
|
| 117 | .timeout_us = 10000,
|
| 118 | };
|
| 119 |
|
| 120 | static int class_function_startup(struct snd_pcm_substream *substream,
|
| 121 | struct snd_soc_dai *dai)
|
| 122 | {
|
| 123 | struct class_function_drv *drv = snd_soc_component_get_drvdata(dai->component);
|
| 124 |
|
| 125 | return sdca_asoc_set_constraints(drv->dev, drv->regmap, drv->function,
|
| 126 | substream, dai);
|
| 127 | }
|
| 128 |
|
| 129 | static int class_function_sdw_add_peripheral(struct snd_pcm_substream *substream,
|
| 130 | struct snd_pcm_hw_params *params,
|
| 131 | struct snd_soc_dai *dai)
|
| 132 | {
|
| 133 | struct class_function_drv *drv = snd_soc_component_get_drvdata(dai->component);
|
| 134 | struct sdw_stream_runtime *sdw_stream = snd_soc_dai_get_dma_data(dai, substream);
|
| 135 | struct sdw_slave *sdw = dev_to_sdw_dev(drv->dev->parent);
|
| 136 | struct sdw_stream_config sconfig = {0};
|
| 137 | struct sdw_port_config pconfig = {0};
|
| 138 | int ret;
|
| 139 |
|
| 140 | if (!sdw_stream)
|
| 141 | return -EINVAL;
|
| 142 |
|
| 143 | snd_sdw_params_to_config(substream, params, &sconfig, &pconfig);
|
| 144 |
|
| 145 | |
| 146 | * FIXME: As also noted in sdca_asoc_get_port(), currently only
|
| 147 | * a single unshared port is supported for each DAI.
|
| 148 |
|
| 149 | ret = sdca_asoc_get_port(drv->dev, drv->regmap, drv->function, dai);
|
| 150 | if (ret < 0)
|
| 151 | return ret;
|
| 152 |
|
| 153 | pconfig.num = ret;
|
| 154 |
|
| 155 | ret = sdw_stream_add_slave(sdw, &sconfig, &pconfig, 1, sdw_stream);
|
| 156 | if (ret) {
|
| 157 | dev_err(drv->dev, "failed to add sdw stream: %d\n", ret);
|
| 158 | return ret;
|
| 159 | }
|
| 160 |
|
| 161 | return sdca_asoc_hw_params(drv->dev, drv->regmap, drv->function,
|
| 162 | substream, params, dai);
|
| 163 | }
|
| 164 |
|
| 165 | static int class_function_sdw_remove_peripheral(struct snd_pcm_substream *substream,
|
| 166 | struct snd_soc_dai *dai)
|
| 167 | {
|
| 168 | struct class_function_drv *drv = snd_soc_component_get_drvdata(dai->component);
|
| 169 | struct sdw_stream_runtime *sdw_stream = snd_soc_dai_get_dma_data(dai, substream);
|
| 170 | struct sdw_slave *sdw = dev_to_sdw_dev(drv->dev->parent);
|
| 171 |
|
| 172 | if (!sdw_stream)
|
| 173 | return -EINVAL;
|
| 174 |
|
| 175 | return sdw_stream_remove_slave(sdw, sdw_stream);
|
| 176 | }
|
| 177 |
|
| 178 | static int class_function_sdw_set_stream(struct snd_soc_dai *dai, void *sdw_stream,
|
| 179 | int direction)
|
| 180 | {
|
| 181 | snd_soc_dai_dma_data_set(dai, direction, sdw_stream);
|
| 182 |
|
| 183 | return 0;
|
| 184 | }
|
| 185 |
|
| 186 | static const struct snd_soc_dai_ops class_function_sdw_ops = {
|
| 187 | .startup = class_function_startup,
|
| 188 | .shutdown = sdca_asoc_free_constraints,
|
| 189 | .set_stream = class_function_sdw_set_stream,
|
| 190 | .hw_params = class_function_sdw_add_peripheral,
|
| 191 | .hw_free = class_function_sdw_remove_peripheral,
|
| 192 | };
|
| 193 |
|
| 194 | static int class_function_component_fixup_controls(struct snd_soc_component *component)
|
| 195 | {
|
| 196 | struct class_function_drv *drv = snd_soc_component_get_drvdata(component);
|
| 197 | struct sdca_class_drv *core = drv->core;
|
| 198 |
|
| 199 | return sdca_irq_populate(drv->function, component, core->irq_info);
|
| 200 | }
|
| 201 |
|
| 202 | static void class_function_component_remove(struct snd_soc_component *component)
|
| 203 | {
|
| 204 | struct class_function_drv *drv = snd_soc_component_get_drvdata(component);
|
| 205 | struct sdca_class_drv *core = drv->core;
|
| 206 |
|
| 207 | sdca_irq_cleanup(component->dev, drv->function, core->irq_info);
|
| 208 | }
|
| 209 |
|
| 210 | static int class_function_set_jack(struct snd_soc_component *component,
|
| 211 | struct snd_soc_jack *jack, void *d)
|
| 212 | {
|
| 213 | struct class_function_drv *drv = snd_soc_component_get_drvdata(component);
|
| 214 | struct sdca_class_drv *core = drv->core;
|
| 215 |
|
| 216 | return sdca_jack_set_jack(core->irq_info, jack);
|
| 217 | }
|
| 218 |
|
| 219 | static const struct snd_soc_component_driver class_function_component_drv = {
|
| 220 | .fixup_controls = class_function_component_fixup_controls,
|
| 221 | .remove = class_function_component_remove,
|
| 222 | .endianness = 1,
|
| 223 | };
|
| 224 |
|
| 225 | static int class_function_init_device(struct class_function_drv *drv,
|
| 226 | unsigned int status)
|
| 227 | {
|
| 228 | int ret;
|
| 229 |
|
| 230 | if (!(status & SDCA_CTL_ENTITY_0_FUNCTION_HAS_BEEN_RESET)) {
|
| 231 | dev_dbg(drv->dev, "reset function device\n");
|
| 232 |
|
| 233 | ret = sdca_reset_function(drv->dev, drv->function, drv->regmap);
|
| 234 | if (ret)
|
| 235 | return ret;
|
| 236 | }
|
| 237 |
|
| 238 | if (status & SDCA_CTL_ENTITY_0_FUNCTION_NEEDS_INITIALIZATION) {
|
| 239 | dev_dbg(drv->dev, "write initialisation\n");
|
| 240 |
|
| 241 | ret = sdca_regmap_write_init(drv->dev, drv->core->dev_regmap,
|
| 242 | drv->function);
|
| 243 | if (ret)
|
| 244 | return ret;
|
| 245 | }
|
| 246 |
|
| 247 | return 0;
|
| 248 | }
|
| 249 |
|
| 250 | static int class_function_boot(struct class_function_drv *drv)
|
| 251 | {
|
| 252 | unsigned int reg = SDW_SDCA_CTL(drv->function->desc->adr,
|
| 253 | SDCA_ENTITY_TYPE_ENTITY_0,
|
| 254 | SDCA_CTL_ENTITY_0_FUNCTION_STATUS, 0);
|
| 255 | unsigned int val;
|
| 256 | int ret;
|
| 257 |
|
| 258 | guard(mutex)(&drv->core->init_lock);
|
| 259 |
|
| 260 | ret = regmap_read(drv->regmap, reg, &val);
|
| 261 | if (ret < 0) {
|
| 262 | dev_err(drv->dev, "failed to read function status: %d\n", ret);
|
| 263 | return ret;
|
| 264 | }
|
| 265 |
|
| 266 | ret = class_function_init_device(drv, val);
|
| 267 | if (ret)
|
| 268 | return ret;
|
| 269 |
|
| 270 |
|
| 271 | ret = sdca_irq_populate_early(drv->dev, drv->regmap, drv->function,
|
| 272 | drv->core->irq_info);
|
| 273 | if (ret)
|
| 274 | return ret;
|
| 275 |
|
| 276 | ret = sdca_fdl_sync(drv->dev, drv->function, drv->core->irq_info);
|
| 277 | if (ret)
|
| 278 | return ret;
|
| 279 |
|
| 280 | ret = sdca_regmap_write_defaults(drv->dev, drv->regmap, drv->function);
|
| 281 | if (ret)
|
| 282 | return ret;
|
| 283 |
|
| 284 | ret = regmap_write(drv->regmap, reg, 0xFF);
|
| 285 | if (ret < 0) {
|
| 286 | dev_err(drv->dev, "failed to clear function status: %d\n", ret);
|
| 287 | return ret;
|
| 288 | }
|
| 289 |
|
| 290 | return 0;
|
| 291 | }
|
| 292 |
|
| 293 | static int class_function_probe(struct auxiliary_device *auxdev,
|
| 294 | const struct auxiliary_device_id *aux_dev_id)
|
| 295 | {
|
| 296 | struct device *dev = &auxdev->dev;
|
| 297 | struct sdca_class_drv *core = dev_get_drvdata(dev->parent);
|
| 298 | struct sdca_dev *sdev = auxiliary_dev_to_sdca_dev(auxdev);
|
| 299 | struct snd_soc_component_driver *cmp_drv;
|
| 300 | struct snd_soc_dai_driver *dais;
|
| 301 | struct class_function_drv *drv;
|
| 302 | struct regmap_sdw_mbq_cfg *mbq_config;
|
| 303 | struct regmap_config *config;
|
| 304 | struct reg_default *defaults;
|
| 305 | int ndefaults;
|
| 306 | int num_dais;
|
| 307 | int ret;
|
| 308 |
|
| 309 | drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
|
| 310 | if (!drv)
|
| 311 | return -ENOMEM;
|
| 312 |
|
| 313 | cmp_drv = devm_kmemdup(dev, &class_function_component_drv, sizeof(*cmp_drv),
|
| 314 | GFP_KERNEL);
|
| 315 | if (!cmp_drv)
|
| 316 | return -ENOMEM;
|
| 317 |
|
| 318 | config = devm_kmemdup(dev, &class_function_regmap_config, sizeof(*config),
|
| 319 | GFP_KERNEL);
|
| 320 | if (!config)
|
| 321 | return -ENOMEM;
|
| 322 |
|
| 323 | mbq_config = devm_kmemdup(dev, &class_function_mbq_config, sizeof(*mbq_config),
|
| 324 | GFP_KERNEL);
|
| 325 | if (!mbq_config)
|
| 326 | return -ENOMEM;
|
| 327 |
|
| 328 | drv->dev = dev;
|
| 329 | drv->core = core;
|
| 330 | drv->function = &sdev->function;
|
| 331 |
|
| 332 | ret = sdca_parse_function(dev, drv->function);
|
| 333 | if (ret)
|
| 334 | return ret;
|
| 335 |
|
| 336 | ndefaults = sdca_regmap_count_constants(dev, drv->function);
|
| 337 | if (ndefaults < 0)
|
| 338 | return ndefaults;
|
| 339 |
|
| 340 | defaults = devm_kcalloc(dev, ndefaults, sizeof(*defaults), GFP_KERNEL);
|
| 341 | if (!defaults)
|
| 342 | return -ENOMEM;
|
| 343 |
|
| 344 | ret = sdca_regmap_populate_constants(dev, drv->function, defaults);
|
| 345 | if (ret < 0)
|
| 346 | return ret;
|
| 347 |
|
| 348 | regcache_sort_defaults(defaults, ndefaults);
|
| 349 |
|
| 350 | auxiliary_set_drvdata(auxdev, drv);
|
| 351 |
|
| 352 | config->reg_defaults = defaults;
|
| 353 | config->num_reg_defaults = ndefaults;
|
| 354 | config->lock_arg = &core->regmap_lock;
|
| 355 |
|
| 356 | if (drv->function->busy_max_delay) {
|
| 357 | mbq_config->timeout_us = drv->function->busy_max_delay;
|
| 358 | mbq_config->retry_us = umax(drv->function->busy_max_delay / 10,
|
| 359 | mbq_config->retry_us);
|
| 360 | }
|
| 361 |
|
| 362 | drv->regmap = devm_regmap_init_sdw_mbq_cfg(dev, core->sdw, config, mbq_config);
|
| 363 | if (IS_ERR(drv->regmap))
|
| 364 | return dev_err_probe(dev, PTR_ERR(drv->regmap),
|
| 365 | "failed to create regmap");
|
| 366 |
|
| 367 | switch (drv->function->desc->type) {
|
| 368 | case SDCA_FUNCTION_TYPE_UAJ:
|
| 369 | case SDCA_FUNCTION_TYPE_RJ:
|
| 370 | cmp_drv->set_jack = class_function_set_jack;
|
| 371 | break;
|
| 372 | default:
|
| 373 | break;
|
| 374 | }
|
| 375 |
|
| 376 | ret = sdca_asoc_populate_component(dev, drv->function, cmp_drv,
|
| 377 | &dais, &num_dais,
|
| 378 | &class_function_sdw_ops);
|
| 379 | if (ret)
|
| 380 | return ret;
|
| 381 |
|
| 382 | dev_pm_set_driver_flags(dev, DPM_FLAG_NO_DIRECT_COMPLETE);
|
| 383 |
|
| 384 | pm_runtime_set_autosuspend_delay(dev, 200);
|
| 385 | pm_runtime_use_autosuspend(dev);
|
| 386 | pm_runtime_set_active(dev);
|
| 387 | pm_runtime_get_noresume(dev);
|
| 388 |
|
| 389 | ret = devm_pm_runtime_enable(dev);
|
| 390 | if (ret)
|
| 391 | goto err_pm;
|
| 392 |
|
| 393 | ret = class_function_boot(drv);
|
| 394 | if (ret)
|
| 395 | goto err_pm;
|
| 396 |
|
| 397 | ret = devm_snd_soc_register_component(dev, cmp_drv, dais, num_dais);
|
| 398 | if (ret) {
|
| 399 | dev_err_probe(dev, ret, "failed to register component\n");
|
| 400 | goto err_pm;
|
| 401 | }
|
| 402 |
|
| 403 | pm_runtime_mark_last_busy(dev);
|
| 404 | pm_runtime_put_autosuspend(dev);
|
| 405 |
|
| 406 | return 0;
|
| 407 |
|
| 408 | err_pm:
|
| 409 | pm_runtime_put_sync(dev);
|
| 410 |
|
| 411 | return ret;
|
| 412 | }
|
| 413 |
|
| 414 | static void class_function_remove(struct auxiliary_device *auxdev)
|
| 415 | {
|
| 416 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 417 |
|
| 418 | sdca_irq_cleanup_late(drv->dev, drv->function, drv->core->irq_info);
|
| 419 | }
|
| 420 |
|
| 421 | static int class_function_runtime_suspend(struct device *dev)
|
| 422 | {
|
| 423 | struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
|
| 424 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 425 |
|
| 426 | |
| 427 | * Whilst the driver doesn't power the chip down here, going into
|
| 428 | * runtime suspend means the driver can't be sure the bus won't
|
| 429 | * power down which would prevent communication with the device.
|
| 430 |
|
| 431 | regcache_cache_only(drv->regmap, true);
|
| 432 |
|
| 433 | return 0;
|
| 434 | }
|
| 435 |
|
| 436 | static int class_function_runtime_resume(struct device *dev)
|
| 437 | {
|
| 438 | struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
|
| 439 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 440 | int ret;
|
| 441 |
|
| 442 | guard(mutex)(&drv->core->init_lock);
|
| 443 |
|
| 444 | regcache_mark_dirty(drv->regmap);
|
| 445 | regcache_cache_only(drv->regmap, false);
|
| 446 |
|
| 447 | if (drv->suspended) {
|
| 448 | unsigned int reg = SDW_SDCA_CTL(drv->function->desc->adr,
|
| 449 | SDCA_ENTITY_TYPE_ENTITY_0,
|
| 450 | SDCA_CTL_ENTITY_0_FUNCTION_STATUS, 0);
|
| 451 | unsigned int val;
|
| 452 |
|
| 453 | ret = regmap_read(drv->regmap, reg, &val);
|
| 454 | if (ret < 0) {
|
| 455 | dev_err(drv->dev, "failed to read function status: %d\n", ret);
|
| 456 | goto err;
|
| 457 | }
|
| 458 |
|
| 459 | ret = class_function_init_device(drv, val);
|
| 460 | if (ret)
|
| 461 | goto err;
|
| 462 |
|
| 463 | sdca_irq_enable_early(drv->function, drv->core->irq_info);
|
| 464 |
|
| 465 | ret = sdca_fdl_sync(drv->dev, drv->function, drv->core->irq_info);
|
| 466 | if (ret)
|
| 467 | goto err;
|
| 468 |
|
| 469 | sdca_irq_enable(drv->function, drv->core->irq_info);
|
| 470 |
|
| 471 | ret = regmap_write(drv->regmap, reg, 0xFF);
|
| 472 | if (ret < 0) {
|
| 473 | dev_err(drv->dev, "failed to clear function status: %d\n", ret);
|
| 474 | goto err;
|
| 475 | }
|
| 476 |
|
| 477 | drv->suspended = false;
|
| 478 | }
|
| 479 |
|
| 480 | ret = regcache_sync(drv->regmap);
|
| 481 | if (ret) {
|
| 482 | dev_err(drv->dev, "failed to restore register cache: %d\n", ret);
|
| 483 | goto err;
|
| 484 | }
|
| 485 |
|
| 486 | return 0;
|
| 487 |
|
| 488 | err:
|
| 489 | regcache_cache_only(drv->regmap, true);
|
| 490 |
|
| 491 | return ret;
|
| 492 | }
|
| 493 |
|
| 494 | static int class_function_suspend(struct device *dev)
|
| 495 | {
|
| 496 | struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
|
| 497 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
|
| 498 | int ret;
|
| 499 |
|
| 500 |
|
| 501 | ret = pm_runtime_resume_and_get(dev);
|
| 502 | if (ret) {
|
| 503 | dev_err(dev, "failed to resume for suspend: %d\n", ret);
|
| 504 | return ret;
|
| 505 | }
|
| 506 |
|
| 507 | drv->suspended = true;
|
| 508 |
|
| 509 | sdca_irq_disable(drv->function, drv->core->irq_info);
|
| 510 |
|
| 511 | ret = pm_runtime_force_suspend(dev);
|
| 512 | if (ret) {
|
| 513 | dev_err(dev, "failed to force suspend: %d\n", ret);
|
| 514 | return ret;
|
| 515 | }
|
| 516 |
|
| 517 | pm_runtime_put_noidle(dev);
|
| 518 |
|
| 519 | return 0;
|
| 520 | }
|
| 521 |
|
| 522 | static int class_function_resume(struct device *dev)
|
| 523 | {
|
| 524 | int ret;
|
| 525 |
|
| 526 | ret = pm_runtime_force_resume(dev);
|
| 527 | if (ret) {
|
| 528 | dev_err(dev, "failed to force resume: %d\n", ret);
|
| 529 | return ret;
|
| 530 | }
|
| 531 |
|
| 532 | return 0;
|
| 533 | }
|
| 534 |
|
| 535 | static const struct dev_pm_ops class_function_pm_ops = {
|
| 536 | SYSTEM_SLEEP_PM_OPS(class_function_suspend, class_function_resume)
|
| 537 | RUNTIME_PM_OPS(class_function_runtime_suspend,
|
| 538 | class_function_runtime_resume, NULL)
|
| 539 | };
|
| 540 |
|
| 541 | static const struct auxiliary_device_id class_function_id_table[] = {
|
| 542 | {
|
| 543 | .name = "snd_soc_sdca." SDCA_FUNCTION_TYPE_SMART_AMP_NAME,
|
| 544 | .driver_data = SDCA_FUNCTION_TYPE_SMART_AMP,
|
| 545 | },
|
| 546 | {
|
| 547 | .name = "snd_soc_sdca." SDCA_FUNCTION_TYPE_SMART_MIC_NAME,
|
| 548 | .driver_data = SDCA_FUNCTION_TYPE_SMART_MIC,
|
| 549 | },
|
| 550 | {
|
| 551 | .name = "snd_soc_sdca." SDCA_FUNCTION_TYPE_UAJ_NAME,
|
| 552 | .driver_data = SDCA_FUNCTION_TYPE_UAJ,
|
| 553 | },
|
| 554 | {
|
| 555 | .name = "snd_soc_sdca." SDCA_FUNCTION_TYPE_HID_NAME,
|
| 556 | .driver_data = SDCA_FUNCTION_TYPE_HID,
|
| 557 | },
|
| 558 | {
|
| 559 | .name = "snd_soc_sdca." SDCA_FUNCTION_TYPE_RJ_NAME,
|
| 560 | .driver_data = SDCA_FUNCTION_TYPE_RJ,
|
| 561 | },
|
| 562 | {},
|
| 563 | };
|
| 564 | MODULE_DEVICE_TABLE(auxiliary, class_function_id_table);
|
| 565 |
|
| 566 | static struct auxiliary_driver class_function_drv = {
|
| 567 | .driver = {
|
| 568 | .name = "sdca_function",
|
| 569 | .pm = pm_ptr(&class_function_pm_ops),
|
| 570 | },
|
| 571 |
|
| 572 | .probe = class_function_probe,
|
| 573 | .remove = class_function_remove,
|
| 574 | .id_table = class_function_id_table
|
| 575 | };
|
| 576 | module_auxiliary_driver(class_function_drv);
|
| 577 |
|
| 578 | MODULE_LICENSE("GPL");
|
| 579 | MODULE_DESCRIPTION("SDCA Class Function Driver");
|
| 580 | MODULE_IMPORT_NS("SND_SOC_SDCA");
|