diff options
author | Sebastien Guiriec <sebastien.guiriec@intel.com> | 2016-12-05 11:45:02 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-12-05 12:22:24 -0500 |
commit | fade74dfab7cdba55a197db08f3d15cf2319bf4c (patch) | |
tree | 7113a347d51c27a0b313c2c4bffb4fc255bc4127 | |
parent | 5203a3ca09d51b3f475fd12cf974f886147d371d (diff) |
ASoC: Intel: atom: Add sysfs entry in order to store FW version
This patch is adding a sysfs entry in order to be able to get
access to SST FW version.
Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/intel/atom/sst/sst.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c index 9b6e27385dc9..f9ba71315e33 100644 --- a/sound/soc/intel/atom/sst/sst.c +++ b/sound/soc/intel/atom/sst/sst.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/pm_qos.h> | 27 | #include <linux/pm_qos.h> |
28 | #include <linux/async.h> | 28 | #include <linux/async.h> |
29 | #include <linux/acpi.h> | 29 | #include <linux/acpi.h> |
30 | #include <linux/sysfs.h> | ||
30 | #include <sound/core.h> | 31 | #include <sound/core.h> |
31 | #include <sound/soc.h> | 32 | #include <sound/soc.h> |
32 | #include <asm/platform_sst_audio.h> | 33 | #include <asm/platform_sst_audio.h> |
@@ -242,6 +243,32 @@ int sst_alloc_drv_context(struct intel_sst_drv **ctx, | |||
242 | } | 243 | } |
243 | EXPORT_SYMBOL_GPL(sst_alloc_drv_context); | 244 | EXPORT_SYMBOL_GPL(sst_alloc_drv_context); |
244 | 245 | ||
246 | static ssize_t firmware_version_show(struct device *dev, | ||
247 | struct device_attribute *attr, char *buf) | ||
248 | { | ||
249 | struct intel_sst_drv *ctx = dev_get_drvdata(dev); | ||
250 | |||
251 | if (ctx->fw_version.type == 0 && ctx->fw_version.major == 0 && | ||
252 | ctx->fw_version.minor == 0 && ctx->fw_version.build == 0) | ||
253 | return sprintf(buf, "FW not yet loaded\n"); | ||
254 | else | ||
255 | return sprintf(buf, "v%02x.%02x.%02x.%02x\n", | ||
256 | ctx->fw_version.type, ctx->fw_version.major, | ||
257 | ctx->fw_version.minor, ctx->fw_version.build); | ||
258 | |||
259 | } | ||
260 | |||
261 | DEVICE_ATTR_RO(firmware_version); | ||
262 | |||
263 | static const struct attribute *sst_fw_version_attrs[] = { | ||
264 | &dev_attr_firmware_version.attr, | ||
265 | NULL, | ||
266 | }; | ||
267 | |||
268 | static const struct attribute_group sst_fw_version_attr_group = { | ||
269 | .attrs = (struct attribute **)sst_fw_version_attrs, | ||
270 | }; | ||
271 | |||
245 | int sst_context_init(struct intel_sst_drv *ctx) | 272 | int sst_context_init(struct intel_sst_drv *ctx) |
246 | { | 273 | { |
247 | int ret = 0, i; | 274 | int ret = 0, i; |
@@ -315,8 +342,19 @@ int sst_context_init(struct intel_sst_drv *ctx) | |||
315 | dev_err(ctx->dev, "Firmware download failed:%d\n", ret); | 342 | dev_err(ctx->dev, "Firmware download failed:%d\n", ret); |
316 | goto do_free_mem; | 343 | goto do_free_mem; |
317 | } | 344 | } |
345 | |||
346 | ret = sysfs_create_group(&ctx->dev->kobj, | ||
347 | &sst_fw_version_attr_group); | ||
348 | if (ret) { | ||
349 | dev_err(ctx->dev, | ||
350 | "Unable to create sysfs\n"); | ||
351 | goto err_sysfs; | ||
352 | } | ||
353 | |||
318 | sst_register(ctx->dev); | 354 | sst_register(ctx->dev); |
319 | return 0; | 355 | return 0; |
356 | err_sysfs: | ||
357 | sysfs_remove_group(&ctx->dev->kobj, &sst_fw_version_attr_group); | ||
320 | 358 | ||
321 | do_free_mem: | 359 | do_free_mem: |
322 | destroy_workqueue(ctx->post_msg_wq); | 360 | destroy_workqueue(ctx->post_msg_wq); |
@@ -330,6 +368,7 @@ void sst_context_cleanup(struct intel_sst_drv *ctx) | |||
330 | pm_runtime_disable(ctx->dev); | 368 | pm_runtime_disable(ctx->dev); |
331 | sst_unregister(ctx->dev); | 369 | sst_unregister(ctx->dev); |
332 | sst_set_fw_state_locked(ctx, SST_SHUTDOWN); | 370 | sst_set_fw_state_locked(ctx, SST_SHUTDOWN); |
371 | sysfs_remove_group(&ctx->dev->kobj, &sst_fw_version_attr_group); | ||
333 | flush_scheduled_work(); | 372 | flush_scheduled_work(); |
334 | destroy_workqueue(ctx->post_msg_wq); | 373 | destroy_workqueue(ctx->post_msg_wq); |
335 | pm_qos_remove_request(ctx->qos); | 374 | pm_qos_remove_request(ctx->qos); |