Lines Matching +full:uart +full:- +full:attached

1 // SPDX-License-Identifier: GPL-2.0+
3 * extcon-fsa9480.c - Fairchild Semiconductor FSA9480 extcon driver
7 * Loosely based on old fsa9480 misc-device driver.
20 #include <linux/extcon-provider.h>
86 * D- [7:5] / D+ [4:2]
87 * 000: Open all / 001: USB / 010: AUDIO / 011: UART / 100: V_AUDIO
169 ret = regmap_write(usbsw->regmap, reg, value); in fsa9480_write_reg()
171 dev_err(usbsw->dev, "%s: err %d\n", __func__, ret); in fsa9480_write_reg()
180 ret = regmap_read(usbsw->regmap, reg, &val); in fsa9480_read_reg()
182 dev_err(usbsw->dev, "%s: err %d\n", __func__, ret); in fsa9480_read_reg()
194 ret = regmap_bulk_read(usbsw->regmap, FSA9480_REG_INT1, regs, 2); in fsa9480_read_irq()
196 dev_err(usbsw->dev, "%s: err %d\n", __func__, ret); in fsa9480_read_irq()
203 u16 mask, bool attached) in fsa9480_handle_change() argument
206 int dev = fls64(mask) - 1; in fsa9480_handle_change()
210 int cable = fls64(cables) - 1; in fsa9480_handle_change()
212 extcon_set_state_sync(usbsw->edev, cable, attached); in fsa9480_handle_change()
228 dev_err(usbsw->dev, "%s: failed to read registers", __func__); in fsa9480_detect_dev()
233 dev_info(usbsw->dev, "dev1: 0x%x, dev2: 0x%x\n", val1, val2); in fsa9480_detect_dev()
236 fsa9480_handle_change(usbsw, usbsw->cable & ~val, false); in fsa9480_detect_dev()
238 /* then handle attached ones */ in fsa9480_detect_dev()
239 fsa9480_handle_change(usbsw, val & ~usbsw->cable, true); in fsa9480_detect_dev()
241 usbsw->cable = val; in fsa9480_detect_dev()
266 if (!client->irq) { in fsa9480_probe()
267 dev_err(&client->dev, "no interrupt provided\n"); in fsa9480_probe()
268 return -EINVAL; in fsa9480_probe()
271 info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); in fsa9480_probe()
273 return -ENOMEM; in fsa9480_probe()
274 info->dev = &client->dev; in fsa9480_probe()
279 info->edev = devm_extcon_dev_allocate(info->dev, in fsa9480_probe()
281 if (IS_ERR(info->edev)) { in fsa9480_probe()
282 dev_err(info->dev, "failed to allocate memory for extcon\n"); in fsa9480_probe()
283 ret = -ENOMEM; in fsa9480_probe()
287 ret = devm_extcon_dev_register(info->dev, info->edev); in fsa9480_probe()
289 dev_err(info->dev, "failed to register extcon device\n"); in fsa9480_probe()
293 info->regmap = devm_regmap_init_i2c(client, &fsa9480_regmap_config); in fsa9480_probe()
294 if (IS_ERR(info->regmap)) { in fsa9480_probe()
295 ret = PTR_ERR(info->regmap); in fsa9480_probe()
296 dev_err(info->dev, "failed to allocate register map: %d\n", in fsa9480_probe()
312 ret = devm_request_threaded_irq(info->dev, client->irq, NULL, in fsa9480_probe()
317 dev_err(info->dev, "failed to request IRQ\n"); in fsa9480_probe()
321 device_init_wakeup(info->dev, true); in fsa9480_probe()
332 if (device_may_wakeup(&client->dev) && client->irq) in fsa9480_suspend()
333 enable_irq_wake(client->irq); in fsa9480_suspend()
342 if (device_may_wakeup(&client->dev) && client->irq) in fsa9480_resume()
343 disable_irq_wake(client->irq); in fsa9480_resume()