aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2011-05-03 11:03:43 -0400
committerPeter Ujfalusi <peter.ujfalusi@ti.com>2011-07-04 11:43:51 -0400
commit4fe5668b73d7ad041101656c98f3a58d86f68840 (patch)
tree4e5ce438db092e54f215b528a6f01a20d184323f /drivers/mfd
parentb252b0efb605b92a2f5d118e294d088d89cfd286 (diff)
MFD: twl4030-codec: Rename internals from codec to audio
In preparation of renaming the driver from twl4030-codec to twl4030-audio, first do some clean ups in the driver, which does not cause any problems outside. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/twl4030-codec.c135
1 files changed, 68 insertions, 67 deletions
diff --git a/drivers/mfd/twl4030-codec.c b/drivers/mfd/twl4030-codec.c
index 2bf4136464c1..e1782b3f66a5 100644
--- a/drivers/mfd/twl4030-codec.c
+++ b/drivers/mfd/twl4030-codec.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * MFD driver for twl4030 codec submodule 2 * MFD driver for twl4030 audio submodule, which contains an audio codec, and
3 * the vibra control.
3 * 4 *
4 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> 5 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
5 * 6 *
@@ -31,53 +32,53 @@
31#include <linux/mfd/core.h> 32#include <linux/mfd/core.h>
32#include <linux/mfd/twl4030-codec.h> 33#include <linux/mfd/twl4030-codec.h>
33 34
34#define TWL4030_CODEC_CELLS 2 35#define TWL4030_AUDIO_CELLS 2
35 36
36static struct platform_device *twl4030_codec_dev; 37static struct platform_device *twl4030_audio_dev;
37 38
38struct twl4030_codec_resource { 39struct twl4030_audio_resource {
39 int request_count; 40 int request_count;
40 u8 reg; 41 u8 reg;
41 u8 mask; 42 u8 mask;
42}; 43};
43 44
44struct twl4030_codec { 45struct twl4030_audio {
45 unsigned int audio_mclk; 46 unsigned int audio_mclk;
46 struct mutex mutex; 47 struct mutex mutex;
47 struct twl4030_codec_resource resource[TWL4030_CODEC_RES_MAX]; 48 struct twl4030_audio_resource resource[TWL4030_CODEC_RES_MAX];
48 struct mfd_cell cells[TWL4030_CODEC_CELLS]; 49 struct mfd_cell cells[TWL4030_AUDIO_CELLS];
49}; 50};
50 51
51/* 52/*
52 * Modify the resource, the function returns the content of the register 53 * Modify the resource, the function returns the content of the register
53 * after the modification. 54 * after the modification.
54 */ 55 */
55static int twl4030_codec_set_resource(enum twl4030_codec_res id, int enable) 56static int twl4030_audio_set_resource(enum twl4030_codec_res id, int enable)
56{ 57{
57 struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev); 58 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev);
58 u8 val; 59 u8 val;
59 60
60 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val, 61 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val,
61 codec->resource[id].reg); 62 audio->resource[id].reg);
62 63
63 if (enable) 64 if (enable)
64 val |= codec->resource[id].mask; 65 val |= audio->resource[id].mask;
65 else 66 else
66 val &= ~codec->resource[id].mask; 67 val &= ~audio->resource[id].mask;
67 68
68 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, 69 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
69 val, codec->resource[id].reg); 70 val, audio->resource[id].reg);
70 71
71 return val; 72 return val;
72} 73}
73 74
74static inline int twl4030_codec_get_resource(enum twl4030_codec_res id) 75static inline int twl4030_audio_get_resource(enum twl4030_codec_res id)
75{ 76{
76 struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev); 77 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev);
77 u8 val; 78 u8 val;
78 79
79 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val, 80 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val,
80 codec->resource[id].reg); 81 audio->resource[id].reg);
81 82
82 return val; 83 return val;
83} 84}
@@ -88,24 +89,24 @@ static inline int twl4030_codec_get_resource(enum twl4030_codec_res id)
88 */ 89 */
89int twl4030_codec_enable_resource(enum twl4030_codec_res id) 90int twl4030_codec_enable_resource(enum twl4030_codec_res id)
90{ 91{
91 struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev); 92 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev);
92 int val; 93 int val;
93 94
94 if (id >= TWL4030_CODEC_RES_MAX) { 95 if (id >= TWL4030_CODEC_RES_MAX) {
95 dev_err(&twl4030_codec_dev->dev, 96 dev_err(&twl4030_audio_dev->dev,
96 "Invalid resource ID (%u)\n", id); 97 "Invalid resource ID (%u)\n", id);
97 return -EINVAL; 98 return -EINVAL;
98 } 99 }
99 100
100 mutex_lock(&codec->mutex); 101 mutex_lock(&audio->mutex);
101 if (!codec->resource[id].request_count) 102 if (!audio->resource[id].request_count)
102 /* Resource was disabled, enable it */ 103 /* Resource was disabled, enable it */
103 val = twl4030_codec_set_resource(id, 1); 104 val = twl4030_audio_set_resource(id, 1);
104 else 105 else
105 val = twl4030_codec_get_resource(id); 106 val = twl4030_audio_get_resource(id);
106 107
107 codec->resource[id].request_count++; 108 audio->resource[id].request_count++;
108 mutex_unlock(&codec->mutex); 109 mutex_unlock(&audio->mutex);
109 110
110 return val; 111 return val;
111} 112}
@@ -117,31 +118,31 @@ EXPORT_SYMBOL_GPL(twl4030_codec_enable_resource);
117 */ 118 */
118int twl4030_codec_disable_resource(unsigned id) 119int twl4030_codec_disable_resource(unsigned id)
119{ 120{
120 struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev); 121 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev);
121 int val; 122 int val;
122 123
123 if (id >= TWL4030_CODEC_RES_MAX) { 124 if (id >= TWL4030_CODEC_RES_MAX) {
124 dev_err(&twl4030_codec_dev->dev, 125 dev_err(&twl4030_audio_dev->dev,
125 "Invalid resource ID (%u)\n", id); 126 "Invalid resource ID (%u)\n", id);
126 return -EINVAL; 127 return -EINVAL;
127 } 128 }
128 129
129 mutex_lock(&codec->mutex); 130 mutex_lock(&audio->mutex);
130 if (!codec->resource[id].request_count) { 131 if (!audio->resource[id].request_count) {
131 dev_err(&twl4030_codec_dev->dev, 132 dev_err(&twl4030_audio_dev->dev,
132 "Resource has been disabled already (%u)\n", id); 133 "Resource has been disabled already (%u)\n", id);
133 mutex_unlock(&codec->mutex); 134 mutex_unlock(&audio->mutex);
134 return -EPERM; 135 return -EPERM;
135 } 136 }
136 codec->resource[id].request_count--; 137 audio->resource[id].request_count--;
137 138
138 if (!codec->resource[id].request_count) 139 if (!audio->resource[id].request_count)
139 /* Resource can be disabled now */ 140 /* Resource can be disabled now */
140 val = twl4030_codec_set_resource(id, 0); 141 val = twl4030_audio_set_resource(id, 0);
141 else 142 else
142 val = twl4030_codec_get_resource(id); 143 val = twl4030_audio_get_resource(id);
143 144
144 mutex_unlock(&codec->mutex); 145 mutex_unlock(&audio->mutex);
145 146
146 return val; 147 return val;
147} 148}
@@ -149,15 +150,15 @@ EXPORT_SYMBOL_GPL(twl4030_codec_disable_resource);
149 150
150unsigned int twl4030_codec_get_mclk(void) 151unsigned int twl4030_codec_get_mclk(void)
151{ 152{
152 struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev); 153 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev);
153 154
154 return codec->audio_mclk; 155 return audio->audio_mclk;
155} 156}
156EXPORT_SYMBOL_GPL(twl4030_codec_get_mclk); 157EXPORT_SYMBOL_GPL(twl4030_codec_get_mclk);
157 158
158static int __devinit twl4030_codec_probe(struct platform_device *pdev) 159static int __devinit twl4030_audio_probe(struct platform_device *pdev)
159{ 160{
160 struct twl4030_codec *codec; 161 struct twl4030_audio *audio;
161 struct twl4030_codec_data *pdata = pdev->dev.platform_data; 162 struct twl4030_codec_data *pdata = pdev->dev.platform_data;
162 struct mfd_cell *cell = NULL; 163 struct mfd_cell *cell = NULL;
163 int ret, childs = 0; 164 int ret, childs = 0;
@@ -187,33 +188,33 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev)
187 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, 188 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
188 val, TWL4030_REG_APLL_CTL); 189 val, TWL4030_REG_APLL_CTL);
189 190
190 codec = kzalloc(sizeof(struct twl4030_codec), GFP_KERNEL); 191 audio = kzalloc(sizeof(struct twl4030_audio), GFP_KERNEL);
191 if (!codec) 192 if (!audio)
192 return -ENOMEM; 193 return -ENOMEM;
193 194
194 platform_set_drvdata(pdev, codec); 195 platform_set_drvdata(pdev, audio);
195 196
196 twl4030_codec_dev = pdev; 197 twl4030_audio_dev = pdev;
197 mutex_init(&codec->mutex); 198 mutex_init(&audio->mutex);
198 codec->audio_mclk = pdata->audio_mclk; 199 audio->audio_mclk = pdata->audio_mclk;
199 200
200 /* Codec power */ 201 /* Codec power */
201 codec->resource[TWL4030_CODEC_RES_POWER].reg = TWL4030_REG_CODEC_MODE; 202 audio->resource[TWL4030_CODEC_RES_POWER].reg = TWL4030_REG_CODEC_MODE;
202 codec->resource[TWL4030_CODEC_RES_POWER].mask = TWL4030_CODECPDZ; 203 audio->resource[TWL4030_CODEC_RES_POWER].mask = TWL4030_CODECPDZ;
203 204
204 /* PLL */ 205 /* PLL */
205 codec->resource[TWL4030_CODEC_RES_APLL].reg = TWL4030_REG_APLL_CTL; 206 audio->resource[TWL4030_CODEC_RES_APLL].reg = TWL4030_REG_APLL_CTL;
206 codec->resource[TWL4030_CODEC_RES_APLL].mask = TWL4030_APLL_EN; 207 audio->resource[TWL4030_CODEC_RES_APLL].mask = TWL4030_APLL_EN;
207 208
208 if (pdata->audio) { 209 if (pdata->audio) {
209 cell = &codec->cells[childs]; 210 cell = &audio->cells[childs];
210 cell->name = "twl4030-codec"; 211 cell->name = "twl4030-codec";
211 cell->platform_data = pdata->audio; 212 cell->platform_data = pdata->audio;
212 cell->pdata_size = sizeof(*pdata->audio); 213 cell->pdata_size = sizeof(*pdata->audio);
213 childs++; 214 childs++;
214 } 215 }
215 if (pdata->vibra) { 216 if (pdata->vibra) {
216 cell = &codec->cells[childs]; 217 cell = &audio->cells[childs];
217 cell->name = "twl4030-vibra"; 218 cell->name = "twl4030-vibra";
218 cell->platform_data = pdata->vibra; 219 cell->platform_data = pdata->vibra;
219 cell->pdata_size = sizeof(*pdata->vibra); 220 cell->pdata_size = sizeof(*pdata->vibra);
@@ -221,7 +222,7 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev)
221 } 222 }
222 223
223 if (childs) 224 if (childs)
224 ret = mfd_add_devices(&pdev->dev, pdev->id, codec->cells, 225 ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells,
225 childs, NULL, 0); 226 childs, NULL, 0);
226 else { 227 else {
227 dev_err(&pdev->dev, "No platform data found for childs\n"); 228 dev_err(&pdev->dev, "No platform data found for childs\n");
@@ -232,45 +233,45 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev)
232 return 0; 233 return 0;
233 234
234 platform_set_drvdata(pdev, NULL); 235 platform_set_drvdata(pdev, NULL);
235 kfree(codec); 236 kfree(audio);
236 twl4030_codec_dev = NULL; 237 twl4030_audio_dev = NULL;
237 return ret; 238 return ret;
238} 239}
239 240
240static int __devexit twl4030_codec_remove(struct platform_device *pdev) 241static int __devexit twl4030_audio_remove(struct platform_device *pdev)
241{ 242{
242 struct twl4030_codec *codec = platform_get_drvdata(pdev); 243 struct twl4030_audio *audio = platform_get_drvdata(pdev);
243 244
244 mfd_remove_devices(&pdev->dev); 245 mfd_remove_devices(&pdev->dev);
245 platform_set_drvdata(pdev, NULL); 246 platform_set_drvdata(pdev, NULL);
246 kfree(codec); 247 kfree(audio);
247 twl4030_codec_dev = NULL; 248 twl4030_audio_dev = NULL;
248 249
249 return 0; 250 return 0;
250} 251}
251 252
252MODULE_ALIAS("platform:twl4030-audio"); 253MODULE_ALIAS("platform:twl4030-audio");
253 254
254static struct platform_driver twl4030_codec_driver = { 255static struct platform_driver twl4030_audio_driver = {
255 .probe = twl4030_codec_probe, 256 .probe = twl4030_audio_probe,
256 .remove = __devexit_p(twl4030_codec_remove), 257 .remove = __devexit_p(twl4030_audio_remove),
257 .driver = { 258 .driver = {
258 .owner = THIS_MODULE, 259 .owner = THIS_MODULE,
259 .name = "twl4030-audio", 260 .name = "twl4030-audio",
260 }, 261 },
261}; 262};
262 263
263static int __devinit twl4030_codec_init(void) 264static int __devinit twl4030_audio_init(void)
264{ 265{
265 return platform_driver_register(&twl4030_codec_driver); 266 return platform_driver_register(&twl4030_audio_driver);
266} 267}
267module_init(twl4030_codec_init); 268module_init(twl4030_audio_init);
268 269
269static void __devexit twl4030_codec_exit(void) 270static void __devexit twl4030_audio_exit(void)
270{ 271{
271 platform_driver_unregister(&twl4030_codec_driver); 272 platform_driver_unregister(&twl4030_audio_driver);
272} 273}
273module_exit(twl4030_codec_exit); 274module_exit(twl4030_audio_exit);
274 275
275MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>"); 276MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
276MODULE_LICENSE("GPL"); 277MODULE_LICENSE("GPL");