linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] Group and resource assignments for TWL4030
@ 2009-02-10 13:11 Peter 'p2' De Schrijver
  2009-02-10 13:11 ` [PATCH 1/1] " Peter 'p2' De Schrijver
  2009-02-13 20:55 ` [PATCH 0/1] " David Brownell
  0 siblings, 2 replies; 14+ messages in thread
From: Peter 'p2' De Schrijver @ 2009-02-10 13:11 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This patch introduces support for board specific group assignments of TWL4030
resources. The resource type and type2 fields can also be specified.

Peter 'p2' De Schrijver (1):
  Group and resource assignments for TWL4030

 drivers/mfd/twl4030-power.c |   95 ++++++++++++++++++++++++++++++++++++++++++-
 include/linux/i2c/twl4030.h |   41 ++++++++++++++++++-
 2 files changed, 134 insertions(+), 2 deletions(-)


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

* [PATCH 1/1] Group and resource assignments for TWL4030
  2009-02-10 13:11 [PATCH 0/1] Group and resource assignments for TWL4030 Peter 'p2' De Schrijver
@ 2009-02-10 13:11 ` Peter 'p2' De Schrijver
  2009-02-10 13:28   ` Felipe Balbi
  2009-03-03 23:28   ` David Brownell
  2009-02-13 20:55 ` [PATCH 0/1] " David Brownell
  1 sibling, 2 replies; 14+ messages in thread
From: Peter 'p2' De Schrijver @ 2009-02-10 13:11 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver


Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 drivers/mfd/twl4030-power.c |   95 ++++++++++++++++++++++++++++++++++++++++++-
 include/linux/i2c/twl4030.h |   41 ++++++++++++++++++-
 2 files changed, 134 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index d9d1655..c558127 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -38,6 +38,8 @@ static u8 triton_next_free_address = 0x2b;
 #define PHY_TO_OFF_PM_MASTER(p)		(p - 0x36)
 #define PHY_TO_OFF_PM_RECEIVER(p)	(p - 0x5b)
 
+#define NUM_OF_RESOURCES	28
+
 /* resource - hfclk */
 #define R_HFCLKOUT_DEV_GRP 	PHY_TO_OFF_PM_RECEIVER(0xe6)
 
@@ -66,6 +68,42 @@ static u8 triton_next_free_address = 0x2b;
 #define KEY_1			0xC0
 #define KEY_2			0x0C
 
+/* resource configuration registers */
+
+#define DEVGROUP_OFFSET		0
+#define TYPE_OFFSET		1
+
+static int __initdata res_config_addrs[] = {
+	[1] = 0x17,
+	[2] = 0x1b,
+	[3] = 0x1f,
+	[4] = 0x23,
+	[5] = 0x27,
+	[6] = 0x2b,
+	[7] = 0x2f,
+	[8] = 0x33,
+	[9] = 0x37,
+	[10] = 0x3b,
+	[11] = 0x3f,
+	[12] = 0x43,
+	[13] = 0x47,
+	[14] = 0x4b,
+	[15] = 0x55,
+	[16] = 0x63,
+	[17] = 0x71,
+	[18] = 0x74,
+	[19] = 0x77,
+	[20] = 0x7a,
+	[21] = 0x7f,
+	[22] = 0x82,
+	[23] = 0x85,
+	[24] = 0x88,
+	[25] = 0x8b,
+	[26] = 0x8e,
+	[27] = 0x91,
+	[28] = 0x94,
+};
+
 static int __init twl4030_write_script_byte(u8 address, u8 byte)
 {
 	int err;
@@ -245,10 +283,57 @@ static int __init load_triton_script(struct twl4030_script *tscript)
 	return err;
 }
 
+static void __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
+{
+	int rconfig_addr;
+	u8 type;
+
+	if (rconfig->resource > NUM_OF_RESOURCES) {
+		printk(KERN_ERR
+			"TWL4030 Resource %d does not exist\n",
+			rconfig->resource);
+		return;
+	}
+
+	rconfig_addr = res_config_addrs[rconfig->resource];
+
+	/* Set resource group */
+
+	if (rconfig->devgroup >= 0)
+		twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+					rconfig->devgroup << 5,
+					rconfig_addr + DEVGROUP_OFFSET);
+
+	/* Set resource types */
+
+	if (twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER,
+					&type,
+					rconfig_addr + TYPE_OFFSET) < 0) {
+		printk(KERN_ERR
+			"TWL4030 Resource %d type could not read\n",
+			rconfig->resource);
+		return;
+	}
+
+	if (rconfig->type >= 0) {
+		type &= ~7;
+		type |= rconfig->type;
+	}
+
+	if (rconfig->type2 >= 0) {
+		type &= ~(3 << 3);
+		type |= rconfig->type2 << 3;
+	}
+
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+				type, rconfig_addr + TYPE_OFFSET);
+}
+
 void __init twl4030_power_init(struct twl4030_power_data *triton2_scripts)
 {
 	int err = 0;
 	int i;
+	struct twl4030_resconfig *resconfig;
 
 	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_1,
 				R_PROTECT_KEY);
@@ -258,12 +343,20 @@ void __init twl4030_power_init(struct twl4030_power_data *triton2_scripts)
 		printk(KERN_ERR
 			"TWL4030 Unable to unlock registers\n");
 
-	for (i = 0; i < triton2_scripts->size; i++) {
+	for (i = 0; i < triton2_scripts->scripts_size; i++) {
 		err = load_triton_script(triton2_scripts->scripts[i]);
 		if (err)
 			break;
 	}
 
+	resconfig = triton2_scripts->resource_config;
+	if (resconfig) {
+		while (resconfig->resource) {
+			twl4030_configure_resource(resconfig);
+			resconfig++;
+		}
+	}
+
 	if (twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY))
 		printk(KERN_ERR
 			"TWL4030 Unable to relock registers\n");
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index 93d483d..e6ce1cd 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -243,6 +243,37 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
 #define RES_STATE_SLEEP		0x8
 #define RES_STATE_OFF		0x0
 
+/* Power resources */
+
+#define RES_VAUX1		1
+#define RES_VAUX2		2
+#define RES_VAUX3		3
+#define RES_VAUX4		4
+#define RES_VMMC1		5
+#define RES_VMMC2		6
+#define RES_VPLL1		7
+#define RES_VPLL2		8
+#define RES_VSIM		9
+#define RES_VDAC		10
+#define RES_VINTANA1		11
+#define RES_VINTANA2		12
+#define RES_VINTDIG		13
+#define RES_VIO			14
+#define RES_VDD1		15
+#define RES_VDD2		16
+#define RES_VUSB_1v5		17
+#define RES_VUSB_1v8		18
+#define RES_VUSB_3v1		19
+#define RES_VUSBCP		20
+#define RES_REGEN		21
+#define RES_NRES_PWRON		22
+#define RES_CLKEN		23
+#define RES_SYSEN		24
+#define RES_HFCLKOUT		25
+#define RES_32KCLKOUT		26
+#define RES_RESET		27
+#define RES_Main_Ref		28
+
 /*
  * Power Bus Message Format ... these can be sent individually by Linux,
  * but are usually part of downloaded scripts that are run when various
@@ -334,9 +365,17 @@ struct twl4030_script {
 #define TRITON_SLEEP_SCRIPT	(1<<3)
 };
 
+struct twl4030_resconfig {
+	int resource;
+	int devgroup;
+	int type;
+	int type2;
+};
+
 struct twl4030_power_data {
 	struct twl4030_script **scripts;
-	unsigned size;
+	unsigned scripts_size;
+	struct twl4030_resconfig *resource_config;
 };
 
 struct twl4030_platform_data {
-- 
1.5.6.3


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

* Re: [PATCH 1/1] Group and resource assignments for TWL4030
  2009-02-10 13:11 ` [PATCH 1/1] " Peter 'p2' De Schrijver
@ 2009-02-10 13:28   ` Felipe Balbi
  2009-03-03 23:28   ` David Brownell
  1 sibling, 0 replies; 14+ messages in thread
From: Felipe Balbi @ 2009-02-10 13:28 UTC (permalink / raw)
  To: De-Schrijver Peter (Nokia-D/Helsinki); +Cc: linux-omap

On Tue, Feb 10, 2009 at 02:11:35PM +0100, Peter 'p2' De Schrijver wrote:
> 
> Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
> ---
>  drivers/mfd/twl4030-power.c |   95 ++++++++++++++++++++++++++++++++++++++++++-
>  include/linux/i2c/twl4030.h |   41 ++++++++++++++++++-
>  2 files changed, 134 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> index d9d1655..c558127 100644
> --- a/drivers/mfd/twl4030-power.c
> +++ b/drivers/mfd/twl4030-power.c
> @@ -38,6 +38,8 @@ static u8 triton_next_free_address = 0x2b;
>  #define PHY_TO_OFF_PM_MASTER(p)                (p - 0x36)
>  #define PHY_TO_OFF_PM_RECEIVER(p)      (p - 0x5b)
> 
> +#define NUM_OF_RESOURCES       28
> +
>  /* resource - hfclk */
>  #define R_HFCLKOUT_DEV_GRP     PHY_TO_OFF_PM_RECEIVER(0xe6)
> 
> @@ -66,6 +68,42 @@ static u8 triton_next_free_address = 0x2b;
>  #define KEY_1                  0xC0
>  #define KEY_2                  0x0C
> 
> +/* resource configuration registers */
> +
> +#define DEVGROUP_OFFSET                0
> +#define TYPE_OFFSET            1
> +
> +static int __initdata res_config_addrs[] = {
> +       [1] = 0x17,
> +       [2] = 0x1b,
> +       [3] = 0x1f,
> +       [4] = 0x23,
> +       [5] = 0x27,
> +       [6] = 0x2b,
> +       [7] = 0x2f,
> +       [8] = 0x33,
> +       [9] = 0x37,
> +       [10] = 0x3b,
> +       [11] = 0x3f,
> +       [12] = 0x43,
> +       [13] = 0x47,
> +       [14] = 0x4b,
> +       [15] = 0x55,
> +       [16] = 0x63,
> +       [17] = 0x71,
> +       [18] = 0x74,
> +       [19] = 0x77,
> +       [20] = 0x7a,
> +       [21] = 0x7f,
> +       [22] = 0x82,
> +       [23] = 0x85,
> +       [24] = 0x88,
> +       [25] = 0x8b,
> +       [26] = 0x8e,
> +       [27] = 0x91,
> +       [28] = 0x94,
> +};
> +
>  static int __init twl4030_write_script_byte(u8 address, u8 byte)
>  {
>         int err;
> @@ -245,10 +283,57 @@ static int __init load_triton_script(struct twl4030_script *tscript)
>         return err;
>  }
> 
> +static void __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
> +{
> +       int rconfig_addr;
> +       u8 type;
> +
> +       if (rconfig->resource > NUM_OF_RESOURCES) {
> +               printk(KERN_ERR
> +                       "TWL4030 Resource %d does not exist\n",
> +                       rconfig->resource);
> +               return;
> +       }
> +
> +       rconfig_addr = res_config_addrs[rconfig->resource];
> +
> +       /* Set resource group */
> +
> +       if (rconfig->devgroup >= 0)
> +               twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
> +                                       rconfig->devgroup << 5,
> +                                       rconfig_addr + DEVGROUP_OFFSET);
> +
> +       /* Set resource types */
> +
> +       if (twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER,
> +                                       &type,
> +                                       rconfig_addr + TYPE_OFFSET) < 0) {
> +               printk(KERN_ERR
> +                       "TWL4030 Resource %d type could not read\n",
> +                       rconfig->resource);
> +               return;
> +       }
> +
> +       if (rconfig->type >= 0) {
> +               type &= ~7;
> +               type |= rconfig->type;
> +       }
> +
> +       if (rconfig->type2 >= 0) {
> +               type &= ~(3 << 3);
> +               type |= rconfig->type2 << 3;
> +       }
> +
> +       twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
> +                               type, rconfig_addr + TYPE_OFFSET);
> +}
> +
>  void __init twl4030_power_init(struct twl4030_power_data *triton2_scripts)
>  {
>         int err = 0;
>         int i;
> +       struct twl4030_resconfig *resconfig;
> 
>         err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_1,
>                                 R_PROTECT_KEY);
> @@ -258,12 +343,20 @@ void __init twl4030_power_init(struct twl4030_power_data *triton2_scripts)
>                 printk(KERN_ERR
>                         "TWL4030 Unable to unlock registers\n");
> 
> -       for (i = 0; i < triton2_scripts->size; i++) {
> +       for (i = 0; i < triton2_scripts->scripts_size; i++) {
>                 err = load_triton_script(triton2_scripts->scripts[i]);
>                 if (err)
>                         break;
>         }
> 
> +       resconfig = triton2_scripts->resource_config;
> +       if (resconfig) {
> +               while (resconfig->resource) {
> +                       twl4030_configure_resource(resconfig);
> +                       resconfig++;
> +               }
> +       }
> +
>         if (twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY))
>                 printk(KERN_ERR
>                         "TWL4030 Unable to relock registers\n");
> diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
> index 93d483d..e6ce1cd 100644
> --- a/include/linux/i2c/twl4030.h
> +++ b/include/linux/i2c/twl4030.h
> @@ -243,6 +243,37 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
>  #define RES_STATE_SLEEP                0x8
>  #define RES_STATE_OFF          0x0
> 
> +/* Power resources */
> +
> +#define RES_VAUX1              1
> +#define RES_VAUX2              2
> +#define RES_VAUX3              3
> +#define RES_VAUX4              4
> +#define RES_VMMC1              5
> +#define RES_VMMC2              6
> +#define RES_VPLL1              7
> +#define RES_VPLL2              8
> +#define RES_VSIM               9
> +#define RES_VDAC               10
> +#define RES_VINTANA1           11
> +#define RES_VINTANA2           12
> +#define RES_VINTDIG            13
> +#define RES_VIO                        14
> +#define RES_VDD1               15
> +#define RES_VDD2               16
> +#define RES_VUSB_1v5           17
> +#define RES_VUSB_1v8           18
> +#define RES_VUSB_3v1           19
> +#define RES_VUSBCP             20
> +#define RES_REGEN              21
> +#define RES_NRES_PWRON         22
> +#define RES_CLKEN              23
> +#define RES_SYSEN              24
> +#define RES_HFCLKOUT           25
> +#define RES_32KCLKOUT          26
> +#define RES_RESET              27
> +#define RES_Main_Ref           28

These are not being used anywhere, I guess you wanted to use them in the
array in the beginning of the patch ??

-- 
balbi

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

* Re: [PATCH 0/1] Group and resource assignments for TWL4030
  2009-02-10 13:11 [PATCH 0/1] Group and resource assignments for TWL4030 Peter 'p2' De Schrijver
  2009-02-10 13:11 ` [PATCH 1/1] " Peter 'p2' De Schrijver
@ 2009-02-13 20:55 ` David Brownell
  2009-02-15 16:48   ` Peter 'p2' De Schrijver
  1 sibling, 1 reply; 14+ messages in thread
From: David Brownell @ 2009-02-13 20:55 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Tuesday 10 February 2009, Peter 'p2' De Schrijver wrote:
> 
> This patch introduces support for board specific group assignments of TWL4030
> resources. The resource type and type2 fields can also be specified.

Do we have any real examples yet of needing to assign
resources to anything other than P1 (processor)?

I'd sort of like to stick to simplifying assumptions,
notably "only P1 matters", until we have a clear need
to switch to another one.

This sort of thing ties into some patches I have
floating around, to disable regulators turned on
inappropriately by the boot loader.  I was doing
that in a late_initcall in the regulator driver ...
but it's a bit messy, as the regulator framework
has deficiencies in that area (too).

- dave

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

* Re: [PATCH 0/1] Group and resource assignments for TWL4030
  2009-02-13 20:55 ` [PATCH 0/1] " David Brownell
@ 2009-02-15 16:48   ` Peter 'p2' De Schrijver
  2009-02-27 16:59     ` Tony Lindgren
  0 siblings, 1 reply; 14+ messages in thread
From: Peter 'p2' De Schrijver @ 2009-02-15 16:48 UTC (permalink / raw)
  To: ext David Brownell; +Cc: linux-omap

On Fri, Feb 13, 2009 at 09:55:21PM +0100, ext David Brownell wrote:
> On Tuesday 10 February 2009, Peter 'p2' De Schrijver wrote:
> >
> > This patch introduces support for board specific group assignments of TWL4030
> > resources. The resource type and type2 fields can also be specified.
> 
> Do we have any real examples yet of needing to assign
> resources to anything other than P1 (processor)?
> 

Yes. On our custom hardware we use it to assign CLKEN to P3.

Cheers,

Peter.

-- 
goa is a state of mind

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

* Re: [PATCH 0/1] Group and resource assignments for TWL4030
  2009-02-15 16:48   ` Peter 'p2' De Schrijver
@ 2009-02-27 16:59     ` Tony Lindgren
  2009-03-03 23:38       ` David Brownell
  0 siblings, 1 reply; 14+ messages in thread
From: Tony Lindgren @ 2009-02-27 16:59 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: ext David Brownell, linux-omap

* Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com> [090215 08:49]:
> On Fri, Feb 13, 2009 at 09:55:21PM +0100, ext David Brownell wrote:
> > On Tuesday 10 February 2009, Peter 'p2' De Schrijver wrote:
> > >
> > > This patch introduces support for board specific group assignments of TWL4030
> > > resources. The resource type and type2 fields can also be specified.
> > 
> > Do we have any real examples yet of needing to assign
> > resources to anything other than P1 (processor)?
> > 
> 
> Yes. On our custom hardware we use it to assign CLKEN to P3.

BTW, this should be discussed and integrated via the driver lists,
in this case that's Samuel Ortiz and LKML.

Regards,

Tony

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

* Re: [PATCH 1/1] Group and resource assignments for TWL4030
  2009-02-10 13:11 ` [PATCH 1/1] " Peter 'p2' De Schrijver
  2009-02-10 13:28   ` Felipe Balbi
@ 2009-03-03 23:28   ` David Brownell
  1 sibling, 0 replies; 14+ messages in thread
From: David Brownell @ 2009-03-03 23:28 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Tuesday 10 February 2009, Peter 'p2' De Schrijver wrote:
> +struct twl4030_resconfig {
> +       int resource;
> +       int devgroup;
> +       int type;
> +       int type2;
> +};
> +

Make all those "u8" ... save 28 * 3 * 4 == 336 bytes
on a system that configures all 28 resources.  ;)


--
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

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

* Re: [PATCH 0/1] Group and resource assignments for TWL4030
  2009-02-27 16:59     ` Tony Lindgren
@ 2009-03-03 23:38       ` David Brownell
  2009-03-04 14:41         ` Peter 'p2' De Schrijver
  2009-03-06  0:16         ` Tony Lindgren
  0 siblings, 2 replies; 14+ messages in thread
From: David Brownell @ 2009-03-03 23:38 UTC (permalink / raw)
  To: Tony Lindgren, Peter 'p2' De Schrijver; +Cc: linux-omap

On Friday 27 February 2009, Tony Lindgren wrote:
> * Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com> [090215 08:49]:
> > On Fri, Feb 13, 2009 at 09:55:21PM +0100, ext David Brownell wrote:
> > > On Tuesday 10 February 2009, Peter 'p2' De Schrijver wrote:
> > > >
> > > > This patch introduces support for board specific group assignments of TWL4030
> > > > resources. The resource type and type2 fields can also be specified.
> > > 
> > > Do we have any real examples yet of needing to assign
> > > resources to anything other than P1 (processor)?
> > 
> > Yes. On our custom hardware we use it to assign CLKEN to P3.

P3 roughly translating to "system running", with
no regard to whether ARM(s) or DSP are active, yes?

I've seen hardware which hooks CLKEN to the enable
line for a 2.8V regulator, and REGEN to the enable
line for a 2.5V regulator.

Table 5-8 of the chip manual tells me those, along
with HFCLOCK and a few other resources, are already
assigned to the P3 (and P1 and P2) groups by device
reset.  So that use case isn't quite complete.  At
least some of this look like normal paranoia, to
defend against hardware and bootloader oddities.  ;)


I'm not sure how those should be modeled within
the regulator framework.  My first thought is to
just let those particular resources live outside
that framework, until there's a need for another
solution ... the main virtue of that framework is
to have a standard way for Linux to manage things,
but these are resources it won't be managing.
The secondary virtue of "visibility into hardware"
isn't very compelling here IMO.


> BTW, this should be discussed and integrated via the driver lists,
> in this case that's Samuel Ortiz and LKML.

Actually this is related to the twl4030-power.c
driver which has not yet gone upstream.  I'm not
sure there'd be much point to discussing this on
the PM list though.


So let me suggest a slightly different approach:

 - Peter updates $SUBJECT patch to address the
   comments from me (data shrink) and Felipe
   (use those RES_* symbols in res_config_addrs)

 - Tony merges that to the OMAP tree

 - Peter starts work on merging twl4030-power.c
   to mainline (discuss on LKML etc)

There will be a few more issues to sort with this
driver.  There are section warnings generated by
some of the platform code, and the generic script
doesn't work at all on Beagle.

- Dave


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

* Re: [PATCH 0/1] Group and resource assignments for TWL4030
  2009-03-03 23:38       ` David Brownell
@ 2009-03-04 14:41         ` Peter 'p2' De Schrijver
  2009-03-06  0:16         ` Tony Lindgren
  1 sibling, 0 replies; 14+ messages in thread
From: Peter 'p2' De Schrijver @ 2009-03-04 14:41 UTC (permalink / raw)
  To: ext David Brownell; +Cc: Tony Lindgren, linux-omap

On Wed, Mar 04, 2009 at 12:38:16AM +0100, ext David Brownell wrote:
> On Friday 27 February 2009, Tony Lindgren wrote:
> > * Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com> [090215 08:49]:
> > > On Fri, Feb 13, 2009 at 09:55:21PM +0100, ext David Brownell wrote:
> > > > On Tuesday 10 February 2009, Peter 'p2' De Schrijver wrote:
> > > > >
> > > > > This patch introduces support for board specific group assignments of TWL4030
> > > > > resources. The resource type and type2 fields can also be specified.
> > > > 
> > > > Do we have any real examples yet of needing to assign
> > > > resources to anything other than P1 (processor)?
> > > 
> > > Yes. On our custom hardware we use it to assign CLKEN to P3.
> 
> P3 roughly translating to "system running", with
> no regard to whether ARM(s) or DSP are active, yes?
> 

Depends on the board. We use P3 to control the system oscillator. The
SYSCLK_REQ output of OMAP3 is wired to the CLKREQ input on the TWL4030.
OMAP3 will disable SYSCLK_REQ when the system clock is no longer
necessary. (Eg, when going to chip retention).  This obviously only works if
CLKEN is only in P3.  (Otherwise it won't be turned off as P1 is still
active). A similar setup is used on the TI SDP3430 board.

Cheers,

Peter.

-- 
goa is a state of mind

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

* Re: [PATCH 0/1] Group and resource assignments for TWL4030
  2009-03-03 23:38       ` David Brownell
  2009-03-04 14:41         ` Peter 'p2' De Schrijver
@ 2009-03-06  0:16         ` Tony Lindgren
  2009-03-13 15:33           ` Peter 'p2' De Schrijver
  1 sibling, 1 reply; 14+ messages in thread
From: Tony Lindgren @ 2009-03-06  0:16 UTC (permalink / raw)
  To: David Brownell; +Cc: Peter 'p2' De Schrijver, linux-omap

* David Brownell <david-b@pacbell.net> [090303 15:38]:
> On Friday 27 February 2009, Tony Lindgren wrote:
> > * Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com> [090215 08:49]:
> > > On Fri, Feb 13, 2009 at 09:55:21PM +0100, ext David Brownell wrote:
> > > > On Tuesday 10 February 2009, Peter 'p2' De Schrijver wrote:
> > > > >
> > > > > This patch introduces support for board specific group assignments of TWL4030
> > > > > resources. The resource type and type2 fields can also be specified.
> > > > 
> > > > Do we have any real examples yet of needing to assign
> > > > resources to anything other than P1 (processor)?
> > > 
> > > Yes. On our custom hardware we use it to assign CLKEN to P3.
> 
> P3 roughly translating to "system running", with
> no regard to whether ARM(s) or DSP are active, yes?
> 
> I've seen hardware which hooks CLKEN to the enable
> line for a 2.8V regulator, and REGEN to the enable
> line for a 2.5V regulator.
> 
> Table 5-8 of the chip manual tells me those, along
> with HFCLOCK and a few other resources, are already
> assigned to the P3 (and P1 and P2) groups by device
> reset.  So that use case isn't quite complete.  At
> least some of this look like normal paranoia, to
> defend against hardware and bootloader oddities.  ;)
> 
> 
> I'm not sure how those should be modeled within
> the regulator framework.  My first thought is to
> just let those particular resources live outside
> that framework, until there's a need for another
> solution ... the main virtue of that framework is
> to have a standard way for Linux to manage things,
> but these are resources it won't be managing.
> The secondary virtue of "visibility into hardware"
> isn't very compelling here IMO.
> 
> 
> > BTW, this should be discussed and integrated via the driver lists,
> > in this case that's Samuel Ortiz and LKML.
> 
> Actually this is related to the twl4030-power.c
> driver which has not yet gone upstream.  I'm not
> sure there'd be much point to discussing this on
> the PM list though.
> 
> 
> So let me suggest a slightly different approach:
> 
>  - Peter updates $SUBJECT patch to address the
>    comments from me (data shrink) and Felipe
>    (use those RES_* symbols in res_config_addrs)
> 
>  - Tony merges that to the OMAP tree
> 
>  - Peter starts work on merging twl4030-power.c
>    to mainline (discuss on LKML etc)
> 
> There will be a few more issues to sort with this
> driver.  There are section warnings generated by
> some of the platform code, and the generic script
> doesn't work at all on Beagle.

This sounds OK to me as long as Peter is fine with that.

Tony

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

* [PATCH 0/1] Group and resource assignments for TWL4030
  2009-03-06  0:16         ` Tony Lindgren
@ 2009-03-13 15:33           ` Peter 'p2' De Schrijver
  2009-03-13 15:33             ` [PATCH 1/1] " Peter 'p2' De Schrijver
  0 siblings, 1 reply; 14+ messages in thread
From: Peter 'p2' De Schrijver @ 2009-03-13 15:33 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This patch introduces support for board specific group assignments of TWL4030
resources. The resource type and type2 fields can also be specified.

Peter 'p2' De Schrijver (1):
  Group and resource assignments for TWL4030

 drivers/mfd/twl4030-power.c |   96 ++++++++++++++++++++++++++++++++++++++++++-
 include/linux/i2c/twl4030.h |   41 ++++++++++++++++++-
 2 files changed, 135 insertions(+), 2 deletions(-)


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

* [PATCH 1/1] Group and resource assignments for TWL4030
  2009-03-13 15:33           ` Peter 'p2' De Schrijver
@ 2009-03-13 15:33             ` Peter 'p2' De Schrijver
  2009-03-13 23:11               ` David Brownell
  2009-03-14  1:16               ` [PATCH 1/1] Group and resource assignments for TWL4030 (v3) David Brownell
  0 siblings, 2 replies; 14+ messages in thread
From: Peter 'p2' De Schrijver @ 2009-03-13 15:33 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver


Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 drivers/mfd/twl4030-power.c |   96 ++++++++++++++++++++++++++++++++++++++++++-
 include/linux/i2c/twl4030.h |   41 ++++++++++++++++++-
 2 files changed, 135 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index d9d1655..f1d416c 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -38,6 +38,8 @@ static u8 triton_next_free_address = 0x2b;
 #define PHY_TO_OFF_PM_MASTER(p)		(p - 0x36)
 #define PHY_TO_OFF_PM_RECEIVER(p)	(p - 0x5b)
 
+#define NUM_OF_RESOURCES	28
+
 /* resource - hfclk */
 #define R_HFCLKOUT_DEV_GRP 	PHY_TO_OFF_PM_RECEIVER(0xe6)
 
@@ -66,6 +68,42 @@ static u8 triton_next_free_address = 0x2b;
 #define KEY_1			0xC0
 #define KEY_2			0x0C
 
+/* resource configuration registers */
+
+#define DEVGROUP_OFFSET		0
+#define TYPE_OFFSET		1
+
+static int res_config_addrs[] = {
+	[RES_VAUX1] = 0x17,
+	[RES_VAUX2] = 0x1b,
+	[RES_VAUX3] = 0x1f,
+	[RES_VAUX4] = 0x23,
+	[RES_VMMC1] = 0x27,
+	[RES_VMMC2] = 0x2b,
+	[RES_VPLL1] = 0x2f,
+	[RES_VPLL2] = 0x33,
+	[RES_VSIM] = 0x37,
+	[RES_VDAC] = 0x3b,
+	[RES_VINTANA1] = 0x3f,
+	[RES_VINTANA2] = 0x43,
+	[RES_VINTDIG] = 0x47,
+	[RES_VIO] = 0x4b,
+	[RES_VDD1] = 0x55,
+	[RES_VDD2] = 0x63,
+	[RES_VUSB_1v5] = 0x71,
+	[RES_VUSB_1v8] = 0x74,
+	[RES_VUSB_3v1] = 0x77,
+	[RES_VUSBCP] = 0x7a,
+	[RES_REGEN] = 0x7f,
+	[RES_NRES_PWRON] = 0x82,
+	[RES_CLKEN] = 0x85,
+	[RES_SYSEN] = 0x88,
+	[RES_HFCLKOUT] = 0x8b,
+	[RES_32KCLKOUT] = 0x8e,
+	[RES_RESET] = 0x91,
+	[RES_Main_Ref] = 0x94,
+};
+
 static int __init twl4030_write_script_byte(u8 address, u8 byte)
 {
 	int err;
@@ -219,6 +257,53 @@ static int __init config_warmreset_sequence(u8 address)
 	return err;
 }
 
+void twl4030_configure_resource(struct twl4030_resconfig *rconfig)
+{
+	int rconfig_addr;
+	u8 type;
+
+	if (rconfig->resource > NUM_OF_RESOURCES) {
+		printk(KERN_ERR
+			"TWL4030 Resource %d does not exist\n",
+			rconfig->resource);
+		return;
+	}
+
+	rconfig_addr = res_config_addrs[rconfig->resource];
+
+	/* Set resource group */
+
+	if (rconfig->devgroup >= 0)
+		twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+					rconfig->devgroup << 5,
+					rconfig_addr + DEVGROUP_OFFSET);
+
+	/* Set resource types */
+
+	if (twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER,
+					&type,
+					rconfig_addr + TYPE_OFFSET) < 0) {
+		printk(KERN_ERR
+			"TWL4030 Resource %d type could not read\n",
+			rconfig->resource);
+		return;
+	}
+
+	if (rconfig->type >= 0) {
+		type &= ~7;
+		type |= rconfig->type;
+	}
+
+	if (rconfig->type2 >= 0) {
+		type &= ~(3 << 3);
+		type |= rconfig->type2 << 3;
+	}
+
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+				type, rconfig_addr + TYPE_OFFSET);
+
+}
+
 static int __init load_triton_script(struct twl4030_script *tscript)
 {
 	u8 address = triton_next_free_address;
@@ -249,6 +334,7 @@ void __init twl4030_power_init(struct twl4030_power_data *triton2_scripts)
 {
 	int err = 0;
 	int i;
+	struct twl4030_resconfig *resconfig;
 
 	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_1,
 				R_PROTECT_KEY);
@@ -258,12 +344,20 @@ void __init twl4030_power_init(struct twl4030_power_data *triton2_scripts)
 		printk(KERN_ERR
 			"TWL4030 Unable to unlock registers\n");
 
-	for (i = 0; i < triton2_scripts->size; i++) {
+	for (i = 0; i < triton2_scripts->scripts_size; i++) {
 		err = load_triton_script(triton2_scripts->scripts[i]);
 		if (err)
 			break;
 	}
 
+	resconfig = triton2_scripts->resource_config;
+	if (resconfig) {
+		while (resconfig->resource) {
+			twl4030_configure_resource(resconfig);
+			resconfig++;
+		}
+	}
+
 	if (twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY))
 		printk(KERN_ERR
 			"TWL4030 Unable to relock registers\n");
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index 17bd400..efa7af1 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -243,6 +243,37 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
 #define RES_STATE_SLEEP		0x8
 #define RES_STATE_OFF		0x0
 
+/* Power resources */
+
+#define RES_VAUX1               1
+#define RES_VAUX2               2
+#define RES_VAUX3               3
+#define RES_VAUX4               4
+#define RES_VMMC1               5
+#define RES_VMMC2               6
+#define RES_VPLL1               7
+#define RES_VPLL2               8
+#define RES_VSIM                9
+#define RES_VDAC                10
+#define RES_VINTANA1            11
+#define RES_VINTANA2            12
+#define RES_VINTDIG             13
+#define RES_VIO                 14
+#define RES_VDD1                15
+#define RES_VDD2                16
+#define RES_VUSB_1v5            17
+#define RES_VUSB_1v8            18
+#define RES_VUSB_3v1            19
+#define RES_VUSBCP              20
+#define RES_REGEN               21
+#define RES_NRES_PWRON          22
+#define RES_CLKEN               23
+#define RES_SYSEN               24
+#define RES_HFCLKOUT            25
+#define RES_32KCLKOUT           26
+#define RES_RESET               27
+#define RES_Main_Ref            28
+
 /*
  * Power Bus Message Format ... these can be sent individually by Linux,
  * but are usually part of downloaded scripts that are run when various
@@ -334,9 +365,17 @@ struct twl4030_script {
 #define TRITON_SLEEP_SCRIPT	(1<<3)
 };
 
+struct twl4030_resconfig {
+	u8 resource;
+	u8 devgroup;
+	u8 type;
+	u8 type2;
+};
+
 struct twl4030_power_data {
 	struct twl4030_script **scripts;
-	unsigned size;
+	unsigned scripts_size;
+	struct twl4030_resconfig *resource_config;
 };
 
 struct twl4030_platform_data {
-- 
1.5.6.3


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

* Re: [PATCH 1/1] Group and resource assignments for TWL4030
  2009-03-13 15:33             ` [PATCH 1/1] " Peter 'p2' De Schrijver
@ 2009-03-13 23:11               ` David Brownell
  2009-03-14  1:16               ` [PATCH 1/1] Group and resource assignments for TWL4030 (v3) David Brownell
  1 sibling, 0 replies; 14+ messages in thread
From: David Brownell @ 2009-03-13 23:11 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Friday 13 March 2009, Peter 'p2' De Schrijver wrote:
>  struct twl4030_power_data {
>         struct twl4030_script **scripts;
> -       unsigned size;
> +       unsigned scripts_size;

And that little bit breaks builds ... since the various
bits of code that initialize a twl4030_power_data have
not been changed.

I'll send an updated version of this patch soonish.


> +       struct twl4030_resconfig *resource_config;
>  };


--
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

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

* [PATCH 1/1] Group and resource assignments for TWL4030 (v3)
  2009-03-13 15:33             ` [PATCH 1/1] " Peter 'p2' De Schrijver
  2009-03-13 23:11               ` David Brownell
@ 2009-03-14  1:16               ` David Brownell
  1 sibling, 0 replies; 14+ messages in thread
From: David Brownell @ 2009-03-14  1:16 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver, linux-omap

From: "Peter 'p2' De Schrijver" <peter.de-schrijver@nokia.com>
Subject: Group and resource assignments for TWL4030

Introduce support for board specific group assignments of TWL4030
power resources.  The resource type and type2 fields can also be
specified.

Most such power resources are regulators; this hook can be used
to ensure regulators that will never be used get properly disabled,
regardless of what the bootloader does.  Other resources include
control signals like CLKREQ and REGEN; this can properly couple
TWL CLKREQ (out) to OMAP SYSCLK_REQ (in) so retention mode works.

[ dbrownell@users.sourceforge.net: cosmetic and doc updates;
  use the RES_* constants in the regulator driver; fix buildbug ]

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
Removes the build bug ... and now depends on the VPLL2 patch
that I just posted (sorry).

 drivers/mfd/Kconfig                   |   14 +++-
 drivers/mfd/twl4030-power.c           |   94 ++++++++++++++++++++++++++++++++
 drivers/regulator/twl4030-regulator.c |   40 ++++++-------
 include/linux/i2c/twl4030.h           |   39 +++++++++++++
 4 files changed, 162 insertions(+), 25 deletions(-)

--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -107,13 +107,17 @@ config TWL4030_CORE
 	  versions) and many other features.
 
 config TWL4030_POWER
-	bool "Support power sequencing scripts on TWL4030/TPS659x0"
+	bool "Support power resources on TWL4030 family chips"
 	depends on TWL4030_CORE
 	help
-	  Say yes here if you want to use the power sequencing scripts on
-	  the TWL4030/TPS659x0. These scripts control which regulators or
-	  oscillators are switched off or on or reset when a sleep, wakeup
-	  or warm reset event occurs.
+	  Say yes here if you want to use the power resources on the
+	  TWL4030 family chips.  Most of these resources are regulators,
+	  which have a separate driver; some are control signals, such
+	  as clock request handshaking.
+
+	  This driver uses board-specific data to initialize the resources
+	  and load scripts controling which resources are switched off/on
+	  or reset when a sleep, wakeup or warm reset event occurs.
 
 config MFD_TMIO
 	bool
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -38,6 +38,8 @@ static u8 triton_next_free_address = 0x2
 #define PHY_TO_OFF_PM_MASTER(p)		(p - 0x36)
 #define PHY_TO_OFF_PM_RECEIVER(p)	(p - 0x5b)
 
+#define NUM_OF_RESOURCES	28
+
 /* resource - hfclk */
 #define R_HFCLKOUT_DEV_GRP 	PHY_TO_OFF_PM_RECEIVER(0xe6)
 
@@ -66,6 +68,42 @@ static u8 triton_next_free_address = 0x2
 #define KEY_1			0xC0
 #define KEY_2			0x0C
 
+/* resource configuration registers */
+
+#define DEVGROUP_OFFSET		0
+#define TYPE_OFFSET		1
+
+static u8 res_config_addrs[] = {
+	[RES_VAUX1]	= 0x17,
+	[RES_VAUX2]	= 0x1b,
+	[RES_VAUX3]	= 0x1f,
+	[RES_VAUX4]	= 0x23,
+	[RES_VMMC1]	= 0x27,
+	[RES_VMMC2]	= 0x2b,
+	[RES_VPLL1]	= 0x2f,
+	[RES_VPLL2]	= 0x33,
+	[RES_VSIM]	= 0x37,
+	[RES_VDAC]	= 0x3b,
+	[RES_VINTANA1]	= 0x3f,
+	[RES_VINTANA2]	= 0x43,
+	[RES_VINTDIG]	= 0x47,
+	[RES_VIO]	= 0x4b,
+	[RES_VDD1]	= 0x55,
+	[RES_VDD2]	= 0x63,
+	[RES_VUSB_1V5]	= 0x71,
+	[RES_VUSB_1V8]	= 0x74,
+	[RES_VUSB_3V1]	= 0x77,
+	[RES_VUSBCP]	= 0x7a,
+	[RES_REGEN]	= 0x7f,
+	[RES_NRES_PWRON] = 0x82,
+	[RES_CLKEN]	= 0x85,
+	[RES_SYSEN]	= 0x88,
+	[RES_HFCLKOUT]	= 0x8b,
+	[RES_32KCLKOUT]	= 0x8e,
+	[RES_RESET]	= 0x91,
+	[RES_Main_Ref]	= 0x94,
+};
+
 static int __init twl4030_write_script_byte(u8 address, u8 byte)
 {
 	int err;
@@ -219,6 +257,53 @@ static int __init config_warmreset_seque
 	return err;
 }
 
+void twl4030_configure_resource(struct twl4030_resconfig *rconfig)
+{
+	int rconfig_addr;
+	u8 type;
+
+	if (rconfig->resource > NUM_OF_RESOURCES) {
+		printk(KERN_ERR
+			"TWL4030 Resource %d does not exist\n",
+			rconfig->resource);
+		return;
+	}
+
+	rconfig_addr = res_config_addrs[rconfig->resource];
+
+	/* Set resource group */
+
+	if (rconfig->devgroup >= 0)
+		twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+					rconfig->devgroup << 5,
+					rconfig_addr + DEVGROUP_OFFSET);
+
+	/* Set resource types */
+
+	if (twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER,
+					&type,
+					rconfig_addr + TYPE_OFFSET) < 0) {
+		printk(KERN_ERR
+			"TWL4030 Resource %d type could not read\n",
+			rconfig->resource);
+		return;
+	}
+
+	if (rconfig->type >= 0) {
+		type &= ~7;
+		type |= rconfig->type;
+	}
+
+	if (rconfig->type2 >= 0) {
+		type &= ~(3 << 3);
+		type |= rconfig->type2 << 3;
+	}
+
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+				type, rconfig_addr + TYPE_OFFSET);
+
+}
+
 static int __init load_triton_script(struct twl4030_script *tscript)
 {
 	u8 address = triton_next_free_address;
@@ -249,6 +334,7 @@ void __init twl4030_power_init(struct tw
 {
 	int err = 0;
 	int i;
+	struct twl4030_resconfig *resconfig;
 
 	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_1,
 				R_PROTECT_KEY);
@@ -264,6 +350,14 @@ void __init twl4030_power_init(struct tw
 			break;
 	}
 
+	resconfig = triton2_scripts->resource_config;
+	if (resconfig) {
+		while (resconfig->resource) {
+			twl4030_configure_resource(resconfig);
+			resconfig++;
+		}
+	}
+
 	if (twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY))
 		printk(KERN_ERR
 			"TWL4030 Unable to relock registers\n");
--- a/drivers/regulator/twl4030-regulator.c
+++ b/drivers/regulator/twl4030-regulator.c
@@ -395,30 +395,30 @@ static struct regulator_ops twl4030fixed
  * software control over them after boot.
  */
 static struct twlreg_info twl4030_regs[] = {
-	TWL_ADJUSTABLE_LDO(VAUX1, 0x17, 1),
-	TWL_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2),
-	TWL_ADJUSTABLE_LDO(VAUX2, 0x1b, 2),
-	TWL_ADJUSTABLE_LDO(VAUX3, 0x1f, 3),
-	TWL_ADJUSTABLE_LDO(VAUX4, 0x23, 4),
-	TWL_ADJUSTABLE_LDO(VMMC1, 0x27, 5),
-	TWL_ADJUSTABLE_LDO(VMMC2, 0x2b, 6),
+	TWL_ADJUSTABLE_LDO(VAUX1, 0x17, RES_VAUX1),
+	TWL_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, RES_VAUX2),
+	TWL_ADJUSTABLE_LDO(VAUX2, 0x1b, RES_VAUX2),
+	TWL_ADJUSTABLE_LDO(VAUX3, 0x1f, RES_VAUX3),
+	TWL_ADJUSTABLE_LDO(VAUX4, 0x23, RES_VAUX4),
+	TWL_ADJUSTABLE_LDO(VMMC1, 0x27, RES_VMMC1),
+	TWL_ADJUSTABLE_LDO(VMMC2, 0x2b, RES_VMMC2),
 	/*
-	TWL_ADJUSTABLE_LDO(VPLL1, 0x2f, 7),
+	TWL_ADJUSTABLE_LDO(VPLL1, 0x2f, RES_VPLL1),
 	*/
-	TWL_ADJUSTABLE_LDO(VPLL2, 0x33, 8),
-	TWL_ADJUSTABLE_LDO(VSIM, 0x37, 9),
-	TWL_ADJUSTABLE_LDO(VDAC, 0x3b, 10),
+	TWL_ADJUSTABLE_LDO(VPLL2, 0x33, RES_VPLL2),
+	TWL_ADJUSTABLE_LDO(VSIM, 0x37, RES_VSIM),
+	TWL_ADJUSTABLE_LDO(VDAC, 0x3b, RES_VDAC),
 	/*
-	TWL_ADJUSTABLE_LDO(VINTANA1, 0x3f, 11),
-	TWL_ADJUSTABLE_LDO(VINTANA2, 0x43, 12),
-	TWL_ADJUSTABLE_LDO(VINTDIG, 0x47, 13),
-	TWL_SMPS(VIO, 0x4b, 14),
-	TWL_SMPS(VDD1, 0x55, 15),
-	TWL_SMPS(VDD2, 0x63, 16),
+	TWL_ADJUSTABLE_LDO(VINTANA1, 0x3f, RES_VINTANA1),
+	TWL_ADJUSTABLE_LDO(VINTANA2, 0x43, RES_VINTANA1),
+	TWL_ADJUSTABLE_LDO(VINTDIG, 0x47, RES_VINTDIG),
+	TWL_SMPS(VIO, 0x4b, RES_VIO),
+	TWL_SMPS(VDD1, 0x55, RES_VDD1),
+	TWL_SMPS(VDD2, 0x63, RES_VDD2),
 	 */
-	TWL_FIXED_LDO(VUSB1V5, 0x71, 1500, 17),
-	TWL_FIXED_LDO(VUSB1V8, 0x74, 1800, 18),
-	TWL_FIXED_LDO(VUSB3V1, 0x77, 3100, 19),
+	TWL_FIXED_LDO(VUSB1V5, 0x71, 1500, RES_VUSB_1V5),
+	TWL_FIXED_LDO(VUSB1V8, 0x74, 1800, RES_VUSB_1V8),
+	TWL_FIXED_LDO(VUSB3V1, 0x77, 3100, RES_VUSB_3V1),
 	/* VUSBCP is managed *only* by the USB subchip */
 };
 
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -243,6 +243,37 @@ int twl4030_i2c_read(u8 mod_no, u8 *valu
 #define RES_STATE_SLEEP		0x8
 #define RES_STATE_OFF		0x0
 
+/* Power resources */
+
+#define RES_VAUX1               1
+#define RES_VAUX2               2
+#define RES_VAUX3               3
+#define RES_VAUX4               4
+#define RES_VMMC1               5
+#define RES_VMMC2               6
+#define RES_VPLL1               7
+#define RES_VPLL2               8
+#define RES_VSIM                9
+#define RES_VDAC                10
+#define RES_VINTANA1            11
+#define RES_VINTANA2            12
+#define RES_VINTDIG             13
+#define RES_VIO                 14
+#define RES_VDD1                15
+#define RES_VDD2                16
+#define RES_VUSB_1V5            17
+#define RES_VUSB_1V8            18
+#define RES_VUSB_3V1            19
+#define RES_VUSBCP              20
+#define RES_REGEN               21
+#define RES_NRES_PWRON          22
+#define RES_CLKEN               23
+#define RES_SYSEN               24
+#define RES_HFCLKOUT            25
+#define RES_32KCLKOUT           26
+#define RES_RESET               27
+#define RES_Main_Ref            28
+
 /*
  * Power Bus Message Format ... these can be sent individually by Linux,
  * but are usually part of downloaded scripts that are run when various
@@ -342,9 +373,17 @@ struct twl4030_script {
 #define TRITON_SLEEP_SCRIPT	(1<<3)
 };
 
+struct twl4030_resconfig {
+	u8 resource;
+	u8 devgroup;
+	u8 type;
+	u8 type2;
+};
+
 struct twl4030_power_data {
 	struct twl4030_script **scripts;
 	unsigned size;
+	const struct twl4030_resconfig *resource_config;
 };
 
 struct twl4030_platform_data {

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

end of thread, other threads:[~2009-03-14  1:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-10 13:11 [PATCH 0/1] Group and resource assignments for TWL4030 Peter 'p2' De Schrijver
2009-02-10 13:11 ` [PATCH 1/1] " Peter 'p2' De Schrijver
2009-02-10 13:28   ` Felipe Balbi
2009-03-03 23:28   ` David Brownell
2009-02-13 20:55 ` [PATCH 0/1] " David Brownell
2009-02-15 16:48   ` Peter 'p2' De Schrijver
2009-02-27 16:59     ` Tony Lindgren
2009-03-03 23:38       ` David Brownell
2009-03-04 14:41         ` Peter 'p2' De Schrijver
2009-03-06  0:16         ` Tony Lindgren
2009-03-13 15:33           ` Peter 'p2' De Schrijver
2009-03-13 15:33             ` [PATCH 1/1] " Peter 'p2' De Schrijver
2009-03-13 23:11               ` David Brownell
2009-03-14  1:16               ` [PATCH 1/1] Group and resource assignments for TWL4030 (v3) David Brownell

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).