Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
Arm Community blogs
Arm Community blogs
Embedded and Microcontrollers blog How to add SPI device on AM335X
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded and Microcontrollers blog

  • Internet of Things (IoT) blog

  • Laptops and Desktops blog

  • Mobile, Graphics, and Gaming blog

  • Operating Systems blog

  • Servers and Cloud Computing blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tags
  • linux kernel
  • development board
  • ti am335x
  • spi
  • arm cortex a8
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

How to add SPI device on AM335X

jack
jack
October 12, 2016

As we know, we frequently utilize SPI devices on the embedded boards, however, many development boards have no SPI devices, as a result, there is no registration information of SPI devices  in it's kernel, you may have no ideas for adding SPI devices if you are not familiar with the kernel.

Don't worry, here, we take MYD-AM335X development board as an example to indicate the way to add SPI flash on the board.

1. First, we need spidev, and we need to add it to the kernel, running it under the root catalog of Linux kernel original code.

1

make ARCH=arm menuconfig

Choose it in sequence:

11.png

Attention: above should all be choosed.

2. Add pin configuration of SPI on arch/arm/mach-omap2/board-am335xevm.c file.

1

2

3

4

5

6

7

8

/* Module pin for SPI, JBO */

static struct pinmux_config spi_pin_mux[] = {

    {"mcasp0_aclkx.spi1_sclk", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL | AM33XX_INPUT_EN },

    {"mcasp0_fsx.spi1_d0", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL | AM33XX_PULL_UP | AM33XX_INPUT_EN},

    {"mcasp0_axr0.spi1_d1", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL | AM33XX_INPUT_EN},

    {"mcasp0_ahclkr.spi1_cs0", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL | AM33XX_PULL_UP | AM33XX_INPUT_EN},

    {NULL, 0},

};

3. Add SPI devices and registration function

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

19

20

/* Spi slave device, JBO */

static struct spi_board_info am335x_spi1_slave_info[] = {

    {

        .modalias      = "spidev", // to match spidev drive

        .max_speed_hz  = 1000000, // maximal speed

        .bus_num       = 2, // indicate the device is on spi1

        .chip_select   = 0, //indicate it uses spi1_cs0

    },

};

/* Setup SPI, JBO */

static void spi_init(int evm_id, int profile)

{

    /* Configure SPI */

    setup_pin_mux(spi_pin_mux);

    spi_register_board_info(am335x_spi1_slave_info,

                            ARRAY_SIZE(am335x_spi1_slave_info));

    return;

}

4. Add the function call on device initialization list, comment out the MCASP function, as follow

1

2

3

4

5

6

7

static struct evm_dev_cfg myd_am335x_dev_cfg[] = {

    // ..............

    //{mcasp0_init,   DEV_ON_BASEBOARD, PROFILE_ALL},                                                                               

    {spi_init,      DEV_ON_BASEBOARD, PROFILE_ALL},

    // ..............

    {NULL, 0, 0},

};

5. recompile the kernel, you could find spidev 2.0 device node under the /dev/ catalog after you start up the board by this kernel.

Anonymous
Embedded and Microcontrollers blog
  • Formally verifying a floating-point division routine with Gappa – part 2

    Simon Tatham
    Simon Tatham
    A method of testing whether a numerical error analysis using Gappa really matches the code it is intended to describe.
    • September 4, 2025
  • Formally verifying a floating-point division routine with Gappa – part 1

    Simon Tatham
    Simon Tatham
    Learn the basics of using Gappa for numerical error analysis, using floating-point division in Arm machine code as a case study.
    • September 4, 2025
  • Adapting Kubernetes for high-performance IoT Edge deployments

    Alexandre Peixoto Ferreira
    Alexandre Peixoto Ferreira
    In this blog post, we address heterogeneity in IoT edge deployments using Kubernetes.
    • August 21, 2024