Commit 4dce3c4b authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'extcon-next-for-4.15' of...

Merge tag 'extcon-next-for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into usb-next

Chanwoo writes:

Update extcon for 4.15

Detailed description for this pull request:
1. Split out extcon header file for consumer and provider device
: The extcon has two type of extcon devices as following.
- 'extcon provider deivce' adds new extcon device and detect
the state/properties of external connector. Also, it notifies the
state/properties to the extcon consumer device.
- 'extcon consumer device' gets the change state/properties
from extcon provider device.

Prior to that, include/linux/extcon.h contains all exported API
for both provider and consumer device driver. To clarify the meaning
of header file and to remove the wrong use-case on consumer device.
- include/linux/extcon-provider.h includes API for the provider device driver.
- include/linux/extcon.h includes the API for the consumer device driver.

2. Support the SmartDock accessory on extcon-max77843.c device driver
- Support the SmartDock accessory which detects following connectors
 at the same time.
 : USB host throught USB hub for mouse, keyboard and so on.
 : MHL connector for video output.
 : Charger connector for battery charging.
- It tested with Unitek Y-2165 MHL+OTG Hub Smart Phone Dock.

3. Fix the minor issue of extcon driver
- Delete the unneeded initialization in extcon-max14577.
- Make extcon_info static const in order to fix the warning.
parents 6bd5bb1e 4a4a8714
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/iio/consumer.h> #include <linux/iio/consumer.h>
#include <linux/extcon/extcon-adc-jack.h> #include <linux/extcon/extcon-adc-jack.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
/** /**
* struct adc_jack_data - internal data for adc_jack device driver * struct adc_jack_data - internal data for adc_jack device driver
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/property.h> #include <linux/property.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <sound/soc.h> #include <sound/soc.h>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h> #include <linux/property.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/extcon/extcon-gpio.h> #include <linux/extcon/extcon-gpio.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* more details. * more details.
*/ */
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mfd/intel_soc_pmic.h> #include <linux/mfd/intel_soc_pmic.h>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mfd/max14577.h> #include <linux/mfd/max14577.h>
#include <linux/mfd/max14577-private.h> #include <linux/mfd/max14577-private.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#define DELAY_MS_DEFAULT 17000 /* unit: millisecond */ #define DELAY_MS_DEFAULT 17000 /* unit: millisecond */
...@@ -204,8 +204,8 @@ static int max14577_muic_set_debounce_time(struct max14577_muic_info *info, ...@@ -204,8 +204,8 @@ static int max14577_muic_set_debounce_time(struct max14577_muic_info *info,
static int max14577_muic_set_path(struct max14577_muic_info *info, static int max14577_muic_set_path(struct max14577_muic_info *info,
u8 val, bool attached) u8 val, bool attached)
{ {
int ret = 0;
u8 ctrl1, ctrl2 = 0; u8 ctrl1, ctrl2 = 0;
int ret;
/* Set open state to path before changing hw path */ /* Set open state to path before changing hw path */
ret = max14577_update_reg(info->max14577->regmap, ret = max14577_update_reg(info->max14577->regmap,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* may be copied, distributed, and modified under those terms. * may be copied, distributed, and modified under those terms.
*/ */
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <linux/mfd/max77693.h> #include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-common.h> #include <linux/mfd/max77693-common.h>
#include <linux/mfd/max77693-private.h> #include <linux/mfd/max77693-private.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* (at your option) any later version. * (at your option) any later version.
*/ */
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -80,7 +80,7 @@ enum max77843_muic_accessory_type { ...@@ -80,7 +80,7 @@ enum max77843_muic_accessory_type {
MAX77843_MUIC_ADC_REMOTE_S12_BUTTON, MAX77843_MUIC_ADC_REMOTE_S12_BUTTON,
MAX77843_MUIC_ADC_RESERVED_ACC_1, MAX77843_MUIC_ADC_RESERVED_ACC_1,
MAX77843_MUIC_ADC_RESERVED_ACC_2, MAX77843_MUIC_ADC_RESERVED_ACC_2,
MAX77843_MUIC_ADC_RESERVED_ACC_3, MAX77843_MUIC_ADC_RESERVED_ACC_3, /* SmartDock */
MAX77843_MUIC_ADC_RESERVED_ACC_4, MAX77843_MUIC_ADC_RESERVED_ACC_4,
MAX77843_MUIC_ADC_RESERVED_ACC_5, MAX77843_MUIC_ADC_RESERVED_ACC_5,
MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2, MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2,
...@@ -119,6 +119,7 @@ enum max77843_muic_charger_type { ...@@ -119,6 +119,7 @@ enum max77843_muic_charger_type {
MAX77843_MUIC_CHG_SPECIAL_BIAS, MAX77843_MUIC_CHG_SPECIAL_BIAS,
MAX77843_MUIC_CHG_RESERVED, MAX77843_MUIC_CHG_RESERVED,
MAX77843_MUIC_CHG_GND, MAX77843_MUIC_CHG_GND,
MAX77843_MUIC_CHG_DOCK,
}; };
static const unsigned int max77843_extcon_cable[] = { static const unsigned int max77843_extcon_cable[] = {
...@@ -130,6 +131,7 @@ static const unsigned int max77843_extcon_cable[] = { ...@@ -130,6 +131,7 @@ static const unsigned int max77843_extcon_cable[] = {
EXTCON_CHG_USB_FAST, EXTCON_CHG_USB_FAST,
EXTCON_CHG_USB_SLOW, EXTCON_CHG_USB_SLOW,
EXTCON_DISP_MHL, EXTCON_DISP_MHL,
EXTCON_DOCK,
EXTCON_JIG, EXTCON_JIG,
EXTCON_NONE, EXTCON_NONE,
}; };
...@@ -200,7 +202,7 @@ static const struct regmap_irq_chip max77843_muic_irq_chip = { ...@@ -200,7 +202,7 @@ static const struct regmap_irq_chip max77843_muic_irq_chip = {
}; };
static int max77843_muic_set_path(struct max77843_muic_info *info, static int max77843_muic_set_path(struct max77843_muic_info *info,
u8 val, bool attached) u8 val, bool attached, bool nobccomp)
{ {
struct max77693_dev *max77843 = info->max77843; struct max77693_dev *max77843 = info->max77843;
int ret = 0; int ret = 0;
...@@ -210,10 +212,16 @@ static int max77843_muic_set_path(struct max77843_muic_info *info, ...@@ -210,10 +212,16 @@ static int max77843_muic_set_path(struct max77843_muic_info *info,
ctrl1 = val; ctrl1 = val;
else else
ctrl1 = MAX77843_MUIC_CONTROL1_SW_OPEN; ctrl1 = MAX77843_MUIC_CONTROL1_SW_OPEN;
if (nobccomp) {
/* Disable BC1.2 protocol and force manual switch control */
ctrl1 |= MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK;
}
ret = regmap_update_bits(max77843->regmap_muic, ret = regmap_update_bits(max77843->regmap_muic,
MAX77843_MUIC_REG_CONTROL1, MAX77843_MUIC_REG_CONTROL1,
MAX77843_MUIC_CONTROL1_COM_SW, ctrl1); MAX77843_MUIC_CONTROL1_COM_SW |
MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK,
ctrl1);
if (ret < 0) { if (ret < 0) {
dev_err(info->dev, "Cannot switch MUIC port\n"); dev_err(info->dev, "Cannot switch MUIC port\n");
return ret; return ret;
...@@ -240,6 +248,21 @@ static int max77843_muic_set_path(struct max77843_muic_info *info, ...@@ -240,6 +248,21 @@ static int max77843_muic_set_path(struct max77843_muic_info *info,
return 0; return 0;
} }
static void max77843_charger_set_otg_vbus(struct max77843_muic_info *info,
bool on)
{
struct max77693_dev *max77843 = info->max77843;
unsigned int cnfg00;
if (on)
cnfg00 = MAX77843_CHG_OTG_MASK | MAX77843_CHG_BOOST_MASK;
else
cnfg00 = MAX77843_CHG_ENABLE | MAX77843_CHG_BUCK_MASK;
regmap_update_bits(max77843->regmap_chg, MAX77843_CHG_REG_CHG_CNFG_00,
MAX77843_CHG_MODE_MASK, cnfg00);
}
static int max77843_muic_get_cable_type(struct max77843_muic_info *info, static int max77843_muic_get_cable_type(struct max77843_muic_info *info,
enum max77843_muic_cable_group group, bool *attached) enum max77843_muic_cable_group group, bool *attached)
{ {
...@@ -288,6 +311,19 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info, ...@@ -288,6 +311,19 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info,
break; break;
} }
if (adc == MAX77843_MUIC_ADC_RESERVED_ACC_3) { /* SmartDock */
if (chg_type == MAX77843_MUIC_CHG_NONE) {
*attached = false;
cable_type = info->prev_chg_type;
info->prev_chg_type = MAX77843_MUIC_CHG_NONE;
} else {
*attached = true;
cable_type = MAX77843_MUIC_CHG_DOCK;
info->prev_chg_type = MAX77843_MUIC_CHG_DOCK;
}
break;
}
if (chg_type == MAX77843_MUIC_CHG_NONE) { if (chg_type == MAX77843_MUIC_CHG_NONE) {
*attached = false; *attached = false;
cable_type = info->prev_chg_type; cable_type = info->prev_chg_type;
...@@ -350,17 +386,18 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info) ...@@ -350,17 +386,18 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info)
case MAX77843_MUIC_GND_USB_HOST_VB: case MAX77843_MUIC_GND_USB_HOST_VB:
ret = max77843_muic_set_path(info, ret = max77843_muic_set_path(info,
MAX77843_MUIC_CONTROL1_SW_USB, MAX77843_MUIC_CONTROL1_SW_USB,
attached); attached, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached);
max77843_charger_set_otg_vbus(info, attached);
break; break;
case MAX77843_MUIC_GND_MHL_VB: case MAX77843_MUIC_GND_MHL_VB:
case MAX77843_MUIC_GND_MHL: case MAX77843_MUIC_GND_MHL:
ret = max77843_muic_set_path(info, ret = max77843_muic_set_path(info,
MAX77843_MUIC_CONTROL1_SW_OPEN, MAX77843_MUIC_CONTROL1_SW_OPEN,
attached); attached, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -396,7 +433,7 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info, ...@@ -396,7 +433,7 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info,
return -EINVAL; return -EINVAL;
} }
ret = max77843_muic_set_path(info, path, attached); ret = max77843_muic_set_path(info, path, attached, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -405,6 +442,26 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info, ...@@ -405,6 +442,26 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info,
return 0; return 0;
} }
static int max77843_muic_dock_handler(struct max77843_muic_info *info,
bool attached)
{
int ret;
dev_dbg(info->dev, "external connector is %s (adc: 0x10)\n",
attached ? "attached" : "detached");
ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB,
attached, attached);
if (ret < 0)
return ret;
extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached);
extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached);
extcon_set_state_sync(info->edev, EXTCON_DOCK, attached);
return 0;
}
static int max77843_muic_adc_handler(struct max77843_muic_info *info) static int max77843_muic_adc_handler(struct max77843_muic_info *info)
{ {
int ret, cable_type; int ret, cable_type;
...@@ -419,6 +476,11 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info) ...@@ -419,6 +476,11 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info)
info->prev_cable_type); info->prev_cable_type);
switch (cable_type) { switch (cable_type) {
case MAX77843_MUIC_ADC_RESERVED_ACC_3: /* SmartDock */
ret = max77843_muic_dock_handler(info, attached);
if (ret < 0)
return ret;
break;
case MAX77843_MUIC_ADC_GROUND: case MAX77843_MUIC_ADC_GROUND:
ret = max77843_muic_adc_gnd_handler(info); ret = max77843_muic_adc_gnd_handler(info);
if (ret < 0) if (ret < 0)
...@@ -446,7 +508,6 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info) ...@@ -446,7 +508,6 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info)
case MAX77843_MUIC_ADC_REMOTE_S12_BUTTON: case MAX77843_MUIC_ADC_REMOTE_S12_BUTTON:
case MAX77843_MUIC_ADC_RESERVED_ACC_1: case MAX77843_MUIC_ADC_RESERVED_ACC_1:
case MAX77843_MUIC_ADC_RESERVED_ACC_2: case MAX77843_MUIC_ADC_RESERVED_ACC_2:
case MAX77843_MUIC_ADC_RESERVED_ACC_3:
case MAX77843_MUIC_ADC_RESERVED_ACC_4: case MAX77843_MUIC_ADC_RESERVED_ACC_4:
case MAX77843_MUIC_ADC_RESERVED_ACC_5: case MAX77843_MUIC_ADC_RESERVED_ACC_5:
case MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2: case MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2:
...@@ -490,7 +551,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) ...@@ -490,7 +551,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
case MAX77843_MUIC_CHG_USB: case MAX77843_MUIC_CHG_USB:
ret = max77843_muic_set_path(info, ret = max77843_muic_set_path(info,
MAX77843_MUIC_CONTROL1_SW_USB, MAX77843_MUIC_CONTROL1_SW_USB,
attached); attached, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -501,7 +562,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) ...@@ -501,7 +562,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
case MAX77843_MUIC_CHG_DOWNSTREAM: case MAX77843_MUIC_CHG_DOWNSTREAM:
ret = max77843_muic_set_path(info, ret = max77843_muic_set_path(info,
MAX77843_MUIC_CONTROL1_SW_OPEN, MAX77843_MUIC_CONTROL1_SW_OPEN,
attached); attached, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -511,7 +572,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) ...@@ -511,7 +572,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
case MAX77843_MUIC_CHG_DEDICATED: case MAX77843_MUIC_CHG_DEDICATED:
ret = max77843_muic_set_path(info, ret = max77843_muic_set_path(info,
MAX77843_MUIC_CONTROL1_SW_OPEN, MAX77843_MUIC_CONTROL1_SW_OPEN,
attached); attached, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -521,7 +582,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) ...@@ -521,7 +582,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
case MAX77843_MUIC_CHG_SPECIAL_500MA: case MAX77843_MUIC_CHG_SPECIAL_500MA:
ret = max77843_muic_set_path(info, ret = max77843_muic_set_path(info,
MAX77843_MUIC_CONTROL1_SW_OPEN, MAX77843_MUIC_CONTROL1_SW_OPEN,
attached); attached, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -531,7 +592,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) ...@@ -531,7 +592,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
case MAX77843_MUIC_CHG_SPECIAL_1A: case MAX77843_MUIC_CHG_SPECIAL_1A:
ret = max77843_muic_set_path(info, ret = max77843_muic_set_path(info,
MAX77843_MUIC_CONTROL1_SW_OPEN, MAX77843_MUIC_CONTROL1_SW_OPEN,
attached); attached, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -550,6 +611,9 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) ...@@ -550,6 +611,9 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
false); false);
break; break;
case MAX77843_MUIC_CHG_DOCK:
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, attached);
break;
case MAX77843_MUIC_CHG_NONE: case MAX77843_MUIC_CHG_NONE:
break; break;
default: default:
...@@ -558,7 +622,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) ...@@ -558,7 +622,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
attached ? "attached" : "detached", chg_type); attached ? "attached" : "detached", chg_type);
max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN,
attached); attached, false);
return -EINVAL; return -EINVAL;
} }
...@@ -798,7 +862,8 @@ static int max77843_muic_probe(struct platform_device *pdev) ...@@ -798,7 +862,8 @@ static int max77843_muic_probe(struct platform_device *pdev)
max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS); max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS);
/* Set initial path for UART */ /* Set initial path for UART */
max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true); max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true,
false);
/* Check revision number of MUIC device */ /* Check revision number of MUIC device */
ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id); ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/mfd/max8997.h> #include <linux/mfd/max8997.h>
#include <linux/mfd/max8997-private.h> #include <linux/mfd/max8997-private.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#define DEV_NAME "max8997-muic" #define DEV_NAME "max8997-muic"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include "extcon-rt8973a.h" #include "extcon-rt8973a.h"
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include "extcon-sm5502.h" #include "extcon-sm5502.h"
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/init.h> #include <linux/init.h>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mfd/cros_ec.h> #include <linux/mfd/cros_ec.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define SUPPORTED_CABLE_MAX 32 #define SUPPORTED_CABLE_MAX 32
struct __extcon_info { static const struct __extcon_info {
unsigned int type; unsigned int type;
unsigned int id; unsigned int id;
const char *name; const char *name;
......
#ifndef __LINUX_EXTCON_INTERNAL_H__ #ifndef __LINUX_EXTCON_INTERNAL_H__
#define __LINUX_EXTCON_INTERNAL_H__ #define __LINUX_EXTCON_INTERNAL_H__
#include <linux/extcon.h> #include <linux/extcon-provider.h>
/** /**
* struct extcon_dev - An extcon device represents one external connector. * struct extcon_dev - An extcon device represents one external connector.
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
*/ */
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/init.h> #include <linux/init.h>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <linux/power_supply.h> #include <linux/power_supply.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#define SMBB_CHG_VMAX 0x040 #define SMBB_CHG_VMAX 0x040
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
......
/*
* External Connector (extcon) framework
* - linux/include/linux/extcon-provider.h for extcon provider device driver.
*
* Copyright (C) 2017 Samsung Electronics
* Author: Chanwoo Choi <cw00.choi@samsung.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __LINUX_EXTCON_PROVIDER_H__
#define __LINUX_EXTCON_PROVIDER_H__
#include <linux/extcon.h>
struct extcon_dev;
#if IS_ENABLED(CONFIG_EXTCON)
/* Following APIs register/unregister the extcon device. */
extern int extcon_dev_register(struct extcon_dev *edev);
extern void extcon_dev_unregister(struct extcon_dev *edev);
extern int devm_extcon_dev_register(struct device *dev,
struct extcon_dev *edev);
extern void devm_extcon_dev_unregister(struct device *dev,
struct extcon_dev *edev);
/* Following APIs allocate/free the memory of the extcon device. */
extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
extern void extcon_dev_free(struct extcon_dev *edev);
extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
const unsigned int *cable);
extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
/* Synchronize the state and property value for each external connector. */
extern int extcon_sync(struct extcon_dev *edev, unsigned int id);
/*
* Following APIs set the connected state of each external connector.
* The 'id' argument indicates the defined external connector.
*/
extern int extcon_set_state(struct extcon_dev *edev, unsigned int id,
bool state);
extern int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
bool state);
/*
* Following APIs set the property of each external connector.
* The 'id' argument indicates the defined external connector
* and the 'prop' indicates the extcon property.
*
* And extcon_set_property_capability() set the capability of the property
* for each external connector. They are used to set the capability of the
* property of each external connector based on the id and property.
*/
extern int extcon_set_property(struct extcon_dev *edev, unsigned int id,
unsigned int prop,
union extcon_property_value prop_val);
extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
unsigned int prop,
union extcon_property_value prop_val);
extern int extcon_set_property_capability(struct extcon_dev *edev,
unsigned int id, unsigned int prop);
#else /* CONFIG_EXTCON */
static inline int extcon_dev_register(struct extcon_dev *edev)
{
return 0;
}
static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
static inline int devm_extcon_dev_register(struct device *dev,
struct extcon_dev *edev)
{
return -EINVAL;
}
static inline void devm_extcon_dev_unregister(struct device *dev,
struct extcon_dev *edev) { }
static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
{
return ERR_PTR(-ENOSYS);
}
static inline void extcon_dev_free(struct extcon_dev *edev) { }
static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
const unsigned int *cable)
{
return ERR_PTR(-ENOSYS);
}
static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
bool state)
{
return 0;
}
static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
bool state)
{
return 0;
}
static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
{
return 0;
}
static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
unsigned int prop,
union extcon_property_value prop_val)
{
return 0;
}
static inline int extcon_set_property_sync(struct extcon_dev *edev,
unsigned int id, unsigned int prop,
union extcon_property_value prop_val)
{
return 0;
}
static inline int extcon_set_property_capability(struct extcon_dev *edev,
unsigned int id, unsigned int prop)
{
return 0;
}
#endif /* CONFIG_EXTCON */
#endif /* __LINUX_EXTCON_PROVIDER_H__ */
/* /*
* External Connector (extcon) framework * External Connector (extcon) framework
* - linux/include/linux/extcon.h for extcon consumer device driver.
* *
* Copyright (C) 2015 Samsung Electronics * Copyright (C) 2015 Samsung Electronics
* Author: Chanwoo Choi <cw00.choi@samsung.com> * Author: Chanwoo Choi <cw00.choi@samsung.com>
...@@ -170,61 +171,29 @@ union extcon_property_value { ...@@ -170,61 +171,29 @@ union extcon_property_value {
int intval; /* type : integer (intval) */ int intval; /* type : integer (intval) */
}; };
struct extcon_cable;
struct extcon_dev; struct extcon_dev;
#if IS_ENABLED(CONFIG_EXTCON) #if IS_ENABLED(CONFIG_EXTCON)
/* Following APIs register/unregister the extcon device. */
extern int extcon_dev_register(struct extcon_dev *edev);
extern void extcon_dev_unregister(struct extcon_dev *edev);
extern int devm_extcon_dev_register(struct device *dev,
struct extcon_dev *edev);
extern void devm_extcon_dev_unregister(struct device *dev,
struct extcon_dev *edev);
/* Following APIs allocate/free the memory of the extcon device. */
extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
extern void extcon_dev_free(struct extcon_dev *edev);
extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
const unsigned int *cable);
extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
/* Synchronize the state and property value for each external connector. */
extern int extcon_sync(struct extcon_dev *edev, unsigned int id);
/* /*
* Following APIs get/set the connected state of each external connector. * Following APIs get the connected state of each external connector.
* The 'id' argument indicates the defined external connector. * The 'id' argument indicates the defined external connector.
*/ */
extern int extcon_get_state(struct extcon_dev *edev, unsigned int id); extern int extcon_get_state(struct extcon_dev *edev, unsigned int id);
extern int extcon_set_state(struct extcon_dev *edev, unsigned int id,
bool state);
extern int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
bool state);
/* /*
* Following APIs get/set the property of each external connector. * Following APIs get the property of each external connector.
* The 'id' argument indicates the defined external connector * The 'id' argument indicates the defined external connector
* and the 'prop' indicates the extcon property. * and the 'prop' indicates the extcon property.
* *
* And extcon_get/set_property_capability() set the capability of the property * And extcon_get_property_capability() get the capability of the property
* for each external connector. They are used to set the capability of the * for each external connector. They are used to get the capability of the
* property of each external connector based on the id and property. * property of each external connector based on the id and property.
*/ */
extern int extcon_get_property(struct extcon_dev *edev, unsigned int id, extern int extcon_get_property(struct extcon_dev *edev, unsigned int id,
unsigned int prop, unsigned int prop,
union extcon_property_value *prop_val); union extcon_property_value *prop_val);
extern int extcon_set_property(struct extcon_dev *edev, unsigned int id,
unsigned int prop,
union extcon_property_value prop_val);
extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
unsigned int prop,
union extcon_property_value prop_val);
extern int extcon_get_property_capability(struct extcon_dev *edev, extern int extcon_get_property_capability(struct extcon_dev *edev,
unsigned int id, unsigned int prop); unsigned int id, unsigned int prop);
extern int extcon_set_property_capability(struct extcon_dev *edev,
unsigned int id, unsigned int prop);
/* /*
* Following APIs register the notifier block in order to detect * Following APIs register the notifier block in order to detect
...@@ -268,79 +237,17 @@ extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, ...@@ -268,79 +237,17 @@ extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
extern const char *extcon_get_edev_name(struct extcon_dev *edev); extern const char *extcon_get_edev_name(struct extcon_dev *edev);
#else /* CONFIG_EXTCON */ #else /* CONFIG_EXTCON */
static inline int extcon_dev_register(struct extcon_dev *edev)
{
return 0;
}
static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
static inline int devm_extcon_dev_register(struct device *dev,
struct extcon_dev *edev)
{
return -EINVAL;
}
static inline void devm_extcon_dev_unregister(struct device *dev,
struct extcon_dev *edev) { }
static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
{
return ERR_PTR(-ENOSYS);
}
static inline void extcon_dev_free(struct extcon_dev *edev) { }
static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
const unsigned int *cable)
{
return ERR_PTR(-ENOSYS);
}
static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id) static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id)
{ {
return 0; return 0;
} }
static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
bool state)
{
return 0;
}
static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
bool state)
{
return 0;
}
static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
{
return 0;
}
static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id, static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id,
unsigned int prop, unsigned int prop,
union extcon_property_value *prop_val) union extcon_property_value *prop_val)
{ {
return 0; return 0;
} }
static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
unsigned int prop,
union extcon_property_value prop_val)
{
return 0;
}
static inline int extcon_set_property_sync(struct extcon_dev *edev,
unsigned int id, unsigned int prop,
union extcon_property_value prop_val)
{
return 0;
}
static inline int extcon_get_property_capability(struct extcon_dev *edev, static inline int extcon_get_property_capability(struct extcon_dev *edev,
unsigned int id, unsigned int prop) unsigned int id, unsigned int prop)
...@@ -348,12 +255,6 @@ static inline int extcon_get_property_capability(struct extcon_dev *edev, ...@@ -348,12 +255,6 @@ static inline int extcon_get_property_capability(struct extcon_dev *edev,
return 0; return 0;
} }
static inline int extcon_set_property_capability(struct extcon_dev *edev,
unsigned int id, unsigned int prop)
{
return 0;
}
static inline int extcon_register_notifier(struct extcon_dev *edev, static inline int extcon_register_notifier(struct extcon_dev *edev,
unsigned int id, struct notifier_block *nb) unsigned int id, struct notifier_block *nb)
{ {
......
...@@ -245,10 +245,13 @@ enum max77843_irq_muic { ...@@ -245,10 +245,13 @@ enum max77843_irq_muic {
#define MAX77843_CHG_OVER_CURRENT_BAT (0x06 << 4) #define MAX77843_CHG_OVER_CURRENT_BAT (0x06 << 4)
/* MAX77843 CHG_CNFG_00 register */ /* MAX77843 CHG_CNFG_00 register */
#define MAX77843_CHG_MODE_MASK 0x0f
#define MAX77843_CHG_DISABLE 0x00 #define MAX77843_CHG_DISABLE 0x00
#define MAX77843_CHG_ENABLE 0x05 #define MAX77843_CHG_ENABLE 0x05
#define MAX77843_CHG_MASK 0x01 #define MAX77843_CHG_MASK 0x01
#define MAX77843_CHG_OTG_MASK 0x02
#define MAX77843_CHG_BUCK_MASK 0x04 #define MAX77843_CHG_BUCK_MASK 0x04
#define MAX77843_CHG_BOOST_MASK 0x08
/* MAX77843 CHG_CNFG_01 register */ /* MAX77843 CHG_CNFG_01 register */
#define MAX77843_CHG_RESTART_THRESHOLD_100 0x00 #define MAX77843_CHG_RESTART_THRESHOLD_100 0x00
...@@ -347,6 +350,7 @@ enum max77843_irq_muic { ...@@ -347,6 +350,7 @@ enum max77843_irq_muic {
/* MAX77843 CONTROL register */ /* MAX77843 CONTROL register */
#define MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT 0 #define MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT 0
#define MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT 3 #define MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT 3
#define MAX77843_MUIC_CONTROL1_NOBCCOMP_SHIFT 6
#define MAX77843_MUIC_CONTROL1_IDBEN_SHIFT 7 #define MAX77843_MUIC_CONTROL1_IDBEN_SHIFT 7
#define MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT 0 #define MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT 0
#define MAX77843_MUIC_CONTROL2_ADCEN_SHIFT 1 #define MAX77843_MUIC_CONTROL2_ADCEN_SHIFT 1
...@@ -363,6 +367,7 @@ enum max77843_irq_muic { ...@@ -363,6 +367,7 @@ enum max77843_irq_muic {
#define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT) #define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT)
#define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT) #define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT)
#define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(MAX77843_MUIC_CONTROL1_IDBEN_SHIFT) #define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(MAX77843_MUIC_CONTROL1_IDBEN_SHIFT)
#define MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK BIT(MAX77843_MUIC_CONTROL1_NOBCCOMP_SHIFT)
#define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT) #define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT)
#define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(MAX77843_MUIC_CONTROL2_ADCEN_SHIFT) #define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(MAX77843_MUIC_CONTROL2_ADCEN_SHIFT)
#define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(MAX77843_MUIC_CONTROL2_CPEN_SHIFT) #define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(MAX77843_MUIC_CONTROL2_CPEN_SHIFT)
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/extcon.h> #include <linux/extcon-provider.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/usb/phy_companion.h> #include <linux/usb/phy_companion.h>
......
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