Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [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/ioport.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/bootmem.h> |
| 18 | #include <asm/mach-types.h> |
| 19 | #include <mach/msm_memtypes.h> |
| 20 | #include <mach/board.h> |
| 21 | #include <mach/gpio.h> |
| 22 | #include <mach/gpiomux.h> |
| 23 | #include <linux/ion.h> |
| 24 | #include <mach/ion.h> |
| 25 | |
| 26 | #include "devices.h" |
| 27 | #include "board-8064.h" |
| 28 | |
| 29 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
| 30 | /* prim = 1366 x 768 x 3(bpp) x 3(pages) */ |
| 31 | #define MSM_FB_PRIM_BUF_SIZE roundup(1366 * 768 * 3 * 3, 0x10000) |
| 32 | #else |
| 33 | /* prim = 1366 x 768 x 3(bpp) x 2(pages) */ |
| 34 | #define MSM_FB_PRIM_BUF_SIZE roundup(1366 * 768 * 3 * 2, 0x10000) |
| 35 | #endif |
| 36 | |
| 37 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
| 38 | /* hdmi = 1920 x 1088 x 2(bpp) x 1(page) */ |
| 39 | #define MSM_FB_EXT_BUF_SIZE 0x3FC000 |
| 40 | #elif defined(CONFIG_FB_MSM_TVOUT) |
| 41 | /* tvout = 720 x 576 x 2(bpp) x 2(pages) */ |
| 42 | #define MSM_FB_EXT_BUF_SIZE 0x195000 |
| 43 | #else /* CONFIG_FB_MSM_HDMI_MSM_PANEL */ |
| 44 | #define MSM_FB_EXT_BUF_SIZE 0 |
| 45 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */ |
| 46 | |
| 47 | #define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE, 4096) |
| 48 | |
| 49 | #ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK |
| 50 | #define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096) |
| 51 | #else |
| 52 | #define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0) |
| 53 | #endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */ |
| 54 | |
| 55 | #ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK |
| 56 | #define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096) |
| 57 | #else |
| 58 | #define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0) |
| 59 | #endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */ |
| 60 | |
| 61 | static struct resource msm_fb_resources[] = { |
| 62 | { |
| 63 | .flags = IORESOURCE_DMA, |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | #define SIMULATOR_PANAL_NAME "mipi_video_simulator" |
| 68 | #define SIMULATOR_PANAL_NAME_LEN 20 |
| 69 | #define LVDS_CHIMEI_PANEL_NAME "lvds_chimei_wxga" |
| 70 | #define LVDS_CHIMEI_PANEL_NAME_LEN 16 |
| 71 | |
| 72 | static int msm_fb_detect_panel(const char *name) |
| 73 | { |
| 74 | if (!strncmp(name, LVDS_CHIMEI_PANEL_NAME, |
| 75 | LVDS_CHIMEI_PANEL_NAME_LEN)) |
| 76 | return 0; |
| 77 | return -ENODEV; |
| 78 | } |
| 79 | |
| 80 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 81 | .detect_client = msm_fb_detect_panel, |
| 82 | }; |
| 83 | |
| 84 | static struct platform_device msm_fb_device = { |
| 85 | .name = "msm_fb", |
| 86 | .id = 0, |
| 87 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 88 | .resource = msm_fb_resources, |
| 89 | .dev.platform_data = &msm_fb_pdata, |
| 90 | }; |
| 91 | |
| 92 | void __init apq8064_allocate_fb_region(void) |
| 93 | { |
| 94 | void *addr; |
| 95 | unsigned long size; |
| 96 | |
| 97 | size = MSM_FB_SIZE; |
| 98 | addr = alloc_bootmem_align(size, 0x1000); |
| 99 | msm_fb_resources[0].start = __pa(addr); |
| 100 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 101 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", |
| 102 | size, addr, __pa(addr)); |
| 103 | } |
| 104 | |
| 105 | #define MDP_VSYNC_GPIO 0 |
| 106 | |
| 107 | static int mdp_core_clk_rate_table[] = { |
| 108 | 266667000, |
| 109 | 266667000, |
| 110 | 266667000, |
| 111 | 266667000, |
| 112 | }; |
| 113 | |
| 114 | static struct msm_panel_common_pdata mdp_pdata = { |
| 115 | .gpio = MDP_VSYNC_GPIO, |
| 116 | .mdp_core_clk_rate = 266667000, |
| 117 | .mdp_core_clk_table = mdp_core_clk_rate_table, |
| 118 | .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table), |
| 119 | .mdp_rev = MDP_REV_44, |
| 120 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
| 121 | .mem_hid = ION_CP_MM_HEAP_ID, |
| 122 | #else |
| 123 | .mem_hid = MEMTYPE_EBI1, |
| 124 | #endif |
| 125 | }; |
| 126 | |
| 127 | void __init apq8064_mdp_writeback(struct memtype_reserve* reserve_table) |
| 128 | { |
| 129 | mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE; |
| 130 | mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE; |
| 131 | #if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION) |
| 132 | reserve_table[mdp_pdata.mem_hid].size += |
| 133 | mdp_pdata.ov0_wb_size; |
| 134 | reserve_table[mdp_pdata.mem_hid].size += |
| 135 | mdp_pdata.ov1_wb_size; |
| 136 | #endif |
| 137 | } |
| 138 | |
| 139 | void __init apq8064_init_fb(void) |
| 140 | { |
| 141 | platform_device_register(&msm_fb_device); |
| 142 | msm_fb_register_device("mdp", &mdp_pdata); |
| 143 | msm_fb_register_device("lvds", NULL); |
| 144 | } |