Commit f98f690f authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul

soundwire: intel: update interfaces between ASoC and SoundWire

The current interfaces between ASoC and SoundWire are limited by the
platform_device infrastructure to an init() and exit() (mapped to the
platform driver.probe and .remove)

To help with the platform detection, machine driver selection and
management of power dependencies between DSP and SoundWire IP, the
ASoC side requires:

a) an ACPI scan helper, to report if any devices are exposed in the
DSDT tables, and if any links are disabled by the BIOS.

b) a probe helper that allocates the resources without actually
starting the bus.

c) a startup helper which does start the bus when all power
dependencies are settled.

d) an exit helper to free all resources

e) an interrupt_enable/disable helper, typically invoked after the
startup helper but also used in suspend routines.

This patch moves all required interfaces to sdw_intel.h, mainly to
allow SoundWire and ASoC parts to be merged separately once the header
files are shared between trees.

To avoid compilation issues, the conflicts in intel_init.c are blindly
removed. This would in theory prevent the code from working, but since
there are no users of the Intel Soundwire driver this has no
impact. Functionality will be restored when the removal of platform
devices is complete.

Support for SoundWire + SOF builds will only be provided once all the
required pieces are upstream.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191212014507.28050-6-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent b2bd75f8
...@@ -5,17 +5,20 @@ ...@@ -5,17 +5,20 @@
#define __SDW_INTEL_LOCAL_H #define __SDW_INTEL_LOCAL_H
/** /**
* struct sdw_intel_link_res - Soundwire link resources * struct sdw_intel_link_res - Soundwire Intel link resource structure,
* typically populated by the controller driver.
* @pdev: platform_device
* @mmio_base: mmio base of SoundWire registers
* @registers: Link IO registers base * @registers: Link IO registers base
* @shim: Audio shim pointer * @shim: Audio shim pointer
* @alh: ALH (Audio Link Hub) pointer * @alh: ALH (Audio Link Hub) pointer
* @irq: Interrupt line * @irq: Interrupt line
* @ops: Shim callback ops * @ops: Shim callback ops
* @arg: Shim callback ops argument * @arg: Shim callback ops argument
*
* This is set as pdata for each link instance.
*/ */
struct sdw_intel_link_res { struct sdw_intel_link_res {
struct platform_device *pdev;
void __iomem *mmio_base; /* not strictly needed, useful for debug */
void __iomem *registers; void __iomem *registers;
void __iomem *shim; void __iomem *shim;
void __iomem *alh; void __iomem *alh;
......
...@@ -27,19 +27,9 @@ static int link_mask; ...@@ -27,19 +27,9 @@ static int link_mask;
module_param_named(sdw_link_mask, link_mask, int, 0444); module_param_named(sdw_link_mask, link_mask, int, 0444);
MODULE_PARM_DESC(sdw_link_mask, "Intel link mask (one bit per link)"); MODULE_PARM_DESC(sdw_link_mask, "Intel link mask (one bit per link)");
struct sdw_link_data {
struct sdw_intel_link_res res;
struct platform_device *pdev;
};
struct sdw_intel_ctx {
int count;
struct sdw_link_data *links;
};
static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx) static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx)
{ {
struct sdw_link_data *link = ctx->links; struct sdw_intel_link_res *link = ctx->links;
int i; int i;
if (!link) if (!link)
...@@ -62,7 +52,7 @@ static struct sdw_intel_ctx ...@@ -62,7 +52,7 @@ static struct sdw_intel_ctx
{ {
struct platform_device_info pdevinfo; struct platform_device_info pdevinfo;
struct platform_device *pdev; struct platform_device *pdev;
struct sdw_link_data *link; struct sdw_intel_link_res *link;
struct sdw_intel_ctx *ctx; struct sdw_intel_ctx *ctx;
struct acpi_device *adev; struct acpi_device *adev;
int ret, i; int ret, i;
...@@ -123,14 +113,12 @@ static struct sdw_intel_ctx ...@@ -123,14 +113,12 @@ static struct sdw_intel_ctx
continue; continue;
} }
link->res.irq = res->irq; link->registers = res->mmio_base + SDW_LINK_BASE
link->res.registers = res->mmio_base + SDW_LINK_BASE
+ (SDW_LINK_SIZE * i); + (SDW_LINK_SIZE * i);
link->res.shim = res->mmio_base + SDW_SHIM_BASE; link->shim = res->mmio_base + SDW_SHIM_BASE;
link->res.alh = res->mmio_base + SDW_ALH_BASE; link->alh = res->mmio_base + SDW_ALH_BASE;
link->res.ops = res->ops; link->ops = res->ops;
link->res.arg = res->arg;
memset(&pdevinfo, 0, sizeof(pdevinfo)); memset(&pdevinfo, 0, sizeof(pdevinfo));
...@@ -138,8 +126,6 @@ static struct sdw_intel_ctx ...@@ -138,8 +126,6 @@ static struct sdw_intel_ctx
pdevinfo.name = "int-sdw"; pdevinfo.name = "int-sdw";
pdevinfo.id = i; pdevinfo.id = i;
pdevinfo.fwnode = acpi_fwnode_handle(adev); pdevinfo.fwnode = acpi_fwnode_handle(adev);
pdevinfo.data = &link->res;
pdevinfo.size_data = sizeof(link->res);
pdev = platform_device_register_full(&pdevinfo); pdev = platform_device_register_full(&pdevinfo);
if (IS_ERR(pdev)) { if (IS_ERR(pdev)) {
...@@ -216,7 +202,6 @@ void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res) ...@@ -216,7 +202,6 @@ void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res)
return sdw_intel_add_controller(res); return sdw_intel_add_controller(res);
} }
EXPORT_SYMBOL(sdw_intel_init);
/** /**
* sdw_intel_exit() - SoundWire Intel exit * sdw_intel_exit() - SoundWire Intel exit
...@@ -224,10 +209,8 @@ EXPORT_SYMBOL(sdw_intel_init); ...@@ -224,10 +209,8 @@ EXPORT_SYMBOL(sdw_intel_init);
* *
* Delete the controller instances created and cleanup * Delete the controller instances created and cleanup
*/ */
void sdw_intel_exit(void *arg) void sdw_intel_exit(struct sdw_intel_ctx *ctx)
{ {
struct sdw_intel_ctx *ctx = arg;
sdw_intel_cleanup_pdev(ctx); sdw_intel_cleanup_pdev(ctx);
kfree(ctx); kfree(ctx);
} }
......
...@@ -16,24 +16,91 @@ struct sdw_intel_ops { ...@@ -16,24 +16,91 @@ struct sdw_intel_ops {
}; };
/** /**
* struct sdw_intel_res - Soundwire Intel resource structure * 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)
*/
struct sdw_intel_ctx {
int count;
void __iomem *mmio_base;
u32 link_mask;
acpi_handle handle;
struct sdw_intel_link_res *links;
};
/**
* struct sdw_intel_res - Soundwire Intel global resource structure,
* typically populated by the DSP driver
*
* @count: link count
* @mmio_base: mmio base of SoundWire registers * @mmio_base: mmio base of SoundWire registers
* @irq: interrupt number * @irq: interrupt number
* @handle: ACPI parent handle * @handle: ACPI parent handle
* @parent: parent device * @parent: parent device
* @ops: callback ops * @ops: callback ops
* @arg: callback arg * @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.
*/ */
struct sdw_intel_res { struct sdw_intel_res {
int count;
void __iomem *mmio_base; void __iomem *mmio_base;
int irq; int irq;
acpi_handle handle; acpi_handle handle;
struct device *parent; struct device *parent;
const struct sdw_intel_ops *ops; const struct sdw_intel_ops *ops;
void *arg; struct device *dev;
u32 link_mask;
}; };
void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res); /*
void sdw_intel_exit(void *arg); * 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);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment