Commit cfb7a33b authored by Peter Ujfalusi's avatar Peter Ujfalusi

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: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 753621c2
...@@ -270,7 +270,8 @@ int twl6040_power(struct twl6040 *twl6040, int on) ...@@ -270,7 +270,8 @@ int twl6040_power(struct twl6040 *twl6040, int on)
goto out; goto out;
} }
} }
twl6040->pll = TWL6040_LPPLL_ID; /* Default PLL configuration after power up */
twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;
twl6040->sysclk = 19200000; twl6040->sysclk = 19200000;
} else { } else {
/* already powered-down */ /* already powered-down */
...@@ -294,7 +295,6 @@ int twl6040_power(struct twl6040 *twl6040, int on) ...@@ -294,7 +295,6 @@ int twl6040_power(struct twl6040 *twl6040, int on)
/* use manual power-down sequence */ /* use manual power-down sequence */
twl6040_power_down(twl6040); twl6040_power_down(twl6040);
} }
twl6040->pll = TWL6040_NOPLL_ID;
twl6040->sysclk = 0; twl6040->sysclk = 0;
} }
...@@ -304,7 +304,7 @@ int twl6040_power(struct twl6040 *twl6040, int on) ...@@ -304,7 +304,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
} }
EXPORT_SYMBOL(twl6040_power); EXPORT_SYMBOL(twl6040_power);
int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id, int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
unsigned int freq_in, unsigned int freq_out) unsigned int freq_in, unsigned int freq_out)
{ {
u8 hppllctl, lppllctl; u8 hppllctl, lppllctl;
...@@ -315,8 +315,8 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id, ...@@ -315,8 +315,8 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
hppllctl = twl6040_reg_read(twl6040, TWL6040_REG_HPPLLCTL); hppllctl = twl6040_reg_read(twl6040, TWL6040_REG_HPPLLCTL);
lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL); lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL);
switch (id) { switch (pll_id) {
case TWL6040_LPPLL_ID: case TWL6040_SYSCLK_SEL_LPPLL:
/* low-power PLL divider */ /* low-power PLL divider */
switch (freq_out) { switch (freq_out) {
case 17640000: case 17640000:
...@@ -352,10 +352,8 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id, ...@@ -352,10 +352,8 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
ret = -EINVAL; ret = -EINVAL;
goto pll_out; goto pll_out;
} }
twl6040->pll = TWL6040_LPPLL_ID;
break; break;
case TWL6040_HPPLL_ID: case TWL6040_SYSCLK_SEL_HPPLL:
/* high-performance PLL can provide only 19.2 MHz */ /* high-performance PLL can provide only 19.2 MHz */
if (freq_out != 19200000) { if (freq_out != 19200000) {
dev_err(&twl6040_dev->dev, dev_err(&twl6040_dev->dev,
...@@ -406,16 +404,15 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id, ...@@ -406,16 +404,15 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
lppllctl &= ~TWL6040_LPLLENA; lppllctl &= ~TWL6040_LPLLENA;
twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl); twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
twl6040->pll = TWL6040_HPPLL_ID;
break; break;
default: default:
dev_err(&twl6040_dev->dev, "unknown pll id %d\n", id); dev_err(&twl6040_dev->dev, "unknown pll id %d\n", pll_id);
ret = -EINVAL; ret = -EINVAL;
goto pll_out; goto pll_out;
} }
twl6040->sysclk = freq_out; twl6040->sysclk = freq_out;
twl6040->pll = pll_id;
pll_out: pll_out:
mutex_unlock(&twl6040->mutex); mutex_unlock(&twl6040->mutex);
...@@ -423,9 +420,12 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id, ...@@ -423,9 +420,12 @@ int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id,
} }
EXPORT_SYMBOL(twl6040_set_pll); EXPORT_SYMBOL(twl6040_set_pll);
enum twl6040_pll_id twl6040_get_pll(struct twl6040 *twl6040) int twl6040_get_pll(struct twl6040 *twl6040)
{ {
return twl6040->pll; if (twl6040->power_count)
return twl6040->pll;
else
return -ENODEV;
} }
EXPORT_SYMBOL(twl6040_get_pll); EXPORT_SYMBOL(twl6040_get_pll);
......
...@@ -165,9 +165,6 @@ ...@@ -165,9 +165,6 @@
#define TWL6040_RESETSPLIT 0x04 #define TWL6040_RESETSPLIT 0x04
#define TWL6040_INTCLRMODE 0x08 #define TWL6040_INTCLRMODE 0x08
#define TWL6040_SYSCLK_SEL_LPPLL 1
#define TWL6040_SYSCLK_SEL_HPPLL 2
/* STATUS (0x2E) fields */ /* STATUS (0x2E) fields */
#define TWL6040_PLUGCOMP 0x02 #define TWL6040_PLUGCOMP 0x02
...@@ -188,11 +185,9 @@ ...@@ -188,11 +185,9 @@
#define TWL6040_IRQ_VIB 4 #define TWL6040_IRQ_VIB 4
#define TWL6040_IRQ_READY 5 #define TWL6040_IRQ_READY 5
enum twl6040_pll_id { /* PLL selection */
TWL6040_NOPLL_ID, #define TWL6040_SYSCLK_SEL_LPPLL 0
TWL6040_LPPLL_ID, #define TWL6040_SYSCLK_SEL_HPPLL 1
TWL6040_HPPLL_ID,
};
struct twl6040 { struct twl6040 {
struct device *dev; struct device *dev;
...@@ -206,7 +201,7 @@ struct twl6040 { ...@@ -206,7 +201,7 @@ struct twl6040 {
int power_count; int power_count;
int rev; int rev;
enum twl6040_pll_id pll; int pll;
unsigned int sysclk; unsigned int sysclk;
unsigned int irq; unsigned int irq;
...@@ -223,9 +218,9 @@ int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, ...@@ -223,9 +218,9 @@ int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg,
int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg,
u8 mask); u8 mask);
int twl6040_power(struct twl6040 *twl6040, int on); int twl6040_power(struct twl6040 *twl6040, int on);
int twl6040_set_pll(struct twl6040 *twl6040, enum twl6040_pll_id id, int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
unsigned int freq_in, unsigned int freq_out); unsigned int freq_in, unsigned int freq_out);
enum twl6040_pll_id twl6040_get_pll(struct twl6040 *twl6040); int twl6040_get_pll(struct twl6040 *twl6040);
unsigned int twl6040_get_sysclk(struct twl6040 *twl6040); unsigned int twl6040_get_sysclk(struct twl6040 *twl6040);
int twl6040_irq_init(struct twl6040 *twl6040); int twl6040_irq_init(struct twl6040 *twl6040);
void twl6040_irq_exit(struct twl6040 *twl6040); void twl6040_irq_exit(struct twl6040 *twl6040);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment