summaryrefslogtreecommitdiff
path: root/target/linux/brcm2708/patches-3.10/0052-Add-retry-on-error-and-tidy-of-temperature-driver.patch
diff options
context:
space:
mode:
authorflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2014-02-28 20:30:08 +0000
committerflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2014-02-28 20:30:08 +0000
commita08a7ff8689d7bdafdc4d545b033ca91b067cbcc (patch)
tree70158d97f68604d69da8da779507469cf930bf07 /target/linux/brcm2708/patches-3.10/0052-Add-retry-on-error-and-tidy-of-temperature-driver.patch
parentb276c3da17145991bcf3c2a63f50963654f9b878 (diff)
brcm2708: update against latest rpi-3.10.y branch
Update our copies of the brcm2708 patches to the latest rpi-3.10-y rebased against linux-3.10.y stable (3.10.32). This should hopefully make it easier for us in the future to leverage the raspberry/rpi-* branches. Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@39770 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/brcm2708/patches-3.10/0052-Add-retry-on-error-and-tidy-of-temperature-driver.patch')
-rw-r--r--target/linux/brcm2708/patches-3.10/0052-Add-retry-on-error-and-tidy-of-temperature-driver.patch124
1 files changed, 124 insertions, 0 deletions
diff --git a/target/linux/brcm2708/patches-3.10/0052-Add-retry-on-error-and-tidy-of-temperature-driver.patch b/target/linux/brcm2708/patches-3.10/0052-Add-retry-on-error-and-tidy-of-temperature-driver.patch
new file mode 100644
index 0000000000..6789241fe6
--- /dev/null
+++ b/target/linux/brcm2708/patches-3.10/0052-Add-retry-on-error-and-tidy-of-temperature-driver.patch
@@ -0,0 +1,124 @@
+From 2e7a6ee154b800b1e749e99d20a29673eea70aa1 Mon Sep 17 00:00:00 2001
+From: popcornmix <popcornmix@gmail.com>
+Date: Sun, 24 Feb 2013 16:30:57 +0000
+Subject: [PATCH 052/174] Add retry on error and tidy of temperature driver
+
+---
+ drivers/thermal/bcm2835-thermal.c | 78 ++++++++++++++-------------------------
+ 1 file changed, 27 insertions(+), 51 deletions(-)
+
+--- a/drivers/thermal/bcm2835-thermal.c
++++ b/drivers/thermal/bcm2835-thermal.c
+@@ -33,7 +33,6 @@
+ #define print_debug(fmt,...)
+ #endif
+ #define print_err(fmt,...) printk(KERN_ERR "%s:%s:%d: "fmt"\n", MODULE_NAME, __func__,__LINE__, ##__VA_ARGS__)
+-#define print_info(fmt,...) printk(KERN_INFO "%s: "fmt"\n", MODULE_NAME, ##__VA_ARGS__)
+
+ #define VC_TAG_GET_TEMP 0x00030006
+ #define VC_TAG_GET_MAX_TEMP 0x0003000A
+@@ -66,12 +65,6 @@ struct bcm2835_thermal_data {
+ struct vc_msg msg;
+ };
+
+-/* --- PROTOTYPES --- */
+-static int bcm2835_get_temp(struct thermal_zone_device *thermal_dev, unsigned long *);
+-static int bcm2835_get_max_temp(struct thermal_zone_device *thermal_dev, int, unsigned long *);
+-static int bcm2835_get_trip_type(struct thermal_zone_device *thermal_dev, int trip_num, enum thermal_trip_type *trip_type);
+-static int bcm2835_get_mode(struct thermal_zone_device *thermal_dev, enum thermal_device_mode *dev_mode);
+-
+ /* --- GLOBALS --- */
+ static struct bcm2835_thermal_data bcm2835_data;
+
+@@ -79,64 +72,47 @@ static struct bcm2835_thermal_data bcm28
+ static struct thermal_zone_device_ops ops;
+
+ /* --- FUNCTIONS --- */
+-static int bcm2835_get_max_temp(struct thermal_zone_device *thermal_dev, int trip_num, unsigned long *temp)
+-{
+- int result;
+
++static int bcm2835_get_temp_or_max(struct thermal_zone_device *thermal_dev, unsigned long *temp, unsigned tag_id)
++{
++ int result = -1, retry = 3;
+ print_debug("IN");
+
+- /* wipe all previous message data */
+- memset(&bcm2835_data.msg, 0, sizeof bcm2835_data.msg);
+-
+- /* prepare message */
+- bcm2835_data.msg.msg_size = sizeof bcm2835_data.msg;
+- bcm2835_data.msg.tag.buffer_size = 8;
+- bcm2835_data.msg.tag.tag_id = VC_TAG_GET_MAX_TEMP;
+-
+- /* send the message */
+- result = bcm_mailbox_property(&bcm2835_data.msg, sizeof bcm2835_data.msg);
++ *temp = 0;
++ while (result != 0 && retry-- > 0) {
++ /* wipe all previous message data */
++ memset(&bcm2835_data.msg, 0, sizeof bcm2835_data.msg);
++
++ /* prepare message */
++ bcm2835_data.msg.msg_size = sizeof bcm2835_data.msg;
++ bcm2835_data.msg.tag.buffer_size = 8;
++ bcm2835_data.msg.tag.tag_id = tag_id;
++
++ /* send the message */
++ result = bcm_mailbox_property(&bcm2835_data.msg, sizeof bcm2835_data.msg);
++ print_debug("Got %stemperature as %u (%d,%x)\n", tag_id==VC_TAG_GET_MAX_TEMP ? "max ":"", (uint)bcm2835_data.msg.tag.val, result, bcm2835_data.msg.request_code);
++ if (!(bcm2835_data.msg.request_code & 0x80000000))
++ result = -1;
++ }
+
+ /* check if it was all ok and return the rate in milli degrees C */
+- if (result == 0 && (bcm2835_data.msg.request_code & 0x80000000))
++ if (result == 0)
+ *temp = (uint)bcm2835_data.msg.tag.val;
+- #ifdef THERMAL_DEBUG_ENABLE
+ else
+- print_debug("Failed to get temperature!");
+- #endif
+- print_debug("Got temperature as %u",(uint)*temp);
++ print_err("Failed to get temperature! (%x:%d)\n", tag_id, result);
+ print_debug("OUT");
+- return 0;
++ return result;
+ }
+
+ static int bcm2835_get_temp(struct thermal_zone_device *thermal_dev, unsigned long *temp)
+ {
+- int result;
+-
+- print_debug("IN");
+-
+- /* wipe all previous message data */
+- memset(&bcm2835_data.msg, 0, sizeof bcm2835_data.msg);
+-
+- /* prepare message */
+- bcm2835_data.msg.msg_size = sizeof bcm2835_data.msg;
+- bcm2835_data.msg.tag.buffer_size = 8;
+- bcm2835_data.msg.tag.tag_id = VC_TAG_GET_TEMP;
+-
+- /* send the message */
+- result = bcm_mailbox_property(&bcm2835_data.msg, sizeof bcm2835_data.msg);
+-
+- /* check if it was all ok and return the rate in milli degrees C */
+- if (result == 0 && (bcm2835_data.msg.request_code & 0x80000000))
+- *temp = (uint)bcm2835_data.msg.tag.val;
+- #ifdef THERMAL_DEBUG_ENABLE
+- else
+- print_debug("Failed to get temperature!");
+- #endif
+- print_debug("Got temperature as %u",(uint)*temp);
+- print_debug("OUT");
+- return 0;
++ return bcm2835_get_temp_or_max(thermal_dev, temp, VC_TAG_GET_TEMP);
+ }
+
++static int bcm2835_get_max_temp(struct thermal_zone_device *thermal_dev, int trip_num, unsigned long *temp)
++{
++ return bcm2835_get_temp_or_max(thermal_dev, temp, VC_TAG_GET_MAX_TEMP);
++}
+
+ static int bcm2835_get_trip_type(struct thermal_zone_device * thermal_dev, int trip_num, enum thermal_trip_type *trip_type)
+ {