#include <linux/device.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/workqueue.h>
#include <soc/bcm2835/raspberrypi-firmware.h>
#define UNDERVOLTAGE_STICKY_BIT BIT(16)
struct device *hwmon_dev;
struct delayed_work get_values_poll_work;
static void rpi_firmware_get_throttled(struct rpi_hwmon_data *data)
u32 new_uv, old_uv, value;
ret = rpi_firmware_property(data->fw, RPI_FIRMWARE_GET_THROTTLED,
dev_err_once(data->hwmon_dev, "Failed to get throttled (%d)\n",
new_uv = value & UNDERVOLTAGE_STICKY_BIT;
old_uv = data->last_throttled & UNDERVOLTAGE_STICKY_BIT;
data->last_throttled = value;
dev_crit(data->hwmon_dev, "Undervoltage detected!\n");
dev_info(data->hwmon_dev, "Voltage normalised\n");
sysfs_notify(&data->hwmon_dev->kobj, NULL, "in0_lcrit_alarm");
static void get_values_poll(struct work_struct *work)
struct rpi_hwmon_data *data;
data = container_of(work, struct rpi_hwmon_data,
get_values_poll_work.work);