From 25440e63d2dfd329ba35aec48f11f0c20b18cdbd Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Tue, 31 Oct 2017 06:11:57 -0700 Subject: gpu: nvgpu: move platform_gk20a.h to linux Move gk20a/platform_gk20a.h to linux specific directory as common/linux/platform_gk20a.h since this file includes all linux specific stuff Fix #includes in all the files to include this file with correct path Remove #include of this file where it is no more needed Fix gk20a_init_sim_support() to receive struct gk20a as parameter instead of receiving linux specific struct platform_device NVGPU-316 Change-Id: I5ec08e776b753af4d39d11c11f6f068be2ac236f Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/1589938 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/as.c | 1 - drivers/gpu/nvgpu/common/linux/clk.c | 2 +- drivers/gpu/nvgpu/common/linux/ctxsw_trace.c | 2 +- drivers/gpu/nvgpu/common/linux/debug.c | 2 +- drivers/gpu/nvgpu/common/linux/debug_cde.c | 2 +- drivers/gpu/nvgpu/common/linux/debug_clk.c | 2 +- drivers/gpu/nvgpu/common/linux/dma.c | 2 +- drivers/gpu/nvgpu/common/linux/dmabuf.c | 2 +- drivers/gpu/nvgpu/common/linux/driver_common.c | 2 +- drivers/gpu/nvgpu/common/linux/firmware.c | 2 +- drivers/gpu/nvgpu/common/linux/ioctl.c | 2 +- drivers/gpu/nvgpu/common/linux/ioctl_as.c | 2 +- drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 2 +- drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c | 2 +- drivers/gpu/nvgpu/common/linux/ioctl_dbg.c | 2 +- drivers/gpu/nvgpu/common/linux/ioctl_tsg.c | 2 +- drivers/gpu/nvgpu/common/linux/log.c | 2 +- drivers/gpu/nvgpu/common/linux/module.c | 4 +- drivers/gpu/nvgpu/common/linux/pci.c | 2 +- drivers/gpu/nvgpu/common/linux/platform_gk20a.h | 302 +++++++++++++++++++++ .../gpu/nvgpu/common/linux/platform_gk20a_tegra.c | 2 +- .../gpu/nvgpu/common/linux/platform_gp10b_tegra.c | 2 +- drivers/gpu/nvgpu/common/linux/scale.c | 2 +- drivers/gpu/nvgpu/common/linux/sysfs.c | 2 +- drivers/gpu/nvgpu/common/linux/timers.c | 3 +- drivers/gpu/nvgpu/common/linux/vm.c | 2 +- drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 1 - drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 1 - drivers/gpu/nvgpu/gk20a/platform_gk20a.h | 302 --------------------- drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c | 2 +- drivers/gpu/nvgpu/gk20a/sim_gk20a.c | 5 +- drivers/gpu/nvgpu/gk20a/sim_gk20a.h | 2 +- drivers/gpu/nvgpu/gm20b/clk_gm20b.h | 3 + drivers/gpu/nvgpu/pmgr/pmgrpmu.c | 2 +- drivers/gpu/nvgpu/pmgr/pwrpolicy.c | 2 +- drivers/gpu/nvgpu/vgpu/css_vgpu.c | 2 +- drivers/gpu/nvgpu/vgpu/tsg_vgpu.c | 2 +- drivers/gpu/nvgpu/vgpu/vgpu.h | 2 +- 38 files changed, 339 insertions(+), 341 deletions(-) create mode 100644 drivers/gpu/nvgpu/common/linux/platform_gk20a.h delete mode 100644 drivers/gpu/nvgpu/gk20a/platform_gk20a.h (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/common/as.c b/drivers/gpu/nvgpu/common/as.c index 3fcc65fa..31cdd0b6 100644 --- a/drivers/gpu/nvgpu/common/as.c +++ b/drivers/gpu/nvgpu/common/as.c @@ -28,7 +28,6 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" /* dumb allocator... */ static int generate_as_share_id(struct gk20a_as *as) diff --git a/drivers/gpu/nvgpu/common/linux/clk.c b/drivers/gpu/nvgpu/common/linux/clk.c index 3f768867..a9888590 100644 --- a/drivers/gpu/nvgpu/common/linux/clk.c +++ b/drivers/gpu/nvgpu/common/linux/clk.c @@ -22,9 +22,9 @@ #include "clk.h" #include "os_linux.h" +#include "platform_gk20a.h" #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" static unsigned long nvgpu_linux_clk_get_rate(struct gk20a *g, u32 api_domain) { diff --git a/drivers/gpu/nvgpu/common/linux/ctxsw_trace.c b/drivers/gpu/nvgpu/common/linux/ctxsw_trace.c index a4a07a4c..8268bf60 100644 --- a/drivers/gpu/nvgpu/common/linux/ctxsw_trace.c +++ b/drivers/gpu/nvgpu/common/linux/ctxsw_trace.c @@ -23,13 +23,13 @@ #include "gk20a/gk20a.h" #include "gk20a/gr_gk20a.h" -#include "gk20a/platform_gk20a.h" #include #include #include #include +#include "platform_gk20a.h" #include "os_linux.h" #include "ctxsw_trace.h" diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c index 08d0e679..7a4e4e9f 100644 --- a/drivers/gpu/nvgpu/common/linux/debug.c +++ b/drivers/gpu/nvgpu/common/linux/debug.c @@ -24,9 +24,9 @@ #include "debug_hal.h" #include "debug_xve.h" #include "os_linux.h" +#include "platform_gk20a.h" #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include #include diff --git a/drivers/gpu/nvgpu/common/linux/debug_cde.c b/drivers/gpu/nvgpu/common/linux/debug_cde.c index cbea83b9..f0afa6ee 100644 --- a/drivers/gpu/nvgpu/common/linux/debug_cde.c +++ b/drivers/gpu/nvgpu/common/linux/debug_cde.c @@ -13,7 +13,7 @@ */ #include "debug_cde.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "os_linux.h" #include diff --git a/drivers/gpu/nvgpu/common/linux/debug_clk.c b/drivers/gpu/nvgpu/common/linux/debug_clk.c index 81839de7..2484d44b 100644 --- a/drivers/gpu/nvgpu/common/linux/debug_clk.c +++ b/drivers/gpu/nvgpu/common/linux/debug_clk.c @@ -16,9 +16,9 @@ #include #include -#include "gk20a/platform_gk20a.h" #include "gm20b/clk_gm20b.h" #include "os_linux.h" +#include "platform_gk20a.h" static int rate_get(void *data, u64 *val) { diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c index 9e9d1007..5bac42e3 100644 --- a/drivers/gpu/nvgpu/common/linux/dma.c +++ b/drivers/gpu/nvgpu/common/linux/dma.c @@ -31,8 +31,8 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "os_linux.h" /* diff --git a/drivers/gpu/nvgpu/common/linux/dmabuf.c b/drivers/gpu/nvgpu/common/linux/dmabuf.c index 2415b7c2..6b44ff55 100644 --- a/drivers/gpu/nvgpu/common/linux/dmabuf.c +++ b/drivers/gpu/nvgpu/common/linux/dmabuf.c @@ -25,8 +25,8 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "dmabuf.h" #include "os_linux.h" diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c index 759607a2..cdb28eaf 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c @@ -25,7 +25,7 @@ #include "scale.h" #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "module.h" #include "os_linux.h" #include "sysfs.h" diff --git a/drivers/gpu/nvgpu/common/linux/firmware.c b/drivers/gpu/nvgpu/common/linux/firmware.c index 44ff1507..a76165ff 100644 --- a/drivers/gpu/nvgpu/common/linux/firmware.c +++ b/drivers/gpu/nvgpu/common/linux/firmware.c @@ -21,7 +21,7 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "os_linux.h" static const struct firmware *do_request_firmware(struct device *dev, diff --git a/drivers/gpu/nvgpu/common/linux/ioctl.c b/drivers/gpu/nvgpu/common/linux/ioctl.c index c1053268..0aa7f6a3 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl.c @@ -22,7 +22,6 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gk20a/dbg_gpu_gk20a.h" #include "ioctl_channel.h" @@ -33,6 +32,7 @@ #include "module.h" #include "os_linux.h" #include "ctxsw_trace.h" +#include "platform_gk20a.h" #define GK20A_NUM_CDEVS 7 diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_as.c b/drivers/gpu/nvgpu/common/linux/ioctl_as.c index 18d0dd07..e566bfb4 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_as.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_as.c @@ -28,7 +28,7 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "ioctl_as.h" #include "os_linux.h" diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 5b0c4a50..44f662cb 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c @@ -33,8 +33,8 @@ #include "gk20a/gk20a.h" #include "gk20a/dbg_gpu_gk20a.h" #include "gk20a/fence_gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "ioctl_channel.h" #include "channel.h" #include "os_linux.h" diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c index 1442c19a..73911717 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c @@ -39,9 +39,9 @@ #include "ioctl_tsg.h" #include "ioctl_channel.h" #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gk20a/fence_gk20a.h" +#include "platform_gk20a.h" #include "os_linux.h" #include "dmabuf.h" diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_dbg.c b/drivers/gpu/nvgpu/common/linux/ioctl_dbg.c index 24bf813a..f8bdd19b 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_dbg.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_dbg.c @@ -33,11 +33,11 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gk20a/gr_gk20a.h" #include "gk20a/regops_gk20a.h" #include "gk20a/dbg_gpu_gk20a.h" #include "os_linux.h" +#include "platform_gk20a.h" #include "ioctl_dbg.h" diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c index 7eea636e..2570886d 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c @@ -25,8 +25,8 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gk20a/tsg_gk20a.h" +#include "platform_gk20a.h" #include "ioctl_tsg.h" #include "ioctl_channel.h" #include "os_linux.h" diff --git a/drivers/gpu/nvgpu/common/linux/log.c b/drivers/gpu/nvgpu/common/linux/log.c index f371bb77..e120a3de 100644 --- a/drivers/gpu/nvgpu/common/linux/log.c +++ b/drivers/gpu/nvgpu/common/linux/log.c @@ -20,7 +20,7 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "os_linux.h" /* diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index 7706d826..4aff6a2d 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c @@ -33,7 +33,7 @@ #include #include -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "sysfs.h" #include "vgpu/vgpu.h" #include "scale.h" @@ -661,7 +661,7 @@ static int gk20a_init_support(struct platform_device *dev) goto fail; } - err = gk20a_init_sim_support(dev); + err = gk20a_init_sim_support(g); if (err) goto fail; } diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c index 19483f86..118567e5 100644 --- a/drivers/gpu/nvgpu/common/linux/pci.c +++ b/drivers/gpu/nvgpu/common/linux/pci.c @@ -23,13 +23,13 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include "clk/clk.h" #include "clk/clk_mclk.h" #include "module.h" #include "intr.h" #include "sysfs.h" #include "os_linux.h" +#include "platform_gk20a.h" #include "pci.h" #ifdef CONFIG_TEGRA_19x_GPU diff --git a/drivers/gpu/nvgpu/common/linux/platform_gk20a.h b/drivers/gpu/nvgpu/common/linux/platform_gk20a.h new file mode 100644 index 00000000..348c9e24 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/platform_gk20a.h @@ -0,0 +1,302 @@ +/* + * GK20A Platform (SoC) Interface + * + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef _GK20A_PLATFORM_H_ +#define _GK20A_PLATFORM_H_ + +#include + +#include + +#include "gk20a/gk20a.h" + +#define GK20A_CLKS_MAX 4 + +struct gk20a; +struct channel_gk20a; +struct gr_ctx_buffer_desc; +struct gk20a_scale_profile; + +struct secure_page_buffer { + void (*destroy)(struct gk20a *, struct secure_page_buffer *); + size_t size; + u64 iova; +}; + +struct gk20a_platform { + /* Populated by the gk20a driver before probing the platform. */ + struct gk20a *g; + + /* Should be populated at probe. */ + bool can_railgate_init; + + /* Should be populated at probe. */ + bool can_elpg_init; + + /* Should be populated at probe. */ + bool has_syncpoints; + + /* channel limit after which to start aggressive sync destroy */ + unsigned int aggressive_sync_destroy_thresh; + + /* flag to set sync destroy aggressiveness */ + bool aggressive_sync_destroy; + + /* set if ASPM should be disabled on boot; only makes sense for PCI */ + bool disable_aspm; + + /* Set if the platform can unify the small/large address spaces. */ + bool unify_address_spaces; + + /* Clock configuration is stored here. Platform probe is responsible + * for filling this data. */ + struct clk *clk[GK20A_CLKS_MAX]; + int num_clks; + +#ifdef CONFIG_RESET_CONTROLLER + /* Reset control for device */ + struct reset_control *reset_control; +#endif + + /* Delay before rail gated */ + int railgate_delay_init; + + /* Second Level Clock Gating: true = enable false = disable */ + bool enable_slcg; + + /* Block Level Clock Gating: true = enable flase = disable */ + bool enable_blcg; + + /* Engine Level Clock Gating: true = enable flase = disable */ + bool enable_elcg; + + /* Should be populated at probe. */ + bool can_slcg; + + /* Should be populated at probe. */ + bool can_blcg; + + /* Should be populated at probe. */ + bool can_elcg; + + /* Engine Level Power Gating: true = enable flase = disable */ + bool enable_elpg; + + /* Adaptative ELPG: true = enable flase = disable */ + bool enable_aelpg; + + /* PMU Perfmon: true = enable false = disable */ + bool enable_perfmon; + + /* Memory System Clock Gating: true = enable flase = disable*/ + bool enable_mscg; + + /* Timeout for per-channel watchdog (in mS) */ + u32 ch_wdt_timeout_ms; + + /* Enable SMMU bypass by default */ + bool bypass_smmu; + + /* Disable big page support */ + bool disable_bigpage; + + /* + * gk20a_do_idle() API can take GPU either into rail gate or CAR reset + * This flag can be used to force CAR reset case instead of rail gate + */ + bool force_reset_in_do_idle; + + /* default pri timeout, on PCIe it should be lower than timeout + * detection + */ + u32 default_pri_timeout; + + /* Initialize the platform interface of the gk20a driver. + * + * The platform implementation of this function must + * - set the power and clocks of the gk20a device to a known + * state, and + * - populate the gk20a_platform structure (a pointer to the + * structure can be obtained by calling gk20a_get_platform). + * + * After this function is finished, the driver will initialise + * pm runtime and genpd based on the platform configuration. + */ + int (*probe)(struct device *dev); + + /* Second stage initialisation - called once all power management + * initialisations are done. + */ + int (*late_probe)(struct device *dev); + + /* Remove device after power management has been done + */ + int (*remove)(struct device *dev); + + /* Poweron platform dependencies */ + int (*busy)(struct device *dev); + + /* Powerdown platform dependencies */ + void (*idle)(struct device *dev); + + struct secure_page_buffer secure_buffer; + + /* Device is going to be suspended */ + int (*suspend)(struct device *); + + /* Called to turn off the device */ + int (*railgate)(struct device *dev); + + /* Called to turn on the device */ + int (*unrailgate)(struct device *dev); + struct nvgpu_mutex railgate_lock; + + /* Called to check state of device */ + bool (*is_railgated)(struct device *dev); + + /* get supported frequency list */ + int (*get_clk_freqs)(struct device *pdev, + unsigned long **freqs, int *num_freqs); + + /* clk related supported functions */ + long (*clk_round_rate)(struct device *dev, + unsigned long rate); + + /* Called to register GPCPLL with common clk framework */ + int (*clk_register)(struct gk20a *g); + + /* Postscale callback is called after frequency change */ + void (*postscale)(struct device *dev, + unsigned long freq); + + /* Pre callback is called before frequency change */ + void (*prescale)(struct device *dev); + + /* Devfreq governor name. If scaling is enabled, we request + * this governor to be used in scaling */ + const char *devfreq_governor; + + /* Quality of service notifier callback. If this is set, the scaling + * routines will register a callback to Qos. Each time we receive + * a new value, this callback gets called. */ + int (*qos_notify)(struct notifier_block *nb, + unsigned long n, void *p); + + /* Called as part of debug dump. If the gpu gets hung, this function + * is responsible for delivering all necessary debug data of other + * hw units which may interact with the gpu without direct supervision + * of the CPU. + */ + void (*dump_platform_dependencies)(struct device *dev); + + /* Callbacks to assert/deassert GPU reset */ + int (*reset_assert)(struct device *dev); + int (*reset_deassert)(struct device *dev); + struct clk *clk_reset; + struct dvfs_rail *gpu_rail; + + bool virtual_dev; +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION + void *vgpu_priv; +#endif + /* source frequency for ptimer in hz */ + u32 ptimer_src_freq; + + bool has_cde; + + /* soc name for finding firmware files */ + const char *soc_name; + + /* false if vidmem aperture actually points to sysmem */ + bool honors_aperture; + /* unified or split memory with separate vidmem? */ + bool unified_memory; + + /* true if all channels must be in TSG */ + bool tsg_required; + + /* minimum supported VBIOS version */ + u32 vbios_min_version; + + /* true if we run preos microcode on this board */ + bool run_preos; + + /* true if we need to program sw threshold for + * power limits + */ + bool hardcode_sw_threshold; + + /* i2c device index, port and address for INA3221 */ + u32 ina3221_dcb_index; + u32 ina3221_i2c_address; + u32 ina3221_i2c_port; +}; + +static inline struct gk20a_platform *gk20a_get_platform( + struct device *dev) +{ + return (struct gk20a_platform *)dev_get_drvdata(dev); +} + +#ifdef CONFIG_TEGRA_GK20A +extern struct gk20a_platform gm20b_tegra_platform; +extern struct gk20a_platform gp10b_tegra_platform; +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION +extern struct gk20a_platform vgpu_tegra_platform; +#endif +#endif + +int gk20a_tegra_busy(struct device *dev); +void gk20a_tegra_idle(struct device *dev); +void gk20a_tegra_debug_dump(struct device *pdev); + +static inline struct gk20a *get_gk20a(struct device *dev) +{ + return gk20a_get_platform(dev)->g; +} +static inline struct gk20a *gk20a_from_dev(struct device *dev) +{ + if (!dev) + return NULL; + + return ((struct gk20a_platform *)dev_get_drvdata(dev))->g; +} +static inline bool gk20a_gpu_is_virtual(struct device *dev) +{ + struct gk20a_platform *platform = dev_get_drvdata(dev); + + return platform->virtual_dev; +} + +static inline int support_gk20a_pmu(struct device *dev) +{ + if (IS_ENABLED(CONFIG_GK20A_PMU)) { + /* gPMU is not supported for vgpu */ + return !gk20a_gpu_is_virtual(dev); + } + + return 0; +} + +#endif diff --git a/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c index 2d6d156c..c40eafe4 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c @@ -47,10 +47,10 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gm20b/clk_gm20b.h" #include "scale.h" +#include "platform_gk20a.h" #include "clk.h" #include "os_linux.h" diff --git a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c index 1f7a7694..b944844e 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c @@ -35,9 +35,9 @@ #include "clk.h" -#include "gk20a/platform_gk20a.h" #include "gk20a/gk20a.h" +#include "platform_gk20a.h" #include "platform_gk20a_tegra.h" #include "gp10b/platform_gp10b.h" #include "platform_gp10b_tegra.h" diff --git a/drivers/gpu/nvgpu/common/linux/scale.c b/drivers/gpu/nvgpu/common/linux/scale.c index 05f09dcc..84ac1cfd 100644 --- a/drivers/gpu/nvgpu/common/linux/scale.c +++ b/drivers/gpu/nvgpu/common/linux/scale.c @@ -27,7 +27,7 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "scale.h" #include "os_linux.h" diff --git a/drivers/gpu/nvgpu/common/linux/sysfs.c b/drivers/gpu/nvgpu/common/linux/sysfs.c index 6897fae8..b1e7d1ed 100644 --- a/drivers/gpu/nvgpu/common/linux/sysfs.c +++ b/drivers/gpu/nvgpu/common/linux/sysfs.c @@ -23,7 +23,7 @@ #include #include "sysfs.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "gk20a/pmu_gk20a.h" #include "gk20a/gr_gk20a.h" diff --git a/drivers/gpu/nvgpu/common/linux/timers.c b/drivers/gpu/nvgpu/common/linux/timers.c index 5786b240..d0004aa5 100644 --- a/drivers/gpu/nvgpu/common/linux/timers.c +++ b/drivers/gpu/nvgpu/common/linux/timers.c @@ -21,7 +21,8 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" + +#include "platform_gk20a.h" /* * Returns 1 if the platform is pre-Si and should ignore the timeout checking. diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c index bb337d97..d04ed5ed 100644 --- a/drivers/gpu/nvgpu/common/linux/vm.c +++ b/drivers/gpu/nvgpu/common/linux/vm.c @@ -32,8 +32,8 @@ #include "gk20a/gk20a.h" #include "gk20a/mm_gk20a.h" #include "gk20a/kind_gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "platform_gk20a.h" #include "os_linux.h" #include "dmabuf.h" diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index 802ccd76..f70cfdf8 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c @@ -29,7 +29,6 @@ #include #include "gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gr_gk20a.h" #include "dbg_gpu_gk20a.h" #include "regops_gk20a.h" diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index cb0c015e..d54e8d43 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c @@ -41,7 +41,6 @@ #include #include "gk20a.h" -#include "platform_gk20a.h" #include "mm_gk20a.h" #include "fence_gk20a.h" #include "kind_gk20a.h" diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h deleted file mode 100644 index d4ff17f3..00000000 --- a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * GK20A Platform (SoC) Interface - * - * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef _GK20A_PLATFORM_H_ -#define _GK20A_PLATFORM_H_ - -#include - -#include - -#include "gk20a.h" - -#define GK20A_CLKS_MAX 4 - -struct gk20a; -struct channel_gk20a; -struct gr_ctx_buffer_desc; -struct gk20a_scale_profile; - -struct secure_page_buffer { - void (*destroy)(struct gk20a *, struct secure_page_buffer *); - size_t size; - u64 iova; -}; - -struct gk20a_platform { - /* Populated by the gk20a driver before probing the platform. */ - struct gk20a *g; - - /* Should be populated at probe. */ - bool can_railgate_init; - - /* Should be populated at probe. */ - bool can_elpg_init; - - /* Should be populated at probe. */ - bool has_syncpoints; - - /* channel limit after which to start aggressive sync destroy */ - unsigned int aggressive_sync_destroy_thresh; - - /* flag to set sync destroy aggressiveness */ - bool aggressive_sync_destroy; - - /* set if ASPM should be disabled on boot; only makes sense for PCI */ - bool disable_aspm; - - /* Set if the platform can unify the small/large address spaces. */ - bool unify_address_spaces; - - /* Clock configuration is stored here. Platform probe is responsible - * for filling this data. */ - struct clk *clk[GK20A_CLKS_MAX]; - int num_clks; - -#ifdef CONFIG_RESET_CONTROLLER - /* Reset control for device */ - struct reset_control *reset_control; -#endif - - /* Delay before rail gated */ - int railgate_delay_init; - - /* Second Level Clock Gating: true = enable false = disable */ - bool enable_slcg; - - /* Block Level Clock Gating: true = enable flase = disable */ - bool enable_blcg; - - /* Engine Level Clock Gating: true = enable flase = disable */ - bool enable_elcg; - - /* Should be populated at probe. */ - bool can_slcg; - - /* Should be populated at probe. */ - bool can_blcg; - - /* Should be populated at probe. */ - bool can_elcg; - - /* Engine Level Power Gating: true = enable flase = disable */ - bool enable_elpg; - - /* Adaptative ELPG: true = enable flase = disable */ - bool enable_aelpg; - - /* PMU Perfmon: true = enable false = disable */ - bool enable_perfmon; - - /* Memory System Clock Gating: true = enable flase = disable*/ - bool enable_mscg; - - /* Timeout for per-channel watchdog (in mS) */ - u32 ch_wdt_timeout_ms; - - /* Enable SMMU bypass by default */ - bool bypass_smmu; - - /* Disable big page support */ - bool disable_bigpage; - - /* - * gk20a_do_idle() API can take GPU either into rail gate or CAR reset - * This flag can be used to force CAR reset case instead of rail gate - */ - bool force_reset_in_do_idle; - - /* default pri timeout, on PCIe it should be lower than timeout - * detection - */ - u32 default_pri_timeout; - - /* Initialize the platform interface of the gk20a driver. - * - * The platform implementation of this function must - * - set the power and clocks of the gk20a device to a known - * state, and - * - populate the gk20a_platform structure (a pointer to the - * structure can be obtained by calling gk20a_get_platform). - * - * After this function is finished, the driver will initialise - * pm runtime and genpd based on the platform configuration. - */ - int (*probe)(struct device *dev); - - /* Second stage initialisation - called once all power management - * initialisations are done. - */ - int (*late_probe)(struct device *dev); - - /* Remove device after power management has been done - */ - int (*remove)(struct device *dev); - - /* Poweron platform dependencies */ - int (*busy)(struct device *dev); - - /* Powerdown platform dependencies */ - void (*idle)(struct device *dev); - - struct secure_page_buffer secure_buffer; - - /* Device is going to be suspended */ - int (*suspend)(struct device *); - - /* Called to turn off the device */ - int (*railgate)(struct device *dev); - - /* Called to turn on the device */ - int (*unrailgate)(struct device *dev); - struct nvgpu_mutex railgate_lock; - - /* Called to check state of device */ - bool (*is_railgated)(struct device *dev); - - /* get supported frequency list */ - int (*get_clk_freqs)(struct device *pdev, - unsigned long **freqs, int *num_freqs); - - /* clk related supported functions */ - long (*clk_round_rate)(struct device *dev, - unsigned long rate); - - /* Called to register GPCPLL with common clk framework */ - int (*clk_register)(struct gk20a *g); - - /* Postscale callback is called after frequency change */ - void (*postscale)(struct device *dev, - unsigned long freq); - - /* Pre callback is called before frequency change */ - void (*prescale)(struct device *dev); - - /* Devfreq governor name. If scaling is enabled, we request - * this governor to be used in scaling */ - const char *devfreq_governor; - - /* Quality of service notifier callback. If this is set, the scaling - * routines will register a callback to Qos. Each time we receive - * a new value, this callback gets called. */ - int (*qos_notify)(struct notifier_block *nb, - unsigned long n, void *p); - - /* Called as part of debug dump. If the gpu gets hung, this function - * is responsible for delivering all necessary debug data of other - * hw units which may interact with the gpu without direct supervision - * of the CPU. - */ - void (*dump_platform_dependencies)(struct device *dev); - - /* Callbacks to assert/deassert GPU reset */ - int (*reset_assert)(struct device *dev); - int (*reset_deassert)(struct device *dev); - struct clk *clk_reset; - struct dvfs_rail *gpu_rail; - - bool virtual_dev; -#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION - void *vgpu_priv; -#endif - /* source frequency for ptimer in hz */ - u32 ptimer_src_freq; - - bool has_cde; - - /* soc name for finding firmware files */ - const char *soc_name; - - /* false if vidmem aperture actually points to sysmem */ - bool honors_aperture; - /* unified or split memory with separate vidmem? */ - bool unified_memory; - - /* true if all channels must be in TSG */ - bool tsg_required; - - /* minimum supported VBIOS version */ - u32 vbios_min_version; - - /* true if we run preos microcode on this board */ - bool run_preos; - - /* true if we need to program sw threshold for - * power limits - */ - bool hardcode_sw_threshold; - - /* i2c device index, port and address for INA3221 */ - u32 ina3221_dcb_index; - u32 ina3221_i2c_address; - u32 ina3221_i2c_port; -}; - -static inline struct gk20a_platform *gk20a_get_platform( - struct device *dev) -{ - return (struct gk20a_platform *)dev_get_drvdata(dev); -} - -#ifdef CONFIG_TEGRA_GK20A -extern struct gk20a_platform gm20b_tegra_platform; -extern struct gk20a_platform gp10b_tegra_platform; -#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION -extern struct gk20a_platform vgpu_tegra_platform; -#endif -#endif - -int gk20a_tegra_busy(struct device *dev); -void gk20a_tegra_idle(struct device *dev); -void gk20a_tegra_debug_dump(struct device *pdev); - -static inline struct gk20a *get_gk20a(struct device *dev) -{ - return gk20a_get_platform(dev)->g; -} -static inline struct gk20a *gk20a_from_dev(struct device *dev) -{ - if (!dev) - return NULL; - - return ((struct gk20a_platform *)dev_get_drvdata(dev))->g; -} -static inline bool gk20a_gpu_is_virtual(struct device *dev) -{ - struct gk20a_platform *platform = dev_get_drvdata(dev); - - return platform->virtual_dev; -} - -static inline int support_gk20a_pmu(struct device *dev) -{ - if (IS_ENABLED(CONFIG_GK20A_PMU)) { - /* gPMU is not supported for vgpu */ - return !gk20a_gpu_is_virtual(dev); - } - - return 0; -} - -#endif diff --git a/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c b/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c index 90a37c47..6209188c 100644 --- a/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c +++ b/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c @@ -23,7 +23,7 @@ */ #include "gk20a.h" -#include "platform_gk20a.h" +#include "common/linux/platform_gk20a.h" #include "vgpu/clk_vgpu.h" #include diff --git a/drivers/gpu/nvgpu/gk20a/sim_gk20a.c b/drivers/gpu/nvgpu/gk20a/sim_gk20a.c index 34ca5add..ab064710 100644 --- a/drivers/gpu/nvgpu/gk20a/sim_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/sim_gk20a.c @@ -28,7 +28,6 @@ #include #include "gk20a.h" -#include "platform_gk20a.h" #include @@ -104,11 +103,9 @@ static int alloc_and_kmap_iopage(struct gk20a *g, } -int gk20a_init_sim_support(struct platform_device *pdev) +int gk20a_init_sim_support(struct gk20a *g) { int err = 0; - struct device *dev = &pdev->dev; - struct gk20a *g = get_gk20a(dev); u64 phys; /* allocate sim event/msg buffers */ diff --git a/drivers/gpu/nvgpu/gk20a/sim_gk20a.h b/drivers/gpu/nvgpu/gk20a/sim_gk20a.h index 17e508de..44378e7a 100644 --- a/drivers/gpu/nvgpu/gk20a/sim_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/sim_gk20a.h @@ -45,7 +45,7 @@ struct sim_gk20a { void (*remove_support)(struct sim_gk20a *); }; -int gk20a_init_sim_support(struct platform_device *pdev); +int gk20a_init_sim_support(struct gk20a *g); int gk20a_sim_esc_readl(struct gk20a *g, char *path, u32 index, u32 *data); #endif /*__SIM_GK20A_H__*/ diff --git a/drivers/gpu/nvgpu/gm20b/clk_gm20b.h b/drivers/gpu/nvgpu/gm20b/clk_gm20b.h index daa0bb0b..e814ac70 100644 --- a/drivers/gpu/nvgpu/gm20b/clk_gm20b.h +++ b/drivers/gpu/nvgpu/gm20b/clk_gm20b.h @@ -26,6 +26,9 @@ #include +struct gk20a; +struct clk_gk20a; + struct nvgpu_clk_pll_debug_data { u32 trim_sys_sel_vco_reg; u32 trim_sys_sel_vco_val; diff --git a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c index afc92d66..6913c280 100644 --- a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c +++ b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c @@ -25,9 +25,9 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gp106/bios_gp106.h" #include "common/linux/os_linux.h" +#include "common/linux/platform_gk20a.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" diff --git a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c index 37fff2d4..5eade2e0 100644 --- a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c +++ b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c @@ -24,12 +24,12 @@ #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" #include "pwrpolicy.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" #include "gp106/bios_gp106.h" #include "common/linux/os_linux.h" +#include "common/linux/platform_gk20a.h" #define _pwr_policy_limitarboutputget_helper(p_limit_arb) (p_limit_arb)->output #define _pwr_policy_limitdeltaapply(limit, delta) ((u32)max(((s32)limit) + (delta), 0)) diff --git a/drivers/gpu/nvgpu/vgpu/css_vgpu.c b/drivers/gpu/nvgpu/vgpu/css_vgpu.c index 266ce871..f45ccc60 100644 --- a/drivers/gpu/nvgpu/vgpu/css_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/css_vgpu.c @@ -26,8 +26,8 @@ #include "gk20a/gk20a.h" #include "gk20a/channel_gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gk20a/css_gr_gk20a.h" +#include "common/linux/platform_gk20a.h" #include "vgpu.h" #include "css_vgpu.h" diff --git a/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c b/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c index 94d7140e..683317dc 100644 --- a/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c @@ -24,8 +24,8 @@ #include "gk20a/gk20a.h" #include "gk20a/channel_gk20a.h" -#include "gk20a/platform_gk20a.h" #include "gk20a/tsg_gk20a.h" +#include "common/linux/platform_gk20a.h" #include "vgpu.h" #include "fifo_vgpu.h" diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.h b/drivers/gpu/nvgpu/vgpu/vgpu.h index d5c49c0f..6ce61e92 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.h +++ b/drivers/gpu/nvgpu/vgpu/vgpu.h @@ -28,7 +28,7 @@ #include #include #include "gk20a/gk20a.h" -#include "gk20a/platform_gk20a.h" +#include "common/linux/platform_gk20a.h" #include "common/linux/os_linux.h" #include -- cgit v1.2.2