mfd/extcon: max77693: Rename defines to allow inclusion with max77843

Add MAX77693 prefix to some of the defines used in max77693 extcon
driver so the max77693-private.h can be included simultaneously with
max77843-private.h.

Additionally use BIT() macro in header.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Krzysztof Kozlowski 2015-07-15 21:59:52 +09:00 committed by Mark Brown
parent bc1aadc186
commit cceb433a1e
2 changed files with 86 additions and 82 deletions

View File

@ -43,7 +43,7 @@ static struct max77693_reg_data default_init_data[] = {
{ {
/* STATUS2 - [3]ChgDetRun */ /* STATUS2 - [3]ChgDetRun */
.addr = MAX77693_MUIC_REG_STATUS2, .addr = MAX77693_MUIC_REG_STATUS2,
.data = STATUS2_CHGDETRUN_MASK, .data = MAX77693_STATUS2_CHGDETRUN_MASK,
}, { }, {
/* INTMASK1 - Unmask [3]ADC1KM,[0]ADCM */ /* INTMASK1 - Unmask [3]ADC1KM,[0]ADCM */
.addr = MAX77693_MUIC_REG_INTMASK1, .addr = MAX77693_MUIC_REG_INTMASK1,
@ -236,7 +236,7 @@ static int max77693_muic_set_debounce_time(struct max77693_muic_info *info,
*/ */
ret = regmap_write(info->max77693->regmap_muic, ret = regmap_write(info->max77693->regmap_muic,
MAX77693_MUIC_REG_CTRL3, MAX77693_MUIC_REG_CTRL3,
time << CONTROL3_ADCDBSET_SHIFT); time << MAX77693_CONTROL3_ADCDBSET_SHIFT);
if (ret) { if (ret) {
dev_err(info->dev, "failed to set ADC debounce time\n"); dev_err(info->dev, "failed to set ADC debounce time\n");
return ret; return ret;
@ -269,7 +269,7 @@ static int max77693_muic_set_path(struct max77693_muic_info *info,
if (attached) if (attached)
ctrl1 = val; ctrl1 = val;
else else
ctrl1 = CONTROL1_SW_OPEN; ctrl1 = MAX77693_CONTROL1_SW_OPEN;
ret = regmap_update_bits(info->max77693->regmap_muic, ret = regmap_update_bits(info->max77693->regmap_muic,
MAX77693_MUIC_REG_CTRL1, COMP_SW_MASK, ctrl1); MAX77693_MUIC_REG_CTRL1, COMP_SW_MASK, ctrl1);
@ -279,13 +279,14 @@ static int max77693_muic_set_path(struct max77693_muic_info *info,
} }
if (attached) if (attached)
ctrl2 |= CONTROL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */ ctrl2 |= MAX77693_CONTROL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */
else else
ctrl2 |= CONTROL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */ ctrl2 |= MAX77693_CONTROL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */
ret = regmap_update_bits(info->max77693->regmap_muic, ret = regmap_update_bits(info->max77693->regmap_muic,
MAX77693_MUIC_REG_CTRL2, MAX77693_MUIC_REG_CTRL2,
CONTROL2_LOWPWR_MASK | CONTROL2_CPEN_MASK, ctrl2); MAX77693_CONTROL2_LOWPWR_MASK | MAX77693_CONTROL2_CPEN_MASK,
ctrl2);
if (ret < 0) { if (ret < 0) {
dev_err(info->dev, "failed to update MUIC register\n"); dev_err(info->dev, "failed to update MUIC register\n");
return ret; return ret;
@ -327,8 +328,8 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
* Read ADC value to check cable type and decide cable state * Read ADC value to check cable type and decide cable state
* according to cable type * according to cable type
*/ */
adc = info->status[0] & STATUS1_ADC_MASK; adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
adc >>= STATUS1_ADC_SHIFT; adc >>= MAX77693_STATUS1_ADC_SHIFT;
/* /*
* Check current cable state/cable type and store cable type * Check current cable state/cable type and store cable type
@ -351,8 +352,8 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
* Read ADC value to check cable type and decide cable state * Read ADC value to check cable type and decide cable state
* according to cable type * according to cable type
*/ */
adc = info->status[0] & STATUS1_ADC_MASK; adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
adc >>= STATUS1_ADC_SHIFT; adc >>= MAX77693_STATUS1_ADC_SHIFT;
/* /*
* Check current cable state/cable type and store cable type * Check current cable state/cable type and store cable type
@ -367,13 +368,13 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
} else { } else {
*attached = true; *attached = true;
adclow = info->status[0] & STATUS1_ADCLOW_MASK; adclow = info->status[0] & MAX77693_STATUS1_ADCLOW_MASK;
adclow >>= STATUS1_ADCLOW_SHIFT; adclow >>= MAX77693_STATUS1_ADCLOW_SHIFT;
adc1k = info->status[0] & STATUS1_ADC1K_MASK; adc1k = info->status[0] & MAX77693_STATUS1_ADC1K_MASK;
adc1k >>= STATUS1_ADC1K_SHIFT; adc1k >>= MAX77693_STATUS1_ADC1K_SHIFT;
vbvolt = info->status[1] & STATUS2_VBVOLT_MASK; vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK;
vbvolt >>= STATUS2_VBVOLT_SHIFT; vbvolt >>= MAX77693_STATUS2_VBVOLT_SHIFT;
/** /**
* [0x1|VBVolt|ADCLow|ADC1K] * [0x1|VBVolt|ADCLow|ADC1K]
@ -398,8 +399,8 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
* Read charger type to check cable type and decide cable state * Read charger type to check cable type and decide cable state
* according to type of charger cable. * according to type of charger cable.
*/ */
chg_type = info->status[1] & STATUS2_CHGTYP_MASK; chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK;
chg_type >>= STATUS2_CHGTYP_SHIFT; chg_type >>= MAX77693_STATUS2_CHGTYP_SHIFT;
if (chg_type == MAX77693_CHARGER_TYPE_NONE) { if (chg_type == MAX77693_CHARGER_TYPE_NONE) {
*attached = false; *attached = false;
@ -423,10 +424,10 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
* Read ADC value to check cable type and decide cable state * Read ADC value to check cable type and decide cable state
* according to cable type * according to cable type
*/ */
adc = info->status[0] & STATUS1_ADC_MASK; adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
adc >>= STATUS1_ADC_SHIFT; adc >>= MAX77693_STATUS1_ADC_SHIFT;
chg_type = info->status[1] & STATUS2_CHGTYP_MASK; chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK;
chg_type >>= STATUS2_CHGTYP_SHIFT; chg_type >>= MAX77693_STATUS2_CHGTYP_SHIFT;
if (adc == MAX77693_MUIC_ADC_OPEN if (adc == MAX77693_MUIC_ADC_OPEN
&& chg_type == MAX77693_CHARGER_TYPE_NONE) && chg_type == MAX77693_CHARGER_TYPE_NONE)
@ -438,8 +439,8 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
* Read vbvolt field, if vbvolt is 1, * Read vbvolt field, if vbvolt is 1,
* this cable is used for charging. * this cable is used for charging.
*/ */
vbvolt = info->status[1] & STATUS2_VBVOLT_MASK; vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK;
vbvolt >>= STATUS2_VBVOLT_SHIFT; vbvolt >>= MAX77693_STATUS2_VBVOLT_SHIFT;
cable_type = vbvolt; cable_type = vbvolt;
break; break;
@ -521,7 +522,8 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
} }
/* Dock-Car/Desk/Audio, PATH:AUDIO */ /* Dock-Car/Desk/Audio, PATH:AUDIO */
ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO,
attached);
if (ret < 0) if (ret < 0)
return ret; return ret;
extcon_set_cable_state_(info->edev, dock_id, attached); extcon_set_cable_state_(info->edev, dock_id, attached);
@ -586,14 +588,16 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info)
case MAX77693_MUIC_GND_USB_HOST: case MAX77693_MUIC_GND_USB_HOST:
case MAX77693_MUIC_GND_USB_HOST_VB: case MAX77693_MUIC_GND_USB_HOST_VB:
/* USB_HOST, PATH: AP_USB */ /* USB_HOST, PATH: AP_USB */
ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_USB,
attached);
if (ret < 0) if (ret < 0)
return ret; return ret;
extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, attached); extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, attached);
break; break;
case MAX77693_MUIC_GND_AV_CABLE_LOAD: case MAX77693_MUIC_GND_AV_CABLE_LOAD:
/* Audio Video Cable with load, PATH:AUDIO */ /* Audio Video Cable with load, PATH:AUDIO */
ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO,
attached);
if (ret < 0) if (ret < 0)
return ret; return ret;
extcon_set_cable_state_(info->edev, EXTCON_USB, attached); extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
@ -616,7 +620,7 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info,
int cable_type, bool attached) int cable_type, bool attached)
{ {
int ret = 0; int ret = 0;
u8 path = CONTROL1_SW_OPEN; u8 path = MAX77693_CONTROL1_SW_OPEN;
dev_info(info->dev, dev_info(info->dev,
"external connector is %s (adc:0x%02x)\n", "external connector is %s (adc:0x%02x)\n",
@ -626,12 +630,12 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info,
case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */ case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */
case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */ case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */
/* PATH:AP_USB */ /* PATH:AP_USB */
path = CONTROL1_SW_USB; path = MAX77693_CONTROL1_SW_USB;
break; break;
case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */ case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */
case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* ADC_JIG_UART_ON */ case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* ADC_JIG_UART_ON */
/* PATH:AP_UART */ /* PATH:AP_UART */
path = CONTROL1_SW_UART; path = MAX77693_CONTROL1_SW_UART;
break; break;
default: default:
dev_err(info->dev, "failed to detect %s jig cable\n", dev_err(info->dev, "failed to detect %s jig cable\n",
@ -1181,12 +1185,12 @@ static int max77693_muic_probe(struct platform_device *pdev)
if (muic_pdata->path_uart) if (muic_pdata->path_uart)
info->path_uart = muic_pdata->path_uart; info->path_uart = muic_pdata->path_uart;
else else
info->path_uart = CONTROL1_SW_UART; info->path_uart = MAX77693_CONTROL1_SW_UART;
if (muic_pdata->path_usb) if (muic_pdata->path_usb)
info->path_usb = muic_pdata->path_usb; info->path_usb = muic_pdata->path_usb;
else else
info->path_usb = CONTROL1_SW_USB; info->path_usb = MAX77693_CONTROL1_SW_USB;
/* /*
* Default delay time for detecting cable state * Default delay time for detecting cable state
@ -1198,8 +1202,8 @@ static int max77693_muic_probe(struct platform_device *pdev)
else else
delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
} else { } else {
info->path_usb = CONTROL1_SW_USB; info->path_usb = MAX77693_CONTROL1_SW_USB;
info->path_uart = CONTROL1_SW_UART; info->path_uart = MAX77693_CONTROL1_SW_UART;
delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
} }

View File

@ -310,30 +310,30 @@ enum max77693_muic_reg {
#define INTMASK2_CHGTYP_MASK (1 << INTMASK2_CHGTYP_SHIFT) #define INTMASK2_CHGTYP_MASK (1 << INTMASK2_CHGTYP_SHIFT)
/* MAX77693 MUIC - STATUS1~3 Register */ /* MAX77693 MUIC - STATUS1~3 Register */
#define STATUS1_ADC_SHIFT (0) #define MAX77693_STATUS1_ADC_SHIFT 0
#define STATUS1_ADCLOW_SHIFT (5) #define MAX77693_STATUS1_ADCLOW_SHIFT 5
#define STATUS1_ADCERR_SHIFT (6) #define MAX77693_STATUS1_ADCERR_SHIFT 6
#define STATUS1_ADC1K_SHIFT (7) #define MAX77693_STATUS1_ADC1K_SHIFT 7
#define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT) #define MAX77693_STATUS1_ADC_MASK (0x1f << MAX77693_STATUS1_ADC_SHIFT)
#define STATUS1_ADCLOW_MASK (0x1 << STATUS1_ADCLOW_SHIFT) #define MAX77693_STATUS1_ADCLOW_MASK BIT(MAX77693_STATUS1_ADCLOW_SHIFT)
#define STATUS1_ADCERR_MASK (0x1 << STATUS1_ADCERR_SHIFT) #define MAX77693_STATUS1_ADCERR_MASK BIT(MAX77693_STATUS1_ADCERR_SHIFT)
#define STATUS1_ADC1K_MASK (0x1 << STATUS1_ADC1K_SHIFT) #define MAX77693_STATUS1_ADC1K_MASK BIT(MAX77693_STATUS1_ADC1K_SHIFT)
#define STATUS2_CHGTYP_SHIFT (0) #define MAX77693_STATUS2_CHGTYP_SHIFT 0
#define STATUS2_CHGDETRUN_SHIFT (3) #define MAX77693_STATUS2_CHGDETRUN_SHIFT 3
#define STATUS2_DCDTMR_SHIFT (4) #define MAX77693_STATUS2_DCDTMR_SHIFT 4
#define STATUS2_DXOVP_SHIFT (5) #define MAX77693_STATUS2_DXOVP_SHIFT 5
#define STATUS2_VBVOLT_SHIFT (6) #define MAX77693_STATUS2_VBVOLT_SHIFT 6
#define STATUS2_VIDRM_SHIFT (7) #define MAX77693_STATUS2_VIDRM_SHIFT 7
#define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT) #define MAX77693_STATUS2_CHGTYP_MASK (0x7 << MAX77693_STATUS2_CHGTYP_SHIFT)
#define STATUS2_CHGDETRUN_MASK (0x1 << STATUS2_CHGDETRUN_SHIFT) #define MAX77693_STATUS2_CHGDETRUN_MASK BIT(MAX77693_STATUS2_CHGDETRUN_SHIFT)
#define STATUS2_DCDTMR_MASK (0x1 << STATUS2_DCDTMR_SHIFT) #define MAX77693_STATUS2_DCDTMR_MASK BIT(MAX77693_STATUS2_DCDTMR_SHIFT)
#define STATUS2_DXOVP_MASK (0x1 << STATUS2_DXOVP_SHIFT) #define MAX77693_STATUS2_DXOVP_MASK BIT(MAX77693_STATUS2_DXOVP_SHIFT)
#define STATUS2_VBVOLT_MASK (0x1 << STATUS2_VBVOLT_SHIFT) #define MAX77693_STATUS2_VBVOLT_MASK BIT(MAX77693_STATUS2_VBVOLT_SHIFT)
#define STATUS2_VIDRM_MASK (0x1 << STATUS2_VIDRM_SHIFT) #define MAX77693_STATUS2_VIDRM_MASK BIT(MAX77693_STATUS2_VIDRM_SHIFT)
#define STATUS3_OVP_SHIFT (2) #define MAX77693_STATUS3_OVP_SHIFT 2
#define STATUS3_OVP_MASK (0x1 << STATUS3_OVP_SHIFT) #define MAX77693_STATUS3_OVP_MASK BIT(MAX77693_STATUS3_OVP_SHIFT)
/* MAX77693 CDETCTRL1~2 register */ /* MAX77693 CDETCTRL1~2 register */
#define CDETCTRL1_CHGDETEN_SHIFT (0) #define CDETCTRL1_CHGDETEN_SHIFT (0)
@ -362,38 +362,38 @@ enum max77693_muic_reg {
#define COMN1SW_MASK (0x7 << COMN1SW_SHIFT) #define COMN1SW_MASK (0x7 << COMN1SW_SHIFT)
#define COMP2SW_MASK (0x7 << COMP2SW_SHIFT) #define COMP2SW_MASK (0x7 << COMP2SW_SHIFT)
#define COMP_SW_MASK (COMP2SW_MASK | COMN1SW_MASK) #define COMP_SW_MASK (COMP2SW_MASK | COMN1SW_MASK)
#define CONTROL1_SW_USB ((1 << COMP2SW_SHIFT) \ #define MAX77693_CONTROL1_SW_USB ((1 << COMP2SW_SHIFT) \
| (1 << COMN1SW_SHIFT)) | (1 << COMN1SW_SHIFT))
#define CONTROL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \ #define MAX77693_CONTROL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \
| (2 << COMN1SW_SHIFT)) | (2 << COMN1SW_SHIFT))
#define CONTROL1_SW_UART ((3 << COMP2SW_SHIFT) \ #define MAX77693_CONTROL1_SW_UART ((3 << COMP2SW_SHIFT) \
| (3 << COMN1SW_SHIFT)) | (3 << COMN1SW_SHIFT))
#define CONTROL1_SW_OPEN ((0 << COMP2SW_SHIFT) \ #define MAX77693_CONTROL1_SW_OPEN ((0 << COMP2SW_SHIFT) \
| (0 << COMN1SW_SHIFT)) | (0 << COMN1SW_SHIFT))
#define CONTROL2_LOWPWR_SHIFT (0) #define MAX77693_CONTROL2_LOWPWR_SHIFT 0
#define CONTROL2_ADCEN_SHIFT (1) #define MAX77693_CONTROL2_ADCEN_SHIFT 1
#define CONTROL2_CPEN_SHIFT (2) #define MAX77693_CONTROL2_CPEN_SHIFT 2
#define CONTROL2_SFOUTASRT_SHIFT (3) #define MAX77693_CONTROL2_SFOUTASRT_SHIFT 3
#define CONTROL2_SFOUTORD_SHIFT (4) #define MAX77693_CONTROL2_SFOUTORD_SHIFT 4
#define CONTROL2_ACCDET_SHIFT (5) #define MAX77693_CONTROL2_ACCDET_SHIFT 5
#define CONTROL2_USBCPINT_SHIFT (6) #define MAX77693_CONTROL2_USBCPINT_SHIFT 6
#define CONTROL2_RCPS_SHIFT (7) #define MAX77693_CONTROL2_RCPS_SHIFT 7
#define CONTROL2_LOWPWR_MASK (0x1 << CONTROL2_LOWPWR_SHIFT) #define MAX77693_CONTROL2_LOWPWR_MASK BIT(MAX77693_CONTROL2_LOWPWR_SHIFT)
#define CONTROL2_ADCEN_MASK (0x1 << CONTROL2_ADCEN_SHIFT) #define MAX77693_CONTROL2_ADCEN_MASK BIT(MAX77693_CONTROL2_ADCEN_SHIFT)
#define CONTROL2_CPEN_MASK (0x1 << CONTROL2_CPEN_SHIFT) #define MAX77693_CONTROL2_CPEN_MASK BIT(MAX77693_CONTROL2_CPEN_SHIFT)
#define CONTROL2_SFOUTASRT_MASK (0x1 << CONTROL2_SFOUTASRT_SHIFT) #define MAX77693_CONTROL2_SFOUTASRT_MASK BIT(MAX77693_CONTROL2_SFOUTASRT_SHIFT)
#define CONTROL2_SFOUTORD_MASK (0x1 << CONTROL2_SFOUTORD_SHIFT) #define MAX77693_CONTROL2_SFOUTORD_MASK BIT(MAX77693_CONTROL2_SFOUTORD_SHIFT)
#define CONTROL2_ACCDET_MASK (0x1 << CONTROL2_ACCDET_SHIFT) #define MAX77693_CONTROL2_ACCDET_MASK BIT(MAX77693_CONTROL2_ACCDET_SHIFT)
#define CONTROL2_USBCPINT_MASK (0x1 << CONTROL2_USBCPINT_SHIFT) #define MAX77693_CONTROL2_USBCPINT_MASK BIT(MAX77693_CONTROL2_USBCPINT_SHIFT)
#define CONTROL2_RCPS_MASK (0x1 << CONTROL2_RCPS_SHIFT) #define MAX77693_CONTROL2_RCPS_MASK BIT(MAX77693_CONTROL2_RCPS_SHIFT)
#define CONTROL3_JIGSET_SHIFT (0) #define MAX77693_CONTROL3_JIGSET_SHIFT 0
#define CONTROL3_BTLDSET_SHIFT (2) #define MAX77693_CONTROL3_BTLDSET_SHIFT 2
#define CONTROL3_ADCDBSET_SHIFT (4) #define MAX77693_CONTROL3_ADCDBSET_SHIFT 4
#define CONTROL3_JIGSET_MASK (0x3 << CONTROL3_JIGSET_SHIFT) #define MAX77693_CONTROL3_JIGSET_MASK (0x3 << MAX77693_CONTROL3_JIGSET_SHIFT)
#define CONTROL3_BTLDSET_MASK (0x3 << CONTROL3_BTLDSET_SHIFT) #define MAX77693_CONTROL3_BTLDSET_MASK (0x3 << MAX77693_CONTROL3_BTLDSET_SHIFT)
#define CONTROL3_ADCDBSET_MASK (0x3 << CONTROL3_ADCDBSET_SHIFT) #define MAX77693_CONTROL3_ADCDBSET_MASK (0x3 << MAX77693_CONTROL3_ADCDBSET_SHIFT)
/* Slave addr = 0x90: Haptic */ /* Slave addr = 0x90: Haptic */
enum max77693_haptic_reg { enum max77693_haptic_reg {