Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <tobetter@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dongjin Kim and committed by
Greg Kroah-Hartman
e8e44a48 45f6bc5f

+15 -9
+10 -9
drivers/usb/misc/usb3503.c
··· 42 42 #define USB3503_NRD 0x09 43 43 44 44 #define USB3503_PDS 0x0a 45 - #define USB3503_PORT1 (1 << 1) 46 - #define USB3503_PORT2 (1 << 2) 47 - #define USB3503_PORT3 (1 << 3) 48 45 49 46 #define USB3503_SP_ILOCK 0xe7 50 47 #define USB3503_SPILOCK_CONNECT (1 << 1) ··· 53 56 struct usb3503 { 54 57 enum usb3503_mode mode; 55 58 struct i2c_client *client; 59 + u8 port_off_mask; 56 60 int gpio_intn; 57 61 int gpio_reset; 58 62 int gpio_connect; ··· 132 134 goto err_hubmode; 133 135 } 134 136 135 - /* PDS : Port2,3 Disable For Self Powered Operation */ 136 - err = usb3503_set_bits(i2c, USB3503_PDS, 137 - (USB3503_PORT2 | USB3503_PORT3)); 138 - if (err < 0) { 139 - dev_err(&i2c->dev, "PDS failed (%d)\n", err); 140 - goto err_hubmode; 137 + /* PDS : Disable For Self Powered Operation */ 138 + if (hub->port_off_mask) { 139 + err = usb3503_set_bits(i2c, USB3503_PDS, 140 + hub->port_off_mask); 141 + if (err < 0) { 142 + dev_err(&i2c->dev, "PDS failed (%d)\n", err); 143 + goto err_hubmode; 144 + } 141 145 } 142 146 143 147 /* CFG1 : SELF_BUS_PWR -> Self-Powerd operation */ ··· 197 197 hub->client = i2c; 198 198 199 199 if (pdata) { 200 + hub->port_off_mask = pdata->port_off_mask; 200 201 hub->gpio_intn = pdata->gpio_intn; 201 202 hub->gpio_connect = pdata->gpio_connect; 202 203 hub->gpio_reset = pdata->gpio_reset;
+5
include/linux/platform_data/usb3503.h
··· 3 3 4 4 #define USB3503_I2C_NAME "usb3503" 5 5 6 + #define USB3503_OFF_PORT1 (1 << 1) 7 + #define USB3503_OFF_PORT2 (1 << 2) 8 + #define USB3503_OFF_PORT3 (1 << 3) 9 + 6 10 enum usb3503_mode { 7 11 USB3503_MODE_UNKNOWN, 8 12 USB3503_MODE_HUB, ··· 15 11 16 12 struct usb3503_platform_data { 17 13 enum usb3503_mode initial_mode; 14 + u8 port_off_mask; 18 15 int gpio_intn; 19 16 int gpio_connect; 20 17 int gpio_reset;