diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index 2debe235..994c9cd2 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | |||
@@ -389,6 +389,55 @@ static ssize_t aelpg_param_read(struct device *device, | |||
389 | static DEVICE_ATTR(aelpg_param, S_IRWXUGO, | 389 | static DEVICE_ATTR(aelpg_param, S_IRWXUGO, |
390 | aelpg_param_read, aelpg_param_store); | 390 | aelpg_param_read, aelpg_param_store); |
391 | 391 | ||
392 | static ssize_t aelpg_enable_store(struct device *device, | ||
393 | struct device_attribute *attr, const char *buf, size_t count) | ||
394 | { | ||
395 | struct platform_device *ndev = to_platform_device(device); | ||
396 | struct gk20a *g = get_gk20a(ndev); | ||
397 | unsigned long val = 0; | ||
398 | int status = 0; | ||
399 | union pmu_ap_cmd ap_cmd; | ||
400 | int err; | ||
401 | |||
402 | if (kstrtoul(buf, 10, &val) < 0) | ||
403 | return -EINVAL; | ||
404 | |||
405 | err = gk20a_busy(g->dev); | ||
406 | if (g->pmu.pmu_ready) { | ||
407 | if (val && !g->aelpg_enabled) { | ||
408 | g->aelpg_enabled = true; | ||
409 | /* Enable AELPG */ | ||
410 | ap_cmd.init.cmd_id = PMU_AP_CMD_ID_ENABLE_CTRL; | ||
411 | status = gk20a_pmu_ap_send_command(g, &ap_cmd, false); | ||
412 | } else if (!val && g->aelpg_enabled) { | ||
413 | g->aelpg_enabled = false; | ||
414 | /* Disable AELPG */ | ||
415 | ap_cmd.init.cmd_id = PMU_AP_CMD_ID_DISABLE_CTRL; | ||
416 | status = gk20a_pmu_ap_send_command(g, &ap_cmd, false); | ||
417 | } | ||
418 | } else { | ||
419 | dev_info(device, "PMU is not ready, AELPG request failed\n"); | ||
420 | } | ||
421 | gk20a_idle(g->dev); | ||
422 | |||
423 | dev_info(device, "AELPG is %s.\n", g->aelpg_enabled ? "enabled" : | ||
424 | "disabled"); | ||
425 | |||
426 | return count; | ||
427 | } | ||
428 | |||
429 | static ssize_t aelpg_enable_read(struct device *device, | ||
430 | struct device_attribute *attr, char *buf) | ||
431 | { | ||
432 | struct platform_device *ndev = to_platform_device(device); | ||
433 | struct gk20a *g = get_gk20a(ndev); | ||
434 | |||
435 | return sprintf(buf, "%d\n", g->aelpg_enabled ? 1 : 0); | ||
436 | } | ||
437 | |||
438 | static DEVICE_ATTR(aelpg_enable, ROOTRW, | ||
439 | aelpg_enable_read, aelpg_enable_store); | ||
440 | |||
392 | #ifdef CONFIG_PM_RUNTIME | 441 | #ifdef CONFIG_PM_RUNTIME |
393 | static ssize_t force_idle_store(struct device *device, | 442 | static ssize_t force_idle_store(struct device *device, |
394 | struct device_attribute *attr, const char *buf, size_t count) | 443 | struct device_attribute *attr, const char *buf, size_t count) |
@@ -458,6 +507,7 @@ void gk20a_remove_sysfs(struct device *dev) | |||
458 | device_remove_file(dev, &dev_attr_force_idle); | 507 | device_remove_file(dev, &dev_attr_force_idle); |
459 | #endif | 508 | #endif |
460 | device_remove_file(dev, &dev_attr_aelpg_param); | 509 | device_remove_file(dev, &dev_attr_aelpg_param); |
510 | device_remove_file(dev, &dev_attr_aelpg_enable); | ||
461 | 511 | ||
462 | if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) | 512 | if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) |
463 | sysfs_remove_link(&dev->kobj, dev_name(dev)); | 513 | sysfs_remove_link(&dev->kobj, dev_name(dev)); |
@@ -482,6 +532,7 @@ void gk20a_create_sysfs(struct platform_device *dev) | |||
482 | error |= device_create_file(&dev->dev, &dev_attr_force_idle); | 532 | error |= device_create_file(&dev->dev, &dev_attr_force_idle); |
483 | #endif | 533 | #endif |
484 | error |= device_create_file(&dev->dev, &dev_attr_aelpg_param); | 534 | error |= device_create_file(&dev->dev, &dev_attr_aelpg_param); |
535 | error |= device_create_file(&dev->dev, &dev_attr_aelpg_enable); | ||
485 | 536 | ||
486 | if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev)) | 537 | if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev)) |
487 | error |= sysfs_create_link(&g->host1x_dev->dev.kobj, | 538 | error |= sysfs_create_link(&g->host1x_dev->dev.kobj, |