diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2016-02-12 00:22:17 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2016-03-13 20:13:55 -0400 |
commit | 2efd3908517d0d32014dd88ccece9f40c3c4e13a (patch) | |
tree | da174a92ebd85aaab38813709e8c319d6a163a1d | |
parent | 195c113773c50fbc2bbe319d48ce82e43d9ff09c (diff) |
drm/nouveau/clk/gk20a: split gk20a_clk_new()
This allows to instanciate drivers that use the same logic as gk20a with
different parameters.
Add a constructor function to allow other chips that inherit from this
clock to easily initialize its members
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c index 311cf49fdd94..4e92186a1bb3 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c | |||
@@ -671,29 +671,48 @@ gk20a_clk = { | |||
671 | }; | 671 | }; |
672 | 672 | ||
673 | int | 673 | int |
674 | gk20a_clk_new(struct nvkm_device *device, int index, struct nvkm_clk **pclk) | 674 | _gk20a_clk_ctor(struct nvkm_device *device, int index, |
675 | const struct nvkm_clk_func *func, | ||
676 | const struct gk20a_clk_pllg_params *params, | ||
677 | struct gk20a_clk *clk) | ||
675 | { | 678 | { |
676 | struct nvkm_device_tegra *tdev = device->func->tegra(device); | 679 | struct nvkm_device_tegra *tdev = device->func->tegra(device); |
677 | struct gk20a_clk *clk; | 680 | int ret; |
678 | int ret, i; | 681 | int i; |
679 | |||
680 | if (!(clk = kzalloc(sizeof(*clk), GFP_KERNEL))) | ||
681 | return -ENOMEM; | ||
682 | *pclk = &clk->base; | ||
683 | 682 | ||
684 | /* Finish initializing the pstates */ | 683 | /* Finish initializing the pstates */ |
685 | for (i = 0; i < ARRAY_SIZE(gk20a_pstates); i++) { | 684 | for (i = 0; i < func->nr_pstates; i++) { |
686 | INIT_LIST_HEAD(&gk20a_pstates[i].list); | 685 | INIT_LIST_HEAD(&func->pstates[i].list); |
687 | gk20a_pstates[i].pstate = i + 1; | 686 | func->pstates[i].pstate = i + 1; |
688 | } | 687 | } |
689 | 688 | ||
690 | clk->params = &gk20a_pllg_params; | 689 | clk->params = params; |
691 | clk->parent_rate = clk_get_rate(tdev->clk); | 690 | clk->parent_rate = clk_get_rate(tdev->clk); |
692 | 691 | ||
693 | ret = nvkm_clk_ctor(&gk20a_clk, device, index, true, &clk->base); | 692 | ret = nvkm_clk_ctor(func, device, index, true, &clk->base); |
693 | if (ret) | ||
694 | return ret; | ||
695 | |||
694 | nvkm_debug(&clk->base.subdev, "parent clock rate: %d Khz\n", | 696 | nvkm_debug(&clk->base.subdev, "parent clock rate: %d Khz\n", |
695 | clk->parent_rate / KHZ); | 697 | clk->parent_rate / KHZ); |
696 | 698 | ||
699 | return 0; | ||
700 | } | ||
701 | |||
702 | int | ||
703 | gk20a_clk_new(struct nvkm_device *device, int index, struct nvkm_clk **pclk) | ||
704 | { | ||
705 | struct gk20a_clk *clk; | ||
706 | int ret; | ||
707 | |||
708 | clk = kzalloc(sizeof(*clk), GFP_KERNEL); | ||
709 | if (!clk) | ||
710 | return -ENOMEM; | ||
711 | *pclk = &clk->base; | ||
712 | |||
713 | ret = _gk20a_clk_ctor(device, index, &gk20a_clk, &gk20a_pllg_params, | ||
714 | clk); | ||
715 | |||
697 | clk->pl_to_div = pl_to_div; | 716 | clk->pl_to_div = pl_to_div; |
698 | clk->div_to_pl = div_to_pl; | 717 | clk->div_to_pl = div_to_pl; |
699 | 718 | ||