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
299 driver = devm_kzalloc(dev, sizeof(struct ns2_phy_driver), in ns2_drd_phy_probe()
301 if (!driver) in ns2_drd_phy_probe()
304 driver->data = devm_kzalloc(dev, sizeof(struct ns2_phy_data), in ns2_drd_phy_probe()
306 if (!driver->data) in ns2_drd_phy_probe()
309 driver->icfgdrd_regs = devm_platform_ioremap_resource_byname(pdev, "icfg"); in ns2_drd_phy_probe()
310 if (IS_ERR(driver->icfgdrd_regs)) in ns2_drd_phy_probe()
311 return PTR_ERR(driver->icfgdrd_regs); in ns2_drd_phy_probe()
313 driver->idmdrd_rst_ctrl = devm_platform_ioremap_resource_byname(pdev, "rst-ctrl"); in ns2_drd_phy_probe()
314 if (IS_ERR(driver->idmdrd_rst_ctrl)) in ns2_drd_phy_probe()
315 return PTR_ERR(driver->idmdrd_rst_ctrl); in ns2_drd_phy_probe()
317 driver->crmu_usb2_ctrl = devm_platform_ioremap_resource_byname(pdev, "crmu-ctrl"); in ns2_drd_phy_probe()
318 if (IS_ERR(driver->crmu_usb2_ctrl)) in ns2_drd_phy_probe()
319 return PTR_ERR(driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
321 driver->usb2h_strap_reg = devm_platform_ioremap_resource_byname(pdev, "usb2-strap"); in ns2_drd_phy_probe()
322 if (IS_ERR(driver->usb2h_strap_reg)) in ns2_drd_phy_probe()
323 return PTR_ERR(driver->usb2h_strap_reg); in ns2_drd_phy_probe()
326 driver->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN); in ns2_drd_phy_probe()
327 if (IS_ERR(driver->id_gpiod)) { in ns2_drd_phy_probe()
329 return PTR_ERR(driver->id_gpiod); in ns2_drd_phy_probe()
331 driver->vbus_gpiod = devm_gpiod_get(&pdev->dev, "vbus", GPIOD_IN); in ns2_drd_phy_probe()
332 if (IS_ERR(driver->vbus_gpiod)) { in ns2_drd_phy_probe()
334 return PTR_ERR(driver->vbus_gpiod); in ns2_drd_phy_probe()
337 driver->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); in ns2_drd_phy_probe()
338 if (IS_ERR(driver->edev)) { in ns2_drd_phy_probe()
343 ret = devm_extcon_dev_register(dev, driver->edev); in ns2_drd_phy_probe()
349 ret = gpiod_set_debounce(driver->id_gpiod, GPIO_DELAY * 1000); in ns2_drd_phy_probe()
351 driver->debounce_jiffies = msecs_to_jiffies(GPIO_DELAY); in ns2_drd_phy_probe()
353 INIT_DELAYED_WORK(&driver->wq_extcon, extcon_work); in ns2_drd_phy_probe()
355 driver->id_irq = gpiod_to_irq(driver->id_gpiod); in ns2_drd_phy_probe()
356 if (driver->id_irq < 0) { in ns2_drd_phy_probe()
358 return driver->id_irq; in ns2_drd_phy_probe()
361 driver->vbus_irq = gpiod_to_irq(driver->vbus_gpiod); in ns2_drd_phy_probe()
362 if (driver->vbus_irq < 0) { in ns2_drd_phy_probe()
364 return driver->vbus_irq; in ns2_drd_phy_probe()
367 ret = devm_request_irq(dev, driver->id_irq, gpio_irq_handler, in ns2_drd_phy_probe()
369 "usb_id", driver); in ns2_drd_phy_probe()
375 ret = devm_request_irq(dev, driver->vbus_irq, gpio_irq_handler, in ns2_drd_phy_probe()
377 "usb_vbus", driver); in ns2_drd_phy_probe()
383 dev_set_drvdata(dev, driver); in ns2_drd_phy_probe()
386 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
388 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
390 data = driver->data; in ns2_drd_phy_probe()
397 data->driver = driver; in ns2_drd_phy_probe()
406 platform_set_drvdata(pdev, driver); in ns2_drd_phy_probe()
409 queue_delayed_work(system_power_efficient_wq, &driver->wq_extcon, in ns2_drd_phy_probe()
410 driver->debounce_jiffies); in ns2_drd_phy_probe()
417 .driver = {
426 MODULE_DESCRIPTION("Broadcom NS2 USB2 PHY driver");