mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 15:32:33 +00:00
f5919b65d4
Patch generation process: - rebase rpi/rpi-4.14.y on v4.14.89 from linux-stable - git format-patch v4.14.89 Patches skipped during rebase: - lan78xx: Read MAC address from DT if present - lan78xx: Enable LEDs and auto-negotiation - Revert "softirq: Let ksoftirqd do its job" - sc16is7xx: Fix for multi-channel stall - lan78xx: Ignore DT MAC address if already valid - lan78xx: Simple patch to prevent some crashes - tcp_write_queue_purge clears all the SKBs in the write queue - Revert "lan78xx: Simple patch to prevent some crashes" - lan78xx: Connect phy early - Arm: mm: ftrace: Only set text back to ro after kernel has been marked ro - Revert "Revert "softirq: Let ksoftirqd do its job"" - ASoC: cs4265: SOC_SINGLE register value error fix - Revert "ASoC: cs4265: SOC_SINGLE register value error fix" - Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends" - Revert "Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"" Patches dropped after rebase: - net: Add non-mainline source for rtl8192cu wlan - net: Fix rtl8192cu build errors on other platforms - brcm: adds support for BCM43341 wifi - brcmfmac: Mute expected startup 'errors' - ARM64: Fix build break for RTL8187/RTL8192CU wifi - ARM64: Enable RTL8187/RTL8192CU wifi in build config - This is the driver for Sony CXD2880 DVB-T2/T tuner + demodulator - brcmfmac: add CLM download support - brcmfmac: request_firmware_direct is quieter - Sets the BCDC priority to constant 0 - brcmfmac: Disable ARP offloading when promiscuous - brcmfmac: Avoid possible out-of-bounds read - brcmfmac: Delete redundant length check - net: rtl8192cu: Normalize indentation - net: rtl8192cu: Fix implicit fallthrough warnings - Revert "Sets the BCDC priority to constant 0" - media: cxd2880: Bump to match 4.18.y version - media: cxd2880-spi: Bump to match 4.18.y version - Revert "mm: alloc_contig: re-allow CMA to compact FS pages" - Revert "Revert "mm: alloc_contig: re-allow CMA to compact FS pages"" - cxd2880: CXD2880_SPI_DRV should select DVB_CXD2880 with MEDIA_SUBDRV_AUTOSELECT - 950-0421-HID-hid-bigbenff-driver-for-BigBen-Interactive-PS3OF.patch - 950-0453-Add-hid-bigbenff-to-list-of-have_special_driver-for-.patch Make I2C built-in instead of modular as in upstream defconfig; also the easiest way to get MFD_ARIZONA enabled, which is required by kmod-sound-soc-rpi-cirrus. Add missing compatible strings from 4.9/960-add-rasbperrypi-compatible.patch, using upstream names for compute modules. Add extra patch to enable the LEDs on lan78xx. Compile-tested: bcm2708, bcm2709, bcm2710 (with CONFIG_ALL_KMODS=y) Runtime-tested: bcm2708, bcm2710 Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
246 lines
7.1 KiB
Diff
246 lines
7.1 KiB
Diff
From 97a6a1f61eb949892457a739435fd5280fc800f8 Mon Sep 17 00:00:00 2001
|
|
From: XECDesign <XECDesign@users.noreply.github.com>
|
|
Date: Wed, 29 Aug 2018 15:08:30 +0100
|
|
Subject: [PATCH 412/454] PoE HAT driver cleanup
|
|
|
|
* Fix undeclared variable in rpi_poe_fan_suspend
|
|
* Add SPDX-License-Identifier
|
|
* Expand PoE acronym in Kconfig help
|
|
* Give clearer error message on of_property_count_u32_elems fail
|
|
* Add documentation
|
|
* Add vendor to of_device_id compatible string.
|
|
* Rename m_data_s struct to fw_data_s
|
|
* Fix typos
|
|
|
|
Fixes: #2665
|
|
|
|
Signed-off-by: Serge Schneider <serge@raspberrypi.org>
|
|
---
|
|
.../devicetree/bindings/hwmon/rpi-poe-fan.txt | 55 +++++++++++++++++++
|
|
Documentation/hwmon/rpi-poe-fan | 15 +++++
|
|
.../arm/boot/dts/overlays/rpi-poe-overlay.dts | 2 +-
|
|
drivers/hwmon/Kconfig | 5 +-
|
|
drivers/hwmon/rpi-poe-fan.c | 39 ++++++-------
|
|
5 files changed, 90 insertions(+), 26 deletions(-)
|
|
create mode 100644 Documentation/devicetree/bindings/hwmon/rpi-poe-fan.txt
|
|
create mode 100644 Documentation/hwmon/rpi-poe-fan
|
|
|
|
--- /dev/null
|
|
+++ b/Documentation/devicetree/bindings/hwmon/rpi-poe-fan.txt
|
|
@@ -0,0 +1,55 @@
|
|
+Bindings for the Raspberry Pi PoE HAT fan
|
|
+
|
|
+Required properties:
|
|
+- compatible : "raspberrypi,rpi-poe-fan"
|
|
+- firmware : Reference to the RPi firmware device node
|
|
+- pwms : the PWM that is used to control the PWM fan
|
|
+- cooling-levels : PWM duty cycle values in a range from 0 to 255
|
|
+ which correspond to thermal cooling states
|
|
+
|
|
+Example:
|
|
+ fan0: rpi-poe-fan@0 {
|
|
+ compatible = "raspberrypi,rpi-poe-fan";
|
|
+ firmware = <&firmware>;
|
|
+ cooling-min-state = <0>;
|
|
+ cooling-max-state = <3>;
|
|
+ #cooling-cells = <2>;
|
|
+ cooling-levels = <0 50 150 255>;
|
|
+ status = "okay";
|
|
+ };
|
|
+
|
|
+ thermal-zones {
|
|
+ cpu_thermal: cpu-thermal {
|
|
+ trips {
|
|
+ threshold: trip-point@0 {
|
|
+ temperature = <45000>;
|
|
+ hysteresis = <5000>;
|
|
+ type = "active";
|
|
+ };
|
|
+ target: trip-point@1 {
|
|
+ temperature = <50000>;
|
|
+ hysteresis = <2000>;
|
|
+ type = "active";
|
|
+ };
|
|
+ cpu_hot: cpu_hot@0 {
|
|
+ temperature = <55000>;
|
|
+ hysteresis = <2000>;
|
|
+ type = "active";
|
|
+ };
|
|
+ };
|
|
+ cooling-maps {
|
|
+ map0 {
|
|
+ trip = <&threshold>;
|
|
+ cooling-device = <&fan0 0 1>;
|
|
+ };
|
|
+ map1 {
|
|
+ trip = <&target>;
|
|
+ cooling-device = <&fan0 1 2>;
|
|
+ };
|
|
+ map2 {
|
|
+ trip = <&cpu_hot>;
|
|
+ cooling-device = <&fan0 2 3>;
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+ };
|
|
--- /dev/null
|
|
+++ b/Documentation/hwmon/rpi-poe-fan
|
|
@@ -0,0 +1,15 @@
|
|
+Kernel driver rpi-poe-fan
|
|
+=====================
|
|
+
|
|
+This driver enables the use of the Raspberry Pi PoE HAT fan.
|
|
+
|
|
+Author: Serge Schneider <serge@raspberrypi.org>
|
|
+
|
|
+Description
|
|
+-----------
|
|
+
|
|
+The driver implements a simple interface for driving the Raspberry Pi PoE
|
|
+(Power over Ethernet) HAT fan. The driver passes commands to the Raspberry Pi
|
|
+firmware through the mailbox property interface. The firmware then forwards
|
|
+the commands to the board over I2C on the ID_EEPROM pins. The driver exposes
|
|
+the fan to the user space through the hwmon sysfs interface.
|
|
--- a/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts
|
|
+++ b/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts
|
|
@@ -11,7 +11,7 @@
|
|
target-path = "/";
|
|
__overlay__ {
|
|
fan0: rpi-poe-fan@0 {
|
|
- compatible = "rpi-poe-fan";
|
|
+ compatible = "raspberrypi,rpi-poe-fan";
|
|
firmware = <&firmware>;
|
|
cooling-min-state = <0>;
|
|
cooling-max-state = <3>;
|
|
--- a/drivers/hwmon/Kconfig
|
|
+++ b/drivers/hwmon/Kconfig
|
|
@@ -1287,11 +1287,12 @@ config SENSORS_PWM_FAN
|
|
will be called pwm-fan.
|
|
|
|
config SENSORS_RPI_POE_FAN
|
|
- tristate "Raspberry Pi POE HAT fan"
|
|
+ tristate "Raspberry Pi PoE HAT fan"
|
|
depends on RASPBERRYPI_FIRMWARE
|
|
depends on THERMAL || THERMAL=n
|
|
help
|
|
- If you say yes here you get support for Raspberry Pi POE HAT fan.
|
|
+ If you say yes here you get support for Raspberry Pi PoE (Power over
|
|
+ Ethernet) HAT fan.
|
|
|
|
This driver can also be built as a module. If so, the module
|
|
will be called rpi-poe-fan.
|
|
--- a/drivers/hwmon/rpi-poe-fan.c
|
|
+++ b/drivers/hwmon/rpi-poe-fan.c
|
|
@@ -1,20 +1,11 @@
|
|
+// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
- * rpi-poe-fan.c - Hwmon driver for Raspberry Pi POE HAT fan.
|
|
+ * rpi-poe-fan.c - Hwmon driver for Raspberry Pi PoE HAT fan.
|
|
*
|
|
* Copyright (C) 2018 Raspberry Pi (Trading) Ltd.
|
|
* Based on pwm-fan.c by Kamil Debski <k.debski@samsung.com>
|
|
*
|
|
* Author: Serge Schneider <serge@raspberrypi.org>
|
|
- *
|
|
- * This program is free software; you can redistribute it and/or modify
|
|
- * it under the terms of the GNU General Public License as published by
|
|
- * the Free Software Foundation; either version 2 of the License, or
|
|
- * (at your option) any later version.
|
|
- *
|
|
- * This program is distributed in the hope that it will be useful,
|
|
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
- * GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <linux/hwmon.h>
|
|
@@ -46,41 +37,41 @@ struct rpi_poe_fan_ctx {
|
|
struct notifier_block nb;
|
|
};
|
|
|
|
-struct m_data_s{
|
|
+struct fw_tag_data_s{
|
|
u32 reg;
|
|
u32 val;
|
|
u32 ret;
|
|
};
|
|
|
|
static int write_reg(struct rpi_firmware *fw, u32 reg, u32 *val){
|
|
- struct m_data_s m_data = {
|
|
+ struct fw_tag_data_s fw_tag_data = {
|
|
.reg = reg,
|
|
.val = *val
|
|
};
|
|
int ret;
|
|
ret = rpi_firmware_property(fw, RPI_FIRMWARE_SET_POE_HAT_VAL,
|
|
- &m_data, sizeof(m_data));
|
|
+ &fw_tag_data, sizeof(fw_tag_data));
|
|
if (ret) {
|
|
return ret;
|
|
- } else if (m_data.ret) {
|
|
+ } else if (fw_tag_data.ret) {
|
|
return -EIO;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int read_reg(struct rpi_firmware *fw, u32 reg, u32 *val){
|
|
- struct m_data_s m_data = {
|
|
+ struct fw_tag_data_s fw_tag_data = {
|
|
.reg = reg,
|
|
};
|
|
int ret;
|
|
ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_POE_HAT_VAL,
|
|
- &m_data, sizeof(m_data));
|
|
+ &fw_tag_data, sizeof(fw_tag_data));
|
|
if (ret) {
|
|
return ret;
|
|
- } else if (m_data.ret) {
|
|
+ } else if (fw_tag_data.ret) {
|
|
return -EIO;
|
|
}
|
|
- *val = m_data.val;
|
|
+ *val = fw_tag_data.val;
|
|
return 0;
|
|
}
|
|
|
|
@@ -268,7 +259,8 @@ static int rpi_poe_fan_of_get_cooling_da
|
|
|
|
ret = of_property_count_u32_elems(np, "cooling-levels");
|
|
if (ret <= 0) {
|
|
- dev_err(dev, "Wrong data!\n");
|
|
+ dev_err(dev, "cooling-levels property missing or invalid: %d\n",
|
|
+ ret);
|
|
return ret ? : -EINVAL;
|
|
}
|
|
|
|
@@ -397,10 +389,11 @@ static int rpi_poe_fan_suspend(struct de
|
|
{
|
|
struct rpi_poe_fan_ctx *ctx = dev_get_drvdata(dev);
|
|
u32 value = 0;
|
|
+ int ret = 0;
|
|
|
|
if (ctx->pwm_value != value)
|
|
ret = write_reg(ctx->fw, POE_CUR_PWM, &value);
|
|
- return 0;
|
|
+ return ret;
|
|
}
|
|
|
|
static int rpi_poe_fan_resume(struct device *dev)
|
|
@@ -420,7 +413,7 @@ static SIMPLE_DEV_PM_OPS(rpi_poe_fan_pm,
|
|
rpi_poe_fan_resume);
|
|
|
|
static const struct of_device_id of_rpi_poe_fan_match[] = {
|
|
- { .compatible = "rpi-poe-fan", },
|
|
+ { .compatible = "raspberrypi,rpi-poe-fan", },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, of_rpi_poe_fan_match);
|
|
@@ -439,5 +432,5 @@ module_platform_driver(rpi_poe_fan_drive
|
|
|
|
MODULE_AUTHOR("Serge Schneider <serge@raspberrypi.org>");
|
|
MODULE_ALIAS("platform:rpi-poe-fan");
|
|
-MODULE_DESCRIPTION("Raspberry Pi POE HAT fan driver");
|
|
+MODULE_DESCRIPTION("Raspberry Pi PoE HAT fan driver");
|
|
MODULE_LICENSE("GPL");
|