Add support for CS35L41 in HDA systems
Subsystems (5)
v6 cover Add support for CS35L41 in HDA systems
Add support for laptops that have CS35L41 connected to an HDA codec by I2S and direct I2C connection to the CPU.
Laptops that use CS35L41 and are SPI will be added in the future, after the support for it is resolved at i2c-multi-instantiate driver. i2c-multi-instantiate thread: https://lkml.org/lkml/2021/12/10/557
Hardware:
- Some laptops have two CS35L41 amplifiers, connected to Realtek ALC287 by an I2S bus and by and direct I2C to the CPU.
- The ALC287 codec is connected to the CPU by an HDA bus.
- The CS35L41 has a DSP which will require firmware to be loaded.
Architecture:
- Creation of a library of shared functions for CS35L41 ASoC and HDA
- HDA codec driver (RealTek) and CS35L41 HDA driver are combined by using component binding, where it uses device names to find the components and bind to the master
- The HDA CS35L41 driver applies pre-defined registers sequences for each action in playback for HDA Sound card
Changes from V5:
- Fix build issues reported by Intel Test Bot
- Check devm_kasprintf return
- Add ACPI dependency to HDA drivers
V5: https://lkml.org/lkml/2021/12/16/430
Changes from V4:
- Save index received from ACPI for latter use in DSP Support
- Move CS35L41_DSP1_CCM_CORE_CTRL to regmap_write so doesn't
affect DSP hibernation feature
V4: https://lkml.org/lkml/2021/12/14/487
Changes from V3:
- SPI bus driver starter added
- Use separate modules approach instead of liking library
- Add CSC3551 ACPI _HID for more I2C laptops
- Removed regulators from HDA driver
- Add note about Non-conforming _HID
V3: https://lkml.org/lkml/2021/11/23/723
Changes from V2:
- Not an RFC
- Create a new HDA driver for CS35L41 instead of using the ASoC one
- Use component binding and device names to find the CS35L41 driver
- Create a shared library for ASoC and HDA CS35L41 drivers
v2: https://lkml.org/lkml/2021/10/8/344
Lucas Tanure (9):
ASoC: cs35l41: Convert tables to shared source code
ASoC: cs35l41: Move cs35l41_otp_unpack to shared code
ASoC: cs35l41: Move power initializations to reg_sequence
ASoC: cs35l41: Create shared function for errata patches
ASoC: cs35l41: Create shared function for setting channels
ASoC: cs35l41: Create shared function for boost configuration
hda: cs35l41: Add support for CS35L41 in HDA systems ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI
nodes
ALSA: hda/realtek: Add support for Legion 7 16ACHg6 laptop
Stefan Binding (1):
ALSA: hda/realtek: Add CS35L41 support for Thinkpad laptops
MAINTAINERS | 2 +
drivers/acpi/scan.c | 3 +
drivers/platform/x86/i2c-multi-instantiate.c | 11 +
include/sound/cs35l41.h | 739 ++++++++++++++++++
sound/pci/hda/Kconfig | 29 +
sound/pci/hda/Makefile | 10 +
sound/pci/hda/cs35l41_hda.c | 527 +++++++++++++
sound/pci/hda/cs35l41_hda.h | 69 ++
sound/pci/hda/cs35l41_hda_i2c.c | 66 ++
sound/pci/hda/cs35l41_hda_spi.c | 63 ++
sound/pci/hda/hda_component.h | 20 +
sound/pci/hda/patch_realtek.c | 146 ++++
sound/soc/codecs/Kconfig | 11 +-
sound/soc/codecs/Makefile | 4 +-
sound/soc/codecs/cs35l41-i2c.c | 1 -
.../{cs35l41-tables.c => cs35l41-lib.c} | 355 ++++++++-
sound/soc/codecs/cs35l41-spi.c | 1 -
sound/soc/codecs/cs35l41.c | 360 +--------
sound/soc/codecs/cs35l41.h | 734 -----------------
19 files changed, 2055 insertions(+), 1096 deletions(-)
create mode 100644 sound/pci/hda/cs35l41_hda.c
create mode 100644 sound/pci/hda/cs35l41_hda.h
create mode 100644 sound/pci/hda/cs35l41_hda_i2c.c
create mode 100644 sound/pci/hda/cs35l41_hda_spi.c
create mode 100644 sound/pci/hda/hda_component.h
rename sound/soc/codecs/{cs35l41-tables.c => cs35l41-lib.c} (71%)Signature · 1 line
2.34.1
PATCH v6 1/10 ASoC: cs35l41: Convert tables to shared source code
To support CS35L41 in HDA systems the HDA driver for CS35L41 would have to duplicate some functions that already exist on ASoC driver
So instead of duplicate the code, use the new lib source as a shared resource for both ASoC and HDA
Also, change the way CONFIG_SND_SOC_CS35L41 is selected, as reported by Intel Kernel test robot, it is possible to build SND_SOC_CS35L41_SPI/I2C without the main driver, which would lead to build failures.
---
include/sound/cs35l41.h | 733 +++++++++++++++++
sound/soc/codecs/Kconfig | 11 +-
sound/soc/codecs/Makefile | 4 +-
sound/soc/codecs/cs35l41-i2c.c | 1 -
.../{cs35l41-tables.c => cs35l41-lib.c} | 14 +-
sound/soc/codecs/cs35l41-spi.c | 1 -
sound/soc/codecs/cs35l41.h | 734 ------------------
7 files changed, 755 insertions(+), 743 deletions(-)
rename sound/soc/codecs/{cs35l41-tables.c => cs35l41-lib.c} (98%)include/sound/cs35l41.h +733 -0
@@ -10,6 +10,721 @@#ifndef __CS35L41_H#define __CS35L41_H +#include <linux/regmap.h> + +#define CS35L41_FIRSTREG 0x00000000 +#define CS35L41_LASTREG 0x03804FE8 +#define CS35L41_DEVID 0x00000000 +#define CS35L41_REVID 0x00000004 +#define CS35L41_FABID 0x00000008 +#define CS35L41_RELID 0x0000000C +#define CS35L41_OTPID 0x00000010 +#define CS35L41_SFT_RESET 0x00000020 +#define CS35L41_TEST_KEY_CTL 0x00000040 +#define CS35L41_USER_KEY_CTL 0x00000044 +#define CS35L41_OTP_MEM0 0x00000400 +#define CS35L41_OTP_MEM31 0x0000047C +#define CS35L41_OTP_CTRL0 0x00000500 +#define CS35L41_OTP_CTRL1 0x00000504 +#define CS35L41_OTP_CTRL3 0x00000508 +#define CS35L41_OTP_CTRL4 0x0000050C +#define CS35L41_OTP_CTRL5 0x00000510 +#define CS35L41_OTP_CTRL6 0x00000514 +#define CS35L41_OTP_CTRL7 0x00000518 +#define CS35L41_OTP_CTRL8 0x0000051C +#define CS35L41_PWR_CTRL1 0x00002014 +#define CS35L41_PWR_CTRL2 0x00002018 +#define CS35L41_PWR_CTRL3 0x0000201C +#define CS35L41_CTRL_OVRRIDE 0x00002020 +#define CS35L41_AMP_OUT_MUTE 0x00002024 +#define CS35L41_PROTECT_REL_ERR_IGN 0x00002034 +#define CS35L41_GPIO_PAD_CONTROL 0x0000242C +#define CS35L41_JTAG_CONTROL 0x00002438 +#define CS35L41_PLL_CLK_CTRL 0x00002C04 +#define CS35L41_DSP_CLK_CTRL 0x00002C08 +#define CS35L41_GLOBAL_CLK_CTRL 0x00002C0C +#define CS35L41_DATA_FS_SEL 0x00002C10 +#define CS35L41_TST_FS_MON0 0x00002D10 +#define CS35L41_MDSYNC_EN 0x00003400 +#define CS35L41_MDSYNC_TX_ID 0x00003408 +#define CS35L41_MDSYNC_PWR_CTRL 0x0000340C +#define CS35L41_MDSYNC_DATA_TX 0x00003410 +#define CS35L41_MDSYNC_TX_STATUS 0x00003414 +#define CS35L41_MDSYNC_DATA_RX 0x0000341C +#define CS35L41_MDSYNC_RX_STATUS 0x00003420 +#define CS35L41_MDSYNC_ERR_STATUS 0x00003424 +#define CS35L41_MDSYNC_SYNC_PTE2 0x00003528 +#define CS35L41_MDSYNC_SYNC_PTE3 0x0000352C +#define CS35L41_MDSYNC_SYNC_MSM_STATUS 0x0000353C +#define CS35L41_BSTCVRT_VCTRL1 0x00003800 +#define CS35L41_BSTCVRT_VCTRL2 0x00003804 +#define CS35L41_BSTCVRT_PEAK_CUR 0x00003808 +#define CS35L41_BSTCVRT_SFT_RAMP 0x0000380C +#define CS35L41_BSTCVRT_COEFF 0x00003810 +#define CS35L41_BSTCVRT_SLOPE_LBST 0x00003814 +#define CS35L41_BSTCVRT_SW_FREQ 0x00003818 +#define CS35L41_BSTCVRT_DCM_CTRL 0x0000381C +#define CS35L41_BSTCVRT_DCM_MODE_FORCE 0x00003820 +#define CS35L41_BSTCVRT_OVERVOLT_CTRL 0x00003830 +#define CS35L41_VI_VOL_POL 0x00004000 +#define CS35L41_VIMON_SPKMON_RESYNC 0x00004100 +#define CS35L41_DTEMP_WARN_THLD 0x00004220 +#define CS35L41_DTEMP_CFG 0x00004224 +#define CS35L41_DTEMP_EN 0x00004308 +#define CS35L41_VPVBST_FS_SEL 0x00004400 +#define CS35L41_SP_ENABLES 0x00004800 +#define CS35L41_SP_RATE_CTRL 0x00004804 +#define CS35L41_SP_FORMAT 0x00004808 +#define CS35L41_SP_HIZ_CTRL 0x0000480C +#define CS35L41_SP_FRAME_TX_SLOT 0x00004810 +#define CS35L41_SP_FRAME_RX_SLOT 0x00004820 +#define CS35L41_SP_TX_WL 0x00004830 +#define CS35L41_SP_RX_WL 0x00004840 +#define CS35L41_ASP_CONTROL4 0x00004854 +#define CS35L41_DAC_PCM1_SRC 0x00004C00 +#define CS35L41_ASP_TX1_SRC 0x00004C20 +#define CS35L41_ASP_TX2_SRC 0x00004C24 +#define CS35L41_ASP_TX3_SRC 0x00004C28 +#define CS35L41_ASP_TX4_SRC 0x00004C2C +#define CS35L41_DSP1_RX1_SRC 0x00004C40 +#define CS35L41_DSP1_RX2_SRC 0x00004C44 +#define CS35L41_DSP1_RX3_SRC 0x00004C48 +#define CS35L41_DSP1_RX4_SRC 0x00004C4C +#define CS35L41_DSP1_RX5_SRC 0x00004C50 +#define CS35L41_DSP1_RX6_SRC 0x00004C54 +#define CS35L41_DSP1_RX7_SRC 0x00004C58 +#define CS35L41_DSP1_RX8_SRC 0x00004C5C +#define CS35L41_NGATE1_SRC 0x00004C60 +#define CS35L41_NGATE2_SRC 0x00004C64 +#define CS35L41_AMP_DIG_VOL_CTRL 0x00006000 +#define CS35L41_VPBR_CFG 0x00006404 +#define CS35L41_VBBR_CFG 0x00006408 +#define CS35L41_VPBR_STATUS 0x0000640C +#define CS35L41_VBBR_STATUS 0x00006410 +#define CS35L41_OVERTEMP_CFG 0x00006414 +#define CS35L41_AMP_ERR_VOL 0x00006418 +#define CS35L41_VOL_STATUS_TO_DSP 0x00006450 +#define CS35L41_CLASSH_CFG 0x00006800 +#define CS35L41_WKFET_CFG 0x00006804 +#define CS35L41_NG_CFG 0x00006808 +#define CS35L41_AMP_GAIN_CTRL 0x00006C04 +#define CS35L41_DAC_MSM_CFG 0x00007400 +#define CS35L41_IRQ1_CFG 0x00010000 +#define CS35L41_IRQ1_STATUS 0x00010004 +#define CS35L41_IRQ1_STATUS1 0x00010010 +#define CS35L41_IRQ1_STATUS2 0x00010014 +#define CS35L41_IRQ1_STATUS3 0x00010018 +#define CS35L41_IRQ1_STATUS4 0x0001001C +#define CS35L41_IRQ1_RAW_STATUS1 0x00010090 +#define CS35L41_IRQ1_RAW_STATUS2 0x00010094 +#define CS35L41_IRQ1_RAW_STATUS3 0x00010098 +#define CS35L41_IRQ1_RAW_STATUS4 0x0001009C +#define CS35L41_IRQ1_MASK1 0x00010110 +#define CS35L41_IRQ1_MASK2 0x00010114 +#define CS35L41_IRQ1_MASK3 0x00010118 +#define CS35L41_IRQ1_MASK4 0x0001011C +#define CS35L41_IRQ1_FRC1 0x00010190 +#define CS35L41_IRQ1_FRC2 0x00010194 +#define CS35L41_IRQ1_FRC3 0x00010198 +#define CS35L41_IRQ1_FRC4 0x0001019C +#define CS35L41_IRQ1_EDGE1 0x00010210 +#define CS35L41_IRQ1_EDGE4 0x0001021C +#define CS35L41_IRQ1_POL1 0x00010290 +#define CS35L41_IRQ1_POL2 0x00010294 +#define CS35L41_IRQ1_POL3 0x00010298 +#define CS35L41_IRQ1_POL4 0x0001029C +#define CS35L41_IRQ1_DB3 0x00010318 +#define CS35L41_IRQ2_CFG 0x00010800 +#define CS35L41_IRQ2_STATUS 0x00010804 +#define CS35L41_IRQ2_STATUS1 0x00010810 +#define CS35L41_IRQ2_STATUS2 0x00010814 +#define CS35L41_IRQ2_STATUS3 0x00010818 +#define CS35L41_IRQ2_STATUS4 0x0001081C +#define CS35L41_IRQ2_RAW_STATUS1 0x00010890 +#define CS35L41_IRQ2_RAW_STATUS2 0x00010894 +#define CS35L41_IRQ2_RAW_STATUS3 0x00010898 +#define CS35L41_IRQ2_RAW_STATUS4 0x0001089C +#define CS35L41_IRQ2_MASK1 0x00010910 +#define CS35L41_IRQ2_MASK2 0x00010914 +#define CS35L41_IRQ2_MASK3 0x00010918 +#define CS35L41_IRQ2_MASK4 0x0001091C +#define CS35L41_IRQ2_FRC1 0x00010990 +#define CS35L41_IRQ2_FRC2 0x00010994 +#define CS35L41_IRQ2_FRC3 0x00010998 +#define CS35L41_IRQ2_FRC4 0x0001099C +#define CS35L41_IRQ2_EDGE1 0x00010A10 +#define CS35L41_IRQ2_EDGE4 0x00010A1C +#define CS35L41_IRQ2_POL1 0x00010A90 +#define CS35L41_IRQ2_POL2 0x00010A94 +#define CS35L41_IRQ2_POL3 0x00010A98 +#define CS35L41_IRQ2_POL4 0x00010A9C +#define CS35L41_IRQ2_DB3 0x00010B18 +#define CS35L41_GPIO_STATUS1 0x00011000 +#define CS35L41_GPIO1_CTRL1 0x00011008 +#define CS35L41_GPIO2_CTRL1 0x0001100C +#define CS35L41_MIXER_NGATE_CFG 0x00012000 +#define CS35L41_MIXER_NGATE_CH1_CFG 0x00012004 +#define CS35L41_MIXER_NGATE_CH2_CFG 0x00012008 +#define CS35L41_DSP_MBOX_1 0x00013000 +#define CS35L41_DSP_MBOX_2 0x00013004 +#define CS35L41_DSP_MBOX_3 0x00013008 +#define CS35L41_DSP_MBOX_4 0x0001300C +#define CS35L41_DSP_MBOX_5 0x00013010 +#define CS35L41_DSP_MBOX_6 0x00013014 +#define CS35L41_DSP_MBOX_7 0x00013018 +#define CS35L41_DSP_MBOX_8 0x0001301C +#define CS35L41_DSP_VIRT1_MBOX_1 0x00013020 +#define CS35L41_DSP_VIRT1_MBOX_2 0x00013024 +#define CS35L41_DSP_VIRT1_MBOX_3 0x00013028 +#define CS35L41_DSP_VIRT1_MBOX_4 0x0001302C +#define CS35L41_DSP_VIRT1_MBOX_5 0x00013030 +#define CS35L41_DSP_VIRT1_MBOX_6 0x00013034 +#define CS35L41_DSP_VIRT1_MBOX_7 0x00013038 +#define CS35L41_DSP_VIRT1_MBOX_8 0x0001303C +#define CS35L41_DSP_VIRT2_MBOX_1 0x00013040 +#define CS35L41_DSP_VIRT2_MBOX_2 0x00013044 +#define CS35L41_DSP_VIRT2_MBOX_3 0x00013048 +#define CS35L41_DSP_VIRT2_MBOX_4 0x0001304C +#define CS35L41_DSP_VIRT2_MBOX_5 0x00013050 +#define CS35L41_DSP_VIRT2_MBOX_6 0x00013054 +#define CS35L41_DSP_VIRT2_MBOX_7 0x00013058 +#define CS35L41_DSP_VIRT2_MBOX_8 0x0001305C +#define CS35L41_CLOCK_DETECT_1 0x00014000 +#define CS35L41_TIMER1_CONTROL 0x00015000 +#define CS35L41_TIMER1_COUNT_PRESET 0x00015004 +#define CS35L41_TIMER1_START_STOP 0x0001500C +#define CS35L41_TIMER1_STATUS 0x00015010 +#define CS35L41_TIMER1_COUNT_READBACK 0x00015014 +#define CS35L41_TIMER1_DSP_CLK_CFG 0x00015018 +#define CS35L41_TIMER1_DSP_CLK_STATUS 0x0001501C +#define CS35L41_TIMER2_CONTROL 0x00015100 +#define CS35L41_TIMER2_COUNT_PRESET 0x00015104 +#define CS35L41_TIMER2_START_STOP 0x0001510C +#define CS35L41_TIMER2_STATUS 0x00015110 +#define CS35L41_TIMER2_COUNT_READBACK 0x00015114 +#define CS35L41_TIMER2_DSP_CLK_CFG 0x00015118 +#define CS35L41_TIMER2_DSP_CLK_STATUS 0x0001511C +#define CS35L41_DFT_JTAG_CONTROL 0x00016000 +#define CS35L41_DIE_STS1 0x00017040 +#define CS35L41_DIE_STS2 0x00017044 +#define CS35L41_TEMP_CAL1 0x00017048 +#define CS35L41_TEMP_CAL2 0x0001704C +#define CS35L41_DSP1_XMEM_PACK_0 0x02000000 +#define CS35L41_DSP1_XMEM_PACK_3068 0x02002FF0 +#define CS35L41_DSP1_XMEM_UNPACK32_0 0x02400000 +#define CS35L41_DSP1_XMEM_UNPACK32_2046 0x02401FF8 +#define CS35L41_DSP1_TIMESTAMP_COUNT 0x025C0800 +#define CS35L41_DSP1_SYS_ID 0x025E0000 +#define CS35L41_DSP1_SYS_VERSION 0x025E0004 +#define CS35L41_DSP1_SYS_CORE_ID 0x025E0008 +#define CS35L41_DSP1_SYS_AHB_ADDR 0x025E000C +#define CS35L41_DSP1_SYS_XSRAM_SIZE 0x025E0010 +#define CS35L41_DSP1_SYS_YSRAM_SIZE 0x025E0018 +#define CS35L41_DSP1_SYS_PSRAM_SIZE 0x025E0020 +#define CS35L41_DSP1_SYS_PM_BOOT_SIZE 0x025E0028 +#define CS35L41_DSP1_SYS_FEATURES 0x025E002C +#define CS35L41_DSP1_SYS_FIR_FILTERS 0x025E0030 +#define CS35L41_DSP1_SYS_LMS_FILTERS 0x025E0034 +#define CS35L41_DSP1_SYS_XM_BANK_SIZE 0x025E0038 +#define CS35L41_DSP1_SYS_YM_BANK_SIZE 0x025E003C +#define CS35L41_DSP1_SYS_PM_BANK_SIZE 0x025E0040 +#define CS35L41_DSP1_AHBM_WIN0_CTRL0 0x025E2000 +#define CS35L41_DSP1_AHBM_WIN0_CTRL1 0x025E2004 +#define CS35L41_DSP1_AHBM_WIN1_CTRL0 0x025E2008 +#define CS35L41_DSP1_AHBM_WIN1_CTRL1 0x025E200C +#define CS35L41_DSP1_AHBM_WIN2_CTRL0 0x025E2010 +#define CS35L41_DSP1_AHBM_WIN2_CTRL1 0x025E2014 +#define CS35L41_DSP1_AHBM_WIN3_CTRL0 0x025E2018 +#define CS35L41_DSP1_AHBM_WIN3_CTRL1 0x025E201C +#define CS35L41_DSP1_AHBM_WIN4_CTRL0 0x025E2020 +#define CS35L41_DSP1_AHBM_WIN4_CTRL1 0x025E2024 +#define CS35L41_DSP1_AHBM_WIN5_CTRL0 0x025E2028 +#define CS35L41_DSP1_AHBM_WIN5_CTRL1 0x025E202C +#define CS35L41_DSP1_AHBM_WIN6_CTRL0 0x025E2030 +#define CS35L41_DSP1_AHBM_WIN6_CTRL1 0x025E2034 +#define CS35L41_DSP1_AHBM_WIN7_CTRL0 0x025E2038 +#define CS35L41_DSP1_AHBM_WIN7_CTRL1 0x025E203C +#define CS35L41_DSP1_AHBM_WIN_DBG_CTRL0 0x025E2040 +#define CS35L41_DSP1_AHBM_WIN_DBG_CTRL1 0x025E2044 +#define CS35L41_DSP1_XMEM_UNPACK24_0 0x02800000 +#define CS35L41_DSP1_XMEM_UNPACK24_4093 0x02803FF4 +#define CS35L41_DSP1_CTRL_BASE 0x02B80000 +#define CS35L41_DSP1_CORE_SOFT_RESET 0x02B80010 +#define CS35L41_DSP1_DEBUG 0x02B80040 +#define CS35L41_DSP1_TIMER_CTRL 0x02B80048 +#define CS35L41_DSP1_STREAM_ARB_CTRL 0x02B80050 +#define CS35L41_DSP1_RX1_RATE 0x02B80080 +#define CS35L41_DSP1_RX2_RATE 0x02B80088 +#define CS35L41_DSP1_RX3_RATE 0x02B80090 +#define CS35L41_DSP1_RX4_RATE 0x02B80098 +#define CS35L41_DSP1_RX5_RATE 0x02B800A0 +#define CS35L41_DSP1_RX6_RATE 0x02B800A8 +#define CS35L41_DSP1_RX7_RATE 0x02B800B0 +#define CS35L41_DSP1_RX8_RATE 0x02B800B8 +#define CS35L41_DSP1_TX1_RATE 0x02B80280 +#define CS35L41_DSP1_TX2_RATE 0x02B80288 +#define CS35L41_DSP1_TX3_RATE 0x02B80290 +#define CS35L41_DSP1_TX4_RATE 0x02B80298 +#define CS35L41_DSP1_TX5_RATE 0x02B802A0 +#define CS35L41_DSP1_TX6_RATE 0x02B802A8 +#define CS35L41_DSP1_TX7_RATE 0x02B802B0 +#define CS35L41_DSP1_TX8_RATE 0x02B802B8 +#define CS35L41_DSP1_NMI_CTRL1 0x02B80480 +#define CS35L41_DSP1_NMI_CTRL2 0x02B80488 +#define CS35L41_DSP1_NMI_CTRL3 0x02B80490 +#define CS35L41_DSP1_NMI_CTRL4 0x02B80498 +#define CS35L41_DSP1_NMI_CTRL5 0x02B804A0 +#define CS35L41_DSP1_NMI_CTRL6 0x02B804A8 +#define CS35L41_DSP1_NMI_CTRL7 0x02B804B0 +#define CS35L41_DSP1_NMI_CTRL8 0x02B804B8 +#define CS35L41_DSP1_RESUME_CTRL 0x02B80500 +#define CS35L41_DSP1_IRQ1_CTRL 0x02B80508 +#define CS35L41_DSP1_IRQ2_CTRL 0x02B80510 +#define CS35L41_DSP1_IRQ3_CTRL 0x02B80518 +#define CS35L41_DSP1_IRQ4_CTRL 0x02B80520 +#define CS35L41_DSP1_IRQ5_CTRL 0x02B80528 +#define CS35L41_DSP1_IRQ6_CTRL 0x02B80530 +#define CS35L41_DSP1_IRQ7_CTRL 0x02B80538 +#define CS35L41_DSP1_IRQ8_CTRL 0x02B80540 +#define CS35L41_DSP1_IRQ9_CTRL 0x02B80548 +#define CS35L41_DSP1_IRQ10_CTRL 0x02B80550 +#define CS35L41_DSP1_IRQ11_CTRL 0x02B80558 +#define CS35L41_DSP1_IRQ12_CTRL 0x02B80560 +#define CS35L41_DSP1_IRQ13_CTRL 0x02B80568 +#define CS35L41_DSP1_IRQ14_CTRL 0x02B80570 +#define CS35L41_DSP1_IRQ15_CTRL 0x02B80578 +#define CS35L41_DSP1_IRQ16_CTRL 0x02B80580 +#define CS35L41_DSP1_IRQ17_CTRL 0x02B80588 +#define CS35L41_DSP1_IRQ18_CTRL 0x02B80590 +#define CS35L41_DSP1_IRQ19_CTRL 0x02B80598 +#define CS35L41_DSP1_IRQ20_CTRL 0x02B805A0 +#define CS35L41_DSP1_IRQ21_CTRL 0x02B805A8 +#define CS35L41_DSP1_IRQ22_CTRL 0x02B805B0 +#define CS35L41_DSP1_IRQ23_CTRL 0x02B805B8 +#define CS35L41_DSP1_SCRATCH1 0x02B805C0 +#define CS35L41_DSP1_SCRATCH2 0x02B805C8 +#define CS35L41_DSP1_SCRATCH3 0x02B805D0 +#define CS35L41_DSP1_SCRATCH4 0x02B805D8 +#define CS35L41_DSP1_CCM_CORE_CTRL 0x02BC1000 +#define CS35L41_DSP1_CCM_CLK_OVERRIDE 0x02BC1008 +#define CS35L41_DSP1_XM_MSTR_EN 0x02BC2000 +#define CS35L41_DSP1_XM_CORE_PRI 0x02BC2008 +#define CS35L41_DSP1_XM_AHB_PACK_PL_PRI 0x02BC2010 +#define CS35L41_DSP1_XM_AHB_UP_PL_PRI 0x02BC2018 +#define CS35L41_DSP1_XM_ACCEL_PL0_PRI 0x02BC2020 +#define CS35L41_DSP1_XM_NPL0_PRI 0x02BC2078 +#define CS35L41_DSP1_YM_MSTR_EN 0x02BC20C0 +#define CS35L41_DSP1_YM_CORE_PRI 0x02BC20C8 +#define CS35L41_DSP1_YM_AHB_PACK_PL_PRI 0x02BC20D0 +#define CS35L41_DSP1_YM_AHB_UP_PL_PRI 0x02BC20D8 +#define CS35L41_DSP1_YM_ACCEL_PL0_PRI 0x02BC20E0 +#define CS35L41_DSP1_YM_NPL0_PRI 0x02BC2138 +#define CS35L41_DSP1_PM_MSTR_EN 0x02BC2180 +#define CS35L41_DSP1_PM_PATCH0_ADDR 0x02BC2188 +#define CS35L41_DSP1_PM_PATCH0_EN 0x02BC218C +#define CS35L41_DSP1_PM_PATCH0_DATA_LO 0x02BC2190 +#define CS35L41_DSP1_PM_PATCH0_DATA_HI 0x02BC2194 +#define CS35L41_DSP1_PM_PATCH1_ADDR 0x02BC2198 +#define CS35L41_DSP1_PM_PATCH1_EN 0x02BC219C +#define CS35L41_DSP1_PM_PATCH1_DATA_LO 0x02BC21A0 +#define CS35L41_DSP1_PM_PATCH1_DATA_HI 0x02BC21A4 +#define CS35L41_DSP1_PM_PATCH2_ADDR 0x02BC21A8 +#define CS35L41_DSP1_PM_PATCH2_EN 0x02BC21AC +#define CS35L41_DSP1_PM_PATCH2_DATA_LO 0x02BC21B0 +#define CS35L41_DSP1_PM_PATCH2_DATA_HI 0x02BC21B4 +#define CS35L41_DSP1_PM_PATCH3_ADDR 0x02BC21B8 +#define CS35L41_DSP1_PM_PATCH3_EN 0x02BC21BC +#define CS35L41_DSP1_PM_PATCH3_DATA_LO 0x02BC21C0 +#define CS35L41_DSP1_PM_PATCH3_DATA_HI 0x02BC21C4 +#define CS35L41_DSP1_PM_PATCH4_ADDR 0x02BC21C8 +#define CS35L41_DSP1_PM_PATCH4_EN 0x02BC21CC +#define CS35L41_DSP1_PM_PATCH4_DATA_LO 0x02BC21D0 +#define CS35L41_DSP1_PM_PATCH4_DATA_HI 0x02BC21D4 +#define CS35L41_DSP1_PM_PATCH5_ADDR 0x02BC21D8 +#define CS35L41_DSP1_PM_PATCH5_EN 0x02BC21DC +#define CS35L41_DSP1_PM_PATCH5_DATA_LO 0x02BC21E0 +#define CS35L41_DSP1_PM_PATCH5_DATA_HI 0x02BC21E4 +#define CS35L41_DSP1_PM_PATCH6_ADDR 0x02BC21E8 +#define CS35L41_DSP1_PM_PATCH6_EN 0x02BC21EC +#define CS35L41_DSP1_PM_PATCH6_DATA_LO 0x02BC21F0 +#define CS35L41_DSP1_PM_PATCH6_DATA_HI 0x02BC21F4 +#define CS35L41_DSP1_PM_PATCH7_ADDR 0x02BC21F8 +#define CS35L41_DSP1_PM_PATCH7_EN 0x02BC21FC +#define CS35L41_DSP1_PM_PATCH7_DATA_LO 0x02BC2200 +#define CS35L41_DSP1_PM_PATCH7_DATA_HI 0x02BC2204 +#define CS35L41_DSP1_MPU_XM_ACCESS0 0x02BC3000 +#define CS35L41_DSP1_MPU_YM_ACCESS0 0x02BC3004 +#define CS35L41_DSP1_MPU_WNDW_ACCESS0 0x02BC3008 +#define CS35L41_DSP1_MPU_XREG_ACCESS0 0x02BC300C +#define CS35L41_DSP1_MPU_YREG_ACCESS0 0x02BC3014 +#define CS35L41_DSP1_MPU_XM_ACCESS1 0x02BC3018 +#define CS35L41_DSP1_MPU_YM_ACCESS1 0x02BC301C +#define CS35L41_DSP1_MPU_WNDW_ACCESS1 0x02BC3020 +#define CS35L41_DSP1_MPU_XREG_ACCESS1 0x02BC3024 +#define CS35L41_DSP1_MPU_YREG_ACCESS1 0x02BC302C +#define CS35L41_DSP1_MPU_XM_ACCESS2 0x02BC3030 +#define CS35L41_DSP1_MPU_YM_ACCESS2 0x02BC3034 +#define CS35L41_DSP1_MPU_WNDW_ACCESS2 0x02BC3038 +#define CS35L41_DSP1_MPU_XREG_ACCESS2 0x02BC303C +#define CS35L41_DSP1_MPU_YREG_ACCESS2 0x02BC3044 +#define CS35L41_DSP1_MPU_XM_ACCESS3 0x02BC3048 +#define CS35L41_DSP1_MPU_YM_ACCESS3 0x02BC304C +#define CS35L41_DSP1_MPU_WNDW_ACCESS3 0x02BC3050 +#define CS35L41_DSP1_MPU_XREG_ACCESS3 0x02BC3054 +#define CS35L41_DSP1_MPU_YREG_ACCESS3 0x02BC305C +#define CS35L41_DSP1_MPU_XM_VIO_ADDR 0x02BC3100 +#define CS35L41_DSP1_MPU_XM_VIO_STATUS 0x02BC3104 +#define CS35L41_DSP1_MPU_YM_VIO_ADDR 0x02BC3108 +#define CS35L41_DSP1_MPU_YM_VIO_STATUS 0x02BC310C +#define CS35L41_DSP1_MPU_PM_VIO_ADDR 0x02BC3110 +#define CS35L41_DSP1_MPU_PM_VIO_STATUS 0x02BC3114 +#define CS35L41_DSP1_MPU_LOCK_CONFIG 0x02BC3140 +#define CS35L41_DSP1_MPU_WDT_RST_CTRL 0x02BC3180 +#define CS35L41_DSP1_STRMARB_MSTR0_CFG0 0x02BC5000 +#define CS35L41_DSP1_STRMARB_MSTR0_CFG1 0x02BC5004 +#define CS35L41_DSP1_STRMARB_MSTR0_CFG2 0x02BC5008 +#define CS35L41_DSP1_STRMARB_MSTR1_CFG0 0x02BC5010 +#define CS35L41_DSP1_STRMARB_MSTR1_CFG1 0x02BC5014 +#define CS35L41_DSP1_STRMARB_MSTR1_CFG2 0x02BC5018 +#define CS35L41_DSP1_STRMARB_MSTR2_CFG0 0x02BC5020 +#define CS35L41_DSP1_STRMARB_MSTR2_CFG1 0x02BC5024 +#define CS35L41_DSP1_STRMARB_MSTR2_CFG2 0x02BC5028 +#define CS35L41_DSP1_STRMARB_MSTR3_CFG0 0x02BC5030 +#define CS35L41_DSP1_STRMARB_MSTR3_CFG1 0x02BC5034 +#define CS35L41_DSP1_STRMARB_MSTR3_CFG2 0x02BC5038 +#define CS35L41_DSP1_STRMARB_MSTR4_CFG0 0x02BC5040 +#define CS35L41_DSP1_STRMARB_MSTR4_CFG1 0x02BC5044 +#define CS35L41_DSP1_STRMARB_MSTR4_CFG2 0x02BC5048 +#define CS35L41_DSP1_STRMARB_MSTR5_CFG0 0x02BC5050 +#define CS35L41_DSP1_STRMARB_MSTR5_CFG1 0x02BC5054 +#define CS35L41_DSP1_STRMARB_MSTR5_CFG2 0x02BC5058 +#define CS35L41_DSP1_STRMARB_MSTR6_CFG0 0x02BC5060 +#define CS35L41_DSP1_STRMARB_MSTR6_CFG1 0x02BC5064 +#define CS35L41_DSP1_STRMARB_MSTR6_CFG2 0x02BC5068 +#define CS35L41_DSP1_STRMARB_MSTR7_CFG0 0x02BC5070 +#define CS35L41_DSP1_STRMARB_MSTR7_CFG1 0x02BC5074 +#define CS35L41_DSP1_STRMARB_MSTR7_CFG2 0x02BC5078 +#define CS35L41_DSP1_STRMARB_TX0_CFG0 0x02BC5200 +#define CS35L41_DSP1_STRMARB_TX0_CFG1 0x02BC5204 +#define CS35L41_DSP1_STRMARB_TX1_CFG0 0x02BC5208 +#define CS35L41_DSP1_STRMARB_TX1_CFG1 0x02BC520C +#define CS35L41_DSP1_STRMARB_TX2_CFG0 0x02BC5210 +#define CS35L41_DSP1_STRMARB_TX2_CFG1 0x02BC5214 +#define CS35L41_DSP1_STRMARB_TX3_CFG0 0x02BC5218 +#define CS35L41_DSP1_STRMARB_TX3_CFG1 0x02BC521C +#define CS35L41_DSP1_STRMARB_TX4_CFG0 0x02BC5220 +#define CS35L41_DSP1_STRMARB_TX4_CFG1 0x02BC5224 +#define CS35L41_DSP1_STRMARB_TX5_CFG0 0x02BC5228 +#define CS35L41_DSP1_STRMARB_TX5_CFG1 0x02BC522C +#define CS35L41_DSP1_STRMARB_TX6_CFG0 0x02BC5230 +#define CS35L41_DSP1_STRMARB_TX6_CFG1 0x02BC5234 +#define CS35L41_DSP1_STRMARB_TX7_CFG0 0x02BC5238 +#define CS35L41_DSP1_STRMARB_TX7_CFG1 0x02BC523C +#define CS35L41_DSP1_STRMARB_RX0_CFG0 0x02BC5400 +#define CS35L41_DSP1_STRMARB_RX0_CFG1 0x02BC5404 +#define CS35L41_DSP1_STRMARB_RX1_CFG0 0x02BC5408 +#define CS35L41_DSP1_STRMARB_RX1_CFG1 0x02BC540C +#define CS35L41_DSP1_STRMARB_RX2_CFG0 0x02BC5410 +#define CS35L41_DSP1_STRMARB_RX2_CFG1 0x02BC5414 +#define CS35L41_DSP1_STRMARB_RX3_CFG0 0x02BC5418 +#define CS35L41_DSP1_STRMARB_RX3_CFG1 0x02BC541C +#define CS35L41_DSP1_STRMARB_RX4_CFG0 0x02BC5420 +#define CS35L41_DSP1_STRMARB_RX4_CFG1 0x02BC5424 +#define CS35L41_DSP1_STRMARB_RX5_CFG0 0x02BC5428 +#define CS35L41_DSP1_STRMARB_RX5_CFG1 0x02BC542C +#define CS35L41_DSP1_STRMARB_RX6_CFG0 0x02BC5430 +#define CS35L41_DSP1_STRMARB_RX6_CFG1 0x02BC5434 +#define CS35L41_DSP1_STRMARB_RX7_CFG0 0x02BC5438 +#define CS35L41_DSP1_STRMARB_RX7_CFG1 0x02BC543C +#define CS35L41_DSP1_STRMARB_IRQ0_CFG0 0x02BC5600 +#define CS35L41_DSP1_STRMARB_IRQ0_CFG1 0x02BC5604 +#define CS35L41_DSP1_STRMARB_IRQ0_CFG2 0x02BC5608 +#define CS35L41_DSP1_STRMARB_IRQ1_CFG0 0x02BC5610 +#define CS35L41_DSP1_STRMARB_IRQ1_CFG1 0x02BC5614 +#define CS35L41_DSP1_STRMARB_IRQ1_CFG2 0x02BC5618 +#define CS35L41_DSP1_STRMARB_IRQ2_CFG0 0x02BC5620 +#define CS35L41_DSP1_STRMARB_IRQ2_CFG1 0x02BC5624 +#define CS35L41_DSP1_STRMARB_IRQ2_CFG2 0x02BC5628 +#define CS35L41_DSP1_STRMARB_IRQ3_CFG0 0x02BC5630 +#define CS35L41_DSP1_STRMARB_IRQ3_CFG1 0x02BC5634 +#define CS35L41_DSP1_STRMARB_IRQ3_CFG2 0x02BC5638 +#define CS35L41_DSP1_STRMARB_IRQ4_CFG0 0x02BC5640 +#define CS35L41_DSP1_STRMARB_IRQ4_CFG1 0x02BC5644 +#define CS35L41_DSP1_STRMARB_IRQ4_CFG2 0x02BC5648 +#define CS35L41_DSP1_STRMARB_IRQ5_CFG0 0x02BC5650 +#define CS35L41_DSP1_STRMARB_IRQ5_CFG1 0x02BC5654 +#define CS35L41_DSP1_STRMARB_IRQ5_CFG2 0x02BC5658 +#define CS35L41_DSP1_STRMARB_IRQ6_CFG0 0x02BC5660 +#define CS35L41_DSP1_STRMARB_IRQ6_CFG1 0x02BC5664 +#define CS35L41_DSP1_STRMARB_IRQ6_CFG2 0x02BC5668 +#define CS35L41_DSP1_STRMARB_IRQ7_CFG0 0x02BC5670 +#define CS35L41_DSP1_STRMARB_IRQ7_CFG1 0x02BC5674 +#define CS35L41_DSP1_STRMARB_IRQ7_CFG2 0x02BC5678 +#define CS35L41_DSP1_STRMARB_RESYNC_MSK 0x02BC5A00 +#define CS35L41_DSP1_STRMARB_ERR_STATUS 0x02BC5A08 +#define CS35L41_DSP1_INTPCTL_RES_STATIC 0x02BC6000 +#define CS35L41_DSP1_INTPCTL_RES_DYN 0x02BC6004 +#define CS35L41_DSP1_INTPCTL_NMI_CTRL 0x02BC6008 +#define CS35L41_DSP1_INTPCTL_IRQ_INV 0x02BC6010 +#define CS35L41_DSP1_INTPCTL_IRQ_MODE 0x02BC6014 +#define CS35L41_DSP1_INTPCTL_IRQ_EN 0x02BC6018 +#define CS35L41_DSP1_INTPCTL_IRQ_MSK 0x02BC601C +#define CS35L41_DSP1_INTPCTL_IRQ_FLUSH 0x02BC6020 +#define CS35L41_DSP1_INTPCTL_IRQ_MSKCLR 0x02BC6024 +#define CS35L41_DSP1_INTPCTL_IRQ_FRC 0x02BC6028 +#define CS35L41_DSP1_INTPCTL_IRQ_MSKSET 0x02BC602C +#define CS35L41_DSP1_INTPCTL_IRQ_ERR 0x02BC6030 +#define CS35L41_DSP1_INTPCTL_IRQ_PEND 0x02BC6034 +#define CS35L41_DSP1_INTPCTL_IRQ_GEN 0x02BC6038 +#define CS35L41_DSP1_INTPCTL_TESTBITS 0x02BC6040 +#define CS35L41_DSP1_WDT_CONTROL 0x02BC7000 +#define CS35L41_DSP1_WDT_STATUS 0x02BC7008 +#define CS35L41_DSP1_YMEM_PACK_0 0x02C00000 +#define CS35L41_DSP1_YMEM_PACK_1532 0x02C017F0 +#define CS35L41_DSP1_YMEM_UNPACK32_0 0x03000000 +#define CS35L41_DSP1_YMEM_UNPACK32_1022 0x03000FF8 +#define CS35L41_DSP1_YMEM_UNPACK24_0 0x03400000 +#define CS35L41_DSP1_YMEM_UNPACK24_2045 0x03401FF4 +#define CS35L41_DSP1_PMEM_0 0x03800000 +#define CS35L41_DSP1_PMEM_5114 0x03804FE8 + +/*test regs for emulation bringup*/ +#define CS35L41_PLL_OVR 0x00003018 +#define CS35L41_BST_TEST_DUTY 0x00003900 +#define CS35L41_DIGPWM_IOCTRL 0x0000706C + +/*registers populated by OTP*/ +#define CS35L41_OTP_TRIM_1 0x0000208c +#define CS35L41_OTP_TRIM_2 0x00002090 +#define CS35L41_OTP_TRIM_3 0x00003010 +#define CS35L41_OTP_TRIM_4 0x0000300C +#define CS35L41_OTP_TRIM_5 0x0000394C +#define CS35L41_OTP_TRIM_6 0x00003950 +#define CS35L41_OTP_TRIM_7 0x00003954 +#define CS35L41_OTP_TRIM_8 0x00003958 +#define CS35L41_OTP_TRIM_9 0x0000395C +#define CS35L41_OTP_TRIM_10 0x0000416C +#define CS35L41_OTP_TRIM_11 0x00004160 +#define CS35L41_OTP_TRIM_12 0x00004170 +#define CS35L41_OTP_TRIM_13 0x00004360 +#define CS35L41_OTP_TRIM_14 0x00004448 +#define CS35L41_OTP_TRIM_15 0x0000444C +#define CS35L41_OTP_TRIM_16 0x00006E30 +#define CS35L41_OTP_TRIM_17 0x00006E34 +#define CS35L41_OTP_TRIM_18 0x00006E38 +#define CS35L41_OTP_TRIM_19 0x00006E3C +#define CS35L41_OTP_TRIM_20 0x00006E40 +#define CS35L41_OTP_TRIM_21 0x00006E44 +#define CS35L41_OTP_TRIM_22 0x00006E48 +#define CS35L41_OTP_TRIM_23 0x00006E4C +#define CS35L41_OTP_TRIM_24 0x00006E50 +#define CS35L41_OTP_TRIM_25 0x00006E54 +#define CS35L41_OTP_TRIM_26 0x00006E58 +#define CS35L41_OTP_TRIM_27 0x00006E5C +#define CS35L41_OTP_TRIM_28 0x00006E60 +#define CS35L41_OTP_TRIM_29 0x00006E64 +#define CS35L41_OTP_TRIM_30 0x00007418 +#define CS35L41_OTP_TRIM_31 0x0000741C +#define CS35L41_OTP_TRIM_32 0x00007434 +#define CS35L41_OTP_TRIM_33 0x00007068 +#define CS35L41_OTP_TRIM_34 0x0000410C +#define CS35L41_OTP_TRIM_35 0x0000400C +#define CS35L41_OTP_TRIM_36 0x00002030 + +#define CS35L41_MAX_CACHE_REG 36 +#define CS35L41_OTP_SIZE_WORDS 32 +#define CS35L41_NUM_OTP_ELEM 100 +#define CS35L41_NUM_OTP_MAPS 5 + +#define CS35L41_VALID_PDATA 0x80000000 +#define CS35L41_NUM_SUPPLIES 2 + +#define CS35L41_SCLK_MSTR_MASK 0x10 +#define CS35L41_SCLK_MSTR_SHIFT 4 +#define CS35L41_LRCLK_MSTR_MASK 0x01 +#define CS35L41_LRCLK_MSTR_SHIFT 0 +#define CS35L41_SCLK_INV_MASK 0x40 +#define CS35L41_SCLK_INV_SHIFT 6 +#define CS35L41_LRCLK_INV_MASK 0x04 +#define CS35L41_LRCLK_INV_SHIFT 2 +#define CS35L41_SCLK_FRC_MASK 0x20 +#define CS35L41_SCLK_FRC_SHIFT 5 +#define CS35L41_LRCLK_FRC_MASK 0x02 +#define CS35L41_LRCLK_FRC_SHIFT 1 + +#define CS35L41_AMP_GAIN_PCM_MASK 0x3E0 +#define CS35L41_AMP_GAIN_ZC_MASK 0x0400 +#define CS35L41_AMP_GAIN_ZC_SHIFT 10 + +#define CS35L41_BST_CTL_MASK 0xFF +#define CS35L41_BST_CTL_SEL_MASK 0x03 +#define CS35L41_BST_CTL_SEL_REG 0x00 +#define CS35L41_BST_CTL_SEL_CLASSH 0x01 +#define CS35L41_BST_IPK_MASK 0x7F +#define CS35L41_BST_IPK_SHIFT 0 +#define CS35L41_BST_LIM_MASK 0x4 +#define CS35L41_BST_LIM_SHIFT 2 +#define CS35L41_BST_K1_MASK 0x000000FF +#define CS35L41_BST_K1_SHIFT 0 +#define CS35L41_BST_K2_MASK 0x0000FF00 +#define CS35L41_BST_K2_SHIFT 8 +#define CS35L41_BST_SLOPE_MASK 0x0000FF00 +#define CS35L41_BST_SLOPE_SHIFT 8 +#define CS35L41_BST_LBST_VAL_MASK 0x00000003 +#define CS35L41_BST_LBST_VAL_SHIFT 0 + +#define CS35L41_TEMP_THLD_MASK 0x03 +#define CS35L41_VMON_IMON_VOL_MASK 0x07FF07FF +#define CS35L41_PDM_MODE_MASK 0x01 +#define CS35L41_PDM_MODE_SHIFT 0 + +#define CS35L41_CH_MEM_DEPTH_MASK 0x07 +#define CS35L41_CH_MEM_DEPTH_SHIFT 0 +#define CS35L41_CH_HDRM_CTL_MASK 0x007F0000 +#define CS35L41_CH_HDRM_CTL_SHIFT 16 +#define CS35L41_CH_REL_RATE_MASK 0xFF00 +#define CS35L41_CH_REL_RATE_SHIFT 8 +#define CS35L41_CH_WKFET_DLY_MASK 0x001C +#define CS35L41_CH_WKFET_DLY_SHIFT 2 +#define CS35L41_CH_WKFET_THLD_MASK 0x0F00 +#define CS35L41_CH_WKFET_THLD_SHIFT 8 + +#define CS35L41_HW_NG_SEL_MASK 0x3F00 +#define CS35L41_HW_NG_SEL_SHIFT 8 +#define CS35L41_HW_NG_DLY_MASK 0x0070 +#define CS35L41_HW_NG_DLY_SHIFT 4 +#define CS35L41_HW_NG_THLD_MASK 0x0007 +#define CS35L41_HW_NG_THLD_SHIFT 0 + +#define CS35L41_DSP_NG_ENABLE_MASK 0x00010000 +#define CS35L41_DSP_NG_ENABLE_SHIFT 16 +#define CS35L41_DSP_NG_THLD_MASK 0x7 +#define CS35L41_DSP_NG_THLD_SHIFT 0 +#define CS35L41_DSP_NG_DELAY_MASK 0x0F00 +#define CS35L41_DSP_NG_DELAY_SHIFT 8 + +#define CS35L41_ASP_FMT_MASK 0x0700 +#define CS35L41_ASP_FMT_SHIFT 8 +#define CS35L41_ASP_DOUT_HIZ_MASK 0x03 +#define CS35L41_ASP_DOUT_HIZ_SHIFT 0 +#define CS35L41_ASP_WIDTH_16 0x10 +#define CS35L41_ASP_WIDTH_24 0x18 +#define CS35L41_ASP_WIDTH_32 0x20 +#define CS35L41_ASP_WIDTH_TX_MASK 0xFF0000 +#define CS35L41_ASP_WIDTH_TX_SHIFT 16 +#define CS35L41_ASP_WIDTH_RX_MASK 0xFF000000 +#define CS35L41_ASP_WIDTH_RX_SHIFT 24 +#define CS35L41_ASP_RX1_SLOT_MASK 0x3F +#define CS35L41_ASP_RX1_SLOT_SHIFT 0 +#define CS35L41_ASP_RX2_SLOT_MASK 0x3F00 +#define CS35L41_ASP_RX2_SLOT_SHIFT 8 +#define CS35L41_ASP_RX_WL_MASK 0x3F +#define CS35L41_ASP_TX_WL_MASK 0x3F +#define CS35L41_ASP_RX_WL_SHIFT 0 +#define CS35L41_ASP_TX_WL_SHIFT 0 +#define CS35L41_ASP_SOURCE_MASK 0x7F + +#define CS35L41_INPUT_SRC_ASPRX1 0x08 +#define CS35L41_INPUT_SRC_ASPRX2 0x09 +#define CS35L41_INPUT_SRC_VMON 0x18 +#define CS35L41_INPUT_SRC_IMON 0x19 +#define CS35L41_INPUT_SRC_CLASSH 0x21 +#define CS35L41_INPUT_SRC_VPMON 0x28 +#define CS35L41_INPUT_SRC_VBSTMON 0x29 +#define CS35L41_INPUT_SRC_TEMPMON 0x3A +#define CS35L41_INPUT_SRC_RSVD 0x3B +#define CS35L41_INPUT_DSP_TX1 0x32 +#define CS35L41_INPUT_DSP_TX2 0x33 + +#define CS35L41_PLL_CLK_SEL_MASK 0x07 +#define CS35L41_PLL_CLK_SEL_SHIFT 0 +#define CS35L41_PLL_CLK_EN_MASK 0x10 +#define CS35L41_PLL_CLK_EN_SHIFT 4 +#define CS35L41_PLL_OPENLOOP_MASK 0x0800 +#define CS35L41_PLL_OPENLOOP_SHIFT 11 +#define CS35L41_PLLSRC_SCLK 0 +#define CS35L41_PLLSRC_LRCLK 1 +#define CS35L41_PLLSRC_SELF 3 +#define CS35L41_PLLSRC_PDMCLK 4 +#define CS35L41_PLLSRC_MCLK 5 +#define CS35L41_PLLSRC_SWIRE 7 +#define CS35L41_REFCLK_FREQ_MASK 0x7E0 +#define CS35L41_REFCLK_FREQ_SHIFT 5 + +#define CS35L41_GLOBAL_FS_MASK 0x1F +#define CS35L41_GLOBAL_FS_SHIFT 0 + +#define CS35L41_GLOBAL_EN_MASK 0x01 +#define CS35L41_GLOBAL_EN_SHIFT 0 +#define CS35L41_BST_EN_MASK 0x0030 +#define CS35L41_BST_EN_SHIFT 4 +#define CS35L41_BST_EN_DEFAULT 0x2 +#define CS35L41_AMP_EN_SHIFT 0 +#define CS35L41_AMP_EN_MASK 1 + +#define CS35L41_PDN_DONE_MASK 0x00800000 +#define CS35L41_PDN_DONE_SHIFT 23 +#define CS35L41_PUP_DONE_MASK 0x01000000 +#define CS35L41_PUP_DONE_SHIFT 24 + +#define CS35L36_PUP_DONE_IRQ_UNMASK 0x5F +#define CS35L36_PUP_DONE_IRQ_MASK 0xBF + +#define CS35L41_AMP_SHORT_ERR 0x80000000 +#define CS35L41_BST_SHORT_ERR 0x0100 +#define CS35L41_TEMP_WARN 0x8000 +#define CS35L41_TEMP_ERR 0x00020000 +#define CS35L41_BST_OVP_ERR 0x40 +#define CS35L41_BST_DCM_UVP_ERR 0x80 +#define CS35L41_OTP_BOOT_DONE 0x02 +#define CS35L41_PLL_UNLOCK 0x10 +#define CS35L41_OTP_BOOT_ERR 0x80000000 + +#define CS35L41_AMP_SHORT_ERR_RLS 0x02 +#define CS35L41_BST_SHORT_ERR_RLS 0x04 +#define CS35L41_BST_OVP_ERR_RLS 0x08 +#define CS35L41_BST_UVP_ERR_RLS 0x10 +#define CS35L41_TEMP_WARN_ERR_RLS 0x20 +#define CS35L41_TEMP_ERR_RLS 0x40 + +#define CS35L41_INT1_MASK_DEFAULT 0x7FFCFE3F +#define CS35L41_INT1_UNMASK_PUP 0xFEFFFFFF +#define CS35L41_INT1_UNMASK_PDN 0xFF7FFFFF + +#define CS35L41_GPIO_DIR_MASK 0x80000000 +#define CS35L41_GPIO_DIR_SHIFT 31 +#define CS35L41_GPIO1_CTRL_MASK 0x00030000 +#define CS35L41_GPIO1_CTRL_SHIFT 16 +#define CS35L41_GPIO2_CTRL_MASK 0x07000000 +#define CS35L41_GPIO2_CTRL_SHIFT 24 +#define CS35L41_GPIO_CTRL_OPEN_INT 2 +#define CS35L41_GPIO_CTRL_ACTV_LO 4 +#define CS35L41_GPIO_CTRL_ACTV_HI 5 +#define CS35L41_GPIO_POL_MASK 0x1000 +#define CS35L41_GPIO_POL_SHIFT 12 + +#define CS35L41_AMP_INV_PCM_SHIFT 14 +#define CS35L41_AMP_INV_PCM_MASK BIT(CS35L41_AMP_INV_PCM_SHIFT) +#define CS35L41_AMP_PCM_VOL_SHIFT 3 +#define CS35L41_AMP_PCM_VOL_MASK (0x7FF << 3) +#define CS35L41_AMP_PCM_VOL_MUTE 0x4CF + +#define CS35L41_CHIP_ID 0x35a40 +#define CS35L41R_CHIP_ID 0x35b40 +#define CS35L41_MTLREVID_MASK 0x0F +#define CS35L41_REVID_A0 0xA0 +#define CS35L41_REVID_B0 0xB0 +#define CS35L41_REVID_B2 0xB2 + +#define CS35L41_HALO_CORE_RESET 0x00000200 + +#define CS35L41_FS1_WINDOW_MASK 0x000007FF +#define CS35L41_FS2_WINDOW_MASK 0x00FFF800 +#define CS35L41_FS2_WINDOW_SHIFT 12 + +#define CS35L41_SPI_MAX_FREQ 4000000 +#define CS35L41_REGSTRIDE 4 +enum cs35l41_clk_ids {CS35L41_CLKID_SCLK =0 , CS35L41_CLKID_LRCLK = 1,
@@ -31,4 +746,22 @@ struct cs35l41_platform_data { struct cs35l41_irq_cfg irq_config2; }; +struct cs35l41_otp_packed_element_t { +u32 reg; +u8 shift; +u8 size; +}; + +struct cs35l41_otp_map_element_t { +u32 id; +u32 num_elements; +const struct cs35l41_otp_packed_element_t *map; +u32 bit_offset; +u32 word_offset; +}; + +extern const struct cs35l41_otp_map_element_t cs35l41_otp_map_map[CS35L41_NUM_OTP_MAPS ]; +extern struct regmap_config cs35l41_regmap_i2c; +extern struct regmap_config cs35l41_regmap_spi; +#endif /* __CS35L41_H */
sound/soc/codecs/Kconfig +7 -4
@@ -612,21 +612,24 @@ config SND_SOC_CS35L36 tristate "Cirrus Logic CS35L36 CODEC" depends on I2C +config SND_SOC_CS35L41_LIB + tristate + config SND_SOC_CS35L41 tristate - default y if SND_SOC_CS35L41_SPI=y - default y if SND_SOC_CS35L41_I2C=y - default m if SND_SOC_CS35L41_SPI=m - default m if SND_SOC_CS35L41_I2C=m config SND_SOC_CS35L41_SPI tristate "Cirrus Logic CS35L41 CODEC (SPI)" depends on SPI_MASTER + select SND_SOC_CS35L41_LIB + select SND_SOC_CS35L41 select REGMAP_SPI config SND_SOC_CS35L41_I2C tristate "Cirrus Logic CS35L41 CODEC (I2C)" depends on I2C + select SND_SOC_CS35L41_LIB + select SND_SOC_CS35L41 select REGMAP_I2C config SND_SOC_CS42L42
sound/soc/codecs/Makefile +3 -1
@@ -54,7 +54,8 @@ snd-soc-cs35l33-objs := cs35l33.o snd-soc-cs35l34-objs := cs35l34.o snd-soc-cs35l35-objs := cs35l35.o snd-soc-cs35l36-objs := cs35l36.o -snd-soc-cs35l41-objs := cs35l41.o cs35l41-tables.o +snd-soc-cs35l41-lib-objs := cs35l41-lib.o +snd-soc-cs35l41-objs := cs35l41.o snd-soc-cs35l41-spi-objs := cs35l41-spi.o snd-soc-cs35l41-i2c-objs := cs35l41-i2c.o snd-soc-cs42l42-objs := cs42l42.o
@@ -393,6 +394,7 @@ obj-$(CONFIG_SND_SOC_CS35L34) += snd-soc-cs35l34.o obj-$(CONFIG_SND_SOC_CS35L35) += snd-soc-cs35l35.o obj-$(CONFIG_SND_SOC_CS35L36) += snd-soc-cs35l36.o obj-$(CONFIG_SND_SOC_CS35L41) += snd-soc-cs35l41.o +obj-$(CONFIG_SND_SOC_CS35L41_LIB) += snd-soc-cs35l41-lib.o obj-$(CONFIG_SND_SOC_CS35L41_SPI) += snd-soc-cs35l41-spi.o obj-$(CONFIG_SND_SOC_CS35L41_I2C) += snd-soc-cs35l41-i2c.o obj-$(CONFIG_SND_SOC_CS42L42) += snd-soc-cs42l42.o
sound/soc/codecs/cs35l41-i2c.c +0 -1
@@ -17,7 +17,6 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include <sound/cs35l41.h> #include "cs35l41.h" static const struct i2c_device_id cs35l41_id_i2c[] = {
sound/soc/codecs/cs35l41-lib.c renamed from sound/soc/codecs/cs35l41-tables.c +12 -2
@@ -1,12 +1,16 @@// SPDX-License-Identifier: GPL-2.0 // -// cs35l41-tables.c -- CS35L41 ALSA SoC audio driver +// cs35l41-lib.c -- CS35L41 Common functions for HDA and ASoC Audio drivers // // Copyright 2017-2021 Cirrus Logic, Inc. // // Author: David Rhodes <[email protected]> +// Author: Lucas Tanure <[email protected]> -#include "cs35l41.h" +#include <linux/module.h> +#include <linux/regmap.h> + +#include <sound/cs35l41.h> static const struct reg_default cs35l41_reg[] = { {CS35L41_PWR_CTRL1 ,0x00000000 },
@@ -688,6 +692,7 @@ const struct cs35l41_otp_map_element_t cs35l41_otp_map_map[CS35L41_NUM_OTP_MAPS] .word_offset = 2, }, }; +EXPORT_SYMBOL_GPL (cs35l41_otp_map_map);struct regmap_config cs35l41_regmap_i2c = { .reg_bits = 32,
@@ -721,3 +726,8 @@ struct regmap_config cs35l41_regmap_spi = { .cache_type = REGCACHE_RBTREE, };EXPORT_SYMBOL_GPL (cs35l41_regmap_spi); + +MODULE_DESCRIPTION ("CS35L41 library" ); +MODULE_AUTHOR ("David Rhodes, Cirrus Logic Inc, <[email protected]>" ); +MODULE_AUTHOR ("Lucas Tanure, Cirrus Logic Inc, <[email protected]>" ); +MODULE_LICENSE ("GPL" );
sound/soc/codecs/cs35l41-spi.c +0 -1
@@ -15,7 +15,6 @@#include <linux/platform_device.h> #include <linux/spi/spi.h> -#include <sound/cs35l41.h> #include "cs35l41.h" static const struct spi_device_id cs35l41_id_spi[] = {
sound/soc/codecs/cs35l41.h +0 -734
749 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v6 2/10 ASoC: cs35l41: Move cs35l41_otp_unpack to shared code
In reply to Lucas TanureASoC and HDA will do the same cs35l41_otp_unpack, so move it to shared code
--- include/sound/cs35l41.h | 4 +- sound/soc/codecs/cs35l41-lib.c | 121 ++++++++++++++++++++++++++++++- sound/soc/codecs/cs35l41.c | 125 +-------------------------------- 3 files changed, 122 insertions(+), 128 deletions(-)
include/sound/cs35l41.h +2 -2
@@ -534,7 +534,6 @@#define CS35L41_MAX_CACHE_REG 36#define CS35L41_OTP_SIZE_WORDS 32#define CS35L41_NUM_OTP_ELEM 100 -#define CS35L41_NUM_OTP_MAPS 5#define CS35L41_VALID_PDATA 0x80000000#define CS35L41_NUM_SUPPLIES 2
@@ -760,8 +759,9 @@ struct cs35l41_otp_map_element_t { u32 word_offset; }; -extern const struct cs35l41_otp_map_element_t cs35l41_otp_map_map[CS35L41_NUM_OTP_MAPS ];extern struct regmap_config cs35l41_regmap_i2c;extern struct regmap_config cs35l41_regmap_spi; +int cs35l41_otp_unpack (struct device *dev,struct regmap *regmap); +#endif /* __CS35L41_H */
sound/soc/codecs/cs35l41-lib.c +119 -2
147 lines not on this page · raw message
sound/soc/codecs/cs35l41.c +1 -124
143 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v6 3/10 ASoC: cs35l41: Move power initializations to reg_sequence
In reply to Lucas TanureASoC and HDA systems for all revisions of CS35L41 will benefit from having this initialization, so add it to reg_sequence of each revision
By moving to reg_sequence all gains are set to zero. And boost, monitoring parts, and class D amplifier are disabled.
--- sound/soc/codecs/cs35l41-lib.c | 3 ++- sound/soc/codecs/cs35l41.c | 20 ++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-)
sound/soc/codecs/cs35l41-lib.c +2 -1
@@ -17,6 +17,7 @@static const struct reg_default cs35l41_reg[] = { {CS35L41_PWR_CTRL1 ,0x00000000 }, + {CS35L41_PWR_CTRL2 ,0x00000000 }, {CS35L41_PWR_CTRL3 ,0x01000010 }, {CS35L41_GPIO_PAD_CONTROL ,0x00000000 }, {CS35L41_SP_ENABLES ,0x00000000 },
@@ -46,7 +47,7 @@ static const struct reg_default cs35l41_reg[] = { { CS35L41_CLASSH_CFG, 0x000B0405 }, { CS35L41_WKFET_CFG, 0x00000111 }, { CS35L41_NG_CFG, 0x00000033 }, - { CS35L41_AMP_GAIN_CTRL, 0x00000273 }, + { CS35L41_AMP_GAIN_CTRL, 0x00000000 }, { CS35L41_GPIO1_CTRL1, 0xE1000001 }, { CS35L41_GPIO2_CTRL1, 0xE1000001 }, { CS35L41_MIXER_NGATE_CFG, 0x00000000 },
sound/soc/codecs/cs35l41.c +6 -14
@@ -1288,6 +1288,8 @@ static const struct reg_sequence cs35l41_reva0_errata_patch[] = { { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, { 0x00000040, 0x0000CCCC }, { 0x00000040, 0x00003333 }, + { CS35L41_PWR_CTRL2, 0x00000000 }, + { CS35L41_AMP_GAIN_CTRL, 0x00000000 }, }; static const struct reg_sequence cs35l41_revb0_errata_patch[] = {
@@ -1301,6 +1303,8 @@ static const struct reg_sequence cs35l41_revb0_errata_patch[] = { { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, { 0x00000040, 0x0000CCCC }, { 0x00000040, 0x00003333 }, + { CS35L41_PWR_CTRL2, 0x00000000 }, + { CS35L41_AMP_GAIN_CTRL, 0x00000000 }, }; static const struct reg_sequence cs35l41_revb2_errata_patch[] = {
@@ -1314,6 +1318,8 @@ static const struct reg_sequence cs35l41_revb2_errata_patch[] = { { CS35L41_DSP1_XM_ACCEL_PL0_PRI, 0x00000000 }, { 0x00000040, 0x0000CCCC }, { 0x00000040, 0x00003333 }, + { CS35L41_PWR_CTRL2, 0x00000000 }, + { CS35L41_AMP_GAIN_CTRL, 0x00000000 }, }; static const struct reg_sequence cs35l41_fs_errata_patch[] = {
@@ -1556,20 +1562,6 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, goto err; } - ret =regmap_update_bits (cs35l41->regmap,CS35L41_PWR_CTRL2 , -CS35L41_AMP_EN_MASK ,0 ); -if (ret <0 ) { -dev_err (cs35l41->dev,"Write CS35L41_PWR_CTRL2 failed: %d\n" , ret); - goto err; - } - - ret =regmap_update_bits (cs35l41->regmap,CS35L41_AMP_GAIN_CTRL , -CS35L41_AMP_GAIN_PCM_MASK ,0 ); -if (ret <0 ) { -dev_err (cs35l41->dev,"Write CS35L41_AMP_GAIN_CTRL failed: %d\n" , ret); - goto err; - } - ret =cs35l41_set_pdata (cs35l41);if (ret <0 ) {dev_err (cs35l41->dev,"Set pdata failed: %d\n" , ret);
Signature · 1 line
2.34.1
PATCH v6 4/10 ASoC: cs35l41: Create shared function for errata patches
In reply to Lucas TanureASoC and HDA systems require the same errata patches, so move it to the shared code using a function the correctly applies the patches by revision
Also, move CS35L41_DSP1_CCM_CORE_CTRL write to errata patch function as is required to be written at boot, but not in regmap_register_patch sequence as will affect waking up from hibernation
--- include/sound/cs35l41.h | 1 + sound/soc/codecs/cs35l41-lib.c | 89 ++++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l41.c | 92 ++-------------------------------- 3 files changed, 93 insertions(+), 89 deletions(-)
include/sound/cs35l41.h +1 -0
@@ -763,5 +763,6 @@ extern struct regmap_config cs35l41_regmap_i2c;extern struct regmap_config cs35l41_regmap_spi;int cs35l41_otp_unpack (struct device *dev,struct regmap *regmap); +int cs35l41_register_errata_patch (struct device *dev,struct regmap *reg,unsigned int reg_revid);#endif /* __CS35L41_H */
sound/soc/codecs/cs35l41-lib.c +89 -0
101 lines not on this page · raw message
sound/soc/codecs/cs35l41.c +3 -89
110 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v6 5/10 ASoC: cs35l41: Create shared function for setting channels
In reply to Lucas TanureASoC and HDA will use the same register to set channels for the device
--- include/sound/cs35l41.h | 3 +++ sound/soc/codecs/cs35l41-lib.c | 32 ++++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l41.c | 30 +++--------------------------- 3 files changed, 38 insertions(+), 27 deletions(-)
include/sound/cs35l41.h +3 -0
@@ -764,5 +764,8 @@ extern struct regmap_config cs35l41_regmap_spi;int cs35l41_otp_unpack (struct device *dev,struct regmap *regmap);int cs35l41_register_errata_patch (struct device *dev,struct regmap *reg,unsigned int reg_revid); +int cs35l41_set_channels (struct device *dev,struct regmap *reg, +unsigned int tx_num,unsigned int *tx_slot, +unsigned int rx_num,unsigned int *rx_slot);#endif /* __CS35L41_H */
sound/soc/codecs/cs35l41-lib.c +32 -0
@@ -934,6 +934,38 @@ int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsign }EXPORT_SYMBOL_GPL (cs35l41_register_errata_patch); +int cs35l41_set_channels (struct device *dev,struct regmap *reg, +unsigned int tx_num,unsigned int *tx_slot, +unsigned int rx_num,unsigned int *rx_slot) +{ +unsigned int val, mask; +int i; + +if (tx_num >4 || rx_num >2 ) +return -EINVAL ; + + val =0 ; + mask =0 ; +for (i =0 ; i < rx_num; i++) { +dev_dbg (dev,"rx slot %d position = %d\n" , i, rx_slot[i]); + val |= rx_slot[i] << (i *8 ); + mask |=0x3F << (i *8 ); + } +regmap_update_bits (reg,CS35L41_SP_FRAME_RX_SLOT , mask, val); + + val =0 ; + mask =0 ; +for (i =0 ; i < tx_num; i++) { +dev_dbg (dev,"tx slot %d position = %d\n" , i, tx_slot[i]); + val |= tx_slot[i] << (i *8 ); + mask |=0x3F << (i *8 ); + } +regmap_update_bits (reg,CS35L41_SP_FRAME_TX_SLOT , mask, val); + +return 0 ; +} +EXPORT_SYMBOL_GPL (cs35l41_set_channels); +MODULE_DESCRIPTION ("CS35L41 library" );MODULE_AUTHOR ("David Rhodes, Cirrus Logic Inc, <[email protected]>" );MODULE_AUTHOR ("Lucas Tanure, Cirrus Logic Inc, <[email protected]>" );
sound/soc/codecs/cs35l41.c +3 -27
@@ -751,36 +751,12 @@ static const struct cs_dsp_region cs35l41_dsp1_regions[] = { {. type = WMFW_ADSP2_YM, .base = CS35L41_DSP1_YMEM_UNPACK24_0}, }; -static int cs35l41_set_channel_map (struct snd_soc_dai *dai,unsigned int tx_num, -unsigned int *tx_slot,unsigned int rx_num, -unsigned int *rx_slot) +static int cs35l41_set_channel_map (struct snd_soc_dai *dai,unsigned int tx_n, +unsigned int *tx_slot,unsigned int rx_n,unsigned int *rx_slot) {struct cs35l41_private *cs35l41 =snd_soc_component_get_drvdata (dai->component); -unsigned int val, mask; -int i; - -if (tx_num >4 || rx_num >2 ) -return -EINVAL ; - val =0 ; - mask =0 ; -for (i =0 ; i < rx_num; i++) { -dev_dbg (cs35l41->dev,"rx slot %d position = %d\n" , i, rx_slot[i]); - val |= rx_slot[i] << (i *8 ); - mask |=0x3F << (i *8 ); - } -regmap_update_bits (cs35l41->regmap,CS35L41_SP_FRAME_RX_SLOT , mask, val); - - val =0 ; - mask =0 ; -for (i =0 ; i < tx_num; i++) { -dev_dbg (cs35l41->dev,"tx slot %d position = %d\n" , i, tx_slot[i]); - val |= tx_slot[i] << (i *8 ); - mask |=0x3F << (i *8 ); - } -regmap_update_bits (cs35l41->regmap,CS35L41_SP_FRAME_TX_SLOT , mask, val); - -return 0 ; +return cs35l41_set_channels (cs35l41->dev, cs35l41->regmap, tx_n, tx_slot, rx_n, rx_slot); }static int cs35l41_set_dai_fmt (struct snd_soc_dai *dai,unsigned int fmt)
Signature · 1 line
2.34.1
PATCH v6 6/10 ASoC: cs35l41: Create shared function for boost configuration
In reply to Lucas TanureASoC and HDA will use the same registers to configure internal boost for the device
--- include/sound/cs35l41.h | 2 + sound/soc/codecs/cs35l41-lib.c | 98 ++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l41.c | 105 +-------------------------------- 3 files changed, 102 insertions(+), 103 deletions(-)
include/sound/cs35l41.h +2 -0
@@ -767,5 +767,7 @@ int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsignint cs35l41_set_channels (struct device *dev,struct regmap *reg,unsigned int tx_num,unsigned int *tx_slot,unsigned int rx_num,unsigned int *rx_slot); +int cs35l41_boost_config (struct device *dev,struct regmap *regmap,int boost_ind,int boost_cap, +int boost_ipk);#endif /* __CS35L41_H */
sound/soc/codecs/cs35l41-lib.c +98 -0
104 lines not on this page · raw message
sound/soc/codecs/cs35l41.c +2 -103
123 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v6 7/10 hda: cs35l41: Add support for CS35L41 in HDA systems
In reply to Lucas TanureAdd support for CS35L41 using a new separated driver that can be used in all upcoming designs
--- MAINTAINERS | 2 + sound/pci/hda/Kconfig | 29 ++ sound/pci/hda/Makefile | 10 + sound/pci/hda/cs35l41_hda.c | 527 ++++++++++++++++++++++++++++++++ sound/pci/hda/cs35l41_hda.h | 69 +++++ sound/pci/hda/cs35l41_hda_i2c.c | 66 ++++ sound/pci/hda/cs35l41_hda_spi.c | 63 ++++ sound/pci/hda/hda_component.h | 20 ++ 8 files changed, 786 insertions(+) create mode 100644 sound/pci/hda/cs35l41_hda.c create mode 100644 sound/pci/hda/cs35l41_hda.h create mode 100644 sound/pci/hda/cs35l41_hda_i2c.c create mode 100644 sound/pci/hda/cs35l41_hda_spi.c create mode 100644 sound/pci/hda/hda_component.h
MAINTAINERS +2 -0
@@ -4555,10 +4555,12 @@ F: drivers/media/cec/i2c/ch7322.c CIRRUS LOGIC AUDIO CODEC DRIVERS M: James Schulman <[email protected]> M: David Rhodes <[email protected]> +M: Lucas Tanure <[email protected]> L: [email protected] (moderated for non-subscribers) L: [email protected] S: Maintained F: Documentation/devicetree/bindings/sound/cirrus,cs* +F: sound/pci/hda/cs* F: sound/soc/codecs/cs* CIRRUS LOGIC DSP FIRMWARE DRIVER
sound/pci/hda/Kconfig +29 -0
@@ -91,6 +91,35 @@ config SND_HDA_PATCH_LOADER start up. The "patch" file can be specified via patch module option, such as patch=hda-init. +config SND_HDA_SCODEC_CS35L41 + tristate + +config SND_HDA_SCODEC_CS35L41_I2C + tristate "Build CS35L41 HD-audio side codec support for I2C Bus" + depends on ACPI + select SND_HDA_GENERIC + select SND_SOC_CS35L41_LIB + select SND_HDA_SCODEC_CS35L41 + help + Say Y or M here to include CS35L41 I2C HD-audio side codec support + in snd-hda-intel driver, such as ALC287. + +comment "Set to Y if you want auto-loading the side codec driver" + depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_I2C=m + +config SND_HDA_SCODEC_CS35L41_SPI + tristate "Build CS35L41 HD-audio codec support for SPI Bus" + depends on ACPI + select SND_HDA_GENERIC + select SND_SOC_CS35L41_LIB + select SND_HDA_SCODEC_CS35L41 + help + Say Y or M here to include CS35L41 SPI HD-audio side codec support + in snd-hda-intel driver, such as ALC287. + +comment "Set to Y if you want auto-loading the side codec driver" + depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_SPI=m + config SND_HDA_CODEC_REALTEK tristate "Build Realtek HD-audio codec support" select SND_HDA_GENERIC
sound/pci/hda/Makefile +10 -0
@@ -27,6 +27,11 @@ snd-hda-codec-conexant-objs := patch_conexant.o snd-hda-codec-via-objs := patch_via.o snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o +# side codecs +snd-hda-scodec-cs35l41-objs := cs35l41_hda.o +snd-hda-scodec-cs35l41-i2c-objs := cs35l41_hda_i2c.o +snd-hda-scodec-cs35l41-spi-objs := cs35l41_hda_spi.o + # common driver obj-$(CONFIG_SND_HDA) := snd-hda-codec.o
@@ -45,6 +50,11 @@ obj-$(CONFIG_SND_HDA_CODEC_CONEXANT) += snd-hda-codec-conexant.o obj-$(CONFIG_SND_HDA_CODEC_VIA) += snd-hda-codec-via.o obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o +# side codecs +obj-$(CONFIG_SND_HDA_SCODEC_CS35L41) += snd-hda-scodec-cs35l41.o +obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_I2C) += snd-hda-scodec-cs35l41-i2c.o +obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_SPI) += snd-hda-scodec-cs35l41-spi.o + # this must be the last entry after codec drivers; # otherwise the codec patches won't be hooked before the PCI probe # when built in kernel
sound/pci/hda/cs35l41_hda.c new file +527 -0
527 lines not on this page · raw message
sound/pci/hda/cs35l41_hda.h new file +69 -0
69 lines not on this page · raw message
sound/pci/hda/cs35l41_hda_i2c.c new file +66 -0
66 lines not on this page · raw message
sound/pci/hda/cs35l41_hda_spi.c new file +63 -0
63 lines not on this page · raw message
sound/pci/hda/hda_component.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* HD audio Component Binding Interface +* +* Copyright (C) 2021 Cirrus Logic, Inc. and +* Cirrus Logic International Semiconductor Ltd. +*/ + +#include <linux/component.h> + +#define HDA_MAX_COMPONENTS 4 +#define HDA_MAX_NAME_SIZE 50 + +struct hda_component { +struct device *dev; +char name[HDA_MAX_NAME_SIZE ]; +void (*playback_hook)(struct device *dev,int action); +int (*set_channel_map)(struct device *dev,unsigned int rx_num,unsigned int *rx_slot, +unsigned int tx_num,unsigned int *tx_slot); +};
Signature · 1 line
2.34.1
Re: [PATCH v6 07/10] hda: cs35l41: Add support for CS35L41 in HDA systems
Quoted 27 lines · Lucas Tanure
Add support for CS35L41 using a new separated driver that can be used in all upcoming designs
Signed-off-by Lucas Tanure <[email protected]>---
sound/pci/hda/cs35l41_hda.c new file +22
-0+ mtl_revid = reg_revid &CS35L41_MTLREVID_MASK ; + + chipid = (mtl_revid %2 ) ?CS35L41R_CHIP_ID :CS35L41_CHIP_ID ; +if (regid != chipid) { +dev_err (cs35l41->dev,"CS35L41 Device ID (%X). Expected ID %X\n" , regid, chipid); + ret = -ENODEV ; + goto err; + } + + ret =cs35l41_register_errata_patch (cs35l41->dev, cs35l41->regmap, reg_revid); +if (ret) + goto err; + + ret =cs35l41_otp_unpack (cs35l41->dev, cs35l41->regmap); +if (ret) { +dev_err (cs35l41->dev,"OTP Unpack failed: %d\n" , ret); + goto err; + } + + ret =cs35l41_hda_apply_properties (cs35l41, acpi_hw_cfg); +if (ret) + goto err;
sound/pci/hda/cs35l41_hda.c line 488
Quoted 10 lines
sound/pci/hda/cs35l41_hda.c new file +10
-0+kfree (acpi_hw_cfg); + +if (cs35l41->reg_seq->probe) { + ret =regmap_register_patch (cs35l41->regmap, cs35l41->reg_seq->probe, + cs35l41->reg_seq->num_probe); +if (ret) { +dev_err (cs35l41->dev,"Fail to apply probe reg patch: %d\n" , ret); + goto err; + } + }
Probably shouldn't use regmap_register_patch here, cs35l41_register_errata_patch has already registered a patch to the regmap, and this will then overwrite that patch. Probably better to do this stuff as a multi-write.
Thanks,
Charles
Re: [PATCH v6 07/10] hda: cs35l41: Add support for CS35L41 in HDA systems
In reply to Lucas TanureQuoted 28 lines · Lucas Tanure
Add support for CS35L41 using a new separated driver that can be used in all upcoming designs
sound/pci/hda/Kconfig +22
-0+config SND_HDA_SCODEC_CS35L41_I2C + tristate "Build CS35L41 HD-audio side codec support for I2C Bus" + depends on ACPI + select SND_HDA_GENERIC + select SND_SOC_CS35L41_LIB + select SND_HDA_SCODEC_CS35L41 + help + Say Y or M here to include CS35L41 I2C HD-audio side codec support + in snd-hda-intel driver, such as ALC287. + +comment "Set to Y if you want auto-loading the side codec driver" + depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_I2C=m + +config SND_HDA_SCODEC_CS35L41_SPI + tristate "Build CS35L41 HD-audio codec support for SPI Bus" + depends on ACPI + select SND_HDA_GENERIC + select SND_SOC_CS35L41_LIB + select SND_HDA_SCODEC_CS35L41 + help + Say Y or M here to include CS35L41 SPI HD-audio side codec support + in snd-hda-intel driver, such as ALC287.
...
Quoted 1 line
+//
cs35l41.c-- CS35l41 ALSA HDA audio driver
It's an additional burden in case the file will be renamed. i..o.w. drop the names of the files from the files.
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+#include <linux/acpi.h> +#include <linux/module.h> +#include <sound/hda_codec.h> +#include "hda_local.h" +#include "hda_auto_parser.h" +#include "hda_jack.h" +#include "hda_generic.h" +#include "hda_component.h" +#include "cs35l41_hda.h"
...
Quoted 1 line
+ {
CS35L41_PWR_CTRL1,0x00000001, 2000 }, //GLOBAL_EN = 1
Here and everywhere else, missed space after //
...
Quoted 14 lines
sound/pci/hda/cs35l41_hda.c new file +14
-0+static void cs35l41_hda_playback_hook (struct device *dev,int action) +{ +struct cs35l41_hda *cs35l41 =dev_get_drvdata (dev); +const struct cs35l41_hda_reg_sequence *reg_seq = cs35l41->reg_seq; +struct regmap *reg = cs35l41->regmap; +int ret =0 ; + +switch (action) { +case HDA_GEN_PCM_ACT_OPEN : +if (reg_seq->open) + ret =regmap_multi_reg_write (reg, reg_seq->open, reg_seq->num_open); +break ; +case HDA_GEN_PCM_ACT_PREPARE : +if (reg_seq->prepare)
sound/pci/hda/cs35l41_hda.c line 163
Quoted 10 lines
sound/pci/hda/cs35l41_hda.c new file +10
-0+ ret =regmap_multi_reg_write (reg, reg_seq->prepare, reg_seq->num_prepare); +break ; +case HDA_GEN_PCM_ACT_CLEANUP : +if (reg_seq->cleanup) + ret =regmap_multi_reg_write (reg, reg_seq->cleanup, reg_seq->num_cleanup); +break ; +case HDA_GEN_PCM_ACT_CLOSE : +if (reg_seq->close) + ret =regmap_multi_reg_write (reg, reg_seq->close, reg_seq->num_close); +break ;
default case?
sound/pci/hda/cs35l41_hda.c line 168
Quoted 6 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ } + +if (ret) +dev_warn (cs35l41->dev,"Failed to apply multi reg write: %d\n" , ret); +
Redundant blank line.
Quoted 1 line
+}
...
sound/pci/hda/cs35l41_hda.c line 188
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (comps && cs35l41->index >=0 && cs35l41->index <HDA_MAX_COMPONENTS ) + comps = &comps[cs35l41->index]; +else +return -EINVAL ;
Can you check first? In such a case you won't need the 'else' branch at all.
...
Quoted 1 line
+ if (!comps->dev) {
Why not a positive check and standard pattern as per above?
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+ comps->dev = dev; +strscpy (comps->name,dev_name (dev),sizeof (comps->name)); + comps->playback_hook = cs35l41_hda_playback_hook; + comps->set_channel_map = cs35l41_hda_channel_map; +return 0 ; + } + +return -EBUSY ; +}
...
sound/pci/hda/cs35l41_hda.c line 237
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+switch (hw_cfg->gpio1_func) { +case CS35l41_VSPK_SWITCH: +regmap_update_bits (cs35l41->regmap,CS35L41_GPIO_PAD_CONTROL , +CS35L41_GPIO1_CTRL_MASK ,1 <<CS35L41_GPIO1_CTRL_SHIFT ); +break ; +case CS35l41_SYNC: +regmap_update_bits (cs35l41->regmap,CS35L41_GPIO_PAD_CONTROL , +CS35L41_GPIO1_CTRL_MASK ,2 <<CS35L41_GPIO1_CTRL_SHIFT ); +break ;
default case?
Same for all switch-cases in your code.
Quoted 1 line
+ }
...
sound/pci/hda/cs35l41_hda.c line 263
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ ret =cs35l41_hda_channel_map (cs35l41->dev,0 ,NULL ,1 , (unsigned int *)&hw_cfg->spk_pos); +if (ret) +return ret; + +return 0 ;
return cs35l41_hda_...(...);
...
sound/pci/hda/cs35l41_hda.c line 287
Quoted 2 lines
sound/pci/hda/cs35l41_hda.c new file +2
-0+ property ="cirrus,dev-index" ; + ret =device_property_count_u32 (acpi_dev, property);
Please, name adev the pointer to ACPI device. Ah, what a mess, you have named acpi_dev the pointer to the struct device. Please, find a better name, like dev, or physdev or so.
Quoted 1 line
+ if (ret <= 0)
Shouldn't you override the error code for the 0 case?
Quoted 1 line
+ goto
no_acpi_dsd;
...
sound/pci/hda/cs35l41_hda.c line 294
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (ret >ARRAY_SIZE (values)) { + ret = -EINVAL ; + goto err; + }
Is it really the issue? I would expect the issue when you have less than expected, and not otherwise.
...
Quoted 1 line
+ /* No
devm_version as CLSA0100, inno_acpi_dsdcase, can't use devm version */
Can you elaborate why devm can't be used?
Quoted 1 line
+
cs35l41->reset_gpio= fwnode_gpiod_get_index(&adev->fwnode, "reset",cs35l41->index,
Please, do not dereference fwnode pointers. Also, why can't you use the device instead of fwnode?
Quoted 1 line
+
GPIOD_OUT_LOW, "cs35l41-reset");
...
Quoted 1 line
+
hw_cfg=kzalloc(sizeof(*hw_cfg), GFP_KERNEL);
Why not devm?
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (!hw_cfg) { + ret = -ENOMEM ; + goto err; + }
...
sound/pci/hda/cs35l41_hda.c line 328
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ property ="cirrus,speaker-position" ; + ret =device_property_read_u32_array (acpi_dev, property, values, nval); +if (ret) + goto err_free; + hw_cfg->spk_pos = values[cs35l41->index];
This and further is weird. Why do you need to retrieve all values for just one? Use indexed APIs for that. If there are none, create them.
...
sound/pci/hda/cs35l41_hda.c line 371
Quoted 3 lines
sound/pci/hda/cs35l41_hda.c new file +3
-0+no_acpi_dsd: +/* +* Device CLSA0100 doesn't have _DSD so a gpiod_get by the label reset won't work.
So, you need to add mapping tables and switch to regular APIs, tell me, why it won't work.
sound/pci/hda/cs35l41_hda.c line 375
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+* And devices created by i2c-multi-instantiate don't have their device struct pointing to +* the correct fwnode, so acpi_dev must be used here +* And devm functions expect that the device requesting the resource has the correct +* fwnode
You missed grammar periods and what else? Please, update your comments to use proper English grammar.
Quoted 12 lines
sound/pci/hda/cs35l41_hda.c new file +12
-0+*/ +if (strncmp (hid,"CLSA0100" ,8 ) !=0 ) +return ERR_PTR (-EINVAL ); + +/* check I2C address to assign the index */ + cs35l41->index = id ==0x40 ?0 :1 ; + cs35l41->reset_gpio =gpiod_get_index (acpi_dev,NULL ,0 ,GPIOD_OUT_HIGH ); + cs35l41->vspk_always_on = true; +put_device (acpi_dev); + +return NULL ; +}
...
sound/pci/hda/cs35l41_hda.c line 398
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, + struct regmap *regmap) + if (IS_ERR(regmap)) + return PTR_ERR(regmap);
Why?
...
Quoted 1 line
+ if (
IS_ERR(cs35l41->reset_gpio)) {
You should use _optinal variants instead,
sound/pci/hda/cs35l41_hda.c line 421
Quoted 8 lines
sound/pci/hda/cs35l41_hda.c new file +8
-0+ ret =PTR_ERR (cs35l41->reset_gpio); + cs35l41->reset_gpio =NULL ; +if (ret == -EBUSY ) { +dev_info (cs35l41->dev,"Reset line busy, assuming shared reset\n" ); + }else { +if (ret != -EPROBE_DEFER ) +dev_err (cs35l41->dev,"Failed to get reset GPIO: %d\n" , ret); + goto err;
We have dev_err_probe() for a few releases already.
Quoted 2 lines
(quoted diff) +2
-0+ } + }
...
sound/pci/hda/cs35l41_hda.c line 441
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+ ret =regmap_read (cs35l41->regmap,CS35L41_IRQ1_STATUS3 , &int_sts); +if (ret || (int_sts &CS35L41_OTP_BOOT_ERR )) { +dev_err (cs35l41->dev,"OTP Boot error\n" ); + ret = -EIO ;
Why shadowing error code?
Why not use dev_err_probe()?
Quoted 2 lines
(quoted diff) +2
-0+ goto err; + }
...
Quoted 1 line
+EXPORT_SYMBOL_GPL(cs35l41_hda_probe);
Please, use the namespace variant and avoid polluting the global namespace with your symbols.
...
Quoted 1 line
+ *
cs35l41_hda.h-- CS35L41 ALSA HDA audio driver
No file names in the files.
...
sound/pci/hda/cs35l41_hda.h line 16
Quoted 4 lines
sound/pci/hda/cs35l41_hda.h new file +4
-0+#include <linux/regulator/consumer.h> +#include <linux/gpio/consumer.h> +#include <linux/device.h> +#include <sound/cs35l41.h>
Please revisit this. You need to add here only the headers that you are a direct user of (or in some cases their top level ones, like types.h for compiler_attributes.h).
...
Quoted 1 line
+#ifdef
CONFIG_ACPI
Drop this ugliness.
sound/pci/hda/cs35l41_hda_i2c.c line 46
Quoted 3 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +3
-0+static const struct acpi_device_id cs35l41_acpi_hda_match[] = { + {"CLSA0100" ,0 }, + {"CSC3551" ,0 },
I believe these IDs are officially allocated by the Cirrus Logic, right?
Quoted 1 line
+ { },
No comma for terminator line here and everywhere else where it's the case.
sound/pci/hda/cs35l41_hda_i2c.c line 55
Quoted 8 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +8
-0+}; +MODULE_DEVICE_TABLE (acpi, cs35l41_acpi_hda_match); +#endif + +static struct i2c_driver cs35l41_i2c_driver = { + .driver = { + .name ="cs35l41-hda" , + .acpi_match_table =ACPI_PTR (cs35l41_acpi_hda_match),
ACPI_PTR() as well.
sound/pci/hda/cs35l41_hda_i2c.c line 61
Quoted 7 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +6
-0+ }, + .id_table = cs35l41_hda_i2c_id, + .probe = cs35l41_hda_i2c_probe, + .remove = cs35l41_hda_i2c_remove, +}; +
No need to have a blank line here.
Quoted 1 line
+module_i2c_driver(cs35l41_i2c_driver);
I stopped here, so this code needs more work and can't be applied like this.
I believe that current Cirrus Logic drivers are written in the same (semi-) bad style and have to be fixed in the future. Put this to your TODO list, please.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 07/10] hda: cs35l41: Add support for CS35L41 in HDA systems
Tom,below my review where you may find a lot to be improved in the code, including the place where you should fix it instead of your approach.
Quoted 356 lines · Andy Shevchenko
Quoted 28 lines · Lucas Tanure
Add support for CS35L41 using a new separated driver that can be used in all upcoming designs
sound/pci/hda/Kconfig +22
-0+config SND_HDA_SCODEC_CS35L41_I2C + tristate "Build CS35L41 HD-audio side codec support for I2C Bus" + depends on ACPI + select SND_HDA_GENERIC + select SND_SOC_CS35L41_LIB + select SND_HDA_SCODEC_CS35L41 + help + Say Y or M here to include CS35L41 I2C HD-audio side codec support + in snd-hda-intel driver, such as ALC287. + +comment "Set to Y if you want auto-loading the side codec driver" + depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_I2C=m + +config SND_HDA_SCODEC_CS35L41_SPI + tristate "Build CS35L41 HD-audio codec support for SPI Bus" + depends on ACPI + select SND_HDA_GENERIC + select SND_SOC_CS35L41_LIB + select SND_HDA_SCODEC_CS35L41 + help + Say Y or M here to include CS35L41 SPI HD-audio side codec support + in snd-hda-intel driver, such as ALC287....
Quoted 1 line
+//
cs35l41.c-- CS35l41 ALSA HDA audio driverIt's an additional burden in case the file will be renamed. i..o.w. drop the names of the files from the files.
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+#include <linux/acpi.h> +#include <linux/module.h> +#include <sound/hda_codec.h> +#include "hda_local.h" +#include "hda_auto_parser.h" +#include "hda_jack.h" +#include "hda_generic.h" +#include "hda_component.h" +#include "cs35l41_hda.h" ...
Quoted 1 line
+ {
CS35L41_PWR_CTRL1,0x00000001, 2000 }, //GLOBAL_EN = 1Here and everywhere else, missed space after //
...
Quoted 14 lines
sound/pci/hda/cs35l41_hda.c new file +14
-0+static void cs35l41_hda_playback_hook (struct device *dev,int action) +{ +struct cs35l41_hda *cs35l41 =dev_get_drvdata (dev); +const struct cs35l41_hda_reg_sequence *reg_seq = cs35l41->reg_seq; +struct regmap *reg = cs35l41->regmap; +int ret =0 ; + +switch (action) { +case HDA_GEN_PCM_ACT_OPEN : +if (reg_seq->open) + ret =regmap_multi_reg_write (reg, reg_seq->open, reg_seq->num_open); +break ; +case HDA_GEN_PCM_ACT_PREPARE : +if (reg_seq->prepare)sound/pci/hda/cs35l41_hda.c line 163
Quoted 10 lines
sound/pci/hda/cs35l41_hda.c new file +10
-0+ ret =regmap_multi_reg_write (reg, reg_seq->prepare, reg_seq->num_prepare); +break ; +case HDA_GEN_PCM_ACT_CLEANUP : +if (reg_seq->cleanup) + ret =regmap_multi_reg_write (reg, reg_seq->cleanup, reg_seq->num_cleanup); +break ; +case HDA_GEN_PCM_ACT_CLOSE : +if (reg_seq->close) + ret =regmap_multi_reg_write (reg, reg_seq->close, reg_seq->num_close); +break ;default case?
sound/pci/hda/cs35l41_hda.c line 168
Quoted 6 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ } + +if (ret) +dev_warn (cs35l41->dev,"Failed to apply multi reg write: %d\n" , ret); +Redundant blank line.
Quoted 1 line
+}
...
sound/pci/hda/cs35l41_hda.c line 188
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (comps && cs35l41->index >=0 && cs35l41->index <HDA_MAX_COMPONENTS ) + comps = &comps[cs35l41->index]; +else +return -EINVAL ;Can you check first? In such a case you won't need the 'else' branch at all.
...
Quoted 1 line
+ if (!comps->dev) {
Why not a positive check and standard pattern as per above?
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+ comps->dev = dev; +strscpy (comps->name,dev_name (dev),sizeof (comps->name)); + comps->playback_hook = cs35l41_hda_playback_hook; + comps->set_channel_map = cs35l41_hda_channel_map; +return 0 ; + } + +return -EBUSY ; +}...
sound/pci/hda/cs35l41_hda.c line 237
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+switch (hw_cfg->gpio1_func) { +case CS35l41_VSPK_SWITCH: +regmap_update_bits (cs35l41->regmap,CS35L41_GPIO_PAD_CONTROL , +CS35L41_GPIO1_CTRL_MASK ,1 <<CS35L41_GPIO1_CTRL_SHIFT ); +break ; +case CS35l41_SYNC: +regmap_update_bits (cs35l41->regmap,CS35L41_GPIO_PAD_CONTROL , +CS35L41_GPIO1_CTRL_MASK ,2 <<CS35L41_GPIO1_CTRL_SHIFT ); +break ;default case?
Same for all switch-cases in your code.
Quoted 1 line
+ }
...
sound/pci/hda/cs35l41_hda.c line 263
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ ret =cs35l41_hda_channel_map (cs35l41->dev,0 ,NULL ,1 , (unsigned int *)&hw_cfg->spk_pos); +if (ret) +return ret; + +return 0 ;return cs35l41_hda_...(...);
...
sound/pci/hda/cs35l41_hda.c line 287
Quoted 2 lines
sound/pci/hda/cs35l41_hda.c new file +2
-0+ property ="cirrus,dev-index" ; + ret =device_property_count_u32 (acpi_dev, property);Please, name adev the pointer to ACPI device. Ah, what a mess, you have named
acpi_devthe pointer to the struct device. Please, find a better name, like dev, or physdev or so.Quoted 1 line
+ if (ret <= 0)
Shouldn't you override the error code for the 0 case?
Quoted 1 line
+ goto
no_acpi_dsd;...
sound/pci/hda/cs35l41_hda.c line 294
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (ret >ARRAY_SIZE (values)) { + ret = -EINVAL ; + goto err; + }Is it really the issue? I would expect the issue when you have less than expected, and not otherwise.
...
Quoted 1 line
+ /* No
devm_version as CLSA0100, inno_acpi_dsdcase, can't use devm version */Can you elaborate why devm can't be used?
Quoted 1 line
+
cs35l41->reset_gpio= fwnode_gpiod_get_index(&adev->fwnode, "reset",cs35l41->index,Please, do not dereference fwnode pointers. Also, why can't you use the device instead of fwnode?
Quoted 1 line
+
GPIOD_OUT_LOW, "cs35l41-reset");...
Quoted 1 line
+
hw_cfg=kzalloc(sizeof(*hw_cfg), GFP_KERNEL);Why not devm?
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (!hw_cfg) { + ret = -ENOMEM ; + goto err; + }...
sound/pci/hda/cs35l41_hda.c line 328
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ property ="cirrus,speaker-position" ; + ret =device_property_read_u32_array (acpi_dev, property, values, nval); +if (ret) + goto err_free; + hw_cfg->spk_pos = values[cs35l41->index];This and further is weird. Why do you need to retrieve all values for just one? Use indexed APIs for that. If there are none, create them.
...
sound/pci/hda/cs35l41_hda.c line 371
Quoted 3 lines
sound/pci/hda/cs35l41_hda.c new file +3
-0+no_acpi_dsd: +/* +* Device CLSA0100 doesn't have _DSD so a gpiod_get by the label reset won't work. So, you need to add mapping tables and switch to regular APIs, tell me, why it won't work.
sound/pci/hda/cs35l41_hda.c line 375
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+* And devices created by i2c-multi-instantiate don't have their device struct pointing to +* the correct fwnode, so acpi_dev must be used here +* And devm functions expect that the device requesting the resource has the correct +* fwnode You missed grammar periods and what else? Please, update your comments to use proper English grammar.
Quoted 12 lines
sound/pci/hda/cs35l41_hda.c new file +12
-0+*/ +if (strncmp (hid,"CLSA0100" ,8 ) !=0 ) +return ERR_PTR (-EINVAL ); + +/* check I2C address to assign the index */ + cs35l41->index = id ==0x40 ?0 :1 ; + cs35l41->reset_gpio =gpiod_get_index (acpi_dev,NULL ,0 ,GPIOD_OUT_HIGH ); + cs35l41->vspk_always_on = true; +put_device (acpi_dev); + +return NULL ; +}...
sound/pci/hda/cs35l41_hda.c line 398
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, + struct regmap *regmap) + if (IS_ERR(regmap)) + return PTR_ERR(regmap);Why?
...
Quoted 1 line
+ if (
IS_ERR(cs35l41->reset_gpio)) {You should use
_optinalvariants instead,sound/pci/hda/cs35l41_hda.c line 421
Quoted 8 lines
sound/pci/hda/cs35l41_hda.c new file +8
-0+ ret =PTR_ERR (cs35l41->reset_gpio); + cs35l41->reset_gpio =NULL ; +if (ret == -EBUSY ) { +dev_info (cs35l41->dev,"Reset line busy, assuming shared reset\n" ); + }else { +if (ret != -EPROBE_DEFER ) +dev_err (cs35l41->dev,"Failed to get reset GPIO: %d\n" , ret); + goto err;We have
dev_err_probe()for a few releases already.Quoted 2 lines
(quoted diff) +2
-0+ } + }...
sound/pci/hda/cs35l41_hda.c line 441
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+ ret =regmap_read (cs35l41->regmap,CS35L41_IRQ1_STATUS3 , &int_sts); +if (ret || (int_sts &CS35L41_OTP_BOOT_ERR )) { +dev_err (cs35l41->dev,"OTP Boot error\n" ); + ret = -EIO ;Why shadowing error code?
Why not usedev_err_probe()?Quoted 2 lines
(quoted diff) +2
-0+ goto err; + }...
Quoted 1 line
+EXPORT_SYMBOL_GPL(cs35l41_hda_probe);
Please, use the namespace variant and avoid polluting the global namespace with your symbols.
...
Quoted 1 line
+ *
cs35l41_hda.h-- CS35L41 ALSA HDA audio driverNo file names in the files.
...
sound/pci/hda/cs35l41_hda.h line 16
Quoted 4 lines
sound/pci/hda/cs35l41_hda.h new file +4
-0+#include <linux/regulator/consumer.h> +#include <linux/gpio/consumer.h> +#include <linux/device.h> +#include <sound/cs35l41.h> Please revisit this. You need to add here only the headers that you are a direct user of (or in some cases their top level ones, like
types.hforcompiler_attributes.h)....
Quoted 1 line
+#ifdef
CONFIG_ACPIDrop this ugliness.
sound/pci/hda/cs35l41_hda_i2c.c line 46
Quoted 3 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +3
-0+static const struct acpi_device_id cs35l41_acpi_hda_match[] = { + {"CLSA0100" ,0 }, + {"CSC3551" ,0 },I believe these IDs are officially allocated by the Cirrus Logic, right?
Quoted 1 line
+ { },
No comma for terminator line here and everywhere else where it's the case.
sound/pci/hda/cs35l41_hda_i2c.c line 55
Quoted 8 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +8
-0+}; +MODULE_DEVICE_TABLE (acpi, cs35l41_acpi_hda_match); +#endif + +static struct i2c_driver cs35l41_i2c_driver = { + .driver = { + .name ="cs35l41-hda" , + .acpi_match_table =ACPI_PTR (cs35l41_acpi_hda_match),
ACPI_PTR()as well.sound/pci/hda/cs35l41_hda_i2c.c line 61
Quoted 7 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +6
-0+ }, + .id_table = cs35l41_hda_i2c_id, + .probe = cs35l41_hda_i2c_probe, + .remove = cs35l41_hda_i2c_remove, +}; +No need to have a blank line here.
Quoted 1 line
+module_i2c_driver(cs35l41_i2c_driver);
I stopped here, so this code needs more work and can't be applied like this.
I believe that current Cirrus Logic drivers are written in the same (semi-) bad style and have to be fixed in the future. Put this to your TODO list, please.
--
With Best Regards,
Andy Shevchenko
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 07/10] hda: cs35l41: Add support for CS35L41 in HDA systems
In reply to Andy ShevchenkoQuoted 210 lines · Andy Shevchenko
Quoted 28 lines · Lucas Tanure
Add support for CS35L41 using a new separated driver that can be used in all upcoming designs
sound/pci/hda/Kconfig +22
-0+config SND_HDA_SCODEC_CS35L41_I2C + tristate "Build CS35L41 HD-audio side codec support for I2C Bus" + depends on ACPI + select SND_HDA_GENERIC + select SND_SOC_CS35L41_LIB + select SND_HDA_SCODEC_CS35L41 + help + Say Y or M here to include CS35L41 I2C HD-audio side codec support + in snd-hda-intel driver, such as ALC287. + +comment "Set to Y if you want auto-loading the side codec driver" + depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_I2C=m + +config SND_HDA_SCODEC_CS35L41_SPI + tristate "Build CS35L41 HD-audio codec support for SPI Bus" + depends on ACPI + select SND_HDA_GENERIC + select SND_SOC_CS35L41_LIB + select SND_HDA_SCODEC_CS35L41 + help + Say Y or M here to include CS35L41 SPI HD-audio side codec support + in snd-hda-intel driver, such as ALC287....
Quoted 1 line
+//
cs35l41.c-- CS35l41 ALSA HDA audio driverIt's an additional burden in case the file will be renamed. i..o.w. drop the names of the files from the files.
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+#include <linux/acpi.h> +#include <linux/module.h> +#include <sound/hda_codec.h> +#include "hda_local.h" +#include "hda_auto_parser.h" +#include "hda_jack.h" +#include "hda_generic.h" +#include "hda_component.h" +#include "cs35l41_hda.h" ...
Quoted 1 line
+ {
CS35L41_PWR_CTRL1,0x00000001, 2000 }, //GLOBAL_EN = 1Here and everywhere else, missed space after //
...
Quoted 14 lines
sound/pci/hda/cs35l41_hda.c new file +14
-0+static void cs35l41_hda_playback_hook (struct device *dev,int action) +{ +struct cs35l41_hda *cs35l41 =dev_get_drvdata (dev); +const struct cs35l41_hda_reg_sequence *reg_seq = cs35l41->reg_seq; +struct regmap *reg = cs35l41->regmap; +int ret =0 ; + +switch (action) { +case HDA_GEN_PCM_ACT_OPEN : +if (reg_seq->open) + ret =regmap_multi_reg_write (reg, reg_seq->open, reg_seq->num_open); +break ; +case HDA_GEN_PCM_ACT_PREPARE : +if (reg_seq->prepare)sound/pci/hda/cs35l41_hda.c line 163
Quoted 10 lines
sound/pci/hda/cs35l41_hda.c new file +10
-0+ ret =regmap_multi_reg_write (reg, reg_seq->prepare, reg_seq->num_prepare); +break ; +case HDA_GEN_PCM_ACT_CLEANUP : +if (reg_seq->cleanup) + ret =regmap_multi_reg_write (reg, reg_seq->cleanup, reg_seq->num_cleanup); +break ; +case HDA_GEN_PCM_ACT_CLOSE : +if (reg_seq->close) + ret =regmap_multi_reg_write (reg, reg_seq->close, reg_seq->num_close); +break ;default case?
sound/pci/hda/cs35l41_hda.c line 168
Quoted 6 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ } + +if (ret) +dev_warn (cs35l41->dev,"Failed to apply multi reg write: %d\n" , ret); +Redundant blank line.
Quoted 1 line
+}
...
sound/pci/hda/cs35l41_hda.c line 188
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (comps && cs35l41->index >=0 && cs35l41->index <HDA_MAX_COMPONENTS ) + comps = &comps[cs35l41->index]; +else +return -EINVAL ;Can you check first? In such a case you won't need the 'else' branch at all.
...
Quoted 1 line
+ if (!comps->dev) {
Why not a positive check and standard pattern as per above?
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+ comps->dev = dev; +strscpy (comps->name,dev_name (dev),sizeof (comps->name)); + comps->playback_hook = cs35l41_hda_playback_hook; + comps->set_channel_map = cs35l41_hda_channel_map; +return 0 ; + } + +return -EBUSY ; +}...
sound/pci/hda/cs35l41_hda.c line 237
Quoted 9 lines
sound/pci/hda/cs35l41_hda.c new file +9
-0+switch (hw_cfg->gpio1_func) { +case CS35l41_VSPK_SWITCH: +regmap_update_bits (cs35l41->regmap,CS35L41_GPIO_PAD_CONTROL , +CS35L41_GPIO1_CTRL_MASK ,1 <<CS35L41_GPIO1_CTRL_SHIFT ); +break ; +case CS35l41_SYNC: +regmap_update_bits (cs35l41->regmap,CS35L41_GPIO_PAD_CONTROL , +CS35L41_GPIO1_CTRL_MASK ,2 <<CS35L41_GPIO1_CTRL_SHIFT ); +break ;default case?
Same for all switch-cases in your code.
Quoted 1 line
+ }
...
sound/pci/hda/cs35l41_hda.c line 263
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ ret =cs35l41_hda_channel_map (cs35l41->dev,0 ,NULL ,1 , (unsigned int *)&hw_cfg->spk_pos); +if (ret) +return ret; + +return 0 ;return cs35l41_hda_...(...);
...
sound/pci/hda/cs35l41_hda.c line 287
Quoted 2 lines
sound/pci/hda/cs35l41_hda.c new file +2
-0+ property ="cirrus,dev-index" ; + ret =device_property_count_u32 (acpi_dev, property);Please, name adev the pointer to ACPI device. Ah, what a mess, you have named
acpi_devthe pointer to the struct device. Please, find a better name, like dev, or physdev or so.Quoted 1 line
+ if (ret <= 0)
Shouldn't you override the error code for the 0 case?
Quoted 1 line
+ goto
no_acpi_dsd;...
sound/pci/hda/cs35l41_hda.c line 294
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (ret >ARRAY_SIZE (values)) { + ret = -EINVAL ; + goto err; + }Is it really the issue? I would expect the issue when you have less than expected, and not otherwise.
...
Quoted 1 line
+ /* No
devm_version as CLSA0100, inno_acpi_dsdcase, can't use devm version */Can you elaborate why devm can't be used?
Quoted 1 line
+
cs35l41->reset_gpio= fwnode_gpiod_get_index(&adev->fwnode, "reset",cs35l41->index,Please, do not dereference fwnode pointers. Also, why can't you use the device instead of fwnode?
Quoted 1 line
+
GPIOD_OUT_LOW, "cs35l41-reset");...
Quoted 1 line
+
hw_cfg=kzalloc(sizeof(*hw_cfg), GFP_KERNEL);Why not devm?
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+if (!hw_cfg) { + ret = -ENOMEM ; + goto err; + }...
sound/pci/hda/cs35l41_hda.c line 328
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +5
-0+ property ="cirrus,speaker-position" ; + ret =device_property_read_u32_array (acpi_dev, property, values, nval); +if (ret) + goto err_free; + hw_cfg->spk_pos = values[cs35l41->index];This and further is weird. Why do you need to retrieve all values for just one? Use indexed APIs for that. If there are none, create them.
Quoted 8 lines
...
sound/pci/hda/cs35l41_hda.c line 371
Quoted 3 lines
sound/pci/hda/cs35l41_hda.c new file +3
-0+no_acpi_dsd: +/* +* Device CLSA0100 doesn't have _DSD so a gpiod_get by the label reset won't work. So, you need to add mapping tables and switch to regular APIs, tell me, why it won't work.
I will submit a patch series to fix most of the issues you pointed out. The part about how the driver access the ACPI table is going to be improved later if possible. The laptop has already shipped and doesn't have a _DSD node, so the driver needs to read the reset GPIO from a hard coded index inside a node that contains more than one cs35l41.
Quoted 24 lines
sound/pci/hda/cs35l41_hda.c line 375
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+* And devices created by i2c-multi-instantiate don't have their device struct pointing to +* the correct fwnode, so acpi_dev must be used here +* And devm functions expect that the device requesting the resource has the correct +* fwnode You missed grammar periods and what else? Please, update your comments to use proper English grammar.
Quoted 12 lines
sound/pci/hda/cs35l41_hda.c new file +12
-0+*/ +if (strncmp (hid,"CLSA0100" ,8 ) !=0 ) +return ERR_PTR (-EINVAL ); + +/* check I2C address to assign the index */ + cs35l41->index = id ==0x40 ?0 :1 ; + cs35l41->reset_gpio =gpiod_get_index (acpi_dev,NULL ,0 ,GPIOD_OUT_HIGH ); + cs35l41->vspk_always_on = true; +put_device (acpi_dev); + +return NULL ; +}...
Quoted 7 lines
sound/pci/hda/cs35l41_hda.c line 398
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, + struct regmap *regmap) + if (IS_ERR(regmap)) + return PTR_ERR(regmap);Why?
It is up to the I2C/SPI module to create the regmap and provide to the main module. If that fails the main module can't continue.
Quoted 62 lines
...
Quoted 1 line
+ if (
IS_ERR(cs35l41->reset_gpio)) {You should use
_optinalvariants instead,sound/pci/hda/cs35l41_hda.c line 421
Quoted 8 lines
sound/pci/hda/cs35l41_hda.c new file +8
-0+ ret =PTR_ERR (cs35l41->reset_gpio); + cs35l41->reset_gpio =NULL ; +if (ret == -EBUSY ) { +dev_info (cs35l41->dev,"Reset line busy, assuming shared reset\n" ); + }else { +if (ret != -EPROBE_DEFER ) +dev_err (cs35l41->dev,"Failed to get reset GPIO: %d\n" , ret); + goto err;We have
dev_err_probe()for a few releases already.Quoted 2 lines
(quoted diff) +2
-0+ } + }...
sound/pci/hda/cs35l41_hda.c line 441
Quoted 4 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+ ret =regmap_read (cs35l41->regmap,CS35L41_IRQ1_STATUS3 , &int_sts); +if (ret || (int_sts &CS35L41_OTP_BOOT_ERR )) { +dev_err (cs35l41->dev,"OTP Boot error\n" ); + ret = -EIO ;Why shadowing error code?
Why not usedev_err_probe()?Quoted 2 lines
(quoted diff) +2
-0+ goto err; + }...
Quoted 1 line
+EXPORT_SYMBOL_GPL(cs35l41_hda_probe);
Please, use the namespace variant and avoid polluting the global namespace with your symbols.
...
Quoted 1 line
+ *
cs35l41_hda.h-- CS35L41 ALSA HDA audio driverNo file names in the files.
...
sound/pci/hda/cs35l41_hda.h line 16
Quoted 4 lines
sound/pci/hda/cs35l41_hda.h new file +4
-0+#include <linux/regulator/consumer.h> +#include <linux/gpio/consumer.h> +#include <linux/device.h> +#include <sound/cs35l41.h> Please revisit this. You need to add here only the headers that you are a direct user of (or in some cases their top level ones, like
types.hforcompiler_attributes.h)....
Quoted 1 line
+#ifdef
CONFIG_ACPI
Quoted 7 lines
Drop this ugliness.
sound/pci/hda/cs35l41_hda_i2c.c line 46
Quoted 3 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +3
-0+static const struct acpi_device_id cs35l41_acpi_hda_match[] = { + {"CLSA0100" ,0 }, + {"CSC3551" ,0 },I believe these IDs are officially allocated by the Cirrus Logic, right?
CLSA010* is not a valid id for Cirrus Logic, but the Bios is already in production, so we must support it. CSC3551 is a valid id for Cirrus Logic.
Quoted 26 lines
Quoted 2 lines
+ { },
No comma for terminator line here and everywhere else where it's the case.
sound/pci/hda/cs35l41_hda_i2c.c line 55
Quoted 8 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +8
-0+}; +MODULE_DEVICE_TABLE (acpi, cs35l41_acpi_hda_match); +#endif + +static struct i2c_driver cs35l41_i2c_driver = { + .driver = { + .name ="cs35l41-hda" , + .acpi_match_table =ACPI_PTR (cs35l41_acpi_hda_match),
ACPI_PTR()as well.sound/pci/hda/cs35l41_hda_i2c.c line 61
Quoted 7 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +6
-0+ }, + .id_table = cs35l41_hda_i2c_id, + .probe = cs35l41_hda_i2c_probe, + .remove = cs35l41_hda_i2c_remove, +}; +No need to have a blank line here.
Quoted 8 lines
Quoted 1 line
+module_i2c_driver(cs35l41_i2c_driver);
I stopped here, so this code needs more work and can't be applied like this.
I believe that current Cirrus Logic drivers are written in the same (semi-) bad style and have to be fixed in the future. Put this to your TODO list, please.
Thanks for your comments. I will address the remaining ones in due time. Lucas
Re: [PATCH v6 07/10] hda: cs35l41: Add support for CS35L41 in HDA systems
Quoted 3 lines · Lucas tanure
Quoted 2 lines · Andy Shevchenko
On Fri, Dec 17, 2021 at 5:45 PM Lucas Tanure
<[email protected]> wrote:
...
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
+ * Device CLSA0100 doesn't have
_DSDso agpiod_getby the label reset won't work.So, you need to add mapping tables and switch to regular APIs, tell me, why it won't work.
I will submit a patch series to fix most of the issues you pointed out.
Thanks!
Quoted 5 lines
The part about how the driver access the ACPI table is going to be improved later if possible.
The laptop has already shipped and doesn't have a_DSDnode, so the driver needs to read the reset GPIO from a hard coded index inside a node that contains more than one cs35l41.
We have a lot of cases like this, hint: git grep -n -w devm_acpi_dev_add_driver_gpios.
...
Quoted 9 lines
Quoted 7 lines
sound/pci/hda/cs35l41_hda.c line 398
Quoted 5 lines
sound/pci/hda/cs35l41_hda.c new file +4
-0+int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, + struct regmap *regmap) + if (IS_ERR(regmap)) + return PTR_ERR(regmap);Why?
It is up to the I2C/SPI module to create the regmap and provide to the main module. If that fails the main module can't continue.
So, this is band-aiding the issue, which is in the caller. Caller shouldn't call this function without the regmap being ready-to-use.
...
Quoted 7 lines
Quoted 4 lines
sound/pci/hda/cs35l41_hda_i2c.c line 46
Quoted 2 lines
sound/pci/hda/cs35l41_hda_i2c.c new file +2
-0+ {"CLSA0100", 0 }, + {"CSC3551", 0 },I believe these IDs are officially allocated by the Cirrus Logic, right?
CLSA010* is not a valid id for Cirrus Logic, but the Bios is already in production, so we must support it.
CSC3551 is a valid id for Cirrus Logic.
Thank you for elaborating. Can we be sure that there won't be any abuse of ACPI specification in the future (meaning all IDs will follow the ACPI/PNP registries and be allocated by certain vendor)?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 07/10] hda: cs35l41: Add support for CS35L41 in HDA systems
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Lucas tanure
Quoted 2 lines · Andy Shevchenko
On Fri, Dec 17, 2021 at 5:45 PM Lucas Tanure
<[email protected]> wrote:
...
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+ * Device CLSA0100 doesn't have
_DSDso agpiod_getby the label reset won't work.So, you need to add mapping tables and switch to regular APIs, tell me, why it won't work.
Quoted 8 lines
Quoted 5 lines
The part about how the driver access the ACPI table is going to be improved later if possible.
The laptop has already shipped and doesn't have a_DSDnode, so the driver needs to read the reset GPIO from a hard coded index inside a node that contains more than one cs35l41.We have a lot of cases like this, hint:
git grep -n -w devm_acpi_dev_add_driver_gpios.
It's all described here: Documentation/firmware-guide/acpi/gpio-properties.rst
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 07/10] hda: cs35l41: Add support for CS35L41 in HDA systems
In reply to Andy ShevchenkoSorry for resurrecting old thread...
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Lucas Tanure
Add support for CS35L41 using a new separated driver that can be used in all upcoming designs
...
Quoted 8 lines
Quoted 1 line
+ /* No
devm_version as CLSA0100, inno_acpi_dsdcase, can't use devm version */Can you elaborate why devm can't be used?
Quoted 1 line
+
cs35l41->reset_gpio= fwnode_gpiod_get_index(&adev->fwnode, "reset",cs35l41->index,Please, do not dereference fwnode pointers. Also, why can't you use the device instead of fwnode?
We are doing "acpi_dev_put(adev);" a few lines above, so using adev in the call to fwnode_gpiod_get_index() is technically use-after-free, isn't it?
Also, why can't we do
cs35l41->reset_gpio = gpiod_get_index(acpi_dev, "reset", cs35l41->index, GPIOD_OUT_LOW);
since acpi_dev is device structure corresponding to adev and we are getting the rest of the properties from it?
I saw downthread that there was supposed to be a patch addressing several issues raised by Andy, was it ever submitted?
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH v6 07/10] hda: cs35l41: Add support for CS35L41 in HDA systems
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Andy Shevchenko
On Fri, Dec 17, 2021 at 5:45 PM Lucas Tanure
<[email protected]> wrote:
...
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
+
cs35l41->reset_gpio= fwnode_gpiod_get_index(&adev->fwnode, "reset",cs35l41->index,Please, do not dereference fwnode pointers. Also, why can't you use the device instead of fwnode?
We are doing "
acpi_dev_put(adev);" a few lines above, so using adev in the call tofwnode_gpiod_get_index()is technically use-after-free, isn't it?
Right, but I believe this is in response to the author and not to me.
Quoted 8 lines
Also, why can't we do
cs35l41->reset_gpio = gpiod_get_index(acpi_dev, "reset", cs35l41->index, GPIOD_OUT_LOW);since
acpi_devis device structure corresponding to adev and we are getting the rest of the properties from it?
I remembered that I have also stumbled over that, but IIRC the point here is that ACPI tables might be broken (since the multi-instance device is a gray area to begin with). So we need clarification from Cirrus to understand what the cases they want to cover with this twisted code to get a GPIO.
Quoted 2 lines
I saw downthread that there was supposed to be a patch addressing several issues raised by Andy, was it ever submitted?
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v6 8/10 ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodes
In reply to Lucas TanureThe ACPI device with CLSA0100 or CSC3551 is a sound card with multiple instances of CS35L41 connectec by I2C to the main CPU.
We add an ID to the i2c_multi_instantiate_ids list to enumerate all I2C slaves correctly.
--- drivers/acpi/scan.c | 3 +++ drivers/platform/x86/i2c-multi-instantiate.c | 11 +++++++++++ 2 files changed, 14 insertions(+)
drivers/acpi/scan.c +3 -0
@@ -1712,8 +1712,11 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)static const struct acpi_device_id i2c_multi_instantiate_ids[] = { {"BSG1160" , }, {"BSG2150" , }, + {"CSC3551" , }, {"INT33FE" , }, {"INT3515" , }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , }, {} };
drivers/platform/x86/i2c-multi-instantiate.c +11 -0
@@ -147,6 +147,14 @@ static const struct i2c_inst_data int3515_data[] = { {} }; +static const struct i2c_inst_data cs35l41_hda[] = { + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {} +}; +/* * Note new device-ids must also be added to i2c_multi_instantiate_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent().
@@ -154,7 +162,10 @@ static const struct i2c_inst_data int3515_data[] = {static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { {"BSG1160" , (unsigned long )bsg1160_data }, {"BSG2150" , (unsigned long )bsg2150_data }, + {"CSC3551" , (unsigned long )cs35l41_hda }, {"INT3515" , (unsigned long )int3515_data }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , (unsigned long )cs35l41_hda }, { } };MODULE_DEVICE_TABLE (acpi, i2c_multi_inst_acpi_ids);
Signature · 1 line
2.34.1
Rafael J. Wysocki
maintainerRe: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodes
Quoted 3 lines · Lucas Tanure
The ACPI device with CLSA0100 or CSC3551 is a sound card with multiple instances of CS35L41 connectec by I2C to
"connected" I suppose?
Quoted 6 lines
the main CPU.
We add an ID to the
i2c_multi_instantiate_idslist to enumerate all I2C slaves correctly.Signed-off-by Lucas Tanure <[email protected]>
This requires an ACK from Hans.
If you receive one, please feel free to add my ACK to it too.
Thanks!
Quoted 54 lines
--- drivers/acpi/scan.c | 3 +++ drivers/platform/x86/i2c-multi-instantiate.c | 11 +++++++++++ 2 files changed, 14 insertions(+)drivers/acpi/scan.c +3
-0@@ -1712,8 +1712,11 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)static const struct acpi_device_id i2c_multi_instantiate_ids[] = { {"BSG1160" , }, {"BSG2150" , }, + {"CSC3551" , }, {"INT33FE" , }, {"INT3515" , }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , }, {} };drivers/platform/x86/i2c-multi-instantiate.c +11
-1@@ -147,6 +147,14 @@ static const struct i2c_inst_data int3515_data[] = { {} }; +static const struct i2c_inst_data cs35l41_hda[] = { + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {} +}; +/* * Note new device-ids must also be added to i2c_multi_instantiate_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). @@ -154,7 +162,10 @@ static const struct i2c_inst_data int3515_data[] = {static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { {"BSG1160" , (unsigned long )bsg1160_data }, {"BSG2150" , (unsigned long )bsg2150_data }, + {"CSC3551" , (unsigned long )cs35l41_hda }, {"INT3515" , (unsigned long )int3515_data }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , (unsigned long )cs35l41_hda }, { } };MODULE_DEVICE_TABLE (acpi, i2c_multi_inst_acpi_ids); --2.34.1
Re: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodes
Hi,
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Lucas Tanure
The ACPI device with CLSA0100 or CSC3551 is a sound card with multiple instances of CS35L41 connectec by I2C to
"connected" I suppose?
Quoted 2 lines
the main CPU.
Quoted 8 lines
Quoted 4 lines
We add an ID to the
i2c_multi_instantiate_idslist to enumerate all I2C slaves correctly.Signed-off-by Lucas Tanure <[email protected]>This requires an ACK from Hans.
If you receive one, please feel free to add my ACK to it too.
One problem which I see here is that this change conflicts with this series:
https://lore.kernel.org/all/[email protected]/
I have reviewing that series on my todo list.
One interesting question for you (Rafael) about that series is that i2c-multi-instantiate.c, which after the series also handles spi devices,is being moved to drivers/acpi .
This is fine with me, but I wonder if it would not be better to keep it under drivers/platform/x86 ? Since the new SPI use-cases are also all on x86 laptops AFAICT.
But back to this series, as said the 2 series conflict, since both are being submitted by @opensource.cirrus.com people, it would be good if the Cirrus folks can decide in which order these series should be merged.
It might be best to just move this one patch to the other series? Thus removing the conflict between the 2 series.
Regards,
Hans
Quoted 55 lines
Quoted 54 lines
--- drivers/acpi/scan.c | 3 +++ drivers/platform/x86/i2c-multi-instantiate.c | 11 +++++++++++ 2 files changed, 14 insertions(+)drivers/acpi/scan.c +3
-0@@ -1712,8 +1712,11 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)static const struct acpi_device_id i2c_multi_instantiate_ids[] = { {"BSG1160" , }, {"BSG2150" , }, + {"CSC3551" , }, {"INT33FE" , }, {"INT3515" , }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , }, {} };drivers/platform/x86/i2c-multi-instantiate.c +11
-1@@ -147,6 +147,14 @@ static const struct i2c_inst_data int3515_data[] = { {} }; +static const struct i2c_inst_data cs35l41_hda[] = { + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {} +}; +/* * Note new device-ids must also be added to i2c_multi_instantiate_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). @@ -154,7 +162,10 @@ static const struct i2c_inst_data int3515_data[] = {static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { {"BSG1160" , (unsigned long )bsg1160_data }, {"BSG2150" , (unsigned long )bsg2150_data }, + {"CSC3551" , (unsigned long )cs35l41_hda }, {"INT3515" , (unsigned long )int3515_data }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , (unsigned long )cs35l41_hda }, { } };MODULE_DEVICE_TABLE (acpi, i2c_multi_inst_acpi_ids); --2.34.1
Mark Brown
maintainerRe: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodes
Quoted 3 lines · Hans de Goede
This is fine with me, but I wonder if it would not be better to keep it under
drivers/platform/x86? Since the new SPI use-cases are also all on x86 laptops AFAICT.
Someone's going to end up using it for one of the Arm devices with ACPI, *especially* if it's put in drivers/platform/x86.
RE: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodes
In reply to Hans de GoedeHi,
Quoted 60 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: 17 December 2021 18:27
To: Rafael J. Wysocki <[email protected]>; Lucas Tanure <[email protected]>; Stefan Binding <[email protected]>
Cc: Len Brown <[email protected]>; Mark Gross <[email protected]>; Liam Girdwood <[email protected]>; Jaroslav Kysela <[email protected]>; Mark Brown <[email protected]>; Takashi Iwai <[email protected]>; moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM... <[email protected]>; ACPI Devel Maling List <linux- [email protected]>; [email protected]; Platform Driver <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>
Subject: Re: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodesHi,
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Lucas Tanure
The ACPI device with CLSA0100 or CSC3551 is a sound card with multiple instances of CS35L41 connectec by I2C to
"connected" I suppose?
Quoted 2 lines
the main CPU.
Quoted 8 lines
Quoted 4 lines
We add an ID to the
i2c_multi_instantiate_idslist to enumerate all I2C slaves correctly.Signed-off-by Lucas Tanure <[email protected]>This requires an ACK from Hans.
If you receive one, please feel free to add my ACK to it too.
One problem which I see here is that this change conflicts with this series:
https://lore.kernel.org/all/20211210154050.3713-1-
[email protected]/I have reviewing that series on my todo list.
One interesting question for you (Rafael) about that series is that
i2c-multi-instantiate.c, which after the series also handles spi devices,is being moved todrivers/acpi.This is fine with me, but I wonder if it would not be better to keep it under
drivers/platform/x86? Since the new SPI use-cases are also all on x86 laptops AFAICT.But back to this series, as said the 2 series conflict, since both are being submitted by @opensource.cirrus.com people, it would be good if the Cirrus folks can decide in which order these series should be merged.
Quoted 7 lines
It might be best to just move this one patch to the other series? Thus removing the conflict between the 2 series.
Regards,
Hans
We don’t really have a preference which order these two chains should be merged in. We would rebase the other chain if one got merged first.
If pushed for an answer, maybe:
https://lore.kernel.org/all/[email protected]/
should be merged first?
Thanks,
Stefan
Quoted 61 lines
Quoted 7 lines
Quoted 7 lines
--- drivers/acpi/scan.c | 3 +++ drivers/platform/x86/i2c-multi-instantiate.c | 11 +++++++++++ 2 files changed, 14 insertions(+)Quoted 5 lines
drivers/acpi/scan.c static bool
Quoted 5 lines
drivers/acpi/scan.c +0
-0@@ -1712,8 +1712,11 @@ static bool
acpi_device_enumeration_by_parent(struct acpi_device *device)Quoted 11 lines
Quoted 11 lines
drivers/acpi/scan.c +3
-0static const struct acpi_device_id i2c_multi_instantiate_ids[] = { {"BSG1160" , }, {"BSG2150" , }, + {"CSC3551" , }, {"INT33FE" , }, {"INT3515" , }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , }, {} };Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/platform/x86/i2c-multi-instantiate.cQuoted 4 lines
drivers/platform/x86/i2c-multi-instantiate.c static const struct i2c_inst_data int3515_data[] =
Quoted 4 lines
index
4956a1df5b90..a889789b966c100644drivers/platform/x86/i2c-multi-instantiate.c +0
-0@@ -147,6 +147,14 @@ static const struct i2c_inst_data int3515_data[] ={
Quoted 15 lines
drivers/platform/x86/i2c-multi-instantiate.c static const struct i2c_inst_data int3515_data[] =
Quoted 15 lines
drivers/platform/x86/i2c-multi-instantiate.c +8
-0{} }; +static const struct i2c_inst_data cs35l41_hda[] = { + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {} +}; +/* * Note new device-ids must also be added to i2c_multi_instantiate_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). @@ -154,7 +162,10 @@ static const struct i2c_inst_data int3515_data[] ={
Quoted 14 lines
Quoted 13 lines
drivers/platform/x86/i2c-multi-instantiate.c +3
-1static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { {"BSG1160" , (unsigned long )bsg1160_data }, {"BSG2150" , (unsigned long )bsg2150_data }, + {"CSC3551" , (unsigned long )cs35l41_hda }, {"INT3515" , (unsigned long )int3515_data }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , (unsigned long )cs35l41_hda }, { } };MODULE_DEVICE_TABLE (acpi, i2c_multi_inst_acpi_ids); --2.34.1
Re: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodes
Quoted 77 lines · Stefan Binding
Hi,
Quoted 60 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: 17 December 2021 18:27
To: Rafael J. Wysocki <[email protected]>; Lucas Tanure <[email protected]>; Stefan Binding <[email protected]>
Cc: Len Brown <[email protected]>; Mark Gross <[email protected]>; Liam Girdwood <[email protected]>; Jaroslav Kysela <[email protected]>; Mark Brown <[email protected]>; Takashi Iwai <[email protected]>; moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM... <[email protected]>; ACPI Devel Maling List <linux- [email protected]>; [email protected]; Platform Driver <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>
Subject: Re: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodesHi,
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Lucas Tanure
The ACPI device with CLSA0100 or CSC3551 is a sound card with multiple instances of CS35L41 connectec by I2C to
"connected" I suppose?
Quoted 2 lines
the main CPU.
Quoted 8 lines
Quoted 4 lines
We add an ID to the
i2c_multi_instantiate_idslist to enumerate all I2C slaves correctly.Signed-off-by Lucas Tanure <[email protected]>This requires an ACK from Hans.
If you receive one, please feel free to add my ACK to it too.
One problem which I see here is that this change conflicts with this series:
https://lore.kernel.org/all/20211210154050.3713-1-
[email protected]/I have reviewing that series on my todo list.
One interesting question for you (Rafael) about that series is that
i2c-multi-instantiate.c, which after the series also handles spi devices,is being moved todrivers/acpi.This is fine with me, but I wonder if it would not be better to keep it under
drivers/platform/x86? Since the new SPI use-cases are also all on x86 laptops AFAICT.But back to this series, as said the 2 series conflict, since both are being submitted by @opensource.cirrus.com people, it would be good if the Cirrus folks can decide in which order these series should be merged.
Quoted 7 lines
It might be best to just move this one patch to the other series? Thus removing the conflict between the 2 series.
Regards,
Hans
We don’t really have a preference which order these two chains should be merged in. We would rebase the other chain if one got merged first.
If pushed for an answer, maybe:
https://lore.kernel.org/all/[email protected]/
should be merged first?
Quoted 66 lines
Thanks,
StefanQuoted 61 lines
Quoted 7 lines
Quoted 7 lines
--- drivers/acpi/scan.c | 3 +++ drivers/platform/x86/i2c-multi-instantiate.c | 11 +++++++++++ 2 files changed, 14 insertions(+)Quoted 5 lines
drivers/acpi/scan.c static bool
Quoted 5 lines
drivers/acpi/scan.c +0
-0@@ -1712,8 +1712,11 @@ static bool
acpi_device_enumeration_by_parent(struct acpi_device *device)Quoted 11 lines
Quoted 11 lines
drivers/acpi/scan.c +3
-0static const struct acpi_device_id i2c_multi_instantiate_ids[] = { {"BSG1160" , }, {"BSG2150" , }, + {"CSC3551" , }, {"INT33FE" , }, {"INT3515" , }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , }, {} };Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/platform/x86/i2c-multi-instantiate.cQuoted 4 lines
drivers/platform/x86/i2c-multi-instantiate.c static const struct i2c_inst_data int3515_data[] =
Quoted 4 lines
index
4956a1df5b90..a889789b966c100644drivers/platform/x86/i2c-multi-instantiate.c +0
-0@@ -147,6 +147,14 @@ static const struct i2c_inst_data int3515_data[] ={
Quoted 15 lines
drivers/platform/x86/i2c-multi-instantiate.c static const struct i2c_inst_data int3515_data[] =
Quoted 15 lines
drivers/platform/x86/i2c-multi-instantiate.c +8
-0{} }; +static const struct i2c_inst_data cs35l41_hda[] = { + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {"cs35l41-hda" ,IRQ_RESOURCE_GPIO ,0 }, + {} +}; +/* * Note new device-ids must also be added to i2c_multi_instantiate_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). @@ -154,7 +162,10 @@ static const struct i2c_inst_data int3515_data[] ={
Quoted 14 lines
Quoted 13 lines
drivers/platform/x86/i2c-multi-instantiate.c +3
-1static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { {"BSG1160" , (unsigned long )bsg1160_data }, {"BSG2150" , (unsigned long )bsg2150_data }, + {"CSC3551" , (unsigned long )cs35l41_hda }, {"INT3515" , (unsigned long )int3515_data }, +/* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100" , (unsigned long )cs35l41_hda }, { } };MODULE_DEVICE_TABLE (acpi, i2c_multi_inst_acpi_ids); --2.34.1
As the ic2-multi-instantiate patch chain is still being worked out, we would like to submit a new chain for CLSA0100 id and a few fixes for the HDA cs35l41 driver. And to avoid conflicts the ic2-multi-instantiate patch chain will wait for this new patch chain to be merged.
Thanks,
Lucas Tanure
Re: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodes
Hello,
Will this also include adding support for ID's matching CLSA0101?
Thanks,
-Cameron
Quoted 5 lines · Lucas tanure
As the ic2-multi-instantiate patch chain is still being worked out, we would like to submit a new chain for CLSA0100 id and a few fixes for the HDA cs35l41 driver. And to avoid conflicts the ic2-multi-instantiate patch chain will wait for this new patch chain to be merged.
Thanks,
Lucas Tanure
Re: [PATCH v6 08/10] ACPI / scan: Create platform device for CLSA0100 and CSC3551 ACPI nodes
Quoted 16 lines · Cameron Berkenpas
Hello,
Will this also include adding support for ID's matching CLSA0101?
Thanks,
-Cameron
Quoted 5 lines · Lucas tanure
As the ic2-multi-instantiate patch chain is still being worked out, we would like to submit a new chain for CLSA0100 id and a few fixes for the HDA cs35l41 driver. And to avoid conflicts the ic2-multi-instantiate patch chain will wait for this new patch chain to be merged.
Thanks,
Lucas Tanure
Hi, We have the plan to support CLSA0101 in the near future, but not for this current patch series. Lucas
PATCH v6 9/10 ALSA: hda/realtek: Add support for Legion 7 16ACHg6 laptop
In reply to Lucas TanureAdd Support for CS35L41 using the component binding method
--- sound/pci/hda/patch_realtek.c | 107 ++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+)
sound/pci/hda/patch_realtek.c +107 -0
@@ -25,6 +25,7 @@#include "hda_auto_parser.h" #include "hda_jack.h" #include "hda_generic.h" +#include "hda_component.h" /* keep halting ALC5505 DSP, for power saving */ #define HALT_REALTEK_ALC5505
@@ -126,6 +127,10 @@ struct alc_spec {unsigned int coef0;struct input_dev *kb_dev;u8 alc_mute_keycode_map[1 ]; + +/* component binding */ +struct component_match *match; +struct hda_component comps[HDA_MAX_COMPONENTS ]; };/*
@@ -6497,6 +6502,102 @@ static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec, } } +static int comp_match_dev_name (struct device *dev,void *data) +{ +return strcmp (dev_name (dev), data) ==0 ; +} + +static int find_comp_by_dev_name (struct alc_spec *spec,const char *name) +{ +int i; + +for (i =0 ; i <HDA_MAX_COMPONENTS ; i++) { +if (strcmp (spec->comps[i].name, name) ==0 ) +return i; + } + +return -ENODEV ; +} + +static int comp_bind (struct device *dev) +{ +struct hda_codec *cdc =dev_to_hda_codec (dev); +struct alc_spec *spec = cdc->spec; + +return component_bind_all (dev, spec->comps); +} + +static void comp_unbind (struct device *dev) +{ +struct hda_codec *cdc =dev_to_hda_codec (dev); +struct alc_spec *spec = cdc->spec; + +component_unbind_all (dev, spec->comps); +} + +static const struct component_master_ops comp_master_ops = { + .bind = comp_bind, + .unbind = comp_unbind, +}; + +static void comp_generic_playback_hook (struct hda_pcm_stream *hinfo,struct hda_codec *cdc, +struct snd_pcm_substream *sub,int action) +{ +struct alc_spec *spec = cdc->spec; +int i; + +for (i =0 ; i <HDA_MAX_COMPONENTS ; i++) { +if (spec->comps[i].dev) + spec->comps[i].playback_hook (spec->comps[i].dev, action); + } +} + +static void alc287_legion_16achg6_playback_hook (struct hda_pcm_stream *hinfo,struct hda_codec *cdc, +struct snd_pcm_substream *sub,int action) +{ +struct alc_spec *spec = cdc->spec; +unsigned int rx_slot; +int i; + +switch (action) { +case HDA_GEN_PCM_ACT_PREPARE : + rx_slot =0 ; + i =find_comp_by_dev_name (spec,"i2c-CLSA0100:00-cs35l41-hda.0" ); +if (i >=0 ) + spec->comps[i].set_channel_map (spec->comps[i].dev,0 ,NULL ,1 , &rx_slot); + + rx_slot =1 ; + i =find_comp_by_dev_name (spec,"i2c-CLSA0100:00-cs35l41-hda.1" ); +if (i >=0 ) + spec->comps[i].set_channel_map (spec->comps[i].dev,0 ,NULL ,1 , &rx_slot); +break ; + } + +comp_generic_playback_hook (hinfo, cdc, sub, action); +} + +static void alc287_fixup_legion_16achg6_speakers (struct hda_codec *cdc,const struct hda_fixup *fix, +int action) +{ +struct device *dev =hda_codec_dev (cdc); +struct alc_spec *spec = cdc->spec; +int ret; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : +component_match_add (dev, &spec->match, comp_match_dev_name, +"i2c-CLSA0100:00-cs35l41-hda.0" ); +component_match_add (dev, &spec->match, comp_match_dev_name, +"i2c-CLSA0100:00-cs35l41-hda.1" ); + ret =component_master_add_with_match (dev, &comp_master_ops, spec->match); +if (ret) +codec_err (cdc,"Fail to register component aggregator %d\n" , ret); +else + spec->gen.pcm_playback_hook = alc287_legion_16achg6_playback_hook; +break ; + } +} +/* for alc295_fixup_hp_top_speakers */ #include "hp_x360_helper.c"
@@ -6766,6 +6867,7 @@ enum {ALC256_FIXUP_SET_COEF_DEFAULTS ,ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE ,ALC233_FIXUP_NO_AUDIO_JACK , + ALC287_FIXUP_LEGION_16ACHG6, }; static const struct hda_fixup alc269_fixups[] = {
@@ -8490,6 +8592,10 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc233_fixup_no_audio_jack, }, + [ALC287_FIXUP_LEGION_16ACHG6] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc287_fixup_legion_16achg6_speakers, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -8901,6 +9007,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3827 ,"Ideapad S740" ,ALC285_FIXUP_IDEAPAD_S740_COEF ),SND_PCI_QUIRK (0x17aa ,0x3843 ,"Yoga 9i" ,ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP ),SND_PCI_QUIRK (0x17aa ,0x3813 ,"Legion 7i 15IMHG05" ,ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS ), +SND_PCI_QUIRK (0x17aa ,0x3847 ,"Legion 7 16ACHG6" ,ALC287_FIXUP_LEGION_16ACHG6 ),SND_PCI_QUIRK (0x17aa ,0x3852 ,"Lenovo Yoga 7 14ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3853 ,"Lenovo Yoga 7 15ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ), SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
Signature · 1 line
2.34.1
PATCH v6 10/10 ALSA: hda/realtek: Add CS35L41 support for Thinkpad laptops
In reply to Lucas TanureFrom: Stefan Binding <[email protected]>
Add support for two CS35L41 using I2C bus and the component binding method
--- sound/pci/hda/patch_realtek.c | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
sound/pci/hda/patch_realtek.c +39 -0
@@ -6552,6 +6552,37 @@ static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_ } } +static void cs35l41_generic_fixup (struct hda_codec *cdc,int action,const char *bus, +const char *hid,int count) +{ +struct device *dev =hda_codec_dev (cdc); +struct alc_spec *spec = cdc->spec; +char *name; +int ret, i; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : +for (i =0 ; i < count; i++) { + name =devm_kasprintf (dev,GFP_KERNEL , +"%s-%s:00-cs35l41-hda.%d" , bus, hid, i); +if (!name) +return ; +component_match_add (dev, &spec->match, comp_match_dev_name, name); + } + ret =component_master_add_with_match (dev, &comp_master_ops, spec->match); +if (ret) +codec_err (cdc,"Fail to register component aggregator %d\n" , ret); +else + spec->gen.pcm_playback_hook = comp_generic_playback_hook; +break ; + } +} + +static void cs35l41_fixup_i2c_two (struct hda_codec *cdc,const struct hda_fixup *fix,int action) +{ +cs35l41_generic_fixup (cdc, action,"i2c" ,"CSC3551" ,2 ); +} +static void alc287_legion_16achg6_playback_hook (struct hda_pcm_stream *hinfo,struct hda_codec *cdc,struct snd_pcm_substream *sub,int action) {
@@ -6868,6 +6899,7 @@ enum {ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE ,ALC233_FIXUP_NO_AUDIO_JACK ,ALC287_FIXUP_LEGION_16ACHG6 , + ALC287_FIXUP_CS35L41_I2C_2, }; static const struct hda_fixup alc269_fixups[] = {
@@ -8596,6 +8628,10 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc287_fixup_legion_16achg6_speakers, }, + [ALC287_FIXUP_CS35L41_I2C_2] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35l41_fixup_i2c_two, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -9008,6 +9044,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3843 ,"Yoga 9i" ,ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP ),SND_PCI_QUIRK (0x17aa ,0x3813 ,"Legion 7i 15IMHG05" ,ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3847 ,"Legion 7 16ACHG6" ,ALC287_FIXUP_LEGION_16ACHG6 ), +SND_PCI_QUIRK (0x17aa ,0x22F1 ,"Thinkpad" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x17aa ,0x22F2 ,"Thinkpad" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x17aa ,0x22F3 ,"Thinkpad" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x17aa ,0x3852 ,"Lenovo Yoga 7 14ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3853 ,"Lenovo Yoga 7 15ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ), SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
Signature · 1 line
2.34.1
Mark Brown
maintainerRe: (subset) [PATCH v6 00/10] Add support for CS35L41 in HDA systems
In reply to Lucas TanureQuoted 8 lines · Lucas Tanure
Add support for laptops that have CS35L41 connected to an HDA codec by I2S and direct I2C connection to the CPU.
Laptops that use CS35L41 and are SPI will be added in the future, after the support for it is resolved at i2c-multi-instantiate driver. i2c-multi-instantiate thread: https://lkml.org/lkml/2021/12/10/557
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/10] ASoC: cs35l41: Convert tables to shared source code
commit: a87d42227cf5614fe0040ddd1fe642c54298b42c
[02/10] ASoC: cs35l41: Move cs35l41_otp_unpack to shared code
commit: fe120d4cb6f6cd03007239e7c578b8703fe6d336
[03/10] ASoC: cs35l41: Move power initializations to reg_sequence
commit: 062ce0593315e22aac527389dd6dd4328c49f0fb
[04/10] ASoC: cs35l41: Create shared function for errata patches
commit: 8b2278604b6de27329ec7ed82ca696c4751111b6
[05/10] ASoC: cs35l41: Create shared function for setting channels
commit: 3bc3e3da657f17c14df8ae8fab58183407bd7521
[06/10] ASoC: cs35l41: Create shared function for boost configuration
commit: e8e4fcc047c6e0c5411faeb8cc29aed2e5036a00All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Re: (subset) [PATCH v6 00/10] Add support for CS35L41 in HDA systems
Quoted 18 lines · Mark Brown
Quoted 8 lines · Lucas Tanure
Add support for laptops that have CS35L41 connected to an HDA codec by I2S and direct I2C connection to the CPU.
Laptops that use CS35L41 and are SPI will be added in the future, after the support for it is resolved at i2c-multi-instantiate driver. i2c-multi-instantiate thread: https://lkml.org/lkml/2021/12/10/557
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/10] ASoC: cs35l41: Convert tables to shared source code
Quoted 11 lines
commit: a87d42227cf5614fe0040ddd1fe642c54298b42c
[02/10] ASoC: cs35l41: Move cs35l41_otp_unpack to shared code
commit: fe120d4cb6f6cd03007239e7c578b8703fe6d336
[03/10] ASoC: cs35l41: Move power initializations to reg_sequence
commit: 062ce0593315e22aac527389dd6dd4328c49f0fb
[04/10] ASoC: cs35l41: Create shared function for errata patches
commit: 8b2278604b6de27329ec7ed82ca696c4751111b6
[05/10] ASoC: cs35l41: Create shared function for setting channels
commit: 3bc3e3da657f17c14df8ae8fab58183407bd7521
[06/10] ASoC: cs35l41: Create shared function for boost configuration
commit: e8e4fcc047c6e0c5411faeb8cc29aed2e5036a00Mark, could you send a PR including those for 5.17?
The rest HD-audio part of the patch set depends on this new ASoC codec stuff (at least Kconfig), so I can't apply the patches before merging those. The ACPI patch might be still not applicable through my tree, but it can be taken independently.
thanks,
Takashi
Re: (subset) [PATCH v6 00/10] Add support for CS35L41 in HDA systems
Quoted 33 lines · Takashi Iwai
Quoted 18 lines · Mark Brown
Quoted 8 lines · Lucas Tanure
Add support for laptops that have CS35L41 connected to an HDA codec by I2S and direct I2C connection to the CPU.
Laptops that use CS35L41 and are SPI will be added in the future, after the support for it is resolved at i2c-multi-instantiate driver. i2c-multi-instantiate thread: https://lkml.org/lkml/2021/12/10/557
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/10] ASoC: cs35l41: Convert tables to shared source code
Quoted 11 lines
commit: a87d42227cf5614fe0040ddd1fe642c54298b42c [02/10] ASoC: cs35l41: Move cs35l41_otp_unpack to shared code commit: fe120d4cb6f6cd03007239e7c578b8703fe6d336 [03/10] ASoC: cs35l41: Move power initializations to reg_sequence commit: 062ce0593315e22aac527389dd6dd4328c49f0fb [04/10] ASoC: cs35l41: Create shared function for errata patches commit: 8b2278604b6de27329ec7ed82ca696c4751111b6 [05/10] ASoC: cs35l41: Create shared function for setting channels commit: 3bc3e3da657f17c14df8ae8fab58183407bd7521 [06/10] ASoC: cs35l41: Create shared function for boost configuration commit: e8e4fcc047c6e0c5411faeb8cc29aed2e5036a00
Quoted 5 lines
Mark, could you send a PR including those for 5.17?
The rest HD-audio part of the patch set depends on this new ASoC codec stuff (at leastKconfig), so I can't apply the patches before merging those. The ACPI patch might be still not applicable through my tree, but it can be taken independently.
Now I merged Mark's asoc tree, and applied the patches 7, 9 and 10.
ALSA: hda: cs35l41: Add support for CS35L41 in HDA systems
ALSA: hda/realtek: Add support for Legion 7 16ACHg6 laptop
ALSA: hda/realtek: Add CS35L41 support for Thinkpad laptops
The patches 9 and 10 have been slightly modified to adjust the quirk entry positions.
The only missing patch is the ACPI patch. I'm open in which way to take; it's fine to be applied via other trees.
Let me know your favorite.
thanks,
Takashi