Lines Matching +full:mux +full:- +full:delay +full:- +full:config +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0-or-later
10 #include <linux/delay.h>
35 /* GPIO CONFIG bits */
81 * make sure that there is a minimum delay between a write access and the
82 * following access. The 500 is based on experimental data. At a delay of
83 * 350us the issue seems to go away. Add a bit of extra margin to allow for
94 if (data->fan_data[fan][3] & 1) in ucd9000_get_fan_config()
98 fan_config |= (data->fan_data[fan][3] & 0x06) >> 1; in ucd9000_get_fan_config()
111 return -ENXIO; in ucd9000_read_byte_data()
125 return -ENXIO; in ucd9000_read_byte_data()
138 ret = -ENODATA; in ucd9000_read_byte_data()
223 dev_dbg(&client->dev, "failed to read GPIO %d config: %d\n", in ucd9000_gpio_set()
245 dev_dbg(&client->dev, "Failed to write GPIO %d config: %d\n", in ucd9000_gpio_set()
254 dev_dbg(&client->dev, "Failed to write GPIO %d config: %d\n", in ucd9000_gpio_set()
276 int ret, config, out_val; in ucd9000_gpio_set_direction() local
305 config = ret; in ucd9000_gpio_set_direction()
308 ret = i2c_smbus_write_byte_data(client, UCD9000_GPIO_CONFIG, config); in ucd9000_gpio_set_direction()
312 config &= ~UCD9000_GPIO_CONFIG_ENABLE; in ucd9000_gpio_set_direction()
314 return i2c_smbus_write_byte_data(client, UCD9000_GPIO_CONFIG, config); in ucd9000_gpio_set_direction()
336 switch (mid->driver_data) { in ucd9000_probe_gpio()
338 data->gpio.ngpio = UCD9090_NUM_GPIOS; in ucd9000_probe_gpio()
343 data->gpio.ngpio = UCD901XX_NUM_GPIOS; in ucd9000_probe_gpio()
346 data->gpio.ngpio = UCD90320_NUM_GPIOS; in ucd9000_probe_gpio()
349 data->gpio.ngpio = UCD90910_NUM_GPIOS; in ucd9000_probe_gpio()
357 * This support should be added when possible given the mux in ucd9000_probe_gpio()
360 data->gpio.label = client->name; in ucd9000_probe_gpio()
361 data->gpio.get_direction = ucd9000_gpio_get_direction; in ucd9000_probe_gpio()
362 data->gpio.direction_input = ucd9000_gpio_direction_input; in ucd9000_probe_gpio()
363 data->gpio.direction_output = ucd9000_gpio_direction_output; in ucd9000_probe_gpio()
364 data->gpio.get = ucd9000_gpio_get; in ucd9000_probe_gpio()
365 data->gpio.set = ucd9000_gpio_set; in ucd9000_probe_gpio()
366 data->gpio.can_sleep = true; in ucd9000_probe_gpio()
367 data->gpio.base = -1; in ucd9000_probe_gpio()
368 data->gpio.parent = &client->dev; in ucd9000_probe_gpio()
370 rc = devm_gpiochip_add_data(&client->dev, &data->gpio, client); in ucd9000_probe_gpio()
372 dev_warn(&client->dev, "Could not add gpiochip: %d\n", rc); in ucd9000_probe_gpio()
396 struct i2c_client *client = entry->client; in ucd9000_debugfs_show_mfr_status_bit()
407 i = ret - 3 - entry->index / 8; in ucd9000_debugfs_show_mfr_status_bit()
409 *val = !!(buffer[i] & BIT(entry->index % 8)); in ucd9000_debugfs_show_mfr_status_bit()
420 struct i2c_client *client = file->private_data; in ucd9000_debugfs_read_mfr_status()
434 return simple_read_from_buffer(buf, count, ppos, str, res - str); in ucd9000_debugfs_read_mfr_status()
454 return -ENOENT; in ucd9000_init_debugfs()
456 data->debugfs = debugfs_create_dir(client->name, debugfs); in ucd9000_init_debugfs()
464 if (mid->driver_data == ucd9090 || mid->driver_data == ucd90160 || in ucd9000_init_debugfs()
465 mid->driver_data == ucd90320 || mid->driver_data == ucd90910) { in ucd9000_init_debugfs()
466 gpi_count = mid->driver_data == ucd90320 ? UCD90320_GPI_COUNT in ucd9000_init_debugfs()
468 entries = devm_kcalloc(&client->dev, in ucd9000_init_debugfs()
472 return -ENOMEM; in ucd9000_init_debugfs()
479 debugfs_create_file(name, 0444, data->debugfs, in ucd9000_init_debugfs()
486 debugfs_create_file(name, 0444, data->debugfs, client, in ucd9000_init_debugfs()
509 if (!i2c_check_functionality(client->adapter, in ucd9000_probe()
512 return -ENODEV; in ucd9000_probe()
517 dev_err(&client->dev, "Failed to read device ID\n"); in ucd9000_probe()
521 dev_info(&client->dev, "Device ID %s\n", block_buffer); in ucd9000_probe()
523 for (mid = ucd9000_id; mid->name[0]; mid++) { in ucd9000_probe()
524 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) in ucd9000_probe()
527 if (!mid->name[0]) { in ucd9000_probe()
528 dev_err(&client->dev, "Unsupported device\n"); in ucd9000_probe()
529 return -ENODEV; in ucd9000_probe()
532 if (client->dev.of_node) in ucd9000_probe()
533 chip = (uintptr_t)of_device_get_match_data(&client->dev); in ucd9000_probe()
535 chip = mid->driver_data; in ucd9000_probe()
537 if (chip != ucd9000 && strcmp(client->name, mid->name) != 0) in ucd9000_probe()
538 dev_notice(&client->dev, in ucd9000_probe()
540 client->name, mid->name); in ucd9000_probe()
542 data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data), in ucd9000_probe()
545 return -ENOMEM; in ucd9000_probe()
546 info = &data->info; in ucd9000_probe()
550 dev_err(&client->dev, in ucd9000_probe()
554 info->pages = ret; in ucd9000_probe()
555 if (!info->pages) { in ucd9000_probe()
556 dev_err(&client->dev, "No pages configured\n"); in ucd9000_probe()
557 return -ENODEV; in ucd9000_probe()
561 info->func[0] = PMBUS_HAVE_TEMP; in ucd9000_probe()
567 dev_err(&client->dev, "Failed to read configuration data\n"); in ucd9000_probe()
568 return -ENODEV; in ucd9000_probe()
573 if (page >= info->pages) in ucd9000_probe()
579 info->func[page] |= PMBUS_HAVE_VOUT in ucd9000_probe()
583 info->func[page] |= PMBUS_HAVE_TEMP2 in ucd9000_probe()
587 info->func[page] |= PMBUS_HAVE_IOUT in ucd9000_probe()
596 if (mid->driver_data == ucd90124) { in ucd9000_probe()
602 data->fan_data[i]); in ucd9000_probe()
608 info->read_byte_data = ucd9000_read_byte_data; in ucd9000_probe()
609 info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12 in ucd9000_probe()
611 } else if (mid->driver_data == ucd90320) { in ucd9000_probe()
612 /* Delay SMBus operations after a write */ in ucd9000_probe()
613 info->write_delay = UCD90320_WAIT_DELAY_US; in ucd9000_probe()
624 dev_warn(&client->dev, "Failed to register debugfs: %d\n", in ucd9000_probe()