cca32620b4c375b5c06f7f711881ffd43888a450
[glsdk/meta-ti-glsdk.git] / recipes-bsp / linux / linux-omap-psp-2.6.32 / cam / 0046-omap3beagle-camera-Cleanup-regulator-usage.patch
1 From 240def7eda2939e944ab70726cdecf270865553d Mon Sep 17 00:00:00 2001
2 From: Sergio Aguirre <saaguirre@ti.com>
3 Date: Mon, 12 Jul 2010 15:53:44 -0500
4 Subject: [PATCH 46/75] omap3beagle: camera: Cleanup regulator usage
6 We were missing the point of regulator abstraction layer.
8 Camera board file shouldn't be aware of what vaux is using, but
9 just asking for a specific power supply (for cam_1v8 and cam_2v8).
11 How is that mapped before, is something that the regulator machine
12 should figure out.
14 Signed-off-by: Sergio Aguirre <saaguirre@ti.com>
15 ---
16 arch/arm/mach-omap2/board-omap3beagle-camera.c | 50 ++++++++++++------------
17 arch/arm/mach-omap2/board-omap3beagle.c | 24 +++++-------
18 2 files changed, 35 insertions(+), 39 deletions(-)
20 diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
21 index befa7d4..c91529d 100644
22 --- a/arch/arm/mach-omap2/board-omap3beagle-camera.c
23 +++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
24 @@ -51,8 +51,8 @@
26 #define LEOPARD_RESET_GPIO 98
28 -static struct regulator *beagle_mt9v113_1_8v1;
29 -static struct regulator *beagle_mt9v113_1_8v2;
30 +static struct regulator *cam_1v8_reg;
31 +static struct regulator *cam_2v8_reg;
33 /* Arbitrary memory handling limit */
34 #define MT9V113_MAX_FRAME_SIZE PAGE_ALIGN(640 * 480 * 4)
35 @@ -148,10 +148,10 @@ static int mt9v113_power_set(struct v4l2_int_device *s, enum v4l2_power power)
36 case V4L2_POWER_OFF:
37 isp_set_xclk(vdev->cam->isp, 0, CAM_USE_XCLKA);
39 - if (regulator_is_enabled(beagle_mt9v113_1_8v1))
40 - regulator_disable(beagle_mt9v113_1_8v1);
41 - if (regulator_is_enabled(beagle_mt9v113_1_8v2))
42 - regulator_disable(beagle_mt9v113_1_8v2);
43 + if (regulator_is_enabled(cam_1v8_reg))
44 + regulator_disable(cam_1v8_reg);
45 + if (regulator_is_enabled(cam_2v8_reg))
46 + regulator_disable(cam_2v8_reg);
48 break;
50 @@ -162,10 +162,10 @@ static int mt9v113_power_set(struct v4l2_int_device *s, enum v4l2_power power)
51 gpio_set_value(LEOPARD_RESET_GPIO, 0);
53 /* turn on VDD */
54 - regulator_enable(beagle_mt9v113_1_8v1);
55 + regulator_enable(cam_1v8_reg);
56 mdelay(1);
57 /* turn on VDD_IO */
58 - regulator_enable(beagle_mt9v113_1_8v2);
59 + regulator_enable(cam_2v8_reg);
60 mdelay(50);
62 /* Enable EXTCLK */
63 @@ -201,24 +201,24 @@ struct mt9v113_platform_data mt9v113_pdata = {
65 static int beagle_cam_probe(struct platform_device *pdev)
66 {
67 - beagle_mt9v113_1_8v1 = regulator_get(&pdev->dev, "vaux3_1");
68 - if (IS_ERR(beagle_mt9v113_1_8v1)) {
69 - dev_err(&pdev->dev, "vaux3_1 regulator missing\n");
70 - return PTR_ERR(beagle_mt9v113_1_8v1);
71 + cam_1v8_reg = regulator_get(&pdev->dev, "cam_1v8");
72 + if (IS_ERR(cam_1v8_reg)) {
73 + dev_err(&pdev->dev, "cam_1v8 regulator missing\n");
74 + return PTR_ERR(cam_1v8_reg);
75 }
77 - beagle_mt9v113_1_8v2 = regulator_get(&pdev->dev, "vaux4_1");
78 - if (IS_ERR(beagle_mt9v113_1_8v2)) {
79 - dev_err(&pdev->dev, "vaux4_1 regulator missing\n");
80 - regulator_put(beagle_mt9v113_1_8v1);
81 - return PTR_ERR(beagle_mt9v113_1_8v2);
82 + cam_2v8_reg = regulator_get(&pdev->dev, "cam_2v8");
83 + if (IS_ERR(cam_2v8_reg)) {
84 + dev_err(&pdev->dev, "cam_2v8 regulator missing\n");
85 + regulator_put(cam_1v8_reg);
86 + return PTR_ERR(cam_2v8_reg);
87 }
89 if (gpio_request(LEOPARD_RESET_GPIO, "cam_rst") != 0) {
90 dev_err(&pdev->dev, "Could not request GPIO %d",
91 LEOPARD_RESET_GPIO);
92 - regulator_put(beagle_mt9v113_1_8v2);
93 - regulator_put(beagle_mt9v113_1_8v1);
94 + regulator_put(cam_2v8_reg);
95 + regulator_put(cam_1v8_reg);
96 return -ENODEV;
97 }
99 @@ -266,13 +266,13 @@ static int beagle_cam_probe(struct platform_device *pdev)
101 static int beagle_cam_remove(struct platform_device *pdev)
102 {
103 - if (regulator_is_enabled(beagle_mt9v113_1_8v1))
104 - regulator_disable(beagle_mt9v113_1_8v1);
105 - regulator_put(beagle_mt9v113_1_8v1);
106 + if (regulator_is_enabled(cam_1v8_reg))
107 + regulator_disable(cam_1v8_reg);
108 + regulator_put(cam_1v8_reg);
110 - if (regulator_is_enabled(beagle_mt9v113_1_8v2))
111 - regulator_disable(beagle_mt9v113_1_8v2);
112 - regulator_put(beagle_mt9v113_1_8v2);
113 + if (regulator_is_enabled(cam_2v8_reg))
114 + regulator_disable(cam_2v8_reg);
115 + regulator_put(cam_2v8_reg);
117 gpio_free(LEOPARD_RESET_GPIO);
119 diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
120 index 6835c1a..a1535ca 100644
121 --- a/arch/arm/mach-omap2/board-omap3beagle.c
122 +++ b/arch/arm/mach-omap2/board-omap3beagle.c
123 @@ -414,18 +414,14 @@ static struct platform_device beagle_cam_device = {
124 .id = -1,
125 };
127 -static struct regulator_consumer_supply beagle_vaux3_supplies[] = {
128 - {
129 - .supply = "vaux3_1",
130 - .dev = &beagle_cam_device.dev,
131 - },
132 +static struct regulator_consumer_supply beagle_vaux3_supply = {
133 + .supply = "cam_1v8",
134 + .dev = &beagle_cam_device.dev,
135 };
137 -static struct regulator_consumer_supply beagle_vaux4_supplies[] = {
138 - {
139 - .supply = "vaux4_1",
140 - .dev = &beagle_cam_device.dev,
141 - },
142 +static struct regulator_consumer_supply beagle_vaux4_supply = {
143 + .supply = "cam_2v8",
144 + .dev = &beagle_cam_device.dev,
145 };
147 /* VAUX3 for CAM_1V8 */
148 @@ -439,8 +435,8 @@ static struct regulator_init_data beagle_vaux3 = {
149 .valid_ops_mask = REGULATOR_CHANGE_MODE
150 | REGULATOR_CHANGE_STATUS,
151 },
152 - .num_consumer_supplies = ARRAY_SIZE(beagle_vaux3_supplies),
153 - .consumer_supplies = beagle_vaux3_supplies,
154 + .num_consumer_supplies = 1,
155 + .consumer_supplies = &beagle_vaux3_supply,
156 };
158 /* VAUX4 for CAM_2V8 */
159 @@ -454,8 +450,8 @@ static struct regulator_init_data beagle_vaux4 = {
160 .valid_ops_mask = REGULATOR_CHANGE_MODE
161 | REGULATOR_CHANGE_STATUS,
162 },
163 - .num_consumer_supplies = ARRAY_SIZE(beagle_vaux4_supplies),
164 - .consumer_supplies = beagle_vaux4_supplies,
165 + .num_consumer_supplies = 1,
166 + .consumer_supplies = &beagle_vaux4_supply,
167 };
169 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
170 --
171 1.6.6.1