aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile/board-kzm9g.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2012-04-10 23:58:33 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-05-12 16:34:16 -0400
commit26786111f9f291c8ab313ea31d90efdf6cfde792 (patch)
treeacdd2fb24675b33fce334c432db1a3171205698a /arch/arm/mach-shmobile/board-kzm9g.c
parentdd818180f9303eed270513e8ccd4516bb3a577f5 (diff)
ARM: mach-shmobile: kzm9g: add LCDC support
AS3711 chip initalization is required for enabling LCDC backlight, but there is no driver for this chip. So, this patch sends its settings when boot. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Tested-by: Simon Horman <horms@verge.net.au> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'arch/arm/mach-shmobile/board-kzm9g.c')
-rw-r--r--arch/arm/mach-shmobile/board-kzm9g.c143
1 files changed, 143 insertions, 0 deletions
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c
index f48db233719a..145341dbebf5 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -16,12 +16,15 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */ 18 */
19
20#include <linux/delay.h>
19#include <linux/gpio.h> 21#include <linux/gpio.h>
20#include <linux/io.h> 22#include <linux/io.h>
21#include <linux/irq.h> 23#include <linux/irq.h>
22#include <linux/platform_device.h> 24#include <linux/platform_device.h>
23#include <linux/smsc911x.h> 25#include <linux/smsc911x.h>
24#include <linux/usb/r8a66597.h> 26#include <linux/usb/r8a66597.h>
27#include <linux/videodev2.h>
25#include <mach/irqs.h> 28#include <mach/irqs.h>
26#include <mach/sh73a0.h> 29#include <mach/sh73a0.h>
27#include <mach/common.h> 30#include <mach/common.h>
@@ -29,6 +32,7 @@
29#include <asm/hardware/gic.h> 32#include <asm/hardware/gic.h>
30#include <asm/mach-types.h> 33#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 34#include <asm/mach/arch.h>
35#include <video/sh_mobile_lcdc.h>
32 36
33/* SMSC 9221 */ 37/* SMSC 9221 */
34static struct resource smsc9221_resources[] = { 38static struct resource smsc9221_resources[] = {
@@ -88,11 +92,119 @@ static struct platform_device usb_host_device = {
88 .resource = usb_resources, 92 .resource = usb_resources,
89}; 93};
90 94
95/* LCDC */
96static struct fb_videomode kzm_lcdc_mode = {
97 .name = "WVGA Panel",
98 .xres = 800,
99 .yres = 480,
100 .left_margin = 220,
101 .right_margin = 110,
102 .hsync_len = 70,
103 .upper_margin = 20,
104 .lower_margin = 5,
105 .vsync_len = 5,
106 .sync = 0,
107};
108
109static struct sh_mobile_lcdc_info lcdc_info = {
110 .clock_source = LCDC_CLK_BUS,
111 .ch[0] = {
112 .chan = LCDC_CHAN_MAINLCD,
113 .fourcc = V4L2_PIX_FMT_RGB565,
114 .interface_type = RGB24,
115 .lcd_modes = &kzm_lcdc_mode,
116 .num_modes = 1,
117 .clock_divider = 5,
118 .flags = 0,
119 .panel_cfg = {
120 .width = 152,
121 .height = 91,
122 },
123 }
124};
125
126static struct resource lcdc_resources[] = {
127 [0] = {
128 .name = "LCDC",
129 .start = 0xfe940000,
130 .end = 0xfe943fff,
131 .flags = IORESOURCE_MEM,
132 },
133 [1] = {
134 .start = intcs_evt2irq(0x580),
135 .flags = IORESOURCE_IRQ,
136 },
137};
138
139static struct platform_device lcdc_device = {
140 .name = "sh_mobile_lcdc_fb",
141 .num_resources = ARRAY_SIZE(lcdc_resources),
142 .resource = lcdc_resources,
143 .dev = {
144 .platform_data = &lcdc_info,
145 .coherent_dma_mask = ~0,
146 },
147};
148
91static struct platform_device *kzm_devices[] __initdata = { 149static struct platform_device *kzm_devices[] __initdata = {
92 &smsc_device, 150 &smsc_device,
93 &usb_host_device, 151 &usb_host_device,
152 &lcdc_device,
94}; 153};
95 154
155/*
156 * FIXME
157 *
158 * This is quick hack for enabling LCDC backlight
159 */
160static int __init as3711_enable_lcdc_backlight(void)
161{
162 struct i2c_adapter *a = i2c_get_adapter(0);
163 struct i2c_msg msg;
164 int i, ret;
165 __u8 magic[] = {
166 0x40, 0x2a,
167 0x43, 0x3c,
168 0x44, 0x3c,
169 0x45, 0x3c,
170 0x54, 0x03,
171 0x51, 0x00,
172 0x51, 0x01,
173 0xff, 0x00, /* wait */
174 0x43, 0xf0,
175 0x44, 0xf0,
176 0x45, 0xf0,
177 };
178
179 if (!machine_is_kzm9g())
180 return 0;
181
182 if (!a)
183 return 0;
184
185 msg.addr = 0x40;
186 msg.len = 2;
187 msg.flags = 0;
188
189 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
190 msg.buf = magic + i;
191
192 if (0xff == msg.buf[0]) {
193 udelay(500);
194 continue;
195 }
196
197 ret = i2c_transfer(a, &msg, 1);
198 if (ret < 0) {
199 pr_err("i2c transfer fail\n");
200 break;
201 }
202 }
203
204 return 0;
205}
206device_initcall(as3711_enable_lcdc_backlight);
207
96static void __init kzm_init(void) 208static void __init kzm_init(void)
97{ 209{
98 sh73a0_pinmux_init(); 210 sh73a0_pinmux_init();
@@ -110,6 +222,37 @@ static void __init kzm_init(void)
110 gpio_request(GPIO_PORT224, NULL); /* IRQ3 */ 222 gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
111 gpio_direction_input(GPIO_PORT224); 223 gpio_direction_input(GPIO_PORT224);
112 224
225 /* LCDC */
226 gpio_request(GPIO_FN_LCDD23, NULL);
227 gpio_request(GPIO_FN_LCDD22, NULL);
228 gpio_request(GPIO_FN_LCDD21, NULL);
229 gpio_request(GPIO_FN_LCDD20, NULL);
230 gpio_request(GPIO_FN_LCDD19, NULL);
231 gpio_request(GPIO_FN_LCDD18, NULL);
232 gpio_request(GPIO_FN_LCDD17, NULL);
233 gpio_request(GPIO_FN_LCDD16, NULL);
234 gpio_request(GPIO_FN_LCDD15, NULL);
235 gpio_request(GPIO_FN_LCDD14, NULL);
236 gpio_request(GPIO_FN_LCDD13, NULL);
237 gpio_request(GPIO_FN_LCDD12, NULL);
238 gpio_request(GPIO_FN_LCDD11, NULL);
239 gpio_request(GPIO_FN_LCDD10, NULL);
240 gpio_request(GPIO_FN_LCDD9, NULL);
241 gpio_request(GPIO_FN_LCDD8, NULL);
242 gpio_request(GPIO_FN_LCDD7, NULL);
243 gpio_request(GPIO_FN_LCDD6, NULL);
244 gpio_request(GPIO_FN_LCDD5, NULL);
245 gpio_request(GPIO_FN_LCDD4, NULL);
246 gpio_request(GPIO_FN_LCDD3, NULL);
247 gpio_request(GPIO_FN_LCDD2, NULL);
248 gpio_request(GPIO_FN_LCDD1, NULL);
249 gpio_request(GPIO_FN_LCDD0, NULL);
250 gpio_request(GPIO_FN_LCDDISP, NULL);
251 gpio_request(GPIO_FN_LCDDCK, NULL);
252
253 gpio_request(GPIO_PORT222, NULL);
254 gpio_direction_output(GPIO_PORT222, 1);
255
113#ifdef CONFIG_CACHE_L2X0 256#ifdef CONFIG_CACHE_L2X0
114 /* Early BRESP enable, Shared attribute override enable, 64K*8way */ 257 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
115 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); 258 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);