Skip to contentSkip to conversation

hwmon: (ltc4245) expose all GPIO pins

PATCH Applied Ira W. Snyder 2 participants 2 messages May 27, 2010 – May 29, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 hwmon: (ltc4245) expose all GPIO pins

Add support for exposing all GPIO pins as analog voltages. Though this is not an ideal use of the chip, some hardware engineers may decide that the LTC4245 meets their design requirements when studying the datasheet.

The GPIO pins are sampled in round-robin fashion, meaning that a slow reader will see stale data. A userspace application can detect this, because it will get -EAGAIN when reading from a sysfs file which contains stale data.

Users can choose to use this feature on a per-chip basis by using either platform data or the OF device tree (where applicable).

---

v1 -> v2:
* use platform data or OF to configure extra GPIO support

v2 -> v3:
* use register value for current GPIO setting
* improve documentation

 Documentation/hwmon/ltc4245 |   24 ++++++-
 drivers/hwmon/ltc4245.c     |  177 ++++++++++++++++++++++++++++++++++++++++---
 include/linux/i2c/ltc4245.h |   21 +++++
 3 files changed, 211 insertions(+), 11 deletions(-)
 create mode 100644 include/linux/i2c/ltc4245.h
Documentation/hwmon/ltc4245 +23 -1
index 86b5880..b478b08 100644
@@ -72,9 +72,31 @@ in6_min_alarm		5v  output undervoltage alarm
 in7_min_alarm		3v  output undervoltage alarm
 in8_min_alarm		Vee (-12v) output undervoltage alarm
 
-in9_input		GPIO voltage data
+in9_input		GPIO voltage data (see note 1)
+in10_input		GPIO voltage data (see note 1)
+in11_input		GPIO voltage data (see note 1)
 
 power1_input		12v power usage (mW)
 power2_input		5v  power usage (mW)
 power3_input		3v  power usage (mW)
 power4_input		Vee (-12v) power usage (mW)
+
+
+Note 1
+------
+
+If you have NOT configured the driver to sample all GPIO pins as analog
+voltages, then the in10_input and in11_input sysfs attributes will not be
+created. The driver will sample the GPIO pin that is currently connected to the
+ADC as an analog voltage, and report the value in in9_input.
+
+If you have configured the driver to sample all GPIO pins as analog voltages,
+then they will be sampled in round-robin fashion. If userspace reads too
+slowly, -EAGAIN will be returned when you read the sysfs attribute containing
+the sensor reading.
+
+The LTC4245 chip can be configured to sample all GPIO pins with two methods:
+1) platform data -- see include/linux/i2c/ltc4245.h
+2) OF device tree -- add the "ltc4245,use-extra-gpios" property to each chip
+
+The default mode of operation is to sample a single GPIO pin.
drivers/hwmon/ltc4245.c +167 -10

254 lines not on this page · raw message

include/linux/i2c/ltc4245.h new file +21 -0
new file mode 100644
index 0000000..56bda4b
@@ -0,0 +1,21 @@
+/*
+ * Platform Data for LTC4245 hardware monitor chip
+ *
+ * Copyright (c) 2010 Ira W. Snyder <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef LINUX_LTC4245_H
+#define LINUX_LTC4245_H
+
+#include <linux/types.h>
+
+struct ltc4245_platform_data {
+	bool use_extra_gpios;
+};
+
+#endif /* LINUX_LTC4245_H */
Signature · 7 lines
1.6.4.4


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Applied
#1 lore raw

Re: [lm-sensors] [PATCH v3 2/2] hwmon: (ltc4245) expose all GPIO

Hi Ira,

Quoted 9 lines · Ira W. Snyder

Add support for exposing all GPIO pins as analog voltages. Though this is not an ideal use of the chip, some hardware engineers may decide that the LTC4245 meets their design requirements when studying the datasheet.

The GPIO pins are sampled in round-robin fashion, meaning that a slow reader will see stale data. A userspace application can detect this, because it will get -EAGAIN when reading from a sysfs file which contains stale data.

Quoted 6 lines

Users can choose to use this feature on a per-chip basis by using either platform data or the OF device tree (where applicable).

---
(...)

Applied, thanks.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors