Commit 705c9c41 authored by Luis Fernando Ruiz's avatar Luis Fernando Ruiz Committed by Alessandro Rubini

Temperature attribute exported to sysfs.

New temperature attribute added for reading in fd_zio_info_get().
parent f08b523a
...@@ -660,10 +660,10 @@ directory is @i{/sys/bus/zio/devices/fd-0200}: ...@@ -660,10 +660,10 @@ directory is @i{/sys/bus/zio/devices/fd-0200}:
@smallexample @smallexample
spusa# ls -Ff /sys/bus/zio/devices/fd-0200/ spusa# ls -Ff /sys/bus/zio/devices/fd-0200/
./ enable utc-l power/ fd-ch2/ ./ enable utc-l subsystem fd-ch1/
../ resolution-bits coarse driver fd-ch3/ ../ resolution-bits coarse power/ fd-ch2/
uevent version command fd-input/ fd-ch4/ uevent version command driver fd-ch3/
name utc-h subsystem fd-ch1/ name utc-h temperature fd-input/ fd-ch4/
@end smallexample @end smallexample
@c ========================================================================== @c ==========================================================================
...@@ -671,7 +671,8 @@ directory is @i{/sys/bus/zio/devices/fd-0200}: ...@@ -671,7 +671,8 @@ directory is @i{/sys/bus/zio/devices/fd-0200}:
@section Device Attributes @section Device Attributes
Device-wide attributes are the three time tags (@i{utc-h}, @i{utc-l}, Device-wide attributes are the three time tags (@i{utc-h}, @i{utc-l},
@i{coarse}), a read-only @i{version} and a write-only @i{command}. @i{coarse}), a read-only @i{version}, a read-only @i{temperature}
and a write-only @i{command}.
To read device time you To read device time you
should read @i{utc-h} first. Reading @u{utc-h} will atomically read should read @i{utc-h} first. Reading @u{utc-h} will atomically read
all values from the card and store them in the software driver: when all values from the card and store them in the software driver: when
...@@ -697,6 +698,16 @@ last: writing @i{utc-h} atomically programs the hardware: ...@@ -697,6 +698,16 @@ last: writing @i{utc-h} atomically programs the hardware:
10003 10003
@end smallexample @end smallexample
The temperature value is scaled by four bits, so you need divide it by
16 to obtain the value in degrees. In this example:
@smallexample
spusa# cat temperature
1129
@end smallexample
Temperature is 70.5625 degrees.
If you write 0 to @i{command}, board time will be If you write 0 to @i{command}, board time will be
synchronized to the current Linux clock within one microsecond synchronized to the current Linux clock within one microsecond
(reading Linux time and writing to the @i{fine-delay} registers is (reading Linux time and writing to the @i{fine-delay} registers is
......
...@@ -44,6 +44,7 @@ static struct zio_attribute fd_zattr_dev[] = { ...@@ -44,6 +44,7 @@ static struct zio_attribute fd_zattr_dev[] = {
ZATTR_EXT_REG("utc-l", _RW_, FD_ATTR_DEV_UTC_L, 0), ZATTR_EXT_REG("utc-l", _RW_, FD_ATTR_DEV_UTC_L, 0),
ZATTR_EXT_REG("coarse", _RW_, FD_ATTR_DEV_COARSE, 0), ZATTR_EXT_REG("coarse", _RW_, FD_ATTR_DEV_COARSE, 0),
ZATTR_EXT_REG("command", S_IWUGO, FD_ATTR_DEV_COMMAND, 0), ZATTR_EXT_REG("command", S_IWUGO, FD_ATTR_DEV_COMMAND, 0),
ZATTR_EXT_REG("temperature", _RW_, FD_ATTR_DEV_TEMP, 0),
}; };
/* Extended attributes for the TDC (== input) cset */ /* Extended attributes for the TDC (== input) cset */
...@@ -191,13 +192,20 @@ static int fd_zio_info_get(struct device *dev, struct zio_attribute *zattr, ...@@ -191,13 +192,20 @@ static int fd_zio_info_get(struct device *dev, struct zio_attribute *zattr,
if (__fd_get_type(dev) == FD_TYPE_OUTPUT) if (__fd_get_type(dev) == FD_TYPE_OUTPUT)
return fd_zio_info_output(dev, zattr, usr_val); return fd_zio_info_output(dev, zattr, usr_val);
/* reading temperature */
zdev = to_zio_dev(dev);
attr = zdev->zattr_set.ext_zattr;
fd = zdev->private_data;
if (zattr->priv.addr == FD_ATTR_DEV_TEMP) {
attr[FD_ATTR_DEV_TEMP].value = fd_read_temp(fd, 0);
return 0;
}
/* following is whole-dev */ /* following is whole-dev */
if (zattr->priv.addr != FD_ATTR_DEV_UTC_H) if (zattr->priv.addr != FD_ATTR_DEV_UTC_H)
return 0; return 0;
/* reading utc-h calls an atomic get-time */ /* reading utc-h calls an atomic get-time */
zdev = to_zio_dev(dev);
attr = zdev->zattr_set.ext_zattr;
fd = zdev->private_data;
fd_time_get(fd, &t, NULL); fd_time_get(fd, &t, NULL);
attr[FD_ATTR_DEV_UTC_H].value = t.utc >> 32; attr[FD_ATTR_DEV_UTC_H].value = t.utc >> 32;
attr[FD_ATTR_DEV_UTC_L].value = t.utc & 0xffffffff; attr[FD_ATTR_DEV_UTC_L].value = t.utc & 0xffffffff;
......
...@@ -23,7 +23,7 @@ enum fd_zattr_dev_idx { ...@@ -23,7 +23,7 @@ enum fd_zattr_dev_idx {
FD_ATTR_DEV_UTC_L, FD_ATTR_DEV_UTC_L,
FD_ATTR_DEV_COARSE, FD_ATTR_DEV_COARSE,
FD_ATTR_DEV_COMMAND, /* see below for commands */ FD_ATTR_DEV_COMMAND, /* see below for commands */
FD_ATTR_DEV_RESERVE_5, FD_ATTR_DEV_TEMP,
FD_ATTR_DEV_RESERVE_6, FD_ATTR_DEV_RESERVE_6,
FD_ATTR_DEV_RESERVE_7, FD_ATTR_DEV_RESERVE_7,
FD_ATTR_DEV__LAST, FD_ATTR_DEV__LAST,
......
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