aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authorDongjin Kim <tobetter@gmail.com>2013-01-23 12:47:10 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-24 16:42:10 -0500
commiteab8050c0168ab6595e9ac6bc72a14d27390ea7a (patch)
tree7c528d0f053cb902d1b05e40448b36b010dd4d51 /drivers/usb/misc
parent9bc5d12620cb88aa7df4700980f8106d0e66a9dc (diff)
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>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/usb3503.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index dc2c993ea189..471218aea7b3 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/of_gpio.h>
26#include <linux/platform_device.h> 27#include <linux/platform_device.h>
27#include <linux/platform_data/usb3503.h> 28#include <linux/platform_data/usb3503.h>
28 29
@@ -181,8 +182,10 @@ err_hubmode:
181static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) 182static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
182{ 183{
183 struct usb3503_platform_data *pdata = i2c->dev.platform_data; 184 struct usb3503_platform_data *pdata = i2c->dev.platform_data;
185 struct device_node *np = i2c->dev.of_node;
184 struct usb3503 *hub; 186 struct usb3503 *hub;
185 int err = -ENOMEM; 187 int err = -ENOMEM;
188 u32 mode;
186 189
187 hub = kzalloc(sizeof(struct usb3503), GFP_KERNEL); 190 hub = kzalloc(sizeof(struct usb3503), GFP_KERNEL);
188 if (!hub) { 191 if (!hub) {
@@ -193,14 +196,23 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
193 i2c_set_clientdata(i2c, hub); 196 i2c_set_clientdata(i2c, hub);
194 hub->client = i2c; 197 hub->client = i2c;
195 198
196 if (!pdata) { 199 if (pdata) {
197 dev_dbg(&i2c->dev, "missing platform data\n");
198 goto err_out;
199 } else {
200 hub->gpio_intn = pdata->gpio_intn; 200 hub->gpio_intn = pdata->gpio_intn;
201 hub->gpio_connect = pdata->gpio_connect; 201 hub->gpio_connect = pdata->gpio_connect;
202 hub->gpio_reset = pdata->gpio_reset; 202 hub->gpio_reset = pdata->gpio_reset;
203 hub->mode = pdata->initial_mode; 203 hub->mode = pdata->initial_mode;
204 } else if (np) {
205 hub->gpio_intn = of_get_named_gpio(np, "connect-gpios", 0);
206 if (hub->gpio_intn == -EPROBE_DEFER)
207 return -EPROBE_DEFER;
208 hub->gpio_connect = of_get_named_gpio(np, "intn-gpios", 0);
209 if (hub->gpio_connect == -EPROBE_DEFER)
210 return -EPROBE_DEFER;
211 hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0);
212 if (hub->gpio_reset == -EPROBE_DEFER)
213 return -EPROBE_DEFER;
214 of_property_read_u32(np, "initial-mode", &mode);
215 hub->mode = mode;
204 } 216 }
205 217
206 if (gpio_is_valid(hub->gpio_intn)) { 218 if (gpio_is_valid(hub->gpio_intn)) {
@@ -236,7 +248,7 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
236 } 248 }
237 } 249 }
238 250
239 usb3503_switch_mode(hub, pdata->initial_mode); 251 usb3503_switch_mode(hub, hub->mode);
240 252
241 dev_info(&i2c->dev, "%s: probed on %s mode\n", __func__, 253 dev_info(&i2c->dev, "%s: probed on %s mode\n", __func__,
242 (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby"); 254 (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby");
@@ -277,9 +289,18 @@ static const struct i2c_device_id usb3503_id[] = {
277}; 289};
278MODULE_DEVICE_TABLE(i2c, usb3503_id); 290MODULE_DEVICE_TABLE(i2c, usb3503_id);
279 291
292#ifdef CONFIG_OF
293static const struct of_device_id usb3503_of_match[] = {
294 { .compatible = "smsc,usb3503", },
295 {},
296};
297MODULE_DEVICE_TABLE(of, usb3503_of_match);
298#endif
299
280static struct i2c_driver usb3503_driver = { 300static struct i2c_driver usb3503_driver = {
281 .driver = { 301 .driver = {
282 .name = USB3503_I2C_NAME, 302 .name = USB3503_I2C_NAME,
303 .of_match_table = of_match_ptr(usb3503_of_match),
283 }, 304 },
284 .probe = usb3503_probe, 305 .probe = usb3503_probe,
285 .remove = usb3503_remove, 306 .remove = usb3503_remove,