1 /* linux/arch/arm/mach-s5pv310/setup-fb.c
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
6 * Base FIMD controller configuration
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/clk.h>
14 #include <linux/delay.h>
15 #include <linux/err.h>
16 #include <linux/gpio.h>
17 #include <linux/kernel.h>
18 #include <linux/platform_device.h>
19 #include <linux/types.h>
20 #include <plat/clock.h>
21 #include <plat/gpio-cfg.h>
22 #include <mach/regs-clock.h>
23 #include <mach/regs-gpio.h>
26 #include <mach/gpio.h>
27 /* #include <mach/pd.h> */
29 struct platform_device; /* don't need the contents */
31 void s3cfb_cfg_gpio(struct platform_device *pdev)
36 for (i = 0; i < 8; i++) {
37 s3c_gpio_cfgpin(S5PV310_GPF0(i), S3C_GPIO_SFN(2));
38 s3c_gpio_setpull(S5PV310_GPF0(i), S3C_GPIO_PULL_NONE);
39 s5p_gpio_set_drvstr(S5PV310_GPF0(i), S5P_GPIO_DRVSTR_LV4);
42 for (i = 0; i < 8; i++) {
43 s3c_gpio_cfgpin(S5PV310_GPF1(i), S3C_GPIO_SFN(2));
44 s3c_gpio_setpull(S5PV310_GPF1(i), S3C_GPIO_PULL_NONE);
45 s5p_gpio_set_drvstr(S5PV310_GPF1(i), S5P_GPIO_DRVSTR_LV4);
48 for (i = 0; i < 8; i++) {
49 s3c_gpio_cfgpin(S5PV310_GPF2(i), S3C_GPIO_SFN(2));
50 s3c_gpio_setpull(S5PV310_GPF2(i), S3C_GPIO_PULL_NONE);
51 s5p_gpio_set_drvstr(S5PV310_GPF2(i), S5P_GPIO_DRVSTR_LV4);
54 for (i = 0; i < 4; i++) {
55 s3c_gpio_cfgpin(S5PV310_GPF3(i), S3C_GPIO_SFN(2));
56 s3c_gpio_setpull(S5PV310_GPF3(i), S3C_GPIO_PULL_NONE);
57 s5p_gpio_set_drvstr(S5PV310_GPF3(i), S5P_GPIO_DRVSTR_LV4);
60 /* Set FIMD0 bypass */
61 reg = __raw_readl(S3C_VA_SYS + 0x0210);
63 __raw_writel(reg, S3C_VA_SYS + 0x0210);
66 int s3cfb_clk_setup(struct platform_device *pdev, struct clk **out_clk)
68 struct clk *sclk = NULL;
69 struct clk *mout_mpll = NULL;
70 struct clk *lcd_clk = NULL;
74 lcd_clk = clk_get(&pdev->dev, "fimd0");
75 if (IS_ERR(lcd_clk)) {
76 dev_err(&pdev->dev, "failed to get lcd_clk for fimd\n");
80 sclk = clk_get(&pdev->dev, "sclk_fimd0");
82 dev_err(&pdev->dev, "failed to get sclk for fimd\n");
86 lcd_clk->parent = sclk;
88 mout_mpll = clk_get(&pdev->dev, "mout_mpll");
89 if (IS_ERR(mout_mpll)) {
90 dev_err(&pdev->dev, "failed to get mout_mpll\n");
94 clk_set_parent(sclk, mout_mpll);
99 clk_set_rate(sclk, rate);
100 dev_dbg(&pdev->dev, "set fimd sclk rate to %d\n", rate);
121 int s3cfb_clk_on(struct platform_device *pdev, struct clk *in_clk,
132 void s3cfb_get_clk_name(char *clk_name)
134 strcpy(clk_name, "sclk_fimd");
137 #ifdef CONFIG_FB_S3C_WA101S
138 int s3cfb_backlight_on(struct platform_device *pdev)
140 #if !defined(CONFIG_BACKLIGHT_PWM)
143 err = gpio_request(S5PV310_GPD0(1), "GPD0");
145 printk(KERN_ERR "failed to request GPD0 for "
146 "lcd backlight control\n");
150 gpio_direction_output(S5PV310_GPD0(1), 1);
151 gpio_free(S5PV310_GPD0(1));
156 int s3cfb_backlight_off(struct platform_device *pdev)
158 #if !defined(CONFIG_BACKLIGHT_PWM)
161 err = gpio_request(S5PV310_GPD0(1), "GPD0");
163 printk(KERN_ERR "failed to request GPD0 for "
164 "lcd backlight control\n");
168 gpio_direction_output(S5PV310_GPD0(1), 0);
169 gpio_free(S5PV310_GPD0(1));
174 int s3cfb_lcd_on(struct platform_device *pdev)
179 int s3cfb_lcd_off(struct platform_device *pdev)
184 #elif defined(CONFIG_FB_S3C_LTE480WV)
185 int s3cfb_backlight_on(struct platform_device *pdev)
187 #if !defined(CONFIG_BACKLIGHT_PWM)
190 err = gpio_request(S5PV310_GPD0(1), "GPD0");
192 printk(KERN_ERR "failed to request GPD0 for "
193 "lcd backlight control\n");
197 gpio_direction_output(S5PV310_GPD0(1), 1);
198 gpio_free(S5PV310_GPD0(1));
203 int s3cfb_backlight_off(struct platform_device *pdev)
205 #if !defined(CONFIG_BACKLIGHT_PWM)
208 err = gpio_request(S5PV310_GPD0(1), "GPD0");
210 printk(KERN_ERR "failed to request GPD0 for "
211 "lcd backlight control\n");
215 gpio_direction_output(S5PV310_GPD0(1), 0);
216 gpio_free(S5PV310_GPD0(1));
221 int s3cfb_lcd_on(struct platform_device *pdev)
225 err = gpio_request(S5PV310_GPX0(6), "GPX0");
227 printk(KERN_ERR "failed to request GPX0 for "
228 "lcd reset control\n");
232 gpio_direction_output(S5PV310_GPX0(6), 1);
235 gpio_set_value(S5PV310_GPX0(6), 0);
238 gpio_set_value(S5PV310_GPX0(6), 1);
241 gpio_free(S5PV310_GPX0(6));
246 int s3cfb_lcd_off(struct platform_device *pdev)
250 #elif defined(CONFIG_FB_S3C_HT101HD1)
251 int s3cfb_backlight_on(struct platform_device *pdev)
253 #if !defined(CONFIG_BACKLIGHT_PWM)
256 err = gpio_request(S5PV310_GPD0(0), "GPD0");
258 printk(KERN_ERR "failed to request GPD0 for "
259 "lcd backlight control\n");
263 err = gpio_request(S5PV310_GPB(2), "GPB");
265 printk(KERN_ERR "failed to request GPB for "
266 "lcd LED_EN control\n");
270 gpio_direction_output(S5PV310_GPD0(0), 1); /* BL pwm High */
271 gpio_direction_output(S5PV310_GPB(2), 1); /* LED_EN (SPI1_MOSI) */
273 gpio_free(S5PV310_GPD0(0));
274 gpio_free(S5PV310_GPB(2));
279 int s3cfb_backlight_off(struct platform_device *pdev)
281 #if !defined(CONFIG_BACKLIGHT_PWM)
284 err = gpio_request(S5PV310_GPD0(0), "GPD0");
286 printk(KERN_ERR "failed to request GPD0 for "
287 "lcd backlight control\n");
291 err = gpio_request(S5PV310_GPB(2), "GPB");
293 printk(KERN_ERR "failed to request GPB for "
294 "lcd LED_EN control\n");
298 gpio_direction_output(S5PV310_GPD0(3), 0);
299 gpio_direction_output(S5PV310_GPB(2), 0);
301 gpio_free(S5PV310_GPD0(0));
302 gpio_free(S5PV310_GPB(2));
307 int s3cfb_lcd_on(struct platform_device *pdev)
311 err = gpio_request(S5PV310_GPH0(1), "GPH0");
313 printk(KERN_ERR "failed to request GPH0 for "
314 "lcd reset control\n");
318 gpio_direction_output(S5PV310_GPH0(1), 1);
320 gpio_set_value(S5PV310_GPH0(1), 0);
321 gpio_set_value(S5PV310_GPH0(1), 1);
323 gpio_free(S5PV310_GPH0(1));
328 int s3cfb_lcd_off(struct platform_device *pdev)
332 #elif defined(CONFIG_FB_S3C_AMS369FG06)
333 int s3cfb_backlight_on(struct platform_device *pdev)
338 int s3cfb_backlight_off(struct platform_device *pdev)
343 int s3cfb_lcd_on(struct platform_device *pdev)
347 err = gpio_request(S5PV310_GPX0(6), "GPX0");
349 printk(KERN_ERR "failed to request GPX0 for "
350 "lcd reset control\n");
354 gpio_direction_output(S5PV310_GPX0(6), 1);
357 gpio_set_value(S5PV310_GPX0(6), 1);
360 gpio_free(S5PV310_GPX0(6));
365 int s3cfb_lcd_off(struct platform_device *pdev)
371 int s3cfb_backlight_on(struct platform_device *pdev)
376 int s3cfb_backlight_off(struct platform_device *pdev)
381 int s3cfb_lcd_on(struct platform_device *pdev)
386 int s3cfb_lcd_off(struct platform_device *pdev)