mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* PMIC device driver
@ 2011-02-16  8:37 Vanalme Filip
  0 siblings, 0 replies; 3+ messages in thread
From: Vanalme Filip @ 2011-02-16  8:37 UTC (permalink / raw)
  To: barebox

Up till now, I could not start up the network on my i.mx27PDK board. After measuring on the device, I could see that power was missing for the PHY. Good reason, of course, for not starting up... 
To enable the missing power, I have to adjust some registers in the PMIC device (mc13783).
If I look into the mc13783.c file, I could see that this has similarities with Linux device drivers. So, to access the PMIC, I guess I have to do an open("/dev/pmic") and then a read or write. However, when I look to the pmic_read() and pmic_write() function, they have, besides the device pointer, buffer pointer and buffer size, an offset parameter that indicate the register within the PMIC to read/write. On the other hand, the standard read and write functions only take 3 parameters (device, buffer, buffersize). How do I pass that offset to these functions ? How do I use the PMIC device driver ?
(Maybe this is a general Linux device driver question, but I'm not that familiar with device drivers, so...)

Is it the best way to do it like this (open, read, write), or do I better call those functions directly ? (I have to set the PMIC registers in the "late_init" function of the barebox startup sequence)

Filip Vanalme



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PMIC device driver
  2011-02-16 12:20 Vanalme Filip
@ 2011-02-16 20:34 ` Marc Reilly
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Reilly @ 2011-02-16 20:34 UTC (permalink / raw)
  To: barebox; +Cc: Vanalme Filip


Hi,

> > indicate the register within the PMIC to read/write. On the other hand,
> > the standard read and write functions only take 3 parameters (device,
> > buffer, buffersize). How do I pass that offset to these functions ? How
> > do I use the PMIC device driver ?
> > (Maybe this is a general Linux device driver question, but I'm not that
> > familiar with device drivers, so...)

I'd be using the pmic_read_reg and pmic_write_reg functions (they should be 
renamed and exported first though.)

Have a look at the mc13892 driver ..

> > 
> > Is it the best way to do it like this (open, read, write), or do I better
> > call those functions directly ? (I have to set the PMIC registers in the
> > "late_init" function of the barebox startup sequence)

... and the freescale-mx35-3stack for example.


> 
> [Filip] Think I found how it works. I have to use the normal read, write
> and lseek functions to read/write PMIC registers. 

As I said above, I reckon your board code will be cleaner if you skip the file 
I/O and use the _read_reg and _write_reg functions directly.


> The 'offset' and 'flag'
> parameters in read and write functions are for internal use only. Correct.
> When reading, an internal index is incremented. A following read starts
> where the previous ended. With lseek, one can move that index to address
> the correct register. Right ?
In general, yes.


HTH,

Cheers
Marc


> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* PMIC device driver
@ 2011-02-16 12:20 Vanalme Filip
  2011-02-16 20:34 ` Marc Reilly
  0 siblings, 1 reply; 3+ messages in thread
From: Vanalme Filip @ 2011-02-16 12:20 UTC (permalink / raw)
  To: barebox

> -----Original Message-----
> From: Vanalme Filip
> Sent: woensdag 16 februari 2011 9:38
> To: 'barebox@lists.infradead.org'
> Subject: PMIC device driver
> 
> Up till now, I could not start up the network on my i.mx27PDK board. After
> measuring on the device, I could see that power was missing for the PHY. Good
> reason, of course, for not starting up...
> To enable the missing power, I have to adjust some registers in the PMIC device
> (mc13783).
> If I look into the mc13783.c file, I could see that this has similarities with Linux
> device drivers. So, to access the PMIC, I guess I have to do an open("/dev/pmic")
> and then a read or write. However, when I look to the pmic_read() and pmic_write()
> function, they have, besides the device pointer, buffer pointer and buffer size, an
> offset parameter that indicate the register within the PMIC to read/write. On the
> other hand, the standard read and write functions only take 3 parameters (device,
> buffer, buffersize). How do I pass that offset to these functions ? How do I use the
> PMIC device driver ?
> (Maybe this is a general Linux device driver question, but I'm not that familiar with
> device drivers, so...)
> 
> Is it the best way to do it like this (open, read, write), or do I better call those
> functions directly ? (I have to set the PMIC registers in the "late_init" function of
> the barebox startup sequence)
> 
> Filip Vanalme
> 

[Filip] Think I found how it works. I have to use the normal read, write and lseek functions to read/write PMIC registers. The 'offset' and 'flag' parameters in read and write functions are for internal use only. Correct. When reading, an internal index is incremented. A following read starts where the previous ended. With lseek, one can move that index to address the correct register. Right ?

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-16 20:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-16  8:37 PMIC device driver Vanalme Filip
2011-02-16 12:20 Vanalme Filip
2011-02-16 20:34 ` Marc Reilly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox