video: tegra: host: Register devices in SoC files
[linux-2.6.git] / arch / arm / mach-tegra / p852 / board-p852-panel.c
1 /*
2  * arch/arm/mach-tegra/board-p852-panel.c
3  *
4  * Copyright (c) 2010-2012, NVIDIA Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 #include <linux/delay.h>
22 #include <linux/gpio.h>
23 #include <linux/regulator/consumer.h>
24 #include <linux/resource.h>
25 #include <linux/nvhost.h>
26 #include <linux/platform_device.h>
27 #include <asm/mach-types.h>
28 #include <linux/nvmap.h>
29 #include <mach/irqs.h>
30 #include <mach/iomap.h>
31 #include <mach/dc.h>
32 #include <mach/fb.h>
33
34 #include "board-p852.h"
35 #include "../tegra2_host1x_devices.h"
36
37 #define CARVEOUT_IRAM {\
38         .name = "iram",\
39         .usage_mask = NVMAP_HEAP_CARVEOUT_IRAM,\
40         .base = TEGRA_IRAM_BASE,\
41         .size = TEGRA_IRAM_SIZE,\
42         .buddy_size = 0, /* no buddy allocation for IRAM */\
43 }
44
45 static int p852_panel_enable(void)
46 {
47         pr_info("%s\n", __func__);
48         return 0;
49 }
50
51 static int p852_panel_disable(void)
52 {
53         pr_info("%s\n", __func__);
54         return 0;
55 }
56
57 static struct resource p852_disp_resources[] = {
58         {
59          .name = "irq",
60          .start = INT_DISPLAY_GENERAL,
61          .end = INT_DISPLAY_GENERAL,
62          .flags = IORESOURCE_IRQ,
63         },
64         {
65          .name = "regs",
66          .start = TEGRA_DISPLAY_BASE,
67          .end = TEGRA_DISPLAY_BASE + TEGRA_DISPLAY_SIZE - 1,
68          .flags = IORESOURCE_MEM,
69         },
70         {
71          .name = "fbmem",
72          .start = 0,
73          .end =   0,
74          .flags = IORESOURCE_MEM,
75         },
76 };
77
78 static struct tegra_dc_mode p852_panel_modes[] = {
79 /* Timings for the LG LB070WV4 panel */
80         {
81          .pclk = 33230769,
82
83          .h_ref_to_sync = 1,
84          .v_ref_to_sync = 1,
85
86          .h_sync_width = 128,
87          .v_sync_width = 2,
88
89          .h_back_porch = 88,
90          .v_back_porch = 30,
91
92          .h_front_porch = 40,
93          .v_front_porch = 13,
94
95          .h_active = 800,
96          .v_active = 480,
97          },
98 };
99
100 static struct tegra_fb_data p852_fb_data = {
101         .win = 0,
102         .xres = 800,
103         .yres = 480,
104         .bits_per_pixel = 16,
105 };
106
107 static struct tegra_dc_out p852_disp_out = {
108         .type = TEGRA_DC_OUT_RGB,
109
110         .align = TEGRA_DC_ALIGN_MSB,
111         .order = TEGRA_DC_ORDER_RED_BLUE,
112
113         .modes = p852_panel_modes,
114         .n_modes = ARRAY_SIZE(p852_panel_modes),
115
116         .enable = p852_panel_enable,
117         .disable = p852_panel_disable,
118 };
119
120 static struct tegra_dc_platform_data p852_disp_pdata = {
121         .flags = TEGRA_DC_FLAG_ENABLED,
122         .default_out = &p852_disp_out,
123         .fb = &p852_fb_data,
124 };
125
126 static struct nvhost_device p852_disp_device = {
127         .name = "tegradc",
128         .id = 0,
129         .resource = p852_disp_resources,
130         .num_resources = ARRAY_SIZE(p852_disp_resources),
131         .dev = {
132                 .platform_data = &p852_disp_pdata,
133                 },
134 };
135
136 static struct nvmap_platform_carveout p852_carveouts[] = {
137         [0] = CARVEOUT_IRAM,
138         [1] = {
139                .name = "generic-0",
140                .usage_mask = NVMAP_HEAP_CARVEOUT_GENERIC,
141                .base = 0,
142                .size = 0,
143                .buddy_size = SZ_32K,
144                },
145 };
146
147 static struct nvmap_platform_data p852_nvmap_data = {
148         .carveouts = p852_carveouts,
149         .nr_carveouts = ARRAY_SIZE(p852_carveouts),
150 };
151
152 static struct platform_device p852_nvmap_device = {
153         .name = "tegra-nvmap",
154         .id = -1,
155         .dev = {
156                 .platform_data = &p852_nvmap_data,
157                 },
158 };
159
160 static struct platform_device *p852_gfx_devices[] __initdata = {
161         &tegra_pwfm2_device,
162 };
163
164 int __init p852_panel_init(void)
165 {
166         int err;
167         struct resource *res;
168
169         pr_info("%s\n", __func__);
170
171         p852_carveouts[1].base = tegra_carveout_start;
172         p852_carveouts[1].size = tegra_carveout_size;
173
174         err = platform_device_register(&p852_nvmap_device);
175         if (err)
176                 return err;
177
178 #ifdef CONFIG_TEGRA_GRHOST
179         err = tegra2_register_host1x_devices();
180         if (err)
181                 return err;
182 #endif
183
184         err = platform_add_devices(p852_gfx_devices,
185                                    ARRAY_SIZE(p852_gfx_devices));
186
187         res = nvhost_get_resource_byname(&p852_disp_device,
188                                         IORESOURCE_MEM, "fbmem");
189
190         res->start = tegra_fb_start;
191         res->end = tegra_fb_start + tegra_fb_size - 1;
192
193         if (!err)
194                 err = nvhost_device_register(&p852_disp_device);
195
196         return err;
197 }