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.

Kernel boot customization

My custom hardware has the option for me to enable or disable serial output to help save power if no debugging output messages are needed.  I have successfully modified U-Boot code to toggle the appropriate GPIO line high and enable serial output.  The kernel seems to assume that GPIOs haven't been configured yet and so resets them to some "default" state which disables my serial output.  After some examination, it seems that arch/arm/mach-davinci/board-evm.c is the appropriate file to modify in order to ensure that this line gets toggled high.  I've added the following code to the end of the board_init() function:

#define GPIO_DIR01                __REG(0x01C67010)
#define GPIO_OUT_DATA01    __REG(0x01C67014)
#define GPIO_DIR23                __REG(0x01C67038)
#define GPIO_OUT_DATA23    __REG(0x01C6703C)
#define XPINMUX0                   __REG(0x01C40000)
#define XPINMUX1                   __REG(0x01C40004)

// Turn on serial I/O

XPINMUX0 &= ~((1<<22) | (1<<23) | (1<<24) | (1<<25));    // Ensure GPIOs 0, 3, and 47 are GPIOs
XPINMUX1 &= ~((1<<6) | (1<<9));
GPIO_DIR01 &= ~((1<<0) | (1<<2) | (1<<3));
GPIO_DIR23 &= ~(1<<15);
// Enable UART level shifter
GPIO_OUT_DATA01 |= (1<<0);

I also set up some GPIOs that control voltage translation to some other on-board peripherals that are not always on so that I can control their state to save power. I have also tried placing this code at the end the evm_init() function, but probing the appropriate pins on the board show that they are not being toggled no matter which function the code is in.  I'm pretty confident the code is OK because it's the same code I use in U-Boot (save for how registers are defined) and have verified that the pin on my board toggles correctly.

 Is there some other function that disables or resets the state of GPIO registers and/or am I just putting my code in the wrong place?  I'd like to have this done at kernel boot so I can view kernel messages for debugging purposes during development.

Thanks

  • The code looks good to me. 

    This is probably being overwritten by one of the peripheral drivers which load after this code segment is processed; please note that there is no central place where pinmux drivers are set; last time I checked, they were being set by more than one driver during driver initialization stage, the final status of pinmux registers dependant on which drivers are enabled and the loading order.