diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 213 |
1 files changed, 93 insertions, 120 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index d433c9bb..9d25cfdd 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/platform_device.h> | 21 | #include <linux/device.h> |
22 | #include <linux/pm_runtime.h> | 22 | #include <linux/pm_runtime.h> |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/fb.h> | 24 | #include <linux/fb.h> |
@@ -34,11 +34,10 @@ | |||
34 | 34 | ||
35 | #define ROOTRW (S_IRWXU|S_IRGRP|S_IROTH) | 35 | #define ROOTRW (S_IRWXU|S_IRGRP|S_IROTH) |
36 | 36 | ||
37 | static ssize_t elcg_enable_store(struct device *device, | 37 | static ssize_t elcg_enable_store(struct device *dev, |
38 | struct device_attribute *attr, const char *buf, size_t count) | 38 | struct device_attribute *attr, const char *buf, size_t count) |
39 | { | 39 | { |
40 | struct platform_device *ndev = to_platform_device(device); | 40 | struct gk20a *g = get_gk20a(dev); |
41 | struct gk20a *g = get_gk20a(ndev); | ||
42 | unsigned long val = 0; | 41 | unsigned long val = 0; |
43 | int err; | 42 | int err; |
44 | 43 | ||
@@ -60,28 +59,26 @@ static ssize_t elcg_enable_store(struct device *device, | |||
60 | } | 59 | } |
61 | gk20a_idle(g->dev); | 60 | gk20a_idle(g->dev); |
62 | 61 | ||
63 | dev_info(device, "ELCG is %s.\n", g->elcg_enabled ? "enabled" : | 62 | dev_info(dev, "ELCG is %s.\n", g->elcg_enabled ? "enabled" : |
64 | "disabled"); | 63 | "disabled"); |
65 | 64 | ||
66 | return count; | 65 | return count; |
67 | } | 66 | } |
68 | 67 | ||
69 | static ssize_t elcg_enable_read(struct device *device, | 68 | static ssize_t elcg_enable_read(struct device *dev, |
70 | struct device_attribute *attr, char *buf) | 69 | struct device_attribute *attr, char *buf) |
71 | { | 70 | { |
72 | struct platform_device *ndev = to_platform_device(device); | 71 | struct gk20a *g = get_gk20a(dev); |
73 | struct gk20a *g = get_gk20a(ndev); | ||
74 | 72 | ||
75 | return sprintf(buf, "%d\n", g->elcg_enabled ? 1 : 0); | 73 | return sprintf(buf, "%d\n", g->elcg_enabled ? 1 : 0); |
76 | } | 74 | } |
77 | 75 | ||
78 | static DEVICE_ATTR(elcg_enable, ROOTRW, elcg_enable_read, elcg_enable_store); | 76 | static DEVICE_ATTR(elcg_enable, ROOTRW, elcg_enable_read, elcg_enable_store); |
79 | 77 | ||
80 | static ssize_t blcg_enable_store(struct device *device, | 78 | static ssize_t blcg_enable_store(struct device *dev, |
81 | struct device_attribute *attr, const char *buf, size_t count) | 79 | struct device_attribute *attr, const char *buf, size_t count) |
82 | { | 80 | { |
83 | struct platform_device *ndev = to_platform_device(device); | 81 | struct gk20a *g = get_gk20a(dev); |
84 | struct gk20a *g = get_gk20a(ndev); | ||
85 | unsigned long val = 0; | 82 | unsigned long val = 0; |
86 | int err; | 83 | int err; |
87 | 84 | ||
@@ -118,17 +115,16 @@ static ssize_t blcg_enable_store(struct device *device, | |||
118 | g->blcg_enabled); | 115 | g->blcg_enabled); |
119 | gk20a_idle(g->dev); | 116 | gk20a_idle(g->dev); |
120 | 117 | ||
121 | dev_info(device, "BLCG is %s.\n", g->blcg_enabled ? "enabled" : | 118 | dev_info(dev, "BLCG is %s.\n", g->blcg_enabled ? "enabled" : |
122 | "disabled"); | 119 | "disabled"); |
123 | 120 | ||
124 | return count; | 121 | return count; |
125 | } | 122 | } |
126 | 123 | ||
127 | static ssize_t blcg_enable_read(struct device *device, | 124 | static ssize_t blcg_enable_read(struct device *dev, |
128 | struct device_attribute *attr, char *buf) | 125 | struct device_attribute *attr, char *buf) |
129 | { | 126 | { |
130 | struct platform_device *ndev = to_platform_device(device); | 127 | struct gk20a *g = get_gk20a(dev); |
131 | struct gk20a *g = get_gk20a(ndev); | ||
132 | 128 | ||
133 | return sprintf(buf, "%d\n", g->blcg_enabled ? 1 : 0); | 129 | return sprintf(buf, "%d\n", g->blcg_enabled ? 1 : 0); |
134 | } | 130 | } |
@@ -136,11 +132,10 @@ static ssize_t blcg_enable_read(struct device *device, | |||
136 | 132 | ||
137 | static DEVICE_ATTR(blcg_enable, ROOTRW, blcg_enable_read, blcg_enable_store); | 133 | static DEVICE_ATTR(blcg_enable, ROOTRW, blcg_enable_read, blcg_enable_store); |
138 | 134 | ||
139 | static ssize_t slcg_enable_store(struct device *device, | 135 | static ssize_t slcg_enable_store(struct device *dev, |
140 | struct device_attribute *attr, const char *buf, size_t count) | 136 | struct device_attribute *attr, const char *buf, size_t count) |
141 | { | 137 | { |
142 | struct platform_device *ndev = to_platform_device(device); | 138 | struct gk20a *g = get_gk20a(dev); |
143 | struct gk20a *g = get_gk20a(ndev); | ||
144 | unsigned long val = 0; | 139 | unsigned long val = 0; |
145 | int err; | 140 | int err; |
146 | 141 | ||
@@ -185,17 +180,16 @@ static ssize_t slcg_enable_store(struct device *device, | |||
185 | g->ops.clock_gating.slcg_xbar_load_gating_prod(g, g->slcg_enabled); | 180 | g->ops.clock_gating.slcg_xbar_load_gating_prod(g, g->slcg_enabled); |
186 | gk20a_idle(g->dev); | 181 | gk20a_idle(g->dev); |
187 | 182 | ||
188 | dev_info(device, "SLCG is %s.\n", g->slcg_enabled ? "enabled" : | 183 | dev_info(dev, "SLCG is %s.\n", g->slcg_enabled ? "enabled" : |
189 | "disabled"); | 184 | "disabled"); |
190 | 185 | ||
191 | return count; | 186 | return count; |
192 | } | 187 | } |
193 | 188 | ||
194 | static ssize_t slcg_enable_read(struct device *device, | 189 | static ssize_t slcg_enable_read(struct device *dev, |
195 | struct device_attribute *attr, char *buf) | 190 | struct device_attribute *attr, char *buf) |
196 | { | 191 | { |
197 | struct platform_device *ndev = to_platform_device(device); | 192 | struct gk20a *g = get_gk20a(dev); |
198 | struct gk20a *g = get_gk20a(ndev); | ||
199 | 193 | ||
200 | return sprintf(buf, "%d\n", g->slcg_enabled ? 1 : 0); | 194 | return sprintf(buf, "%d\n", g->slcg_enabled ? 1 : 0); |
201 | } | 195 | } |
@@ -203,8 +197,8 @@ static ssize_t slcg_enable_read(struct device *device, | |||
203 | static DEVICE_ATTR(slcg_enable, ROOTRW, slcg_enable_read, slcg_enable_store); | 197 | static DEVICE_ATTR(slcg_enable, ROOTRW, slcg_enable_read, slcg_enable_store); |
204 | 198 | ||
205 | static ssize_t ptimer_scale_factor_show(struct device *dev, | 199 | static ssize_t ptimer_scale_factor_show(struct device *dev, |
206 | struct device_attribute *attr, | 200 | struct device_attribute *attr, |
207 | char *buf) | 201 | char *buf) |
208 | { | 202 | { |
209 | struct gk20a_platform *platform = dev_get_drvdata(dev); | 203 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
210 | u32 src_freq_hz = platform->ptimer_src_freq; | 204 | u32 src_freq_hz = platform->ptimer_src_freq; |
@@ -240,8 +234,7 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
240 | { | 234 | { |
241 | struct gk20a_platform *platform = dev_get_drvdata(dev); | 235 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
242 | struct generic_pm_domain *genpd = dev_to_genpd(dev); | 236 | struct generic_pm_domain *genpd = dev_to_genpd(dev); |
243 | struct platform_device *ndev = to_platform_device(dev); | 237 | struct gk20a *g = get_gk20a(dev); |
244 | struct gk20a *g = get_gk20a(ndev); | ||
245 | unsigned long railgate_enable = 0; | 238 | unsigned long railgate_enable = 0; |
246 | int err; | 239 | int err; |
247 | 240 | ||
@@ -255,7 +248,7 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
255 | /* release extra ref count:if power domains not enabled */ | 248 | /* release extra ref count:if power domains not enabled */ |
256 | if ((platform->railgate) && \ | 249 | if ((platform->railgate) && \ |
257 | !IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) | 250 | !IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) |
258 | err = platform->railgate(ndev); | 251 | err = platform->railgate(dev); |
259 | mutex_unlock(&platform->railgate_lock); | 252 | mutex_unlock(&platform->railgate_lock); |
260 | } else if (railgate_enable == 0 && platform->can_railgate) { | 253 | } else if (railgate_enable == 0 && platform->can_railgate) { |
261 | mutex_lock(&platform->railgate_lock); | 254 | mutex_lock(&platform->railgate_lock); |
@@ -265,7 +258,7 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
265 | /* take extra ref count - incase of power domains not enabled */ | 258 | /* take extra ref count - incase of power domains not enabled */ |
266 | if ((platform->unrailgate) && \ | 259 | if ((platform->unrailgate) && \ |
267 | !IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) | 260 | !IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) |
268 | err = platform->unrailgate(ndev); | 261 | err = platform->unrailgate(dev); |
269 | mutex_unlock(&platform->railgate_lock); | 262 | mutex_unlock(&platform->railgate_lock); |
270 | } | 263 | } |
271 | dev_info(dev, "railgate is %s.\n", platform->can_railgate ? | 264 | dev_info(dev, "railgate is %s.\n", platform->can_railgate ? |
@@ -279,11 +272,10 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
279 | return count; | 272 | return count; |
280 | } | 273 | } |
281 | 274 | ||
282 | static ssize_t railgate_enable_read(struct device *device, | 275 | static ssize_t railgate_enable_read(struct device *dev, |
283 | struct device_attribute *attr, char *buf) | 276 | struct device_attribute *attr, char *buf) |
284 | { | 277 | { |
285 | struct platform_device *ndev = to_platform_device(device); | 278 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
286 | struct gk20a_platform *platform = dev_get_drvdata(&ndev->dev); | ||
287 | 279 | ||
288 | return sprintf(buf, "%d\n", platform->can_railgate ? 1 : 0); | 280 | return sprintf(buf, "%d\n", platform->can_railgate ? 1 : 0); |
289 | } | 281 | } |
@@ -297,9 +289,8 @@ static ssize_t railgate_delay_store(struct device *dev, | |||
297 | const char *buf, size_t count) | 289 | const char *buf, size_t count) |
298 | { | 290 | { |
299 | struct gk20a_platform *platform = dev_get_drvdata(dev); | 291 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
300 | struct platform_device *ndev = to_platform_device(dev); | ||
301 | int railgate_delay = 0, ret = 0; | 292 | int railgate_delay = 0, ret = 0; |
302 | struct gk20a *g = get_gk20a(ndev); | 293 | struct gk20a *g = get_gk20a(dev); |
303 | int err; | 294 | int err; |
304 | 295 | ||
305 | if (!platform->can_railgate) { | 296 | if (!platform->can_railgate) { |
@@ -373,8 +364,7 @@ static DEVICE_ATTR(clockgate_delay, ROOTRW, clockgate_delay_show, | |||
373 | static ssize_t counters_show(struct device *dev, | 364 | static ssize_t counters_show(struct device *dev, |
374 | struct device_attribute *attr, char *buf) | 365 | struct device_attribute *attr, char *buf) |
375 | { | 366 | { |
376 | struct platform_device *pdev = to_platform_device(dev); | 367 | struct gk20a *g = get_gk20a(dev); |
377 | struct gk20a *g = get_gk20a(pdev); | ||
378 | u32 busy_cycles, total_cycles; | 368 | u32 busy_cycles, total_cycles; |
379 | ssize_t res; | 369 | ssize_t res; |
380 | 370 | ||
@@ -390,8 +380,7 @@ static ssize_t counters_show_reset(struct device *dev, | |||
390 | struct device_attribute *attr, char *buf) | 380 | struct device_attribute *attr, char *buf) |
391 | { | 381 | { |
392 | ssize_t res = counters_show(dev, attr, buf); | 382 | ssize_t res = counters_show(dev, attr, buf); |
393 | struct platform_device *pdev = to_platform_device(dev); | 383 | struct gk20a *g = get_gk20a(dev); |
394 | struct gk20a *g = get_gk20a(pdev); | ||
395 | 384 | ||
396 | gk20a_pmu_reset_load_counters(g); | 385 | gk20a_pmu_reset_load_counters(g); |
397 | 386 | ||
@@ -403,8 +392,7 @@ static ssize_t gk20a_load_show(struct device *dev, | |||
403 | struct device_attribute *attr, | 392 | struct device_attribute *attr, |
404 | char *buf) | 393 | char *buf) |
405 | { | 394 | { |
406 | struct platform_device *pdev = to_platform_device(dev); | 395 | struct gk20a *g = get_gk20a(dev); |
407 | struct gk20a *g = get_gk20a(pdev); | ||
408 | u32 busy_time; | 396 | u32 busy_time; |
409 | ssize_t res; | 397 | ssize_t res; |
410 | int err; | 398 | int err; |
@@ -427,11 +415,10 @@ static ssize_t gk20a_load_show(struct device *dev, | |||
427 | } | 415 | } |
428 | static DEVICE_ATTR(load, S_IRUGO, gk20a_load_show, NULL); | 416 | static DEVICE_ATTR(load, S_IRUGO, gk20a_load_show, NULL); |
429 | 417 | ||
430 | static ssize_t elpg_enable_store(struct device *device, | 418 | static ssize_t elpg_enable_store(struct device *dev, |
431 | struct device_attribute *attr, const char *buf, size_t count) | 419 | struct device_attribute *attr, const char *buf, size_t count) |
432 | { | 420 | { |
433 | struct platform_device *ndev = to_platform_device(device); | 421 | struct gk20a *g = get_gk20a(dev); |
434 | struct gk20a *g = get_gk20a(ndev); | ||
435 | unsigned long val = 0; | 422 | unsigned long val = 0; |
436 | int err; | 423 | int err; |
437 | 424 | ||
@@ -455,28 +442,26 @@ static ssize_t elpg_enable_store(struct device *device, | |||
455 | } | 442 | } |
456 | gk20a_idle(g->dev); | 443 | gk20a_idle(g->dev); |
457 | 444 | ||
458 | dev_info(device, "ELPG is %s.\n", g->elpg_enabled ? "enabled" : | 445 | dev_info(dev, "ELPG is %s.\n", g->elpg_enabled ? "enabled" : |
459 | "disabled"); | 446 | "disabled"); |
460 | 447 | ||
461 | return count; | 448 | return count; |
462 | } | 449 | } |
463 | 450 | ||
464 | static ssize_t elpg_enable_read(struct device *device, | 451 | static ssize_t elpg_enable_read(struct device *dev, |
465 | struct device_attribute *attr, char *buf) | 452 | struct device_attribute *attr, char *buf) |
466 | { | 453 | { |
467 | struct platform_device *ndev = to_platform_device(device); | 454 | struct gk20a *g = get_gk20a(dev); |
468 | struct gk20a *g = get_gk20a(ndev); | ||
469 | 455 | ||
470 | return sprintf(buf, "%d\n", g->elpg_enabled ? 1 : 0); | 456 | return sprintf(buf, "%d\n", g->elpg_enabled ? 1 : 0); |
471 | } | 457 | } |
472 | 458 | ||
473 | static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store); | 459 | static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store); |
474 | 460 | ||
475 | static ssize_t aelpg_param_store(struct device *device, | 461 | static ssize_t aelpg_param_store(struct device *dev, |
476 | struct device_attribute *attr, const char *buf, size_t count) | 462 | struct device_attribute *attr, const char *buf, size_t count) |
477 | { | 463 | { |
478 | struct platform_device *ndev = to_platform_device(device); | 464 | struct gk20a *g = get_gk20a(dev); |
479 | struct gk20a *g = get_gk20a(ndev); | ||
480 | int status = 0; | 465 | int status = 0; |
481 | union pmu_ap_cmd ap_cmd; | 466 | union pmu_ap_cmd ap_cmd; |
482 | int *paramlist = (int *)g->pmu.aelpg_param; | 467 | int *paramlist = (int *)g->pmu.aelpg_param; |
@@ -514,11 +499,10 @@ static ssize_t aelpg_param_store(struct device *device, | |||
514 | return count; | 499 | return count; |
515 | } | 500 | } |
516 | 501 | ||
517 | static ssize_t aelpg_param_read(struct device *device, | 502 | static ssize_t aelpg_param_read(struct device *dev, |
518 | struct device_attribute *attr, char *buf) | 503 | struct device_attribute *attr, char *buf) |
519 | { | 504 | { |
520 | struct platform_device *ndev = to_platform_device(device); | 505 | struct gk20a *g = get_gk20a(dev); |
521 | struct gk20a *g = get_gk20a(ndev); | ||
522 | 506 | ||
523 | return sprintf(buf, "%d %d %d %d %d\n", g->pmu.aelpg_param[0], | 507 | return sprintf(buf, "%d %d %d %d %d\n", g->pmu.aelpg_param[0], |
524 | g->pmu.aelpg_param[1], g->pmu.aelpg_param[2], | 508 | g->pmu.aelpg_param[1], g->pmu.aelpg_param[2], |
@@ -528,11 +512,10 @@ static ssize_t aelpg_param_read(struct device *device, | |||
528 | static DEVICE_ATTR(aelpg_param, ROOTRW, | 512 | static DEVICE_ATTR(aelpg_param, ROOTRW, |
529 | aelpg_param_read, aelpg_param_store); | 513 | aelpg_param_read, aelpg_param_store); |
530 | 514 | ||
531 | static ssize_t aelpg_enable_store(struct device *device, | 515 | static ssize_t aelpg_enable_store(struct device *dev, |
532 | struct device_attribute *attr, const char *buf, size_t count) | 516 | struct device_attribute *attr, const char *buf, size_t count) |
533 | { | 517 | { |
534 | struct platform_device *ndev = to_platform_device(device); | 518 | struct gk20a *g = get_gk20a(dev); |
535 | struct gk20a *g = get_gk20a(ndev); | ||
536 | unsigned long val = 0; | 519 | unsigned long val = 0; |
537 | int status = 0; | 520 | int status = 0; |
538 | union pmu_ap_cmd ap_cmd; | 521 | union pmu_ap_cmd ap_cmd; |
@@ -558,21 +541,20 @@ static ssize_t aelpg_enable_store(struct device *device, | |||
558 | status = gk20a_pmu_ap_send_command(g, &ap_cmd, false); | 541 | status = gk20a_pmu_ap_send_command(g, &ap_cmd, false); |
559 | } | 542 | } |
560 | } else { | 543 | } else { |
561 | dev_info(device, "PMU is not ready, AELPG request failed\n"); | 544 | dev_info(dev, "PMU is not ready, AELPG request failed\n"); |
562 | } | 545 | } |
563 | gk20a_idle(g->dev); | 546 | gk20a_idle(g->dev); |
564 | 547 | ||
565 | dev_info(device, "AELPG is %s.\n", g->aelpg_enabled ? "enabled" : | 548 | dev_info(dev, "AELPG is %s.\n", g->aelpg_enabled ? "enabled" : |
566 | "disabled"); | 549 | "disabled"); |
567 | 550 | ||
568 | return count; | 551 | return count; |
569 | } | 552 | } |
570 | 553 | ||
571 | static ssize_t aelpg_enable_read(struct device *device, | 554 | static ssize_t aelpg_enable_read(struct device *dev, |
572 | struct device_attribute *attr, char *buf) | 555 | struct device_attribute *attr, char *buf) |
573 | { | 556 | { |
574 | struct platform_device *ndev = to_platform_device(device); | 557 | struct gk20a *g = get_gk20a(dev); |
575 | struct gk20a *g = get_gk20a(ndev); | ||
576 | 558 | ||
577 | return sprintf(buf, "%d\n", g->aelpg_enabled ? 1 : 0); | 559 | return sprintf(buf, "%d\n", g->aelpg_enabled ? 1 : 0); |
578 | } | 560 | } |
@@ -581,19 +563,17 @@ static DEVICE_ATTR(aelpg_enable, ROOTRW, | |||
581 | aelpg_enable_read, aelpg_enable_store); | 563 | aelpg_enable_read, aelpg_enable_store); |
582 | 564 | ||
583 | 565 | ||
584 | static ssize_t allow_all_enable_read(struct device *device, | 566 | static ssize_t allow_all_enable_read(struct device *dev, |
585 | struct device_attribute *attr, char *buf) | 567 | struct device_attribute *attr, char *buf) |
586 | { | 568 | { |
587 | struct platform_device *ndev = to_platform_device(device); | 569 | struct gk20a *g = get_gk20a(dev); |
588 | struct gk20a *g = get_gk20a(ndev); | ||
589 | return sprintf(buf, "%d\n", g->allow_all ? 1 : 0); | 570 | return sprintf(buf, "%d\n", g->allow_all ? 1 : 0); |
590 | } | 571 | } |
591 | 572 | ||
592 | static ssize_t allow_all_enable_store(struct device *device, | 573 | static ssize_t allow_all_enable_store(struct device *dev, |
593 | struct device_attribute *attr, const char *buf, size_t count) | 574 | struct device_attribute *attr, const char *buf, size_t count) |
594 | { | 575 | { |
595 | struct platform_device *ndev = to_platform_device(device); | 576 | struct gk20a *g = get_gk20a(dev); |
596 | struct gk20a *g = get_gk20a(ndev); | ||
597 | unsigned long val = 0; | 577 | unsigned long val = 0; |
598 | int err; | 578 | int err; |
599 | 579 | ||
@@ -610,11 +590,10 @@ static ssize_t allow_all_enable_store(struct device *device, | |||
610 | static DEVICE_ATTR(allow_all, ROOTRW, | 590 | static DEVICE_ATTR(allow_all, ROOTRW, |
611 | allow_all_enable_read, allow_all_enable_store); | 591 | allow_all_enable_read, allow_all_enable_store); |
612 | 592 | ||
613 | static ssize_t emc3d_ratio_store(struct device *device, | 593 | static ssize_t emc3d_ratio_store(struct device *dev, |
614 | struct device_attribute *attr, const char *buf, size_t count) | 594 | struct device_attribute *attr, const char *buf, size_t count) |
615 | { | 595 | { |
616 | struct platform_device *ndev = to_platform_device(device); | 596 | struct gk20a *g = get_gk20a(dev); |
617 | struct gk20a *g = get_gk20a(ndev); | ||
618 | unsigned long val = 0; | 597 | unsigned long val = 0; |
619 | 598 | ||
620 | if (kstrtoul(buf, 10, &val) < 0) | 599 | if (kstrtoul(buf, 10, &val) < 0) |
@@ -625,22 +604,20 @@ static ssize_t emc3d_ratio_store(struct device *device, | |||
625 | return count; | 604 | return count; |
626 | } | 605 | } |
627 | 606 | ||
628 | static ssize_t emc3d_ratio_read(struct device *device, | 607 | static ssize_t emc3d_ratio_read(struct device *dev, |
629 | struct device_attribute *attr, char *buf) | 608 | struct device_attribute *attr, char *buf) |
630 | { | 609 | { |
631 | struct platform_device *ndev = to_platform_device(device); | 610 | struct gk20a *g = get_gk20a(dev); |
632 | struct gk20a *g = get_gk20a(ndev); | ||
633 | 611 | ||
634 | return sprintf(buf, "%d\n", g->emc3d_ratio); | 612 | return sprintf(buf, "%d\n", g->emc3d_ratio); |
635 | } | 613 | } |
636 | 614 | ||
637 | static DEVICE_ATTR(emc3d_ratio, ROOTRW, emc3d_ratio_read, emc3d_ratio_store); | 615 | static DEVICE_ATTR(emc3d_ratio, ROOTRW, emc3d_ratio_read, emc3d_ratio_store); |
638 | 616 | ||
639 | static ssize_t fmax_at_vmin_safe_read(struct device *device, | 617 | static ssize_t fmax_at_vmin_safe_read(struct device *dev, |
640 | struct device_attribute *attr, char *buf) | 618 | struct device_attribute *attr, char *buf) |
641 | { | 619 | { |
642 | struct platform_device *ndev = to_platform_device(device); | 620 | struct gk20a *g = get_gk20a(dev); |
643 | struct gk20a *g = get_gk20a(ndev); | ||
644 | unsigned long gpu_fmax_at_vmin_hz = 0; | 621 | unsigned long gpu_fmax_at_vmin_hz = 0; |
645 | 622 | ||
646 | gpu_fmax_at_vmin_hz = tegra_dvfs_get_fmax_at_vmin_safe_t( | 623 | gpu_fmax_at_vmin_hz = tegra_dvfs_get_fmax_at_vmin_safe_t( |
@@ -652,11 +629,10 @@ static ssize_t fmax_at_vmin_safe_read(struct device *device, | |||
652 | static DEVICE_ATTR(fmax_at_vmin_safe, S_IRUGO, fmax_at_vmin_safe_read, NULL); | 629 | static DEVICE_ATTR(fmax_at_vmin_safe, S_IRUGO, fmax_at_vmin_safe_read, NULL); |
653 | 630 | ||
654 | #ifdef CONFIG_PM | 631 | #ifdef CONFIG_PM |
655 | static ssize_t force_idle_store(struct device *device, | 632 | static ssize_t force_idle_store(struct device *dev, |
656 | struct device_attribute *attr, const char *buf, size_t count) | 633 | struct device_attribute *attr, const char *buf, size_t count) |
657 | { | 634 | { |
658 | struct platform_device *ndev = to_platform_device(device); | 635 | struct gk20a *g = get_gk20a(dev); |
659 | struct gk20a *g = get_gk20a(ndev); | ||
660 | unsigned long val = 0; | 636 | unsigned long val = 0; |
661 | int err = 0; | 637 | int err = 0; |
662 | 638 | ||
@@ -667,10 +643,10 @@ static ssize_t force_idle_store(struct device *device, | |||
667 | if (g->forced_idle) | 643 | if (g->forced_idle) |
668 | return count; /* do nothing */ | 644 | return count; /* do nothing */ |
669 | else { | 645 | else { |
670 | err = __gk20a_do_idle(ndev, false); | 646 | err = __gk20a_do_idle(dev, false); |
671 | if (!err) { | 647 | if (!err) { |
672 | g->forced_idle = 1; | 648 | g->forced_idle = 1; |
673 | dev_info(device, "gpu is idle : %d\n", | 649 | dev_info(dev, "gpu is idle : %d\n", |
674 | g->forced_idle); | 650 | g->forced_idle); |
675 | } | 651 | } |
676 | } | 652 | } |
@@ -678,10 +654,10 @@ static ssize_t force_idle_store(struct device *device, | |||
678 | if (!g->forced_idle) | 654 | if (!g->forced_idle) |
679 | return count; /* do nothing */ | 655 | return count; /* do nothing */ |
680 | else { | 656 | else { |
681 | err = __gk20a_do_unidle(ndev); | 657 | err = __gk20a_do_unidle(dev); |
682 | if (!err) { | 658 | if (!err) { |
683 | g->forced_idle = 0; | 659 | g->forced_idle = 0; |
684 | dev_info(device, "gpu is idle : %d\n", | 660 | dev_info(dev, "gpu is idle : %d\n", |
685 | g->forced_idle); | 661 | g->forced_idle); |
686 | } | 662 | } |
687 | } | 663 | } |
@@ -690,11 +666,10 @@ static ssize_t force_idle_store(struct device *device, | |||
690 | return count; | 666 | return count; |
691 | } | 667 | } |
692 | 668 | ||
693 | static ssize_t force_idle_read(struct device *device, | 669 | static ssize_t force_idle_read(struct device *dev, |
694 | struct device_attribute *attr, char *buf) | 670 | struct device_attribute *attr, char *buf) |
695 | { | 671 | { |
696 | struct platform_device *ndev = to_platform_device(device); | 672 | struct gk20a *g = get_gk20a(dev); |
697 | struct gk20a *g = get_gk20a(ndev); | ||
698 | 673 | ||
699 | return sprintf(buf, "%d\n", g->forced_idle ? 1 : 0); | 674 | return sprintf(buf, "%d\n", g->forced_idle ? 1 : 0); |
700 | } | 675 | } |
@@ -702,11 +677,10 @@ static ssize_t force_idle_read(struct device *device, | |||
702 | static DEVICE_ATTR(force_idle, ROOTRW, force_idle_read, force_idle_store); | 677 | static DEVICE_ATTR(force_idle, ROOTRW, force_idle_read, force_idle_store); |
703 | #endif | 678 | #endif |
704 | 679 | ||
705 | static ssize_t tpc_fs_mask_store(struct device *device, | 680 | static ssize_t tpc_fs_mask_store(struct device *dev, |
706 | struct device_attribute *attr, const char *buf, size_t count) | 681 | struct device_attribute *attr, const char *buf, size_t count) |
707 | { | 682 | { |
708 | struct platform_device *ndev = to_platform_device(device); | 683 | struct gk20a *g = get_gk20a(dev); |
709 | struct gk20a *g = get_gk20a(ndev); | ||
710 | unsigned long val = 0; | 684 | unsigned long val = 0; |
711 | 685 | ||
712 | if (kstrtoul(buf, 10, &val) < 0) | 686 | if (kstrtoul(buf, 10, &val) < 0) |
@@ -730,11 +704,10 @@ static ssize_t tpc_fs_mask_store(struct device *device, | |||
730 | return count; | 704 | return count; |
731 | } | 705 | } |
732 | 706 | ||
733 | static ssize_t tpc_fs_mask_read(struct device *device, | 707 | static ssize_t tpc_fs_mask_read(struct device *dev, |
734 | struct device_attribute *attr, char *buf) | 708 | struct device_attribute *attr, char *buf) |
735 | { | 709 | { |
736 | struct platform_device *ndev = to_platform_device(device); | 710 | struct gk20a *g = get_gk20a(dev); |
737 | struct gk20a *g = get_gk20a(ndev); | ||
738 | struct gr_gk20a *gr = &g->gr; | 711 | struct gr_gk20a *gr = &g->gr; |
739 | u32 gpc_index; | 712 | u32 gpc_index; |
740 | u32 tpc_fs_mask = 0; | 713 | u32 tpc_fs_mask = 0; |
@@ -760,7 +733,7 @@ static DEVICE_ATTR(tpc_fs_mask, ROOTRW, tpc_fs_mask_read, tpc_fs_mask_store); | |||
760 | 733 | ||
761 | void gk20a_remove_sysfs(struct device *dev) | 734 | void gk20a_remove_sysfs(struct device *dev) |
762 | { | 735 | { |
763 | struct gk20a *g = get_gk20a(to_platform_device(dev)); | 736 | struct gk20a *g = get_gk20a(dev); |
764 | 737 | ||
765 | device_remove_file(dev, &dev_attr_elcg_enable); | 738 | device_remove_file(dev, &dev_attr_elcg_enable); |
766 | device_remove_file(dev, &dev_attr_blcg_enable); | 739 | device_remove_file(dev, &dev_attr_blcg_enable); |
@@ -797,50 +770,50 @@ void gk20a_remove_sysfs(struct device *dev) | |||
797 | } | 770 | } |
798 | } | 771 | } |
799 | 772 | ||
800 | void gk20a_create_sysfs(struct platform_device *dev) | 773 | void gk20a_create_sysfs(struct device *dev) |
801 | { | 774 | { |
802 | struct gk20a *g = get_gk20a(dev); | 775 | struct gk20a *g = gk20a_from_dev(dev); |
803 | int error = 0; | 776 | int error = 0; |
804 | 777 | ||
805 | error |= device_create_file(&dev->dev, &dev_attr_elcg_enable); | 778 | error |= device_create_file(dev, &dev_attr_elcg_enable); |
806 | error |= device_create_file(&dev->dev, &dev_attr_blcg_enable); | 779 | error |= device_create_file(dev, &dev_attr_blcg_enable); |
807 | error |= device_create_file(&dev->dev, &dev_attr_slcg_enable); | 780 | error |= device_create_file(dev, &dev_attr_slcg_enable); |
808 | error |= device_create_file(&dev->dev, &dev_attr_ptimer_scale_factor); | 781 | error |= device_create_file(dev, &dev_attr_ptimer_scale_factor); |
809 | error |= device_create_file(&dev->dev, &dev_attr_elpg_enable); | 782 | error |= device_create_file(dev, &dev_attr_elpg_enable); |
810 | error |= device_create_file(&dev->dev, &dev_attr_emc3d_ratio); | 783 | error |= device_create_file(dev, &dev_attr_emc3d_ratio); |
811 | error |= device_create_file(&dev->dev, &dev_attr_fmax_at_vmin_safe); | 784 | error |= device_create_file(dev, &dev_attr_fmax_at_vmin_safe); |
812 | error |= device_create_file(&dev->dev, &dev_attr_counters); | 785 | error |= device_create_file(dev, &dev_attr_counters); |
813 | error |= device_create_file(&dev->dev, &dev_attr_counters_reset); | 786 | error |= device_create_file(dev, &dev_attr_counters_reset); |
814 | error |= device_create_file(&dev->dev, &dev_attr_load); | 787 | error |= device_create_file(dev, &dev_attr_load); |
815 | error |= device_create_file(&dev->dev, &dev_attr_railgate_delay); | 788 | error |= device_create_file(dev, &dev_attr_railgate_delay); |
816 | error |= device_create_file(&dev->dev, &dev_attr_is_railgated); | 789 | error |= device_create_file(dev, &dev_attr_is_railgated); |
817 | error |= device_create_file(&dev->dev, &dev_attr_clockgate_delay); | 790 | error |= device_create_file(dev, &dev_attr_clockgate_delay); |
818 | #ifdef CONFIG_PM | 791 | #ifdef CONFIG_PM |
819 | error |= device_create_file(&dev->dev, &dev_attr_force_idle); | 792 | error |= device_create_file(dev, &dev_attr_force_idle); |
820 | #if defined(CONFIG_PM_GENERIC_DOMAINS) | 793 | #if defined(CONFIG_PM_GENERIC_DOMAINS) |
821 | error |= device_create_file(&dev->dev, &dev_attr_railgate_enable); | 794 | error |= device_create_file(dev, &dev_attr_railgate_enable); |
822 | #endif | 795 | #endif |
823 | #endif | 796 | #endif |
824 | error |= device_create_file(&dev->dev, &dev_attr_aelpg_param); | 797 | error |= device_create_file(dev, &dev_attr_aelpg_param); |
825 | error |= device_create_file(&dev->dev, &dev_attr_aelpg_enable); | 798 | error |= device_create_file(dev, &dev_attr_aelpg_enable); |
826 | error |= device_create_file(&dev->dev, &dev_attr_allow_all); | 799 | error |= device_create_file(dev, &dev_attr_allow_all); |
827 | error |= device_create_file(&dev->dev, &dev_attr_tpc_fs_mask); | 800 | error |= device_create_file(dev, &dev_attr_tpc_fs_mask); |
828 | 801 | ||
829 | if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev)) { | 802 | if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) { |
830 | error |= sysfs_create_link(&g->host1x_dev->dev.kobj, | 803 | error |= sysfs_create_link(&g->host1x_dev->dev.kobj, |
831 | &dev->dev.kobj, | 804 | &dev->kobj, |
832 | dev_name(&dev->dev)); | 805 | dev_name(dev)); |
833 | if (strcmp(dev_name(&dev->dev), "gpu.0")) { | 806 | if (strcmp(dev_name(dev), "gpu.0")) { |
834 | struct kobject *kobj = &dev->dev.kobj; | 807 | struct kobject *kobj = &dev->kobj; |
835 | struct device *parent = container_of((kobj->parent), | 808 | struct device *parent = container_of((kobj->parent), |
836 | struct device, kobj); | 809 | struct device, kobj); |
837 | error |= sysfs_create_link(&parent->kobj, | 810 | error |= sysfs_create_link(&parent->kobj, |
838 | &dev->dev.kobj, "gpu.0"); | 811 | &dev->kobj, "gpu.0"); |
839 | } | 812 | } |
840 | 813 | ||
841 | } | 814 | } |
842 | 815 | ||
843 | if (error) | 816 | if (error) |
844 | dev_err(&dev->dev, "Failed to create sysfs attributes!\n"); | 817 | dev_err(dev, "Failed to create sysfs attributes!\n"); |
845 | 818 | ||
846 | } | 819 | } |