aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-msm/board-9615-display.c
blob: 4b355d0ce033c5b06c31a3d5c2bcb0f37afb950d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/platform_device.h>
#include <linux/bootmem.h>
#include <linux/msm_ion.h>
#include <asm/mach-types.h>
#include <mach/msm_memtypes.h>
#include <mach/board.h>
#include <mach/gpio.h>
#include <mach/gpiomux.h>
#include <mach/ion.h>
#include <mach/msm_bus_board.h>

#include "devices.h"
#include "board-9615.h"

/* prim = 240 x 320 x 4(bpp) x 2(pages) */
#define MSM_FB_PRIM_BUF_SIZE roundup(240 * 320 * 4 * 2, 0x10000)
#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE, 4096)

#define GPIO_PIN_EBI2_LCD_A_D	21
#define GPIO_PIN_EBI2_LCD_CS	22
#define GPIO_PIN_EBI2_LCD_RS	24


#ifdef CONFIG_FB_MSM

static struct resource msm_fb_resources[] = {
	{
		.flags = IORESOURCE_MEM,
	}
};

static int msm_fb_detect_panel(const char *name)
{
	return 0;
}

static struct msm_fb_platform_data msm_fb_pdata = {
	.detect_client = msm_fb_detect_panel,
};

static struct platform_device msm_fb_device = {
	.name              = "msm_fb",
	.id                = 0,
	.num_resources     = ARRAY_SIZE(msm_fb_resources),
	.resource          = msm_fb_resources,
	.dev.platform_data = &msm_fb_pdata,
};

void __init mdm9615_allocate_fb_region(void)
{
	void *addr;
	unsigned long size;

	size = MSM_FB_SIZE;
	addr = alloc_bootmem_align(size, 0x1000);
	msm_fb_resources[0].start = __pa(addr);
	msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
	pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
			size, addr, __pa(addr));
}


static bool ebi2_power_init;
static int ebi2_panel_power(int on)
{
	static struct regulator *panel_power;
	int rc;

	pr_debug("%s: on=%d\n", __func__, on);

	if (!ebi2_power_init) {
		panel_power = regulator_get(&msm_ebi2_lcdc_device.dev,
				"VDDI2");
		if (IS_ERR_OR_NULL(panel_power)) {
			pr_err("could not get L14, rc = %ld\n",
				PTR_ERR(panel_power));
			return -ENODEV;
		}

		rc = regulator_set_voltage(panel_power, 2800000, 3800000);
		if (rc) {
			pr_err("set_voltage L14 failed, rc=%d\n", rc);
			return -EINVAL;
		}

		ebi2_power_init = true;
	}

	if (on) {
		rc = regulator_enable(panel_power);
		if (rc) {
			pr_err("enable L14 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		rc = gpio_request(GPIO_PIN_EBI2_LCD_A_D, "disp_a_d");
		if (rc) {
			pr_err("request gpio EBI2_LCD_A_D failed, rc=%d\n", rc);
			goto error1;
		}
		rc = gpio_request(GPIO_PIN_EBI2_LCD_CS, "disp_cs");
		if (rc) {
			pr_err("request gpio EBI2_LCD_CS failed, rc=%d\n", rc);
			goto error2;
		}
		rc = gpio_request(GPIO_PIN_EBI2_LCD_RS, "disp_rs");
		if (rc) {
			pr_err("request gpio EBI2_LCD_RS failed, rc=%d\n", rc);
			goto error3;
		}
	} else {
		gpio_free(GPIO_PIN_EBI2_LCD_RS);
		gpio_free(GPIO_PIN_EBI2_LCD_CS);
		gpio_free(GPIO_PIN_EBI2_LCD_A_D);

		rc = regulator_disable(panel_power);
		if (rc) {
			pr_err("disable L14 failed, rc=%d\n", rc);
			return -ENODEV;
		}
	}

	return 0;
error3:
	gpio_free(GPIO_PIN_EBI2_LCD_CS);
error2:
	gpio_free(GPIO_PIN_EBI2_LCD_A_D);
error1:
	regulator_disable(panel_power);
	return rc;

}

static struct lcdc_platform_data ebi2_lcdc_pdata = {
	.lcdc_power_save = ebi2_panel_power,
};

static struct lvds_panel_platform_data ebi2_epson_s1d_pdata;

static struct platform_device ebi2_epson_s1d_panel_device = {
	.name = "ebi2_epson_s1d_qvga",
	.id = 0,
	.dev = {
		.platform_data = &ebi2_epson_s1d_pdata,
	}
};

void __init mdm9615_init_fb(void)
{
	platform_device_register(&msm_fb_device);
	platform_device_register(&ebi2_epson_s1d_panel_device);

	msm_fb_register_device("ebi2_lcd", &ebi2_lcdc_pdata);
}
#endif