11 #include "sw/device/lib/base/multibits.h"
14 #include "sensor_ctrl_regs.h"
22 return event_idx < SENSOR_CTRL_PARAM_NUM_ALERT_EVENTS;
29 return (mmio_region_read32(sensor_ctrl->
base_addr,
30 SENSOR_CTRL_CFG_REGWEN_REG_OFFSET) == 0);
35 if (sensor_ctrl == NULL) {
39 mmio_region_write32(sensor_ctrl->
base_addr, SENSOR_CTRL_CFG_REGWEN_REG_OFFSET,
49 if (sensor_ctrl == NULL || !is_ast_event_valid(event_idx) || enable == NULL) {
53 uint32_t reg = mmio_region_read32(sensor_ctrl->
base_addr,
54 SENSOR_CTRL_ALERT_TRIG_REG_OFFSET);
64 if (sensor_ctrl == NULL || !is_ast_event_valid(event_idx)) {
68 uint32_t reg = mmio_region_read32(sensor_ctrl->
base_addr,
69 SENSOR_CTRL_ALERT_TRIG_REG_OFFSET);
71 mmio_region_write32(sensor_ctrl->
base_addr, SENSOR_CTRL_ALERT_TRIG_REG_OFFSET,
81 if (sensor_ctrl == NULL || !is_ast_event_valid(event_idx)) {
85 if (is_locked(sensor_ctrl)) {
91 SENSOR_CTRL_ALERT_EN_0_REG_OFFSET + ((ptrdiff_t)event_idx << 2),
101 if (sensor_ctrl == NULL || !is_ast_event_valid(event_idx)) {
105 if (is_locked(sensor_ctrl)) {
109 uint32_t reg = mmio_region_read32(sensor_ctrl->
base_addr,
110 SENSOR_CTRL_FATAL_ALERT_EN_REG_OFFSET);
112 mmio_region_write32(sensor_ctrl->
base_addr,
113 SENSOR_CTRL_FATAL_ALERT_EN_REG_OFFSET, reg);
121 if (sensor_ctrl == NULL || events == NULL) {
125 *events = mmio_region_read32(sensor_ctrl->
base_addr,
126 SENSOR_CTRL_RECOV_ALERT_REG_OFFSET);
135 if (sensor_ctrl == NULL || !is_ast_event_valid(event_idx)) {
140 mmio_region_write32(sensor_ctrl->
base_addr,
141 SENSOR_CTRL_RECOV_ALERT_REG_OFFSET, reg);
149 if (sensor_ctrl == NULL || events == NULL) {
153 *events = mmio_region_read32(sensor_ctrl->
base_addr,
154 SENSOR_CTRL_FATAL_ALERT_REG_OFFSET);
162 if (sensor_ctrl == NULL || done == NULL) {
167 mmio_region_read32(sensor_ctrl->
base_addr, SENSOR_CTRL_STATUS_REG_OFFSET);
178 if (sensor_ctrl == NULL || io_power_status == NULL) {
183 mmio_region_read32(sensor_ctrl->
base_addr, SENSOR_CTRL_STATUS_REG_OFFSET);