Lines Matching +full:gpi +full:- +full:config
1 // SPDX-License-Identifier: GPL-2.0-or-later
33 /* GPIO CONFIG bits */
82 if (data->fan_data[fan][3] & 1) in ucd9000_get_fan_config()
86 fan_config |= (data->fan_data[fan][3] & 0x06) >> 1; in ucd9000_get_fan_config()
99 return -ENXIO; in ucd9000_read_byte_data()
113 return -ENXIO; in ucd9000_read_byte_data()
126 ret = -ENODATA; in ucd9000_read_byte_data()
211 dev_dbg(&client->dev, "failed to read GPIO %d config: %d\n", in ucd9000_gpio_set()
233 dev_dbg(&client->dev, "Failed to write GPIO %d config: %d\n", in ucd9000_gpio_set()
242 dev_dbg(&client->dev, "Failed to write GPIO %d config: %d\n", in ucd9000_gpio_set()
264 int ret, config, out_val; in ucd9000_gpio_set_direction() local
293 config = ret; in ucd9000_gpio_set_direction()
296 ret = i2c_smbus_write_byte_data(client, UCD9000_GPIO_CONFIG, config); in ucd9000_gpio_set_direction()
300 config &= ~UCD9000_GPIO_CONFIG_ENABLE; in ucd9000_gpio_set_direction()
302 return i2c_smbus_write_byte_data(client, UCD9000_GPIO_CONFIG, config); in ucd9000_gpio_set_direction()
324 switch (mid->driver_data) { in ucd9000_probe_gpio()
326 data->gpio.ngpio = UCD9090_NUM_GPIOS; in ucd9000_probe_gpio()
331 data->gpio.ngpio = UCD901XX_NUM_GPIOS; in ucd9000_probe_gpio()
334 data->gpio.ngpio = UCD90320_NUM_GPIOS; in ucd9000_probe_gpio()
337 data->gpio.ngpio = UCD90910_NUM_GPIOS; in ucd9000_probe_gpio()
348 data->gpio.label = client->name; in ucd9000_probe_gpio()
349 data->gpio.get_direction = ucd9000_gpio_get_direction; in ucd9000_probe_gpio()
350 data->gpio.direction_input = ucd9000_gpio_direction_input; in ucd9000_probe_gpio()
351 data->gpio.direction_output = ucd9000_gpio_direction_output; in ucd9000_probe_gpio()
352 data->gpio.get = ucd9000_gpio_get; in ucd9000_probe_gpio()
353 data->gpio.set = ucd9000_gpio_set; in ucd9000_probe_gpio()
354 data->gpio.can_sleep = true; in ucd9000_probe_gpio()
355 data->gpio.base = -1; in ucd9000_probe_gpio()
356 data->gpio.parent = &client->dev; in ucd9000_probe_gpio()
358 rc = devm_gpiochip_add_data(&client->dev, &data->gpio, client); in ucd9000_probe_gpio()
360 dev_warn(&client->dev, "Could not add gpiochip: %d\n", rc); in ucd9000_probe_gpio()
384 struct i2c_client *client = entry->client; in ucd9000_debugfs_show_mfr_status_bit()
393 * GPI fault bits are in sets of 8, two bytes from end of response. in ucd9000_debugfs_show_mfr_status_bit()
395 i = ret - 3 - entry->index / 8; in ucd9000_debugfs_show_mfr_status_bit()
397 *val = !!(buffer[i] & BIT(entry->index % 8)); in ucd9000_debugfs_show_mfr_status_bit()
408 struct i2c_client *client = file->private_data; in ucd9000_debugfs_read_mfr_status()
422 return simple_read_from_buffer(buf, count, ppos, str, res - str); in ucd9000_debugfs_read_mfr_status()
442 return -ENOENT; in ucd9000_init_debugfs()
444 data->debugfs = debugfs_create_dir(client->name, debugfs); in ucd9000_init_debugfs()
445 if (!data->debugfs) in ucd9000_init_debugfs()
446 return -ENOENT; in ucd9000_init_debugfs()
450 * UCD90320, and UCD90910 report GPI faults in their MFR_STATUS in ucd9000_init_debugfs()
451 * register, so only create the GPI fault debugfs attributes for those in ucd9000_init_debugfs()
454 if (mid->driver_data == ucd9090 || mid->driver_data == ucd90160 || in ucd9000_init_debugfs()
455 mid->driver_data == ucd90320 || mid->driver_data == ucd90910) { in ucd9000_init_debugfs()
456 gpi_count = mid->driver_data == ucd90320 ? UCD90320_GPI_COUNT in ucd9000_init_debugfs()
458 entries = devm_kcalloc(&client->dev, in ucd9000_init_debugfs()
462 return -ENOMEM; in ucd9000_init_debugfs()
468 "gpi%d_alarm", i + 1); in ucd9000_init_debugfs()
469 debugfs_create_file(name, 0444, data->debugfs, in ucd9000_init_debugfs()
476 debugfs_create_file(name, 0444, data->debugfs, client, in ucd9000_init_debugfs()
499 if (!i2c_check_functionality(client->adapter, in ucd9000_probe()
502 return -ENODEV; in ucd9000_probe()
507 dev_err(&client->dev, "Failed to read device ID\n"); in ucd9000_probe()
511 dev_info(&client->dev, "Device ID %s\n", block_buffer); in ucd9000_probe()
513 for (mid = ucd9000_id; mid->name[0]; mid++) { in ucd9000_probe()
514 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) in ucd9000_probe()
517 if (!mid->name[0]) { in ucd9000_probe()
518 dev_err(&client->dev, "Unsupported device\n"); in ucd9000_probe()
519 return -ENODEV; in ucd9000_probe()
522 if (client->dev.of_node) in ucd9000_probe()
523 chip = (enum chips)of_device_get_match_data(&client->dev); in ucd9000_probe()
525 chip = mid->driver_data; in ucd9000_probe()
527 if (chip != ucd9000 && strcmp(client->name, mid->name) != 0) in ucd9000_probe()
528 dev_notice(&client->dev, in ucd9000_probe()
530 client->name, mid->name); in ucd9000_probe()
532 data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data), in ucd9000_probe()
535 return -ENOMEM; in ucd9000_probe()
536 info = &data->info; in ucd9000_probe()
540 dev_err(&client->dev, in ucd9000_probe()
544 info->pages = ret; in ucd9000_probe()
545 if (!info->pages) { in ucd9000_probe()
546 dev_err(&client->dev, "No pages configured\n"); in ucd9000_probe()
547 return -ENODEV; in ucd9000_probe()
551 info->func[0] = PMBUS_HAVE_TEMP; in ucd9000_probe()
557 dev_err(&client->dev, "Failed to read configuration data\n"); in ucd9000_probe()
558 return -ENODEV; in ucd9000_probe()
563 if (page >= info->pages) in ucd9000_probe()
569 info->func[page] |= PMBUS_HAVE_VOUT in ucd9000_probe()
573 info->func[page] |= PMBUS_HAVE_TEMP2 in ucd9000_probe()
577 info->func[page] |= PMBUS_HAVE_IOUT in ucd9000_probe()
586 if (mid->driver_data == ucd90124) { in ucd9000_probe()
592 data->fan_data[i]); in ucd9000_probe()
598 info->read_byte_data = ucd9000_read_byte_data; in ucd9000_probe()
599 info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12 in ucd9000_probe()
611 dev_warn(&client->dev, "Failed to register debugfs: %d\n", in ucd9000_probe()