Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branches 'asoc/topic/adsp', 'asoc/topic/atmel', 'asoc/topic/bcm2835', 'asoc/topic/docs', 'asoc/topic/fsl', 'asoc/topic/generic', 'asoc/topic/kirkwood', 'asoc/topic/mc13783', 'asoc/topic/mxs', 'asoc/topic/nuc900', 'asoc/topic/sai', 'asoc/topic/sh', 'asoc/topic/ssm2602', 'asoc/topic/tlv320aic3x', 'asoc/topic/twl4030', 'asoc/topic/ux500', 'asoc/topic/width' and 'asoc/topic/x86' into for-tiwai

+2397 -967
+50
Documentation/devicetree/bindings/sound/fsl,esai.txt
··· 1 + Freescale Enhanced Serial Audio Interface (ESAI) Controller 2 + 3 + The Enhanced Serial Audio Interface (ESAI) provides a full-duplex serial port 4 + for serial communication with a variety of serial devices, including industry 5 + standard codecs, Sony/Phillips Digital Interface (S/PDIF) transceivers, and 6 + other DSPs. It has up to six transmitters and four receivers. 7 + 8 + Required properties: 9 + 10 + - compatible : Compatible list, must contain "fsl,imx35-esai". 11 + 12 + - reg : Offset and length of the register set for the device. 13 + 14 + - interrupts : Contains the spdif interrupt. 15 + 16 + - dmas : Generic dma devicetree binding as described in 17 + Documentation/devicetree/bindings/dma/dma.txt. 18 + 19 + - dma-names : Two dmas have to be defined, "tx" and "rx". 20 + 21 + - clocks: Contains an entry for each entry in clock-names. 22 + 23 + - clock-names : Includes the following entries: 24 + "core" The core clock used to access registers 25 + "extal" The esai baud clock for esai controller used to derive 26 + HCK, SCK and FS. 27 + "fsys" The system clock derived from ahb clock used to derive 28 + HCK, SCK and FS. 29 + 30 + - fsl,fifo-depth: The number of elements in the transmit and receive FIFOs. 31 + This number is the maximum allowed value for TFCR[TFWM] or RFCR[RFWM]. 32 + 33 + - fsl,esai-synchronous: This is a boolean property. If present, indicating 34 + that ESAI would work in the synchronous mode, which means all the settings 35 + for Receiving would be duplicated from Transmition related registers. 36 + 37 + Example: 38 + 39 + esai: esai@02024000 { 40 + compatible = "fsl,imx35-esai"; 41 + reg = <0x02024000 0x4000>; 42 + interrupts = <0 51 0x04>; 43 + clocks = <&clks 208>, <&clks 118>, <&clks 208>; 44 + clock-names = "core", "extal", "fsys"; 45 + dmas = <&sdma 23 21 0>, <&sdma 24 21 0>; 46 + dma-names = "rx", "tx"; 47 + fsl,fifo-depth = <128>; 48 + fsl,esai-synchronous; 49 + status = "disabled"; 50 + };
+6 -1
Documentation/devicetree/bindings/sound/fsl,ssi.txt
··· 4 4 be programmed in AC97, I2S, left-justified, or right-justified modes. 5 5 6 6 Required properties: 7 - - compatible: Compatible list, contains "fsl,ssi". 7 + - compatible: Compatible list, should contain one of the following 8 + compatibles: 9 + fsl,mpc8610-ssi 10 + fsl,imx51-ssi 11 + fsl,imx35-ssi 12 + fsl,imx21-ssi 8 13 - cell-index: The SSI, <0> = SSI1, <1> = SSI2, and so on. 9 14 - reg: Offset and length of the register set for the device. 10 15 - interrupts: <a b> where a is the interrupt number and b is a
+1 -1
Documentation/devicetree/bindings/sound/simple-card.txt
··· 11 11 - simple-audio-card,format : CPU/CODEC common audio format. 12 12 "i2s", "right_j", "left_j" , "dsp_a" 13 13 "dsp_b", "ac97", "pdm", "msb", "lsb" 14 - - simple-audio-routing : A list of the connections between audio components. 14 + - simple-audio-card,routing : A list of the connections between audio components. 15 15 Each entry is a pair of strings, the first being the 16 16 connection's sink, the second being the connection's 17 17 source.
+1
Documentation/devicetree/bindings/sound/tlv320aic3x.txt
··· 6 6 7 7 - compatible - "string" - One of: 8 8 "ti,tlv320aic3x" - Generic TLV320AIC3x device 9 + "ti,tlv320aic32x4" - TLV320AIC32x4 9 10 "ti,tlv320aic33" - TLV320AIC33 10 11 "ti,tlv320aic3007" - TLV320AIC3007 11 12 "ti,tlv320aic3106" - TLV320AIC3106
+18 -9
Documentation/sound/alsa/soc/overview.txt
··· 49 49 * Machine specific controls: Allow machines to add controls to the sound card 50 50 (e.g. volume control for speaker amplifier). 51 51 52 - To achieve all this, ASoC basically splits an embedded audio system into 3 53 - components :- 52 + To achieve all this, ASoC basically splits an embedded audio system into 53 + multiple re-usable component drivers :- 54 54 55 - * Codec driver: The codec driver is platform independent and contains audio 56 - controls, audio interface capabilities, codec DAPM definition and codec IO 57 - functions. 55 + * Codec class drivers: The codec class driver is platform independent and 56 + contains audio controls, audio interface capabilities, codec DAPM 57 + definition and codec IO functions. This class extends to BT, FM and MODEM 58 + ICs if required. Codec class drivers should be generic code that can run 59 + on any architecture and machine. 58 60 59 - * Platform driver: The platform driver contains the audio DMA engine and audio 60 - interface drivers (e.g. I2S, AC97, PCM) for that platform. 61 + * Platform class drivers: The platform class driver includes the audio DMA 62 + engine driver, digital audio interface (DAI) drivers (e.g. I2S, AC97, PCM) 63 + and any audio DSP drivers for that platform. 61 64 62 - * Machine driver: The machine driver handles any machine specific controls and 63 - audio events (e.g. turning on an amp at start of playback). 65 + * Machine class driver: The machine driver class acts as the glue that 66 + decribes and binds the other component drivers together to form an ALSA 67 + "sound card device". It handles any machine specific controls and 68 + machine level audio events (e.g. turning on an amp at start of playback). 64 69 65 70 66 71 Documentation ··· 89 84 pop_clicks.txt: How to minimise audio artifacts. 90 85 91 86 clocking.txt: ASoC clocking for best power performance. 87 + 88 + jack.txt: ASoC jack detection. 89 + 90 + DPCM.txt: Dynamic PCM - Describes DPCM with DSP examples.
+4 -4
arch/arm/mach-ux500/board-mop500-audio.c
··· 31 31 }; 32 32 33 33 struct msp_i2s_platform_data msp0_platform_data = { 34 - .id = MSP_I2S_0, 34 + .id = 0, 35 35 .msp_i2s_dma_rx = &msp0_dma_rx, 36 36 .msp_i2s_dma_tx = &msp0_dma_tx, 37 37 }; ··· 49 49 }; 50 50 51 51 struct msp_i2s_platform_data msp1_platform_data = { 52 - .id = MSP_I2S_1, 52 + .id = 1, 53 53 .msp_i2s_dma_rx = NULL, 54 54 .msp_i2s_dma_tx = &msp1_dma_tx, 55 55 }; ··· 69 69 }; 70 70 71 71 struct msp_i2s_platform_data msp2_platform_data = { 72 - .id = MSP_I2S_2, 72 + .id = 2, 73 73 .msp_i2s_dma_rx = &msp2_dma_rx, 74 74 .msp_i2s_dma_tx = &msp2_dma_tx, 75 75 }; 76 76 77 77 struct msp_i2s_platform_data msp3_platform_data = { 78 - .id = MSP_I2S_3, 78 + .id = 3, 79 79 .msp_i2s_dma_rx = &msp1_dma_rx, 80 80 .msp_i2s_dma_tx = NULL, 81 81 };
+166 -30
drivers/mfd/twl-core.c
··· 47 47 #include <linux/i2c.h> 48 48 #include <linux/i2c/twl.h> 49 49 50 + /* Register descriptions for audio */ 51 + #include <linux/mfd/twl4030-audio.h> 52 + 50 53 #include "twl-core.h" 51 54 52 55 /* ··· 203 200 { 2, TWL5031_BASEADD_INTERRUPTS }, 204 201 }; 205 202 203 + static struct reg_default twl4030_49_defaults[] = { 204 + /* Audio Registers */ 205 + { 0x01, 0x00}, /* CODEC_MODE */ 206 + { 0x02, 0x00}, /* OPTION */ 207 + /* 0x03 Unused */ 208 + { 0x04, 0x00}, /* MICBIAS_CTL */ 209 + { 0x05, 0x00}, /* ANAMICL */ 210 + { 0x06, 0x00}, /* ANAMICR */ 211 + { 0x07, 0x00}, /* AVADC_CTL */ 212 + { 0x08, 0x00}, /* ADCMICSEL */ 213 + { 0x09, 0x00}, /* DIGMIXING */ 214 + { 0x0a, 0x0f}, /* ATXL1PGA */ 215 + { 0x0b, 0x0f}, /* ATXR1PGA */ 216 + { 0x0c, 0x0f}, /* AVTXL2PGA */ 217 + { 0x0d, 0x0f}, /* AVTXR2PGA */ 218 + { 0x0e, 0x00}, /* AUDIO_IF */ 219 + { 0x0f, 0x00}, /* VOICE_IF */ 220 + { 0x10, 0x3f}, /* ARXR1PGA */ 221 + { 0x11, 0x3f}, /* ARXL1PGA */ 222 + { 0x12, 0x3f}, /* ARXR2PGA */ 223 + { 0x13, 0x3f}, /* ARXL2PGA */ 224 + { 0x14, 0x25}, /* VRXPGA */ 225 + { 0x15, 0x00}, /* VSTPGA */ 226 + { 0x16, 0x00}, /* VRX2ARXPGA */ 227 + { 0x17, 0x00}, /* AVDAC_CTL */ 228 + { 0x18, 0x00}, /* ARX2VTXPGA */ 229 + { 0x19, 0x32}, /* ARXL1_APGA_CTL*/ 230 + { 0x1a, 0x32}, /* ARXR1_APGA_CTL*/ 231 + { 0x1b, 0x32}, /* ARXL2_APGA_CTL*/ 232 + { 0x1c, 0x32}, /* ARXR2_APGA_CTL*/ 233 + { 0x1d, 0x00}, /* ATX2ARXPGA */ 234 + { 0x1e, 0x00}, /* BT_IF */ 235 + { 0x1f, 0x55}, /* BTPGA */ 236 + { 0x20, 0x00}, /* BTSTPGA */ 237 + { 0x21, 0x00}, /* EAR_CTL */ 238 + { 0x22, 0x00}, /* HS_SEL */ 239 + { 0x23, 0x00}, /* HS_GAIN_SET */ 240 + { 0x24, 0x00}, /* HS_POPN_SET */ 241 + { 0x25, 0x00}, /* PREDL_CTL */ 242 + { 0x26, 0x00}, /* PREDR_CTL */ 243 + { 0x27, 0x00}, /* PRECKL_CTL */ 244 + { 0x28, 0x00}, /* PRECKR_CTL */ 245 + { 0x29, 0x00}, /* HFL_CTL */ 246 + { 0x2a, 0x00}, /* HFR_CTL */ 247 + { 0x2b, 0x05}, /* ALC_CTL */ 248 + { 0x2c, 0x00}, /* ALC_SET1 */ 249 + { 0x2d, 0x00}, /* ALC_SET2 */ 250 + { 0x2e, 0x00}, /* BOOST_CTL */ 251 + { 0x2f, 0x00}, /* SOFTVOL_CTL */ 252 + { 0x30, 0x13}, /* DTMF_FREQSEL */ 253 + { 0x31, 0x00}, /* DTMF_TONEXT1H */ 254 + { 0x32, 0x00}, /* DTMF_TONEXT1L */ 255 + { 0x33, 0x00}, /* DTMF_TONEXT2H */ 256 + { 0x34, 0x00}, /* DTMF_TONEXT2L */ 257 + { 0x35, 0x79}, /* DTMF_TONOFF */ 258 + { 0x36, 0x11}, /* DTMF_WANONOFF */ 259 + { 0x37, 0x00}, /* I2S_RX_SCRAMBLE_H */ 260 + { 0x38, 0x00}, /* I2S_RX_SCRAMBLE_M */ 261 + { 0x39, 0x00}, /* I2S_RX_SCRAMBLE_L */ 262 + { 0x3a, 0x06}, /* APLL_CTL */ 263 + { 0x3b, 0x00}, /* DTMF_CTL */ 264 + { 0x3c, 0x44}, /* DTMF_PGA_CTL2 (0x3C) */ 265 + { 0x3d, 0x69}, /* DTMF_PGA_CTL1 (0x3D) */ 266 + { 0x3e, 0x00}, /* MISC_SET_1 */ 267 + { 0x3f, 0x00}, /* PCMBTMUX */ 268 + /* 0x40 - 0x42 Unused */ 269 + { 0x43, 0x00}, /* RX_PATH_SEL */ 270 + { 0x44, 0x32}, /* VDL_APGA_CTL */ 271 + { 0x45, 0x00}, /* VIBRA_CTL */ 272 + { 0x46, 0x00}, /* VIBRA_SET */ 273 + { 0x47, 0x00}, /* VIBRA_PWM_SET */ 274 + { 0x48, 0x00}, /* ANAMIC_GAIN */ 275 + { 0x49, 0x00}, /* MISC_SET_2 */ 276 + /* End of Audio Registers */ 277 + }; 278 + 279 + static bool twl4030_49_nop_reg(struct device *dev, unsigned int reg) 280 + { 281 + switch (reg) { 282 + case 0: 283 + case 3: 284 + case 40: 285 + case 41: 286 + case 42: 287 + return false; 288 + default: 289 + return true; 290 + } 291 + } 292 + 293 + static const struct regmap_range twl4030_49_volatile_ranges[] = { 294 + regmap_reg_range(TWL4030_BASEADD_TEST, 0xff), 295 + }; 296 + 297 + static const struct regmap_access_table twl4030_49_volatile_table = { 298 + .yes_ranges = twl4030_49_volatile_ranges, 299 + .n_yes_ranges = ARRAY_SIZE(twl4030_49_volatile_ranges), 300 + }; 301 + 206 302 static struct regmap_config twl4030_regmap_config[4] = { 207 303 { 208 304 /* Address 0x48 */ ··· 314 212 .reg_bits = 8, 315 213 .val_bits = 8, 316 214 .max_register = 0xff, 215 + 216 + .readable_reg = twl4030_49_nop_reg, 217 + .writeable_reg = twl4030_49_nop_reg, 218 + 219 + .volatile_table = &twl4030_49_volatile_table, 220 + 221 + .reg_defaults = twl4030_49_defaults, 222 + .num_reg_defaults = ARRAY_SIZE(twl4030_49_defaults), 223 + .cache_type = REGCACHE_RBTREE, 317 224 }, 318 225 { 319 226 /* Address 0x4a */ ··· 413 302 EXPORT_SYMBOL(twl_rev); 414 303 415 304 /** 305 + * twl_get_regmap - Get the regmap associated with the given module 306 + * @mod_no: module number 307 + * 308 + * Returns the regmap pointer or NULL in case of failure. 309 + */ 310 + static struct regmap *twl_get_regmap(u8 mod_no) 311 + { 312 + int sid; 313 + struct twl_client *twl; 314 + 315 + if (unlikely(!twl_priv || !twl_priv->ready)) { 316 + pr_err("%s: not initialized\n", DRIVER_NAME); 317 + return NULL; 318 + } 319 + if (unlikely(mod_no >= twl_get_last_module())) { 320 + pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 321 + return NULL; 322 + } 323 + 324 + sid = twl_priv->twl_map[mod_no].sid; 325 + twl = &twl_priv->twl_modules[sid]; 326 + 327 + return twl->regmap; 328 + } 329 + 330 + /** 416 331 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0 417 332 * @mod_no: module number 418 333 * @value: an array of num_bytes+1 containing data to write ··· 449 312 */ 450 313 int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 451 314 { 315 + struct regmap *regmap = twl_get_regmap(mod_no); 452 316 int ret; 453 - int sid; 454 - struct twl_client *twl; 455 317 456 - if (unlikely(!twl_priv || !twl_priv->ready)) { 457 - pr_err("%s: not initialized\n", DRIVER_NAME); 318 + if (!regmap) 458 319 return -EPERM; 459 - } 460 - if (unlikely(mod_no >= twl_get_last_module())) { 461 - pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 462 - return -EPERM; 463 - } 464 320 465 - sid = twl_priv->twl_map[mod_no].sid; 466 - twl = &twl_priv->twl_modules[sid]; 467 - 468 - ret = regmap_bulk_write(twl->regmap, 469 - twl_priv->twl_map[mod_no].base + reg, value, 470 - num_bytes); 321 + ret = regmap_bulk_write(regmap, twl_priv->twl_map[mod_no].base + reg, 322 + value, num_bytes); 471 323 472 324 if (ret) 473 325 pr_err("%s: Write failed (mod %d, reg 0x%02x count %d)\n", ··· 477 351 */ 478 352 int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 479 353 { 354 + struct regmap *regmap = twl_get_regmap(mod_no); 480 355 int ret; 481 - int sid; 482 - struct twl_client *twl; 483 356 484 - if (unlikely(!twl_priv || !twl_priv->ready)) { 485 - pr_err("%s: not initialized\n", DRIVER_NAME); 357 + if (!regmap) 486 358 return -EPERM; 487 - } 488 - if (unlikely(mod_no >= twl_get_last_module())) { 489 - pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 490 - return -EPERM; 491 - } 492 359 493 - sid = twl_priv->twl_map[mod_no].sid; 494 - twl = &twl_priv->twl_modules[sid]; 495 - 496 - ret = regmap_bulk_read(twl->regmap, 497 - twl_priv->twl_map[mod_no].base + reg, value, 498 - num_bytes); 360 + ret = regmap_bulk_read(regmap, twl_priv->twl_map[mod_no].base + reg, 361 + value, num_bytes); 499 362 500 363 if (ret) 501 364 pr_err("%s: Read failed (mod %d, reg 0x%02x count %d)\n", ··· 493 378 return ret; 494 379 } 495 380 EXPORT_SYMBOL(twl_i2c_read); 381 + 382 + /** 383 + * twl_regcache_bypass - Configure the regcache bypass for the regmap associated 384 + * with the module 385 + * @mod_no: module number 386 + * @enable: Regcache bypass state 387 + * 388 + * Returns 0 else failure. 389 + */ 390 + int twl_set_regcache_bypass(u8 mod_no, bool enable) 391 + { 392 + struct regmap *regmap = twl_get_regmap(mod_no); 393 + 394 + if (!regmap) 395 + return -EPERM; 396 + 397 + regcache_cache_bypass(regmap, enable); 398 + 399 + return 0; 400 + } 401 + EXPORT_SYMBOL(twl_set_regcache_bypass); 496 402 497 403 /*----------------------------------------------------------------------*/ 498 404
+3 -2
include/linux/i2c/twl.h
··· 175 175 TWL_CLASS_IS(4030, TWL4030_CLASS_ID) 176 176 TWL_CLASS_IS(6030, TWL6030_CLASS_ID) 177 177 178 + /* Set the regcache bypass for the regmap associated with the nodule */ 179 + int twl_set_regcache_bypass(u8 mod_no, bool enable); 180 + 178 181 /* 179 182 * Read and write several 8-bit registers at once. 180 183 */ ··· 670 667 unsigned int digimic_delay; /* in ms */ 671 668 unsigned int ramp_delay_value; 672 669 unsigned int offset_cncl_path; 673 - unsigned int check_defaults:1; 674 - unsigned int reset_registers:1; 675 670 unsigned int hs_extmute:1; 676 671 int hs_extmute_gpio; 677 672 };
+1 -8
include/linux/platform_data/asoc-ux500-msp.h
··· 10 10 11 11 #include <linux/platform_data/dma-ste-dma40.h> 12 12 13 - enum msp_i2s_id { 14 - MSP_I2S_0 = 0, 15 - MSP_I2S_1, 16 - MSP_I2S_2, 17 - MSP_I2S_3, 18 - }; 19 - 20 13 /* Platform data structure for a MSP I2S-device */ 21 14 struct msp_i2s_platform_data { 22 - enum msp_i2s_id id; 15 + int id; 23 16 struct stedma40_chan_cfg *msp_i2s_dma_rx; 24 17 struct stedma40_chan_cfg *msp_i2s_dma_tx; 25 18 };
-1
sound/soc/atmel/atmel-pcm-dma.c
··· 50 50 SNDRV_PCM_INFO_INTERLEAVED | 51 51 SNDRV_PCM_INFO_RESUME | 52 52 SNDRV_PCM_INFO_PAUSE, 53 - .formats = SNDRV_PCM_FMTBIT_S16_LE, 54 53 .period_bytes_min = 256, /* lighting DMA overhead */ 55 54 .period_bytes_max = 2 * 0xffff, /* if 2 bytes format */ 56 55 .periods_min = 8,
-1
sound/soc/atmel/atmel-pcm-pdc.c
··· 58 58 SNDRV_PCM_INFO_MMAP_VALID | 59 59 SNDRV_PCM_INFO_INTERLEAVED | 60 60 SNDRV_PCM_INFO_PAUSE, 61 - .formats = SNDRV_PCM_FMTBIT_S16_LE, 62 61 .period_bytes_min = 32, 63 62 .period_bytes_max = 8192, 64 63 .periods_min = 2,
-1
sound/soc/bcm/Kconfig
··· 1 1 config SND_BCM2835_SOC_I2S 2 2 tristate "SoC Audio support for the Broadcom BCM2835 I2S module" 3 3 depends on ARCH_BCM2835 || COMPILE_TEST 4 - select SND_SOC_DMAENGINE_PCM 5 4 select SND_SOC_GENERIC_DMAENGINE_PCM 6 5 select REGMAP_MMIO 7 6 help
+5 -5
sound/soc/codecs/ad1836.c
··· 168 168 int word_len = 0; 169 169 170 170 /* bit size */ 171 - switch (params_format(params)) { 172 - case SNDRV_PCM_FORMAT_S16_LE: 171 + switch (params_width(params)) { 172 + case 16: 173 173 word_len = AD1836_WORD_LEN_16; 174 174 break; 175 - case SNDRV_PCM_FORMAT_S20_3LE: 175 + case 20: 176 176 word_len = AD1836_WORD_LEN_20; 177 177 break; 178 - case SNDRV_PCM_FORMAT_S24_LE: 179 - case SNDRV_PCM_FORMAT_S32_LE: 178 + case 24: 179 + case 32: 180 180 word_len = AD1836_WORD_LEN_24; 181 181 break; 182 182 default:
+5 -5
sound/soc/codecs/ad193x.c
··· 249 249 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); 250 250 251 251 /* bit size */ 252 - switch (params_format(params)) { 253 - case SNDRV_PCM_FORMAT_S16_LE: 252 + switch (params_width(params)) { 253 + case 16: 254 254 word_len = 3; 255 255 break; 256 - case SNDRV_PCM_FORMAT_S20_3LE: 256 + case 20: 257 257 word_len = 1; 258 258 break; 259 - case SNDRV_PCM_FORMAT_S24_LE: 260 - case SNDRV_PCM_FORMAT_S32_LE: 259 + case 24: 260 + case 32: 261 261 word_len = 0; 262 262 break; 263 263 }
+5 -5
sound/soc/codecs/adau1373.c
··· 1078 1078 ADAU1373_BCLKDIV_SR_MASK | ADAU1373_BCLKDIV_BCLK_MASK, 1079 1079 (div << 2) | ADAU1373_BCLKDIV_64); 1080 1080 1081 - switch (params_format(params)) { 1082 - case SNDRV_PCM_FORMAT_S16_LE: 1081 + switch (params_width(params)) { 1082 + case 16: 1083 1083 ctrl = ADAU1373_DAI_WLEN_16; 1084 1084 break; 1085 - case SNDRV_PCM_FORMAT_S20_3LE: 1085 + case 20: 1086 1086 ctrl = ADAU1373_DAI_WLEN_20; 1087 1087 break; 1088 - case SNDRV_PCM_FORMAT_S24_LE: 1088 + case 24: 1089 1089 ctrl = ADAU1373_DAI_WLEN_24; 1090 1090 break; 1091 - case SNDRV_PCM_FORMAT_S32_LE: 1091 + case 32: 1092 1092 ctrl = ADAU1373_DAI_WLEN_32; 1093 1093 break; 1094 1094 default:
+16 -18
sound/soc/codecs/adau1701.c
··· 299 299 } 300 300 301 301 static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec, 302 - snd_pcm_format_t format) 302 + struct snd_pcm_hw_params *params) 303 303 { 304 304 struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); 305 305 unsigned int mask = ADAU1701_SEROCTL_WORD_LEN_MASK; 306 306 unsigned int val; 307 307 308 - switch (format) { 309 - case SNDRV_PCM_FORMAT_S16_LE: 308 + switch (params_width(params)) { 309 + case 16: 310 310 val = ADAU1701_SEROCTL_WORD_LEN_16; 311 311 break; 312 - case SNDRV_PCM_FORMAT_S20_3LE: 312 + case 20: 313 313 val = ADAU1701_SEROCTL_WORD_LEN_20; 314 314 break; 315 - case SNDRV_PCM_FORMAT_S24_LE: 315 + case 24: 316 316 val = ADAU1701_SEROCTL_WORD_LEN_24; 317 317 break; 318 318 default: ··· 320 320 } 321 321 322 322 if (adau1701->dai_fmt == SND_SOC_DAIFMT_RIGHT_J) { 323 - switch (format) { 324 - case SNDRV_PCM_FORMAT_S16_LE: 323 + switch (params_width(params)) { 324 + case 16: 325 325 val |= ADAU1701_SEROCTL_MSB_DEALY16; 326 326 break; 327 - case SNDRV_PCM_FORMAT_S20_3LE: 327 + case 20: 328 328 val |= ADAU1701_SEROCTL_MSB_DEALY12; 329 329 break; 330 - case SNDRV_PCM_FORMAT_S24_LE: 330 + case 24: 331 331 val |= ADAU1701_SEROCTL_MSB_DEALY8; 332 332 break; 333 333 } ··· 340 340 } 341 341 342 342 static int adau1701_set_playback_pcm_format(struct snd_soc_codec *codec, 343 - snd_pcm_format_t format) 343 + struct snd_pcm_hw_params *params) 344 344 { 345 345 struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); 346 346 unsigned int val; ··· 348 348 if (adau1701->dai_fmt != SND_SOC_DAIFMT_RIGHT_J) 349 349 return 0; 350 350 351 - switch (format) { 352 - case SNDRV_PCM_FORMAT_S16_LE: 351 + switch (params_width(params)) { 352 + case 16: 353 353 val = ADAU1701_SERICTL_RIGHTJ_16; 354 354 break; 355 - case SNDRV_PCM_FORMAT_S20_3LE: 355 + case 20: 356 356 val = ADAU1701_SERICTL_RIGHTJ_20; 357 357 break; 358 - case SNDRV_PCM_FORMAT_S24_LE: 358 + case 24: 359 359 val = ADAU1701_SERICTL_RIGHTJ_24; 360 360 break; 361 361 default: ··· 374 374 struct snd_soc_codec *codec = dai->codec; 375 375 struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); 376 376 unsigned int clkdiv = adau1701->sysclk / params_rate(params); 377 - snd_pcm_format_t format; 378 377 unsigned int val; 379 378 int ret; 380 379 ··· 405 406 regmap_update_bits(adau1701->regmap, ADAU1701_DSPCTRL, 406 407 ADAU1701_DSPCTRL_SR_MASK, val); 407 408 408 - format = params_format(params); 409 409 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 410 - return adau1701_set_playback_pcm_format(codec, format); 410 + return adau1701_set_playback_pcm_format(codec, params); 411 411 else 412 - return adau1701_set_capture_pcm_format(codec, format); 412 + return adau1701_set_capture_pcm_format(codec, params); 413 413 } 414 414 415 415 static int adau1701_set_dai_fmt(struct snd_soc_dai *codec_dai,
+14 -16
sound/soc/codecs/adav80x.c
··· 453 453 } 454 454 455 455 static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec, 456 - struct snd_soc_dai *dai, snd_pcm_format_t format) 456 + struct snd_soc_dai *dai, struct snd_pcm_hw_params *params) 457 457 { 458 458 struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); 459 459 unsigned int val; 460 460 461 - switch (format) { 462 - case SNDRV_PCM_FORMAT_S16_LE: 461 + switch (params_width(params)) { 462 + case 16: 463 463 val = ADAV80X_CAPTURE_WORD_LEN16; 464 464 break; 465 - case SNDRV_PCM_FORMAT_S18_3LE: 465 + case 18: 466 466 val = ADAV80X_CAPTRUE_WORD_LEN18; 467 467 break; 468 - case SNDRV_PCM_FORMAT_S20_3LE: 468 + case 20: 469 469 val = ADAV80X_CAPTURE_WORD_LEN20; 470 470 break; 471 - case SNDRV_PCM_FORMAT_S24_LE: 471 + case 24: 472 472 val = ADAV80X_CAPTURE_WORD_LEN24; 473 473 break; 474 474 default: ··· 482 482 } 483 483 484 484 static int adav80x_set_playback_pcm_format(struct snd_soc_codec *codec, 485 - struct snd_soc_dai *dai, snd_pcm_format_t format) 485 + struct snd_soc_dai *dai, struct snd_pcm_hw_params *params) 486 486 { 487 487 struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); 488 488 unsigned int val; ··· 490 490 if (adav80x->dai_fmt[dai->id] != SND_SOC_DAIFMT_RIGHT_J) 491 491 return 0; 492 492 493 - switch (format) { 494 - case SNDRV_PCM_FORMAT_S16_LE: 493 + switch (params_width(params)) { 494 + case 16: 495 495 val = ADAV80X_PLAYBACK_MODE_RIGHT_J_16; 496 496 break; 497 - case SNDRV_PCM_FORMAT_S18_3LE: 497 + case 18: 498 498 val = ADAV80X_PLAYBACK_MODE_RIGHT_J_18; 499 499 break; 500 - case SNDRV_PCM_FORMAT_S20_3LE: 500 + case 20: 501 501 val = ADAV80X_PLAYBACK_MODE_RIGHT_J_20; 502 502 break; 503 - case SNDRV_PCM_FORMAT_S24_LE: 503 + case 24: 504 504 val = ADAV80X_PLAYBACK_MODE_RIGHT_J_24; 505 505 break; 506 506 default: ··· 524 524 return -EINVAL; 525 525 526 526 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 527 - adav80x_set_playback_pcm_format(codec, dai, 528 - params_format(params)); 527 + adav80x_set_playback_pcm_format(codec, dai, params); 529 528 adav80x_set_dac_clock(codec, rate); 530 529 } else { 531 - adav80x_set_capture_pcm_format(codec, dai, 532 - params_format(params)); 530 + adav80x_set_capture_pcm_format(codec, dai, params); 533 531 adav80x_set_adc_clock(codec, rate); 534 532 } 535 533 adav80x->rate = rate;
+5 -5
sound/soc/codecs/alc5623.c
··· 714 714 iface &= ~ALC5623_DAI_I2S_DL_MASK; 715 715 716 716 /* bit size */ 717 - switch (params_format(params)) { 718 - case SNDRV_PCM_FORMAT_S16_LE: 717 + switch (params_width(params)) { 718 + case 16: 719 719 iface |= ALC5623_DAI_I2S_DL_16; 720 720 break; 721 - case SNDRV_PCM_FORMAT_S20_3LE: 721 + case 20: 722 722 iface |= ALC5623_DAI_I2S_DL_20; 723 723 break; 724 - case SNDRV_PCM_FORMAT_S24_LE: 724 + case 24: 725 725 iface |= ALC5623_DAI_I2S_DL_24; 726 726 break; 727 - case SNDRV_PCM_FORMAT_S32_LE: 727 + case 32: 728 728 iface |= ALC5623_DAI_I2S_DL_32; 729 729 break; 730 730 default:
+4 -4
sound/soc/codecs/alc5632.c
··· 869 869 iface &= ~ALC5632_DAI_I2S_DL_MASK; 870 870 871 871 /* bit size */ 872 - switch (params_format(params)) { 873 - case SNDRV_PCM_FORMAT_S16_LE: 872 + switch (params_width(params)) { 873 + case 16: 874 874 iface |= ALC5632_DAI_I2S_DL_16; 875 875 break; 876 - case SNDRV_PCM_FORMAT_S20_3LE: 876 + case 20: 877 877 iface |= ALC5632_DAI_I2S_DL_20; 878 878 break; 879 - case SNDRV_PCM_FORMAT_S24_LE: 879 + case 24: 880 880 iface |= ALC5632_DAI_I2S_DL_24; 881 881 break; 882 882 default:
+9 -8
sound/soc/codecs/arizona.h
··· 166 166 ARIZONA_MIXER_INPUT_ROUTES(name " Input 4") 167 167 168 168 #define ARIZONA_DSP_ROUTES(name) \ 169 - { name, NULL, name " Aux 1" }, \ 170 - { name, NULL, name " Aux 2" }, \ 171 - { name, NULL, name " Aux 3" }, \ 172 - { name, NULL, name " Aux 4" }, \ 173 - { name, NULL, name " Aux 5" }, \ 174 - { name, NULL, name " Aux 6" }, \ 169 + { name, NULL, name " Preloader"}, \ 170 + { name " Preloader", NULL, name " Aux 1" }, \ 171 + { name " Preloader", NULL, name " Aux 2" }, \ 172 + { name " Preloader", NULL, name " Aux 3" }, \ 173 + { name " Preloader", NULL, name " Aux 4" }, \ 174 + { name " Preloader", NULL, name " Aux 5" }, \ 175 + { name " Preloader", NULL, name " Aux 6" }, \ 175 176 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 1"), \ 176 177 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 2"), \ 177 178 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 3"), \ 178 179 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 4"), \ 179 180 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 5"), \ 180 181 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 6"), \ 181 - ARIZONA_MIXER_ROUTES(name, name "L"), \ 182 - ARIZONA_MIXER_ROUTES(name, name "R") 182 + ARIZONA_MIXER_ROUTES(name " Preloader", name "L"), \ 183 + ARIZONA_MIXER_ROUTES(name " Preloader", name "R") 183 184 184 185 #define ARIZONA_RATE_ENUM_SIZE 4 185 186 extern const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE];
+5 -9
sound/soc/codecs/cs42l51.c
··· 423 423 intf_ctl |= CS42L51_INTF_CTL_DAC_FORMAT(CS42L51_DAC_DIF_LJ24); 424 424 break; 425 425 case SND_SOC_DAIFMT_RIGHT_J: 426 - switch (params_format(params)) { 427 - case SNDRV_PCM_FORMAT_S16_LE: 428 - case SNDRV_PCM_FORMAT_S16_BE: 426 + switch (params_width(params)) { 427 + case 16: 429 428 fmt = CS42L51_DAC_DIF_RJ16; 430 429 break; 431 - case SNDRV_PCM_FORMAT_S18_3LE: 432 - case SNDRV_PCM_FORMAT_S18_3BE: 430 + case 18: 433 431 fmt = CS42L51_DAC_DIF_RJ18; 434 432 break; 435 - case SNDRV_PCM_FORMAT_S20_3LE: 436 - case SNDRV_PCM_FORMAT_S20_3BE: 433 + case 20: 437 434 fmt = CS42L51_DAC_DIF_RJ20; 438 435 break; 439 - case SNDRV_PCM_FORMAT_S24_LE: 440 - case SNDRV_PCM_FORMAT_S24_BE: 436 + case 24: 441 437 fmt = CS42L51_DAC_DIF_RJ24; 442 438 break; 443 439 default:
+5 -5
sound/soc/codecs/da7210.c
··· 778 778 779 779 dai_cfg1 = 0xFC & snd_soc_read(codec, DA7210_DAI_CFG1); 780 780 781 - switch (params_format(params)) { 782 - case SNDRV_PCM_FORMAT_S16_LE: 781 + switch (params_width(params)) { 782 + case 16: 783 783 dai_cfg1 |= DA7210_DAI_WORD_S16_LE; 784 784 break; 785 - case SNDRV_PCM_FORMAT_S20_3LE: 785 + case 20: 786 786 dai_cfg1 |= DA7210_DAI_WORD_S20_3LE; 787 787 break; 788 - case SNDRV_PCM_FORMAT_S24_LE: 788 + case 24: 789 789 dai_cfg1 |= DA7210_DAI_WORD_S24_LE; 790 790 break; 791 - case SNDRV_PCM_FORMAT_S32_LE: 791 + case 32: 792 792 dai_cfg1 |= DA7210_DAI_WORD_S32_LE; 793 793 break; 794 794 default:
+5 -5
sound/soc/codecs/da7213.c
··· 1067 1067 u8 fs; 1068 1068 1069 1069 /* Set DAI format */ 1070 - switch (params_format(params)) { 1071 - case SNDRV_PCM_FORMAT_S16_LE: 1070 + switch (params_width(params)) { 1071 + case 16: 1072 1072 dai_ctrl |= DA7213_DAI_WORD_LENGTH_S16_LE; 1073 1073 break; 1074 - case SNDRV_PCM_FORMAT_S20_3LE: 1074 + case 20: 1075 1075 dai_ctrl |= DA7213_DAI_WORD_LENGTH_S20_LE; 1076 1076 break; 1077 - case SNDRV_PCM_FORMAT_S24_LE: 1077 + case 24: 1078 1078 dai_ctrl |= DA7213_DAI_WORD_LENGTH_S24_LE; 1079 1079 break; 1080 - case SNDRV_PCM_FORMAT_S32_LE: 1080 + case 32: 1081 1081 dai_ctrl |= DA7213_DAI_WORD_LENGTH_S32_LE; 1082 1082 break; 1083 1083 default:
+5 -5
sound/soc/codecs/da732x.c
··· 973 973 974 974 reg_aif = dai->driver->base; 975 975 976 - switch (params_format(params)) { 977 - case SNDRV_PCM_FORMAT_S16_LE: 976 + switch (params_width(params)) { 977 + case 16: 978 978 aif |= DA732X_AIF_WORD_16; 979 979 break; 980 - case SNDRV_PCM_FORMAT_S20_3LE: 980 + case 20: 981 981 aif |= DA732X_AIF_WORD_20; 982 982 break; 983 - case SNDRV_PCM_FORMAT_S24_LE: 983 + case 24: 984 984 aif |= DA732X_AIF_WORD_24; 985 985 break; 986 - case SNDRV_PCM_FORMAT_S32_LE: 986 + case 32: 987 987 aif |= DA732X_AIF_WORD_32; 988 988 break; 989 989 default:
+5 -5
sound/soc/codecs/da9055.c
··· 1058 1058 u8 aif_ctrl, fs; 1059 1059 u32 sysclk; 1060 1060 1061 - switch (params_format(params)) { 1062 - case SNDRV_PCM_FORMAT_S16_LE: 1061 + switch (params_width(params)) { 1062 + case 16: 1063 1063 aif_ctrl = DA9055_AIF_WORD_S16_LE; 1064 1064 break; 1065 - case SNDRV_PCM_FORMAT_S20_3LE: 1065 + case 20: 1066 1066 aif_ctrl = DA9055_AIF_WORD_S20_3LE; 1067 1067 break; 1068 - case SNDRV_PCM_FORMAT_S24_LE: 1068 + case 24: 1069 1069 aif_ctrl = DA9055_AIF_WORD_S24_LE; 1070 1070 break; 1071 - case SNDRV_PCM_FORMAT_S32_LE: 1071 + case 32: 1072 1072 aif_ctrl = DA9055_AIF_WORD_S32_LE; 1073 1073 break; 1074 1074 default:
+3 -3
sound/soc/codecs/isabelle.c
··· 951 951 ISABELLE_FS_RATE_MASK, fs_val); 952 952 953 953 /* bit size */ 954 - switch (params_format(params)) { 955 - case SNDRV_PCM_FORMAT_S20_3LE: 954 + switch (params_width(params)) { 955 + case 20: 956 956 aif |= ISABELLE_AIF_LENGTH_20; 957 957 break; 958 - case SNDRV_PCM_FORMAT_S32_LE: 958 + case 32: 959 959 aif |= ISABELLE_AIF_LENGTH_32; 960 960 break; 961 961 default:
+3 -3
sound/soc/codecs/max98088.c
··· 1233 1233 1234 1234 rate = params_rate(params); 1235 1235 1236 - switch (params_format(params)) { 1237 - case SNDRV_PCM_FORMAT_S16_LE: 1236 + switch (params_width(params)) { 1237 + case 16: 1238 1238 snd_soc_update_bits(codec, M98088_REG_14_DAI1_FORMAT, 1239 1239 M98088_DAI_WS, 0); 1240 1240 break; 1241 - case SNDRV_PCM_FORMAT_S24_LE: 1241 + case 24: 1242 1242 snd_soc_update_bits(codec, M98088_REG_14_DAI1_FORMAT, 1243 1243 M98088_DAI_WS, M98088_DAI_WS); 1244 1244 break;
+2 -2
sound/soc/codecs/max98090.c
··· 1840 1840 1841 1841 max98090->lrclk = params_rate(params); 1842 1842 1843 - switch (params_format(params)) { 1844 - case SNDRV_PCM_FORMAT_S16_LE: 1843 + switch (params_width(params)) { 1844 + case 16: 1845 1845 snd_soc_update_bits(codec, M98090_REG_INTERFACE_FORMAT, 1846 1846 M98090_WS_MASK, 0); 1847 1847 break;
+3 -3
sound/soc/codecs/max98095.c
··· 1213 1213 1214 1214 rate = params_rate(params); 1215 1215 1216 - switch (params_format(params)) { 1217 - case SNDRV_PCM_FORMAT_S16_LE: 1216 + switch (params_width(params)) { 1217 + case 16: 1218 1218 snd_soc_update_bits(codec, M98095_02A_DAI1_FORMAT, 1219 1219 M98095_DAI_WS, 0); 1220 1220 break; 1221 - case SNDRV_PCM_FORMAT_S24_LE: 1221 + case 24: 1222 1222 snd_soc_update_bits(codec, M98095_02A_DAI1_FORMAT, 1223 1223 M98095_DAI_WS, M98095_DAI_WS); 1224 1224 break;
+4 -4
sound/soc/codecs/max9850.c
··· 149 149 snd_soc_write(codec, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); 150 150 snd_soc_write(codec, MAX9850_LRCLK_LSB, lrclk_div & 0xff); 151 151 152 - switch (params_format(params)) { 153 - case SNDRV_PCM_FORMAT_S16_LE: 152 + switch (params_width(params)) { 153 + case 16: 154 154 da = 0; 155 155 break; 156 - case SNDRV_PCM_FORMAT_S20_3LE: 156 + case 20: 157 157 da = 0x2; 158 158 break; 159 - case SNDRV_PCM_FORMAT_S24_LE: 159 + case 24: 160 160 da = 0x3; 161 161 break; 162 162 default:
+10 -24
sound/soc/codecs/mc13783.c
··· 750 750 .num_dapm_routes = ARRAY_SIZE(mc13783_routes), 751 751 }; 752 752 753 - static int mc13783_codec_probe(struct platform_device *pdev) 753 + static int __init mc13783_codec_probe(struct platform_device *pdev) 754 754 { 755 - struct mc13xxx *mc13xxx; 756 755 struct mc13783_priv *priv; 757 756 struct mc13xxx_codec_platform_data *pdata = pdev->dev.platform_data; 758 757 int ret; 759 758 760 - mc13xxx = dev_get_drvdata(pdev->dev.parent); 761 - 762 - 763 759 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 764 - if (priv == NULL) 760 + if (!priv) 765 761 return -ENOMEM; 766 762 767 - dev_set_drvdata(&pdev->dev, priv); 768 - priv->mc13xxx = mc13xxx; 769 763 if (pdata) { 770 764 priv->adc_ssi_port = pdata->adc_ssi_port; 771 765 priv->dac_ssi_port = pdata->dac_ssi_port; 772 766 } else { 773 - priv->adc_ssi_port = MC13783_SSI1_PORT; 774 - priv->dac_ssi_port = MC13783_SSI2_PORT; 767 + return -ENOSYS; 775 768 } 769 + 770 + dev_set_drvdata(&pdev->dev, priv); 771 + priv->mc13xxx = dev_get_drvdata(pdev->dev.parent); 776 772 777 773 if (priv->adc_ssi_port == priv->dac_ssi_port) 778 774 ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, ··· 776 780 else 777 781 ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, 778 782 mc13783_dai_async, ARRAY_SIZE(mc13783_dai_async)); 779 - 780 - if (ret) 781 - goto err_register_codec; 782 - 783 - return 0; 784 - 785 - err_register_codec: 786 - dev_err(&pdev->dev, "register codec failed with %d\n", ret); 787 783 788 784 return ret; 789 785 } ··· 789 801 790 802 static struct platform_driver mc13783_codec_driver = { 791 803 .driver = { 792 - .name = "mc13783-codec", 793 - .owner = THIS_MODULE, 794 - }, 795 - .probe = mc13783_codec_probe, 804 + .name = "mc13783-codec", 805 + .owner = THIS_MODULE, 806 + }, 796 807 .remove = mc13783_codec_remove, 797 808 }; 798 - 799 - module_platform_driver(mc13783_codec_driver); 809 + module_platform_driver_probe(mc13783_codec_driver, mc13783_codec_probe); 800 810 801 811 MODULE_DESCRIPTION("ASoC MC13783 driver"); 802 812 MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>");
+10 -4
sound/soc/codecs/ssm2602.c
··· 194 194 }; 195 195 196 196 static const unsigned int ssm2602_rates_12288000[] = { 197 - 8000, 32000, 48000, 96000, 197 + 8000, 16000, 32000, 48000, 96000, 198 198 }; 199 199 200 200 static struct snd_pcm_hw_constraint_list ssm2602_constraints_12288000 = { ··· 230 230 {12288000, 32000, SSM2602_COEFF_SRATE(0x6, 0x0, 0x0)}, 231 231 {18432000, 32000, SSM2602_COEFF_SRATE(0x6, 0x1, 0x0)}, 232 232 {12000000, 32000, SSM2602_COEFF_SRATE(0x6, 0x0, 0x1)}, 233 + 234 + /* 16k */ 235 + {12288000, 16000, SSM2602_COEFF_SRATE(0x5, 0x0, 0x0)}, 236 + {18432000, 16000, SSM2602_COEFF_SRATE(0x5, 0x1, 0x0)}, 237 + {12000000, 16000, SSM2602_COEFF_SRATE(0xa, 0x0, 0x1)}, 233 238 234 239 /* 8k */ 235 240 {12288000, 8000, SSM2602_COEFF_SRATE(0x3, 0x0, 0x0)}, ··· 478 473 return 0; 479 474 } 480 475 481 - #define SSM2602_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_32000 |\ 482 - SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ 483 - SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) 476 + #define SSM2602_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ 477 + SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ 478 + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\ 479 + SNDRV_PCM_RATE_96000) 484 480 485 481 #define SSM2602_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 486 482 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
+136 -244
sound/soc/codecs/twl4030.c
··· 48 48 49 49 #define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1) 50 50 51 - /* 52 - * twl4030 register cache & default register settings 53 - */ 54 - static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { 55 - 0x00, /* this register not used */ 56 - 0x00, /* REG_CODEC_MODE (0x1) */ 57 - 0x00, /* REG_OPTION (0x2) */ 58 - 0x00, /* REG_UNKNOWN (0x3) */ 59 - 0x00, /* REG_MICBIAS_CTL (0x4) */ 60 - 0x00, /* REG_ANAMICL (0x5) */ 61 - 0x00, /* REG_ANAMICR (0x6) */ 62 - 0x00, /* REG_AVADC_CTL (0x7) */ 63 - 0x00, /* REG_ADCMICSEL (0x8) */ 64 - 0x00, /* REG_DIGMIXING (0x9) */ 65 - 0x0f, /* REG_ATXL1PGA (0xA) */ 66 - 0x0f, /* REG_ATXR1PGA (0xB) */ 67 - 0x0f, /* REG_AVTXL2PGA (0xC) */ 68 - 0x0f, /* REG_AVTXR2PGA (0xD) */ 69 - 0x00, /* REG_AUDIO_IF (0xE) */ 70 - 0x00, /* REG_VOICE_IF (0xF) */ 71 - 0x3f, /* REG_ARXR1PGA (0x10) */ 72 - 0x3f, /* REG_ARXL1PGA (0x11) */ 73 - 0x3f, /* REG_ARXR2PGA (0x12) */ 74 - 0x3f, /* REG_ARXL2PGA (0x13) */ 75 - 0x25, /* REG_VRXPGA (0x14) */ 76 - 0x00, /* REG_VSTPGA (0x15) */ 77 - 0x00, /* REG_VRX2ARXPGA (0x16) */ 78 - 0x00, /* REG_AVDAC_CTL (0x17) */ 79 - 0x00, /* REG_ARX2VTXPGA (0x18) */ 80 - 0x32, /* REG_ARXL1_APGA_CTL (0x19) */ 81 - 0x32, /* REG_ARXR1_APGA_CTL (0x1A) */ 82 - 0x32, /* REG_ARXL2_APGA_CTL (0x1B) */ 83 - 0x32, /* REG_ARXR2_APGA_CTL (0x1C) */ 84 - 0x00, /* REG_ATX2ARXPGA (0x1D) */ 85 - 0x00, /* REG_BT_IF (0x1E) */ 86 - 0x55, /* REG_BTPGA (0x1F) */ 87 - 0x00, /* REG_BTSTPGA (0x20) */ 88 - 0x00, /* REG_EAR_CTL (0x21) */ 89 - 0x00, /* REG_HS_SEL (0x22) */ 90 - 0x00, /* REG_HS_GAIN_SET (0x23) */ 91 - 0x00, /* REG_HS_POPN_SET (0x24) */ 92 - 0x00, /* REG_PREDL_CTL (0x25) */ 93 - 0x00, /* REG_PREDR_CTL (0x26) */ 94 - 0x00, /* REG_PRECKL_CTL (0x27) */ 95 - 0x00, /* REG_PRECKR_CTL (0x28) */ 96 - 0x00, /* REG_HFL_CTL (0x29) */ 97 - 0x00, /* REG_HFR_CTL (0x2A) */ 98 - 0x05, /* REG_ALC_CTL (0x2B) */ 99 - 0x00, /* REG_ALC_SET1 (0x2C) */ 100 - 0x00, /* REG_ALC_SET2 (0x2D) */ 101 - 0x00, /* REG_BOOST_CTL (0x2E) */ 102 - 0x00, /* REG_SOFTVOL_CTL (0x2F) */ 103 - 0x13, /* REG_DTMF_FREQSEL (0x30) */ 104 - 0x00, /* REG_DTMF_TONEXT1H (0x31) */ 105 - 0x00, /* REG_DTMF_TONEXT1L (0x32) */ 106 - 0x00, /* REG_DTMF_TONEXT2H (0x33) */ 107 - 0x00, /* REG_DTMF_TONEXT2L (0x34) */ 108 - 0x79, /* REG_DTMF_TONOFF (0x35) */ 109 - 0x11, /* REG_DTMF_WANONOFF (0x36) */ 110 - 0x00, /* REG_I2S_RX_SCRAMBLE_H (0x37) */ 111 - 0x00, /* REG_I2S_RX_SCRAMBLE_M (0x38) */ 112 - 0x00, /* REG_I2S_RX_SCRAMBLE_L (0x39) */ 113 - 0x06, /* REG_APLL_CTL (0x3A) */ 114 - 0x00, /* REG_DTMF_CTL (0x3B) */ 115 - 0x44, /* REG_DTMF_PGA_CTL2 (0x3C) */ 116 - 0x69, /* REG_DTMF_PGA_CTL1 (0x3D) */ 117 - 0x00, /* REG_MISC_SET_1 (0x3E) */ 118 - 0x00, /* REG_PCMBTMUX (0x3F) */ 119 - 0x00, /* not used (0x40) */ 120 - 0x00, /* not used (0x41) */ 121 - 0x00, /* not used (0x42) */ 122 - 0x00, /* REG_RX_PATH_SEL (0x43) */ 123 - 0x32, /* REG_VDL_APGA_CTL (0x44) */ 124 - 0x00, /* REG_VIBRA_CTL (0x45) */ 125 - 0x00, /* REG_VIBRA_SET (0x46) */ 126 - 0x00, /* REG_VIBRA_PWM_SET (0x47) */ 127 - 0x00, /* REG_ANAMIC_GAIN (0x48) */ 128 - 0x00, /* REG_MISC_SET_2 (0x49) */ 129 - }; 130 - 131 51 /* codec private data */ 132 52 struct twl4030_priv { 133 53 unsigned int codec_powered; ··· 70 150 u8 earpiece_enabled; 71 151 u8 predrivel_enabled, predriver_enabled; 72 152 u8 carkitl_enabled, carkitr_enabled; 153 + u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1]; 73 154 74 155 struct twl4030_codec_data *pdata; 75 156 }; 76 157 77 - /* 78 - * read twl4030 register cache 79 - */ 80 - static inline unsigned int twl4030_read_reg_cache(struct snd_soc_codec *codec, 81 - unsigned int reg) 158 + static void tw4030_init_ctl_cache(struct twl4030_priv *twl4030) 82 159 { 83 - u8 *cache = codec->reg_cache; 160 + int i; 161 + u8 byte; 162 + 163 + for (i = TWL4030_REG_EAR_CTL; i <= TWL4030_REG_PRECKR_CTL; i++) { 164 + twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, i); 165 + twl4030->ctl_cache[i - TWL4030_REG_EAR_CTL] = byte; 166 + } 167 + } 168 + 169 + static unsigned int twl4030_read(struct snd_soc_codec *codec, unsigned int reg) 170 + { 171 + struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 172 + u8 value = 0; 84 173 85 174 if (reg >= TWL4030_CACHEREGNUM) 86 175 return -EIO; 87 176 88 - return cache[reg]; 177 + switch (reg) { 178 + case TWL4030_REG_EAR_CTL: 179 + case TWL4030_REG_PREDL_CTL: 180 + case TWL4030_REG_PREDR_CTL: 181 + case TWL4030_REG_PRECKL_CTL: 182 + case TWL4030_REG_PRECKR_CTL: 183 + case TWL4030_REG_HS_GAIN_SET: 184 + value = twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL]; 185 + break; 186 + default: 187 + twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &value, reg); 188 + break; 189 + } 190 + 191 + return value; 89 192 } 90 193 91 - /* 92 - * write twl4030 register cache 93 - */ 94 - static inline void twl4030_write_reg_cache(struct snd_soc_codec *codec, 95 - u8 reg, u8 value) 194 + static bool twl4030_can_write_to_chip(struct twl4030_priv *twl4030, 195 + unsigned int reg) 96 196 { 97 - u8 *cache = codec->reg_cache; 197 + bool write_to_reg = false; 98 198 99 - if (reg >= TWL4030_CACHEREGNUM) 100 - return; 101 - cache[reg] = value; 102 - } 103 - 104 - /* 105 - * write to the twl4030 register space 106 - */ 107 - static int twl4030_write(struct snd_soc_codec *codec, 108 - unsigned int reg, unsigned int value) 109 - { 110 - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 111 - int write_to_reg = 0; 112 - 113 - twl4030_write_reg_cache(codec, reg, value); 114 199 /* Decide if the given register can be written */ 115 200 switch (reg) { 116 201 case TWL4030_REG_EAR_CTL: 117 202 if (twl4030->earpiece_enabled) 118 - write_to_reg = 1; 203 + write_to_reg = true; 119 204 break; 120 205 case TWL4030_REG_PREDL_CTL: 121 206 if (twl4030->predrivel_enabled) 122 - write_to_reg = 1; 207 + write_to_reg = true; 123 208 break; 124 209 case TWL4030_REG_PREDR_CTL: 125 210 if (twl4030->predriver_enabled) 126 - write_to_reg = 1; 211 + write_to_reg = true; 127 212 break; 128 213 case TWL4030_REG_PRECKL_CTL: 129 214 if (twl4030->carkitl_enabled) 130 - write_to_reg = 1; 215 + write_to_reg = true; 131 216 break; 132 217 case TWL4030_REG_PRECKR_CTL: 133 218 if (twl4030->carkitr_enabled) 134 - write_to_reg = 1; 219 + write_to_reg = true; 135 220 break; 136 221 case TWL4030_REG_HS_GAIN_SET: 137 222 if (twl4030->hsl_enabled || twl4030->hsr_enabled) 138 - write_to_reg = 1; 223 + write_to_reg = true; 139 224 break; 140 225 default: 141 226 /* All other register can be written */ 142 - write_to_reg = 1; 227 + write_to_reg = true; 143 228 break; 144 229 } 145 - if (write_to_reg) 146 - return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, 147 - value, reg); 230 + 231 + return write_to_reg; 232 + } 233 + 234 + static int twl4030_write(struct snd_soc_codec *codec, unsigned int reg, 235 + unsigned int value) 236 + { 237 + struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 238 + 239 + /* Update the ctl cache */ 240 + switch (reg) { 241 + case TWL4030_REG_EAR_CTL: 242 + case TWL4030_REG_PREDL_CTL: 243 + case TWL4030_REG_PREDR_CTL: 244 + case TWL4030_REG_PRECKL_CTL: 245 + case TWL4030_REG_PRECKR_CTL: 246 + case TWL4030_REG_HS_GAIN_SET: 247 + twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL] = value; 248 + break; 249 + default: 250 + break; 251 + } 252 + 253 + if (twl4030_can_write_to_chip(twl4030, reg)) 254 + return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, reg); 148 255 149 256 return 0; 150 257 } ··· 199 252 else 200 253 mode = twl4030_audio_disable_resource(TWL4030_AUDIO_RES_POWER); 201 254 202 - if (mode >= 0) { 203 - twl4030_write_reg_cache(codec, TWL4030_REG_CODEC_MODE, mode); 255 + if (mode >= 0) 204 256 twl4030->codec_powered = enable; 205 - } 206 257 207 258 /* REVISIT: this delay is present in TI sample drivers */ 208 259 /* but there seems to be no TRM requirement for it */ 209 260 udelay(10); 210 - } 211 - 212 - static inline void twl4030_check_defaults(struct snd_soc_codec *codec) 213 - { 214 - int i, difference = 0; 215 - u8 val; 216 - 217 - dev_dbg(codec->dev, "Checking TWL audio default configuration\n"); 218 - for (i = 1; i <= TWL4030_REG_MISC_SET_2; i++) { 219 - twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val, i); 220 - if (val != twl4030_reg[i]) { 221 - difference++; 222 - dev_dbg(codec->dev, 223 - "Reg 0x%02x: chip: 0x%02x driver: 0x%02x\n", 224 - i, val, twl4030_reg[i]); 225 - } 226 - } 227 - dev_dbg(codec->dev, "Found %d non-matching registers. %s\n", 228 - difference, difference ? "Not OK" : "OK"); 229 - } 230 - 231 - static inline void twl4030_reset_registers(struct snd_soc_codec *codec) 232 - { 233 - int i; 234 - 235 - /* set all audio section registers to reasonable defaults */ 236 - for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++) 237 - if (i != TWL4030_REG_APLL_CTL) 238 - twl4030_write(codec, i, twl4030_reg[i]); 239 - 240 261 } 241 262 242 263 static void twl4030_setup_pdata_of(struct twl4030_codec_data *pdata, ··· 287 372 } 288 373 } 289 374 290 - /* Check defaults, if instructed before anything else */ 291 - if (pdata && pdata->check_defaults) 292 - twl4030_check_defaults(codec); 293 - 294 - /* Reset registers, if no setup data or if instructed to do so */ 295 - if (!pdata || (pdata && pdata->reset_registers)) 296 - twl4030_reset_registers(codec); 297 - 298 - /* Refresh APLL_CTL register from HW */ 299 - twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, 300 - TWL4030_REG_APLL_CTL); 301 - twl4030_write_reg_cache(codec, TWL4030_REG_APLL_CTL, byte); 375 + /* Initialize the local ctl register cache */ 376 + tw4030_init_ctl_cache(twl4030); 302 377 303 378 /* anti-pop when changing analog gain */ 304 - reg = twl4030_read_reg_cache(codec, TWL4030_REG_MISC_SET_1); 379 + reg = twl4030_read(codec, TWL4030_REG_MISC_SET_1); 305 380 twl4030_write(codec, TWL4030_REG_MISC_SET_1, 306 - reg | TWL4030_SMOOTH_ANAVOL_EN); 381 + reg | TWL4030_SMOOTH_ANAVOL_EN); 307 382 308 383 twl4030_write(codec, TWL4030_REG_OPTION, 309 - TWL4030_ATXL1_EN | TWL4030_ATXR1_EN | 310 - TWL4030_ARXL2_EN | TWL4030_ARXR2_EN); 384 + TWL4030_ATXL1_EN | TWL4030_ATXR1_EN | 385 + TWL4030_ARXL2_EN | TWL4030_ARXR2_EN); 311 386 312 387 /* REG_ARXR2_APGA_CTL reset according to the TRM: 0dB, DA_EN */ 313 388 twl4030_write(codec, TWL4030_REG_ARXR2_APGA_CTL, 0x32); ··· 308 403 309 404 twl4030->pdata = pdata; 310 405 311 - reg = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); 406 + reg = twl4030_read(codec, TWL4030_REG_HS_POPN_SET); 312 407 reg &= ~TWL4030_RAMP_DELAY; 313 408 reg |= (pdata->ramp_delay_value << 2); 314 - twl4030_write_reg_cache(codec, TWL4030_REG_HS_POPN_SET, reg); 409 + twl4030_write(codec, TWL4030_REG_HS_POPN_SET, reg); 315 410 316 411 /* initiate offset cancellation */ 317 412 twl4030_codec_enable(codec, 1); 318 413 319 - reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); 414 + reg = twl4030_read(codec, TWL4030_REG_ANAMICL); 320 415 reg &= ~TWL4030_OFFSET_CNCL_SEL; 321 416 reg |= pdata->offset_cncl_path; 322 417 twl4030_write(codec, TWL4030_REG_ANAMICL, 323 - reg | TWL4030_CNCL_OFFSET_START); 418 + reg | TWL4030_CNCL_OFFSET_START); 324 419 325 420 /* 326 421 * Wait for offset cancellation to complete. ··· 330 425 msleep(20); 331 426 do { 332 427 usleep_range(1000, 2000); 428 + twl_set_regcache_bypass(TWL4030_MODULE_AUDIO_VOICE, true); 333 429 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, 334 - TWL4030_REG_ANAMICL); 430 + TWL4030_REG_ANAMICL); 431 + twl_set_regcache_bypass(TWL4030_MODULE_AUDIO_VOICE, false); 335 432 } while ((i++ < 100) && 336 433 ((byte & TWL4030_CNCL_OFFSET_START) == 337 434 TWL4030_CNCL_OFFSET_START)); 338 - 339 - /* Make sure that the reg_cache has the same value as the HW */ 340 - twl4030_write_reg_cache(codec, TWL4030_REG_ANAMICL, byte); 341 435 342 436 twl4030_codec_enable(codec, 0); 343 437 } ··· 357 453 status = twl4030_audio_disable_resource( 358 454 TWL4030_AUDIO_RES_APLL); 359 455 } 360 - 361 - if (status >= 0) 362 - twl4030_write_reg_cache(codec, TWL4030_REG_APLL_CTL, status); 363 456 } 364 457 365 458 /* Earpiece */ ··· 572 671 */ 573 672 #define TWL4030_OUTPUT_PGA(pin_name, reg, mask) \ 574 673 static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \ 575 - struct snd_kcontrol *kcontrol, int event) \ 674 + struct snd_kcontrol *kcontrol, int event) \ 576 675 { \ 577 676 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); \ 578 677 \ 579 678 switch (event) { \ 580 679 case SND_SOC_DAPM_POST_PMU: \ 581 680 twl4030->pin_name##_enabled = 1; \ 582 - twl4030_write(w->codec, reg, \ 583 - twl4030_read_reg_cache(w->codec, reg)); \ 681 + twl4030_write(w->codec, reg, twl4030_read(w->codec, reg)); \ 584 682 break; \ 585 683 case SND_SOC_DAPM_POST_PMD: \ 586 684 twl4030->pin_name##_enabled = 0; \ 587 - twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, \ 588 - 0, reg); \ 685 + twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, 0, reg); \ 589 686 break; \ 590 687 } \ 591 688 return 0; \ ··· 599 700 { 600 701 unsigned char hs_ctl; 601 702 602 - hs_ctl = twl4030_read_reg_cache(codec, reg); 703 + hs_ctl = twl4030_read(codec, reg); 603 704 604 705 if (ramp) { 605 706 /* HF ramp-up */ ··· 626 727 } 627 728 628 729 static int handsfreelpga_event(struct snd_soc_dapm_widget *w, 629 - struct snd_kcontrol *kcontrol, int event) 730 + struct snd_kcontrol *kcontrol, int event) 630 731 { 631 732 switch (event) { 632 733 case SND_SOC_DAPM_POST_PMU: ··· 640 741 } 641 742 642 743 static int handsfreerpga_event(struct snd_soc_dapm_widget *w, 643 - struct snd_kcontrol *kcontrol, int event) 744 + struct snd_kcontrol *kcontrol, int event) 644 745 { 645 746 switch (event) { 646 747 case SND_SOC_DAPM_POST_PMU: ··· 654 755 } 655 756 656 757 static int vibramux_event(struct snd_soc_dapm_widget *w, 657 - struct snd_kcontrol *kcontrol, int event) 758 + struct snd_kcontrol *kcontrol, int event) 658 759 { 659 760 twl4030_write(w->codec, TWL4030_REG_VIBRA_SET, 0xff); 660 761 return 0; 661 762 } 662 763 663 764 static int apll_event(struct snd_soc_dapm_widget *w, 664 - struct snd_kcontrol *kcontrol, int event) 765 + struct snd_kcontrol *kcontrol, int event) 665 766 { 666 767 switch (event) { 667 768 case SND_SOC_DAPM_PRE_PMU: ··· 675 776 } 676 777 677 778 static int aif_event(struct snd_soc_dapm_widget *w, 678 - struct snd_kcontrol *kcontrol, int event) 779 + struct snd_kcontrol *kcontrol, int event) 679 780 { 680 781 u8 audio_if; 681 782 682 - audio_if = twl4030_read_reg_cache(w->codec, TWL4030_REG_AUDIO_IF); 783 + audio_if = twl4030_read(w->codec, TWL4030_REG_AUDIO_IF); 683 784 switch (event) { 684 785 case SND_SOC_DAPM_PRE_PMU: 685 786 /* Enable AIF */ ··· 687 788 twl4030_apll_enable(w->codec, 1); 688 789 689 790 twl4030_write(w->codec, TWL4030_REG_AUDIO_IF, 690 - audio_if | TWL4030_AIF_EN); 791 + audio_if | TWL4030_AIF_EN); 691 792 break; 692 793 case SND_SOC_DAPM_POST_PMD: 693 794 /* disable the DAI before we stop it's source PLL */ 694 795 twl4030_write(w->codec, TWL4030_REG_AUDIO_IF, 695 - audio_if & ~TWL4030_AIF_EN); 796 + audio_if & ~TWL4030_AIF_EN); 696 797 twl4030_apll_enable(w->codec, 0); 697 798 break; 698 799 } ··· 709 810 8388608, 16777216, 33554432, 67108864}; 710 811 unsigned int delay; 711 812 712 - hs_gain = twl4030_read_reg_cache(codec, TWL4030_REG_HS_GAIN_SET); 713 - hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); 813 + hs_gain = twl4030_read(codec, TWL4030_REG_HS_GAIN_SET); 814 + hs_pop = twl4030_read(codec, TWL4030_REG_HS_POPN_SET); 714 815 delay = (ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / 715 816 twl4030->sysclk) + 1; 716 817 ··· 730 831 hs_pop |= TWL4030_VMID_EN; 731 832 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); 732 833 /* Actually write to the register */ 733 - twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, 734 - hs_gain, 735 - TWL4030_REG_HS_GAIN_SET); 834 + twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, hs_gain, 835 + TWL4030_REG_HS_GAIN_SET); 736 836 hs_pop |= TWL4030_RAMP_EN; 737 837 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); 738 838 /* Wait ramp delay time + 1, so the VMID can settle */ ··· 744 846 /* Wait ramp delay time + 1, so the VMID can settle */ 745 847 twl4030_wait_ms(delay); 746 848 /* Bypass the reg_cache to mute the headset */ 747 - twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, 748 - hs_gain & (~0x0f), 749 - TWL4030_REG_HS_GAIN_SET); 849 + twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, hs_gain & (~0x0f), 850 + TWL4030_REG_HS_GAIN_SET); 750 851 751 852 hs_pop &= ~TWL4030_VMID_EN; 752 853 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); ··· 763 866 } 764 867 765 868 static int headsetlpga_event(struct snd_soc_dapm_widget *w, 766 - struct snd_kcontrol *kcontrol, int event) 869 + struct snd_kcontrol *kcontrol, int event) 767 870 { 768 871 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 769 872 ··· 787 890 } 788 891 789 892 static int headsetrpga_event(struct snd_soc_dapm_widget *w, 790 - struct snd_kcontrol *kcontrol, int event) 893 + struct snd_kcontrol *kcontrol, int event) 791 894 { 792 895 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 793 896 ··· 811 914 } 812 915 813 916 static int digimic_event(struct snd_soc_dapm_widget *w, 814 - struct snd_kcontrol *kcontrol, int event) 917 + struct snd_kcontrol *kcontrol, int event) 815 918 { 816 919 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 817 920 struct twl4030_codec_data *pdata = twl4030->pdata; ··· 832 935 * Custom volsw and volsw_2r get/put functions to handle these gain bits. 833 936 */ 834 937 static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol, 835 - struct snd_ctl_elem_value *ucontrol) 938 + struct snd_ctl_elem_value *ucontrol) 836 939 { 837 940 struct soc_mixer_control *mc = 838 941 (struct soc_mixer_control *)kcontrol->private_value; ··· 861 964 } 862 965 863 966 static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol, 864 - struct snd_ctl_elem_value *ucontrol) 967 + struct snd_ctl_elem_value *ucontrol) 865 968 { 866 969 struct soc_mixer_control *mc = 867 970 (struct soc_mixer_control *)kcontrol->private_value; ··· 890 993 } 891 994 892 995 static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, 893 - struct snd_ctl_elem_value *ucontrol) 996 + struct snd_ctl_elem_value *ucontrol) 894 997 { 895 998 struct soc_mixer_control *mc = 896 999 (struct soc_mixer_control *)kcontrol->private_value; ··· 917 1020 } 918 1021 919 1022 static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, 920 - struct snd_ctl_elem_value *ucontrol) 1023 + struct snd_ctl_elem_value *ucontrol) 921 1024 { 922 1025 struct soc_mixer_control *mc = 923 1026 (struct soc_mixer_control *)kcontrol->private_value; ··· 1648 1751 /* In case of 4 channel mode, the RX1 L/R for playback and the TX2 L/R for 1649 1752 * capture has to be enabled/disabled. */ 1650 1753 static void twl4030_tdm_enable(struct snd_soc_codec *codec, int direction, 1651 - int enable) 1754 + int enable) 1652 1755 { 1653 1756 u8 reg, mask; 1654 1757 1655 - reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION); 1758 + reg = twl4030_read(codec, TWL4030_REG_OPTION); 1656 1759 1657 1760 if (direction == SNDRV_PCM_STREAM_PLAYBACK) 1658 1761 mask = TWL4030_ARXL1_VRX_EN | TWL4030_ARXR1_EN; ··· 1681 1784 if (twl4030->configured) 1682 1785 twl4030_constraints(twl4030, twl4030->master_substream); 1683 1786 } else { 1684 - if (!(twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) & 1787 + if (!(twl4030_read(codec, TWL4030_REG_CODEC_MODE) & 1685 1788 TWL4030_OPTION_1)) { 1686 1789 /* In option2 4 channel is not supported, set the 1687 1790 * constraint for the first stream for channels, the 1688 1791 * second stream will 'inherit' this cosntraint */ 1689 1792 snd_pcm_hw_constraint_minmax(substream->runtime, 1690 - SNDRV_PCM_HW_PARAM_CHANNELS, 1691 - 2, 2); 1793 + SNDRV_PCM_HW_PARAM_CHANNELS, 1794 + 2, 2); 1692 1795 } 1693 1796 twl4030->master_substream = substream; 1694 1797 } ··· 1720 1823 } 1721 1824 1722 1825 static int twl4030_hw_params(struct snd_pcm_substream *substream, 1723 - struct snd_pcm_hw_params *params, 1724 - struct snd_soc_dai *dai) 1826 + struct snd_pcm_hw_params *params, 1827 + struct snd_soc_dai *dai) 1725 1828 { 1726 1829 struct snd_soc_codec *codec = dai->codec; 1727 1830 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); ··· 1729 1832 1730 1833 /* If the substream has 4 channel, do the necessary setup */ 1731 1834 if (params_channels(params) == 4) { 1732 - format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); 1733 - mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE); 1835 + format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); 1836 + mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE); 1734 1837 1735 1838 /* Safety check: are we in the correct operating mode and 1736 1839 * the interface is in TDM mode? */ ··· 1746 1849 return 0; 1747 1850 1748 1851 /* bit rate */ 1749 - old_mode = twl4030_read_reg_cache(codec, 1750 - TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; 1852 + old_mode = twl4030_read(codec, 1853 + TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; 1751 1854 mode = old_mode & ~TWL4030_APLL_RATE; 1752 1855 1753 1856 switch (params_rate(params)) { ··· 1788 1891 } 1789 1892 1790 1893 /* sample size */ 1791 - old_format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); 1894 + old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); 1792 1895 format = old_format; 1793 1896 format &= ~TWL4030_DATA_WIDTH; 1794 1897 switch (params_format(params)) { ··· 1837 1940 return 0; 1838 1941 } 1839 1942 1840 - static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, 1841 - int clk_id, unsigned int freq, int dir) 1943 + static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, 1944 + unsigned int freq, int dir) 1842 1945 { 1843 1946 struct snd_soc_codec *codec = codec_dai->codec; 1844 1947 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); ··· 1863 1966 return 0; 1864 1967 } 1865 1968 1866 - static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, 1867 - unsigned int fmt) 1969 + static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) 1868 1970 { 1869 1971 struct snd_soc_codec *codec = codec_dai->codec; 1870 1972 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 1871 1973 u8 old_format, format; 1872 1974 1873 1975 /* get format */ 1874 - old_format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); 1976 + old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); 1875 1977 format = old_format; 1876 1978 1877 1979 /* set master/slave audio interface */ ··· 1920 2024 static int twl4030_set_tristate(struct snd_soc_dai *dai, int tristate) 1921 2025 { 1922 2026 struct snd_soc_codec *codec = dai->codec; 1923 - u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); 2027 + u8 reg = twl4030_read(codec, TWL4030_REG_AUDIO_IF); 1924 2028 1925 2029 if (tristate) 1926 2030 reg |= TWL4030_AIF_TRI_EN; ··· 1933 2037 /* In case of voice mode, the RX1 L(VRX) for downlink and the TX2 L/R 1934 2038 * (VTXL, VTXR) for uplink has to be enabled/disabled. */ 1935 2039 static void twl4030_voice_enable(struct snd_soc_codec *codec, int direction, 1936 - int enable) 2040 + int enable) 1937 2041 { 1938 2042 u8 reg, mask; 1939 2043 1940 - reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION); 2044 + reg = twl4030_read(codec, TWL4030_REG_OPTION); 1941 2045 1942 2046 if (direction == SNDRV_PCM_STREAM_PLAYBACK) 1943 2047 mask = TWL4030_ARXL1_VRX_EN; ··· 1953 2057 } 1954 2058 1955 2059 static int twl4030_voice_startup(struct snd_pcm_substream *substream, 1956 - struct snd_soc_dai *dai) 2060 + struct snd_soc_dai *dai) 1957 2061 { 1958 2062 struct snd_soc_codec *codec = dai->codec; 1959 2063 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); ··· 1972 2076 /* If the codec mode is not option2, the voice PCM interface is not 1973 2077 * available. 1974 2078 */ 1975 - mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) 2079 + mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE) 1976 2080 & TWL4030_OPT_MODE; 1977 2081 1978 2082 if (mode != TWL4030_OPTION_2) { ··· 1985 2089 } 1986 2090 1987 2091 static void twl4030_voice_shutdown(struct snd_pcm_substream *substream, 1988 - struct snd_soc_dai *dai) 2092 + struct snd_soc_dai *dai) 1989 2093 { 1990 2094 struct snd_soc_codec *codec = dai->codec; 1991 2095 ··· 1994 2098 } 1995 2099 1996 2100 static int twl4030_voice_hw_params(struct snd_pcm_substream *substream, 1997 - struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 2101 + struct snd_pcm_hw_params *params, 2102 + struct snd_soc_dai *dai) 1998 2103 { 1999 2104 struct snd_soc_codec *codec = dai->codec; 2000 2105 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); ··· 2005 2108 twl4030_voice_enable(codec, substream->stream, 1); 2006 2109 2007 2110 /* bit rate */ 2008 - old_mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) 2009 - & ~(TWL4030_CODECPDZ); 2111 + old_mode = twl4030_read(codec, 2112 + TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; 2010 2113 mode = old_mode; 2011 2114 2012 2115 switch (params_rate(params)) { ··· 2040 2143 } 2041 2144 2042 2145 static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, 2043 - int clk_id, unsigned int freq, int dir) 2146 + int clk_id, unsigned int freq, int dir) 2044 2147 { 2045 2148 struct snd_soc_codec *codec = codec_dai->codec; 2046 2149 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); ··· 2061 2164 } 2062 2165 2063 2166 static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, 2064 - unsigned int fmt) 2167 + unsigned int fmt) 2065 2168 { 2066 2169 struct snd_soc_codec *codec = codec_dai->codec; 2067 2170 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 2068 2171 u8 old_format, format; 2069 2172 2070 2173 /* get format */ 2071 - old_format = twl4030_read_reg_cache(codec, TWL4030_REG_VOICE_IF); 2174 + old_format = twl4030_read(codec, TWL4030_REG_VOICE_IF); 2072 2175 format = old_format; 2073 2176 2074 2177 /* set master/slave audio interface */ ··· 2115 2218 static int twl4030_voice_set_tristate(struct snd_soc_dai *dai, int tristate) 2116 2219 { 2117 2220 struct snd_soc_codec *codec = dai->codec; 2118 - u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_VOICE_IF); 2221 + u8 reg = twl4030_read(codec, TWL4030_REG_VOICE_IF); 2119 2222 2120 2223 if (tristate) 2121 2224 reg |= TWL4030_VIF_TRI_EN; ··· 2207 2310 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 2208 2311 struct twl4030_codec_data *pdata = twl4030->pdata; 2209 2312 2210 - /* Reset registers to their chip default before leaving */ 2211 - twl4030_reset_registers(codec); 2212 2313 twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF); 2213 2314 2214 2315 if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio)) ··· 2218 2323 static struct snd_soc_codec_driver soc_codec_dev_twl4030 = { 2219 2324 .probe = twl4030_soc_probe, 2220 2325 .remove = twl4030_soc_remove, 2221 - .read = twl4030_read_reg_cache, 2326 + .read = twl4030_read, 2222 2327 .write = twl4030_write, 2223 2328 .set_bias_level = twl4030_set_bias_level, 2224 2329 .idle_bias_off = true, 2225 - .reg_cache_size = sizeof(twl4030_reg), 2226 - .reg_word_size = sizeof(u8), 2227 - .reg_cache_default = twl4030_reg, 2228 2330 2229 2331 .controls = twl4030_snd_controls, 2230 2332 .num_controls = ARRAY_SIZE(twl4030_snd_controls), ··· 2234 2342 static int twl4030_codec_probe(struct platform_device *pdev) 2235 2343 { 2236 2344 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_twl4030, 2237 - twl4030_dai, ARRAY_SIZE(twl4030_dai)); 2345 + twl4030_dai, ARRAY_SIZE(twl4030_dai)); 2238 2346 } 2239 2347 2240 2348 static int twl4030_codec_remove(struct platform_device *pdev)
+128 -85
sound/soc/codecs/wm_adsp.c
··· 1497 1497 return 0; 1498 1498 } 1499 1499 1500 + static void wm_adsp2_boot_work(struct work_struct *work) 1501 + { 1502 + struct wm_adsp *dsp = container_of(work, 1503 + struct wm_adsp, 1504 + boot_work); 1505 + int ret; 1506 + unsigned int val; 1507 + 1508 + /* 1509 + * For simplicity set the DSP clock rate to be the 1510 + * SYSCLK rate rather than making it configurable. 1511 + */ 1512 + ret = regmap_read(dsp->regmap, ARIZONA_SYSTEM_CLOCK_1, &val); 1513 + if (ret != 0) { 1514 + adsp_err(dsp, "Failed to read SYSCLK state: %d\n", ret); 1515 + return; 1516 + } 1517 + val = (val & ARIZONA_SYSCLK_FREQ_MASK) 1518 + >> ARIZONA_SYSCLK_FREQ_SHIFT; 1519 + 1520 + ret = regmap_update_bits_async(dsp->regmap, 1521 + dsp->base + ADSP2_CLOCKING, 1522 + ADSP2_CLK_SEL_MASK, val); 1523 + if (ret != 0) { 1524 + adsp_err(dsp, "Failed to set clock rate: %d\n", ret); 1525 + return; 1526 + } 1527 + 1528 + if (dsp->dvfs) { 1529 + ret = regmap_read(dsp->regmap, 1530 + dsp->base + ADSP2_CLOCKING, &val); 1531 + if (ret != 0) { 1532 + dev_err(dsp->dev, "Failed to read clocking: %d\n", ret); 1533 + return; 1534 + } 1535 + 1536 + if ((val & ADSP2_CLK_SEL_MASK) >= 3) { 1537 + ret = regulator_enable(dsp->dvfs); 1538 + if (ret != 0) { 1539 + dev_err(dsp->dev, 1540 + "Failed to enable supply: %d\n", 1541 + ret); 1542 + return; 1543 + } 1544 + 1545 + ret = regulator_set_voltage(dsp->dvfs, 1546 + 1800000, 1547 + 1800000); 1548 + if (ret != 0) { 1549 + dev_err(dsp->dev, 1550 + "Failed to raise supply: %d\n", 1551 + ret); 1552 + return; 1553 + } 1554 + } 1555 + } 1556 + 1557 + ret = wm_adsp2_ena(dsp); 1558 + if (ret != 0) 1559 + return; 1560 + 1561 + ret = wm_adsp_load(dsp); 1562 + if (ret != 0) 1563 + goto err; 1564 + 1565 + ret = wm_adsp_setup_algs(dsp); 1566 + if (ret != 0) 1567 + goto err; 1568 + 1569 + ret = wm_adsp_load_coeff(dsp); 1570 + if (ret != 0) 1571 + goto err; 1572 + 1573 + /* Initialize caches for enabled and unset controls */ 1574 + ret = wm_coeff_init_control_caches(dsp); 1575 + if (ret != 0) 1576 + goto err; 1577 + 1578 + /* Sync set controls */ 1579 + ret = wm_coeff_sync_controls(dsp); 1580 + if (ret != 0) 1581 + goto err; 1582 + 1583 + ret = regmap_update_bits_async(dsp->regmap, 1584 + dsp->base + ADSP2_CONTROL, 1585 + ADSP2_CORE_ENA, 1586 + ADSP2_CORE_ENA); 1587 + if (ret != 0) 1588 + goto err; 1589 + 1590 + dsp->running = true; 1591 + 1592 + return; 1593 + 1594 + err: 1595 + regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, 1596 + ADSP2_SYS_ENA | ADSP2_CORE_ENA | ADSP2_START, 0); 1597 + } 1598 + 1599 + int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, 1600 + struct snd_kcontrol *kcontrol, int event) 1601 + { 1602 + struct snd_soc_codec *codec = w->codec; 1603 + struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); 1604 + struct wm_adsp *dsp = &dsps[w->shift]; 1605 + 1606 + dsp->card = codec->card; 1607 + 1608 + switch (event) { 1609 + case SND_SOC_DAPM_PRE_PMU: 1610 + queue_work(system_unbound_wq, &dsp->boot_work); 1611 + break; 1612 + default: 1613 + break; 1614 + }; 1615 + 1616 + return 0; 1617 + } 1618 + EXPORT_SYMBOL_GPL(wm_adsp2_early_event); 1619 + 1500 1620 int wm_adsp2_event(struct snd_soc_dapm_widget *w, 1501 1621 struct snd_kcontrol *kcontrol, int event) 1502 1622 { ··· 1625 1505 struct wm_adsp *dsp = &dsps[w->shift]; 1626 1506 struct wm_adsp_alg_region *alg_region; 1627 1507 struct wm_coeff_ctl *ctl; 1628 - unsigned int val; 1629 1508 int ret; 1630 - 1631 - dsp->card = codec->card; 1632 1509 1633 1510 switch (event) { 1634 1511 case SND_SOC_DAPM_POST_PMU: 1635 - /* 1636 - * For simplicity set the DSP clock rate to be the 1637 - * SYSCLK rate rather than making it configurable. 1638 - */ 1639 - ret = regmap_read(dsp->regmap, ARIZONA_SYSTEM_CLOCK_1, &val); 1640 - if (ret != 0) { 1641 - adsp_err(dsp, "Failed to read SYSCLK state: %d\n", 1642 - ret); 1643 - return ret; 1644 - } 1645 - val = (val & ARIZONA_SYSCLK_FREQ_MASK) 1646 - >> ARIZONA_SYSCLK_FREQ_SHIFT; 1512 + flush_work(&dsp->boot_work); 1647 1513 1648 - ret = regmap_update_bits_async(dsp->regmap, 1649 - dsp->base + ADSP2_CLOCKING, 1650 - ADSP2_CLK_SEL_MASK, val); 1651 - if (ret != 0) { 1652 - adsp_err(dsp, "Failed to set clock rate: %d\n", 1653 - ret); 1654 - return ret; 1655 - } 1514 + if (!dsp->running) 1515 + return -EIO; 1656 1516 1657 - if (dsp->dvfs) { 1658 - ret = regmap_read(dsp->regmap, 1659 - dsp->base + ADSP2_CLOCKING, &val); 1660 - if (ret != 0) { 1661 - dev_err(dsp->dev, 1662 - "Failed to read clocking: %d\n", ret); 1663 - return ret; 1664 - } 1665 - 1666 - if ((val & ADSP2_CLK_SEL_MASK) >= 3) { 1667 - ret = regulator_enable(dsp->dvfs); 1668 - if (ret != 0) { 1669 - dev_err(dsp->dev, 1670 - "Failed to enable supply: %d\n", 1671 - ret); 1672 - return ret; 1673 - } 1674 - 1675 - ret = regulator_set_voltage(dsp->dvfs, 1676 - 1800000, 1677 - 1800000); 1678 - if (ret != 0) { 1679 - dev_err(dsp->dev, 1680 - "Failed to raise supply: %d\n", 1681 - ret); 1682 - return ret; 1683 - } 1684 - } 1685 - } 1686 - 1687 - ret = wm_adsp2_ena(dsp); 1688 - if (ret != 0) 1689 - return ret; 1690 - 1691 - ret = wm_adsp_load(dsp); 1517 + ret = regmap_update_bits(dsp->regmap, 1518 + dsp->base + ADSP2_CONTROL, 1519 + ADSP2_START, 1520 + ADSP2_START); 1692 1521 if (ret != 0) 1693 1522 goto err; 1694 - 1695 - ret = wm_adsp_setup_algs(dsp); 1696 - if (ret != 0) 1697 - goto err; 1698 - 1699 - ret = wm_adsp_load_coeff(dsp); 1700 - if (ret != 0) 1701 - goto err; 1702 - 1703 - /* Initialize caches for enabled and unset controls */ 1704 - ret = wm_coeff_init_control_caches(dsp); 1705 - if (ret != 0) 1706 - goto err; 1707 - 1708 - /* Sync set controls */ 1709 - ret = wm_coeff_sync_controls(dsp); 1710 - if (ret != 0) 1711 - goto err; 1712 - 1713 - ret = regmap_update_bits_async(dsp->regmap, 1714 - dsp->base + ADSP2_CONTROL, 1715 - ADSP2_CORE_ENA | ADSP2_START, 1716 - ADSP2_CORE_ENA | ADSP2_START); 1717 - if (ret != 0) 1718 - goto err; 1719 - 1720 - dsp->running = true; 1721 1523 break; 1722 1524 1723 1525 case SND_SOC_DAPM_PRE_PMD: ··· 1710 1668 1711 1669 INIT_LIST_HEAD(&adsp->alg_regions); 1712 1670 INIT_LIST_HEAD(&adsp->ctl_list); 1671 + INIT_WORK(&adsp->boot_work, wm_adsp2_boot_work); 1713 1672 1714 1673 if (dvfs) { 1715 1674 adsp->dvfs = devm_regulator_get(adsp->dev, "DCVDD");
+10 -2
sound/soc/codecs/wm_adsp.h
··· 59 59 struct regulator *dvfs; 60 60 61 61 struct list_head ctl_list; 62 + 63 + struct work_struct boot_work; 62 64 }; 63 65 64 66 #define WM_ADSP1(wname, num) \ ··· 68 66 wm_adsp1_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD) 69 67 70 68 #define WM_ADSP2(wname, num) \ 71 - SND_SOC_DAPM_PGA_E(wname, SND_SOC_NOPM, num, 0, NULL, 0, \ 72 - wm_adsp2_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD) 69 + { .id = snd_soc_dapm_dai_link, .name = wname " Preloader", \ 70 + .reg = SND_SOC_NOPM, .shift = num, .event = wm_adsp2_early_event, \ 71 + .event_flags = SND_SOC_DAPM_PRE_PMU }, \ 72 + { .id = snd_soc_dapm_out_drv, .name = wname, \ 73 + .reg = SND_SOC_NOPM, .shift = num, .event = wm_adsp2_event, \ 74 + .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD } 73 75 74 76 extern const struct snd_kcontrol_new wm_adsp1_fw_controls[]; 75 77 extern const struct snd_kcontrol_new wm_adsp2_fw_controls[]; ··· 82 76 int wm_adsp2_init(struct wm_adsp *adsp, bool dvfs); 83 77 int wm_adsp1_event(struct snd_soc_dapm_widget *w, 84 78 struct snd_kcontrol *kcontrol, int event); 79 + int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, 80 + struct snd_kcontrol *kcontrol, int event); 85 81 int wm_adsp2_event(struct snd_soc_dapm_widget *w, 86 82 struct snd_kcontrol *kcontrol, int event); 87 83
+3
sound/soc/fsl/Kconfig
··· 8 8 config SND_SOC_FSL_SPDIF 9 9 tristate 10 10 11 + config SND_SOC_FSL_ESAI 12 + tristate 13 + 11 14 config SND_SOC_FSL_UTILS 12 15 tristate 13 16
+2
sound/soc/fsl/Makefile
··· 14 14 snd-soc-fsl-sai-objs := fsl_sai.o 15 15 snd-soc-fsl-ssi-objs := fsl_ssi.o 16 16 snd-soc-fsl-spdif-objs := fsl_spdif.o 17 + snd-soc-fsl-esai-objs := fsl_esai.o 17 18 snd-soc-fsl-utils-objs := fsl_utils.o 18 19 snd-soc-fsl-dma-objs := fsl_dma.o 19 20 obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o 20 21 obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o 21 22 obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o 23 + obj-$(CONFIG_SND_SOC_FSL_ESAI) += snd-soc-fsl-esai.o 22 24 obj-$(CONFIG_SND_SOC_FSL_UTILS) += snd-soc-fsl-utils.o 23 25 obj-$(CONFIG_SND_SOC_POWERPC_DMA) += snd-soc-fsl-dma.o 24 26
-7
sound/soc/fsl/fsl_dma.c
··· 55 55 SNDRV_PCM_FMTBIT_S32_BE | \ 56 56 SNDRV_PCM_FMTBIT_U32_LE | \ 57 57 SNDRV_PCM_FMTBIT_U32_BE) 58 - 59 - #define FSLDMA_PCM_RATES (SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_192000 | \ 60 - SNDRV_PCM_RATE_CONTINUOUS) 61 - 62 58 struct dma_object { 63 59 struct snd_soc_platform_driver dai; 64 60 dma_addr_t ssi_stx_phys; ··· 136 140 SNDRV_PCM_INFO_JOINT_DUPLEX | 137 141 SNDRV_PCM_INFO_PAUSE, 138 142 .formats = FSLDMA_PCM_FORMATS, 139 - .rates = FSLDMA_PCM_RATES, 140 - .rate_min = 5512, 141 - .rate_max = 192000, 142 143 .period_bytes_min = 512, /* A reasonable limit */ 143 144 .period_bytes_max = (u32) -1, 144 145 .periods_min = NUM_DMA_LINKS,
+815
sound/soc/fsl/fsl_esai.c
··· 1 + /* 2 + * Freescale ESAI ALSA SoC Digital Audio Interface (DAI) driver 3 + * 4 + * Copyright (C) 2014 Freescale Semiconductor, Inc. 5 + * 6 + * This file is licensed under the terms of the GNU General Public License 7 + * version 2. This program is licensed "as is" without any warranty of any 8 + * kind, whether express or implied. 9 + */ 10 + 11 + #include <linux/clk.h> 12 + #include <linux/dmaengine.h> 13 + #include <linux/module.h> 14 + #include <linux/of_irq.h> 15 + #include <linux/of_platform.h> 16 + #include <sound/dmaengine_pcm.h> 17 + #include <sound/pcm_params.h> 18 + 19 + #include "fsl_esai.h" 20 + #include "imx-pcm.h" 21 + 22 + #define FSL_ESAI_RATES SNDRV_PCM_RATE_8000_192000 23 + #define FSL_ESAI_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ 24 + SNDRV_PCM_FMTBIT_S16_LE | \ 25 + SNDRV_PCM_FMTBIT_S20_3LE | \ 26 + SNDRV_PCM_FMTBIT_S24_LE) 27 + 28 + /** 29 + * fsl_esai: ESAI private data 30 + * 31 + * @dma_params_rx: DMA parameters for receive channel 32 + * @dma_params_tx: DMA parameters for transmit channel 33 + * @pdev: platform device pointer 34 + * @regmap: regmap handler 35 + * @coreclk: clock source to access register 36 + * @extalclk: esai clock source to derive HCK, SCK and FS 37 + * @fsysclk: system clock source to derive HCK, SCK and FS 38 + * @fifo_depth: depth of tx/rx FIFO 39 + * @slot_width: width of each DAI slot 40 + * @hck_rate: clock rate of desired HCKx clock 41 + * @sck_div: if using PSR/PM dividers for SCKx clock 42 + * @slave_mode: if fully using DAI slave mode 43 + * @synchronous: if using tx/rx synchronous mode 44 + * @name: driver name 45 + */ 46 + struct fsl_esai { 47 + struct snd_dmaengine_dai_dma_data dma_params_rx; 48 + struct snd_dmaengine_dai_dma_data dma_params_tx; 49 + struct platform_device *pdev; 50 + struct regmap *regmap; 51 + struct clk *coreclk; 52 + struct clk *extalclk; 53 + struct clk *fsysclk; 54 + u32 fifo_depth; 55 + u32 slot_width; 56 + u32 hck_rate[2]; 57 + bool sck_div[2]; 58 + bool slave_mode; 59 + bool synchronous; 60 + char name[32]; 61 + }; 62 + 63 + static irqreturn_t esai_isr(int irq, void *devid) 64 + { 65 + struct fsl_esai *esai_priv = (struct fsl_esai *)devid; 66 + struct platform_device *pdev = esai_priv->pdev; 67 + u32 esr; 68 + 69 + regmap_read(esai_priv->regmap, REG_ESAI_ESR, &esr); 70 + 71 + if (esr & ESAI_ESR_TINIT_MASK) 72 + dev_dbg(&pdev->dev, "isr: Transmition Initialized\n"); 73 + 74 + if (esr & ESAI_ESR_RFF_MASK) 75 + dev_warn(&pdev->dev, "isr: Receiving overrun\n"); 76 + 77 + if (esr & ESAI_ESR_TFE_MASK) 78 + dev_warn(&pdev->dev, "isr: Transmition underrun\n"); 79 + 80 + if (esr & ESAI_ESR_TLS_MASK) 81 + dev_dbg(&pdev->dev, "isr: Just transmitted the last slot\n"); 82 + 83 + if (esr & ESAI_ESR_TDE_MASK) 84 + dev_dbg(&pdev->dev, "isr: Transmition data exception\n"); 85 + 86 + if (esr & ESAI_ESR_TED_MASK) 87 + dev_dbg(&pdev->dev, "isr: Transmitting even slots\n"); 88 + 89 + if (esr & ESAI_ESR_TD_MASK) 90 + dev_dbg(&pdev->dev, "isr: Transmitting data\n"); 91 + 92 + if (esr & ESAI_ESR_RLS_MASK) 93 + dev_dbg(&pdev->dev, "isr: Just received the last slot\n"); 94 + 95 + if (esr & ESAI_ESR_RDE_MASK) 96 + dev_dbg(&pdev->dev, "isr: Receiving data exception\n"); 97 + 98 + if (esr & ESAI_ESR_RED_MASK) 99 + dev_dbg(&pdev->dev, "isr: Receiving even slots\n"); 100 + 101 + if (esr & ESAI_ESR_RD_MASK) 102 + dev_dbg(&pdev->dev, "isr: Receiving data\n"); 103 + 104 + return IRQ_HANDLED; 105 + } 106 + 107 + /** 108 + * This function is used to calculate the divisors of psr, pm, fp and it is 109 + * supposed to be called in set_dai_sysclk() and set_bclk(). 110 + * 111 + * @ratio: desired overall ratio for the paticipating dividers 112 + * @usefp: for HCK setting, there is no need to set fp divider 113 + * @fp: bypass other dividers by setting fp directly if fp != 0 114 + * @tx: current setting is for playback or capture 115 + */ 116 + static int fsl_esai_divisor_cal(struct snd_soc_dai *dai, bool tx, u32 ratio, 117 + bool usefp, u32 fp) 118 + { 119 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 120 + u32 psr, pm = 999, maxfp, prod, sub, savesub, i, j; 121 + 122 + maxfp = usefp ? 16 : 1; 123 + 124 + if (usefp && fp) 125 + goto out_fp; 126 + 127 + if (ratio > 2 * 8 * 256 * maxfp || ratio < 2) { 128 + dev_err(dai->dev, "the ratio is out of range (2 ~ %d)\n", 129 + 2 * 8 * 256 * maxfp); 130 + return -EINVAL; 131 + } else if (ratio % 2) { 132 + dev_err(dai->dev, "the raio must be even if using upper divider\n"); 133 + return -EINVAL; 134 + } 135 + 136 + ratio /= 2; 137 + 138 + psr = ratio <= 256 * maxfp ? ESAI_xCCR_xPSR_BYPASS : ESAI_xCCR_xPSR_DIV8; 139 + 140 + /* Set the max fluctuation -- 0.1% of the max devisor */ 141 + savesub = (psr ? 1 : 8) * 256 * maxfp / 1000; 142 + 143 + /* Find the best value for PM */ 144 + for (i = 1; i <= 256; i++) { 145 + for (j = 1; j <= maxfp; j++) { 146 + /* PSR (1 or 8) * PM (1 ~ 256) * FP (1 ~ 16) */ 147 + prod = (psr ? 1 : 8) * i * j; 148 + 149 + if (prod == ratio) 150 + sub = 0; 151 + else if (prod / ratio == 1) 152 + sub = prod - ratio; 153 + else if (ratio / prod == 1) 154 + sub = ratio - prod; 155 + else 156 + continue; 157 + 158 + /* Calculate the fraction */ 159 + sub = sub * 1000 / ratio; 160 + if (sub < savesub) { 161 + savesub = sub; 162 + pm = i; 163 + fp = j; 164 + } 165 + 166 + /* We are lucky */ 167 + if (savesub == 0) 168 + goto out; 169 + } 170 + } 171 + 172 + if (pm == 999) { 173 + dev_err(dai->dev, "failed to calculate proper divisors\n"); 174 + return -EINVAL; 175 + } 176 + 177 + out: 178 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCCR(tx), 179 + ESAI_xCCR_xPSR_MASK | ESAI_xCCR_xPM_MASK, 180 + psr | ESAI_xCCR_xPM(pm)); 181 + 182 + out_fp: 183 + /* Bypass fp if not being required */ 184 + if (maxfp <= 1) 185 + return 0; 186 + 187 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCCR(tx), 188 + ESAI_xCCR_xFP_MASK, ESAI_xCCR_xFP(fp)); 189 + 190 + return 0; 191 + } 192 + 193 + /** 194 + * This function mainly configures the clock frequency of MCLK (HCKT/HCKR) 195 + * 196 + * @Parameters: 197 + * clk_id: The clock source of HCKT/HCKR 198 + * (Input from outside; output from inside, FSYS or EXTAL) 199 + * freq: The required clock rate of HCKT/HCKR 200 + * dir: The clock direction of HCKT/HCKR 201 + * 202 + * Note: If the direction is input, we do not care about clk_id. 203 + */ 204 + static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, 205 + unsigned int freq, int dir) 206 + { 207 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 208 + struct clk *clksrc = esai_priv->extalclk; 209 + bool tx = clk_id <= ESAI_HCKT_EXTAL; 210 + bool in = dir == SND_SOC_CLOCK_IN; 211 + u32 ret, ratio, ecr = 0; 212 + unsigned long clk_rate; 213 + 214 + /* sck_div can be only bypassed if ETO/ERO=0 and SNC_SOC_CLOCK_OUT */ 215 + esai_priv->sck_div[tx] = true; 216 + 217 + /* Set the direction of HCKT/HCKR pins */ 218 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCCR(tx), 219 + ESAI_xCCR_xHCKD, in ? 0 : ESAI_xCCR_xHCKD); 220 + 221 + if (in) 222 + goto out; 223 + 224 + switch (clk_id) { 225 + case ESAI_HCKT_FSYS: 226 + case ESAI_HCKR_FSYS: 227 + clksrc = esai_priv->fsysclk; 228 + break; 229 + case ESAI_HCKT_EXTAL: 230 + ecr |= ESAI_ECR_ETI; 231 + case ESAI_HCKR_EXTAL: 232 + ecr |= ESAI_ECR_ERI; 233 + break; 234 + default: 235 + return -EINVAL; 236 + } 237 + 238 + if (IS_ERR(clksrc)) { 239 + dev_err(dai->dev, "no assigned %s clock\n", 240 + clk_id % 2 ? "extal" : "fsys"); 241 + return PTR_ERR(clksrc); 242 + } 243 + clk_rate = clk_get_rate(clksrc); 244 + 245 + ratio = clk_rate / freq; 246 + if (ratio * freq > clk_rate) 247 + ret = ratio * freq - clk_rate; 248 + else if (ratio * freq < clk_rate) 249 + ret = clk_rate - ratio * freq; 250 + else 251 + ret = 0; 252 + 253 + /* Block if clock source can not be divided into the required rate */ 254 + if (ret != 0 && clk_rate / ret < 1000) { 255 + dev_err(dai->dev, "failed to derive required HCK%c rate\n", 256 + tx ? 'T' : 'R'); 257 + return -EINVAL; 258 + } 259 + 260 + if (ratio == 1) { 261 + /* Bypass all the dividers if not being needed */ 262 + ecr |= tx ? ESAI_ECR_ETO : ESAI_ECR_ERO; 263 + goto out; 264 + } 265 + 266 + ret = fsl_esai_divisor_cal(dai, tx, ratio, false, 0); 267 + if (ret) 268 + return ret; 269 + 270 + esai_priv->sck_div[tx] = false; 271 + 272 + out: 273 + esai_priv->hck_rate[tx] = freq; 274 + 275 + regmap_update_bits(esai_priv->regmap, REG_ESAI_ECR, 276 + tx ? ESAI_ECR_ETI | ESAI_ECR_ETO : 277 + ESAI_ECR_ERI | ESAI_ECR_ERO, ecr); 278 + 279 + return 0; 280 + } 281 + 282 + /** 283 + * This function configures the related dividers according to the bclk rate 284 + */ 285 + static int fsl_esai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq) 286 + { 287 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 288 + u32 hck_rate = esai_priv->hck_rate[tx]; 289 + u32 sub, ratio = hck_rate / freq; 290 + 291 + /* Don't apply for fully slave mode*/ 292 + if (esai_priv->slave_mode) 293 + return 0; 294 + 295 + if (ratio * freq > hck_rate) 296 + sub = ratio * freq - hck_rate; 297 + else if (ratio * freq < hck_rate) 298 + sub = hck_rate - ratio * freq; 299 + else 300 + sub = 0; 301 + 302 + /* Block if clock source can not be divided into the required rate */ 303 + if (sub != 0 && hck_rate / sub < 1000) { 304 + dev_err(dai->dev, "failed to derive required SCK%c rate\n", 305 + tx ? 'T' : 'R'); 306 + return -EINVAL; 307 + } 308 + 309 + if (esai_priv->sck_div[tx] && (ratio > 16 || ratio == 0)) { 310 + dev_err(dai->dev, "the ratio is out of range (1 ~ 16)\n"); 311 + return -EINVAL; 312 + } 313 + 314 + return fsl_esai_divisor_cal(dai, tx, ratio, true, 315 + esai_priv->sck_div[tx] ? 0 : ratio); 316 + } 317 + 318 + static int fsl_esai_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask, 319 + u32 rx_mask, int slots, int slot_width) 320 + { 321 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 322 + 323 + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR, 324 + ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); 325 + 326 + regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMA, 327 + ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(tx_mask)); 328 + regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMB, 329 + ESAI_xSMA_xS_MASK, ESAI_xSMB_xS(tx_mask)); 330 + 331 + regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, 332 + ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); 333 + 334 + regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMA, 335 + ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(rx_mask)); 336 + regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMB, 337 + ESAI_xSMA_xS_MASK, ESAI_xSMB_xS(rx_mask)); 338 + 339 + esai_priv->slot_width = slot_width; 340 + 341 + return 0; 342 + } 343 + 344 + static int fsl_esai_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) 345 + { 346 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 347 + u32 xcr = 0, xccr = 0, mask; 348 + 349 + /* DAI mode */ 350 + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 351 + case SND_SOC_DAIFMT_I2S: 352 + /* Data on rising edge of bclk, frame low, 1clk before data */ 353 + xcr |= ESAI_xCR_xFSR; 354 + xccr |= ESAI_xCCR_xFSP | ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP; 355 + break; 356 + case SND_SOC_DAIFMT_LEFT_J: 357 + /* Data on rising edge of bclk, frame high */ 358 + xccr |= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP; 359 + break; 360 + case SND_SOC_DAIFMT_RIGHT_J: 361 + /* Data on rising edge of bclk, frame high, right aligned */ 362 + xccr |= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP | ESAI_xCR_xWA; 363 + break; 364 + case SND_SOC_DAIFMT_DSP_A: 365 + /* Data on rising edge of bclk, frame high, 1clk before data */ 366 + xcr |= ESAI_xCR_xFSL | ESAI_xCR_xFSR; 367 + xccr |= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP; 368 + break; 369 + case SND_SOC_DAIFMT_DSP_B: 370 + /* Data on rising edge of bclk, frame high */ 371 + xcr |= ESAI_xCR_xFSL; 372 + xccr |= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP; 373 + break; 374 + default: 375 + return -EINVAL; 376 + } 377 + 378 + /* DAI clock inversion */ 379 + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 380 + case SND_SOC_DAIFMT_NB_NF: 381 + /* Nothing to do for both normal cases */ 382 + break; 383 + case SND_SOC_DAIFMT_IB_NF: 384 + /* Invert bit clock */ 385 + xccr ^= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP; 386 + break; 387 + case SND_SOC_DAIFMT_NB_IF: 388 + /* Invert frame clock */ 389 + xccr ^= ESAI_xCCR_xFSP; 390 + break; 391 + case SND_SOC_DAIFMT_IB_IF: 392 + /* Invert both clocks */ 393 + xccr ^= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP | ESAI_xCCR_xFSP; 394 + break; 395 + default: 396 + return -EINVAL; 397 + } 398 + 399 + esai_priv->slave_mode = false; 400 + 401 + /* DAI clock master masks */ 402 + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 403 + case SND_SOC_DAIFMT_CBM_CFM: 404 + esai_priv->slave_mode = true; 405 + break; 406 + case SND_SOC_DAIFMT_CBS_CFM: 407 + xccr |= ESAI_xCCR_xCKD; 408 + break; 409 + case SND_SOC_DAIFMT_CBM_CFS: 410 + xccr |= ESAI_xCCR_xFSD; 411 + break; 412 + case SND_SOC_DAIFMT_CBS_CFS: 413 + xccr |= ESAI_xCCR_xFSD | ESAI_xCCR_xCKD; 414 + break; 415 + default: 416 + return -EINVAL; 417 + } 418 + 419 + mask = ESAI_xCR_xFSL | ESAI_xCR_xFSR; 420 + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, mask, xcr); 421 + regmap_update_bits(esai_priv->regmap, REG_ESAI_RCR, mask, xcr); 422 + 423 + mask = ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP | ESAI_xCCR_xFSP | 424 + ESAI_xCCR_xFSD | ESAI_xCCR_xCKD | ESAI_xCR_xWA; 425 + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR, mask, xccr); 426 + regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, mask, xccr); 427 + 428 + return 0; 429 + } 430 + 431 + static int fsl_esai_startup(struct snd_pcm_substream *substream, 432 + struct snd_soc_dai *dai) 433 + { 434 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 435 + 436 + /* 437 + * Some platforms might use the same bit to gate all three or two of 438 + * clocks, so keep all clocks open/close at the same time for safety 439 + */ 440 + clk_prepare_enable(esai_priv->coreclk); 441 + if (!IS_ERR(esai_priv->extalclk)) 442 + clk_prepare_enable(esai_priv->extalclk); 443 + if (!IS_ERR(esai_priv->fsysclk)) 444 + clk_prepare_enable(esai_priv->fsysclk); 445 + 446 + if (!dai->active) { 447 + /* Reset Port C */ 448 + regmap_update_bits(esai_priv->regmap, REG_ESAI_PRRC, 449 + ESAI_PRRC_PDC_MASK, ESAI_PRRC_PDC(ESAI_GPIO)); 450 + regmap_update_bits(esai_priv->regmap, REG_ESAI_PCRC, 451 + ESAI_PCRC_PC_MASK, ESAI_PCRC_PC(ESAI_GPIO)); 452 + 453 + /* Set synchronous mode */ 454 + regmap_update_bits(esai_priv->regmap, REG_ESAI_SAICR, 455 + ESAI_SAICR_SYNC, esai_priv->synchronous ? 456 + ESAI_SAICR_SYNC : 0); 457 + 458 + /* Set a default slot number -- 2 */ 459 + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR, 460 + ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(2)); 461 + regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, 462 + ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(2)); 463 + } 464 + 465 + return 0; 466 + } 467 + 468 + static int fsl_esai_hw_params(struct snd_pcm_substream *substream, 469 + struct snd_pcm_hw_params *params, 470 + struct snd_soc_dai *dai) 471 + { 472 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 473 + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; 474 + u32 width = snd_pcm_format_width(params_format(params)); 475 + u32 channels = params_channels(params); 476 + u32 bclk, mask, val, ret; 477 + 478 + bclk = params_rate(params) * esai_priv->slot_width * 2; 479 + 480 + ret = fsl_esai_set_bclk(dai, tx, bclk); 481 + if (ret) 482 + return ret; 483 + 484 + /* Use Normal mode to support monaural audio */ 485 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), 486 + ESAI_xCR_xMOD_MASK, params_channels(params) > 1 ? 487 + ESAI_xCR_xMOD_NETWORK : 0); 488 + 489 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), 490 + ESAI_xFCR_xFR_MASK, ESAI_xFCR_xFR); 491 + 492 + mask = ESAI_xFCR_xFR_MASK | ESAI_xFCR_xWA_MASK | ESAI_xFCR_xFWM_MASK | 493 + (tx ? ESAI_xFCR_TE_MASK | ESAI_xFCR_TIEN : ESAI_xFCR_RE_MASK); 494 + val = ESAI_xFCR_xWA(width) | ESAI_xFCR_xFWM(esai_priv->fifo_depth) | 495 + (tx ? ESAI_xFCR_TE(channels) | ESAI_xFCR_TIEN : ESAI_xFCR_RE(channels)); 496 + 497 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), mask, val); 498 + 499 + mask = ESAI_xCR_xSWS_MASK | (tx ? ESAI_xCR_PADC : 0); 500 + val = ESAI_xCR_xSWS(esai_priv->slot_width, width) | (tx ? ESAI_xCR_PADC : 0); 501 + 502 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), mask, val); 503 + 504 + return 0; 505 + } 506 + 507 + static void fsl_esai_shutdown(struct snd_pcm_substream *substream, 508 + struct snd_soc_dai *dai) 509 + { 510 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 511 + 512 + if (!IS_ERR(esai_priv->fsysclk)) 513 + clk_disable_unprepare(esai_priv->fsysclk); 514 + if (!IS_ERR(esai_priv->extalclk)) 515 + clk_disable_unprepare(esai_priv->extalclk); 516 + clk_disable_unprepare(esai_priv->coreclk); 517 + } 518 + 519 + static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, 520 + struct snd_soc_dai *dai) 521 + { 522 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 523 + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; 524 + u8 i, channels = substream->runtime->channels; 525 + 526 + switch (cmd) { 527 + case SNDRV_PCM_TRIGGER_START: 528 + case SNDRV_PCM_TRIGGER_RESUME: 529 + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 530 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), 531 + ESAI_xFCR_xFEN_MASK, ESAI_xFCR_xFEN); 532 + 533 + /* Write initial words reqiured by ESAI as normal procedure */ 534 + for (i = 0; tx && i < channels; i++) 535 + regmap_write(esai_priv->regmap, REG_ESAI_ETDR, 0x0); 536 + 537 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), 538 + tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, 539 + tx ? ESAI_xCR_TE(channels) : ESAI_xCR_RE(channels)); 540 + break; 541 + case SNDRV_PCM_TRIGGER_SUSPEND: 542 + case SNDRV_PCM_TRIGGER_STOP: 543 + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 544 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), 545 + tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, 0); 546 + 547 + /* Disable and reset FIFO */ 548 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), 549 + ESAI_xFCR_xFR | ESAI_xFCR_xFEN, ESAI_xFCR_xFR); 550 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), 551 + ESAI_xFCR_xFR, 0); 552 + break; 553 + default: 554 + return -EINVAL; 555 + } 556 + 557 + return 0; 558 + } 559 + 560 + static struct snd_soc_dai_ops fsl_esai_dai_ops = { 561 + .startup = fsl_esai_startup, 562 + .shutdown = fsl_esai_shutdown, 563 + .trigger = fsl_esai_trigger, 564 + .hw_params = fsl_esai_hw_params, 565 + .set_sysclk = fsl_esai_set_dai_sysclk, 566 + .set_fmt = fsl_esai_set_dai_fmt, 567 + .set_tdm_slot = fsl_esai_set_dai_tdm_slot, 568 + }; 569 + 570 + static int fsl_esai_dai_probe(struct snd_soc_dai *dai) 571 + { 572 + struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); 573 + 574 + snd_soc_dai_init_dma_data(dai, &esai_priv->dma_params_tx, 575 + &esai_priv->dma_params_rx); 576 + 577 + return 0; 578 + } 579 + 580 + static struct snd_soc_dai_driver fsl_esai_dai = { 581 + .probe = fsl_esai_dai_probe, 582 + .playback = { 583 + .channels_min = 1, 584 + .channels_max = 12, 585 + .rates = FSL_ESAI_RATES, 586 + .formats = FSL_ESAI_FORMATS, 587 + }, 588 + .capture = { 589 + .channels_min = 1, 590 + .channels_max = 8, 591 + .rates = FSL_ESAI_RATES, 592 + .formats = FSL_ESAI_FORMATS, 593 + }, 594 + .ops = &fsl_esai_dai_ops, 595 + }; 596 + 597 + static const struct snd_soc_component_driver fsl_esai_component = { 598 + .name = "fsl-esai", 599 + }; 600 + 601 + static bool fsl_esai_readable_reg(struct device *dev, unsigned int reg) 602 + { 603 + switch (reg) { 604 + case REG_ESAI_ERDR: 605 + case REG_ESAI_ECR: 606 + case REG_ESAI_ESR: 607 + case REG_ESAI_TFCR: 608 + case REG_ESAI_TFSR: 609 + case REG_ESAI_RFCR: 610 + case REG_ESAI_RFSR: 611 + case REG_ESAI_RX0: 612 + case REG_ESAI_RX1: 613 + case REG_ESAI_RX2: 614 + case REG_ESAI_RX3: 615 + case REG_ESAI_SAISR: 616 + case REG_ESAI_SAICR: 617 + case REG_ESAI_TCR: 618 + case REG_ESAI_TCCR: 619 + case REG_ESAI_RCR: 620 + case REG_ESAI_RCCR: 621 + case REG_ESAI_TSMA: 622 + case REG_ESAI_TSMB: 623 + case REG_ESAI_RSMA: 624 + case REG_ESAI_RSMB: 625 + case REG_ESAI_PRRC: 626 + case REG_ESAI_PCRC: 627 + return true; 628 + default: 629 + return false; 630 + } 631 + } 632 + 633 + static bool fsl_esai_writeable_reg(struct device *dev, unsigned int reg) 634 + { 635 + switch (reg) { 636 + case REG_ESAI_ETDR: 637 + case REG_ESAI_ECR: 638 + case REG_ESAI_TFCR: 639 + case REG_ESAI_RFCR: 640 + case REG_ESAI_TX0: 641 + case REG_ESAI_TX1: 642 + case REG_ESAI_TX2: 643 + case REG_ESAI_TX3: 644 + case REG_ESAI_TX4: 645 + case REG_ESAI_TX5: 646 + case REG_ESAI_TSR: 647 + case REG_ESAI_SAICR: 648 + case REG_ESAI_TCR: 649 + case REG_ESAI_TCCR: 650 + case REG_ESAI_RCR: 651 + case REG_ESAI_RCCR: 652 + case REG_ESAI_TSMA: 653 + case REG_ESAI_TSMB: 654 + case REG_ESAI_RSMA: 655 + case REG_ESAI_RSMB: 656 + case REG_ESAI_PRRC: 657 + case REG_ESAI_PCRC: 658 + return true; 659 + default: 660 + return false; 661 + } 662 + } 663 + 664 + static const struct regmap_config fsl_esai_regmap_config = { 665 + .reg_bits = 32, 666 + .reg_stride = 4, 667 + .val_bits = 32, 668 + 669 + .max_register = REG_ESAI_PCRC, 670 + .readable_reg = fsl_esai_readable_reg, 671 + .writeable_reg = fsl_esai_writeable_reg, 672 + }; 673 + 674 + static int fsl_esai_probe(struct platform_device *pdev) 675 + { 676 + struct device_node *np = pdev->dev.of_node; 677 + struct fsl_esai *esai_priv; 678 + struct resource *res; 679 + const uint32_t *iprop; 680 + void __iomem *regs; 681 + int irq, ret; 682 + 683 + esai_priv = devm_kzalloc(&pdev->dev, sizeof(*esai_priv), GFP_KERNEL); 684 + if (!esai_priv) 685 + return -ENOMEM; 686 + 687 + esai_priv->pdev = pdev; 688 + strcpy(esai_priv->name, np->name); 689 + 690 + /* Get the addresses and IRQ */ 691 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 692 + regs = devm_ioremap_resource(&pdev->dev, res); 693 + if (IS_ERR(regs)) 694 + return PTR_ERR(regs); 695 + 696 + esai_priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev, 697 + "core", regs, &fsl_esai_regmap_config); 698 + if (IS_ERR(esai_priv->regmap)) { 699 + dev_err(&pdev->dev, "failed to init regmap: %ld\n", 700 + PTR_ERR(esai_priv->regmap)); 701 + return PTR_ERR(esai_priv->regmap); 702 + } 703 + 704 + esai_priv->coreclk = devm_clk_get(&pdev->dev, "core"); 705 + if (IS_ERR(esai_priv->coreclk)) { 706 + dev_err(&pdev->dev, "failed to get core clock: %ld\n", 707 + PTR_ERR(esai_priv->coreclk)); 708 + return PTR_ERR(esai_priv->coreclk); 709 + } 710 + 711 + esai_priv->extalclk = devm_clk_get(&pdev->dev, "extal"); 712 + if (IS_ERR(esai_priv->extalclk)) 713 + dev_warn(&pdev->dev, "failed to get extal clock: %ld\n", 714 + PTR_ERR(esai_priv->extalclk)); 715 + 716 + esai_priv->fsysclk = devm_clk_get(&pdev->dev, "fsys"); 717 + if (IS_ERR(esai_priv->fsysclk)) 718 + dev_warn(&pdev->dev, "failed to get fsys clock: %ld\n", 719 + PTR_ERR(esai_priv->fsysclk)); 720 + 721 + irq = platform_get_irq(pdev, 0); 722 + if (irq < 0) { 723 + dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); 724 + return irq; 725 + } 726 + 727 + ret = devm_request_irq(&pdev->dev, irq, esai_isr, 0, 728 + esai_priv->name, esai_priv); 729 + if (ret) { 730 + dev_err(&pdev->dev, "failed to claim irq %u\n", irq); 731 + return ret; 732 + } 733 + 734 + /* Set a default slot size */ 735 + esai_priv->slot_width = 32; 736 + 737 + /* Set a default master/slave state */ 738 + esai_priv->slave_mode = true; 739 + 740 + /* Determine the FIFO depth */ 741 + iprop = of_get_property(np, "fsl,fifo-depth", NULL); 742 + if (iprop) 743 + esai_priv->fifo_depth = be32_to_cpup(iprop); 744 + else 745 + esai_priv->fifo_depth = 64; 746 + 747 + esai_priv->dma_params_tx.maxburst = 16; 748 + esai_priv->dma_params_rx.maxburst = 16; 749 + esai_priv->dma_params_tx.addr = res->start + REG_ESAI_ETDR; 750 + esai_priv->dma_params_rx.addr = res->start + REG_ESAI_ERDR; 751 + 752 + esai_priv->synchronous = 753 + of_property_read_bool(np, "fsl,esai-synchronous"); 754 + 755 + /* Implement full symmetry for synchronous mode */ 756 + if (esai_priv->synchronous) { 757 + fsl_esai_dai.symmetric_rates = 1; 758 + fsl_esai_dai.symmetric_channels = 1; 759 + fsl_esai_dai.symmetric_samplebits = 1; 760 + } 761 + 762 + dev_set_drvdata(&pdev->dev, esai_priv); 763 + 764 + /* Reset ESAI unit */ 765 + ret = regmap_write(esai_priv->regmap, REG_ESAI_ECR, ESAI_ECR_ERST); 766 + if (ret) { 767 + dev_err(&pdev->dev, "failed to reset ESAI: %d\n", ret); 768 + return ret; 769 + } 770 + 771 + /* 772 + * We need to enable ESAI so as to access some of its registers. 773 + * Otherwise, we would fail to dump regmap from user space. 774 + */ 775 + ret = regmap_write(esai_priv->regmap, REG_ESAI_ECR, ESAI_ECR_ESAIEN); 776 + if (ret) { 777 + dev_err(&pdev->dev, "failed to enable ESAI: %d\n", ret); 778 + return ret; 779 + } 780 + 781 + ret = devm_snd_soc_register_component(&pdev->dev, &fsl_esai_component, 782 + &fsl_esai_dai, 1); 783 + if (ret) { 784 + dev_err(&pdev->dev, "failed to register DAI: %d\n", ret); 785 + return ret; 786 + } 787 + 788 + ret = imx_pcm_dma_init(pdev); 789 + if (ret) 790 + dev_err(&pdev->dev, "failed to init imx pcm dma: %d\n", ret); 791 + 792 + return ret; 793 + } 794 + 795 + static const struct of_device_id fsl_esai_dt_ids[] = { 796 + { .compatible = "fsl,imx35-esai", }, 797 + {} 798 + }; 799 + MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids); 800 + 801 + static struct platform_driver fsl_esai_driver = { 802 + .probe = fsl_esai_probe, 803 + .driver = { 804 + .name = "fsl-esai-dai", 805 + .owner = THIS_MODULE, 806 + .of_match_table = fsl_esai_dt_ids, 807 + }, 808 + }; 809 + 810 + module_platform_driver(fsl_esai_driver); 811 + 812 + MODULE_AUTHOR("Freescale Semiconductor, Inc."); 813 + MODULE_DESCRIPTION("Freescale ESAI CPU DAI driver"); 814 + MODULE_LICENSE("GPL v2"); 815 + MODULE_ALIAS("platform:fsl-esai-dai");
+354
sound/soc/fsl/fsl_esai.h
··· 1 + /* 2 + * fsl_esai.h - ALSA ESAI interface for the Freescale i.MX SoC 3 + * 4 + * Copyright (C) 2014 Freescale Semiconductor, Inc. 5 + * 6 + * Author: Nicolin Chen <Guangyu.Chen@freescale.com> 7 + * 8 + * This file is licensed under the terms of the GNU General Public License 9 + * version 2. This program is licensed "as is" without any warranty of any 10 + * kind, whether express or implied. 11 + */ 12 + 13 + #ifndef _FSL_ESAI_DAI_H 14 + #define _FSL_ESAI_DAI_H 15 + 16 + /* ESAI Register Map */ 17 + #define REG_ESAI_ETDR 0x00 18 + #define REG_ESAI_ERDR 0x04 19 + #define REG_ESAI_ECR 0x08 20 + #define REG_ESAI_ESR 0x0C 21 + #define REG_ESAI_TFCR 0x10 22 + #define REG_ESAI_TFSR 0x14 23 + #define REG_ESAI_RFCR 0x18 24 + #define REG_ESAI_RFSR 0x1C 25 + #define REG_ESAI_xFCR(tx) (tx ? REG_ESAI_TFCR : REG_ESAI_RFCR) 26 + #define REG_ESAI_xFSR(tx) (tx ? REG_ESAI_TFSR : REG_ESAI_RFSR) 27 + #define REG_ESAI_TX0 0x80 28 + #define REG_ESAI_TX1 0x84 29 + #define REG_ESAI_TX2 0x88 30 + #define REG_ESAI_TX3 0x8C 31 + #define REG_ESAI_TX4 0x90 32 + #define REG_ESAI_TX5 0x94 33 + #define REG_ESAI_TSR 0x98 34 + #define REG_ESAI_RX0 0xA0 35 + #define REG_ESAI_RX1 0xA4 36 + #define REG_ESAI_RX2 0xA8 37 + #define REG_ESAI_RX3 0xAC 38 + #define REG_ESAI_SAISR 0xCC 39 + #define REG_ESAI_SAICR 0xD0 40 + #define REG_ESAI_TCR 0xD4 41 + #define REG_ESAI_TCCR 0xD8 42 + #define REG_ESAI_RCR 0xDC 43 + #define REG_ESAI_RCCR 0xE0 44 + #define REG_ESAI_xCR(tx) (tx ? REG_ESAI_TCR : REG_ESAI_RCR) 45 + #define REG_ESAI_xCCR(tx) (tx ? REG_ESAI_TCCR : REG_ESAI_RCCR) 46 + #define REG_ESAI_TSMA 0xE4 47 + #define REG_ESAI_TSMB 0xE8 48 + #define REG_ESAI_RSMA 0xEC 49 + #define REG_ESAI_RSMB 0xF0 50 + #define REG_ESAI_xSMA(tx) (tx ? REG_ESAI_TSMA : REG_ESAI_RSMA) 51 + #define REG_ESAI_xSMB(tx) (tx ? REG_ESAI_TSMB : REG_ESAI_RSMB) 52 + #define REG_ESAI_PRRC 0xF8 53 + #define REG_ESAI_PCRC 0xFC 54 + 55 + /* ESAI Control Register -- REG_ESAI_ECR 0x8 */ 56 + #define ESAI_ECR_ETI_SHIFT 19 57 + #define ESAI_ECR_ETI_MASK (1 << ESAI_ECR_ETI_SHIFT) 58 + #define ESAI_ECR_ETI (1 << ESAI_ECR_ETI_SHIFT) 59 + #define ESAI_ECR_ETO_SHIFT 18 60 + #define ESAI_ECR_ETO_MASK (1 << ESAI_ECR_ETO_SHIFT) 61 + #define ESAI_ECR_ETO (1 << ESAI_ECR_ETO_SHIFT) 62 + #define ESAI_ECR_ERI_SHIFT 17 63 + #define ESAI_ECR_ERI_MASK (1 << ESAI_ECR_ERI_SHIFT) 64 + #define ESAI_ECR_ERI (1 << ESAI_ECR_ERI_SHIFT) 65 + #define ESAI_ECR_ERO_SHIFT 16 66 + #define ESAI_ECR_ERO_MASK (1 << ESAI_ECR_ERO_SHIFT) 67 + #define ESAI_ECR_ERO (1 << ESAI_ECR_ERO_SHIFT) 68 + #define ESAI_ECR_ERST_SHIFT 1 69 + #define ESAI_ECR_ERST_MASK (1 << ESAI_ECR_ERST_SHIFT) 70 + #define ESAI_ECR_ERST (1 << ESAI_ECR_ERST_SHIFT) 71 + #define ESAI_ECR_ESAIEN_SHIFT 0 72 + #define ESAI_ECR_ESAIEN_MASK (1 << ESAI_ECR_ESAIEN_SHIFT) 73 + #define ESAI_ECR_ESAIEN (1 << ESAI_ECR_ESAIEN_SHIFT) 74 + 75 + /* ESAI Status Register -- REG_ESAI_ESR 0xC */ 76 + #define ESAI_ESR_TINIT_SHIFT 10 77 + #define ESAI_ESR_TINIT_MASK (1 << ESAI_ESR_TINIT_SHIFT) 78 + #define ESAI_ESR_TINIT (1 << ESAI_ESR_TINIT_SHIFT) 79 + #define ESAI_ESR_RFF_SHIFT 9 80 + #define ESAI_ESR_RFF_MASK (1 << ESAI_ESR_RFF_SHIFT) 81 + #define ESAI_ESR_RFF (1 << ESAI_ESR_RFF_SHIFT) 82 + #define ESAI_ESR_TFE_SHIFT 8 83 + #define ESAI_ESR_TFE_MASK (1 << ESAI_ESR_TFE_SHIFT) 84 + #define ESAI_ESR_TFE (1 << ESAI_ESR_TFE_SHIFT) 85 + #define ESAI_ESR_TLS_SHIFT 7 86 + #define ESAI_ESR_TLS_MASK (1 << ESAI_ESR_TLS_SHIFT) 87 + #define ESAI_ESR_TLS (1 << ESAI_ESR_TLS_SHIFT) 88 + #define ESAI_ESR_TDE_SHIFT 6 89 + #define ESAI_ESR_TDE_MASK (1 << ESAI_ESR_TDE_SHIFT) 90 + #define ESAI_ESR_TDE (1 << ESAI_ESR_TDE_SHIFT) 91 + #define ESAI_ESR_TED_SHIFT 5 92 + #define ESAI_ESR_TED_MASK (1 << ESAI_ESR_TED_SHIFT) 93 + #define ESAI_ESR_TED (1 << ESAI_ESR_TED_SHIFT) 94 + #define ESAI_ESR_TD_SHIFT 4 95 + #define ESAI_ESR_TD_MASK (1 << ESAI_ESR_TD_SHIFT) 96 + #define ESAI_ESR_TD (1 << ESAI_ESR_TD_SHIFT) 97 + #define ESAI_ESR_RLS_SHIFT 3 98 + #define ESAI_ESR_RLS_MASK (1 << ESAI_ESR_RLS_SHIFT) 99 + #define ESAI_ESR_RLS (1 << ESAI_ESR_RLS_SHIFT) 100 + #define ESAI_ESR_RDE_SHIFT 2 101 + #define ESAI_ESR_RDE_MASK (1 << ESAI_ESR_RDE_SHIFT) 102 + #define ESAI_ESR_RDE (1 << ESAI_ESR_RDE_SHIFT) 103 + #define ESAI_ESR_RED_SHIFT 1 104 + #define ESAI_ESR_RED_MASK (1 << ESAI_ESR_RED_SHIFT) 105 + #define ESAI_ESR_RED (1 << ESAI_ESR_RED_SHIFT) 106 + #define ESAI_ESR_RD_SHIFT 0 107 + #define ESAI_ESR_RD_MASK (1 << ESAI_ESR_RD_SHIFT) 108 + #define ESAI_ESR_RD (1 << ESAI_ESR_RD_SHIFT) 109 + 110 + /* 111 + * Transmit FIFO Configuration Register -- REG_ESAI_TFCR 0x10 112 + * Receive FIFO Configuration Register -- REG_ESAI_RFCR 0x18 113 + */ 114 + #define ESAI_xFCR_TIEN_SHIFT 19 115 + #define ESAI_xFCR_TIEN_MASK (1 << ESAI_xFCR_TIEN_SHIFT) 116 + #define ESAI_xFCR_TIEN (1 << ESAI_xFCR_TIEN_SHIFT) 117 + #define ESAI_xFCR_REXT_SHIFT 19 118 + #define ESAI_xFCR_REXT_MASK (1 << ESAI_xFCR_REXT_SHIFT) 119 + #define ESAI_xFCR_REXT (1 << ESAI_xFCR_REXT_SHIFT) 120 + #define ESAI_xFCR_xWA_SHIFT 16 121 + #define ESAI_xFCR_xWA_WIDTH 3 122 + #define ESAI_xFCR_xWA_MASK (((1 << ESAI_xFCR_xWA_WIDTH) - 1) << ESAI_xFCR_xWA_SHIFT) 123 + #define ESAI_xFCR_xWA(v) (((8 - ((v) >> 2)) << ESAI_xFCR_xWA_SHIFT) & ESAI_xFCR_xWA_MASK) 124 + #define ESAI_xFCR_xFWM_SHIFT 8 125 + #define ESAI_xFCR_xFWM_WIDTH 8 126 + #define ESAI_xFCR_xFWM_MASK (((1 << ESAI_xFCR_xFWM_WIDTH) - 1) << ESAI_xFCR_xFWM_SHIFT) 127 + #define ESAI_xFCR_xFWM(v) ((((v) - 1) << ESAI_xFCR_xFWM_SHIFT) & ESAI_xFCR_xFWM_MASK) 128 + #define ESAI_xFCR_xE_SHIFT 2 129 + #define ESAI_xFCR_TE_WIDTH 6 130 + #define ESAI_xFCR_RE_WIDTH 4 131 + #define ESAI_xFCR_TE_MASK (((1 << ESAI_xFCR_TE_WIDTH) - 1) << ESAI_xFCR_xE_SHIFT) 132 + #define ESAI_xFCR_RE_MASK (((1 << ESAI_xFCR_RE_WIDTH) - 1) << ESAI_xFCR_xE_SHIFT) 133 + #define ESAI_xFCR_TE(x) ((ESAI_xFCR_TE_MASK >> (ESAI_xFCR_TE_WIDTH - ((x + 1) >> 1))) & ESAI_xFCR_TE_MASK) 134 + #define ESAI_xFCR_RE(x) ((ESAI_xFCR_RE_MASK >> (ESAI_xFCR_RE_WIDTH - ((x + 1) >> 1))) & ESAI_xFCR_RE_MASK) 135 + #define ESAI_xFCR_xFR_SHIFT 1 136 + #define ESAI_xFCR_xFR_MASK (1 << ESAI_xFCR_xFR_SHIFT) 137 + #define ESAI_xFCR_xFR (1 << ESAI_xFCR_xFR_SHIFT) 138 + #define ESAI_xFCR_xFEN_SHIFT 0 139 + #define ESAI_xFCR_xFEN_MASK (1 << ESAI_xFCR_xFEN_SHIFT) 140 + #define ESAI_xFCR_xFEN (1 << ESAI_xFCR_xFEN_SHIFT) 141 + 142 + /* 143 + * Transmit FIFO Status Register -- REG_ESAI_TFSR 0x14 144 + * Receive FIFO Status Register --REG_ESAI_RFSR 0x1C 145 + */ 146 + #define ESAI_xFSR_NTFO_SHIFT 12 147 + #define ESAI_xFSR_NRFI_SHIFT 12 148 + #define ESAI_xFSR_NTFI_SHIFT 8 149 + #define ESAI_xFSR_NRFO_SHIFT 8 150 + #define ESAI_xFSR_NTFx_WIDTH 3 151 + #define ESAI_xFSR_NRFx_WIDTH 2 152 + #define ESAI_xFSR_NTFO_MASK (((1 << ESAI_xFSR_NTFx_WIDTH) - 1) << ESAI_xFSR_NTFO_SHIFT) 153 + #define ESAI_xFSR_NTFI_MASK (((1 << ESAI_xFSR_NTFx_WIDTH) - 1) << ESAI_xFSR_NTFI_SHIFT) 154 + #define ESAI_xFSR_NRFO_MASK (((1 << ESAI_xFSR_NRFx_WIDTH) - 1) << ESAI_xFSR_NRFO_SHIFT) 155 + #define ESAI_xFSR_NRFI_MASK (((1 << ESAI_xFSR_NRFx_WIDTH) - 1) << ESAI_xFSR_NRFI_SHIFT) 156 + #define ESAI_xFSR_xFCNT_SHIFT 0 157 + #define ESAI_xFSR_xFCNT_WIDTH 8 158 + #define ESAI_xFSR_xFCNT_MASK (((1 << ESAI_xFSR_xFCNT_WIDTH) - 1) << ESAI_xFSR_xFCNT_SHIFT) 159 + 160 + /* ESAI Transmit Slot Register -- REG_ESAI_TSR 0x98 */ 161 + #define ESAI_TSR_SHIFT 0 162 + #define ESAI_TSR_WIDTH 24 163 + #define ESAI_TSR_MASK (((1 << ESAI_TSR_WIDTH) - 1) << ESAI_TSR_SHIFT) 164 + 165 + /* Serial Audio Interface Status Register -- REG_ESAI_SAISR 0xCC */ 166 + #define ESAI_SAISR_TODFE_SHIFT 17 167 + #define ESAI_SAISR_TODFE_MASK (1 << ESAI_SAISR_TODFE_SHIFT) 168 + #define ESAI_SAISR_TODFE (1 << ESAI_SAISR_TODFE_SHIFT) 169 + #define ESAI_SAISR_TEDE_SHIFT 16 170 + #define ESAI_SAISR_TEDE_MASK (1 << ESAI_SAISR_TEDE_SHIFT) 171 + #define ESAI_SAISR_TEDE (1 << ESAI_SAISR_TEDE_SHIFT) 172 + #define ESAI_SAISR_TDE_SHIFT 15 173 + #define ESAI_SAISR_TDE_MASK (1 << ESAI_SAISR_TDE_SHIFT) 174 + #define ESAI_SAISR_TDE (1 << ESAI_SAISR_TDE_SHIFT) 175 + #define ESAI_SAISR_TUE_SHIFT 14 176 + #define ESAI_SAISR_TUE_MASK (1 << ESAI_SAISR_TUE_SHIFT) 177 + #define ESAI_SAISR_TUE (1 << ESAI_SAISR_TUE_SHIFT) 178 + #define ESAI_SAISR_TFS_SHIFT 13 179 + #define ESAI_SAISR_TFS_MASK (1 << ESAI_SAISR_TFS_SHIFT) 180 + #define ESAI_SAISR_TFS (1 << ESAI_SAISR_TFS_SHIFT) 181 + #define ESAI_SAISR_RODF_SHIFT 10 182 + #define ESAI_SAISR_RODF_MASK (1 << ESAI_SAISR_RODF_SHIFT) 183 + #define ESAI_SAISR_RODF (1 << ESAI_SAISR_RODF_SHIFT) 184 + #define ESAI_SAISR_REDF_SHIFT 9 185 + #define ESAI_SAISR_REDF_MASK (1 << ESAI_SAISR_REDF_SHIFT) 186 + #define ESAI_SAISR_REDF (1 << ESAI_SAISR_REDF_SHIFT) 187 + #define ESAI_SAISR_RDF_SHIFT 8 188 + #define ESAI_SAISR_RDF_MASK (1 << ESAI_SAISR_RDF_SHIFT) 189 + #define ESAI_SAISR_RDF (1 << ESAI_SAISR_RDF_SHIFT) 190 + #define ESAI_SAISR_ROE_SHIFT 7 191 + #define ESAI_SAISR_ROE_MASK (1 << ESAI_SAISR_ROE_SHIFT) 192 + #define ESAI_SAISR_ROE (1 << ESAI_SAISR_ROE_SHIFT) 193 + #define ESAI_SAISR_RFS_SHIFT 6 194 + #define ESAI_SAISR_RFS_MASK (1 << ESAI_SAISR_RFS_SHIFT) 195 + #define ESAI_SAISR_RFS (1 << ESAI_SAISR_RFS_SHIFT) 196 + #define ESAI_SAISR_IF2_SHIFT 2 197 + #define ESAI_SAISR_IF2_MASK (1 << ESAI_SAISR_IF2_SHIFT) 198 + #define ESAI_SAISR_IF2 (1 << ESAI_SAISR_IF2_SHIFT) 199 + #define ESAI_SAISR_IF1_SHIFT 1 200 + #define ESAI_SAISR_IF1_MASK (1 << ESAI_SAISR_IF1_SHIFT) 201 + #define ESAI_SAISR_IF1 (1 << ESAI_SAISR_IF1_SHIFT) 202 + #define ESAI_SAISR_IF0_SHIFT 0 203 + #define ESAI_SAISR_IF0_MASK (1 << ESAI_SAISR_IF0_SHIFT) 204 + #define ESAI_SAISR_IF0 (1 << ESAI_SAISR_IF0_SHIFT) 205 + 206 + /* Serial Audio Interface Control Register -- REG_ESAI_SAICR 0xD0 */ 207 + #define ESAI_SAICR_ALC_SHIFT 8 208 + #define ESAI_SAICR_ALC_MASK (1 << ESAI_SAICR_ALC_SHIFT) 209 + #define ESAI_SAICR_ALC (1 << ESAI_SAICR_ALC_SHIFT) 210 + #define ESAI_SAICR_TEBE_SHIFT 7 211 + #define ESAI_SAICR_TEBE_MASK (1 << ESAI_SAICR_TEBE_SHIFT) 212 + #define ESAI_SAICR_TEBE (1 << ESAI_SAICR_TEBE_SHIFT) 213 + #define ESAI_SAICR_SYNC_SHIFT 6 214 + #define ESAI_SAICR_SYNC_MASK (1 << ESAI_SAICR_SYNC_SHIFT) 215 + #define ESAI_SAICR_SYNC (1 << ESAI_SAICR_SYNC_SHIFT) 216 + #define ESAI_SAICR_OF2_SHIFT 2 217 + #define ESAI_SAICR_OF2_MASK (1 << ESAI_SAICR_OF2_SHIFT) 218 + #define ESAI_SAICR_OF2 (1 << ESAI_SAICR_OF2_SHIFT) 219 + #define ESAI_SAICR_OF1_SHIFT 1 220 + #define ESAI_SAICR_OF1_MASK (1 << ESAI_SAICR_OF1_SHIFT) 221 + #define ESAI_SAICR_OF1 (1 << ESAI_SAICR_OF1_SHIFT) 222 + #define ESAI_SAICR_OF0_SHIFT 0 223 + #define ESAI_SAICR_OF0_MASK (1 << ESAI_SAICR_OF0_SHIFT) 224 + #define ESAI_SAICR_OF0 (1 << ESAI_SAICR_OF0_SHIFT) 225 + 226 + /* 227 + * Transmit Control Register -- REG_ESAI_TCR 0xD4 228 + * Receive Control Register -- REG_ESAI_RCR 0xDC 229 + */ 230 + #define ESAI_xCR_xLIE_SHIFT 23 231 + #define ESAI_xCR_xLIE_MASK (1 << ESAI_xCR_xLIE_SHIFT) 232 + #define ESAI_xCR_xLIE (1 << ESAI_xCR_xLIE_SHIFT) 233 + #define ESAI_xCR_xIE_SHIFT 22 234 + #define ESAI_xCR_xIE_MASK (1 << ESAI_xCR_xIE_SHIFT) 235 + #define ESAI_xCR_xIE (1 << ESAI_xCR_xIE_SHIFT) 236 + #define ESAI_xCR_xEDIE_SHIFT 21 237 + #define ESAI_xCR_xEDIE_MASK (1 << ESAI_xCR_xEDIE_SHIFT) 238 + #define ESAI_xCR_xEDIE (1 << ESAI_xCR_xEDIE_SHIFT) 239 + #define ESAI_xCR_xEIE_SHIFT 20 240 + #define ESAI_xCR_xEIE_MASK (1 << ESAI_xCR_xEIE_SHIFT) 241 + #define ESAI_xCR_xEIE (1 << ESAI_xCR_xEIE_SHIFT) 242 + #define ESAI_xCR_xPR_SHIFT 19 243 + #define ESAI_xCR_xPR_MASK (1 << ESAI_xCR_xPR_SHIFT) 244 + #define ESAI_xCR_xPR (1 << ESAI_xCR_xPR_SHIFT) 245 + #define ESAI_xCR_PADC_SHIFT 17 246 + #define ESAI_xCR_PADC_MASK (1 << ESAI_xCR_PADC_SHIFT) 247 + #define ESAI_xCR_PADC (1 << ESAI_xCR_PADC_SHIFT) 248 + #define ESAI_xCR_xFSR_SHIFT 16 249 + #define ESAI_xCR_xFSR_MASK (1 << ESAI_xCR_xFSR_SHIFT) 250 + #define ESAI_xCR_xFSR (1 << ESAI_xCR_xFSR_SHIFT) 251 + #define ESAI_xCR_xFSL_SHIFT 15 252 + #define ESAI_xCR_xFSL_MASK (1 << ESAI_xCR_xFSL_SHIFT) 253 + #define ESAI_xCR_xFSL (1 << ESAI_xCR_xFSL_SHIFT) 254 + #define ESAI_xCR_xSWS_SHIFT 10 255 + #define ESAI_xCR_xSWS_WIDTH 5 256 + #define ESAI_xCR_xSWS_MASK (((1 << ESAI_xCR_xSWS_WIDTH) - 1) << ESAI_xCR_xSWS_SHIFT) 257 + #define ESAI_xCR_xSWS(s, w) ((w < 24 ? (s - w + ((w - 8) >> 2)) : (s < 32 ? 0x1e : 0x1f)) << ESAI_xCR_xSWS_SHIFT) 258 + #define ESAI_xCR_xMOD_SHIFT 8 259 + #define ESAI_xCR_xMOD_WIDTH 2 260 + #define ESAI_xCR_xMOD_MASK (((1 << ESAI_xCR_xMOD_WIDTH) - 1) << ESAI_xCR_xMOD_SHIFT) 261 + #define ESAI_xCR_xMOD_ONDEMAND (0x1 << ESAI_xCR_xMOD_SHIFT) 262 + #define ESAI_xCR_xMOD_NETWORK (0x1 << ESAI_xCR_xMOD_SHIFT) 263 + #define ESAI_xCR_xMOD_AC97 (0x3 << ESAI_xCR_xMOD_SHIFT) 264 + #define ESAI_xCR_xWA_SHIFT 7 265 + #define ESAI_xCR_xWA_MASK (1 << ESAI_xCR_xWA_SHIFT) 266 + #define ESAI_xCR_xWA (1 << ESAI_xCR_xWA_SHIFT) 267 + #define ESAI_xCR_xSHFD_SHIFT 6 268 + #define ESAI_xCR_xSHFD_MASK (1 << ESAI_xCR_xSHFD_SHIFT) 269 + #define ESAI_xCR_xSHFD (1 << ESAI_xCR_xSHFD_SHIFT) 270 + #define ESAI_xCR_xE_SHIFT 0 271 + #define ESAI_xCR_TE_WIDTH 6 272 + #define ESAI_xCR_RE_WIDTH 4 273 + #define ESAI_xCR_TE_MASK (((1 << ESAI_xCR_TE_WIDTH) - 1) << ESAI_xCR_xE_SHIFT) 274 + #define ESAI_xCR_RE_MASK (((1 << ESAI_xCR_RE_WIDTH) - 1) << ESAI_xCR_xE_SHIFT) 275 + #define ESAI_xCR_TE(x) ((ESAI_xCR_TE_MASK >> (ESAI_xCR_TE_WIDTH - ((x + 1) >> 1))) & ESAI_xCR_TE_MASK) 276 + #define ESAI_xCR_RE(x) ((ESAI_xCR_RE_MASK >> (ESAI_xCR_RE_WIDTH - ((x + 1) >> 1))) & ESAI_xCR_RE_MASK) 277 + 278 + /* 279 + * Transmit Clock Control Register -- REG_ESAI_TCCR 0xD8 280 + * Receive Clock Control Register -- REG_ESAI_RCCR 0xE0 281 + */ 282 + #define ESAI_xCCR_xHCKD_SHIFT 23 283 + #define ESAI_xCCR_xHCKD_MASK (1 << ESAI_xCCR_xHCKD_SHIFT) 284 + #define ESAI_xCCR_xHCKD (1 << ESAI_xCCR_xHCKD_SHIFT) 285 + #define ESAI_xCCR_xFSD_SHIFT 22 286 + #define ESAI_xCCR_xFSD_MASK (1 << ESAI_xCCR_xFSD_SHIFT) 287 + #define ESAI_xCCR_xFSD (1 << ESAI_xCCR_xFSD_SHIFT) 288 + #define ESAI_xCCR_xCKD_SHIFT 21 289 + #define ESAI_xCCR_xCKD_MASK (1 << ESAI_xCCR_xCKD_SHIFT) 290 + #define ESAI_xCCR_xCKD (1 << ESAI_xCCR_xCKD_SHIFT) 291 + #define ESAI_xCCR_xHCKP_SHIFT 20 292 + #define ESAI_xCCR_xHCKP_MASK (1 << ESAI_xCCR_xHCKP_SHIFT) 293 + #define ESAI_xCCR_xHCKP (1 << ESAI_xCCR_xHCKP_SHIFT) 294 + #define ESAI_xCCR_xFSP_SHIFT 19 295 + #define ESAI_xCCR_xFSP_MASK (1 << ESAI_xCCR_xFSP_SHIFT) 296 + #define ESAI_xCCR_xFSP (1 << ESAI_xCCR_xFSP_SHIFT) 297 + #define ESAI_xCCR_xCKP_SHIFT 18 298 + #define ESAI_xCCR_xCKP_MASK (1 << ESAI_xCCR_xCKP_SHIFT) 299 + #define ESAI_xCCR_xCKP (1 << ESAI_xCCR_xCKP_SHIFT) 300 + #define ESAI_xCCR_xFP_SHIFT 14 301 + #define ESAI_xCCR_xFP_WIDTH 4 302 + #define ESAI_xCCR_xFP_MASK (((1 << ESAI_xCCR_xFP_WIDTH) - 1) << ESAI_xCCR_xFP_SHIFT) 303 + #define ESAI_xCCR_xFP(v) ((((v) - 1) << ESAI_xCCR_xFP_SHIFT) & ESAI_xCCR_xFP_MASK) 304 + #define ESAI_xCCR_xDC_SHIFT 9 305 + #define ESAI_xCCR_xDC_WIDTH 4 306 + #define ESAI_xCCR_xDC_MASK (((1 << ESAI_xCCR_xDC_WIDTH) - 1) << ESAI_xCCR_xDC_SHIFT) 307 + #define ESAI_xCCR_xDC(v) ((((v) - 1) << ESAI_xCCR_xDC_SHIFT) & ESAI_xCCR_xDC_MASK) 308 + #define ESAI_xCCR_xPSR_SHIFT 8 309 + #define ESAI_xCCR_xPSR_MASK (1 << ESAI_xCCR_xPSR_SHIFT) 310 + #define ESAI_xCCR_xPSR_BYPASS (1 << ESAI_xCCR_xPSR_SHIFT) 311 + #define ESAI_xCCR_xPSR_DIV8 (0 << ESAI_xCCR_xPSR_SHIFT) 312 + #define ESAI_xCCR_xPM_SHIFT 0 313 + #define ESAI_xCCR_xPM_WIDTH 8 314 + #define ESAI_xCCR_xPM_MASK (((1 << ESAI_xCCR_xPM_WIDTH) - 1) << ESAI_xCCR_xPM_SHIFT) 315 + #define ESAI_xCCR_xPM(v) ((((v) - 1) << ESAI_xCCR_xPM_SHIFT) & ESAI_xCCR_xPM_MASK) 316 + 317 + /* Transmit Slot Mask Register A/B -- REG_ESAI_TSMA/B 0xE4 ~ 0xF0 */ 318 + #define ESAI_xSMA_xS_SHIFT 0 319 + #define ESAI_xSMA_xS_WIDTH 16 320 + #define ESAI_xSMA_xS_MASK (((1 << ESAI_xSMA_xS_WIDTH) - 1) << ESAI_xSMA_xS_SHIFT) 321 + #define ESAI_xSMA_xS(v) ((v) & ESAI_xSMA_xS_MASK) 322 + #define ESAI_xSMB_xS_SHIFT 0 323 + #define ESAI_xSMB_xS_WIDTH 16 324 + #define ESAI_xSMB_xS_MASK (((1 << ESAI_xSMB_xS_WIDTH) - 1) << ESAI_xSMB_xS_SHIFT) 325 + #define ESAI_xSMB_xS(v) (((v) >> ESAI_xSMA_xS_WIDTH) & ESAI_xSMA_xS_MASK) 326 + 327 + /* Port C Direction Register -- REG_ESAI_PRRC 0xF8 */ 328 + #define ESAI_PRRC_PDC_SHIFT 0 329 + #define ESAI_PRRC_PDC_WIDTH 12 330 + #define ESAI_PRRC_PDC_MASK (((1 << ESAI_PRRC_PDC_WIDTH) - 1) << ESAI_PRRC_PDC_SHIFT) 331 + #define ESAI_PRRC_PDC(v) ((v) & ESAI_PRRC_PDC_MASK) 332 + 333 + /* Port C Control Register -- REG_ESAI_PCRC 0xFC */ 334 + #define ESAI_PCRC_PC_SHIFT 0 335 + #define ESAI_PCRC_PC_WIDTH 12 336 + #define ESAI_PCRC_PC_MASK (((1 << ESAI_PCRC_PC_WIDTH) - 1) << ESAI_PCRC_PC_SHIFT) 337 + #define ESAI_PCRC_PC(v) ((v) & ESAI_PCRC_PC_MASK) 338 + 339 + #define ESAI_GPIO 0xfff 340 + 341 + /* ESAI clock source */ 342 + #define ESAI_HCKT_FSYS 0 343 + #define ESAI_HCKT_EXTAL 1 344 + #define ESAI_HCKR_FSYS 2 345 + #define ESAI_HCKR_EXTAL 3 346 + 347 + /* ESAI clock divider */ 348 + #define ESAI_TX_DIV_PSR 0 349 + #define ESAI_TX_DIV_PM 1 350 + #define ESAI_TX_DIV_FP 2 351 + #define ESAI_RX_DIV_PSR 3 352 + #define ESAI_RX_DIV_PM 4 353 + #define ESAI_RX_DIV_FP 5 354 + #endif /* _FSL_ESAI_DAI_H */
+3 -4
sound/soc/fsl/fsl_sai.c
··· 62 62 reg_cr2 = FSL_SAI_RCR2; 63 63 64 64 val_cr2 = sai_readl(sai, sai->base + reg_cr2); 65 + val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; 66 + 65 67 switch (clk_id) { 66 68 case FSL_SAI_CLK_BUS: 67 - val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; 68 69 val_cr2 |= FSL_SAI_CR2_MSEL_BUS; 69 70 break; 70 71 case FSL_SAI_CLK_MAST1: 71 - val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; 72 72 val_cr2 |= FSL_SAI_CR2_MSEL_MCLK1; 73 73 break; 74 74 case FSL_SAI_CLK_MAST2: 75 - val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; 76 75 val_cr2 |= FSL_SAI_CR2_MSEL_MCLK2; 77 76 break; 78 77 case FSL_SAI_CLK_MAST3: 79 - val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; 80 78 val_cr2 |= FSL_SAI_CR2_MSEL_MCLK3; 81 79 break; 82 80 default: 83 81 return -EINVAL; 84 82 } 83 + 85 84 sai_writel(sai, val_cr2, sai->base + reg_cr2); 86 85 87 86 return 0;
+400 -183
sound/soc/fsl/fsl_ssi.c
··· 35 35 #include <linux/module.h> 36 36 #include <linux/interrupt.h> 37 37 #include <linux/clk.h> 38 + #include <linux/debugfs.h> 38 39 #include <linux/device.h> 39 40 #include <linux/delay.h> 40 41 #include <linux/slab.h> ··· 107 106 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE) 108 107 #endif 109 108 110 - /* SIER bitflag of interrupts to enable */ 111 - #define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \ 112 - CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \ 113 - CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \ 114 - CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \ 115 - CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN) 109 + #define FSLSSI_SIER_DBG_RX_FLAGS (CCSR_SSI_SIER_RFF0_EN | \ 110 + CCSR_SSI_SIER_RLS_EN | CCSR_SSI_SIER_RFS_EN | \ 111 + CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_RFRC_EN) 112 + #define FSLSSI_SIER_DBG_TX_FLAGS (CCSR_SSI_SIER_TFE0_EN | \ 113 + CCSR_SSI_SIER_TLS_EN | CCSR_SSI_SIER_TFS_EN | \ 114 + CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TFRC_EN) 115 + #define FSLSSI_SISR_MASK (FSLSSI_SIER_DBG_RX_FLAGS | FSLSSI_SIER_DBG_TX_FLAGS) 116 + 117 + 118 + enum fsl_ssi_type { 119 + FSL_SSI_MCP8610, 120 + FSL_SSI_MX21, 121 + FSL_SSI_MX35, 122 + FSL_SSI_MX51, 123 + }; 124 + 125 + struct fsl_ssi_reg_val { 126 + u32 sier; 127 + u32 srcr; 128 + u32 stcr; 129 + u32 scr; 130 + }; 131 + 132 + struct fsl_ssi_rxtx_reg_val { 133 + struct fsl_ssi_reg_val rx; 134 + struct fsl_ssi_reg_val tx; 135 + }; 116 136 117 137 /** 118 138 * fsl_ssi_private: per-SSI private data ··· 154 132 unsigned int irq; 155 133 unsigned int fifo_depth; 156 134 struct snd_soc_dai_driver cpu_dai_drv; 157 - struct device_attribute dev_attr; 158 135 struct platform_device *pdev; 159 136 137 + enum fsl_ssi_type hw_type; 160 138 bool new_binding; 161 139 bool ssi_on_imx; 162 140 bool imx_ac97; 163 141 bool use_dma; 164 142 bool baudclk_locked; 143 + bool irq_stats; 144 + bool offline_config; 165 145 u8 i2s_mode; 166 146 spinlock_t baudclk_lock; 167 147 struct clk *baudclk; ··· 173 149 struct imx_dma_data filter_data_tx; 174 150 struct imx_dma_data filter_data_rx; 175 151 struct imx_pcm_fiq_params fiq_params; 152 + /* Register values for rx/tx configuration */ 153 + struct fsl_ssi_rxtx_reg_val rxtx_reg_val; 176 154 177 155 struct { 178 156 unsigned int rfrc; ··· 199 173 unsigned int tfe1; 200 174 unsigned int tfe0; 201 175 } stats; 176 + struct dentry *dbg_dir; 177 + struct dentry *dbg_stats; 202 178 203 179 char name[1]; 204 180 }; 181 + 182 + static const struct of_device_id fsl_ssi_ids[] = { 183 + { .compatible = "fsl,mpc8610-ssi", .data = (void *) FSL_SSI_MCP8610}, 184 + { .compatible = "fsl,imx51-ssi", .data = (void *) FSL_SSI_MX51}, 185 + { .compatible = "fsl,imx35-ssi", .data = (void *) FSL_SSI_MX35}, 186 + { .compatible = "fsl,imx21-ssi", .data = (void *) FSL_SSI_MX21}, 187 + {} 188 + }; 189 + MODULE_DEVICE_TABLE(of, fsl_ssi_ids); 205 190 206 191 /** 207 192 * fsl_ssi_isr: SSI interrupt handler ··· 232 195 struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 233 196 irqreturn_t ret = IRQ_NONE; 234 197 __be32 sisr; 235 - __be32 sisr2 = 0; 198 + __be32 sisr2; 199 + __be32 sisr_write_mask = 0; 200 + 201 + switch (ssi_private->hw_type) { 202 + case FSL_SSI_MX21: 203 + sisr_write_mask = 0; 204 + break; 205 + 206 + case FSL_SSI_MCP8610: 207 + case FSL_SSI_MX35: 208 + sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC | 209 + CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | 210 + CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1; 211 + break; 212 + 213 + case FSL_SSI_MX51: 214 + sisr_write_mask = CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | 215 + CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1; 216 + break; 217 + } 236 218 237 219 /* We got an interrupt, so read the status register to see what we 238 220 were interrupted for. We mask it with the Interrupt Enable register 239 221 so that we only check for events that we're interested in. 240 222 */ 241 - sisr = read_ssi(&ssi->sisr) & SIER_FLAGS; 223 + sisr = read_ssi(&ssi->sisr) & FSLSSI_SISR_MASK; 242 224 243 225 if (sisr & CCSR_SSI_SISR_RFRC) { 244 226 ssi_private->stats.rfrc++; 245 - sisr2 |= CCSR_SSI_SISR_RFRC; 246 227 ret = IRQ_HANDLED; 247 228 } 248 229 249 230 if (sisr & CCSR_SSI_SISR_TFRC) { 250 231 ssi_private->stats.tfrc++; 251 - sisr2 |= CCSR_SSI_SISR_TFRC; 252 232 ret = IRQ_HANDLED; 253 233 } 254 234 ··· 306 252 307 253 if (sisr & CCSR_SSI_SISR_ROE1) { 308 254 ssi_private->stats.roe1++; 309 - sisr2 |= CCSR_SSI_SISR_ROE1; 310 255 ret = IRQ_HANDLED; 311 256 } 312 257 313 258 if (sisr & CCSR_SSI_SISR_ROE0) { 314 259 ssi_private->stats.roe0++; 315 - sisr2 |= CCSR_SSI_SISR_ROE0; 316 260 ret = IRQ_HANDLED; 317 261 } 318 262 319 263 if (sisr & CCSR_SSI_SISR_TUE1) { 320 264 ssi_private->stats.tue1++; 321 - sisr2 |= CCSR_SSI_SISR_TUE1; 322 265 ret = IRQ_HANDLED; 323 266 } 324 267 325 268 if (sisr & CCSR_SSI_SISR_TUE0) { 326 269 ssi_private->stats.tue0++; 327 - sisr2 |= CCSR_SSI_SISR_TUE0; 328 270 ret = IRQ_HANDLED; 329 271 } 330 272 ··· 364 314 ret = IRQ_HANDLED; 365 315 } 366 316 317 + sisr2 = sisr & sisr_write_mask; 367 318 /* Clear the bits that we set */ 368 319 if (sisr2) 369 320 write_ssi(sisr2, &ssi->sisr); 370 321 371 322 return ret; 323 + } 324 + 325 + #if IS_ENABLED(CONFIG_DEBUG_FS) 326 + /* Show the statistics of a flag only if its interrupt is enabled. The 327 + * compiler will optimze this code to a no-op if the interrupt is not 328 + * enabled. 329 + */ 330 + #define SIER_SHOW(flag, name) \ 331 + do { \ 332 + if (FSLSSI_SISR_MASK & CCSR_SSI_SIER_##flag) \ 333 + seq_printf(s, #name "=%u\n", ssi_private->stats.name); \ 334 + } while (0) 335 + 336 + 337 + /** 338 + * fsl_sysfs_ssi_show: display SSI statistics 339 + * 340 + * Display the statistics for the current SSI device. To avoid confusion, 341 + * we only show those counts that are enabled. 342 + */ 343 + static int fsl_ssi_stats_show(struct seq_file *s, void *unused) 344 + { 345 + struct fsl_ssi_private *ssi_private = s->private; 346 + 347 + SIER_SHOW(RFRC_EN, rfrc); 348 + SIER_SHOW(TFRC_EN, tfrc); 349 + SIER_SHOW(CMDAU_EN, cmdau); 350 + SIER_SHOW(CMDDU_EN, cmddu); 351 + SIER_SHOW(RXT_EN, rxt); 352 + SIER_SHOW(RDR1_EN, rdr1); 353 + SIER_SHOW(RDR0_EN, rdr0); 354 + SIER_SHOW(TDE1_EN, tde1); 355 + SIER_SHOW(TDE0_EN, tde0); 356 + SIER_SHOW(ROE1_EN, roe1); 357 + SIER_SHOW(ROE0_EN, roe0); 358 + SIER_SHOW(TUE1_EN, tue1); 359 + SIER_SHOW(TUE0_EN, tue0); 360 + SIER_SHOW(TFS_EN, tfs); 361 + SIER_SHOW(RFS_EN, rfs); 362 + SIER_SHOW(TLS_EN, tls); 363 + SIER_SHOW(RLS_EN, rls); 364 + SIER_SHOW(RFF1_EN, rff1); 365 + SIER_SHOW(RFF0_EN, rff0); 366 + SIER_SHOW(TFE1_EN, tfe1); 367 + SIER_SHOW(TFE0_EN, tfe0); 368 + 369 + return 0; 370 + } 371 + 372 + static int fsl_ssi_stats_open(struct inode *inode, struct file *file) 373 + { 374 + return single_open(file, fsl_ssi_stats_show, inode->i_private); 375 + } 376 + 377 + static const struct file_operations fsl_ssi_stats_ops = { 378 + .open = fsl_ssi_stats_open, 379 + .read = seq_read, 380 + .llseek = seq_lseek, 381 + .release = single_release, 382 + }; 383 + 384 + static int fsl_ssi_debugfs_create(struct fsl_ssi_private *ssi_private, 385 + struct device *dev) 386 + { 387 + ssi_private->dbg_dir = debugfs_create_dir(dev_name(dev), NULL); 388 + if (!ssi_private->dbg_dir) 389 + return -ENOMEM; 390 + 391 + ssi_private->dbg_stats = debugfs_create_file("stats", S_IRUGO, 392 + ssi_private->dbg_dir, ssi_private, &fsl_ssi_stats_ops); 393 + if (!ssi_private->dbg_stats) { 394 + debugfs_remove(ssi_private->dbg_dir); 395 + return -ENOMEM; 396 + } 397 + 398 + return 0; 399 + } 400 + 401 + static void fsl_ssi_debugfs_remove(struct fsl_ssi_private *ssi_private) 402 + { 403 + debugfs_remove(ssi_private->dbg_stats); 404 + debugfs_remove(ssi_private->dbg_dir); 405 + } 406 + 407 + #else 408 + 409 + static int fsl_ssi_debugfs_create(struct fsl_ssi_private *ssi_private, 410 + struct device *dev) 411 + { 412 + return 0; 413 + } 414 + 415 + static void fsl_ssi_debugfs_remove(struct fsl_ssi_private *ssi_private) 416 + { 417 + } 418 + 419 + #endif /* IS_ENABLED(CONFIG_DEBUG_FS) */ 420 + 421 + /* 422 + * Enable/Disable all rx/tx config flags at once. 423 + */ 424 + static void fsl_ssi_rxtx_config(struct fsl_ssi_private *ssi_private, 425 + bool enable) 426 + { 427 + struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 428 + struct fsl_ssi_rxtx_reg_val *vals = &ssi_private->rxtx_reg_val; 429 + 430 + if (enable) { 431 + write_ssi_mask(&ssi->sier, 0, vals->rx.sier | vals->tx.sier); 432 + write_ssi_mask(&ssi->srcr, 0, vals->rx.srcr | vals->tx.srcr); 433 + write_ssi_mask(&ssi->stcr, 0, vals->rx.stcr | vals->tx.stcr); 434 + } else { 435 + write_ssi_mask(&ssi->srcr, vals->rx.srcr | vals->tx.srcr, 0); 436 + write_ssi_mask(&ssi->stcr, vals->rx.stcr | vals->tx.stcr, 0); 437 + write_ssi_mask(&ssi->sier, vals->rx.sier | vals->tx.sier, 0); 438 + } 439 + } 440 + 441 + /* 442 + * Enable/Disable a ssi configuration. You have to pass either 443 + * ssi_private->rxtx_reg_val.rx or tx as vals parameter. 444 + */ 445 + static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, 446 + struct fsl_ssi_reg_val *vals) 447 + { 448 + struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 449 + struct fsl_ssi_reg_val *avals; 450 + u32 scr_val = read_ssi(&ssi->scr); 451 + int nr_active_streams = !!(scr_val & CCSR_SSI_SCR_TE) + 452 + !!(scr_val & CCSR_SSI_SCR_RE); 453 + 454 + /* Find the other direction values rx or tx which we do not want to 455 + * modify */ 456 + if (&ssi_private->rxtx_reg_val.rx == vals) 457 + avals = &ssi_private->rxtx_reg_val.tx; 458 + else 459 + avals = &ssi_private->rxtx_reg_val.rx; 460 + 461 + /* If vals should be disabled, start with disabling the unit */ 462 + if (!enable) { 463 + u32 scr = vals->scr & (vals->scr ^ avals->scr); 464 + write_ssi_mask(&ssi->scr, scr, 0); 465 + } 466 + 467 + /* 468 + * We are running on a SoC which does not support online SSI 469 + * reconfiguration, so we have to enable all necessary flags at once 470 + * even if we do not use them later (capture and playback configuration) 471 + */ 472 + if (ssi_private->offline_config) { 473 + if ((enable && !nr_active_streams) || 474 + (!enable && nr_active_streams == 1)) 475 + fsl_ssi_rxtx_config(ssi_private, enable); 476 + 477 + goto config_done; 478 + } 479 + 480 + /* 481 + * Configure single direction units while the SSI unit is running 482 + * (online configuration) 483 + */ 484 + if (enable) { 485 + write_ssi_mask(&ssi->sier, 0, vals->sier); 486 + write_ssi_mask(&ssi->srcr, 0, vals->srcr); 487 + write_ssi_mask(&ssi->stcr, 0, vals->stcr); 488 + } else { 489 + u32 sier; 490 + u32 srcr; 491 + u32 stcr; 492 + 493 + /* 494 + * Disabling the necessary flags for one of rx/tx while the 495 + * other stream is active is a little bit more difficult. We 496 + * have to disable only those flags that differ between both 497 + * streams (rx XOR tx) and that are set in the stream that is 498 + * disabled now. Otherwise we could alter flags of the other 499 + * stream 500 + */ 501 + 502 + /* These assignments are simply vals without bits set in avals*/ 503 + sier = vals->sier & (vals->sier ^ avals->sier); 504 + srcr = vals->srcr & (vals->srcr ^ avals->srcr); 505 + stcr = vals->stcr & (vals->stcr ^ avals->stcr); 506 + 507 + write_ssi_mask(&ssi->srcr, srcr, 0); 508 + write_ssi_mask(&ssi->stcr, stcr, 0); 509 + write_ssi_mask(&ssi->sier, sier, 0); 510 + } 511 + 512 + config_done: 513 + /* Enabling of subunits is done after configuration */ 514 + if (enable) 515 + write_ssi_mask(&ssi->scr, 0, vals->scr); 516 + } 517 + 518 + 519 + static void fsl_ssi_rx_config(struct fsl_ssi_private *ssi_private, bool enable) 520 + { 521 + fsl_ssi_config(ssi_private, enable, &ssi_private->rxtx_reg_val.rx); 522 + } 523 + 524 + static void fsl_ssi_tx_config(struct fsl_ssi_private *ssi_private, bool enable) 525 + { 526 + fsl_ssi_config(ssi_private, enable, &ssi_private->rxtx_reg_val.tx); 527 + } 528 + 529 + /* 530 + * Setup rx/tx register values used to enable/disable the streams. These will 531 + * be used later in fsl_ssi_config to setup the streams without the need to 532 + * check for all different SSI modes. 533 + */ 534 + static void fsl_ssi_setup_reg_vals(struct fsl_ssi_private *ssi_private) 535 + { 536 + struct fsl_ssi_rxtx_reg_val *reg = &ssi_private->rxtx_reg_val; 537 + 538 + reg->rx.sier = CCSR_SSI_SIER_RFF0_EN; 539 + reg->rx.srcr = CCSR_SSI_SRCR_RFEN0; 540 + reg->rx.scr = 0; 541 + reg->tx.sier = CCSR_SSI_SIER_TFE0_EN; 542 + reg->tx.stcr = CCSR_SSI_STCR_TFEN0; 543 + reg->tx.scr = 0; 544 + 545 + if (!ssi_private->imx_ac97) { 546 + reg->rx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE; 547 + reg->rx.sier |= CCSR_SSI_SIER_RFF0_EN; 548 + reg->tx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE; 549 + reg->tx.sier |= CCSR_SSI_SIER_TFE0_EN; 550 + } 551 + 552 + if (ssi_private->use_dma) { 553 + reg->rx.sier |= CCSR_SSI_SIER_RDMAE; 554 + reg->tx.sier |= CCSR_SSI_SIER_TDMAE; 555 + } else { 556 + reg->rx.sier |= CCSR_SSI_SIER_RIE; 557 + reg->tx.sier |= CCSR_SSI_SIER_TIE; 558 + } 559 + 560 + reg->rx.sier |= FSLSSI_SIER_DBG_RX_FLAGS; 561 + reg->tx.sier |= FSLSSI_SIER_DBG_TX_FLAGS; 372 562 } 373 563 374 564 static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private) ··· 647 357 u8 wm; 648 358 int synchronous = ssi_private->cpu_dai_drv.symmetric_rates; 649 359 360 + fsl_ssi_setup_reg_vals(ssi_private); 361 + 650 362 if (ssi_private->imx_ac97) 651 363 ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL | CCSR_SSI_SCR_NET; 652 364 else ··· 672 380 ssi_private->i2s_mode | 673 381 (synchronous ? CCSR_SSI_SCR_SYN : 0)); 674 382 675 - write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | 676 - CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TEFS | 677 - CCSR_SSI_STCR_TSCKP, &ssi->stcr); 383 + write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFSI | 384 + CCSR_SSI_STCR_TEFS | CCSR_SSI_STCR_TSCKP, &ssi->stcr); 678 385 679 - write_ssi(CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFEN0 | 680 - CCSR_SSI_SRCR_RFSI | CCSR_SSI_SRCR_REFS | 681 - CCSR_SSI_SRCR_RSCKP, &ssi->srcr); 386 + write_ssi(CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFSI | 387 + CCSR_SSI_SRCR_REFS | CCSR_SSI_SRCR_RSCKP, &ssi->srcr); 388 + 682 389 /* 683 390 * The DC and PM bits are only used if the SSI is the clock master. 684 391 */ ··· 709 418 */ 710 419 if (ssi_private->imx_ac97) 711 420 fsl_ssi_setup_ac97(ssi_private); 421 + 422 + /* 423 + * Set a default slot number so that there is no need for those common 424 + * cases like I2S mode to call the extra set_tdm_slot() any more. 425 + */ 426 + if (!ssi_private->imx_ac97) { 427 + write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_DC_MASK, 428 + CCSR_SSI_SxCCR_DC(2)); 429 + write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_DC_MASK, 430 + CCSR_SSI_SxCCR_DC(2)); 431 + } 712 432 713 433 return 0; 714 434 } ··· 1063 761 struct snd_soc_pcm_runtime *rtd = substream->private_data; 1064 762 struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); 1065 763 struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 1066 - unsigned int sier_bits; 1067 764 unsigned long flags; 1068 - 1069 - /* 1070 - * Enable only the interrupts and DMA requests 1071 - * that are needed for the channel. As the fiq 1072 - * is polling for this bits, we have to ensure 1073 - * that this are aligned with the preallocated 1074 - * buffers 1075 - */ 1076 - 1077 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1078 - if (ssi_private->use_dma) 1079 - sier_bits = SIER_FLAGS; 1080 - else 1081 - sier_bits = CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TFE0_EN; 1082 - } else { 1083 - if (ssi_private->use_dma) 1084 - sier_bits = SIER_FLAGS; 1085 - else 1086 - sier_bits = CCSR_SSI_SIER_RIE | CCSR_SSI_SIER_RFF0_EN; 1087 - } 1088 765 1089 766 switch (cmd) { 1090 767 case SNDRV_PCM_TRIGGER_START: 1091 768 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1092 769 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1093 - write_ssi_mask(&ssi->scr, 0, 1094 - CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE); 770 + fsl_ssi_tx_config(ssi_private, true); 1095 771 else 1096 - write_ssi_mask(&ssi->scr, 0, 1097 - CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE); 772 + fsl_ssi_rx_config(ssi_private, true); 1098 773 break; 1099 774 1100 775 case SNDRV_PCM_TRIGGER_STOP: 1101 776 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1102 777 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1103 - write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TE, 0); 778 + fsl_ssi_tx_config(ssi_private, false); 1104 779 else 1105 - write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0); 780 + fsl_ssi_rx_config(ssi_private, false); 1106 781 1107 782 if (!ssi_private->imx_ac97 && (read_ssi(&ssi->scr) & 1108 783 (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0) { 1109 - write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0); 1110 784 spin_lock_irqsave(&ssi_private->baudclk_lock, flags); 1111 785 ssi_private->baudclk_locked = false; 1112 786 spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); ··· 1093 815 return -EINVAL; 1094 816 } 1095 817 1096 - write_ssi(sier_bits, &ssi->sier); 818 + if (ssi_private->imx_ac97) { 819 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 820 + write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor); 821 + else 822 + write_ssi(CCSR_SSI_SOR_RX_CLR, &ssi->sor); 823 + } 1097 824 1098 825 return 0; 1099 826 } ··· 1146 863 .name = "fsl-ssi", 1147 864 }; 1148 865 1149 - /** 1150 - * fsl_ssi_ac97_trigger: start and stop the AC97 receive/transmit. 1151 - * 1152 - * This function is called by ALSA to start, stop, pause, and resume the 1153 - * transfer of data. 1154 - */ 1155 - static int fsl_ssi_ac97_trigger(struct snd_pcm_substream *substream, int cmd, 1156 - struct snd_soc_dai *dai) 1157 - { 1158 - struct snd_soc_pcm_runtime *rtd = substream->private_data; 1159 - struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata( 1160 - rtd->cpu_dai); 1161 - struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 1162 - 1163 - switch (cmd) { 1164 - case SNDRV_PCM_TRIGGER_START: 1165 - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1166 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1167 - write_ssi_mask(&ssi->sier, 0, CCSR_SSI_SIER_TIE | 1168 - CCSR_SSI_SIER_TFE0_EN); 1169 - else 1170 - write_ssi_mask(&ssi->sier, 0, CCSR_SSI_SIER_RIE | 1171 - CCSR_SSI_SIER_RFF0_EN); 1172 - break; 1173 - 1174 - case SNDRV_PCM_TRIGGER_STOP: 1175 - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1176 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1177 - write_ssi_mask(&ssi->sier, CCSR_SSI_SIER_TIE | 1178 - CCSR_SSI_SIER_TFE0_EN, 0); 1179 - else 1180 - write_ssi_mask(&ssi->sier, CCSR_SSI_SIER_RIE | 1181 - CCSR_SSI_SIER_RFF0_EN, 0); 1182 - break; 1183 - 1184 - default: 1185 - return -EINVAL; 1186 - } 1187 - 1188 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1189 - write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor); 1190 - else 1191 - write_ssi(CCSR_SSI_SOR_RX_CLR, &ssi->sor); 1192 - 1193 - return 0; 1194 - } 1195 - 1196 - static const struct snd_soc_dai_ops fsl_ssi_ac97_dai_ops = { 1197 - .startup = fsl_ssi_startup, 1198 - .trigger = fsl_ssi_ac97_trigger, 1199 - }; 1200 - 1201 866 static struct snd_soc_dai_driver fsl_ssi_ac97_dai = { 1202 867 .ac97_control = 1, 1203 868 .playback = { ··· 1162 931 .rates = SNDRV_PCM_RATE_48000, 1163 932 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1164 933 }, 1165 - .ops = &fsl_ssi_ac97_dai_ops, 934 + .ops = &fsl_ssi_dai_ops, 1166 935 }; 1167 936 1168 937 ··· 1220 989 .write = fsl_ssi_ac97_write, 1221 990 }; 1222 991 1223 - /* Show the statistics of a flag only if its interrupt is enabled. The 1224 - * compiler will optimze this code to a no-op if the interrupt is not 1225 - * enabled. 1226 - */ 1227 - #define SIER_SHOW(flag, name) \ 1228 - do { \ 1229 - if (SIER_FLAGS & CCSR_SSI_SIER_##flag) \ 1230 - length += sprintf(buf + length, #name "=%u\n", \ 1231 - ssi_private->stats.name); \ 1232 - } while (0) 1233 - 1234 - 1235 - /** 1236 - * fsl_sysfs_ssi_show: display SSI statistics 1237 - * 1238 - * Display the statistics for the current SSI device. To avoid confusion, 1239 - * we only show those counts that are enabled. 1240 - */ 1241 - static ssize_t fsl_sysfs_ssi_show(struct device *dev, 1242 - struct device_attribute *attr, char *buf) 1243 - { 1244 - struct fsl_ssi_private *ssi_private = 1245 - container_of(attr, struct fsl_ssi_private, dev_attr); 1246 - ssize_t length = 0; 1247 - 1248 - SIER_SHOW(RFRC_EN, rfrc); 1249 - SIER_SHOW(TFRC_EN, tfrc); 1250 - SIER_SHOW(CMDAU_EN, cmdau); 1251 - SIER_SHOW(CMDDU_EN, cmddu); 1252 - SIER_SHOW(RXT_EN, rxt); 1253 - SIER_SHOW(RDR1_EN, rdr1); 1254 - SIER_SHOW(RDR0_EN, rdr0); 1255 - SIER_SHOW(TDE1_EN, tde1); 1256 - SIER_SHOW(TDE0_EN, tde0); 1257 - SIER_SHOW(ROE1_EN, roe1); 1258 - SIER_SHOW(ROE0_EN, roe0); 1259 - SIER_SHOW(TUE1_EN, tue1); 1260 - SIER_SHOW(TUE0_EN, tue0); 1261 - SIER_SHOW(TFS_EN, tfs); 1262 - SIER_SHOW(RFS_EN, rfs); 1263 - SIER_SHOW(TLS_EN, tls); 1264 - SIER_SHOW(RLS_EN, rls); 1265 - SIER_SHOW(RFF1_EN, rff1); 1266 - SIER_SHOW(RFF0_EN, rff0); 1267 - SIER_SHOW(TFE1_EN, tfe1); 1268 - SIER_SHOW(TFE0_EN, tfe0); 1269 - 1270 - return length; 1271 - } 1272 - 1273 992 /** 1274 993 * Make every character in a string lower-case 1275 994 */ ··· 1241 1060 int ret = 0; 1242 1061 struct device_attribute *dev_attr = NULL; 1243 1062 struct device_node *np = pdev->dev.of_node; 1063 + const struct of_device_id *of_id; 1064 + enum fsl_ssi_type hw_type; 1244 1065 const char *p, *sprop; 1245 1066 const uint32_t *iprop; 1246 1067 struct resource res; ··· 1256 1073 */ 1257 1074 if (!of_device_is_available(np)) 1258 1075 return -ENODEV; 1076 + 1077 + of_id = of_match_device(fsl_ssi_ids, &pdev->dev); 1078 + if (!of_id) 1079 + return -EINVAL; 1080 + hw_type = (enum fsl_ssi_type) of_id->data; 1259 1081 1260 1082 /* We only support the SSI in "I2S Slave" mode */ 1261 1083 sprop = of_get_property(np, "fsl,mode", NULL); ··· 1288 1100 1289 1101 ssi_private->use_dma = !of_property_read_bool(np, 1290 1102 "fsl,fiq-stream-filter"); 1103 + ssi_private->hw_type = hw_type; 1291 1104 1292 1105 if (ac97) { 1293 1106 memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai, ··· 1342 1153 ssi_private->baudclk_locked = false; 1343 1154 spin_lock_init(&ssi_private->baudclk_lock); 1344 1155 1345 - if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx21-ssi")) { 1156 + /* 1157 + * imx51 and later SoCs have a slightly different IP that allows the 1158 + * SSI configuration while the SSI unit is running. 1159 + * 1160 + * More important, it is necessary on those SoCs to configure the 1161 + * sperate TX/RX DMA bits just before starting the stream 1162 + * (fsl_ssi_trigger). The SDMA unit has to be configured before fsl_ssi 1163 + * sends any DMA requests to the SDMA unit, otherwise it is not defined 1164 + * how the SDMA unit handles the DMA request. 1165 + * 1166 + * SDMA units are present on devices starting at imx35 but the imx35 1167 + * reference manual states that the DMA bits should not be changed 1168 + * while the SSI unit is running (SSIEN). So we support the necessary 1169 + * online configuration of fsl-ssi starting at imx51. 1170 + */ 1171 + switch (hw_type) { 1172 + case FSL_SSI_MCP8610: 1173 + case FSL_SSI_MX21: 1174 + case FSL_SSI_MX35: 1175 + ssi_private->offline_config = true; 1176 + break; 1177 + case FSL_SSI_MX51: 1178 + ssi_private->offline_config = false; 1179 + break; 1180 + } 1181 + 1182 + if (hw_type == FSL_SSI_MX21 || hw_type == FSL_SSI_MX51 || 1183 + hw_type == FSL_SSI_MX35) { 1346 1184 u32 dma_events[2]; 1347 1185 ssi_private->ssi_on_imx = true; 1348 1186 ··· 1391 1175 */ 1392 1176 ssi_private->baudclk = devm_clk_get(&pdev->dev, "baud"); 1393 1177 if (IS_ERR(ssi_private->baudclk)) 1394 - dev_warn(&pdev->dev, "could not get baud clock: %d\n", ret); 1178 + dev_warn(&pdev->dev, "could not get baud clock: %ld\n", 1179 + PTR_ERR(ssi_private->baudclk)); 1395 1180 else 1396 1181 clk_prepare_enable(ssi_private->baudclk); 1397 1182 ··· 1434 1217 dma_events[0], shared ? IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI); 1435 1218 imx_pcm_dma_params_init_data(&ssi_private->filter_data_rx, 1436 1219 dma_events[1], shared ? IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI); 1437 - } else if (ssi_private->use_dma) { 1220 + } 1221 + 1222 + /* 1223 + * Enable interrupts only for MCP8610 and MX51. The other MXs have 1224 + * different writeable interrupt status registers. 1225 + */ 1226 + if (ssi_private->use_dma) { 1438 1227 /* The 'name' should not have any slashes in it. */ 1439 1228 ret = devm_request_irq(&pdev->dev, ssi_private->irq, 1440 1229 fsl_ssi_isr, 0, ssi_private->name, 1441 1230 ssi_private); 1231 + ssi_private->irq_stats = true; 1442 1232 if (ret < 0) { 1443 1233 dev_err(&pdev->dev, "could not claim irq %u\n", 1444 1234 ssi_private->irq); 1445 - goto error_irqmap; 1235 + goto error_clk; 1446 1236 } 1447 - } 1448 - 1449 - /* Initialize the the device_attribute structure */ 1450 - dev_attr = &ssi_private->dev_attr; 1451 - sysfs_attr_init(&dev_attr->attr); 1452 - dev_attr->attr.name = "statistics"; 1453 - dev_attr->attr.mode = S_IRUGO; 1454 - dev_attr->show = fsl_sysfs_ssi_show; 1455 - 1456 - ret = device_create_file(&pdev->dev, dev_attr); 1457 - if (ret) { 1458 - dev_err(&pdev->dev, "could not create sysfs %s file\n", 1459 - ssi_private->dev_attr.attr.name); 1460 - goto error_clk; 1461 1237 } 1462 1238 1463 1239 /* Register with ASoC */ ··· 1462 1252 dev_err(&pdev->dev, "failed to register DAI: %d\n", ret); 1463 1253 goto error_dev; 1464 1254 } 1255 + 1256 + ret = fsl_ssi_debugfs_create(ssi_private, &pdev->dev); 1257 + if (ret) 1258 + goto error_dbgfs; 1465 1259 1466 1260 if (ssi_private->ssi_on_imx) { 1467 1261 if (!ssi_private->use_dma) { ··· 1486 1272 1487 1273 ret = imx_pcm_fiq_init(pdev, &ssi_private->fiq_params); 1488 1274 if (ret) 1489 - goto error_dev; 1275 + goto error_pcm; 1490 1276 } else { 1491 1277 ret = imx_pcm_dma_init(pdev); 1492 1278 if (ret) 1493 - goto error_dev; 1279 + goto error_pcm; 1494 1280 } 1495 1281 } 1496 1282 ··· 1532 1318 return 0; 1533 1319 1534 1320 error_dai: 1321 + if (ssi_private->ssi_on_imx && !ssi_private->use_dma) 1322 + imx_pcm_fiq_exit(pdev); 1323 + 1324 + error_pcm: 1325 + fsl_ssi_debugfs_remove(ssi_private); 1326 + 1327 + error_dbgfs: 1535 1328 snd_soc_unregister_component(&pdev->dev); 1536 1329 1537 1330 error_dev: ··· 1552 1331 } 1553 1332 1554 1333 error_irqmap: 1555 - irq_dispose_mapping(ssi_private->irq); 1334 + if (ssi_private->irq_stats) 1335 + irq_dispose_mapping(ssi_private->irq); 1556 1336 1557 1337 return ret; 1558 1338 } ··· 1562 1340 { 1563 1341 struct fsl_ssi_private *ssi_private = dev_get_drvdata(&pdev->dev); 1564 1342 1343 + fsl_ssi_debugfs_remove(ssi_private); 1344 + 1565 1345 if (!ssi_private->new_binding) 1566 1346 platform_device_unregister(ssi_private->pdev); 1567 1347 snd_soc_unregister_component(&pdev->dev); 1568 - device_remove_file(&pdev->dev, &ssi_private->dev_attr); 1569 1348 if (ssi_private->ssi_on_imx) { 1570 1349 if (!IS_ERR(ssi_private->baudclk)) 1571 1350 clk_disable_unprepare(ssi_private->baudclk); 1572 1351 clk_disable_unprepare(ssi_private->clk); 1573 1352 } 1574 - irq_dispose_mapping(ssi_private->irq); 1353 + if (ssi_private->irq_stats) 1354 + irq_dispose_mapping(ssi_private->irq); 1575 1355 1576 1356 return 0; 1577 1357 } 1578 - 1579 - static const struct of_device_id fsl_ssi_ids[] = { 1580 - { .compatible = "fsl,mpc8610-ssi", }, 1581 - { .compatible = "fsl,imx21-ssi", }, 1582 - {} 1583 - }; 1584 - MODULE_DEVICE_TABLE(of, fsl_ssi_ids); 1585 1358 1586 1359 static struct platform_driver fsl_ssi_driver = { 1587 1360 .driver = {
-3
sound/soc/fsl/imx-pcm-dma.c
··· 41 41 SNDRV_PCM_INFO_PAUSE | 42 42 SNDRV_PCM_INFO_RESUME, 43 43 .formats = SNDRV_PCM_FMTBIT_S16_LE, 44 - .rate_min = 8000, 45 - .channels_min = 2, 46 - .channels_max = 2, 47 44 .buffer_bytes_max = IMX_SSI_DMABUF_SIZE, 48 45 .period_bytes_min = 128, 49 46 .period_bytes_max = 65535, /* Limited by SDMA engine */
-3
sound/soc/fsl/imx-pcm-fiq.c
··· 162 162 SNDRV_PCM_INFO_PAUSE | 163 163 SNDRV_PCM_INFO_RESUME, 164 164 .formats = SNDRV_PCM_FMTBIT_S16_LE, 165 - .rate_min = 8000, 166 - .channels_min = 2, 167 - .channels_max = 2, 168 165 .buffer_bytes_max = IMX_SSI_DMABUF_SIZE, 169 166 .period_bytes_min = 128, 170 167 .period_bytes_max = 16 * 1024,
-4
sound/soc/fsl/mpc5200_dma.c
··· 200 200 SNDRV_PCM_INFO_BATCH, 201 201 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | 202 202 SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE, 203 - .rate_min = 8000, 204 - .rate_max = 48000, 205 - .channels_min = 1, 206 - .channels_max = 2, 207 203 .period_bytes_max = 1024 * 1024, 208 204 .period_bytes_min = 32, 209 205 .periods_min = 2,
+36 -34
sound/soc/generic/simple-card.c
··· 9 9 * published by the Free Software Foundation. 10 10 */ 11 11 #include <linux/clk.h> 12 + #include <linux/module.h> 12 13 #include <linux/of.h> 13 14 #include <linux/platform_device.h> 14 - #include <linux/module.h> 15 + #include <linux/string.h> 15 16 #include <sound/simple_card.h> 16 - 17 - #define asoc_simple_get_card_info(p) \ 18 - container_of(p->dai_link, struct asoc_simple_card_info, snd_link) 19 17 20 18 static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, 21 19 struct asoc_simple_dai *set, ··· 39 41 40 42 static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) 41 43 { 42 - struct asoc_simple_card_info *info = asoc_simple_get_card_info(rtd); 44 + struct asoc_simple_card_info *info = 45 + snd_soc_card_get_drvdata(rtd->card); 43 46 struct snd_soc_dai *codec = rtd->codec_dai; 44 47 struct snd_soc_dai *cpu = rtd->cpu_dai; 45 48 unsigned int daifmt = info->daifmt; ··· 105 106 &dai->sysclk); 106 107 } else { 107 108 clk = of_clk_get(*node, 0); 108 - if (IS_ERR(clk)) { 109 - ret = PTR_ERR(clk); 110 - goto parse_error; 111 - } 112 - 113 - dai->sysclk = clk_get_rate(clk); 109 + if (!IS_ERR(clk)) 110 + dai->sysclk = clk_get_rate(clk); 114 111 } 115 112 116 113 ret = 0; ··· 133 138 (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK); 134 139 135 140 /* DAPM routes */ 136 - ret = snd_soc_of_parse_audio_routing(&info->snd_card, 137 - "simple-audio-routing"); 138 - if (ret) 139 - return ret; 141 + if (of_property_read_bool(node, "simple-audio-card,routing")) { 142 + ret = snd_soc_of_parse_audio_routing(&info->snd_card, 143 + "simple-audio-card,routing"); 144 + if (ret) 145 + return ret; 146 + } 140 147 141 148 /* CPU sub-node */ 142 149 ret = -EINVAL; ··· 194 197 struct device_node *np = pdev->dev.of_node; 195 198 struct device_node *of_cpu, *of_codec, *of_platform; 196 199 struct device *dev = &pdev->dev; 200 + int ret; 197 201 198 202 cinfo = NULL; 199 203 of_cpu = NULL; 200 204 of_codec = NULL; 201 205 of_platform = NULL; 206 + 207 + cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL); 208 + if (!cinfo) 209 + return -ENOMEM; 210 + 202 211 if (np && of_device_is_available(np)) { 203 - cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL); 204 - if (cinfo) { 205 - int ret; 206 - cinfo->snd_card.dev = &pdev->dev; 207 - ret = asoc_simple_card_parse_of(np, cinfo, dev, 208 - &of_cpu, 209 - &of_codec, 210 - &of_platform); 211 - if (ret < 0) { 212 - if (ret != -EPROBE_DEFER) 213 - dev_err(dev, "parse error %d\n", ret); 214 - return ret; 215 - } 212 + cinfo->snd_card.dev = dev; 213 + 214 + ret = asoc_simple_card_parse_of(np, cinfo, dev, 215 + &of_cpu, 216 + &of_codec, 217 + &of_platform); 218 + if (ret < 0) { 219 + if (ret != -EPROBE_DEFER) 220 + dev_err(dev, "parse error %d\n", ret); 221 + return ret; 216 222 } 217 223 } else { 218 - cinfo->snd_card.dev = &pdev->dev; 219 - cinfo = pdev->dev.platform_data; 220 - } 224 + if (!dev->platform_data) { 225 + dev_err(dev, "no info for asoc-simple-card\n"); 226 + return -EINVAL; 227 + } 221 228 222 - if (!cinfo) { 223 - dev_err(dev, "no info for asoc-simple-card\n"); 224 - return -EINVAL; 229 + memcpy(cinfo, dev->platform_data, sizeof(*cinfo)); 230 + cinfo->snd_card.dev = dev; 225 231 } 226 232 227 233 if (!cinfo->name || ··· 258 258 cinfo->snd_card.owner = THIS_MODULE; 259 259 cinfo->snd_card.dai_link = &cinfo->snd_link; 260 260 cinfo->snd_card.num_links = 1; 261 + 262 + snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo); 261 263 262 264 return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card); 263 265 }
-10
sound/soc/intel/sst_platform.c
··· 89 89 SNDRV_PCM_INFO_MMAP_VALID | 90 90 SNDRV_PCM_INFO_BLOCK_TRANSFER | 91 91 SNDRV_PCM_INFO_SYNC_START), 92 - .formats = (SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_U16 | 93 - SNDRV_PCM_FMTBIT_S24 | SNDRV_PCM_FMTBIT_U24 | 94 - SNDRV_PCM_FMTBIT_S32 | SNDRV_PCM_FMTBIT_U32), 95 - .rates = (SNDRV_PCM_RATE_8000| 96 - SNDRV_PCM_RATE_44100 | 97 - SNDRV_PCM_RATE_48000), 98 - .rate_min = SST_MIN_RATE, 99 - .rate_max = SST_MAX_RATE, 100 - .channels_min = SST_MIN_CHANNEL, 101 - .channels_max = SST_MAX_CHANNEL, 102 92 .buffer_bytes_max = SST_MAX_BUFFER, 103 93 .period_bytes_min = SST_MIN_PERIOD_BYTES, 104 94 .period_bytes_max = SST_MAX_PERIOD_BYTES,
-4
sound/soc/intel/sst_platform.h
··· 33 33 #define SST_STEREO 2 34 34 #define SST_MAX_CAP 5 35 35 36 - #define SST_MIN_RATE 8000 37 - #define SST_MAX_RATE 48000 38 - #define SST_MIN_CHANNEL 1 39 - #define SST_MAX_CHANNEL 5 40 36 #define SST_MAX_BUFFER (800*1024) 41 37 #define SST_MIN_BUFFER (800*1024) 42 38 #define SST_MIN_PERIOD_BYTES 32
-16
sound/soc/kirkwood/kirkwood-dma.c
··· 21 21 #include <sound/soc.h> 22 22 #include "kirkwood.h" 23 23 24 - #define KIRKWOOD_RATES \ 25 - (SNDRV_PCM_RATE_8000_192000 | \ 26 - SNDRV_PCM_RATE_CONTINUOUS | \ 27 - SNDRV_PCM_RATE_KNOT) 28 - 29 - #define KIRKWOOD_FORMATS \ 30 - (SNDRV_PCM_FMTBIT_S16_LE | \ 31 - SNDRV_PCM_FMTBIT_S24_LE | \ 32 - SNDRV_PCM_FMTBIT_S32_LE) 33 - 34 24 static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs) 35 25 { 36 26 struct snd_soc_pcm_runtime *soc_runtime = subs->private_data; ··· 33 43 SNDRV_PCM_INFO_MMAP_VALID | 34 44 SNDRV_PCM_INFO_BLOCK_TRANSFER | 35 45 SNDRV_PCM_INFO_PAUSE), 36 - .formats = KIRKWOOD_FORMATS, 37 - .rates = KIRKWOOD_RATES, 38 - .rate_min = 8000, 39 - .rate_max = 384000, 40 - .channels_min = 1, 41 - .channels_max = 8, 42 46 .buffer_bytes_max = KIRKWOOD_SND_MAX_BUFFER_BYTES, 43 47 .period_bytes_min = KIRKWOOD_SND_MIN_PERIOD_BYTES, 44 48 .period_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES,
-6
sound/soc/mxs/mxs-pcm.c
··· 36 36 SNDRV_PCM_INFO_RESUME | 37 37 SNDRV_PCM_INFO_INTERLEAVED | 38 38 SNDRV_PCM_INFO_HALF_DUPLEX, 39 - .formats = SNDRV_PCM_FMTBIT_S16_LE | 40 - SNDRV_PCM_FMTBIT_S20_3LE | 41 - SNDRV_PCM_FMTBIT_S24_LE, 42 - .channels_min = 2, 43 - .channels_max = 2, 44 39 .period_bytes_min = 32, 45 40 .period_bytes_max = 8192, 46 41 .periods_min = 1, ··· 52 57 int mxs_pcm_platform_register(struct device *dev) 53 58 { 54 59 return devm_snd_dmaengine_pcm_register(dev, &mxs_dmaengine_pcm_config, 55 - SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 56 60 SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX); 57 61 } 58 62 EXPORT_SYMBOL_GPL(mxs_pcm_platform_register);
-3
sound/soc/nuc900/nuc900-pcm.c
··· 32 32 SNDRV_PCM_INFO_MMAP_VALID | 33 33 SNDRV_PCM_INFO_PAUSE | 34 34 SNDRV_PCM_INFO_RESUME, 35 - .formats = SNDRV_PCM_FMTBIT_S16_LE, 36 - .channels_min = 1, 37 - .channels_max = 2, 38 35 .buffer_bytes_max = 4*1024, 39 36 .period_bytes_min = 1*1024, 40 37 .period_bytes_max = 4*1024,
-17
sound/soc/sh/dma-sh7760.c
··· 89 89 #define DMABRG_PREALLOC_BUFFER 32 * 1024 90 90 #define DMABRG_PREALLOC_BUFFER_MAX 32 * 1024 91 91 92 - /* support everything the SSI supports */ 93 - #define DMABRG_RATES \ 94 - SNDRV_PCM_RATE_8000_192000 95 - 96 - #define DMABRG_FMTS \ 97 - (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | \ 98 - SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE | \ 99 - SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_U20_3LE | \ 100 - SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3LE | \ 101 - SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE) 102 - 103 92 static struct snd_pcm_hardware camelot_pcm_hardware = { 104 93 .info = (SNDRV_PCM_INFO_MMAP | 105 94 SNDRV_PCM_INFO_INTERLEAVED | 106 95 SNDRV_PCM_INFO_BLOCK_TRANSFER | 107 96 SNDRV_PCM_INFO_MMAP_VALID | 108 97 SNDRV_PCM_INFO_BATCH), 109 - .formats = DMABRG_FMTS, 110 - .rates = DMABRG_RATES, 111 - .rate_min = 8000, 112 - .rate_max = 192000, 113 - .channels_min = 2, 114 - .channels_max = 8, /* max of the SSI */ 115 98 .buffer_bytes_max = DMABRG_PERIOD_MAX, 116 99 .period_bytes_min = DMABRG_PERIOD_MIN, 117 100 .period_bytes_max = DMABRG_PERIOD_MAX / 2,
-6
sound/soc/sh/fsi.c
··· 1787 1787 SNDRV_PCM_INFO_MMAP | 1788 1788 SNDRV_PCM_INFO_MMAP_VALID | 1789 1789 SNDRV_PCM_INFO_PAUSE, 1790 - .formats = FSI_FMTS, 1791 - .rates = FSI_RATES, 1792 - .rate_min = 8000, 1793 - .rate_max = 192000, 1794 - .channels_min = 2, 1795 - .channels_max = 2, 1796 1790 .buffer_bytes_max = 64 * 1024, 1797 1791 .period_bytes_min = 32, 1798 1792 .period_bytes_max = 8192,
-6
sound/soc/sh/rcar/core.c
··· 628 628 SNDRV_PCM_INFO_MMAP | 629 629 SNDRV_PCM_INFO_MMAP_VALID | 630 630 SNDRV_PCM_INFO_PAUSE, 631 - .formats = RSND_FMTS, 632 - .rates = RSND_RATES, 633 - .rate_min = 8000, 634 - .rate_max = 192000, 635 - .channels_min = 2, 636 - .channels_max = 2, 637 631 .buffer_bytes_max = 64 * 1024, 638 632 .period_bytes_min = 32, 639 633 .period_bytes_max = 8192,
+2
sound/soc/ux500/mop500.c
··· 91 91 for (i = 0; i < 2; i++) { 92 92 mop500_dai_links[i].cpu_of_node = msp_np[i]; 93 93 mop500_dai_links[i].cpu_dai_name = NULL; 94 + mop500_dai_links[i].platform_of_node = msp_np[i]; 95 + mop500_dai_links[i].platform_name = NULL; 94 96 mop500_dai_links[i].codec_of_node = codec_np; 95 97 mop500_dai_links[i].codec_name = NULL; 96 98 }
+60 -86
sound/soc/ux500/ux500_msp_dai.c
··· 17 17 #include <linux/bitops.h> 18 18 #include <linux/platform_device.h> 19 19 #include <linux/clk.h> 20 + #include <linux/of.h> 20 21 #include <linux/regulator/consumer.h> 21 22 #include <linux/mfd/dbx500-prcmu.h> 22 23 #include <linux/platform_data/asoc-ux500-msp.h> 23 24 24 25 #include <sound/soc.h> 25 26 #include <sound/soc-dai.h> 27 + #include <sound/dmaengine_pcm.h> 26 28 27 29 #include "ux500_msp_i2s.h" 28 30 #include "ux500_msp_dai.h" ··· 656 654 return ret; 657 655 } 658 656 657 + static int ux500_msp_dai_of_probe(struct snd_soc_dai *dai) 658 + { 659 + struct ux500_msp_i2s_drvdata *drvdata = dev_get_drvdata(dai->dev); 660 + struct snd_dmaengine_dai_dma_data *playback_dma_data; 661 + struct snd_dmaengine_dai_dma_data *capture_dma_data; 662 + 663 + playback_dma_data = devm_kzalloc(dai->dev, 664 + sizeof(*playback_dma_data), 665 + GFP_KERNEL); 666 + if (!playback_dma_data) 667 + return -ENOMEM; 668 + 669 + capture_dma_data = devm_kzalloc(dai->dev, 670 + sizeof(*capture_dma_data), 671 + GFP_KERNEL); 672 + if (!capture_dma_data) 673 + return -ENOMEM; 674 + 675 + playback_dma_data->addr = drvdata->msp->playback_dma_data.tx_rx_addr; 676 + capture_dma_data->addr = drvdata->msp->capture_dma_data.tx_rx_addr; 677 + 678 + playback_dma_data->maxburst = 4; 679 + capture_dma_data->maxburst = 4; 680 + 681 + snd_soc_dai_init_dma_data(dai, playback_dma_data, capture_dma_data); 682 + 683 + return 0; 684 + } 685 + 659 686 static int ux500_msp_dai_probe(struct snd_soc_dai *dai) 660 687 { 661 688 struct ux500_msp_i2s_drvdata *drvdata = dev_get_drvdata(dai->dev); 689 + struct msp_i2s_platform_data *pdata = dai->dev->platform_data; 690 + int ret; 662 691 663 - dai->playback_dma_data = &drvdata->msp->playback_dma_data; 664 - dai->capture_dma_data = &drvdata->msp->capture_dma_data; 692 + if (!pdata) { 693 + ret = ux500_msp_dai_of_probe(dai); 694 + return ret; 695 + } 665 696 666 697 drvdata->msp->playback_dma_data.data_size = drvdata->slot_width; 667 698 drvdata->msp->capture_dma_data.data_size = drvdata->slot_width; 668 699 700 + snd_soc_dai_init_dma_data(dai, 701 + &drvdata->msp->playback_dma_data, 702 + &drvdata->msp->capture_dma_data); 669 703 return 0; 670 704 } 671 705 ··· 718 680 } 719 681 }; 720 682 721 - static struct snd_soc_dai_driver ux500_msp_dai_drv[UX500_NBR_OF_DAI] = { 722 - { 723 - .name = "ux500-msp-i2s.0", 724 - .probe = ux500_msp_dai_probe, 725 - .id = 0, 726 - .suspend = NULL, 727 - .resume = NULL, 728 - .playback = { 729 - .channels_min = UX500_MSP_MIN_CHANNELS, 730 - .channels_max = UX500_MSP_MAX_CHANNELS, 731 - .rates = UX500_I2S_RATES, 732 - .formats = UX500_I2S_FORMATS, 733 - }, 734 - .capture = { 735 - .channels_min = UX500_MSP_MIN_CHANNELS, 736 - .channels_max = UX500_MSP_MAX_CHANNELS, 737 - .rates = UX500_I2S_RATES, 738 - .formats = UX500_I2S_FORMATS, 739 - }, 740 - .ops = ux500_msp_dai_ops, 741 - }, 742 - { 743 - .name = "ux500-msp-i2s.1", 744 - .probe = ux500_msp_dai_probe, 745 - .id = 1, 746 - .suspend = NULL, 747 - .resume = NULL, 748 - .playback = { 749 - .channels_min = UX500_MSP_MIN_CHANNELS, 750 - .channels_max = UX500_MSP_MAX_CHANNELS, 751 - .rates = UX500_I2S_RATES, 752 - .formats = UX500_I2S_FORMATS, 753 - }, 754 - .capture = { 755 - .channels_min = UX500_MSP_MIN_CHANNELS, 756 - .channels_max = UX500_MSP_MAX_CHANNELS, 757 - .rates = UX500_I2S_RATES, 758 - .formats = UX500_I2S_FORMATS, 759 - }, 760 - .ops = ux500_msp_dai_ops, 761 - }, 762 - { 763 - .name = "ux500-msp-i2s.2", 764 - .id = 2, 765 - .probe = ux500_msp_dai_probe, 766 - .suspend = NULL, 767 - .resume = NULL, 768 - .playback = { 769 - .channels_min = UX500_MSP_MIN_CHANNELS, 770 - .channels_max = UX500_MSP_MAX_CHANNELS, 771 - .rates = UX500_I2S_RATES, 772 - .formats = UX500_I2S_FORMATS, 773 - }, 774 - .capture = { 775 - .channels_min = UX500_MSP_MIN_CHANNELS, 776 - .channels_max = UX500_MSP_MAX_CHANNELS, 777 - .rates = UX500_I2S_RATES, 778 - .formats = UX500_I2S_FORMATS, 779 - }, 780 - .ops = ux500_msp_dai_ops, 781 - }, 782 - { 783 - .name = "ux500-msp-i2s.3", 784 - .probe = ux500_msp_dai_probe, 785 - .id = 3, 786 - .suspend = NULL, 787 - .resume = NULL, 788 - .playback = { 789 - .channels_min = UX500_MSP_MIN_CHANNELS, 790 - .channels_max = UX500_MSP_MAX_CHANNELS, 791 - .rates = UX500_I2S_RATES, 792 - .formats = UX500_I2S_FORMATS, 793 - }, 794 - .capture = { 795 - .channels_min = UX500_MSP_MIN_CHANNELS, 796 - .channels_max = UX500_MSP_MAX_CHANNELS, 797 - .rates = UX500_I2S_RATES, 798 - .formats = UX500_I2S_FORMATS, 799 - }, 800 - .ops = ux500_msp_dai_ops, 801 - }, 683 + static struct snd_soc_dai_driver ux500_msp_dai_drv = { 684 + .probe = ux500_msp_dai_probe, 685 + .suspend = NULL, 686 + .resume = NULL, 687 + .playback.channels_min = UX500_MSP_MIN_CHANNELS, 688 + .playback.channels_max = UX500_MSP_MAX_CHANNELS, 689 + .playback.rates = UX500_I2S_RATES, 690 + .playback.formats = UX500_I2S_FORMATS, 691 + .capture.channels_min = UX500_MSP_MIN_CHANNELS, 692 + .capture.channels_max = UX500_MSP_MAX_CHANNELS, 693 + .capture.rates = UX500_I2S_RATES, 694 + .capture.formats = UX500_I2S_FORMATS, 695 + .ops = ux500_msp_dai_ops, 802 696 }; 803 697 804 698 static const struct snd_soc_component_driver ux500_msp_component = { ··· 741 771 static int ux500_msp_drv_probe(struct platform_device *pdev) 742 772 { 743 773 struct ux500_msp_i2s_drvdata *drvdata; 774 + struct msp_i2s_platform_data *pdata = pdev->dev.platform_data; 775 + struct device_node *np = pdev->dev.of_node; 744 776 int ret = 0; 745 777 746 - dev_dbg(&pdev->dev, "%s: Enter (pdev->name = %s).\n", __func__, 747 - pdev->name); 778 + if (!pdata && !np) { 779 + dev_err(&pdev->dev, "No platform data or Device Tree found\n"); 780 + return -ENODEV; 781 + } 748 782 749 783 drvdata = devm_kzalloc(&pdev->dev, 750 784 sizeof(struct ux500_msp_i2s_drvdata), ··· 800 826 dev_set_drvdata(&pdev->dev, drvdata); 801 827 802 828 ret = snd_soc_register_component(&pdev->dev, &ux500_msp_component, 803 - &ux500_msp_dai_drv[drvdata->msp->id], 1); 829 + &ux500_msp_dai_drv, 1); 804 830 if (ret < 0) { 805 831 dev_err(&pdev->dev, "Error: %s: Failed to register MSP%d!\n", 806 832 __func__, drvdata->msp->id);
+41 -15
sound/soc/ux500/ux500_msp_i2s.c
··· 646 646 647 647 } 648 648 649 + static int ux500_msp_i2s_of_init_msp(struct platform_device *pdev, 650 + struct ux500_msp *msp, 651 + struct msp_i2s_platform_data **platform_data) 652 + { 653 + struct msp_i2s_platform_data *pdata; 654 + 655 + *platform_data = devm_kzalloc(&pdev->dev, 656 + sizeof(struct msp_i2s_platform_data), 657 + GFP_KERNEL); 658 + pdata = *platform_data; 659 + if (!pdata) 660 + return -ENOMEM; 661 + 662 + msp->playback_dma_data.dma_cfg = devm_kzalloc(&pdev->dev, 663 + sizeof(struct stedma40_chan_cfg), 664 + GFP_KERNEL); 665 + if (!msp->playback_dma_data.dma_cfg) 666 + return -ENOMEM; 667 + 668 + msp->capture_dma_data.dma_cfg = devm_kzalloc(&pdev->dev, 669 + sizeof(struct stedma40_chan_cfg), 670 + GFP_KERNEL); 671 + if (!msp->capture_dma_data.dma_cfg) 672 + return -ENOMEM; 673 + 674 + return 0; 675 + } 676 + 649 677 int ux500_msp_i2s_init_msp(struct platform_device *pdev, 650 678 struct ux500_msp **msp_p, 651 679 struct msp_i2s_platform_data *platform_data) ··· 681 653 struct resource *res = NULL; 682 654 struct device_node *np = pdev->dev.of_node; 683 655 struct ux500_msp *msp; 656 + int ret; 684 657 685 658 *msp_p = devm_kzalloc(&pdev->dev, sizeof(struct ux500_msp), GFP_KERNEL); 686 659 msp = *msp_p; 687 660 if (!msp) 688 661 return -ENOMEM; 689 662 690 - if (np) { 691 - if (!platform_data) { 692 - platform_data = devm_kzalloc(&pdev->dev, 693 - sizeof(struct msp_i2s_platform_data), GFP_KERNEL); 694 - if (!platform_data) 695 - return -ENOMEM; 696 - } 697 - } else 698 - if (!platform_data) 663 + if (!platform_data) { 664 + if (np) { 665 + ret = ux500_msp_i2s_of_init_msp(pdev, msp, 666 + &platform_data); 667 + if (ret) 668 + return ret; 669 + } else 699 670 return -EINVAL; 671 + } else { 672 + msp->playback_dma_data.dma_cfg = platform_data->msp_i2s_dma_tx; 673 + msp->capture_dma_data.dma_cfg = platform_data->msp_i2s_dma_rx; 674 + msp->id = platform_data->id; 675 + } 700 676 701 - dev_dbg(&pdev->dev, "%s: Enter (name: %s, id: %d).\n", __func__, 702 - pdev->name, platform_data->id); 703 - 704 - msp->id = platform_data->id; 705 677 msp->dev = &pdev->dev; 706 - msp->playback_dma_data.dma_cfg = platform_data->msp_i2s_dma_tx; 707 - msp->capture_dma_data.dma_cfg = platform_data->msp_i2s_dma_rx; 708 678 709 679 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 710 680 if (res == NULL) {
+1 -1
sound/soc/ux500/ux500_msp_i2s.h
··· 475 475 }; 476 476 477 477 struct ux500_msp { 478 - enum msp_i2s_id id; 478 + int id; 479 479 void __iomem *registers; 480 480 struct device *dev; 481 481 struct ux500_msp_dma_params playback_dma_data;
+33 -32
sound/soc/ux500/ux500_pcm.c
··· 28 28 #include "ux500_msp_i2s.h" 29 29 #include "ux500_pcm.h" 30 30 31 - #define UX500_PLATFORM_MIN_RATE 8000 32 - #define UX500_PLATFORM_MAX_RATE 48000 33 - 34 - #define UX500_PLATFORM_MIN_CHANNELS 1 35 - #define UX500_PLATFORM_MAX_CHANNELS 8 36 - 37 31 #define UX500_PLATFORM_PERIODS_BYTES_MIN 128 38 32 #define UX500_PLATFORM_PERIODS_BYTES_MAX (64 * PAGE_SIZE) 39 33 #define UX500_PLATFORM_PERIODS_MIN 2 ··· 39 45 SNDRV_PCM_INFO_MMAP | 40 46 SNDRV_PCM_INFO_RESUME | 41 47 SNDRV_PCM_INFO_PAUSE, 42 - .formats = SNDRV_PCM_FMTBIT_S16_LE | 43 - SNDRV_PCM_FMTBIT_U16_LE | 44 - SNDRV_PCM_FMTBIT_S16_BE | 45 - SNDRV_PCM_FMTBIT_U16_BE, 46 - .rates = SNDRV_PCM_RATE_KNOT, 47 - .rate_min = UX500_PLATFORM_MIN_RATE, 48 - .rate_max = UX500_PLATFORM_MAX_RATE, 49 - .channels_min = UX500_PLATFORM_MIN_CHANNELS, 50 - .channels_max = UX500_PLATFORM_MAX_CHANNELS, 51 48 .buffer_bytes_max = UX500_PLATFORM_BUFFER_BYTES_MAX, 52 49 .period_bytes_min = UX500_PLATFORM_PERIODS_BYTES_MIN, 53 50 .period_bytes_max = UX500_PLATFORM_PERIODS_BYTES_MAX, ··· 50 65 struct snd_pcm_substream *substream) 51 66 { 52 67 struct snd_soc_dai *dai = rtd->cpu_dai; 53 - struct device *dev = dai->dev; 54 68 u16 per_data_width, mem_data_width; 55 69 struct stedma40_chan_cfg *dma_cfg; 56 70 struct ux500_msp_dma_params *dma_params; 57 - 58 - dev_dbg(dev, "%s: MSP %d (%s): Enter.\n", __func__, dai->id, 59 - snd_pcm_stream_str(substream)); 60 71 61 72 dma_params = snd_soc_dai_get_dma_data(dai, substream); 62 73 dma_cfg = dma_params->dma_cfg; ··· 89 108 struct dma_slave_config *slave_config) 90 109 { 91 110 struct snd_soc_pcm_runtime *rtd = substream->private_data; 92 - struct ux500_msp_dma_params *dma_params; 93 - struct stedma40_chan_cfg *dma_cfg; 111 + struct msp_i2s_platform_data *pdata = rtd->cpu_dai->dev->platform_data; 112 + struct snd_dmaengine_dai_dma_data *snd_dma_params; 113 + struct ux500_msp_dma_params *ste_dma_params; 114 + dma_addr_t dma_addr; 94 115 int ret; 95 116 96 - dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 97 - dma_cfg = dma_params->dma_cfg; 117 + if (pdata) { 118 + ste_dma_params = 119 + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 120 + dma_addr = ste_dma_params->tx_rx_addr; 121 + } else { 122 + snd_dma_params = 123 + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 124 + dma_addr = snd_dma_params->addr; 125 + } 98 126 99 127 ret = snd_hwparams_to_dma_slave_config(substream, params, slave_config); 100 128 if (ret) 101 129 return ret; 102 130 103 131 slave_config->dst_maxburst = 4; 104 - slave_config->dst_addr_width = dma_cfg->dst_info.data_width; 105 132 slave_config->src_maxburst = 4; 106 - slave_config->src_addr_width = dma_cfg->src_info.data_width; 133 + 134 + slave_config->src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; 135 + slave_config->dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; 107 136 108 137 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 109 - slave_config->dst_addr = dma_params->tx_rx_addr; 138 + slave_config->dst_addr = dma_addr; 110 139 else 111 - slave_config->src_addr = dma_params->tx_rx_addr; 140 + slave_config->src_addr = dma_addr; 112 141 113 142 return 0; 114 143 } ··· 130 139 .prepare_slave_config = ux500_pcm_prepare_slave_config, 131 140 }; 132 141 142 + static const struct snd_dmaengine_pcm_config ux500_dmaengine_of_pcm_config = { 143 + .compat_request_channel = ux500_pcm_request_chan, 144 + .prepare_slave_config = ux500_pcm_prepare_slave_config, 145 + }; 146 + 133 147 int ux500_pcm_register_platform(struct platform_device *pdev) 134 148 { 149 + const struct snd_dmaengine_pcm_config *pcm_config; 150 + struct device_node *np = pdev->dev.of_node; 135 151 int ret; 136 152 137 - ret = snd_dmaengine_pcm_register(&pdev->dev, 138 - &ux500_dmaengine_pcm_config, 139 - SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 140 - SND_DMAENGINE_PCM_FLAG_COMPAT | 141 - SND_DMAENGINE_PCM_FLAG_NO_DT); 153 + if (np) 154 + pcm_config = &ux500_dmaengine_of_pcm_config; 155 + else 156 + pcm_config = &ux500_dmaengine_pcm_config; 157 + 158 + ret = snd_dmaengine_pcm_register(&pdev->dev, pcm_config, 159 + SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 160 + SND_DMAENGINE_PCM_FLAG_COMPAT); 142 161 if (ret < 0) { 143 162 dev_err(&pdev->dev, 144 163 "%s: ERROR: Failed to register platform '%s' (%d)!\n",