diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2014-07-26 05:41:40 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2014-08-09 15:12:47 -0400 |
commit | bb4d29df5e929a356e2cff2a6d7f38442d322d5b (patch) | |
tree | 439b721a4b2c7b7e0457f68799214ec5a7f18e05 /drivers/gpu | |
parent | 2cfd22f4730d5e759a313729b92a72bcc12c41cb (diff) |
drm/nouveau/clk: support for non-BIOS pstates
Make nouveau_clock_create() take new two optional arguments: an array
of pstates and its size. When these are specified,
nouveau_clock_create() will use the provided pstates instead of
probing them using the BIOS.
This is useful for platforms which do not provide a BIOS, like Tegra.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
9 files changed, 30 insertions, 20 deletions
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h index 9f37c096c34d..a7581478e4ea 100644 --- a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h +++ b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h | |||
@@ -115,8 +115,9 @@ struct nouveau_clocks { | |||
115 | int mdiv; | 115 | int mdiv; |
116 | }; | 116 | }; |
117 | 117 | ||
118 | #define nouveau_clock_create(p,e,o,i,r,d) \ | 118 | #define nouveau_clock_create(p,e,o,i,r,s,n,d) \ |
119 | nouveau_clock_create_((p), (e), (o), (i), (r), sizeof(**d), (void **)d) | 119 | nouveau_clock_create_((p), (e), (o), (i), (r), (s), (n), sizeof(**d), \ |
120 | (void **)d) | ||
120 | #define nouveau_clock_destroy(p) ({ \ | 121 | #define nouveau_clock_destroy(p) ({ \ |
121 | struct nouveau_clock *clk = (p); \ | 122 | struct nouveau_clock *clk = (p); \ |
122 | _nouveau_clock_dtor(nv_object(clk)); \ | 123 | _nouveau_clock_dtor(nv_object(clk)); \ |
@@ -132,7 +133,8 @@ struct nouveau_clocks { | |||
132 | 133 | ||
133 | int nouveau_clock_create_(struct nouveau_object *, struct nouveau_object *, | 134 | int nouveau_clock_create_(struct nouveau_object *, struct nouveau_object *, |
134 | struct nouveau_oclass *, | 135 | struct nouveau_oclass *, |
135 | struct nouveau_clocks *, bool, int, void **); | 136 | struct nouveau_clocks *, struct nouveau_pstate *, |
137 | int, bool, int, void **); | ||
136 | void _nouveau_clock_dtor(struct nouveau_object *); | 138 | void _nouveau_clock_dtor(struct nouveau_object *); |
137 | int _nouveau_clock_init(struct nouveau_object *); | 139 | int _nouveau_clock_init(struct nouveau_object *); |
138 | int _nouveau_clock_fini(struct nouveau_object *, bool); | 140 | int _nouveau_clock_fini(struct nouveau_object *, bool); |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c index 508639d0f088..d3f70d892d54 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c | |||
@@ -534,6 +534,7 @@ nouveau_clock_create_(struct nouveau_object *parent, | |||
534 | struct nouveau_object *engine, | 534 | struct nouveau_object *engine, |
535 | struct nouveau_oclass *oclass, | 535 | struct nouveau_oclass *oclass, |
536 | struct nouveau_clocks *clocks, | 536 | struct nouveau_clocks *clocks, |
537 | struct nouveau_pstate *pstates, int nb_pstates, | ||
537 | bool allow_reclock, | 538 | bool allow_reclock, |
538 | int length, void **object) | 539 | int length, void **object) |
539 | { | 540 | { |
@@ -557,10 +558,17 @@ nouveau_clock_create_(struct nouveau_object *parent, | |||
557 | init_waitqueue_head(&clk->wait); | 558 | init_waitqueue_head(&clk->wait); |
558 | atomic_set(&clk->waiting, 0); | 559 | atomic_set(&clk->waiting, 0); |
559 | 560 | ||
560 | idx = 0; | 561 | /* If no pstates are provided, try and fetch them from the BIOS */ |
561 | do { | 562 | if (!pstates) { |
562 | ret = nouveau_pstate_new(clk, idx++); | 563 | idx = 0; |
563 | } while (ret == 0); | 564 | do { |
565 | ret = nouveau_pstate_new(clk, idx++); | ||
566 | } while (ret == 0); | ||
567 | } else { | ||
568 | for (idx = 0; idx < nb_pstates; idx++) | ||
569 | list_add_tail(&pstates[idx].head, &clk->states); | ||
570 | clk->state_nr = nb_pstates; | ||
571 | } | ||
564 | 572 | ||
565 | clk->allow_reclock = allow_reclock; | 573 | clk->allow_reclock = allow_reclock; |
566 | 574 | ||
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c index eb2d4425a49e..4c48232686be 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c | |||
@@ -82,8 +82,8 @@ nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
82 | struct nv04_clock_priv *priv; | 82 | struct nv04_clock_priv *priv; |
83 | int ret; | 83 | int ret; |
84 | 84 | ||
85 | ret = nouveau_clock_create(parent, engine, oclass, nv04_domain, false, | 85 | ret = nouveau_clock_create(parent, engine, oclass, nv04_domain, NULL, 0, |
86 | &priv); | 86 | false, &priv); |
87 | *pobject = nv_object(priv); | 87 | *pobject = nv_object(priv); |
88 | if (ret) | 88 | if (ret) |
89 | return ret; | 89 | return ret; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nv40.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nv40.c index 8a9e16839791..08368fe97029 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nv40.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nv40.c | |||
@@ -213,8 +213,8 @@ nv40_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
213 | struct nv40_clock_priv *priv; | 213 | struct nv40_clock_priv *priv; |
214 | int ret; | 214 | int ret; |
215 | 215 | ||
216 | ret = nouveau_clock_create(parent, engine, oclass, nv40_domain, true, | 216 | ret = nouveau_clock_create(parent, engine, oclass, nv40_domain, NULL, 0, |
217 | &priv); | 217 | true, &priv); |
218 | *pobject = nv_object(priv); | 218 | *pobject = nv_object(priv); |
219 | if (ret) | 219 | if (ret) |
220 | return ret; | 220 | return ret; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c index 8c132772ba9e..5070ebc260f8 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nv50.c | |||
@@ -507,7 +507,7 @@ nv50_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
507 | int ret; | 507 | int ret; |
508 | 508 | ||
509 | ret = nouveau_clock_create(parent, engine, oclass, pclass->domains, | 509 | ret = nouveau_clock_create(parent, engine, oclass, pclass->domains, |
510 | false, &priv); | 510 | NULL, 0, false, &priv); |
511 | *pobject = nv_object(priv); | 511 | *pobject = nv_object(priv); |
512 | if (ret) | 512 | if (ret) |
513 | return ret; | 513 | return ret; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c index 9fb58354a80b..087012b18956 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c | |||
@@ -302,8 +302,8 @@ nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
302 | struct nva3_clock_priv *priv; | 302 | struct nva3_clock_priv *priv; |
303 | int ret; | 303 | int ret; |
304 | 304 | ||
305 | ret = nouveau_clock_create(parent, engine, oclass, nva3_domain, false, | 305 | ret = nouveau_clock_create(parent, engine, oclass, nva3_domain, NULL, 0, |
306 | &priv); | 306 | false, &priv); |
307 | *pobject = nv_object(priv); | 307 | *pobject = nv_object(priv); |
308 | if (ret) | 308 | if (ret) |
309 | return ret; | 309 | return ret; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c index 6a65fc9e9663..74e19731b1b7 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c | |||
@@ -421,8 +421,8 @@ nvaa_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
421 | struct nvaa_clock_priv *priv; | 421 | struct nvaa_clock_priv *priv; |
422 | int ret; | 422 | int ret; |
423 | 423 | ||
424 | ret = nouveau_clock_create(parent, engine, oclass, nvaa_domains, true, | 424 | ret = nouveau_clock_create(parent, engine, oclass, nvaa_domains, NULL, |
425 | &priv); | 425 | 0, true, &priv); |
426 | *pobject = nv_object(priv); | 426 | *pobject = nv_object(priv); |
427 | if (ret) | 427 | if (ret) |
428 | return ret; | 428 | return ret; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c index dbf8517f54da..1234abaab2db 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c | |||
@@ -437,8 +437,8 @@ nvc0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
437 | struct nvc0_clock_priv *priv; | 437 | struct nvc0_clock_priv *priv; |
438 | int ret; | 438 | int ret; |
439 | 439 | ||
440 | ret = nouveau_clock_create(parent, engine, oclass, nvc0_domain, false, | 440 | ret = nouveau_clock_create(parent, engine, oclass, nvc0_domain, NULL, 0, |
441 | &priv); | 441 | false, &priv); |
442 | *pobject = nv_object(priv); | 442 | *pobject = nv_object(priv); |
443 | if (ret) | 443 | if (ret) |
444 | return ret; | 444 | return ret; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c index 0e62a3240144..7eccad57512e 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c | |||
@@ -475,8 +475,8 @@ nve0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
475 | struct nve0_clock_priv *priv; | 475 | struct nve0_clock_priv *priv; |
476 | int ret; | 476 | int ret; |
477 | 477 | ||
478 | ret = nouveau_clock_create(parent, engine, oclass, nve0_domain, true, | 478 | ret = nouveau_clock_create(parent, engine, oclass, nve0_domain, NULL, 0, |
479 | &priv); | 479 | true, &priv); |
480 | *pobject = nv_object(priv); | 480 | *pobject = nv_object(priv); |
481 | if (ret) | 481 | if (ret) |
482 | return ret; | 482 | return ret; |