Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 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> |
| 16 | #include <linux/msm_kgsl.h> |
| 17 | #include <mach/msm_bus_board.h> |
| 18 | #include <mach/board.h> |
| 19 | |
| 20 | #include "devices.h" |
| 21 | #include "board-8064.h" |
| 22 | |
| 23 | #ifdef CONFIG_MSM_BUS_SCALING |
| 24 | static struct msm_bus_vectors grp3d_init_vectors[] = { |
| 25 | { |
| 26 | .src = MSM_BUS_MASTER_GRAPHICS_3D, |
| 27 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 28 | .ab = 0, |
| 29 | .ib = 0, |
| 30 | }, |
| 31 | { |
| 32 | .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1, |
| 33 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 34 | .ab = 0, |
| 35 | .ib = 0, |
| 36 | }, |
| 37 | }; |
| 38 | |
| 39 | static struct msm_bus_vectors grp3d_low_vectors[] = { |
| 40 | { |
| 41 | .src = MSM_BUS_MASTER_GRAPHICS_3D, |
| 42 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 43 | .ab = 0, |
| 44 | .ib = KGSL_CONVERT_TO_MBPS(2000), |
| 45 | }, |
| 46 | { |
| 47 | .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1, |
| 48 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 49 | .ab = 0, |
| 50 | .ib = KGSL_CONVERT_TO_MBPS(2000), |
| 51 | }, |
| 52 | }; |
| 53 | |
| 54 | static struct msm_bus_vectors grp3d_nominal_high_vectors[] = { |
| 55 | { |
| 56 | .src = MSM_BUS_MASTER_GRAPHICS_3D, |
| 57 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 58 | .ab = 0, |
| 59 | .ib = KGSL_CONVERT_TO_MBPS(3200), |
| 60 | }, |
| 61 | { |
| 62 | .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1, |
| 63 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 64 | .ab = 0, |
| 65 | .ib = KGSL_CONVERT_TO_MBPS(3200), |
| 66 | }, |
| 67 | }; |
| 68 | |
| 69 | static struct msm_bus_vectors grp3d_max_vectors[] = { |
| 70 | { |
| 71 | .src = MSM_BUS_MASTER_GRAPHICS_3D, |
| 72 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 73 | .ab = 0, |
| 74 | .ib = KGSL_CONVERT_TO_MBPS(4264), |
| 75 | }, |
| 76 | { |
| 77 | .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1, |
| 78 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 79 | .ab = 0, |
| 80 | .ib = KGSL_CONVERT_TO_MBPS(4264), |
| 81 | }, |
| 82 | }; |
| 83 | |
| 84 | static struct msm_bus_paths grp3d_bus_scale_usecases[] = { |
| 85 | { |
| 86 | ARRAY_SIZE(grp3d_init_vectors), |
| 87 | grp3d_init_vectors, |
| 88 | }, |
| 89 | { |
| 90 | ARRAY_SIZE(grp3d_low_vectors), |
| 91 | grp3d_low_vectors, |
| 92 | }, |
| 93 | { |
| 94 | ARRAY_SIZE(grp3d_nominal_high_vectors), |
| 95 | grp3d_nominal_high_vectors, |
| 96 | }, |
| 97 | { |
| 98 | ARRAY_SIZE(grp3d_max_vectors), |
| 99 | grp3d_max_vectors, |
| 100 | }, |
| 101 | }; |
| 102 | |
| 103 | static struct msm_bus_scale_pdata grp3d_bus_scale_pdata = { |
| 104 | grp3d_bus_scale_usecases, |
| 105 | ARRAY_SIZE(grp3d_bus_scale_usecases), |
| 106 | .name = "grp3d", |
| 107 | }; |
| 108 | #endif |
| 109 | |
| 110 | static struct resource kgsl_3d0_resources[] = { |
| 111 | { |
| 112 | .name = KGSL_3D0_REG_MEMORY, |
| 113 | .start = 0x04300000, /* GFX3D address */ |
| 114 | .end = 0x0431ffff, |
| 115 | .flags = IORESOURCE_MEM, |
| 116 | }, |
| 117 | { |
| 118 | .name = KGSL_3D0_IRQ, |
| 119 | .start = GFX3D_IRQ, |
| 120 | .end = GFX3D_IRQ, |
| 121 | .flags = IORESOURCE_IRQ, |
| 122 | }, |
| 123 | }; |
| 124 | |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 125 | static const char *kgsl_3d0_iommu0_ctx_names[] = { |
| 126 | "gfx3d_user", |
| 127 | /* priv_ctx goes here */ |
| 128 | }; |
| 129 | |
| 130 | static const char *kgsl_3d0_iommu1_ctx_names[] = { |
| 131 | "gfx3d1_user", |
| 132 | /* priv_ctx goes here */ |
| 133 | }; |
| 134 | |
| 135 | static struct kgsl_device_iommu_data kgsl_3d0_iommu_data[] = { |
| 136 | { |
| 137 | .iommu_ctx_names = kgsl_3d0_iommu0_ctx_names, |
| 138 | .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu0_ctx_names), |
| 139 | .physstart = 0x07C00000, |
| 140 | .physend = 0x07C00000 + SZ_1M - 1, |
| 141 | }, |
| 142 | { |
| 143 | .iommu_ctx_names = kgsl_3d0_iommu1_ctx_names, |
| 144 | .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu1_ctx_names), |
| 145 | .physstart = 0x07D00000, |
| 146 | .physend = 0x07D00000 + SZ_1M - 1, |
| 147 | }, |
| 148 | }; |
| 149 | |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 150 | static struct kgsl_device_platform_data kgsl_3d0_pdata = { |
| 151 | .pwrlevel = { |
| 152 | { |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 153 | .gpu_freq = 400000000, |
Tarun Karra | 7185370 | 2012-02-17 15:21:59 -0800 | [diff] [blame] | 154 | .bus_freq = 3, |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 155 | .io_fraction = 0, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 156 | }, |
| 157 | { |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 158 | .gpu_freq = 320000000, |
Tarun Karra | 7185370 | 2012-02-17 15:21:59 -0800 | [diff] [blame] | 159 | .bus_freq = 2, |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 160 | .io_fraction = 33, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 161 | }, |
| 162 | { |
| 163 | .gpu_freq = 1920000000, |
Tarun Karra | 7185370 | 2012-02-17 15:21:59 -0800 | [diff] [blame] | 164 | .bus_freq = 1, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 165 | .io_fraction = 100, |
| 166 | }, |
| 167 | { |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 168 | .gpu_freq = 27000000, |
| 169 | .bus_freq = 0, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 170 | }, |
| 171 | }, |
| 172 | .init_level = 0, |
| 173 | .num_levels = 4, |
| 174 | .set_grp_async = NULL, |
| 175 | .idle_timeout = HZ/20, |
| 176 | .nap_allowed = true, |
| 177 | .clk_map = KGSL_CLK_CORE | KGSL_CLK_IFACE | KGSL_CLK_MEM_IFACE, |
| 178 | #ifdef CONFIG_MSM_BUS_SCALING |
| 179 | .bus_scale_table = &grp3d_bus_scale_pdata, |
| 180 | #endif |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 181 | .iommu_data = kgsl_3d0_iommu_data, |
| 182 | .iommu_count = ARRAY_SIZE(kgsl_3d0_iommu_data), |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 183 | }; |
| 184 | |
| 185 | struct platform_device device_kgsl_3d0 = { |
| 186 | .name = "kgsl-3d0", |
| 187 | .id = 0, |
| 188 | .num_resources = ARRAY_SIZE(kgsl_3d0_resources), |
| 189 | .resource = kgsl_3d0_resources, |
| 190 | .dev = { |
| 191 | .platform_data = &kgsl_3d0_pdata, |
| 192 | }, |
| 193 | }; |
| 194 | |
| 195 | void __init apq8064_init_gpu(void) |
| 196 | { |
| 197 | platform_device_register(&device_kgsl_3d0); |
| 198 | } |