aboutsummaryrefslogtreecommitdiff
path: root/linux/3.1.6/0013-n35-Acer-n35-GPS-power-management.patch
diff options
context:
space:
mode:
Diffstat (limited to 'linux/3.1.6/0013-n35-Acer-n35-GPS-power-management.patch')
-rw-r--r--linux/3.1.6/0013-n35-Acer-n35-GPS-power-management.patch206
1 files changed, 206 insertions, 0 deletions
diff --git a/linux/3.1.6/0013-n35-Acer-n35-GPS-power-management.patch b/linux/3.1.6/0013-n35-Acer-n35-GPS-power-management.patch
new file mode 100644
index 0000000..9193ce6
--- /dev/null
+++ b/linux/3.1.6/0013-n35-Acer-n35-GPS-power-management.patch
@@ -0,0 +1,206 @@
+From 2dac0b9383e3939ce69b07aff70e8eae3b7fa561 Mon Sep 17 00:00:00 2001
+From: Jiri Pinkava <jiri.pinkava@vscht.cz>
+Date: Wed, 26 May 2010 23:00:56 +0200
+Subject: [PATCH 13/14] n35: Acer n35 GPS power management
+
+Signed-off-by: Jiri Pinkava <jiri.pinkava@vscht.cz>
+---
+ arch/arm/mach-s3c2410/Makefile | 1 +
+ arch/arm/mach-s3c2410/mach-n30.c | 6 ++
+ arch/arm/mach-s3c2410/n35_gps.c | 148 ++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 155 insertions(+), 0 deletions(-)
+ create mode 100644 arch/arm/mach-s3c2410/n35_gps.c
+
+diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
+index 0d468e9..896baa4 100644
+--- a/arch/arm/mach-s3c2410/Makefile
++++ b/arch/arm/mach-s3c2410/Makefile
+@@ -25,6 +25,7 @@ obj-$(CONFIG_ARCH_H1940) += mach-h1940.o
+ obj-$(CONFIG_H1940BT) += h1940-bluetooth.o
+ obj-$(CONFIG_PM_H1940) += pm-h1940.o
+ obj-$(CONFIG_MACH_N30) += mach-n30.o
++obj-$(CONFIG_MACH_N35) += n35_gps.o
+ obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o
+ obj-$(CONFIG_MACH_OTOM) += mach-otom.o
+ obj-$(CONFIG_MACH_AML_M5900) += mach-amlm5900.o
+diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c
+index 34a7e9e..010d5aa 100644
+--- a/arch/arm/mach-s3c2410/mach-n30.c
++++ b/arch/arm/mach-s3c2410/mach-n30.c
+@@ -631,6 +631,11 @@ static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = {
+ .set_power = n30_sdi_set_power,
+ };
+
++static struct platform_device n35_device_gps = {
++ .name = "n35-gps",
++ .id = -1,
++};
++
+ static struct platform_device *n30_devices[] __initdata = {
+ &s3c_device_lcd,
+ &s3c_device_wdt,
+@@ -664,6 +669,7 @@ static struct platform_device *n35_devices[] __initdata = {
+ &s3c_device_ts,
+ &s3c_device_timer[0],
+ &n35_backlight,
++ &n35_device_gps,
+ &n35_lcd_powerdev,
+ &n30_battery,
+ &n35_button_device,
+diff --git a/arch/arm/mach-s3c2410/n35_gps.c b/arch/arm/mach-s3c2410/n35_gps.c
+new file mode 100644
+index 0000000..41506e9
+--- /dev/null
++++ b/arch/arm/mach-s3c2410/n35_gps.c
+@@ -0,0 +1,148 @@
++/*
++ * arch/arm/mach-s3c2410/n35-gps.c
++ * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
++ *
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file COPYING in the main directory of this archive for
++ * more details.
++ *
++ * Acer n35 GPS "driver"
++ * FIXME: Do proper up/down handling, now it only ses power on/off.
++ *
++ */
++
++#include <linux/module.h>
++#include <linux/platform_device.h>
++//#include <linux/delay.h>
++#include <linux/string.h>
++#include <linux/ctype.h>
++#include <linux/gpio.h>
++
++#include <mach/regs-gpio.h>
++#include <mach/hardware.h>
++
++#define DRV_NAME "n35-gps"
++
++struct n35_gps_data {
++ int suspend_power_state;
++};
++
++static struct n35_gps_data n35_gps;
++
++static int gps_power_get(void)
++{
++ return !(gpio_get_value(S3C2410_GPB(4)) || \
++ gpio_get_value(S3C2410_GPG(11)));
++}
++
++static void gps_power_set(int power)
++{
++ gpio_set_value(S3C2410_GPB(4), power ? 0 : 1);
++ gpio_set_value(S3C2410_GPG(11), power ? 0 : 1);
++}
++
++static ssize_t gps_power_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ if (gps_power_get())
++ return sprintf(buf, "1\n");
++ return sprintf(buf, "0\n");
++}
++
++static ssize_t gps_power_store(struct device *pdev,
++ struct device_attribute *attr, const char *buf, size_t size)
++{
++ int power;
++
++ power = simple_strtoul(buf, NULL, 0);
++ gps_power_set(power);
++
++ return size;
++}
++
++static DEVICE_ATTR(gps_power, 0664, gps_power_show, gps_power_store);
++
++static int __devinit n35_gps_probe(struct platform_device *pdev)
++{
++ int ret;
++
++ ret = gpio_request(S3C2410_GPB(4), "Acer n35 GPS module power");
++ if (ret)
++ goto ret_err;
++
++ ret = gpio_request(S3C2410_GPG(11), "Acer n35 GPS antena power");
++ if (ret)
++ goto ret_err_gpg4;
++
++ s3c_gpio_cfgpin(S3C2410_GPB(4), S3C2410_GPIO_OUTPUT);
++ s3c_gpio_cfgpin(S3C2410_GPG(11), S3C2410_GPIO_OUTPUT);
++
++ gps_power_set(0);
++
++ ret = device_create_file(&pdev->dev, &dev_attr_gps_power);
++ if (ret) {
++ dev_err(&pdev->dev, "Failed to create GPS sysfs device\n");
++ goto ret_err_gpg11;
++ }
++
++ return 0;
++ret_err_gpg11:
++ gpio_free(S3C2410_GPG(11));
++ret_err_gpg4:
++ gpio_free(S3C2410_GPB(4));
++ret_err:
++ return ret;
++}
++
++static int n35_gps_remove(struct platform_device *pdev)
++{
++ gps_power_set(0);
++
++ gpio_free(S3C2410_GPG(11));
++ gpio_free(S3C2410_GPB(4));
++
++ device_remove_file(&pdev->dev, &dev_attr_gps_power);
++
++ return 0;
++}
++
++static int n35_gps_suspend(struct platform_device *pdev, pm_message_t state)
++{
++ n35_gps.suspend_power_state = gps_power_get();
++ gps_power_set(0);
++ return 0;
++}
++
++static int n35_gps_resume(struct platform_device *pdev)
++{
++ gps_power_set(n35_gps.suspend_power_state);
++ return 0;
++}
++
++static struct platform_driver n35_gps_driver = {
++ .driver = {
++ .name = DRV_NAME,
++ },
++ .probe = n35_gps_probe,
++ .remove = n35_gps_remove,
++ .resume = n35_gps_resume,
++ .suspend = n35_gps_suspend,
++};
++
++
++static int __init n35_gps_init(void)
++{
++ return platform_driver_register(&n35_gps_driver);
++}
++
++static void __exit n35_gps_exit(void)
++{
++ platform_driver_unregister(&n35_gps_driver);
++}
++
++module_init(n35_gps_init);
++module_exit(n35_gps_exit);
++
++MODULE_AUTHOR("Jiri Pinkava <jiri.pinkava@vscht.cz>");
++MODULE_DESCRIPTION("Driver for the Acer n35 GPS");
++MODULE_LICENSE("GPL");
+--
+1.7.3.1
+