Zephyr Versal SYSMON Driver Implementation
This page provides details on the implementation of the Versal SYSMON Zephyr driver.
Sensor Layer
The sensor driver does not use a subsystem. Instead, the
Zephyr sensor framework
header (sensor.h) validates the parameters passed and calls the
driver API.
https://xilinx-wiki.atlassian.net/wiki/spaces/A/whiteboard/3435855922
Versal SYSMON Node
Note: Node structure is not yet finalized
sysmon@f1270000 {
compatible = "xlnx,versal-sysmon";
reg = <0x00 0xf1270000 0x00 0x4000>;
interrupts = <0x00 0x90 0x04>;
xlnx,numchannels = [08];
status = "okay";
vccint {
xlnx,register = [00];
xlnx,bipolar;
xlnx,name = "vccint";
};
vccsoc {
xlnx,register = [1f];
xlnx,bipolar;
xlnx,name = "vccsoc";
};
vccram {
xlnx,register = [3f];
xlnx,bipolar;
xlnx,name = "vccram";
};
vccaux {
xlnx,register = [20];
xlnx,bipolar;
xlnx,name = "vccaux";
};
vccbram {
xlnx,register = [5f];
xlnx,name = "vccbram";
};
gtavaux {
xlnx,register = [60];
xlnx,name = "gt_avaux";
};
gtvccaux {
xlnx,register = [40];
xlnx,bipolar;
xlnx,name = "gt_vccaux";
};
vccintir {
xlnx,register = [7f];
xlnx,bipolar;
xlnx,name = "vccint_ir";
};
};
Probe Data From Node
In driver we need to assign the compatible string to a zephyr macro,
DT_DRV_COMPAT. If the assigned string matches with any one of the DT nodes
with status property okay then driver register the Init API to the sensor
framework using a framework structure.
Sensor Framework
Sensor framework has a structure where drivers need to register their APIs by following the same protocol used in the structure that follows,
Framework Structure
__subsystem struct sensor_driver_api {
sensor_attr_set_t attr_set;
sensor_attr_get_t attr_get;
sensor_trigger_set_t trigger_set;
sensor_sample_fetch_t sample_fetch;
sensor_channel_get_t channel_get;
sensor_get_decoder_t get_decoder;
sensor_submit_t submit;
};
Functional Implementation
sensor_attr_set_t
Args: const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val
Set lower/upper thresholds.
Enable/disable interrupt and configure interrupt mode.
Enable/disable averaging.
sensor_attr_get_t
Args: const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val
Get lower/upper thresholds, averaging count, Interrupt mode, and interrupt configuration.
sensor_trigger_set_t
Args: const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler
Register interrupt handler callback based on trigger types.
Trigger types:
SENSOR_TRIG_DATA_READY
SENSOR_TRIG_THRESHOLD
sensor_sample_fetch_t
Args: const struct device *dev, enum sensor_channel chan
Read the raw voltage/temperature values and convert them into actual values.
store the data in driver data structure.
chan types
SENSOR_CHAN_VOLTAGE
SENSOR_CHAN_DIE_TEMP
SENSOR_CHAN_ALL
sensor_channel_get_t
Args: const struct device *dev, enum sensor_channel chan, struct sensor_value *val
Return a useful value for a particular channel, from the driver’s internal data