Lines Matching +full:integer +full:- +full:n
1 // SPDX-License-Identifier: GPL-2.0-only
79 struct acpi_smbus_cmi *smbus_cmi = adap->algo_data; in acpi_smbus_cmi_access()
90 dev_dbg(&adap->dev, "access size: %d %s\n", size, in acpi_smbus_cmi_access()
98 mt_params[3].integer.value = 0; in acpi_smbus_cmi_access()
100 mt_params[4].integer.value = 0; in acpi_smbus_cmi_access()
108 mt_params[3].integer.value = 0; in acpi_smbus_cmi_access()
110 mt_params[4].integer.value = 0; in acpi_smbus_cmi_access()
120 mt_params[3].integer.value = 1; in acpi_smbus_cmi_access()
122 mt_params[4].integer.value = data->byte; in acpi_smbus_cmi_access()
130 mt_params[3].integer.value = 2; in acpi_smbus_cmi_access()
132 mt_params[4].integer.value = data->word; in acpi_smbus_cmi_access()
139 len = data->block[0]; in acpi_smbus_cmi_access()
141 return -EINVAL; in acpi_smbus_cmi_access()
143 mt_params[3].integer.value = len; in acpi_smbus_cmi_access()
146 mt_params[4].buffer.pointer = data->block + 1; in acpi_smbus_cmi_access()
151 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); in acpi_smbus_cmi_access()
152 return -EOPNOTSUPP; in acpi_smbus_cmi_access()
157 method = smbus_cmi->methods->mt_sbr; in acpi_smbus_cmi_access()
161 method = smbus_cmi->methods->mt_sbw; in acpi_smbus_cmi_access()
167 mt_params[0].integer.value = protocol; in acpi_smbus_cmi_access()
169 mt_params[1].integer.value = addr; in acpi_smbus_cmi_access()
171 mt_params[2].integer.value = command; in acpi_smbus_cmi_access()
173 status = acpi_evaluate_object(smbus_cmi->handle, method, &input, in acpi_smbus_cmi_access()
176 acpi_handle_err(smbus_cmi->handle, in acpi_smbus_cmi_access()
177 "Failed to evaluate %s: %i\n", method, status); in acpi_smbus_cmi_access()
178 return -EIO; in acpi_smbus_cmi_access()
182 if (pkg && pkg->type == ACPI_TYPE_PACKAGE) in acpi_smbus_cmi_access()
183 obj = pkg->package.elements; in acpi_smbus_cmi_access()
185 acpi_handle_err(smbus_cmi->handle, "Invalid argument type\n"); in acpi_smbus_cmi_access()
186 result = -EIO; in acpi_smbus_cmi_access()
189 if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) { in acpi_smbus_cmi_access()
190 acpi_handle_err(smbus_cmi->handle, "Invalid argument type\n"); in acpi_smbus_cmi_access()
191 result = -EIO; in acpi_smbus_cmi_access()
195 result = obj->integer.value; in acpi_smbus_cmi_access()
196 acpi_handle_debug(smbus_cmi->handle, "%s return status: %i\n", method, in acpi_smbus_cmi_access()
204 result = -EBUSY; in acpi_smbus_cmi_access()
207 result = -ETIMEDOUT; in acpi_smbus_cmi_access()
210 result = -ENXIO; in acpi_smbus_cmi_access()
213 result = -EIO; in acpi_smbus_cmi_access()
220 obj = pkg->package.elements + 1; in acpi_smbus_cmi_access()
221 if (obj->type != ACPI_TYPE_INTEGER) { in acpi_smbus_cmi_access()
222 acpi_handle_err(smbus_cmi->handle, "Invalid argument type\n"); in acpi_smbus_cmi_access()
223 result = -EIO; in acpi_smbus_cmi_access()
227 len = obj->integer.value; in acpi_smbus_cmi_access()
228 obj = pkg->package.elements + 2; in acpi_smbus_cmi_access()
233 if (obj->type != ACPI_TYPE_INTEGER) { in acpi_smbus_cmi_access()
234 acpi_handle_err(smbus_cmi->handle, in acpi_smbus_cmi_access()
235 "Invalid argument type\n"); in acpi_smbus_cmi_access()
236 result = -EIO; in acpi_smbus_cmi_access()
240 data->word = obj->integer.value; in acpi_smbus_cmi_access()
242 data->byte = obj->integer.value; in acpi_smbus_cmi_access()
245 if (obj->type != ACPI_TYPE_BUFFER) { in acpi_smbus_cmi_access()
246 acpi_handle_err(smbus_cmi->handle, in acpi_smbus_cmi_access()
247 "Invalid argument type\n"); in acpi_smbus_cmi_access()
248 result = -EIO; in acpi_smbus_cmi_access()
252 return -EPROTO; in acpi_smbus_cmi_access()
253 data->block[0] = len; in acpi_smbus_cmi_access()
254 memcpy(data->block + 1, obj->buffer.pointer, len); in acpi_smbus_cmi_access()
260 dev_dbg(&adap->dev, "Transaction status: %i\n", result); in acpi_smbus_cmi_access()
266 struct acpi_smbus_cmi *smbus_cmi = adapter->algo_data; in acpi_smbus_cmi_func()
269 ret = smbus_cmi->cap_read | smbus_cmi->cap_write ? in acpi_smbus_cmi_func()
272 ret |= smbus_cmi->cap_read ? in acpi_smbus_cmi_func()
278 ret |= smbus_cmi->cap_write ? in acpi_smbus_cmi_func()
297 struct acpi_handle *handle = smbus_cmi->handle; in acpi_smbus_cmi_add_cap()
301 if (!strcmp(name, smbus_cmi->methods->mt_info)) { in acpi_smbus_cmi_add_cap()
302 status = acpi_evaluate_object(smbus_cmi->handle, in acpi_smbus_cmi_add_cap()
303 smbus_cmi->methods->mt_info, in acpi_smbus_cmi_add_cap()
306 acpi_handle_err(handle, "Failed to evaluate %s: %i\n", in acpi_smbus_cmi_add_cap()
307 smbus_cmi->methods->mt_info, status); in acpi_smbus_cmi_add_cap()
308 return -EIO; in acpi_smbus_cmi_add_cap()
312 if (obj && obj->type == ACPI_TYPE_PACKAGE) in acpi_smbus_cmi_add_cap()
313 obj = obj->package.elements; in acpi_smbus_cmi_add_cap()
315 acpi_handle_err(handle, "Invalid argument type\n"); in acpi_smbus_cmi_add_cap()
317 return -EIO; in acpi_smbus_cmi_add_cap()
320 if (obj->type != ACPI_TYPE_INTEGER) { in acpi_smbus_cmi_add_cap()
321 acpi_handle_err(handle, "Invalid argument type\n"); in acpi_smbus_cmi_add_cap()
323 return -EIO; in acpi_smbus_cmi_add_cap()
325 acpi_handle_debug(handle, "SMBus CMI Version %x\n", in acpi_smbus_cmi_add_cap()
326 (int)obj->integer.value); in acpi_smbus_cmi_add_cap()
329 smbus_cmi->cap_info = 1; in acpi_smbus_cmi_add_cap()
330 } else if (!strcmp(name, smbus_cmi->methods->mt_sbr)) in acpi_smbus_cmi_add_cap()
331 smbus_cmi->cap_read = 1; in acpi_smbus_cmi_add_cap()
332 else if (!strcmp(name, smbus_cmi->methods->mt_sbw)) in acpi_smbus_cmi_add_cap()
333 smbus_cmi->cap_write = 1; in acpi_smbus_cmi_add_cap()
335 acpi_handle_debug(handle, "Unsupported CMI method: %s\n", name); in acpi_smbus_cmi_add_cap()
358 struct device *dev = &device->dev; in smbus_cmi_probe()
364 return -ENOMEM; in smbus_cmi_probe()
366 smbus_cmi->handle = ACPI_HANDLE(dev); in smbus_cmi_probe()
367 smbus_cmi->methods = device_get_match_data(dev); in smbus_cmi_probe()
371 smbus_cmi->cap_info = 0; in smbus_cmi_probe()
372 smbus_cmi->cap_read = 0; in smbus_cmi_probe()
373 smbus_cmi->cap_write = 0; in smbus_cmi_probe()
375 acpi_walk_namespace(ACPI_TYPE_METHOD, smbus_cmi->handle, 1, in smbus_cmi_probe()
378 if (smbus_cmi->cap_info == 0) { in smbus_cmi_probe()
379 ret = -ENODEV; in smbus_cmi_probe()
383 snprintf(smbus_cmi->adapter.name, sizeof(smbus_cmi->adapter.name), in smbus_cmi_probe()
385 smbus_cmi->adapter.owner = THIS_MODULE; in smbus_cmi_probe()
386 smbus_cmi->adapter.algo = &acpi_smbus_cmi_algorithm; in smbus_cmi_probe()
387 smbus_cmi->adapter.algo_data = smbus_cmi; in smbus_cmi_probe()
388 smbus_cmi->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; in smbus_cmi_probe()
389 smbus_cmi->adapter.dev.parent = &device->dev; in smbus_cmi_probe()
391 ret = i2c_add_adapter(&smbus_cmi->adapter); in smbus_cmi_probe()
393 dev_err(&device->dev, "Couldn't register adapter!\n"); in smbus_cmi_probe()
408 i2c_del_adapter(&smbus_cmi->adapter); in smbus_cmi_remove()