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

USB: misc: usb3503: add dt support

Added device tree support for usb3503 driver and add new document with device tree binding information.

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
eab8050c 9bc5d126

+46 -5
+20
Documentation/devicetree/bindings/usb/usb3503.txt
··· 1 + SMSC USB3503 High-Speed Hub Controller 2 + 3 + Required properties: 4 + - compatible: Should be "smsc,usb3503". 5 + - reg: Specifies the i2c slave address, it should be 0x08. 6 + - connect-gpios: Should specify GPIO for connect. 7 + - intn-gpios: Should specify GPIO for interrupt. 8 + - reset-gpios: Should specify GPIO for reset. 9 + - initial-mode: Should specify initial mode. 10 + (1 for HUB mode, 2 for STANDBY mode) 11 + 12 + Examples: 13 + usb3503@08 { 14 + compatible = "smsc,usb3503"; 15 + reg = <0x08>; 16 + connect-gpios = <&gpx3 0 1>; 17 + intn-gpios = <&gpx3 4 1>; 18 + reset-gpios = <&gpx3 5 1>; 19 + initial-mode = <1>; 20 + };
+26 -5
drivers/usb/misc/usb3503.c
··· 23 23 #include <linux/delay.h> 24 24 #include <linux/slab.h> 25 25 #include <linux/module.h> 26 + #include <linux/of_gpio.h> 26 27 #include <linux/platform_device.h> 27 28 #include <linux/platform_data/usb3503.h> 28 29 ··· 182 181 static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) 183 182 { 184 183 struct usb3503_platform_data *pdata = i2c->dev.platform_data; 184 + struct device_node *np = i2c->dev.of_node; 185 185 struct usb3503 *hub; 186 186 int err = -ENOMEM; 187 + u32 mode; 187 188 188 189 hub = kzalloc(sizeof(struct usb3503), GFP_KERNEL); 189 190 if (!hub) { ··· 196 193 i2c_set_clientdata(i2c, hub); 197 194 hub->client = i2c; 198 195 199 - if (!pdata) { 200 - dev_dbg(&i2c->dev, "missing platform data\n"); 201 - goto err_out; 202 - } else { 196 + if (pdata) { 203 197 hub->gpio_intn = pdata->gpio_intn; 204 198 hub->gpio_connect = pdata->gpio_connect; 205 199 hub->gpio_reset = pdata->gpio_reset; 206 200 hub->mode = pdata->initial_mode; 201 + } else if (np) { 202 + hub->gpio_intn = of_get_named_gpio(np, "connect-gpios", 0); 203 + if (hub->gpio_intn == -EPROBE_DEFER) 204 + return -EPROBE_DEFER; 205 + hub->gpio_connect = of_get_named_gpio(np, "intn-gpios", 0); 206 + if (hub->gpio_connect == -EPROBE_DEFER) 207 + return -EPROBE_DEFER; 208 + hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0); 209 + if (hub->gpio_reset == -EPROBE_DEFER) 210 + return -EPROBE_DEFER; 211 + of_property_read_u32(np, "initial-mode", &mode); 212 + hub->mode = mode; 207 213 } 208 214 209 215 if (gpio_is_valid(hub->gpio_intn)) { ··· 248 236 } 249 237 } 250 238 251 - usb3503_switch_mode(hub, pdata->initial_mode); 239 + usb3503_switch_mode(hub, hub->mode); 252 240 253 241 dev_info(&i2c->dev, "%s: probed on %s mode\n", __func__, 254 242 (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby"); ··· 289 277 }; 290 278 MODULE_DEVICE_TABLE(i2c, usb3503_id); 291 279 280 + #ifdef CONFIG_OF 281 + static const struct of_device_id usb3503_of_match[] = { 282 + { .compatible = "smsc,usb3503", }, 283 + {}, 284 + }; 285 + MODULE_DEVICE_TABLE(of, usb3503_of_match); 286 + #endif 287 + 292 288 static struct i2c_driver usb3503_driver = { 293 289 .driver = { 294 290 .name = USB3503_I2C_NAME, 291 + .of_match_table = of_match_ptr(usb3503_of_match), 295 292 }, 296 293 .probe = usb3503_probe, 297 294 .remove = usb3503_remove,