Lines Matching refs:driver
67 struct ns2_phy_driver *driver; member
79 struct ns2_phy_driver *driver) in pll_lock_stat() argument
83 return readl_poll_timeout_atomic(driver->icfgdrd_regs + usb_reg, in pll_lock_stat()
91 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_init() local
94 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_init()
103 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_init()
111 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_poweroff() local
114 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
116 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
118 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
120 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweroff()
123 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_poweroff()
125 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in ns2_drd_phy_poweroff()
133 struct ns2_phy_driver *driver = data->driver; in ns2_drd_phy_poweron() local
139 writel(DRD_DEV_VAL, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in ns2_drd_phy_poweron()
141 val = readl(driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
143 writel(val, driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
145 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
147 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
150 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
152 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
154 ret = pll_lock_stat(ICFG_MISC_STAT, PHY_PLL_LOCK, driver); in ns2_drd_phy_poweron()
160 writel(DRD_HOST_VAL, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in ns2_drd_phy_poweron()
162 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
164 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_poweron()
166 ret = pll_lock_stat(ICFG_MISC_STAT, PHY_PLL_LOCK, driver); in ns2_drd_phy_poweron()
172 val = readl(driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
174 writel(val, driver->idmdrd_rst_ctrl); in ns2_drd_phy_poweron()
177 val = readl(driver->usb2h_strap_reg); in ns2_drd_phy_poweron()
179 writel(val, driver->usb2h_strap_reg); in ns2_drd_phy_poweron()
185 static void connect_change(struct ns2_phy_driver *driver) in connect_change() argument
190 extcon_event = driver->data->new_state; in connect_change()
191 val = readl(driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
196 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
199 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
201 val = readl(driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
203 writel(val, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
208 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
211 writel(val, driver->icfgdrd_regs + ICFG_FSM_CTRL); in connect_change()
213 val = readl(driver->usb2h_strap_reg); in connect_change()
215 writel(val, driver->usb2h_strap_reg); in connect_change()
217 val = readl(driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
219 writel(val, driver->icfgdrd_regs + ICFG_DRD_P0CTL); in connect_change()
230 struct ns2_phy_driver *driver; in extcon_work() local
234 driver = container_of(to_delayed_work(work), in extcon_work()
237 id = gpiod_get_value_cansleep(driver->id_gpiod); in extcon_work()
238 vbus = gpiod_get_value_cansleep(driver->vbus_gpiod); in extcon_work()
241 extcon_set_state_sync(driver->edev, EXTCON_USB_HOST, true); in extcon_work()
243 driver->data->new_state = EVT_HOST; in extcon_work()
244 connect_change(driver); in extcon_work()
246 extcon_set_state_sync(driver->edev, EXTCON_USB_HOST, false); in extcon_work()
247 extcon_set_state_sync(driver->edev, EXTCON_USB, false); in extcon_work()
250 extcon_set_state_sync(driver->edev, EXTCON_USB, true); in extcon_work()
252 driver->data->new_state = EVT_DEVICE; in extcon_work()
253 connect_change(driver); in extcon_work()
259 struct ns2_phy_driver *driver = dev_id; in gpio_irq_handler() local
261 queue_delayed_work(system_power_efficient_wq, &driver->wq_extcon, in gpio_irq_handler()
262 driver->debounce_jiffies); in gpio_irq_handler()
284 struct ns2_phy_driver *driver; in ns2_drd_phy_probe() local
289 driver = devm_kzalloc(dev, sizeof(struct ns2_phy_driver), in ns2_drd_phy_probe()
291 if (!driver) in ns2_drd_phy_probe()
294 driver->data = devm_kzalloc(dev, sizeof(struct ns2_phy_data), in ns2_drd_phy_probe()
296 if (!driver->data) in ns2_drd_phy_probe()
299 driver->icfgdrd_regs = devm_platform_ioremap_resource_byname(pdev, "icfg"); in ns2_drd_phy_probe()
300 if (IS_ERR(driver->icfgdrd_regs)) in ns2_drd_phy_probe()
301 return PTR_ERR(driver->icfgdrd_regs); in ns2_drd_phy_probe()
303 driver->idmdrd_rst_ctrl = devm_platform_ioremap_resource_byname(pdev, "rst-ctrl"); in ns2_drd_phy_probe()
304 if (IS_ERR(driver->idmdrd_rst_ctrl)) in ns2_drd_phy_probe()
305 return PTR_ERR(driver->idmdrd_rst_ctrl); in ns2_drd_phy_probe()
307 driver->crmu_usb2_ctrl = devm_platform_ioremap_resource_byname(pdev, "crmu-ctrl"); in ns2_drd_phy_probe()
308 if (IS_ERR(driver->crmu_usb2_ctrl)) in ns2_drd_phy_probe()
309 return PTR_ERR(driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
311 driver->usb2h_strap_reg = devm_platform_ioremap_resource_byname(pdev, "usb2-strap"); in ns2_drd_phy_probe()
312 if (IS_ERR(driver->usb2h_strap_reg)) in ns2_drd_phy_probe()
313 return PTR_ERR(driver->usb2h_strap_reg); in ns2_drd_phy_probe()
316 driver->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN); in ns2_drd_phy_probe()
317 if (IS_ERR(driver->id_gpiod)) { in ns2_drd_phy_probe()
319 return PTR_ERR(driver->id_gpiod); in ns2_drd_phy_probe()
321 driver->vbus_gpiod = devm_gpiod_get(&pdev->dev, "vbus", GPIOD_IN); in ns2_drd_phy_probe()
322 if (IS_ERR(driver->vbus_gpiod)) { in ns2_drd_phy_probe()
324 return PTR_ERR(driver->vbus_gpiod); in ns2_drd_phy_probe()
327 driver->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); in ns2_drd_phy_probe()
328 if (IS_ERR(driver->edev)) { in ns2_drd_phy_probe()
333 ret = devm_extcon_dev_register(dev, driver->edev); in ns2_drd_phy_probe()
339 ret = gpiod_set_debounce(driver->id_gpiod, GPIO_DELAY * 1000); in ns2_drd_phy_probe()
341 driver->debounce_jiffies = msecs_to_jiffies(GPIO_DELAY); in ns2_drd_phy_probe()
343 INIT_DELAYED_WORK(&driver->wq_extcon, extcon_work); in ns2_drd_phy_probe()
345 driver->id_irq = gpiod_to_irq(driver->id_gpiod); in ns2_drd_phy_probe()
346 if (driver->id_irq < 0) { in ns2_drd_phy_probe()
348 return driver->id_irq; in ns2_drd_phy_probe()
351 driver->vbus_irq = gpiod_to_irq(driver->vbus_gpiod); in ns2_drd_phy_probe()
352 if (driver->vbus_irq < 0) { in ns2_drd_phy_probe()
354 return driver->vbus_irq; in ns2_drd_phy_probe()
357 ret = devm_request_irq(dev, driver->id_irq, gpio_irq_handler, in ns2_drd_phy_probe()
359 "usb_id", driver); in ns2_drd_phy_probe()
365 ret = devm_request_irq(dev, driver->vbus_irq, gpio_irq_handler, in ns2_drd_phy_probe()
367 "usb_vbus", driver); in ns2_drd_phy_probe()
373 dev_set_drvdata(dev, driver); in ns2_drd_phy_probe()
376 val = readl(driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
378 writel(val, driver->crmu_usb2_ctrl); in ns2_drd_phy_probe()
380 data = driver->data; in ns2_drd_phy_probe()
387 data->driver = driver; in ns2_drd_phy_probe()
396 platform_set_drvdata(pdev, driver); in ns2_drd_phy_probe()
399 queue_delayed_work(system_power_efficient_wq, &driver->wq_extcon, in ns2_drd_phy_probe()
400 driver->debounce_jiffies); in ns2_drd_phy_probe()
407 .driver = {