Path: blob/master/sound/soc/intel/keembay/kmb_platform.h
26481 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Intel KeemBay Platform driver3*4* Copyright (C) 2020 Intel Corporation.5*6*/78#ifndef KMB_PLATFORM_H_9#define KMB_PLATFORM_H_1011#include <linux/bits.h>12#include <linux/bitfield.h>13#include <linux/types.h>14#include <sound/dmaengine_pcm.h>1516/* Register values with reference to KMB databook v1.1 */17/* common register for all channel */18#define IER 0x00019#define IRER 0x00420#define ITER 0x00821#define CER 0x00C22#define CCR 0x01023#define RXFFR 0x01424#define TXFFR 0x0182526/* Interrupt status register fields */27#define ISR_TXFO BIT(5)28#define ISR_TXFE BIT(4)29#define ISR_RXFO BIT(1)30#define ISR_RXDA BIT(0)3132/* I2S Tx Rx Registers for all channels */33#define LRBR_LTHR(x) (0x40 * (x) + 0x020)34#define RRBR_RTHR(x) (0x40 * (x) + 0x024)35#define RER(x) (0x40 * (x) + 0x028)36#define TER(x) (0x40 * (x) + 0x02C)37#define RCR(x) (0x40 * (x) + 0x030)38#define TCR(x) (0x40 * (x) + 0x034)39#define ISR(x) (0x40 * (x) + 0x038)40#define IMR(x) (0x40 * (x) + 0x03C)41#define ROR(x) (0x40 * (x) + 0x040)42#define TOR(x) (0x40 * (x) + 0x044)43#define RFCR(x) (0x40 * (x) + 0x048)44#define TFCR(x) (0x40 * (x) + 0x04C)45#define RFF(x) (0x40 * (x) + 0x050)46#define TFF(x) (0x40 * (x) + 0x054)4748/* I2S COMP Registers */49#define I2S_COMP_PARAM_2 0x01F050#define I2S_COMP_PARAM_1 0x01F451#define I2S_COMP_VERSION 0x01F852#define I2S_COMP_TYPE 0x01FC5354/* PSS_GEN_CTRL_I2S_GEN_CFG_0 Registers */55#define I2S_GEN_CFG_0 0x00056#define PSS_CPR_RST_EN 0x01057#define PSS_CPR_RST_SET 0x01458#define PSS_CPR_CLK_CLR 0x00059#define PSS_CPR_AUX_RST_EN 0x0706061#define CLOCK_PROVIDER_MODE BIT(13)6263/* Interrupt Flag */64#define TX_INT_FLAG GENMASK(5, 4)65#define RX_INT_FLAG GENMASK(1, 0)66/*67* Component parameter register fields - define the I2S block's68* configuration.69*/70#define COMP1_TX_WORDSIZE_3(r) FIELD_GET(GENMASK(27, 25), (r))71#define COMP1_TX_WORDSIZE_2(r) FIELD_GET(GENMASK(24, 22), (r))72#define COMP1_TX_WORDSIZE_1(r) FIELD_GET(GENMASK(21, 19), (r))73#define COMP1_TX_WORDSIZE_0(r) FIELD_GET(GENMASK(18, 16), (r))74#define COMP1_RX_ENABLED(r) FIELD_GET(BIT(6), (r))75#define COMP1_TX_ENABLED(r) FIELD_GET(BIT(5), (r))76#define COMP1_MODE_EN(r) FIELD_GET(BIT(4), (r))77#define COMP1_APB_DATA_WIDTH(r) FIELD_GET(GENMASK(1, 0), (r))78#define COMP2_RX_WORDSIZE_3(r) FIELD_GET(GENMASK(12, 10), (r))79#define COMP2_RX_WORDSIZE_2(r) FIELD_GET(GENMASK(9, 7), (r))80#define COMP2_RX_WORDSIZE_1(r) FIELD_GET(GENMASK(5, 3), (r))81#define COMP2_RX_WORDSIZE_0(r) FIELD_GET(GENMASK(2, 0), (r))8283/* Add 1 to the below registers to indicate the actual size */84#define COMP1_TX_CHANNELS(r) (FIELD_GET(GENMASK(10, 9), (r)) + 1)85#define COMP1_RX_CHANNELS(r) (FIELD_GET(GENMASK(8, 7), (r)) + 1)86#define COMP1_FIFO_DEPTH(r) (FIELD_GET(GENMASK(3, 2), (r)) + 1)8788/* Number of entries in WORDSIZE and DATA_WIDTH parameter registers */89#define COMP_MAX_WORDSIZE 8 /* 3 bits register width */9091#define MAX_CHANNEL_NUM 892#define MIN_CHANNEL_NUM 293#define MAX_ISR 49495#define TWO_CHANNEL_SUPPORT 2 /* up to 2.0 */96#define FOUR_CHANNEL_SUPPORT 4 /* up to 3.1 */97#define SIX_CHANNEL_SUPPORT 6 /* up to 5.1 */98#define EIGHT_CHANNEL_SUPPORT 8 /* up to 7.1 */99100#define DWC_I2S_PLAY BIT(0)101#define DWC_I2S_RECORD BIT(1)102#define DW_I2S_CONSUMER BIT(2)103#define DW_I2S_PROVIDER BIT(3)104105#define I2S_RXDMA 0x01C0106#define I2S_RRXDMA 0x01C4107#define I2S_TXDMA 0x01C8108#define I2S_RTXDMA 0x01CC109#define I2S_DMACR 0x0200110#define I2S_DMAEN_RXBLOCK (1 << 16)111#define I2S_DMAEN_TXBLOCK (1 << 17)112113/*114* struct i2s_clk_config_data - represent i2s clk configuration data115* @chan_nr: number of channel116* @data_width: number of bits per sample (8/16/24/32 bit)117* @sample_rate: sampling frequency (8Khz, 16Khz, 48Khz)118*/119struct i2s_clk_config_data {120int chan_nr;121u32 data_width;122u32 sample_rate;123};124125struct kmb_i2s_info {126void __iomem *i2s_base;127void __iomem *pss_base;128struct clk *clk_i2s;129struct clk *clk_apb;130int active;131unsigned int capability;132unsigned int i2s_reg_comp1;133unsigned int i2s_reg_comp2;134struct device *dev;135u32 ccr;136u32 xfer_resolution;137u32 fifo_th;138bool clock_provider;139/* data related to DMA transfers b/w i2s and DMAC */140struct snd_dmaengine_dai_dma_data play_dma_data;141struct snd_dmaengine_dai_dma_data capture_dma_data;142143struct i2s_clk_config_data config;144int (*i2s_clk_cfg)(struct i2s_clk_config_data *config);145146/* data related to PIO transfers */147bool use_pio;148struct snd_pcm_substream *tx_substream;149struct snd_pcm_substream *rx_substream;150unsigned int tx_ptr;151unsigned int rx_ptr;152bool iec958_fmt;153};154155#endif /* KMB_PLATFORM_H_ */156157158