Lines Matching defs:hub

2  * Driver for SMSC USB3503 USB 2.0 hub controller driver
69 static int usb3503_reset(struct usb3503 *hub, int state)
71 if (!state && gpio_is_valid(hub->gpio_connect))
72 gpio_set_value_cansleep(hub->gpio_connect, 0);
74 if (gpio_is_valid(hub->gpio_reset))
75 gpio_set_value_cansleep(hub->gpio_reset, state);
77 /* Wait T_HUBINIT == 4ms for hub logic to stabilize */
84 static int usb3503_connect(struct usb3503 *hub)
86 struct device *dev = hub->dev;
89 usb3503_reset(hub, 1);
91 if (hub->regmap) {
93 err = regmap_write(hub->regmap, USB3503_SP_ILOCK,
102 if (hub->port_off_mask) {
103 err = regmap_update_bits(hub->regmap, USB3503_PDS,
104 hub->port_off_mask,
105 hub->port_off_mask);
113 err = regmap_update_bits(hub->regmap, USB3503_CFG1,
121 /* SP_LOCK: clear connect_n, config_n for hub connect */
122 err = regmap_update_bits(hub->regmap, USB3503_SP_ILOCK,
131 if (gpio_is_valid(hub->gpio_connect))
132 gpio_set_value_cansleep(hub->gpio_connect, 1);
134 hub->mode = USB3503_MODE_HUB;
140 static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode)
142 struct device *dev = hub->dev;
147 err = usb3503_connect(hub);
151 usb3503_reset(hub, 0);
171 static int usb3503_probe(struct usb3503 *hub)
173 struct device *dev = hub->dev;
182 hub->port_off_mask = pdata->port_off_mask;
183 hub->gpio_intn = pdata->gpio_intn;
184 hub->gpio_connect = pdata->gpio_connect;
185 hub->gpio_reset = pdata->gpio_reset;
186 hub->mode = pdata->initial_mode;
189 hub->port_off_mask = 0;
200 hub->clk = clk;
210 hub->secondary_ref_clk = 0;
216 hub->secondary_ref_clk = 1;
224 err = clk_set_rate(hub->clk, rate);
233 err = clk_prepare_enable(hub->clk);
247 hub->port_off_mask |= (1 << port);
251 hub->gpio_intn = of_get_named_gpio(np, "intn-gpios", 0);
252 if (hub->gpio_intn == -EPROBE_DEFER)
254 hub->gpio_connect = of_get_named_gpio(np, "connect-gpios", 0);
255 if (hub->gpio_connect == -EPROBE_DEFER)
257 hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0);
258 if (hub->gpio_reset == -EPROBE_DEFER)
261 hub->mode = mode;
264 if (hub->port_off_mask && !hub->regmap)
267 if (gpio_is_valid(hub->gpio_intn)) {
268 int val = hub->secondary_ref_clk ? GPIOF_OUT_INIT_LOW :
270 err = devm_gpio_request_one(dev, hub->gpio_intn, val,
275 hub->gpio_intn, err);
280 if (gpio_is_valid(hub->gpio_connect)) {
281 err = devm_gpio_request_one(dev, hub->gpio_connect,
286 hub->gpio_connect, err);
291 if (gpio_is_valid(hub->gpio_reset)) {
292 err = devm_gpio_request_one(dev, hub->gpio_reset,
297 hub->gpio_reset, err);
302 usb3503_switch_mode(hub, hub->mode);
305 (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby");
313 struct usb3503 *hub;
316 hub = devm_kzalloc(&i2c->dev, sizeof(struct usb3503), GFP_KERNEL);
317 if (!hub) {
322 i2c_set_clientdata(i2c, hub);
323 hub->regmap = devm_regmap_init_i2c(i2c, &usb3503_regmap_config);
324 if (IS_ERR(hub->regmap)) {
325 err = PTR_ERR(hub->regmap);
329 hub->dev = &i2c->dev;
331 return usb3503_probe(hub);
336 struct usb3503 *hub;
338 hub = devm_kzalloc(&pdev->dev, sizeof(struct usb3503), GFP_KERNEL);
339 if (!hub) {
343 hub->dev = &pdev->dev;
345 return usb3503_probe(hub);
352 struct usb3503 *hub = i2c_get_clientdata(client);
354 usb3503_switch_mode(hub, USB3503_MODE_STANDBY);
356 if (hub->clk)
357 clk_disable_unprepare(hub->clk);
365 struct usb3503 *hub = i2c_get_clientdata(client);
367 if (hub->clk)
368 clk_prepare_enable(hub->clk);
370 usb3503_switch_mode(hub, hub->mode);