From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Added MC13892VK Power Management driver
Date: Mon, 22 Mar 2010 11:21:10 +0100 [thread overview]
Message-ID: <4BA74496.20705@denx.de> (raw)
In-Reply-To: <4BA56068.2060308@windriver.com>
Hi Tom,
Tom wrote:
> Stefano Babic wrote:
>> Added SPI driver for the Power Management Controller
>> used with i.MX51 Processor.
>>
>
> Errors in
> imx31_litekeit
> imx31_phycore_eet
> imx31_ads
> These must be fixed
...and I have to test with a MX31, too. I will find a board and test the
changes before sending version 2 of the patch.
>> +
>> + tmp = pmic_tx;
>> + for (i = 0; i < 4; i++) {
>> + tx[i] = (tmp & 0xFF000000) >> 24;
>> + tmp <<= 8;
>> + }
>
> Looks like you are converting for bigendian to little.
> It may be better to use one of the cpu_to_little functions
> see linux/byteorder/generic.h
Thanks, I will check it.
>> + pmic_rx = (rx[0] << 24) | (rx[1] << 16) | (rx[2] << 8) | rx[3];
>
> A conversion of little to big.
> Use existing conversion functions
ok, thanks.
>> + rev_id = mc13892_reg(slave, 7, 0, 0);
>
> Be consistent on use of mc13892_reg.
> If you have the read/write wrappers, use them.
> From this conext it is difficult to understand that this is a read.
Agree, this is a mistake, I forget to correct it, mc13892_reg() must not
be used outside the driver.
>
> The return is a u32 value, not a pointer so the modifier 'volatile' is
> not needed in the declaration of rev_id
Ok, got it.
>> + MC13892_REG_LED_CTL2,
>> + MC13892_REG_LED_CTL3,
>> + MC13892_REG_UNUSED12,
>> + MC13892_REG_UNUSED13,
>> + MC13892_REG_TRIM0,
>> + MC13892_REG_TRIM1,
>> + MC13892_REG_TEST0,
>> + MC13892_REG_TEST1, /*60 */
>> + MC13892_REG_TEST2,
>> + MC13892_REG_TEST3,
>> + MC13892_REG_TEST4,
>
> This should be converted to the reg access through struct members.
I do not know if this helps to make code more readable. We need to send
the address of the internal register via the SPI interface, and these
registers are not mapped into the microprocessor address space.
If I use a structure, I must always convert the address to the register
number before sending via the SPI interface. At the end, I have a
further step that probably makes difficult to understand.
The same approach with register number is actually used for
drivers/rtc/mc13873-rtc.c, whose interface is quite similar as this one,
even if in this case the register number is directly used. I think it is
better to have the same approach for similar chips.
> These wrappers add an unneeded layer of indirection
> There should be real read / write funtions
Agree, I will remove that indirection and avoid to export mc13892_reg.
Stefano
--
=====================================================================
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 at denx.de
=====================================================================
next prev parent reply other threads:[~2010-03-22 10:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 16:18 [U-Boot] [PATCH] Added MC13892VK Power Management driver Stefano Babic
2010-03-20 23:55 ` Tom
2010-03-22 10:21 ` Stefano Babic [this message]
2010-04-19 7:56 ` [U-Boot] [PATCH 1/6] MX: Added Freescale Power Management Driver Stefano Babic
2010-04-19 7:56 ` [U-Boot] [PATCH 2/6] MX: RTC13783 uses general function to access PMIC Stefano Babic
2010-04-19 7:56 ` [U-Boot] [PATCH 3/6] MX31: Add support for PMIC to the QONG module Stefano Babic
2010-04-19 7:56 ` [U-Boot] [PATCH V2 4/6] SPI: added support for MX51 to mxc_spi Stefano Babic
2010-04-19 7:56 ` [U-Boot] [PATCH 5/6] MX: Added definition file for MC13892 Stefano Babic
2010-04-19 7:57 ` [U-Boot] [PATCH V2 6/6] Add SPI support to mx51evk board Stefano Babic
2010-04-19 18:42 ` [U-Boot] [PATCH 1/6] MX: Added Freescale Power Management Driver Magnus Lilja
2010-04-19 20:10 ` Stefano Babic
2010-04-19 21:04 ` [U-Boot] [PATCH V2 2/6] MX: RTC13783 uses general function to access PMIC Stefano Babic
2010-04-22 20:06 ` Magnus Lilja
2010-04-23 8:19 ` Stefano Babic
2010-04-19 21:06 ` [U-Boot] [PATCH V3 4/6] SPI: added support for MX51 to mxc_spi 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=4BA74496.20705@denx.de \
--to=sbabic@denx.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox