Skip to content

Commit

Permalink
Merge tag 'extcon-next-for-4.6' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
Greg Kroah-Hartman committed Mar 2, 2016
2 parents 523462d + ae64e42 commit 449a97d
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 13 deletions.
3 changes: 1 addition & 2 deletions arch/arm/boot/dts/am57xx-beagle-x15.dts
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,7 @@
extcon_usb2: tps659038_usb {
compatible = "ti,palmas-usb-vid";
ti,enable-vbus-detection;
ti,enable-id-detection;
id-gpios = <&gpio7 24 GPIO_ACTIVE_HIGH>;
vbus-gpio = <&gpio4 21 GPIO_ACTIVE_HIGH>;
};

};
Expand Down
4 changes: 2 additions & 2 deletions drivers/extcon/extcon-arizona.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
break;
};

mutex_lock(&arizona->dapm->card->dapm_mutex);
snd_soc_dapm_mutex_lock(arizona->dapm);

arizona->hpdet_clamp = clamp;

Expand Down Expand Up @@ -227,7 +227,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/extcon/extcon-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int gpio_extcon_probe(struct platform_device *pdev)
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.
*/
ret = devm_request_any_context_irq(&pdev->dev, data->irq,
Expand Down
3 changes: 3 additions & 0 deletions drivers/extcon/extcon-max14577.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ enum max14577_muic_acc_type {

static const unsigned int max14577_extcon_cable[] = {
EXTCON_USB,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_FAST,
EXTCON_CHG_USB_SLOW,
Expand Down Expand Up @@ -454,6 +455,8 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info)
return ret;

extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break;
case MAX14577_CHARGER_TYPE_DEDICATED_CHG:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_DCP,
Expand Down
12 changes: 11 additions & 1 deletion drivers/extcon/extcon-max77693.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ enum max77693_muic_acc_type {
static const unsigned int max77693_extcon_cable[] = {
EXTCON_USB,
EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_FAST,
EXTCON_CHG_USB_SLOW,
Expand Down Expand Up @@ -512,8 +513,11 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
break;
case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */
dock_id = EXTCON_DOCK;
if (!attached)
if (!attached) {
extcon_set_cable_state_(info->edev, EXTCON_USB, false);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
false);
}
break;
default:
dev_err(info->dev, "failed to detect %s dock device\n",
Expand Down Expand Up @@ -601,6 +605,8 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info)
if (ret < 0)
return ret;
extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break;
case MAX77693_MUIC_GND_MHL:
case MAX77693_MUIC_GND_MHL_VB:
Expand Down Expand Up @@ -830,6 +836,8 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info)
*/
extcon_set_cable_state_(info->edev, EXTCON_USB,
attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);

if (!cable_attached)
extcon_set_cable_state_(info->edev, EXTCON_DOCK,
Expand Down Expand Up @@ -899,6 +907,8 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info)

extcon_set_cable_state_(info->edev, EXTCON_USB,
attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break;
case MAX77693_CHARGER_TYPE_DEDICATED_CHG:
/* Only TA cable */
Expand Down
5 changes: 4 additions & 1 deletion drivers/extcon/extcon-max77843.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ enum max77843_muic_charger_type {
static const unsigned int max77843_extcon_cable[] = {
EXTCON_USB,
EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_CDP,
EXTCON_CHG_USB_FAST,
Expand Down Expand Up @@ -486,6 +487,8 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
return ret;

extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break;
case MAX77843_MUIC_CHG_DOWNSTREAM:
ret = max77843_muic_set_path(info,
Expand Down Expand Up @@ -803,7 +806,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
/* Clear IRQ bits before request IRQs */
ret = regmap_bulk_read(max77843->regmap_muic,
MAX77843_MUIC_REG_INT1, info->status,
MAX77843_MUIC_IRQ_NUM);
MAX77843_MUIC_STATUS_NUM);
if (ret) {
dev_err(&pdev->dev, "Failed to Clear IRQ bits\n");
goto err_muic_irq;
Expand Down
3 changes: 3 additions & 0 deletions drivers/extcon/extcon-max8997.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ struct max8997_muic_info {
static const unsigned int max8997_extcon_cable[] = {
EXTCON_USB,
EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_FAST,
EXTCON_CHG_USB_SLOW,
Expand Down Expand Up @@ -334,6 +335,8 @@ static int max8997_muic_handle_usb(struct max8997_muic_info *info,
break;
case MAX8997_USB_DEVICE:
extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
attached);
break;
default:
dev_err(info->dev, "failed to detect %s usb cable\n",
Expand Down
54 changes: 52 additions & 2 deletions drivers/extcon/extcon-palmas.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,23 @@ static int palmas_usb_probe(struct platform_device *pdev)
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) {
palmas_usb->enable_id_detection = false;
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) {
u32 debounce;

Expand Down Expand Up @@ -266,7 +278,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->id_irq,
NULL, palmas_id_irq_handler,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
IRQF_ONESHOT | IRQF_EARLY_RESUME,
IRQF_ONESHOT,
"palmas_usb_id", palmas_usb);
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
Expand Down Expand Up @@ -304,13 +316,47 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->vbus_irq, NULL,
palmas_vbus_irq_handler,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
IRQF_ONESHOT | IRQF_EARLY_RESUME,
IRQF_ONESHOT,
"palmas_usb_vbus", palmas_usb);
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->vbus_irq, 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);
Expand All @@ -337,6 +383,8 @@ static int palmas_usb_suspend(struct device *dev)
if (device_may_wakeup(dev)) {
if (palmas_usb->enable_vbus_detection)
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)
enable_irq_wake(palmas_usb->id_irq);
if (palmas_usb->enable_gpio_id_detection)
Expand All @@ -352,6 +400,8 @@ static int palmas_usb_resume(struct device *dev)
if (device_may_wakeup(dev)) {
if (palmas_usb->enable_vbus_detection)
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)
disable_irq_wake(palmas_usb->id_irq);
if (palmas_usb->enable_gpio_id_detection)
Expand Down
8 changes: 6 additions & 2 deletions drivers/extcon/extcon-rt8973a.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static struct reg_data rt8973a_reg_data[] = {
static const unsigned int rt8973a_extcon_cable[] = {
EXTCON_USB,
EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP,
EXTCON_JIG,
EXTCON_NONE,
Expand Down Expand Up @@ -398,6 +399,9 @@ static int rt8973a_muic_cable_handler(struct rt8973a_muic_info *info,

/* Change the state of external accessory */
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;
}
Expand Down Expand Up @@ -663,7 +667,7 @@ MODULE_DEVICE_TABLE(of, rt8973a_dt_match);
#ifdef CONFIG_PM_SLEEP
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);

enable_irq_wake(info->irq);
Expand All @@ -673,7 +677,7 @@ static int rt8973a_muic_suspend(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);

disable_irq_wake(info->irq);
Expand Down
8 changes: 6 additions & 2 deletions drivers/extcon/extcon-sm5502.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static struct reg_data sm5502_reg_data[] = {
static const unsigned int sm5502_extcon_cable[] = {
EXTCON_USB,
EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_DCP,
EXTCON_NONE,
};
Expand Down Expand Up @@ -411,6 +412,9 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info,

/* Change the state of external accessory */
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;
}
Expand Down Expand Up @@ -655,7 +659,7 @@ MODULE_DEVICE_TABLE(of, sm5502_dt_match);
#ifdef CONFIG_PM_SLEEP
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);

enable_irq_wake(info->irq);
Expand All @@ -665,7 +669,7 @@ static int sm5502_muic_suspend(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);

disable_irq_wake(info->irq);
Expand Down
3 changes: 3 additions & 0 deletions include/linux/mfd/palmas.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,9 @@ struct palmas_usb {
int vbus_irq;

int gpio_id_irq;
int gpio_vbus_irq;
struct gpio_desc *id_gpiod;
struct gpio_desc *vbus_gpiod;
unsigned long sw_debounce_jiffies;
struct delayed_work wq_detectid;

Expand All @@ -589,6 +591,7 @@ struct palmas_usb {
bool enable_vbus_detection;
bool enable_id_detection;
bool enable_gpio_id_detection;
bool enable_gpio_vbus_detection;
};

#define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
Expand Down

0 comments on commit 449a97d

Please sign in to comment.