Lines Matching full:driver
77 struct ns2_phy_driver *driver; member
89 struct ns2_phy_driver *driver) in pll_lock_stat() argument
93 return readl_poll_timeout_atomic(driver->icfgdrd_regs + usb_reg, in pll_lock_stat()
101 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_init() local
104 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_init()
113 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_init()
121 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_poweroff() local
124 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
126 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
128 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
130 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
133 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_poweroff()
135 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_poweroff()
143 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_poweron() local
149 writel(DRD_DEV_VAL, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in ns2_drd_phy_poweron()
151 val = readl(driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
153 writel(val, driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
155 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
157 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
160 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
162 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
164 ret = pll_lock_stat(ICFG_MISC_STAT, PHY_PLL_LOCK, driver); in ns2_drd_phy_poweron()
170 writel(DRD_HOST_VAL, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in ns2_drd_phy_poweron()
172 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
174 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
176 ret = pll_lock_stat(ICFG_MISC_STAT, PHY_PLL_LOCK, driver); in ns2_drd_phy_poweron()
182 val = readl(driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
184 writel(val, driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
187 val = readl(driver->usb2h_strap_reg); in ns2_drd_phy_poweron()
189 writel(val, driver->usb2h_strap_reg); in ns2_drd_phy_poweron()
195 static void connect_change(struct ns2_phy_driver *driver) in connect_change() argument
200 extcon_event = driver->data->new_state; in connect_change()
201 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
206 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
209 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
211 val = readl(driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
213 writel(val, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
218 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
221 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
223 val = readl(driver->usb2h_strap_reg); in connect_change()
225 writel(val, driver->usb2h_strap_reg); in connect_change()
227 val = readl(driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
229 writel(val, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
240 struct ns2_phy_driver *driver; in extcon_work() local
244 driver = container_of(to_delayed_work(work), in extcon_work()
247 id = gpiod_get_value_cansleep(driver->id_gpiod); in extcon_work()
248 vbus = gpiod_get_value_cansleep(driver->vbus_gpiod); in extcon_work()
251 extcon_set_state_sync(driver->edev, EXTCON_USB_HOST, true); in extcon_work()
253 driver->data->new_state = EVT_HOST; in extcon_work()
254 connect_change(driver); in extcon_work()
256 extcon_set_state_sync(driver->edev, EXTCON_USB_HOST, false); in extcon_work()
257 extcon_set_state_sync(driver->edev, EXTCON_USB, false); in extcon_work()
260 extcon_set_state_sync(driver->edev, EXTCON_USB, true); in extcon_work()
262 driver->data->new_state = EVT_DEVICE; in extcon_work()
263 connect_change(driver); in extcon_work()
269 struct ns2_phy_driver *driver = dev_id; in gpio_irq_handler() local
271 queue_delayed_work(system_power_efficient_wq, &driver->wq_extcon, in gpio_irq_handler()
272 driver->debounce_jiffies); in gpio_irq_handler()
294 struct ns2_phy_driver *driver; in ns2_drd_phy_probe() local
300 driver = devm_kzalloc(dev, sizeof(struct ns2_phy_driver), in ns2_drd_phy_probe()
302 if (!driver) in ns2_drd_phy_probe()
305 driver->data = devm_kzalloc(dev, sizeof(struct ns2_phy_data), in ns2_drd_phy_probe()
307 if (!driver->data) in ns2_drd_phy_probe()
311 driver->icfgdrd_regs = devm_ioremap_resource(dev, res); in ns2_drd_phy_probe()
312 if (IS_ERR(driver->icfgdrd_regs)) in ns2_drd_phy_probe()
313 return PTR_ERR(driver->icfgdrd_regs); in ns2_drd_phy_probe()
316 driver->idmdrd_rst_ctrl = devm_ioremap_resource(dev, res); in ns2_drd_phy_probe()
317 if (IS_ERR(driver->idmdrd_rst_ctrl)) in ns2_drd_phy_probe()
318 return PTR_ERR(driver->idmdrd_rst_ctrl); in ns2_drd_phy_probe()
321 driver->crmu_usb2_ctrl = devm_ioremap_resource(dev, res); in ns2_drd_phy_probe()
322 if (IS_ERR(driver->crmu_usb2_ctrl)) in ns2_drd_phy_probe()
323 return PTR_ERR(driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
326 driver->usb2h_strap_reg = devm_ioremap_resource(dev, res); in ns2_drd_phy_probe()
327 if (IS_ERR(driver->usb2h_strap_reg)) in ns2_drd_phy_probe()
328 return PTR_ERR(driver->usb2h_strap_reg); in ns2_drd_phy_probe()
331 driver->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN); in ns2_drd_phy_probe()
332 if (IS_ERR(driver->id_gpiod)) { in ns2_drd_phy_probe()
334 return PTR_ERR(driver->id_gpiod); in ns2_drd_phy_probe()
336 driver->vbus_gpiod = devm_gpiod_get(&pdev->dev, "vbus", GPIOD_IN); in ns2_drd_phy_probe()
337 if (IS_ERR(driver->vbus_gpiod)) { in ns2_drd_phy_probe()
339 return PTR_ERR(driver->vbus_gpiod); in ns2_drd_phy_probe()
342 driver->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); in ns2_drd_phy_probe()
343 if (IS_ERR(driver->edev)) { in ns2_drd_phy_probe()
348 ret = devm_extcon_dev_register(dev, driver->edev); in ns2_drd_phy_probe()
354 ret = gpiod_set_debounce(driver->id_gpiod, GPIO_DELAY * 1000); in ns2_drd_phy_probe()
356 driver->debounce_jiffies = msecs_to_jiffies(GPIO_DELAY); in ns2_drd_phy_probe()
358 INIT_DELAYED_WORK(&driver->wq_extcon, extcon_work); in ns2_drd_phy_probe()
360 driver->id_irq = gpiod_to_irq(driver->id_gpiod); in ns2_drd_phy_probe()
361 if (driver->id_irq < 0) { in ns2_drd_phy_probe()
363 return driver->id_irq; in ns2_drd_phy_probe()
366 driver->vbus_irq = gpiod_to_irq(driver->vbus_gpiod); in ns2_drd_phy_probe()
367 if (driver->vbus_irq < 0) { in ns2_drd_phy_probe()
369 return driver->vbus_irq; in ns2_drd_phy_probe()
372 ret = devm_request_irq(dev, driver->id_irq, gpio_irq_handler, in ns2_drd_phy_probe()
374 "usb_id", driver); in ns2_drd_phy_probe()
380 ret = devm_request_irq(dev, driver->vbus_irq, gpio_irq_handler, in ns2_drd_phy_probe()
382 "usb_vbus", driver); in ns2_drd_phy_probe()
388 dev_set_drvdata(dev, driver); in ns2_drd_phy_probe()
391 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
393 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
395 data = driver->data; in ns2_drd_phy_probe()
402 data->driver = driver; in ns2_drd_phy_probe()
411 platform_set_drvdata(pdev, driver); in ns2_drd_phy_probe()
414 queue_delayed_work(system_power_efficient_wq, &driver->wq_extcon, in ns2_drd_phy_probe()
415 driver->debounce_jiffies); in ns2_drd_phy_probe()
422 .driver = {
431 MODULE_DESCRIPTION("Broadcom NS2 USB2 PHY driver");