s3c-i2s-v2.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * ALSA Soc Audio Layer - S3C_I2SV2 I2S driver
  4. *
  5. * Copyright (c) 2007 Simtec Electronics
  6. * http://armlinux.simtec.co.uk/
  7. * Ben Dooks <ben@simtec.co.uk>
  8. */
  9. /* This code is the core support for the I2S block found in a number of
  10. * Samsung SoC devices which is unofficially named I2S-V2. Currently the
  11. * S3C2412 and the S3C64XX series use this block to provide 1 or 2 I2S
  12. * channels via configurable GPIO.
  13. */
  14. #ifndef __SND_SOC_S3C24XX_S3C_I2SV2_I2S_H
  15. #define __SND_SOC_S3C24XX_S3C_I2SV2_I2S_H __FILE__
  16. #define S3C_I2SV2_DIV_BCLK (1)
  17. #define S3C_I2SV2_DIV_RCLK (2)
  18. #define S3C_I2SV2_DIV_PRESCALER (3)
  19. #define S3C_I2SV2_CLKSRC_PCLK 0
  20. #define S3C_I2SV2_CLKSRC_AUDIOBUS 1
  21. #define S3C_I2SV2_CLKSRC_CDCLK 2
  22. /* Set this flag for I2S controllers that have the bit IISMOD[12]
  23. * bridge/break RCLK signal and external Xi2sCDCLK pin.
  24. */
  25. #define S3C_FEATURE_CDCLKCON (1 << 0)
  26. /**
  27. * struct s3c_i2sv2_info - S3C I2S-V2 information
  28. * @dev: The parent device passed to use from the probe.
  29. * @regs: The pointer to the device registe block.
  30. * @feature: Set of bit-flags indicating features of the controller.
  31. * @master: True if the I2S core is the I2S bit clock master.
  32. * @dma_playback: DMA information for playback channel.
  33. * @dma_capture: DMA information for capture channel.
  34. * @suspend_iismod: PM save for the IISMOD register.
  35. * @suspend_iiscon: PM save for the IISCON register.
  36. * @suspend_iispsr: PM save for the IISPSR register.
  37. *
  38. * This is the private codec state for the hardware associated with an
  39. * I2S channel such as the register mappings and clock sources.
  40. */
  41. struct s3c_i2sv2_info {
  42. struct device *dev;
  43. void __iomem *regs;
  44. u32 feature;
  45. struct clk *iis_pclk;
  46. struct clk *iis_cclk;
  47. unsigned char master;
  48. struct snd_dmaengine_dai_dma_data *dma_playback;
  49. struct snd_dmaengine_dai_dma_data *dma_capture;
  50. u32 suspend_iismod;
  51. u32 suspend_iiscon;
  52. u32 suspend_iispsr;
  53. unsigned long base;
  54. };
  55. extern struct clk *s3c_i2sv2_get_clock(struct snd_soc_dai *cpu_dai);
  56. struct s3c_i2sv2_rate_calc {
  57. unsigned int clk_div; /* for prescaler */
  58. unsigned int fs_div; /* for root frame clock */
  59. };
  60. extern int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info,
  61. unsigned int *fstab,
  62. unsigned int rate, struct clk *clk);
  63. /**
  64. * s3c_i2sv2_probe - probe for i2s device helper
  65. * @dai: The ASoC DAI structure supplied to the original probe.
  66. * @i2s: Our local i2s structure to fill in.
  67. * @base: The base address for the registers.
  68. */
  69. extern int s3c_i2sv2_probe(struct snd_soc_dai *dai,
  70. struct s3c_i2sv2_info *i2s);
  71. /**
  72. * s3c_i2sv2_cleanup - cleanup resources allocated in s3c_i2sv2_probe
  73. * @dai: The ASoC DAI structure supplied to the original probe.
  74. * @i2s: Our local i2s structure to fill in.
  75. */
  76. extern void s3c_i2sv2_cleanup(struct snd_soc_dai *dai,
  77. struct s3c_i2sv2_info *i2s);
  78. /**
  79. * s3c_i2sv2_register_component - register component and dai with soc core
  80. * @dev: DAI device
  81. * @id: DAI ID
  82. * @drv: The driver structure to register
  83. *
  84. * Fill in any missing fields and then register the given dai with the
  85. * soc core.
  86. */
  87. extern int s3c_i2sv2_register_component(struct device *dev, int id,
  88. const struct snd_soc_component_driver *cmp_drv,
  89. struct snd_soc_dai_driver *dai_drv);
  90. #endif /* __SND_SOC_S3C24XX_S3C_I2SV2_I2S_H */