2019-05-27 14:55:21 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-09-18 01:40:09 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 ARM Limited
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DRVNAME "vexpress-hwmon"
|
|
|
|
#define pr_fmt(fmt) DRVNAME ": " fmt
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/hwmon.h>
|
|
|
|
#include <linux/hwmon-sysfs.h>
|
|
|
|
#include <linux/module.h>
|
2012-12-31 16:04:59 +08:00
|
|
|
#include <linux/of.h>
|
2012-09-18 01:40:09 +08:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/vexpress.h>
|
|
|
|
|
|
|
|
struct vexpress_hwmon_data {
|
|
|
|
struct device *hwmon_dev;
|
mfd: vexpress: Convert custom func API to regmap
Components of the Versatile Express platform (configuration
microcontrollers on motherboard and daughterboards in particular)
talk to each other over a custom configuration bus. They
provide miscellaneous functions (from clock generator control
to energy sensors) which are represented as platform devices
(and Device Tree nodes). The transactions on the bus can
be generated by different "bridges" in the system, some
of which are universal for the whole platform (for the price
of high transfer latencies), others restricted to a subsystem
(but much faster).
Until now drivers for such functions were using custom "func"
API, which is being replaced in this patch by regmap calls.
This required:
* a rework (and move to drivers/bus directory, as suggested
by Samuel and Arnd) of the config bus core, which is much
simpler now and uses device model infrastructure (class)
to keep track of the bridges; non-DT case (soon to be
retired anyway) is simply covered by a special device
registration function
* the new config-bus driver also takes over device population,
so there is no need for special matching table for
of_platform_populate nor "simple-bus" hack in the arm64
model dtsi file (relevant bindings documentation has
been updated); this allows all the vexpress devices
fit into normal device model, making it possible
to remove plenty of early inits and other hacks in
the near future
* adaptation of the syscfg bridge implementation in the
sysreg driver, again making it much simpler; there is
a special case of the "energy" function spanning two
registers, where they should be both defined in the tree
now, but backward compatibility is maintained in the code
* modification of the relevant drivers:
* hwmon - just a straight-forward API change
* power/reset driver - API change
* regulator - API change plus error handling
simplification
* osc clock driver - this one required larger rework
in order to turn in into a standard platform driver
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Acked-by: Mark Brown <broonie@linaro.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Mike Turquette <mturquette@linaro.org>
2014-04-30 23:46:29 +08:00
|
|
|
struct regmap *reg;
|
2012-09-18 01:40:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static ssize_t vexpress_hwmon_label_show(struct device *dev,
|
|
|
|
struct device_attribute *dev_attr, char *buffer)
|
|
|
|
{
|
|
|
|
const char *label = of_get_property(dev->of_node, "label", NULL);
|
|
|
|
|
hwmon: replace snprintf in show functions with sysfs_emit
coccicheck complains about the use of snprintf() in sysfs
show functions.
drivers/hwmon/ina3221.c:701:8-16: WARNING: use scnprintf or sprintf
This results in a large number of patch submissions. Fix it all in
one go using the following coccinelle rules. Use sysfs_emit instead
of scnprintf or sprintf since that makes more sense.
@depends on patch@
identifier show, dev, attr, buf;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}
@depends on patch@
identifier show, dev, attr, buf, rc;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
rc =
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}
While at it, remove unnecessary braces and as well as unnecessary
else after return statements to address checkpatch warnings in the
resulting patch.
Cc: Zihao Tang <tangzihao1@hisilicon.com>
Cc: Jay Fang <f.fangjian@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-03-22 11:49:10 +08:00
|
|
|
return sysfs_emit(buffer, "%s\n", label);
|
2012-09-18 01:40:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t vexpress_hwmon_u32_show(struct device *dev,
|
|
|
|
struct device_attribute *dev_attr, char *buffer)
|
|
|
|
{
|
|
|
|
struct vexpress_hwmon_data *data = dev_get_drvdata(dev);
|
|
|
|
int err;
|
|
|
|
u32 value;
|
|
|
|
|
mfd: vexpress: Convert custom func API to regmap
Components of the Versatile Express platform (configuration
microcontrollers on motherboard and daughterboards in particular)
talk to each other over a custom configuration bus. They
provide miscellaneous functions (from clock generator control
to energy sensors) which are represented as platform devices
(and Device Tree nodes). The transactions on the bus can
be generated by different "bridges" in the system, some
of which are universal for the whole platform (for the price
of high transfer latencies), others restricted to a subsystem
(but much faster).
Until now drivers for such functions were using custom "func"
API, which is being replaced in this patch by regmap calls.
This required:
* a rework (and move to drivers/bus directory, as suggested
by Samuel and Arnd) of the config bus core, which is much
simpler now and uses device model infrastructure (class)
to keep track of the bridges; non-DT case (soon to be
retired anyway) is simply covered by a special device
registration function
* the new config-bus driver also takes over device population,
so there is no need for special matching table for
of_platform_populate nor "simple-bus" hack in the arm64
model dtsi file (relevant bindings documentation has
been updated); this allows all the vexpress devices
fit into normal device model, making it possible
to remove plenty of early inits and other hacks in
the near future
* adaptation of the syscfg bridge implementation in the
sysreg driver, again making it much simpler; there is
a special case of the "energy" function spanning two
registers, where they should be both defined in the tree
now, but backward compatibility is maintained in the code
* modification of the relevant drivers:
* hwmon - just a straight-forward API change
* power/reset driver - API change
* regulator - API change plus error handling
simplification
* osc clock driver - this one required larger rework
in order to turn in into a standard platform driver
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Acked-by: Mark Brown <broonie@linaro.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Mike Turquette <mturquette@linaro.org>
2014-04-30 23:46:29 +08:00
|
|
|
err = regmap_read(data->reg, 0, &value);
|
2012-09-18 01:40:09 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
hwmon: replace snprintf in show functions with sysfs_emit
coccicheck complains about the use of snprintf() in sysfs
show functions.
drivers/hwmon/ina3221.c:701:8-16: WARNING: use scnprintf or sprintf
This results in a large number of patch submissions. Fix it all in
one go using the following coccinelle rules. Use sysfs_emit instead
of scnprintf or sprintf since that makes more sense.
@depends on patch@
identifier show, dev, attr, buf;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}
@depends on patch@
identifier show, dev, attr, buf, rc;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
rc =
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}
While at it, remove unnecessary braces and as well as unnecessary
else after return statements to address checkpatch warnings in the
resulting patch.
Cc: Zihao Tang <tangzihao1@hisilicon.com>
Cc: Jay Fang <f.fangjian@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-03-22 11:49:10 +08:00
|
|
|
return sysfs_emit(buffer, "%u\n", value /
|
|
|
|
to_sensor_dev_attr(dev_attr)->index);
|
2012-09-18 01:40:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t vexpress_hwmon_u64_show(struct device *dev,
|
|
|
|
struct device_attribute *dev_attr, char *buffer)
|
|
|
|
{
|
|
|
|
struct vexpress_hwmon_data *data = dev_get_drvdata(dev);
|
|
|
|
int err;
|
|
|
|
u32 value_hi, value_lo;
|
|
|
|
|
mfd: vexpress: Convert custom func API to regmap
Components of the Versatile Express platform (configuration
microcontrollers on motherboard and daughterboards in particular)
talk to each other over a custom configuration bus. They
provide miscellaneous functions (from clock generator control
to energy sensors) which are represented as platform devices
(and Device Tree nodes). The transactions on the bus can
be generated by different "bridges" in the system, some
of which are universal for the whole platform (for the price
of high transfer latencies), others restricted to a subsystem
(but much faster).
Until now drivers for such functions were using custom "func"
API, which is being replaced in this patch by regmap calls.
This required:
* a rework (and move to drivers/bus directory, as suggested
by Samuel and Arnd) of the config bus core, which is much
simpler now and uses device model infrastructure (class)
to keep track of the bridges; non-DT case (soon to be
retired anyway) is simply covered by a special device
registration function
* the new config-bus driver also takes over device population,
so there is no need for special matching table for
of_platform_populate nor "simple-bus" hack in the arm64
model dtsi file (relevant bindings documentation has
been updated); this allows all the vexpress devices
fit into normal device model, making it possible
to remove plenty of early inits and other hacks in
the near future
* adaptation of the syscfg bridge implementation in the
sysreg driver, again making it much simpler; there is
a special case of the "energy" function spanning two
registers, where they should be both defined in the tree
now, but backward compatibility is maintained in the code
* modification of the relevant drivers:
* hwmon - just a straight-forward API change
* power/reset driver - API change
* regulator - API change plus error handling
simplification
* osc clock driver - this one required larger rework
in order to turn in into a standard platform driver
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Acked-by: Mark Brown <broonie@linaro.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Mike Turquette <mturquette@linaro.org>
2014-04-30 23:46:29 +08:00
|
|
|
err = regmap_read(data->reg, 0, &value_lo);
|
2012-09-18 01:40:09 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
mfd: vexpress: Convert custom func API to regmap
Components of the Versatile Express platform (configuration
microcontrollers on motherboard and daughterboards in particular)
talk to each other over a custom configuration bus. They
provide miscellaneous functions (from clock generator control
to energy sensors) which are represented as platform devices
(and Device Tree nodes). The transactions on the bus can
be generated by different "bridges" in the system, some
of which are universal for the whole platform (for the price
of high transfer latencies), others restricted to a subsystem
(but much faster).
Until now drivers for such functions were using custom "func"
API, which is being replaced in this patch by regmap calls.
This required:
* a rework (and move to drivers/bus directory, as suggested
by Samuel and Arnd) of the config bus core, which is much
simpler now and uses device model infrastructure (class)
to keep track of the bridges; non-DT case (soon to be
retired anyway) is simply covered by a special device
registration function
* the new config-bus driver also takes over device population,
so there is no need for special matching table for
of_platform_populate nor "simple-bus" hack in the arm64
model dtsi file (relevant bindings documentation has
been updated); this allows all the vexpress devices
fit into normal device model, making it possible
to remove plenty of early inits and other hacks in
the near future
* adaptation of the syscfg bridge implementation in the
sysreg driver, again making it much simpler; there is
a special case of the "energy" function spanning two
registers, where they should be both defined in the tree
now, but backward compatibility is maintained in the code
* modification of the relevant drivers:
* hwmon - just a straight-forward API change
* power/reset driver - API change
* regulator - API change plus error handling
simplification
* osc clock driver - this one required larger rework
in order to turn in into a standard platform driver
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Acked-by: Mark Brown <broonie@linaro.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Mike Turquette <mturquette@linaro.org>
2014-04-30 23:46:29 +08:00
|
|
|
err = regmap_read(data->reg, 1, &value_hi);
|
2012-09-18 01:40:09 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
hwmon: replace snprintf in show functions with sysfs_emit
coccicheck complains about the use of snprintf() in sysfs
show functions.
drivers/hwmon/ina3221.c:701:8-16: WARNING: use scnprintf or sprintf
This results in a large number of patch submissions. Fix it all in
one go using the following coccinelle rules. Use sysfs_emit instead
of scnprintf or sprintf since that makes more sense.
@depends on patch@
identifier show, dev, attr, buf;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}
@depends on patch@
identifier show, dev, attr, buf, rc;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
rc =
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}
While at it, remove unnecessary braces and as well as unnecessary
else after return statements to address checkpatch warnings in the
resulting patch.
Cc: Zihao Tang <tangzihao1@hisilicon.com>
Cc: Jay Fang <f.fangjian@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-03-22 11:49:10 +08:00
|
|
|
return sysfs_emit(buffer, "%llu\n",
|
|
|
|
div_u64(((u64)value_hi << 32) | value_lo,
|
|
|
|
to_sensor_dev_attr(dev_attr)->index));
|
2012-09-18 01:40:09 +08:00
|
|
|
}
|
|
|
|
|
2014-04-24 01:27:05 +08:00
|
|
|
static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj,
|
|
|
|
struct attribute *attr, int index)
|
|
|
|
{
|
|
|
|
struct device *dev = kobj_to_dev(kobj);
|
|
|
|
struct device_attribute *dev_attr = container_of(attr,
|
|
|
|
struct device_attribute, attr);
|
|
|
|
|
|
|
|
if (dev_attr->show == vexpress_hwmon_label_show &&
|
|
|
|
!of_get_property(dev->of_node, "label", NULL))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return attr->mode;
|
|
|
|
}
|
|
|
|
|
2014-04-24 01:27:04 +08:00
|
|
|
struct vexpress_hwmon_type {
|
|
|
|
const char *name;
|
|
|
|
const struct attribute_group **attr_groups;
|
|
|
|
};
|
|
|
|
|
2012-09-18 01:40:09 +08:00
|
|
|
#if !defined(CONFIG_REGULATOR_VEXPRESS)
|
2018-12-11 06:02:23 +08:00
|
|
|
static DEVICE_ATTR(in1_label, 0444, vexpress_hwmon_label_show, NULL);
|
|
|
|
static SENSOR_DEVICE_ATTR_RO(in1_input, vexpress_hwmon_u32, 1000);
|
2014-06-12 22:14:33 +08:00
|
|
|
static struct attribute *vexpress_hwmon_attrs_volt[] = {
|
|
|
|
&dev_attr_in1_label.attr,
|
|
|
|
&sensor_dev_attr_in1_input.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
static struct attribute_group vexpress_hwmon_group_volt = {
|
2014-04-24 01:27:05 +08:00
|
|
|
.is_visible = vexpress_hwmon_attr_is_visible,
|
2012-09-18 01:40:09 +08:00
|
|
|
.attrs = vexpress_hwmon_attrs_volt,
|
|
|
|
};
|
2014-04-24 01:27:04 +08:00
|
|
|
static struct vexpress_hwmon_type vexpress_hwmon_volt = {
|
|
|
|
.name = "vexpress_volt",
|
|
|
|
.attr_groups = (const struct attribute_group *[]) {
|
|
|
|
&vexpress_hwmon_group_volt,
|
|
|
|
NULL,
|
|
|
|
},
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
#endif
|
|
|
|
|
2018-12-11 06:02:23 +08:00
|
|
|
static DEVICE_ATTR(curr1_label, 0444, vexpress_hwmon_label_show, NULL);
|
|
|
|
static SENSOR_DEVICE_ATTR_RO(curr1_input, vexpress_hwmon_u32, 1000);
|
2014-06-12 22:14:33 +08:00
|
|
|
static struct attribute *vexpress_hwmon_attrs_amp[] = {
|
|
|
|
&dev_attr_curr1_label.attr,
|
|
|
|
&sensor_dev_attr_curr1_input.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
static struct attribute_group vexpress_hwmon_group_amp = {
|
2014-04-24 01:27:05 +08:00
|
|
|
.is_visible = vexpress_hwmon_attr_is_visible,
|
2012-09-18 01:40:09 +08:00
|
|
|
.attrs = vexpress_hwmon_attrs_amp,
|
|
|
|
};
|
2014-04-24 01:27:04 +08:00
|
|
|
static struct vexpress_hwmon_type vexpress_hwmon_amp = {
|
|
|
|
.name = "vexpress_amp",
|
|
|
|
.attr_groups = (const struct attribute_group *[]) {
|
|
|
|
&vexpress_hwmon_group_amp,
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
|
2018-12-11 06:02:23 +08:00
|
|
|
static DEVICE_ATTR(temp1_label, 0444, vexpress_hwmon_label_show, NULL);
|
|
|
|
static SENSOR_DEVICE_ATTR_RO(temp1_input, vexpress_hwmon_u32, 1000);
|
2014-06-12 22:14:33 +08:00
|
|
|
static struct attribute *vexpress_hwmon_attrs_temp[] = {
|
|
|
|
&dev_attr_temp1_label.attr,
|
|
|
|
&sensor_dev_attr_temp1_input.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
static struct attribute_group vexpress_hwmon_group_temp = {
|
2014-04-24 01:27:05 +08:00
|
|
|
.is_visible = vexpress_hwmon_attr_is_visible,
|
2012-09-18 01:40:09 +08:00
|
|
|
.attrs = vexpress_hwmon_attrs_temp,
|
|
|
|
};
|
2014-04-24 01:27:04 +08:00
|
|
|
static struct vexpress_hwmon_type vexpress_hwmon_temp = {
|
|
|
|
.name = "vexpress_temp",
|
|
|
|
.attr_groups = (const struct attribute_group *[]) {
|
|
|
|
&vexpress_hwmon_group_temp,
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
|
2018-12-11 06:02:23 +08:00
|
|
|
static DEVICE_ATTR(power1_label, 0444, vexpress_hwmon_label_show, NULL);
|
|
|
|
static SENSOR_DEVICE_ATTR_RO(power1_input, vexpress_hwmon_u32, 1);
|
2014-06-12 22:14:33 +08:00
|
|
|
static struct attribute *vexpress_hwmon_attrs_power[] = {
|
|
|
|
&dev_attr_power1_label.attr,
|
|
|
|
&sensor_dev_attr_power1_input.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
static struct attribute_group vexpress_hwmon_group_power = {
|
2014-04-24 01:27:05 +08:00
|
|
|
.is_visible = vexpress_hwmon_attr_is_visible,
|
2012-09-18 01:40:09 +08:00
|
|
|
.attrs = vexpress_hwmon_attrs_power,
|
|
|
|
};
|
2014-04-24 01:27:04 +08:00
|
|
|
static struct vexpress_hwmon_type vexpress_hwmon_power = {
|
|
|
|
.name = "vexpress_power",
|
|
|
|
.attr_groups = (const struct attribute_group *[]) {
|
|
|
|
&vexpress_hwmon_group_power,
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
|
2018-12-11 06:02:23 +08:00
|
|
|
static DEVICE_ATTR(energy1_label, 0444, vexpress_hwmon_label_show, NULL);
|
|
|
|
static SENSOR_DEVICE_ATTR_RO(energy1_input, vexpress_hwmon_u64, 1);
|
2014-06-12 22:14:33 +08:00
|
|
|
static struct attribute *vexpress_hwmon_attrs_energy[] = {
|
|
|
|
&dev_attr_energy1_label.attr,
|
|
|
|
&sensor_dev_attr_energy1_input.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
static struct attribute_group vexpress_hwmon_group_energy = {
|
2014-04-24 01:27:05 +08:00
|
|
|
.is_visible = vexpress_hwmon_attr_is_visible,
|
2012-09-18 01:40:09 +08:00
|
|
|
.attrs = vexpress_hwmon_attrs_energy,
|
|
|
|
};
|
2014-04-24 01:27:04 +08:00
|
|
|
static struct vexpress_hwmon_type vexpress_hwmon_energy = {
|
|
|
|
.name = "vexpress_energy",
|
|
|
|
.attr_groups = (const struct attribute_group *[]) {
|
|
|
|
&vexpress_hwmon_group_energy,
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
};
|
2012-09-18 01:40:09 +08:00
|
|
|
|
2015-03-17 03:54:36 +08:00
|
|
|
static const struct of_device_id vexpress_hwmon_of_match[] = {
|
2012-09-18 01:40:09 +08:00
|
|
|
#if !defined(CONFIG_REGULATOR_VEXPRESS)
|
|
|
|
{
|
|
|
|
.compatible = "arm,vexpress-volt",
|
2014-04-24 01:27:04 +08:00
|
|
|
.data = &vexpress_hwmon_volt,
|
2012-09-18 01:40:09 +08:00
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
.compatible = "arm,vexpress-amp",
|
2014-04-24 01:27:04 +08:00
|
|
|
.data = &vexpress_hwmon_amp,
|
2012-09-18 01:40:09 +08:00
|
|
|
}, {
|
|
|
|
.compatible = "arm,vexpress-temp",
|
2014-04-24 01:27:04 +08:00
|
|
|
.data = &vexpress_hwmon_temp,
|
2012-09-18 01:40:09 +08:00
|
|
|
}, {
|
|
|
|
.compatible = "arm,vexpress-power",
|
2014-04-24 01:27:04 +08:00
|
|
|
.data = &vexpress_hwmon_power,
|
2012-09-18 01:40:09 +08:00
|
|
|
}, {
|
|
|
|
.compatible = "arm,vexpress-energy",
|
2014-04-24 01:27:04 +08:00
|
|
|
.data = &vexpress_hwmon_energy,
|
2012-09-18 01:40:09 +08:00
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, vexpress_hwmon_of_match);
|
|
|
|
|
|
|
|
static int vexpress_hwmon_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct vexpress_hwmon_data *data;
|
2014-04-24 01:27:04 +08:00
|
|
|
const struct vexpress_hwmon_type *type;
|
2012-09-18 01:40:09 +08:00
|
|
|
|
|
|
|
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
|
|
|
|
if (!data)
|
|
|
|
return -ENOMEM;
|
|
|
|
platform_set_drvdata(pdev, data);
|
|
|
|
|
2022-03-07 11:36:31 +08:00
|
|
|
type = of_device_get_match_data(&pdev->dev);
|
|
|
|
if (!type)
|
2012-09-18 01:40:09 +08:00
|
|
|
return -ENODEV;
|
|
|
|
|
mfd: vexpress: Convert custom func API to regmap
Components of the Versatile Express platform (configuration
microcontrollers on motherboard and daughterboards in particular)
talk to each other over a custom configuration bus. They
provide miscellaneous functions (from clock generator control
to energy sensors) which are represented as platform devices
(and Device Tree nodes). The transactions on the bus can
be generated by different "bridges" in the system, some
of which are universal for the whole platform (for the price
of high transfer latencies), others restricted to a subsystem
(but much faster).
Until now drivers for such functions were using custom "func"
API, which is being replaced in this patch by regmap calls.
This required:
* a rework (and move to drivers/bus directory, as suggested
by Samuel and Arnd) of the config bus core, which is much
simpler now and uses device model infrastructure (class)
to keep track of the bridges; non-DT case (soon to be
retired anyway) is simply covered by a special device
registration function
* the new config-bus driver also takes over device population,
so there is no need for special matching table for
of_platform_populate nor "simple-bus" hack in the arm64
model dtsi file (relevant bindings documentation has
been updated); this allows all the vexpress devices
fit into normal device model, making it possible
to remove plenty of early inits and other hacks in
the near future
* adaptation of the syscfg bridge implementation in the
sysreg driver, again making it much simpler; there is
a special case of the "energy" function spanning two
registers, where they should be both defined in the tree
now, but backward compatibility is maintained in the code
* modification of the relevant drivers:
* hwmon - just a straight-forward API change
* power/reset driver - API change
* regulator - API change plus error handling
simplification
* osc clock driver - this one required larger rework
in order to turn in into a standard platform driver
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Acked-by: Mark Brown <broonie@linaro.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Mike Turquette <mturquette@linaro.org>
2014-04-30 23:46:29 +08:00
|
|
|
data->reg = devm_regmap_init_vexpress_config(&pdev->dev);
|
|
|
|
if (IS_ERR(data->reg))
|
|
|
|
return PTR_ERR(data->reg);
|
2012-09-18 01:40:09 +08:00
|
|
|
|
2014-06-12 22:14:33 +08:00
|
|
|
data->hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev,
|
|
|
|
type->name, data, type->attr_groups);
|
2012-09-18 01:40:09 +08:00
|
|
|
|
2014-06-12 22:14:33 +08:00
|
|
|
return PTR_ERR_OR_ZERO(data->hwmon_dev);
|
2012-09-18 01:40:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver vexpress_hwmon_driver = {
|
|
|
|
.probe = vexpress_hwmon_probe,
|
|
|
|
.driver = {
|
|
|
|
.name = DRVNAME,
|
|
|
|
.of_match_table = vexpress_hwmon_of_match,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module_platform_driver(vexpress_hwmon_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Pawel Moll <pawel.moll@arm.com>");
|
|
|
|
MODULE_DESCRIPTION("Versatile Express hwmon sensors driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS("platform:vexpress-hwmon");
|