This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: How to add PCM186x driver to linux?

Part Number: AM5728


Tool/software: Linux

Hi,

we are making custom board with Linux based on am57xx-evm sdk (linux 4.4.19). Now we are tring to add PCM186x driver to linux .

I found 4 files on TI git:
- pcm186x.c;
- pcm186x.h;
- pcm186x-i2c.c;
- pcm186x-spi.c.

I have copied them to linux-folder/sound/soc/codecs

I have added next lines to linux-folder/sound/soc/codecs/makefile:
snd-soc-pcm1862x-objs := pcm186x.o
snd-soc-pcm1862x-i2c-objs := pcm186x-i2c.o
snd-soc-pcm1862x-spi-objs := pcm186x-spi.o
...
obj-$(CONFIG_SND_SOC_PCM186x) += snd-soc-pcm186x.o
obj-$(CONFIG_SND_SOC_PCM186x_I2C) += snd-soc-pcm186x-i2c.o
obj-$(CONFIG_SND_SOC_PCM186x_SPI) += snd-soc-pcm186x-spi.o

And of course I have added this lines to linux-folder/arch/arm/configs/tisdk_am57xx-evm_defconfig file:
CONFIG_SND_SOC_PCM186x=y
CONFIG_SND_SOC_PCM186x_I2C=y
CONFIG_SND_SOC_PCM186x_SPI=y

then I type 2 commands in terminal:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- tisdk_am57xx-evm_defconfig

the last one makes .config file, but there are no my new lines about PCM186x configs.
Shell I add some else lines in other files?

Br,
Alexander.

  • Hi Alexander,

    You need to also modify the corresponding Kconfig files.

    Best Regards,
    Yordan
  • Hi,

    I have modified kconfig files, PCM186x config lines appeared in xconfig, but there is no .o files, and no error messages.

    So I tried to build out of tree module.

    I made Makefile:

    # Makefile – makefile of our first driver
     
    # if KERNELRELEASE is defined, we've been invoked from the
    # kernel build system and can use its language.
    ifneq (${KERNELRELEASE},)
        obj-m := pcm186x-i2c.o
    # Otherwise we were called directly from the command line.
    # Invoke the kernel build system.
    else
        KERNEL_SOURCE := /opt/ti-processor-sdk-linux-am57xx-evm-03.01.00.06/board-support/linux-4.4.19
        PWD := $(shell pwd)
    default:
      ${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules
     
    clean:
      ${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean
    endif

    and build it with make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- command.

    It made .o and .ko file, but also it shows this warnings:
    WARNING: "pcm186x_pm_ops" [/home/user1/Documents/pcm186x/pcm186x-i2c.ko] undefined!
    WARNING: "pcm186x_probe" [/home/user1/Documents/pcm186x/pcm186x-i2c.ko] undefined!
    WARNING: "pcm186x_regmap" [/home/user1/Documents/pcm186x/pcm186x-i2c.ko] undefined!
    WARNING: "pcm186x_remove" [/home/user1/Documents/pcm186x/pcm186x-i2c.ko] undefined!

    this variables are defined in pcm186x.c

    So can you tell me please, how should I correctly build this driver?

    Br,
    Alexander

  • Hello, you need pcm186x.o and pcm186x-i2c.o on obj-m line, here is my Makefile for building this driver out of tree

    export ARCH:=arm
    export CROSS_COMPILE:=arm-linux-gnueabihf-
    
    ifneq ($(KERNELRELEASE),)
    obj-m := pcm186x-i2c.o pcm186x.o pcm186x-spi.o
    else
    KDIR := /home/user/linux-y335x
    all:
            $(MAKE) -C $(KDIR) M=$$PWD
    clean:
            $(MAKE) -C $(KDIR) M=$$PWD clean
    endif