Lines Matching refs:hub
56 static int usb3503_connect(struct usb3503 *hub) in usb3503_connect() argument
58 struct device *dev = hub->dev; in usb3503_connect()
61 if (hub->regmap) { in usb3503_connect()
63 err = regmap_write(hub->regmap, USB3503_SP_ILOCK, in usb3503_connect()
72 if (hub->port_off_mask) { in usb3503_connect()
73 err = regmap_update_bits(hub->regmap, USB3503_PDS, in usb3503_connect()
74 hub->port_off_mask, in usb3503_connect()
75 hub->port_off_mask); in usb3503_connect()
83 err = regmap_update_bits(hub->regmap, USB3503_CFG1, in usb3503_connect()
92 err = regmap_update_bits(hub->regmap, USB3503_SP_ILOCK, in usb3503_connect()
101 if (hub->connect) in usb3503_connect()
102 gpiod_set_value_cansleep(hub->connect, 1); in usb3503_connect()
104 hub->mode = USB3503_MODE_HUB; in usb3503_connect()
110 static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode) in usb3503_switch_mode() argument
112 struct device *dev = hub->dev; in usb3503_switch_mode()
137 if (!conn && hub->connect) in usb3503_switch_mode()
138 gpiod_set_value_cansleep(hub->connect, 0); in usb3503_switch_mode()
140 if (hub->reset) in usb3503_switch_mode()
141 gpiod_set_value_cansleep(hub->reset, rst); in usb3503_switch_mode()
143 if (hub->bypass) in usb3503_switch_mode()
144 gpiod_set_value_cansleep(hub->bypass, bypass); in usb3503_switch_mode()
149 return usb3503_connect(hub); in usb3503_switch_mode()
162 static int usb3503_probe(struct usb3503 *hub) in usb3503_probe() argument
164 struct device *dev = hub->dev; in usb3503_probe()
175 hub->port_off_mask = pdata->port_off_mask; in usb3503_probe()
176 hub->mode = pdata->initial_mode; in usb3503_probe()
179 hub->port_off_mask = 0; in usb3503_probe()
187 hub->secondary_ref_clk = 0; in usb3503_probe()
193 hub->secondary_ref_clk = 1; in usb3503_probe()
203 hub->clk = devm_clk_get_optional(dev, "refclk"); in usb3503_probe()
204 if (IS_ERR(hub->clk)) { in usb3503_probe()
206 PTR_ERR(hub->clk)); in usb3503_probe()
207 return PTR_ERR(hub->clk); in usb3503_probe()
211 err = clk_set_rate(hub->clk, rate); in usb3503_probe()
220 err = clk_prepare_enable(hub->clk); in usb3503_probe()
233 hub->port_off_mask |= (1 << port); in usb3503_probe()
238 hub->mode = mode; in usb3503_probe()
241 if (hub->secondary_ref_clk) in usb3503_probe()
245 hub->intn = devm_gpiod_get_optional(dev, "intn", flags); in usb3503_probe()
246 if (IS_ERR(hub->intn)) { in usb3503_probe()
247 err = PTR_ERR(hub->intn); in usb3503_probe()
250 if (hub->intn) in usb3503_probe()
251 gpiod_set_consumer_name(hub->intn, "usb3503 intn"); in usb3503_probe()
253 hub->connect = devm_gpiod_get_optional(dev, "connect", GPIOD_OUT_LOW); in usb3503_probe()
254 if (IS_ERR(hub->connect)) { in usb3503_probe()
255 err = PTR_ERR(hub->connect); in usb3503_probe()
258 if (hub->connect) in usb3503_probe()
259 gpiod_set_consumer_name(hub->connect, "usb3503 connect"); in usb3503_probe()
261 hub->bypass = devm_gpiod_get_optional(dev, "bypass", GPIOD_OUT_HIGH); in usb3503_probe()
262 if (IS_ERR(hub->bypass)) { in usb3503_probe()
263 err = PTR_ERR(hub->bypass); in usb3503_probe()
266 if (hub->bypass) in usb3503_probe()
267 gpiod_set_consumer_name(hub->bypass, "usb3503 bypass"); in usb3503_probe()
269 hub->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); in usb3503_probe()
270 if (IS_ERR(hub->reset)) { in usb3503_probe()
271 err = PTR_ERR(hub->reset); in usb3503_probe()
274 if (hub->reset) { in usb3503_probe()
277 gpiod_set_consumer_name(hub->reset, "usb3503 reset"); in usb3503_probe()
280 if (hub->port_off_mask && !hub->regmap) in usb3503_probe()
283 usb3503_switch_mode(hub, hub->mode); in usb3503_probe()
286 (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby"); in usb3503_probe()
292 clk_disable_unprepare(hub->clk); in usb3503_probe()
298 struct usb3503 *hub; in usb3503_i2c_probe() local
301 hub = devm_kzalloc(&i2c->dev, sizeof(struct usb3503), GFP_KERNEL); in usb3503_i2c_probe()
302 if (!hub) in usb3503_i2c_probe()
305 i2c_set_clientdata(i2c, hub); in usb3503_i2c_probe()
306 hub->regmap = devm_regmap_init_i2c(i2c, &usb3503_regmap_config); in usb3503_i2c_probe()
307 if (IS_ERR(hub->regmap)) { in usb3503_i2c_probe()
308 err = PTR_ERR(hub->regmap); in usb3503_i2c_probe()
312 hub->dev = &i2c->dev; in usb3503_i2c_probe()
314 return usb3503_probe(hub); in usb3503_i2c_probe()
319 struct usb3503 *hub; in usb3503_i2c_remove() local
321 hub = i2c_get_clientdata(i2c); in usb3503_i2c_remove()
322 clk_disable_unprepare(hub->clk); in usb3503_i2c_remove()
327 struct usb3503 *hub; in usb3503_platform_probe() local
329 hub = devm_kzalloc(&pdev->dev, sizeof(struct usb3503), GFP_KERNEL); in usb3503_platform_probe()
330 if (!hub) in usb3503_platform_probe()
332 hub->dev = &pdev->dev; in usb3503_platform_probe()
333 platform_set_drvdata(pdev, hub); in usb3503_platform_probe()
335 return usb3503_probe(hub); in usb3503_platform_probe()
340 struct usb3503 *hub; in usb3503_platform_remove() local
342 hub = platform_get_drvdata(pdev); in usb3503_platform_remove()
343 clk_disable_unprepare(hub->clk); in usb3503_platform_remove()
346 static int __maybe_unused usb3503_suspend(struct usb3503 *hub) in usb3503_suspend() argument
348 usb3503_switch_mode(hub, USB3503_MODE_STANDBY); in usb3503_suspend()
349 clk_disable_unprepare(hub->clk); in usb3503_suspend()
354 static int __maybe_unused usb3503_resume(struct usb3503 *hub) in usb3503_resume() argument
356 clk_prepare_enable(hub->clk); in usb3503_resume()
357 usb3503_switch_mode(hub, hub->mode); in usb3503_resume()