add new gpio_vbus "transceiver"
PATCH 2/5 add new gpio_vbus "transceiver"
From: Philipp Zabel <[email protected]>
gpio_vbus provides simple GPIO VBUS sensing for peripheral controllers with an internal transceiver. Optionally, a second GPIO can be used to control D+ pullup.
It also interfaces with the regulator framework to limit charging currents when powered via USB. gpio_vbus requests the regulator supplying "vbus_draw" and can enable/disable it or limit its current depending on USB state.
[[email protected]: use drivers/otg, cleanups ]
Signed-off-by Philipp Zabel <[email protected]>
Signed-off-by David Brownell <[email protected]>
Signed-off-by Greg Kroah-Hartman <[email protected]>
--- drivers/usb/otg/Kconfig | 13 + drivers/usb/otg/Makefile | 5 drivers/usb/otg/gpio_vbus.c | 335 ++++++++++++++++++++++++++++++++++++++++ include/linux/usb/gpio_vbus.h | 30 +++ 4 files changed, 383 insertions(+)
drivers/usb/otg/Kconfig +13 -0
@@ -14,6 +14,19 @@ config USB_OTG_UTILS Select this to make sure the build includes objects from the OTG infrastructure directory. +# +# USB Transceiver Drivers +# +config USB_GPIO_VBUS + tristate "GPIO based peripheral-only VBUS sensing 'transceiver'" + depends on GENERIC_GPIO + select USB_OTG_UTILS + help + Provides simple GPIO VBUS sensing for controllers with an + internal transceiver via the otg_transceiver interface, and + optionally control of a D+ pullup GPIO as well as a VBUS + current limit regulator. + config ISP1301_OMAP tristate "Philips ISP1301 with OMAP OTG" depends on I2C && ARCH_OMAP_OTG
drivers/usb/otg/Makefile +5 -0
@@ -1,3 +1,8 @@ +# +# OTG infrastructure and transceiver drivers +# + +obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o ifeq ($(CONFIG_USB_DEBUG),y)
drivers/usb/otg/gpio_vbus.c new file +335 -0
335 lines not on this page · raw message
include/linux/usb/gpio_vbus.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* A simple GPIO VBUS sensing driver for B peripheral only devices +* with internal transceivers. +* Optionally D+ pullup can be controlled by a second GPIO. +* +* Copyright (c) 2008 Philipp Zabel <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +/** +* struct gpio_vbus_mach_info - configuration for gpio_vbus +* @gpio_vbus: VBUS sensing GPIO +* @gpio_pullup: optional D+ or D- pullup GPIO (else negative/invalid) +* @gpio_vbus_inverted: true if gpio_vbus is active low +* @gpio_pullup_inverted: true if gpio_pullup is active low +* +* The VBUS sensing GPIO should have a pulldown, which will normally be +* part of a resistor ladder turning a 4.0V-5.25V level on VBUS into a +* value the GPIO detects as active. Some systems will use comparators. +*/ +struct gpio_vbus_mach_info { +int gpio_vbus; +int gpio_pullup; +bool gpio_vbus_inverted; +bool gpio_pullup_inverted; +};