-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hello list,

gta01-pm-gps is not working under GTA02, and kernel dumps the following
messages:
  gta01-pm-gps.0: Unknown GTA01 Revision 0x320, GPS PM features not
available!!!
  gta01-pm-gps: probe of gta01-pm-gps.0 failed with error -1

This patch creates a working GPS PM driver reflecting the changes in PMU
pcf50633 controls.

Thanks,
- -jserv
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHCyTl0Wz/dZh2kkkRAs6rAJ0Utg9B/+v90M38LmDvLGXTU6SyWACfeOg/
/nVvtuSBx1n7P8YnkxMKvUk=
=ZZDF
-----END PGP SIGNATURE-----
AGPS power management for GTA02.
---
 arch/arm/common/Makefile           |    1 
 arch/arm/common/gta02_pm_gps.c     |  140 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-s3c2440/mach-gta02.c |    6 +
 drivers/i2c/chips/pcf50633.c       |   22 +++++
 include/linux/pcf50633.h           |    6 +
 5 files changed, 175 insertions(+)

Index: linux-2.6.22.5/arch/arm/common/Makefile
===================================================================
--- linux-2.6.22.5.orig/arch/arm/common/Makefile	2007-10-08 23:04:05.000000000 +0800
+++ linux-2.6.22.5/arch/arm/common/Makefile	2007-10-09 13:25:43.000000000 +0800
@@ -18,3 +18,4 @@
 obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_MACH_NEO1973_GTA01)+= gta01_pm_gsm.o gta01_pm_gps.o gta01_pm_bt.o
+obj-$(CONFIG_MACH_NEO1973_GTA02)+= gta02_pm_gps.o
Index: linux-2.6.22.5/arch/arm/common/gta02_pm_gps.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.22.5/arch/arm/common/gta02_pm_gps.c	2007-10-09 13:36:10.000000000 +0800
@@ -0,0 +1,140 @@
+/*
+ * GSM Management code for the FIC Neo1973 GSM Phone
+ *
+ * (C) 2007 by OpenMoko Inc.
+ * Author: Harald Welte <[EMAIL PROTECTED]>
+ * Modified by Sweden Hsu <[EMAIL PROTECTED]>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/console.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <linux/pcf50633.h>
+#include <asm/arch/gta01.h>
+#include <asm/arch/gta02.h>
+
+static int gps_state = 0;
+
+static ssize_t gps_read(struct device *dev, struct device_attribute *attr,
+			char *buf)
+{
+	unsigned int vol;
+	vol = pcf50633_voltage_get(pcf50633_global, PCF50633_REGULATOR_LDO5);
+	dev_info (dev, "Get PCF50633 LDO5 = %d",vol);
+
+	return sprintf(buf, "%d  LDO5=%d\n", gps_state, vol);
+}
+
+static ssize_t gps_write(struct device *dev, struct device_attribute *attr,
+			 const char *buf, size_t count)
+{
+	unsigned long on = simple_strtoul(buf, NULL, 10);
+
+	if (!strcmp(attr->attr.name, "power_on")) {
+		if (on) {
+			dev_info(dev, "powering up AGPS");
+
+			pcf50633_voltage_set(pcf50633_global, PCF50633_REGULATOR_LDO5, 3000);
+			pcf50633_ldo5ena_set(pcf50633_global, 0x01);
+			gps_state = 1;
+		} else {
+
+			pcf50633_voltage_set(pcf50633_global, PCF50633_REGULATOR_LDO5, 0);
+			pcf50633_ldo5ena_set(pcf50633_global, 0x00);
+			gps_state = 0;
+			dev_info(dev, "powered down AGPS");
+		}
+	}
+	return count;
+}
+
+static DEVICE_ATTR(power_on, 0644, gps_read, gps_write);
+
+#ifdef CONFIG_PM
+static int gta02_gps_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	/* GPIO state is saved/restored by S3C24xx core GPIO driver, so we
+	 * don't need to do anything here */
+	return 0;
+}
+
+static int gta02_gps_resume(struct platform_device *pdev)
+{
+	/* GPIO state is saved/restored by S3C24xx core GPIO driver, so we
+	 * don't need to do anything here */
+
+	/* Make sure that the kernel console on the serial port is still
+	 * disabled. FIXME: resume ordering race with serial driver! */
+	return 0;
+}
+#else
+#define gta02_gps_suspend	NULL
+#define gta02_gps_resume	NULL
+#endif
+
+static struct attribute *gta02_gps_sysfs_entries[] = {
+	&dev_attr_power_on.attr,
+	NULL,
+	NULL
+};
+
+static struct attribute_group gta02_gps_attr_group = {
+	.name	= NULL,
+	.attrs	= gta02_gps_sysfs_entries,
+};
+
+static int __init gta02_gps_probe(struct platform_device *pdev)
+{
+	switch (system_rev) {
+		case GTA02v2_SYSTEM_REV:
+ 			return sysfs_create_group(&pdev->dev.kobj, &gta02_gps_attr_group);
+		default:
+			return -1;
+	}
+}
+
+static int gta02_gps_remove(struct platform_device *pdev)
+{
+	sysfs_remove_group(&pdev->dev.kobj, &gta02_gps_attr_group);
+
+	return 0;
+}
+
+static struct platform_driver gta02_gps_driver = {
+	.probe		= gta02_gps_probe,
+	.remove		= gta02_gps_remove,
+	.suspend	= gta02_gps_suspend,
+	.resume		= gta02_gps_resume,
+	.driver		= {
+		.name		= "gta02-pm-gps",
+	},
+};
+
+static int __devinit gta02_gps_init(void)
+{
+	return platform_driver_register(&gta02_gps_driver);
+}
+
+static void gta02_gps_exit(void)
+{
+	platform_driver_unregister(&gta02_gps_driver);
+}
+
+module_init(gta02_gps_init);
+module_exit(gta02_gps_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("FIC GTA02 (Neo1973) GPS Management");
Index: linux-2.6.22.5/arch/arm/mach-s3c2440/mach-gta02.c
===================================================================
--- linux-2.6.22.5.orig/arch/arm/mach-s3c2440/mach-gta02.c	2007-10-08 23:04:06.000000000 +0800
+++ linux-2.6.22.5/arch/arm/mach-s3c2440/mach-gta02.c	2007-10-09 13:29:58.000000000 +0800
@@ -579,6 +579,10 @@
 	.name		= "gta01-pm-gsm",
 };
 
+static struct platform_device gta02_pm_gps_dev = {
+	.name		= "gta02-pm-gps",
+};
+
 /* USB */
 static struct s3c2410_hcd_info gta02_usb_info = {
 	.port[0]	= {
@@ -678,6 +682,8 @@
 	platform_device_register(&gta01_button_dev);
 	platform_device_register(&gta01_pm_gsm_dev);
 
+	platform_device_register(&gta02_pm_gps_dev);
+
 	mangle_pmu_pdata_by_system_rev();
 	platform_device_register(&gta02_pmu_dev);
 	platform_device_register(&gta02_led_dev);
Index: linux-2.6.22.5/drivers/i2c/chips/pcf50633.c
===================================================================
--- linux-2.6.22.5.orig/drivers/i2c/chips/pcf50633.c	2007-10-08 23:04:06.000000000 +0800
+++ linux-2.6.22.5/drivers/i2c/chips/pcf50633.c	2007-10-09 13:34:13.000000000 +0800
@@ -450,6 +450,28 @@
 }
 EXPORT_SYMBOL(pcf50633_go_standby);
 
+void pcf50633_gpio2_output_set(struct pcf50633_data*pcf,int on)
+{
+	u_int8_t val;
+
+	/* Set GPIO2 output */
+	reg_set_bit_mask(pcf, PCF50633_REG_GPIOCTL, 0x02, 0);
+
+	if (on)
+		val = PCF50633_GPOCFG_GPOSEL_1;
+	else
+		val = PCF50633_GPOCFG_GPOSEL_0;
+
+	reg_set_bit_mask(pcf, PCF50633_REG_GPIO2CFG, 0x0f, val);
+}
+EXPORT_SYMBOL(pcf50633_gpio2_output_set);
+
+void pcf50633_ldo5ena_set(struct pcf50633_data*pcf, u_int8_t val)
+{
+	reg_write(pcf,PCF50633_REG_LDO5ENA, val);
+}
+EXPORT_SYMBOL(pcf50633_ldo5ena_set);
+
 void pcf50633_gpo0_set(struct pcf50633_data *pcf, int on)
 {
 	u_int8_t val;
Index: linux-2.6.22.5/include/linux/pcf50633.h
===================================================================
--- linux-2.6.22.5.orig/include/linux/pcf50633.h	2007-10-08 23:04:06.000000000 +0800
+++ linux-2.6.22.5/include/linux/pcf50633.h	2007-10-09 13:24:55.000000000 +0800
@@ -24,6 +24,12 @@
 pcf50633_go_standby(void);
 
 extern void
+pcf50633_gpio2_output_set(struct pcf50633_data *pcf, int on);
+
+extern void
+pcf50633_ldo5ena_set(struct pcf50633_data*pcf, u_int8_t val);
+
+extern void
 pcf50633_gpo0_set(struct pcf50633_data *pcf, int on);
 
 extern int

Reply via email to