firmware: raspberrypi: Register hwmon driver
authorStefan Wahren <stefan.wahren@i2se.com>
Fri, 25 May 2018 19:24:36 +0000 (21:24 +0200)
committerFlorian Fainelli <f.fainelli@gmail.com>
Mon, 9 Jul 2018 17:47:28 +0000 (10:47 -0700)
Since the raspberrypi-hwmon driver is tied to the VC4 firmware instead of
particular hardware its registration should be in the firmware driver.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
drivers/firmware/raspberrypi.c

index 6692888..0602626 100644 (file)
@@ -21,6 +21,8 @@
 #define MBOX_DATA28(msg)               ((msg) & ~0xf)
 #define MBOX_CHAN_PROPERTY             8
 
+static struct platform_device *rpi_hwmon;
+
 struct rpi_firmware {
        struct mbox_client cl;
        struct mbox_chan *chan; /* The property channel. */
@@ -183,6 +185,20 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
        }
 }
 
+static void
+rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)
+{
+       u32 packet;
+       int ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_THROTTLED,
+                                       &packet, sizeof(packet));
+
+       if (ret)
+               return;
+
+       rpi_hwmon = platform_device_register_data(dev, "raspberrypi-hwmon",
+                                                 -1, NULL, 0);
+}
+
 static int rpi_firmware_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -209,6 +225,7 @@ static int rpi_firmware_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, fw);
 
        rpi_firmware_print_firmware_revision(fw);
+       rpi_register_hwmon_driver(dev, fw);
 
        return 0;
 }
@@ -217,6 +234,8 @@ static int rpi_firmware_remove(struct platform_device *pdev)
 {
        struct rpi_firmware *fw = platform_get_drvdata(pdev);
 
+       platform_device_unregister(rpi_hwmon);
+       rpi_hwmon = NULL;
        mbox_free_channel(fw->chan);
 
        return 0;