Re: [PATCH] gpio-sch: set output level after configuration of direction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2014-03-27 at 14:10 +0100, Alexander Stein wrote:
> 
> On Wednesday 26 March 2014 20:05:43, Gerhard Sittig wrote:
> > On Tue, 2014-03-25 at 10:33 +0100, Alexander Stein wrote:
> > > 
> > > According to the datasheet, writing to the level register has no effect
> > > when GPIO is programmed as input. Hence we set the level after configuring
> > > the GPIO as output. But we cannot prevent a short low pulse if direction is
> > > set to high and an external pull-up is connected.
> > 
> > Does "will have no effect" actually translate into "should not be
> > done" or even "must not be done"?  Doesn't sound like it.
> 
> I would translate that into 'won't do anything', it's read-only, thus the written value is lost. It just reflects the current signal when configured as input.

This is new information (both the "read-only" thing and "data
will be lost").  I'd suggest to update the commit message then.

BTW does reflecting input data and accepting output data (which
may or may not apply at the moment since it's only used in output
mode) not necessarily conflict.  Hardware may have two separate
registers (one for read, one for write) at the same address.
GPIO data registers often are implemented that way.  Which is why
you usually can "queue" the output value and then switch
directions.  And in the output case it's valid as well that input
sensed at the wire and output data dictated by the CPU might
differ (think open drain or bus keeper).

> > I understood that setting the data register for input pins does
> > nothing in that very moment, yet when switching to output the
> > value immediately gets used.  So this is the most appropriate
> > thing to do.
> 
> That would be the correct way, if hardware can be programmed that way. But if the data register is set when GPIO is confgured as input the data is lost. So when switching to output it does _NOT_ have the previously set value.
> That's why the direction is set first and data afterwards. Awkward, but yet the only way to set an "initial" output value

This information should end up in the source comment, I guess, in
this very strength.  It's an unusual limitation in a block that
implements a commodity feature.  The previous "soft" form made me
ask those questions, as will the next person to look ask again.

You keep referring to the documentation, did you check that the
hardware behaves the way you interpret the document?  Just to
make sure ...  This question might be avoided by saying "the
datasheet states and observation of hardware acknowledges ...".
It's not unusual that documentation and implementation differ. :)


virtually yours
Gerhard Sittig
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office@xxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux