* [Q/RFC] mpc52xx gpt api
@ 2009-11-15 17:17 Albrecht Dreß
2009-11-20 22:04 ` Grant Likely
0 siblings, 1 reply; 2+ messages in thread
From: Albrecht Dreß @ 2009-11-15 17:17 UTC (permalink / raw)
To: linuxppc-dev
Hi all,
I tried to use a '5200B internal timer for a very simple task - as pwm to m=
ake a led blink, but apparently the current gpt implementation from Grant's=
tree does only support internal (cpu timer) modes which do not use the tim=
er io pin.
The first hurdle was to actually get the timer itself - mpc52xx_gpt_from_ir=
q() never returned something when I passed the timers (v)irq to it. What i=
s the intended use of this function? BTW, I do not need timer irq's, so I =
believe there should be an other way to grab a timer!
I made several changes to finally get the pwm timer running for me with the=
current implementation, but IMO it might be interesting to have a more gen=
eric api. Before digging into it, I would be interested in any comment abo=
ut the following approach, which could cover all possible gpt operating mod=
es:
* struct mpc52xx_gpt_priv *mpc52xx_gpt_grab(const char * name, mode)
name: timer name, e.g. "f0000630.timer", or NULL for the next free cpu ti=
mer
mode: CPU, PWM, IC or OC. The latter three are only possible if the requ=
ested timer shall not be used as gpio (i.e. the device tree does not regist=
er it as such)
The function shall mark the timer as being in use, to avoid access confli=
cts.
It might also make sense to pass an irq callback function here. The gpt =
module would catch the hw irq, clear the status flags, and then call this f=
unction.
* int mpc52xx_gpt_setup
Configure period, continuous (cpu only), pwm width and polarity (pwm only=
). Didn't look into the special IC/OC requirements yet. Probably it makes=
sense to provide different functions for the four different modes (mpc52xx=
_gpt_setup_internal, mpc52xx_gpt_setup_pwm, etc.). We might then omit the =
mode parameter of the "grab" function, and shift the gpio vs. timer pin con=
flict check here.
The function shall always change the timer registers, even if the timer i=
s already running, which is convenient if e.g. the pwm output waveform shal=
l be changed on the fly.
* int mpc52xx_gpt_runstate(struct mpc52xx_gpt_priv *, int running)
Start/stop the timer
* int mpc52xx_gpt_release(struct mpc52xx_gpt_priv *)
Release timer, so an other mpc52xx_gpt_grab() will succeed.
Opinions?
Cheers, Albrecht.
Jetzt NEU: Do it youself E-Cards bei Arcor.de!
Stellen Sie Ihr eigenes Unikat zusammen und machen Sie dem Empf=E4nger eine=
ganz pers=F6nliche Freude!
E-Card Marke Eigenbau: HIER KLICKEN: http://www.arcor.de/rd/footer.ecard
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Q/RFC] mpc52xx gpt api
2009-11-15 17:17 [Q/RFC] mpc52xx gpt api Albrecht Dreß
@ 2009-11-20 22:04 ` Grant Likely
0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2009-11-20 22:04 UTC (permalink / raw)
To: Albrecht Dreß; +Cc: linuxppc-dev
On Sun, Nov 15, 2009 at 10:17 AM, Albrecht Dre=DF <albrecht.dress@arcor.de>=
wrote:
> Hi all,
>
> I tried to use a '5200B internal timer for a very simple task - as pwm to=
make a led blink, but apparently the current gpt implementation from Grant=
's tree does only support internal (cpu timer) modes which do not use the t=
imer io pin.
>
> The first hurdle was to actually get the timer itself - mpc52xx_gpt_from_=
irq() never returned something when I passed the timers (v)irq to it. =A0Wh=
at is the intended use of this function? =A0BTW, I do not need timer irq's,=
so I believe there should be an other way to grab a timer!
There is a discussion running right now on the linux-embedded list
about implementing an PWM api. It's worth hopping over and taking a
look.
g.
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-20 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-15 17:17 [Q/RFC] mpc52xx gpt api Albrecht Dreß
2009-11-20 22:04 ` Grant Likely
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.