Lines Matching refs:hub
55 static int usb3503_reset(struct usb3503 *hub, int state) in usb3503_reset() argument
57 if (!state && hub->connect) in usb3503_reset()
58 gpiod_set_value_cansleep(hub->connect, 0); in usb3503_reset()
60 if (hub->reset) in usb3503_reset()
61 gpiod_set_value_cansleep(hub->reset, !state); in usb3503_reset()
70 static int usb3503_connect(struct usb3503 *hub) in usb3503_connect() argument
72 struct device *dev = hub->dev; in usb3503_connect()
75 usb3503_reset(hub, 1); in usb3503_connect()
77 if (hub->regmap) { in usb3503_connect()
79 err = regmap_write(hub->regmap, USB3503_SP_ILOCK, in usb3503_connect()
88 if (hub->port_off_mask) { in usb3503_connect()
89 err = regmap_update_bits(hub->regmap, USB3503_PDS, in usb3503_connect()
90 hub->port_off_mask, in usb3503_connect()
91 hub->port_off_mask); in usb3503_connect()
99 err = regmap_update_bits(hub->regmap, USB3503_CFG1, in usb3503_connect()
108 err = regmap_update_bits(hub->regmap, USB3503_SP_ILOCK, in usb3503_connect()
117 if (hub->connect) in usb3503_connect()
118 gpiod_set_value_cansleep(hub->connect, 1); in usb3503_connect()
120 hub->mode = USB3503_MODE_HUB; in usb3503_connect()
126 static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode) in usb3503_switch_mode() argument
128 struct device *dev = hub->dev; in usb3503_switch_mode()
133 err = usb3503_connect(hub); in usb3503_switch_mode()
137 usb3503_reset(hub, 0); in usb3503_switch_mode()
157 static int usb3503_probe(struct usb3503 *hub) in usb3503_probe() argument
159 struct device *dev = hub->dev; in usb3503_probe()
170 hub->port_off_mask = pdata->port_off_mask; in usb3503_probe()
171 hub->mode = pdata->initial_mode; in usb3503_probe()
174 hub->port_off_mask = 0; in usb3503_probe()
182 hub->secondary_ref_clk = 0; in usb3503_probe()
188 hub->secondary_ref_clk = 1; in usb3503_probe()
198 hub->clk = devm_clk_get_optional(dev, "refclk"); in usb3503_probe()
199 if (IS_ERR(hub->clk)) { in usb3503_probe()
201 PTR_ERR(hub->clk)); in usb3503_probe()
202 return PTR_ERR(hub->clk); in usb3503_probe()
206 err = clk_set_rate(hub->clk, rate); in usb3503_probe()
215 err = clk_prepare_enable(hub->clk); in usb3503_probe()
228 hub->port_off_mask |= (1 << port); in usb3503_probe()
233 hub->mode = mode; in usb3503_probe()
236 if (hub->secondary_ref_clk) in usb3503_probe()
240 hub->intn = devm_gpiod_get_optional(dev, "intn", flags); in usb3503_probe()
241 if (IS_ERR(hub->intn)) { in usb3503_probe()
242 err = PTR_ERR(hub->intn); in usb3503_probe()
245 if (hub->intn) in usb3503_probe()
246 gpiod_set_consumer_name(hub->intn, "usb3503 intn"); in usb3503_probe()
248 hub->connect = devm_gpiod_get_optional(dev, "connect", GPIOD_OUT_LOW); in usb3503_probe()
249 if (IS_ERR(hub->connect)) { in usb3503_probe()
250 err = PTR_ERR(hub->connect); in usb3503_probe()
253 if (hub->connect) in usb3503_probe()
254 gpiod_set_consumer_name(hub->connect, "usb3503 connect"); in usb3503_probe()
256 hub->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); in usb3503_probe()
257 if (IS_ERR(hub->reset)) { in usb3503_probe()
258 err = PTR_ERR(hub->reset); in usb3503_probe()
261 if (hub->reset) { in usb3503_probe()
264 gpiod_set_consumer_name(hub->reset, "usb3503 reset"); in usb3503_probe()
267 if (hub->port_off_mask && !hub->regmap) in usb3503_probe()
270 usb3503_switch_mode(hub, hub->mode); in usb3503_probe()
273 (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby"); in usb3503_probe()
279 clk_disable_unprepare(hub->clk); in usb3503_probe()
286 struct usb3503 *hub; in usb3503_i2c_probe() local
289 hub = devm_kzalloc(&i2c->dev, sizeof(struct usb3503), GFP_KERNEL); in usb3503_i2c_probe()
290 if (!hub) in usb3503_i2c_probe()
293 i2c_set_clientdata(i2c, hub); in usb3503_i2c_probe()
294 hub->regmap = devm_regmap_init_i2c(i2c, &usb3503_regmap_config); in usb3503_i2c_probe()
295 if (IS_ERR(hub->regmap)) { in usb3503_i2c_probe()
296 err = PTR_ERR(hub->regmap); in usb3503_i2c_probe()
300 hub->dev = &i2c->dev; in usb3503_i2c_probe()
302 return usb3503_probe(hub); in usb3503_i2c_probe()
307 struct usb3503 *hub; in usb3503_i2c_remove() local
309 hub = i2c_get_clientdata(i2c); in usb3503_i2c_remove()
310 clk_disable_unprepare(hub->clk); in usb3503_i2c_remove()
315 struct usb3503 *hub; in usb3503_platform_probe() local
317 hub = devm_kzalloc(&pdev->dev, sizeof(struct usb3503), GFP_KERNEL); in usb3503_platform_probe()
318 if (!hub) in usb3503_platform_probe()
320 hub->dev = &pdev->dev; in usb3503_platform_probe()
321 platform_set_drvdata(pdev, hub); in usb3503_platform_probe()
323 return usb3503_probe(hub); in usb3503_platform_probe()
328 struct usb3503 *hub; in usb3503_platform_remove() local
330 hub = platform_get_drvdata(pdev); in usb3503_platform_remove()
331 clk_disable_unprepare(hub->clk); in usb3503_platform_remove()
336 static int __maybe_unused usb3503_suspend(struct usb3503 *hub) in usb3503_suspend() argument
338 usb3503_switch_mode(hub, USB3503_MODE_STANDBY); in usb3503_suspend()
339 clk_disable_unprepare(hub->clk); in usb3503_suspend()
344 static int __maybe_unused usb3503_resume(struct usb3503 *hub) in usb3503_resume() argument
346 clk_prepare_enable(hub->clk); in usb3503_resume()
347 usb3503_switch_mode(hub, hub->mode); in usb3503_resume()