2019-05-01 18:57:25 +03:00
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
/* Copyright(c) 2015-17 Intel Corporation. */
2017-12-14 08:49:43 +03:00
# ifndef __SDW_INTEL_LOCAL_H
# define __SDW_INTEL_LOCAL_H
/**
2019-12-12 04:45:01 +03:00
* struct sdw_intel_link_res - Soundwire Intel link resource structure ,
* typically populated by the controller driver .
2022-11-11 04:31:28 +03:00
* @ hw_ops : platform - specific ops
2019-12-12 04:45:01 +03:00
* @ mmio_base : mmio base of SoundWire registers
2017-12-14 08:49:43 +03:00
* @ registers : Link IO registers base
* @ shim : Audio shim pointer
* @ alh : ALH ( Audio Link Hub ) pointer
* @ irq : Interrupt line
2018-04-26 16:09:05 +03:00
* @ ops : Shim callback ops
2019-12-12 04:45:02 +03:00
* @ dev : device implementing hw_params and free callbacks
2020-07-16 18:09:40 +03:00
* @ shim_lock : mutex to handle access to shared SHIM registers
* @ shim_mask : global pointer to check SHIM register initialization
2020-08-17 18:29:18 +03:00
* @ clock_stop_quirks : mask defining requested behavior on pm_suspend
2020-09-01 18:05:55 +03:00
* @ link_mask : global mask needed for power - up / down sequences
2020-07-16 18:09:45 +03:00
* @ cdns : Cadence master descriptor
* @ list : used to walk - through all masters exposed by the same controller
2017-12-14 08:49:43 +03:00
*/
struct sdw_intel_link_res {
2022-11-11 04:31:28 +03:00
const struct sdw_intel_hw_ops * hw_ops ;
2019-12-12 04:45:01 +03:00
void __iomem * mmio_base ; /* not strictly needed, useful for debug */
2017-12-14 08:49:43 +03:00
void __iomem * registers ;
void __iomem * shim ;
void __iomem * alh ;
int irq ;
2018-04-26 16:09:05 +03:00
const struct sdw_intel_ops * ops ;
2019-12-12 04:45:02 +03:00
struct device * dev ;
2020-07-16 18:09:40 +03:00
struct mutex * shim_lock ; /* protect shared registers */
u32 * shim_mask ;
2020-08-17 18:29:18 +03:00
u32 clock_stop_quirks ;
2020-09-01 18:05:55 +03:00
u32 link_mask ;
2020-07-16 18:09:45 +03:00
struct sdw_cdns * cdns ;
struct list_head list ;
2017-12-14 08:49:43 +03:00
} ;
2020-05-31 21:20:57 +03:00
struct sdw_intel {
struct sdw_cdns cdns ;
int instance ;
struct sdw_intel_link_res * link_res ;
2021-08-18 05:49:53 +03:00
bool startup_done ;
2020-05-31 21:20:57 +03:00
# ifdef CONFIG_DEBUG_FS
struct dentry * debugfs ;
# endif
} ;
2021-05-11 08:21:32 +03:00
int intel_link_startup ( struct auxiliary_device * auxdev ) ;
int intel_link_process_wakeen_event ( struct auxiliary_device * auxdev ) ;
struct sdw_intel_link_dev {
struct auxiliary_device auxdev ;
struct sdw_intel_link_res link_res ;
} ;
# define auxiliary_dev_to_sdw_intel_link_dev(auxiliary_dev) \
container_of ( auxiliary_dev , struct sdw_intel_link_dev , auxdev )
2020-05-31 21:21:02 +03:00
2022-11-11 04:31:29 +03: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)
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 04:31:30 +03: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 04:31:31 +03: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 ;
}
2017-12-14 08:49:43 +03:00
# endif /* __SDW_INTEL_LOCAL_H */