2019-05-01 15:57:25 +00:00
|
|
|
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
|
|
|
|
/* Copyright(c) 2015-17 Intel Corporation. */
|
2017-12-14 05:49:43 +00:00
|
|
|
|
|
|
|
#ifndef __SDW_INTEL_LOCAL_H
|
|
|
|
#define __SDW_INTEL_LOCAL_H
|
|
|
|
|
2023-05-15 07:10:22 +00:00
|
|
|
struct hdac_bus;
|
|
|
|
|
2017-12-14 05:49:43 +00:00
|
|
|
/**
|
2019-12-12 01:45:01 +00:00
|
|
|
* struct sdw_intel_link_res - Soundwire Intel link resource structure,
|
|
|
|
* typically populated by the controller driver.
|
2022-11-11 01:31:28 +00:00
|
|
|
* @hw_ops: platform-specific ops
|
2019-12-12 01:45:01 +00:00
|
|
|
* @mmio_base: mmio base of SoundWire registers
|
2017-12-14 05:49:43 +00:00
|
|
|
* @registers: Link IO registers base
|
2023-05-15 07:10:21 +00:00
|
|
|
* @ip_offset: offset for MCP_IP registers
|
2017-12-14 05:49:43 +00:00
|
|
|
* @shim: Audio shim pointer
|
2023-05-15 07:10:20 +00:00
|
|
|
* @shim_vs: Audio vendor-specific shim pointer
|
2017-12-14 05:49:43 +00:00
|
|
|
* @alh: ALH (Audio Link Hub) pointer
|
|
|
|
* @irq: Interrupt line
|
2018-04-26 13:09:05 +00:00
|
|
|
* @ops: Shim callback ops
|
2019-12-12 01:45:02 +00:00
|
|
|
* @dev: device implementing hw_params and free callbacks
|
2020-07-16 15:09:40 +00:00
|
|
|
* @shim_lock: mutex to handle access to shared SHIM registers
|
|
|
|
* @shim_mask: global pointer to check SHIM register initialization
|
2020-08-17 15:29:18 +00:00
|
|
|
* @clock_stop_quirks: mask defining requested behavior on pm_suspend
|
2020-09-01 15:05:55 +00:00
|
|
|
* @link_mask: global mask needed for power-up/down sequences
|
2020-07-16 15:09:45 +00:00
|
|
|
* @cdns: Cadence master descriptor
|
|
|
|
* @list: used to walk-through all masters exposed by the same controller
|
2023-05-15 07:10:22 +00:00
|
|
|
* @hbus: hdac_bus pointer, needed for power management
|
2017-12-14 05:49:43 +00:00
|
|
|
*/
|
|
|
|
struct sdw_intel_link_res {
|
2022-11-11 01:31:28 +00:00
|
|
|
const struct sdw_intel_hw_ops *hw_ops;
|
|
|
|
|
2019-12-12 01:45:01 +00:00
|
|
|
void __iomem *mmio_base; /* not strictly needed, useful for debug */
|
2017-12-14 05:49:43 +00:00
|
|
|
void __iomem *registers;
|
2023-05-15 07:10:21 +00:00
|
|
|
u32 ip_offset;
|
2017-12-14 05:49:43 +00:00
|
|
|
void __iomem *shim;
|
2023-05-15 07:10:20 +00:00
|
|
|
void __iomem *shim_vs;
|
2017-12-14 05:49:43 +00:00
|
|
|
void __iomem *alh;
|
|
|
|
int irq;
|
2018-04-26 13:09:05 +00:00
|
|
|
const struct sdw_intel_ops *ops;
|
2019-12-12 01:45:02 +00:00
|
|
|
struct device *dev;
|
2020-07-16 15:09:40 +00:00
|
|
|
struct mutex *shim_lock; /* protect shared registers */
|
|
|
|
u32 *shim_mask;
|
2020-08-17 15:29:18 +00:00
|
|
|
u32 clock_stop_quirks;
|
2020-09-01 15:05:55 +00:00
|
|
|
u32 link_mask;
|
2020-07-16 15:09:45 +00:00
|
|
|
struct sdw_cdns *cdns;
|
|
|
|
struct list_head list;
|
2023-05-15 07:10:22 +00:00
|
|
|
struct hdac_bus *hbus;
|
2017-12-14 05:49:43 +00:00
|
|
|
};
|
|
|
|
|
2020-05-31 18:20:57 +00:00
|
|
|
struct sdw_intel {
|
|
|
|
struct sdw_cdns cdns;
|
|
|
|
int instance;
|
|
|
|
struct sdw_intel_link_res *link_res;
|
2021-08-18 02:49:53 +00:00
|
|
|
bool startup_done;
|
2020-05-31 18:20:57 +00:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
struct dentry *debugfs;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2024-04-29 00:43:19 +00:00
|
|
|
struct sdw_intel_prop {
|
2024-06-03 07:02:40 +00:00
|
|
|
u16 clde;
|
|
|
|
u16 doaise2;
|
|
|
|
u16 dodse2;
|
|
|
|
u16 clds;
|
|
|
|
u16 clss;
|
2024-04-29 00:43:21 +00:00
|
|
|
u16 doaise;
|
2024-04-29 00:43:19 +00:00
|
|
|
u16 doais;
|
2024-04-29 00:43:20 +00:00
|
|
|
u16 dodse;
|
2024-04-29 00:43:19 +00:00
|
|
|
u16 dods;
|
|
|
|
};
|
|
|
|
|
2023-03-14 01:53:55 +00:00
|
|
|
enum intel_pdi_type {
|
|
|
|
INTEL_PDI_IN = 0,
|
|
|
|
INTEL_PDI_OUT = 1,
|
|
|
|
INTEL_PDI_BD = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read, write helpers for HW registers
|
|
|
|
*/
|
|
|
|
static inline int intel_readl(void __iomem *base, int offset)
|
|
|
|
{
|
|
|
|
return readl(base + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void intel_writel(void __iomem *base, int offset, int value)
|
|
|
|
{
|
|
|
|
writel(value, base + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u16 intel_readw(void __iomem *base, int offset)
|
|
|
|
{
|
|
|
|
return readw(base + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void intel_writew(void __iomem *base, int offset, u16 value)
|
|
|
|
{
|
|
|
|
writew(value, base + offset);
|
|
|
|
}
|
|
|
|
|
2022-11-11 01:31:34 +00:00
|
|
|
#define cdns_to_intel(_cdns) container_of(_cdns, struct sdw_intel, cdns)
|
2021-05-11 05:21:32 +00:00
|
|
|
|
2022-11-11 01:31:34 +00:00
|
|
|
#define INTEL_MASTER_RESET_ITERATIONS 10
|
2020-05-31 18:21:02 +00:00
|
|
|
|
2022-11-11 01:31:29 +00:00
|
|
|
#define SDW_INTEL_CHECK_OPS(sdw, cb) ((sdw) && (sdw)->link_res && (sdw)->link_res->hw_ops && \
|
|
|
|
(sdw)->link_res->hw_ops->cb)
|
|
|
|
#define SDW_INTEL_OPS(sdw, cb) ((sdw)->link_res->hw_ops->cb)
|
|
|
|
|
2023-05-15 07:10:26 +00:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void intel_ace2x_debugfs_init(struct sdw_intel *sdw);
|
|
|
|
void intel_ace2x_debugfs_exit(struct sdw_intel *sdw);
|
|
|
|
#else
|
|
|
|
static inline void intel_ace2x_debugfs_init(struct sdw_intel *sdw) {}
|
|
|
|
static inline void intel_ace2x_debugfs_exit(struct sdw_intel *sdw) {}
|
|
|
|
#endif
|
|
|
|
|
2022-11-11 01:31:29 +00:00
|
|
|
static inline void sdw_intel_debugfs_init(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, debugfs_init))
|
|
|
|
SDW_INTEL_OPS(sdw, debugfs_init)(sdw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void sdw_intel_debugfs_exit(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, debugfs_exit))
|
|
|
|
SDW_INTEL_OPS(sdw, debugfs_exit)(sdw);
|
|
|
|
}
|
|
|
|
|
2022-11-11 01:31:30 +00:00
|
|
|
static inline int sdw_intel_register_dai(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, register_dai))
|
|
|
|
return SDW_INTEL_OPS(sdw, register_dai)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
2022-11-11 01:31:31 +00:00
|
|
|
static inline void sdw_intel_check_clock_stop(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, check_clock_stop))
|
|
|
|
SDW_INTEL_OPS(sdw, check_clock_stop)(sdw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdw_intel_start_bus(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, start_bus))
|
|
|
|
return SDW_INTEL_OPS(sdw, start_bus)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdw_intel_start_bus_after_reset(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, start_bus_after_reset))
|
|
|
|
return SDW_INTEL_OPS(sdw, start_bus_after_reset)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdw_intel_start_bus_after_clock_stop(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, start_bus_after_clock_stop))
|
|
|
|
return SDW_INTEL_OPS(sdw, start_bus_after_clock_stop)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdw_intel_stop_bus(struct sdw_intel *sdw, bool clock_stop)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, stop_bus))
|
|
|
|
return SDW_INTEL_OPS(sdw, stop_bus)(sdw, clock_stop);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
2022-11-11 01:31:32 +00:00
|
|
|
static inline int sdw_intel_link_power_up(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, link_power_up))
|
|
|
|
return SDW_INTEL_OPS(sdw, link_power_up)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdw_intel_link_power_down(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, link_power_down))
|
|
|
|
return SDW_INTEL_OPS(sdw, link_power_down)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
2022-11-11 01:31:33 +00:00
|
|
|
static inline int sdw_intel_shim_check_wake(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, shim_check_wake))
|
|
|
|
return SDW_INTEL_OPS(sdw, shim_check_wake)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void sdw_intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, shim_wake))
|
|
|
|
SDW_INTEL_OPS(sdw, shim_wake)(sdw, wake_enable);
|
|
|
|
}
|
|
|
|
|
2023-03-14 01:54:00 +00:00
|
|
|
static inline void sdw_intel_sync_arm(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, sync_arm))
|
|
|
|
SDW_INTEL_OPS(sdw, sync_arm)(sdw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdw_intel_sync_go_unlocked(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, sync_go_unlocked))
|
|
|
|
return SDW_INTEL_OPS(sdw, sync_go_unlocked)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdw_intel_sync_go(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, sync_go))
|
|
|
|
return SDW_INTEL_OPS(sdw, sync_go)(sdw);
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
2023-03-14 01:54:03 +00:00
|
|
|
static inline bool sdw_intel_sync_check_cmdsync_unlocked(struct sdw_intel *sdw)
|
|
|
|
{
|
|
|
|
if (SDW_INTEL_CHECK_OPS(sdw, sync_check_cmdsync_unlocked))
|
|
|
|
return SDW_INTEL_OPS(sdw, sync_check_cmdsync_unlocked)(sdw);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-03-14 01:54:02 +00:00
|
|
|
/* common bus management */
|
|
|
|
int intel_start_bus(struct sdw_intel *sdw);
|
|
|
|
int intel_start_bus_after_reset(struct sdw_intel *sdw);
|
|
|
|
void intel_check_clock_stop(struct sdw_intel *sdw);
|
|
|
|
int intel_start_bus_after_clock_stop(struct sdw_intel *sdw);
|
|
|
|
int intel_stop_bus(struct sdw_intel *sdw, bool clock_stop);
|
|
|
|
|
2023-03-14 01:54:04 +00:00
|
|
|
/* common bank switch routines */
|
|
|
|
int intel_pre_bank_switch(struct sdw_intel *sdw);
|
|
|
|
int intel_post_bank_switch(struct sdw_intel *sdw);
|
|
|
|
|
2017-12-14 05:49:43 +00:00
|
|
|
#endif /* __SDW_INTEL_LOCAL_H */
|