SPI input is always 0 with BeagleBoneBlack Anstrom images

I’m trying to write user-space SPI1 driver in slave mode. I just got past the bus errors trying to access the SPI registers without first turning on the clock in the clock module. Now I’m not able to change the pin mux settings:

#define MUX_SPI1_CS0 0x99C
#define MUX_SPI1_D0 0x994
#define MUX_SPI1_D1 0x998
#define MUX_SPI1_SCLK 0x990

#define CONTROL_MODULE_BANK_SIZE 0x2000 /* 8K */
Control_Module_Base = 0x44E10000;

m_controlModule = (uint32_t *)mmap(NULL, CONTROL_MODULE_BANK_SIZE,
MAP_SHARED, m_io_fd,

Read initial pin mux values:

printf("%s(): old MUX vals:\n"
“MUX_SPI1_CS0 = 0x%08X\n”
“MUX_SPI1_D0 = 0x%08X\n”
“MUX_SPI1_D1 = 0x%08X\n”

0x33, 0x33, 0x23, 0x23
Write new values:

m_controlModule[MUX_SPI1_CS0/4] = 0x3B;
m_controlModule[MUX_SPI1_D0/4] = 0x3B;
m_controlModule[MUX_SPI1_D1/4] = 0x1B;
m_controlModule[MUX_SPI1_SCLK/4] = 0x3B;

Read back values:
0x33, 0x33, 0x23, 0x23

Any ideas?

This an _ALMOST_ well known problem that many got bit by.

In reference manual, it states clearly that mux register can be
written _ONLY_ in Supervisor mode.
When in userspace you are in ARM user mode, and hence you can rightly
read the registers, but once you do a write, it will create some kind
of fault and probably your system should crash after a time.

Bottom line is - use kernel to program the mux registers.

3.8 kernel has a new framework for muxing via device tree blob.
Easiest could also be to just write these registers in any init
routine of a driver in kernel.

Best is to set mux as per the pinctrl 3.8 kernel method - but i have
not done much with it to help.

this was one reason to write my own mux legacy support for 3.8 kernel .

See the top most post on this thread: