Some really hip electronic circuits

Enable spi2.1 on BeagleBone

Well, the SPI 2.0 is enabled in user space and has been for a while now. However, the Replicape uses both SPI 2.0 (CS0) and SPI 2.1 (CS1). So how can that be enabled as well? Newer versions of the Linux kernel enables automatic pin-muxing by reading the contents of the EEPROM, but you still need to recompile the kernel to enable a second channel for the SPI.

To get stuff into your EEPROM so the kernel will mux the pins right, have a look at this page. The guy has a couple of methods, my personal favourite is the bone-script.

Where is the file?
There is really only one file to worry about when configuring the features of the kernel for BeagleBone. The file of interest for adding a new cape is “board-am335xevm.c” located in:

The function of interest is the “beaglebone_cape_setup” that handles all cape specific setups. That is where the pin-muxing goes.
At the bottom of that function is where the default setup occurs under the goto-label “out2:”

This only happens if none of the capes have claimed the SPI1 (which appears as SPI2.0 in the Linux file system). It might be a good idea to change the text in the “pr_info” function so you know on startup that the chnages you have made really did occur.

So to enable spi2.1, the “spi_register_board_info” function must be changed. Initially it looks like this:

You see what I did there? The second structure is identical, only it has .chip_slect = 1.

Enable the pin-muxing – the wrong way
If you only want SPI2.1 enabled without having to make a cape just to pin-mux right, you can simply change the “spi1_pin_mux” structure. I added the last entry for the spi1_cs1-pin.

This function should be placed somewhere in the “beaglebone_cape_setup” function. There are several others there, so a place should be easy to find..

Now the “pin-muxing the wrong way” is just a hack so it is not necessary to send a patch up stream, but for capes you are planning on selling, it would be great with support for it right out of the box. Look in the comments on the compiling a kernel for BeagleBone for info on that.