diff options
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0013-MFD-TWL4030-optimizing-resource-configuration.patch')
-rw-r--r-- | extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0013-MFD-TWL4030-optimizing-resource-configuration.patch | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0013-MFD-TWL4030-optimizing-resource-configuration.patch b/extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0013-MFD-TWL4030-optimizing-resource-configuration.patch new file mode 100644 index 00000000..8904f8de --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0013-MFD-TWL4030-optimizing-resource-configuration.patch | |||
@@ -0,0 +1,184 @@ | |||
1 | From bf171753a162d07753208c6bcfae8ca1e5c94af3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Lesly A M <leslyam@ti.com> | ||
3 | Date: Wed, 1 Jun 2011 14:57:05 -0700 | ||
4 | Subject: [PATCH 13/13] MFD: TWL4030: optimizing resource configuration | ||
5 | |||
6 | Skip the i2c register writes in twl4030_configure_resource() if the new value | ||
7 | is same as the old value, for devgrp/type/remap regs. | ||
8 | |||
9 | Suggested by David Derrick <dderrick@ti.com> | ||
10 | |||
11 | Signed-off-by: Lesly A M <leslyam@ti.com> | ||
12 | Cc: Nishanth Menon <nm@ti.com> | ||
13 | Cc: David Derrick <dderrick@ti.com> | ||
14 | Cc: Samuel Ortiz <sameo@linux.intel.com> | ||
15 | --- | ||
16 | drivers/mfd/twl4030-power.c | 126 ++++++++++++++++++++++++------------------ | ||
17 | 1 files changed, 72 insertions(+), 54 deletions(-) | ||
18 | |||
19 | diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c | ||
20 | index 8af3fe3..d82632f 100644 | ||
21 | --- a/drivers/mfd/twl4030-power.c | ||
22 | +++ b/drivers/mfd/twl4030-power.c | ||
23 | @@ -335,9 +335,9 @@ static int twl4030_configure_resource(struct twl4030_resconfig *rconfig) | ||
24 | { | ||
25 | int rconfig_addr; | ||
26 | int err; | ||
27 | - u8 type; | ||
28 | - u8 grp; | ||
29 | - u8 remap; | ||
30 | + u8 type, type_value; | ||
31 | + u8 grp, grp_value; | ||
32 | + u8 remap, remap_value; | ||
33 | |||
34 | if (rconfig->resource > TOTAL_RESOURCES) { | ||
35 | pr_err("TWL4030 Resource %d does not exist\n", | ||
36 | @@ -348,76 +348,94 @@ static int twl4030_configure_resource(struct twl4030_resconfig *rconfig) | ||
37 | rconfig_addr = res_config_addrs[rconfig->resource]; | ||
38 | |||
39 | /* Set resource group */ | ||
40 | - err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &grp, | ||
41 | + if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) { | ||
42 | + err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &grp, | ||
43 | rconfig_addr + DEV_GRP_OFFSET); | ||
44 | - if (err) { | ||
45 | - pr_err("TWL4030 Resource %d group could not be read\n", | ||
46 | - rconfig->resource); | ||
47 | - return err; | ||
48 | - } | ||
49 | + if (err) { | ||
50 | + pr_err("TWL4030 Resource %d group could not be read\n", | ||
51 | + rconfig->resource); | ||
52 | + return err; | ||
53 | + } | ||
54 | |||
55 | - if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) { | ||
56 | - grp &= ~DEV_GRP_MASK; | ||
57 | - grp |= rconfig->devgroup << DEV_GRP_SHIFT; | ||
58 | - err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, | ||
59 | + grp_value = (grp & DEV_GRP_MASK) >> DEV_GRP_SHIFT; | ||
60 | + | ||
61 | + if (rconfig->devgroup != grp_value) { | ||
62 | + grp &= ~DEV_GRP_MASK; | ||
63 | + grp |= rconfig->devgroup << DEV_GRP_SHIFT; | ||
64 | + err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, | ||
65 | grp, rconfig_addr + DEV_GRP_OFFSET); | ||
66 | - if (err < 0) { | ||
67 | - pr_err("TWL4030 failed to program devgroup\n"); | ||
68 | - return err; | ||
69 | + if (err < 0) { | ||
70 | + pr_err("TWL4030 failed to program devgroup\n"); | ||
71 | + return err; | ||
72 | + } | ||
73 | } | ||
74 | } | ||
75 | |||
76 | /* Set resource types */ | ||
77 | - err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type, | ||
78 | + if ((rconfig->type != TWL4030_RESCONFIG_UNDEF) || | ||
79 | + (rconfig->type2 != TWL4030_RESCONFIG_UNDEF)) { | ||
80 | + | ||
81 | + err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type, | ||
82 | rconfig_addr + TYPE_OFFSET); | ||
83 | - if (err < 0) { | ||
84 | - pr_err("TWL4030 Resource %d type could not be read\n", | ||
85 | - rconfig->resource); | ||
86 | - return err; | ||
87 | - } | ||
88 | + if (err < 0) { | ||
89 | + pr_err("TWL4030 Resource %d type could not be read\n", | ||
90 | + rconfig->resource); | ||
91 | + return err; | ||
92 | + } | ||
93 | |||
94 | - if (rconfig->type != TWL4030_RESCONFIG_UNDEF) { | ||
95 | - type &= ~TYPE_MASK; | ||
96 | - type |= rconfig->type << TYPE_SHIFT; | ||
97 | - } | ||
98 | + type_value = type; | ||
99 | |||
100 | - if (rconfig->type2 != TWL4030_RESCONFIG_UNDEF) { | ||
101 | - type &= ~TYPE2_MASK; | ||
102 | - type |= rconfig->type2 << TYPE2_SHIFT; | ||
103 | - } | ||
104 | + if (rconfig->type != TWL4030_RESCONFIG_UNDEF) { | ||
105 | + type &= ~TYPE_MASK; | ||
106 | + type |= rconfig->type << TYPE_SHIFT; | ||
107 | + } | ||
108 | |||
109 | - err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, | ||
110 | + if (rconfig->type2 != TWL4030_RESCONFIG_UNDEF) { | ||
111 | + type &= ~TYPE2_MASK; | ||
112 | + type |= rconfig->type2 << TYPE2_SHIFT; | ||
113 | + } | ||
114 | + | ||
115 | + if (type != type_value) { | ||
116 | + err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, | ||
117 | type, rconfig_addr + TYPE_OFFSET); | ||
118 | - if (err < 0) { | ||
119 | - pr_err("TWL4030 failed to program resource type\n"); | ||
120 | - return err; | ||
121 | + if (err < 0) { | ||
122 | + pr_err("TWL4030 failed to program resource type\n"); | ||
123 | + return err; | ||
124 | + } | ||
125 | + } | ||
126 | } | ||
127 | |||
128 | /* Set remap states */ | ||
129 | - err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &remap, | ||
130 | + if ((rconfig->remap_off != TWL4030_RESCONFIG_UNDEF) || | ||
131 | + (rconfig->remap_sleep != TWL4030_RESCONFIG_UNDEF)) { | ||
132 | + err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &remap, | ||
133 | rconfig_addr + REMAP_OFFSET); | ||
134 | - if (err < 0) { | ||
135 | - pr_err("TWL4030 Resource %d remap could not be read\n", | ||
136 | - rconfig->resource); | ||
137 | - return err; | ||
138 | - } | ||
139 | + if (err < 0) { | ||
140 | + pr_err("TWL4030 Resource %d remap could not be read\n", | ||
141 | + rconfig->resource); | ||
142 | + return err; | ||
143 | + } | ||
144 | |||
145 | - if (rconfig->remap_off != TWL4030_RESCONFIG_UNDEF) { | ||
146 | - remap &= ~OFF_STATE_MASK; | ||
147 | - remap |= rconfig->remap_off << OFF_STATE_SHIFT; | ||
148 | - } | ||
149 | + remap_value = remap; | ||
150 | |||
151 | - if (rconfig->remap_sleep != TWL4030_RESCONFIG_UNDEF) { | ||
152 | - remap &= ~SLEEP_STATE_MASK; | ||
153 | - remap |= rconfig->remap_sleep << SLEEP_STATE_SHIFT; | ||
154 | - } | ||
155 | + if (rconfig->remap_off != TWL4030_RESCONFIG_UNDEF) { | ||
156 | + remap &= ~OFF_STATE_MASK; | ||
157 | + remap |= rconfig->remap_off << OFF_STATE_SHIFT; | ||
158 | + } | ||
159 | |||
160 | - err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, | ||
161 | - remap, | ||
162 | - rconfig_addr + REMAP_OFFSET); | ||
163 | - if (err < 0) { | ||
164 | - pr_err("TWL4030 failed to program remap\n"); | ||
165 | - return err; | ||
166 | + if (rconfig->remap_sleep != TWL4030_RESCONFIG_UNDEF) { | ||
167 | + remap &= ~SLEEP_STATE_MASK; | ||
168 | + remap |= rconfig->remap_sleep << SLEEP_STATE_SHIFT; | ||
169 | + } | ||
170 | + | ||
171 | + if (remap != remap_value) { | ||
172 | + err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, | ||
173 | + remap, rconfig_addr + REMAP_OFFSET); | ||
174 | + if (err < 0) { | ||
175 | + pr_err("TWL4030 failed to program remap\n"); | ||
176 | + return err; | ||
177 | + } | ||
178 | + } | ||
179 | } | ||
180 | |||
181 | return 0; | ||
182 | -- | ||
183 | 1.6.6.1 | ||
184 | |||