blob: 12a6ab129a03e9d3beb4d53087b3c0599a948046 [file] [log] [blame]
Lynus Vazd9c0d2e2013-01-23 12:38:44 +05301/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +05302 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#include <linux/init.h>
15#include <linux/platform_device.h>
Jordan Crouse914de9b2012-07-09 13:49:46 -060016#include <mach/kgsl.h>
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +053017#include <mach/msm_bus_board.h>
18#include <mach/board.h>
Sudhakara Rao Tentu87c4e8e2012-06-20 14:42:58 +053019#include <mach/socinfo.h>
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +053020
21#include "devices.h"
22#include "board-8930.h"
23
24#ifdef CONFIG_MSM_BUS_SCALING
25static struct msm_bus_vectors grp3d_init_vectors[] = {
26 {
27 .src = MSM_BUS_MASTER_GRAPHICS_3D,
28 .dst = MSM_BUS_SLAVE_EBI_CH0,
29 .ab = 0,
30 .ib = 0,
31 },
32};
33
34static struct msm_bus_vectors grp3d_low_vectors[] = {
35 {
36 .src = MSM_BUS_MASTER_GRAPHICS_3D,
37 .dst = MSM_BUS_SLAVE_EBI_CH0,
38 .ab = 0,
Lucille Sylvester26615342012-06-26 17:55:10 -060039 .ib = KGSL_CONVERT_TO_MBPS(1000),
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +053040 },
41};
42
43static struct msm_bus_vectors grp3d_nominal_vectors[] = {
44 {
45 .src = MSM_BUS_MASTER_GRAPHICS_3D,
46 .dst = MSM_BUS_SLAVE_EBI_CH0,
47 .ab = 0,
Lucille Sylvester26615342012-06-26 17:55:10 -060048 .ib = KGSL_CONVERT_TO_MBPS(2656),
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +053049 },
50};
51
52static struct msm_bus_vectors grp3d_max_vectors[] = {
53 {
54 .src = MSM_BUS_MASTER_GRAPHICS_3D,
55 .dst = MSM_BUS_SLAVE_EBI_CH0,
56 .ab = 0,
Sudhakara Rao Tentuef9d75e2012-03-30 09:21:42 -070057 .ib = KGSL_CONVERT_TO_MBPS(4264),
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +053058 },
59};
60
61static struct msm_bus_paths grp3d_bus_scale_usecases[] = {
62 {
63 ARRAY_SIZE(grp3d_init_vectors),
64 grp3d_init_vectors,
65 },
66 {
67 ARRAY_SIZE(grp3d_low_vectors),
68 grp3d_low_vectors,
69 },
70 {
71 ARRAY_SIZE(grp3d_nominal_vectors),
72 grp3d_nominal_vectors,
73 },
74 {
75 ARRAY_SIZE(grp3d_max_vectors),
76 grp3d_max_vectors,
77 },
78};
79
80static struct msm_bus_scale_pdata grp3d_bus_scale_pdata = {
81 grp3d_bus_scale_usecases,
82 ARRAY_SIZE(grp3d_bus_scale_usecases),
83 .name = "grp3d",
84};
85#endif
86
87static struct resource kgsl_3d0_resources[] = {
88 {
89 .name = KGSL_3D0_REG_MEMORY,
90 .start = 0x04300000, /* GFX3D address */
Harsh Vardhan Dwivedi623b9a22012-10-28 20:54:17 -060091 .end = 0x0430ffff,
92 .flags = IORESOURCE_MEM,
93 },
94 {
95 .name = KGSL_3D0_SHADER_MEMORY,
96 .start = 0x04310000,
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +053097 .end = 0x0431ffff,
98 .flags = IORESOURCE_MEM,
99 },
100 {
101 .name = KGSL_3D0_IRQ,
102 .start = GFX3D_IRQ,
103 .end = GFX3D_IRQ,
104 .flags = IORESOURCE_IRQ,
105 },
106};
107
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600108static const struct kgsl_iommu_ctx kgsl_3d0_iommu0_ctxs[] = {
109 { "gfx3d_user", 0 },
110 { "gfx3d_priv", 1 },
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +0530111};
112
113static struct kgsl_device_iommu_data kgsl_3d0_iommu_data[] = {
114 {
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600115 .iommu_ctxs = kgsl_3d0_iommu0_ctxs,
116 .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu0_ctxs),
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +0530117 .physstart = 0x07C00000,
118 .physend = 0x07C00000 + SZ_1M - 1,
119 },
120};
121
122static struct kgsl_device_platform_data kgsl_3d0_pdata = {
123 .pwrlevel = {
124 {
Sudhakara Rao Tentu18481ea2012-04-25 03:51:50 -0700125 .gpu_freq = 400000000,
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +0530126 .bus_freq = 3,
127 .io_fraction = 0,
128 },
129 {
Sudhakara Rao Tentuef9d75e2012-03-30 09:21:42 -0700130 .gpu_freq = 320000000,
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +0530131 .bus_freq = 2,
132 .io_fraction = 33,
133 },
134 {
Sudhakara Rao Tentuef9d75e2012-03-30 09:21:42 -0700135 .gpu_freq = 192000000,
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +0530136 .bus_freq = 1,
137 .io_fraction = 100,
138 },
139 {
140 .gpu_freq = 27000000,
141 .bus_freq = 0,
142 },
143 },
Lucille Sylvester7e3941b2012-06-29 11:57:43 -0600144 .init_level = 1,
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +0530145 .num_levels = 4,
146 .set_grp_async = NULL,
Sudhakara Rao Tentuef9d75e2012-03-30 09:21:42 -0700147 .idle_timeout = HZ/12,
Lynus Vazd9c0d2e2013-01-23 12:38:44 +0530148 .strtstp_sleepwake = false,
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +0530149 .clk_map = KGSL_CLK_CORE | KGSL_CLK_IFACE | KGSL_CLK_MEM_IFACE,
150#ifdef CONFIG_MSM_BUS_SCALING
151 .bus_scale_table = &grp3d_bus_scale_pdata,
152#endif
153 .iommu_data = kgsl_3d0_iommu_data,
154 .iommu_count = ARRAY_SIZE(kgsl_3d0_iommu_data),
155};
156
157static struct platform_device device_kgsl_3d0 = {
158 .name = "kgsl-3d0",
159 .id = 0,
160 .num_resources = ARRAY_SIZE(kgsl_3d0_resources),
161 .resource = kgsl_3d0_resources,
162 .dev = {
163 .platform_data = &kgsl_3d0_pdata,
164 },
165};
166
167void __init msm8930_init_gpu(void)
168{
Jordan Crouse4815e9f2012-07-09 15:36:37 -0600169 unsigned int version = socinfo_get_version();
170
Jordan Crouse9c7bab32012-10-25 09:37:43 -0600171 /* Set the turbo speed for the AA and AB respectively */
172
Sudhakara Rao Tentudcc2e222012-07-07 09:49:55 +0530173 if (cpu_is_msm8930aa())
174 kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 450000000;
Lynus Vaz4f3182e2012-12-10 12:11:18 +0530175 else if (cpu_is_msm8930ab()) {
Jordan Crouse9c7bab32012-10-25 09:37:43 -0600176 kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 500000000;
Lynus Vaz4f3182e2012-12-10 12:11:18 +0530177 grp3d_max_vectors[0].ib = KGSL_CONVERT_TO_MBPS(4800);
178 }
Sudhakara Rao Tentu87c4e8e2012-06-20 14:42:58 +0530179
Jordan Crouse9c7bab32012-10-25 09:37:43 -0600180 /* Set up the chip ID based on the SoC version */
181
182 if (cpu_is_msm8930ab())
183 kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 0, 5, 3);
184 else if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
Jordan Crouse4815e9f2012-07-09 15:36:37 -0600185 (SOCINFO_VERSION_MINOR(version) == 2))
186 kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 0, 5, 2);
187 else
188 kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 0, 5, 0);
189
Sudhakara Rao Tentu8b5c8ed2012-03-05 14:48:41 +0530190 platform_device_register(&device_kgsl_3d0);
191}