| 1 |
/* arch/arm/mach-msm/board-trout.c |
| 2 |
* |
| 3 |
* Copyright (C) 2008 Google, Inc. |
| 4 |
* |
| 5 |
* This software is licensed under the terms of the GNU General Public |
| 6 |
* License version 2, as published by the Free Software Foundation, and |
| 7 |
* may be copied, distributed, and modified under those terms. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
*/ |
| 15 |
|
| 16 |
#include <linux/kernel.h> |
| 17 |
#include <linux/init.h> |
| 18 |
#include <linux/fs.h> |
| 19 |
#include <linux/platform_device.h> |
| 20 |
#include <linux/android_pmem.h> |
| 21 |
#include <mach/board_htc.h> |
| 22 |
#include <asm/mach-types.h> |
| 23 |
|
| 24 |
#define MODULE_NAME "pmem" |
| 25 |
#define MSM_SMI_BASE 0x00000000 |
| 26 |
#define MSM_SMI2_BASE 0x02000000 |
| 27 |
#define MSM_EBI_BASE 0x10000000 |
| 28 |
#define MSM_EBIN_BASE 0x20000000 |
| 29 |
|
| 30 |
/* Copy paste from devices_htc.c |
| 31 |
*/ |
| 32 |
|
| 33 |
static struct android_pmem_platform_data pmem_pdata = { |
| 34 |
.name = "pmem", |
| 35 |
.no_allocator = 1, |
| 36 |
.cached = 1, |
| 37 |
}; |
| 38 |
|
| 39 |
static struct android_pmem_platform_data pmem_adsp_pdata = { |
| 40 |
.name = "pmem_adsp", |
| 41 |
.no_allocator = 0, |
| 42 |
.cached = 0, |
| 43 |
}; |
| 44 |
|
| 45 |
static struct android_pmem_platform_data pmem_camera_pdata = { |
| 46 |
.name = "pmem_camera", |
| 47 |
.no_allocator = 0, |
| 48 |
.cached = 0, |
| 49 |
}; |
| 50 |
|
| 51 |
static struct android_pmem_platform_data pmem_gpu0_pdata = { |
| 52 |
.name = "pmem_gpu0", |
| 53 |
.no_allocator = 1, |
| 54 |
.cached = 0, |
| 55 |
.buffered = 1, |
| 56 |
}; |
| 57 |
|
| 58 |
static struct android_pmem_platform_data pmem_gpu1_pdata = { |
| 59 |
.name = "pmem_gpu1", |
| 60 |
.no_allocator = 1, |
| 61 |
.cached = 0, |
| 62 |
.buffered = 1, |
| 63 |
}; |
| 64 |
|
| 65 |
static struct platform_device pmem_device = { |
| 66 |
.name = "android_pmem", |
| 67 |
.id = 0, |
| 68 |
.dev = { .platform_data = &pmem_pdata }, |
| 69 |
}; |
| 70 |
|
| 71 |
static struct platform_device pmem_adsp_device = { |
| 72 |
.name = "android_pmem", |
| 73 |
.id = 1, |
| 74 |
.dev = { .platform_data = &pmem_adsp_pdata }, |
| 75 |
}; |
| 76 |
|
| 77 |
static struct platform_device pmem_gpu0_device = { |
| 78 |
.name = "android_pmem", |
| 79 |
.id = 2, |
| 80 |
.dev = { .platform_data = &pmem_gpu0_pdata }, |
| 81 |
}; |
| 82 |
|
| 83 |
static struct platform_device pmem_gpu1_device = { |
| 84 |
.name = "android_pmem", |
| 85 |
.id = 3, |
| 86 |
.dev = { .platform_data = &pmem_gpu1_pdata }, |
| 87 |
}; |
| 88 |
|
| 89 |
static struct platform_device pmem_camera_device = { |
| 90 |
.name = "android_pmem", |
| 91 |
.id = 4, |
| 92 |
.dev = { .platform_data = &pmem_camera_pdata }, |
| 93 |
}; |
| 94 |
|
| 95 |
static struct resource ram_console_resource[] = { |
| 96 |
{ |
| 97 |
.flags = IORESOURCE_MEM, |
| 98 |
} |
| 99 |
}; |
| 100 |
|
| 101 |
static struct platform_device ram_console_device = { |
| 102 |
.name = "ram_console", |
| 103 |
.id = -1, |
| 104 |
.num_resources = ARRAY_SIZE(ram_console_resource), |
| 105 |
.resource = ram_console_resource, |
| 106 |
}; |
| 107 |
|
| 108 |
/* Eclair hw3d */ |
| 109 |
static struct resource resources_hw3d[] = { |
| 110 |
{ |
| 111 |
.start = 0xA0000000, |
| 112 |
.end = 0xA00fffff, |
| 113 |
.flags = IORESOURCE_MEM, |
| 114 |
.name = "regs", |
| 115 |
}, |
| 116 |
{ |
| 117 |
.flags = IORESOURCE_MEM, |
| 118 |
.name = "smi", |
| 119 |
}, |
| 120 |
{ |
| 121 |
.flags = IORESOURCE_MEM, |
| 122 |
.name = "ebi", |
| 123 |
}, |
| 124 |
{ |
| 125 |
.start = INT_GRAPHICS, |
| 126 |
.end = INT_GRAPHICS, |
| 127 |
.flags = IORESOURCE_IRQ, |
| 128 |
.name = "gfx", |
| 129 |
}, |
| 130 |
}; |
| 131 |
|
| 132 |
static struct platform_device hw3d_device = { |
| 133 |
.name = "msm_hw3d", |
| 134 |
.id = 0, |
| 135 |
.num_resources = ARRAY_SIZE(resources_hw3d), |
| 136 |
.resource = resources_hw3d, |
| 137 |
}; |
| 138 |
|
| 139 |
|
| 140 |
void __init msm_add_mem_devices(struct msm_pmem_setting *setting) |
| 141 |
{ |
| 142 |
if (setting->pmem_size) { |
| 143 |
pmem_pdata.start = setting->pmem_start; |
| 144 |
pmem_pdata.size = setting->pmem_size; |
| 145 |
platform_device_register(&pmem_device); |
| 146 |
} |
| 147 |
|
| 148 |
if (setting->pmem_adsp_size) { |
| 149 |
pmem_adsp_pdata.start = setting->pmem_adsp_start; |
| 150 |
pmem_adsp_pdata.size = setting->pmem_adsp_size; |
| 151 |
platform_device_register(&pmem_adsp_device); |
| 152 |
} |
| 153 |
|
| 154 |
if (setting->pmem_gpu0_size) { |
| 155 |
pmem_gpu0_pdata.start = setting->pmem_gpu0_start; |
| 156 |
pmem_gpu0_pdata.size = setting->pmem_gpu0_size; |
| 157 |
platform_device_register(&pmem_gpu0_device); |
| 158 |
} |
| 159 |
|
| 160 |
if (setting->pmem_gpu1_size) { |
| 161 |
pmem_gpu1_pdata.start = setting->pmem_gpu1_start; |
| 162 |
pmem_gpu1_pdata.size = setting->pmem_gpu1_size; |
| 163 |
platform_device_register(&pmem_gpu1_device); |
| 164 |
} |
| 165 |
|
| 166 |
#if defined(CONFIG_MSM_HW3D) |
| 167 |
/* Eclair hw3d */ |
| 168 |
if (setting->pmem_gpu0_size || setting->pmem_gpu1_size) { |
| 169 |
struct resource *res; |
| 170 |
res=platform_get_resource_byname(&hw3d_device, IORESOURCE_MEM, "smi"); |
| 171 |
res->start=setting->pmem_gpu0_start; |
| 172 |
res->end=setting->pmem_gpu0_start+setting->pmem_gpu0_size-1; |
| 173 |
res=platform_get_resource_byname(&hw3d_device, IORESOURCE_MEM, "ebi"); |
| 174 |
res->start=setting->pmem_gpu1_start; |
| 175 |
res->end=setting->pmem_gpu1_start+setting->pmem_gpu1_size-1; |
| 176 |
platform_device_register(&hw3d_device); |
| 177 |
} |
| 178 |
#endif |
| 179 |
if (setting->pmem_camera_size) { |
| 180 |
pmem_camera_pdata.start = setting->pmem_camera_start; |
| 181 |
pmem_camera_pdata.size = setting->pmem_camera_size; |
| 182 |
platform_device_register(&pmem_camera_device); |
| 183 |
} |
| 184 |
|
| 185 |
if (setting->ram_console_size) { |
| 186 |
ram_console_resource[0].start = setting->ram_console_start; |
| 187 |
ram_console_resource[0].end = setting->ram_console_start |
| 188 |
+ setting->ram_console_size - 1; |
| 189 |
platform_device_register(&ram_console_device); |
| 190 |
} |
| 191 |
} |
| 192 |
/* |
| 193 |
* End of paste*/ |
| 194 |
static struct msm_pmem_setting pmem_setting = { |
| 195 |
/* |
| 196 |
* For reference only |
| 197 |
.pmem_start = MSM_PMEM_MDP_BASE, |
| 198 |
.pmem_size = MSM_PMEM_MDP_SIZE, |
| 199 |
.pmem_adsp_start = MSM_PMEM_ADSP_BASE, |
| 200 |
.pmem_adsp_size = MSM_PMEM_ADSP_SIZE, |
| 201 |
.pmem_gpu0_start = MSM_PMEM_GPU0_BASE, |
| 202 |
.pmem_gpu0_size = MSM_PMEM_GPU0_SIZE, |
| 203 |
.pmem_gpu1_start = MSM_PMEM_GPU1_BASE, |
| 204 |
.pmem_gpu1_size = MSM_PMEM_GPU1_SIZE, |
| 205 |
.pmem_camera_start = MSM_PMEM_CAMERA_BASE, |
| 206 |
.pmem_camera_size = MSM_PMEM_CAMERA_SIZE, |
| 207 |
.ram_console_start = MSM_RAM_CONSOLE_BASE, |
| 208 |
.ram_console_size = MSM_RAM_CONSOLE_SIZE, |
| 209 |
*/ |
| 210 |
}; |
| 211 |
struct resource resources_msm_fb[]={ |
| 212 |
{ |
| 213 |
}, |
| 214 |
}; |
| 215 |
#define CALC_PMEM(name, prev, size) \ |
| 216 |
pmem_setting.name## _start = pmem_setting.prev## _start+\ |
| 217 |
pmem_setting.prev## _size;\ |
| 218 |
pmem_setting.name## _size = size; |
| 219 |
|
| 220 |
#define CALC_PMEM_BEFORE(name, prev, size) \ |
| 221 |
pmem_setting.name## _start = pmem_setting.prev## _start-\ |
| 222 |
size;\ |
| 223 |
pmem_setting.name## _size = size; |
| 224 |
|
| 225 |
//#define RHODIUM_USE_SMI2 /* CAUTION : if enabled here, must also be enabled in board-htcrhodium.c */ |
| 226 |
|
| 227 |
static int __init msm_pmem_init(void) { |
| 228 |
long pmem_shift = 0; |
| 229 |
switch(__machine_arch_type) { |
| 230 |
case MACH_TYPE_HTCDIAMOND: |
| 231 |
case MACH_TYPE_HTCRAPHAEL_CDMA500: |
| 232 |
//SMI 64 + EBI 128 |
| 233 |
pmem_setting.pmem_start=MSM_SMI2_BASE; |
| 234 |
pmem_setting.pmem_size=14*1024*1024; // Use 14Mb. Might be reduced down to 12Mb if required. |
| 235 |
CALC_PMEM(pmem_adsp, pmem, 8*1024*1024); // 8Mb for ADSP Jpeg + Video processing |
| 236 |
CALC_PMEM(pmem_camera, pmem_adsp, 8*1024*1024); // 8Mb for Camera preview buffers + snap ( 3MP sensor : 2064 * 1544 * (3 / 2) = 4780224 bytes = 4.56Mb) |
| 237 |
CALC_PMEM(fb, pmem_camera, 2*1024*1024); // 640*480*2 (2byte/pixel)(Or 3?) *2 (front+back buffer)=1.2MiB |
| 238 |
//Total 32MB |
| 239 |
|
| 240 |
//GPU1 must be in EBI bank 1 |
| 241 |
pmem_setting.pmem_gpu1_start=MSM_EBI_BASE+107*1024*1024; |
| 242 |
pmem_setting.pmem_gpu1_size=0x800000; |
| 243 |
|
| 244 |
// Ram console not working when placed at the end of SMI2 |
| 245 |
// Put it at the end of EBI1 before the GPU1 |
| 246 |
CALC_PMEM_BEFORE(ram_console, pmem_gpu1, 1*1024*1024); |
| 247 |
break; |
| 248 |
case MACH_TYPE_HTCRAPHAEL: |
| 249 |
case MACH_TYPE_HTCRAPHAEL_CDMA: |
| 250 |
case MACH_TYPE_HTCDIAMOND_CDMA: |
| 251 |
//SMI 32 + EBI 2*128 or 1*256 (newer htctopaz) |
| 252 |
pmem_setting.pmem_start=MSM_EBIN_BASE+128*1024*1024-50*1024*1024; |
| 253 |
pmem_setting.pmem_size=32*1024*1024; // 32MB |
| 254 |
CALC_PMEM(pmem_adsp, pmem, 8*1024*1024); // 8Mb for ADSP Jpeg + Video processing |
| 255 |
CALC_PMEM(pmem_camera, pmem_adsp, 8*1024*1024); // 8Mb for Camera preview buffers ( 3MP sensor : 2064 * 1544 * (3 / 2) = 4780224 bytes = 4.56Mb) |
| 256 |
CALC_PMEM(fb, pmem_camera, 2*1024*1024); // 640*480*2 (2byte/pixel)(Or 3?) *2 (front+back buffer)=1.2MiB |
| 257 |
//Total 50MB |
| 258 |
|
| 259 |
pmem_setting.pmem_gpu1_start=MSM_EBI_BASE+107*1024*1024; |
| 260 |
pmem_setting.pmem_gpu1_size=8*1024*1024; |
| 261 |
|
| 262 |
pmem_setting.ram_console_start=0x8e0000; |
| 263 |
pmem_setting.ram_console_size=0x20000; |
| 264 |
break; |
| 265 |
case MACH_TYPE_HTCBLACKSTONE: |
| 266 |
case MACH_TYPE_HTCTOPAZ: |
| 267 |
case MACH_TYPE_HTCKOVSKY: |
| 268 |
//SMI 32 + EBI 2*128 or 1*256 (newer htctopaz) |
| 269 |
|
| 270 |
// only htctopaz for now |
| 271 |
if (board_mcp_monodie()) { |
| 272 |
// we can start right after the first 128MB |
| 273 |
pmem_shift = 0x8000000; |
| 274 |
} |
| 275 |
|
| 276 |
pmem_setting.pmem_start=MSM_EBIN_BASE+128*1024*1024-50*1024*1024-pmem_shift; |
| 277 |
pmem_setting.pmem_size=32*1024*1024; // 32MB |
| 278 |
CALC_PMEM(pmem_adsp, pmem, 8*1024*1024); // 8Mb for ADSP Jpeg + Video processing |
| 279 |
CALC_PMEM(pmem_camera, pmem_adsp, 8*1024*1024); // 8Mb for Camera preview buffers + snap ( 5MP sensor : 2608 * 1960 * (3 / 2) = 7667520 bytes = 7.31Mb) |
| 280 |
CALC_PMEM(fb, pmem_camera, 2*1024*1024); // 640*480*2 (2byte/pixel)(Or 3?) *2 (front+back buffer)=1.2MiB |
| 281 |
//Total 50MB |
| 282 |
|
| 283 |
if (machine_is_htctopaz()) { |
| 284 |
// wince oemaddresstable gives us 0-112mb usable range, |
| 285 |
// so set up 104mb for bank0 and 8mb for gpu1 (=112mb) |
| 286 |
// (confirmed to not work on topa when gpu1 mem exceeds |
| 287 |
// 112mb) <- cause : part of amss is loaded @0x17000000 |
| 288 |
pmem_setting.pmem_gpu1_start=MSM_EBI_BASE+104*1024*1024; |
| 289 |
} else { |
| 290 |
pmem_setting.pmem_gpu1_start=MSM_EBI_BASE+107*1024*1024; |
| 291 |
} |
| 292 |
pmem_setting.pmem_gpu1_size=8*1024*1024; |
| 293 |
|
| 294 |
pmem_setting.ram_console_start=0x8e0000; |
| 295 |
pmem_setting.ram_console_size=0x20000; |
| 296 |
break; |
| 297 |
case MACH_TYPE_HTCRHODIUM: |
| 298 |
//SMI 64 + EBI 2*128 |
| 299 |
|
| 300 |
#ifdef RHODIUM_USE_SMI2 |
| 301 |
/* SMI2 might also be used for some others memory regions |
| 302 |
* but ADSP does not seems to be able to work with it |
| 303 |
* so leave the adsp pmem in the EBI |
| 304 |
*/ |
| 305 |
pmem_setting.pmem_camera_start=MSM_SMI2_BASE; |
| 306 |
pmem_setting.pmem_camera_size=8*1024*1024; // 8Mb for Camera preview buffers + snap ( 3MP sensor : 2064 * 1544 * (3 / 2) = 4780224 bytes = 4.56Mb) |
| 307 |
#endif |
| 308 |
|
| 309 |
pmem_setting.pmem_size=32*1024*1024; // 32MB |
| 310 |
#ifdef RHODIUM_USE_SMI2 |
| 311 |
pmem_setting.pmem_start=MSM_EBIN_BASE+128*1024*1024-42*1024*1024; |
| 312 |
CALC_PMEM(pmem_adsp, pmem, 8*1024*1024); // 8Mb for ADSP Jpeg + Video processing |
| 313 |
CALC_PMEM(fb, pmem_adsp, 2*1024*1024); // 640*480*2 (2byte/pixel)(Or 3?) *2 (front+back buffer)=1.2MiB |
| 314 |
#else |
| 315 |
pmem_setting.pmem_start=MSM_EBIN_BASE+128*1024*1024-50*1024*1024; |
| 316 |
CALC_PMEM(pmem_adsp, pmem, 8*1024*1024); // 8Mb for ADSP Jpeg + Video processing |
| 317 |
CALC_PMEM(pmem_camera, pmem_adsp, 8*1024*1024); // 8Mb for Camera preview buffers + snap ( 3MP sensor : 2064 * 1544 * (3 / 2) = 4780224 bytes = 4.56Mb) |
| 318 |
CALC_PMEM(fb, pmem_camera, 2*1024*1024); // 640*480*2 (2byte/pixel)(Or 3?) *2 (front+back buffer)=1.2MiB |
| 319 |
#endif |
| 320 |
//Total 42/50MB |
| 321 |
|
| 322 |
// wince oemaddresstable gives us 0-107mb usable range, |
| 323 |
// so set up 99mb for bank0 and 8mb for gpu1 (=107mb) |
| 324 |
pmem_setting.pmem_gpu1_start=MSM_EBI_BASE+99*1024*1024; |
| 325 |
pmem_setting.pmem_gpu1_size=8*1024*1024; |
| 326 |
pmem_setting.ram_console_start=0x8e0000; |
| 327 |
pmem_setting.ram_console_size=0x20000; |
| 328 |
break; |
| 329 |
default: |
| 330 |
//SMI 32 + EBI 128 |
| 331 |
//So much things for so few memory |
| 332 |
|
| 333 |
pmem_setting.pmem_start=MSM_EBI_BASE+89*1024*1024; |
| 334 |
pmem_setting.pmem_size=0x800000;//8MB |
| 335 |
CALC_PMEM(pmem_adsp, pmem, 0x800000);//8MB |
| 336 |
CALC_PMEM(fb, pmem_adsp, 0x200000);//2MB |
| 337 |
CALC_PMEM(pmem_camera, fb, 0x100000);//1MB |
| 338 |
} |
| 339 |
//GPU0 must be in SMI1 |
| 340 |
pmem_setting.pmem_gpu0_start=MSM_SMI_BASE+1024*1024; |
| 341 |
pmem_setting.pmem_gpu0_size=0x700000; |
| 342 |
resources_msm_fb[0].start=pmem_setting.fb_start; |
| 343 |
resources_msm_fb[0].end=pmem_setting.fb_start+pmem_setting.fb_size; |
| 344 |
resources_msm_fb[0].flags=IORESOURCE_MEM; |
| 345 |
msm_add_mem_devices(&pmem_setting); |
| 346 |
|
| 347 |
return 0; |
| 348 |
} |
| 349 |
module_init(msm_pmem_init); |
| 350 |
|
| 351 |
MODULE_DESCRIPTION("PMEM settings"); |
| 352 |
MODULE_AUTHOR("HUSSON Pierre-Hugues <phhusson@free.fr>"); |
| 353 |
MODULE_LICENSE("GPL"); |