--- /dev/null
+EXTCON FOR GPIO-STATES
+
+Required Properties:
+ - compatible : Should be "extcon-gpio-states";
+
+Optional Properties:
+ - extcon-gpio,name: Name of extcon device.
+ - gpios: List of teh gpios.
+ - extcon-gpio,irq-flags: IRQ flags for GPIO.
+ - extcon-gpio,debounce: Debounce time in ms.
+ - extcon-gpio,wait-for-gpio-scan: Wait timeout for scanning all gpio states
+ after chnage found in gpio and debounce timeof gpio is completed.
+ - extcon-gpio,out-cable-names: Output cable names.
+ - extcon-gpio,cable-states: GPIO states and ther corresponding output cable
+ state. This is array of the data for table as
+ gpio-state <-> output cable-state
+extcon-gpio {
+ compatible = "extcon-gpio-states";
+ gpio = <&gpio 20 0 &gpio 30 0>;
+ extcon-gpio,cable-states = <0x00 0x00
+ 0x01 0x01
+ 0x02 0x02
+ 0x03 0x4>;
+ extcon-gpio,out-cable-names = "vbus", "host", "otg-y-cable";
+};
struct gpio_extcon_platform_data {
const char *name;
unsigned long debounce;
+ unsigned long wait_for_gpio_scan;
unsigned long irq_flags;
struct gpio_info *gpios;
int n_gpio;
struct delayed_work work;
unsigned long debounce_jiffies;
struct timer_list timer;
- int timer_to_work_jiffies;
+ int gpio_scan_work_jiffies;
spinlock_t lock;
int *gpio_curr_state;
struct gpio_extcon_platform_data *pdata;
int cable_detect_jiffies;
};
-static void gpio_extcon_work(struct work_struct *work)
+static void gpio_extcon_scan_work(struct work_struct *work)
{
int state = 0;
int cstate = -1;
if (!wake_lock_active(&gpex->wake_lock))
wake_lock_timeout(&gpex->wake_lock, gpex->cable_detect_jiffies);
- schedule_delayed_work(&gpex->work, gpex->timer_to_work_jiffies);
+ schedule_delayed_work(&gpex->work, gpex->gpio_scan_work_jiffies);
}
static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
else
pdata->cable_detect_delay = EXTCON_GPIO_STATE_WAKEUP_TIME;
+ ret = of_property_read_u32(np, "extcon-gpio,wait-for-gpio-scan", &pval);
+ if (!ret)
+ pdata->wait_for_gpio_scan = pval;
+ else
+ pdata->wait_for_gpio_scan = 100;
+
+
pdata->n_out_cables = of_property_count_strings(np,
"extcon-gpio,out-cable-names");
if (pdata->n_out_cables <= 0) {
gpex->edev.name = pdata->name;
gpex->edev.dev.parent = &pdev->dev;
gpex->debounce_jiffies = msecs_to_jiffies(pdata->debounce);
- gpex->timer_to_work_jiffies = msecs_to_jiffies(100);
+ gpex->gpio_scan_work_jiffies = msecs_to_jiffies(
+ pdata->wait_for_gpio_scan);
gpex->edev.supported_cable = pdata->out_cable_name;
gpex->cable_detect_jiffies =
msecs_to_jiffies(pdata->cable_detect_delay);
if (ret < 0)
return ret;
- INIT_DELAYED_WORK(&gpex->work, gpio_extcon_work);
+ INIT_DELAYED_WORK(&gpex->work, gpio_extcon_scan_work);
setup_timer(&gpex->timer, gpio_extcon_notifier_timer,
(unsigned long)gpex);
device_wakeup_enable(gpex->dev);
/* Perform initial detection */
- gpio_extcon_work(&gpex->work.work);
+ gpio_extcon_scan_work(&gpex->work.work);
return 0;
err:
for (i = 0; i < gpex->pdata->n_gpio; ++i)
disable_irq_wake(gpex->pdata->gpios[i].irq);
}
- gpio_extcon_work(&gpex->work.work);
+ gpio_extcon_scan_work(&gpex->work.work);
return 0;
}