Lines Matching full:driver
76 struct ns2_phy_driver *driver; member
88 struct ns2_phy_driver *driver) in pll_lock_stat() argument
95 val = readl(driver->icfgdrd_regs + usb_reg); in pll_lock_stat()
106 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_init() local
109 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_init()
118 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_init()
126 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_poweroff() local
129 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
131 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
133 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
135 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
138 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_poweroff()
140 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_poweroff()
148 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_poweron() local
154 writel(DRD_DEV_VAL, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in ns2_drd_phy_poweron()
156 val = readl(driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
158 writel(val, driver->idmdrd_rst_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()
165 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
167 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
169 ret = pll_lock_stat(ICFG_MISC_STAT, PHY_PLL_LOCK, driver); in ns2_drd_phy_poweron()
175 writel(DRD_HOST_VAL, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in ns2_drd_phy_poweron()
177 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
179 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
181 ret = pll_lock_stat(ICFG_MISC_STAT, PHY_PLL_LOCK, driver); in ns2_drd_phy_poweron()
187 val = readl(driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
189 writel(val, driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
192 val = readl(driver->usb2h_strap_reg); in ns2_drd_phy_poweron()
194 writel(val, driver->usb2h_strap_reg); in ns2_drd_phy_poweron()
200 static void connect_change(struct ns2_phy_driver *driver) in connect_change() argument
205 extcon_event = driver->data->new_state; in connect_change()
206 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
211 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
214 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
216 val = readl(driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
218 writel(val, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
223 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
226 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
228 val = readl(driver->usb2h_strap_reg); in connect_change()
230 writel(val, driver->usb2h_strap_reg); in connect_change()
232 val = readl(driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
234 writel(val, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
245 struct ns2_phy_driver *driver; in extcon_work() local
249 driver = container_of(to_delayed_work(work), in extcon_work()
252 id = gpiod_get_value_cansleep(driver->id_gpiod); in extcon_work()
253 vbus = gpiod_get_value_cansleep(driver->vbus_gpiod); in extcon_work()
256 extcon_set_state_sync(driver->edev, EXTCON_USB_HOST, true); in extcon_work()
258 driver->data->new_state = EVT_HOST; in extcon_work()
259 connect_change(driver); in extcon_work()
261 extcon_set_state_sync(driver->edev, EXTCON_USB_HOST, false); in extcon_work()
262 extcon_set_state_sync(driver->edev, EXTCON_USB, false); in extcon_work()
265 extcon_set_state_sync(driver->edev, EXTCON_USB, true); in extcon_work()
267 driver->data->new_state = EVT_DEVICE; in extcon_work()
268 connect_change(driver); in extcon_work()
274 struct ns2_phy_driver *driver = dev_id; in gpio_irq_handler() local
276 queue_delayed_work(system_power_efficient_wq, &driver->wq_extcon, in gpio_irq_handler()
277 driver->debounce_jiffies); in gpio_irq_handler()
299 struct ns2_phy_driver *driver; in ns2_drd_phy_probe() local
305 driver = devm_kzalloc(dev, sizeof(struct ns2_phy_driver), in ns2_drd_phy_probe()
307 if (!driver) in ns2_drd_phy_probe()
310 driver->data = devm_kzalloc(dev, sizeof(struct ns2_phy_data), in ns2_drd_phy_probe()
312 if (!driver->data) in ns2_drd_phy_probe()
316 driver->icfgdrd_regs = devm_ioremap_resource(dev, res); in ns2_drd_phy_probe()
317 if (IS_ERR(driver->icfgdrd_regs)) in ns2_drd_phy_probe()
318 return PTR_ERR(driver->icfgdrd_regs); in ns2_drd_phy_probe()
321 driver->idmdrd_rst_ctrl = devm_ioremap_resource(dev, res); in ns2_drd_phy_probe()
322 if (IS_ERR(driver->idmdrd_rst_ctrl)) in ns2_drd_phy_probe()
323 return PTR_ERR(driver->idmdrd_rst_ctrl); in ns2_drd_phy_probe()
326 driver->crmu_usb2_ctrl = devm_ioremap_resource(dev, res); in ns2_drd_phy_probe()
327 if (IS_ERR(driver->crmu_usb2_ctrl)) in ns2_drd_phy_probe()
328 return PTR_ERR(driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
331 driver->usb2h_strap_reg = devm_ioremap_resource(dev, res); in ns2_drd_phy_probe()
332 if (IS_ERR(driver->usb2h_strap_reg)) in ns2_drd_phy_probe()
333 return PTR_ERR(driver->usb2h_strap_reg); in ns2_drd_phy_probe()
336 driver->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN); in ns2_drd_phy_probe()
337 if (IS_ERR(driver->id_gpiod)) { in ns2_drd_phy_probe()
339 return PTR_ERR(driver->id_gpiod); in ns2_drd_phy_probe()
341 driver->vbus_gpiod = devm_gpiod_get(&pdev->dev, "vbus", GPIOD_IN); in ns2_drd_phy_probe()
342 if (IS_ERR(driver->vbus_gpiod)) { in ns2_drd_phy_probe()
344 return PTR_ERR(driver->vbus_gpiod); in ns2_drd_phy_probe()
347 driver->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); in ns2_drd_phy_probe()
348 if (IS_ERR(driver->edev)) { in ns2_drd_phy_probe()
353 ret = devm_extcon_dev_register(dev, driver->edev); in ns2_drd_phy_probe()
359 ret = gpiod_set_debounce(driver->id_gpiod, GPIO_DELAY * 1000); in ns2_drd_phy_probe()
361 driver->debounce_jiffies = msecs_to_jiffies(GPIO_DELAY); in ns2_drd_phy_probe()
363 INIT_DELAYED_WORK(&driver->wq_extcon, extcon_work); in ns2_drd_phy_probe()
365 driver->id_irq = gpiod_to_irq(driver->id_gpiod); in ns2_drd_phy_probe()
366 if (driver->id_irq < 0) { in ns2_drd_phy_probe()
368 return driver->id_irq; in ns2_drd_phy_probe()
371 driver->vbus_irq = gpiod_to_irq(driver->vbus_gpiod); in ns2_drd_phy_probe()
372 if (driver->vbus_irq < 0) { in ns2_drd_phy_probe()
374 return driver->vbus_irq; in ns2_drd_phy_probe()
377 ret = devm_request_irq(dev, driver->id_irq, gpio_irq_handler, in ns2_drd_phy_probe()
379 "usb_id", driver); in ns2_drd_phy_probe()
385 ret = devm_request_irq(dev, driver->vbus_irq, gpio_irq_handler, in ns2_drd_phy_probe()
387 "usb_vbus", driver); in ns2_drd_phy_probe()
393 dev_set_drvdata(dev, driver); in ns2_drd_phy_probe()
396 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
398 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
400 data = driver->data; in ns2_drd_phy_probe()
407 data->driver = driver; in ns2_drd_phy_probe()
416 platform_set_drvdata(pdev, driver); in ns2_drd_phy_probe()
419 queue_delayed_work(system_power_efficient_wq, &driver->wq_extcon, in ns2_drd_phy_probe()
420 driver->debounce_jiffies); in ns2_drd_phy_probe()
427 .driver = {
436 MODULE_DESCRIPTION("Broadcom NS2 USB2 PHY driver");