Lines Matching +full:self +full:- +full:powered

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (c) 2012-2013 Dongjin Kim (tobetter@gmail.com)
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()
71 /* PDS : Set the ports which are disabled in self-powered mode. */ 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()
82 /* CFG1 : Set SELF_BUS_PWR, this enables self-powered operation. */ 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()
112 struct device *dev = hub->dev; in usb3503_switch_mode()
134 return -EINVAL; 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()
164 struct device *dev = hub->dev; in usb3503_probe()
166 struct device_node *np = dev->of_node; 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()
181 if (!of_property_read_u32(np, "refclk-frequency", &rate)) { in usb3503_probe()
187 hub->secondary_ref_clk = 0; in usb3503_probe()
193 hub->secondary_ref_clk = 1; in usb3503_probe()
199 return -EINVAL; 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()
227 property = of_get_property(np, "disabled-ports", &len); in usb3503_probe()
233 hub->port_off_mask |= (1 << port); in usb3503_probe()
237 of_property_read_u32(np, "initial-mode", &mode); 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()
301 hub = devm_kzalloc(&i2c->dev, sizeof(struct usb3503), GFP_KERNEL); in usb3503_i2c_probe()
303 return -ENOMEM; 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()
309 dev_err(&i2c->dev, "Failed to initialise regmap: %d\n", err); in usb3503_i2c_probe()
312 hub->dev = &i2c->dev; in usb3503_i2c_probe()
322 clk_disable_unprepare(hub->clk); in usb3503_i2c_remove()
329 hub = devm_kzalloc(&pdev->dev, sizeof(struct usb3503), GFP_KERNEL); in usb3503_platform_probe()
331 return -ENOMEM; in usb3503_platform_probe()
332 hub->dev = &pdev->dev; in usb3503_platform_probe()
343 clk_disable_unprepare(hub->clk); in usb3503_platform_remove()
349 clk_disable_unprepare(hub->clk); in usb3503_suspend()
356 clk_prepare_enable(hub->clk); in usb3503_resume()
357 usb3503_switch_mode(hub, hub->mode); in usb3503_resume()