From a06955ae1ef2a942f18025d4fefceea2c638a76f Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:52:41 +0100 Subject: usb: gadget: Do not call board_usb_xxx() directly in USB gadget drivers Add 2 functions to wrap the calls to board_usb_init() and board_usb_cleanup(). This is a preparatory work for DM support for UDC drivers (DM_USB_GADGET). Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Lukasz Majewski --- include/linux/usb/gadget.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index b824f13477..40ca2d3468 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -19,6 +19,7 @@ #define __LINUX_USB_GADGET_H #include +#include #include #include @@ -926,4 +927,13 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *); extern int usb_gadget_handle_interrupts(int index); +static inline int usb_gadget_initialize(int index) +{ + return board_usb_init(index, USB_INIT_DEVICE); +} + +static inline int usb_gadget_release(int index) +{ + return board_usb_cleanup(index, USB_INIT_DEVICE); +} #endif /* __LINUX_USB_GADGET_H */ -- cgit From ff8d75583487eb69bcb6f036088d979c76db3753 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:52:43 +0100 Subject: usb: udc: implement DM versions of usb_gadget_initialize()/_release()/_handle_interrupt() When DM_USB_GADGET the platform code for the USB device must be replaced by calls to a USB device driver. usb_gadget_initialize() probes the USB device driver. usb_gadget_release() removes the USB device driver. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Lukasz Majewski --- include/linux/usb/gadget.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 40ca2d3468..497798a32a 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -927,6 +927,12 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *); extern int usb_gadget_handle_interrupts(int index); +#if CONFIG_IS_ENABLED(DM_USB_GADGET) +int usb_gadget_initialize(int index); +int usb_gadget_release(int index); +int dm_usb_gadget_handle_interrupts(struct udevice *dev); +#else +#include static inline int usb_gadget_initialize(int index) { return board_usb_init(index, USB_INIT_DEVICE); @@ -936,4 +942,6 @@ static inline int usb_gadget_release(int index) { return board_usb_cleanup(index, USB_INIT_DEVICE); } +#endif + #endif /* __LINUX_USB_GADGET_H */ -- cgit From d648a50c0a27452a5439e7982b23b97c64820430 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:52:45 +0100 Subject: dwc3: move phy operation to core.c Those operations can be used for peripheral operation as well as host operation. Signed-off-by: Jean-Jacques Hiblot # Conflicts: # drivers/usb/dwc3/core.c # drivers/usb/host/xhci-dwc3.c --- include/dwc3-uboot.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/dwc3-uboot.h b/include/dwc3-uboot.h index 228ab3b102..9941cc37a3 100644 --- a/include/dwc3-uboot.h +++ b/include/dwc3-uboot.h @@ -38,4 +38,23 @@ struct dwc3_device { int dwc3_uboot_init(struct dwc3_device *dev); void dwc3_uboot_exit(int index); void dwc3_uboot_handle_interrupt(int index); + +struct phy; +#if CONFIG_IS_ENABLED(PHY) && CONFIG_IS_ENABLED(DM_USB) +int dwc3_setup_phy(struct udevice *dev, struct phy **array, int *num_phys); +int dwc3_shutdown_phy(struct udevice *dev, struct phy *usb_phys, int num_phys); +#else +static inline int dwc3_setup_phy(struct udevice *dev, struct phy **array, + int *num_phys) +{ + return -ENOTSUPP; +} + +static inline int dwc3_shutdown_phy(struct udevice *dev, struct phy *usb_phys, + int num_phys) +{ + return -ENOTSUPP; +} +#endif + #endif /* __DWC3_UBOOT_H_ */ -- cgit From 0131162439508801b9f8a330fa731f04273c9337 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:52:46 +0100 Subject: dm: usb: create a new UCLASS ID for USB gadget devices UCLASS_USB_DEV_GENERIC was meant for USB devices connected to host controllers, not gadget devices. Adding a new UCLASS for gadget devices alone. Also move the generic DM code for USB gadgets in a separate file for clarity. Signed-off-by: Jean-Jacques Hiblot --- include/dm/uclass-id.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 62d9e2f404..314fff4a81 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -93,6 +93,7 @@ enum uclass_id { UCLASS_USB, /* USB bus */ UCLASS_USB_DEV_GENERIC, /* USB generic device */ UCLASS_USB_HUB, /* USB hub */ + UCLASS_USB_GADGET_GENERIC, /* USB generic device */ UCLASS_VIDEO, /* Video or LCD device */ UCLASS_VIDEO_BRIDGE, /* Video bridge, e.g. DisplayPort to LVDS */ UCLASS_VIDEO_CONSOLE, /* Text console driver for video device */ -- cgit From 6c3af1f24e4b8ccbef20bc00b9529f4a325583f2 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:57:37 +0100 Subject: syscon: dm: Add a new method to get a regmap from DTS syscon_regmap_lookup_by_phandle() can be used to get the regmap of a syscon device from a reference in the DTS. It operates similarly to the linux version of the namesake function. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- include/syscon.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/syscon.h b/include/syscon.h index 2aa73e520a..3df96e3276 100644 --- a/include/syscon.h +++ b/include/syscon.h @@ -73,6 +73,19 @@ int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp); */ struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data); +/** + * syscon_regmap_lookup_by_phandle() - Look up a controller by a phandle + * + * This operates by looking up the given name in the device (device + * tree property) of the device using the system controller. + * + * @dev: Device using the system controller + * @name: Name of property referring to the system controller + * @return A pointer to the regmap if found, ERR_PTR(-ve) on error + */ +struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev, + const char *name); + /** * syscon_get_first_range() - get the first memory range from a syscon regmap * -- cgit