All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 0/2] Generic PMIC driver
Date: Tue, 20 Sep 2011 14:38:07 +0200	[thread overview]
Message-ID: <20110920143807.590fc691@lmajewski.digital.local> (raw)
In-Reply-To: <4E784D9C.5090708@denx.de>

Hi Stefano,

Thanks for the reply.

> > 
> > In my opinion following issues needs discussion:
> > 1. In proposed 
> > int struct pmic *p, u32 *val) the val is returned by
> > pointer.
> 
> And the register to be read/write is embedded in the structure. For
> readness I will let it as separate parameter, but this is my personal
> taste.
For the first version of the pmic_core.c driver we might stick to this
proposition.


> Who is responsible to allocate the pmic structure ? It could be (there
> is no use case at the moment) that the pmic can be programmed before
> the relocation, when malloc() is not available.

In my opinion on the beginning we should focus on basic scenarios. 
Therefore the pmic struct is defined static at pmic_core.c as
follows:
static struct pmic pmic;

It is simple and efficient (since it's scope is limited to the
translation unit). We shall NOT use malloc() allocation for the first
version of the driver.

> > Now at fsl_pmic.c read value is returned by return clause.
> 
> Yes, we can change - of course, we need to update in one-shot also the
> boards already using a pmic.

Some work for the iMX target boards (e.g. MX51evk) need to be done to
comply with new framework.

As fair as I looked into the code, only iMX power_init methods need
to be fixed. 

> > I think, that passing pointer is a better approach,since errors
> > from i2c_read/spi_read can be caught in upper layers.
> 
> Using a pointer is the common way to implement a read routine, so I
> cannot argue. The side effect is that the calling code will be filled
> with the same and boring check:
> 
> 	ret = pmic_read_reg(....);
> 	if (ret) {
> 		<...error handling, most case only print>
> 	}
> 	ret = pmic_read_reg(....);
> 	if (ret) {
> 		<...error handling, most case only print>
> 	}
> 
I think, that error checking is always welcome :-).

> > 2. Since I haven't got a chance to test SPI part of the fsl_pmic.c
> > driver, I've focused mainly on I2C and place stubs for SPI.
> 
> Ok, right - this is a RFC. I will do no not review the details in your
> sample code, we are discussing the interface ;-).
> 
> For the "real" patch, I think we should merge this new code with
> fsl_pmic.c, too.
> 
In my opinion we shall reuse fsl_pmic.c code as much as possible 
(especially the SPI code - since I cannot test it). 

> > 
> > 3. Suggestions for struct pmic's additional fields for SPI are more
> > than welcome :-) 
> 
> We should have the parameters to setup a SPUI connection:
> 	- SPI chipselect
> 	- SPI frequency
> 	- SPI mode
> 	- SPI bus
> 

OK.


> > 4. Now the pmic_core.c file consist of
> >    #ifdef PMIC_I2C
> >    {Code for handling I2C}
> >    #else
> >    {Code for handling SPI}
> >    #endif
> > 
> > The same approach is used at fsl_pmic.c   
> > 
> > I'm wondering if this approach shouldn't be replaced with on-time
> > checking if SPI or I2C interface is available.
> > This check can be performed by:
> > 
> > struct pmic *p;
> > if (p->interface == PMIC_I2C) {
> > 
> > } else {
> > 
> > }
> > 
> > It would allow to remove obscure #ifdefs, but on the other hand it
> > will reduce execution speed of the driver.
> 
> Well, I do not worry about time execution. The time to execute the if
> branch is maybe negligible compared to the time to make a I2C/SPI
> transfer.
> 
> However, we increase the footprint, and surely only one mechanism is
> required on the same board.
> 
So I will try to use switch-case construct.

switch (p->interface) {
	case PMIC_I2C:

	case PMIC_SPI:

}


> Best regards,
> Stefano Babic
> 

-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center
Platform Group

  reply	other threads:[~2011-09-20 12:38 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01  9:13 [U-Boot] [PATCH 0/2] misc:max8998 Support for MAX8998 PMIC driver Lukasz Majewski
2011-09-01  9:13 ` [U-Boot] [PATCH 1/2] " Lukasz Majewski
2011-09-01  9:13 ` [U-Boot] [PATCH 2/2] misc:samsung:s5p Enable MAX8998 support at GONI reference target Lukasz Majewski
2011-09-12  8:14 ` [U-Boot] [PATCH 0/2] misc:max8998 Support for MAX8998 PMIC driver Lukasz Majewski
2011-09-12 10:50   ` Stefano Babic
2011-09-12 11:41     ` Wolfgang Denk
2011-09-12 13:18     ` Lukasz Majewski
2011-09-12 13:50       ` Stefano Babic
2011-09-19 15:06 ` [U-Boot] [RFC 0/2] Generic " Lukasz Majewski
2011-09-19 15:06   ` [U-Boot] [RFC 1/2] misc:pmic New generic pmic driver Lukasz Majewski
2011-09-19 15:06   ` [U-Boot] [RFC 2/2] misc:pmic:max8998: Support for max8998 pmic Lukasz Majewski
2011-09-20  8:23   ` [U-Boot] [RFC 0/2] Generic PMIC driver Stefano Babic
2011-09-20 12:38     ` Lukasz Majewski [this message]
2011-09-20 14:08       ` Stefano Babic
2011-09-26 15:10 ` [U-Boot] [PATCH 0/3] misc:pmic: New PMIC generic driver Lukasz Majewski
2011-09-26 15:10   ` [U-Boot] [PATCH 1/3] misc:pmic New generic pmic driver Lukasz Majewski
2011-10-02 16:12     ` stefano babic
2011-09-26 15:10   ` [U-Boot] [PATCH 2/3] misc:pmic: Enable PMIC handling at u-boot startup code Lukasz Majewski
2011-10-02 16:14     ` stefano babic
2011-09-26 15:10   ` [U-Boot] [PATCH 3/3] misc:pmic:mx: Code modification for mx51evk board Lukasz Majewski
2011-10-02 16:15     ` stefano babic
2011-09-28 11:28   ` [U-Boot] [PATCH 0/3] misc:pmic: New PMIC generic driver Stefano Babic
2011-09-28 11:56     ` Lukasz Majewski
2011-10-02 15:58   ` stefano babic
2011-10-04  5:45 ` [U-Boot] [PATCH v2 " Lukasz Majewski
2011-10-04  5:45   ` [U-Boot] [PATCH v2 1/3] misc:pmic:core New generic PMIC driver Lukasz Majewski
2011-10-05 10:52     ` Stefano Babic
2011-10-06  9:48     ` Stefano Babic
2011-10-06 11:13       ` Lukasz Majewski
2011-10-06 11:19         ` Stefano Babic
2011-10-04  5:45   ` [U-Boot] [PATCH v2 2/3] misc:pmic:max8998 MAX8998 support at a new " Lukasz Majewski
2011-10-05 10:53     ` Stefano Babic
2011-10-12 10:55     ` Stefano Babic
2011-10-04  5:45   ` [U-Boot] [PATCH v2 3/3] misc:pmic:samsung Enable PMIC driver at GONI target Lukasz Majewski
2011-10-05 10:54     ` Stefano Babic
2011-10-12 10:56     ` Stefano Babic
2011-10-05 10:52   ` [U-Boot] [PATCH v2 0/3] misc:pmic: New PMIC generic driver Stefano Babic
2011-10-05 10:56   ` [U-Boot] [PATCH v2 4/4] misc: pmic: Freescale PMIC switches to generic PMIC driver Stefano Babic
2011-10-06 12:37   ` [U-Boot] [PATCH v3 1/3] misc:pmic:core New " Lukasz Majewski
2011-10-12 10:57     ` Stefano Babic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110920143807.590fc691@lmajewski.digital.local \
    --to=l.majewski@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.