Lines Matching +full:hot +full:- +full:plug

1 // SPDX-License-Identifier: GPL-2.0+
3 * Surface Book (2 and later) hot-plug driver.
5 * Surface Book devices (can) have a hot-pluggable discrete GPU (dGPU). This
6 * driver is responsible for out-of-band hot-plug event signaling on these
7 * devices. It is specifically required when the hot-plug device is in D3cold
8 * and can thus not generate PCIe hot-plug events itself.
11 * device-check notifications to be picked up by the PCIe hot-plug driver.
13 * Copyright (C) 2019-2022 Maximilian Luz <luzmaximilian@gmail.com>
32 { "base_presence-int-gpio", &shps_base_presence_int, 1 },
33 { "base_presence-gpio", &shps_base_presence, 1 },
34 { "device_power-int-gpio", &shps_device_power_int, 1 },
35 { "device_power-gpio", &shps_device_power, 1 },
36 { "device_presence-int-gpio", &shps_device_presence_int, 1 },
37 { "device_presence-gpio", &shps_device_presence, 1 },
41 /* 5515a847-ed55-4b27-8352-cd320e10360a */
75 #define SHPS_IRQ_NOT_PRESENT ((unsigned int)-1)
85 acpi_handle handle = ACPI_HANDLE(&pdev->dev); in shps_dsm_notify_irq()
90 mutex_lock(&sdev->lock[type]); in shps_dsm_notify_irq()
92 value = gpiod_get_value_cansleep(sdev->gpio[type]); in shps_dsm_notify_irq()
94 mutex_unlock(&sdev->lock[type]); in shps_dsm_notify_irq()
95 dev_err(&pdev->dev, "failed to get gpio: %d (irq=%d)\n", type, value); in shps_dsm_notify_irq()
99 dev_dbg(&pdev->dev, "IRQ notification via DSM (irq=%d, value=%d)\n", type, value); in shps_dsm_notify_irq()
107 dev_err(&pdev->dev, "IRQ notification via DSM failed (irq=%d, gpio=%d)\n", in shps_dsm_notify_irq()
110 } else if (result->buffer.length != 1 || result->buffer.pointer[0] != 0) { in shps_dsm_notify_irq()
111 dev_err(&pdev->dev, in shps_dsm_notify_irq()
116 mutex_unlock(&sdev->lock[type]); in shps_dsm_notify_irq()
129 if (irq == sdev->irq[type]) in shps_handle_irq()
146 acpi_handle handle = ACPI_HANDLE(&pdev->dev); in shps_setup_irq()
157 dev_dbg(&pdev->dev, "IRQ notification via DSM not present (irq=%d)\n", type); in shps_setup_irq()
161 gpiod = devm_gpiod_get(&pdev->dev, shps_gpio_names[type], GPIOD_ASIS); in shps_setup_irq()
169 irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "shps-irq-%d", type); in shps_setup_irq()
171 return -ENOMEM; in shps_setup_irq()
173 status = devm_request_threaded_irq(&pdev->dev, irq, NULL, shps_handle_irq, in shps_setup_irq()
178 dev_dbg(&pdev->dev, "set up irq %d as type %d\n", irq, type); in shps_setup_irq()
180 sdev->gpio[type] = gpiod; in shps_setup_irq()
181 sdev->irq[type] = irq; in shps_setup_irq()
193 if (sdev->irq[i] != SHPS_IRQ_NOT_PRESENT) in surface_hotplug_remove()
194 disable_irq(sdev->irq[i]); in surface_hotplug_remove()
196 mutex_destroy(&sdev->lock[i]); in surface_hotplug_remove()
209 * however that doesn't have a hot-pluggable PCIe device. It also in surface_hotplug_probe()
213 if (gpiod_count(&pdev->dev, NULL) < 0) in surface_hotplug_probe()
214 return -ENODEV; in surface_hotplug_probe()
216 status = devm_acpi_dev_add_driver_gpios(&pdev->dev, shps_acpi_gpios); in surface_hotplug_probe()
220 sdev = devm_kzalloc(&pdev->dev, sizeof(*sdev), GFP_KERNEL); in surface_hotplug_probe()
222 return -ENOMEM; in surface_hotplug_probe()
231 sdev->irq[i] = SHPS_IRQ_NOT_PRESENT; in surface_hotplug_probe()
235 mutex_init(&sdev->lock[i]); in surface_hotplug_probe()
239 dev_err(&pdev->dev, "failed to set up IRQ %d: %d\n", i, status); in surface_hotplug_probe()
244 /* Ensure everything is up-to-date. */ in surface_hotplug_probe()
246 if (sdev->irq[i] != SHPS_IRQ_NOT_PRESENT) in surface_hotplug_probe()
274 MODULE_DESCRIPTION("Surface Hot-Plug Signaling Driver for Surface Book Devices");