Lines Matching +full:package +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
21 * * -EIO if there is an issue in acpi_object passed.
25 if (!obj || obj->type != ACPI_TYPE_INTEGER) in get_int_value()
26 return -EIO; in get_int_value()
27 *out = (int)obj->integer.value; in get_int_value()
32 * update_sar_data: sar data is updated based on regulatory mode
36 * context->reg_value will never exceed MAX_REGULATORY
41 &context->config_data[context->reg_value]; in update_sar_data()
43 if (config->device_mode_info && in update_sar_data()
44 context->sar_data.device_mode < config->total_dev_mode) { in update_sar_data()
47 for (itr = 0; itr < config->total_dev_mode; itr++) { in update_sar_data()
48 if (context->sar_data.device_mode == in update_sar_data()
49 config->device_mode_info[itr].device_mode) { in update_sar_data()
51 &config->device_mode_info[itr]; in update_sar_data()
53 context->sar_data.antennatable_index = dev_mode->antennatable_index; in update_sar_data()
54 context->sar_data.bandtable_index = dev_mode->bandtable_index; in update_sar_data()
55 context->sar_data.sartable_index = dev_mode->sartable_index; in update_sar_data()
63 * parse_package: parse acpi package for retrieving SAR information
67 * Given acpi_object is iterated to retrieve information for each device mode.
68 * If a given package corresponding to a specific device mode is faulty, it is
71 * statements in the for loop on encountering error in parsing given device mode.
83 num = &item->package.elements[0]; in parse_package()
89 data = &context->config_data[reg]; in parse_package()
90 if (data->total_dev_mode > MAX_DEV_MODES || data->total_dev_mode == 0 || in parse_package()
91 item->package.count <= data->total_dev_mode) in parse_package()
94 data->device_mode_info = kmalloc_array(data->total_dev_mode, in parse_package()
96 if (!data->device_mode_info) in parse_package()
99 for (itr = 0; itr < data->total_dev_mode; itr++) { in parse_package()
102 num = &item->package.elements[itr + 1]; in parse_package()
103 if (num->type != ACPI_TYPE_PACKAGE || num->package.count < TOTAL_DATA) in parse_package()
105 if (get_int_value(&num->package.elements[0], &temp.device_mode)) in parse_package()
107 if (get_int_value(&num->package.elements[1], &temp.bandtable_index)) in parse_package()
109 if (get_int_value(&num->package.elements[2], &temp.antennatable_index)) in parse_package()
111 if (get_int_value(&num->package.elements[3], &temp.sartable_index)) in parse_package()
113 data->device_mode_info[itr] = temp; in parse_package()
122 * Retrieve the current device mode information from the BIOS.
130 struct wwan_sar_context *context = dev_get_drvdata(&device->dev); in sar_get_device_mode()
135 out = acpi_evaluate_dsm_typed(context->handle, &context->guid, rev, in sar_get_device_mode()
138 dev_err(&device->dev, "DSM cmd:%d Failed to retrieve value\n", COMMAND_ID_DEV_MODE); in sar_get_device_mode()
142 context->sar_data.device_mode = out->integer.value; in sar_get_device_mode()
144 sysfs_notify(&device->dev.kobj, NULL, SYSFS_DATANAME); in sar_get_device_mode()
161 return sysfs_emit(buf, "%d %d %d %d\n", context->sar_data.device_mode, in intc_data_show()
162 context->sar_data.bandtable_index, in intc_data_show()
163 context->sar_data.antennatable_index, in intc_data_show()
164 context->sar_data.sartable_index); in intc_data_show()
172 return sysfs_emit(buf, "%d\n", context->reg_value); in intc_reg_show()
183 return -EINVAL; in intc_reg_store()
188 return -EOVERFLOW; in intc_reg_store()
189 context->reg_value = value; in intc_reg_store()
191 sysfs_notify(&dev->kobj, NULL, SYSFS_DATANAME); in intc_reg_store()
212 dev_err(&device->dev, "sar_get_device_mode error"); in sar_notify()
223 out = acpi_evaluate_dsm_typed(context->handle, &context->guid, rev, in sar_get_data()
227 if (out->package.count >= 3 && in sar_get_data()
228 out->package.elements[0].type == ACPI_TYPE_INTEGER && in sar_get_data()
229 out->package.elements[1].type == ACPI_TYPE_INTEGER && in sar_get_data()
230 out->package.elements[2].type == ACPI_TYPE_PACKAGE && in sar_get_data()
231 out->package.elements[2].package.count > 0) { in sar_get_data()
232 context->config_data[reg].version = out->package.elements[0].integer.value; in sar_get_data()
233 context->config_data[reg].total_dev_mode = in sar_get_data()
234 out->package.elements[1].integer.value; in sar_get_data()
235 if (context->config_data[reg].total_dev_mode <= 0 || in sar_get_data()
236 context->config_data[reg].total_dev_mode > MAX_DEV_MODES) { in sar_get_data()
240 parse_package(context, &out->package.elements[2]); in sar_get_data()
253 return -ENOMEM; in sar_probe()
255 context->sar_device = device; in sar_probe()
256 context->handle = ACPI_HANDLE(&device->dev); in sar_probe()
257 dev_set_drvdata(&device->dev, context); in sar_probe()
259 result = guid_parse(SAR_DSM_UUID, &context->guid); in sar_probe()
261 dev_err(&device->dev, "SAR UUID parse error: %d\n", result); in sar_probe()
269 dev_err(&device->dev, "Failed to get device mode\n"); in sar_probe()
270 result = -EIO; in sar_probe()
274 result = sysfs_create_group(&device->dev.kobj, &intcsar_group); in sar_probe()
276 dev_err(&device->dev, "sysfs creation failed\n"); in sar_probe()
280 if (acpi_install_notify_handler(ACPI_HANDLE(&device->dev), ACPI_DEVICE_NOTIFY, in sar_probe()
282 dev_err(&device->dev, "Failed acpi_install_notify_handler\n"); in sar_probe()
283 result = -EIO; in sar_probe()
289 sysfs_remove_group(&device->dev.kobj, &intcsar_group); in sar_probe()
297 struct wwan_sar_context *context = dev_get_drvdata(&device->dev); in sar_remove()
300 acpi_remove_notify_handler(ACPI_HANDLE(&device->dev), in sar_remove()
302 sysfs_remove_group(&device->dev.kobj, &intcsar_group); in sar_remove()
304 kfree(context->config_data[reg].device_mode_info); in sar_remove()