Commit 449a97d0 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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

Merge tag 'extcon-next-for-4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-testing

Chanwoo writes:

Update extcon for 4.6

Detailed description for patchset:
1. Add new EXTCON_CHG_USB_SDP type
- SDP (Standard Downstream Port) USB Charging Port
  means the charging connector.a

2. Add the VBUS detection by using GPIO on extcon-palmas
- Beaglex15 board uses the extcon-palmas driver
  But, beaglex15 board need the GPIO support for VBUS
  detection.

3. Fix the minor issue of extcon drivers
parents 523462df ae64e42c
...@@ -562,8 +562,7 @@ tps659038_gpio: tps659038_gpio { ...@@ -562,8 +562,7 @@ tps659038_gpio: tps659038_gpio {
extcon_usb2: tps659038_usb { extcon_usb2: tps659038_usb {
compatible = "ti,palmas-usb-vid"; compatible = "ti,palmas-usb-vid";
ti,enable-vbus-detection; ti,enable-vbus-detection;
ti,enable-id-detection; vbus-gpio = <&gpio4 21 GPIO_ACTIVE_HIGH>;
id-gpios = <&gpio7 24 GPIO_ACTIVE_HIGH>;
}; };
}; };
......
...@@ -185,7 +185,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info, ...@@ -185,7 +185,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
break; break;
}; };
mutex_lock(&arizona->dapm->card->dapm_mutex); snd_soc_dapm_mutex_lock(arizona->dapm);
arizona->hpdet_clamp = clamp; arizona->hpdet_clamp = clamp;
...@@ -227,7 +227,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info, ...@@ -227,7 +227,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
ret); ret);
} }
mutex_unlock(&arizona->dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(arizona->dapm);
} }
static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode) static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
......
...@@ -126,7 +126,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) ...@@ -126,7 +126,7 @@ static int gpio_extcon_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&data->work, gpio_extcon_work); INIT_DELAYED_WORK(&data->work, gpio_extcon_work);
/* /*
* Request the interrput of gpio to detect whether external connector * Request the interrupt of gpio to detect whether external connector
* is attached or detached. * is attached or detached.
*/ */
ret = devm_request_any_context_irq(&pdev->dev, data->irq, ret = devm_request_any_context_irq(&pdev->dev, data->irq,
......
...@@ -150,6 +150,7 @@ enum max14577_muic_acc_type { ...@@ -150,6 +150,7 @@ enum max14577_muic_acc_type {
static const unsigned int max14577_extcon_cable[] = { static const unsigned int max14577_extcon_cable[] = {
EXTCON_USB, EXTCON_USB,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP, EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_FAST, EXTCON_CHG_USB_FAST,
EXTCON_CHG_USB_SLOW, EXTCON_CHG_USB_SLOW,
...@@ -454,6 +455,8 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info) ...@@ -454,6 +455,8 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info)
return ret; return ret;
extcon_set_cable_state_(info->edev, EXTCON_USB, attached); extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break; break;
case MAX14577_CHARGER_TYPE_DEDICATED_CHG: case MAX14577_CHARGER_TYPE_DEDICATED_CHG:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_DCP, extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_DCP,
......
...@@ -204,6 +204,7 @@ enum max77693_muic_acc_type { ...@@ -204,6 +204,7 @@ enum max77693_muic_acc_type {
static const unsigned int max77693_extcon_cable[] = { static const unsigned int max77693_extcon_cable[] = {
EXTCON_USB, EXTCON_USB,
EXTCON_USB_HOST, EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP, EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_FAST, EXTCON_CHG_USB_FAST,
EXTCON_CHG_USB_SLOW, EXTCON_CHG_USB_SLOW,
...@@ -512,8 +513,11 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info, ...@@ -512,8 +513,11 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
break; break;
case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */ case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */
dock_id = EXTCON_DOCK; dock_id = EXTCON_DOCK;
if (!attached) if (!attached) {
extcon_set_cable_state_(info->edev, EXTCON_USB, false); extcon_set_cable_state_(info->edev, EXTCON_USB, false);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
false);
}
break; break;
default: default:
dev_err(info->dev, "failed to detect %s dock device\n", dev_err(info->dev, "failed to detect %s dock device\n",
...@@ -601,6 +605,8 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) ...@@ -601,6 +605,8 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info)
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);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break; break;
case MAX77693_MUIC_GND_MHL: case MAX77693_MUIC_GND_MHL:
case MAX77693_MUIC_GND_MHL_VB: case MAX77693_MUIC_GND_MHL_VB:
...@@ -830,6 +836,8 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) ...@@ -830,6 +836,8 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info)
*/ */
extcon_set_cable_state_(info->edev, EXTCON_USB, extcon_set_cable_state_(info->edev, EXTCON_USB,
attached); attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
if (!cable_attached) if (!cable_attached)
extcon_set_cable_state_(info->edev, EXTCON_DOCK, extcon_set_cable_state_(info->edev, EXTCON_DOCK,
...@@ -899,6 +907,8 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) ...@@ -899,6 +907,8 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info)
extcon_set_cable_state_(info->edev, EXTCON_USB, extcon_set_cable_state_(info->edev, EXTCON_USB,
attached); attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break; break;
case MAX77693_CHARGER_TYPE_DEDICATED_CHG: case MAX77693_CHARGER_TYPE_DEDICATED_CHG:
/* Only TA cable */ /* Only TA cable */
......
...@@ -122,6 +122,7 @@ enum max77843_muic_charger_type { ...@@ -122,6 +122,7 @@ enum max77843_muic_charger_type {
static const unsigned int max77843_extcon_cable[] = { static const unsigned int max77843_extcon_cable[] = {
EXTCON_USB, EXTCON_USB,
EXTCON_USB_HOST, EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP, EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_CDP, EXTCON_CHG_USB_CDP,
EXTCON_CHG_USB_FAST, EXTCON_CHG_USB_FAST,
...@@ -486,6 +487,8 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) ...@@ -486,6 +487,8 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
return ret; return ret;
extcon_set_cable_state_(info->edev, EXTCON_USB, attached); extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break; break;
case MAX77843_MUIC_CHG_DOWNSTREAM: case MAX77843_MUIC_CHG_DOWNSTREAM:
ret = max77843_muic_set_path(info, ret = max77843_muic_set_path(info,
...@@ -803,7 +806,7 @@ static int max77843_muic_probe(struct platform_device *pdev) ...@@ -803,7 +806,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
/* Clear IRQ bits before request IRQs */ /* Clear IRQ bits before request IRQs */
ret = regmap_bulk_read(max77843->regmap_muic, ret = regmap_bulk_read(max77843->regmap_muic,
MAX77843_MUIC_REG_INT1, info->status, MAX77843_MUIC_REG_INT1, info->status,
MAX77843_MUIC_IRQ_NUM); MAX77843_MUIC_STATUS_NUM);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to Clear IRQ bits\n"); dev_err(&pdev->dev, "Failed to Clear IRQ bits\n");
goto err_muic_irq; goto err_muic_irq;
......
...@@ -148,6 +148,7 @@ struct max8997_muic_info { ...@@ -148,6 +148,7 @@ struct max8997_muic_info {
static const unsigned int max8997_extcon_cable[] = { static const unsigned int max8997_extcon_cable[] = {
EXTCON_USB, EXTCON_USB,
EXTCON_USB_HOST, EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP, EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_FAST, EXTCON_CHG_USB_FAST,
EXTCON_CHG_USB_SLOW, EXTCON_CHG_USB_SLOW,
...@@ -334,6 +335,8 @@ static int max8997_muic_handle_usb(struct max8997_muic_info *info, ...@@ -334,6 +335,8 @@ static int max8997_muic_handle_usb(struct max8997_muic_info *info,
break; break;
case MAX8997_USB_DEVICE: case MAX8997_USB_DEVICE:
extcon_set_cable_state_(info->edev, EXTCON_USB, attached); extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break; break;
default: default:
dev_err(info->dev, "failed to detect %s usb cable\n", dev_err(info->dev, "failed to detect %s usb cable\n",
......
...@@ -216,11 +216,23 @@ static int palmas_usb_probe(struct platform_device *pdev) ...@@ -216,11 +216,23 @@ static int palmas_usb_probe(struct platform_device *pdev)
return PTR_ERR(palmas_usb->id_gpiod); return PTR_ERR(palmas_usb->id_gpiod);
} }
palmas_usb->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus",
GPIOD_IN);
if (IS_ERR(palmas_usb->vbus_gpiod)) {
dev_err(&pdev->dev, "failed to get vbus gpio\n");
return PTR_ERR(palmas_usb->vbus_gpiod);
}
if (palmas_usb->enable_id_detection && palmas_usb->id_gpiod) { if (palmas_usb->enable_id_detection && palmas_usb->id_gpiod) {
palmas_usb->enable_id_detection = false; palmas_usb->enable_id_detection = false;
palmas_usb->enable_gpio_id_detection = true; palmas_usb->enable_gpio_id_detection = true;
} }
if (palmas_usb->enable_vbus_detection && palmas_usb->vbus_gpiod) {
palmas_usb->enable_vbus_detection = false;
palmas_usb->enable_gpio_vbus_detection = true;
}
if (palmas_usb->enable_gpio_id_detection) { if (palmas_usb->enable_gpio_id_detection) {
u32 debounce; u32 debounce;
...@@ -266,7 +278,7 @@ static int palmas_usb_probe(struct platform_device *pdev) ...@@ -266,7 +278,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->id_irq, palmas_usb->id_irq,
NULL, palmas_id_irq_handler, NULL, palmas_id_irq_handler,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
IRQF_ONESHOT | IRQF_EARLY_RESUME, IRQF_ONESHOT,
"palmas_usb_id", palmas_usb); "palmas_usb_id", palmas_usb);
if (status < 0) { if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
...@@ -304,13 +316,47 @@ static int palmas_usb_probe(struct platform_device *pdev) ...@@ -304,13 +316,47 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->vbus_irq, NULL, palmas_usb->vbus_irq, NULL,
palmas_vbus_irq_handler, palmas_vbus_irq_handler,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
IRQF_ONESHOT | IRQF_EARLY_RESUME, IRQF_ONESHOT,
"palmas_usb_vbus", palmas_usb); "palmas_usb_vbus", palmas_usb);
if (status < 0) { if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->vbus_irq, status); palmas_usb->vbus_irq, status);
return status; return status;
} }
} else if (palmas_usb->enable_gpio_vbus_detection) {
/* remux GPIO_1 as VBUSDET */
status = palmas_update_bits(palmas,
PALMAS_PU_PD_OD_BASE,
PALMAS_PRIMARY_SECONDARY_PAD1,
PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
(1 << PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT));
if (status < 0) {
dev_err(&pdev->dev, "can't remux GPIO1\n");
return status;
}
palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
PALMAS_VBUS_OTG_IRQ);
palmas_usb->gpio_vbus_irq = gpiod_to_irq(palmas_usb->vbus_gpiod);
if (palmas_usb->gpio_vbus_irq < 0) {
dev_err(&pdev->dev, "failed to get vbus irq\n");
return palmas_usb->gpio_vbus_irq;
}
status = devm_request_threaded_irq(&pdev->dev,
palmas_usb->gpio_vbus_irq,
NULL,
palmas_vbus_irq_handler,
IRQF_TRIGGER_FALLING |
IRQF_TRIGGER_RISING |
IRQF_ONESHOT |
IRQF_EARLY_RESUME,
"palmas_usb_vbus",
palmas_usb);
if (status < 0) {
dev_err(&pdev->dev,
"failed to request handler for vbus irq\n");
return status;
}
} }
palmas_enable_irq(palmas_usb); palmas_enable_irq(palmas_usb);
...@@ -337,6 +383,8 @@ static int palmas_usb_suspend(struct device *dev) ...@@ -337,6 +383,8 @@ static int palmas_usb_suspend(struct device *dev)
if (device_may_wakeup(dev)) { if (device_may_wakeup(dev)) {
if (palmas_usb->enable_vbus_detection) if (palmas_usb->enable_vbus_detection)
enable_irq_wake(palmas_usb->vbus_irq); enable_irq_wake(palmas_usb->vbus_irq);
if (palmas_usb->enable_gpio_vbus_detection)
enable_irq_wake(palmas_usb->gpio_vbus_irq);
if (palmas_usb->enable_id_detection) if (palmas_usb->enable_id_detection)
enable_irq_wake(palmas_usb->id_irq); enable_irq_wake(palmas_usb->id_irq);
if (palmas_usb->enable_gpio_id_detection) if (palmas_usb->enable_gpio_id_detection)
...@@ -352,6 +400,8 @@ static int palmas_usb_resume(struct device *dev) ...@@ -352,6 +400,8 @@ static int palmas_usb_resume(struct device *dev)
if (device_may_wakeup(dev)) { if (device_may_wakeup(dev)) {
if (palmas_usb->enable_vbus_detection) if (palmas_usb->enable_vbus_detection)
disable_irq_wake(palmas_usb->vbus_irq); disable_irq_wake(palmas_usb->vbus_irq);
if (palmas_usb->enable_gpio_vbus_detection)
disable_irq_wake(palmas_usb->gpio_vbus_irq);
if (palmas_usb->enable_id_detection) if (palmas_usb->enable_id_detection)
disable_irq_wake(palmas_usb->id_irq); disable_irq_wake(palmas_usb->id_irq);
if (palmas_usb->enable_gpio_id_detection) if (palmas_usb->enable_gpio_id_detection)
......
...@@ -93,6 +93,7 @@ static struct reg_data rt8973a_reg_data[] = { ...@@ -93,6 +93,7 @@ static struct reg_data rt8973a_reg_data[] = {
static const unsigned int rt8973a_extcon_cable[] = { static const unsigned int rt8973a_extcon_cable[] = {
EXTCON_USB, EXTCON_USB,
EXTCON_USB_HOST, EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP, EXTCON_CHG_USB_DCP,
EXTCON_JIG, EXTCON_JIG,
EXTCON_NONE, EXTCON_NONE,
...@@ -398,6 +399,9 @@ static int rt8973a_muic_cable_handler(struct rt8973a_muic_info *info, ...@@ -398,6 +399,9 @@ static int rt8973a_muic_cable_handler(struct rt8973a_muic_info *info,
/* Change the state of external accessory */ /* Change the state of external accessory */
extcon_set_cable_state_(info->edev, id, attached); extcon_set_cable_state_(info->edev, id, attached);
if (id == EXTCON_USB)
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
return 0; return 0;
} }
...@@ -663,7 +667,7 @@ MODULE_DEVICE_TABLE(of, rt8973a_dt_match); ...@@ -663,7 +667,7 @@ MODULE_DEVICE_TABLE(of, rt8973a_dt_match);
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int rt8973a_muic_suspend(struct device *dev) static int rt8973a_muic_suspend(struct device *dev)
{ {
struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); struct i2c_client *i2c = to_i2c_client(dev);
struct rt8973a_muic_info *info = i2c_get_clientdata(i2c); struct rt8973a_muic_info *info = i2c_get_clientdata(i2c);
enable_irq_wake(info->irq); enable_irq_wake(info->irq);
...@@ -673,7 +677,7 @@ static int rt8973a_muic_suspend(struct device *dev) ...@@ -673,7 +677,7 @@ static int rt8973a_muic_suspend(struct device *dev)
static int rt8973a_muic_resume(struct device *dev) static int rt8973a_muic_resume(struct device *dev)
{ {
struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); struct i2c_client *i2c = to_i2c_client(dev);
struct rt8973a_muic_info *info = i2c_get_clientdata(i2c); struct rt8973a_muic_info *info = i2c_get_clientdata(i2c);
disable_irq_wake(info->irq); disable_irq_wake(info->irq);
......
...@@ -95,6 +95,7 @@ static struct reg_data sm5502_reg_data[] = { ...@@ -95,6 +95,7 @@ static struct reg_data sm5502_reg_data[] = {
static const unsigned int sm5502_extcon_cable[] = { static const unsigned int sm5502_extcon_cable[] = {
EXTCON_USB, EXTCON_USB,
EXTCON_USB_HOST, EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP, EXTCON_CHG_USB_DCP,
EXTCON_NONE, EXTCON_NONE,
}; };
...@@ -411,6 +412,9 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info, ...@@ -411,6 +412,9 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info,
/* Change the state of external accessory */ /* Change the state of external accessory */
extcon_set_cable_state_(info->edev, id, attached); extcon_set_cable_state_(info->edev, id, attached);
if (id == EXTCON_USB)
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
return 0; return 0;
} }
...@@ -655,7 +659,7 @@ MODULE_DEVICE_TABLE(of, sm5502_dt_match); ...@@ -655,7 +659,7 @@ MODULE_DEVICE_TABLE(of, sm5502_dt_match);
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int sm5502_muic_suspend(struct device *dev) static int sm5502_muic_suspend(struct device *dev)
{ {
struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); struct i2c_client *i2c = to_i2c_client(dev);
struct sm5502_muic_info *info = i2c_get_clientdata(i2c); struct sm5502_muic_info *info = i2c_get_clientdata(i2c);
enable_irq_wake(info->irq); enable_irq_wake(info->irq);
...@@ -665,7 +669,7 @@ static int sm5502_muic_suspend(struct device *dev) ...@@ -665,7 +669,7 @@ static int sm5502_muic_suspend(struct device *dev)
static int sm5502_muic_resume(struct device *dev) static int sm5502_muic_resume(struct device *dev)
{ {
struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); struct i2c_client *i2c = to_i2c_client(dev);
struct sm5502_muic_info *info = i2c_get_clientdata(i2c); struct sm5502_muic_info *info = i2c_get_clientdata(i2c);
disable_irq_wake(info->irq); disable_irq_wake(info->irq);
......
...@@ -580,7 +580,9 @@ struct palmas_usb { ...@@ -580,7 +580,9 @@ struct palmas_usb {
int vbus_irq; int vbus_irq;
int gpio_id_irq; int gpio_id_irq;
int gpio_vbus_irq;
struct gpio_desc *id_gpiod; struct gpio_desc *id_gpiod;
struct gpio_desc *vbus_gpiod;
unsigned long sw_debounce_jiffies; unsigned long sw_debounce_jiffies;
struct delayed_work wq_detectid; struct delayed_work wq_detectid;
...@@ -589,6 +591,7 @@ struct palmas_usb { ...@@ -589,6 +591,7 @@ struct palmas_usb {
bool enable_vbus_detection; bool enable_vbus_detection;
bool enable_id_detection; bool enable_id_detection;
bool enable_gpio_id_detection; bool enable_gpio_id_detection;
bool enable_gpio_vbus_detection;
}; };
#define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator) #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
......
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