Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 355093
b: refs/heads/master
c: af5eb1a
h: refs/heads/master
i:
  355091: c75c9c1
v: v3
  • Loading branch information
Chanwoo Choi committed Feb 13, 2013
1 parent cd5f1fd commit a16217a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 685dc9a7dbfede28cc4a0fe4e65804194ec04fa5
refs/heads/master: af5eb1a13273447c5708cd5425696f3b6f79dd9b
45 changes: 36 additions & 9 deletions trunk/drivers/extcon/extcon-max8997.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <linux/irqdomain.h>

#define DEV_NAME "max8997-muic"
#define DELAY_MS_DEFAULT 20000 /* unit: millisecond */

enum max8997_muic_adc_debounce_time {
ADC_DEBOUNCE_TIME_0_5MS = 0, /* 0.5ms */
Expand Down Expand Up @@ -128,6 +129,14 @@ struct max8997_muic_info {
struct max8997_muic_platform_data *muic_pdata;
enum max8997_muic_charger_type pre_charger_type;

/*
* Use delayed workqueue to detect cable state and then
* notify cable state to notifiee/platform through uevent.
* After completing the booting of platform, the extcon provider
* driver should notify cable state to upper layer.
*/
struct delayed_work wq_detcable;

/*
* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
* h/w path of COMP2/COMN1 on CONTROL1 register.
Expand Down Expand Up @@ -629,11 +638,23 @@ static int max8997_muic_detect_dev(struct max8997_muic_info *info)
return 0;
}

static void max8997_muic_detect_cable_wq(struct work_struct *work)
{
struct max8997_muic_info *info = container_of(to_delayed_work(work),
struct max8997_muic_info, wq_detcable);
int ret;

ret = max8997_muic_detect_dev(info);
if (ret < 0)
pr_err("failed to detect cable type\n");
}

static int max8997_muic_probe(struct platform_device *pdev)
{
struct max8997_dev *max8997 = dev_get_drvdata(pdev->dev.parent);
struct max8997_platform_data *pdata = dev_get_platdata(max8997->dev);
struct max8997_muic_info *info;
int delay_jiffies;
int ret, i;

info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info),
Expand Down Expand Up @@ -721,17 +742,23 @@ static int max8997_muic_probe(struct platform_device *pdev)
/* Set ADC debounce time */
max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);

/* Initial device detection */
ret = max8997_muic_detect_dev(info);
if (ret < 0) {
dev_err(&pdev->dev, "failed to detect cable type\n");
goto err_extcon;
}
/*
* Detect accessory after completing the initialization of platform
*
* - Use delayed workqueue to detect cable state and then
* notify cable state to notifiee/platform through uevent.
* After completing the booting of platform, the extcon provider
* driver should notify cable state to upper layer.
*/
INIT_DELAYED_WORK(&info->wq_detcable, max8997_muic_detect_cable_wq);
if (pdata->muic_pdata->detcable_delay_ms)
delay_jiffies = msecs_to_jiffies(pdata->muic_pdata->detcable_delay_ms);
else
delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
schedule_delayed_work(&info->wq_detcable, delay_jiffies);

return ret;
return 0;

err_extcon:
extcon_dev_unregister(info->edev);
err_irq:
while (--i >= 0)
free_irq(muic_irqs[i].virq, info);
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/mfd/max8997.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ struct max8997_muic_platform_data {
struct max8997_muic_reg_data *init_data;
int num_init_data;

/* Check cable state after certain delay */
int detcable_delay_ms;

/*
* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
* h/w path of COMP2/COMN1 on CONTROL1 register.
Expand Down

0 comments on commit a16217a

Please sign in to comment.