Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [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> |
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 */ |
| 91 | .end = 0x0431ffff, |
| 92 | .flags = IORESOURCE_MEM, |
| 93 | }, |
| 94 | { |
| 95 | .name = KGSL_3D0_IRQ, |
| 96 | .start = GFX3D_IRQ, |
| 97 | .end = GFX3D_IRQ, |
| 98 | .flags = IORESOURCE_IRQ, |
| 99 | }, |
| 100 | }; |
| 101 | |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 102 | static const struct kgsl_iommu_ctx kgsl_3d0_iommu0_ctxs[] = { |
| 103 | { "gfx3d_user", 0 }, |
| 104 | { "gfx3d_priv", 1 }, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | static struct kgsl_device_iommu_data kgsl_3d0_iommu_data[] = { |
| 108 | { |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 109 | .iommu_ctxs = kgsl_3d0_iommu0_ctxs, |
| 110 | .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu0_ctxs), |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 111 | .physstart = 0x07C00000, |
| 112 | .physend = 0x07C00000 + SZ_1M - 1, |
| 113 | }, |
| 114 | }; |
| 115 | |
| 116 | static struct kgsl_device_platform_data kgsl_3d0_pdata = { |
| 117 | .pwrlevel = { |
| 118 | { |
Sudhakara Rao Tentu | 18481ea | 2012-04-25 03:51:50 -0700 | [diff] [blame] | 119 | .gpu_freq = 400000000, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 120 | .bus_freq = 3, |
| 121 | .io_fraction = 0, |
| 122 | }, |
| 123 | { |
Sudhakara Rao Tentu | ef9d75e | 2012-03-30 09:21:42 -0700 | [diff] [blame] | 124 | .gpu_freq = 320000000, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 125 | .bus_freq = 2, |
| 126 | .io_fraction = 33, |
| 127 | }, |
| 128 | { |
Sudhakara Rao Tentu | ef9d75e | 2012-03-30 09:21:42 -0700 | [diff] [blame] | 129 | .gpu_freq = 192000000, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 130 | .bus_freq = 1, |
| 131 | .io_fraction = 100, |
| 132 | }, |
| 133 | { |
| 134 | .gpu_freq = 27000000, |
| 135 | .bus_freq = 0, |
| 136 | }, |
| 137 | }, |
Lucille Sylvester | 7e3941b | 2012-06-29 11:57:43 -0600 | [diff] [blame] | 138 | .init_level = 1, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 139 | .num_levels = 4, |
| 140 | .set_grp_async = NULL, |
Sudhakara Rao Tentu | ef9d75e | 2012-03-30 09:21:42 -0700 | [diff] [blame] | 141 | .idle_timeout = HZ/12, |
| 142 | .nap_allowed = true, |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 143 | .clk_map = KGSL_CLK_CORE | KGSL_CLK_IFACE | KGSL_CLK_MEM_IFACE, |
| 144 | #ifdef CONFIG_MSM_BUS_SCALING |
| 145 | .bus_scale_table = &grp3d_bus_scale_pdata, |
| 146 | #endif |
| 147 | .iommu_data = kgsl_3d0_iommu_data, |
| 148 | .iommu_count = ARRAY_SIZE(kgsl_3d0_iommu_data), |
| 149 | }; |
| 150 | |
| 151 | static struct platform_device device_kgsl_3d0 = { |
| 152 | .name = "kgsl-3d0", |
| 153 | .id = 0, |
| 154 | .num_resources = ARRAY_SIZE(kgsl_3d0_resources), |
| 155 | .resource = kgsl_3d0_resources, |
| 156 | .dev = { |
| 157 | .platform_data = &kgsl_3d0_pdata, |
| 158 | }, |
| 159 | }; |
| 160 | |
| 161 | void __init msm8930_init_gpu(void) |
| 162 | { |
Sudhakara Rao Tentu | 87c4e8e | 2012-06-20 14:42:58 +0530 | [diff] [blame] | 163 | if (cpu_is_msm8627()) |
| 164 | kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 400000000; |
| 165 | |
Sudhakara Rao Tentu | 8b5c8ed | 2012-03-05 14:48:41 +0530 | [diff] [blame] | 166 | platform_device_register(&device_kgsl_3d0); |
| 167 | } |