Saturday, March 24, 2012

Enabling SPI on BeagleBoard

Here is the reference blog to enable SPI on BeagleBoard with Angstrom.
[1] http://linuxdeveloper.blogspot.ca/2011/10/enabling-spi-on-beagleboard-xm.html

pin-mux:
Do not forget to patch /arch/arm/mach-omap2/board-omap3beagle.c
See [2] http://elinux.org/BeagleBoard/SPI for details. Here is the patch file:
[3] http://elinux.org/BeagleBoard/SPI/Patch-2.6.37

Actually, one can also customize U-boot to setup the pin-mux. Let's focus on the way provided by reference [2] now. After activating CONFIG_OMAP_MUX (You can do this by selecting 'System Type --> TI OMAP Implementations --> OMAP multiplexing support' in the kernel's make menuconfig. See [4] http://elinux.org/BeagleBoardPinMux for details.), I got a kernel panic error as mentioned in reference [2] and the following links:
[5] https://groups.google.com/forum/?fromgroups#!topic/beagleboard/Tmt1PS6KGmg
[6] https://groups.google.com/forum/?fromgroups#!topic/beagleboard/On9iVpUnWBI
(According to my tests, this panic error always occurs on the xM board. It may not happen on the original BeagleBoard as outlined by reference [6].)

To fix it up, reference [2], [5], and [6] gave a solution by commenting the line 'omap_cfg_reg(AH8_34XX_GPIO29);'. However, I cannot find this line in 'board-omap3beagle.c'. My kernel version is 2.6.34. Take a look at the git log, you'll find that new kernel versions do not support 'omap_cfg_reg()' anymore. I believe it was replaced by function 'omap_mux_init_gpio()', which appears in my 'board-omap3beagle.c'. Anyway, after commenting out lines:
'omap_mux_init_gpio(29, OMAP_PIN_INPUT);',
'omap_mux_init_gpio(23, OMAP_PIN_INPUT);',
and 'mmc[0].gpio_wp = 23;',
the panic error was gone.


The kernel image has been tested on both original BeagleBoard and xM board. 'spidev_test' results are good for /dev/spidev4.0, /dev/spidev3.0, and /dev/spidev3.1.

My next plan is to remap SPI3 on header P17 rather than the expansion header. I tried to modify 'board-omap3beagle.c' as follows:

static void __init omap3_beagle_config_mcspi3_mux(void)
{
// NOTE: Clock pins need to be in input mode
omap_mux_init_signal("etk_d3.mcspi3_clk",
OMAP_PIN_INPUT);
omap_mux_init_signal("etk_d2.mcspi3_cs0",
OMAP_PIN_OUTPUT);
omap_mux_init_signal("etk_d7.mcspi3_cs1",
OMAP_PIN_OUTPUT);
omap_mux_init_signal("etk_d0.mcspi3_simo",
OMAP_PIN_OUTPUT);
omap_mux_init_signal("etk_d1.mcspi3_somi",
OMAP_PIN_INPUT_PULLUP);
}

However, it does not work. I am still trying to figure out a solution.

3 comments:

  1. Did you finally get the SPI3 on P17 working? I also tried to set the MUX in u-boot without success...

    Thanks,
    flo

    ReplyDelete
    Replies
    1. To answer my own question:

      You have to disable HSUSB1 on P17. Change the board-omap3beagle.c to the following:

      static const struct usbhs_omap_board_data usbhs_bdata __initconst = {

      .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,

      Greetings,
      flo

      Delete
  2. Is this procedure same for beagle board C4

    ReplyDelete