1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) 1 2 * 3 * Copyright (c) 2018 Baylibre SAS. 4 * Author: Jerome Brunet <jbrunet@baylibre.com 5 */ 6 7 #ifndef _MESON_AXG_TDM_H 8 #define _MESON_AXG_TDM_H 9 10 #include <linux/clk.h> 11 #include <linux/regmap.h> 12 #include <sound/pcm.h> 13 #include <sound/soc.h> 14 #include <sound/soc-dai.h> 15 16 #define AXG_TDM_NUM_LANES 4 17 #define AXG_TDM_CHANNEL_MAX 128 18 #define AXG_TDM_RATES (SNDRV_PCM_RAT 19 SNDRV_PCM_RAT 20 #define AXG_TDM_FORMATS (SNDRV_PCM_FMT 21 SNDRV_PCM_FMT 22 SNDRV_PCM_FMT 23 SNDRV_PCM_FMT 24 SNDRV_PCM_FMT 25 26 struct axg_tdm_iface { 27 struct clk *sclk; 28 struct clk *lrclk; 29 struct clk *mclk; 30 unsigned long mclk_rate; 31 32 /* format is common to all the DAIs of 33 unsigned int fmt; 34 unsigned int slots; 35 unsigned int slot_width; 36 37 /* For component wide symmetry */ 38 int rate; 39 }; 40 41 static inline bool axg_tdm_lrclk_invert(unsign 42 { 43 return ((fmt & SND_SOC_DAIFMT_FORMAT_M 44 !!(fmt & (SND_SOC_DAIFMT_IB_IF 45 } 46 47 static inline bool axg_tdm_sclk_invert(unsigne 48 { 49 return fmt & (SND_SOC_DAIFMT_IB_IF | S 50 } 51 52 struct axg_tdm_stream { 53 struct axg_tdm_iface *iface; 54 struct list_head formatter_list; 55 struct mutex lock; 56 unsigned int channels; 57 unsigned int width; 58 unsigned int physical_width; 59 u32 *mask; 60 bool ready; 61 62 /* For continuous clock tracking */ 63 bool clk_enabled; 64 }; 65 66 struct axg_tdm_stream *axg_tdm_stream_alloc(st 67 void axg_tdm_stream_free(struct axg_tdm_stream 68 int axg_tdm_stream_start(struct axg_tdm_stream 69 void axg_tdm_stream_stop(struct axg_tdm_stream 70 int axg_tdm_stream_set_cont_clocks(struct axg_ 71 unsigned in 72 73 static inline int axg_tdm_stream_reset(struct 74 { 75 axg_tdm_stream_stop(ts); 76 return axg_tdm_stream_start(ts); 77 } 78 79 int axg_tdm_set_tdm_slots(struct snd_soc_dai * 80 u32 *rx_mask, unsign 81 unsigned int slot_wi 82 83 #endif /* _MESON_AXG_TDM_H */ 84
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.