summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c
index eb0aa5d1..2debe235 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c
@@ -29,6 +29,7 @@
29#include "gk20a.h" 29#include "gk20a.h"
30#include "gr_gk20a.h" 30#include "gr_gk20a.h"
31#include "fifo_gk20a.h" 31#include "fifo_gk20a.h"
32#include "pmu_gk20a.h"
32 33
33 34
34#define PTIMER_FP_FACTOR 1000000 35#define PTIMER_FP_FACTOR 1000000
@@ -332,6 +333,62 @@ static ssize_t elpg_enable_read(struct device *device,
332 333
333static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store); 334static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store);
334 335
336static ssize_t aelpg_param_store(struct device *device,
337 struct device_attribute *attr, const char *buf, size_t count)
338{
339 struct platform_device *ndev = to_platform_device(device);
340 struct gk20a *g = get_gk20a(ndev);
341 int status = 0;
342 union pmu_ap_cmd ap_cmd;
343 int *paramlist = (int *)g->pmu.aelpg_param;
344 u32 defaultparam[5] = {
345 APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US,
346 APCTRL_MINIMUM_IDLE_FILTER_DEFAULT_US,
347 APCTRL_MINIMUM_TARGET_SAVING_DEFAULT_US,
348 APCTRL_POWER_BREAKEVEN_DEFAULT_US,
349 APCTRL_CYCLES_PER_SAMPLE_MAX_DEFAULT
350 };
351
352 /* Get each parameter value from input string*/
353 sscanf(buf, "%d %d %d %d %d", &paramlist[0], &paramlist[1],
354 &paramlist[2], &paramlist[3], &paramlist[4]);
355
356 /* If parameter value is 0 then reset to SW default values*/
357 if ((paramlist[0] | paramlist[1] | paramlist[2]
358 | paramlist[3] | paramlist[4]) == 0x00) {
359 memcpy(paramlist, defaultparam, sizeof(defaultparam));
360 }
361
362 /* If aelpg is enabled & pmu is ready then post values to
363 * PMU else store then post later
364 */
365 if (g->aelpg_enabled && g->pmu.pmu_ready) {
366 /* Disable AELPG */
367 ap_cmd.init.cmd_id = PMU_AP_CMD_ID_DISABLE_CTRL;
368 status = gk20a_pmu_ap_send_command(g, &ap_cmd, false);
369
370 /* Enable AELPG */
371 gk20a_aelpg_init(g);
372 gk20a_aelpg_init_and_enable(g, PMU_AP_CTRL_ID_GRAPHICS);
373 }
374
375 return count;
376}
377
378static ssize_t aelpg_param_read(struct device *device,
379 struct device_attribute *attr, char *buf)
380{
381 struct platform_device *ndev = to_platform_device(device);
382 struct gk20a *g = get_gk20a(ndev);
383
384 return sprintf(buf, "%d %d %d %d %d\n", g->pmu.aelpg_param[0],
385 g->pmu.aelpg_param[1], g->pmu.aelpg_param[2],
386 g->pmu.aelpg_param[3], g->pmu.aelpg_param[4]);
387}
388
389static DEVICE_ATTR(aelpg_param, S_IRWXUGO,
390 aelpg_param_read, aelpg_param_store);
391
335#ifdef CONFIG_PM_RUNTIME 392#ifdef CONFIG_PM_RUNTIME
336static ssize_t force_idle_store(struct device *device, 393static ssize_t force_idle_store(struct device *device,
337 struct device_attribute *attr, const char *buf, size_t count) 394 struct device_attribute *attr, const char *buf, size_t count)
@@ -400,6 +457,7 @@ void gk20a_remove_sysfs(struct device *dev)
400#ifdef CONFIG_PM_RUNTIME 457#ifdef CONFIG_PM_RUNTIME
401 device_remove_file(dev, &dev_attr_force_idle); 458 device_remove_file(dev, &dev_attr_force_idle);
402#endif 459#endif
460 device_remove_file(dev, &dev_attr_aelpg_param);
403 461
404 if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) 462 if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev))
405 sysfs_remove_link(&dev->kobj, dev_name(dev)); 463 sysfs_remove_link(&dev->kobj, dev_name(dev));
@@ -423,6 +481,7 @@ void gk20a_create_sysfs(struct platform_device *dev)
423#ifdef CONFIG_PM_RUNTIME 481#ifdef CONFIG_PM_RUNTIME
424 error |= device_create_file(&dev->dev, &dev_attr_force_idle); 482 error |= device_create_file(&dev->dev, &dev_attr_force_idle);
425#endif 483#endif
484 error |= device_create_file(&dev->dev, &dev_attr_aelpg_param);
426 485
427 if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev)) 486 if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev))
428 error |= sysfs_create_link(&g->host1x_dev->dev.kobj, 487 error |= sysfs_create_link(&g->host1x_dev->dev.kobj,