mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
The compiler option -Wmissing-prototypes is being enabled globally in the upstream Linux kernel and this causes build failures for nvgpu. The build failures occur because either the driver is missing an include file which has the prototype or because the function is not declared statically when it should be (ie. there are no external users). Fix the various build failures and enable -Wmissing-prototypes to prevent any new instances from occurring. Bug 4404965 Change-Id: I551922836e37b0c94c158232d6277f4053e9d2d3 Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/3027483 (cherry picked from commit e8cbf90db2d0db7277db9e3eec9fb88d69c7fcc7) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/3035518 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
102 lines
2.5 KiB
C
102 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
// SPDX-FileCopyrightText: Copyright (c) 2017-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
|
|
/*
|
|
* Linux clock support for ga10b
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include "clk.h"
|
|
#include "clk_ga10b.h"
|
|
#include "os_linux.h"
|
|
#include "platform_gk20a.h"
|
|
|
|
#include <nvgpu/gk20a.h>
|
|
#include <nvgpu/clk_arb.h>
|
|
#include <nvgpu/gr/gr_utils.h>
|
|
#include <nvgpu/gr/config.h>
|
|
#include <nvgpu/pmu/clk/clk.h>
|
|
|
|
/*
|
|
* GA10B clock list:
|
|
* platform->clk[0]- sysclk
|
|
* For GPU Full config:
|
|
* platform->clk[1] - gpc0 clk
|
|
* platform->clk[2] - gpc1 clk
|
|
* platform->clk[3] - fuse clk
|
|
* For GPU GPC Floor-swept config:
|
|
* platform->clk[1] - Active gpc(gpc0/gpc1) clk
|
|
* platform->clk[2] - fuse clk
|
|
*/
|
|
|
|
/*
|
|
* GPU clock policy for ga10b:
|
|
* All sys, gpc0 and gpc1 clk are at same rate.
|
|
* So, for clock set_rate, change all clocks for
|
|
* any clock rate change request.
|
|
*/
|
|
|
|
/*
|
|
* PWRCLK is used for pmu runs at fixed rate 204MHZ in ga10b
|
|
* PWRCLK is enabled once gpu out of reset. CCF is not
|
|
* supporting any clock set/get calls for PWRCLK. To support
|
|
* legacy code, nvgpu driver only supporting clk_get_rate by
|
|
* returning fixed 204MHz rate
|
|
*/
|
|
#define NVGPU_GA10B_PWRCLK_RATE 204000000UL;
|
|
|
|
unsigned long nvgpu_ga10b_linux_clk_get_rate(
|
|
struct gk20a *g, u32 api_domain)
|
|
{
|
|
struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
|
|
unsigned long ret;
|
|
|
|
switch (api_domain) {
|
|
case CTRL_CLK_DOMAIN_SYSCLK:
|
|
case CTRL_CLK_DOMAIN_GPCCLK:
|
|
ret = clk_get_rate(platform->clk[0]);
|
|
break;
|
|
case CTRL_CLK_DOMAIN_PWRCLK:
|
|
/* power domain is at fixed clock */
|
|
ret = NVGPU_GA10B_PWRCLK_RATE;
|
|
break;
|
|
default:
|
|
nvgpu_err(g, "unknown clock: %u", api_domain);
|
|
ret = 0;
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int nvgpu_ga10b_linux_clk_set_rate(struct gk20a *g,
|
|
u32 api_domain, unsigned long rate)
|
|
{
|
|
struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
|
|
struct nvgpu_gr_config *gr_config = nvgpu_gr_get_config_ptr(g);
|
|
u32 gpc_count = nvgpu_gr_config_get_gpc_count(gr_config);
|
|
int ret;
|
|
|
|
switch (api_domain) {
|
|
case CTRL_CLK_DOMAIN_GPCCLK:
|
|
case CTRL_CLK_DOMAIN_SYSCLK:
|
|
ret = clk_set_rate(platform->clk[0], rate);
|
|
ret = clk_set_rate(platform->clk[1], rate);
|
|
/* Set second gpcclk for full-config */
|
|
if (gpc_count == 2U)
|
|
ret = clk_set_rate(platform->clk[2], rate);
|
|
break;
|
|
case CTRL_CLK_DOMAIN_PWRCLK:
|
|
nvgpu_err(g, "unsupported operation: %u", api_domain);
|
|
ret = -EINVAL;
|
|
break;
|
|
default:
|
|
nvgpu_err(g, "unknown clock: %u", api_domain);
|
|
ret = -EINVAL;
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|