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/OMAP-L138: Lodable kernel module for spi-nor flash

Part Number: OMAP-L138


Tool/software: Linux

Hi!

I'm developing the linux kernel and root filesystem for a board with OMAP-L138.

The Linux kernel version is 4.4.25, but I'm still using a board support file "arch/arm/mach-davinci/board-<myboard>.c" for setting up the necessary drivers and configuration details for the peripheral devices.
This works very good for all peripheral devices with can be reached during start up.

Now I've to support a spi-nor flash ("n25q256a" from Micron) wich isn't reachable during start up.
To get access to the flash a register has to be set for switching the spi bus from a FPGA to the OMAP-L138 processor; but this can only be done only after the start of the linux kernel!

I've to build a "loadable" kernel module (*.ko) so that is loadable form userspace with "insmod".
The necessary driver is "drivers/mtd/spi-nor/spi-nor.c", but I have to set some configuration details (for example number of spi bus, spi clock frequency, flash partitions, ...)

How can I do this without having "device tree support"?
Is there an example that shows how to do it?

For any hint I would be very grateful!

Best regards,
Jan-Marc.

  • Hi Jan-Marc,

    In Processor SDK Linux, the arch/arm/mach-davinci/board-da850-evm.c contains a SPI NOR entries. Can you have a look at it and try to reuse it for your evm?

    Best Regards,
    Yordan
  • Hi Yordan!

    Thank you for your answer.

    Is this example really usable for my board?

    In boardfile "arch/arm/mach-davinci/board-da850-evm.c" they are calling "spi_register_board_info()" in function "da850_evm_init()".
    But this wouldn't work for me, because at this time the spi flash isn't reachable!

    I think I have to build the driver as a lodable kernel module.
    After starting this kernel module ("insmod...") I have to pass the parameters to the driver which are otherwise contained in the structures "flash_platform_data", "davinci_spi_config" and "spi_board_info".
    Is this right?

    Best regards
    Jan-Marc.
  • Hi Jan-Marc,

    Is this example really usable for my board?

    Yes, da850 references a family of devices which contains the OMAP-L138, for example the dts file for omapl138-lcdk is called da850-lcdk.dts, so yes you should be referencing this file.

    I think I have to build the driver as a lodable kernel module.
    After starting this kernel module ("insmod...") I have to pass the parameters to the driver which are otherwise contained in the structures "flash_platform_data", "davinci_spi_config" and "spi_board_info".
    Is this right?

    Yes, you are correct.

    Best Regards,
    Yordan
  • Hi Yordan!

    Thank you for your reply.

    As I said I'm not using a dts file for my board.

    And how do I pass the parameters to the loadable kernel module which are otherwise contained in the structures "flash_platform_data", "davinci_spi_config" and "spi_board_info"?

    I'm not really smart from the example!

    Best regards,
    Jan-Marc.

  • Hi Jan-Marc,

    When you compile the kernel the info from the board file should be saved in the kernel image. Just configure the module as loadable kernel module and it should read the needed information from the baord file, when you insmod it.

    Best Regards,
    Yordan