Lines Matching refs:hub
3 * Driver for SMSC USB3503 USB 2.0 hub controller driver
55 static int usb3503_reset(struct usb3503 *hub, int state)
57 if (!state && hub->connect)
58 gpiod_set_value_cansleep(hub->connect, 0);
60 if (hub->reset)
61 gpiod_set_value_cansleep(hub->reset, !state);
63 /* Wait T_HUBINIT == 4ms for hub logic to stabilize */
70 static int usb3503_connect(struct usb3503 *hub)
72 struct device *dev = hub->dev;
75 usb3503_reset(hub, 1);
77 if (hub->regmap) {
79 err = regmap_write(hub->regmap, USB3503_SP_ILOCK,
88 if (hub->port_off_mask) {
89 err = regmap_update_bits(hub->regmap, USB3503_PDS,
90 hub->port_off_mask,
91 hub->port_off_mask);
99 err = regmap_update_bits(hub->regmap, USB3503_CFG1,
107 /* SP_LOCK: clear connect_n, config_n for hub connect */
108 err = regmap_update_bits(hub->regmap, USB3503_SP_ILOCK,
117 if (hub->connect)
118 gpiod_set_value_cansleep(hub->connect, 1);
120 hub->mode = USB3503_MODE_HUB;
126 static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode)
128 struct device *dev = hub->dev;
133 err = usb3503_connect(hub);
137 usb3503_reset(hub, 0);
157 static int usb3503_probe(struct usb3503 *hub)
159 struct device *dev = hub->dev;
169 hub->port_off_mask = pdata->port_off_mask;
170 hub->mode = pdata->initial_mode;
173 hub->port_off_mask = 0;
181 hub->secondary_ref_clk = 0;
187 hub->secondary_ref_clk = 1;
197 hub->clk = devm_clk_get_optional(dev, "refclk");
198 if (IS_ERR(hub->clk)) {
200 PTR_ERR(hub->clk));
201 return PTR_ERR(hub->clk);
205 err = clk_set_rate(hub->clk, rate);
214 err = clk_prepare_enable(hub->clk);
226 hub->port_off_mask |= (1 << port);
231 hub->mode = mode;
234 if (hub->secondary_ref_clk)
238 hub->intn = devm_gpiod_get_optional(dev, "intn", flags);
239 if (IS_ERR(hub->intn))
240 return PTR_ERR(hub->intn);
241 if (hub->intn)
242 gpiod_set_consumer_name(hub->intn, "usb3503 intn");
244 hub->connect = devm_gpiod_get_optional(dev, "connect", GPIOD_OUT_LOW);
245 if (IS_ERR(hub->connect))
246 return PTR_ERR(hub->connect);
247 if (hub->connect)
248 gpiod_set_consumer_name(hub->connect, "usb3503 connect");
250 hub->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
251 if (IS_ERR(hub->reset))
252 return PTR_ERR(hub->reset);
253 if (hub->reset) {
256 gpiod_set_consumer_name(hub->reset, "usb3503 reset");
259 if (hub->port_off_mask && !hub->regmap)
262 usb3503_switch_mode(hub, hub->mode);
265 (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby");
273 struct usb3503 *hub;
276 hub = devm_kzalloc(&i2c->dev, sizeof(struct usb3503), GFP_KERNEL);
277 if (!hub)
280 i2c_set_clientdata(i2c, hub);
281 hub->regmap = devm_regmap_init_i2c(i2c, &usb3503_regmap_config);
282 if (IS_ERR(hub->regmap)) {
283 err = PTR_ERR(hub->regmap);
287 hub->dev = &i2c->dev;
289 return usb3503_probe(hub);
294 struct usb3503 *hub;
296 hub = i2c_get_clientdata(i2c);
297 clk_disable_unprepare(hub->clk);
304 struct usb3503 *hub;
306 hub = devm_kzalloc(&pdev->dev, sizeof(struct usb3503), GFP_KERNEL);
307 if (!hub)
309 hub->dev = &pdev->dev;
310 platform_set_drvdata(pdev, hub);
312 return usb3503_probe(hub);
317 struct usb3503 *hub;
319 hub = platform_get_drvdata(pdev);
320 clk_disable_unprepare(hub->clk);
325 static int __maybe_unused usb3503_suspend(struct usb3503 *hub)
327 usb3503_switch_mode(hub, USB3503_MODE_STANDBY);
328 clk_disable_unprepare(hub->clk);
333 static int __maybe_unused usb3503_resume(struct usb3503 *hub)
335 clk_prepare_enable(hub->clk);
336 usb3503_switch_mode(hub, hub->mode);