The AR1520 is a GPS chip connect to I2C bus of system.
This driver will get IRQ of GPIO RTS pin and.
==============================================================================================================
diff -ruN linux-2.6-mid-ref/arch/x86/platform/mrst/mrst.c
linux-2.6-mid-ref.new/arch/x86/platform/mrst/mrst.c
--- linux-2.6-mid-ref/arch/x86/platform/mrst/mrst.c 2011-02-23
18:46:36.330669413 +0800
+++ linux-2.6-mid-ref.new/arch/x86/platform/mrst/mrst.c 2011-02-23
21:12:15.030668857 +0800
@@ -23,6 +23,7 @@
#include <linux/i2c.h>
#include <linux/i2c/pca953x.h>
#include <linux/i2c/tc35894xbg.h>
+#include <linux/ar1520.h>
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
#include <linux/input.h>
@@ -617,6 +618,21 @@
return &intr2nd_pdata;
}
+static void __init *ar1520_gps_platform_data(void *info)
+{
+ static int dummy;
+ struct i2c_board_info *i2c_info = info;
+ static struct ar1520_gps_platform_data ar1520_i2c_pdata;
+ int gpio = get_gpio_by_name("gps_rts");
+ if (gpio == -1)
+ return NULL;
+
+ ar1520_i2c_pdata.gps_gpio_rts = gpio;
+
+ return &ar1520_i2c_pdata;
+}
+
+
static void tc35894xbg_reset_ctrl(struct i2c_client *client, int value)
{
struct tc35894xbg_platform_data *pdata = client->dev.platform_data;
@@ -815,6 +831,7 @@
{"i2c_TC35894-nEB1", SFI_DEV_TYPE_I2C, 0, &tc35894xbg_n_platform_data},
{"i2c_TC35894-i", SFI_DEV_TYPE_I2C, 0, &tc35894xbg_i_platform_data},
{"ektf2136_spi", SFI_DEV_TYPE_SPI, 0, &ektf2136_spi_platform_data},
+ {"ath1520a", SFI_DEV_TYPE_I2C, 0, &ar1520_gps_platform_data},
{},
};
diff -ruN linux-2.6-mid-ref/drivers/misc/ar1520.c
linux-2.6-mid-ref.new/drivers/misc/ar1520.c
--- linux-2.6-mid-ref/drivers/misc/ar1520.c 1970-01-01 08:00:00.000000000 +0800
+++ linux-2.6-mid-ref.new/drivers/misc/ar1520.c 2011-02-23 21:09:55.278669066
+0800
@@ -0,0 +1,179 @@
+/*
+ * ar1520.c - Atheros AR1520 RTS Driver
+ *
+ * Copyright (C) 2008 Intel Corp
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/sysfs.h>
+#include <linux/pm_runtime.h>
+#include <linux/kernel.h>
+#include <linux/gpio.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <asm/uaccess.h>
+#include <linux/ar1520.h>
+#include <linux/platform_device.h>
+
+static irqreturn_t gpsrts_irq_handler(int irq, void *dev_id)
+{
+ struct ar1520_gps_data *data = dev_id;
+ data->flag=1;
+ return IRQ_HANDLED;
+}
+
+static ssize_t out_rts_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ar1520_gps_data *data = dev_get_drvdata(dev);
+ if (data->flag==1){
+ data->flag=0;
+ return sprintf(buf, "1\n");
+ }
+ return sprintf(buf, "0\n");
+}
+
+static DEVICE_ATTR(i2crts, S_IRUGO, out_rts_show, NULL);
+
+static struct attribute *mid_att[] = {
+ &dev_attr_i2crts.attr,
+ NULL
+};
+
+static const struct attribute_group ar1520_gr = {
+ .attrs = mid_att
+};
+
+static int __devinit ar1520_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ int res;
+ struct ar1520_gps_platform_data *pdata;
+ struct ar1520_gps_data *data;
+ int gpio_base;
+
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ pdata = client->dev.platform_data;
+ if (!pdata) {
+ dev_err(&client->dev, "no platform data\n");
+ res = -ENODEV;
+ }
+
+ i2c_set_clientdata(client, data);
+ data->client = client;
+ data->pdata = pdata;
+ data->gps_gpio_rts = pdata->gps_gpio_rts;
+ gpio_base = data->gps_gpio_rts;
+ gpio_direction_input(gpio_base);
+ res = gpio_to_irq(gpio_base);
+ data->gps_irq = res;
+ client->irq = res;
+
+ res= request_irq(data->gps_irq, gpsrts_irq_handler,
+ IRQF_TRIGGER_FALLING, "i2c_gps", data);
+ if (res)
+ dev_err(&client->dev, "could not get GPS_IRQ = %d\n",
+ client->irq);
+
+ res = sysfs_create_group(&client->dev.kobj, &ar1520_gr);
+ if (res) {
+ dev_err(&client->dev, "ar1520: device create file failed\n");
+ return res;
+ }
+ dev_info(&client->dev, "%s ar1520: GPS chip found\n", client->name);
+ device_init_wakeup(&client->dev, 1);
+ pm_runtime_enable(&client->dev);
+ enable_irq_wake(client->irq);
+
+ return res;
+}
+
+static int ar1520_remove(struct i2c_client *client)
+{
+ struct ar1520_gps_data *data = i2c_get_clientdata(client);
+
+ disable_irq_wake(client->irq);
+ free_irq(client->irq, data);
+ gpio_free(data->gps_gpio_rts);
+ sysfs_remove_group(&client->dev.kobj, &ar1520_gr);
+ return 0;
+}
+
+static struct i2c_device_id ar1520_id[] = {
+ { "ath1520a", 0 },
+ { }
+};
+
+static int ar1520_runtime_suspend(struct device *dev)
+{
+ /* AR1520 is automatically in Suspend mode */
+ return 0;
+}
+
+static int ar1520_runtime_resume(struct device *dev)
+{
+ /* AR1520 automatically wakes from Suspend mode */
+ return 0;
+}
+
+static const struct dev_pm_ops ar1520_pm_ops = {
+ .runtime_suspend = ar1520_runtime_suspend,
+ .runtime_resume = ar1520_runtime_resume,
+};
+
+
+MODULE_DEVICE_TABLE(i2c, ar1520_id);
+
+static struct i2c_driver ar1520_driver = {
+ .driver = {
+ .name = "ath1520a",
+ .pm = &ar1520_pm_ops,
+ },
+ .probe = ar1520_probe,
+ .remove = ar1520_remove,
+ .id_table = ar1520_id,
+};
+
+static int __init ar1520_init(void)
+{
+ return i2c_add_driver(&ar1520_driver);
+}
+
+static void __exit ar1520_exit(void)
+{
+ i2c_del_driver(&ar1520_driver);
+}
+
+module_init(ar1520_init);
+module_exit(ar1520_exit);
+
+MODULE_AUTHOR("Allen Kao<[email protected]>");
+MODULE_DESCRIPTION("Atheros AR1520 Driver");
+MODULE_LICENSE("GPL v2");
diff -ruN linux-2.6-mid-ref/drivers/misc/Kconfig
linux-2.6-mid-ref.new/drivers/misc/Kconfig
--- linux-2.6-mid-ref/drivers/misc/Kconfig 2011-02-23 18:46:38.138668821
+0800
+++ linux-2.6-mid-ref.new/drivers/misc/Kconfig 2011-02-23 21:09:08.815167924
+0800
@@ -371,6 +371,15 @@
This driver provides support for the Honeywell HMC6352 compass,
providing configuration and heading data via sysfs.
+config AR1520
+ tristate "Atheros AR1520 support"
+ depends on I2C
+ ---help---
+ Say Y here if you want to build a driver for Atheros AR1520 GPS chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ar1520. If unsure, say N here.
+
config EP93XX_PWM
tristate "EP93xx PWM support"
depends on ARCH_EP93XX
diff -ruN linux-2.6-mid-ref/drivers/misc/Makefile
linux-2.6-mid-ref.new/drivers/misc/Makefile
--- linux-2.6-mid-ref/drivers/misc/Makefile 2011-02-23 18:46:38.138668821 +0800
+++ linux-2.6-mid-ref.new/drivers/misc/Makefile 2011-02-23 21:09:19.042669114
+0800
@@ -36,6 +36,7 @@
obj-$(CONFIG_C2PORT) += c2port/
obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/
obj-$(CONFIG_HMC6352) += hmc6352.o
+obj-$(CONFIG_AR1520) += ar1520.o
obj-y += eeprom/
obj-y += cb710/
obj-$(CONFIG_VMWARE_BALLOON) += vmw_balloon.o
diff -ruN linux-2.6-mid-ref/include/linux/ar1520.h
linux-2.6-mid-ref.new/include/linux/ar1520.h
--- linux-2.6-mid-ref/include/linux/ar1520.h 1970-01-01 08:00:00.000000000 +0800
+++ linux-2.6-mid-ref.new/include/linux/ar1520.h 2011-02-23
21:09:38.038668029 +0800
@@ -0,0 +1,19 @@
+#ifndef LINUX_AR1520_H
+#define LINUX_AR1520_H
+
+struct ar1520_gps_platform_data {
+ unsigned gps_gpio_rts;
+ unsigned gps_irq;
+ void (*cleanup)(struct i2c_client *client);
+ void (*enable)(struct i2c_client *client);
+};
+
+struct ar1520_gps_data {
+ unsigned gps_gpio_rts;
+ unsigned gps_irq;
+ struct i2c_client *client;
+ struct ar1520_gps_platform_data *pdata;
+ int flag;
+};
+
+#endif
=================================================================================================================
Allen Kao
Atheros Internation Ltd., Taiwan Branch
12F, No. 407, Ruiguang Rd.,
Neihu Dist., Taipei City 11492, Taiwan, R.O.C.
Tel: +886-2-87516385 Ext. 1635
email: [email protected]
_______________________________________________
MeeGo-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel