Lines Matching refs:hub
65 static int onboard_hub_power_on(struct onboard_hub *hub) in onboard_hub_power_on() argument
69 err = regulator_bulk_enable(hub->pdata->num_supplies, hub->supplies); in onboard_hub_power_on()
71 dev_err(hub->dev, "failed to enable supplies: %d\n", err); in onboard_hub_power_on()
75 fsleep(hub->pdata->reset_us); in onboard_hub_power_on()
76 gpiod_set_value_cansleep(hub->reset_gpio, 0); in onboard_hub_power_on()
78 hub->is_powered_on = true; in onboard_hub_power_on()
83 static int onboard_hub_power_off(struct onboard_hub *hub) in onboard_hub_power_off() argument
87 gpiod_set_value_cansleep(hub->reset_gpio, 1); in onboard_hub_power_off()
89 err = regulator_bulk_disable(hub->pdata->num_supplies, hub->supplies); in onboard_hub_power_off()
91 dev_err(hub->dev, "failed to disable supplies: %d\n", err); in onboard_hub_power_off()
95 hub->is_powered_on = false; in onboard_hub_power_off()
102 struct onboard_hub *hub = dev_get_drvdata(dev); in onboard_hub_suspend() local
106 if (hub->always_powered_in_suspend) in onboard_hub_suspend()
109 mutex_lock(&hub->lock); in onboard_hub_suspend()
111 list_for_each_entry(node, &hub->udev_list, list) { in onboard_hub_suspend()
121 mutex_unlock(&hub->lock); in onboard_hub_suspend()
126 return onboard_hub_power_off(hub); in onboard_hub_suspend()
131 struct onboard_hub *hub = dev_get_drvdata(dev); in onboard_hub_resume() local
133 if (hub->is_powered_on) in onboard_hub_resume()
136 return onboard_hub_power_on(hub); in onboard_hub_resume()
144 static int onboard_hub_add_usbdev(struct onboard_hub *hub, struct usb_device *udev) in onboard_hub_add_usbdev() argument
150 mutex_lock(&hub->lock); in onboard_hub_add_usbdev()
152 if (hub->going_away) { in onboard_hub_add_usbdev()
165 list_add(&node->list, &hub->udev_list); in onboard_hub_add_usbdev()
167 mutex_unlock(&hub->lock); in onboard_hub_add_usbdev()
170 WARN_ON(sysfs_create_link(&hub->dev->kobj, &udev->dev.kobj, link_name)); in onboard_hub_add_usbdev()
175 mutex_unlock(&hub->lock); in onboard_hub_add_usbdev()
180 static void onboard_hub_remove_usbdev(struct onboard_hub *hub, const struct usb_device *udev) in onboard_hub_remove_usbdev() argument
186 sysfs_remove_link(&hub->dev->kobj, link_name); in onboard_hub_remove_usbdev()
188 mutex_lock(&hub->lock); in onboard_hub_remove_usbdev()
190 list_for_each_entry(node, &hub->udev_list, list) { in onboard_hub_remove_usbdev()
198 mutex_unlock(&hub->lock); in onboard_hub_remove_usbdev()
204 const struct onboard_hub *hub = dev_get_drvdata(dev); in always_powered_in_suspend_show() local
206 return sysfs_emit(buf, "%d\n", hub->always_powered_in_suspend); in always_powered_in_suspend_show()
212 struct onboard_hub *hub = dev_get_drvdata(dev); in always_powered_in_suspend_store() local
220 hub->always_powered_in_suspend = val; in always_powered_in_suspend_store()
245 struct onboard_hub *hub; in onboard_hub_probe() local
249 hub = devm_kzalloc(dev, sizeof(*hub), GFP_KERNEL); in onboard_hub_probe()
250 if (!hub) in onboard_hub_probe()
257 hub->pdata = of_id->data; in onboard_hub_probe()
258 if (!hub->pdata) in onboard_hub_probe()
261 if (hub->pdata->num_supplies > MAX_SUPPLIES) in onboard_hub_probe()
265 for (i = 0; i < hub->pdata->num_supplies; i++) in onboard_hub_probe()
266 hub->supplies[i].supply = supply_names[i]; in onboard_hub_probe()
268 err = devm_regulator_bulk_get(dev, hub->pdata->num_supplies, hub->supplies); in onboard_hub_probe()
274 hub->reset_gpio = devm_gpiod_get_optional(dev, "reset", in onboard_hub_probe()
276 if (IS_ERR(hub->reset_gpio)) in onboard_hub_probe()
277 return dev_err_probe(dev, PTR_ERR(hub->reset_gpio), "failed to get reset GPIO\n"); in onboard_hub_probe()
279 hub->dev = dev; in onboard_hub_probe()
280 mutex_init(&hub->lock); in onboard_hub_probe()
281 INIT_LIST_HEAD(&hub->udev_list); in onboard_hub_probe()
283 dev_set_drvdata(dev, hub); in onboard_hub_probe()
285 err = onboard_hub_power_on(hub); in onboard_hub_probe()
304 struct onboard_hub *hub = dev_get_drvdata(&pdev->dev); in onboard_hub_remove() local
308 hub->going_away = true; in onboard_hub_remove()
310 mutex_lock(&hub->lock); in onboard_hub_remove()
313 while (!list_empty(&hub->udev_list)) { in onboard_hub_remove()
314 node = list_first_entry(&hub->udev_list, struct usbdev_node, list); in onboard_hub_remove()
322 mutex_unlock(&hub->lock); in onboard_hub_remove()
325 mutex_lock(&hub->lock); in onboard_hub_remove()
328 mutex_unlock(&hub->lock); in onboard_hub_remove()
330 onboard_hub_power_off(hub); in onboard_hub_remove()
368 struct onboard_hub *hub; in _find_onboard_hub() local
385 hub = dev_get_drvdata(&pdev->dev); in _find_onboard_hub()
395 if (!hub) in _find_onboard_hub()
398 return hub; in _find_onboard_hub()
404 struct onboard_hub *hub; in onboard_hub_usbdev_probe() local
411 hub = _find_onboard_hub(dev); in onboard_hub_usbdev_probe()
412 if (IS_ERR(hub)) in onboard_hub_usbdev_probe()
413 return PTR_ERR(hub); in onboard_hub_usbdev_probe()
415 dev_set_drvdata(dev, hub); in onboard_hub_usbdev_probe()
417 err = onboard_hub_add_usbdev(hub, udev); in onboard_hub_usbdev_probe()
426 struct onboard_hub *hub = dev_get_drvdata(&udev->dev); in onboard_hub_usbdev_disconnect() local
428 onboard_hub_remove_usbdev(hub, udev); in onboard_hub_usbdev_disconnect()