• Home
  • Raw
  • Download

Lines Matching refs:info

72 static void ptn5150_check_state(struct ptn5150_info *info)  in ptn5150_check_state()  argument
78 ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, &reg_data); in ptn5150_check_state()
80 dev_err(info->dev, "failed to read CC STATUS %d\n", ret); in ptn5150_check_state()
88 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, false); in ptn5150_check_state()
89 gpiod_set_value_cansleep(info->vbus_gpiod, 0); in ptn5150_check_state()
90 extcon_set_state_sync(info->edev, EXTCON_USB, true); in ptn5150_check_state()
94 extcon_set_state_sync(info->edev, EXTCON_USB, false); in ptn5150_check_state()
97 gpiod_set_value_cansleep(info->vbus_gpiod, 0); in ptn5150_check_state()
99 gpiod_set_value_cansleep(info->vbus_gpiod, 1); in ptn5150_check_state()
101 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true); in ptn5150_check_state()
109 ret = usb_role_switch_set_role(info->role_sw, usb_role); in ptn5150_check_state()
111 dev_err(info->dev, "failed to set %s role: %d\n", in ptn5150_check_state()
118 struct ptn5150_info *info = container_of(work, in ptn5150_irq_work() local
123 if (!info->edev) in ptn5150_irq_work()
126 mutex_lock(&info->mutex); in ptn5150_irq_work()
129 ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, &int_status); in ptn5150_irq_work()
131 dev_err(info->dev, "failed to read INT STATUS %d\n", ret); in ptn5150_irq_work()
132 mutex_unlock(&info->mutex); in ptn5150_irq_work()
141 ptn5150_check_state(info); in ptn5150_irq_work()
143 extcon_set_state_sync(info->edev, in ptn5150_irq_work()
145 extcon_set_state_sync(info->edev, in ptn5150_irq_work()
147 gpiod_set_value_cansleep(info->vbus_gpiod, 0); in ptn5150_irq_work()
149 ret = usb_role_switch_set_role(info->role_sw, in ptn5150_irq_work()
152 dev_err(info->dev, in ptn5150_irq_work()
159 ret = regmap_read(info->regmap, PTN5150_REG_INT_REG_STATUS, in ptn5150_irq_work()
162 dev_err(info->dev, in ptn5150_irq_work()
164 mutex_unlock(&info->mutex); in ptn5150_irq_work()
168 mutex_unlock(&info->mutex); in ptn5150_irq_work()
174 struct ptn5150_info *info = data; in ptn5150_irq_handler() local
176 schedule_work(&info->irq_work); in ptn5150_irq_handler()
181 static int ptn5150_init_dev_type(struct ptn5150_info *info) in ptn5150_init_dev_type() argument
186 ret = regmap_read(info->regmap, PTN5150_REG_DEVICE_ID, &reg_data); in ptn5150_init_dev_type()
188 dev_err(info->dev, "failed to read DEVICE_ID %d\n", ret); in ptn5150_init_dev_type()
194 dev_dbg(info->dev, "Device type: version: 0x%x, vendor: 0x%x\n", in ptn5150_init_dev_type()
198 ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, &reg_data); in ptn5150_init_dev_type()
200 dev_err(info->dev, in ptn5150_init_dev_type()
206 ret = regmap_read(info->regmap, PTN5150_REG_INT_REG_STATUS, &reg_data); in ptn5150_init_dev_type()
208 dev_err(info->dev, in ptn5150_init_dev_type()
218 struct ptn5150_info *info = data; in ptn5150_work_sync_and_put() local
220 cancel_work_sync(&info->irq_work); in ptn5150_work_sync_and_put()
221 usb_role_switch_put(info->role_sw); in ptn5150_work_sync_and_put()
228 struct ptn5150_info *info; in ptn5150_i2c_probe() local
234 info = devm_kzalloc(&i2c->dev, sizeof(*info), GFP_KERNEL); in ptn5150_i2c_probe()
235 if (!info) in ptn5150_i2c_probe()
237 i2c_set_clientdata(i2c, info); in ptn5150_i2c_probe()
239 info->dev = &i2c->dev; in ptn5150_i2c_probe()
240 info->i2c = i2c; in ptn5150_i2c_probe()
241 info->vbus_gpiod = devm_gpiod_get(&i2c->dev, "vbus", GPIOD_OUT_LOW); in ptn5150_i2c_probe()
242 if (IS_ERR(info->vbus_gpiod)) { in ptn5150_i2c_probe()
243 ret = PTR_ERR(info->vbus_gpiod); in ptn5150_i2c_probe()
246 info->vbus_gpiod = NULL; in ptn5150_i2c_probe()
252 mutex_init(&info->mutex); in ptn5150_i2c_probe()
254 INIT_WORK(&info->irq_work, ptn5150_irq_work); in ptn5150_i2c_probe()
256 info->regmap = devm_regmap_init_i2c(i2c, &ptn5150_regmap_config); in ptn5150_i2c_probe()
257 if (IS_ERR(info->regmap)) { in ptn5150_i2c_probe()
258 return dev_err_probe(info->dev, PTR_ERR(info->regmap), in ptn5150_i2c_probe()
263 info->irq = i2c->irq; in ptn5150_i2c_probe()
265 info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); in ptn5150_i2c_probe()
266 if (IS_ERR(info->int_gpiod)) { in ptn5150_i2c_probe()
267 return dev_err_probe(dev, PTR_ERR(info->int_gpiod), in ptn5150_i2c_probe()
271 info->irq = gpiod_to_irq(info->int_gpiod); in ptn5150_i2c_probe()
272 if (info->irq < 0) { in ptn5150_i2c_probe()
274 return info->irq; in ptn5150_i2c_probe()
278 ret = devm_request_threaded_irq(dev, info->irq, NULL, in ptn5150_i2c_probe()
282 i2c->name, info); in ptn5150_i2c_probe()
289 info->edev = devm_extcon_dev_allocate(info->dev, ptn5150_extcon_cable); in ptn5150_i2c_probe()
290 if (IS_ERR(info->edev)) { in ptn5150_i2c_probe()
291 dev_err(info->dev, "failed to allocate memory for extcon\n"); in ptn5150_i2c_probe()
296 ret = devm_extcon_dev_register(info->dev, info->edev); in ptn5150_i2c_probe()
298 dev_err(info->dev, "failed to register extcon device\n"); in ptn5150_i2c_probe()
302 extcon_set_property_capability(info->edev, EXTCON_USB, in ptn5150_i2c_probe()
304 extcon_set_property_capability(info->edev, EXTCON_USB_HOST, in ptn5150_i2c_probe()
306 extcon_set_property_capability(info->edev, EXTCON_USB_HOST, in ptn5150_i2c_probe()
310 ret = ptn5150_init_dev_type(info); in ptn5150_i2c_probe()
314 info->role_sw = usb_role_switch_get(info->dev); in ptn5150_i2c_probe()
315 if (IS_ERR(info->role_sw)) in ptn5150_i2c_probe()
316 return dev_err_probe(info->dev, PTR_ERR(info->role_sw), in ptn5150_i2c_probe()
319 ret = devm_add_action_or_reset(dev, ptn5150_work_sync_and_put, info); in ptn5150_i2c_probe()
327 mutex_lock(&info->mutex); in ptn5150_i2c_probe()
328 ptn5150_check_state(info); in ptn5150_i2c_probe()
329 mutex_unlock(&info->mutex); in ptn5150_i2c_probe()