rn_acp3x.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * AMD ALSA SoC PDM Driver
  4. *
  5. * Copyright 2020 Advanced Micro Devices, Inc.
  6. */
  7. #include "rn_chip_offset_byte.h"
  8. #define ACP_DEVS 3
  9. #define ACP_PHY_BASE_ADDRESS 0x1240000
  10. #define ACP_REG_START 0x1240000
  11. #define ACP_REG_END 0x1250200
  12. #define ACP_DEVICE_ID 0x15E2
  13. #define ACP_POWER_ON 0x00
  14. #define ACP_POWER_ON_IN_PROGRESS 0x01
  15. #define ACP_POWER_OFF 0x02
  16. #define ACP_POWER_OFF_IN_PROGRESS 0x03
  17. #define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001
  18. #define ACP_PGFSM_CNTL_POWER_ON_MASK 0x01
  19. #define ACP_PGFSM_CNTL_POWER_OFF_MASK 0x00
  20. #define ACP_PGFSM_STATUS_MASK 0x03
  21. #define ACP_POWERED_ON 0x00
  22. #define ACP_POWER_ON_IN_PROGRESS 0x01
  23. #define ACP_POWERED_OFF 0x02
  24. #define ACP_POWER_OFF_IN_PROGRESS 0x03
  25. #define ACP_ERROR_MASK 0x20000000
  26. #define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF
  27. #define PDM_DMA_STAT 0x10
  28. #define PDM_DMA_INTR_MASK 0x10000
  29. #define ACP_ERROR_STAT 29
  30. #define PDM_DECIMATION_FACTOR 0x2
  31. #define ACP_PDM_CLK_FREQ_MASK 0x07
  32. #define ACP_WOV_MISC_CTRL_MASK 0x10
  33. #define ACP_PDM_ENABLE 0x01
  34. #define ACP_PDM_DISABLE 0x00
  35. #define ACP_PDM_DMA_EN_STATUS 0x02
  36. #define TWO_CH 0x02
  37. #define DELAY_US 5
  38. #define ACP_COUNTER 20000
  39. /* time in ms for runtime suspend delay */
  40. #define ACP_SUSPEND_DELAY_MS 2000
  41. #define ACP_SRAM_PTE_OFFSET 0x02050000
  42. #define PAGE_SIZE_4K_ENABLE 0x2
  43. #define MEM_WINDOW_START 0x4000000
  44. #define CAPTURE_MIN_NUM_PERIODS 4
  45. #define CAPTURE_MAX_NUM_PERIODS 4
  46. #define CAPTURE_MAX_PERIOD_SIZE 8192
  47. #define CAPTURE_MIN_PERIOD_SIZE 4096
  48. #define MAX_BUFFER (CAPTURE_MAX_PERIOD_SIZE * CAPTURE_MAX_NUM_PERIODS)
  49. #define MIN_BUFFER MAX_BUFFER
  50. #define ACP_DMIC_AUTO -1
  51. struct pdm_dev_data {
  52. u32 pdm_irq;
  53. void __iomem *acp_base;
  54. struct snd_pcm_substream *capture_stream;
  55. };
  56. struct pdm_stream_instance {
  57. u16 num_pages;
  58. u16 channels;
  59. dma_addr_t dma_addr;
  60. u64 bytescount;
  61. void __iomem *acp_base;
  62. };
  63. union acp_pdm_dma_count {
  64. struct {
  65. u32 low;
  66. u32 high;
  67. } bcount;
  68. u64 bytescount;
  69. };
  70. static inline u32 rn_readl(void __iomem *base_addr)
  71. {
  72. return readl(base_addr - ACP_PHY_BASE_ADDRESS);
  73. }
  74. static inline void rn_writel(u32 val, void __iomem *base_addr)
  75. {
  76. writel(val, base_addr - ACP_PHY_BASE_ADDRESS);
  77. }
  78. /* Machine configuration */
  79. int snd_amd_acp_find_config(struct pci_dev *pci);