Lynus Vaz | d9c0d2e | 2013-01-23 12:38:44 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 2 | * |
| 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 Crouse | 914de9b | 2012-07-09 13:49:46 -0600 | [diff] [blame] | 16 | #include <mach/kgsl.h> |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 17 | #include <mach/msm_bus_board.h> |
| 18 | #include <mach/board.h> |
Sudhakara Rao Tentu | 87c4e8e | 2012-06-20 14:42:58 +0530 | [diff] [blame] | 19 | #include <mach/socinfo.h> |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 20 | |
| 21 | #include "devices.h" |
| 22 | #include "board-8930.h" |
| 23 | |
| 24 | #ifdef CONFIG_MSM_BUS_SCALING |
| 25 | static 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 | |
| 34 | static 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 Sylvester | 2661534 | 2012-06-26 17:55:10 -0600 | [diff] [blame] | 39 | .ib = KGSL_CONVERT_TO_MBPS(1000), |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 40 | }, |
| 41 | }; |
| 42 | |
| 43 | static 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 Sylvester | 2661534 | 2012-06-26 17:55:10 -0600 | [diff] [blame] | 48 | .ib = KGSL_CONVERT_TO_MBPS(2656), |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 49 | }, |
| 50 | }; |
| 51 | |
| 52 | static 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 Tentu | ef9d75e | 2012-03-30 09:21:42 -0700 | [diff] [blame] | 57 | .ib = KGSL_CONVERT_TO_MBPS(4264), |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 58 | }, |
| 59 | }; |
| 60 | |
| 61 | static 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 | |
| 80 | static 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 | |
| 87 | static struct resource kgsl_3d0_resources[] = { |
| 88 | { |
| 89 | .name = KGSL_3D0_REG_MEMORY, |
| 90 | .start = 0x04300000, /* GFX3D address */ |
Harsh Vardhan Dwivedi | 623b9a2 | 2012-10-28 20:54:17 -0600 | [diff] [blame] | 91 | .end = 0x0430ffff, |
| 92 | .flags = IORESOURCE_MEM, |
| 93 | }, |
| 94 | { |
| 95 | .name = KGSL_3D0_SHADER_MEMORY, |
| 96 | .start = 0x04310000, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 97 | .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 Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 108 | static const struct kgsl_iommu_ctx kgsl_3d0_iommu0_ctxs[] = { |
| 109 | { "gfx3d_user", 0 }, |
| 110 | { "gfx3d_priv", 1 }, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | static struct kgsl_device_iommu_data kgsl_3d0_iommu_data[] = { |
| 114 | { |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 115 | .iommu_ctxs = kgsl_3d0_iommu0_ctxs, |
| 116 | .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu0_ctxs), |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 117 | .physstart = 0x07C00000, |
| 118 | .physend = 0x07C00000 + SZ_1M - 1, |
| 119 | }, |
| 120 | }; |
| 121 | |
| 122 | static struct kgsl_device_platform_data kgsl_3d0_pdata = { |
| 123 | .pwrlevel = { |
| 124 | { |
Sudhakara Rao Tentu | 18481ea | 2012-04-25 03:51:50 -0700 | [diff] [blame] | 125 | .gpu_freq = 400000000, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 126 | .bus_freq = 3, |
| 127 | .io_fraction = 0, |
| 128 | }, |
| 129 | { |
Sudhakara Rao Tentu | ef9d75e | 2012-03-30 09:21:42 -0700 | [diff] [blame] | 130 | .gpu_freq = 320000000, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 131 | .bus_freq = 2, |
| 132 | .io_fraction = 33, |
| 133 | }, |
| 134 | { |
Sudhakara Rao Tentu | ef9d75e | 2012-03-30 09:21:42 -0700 | [diff] [blame] | 135 | .gpu_freq = 192000000, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 136 | .bus_freq = 1, |
| 137 | .io_fraction = 100, |
| 138 | }, |
| 139 | { |
| 140 | .gpu_freq = 27000000, |
| 141 | .bus_freq = 0, |
| 142 | }, |
| 143 | }, |
Lucille Sylvester | 7e3941b | 2012-06-29 11:57:43 -0600 | [diff] [blame] | 144 | .init_level = 1, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 145 | .num_levels = 4, |
| 146 | .set_grp_async = NULL, |
Sudhakara Rao Tentu | ef9d75e | 2012-03-30 09:21:42 -0700 | [diff] [blame] | 147 | .idle_timeout = HZ/12, |
Lynus Vaz | d9c0d2e | 2013-01-23 12:38:44 +0530 | [diff] [blame] | 148 | .strtstp_sleepwake = false, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 149 | .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 | |
| 157 | static 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 | |
| 167 | void __init msm8930_init_gpu(void) |
| 168 | { |
Jordan Crouse | 4815e9f | 2012-07-09 15:36:37 -0600 | [diff] [blame] | 169 | unsigned int version = socinfo_get_version(); |
| 170 | |
Jordan Crouse | 9c7bab3 | 2012-10-25 09:37:43 -0600 | [diff] [blame] | 171 | /* Set the turbo speed for the AA and AB respectively */ |
| 172 | |
Sudhakara Rao Tentu | dcc2e22 | 2012-07-07 09:49:55 +0530 | [diff] [blame] | 173 | if (cpu_is_msm8930aa()) |
| 174 | kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 450000000; |
Lynus Vaz | 4f3182e | 2012-12-10 12:11:18 +0530 | [diff] [blame] | 175 | else if (cpu_is_msm8930ab()) { |
Jordan Crouse | 9c7bab3 | 2012-10-25 09:37:43 -0600 | [diff] [blame] | 176 | kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 500000000; |
Lynus Vaz | 4f3182e | 2012-12-10 12:11:18 +0530 | [diff] [blame] | 177 | grp3d_max_vectors[0].ib = KGSL_CONVERT_TO_MBPS(4800); |
| 178 | } |
Sudhakara Rao Tentu | 87c4e8e | 2012-06-20 14:42:58 +0530 | [diff] [blame] | 179 | |
Jordan Crouse | 9c7bab3 | 2012-10-25 09:37:43 -0600 | [diff] [blame] | 180 | /* 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 Crouse | 4815e9f | 2012-07-09 15:36:37 -0600 | [diff] [blame] | 185 | (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 Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 190 | platform_device_register(&device_kgsl_3d0); |
| 191 | } |