Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: intel: Add pre/post bank switch ops

To support multi link on Intel platforms, we need to update
SDW SHIM registers.

So, add pre/post bank switch ops for the same in Intel driver.

Signed-off-by: Sanyog Kale <sanyog.r.kale@intel.com>
Signed-off-by: Shreyas NC <shreyas.nc@intel.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Shreyas NC and committed by
Vinod Koul
30246e2d 9b5c132a

+65
+65
drivers/soundwire/intel.c
··· 398 398 } 399 399 400 400 /* 401 + * bank switch routines 402 + */ 403 + 404 + static int intel_pre_bank_switch(struct sdw_bus *bus) 405 + { 406 + struct sdw_cdns *cdns = bus_to_cdns(bus); 407 + struct sdw_intel *sdw = cdns_to_intel(cdns); 408 + void __iomem *shim = sdw->res->shim; 409 + int sync_reg; 410 + 411 + /* Write to register only for multi-link */ 412 + if (!bus->multi_link) 413 + return 0; 414 + 415 + /* Read SYNC register */ 416 + sync_reg = intel_readl(shim, SDW_SHIM_SYNC); 417 + sync_reg |= SDW_SHIM_SYNC_CMDSYNC << sdw->instance; 418 + intel_writel(shim, SDW_SHIM_SYNC, sync_reg); 419 + 420 + return 0; 421 + } 422 + 423 + static int intel_post_bank_switch(struct sdw_bus *bus) 424 + { 425 + struct sdw_cdns *cdns = bus_to_cdns(bus); 426 + struct sdw_intel *sdw = cdns_to_intel(cdns); 427 + void __iomem *shim = sdw->res->shim; 428 + int sync_reg, ret; 429 + 430 + /* Write to register only for multi-link */ 431 + if (!bus->multi_link) 432 + return 0; 433 + 434 + /* Read SYNC register */ 435 + sync_reg = intel_readl(shim, SDW_SHIM_SYNC); 436 + 437 + /* 438 + * post_bank_switch() ops is called from the bus in loop for 439 + * all the Masters in the steam with the expectation that 440 + * we trigger the bankswitch for the only first Master in the list 441 + * and do nothing for the other Masters 442 + * 443 + * So, set the SYNCGO bit only if CMDSYNC bit is set for any Master. 444 + */ 445 + if (!(sync_reg & SDW_SHIM_SYNC_CMDSYNC_MASK)) 446 + return 0; 447 + 448 + /* 449 + * Set SyncGO bit to synchronously trigger a bank switch for 450 + * all the masters. A write to SYNCGO bit clears CMDSYNC bit for all 451 + * the Masters. 452 + */ 453 + sync_reg |= SDW_SHIM_SYNC_SYNCGO; 454 + 455 + ret = intel_clear_bit(shim, SDW_SHIM_SYNC, sync_reg, 456 + SDW_SHIM_SYNC_SYNCGO); 457 + if (ret < 0) 458 + dev_err(sdw->cdns.dev, "Post bank switch failed: %d", ret); 459 + 460 + return ret; 461 + } 462 + 463 + /* 401 464 * DAI routines 402 465 */ 403 466 ··· 813 750 .xfer_msg_defer = cdns_xfer_msg_defer, 814 751 .reset_page_addr = cdns_reset_page_addr, 815 752 .set_bus_conf = cdns_bus_conf, 753 + .pre_bank_switch = intel_pre_bank_switch, 754 + .post_bank_switch = intel_post_bank_switch, 816 755 }; 817 756 818 757 /*