83065dd1610b966aebd523ee5131ec2e989b5f67
[openwrt/staging/mkresin.git] /
1 From 53250b67aca386f2e01881623c192089226bbae3 Mon Sep 17 00:00:00 2001
2 From: Stefan Wahren <stefan.wahren@i2se.com>
3 Date: Sat, 13 Oct 2018 13:31:21 +0200
4 Subject: [PATCH 147/725] firmware: raspberrypi: Add backward compatible
5 get_throttled
6
7 Avoid a hard userspace ABI change by adding a compatible get_throttled
8 sysfs entry. Its value is now feed by the GET_THROTTLED requests of the
9 new hwmon driver. The first access to get_throttled will generate
10 a warning.
11
12 Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
13 ---
14 drivers/firmware/raspberrypi.c | 33 +++++++++++++++++++++++++++++++++
15 1 file changed, 33 insertions(+)
16
17 --- a/drivers/firmware/raspberrypi.c
18 +++ b/drivers/firmware/raspberrypi.c
19 @@ -31,6 +31,7 @@ struct rpi_firmware {
20 struct mbox_chan *chan; /* The property channel. */
21 struct completion c;
22 u32 enabled;
23 + u32 get_throttled;
24 };
25
26 static struct platform_device *g_pdev;
27 @@ -171,6 +172,12 @@ int rpi_firmware_property(struct rpi_fir
28 data + sizeof(struct rpi_firmware_property_tag_header),
29 buf_size);
30
31 + if ((tag == RPI_FIRMWARE_GET_THROTTLED) &&
32 + memcmp(&fw->get_throttled, tag_data, sizeof(fw->get_throttled))) {
33 + memcpy(&fw->get_throttled, tag_data, sizeof(fw->get_throttled));
34 + sysfs_notify(&fw->cl.dev->kobj, NULL, "get_throttled");
35 + }
36 +
37 return ret;
38 }
39 EXPORT_SYMBOL_GPL(rpi_firmware_property);
40 @@ -195,6 +202,27 @@ static int rpi_firmware_notify_reboot(st
41 return 0;
42 }
43
44 +static ssize_t get_throttled_show(struct device *dev,
45 + struct device_attribute *attr, char *buf)
46 +{
47 + struct rpi_firmware *fw = dev_get_drvdata(dev);
48 +
49 + WARN_ONCE(1, "deprecated, use hwmon sysfs instead\n");
50 +
51 + return sprintf(buf, "%x\n", fw->get_throttled);
52 +}
53 +
54 +static DEVICE_ATTR_RO(get_throttled);
55 +
56 +static struct attribute *rpi_firmware_dev_attrs[] = {
57 + &dev_attr_get_throttled.attr,
58 + NULL,
59 +};
60 +
61 +static const struct attribute_group rpi_firmware_dev_group = {
62 + .attrs = rpi_firmware_dev_attrs,
63 +};
64 +
65 static void
66 rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
67 {
68 @@ -227,6 +255,11 @@ rpi_register_hwmon_driver(struct device
69
70 rpi_hwmon = platform_device_register_data(dev, "raspberrypi-hwmon",
71 -1, NULL, 0);
72 +
73 + if (!IS_ERR_OR_NULL(rpi_hwmon)) {
74 + if (devm_device_add_group(dev, &rpi_firmware_dev_group))
75 + dev_err(dev, "Failed to create get_trottled attr\n");
76 + }
77 }
78
79 static int rpi_firmware_probe(struct platform_device *pdev)