Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2012 ARM Limited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define DRVNAME "vexpress-hwmon"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define pr_fmt(fmt) DRVNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/hwmon.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/hwmon-sysfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/of_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/vexpress.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct vexpress_hwmon_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct device *hwmon_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	struct regmap *reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static ssize_t vexpress_hwmon_label_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		struct device_attribute *dev_attr, char *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	const char *label = of_get_property(dev->of_node, "label", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	return snprintf(buffer, PAGE_SIZE, "%s\n", label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static ssize_t vexpress_hwmon_u32_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		struct device_attribute *dev_attr, char *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct vexpress_hwmon_data *data = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	u32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	err = regmap_read(data->reg, 0, &value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	return snprintf(buffer, PAGE_SIZE, "%u\n", value /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			to_sensor_dev_attr(dev_attr)->index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) static ssize_t vexpress_hwmon_u64_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		struct device_attribute *dev_attr, char *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct vexpress_hwmon_data *data = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	u32 value_hi, value_lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	err = regmap_read(data->reg, 0, &value_lo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	err = regmap_read(data->reg, 1, &value_hi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	return snprintf(buffer, PAGE_SIZE, "%llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			div_u64(((u64)value_hi << 32) | value_lo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 			to_sensor_dev_attr(dev_attr)->index));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		struct attribute *attr, int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct device *dev = kobj_to_dev(kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct device_attribute *dev_attr = container_of(attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 				struct device_attribute, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	if (dev_attr->show == vexpress_hwmon_label_show &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			!of_get_property(dev->of_node, "label", NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	return attr->mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) struct vexpress_hwmon_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	const struct attribute_group **attr_groups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #if !defined(CONFIG_REGULATOR_VEXPRESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static DEVICE_ATTR(in1_label, 0444, vexpress_hwmon_label_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static SENSOR_DEVICE_ATTR_RO(in1_input, vexpress_hwmon_u32, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) static struct attribute *vexpress_hwmon_attrs_volt[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	&dev_attr_in1_label.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	&sensor_dev_attr_in1_input.dev_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static struct attribute_group vexpress_hwmon_group_volt = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	.is_visible = vexpress_hwmon_attr_is_visible,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	.attrs = vexpress_hwmon_attrs_volt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) static struct vexpress_hwmon_type vexpress_hwmon_volt = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	.name = "vexpress_volt",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	.attr_groups = (const struct attribute_group *[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		&vexpress_hwmon_group_volt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static DEVICE_ATTR(curr1_label, 0444, vexpress_hwmon_label_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static SENSOR_DEVICE_ATTR_RO(curr1_input, vexpress_hwmon_u32, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static struct attribute *vexpress_hwmon_attrs_amp[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	&dev_attr_curr1_label.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	&sensor_dev_attr_curr1_input.dev_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static struct attribute_group vexpress_hwmon_group_amp = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	.is_visible = vexpress_hwmon_attr_is_visible,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	.attrs = vexpress_hwmon_attrs_amp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static struct vexpress_hwmon_type vexpress_hwmon_amp = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	.name = "vexpress_amp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	.attr_groups = (const struct attribute_group *[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		&vexpress_hwmon_group_amp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static DEVICE_ATTR(temp1_label, 0444, vexpress_hwmon_label_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static SENSOR_DEVICE_ATTR_RO(temp1_input, vexpress_hwmon_u32, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static struct attribute *vexpress_hwmon_attrs_temp[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	&dev_attr_temp1_label.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	&sensor_dev_attr_temp1_input.dev_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static struct attribute_group vexpress_hwmon_group_temp = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	.is_visible = vexpress_hwmon_attr_is_visible,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	.attrs = vexpress_hwmon_attrs_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static struct vexpress_hwmon_type vexpress_hwmon_temp = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	.name = "vexpress_temp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	.attr_groups = (const struct attribute_group *[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		&vexpress_hwmon_group_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static DEVICE_ATTR(power1_label, 0444, vexpress_hwmon_label_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static SENSOR_DEVICE_ATTR_RO(power1_input, vexpress_hwmon_u32, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static struct attribute *vexpress_hwmon_attrs_power[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	&dev_attr_power1_label.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	&sensor_dev_attr_power1_input.dev_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static struct attribute_group vexpress_hwmon_group_power = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	.is_visible = vexpress_hwmon_attr_is_visible,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	.attrs = vexpress_hwmon_attrs_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static struct vexpress_hwmon_type vexpress_hwmon_power = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	.name = "vexpress_power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	.attr_groups = (const struct attribute_group *[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		&vexpress_hwmon_group_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static DEVICE_ATTR(energy1_label, 0444, vexpress_hwmon_label_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static SENSOR_DEVICE_ATTR_RO(energy1_input, vexpress_hwmon_u64, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static struct attribute *vexpress_hwmon_attrs_energy[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	&dev_attr_energy1_label.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	&sensor_dev_attr_energy1_input.dev_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static struct attribute_group vexpress_hwmon_group_energy = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	.is_visible = vexpress_hwmon_attr_is_visible,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	.attrs = vexpress_hwmon_attrs_energy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static struct vexpress_hwmon_type vexpress_hwmon_energy = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	.name = "vexpress_energy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	.attr_groups = (const struct attribute_group *[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		&vexpress_hwmon_group_energy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static const struct of_device_id vexpress_hwmon_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #if !defined(CONFIG_REGULATOR_VEXPRESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		.compatible = "arm,vexpress-volt",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		.data = &vexpress_hwmon_volt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		.compatible = "arm,vexpress-amp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		.data = &vexpress_hwmon_amp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		.compatible = "arm,vexpress-temp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		.data = &vexpress_hwmon_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		.compatible = "arm,vexpress-power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		.data = &vexpress_hwmon_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		.compatible = "arm,vexpress-energy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		.data = &vexpress_hwmon_energy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) MODULE_DEVICE_TABLE(of, vexpress_hwmon_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) static int vexpress_hwmon_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	const struct of_device_id *match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	struct vexpress_hwmon_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	const struct vexpress_hwmon_type *type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	platform_set_drvdata(pdev, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	match = of_match_device(vexpress_hwmon_of_match, &pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	if (!match)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	type = match->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	data->reg = devm_regmap_init_vexpress_config(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	if (IS_ERR(data->reg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		return PTR_ERR(data->reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	data->hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			type->name, data, type->attr_groups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	return PTR_ERR_OR_ZERO(data->hwmon_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static struct platform_driver vexpress_hwmon_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	.probe = vexpress_hwmon_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	.driver	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		.name = DRVNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		.of_match_table = vexpress_hwmon_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) module_platform_driver(vexpress_hwmon_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) MODULE_AUTHOR("Pawel Moll <pawel.moll@arm.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) MODULE_DESCRIPTION("Versatile Express hwmon sensors driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) MODULE_ALIAS("platform:vexpress-hwmon");