All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] extcon: Inform the state of both ID and VBUS pin for USB
@ 2015-05-22 10:49 Chanwoo Choi
  2015-05-22 10:49 ` [PATCH 1/2] extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors Chanwoo Choi
  2015-05-22 10:49 ` [PATCH 2/2] extcon: usb-gpio: Update the ID pin state of USB when cable state is changed Chanwoo Choi
  0 siblings, 2 replies; 4+ messages in thread
From: Chanwoo Choi @ 2015-05-22 10:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: rogerq, r.baldyga, peter.chen, kishon, balbi, iivanov, cw00.choi,
	myungjoo.ham

Previously, I discussed how to inform the changed state of both ID
and VBUS pin for USB connector on patch-set[1].
[1] https://lkml.org/lkml/2015/4/2/310

So, this patch adds the extcon_set_cable_line_state() function to inform
the additional state of external connectors without additional register/
unregister functions. This function uses the existing notifier chain
which is registered by extcon_register_notifier() / extcon_register_interest().

The extcon_set_cable_line_state() can inform the new state of both
ID and VBUS pin state through extcon_set_cable_line_state().

For exmaple:
- On extcon-usb-gpio.c as extcon provider driver as following:
	static void usb_extcon_detect_cable(struct work_struct *work)
	{
		...
		/* check ID and update cable state */
		id = gpiod_get_value_cansleep(info->id_gpiod);
		if (id) {
			extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, false);
			extcon_set_cable_state_(info->edev, EXTCON_USB, true);

			extcon_set_cable_line_state(info->edev, EXTCON_USB,
							EXTCON_USB_ID_HIGH);
		} else {
			extcon_set_cable_state_(info->edev, EXTCON_USB, false);
			extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, true);

			extcon_set_cable_line_state(info->edev, EXTCON_USB,
							EXTCON_USB_ID_LOW);
		}
	}

- On specific extcon consumder driver as following:
	static int xxx_probe(struct platform_device *pdev)
	{
		struct notifier_chain nh;

		nb.notifier_call = extcon_usb_notifier;
		ret = extcon_register_notifier(edev, EXTCON_USB, &nb);
		...
	}

	static int extcon_usb_notifier(struct notifier_block *self,
		unsigned long event, void *ptr)
	{
		switch (event) {
		case EXTCON_DETACHED:
			printk("USB is detached\n");
			break;
		case EXTCON_ATTACHED:
			printk("USB is attached\n");
			break;

		case EXTCON_USB_ID_LOW:
			printk("USB's ID pin is low state\n");
			break;
		case EXTCON_USB_ID_HIGH:
			printk("USB's ID pin is high state\n");
			break;
		case EXTCON_USB_VBUS_LOW:
			printk("USB's VBUS pin is high state\n");
			break;
		case EXTCON_USB_VBUS_HIGH:
			printk("USB's VBUS pin is high state\n");
			break;
		default:
			return -EINVAL;
		};
	}

Chanwoo Choi (2):
  extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors
  extcon: usb-gpio: Update the ID pin state of USB when cable state is changed

 drivers/extcon/extcon-usb-gpio.c |  6 ++++
 drivers/extcon/extcon.c          | 74 +++++++++++++++++++++++++++++++++++++++-
 include/linux/extcon.h           | 24 +++++++++++++
 3 files changed, 103 insertions(+), 1 deletion(-)

-- 
1.8.5.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-25  2:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-22 10:49 [PATCH 0/2] extcon: Inform the state of both ID and VBUS pin for USB Chanwoo Choi
2015-05-22 10:49 ` [PATCH 1/2] extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors Chanwoo Choi
2015-05-25  2:12   ` Peter Chen
2015-05-22 10:49 ` [PATCH 2/2] extcon: usb-gpio: Update the ID pin state of USB when cable state is changed Chanwoo Choi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.