Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756510AbbEVKuo (ORCPT ); Fri, 22 May 2015 06:50:44 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:31006 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755652AbbEVKt7 (ORCPT ); Fri, 22 May 2015 06:49:59 -0400 X-AuditID: cbfee68f-f793b6d000005f66-16-555f09d59c7e From: Chanwoo Choi To: linux-kernel@vger.kernel.org Cc: rogerq@ti.com, r.baldyga@samsung.com, peter.chen@freescale.com, kishon@ti.com, balbi@ti.com, iivanov@mm-sol.com, cw00.choi@samsung.com, myungjoo.ham@samsung.com Subject: [PATCH 0/2] extcon: Inform the state of both ID and VBUS pin for USB Date: Fri, 22 May 2015 19:49:48 +0900 Message-id: <1432291790-4933-1-git-send-email-cw00.choi@samsung.com> X-Mailer: git-send-email 1.8.5.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsWyRsSkSPcqZ3yowcudNhYH79dbXP/ynNXi 2cSHjBYXnvawWVzeNYfN4nbjCjaLY7P/Mlk8OLyT3aLnkZYDp8e/w/1MHpv2T2P26NuyitHj +I3tTB6fN8kFsEZx2aSk5mSWpRbp2yVwZZxuPMFecEGkYsedB0wNjGcEuhg5OSQETCQW7/3C CGGLSVy4t56ti5GLQ0hgKaPE8w0zWWCKHp78xwiRWMQocfnlQmaQhJDAF0aJGUe1QGw2AS2J /S9usIHYIgIKEpt7n7GCNDALrGCU2HX1AFADB4ewgK/EglkOIDUsAqoSj489YQWxeQVcJBbs OcsMsUxBYtnymWC9EgKT2SVOTp/HCNEgIPFt8iEWkDkSArISmw5A1UtKHFxxg2UCo+ACRoZV jKKpBckFxUnpRcZ6xYm5xaV56XrJ+bmbGIFhfPrfs/4djHcPWB9iFOBgVOLh7TgcFyrEmlhW XJl7iNEUaMNEZinR5HxgtOSVxBsamxlZmJqYGhuZW5opifMulPo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9/7lFi9VfIS3/tqBUY+s6pwjW00rvW9xqdymxFGckGmoxFxUnAgD5d6TkqAIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2801 Lines: 89 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/