21 #include <linux/kernel.h>
22 #include <linux/module.h>
25 #include <linux/types.h>
26 #include <linux/device.h>
34 #include <linux/usb/ch9.h>
39 #define ISP1704_PWR_CTRL 0x3d
40 #define ISP1704_PWR_CTRL_SWCTRL (1 << 0)
41 #define ISP1704_PWR_CTRL_DET_COMP (1 << 1)
42 #define ISP1704_PWR_CTRL_BVALID_RISE (1 << 2)
43 #define ISP1704_PWR_CTRL_BVALID_FALL (1 << 3)
44 #define ISP1704_PWR_CTRL_DP_WKPU_EN (1 << 4)
45 #define ISP1704_PWR_CTRL_VDAT_DET (1 << 5)
46 #define ISP1704_PWR_CTRL_DPVSRC_EN (1 << 6)
47 #define ISP1704_PWR_CTRL_HWDETECT (1 << 7)
49 #define NXP_VENDOR_ID 0x04cc
51 static u16 isp170x_id[] = {
76 return usb_phy_io_read(isp->
phy, reg);
81 return usb_phy_io_write(isp->
phy, val, reg);
88 static void isp1704_charger_set_power(
struct isp1704_charger *isp,
bool on)
223 ret = isp1704_charger_verify(isp);
249 isp1704_charger_set_power(isp, 1);
256 detect = isp1704_charger_detect(isp);
260 isp->
psy.type = isp1704_charger_type(isp);
263 switch (isp->
psy.type) {
277 if (isp->
phy->otg->gadget)
278 usb_gadget_connect(isp->
phy->otg->gadget);
296 if (isp->
phy->otg->gadget)
297 usb_gadget_disconnect(isp->
phy->otg->gadget);
299 isp1704_charger_set_power(isp, 0);
317 unsigned long event,
void *power)
397 for (i = 0; i <
ARRAY_SIZE(isp170x_id); i++) {
398 if (product == isp170x_id[i]) {
404 dev_err(isp->
dev,
"product id %x not matching known ids", product);
419 if (IS_ERR_OR_NULL(isp->
phy))
423 platform_set_drvdata(pdev, isp);
425 isp1704_charger_set_power(isp, 1);
427 ret = isp1704_test_ulpi(isp);
431 isp->
psy.name =
"isp1704";
433 isp->
psy.properties = power_props;
435 isp->
psy.get_property = isp1704_charger_get_property;
447 isp->
nb.notifier_call = isp1704_notifier_call;
449 ret = usb_register_notifier(isp->
phy, &isp->
nb);
462 if (isp->
phy->otg->gadget)
463 usb_gadget_disconnect(isp->
phy->otg->gadget);
467 isp1704_charger_set_power(isp, 0);
477 isp1704_charger_set_power(isp, 0);
482 dev_err(&pdev->
dev,
"failed to register isp1704 with error %d\n", ret);
491 usb_unregister_notifier(isp->
phy, &isp->
nb);
494 isp1704_charger_set_power(isp, 0);
502 .name =
"isp1704_charger",
504 .probe = isp1704_charger_probe,