Pin Mux Configuration in U-Boot (Naon)

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
Naon am387x-dm814x.png Applies to Naon
Tux.png Applies to U-Boot


Warning-icon.png Please note that pin mux configuration is a very critical step. Wrong configuration may lead to system instability, side effects or even damage the hardware permanently Warning-icon.png

Introduction[edit | edit source]

The first thing to do when adding/modifying a peripheral is configure correctly the internal Pin Mux: in fact, nearly every peripheral function can be attached to more than one pin and nearly every pin is shared between two or more peripheral.

Texas Instruments Pin Mux Utility[edit | edit source]

Pin Mux is quite complex in Naon and, fortunately, a tool from TI can help: we suggest to download and install TI Pin Mux Utility from TI website.

Software installation and generic usage documentation is available on this TI wiki page

Pin Mux Utility also warn the user if there's a conflict in mux usage (e.g. the same pin configured for two function) and does not allow to export the source code when this kind of problems arise. Please take a look, for example, at Additional UART on Linux (Naon) article for a step-by-step guide in how to change pin mux configuration and how to fix conflicts.


An example of Pin Mux Utility with mux conflic

Pin Mux Configuration in u-boot[edit | edit source]

Due the fact the correct configuration of pin mux usually should be applied as soon as possible and that's better if pin mux is done is only one place, DAVE Embedded Systems choose to move all its initialization inside the startup code of U-Boot

Changing default pin mux configuration is just a matter of:

  1. open TI Pin Mux configuration
  2. load the Naon default configuration provided by DAVE Embedded Systems
  3. change the mux as needed
  4. export the generated source code into the U-Boot source tree
  5. rebuild u-boot and update it on your Naon board

Exporting generated source file[edit | edit source]

Pix Mux Utility export function, generate two source file:

  1. mux.h: which contains only pin mux registers offset. This file does NOT change when user changes pin mux configuration. It does NOT need to be updated.
  2. pinmux.h: which contains pin mux register values for each pin. This is the file that need to be updated in U-Boot source code

To update the default pin mux configuration with your changes just overwrite the board/dave/naon/pinmux.h file inside the U-Boot source tree with the generated one.

Please also note that, inside pinmux.h, user should change:

#define MUX_EVM() \
MUX_VAL(PINCNTL1, (IEN | IPU | FCN1 )) /* SD1_CLK */\
MUX_VAL(PINCNTL2, (IEN | IPU | FCN1 )) /* SD1_CMD_MUX0 */\
MUX_VAL(PINCNTL3, (IEN | IPU | FCN1 )) /* SD1_DAT[0] */\

into

#define MUX_NAON() \
MUX_VAL(PINCNTL1, (IEN | IPU | FCN1 )) /* SD1_CLK */\
MUX_VAL(PINCNTL2, (IEN | IPU | FCN1 )) /* SD1_CMD_MUX0 */\
MUX_VAL(PINCNTL3, (IEN | IPU | FCN1 )) /* SD1_DAT[0] */\

Before building and installing the new binaries we suggest to take a look at the diff between the original pinmux.h and the generated one. The changed should be restricted only on the user chosen pins

diff --git a/board/dave/naon/pinmux.h b/board/dave/naon/pinmux.h
index c1fccd6..0e6b2e2 100644
--- a/board/dave/naon/pinmux.h
+++ b/board/dave/naon/pinmux.h
@@ -208,8 +208,8 @@ MUX_VAL(PINCNTL168, (IEN | IPU | DISABLED )) /* safe_mode */\
 MUX_VAL(PINCNTL169, (IEN | IPD | DISABLED )) /* safe_mode */\
 MUX_VAL(PINCNTL170, (IEN | IPD | DISABLED )) /* safe_mode */\
 MUX_VAL(PINCNTL171, (IEN | IPD | DISABLED )) /* safe_mode */\
-MUX_VAL(PINCNTL172, (IEN | IPD | DISABLED )) /* safe_mode */\
-MUX_VAL(PINCNTL173, (IEN | IPU | DISABLED )) /* safe_mode */\
+MUX_VAL(PINCNTL172, (IDIS | IPD | FCN6 )) /* UART2_RXD_MUX0 */\
+MUX_VAL(PINCNTL173, (IDIS | IPD | FCN6 )) /* UART2_TXD_MUX1 */\
 MUX_VAL(PINCNTL174, (IEN | IPD | DISABLED )) /* safe_mode */\
 MUX_VAL(PINCNTL175, (IEN | IPD | FCN1 )) /* VOUT[0]_FLD_MUX1 */\
 MUX_VAL(PINCNTL176, (IEN | IPD | FCN1 )) /* VOUT[0]_CLK */\


Info-icon.png To avoid timestamp problems and broken dependency, before building U-Boot we suggest to run u-boot_clean target:
nelk@nelk-desktop:/home/shared/devel/dave/naon-DAA/sw/linux/sdk/sdk-5.03.01.15$ make u-boot_clean u-boot u-boot_install
Info-icon.png


Info-icon.png Please note that, for NELK < 2.0.0, pin mux configuration is applied in both U-Boot stage (1st and 2nd). When changing pin mux configuration for your custom board, please be sure to update both binaries Info-icon.png


Multiple Pin Mux Support[edit | edit source]

Info-icon.png This paragraph applies to NELK 2.0.0 or above Info-icon.png

To allow greater flexibility, starting from u-boot released with NELK 2.0.0 user can choose which pin mux to use by setting the naon_host U-Boot environment variable.

If this variable is empty or not correctly configured, U-Boot will warn the user and it does not apply any pin mux configuration (apart the default one configured by 1st stage).

...
## Starting application at 0x81000000 ...


U-Boot 2010.06-00011-gd371eb4 (Apr 22 2013 - 12:17:53) [nelk-4.0.0-Naon]

TI8148-GP rev 2.1

ARM clk: 600MHz
DDR clk: 400MHz
L3  clk: 200MHz
DSS clk: 200MHz
IVA clk: 266MHz
ISS clk: 400MHz
DSP clk: 500MHz

I2C:   ready
DRAM:  512 MiB
NAND:  HW ECC BCH8 Selected
1024 MiB
MMC:   OMAP SD/MMC: 0
*** Warning - bad CRC, using default environment

WARNING!! no valid pin mux defined, please configure 'naon_host'
environment variable to the correct value, save the environment
and reboot or some peripheral may not work correctly
Net:   <ethaddr> not set. Reading from E-fuse
Detected MACID:00:17:EB:52:6A:8A
cpsw
Hit any key to stop autoboot:  0 
NAON#

In this case, many peripheral will not work correctly, but the user is safe to plug the module in any board, due the fact that all pin are muxed in safe mode.

To configure, e.g., for the user should set the naon_host environment variable accordingly:

NAON#setenv naon_host evb_mid
NAON#saveenv
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done


Info-icon.png Please note that pin mux is applied only at boot time, for this reason, after configuring the environment variable, the user should reset the board to apply the settings. Info-icon.png


U-Boot 2010.06-00011-gd371eb4 (Apr 22 2013 - 12:17:17) [nelk-4.0.0-Naon-min]

TI8148-GP rev 2.1

ARM clk: 600MHz
DDR clk: 400MHz
L3  clk: 200MHz
DSS clk: 200MHz
IVA clk: 266MHz
ISS clk: 400MHz
DSP clk: 500MHz

DRAM:  512 MiB
Using default environment

Hit any key to stop autoboot:  0 
8192 KiB AT45DB642D at 0:0 is now current device
## Starting application at 0x81000000 ...


U-Boot 2010.06-00011-gd371eb4 (Apr 22 2013 - 12:17:53) [nelk-4.0.0-Naon]

TI8148-GP rev 2.1

ARM clk: 600MHz
DDR clk: 400MHz
L3  clk: 200MHz
DSS clk: 200MHz
IVA clk: 266MHz
ISS clk: 400MHz
DSP clk: 500MHz

I2C:   ready
DRAM:  512 MiB
NAND:  HW ECC BCH8 Selected
1024 MiB
MMC:   OMAP SD/MMC: 0
MUX: configuring for evb_mid
Net:   Detected MACID:00:17:EB:52:6A:8A
cpsw
NAON#