Skip to content

Commit cfb7a33

Browse files
author
Peter Ujfalusi
committed
MFD: twl6040: Remove enum for PLL tracking
There is no need to have two different types for tracking the selected PLL. Use only the defines, when dealing with the PLLs. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 753621c commit cfb7a33

2 files changed

Lines changed: 19 additions & 24 deletions

File tree

‎drivers/mfd/twl6040-core.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ int twl6040_power(struct twl6040 *twl6040, int on)
270270
goto out;
271271
}
272272
}
273-
twl6040->pll = TWL6040_LPPLL_ID;
273+
/* Default PLL configuration after power up */
274+
twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;
274275
twl6040->sysclk = 19200000;
275276
} else {
276277
/* already powered-down */
@@ -294,7 +295,6 @@ int twl6040_power(struct twl6040 *twl6040, int on)
294295
/* use manual power-down sequence */
295296
twl6040_power_down(twl6040);
296297
}
297-
twl6040->pll = TWL6040_NOPLL_ID;
298298
twl6040->sysclk = 0;
299299
}
300300

@@ -304,7 +304,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
304304
}
305305
EXPORT_SYMBOL(twl6040_power);
306306

307-
int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
307+
int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
308308
unsigned int freq_in, unsigned int freq_out)
309309
{
310310
u8 hppllctl, lppllctl;
@@ -315,8 +315,8 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
315315
hppllctl = twl6040_reg_read(twl6040, TWL6040_REG_HPPLLCTL);
316316
lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL);
317317

318-
switch (id) {
319-
case TWL6040_LPPLL_ID:
318+
switch (pll_id) {
319+
case TWL6040_SYSCLK_SEL_LPPLL:
320320
/* low-power PLL divider */
321321
switch (freq_out) {
322322
case 17640000:
@@ -352,10 +352,8 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
352352
ret = -EINVAL;
353353
goto pll_out;
354354
}
355-
356-
twl6040->pll = TWL6040_LPPLL_ID;
357355
break;
358-
case TWL6040_HPPLL_ID:
356+
case TWL6040_SYSCLK_SEL_HPPLL:
359357
/* high-performance PLL can provide only 19.2 MHz */
360358
if (freq_out != 19200000) {
361359
dev_err(&twl6040_dev->dev,
@@ -406,26 +404,28 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
406404
twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
407405
lppllctl &= ~TWL6040_LPLLENA;
408406
twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
409-
410-
twl6040->pll = TWL6040_HPPLL_ID;
411407
break;
412408
default:
413-
dev_err(&twl6040_dev->dev, "unknown pll id %d\n", id);
409+
dev_err(&twl6040_dev->dev, "unknown pll id %d\n", pll_id);
414410
ret = -EINVAL;
415411
goto pll_out;
416412
}
417413

418414
twl6040->sysclk = freq_out;
415+
twl6040->pll = pll_id;
419416

420417
pll_out:
421418
mutex_unlock(&twl6040->mutex);
422419
return ret;
423420
}
424421
EXPORT_SYMBOL(twl6040_set_pll);
425422

426-
enum twl6040_pll_id twl6040_get_pll(struct twl6040 *twl6040)
423+
int twl6040_get_pll(struct twl6040 *twl6040)
427424
{
428-
return twl6040->pll;
425+
if (twl6040->power_count)
426+
return twl6040->pll;
427+
else
428+
return -ENODEV;
429429
}
430430
EXPORT_SYMBOL(twl6040_get_pll);
431431

‎include/linux/mfd/twl6040.h‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@
165165
#define TWL6040_RESETSPLIT 0x04
166166
#define TWL6040_INTCLRMODE 0x08
167167

168-
#define TWL6040_SYSCLK_SEL_LPPLL 1
169-
#define TWL6040_SYSCLK_SEL_HPPLL 2
170-
171168
/* STATUS (0x2E) fields */
172169

173170
#define TWL6040_PLUGCOMP 0x02
@@ -188,11 +185,9 @@
188185
#define TWL6040_IRQ_VIB 4
189186
#define TWL6040_IRQ_READY 5
190187

191-
enum twl6040_pll_id {
192-
TWL6040_NOPLL_ID,
193-
TWL6040_LPPLL_ID,
194-
TWL6040_HPPLL_ID,
195-
};
188+
/* PLL selection */
189+
#define TWL6040_SYSCLK_SEL_LPPLL 0
190+
#define TWL6040_SYSCLK_SEL_HPPLL 1
196191

197192
struct twl6040 {
198193
struct device *dev;
@@ -206,7 +201,7 @@ struct twl6040 {
206201
int power_count;
207202
int rev;
208203

209-
enum twl6040_pll_id pll;
204+
int pll;
210205
unsigned int sysclk;
211206

212207
unsigned int irq;
@@ -223,9 +218,9 @@ int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg,
223218
int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg,
224219
u8 mask);
225220
int twl6040_power(struct twl6040 *twl6040, int on);
226-
int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
221+
int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
227222
unsigned int freq_in, unsigned int freq_out);
228-
enum twl6040_pll_id twl6040_get_pll(struct twl6040 *twl6040);
223+
int twl6040_get_pll(struct twl6040 *twl6040);
229224
unsigned int twl6040_get_sysclk(struct twl6040 *twl6040);
230225
int twl6040_irq_init(struct twl6040 *twl6040);
231226
void twl6040_irq_exit(struct twl6040 *twl6040);

0 commit comments

Comments
 (0)