upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / setup-fimc0.c
1 /* linux/arch/arm/mach-s5pv210/setup-fimc0.c
2  *
3  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com/
5  *
6  * Base FIMC 0 gpio configuration
7  *
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.
11 */
12
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/gpio.h>
16 #include <linux/clk.h>
17 #include <linux/err.h>
18 #include <linux/platform_device.h>
19 #include <linux/io.h>
20 #include <plat/clock.h>
21 #include <plat/gpio-cfg.h>
22 #include <mach/regs-gpio.h>
23 #include <plat/map-s5p.h>
24 #include <mach/map.h>
25
26 struct platform_device; /* don't need the contents */
27
28 void s3c_fimc0_cfg_gpio(struct platform_device *pdev)
29 {
30 #if 0
31         int i = 0;
32         /* TODO FIXME: breaks qt602240 touch screen on Universal C210 */
33         /* CAM A port(b0010) : PCLK, VSYNC, HREF, DATA[0-4] */
34         for (i = 0; i < 8; i++) {
35                 s3c_gpio_cfgpin(S5PV310_GPJ0(i), S3C_GPIO_SFN(2));
36                 s3c_gpio_setpull(S5PV310_GPJ0(i), S3C_GPIO_PULL_NONE);
37         }
38         /* CAM A port(b0010) : DATA[5-7], CLKOUT(MIPI CAM also), FIELD */
39         for (i = 0; i < 5; i++) {
40                 s3c_gpio_cfgpin(S5PV310_GPJ1(i), S3C_GPIO_SFN(2));
41                 s3c_gpio_setpull(S5PV310_GPJ1(i), S3C_GPIO_PULL_NONE);
42         }
43
44         /* CAM B port(b0011) : DATA[0-7] */
45         for (i = 0; i < 8; i++) {
46                 s3c_gpio_cfgpin(S5PV310_GPE1(i), S3C_GPIO_SFN(3));
47                 s3c_gpio_setpull(S5PV310_GPE1(i), S3C_GPIO_PULL_NONE);
48         }
49         /* CAM B port(b0011) : PCLK, VSYNC, HREF, FIELD, CLCKOUT */
50         for (i = 0; i < 5; i++) {
51                 s3c_gpio_cfgpin(S5PV310_GPE0(i), S3C_GPIO_SFN(3));
52                 s3c_gpio_setpull(S5PV310_GPE0(i), S3C_GPIO_PULL_NONE);
53         }
54 #endif
55         /* note : driver strength to max is unnecessary */
56 }
57
58 int s3c_fimc_clk_on(struct platform_device *pdev, struct clk **clk)
59 {
60         struct clk *sclk_fimc_lclk = NULL;
61         struct clk *mout_mpll = NULL;
62         struct clk *mout_epll = NULL;
63
64         mout_mpll = clk_get(&pdev->dev, "mout_mpll");
65         if (IS_ERR(mout_mpll)) {
66                 dev_err(&pdev->dev, "failed to get mout_mpll\n");
67                 goto err_clk1;
68         }
69
70         sclk_fimc_lclk = clk_get(&pdev->dev, "sclk_fimc");
71         if (IS_ERR(sclk_fimc_lclk)) {
72                 dev_err(&pdev->dev, "failed to get sclk_fimc_lclk\n");
73                 goto err_clk2;
74         }
75
76         clk_set_parent(sclk_fimc_lclk, mout_mpll);
77         clk_set_rate(sclk_fimc_lclk, 166750000);
78
79         /* be able to handle clock on/off only with this clock */
80         *clk = clk_get(&pdev->dev, "fimc");
81         if (IS_ERR(clk)) {
82                 dev_err(&pdev->dev, "failed to get interface clock\n");
83                 goto err_clk3;
84         }
85         mout_epll = clk_get(&pdev->dev, "mout_epll");
86
87         clk_enable(*clk);
88         clk_enable(sclk_fimc_lclk);
89
90         return 0;
91
92 err_clk3:
93         clk_put(sclk_fimc_lclk);
94
95 err_clk2:
96         clk_put(mout_mpll);
97
98 err_clk1:
99         return -EINVAL;
100 }
101
102 int s3c_fimc_clk_off(struct platform_device *pdev, struct clk **clk)
103 {
104         clk_disable(*clk);
105         clk_put(*clk);
106
107         *clk = NULL;
108
109         return 0;
110 }