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

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

authored by

Dongjin Kim and committed by
Greg Kroah-Hartman
e8b58b49 e8e44a48

+19
+5
Documentation/devicetree/bindings/usb/usb3503.txt
··· 4 4 - compatible: Should be "smsc,usb3503". 5 5 - reg: Specifies the i2c slave address, it should be 0x08. 6 6 - connect-gpios: Should specify GPIO for connect. 7 + - disabled-ports: Should specify the ports unused. 8 + '1' or '2' or '3' are availe for this property to describe the port 9 + number. 1~3 property values are possible to be desribed. 10 + Do not describe this property if all ports have to be enabled. 7 11 - intn-gpios: Should specify GPIO for interrupt. 8 12 - reset-gpios: Should specify GPIO for reset. 9 13 - initial-mode: Should specify initial mode. ··· 18 14 compatible = "smsc,usb3503"; 19 15 reg = <0x08>; 20 16 connect-gpios = <&gpx3 0 1>; 17 + disabled-ports = <2 3>; 21 18 intn-gpios = <&gpx3 4 1>; 22 19 reset-gpios = <&gpx3 5 1>; 23 20 initial-mode = <1>;
+14
drivers/usb/misc/usb3503.c
··· 186 186 struct usb3503 *hub; 187 187 int err = -ENOMEM; 188 188 u32 mode = USB3503_MODE_UNKNOWN; 189 + const u32 *property; 190 + int len; 189 191 190 192 hub = kzalloc(sizeof(struct usb3503), GFP_KERNEL); 191 193 if (!hub) { ··· 205 203 hub->gpio_reset = pdata->gpio_reset; 206 204 hub->mode = pdata->initial_mode; 207 205 } else if (np) { 206 + hub->port_off_mask = 0; 207 + 208 + property = of_get_property(np, "disabled-ports", &len); 209 + if (property && (len / sizeof(u32)) > 0) { 210 + int i; 211 + for (i = 0; i < len / sizeof(u32); i++) { 212 + u32 port = be32_to_cpu(property[i]); 213 + if ((1 <= port) && (port <= 3)) 214 + hub->port_off_mask |= (1 << port); 215 + } 216 + } 217 + 208 218 hub->gpio_intn = of_get_named_gpio(np, "connect-gpios", 0); 209 219 if (hub->gpio_intn == -EPROBE_DEFER) 210 220 return -EPROBE_DEFER;