gpu: nvgpu: Use device instead of platform_device

Use struct device instead of struct platform_device wherever
possible. This allows adding other bus types later.

Change-Id: I90623c020919ca8e2e5b31d53914c324d2dc6af9
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1120464
This commit is contained in:
Terje Bergstrom
2016-03-30 14:03:35 -07:00
committed by Deepak Nibade
parent bd688d31ce
commit fce01666d5
5 changed files with 61 additions and 70 deletions

View File

@@ -1,7 +1,7 @@
/*
* GP10B CDE
*
* Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -46,7 +46,7 @@ static void gp10b_cde_get_program_numbers(struct gk20a *g,
}
if (g->mm.bypass_smmu) {
if (!g->mm.disable_bigpage) {
gk20a_warn(&g->dev->dev,
gk20a_warn(g->dev,
"when bypass_smmu is 1, disable_bigpage must be 1 too");
}
hprog |= 1;

View File

@@ -20,11 +20,10 @@
#define ROOTRW (S_IRWXU|S_IRGRP|S_IROTH)
static ssize_t ecc_enable_store(struct device *device,
static ssize_t ecc_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct platform_device *ndev = to_platform_device(device);
struct gk20a *g = get_gk20a(ndev);
struct gk20a *g = get_gk20a(dev);
u32 ecc_mask;
u32 err = 0;
@@ -33,17 +32,16 @@ static ssize_t ecc_enable_store(struct device *device,
err = g->ops.pmu.send_lrf_tex_ltc_dram_overide_en_dis_cmd
(g, ecc_mask);
if (err)
dev_err(device, "ECC override did not happen\n");
dev_err(dev, "ECC override did not happen\n");
} else
return -EINVAL;
return count;
}
static ssize_t ecc_enable_read(struct device *device,
static ssize_t ecc_enable_read(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct platform_device *ndev = to_platform_device(device);
struct gk20a *g = get_gk20a(ndev);
struct gk20a *g = get_gk20a(dev);
return sprintf(buf, "ecc override =0x%x\n",
g->ops.gr.get_lrf_tex_ltc_dram_override(g));
@@ -51,13 +49,13 @@ static ssize_t ecc_enable_read(struct device *device,
static DEVICE_ATTR(ecc_enable, ROOTRW, ecc_enable_read, ecc_enable_store);
void gp10b_create_sysfs(struct platform_device *dev)
void gp10b_create_sysfs(struct device *dev)
{
int error = 0;
error |= device_create_file(&dev->dev, &dev_attr_ecc_enable);
error |= device_create_file(dev, &dev_attr_ecc_enable);
if (error)
dev_err(&dev->dev, "Failed to create sysfs attributes!\n");
dev_err(dev, "Failed to create sysfs attributes!\n");
}
void gp10b_remove_sysfs(struct device *dev)

View File

@@ -19,7 +19,7 @@
/*ECC Fuse*/
#define FUSE_OPT_ECC_EN 0x358
void gp10b_create_sysfs(struct platform_device *dev);
void gp10b_create_sysfs(struct device *dev);
void gp10b_remove_sysfs(struct device *dev);
#endif /*_GP10B_SYSFS_H_*/

View File

@@ -1,7 +1,7 @@
/*
* GM20B GPU GR
* GP10B GPU GR
*
* Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -35,7 +35,7 @@ enum {
void gp10b_init_gr(struct gpu_ops *ops);
int gr_gp10b_alloc_buffer(struct vm_gk20a *vm, size_t size,
struct mem_desc *mem);
void gr_gp10b_create_sysfs(struct platform_device *dev);
void gr_gp10b_create_sysfs(struct device *dev);
struct ecc_stat {
char **names;

View File

@@ -1,7 +1,5 @@
/*
* drivers/video/tegra/host/gk20a/platform_gk20a_tegra.c
*
* GK20A Tegra Platform Interface
* GP10B Tegra Platform Interface
*
* Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
*
@@ -62,11 +60,9 @@ static void gr_gp10b_remove_sysfs(struct device *dev);
* the clock information to gp10b platform data.
*/
static int gp10b_tegra_get_clocks(struct platform_device *pdev)
static int gp10b_tegra_get_clocks(struct device *dev)
{
struct gk20a_platform *platform = platform_get_drvdata(pdev);
struct gk20a *g = get_gk20a(pdev);
struct device *dev = dev_from_gk20a(g);
struct gk20a_platform *platform = dev_get_drvdata(dev);
int i;
if (tegra_platform_is_linsim())
@@ -79,7 +75,7 @@ static int gp10b_tegra_get_clocks(struct platform_device *pdev)
c = clk_get(dev, tegra_gp10b_clocks[i].name);
if (IS_ERR(c)) {
gk20a_err(&pdev->dev, "cannot get clock %s",
gk20a_err(dev, "cannot get clock %s",
tegra_gp10b_clocks[i].name);
} else {
clk_set_rate(c, rate);
@@ -91,9 +87,9 @@ static int gp10b_tegra_get_clocks(struct platform_device *pdev)
return 0;
}
static void gp10b_tegra_scale_init(struct platform_device *pdev)
static void gp10b_tegra_scale_init(struct device *dev)
{
struct gk20a_platform *platform = gk20a_get_platform(pdev);
struct gk20a_platform *platform = gk20a_get_platform(dev);
struct gk20a_scale_profile *profile = platform->g->scale_profile;
struct tegra_bwmgr_client *bwmgr_handle;
@@ -104,9 +100,9 @@ static void gp10b_tegra_scale_init(struct platform_device *pdev)
profile->private_data = (void *)bwmgr_handle;
}
static void gp10b_tegra_scale_exit(struct platform_device *pdev)
static void gp10b_tegra_scale_exit(struct device *dev)
{
struct gk20a_platform *platform = gk20a_get_platform(pdev);
struct gk20a_platform *platform = gk20a_get_platform(dev);
struct gk20a_scale_profile *profile = platform->g->scale_profile;
if (profile)
@@ -114,30 +110,29 @@ static void gp10b_tegra_scale_exit(struct platform_device *pdev)
(struct tegra_bwmgr_client *)profile->private_data);
}
static int gp10b_tegra_probe(struct platform_device *pdev)
static int gp10b_tegra_probe(struct device *dev)
{
struct gk20a_platform *platform = gk20a_get_platform(pdev);
struct device_node *np = pdev->dev.of_node;
struct gk20a_platform *platform = dev_get_drvdata(dev);
struct device_node *np = dev->of_node;
struct device_node *host1x_node;
struct platform_device *host1x_pdev;
const __be32 *host1x_ptr;
host1x_ptr = of_get_property(np, "nvidia,host1x", NULL);
if (!host1x_ptr) {
gk20a_err(&pdev->dev, "host1x device not available");
gk20a_err(dev, "host1x device not available");
return -ENOSYS;
}
host1x_node = of_find_node_by_phandle(be32_to_cpup(host1x_ptr));
host1x_pdev = of_find_device_by_node(host1x_node);
if (!host1x_pdev) {
gk20a_err(&pdev->dev, "host1x device not available");
gk20a_err(dev, "host1x device not available");
return -ENOSYS;
}
platform->g->host1x_dev = host1x_pdev;
platform->bypass_smmu = !device_is_iommuable(&pdev->dev);
platform->bypass_smmu = !device_is_iommuable(dev);
platform->disable_bigpage = platform->bypass_smmu;
platform->g->gr.t18x.ctx_vars.dump_ctxsw_stats_on_channel_close
@@ -165,39 +160,39 @@ static int gp10b_tegra_probe(struct platform_device *pdev)
&platform->g->gr.t18x.
ctx_vars.dump_ctxsw_stats_on_channel_close);
gp10b_tegra_get_clocks(pdev);
gp10b_tegra_get_clocks(dev);
return 0;
}
static int gp10b_tegra_late_probe(struct platform_device *pdev)
static int gp10b_tegra_late_probe(struct device *dev)
{
/* Make gk20a power domain a subdomain of host1x */
nvhost_register_client_domain(dev_to_genpd(&pdev->dev));
nvhost_register_client_domain(dev_to_genpd(dev));
/*Create GP10B specific sysfs*/
gp10b_create_sysfs(pdev);
gp10b_create_sysfs(dev);
/* Initialise tegra specific scaling quirks */
gp10b_tegra_scale_init(pdev);
gp10b_tegra_scale_init(dev);
return 0;
}
static int gp10b_tegra_remove(struct platform_device *pdev)
static int gp10b_tegra_remove(struct device *dev)
{
/* remove gk20a power subdomain from host1x */
nvhost_unregister_client_domain(dev_to_genpd(&pdev->dev));
gr_gp10b_remove_sysfs(&pdev->dev);
nvhost_unregister_client_domain(dev_to_genpd(dev));
gr_gp10b_remove_sysfs(dev);
/*Remove GP10B specific sysfs*/
gp10b_remove_sysfs(&pdev->dev);
gp10b_remove_sysfs(dev);
/* deinitialise tegra specific scaling quirks */
gp10b_tegra_scale_exit(pdev);
gp10b_tegra_scale_exit(dev);
return 0;
}
static bool gp10b_tegra_is_railgated(struct platform_device *pdev)
static bool gp10b_tegra_is_railgated(struct device *dev)
{
bool ret = false;
@@ -207,9 +202,9 @@ static bool gp10b_tegra_is_railgated(struct platform_device *pdev)
return ret;
}
static int gp10b_tegra_railgate(struct platform_device *pdev)
static int gp10b_tegra_railgate(struct device *dev)
{
struct gk20a_platform *platform = gk20a_get_platform(pdev);
struct gk20a_platform *platform = gk20a_get_platform(dev);
if (tegra_bpmp_running() &&
tegra_powergate_is_powered(TEGRA_POWERGATE_GPU)) {
@@ -223,10 +218,10 @@ static int gp10b_tegra_railgate(struct platform_device *pdev)
return 0;
}
static int gp10b_tegra_unrailgate(struct platform_device *pdev)
static int gp10b_tegra_unrailgate(struct device *dev)
{
int ret = 0;
struct gk20a_platform *platform = gk20a_get_platform(pdev);
struct gk20a_platform *platform = gk20a_get_platform(dev);
if (tegra_bpmp_running()) {
int i;
@@ -244,7 +239,7 @@ static int gp10b_tegra_suspend(struct device *dev)
return 0;
}
static int gp10b_tegra_reset_assert(struct platform_device *dev)
static int gp10b_tegra_reset_assert(struct device *dev)
{
struct gk20a_platform *platform = gk20a_get_platform(dev);
int ret = 0;
@@ -257,7 +252,7 @@ static int gp10b_tegra_reset_assert(struct platform_device *dev)
return ret;
}
static int gp10b_tegra_reset_deassert(struct platform_device *dev)
static int gp10b_tegra_reset_deassert(struct device *dev)
{
struct gk20a_platform *platform = gk20a_get_platform(dev);
int ret = 0;
@@ -270,9 +265,9 @@ static int gp10b_tegra_reset_deassert(struct platform_device *dev)
return ret;
}
static void gp10b_tegra_prescale(struct platform_device *pdev)
static void gp10b_tegra_prescale(struct device *dev)
{
struct gk20a *g = get_gk20a(pdev);
struct gk20a *g = get_gk20a(dev);
u32 avg = 0;
gk20a_dbg_fn("");
@@ -282,7 +277,7 @@ static void gp10b_tegra_prescale(struct platform_device *pdev)
gk20a_dbg_fn("done");
}
static void gp10b_tegra_postscale(struct platform_device *pdev,
static void gp10b_tegra_postscale(struct device *pdev,
unsigned long freq)
{
struct gk20a_platform *platform = gk20a_get_platform(pdev);
@@ -304,7 +299,7 @@ static void gp10b_tegra_postscale(struct platform_device *pdev,
gk20a_dbg_fn("done");
}
static unsigned long gp10b_get_clk_rate(struct platform_device *dev)
static unsigned long gp10b_get_clk_rate(struct device *dev)
{
struct gk20a_platform *platform = gk20a_get_platform(dev);
@@ -312,25 +307,24 @@ static unsigned long gp10b_get_clk_rate(struct platform_device *dev)
}
static long gp10b_round_clk_rate(struct platform_device *dev,
unsigned long rate)
static long gp10b_round_clk_rate(struct device *dev, unsigned long rate)
{
struct gk20a_platform *platform = gk20a_get_platform(dev);
return clk_round_rate(platform->clk[0], rate);
}
static int gp10b_set_clk_rate(struct platform_device *dev, unsigned long rate)
static int gp10b_set_clk_rate(struct device *dev, unsigned long rate)
{
struct gk20a_platform *platform = gk20a_get_platform(dev);
return clk_set_rate(platform->clk[0], rate);
}
static int gp10b_clk_get_freqs(struct platform_device *pdev,
static int gp10b_clk_get_freqs(struct device *dev,
unsigned long **freqs, int *num_freqs)
{
struct gk20a_platform *platform = gk20a_get_platform(pdev);
struct gk20a_platform *platform = gk20a_get_platform(dev);
unsigned long min_rate, max_rate, freq_step, rate;
int i;
@@ -408,6 +402,8 @@ struct gk20a_platform t18x_gpu_tegra_platform = {
.reset_deassert = gp10b_tegra_reset_deassert,
.force_reset_in_do_idle = false,
.soc_name = "tegra18x",
};
@@ -481,7 +477,7 @@ static ssize_t ecc_stat_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "Error: No ECC stat found!\n");
}
static int ecc_stat_create(struct platform_device *dev,
static int ecc_stat_create(struct device *dev,
int is_l2,
char *ecc_stat_name,
struct ecc_stat *ecc_stat,
@@ -526,8 +522,7 @@ static int ecc_stat_create(struct platform_device *dev,
dev_attr_array[hw_unit].store = NULL;
/* Create sysfs file */
error |= device_create_file(&dev->dev,
&dev_attr_array[hw_unit]);
error |= device_create_file(dev, &dev_attr_array[hw_unit]);
}
/* Add hash table entry */
@@ -544,8 +539,7 @@ static void ecc_stat_remove(struct device *dev,
struct ecc_stat *ecc_stat,
struct device_attribute *dev_attr_array)
{
struct platform_device *ndev = to_platform_device(dev);
struct gk20a *g = get_gk20a(ndev);
struct gk20a *g = get_gk20a(dev);
int num_hw_units = 0;
int hw_unit = 0;
@@ -571,7 +565,7 @@ static void ecc_stat_remove(struct device *dev,
kfree(dev_attr_array);
}
void gr_gp10b_create_sysfs(struct platform_device *dev)
void gr_gp10b_create_sysfs(struct device *dev)
{
int error = 0;
struct gk20a *g = get_gk20a(dev);
@@ -663,13 +657,12 @@ void gr_gp10b_create_sysfs(struct platform_device *dev)
dev_attr_l2_ecc_ded_count_array);
if (error)
dev_err(&dev->dev, "Failed to create sysfs attributes!\n");
dev_err(dev, "Failed to create sysfs attributes!\n");
}
static void gr_gp10b_remove_sysfs(struct device *dev)
{
struct platform_device *ndev = to_platform_device(dev);
struct gk20a *g = get_gk20a(ndev);
struct gk20a *g = get_gk20a(dev);
ecc_stat_remove(dev,
0,