Commit 3305829b authored by Carlos Eduardo Aguiar's avatar Carlos Eduardo Aguiar Committed by Tony Lindgren

OMAP: MENELAUS: Using macros instead of some constant magic numbers.

This patch makes drivers/i2c/chips/menelaus.c file to use macros
instead of some constant magic numbers.
Signed-off-by: default avatarCarlos Eduardo Aguiar <carlos.aguiar@indt.org.br>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 97dc8ace
...@@ -129,6 +129,39 @@ ...@@ -129,6 +129,39 @@
#define MENELAUS_RESERVED14_IRQ 14 /* Reserved */ #define MENELAUS_RESERVED14_IRQ 14 /* Reserved */
#define MENELAUS_RESERVED15_IRQ 15 /* Reserved */ #define MENELAUS_RESERVED15_IRQ 15 /* Reserved */
/* VCORE_CTRL1 register */
#define VCORE_CTRL1_BYP_COMP (1 << 5)
#define VCORE_CTRL1_HW_NSW (1 << 7)
/* GPIO_CTRL register */
#define GPIO_CTRL_SLOTSELEN (1 << 5)
#define GPIO_CTRL_SLPCTLEN (1 << 6)
#define GPIO1_DIR_INPUT (1 << 0)
#define GPIO2_DIR_INPUT (1 << 1)
#define GPIO3_DIR_INPUT (1 << 2)
/* MCT_CTRL1 register */
#define MCT_CTRL1_S1_CMD_OD (1 << 2)
#define MCT_CTRL1_S2_CMD_OD (1 << 3)
/* MCT_CTRL2 register */
#define MCT_CTRL2_VS2_SEL_D0 (1 << 0)
#define MCT_CTRL2_VS2_SEL_D1 (1 << 1)
#define MCT_CTRL2_S1CD_BUFEN (1 << 4)
#define MCT_CTRL2_S2CD_BUFEN (1 << 5)
#define MCT_CTRL2_S1CD_DBEN (1 << 6)
#define MCT_CTRL2_S2CD_BEN (1 << 7)
/* MCT_CTRL3 register */
#define MCT_CTRL3_SLOT1_EN (1 << 0)
#define MCT_CTRL3_SLOT2_EN (1 << 1)
#define MCT_CTRL3_S1_AUTO_EN (1 << 2)
#define MCT_CTRL3_S2_AUTO_EN (1 << 3)
/* MCT_PIN_ST register */
#define MCT_PIN_ST_S1_CD_ST (1 << 0)
#define MCT_PIN_ST_S2_CD_ST (1 << 1)
static void menelaus_work(struct work_struct *_menelaus); static void menelaus_work(struct work_struct *_menelaus);
struct menelaus_chip { struct menelaus_chip {
...@@ -250,10 +283,10 @@ static void menelaus_mmc_cd_work(struct menelaus_chip *menelaus_hw) ...@@ -250,10 +283,10 @@ static void menelaus_mmc_cd_work(struct menelaus_chip *menelaus_hw)
return; return;
if (!(reg & 0x1)) if (!(reg & 0x1))
card_mask |= (1 << 0); card_mask |= MCT_PIN_ST_S1_CD_ST;
if (!(reg & 0x2)) if (!(reg & 0x2))
card_mask |= (1 << 1); card_mask |= MCT_PIN_ST_S2_CD_ST;
if (menelaus_hw->mmc_callback) if (menelaus_hw->mmc_callback)
menelaus_hw->mmc_callback(menelaus_hw->mmc_callback_data, menelaus_hw->mmc_callback(menelaus_hw->mmc_callback_data,
...@@ -278,14 +311,14 @@ int menelaus_set_mmc_opendrain(int slot, int enable) ...@@ -278,14 +311,14 @@ int menelaus_set_mmc_opendrain(int slot, int enable)
val = ret; val = ret;
if (slot == 1) { if (slot == 1) {
if (enable) if (enable)
val |= 1 << 2; val |= MCT_CTRL1_S1_CMD_OD;
else else
val &= ~(1 << 2); val &= ~MCT_CTRL1_S1_CMD_OD;
} else { } else {
if (enable) if (enable)
val |= 1 << 3; val |= MCT_CTRL1_S2_CMD_OD;
else else
val &= ~(1 << 3); val &= ~MCT_CTRL1_S2_CMD_OD;
} }
ret = menelaus_write_reg(MENELAUS_MCT_CTRL1, val); ret = menelaus_write_reg(MENELAUS_MCT_CTRL1, val);
mutex_unlock(&the_menelaus->lock); mutex_unlock(&the_menelaus->lock);
...@@ -302,11 +335,11 @@ int menelaus_set_slot_sel(int enable) ...@@ -302,11 +335,11 @@ int menelaus_set_slot_sel(int enable)
ret = menelaus_read_reg(MENELAUS_GPIO_CTRL); ret = menelaus_read_reg(MENELAUS_GPIO_CTRL);
if (ret < 0) if (ret < 0)
goto out; goto out;
ret |= 0x02; ret |= GPIO2_DIR_INPUT;
if (enable) if (enable)
ret |= 1 << 5; ret |= GPIO_CTRL_SLOTSELEN;
else else
ret &= ~(1 << 5); ret &= ~GPIO_CTRL_SLOTSELEN;
ret = menelaus_write_reg(MENELAUS_GPIO_CTRL, ret); ret = menelaus_write_reg(MENELAUS_GPIO_CTRL, ret);
out: out:
mutex_unlock(&the_menelaus->lock); mutex_unlock(&the_menelaus->lock);
...@@ -325,14 +358,14 @@ int menelaus_enable_slot(int slot, int enable) ...@@ -325,14 +358,14 @@ int menelaus_enable_slot(int slot, int enable)
val = ret; val = ret;
if (slot == 1) { if (slot == 1) {
if (enable) if (enable)
val |= 1 << 0; val |= MCT_CTRL3_SLOT1_EN;
else else
val &= ~(1 << 0); val &= ~MCT_CTRL3_SLOT1_EN;
} else { } else {
if (enable) if (enable)
val |= 1 << 1; val |= MCT_CTRL3_SLOT2_EN;
else else
val &= ~(1 << 1); val &= MCT_CTRL3_SLOT2_EN;
} }
ret = menelaus_write_reg(MENELAUS_MCT_CTRL3, val); ret = menelaus_write_reg(MENELAUS_MCT_CTRL3, val);
...@@ -359,14 +392,14 @@ int menelaus_set_mmc_slot(int slot, int enable, int power, int cd_en) ...@@ -359,14 +392,14 @@ int menelaus_set_mmc_slot(int slot, int enable, int power, int cd_en)
val = ret; val = ret;
if (slot == 1) { if (slot == 1) {
if (cd_en) if (cd_en)
val |= (1 << 4) | (1 << 6); val |= MCT_CTRL2_S1CD_BUFEN | MCT_CTRL2_S1CD_DBEN;
else else
val &= ~((1 << 4) | (1 << 6)); val &= ~(MCT_CTRL2_S1CD_BUFEN | MCT_CTRL2_S1CD_DBEN);
} else { } else {
if (cd_en) if (cd_en)
val |= (1 << 5) | (1 << 7); val |= MCT_CTRL2_S2CD_BUFEN | MCT_CTRL2_S2CD_BEN;
else else
val &= ~((1 << 5) | (1 << 7)); val &= ~(MCT_CTRL2_S2CD_BUFEN | MCT_CTRL2_S2CD_BEN);
} }
ret = menelaus_write_reg(MENELAUS_MCT_CTRL2, val); ret = menelaus_write_reg(MENELAUS_MCT_CTRL2, val);
if (ret < 0) if (ret < 0)
...@@ -378,25 +411,25 @@ int menelaus_set_mmc_slot(int slot, int enable, int power, int cd_en) ...@@ -378,25 +411,25 @@ int menelaus_set_mmc_slot(int slot, int enable, int power, int cd_en)
val = ret; val = ret;
if (slot == 1) { if (slot == 1) {
if (enable) if (enable)
val |= 1 << 0; val |= MCT_CTRL3_SLOT1_EN;
else else
val &= ~(1 << 0); val &= ~MCT_CTRL3_SLOT1_EN;
} else { } else {
int b; int b;
if (enable) if (enable)
val |= 1 << 1; val |= MCT_CTRL3_SLOT2_EN;
else else
val &= ~(1 << 1); val &= ~MCT_CTRL3_SLOT2_EN;
b = menelaus_read_reg(MENELAUS_MCT_CTRL2); b = menelaus_read_reg(MENELAUS_MCT_CTRL2);
b &= ~0x03; b &= ~(MCT_CTRL2_VS2_SEL_D0 | MCT_CTRL2_VS2_SEL_D1);
b |= power; b |= power;
ret = menelaus_write_reg(MENELAUS_MCT_CTRL2, b); ret = menelaus_write_reg(MENELAUS_MCT_CTRL2, b);
if (ret < 0) if (ret < 0)
goto out; goto out;
} }
/* Disable autonomous shutdown */ /* Disable autonomous shutdown */
val &= ~(0x03 << 2); val &= ~(MCT_CTRL3_S1_AUTO_EN | MCT_CTRL3_S2_AUTO_EN);
ret = menelaus_write_reg(MENELAUS_MCT_CTRL3, val); ret = menelaus_write_reg(MENELAUS_MCT_CTRL3, val);
out: out:
mutex_unlock(&the_menelaus->lock); mutex_unlock(&the_menelaus->lock);
...@@ -581,7 +614,7 @@ int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV) ...@@ -581,7 +614,7 @@ int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV)
if (!the_menelaus->vcore_hw_mode) { if (!the_menelaus->vcore_hw_mode) {
val = menelaus_read_reg(MENELAUS_VCORE_CTRL1); val = menelaus_read_reg(MENELAUS_VCORE_CTRL1);
/* HW mode, turn OFF byte comparator */ /* HW mode, turn OFF byte comparator */
val |= ((1 << 7) | (1 << 5)); val |= (VCORE_CTRL1_HW_NSW | VCORE_CTRL1_BYP_COMP);
ret = menelaus_write_reg(MENELAUS_VCORE_CTRL1, val); ret = menelaus_write_reg(MENELAUS_VCORE_CTRL1, val);
the_menelaus->vcore_hw_mode = 1; the_menelaus->vcore_hw_mode = 1;
} }
...@@ -778,7 +811,7 @@ int menelaus_set_regulator_sleep(int enable, u32 val) ...@@ -778,7 +811,7 @@ int menelaus_set_regulator_sleep(int enable, u32 val)
ret = menelaus_read_reg(MENELAUS_GPIO_CTRL); ret = menelaus_read_reg(MENELAUS_GPIO_CTRL);
if (ret < 0) if (ret < 0)
goto out; goto out;
t = ((1 << 6) | 0x04); t = (GPIO_CTRL_SLPCTLEN | GPIO3_DIR_INPUT);
if (enable) if (enable)
ret |= t; ret |= t;
else else
......
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