gpio initialization -- seems to be happening in u-boot

Or is it x-load?

I've been looking but have been unable to find the code that initializes the
gpio pins on the expansion connector.

Once linux is loaded I looked at the mux register (0x4800216a) which is
gpio_139 (MMC2_DAT7 or AE3). It has the value 0x11c which means input
enabled, pullup, pullup enabled and mode4 (gpio mode).

The doc says that the default should be mode 7, safe mode, and pull
disabled, on reset, which I can confirm by watching the hardware. It seems
that soon as u-boot starts, it goes from mode 7 to mode 4 and pullup
enabled.

The x-load source shows a bunch of mux registers being set, but not that
one.

I've been unable to find any mux register setup in either u-boot nor the
kernel that sets up mode 4 or the pullup for that i/o pin. There are setups
for lots of other pins, but not that one, nor others near it. It must be
hidden in there somewhere, but I'm not sure where.

If anyone could point to the code that does this initialization it would be
appreciated.

I'm using x-load-1.42+r7+git73eb0caf065b3b3f407d8af5c4836624e5cc7b69-r7
And u-boot-git-r18. These versions are whatever the standard oe and
beagleboard.conf provides.

Thanks,
Kevin

Hi,

Sun, 30 Nov 2008, Kevin Uhlir wrote:

I've been looking but have been unable to find the code that initializes the
gpio pins on the expansion connector.

I've been unable to find any mux register setup in either u-boot nor the
kernel that sets up mode 4 or the pullup for that i/o pin. There are setups
for lots of other pins, but not that one, nor others near it. It must be
hidden in there somewhere, but I'm not sure where.

Take a look at u-boot file board/omap3/beagle/beagle.h and .c
For me it seems that those files initialize at least almost every pin.

If you want to control the gpios from linux then look at:

http://www.hy-research.com/omap3_pinmux.html

To take it a step further I have actually gotten gpios to work with
the following code in arch/arm/mach-omap2/mux.c, add the following to
the end of omap34xx_pins:

MUX_CFG_34XX("XXX_3430_GPIO_136", 0x164, /* CJD */
               OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
MUX_CFG_34XX("XXX_3430_GPIO_137", 0x166,
               OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
MUX_CFG_34XX("XXX_3430_GPIO_138", 0x168,
               OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
MUX_CFG_34XX("XXX_3430_GPIO_139", 0x16a,
               OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
MUX_CFG_34XX("XXX_3430_GPIO_140", 0x16c,
               OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
MUX_CFG_34XX("XXX_3430_GPIO_141", 0x16e,
               OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
MUX_CFG_34XX("XXX_3430_GPIO_142", 0x170,
               OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
MUX_CFG_34XX("XXX_3430_GPIO_143", 0x172,
               OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)

Then in include/asm-arm/arch-omap/mux.h at the very end of
omap34xx_index add:
    XXXX_3430_GPIO_136, /* CJD */
    XXXX_3430_GPIO_137, /* CJD */
    XXXX_3430_GPIO_138, /* CJD */
    XXXX_3430_GPIO_139, /* CJD */
    XXXX_3430_GPIO_140, /* CJD */
    XXXX_3430_GPIO_141, /* CJD */
    XXXX_3430_GPIO_142, /* CJD */
    XXXX_3430_GPIO_143, /* CJD */

Keep in mind order matters, because the enum in mux.h is used to index
the array in mux.c.

Then to get this stuff to actually do something I added calls to:
omap_cfg_reg(XXXX_3430_GPIO_136);
for all the pins I wanted to configure to the init code of my driver.

After all of that is done you can use the normal gpio functions to do
IO, like gpio_direction_output, and gpio_set_value, and the like.

Hopefully it is obvious what to change if you don't want all of your
gpio's to be outputs.

Found it!.. thank you.

In the u-boot that openembedded/beagleboard.conf pulled by default, there is
no beagle.h.

But beagle.c calls MUX_DEFAULT_ES2()

Which is defined in include/asm/arch-omap3/mux.h, which is where the inits
are being done, including the pins I'm interested in. I missed that the
first time I looked around.

Further question--

Openembedded/conf/machine/beagleboard.conf says:
PREFERRED_VERSION_u-boot = "git"

u-boot_git.bb says:
SRC_URI_beagleboard =
"git://www.sakoman.net/git/u-boot-omap3.git;branch=omap3;protocol=git"
SRCREV_beagleboard = "1e329ec630b31803ee191d2ee335214662b5bfea"
PV_beagleboard = "2008.10+${PR}+gitr${SRCREV}"

This leads to
"u-boot-2008.10+r19+gitr1e329ec630b31803ee191d2ee335214662b5bfea-r19" as the
version I'm using.

All of this comes from openembedded (org.openembedded.dev branch).

I also noticed u-boot-omap3beagleboard_1.1.4.bb in packages/.

Any suggestions as to which is "better"?

Kevin

Thanks for the info, I had found your information looking through the
archives of the group. It helped a lot.

However at this time I was trying to see what was setting the pins to mode 4
w/pullup. As you may see in my other post, I found it with some help. Mode
4 w/pullup is not going to work for my application, whereas the the defaults
(mode 7, no pullup) would have been an ideal power upstate, until linux
comes up and takes control.

So, I needed to find the code that set up mode 4 w/pullup (a bad power up
state for me) so I could change it.

Kevin