Browse Source

Add sysfs file with monitoring information

Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
master
Stefan Reinauer 8 months ago
parent
commit
df2ec1569a
2 changed files with 49 additions and 0 deletions
  1. +1
    -0
      zz9000.h
  2. +48
    -0
      zz9000_core.c

+ 1
- 0
zz9000.h View File

@@ -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;
};



+ 48
- 0
zz9000_core.c View File

@@ -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;



Loading…
Cancel
Save