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 timer 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.  What is 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 generic 
api.  Before digging into it, I would be interested in any comment about the 
following approach, which could cover all possible gpt operating modes:

* 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 timer
  mode: CPU, PWM, IC or OC.  The latter three are only possible if the 
requested timer shall not be used as gpio (i.e. the device tree does not 
register it as such)
  The function shall mark the timer as being in use, to avoid access conflicts.
  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 
function.

* 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 
conflict check here.
  The function shall always change the timer registers, even if the timer is 
already running, which is convenient if e.g. the pwm output waveform shall 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änger eine ganz 
persönliche Freude!
E-Card Marke Eigenbau: HIER KLICKEN: http://www.arcor.de/rd/footer.ecard
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to