From: "Menon, Nishanth" <nm@ti.com>
To: Lesly A M <leslyam@ti.com>
Cc: linux-omap@vger.kernel.org, David Derrick <dderrick@ti.com>,
Samuel Ortiz <sameo@linux.intel.com>
Subject: Re: [PATCH v8 4/7] omap3: pm: TWL5030 version checking
Date: Thu, 10 Mar 2011 09:45:46 +0530 [thread overview]
Message-ID: <AANLkTimO1b5OXUj_Vjsp1YD6W5yOFBzdHFQVoQk_HJ5K@mail.gmail.com> (raw)
In-Reply-To: <1299072653-13414-5-git-send-email-leslyam@ti.com>
$subject - OMAP3: pm? this is mfd twl-core rt?
On Wed, Mar 2, 2011 at 19:00, Lesly A M <leslyam@ti.com> wrote:
>
> Added api to get the TWL5030 Si version from the IDCODE register.
Does this work for 4030 and TPS variants as well? since this is
twl-core - how about the impact to 6030?
> It is used for enabling the workaround for TWL errata 27.
>
> Signed-off-by: Lesly A M <leslyam@ti.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: David Derrick <dderrick@ti.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> ---
> drivers/mfd/twl-core.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/i2c/twl.h | 17 ++++++++++++-
> 2 files changed, 77 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index a35fa7d..5e706d7 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -229,6 +229,9 @@
> /* is driver active, bound to a chip? */
> static bool inuse;
>
> +/* TWL IDCODE Register value */
> +static u32 twl_idcode;
> +
> static unsigned int twl_id;
> unsigned int twl_rev(void)
> {
> @@ -487,6 +490,61 @@ EXPORT_SYMBOL(twl_i2c_read_u8);
>
> /*----------------------------------------------------------------------*/
>
> +/**
> + * twl_read_idcode_register - api to read the IDCODE register.
s/api/API ?
> + * @value: returns 32 bit IDCODE register value.
Warning(drivers/mfd/twl-core.c:500): Excess function parameter
'value' description in 'twl_read_idcode_register'
please run scripts/kernel-doc on file when you add documentation to
ensure the documentation is in sync
> + *
> + * Unlocks the IDCODE register and read the 32 bit value.
> + */
> +int twl_read_idcode_register(void)
as previously mentioned:
drivers/mfd/twl-core.c:499:5: warning: symbol
'twl_read_idcode_register' was not declared. Should it be static?
> +{
> + int err;
> +
> + err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, TWL_EEPROM_R_UNLOCK,
> + REG_UNLOCK_TEST_REG);
> + if (err) {
> + pr_err("TWL4030 Unable to unlock IDCODE registers\n");
> + goto fail;
> + }
Do you want to be consistent everywhere and provide err value in print as well?
> +
> + err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_idcode),
Why should I cast this if I read only u8, why not make twl_idcode as u8?
Also modify twl_get_si_type, twl_get_si_version to return appropriately?
> + REG_IDCODE_7_0, 4);
> + if (err) {
> + pr_err("TWL4030: unable to read IDCODE -%d\n", err);
> + goto fail;
> + }
> +
> + err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, 0x0, REG_UNLOCK_TEST_REG);
> + if (err) {
> + pr_err("TWL4030 Unable to relock IDCODE registers\n");
> + goto fail;
why goto fail here?
> + }
> +fail:
> + return err;
> +}
> +
> +/**
> + * twl_get_si_type - api to get TWL Si type.
> + *
> + * Api to get the TWL Si type from IDCODE value.
> + */
> +int twl_get_si_type(void)
> +{
> + return TWL_SIL_TYPE(twl_idcode);
> +}
> +EXPORT_SYMBOL(twl_get_si_type);
EXPORT_SYMBOL_GPL instead?
> +
> +/**
> + * twl_get_si_version - api to get TWL Si version.
> + *
> + * Api to get the TWL Si version from IDCODE value.
> + */
> +int twl_get_si_version(void)
> +{
> + return TWL_SIL_REV(twl_idcode);
> +}
> +EXPORT_SYMBOL(twl_get_si_version);
^^^^ here as well.
> +
> static struct device *
> add_numbered_child(unsigned chip, const char *name, int num,
> void *pdata, unsigned pdata_len,
> @@ -1056,6 +1114,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
> /* setup clock framework */
> clocks_init(&client->dev, pdata->clock);
>
> + /* read TWL IDCODE Register */
> + twl_read_idcode_register();
> +
as already mentioned, what do we do when this fails?
> /* load power event scripts */
> if (twl_has_power() && pdata->power)
> twl4030_power_init(pdata->power);
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index f4bd475..d3cc2ac 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -150,7 +150,12 @@
> #define MMC_PU (0x1 << 3)
> #define MMC_PD (0x1 << 2)
>
> -
> +#define TWL_SIL_TYPE(rev) ((rev) & 0x00FFFFFF)
> +#define TWL_SIL_REV(rev) ((rev) >> 24)
> +#define TWL_SIL_5030 0x09002F
> +#define TWL5030_REV_1_0 0x00
> +#define TWL5030_REV_1_1 0x10
> +#define TWL5030_REV_1_2 0x30
how about 4030 and 6030?
>
> #define TWL4030_CLASS_ID 0x4030
> #define TWL6030_CLASS_ID 0x6030
> @@ -180,6 +185,9 @@ int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
> int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
> int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
>
> +int twl_get_si_type(void);
> +int twl_get_si_version(void);
Please change the names of these APIs - what is Si?
> +
> int twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
> int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
>
> @@ -279,7 +287,12 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
> *(Use TWL_4030_MODULE_INTBR)
> */
>
> +#define REG_IDCODE_7_0 0x00
> +#define REG_IDCODE_15_8 0x01
> +#define REG_IDCODE_16_23 0x02
> +#define REG_IDCODE_31_24 0x03
> #define REG_GPPUPDCTR1 0x0F
> +#:define REG_UNLOCK_TEST_REG 0x12
>
> /*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
>
> @@ -288,6 +301,8 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
> #define SR_I2C_SCL_CTRL_PU BIT(4)
> #define SR_I2C_SDA_CTRL_PU BIT(6)
>
> +#define TWL_EEPROM_R_UNLOCK 0x49
rest of the file seems to have a convention:
REG_NAME why is this register with a different convention?
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-03-10 4:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
2011-03-02 13:30 ` [PATCH v8 1/7] omap3: pm: Fix for the TRITON sleep/wakeup sequence Lesly A M
2011-03-08 13:14 ` Menon, Nishanth
2011-03-02 13:30 ` [PATCH v8 2/7] omap3: pm: Correct the warning print during script loading Lesly A M
2011-03-08 13:18 ` Menon, Nishanth
2011-03-02 13:30 ` [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards Lesly A M
2011-03-07 21:02 ` Kevin Hilman
2011-03-08 6:50 ` Manuel, Lesly Arackal
2011-03-08 16:29 ` Nishanth Menon
2011-03-08 16:03 ` Menon, Nishanth
2011-03-02 13:30 ` [PATCH v8 4/7] omap3: pm: TWL5030 version checking Lesly A M
2011-03-03 12:00 ` Krishnamoorthy, Balaji T
2011-03-10 4:15 ` Menon, Nishanth [this message]
2011-03-02 13:30 ` [PATCH v8 5/7] mfd: TWL4030: changes for TRITON Errata 27 workaround Lesly A M
2011-03-07 21:14 ` Kevin Hilman
2011-03-08 7:14 ` Manuel, Lesly Arackal
2011-03-02 13:30 ` [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts Lesly A M
2011-03-07 19:42 ` Kevin Hilman
2011-03-07 21:10 ` Kevin Hilman
2011-03-08 7:06 ` Manuel, Lesly Arackal
2011-03-08 7:01 ` Manuel, Lesly Arackal
2011-03-02 13:30 ` [PATCH v8 7/7] omap3630: " Lesly A M
2011-03-07 21:25 ` [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Kevin Hilman
2011-03-08 7:30 ` Manuel, Lesly Arackal
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=AANLkTimO1b5OXUj_Vjsp1YD6W5yOFBzdHFQVoQk_HJ5K@mail.gmail.com \
--to=nm@ti.com \
--cc=dderrick@ti.com \
--cc=leslyam@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=sameo@linux.intel.com \
/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;
as well as URLs for NNTP newsgroup(s).