1*e4e6ec7bSolivier moysan /* 2*e4e6ec7bSolivier moysan * STM32 ALSA SoC Digital Audio Interface (I2S) driver. 3*e4e6ec7bSolivier moysan * 4*e4e6ec7bSolivier moysan * Copyright (C) 2017, STMicroelectronics - All Rights Reserved 5*e4e6ec7bSolivier moysan * Author(s): Olivier Moysan <olivier.moysan@st.com> for STMicroelectronics. 6*e4e6ec7bSolivier moysan * 7*e4e6ec7bSolivier moysan * License terms: GPL V2.0. 8*e4e6ec7bSolivier moysan * 9*e4e6ec7bSolivier moysan * This program is free software; you can redistribute it and/or modify it 10*e4e6ec7bSolivier moysan * under the terms of the GNU General Public License version 2 as published by 11*e4e6ec7bSolivier moysan * the Free Software Foundation. 12*e4e6ec7bSolivier moysan * 13*e4e6ec7bSolivier moysan * This program is distributed in the hope that it will be useful, but 14*e4e6ec7bSolivier moysan * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15*e4e6ec7bSolivier moysan * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16*e4e6ec7bSolivier moysan * details. 17*e4e6ec7bSolivier moysan */ 18*e4e6ec7bSolivier moysan 19*e4e6ec7bSolivier moysan #include <linux/clk.h> 20*e4e6ec7bSolivier moysan #include <linux/delay.h> 21*e4e6ec7bSolivier moysan #include <linux/module.h> 22*e4e6ec7bSolivier moysan #include <linux/of_irq.h> 23*e4e6ec7bSolivier moysan #include <linux/of_platform.h> 24*e4e6ec7bSolivier moysan #include <linux/regmap.h> 25*e4e6ec7bSolivier moysan #include <linux/reset.h> 26*e4e6ec7bSolivier moysan #include <linux/spinlock.h> 27*e4e6ec7bSolivier moysan 28*e4e6ec7bSolivier moysan #include <sound/dmaengine_pcm.h> 29*e4e6ec7bSolivier moysan #include <sound/pcm_params.h> 30*e4e6ec7bSolivier moysan 31*e4e6ec7bSolivier moysan #define STM32_I2S_CR1_REG 0x0 32*e4e6ec7bSolivier moysan #define STM32_I2S_CFG1_REG 0x08 33*e4e6ec7bSolivier moysan #define STM32_I2S_CFG2_REG 0x0C 34*e4e6ec7bSolivier moysan #define STM32_I2S_IER_REG 0x10 35*e4e6ec7bSolivier moysan #define STM32_I2S_SR_REG 0x14 36*e4e6ec7bSolivier moysan #define STM32_I2S_IFCR_REG 0x18 37*e4e6ec7bSolivier moysan #define STM32_I2S_TXDR_REG 0X20 38*e4e6ec7bSolivier moysan #define STM32_I2S_RXDR_REG 0x30 39*e4e6ec7bSolivier moysan #define STM32_I2S_CGFR_REG 0X50 40*e4e6ec7bSolivier moysan 41*e4e6ec7bSolivier moysan /* Bit definition for SPI2S_CR1 register */ 42*e4e6ec7bSolivier moysan #define I2S_CR1_SPE BIT(0) 43*e4e6ec7bSolivier moysan #define I2S_CR1_CSTART BIT(9) 44*e4e6ec7bSolivier moysan #define I2S_CR1_CSUSP BIT(10) 45*e4e6ec7bSolivier moysan #define I2S_CR1_HDDIR BIT(11) 46*e4e6ec7bSolivier moysan #define I2S_CR1_SSI BIT(12) 47*e4e6ec7bSolivier moysan #define I2S_CR1_CRC33_17 BIT(13) 48*e4e6ec7bSolivier moysan #define I2S_CR1_RCRCI BIT(14) 49*e4e6ec7bSolivier moysan #define I2S_CR1_TCRCI BIT(15) 50*e4e6ec7bSolivier moysan 51*e4e6ec7bSolivier moysan /* Bit definition for SPI_CFG2 register */ 52*e4e6ec7bSolivier moysan #define I2S_CFG2_IOSWP_SHIFT 15 53*e4e6ec7bSolivier moysan #define I2S_CFG2_IOSWP BIT(I2S_CFG2_IOSWP_SHIFT) 54*e4e6ec7bSolivier moysan #define I2S_CFG2_LSBFRST BIT(23) 55*e4e6ec7bSolivier moysan #define I2S_CFG2_AFCNTR BIT(31) 56*e4e6ec7bSolivier moysan 57*e4e6ec7bSolivier moysan /* Bit definition for SPI_CFG1 register */ 58*e4e6ec7bSolivier moysan #define I2S_CFG1_FTHVL_SHIFT 5 59*e4e6ec7bSolivier moysan #define I2S_CFG1_FTHVL_MASK GENMASK(8, I2S_CFG1_FTHVL_SHIFT) 60*e4e6ec7bSolivier moysan #define I2S_CFG1_FTHVL_SET(x) ((x) << I2S_CFG1_FTHVL_SHIFT) 61*e4e6ec7bSolivier moysan 62*e4e6ec7bSolivier moysan #define I2S_CFG1_TXDMAEN BIT(15) 63*e4e6ec7bSolivier moysan #define I2S_CFG1_RXDMAEN BIT(14) 64*e4e6ec7bSolivier moysan 65*e4e6ec7bSolivier moysan /* Bit definition for SPI2S_IER register */ 66*e4e6ec7bSolivier moysan #define I2S_IER_RXPIE BIT(0) 67*e4e6ec7bSolivier moysan #define I2S_IER_TXPIE BIT(1) 68*e4e6ec7bSolivier moysan #define I2S_IER_DPXPIE BIT(2) 69*e4e6ec7bSolivier moysan #define I2S_IER_EOTIE BIT(3) 70*e4e6ec7bSolivier moysan #define I2S_IER_TXTFIE BIT(4) 71*e4e6ec7bSolivier moysan #define I2S_IER_UDRIE BIT(5) 72*e4e6ec7bSolivier moysan #define I2S_IER_OVRIE BIT(6) 73*e4e6ec7bSolivier moysan #define I2S_IER_CRCEIE BIT(7) 74*e4e6ec7bSolivier moysan #define I2S_IER_TIFREIE BIT(8) 75*e4e6ec7bSolivier moysan #define I2S_IER_MODFIE BIT(9) 76*e4e6ec7bSolivier moysan #define I2S_IER_TSERFIE BIT(10) 77*e4e6ec7bSolivier moysan 78*e4e6ec7bSolivier moysan /* Bit definition for SPI2S_SR register */ 79*e4e6ec7bSolivier moysan #define I2S_SR_RXP BIT(0) 80*e4e6ec7bSolivier moysan #define I2S_SR_TXP BIT(1) 81*e4e6ec7bSolivier moysan #define I2S_SR_DPXP BIT(2) 82*e4e6ec7bSolivier moysan #define I2S_SR_EOT BIT(3) 83*e4e6ec7bSolivier moysan #define I2S_SR_TXTF BIT(4) 84*e4e6ec7bSolivier moysan #define I2S_SR_UDR BIT(5) 85*e4e6ec7bSolivier moysan #define I2S_SR_OVR BIT(6) 86*e4e6ec7bSolivier moysan #define I2S_SR_CRCERR BIT(7) 87*e4e6ec7bSolivier moysan #define I2S_SR_TIFRE BIT(8) 88*e4e6ec7bSolivier moysan #define I2S_SR_MODF BIT(9) 89*e4e6ec7bSolivier moysan #define I2S_SR_TSERF BIT(10) 90*e4e6ec7bSolivier moysan #define I2S_SR_SUSP BIT(11) 91*e4e6ec7bSolivier moysan #define I2S_SR_TXC BIT(12) 92*e4e6ec7bSolivier moysan #define I2S_SR_RXPLVL GENMASK(14, 13) 93*e4e6ec7bSolivier moysan #define I2S_SR_RXWNE BIT(15) 94*e4e6ec7bSolivier moysan 95*e4e6ec7bSolivier moysan #define I2S_SR_MASK GENMASK(15, 0) 96*e4e6ec7bSolivier moysan 97*e4e6ec7bSolivier moysan /* Bit definition for SPI_IFCR register */ 98*e4e6ec7bSolivier moysan #define I2S_IFCR_EOTC BIT(3) 99*e4e6ec7bSolivier moysan #define I2S_IFCR_TXTFC BIT(4) 100*e4e6ec7bSolivier moysan #define I2S_IFCR_UDRC BIT(5) 101*e4e6ec7bSolivier moysan #define I2S_IFCR_OVRC BIT(6) 102*e4e6ec7bSolivier moysan #define I2S_IFCR_CRCEC BIT(7) 103*e4e6ec7bSolivier moysan #define I2S_IFCR_TIFREC BIT(8) 104*e4e6ec7bSolivier moysan #define I2S_IFCR_MODFC BIT(9) 105*e4e6ec7bSolivier moysan #define I2S_IFCR_TSERFC BIT(10) 106*e4e6ec7bSolivier moysan #define I2S_IFCR_SUSPC BIT(11) 107*e4e6ec7bSolivier moysan 108*e4e6ec7bSolivier moysan #define I2S_IFCR_MASK GENMASK(11, 3) 109*e4e6ec7bSolivier moysan 110*e4e6ec7bSolivier moysan /* Bit definition for SPI_I2SCGFR register */ 111*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SMOD BIT(0) 112*e4e6ec7bSolivier moysan 113*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SCFG_SHIFT 1 114*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SCFG_MASK GENMASK(3, I2S_CGFR_I2SCFG_SHIFT) 115*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SCFG_SET(x) ((x) << I2S_CGFR_I2SCFG_SHIFT) 116*e4e6ec7bSolivier moysan 117*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SSTD_SHIFT 4 118*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SSTD_MASK GENMASK(5, I2S_CGFR_I2SSTD_SHIFT) 119*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SSTD_SET(x) ((x) << I2S_CGFR_I2SSTD_SHIFT) 120*e4e6ec7bSolivier moysan 121*e4e6ec7bSolivier moysan #define I2S_CGFR_PCMSYNC BIT(7) 122*e4e6ec7bSolivier moysan 123*e4e6ec7bSolivier moysan #define I2S_CGFR_DATLEN_SHIFT 8 124*e4e6ec7bSolivier moysan #define I2S_CGFR_DATLEN_MASK GENMASK(9, I2S_CGFR_DATLEN_SHIFT) 125*e4e6ec7bSolivier moysan #define I2S_CGFR_DATLEN_SET(x) ((x) << I2S_CGFR_DATLEN_SHIFT) 126*e4e6ec7bSolivier moysan 127*e4e6ec7bSolivier moysan #define I2S_CGFR_CHLEN_SHIFT 10 128*e4e6ec7bSolivier moysan #define I2S_CGFR_CHLEN BIT(I2S_CGFR_CHLEN_SHIFT) 129*e4e6ec7bSolivier moysan #define I2S_CGFR_CKPOL BIT(11) 130*e4e6ec7bSolivier moysan #define I2S_CGFR_FIXCH BIT(12) 131*e4e6ec7bSolivier moysan #define I2S_CGFR_WSINV BIT(13) 132*e4e6ec7bSolivier moysan #define I2S_CGFR_DATFMT BIT(14) 133*e4e6ec7bSolivier moysan 134*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SDIV_SHIFT 16 135*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SDIV_BIT_H 23 136*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SDIV_MASK GENMASK(I2S_CGFR_I2SDIV_BIT_H,\ 137*e4e6ec7bSolivier moysan I2S_CGFR_I2SDIV_SHIFT) 138*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SDIV_SET(x) ((x) << I2S_CGFR_I2SDIV_SHIFT) 139*e4e6ec7bSolivier moysan #define I2S_CGFR_I2SDIV_MAX ((1 << (I2S_CGFR_I2SDIV_BIT_H -\ 140*e4e6ec7bSolivier moysan I2S_CGFR_I2SDIV_SHIFT)) - 1) 141*e4e6ec7bSolivier moysan 142*e4e6ec7bSolivier moysan #define I2S_CGFR_ODD_SHIFT 24 143*e4e6ec7bSolivier moysan #define I2S_CGFR_ODD BIT(I2S_CGFR_ODD_SHIFT) 144*e4e6ec7bSolivier moysan #define I2S_CGFR_MCKOE BIT(25) 145*e4e6ec7bSolivier moysan 146*e4e6ec7bSolivier moysan enum i2s_master_mode { 147*e4e6ec7bSolivier moysan I2S_MS_NOT_SET, 148*e4e6ec7bSolivier moysan I2S_MS_MASTER, 149*e4e6ec7bSolivier moysan I2S_MS_SLAVE, 150*e4e6ec7bSolivier moysan }; 151*e4e6ec7bSolivier moysan 152*e4e6ec7bSolivier moysan enum i2s_mode { 153*e4e6ec7bSolivier moysan I2S_I2SMOD_TX_SLAVE, 154*e4e6ec7bSolivier moysan I2S_I2SMOD_RX_SLAVE, 155*e4e6ec7bSolivier moysan I2S_I2SMOD_TX_MASTER, 156*e4e6ec7bSolivier moysan I2S_I2SMOD_RX_MASTER, 157*e4e6ec7bSolivier moysan I2S_I2SMOD_FD_SLAVE, 158*e4e6ec7bSolivier moysan I2S_I2SMOD_FD_MASTER, 159*e4e6ec7bSolivier moysan }; 160*e4e6ec7bSolivier moysan 161*e4e6ec7bSolivier moysan enum i2s_fifo_th { 162*e4e6ec7bSolivier moysan I2S_FIFO_TH_NONE, 163*e4e6ec7bSolivier moysan I2S_FIFO_TH_ONE_QUARTER, 164*e4e6ec7bSolivier moysan I2S_FIFO_TH_HALF, 165*e4e6ec7bSolivier moysan I2S_FIFO_TH_THREE_QUARTER, 166*e4e6ec7bSolivier moysan I2S_FIFO_TH_FULL, 167*e4e6ec7bSolivier moysan }; 168*e4e6ec7bSolivier moysan 169*e4e6ec7bSolivier moysan enum i2s_std { 170*e4e6ec7bSolivier moysan I2S_STD_I2S, 171*e4e6ec7bSolivier moysan I2S_STD_LEFT_J, 172*e4e6ec7bSolivier moysan I2S_STD_RIGHT_J, 173*e4e6ec7bSolivier moysan I2S_STD_DSP, 174*e4e6ec7bSolivier moysan }; 175*e4e6ec7bSolivier moysan 176*e4e6ec7bSolivier moysan enum i2s_datlen { 177*e4e6ec7bSolivier moysan I2S_I2SMOD_DATLEN_16, 178*e4e6ec7bSolivier moysan I2S_I2SMOD_DATLEN_24, 179*e4e6ec7bSolivier moysan I2S_I2SMOD_DATLEN_32, 180*e4e6ec7bSolivier moysan }; 181*e4e6ec7bSolivier moysan 182*e4e6ec7bSolivier moysan #define STM32_I2S_DAI_NAME_SIZE 20 183*e4e6ec7bSolivier moysan #define STM32_I2S_FIFO_SIZE 16 184*e4e6ec7bSolivier moysan 185*e4e6ec7bSolivier moysan #define STM32_I2S_IS_MASTER(x) ((x)->ms_flg == I2S_MS_MASTER) 186*e4e6ec7bSolivier moysan #define STM32_I2S_IS_SLAVE(x) ((x)->ms_flg == I2S_MS_SLAVE) 187*e4e6ec7bSolivier moysan 188*e4e6ec7bSolivier moysan /** 189*e4e6ec7bSolivier moysan * @regmap_conf: I2S register map configuration pointer 190*e4e6ec7bSolivier moysan * @egmap: I2S register map pointer 191*e4e6ec7bSolivier moysan * @pdev: device data pointer 192*e4e6ec7bSolivier moysan * @dai_drv: DAI driver pointer 193*e4e6ec7bSolivier moysan * @dma_data_tx: dma configuration data for tx channel 194*e4e6ec7bSolivier moysan * @dma_data_rx: dma configuration data for tx channel 195*e4e6ec7bSolivier moysan * @substream: PCM substream data pointer 196*e4e6ec7bSolivier moysan * @i2sclk: kernel clock feeding the I2S clock generator 197*e4e6ec7bSolivier moysan * @pclk: peripheral clock driving bus interface 198*e4e6ec7bSolivier moysan * @x8kclk: I2S parent clock for sampling frequencies multiple of 8kHz 199*e4e6ec7bSolivier moysan * @x11kclk: I2S parent clock for sampling frequencies multiple of 11kHz 200*e4e6ec7bSolivier moysan * @base: mmio register base virtual address 201*e4e6ec7bSolivier moysan * @phys_addr: I2S registers physical base address 202*e4e6ec7bSolivier moysan * @lock_fd: lock to manage race conditions in full duplex mode 203*e4e6ec7bSolivier moysan * @dais_name: DAI name 204*e4e6ec7bSolivier moysan * @mclk_rate: master clock frequency (Hz) 205*e4e6ec7bSolivier moysan * @fmt: DAI protocol 206*e4e6ec7bSolivier moysan * @refcount: keep count of opened streams on I2S 207*e4e6ec7bSolivier moysan * @ms_flg: master mode flag. 208*e4e6ec7bSolivier moysan */ 209*e4e6ec7bSolivier moysan struct stm32_i2s_data { 210*e4e6ec7bSolivier moysan const struct regmap_config *regmap_conf; 211*e4e6ec7bSolivier moysan struct regmap *regmap; 212*e4e6ec7bSolivier moysan struct platform_device *pdev; 213*e4e6ec7bSolivier moysan struct snd_soc_dai_driver *dai_drv; 214*e4e6ec7bSolivier moysan struct snd_dmaengine_dai_dma_data dma_data_tx; 215*e4e6ec7bSolivier moysan struct snd_dmaengine_dai_dma_data dma_data_rx; 216*e4e6ec7bSolivier moysan struct snd_pcm_substream *substream; 217*e4e6ec7bSolivier moysan struct clk *i2sclk; 218*e4e6ec7bSolivier moysan struct clk *pclk; 219*e4e6ec7bSolivier moysan struct clk *x8kclk; 220*e4e6ec7bSolivier moysan struct clk *x11kclk; 221*e4e6ec7bSolivier moysan void __iomem *base; 222*e4e6ec7bSolivier moysan dma_addr_t phys_addr; 223*e4e6ec7bSolivier moysan spinlock_t lock_fd; /* Manage race conditions for full duplex */ 224*e4e6ec7bSolivier moysan char dais_name[STM32_I2S_DAI_NAME_SIZE]; 225*e4e6ec7bSolivier moysan unsigned int mclk_rate; 226*e4e6ec7bSolivier moysan unsigned int fmt; 227*e4e6ec7bSolivier moysan int refcount; 228*e4e6ec7bSolivier moysan int ms_flg; 229*e4e6ec7bSolivier moysan }; 230*e4e6ec7bSolivier moysan 231*e4e6ec7bSolivier moysan static irqreturn_t stm32_i2s_isr(int irq, void *devid) 232*e4e6ec7bSolivier moysan { 233*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = (struct stm32_i2s_data *)devid; 234*e4e6ec7bSolivier moysan struct platform_device *pdev = i2s->pdev; 235*e4e6ec7bSolivier moysan u32 sr, ier; 236*e4e6ec7bSolivier moysan unsigned long flags; 237*e4e6ec7bSolivier moysan int err = 0; 238*e4e6ec7bSolivier moysan 239*e4e6ec7bSolivier moysan regmap_read(i2s->regmap, STM32_I2S_SR_REG, &sr); 240*e4e6ec7bSolivier moysan regmap_read(i2s->regmap, STM32_I2S_IER_REG, &ier); 241*e4e6ec7bSolivier moysan 242*e4e6ec7bSolivier moysan flags = sr & ier; 243*e4e6ec7bSolivier moysan if (!flags) { 244*e4e6ec7bSolivier moysan dev_dbg(&pdev->dev, "Spurious IRQ sr=0x%08x, ier=0x%08x\n", 245*e4e6ec7bSolivier moysan sr, ier); 246*e4e6ec7bSolivier moysan return IRQ_NONE; 247*e4e6ec7bSolivier moysan } 248*e4e6ec7bSolivier moysan 249*e4e6ec7bSolivier moysan regmap_update_bits(i2s->regmap, STM32_I2S_IFCR_REG, 250*e4e6ec7bSolivier moysan I2S_IFCR_MASK, flags); 251*e4e6ec7bSolivier moysan 252*e4e6ec7bSolivier moysan if (flags & I2S_SR_OVR) { 253*e4e6ec7bSolivier moysan dev_dbg(&pdev->dev, "Overrun\n"); 254*e4e6ec7bSolivier moysan err = 1; 255*e4e6ec7bSolivier moysan } 256*e4e6ec7bSolivier moysan 257*e4e6ec7bSolivier moysan if (flags & I2S_SR_UDR) { 258*e4e6ec7bSolivier moysan dev_dbg(&pdev->dev, "Underrun\n"); 259*e4e6ec7bSolivier moysan err = 1; 260*e4e6ec7bSolivier moysan } 261*e4e6ec7bSolivier moysan 262*e4e6ec7bSolivier moysan if (flags & I2S_SR_TIFRE) 263*e4e6ec7bSolivier moysan dev_dbg(&pdev->dev, "Frame error\n"); 264*e4e6ec7bSolivier moysan 265*e4e6ec7bSolivier moysan if (err) 266*e4e6ec7bSolivier moysan snd_pcm_stop_xrun(i2s->substream); 267*e4e6ec7bSolivier moysan 268*e4e6ec7bSolivier moysan return IRQ_HANDLED; 269*e4e6ec7bSolivier moysan } 270*e4e6ec7bSolivier moysan 271*e4e6ec7bSolivier moysan static bool stm32_i2s_readable_reg(struct device *dev, unsigned int reg) 272*e4e6ec7bSolivier moysan { 273*e4e6ec7bSolivier moysan switch (reg) { 274*e4e6ec7bSolivier moysan case STM32_I2S_CR1_REG: 275*e4e6ec7bSolivier moysan case STM32_I2S_CFG1_REG: 276*e4e6ec7bSolivier moysan case STM32_I2S_CFG2_REG: 277*e4e6ec7bSolivier moysan case STM32_I2S_IER_REG: 278*e4e6ec7bSolivier moysan case STM32_I2S_SR_REG: 279*e4e6ec7bSolivier moysan case STM32_I2S_IFCR_REG: 280*e4e6ec7bSolivier moysan case STM32_I2S_TXDR_REG: 281*e4e6ec7bSolivier moysan case STM32_I2S_RXDR_REG: 282*e4e6ec7bSolivier moysan case STM32_I2S_CGFR_REG: 283*e4e6ec7bSolivier moysan return true; 284*e4e6ec7bSolivier moysan default: 285*e4e6ec7bSolivier moysan return false; 286*e4e6ec7bSolivier moysan } 287*e4e6ec7bSolivier moysan } 288*e4e6ec7bSolivier moysan 289*e4e6ec7bSolivier moysan static bool stm32_i2s_volatile_reg(struct device *dev, unsigned int reg) 290*e4e6ec7bSolivier moysan { 291*e4e6ec7bSolivier moysan switch (reg) { 292*e4e6ec7bSolivier moysan case STM32_I2S_TXDR_REG: 293*e4e6ec7bSolivier moysan case STM32_I2S_RXDR_REG: 294*e4e6ec7bSolivier moysan return true; 295*e4e6ec7bSolivier moysan default: 296*e4e6ec7bSolivier moysan return false; 297*e4e6ec7bSolivier moysan } 298*e4e6ec7bSolivier moysan } 299*e4e6ec7bSolivier moysan 300*e4e6ec7bSolivier moysan static bool stm32_i2s_writeable_reg(struct device *dev, unsigned int reg) 301*e4e6ec7bSolivier moysan { 302*e4e6ec7bSolivier moysan switch (reg) { 303*e4e6ec7bSolivier moysan case STM32_I2S_CR1_REG: 304*e4e6ec7bSolivier moysan case STM32_I2S_CFG1_REG: 305*e4e6ec7bSolivier moysan case STM32_I2S_CFG2_REG: 306*e4e6ec7bSolivier moysan case STM32_I2S_IER_REG: 307*e4e6ec7bSolivier moysan case STM32_I2S_IFCR_REG: 308*e4e6ec7bSolivier moysan case STM32_I2S_TXDR_REG: 309*e4e6ec7bSolivier moysan case STM32_I2S_CGFR_REG: 310*e4e6ec7bSolivier moysan return true; 311*e4e6ec7bSolivier moysan default: 312*e4e6ec7bSolivier moysan return false; 313*e4e6ec7bSolivier moysan } 314*e4e6ec7bSolivier moysan } 315*e4e6ec7bSolivier moysan 316*e4e6ec7bSolivier moysan static int stm32_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) 317*e4e6ec7bSolivier moysan { 318*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = snd_soc_dai_get_drvdata(cpu_dai); 319*e4e6ec7bSolivier moysan u32 cgfr; 320*e4e6ec7bSolivier moysan u32 cgfr_mask = I2S_CGFR_I2SSTD_MASK | I2S_CGFR_CKPOL | 321*e4e6ec7bSolivier moysan I2S_CGFR_WSINV | I2S_CGFR_I2SCFG_MASK; 322*e4e6ec7bSolivier moysan 323*e4e6ec7bSolivier moysan dev_dbg(cpu_dai->dev, "fmt %x\n", fmt); 324*e4e6ec7bSolivier moysan 325*e4e6ec7bSolivier moysan /* 326*e4e6ec7bSolivier moysan * winv = 0 : default behavior (high/low) for all standards 327*e4e6ec7bSolivier moysan * ckpol = 0 for all standards. 328*e4e6ec7bSolivier moysan */ 329*e4e6ec7bSolivier moysan switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 330*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_I2S: 331*e4e6ec7bSolivier moysan cgfr = I2S_CGFR_I2SSTD_SET(I2S_STD_I2S); 332*e4e6ec7bSolivier moysan break; 333*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_MSB: 334*e4e6ec7bSolivier moysan cgfr = I2S_CGFR_I2SSTD_SET(I2S_STD_LEFT_J); 335*e4e6ec7bSolivier moysan break; 336*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_LSB: 337*e4e6ec7bSolivier moysan cgfr = I2S_CGFR_I2SSTD_SET(I2S_STD_RIGHT_J); 338*e4e6ec7bSolivier moysan break; 339*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_DSP_A: 340*e4e6ec7bSolivier moysan cgfr = I2S_CGFR_I2SSTD_SET(I2S_STD_DSP); 341*e4e6ec7bSolivier moysan break; 342*e4e6ec7bSolivier moysan /* DSP_B not mapped on I2S PCM long format. 1 bit offset does not fit */ 343*e4e6ec7bSolivier moysan default: 344*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Unsupported protocol %#x\n", 345*e4e6ec7bSolivier moysan fmt & SND_SOC_DAIFMT_FORMAT_MASK); 346*e4e6ec7bSolivier moysan return -EINVAL; 347*e4e6ec7bSolivier moysan } 348*e4e6ec7bSolivier moysan 349*e4e6ec7bSolivier moysan /* DAI clock strobing */ 350*e4e6ec7bSolivier moysan switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 351*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_NB_NF: 352*e4e6ec7bSolivier moysan break; 353*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_IB_NF: 354*e4e6ec7bSolivier moysan cgfr |= I2S_CGFR_CKPOL; 355*e4e6ec7bSolivier moysan break; 356*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_NB_IF: 357*e4e6ec7bSolivier moysan cgfr |= I2S_CGFR_WSINV; 358*e4e6ec7bSolivier moysan break; 359*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_IB_IF: 360*e4e6ec7bSolivier moysan cgfr |= I2S_CGFR_CKPOL; 361*e4e6ec7bSolivier moysan cgfr |= I2S_CGFR_WSINV; 362*e4e6ec7bSolivier moysan break; 363*e4e6ec7bSolivier moysan default: 364*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Unsupported strobing %#x\n", 365*e4e6ec7bSolivier moysan fmt & SND_SOC_DAIFMT_INV_MASK); 366*e4e6ec7bSolivier moysan return -EINVAL; 367*e4e6ec7bSolivier moysan } 368*e4e6ec7bSolivier moysan 369*e4e6ec7bSolivier moysan /* DAI clock master masks */ 370*e4e6ec7bSolivier moysan switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 371*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_CBM_CFM: 372*e4e6ec7bSolivier moysan i2s->ms_flg = I2S_MS_SLAVE; 373*e4e6ec7bSolivier moysan break; 374*e4e6ec7bSolivier moysan case SND_SOC_DAIFMT_CBS_CFS: 375*e4e6ec7bSolivier moysan i2s->ms_flg = I2S_MS_MASTER; 376*e4e6ec7bSolivier moysan break; 377*e4e6ec7bSolivier moysan default: 378*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Unsupported mode %#x\n", 379*e4e6ec7bSolivier moysan fmt & SND_SOC_DAIFMT_MASTER_MASK); 380*e4e6ec7bSolivier moysan return -EINVAL; 381*e4e6ec7bSolivier moysan } 382*e4e6ec7bSolivier moysan 383*e4e6ec7bSolivier moysan i2s->fmt = fmt; 384*e4e6ec7bSolivier moysan return regmap_update_bits(i2s->regmap, STM32_I2S_CGFR_REG, 385*e4e6ec7bSolivier moysan cgfr_mask, cgfr); 386*e4e6ec7bSolivier moysan } 387*e4e6ec7bSolivier moysan 388*e4e6ec7bSolivier moysan static int stm32_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, 389*e4e6ec7bSolivier moysan int clk_id, unsigned int freq, int dir) 390*e4e6ec7bSolivier moysan { 391*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = snd_soc_dai_get_drvdata(cpu_dai); 392*e4e6ec7bSolivier moysan 393*e4e6ec7bSolivier moysan dev_dbg(cpu_dai->dev, "I2S MCLK frequency is %uHz\n", freq); 394*e4e6ec7bSolivier moysan 395*e4e6ec7bSolivier moysan if ((dir == SND_SOC_CLOCK_OUT) && STM32_I2S_IS_MASTER(i2s)) { 396*e4e6ec7bSolivier moysan i2s->mclk_rate = freq; 397*e4e6ec7bSolivier moysan 398*e4e6ec7bSolivier moysan /* Enable master clock if master mode and mclk-fs are set */ 399*e4e6ec7bSolivier moysan return regmap_update_bits(i2s->regmap, STM32_I2S_CGFR_REG, 400*e4e6ec7bSolivier moysan I2S_CGFR_MCKOE, I2S_CGFR_MCKOE); 401*e4e6ec7bSolivier moysan } 402*e4e6ec7bSolivier moysan 403*e4e6ec7bSolivier moysan return 0; 404*e4e6ec7bSolivier moysan } 405*e4e6ec7bSolivier moysan 406*e4e6ec7bSolivier moysan static int stm32_i2s_configure_clock(struct snd_soc_dai *cpu_dai, 407*e4e6ec7bSolivier moysan struct snd_pcm_hw_params *params) 408*e4e6ec7bSolivier moysan { 409*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = snd_soc_dai_get_drvdata(cpu_dai); 410*e4e6ec7bSolivier moysan unsigned long i2s_clock_rate; 411*e4e6ec7bSolivier moysan unsigned int tmp, div, real_div, nb_bits, frame_len; 412*e4e6ec7bSolivier moysan unsigned int rate = params_rate(params); 413*e4e6ec7bSolivier moysan int ret; 414*e4e6ec7bSolivier moysan u32 cgfr, cgfr_mask; 415*e4e6ec7bSolivier moysan bool odd; 416*e4e6ec7bSolivier moysan 417*e4e6ec7bSolivier moysan if (!(rate % 11025)) 418*e4e6ec7bSolivier moysan clk_set_parent(i2s->i2sclk, i2s->x11kclk); 419*e4e6ec7bSolivier moysan else 420*e4e6ec7bSolivier moysan clk_set_parent(i2s->i2sclk, i2s->x8kclk); 421*e4e6ec7bSolivier moysan i2s_clock_rate = clk_get_rate(i2s->i2sclk); 422*e4e6ec7bSolivier moysan 423*e4e6ec7bSolivier moysan /* 424*e4e6ec7bSolivier moysan * mckl = mclk_ratio x ws 425*e4e6ec7bSolivier moysan * i2s mode : mclk_ratio = 256 426*e4e6ec7bSolivier moysan * dsp mode : mclk_ratio = 128 427*e4e6ec7bSolivier moysan * 428*e4e6ec7bSolivier moysan * mclk on 429*e4e6ec7bSolivier moysan * i2s mode : div = i2s_clk / (mclk_ratio * ws) 430*e4e6ec7bSolivier moysan * dsp mode : div = i2s_clk / (mclk_ratio * ws) 431*e4e6ec7bSolivier moysan * mclk off 432*e4e6ec7bSolivier moysan * i2s mode : div = i2s_clk / (nb_bits x ws) 433*e4e6ec7bSolivier moysan * dsp mode : div = i2s_clk / (nb_bits x ws) 434*e4e6ec7bSolivier moysan */ 435*e4e6ec7bSolivier moysan if (i2s->mclk_rate) { 436*e4e6ec7bSolivier moysan tmp = DIV_ROUND_CLOSEST(i2s_clock_rate, i2s->mclk_rate); 437*e4e6ec7bSolivier moysan } else { 438*e4e6ec7bSolivier moysan frame_len = 32; 439*e4e6ec7bSolivier moysan if ((i2s->fmt & SND_SOC_DAIFMT_FORMAT_MASK) == 440*e4e6ec7bSolivier moysan SND_SOC_DAIFMT_DSP_A) 441*e4e6ec7bSolivier moysan frame_len = 16; 442*e4e6ec7bSolivier moysan 443*e4e6ec7bSolivier moysan /* master clock not enabled */ 444*e4e6ec7bSolivier moysan ret = regmap_read(i2s->regmap, STM32_I2S_CGFR_REG, &cgfr); 445*e4e6ec7bSolivier moysan if (ret < 0) 446*e4e6ec7bSolivier moysan return ret; 447*e4e6ec7bSolivier moysan 448*e4e6ec7bSolivier moysan nb_bits = frame_len * ((cgfr & I2S_CGFR_CHLEN) + 1); 449*e4e6ec7bSolivier moysan tmp = DIV_ROUND_CLOSEST(i2s_clock_rate, (nb_bits * rate)); 450*e4e6ec7bSolivier moysan } 451*e4e6ec7bSolivier moysan 452*e4e6ec7bSolivier moysan /* Check the parity of the divider */ 453*e4e6ec7bSolivier moysan odd = tmp & 0x1; 454*e4e6ec7bSolivier moysan 455*e4e6ec7bSolivier moysan /* Compute the div prescaler */ 456*e4e6ec7bSolivier moysan div = tmp >> 1; 457*e4e6ec7bSolivier moysan 458*e4e6ec7bSolivier moysan cgfr = I2S_CGFR_I2SDIV_SET(div) | (odd << I2S_CGFR_ODD_SHIFT); 459*e4e6ec7bSolivier moysan cgfr_mask = I2S_CGFR_I2SDIV_MASK | I2S_CGFR_ODD; 460*e4e6ec7bSolivier moysan 461*e4e6ec7bSolivier moysan real_div = ((2 * div) + odd); 462*e4e6ec7bSolivier moysan dev_dbg(cpu_dai->dev, "I2S clk: %ld, SCLK: %d\n", 463*e4e6ec7bSolivier moysan i2s_clock_rate, rate); 464*e4e6ec7bSolivier moysan dev_dbg(cpu_dai->dev, "Divider: 2*%d(div)+%d(odd) = %d\n", 465*e4e6ec7bSolivier moysan div, odd, real_div); 466*e4e6ec7bSolivier moysan 467*e4e6ec7bSolivier moysan if (((div == 1) && odd) || (div > I2S_CGFR_I2SDIV_MAX)) { 468*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Wrong divider setting\n"); 469*e4e6ec7bSolivier moysan return -EINVAL; 470*e4e6ec7bSolivier moysan } 471*e4e6ec7bSolivier moysan 472*e4e6ec7bSolivier moysan if (!div && !odd) 473*e4e6ec7bSolivier moysan dev_warn(cpu_dai->dev, "real divider forced to 1\n"); 474*e4e6ec7bSolivier moysan 475*e4e6ec7bSolivier moysan ret = regmap_update_bits(i2s->regmap, STM32_I2S_CGFR_REG, 476*e4e6ec7bSolivier moysan cgfr_mask, cgfr); 477*e4e6ec7bSolivier moysan if (ret < 0) 478*e4e6ec7bSolivier moysan return ret; 479*e4e6ec7bSolivier moysan 480*e4e6ec7bSolivier moysan /* Set bitclock and frameclock to their inactive state */ 481*e4e6ec7bSolivier moysan return regmap_update_bits(i2s->regmap, STM32_I2S_CFG2_REG, 482*e4e6ec7bSolivier moysan I2S_CFG2_AFCNTR, I2S_CFG2_AFCNTR); 483*e4e6ec7bSolivier moysan } 484*e4e6ec7bSolivier moysan 485*e4e6ec7bSolivier moysan static int stm32_i2s_configure(struct snd_soc_dai *cpu_dai, 486*e4e6ec7bSolivier moysan struct snd_pcm_hw_params *params, 487*e4e6ec7bSolivier moysan struct snd_pcm_substream *substream) 488*e4e6ec7bSolivier moysan { 489*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = snd_soc_dai_get_drvdata(cpu_dai); 490*e4e6ec7bSolivier moysan int format = params_width(params); 491*e4e6ec7bSolivier moysan u32 cfgr, cfgr_mask, cfg1, cfg1_mask; 492*e4e6ec7bSolivier moysan bool playback_flg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); 493*e4e6ec7bSolivier moysan unsigned int fthlv; 494*e4e6ec7bSolivier moysan int ret; 495*e4e6ec7bSolivier moysan 496*e4e6ec7bSolivier moysan if ((params_channels(params) == 1) && 497*e4e6ec7bSolivier moysan ((i2s->fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_DSP_A)) { 498*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Mono mode supported only by DSP_A\n"); 499*e4e6ec7bSolivier moysan return -EINVAL; 500*e4e6ec7bSolivier moysan } 501*e4e6ec7bSolivier moysan 502*e4e6ec7bSolivier moysan switch (format) { 503*e4e6ec7bSolivier moysan case 16: 504*e4e6ec7bSolivier moysan cfgr = I2S_CGFR_DATLEN_SET(I2S_I2SMOD_DATLEN_16); 505*e4e6ec7bSolivier moysan cfgr_mask = I2S_CGFR_DATLEN_MASK; 506*e4e6ec7bSolivier moysan break; 507*e4e6ec7bSolivier moysan case 32: 508*e4e6ec7bSolivier moysan cfgr = I2S_CGFR_DATLEN_SET(I2S_I2SMOD_DATLEN_32) | 509*e4e6ec7bSolivier moysan I2S_CGFR_CHLEN; 510*e4e6ec7bSolivier moysan cfgr_mask = I2S_CGFR_DATLEN_MASK | I2S_CGFR_CHLEN; 511*e4e6ec7bSolivier moysan break; 512*e4e6ec7bSolivier moysan default: 513*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Unexpected format %d", format); 514*e4e6ec7bSolivier moysan return -EINVAL; 515*e4e6ec7bSolivier moysan } 516*e4e6ec7bSolivier moysan 517*e4e6ec7bSolivier moysan if (STM32_I2S_IS_SLAVE(i2s)) { 518*e4e6ec7bSolivier moysan if (playback_flg) 519*e4e6ec7bSolivier moysan cfgr |= I2S_CGFR_I2SCFG_SET(I2S_I2SMOD_TX_SLAVE); 520*e4e6ec7bSolivier moysan else 521*e4e6ec7bSolivier moysan cfgr |= I2S_CGFR_I2SCFG_SET(I2S_I2SMOD_RX_SLAVE); 522*e4e6ec7bSolivier moysan 523*e4e6ec7bSolivier moysan /* As data length is either 16 or 32 bits, fixch always set */ 524*e4e6ec7bSolivier moysan cfgr |= I2S_CGFR_FIXCH; 525*e4e6ec7bSolivier moysan cfgr_mask |= I2S_CGFR_FIXCH; 526*e4e6ec7bSolivier moysan } else { 527*e4e6ec7bSolivier moysan if (playback_flg) 528*e4e6ec7bSolivier moysan cfgr |= I2S_CGFR_I2SCFG_SET(I2S_I2SMOD_TX_MASTER); 529*e4e6ec7bSolivier moysan else 530*e4e6ec7bSolivier moysan cfgr |= I2S_CGFR_I2SCFG_SET(I2S_I2SMOD_RX_MASTER); 531*e4e6ec7bSolivier moysan } 532*e4e6ec7bSolivier moysan cfgr_mask |= I2S_CGFR_I2SCFG_MASK; 533*e4e6ec7bSolivier moysan 534*e4e6ec7bSolivier moysan ret = regmap_update_bits(i2s->regmap, STM32_I2S_CGFR_REG, 535*e4e6ec7bSolivier moysan cfgr_mask, cfgr); 536*e4e6ec7bSolivier moysan if (ret < 0) 537*e4e6ec7bSolivier moysan return ret; 538*e4e6ec7bSolivier moysan 539*e4e6ec7bSolivier moysan cfg1 = I2S_CFG1_RXDMAEN; 540*e4e6ec7bSolivier moysan if (playback_flg) 541*e4e6ec7bSolivier moysan cfg1 = I2S_CFG1_TXDMAEN; 542*e4e6ec7bSolivier moysan cfg1_mask = cfg1; 543*e4e6ec7bSolivier moysan 544*e4e6ec7bSolivier moysan fthlv = STM32_I2S_FIFO_SIZE * I2S_FIFO_TH_ONE_QUARTER / 4; 545*e4e6ec7bSolivier moysan cfg1 |= I2S_CFG1_FTHVL_SET(fthlv - 1); 546*e4e6ec7bSolivier moysan cfg1_mask |= I2S_CFG1_FTHVL_MASK; 547*e4e6ec7bSolivier moysan 548*e4e6ec7bSolivier moysan return regmap_update_bits(i2s->regmap, STM32_I2S_CFG1_REG, 549*e4e6ec7bSolivier moysan cfg1_mask, cfg1); 550*e4e6ec7bSolivier moysan } 551*e4e6ec7bSolivier moysan 552*e4e6ec7bSolivier moysan static int stm32_i2s_startup(struct snd_pcm_substream *substream, 553*e4e6ec7bSolivier moysan struct snd_soc_dai *cpu_dai) 554*e4e6ec7bSolivier moysan { 555*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = snd_soc_dai_get_drvdata(cpu_dai); 556*e4e6ec7bSolivier moysan int ret, ier; 557*e4e6ec7bSolivier moysan 558*e4e6ec7bSolivier moysan i2s->substream = substream; 559*e4e6ec7bSolivier moysan 560*e4e6ec7bSolivier moysan spin_lock(&i2s->lock_fd); 561*e4e6ec7bSolivier moysan if (i2s->refcount) { 562*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "%s stream already started\n", 563*e4e6ec7bSolivier moysan (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 564*e4e6ec7bSolivier moysan "Capture" : "Playback")); 565*e4e6ec7bSolivier moysan spin_unlock(&i2s->lock_fd); 566*e4e6ec7bSolivier moysan return -EBUSY; 567*e4e6ec7bSolivier moysan } 568*e4e6ec7bSolivier moysan i2s->refcount = 1; 569*e4e6ec7bSolivier moysan spin_unlock(&i2s->lock_fd); 570*e4e6ec7bSolivier moysan 571*e4e6ec7bSolivier moysan ret = regmap_update_bits(i2s->regmap, STM32_I2S_IFCR_REG, 572*e4e6ec7bSolivier moysan I2S_IFCR_MASK, I2S_IFCR_MASK); 573*e4e6ec7bSolivier moysan if (ret < 0) 574*e4e6ec7bSolivier moysan return ret; 575*e4e6ec7bSolivier moysan 576*e4e6ec7bSolivier moysan /* Enable ITs */ 577*e4e6ec7bSolivier moysan ier = I2S_IER_OVRIE | I2S_IER_UDRIE; 578*e4e6ec7bSolivier moysan if (STM32_I2S_IS_SLAVE(i2s)) 579*e4e6ec7bSolivier moysan ier |= I2S_IER_TIFREIE; 580*e4e6ec7bSolivier moysan 581*e4e6ec7bSolivier moysan return regmap_update_bits(i2s->regmap, STM32_I2S_IER_REG, ier, ier); 582*e4e6ec7bSolivier moysan } 583*e4e6ec7bSolivier moysan 584*e4e6ec7bSolivier moysan static int stm32_i2s_hw_params(struct snd_pcm_substream *substream, 585*e4e6ec7bSolivier moysan struct snd_pcm_hw_params *params, 586*e4e6ec7bSolivier moysan struct snd_soc_dai *cpu_dai) 587*e4e6ec7bSolivier moysan { 588*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = snd_soc_dai_get_drvdata(cpu_dai); 589*e4e6ec7bSolivier moysan int ret; 590*e4e6ec7bSolivier moysan 591*e4e6ec7bSolivier moysan ret = stm32_i2s_configure(cpu_dai, params, substream); 592*e4e6ec7bSolivier moysan if (ret < 0) { 593*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Configuration returned error %d\n", ret); 594*e4e6ec7bSolivier moysan return ret; 595*e4e6ec7bSolivier moysan } 596*e4e6ec7bSolivier moysan 597*e4e6ec7bSolivier moysan if (STM32_I2S_IS_MASTER(i2s)) 598*e4e6ec7bSolivier moysan ret = stm32_i2s_configure_clock(cpu_dai, params); 599*e4e6ec7bSolivier moysan 600*e4e6ec7bSolivier moysan return ret; 601*e4e6ec7bSolivier moysan } 602*e4e6ec7bSolivier moysan 603*e4e6ec7bSolivier moysan static int stm32_i2s_trigger(struct snd_pcm_substream *substream, int cmd, 604*e4e6ec7bSolivier moysan struct snd_soc_dai *cpu_dai) 605*e4e6ec7bSolivier moysan { 606*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = snd_soc_dai_get_drvdata(cpu_dai); 607*e4e6ec7bSolivier moysan bool playback_flg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); 608*e4e6ec7bSolivier moysan u32 cfg1_mask; 609*e4e6ec7bSolivier moysan int ret; 610*e4e6ec7bSolivier moysan 611*e4e6ec7bSolivier moysan switch (cmd) { 612*e4e6ec7bSolivier moysan case SNDRV_PCM_TRIGGER_START: 613*e4e6ec7bSolivier moysan case SNDRV_PCM_TRIGGER_RESUME: 614*e4e6ec7bSolivier moysan case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 615*e4e6ec7bSolivier moysan /* Enable i2s */ 616*e4e6ec7bSolivier moysan dev_dbg(cpu_dai->dev, "start I2S\n"); 617*e4e6ec7bSolivier moysan 618*e4e6ec7bSolivier moysan ret = regmap_update_bits(i2s->regmap, STM32_I2S_CR1_REG, 619*e4e6ec7bSolivier moysan I2S_CR1_SPE, I2S_CR1_SPE); 620*e4e6ec7bSolivier moysan if (ret < 0) { 621*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Error %d enabling I2S\n", ret); 622*e4e6ec7bSolivier moysan return ret; 623*e4e6ec7bSolivier moysan } 624*e4e6ec7bSolivier moysan 625*e4e6ec7bSolivier moysan ret = regmap_update_bits(i2s->regmap, STM32_I2S_CR1_REG, 626*e4e6ec7bSolivier moysan I2S_CR1_CSTART, I2S_CR1_CSTART); 627*e4e6ec7bSolivier moysan if (ret < 0) { 628*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Error %d starting I2S\n", ret); 629*e4e6ec7bSolivier moysan return ret; 630*e4e6ec7bSolivier moysan } 631*e4e6ec7bSolivier moysan break; 632*e4e6ec7bSolivier moysan case SNDRV_PCM_TRIGGER_STOP: 633*e4e6ec7bSolivier moysan case SNDRV_PCM_TRIGGER_SUSPEND: 634*e4e6ec7bSolivier moysan case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 635*e4e6ec7bSolivier moysan dev_dbg(cpu_dai->dev, "stop I2S\n"); 636*e4e6ec7bSolivier moysan 637*e4e6ec7bSolivier moysan ret = regmap_update_bits(i2s->regmap, STM32_I2S_CR1_REG, 638*e4e6ec7bSolivier moysan I2S_CR1_SPE, 0); 639*e4e6ec7bSolivier moysan if (ret < 0) { 640*e4e6ec7bSolivier moysan dev_err(cpu_dai->dev, "Error %d disabling I2S\n", ret); 641*e4e6ec7bSolivier moysan return ret; 642*e4e6ec7bSolivier moysan } 643*e4e6ec7bSolivier moysan 644*e4e6ec7bSolivier moysan cfg1_mask = I2S_CFG1_RXDMAEN; 645*e4e6ec7bSolivier moysan if (playback_flg) 646*e4e6ec7bSolivier moysan cfg1_mask = I2S_CFG1_TXDMAEN; 647*e4e6ec7bSolivier moysan 648*e4e6ec7bSolivier moysan regmap_update_bits(i2s->regmap, STM32_I2S_CFG1_REG, 649*e4e6ec7bSolivier moysan cfg1_mask, 0); 650*e4e6ec7bSolivier moysan break; 651*e4e6ec7bSolivier moysan default: 652*e4e6ec7bSolivier moysan return -EINVAL; 653*e4e6ec7bSolivier moysan } 654*e4e6ec7bSolivier moysan 655*e4e6ec7bSolivier moysan return 0; 656*e4e6ec7bSolivier moysan } 657*e4e6ec7bSolivier moysan 658*e4e6ec7bSolivier moysan static void stm32_i2s_shutdown(struct snd_pcm_substream *substream, 659*e4e6ec7bSolivier moysan struct snd_soc_dai *cpu_dai) 660*e4e6ec7bSolivier moysan { 661*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = snd_soc_dai_get_drvdata(cpu_dai); 662*e4e6ec7bSolivier moysan 663*e4e6ec7bSolivier moysan i2s->substream = NULL; 664*e4e6ec7bSolivier moysan 665*e4e6ec7bSolivier moysan spin_lock(&i2s->lock_fd); 666*e4e6ec7bSolivier moysan i2s->refcount = 0; 667*e4e6ec7bSolivier moysan spin_unlock(&i2s->lock_fd); 668*e4e6ec7bSolivier moysan 669*e4e6ec7bSolivier moysan regmap_update_bits(i2s->regmap, STM32_I2S_CGFR_REG, 670*e4e6ec7bSolivier moysan I2S_CGFR_MCKOE, (unsigned int)~I2S_CGFR_MCKOE); 671*e4e6ec7bSolivier moysan } 672*e4e6ec7bSolivier moysan 673*e4e6ec7bSolivier moysan static int stm32_i2s_dai_probe(struct snd_soc_dai *cpu_dai) 674*e4e6ec7bSolivier moysan { 675*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = dev_get_drvdata(cpu_dai->dev); 676*e4e6ec7bSolivier moysan struct snd_dmaengine_dai_dma_data *dma_data_tx = &i2s->dma_data_tx; 677*e4e6ec7bSolivier moysan struct snd_dmaengine_dai_dma_data *dma_data_rx = &i2s->dma_data_rx; 678*e4e6ec7bSolivier moysan 679*e4e6ec7bSolivier moysan /* Buswidth will be set by framework */ 680*e4e6ec7bSolivier moysan dma_data_tx->addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED; 681*e4e6ec7bSolivier moysan dma_data_tx->addr = (dma_addr_t)(i2s->phys_addr) + STM32_I2S_TXDR_REG; 682*e4e6ec7bSolivier moysan dma_data_tx->maxburst = 1; 683*e4e6ec7bSolivier moysan dma_data_rx->addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED; 684*e4e6ec7bSolivier moysan dma_data_rx->addr = (dma_addr_t)(i2s->phys_addr) + STM32_I2S_RXDR_REG; 685*e4e6ec7bSolivier moysan dma_data_rx->maxburst = 1; 686*e4e6ec7bSolivier moysan 687*e4e6ec7bSolivier moysan snd_soc_dai_init_dma_data(cpu_dai, dma_data_tx, dma_data_rx); 688*e4e6ec7bSolivier moysan 689*e4e6ec7bSolivier moysan return 0; 690*e4e6ec7bSolivier moysan } 691*e4e6ec7bSolivier moysan 692*e4e6ec7bSolivier moysan static const struct regmap_config stm32_h7_i2s_regmap_conf = { 693*e4e6ec7bSolivier moysan .reg_bits = 32, 694*e4e6ec7bSolivier moysan .reg_stride = 4, 695*e4e6ec7bSolivier moysan .val_bits = 32, 696*e4e6ec7bSolivier moysan .max_register = STM32_I2S_CGFR_REG, 697*e4e6ec7bSolivier moysan .readable_reg = stm32_i2s_readable_reg, 698*e4e6ec7bSolivier moysan .volatile_reg = stm32_i2s_volatile_reg, 699*e4e6ec7bSolivier moysan .writeable_reg = stm32_i2s_writeable_reg, 700*e4e6ec7bSolivier moysan .fast_io = true, 701*e4e6ec7bSolivier moysan }; 702*e4e6ec7bSolivier moysan 703*e4e6ec7bSolivier moysan static const struct snd_soc_dai_ops stm32_i2s_pcm_dai_ops = { 704*e4e6ec7bSolivier moysan .set_sysclk = stm32_i2s_set_sysclk, 705*e4e6ec7bSolivier moysan .set_fmt = stm32_i2s_set_dai_fmt, 706*e4e6ec7bSolivier moysan .startup = stm32_i2s_startup, 707*e4e6ec7bSolivier moysan .hw_params = stm32_i2s_hw_params, 708*e4e6ec7bSolivier moysan .trigger = stm32_i2s_trigger, 709*e4e6ec7bSolivier moysan .shutdown = stm32_i2s_shutdown, 710*e4e6ec7bSolivier moysan }; 711*e4e6ec7bSolivier moysan 712*e4e6ec7bSolivier moysan static const struct snd_pcm_hardware stm32_i2s_pcm_hw = { 713*e4e6ec7bSolivier moysan .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP, 714*e4e6ec7bSolivier moysan .buffer_bytes_max = 8 * PAGE_SIZE, 715*e4e6ec7bSolivier moysan .period_bytes_max = 2048, 716*e4e6ec7bSolivier moysan .periods_min = 2, 717*e4e6ec7bSolivier moysan .periods_max = 8, 718*e4e6ec7bSolivier moysan }; 719*e4e6ec7bSolivier moysan 720*e4e6ec7bSolivier moysan static const struct snd_dmaengine_pcm_config stm32_i2s_pcm_config = { 721*e4e6ec7bSolivier moysan .pcm_hardware = &stm32_i2s_pcm_hw, 722*e4e6ec7bSolivier moysan .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, 723*e4e6ec7bSolivier moysan .prealloc_buffer_size = PAGE_SIZE * 8, 724*e4e6ec7bSolivier moysan }; 725*e4e6ec7bSolivier moysan 726*e4e6ec7bSolivier moysan static const struct snd_soc_component_driver stm32_i2s_component = { 727*e4e6ec7bSolivier moysan .name = "stm32-i2s", 728*e4e6ec7bSolivier moysan }; 729*e4e6ec7bSolivier moysan 730*e4e6ec7bSolivier moysan static void stm32_i2s_dai_init(struct snd_soc_pcm_stream *stream, 731*e4e6ec7bSolivier moysan char *stream_name) 732*e4e6ec7bSolivier moysan { 733*e4e6ec7bSolivier moysan stream->stream_name = stream_name; 734*e4e6ec7bSolivier moysan stream->channels_min = 1; 735*e4e6ec7bSolivier moysan stream->channels_max = 2; 736*e4e6ec7bSolivier moysan stream->rates = SNDRV_PCM_RATE_8000_192000; 737*e4e6ec7bSolivier moysan stream->formats = SNDRV_PCM_FMTBIT_S16_LE | 738*e4e6ec7bSolivier moysan SNDRV_PCM_FMTBIT_S32_LE; 739*e4e6ec7bSolivier moysan } 740*e4e6ec7bSolivier moysan 741*e4e6ec7bSolivier moysan static int stm32_i2s_dais_init(struct platform_device *pdev, 742*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s) 743*e4e6ec7bSolivier moysan { 744*e4e6ec7bSolivier moysan struct snd_soc_dai_driver *dai_ptr; 745*e4e6ec7bSolivier moysan 746*e4e6ec7bSolivier moysan dai_ptr = devm_kzalloc(&pdev->dev, sizeof(struct snd_soc_dai_driver), 747*e4e6ec7bSolivier moysan GFP_KERNEL); 748*e4e6ec7bSolivier moysan if (!dai_ptr) 749*e4e6ec7bSolivier moysan return -ENOMEM; 750*e4e6ec7bSolivier moysan 751*e4e6ec7bSolivier moysan snprintf(i2s->dais_name, STM32_I2S_DAI_NAME_SIZE, 752*e4e6ec7bSolivier moysan "%s", dev_name(&pdev->dev)); 753*e4e6ec7bSolivier moysan 754*e4e6ec7bSolivier moysan dai_ptr->probe = stm32_i2s_dai_probe; 755*e4e6ec7bSolivier moysan dai_ptr->ops = &stm32_i2s_pcm_dai_ops; 756*e4e6ec7bSolivier moysan dai_ptr->name = i2s->dais_name; 757*e4e6ec7bSolivier moysan dai_ptr->id = 1; 758*e4e6ec7bSolivier moysan stm32_i2s_dai_init(&dai_ptr->playback, "playback"); 759*e4e6ec7bSolivier moysan stm32_i2s_dai_init(&dai_ptr->capture, "capture"); 760*e4e6ec7bSolivier moysan i2s->dai_drv = dai_ptr; 761*e4e6ec7bSolivier moysan 762*e4e6ec7bSolivier moysan return 0; 763*e4e6ec7bSolivier moysan } 764*e4e6ec7bSolivier moysan 765*e4e6ec7bSolivier moysan static const struct of_device_id stm32_i2s_ids[] = { 766*e4e6ec7bSolivier moysan { 767*e4e6ec7bSolivier moysan .compatible = "st,stm32h7-i2s", 768*e4e6ec7bSolivier moysan .data = &stm32_h7_i2s_regmap_conf 769*e4e6ec7bSolivier moysan }, 770*e4e6ec7bSolivier moysan {}, 771*e4e6ec7bSolivier moysan }; 772*e4e6ec7bSolivier moysan 773*e4e6ec7bSolivier moysan static int stm32_i2s_parse_dt(struct platform_device *pdev, 774*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s) 775*e4e6ec7bSolivier moysan { 776*e4e6ec7bSolivier moysan struct device_node *np = pdev->dev.of_node; 777*e4e6ec7bSolivier moysan const struct of_device_id *of_id; 778*e4e6ec7bSolivier moysan struct reset_control *rst; 779*e4e6ec7bSolivier moysan struct resource *res; 780*e4e6ec7bSolivier moysan int irq, ret; 781*e4e6ec7bSolivier moysan 782*e4e6ec7bSolivier moysan if (!np) 783*e4e6ec7bSolivier moysan return -ENODEV; 784*e4e6ec7bSolivier moysan 785*e4e6ec7bSolivier moysan of_id = of_match_device(stm32_i2s_ids, &pdev->dev); 786*e4e6ec7bSolivier moysan if (of_id) 787*e4e6ec7bSolivier moysan i2s->regmap_conf = (const struct regmap_config *)of_id->data; 788*e4e6ec7bSolivier moysan else 789*e4e6ec7bSolivier moysan return -EINVAL; 790*e4e6ec7bSolivier moysan 791*e4e6ec7bSolivier moysan res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 792*e4e6ec7bSolivier moysan i2s->base = devm_ioremap_resource(&pdev->dev, res); 793*e4e6ec7bSolivier moysan if (IS_ERR(i2s->base)) 794*e4e6ec7bSolivier moysan return PTR_ERR(i2s->base); 795*e4e6ec7bSolivier moysan 796*e4e6ec7bSolivier moysan i2s->phys_addr = res->start; 797*e4e6ec7bSolivier moysan 798*e4e6ec7bSolivier moysan /* Get clocks */ 799*e4e6ec7bSolivier moysan i2s->pclk = devm_clk_get(&pdev->dev, "pclk"); 800*e4e6ec7bSolivier moysan if (IS_ERR(i2s->pclk)) { 801*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "Could not get pclk\n"); 802*e4e6ec7bSolivier moysan return PTR_ERR(i2s->pclk); 803*e4e6ec7bSolivier moysan } 804*e4e6ec7bSolivier moysan 805*e4e6ec7bSolivier moysan i2s->i2sclk = devm_clk_get(&pdev->dev, "i2sclk"); 806*e4e6ec7bSolivier moysan if (IS_ERR(i2s->i2sclk)) { 807*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "Could not get i2sclk\n"); 808*e4e6ec7bSolivier moysan return PTR_ERR(i2s->i2sclk); 809*e4e6ec7bSolivier moysan } 810*e4e6ec7bSolivier moysan 811*e4e6ec7bSolivier moysan i2s->x8kclk = devm_clk_get(&pdev->dev, "x8k"); 812*e4e6ec7bSolivier moysan if (IS_ERR(i2s->x8kclk)) { 813*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "missing x8k parent clock\n"); 814*e4e6ec7bSolivier moysan return PTR_ERR(i2s->x8kclk); 815*e4e6ec7bSolivier moysan } 816*e4e6ec7bSolivier moysan 817*e4e6ec7bSolivier moysan i2s->x11kclk = devm_clk_get(&pdev->dev, "x11k"); 818*e4e6ec7bSolivier moysan if (IS_ERR(i2s->x11kclk)) { 819*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "missing x11k parent clock\n"); 820*e4e6ec7bSolivier moysan return PTR_ERR(i2s->x11kclk); 821*e4e6ec7bSolivier moysan } 822*e4e6ec7bSolivier moysan 823*e4e6ec7bSolivier moysan /* Get irqs */ 824*e4e6ec7bSolivier moysan irq = platform_get_irq(pdev, 0); 825*e4e6ec7bSolivier moysan if (irq < 0) { 826*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "no irq for node %s\n", pdev->name); 827*e4e6ec7bSolivier moysan return -ENOENT; 828*e4e6ec7bSolivier moysan } 829*e4e6ec7bSolivier moysan 830*e4e6ec7bSolivier moysan ret = devm_request_irq(&pdev->dev, irq, stm32_i2s_isr, IRQF_ONESHOT, 831*e4e6ec7bSolivier moysan dev_name(&pdev->dev), i2s); 832*e4e6ec7bSolivier moysan if (ret) { 833*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "irq request returned %d\n", ret); 834*e4e6ec7bSolivier moysan return ret; 835*e4e6ec7bSolivier moysan } 836*e4e6ec7bSolivier moysan 837*e4e6ec7bSolivier moysan /* Reset */ 838*e4e6ec7bSolivier moysan rst = devm_reset_control_get(&pdev->dev, NULL); 839*e4e6ec7bSolivier moysan if (!IS_ERR(rst)) { 840*e4e6ec7bSolivier moysan reset_control_assert(rst); 841*e4e6ec7bSolivier moysan udelay(2); 842*e4e6ec7bSolivier moysan reset_control_deassert(rst); 843*e4e6ec7bSolivier moysan } 844*e4e6ec7bSolivier moysan 845*e4e6ec7bSolivier moysan return 0; 846*e4e6ec7bSolivier moysan } 847*e4e6ec7bSolivier moysan 848*e4e6ec7bSolivier moysan static int stm32_i2s_probe(struct platform_device *pdev) 849*e4e6ec7bSolivier moysan { 850*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s; 851*e4e6ec7bSolivier moysan int ret; 852*e4e6ec7bSolivier moysan 853*e4e6ec7bSolivier moysan i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); 854*e4e6ec7bSolivier moysan if (!i2s) 855*e4e6ec7bSolivier moysan return -ENOMEM; 856*e4e6ec7bSolivier moysan 857*e4e6ec7bSolivier moysan ret = stm32_i2s_parse_dt(pdev, i2s); 858*e4e6ec7bSolivier moysan if (ret) 859*e4e6ec7bSolivier moysan return ret; 860*e4e6ec7bSolivier moysan 861*e4e6ec7bSolivier moysan i2s->pdev = pdev; 862*e4e6ec7bSolivier moysan i2s->ms_flg = I2S_MS_NOT_SET; 863*e4e6ec7bSolivier moysan spin_lock_init(&i2s->lock_fd); 864*e4e6ec7bSolivier moysan platform_set_drvdata(pdev, i2s); 865*e4e6ec7bSolivier moysan 866*e4e6ec7bSolivier moysan ret = stm32_i2s_dais_init(pdev, i2s); 867*e4e6ec7bSolivier moysan if (ret) 868*e4e6ec7bSolivier moysan return ret; 869*e4e6ec7bSolivier moysan 870*e4e6ec7bSolivier moysan i2s->regmap = devm_regmap_init_mmio(&pdev->dev, i2s->base, 871*e4e6ec7bSolivier moysan i2s->regmap_conf); 872*e4e6ec7bSolivier moysan if (IS_ERR(i2s->regmap)) { 873*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "regmap init failed\n"); 874*e4e6ec7bSolivier moysan return PTR_ERR(i2s->regmap); 875*e4e6ec7bSolivier moysan } 876*e4e6ec7bSolivier moysan 877*e4e6ec7bSolivier moysan ret = clk_prepare_enable(i2s->pclk); 878*e4e6ec7bSolivier moysan if (ret) { 879*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "Enable pclk failed: %d\n", ret); 880*e4e6ec7bSolivier moysan return ret; 881*e4e6ec7bSolivier moysan } 882*e4e6ec7bSolivier moysan 883*e4e6ec7bSolivier moysan ret = clk_prepare_enable(i2s->i2sclk); 884*e4e6ec7bSolivier moysan if (ret) { 885*e4e6ec7bSolivier moysan dev_err(&pdev->dev, "Enable i2sclk failed: %d\n", ret); 886*e4e6ec7bSolivier moysan goto err_pclk_disable; 887*e4e6ec7bSolivier moysan } 888*e4e6ec7bSolivier moysan 889*e4e6ec7bSolivier moysan ret = devm_snd_soc_register_component(&pdev->dev, &stm32_i2s_component, 890*e4e6ec7bSolivier moysan i2s->dai_drv, 1); 891*e4e6ec7bSolivier moysan if (ret) 892*e4e6ec7bSolivier moysan goto err_clocks_disable; 893*e4e6ec7bSolivier moysan 894*e4e6ec7bSolivier moysan ret = devm_snd_dmaengine_pcm_register(&pdev->dev, 895*e4e6ec7bSolivier moysan &stm32_i2s_pcm_config, 0); 896*e4e6ec7bSolivier moysan if (ret) 897*e4e6ec7bSolivier moysan goto err_clocks_disable; 898*e4e6ec7bSolivier moysan 899*e4e6ec7bSolivier moysan /* Set SPI/I2S in i2s mode */ 900*e4e6ec7bSolivier moysan ret = regmap_update_bits(i2s->regmap, STM32_I2S_CGFR_REG, 901*e4e6ec7bSolivier moysan I2S_CGFR_I2SMOD, I2S_CGFR_I2SMOD); 902*e4e6ec7bSolivier moysan if (ret) 903*e4e6ec7bSolivier moysan goto err_clocks_disable; 904*e4e6ec7bSolivier moysan 905*e4e6ec7bSolivier moysan return ret; 906*e4e6ec7bSolivier moysan 907*e4e6ec7bSolivier moysan err_clocks_disable: 908*e4e6ec7bSolivier moysan clk_disable_unprepare(i2s->i2sclk); 909*e4e6ec7bSolivier moysan err_pclk_disable: 910*e4e6ec7bSolivier moysan clk_disable_unprepare(i2s->pclk); 911*e4e6ec7bSolivier moysan 912*e4e6ec7bSolivier moysan return ret; 913*e4e6ec7bSolivier moysan } 914*e4e6ec7bSolivier moysan 915*e4e6ec7bSolivier moysan static int stm32_i2s_remove(struct platform_device *pdev) 916*e4e6ec7bSolivier moysan { 917*e4e6ec7bSolivier moysan struct stm32_i2s_data *i2s = platform_get_drvdata(pdev); 918*e4e6ec7bSolivier moysan 919*e4e6ec7bSolivier moysan clk_disable_unprepare(i2s->i2sclk); 920*e4e6ec7bSolivier moysan clk_disable_unprepare(i2s->pclk); 921*e4e6ec7bSolivier moysan 922*e4e6ec7bSolivier moysan return 0; 923*e4e6ec7bSolivier moysan } 924*e4e6ec7bSolivier moysan 925*e4e6ec7bSolivier moysan MODULE_DEVICE_TABLE(of, stm32_i2s_ids); 926*e4e6ec7bSolivier moysan 927*e4e6ec7bSolivier moysan static struct platform_driver stm32_i2s_driver = { 928*e4e6ec7bSolivier moysan .driver = { 929*e4e6ec7bSolivier moysan .name = "st,stm32-i2s", 930*e4e6ec7bSolivier moysan .of_match_table = stm32_i2s_ids, 931*e4e6ec7bSolivier moysan }, 932*e4e6ec7bSolivier moysan .probe = stm32_i2s_probe, 933*e4e6ec7bSolivier moysan .remove = stm32_i2s_remove, 934*e4e6ec7bSolivier moysan }; 935*e4e6ec7bSolivier moysan 936*e4e6ec7bSolivier moysan module_platform_driver(stm32_i2s_driver); 937*e4e6ec7bSolivier moysan 938*e4e6ec7bSolivier moysan MODULE_DESCRIPTION("STM32 Soc i2s Interface"); 939*e4e6ec7bSolivier moysan MODULE_AUTHOR("Olivier Moysan, <olivier.moysan@st.com>"); 940*e4e6ec7bSolivier moysan MODULE_ALIAS("platform:stm32-i2s"); 941*e4e6ec7bSolivier moysan MODULE_LICENSE("GPL v2"); 942