Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/surface: dtx: Add support for native SSAM devices

Add support for native SSAM devices to the DTX driver. This allows
support for the Surface Book 3, on which the DTX device is not present
in ACPI.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20210308184819.437438-3-luzmaximilian@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Maximilian Luz and committed by
Hans de Goede
e893d45f 1d609992

+93 -1
+4
drivers/platform/surface/Kconfig
··· 120 120 behavior of this process, which includes the option to abort it in 121 121 case the base is still in use or speed it up in case it is not. 122 122 123 + Note that this module can be built without support for the Surface 124 + Aggregator Bus (i.e. CONFIG_SURFACE_AGGREGATOR_BUS=n). In that case, 125 + some devices, specifically the Surface Book 3, will not be supported. 126 + 123 127 config SURFACE_GPE 124 128 tristate "Surface GPE/Lid Support Driver" 125 129 depends on DMI
+89 -1
drivers/platform/surface/surface_dtx.c
··· 27 27 #include <linux/workqueue.h> 28 28 29 29 #include <linux/surface_aggregator/controller.h> 30 + #include <linux/surface_aggregator/device.h> 30 31 #include <linux/surface_aggregator/dtx.h> 31 32 32 33 ··· 1195 1194 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1196 1195 }, 1197 1196 }; 1198 - module_platform_driver(surface_dtx_platform_driver); 1197 + 1198 + 1199 + /* -- SSAM device driver. --------------------------------------------------- */ 1200 + 1201 + #ifdef CONFIG_SURFACE_AGGREGATOR_BUS 1202 + 1203 + static int surface_dtx_ssam_probe(struct ssam_device *sdev) 1204 + { 1205 + struct sdtx_device *ddev; 1206 + 1207 + ddev = sdtx_device_create(&sdev->dev, sdev->ctrl); 1208 + if (IS_ERR(ddev)) 1209 + return PTR_ERR(ddev); 1210 + 1211 + ssam_device_set_drvdata(sdev, ddev); 1212 + return 0; 1213 + } 1214 + 1215 + static void surface_dtx_ssam_remove(struct ssam_device *sdev) 1216 + { 1217 + sdtx_device_destroy(ssam_device_get_drvdata(sdev)); 1218 + } 1219 + 1220 + static const struct ssam_device_id surface_dtx_ssam_match[] = { 1221 + { SSAM_SDEV(BAS, 0x01, 0x00, 0x00) }, 1222 + { }, 1223 + }; 1224 + MODULE_DEVICE_TABLE(ssam, surface_dtx_ssam_match); 1225 + 1226 + static struct ssam_device_driver surface_dtx_ssam_driver = { 1227 + .probe = surface_dtx_ssam_probe, 1228 + .remove = surface_dtx_ssam_remove, 1229 + .match_table = surface_dtx_ssam_match, 1230 + .driver = { 1231 + .name = "surface_dtx", 1232 + .pm = &surface_dtx_pm_ops, 1233 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1234 + }, 1235 + }; 1236 + 1237 + static int ssam_dtx_driver_register(void) 1238 + { 1239 + return ssam_device_driver_register(&surface_dtx_ssam_driver); 1240 + } 1241 + 1242 + static void ssam_dtx_driver_unregister(void) 1243 + { 1244 + ssam_device_driver_unregister(&surface_dtx_ssam_driver); 1245 + } 1246 + 1247 + #else /* CONFIG_SURFACE_AGGREGATOR_BUS */ 1248 + 1249 + static int ssam_dtx_driver_register(void) 1250 + { 1251 + return 0; 1252 + } 1253 + 1254 + static void ssam_dtx_driver_unregister(void) 1255 + { 1256 + } 1257 + 1258 + #endif /* CONFIG_SURFACE_AGGREGATOR_BUS */ 1259 + 1260 + 1261 + /* -- Module setup. --------------------------------------------------------- */ 1262 + 1263 + static int __init surface_dtx_init(void) 1264 + { 1265 + int status; 1266 + 1267 + status = ssam_dtx_driver_register(); 1268 + if (status) 1269 + return status; 1270 + 1271 + status = platform_driver_register(&surface_dtx_platform_driver); 1272 + if (status) 1273 + ssam_dtx_driver_unregister(); 1274 + 1275 + return status; 1276 + } 1277 + module_init(surface_dtx_init); 1278 + 1279 + static void __exit surface_dtx_exit(void) 1280 + { 1281 + platform_driver_unregister(&surface_dtx_platform_driver); 1282 + ssam_dtx_driver_unregister(); 1283 + } 1284 + module_exit(surface_dtx_exit); 1199 1285 1200 1286 MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>"); 1201 1287 MODULE_DESCRIPTION("Detachment-system driver for Surface System Aggregator Module");