Lines Matching refs:hub

54 static int onboard_hub_power_on(struct onboard_hub *hub)  in onboard_hub_power_on()  argument
58 err = regulator_enable(hub->vdd); in onboard_hub_power_on()
60 dev_err(hub->dev, "failed to enable regulator: %d\n", err); in onboard_hub_power_on()
64 fsleep(hub->pdata->reset_us); in onboard_hub_power_on()
65 gpiod_set_value_cansleep(hub->reset_gpio, 0); in onboard_hub_power_on()
67 hub->is_powered_on = true; in onboard_hub_power_on()
72 static int onboard_hub_power_off(struct onboard_hub *hub) in onboard_hub_power_off() argument
76 gpiod_set_value_cansleep(hub->reset_gpio, 1); in onboard_hub_power_off()
78 err = regulator_disable(hub->vdd); in onboard_hub_power_off()
80 dev_err(hub->dev, "failed to disable regulator: %d\n", err); in onboard_hub_power_off()
84 hub->is_powered_on = false; in onboard_hub_power_off()
91 struct onboard_hub *hub = dev_get_drvdata(dev); in onboard_hub_suspend() local
95 if (hub->always_powered_in_suspend) in onboard_hub_suspend()
98 mutex_lock(&hub->lock); in onboard_hub_suspend()
100 list_for_each_entry(node, &hub->udev_list, list) { in onboard_hub_suspend()
110 mutex_unlock(&hub->lock); in onboard_hub_suspend()
115 return onboard_hub_power_off(hub); in onboard_hub_suspend()
120 struct onboard_hub *hub = dev_get_drvdata(dev); in onboard_hub_resume() local
122 if (hub->is_powered_on) in onboard_hub_resume()
125 return onboard_hub_power_on(hub); in onboard_hub_resume()
133 static int onboard_hub_add_usbdev(struct onboard_hub *hub, struct usb_device *udev) in onboard_hub_add_usbdev() argument
139 mutex_lock(&hub->lock); in onboard_hub_add_usbdev()
141 if (hub->going_away) { in onboard_hub_add_usbdev()
154 list_add(&node->list, &hub->udev_list); in onboard_hub_add_usbdev()
156 mutex_unlock(&hub->lock); in onboard_hub_add_usbdev()
159 WARN_ON(sysfs_create_link(&hub->dev->kobj, &udev->dev.kobj, link_name)); in onboard_hub_add_usbdev()
164 mutex_unlock(&hub->lock); in onboard_hub_add_usbdev()
169 static void onboard_hub_remove_usbdev(struct onboard_hub *hub, const struct usb_device *udev) in onboard_hub_remove_usbdev() argument
175 sysfs_remove_link(&hub->dev->kobj, link_name); in onboard_hub_remove_usbdev()
177 mutex_lock(&hub->lock); in onboard_hub_remove_usbdev()
179 list_for_each_entry(node, &hub->udev_list, list) { in onboard_hub_remove_usbdev()
187 mutex_unlock(&hub->lock); in onboard_hub_remove_usbdev()
193 const struct onboard_hub *hub = dev_get_drvdata(dev); in always_powered_in_suspend_show() local
195 return sysfs_emit(buf, "%d\n", hub->always_powered_in_suspend); in always_powered_in_suspend_show()
201 struct onboard_hub *hub = dev_get_drvdata(dev); in always_powered_in_suspend_store() local
209 hub->always_powered_in_suspend = val; in always_powered_in_suspend_store()
234 struct onboard_hub *hub; in onboard_hub_probe() local
237 hub = devm_kzalloc(dev, sizeof(*hub), GFP_KERNEL); in onboard_hub_probe()
238 if (!hub) in onboard_hub_probe()
245 hub->pdata = of_id->data; in onboard_hub_probe()
246 if (!hub->pdata) in onboard_hub_probe()
249 hub->vdd = devm_regulator_get(dev, "vdd"); in onboard_hub_probe()
250 if (IS_ERR(hub->vdd)) in onboard_hub_probe()
251 return PTR_ERR(hub->vdd); in onboard_hub_probe()
253 hub->reset_gpio = devm_gpiod_get_optional(dev, "reset", in onboard_hub_probe()
255 if (IS_ERR(hub->reset_gpio)) in onboard_hub_probe()
256 return dev_err_probe(dev, PTR_ERR(hub->reset_gpio), "failed to get reset GPIO\n"); in onboard_hub_probe()
258 hub->dev = dev; in onboard_hub_probe()
259 mutex_init(&hub->lock); in onboard_hub_probe()
260 INIT_LIST_HEAD(&hub->udev_list); in onboard_hub_probe()
262 dev_set_drvdata(dev, hub); in onboard_hub_probe()
264 err = onboard_hub_power_on(hub); in onboard_hub_probe()
283 struct onboard_hub *hub = dev_get_drvdata(&pdev->dev); in onboard_hub_remove() local
287 hub->going_away = true; in onboard_hub_remove()
289 mutex_lock(&hub->lock); in onboard_hub_remove()
292 while (!list_empty(&hub->udev_list)) { in onboard_hub_remove()
293 node = list_first_entry(&hub->udev_list, struct usbdev_node, list); in onboard_hub_remove()
301 mutex_unlock(&hub->lock); in onboard_hub_remove()
304 mutex_lock(&hub->lock); in onboard_hub_remove()
307 mutex_unlock(&hub->lock); in onboard_hub_remove()
309 return onboard_hub_power_off(hub); in onboard_hub_remove()
344 struct onboard_hub *hub; in _find_onboard_hub() local
361 hub = dev_get_drvdata(&pdev->dev); in _find_onboard_hub()
371 if (!hub) in _find_onboard_hub()
374 return hub; in _find_onboard_hub()
380 struct onboard_hub *hub; in onboard_hub_usbdev_probe() local
387 hub = _find_onboard_hub(dev); in onboard_hub_usbdev_probe()
388 if (IS_ERR(hub)) in onboard_hub_usbdev_probe()
389 return PTR_ERR(hub); in onboard_hub_usbdev_probe()
391 dev_set_drvdata(dev, hub); in onboard_hub_usbdev_probe()
393 err = onboard_hub_add_usbdev(hub, udev); in onboard_hub_usbdev_probe()
402 struct onboard_hub *hub = dev_get_drvdata(&udev->dev); in onboard_hub_usbdev_disconnect() local
404 onboard_hub_remove_usbdev(hub, udev); in onboard_hub_usbdev_disconnect()