summaryrefslogtreecommitdiff
path: root/drivers/video/tegra/host/dev.c
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2011-12-29 16:03:51 +0200
committerRohan Somvanshi <rsomvanshi@nvidia.com>2012-01-12 09:56:22 -0800
commit10c8828c7b2bf26ab6ec9feee860fc5cc8eb2ce7 (patch)
tree6e1c0b97ddd63f64eee95c313f46fb49940edc25 /drivers/video/tegra/host/dev.c
parent6bc2684e40093d8859b90d96c0d9957e1472c5c9 (diff)
video: tegra: host: Move device data to nvhost_device
Move all device data from nvhost_channeldesc, nvhost_moduledesc and nvhost_module to nvhost_device. nvhost_devices are also assigned into a hierarchy to prepare for implementation of runtime power management. Change-Id: I1e18daae8fe538086cd1f453d316e0f73e9d7d92 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/72844 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com> Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com> Reviewed-on: http://git-master/r/74560 Reviewed-by: Varun Wadekar <vwadekar@nvidia.com> Tested-by: Varun Wadekar <vwadekar@nvidia.com>
Diffstat (limited to 'drivers/video/tegra/host/dev.c')
-rw-r--r--drivers/video/tegra/host/dev.c126
1 files changed, 58 insertions, 68 deletions
diff --git a/drivers/video/tegra/host/dev.c b/drivers/video/tegra/host/dev.c
index bdbb21fe9e7c..6ea8cbabff13 100644
--- a/drivers/video/tegra/host/dev.c
+++ b/drivers/video/tegra/host/dev.c
@@ -99,7 +99,7 @@ static void trace_write_cmdbufs(struct nvhost_job *job)
*/
for (i = 0; i < gather->words; i += TRACE_MAX_LENGTH) {
trace_nvhost_channel_write_cmdbuf_data(
- job->ch->desc->name,
+ job->ch->dev->name,
gather->mem_id,
min(gather->words - i,
TRACE_MAX_LENGTH),
@@ -116,11 +116,11 @@ static int nvhost_channelrelease(struct inode *inode, struct file *filp)
{
struct nvhost_channel_userctx *priv = filp->private_data;
- trace_nvhost_channel_release(priv->ch->desc->name);
+ trace_nvhost_channel_release(priv->ch->dev->name);
filp->private_data = NULL;
- nvhost_module_remove_client(priv->ch->dev, &priv->ch->mod, priv);
+ nvhost_module_remove_client(priv->ch->dev, priv);
nvhost_putchannel(priv->ch, priv->hwctx);
if (priv->hwctx)
@@ -143,7 +143,7 @@ static int nvhost_channelopen(struct inode *inode, struct file *filp)
ch = nvhost_getchannel(ch);
if (!ch)
return -ENOMEM;
- trace_nvhost_channel_open(ch->desc->name);
+ trace_nvhost_channel_open(ch->dev->name);
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
@@ -152,7 +152,7 @@ static int nvhost_channelopen(struct inode *inode, struct file *filp)
}
filp->private_data = priv;
priv->ch = ch;
- nvhost_module_add_client(ch->dev, &ch->mod, priv);
+ nvhost_module_add_client(ch->dev, priv);
if (ch->ctxhandler.alloc) {
priv->hwctx = ch->ctxhandler.alloc(ch);
@@ -160,7 +160,7 @@ static int nvhost_channelopen(struct inode *inode, struct file *filp)
goto fail;
}
priv->priority = NVHOST_PRIORITY_MEDIUM;
- priv->clientid = atomic_add_return(1, &ch->dev->clientid);
+ priv->clientid = atomic_add_return(1, &ch->dev->host->clientid);
priv->job = nvhost_job_alloc(ch, priv->hwctx, &priv->hdr,
NULL, priv->priority, priv->clientid);
@@ -175,7 +175,7 @@ fail:
static int set_submit(struct nvhost_channel_userctx *ctx)
{
- struct device *device = &ctx->ch->dev->pdev->dev;
+ struct device *device = &ctx->ch->dev->dev;
/* submit should have at least 1 cmdbuf */
if (!ctx->hdr.num_cmdbufs)
@@ -217,7 +217,7 @@ static ssize_t nvhost_channelwrite(struct file *filp, const char __user *buf,
int err = 0;
struct nvhost_job *job = priv->job;
struct nvhost_submit_hdr_ext *hdr = &priv->hdr;
- const char *chname = priv->ch->desc->name;
+ const char *chname = priv->ch->dev->name;
while (remaining) {
size_t consumed;
@@ -308,7 +308,7 @@ static ssize_t nvhost_channelwrite(struct file *filp, const char __user *buf,
}
if (err < 0) {
- dev_err(&priv->ch->dev->pdev->dev, "channel write error\n");
+ dev_err(&priv->ch->dev->dev, "channel write error\n");
reset_submit(priv);
return err;
}
@@ -321,10 +321,10 @@ static int nvhost_ioctl_channel_flush(
struct nvhost_get_param_args *args,
int null_kickoff)
{
- struct device *device = &ctx->ch->dev->pdev->dev;
+ struct device *device = &ctx->ch->dev->dev;
int err;
- trace_nvhost_ioctl_channel_flush(ctx->ch->desc->name);
+ trace_nvhost_ioctl_channel_flush(ctx->ch->dev->name);
if (!ctx->job ||
ctx->hdr.num_relocs ||
@@ -405,7 +405,7 @@ static long nvhost_channelctl(struct file *filp,
priv->hdr.num_cmdbufs ||
priv->hdr.num_waitchks) {
reset_submit(priv);
- dev_err(&priv->ch->dev->pdev->dev,
+ dev_err(&priv->ch->dev->dev,
"channel submit out of sync\n");
err = -EIO;
break;
@@ -413,7 +413,7 @@ static long nvhost_channelctl(struct file *filp,
hdr = (struct nvhost_submit_hdr_ext *)buf;
if (hdr->submit_version > NVHOST_SUBMIT_VERSION_MAX_SUPPORTED) {
- dev_err(&priv->ch->dev->pdev->dev,
+ dev_err(&priv->ch->dev->dev,
"submit version %d > max supported %d\n",
hdr->submit_version,
NVHOST_SUBMIT_VERSION_MAX_SUPPORTED);
@@ -422,7 +422,7 @@ static long nvhost_channelctl(struct file *filp,
}
memcpy(&priv->hdr, hdr, sizeof(struct nvhost_submit_hdr_ext));
err = set_submit(priv);
- trace_nvhost_ioctl_channel_submit(priv->ch->desc->name,
+ trace_nvhost_ioctl_channel_submit(priv->ch->dev->name,
priv->hdr.submit_version,
priv->hdr.num_cmdbufs, priv->hdr.num_relocs,
priv->hdr.num_waitchks,
@@ -431,17 +431,17 @@ static long nvhost_channelctl(struct file *filp,
}
case NVHOST_IOCTL_CHANNEL_GET_SYNCPOINTS:
/* host syncpt ID is used by the RM (and never be given out) */
- BUG_ON(priv->ch->desc->syncpts & (1 << NVSYNCPT_GRAPHICS_HOST));
+ BUG_ON(priv->ch->dev->syncpts & (1 << NVSYNCPT_GRAPHICS_HOST));
((struct nvhost_get_param_args *)buf)->value =
- priv->ch->desc->syncpts;
+ priv->ch->dev->syncpts;
break;
case NVHOST_IOCTL_CHANNEL_GET_WAITBASES:
((struct nvhost_get_param_args *)buf)->value =
- priv->ch->desc->waitbases;
+ priv->ch->dev->waitbases;
break;
case NVHOST_IOCTL_CHANNEL_GET_MODMUTEXES:
((struct nvhost_get_param_args *)buf)->value =
- priv->ch->desc->modulemutexes;
+ priv->ch->dev->modulemutexes;
break;
case NVHOST_IOCTL_CHANNEL_SET_NVMAP_FD:
{
@@ -468,8 +468,7 @@ static long nvhost_channelctl(struct file *filp,
struct nvhost_clk_rate_args *arg =
(struct nvhost_clk_rate_args *)buf;
- err = nvhost_module_get_rate(priv->ch->dev,
- &priv->ch->mod, &rate, 0);
+ err = nvhost_module_get_rate(priv->ch->dev, &rate, 0);
if (err == 0)
arg->rate = rate;
break;
@@ -480,14 +479,13 @@ static long nvhost_channelctl(struct file *filp,
(struct nvhost_clk_rate_args *)buf;
unsigned long rate = (unsigned long)arg->rate;
- err = nvhost_module_set_rate(priv->ch->dev,
- &priv->ch->mod, priv, rate, 0);
+ err = nvhost_module_set_rate(priv->ch->dev, priv, rate, 0);
break;
}
case NVHOST_IOCTL_CHANNEL_SET_TIMEOUT:
priv->timeout =
(u32)((struct nvhost_set_timeout_args *)buf)->timeout;
- dev_dbg(&priv->ch->dev->pdev->dev,
+ dev_dbg(&priv->ch->dev->dev,
"%s: setting buffer timeout (%d ms) for userctx 0x%p\n",
__func__, priv->timeout, priv);
break;
@@ -523,11 +521,11 @@ static int nvhost_ctrlrelease(struct inode *inode, struct file *filp)
struct nvhost_ctrl_userctx *priv = filp->private_data;
int i;
- trace_nvhost_ctrlrelease(priv->dev->mod.name);
+ trace_nvhost_ctrlrelease(priv->dev->dev->name);
filp->private_data = NULL;
if (priv->mod_locks[0])
- nvhost_module_idle(&priv->dev->mod);
+ nvhost_module_idle(priv->dev->dev);
for (i = 1; i < priv->dev->nb_mlocks; i++)
if (priv->mod_locks[i])
nvhost_mutex_unlock(&priv->dev->cpuaccess, i);
@@ -542,7 +540,7 @@ static int nvhost_ctrlopen(struct inode *inode, struct file *filp)
struct nvhost_ctrl_userctx *priv;
u32 *mod_locks;
- trace_nvhost_ctrlopen(host->mod.name);
+ trace_nvhost_ctrlopen(host->dev->name);
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
mod_locks = kzalloc(sizeof(u32)*host->nb_mlocks, GFP_KERNEL);
@@ -611,14 +609,14 @@ static int nvhost_ioctl_ctrl_module_mutex(
trace_nvhost_ioctl_ctrl_module_mutex(args->lock, args->id);
if (args->lock && !ctx->mod_locks[args->id]) {
if (args->id == 0)
- nvhost_module_busy(&ctx->dev->mod);
+ nvhost_module_busy(ctx->dev->dev);
else
err = nvhost_mutex_try_lock(&ctx->dev->cpuaccess, args->id);
if (!err)
ctx->mod_locks[args->id] = 1;
} else if (!args->lock && ctx->mod_locks[args->id]) {
if (args->id == 0)
- nvhost_module_idle(&ctx->dev->mod);
+ nvhost_module_idle(ctx->dev->dev);
else
nvhost_mutex_unlock(&ctx->dev->cpuaccess, args->id);
ctx->mod_locks[args->id] = 0;
@@ -736,22 +734,18 @@ static const struct file_operations nvhost_ctrlops = {
.unlocked_ioctl = nvhost_ctrlctl
};
-static void power_on_host(struct nvhost_module *mod)
+static void power_on_host(struct nvhost_device *dev)
{
- struct nvhost_master *dev =
- container_of(mod, struct nvhost_master, mod);
-
- nvhost_intr_start(&dev->intr, clk_get_rate(mod->clk[0]));
- nvhost_syncpt_reset(&dev->syncpt);
+ struct nvhost_master *host = dev->host;
+ nvhost_intr_start(&host->intr, clk_get_rate(dev->clk[0]));
+ nvhost_syncpt_reset(&host->syncpt);
}
-static int power_off_host(struct nvhost_module *mod)
+static int power_off_host(struct nvhost_device *dev)
{
- struct nvhost_master *dev =
- container_of(mod, struct nvhost_master, mod);
-
- nvhost_syncpt_save(&dev->syncpt);
- nvhost_intr_stop(&dev->intr);
+ struct nvhost_master *host = dev->host;
+ nvhost_syncpt_save(&host->syncpt);
+ nvhost_intr_stop(&host->intr);
return 0;
}
@@ -766,15 +760,9 @@ static int __devinit nvhost_user_init(struct nvhost_master *host)
goto fail;
}
- if (nvhost_major) {
- devno = MKDEV(nvhost_major, nvhost_minor);
- err = register_chrdev_region(devno, host->nb_channels + 1,
- IFACE_NAME);
- } else {
- err = alloc_chrdev_region(&devno, nvhost_minor,
- host->nb_channels + 1, IFACE_NAME);
- nvhost_major = MAJOR(devno);
- }
+ err = alloc_chrdev_region(&devno, nvhost_minor,
+ host->nb_channels + 1, IFACE_NAME);
+ nvhost_major = MAJOR(devno);
if (err < 0) {
dev_err(&host->pdev->dev, "failed to reserve chrdev region\n");
goto fail;
@@ -793,7 +781,7 @@ static int __devinit nvhost_user_init(struct nvhost_master *host)
goto fail;
}
ch->node = device_create(host->nvhost_class, NULL, devno, NULL,
- IFACE_NAME "-%s", ch->desc->name);
+ IFACE_NAME "-%s", ch->dev->name);
if (IS_ERR(ch->node)) {
err = PTR_ERR(ch->node);
dev_err(&host->pdev->dev, "failed to create chan %i device\n", i);
@@ -902,11 +890,12 @@ static int __devinit nvhost_init_chip_support(struct nvhost_master *host)
return 0;
}
-const struct nvhost_moduledesc hostdesc = {
- .finalize_poweron = power_on_host,
- .prepare_poweroff = power_off_host,
- .clocks = {{"host1x", UINT_MAX}, {} },
- NVHOST_MODULE_NO_POWERGATE_IDS,
+struct nvhost_device hostdev = {
+ .name = "host1x",
+ .finalize_poweron = power_on_host,
+ .prepare_poweroff = power_off_host,
+ .clocks = {{"host1x", UINT_MAX}, {} },
+ NVHOST_MODULE_NO_POWERGATE_IDS,
};
static int __devinit nvhost_probe(struct platform_device *pdev)
@@ -957,6 +946,11 @@ static int __devinit nvhost_probe(struct platform_device *pdev)
goto fail;
}
+ /* Register host1x device as bus master */
+ nvhost_device_register(&hostdev);
+ host->dev = &hostdev;
+ nvhost_bus_add_host(host);
+
for (i = 0; i < host->nb_channels; i++) {
struct nvhost_channel *ch = &host->channels[i];
BUG_ON(!host_channel_op(host).init);
@@ -965,6 +959,7 @@ static int __devinit nvhost_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to init channel %d\n", i);
goto fail;
}
+ ch->dev->channel = ch;
}
err = nvhost_cpuaccess_init(&host->cpuaccess, pdev);
@@ -979,25 +974,20 @@ static int __devinit nvhost_probe(struct platform_device *pdev)
if (err)
goto fail;
- err = nvhost_module_init(&host->mod, "host1x",
- &hostdesc, NULL, &pdev->dev);
- for (i = 0; i < host->nb_channels; i++) {
- struct nvhost_channel *ch = &host->channels[i];
- nvhost_module_preinit(ch->desc->name,
- &ch->desc->module);
- }
-
+ err = nvhost_module_init(&hostdev);
if (err)
goto fail;
+ for (i = 0; i < host->nb_channels; i++) {
+ struct nvhost_channel *ch = &host->channels[i];
+ nvhost_module_preinit(ch->dev);
+ }
platform_set_drvdata(pdev, host);
- clk_enable(host->mod.clk[0]);
+ clk_enable(host->dev->clk[0]);
nvhost_syncpt_reset(&host->syncpt);
- clk_disable(host->mod.clk[0]);
-
- nvhost_bus_register(host);
+ clk_disable(host->dev->clk[0]);
nvhost_debug_init(host);
@@ -1031,7 +1021,7 @@ static int nvhost_suspend(struct platform_device *pdev, pm_message_t state)
return ret;
}
- ret = nvhost_module_suspend(&host->mod, true);
+ ret = nvhost_module_suspend(host->dev, true);
dev_info(&pdev->dev, "suspend status: %d\n", ret);
return ret;
}