[U-Boot-Users] i.MX31: mx31_gpio_mux() problem

Sascha Hauer s.hauer at pengutronix.de
Thu Jun 19 14:34:11 CEST 2008


On Wed, Jun 18, 2008 at 10:21:10PM +0200, Magnus Lilja wrote:
> Hi all
> 
> 
> While I was using the mx31_gpio_mux() function in cpu/arm1136/mx31/generic.c to modify the IOMUX for some IO pads I discovered that only the first 256 pads can be modified by this function.
> 
> It's pretty easy to fix this (see patch below) but I wonder if it's really the right way to fix this problem. Currently mx31_gpio_mux() takes only one argument, mode, which contains both the pad number and the new mode.
> 
> Current use:
> mx31_gpio_mux((MUX_CTL_FUNC << 8) | MUX_CTL_CSPI2_MISO);
> 
> (the patch below changes << 8 to << 9 and modifies the mx31_gpiomux() function accordingly)
> 
> Perhaps it's better to split the above into two arguments, pad number and pad mode, the function will then be called with:
> mx31_gpio_mux(MUX_CTL_CSPI2_MISO, MUX_CTL_FUNC);
> 
> I prefer the second approach (i.e. not the one in the patch below).

The first approach has the advantage that you can define convenience
macros like MUX_RXD1__UART1_RXD_MUX which makes it easy to setup new
boards by only reading the definition instead of crawling the datasheet
for Alternate function assignments once the list of defined is somewhat
completed. Looking in the datasheet for every new pin is a pain and
error prone.

  
>  	/* SPI2 */
> -	mx31_gpio_mux((MUX_CTL_FUNC << 8) | MUX_CTL_CSPI2_SS2);
> -	mx31_gpio_mux((MUX_CTL_FUNC << 8) | MUX_CTL_CSPI2_SCLK);
> -	mx31_gpio_mux((MUX_CTL_FUNC << 8) | MUX_CTL_CSPI2_SPI_RDY);
> -	mx31_gpio_mux((MUX_CTL_FUNC << 8) | MUX_CTL_CSPI2_MOSI);
> -	mx31_gpio_mux((MUX_CTL_FUNC << 8) | MUX_CTL_CSPI2_MISO);
> -	mx31_gpio_mux((MUX_CTL_FUNC << 8) | MUX_CTL_CSPI2_SS0);
> -	mx31_gpio_mux((MUX_CTL_FUNC << 8) | MUX_CTL_CSPI2_SS1);
> +	mx31_gpio_mux((MUX_CTL_FUNC << 9) | MUX_CTL_CSPI2_SS2);
> +	mx31_gpio_mux((MUX_CTL_FUNC << 9) | MUX_CTL_CSPI2_SCLK);
> +	mx31_gpio_mux((MUX_CTL_FUNC << 9) | MUX_CTL_CSPI2_SPI_RDY);
> +	mx31_gpio_mux((MUX_CTL_FUNC << 9) | MUX_CTL_CSPI2_MOSI);
> +	mx31_gpio_mux((MUX_CTL_FUNC << 9) | MUX_CTL_CSPI2_MISO);
> +	mx31_gpio_mux((MUX_CTL_FUNC << 9) | MUX_CTL_CSPI2_SS0);
> +	mx31_gpio_mux((MUX_CTL_FUNC << 9) | MUX_CTL_CSPI2_SS1);

And of course my intention was to move such things into
include/asm-arm/arch-mx31/mx31-regs.h so that other people can make use
of it.

> -#define MUX_RXD1__UART1_RXD_MUX	((MUX_CTL_FUNC << 8) | MUX_CTL_RXD1)
> -#define MUX_TXD1__UART1_TXD_MUX	((MUX_CTL_FUNC << 8) | MUX_CTL_TXD1)
> -#define MUX_RTS1__UART1_RTS_B	((MUX_CTL_FUNC << 8) | MUX_CTL_RTS1)
> -#define MUX_RTS1__UART1_CTS_B	((MUX_CTL_FUNC << 8) | MUX_CTL_CTS1)
> +#define MUX_RXD1__UART1_RXD_MUX	((MUX_CTL_FUNC << 9) | MUX_CTL_RXD1)
> +#define MUX_TXD1__UART1_TXD_MUX	((MUX_CTL_FUNC << 9) | MUX_CTL_TXD1)
> +#define MUX_RTS1__UART1_RTS_B	((MUX_CTL_FUNC << 9) | MUX_CTL_RTS1)
> +#define MUX_RTS1__UART1_CTS_B	((MUX_CTL_FUNC << 9) | MUX_CTL_CTS1)

...like these examples here.

Sascha

-- 
Pengutronix e.K. - Linux Solutions for Science and Industry
-----------------------------------------------------------
Kontakt-Informationen finden Sie im Header dieser Mail oder
auf der Webseite -> http://www.pengutronix.de/impressum/ <-




More information about the U-Boot mailing list