2010-08-18 06:20:40

by Felipe Balbi

[permalink] [raw]
Subject: [PATCH 0/4] twl PROTECT_KEY usage cleanup

From: Felipe Balbi <[email protected]>

Hi all,

the following patches are cleaning up the usage
of PROTECT_KEY register.

Boot-tested on custom OMAP3 board.

Felipe Balbi (4):
i2c: twl: add register defines for pm master module
mfd: twl-core: switch over to defines in twl.h
mfd: twl4030-power: switch over to defines in twl.h
usb: otg: twl4030-usb: switch over to defines in twl.h

drivers/mfd/twl-core.c | 21 ++++++++----------
drivers/mfd/twl4030-power.c | 30 ++++++++++++++------------
drivers/usb/otg/twl4030-usb.c | 13 ++++++++---
include/linux/i2c/twl.h | 46 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 80 insertions(+), 30 deletions(-)

--
1.7.2.1.6.g61bf12


2010-08-18 06:20:25

by Felipe Balbi

[permalink] [raw]
Subject: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h

From: Felipe Balbi <[email protected]>

use the new definitions on twl header for code
consistency.

Signed-off-by: Felipe Balbi <[email protected]>
---
drivers/mfd/twl-core.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 720e099..9689ecf 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -202,12 +202,6 @@

/* Few power values */
#define R_CFG_BOOT 0x05
-#define R_PROTECT_KEY 0x0E
-
-/* access control values for R_PROTECT_KEY */
-#define KEY_UNLOCK1 0xce
-#define KEY_UNLOCK2 0xec
-#define KEY_LOCK 0x00

/* some fields in R_CFG_BOOT */
#define HFCLK_FREQ_19p2_MHZ (1 << 0)
@@ -846,8 +840,8 @@ static inline int __init protect_pm_master(void)
{
int e = 0;

- e = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_LOCK,
- R_PROTECT_KEY);
+ e = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
+ TWL4030_PM_MASTER_PROTECT_KEY);
return e;
}

@@ -855,10 +849,13 @@ static inline int __init unprotect_pm_master(void)
{
int e = 0;

- e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_UNLOCK1,
- R_PROTECT_KEY);
- e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_UNLOCK2,
- R_PROTECT_KEY);
+ e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
+ TWL4030_PM_MASTER_KEY_CFG1,
+ TWL4030_PM_MASTER_PROTECT_KEY);
+ e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
+ TWL4030_PM_MASTER_KEY_CFG2,
+ TWL4030_PM_MASTER_PROTECT_KEY);
+
return e;
}

--
1.7.2.1.6.g61bf12

2010-08-18 06:20:32

by Felipe Balbi

[permalink] [raw]
Subject: [PATCH 4/4] usb: otg: twl4030-usb: switch over to defines in twl.h

From: Felipe Balbi <[email protected]>

use the new definitions on twl header for code
consistency.

Signed-off-by: Felipe Balbi <[email protected]>
---
drivers/usb/otg/twl4030-usb.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index 0e88885..c9b7a87 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -124,7 +124,6 @@
#define PHY_DPLL_CLK (1 << 0)

/* In module TWL4030_MODULE_PM_MASTER */
-#define PROTECT_KEY 0x0E
#define STS_HW_CONDITIONS 0x0F

/* In module TWL4030_MODULE_PM_RECEIVER */
@@ -405,8 +404,13 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
{
/* Enable writing to power configuration registers */
- twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0xC0, PROTECT_KEY);
- twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x0C, PROTECT_KEY);
+ twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
+ TWL4030_PM_MASTER_KEY_CFG1,
+ TWL4030_PM_MASTER_PROTECT_KEY);
+
+ twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
+ TWL4030_PM_MASTER_KEY_CFG2,
+ TWL4030_PM_MASTER_PROTECT_KEY);

/* put VUSB3V1 LDO in active state */
twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
@@ -442,7 +446,8 @@ static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE);

/* disable access to power configuration registers */
- twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, PROTECT_KEY);
+ twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
+ TWL4030_PM_MASTER_PROTECT_KEY);

return 0;

--
1.7.2.1.6.g61bf12

2010-08-18 06:20:59

by Felipe Balbi

[permalink] [raw]
Subject: [PATCH 1/4] i2c: twl: add register defines for pm master module

From: Felipe Balbi <[email protected]>

Some modules already need to talk to at least PROTECT_KEY
register, while at that, add defines to the entire register
space.

Signed-off-by: Felipe Balbi <[email protected]>
---
include/linux/i2c/twl.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 6de90bf..a3bfbe1 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -357,6 +357,52 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);

/*----------------------------------------------------------------------*/

+/*
+ * PM Master module register offsets (use TWL4030_MODULE_PM_MASTER)
+ */
+
+#define TWL4030_PM_MASTER_CFG_P1_TRANSITION 0x00
+#define TWL4030_PM_MASTER_CFG_P2_TRANSITION 0x01
+#define TWL4030_PM_MASTER_CFG_P3_TRANSITION 0x02
+#define TWL4030_PM_MASTER_CFG_P123_TRANSITION 0x03
+#define TWL4030_PM_MASTER_STS_BOOT 0x04
+#define TWL4030_PM_MASTER_CFG_BOOT 0x05
+#define TWL4030_PM_MASTER_SHUNDAN 0x06
+#define TWL4030_PM_MASTER_BOOT_BCI 0x07
+#define TWL4030_PM_MASTER_CFG_PWRANA1 0x08
+#define TWL4030_PM_MASTER_CFG_PWRANA2 0x09
+#define TWL4030_PM_MASTER_BACKUP_MISC_STS 0x0a
+#define TWL4030_PM_MASTER_BACKUP_MISC_CFG 0x0b
+#define TWL4030_PM_MASTER_BACKUP_MISC_TST 0x0c
+#define TWL4030_PM_MASTER_PROTECT_KEY 0x0d
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS 0x0e
+#define TWL4030_PM_MASTER_P1_SW_EVENTS 0x0f
+#define TWL4030_PM_MASTER_P2_SW_EVENTS 0x10
+#define TWL4030_PM_MASTER_P3_SW_EVENTS 0x11
+#define TWL4030_PM_MASTER_STS_P123_STATE 0x12
+#define TWL4030_PM_MASTER_PB_CFG 0x13
+#define TWL4030_PM_MASTER_PB_WORD_MSB 0x14
+#define TWL4030_PM_MASTER_PB_WORD_LSB 0x15
+#define TWL4030_PM_MASTER_SEQ_ADD_W2P 0x1b
+#define TWL4030_PM_MASTER_SEQ_ADD_P2A 0x1c
+#define TWL4030_PM_MASTER_SEQ_ADD_A2W 0x1d
+#define TWL4030_PM_MASTER_SEQ_ADD_A2S 0x1e
+#define TWL4030_PM_MASTER_SEQ_ADD_S2A12 0x1f
+#define TWL4030_PM_MASTER_SEQ_ADD_S2A3 0x20
+#define TWL4030_PM_MASTER_SEQ_ADD_WARM 0x21
+#define TWL4030_PM_MASTER_MEMORY_ADDRESS 0x22
+#define TWL4030_PM_MASTER_MEMORY_DATA 0x23
+
+#define TWL4030_PM_MASTER_KEY_CFG1 0xc0
+#define TWL4030_PM_MASTER_KEY_CFG2 0x0c
+
+#define TWL4030_PM_MASTER_KEY_TST1 0xe0
+#define TWL4030_PM_MASTER_KEY_TST2 0x0e
+
+#define TWL4030_PM_MASTER_GLOBAL_TST 0xb6
+
+/*----------------------------------------------------------------------*/
+
/* Power bus message definitions */

/* The TWL4030/5030 splits its power-management resources (the various
--
1.7.2.1.6.g61bf12

2010-08-18 06:21:07

by Felipe Balbi

[permalink] [raw]
Subject: [PATCH 3/4] mfd: twl4030-power: switch over to defines in twl.h

From: Felipe Balbi <[email protected]>

use the new definitions on twl header for code
consistency.

Signed-off-by: Felipe Balbi <[email protected]>
---
drivers/mfd/twl4030-power.c | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 7efa878..16422de0 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -63,10 +63,6 @@ static u8 twl4030_start_script_address = 0x2b;
#define R_MEMORY_ADDRESS PHY_TO_OFF_PM_MASTER(0x59)
#define R_MEMORY_DATA PHY_TO_OFF_PM_MASTER(0x5a)

-#define R_PROTECT_KEY 0x0E
-#define R_KEY_1 0xC0
-#define R_KEY_2 0x0C
-
/* resource configuration registers
<RESOURCE>_DEV_GRP at address 'n+0'
<RESOURCE>_TYPE at address 'n+1'
@@ -465,15 +461,17 @@ int twl4030_remove_script(u8 flags)
{
int err = 0;

- err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_1,
- R_PROTECT_KEY);
+ err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
+ TWL4030_PM_MASTER_KEY_CFG1,
+ TWL4030_PM_MASTER_PROTECT_KEY);
if (err) {
pr_err("twl4030: unable to unlock PROTECT_KEY\n");
return err;
}

- err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_2,
- R_PROTECT_KEY);
+ err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
+ TWL4030_PM_MASTER_KEY_CFG2,
+ TWL4030_PM_MASTER_PROTECT_KEY);
if (err) {
pr_err("twl4030: unable to unlock PROTECT_KEY\n");
return err;
@@ -504,7 +502,8 @@ int twl4030_remove_script(u8 flags)
return err;
}

- err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY);
+ err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
+ TWL4030_PM_MASTER_PROTECT_KEY);
if (err)
pr_err("TWL4030 Unable to relock registers\n");

@@ -518,13 +517,15 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
struct twl4030_resconfig *resconfig;
u8 address = twl4030_start_script_address;

- err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_1,
- R_PROTECT_KEY);
+ err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
+ TWL4030_PM_MASTER_KEY_CFG1,
+ TWL4030_PM_MASTER_PROTECT_KEY);
if (err)
goto unlock;

- err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_2,
- R_PROTECT_KEY);
+ err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
+ TWL4030_PM_MASTER_KEY_CFG2,
+ TWL4030_PM_MASTER_PROTECT_KEY);
if (err)
goto unlock;

@@ -546,7 +547,8 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
}
}

- err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY);
+ err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
+ TWL4030_PM_MASTER_PROTECT_KEY);
if (err)
pr_err("TWL4030 Unable to relock registers\n");
return;
--
1.7.2.1.6.g61bf12

2010-08-18 06:33:28

by Gopinath, Thara

[permalink] [raw]
Subject: RE: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h



>>-----Original Message-----
>>From: [email protected] [mailto:[email protected]] On Behalf Of
>>[email protected]
>>Sent: Wednesday, August 18, 2010 11:50 AM
>>To: Samuel Ortiz
>>Cc: [email protected]; [email protected]; Tony Lindgren; Andrew Morton; Felipe
>>Balbi
>>Subject: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h
>>
>>From: Felipe Balbi <[email protected]>
>>
>>use the new definitions on twl header for code
>>consistency.
>>
>>Signed-off-by: Felipe Balbi <[email protected]>
>>---
>> drivers/mfd/twl-core.c | 21 +++++++++------------
>> 1 files changed, 9 insertions(+), 12 deletions(-)
>>
>>diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
>>index 720e099..9689ecf 100644
>>--- a/drivers/mfd/twl-core.c
>>+++ b/drivers/mfd/twl-core.c
>>@@ -202,12 +202,6 @@
>>
>> /* Few power values */
>> #define R_CFG_BOOT 0x05
>>-#define R_PROTECT_KEY 0x0E
>>-
>>-/* access control values for R_PROTECT_KEY */
>>-#define KEY_UNLOCK1 0xce
>>-#define KEY_UNLOCK2 0xec
>>-#define KEY_LOCK 0x00
>>
>> /* some fields in R_CFG_BOOT */
>> #define HFCLK_FREQ_19p2_MHZ (1 << 0)
>>@@ -846,8 +840,8 @@ static inline int __init protect_pm_master(void)
>> {
>> int e = 0;
>>
>>- e = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_LOCK,
>>- R_PROTECT_KEY);
>>+ e = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
>>+ TWL4030_PM_MASTER_PROTECT_KEY);

Hello Felipe,

R_PROTECT_KEY offset is 0xE where as the new TWL4030_PM_MASTER_PROTECT_KEY
is defined as 0xd. I have not checked the trm to see which is correct. But
I hope this is a conscious change. Else we will end up breaking the functionality.
Also if this is a conscious change may be you should mention it in the patch
description. This comment applies to all other places where R_PROTECT_KEY has
been replaced with TWL4030_PM_MASTER_PROTECT_KEY in this patch as well as in
patch 3/4 and patch 4/4.

Regards
Thara

>> return e;
>> }
>>
>>@@ -855,10 +849,13 @@ static inline int __init unprotect_pm_master(void)
>> {
>> int e = 0;
>>
>>- e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_UNLOCK1,
>>- R_PROTECT_KEY);
>>- e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_UNLOCK2,
>>- R_PROTECT_KEY);
>>+ e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
>>+ TWL4030_PM_MASTER_KEY_CFG1,
>>+ TWL4030_PM_MASTER_PROTECT_KEY);
>>+ e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
>>+ TWL4030_PM_MASTER_KEY_CFG2,
>>+ TWL4030_PM_MASTER_PROTECT_KEY);
>>+
>> return e;
>> }
>>
>>--
>>1.7.2.1.6.g61bf12
>>
>>--
>>To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>>the body of a message to [email protected]
>>More majordomo info at http://vger.kernel.org/majordomo-info.html

2010-08-18 07:03:12

by Gopinath, Thara

[permalink] [raw]
Subject: RE: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h



>>-----Original Message-----
>>From: Felipe Balbi [mailto:[email protected]]
>>Sent: Wednesday, August 18, 2010 12:29 PM
>>To: Gopinath, Thara
>>Cc: Balbi Felipe (Nokia-MS/Helsinki); Samuel Ortiz; [email protected]; linux-
>>[email protected]; Tony Lindgren; Andrew Morton
>>Subject: Re: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h
>>
>>On Wed, Aug 18, 2010 at 08:32:57AM +0200, ext Gopinath, Thara wrote:
>>>R_PROTECT_KEY offset is 0xE where as the new TWL4030_PM_MASTER_PROTECT_KEY
>>>is defined as 0xd. I have not checked the trm to see which is correct. But
>>
>>you can use either 0xc0|0x0c or 0xce|0xec, both will work are unlock
>>keys.

No I am not talking about the key values. I was talking about the register offset
for TWL4030_PM_MASTER_PROTECT_KEY. My question is, is it ok for it to be 0xd or 0xe.
Earlier we were using 0xd and in the new implementation it has been changed to 0xe.

Regards
Thara

2010-08-18 07:04:10

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h

On Wed, Aug 18, 2010 at 08:32:57AM +0200, ext Gopinath, Thara wrote:
>R_PROTECT_KEY offset is 0xE where as the new TWL4030_PM_MASTER_PROTECT_KEY
>is defined as 0xd. I have not checked the trm to see which is correct. But

you can use either 0xc0|0x0c or 0xce|0xec, both will work are unlock
keys.

--
balbi

DefectiveByDesign.org

2010-08-18 07:04:26

by Gopinath, Thara

[permalink] [raw]
Subject: RE: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h



>>-----Original Message-----
>>From: Gopinath, Thara
>>Sent: Wednesday, August 18, 2010 12:33 PM
>>To: '[email protected]'
>>Cc: Samuel Ortiz; [email protected]; [email protected]; Tony Lindgren; Andrew
>>Morton
>>Subject: RE: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h
>>
>>
>>
>>>>-----Original Message-----
>>>>From: Felipe Balbi [mailto:[email protected]]
>>>>Sent: Wednesday, August 18, 2010 12:29 PM
>>>>To: Gopinath, Thara
>>>>Cc: Balbi Felipe (Nokia-MS/Helsinki); Samuel Ortiz; [email protected]; linux-
>>>>[email protected]; Tony Lindgren; Andrew Morton
>>>>Subject: Re: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h
>>>>
>>>>On Wed, Aug 18, 2010 at 08:32:57AM +0200, ext Gopinath, Thara wrote:
>>>>>R_PROTECT_KEY offset is 0xE where as the new TWL4030_PM_MASTER_PROTECT_KEY
>>>>>is defined as 0xd. I have not checked the trm to see which is correct. But
>>>>
>>>>you can use either 0xc0|0x0c or 0xce|0xec, both will work are unlock
>>>>keys.
>>
>>No I am not talking about the key values. I was talking about the register offset
>>for TWL4030_PM_MASTER_PROTECT_KEY. My question is, is it ok for it to be 0xd or 0xe.
>>Earlier we were using 0xd and in the new implementation it has been changed to 0xe.

Typo. Earlier we were using 0xe and in the new implementation it has been changed to 0xd.

Regards
Thara

2010-08-18 07:11:24

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h

Hi,

On Wed, Aug 18, 2010 at 09:03:44AM +0200, ext Gopinath, Thara wrote:
>>>No I am not talking about the key values. I was talking about the register offset
>>>for TWL4030_PM_MASTER_PROTECT_KEY. My question is, is it ok for it to be 0xd or 0xe.
>>>Earlier we were using 0xd and in the new implementation it has been changed to 0xe.
>
>Typo. Earlier we were using 0xe and in the new implementation it has
>been changed to 0xd.

you're right, I'm not sure how I came up with that value since the TRM
shows 0x0e, maybe a copy&paste error. Will change patch 1.

--
balbi

DefectiveByDesign.org

2010-08-18 07:17:02

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h

Hi,

On Wed, Aug 18, 2010 at 09:10:22AM +0200, Balbi Felipe (Nokia-MS/Helsinki) wrote:
>On Wed, Aug 18, 2010 at 09:03:44AM +0200, ext Gopinath, Thara wrote:
>>>>No I am not talking about the key values. I was talking about the register offset
>>>>for TWL4030_PM_MASTER_PROTECT_KEY. My question is, is it ok for it to be 0xd or 0xe.
>>>>Earlier we were using 0xd and in the new implementation it has been changed to 0xe.
>>
>>Typo. Earlier we were using 0xe and in the new implementation it has
>>been changed to 0xd.
>
>you're right, I'm not sure how I came up with that value since the TRM
>shows 0x0e, maybe a copy&paste error. Will change patch 1.

ok, it's because there's no register 0x0a. And I missed that when
defined the register space. Good catch, thanks. I wonder why it didn't
fail to write to that register address :-?

--
balbi

DefectiveByDesign.org

2010-08-18 07:20:32

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 1/4] i2c: twl: add register defines for pm master module

hi,

On Wed, Aug 18, 2010 at 08:19:34AM +0200, Balbi Felipe (Nokia-MS/Helsinki) wrote:
>From: Felipe Balbi <[email protected]>
>
>Some modules already need to talk to at least PROTECT_KEY
>register, while at that, add defines to the entire register
>space.
>
>Signed-off-by: Felipe Balbi <[email protected]>
>---

here's updated patch with correct register space

8<--------------------------------------------------

From a1021f7be2c7e277b303e6930285832f97258f85 Mon Sep 17 00:00:00 2001
From: Felipe Balbi <[email protected]>
Date: Thu, 1 Jul 2010 13:24:37 +0300
Subject: [PATCH 1/4] i2c: twl: add register defines for pm master module

Some modules already need to talk to at least PROTECT_KEY
register, while at that, add defines to the entire register
space.

Signed-off-by: Felipe Balbi <[email protected]>
---
include/linux/i2c/twl.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 6de90bf..9b17244 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -357,6 +357,52 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);

/*----------------------------------------------------------------------*/

+/*
+ * PM Master module register offsets (use TWL4030_MODULE_PM_MASTER)
+ */
+
+#define TWL4030_PM_MASTER_CFG_P1_TRANSITION 0x00
+#define TWL4030_PM_MASTER_CFG_P2_TRANSITION 0x01
+#define TWL4030_PM_MASTER_CFG_P3_TRANSITION 0x02
+#define TWL4030_PM_MASTER_CFG_P123_TRANSITION 0x03
+#define TWL4030_PM_MASTER_STS_BOOT 0x04
+#define TWL4030_PM_MASTER_CFG_BOOT 0x05
+#define TWL4030_PM_MASTER_SHUNDAN 0x06
+#define TWL4030_PM_MASTER_BOOT_BCI 0x07
+#define TWL4030_PM_MASTER_CFG_PWRANA1 0x08
+#define TWL4030_PM_MASTER_CFG_PWRANA2 0x09
+#define TWL4030_PM_MASTER_BACKUP_MISC_STS 0x0b
+#define TWL4030_PM_MASTER_BACKUP_MISC_CFG 0x0c
+#define TWL4030_PM_MASTER_BACKUP_MISC_TST 0x0d
+#define TWL4030_PM_MASTER_PROTECT_KEY 0x0e
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS 0x0f
+#define TWL4030_PM_MASTER_P1_SW_EVENTS 0x10
+#define TWL4030_PM_MASTER_P2_SW_EVENTS 0x11
+#define TWL4030_PM_MASTER_P3_SW_EVENTS 0x12
+#define TWL4030_PM_MASTER_STS_P123_STATE 0x13
+#define TWL4030_PM_MASTER_PB_CFG 0x14
+#define TWL4030_PM_MASTER_PB_WORD_MSB 0x15
+#define TWL4030_PM_MASTER_PB_WORD_LSB 0x16
+#define TWL4030_PM_MASTER_SEQ_ADD_W2P 0x1c
+#define TWL4030_PM_MASTER_SEQ_ADD_P2A 0x1d
+#define TWL4030_PM_MASTER_SEQ_ADD_A2W 0x1e
+#define TWL4030_PM_MASTER_SEQ_ADD_A2S 0x1f
+#define TWL4030_PM_MASTER_SEQ_ADD_S2A12 0x20
+#define TWL4030_PM_MASTER_SEQ_ADD_S2A3 0x21
+#define TWL4030_PM_MASTER_SEQ_ADD_WARM 0x22
+#define TWL4030_PM_MASTER_MEMORY_ADDRESS 0x23
+#define TWL4030_PM_MASTER_MEMORY_DATA 0x24
+
+#define TWL4030_PM_MASTER_KEY_CFG1 0xc0
+#define TWL4030_PM_MASTER_KEY_CFG2 0x0c
+
+#define TWL4030_PM_MASTER_KEY_TST1 0xe0
+#define TWL4030_PM_MASTER_KEY_TST2 0x0e
+
+#define TWL4030_PM_MASTER_GLOBAL_TST 0xb6
+
+/*----------------------------------------------------------------------*/
+
/* Power bus message definitions */

/* The TWL4030/5030 splits its power-management resources (the various
--
1.7.2.1.6.g61bf12

--
balbi

DefectiveByDesign.org

2010-08-18 14:21:23

by Gopinath, Thara

[permalink] [raw]
Subject: RE: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h



>>-----Original Message-----
>>From: Felipe Balbi [mailto:[email protected]]
>>Sent: Wednesday, August 18, 2010 12:46 PM
>>To: Balbi Felipe (Nokia-MS/Helsinki)
>>Cc: Gopinath, Thara; Samuel Ortiz; [email protected]; [email protected]; Tony
>>Lindgren; Andrew Morton
>>Subject: Re: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h
>>
>>Hi,
>>
>>On Wed, Aug 18, 2010 at 09:10:22AM +0200, Balbi Felipe (Nokia-MS/Helsinki) wrote:
>>>On Wed, Aug 18, 2010 at 09:03:44AM +0200, ext Gopinath, Thara wrote:
>>>>>>No I am not talking about the key values. I was talking about the register offset
>>>>>>for TWL4030_PM_MASTER_PROTECT_KEY. My question is, is it ok for it to be 0xd or 0xe.
>>>>>>Earlier we were using 0xd and in the new implementation it has been changed to 0xe.
>>>>
>>>>Typo. Earlier we were using 0xe and in the new implementation it has
>>>>been changed to 0xd.
>>>
>>>you're right, I'm not sure how I came up with that value since the TRM
>>>shows 0x0e, maybe a copy&paste error. Will change patch 1.
>>
>>ok, it's because there's no register 0x0a. And I missed that when
>>defined the register space. Good catch, thanks. I wonder why it didn't
>>fail to write to that register address :-?

0xd is a valid register offset. Hence no crash. Anyways I saw your new
patch. Looks ok to me.

Regards
Thara

2010-08-20 22:11:52

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h

Hi Felipe,

On Wed, Aug 18, 2010 at 10:16:19AM +0300, Felipe Balbi wrote:
> Hi,
>
> On Wed, Aug 18, 2010 at 09:10:22AM +0200, Balbi Felipe (Nokia-MS/Helsinki) wrote:
> >On Wed, Aug 18, 2010 at 09:03:44AM +0200, ext Gopinath, Thara wrote:
> >>>>No I am not talking about the key values. I was talking about the register offset
> >>>>for TWL4030_PM_MASTER_PROTECT_KEY. My question is, is it ok for it to be 0xd or 0xe.
> >>>>Earlier we were using 0xd and in the new implementation it has been changed to 0xe.
> >>
> >>Typo. Earlier we were using 0xe and in the new implementation it has
> >>been changed to 0xd.
> >
> >you're right, I'm not sure how I came up with that value since the TRM
> >shows 0x0e, maybe a copy&paste error. Will change patch 1.
>
> ok, it's because there's no register 0x0a. And I missed that when
> defined the register space. Good catch, thanks.
Should I expect a new patch then ?

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

2010-08-21 14:08:36

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 2/4] mfd: twl-core: switch over to defines in twl.h

On Sat, Aug 21, 2010 at 12:11:46AM +0200, ext Samuel Ortiz wrote:
>Should I expect a new patch then ?

it's patch 1/4. I already replied to that patch with the new version:

https://patchwork.kernel.org/patch/120084/

--
balbi

DefectiveByDesign.org