From e8e44a4896a5f0bde1af36a31b7ec662bdaa44ef Mon Sep 17 00:00:00 2001 From: Dongjin Kim Date: Wed, 22 May 2013 05:20:08 +0900 Subject: usb: misc: usb3503: Add to select the ports to disable This patch is to disable the USB ports unconnected to USB3503. In order to disable the port, 'port_off_mask' must be set. * Disable PORT1 only .port_off_mask = USB3503_OFF_PORT1; * Disable PORT1 and PORT3 only .port_off_mask = USB3503_OFF_PORT1 | USB3503_OFF_PORT3; * Enables all ports .port_off_mask = 0; Signed-off-by: Dongjin Kim Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/usb3503.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'drivers/usb/misc/usb3503.c') diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index d3a1cce1bf9c..ab24bb345979 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -42,9 +42,6 @@ #define USB3503_NRD 0x09 #define USB3503_PDS 0x0a -#define USB3503_PORT1 (1 << 1) -#define USB3503_PORT2 (1 << 2) -#define USB3503_PORT3 (1 << 3) #define USB3503_SP_ILOCK 0xe7 #define USB3503_SPILOCK_CONNECT (1 << 1) @@ -56,6 +53,7 @@ struct usb3503 { enum usb3503_mode mode; struct i2c_client *client; + u8 port_off_mask; int gpio_intn; int gpio_reset; int gpio_connect; @@ -134,12 +132,14 @@ static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode) goto err_hubmode; } - /* PDS : Port2,3 Disable For Self Powered Operation */ - err = usb3503_set_bits(i2c, USB3503_PDS, - (USB3503_PORT2 | USB3503_PORT3)); - if (err < 0) { - dev_err(&i2c->dev, "PDS failed (%d)\n", err); - goto err_hubmode; + /* PDS : Disable For Self Powered Operation */ + if (hub->port_off_mask) { + err = usb3503_set_bits(i2c, USB3503_PDS, + hub->port_off_mask); + if (err < 0) { + dev_err(&i2c->dev, "PDS failed (%d)\n", err); + goto err_hubmode; + } } /* CFG1 : SELF_BUS_PWR -> Self-Powerd operation */ @@ -197,6 +197,7 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) hub->client = i2c; if (pdata) { + hub->port_off_mask = pdata->port_off_mask; hub->gpio_intn = pdata->gpio_intn; hub->gpio_connect = pdata->gpio_connect; hub->gpio_reset = pdata->gpio_reset; -- cgit v1.2.3 From e8b58b49130f40c29bb95cd5d9b36955ff703822 Mon Sep 17 00:00:00 2001 From: Dongjin Kim Date: Wed, 22 May 2013 05:20:09 +0900 Subject: usb: misc: usb3503: Adding device tree entry 'disabled-ports' This patch is to add a property 'disabled-ports' representing the unused port of USB3503. USB3503 can support up to 3 USB host port and each ports can be controlled to be enabled or disabled. Do not describe this property if all ports must be enabled. You can represent the ports to disable in the device tree. usb3503@08{ ... disabled-ports = <2 3>; ... }; Signed-off-by: Dongjin Kim Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/usb3503.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers/usb/misc/usb3503.c') diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index ab24bb345979..1908ec65c55b 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -186,6 +186,8 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) struct usb3503 *hub; int err = -ENOMEM; u32 mode = USB3503_MODE_UNKNOWN; + const u32 *property; + int len; hub = kzalloc(sizeof(struct usb3503), GFP_KERNEL); if (!hub) { @@ -203,6 +205,18 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) hub->gpio_reset = pdata->gpio_reset; hub->mode = pdata->initial_mode; } else if (np) { + hub->port_off_mask = 0; + + property = of_get_property(np, "disabled-ports", &len); + if (property && (len / sizeof(u32)) > 0) { + int i; + for (i = 0; i < len / sizeof(u32); i++) { + u32 port = be32_to_cpu(property[i]); + if ((1 <= port) && (port <= 3)) + hub->port_off_mask |= (1 << port); + } + } + hub->gpio_intn = of_get_named_gpio(np, "connect-gpios", 0); if (hub->gpio_intn == -EPROBE_DEFER) return -EPROBE_DEFER; -- cgit v1.2.3 From ccf92c94135059c2fa7ee67bbd19af5103547510 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Fri, 31 May 2013 18:34:50 -0700 Subject: usb: misc: usb3503: Fix up whitespace Remove an erroneous tab that should be a space. Signed-off-by: Julius Werner Signed-off-by: Dongjin Kim Acked-by: Olof Johansson Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/usb3503.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/misc/usb3503.c') diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index 1908ec65c55b..a56299dbfaf4 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -223,7 +223,7 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) hub->gpio_connect = of_get_named_gpio(np, "intn-gpios", 0); if (hub->gpio_connect == -EPROBE_DEFER) return -EPROBE_DEFER; - hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0); + hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0); if (hub->gpio_reset == -EPROBE_DEFER) return -EPROBE_DEFER; of_property_read_u32(np, "initial-mode", &mode); -- cgit v1.2.3 From 06a962fa7f9bf068eb1238d7aa20453b9e11a9fd Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Fri, 31 May 2013 18:34:52 -0700 Subject: usb: misc: usb3503: Remove 100ms sleep on reset, conform to data sheet The usb3503 driver sleeps a flat 100ms when resetting the chip, with a comment about waiting for the reference clock. This seems to be a board-specific detail that should not hold up boot across all platforms. This patch reduces the sleep to the 4ms initialization delay that the chip itself actually requires (as per its data sheet). If certain boards require more time to set up the reference clock, they should change this through local patches or add a proper, configurable synchronization mechanism. Signed-off-by: Julius Werner Signed-off-by: Dongjin Kim Acked-by: Olof Johansson Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/usb3503.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/usb/misc/usb3503.c') diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index a56299dbfaf4..c3578393ddef 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -105,11 +105,9 @@ static int usb3503_reset(int gpio_reset, int state) if (gpio_is_valid(gpio_reset)) gpio_set_value(gpio_reset, state); - /* Wait RefClk when RESET_N is released, otherwise Hub will - * not transition to Hub Communication Stage. - */ + /* Wait T_HUBINIT == 4ms for hub logic to stabilize */ if (state) - msleep(100); + usleep_range(4000, 10000); return 0; } -- cgit v1.2.3