- 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
+- cable-connected-on-boot: Cable connected on boot. It should be cable index
+ in the output cable names. The number start from 0. Absence of this
+ property will be assume as there is no cable connected. This property
+ will be valid if there is no gpios provided for cable states.
+
+
+This driver also supports the extcon interface for different cable without
+gpios. On this case, if property cable-connected-on-boot provided then
+it will be consider this as the default cable otherwise it will assume
+that there is no cable connected. Later on, through extcon sysfs, the
+state can be chnaged.
+
extcon-gpio {
compatible = "extcon-gpio-states";
gpio = <&gpio 20 0 &gpio 30 0>;
struct gpio_extcon_cables *cable_states;
int n_cable_states;
int cable_detect_delay;
+ int init_state;
};
struct gpio_extcon_info {
if (!pdata)
return ERR_PTR(-ENOMEM);
- of_property_read_string(np, "extcon-gpio,name", &pdata->name);
+ of_property_read_string(np, "label", &pdata->name);
+ if (!pdata->name)
+ of_property_read_string(np, "extcon-gpio,name", &pdata->name);
if (!pdata->name)
pdata->name = np->name;
n_gpio = of_gpio_named_count(np, "gpios");
if (n_gpio < 1) {
- dev_err(&pdev->dev, "Not sufficient gpios\n");
- return ERR_PTR(-EINVAL);
+ ret = of_property_read_u32(np, "cable-connected-on-boot", &pval);
+ pdata->init_state = (!ret) ? pval : -1;
+ goto parse_cable_names;
}
pdata->n_gpio = n_gpio;
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) {
- dev_err(&pdev->dev, "not found out cable names\n");
- return ERR_PTR(-EINVAL);
- }
-
- pdata->out_cable_name = devm_kzalloc(&pdev->dev,
- (pdata->n_out_cables + 1) *
- sizeof(*pdata->out_cable_name), GFP_KERNEL);
- if (!pdata->out_cable_name)
- return ERR_PTR(-ENOMEM);
- count = 0;
- of_property_for_each_string(np, "extcon-gpio,out-cable-names",
- prop, names)
- pdata->out_cable_name[count++] = names;
- pdata->out_cable_name[count] = NULL;
pdata->n_cable_states = of_property_count_u32(np,
"extcon-gpio,cable-states");
pdata->cable_states[count].cstate = pval;
}
+parse_cable_names:
+ pdata->n_out_cables = of_property_count_strings(np,
+ "extcon-gpio,out-cable-names");
+ if (pdata->n_out_cables <= 0) {
+ dev_err(&pdev->dev, "not found out cable names\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ pdata->out_cable_name = devm_kzalloc(&pdev->dev,
+ (pdata->n_out_cables + 1) *
+ sizeof(*pdata->out_cable_name), GFP_KERNEL);
+ if (!pdata->out_cable_name)
+ return ERR_PTR(-ENOMEM);
+ count = 0;
+ of_property_for_each_string(np, "extcon-gpio,out-cable-names",
+ prop, names)
+ pdata->out_cable_name[count++] = names;
+ pdata->out_cable_name[count] = NULL;
+
return pdata;
}
if (!pdata)
return -EINVAL;
- if (!pdata->irq_flags) {
+ if (!pdata->irq_flags && pdata->n_gpio) {
dev_err(&pdev->dev, "IRQ flag is not specified.\n");
return -EINVAL;
}
device_wakeup_enable(gpex->dev);
/* Perform initial detection */
- gpio_extcon_scan_work(&gpex->work.work);
+ if (gpex->pdata->n_gpio) {
+ gpio_extcon_scan_work(&gpex->work.work);
+ } else {
+ if (pdata->init_state < 0) {
+ dev_info(gpex->dev, "No Cable connected on boot\n");
+ extcon_set_state(&gpex->edev, 0);
+ } else {
+ dev_info(gpex->dev, "Cable %s connected on boot\n",
+ pdata->out_cable_name[pdata->init_state]);
+ extcon_set_state(&gpex->edev, BIT(pdata->init_state));
+ }
+ }
+
return 0;
err: