Lines Matching +full:segment +full:- +full:no +full:- +full:remap

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2009,2011 Greg Kroah-Hartman (gregkh@suse.de)
35 * We have 0 - 8 as valid brightness levels. The specs say that level 0 should
37 * userspace that the value is 0 - 7 and then just tell the hardware 1 - 8
74 * Brightness is 0 - 8, as described above.
82 * 0x00 - wireless is off
83 * 0x01 - wireless is on
85 * 0x02 - 3G is off
86 * 0x03 - 3G is on
97 * 0x80 or 0x00 - no action
98 * 0x81 - recovery key pressed
289 * samsung-laptop/ - debugfs root directory
290 * f0000_segment - dump f0000 segment
291 * command - current command
292 * data - current data
293 * d0, d1, d2, d3 - data fields
294 * call - call SABI using command and data
387 const struct sabi_config *config = samsung->config; in sabi_command()
389 u16 port = readw(samsung->sabi + config->header_offsets.port); in sabi_command()
392 mutex_lock(&samsung->sabi_mutex); in sabi_command()
398 command, in->d0, in->d1, in->d2, in->d3); in sabi_command()
404 outb(readb(samsung->sabi + config->header_offsets.en_mem), port); in sabi_command()
407 writew(config->main_function, samsung->sabi_iface + SABI_IFACE_MAIN); in sabi_command()
408 writew(command, samsung->sabi_iface + SABI_IFACE_SUB); in sabi_command()
409 writeb(0, samsung->sabi_iface + SABI_IFACE_COMPLETE); in sabi_command()
411 writel(in->d0, samsung->sabi_iface + SABI_IFACE_DATA); in sabi_command()
412 writel(in->d1, samsung->sabi_iface + SABI_IFACE_DATA + 4); in sabi_command()
413 writew(in->d2, samsung->sabi_iface + SABI_IFACE_DATA + 8); in sabi_command()
414 writeb(in->d3, samsung->sabi_iface + SABI_IFACE_DATA + 10); in sabi_command()
416 outb(readb(samsung->sabi + config->header_offsets.iface_func), port); in sabi_command()
419 outb(readb(samsung->sabi + config->header_offsets.re_mem), port); in sabi_command()
422 complete = readb(samsung->sabi_iface + SABI_IFACE_COMPLETE); in sabi_command()
423 iface_data = readb(samsung->sabi_iface + SABI_IFACE_DATA); in sabi_command()
435 ret = -EINVAL; in sabi_command()
440 out->d0 = readl(samsung->sabi_iface + SABI_IFACE_DATA); in sabi_command()
441 out->d1 = readl(samsung->sabi_iface + SABI_IFACE_DATA + 4); in sabi_command()
442 out->d2 = readw(samsung->sabi_iface + SABI_IFACE_DATA + 2); in sabi_command()
443 out->d3 = readb(samsung->sabi_iface + SABI_IFACE_DATA + 1); in sabi_command()
448 out->d0, out->d1, out->d2, out->d3); in sabi_command()
452 mutex_unlock(&samsung->sabi_mutex); in sabi_command()
468 const struct sabi_config *config = samsung->config; in read_brightness()
469 const struct sabi_commands *commands = &samsung->config->commands; in read_brightness()
474 retval = sabi_command(samsung, commands->get_brightness, in read_brightness()
480 if (user_brightness > config->min_brightness) in read_brightness()
481 user_brightness -= config->min_brightness; in read_brightness()
490 const struct sabi_config *config = samsung->config; in set_brightness()
491 const struct sabi_commands *commands = &samsung->config->commands; in set_brightness()
492 u8 user_level = user_brightness + config->min_brightness; in set_brightness()
494 if (samsung->has_stepping_quirk && user_level != 0) { in set_brightness()
502 sabi_set_commandb(samsung, commands->set_brightness, 0); in set_brightness()
505 sabi_set_commandb(samsung, commands->set_brightness, user_level); in set_brightness()
536 check_level = initial_level - 2; in check_for_stepping_quirk()
538 samsung->has_stepping_quirk = false; in check_for_stepping_quirk()
542 samsung->has_stepping_quirk = true; in check_for_stepping_quirk()
552 const struct sabi_commands *commands = &samsung->config->commands; in update_status()
554 set_brightness(samsung, bd->props.brightness); in update_status()
556 if (bd->props.power == BACKLIGHT_POWER_ON) in update_status()
557 sabi_set_commandb(samsung, commands->set_backlight, 1); in update_status()
559 sabi_set_commandb(samsung, commands->set_backlight, 0); in update_status()
572 struct samsung_laptop *samsung = srfkill->samsung; in seclinux_rfkill_set()
573 const struct sabi_commands *commands = &samsung->config->commands; in seclinux_rfkill_set()
575 return sabi_set_commandb(samsung, commands->set_wireless_button, in seclinux_rfkill_set()
586 const struct sabi_commands *commands = &samsung->config->commands; in swsmi_wireless_status()
588 return sabi_command(samsung, commands->get_wireless_status, in swsmi_wireless_status()
595 struct samsung_laptop *samsung = srfkill->samsung; in swsmi_rfkill_set()
596 const struct sabi_commands *commands = &samsung->config->commands; in swsmi_rfkill_set()
604 /* Don't set the state for non-present devices */ in swsmi_rfkill_set()
609 if (srfkill->type == RFKILL_TYPE_WLAN) in swsmi_rfkill_set()
611 else if (srfkill->type == RFKILL_TYPE_BLUETOOTH) in swsmi_rfkill_set()
614 return sabi_command(samsung, commands->set_wireless_status, in swsmi_rfkill_set()
621 struct samsung_laptop *samsung = srfkill->samsung; in swsmi_rfkill_query()
629 if (srfkill->type == RFKILL_TYPE_WLAN) in swsmi_rfkill_query()
631 else if (srfkill->type == RFKILL_TYPE_BLUETOOTH) in swsmi_rfkill_query()
648 const struct sabi_config *config = samsung->config; in get_performance_level()
649 const struct sabi_commands *commands = &config->commands; in get_performance_level()
655 retval = sabi_command(samsung, commands->get_performance_level, in get_performance_level()
661 for (i = 0; config->performance_levels[i].name; ++i) { in get_performance_level()
662 if (sretval.data[0] == config->performance_levels[i].value) in get_performance_level()
663 return sysfs_emit(buf, "%s\n", config->performance_levels[i].name); in get_performance_level()
673 const struct sabi_config *config = samsung->config; in set_performance_level()
674 const struct sabi_commands *commands = &config->commands; in set_performance_level()
680 for (i = 0; config->performance_levels[i].name; ++i) { in set_performance_level()
682 &config->performance_levels[i]; in set_performance_level()
683 if (!strncasecmp(level->name, buf, strlen(level->name))) { in set_performance_level()
685 commands->set_performance_level, in set_performance_level()
686 level->value); in set_performance_level()
691 if (!config->performance_levels[i].name) in set_performance_level()
692 return -EINVAL; in set_performance_level()
702 const struct sabi_commands *commands = &samsung->config->commands; in read_battery_life_extender()
706 if (commands->get_battery_life_extender == 0xFFFF) in read_battery_life_extender()
707 return -ENODEV; in read_battery_life_extender()
711 retval = sabi_command(samsung, commands->get_battery_life_extender, in read_battery_life_extender()
718 return -ENODEV; in read_battery_life_extender()
726 const struct sabi_commands *commands = &samsung->config->commands; in write_battery_life_extender()
731 return sabi_command(samsung, commands->set_battery_life_extender, in write_battery_life_extender()
757 return -EINVAL; in set_battery_life_extender()
771 const struct sabi_commands *commands = &samsung->config->commands; in read_usb_charge()
775 if (commands->get_usb_charge == 0xFFFF) in read_usb_charge()
776 return -ENODEV; in read_usb_charge()
780 retval = sabi_command(samsung, commands->get_usb_charge, in read_usb_charge()
787 return -ENODEV; in read_usb_charge()
795 const struct sabi_commands *commands = &samsung->config->commands; in write_usb_charge()
800 return sabi_command(samsung, commands->set_usb_charge, in write_usb_charge()
826 return -EINVAL; in set_usb_charge()
840 const struct sabi_commands *commands = &samsung->config->commands; in read_lid_handling()
844 if (commands->get_lid_handling == 0xFFFF) in read_lid_handling()
845 return -ENODEV; in read_lid_handling()
848 retval = sabi_command(samsung, commands->get_lid_handling, in read_lid_handling()
860 const struct sabi_commands *commands = &samsung->config->commands; in write_lid_handling()
865 return sabi_command(samsung, commands->set_lid_handling, in write_lid_handling()
891 return -EINVAL; in set_lid_handling()
920 if (i == strlen(testStr)-1) in find_signature()
932 if (samsung->wlan.rfkill) { in samsung_rfkill_exit()
933 rfkill_unregister(samsung->wlan.rfkill); in samsung_rfkill_exit()
934 rfkill_destroy(samsung->wlan.rfkill); in samsung_rfkill_exit()
935 samsung->wlan.rfkill = NULL; in samsung_rfkill_exit()
937 if (samsung->bluetooth.rfkill) { in samsung_rfkill_exit()
938 rfkill_unregister(samsung->bluetooth.rfkill); in samsung_rfkill_exit()
939 rfkill_destroy(samsung->bluetooth.rfkill); in samsung_rfkill_exit()
940 samsung->bluetooth.rfkill = NULL; in samsung_rfkill_exit()
950 struct rfkill **rfkill = &arfkill->rfkill; in samsung_new_rfkill()
953 arfkill->type = type; in samsung_new_rfkill()
954 arfkill->samsung = samsung; in samsung_new_rfkill()
956 *rfkill = rfkill_alloc(name, &samsung->platform_device->dev, in samsung_new_rfkill()
960 return -EINVAL; in samsung_new_rfkill()
962 if (blocked != -1) in samsung_new_rfkill()
976 return samsung_new_rfkill(samsung, &samsung->wlan, "samsung-wlan", in samsung_rfkill_init_seclinux()
977 RFKILL_TYPE_WLAN, &seclinux_rfkill_ops, -1); in samsung_rfkill_init_seclinux()
989 if (ret == -EINVAL) in samsung_rfkill_init_swsmi()
994 /* 0x02 seems to mean that the device is no present/available */ in samsung_rfkill_init_swsmi()
997 ret = samsung_new_rfkill(samsung, &samsung->wlan, in samsung_rfkill_init_swsmi()
998 "samsung-wlan", in samsung_rfkill_init_swsmi()
1006 ret = samsung_new_rfkill(samsung, &samsung->bluetooth, in samsung_rfkill_init_swsmi()
1007 "samsung-bluetooth", in samsung_rfkill_init_swsmi()
1023 if (samsung->config->sabi_version == 2) in samsung_rfkill_init()
1025 if (samsung->config->sabi_version == 3) in samsung_rfkill_init()
1032 if (samsung->quirks->lid_handling) in samsung_lid_handling_exit()
1040 if (samsung->quirks->lid_handling) in samsung_lid_handling_init()
1048 const struct sabi_commands *commands = &samsung->config->commands; in kbd_backlight_enable()
1052 if (commands->kbd_backlight == 0xFFFF) in kbd_backlight_enable()
1053 return -ENODEV; in kbd_backlight_enable()
1057 retval = sabi_command(samsung, commands->kbd_backlight, in kbd_backlight_enable()
1064 return -ENODEV; in kbd_backlight_enable()
1070 const struct sabi_commands *commands = &samsung->config->commands; in kbd_backlight_read()
1076 retval = sabi_command(samsung, commands->kbd_backlight, in kbd_backlight_read()
1087 const struct sabi_commands *commands = &samsung->config->commands; in kbd_backlight_write()
1092 return sabi_command(samsung, commands->kbd_backlight, in kbd_backlight_write()
1101 kbd_backlight_write(samsung, samsung->kbd_led_wk); in kbd_led_update()
1111 if (value > samsung->kbd_led.max_brightness) in kbd_led_set()
1112 value = samsung->kbd_led.max_brightness; in kbd_led_set()
1114 samsung->kbd_led_wk = value; in kbd_led_set()
1115 queue_work(samsung->led_workqueue, &samsung->kbd_led_work); in kbd_led_set()
1128 led_classdev_unregister(&samsung->kbd_led); in samsung_leds_exit()
1129 if (samsung->led_workqueue) in samsung_leds_exit()
1130 destroy_workqueue(samsung->led_workqueue); in samsung_leds_exit()
1137 samsung->led_workqueue = create_singlethread_workqueue("led_workqueue"); in samsung_leds_init()
1138 if (!samsung->led_workqueue) in samsung_leds_init()
1139 return -ENOMEM; in samsung_leds_init()
1142 INIT_WORK(&samsung->kbd_led_work, kbd_led_update); in samsung_leds_init()
1144 samsung->kbd_led.name = "samsung::kbd_backlight"; in samsung_leds_init()
1145 samsung->kbd_led.brightness_set = kbd_led_set; in samsung_leds_init()
1146 samsung->kbd_led.brightness_get = kbd_led_get; in samsung_leds_init()
1147 samsung->kbd_led.max_brightness = 8; in samsung_leds_init()
1148 if (samsung->quirks->four_kbd_backlight_levels) in samsung_leds_init()
1149 samsung->kbd_led.max_brightness = 4; in samsung_leds_init()
1151 ret = led_classdev_register(&samsung->platform_device->dev, in samsung_leds_init()
1152 &samsung->kbd_led); in samsung_leds_init()
1163 if (samsung->backlight_device) { in samsung_backlight_exit()
1164 backlight_device_unregister(samsung->backlight_device); in samsung_backlight_exit()
1165 samsung->backlight_device = NULL; in samsung_backlight_exit()
1174 if (!samsung->handle_backlight) in samsung_backlight_init()
1179 props.max_brightness = samsung->config->max_brightness - in samsung_backlight_init()
1180 samsung->config->min_brightness; in samsung_backlight_init()
1183 &samsung->platform_device->dev, in samsung_backlight_init()
1189 samsung->backlight_device = bd; in samsung_backlight_init()
1190 samsung->backlight_device->props.brightness = read_brightness(samsung); in samsung_backlight_init()
1191 samsung->backlight_device->props.power = BACKLIGHT_POWER_ON; in samsung_backlight_init()
1192 backlight_update_status(samsung->backlight_device); in samsung_backlight_init()
1205 ok = !!samsung->config->performance_levels[0].name; in samsung_sysfs_is_visible()
1213 return ok ? attr->mode : 0; in samsung_sysfs_is_visible()
1223 struct platform_device *device = samsung->platform_device; in samsung_sysfs_exit()
1225 sysfs_remove_group(&device->dev.kobj, &platform_attribute_group); in samsung_sysfs_exit()
1230 struct platform_device *device = samsung->platform_device; in samsung_sysfs_init()
1232 return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); in samsung_sysfs_init()
1238 struct samsung_laptop *samsung = m->private; in samsung_laptop_call_show()
1239 struct sabi_data *sdata = &samsung->debug.data; in samsung_laptop_call_show()
1243 samsung->debug.command, in samsung_laptop_call_show()
1244 sdata->d0, sdata->d1, sdata->d2, sdata->d3); in samsung_laptop_call_show()
1246 ret = sabi_command(samsung, samsung->debug.command, sdata, sdata); in samsung_laptop_call_show()
1250 samsung->debug.command); in samsung_laptop_call_show()
1255 sdata->d0, sdata->d1, sdata->d2, sdata->d3); in samsung_laptop_call_show()
1262 debugfs_remove_recursive(samsung->debug.root); in samsung_debugfs_exit()
1269 root = debugfs_create_dir("samsung-laptop", NULL); in samsung_debugfs_init()
1270 samsung->debug.root = root; in samsung_debugfs_init()
1272 samsung->debug.f0000_wrapper.data = samsung->f0000_segment; in samsung_debugfs_init()
1273 samsung->debug.f0000_wrapper.size = 0xffff; in samsung_debugfs_init()
1275 samsung->debug.data_wrapper.data = &samsung->debug.data; in samsung_debugfs_init()
1276 samsung->debug.data_wrapper.size = sizeof(samsung->debug.data); in samsung_debugfs_init()
1278 samsung->debug.sdiag_wrapper.data = samsung->sdiag; in samsung_debugfs_init()
1279 samsung->debug.sdiag_wrapper.size = strlen(samsung->sdiag); in samsung_debugfs_init()
1281 debugfs_create_u16("command", 0644, root, &samsung->debug.command); in samsung_debugfs_init()
1282 debugfs_create_u32("d0", 0644, root, &samsung->debug.data.d0); in samsung_debugfs_init()
1283 debugfs_create_u32("d1", 0644, root, &samsung->debug.data.d1); in samsung_debugfs_init()
1284 debugfs_create_u16("d2", 0644, root, &samsung->debug.data.d2); in samsung_debugfs_init()
1285 debugfs_create_u8("d3", 0644, root, &samsung->debug.data.d3); in samsung_debugfs_init()
1286 debugfs_create_blob("data", 0444, root, &samsung->debug.data_wrapper); in samsung_debugfs_init()
1288 &samsung->debug.f0000_wrapper); in samsung_debugfs_init()
1291 debugfs_create_blob("sdiag", 0444, root, &samsung->debug.sdiag_wrapper); in samsung_debugfs_init()
1296 const struct sabi_config *config = samsung->config; in samsung_sabi_exit()
1299 if (config && config->commands.set_linux != 0xff) in samsung_sabi_exit()
1300 sabi_set_commandb(samsung, config->commands.set_linux, 0x80); in samsung_sabi_exit()
1302 if (samsung->sabi_iface) { in samsung_sabi_exit()
1303 iounmap(samsung->sabi_iface); in samsung_sabi_exit()
1304 samsung->sabi_iface = NULL; in samsung_sabi_exit()
1306 if (samsung->f0000_segment) { in samsung_sabi_exit()
1307 iounmap(samsung->f0000_segment); in samsung_sabi_exit()
1308 samsung->f0000_segment = NULL; in samsung_sabi_exit()
1311 samsung->config = NULL; in samsung_sabi_exit()
1317 const struct sabi_config *config = samsung->config; in samsung_sabi_infos()
1320 loca + 0xf0000 - 6); in samsung_sabi_infos()
1324 readw(samsung->sabi + config->header_offsets.port)); in samsung_sabi_infos()
1326 readb(samsung->sabi + config->header_offsets.iface_func)); in samsung_sabi_infos()
1328 readb(samsung->sabi + config->header_offsets.en_mem)); in samsung_sabi_infos()
1330 readb(samsung->sabi + config->header_offsets.re_mem)); in samsung_sabi_infos()
1332 readw(samsung->sabi + config->header_offsets.data_offset)); in samsung_sabi_infos()
1333 printk(KERN_DEBUG " SABI data segment = 0x%04x\n", in samsung_sabi_infos()
1334 readw(samsung->sabi + config->header_offsets.data_segment)); in samsung_sabi_infos()
1341 int loca = find_signature(samsung->f0000_segment, "SDiaG@"); in samsung_sabi_diag()
1348 * Ident: @SDiaG@686XX-N90X3A/966-SEC-07HL-S90X3A in samsung_sabi_diag()
1354 for (i = 0; loca < 0xffff && i < sizeof(samsung->sdiag) - 1; loca++) { in samsung_sabi_diag()
1355 char temp = readb(samsung->f0000_segment + loca); in samsung_sabi_diag()
1357 if (isalnum(temp) || temp == '/' || temp == '-') in samsung_sabi_diag()
1358 samsung->sdiag[i++] = temp; in samsung_sabi_diag()
1363 if (debug && samsung->sdiag[0]) in samsung_sabi_diag()
1364 pr_info("sdiag: %s", samsung->sdiag); in samsung_sabi_diag()
1376 samsung->f0000_segment = ioremap(0xf0000, 0xffff); in samsung_sabi_init()
1377 if (!samsung->f0000_segment) { in samsung_sabi_init()
1379 pr_err("Can't map the segment at 0xf0000\n"); in samsung_sabi_init()
1380 ret = -EINVAL; in samsung_sabi_init()
1388 samsung->config = &sabi_configs[i]; in samsung_sabi_init()
1389 loca = find_signature(samsung->f0000_segment, in samsung_sabi_init()
1390 samsung->config->test_string); in samsung_sabi_init()
1398 ret = -ENODEV; in samsung_sabi_init()
1402 config = samsung->config; in samsung_sabi_init()
1403 commands = &config->commands; in samsung_sabi_init()
1407 samsung->sabi = (samsung->f0000_segment + loca); in samsung_sabi_init()
1410 ifaceP = (readw(samsung->sabi + config->header_offsets.data_segment) & 0x0ffff) << 4; in samsung_sabi_init()
1411 ifaceP += readw(samsung->sabi + config->header_offsets.data_offset) & 0x0ffff; in samsung_sabi_init()
1416 samsung->sabi_iface = ioremap(ifaceP, 16); in samsung_sabi_init()
1417 if (!samsung->sabi_iface) { in samsung_sabi_init()
1418 pr_err("Can't remap %x\n", ifaceP); in samsung_sabi_init()
1419 ret = -EINVAL; in samsung_sabi_init()
1424 if (commands->set_linux != 0xff) { in samsung_sabi_init()
1426 commands->set_linux, 0x81); in samsung_sabi_init()
1429 ret = -ENODEV; in samsung_sabi_init()
1435 if (samsung->handle_backlight) in samsung_sabi_init()
1439 samsung->config->test_string); in samsung_sabi_init()
1450 if (samsung->platform_device) { in samsung_platform_exit()
1451 platform_device_unregister(samsung->platform_device); in samsung_platform_exit()
1452 samsung->platform_device = NULL; in samsung_platform_exit()
1463 samsung->quirks->enable_kbd_backlight) in samsung_pm_notification()
1466 if (val == PM_POST_HIBERNATION && samsung->quirks->lid_handling) in samsung_pm_notification()
1480 samsung->platform_device = pdev; in samsung_platform_init()
1481 platform_set_drvdata(samsung->platform_device, samsung); in samsung_platform_init()
1489 quirks = d->driver_data; in samsung_dmi_matched()
1519 DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
1562 return -ENODEV; in samsung_init()
1566 return -ENODEV; in samsung_init()
1570 return -ENOMEM; in samsung_init()
1572 mutex_init(&samsung->sabi_mutex); in samsung_init()
1573 samsung->handle_backlight = true; in samsung_init()
1574 samsung->quirks = quirks; in samsung_init()
1577 samsung->handle_backlight = false; in samsung_init()
1609 samsung->pm_nb.notifier_call = samsung_pm_notification; in samsung_init()
1610 register_pm_notifier(&samsung->pm_nb); in samsung_init()
1612 samsung_platform_device = samsung->platform_device; in samsung_init()
1637 unregister_pm_notifier(&samsung->pm_nb); in samsung_exit()
1655 MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>");