Lines Matching refs:palmas_usb

43 	struct palmas_usb *palmas_usb = _palmas_usb;  in palmas_vbus_irq_handler()  local
44 struct extcon_dev *edev = palmas_usb->edev; in palmas_vbus_irq_handler()
47 palmas_read(palmas_usb->palmas, PALMAS_INTERRUPT_BASE, in palmas_vbus_irq_handler()
51 if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) { in palmas_vbus_irq_handler()
52 palmas_usb->linkstat = PALMAS_USB_STATE_VBUS; in palmas_vbus_irq_handler()
54 dev_dbg(palmas_usb->dev, "USB cable is attached\n"); in palmas_vbus_irq_handler()
56 dev_dbg(palmas_usb->dev, in palmas_vbus_irq_handler()
60 if (palmas_usb->linkstat == PALMAS_USB_STATE_VBUS) { in palmas_vbus_irq_handler()
61 palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; in palmas_vbus_irq_handler()
63 dev_dbg(palmas_usb->dev, "USB cable is detached\n"); in palmas_vbus_irq_handler()
65 dev_dbg(palmas_usb->dev, in palmas_vbus_irq_handler()
76 struct palmas_usb *palmas_usb = _palmas_usb; in palmas_id_irq_handler() local
77 struct extcon_dev *edev = palmas_usb->edev; in palmas_id_irq_handler()
79 palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE, in palmas_id_irq_handler()
81 palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE, in palmas_id_irq_handler()
86 palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, in palmas_id_irq_handler()
89 palmas_usb->linkstat = PALMAS_USB_STATE_ID; in palmas_id_irq_handler()
91 dev_dbg(palmas_usb->dev, "USB-HOST cable is attached\n"); in palmas_id_irq_handler()
94 palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, in palmas_id_irq_handler()
97 palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; in palmas_id_irq_handler()
99 dev_dbg(palmas_usb->dev, "USB-HOST cable is detached\n"); in palmas_id_irq_handler()
100 } else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) && in palmas_id_irq_handler()
102 palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; in palmas_id_irq_handler()
104 dev_dbg(palmas_usb->dev, "USB-HOST cable is detached\n"); in palmas_id_irq_handler()
105 } else if ((palmas_usb->linkstat == PALMAS_USB_STATE_DISCONNECT) && in palmas_id_irq_handler()
107 palmas_usb->linkstat = PALMAS_USB_STATE_ID; in palmas_id_irq_handler()
109 dev_dbg(palmas_usb->dev, "USB-HOST cable is attached\n"); in palmas_id_irq_handler()
118 struct palmas_usb *palmas_usb = container_of(to_delayed_work(work), in palmas_gpio_id_detect() local
119 struct palmas_usb, in palmas_gpio_id_detect()
121 struct extcon_dev *edev = palmas_usb->edev; in palmas_gpio_id_detect()
123 if (!palmas_usb->id_gpiod) in palmas_gpio_id_detect()
126 id = gpiod_get_value_cansleep(palmas_usb->id_gpiod); in palmas_gpio_id_detect()
130 dev_dbg(palmas_usb->dev, "USB-HOST cable is detached\n"); in palmas_gpio_id_detect()
133 dev_dbg(palmas_usb->dev, "USB-HOST cable is attached\n"); in palmas_gpio_id_detect()
139 struct palmas_usb *palmas_usb = _palmas_usb; in palmas_gpio_id_irq_handler() local
141 queue_delayed_work(system_power_efficient_wq, &palmas_usb->wq_detectid, in palmas_gpio_id_irq_handler()
142 palmas_usb->sw_debounce_jiffies); in palmas_gpio_id_irq_handler()
147 static void palmas_enable_irq(struct palmas_usb *palmas_usb) in palmas_enable_irq() argument
149 palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, in palmas_enable_irq()
153 if (palmas_usb->enable_id_detection) { in palmas_enable_irq()
154 palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, in palmas_enable_irq()
158 palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, in palmas_enable_irq()
164 if (palmas_usb->enable_vbus_detection) in palmas_enable_irq()
165 palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb); in palmas_enable_irq()
168 if (palmas_usb->enable_id_detection) { in palmas_enable_irq()
170 palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb); in palmas_enable_irq()
179 struct palmas_usb *palmas_usb; in palmas_usb_probe() local
187 palmas_usb = devm_kzalloc(&pdev->dev, sizeof(*palmas_usb), GFP_KERNEL); in palmas_usb_probe()
188 if (!palmas_usb) in palmas_usb_probe()
192 palmas_usb->wakeup = of_property_read_bool(node, "ti,wakeup"); in palmas_usb_probe()
193 palmas_usb->enable_id_detection = of_property_read_bool(node, in palmas_usb_probe()
195 palmas_usb->enable_vbus_detection = of_property_read_bool(node, in palmas_usb_probe()
198 palmas_usb->wakeup = true; in palmas_usb_probe()
199 palmas_usb->enable_id_detection = true; in palmas_usb_probe()
200 palmas_usb->enable_vbus_detection = true; in palmas_usb_probe()
203 palmas_usb->wakeup = pdata->wakeup; in palmas_usb_probe()
206 palmas_usb->id_gpiod = devm_gpiod_get_optional(&pdev->dev, "id", in palmas_usb_probe()
208 if (IS_ERR(palmas_usb->id_gpiod)) in palmas_usb_probe()
209 return dev_err_probe(&pdev->dev, PTR_ERR(palmas_usb->id_gpiod), in palmas_usb_probe()
212 palmas_usb->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus", in palmas_usb_probe()
214 if (IS_ERR(palmas_usb->vbus_gpiod)) in palmas_usb_probe()
215 return dev_err_probe(&pdev->dev, PTR_ERR(palmas_usb->vbus_gpiod), in palmas_usb_probe()
218 if (palmas_usb->enable_id_detection && palmas_usb->id_gpiod) { in palmas_usb_probe()
219 palmas_usb->enable_id_detection = false; in palmas_usb_probe()
220 palmas_usb->enable_gpio_id_detection = true; in palmas_usb_probe()
223 if (palmas_usb->enable_vbus_detection && palmas_usb->vbus_gpiod) { in palmas_usb_probe()
224 palmas_usb->enable_vbus_detection = false; in palmas_usb_probe()
225 palmas_usb->enable_gpio_vbus_detection = true; in palmas_usb_probe()
228 if (palmas_usb->enable_gpio_id_detection) { in palmas_usb_probe()
234 status = gpiod_set_debounce(palmas_usb->id_gpiod, in palmas_usb_probe()
237 palmas_usb->sw_debounce_jiffies = msecs_to_jiffies(debounce); in palmas_usb_probe()
241 &palmas_usb->wq_detectid, in palmas_usb_probe()
246 palmas->usb = palmas_usb; in palmas_usb_probe()
247 palmas_usb->palmas = palmas; in palmas_usb_probe()
249 palmas_usb->dev = &pdev->dev; in palmas_usb_probe()
251 palmas_usb_wakeup(palmas, palmas_usb->wakeup); in palmas_usb_probe()
253 platform_set_drvdata(pdev, palmas_usb); in palmas_usb_probe()
255 palmas_usb->edev = devm_extcon_dev_allocate(&pdev->dev, in palmas_usb_probe()
257 if (IS_ERR(palmas_usb->edev)) { in palmas_usb_probe()
262 status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev); in palmas_usb_probe()
268 if (palmas_usb->enable_id_detection) { in palmas_usb_probe()
269 palmas_usb->id_otg_irq = regmap_irq_get_virq(palmas->irq_data, in palmas_usb_probe()
271 palmas_usb->id_irq = regmap_irq_get_virq(palmas->irq_data, in palmas_usb_probe()
273 status = devm_request_threaded_irq(palmas_usb->dev, in palmas_usb_probe()
274 palmas_usb->id_irq, in palmas_usb_probe()
278 "palmas_usb_id", palmas_usb); in palmas_usb_probe()
281 palmas_usb->id_irq, status); in palmas_usb_probe()
284 } else if (palmas_usb->enable_gpio_id_detection) { in palmas_usb_probe()
285 palmas_usb->gpio_id_irq = gpiod_to_irq(palmas_usb->id_gpiod); in palmas_usb_probe()
286 if (palmas_usb->gpio_id_irq < 0) { in palmas_usb_probe()
288 return palmas_usb->gpio_id_irq; in palmas_usb_probe()
291 palmas_usb->gpio_id_irq, in palmas_usb_probe()
298 palmas_usb); in palmas_usb_probe()
306 if (palmas_usb->enable_vbus_detection) { in palmas_usb_probe()
307 palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data, in palmas_usb_probe()
309 palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data, in palmas_usb_probe()
311 status = devm_request_threaded_irq(palmas_usb->dev, in palmas_usb_probe()
312 palmas_usb->vbus_irq, NULL, in palmas_usb_probe()
316 "palmas_usb_vbus", palmas_usb); in palmas_usb_probe()
319 palmas_usb->vbus_irq, status); in palmas_usb_probe()
322 } else if (palmas_usb->enable_gpio_vbus_detection) { in palmas_usb_probe()
334 palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data, in palmas_usb_probe()
336 palmas_usb->gpio_vbus_irq = gpiod_to_irq(palmas_usb->vbus_gpiod); in palmas_usb_probe()
337 if (palmas_usb->gpio_vbus_irq < 0) { in palmas_usb_probe()
339 return palmas_usb->gpio_vbus_irq; in palmas_usb_probe()
342 palmas_usb->gpio_vbus_irq, in palmas_usb_probe()
349 palmas_usb); in palmas_usb_probe()
357 palmas_enable_irq(palmas_usb); in palmas_usb_probe()
359 if (palmas_usb->enable_gpio_vbus_detection) in palmas_usb_probe()
360 palmas_vbus_irq_handler(palmas_usb->gpio_vbus_irq, palmas_usb); in palmas_usb_probe()
361 palmas_gpio_id_detect(&palmas_usb->wq_detectid.work); in palmas_usb_probe()
369 struct palmas_usb *palmas_usb = dev_get_drvdata(dev); in palmas_usb_suspend() local
372 if (palmas_usb->enable_vbus_detection) in palmas_usb_suspend()
373 enable_irq_wake(palmas_usb->vbus_irq); in palmas_usb_suspend()
374 if (palmas_usb->enable_gpio_vbus_detection) in palmas_usb_suspend()
375 enable_irq_wake(palmas_usb->gpio_vbus_irq); in palmas_usb_suspend()
376 if (palmas_usb->enable_id_detection) in palmas_usb_suspend()
377 enable_irq_wake(palmas_usb->id_irq); in palmas_usb_suspend()
378 if (palmas_usb->enable_gpio_id_detection) in palmas_usb_suspend()
379 enable_irq_wake(palmas_usb->gpio_id_irq); in palmas_usb_suspend()
386 struct palmas_usb *palmas_usb = dev_get_drvdata(dev); in palmas_usb_resume() local
389 if (palmas_usb->enable_vbus_detection) in palmas_usb_resume()
390 disable_irq_wake(palmas_usb->vbus_irq); in palmas_usb_resume()
391 if (palmas_usb->enable_gpio_vbus_detection) in palmas_usb_resume()
392 disable_irq_wake(palmas_usb->gpio_vbus_irq); in palmas_usb_resume()
393 if (palmas_usb->enable_id_detection) in palmas_usb_resume()
394 disable_irq_wake(palmas_usb->id_irq); in palmas_usb_resume()
395 if (palmas_usb->enable_gpio_id_detection) in palmas_usb_resume()
396 disable_irq_wake(palmas_usb->gpio_id_irq); in palmas_usb_resume()
400 if (palmas_usb->enable_gpio_vbus_detection) in palmas_usb_resume()
401 palmas_vbus_irq_handler(palmas_usb->gpio_vbus_irq, palmas_usb); in palmas_usb_resume()
402 palmas_gpio_id_detect(&palmas_usb->wq_detectid.work); in palmas_usb_resume()