Lines Matching +full:vbus +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0
14 #include <linux/devm-helpers.h>
15 #include <linux/extcon-provider.h>
16 #include <linux/gpio/consumer.h>
50 * Some platforms have a bug in ACPI GPIO description making IRQ
51 * GPIO to be output only. Ask the GPIO core to ignore this limit.
53 { "id-gpios", &id_gpios, 1, ACPI_GPIO_QUIRK_NO_IO_RESTRICTION },
54 { "vbus-gpios", &vbus_gpios, 1 },
55 { "mux-gpios", &mux_gpios, 1 },
63 if (IS_ERR_OR_NULL(data->vbus_boost)) in int3496_set_vbus_boost()
66 if (data->vbus_boost_enabled == enable) in int3496_set_vbus_boost()
70 ret = regulator_enable(data->vbus_boost); in int3496_set_vbus_boost()
72 ret = regulator_disable(data->vbus_boost); in int3496_set_vbus_boost()
75 data->vbus_boost_enabled = enable; in int3496_set_vbus_boost()
77 dev_err(data->dev, "Error updating Vbus boost regulator: %d\n", ret); in int3496_set_vbus_boost()
84 int id = gpiod_get_value_cansleep(data->gpio_usb_id); in int3496_do_usb_id()
87 dev_dbg(data->dev, "Connected %s cable\n", id ? "PERIPHERAL" : "HOST"); in int3496_do_usb_id()
90 * Peripheral: set USB mux to peripheral and disable VBUS in int3496_do_usb_id()
91 * Host: set USB mux to host and enable VBUS in int3496_do_usb_id()
93 if (!IS_ERR(data->gpio_usb_mux)) in int3496_do_usb_id()
94 gpiod_direction_output(data->gpio_usb_mux, id); in int3496_do_usb_id()
96 if (!IS_ERR(data->gpio_vbus_en)) in int3496_do_usb_id()
97 gpiod_direction_output(data->gpio_vbus_en, !id); in int3496_do_usb_id()
101 extcon_set_state_sync(data->edev, EXTCON_USB_HOST, !id); in int3496_do_usb_id()
109 mod_delayed_work(system_wq, &data->work, DEBOUNCE_TIME); in int3496_thread_isr()
116 struct device *dev = &pdev->dev; in int3496_probe()
123 dev_err(dev, "can't add GPIO ACPI mapping\n"); in int3496_probe()
130 return -ENOMEM; in int3496_probe()
132 data->dev = dev; in int3496_probe()
133 ret = devm_delayed_work_autocancel(dev, &data->work, int3496_do_usb_id); in int3496_probe()
137 data->gpio_usb_id = in int3496_probe()
139 if (IS_ERR(data->gpio_usb_id)) { in int3496_probe()
140 ret = PTR_ERR(data->gpio_usb_id); in int3496_probe()
141 dev_err(dev, "can't request USB ID GPIO: %d\n", ret); in int3496_probe()
145 data->usb_id_irq = gpiod_to_irq(data->gpio_usb_id); in int3496_probe()
146 if (data->usb_id_irq < 0) { in int3496_probe()
147 dev_err(dev, "can't get USB ID IRQ: %d\n", data->usb_id_irq); in int3496_probe()
148 return data->usb_id_irq; in int3496_probe()
151 data->gpio_vbus_en = devm_gpiod_get(dev, "vbus", GPIOD_ASIS); in int3496_probe()
152 if (IS_ERR(data->gpio_vbus_en)) { in int3496_probe()
153 dev_dbg(dev, "can't request VBUS EN GPIO\n"); in int3496_probe()
154 data->vbus_boost = devm_regulator_get_optional(dev, "vbus"); in int3496_probe()
157 data->gpio_usb_mux = devm_gpiod_get(dev, "mux", GPIOD_ASIS); in int3496_probe()
158 if (IS_ERR(data->gpio_usb_mux)) in int3496_probe()
159 dev_dbg(dev, "can't request USB MUX GPIO\n"); in int3496_probe()
162 data->edev = devm_extcon_dev_allocate(dev, int3496_cable); in int3496_probe()
163 if (IS_ERR(data->edev)) in int3496_probe()
164 return -ENOMEM; in int3496_probe()
166 ret = devm_extcon_dev_register(dev, data->edev); in int3496_probe()
172 ret = devm_request_threaded_irq(dev, data->usb_id_irq, in int3496_probe()
179 dev_err(dev, "can't request IRQ for USB ID GPIO: %d\n", ret); in int3496_probe()
183 /* process id-pin so that we start with the right status */ in int3496_probe()
184 queue_delayed_work(system_wq, &data->work, 0); in int3496_probe()
185 flush_delayed_work(&data->work); in int3496_probe()
199 { .name = "intel-int3496" },
206 .name = "intel-int3496",