From: Martin Povišer <povik+lin@xxxxxxxxxxx>
Export a file for the readout of die temperature measurements.
As per the datasheet, the temperature can be calculated by
subtracting the value in the register by 93.
Reviewed-by: Neal Gompa <neal@xxxxxxxxx>
Signed-off-by: Martin Povišer <povik+lin@xxxxxxxxxxx>
Signed-off-by: James Calligeros <jcalligeros99@xxxxxxxxx>
---
sound/soc/codecs/tas2764.c | 45 +++++++++++++++++++++++++
sound/soc/codecs/tas2764.h | 3 ++
2 files changed, 48 insertions(+)
diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c
index 13c7ab7ee1f7a9e1224804de034466ef8bc1bf06..b0d016f85f7fd57bec36b33db5e8c2bd242b5b94 100644
--- a/sound/soc/codecs/tas2764.c
+++ b/sound/soc/codecs/tas2764.c
@@ -16,6 +16,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -571,6 +572,39 @@ static int tas2764_apply_init_quirks(struct tas2764_priv *tas2764)
return 0;
}
+static int tas2764_read_die_temp(struct tas2764_priv *tas2764, int *result)
+{
+ int ret;
+
+ ret = snd_soc_component_read(tas2764->component, TAS2764_TEMP);
+ if (ret < 0)
+ return ret;
+ *result = ret - 93;
+ return 0;
+}
+
+static ssize_t die_temp_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tas2764_priv *tas2764 = i2c_get_clientdata(to_i2c_client(dev));
+ int ret, temp;
+
+ ret = tas2764_read_die_temp(tas2764, &temp);
+
+ if (ret < 0)
+ return ret;
+
+ return sysfs_emit(buf, "%d C\n", temp);
+}
+
+static DEVICE_ATTR_RO(die_temp);
+
+static struct attribute *tas2764_sysfs_attrs[] = {
+ &dev_attr_die_temp.attr,
+ NULL
+};
+ATTRIBUTE_GROUPS(tas2764_sysfs);
+
static int tas2764_codec_probe(struct snd_soc_component *component)
{
struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
@@ -664,9 +698,19 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
return ret;
}
+ ret = sysfs_create_groups(&component->dev->kobj, tas2764_sysfs_groups);
+
+ if (ret < 0)
+ return ret;
+
return 0;
}
+static void tas2764_codec_remove(struct snd_soc_component *component)
+{
+ sysfs_remove_groups(&component->dev->kobj, tas2764_sysfs_groups);
+}
+
static DECLARE_TLV_DB_SCALE(tas2764_digital_tlv, 1100, 50, 0);
static DECLARE_TLV_DB_SCALE(tas2764_playback_volume, -10050, 50, 1);
@@ -698,6 +742,7 @@ static const struct snd_kcontrol_new tas2764_snd_controls[] = {
static const struct snd_soc_component_driver soc_component_driver_tas2764 = {
.probe = tas2764_codec_probe,
+ .remove = tas2764_codec_remove,
.suspend = tas2764_codec_suspend,
.resume = tas2764_codec_resume,
.controls = tas2764_snd_controls,
diff --git a/sound/soc/codecs/tas2764.h b/sound/soc/codecs/tas2764.h
index 00296b8b1f7584e7520bd6ed749a09681f16ea09..786d81eb5b1e71bad094ef94e4b56e8f7c910285 100644
--- a/sound/soc/codecs/tas2764.h
+++ b/sound/soc/codecs/tas2764.h
@@ -111,6 +111,9 @@
#define TAS2764_INT_LTCH3 TAS2764_REG(0x0, 0x50)
#define TAS2764_INT_LTCH4 TAS2764_REG(0x0, 0x51)
+/* Readout Registers */
+#define TAS2764_TEMP TAS2764_REG(0x0, 0x56)
+
/* Clock/IRQ Settings */
#define TAS2764_INT_CLK_CFG TAS2764_REG(0x0, 0x5c)
#define TAS2764_INT_CLK_CFG_IRQZ_CLR BIT(2)
--
2.48.1
[Index of Archives]
[Pulseaudio]
[Linux Audio Users]
[ALSA Devel]
[Fedora Desktop]
[Fedora SELinux]
[Big List of Linux Books]
[Yosemite News]
[KDE Users]