Re: [PATCH v4] extcon: gpio: Add the support for Device tree bindings

From: Chanwoo Choi
Date: Tue May 31 2016 - 03:35:13 EST


Hi Rob,

On 2016ë 05ì 31ì 15:44, Chanwoo Choi wrote:
> On 2016ë 05ì 28ì 00:29, Rob Herring wrote:
>> On Thu, May 26, 2016 at 05:17:45PM +0530, Venkat Reddy Talla wrote:
>>> Add the support for Device tree bindings of extcon-gpio driver.
>>> The extcon-gpio device tree node must include the both 'extcon-id' and
>>> 'gpios' property.
>>
>> I think extcon bindings are a mess in general...
>>
>>> For example:
>>> usb_cable: extcon-gpio-0 {
>>> compatible = "extcon-gpio";
>>> extcon-id = <EXTCON_USB>;
>>> gpios = <&gpio6 1 GPIO_ACTIVE_HIGH>;
>>> }
>>> ta_cable: extcon-gpio-1 {
>>> compatible = "extcon-gpio";
>>> extcon-id = <EXTCON_CHG_USB_DCP>;
>>> gpios = <&gpio3 2 GPIO_ACTIVE_LOW>;
>>> debounce-ms = <50>; /* 50 millisecond */
>>> wakeup-source;
>>> }
>>
>> This is all 1 logical connector, the USB connector. Why are you
>> describing cables? Those are not part of the h/w and are dynamic.
>> Describe this as a connector which is one thing (i.e. node). Use a
>> compatible string that reflects the type of connector
>> (usb-microab-connector), not the driver you want to use. Then define
>> GPIO lines needed to provide state information like VBus, ID, charger
>> modes and control lines like soft connect (D+ pullup enable), VBus
>> enable, etc.
>
> You're right. The extcon-gpio driver will not use the "extcon-gpio" raw compatible.
> As you commented[1], the each connector will have the unique name to use the extcon-gpio.c driver.
> [1] https://lkml.org/lkml/2015/10/21/906
>
>
> For example,
> The extcon-gpio.c driver may have the different name including the h/w information
> according to the kind of external connector.
>
> static const struct of_device_id gpio_extcon_of_match[] = {
> {
> .compatible = "extcon-chg-sdp", /* SDP charger connector */
> .data = EXTCON_CHG_SDP_DATA,
> }, {
> .compatible = "extcon-chg-dcp", /* DCP charger connector */
> .data = EXTCON_CHG_DCP_DATA,
> }, {
> .compatible = "extcon-jack-microphone", /* Microphone jack connector */
> .data = EXTCON_JACK_MICROPHONE_DATA,
> }, {
> .compatible = "extcon-disp-hdmi", /* HDMI connector*/
> .data = EXTCON_DISP_HDMI_DATA,
> },
> ......
> };

I reply it again.

The extcon-gpio.c is very similar with existing gpio_keys.c driver[1]
[1] drivers/input/keyboard/gpio_keys.c

The gpio_keys.c driver use the following style to support the device-tree.
It use the "gpio-keys" compatible and this dt node include the specific
'key code' such as 'extcon-id = <EXTCON_CHG_USB_DCP>;'

gpio_keys {
compatible = "gpio-keys";

power_key {
gpios = <&gpx2 7 GPIO_ACTIVE_LOW>;
linux,code = <KEY_POWER>;
label = "power key";
debounce-interval = <10>;
wakeup-source;
};
};

If the extcon-gpio.c driver should have the separate compatible according to
the kind of external connector, the list of compatible name of extcon-gpio.c driver
will be increased when new external connector is attached.

The extcon-gpio.c driver can separate the kind of external connector
by using the 'extcon-id' property.

Thanks,
Chanwoo Choi