[ar71xx] create firmware image for the Ubiquiti LS-SR71 board
[openwrt/svn-archive/archive.git] / target / linux / s3c24xx / patches-2.6.26 / 1035-gta02-bt-fixes.patch.patch
1 From d4d6e6229c94cfe2bd8f29b4ebc0d60b8ad29455 Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Wed, 16 Jul 2008 14:46:57 +0100
4 Subject: [PATCH] gta02-bt-fixes.patch
5 Modify GTA02 power manager for bluetooth.
6
7 1. Default power value isn't correct. Now we set pcf50633 LDO4 to 3.2 voltage.
8
9 2. Separate GTA01 and GTA02 source code.
10
11 3. Add pcf50633 API for enable register.
12 ---
13 arch/arm/mach-s3c2440/mach-gta02.c | 4 +-
14 arch/arm/plat-s3c24xx/neo1973_pm_bt.c | 71 ++++++++++++++++++++++++++++----
15 include/linux/pcf50633.h | 1 +
16 3 files changed, 65 insertions(+), 11 deletions(-)
17
18 diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
19 index 3fbb131..46acede 100644
20 --- a/arch/arm/mach-s3c2440/mach-gta02.c
21 +++ b/arch/arm/mach-s3c2440/mach-gta02.c
22 @@ -213,10 +213,10 @@ static struct pcf50633_platform_data gta02_pcf_pdata = {
23 },
24 },
25 [PCF50633_REGULATOR_LDO4] = {
26 - .name = "gl_2v5",
27 + .name = "bt_3v2",
28 .voltage = {
29 .init = 2500,
30 - .max = 2500,
31 + .max = 3300,
32 },
33 },
34 [PCF50633_REGULATOR_LDO5] = {
35 diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_bt.c b/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
36 index d685ef7..8f5be88 100644
37 --- a/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
38 +++ b/arch/arm/plat-s3c24xx/neo1973_pm_bt.c
39 @@ -16,12 +16,19 @@
40 #include <linux/kernel.h>
41 #include <linux/platform_device.h>
42
43 -#include <linux/pcf50606.h>
44 -
45 #include <asm/hardware.h>
46 #include <asm/mach-types.h>
47 +
48 +#ifdef CONFIG_MACH_NEO1973_GTA01
49 #include <asm/arch/gta01.h>
50 +#include <linux/pcf50606.h>
51 +#endif
52 +
53 +#ifdef CONFIG_MACH_NEO1973_GTA02
54 #include <asm/arch/gta02.h>
55 +#include <linux/pcf50633.h>
56 +#endif
57 +
58
59 #define DRVMSG "FIC Neo1973 Bluetooth Power Management"
60
61 @@ -30,6 +37,8 @@ static ssize_t bt_read(struct device *dev, struct device_attribute *attr,
62 {
63 if (!strcmp(attr->attr.name, "power_on")) {
64 switch (machine_arch_type) {
65 +
66 +#ifdef CONFIG_MACH_NEO1973_GTA01
67 case MACH_TYPE_NEO1973_GTA01:
68 if (pcf50606_onoff_get(pcf50606_global,
69 PCF50606_REGULATOR_D1REG) &&
70 @@ -37,21 +46,33 @@ static ssize_t bt_read(struct device *dev, struct device_attribute *attr,
71 PCF50606_REGULATOR_D1REG) == 3100)
72 goto out_1;
73 break;
74 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
75 +
76 +#ifdef CONFIG_MACH_NEO1973_GTA02
77 case MACH_TYPE_NEO1973_GTA02:
78 if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN))
79 goto out_1;
80 break;
81 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
82 +
83 }
84 } else if (!strcmp(attr->attr.name, "reset")) {
85 switch (machine_arch_type) {
86 +
87 +#ifdef CONFIG_MACH_NEO1973_GTA01
88 case MACH_TYPE_NEO1973_GTA01:
89 if (s3c2410_gpio_getpin(GTA01_GPIO_BT_EN) == 0)
90 goto out_1;
91 break;
92 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
93 +
94 +#ifdef CONFIG_MACH_NEO1973_GTA02
95 case MACH_TYPE_NEO1973_GTA02:
96 if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN) == 0)
97 goto out_1;
98 break;
99 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
100 +
101 }
102 }
103
104 @@ -64,9 +85,12 @@ static ssize_t bt_write(struct device *dev, struct device_attribute *attr,
105 const char *buf, size_t count)
106 {
107 unsigned long on = simple_strtoul(buf, NULL, 10);
108 + unsigned int vol;
109
110 if (!strcmp(attr->attr.name, "power_on")) {
111 switch (machine_arch_type) {
112 +
113 +#ifdef CONFIG_MACH_NEO1973_GTA01
114 case MACH_TYPE_NEO1973_GTA01:
115 /* if we are powering up, assert reset, then power,
116 * then release reset */
117 @@ -80,22 +104,39 @@ static ssize_t bt_write(struct device *dev, struct device_attribute *attr,
118 PCF50606_REGULATOR_D1REG, on);
119 s3c2410_gpio_setpin(GTA01_GPIO_BT_EN, on);
120 break;
121 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
122 +
123 +#ifdef CONFIG_MACH_NEO1973_GTA02
124 case MACH_TYPE_NEO1973_GTA02:
125 + s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, on ? 0 : 1);
126 if (on)
127 - s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, 0);
128 - else
129 - s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, 1);
130 + pcf50633_voltage_set(pcf50633_global,
131 + PCF50633_REGULATOR_LDO4, 3200);
132 + pcf50633_onoff_set(pcf50633_global,
133 + PCF50633_REGULATOR_LDO4, on);
134 + vol = pcf50633_voltage_get(pcf50633_global,
135 + PCF50633_REGULATOR_LDO4);
136 + dev_info(dev, "GTA02 Set PCF50633 LDO4 = %d\n", vol);
137 break;
138 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
139 +
140 }
141 } else if (!strcmp(attr->attr.name, "reset")) {
142 /* reset is low-active, so we need to invert */
143 switch (machine_arch_type) {
144 +
145 +#ifdef CONFIG_MACH_NEO1973_GTA01
146 case MACH_TYPE_NEO1973_GTA01:
147 s3c2410_gpio_setpin(GTA01_GPIO_BT_EN, on ? 0 : 1);
148 break;
149 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
150 +
151 +#ifdef CONFIG_MACH_NEO1973_GTA02
152 case MACH_TYPE_NEO1973_GTA02:
153 s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, on ? 0 : 1);
154 break;
155 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
156 +
157 }
158 }
159
160 @@ -143,18 +184,30 @@ static int __init gta01_bt_probe(struct platform_device *pdev)
161 dev_info(&pdev->dev, DRVMSG ": starting\n");
162
163 switch (machine_arch_type) {
164 +
165 +#ifdef CONFIG_MACH_NEO1973_GTA01
166 case MACH_TYPE_NEO1973_GTA01:
167 /* we make sure that the voltage is off */
168 pcf50606_onoff_set(pcf50606_global,
169 PCF50606_REGULATOR_D1REG, 0);
170 + /* we pull reset to low to make sure that the chip doesn't
171 + * drain power through the reset line */
172 + s3c2410_gpio_setpin(GTA01_GPIO_BT_EN, 0);
173 break;
174 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
175 +
176 +#ifdef CONFIG_MACH_NEO1973_GTA02
177 case MACH_TYPE_NEO1973_GTA02:
178 - /* FIXME: implementation */
179 + /* we make sure that the voltage is off */
180 + pcf50633_onoff_set(pcf50633_global,
181 + PCF50633_REGULATOR_LDO4, 0);
182 + /* we pull reset to low to make sure that the chip doesn't
183 + * drain power through the reset line */
184 + s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, 0);
185 break;
186 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
187 +
188 }
189 - /* we pull reset to low to make sure that the chip doesn't
190 - * drain power through the reset line */
191 - s3c2410_gpio_setpin(GTA01_GPIO_BT_EN, 0);
192
193 return sysfs_create_group(&pdev->dev.kobj, &gta01_bt_attr_group);
194 }
195 diff --git a/include/linux/pcf50633.h b/include/linux/pcf50633.h
196 index bf50fe4..b6a67ee 100644
197 --- a/include/linux/pcf50633.h
198 +++ b/include/linux/pcf50633.h
199 @@ -46,6 +46,7 @@ pcf50633_voltage_set(struct pcf50633_data *pcf,
200 extern unsigned int
201 pcf50633_voltage_get(struct pcf50633_data *pcf,
202 enum pcf50633_regulator_id reg);
203 +
204 extern int
205 pcf50633_onoff_get(struct pcf50633_data *pcf,
206 enum pcf50633_regulator_id reg);
207 --
208 1.5.6.3
209