^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) // Copyright(c) 2015-17 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * SDW Intel Init Routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Initializes and creates SDW devices based on ACPI and Hardware values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/pm_runtime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/soundwire/sdw_intel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "cadence_master.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "intel.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define SDW_LINK_TYPE 4 /* from Intel ACPI documentation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define SDW_MAX_LINKS 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define SDW_SHIM_LCAP 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define SDW_SHIM_BASE 0x2C000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define SDW_ALH_BASE 0x2C800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define SDW_LINK_BASE 0x30000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define SDW_LINK_SIZE 0x10000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static int ctrl_link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) module_param_named(sdw_link_mask, ctrl_link_mask, int, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) MODULE_PARM_DESC(sdw_link_mask, "Intel link mask (one bit per link)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static bool is_link_enabled(struct fwnode_handle *fw_node, int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct fwnode_handle *link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) char name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) u32 quirk_mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* Find master handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) snprintf(name, sizeof(name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) "mipi-sdw-link-%d-subproperties", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) link = fwnode_get_named_child_node(fw_node, name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) if (!link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) fwnode_property_read_u32(link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) "intel-quirk-mask",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) &quirk_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (quirk_mask & SDW_INTEL_QUIRK_MASK_BUS_DISABLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static int sdw_intel_cleanup(struct sdw_intel_ctx *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct sdw_intel_link_res *link = ctx->links;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) u32 link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (!link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) link_mask = ctx->link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) for (i = 0; i < ctx->count; i++, link++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (!(link_mask & BIT(i)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if (link->pdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) pm_runtime_disable(&link->pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) platform_device_unregister(link->pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (!link->clock_stop_quirks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) pm_runtime_put_noidle(link->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct acpi_device *adev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) u8 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (acpi_bus_get_device(info->handle, &adev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /* Found controller, find links supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ret = fwnode_property_read_u8_array(acpi_fwnode_handle(adev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) "mipi-sdw-master-count", &count, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * In theory we could check the number of links supported in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * hardware, but in that step we cannot assume SoundWire IP is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * powered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * In addition, if the BIOS doesn't even provide this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * 'master-count' property then all the inits based on link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * masks will fail as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * We will check the hardware capabilities in the startup() step
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) dev_err(&adev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) "Failed to read mipi-sdw-master-count: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /* Check count is within bounds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (count > SDW_MAX_LINKS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) dev_err(&adev->dev, "Link count %d exceeds max %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) count, SDW_MAX_LINKS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (!count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) dev_warn(&adev->dev, "No SoundWire links detected\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) dev_dbg(&adev->dev, "ACPI reports %d SDW Link devices\n", count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) info->count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) info->link_mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (ctrl_link_mask && !(ctrl_link_mask & BIT(i))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) dev_dbg(&adev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) "Link %d masked, will not be enabled\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (!is_link_enabled(acpi_fwnode_handle(adev), i)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) dev_dbg(&adev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) "Link %d not selected in firmware\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) info->link_mask |= BIT(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define HDA_DSP_REG_ADSPIC2 (0x10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define HDA_DSP_REG_ADSPIS2 (0x14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define HDA_DSP_REG_ADSPIC2_SNDW BIT(5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * sdw_intel_enable_irq() - enable/disable Intel SoundWire IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * @mmio_base: The mmio base of the control register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * @enable: true if enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) void sdw_intel_enable_irq(void __iomem *mmio_base, bool enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) val = readl(mmio_base + HDA_DSP_REG_ADSPIC2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) val |= HDA_DSP_REG_ADSPIC2_SNDW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) val &= ~HDA_DSP_REG_ADSPIC2_SNDW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) writel(val, mmio_base + HDA_DSP_REG_ADSPIC2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) EXPORT_SYMBOL_NS(sdw_intel_enable_irq, SOUNDWIRE_INTEL_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) irqreturn_t sdw_intel_thread(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct sdw_intel_ctx *ctx = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct sdw_intel_link_res *link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) list_for_each_entry(link, &ctx->link_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) sdw_cdns_irq(irq, link->cdns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) sdw_intel_enable_irq(ctx->mmio_base, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) EXPORT_SYMBOL_NS(sdw_intel_thread, SOUNDWIRE_INTEL_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static struct sdw_intel_ctx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) *sdw_intel_probe_controller(struct sdw_intel_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) struct platform_device_info pdevinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct platform_device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct sdw_intel_link_res *link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct sdw_intel_ctx *ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct acpi_device *adev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct sdw_slave *slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct list_head *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct sdw_bus *bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) u32 link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) int num_slaves = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (!res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (acpi_bus_get_device(res->handle, &adev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) if (!res->count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) count = res->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) dev_dbg(&adev->dev, "Creating %d SDW Link devices\n", count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ctx = devm_kzalloc(&adev->dev, sizeof(*ctx), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (!ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) ctx->count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) ctx->links = devm_kcalloc(&adev->dev, ctx->count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) sizeof(*ctx->links), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (!ctx->links)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ctx->count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) ctx->mmio_base = res->mmio_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ctx->link_mask = res->link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) ctx->handle = res->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) mutex_init(&ctx->shim_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) link = ctx->links;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) link_mask = ctx->link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) INIT_LIST_HEAD(&ctx->link_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /* Create SDW Master devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) for (i = 0; i < count; i++, link++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (!(link_mask & BIT(i))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) dev_dbg(&adev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) "Link %d masked, will not be enabled\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) link->mmio_base = res->mmio_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) link->registers = res->mmio_base + SDW_LINK_BASE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) + (SDW_LINK_SIZE * i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) link->shim = res->mmio_base + SDW_SHIM_BASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) link->alh = res->mmio_base + SDW_ALH_BASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) link->ops = res->ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) link->dev = res->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) link->clock_stop_quirks = res->clock_stop_quirks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) link->shim_lock = &ctx->shim_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) link->shim_mask = &ctx->shim_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) link->link_mask = link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) memset(&pdevinfo, 0, sizeof(pdevinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) pdevinfo.parent = res->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) pdevinfo.name = "intel-sdw";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) pdevinfo.id = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) pdevinfo.fwnode = acpi_fwnode_handle(adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) pdevinfo.data = link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) pdevinfo.size_data = sizeof(*link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) pdev = platform_device_register_full(&pdevinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (IS_ERR(pdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) dev_err(&adev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) "platform device creation failed: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) PTR_ERR(pdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) link->pdev = pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) link->cdns = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) list_add_tail(&link->list, &ctx->link_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) bus = &link->cdns->bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) /* Calculate number of slaves */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) list_for_each(node, &bus->slaves)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) num_slaves++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) ctx->ids = devm_kcalloc(&adev->dev, num_slaves,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) sizeof(*ctx->ids), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) if (!ctx->ids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) ctx->num_slaves = num_slaves;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) list_for_each_entry(link, &ctx->link_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) bus = &link->cdns->bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) list_for_each_entry(slave, &bus->slaves, node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) ctx->ids[i].id = slave->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) ctx->ids[i].link_id = bus->link_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ctx->count = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) sdw_intel_cleanup(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) sdw_intel_startup_controller(struct sdw_intel_ctx *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct acpi_device *adev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) struct sdw_intel_link_res *link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) u32 caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) u32 link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if (acpi_bus_get_device(ctx->handle, &adev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) /* Check SNDWLCAP.LCOUNT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) caps = ioread32(ctx->mmio_base + SDW_SHIM_BASE + SDW_SHIM_LCAP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) caps &= GENMASK(2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) /* Check HW supported vs property value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) if (caps < ctx->count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) dev_err(&adev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) "BIOS master count is larger than hardware capabilities\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) if (!ctx->links)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) link = ctx->links;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) link_mask = ctx->link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /* Startup SDW Master devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) for (i = 0; i < ctx->count; i++, link++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) if (!(link_mask & BIT(i)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) intel_master_startup(link->pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) if (!link->clock_stop_quirks) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * we need to prevent the parent PCI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) * from entering pm_runtime suspend, so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) * power rails to the SoundWire IP are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * turned off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) pm_runtime_get_noresume(link->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) void *cdata, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) struct sdw_intel_acpi_info *info = cdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) struct acpi_device *adev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) u64 adr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) return AE_OK; /* keep going */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) if (acpi_bus_get_device(handle, &adev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) pr_err("%s: Couldn't find ACPI handle\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) return AE_NOT_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) info->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) * On some Intel platforms, multiple children of the HDAS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) * device can be found, but only one of them is the SoundWire
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) * controller. The SNDW device is always exposed with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * Name(_ADR, 0x40000000), with bits 31..28 representing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) * SoundWire link so filter accordingly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) if (FIELD_GET(GENMASK(31, 28), adr) != SDW_LINK_TYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) return AE_OK; /* keep going */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) /* device found, stop namespace walk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) return AE_CTRL_TERMINATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * sdw_intel_acpi_scan() - SoundWire Intel init routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * @parent_handle: ACPI parent handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * @info: description of what firmware/DSDT tables expose
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * This scans the namespace and queries firmware to figure out which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) * links to enable. A follow-up use of sdw_intel_probe() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) * sdw_intel_startup() is required for creation of devices and bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * startup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) int sdw_intel_acpi_scan(acpi_handle *parent_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) struct sdw_intel_acpi_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) info->handle = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) parent_handle, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) sdw_intel_acpi_cb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) NULL, info, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) if (ACPI_FAILURE(status) || info->handle == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) return sdw_intel_scan_controller(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) EXPORT_SYMBOL_NS(sdw_intel_acpi_scan, SOUNDWIRE_INTEL_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) * sdw_intel_probe() - SoundWire Intel probe routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) * @res: resource data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) * This registers a platform device for each Master handled by the controller,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * and SoundWire Master and Slave devices will be created by the platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * device probe. All the information necessary is stored in the context, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * the res argument pointer can be freed after this step.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * This function will be called after sdw_intel_acpi_scan() by SOF probe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) struct sdw_intel_ctx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) *sdw_intel_probe(struct sdw_intel_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) return sdw_intel_probe_controller(res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) EXPORT_SYMBOL_NS(sdw_intel_probe, SOUNDWIRE_INTEL_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) * sdw_intel_startup() - SoundWire Intel startup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) * @ctx: SoundWire context allocated in the probe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) * Startup Intel SoundWire controller. This function will be called after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) * Intel Audio DSP is powered up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) int sdw_intel_startup(struct sdw_intel_ctx *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return sdw_intel_startup_controller(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) EXPORT_SYMBOL_NS(sdw_intel_startup, SOUNDWIRE_INTEL_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) * sdw_intel_exit() - SoundWire Intel exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * @ctx: SoundWire context allocated in the probe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * Delete the controller instances created and cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) void sdw_intel_exit(struct sdw_intel_ctx *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) sdw_intel_cleanup(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) EXPORT_SYMBOL_NS(sdw_intel_exit, SOUNDWIRE_INTEL_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) void sdw_intel_process_wakeen_event(struct sdw_intel_ctx *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) struct sdw_intel_link_res *link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) u32 link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (!ctx->links)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) link = ctx->links;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) link_mask = ctx->link_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) /* Startup SDW Master devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) for (i = 0; i < ctx->count; i++, link++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) if (!(link_mask & BIT(i)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) intel_master_process_wakeen_event(link->pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) EXPORT_SYMBOL_NS(sdw_intel_process_wakeen_event, SOUNDWIRE_INTEL_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) MODULE_LICENSE("Dual BSD/GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) MODULE_DESCRIPTION("Intel Soundwire Init Library");