video: tegra: host: use platform bus/driver/device
Mayuresh Kulkarni [Fri, 26 Oct 2012 13:17:24 +0000 (18:17 +0530)]
- this commit replaces the custom nvhost bus/driver/device
with platform bus/driver/device
- this is in preparation to add DT support
- following is the list of notable changes done:

1. chip_ops: The per SoC differences is encapsulated by chip_ops structure.
With nvhost_bus:
- It is hidden in nvhost_bus and exposed APIs to rest of the code.
These APIs land up in correct implementation for current SoC.
With platform_bus:
- I had to make this global and adjust the API accordingly.

2. nvhost_device
With nvhost_bus:
- The struct nvhost_device encapsulates both Linux device driver parts
as well as tegra specific parts.
With platform_bus:
- I had to move the current nvhost_device as a platform_data
for each platform_device. For this I renamed the struct nvhost_device
to struct nvhost_device_data.
- Also, since nvhost_driver is gone, I had to move all the
function pointers in it to struct nvhost_device_data.

3. Device specific private data: Host1x master device has its own
static data (called nvhost_master) which stores the per SoC
sync-point, IRQ info etc.
With nvhost_bus:
- This was stored as device specific platform_data.
With platform_bus:
- The device specific platform_data is now struct nvhost_device_data
(as mentioned above).
- I need to keep it common for all the devices whose code is
part of host1x directory, so that other parts of code that need per-device
info have a unique interface of platform_get_drvdata.
- As a result, I had to add a void * field in struct nvhost_device_data
which now holds per-device specific data and expose APIs to get/set this data.
- As of now, only host1x master parent device code uses this.

4. Per SoC device names:
With nvhost_bus:
- Per SoC device name is SAME for all the SoCs.
- The correct driver get linked to this device via the concept of id_table.
This id_table allows us to connect multiple devices to single driver code
and pass appropriate function pointer specific to SoC (you can check gr3d.c for details).
With platform_bus:
- The id_table usage of platform_bus is different from above.
- To adhere to its need, I had to append the per-SoC device name
with a version field (so gr3d for t20 became gr3d01, for t30 became gr3d02 etc).
- I adjusted the correct names in _probe of such devices.
Also, I adjusted the node names exposed to user space (/dev/host-gr3d etc)
to be consistent across SoCs.
- But this fails for the sysfs entries created by device registration code
of Linux, since during this time the _probe is not called.
So, device name is still appended with version field.

5. Per SoC device registration function: tegraXXX_register_host1x_devices
is the per SoC specific APIs which is called by board-file to register
the host1x and client devices. Host1x has strict requirements for the
parent->child relations i.e. any client of host1x device should have the
parent set properly BEFORE device registration.
With nvhost_bus:
- Setting of parent was taken care by nvhost_device_register call and other helpers.
With platform_bus:
- It is not possible to change parent till _probe of client device returns
(meaning not much of control in our hand). The device driver core,
takes a mutex lock of parent BEFORE calling _probe to avoid changing parent during _probe.
- So, to set correct parent, I changed the return type of
tegraXXX_register_host1x_devices to return pointer to master host1x parent device.

6. platform_get_drvdata calls:
With nvhost_bus:
- Only host1x master parent calls this.
With platform_bus:
- Almost all the common code ends up calling this.
Fortunately, we had designed the APIs such that they take nvhost_device * as argument.
So changing them to platform_device * is in a way easy.

7. Device list: The debug-fs dump code & module-reg-read-write
functionality rely on having a list of host1x devices registered currently.
With nvhost_bus:
- This is readily available since struct bus_type of Linux holds this list.
Moreover, it provides an iterators to access this list.
With platform_bus:
- Since it holds large number of devices in system, it is inefficient
to use the above iterators. Also, it is difficult to have a common matching
criteria for all the devices who have different platform_data.
- As a result, I had to add a simple list using Linux kernel's list implementation.
It holds the list of devices which have their code within host1x directory
and actually use channels (remember tegra-dc and nvavp are outside
host1x code && do not use physical channels they only need sync-point
and host1x hardware alive when they are alive).
I also had to provide 2 iterators one which is used for
module-reg-read-write and other for debug-fs dump.

8. I changed how tegra-dc and nvavp called the host1x externally exposed APIs
(such APIs end with _ext). In current code, they know little too much of
host1x code internals. I now changed to make them independent of host1x internal
implementation and structure know-how. They now simply send their own
platform_device * to the external visible APIs and these APIs
ensures that the call ends up in correct function call.

bug 1041377

Change-Id: I9cd4d506e6f3bde805923ce7c7bbbd37c9ec13c4
Signed-off-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Reviewed-on: http://git-master/r/131403
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

71 files changed:
arch/arm/mach-tegra/include/mach/fb.h
arch/arm/mach-tegra/include/mach/tegra_dc_ext.h
arch/arm/mach-tegra/tegra11_host1x_devices.h
drivers/video/tegra/dc/dc.c
drivers/video/tegra/dc/dc_priv.h
drivers/video/tegra/dc/dc_priv_defs.h
drivers/video/tegra/dc/dc_sysfs.c
drivers/video/tegra/dc/dsi.c
drivers/video/tegra/dc/ext/dev.c
drivers/video/tegra/dc/hdmi.c
drivers/video/tegra/dc/mipi_cal.c
drivers/video/tegra/dc/nvsd.c
drivers/video/tegra/fb.c
drivers/video/tegra/host/Makefile
drivers/video/tegra/host/bus.c [deleted file]
drivers/video/tegra/host/bus.h [deleted file]
drivers/video/tegra/host/bus_client.c
drivers/video/tegra/host/bus_client.h
drivers/video/tegra/host/chip_support.c
drivers/video/tegra/host/chip_support.h
drivers/video/tegra/host/debug.c
drivers/video/tegra/host/dev.c
drivers/video/tegra/host/dev.h
drivers/video/tegra/host/dmabuf.c
drivers/video/tegra/host/dmabuf.h
drivers/video/tegra/host/gr2d/gr2d.c
drivers/video/tegra/host/gr2d/gr2d_t114.c
drivers/video/tegra/host/gr2d/gr2d_t114.h
drivers/video/tegra/host/gr3d/gr3d.c
drivers/video/tegra/host/gr3d/gr3d.h
drivers/video/tegra/host/gr3d/gr3d_t114.c
drivers/video/tegra/host/gr3d/gr3d_t114.h
drivers/video/tegra/host/gr3d/gr3d_t20.c
drivers/video/tegra/host/gr3d/gr3d_t20.h
drivers/video/tegra/host/gr3d/gr3d_t30.c
drivers/video/tegra/host/gr3d/gr3d_t30.h
drivers/video/tegra/host/gr3d/pod_scaling.c
drivers/video/tegra/host/gr3d/pod_scaling.h
drivers/video/tegra/host/gr3d/scale3d.c
drivers/video/tegra/host/gr3d/scale3d.h
drivers/video/tegra/host/gr3d/scale3d_actmon.c
drivers/video/tegra/host/gr3d/scale3d_actmon.h
drivers/video/tegra/host/host1x/host1x.c
drivers/video/tegra/host/host1x/host1x.h
drivers/video/tegra/host/host1x/host1x_actmon.c
drivers/video/tegra/host/host1x/host1x_channel.c
drivers/video/tegra/host/host1x/host1x_debug.c
drivers/video/tegra/host/host1x/host1x_tickctrl.c
drivers/video/tegra/host/isp/isp.c
drivers/video/tegra/host/mpe/mpe.c
drivers/video/tegra/host/msenc/msenc.c
drivers/video/tegra/host/msenc/msenc.h
drivers/video/tegra/host/nvhost_acm.c
drivers/video/tegra/host/nvhost_acm.h
drivers/video/tegra/host/nvhost_cdma.c
drivers/video/tegra/host/nvhost_cdma.h
drivers/video/tegra/host/nvhost_channel.c
drivers/video/tegra/host/nvhost_channel.h
drivers/video/tegra/host/nvhost_memmgr.c
drivers/video/tegra/host/nvhost_memmgr.h
drivers/video/tegra/host/nvhost_syncpt.c
drivers/video/tegra/host/nvhost_syncpt.h
drivers/video/tegra/host/nvmap.c
drivers/video/tegra/host/nvmap.h
drivers/video/tegra/host/t114/t114.c
drivers/video/tegra/host/t20/t20.c
drivers/video/tegra/host/t30/t30.c
drivers/video/tegra/host/tsec/tsec.c
drivers/video/tegra/host/tsec/tsec.h
drivers/video/tegra/host/vi/vi.c
include/linux/nvhost.h

index 5f4a57e..dcfa5a7 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <linux/fb.h>
 
-struct nvhost_device;
+struct platform_device;
 struct tegra_dc;
 struct tegra_fb_data;
 struct tegra_fb_info;
@@ -32,7 +32,7 @@ int tegra_fb_get_mode(struct tegra_dc *dc);
 int tegra_fb_set_mode(struct tegra_dc *dc, int fps);
 
 #ifdef CONFIG_FB_TEGRA
-struct tegra_fb_info *tegra_fb_register(struct nvhost_device *ndev,
+struct tegra_fb_info *tegra_fb_register(struct platform_device *ndev,
                                        struct tegra_dc *dc,
                                        struct tegra_fb_data *fb_data,
                                        struct resource *fb_mem);
@@ -42,10 +42,9 @@ void tegra_fb_update_monspecs(struct tegra_fb_info *fb_info,
                              bool (*mode_filter)(const struct tegra_dc *dc,
                                                  struct fb_videomode *mode));
 #else
-static inline struct tegra_fb_info *tegra_fb_register(struct nvhost_device *ndev,
-                                                     struct tegra_dc *dc,
-                                                     struct tegra_fb_data *fb_data,
-                                                     struct resource *fb_mem)
+static inline struct tegra_fb_info *tegra_fb_register(
+       struct platform_device *ndev, struct tegra_dc *dc,
+       struct tegra_fb_data *fb_data, struct resource *fb_mem)
 {
        return NULL;
 }
index 5210392..e78d70e 100644 (file)
@@ -27,7 +27,7 @@ struct tegra_dc_ext;
 int __init tegra_dc_ext_module_init(void);
 void __exit tegra_dc_ext_module_exit(void);
 
-struct tegra_dc_ext *tegra_dc_ext_register(struct nvhost_device *ndev,
+struct tegra_dc_ext *tegra_dc_ext_register(struct platform_device *ndev,
                                           struct tegra_dc *dc);
 void tegra_dc_ext_unregister(struct tegra_dc_ext *dc_ext);
 
@@ -50,7 +50,7 @@ void tegra_dc_ext_module_exit(void)
 }
 
 static inline
-struct tegra_dc_ext *tegra_dc_ext_register(struct nvhost_device *ndev,
+struct tegra_dc_ext *tegra_dc_ext_register(struct platform_device *ndev,
                                           struct tegra_dc *dc)
 {
        return NULL;
index add743f..c624e41 100644 (file)
@@ -21,6 +21,6 @@
 #ifndef TEGRA11_HOST1X_DEVICES_H
 #define TEGRA11_HOST1X_DEVICES_H
 
-int tegra11_register_host1x_devices(void);
+struct platform_device *tegra11_register_host1x_devices(void);
 
 #endif
index c3fd418..f425109 100644 (file)
@@ -1480,7 +1480,7 @@ static irqreturn_t tegra_dc_irq(int irq, void *ptr)
        tegra_dc_io_start(dc);
        tegra_dc_hold_dc_out(dc);
 
-       if (!nvhost_module_powered_ext(nvhost_get_parent(dc->ndev))) {
+       if (!nvhost_module_powered_ext(dc->ndev)) {
                WARN(1, "IRQ when DC not powered!\n");
                status = tegra_dc_readl(dc, DC_CMD_INT_STATUS);
                tegra_dc_writel(dc, status, DC_CMD_INT_STATUS);
@@ -2161,8 +2161,7 @@ static ssize_t switch_modeset_print_mode(struct switch_dev *sdev, char *buf)
 }
 #endif
 
-static int tegra_dc_probe(struct nvhost_device *ndev,
-       struct nvhost_device_id *id_table)
+static int tegra_dc_probe(struct platform_device *ndev)
 {
        struct tegra_dc *dc;
        struct tegra_dc_mode *mode;
@@ -2187,14 +2186,14 @@ static int tegra_dc_probe(struct nvhost_device *ndev,
                return -ENOMEM;
        }
 
-       irq = nvhost_get_irq_byname(ndev, "irq");
+       irq = platform_get_irq_byname(ndev, "irq");
        if (irq <= 0) {
                dev_err(&ndev->dev, "no irq\n");
                ret = -ENOENT;
                goto err_free;
        }
 
-       res = nvhost_get_resource_byname(ndev, IORESOURCE_MEM, "regs");
+       res = platform_get_resource_byname(ndev, IORESOURCE_MEM, "regs");
        if (!res) {
                dev_err(&ndev->dev, "no mem resource\n");
                ret = -ENOENT;
@@ -2216,7 +2215,7 @@ static int tegra_dc_probe(struct nvhost_device *ndev,
                goto err_release_resource_reg;
        }
 
-       fb_mem = nvhost_get_resource_byname(ndev, IORESOURCE_MEM, "fbmem");
+       fb_mem = platform_get_resource_byname(ndev, IORESOURCE_MEM, "fbmem");
 
        clk = clk_get(&ndev->dev, NULL);
        if (IS_ERR_OR_NULL(clk)) {
@@ -2282,7 +2281,7 @@ static int tegra_dc_probe(struct nvhost_device *ndev,
                goto err_free_irq;
        }
 
-       nvhost_set_drvdata(ndev, dc);
+       platform_set_drvdata(ndev, dc);
 
 #ifdef CONFIG_SWITCH
        dc->modeset_switch.name = dev_name(&ndev->dev);
@@ -2391,9 +2390,9 @@ err_free:
        return ret;
 }
 
-static int tegra_dc_remove(struct nvhost_device *ndev)
+static int tegra_dc_remove(struct platform_device *ndev)
 {
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
 
        tegra_dc_remove_sysfs(&dc->ndev->dev);
        tegra_dc_remove_debugfs(dc);
@@ -2432,9 +2431,9 @@ static int tegra_dc_remove(struct nvhost_device *ndev)
 }
 
 #ifdef CONFIG_PM
-static int tegra_dc_suspend(struct nvhost_device *ndev, pm_message_t state)
+static int tegra_dc_suspend(struct platform_device *ndev, pm_message_t state)
 {
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
 
        trace_display_suspend(dc);
        dev_info(&ndev->dev, "suspend\n");
@@ -2469,9 +2468,9 @@ static int tegra_dc_suspend(struct nvhost_device *ndev, pm_message_t state)
        return 0;
 }
 
-static int tegra_dc_resume(struct nvhost_device *ndev)
+static int tegra_dc_resume(struct platform_device *ndev)
 {
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
 
        trace_display_resume(dc);
        dev_info(&ndev->dev, "resume\n");
@@ -2497,9 +2496,9 @@ static int tegra_dc_resume(struct nvhost_device *ndev)
 
 #endif /* CONFIG_PM */
 
-static void tegra_dc_shutdown(struct nvhost_device *ndev)
+static void tegra_dc_shutdown(struct platform_device *ndev)
 {
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
 
        if (!dc || !dc->enabled)
                return;
@@ -2531,7 +2530,7 @@ int suspend;
 
 module_param_call(suspend, suspend_set, suspend_get, &suspend, 0644);
 
-struct nvhost_driver tegra_dc_driver = {
+struct platform_driver tegra_dc_driver = {
        .driver = {
                .name = "tegradc",
                .owner = THIS_MODULE,
@@ -2618,12 +2617,12 @@ static int __init tegra_dc_module_init(void)
        int ret = tegra_dc_ext_module_init();
        if (ret)
                return ret;
-       return nvhost_driver_register(&tegra_dc_driver);
+       return platform_driver_register(&tegra_dc_driver);
 }
 
 static void __exit tegra_dc_module_exit(void)
 {
-       nvhost_driver_unregister(&tegra_dc_driver);
+       platform_driver_unregister(&tegra_dc_driver);
        tegra_dc_ext_module_exit();
 }
 
index 7580dec..3ed0af4 100644 (file)
 
 static inline void tegra_dc_io_start(struct tegra_dc *dc)
 {
-       nvhost_module_busy_ext(nvhost_get_parent(dc->ndev));
+       nvhost_module_busy_ext(dc->ndev);
 }
 
 static inline void tegra_dc_io_end(struct tegra_dc *dc)
 {
-       nvhost_module_idle_ext(nvhost_get_parent(dc->ndev));
+       nvhost_module_idle_ext(dc->ndev);
 }
 
 static inline unsigned long tegra_dc_readl(struct tegra_dc *dc,
@@ -40,7 +40,7 @@ static inline unsigned long tegra_dc_readl(struct tegra_dc *dc,
 {
        unsigned long ret;
 
-       BUG_ON(!nvhost_module_powered_ext(to_nvhost_device(dc->ndev->dev.parent)));
+       BUG_ON(!nvhost_module_powered_ext(dc->ndev));
        if (!tegra_is_clk_enabled(dc->clk))
                WARN(1, "DC is clock-gated.\n");
 
@@ -52,7 +52,7 @@ static inline unsigned long tegra_dc_readl(struct tegra_dc *dc,
 static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long val,
                                   unsigned long reg)
 {
-       BUG_ON(!nvhost_module_powered_ext(to_nvhost_device(dc->ndev->dev.parent)));
+       BUG_ON(!nvhost_module_powered_ext(dc->ndev));
        if (!tegra_is_clk_enabled(dc->clk))
                WARN(1, "DC is clock-gated.\n");
 
index 2cec658..a3937bf 100644 (file)
@@ -101,7 +101,7 @@ struct tegra_dc_shift_clk_div {
 };
 
 struct tegra_dc {
-       struct nvhost_device            *ndev;
+       struct platform_device          *ndev;
        struct tegra_dc_platform_data   *pdata;
 
        struct resource                 *base_res;
index 0842094..6ad7a8c 100644 (file)
@@ -33,8 +33,8 @@
 static ssize_t mode_show(struct device *device,
        struct device_attribute *attr, char *buf)
 {
-       struct nvhost_device *ndev = to_nvhost_device(device);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(device);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_mode *m;
        ssize_t res;
 
@@ -69,8 +69,8 @@ static DEVICE_ATTR(mode, S_IRUGO, mode_show, NULL);
 static ssize_t stats_enable_show(struct device *dev,
        struct device_attribute *attr, char *buf)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        bool enabled;
 
        if (mutex_lock_killable(&dc->lock))
@@ -84,8 +84,8 @@ static ssize_t stats_enable_show(struct device *dev,
 static ssize_t stats_enable_store(struct device *dev,
        struct device_attribute *attr, const char *buf, size_t count)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        unsigned long val = 0;
 
        if (strict_strtoul(buf, 10, &val) < 0)
@@ -105,8 +105,8 @@ static DEVICE_ATTR(stats_enable, S_IRUGO|S_IWUSR,
 static ssize_t enable_show(struct device *device,
        struct device_attribute *attr, char *buf)
 {
-       struct nvhost_device *ndev = to_nvhost_device(device);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(device);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        ssize_t res;
 
        mutex_lock(&dc->lock);
@@ -118,8 +118,8 @@ static ssize_t enable_show(struct device *device,
 static ssize_t enable_store(struct device *dev,
        struct device_attribute *attr, const char *buf, size_t count)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        unsigned long val = 0;
 
        if (strict_strtoul(buf, 10, &val) < 0)
@@ -139,8 +139,9 @@ static DEVICE_ATTR(enable, S_IRUGO|S_IWUSR, enable_show, enable_store);
 static ssize_t crc_checksum_latched_show(struct device *device,
        struct device_attribute *attr, char *buf)
 {
-       struct nvhost_device *ndev = to_nvhost_device(device);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(device);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
+
        u32 crc;
 
        if (!dc->enabled) {
@@ -156,8 +157,8 @@ static ssize_t crc_checksum_latched_show(struct device *device,
 static ssize_t crc_checksum_latched_store(struct device *dev,
        struct device_attribute *attr, const char *buf, size_t count)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        unsigned long val = 0;
 
        if (!dc->enabled) {
@@ -188,8 +189,8 @@ static DEVICE_ATTR(crc_checksum_latched, S_IRUGO|S_IWUSR,
 static ssize_t orientation_3d_show(struct device *dev,
        struct device_attribute *attr, char *buf)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_out *dc_out = dc->out;
        const char *orientation;
        switch (dc_out->stereo->orientation) {
@@ -209,8 +210,8 @@ static ssize_t orientation_3d_show(struct device *dev,
 static ssize_t orientation_3d_store(struct device *dev,
        struct device_attribute *attr, const char *buf, size_t cnt)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_out *dc_out = dc->out;
        struct tegra_stereo_out *stereo = dc_out->stereo;
        int orientation;
@@ -239,8 +240,8 @@ static DEVICE_ATTR(stereo_orientation,
 static ssize_t mode_3d_show(struct device *dev,
        struct device_attribute *attr, char *buf)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_out *dc_out = dc->out;
        const char *mode;
        switch (dc_out->stereo->mode_2d_3d) {
@@ -260,8 +261,8 @@ static ssize_t mode_3d_show(struct device *dev,
 static ssize_t mode_3d_store(struct device *dev,
        struct device_attribute *attr, const char *buf, size_t cnt)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_out *dc_out = dc->out;
        struct tegra_stereo_out *stereo = dc_out->stereo;
        int mode;
@@ -287,8 +288,8 @@ static ssize_t colorbar_show(struct device *device,
        struct device_attribute *attr, char *buf)
 {
        int refresh_rate;
-       struct nvhost_device *ndev = to_nvhost_device(device);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(device);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
 
        refresh_rate = tegra_fb_get_mode(dc);
        return snprintf(buf, PAGE_SIZE, "%d\n", refresh_rate);
@@ -300,8 +301,8 @@ static ssize_t colorbar_show(struct device *device,
 static ssize_t colorbar_store(struct device *dev,
        struct device_attribute *attr, const char *buf, size_t count)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
 
        struct nvmap_client     *test_nvmap;
        struct nvmap_handle_ref *win;
@@ -381,8 +382,8 @@ static ssize_t nvdps_show(struct device *device,
        struct device_attribute *attr, char *buf)
 {
        int refresh_rate;
-       struct nvhost_device *ndev = to_nvhost_device(device);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(device);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
 
        refresh_rate = tegra_fb_get_mode(dc);
        return snprintf(buf, PAGE_SIZE, "%d\n", refresh_rate);
@@ -392,8 +393,8 @@ static ssize_t nvdps_show(struct device *device,
 static ssize_t nvdps_store(struct device *dev,
        struct device_attribute *attr, const char *buf, size_t count)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        int refresh_rate;
        int e;
 
@@ -413,8 +414,8 @@ static ssize_t cmu_enable_store(struct device *dev,
 {
        int val;
        int e;
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
 
        e = kstrtoint(buf, 10, &val);
        if (e)
@@ -437,8 +438,8 @@ static DEVICE_ATTR(smart_panel, S_IRUGO, smart_panel_show, NULL);
 
 void tegra_dc_remove_sysfs(struct device *dev)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_sd_settings *sd_settings = dc->out->sd_settings;
 
        device_remove_file(dev, &dev_attr_mode);
@@ -465,8 +466,8 @@ void tegra_dc_remove_sysfs(struct device *dev)
 
 void tegra_dc_create_sysfs(struct device *dev)
 {
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_sd_settings *sd_settings = dc->out->sd_settings;
        int error = 0;
 
index b41e8ab..87db9c7 100644 (file)
@@ -281,7 +281,7 @@ inline unsigned long tegra_dsi_readl(struct tegra_dc_dsi_data *dsi, u32 reg)
 {
        unsigned long ret;
 
-       BUG_ON(!nvhost_module_powered_ext(nvhost_get_parent(dsi->dc->ndev)));
+       BUG_ON(!nvhost_module_powered_ext(dsi->dc->ndev));
        ret = readl(dsi->base + reg * 4);
        trace_display_readl(dsi->dc, ret, dsi->base + reg * 4);
        return ret;
@@ -290,7 +290,7 @@ EXPORT_SYMBOL(tegra_dsi_readl);
 
 inline void tegra_dsi_writel(struct tegra_dc_dsi_data *dsi, u32 val, u32 reg)
 {
-       BUG_ON(!nvhost_module_powered_ext(nvhost_get_parent(dsi->dc->ndev)));
+       BUG_ON(!nvhost_module_powered_ext(dsi->dc->ndev));
        trace_display_writel(dsi->dc, val, dsi->base + reg * 4);
        writel(val, dsi->base + reg * 4);
 }
@@ -3579,15 +3579,15 @@ static int _tegra_dc_dsi_init(struct tegra_dc *dc)
 
        if (dc->out->dsi->ganged_type) {
                if (dsi_enum)
-                       res = nvhost_get_resource_byname(dc->ndev,
+                       res = platform_get_resource_byname(dc->ndev,
                                                IORESOURCE_MEM,
                                                "ganged_dsib_regs");
                else
-                       res = nvhost_get_resource_byname(dc->ndev,
+                       res = platform_get_resource_byname(dc->ndev,
                                                IORESOURCE_MEM,
                                                "ganged_dsia_regs");
        } else {
-               res = nvhost_get_resource_byname(dc->ndev,
+               res = platform_get_resource_byname(dc->ndev,
                                        IORESOURCE_MEM,
                                        "dsi_regs");
        }
index 8d81dae..906c6b2 100644 (file)
@@ -272,8 +272,7 @@ static int tegra_dc_ext_set_windowattr(struct tegra_dc_ext *ext,
                                "Window atrributes are invalid.\n");
 
        if ((s32)flip_win->attr.pre_syncpt_id >= 0) {
-               nvhost_syncpt_wait_timeout(
-                               &nvhost_get_host(ext->dc->ndev)->syncpt,
+               nvhost_syncpt_wait_timeout_ext(ext->dc->ndev,
                                flip_win->attr.pre_syncpt_id,
                                flip_win->attr.pre_syncpt_val,
                                msecs_to_jiffies(500), NULL);
@@ -1032,7 +1031,7 @@ static const struct file_operations tegra_dc_devops = {
        .unlocked_ioctl =       tegra_dc_ioctl,
 };
 
-struct tegra_dc_ext *tegra_dc_ext_register(struct nvhost_device *ndev,
+struct tegra_dc_ext *tegra_dc_ext_register(struct platform_device *ndev,
                                           struct tegra_dc *dc)
 {
        int ret;
index 9f450c5..3da31ce 100644 (file)
@@ -1582,14 +1582,16 @@ static int tegra_dc_hdmi_init(struct tegra_dc *dc)
        if (!hdmi)
                return -ENOMEM;
 
-       res = nvhost_get_resource_byname(dc->ndev, IORESOURCE_MEM, "hdmi_regs");
+       res = platform_get_resource_byname(dc->ndev,
+               IORESOURCE_MEM, "hdmi_regs");
        if (!res) {
                dev_err(&dc->ndev->dev, "hdmi: no mem resource\n");
                err = -ENOENT;
                goto err_free_hdmi;
        }
 
-       base_res = request_mem_region(res->start, resource_size(res), dc->ndev->name);
+       base_res = request_mem_region(res->start,
+               resource_size(res), dc->ndev->name);
        if (!base_res) {
                dev_err(&dc->ndev->dev, "hdmi: request_mem_region failed\n");
                err = -EBUSY;
index f53154c..bf6b9f7 100644 (file)
@@ -49,7 +49,7 @@ struct tegra_mipi_cal *tegra_mipi_cal_init_sw(struct tegra_dc *dc)
                goto fail;
        }
 
-       res = nvhost_get_resource_byname(dc->ndev, IORESOURCE_MEM, "mipi_cal");
+       res = platform_get_resource_byname(dc->ndev, IORESOURCE_MEM, "mipi_cal");
        if (!res) {
                dev_err(&dc->ndev->dev, "mipi_cal: no entry in resource\n");
                err = -ENOENT;
index c7c479a..6a7aa85 100644 (file)
@@ -804,8 +804,8 @@ static ssize_t nvsd_settings_show(struct kobject *kobj,
        struct kobj_attribute *attr, char *buf)
 {
        struct device *dev = container_of((kobj->parent), struct device, kobj);
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_sd_settings *sd_settings = dc->out->sd_settings;
        ssize_t res = 0;
 
@@ -976,8 +976,8 @@ static ssize_t nvsd_settings_store(struct kobject *kobj,
        struct kobj_attribute *attr, const char *buf, size_t count)
 {
        struct device *dev = container_of((kobj->parent), struct device, kobj);
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        struct tegra_dc_sd_settings *sd_settings = dc->out->sd_settings;
        ssize_t res = count;
        bool settings_updated = false;
@@ -1136,8 +1136,8 @@ static ssize_t nvsd_registers_show(struct kobject *kobj,
        struct kobj_attribute *attr, char *buf)
 {
        struct device *dev = container_of((kobj->parent), struct device, kobj);
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct tegra_dc *dc = nvhost_get_drvdata(ndev);
+       struct platform_device *ndev = to_platform_device(dev);
+       struct tegra_dc *dc = platform_get_drvdata(ndev);
        ssize_t res = 0;
 
        mutex_lock(&dc->lock);
index 9995d2a..a6a8b90 100644 (file)
@@ -49,7 +49,7 @@
 
 struct tegra_fb_info {
        struct tegra_dc_win     *win;
-       struct nvhost_device    *ndev;
+       struct platform_device  *ndev;
        struct fb_info          *info;
        bool                    valid;
 
@@ -521,7 +521,7 @@ void tegra_fb_update_monspecs(struct tegra_fb_info *fb_info,
        mutex_unlock(&fb_info->info->lock);
 }
 
-struct tegra_fb_info *tegra_fb_register(struct nvhost_device *ndev,
+struct tegra_fb_info *tegra_fb_register(struct platform_device *ndev,
                                        struct tegra_dc *dc,
                                        struct tegra_fb_data *fb_data,
                                        struct resource *fb_mem)
index 54c84b3..e3ae359 100644 (file)
@@ -7,12 +7,11 @@ nvhost-objs = \
        nvhost_intr.o \
        nvhost_channel.o \
        nvhost_job.o \
-       bus.o \
        dev.o \
        debug.o \
        bus_client.o \
        chip_support.o \
-       nvhost_memmgr.o
+       nvhost_memmgr.o \
 
 obj-$(CONFIG_TEGRA_GRHOST) += mpe/
 obj-$(CONFIG_TEGRA_GRHOST) += gr3d/
diff --git a/drivers/video/tegra/host/bus.c b/drivers/video/tegra/host/bus.c
deleted file mode 100644 (file)
index 9baa7a5..0000000
+++ /dev/null
@@ -1,643 +0,0 @@
-/*
- * drivers/video/tegra/host/bus.c
- *
- * Copyright (C) 2010 Google, Inc.
- * Author: Erik Gilling <konkers@google.com>
- *
- * Copyright (C) 2010-2012 NVIDIA Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/pm_runtime.h>
-#include <linux/export.h>
-#include <linux/nvhost.h>
-#include <linux/io.h>
-
-#include "bus.h"
-#include "dev.h"
-
-struct nvhost_bus *nvhost_bus_inst;
-struct nvhost_master *nvhost;
-
-struct resource *nvhost_get_resource(struct nvhost_device *dev,
-                                      unsigned int type, unsigned int num)
-{
-       int i;
-
-       for (i = 0; i < dev->num_resources; i++) {
-               struct resource *r = &dev->resource[i];
-
-               if (type == resource_type(r) && num-- == 0)
-                       return r;
-       }
-       return NULL;
-}
-EXPORT_SYMBOL_GPL(nvhost_get_resource);
-
-int nvhost_get_irq(struct nvhost_device *dev, unsigned int num)
-{
-       struct resource *r = nvhost_get_resource(dev, IORESOURCE_IRQ, num);
-
-       return r ? r->start : -ENXIO;
-}
-EXPORT_SYMBOL_GPL(nvhost_get_irq);
-
-struct resource *nvhost_get_resource_byname(struct nvhost_device *dev,
-                                             unsigned int type,
-                                             const char *name)
-{
-       int i;
-
-       for (i = 0; i < dev->num_resources; i++) {
-               struct resource *r = &dev->resource[i];
-
-               if (type == resource_type(r) && !strcmp(r->name, name))
-                       return r;
-       }
-       return NULL;
-}
-EXPORT_SYMBOL_GPL(nvhost_get_resource_byname);
-
-int nvhost_get_irq_byname(struct nvhost_device *dev, const char *name)
-{
-       struct resource *r = nvhost_get_resource_byname(dev, IORESOURCE_IRQ,
-                                                         name);
-
-       return r ? r->start : -ENXIO;
-}
-EXPORT_SYMBOL_GPL(nvhost_get_irq_byname);
-
-static struct nvhost_device_id *nvhost_bus_match_id(struct nvhost_device *dev,
-       struct nvhost_device_id *id_table)
-{
-       while (id_table->name[0]) {
-               if (strcmp(dev->name, id_table->name) == 0
-                               && dev->version == id_table->version)
-                       return id_table;
-               id_table++;
-       }
-       return NULL;
-}
-
-static int nvhost_bus_match(struct device *_dev, struct device_driver *drv)
-{
-       struct nvhost_device *dev = to_nvhost_device(_dev);
-       struct nvhost_driver *ndrv = to_nvhost_driver(drv);
-
-       /* check if driver support multiple devices through id_table */
-       if (ndrv->id_table)
-               return nvhost_bus_match_id(dev, ndrv->id_table) != NULL;
-       else /* driver does not support id_table */
-               return !strcmp(dev->name, drv->name);
-}
-
-static int nvhost_drv_probe(struct device *_dev)
-{
-       struct nvhost_driver *drv = to_nvhost_driver(_dev->driver);
-       struct nvhost_device *dev = to_nvhost_device(_dev);
-
-       if (drv && drv->probe) {
-               if (drv->id_table)
-                       return drv->probe(dev, nvhost_bus_match_id(dev, drv->id_table));
-               else
-                       return drv->probe(dev, NULL);
-       }
-       else
-               return -ENODEV;
-}
-
-static int nvhost_drv_remove(struct device *_dev)
-{
-       struct nvhost_driver *drv = to_nvhost_driver(_dev->driver);
-       struct nvhost_device *dev = to_nvhost_device(_dev);
-
-       return drv->remove(dev);
-}
-
-static void nvhost_drv_shutdown(struct device *_dev)
-{
-       struct nvhost_driver *drv = to_nvhost_driver(_dev->driver);
-       struct nvhost_device *dev = to_nvhost_device(_dev);
-
-       drv->shutdown(dev);
-}
-
-int nvhost_driver_register(struct nvhost_driver *drv)
-{
-       drv->driver.bus = &nvhost_bus_inst->nvhost_bus_type;
-       if (drv->probe)
-               drv->driver.probe = nvhost_drv_probe;
-       if (drv->remove)
-               drv->driver.remove = nvhost_drv_remove;
-       if (drv->shutdown)
-               drv->driver.shutdown = nvhost_drv_shutdown;
-
-       return driver_register(&drv->driver);
-}
-EXPORT_SYMBOL(nvhost_driver_register);
-
-void nvhost_driver_unregister(struct nvhost_driver *drv)
-{
-       driver_unregister(&drv->driver);
-}
-EXPORT_SYMBOL_GPL(nvhost_driver_unregister);
-
-int nvhost_add_devices(struct nvhost_device **devs, int num)
-{
-       int i, ret = 0;
-
-       for (i = 0; i < num; i++) {
-               ret = nvhost_device_register(devs[i]);
-               if (ret) {
-                       while (--i >= 0)
-                               nvhost_device_unregister(devs[i]);
-                       break;
-               }
-       }
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(nvhost_add_devices);
-
-int nvhost_device_register(struct nvhost_device *dev)
-{
-       int i, ret = 0;
-
-       if (!dev)
-               return -EINVAL;
-
-       device_initialize(&dev->dev);
-
-       /*  If the dev does not have a parent, assign host1x as parent */
-       if (!dev->dev.parent && nvhost && nvhost->dev != dev)
-               dev->dev.parent = &nvhost->dev->dev;
-
-       dev->dev.bus = &nvhost_bus_inst->nvhost_bus_type;
-
-       if (dev->id != -1)
-               dev_set_name(&dev->dev, "%s.%d", dev->name,  dev->id);
-       else
-               dev_set_name(&dev->dev, "%s", dev->name);
-
-       for (i = 0; i < dev->num_resources; i++) {
-               struct resource *p, *r = &dev->resource[i];
-
-               if (r->name == NULL)
-                       r->name = dev_name(&dev->dev);
-
-               p = r->parent;
-               if (!p) {
-                       if (resource_type(r) == IORESOURCE_MEM)
-                               p = &iomem_resource;
-                       else if (resource_type(r) == IORESOURCE_IO)
-                               p = &ioport_resource;
-               }
-
-               if (p && insert_resource(p, r)) {
-                       pr_err("%s: failed to claim resource %d\n",
-                              dev_name(&dev->dev), i);
-                       ret = -EBUSY;
-                       goto failed;
-               }
-       }
-
-       ret = device_add(&dev->dev);
-       if (ret == 0)
-               return ret;
-
-failed:
-       while (--i >= 0) {
-               struct resource *r = &dev->resource[i];
-               unsigned long type = resource_type(r);
-
-               if (type == IORESOURCE_MEM || type == IORESOURCE_IO)
-                       release_resource(r);
-       }
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(nvhost_device_register);
-
-void nvhost_device_unregister(struct nvhost_device *dev)
-{
-       int i;
-       if (dev) {
-               device_del(&dev->dev);
-
-               for (i = 0; i < dev->num_resources; i++) {
-                       struct resource *r = &dev->resource[i];
-                       unsigned long type = resource_type(r);
-
-                       if (type == IORESOURCE_MEM || type == IORESOURCE_IO)
-                               release_resource(r);
-               }
-
-               put_device(&dev->dev);
-       }
-}
-EXPORT_SYMBOL_GPL(nvhost_device_unregister);
-
-void nvhost_device_writel(struct nvhost_device *dev, u32 r, u32 v)
-{
-       writel(v, dev->aperture + r);
-}
-EXPORT_SYMBOL_GPL(nvhost_device_writel);
-
-u32 nvhost_device_readl(struct nvhost_device *dev, u32 r)
-{
-       return readl(dev->aperture + r);
-}
-EXPORT_SYMBOL_GPL(nvhost_device_readl);
-
-#ifdef CONFIG_PM_SLEEP
-
-static int nvhost_legacy_suspend(struct device *dev, pm_message_t mesg)
-{
-       struct nvhost_driver *pdrv = to_nvhost_driver(dev->driver);
-       struct nvhost_device *pdev = to_nvhost_device(dev);
-       int ret = 0;
-
-       if (dev->driver && pdrv->suspend)
-               ret = pdrv->suspend(pdev, mesg);
-
-       return ret;
-}
-
-static int nvhost_legacy_resume(struct device *dev)
-{
-       struct nvhost_driver *pdrv = to_nvhost_driver(dev->driver);
-       struct nvhost_device *pdev = to_nvhost_device(dev);
-       int ret = 0;
-
-       if (dev->driver && pdrv->resume)
-               ret = pdrv->resume(pdev);
-
-       return ret;
-}
-
-static int nvhost_pm_prepare(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (drv && drv->pm && drv->pm->prepare)
-               ret = drv->pm->prepare(dev);
-
-       return ret;
-}
-
-static void nvhost_pm_complete(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-
-       if (drv && drv->pm && drv->pm->complete)
-               drv->pm->complete(dev);
-}
-
-#else /* !CONFIG_PM_SLEEP */
-
-#define nvhost_pm_prepare              NULL
-#define nvhost_pm_complete             NULL
-
-#endif /* !CONFIG_PM_SLEEP */
-
-#ifdef CONFIG_SUSPEND
-
-int __weak nvhost_pm_suspend(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->suspend)
-                       ret = drv->pm->suspend(dev);
-       } else {
-               ret = nvhost_legacy_suspend(dev, PMSG_SUSPEND);
-       }
-
-       return ret;
-}
-
-int __weak nvhost_pm_suspend_noirq(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->suspend_noirq)
-                       ret = drv->pm->suspend_noirq(dev);
-       }
-
-       return ret;
-}
-
-int __weak nvhost_pm_resume(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->resume)
-                       ret = drv->pm->resume(dev);
-       } else {
-               ret = nvhost_legacy_resume(dev);
-       }
-
-       return ret;
-}
-
-int __weak nvhost_pm_resume_noirq(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->resume_noirq)
-                       ret = drv->pm->resume_noirq(dev);
-       }
-
-       return ret;
-}
-
-#else /* !CONFIG_SUSPEND */
-
-#define nvhost_pm_suspend              NULL
-#define nvhost_pm_resume               NULL
-#define nvhost_pm_suspend_noirq        NULL
-#define nvhost_pm_resume_noirq NULL
-
-#endif /* !CONFIG_SUSPEND */
-
-#ifdef CONFIG_HIBERNATION
-
-static int nvhost_pm_freeze(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->freeze)
-                       ret = drv->pm->freeze(dev);
-       } else {
-               ret = nvhost_legacy_suspend(dev, PMSG_FREEZE);
-       }
-
-       return ret;
-}
-
-static int nvhost_pm_freeze_noirq(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->freeze_noirq)
-                       ret = drv->pm->freeze_noirq(dev);
-       }
-
-       return ret;
-}
-
-static int nvhost_pm_thaw(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->thaw)
-                       ret = drv->pm->thaw(dev);
-       } else {
-               ret = nvhost_legacy_resume(dev);
-       }
-
-       return ret;
-}
-
-static int nvhost_pm_thaw_noirq(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->thaw_noirq)
-                       ret = drv->pm->thaw_noirq(dev);
-       }
-
-       return ret;
-}
-
-static int nvhost_pm_poweroff(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->poweroff)
-                       ret = drv->pm->poweroff(dev);
-       } else {
-               ret = nvhost_legacy_suspend(dev, PMSG_HIBERNATE);
-       }
-
-       return ret;
-}
-
-static int nvhost_pm_poweroff_noirq(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->poweroff_noirq)
-                       ret = drv->pm->poweroff_noirq(dev);
-       }
-
-       return ret;
-}
-
-static int nvhost_pm_restore(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->restore)
-                       ret = drv->pm->restore(dev);
-       } else {
-               ret = nvhost_legacy_resume(dev);
-       }
-
-       return ret;
-}
-
-static int nvhost_pm_restore_noirq(struct device *dev)
-{
-       struct device_driver *drv = dev->driver;
-       int ret = 0;
-
-       if (!drv)
-               return 0;
-
-       if (drv->pm) {
-               if (drv->pm->restore_noirq)
-                       ret = drv->pm->restore_noirq(dev);
-       }
-
-       return ret;
-}
-
-#else /* !CONFIG_HIBERNATION */
-
-#define nvhost_pm_freeze               NULL
-#define nvhost_pm_thaw         NULL
-#define nvhost_pm_poweroff             NULL
-#define nvhost_pm_restore              NULL
-#define nvhost_pm_freeze_noirq NULL
-#define nvhost_pm_thaw_noirq           NULL
-#define nvhost_pm_poweroff_noirq       NULL
-#define nvhost_pm_restore_noirq        NULL
-
-#endif /* !CONFIG_HIBERNATION */
-
-#ifdef CONFIG_PM_RUNTIME
-
-int __weak nvhost_pm_runtime_suspend(struct device *dev)
-{
-       return pm_generic_runtime_suspend(dev);
-};
-
-int __weak nvhost_pm_runtime_resume(struct device *dev)
-{
-       return pm_generic_runtime_resume(dev);
-};
-
-int __weak nvhost_pm_runtime_idle(struct device *dev)
-{
-       return pm_generic_runtime_idle(dev);
-};
-
-#else /* !CONFIG_PM_RUNTIME */
-
-#define nvhost_pm_runtime_suspend NULL
-#define nvhost_pm_runtime_resume NULL
-#define nvhost_pm_runtime_idle NULL
-
-#endif /* !CONFIG_PM_RUNTIME */
-
-static const struct dev_pm_ops nvhost_dev_pm_ops = {
-       .prepare = nvhost_pm_prepare,
-       .complete = nvhost_pm_complete,
-       .suspend = nvhost_pm_suspend,
-       .resume = nvhost_pm_resume,
-       .freeze = nvhost_pm_freeze,
-       .thaw = nvhost_pm_thaw,
-       .poweroff = nvhost_pm_poweroff,
-       .restore = nvhost_pm_restore,
-       .suspend_noirq = nvhost_pm_suspend_noirq,
-       .resume_noirq = nvhost_pm_resume_noirq,
-       .freeze_noirq = nvhost_pm_freeze_noirq,
-       .thaw_noirq = nvhost_pm_thaw_noirq,
-       .poweroff_noirq = nvhost_pm_poweroff_noirq,
-       .restore_noirq = nvhost_pm_restore_noirq,
-       .runtime_suspend = nvhost_pm_runtime_suspend,
-       .runtime_resume = nvhost_pm_runtime_resume,
-       .runtime_idle = nvhost_pm_runtime_idle,
-};
-
-static int set_parent(struct device *dev, void *data)
-{
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       struct nvhost_master *host = data;
-       if (!dev->parent && ndev != host->dev)
-               dev->parent = &host->dev->dev;
-       return 0;
-}
-
-int nvhost_bus_add_host(struct nvhost_master *host)
-{
-       nvhost = host;
-
-       /*  Assign host1x as parent to all devices in nvhost bus */
-       bus_for_each_dev(&nvhost_bus_inst->nvhost_bus_type, NULL, host, set_parent);
-
-       return 0;
-}
-
-struct nvhost_bus *nvhost_bus_get(void)
-{
-       return nvhost_bus_inst;
-}
-
-int nvhost_bus_init(void)
-{
-       int err;
-       struct nvhost_chip_support *chip_ops;
-
-       pr_info("host1x bus init\n");
-
-       nvhost_bus_inst = kzalloc(sizeof(*nvhost_bus_inst), GFP_KERNEL);
-       if (nvhost_bus_inst == NULL) {
-               pr_err("%s: Cannot allocate nvhost_bus\n", __func__);
-               return -ENOMEM;
-       }
-
-       chip_ops = kzalloc(sizeof(*chip_ops), GFP_KERNEL);
-       if (chip_ops == NULL) {
-               pr_err("%s: Cannot allocate nvhost_chip_support\n", __func__);
-               kfree(nvhost_bus_inst);
-               nvhost_bus_inst = NULL;
-               return -ENOMEM;
-       }
-
-       nvhost_bus_inst->nvhost_bus_type.name = "nvhost";
-       nvhost_bus_inst->nvhost_bus_type.match = nvhost_bus_match;
-       nvhost_bus_inst->nvhost_bus_type.pm = &nvhost_dev_pm_ops;
-       nvhost_bus_inst->nvhost_chip_ops = chip_ops;
-
-       err = bus_register(&nvhost_bus_inst->nvhost_bus_type);
-
-       return err;
-}
-postcore_initcall(nvhost_bus_init);
diff --git a/drivers/video/tegra/host/bus.h b/drivers/video/tegra/host/bus.h
deleted file mode 100644 (file)
index 99f8203..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * drivers/video/tegra/host/bus.h
- *
- * Tegra Graphics Host bus API header
- *
- * Copyright (c) 2010-2012, NVIDIA Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __NVHOST_BUS_H
-#define __NVHOST_BUS_H
-
-#include <linux/types.h>
-#include <linux/device.h>
-
-#include "chip_support.h"
-
-struct nvhost_bus {
-       struct nvhost_chip_support *nvhost_chip_ops;
-       struct bus_type nvhost_bus_type;
-};
-
-struct nvhost_bus *nvhost_bus_get(void);
-
-extern struct nvhost_bus *nvhost_bus_inst;
-
-#endif
index 7033fe8..4b0b81d 100644 (file)
@@ -53,9 +53,9 @@
 #include "nvhost_job.h"
 #include "nvhost_hwctx.h"
 
-static int validate_reg(struct nvhost_device *ndev, u32 offset, int count)
+static int validate_reg(struct platform_device *ndev, u32 offset, int count)
 {
-       struct resource *r = nvhost_get_resource(ndev, IORESOURCE_MEM, 0);
+       struct resource *r = platform_get_resource(ndev, IORESOURCE_MEM, 0);
        int err = 0;
 
        if (offset + 4 * count > resource_size(r)
@@ -65,10 +65,11 @@ static int validate_reg(struct nvhost_device *ndev, u32 offset, int count)
        return err;
 }
 
-int nvhost_read_module_regs(struct nvhost_device *ndev,
+int nvhost_read_module_regs(struct platform_device *ndev,
                        u32 offset, int count, u32 *values)
 {
-       void __iomem *p = ndev->aperture + offset;
+       struct nvhost_device_data *pdata = platform_get_drvdata(ndev);
+       void __iomem *p = pdata->aperture + offset;
        int err;
 
        /* verify offset */
@@ -87,11 +88,14 @@ int nvhost_read_module_regs(struct nvhost_device *ndev,
        return 0;
 }
 
-int nvhost_write_module_regs(struct nvhost_device *ndev,
+int nvhost_write_module_regs(struct platform_device *ndev,
                        u32 offset, int count, const u32 *values)
 {
-       void __iomem *p = ndev->aperture + offset;
+       void __iomem *p;
        int err;
+       struct nvhost_device_data *pdata = platform_get_drvdata(ndev);
+
+       p = pdata->aperture + offset;
 
        /* verify offset */
        err = validate_reg(ndev, offset, count);
@@ -125,7 +129,7 @@ static int nvhost_channelrelease(struct inode *inode, struct file *filp)
 {
        struct nvhost_channel_userctx *priv = filp->private_data;
 
-       trace_nvhost_channel_release(priv->ch->dev->name);
+       trace_nvhost_channel_release(dev_name(&priv->ch->dev->dev));
 
        filp->private_data = NULL;
 
@@ -152,7 +156,7 @@ static int nvhost_channelopen(struct inode *inode, struct file *filp)
        ch = nvhost_getchannel(ch);
        if (!ch)
                return -ENOMEM;
-       trace_nvhost_channel_open(ch->dev->name);
+       trace_nvhost_channel_open(dev_name(&ch->dev->dev));
 
        priv = kzalloc(sizeof(*priv), GFP_KERNEL);
        if (!priv) {
@@ -182,7 +186,7 @@ fail:
 
 static int set_submit(struct nvhost_channel_userctx *ctx)
 {
-       struct nvhost_device *ndev = ctx->ch->dev;
+       struct platform_device *ndev = ctx->ch->dev;
        struct nvhost_master *host = nvhost_get_host(ndev);
 
        /* submit should have at least 1 cmdbuf */
@@ -354,7 +358,7 @@ static int nvhost_ioctl_channel_flush(
        struct nvhost_get_param_args *args,
        int null_kickoff)
 {
-       struct nvhost_device *ndev = to_nvhost_device(&ctx->ch->dev->dev);
+       struct platform_device *ndev = to_platform_device(&ctx->ch->dev->dev);
        int err;
 
        trace_nvhost_ioctl_channel_flush(ctx->ch->dev->name);
@@ -404,12 +408,13 @@ static int nvhost_ioctl_channel_read_3d_reg(struct nvhost_channel_userctx *ctx,
                        args->offset, &args->value);
 }
 
-static int moduleid_to_index(struct nvhost_device *dev, u32 moduleid)
+static int moduleid_to_index(struct platform_device *dev, u32 moduleid)
 {
        int i;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        for (i = 0; i < NVHOST_MODULE_MAX_CLOCKS; i++) {
-               if (dev->clocks[i].moduleid == moduleid)
+               if (pdata->clocks[i].moduleid == moduleid)
                        return i;
        }
 
@@ -443,7 +448,7 @@ static int nvhost_ioctl_channel_module_regrdwr(
        u32 *offsets = args->offsets;
        u32 *values = args->values;
        u32 vals[64];
-       struct nvhost_device *ndev;
+       struct platform_device *ndev;
 
        trace_nvhost_ioctl_channel_module_regrdwr(args->id,
                args->num_offsets, args->write);
@@ -555,19 +560,31 @@ static long nvhost_channelctl(struct file *filp,
                break;
        }
        case NVHOST_IOCTL_CHANNEL_GET_SYNCPOINTS:
+       {
                /* host syncpt ID is used by the RM (and never be given out) */
-               BUG_ON(priv->ch->dev->syncpts & (1 << NVSYNCPT_GRAPHICS_HOST));
+               struct nvhost_device_data *pdata = \
+                       platform_get_drvdata(priv->ch->dev);
+               BUG_ON(pdata->syncpts & (1 << NVSYNCPT_GRAPHICS_HOST));
                ((struct nvhost_get_param_args *)buf)->value =
-                       priv->ch->dev->syncpts;
+                       pdata->syncpts;
                break;
+       }
        case NVHOST_IOCTL_CHANNEL_GET_WAITBASES:
+       {
+               struct nvhost_device_data *pdata = \
+                       platform_get_drvdata(priv->ch->dev);
                ((struct nvhost_get_param_args *)buf)->value =
-                       priv->ch->dev->waitbases;
+                       pdata->waitbases;
                break;
+       }
        case NVHOST_IOCTL_CHANNEL_GET_MODMUTEXES:
+       {
+               struct nvhost_device_data *pdata = \
+                       platform_get_drvdata(priv->ch->dev);
                ((struct nvhost_get_param_args *)buf)->value =
-                       priv->ch->dev->modulemutexes;
+                       pdata->modulemutexes;
                break;
+       }
        case NVHOST_IOCTL_CHANNEL_SET_NVMAP_FD:
        {
                int fd = (int)((struct nvhost_set_nvmap_fd_args *)buf)->fd;
@@ -642,11 +659,12 @@ static const struct file_operations nvhost_channelops = {
        .unlocked_ioctl = nvhost_channelctl
 };
 
-int nvhost_client_user_init(struct nvhost_device *dev)
+int nvhost_client_user_init(struct platform_device *dev)
 {
        int err, devno;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       struct nvhost_channel *ch = dev->channel;
+       struct nvhost_channel *ch = pdata->channel;
        err = alloc_chrdev_region(&devno, 0, 1, IFACE_NAME);
        if (err < 0) {
                dev_err(&dev->dev, "failed to allocate devno\n");
@@ -659,16 +677,17 @@ int nvhost_client_user_init(struct nvhost_device *dev)
        err = cdev_add(&ch->cdev, devno, 1);
        if (err < 0) {
                dev_err(&dev->dev,
-                       "failed to add chan %i cdev\n", dev->index);
+                       "failed to add chan %i cdev\n", pdata->index);
                goto fail;
        }
        ch->node = device_create(nvhost_get_host(dev)->nvhost_class,
                        NULL, devno, NULL,
-                       IFACE_NAME "-%s", dev->name);
+                       IFACE_NAME "-%s", dev_name(&dev->dev));
        if (IS_ERR(ch->node)) {
                err = PTR_ERR(ch->node);
                dev_err(&dev->dev,
-                       "failed to create %s channel device\n", dev->name);
+                       "failed to create %s channel device\n",
+                       dev_name(&dev->dev));
                goto fail;
        }
 
@@ -677,11 +696,12 @@ fail:
        return err;
 }
 
-int nvhost_client_device_init(struct nvhost_device *dev)
+int nvhost_client_device_init(struct platform_device *dev)
 {
        int err;
        struct nvhost_master *nvhost_master = nvhost_get_host(dev);
        struct nvhost_channel *ch;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        ch = nvhost_alloc_channel(dev);
        if (ch == NULL)
@@ -690,7 +710,7 @@ int nvhost_client_device_init(struct nvhost_device *dev)
        /* store the pointer to this device for channel */
        ch->dev = dev;
 
-       err = nvhost_channel_init(ch, nvhost_master, dev->index);
+       err = nvhost_channel_init(ch, nvhost_master, pdata->index);
        if (err)
                goto fail;
 
@@ -705,6 +725,10 @@ int nvhost_client_device_init(struct nvhost_device *dev)
        if (tickctrl_op().init_channel)
                tickctrl_op().init_channel(dev);
 
+       err = nvhost_device_list_add(dev);
+       if (err)
+               goto fail;
+
        nvhost_device_debug_init(dev);
 
        dev_info(&dev->dev, "initialized\n");
@@ -717,11 +741,12 @@ fail:
        return err;
 }
 
-int nvhost_client_device_suspend(struct nvhost_device *dev)
+int nvhost_client_device_suspend(struct platform_device *dev)
 {
        int ret = 0;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       ret = nvhost_channel_suspend(dev->channel);
+       ret = nvhost_channel_suspend(pdata->channel);
        if (ret)
                return ret;
 
@@ -730,13 +755,14 @@ int nvhost_client_device_suspend(struct nvhost_device *dev)
        return ret;
 }
 
-int nvhost_client_device_get_resources(struct nvhost_device *dev)
+int nvhost_client_device_get_resources(struct platform_device *dev)
 {
        struct resource *r = NULL;
        void __iomem *regs = NULL;
        struct resource *reg_mem = NULL;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       r = nvhost_get_resource(dev, IORESOURCE_MEM, 0);
+       r = platform_get_resource(dev, IORESOURCE_MEM, 0);
        if (!r)
                goto fail;
 
@@ -748,8 +774,8 @@ int nvhost_client_device_get_resources(struct nvhost_device *dev)
        if (!regs)
                goto fail;
 
-       dev->reg_mem = reg_mem;
-       dev->aperture = regs;
+       pdata->reg_mem = reg_mem;
+       pdata->aperture = regs;
 
        return 0;
 
@@ -764,14 +790,17 @@ fail:
        return -ENXIO;
 }
 
-void nvhost_client_device_put_resources(struct nvhost_device *dev)
+void nvhost_client_device_put_resources(struct platform_device *dev)
 {
        struct resource *r;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+
+       BUG_ON(!pdata);
 
-       r = nvhost_get_resource(dev, IORESOURCE_MEM, 0);
+       r = platform_get_resource(dev, IORESOURCE_MEM, 0);
        BUG_ON(!r);
 
-       iounmap(dev->aperture);
+       iounmap(pdata->aperture);
 
        release_mem_region(r->start, resource_size(r));
 }
@@ -781,7 +810,7 @@ void nvhost_client_device_put_resources(struct nvhost_device *dev)
  * The caller is responsible for calling release_firmware later.
  */
 const struct firmware *
-nvhost_client_request_firmware(struct nvhost_device *dev, const char *fw_name)
+nvhost_client_request_firmware(struct platform_device *dev, const char *fw_name)
 {
        struct nvhost_chip_support *op = nvhost_get_chip_ops();
        const struct firmware *fw;
@@ -793,7 +822,7 @@ nvhost_client_request_firmware(struct nvhost_device *dev, const char *fw_name)
 
        if (op->soc_name) {
                path_len = strlen(fw_name) + strlen(op->soc_name);
-               path_len +=2; /* for the path separator and zero terminator*/
+               path_len += 2; /* for the path separator and zero terminator*/
 
                fw_path = kzalloc(sizeof(*fw_path) * path_len,
                                     GFP_KERNEL);
index ff3dd86..f9f8146 100644 (file)
 #define __NVHOST_BUS_CLIENT_H
 
 #include <linux/types.h>
-struct nvhost_device;
+
 struct firmware;
+struct platform_device;
 
-int nvhost_read_module_regs(struct nvhost_device *ndev,
+int nvhost_read_module_regs(struct platform_device *ndev,
                        u32 offset, int count, u32 *values);
 
-int nvhost_write_module_regs(struct nvhost_device *ndev,
+int nvhost_write_module_regs(struct platform_device *ndev,
                        u32 offset, int count, const u32 *values);
 
-int nvhost_client_user_init(struct nvhost_device *dev);
+int nvhost_client_user_init(struct platform_device *dev);
 
-int nvhost_client_device_init(struct nvhost_device *dev);
+int nvhost_client_device_init(struct platform_device *dev);
 
-int nvhost_client_device_suspend(struct nvhost_device *dev);
+int nvhost_client_device_suspend(struct platform_device *dev);
 
 const struct firmware *
-nvhost_client_request_firmware(struct nvhost_device *dev, const char *fw_name);
+nvhost_client_request_firmware(struct platform_device *dev,
+       const char *fw_name);
 
-int nvhost_client_device_get_resources(struct nvhost_device *dev);
-void nvhost_client_device_put_resources(struct nvhost_device *dev);
+int nvhost_client_device_get_resources(struct platform_device *dev);
+void nvhost_client_device_put_resources(struct platform_device *dev);
 
 #endif
index 7f24529..bc4c727 100644 (file)
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/bug.h>
+#include <linux/slab.h>
 
-#include "bus.h"
 #include "chip_support.h"
 #include "t20/t20.h"
 #include "t30/t30.h"
 #include "t114/t114.h"
+
 #include <mach/hardware.h>
 
+struct nvhost_chip_support *nvhost_chip_ops;
+
 struct nvhost_chip_support *nvhost_get_chip_ops(void)
 {
-       return (nvhost_bus_get())->nvhost_chip_ops;
+       return nvhost_chip_ops;
 }
 
 int nvhost_init_chip_support(struct nvhost_master *host)
 {
        int err = 0;
-       struct nvhost_chip_support *chip_ops;
 
-       chip_ops = nvhost_get_chip_ops();
+       if (nvhost_chip_ops == NULL) {
+               nvhost_chip_ops = kzalloc(sizeof(*nvhost_chip_ops), GFP_KERNEL);
+               if (nvhost_chip_ops == NULL) {
+                       pr_err("%s: Cannot allocate nvhost_chip_support\n",
+                               __func__);
+                       return 0;
+               }
+       }
 
        switch (tegra_get_chipid()) {
        case TEGRA_CHIPID_TEGRA2:
-               chip_ops->soc_name = "tegra2x";
-               err = nvhost_init_t20_support(host, chip_ops);
+               nvhost_chip_ops->soc_name = "tegra2x";
+               err = nvhost_init_t20_support(host, nvhost_chip_ops);
                break;
 
        case TEGRA_CHIPID_TEGRA3:
-               chip_ops->soc_name = "tegra3x";
-               err = nvhost_init_t30_support(host, chip_ops);
+               nvhost_chip_ops->soc_name = "tegra3x";
+               err = nvhost_init_t30_support(host, nvhost_chip_ops);
                break;
 
        case TEGRA_CHIPID_TEGRA11:
-               chip_ops->soc_name = "tegra11x";
-               err = nvhost_init_t114_support(host, chip_ops);
+               nvhost_chip_ops->soc_name = "tegra11x";
+               err = nvhost_init_t114_support(host, nvhost_chip_ops);
                break;
 
        default:
index d1a47c1..0ab2653 100644 (file)
@@ -21,7 +21,6 @@
 #define _NVHOST_CHIP_SUPPORT_H_
 
 #include <linux/types.h>
-#include "bus.h"
 
 struct output;
 
@@ -41,7 +40,7 @@ struct nvhost_job_unpin;
 struct nvhost_intr_syncpt;
 struct mem_handle;
 struct mem_mgr;
-struct nvhost_device;
+struct platform_device;
 
 struct nvhost_channel_ops {
        const char * soc_name;
@@ -132,7 +131,7 @@ struct nvhost_intr_ops {
 
 struct nvhost_dev_ops {
        struct nvhost_channel *(*alloc_nvhost_channel)(
-                       struct nvhost_device *dev);
+                       struct platform_device *dev);
        void (*free_nvhost_channel)(struct nvhost_channel *ch);
 };
 
@@ -145,7 +144,7 @@ struct nvhost_mem_ops {
                        size_t size, size_t align,
                        int flags);
        struct mem_handle *(*get)(struct mem_mgr *,
-                       u32 id, struct nvhost_device *);
+                       u32 id, struct platform_device *);
        void (*put)(struct mem_mgr *, struct mem_handle *);
        struct sg_table *(*pin)(struct mem_mgr *, struct mem_handle *);
        void (*unpin)(struct mem_mgr *, struct mem_handle *, struct sg_table *);
@@ -154,7 +153,7 @@ struct nvhost_mem_ops {
        void *(*kmap)(struct mem_handle *, unsigned int);
        void (*kunmap)(struct mem_handle *, unsigned int, void *);
        int (*pin_array_ids)(struct mem_mgr *,
-                       struct nvhost_device *,
+                       struct platform_device *,
                        long unsigned *,
                        dma_addr_t *,
                        u32,
@@ -181,11 +180,11 @@ struct nvhost_actmon_ops {
 struct nvhost_tickctrl_ops {
        int (*init_host)(struct nvhost_master *host);
        void (*deinit_host)(struct nvhost_master *host);
-       int (*init_channel)(struct nvhost_device *dev);
-       void (*deinit_channel)(struct nvhost_device *dev);
-       int (*tickcount)(struct nvhost_device *dev, u64 *val);
-       int (*stallcount)(struct nvhost_device *dev, u64 *val);
-       int (*xfercount)(struct nvhost_device *dev, u64 *val);
+       int (*init_channel)(struct platform_device *dev);
+       void (*deinit_channel)(struct platform_device *dev);
+       int (*tickcount)(struct platform_device *dev, u64 *val);
+       int (*stallcount)(struct platform_device *dev, u64 *val);
+       int (*xfercount)(struct platform_device *dev, u64 *val);
 };
 
 struct nvhost_chip_support {
@@ -204,13 +203,13 @@ struct nvhost_chip_support {
 
 struct nvhost_chip_support *nvhost_get_chip_ops(void);
 
-#define host_device_op()       nvhost_get_chip_ops()->nvhost_dev
-#define channel_cdma_op()      nvhost_get_chip_ops()->cdma
-#define channel_op()           nvhost_get_chip_ops()->channel
-#define syncpt_op()            nvhost_get_chip_ops()->syncpt
-#define intr_op()              nvhost_get_chip_ops()->intr
-#define cdma_op()              nvhost_get_chip_ops()->cdma
-#define cdma_pb_op()           nvhost_get_chip_ops()->push_buffer
+#define host_device_op()       (nvhost_get_chip_ops()->nvhost_dev)
+#define channel_cdma_op()      (nvhost_get_chip_ops()->cdma)
+#define channel_op()           (nvhost_get_chip_ops()->channel)
+#define syncpt_op()            (nvhost_get_chip_ops()->syncpt)
+#define intr_op()              (nvhost_get_chip_ops()->intr)
+#define cdma_op()              (nvhost_get_chip_ops()->cdma)
+#define cdma_pb_op()           (nvhost_get_chip_ops()->push_buffer)
 #define mem_op()               (nvhost_get_chip_ops()->mem)
 #define actmon_op()            (nvhost_get_chip_ops()->actmon)
 #define tickctrl_op()          (nvhost_get_chip_ops()->tickctrl)
index 0a4e653..efe3f94 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <linux/io.h>
 
-#include "bus.h"
 #include "dev.h"
 #include "debug.h"
 #include "nvhost_acm.h"
@@ -48,24 +47,27 @@ void nvhost_debug_output(struct output *o, const char* fmt, ...)
        o->fn(o->ctx, o->buf, len);
 }
 
-static int show_channels(struct device *dev, void *data)
+static int show_channels(struct platform_device *pdev, void *data)
 {
        struct nvhost_channel *ch;
-       struct nvhost_device *nvdev = to_nvhost_device(dev);
        struct output *o = data;
        struct nvhost_master *m;
+       struct nvhost_device_data *pdata;
 
-       if (nvdev == NULL)
+       if (pdev == NULL)
                return 0;
 
-       m = nvhost_get_host(nvdev);
-       ch = nvdev->channel;
+       pdata = platform_get_drvdata(pdev);
+       m = nvhost_get_host(pdev);
+       ch = pdata->channel;
        if (ch) {
                mutex_lock(&ch->reflock);
                if (ch->refcount) {
                        mutex_lock(&ch->cdma.lock);
-                       nvhost_get_chip_ops()->debug.show_channel_fifo(m, ch, o, nvdev->index);
-                       nvhost_get_chip_ops()->debug.show_channel_cdma(m, ch, o, nvdev->index);
+                       nvhost_get_chip_ops()->debug.show_channel_fifo(
+                               m, ch, o, pdata->index);
+                       nvhost_get_chip_ops()->debug.show_channel_cdma(
+                               m, ch, o, pdata->index);
                        mutex_unlock(&ch->cdma.lock);
                }
                mutex_unlock(&ch->reflock);
@@ -107,31 +109,31 @@ static void show_all(struct nvhost_master *m, struct output *o)
        nvhost_get_chip_ops()->debug.show_mlocks(m, o);
        show_syncpts(m, o);
        nvhost_debug_output(o, "---- channels ----\n");
-       bus_for_each_dev(&(nvhost_bus_get())->nvhost_bus_type, NULL, o,
-                       show_channels);
+       nvhost_device_list_for_all(o, show_channels);
 
        nvhost_module_idle(m->dev);
 }
 
 #ifdef CONFIG_DEBUG_FS
-static int show_channels_no_fifo(struct device *dev, void *data)
+static int show_channels_no_fifo(struct platform_device *pdev, void *data)
 {
        struct nvhost_channel *ch;
-       struct nvhost_device *nvdev = to_nvhost_device(dev);
        struct output *o = data;
        struct nvhost_master *m;
+       struct nvhost_device_data *pdata;
 
-       if (nvdev == NULL)
+       if (pdev == NULL)
                return 0;
 
-       m = nvhost_get_host(nvdev);
-       ch = nvdev->channel;
+       pdata = platform_get_drvdata(pdev);
+       m = nvhost_get_host(pdev);
+       ch = pdata->channel;
        if (ch) {
                mutex_lock(&ch->reflock);
                if (ch->refcount) {
                        mutex_lock(&ch->cdma.lock);
                        nvhost_get_chip_ops()->debug.show_channel_cdma(m,
-                                       ch, o, nvdev->index);
+                                       ch, o, pdata->index);
                        mutex_unlock(&ch->cdma.lock);
                }
                mutex_unlock(&ch->reflock);
@@ -147,8 +149,7 @@ static void show_all_no_fifo(struct nvhost_master *m, struct output *o)
        nvhost_get_chip_ops()->debug.show_mlocks(m, o);
        show_syncpts(m, o);
        nvhost_debug_output(o, "---- channels ----\n");
-       bus_for_each_dev(&(nvhost_bus_get())->nvhost_bus_type, NULL, o,
-                       show_channels_no_fifo);
+       nvhost_device_list_for_all(o, show_channels_no_fifo);
 
        nvhost_module_idle(m->dev);
 }
@@ -162,6 +163,7 @@ static int nvhost_debug_show_all(struct seq_file *s, void *unused)
        show_all(s->private, &o);
        return 0;
 }
+
 static int nvhost_debug_show(struct seq_file *s, void *unused)
 {
        struct output o = {
@@ -233,6 +235,7 @@ static const struct file_operations actmon_above_wmark_fops = {
        .llseek         = seq_lseek,
        .release        = single_release,
 };
+
 static int actmon_avg_show(struct seq_file *s, void *unused)
 {
        struct nvhost_master *host = s->private;
@@ -398,7 +401,7 @@ static const struct file_operations actmon_k_fops = {
 
 static int tickcount_show(struct seq_file *s, void *unused)
 {
-       struct nvhost_device *dev = s->private;
+       struct platform_device *dev = s->private;
        u64 cnt;
        int err;
 
@@ -425,7 +428,7 @@ static const struct file_operations tickcount_fops = {
 
 static int stallcount_show(struct seq_file *s, void *unused)
 {
-       struct nvhost_device *dev = s->private;
+       struct platform_device *dev = s->private;
        u64 cnt;
        int err;
 
@@ -452,7 +455,7 @@ static const struct file_operations stallcount_fops = {
 
 static int xfercount_show(struct seq_file *s, void *unused)
 {
-       struct nvhost_device *dev = s->private;
+       struct platform_device *dev = s->private;
        u64 cnt;
        int err;
 
@@ -477,26 +480,30 @@ static const struct file_operations xfercount_fops = {
        .release        = single_release,
 };
 
-void nvhost_device_debug_init(struct nvhost_device *dev)
+void nvhost_device_debug_init(struct platform_device *dev)
 {
-       struct dentry *de = nvhost_get_parent(dev)->debugfs;
+       struct dentry *de = NULL;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        de = debugfs_create_dir(dev->name, de);
        debugfs_create_file("stallcount", S_IRUGO, de, dev, &stallcount_fops);
        debugfs_create_file("xfercount", S_IRUGO, de, dev, &xfercount_fops);
 
-       dev->debugfs = de;
+       pdata->debugfs = de;
 }
 
 void nvhost_debug_init(struct nvhost_master *master)
 {
+       struct nvhost_device_data *pdata;
        struct dentry *de = debugfs_create_dir("tegra_host", NULL);
 
        if (!de)
                return;
 
+       pdata = platform_get_drvdata(master->dev);
+
        /* Store the created entry */
-       master->dev->debugfs = de;
+       pdata->debugfs = de;
 
        debugfs_create_file("status", S_IRUGO, de,
                        master, &nvhost_debug_fops);
index 7df4e7d..bed54e0 100644 (file)
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/nvhost.h>
+
 #include <linux/module.h>
+#include <linux/io.h>
 #include <linux/nvhost.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+
 #include <mach/gpufuse.h>
 
+/* host1x device list is used in 2 places:
+ * 1. In ioctl(NVHOST_IOCTL_CTRL_MODULE_REGRDWR) of host1x device
+ * 2. debug-fs dump of host1x and client device
+ *    as well as channel state */
+struct nvhost_device_list {
+       struct list_head list;
+       struct platform_device *pdev;
+};
+
+/* HEAD for the host1x device list */
+static struct nvhost_device_list ndev_head;
+
+/* Constructor for the host1x device list */
+void nvhost_device_list_init(void)
+{
+       INIT_LIST_HEAD(&ndev_head.list);
+}
+
+/* Adds a device to tail of host1x device list */
+int nvhost_device_list_add(struct platform_device *pdev)
+{
+       struct nvhost_device_list *list;
+
+       list = kzalloc(sizeof(struct nvhost_device_list), GFP_KERNEL);
+       if (!list)
+               return -ENOMEM;
+
+       list->pdev = pdev;
+       list_add_tail(&list->list, &ndev_head.list);
+
+       return 0;
+}
+
+/* Iterator function for host1x device list
+ * It takes a fptr as an argument and calls that function for each
+ * device in the list */
+void nvhost_device_list_for_all(void *data,
+       int (*fptr)(struct platform_device *pdev, void *fdata))
+{
+       struct list_head *pos;
+       struct nvhost_device_list *nlist;
+       int ret;
+
+       list_for_each(pos, &ndev_head.list) {
+               nlist = list_entry(pos, struct nvhost_device_list, list);
+               if (nlist && nlist->pdev && fptr) {
+                       ret = fptr(nlist->pdev, data);
+                       if (ret) {
+                               pr_info("%s: iterator error\n", __func__);
+                               break;
+                       }
+               }
+       }
+}
+
+/* Simple search function for the host1x device list
+ * It takes the moduleid as argument and returns a pointer to host1x
+ * device that matches the moduleid otherwise returns NULL */
+struct platform_device *nvhost_device_list_match_by_id(u32 id)
+{
+       struct list_head *pos;
+       struct nvhost_device_list *nlist;
+       struct nvhost_device_data *pdata;
+
+       list_for_each(pos, &ndev_head.list) {
+               nlist = list_entry(pos, struct nvhost_device_list, list);
+               if (nlist && nlist->pdev) {
+                       pdata = platform_get_drvdata(nlist->pdev);
+                       if (pdata && (pdata->moduleid == id))
+                               return nlist->pdev;
+               }
+       }
+
+       return NULL;
+}
+
+/* Removes a device from the host1x device list */
+void nvhost_device_list_remove(struct platform_device *pdev)
+{
+       struct list_head *pos;
+       struct nvhost_device_list *nlist;
+
+       list_for_each(pos, &ndev_head.list) {
+               nlist = list_entry(pos, struct nvhost_device_list, list);
+               if (nlist && nlist->pdev == pdev) {
+                       list_del(&nlist->list);
+                       kfree(nlist);
+               }
+       }
+}
+
 static unsigned int register_sets = 2;
 
 void nvhost_set_register_sets(unsigned int r)
@@ -31,6 +127,20 @@ void nvhost_set_register_sets(unsigned int r)
        register_sets = r;
 }
 
+void nvhost_device_writel(struct platform_device *dev, u32 r, u32 v)
+{
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       writel(v, pdata->aperture + r);
+}
+EXPORT_SYMBOL_GPL(nvhost_device_writel);
+
+u32 nvhost_device_readl(struct platform_device *dev, u32 r)
+{
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       return readl(pdata->aperture + r);
+}
+EXPORT_SYMBOL_GPL(nvhost_device_readl);
+
 module_param_call(register_sets, NULL, param_get_uint, &register_sets, 0444);
 MODULE_PARM_DESC(register_sets, "Number of register sets");
 
index 53ec2de..12dfda5 100644 (file)
 
 #include "host1x/host1x.h"
 
+struct platform_device;
+
+void nvhost_device_list_init(void);
+int nvhost_device_list_add(struct platform_device *pdev);
+void nvhost_device_list_for_all(void *data,
+       int (*fptr)(struct platform_device *pdev, void *fdata));
+struct platform_device *nvhost_device_list_match_by_id(u32 id);
+void nvhost_device_list_remove(struct platform_device *pdev);
+
 #endif
index b45d6be..9ec13b2 100644 (file)
@@ -81,7 +81,7 @@ void nvhost_dmabuf_kunmap(struct mem_handle *handle, unsigned int pagenum,
        dma_buf_kunmap(to_dmabuf(handle), pagenum, addr);
 }
 
-struct mem_handle *nvhost_dmabuf_get(u32 id, struct nvhost_device *dev)
+struct mem_handle *nvhost_dmabuf_get(u32 id, struct platform_device *dev)
 {
        struct mem_handle *h;
        struct dma_buf *buf;
@@ -98,7 +98,7 @@ struct mem_handle *nvhost_dmabuf_get(u32 id, struct nvhost_device *dev)
        return (struct mem_handle *) ((u32)h | mem_mgr_type_dmabuf);
 }
 
-int nvhost_dmabuf_pin_array_ids(struct nvhost_device *dev,
+int nvhost_dmabuf_pin_array_ids(struct platform_device *dev,
                long unsigned *ids,
                long unsigned id_type_mask,
                long unsigned id_type,
index f07ec52..2b0fbfa 100644 (file)
@@ -24,7 +24,7 @@
 #include "nvhost_memmgr.h"
 
 struct nvhost_chip_support;
-struct nvhost_device;
+struct platform_device;
 
 struct mem_mgr *nvhost_dmabuf_alloc_mgr(void);
 void nvhost_dmabuf_put_mgr(struct mem_mgr *mgr);
@@ -40,8 +40,8 @@ void nvhost_dmabuf_munmap(struct mem_handle *handle, void *addr);
 void *nvhost_dmabuf_kmap(struct mem_handle *handle, unsigned int pagenum);
 void nvhost_dmabuf_kunmap(struct mem_handle *handle, unsigned int pagenum,
                void *addr);
-int nvhost_dmabuf_get(u32 id, struct nvhost_device *dev);
-int nvhost_dmabuf_pin_array_ids(struct nvhost_device *dev,
+int nvhost_dmabuf_get(u32 id, struct platform_device *dev);
+int nvhost_dmabuf_pin_array_ids(struct platform_device *dev,
                long unsigned *ids,
                long unsigned id_type_mask,
                long unsigned id_type,
index 2c3e680..d6cefcf 100644 (file)
@@ -31,7 +31,7 @@ enum gr2d_ip_ver {
 };
 
 struct gr2d_desc {
-       void (*finalize_poweron)(struct nvhost_device *dev);
+       void (*finalize_poweron)(struct platform_device *dev);
 };
 
 static const struct gr2d_desc gr2d[] = {
@@ -40,50 +40,57 @@ static const struct gr2d_desc gr2d[] = {
        },
        [gr2d_02] = {
                .finalize_poweron = nvhost_gr2d_t114_finalize_poweron,
-       }
+       },
 };
 
-static struct nvhost_device_id gr2d_id[] = {
-       { "gr2d", gr2d_01 },
-       { "gr2d", gr2d_02 },
+static struct platform_device_id gr2d_id[] = {
+       { "gr2d01", gr2d_01 },
+       { "gr2d02", gr2d_02 },
        { },
 };
 
 MODULE_DEVICE_TABLE(nvhost, gr2d_id);
 
-static int gr2d_probe(struct nvhost_device *dev,
-       struct nvhost_device_id *id_table)
+static int gr2d_probe(struct platform_device *dev)
 {
        int index = 0;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)dev->dev.platform_data;
+
+       /* HACK: reset device name */
+       dev_set_name(&dev->dev, "%s", "gr2d");
+
+       index = (int)(platform_get_device_id(dev)->driver_data);
+       BUG_ON(index > gr2d_02);
 
-       index = id_table->version;
+       pdata->pdev = dev;
+       pdata->finalize_poweron = gr2d[index].finalize_poweron;
 
-       drv->finalize_poweron = gr2d[index].finalize_poweron;
+       platform_set_drvdata(dev, pdata);
 
        return nvhost_client_device_init(dev);
 }
 
-static int __exit gr2d_remove(struct nvhost_device *dev)
+static int __exit gr2d_remove(struct platform_device *dev)
 {
        /* Add clean-up */
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int gr2d_suspend(struct nvhost_device *dev, pm_message_t state)
+static int gr2d_suspend(struct platform_device *dev, pm_message_t state)
 {
        return nvhost_client_device_suspend(dev);
 }
 
-static int gr2d_resume(struct nvhost_device *dev)
+static int gr2d_resume(struct platform_device *dev)
 {
        dev_info(&dev->dev, "resuming\n");
        return 0;
 }
 #endif
 
-static struct nvhost_driver gr2d_driver = {
+static struct platform_driver gr2d_driver = {
        .probe = gr2d_probe,
        .remove = __exit_p(gr2d_remove),
 #ifdef CONFIG_PM
@@ -99,12 +106,12 @@ static struct nvhost_driver gr2d_driver = {
 
 static int __init gr2d_init(void)
 {
-       return nvhost_driver_register(&gr2d_driver);
+       return platform_driver_register(&gr2d_driver);
 }
 
 static void __exit gr2d_exit(void)
 {
-       nvhost_driver_unregister(&gr2d_driver);
+       platform_driver_unregister(&gr2d_driver);
 }
 
 module_init(gr2d_init);
index 3efe54b..5513d5d 100644 (file)
@@ -23,7 +23,7 @@
 #include "host1x/host1x.h"
 #include "host1x/hw_host1x02_sync.h"
 
-void nvhost_gr2d_t114_finalize_poweron(struct nvhost_device *dev)
+void nvhost_gr2d_t114_finalize_poweron(struct platform_device *dev)
 {
        void __iomem *sync_aperture = nvhost_get_host(dev)->sync_aperture;
 
index 0d37710..7c930bf 100644 (file)
@@ -21,8 +21,8 @@
 #ifndef __NVHOST_2D_T114_H
 #define __NVHOST_2D_T114_H
 
-struct nvhost_device;
+struct platform_device;
 
-void nvhost_gr2d_t114_finalize_poweron(struct nvhost_device *dev);
+void nvhost_gr2d_t114_finalize_poweron(struct platform_device *dev);
 
 #endif
index fa088c9..d456b1c 100644 (file)
@@ -148,9 +148,10 @@ void nvhost_3dctx_put(struct nvhost_hwctx *ctx)
        kref_put(&ctx->ref, nvhost_3dctx_free);
 }
 
-int nvhost_gr3d_prepare_power_off(struct nvhost_device *dev)
+int nvhost_gr3d_prepare_power_off(struct platform_device *dev)
 {
-       return nvhost_channel_save_context(dev->channel);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       return nvhost_channel_save_context(pdata->channel);
 }
 
 enum gr3d_ip_ver {
@@ -160,16 +161,16 @@ enum gr3d_ip_ver {
 };
 
 struct gr3d_desc {
-       void (*finalize_poweron)(struct nvhost_device *dev);
-       void (*busy)(struct nvhost_device *);
-       void (*idle)(struct nvhost_device *);
-       void (*suspend_ndev)(struct nvhost_device *);
-       void (*init)(struct nvhost_device *dev);
-       void (*deinit)(struct nvhost_device *dev);
-       int (*prepare_poweroff)(struct nvhost_device *dev);
+       void (*finalize_poweron)(struct platform_device *dev);
+       void (*busy)(struct platform_device *);
+       void (*idle)(struct platform_device *);
+       void (*suspend_ndev)(struct platform_device *);
+       void (*init)(struct platform_device *dev);
+       void (*deinit)(struct platform_device *dev);
+       int (*prepare_poweroff)(struct platform_device *dev);
        struct nvhost_hwctx_handler *(*alloc_hwctx_handler)(u32 syncpt,
                        u32 waitbase, struct nvhost_channel *ch);
-       int (*read_reg)(struct nvhost_device *dev, struct nvhost_channel *ch,
+       int (*read_reg)(struct platform_device *dev, struct nvhost_channel *ch,
                        struct nvhost_hwctx *hwctx, u32 offset, u32 *value);
 };
 
@@ -209,56 +210,63 @@ static const struct gr3d_desc gr3d[] = {
        },
 };
 
-static struct nvhost_device_id gr3d_id[] = {
-       { "gr3d", gr3d_01 },
-       { "gr3d", gr3d_02 },
-       { "gr3d", gr3d_03 },
+static struct platform_device_id gr3d_id[] = {
+       { "gr3d01", gr3d_01 },
+       { "gr3d02", gr3d_02 },
+       { "gr3d03", gr3d_03 },
        { },
 };
 
 MODULE_DEVICE_TABLE(nvhost, gr3d_id);
 
-static int gr3d_probe(struct nvhost_device *dev,
-       struct nvhost_device_id *id_table)
+static int gr3d_probe(struct platform_device *dev)
 {
        int index = 0;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)dev->dev.platform_data;
 
-       index = id_table->version;
+       /* HACK: reset device name */
+       dev_set_name(&dev->dev, "%s", "gr3d");
 
-       drv->finalize_poweron           = gr3d[index].finalize_poweron;
-       drv->busy                       = gr3d[index].busy;
-       drv->idle                       = gr3d[index].idle;
-       drv->suspend_ndev               = gr3d[index].suspend_ndev;
-       drv->init                       = gr3d[index].init;
-       drv->deinit                     = gr3d[index].deinit;
-       drv->prepare_poweroff           = gr3d[index].prepare_poweroff;
-       drv->alloc_hwctx_handler        = gr3d[index].alloc_hwctx_handler;
-       drv->read_reg                   = gr3d[index].read_reg;
+       pdata->pdev = dev;
+       index = (int)(platform_get_device_id(dev)->driver_data);
+       BUG_ON(index > gr3d_03);
+
+       pdata->finalize_poweron         = gr3d[index].finalize_poweron;
+       pdata->busy                     = gr3d[index].busy;
+       pdata->idle                     = gr3d[index].idle;
+       pdata->suspend_ndev             = gr3d[index].suspend_ndev;
+       pdata->init                     = gr3d[index].init;
+       pdata->deinit                   = gr3d[index].deinit;
+       pdata->prepare_poweroff         = gr3d[index].prepare_poweroff;
+       pdata->alloc_hwctx_handler      = gr3d[index].alloc_hwctx_handler;
+       pdata->read_reg                 = gr3d[index].read_reg;
+
+       platform_set_drvdata(dev, pdata);
 
        return nvhost_client_device_init(dev);
 }
 
-static int __exit gr3d_remove(struct nvhost_device *dev)
+static int __exit gr3d_remove(struct platform_device *dev)
 {
        /* Add clean-up */
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int gr3d_suspend(struct nvhost_device *dev, pm_message_t state)
+static int gr3d_suspend(struct platform_device *dev, pm_message_t state)
 {
        return nvhost_client_device_suspend(dev);
 }
 
-static int gr3d_resume(struct nvhost_device *dev)
+static int gr3d_resume(struct platform_device *dev)
 {
        dev_info(&dev->dev, "resuming\n");
        return 0;
 }
 #endif
 
-static struct nvhost_driver gr3d_driver = {
+static struct platform_driver gr3d_driver = {
        .probe = gr3d_probe,
        .remove = __exit_p(gr3d_remove),
 #ifdef CONFIG_PM
@@ -274,12 +282,12 @@ static struct nvhost_driver gr3d_driver = {
 
 static int __init gr3d_init(void)
 {
-       return nvhost_driver_register(&gr3d_driver);
+       return platform_driver_register(&gr3d_driver);
 }
 
 static void __exit gr3d_exit(void)
 {
-       nvhost_driver_unregister(&gr3d_driver);
+       platform_driver_unregister(&gr3d_driver);
 }
 
 module_init(gr3d_init);
index b7eb0a8..dde38e1 100644 (file)
@@ -54,6 +54,6 @@ struct host1x_hwctx *nvhost_3dctx_alloc_common(
 void nvhost_3dctx_get(struct nvhost_hwctx *ctx);
 void nvhost_3dctx_free(struct kref *ref);
 void nvhost_3dctx_put(struct nvhost_hwctx *ctx);
-int nvhost_gr3d_prepare_power_off(struct nvhost_device *dev);
+int nvhost_gr3d_prepare_power_off(struct platform_device *dev);
 
 #endif
index 1cc6a37..3be4cc7 100644 (file)
@@ -458,28 +458,28 @@ fail_alloc:
        return NULL;
 }
 
-void nvhost_gr3d_t114_init(struct nvhost_device *dev)
+void nvhost_gr3d_t114_init(struct platform_device *dev)
 {
        if (actmon_op().init)
                actmon_op().init(nvhost_get_host(dev));
        nvhost_scale3d_actmon_init(dev);
 }
 
-void nvhost_gr3d_t114_deinit(struct nvhost_device *dev)
+void nvhost_gr3d_t114_deinit(struct platform_device *dev)
 {
        nvhost_scale3d_actmon_deinit(dev);
        if (actmon_op().deinit)
                actmon_op().deinit(nvhost_get_host(dev));
 }
 
-int nvhost_gr3d_t114_prepare_power_off(struct nvhost_device *dev)
+int nvhost_gr3d_t114_prepare_power_off(struct platform_device *dev)
 {
        if (actmon_op().deinit)
                actmon_op().deinit(nvhost_get_host(dev));
        return nvhost_gr3d_prepare_power_off(dev);
 }
 
-void nvhost_gr3d_t114_finalize_power_on(struct nvhost_device *dev)
+void nvhost_gr3d_t114_finalize_power_on(struct platform_device *dev)
 {
        /* actmon needs to be reinitialized when we come back from
         * power gated state */
index 9c3293d..ad2bac6 100644 (file)
 #define __NVHOST_3DCTX_T114_H
 
 struct nvhost_hwctx_handler;
-struct nvhost_device;
+struct platform_device;
 struct nvhost_channel;
 struct nvhost_hwctx;
 
-struct nvhost_hwctx_handler *nvhost_gr3d_t114_ctxhandler_init(
-               u32 syncpt, u32 base,
-               struct nvhost_channel *ch);
+struct nvhost_hwctx_handler *nvhost_gr3d_t114_ctxhandler_init(u32 syncpt,
+       u32 base, struct nvhost_channel *ch);
 
-void nvhost_gr3d_t114_init(struct nvhost_device *dev);
-void nvhost_gr3d_t114_deinit(struct nvhost_device *dev);
-int nvhost_gr3d_t114_prepare_power_off(struct nvhost_device *dev);
-void nvhost_gr3d_t114_finalize_power_on(struct nvhost_device *dev);
+void nvhost_gr3d_t114_init(struct platform_device *dev);
+void nvhost_gr3d_t114_deinit(struct platform_device *dev);
+int nvhost_gr3d_t114_prepare_power_off(struct platform_device *dev);
+void nvhost_gr3d_t114_finalize_power_on(struct platform_device *dev);
 
-int nvhost_gr3d_t114_read_reg(
-       struct nvhost_device *dev,
+int nvhost_gr3d_t114_read_reg(struct platform_device *dev,
        struct nvhost_channel *channel,
        struct nvhost_hwctx *hwctx,
        u32 offset,
index f9cf9a0..a3218a6 100644 (file)
@@ -411,8 +411,7 @@ fail_alloc:
        return NULL;
 }
 
-int nvhost_gr3d_t20_read_reg(
-       struct nvhost_device *dev,
+int nvhost_gr3d_t20_read_reg(struct platform_device *dev,
        struct nvhost_channel *channel,
        struct nvhost_hwctx *hwctx,
        u32 offset,
index 953739a..5ea7b56 100644 (file)
 struct nvhost_hwctx_handler;
 struct nvhost_hwctx;
 struct nvhost_channel;
-struct nvhost_device;
+struct platform_device;
 
 struct nvhost_hwctx_handler *nvhost_gr3d_t20_ctxhandler_init(
                u32 syncpt, u32 waitbase,
                struct nvhost_channel *ch);
 
 int nvhost_gr3d_t20_read_reg(
-       struct nvhost_device *dev,
+       struct platform_device *dev,
        struct nvhost_channel *channel,
        struct nvhost_hwctx *hwctx,
        u32 offset,
index 69bb1ec..6636405 100644 (file)
@@ -451,7 +451,7 @@ fail_alloc:
 }
 
 int nvhost_gr3d_t30_read_reg(
-       struct nvhost_device *dev,
+       struct platform_device *dev,
        struct nvhost_channel *channel,
        struct nvhost_hwctx *hwctx,
        u32 offset,
index 9ff3af2..6d478e0 100644 (file)
@@ -25,7 +25,7 @@
 
 struct nvhost_hwctx_handler;
 struct nvhost_channel;
-struct nvhost_device;
+struct platform_device;
 struct nvhost_hwctx;
 
 struct nvhost_hwctx_handler *nvhost_gr3d_t30_ctxhandler_init(
@@ -33,7 +33,7 @@ struct nvhost_hwctx_handler *nvhost_gr3d_t30_ctxhandler_init(
                struct nvhost_channel *ch);
 
 int nvhost_gr3d_t30_read_reg(
-       struct nvhost_device *dev,
+       struct platform_device *dev,
        struct nvhost_channel *channel,
        struct nvhost_hwctx *hwctx,
        u32 offset,
index 1df382f..452209c 100644 (file)
@@ -217,9 +217,10 @@ static void podgov_clocks_handler(struct work_struct *work)
  * Prepare the device for suspend
  ******************************************************************************/
 
-void nvhost_scale3d_suspend(struct nvhost_device *dev)
+void nvhost_scale3d_suspend(struct platform_device *dev)
 {
-       struct devfreq *df = (void *)dev->power_manager;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       struct devfreq *df = pdata->power_manager;
        struct podgov_info_rec *podgov;
 
        if (!df)
@@ -246,8 +247,9 @@ void nvhost_scale3d_suspend(struct nvhost_device *dev)
 
 static int podgov_is_enabled(struct device *dev)
 {
-       struct nvhost_device *d = to_nvhost_device(dev);
-       struct devfreq *df = d->power_manager;
+       struct platform_device *d = to_platform_device(dev);
+       struct nvhost_device_data *pdata = platform_get_drvdata(d);
+       struct devfreq *df = pdata->power_manager;
        struct podgov_info_rec *podgov;
        int enable;
 
@@ -272,8 +274,9 @@ static int podgov_is_enabled(struct device *dev)
 
 static void podgov_enable(struct device *dev, int enable)
 {
-       struct nvhost_device *d = to_nvhost_device(dev);
-       struct devfreq *df = d->power_manager;
+       struct platform_device *d = to_platform_device(dev);
+       struct nvhost_device_data *pdata = platform_get_drvdata(d);
+       struct devfreq *df = pdata->power_manager;
        struct podgov_info_rec *podgov;
 
        if (!df)
@@ -615,8 +618,8 @@ static void podgov_idle_handler(struct work_struct *work)
 
        /* Retrieve device driver ops and the device struct */
        struct device *d = df->dev.parent;
-       struct nvhost_driver *drv = to_nvhost_driver(d->driver);
-       struct nvhost_device *dev = to_nvhost_device(d);
+       struct platform_device *dev = to_platform_device(d);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        int notify_idle = 0;
 
@@ -633,8 +636,8 @@ static void podgov_idle_handler(struct work_struct *work)
 
        mutex_unlock(&df->lock);
 
-       if (drv->idle && notify_idle)
-               drv->idle(dev);
+       if (pdata->idle && notify_idle)
+               pdata->idle(dev);
 }
 
 /*******************************************************************************
@@ -748,13 +751,14 @@ EXPORT_SYMBOL(nvhost_scale3d_set_throughput_hint);
 static void nvhost_scale3d_debug_init(struct devfreq *df)
 {
        struct podgov_info_rec *podgov = df->data;
-       struct nvhost_device *dev = to_nvhost_device(df->dev.parent);
+       struct platform_device *dev = to_platform_device(df->dev.parent);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
        struct dentry *f;
 
        if (!podgov)
                return;
 
-       podgov->debugdir = debugfs_create_dir("scaling", dev->debugfs);
+       podgov->debugdir = debugfs_create_dir("scaling", pdata->debugfs);
        if (!podgov->debugdir) {
                pr_err("podgov: can\'t create debugfs directory\n");
                return;
@@ -948,8 +952,9 @@ static int nvhost_pod_estimate_freq(struct devfreq *df,
 
 static int nvhost_pod_init(struct devfreq *df)
 {
-       struct nvhost_device *d = to_nvhost_device(df->dev.parent);
        struct podgov_info_rec *podgov;
+       struct platform_device *d = to_platform_device(df->dev.parent);
+       struct nvhost_device_data *pdata = platform_get_drvdata(d);
        ktime_t now = ktime_get();
        int error = 0;
 
@@ -1022,8 +1027,7 @@ static int nvhost_pod_init(struct devfreq *df)
                        pr_err("%s: too many frequencies\n", __func__);
                        break;
                }
-               rounded_rate =
-                       clk_round_rate(clk_get_parent(d->clk[0]), rate);
+               rounded_rate = clk_round_rate(pdata->clk[0], rate);
                freqs[podgov->freq_count++] = rounded_rate;
                rate = rounded_rate + 2000;
        }
@@ -1071,7 +1075,7 @@ err_alloc_podgov:
 static void nvhost_pod_exit(struct devfreq *df)
 {
        struct podgov_info_rec *podgov = df->data;
-       struct nvhost_device *d = to_nvhost_device(df->dev.parent);
+       struct platform_device *d = to_platform_device(df->dev.parent);
 
        cancel_work_sync(&podgov->work);
        cancel_delayed_work(&podgov->idle_timer);
index fcbbeaf..0657812 100644 (file)
 #ifndef POD_SCALING_H
 #define POD_SCALING_H
 
-struct nvhost_device;
+struct platform_device;
 struct dentry;
 
 #define GET_TARGET_FREQ_DONTSCALE      1
 
 /* Suspend is called when powering down module */
-void nvhost_scale3d_suspend(struct nvhost_device *);
+void nvhost_scale3d_suspend(struct platform_device *);
 
 extern const struct devfreq_governor nvhost_podgov;
 
index 779a058..3870ddf 100644 (file)
@@ -69,7 +69,7 @@ struct power_profile_gr3d {
        long                            emc_dip_offset;
        long                            emc_xmid;
 
-       struct nvhost_device            *dev;
+       struct platform_device          *dev;
        int                             clk_3d;
        int                             clk_3d2;
        int                             clk_3d_emc;
@@ -90,7 +90,9 @@ static struct power_profile_gr3d power_profile;
 /* Convert clk index to struct clk * */
 static inline struct clk *clk(int index)
 {
-       return power_profile.dev->clk[index];
+       struct nvhost_device_data *pdata =
+               platform_get_drvdata(power_profile.dev);
+       return pdata->clk[index];
 }
 
 /*******************************************************************************
@@ -100,9 +102,10 @@ static inline struct clk *clk(int index)
  * used to estimate the current load
  ******************************************************************************/
 
-static void nvhost_scale3d_notify(struct nvhost_device *dev, int busy)
+static void nvhost_scale3d_notify(struct platform_device *dev, int busy)
 {
-       struct devfreq *df = dev->power_manager;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       struct devfreq *df = pdata->power_manager;
        struct nvhost_devfreq_ext_stat *ext_stat;
        ktime_t t;
        unsigned long dt;
@@ -141,13 +144,13 @@ static void nvhost_scale3d_notify(struct nvhost_device *dev, int busy)
        mutex_unlock(&df->lock);
 }
 
-void nvhost_scale3d_notify_idle(struct nvhost_device *dev)
+void nvhost_scale3d_notify_idle(struct platform_device *dev)
 {
        nvhost_scale3d_notify(dev, 0);
 
 }
 
-void nvhost_scale3d_notify_busy(struct nvhost_device *dev)
+void nvhost_scale3d_notify_busy(struct platform_device *dev)
 {
        nvhost_scale3d_notify(dev, 1);
 }
@@ -334,14 +337,14 @@ static void nvhost_scale3d_calibrate_emc(void)
  * pod_scaling governor to handle the clock scaling.
  ******************************************************************************/
 
-void nvhost_scale3d_init(struct nvhost_device *dev)
+void nvhost_scale3d_init(struct platform_device *dev)
 {
        struct nvhost_devfreq_ext_stat *ext_stat;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        if (power_profile.init)
                return;
 
-
        /* Get clocks */
        power_profile.dev = dev;
        power_profile.clk_3d = 0;
@@ -385,7 +388,7 @@ void nvhost_scale3d_init(struct nvhost_device *dev)
        power_profile.init = 1;
 
        /* Start using devfreq */
-       dev->power_manager = devfreq_add_device(&dev->dev,
+       pdata->power_manager = devfreq_add_device(&dev->dev,
                                &nvhost_scale3d_devfreq_profile,
                                &nvhost_podgov,
                                NULL);
@@ -407,13 +410,14 @@ err_bad_power_profile:
  * Stop 3d scaling for the given device.
  ******************************************************************************/
 
-void nvhost_scale3d_deinit(struct nvhost_device *dev)
+void nvhost_scale3d_deinit(struct platform_device *dev)
 {
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
        if (!power_profile.init)
                return;
 
-       if (dev->power_manager)
-               devfreq_remove_device(dev->power_manager);
+       if (pdata->power_manager)
+               devfreq_remove_device(pdata->power_manager);
 
        kfree(power_profile.dev_stat->private_data);
        kfree(power_profile.dev_stat);
index 84cb3d0..6c810bd 100644 (file)
@@ -27,19 +27,19 @@ enum power_profile_status {
        DEVICE_BUSY = 2
 };
 
-struct nvhost_device;
+struct platform_device;
 struct device;
 struct dentry;
 
 /* Initialization and de-initialization for module */
-void nvhost_scale3d_init(struct nvhost_device *);
-void nvhost_scale3d_deinit(struct nvhost_device *);
+void nvhost_scale3d_init(struct platform_device *);
+void nvhost_scale3d_deinit(struct platform_device *);
 
 /*
  * call when performing submit to notify scaling mechanism that 3d module is
  * in use
  */
-void nvhost_scale3d_notify_busy(struct nvhost_device *);
-void nvhost_scale3d_notify_idle(struct nvhost_device *);
+void nvhost_scale3d_notify_busy(struct platform_device *);
+void nvhost_scale3d_notify_idle(struct platform_device *);
 
 #endif
index 0b702cf..3ab5d73 100644 (file)
@@ -94,9 +94,10 @@ static struct power_profile_gr3d power_profile;
  * used to estimate the current load
  ******************************************************************************/
 
-static void nvhost_scale3d_notify(struct nvhost_device *dev, int busy)
+static void nvhost_scale3d_notify(struct platform_device *dev, int busy)
 {
-       struct devfreq *df = dev->power_manager;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       struct devfreq *df = pdata->power_manager;
 
        /* If defreq is disabled, do nothing */
        if (!df) {
@@ -116,12 +117,12 @@ static void nvhost_scale3d_notify(struct nvhost_device *dev, int busy)
        mutex_unlock(&df->lock);
 }
 
-void nvhost_scale3d_actmon_notify_idle(struct nvhost_device *dev)
+void nvhost_scale3d_actmon_notify_idle(struct platform_device *dev)
 {
        nvhost_scale3d_notify(dev, 0);
 }
 
-void nvhost_scale3d_actmon_notify_busy(struct nvhost_device *dev)
+void nvhost_scale3d_actmon_notify_busy(struct platform_device *dev)
 {
        nvhost_scale3d_notify(dev, 1);
 }
@@ -133,7 +134,7 @@ void nvhost_scale3d_actmon_notify_busy(struct nvhost_device *dev)
  ******************************************************************************/
 
 static int nvhost_scale3d_target(struct device *d, unsigned long *freq,
-                                       u32 flags)
+                               u32 flags)
 {
        unsigned long hz;
        long after;
@@ -185,7 +186,7 @@ static int nvhost_scale3d_target(struct device *d, unsigned long *freq,
 static int nvhost_scale3d_get_dev_status(struct device *d,
                      struct devfreq_dev_status *stat)
 {
-       struct nvhost_device *dev = to_nvhost_device(d);
+       struct platform_device *dev = to_platform_device(d);
        struct nvhost_master *host_master = nvhost_get_host(dev);
        struct nvhost_devfreq_ext_stat *ext_stat =
                power_profile.dev_stat->private_data;
@@ -314,20 +315,21 @@ static void nvhost_scale3d_calibrate_emc(void)
  * pod_scaling governor to handle the clock scaling.
  ******************************************************************************/
 
-void nvhost_scale3d_actmon_init(struct nvhost_device *dev)
+void nvhost_scale3d_actmon_init(struct platform_device *dev)
 {
        struct nvhost_devfreq_ext_stat *ext_stat;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        if (power_profile.init)
                return;
 
        /* Get clocks */
-       power_profile.clk_3d = dev->clk[0];
+       power_profile.clk_3d = pdata->clk[0];
        if (tegra_get_chipid() == TEGRA_CHIPID_TEGRA3) {
-               power_profile.clk_3d2 = dev->clk[1];
-               power_profile.clk_3d_emc = dev->clk[2];
+               power_profile.clk_3d2 = pdata->clk[1];
+               power_profile.clk_3d_emc = pdata->clk[2];
        } else
-               power_profile.clk_3d_emc = dev->clk[1];
+               power_profile.clk_3d_emc = pdata->clk[1];
 
        /* Get frequency settings */
        power_profile.max_rate_3d =
@@ -362,7 +364,7 @@ void nvhost_scale3d_actmon_init(struct nvhost_device *dev)
        nvhost_scale3d_calibrate_emc();
 
        /* Start using devfreq */
-       dev->power_manager = devfreq_add_device(&dev->dev,
+       pdata->power_manager = devfreq_add_device(&dev->dev,
                                &nvhost_scale3d_devfreq_profile,
                                &nvhost_podgov,
                                NULL);
@@ -385,13 +387,15 @@ err_bad_power_profile:
  * Stop 3d scaling for the given device.
  ******************************************************************************/
 
-void nvhost_scale3d_actmon_deinit(struct nvhost_device *dev)
+void nvhost_scale3d_actmon_deinit(struct platform_device *dev)
 {
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+
        if (!power_profile.init)
                return;
 
-       if (dev->power_manager)
-               devfreq_remove_device(dev->power_manager);
+       if (pdata->power_manager)
+               devfreq_remove_device(pdata->power_manager);
 
        kfree(power_profile.dev_stat->private_data);
        kfree(power_profile.dev_stat);
index 7d39aec..a43bc1a 100644 (file)
 /* Clumsy way of getting enums from the header */
 #include "scale3d.h"
 
-struct nvhost_device;
+struct platform_device;
 struct device;
 struct dentry;
 
 /* Initialization and de-initialization for module */
-void nvhost_scale3d_actmon_init(struct nvhost_device *);
-void nvhost_scale3d_actmon_deinit(struct nvhost_device *);
+void nvhost_scale3d_actmon_init(struct platform_device *);
+void nvhost_scale3d_actmon_deinit(struct platform_device *);
 
 /*
  * call when performing submit to notify scaling mechanism that 3d module is
  * in use
  */
-void nvhost_scale3d_actmon_notify_busy(struct nvhost_device *);
-void nvhost_scale3d_actmon_notify_idle(struct nvhost_device *);
+void nvhost_scale3d_actmon_notify_busy(struct platform_device *);
+void nvhost_scale3d_actmon_notify_idle(struct platform_device *);
 
 #endif
index 42f8ae6..f137804 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 
 #include "dev.h"
-#include "bus.h"
 #include <trace/events/nvhost.h>
 
 #include <linux/nvhost.h>
 #include "nvhost_acm.h"
 #include "nvhost_channel.h"
 #include "nvhost_job.h"
+#include "chip_support.h"
 
 #define DRIVER_NAME            "host1x"
 
+struct nvhost_master *nvhost;
+
 struct nvhost_ctrl_userctx {
        struct nvhost_master *dev;
        u32 *mod_locks;
@@ -158,23 +160,6 @@ static int nvhost_ioctl_ctrl_module_mutex(struct nvhost_ctrl_userctx *ctx,
        return err;
 }
 
-static int match_by_moduleid(struct device *dev, void *data)
-{
-       struct nvhost_device *ndev = to_nvhost_device(dev);
-       u32 id = (u32)data;
-
-       return id == ndev->moduleid;
-}
-
-static struct nvhost_device *get_ndev_by_moduleid(struct nvhost_master *host,
-               u32 id)
-{
-       struct device *dev = bus_find_device(&nvhost_bus_inst->nvhost_bus_type,
-                       NULL, (void *)id, match_by_moduleid);
-
-       return dev ? to_nvhost_device(dev) : NULL;
-}
-
 static int nvhost_ioctl_ctrl_module_regrdwr(struct nvhost_ctrl_userctx *ctx,
        struct nvhost_ctrl_module_regrdwr_args *args)
 {
@@ -182,18 +167,18 @@ static int nvhost_ioctl_ctrl_module_regrdwr(struct nvhost_ctrl_userctx *ctx,
        u32 *offsets = args->offsets;
        u32 *values = args->values;
        u32 vals[64];
-       struct nvhost_device *ndev;
+       struct platform_device *ndev;
 
        trace_nvhost_ioctl_ctrl_module_regrdwr(args->id,
                        args->num_offsets, args->write);
+
        /* Check that there is something to read and that block size is
         * u32 aligned */
        if (num_offsets == 0 || args->block_size & 3)
                return -EINVAL;
 
-       ndev = get_ndev_by_moduleid(ctx->dev, args->id);
-       if (!ndev)
-               return -EINVAL;
+       ndev = nvhost_device_list_match_by_id(args->id);
+       BUG_ON(!ndev);
 
        while (num_offsets--) {
                int err;
@@ -307,32 +292,35 @@ static const struct file_operations nvhost_ctrlops = {
        .unlocked_ioctl = nvhost_ctrlctl
 };
 
-static void power_on_host(struct nvhost_device *dev)
+static void power_on_host(struct platform_device *dev)
 {
-       struct nvhost_master *host = nvhost_get_drvdata(dev);
+       struct nvhost_master *host = nvhost_get_private_data(dev);
+
        nvhost_syncpt_reset(&host->syncpt);
        if (tickctrl_op().init_host)
                tickctrl_op().init_host(host);
 }
 
-static int power_off_host(struct nvhost_device *dev)
+static int power_off_host(struct platform_device *dev)
 {
-       struct nvhost_master *host = nvhost_get_drvdata(dev);
+       struct nvhost_master *host = nvhost_get_private_data(dev);
+
        if (tickctrl_op().deinit_host)
                tickctrl_op().deinit_host(host);
        nvhost_syncpt_save(&host->syncpt);
        return 0;
 }
 
-static void clock_on_host(struct nvhost_device *dev)
+static void clock_on_host(struct platform_device *dev)
 {
-       struct nvhost_master *host = nvhost_get_drvdata(dev);
-       nvhost_intr_start(&host->intr, clk_get_rate(dev->clk[0]));
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       struct nvhost_master *host = nvhost_get_private_data(dev);
+       nvhost_intr_start(&host->intr, clk_get_rate(pdata->clk[0]));
 }
 
-static int clock_off_host(struct nvhost_device *dev)
+static int clock_off_host(struct platform_device *dev)
 {
-       struct nvhost_master *host = nvhost_get_drvdata(dev);
+       struct nvhost_master *host = nvhost_get_private_data(dev);
        nvhost_intr_stop(&host->intr);
        return 0;
 }
@@ -372,7 +360,7 @@ fail:
        return err;
 }
 
-struct nvhost_channel *nvhost_alloc_channel(struct nvhost_device *dev)
+struct nvhost_channel *nvhost_alloc_channel(struct platform_device *dev)
 {
        BUG_ON(!host_device_op().alloc_nvhost_channel);
        return host_device_op().alloc_nvhost_channel(dev);
@@ -410,16 +398,17 @@ static int nvhost_alloc_resources(struct nvhost_master *host)
        return 0;
 }
 
-static int nvhost_probe(struct nvhost_device *dev,
-       struct nvhost_device_id *id_table)
+static int nvhost_probe(struct platform_device *dev)
 {
        struct nvhost_master *host;
        struct resource *regs, *intr0, *intr1;
        int i, err;
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)dev->dev.platform_data;
 
-       regs = nvhost_get_resource(dev, IORESOURCE_MEM, 0);
-       intr0 = nvhost_get_resource(dev, IORESOURCE_IRQ, 0);
-       intr1 = nvhost_get_resource(dev, IORESOURCE_IRQ, 1);
+       regs = platform_get_resource(dev, IORESOURCE_MEM, 0);
+       intr0 = platform_get_resource(dev, IORESOURCE_IRQ, 0);
+       intr1 = platform_get_resource(dev, IORESOURCE_IRQ, 1);
 
        if (!regs || !intr0 || !intr1) {
                dev_err(&dev->dev, "missing required platform resources\n");
@@ -430,15 +419,30 @@ static int nvhost_probe(struct nvhost_device *dev,
        if (!host)
                return -ENOMEM;
 
-       /*  Register host1x device as bus master */
+       nvhost = host;
+
        host->dev = dev;
 
-       /* Copy host1x parameters */
-       memcpy(&host->info, dev->dev.platform_data,
+       /* Copy host1x parameters. The private_data gets replaced
+        * by nvhost_master later */
+       memcpy(&host->info, pdata->private_data,
                        sizeof(struct host1x_device_info));
 
+       pdata->finalize_poweron = power_on_host;
+       pdata->prepare_poweroff = power_off_host;
+       pdata->prepare_clockoff = clock_off_host;
+       pdata->finalize_clockon = clock_on_host;
+
+       pdata->pdev = dev;
+
+       /* set common host1x device data */
+       platform_set_drvdata(dev, pdata);
+
+       /* set private host1x device data */
+       nvhost_set_private_data(dev, host);
+
        host->reg_mem = request_mem_region(regs->start,
-                                       resource_size(regs), dev->name);
+               resource_size(regs), dev->name);
        if (!host->reg_mem) {
                dev_err(&dev->dev, "failed to get host register memory\n");
                err = -ENXIO;
@@ -465,14 +469,6 @@ static int nvhost_probe(struct nvhost_device *dev,
                goto fail;
        }
 
-       /*  Register host1x device as bus master */
-       host->dev = dev;
-
-       /*  Give pointer to host1x via driver */
-       nvhost_set_drvdata(dev, host);
-
-       nvhost_bus_add_host(host);
-
        err = nvhost_syncpt_init(dev, &host->syncpt);
        if (err)
                goto fail;
@@ -489,11 +485,16 @@ static int nvhost_probe(struct nvhost_device *dev,
        if (err)
                goto fail;
 
-       for (i = 0; i < host->dev->num_clks; i++)
-               clk_prepare_enable(host->dev->clk[i]);
+       for (i = 0; i < pdata->num_clks; i++)
+               clk_prepare_enable(pdata->clk[i]);
        nvhost_syncpt_reset(&host->syncpt);
-       for (i = 0; i < host->dev->num_clks; i++)
-               clk_disable_unprepare(host->dev->clk[0]);
+       for (i = 0; i < pdata->num_clks; i++)
+               clk_disable_unprepare(pdata->clk[i]);
+
+       nvhost_device_list_init();
+       err = nvhost_device_list_add(dev);
+       if (err)
+               goto fail;
 
        nvhost_debug_init(host);
 
@@ -511,18 +512,18 @@ fail:
        return err;
 }
 
-static int __exit nvhost_remove(struct nvhost_device *dev)
+static int __exit nvhost_remove(struct platform_device *dev)
 {
-       struct nvhost_master *host = nvhost_get_drvdata(dev);
+       struct nvhost_master *host = nvhost_get_private_data(dev);
        nvhost_intr_deinit(&host->intr);
        nvhost_syncpt_deinit(&host->syncpt);
        nvhost_free_resources(host);
        return 0;
 }
 
-static int nvhost_suspend(struct nvhost_device *dev, pm_message_t state)
+static int nvhost_suspend(struct platform_device *dev, pm_message_t state)
 {
-       struct nvhost_master *host = nvhost_get_drvdata(dev);
+       struct nvhost_master *host = nvhost_get_private_data(dev);
        int ret = 0;
 
        ret = nvhost_module_suspend(host->dev);
@@ -531,13 +532,13 @@ static int nvhost_suspend(struct nvhost_device *dev, pm_message_t state)
        return ret;
 }
 
-static int nvhost_resume(struct nvhost_device *dev)
+static int nvhost_resume(struct platform_device *dev)
 {
        dev_info(&dev->dev, "resuming\n");
        return 0;
 }
 
-static struct nvhost_driver nvhost_driver = {
+static struct platform_driver platform_driver = {
        .probe = nvhost_probe,
        .remove = __exit_p(nvhost_remove),
        .suspend = nvhost_suspend,
@@ -546,20 +547,16 @@ static struct nvhost_driver nvhost_driver = {
                .owner = THIS_MODULE,
                .name = DRIVER_NAME
        },
-       .finalize_poweron = power_on_host,
-       .prepare_poweroff = power_off_host,
-       .finalize_clockon = clock_on_host,
-       .prepare_clockoff = clock_off_host,
 };
 
 static int __init nvhost_mod_init(void)
 {
-       return nvhost_driver_register(&nvhost_driver);
+       return platform_driver_register(&platform_driver);
 }
 
 static void __exit nvhost_mod_exit(void)
 {
-       nvhost_driver_unregister(&nvhost_driver);
+       platform_driver_unregister(&platform_driver);
 }
 
 /* host1x master device needs nvmap to be instantiated first.
index 44bbf2c..9010fb0 100644 (file)
@@ -52,28 +52,55 @@ struct nvhost_master {
        struct nvhost_syncpt syncpt;
        struct mem_mgr *memmgr;
        struct nvhost_intr intr;
-       struct nvhost_device *dev;
+       struct platform_device *dev;
        atomic_t clientid;
-
        struct host1x_device_info info;
 };
 
 extern struct nvhost_master *nvhost;
 
 void nvhost_debug_init(struct nvhost_master *master);
-void nvhost_device_debug_init(struct nvhost_device *dev);
+void nvhost_device_debug_init(struct platform_device *dev);
 void nvhost_debug_dump(struct nvhost_master *master);
 
-struct nvhost_channel *nvhost_alloc_channel(struct nvhost_device *dev);
+struct nvhost_channel *nvhost_alloc_channel(struct platform_device *dev);
 void nvhost_free_channel(struct nvhost_channel *ch);
 
 extern pid_t nvhost_debug_null_kickoff_pid;
 
-static inline struct nvhost_master *nvhost_get_host(struct nvhost_device *_dev)
+static inline void *nvhost_get_private_data(struct platform_device *_dev)
+{
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)platform_get_drvdata(_dev);
+       BUG_ON(!pdata);
+       return pdata->private_data ? pdata->private_data : NULL;
+}
+
+static inline void nvhost_set_private_data(struct platform_device *_dev,
+       void *priv_data)
+{
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)platform_get_drvdata(_dev);
+       BUG_ON(!pdata);
+       pdata->private_data = priv_data;
+}
+
+static inline struct nvhost_master *nvhost_get_host(
+       struct platform_device *_dev)
+{
+       struct platform_device *pdev;
+
+       if (_dev->dev.parent) {
+               pdev = to_platform_device(_dev->dev.parent);
+               return nvhost_get_private_data(pdev);
+       } else
+               return nvhost_get_private_data(_dev);
+}
+
+static inline struct platform_device *nvhost_get_parent(
+       struct platform_device *_dev)
 {
-       return (_dev->dev.parent) ? \
-               ((struct nvhost_master *) dev_get_drvdata(_dev->dev.parent)) : \
-               ((struct nvhost_master *) dev_get_drvdata(&(_dev->dev)));
+       return _dev->dev.parent ? to_platform_device(_dev->dev.parent) : NULL;
 }
 
 #endif
index 19a7b99..92e008d 100644 (file)
@@ -75,9 +75,10 @@ static void host1x_actmon_update_sample_period_safe(struct nvhost_master *host)
 {
        void __iomem *sync_regs = host->sync_aperture;
        long freq_mhz, clks_per_sample;
+       struct nvhost_device_data *pdata = platform_get_drvdata(host->dev);
 
        /* We use MHz and us instead of Hz and s due to numerical limitations */
-       freq_mhz = clk_get_rate(host->dev->clk[0]) / 1000000;
+       freq_mhz = clk_get_rate(pdata->clk[0]) / 1000000;
        clks_per_sample = (freq_mhz * actmon_status.usecs_per_sample) / 256;
        actmon_status.clks_per_sample = clks_per_sample;
 
index 88874e1..9db45c7 100644 (file)
@@ -38,8 +38,9 @@ static int host1x_drain_read_fifo(struct nvhost_channel *ch,
 static void sync_waitbases(struct nvhost_channel *ch, u32 syncpt_val)
 {
        unsigned long waitbase;
-       unsigned long int waitbase_mask = ch->dev->waitbases;
-       if (ch->dev->waitbasesync) {
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
+       unsigned long int waitbase_mask = pdata->waitbases;
+       if (pdata->waitbasesync) {
                waitbase = find_first_bit(&waitbase_mask, BITS_PER_LONG);
                nvhost_cdma_push(&ch->cdma,
                        nvhost_opcode_setclass(NV_HOST1X_CLASS_ID,
@@ -157,6 +158,7 @@ static void submit_nullkickoff(struct nvhost_job *job, int user_syncpt_incrs)
        struct nvhost_channel *ch = job->ch;
        int incr;
        u32 op_incr;
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
 
        /* push increments that correspond to nulled out commands */
        op_incr = nvhost_opcode_imm_incr_syncpt(
@@ -168,7 +170,7 @@ static void submit_nullkickoff(struct nvhost_job *job, int user_syncpt_incrs)
                nvhost_cdma_push(&ch->cdma, op_incr, NVHOST_OPCODE_NOOP);
 
        /* for 3d, waitbase needs to be incremented after each submit */
-       if (ch->dev->class == NV_GRAPHICS_3D_CLASS_ID) {
+       if (pdata->class == NV_GRAPHICS_3D_CLASS_ID) {
                u32 waitbase = to_host1x_hwctx_handler(job->hwctx->h)->waitbase;
                nvhost_cdma_push(&ch->cdma,
                        nvhost_opcode_setclass(
@@ -206,7 +208,7 @@ static int host1x_channel_submit(struct nvhost_job *job)
        u32 syncval;
        int err;
        void *completed_waiter = NULL, *ctxsave_waiter = NULL;
-       struct nvhost_driver *drv = to_nvhost_driver(ch->dev->dev.driver);
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
 
        /* Bail out on timed out contexts */
        if (job->hwctx && job->hwctx->has_timedout)
@@ -214,8 +216,6 @@ static int host1x_channel_submit(struct nvhost_job *job)
 
        /* Turn on the client module and host1x */
        nvhost_module_busy(ch->dev);
-       if (drv->busy)
-               drv->busy(ch->dev);
 
        /* before error checks, return current max */
        prev_max = job->syncpt_end =
@@ -253,7 +253,7 @@ static int host1x_channel_submit(struct nvhost_job *job)
                goto error;
        }
 
-       if (ch->dev->serialize) {
+       if (pdata->serialize) {
                /* Force serialization by inserting a host wait for the
                 * previous job to finish before this one can commence. */
                nvhost_cdma_push(&ch->cdma,
@@ -275,9 +275,9 @@ static int host1x_channel_submit(struct nvhost_job *job)
        job->syncpt_end = syncval;
 
        /* add a setclass for modules that require it */
-       if (ch->dev->class)
+       if (pdata->class)
                nvhost_cdma_push(&ch->cdma,
-                       nvhost_opcode_setclass(ch->dev->class, 0, 0),
+                       nvhost_opcode_setclass(pdata->class, 0, 0),
                        NVHOST_OPCODE_NOOP);
 
        if (job->null_kickoff)
@@ -357,7 +357,6 @@ static int host1x_drain_read_fifo(struct nvhost_channel *ch,
 
 static int host1x_save_context(struct nvhost_channel *ch)
 {
-       struct nvhost_device *dev = ch->dev;
        struct nvhost_hwctx *hwctx_to_save;
        DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
        u32 syncpt_incrs, syncpt_val;
@@ -365,7 +364,6 @@ static int host1x_save_context(struct nvhost_channel *ch)
        void *ref;
        void *ctx_waiter = NULL, *wakeup_waiter = NULL;
        struct nvhost_job *job;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
        u32 syncpt_id;
 
        ctx_waiter = nvhost_intr_alloc_waiter();
@@ -375,9 +373,6 @@ static int host1x_save_context(struct nvhost_channel *ch)
                goto done;
        }
 
-       if (drv->busy)
-               drv->busy(dev);
-
        mutex_lock(&ch->submitlock);
        hwctx_to_save = ch->cur_ctx;
        if (!hwctx_to_save) {
@@ -458,14 +453,15 @@ static inline void __iomem *host1x_channel_aperture(void __iomem *p, int ndx)
 static inline int host1x_hwctx_handler_init(struct nvhost_channel *ch)
 {
        int err = 0;
-       unsigned long syncpts = ch->dev->syncpts;
-       unsigned long waitbases = ch->dev->waitbases;
+
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
+       unsigned long syncpts = pdata->syncpts;
+       unsigned long waitbases = pdata->waitbases;
        u32 syncpt = find_first_bit(&syncpts, BITS_PER_LONG);
        u32 waitbase = find_first_bit(&waitbases, BITS_PER_LONG);
-       struct nvhost_driver *drv = to_nvhost_driver(ch->dev->dev.driver);
 
-       if (drv->alloc_hwctx_handler) {
-               ch->ctxhandler = drv->alloc_hwctx_handler(syncpt,
+       if (pdata->alloc_hwctx_handler) {
+               ch->ctxhandler = pdata->alloc_hwctx_handler(syncpt,
                                waitbase, ch);
                if (!ch->ctxhandler)
                        err = -ENOMEM;
index 2aab4cd..09a3378 100644 (file)
@@ -271,6 +271,7 @@ static void t20_debug_show_channel_cdma(struct nvhost_master *m,
        u32 dmaput, dmaget, dmactrl;
        u32 cbstat, cbread;
        u32 val, base, baseval;
+       struct nvhost_device_data *pdata = platform_get_drvdata(channel->dev);
 
        dmaput = readl(channel->aperture + host1x_channel_dmaput_r());
        dmaget = readl(channel->aperture + host1x_channel_dmaget_r());
@@ -280,7 +281,7 @@ static void t20_debug_show_channel_cdma(struct nvhost_master *m,
 
        nvhost_debug_output(o, "%d-%s (%d): ", chid,
                            channel->dev->name,
-                           channel->dev->refcount);
+                           pdata->refcount);
 
        if (host1x_channel_dmactrl_dmastop_v(dmactrl)
                || !channel->cdma.push_buffer.mapped) {
index c73ebfd..9a08bc3 100644 (file)
@@ -45,9 +45,10 @@ static void host1x_tickctrl_deinit_host(struct nvhost_master *host)
                        regs + host1x_channel_channelctrl_r());
 }
 
-static int host1x_tickctrl_init_channel(struct nvhost_device *dev)
+static int host1x_tickctrl_init_channel(struct platform_device *dev)
 {
-       void __iomem *regs = dev->channel->aperture;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       void __iomem *regs = pdata->channel->aperture;
 
        /* Initialize counter */
        writel(0, regs + host1x_channel_stallcount_hi_r());
@@ -63,9 +64,10 @@ static int host1x_tickctrl_init_channel(struct nvhost_device *dev)
        return 0;
 }
 
-static void host1x_tickctrl_deinit_channel(struct nvhost_device *dev)
+static void host1x_tickctrl_deinit_channel(struct platform_device *dev)
 {
-       void __iomem *regs = dev->channel->aperture;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       void __iomem *regs = pdata->channel->aperture;
 
        writel(host1x_channel_stallctrl_enable_channel_stall_f(0),
                        regs + host1x_channel_stallctrl_r());
@@ -84,7 +86,7 @@ static u64 readl64(void __iomem *reg_hi, void __iomem *reg_lo)
        return ((u64)hi << 32) | (u64)lo;
 }
 
-static int host1x_tickctrl_tickcount(struct nvhost_device *dev, u64 *val)
+static int host1x_tickctrl_tickcount(struct platform_device *dev, u64 *val)
 {
        void __iomem *regs = nvhost_get_host(dev)->aperture;
 
@@ -95,9 +97,10 @@ static int host1x_tickctrl_tickcount(struct nvhost_device *dev, u64 *val)
        return 0;
 }
 
-static int host1x_tickctrl_stallcount(struct nvhost_device *dev, u64 *val)
+static int host1x_tickctrl_stallcount(struct platform_device *dev, u64 *val)
 {
-       void __iomem *regs = dev->channel->aperture;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       void __iomem *regs = pdata->channel->aperture;
 
        *val = readl64(regs + host1x_channel_stallcount_hi_r(),
                regs + host1x_channel_stallcount_lo_r());
@@ -106,9 +109,10 @@ static int host1x_tickctrl_stallcount(struct nvhost_device *dev, u64 *val)
        return 0;
 }
 
-static int host1x_tickctrl_xfercount(struct nvhost_device *dev, u64 *val)
+static int host1x_tickctrl_xfercount(struct platform_device *dev, u64 *val)
 {
-       void __iomem *regs = dev->channel->aperture;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       void __iomem *regs = pdata->channel->aperture;
 
        *val = readl64(regs + host1x_channel_xfercount_hi_r(),
                regs + host1x_channel_xfercount_lo_r());
index 2f9edaa..282834a 100644 (file)
 #include "dev.h"
 #include "bus_client.h"
 
-static int isp_probe(struct nvhost_device *dev,
-       struct nvhost_device_id *id_table)
+static int isp_probe(struct platform_device *dev)
 {
        int err = 0;
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)dev->dev.platform_data;
+
+       pdata->pdev = dev;
+       platform_set_drvdata(dev, pdata);
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
@@ -38,26 +42,26 @@ static int isp_probe(struct nvhost_device *dev,
        return nvhost_client_device_init(dev);
 }
 
-static int __exit isp_remove(struct nvhost_device *dev)
+static int __exit isp_remove(struct platform_device *dev)
 {
        /* Add clean-up */
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int isp_suspend(struct nvhost_device *dev, pm_message_t state)
+static int isp_suspend(struct platform_device *dev, pm_message_t state)
 {
        return nvhost_client_device_suspend(dev);
 }
 
-static int isp_resume(struct nvhost_device *dev)
+static int isp_resume(struct platform_device *dev)
 {
        dev_info(&dev->dev, "resuming\n");
        return 0;
 }
 #endif
 
-static struct nvhost_driver isp_driver = {
+static struct platform_driver isp_driver = {
        .probe = isp_probe,
        .remove = __exit_p(isp_remove),
 #ifdef CONFIG_PM
@@ -72,12 +76,12 @@ static struct nvhost_driver isp_driver = {
 
 static int __init isp_init(void)
 {
-       return nvhost_driver_register(&isp_driver);
+       return platform_driver_register(&isp_driver);
 }
 
 static void __exit isp_exit(void)
 {
-       nvhost_driver_unregister(&isp_driver);
+       platform_driver_unregister(&isp_driver);
 }
 
 module_init(isp_init);
index 40ad15c..d75309d 100644 (file)
@@ -605,9 +605,10 @@ fail_alloc:
        return NULL;
 }
 
-int nvhost_mpe_prepare_power_off(struct nvhost_device *dev)
+int nvhost_mpe_prepare_power_off(struct platform_device *dev)
 {
-       return nvhost_channel_save_context(dev->channel);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       return nvhost_channel_save_context(pdata->channel);
 }
 
 enum mpe_ip_ver {
@@ -616,7 +617,7 @@ enum mpe_ip_ver {
 };
 
 struct mpe_desc {
-       int (*prepare_poweroff)(struct nvhost_device *dev);
+       int (*prepare_poweroff)(struct platform_device *dev);
        struct nvhost_hwctx_handler *(*alloc_hwctx_handler)(u32 syncpt,
                        u32 waitbase, struct nvhost_channel *ch);
 };
@@ -632,25 +633,33 @@ static const struct mpe_desc mpe[] = {
        },
 };
 
-static struct nvhost_device_id mpe_id[] = {
-       { "mpe", mpe_01 },
-       { "mpe", mpe_02 },
+static struct platform_device_id mpe_id[] = {
+       { "mpe01", mpe_01 },
+       { "mpe02", mpe_02 },
        { },
 };
 
 MODULE_DEVICE_TABLE(nvhost, mpe_id);
 
-static int mpe_probe(struct nvhost_device *dev,
-       struct nvhost_device_id *id_table)
+static int mpe_probe(struct platform_device *dev)
 {
        int err = 0;
        int index = 0;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)dev->dev.platform_data;
 
-       index = id_table->version;
+       /* HACK: reset device name */
+       dev_set_name(&dev->dev, "%s", "mpe");
 
-       drv->prepare_poweroff           = mpe[index].prepare_poweroff;
-       drv->alloc_hwctx_handler        = mpe[index].alloc_hwctx_handler;
+       pdata->pdev = dev;
+
+       index = (int)(platform_get_device_id(dev)->driver_data);
+       BUG_ON(index > mpe_02);
+
+       pdata->prepare_poweroff         = mpe[index].prepare_poweroff;
+       pdata->alloc_hwctx_handler      = mpe[index].alloc_hwctx_handler;
+
+       platform_set_drvdata(dev, pdata);
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
@@ -659,26 +668,26 @@ static int mpe_probe(struct nvhost_device *dev,
        return nvhost_client_device_init(dev);
 }
 
-static int __exit mpe_remove(struct nvhost_device *dev)
+static int __exit mpe_remove(struct platform_device *dev)
 {
        /* Add clean-up */
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int mpe_suspend(struct nvhost_device *dev, pm_message_t state)
+static int mpe_suspend(struct platform_device *dev, pm_message_t state)
 {
        return nvhost_client_device_suspend(dev);
 }
 
-static int mpe_resume(struct nvhost_device *dev)
+static int mpe_resume(struct platform_device *dev)
 {
        dev_info(&dev->dev, "resuming\n");
        return 0;
 }
 #endif
 
-static struct nvhost_driver mpe_driver = {
+static struct platform_driver mpe_driver = {
        .probe = mpe_probe,
        .remove = __exit_p(mpe_remove),
 #ifdef CONFIG_PM
@@ -694,12 +703,12 @@ static struct nvhost_driver mpe_driver = {
 
 static int __init mpe_init(void)
 {
-       return nvhost_driver_register(&mpe_driver);
+       return platform_driver_register(&mpe_driver);
 }
 
 static void __exit mpe_exit(void)
 {
-       nvhost_driver_unregister(&mpe_driver);
+       platform_driver_unregister(&mpe_driver);
 }
 
 module_init(mpe_init);
index 094d019..d85cb85 100644 (file)
 #define set_msenc(ndev, f) ((ndev)->dev.platform_data = f)
 
 /* caller is responsible for freeing */
-static char *msenc_get_fw_name(struct nvhost_device *dev)
+static char *msenc_get_fw_name(struct platform_device *dev)
 {
        char *fw_name;
        u8 maj, min;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       /*note size here is a little over...*/
+       /* note size here is a little over...*/
        fw_name = kzalloc(32, GFP_KERNEL);
        if (!fw_name)
                return NULL;
 
-       decode_msenc_ver(dev->version, &maj, &min);
+       decode_msenc_ver(pdata->version, &maj, &min);
        if (maj == 2) {
                /* there are no minor versions so far for maj==2 */
                sprintf(fw_name, "nvhost_msenc02.fw");
@@ -63,7 +64,7 @@ static char *msenc_get_fw_name(struct nvhost_device *dev)
        return fw_name;
 }
 
-static int msenc_dma_wait_idle(struct nvhost_device *dev, u32 *timeout)
+static int msenc_dma_wait_idle(struct platform_device *dev, u32 *timeout)
 {
        if (!*timeout)
                *timeout = MSENC_IDLE_TIMEOUT_DEFAULT;
@@ -85,7 +86,7 @@ static int msenc_dma_wait_idle(struct nvhost_device *dev, u32 *timeout)
        return -1;
 }
 
-static int msenc_dma_pa_to_internal_256b(struct nvhost_device *dev,
+static int msenc_dma_pa_to_internal_256b(struct platform_device *dev,
                u32 offset, u32 internal_offset, bool imem)
 {
        u32 cmd = msenc_dmatrfcmd_size_256b_f();
@@ -104,7 +105,7 @@ static int msenc_dma_pa_to_internal_256b(struct nvhost_device *dev,
 
 }
 
-static int msenc_wait_idle(struct nvhost_device *dev, u32 *timeout)
+static int msenc_wait_idle(struct platform_device *dev, u32 *timeout)
 {
        if (!*timeout)
                *timeout = MSENC_IDLE_TIMEOUT_DEFAULT;
@@ -122,7 +123,7 @@ static int msenc_wait_idle(struct nvhost_device *dev, u32 *timeout)
        return -1;
 }
 
-int msenc_boot(struct nvhost_device *dev)
+int msenc_boot(struct platform_device *dev)
 {
        u32 timeout;
        u32 offset;
@@ -174,7 +175,7 @@ int msenc_boot(struct nvhost_device *dev)
        return 0;
 }
 
-static int msenc_setup_ucode_image(struct nvhost_device *dev,
+static int msenc_setup_ucode_image(struct platform_device *dev,
                u32 *ucode_ptr,
                const struct firmware *ucode_fw)
 {
@@ -240,7 +241,7 @@ static int msenc_setup_ucode_image(struct nvhost_device *dev,
        return 0;
 }
 
-int msenc_read_ucode(struct nvhost_device *dev, const char *fw_name)
+int msenc_read_ucode(struct platform_device *dev, const char *fw_name)
 {
        struct msenc *m = get_msenc(dev);
        const struct firmware *ucode_fw;
@@ -303,7 +304,7 @@ clean_up:
        return err;
 }
 
-void nvhost_msenc_init(struct nvhost_device *dev)
+void nvhost_msenc_init(struct platform_device *dev)
 {
        int err = 0;
        struct msenc *m;
@@ -339,7 +340,7 @@ void nvhost_msenc_init(struct nvhost_device *dev)
        mem_op().unpin(nvhost_get_host(dev)->memmgr, m->mem_r, m->pa);
 }
 
-void nvhost_msenc_deinit(struct nvhost_device *dev)
+void nvhost_msenc_deinit(struct platform_device *dev)
 {
        struct msenc *m = get_msenc(dev);
 
@@ -351,20 +352,23 @@ void nvhost_msenc_deinit(struct nvhost_device *dev)
        }
 }
 
-void nvhost_msenc_finalize_poweron(struct nvhost_device *dev)
+void nvhost_msenc_finalize_poweron(struct platform_device *dev)
 {
        msenc_boot(dev);
 }
 
-static int msenc_probe(struct nvhost_device *dev,
-               struct nvhost_device_id *id_table)
+static int msenc_probe(struct platform_device *dev)
 {
        int err = 0;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)dev->dev.platform_data;
 
-       drv->init = nvhost_msenc_init;
-       drv->deinit = nvhost_msenc_deinit;
-       drv->finalize_poweron = nvhost_msenc_finalize_poweron;
+       pdata->pdev = dev;
+       pdata->init = nvhost_msenc_init;
+       pdata->deinit = nvhost_msenc_deinit;
+       pdata->finalize_poweron = nvhost_msenc_finalize_poweron;
+
+       platform_set_drvdata(dev, pdata);
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
@@ -373,26 +377,26 @@ static int msenc_probe(struct nvhost_device *dev,
        return nvhost_client_device_init(dev);
 }
 
-static int __exit msenc_remove(struct nvhost_device *dev)
+static int __exit msenc_remove(struct platform_device *dev)
 {
        /* Add clean-up */
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int msenc_suspend(struct nvhost_device *dev, pm_message_t state)
+static int msenc_suspend(struct platform_device *dev, pm_message_t state)
 {
        return nvhost_client_device_suspend(dev);
 }
 
-static int msenc_resume(struct nvhost_device *dev)
+static int msenc_resume(struct platform_device *dev)
 {
        dev_info(&dev->dev, "resuming\n");
        return 0;
 }
 #endif
 
-static struct nvhost_driver msenc_driver = {
+static struct platform_driver msenc_driver = {
        .probe = msenc_probe,
        .remove = __exit_p(msenc_remove),
 #ifdef CONFIG_PM
@@ -407,12 +411,12 @@ static struct nvhost_driver msenc_driver = {
 
 static int __init msenc_init(void)
 {
-       return nvhost_driver_register(&msenc_driver);
+       return platform_driver_register(&msenc_driver);
 }
 
 static void __exit msenc_exit(void)
 {
-       nvhost_driver_unregister(&msenc_driver);
+       platform_driver_unregister(&msenc_driver);
 }
 
 module_init(msenc_init);
index 7025e96..24a1dda 100644 (file)
 struct mem_handle;
 struct sg_table;
 
-void nvhost_msenc_finalize_poweron(struct nvhost_device *dev);
-void nvhost_msenc_init(struct nvhost_device *dev);
-void nvhost_msenc_deinit(struct nvhost_device *dev);
+void nvhost_msenc_finalize_poweron(struct platform_device *dev);
+void nvhost_msenc_init(struct platform_device *dev);
+void nvhost_msenc_deinit(struct platform_device *dev);
 
 /* Would have preferred a static inline here... but we're using this
  * in a place where a constant initializer is required */
-#define NVHOST_ENCODE_MSENC_VER(maj,min) ( (((maj)&0xff)<<8) | ((min)&0xff) )
+#define NVHOST_ENCODE_MSENC_VER(maj, min) \
+       ((((maj) & 0xff) << 8) | ((min) & 0xff))
 
 static inline void decode_msenc_ver(int version, u8 *maj, u8 *min)
 {
@@ -58,9 +59,9 @@ struct msenc {
 };
 
 struct msenc_ucode_bin_header_v1 {
-       u32 bin_magic;        /* 0x10de */
-       u32 bin_ver;          /* cya, versioning of bin format (1) */
-       u32 bin_size;         /* entire image size including this header */
+       u32 bin_magic;          /* 0x10de */
+       u32 bin_ver;            /* cya, versioning of bin format (1) */
+       u32 bin_size;           /* entire image size including this header */
        u32 os_bin_header_offset;
        u32 os_bin_data_offset;
        u32 os_bin_size;
index 95c6299..08730e7 100644 (file)
@@ -59,185 +59,194 @@ static void do_unpowergate_locked(int id)
                tegra_unpowergate_partition(id);
 }
 
-static void do_module_reset_locked(struct nvhost_device *dev)
+static void do_module_reset_locked(struct platform_device *dev)
 {
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+
        /* assert module and mc client reset */
-       if (dev->powergate_ids[0] != -1) {
-               tegra_powergate_mc_disable(dev->powergate_ids[0]);
-               tegra_periph_reset_assert(dev->clk[0]);
-               tegra_powergate_mc_flush(dev->powergate_ids[0]);
+       if (pdata->powergate_ids[0] != -1) {
+               tegra_powergate_mc_disable(pdata->powergate_ids[0]);
+               tegra_periph_reset_assert(pdata->clk[0]);
+               tegra_powergate_mc_flush(pdata->powergate_ids[0]);
        }
-       if (dev->powergate_ids[1] != -1) {
-               tegra_powergate_mc_disable(dev->powergate_ids[1]);
-               tegra_periph_reset_assert(dev->clk[1]);
-               tegra_powergate_mc_flush(dev->powergate_ids[1]);
+       if (pdata->powergate_ids[1] != -1) {
+               tegra_powergate_mc_disable(pdata->powergate_ids[1]);
+               tegra_periph_reset_assert(pdata->clk[1]);
+               tegra_powergate_mc_flush(pdata->powergate_ids[1]);
        }
 
        udelay(POWERGATE_DELAY);
 
        /* deassert reset */
-       if (dev->powergate_ids[0] != -1) {
-               tegra_powergate_mc_flush_done(dev->powergate_ids[0]);
-               tegra_periph_reset_deassert(dev->clk[0]);
-               tegra_powergate_mc_enable(dev->powergate_ids[0]);
+       if (pdata->powergate_ids[0] != -1) {
+               tegra_powergate_mc_flush_done(pdata->powergate_ids[0]);
+               tegra_periph_reset_deassert(pdata->clk[0]);
+               tegra_powergate_mc_enable(pdata->powergate_ids[0]);
        }
-       if (dev->powergate_ids[1] != -1) {
-               tegra_powergate_mc_flush_done(dev->powergate_ids[1]);
-               tegra_periph_reset_deassert(dev->clk[1]);
-               tegra_powergate_mc_enable(dev->powergate_ids[1]);
+       if (pdata->powergate_ids[1] != -1) {
+               tegra_powergate_mc_flush_done(pdata->powergate_ids[1]);
+               tegra_periph_reset_deassert(pdata->clk[1]);
+               tegra_powergate_mc_enable(pdata->powergate_ids[1]);
        }
 }
 
-void nvhost_module_reset(struct nvhost_device *dev)
+void nvhost_module_reset(struct platform_device *dev)
 {
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+
        dev_dbg(&dev->dev,
                "%s: asserting %s module reset (id %d, id2 %d)\n",
-               __func__, dev->name,
-               dev->powergate_ids[0], dev->powergate_ids[1]);
+               __func__, dev_name(&dev->dev),
+               pdata->powergate_ids[0], pdata->powergate_ids[1]);
 
-       mutex_lock(&dev->lock);
+       mutex_lock(&pdata->lock);
        do_module_reset_locked(dev);
-       mutex_unlock(&dev->lock);
+       mutex_unlock(&pdata->lock);
 
        dev_dbg(&dev->dev, "%s: module %s out of reset\n",
-               __func__, dev->name);
+               __func__, dev_name(&dev->dev));
 }
 
-static void to_state_clockgated_locked(struct nvhost_device *dev)
+static void to_state_clockgated_locked(struct platform_device *dev)
 {
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       if (dev->powerstate == NVHOST_POWER_STATE_RUNNING) {
+       if (pdata->powerstate == NVHOST_POWER_STATE_RUNNING) {
                int i, err;
-               if (drv->prepare_clockoff) {
-                       err = drv->prepare_clockoff(dev);
+               if (pdata->prepare_clockoff) {
+                       err = pdata->prepare_clockoff(dev);
                        if (err) {
                                dev_err(&dev->dev, "error clock gating");
                                return;
                        }
                }
-               for (i = 0; i < dev->num_clks; i++)
-                       clk_disable_unprepare(dev->clk[i]);
+
+               for (i = 0; i < pdata->num_clks; i++)
+                       clk_disable_unprepare(pdata->clk[i]);
+
                if (dev->dev.parent)
-                       nvhost_module_idle(to_nvhost_device(dev->dev.parent));
-       } else if (dev->powerstate == NVHOST_POWER_STATE_POWERGATED
-                       && dev->can_powergate) {
-               do_unpowergate_locked(dev->powergate_ids[0]);
-               do_unpowergate_locked(dev->powergate_ids[1]);
+                       nvhost_module_idle(to_platform_device(dev->dev.parent));
+       } else if (pdata->powerstate == NVHOST_POWER_STATE_POWERGATED
+                       && pdata->can_powergate) {
+               do_unpowergate_locked(pdata->powergate_ids[0]);
+               do_unpowergate_locked(pdata->powergate_ids[1]);
 
-               if (dev->powerup_reset)
+               if (pdata->powerup_reset)
                        do_module_reset_locked(dev);
        }
-       dev->powerstate = NVHOST_POWER_STATE_CLOCKGATED;
+       pdata->powerstate = NVHOST_POWER_STATE_CLOCKGATED;
 }
 
-static void to_state_running_locked(struct nvhost_device *dev)
+static void to_state_running_locked(struct platform_device *dev)
 {
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
-       int prev_state = dev->powerstate;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       int prev_state = pdata->powerstate;
 
-       if (dev->powerstate == NVHOST_POWER_STATE_POWERGATED)
+       if (pdata->powerstate == NVHOST_POWER_STATE_POWERGATED)
                to_state_clockgated_locked(dev);
 
-       if (dev->powerstate == NVHOST_POWER_STATE_CLOCKGATED) {
+       if (pdata->powerstate == NVHOST_POWER_STATE_CLOCKGATED) {
                int i;
 
                if (dev->dev.parent)
-                       nvhost_module_busy(to_nvhost_device(dev->dev.parent));
+                       nvhost_module_busy(to_platform_device(dev->dev.parent));
 
-               for (i = 0; i < dev->num_clks; i++) {
-                       int err = clk_prepare_enable(dev->clk[i]);
+               for (i = 0; i < pdata->num_clks; i++) {
+                       int err = clk_prepare_enable(pdata->clk[i]);
                        if (err) {
                                dev_err(&dev->dev, "Cannot turn on clock %s",
-                                       dev->clocks[i].name);
+                                       pdata->clocks[i].name);
                                return;
                        }
                }
 
-               /* Invoke callback. This is used for re-enabling host1x
-                * interrupts. */
-               if (drv->finalize_clockon)
-                       drv->finalize_clockon(dev);
+               if (pdata->finalize_clockon)
+                       pdata->finalize_clockon(dev);
 
                /* Invoke callback after power un-gating. This is used for
                 * restoring context. */
                if (prev_state == NVHOST_POWER_STATE_POWERGATED
-                               && drv->finalize_poweron)
-                       drv->finalize_poweron(dev);
+                               && pdata->finalize_poweron)
+                       pdata->finalize_poweron(dev);
        }
-       dev->powerstate = NVHOST_POWER_STATE_RUNNING;
+       pdata->powerstate = NVHOST_POWER_STATE_RUNNING;
 }
 
 /* This gets called from powergate_handler() and from module suspend.
  * Module suspend is done for all modules, runtime power gating only
  * for modules with can_powergate set.
  */
-static int to_state_powergated_locked(struct nvhost_device *dev)
+static int to_state_powergated_locked(struct platform_device *dev)
 {
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
        int err = 0;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
 
-       if (drv->prepare_poweroff
-                       && dev->powerstate != NVHOST_POWER_STATE_POWERGATED) {
+       if (pdata->prepare_poweroff &&
+               pdata->powerstate != NVHOST_POWER_STATE_POWERGATED) {
                /* Clock needs to be on in prepare_poweroff */
                to_state_running_locked(dev);
-               err = drv->prepare_poweroff(dev);
+               err = pdata->prepare_poweroff(dev);
                if (err)
                        return err;
        }
 
-       if (dev->powerstate == NVHOST_POWER_STATE_RUNNING)
+       if (pdata->powerstate == NVHOST_POWER_STATE_RUNNING)
                to_state_clockgated_locked(dev);
 
-       if (dev->can_powergate) {
-               do_powergate_locked(dev->powergate_ids[0]);
-               do_powergate_locked(dev->powergate_ids[1]);
+       if (pdata->can_powergate) {
+               do_powergate_locked(pdata->powergate_ids[0]);
+               do_powergate_locked(pdata->powergate_ids[1]);
        }
 
-       dev->powerstate = NVHOST_POWER_STATE_POWERGATED;
+       pdata->powerstate = NVHOST_POWER_STATE_POWERGATED;
        return 0;
 }
 
-static void schedule_powergating_locked(struct nvhost_device *dev)
+static void schedule_powergating_locked(struct platform_device *dev)
 {
-       if (dev->can_powergate)
-               schedule_delayed_work(&dev->powerstate_down,
-                               msecs_to_jiffies(dev->powergate_delay));
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       if (pdata->can_powergate)
+               schedule_delayed_work(&pdata->powerstate_down,
+                               msecs_to_jiffies(pdata->powergate_delay));
 }
 
-static void schedule_clockgating_locked(struct nvhost_device *dev)
+static void schedule_clockgating_locked(struct platform_device *dev)
 {
-       schedule_delayed_work(&dev->powerstate_down,
-                       msecs_to_jiffies(dev->clockgate_delay));
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       schedule_delayed_work(&pdata->powerstate_down,
+                       msecs_to_jiffies(pdata->clockgate_delay));
 }
 
-void nvhost_module_busy(struct nvhost_device *dev)
+void nvhost_module_busy(struct platform_device *dev)
 {
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       if (drv->busy)
-               drv->busy(dev);
+       if (pdata->busy)
+               pdata->busy(dev);
 
-       mutex_lock(&dev->lock);
-       cancel_delayed_work(&dev->powerstate_down);
+       mutex_lock(&pdata->lock);
+       cancel_delayed_work(&pdata->powerstate_down);
 
-       dev->refcount++;
-       if (dev->refcount > 0 && !nvhost_module_powered(dev))
+       pdata->refcount++;
+       if (pdata->refcount > 0 && !nvhost_module_powered(dev))
                to_state_running_locked(dev);
-       mutex_unlock(&dev->lock);
+       mutex_unlock(&pdata->lock);
 }
 
 static void powerstate_down_handler(struct work_struct *work)
 {
-       struct nvhost_device *dev;
+       struct platform_device *dev;
+       struct nvhost_device_data *pdata;
 
-       dev = container_of(to_delayed_work(work),
-                       struct nvhost_device,
+       pdata = container_of(to_delayed_work(work),
+                       struct nvhost_device_data,
                        powerstate_down);
 
-       mutex_lock(&dev->lock);
-       if (dev->refcount == 0) {
-               switch (dev->powerstate) {
+       dev = pdata->pdev;
+
+       mutex_lock(&pdata->lock);
+       if (pdata->refcount == 0) {
+               switch (pdata->powerstate) {
                case NVHOST_POWER_STATE_RUNNING:
                        to_state_clockgated_locked(dev);
                        schedule_powergating_locked(dev);
@@ -250,37 +259,38 @@ static void powerstate_down_handler(struct work_struct *work)
                        break;
                }
        }
-       mutex_unlock(&dev->lock);
+       mutex_unlock(&pdata->lock);
 }
 
-void nvhost_module_idle_mult(struct nvhost_device *dev, int refs)
+void nvhost_module_idle_mult(struct platform_device *dev, int refs)
 {
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
        bool kick = false;
 
-       mutex_lock(&dev->lock);
-       dev->refcount -= refs;
-       if (dev->refcount == 0) {
+       mutex_lock(&pdata->lock);
+       pdata->refcount -= refs;
+       if (pdata->refcount == 0) {
                if (nvhost_module_powered(dev))
                        schedule_clockgating_locked(dev);
                kick = true;
        }
-       mutex_unlock(&dev->lock);
+       mutex_unlock(&pdata->lock);
 
        if (kick) {
-               wake_up(&dev->idle_wq);
+               wake_up(&pdata->idle_wq);
 
-               if (drv->idle)
-                       drv->idle(dev);
+               if (pdata->idle)
+                       pdata->idle(dev);
        }
 }
 
-int nvhost_module_get_rate(struct nvhost_device *dev, unsigned long *rate,
+int nvhost_module_get_rate(struct platform_device *dev, unsigned long *rate,
                int index)
 {
        struct clk *c;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       c = dev->clk[index];
+       c = pdata->clk[index];
        if (IS_ERR_OR_NULL(c))
                return -EINVAL;
 
@@ -292,22 +302,23 @@ int nvhost_module_get_rate(struct nvhost_device *dev, unsigned long *rate,
 
 }
 
-static int nvhost_module_update_rate(struct nvhost_device *dev, int index)
+static int nvhost_module_update_rate(struct platform_device *dev, int index)
 {
        unsigned long rate = 0;
        struct nvhost_module_client *m;
        unsigned long devfreq_rate, default_rate;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       if (!dev->clk[index])
+       if (!pdata->clk[index])
                return -EINVAL;
 
        /* If devfreq is on, use that clock rate, otherwise default */
-       devfreq_rate = dev->clocks[index].devfreq_rate;
+       devfreq_rate = pdata->clocks[index].devfreq_rate;
        default_rate = devfreq_rate ?
-               devfreq_rate : dev->clocks[index].default_rate;
-       default_rate = clk_round_rate(dev->clk[index], default_rate);
+               devfreq_rate : pdata->clocks[index].default_rate;
+       default_rate = clk_round_rate(pdata->clk[index], default_rate);
 
-       list_for_each_entry(m, &dev->client_list, node) {
+       list_for_each_entry(m, &pdata->client_list, node) {
                unsigned long r = m->rate[index];
                if (!r)
                        r = default_rate;
@@ -317,21 +328,23 @@ static int nvhost_module_update_rate(struct nvhost_device *dev, int index)
                rate = default_rate;
 
        trace_nvhost_module_update_rate(dev->name,
-                       dev->clocks[index].name, rate);
+                       pdata->clocks[index].name, rate);
 
-       return clk_set_rate(dev->clk[index], rate);
+       return clk_set_rate(pdata->clk[index], rate);
 }
 
-int nvhost_module_set_rate(struct nvhost_device *dev, void *priv,
+int nvhost_module_set_rate(struct platform_device *dev, void *priv,
                unsigned long rate, int index)
 {
        struct nvhost_module_client *m;
        int ret = 0;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        mutex_lock(&client_list_lock);
-       list_for_each_entry(m, &dev->client_list, node) {
+       list_for_each_entry(m, &pdata->client_list, node) {
                if (m->priv == priv)
-                       m->rate[index] = clk_round_rate(dev->clk[index], rate);
+                       m->rate[index] =
+                               clk_round_rate(pdata->clk[index], rate);
        }
 
        ret = nvhost_module_update_rate(dev, index);
@@ -340,9 +353,10 @@ int nvhost_module_set_rate(struct nvhost_device *dev, void *priv,
 
 }
 
-int nvhost_module_add_client(struct nvhost_device *dev, void *priv)
+int nvhost_module_add_client(struct platform_device *dev, void *priv)
 {
        struct nvhost_module_client *client;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        client = kzalloc(sizeof(*client), GFP_KERNEL);
        if (!client)
@@ -352,19 +366,21 @@ int nvhost_module_add_client(struct nvhost_device *dev, void *priv)
        client->priv = priv;
 
        mutex_lock(&client_list_lock);
-       list_add_tail(&client->node, &dev->client_list);
+       list_add_tail(&client->node, &pdata->client_list);
        mutex_unlock(&client_list_lock);
+
        return 0;
 }
 
-void nvhost_module_remove_client(struct nvhost_device *dev, void *priv)
+void nvhost_module_remove_client(struct platform_device *dev, void *priv)
 {
        int i;
        struct nvhost_module_client *m;
        int found = 0;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        mutex_lock(&client_list_lock);
-       list_for_each_entry(m, &dev->client_list, node) {
+       list_for_each_entry(m, &pdata->client_list, node) {
                if (priv == m->priv) {
                        list_del(&m->node);
                        found = 1;
@@ -373,7 +389,7 @@ void nvhost_module_remove_client(struct nvhost_device *dev, void *priv)
        }
        if (found) {
                kfree(m);
-               for (i = 0; i < dev->num_clks; i++)
+               for (i = 0; i < pdata->num_clks; i++)
                        nvhost_module_update_rate(dev, i);
        }
        mutex_unlock(&client_list_lock);
@@ -386,11 +402,12 @@ static ssize_t refcount_show(struct kobject *kobj,
        struct nvhost_device_power_attr *power_attribute =
                container_of(attr, struct nvhost_device_power_attr, \
                        power_attr[NVHOST_POWER_SYSFS_ATTRIB_REFCOUNT]);
-       struct nvhost_device *dev = power_attribute->ndev;
+       struct platform_device *dev = power_attribute->ndev;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       mutex_lock(&dev->lock);
-       ret = sprintf(buf, "%d\n", dev->refcount);
-       mutex_unlock(&dev->lock);
+       mutex_lock(&pdata->lock);
+       ret = sprintf(buf, "%d\n", pdata->refcount);
+       mutex_unlock(&pdata->lock);
 
        return ret;
 }
@@ -402,20 +419,21 @@ static ssize_t powergate_delay_store(struct kobject *kobj,
        struct nvhost_device_power_attr *power_attribute =
                container_of(attr, struct nvhost_device_power_attr, \
                        power_attr[NVHOST_POWER_SYSFS_ATTRIB_POWERGATE_DELAY]);
-       struct nvhost_device *dev = power_attribute->ndev;
+       struct platform_device *dev = power_attribute->ndev;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       if (!dev->can_powergate) {
+       if (!pdata->can_powergate) {
                dev_info(&dev->dev, "does not support power-gating\n");
                return count;
        }
 
-       mutex_lock(&dev->lock);
+       mutex_lock(&pdata->lock);
        ret = sscanf(buf, "%d", &powergate_delay);
        if (ret == 1 && powergate_delay >= 0)
-               dev->powergate_delay = powergate_delay;
+               pdata->powergate_delay = powergate_delay;
        else
                dev_err(&dev->dev, "Invalid powergate delay\n");
-       mutex_unlock(&dev->lock);
+       mutex_unlock(&pdata->lock);
 
        return count;
 }
@@ -427,11 +445,12 @@ static ssize_t powergate_delay_show(struct kobject *kobj,
        struct nvhost_device_power_attr *power_attribute =
                container_of(attr, struct nvhost_device_power_attr, \
                        power_attr[NVHOST_POWER_SYSFS_ATTRIB_POWERGATE_DELAY]);
-       struct nvhost_device *dev = power_attribute->ndev;
+       struct platform_device *dev = power_attribute->ndev;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       mutex_lock(&dev->lock);
-       ret = sprintf(buf, "%d\n", dev->powergate_delay);
-       mutex_unlock(&dev->lock);
+       mutex_lock(&pdata->lock);
+       ret = sprintf(buf, "%d\n", pdata->powergate_delay);
+       mutex_unlock(&pdata->lock);
 
        return ret;
 }
@@ -443,15 +462,16 @@ static ssize_t clockgate_delay_store(struct kobject *kobj,
        struct nvhost_device_power_attr *power_attribute =
                container_of(attr, struct nvhost_device_power_attr, \
                        power_attr[NVHOST_POWER_SYSFS_ATTRIB_CLOCKGATE_DELAY]);
-       struct nvhost_device *dev = power_attribute->ndev;
+       struct platform_device *dev = power_attribute->ndev;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       mutex_lock(&dev->lock);
+       mutex_lock(&pdata->lock);
        ret = sscanf(buf, "%d", &clockgate_delay);
        if (ret == 1 && clockgate_delay >= 0)
-               dev->clockgate_delay = clockgate_delay;
+               pdata->clockgate_delay = clockgate_delay;
        else
                dev_err(&dev->dev, "Invalid clockgate delay\n");
-       mutex_unlock(&dev->lock);
+       mutex_unlock(&pdata->lock);
 
        return count;
 }
@@ -463,43 +483,49 @@ static ssize_t clockgate_delay_show(struct kobject *kobj,
        struct nvhost_device_power_attr *power_attribute =
                container_of(attr, struct nvhost_device_power_attr, \
                        power_attr[NVHOST_POWER_SYSFS_ATTRIB_CLOCKGATE_DELAY]);
-       struct nvhost_device *dev = power_attribute->ndev;
+       struct platform_device *dev = power_attribute->ndev;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       mutex_lock(&dev->lock);
-       ret = sprintf(buf, "%d\n", dev->clockgate_delay);
-       mutex_unlock(&dev->lock);
+       mutex_lock(&pdata->lock);
+       ret = sprintf(buf, "%d\n", pdata->clockgate_delay);
+       mutex_unlock(&pdata->lock);
 
        return ret;
 }
 
-int nvhost_module_set_devfreq_rate(struct nvhost_device *dev, int index,
+int nvhost_module_set_devfreq_rate(struct platform_device *dev, int index,
                unsigned long rate)
 {
-       rate = clk_round_rate(dev->clk[index], rate);
-       dev->clocks[index].devfreq_rate = rate;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+
+       rate = clk_round_rate(pdata->clk[index], rate);
+       pdata->clocks[index].devfreq_rate = rate;
 
        trace_nvhost_module_set_devfreq_rate(dev->name,
-                       dev->clocks[index].name, rate);
+                       pdata->clocks[index].name, rate);
+
        return nvhost_module_update_rate(dev, index);
 }
 
-int nvhost_module_init(struct nvhost_device *dev)
+int nvhost_module_init(struct platform_device *dev)
 {
        int i = 0, err = 0;
        struct kobj_attribute *attr = NULL;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        /* initialize clocks to known state */
-       INIT_LIST_HEAD(&dev->client_list);
-       while (dev->clocks[i].name && i < NVHOST_MODULE_MAX_CLOCKS) {
+       INIT_LIST_HEAD(&pdata->client_list);
+       while (pdata->clocks[i].name && i < NVHOST_MODULE_MAX_CLOCKS) {
                char devname[MAX_DEVID_LENGTH];
-               long rate = dev->clocks[i].default_rate;
+               long rate = pdata->clocks[i].default_rate;
                struct clk *c;
 
-               snprintf(devname, MAX_DEVID_LENGTH, "tegra_%s", dev->name);
-               c = clk_get_sys(devname, dev->clocks[i].name);
+               snprintf(devname, MAX_DEVID_LENGTH, "tegra_%s",
+                       dev_name(&dev->dev));
+               c = clk_get_sys(devname, pdata->clocks[i].name);
                if (IS_ERR_OR_NULL(c)) {
                        dev_err(&dev->dev, "Cannot get clock %s\n",
-                                       dev->clocks[i].name);
+                                       pdata->clocks[i].name);
                        continue;
                }
 
@@ -507,69 +533,69 @@ int nvhost_module_init(struct nvhost_device *dev)
                clk_prepare_enable(c);
                clk_set_rate(c, rate);
                clk_disable_unprepare(c);
-               dev->clk[i] = c;
+               pdata->clk[i] = c;
                i++;
        }
-       dev->num_clks = i;
+       pdata->num_clks = i;
 
-       mutex_init(&dev->lock);
-       init_waitqueue_head(&dev->idle_wq);
-       INIT_DELAYED_WORK(&dev->powerstate_down, powerstate_down_handler);
+       mutex_init(&pdata->lock);
+       init_waitqueue_head(&pdata->idle_wq);
+       INIT_DELAYED_WORK(&pdata->powerstate_down, powerstate_down_handler);
 
        /* power gate units that we can power gate */
-       if (dev->can_powergate) {
-               do_powergate_locked(dev->powergate_ids[0]);
-               do_powergate_locked(dev->powergate_ids[1]);
-               dev->powerstate = NVHOST_POWER_STATE_POWERGATED;
+       if (pdata->can_powergate) {
+               do_powergate_locked(pdata->powergate_ids[0]);
+               do_powergate_locked(pdata->powergate_ids[1]);
+               pdata->powerstate = NVHOST_POWER_STATE_POWERGATED;
        } else {
-               do_unpowergate_locked(dev->powergate_ids[0]);
-               do_unpowergate_locked(dev->powergate_ids[1]);
-               dev->powerstate = NVHOST_POWER_STATE_CLOCKGATED;
+               do_unpowergate_locked(pdata->powergate_ids[0]);
+               do_unpowergate_locked(pdata->powergate_ids[1]);
+               pdata->powerstate = NVHOST_POWER_STATE_CLOCKGATED;
        }
 
        /* Init the power sysfs attributes for this device */
-       dev->power_attrib = kzalloc(sizeof(struct nvhost_device_power_attr),
+       pdata->power_attrib = kzalloc(sizeof(struct nvhost_device_power_attr),
                GFP_KERNEL);
-       if (!dev->power_attrib) {
+       if (!pdata->power_attrib) {
                dev_err(&dev->dev, "Unable to allocate sysfs attributes\n");
                return -ENOMEM;
        }
-       dev->power_attrib->ndev = dev;
+       pdata->power_attrib->ndev = dev;
 
-       dev->power_kobj = kobject_create_and_add("acm", &dev->dev.kobj);
-       if (!dev->power_kobj) {
+       pdata->power_kobj = kobject_create_and_add("acm", &dev->dev.kobj);
+       if (!pdata->power_kobj) {
                dev_err(&dev->dev, "Could not add dir 'power'\n");
                err = -EIO;
                goto fail_attrib_alloc;
        }
 
-       attr = &dev->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_CLOCKGATE_DELAY];
+       attr = &pdata->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_CLOCKGATE_DELAY];
        attr->attr.name = "clockgate_delay";
        attr->attr.mode = S_IWUSR | S_IRUGO;
        attr->show = clockgate_delay_show;
        attr->store = clockgate_delay_store;
-       if (sysfs_create_file(dev->power_kobj, &attr->attr)) {
+       if (sysfs_create_file(pdata->power_kobj, &attr->attr)) {
                dev_err(&dev->dev, "Could not create sysfs attribute clockgate_delay\n");
                err = -EIO;
                goto fail_clockdelay;
        }
 
-       attr = &dev->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_POWERGATE_DELAY];
+       attr = &pdata->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_POWERGATE_DELAY];
        attr->attr.name = "powergate_delay";
        attr->attr.mode = S_IWUSR | S_IRUGO;
        attr->show = powergate_delay_show;
        attr->store = powergate_delay_store;
-       if (sysfs_create_file(dev->power_kobj, &attr->attr)) {
+       if (sysfs_create_file(pdata->power_kobj, &attr->attr)) {
                dev_err(&dev->dev, "Could not create sysfs attribute powergate_delay\n");
                err = -EIO;
                goto fail_powergatedelay;
        }
 
-       attr = &dev->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_REFCOUNT];
+       attr = &pdata->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_REFCOUNT];
        attr->attr.name = "refcount";
        attr->attr.mode = S_IRUGO;
        attr->show = refcount_show;
-       if (sysfs_create_file(dev->power_kobj, &attr->attr)) {
+       if (sysfs_create_file(pdata->power_kobj, &attr->attr)) {
                dev_err(&dev->dev, "Could not create sysfs attribute refcount\n");
                err = -EIO;
                goto fail_refcount;
@@ -578,81 +604,105 @@ int nvhost_module_init(struct nvhost_device *dev)
        return 0;
 
 fail_refcount:
-       attr = &dev->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_POWERGATE_DELAY];
-       sysfs_remove_file(dev->power_kobj, &attr->attr);
+       attr = &pdata->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_POWERGATE_DELAY];
+       sysfs_remove_file(pdata->power_kobj, &attr->attr);
 
 fail_powergatedelay:
-       attr = &dev->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_CLOCKGATE_DELAY];
-       sysfs_remove_file(dev->power_kobj, &attr->attr);
+       attr = &pdata->power_attrib->power_attr[NVHOST_POWER_SYSFS_ATTRIB_CLOCKGATE_DELAY];
+       sysfs_remove_file(pdata->power_kobj, &attr->attr);
 
 fail_clockdelay:
-       kobject_put(dev->power_kobj);
+       kobject_put(pdata->power_kobj);
 
 fail_attrib_alloc:
-       kfree(dev->power_attrib);
+       kfree(pdata->power_attrib);
 
        return err;
 }
 
-static int is_module_idle(struct nvhost_device *dev)
+static int is_module_idle(struct platform_device *dev)
 {
        int count;
-       mutex_lock(&dev->lock);
-       count = dev->refcount;
-       mutex_unlock(&dev->lock);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+
+       mutex_lock(&pdata->lock);
+       count = pdata->refcount;
+       mutex_unlock(&pdata->lock);
+
        return (count == 0);
 }
 
-int nvhost_module_suspend(struct nvhost_device *dev)
+int nvhost_module_suspend(struct platform_device *dev)
 {
        int ret;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       ret = wait_event_timeout(dev->idle_wq, is_module_idle(dev),
+       ret = wait_event_timeout(pdata->idle_wq, is_module_idle(dev),
                        ACM_SUSPEND_WAIT_FOR_IDLE_TIMEOUT);
        if (ret == 0) {
                dev_info(&dev->dev, "%s prevented suspend\n",
-                               dev->name);
+                               dev_name(&dev->dev));
                return -EBUSY;
        }
 
-       mutex_lock(&dev->lock);
-       cancel_delayed_work(&dev->powerstate_down);
+       mutex_lock(&pdata->lock);
+       cancel_delayed_work(&pdata->powerstate_down);
        to_state_powergated_locked(dev);
-       mutex_unlock(&dev->lock);
+       mutex_unlock(&pdata->lock);
 
-       if (drv->suspend_ndev)
-               drv->suspend_ndev(dev);
+       if (pdata->suspend_ndev)
+               pdata->suspend_ndev(dev);
 
        return 0;
 }
 
-void nvhost_module_deinit(struct nvhost_device *dev)
+void nvhost_module_deinit(struct platform_device *dev)
 {
        int i;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       if (drv->deinit)
-               drv->deinit(dev);
+       if (pdata->deinit)
+               pdata->deinit(dev);
 
        nvhost_module_suspend(dev);
-       for (i = 0; i < dev->num_clks; i++)
-               clk_put(dev->clk[i]);
-       dev->powerstate = NVHOST_POWER_STATE_DEINIT;
+       for (i = 0; i < pdata->num_clks; i++)
+               clk_put(pdata->clk[i]);
+       pdata->powerstate = NVHOST_POWER_STATE_DEINIT;
 }
 
 /* public host1x power management APIs */
-bool nvhost_module_powered_ext(struct nvhost_device *dev)
+bool nvhost_module_powered_ext(struct platform_device *dev)
 {
-       return nvhost_module_powered(dev);
+       struct platform_device *pdev;
+
+       BUG_ON(!dev->dev.parent);
+
+       /* get the parent */
+       pdev = to_platform_device(dev->dev.parent);
+
+       return nvhost_module_powered(pdev);
 }
 
-void nvhost_module_busy_ext(struct nvhost_device *dev)
+void nvhost_module_busy_ext(struct platform_device *dev)
 {
-       nvhost_module_busy(dev);
+       struct platform_device *pdev;
+
+       BUG_ON(!dev->dev.parent);
+
+       /* get the parent */
+       pdev = to_platform_device(dev->dev.parent);
+
+       nvhost_module_busy(pdev);
 }
 
-void nvhost_module_idle_ext(struct nvhost_device *dev)
+void nvhost_module_idle_ext(struct platform_device *dev)
 {
-       nvhost_module_idle(dev);
+       struct platform_device *pdev;
+
+       BUG_ON(!dev->dev.parent);
+
+       /* get the parent */
+       pdev = to_platform_device(dev->dev.parent);
+
+       nvhost_module_idle(pdev);
 }
index 2c012e1..cdd1ab1 100644 (file)
 #include <linux/nvhost.h>
 
 /* Sets clocks and powergating state for a module */
-int nvhost_module_init(struct nvhost_device *ndev);
-void nvhost_module_deinit(struct nvhost_device *dev);
-int nvhost_module_suspend(struct nvhost_device *dev);
+int nvhost_module_init(struct platform_device *ndev);
+void nvhost_module_deinit(struct platform_device *dev);
+int nvhost_module_suspend(struct platform_device *dev);
 
-void nvhost_module_reset(struct nvhost_device *dev);
-void nvhost_module_busy(struct nvhost_device *dev);
-void nvhost_module_idle_mult(struct nvhost_device *dev, int refs);
-int nvhost_module_add_client(struct nvhost_device *dev,
+void nvhost_module_reset(struct platform_device *dev);
+void nvhost_module_busy(struct platform_device *dev);
+void nvhost_module_idle_mult(struct platform_device *dev, int refs);
+int nvhost_module_add_client(struct platform_device *dev,
                void *priv);
-void nvhost_module_remove_client(struct nvhost_device *dev,
+void nvhost_module_remove_client(struct platform_device *dev,
                void *priv);
-int nvhost_module_get_rate(struct nvhost_device *dev,
+int nvhost_module_get_rate(struct platform_device *dev,
                unsigned long *rate,
                int index);
-int nvhost_module_set_rate(struct nvhost_device *dev, void *priv,
+int nvhost_module_set_rate(struct platform_device *dev, void *priv,
                unsigned long rate, int index);
-int nvhost_module_set_devfreq_rate(struct nvhost_device *dev, int index,
+int nvhost_module_set_devfreq_rate(struct platform_device *dev, int index,
                unsigned long rate);
 
-static inline bool nvhost_module_powered(struct nvhost_device *dev)
+static inline bool nvhost_module_powered(struct platform_device *dev)
 {
-       return dev->powerstate == NVHOST_POWER_STATE_RUNNING;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       return pdata->powerstate == NVHOST_POWER_STATE_RUNNING;
 }
 
-static inline void nvhost_module_idle(struct nvhost_device *dev)
+static inline void nvhost_module_idle(struct platform_device *dev)
 {
        nvhost_module_idle_mult(dev, 1);
 }
index b4c0e47..1a8d2aa 100644 (file)
@@ -242,12 +242,13 @@ static void update_cdma_locked(struct nvhost_cdma *cdma)
 }
 
 void nvhost_cdma_update_sync_queue(struct nvhost_cdma *cdma,
-               struct nvhost_syncpt *syncpt, struct nvhost_device *dev)
+               struct nvhost_syncpt *syncpt, struct platform_device *dev)
 {
        u32 get_restart;
        u32 syncpt_incrs;
        struct nvhost_job *job = NULL;
        u32 syncpt_val;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
        syncpt_val = nvhost_syncpt_update_min(syncpt, cdma->timeout.syncpt_id);
 
@@ -317,7 +318,7 @@ void nvhost_cdma_update_sync_queue(struct nvhost_cdma *cdma,
                                syncpt_incrs,
                                job->syncpt_end,
                                job->num_slots,
-                               dev->waitbases);
+                               pdata->waitbases);
 
                syncpt_val += syncpt_incrs;
        }
index 35b4702..3543705 100644 (file)
@@ -119,5 +119,5 @@ void        nvhost_cdma_peek(struct nvhost_cdma *cdma,
 unsigned int nvhost_cdma_wait_locked(struct nvhost_cdma *cdma,
                enum cdma_event event);
 void nvhost_cdma_update_sync_queue(struct nvhost_cdma *cdma,
-               struct nvhost_syncpt *syncpt, struct nvhost_device *dev);
+               struct nvhost_syncpt *syncpt, struct platform_device *dev);
 #endif
index 626b929..556231d 100644 (file)
@@ -34,17 +34,16 @@ int nvhost_channel_init(struct nvhost_channel *ch,
                struct nvhost_master *dev, int index)
 {
        int err;
-       struct nvhost_device *ndev;
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
 
-       /* Link nvhost_device to nvhost_channel */
+       /* Link platform_device to nvhost_channel */
        err = channel_op().init(ch, dev, index);
        if (err < 0) {
                dev_err(&dev->dev->dev, "failed to init channel %d\n",
                                index);
                return err;
        }
-       ndev = ch->dev;
-       ndev->channel = ch;
+       pdata->channel = ch;
 
        return 0;
 }
@@ -80,14 +79,14 @@ int nvhost_channel_submit(struct nvhost_job *job)
 struct nvhost_channel *nvhost_getchannel(struct nvhost_channel *ch)
 {
        int err = 0;
-       struct nvhost_driver *drv = to_nvhost_driver(ch->dev->dev.driver);
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
 
        mutex_lock(&ch->reflock);
        if (ch->refcount == 0) {
-               if (drv->init)
-                       drv->init(ch->dev);
+               if (pdata->init)
+                       pdata->init(ch->dev);
                err = nvhost_cdma_init(&ch->cdma);
-       } else if (ch->dev->exclusive) {
+       } else if (pdata->exclusive) {
                err = -EBUSY;
        }
        if (!err)
@@ -96,7 +95,7 @@ struct nvhost_channel *nvhost_getchannel(struct nvhost_channel *ch)
        mutex_unlock(&ch->reflock);
 
        /* Keep alive modules that needs to be when a channel is open */
-       if (!err && ch->dev->keepalive)
+       if (!err && pdata->keepalive)
                nvhost_module_busy(ch->dev);
 
        return err ? NULL : ch;
@@ -104,6 +103,7 @@ struct nvhost_channel *nvhost_getchannel(struct nvhost_channel *ch)
 
 void nvhost_putchannel(struct nvhost_channel *ch, struct nvhost_hwctx *ctx)
 {
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
        BUG_ON(!channel_cdma_op().stop);
 
        if (ctx) {
@@ -114,7 +114,7 @@ void nvhost_putchannel(struct nvhost_channel *ch, struct nvhost_hwctx *ctx)
        }
 
        /* Allow keep-alive'd module to be turned off */
-       if (ch->dev->keepalive)
+       if (pdata->keepalive)
                nvhost_module_idle(ch->dev);
 
        mutex_lock(&ch->reflock);
@@ -185,15 +185,15 @@ int nvhost_channel_read_reg(struct nvhost_channel *ch,
        struct nvhost_hwctx *hwctx,
        u32 offset, u32 *value)
 {
-       struct nvhost_driver *drv = to_nvhost_driver(ch->dev->dev.driver);
-       if (!drv->read_reg)
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
+       if (!pdata->read_reg)
                return -EINVAL;
 
-       return drv->read_reg(ch->dev, ch, hwctx, offset, value);
+       return pdata->read_reg(ch->dev, ch, hwctx, offset, value);
 }
 
 int nvhost_channel_drain_read_fifo(struct nvhost_channel *ch,
-                       u32 *ptr, unsigned int count, unsigned int *pending)
+       u32 *ptr, unsigned int count, unsigned int *pending)
 {
        return channel_op().drain_read_fifo(ch, ptr, count, pending);
 }
index c7c8a71..3aedaef 100644 (file)
@@ -31,7 +31,7 @@
 #define NVHOST_MAX_POWERGATE_IDS       2
 
 struct nvhost_master;
-struct nvhost_device;
+struct platform_device;
 struct nvhost_channel;
 struct nvhost_hwctx;
 
@@ -44,7 +44,7 @@ struct nvhost_channel {
        void __iomem *aperture;
        struct nvhost_hwctx *cur_ctx;
        struct device *node;
-       struct nvhost_device *dev;
+       struct platform_device *dev;
        struct cdev cdev;
        struct nvhost_hwctx_handler *ctxhandler;
        struct nvhost_cdma cdma;
index c727ab0..1c633a8 100644 (file)
@@ -99,7 +99,7 @@ struct mem_handle *nvhost_memmgr_alloc(struct mem_mgr *mgr,
 }
 
 struct mem_handle *nvhost_memmgr_get(struct mem_mgr *mgr,
-               u32 id, struct nvhost_device *dev)
+               u32 id, struct platform_device *dev)
 {
        struct mem_handle *h = NULL;
 
@@ -254,7 +254,7 @@ void nvhost_memmgr_kunmap(struct mem_handle *handle, unsigned int pagenum,
 }
 
 int nvhost_memmgr_pin_array_ids(struct mem_mgr *mgr,
-               struct nvhost_device *dev,
+               struct platform_device *dev,
                long unsigned *ids,
                dma_addr_t *phys_addr,
                u32 count,
index 281ae4f..579213b 100644 (file)
@@ -24,7 +24,7 @@
 struct nvhost_chip_support;
 struct mem_mgr;
 struct mem_handle;
-struct nvhost_device;
+struct platform_device;
 
 struct nvhost_job_unpin {
        struct mem_handle *h;
@@ -53,12 +53,12 @@ struct mem_handle *nvhost_memmgr_alloc(struct mem_mgr *,
                size_t size, size_t align,
                int flags);
 struct mem_handle *nvhost_memmgr_get(struct mem_mgr *,
-               u32 id, struct nvhost_device *dev);
+               u32 id, struct platform_device *dev);
 static inline int nvhost_memmgr_type(u32 id) { return id & MEMMGR_TYPE_MASK; }
 static inline int nvhost_memmgr_id(u32 id) { return id & MEMMGR_ID_MASK; }
 
 int nvhost_memmgr_pin_array_ids(struct mem_mgr *mgr,
-               struct nvhost_device *dev,
+               struct platform_device *dev,
                long unsigned *ids,
                dma_addr_t *phys_addr,
                u32 count,
index 840f524..ea449ed 100644 (file)
@@ -28,7 +28,8 @@
 #include "dev.h"
 #include "chip_support.h"
 
-#define MAX_SYNCPT_LENGTH 5
+#define MAX_SYNCPT_LENGTH      5
+
 /* Name of sysfs node for min and max value */
 static const char *min_name = "min";
 static const char *max_name = "max";
@@ -361,7 +362,7 @@ static ssize_t syncpt_max_show(struct kobject *kobj,
                                syncpt_attr->id));
 }
 
-int nvhost_syncpt_init(struct nvhost_device *dev,
+int nvhost_syncpt_init(struct platform_device *dev,
                struct nvhost_syncpt *sp)
 {
        int i;
@@ -483,27 +484,59 @@ int nvhost_syncpt_nb_mlocks(struct nvhost_syncpt *sp)
 }
 
 /* public sync point API */
-u32 nvhost_syncpt_incr_max_ext(struct nvhost_device *dev, u32 id, u32 incrs)
+u32 nvhost_syncpt_incr_max_ext(struct platform_device *dev, u32 id, u32 incrs)
 {
-       struct nvhost_syncpt *sp = &(nvhost_get_host(dev)->syncpt);
+       struct platform_device *pdev;
+       struct nvhost_syncpt *sp;
+
+       BUG_ON(!dev->dev.parent);
+
+       /* get the parent */
+       pdev = to_platform_device(dev->dev.parent);
+       sp = &(nvhost_get_host(pdev)->syncpt);
+
        return nvhost_syncpt_incr_max(sp, id, incrs);
 }
 
-void nvhost_syncpt_cpu_incr_ext(struct nvhost_device *dev, u32 id)
+void nvhost_syncpt_cpu_incr_ext(struct platform_device *dev, u32 id)
 {
-       struct nvhost_syncpt *sp = &(nvhost_get_host(dev)->syncpt);
+       struct platform_device *pdev;
+       struct nvhost_syncpt *sp;
+
+       BUG_ON(!dev->dev.parent);
+
+       /* get the parent */
+       pdev = to_platform_device(dev->dev.parent);
+       sp = &(nvhost_get_host(pdev)->syncpt);
+
        nvhost_syncpt_cpu_incr(sp, id);
 }
 
-u32 nvhost_syncpt_read_ext(struct nvhost_device *dev, u32 id)
+u32 nvhost_syncpt_read_ext(struct platform_device *dev, u32 id)
 {
-       struct nvhost_syncpt *sp = &(nvhost_get_host(dev)->syncpt);
+       struct platform_device *pdev;
+       struct nvhost_syncpt *sp;
+
+       BUG_ON(!dev->dev.parent);
+
+       /* get the parent */
+       pdev = to_platform_device(dev->dev.parent);
+       sp = &(nvhost_get_host(pdev)->syncpt);
+
        return nvhost_syncpt_read(sp, id);
 }
 
-int nvhost_syncpt_wait_timeout_ext(struct nvhost_device *dev, u32 id, u32 thresh,
-       u32 timeout, u32 *value)
+int nvhost_syncpt_wait_timeout_ext(struct platform_device *dev, u32 id,
+       u32 thresh, u32 timeout, u32 *value)
 {
-       struct nvhost_syncpt *sp = &(nvhost_get_host(dev)->syncpt);
+       struct platform_device *pdev;
+       struct nvhost_syncpt *sp;
+
+       BUG_ON(!dev->dev.parent);
+
+       /* get the parent */
+       pdev = to_platform_device(dev->dev.parent);
+       sp = &(nvhost_get_host(pdev)->syncpt);
+
        return nvhost_syncpt_wait_timeout(sp, id, thresh, timeout, value);
 }
index 9ee4f3a..20e4a7e 100644 (file)
@@ -46,7 +46,7 @@ struct nvhost_syncpt {
        struct nvhost_syncpt_attr *syncpt_attrs;
 };
 
-int nvhost_syncpt_init(struct nvhost_device *, struct nvhost_syncpt *);
+int nvhost_syncpt_init(struct platform_device *, struct nvhost_syncpt *);
 void nvhost_syncpt_deinit(struct nvhost_syncpt *);
 
 #define syncpt_to_dev(sp) container_of(sp, struct nvhost_master, syncpt)
index f8fc8cb..0a42164 100644 (file)
@@ -161,7 +161,7 @@ fail:
 }
 
 struct mem_handle *nvhost_nvmap_get(struct mem_mgr *mgr,
-               u32 id, struct nvhost_device *dev)
+               u32 id, struct platform_device *dev)
 {
        return (struct mem_handle *)
                _nvmap_duplicate_handle_id((struct nvmap_client *)mgr, id);
index 2172f4f..d4b1e43 100644 (file)
@@ -24,7 +24,7 @@
 #include "nvhost_memmgr.h"
 
 struct nvhost_chip_support;
-struct nvhost_device;
+struct platform_device;
 struct sg_table;
 
 struct mem_mgr *nvhost_nvmap_alloc_mgr(void);
@@ -44,7 +44,7 @@ void *nvhost_nvmap_kmap(struct mem_handle *handle, unsigned int pagenum);
 void nvhost_nvmap_kunmap(struct mem_handle *handle, unsigned int pagenum,
                void *addr);
 struct mem_handle *nvhost_nvmap_get(struct mem_mgr *mgr,
-               u32 id, struct nvhost_device *dev);
+               u32 id, struct platform_device *dev);
 
 phys_addr_t nvhost_nvmap_get_addr_from_id(u32 id);
 
index 3eeb93c..57dcc2f 100644 (file)
 #include <linux/mutex.h>
 #include <linux/kernel.h>
 #include <linux/nvhost_ioctl.h>
+
 #include <mach/powergate.h>
 #include <mach/iomap.h>
+
 #include "t20/t20.h"
 #include "t30/t30.h"
 #include "t114.h"
 #include "gr3d/pod_scaling.h"
 #include "class_ids.h"
 
-#define NVMODMUTEX_2D_FULL   (1)
-#define NVMODMUTEX_2D_SIMPLE (2)
-#define NVMODMUTEX_2D_SB_A   (3)
-#define NVMODMUTEX_2D_SB_B   (4)
-#define NVMODMUTEX_3D        (5)
-#define NVMODMUTEX_DISPLAYA  (6)
-#define NVMODMUTEX_DISPLAYB  (7)
-#define NVMODMUTEX_VI        (8)
-#define NVMODMUTEX_DSI       (9)
+#define NVMODMUTEX_2D_FULL     (1)
+#define NVMODMUTEX_2D_SIMPLE   (2)
+#define NVMODMUTEX_2D_SB_A     (3)
+#define NVMODMUTEX_2D_SB_B     (4)
+#define NVMODMUTEX_3D          (5)
+#define NVMODMUTEX_DISPLAYA    (6)
+#define NVMODMUTEX_DISPLAYB    (7)
+#define NVMODMUTEX_VI          (8)
+#define NVMODMUTEX_DSI         (9)
 
 static int t114_num_alloc_channels = 0;
 
@@ -96,54 +98,69 @@ static struct host1x_device_info host1x02_info = {
        .client_managed = NVSYNCPTS_CLIENT_MANAGED,
 };
 
-static struct nvhost_device tegra_host1x02_device = {
-       .dev            = {.platform_data = &host1x02_info},
+static struct nvhost_device_data tegra_host1x02_info = {
+       .clocks         = { {"host1x", 102000000} },
+       NVHOST_MODULE_NO_POWERGATE_IDS,
+};
+
+static struct platform_device tegra_host1x02_device = {
        .name           = "host1x",
        .id             = -1,
        .resource       = tegra_host1x02_resources,
        .num_resources  = ARRAY_SIZE(tegra_host1x02_resources),
-       .clocks         = {{"host1x", 102000000}, {} },
-       NVHOST_MODULE_NO_POWERGATE_IDS,
+       .dev            = {
+               .platform_data = &tegra_host1x02_info,
+       },
 };
 
-static struct nvhost_device tegra_gr3d03_device = {
-       .name          = "gr3d",
-       .version       = 3,
-       .id            = -1,
-       .index         = 1,
-       .syncpts       = BIT(NVSYNCPT_3D),
-       .waitbases     = BIT(NVWAITBASE_3D),
-       .modulemutexes = BIT(NVMODMUTEX_3D),
-       .class         = NV_GRAPHICS_3D_CLASS_ID,
-       .clocks = {{"gr3d", UINT_MAX, 8},
-                       {"emc", UINT_MAX, 75} },
-       .powergate_ids = { TEGRA_POWERGATE_3D, -1 },
+static struct nvhost_device_data tegra_gr3d03_info = {
+       .version        = 3,
+       .index          = 1,
+       .syncpts        = BIT(NVSYNCPT_3D),
+       .waitbases      = BIT(NVWAITBASE_3D),
+       .modulemutexes  = BIT(NVMODMUTEX_3D),
+       .class          = NV_GRAPHICS_3D_CLASS_ID,
+       .clocks         = { {"gr3d", UINT_MAX, 8}, {"emc", UINT_MAX, 75} },
+       .powergate_ids  = { TEGRA_POWERGATE_3D, -1 },
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
-       .can_powergate = true,
+       .can_powergate  = true,
        .powergate_delay = 250,
-       .moduleid      = NVHOST_MODULE_NONE,
+       .moduleid       = NVHOST_MODULE_NONE,
 };
 
-static struct nvhost_device tegra_gr2d03_device = {
-       .name          = "gr2d",
-       .version       = 2,
-       .id            = -1,
-       .index         = 2,
-       .syncpts       = BIT(NVSYNCPT_2D_0) | BIT(NVSYNCPT_2D_1),
-       .waitbases     = BIT(NVWAITBASE_2D_0) | BIT(NVWAITBASE_2D_1),
-       .modulemutexes = BIT(NVMODMUTEX_2D_FULL) | BIT(NVMODMUTEX_2D_SIMPLE) |
-                        BIT(NVMODMUTEX_2D_SB_A) | BIT(NVMODMUTEX_2D_SB_B),
-       .clocks        = { {"gr2d", 0, 7},
-                       {"epp", 0, 10},
-                       {"emc", 300000000, 75 } },
-       .powergate_ids = { TEGRA_POWERGATE_HEG, -1 },
+static struct platform_device tegra_gr3d03_device = {
+       .name           = "gr3d03",
+       .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_gr3d03_info,
+       },
+};
+
+static struct nvhost_device_data tegra_gr2d03_info = {
+       .version        = 2,
+       .index          = 2,
+       .syncpts        = BIT(NVSYNCPT_2D_0) | BIT(NVSYNCPT_2D_1),
+       .waitbases      = BIT(NVWAITBASE_2D_0) | BIT(NVWAITBASE_2D_1),
+       .modulemutexes  = BIT(NVMODMUTEX_2D_FULL) | BIT(NVMODMUTEX_2D_SIMPLE) |
+                         BIT(NVMODMUTEX_2D_SB_A) | BIT(NVMODMUTEX_2D_SB_B),
+       .clocks         = { {"gr2d", 0, 7}, {"epp", 0, 10},
+                           {"emc", 300000000, 75 } },
+       .powergate_ids  = { TEGRA_POWERGATE_HEG, -1 },
        .clockgate_delay = 0,
-       .can_powergate  = false,
+       .can_powergate  = false,
        .powergate_delay = 100,
        .moduleid       = NVHOST_MODULE_NONE,
        .serialize      = true,
 };
 
+static struct platform_device tegra_gr2d03_device = {
+       .name           = "gr2d02",
+       .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_gr2d03_info,
+       },
+};
+
 static struct resource isp_resources[] = {
        {
                .name = "regs",
@@ -153,21 +170,27 @@ static struct resource isp_resources[] = {
        }
 };
 
-static struct nvhost_device tegra_isp01_device = {
-       .name           = "isp",
-       .id             = -1,
-       .resource       = isp_resources,
-       .num_resources  = ARRAY_SIZE(isp_resources),
+static struct nvhost_device_data tegra_isp01_info = {
        .index          = 3,
        .syncpts        = BIT(NVSYNCPT_VI_ISP_2) | BIT(NVSYNCPT_VI_ISP_3) |
                          BIT(NVSYNCPT_VI_ISP_4),
-       .clocks         = { {"epp", 0, 10} },
+       .clocks         = { {"epp", 0} },
        .keepalive      = true,
        NVHOST_MODULE_NO_POWERGATE_IDS,
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .moduleid       = NVHOST_MODULE_ISP,
 };
 
+static struct platform_device tegra_isp01_device = {
+       .name           = "isp",
+       .id             = -1,
+       .resource       = isp_resources,
+       .num_resources  = ARRAY_SIZE(isp_resources),
+       .dev            = {
+               .platform_data = &tegra_isp01_info,
+       },
+};
+
 static struct resource vi_resources[] = {
        {
                .name = "regs",
@@ -177,21 +200,27 @@ static struct resource vi_resources[] = {
        },
 };
 
-static struct nvhost_device tegra_vi01_device = {
-       .name          = "vi",
-       .resource      = vi_resources,
-       .num_resources = ARRAY_SIZE(vi_resources),
-       .id            = -1,
-       .index         = 4,
-       .syncpts       = BIT(NVSYNCPT_CSI_VI_0) | BIT(NVSYNCPT_CSI_VI_1) |
-                        BIT(NVSYNCPT_VI_ISP_0) | BIT(NVSYNCPT_VI_ISP_1) |
-                        BIT(NVSYNCPT_VI_ISP_2) | BIT(NVSYNCPT_VI_ISP_3) |
-                        BIT(NVSYNCPT_VI_ISP_4),
-       .modulemutexes = BIT(NVMODMUTEX_VI),
-       .exclusive     = true,
+static struct nvhost_device_data tegra_vi01_info = {
+       .index          = 4,
+       .syncpts        = BIT(NVSYNCPT_CSI_VI_0) | BIT(NVSYNCPT_CSI_VI_1) |
+                         BIT(NVSYNCPT_VI_ISP_0) | BIT(NVSYNCPT_VI_ISP_1) |
+                         BIT(NVSYNCPT_VI_ISP_2) | BIT(NVSYNCPT_VI_ISP_3) |
+                         BIT(NVSYNCPT_VI_ISP_4),
+       .modulemutexes  = BIT(NVMODMUTEX_VI),
+       .exclusive      = true,
        NVHOST_MODULE_NO_POWERGATE_IDS,
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
-       .moduleid      = NVHOST_MODULE_VI,
+       .moduleid       = NVHOST_MODULE_VI,
+};
+
+static struct platform_device tegra_vi01_device = {
+       .name           = "vi",
+       .resource       = vi_resources,
+       .num_resources  = ARRAY_SIZE(vi_resources),
+       .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_vi01_info,
+       },
 };
 
 static struct resource msenc_resources[] = {
@@ -203,23 +232,28 @@ static struct resource msenc_resources[] = {
        },
 };
 
-static struct nvhost_device tegra_msenc02_device = {
-       .name          = "msenc",
-       .version       = NVHOST_ENCODE_MSENC_VER(2, 0),
-       .id            = -1,
-       .resource      = msenc_resources,
-       .num_resources = ARRAY_SIZE(msenc_resources),
-       .index         = 5,
-       .syncpts       = BIT(NVSYNCPT_MSENC),
-       .waitbases     = BIT(NVWAITBASE_MSENC),
-       .class         = NV_VIDEO_ENCODE_MSENC_CLASS_ID,
-       .clocks        = { {"msenc", UINT_MAX, 107},
-                       {"emc", 300000000, 75} },
+static struct nvhost_device_data tegra_msenc02_info = {
+       .version        = NVHOST_ENCODE_MSENC_VER(2, 0),
+       .index          = 5,
+       .syncpts        = BIT(NVSYNCPT_MSENC),
+       .waitbases      = BIT(NVWAITBASE_MSENC),
+       .class          = NV_VIDEO_ENCODE_MSENC_CLASS_ID,
+       .clocks        = { {"msenc", UINT_MAX, 107}, {"emc", 300000000, 75} },
        .powergate_ids = { TEGRA_POWERGATE_MPE, -1 },
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .powergate_delay = 100,
        .can_powergate = true,
-       .moduleid      = NVHOST_MODULE_MSENC,
+       .moduleid       = NVHOST_MODULE_MSENC,
+};
+
+static struct platform_device tegra_msenc02_device = {
+       .name           = "msenc",
+       .id             = -1,
+       .resource       = msenc_resources,
+       .num_resources  = ARRAY_SIZE(msenc_resources),
+       .dev            = {
+               .platform_data = &tegra_msenc02_info,
+       },
 };
 
 static struct resource tsec_resources[] = {
@@ -231,27 +265,30 @@ static struct resource tsec_resources[] = {
        },
 };
 
-static struct nvhost_device tegra_tsec01_device = {
-       /* channel 7 */
-       .name          = "tsec",
-       .version       = NVHOST_ENCODE_TSEC_VER(1,0),
-       .id            = -1,
-       .resource      = tsec_resources,
-       .num_resources = ARRAY_SIZE(tsec_resources),
-       .index         = 7,
-       .syncpts       = BIT(NVSYNCPT_TSEC),
-       .waitbases     = BIT(NVWAITBASE_TSEC),
-       .class         = NV_TSEC_CLASS_ID,
-       .exclusive     = false,
-       .clocks        = { {"tsec", UINT_MAX, 108},
-                       {"emc", 300000000, 75} },
+static struct nvhost_device_data tegra_tsec01_info = {
+       .version        = NVHOST_ENCODE_TSEC_VER(1, 0),
+       .index          = 7,
+       .syncpts        = BIT(NVSYNCPT_TSEC),
+       .waitbases      = BIT(NVWAITBASE_TSEC),
+       .class          = NV_TSEC_CLASS_ID,
+       .exclusive      = false,
+       .clocks        = { {"tsec", UINT_MAX, 108}, {"emc", 300000000, 75} },
        NVHOST_MODULE_NO_POWERGATE_IDS,
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
-       .moduleid      = NVHOST_MODULE_TSEC,
+       .moduleid       = NVHOST_MODULE_TSEC,
+};
+
+static struct platform_device tegra_tsec01_device = {
+       .name           = "tsec",
+       .id             = -1,
+       .resource       = tsec_resources,
+       .num_resources  = ARRAY_SIZE(tsec_resources),
+       .dev            = {
+               .platform_data = &tegra_tsec01_info,
+       },
 };
 
-static struct nvhost_device *t11_devices[] = {
-       &tegra_host1x02_device,
+static struct platform_device *t11_devices[] = {
        &tegra_gr3d03_device,
        &tegra_gr2d03_device,
        &tegra_isp01_device,
@@ -260,9 +297,33 @@ static struct nvhost_device *t11_devices[] = {
        &tegra_tsec01_device,
 };
 
-int tegra11_register_host1x_devices(void)
+struct platform_device *tegra11_register_host1x_devices(void)
 {
-       return nvhost_add_devices(t11_devices, ARRAY_SIZE(t11_devices));
+       int index = 0;
+       struct platform_device *pdev;
+
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)tegra_host1x02_device.dev.platform_data;
+       pdata->private_data = &host1x02_info;
+
+       /* register host1x device first */
+       platform_device_register(&tegra_host1x02_device);
+       tegra_host1x02_device.dev.parent = NULL;
+
+       /* register clients with host1x device as parent */
+       for (index = 0; index < ARRAY_SIZE(t11_devices); index++) {
+               pdev = t11_devices[index];
+               pdev->dev.parent = &tegra_host1x02_device.dev;
+               if (pdev == &tegra_gr3d03_device) {
+                       const char *real_name = pdev->name;
+                       pdev->name = "gr3d";
+                       platform_device_register(pdev);
+                       pdev->name = real_name;
+               } else
+                       platform_device_register(pdev);
+       }
+
+       return &tegra_host1x02_device;
 }
 
 static void t114_free_nvhost_channel(struct nvhost_channel *ch)
@@ -271,9 +332,10 @@ static void t114_free_nvhost_channel(struct nvhost_channel *ch)
 }
 
 static struct nvhost_channel *t114_alloc_nvhost_channel(
-               struct nvhost_device *dev)
+       struct platform_device *dev)
 {
-       return nvhost_alloc_channel_internal(dev->index,
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       return nvhost_alloc_channel_internal(pdata->index,
                nvhost_get_host(dev)->info.nb_channels,
                &t114_num_alloc_channels);
 }
index 3a9eceb..3b91bf1 100644 (file)
 
 #include <linux/init.h>
 #include <linux/nvhost_ioctl.h>
+
 #include <mach/powergate.h>
 #include <mach/iomap.h>
+
 #include "t20.h"
 #include "gr3d/gr3d_t20.h"
 #include "mpe/mpe.h"
@@ -89,20 +91,23 @@ static struct host1x_device_info host1x01_info = {
        .client_managed = NVSYNCPTS_CLIENT_MANAGED,
 };
 
-static struct nvhost_device tegra_host1x01_device = {
-       .dev            = {.platform_data = &host1x01_info},
+static struct nvhost_device_data tegra_host1x01_info = {
+       .clocks = { {"host1x", UINT_MAX} },
+       NVHOST_MODULE_NO_POWERGATE_IDS,
+};
+
+struct platform_device tegra_host1x01_device = {
        .name           = "host1x",
        .id             = -1,
        .resource       = tegra_host1x01_resources,
        .num_resources  = ARRAY_SIZE(tegra_host1x01_resources),
-       .clocks         = {{"host1x", UINT_MAX}, {} },
-       NVHOST_MODULE_NO_POWERGATE_IDS,
+       .dev            = {
+               .platform_data = &tegra_host1x01_info,
+       },
 };
 
-static struct nvhost_device tegra_gr3d01_device = {
-       .name           = "gr3d",
+static struct nvhost_device_data tegra_gr3d01_info = {
        .version        = 1,
-       .id             = -1,
        .index          = 1,
        .syncpts        = BIT(NVSYNCPT_3D),
        .waitbases      = BIT(NVWAITBASE_3D),
@@ -114,17 +119,22 @@ static struct nvhost_device tegra_gr3d01_device = {
        .moduleid       = NVHOST_MODULE_NONE,
 };
 
-static struct nvhost_device tegra_gr2d01_device = {
-       .name           = "gr2d",
-       .version        = 1,
+static struct platform_device tegra_gr3d01_device = {
+       .name           = "gr3d01",
        .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_gr3d01_info,
+       },
+};
+
+static struct nvhost_device_data tegra_gr2d01_info = {
+       .version        = 1,
        .index          = 2,
        .syncpts        = BIT(NVSYNCPT_2D_0) | BIT(NVSYNCPT_2D_1),
        .waitbases      = BIT(NVWAITBASE_2D_0) | BIT(NVWAITBASE_2D_1),
        .modulemutexes  = BIT(NVMODMUTEX_2D_FULL) | BIT(NVMODMUTEX_2D_SIMPLE) |
                          BIT(NVMODMUTEX_2D_SB_A) | BIT(NVMODMUTEX_2D_SB_B),
-       .clocks         = { {"gr2d", UINT_MAX},
-                           {"epp", UINT_MAX},
+       .clocks         = { {"gr2d", UINT_MAX}, {"epp", UINT_MAX},
                            {"emc", UINT_MAX} },
        NVHOST_MODULE_NO_POWERGATE_IDS,
        .clockgate_delay = 0,
@@ -132,7 +142,24 @@ static struct nvhost_device tegra_gr2d01_device = {
        .serialize      = true,
 };
 
-static struct resource isp_resources_t20[] = {
+static struct platform_device tegra_gr2d01_device = {
+       .name           = "gr2d01",
+       .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_gr2d01_info,
+       },
+};
+
+static struct resource tegra_mpe01_resources[] = {
+       {
+               .name = "regs",
+               .start = TEGRA_MPE_BASE,
+               .end = TEGRA_MPE_BASE + TEGRA_MPE_SIZE - 1,
+               .flags = IORESOURCE_MEM,
+       },
+};
+
+static struct resource isp_resources[] = {
        {
                .name = "regs",
                .start = TEGRA_ISP_BASE,
@@ -141,18 +168,25 @@ static struct resource isp_resources_t20[] = {
        }
 };
 
-static struct nvhost_device tegra_isp01_device = {
-       .name           = "isp",
-       .id             = -1,
-       .resource = isp_resources_t20,
-       .num_resources = ARRAY_SIZE(isp_resources_t20),
+static struct nvhost_device_data tegra_isp01_info = {
        .index          = 3,
        .syncpts        = 0,
+       .keepalive      = true,
        NVHOST_MODULE_NO_POWERGATE_IDS,
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .moduleid       = NVHOST_MODULE_ISP,
 };
 
+static struct platform_device tegra_isp01_device = {
+       .name           = "isp",
+       .id             = -1,
+       .resource       = isp_resources,
+       .num_resources  = ARRAY_SIZE(isp_resources),
+       .dev            = {
+               .platform_data = &tegra_isp01_info,
+       },
+};
+
 static struct resource vi_resources[] = {
        {
                .name = "regs",
@@ -162,11 +196,7 @@ static struct resource vi_resources[] = {
        },
 };
 
-static struct nvhost_device tegra_vi01_device = {
-       .name           = "vi",
-       .resource = vi_resources,
-       .num_resources = ARRAY_SIZE(vi_resources),
-       .id             = -1,
+static struct nvhost_device_data tegra_vi01_info = {
        .index          = 4,
        .syncpts        = BIT(NVSYNCPT_CSI_VI_0) | BIT(NVSYNCPT_CSI_VI_1) |
                          BIT(NVSYNCPT_VI_ISP_0) | BIT(NVSYNCPT_VI_ISP_1) |
@@ -179,21 +209,18 @@ static struct nvhost_device tegra_vi01_device = {
        .moduleid       = NVHOST_MODULE_VI,
 };
 
-static struct resource tegra_mpe01_resources[] = {
-       {
-               .name = "regs",
-               .start = TEGRA_MPE_BASE,
-               .end = TEGRA_MPE_BASE + TEGRA_MPE_SIZE - 1,
-               .flags = IORESOURCE_MEM,
+static struct platform_device tegra_vi01_device = {
+       .name           = "vi",
+       .resource       = vi_resources,
+       .num_resources  = ARRAY_SIZE(vi_resources),
+       .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_vi01_info,
        },
 };
 
-static struct nvhost_device tegra_mpe01_device = {
-       .name           = "mpe",
+static struct nvhost_device_data tegra_mpe01_info = {
        .version        = 1,
-       .id             = -1,
-       .resource       = tegra_mpe01_resources,
-       .num_resources  = ARRAY_SIZE(tegra_mpe01_resources),
        .index          = 5,
        .syncpts        = BIT(NVSYNCPT_MPE) | BIT(NVSYNCPT_MPE_EBM_EOF) |
                          BIT(NVSYNCPT_MPE_WR_SAFE),
@@ -201,15 +228,23 @@ static struct nvhost_device tegra_mpe01_device = {
        .class          = NV_VIDEO_ENCODE_MPEG_CLASS_ID,
        .waitbasesync   = true,
        .keepalive      = true,
-       .clocks         = { {"mpe", UINT_MAX},
-                           {"emc", UINT_MAX} },
+       .clocks         = { {"mpe", UINT_MAX}, {"emc", UINT_MAX} },
        .powergate_ids  = {TEGRA_POWERGATE_MPE, -1},
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .moduleid       = NVHOST_MODULE_MPE,
 };
 
-static struct nvhost_device *t20_devices[] = {
-       &tegra_host1x01_device,
+static struct platform_device tegra_mpe01_device = {
+       .name           = "mpe01",
+       .id             = -1,
+       .resource       = tegra_mpe01_resources,
+       .num_resources  = ARRAY_SIZE(tegra_mpe01_resources),
+       .dev            = {
+               .platform_data = &tegra_mpe01_info,
+       },
+};
+
+static struct platform_device *t20_devices[] = {
        &tegra_gr3d01_device,
        &tegra_gr2d01_device,
        &tegra_isp01_device,
@@ -217,9 +252,33 @@ static struct nvhost_device *t20_devices[] = {
        &tegra_mpe01_device,
 };
 
-int tegra2_register_host1x_devices(void)
+struct platform_device *tegra2_register_host1x_devices(void)
 {
-       return nvhost_add_devices(t20_devices, ARRAY_SIZE(t20_devices));
+       int index = 0;
+       struct platform_device *pdev;
+
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)tegra_host1x01_device.dev.platform_data;
+       pdata->private_data = &host1x01_info;
+
+       /* register host1x device first */
+       platform_device_register(&tegra_host1x01_device);
+       tegra_host1x01_device.dev.parent = NULL;
+
+       /* register clients with host1x device as parent */
+       for (index = 0; index < ARRAY_SIZE(t20_devices); index++) {
+               pdev = t20_devices[index];
+               pdev->dev.parent = &tegra_host1x01_device.dev;
+               if (pdev == &tegra_gr3d01_device) {
+                       const char *real_name = pdev->name;
+                       pdev->name = "gr3d";
+                       platform_device_register(pdev);
+                       pdev->name = real_name;
+               } else
+                       platform_device_register(pdev);
+       }
+
+       return &tegra_host1x01_device;
 }
 
 static void t20_free_nvhost_channel(struct nvhost_channel *ch)
@@ -227,10 +286,10 @@ static void t20_free_nvhost_channel(struct nvhost_channel *ch)
        nvhost_free_channel_internal(ch, &t20_num_alloc_channels);
 }
 
-static struct nvhost_channel *t20_alloc_nvhost_channel(
-               struct nvhost_device *dev)
+static struct nvhost_channel *t20_alloc_nvhost_channel(struct platform_device *dev)
 {
-       return nvhost_alloc_channel_internal(dev->index,
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       return nvhost_alloc_channel_internal(pdata->index,
                nvhost_get_host(dev)->info.nb_channels,
                &t20_num_alloc_channels);
 }
index d4e9ca9..2daf1fc 100644 (file)
@@ -84,7 +84,7 @@ static const char *s_syncpt_names[32] = {
        "dsi"
 };
 
-static struct host1x_device_info host1x01_info = {
+struct host1x_device_info host1x01_info = {
        .nb_channels    = 8,
        .nb_pts         = 32,
        .nb_mlocks      = 16,
@@ -93,20 +93,23 @@ static struct host1x_device_info host1x01_info = {
        .client_managed = NVSYNCPTS_CLIENT_MANAGED,
 };
 
-static struct nvhost_device tegra_host1x01_device = {
-       .dev            = {.platform_data = &host1x01_info},
+static struct nvhost_device_data tegra_host1x01_info = {
+       .clocks = { {"host1x", UINT_MAX} },
+       NVHOST_MODULE_NO_POWERGATE_IDS,
+};
+
+static struct platform_device tegra_host1x01_device = {
        .name           = "host1x",
        .id             = -1,
        .resource       = tegra_host1x01_resources,
        .num_resources  = ARRAY_SIZE(tegra_host1x01_resources),
-       .clocks         = {{"host1x", UINT_MAX}, {} },
-       NVHOST_MODULE_NO_POWERGATE_IDS,
+       .dev            = {
+               .platform_data = &tegra_host1x01_info,
+       },
 };
 
-static struct nvhost_device tegra_gr3d02_device = {
-       .name           = "gr3d",
+static struct nvhost_device_data tegra_gr3d02_info = {
        .version        = 2,
-       .id             = -1,
        .index          = 1,
        .syncpts        = BIT(NVSYNCPT_3D),
        .waitbases      = BIT(NVWAITBASE_3D),
@@ -124,10 +127,16 @@ static struct nvhost_device tegra_gr3d02_device = {
        .moduleid       = NVHOST_MODULE_NONE,
 };
 
-static struct nvhost_device tegra_gr2d02_device = {
-       .name           = "gr2d",
-       .version        = 1,
+static struct platform_device tegra_gr3d02_device = {
+       .name           = "gr3d02",
        .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_gr3d02_info,
+       },
+};
+
+static struct nvhost_device_data tegra_gr2d02_info = {
+       .version        = 1,
        .index          = 2,
        .syncpts        = BIT(NVSYNCPT_2D_0) | BIT(NVSYNCPT_2D_1),
        .waitbases      = BIT(NVWAITBASE_2D_0) | BIT(NVWAITBASE_2D_1),
@@ -142,7 +151,15 @@ static struct nvhost_device tegra_gr2d02_device = {
        .serialize      = true,
 };
 
-static struct resource isp_resources_t20[] = {
+static struct platform_device tegra_gr2d02_device = {
+       .name           = "gr2d01",
+       .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_gr2d02_info,
+       },
+};
+
+static struct resource isp_resources[] = {
        {
                .name = "regs",
                .start = TEGRA_ISP_BASE,
@@ -151,22 +168,27 @@ static struct resource isp_resources_t20[] = {
        }
 };
 
-static struct nvhost_device tegra_isp01_device = {
-       .name           = "isp",
-       .id             = -1,
-       .resource = isp_resources_t20,
-       .num_resources = ARRAY_SIZE(isp_resources_t20),
+static struct nvhost_device_data tegra_isp01_info = {
        .index          = 3,
        .syncpts        = BIT(NVSYNCPT_VI_ISP_2) | BIT(NVSYNCPT_VI_ISP_3) |
                          BIT(NVSYNCPT_VI_ISP_4),
-       .clocks         = { {"epp", 0, 10}
-                         },
+       .clocks         = { {"epp", 0, 10} },
        .keepalive      = true,
        NVHOST_MODULE_NO_POWERGATE_IDS,
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .moduleid       = NVHOST_MODULE_ISP,
 };
 
+static struct platform_device tegra_isp01_device = {
+       .name           = "isp",
+       .id             = -1,
+       .resource       = isp_resources,
+       .num_resources  = ARRAY_SIZE(isp_resources),
+       .dev            = {
+               .platform_data = &tegra_isp01_info,
+       },
+};
+
 static struct resource vi_resources[] = {
        {
                .name = "regs",
@@ -176,11 +198,7 @@ static struct resource vi_resources[] = {
        },
 };
 
-static struct nvhost_device tegra_vi01_device = {
-       .name           = "vi",
-       .resource = vi_resources,
-       .num_resources = ARRAY_SIZE(vi_resources),
-       .id             = -1,
+static struct nvhost_device_data tegra_vi01_info = {
        .index          = 4,
        .syncpts        = BIT(NVSYNCPT_CSI_VI_0) | BIT(NVSYNCPT_CSI_VI_1) |
                          BIT(NVSYNCPT_VI_ISP_0) | BIT(NVSYNCPT_VI_ISP_1) |
@@ -193,6 +211,16 @@ static struct nvhost_device tegra_vi01_device = {
        .moduleid       = NVHOST_MODULE_VI,
 };
 
+static struct platform_device tegra_vi01_device = {
+       .name           = "vi",
+       .resource       = vi_resources,
+       .num_resources  = ARRAY_SIZE(vi_resources),
+       .id             = -1,
+       .dev            = {
+               .platform_data = &tegra_vi01_info,
+       },
+};
+
 static struct resource tegra_mpe01_resources[] = {
        {
                .name = "regs",
@@ -202,12 +230,8 @@ static struct resource tegra_mpe01_resources[] = {
        },
 };
 
-static struct nvhost_device tegra_mpe02_device = {
-       .name           = "mpe",
+static struct nvhost_device_data tegra_mpe02_info = {
        .version        = 2,
-       .id             = -1,
-       .resource       = tegra_mpe01_resources,
-       .num_resources  = ARRAY_SIZE(tegra_mpe01_resources),
        .index          = 5,
        .syncpts        = BIT(NVSYNCPT_MPE) | BIT(NVSYNCPT_MPE_EBM_EOF) |
                          BIT(NVSYNCPT_MPE_WR_SAFE),
@@ -215,8 +239,7 @@ static struct nvhost_device tegra_mpe02_device = {
        .class          = NV_VIDEO_ENCODE_MPEG_CLASS_ID,
        .waitbasesync   = true,
        .keepalive      = true,
-       .clocks         = { {"mpe", UINT_MAX, 29},
-                           {"emc", 400000000, 75} },
+       .clocks         = { {"mpe", UINT_MAX, 29}, {"emc", 400000000, 75} },
        .powergate_ids  = {TEGRA_POWERGATE_MPE, -1},
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .can_powergate  = true,
@@ -224,8 +247,17 @@ static struct nvhost_device tegra_mpe02_device = {
        .moduleid       = NVHOST_MODULE_MPE,
 };
 
-static struct nvhost_device *t30_devices[] = {
-       &tegra_host1x01_device,
+static struct platform_device tegra_mpe02_device = {
+       .name           = "mpe02",
+       .id             = -1,
+       .resource       = tegra_mpe01_resources,
+       .num_resources  = ARRAY_SIZE(tegra_mpe01_resources),
+       .dev            = {
+               .platform_data = &tegra_mpe02_info,
+       },
+};
+
+static struct platform_device *t30_devices[] = {
        &tegra_gr3d02_device,
        &tegra_gr2d02_device,
        &tegra_isp01_device,
@@ -233,9 +265,33 @@ static struct nvhost_device *t30_devices[] = {
        &tegra_mpe02_device,
 };
 
-int tegra3_register_host1x_devices(void)
+struct platform_device *tegra3_register_host1x_devices(void)
 {
-       return nvhost_add_devices(t30_devices, ARRAY_SIZE(t30_devices));
+       int index = 0;
+       struct platform_device *pdev;
+
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)tegra_host1x01_device.dev.platform_data;
+       pdata->private_data = &host1x01_info;
+
+       /* register host1x device first */
+       platform_device_register(&tegra_host1x01_device);
+       tegra_host1x01_device.dev.parent = NULL;
+
+       /* register clients with host1x device as parent */
+       for (index = 0; index < ARRAY_SIZE(t30_devices); index++) {
+               pdev = t30_devices[index];
+               pdev->dev.parent = &tegra_host1x01_device.dev;
+               if (pdev == &tegra_gr3d02_device) {
+                       const char *real_name = pdev->name;
+                       pdev->name = "gr3d";
+                       platform_device_register(pdev);
+                       pdev->name = real_name;
+               } else
+                       platform_device_register(pdev);
+       }
+
+       return &tegra_host1x01_device;
 }
 
 static void t30_free_nvhost_channel(struct nvhost_channel *ch)
@@ -243,10 +299,10 @@ static void t30_free_nvhost_channel(struct nvhost_channel *ch)
        nvhost_free_channel_internal(ch, &t30_num_alloc_channels);
 }
 
-static struct nvhost_channel *t30_alloc_nvhost_channel(
-               struct nvhost_device *dev)
+static struct nvhost_channel *t30_alloc_nvhost_channel(struct platform_device *dev)
 {
-       return nvhost_alloc_channel_internal(dev->index,
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       return nvhost_alloc_channel_internal(pdata->index,
                nvhost_get_host(dev)->info.nb_channels,
                &t30_num_alloc_channels);
 }
index f87b877..c094181 100644 (file)
 static u8 otf_key[TSEC_KEY_LENGTH];
 
 /* caller is responsible for freeing */
-static char *tsec_get_fw_name(struct nvhost_device *dev)
+static char *tsec_get_fw_name(struct platform_device *dev)
 {
        char *fw_name;
        u8 maj, min;
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       /*note size here is a little over...*/
+       /* note size here is a little over...*/
        fw_name = kzalloc(32, GFP_KERNEL);
        if (!fw_name)
                return NULL;
 
-       decode_tsec_ver(dev->version, &maj, &min);
+       decode_tsec_ver(pdata->version, &maj, &min);
        if (maj == 1) {
                /* there are no minor versions so far for maj==1 */
                sprintf(fw_name, "nvhost_tsec.fw");
@@ -67,7 +68,7 @@ static char *tsec_get_fw_name(struct nvhost_device *dev)
        return fw_name;
 }
 
-static int tsec_dma_wait_idle(struct nvhost_device *dev, u32 *timeout)
+static int tsec_dma_wait_idle(struct platform_device *dev, u32 *timeout)
 {
        if (!*timeout)
                *timeout = TSEC_IDLE_TIMEOUT_DEFAULT;
@@ -89,7 +90,7 @@ static int tsec_dma_wait_idle(struct nvhost_device *dev, u32 *timeout)
        return -1;
 }
 
-static int tsec_dma_pa_to_internal_256b(struct nvhost_device *dev,
+static int tsec_dma_pa_to_internal_256b(struct platform_device *dev,
                u32 offset, u32 internal_offset, bool imem)
 {
        u32 cmd = tsec_dmatrfcmd_size_256b_f();
@@ -108,7 +109,7 @@ static int tsec_dma_pa_to_internal_256b(struct nvhost_device *dev,
 
 }
 
-static int tsec_wait_idle(struct nvhost_device *dev, u32 *timeout)
+static int tsec_wait_idle(struct platform_device *dev, u32 *timeout)
 {
        if (!*timeout)
                *timeout = TSEC_IDLE_TIMEOUT_DEFAULT;
@@ -126,7 +127,7 @@ static int tsec_wait_idle(struct nvhost_device *dev, u32 *timeout)
        return -1;
 }
 
-int tsec_boot(struct nvhost_device *dev)
+int tsec_boot(struct platform_device *dev)
 {
        u32 timeout;
        u32 offset;
@@ -178,7 +179,7 @@ int tsec_boot(struct nvhost_device *dev)
        return 0;
 }
 
-static int tsec_setup_ucode_image(struct nvhost_device *dev,
+static int tsec_setup_ucode_image(struct platform_device *dev,
                u32 *ucode_ptr,
                const struct firmware *ucode_fw)
 {
@@ -258,7 +259,7 @@ static int tsec_setup_ucode_image(struct nvhost_device *dev,
        return 0;
 }
 
-int tsec_read_ucode(struct nvhost_device *dev, const char *fw_name)
+int tsec_read_ucode(struct platform_device *dev, const char *fw_name)
 {
        struct tsec *m = get_tsec(dev);
        const struct firmware *ucode_fw;
@@ -321,7 +322,7 @@ clean_up:
        return err;
 }
 
-void nvhost_tsec_init(struct nvhost_device *dev)
+void nvhost_tsec_init(struct platform_device *dev)
 {
        int err = 0;
        struct tsec *m;
@@ -360,7 +361,7 @@ void nvhost_tsec_init(struct nvhost_device *dev)
        mem_op().unpin(nvhost_get_host(dev)->memmgr, m->mem_r, m->pa);
 }
 
-void nvhost_tsec_deinit(struct nvhost_device *dev)
+void nvhost_tsec_deinit(struct platform_device *dev)
 {
        struct tsec *m = get_tsec(dev);
 
@@ -372,19 +373,22 @@ void nvhost_tsec_deinit(struct nvhost_device *dev)
        }
 }
 
-void nvhost_tsec_finalize_poweron(struct nvhost_device *dev)
+void nvhost_tsec_finalize_poweron(struct platform_device *dev)
 {
        tsec_boot(dev);
 }
 
-static int tsec_probe(struct nvhost_device *dev,
-               struct nvhost_device_id *id_table)
+static int tsec_probe(struct platform_device *dev)
 {
        int err;
-       struct nvhost_driver *drv = to_nvhost_driver(dev->dev.driver);
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)dev->dev.platform_data;
 
-       drv->init = nvhost_tsec_init;
-       drv->deinit = nvhost_tsec_deinit;
+       pdata->pdev = dev;
+       pdata->init = nvhost_tsec_init;
+       pdata->deinit = nvhost_tsec_deinit;
+
+       platform_set_drvdata(dev, pdata);
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
@@ -393,26 +397,26 @@ static int tsec_probe(struct nvhost_device *dev,
        return nvhost_client_device_init(dev);
 }
 
-static int __exit tsec_remove(struct nvhost_device *dev)
+static int __exit tsec_remove(struct platform_device *dev)
 {
        /* Add clean-up */
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int tsec_suspend(struct nvhost_device *dev, pm_message_t state)
+static int tsec_suspend(struct platform_device *dev, pm_message_t state)
 {
        return nvhost_client_device_suspend(dev);
 }
 
-static int tsec_resume(struct nvhost_device *dev)
+static int tsec_resume(struct platform_device *dev)
 {
        dev_info(&dev->dev, "resuming\n");
        return 0;
 }
 #endif
 
-static struct nvhost_driver tsec_driver = {
+static struct platform_driver tsec_driver = {
        .probe = tsec_probe,
        .remove = __exit_p(tsec_remove),
 #ifdef CONFIG_PM
@@ -451,12 +455,12 @@ __setup("otf_key=", tsec_key_setup);
 
 static int __init tsec_init(void)
 {
-       return nvhost_driver_register(&tsec_driver);
+       return platform_driver_register(&tsec_driver);
 }
 
 static void __exit tsec_exit(void)
 {
-       nvhost_driver_unregister(&tsec_driver);
+       platform_driver_unregister(&tsec_driver);
 }
 
 module_init(tsec_init);
index 7a4159e..5311929 100644 (file)
 struct mem_handle;
 struct sg_table;
 
-void nvhost_tsec_finalize_poweron(struct nvhost_device *dev);
-void nvhost_tsec_init(struct nvhost_device *dev);
-void nvhost_tsec_deinit(struct nvhost_device *dev);
+void nvhost_tsec_finalize_poweron(struct platform_device *dev);
+void nvhost_tsec_init(struct platform_device *dev);
+void nvhost_tsec_deinit(struct platform_device *dev);
 
 /* Would have preferred a static inline here... but we're using this
  * in a place where a constant initializer is required */
-#define NVHOST_ENCODE_TSEC_VER(maj,min) ( (((maj)&0xff)<<8) | ((min)&0xff) )
+#define NVHOST_ENCODE_TSEC_VER(maj, min)       ( (((maj) & 0xff) << 8) | ((min) & 0xff) )
 
 static inline void decode_tsec_ver(int version, u8 *maj, u8 *min)
 {
@@ -58,9 +58,9 @@ struct tsec {
 };
 
 struct tsec_ucode_bin_header_v1 {
-       u32 bin_magic;        /* 0x10de */
-       u32 bin_ver;          /* cya, versioning of bin format (1) */
-       u32 bin_size;         /* entire image size including this header */
+       u32 bin_magic;          /* 0x10de */
+       u32 bin_ver;            /* cya, versioning of bin format (1) */
+       u32 bin_size;           /* entire image size including this header */
        u32 os_bin_header_offset;
        u32 os_bin_data_offset;
        u32 os_bin_size;
index 51eba5e..dca405b 100644 (file)
 #include "dev.h"
 #include "bus_client.h"
 
-static int vi_probe(struct nvhost_device *dev,
-       struct nvhost_device_id *id_table)
+static int vi_probe(struct platform_device *dev)
 {
        int err = 0;
+       struct nvhost_device_data *pdata =
+               (struct nvhost_device_data *)dev->dev.platform_data;
+
+       pdata->pdev = dev;
+       platform_set_drvdata(dev, pdata);
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
@@ -38,26 +42,26 @@ static int vi_probe(struct nvhost_device *dev,
        return nvhost_client_device_init(dev);
 }
 
-static int __exit vi_remove(struct nvhost_device *dev)
+static int __exit vi_remove(struct platform_device *dev)
 {
        /* Add clean-up */
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int vi_suspend(struct nvhost_device *dev, pm_message_t state)
+static int vi_suspend(struct platform_device *dev, pm_message_t state)
 {
        return nvhost_client_device_suspend(dev);
 }
 
-static int vi_resume(struct nvhost_device *dev)
+static int vi_resume(struct platform_device *dev)
 {
        dev_info(&dev->dev, "resuming\n");
        return 0;
 }
 #endif
 
-static struct nvhost_driver vi_driver = {
+static struct platform_driver vi_driver = {
        .probe = vi_probe,
        .remove = __exit_p(vi_remove),
 #ifdef CONFIG_PM
@@ -72,12 +76,12 @@ static struct nvhost_driver vi_driver = {
 
 static int __init vi_init(void)
 {
-       return nvhost_driver_register(&vi_driver);
+       return platform_driver_register(&vi_driver);
 }
 
 static void __exit vi_exit(void)
 {
-       nvhost_driver_unregister(&vi_driver);
+       platform_driver_unregister(&vi_driver);
 }
 
 module_init(vi_init);
index a25e420..6a35ed2 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/device.h>
 #include <linux/types.h>
 #include <linux/devfreq.h>
+#include <linux/platform_device.h>
 
 struct nvhost_master;
 struct nvhost_hwctx;
@@ -66,11 +67,6 @@ enum nvhost_power_sysfs_attributes {
        NVHOST_POWER_SYSFS_ATTRIB_MAX
 };
 
-struct nvhost_device_id {
-       char name[NVHOST_NAME_SIZE];
-       unsigned long version;
-};
-
 struct nvhost_clock {
        char *name;
        unsigned long default_rate;
@@ -85,14 +81,10 @@ enum nvhost_device_powerstate_t {
        NVHOST_POWER_STATE_POWERGATED
 };
 
-struct nvhost_device {
-       const char      *name;          /* device name */
+struct nvhost_device_data {
        int             version;        /* ip version number of device */
-       struct device   dev;            /* Linux device struct */
        int             id;             /* Separates clients of same hw */
        int             index;          /* Hardware channel number */
-       u32             num_resources;  /* Number of resources following */
-       struct resource *resource;      /* Resources (IOMEM in particular) */
        struct resource *reg_mem;
        void __iomem    *aperture;      /* Iomem mapped to kernel */
 
@@ -128,113 +120,71 @@ struct nvhost_device {
        struct nvhost_device_power_attr *power_attrib;  /* sysfs attributes */
        struct devfreq  *power_manager; /* Device power management */
        struct dentry *debugfs;         /* debugfs directory */
-};
-
-struct nvhost_device_power_attr {
-       struct nvhost_device *ndev;
-       struct kobj_attribute power_attr[NVHOST_POWER_SYSFS_ATTRIB_MAX];
-};
-
-struct nvhost_devfreq_ext_stat {
-       int             busy;
-       unsigned long   max_freq;
-       unsigned long   min_freq;
-};
-
-
-/* Register devices to nvhost bus */
-extern int nvhost_add_devices(struct nvhost_device **, int num);
 
-/* Register device to nvhost bus */
-extern int nvhost_device_register(struct nvhost_device *);
-
-/* Deregister device from nvhost bus */
-extern void nvhost_device_unregister(struct nvhost_device *);
-
-extern struct bus_type nvhost_bus_type;
-
-struct nvhost_driver {
-       int (*probe)(struct nvhost_device *, struct nvhost_device_id *);
-       int (*remove)(struct nvhost_device *);
-       void (*shutdown)(struct nvhost_device *);
-       int (*suspend)(struct nvhost_device *, pm_message_t state);
-       int (*resume)(struct nvhost_device *);
-       struct device_driver driver;
-
-       struct nvhost_device_id *id_table;
+       void *private_data;             /* private platform data */
+       struct platform_device *pdev;   /* owner platform_device */
 
        /* Finalize power on. Can be used for context restore. */
-       void (*finalize_poweron)(struct nvhost_device *dev);
+       void (*finalize_poweron)(struct platform_device *dev);
 
        /* Device is busy. */
-       void (*busy)(struct nvhost_device *);
+       void (*busy)(struct platform_device *);
 
        /* Device is idle. */
-       void (*idle)(struct nvhost_device *);
+       void (*idle)(struct platform_device *);
 
        /* Device is going to be suspended */
-       void (*suspend_ndev)(struct nvhost_device *);
+       void (*suspend_ndev)(struct platform_device *);
 
        /* Device is initialized */
-       void (*init)(struct nvhost_device *dev);
+       void (*init)(struct platform_device *dev);
 
        /* Device is de-initialized. */
-       void (*deinit)(struct nvhost_device *dev);
+       void (*deinit)(struct platform_device *dev);
 
        /* Preparing for power off. Used for context save. */
-       int (*prepare_poweroff)(struct nvhost_device *dev);
+       int (*prepare_poweroff)(struct platform_device *dev);
 
        /* Allocates a context handler for the device */
        struct nvhost_hwctx_handler *(*alloc_hwctx_handler)(u32 syncpt,
                        u32 waitbase, struct nvhost_channel *ch);
 
        /* Clock gating callbacks */
-       int (*prepare_clockoff)(struct nvhost_device *dev);
-       void (*finalize_clockon)(struct nvhost_device *dev);
+       int (*prepare_clockoff)(struct platform_device *dev);
+       void (*finalize_clockon)(struct platform_device *dev);
 
        /* Read module register into memory */
-       int (*read_reg)(struct nvhost_device *dev,
+       int (*read_reg)(struct platform_device *dev,
                        struct nvhost_channel *ch,
                        struct nvhost_hwctx *hwctx,
                        u32 offset,
                        u32 *value);
 };
 
-extern int nvhost_driver_register(struct nvhost_driver *);
-extern void nvhost_driver_unregister(struct nvhost_driver *);
-extern struct resource *nvhost_get_resource(struct nvhost_device *,
-               unsigned int, unsigned int);
-extern int nvhost_get_irq(struct nvhost_device *, unsigned int);
-extern struct resource *nvhost_get_resource_byname(struct nvhost_device *,
-               unsigned int, const char *);
-extern int nvhost_get_irq_byname(struct nvhost_device *, const char *);
-extern void nvhost_device_writel(struct nvhost_device *, u32 r, u32 v);
-extern u32 nvhost_device_readl(struct nvhost_device *, u32 r);
-
-#define to_nvhost_device(x)    container_of((x), struct nvhost_device, dev)
-#define to_nvhost_driver(drv)  (container_of((drv), struct nvhost_driver, \
-                                driver))
-
-#define nvhost_get_drvdata(_dev)       dev_get_drvdata(&(_dev)->dev)
-#define nvhost_set_drvdata(_dev, data) dev_set_drvdata(&(_dev)->dev, (data))
+struct nvhost_devfreq_ext_stat {
+       int             busy;
+       unsigned long   max_freq;
+       unsigned long   min_freq;
+};
 
-int nvhost_bus_add_host(struct nvhost_master *host);
+struct nvhost_device_power_attr {
+       struct platform_device *ndev;
+       struct kobj_attribute power_attr[NVHOST_POWER_SYSFS_ATTRIB_MAX];
+};
 
-static inline struct nvhost_device *nvhost_get_parent(struct nvhost_device *_dev)
-{
-       return _dev->dev.parent ? to_nvhost_device(_dev->dev.parent) : NULL;
-}
+void nvhost_device_writel(struct platform_device *dev, u32 r, u32 v);
+u32 nvhost_device_readl(struct platform_device *dev, u32 r);
 
 /* public host1x power management APIs */
-bool nvhost_module_powered_ext(struct nvhost_device *dev);
-void nvhost_module_busy_ext(struct nvhost_device *dev);
-void nvhost_module_idle_ext(struct nvhost_device *dev);
+bool nvhost_module_powered_ext(struct platform_device *dev);
+void nvhost_module_busy_ext(struct platform_device *dev);
+void nvhost_module_idle_ext(struct platform_device *dev);
 
 /* public host1x sync-point management APIs */
-u32 nvhost_syncpt_incr_max_ext(struct nvhost_device *dev, u32 id, u32 incrs);
-void nvhost_syncpt_cpu_incr_ext(struct nvhost_device *dev, u32 id);
-u32 nvhost_syncpt_read_ext(struct nvhost_device *dev, u32 id);
-int nvhost_syncpt_wait_timeout_ext(struct nvhost_device *dev, u32 id, u32 thresh,
+u32 nvhost_syncpt_incr_max_ext(struct platform_device *dev, u32 id, u32 incrs);
+void nvhost_syncpt_cpu_incr_ext(struct platform_device *dev, u32 id);
+u32 nvhost_syncpt_read_ext(struct platform_device *dev, u32 id);
+int nvhost_syncpt_wait_timeout_ext(struct platform_device *dev, u32 id, u32 thresh,
        u32 timeout, u32 *value);
 
 void nvhost_scale3d_set_throughput_hint(int hint);