]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
usb: dfu: fix boards wo USB cable detection
authorMateusz Zalega <m.zalega@samsung.com>
Wed, 30 Apr 2014 11:07:48 +0000 (13:07 +0200)
committerLukasz Majewski <l.majewski@samsung.com>
Mon, 5 May 2014 06:00:28 +0000 (08:00 +0200)
Former usb_cable_connected() patch broke compilation of boards which do
not support this feature.

I've renamed usb_cable_connected() to g_dnl_usb_cable_connected() and added
its default implementation to gadget downloader driver code. There's
only one driver of this kind and it's unlikely there'll be another, so
there's no point in keeping it in /common.

Previously this function was declared in usb.h. I've moved it, since
it's more appropriate to keep it in g_dnl.h - usb.h seems to be intended
for USB host implementation.

Existing code, confronted with default -EOPNOTSUPP return value,
continues as if the cable was connected.

CONFIG_USB_CABLE_CHECK was removed.

Change-Id: Ib9198621adee2811b391c64512f14646cefd0369
Signed-off-by: Mateusz Zalega <m.zalega@samsung.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
README
board/samsung/origen/origen.c
board/samsung/trats/trats.c
board/samsung/trats2/trats2.c
board/samsung/universal_c210/universal.c
common/cmd_usb_mass_storage.c
drivers/usb/gadget/f_mass_storage.c
drivers/usb/gadget/g_dnl.c
include/configs/exynos4-dt.h
include/g_dnl.h
include/usb.h

diff --git a/README b/README
index 12758dc6e793f3fb27b0520ea7127788921308a2..b973344184f23210a9ff40b5d311a022df4eec2c 100644 (file)
--- a/README
+++ b/README
@@ -1484,13 +1484,6 @@ The following options need to be configured:
                        for your device
                        - CONFIG_USBD_PRODUCTID 0xFFFF
 
-               Some USB device drivers may need to check USB cable attachment.
-               In this case you can enable following config in BoardName.h:
-                       CONFIG_USB_CABLE_CHECK
-                       This enables function definition:
-                       - usb_cable_connected() in include/usb.h
-                       Implementation of this function is board-specific.
-
 - ULPI Layer Support:
                The ULPI (UTMI Low Pin (count) Interface) PHYs are supported via
                the generic ULPI layer. The generic layer accesses the ULPI PHY
index d502f02d3dac2a339a099734ac541fd2f7365e2c..a539267a1ca43339ddfe246ecc37aa85b0f73b9f 100644 (file)
@@ -30,13 +30,6 @@ int board_usb_init(int index, enum usb_init_type init)
        return 0;
 }
 
-#ifdef CONFIG_USB_CABLE_CHECK
-int usb_cable_connected(void)
-{
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 int exynos_early_init_f(void)
 {
index 7c79e7b73a75727fb483b441ac2a8958546d365b..ab0ad1d6505b9ae94e5f98fc0bec824092b7a100 100644 (file)
@@ -430,8 +430,7 @@ int board_usb_init(int index, enum usb_init_type init)
        return s3c_udc_probe(&s5pc210_otg_data);
 }
 
-#ifdef CONFIG_USB_CABLE_CHECK
-int usb_cable_connected(void)
+int g_dnl_board_usb_cable_connected(void)
 {
        struct pmic *muic = pmic_get("MAX8997_MUIC");
        if (!muic)
@@ -440,7 +439,6 @@ int usb_cable_connected(void)
        return !!muic->chrg->chrg_type(muic);
 }
 #endif
-#endif
 
 static void pmic_reset(void)
 {
index f558ef97a91cccd67348c0ec800c1686859c4800..47095252a7522e82256f832ce35267001808436f 100644 (file)
@@ -312,8 +312,7 @@ int board_usb_init(int index, enum usb_init_type init)
        return s3c_udc_probe(&s5pc210_otg_data);
 }
 
-#ifdef CONFIG_USB_CABLE_CHECK
-int usb_cable_connected(void)
+int g_dnl_board_usb_cable_connected(void)
 {
        struct pmic *muic = pmic_get("MAX77693_MUIC");
        if (!muic)
@@ -322,7 +321,6 @@ int usb_cable_connected(void)
        return !!muic->chrg->chrg_type(muic);
 }
 #endif
-#endif
 
 static int pmic_init_max77686(void)
 {
index f9d71b617dd0256a4083f329cbf67884d8261fff..8e49195fe1c05d005d24f51baebebe17c5c065c8 100644 (file)
@@ -197,13 +197,6 @@ int board_usb_init(int index, enum usb_init_type init)
        return s3c_udc_probe(&s5pc210_otg_data);
 }
 
-#ifdef CONFIG_USB_CABLE_CHECK
-int usb_cable_connected(void)
-{
-       return 0;
-}
-#endif
-
 int exynos_early_init_f(void)
 {
        wdt_stop();
index 5f557d5f857df2916cc5f818abbd8ac1b5e08b1c..14a5b6ae5ea1fcc9e855746a8f20a55f59e2a1b8 100644 (file)
@@ -45,10 +45,14 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
        /* Timeout unit: seconds */
        int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
 
-       if (!usb_cable_connected()) {
+       if (!g_dnl_board_usb_cable_connected()) {
+               /*
+                * Won't execute if we don't know whether the cable is
+                * connected.
+                */
                puts("Please connect USB cable.\n");
 
-               while (!usb_cable_connected()) {
+               while (!g_dnl_board_usb_cable_connected()) {
                        if (ctrlc()) {
                                puts("\rCTRL+C - Operation aborted.\n");
                                goto exit;
index f896169743c3a9cff8274c3e2062ae615e3d1ac1..4fae5cd3b1ad561674994b8e5c8265c4d5b69664 100644 (file)
 #include <config.h>
 #include <malloc.h>
 #include <common.h>
-#include <usb.h>
+#include <g_dnl.h>
 
 #include <linux/err.h>
 #include <linux/usb/ch9.h>
@@ -680,11 +680,11 @@ static int sleep_thread(struct fsg_common *common)
                        /* Handle CTRL+C */
                        if (ctrlc())
                                return -EPIPE;
-#ifdef CONFIG_USB_CABLE_CHECK
+
                        /* Check cable connection */
-                       if (!usb_cable_connected())
+                       if (!g_dnl_board_usb_cable_connected())
                                return -EIO;
-#endif
+
                        k = 0;
                }
 
index dd95afe86a5d5d44bbc07c91c883d09b1efa6958..973d7378b52a05bf79d47f45286e90624e82c697 100644 (file)
@@ -152,6 +152,11 @@ __weak int g_dnl_get_board_bcd_device_number(int gcnum)
        return gcnum;
 }
 
+__weak int g_dnl_board_usb_cable_connected(void)
+{
+       return -EOPNOTSUPP;
+}
+
 static int g_dnl_get_bcd_device_number(struct usb_composite_dev *cdev)
 {
        struct usb_gadget *gadget = cdev->gadget;
index 2040bf7784d2255f1b804d365d4ce49609a43c59..cbd2d204cf98d3551029c6e4cd9137094149ebc4 100644 (file)
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_USB_GADGET_VBUS_DRAW    2
-#define CONFIG_USB_CABLE_CHECK
 
 #define CONFIG_CMD_USB_MASS_STORAGE
 #define CONFIG_USB_GADGET_MASS_STORAGE
index 8f813c21ee6ace1cdec6e55bcd18b75051dca15a..f4e8d1089e639b8d3157221e0dff60294063fb37 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 int g_dnl_bind_fixup(struct usb_device_descriptor *, const char *);
+int g_dnl_board_usb_cable_connected(void);
 int g_dnl_register(const char *s);
 void g_dnl_unregister(void);
 void g_dnl_set_serialnumber(char *);
index 736730e8964258470939f218c32853b3571328b8..d9fedeeff7de98bcc192fc2b76e561db067010ab 100644 (file)
@@ -197,16 +197,6 @@ int board_usb_init(int index, enum usb_init_type init);
  */
 int board_usb_cleanup(int index, enum usb_init_type init);
 
-/*
- * If CONFIG_USB_CABLE_CHECK is set then this function
- * should be defined in board file.
- *
- * @return 1 if cable is connected and 0 otherwise.
- */
-#ifdef CONFIG_USB_CABLE_CHECK
-int usb_cable_connected(void);
-#endif
-
 #ifdef CONFIG_USB_STORAGE
 
 #define USB_MAX_STOR_DEV 5