Search code examples
linuxaudiokernelcodecalsa

Set up CS4270 audio codec chip as ALSA device on Raspberry CM4


I’ve got a Raspberry CM4 connected with a Cirrus Logic CS4270 chip that should provide audio I/O ( CS4270 Datasheet: https://media.digikey.com/pdf/data%20sheets/cirrus%20logic%20pdfs/cs4270.pdf ). The CS4270 is set in Software Mode (I2C protocol), with the following pinout:

CS4270 CM4
RST GPIO22
SDIN GPIO21
SDOUT GPIO20
LRCK GPIO19
SCLK GPIO18
M0 GPIO3 (SCL1)
M1 GPIO2 (SDA1)
I2S/*LJ GND
MDIV1 3V3
MDIV2 GND
MCLK (Input from external 22.5792MHZ oscillator)

I can find the CS4270 codec implementation inside the linux kernel code on “/sound/soc/codecs/cs4270.c” ( https://github.com/torvalds/linux/blob/master/sound/soc/codecs/cs4270.c ). However, I’m not capable to set it up to work (e.g. I’ve built a linux kernel to get all the modules, but “snd-soc-cs4270.ko” is not present in the built modules.)

My question is:

How can make the CS4270 work with ALSA as an audio device?

Sorry for the vague question, but I really don’t know how to proceed.

Best, FD


Solution

  • Ok, I found the solution myself:

    CS4270 chip codec is not enabled by default. To enable it, inside the main directory of raspberry linux kernel (in my case rpi-5.15.y), do:

    • "make menuconfig" to build the kernel configuration menu
    • Inside menuconfig menu navigate to ”Device Drivers” -> “Sound card support” -> ”Advanced Linux Sound Architecture” -> ”ALSA for SoC audio support” -> “Codec Drivers”
    • Allow Cirrus cs4270 codec to be built as a module (M)
    • Save and exit
    • Make as your needs (select all other configuration options as defaults if asked)

    The .ko file is then successfully compiled.