U-Boot v1 Beagle GPIO module 6 handling off by one error?

While having a look to Beagle's GPIO handling in U-Boot v1, I wonder if we have an off by one error there. As I'm not sure, anybody likes to re-check this?

I talk about GPIO module 6 configuration in

misc_init_r()

http://www.sakoman.net/cgi-bin/gitweb.cgi?p=u-boot-omap3.git;a=blob;f=board/omap3/beagle/beagle.c;h=bf77b4f3113f039c22d33f169ae77082154a99eb;hb=refs/heads/omap3-dev

There we have

writel(~((GPIO10) | GPIO9 | GPIO3 | GPIO2), &gpio6_base->oe);
writel(GPIO10 | GPIO9 | GPIO3 | GPIO2, &gpio6_base->setdataout);

Now, looking at

http://www.sakoman.net/cgi-bin/gitweb.cgi?p=u-boot-omap3.git;a=blob;f=board/omap3/beagle/beagle.h;h=028e3f623c537e04aa1b57cd6e243920d5ec3265;hb=refs/heads/omap3-dev

which has

MUX_VAL(CP(MCBSP1_FSX), (IDIS | PTD | DIS | M4)) /*GPIO_161*/\
MUX_VAL(CP(MCBSP1_CLKX), (IDIS | PTD | DIS | M4)) /*GPIO_162*/\

I wonder if it has to be GPIO2 | GPIO1 above instead of GPIO3 | GPIO2 to configure GPIO_161 and GPIO_162 ? As I understand it, GPIO module 6 goes from GPIO_160 to GPIO_192. So GPIO_161 would be at offset GPIO1 and GPIO_162 would be at offset GPIO2?

What do you think?

I'm not sure about GPIO10 | GPIO9, though. This configures GPIO_169 and GPIO_170?

GPIO module 5 in the same function looks correct to me:

writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);

configures

GPIO_140, GPIO_141, GPIO_142, GPIO_143, GPIO_149, GPIO_150, GPIO_156, GPIO_157, GPIO_158 and GPIO_159.

Sorry if I missed something.

Many thanks

Dirk

Btw.: Overo seems to have the same code. Is it needed/correct there?

Hi Dirk,

I agree - Seems like GPIO-block 6 is off by one for GPIO_161 and GPIO_162
(Should had been 1 and 2 instead of 2 and 3). The signals are however only
routed to the expansion connector, which might be the reason why nobody have

caught the mistake yet :slight_smile:

Secondly you are right, that GPIO9 and GPIO10 in block 6 addresses real
world
GPIO_169 and GPIO_170.

Last I can confirm, that GPIO-block 6 starts at GPIO_160 and ends at
GPIO_191
- Both included

Best regards
  Søren

Søren Steen Christensen wrote:

Hi Dirk,

I agree - Seems like GPIO-block 6 is off by one for GPIO_161 and GPIO_162
(Should had been 1 and 2 instead of 2 and 3). The signals are however only routed to the expansion connector, which might be the reason why nobody have

caught the mistake yet :slight_smile:

ok, thanks for checking :slight_smile:

Secondly you are right, that GPIO9 and GPIO10 in block 6 addresses real
world GPIO_169 and GPIO_170.

ok, then the question is: Is this correct?

Looking at the schmatic and pin mux we have:

I2C2_SCL/GPIO_168
MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M4)) /*GPIO_168*/\

HSUSB0_D3/UART3_CTS_RCTX/GPIO_169
MUX_VAL(CP(HSUSB0_DATA3), (IEN | PTD | DIS | M0)) /*HSUSB0_DATA3*/\

HDQ_SIO/SYS_ALTCLK/I2C2_SCCBE/I2C3_SCCBE/GPIO_170
MUX_VAL(CP(HDQ_SIO), (IDIS | PTU | EN | M4)) /*HDQ_SIO*/\

=> GPIO_169 isn't configured as GPIO, so it makes no sense to set it.

I would vote for GPIO_168 instead of 169. With the GPIO_161 and GPIO_162 changes this would result in

writel(~((GPIO10) | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);

writel(GPIO10 | GPIO8 | GPIO2 | GPIO1, &gpio6_base->setdataout);

What do you think?

Thanks

Dirk

Hi Dirk,

GPIO_168 as well only goes to the expansion connector => Nobody/not many
uses it yet :slight_smile:

I agree it makes no sense to configure GPIO_169, when the ball is muxed to
HSUSB0_DATA3...
I therefore think you new assignment is correct/better than the previous one
- Now the pinmuxing and GPIO configuration seem consistent...

My only questions is if we should mux I2C2 to I2C or GPIO functionality in
general? What is the general rule of thumb in U-boot? Set everything to
GPIO, leave not used stuff as untouched (safe-mode) or configure it to it's
given peripheral (I2C/UART/MMC/etc...)?

In case we decide to go for GPIO (which is what's currently in the pinmuxing
table - At least for I2C2), I think we should setup GPIO_183 as well as
GPIO_168 (I2C2-sda and I2C2-scl) in order to be consistent. I would
therefore recommend to add GPIO23 to the setup lines, like:

writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, &gpio6_base->setdataout);

With respect to GPIO_170, is used for the DVI-chip power-down signal

Happy New Year to all
  Søren