Re: [PATCH 1/8] usb: add bus type for USB ULPI
On Thu, Feb 12, 2015 at 05:44:20PM -0800, Stephen Boyd wrote: > On 01/23/15 07:12, Heikki Krogerus wrote: > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > > index e614ef6..753cb08 100644 > > --- a/scripts/mod/file2alias.c > > +++ b/scripts/mod/file2alias.c > > @@ -1176,6 +1176,19 @@ static int do_rio_entry(const char *filename, > > } > > ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); > > > > +/* Looks like: mei:S */ > > This comment doesn't look right. Oops. Thanks for catching that one. > > +static int do_ulpi_entry(const char *filename, void *symval, > > +char *alias) > > +{ > > + DEF_FIELD(symval, ulpi_device_id, vendor); > > + DEF_FIELD(symval, ulpi_device_id, product); > > + > > + sprintf(alias, "ulpi:v%04xp%04x", vendor, product); > > + > > + return 1; > > +} > > +ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry); -- heikki -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/8] usb: add bus type for USB ULPI
On 01/23/15 07:12, Heikki Krogerus wrote: > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > index e614ef6..753cb08 100644 > --- a/scripts/mod/file2alias.c > +++ b/scripts/mod/file2alias.c > @@ -1176,6 +1176,19 @@ static int do_rio_entry(const char *filename, > } > ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); > > +/* Looks like: mei:S */ This comment doesn't look right. > +static int do_ulpi_entry(const char *filename, void *symval, > + char *alias) > +{ > + DEF_FIELD(symval, ulpi_device_id, vendor); > + DEF_FIELD(symval, ulpi_device_id, product); > + > + sprintf(alias, "ulpi:v%04xp%04x", vendor, product); > + > + return 1; > +} > +ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry); > + -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/8] usb: add bus type for USB ULPI
On Wed, Jan 28, 2015 at 11:02:37PM -0600, Felipe Balbi wrote: > Hi, > > On Fri, Jan 23, 2015 at 05:12:51PM +0200, Heikki Krogerus wrote: > > @@ -6,4 +6,5 @@ obj-$(CONFIG_USB_COMMON) += usb-common.o > > usb-common-y += common.o > > usb-common-$(CONFIG_USB_LED_TRIG) += led.o > > > > -obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o > > +obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o > > a bit of unrelated change here. OK > > diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig > > index cc0ced0..c0fc3b5 100644 > > --- a/drivers/usb/core/Kconfig > > +++ b/drivers/usb/core/Kconfig > > @@ -84,3 +84,11 @@ config USB_OTG_FSM > > Implements OTG Finite State Machine as specified in On-The-Go > > and Embedded Host Supplement to the USB Revision 2.0 Specification. > > > > +config USB_ULPI_BUS > > + bool "USB ULPI PHY interface support" > > + depends on USB || USB_GADGET > > depends on USB_SUPPORT ? sure > > +int ulpi_register_driver(struct ulpi_driver *drv); > > +void ulpi_unregister_driver(struct ulpi_driver *drv); > > + > > +#define module_ulpi_driver(__ulpi_driver) \ > > + module_driver(__ulpi_driver, ulpi_register_driver, \ > > + ulpi_unregister_driver) > > + > > +int ulpi_read(struct ulpi *ulpi, u8 addr); > > +int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val); > > no stubs ? Is there really need for them? Well, I'll add them. Thanks, -- heikki -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/8] usb: add bus type for USB ULPI
Hi, On Fri, Jan 23, 2015 at 05:12:51PM +0200, Heikki Krogerus wrote: > @@ -6,4 +6,5 @@ obj-$(CONFIG_USB_COMMON)+= usb-common.o > usb-common-y += common.o > usb-common-$(CONFIG_USB_LED_TRIG) += led.o > > -obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o > +obj-$(CONFIG_USB_OTG_FSM)+= usb-otg-fsm.o a bit of unrelated change here. > diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig > index cc0ced0..c0fc3b5 100644 > --- a/drivers/usb/core/Kconfig > +++ b/drivers/usb/core/Kconfig > @@ -84,3 +84,11 @@ config USB_OTG_FSM > Implements OTG Finite State Machine as specified in On-The-Go > and Embedded Host Supplement to the USB Revision 2.0 Specification. > > +config USB_ULPI_BUS > + bool "USB ULPI PHY interface support" > + depends on USB || USB_GADGET depends on USB_SUPPORT ? > +int ulpi_register_driver(struct ulpi_driver *drv); > +void ulpi_unregister_driver(struct ulpi_driver *drv); > + > +#define module_ulpi_driver(__ulpi_driver) \ > + module_driver(__ulpi_driver, ulpi_register_driver, \ > + ulpi_unregister_driver) > + > +int ulpi_read(struct ulpi *ulpi, u8 addr); > +int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val); no stubs ? -- balbi signature.asc Description: Digital signature
[PATCH 1/8] usb: add bus type for USB ULPI
UTMI+ Low Pin Interface (ULPI) is a commonly used PHY interface for USB 2.0. The ULPI specification describes a standard set of registers which the vendors can extend for their specific needs. ULPI PHYs provide often functions such as charger detection and ADP sensing and probing. There are two major issues that the bus type is meant to tackle: Firstly, ULPI registers are accessed from the controller. The bus provides convenient method for the controller drivers to share that access with the actual PHY drivers. Secondly, there are already platforms that assume ULPI PHYs are runtime detected, such as many Intel Baytrail based platforms. They do not provide any kind of hardware description for the ULPI PHYs like separate ACPI device object that could be used to enumerate a device from. Signed-off-by: Heikki Krogerus --- MAINTAINERS | 7 ++ drivers/usb/common/Makefile | 3 +- drivers/usb/common/ulpi.c | 253 ++ drivers/usb/core/Kconfig | 8 ++ include/linux/mod_devicetable.h | 6 + include/linux/ulpi/driver.h | 62 ++ include/linux/ulpi/interface.h| 23 include/linux/ulpi/regs.h | 130 include/linux/usb/ulpi.h | 134 +--- scripts/mod/devicetable-offsets.c | 4 + scripts/mod/file2alias.c | 13 ++ 11 files changed, 510 insertions(+), 133 deletions(-) create mode 100644 drivers/usb/common/ulpi.c create mode 100644 include/linux/ulpi/driver.h create mode 100644 include/linux/ulpi/interface.h create mode 100644 include/linux/ulpi/regs.h diff --git a/MAINTAINERS b/MAINTAINERS index 761a4a1..7d0c58c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10234,6 +10234,13 @@ S: Maintained F: Documentation/video4linux/zr364xx.txt F: drivers/media/usb/zr364xx/ +ULPI BUS +M: Heikki Krogerus +L: linux-usb@vger.kernel.org +S: Maintained +F: drivers/usb/common/ulpi.c +F: include/linux/ulpi/ + USER-MODE LINUX (UML) M: Jeff Dike M: Richard Weinberger diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile index ca2f8bd..5791d6c 100644 --- a/drivers/usb/common/Makefile +++ b/drivers/usb/common/Makefile @@ -6,4 +6,5 @@ obj-$(CONFIG_USB_COMMON) += usb-common.o usb-common-y += common.o usb-common-$(CONFIG_USB_LED_TRIG) += led.o -obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o +obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o +obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c new file mode 100644 index 000..3ed66be --- /dev/null +++ b/drivers/usb/common/ulpi.c @@ -0,0 +1,253 @@ +/** + * ulpi.c - USB ULPI PHY bus + * + * Copyright (C) 2015 Intel Corporation + * + * Author: Heikki Krogerus + * + * 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. + */ + +#include +#include +#include +#include +#include + +/* -- */ + +int ulpi_read(struct ulpi *ulpi, u8 addr) +{ + return ulpi->ops->read(ulpi->ops, addr); +} +EXPORT_SYMBOL_GPL(ulpi_read); + +int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val) +{ + return ulpi->ops->write(ulpi->ops, addr, val); +} +EXPORT_SYMBOL_GPL(ulpi_write); + +/* -- */ + +static int ulpi_match(struct device *dev, struct device_driver *driver) +{ + struct ulpi_driver *drv = to_ulpi_driver(driver); + struct ulpi *ulpi = to_ulpi_dev(dev); + const struct ulpi_device_id *id; + + for (id = drv->id_table; id->vendor; id++) + if (id->vendor == ulpi->id.vendor && + id->product == ulpi->id.product) + return 1; + + return 0; +} + +static int ulpi_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct ulpi *ulpi = to_ulpi_dev(dev); + + if (add_uevent_var(env, "MODALIAS=ulpi:v%04xp%04x", + ulpi->id.vendor, ulpi->id.product)) + return -ENOMEM; + return 0; +} + +static int ulpi_probe(struct device *dev) +{ + struct ulpi_driver *drv = to_ulpi_driver(dev->driver); + + return drv->probe(to_ulpi_dev(dev)); +} + +static int ulpi_remove(struct device *dev) +{ + struct ulpi_driver *drv = to_ulpi_driver(dev->driver); + + if (drv->remove) + drv->remove(to_ulpi_dev(dev)); + + return 0; +} + +struct bus_type ulpi_bus = { + .name = "ulpi", + .match = ulpi_match, + .uevent = ulpi_uevent, + .probe = ulpi_probe, + .remove = ulpi_remove, +}; +EXPORT_SYMBOL_GPL(ulpi_bus); + +/* -- */ + +static ssize_t modalias_show(struct d