Lines Matching +full:loongson +full:- +full:1 +full:c

1 // SPDX-License-Identifier: GPL-2.0
3 * Generic Loongson processor based LAPTOP/ALL-IN-ONE driver
5 * Jianmin Lv <lvjianmin@loongson.cn>
6 * Huacai Chen <chenhuacai@loongson.cn>
8 * Copyright (C) 2022 Loongson Technology Corporation Limited
20 #include <linux/input/sparse-keymap.h>
26 /* 1. Driver-wide structs and misc. variables */
32 #define ACPI_LAPTOP_NAME "loongson-laptop"
33 #define ACPI_LAPTOP_ACPI_EVENT_PREFIX "loongson"
82 quiet = 1; in acpi_evalf()
94 char c = *(fmt++); in acpi_evalf() local
95 switch (c) { in acpi_evalf()
102 pr_err("acpi_evalf() called with invalid format character '%c'\n", c); in acpi_evalf()
129 pr_err("acpi_evalf() called with invalid format character '%c'\n", res_type); in acpi_evalf()
143 return -EIO; in hotkey_status_get()
152 if (!sub_driver || !sub_driver->notify) in dispatch_acpi_notify()
154 sub_driver->notify(sub_driver, event); in dispatch_acpi_notify()
161 if (!*sub_driver->handle) in setup_acpi_notify()
164 sub_driver->device = acpi_fetch_acpi_dev(*sub_driver->handle); in setup_acpi_notify()
165 if (!sub_driver->device) { in setup_acpi_notify()
166 pr_err("acpi_fetch_acpi_dev(%s) failed\n", sub_driver->name); in setup_acpi_notify()
167 return -ENODEV; in setup_acpi_notify()
170 sub_driver->device->driver_data = sub_driver; in setup_acpi_notify()
171 sprintf(acpi_device_class(sub_driver->device), "%s/%s", in setup_acpi_notify()
172 ACPI_LAPTOP_ACPI_EVENT_PREFIX, sub_driver->name); in setup_acpi_notify()
174 status = acpi_install_notify_handler(*sub_driver->handle, in setup_acpi_notify()
175 sub_driver->type, dispatch_acpi_notify, sub_driver); in setup_acpi_notify()
179 "handling %s events\n", sub_driver->name); in setup_acpi_notify()
182 sub_driver->name, acpi_format_exception(status)); in setup_acpi_notify()
184 return -ENODEV; in setup_acpi_notify()
186 sub_driver->acpi_notify_installed = 1; in setup_acpi_notify()
206 pr_info("Loongson_backlight: resume brightness %d\n", bd->props.brightness); in loongson_hotkey_resume()
213 if (test_bit(SW_LID, generic_inputdev->swbit)) { in loongson_hotkey_resume()
215 return -EIO; in loongson_hotkey_resume()
218 * When the system is awakened by other wake-up sources, in loongson_hotkey_resume()
230 if (test_bit(SW_LID, generic_inputdev->sw) && !(status & (1 << SW_LID))) { in loongson_hotkey_resume()
234 sparse_keymap_report_entry(generic_inputdev, &ke, 1, true); in loongson_hotkey_resume()
246 hotkey_handle = ACPI_HANDLE(&pdev->dev); in loongson_hotkey_probe()
249 return -ENODEV; in loongson_hotkey_probe()
263 .name = "loongson-hotkey",
281 return -1; in hotkey_map()
284 for (index = 0; index < pack->package.count; index++) { in hotkey_map()
287 sub_pack = &pack->package.elements[index]; in hotkey_map()
289 element = &sub_pack->package.elements[0]; in hotkey_map()
290 hotkey_keycode_map[index].type = element->integer.value; in hotkey_map()
291 element = &sub_pack->package.elements[1]; in hotkey_map()
292 hotkey_keycode_map[index].code = element->integer.value; in hotkey_map()
293 element = &sub_pack->package.elements[2]; in hotkey_map()
294 hotkey_keycode_map[index].keycode = element->integer.value; in hotkey_map()
302 if (!acpi_evalf(hotkey_handle, NULL, "VCBL", "vd", enable ? 1 : 0)) in hotkey_backlight_set()
303 return -EIO; in hotkey_backlight_set()
313 return -ENXIO; in ec_get_brightness()
316 return -EIO; in ec_get_brightness()
327 return -ENXIO; in ec_set_brightness()
330 ret = -EIO; in ec_set_brightness()
340 return -ENXIO; in ec_backlight_level()
343 return -EIO; in ec_backlight_level()
349 return -EIO; in ec_backlight_level()
359 int lvl = ec_backlight_level(bd->props.brightness); in loongson_laptop_backlight_update()
362 return -EIO; in loongson_laptop_backlight_update()
364 return -EIO; in loongson_laptop_backlight_update()
375 return -EIO; in loongson_laptop_get_brightness()
393 return -EIO; in laptop_backlight_register()
395 props.brightness = 1; in laptop_backlight_register()
409 struct acpi_object_list args = { 1, &arg0 }; in loongson_laptop_turn_on_backlight()
411 arg0.integer.value = 1; in loongson_laptop_turn_on_backlight()
414 pr_info("Loongson lvds error: 0x%x\n", status); in loongson_laptop_turn_on_backlight()
415 return -ENODEV; in loongson_laptop_turn_on_backlight()
425 struct acpi_object_list args = { 1, &arg0 }; in loongson_laptop_turn_off_backlight()
430 pr_info("Loongson lvds error: 0x%x\n", status); in loongson_laptop_turn_off_backlight()
431 return -ENODEV; in loongson_laptop_turn_off_backlight()
485 ke->sw.value = !!(status & (1 << ke->sw.code)); in event_notify()
487 sparse_keymap_report_entry(generic_inputdev, ke, 1, true); in event_notify()
499 if (!sub_driver || !sub_driver->driver) in generic_subdriver_init()
500 return -EINVAL; in generic_subdriver_init()
502 ret = platform_driver_register(sub_driver->driver); in generic_subdriver_init()
504 return -EINVAL; in generic_subdriver_init()
506 if (sub_driver->init) { in generic_subdriver_init()
507 ret = sub_driver->init(sub_driver); in generic_subdriver_init()
512 if (sub_driver->notify) { in generic_subdriver_init()
514 if (ret == -ENODEV) { in generic_subdriver_init()
532 if (sub_driver->acpi_notify_installed) { in generic_subdriver_exit()
533 acpi_remove_notify_handler(*sub_driver->handle, in generic_subdriver_exit()
534 sub_driver->type, dispatch_acpi_notify); in generic_subdriver_exit()
535 sub_driver->acpi_notify_installed = 0; in generic_subdriver_exit()
537 platform_driver_unregister(sub_driver->driver); in generic_subdriver_exit()
557 return -ENODEV; in generic_acpi_laptop_init()
562 return -ENODEV; in generic_acpi_laptop_init()
565 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); in generic_acpi_laptop_init()
570 return -ENOMEM; in generic_acpi_laptop_init()
574 generic_inputdev->name = in generic_acpi_laptop_init()
575 "Loongson Generic Laptop/All-in-One Extra Buttons"; in generic_acpi_laptop_init()
576 generic_inputdev->phys = ACPI_LAPTOP_NAME "/input0"; in generic_acpi_laptop_init()
577 generic_inputdev->id.bustype = BUS_HOST; in generic_acpi_laptop_init()
578 generic_inputdev->dev.parent = NULL; in generic_acpi_laptop_init()
585 while (--i >= 0) in generic_acpi_laptop_init()
594 while (--i >= 0) in generic_acpi_laptop_init()
600 input_device_registered = 1; in generic_acpi_laptop_init()
603 pr_info("Loongson Laptop used, init brightness is 0x%x\n", status); in generic_acpi_laptop_init()
606 pr_err("Loongson Laptop: laptop-backlight device register failed\n"); in generic_acpi_laptop_init()
625 MODULE_AUTHOR("Jianmin Lv <lvjianmin@loongson.cn>");
626 MODULE_AUTHOR("Huacai Chen <chenhuacai@loongson.cn>");
627 MODULE_DESCRIPTION("Loongson Laptop/All-in-One ACPI Driver");