Message ID | 20250218-apple-codec-changes-v2-13-932760fd7e07@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | ASoC: tas27{64,70}: improve support for Apple codec variants | expand |
On Tue, Feb 18, 2025 at 06:35:47PM +1000, James Calligeros wrote: > From: Martin Povišer <povik+lin@cutebit.org> > > Export a file for the readout of die temperature measurements. > As per the datasheet, the temperature can be calculated by > dividing the register value by 16 and then subtracting 93. Please don't ignore review comments, people are generally making them for a reason and are likely to have the same concerns if issues remain unaddressed. Having to repeat the same comments can get repetitive and make people question the value of time spent reviewing. If you disagree with the review comments that's fine but you need to reply and discuss your concerns so that the reviewer can understand your decisions.
Le Tue, Feb 18, 2025 at 03:22:19PM +0000, Mark Brown a écrit : > On Tue, Feb 18, 2025 at 06:35:47PM +1000, James Calligeros wrote: > > From: Martin Povišer <povik+lin@cutebit.org> > > > > Export a file for the readout of die temperature measurements. > > As per the datasheet, the temperature can be calculated by > > dividing the register value by 16 and then subtracting 93. > > Please don't ignore review comments, people are generally making them > for a reason and are likely to have the same concerns if issues remain > unaddressed. Having to repeat the same comments can get repetitive and > make people question the value of time spent reviewing. If you disagree > with the review comments that's fine but you need to reply and discuss > your concerns so that the reviewer can understand your decisions. Which review comment...? The only thing I could find was about hwmon exporting, which James added a patch for in v2 ("ASoC: tas2770: expose die temp to hwmon"). Maybe I missed an email?
Le Tue, Feb 18, 2025 at 03:22:19PM +0000, Mark Brown a écrit : > On Tue, Feb 18, 2025 at 06:35:47PM +1000, James Calligeros wrote: > > From: Martin Povišer <povik+lin@cutebit.org> > > > > Export a file for the readout of die temperature measurements. > > As per the datasheet, the temperature can be calculated by > > dividing the register value by 16 and then subtracting 93. > > Please don't ignore review comments, people are generally making them > for a reason and are likely to have the same concerns if issues remain > unaddressed. Having to repeat the same comments can get repetitive and > make people question the value of time spent reviewing. If you disagree > with the review comments that's fine but you need to reply and discuss > your concerns so that the reviewer can understand your decisions. Oh, I see your later email. Serves me right for replying without reading the whole thing, sorry!
diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c index 7f219df8be7046912bf3ef452f75c17b5118bcf6..84066884d36be8d41d83bca5680e9f683c420d78 100644 --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -20,6 +20,7 @@ #include <linux/regmap.h> #include <linux/of.h> #include <linux/slab.h> +#include <linux/sysfs.h> #include <sound/soc.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -491,6 +492,51 @@ static struct snd_soc_dai_driver tas2770_dai_driver[] = { }, }; +static int tas2770_read_die_temp(struct tas2770_priv *tas2770, int *result) +{ + int ret, reading; + + ret = snd_soc_component_read(tas2770->component, TAS2770_TEMP_MSB); + if (ret < 0) + return ret; + reading = ret << 4; + + ret = snd_soc_component_read(tas2770->component, TAS2770_TEMP_LSB); + if (ret < 0) + return ret; + reading |= ret >> 4; + + /* + * As per datasheet: divide register by 16 and subtract 93. We don't + * want to divide just yet though. + */ + *result = reading - (93 * 16); + return 0; +} + +static ssize_t die_temp_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct tas2770_priv *tas2770 = i2c_get_clientdata(to_i2c_client(dev)); + int ret, temp; + + ret = tas2770_read_die_temp(tas2770, &temp); + + if (ret < 0) + return ret; + + return sysfs_emit(buf, "%d.%03d C\n", temp / 16, + (temp * 1000 / 16) % 1000); +} + +static DEVICE_ATTR_RO(die_temp); + +static struct attribute *tas2770_sysfs_attrs[] = { + &dev_attr_die_temp.attr, + NULL +}; +ATTRIBUTE_GROUPS(tas2770_sysfs); + static const struct regmap_config tas2770_i2c_regmap; static int tas2770_codec_probe(struct snd_soc_component *component) @@ -517,9 +563,19 @@ static int tas2770_codec_probe(struct snd_soc_component *component) return ret; } + ret = sysfs_create_groups(&component->dev->kobj, tas2770_sysfs_groups); + + if (ret < 0) + return ret; + return 0; } +static void tas2770_codec_remove(struct snd_soc_component *component) +{ + sysfs_remove_groups(&component->dev->kobj, tas2770_sysfs_groups); +} + static DECLARE_TLV_DB_SCALE(tas2770_digital_tlv, 1100, 50, 0); static DECLARE_TLV_DB_SCALE(tas2770_playback_volume, -10050, 50, 0); @@ -532,6 +588,7 @@ static const struct snd_kcontrol_new tas2770_snd_controls[] = { static const struct snd_soc_component_driver soc_component_driver_tas2770 = { .probe = tas2770_codec_probe, + .remove = tas2770_codec_remove, .suspend = tas2770_codec_suspend, .resume = tas2770_codec_resume, .controls = tas2770_snd_controls,