2019-05-02 18:59:19 +08:00
|
|
|
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
|
|
|
|
/* Copyright(c) 2015-17 Intel Corporation. */
|
2017-12-14 13:49:43 +08:00
|
|
|
|
|
|
|
#ifndef __SDW_INTEL_H
|
|
|
|
#define __SDW_INTEL_H
|
|
|
|
|
2019-12-12 09:45:03 +08:00
|
|
|
#include <linux/irqreturn.h>
|
|
|
|
|
2019-12-12 09:45:02 +08:00
|
|
|
/**
|
|
|
|
* struct sdw_intel_stream_params_data: configuration passed during
|
|
|
|
* the @params_stream callback, e.g. for interaction with DSP
|
|
|
|
* firmware.
|
|
|
|
*/
|
|
|
|
struct sdw_intel_stream_params_data {
|
|
|
|
struct snd_pcm_substream *substream;
|
|
|
|
struct snd_soc_dai *dai;
|
|
|
|
struct snd_pcm_hw_params *hw_params;
|
|
|
|
int link_id;
|
|
|
|
int alh_stream_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct sdw_intel_stream_free_data: configuration passed during
|
|
|
|
* the @free_stream callback, e.g. for interaction with DSP
|
|
|
|
* firmware.
|
|
|
|
*/
|
|
|
|
struct sdw_intel_stream_free_data {
|
|
|
|
struct snd_pcm_substream *substream;
|
|
|
|
struct snd_soc_dai *dai;
|
|
|
|
int link_id;
|
|
|
|
};
|
|
|
|
|
2018-04-26 21:09:05 +08:00
|
|
|
/**
|
|
|
|
* struct sdw_intel_ops: Intel audio driver callback ops
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct sdw_intel_ops {
|
2019-12-12 09:45:02 +08:00
|
|
|
int (*params_stream)(struct device *dev,
|
|
|
|
struct sdw_intel_stream_params_data *params_data);
|
|
|
|
int (*free_stream)(struct device *dev,
|
|
|
|
struct sdw_intel_stream_free_data *free_data);
|
2018-04-26 21:09:05 +08:00
|
|
|
};
|
|
|
|
|
2017-12-14 13:49:43 +08:00
|
|
|
/**
|
2019-12-12 09:45:01 +08:00
|
|
|
* struct sdw_intel_acpi_info - Soundwire Intel information found in ACPI tables
|
|
|
|
* @handle: ACPI controller handle
|
|
|
|
* @count: link count found with "sdw-master-count" property
|
|
|
|
* @link_mask: bit-wise mask listing links enabled by BIOS menu
|
|
|
|
*
|
|
|
|
* this structure could be expanded to e.g. provide all the _ADR
|
|
|
|
* information in case the link_mask is not sufficient to identify
|
|
|
|
* platform capabilities.
|
|
|
|
*/
|
|
|
|
struct sdw_intel_acpi_info {
|
|
|
|
acpi_handle handle;
|
|
|
|
int count;
|
|
|
|
u32 link_mask;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sdw_intel_link_res;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct sdw_intel_ctx - context allocated by the controller
|
|
|
|
* driver probe
|
|
|
|
* @count: link count
|
|
|
|
* @mmio_base: mmio base of SoundWire registers, only used to check
|
|
|
|
* hardware capabilities after all power dependencies are settled.
|
|
|
|
* @link_mask: bit-wise mask listing SoundWire links reported by the
|
|
|
|
* Controller
|
|
|
|
* @handle: ACPI parent handle
|
|
|
|
* @links: information for each link (controller-specific and kept
|
|
|
|
* opaque here)
|
2019-12-12 09:45:04 +08:00
|
|
|
* @link_list: list to handle interrupts across all links
|
2019-12-12 09:45:01 +08:00
|
|
|
*/
|
|
|
|
struct sdw_intel_ctx {
|
|
|
|
int count;
|
|
|
|
void __iomem *mmio_base;
|
|
|
|
u32 link_mask;
|
|
|
|
acpi_handle handle;
|
|
|
|
struct sdw_intel_link_res *links;
|
2019-12-12 09:45:04 +08:00
|
|
|
struct list_head link_list;
|
2019-12-12 09:45:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct sdw_intel_res - Soundwire Intel global resource structure,
|
|
|
|
* typically populated by the DSP driver
|
|
|
|
*
|
|
|
|
* @count: link count
|
2017-12-14 13:49:43 +08:00
|
|
|
* @mmio_base: mmio base of SoundWire registers
|
|
|
|
* @irq: interrupt number
|
|
|
|
* @handle: ACPI parent handle
|
|
|
|
* @parent: parent device
|
2018-04-26 21:09:05 +08:00
|
|
|
* @ops: callback ops
|
2019-12-12 09:45:01 +08:00
|
|
|
* @dev: device implementing hwparams and free callbacks
|
|
|
|
* @link_mask: bit-wise mask listing links selected by the DSP driver
|
|
|
|
* This mask may be a subset of the one reported by the controller since
|
|
|
|
* machine-specific quirks are handled in the DSP driver.
|
2017-12-14 13:49:43 +08:00
|
|
|
*/
|
|
|
|
struct sdw_intel_res {
|
2019-12-12 09:45:01 +08:00
|
|
|
int count;
|
2017-12-14 13:49:43 +08:00
|
|
|
void __iomem *mmio_base;
|
|
|
|
int irq;
|
|
|
|
acpi_handle handle;
|
|
|
|
struct device *parent;
|
2018-04-26 21:09:05 +08:00
|
|
|
const struct sdw_intel_ops *ops;
|
2019-12-12 09:45:01 +08:00
|
|
|
struct device *dev;
|
|
|
|
u32 link_mask;
|
2017-12-14 13:49:43 +08:00
|
|
|
};
|
|
|
|
|
2019-12-12 09:45:01 +08:00
|
|
|
/*
|
|
|
|
* On Intel platforms, the SoundWire IP has dependencies on power
|
|
|
|
* rails shared with the DSP, and the initialization steps are split
|
|
|
|
* in three. First an ACPI scan to check what the firmware describes
|
|
|
|
* in DSDT tables, then an allocation step (with no hardware
|
|
|
|
* configuration but with all the relevant devices created) and last
|
|
|
|
* the actual hardware configuration. The final stage is a global
|
|
|
|
* interrupt enable which is controlled by the DSP driver. Splitting
|
|
|
|
* these phases helps simplify the boot flow and make early decisions
|
|
|
|
* on e.g. which machine driver to select (I2S mode, HDaudio or
|
|
|
|
* SoundWire).
|
|
|
|
*/
|
|
|
|
int sdw_intel_acpi_scan(acpi_handle *parent_handle,
|
|
|
|
struct sdw_intel_acpi_info *info);
|
|
|
|
|
|
|
|
struct sdw_intel_ctx *
|
|
|
|
sdw_intel_probe(struct sdw_intel_res *res);
|
|
|
|
|
|
|
|
int sdw_intel_startup(struct sdw_intel_ctx *ctx);
|
|
|
|
|
|
|
|
void sdw_intel_exit(struct sdw_intel_ctx *ctx);
|
|
|
|
|
|
|
|
void sdw_intel_enable_irq(void __iomem *mmio_base, bool enable);
|
2017-12-14 13:49:44 +08:00
|
|
|
|
2019-12-12 09:45:03 +08:00
|
|
|
irqreturn_t sdw_intel_thread(int irq, void *dev_id);
|
|
|
|
|
2017-12-14 13:49:43 +08:00
|
|
|
#endif
|