@@ -60,6 +60,7 @@ struct adm1266_data {
const char *gpio_names[ADM1266_GPIO_NR + ADM1266_PDIO_NR];
struct i2c_client *client;
struct mutex ioctl_mutex; /* lock ioctl access */
+ struct dentry *debugfs_dir;
struct nvmem_config nvmem_config;
struct nvmem_device *nvmem;
u8 *dev_mem;
@@ -406,6 +407,28 @@ static const struct proc_ops adm1266_proc_ops = {
.proc_ioctl = adm1266_ioctl,
};
+static int adm1266_blackbox_information_read(struct seq_file *s, void *pdata)
+{
+ struct device *dev = s->private;
+ struct i2c_client *client = to_i2c_client(dev);
+ u8 read_buf[5];
+ unsigned int latest_id;
+ int ret;
+
+ ret = i2c_smbus_read_block_data(client, ADM1266_BLACKBOX_INFO,
+ read_buf);
+ if (ret < 0)
+ return ret;
+
+ seq_puts(s, "BLACKBOX_INFORMATION:\n");
+ latest_id = read_buf[0] + (read_buf[1] << 8);
+ seq_printf(s, "Black box ID: %u\n", latest_id);
+ seq_printf(s, "Logic index: %u\n", read_buf[2]);
+ seq_printf(s, "Record count: %u\n", read_buf[3]);
+
+ return 0;
+}
+
static int adm1266_init_procfs(struct adm1266_data *data)
{
struct proc_dir_entry *proc_dir;
@@ -423,6 +446,29 @@ static int adm1266_init_procfs(struct adm1266_data *data)
return 0;
}
+static int adm1266_init_debugfs(struct adm1266_data *data)
+{
+ struct dentry *entry;
+ struct dentry *root;
+
+ root = pmbus_get_debugfs_dir(data->client);
+ if (!root)
+ return -ENOENT;
+
+ data->debugfs_dir = debugfs_create_dir(data->client->name, root);
+ if (!data->debugfs_dir)
+ return -ENOENT;
+
+ entry = debugfs_create_devm_seqfile(&data->client->dev,
+ "blackbox_information",
+ data->debugfs_dir,
+ adm1266_blackbox_information_read);
+ if (!entry)
+ return -ENOENT;
+
+ return 0;
+}
+
static int adm1266_nvmem_read_blackbox(struct adm1266_data *data, u8 *buf)
{
u8 read_buf[5];
@@ -571,7 +617,15 @@ static int adm1266_probe(struct i2c_client *client,
for (i = 0; i < info->pages; i++)
info->func[i] = funcs;
- return pmbus_do_probe(client, id, info);
+ ret = pmbus_do_probe(client, id, info);
+ if (ret)
+ return ret;
+
+ ret = adm1266_init_debugfs(data);
+ if (ret)
+ dev_warn(&client->dev, "Failed to register debugfs: %d\n", ret);
+
+ return 0;
}
static const struct of_device_id adm1266_of_match[] = {