rt715-sdw.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) rt715-sdw.c (7ef8c9edc86cff0881b2eb9a3274796258fbd872)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * rt715-sdw.c -- rt715 ALSA SoC audio driver
4 *
5 * Copyright(c) 2019 Realtek Semiconductor Corp.
6 *
7 * ALC715 ASoC Codec Driver based Intel Dummy SdW codec driver
8 *
9 */
10#include <linux/delay.h>
11#include <linux/device.h>
12#include <linux/mod_devicetable.h>
13#include <linux/soundwire/sdw.h>
14#include <linux/soundwire/sdw_type.h>
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * rt715-sdw.c -- rt715 ALSA SoC audio driver
4 *
5 * Copyright(c) 2019 Realtek Semiconductor Corp.
6 *
7 * ALC715 ASoC Codec Driver based Intel Dummy SdW codec driver
8 *
9 */
10#include <linux/delay.h>
11#include <linux/device.h>
12#include <linux/mod_devicetable.h>
13#include <linux/soundwire/sdw.h>
14#include <linux/soundwire/sdw_type.h>
15#include <linux/soundwire/sdw_registers.h>
15#include <linux/module.h>
16#include <linux/of.h>
17#include <linux/regmap.h>
18#include <sound/soc.h>
19#include "rt715.h"
20#include "rt715-sdw.h"
21
22static bool rt715_readable_register(struct device *dev, unsigned int reg)

--- 403 unchanged lines hidden (view full) ---

426
427 /* perform I/O transfers required for Slave initialization */
428 return rt715_io_init(&slave->dev, slave);
429}
430
431static int rt715_read_prop(struct sdw_slave *slave)
432{
433 struct sdw_slave_prop *prop = &slave->prop;
16#include <linux/module.h>
17#include <linux/of.h>
18#include <linux/regmap.h>
19#include <sound/soc.h>
20#include "rt715.h"
21#include "rt715-sdw.h"
22
23static bool rt715_readable_register(struct device *dev, unsigned int reg)

--- 403 unchanged lines hidden (view full) ---

427
428 /* perform I/O transfers required for Slave initialization */
429 return rt715_io_init(&slave->dev, slave);
430}
431
432static int rt715_read_prop(struct sdw_slave *slave)
433{
434 struct sdw_slave_prop *prop = &slave->prop;
434 int nval, i, num_of_ports = 1;
435 int nval, i;
435 u32 bit;
436 unsigned long addr;
437 struct sdw_dpn_prop *dpn;
438
436 u32 bit;
437 unsigned long addr;
438 struct sdw_dpn_prop *dpn;
439
440 prop->scp_int1_mask = SDW_SCP_INT1_IMPL_DEF | SDW_SCP_INT1_BUS_CLASH |
441 SDW_SCP_INT1_PARITY;
442 prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY;
443
439 prop->paging_support = false;
440
441 /* first we need to allocate memory for set bits in port lists */
442 prop->source_ports = 0x50;/* BITMAP: 01010000 */
443 prop->sink_ports = 0x0; /* BITMAP: 00000000 */
444
445 nval = hweight32(prop->source_ports);
444 prop->paging_support = false;
445
446 /* first we need to allocate memory for set bits in port lists */
447 prop->source_ports = 0x50;/* BITMAP: 01010000 */
448 prop->sink_ports = 0x0; /* BITMAP: 00000000 */
449
450 nval = hweight32(prop->source_ports);
446 num_of_ports += nval;
447 prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval,
448 sizeof(*prop->src_dpn_prop),
449 GFP_KERNEL);
450 if (!prop->src_dpn_prop)
451 return -ENOMEM;
452
453 dpn = prop->src_dpn_prop;
454 i = 0;
455 addr = prop->source_ports;
456 for_each_set_bit(bit, &addr, 32) {
457 dpn[i].num = bit;
458 dpn[i].simple_ch_prep_sm = true;
459 dpn[i].ch_prep_timeout = 10;
460 i++;
461 }
462
451 prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval,
452 sizeof(*prop->src_dpn_prop),
453 GFP_KERNEL);
454 if (!prop->src_dpn_prop)
455 return -ENOMEM;
456
457 dpn = prop->src_dpn_prop;
458 i = 0;
459 addr = prop->source_ports;
460 for_each_set_bit(bit, &addr, 32) {
461 dpn[i].num = bit;
462 dpn[i].simple_ch_prep_sm = true;
463 dpn[i].ch_prep_timeout = 10;
464 i++;
465 }
466
463 /* do this again for sink now */
464 nval = hweight32(prop->sink_ports);
465 num_of_ports += nval;
466 prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval,
467 sizeof(*prop->sink_dpn_prop),
468 GFP_KERNEL);
469 if (!prop->sink_dpn_prop)
470 return -ENOMEM;
471
472 dpn = prop->sink_dpn_prop;
473 i = 0;
474 addr = prop->sink_ports;
475 for_each_set_bit(bit, &addr, 32) {
476 dpn[i].num = bit;
477 dpn[i].simple_ch_prep_sm = true;
478 dpn[i].ch_prep_timeout = 10;
479 i++;
480 }
481
482 /* Allocate port_ready based on num_of_ports */
483 slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports,
484 sizeof(*slave->port_ready),
485 GFP_KERNEL);
486 if (!slave->port_ready)
487 return -ENOMEM;
488
489 /* Initialize completion */
490 for (i = 0; i < num_of_ports; i++)
491 init_completion(&slave->port_ready[i]);
492
493 /* set the timeout values */
494 prop->clk_stop_timeout = 20;
495
496 /* wake-up event */
497 prop->wake_capable = 1;
498
499 return 0;
500}

--- 35 unchanged lines hidden (view full) ---

536 return PTR_ERR(regmap);
537
538 rt715_init(&slave->dev, sdw_regmap, regmap, slave);
539
540 return 0;
541}
542
543static const struct sdw_device_id rt715_id[] = {
467 /* set the timeout values */
468 prop->clk_stop_timeout = 20;
469
470 /* wake-up event */
471 prop->wake_capable = 1;
472
473 return 0;
474}

--- 35 unchanged lines hidden (view full) ---

510 return PTR_ERR(regmap);
511
512 rt715_init(&slave->dev, sdw_regmap, regmap, slave);
513
514 return 0;
515}
516
517static const struct sdw_device_id rt715_id[] = {
544 SDW_SLAVE_ENTRY(0x025d, 0x715, 0),
518 SDW_SLAVE_ENTRY_EXT(0x025d, 0x714, 0x2, 0, 0),
519 SDW_SLAVE_ENTRY_EXT(0x025d, 0x715, 0x2, 0, 0),
545 {},
546};
547MODULE_DEVICE_TABLE(sdw, rt715_id);
548
549static int __maybe_unused rt715_dev_suspend(struct device *dev)
550{
551 struct rt715_priv *rt715 = dev_get_drvdata(dev);
552
553 if (!rt715->hw_init)
554 return 0;
555
556 regcache_cache_only(rt715->regmap, true);
557
558 return 0;
559}
560
520 {},
521};
522MODULE_DEVICE_TABLE(sdw, rt715_id);
523
524static int __maybe_unused rt715_dev_suspend(struct device *dev)
525{
526 struct rt715_priv *rt715 = dev_get_drvdata(dev);
527
528 if (!rt715->hw_init)
529 return 0;
530
531 regcache_cache_only(rt715->regmap, true);
532
533 return 0;
534}
535
561#define RT715_PROBE_TIMEOUT 2000
536#define RT715_PROBE_TIMEOUT 5000
562
563static int __maybe_unused rt715_dev_resume(struct device *dev)
564{
565 struct sdw_slave *slave = dev_to_sdw_dev(dev);
566 struct rt715_priv *rt715 = dev_get_drvdata(dev);
567 unsigned long time;
568
569 if (!rt715->hw_init)

--- 41 unchanged lines hidden ---
537
538static int __maybe_unused rt715_dev_resume(struct device *dev)
539{
540 struct sdw_slave *slave = dev_to_sdw_dev(dev);
541 struct rt715_priv *rt715 = dev_get_drvdata(dev);
542 unsigned long time;
543
544 if (!rt715->hw_init)

--- 41 unchanged lines hidden ---