1 From c3baf8bae35ec67edb89c07cd8367040c95cca74 Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Fri, 4 Apr 2008 11:36:19 +0100
4 Subject: [PATCH] gta02-bt-fixes.patch
5 Modify GTA02 power manager for bluetooth.
7 1. Default power value isn't correct. Now we set pcf50633 LDO4 to 3.2 voltage.
9 2. Separate GTA01 and GTA02 source code.
11 3. Add pcf50633 API for enable register.
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(-)
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 = {
25 [PCF50633_REGULATOR_LDO4] = {
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
40 #include <linux/kernel.h>
41 #include <linux/platform_device.h>
43 -#include <linux/pcf50606.h>
45 #include <asm/hardware.h>
46 #include <asm/mach-types.h>
48 +#ifdef CONFIG_MACH_NEO1973_GTA01
49 #include <asm/arch/gta01.h>
50 +#include <linux/pcf50606.h>
53 +#ifdef CONFIG_MACH_NEO1973_GTA02
54 #include <asm/arch/gta02.h>
55 +#include <linux/pcf50633.h>
59 #define DRVMSG "FIC Neo1973 Bluetooth Power Management"
61 @@ -30,6 +37,8 @@ static ssize_t bt_read(struct device *dev, struct device_attribute *attr,
63 if (!strcmp(attr->attr.name, "power_on")) {
64 switch (machine_arch_type) {
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)
74 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
76 +#ifdef CONFIG_MACH_NEO1973_GTA02
77 case MACH_TYPE_NEO1973_GTA02:
78 if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN))
81 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
84 } else if (!strcmp(attr->attr.name, "reset")) {
85 switch (machine_arch_type) {
87 +#ifdef CONFIG_MACH_NEO1973_GTA01
88 case MACH_TYPE_NEO1973_GTA01:
89 if (s3c2410_gpio_getpin(GTA01_GPIO_BT_EN) == 0)
92 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
94 +#ifdef CONFIG_MACH_NEO1973_GTA02
95 case MACH_TYPE_NEO1973_GTA02:
96 if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN) == 0)
99 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
104 @@ -64,9 +85,12 @@ static ssize_t bt_write(struct device *dev, struct device_attribute *attr,
105 const char *buf, size_t count)
107 unsigned long on = simple_strtoul(buf, NULL, 10);
110 if (!strcmp(attr->attr.name, "power_on")) {
111 switch (machine_arch_type) {
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);
121 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
123 +#ifdef CONFIG_MACH_NEO1973_GTA02
124 case MACH_TYPE_NEO1973_GTA02:
125 + s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, on ? 0 : 1);
127 - s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, 0);
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);
138 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
141 } else if (!strcmp(attr->attr.name, "reset")) {
142 /* reset is low-active, so we need to invert */
143 switch (machine_arch_type) {
145 +#ifdef CONFIG_MACH_NEO1973_GTA01
146 case MACH_TYPE_NEO1973_GTA01:
147 s3c2410_gpio_setpin(GTA01_GPIO_BT_EN, on ? 0 : 1);
149 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
151 +#ifdef CONFIG_MACH_NEO1973_GTA02
152 case MACH_TYPE_NEO1973_GTA02:
153 s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, on ? 0 : 1);
155 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
160 @@ -143,18 +184,30 @@ static int __init gta01_bt_probe(struct platform_device *pdev)
161 dev_info(&pdev->dev, DRVMSG ": starting\n");
163 switch (machine_arch_type) {
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);
174 +#endif /* CONFIG_MACH_NEO1973_GTA01 */
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);
186 +#endif /* CONFIG_MACH_NEO1973_GTA02 */
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);
193 return sysfs_create_group(&pdev->dev.kobj, >a01_bt_attr_group);
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,
201 pcf50633_voltage_get(struct pcf50633_data *pcf,
202 enum pcf50633_regulator_id reg);
205 pcf50633_onoff_get(struct pcf50633_data *pcf,
206 enum pcf50633_regulator_id reg);