Commit df2ec156 authored by Stefan Reinauer's avatar Stefan Reinauer 🤠
Browse files

Add sysfs file with monitoring information


Signed-off-by: Stefan Reinauer's avatarStefan Reinauer <stefan.reinauer@coreboot.org>
parent 92ea53d6
......@@ -21,6 +21,7 @@ struct zz9000_platform_data {
struct resource *res[5];
struct zorro_dev *zdev;
struct fb_info *fb_info;
struct device *sysfs_root;
int fb_size;
};
......
......@@ -14,11 +14,46 @@ struct zz9000_platform_data *get_zz9000_data(void)
}
EXPORT_SYMBOL_GPL(get_zz9000_data);
static ssize_t zz9000_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
int pos = 0;
uint16_t temp;
pos += sprintf(buf + pos, "MNT ZZ9000 Zorro %s found at 0x%08x\n",
is_zorro3(zz9000_data->zdev) ? "III" : "II", zz9000_data->zdev->resource.start);
pos += sprintf(buf + pos, " driver version: %s\n", ZZ9000_VERSION);
pos += sprintf(buf + pos, " HW version: %d\n", zz_readw(MNTZZ_HW_VERSION));
pos += sprintf(buf + pos, " FW version: %d.%d\n", zz_readw(MNTZZ_FW_VERSION) >> 8,
zz_readw(MNTZZ_FW_VERSION) & 0xff);
temp = zz_readw(MNTZZ_TEMPERATURE);
pos += sprintf(buf + pos, " Temperature: %d.%02d°C\n", temp / 10, temp % 10);
temp = zz_readw(MNTZZ_VOLTAGE_AUX);
pos += sprintf(buf + pos, " Voltage Vaux: %d.%02dV\n", temp / 100, temp % 100);
temp = zz_readw(MNTZZ_VOLTAGE_INT);
pos += sprintf(buf + pos, " Voltage Vint: %d.%02dV\n", temp / 100, temp % 100);
printk(KERN_INFO "Bytes read: %d\n", pos);
}
static ssize_t zz9000_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
// Nothing to do here.
return count;
}
static struct kobj_attribute zz9000_info_attribute =
__ATTR(info, 0664, zz9000_show, zz9000_store);
static void zz9000_remove(struct zorro_dev *zdev)
{
struct zz9000_platform_data *zz9000_data = zorro_get_drvdata(zdev);
uint32_t board = zdev->resource.start;
if (zz9000_data->sysfs_root)
root_device_unregister(zz9000_data->sysfs_root);
if (zz9000_data->registers)
iounmap(zz9000_data->registers);
if (zz9000_data->eth_rx_mem)
......@@ -125,6 +160,19 @@ static int zz9000_probe(struct zorro_dev *zdev,
temp = zz_readw(MNTZZ_VOLTAGE_INT);
printk(KERN_INFO " Voltage Vint %d.%02dV\n", temp / 100, temp % 100);
zz9000_data->sysfs_root = root_device_register("zz9000");
if(!zz9000_data->sysfs_root) {
ret = -ENOMEM;
goto cleanup;
}
ret = sysfs_create_file(&zz9000_data->sysfs_root->kobj,
&zz9000_info_attribute.attr);
if (ret) {
pr_debug("Failed to create /sys/devices/zz9000/info\n");
}
if (!ret)
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment