1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2dfe66a18SJeeja KP #ifndef __SOUND_HDAUDIO_EXT_H 3dfe66a18SJeeja KP #define __SOUND_HDAUDIO_EXT_H 4dfe66a18SJeeja KP 5c19bd02eSCezary Rojewski #include <linux/io-64-nonatomic-lo-hi.h> 6c19bd02eSCezary Rojewski #include <linux/iopoll.h> 7dfe66a18SJeeja KP #include <sound/hdaudio.h> 8dfe66a18SJeeja KP 976f56faeSRakesh Ughreja int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, 10dfe66a18SJeeja KP const struct hdac_bus_ops *ops, 11cb04ba33SRakesh Ughreja const struct hdac_ext_bus_ops *ext_ops); 12dfe66a18SJeeja KP 1376f56faeSRakesh Ughreja void snd_hdac_ext_bus_exit(struct hdac_bus *bus); 1476f56faeSRakesh Ughreja void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus); 15dfe66a18SJeeja KP 16b6e84c99SSubhransu S. Prusty #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \ 17b6e84c99SSubhransu S. Prusty { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \ 18b6e84c99SSubhransu S. Prusty .api_version = HDA_DEV_ASOC, \ 19b6e84c99SSubhransu S. Prusty .driver_data = (unsigned long)(drv_data) } 20b6e84c99SSubhransu S. Prusty #define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \ 21b6e84c99SSubhransu S. Prusty HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data) 22b6e84c99SSubhransu S. Prusty 2376f56faeSRakesh Ughreja void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *chip, bool enable); 2476f56faeSRakesh Ughreja void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *chip, bool enable); 25dfe66a18SJeeja KP 2676f56faeSRakesh Ughreja int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus); 27b0cd60f3SPierre-Louis Bossart struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_addr(struct hdac_bus *bus, int addr); 28b0cd60f3SPierre-Louis Bossart struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_name(struct hdac_bus *bus, 290b00a561SJeeja KP const char *codec_name); 300b00a561SJeeja KP 310b00a561SJeeja KP enum hdac_ext_stream_type { 320b00a561SJeeja KP HDAC_EXT_STREAM_TYPE_COUPLED = 0, 330b00a561SJeeja KP HDAC_EXT_STREAM_TYPE_HOST, 340b00a561SJeeja KP HDAC_EXT_STREAM_TYPE_LINK 350b00a561SJeeja KP }; 360b00a561SJeeja KP 37df203a4eSJeeja KP /** 38df203a4eSJeeja KP * hdac_ext_stream: HDAC extended stream for extended HDA caps 39df203a4eSJeeja KP * 40df203a4eSJeeja KP * @hstream: hdac_stream 41df203a4eSJeeja KP * @pphc_addr: processing pipe host stream pointer 42df203a4eSJeeja KP * @pplc_addr: processing pipe link stream pointer 43df203a4eSJeeja KP * @decoupled: stream host and link is decoupled 44df203a4eSJeeja KP * @link_locked: link is locked 45df203a4eSJeeja KP * @link_prepared: link is prepared 460c4aa677SPierre-Louis Bossart * @link_substream: link substream 47df203a4eSJeeja KP */ 48df203a4eSJeeja KP struct hdac_ext_stream { 49df203a4eSJeeja KP struct hdac_stream hstream; 50df203a4eSJeeja KP 51df203a4eSJeeja KP void __iomem *pphc_addr; 52df203a4eSJeeja KP void __iomem *pplc_addr; 53df203a4eSJeeja KP 542b9a50eaSCezary Rojewski u32 pphcllpl; 552b9a50eaSCezary Rojewski u32 pphcllpu; 562b9a50eaSCezary Rojewski u32 pphcldpl; 572b9a50eaSCezary Rojewski u32 pphcldpu; 582b9a50eaSCezary Rojewski 59*f9eeb6bbSPeter Ujfalusi u32 pplcllpl; 60*f9eeb6bbSPeter Ujfalusi u32 pplcllpu; 61*f9eeb6bbSPeter Ujfalusi 62df203a4eSJeeja KP bool decoupled:1; 63df203a4eSJeeja KP bool link_locked:1; 64df203a4eSJeeja KP bool link_prepared; 65df203a4eSJeeja KP 665eb4ff88SCezary Rojewski int (*host_setup)(struct hdac_stream *, bool); 6788320b74SCezary Rojewski 68df203a4eSJeeja KP struct snd_pcm_substream *link_substream; 69df203a4eSJeeja KP }; 70df203a4eSJeeja KP 71df203a4eSJeeja KP #define hdac_stream(s) (&(s)->hstream) 72df203a4eSJeeja KP #define stream_to_hdac_ext_stream(s) \ 73df203a4eSJeeja KP container_of(s, struct hdac_ext_stream, hstream) 74df203a4eSJeeja KP 7576f56faeSRakesh Ughreja int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, 76e7a3484dSVinod Koul int num_stream, int dir); 770839a04eSPierre-Louis Bossart void snd_hdac_ext_stream_free_all(struct hdac_bus *bus); 787f05ca9aSPierre-Louis Bossart void snd_hdac_ext_link_free_all(struct hdac_bus *bus); 7976f56faeSRakesh Ughreja struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, 80df203a4eSJeeja KP struct snd_pcm_substream *substream, 81df203a4eSJeeja KP int type); 820f7e5ee6SPierre-Louis Bossart void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type); 8397d73d97SCezary Rojewski struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus, 8497d73d97SCezary Rojewski struct snd_compr_stream *cstream); 85868ddfceSPierre-Louis Bossart void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, 860f7e5ee6SPierre-Louis Bossart struct hdac_ext_stream *hext_stream, bool decouple); 8776f56faeSRakesh Ughreja void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, 88df203a4eSJeeja KP struct hdac_ext_stream *azx_dev, bool decouple); 89df203a4eSJeeja KP 9000b6cd95SPierre-Louis Bossart void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream); 9100b6cd95SPierre-Louis Bossart void snd_hdac_ext_stream_clear(struct hdac_ext_stream *hext_stream); 9200b6cd95SPierre-Louis Bossart void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream); 9300b6cd95SPierre-Louis Bossart int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt); 945eb4ff88SCezary Rojewski int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream, bool code_loading); 95df203a4eSJeeja KP 960b00a561SJeeja KP struct hdac_ext_link { 970b00a561SJeeja KP struct hdac_bus *bus; 980b00a561SJeeja KP int index; 990b00a561SJeeja KP void __iomem *ml_addr; /* link output stream reg pointer */ 1000b00a561SJeeja KP u32 lcaps; /* link capablities */ 1010b00a561SJeeja KP u16 lsdiid; /* link sdi identifier */ 1024446085dSVinod Koul 1034446085dSVinod Koul int ref_count; 1044446085dSVinod Koul 1050b00a561SJeeja KP struct list_head list; 1060b00a561SJeeja KP }; 1070b00a561SJeeja KP 108eebaa6b0SPierre-Louis Bossart int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *hlink); 109eebaa6b0SPierre-Louis Bossart int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *hlink); 11076f56faeSRakesh Ughreja int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus); 11176f56faeSRakesh Ughreja int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus); 1127fa403f2SPierre-Louis Bossart void snd_hdac_ext_bus_link_set_stream_id(struct hdac_ext_link *hlink, 1130b00a561SJeeja KP int stream); 1147fa403f2SPierre-Louis Bossart void snd_hdac_ext_bus_link_clear_stream_id(struct hdac_ext_link *hlink, 1150b00a561SJeeja KP int stream); 1160b00a561SJeeja KP 117eebaa6b0SPierre-Louis Bossart int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *hlink); 118eebaa6b0SPierre-Louis Bossart int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *hlink); 1194446085dSVinod Koul 120f9e5fd1bSKai Vehmanen void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable); 121f9e5fd1bSKai Vehmanen 122c19bd02eSCezary Rojewski #define snd_hdac_adsp_writeb(chip, reg, value) \ 123c19bd02eSCezary Rojewski snd_hdac_reg_writeb(chip, (chip)->dsp_ba + (reg), value) 124c19bd02eSCezary Rojewski #define snd_hdac_adsp_readb(chip, reg) \ 125c19bd02eSCezary Rojewski snd_hdac_reg_readb(chip, (chip)->dsp_ba + (reg)) 126c19bd02eSCezary Rojewski #define snd_hdac_adsp_writew(chip, reg, value) \ 127c19bd02eSCezary Rojewski snd_hdac_reg_writew(chip, (chip)->dsp_ba + (reg), value) 128c19bd02eSCezary Rojewski #define snd_hdac_adsp_readw(chip, reg) \ 129c19bd02eSCezary Rojewski snd_hdac_reg_readw(chip, (chip)->dsp_ba + (reg)) 130c19bd02eSCezary Rojewski #define snd_hdac_adsp_writel(chip, reg, value) \ 131c19bd02eSCezary Rojewski snd_hdac_reg_writel(chip, (chip)->dsp_ba + (reg), value) 132c19bd02eSCezary Rojewski #define snd_hdac_adsp_readl(chip, reg) \ 133c19bd02eSCezary Rojewski snd_hdac_reg_readl(chip, (chip)->dsp_ba + (reg)) 134c19bd02eSCezary Rojewski #define snd_hdac_adsp_writeq(chip, reg, value) \ 135c19bd02eSCezary Rojewski snd_hdac_reg_writeq(chip, (chip)->dsp_ba + (reg), value) 136c19bd02eSCezary Rojewski #define snd_hdac_adsp_readq(chip, reg) \ 137c19bd02eSCezary Rojewski snd_hdac_reg_readq(chip, (chip)->dsp_ba + (reg)) 138c19bd02eSCezary Rojewski 139c19bd02eSCezary Rojewski #define snd_hdac_adsp_updateb(chip, reg, mask, val) \ 140c19bd02eSCezary Rojewski snd_hdac_adsp_writeb(chip, reg, \ 141c19bd02eSCezary Rojewski (snd_hdac_adsp_readb(chip, reg) & ~(mask)) | (val)) 142c19bd02eSCezary Rojewski #define snd_hdac_adsp_updatew(chip, reg, mask, val) \ 143c19bd02eSCezary Rojewski snd_hdac_adsp_writew(chip, reg, \ 144c19bd02eSCezary Rojewski (snd_hdac_adsp_readw(chip, reg) & ~(mask)) | (val)) 145c19bd02eSCezary Rojewski #define snd_hdac_adsp_updatel(chip, reg, mask, val) \ 146c19bd02eSCezary Rojewski snd_hdac_adsp_writel(chip, reg, \ 147c19bd02eSCezary Rojewski (snd_hdac_adsp_readl(chip, reg) & ~(mask)) | (val)) 148c19bd02eSCezary Rojewski #define snd_hdac_adsp_updateq(chip, reg, mask, val) \ 149c19bd02eSCezary Rojewski snd_hdac_adsp_writeq(chip, reg, \ 150c19bd02eSCezary Rojewski (snd_hdac_adsp_readq(chip, reg) & ~(mask)) | (val)) 151c19bd02eSCezary Rojewski 152c19bd02eSCezary Rojewski #define snd_hdac_adsp_readb_poll(chip, reg, val, cond, delay_us, timeout_us) \ 153c19bd02eSCezary Rojewski readb_poll_timeout((chip)->dsp_ba + (reg), val, cond, \ 154c19bd02eSCezary Rojewski delay_us, timeout_us) 155c19bd02eSCezary Rojewski #define snd_hdac_adsp_readw_poll(chip, reg, val, cond, delay_us, timeout_us) \ 156c19bd02eSCezary Rojewski readw_poll_timeout((chip)->dsp_ba + (reg), val, cond, \ 157c19bd02eSCezary Rojewski delay_us, timeout_us) 158c19bd02eSCezary Rojewski #define snd_hdac_adsp_readl_poll(chip, reg, val, cond, delay_us, timeout_us) \ 159c19bd02eSCezary Rojewski readl_poll_timeout((chip)->dsp_ba + (reg), val, cond, \ 160c19bd02eSCezary Rojewski delay_us, timeout_us) 161c19bd02eSCezary Rojewski #define snd_hdac_adsp_readq_poll(chip, reg, val, cond, delay_us, timeout_us) \ 162c19bd02eSCezary Rojewski readq_poll_timeout((chip)->dsp_ba + (reg), val, cond, \ 163c19bd02eSCezary Rojewski delay_us, timeout_us) 164a512f561SVinod Koul 165a512f561SVinod Koul struct hdac_ext_device; 166a512f561SVinod Koul 167a512f561SVinod Koul /* ops common to all codec drivers */ 168a512f561SVinod Koul struct hdac_ext_codec_ops { 169a512f561SVinod Koul int (*build_controls)(struct hdac_ext_device *dev); 170a512f561SVinod Koul int (*init)(struct hdac_ext_device *dev); 171a512f561SVinod Koul void (*free)(struct hdac_ext_device *dev); 172a512f561SVinod Koul }; 173a512f561SVinod Koul 174a512f561SVinod Koul struct hda_dai_map { 175a512f561SVinod Koul char *dai_name; 176a512f561SVinod Koul hda_nid_t nid; 177a512f561SVinod Koul u32 maxbps; 178a512f561SVinod Koul }; 179a512f561SVinod Koul 1801e83b047SSubhransu S. Prusty struct hdac_ext_dma_params { 1811e83b047SSubhransu S. Prusty u32 format; 1821e83b047SSubhransu S. Prusty u8 stream_tag; 1831e83b047SSubhransu S. Prusty }; 1843787a398SRakesh Ughreja 185e1df9317SRakesh Ughreja int snd_hda_ext_driver_register(struct hdac_driver *drv); 186e1df9317SRakesh Ughreja void snd_hda_ext_driver_unregister(struct hdac_driver *drv); 187a512f561SVinod Koul 188dfe66a18SJeeja KP #endif /* __SOUND_HDAUDIO_EXT_H */ 189