All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wayne Lin <00601wayne@gmail.com>
To: linux-input@vger.kernel.org
Cc: wayne <wayne.lin@quantatw.com>
Subject: [RFC 06/36]  [Driver][Qualcomm 1070][EC_BRG] EC Bridge driver porting
Date: Mon, 26 Jul 2010 16:30:15 +0800	[thread overview]
Message-ID: <1280133045-25945-6-git-send-email-wayne.lin@quantatw.com> (raw)
In-Reply-To: <1280133045-25945-1-git-send-email-wayne.lin@quantatw.com>

From: wayne <wayne.lin@quantatw.com>

---
 drivers/hwmon/Kconfig    |    8 ++
 drivers/hwmon/Makefile   |    1 +
 drivers/hwmon/wpce775x.c |  166 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/wpce775x.h |   30 ++++++++
 4 files changed, 205 insertions(+), 0 deletions(-)
 create mode 100755 drivers/hwmon/wpce775x.c
 create mode 100755 include/linux/wpce775x.h

diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 83a283e..d652272 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1061,4 +1061,12 @@ config SENSORS_ISL29011
         help
           ISL29011 Light Sensor Driver implemented by Quanta.
 
+config SENSORS_WPCE775X
+  	tristate "Winbond WPCE775X"
+  	depends on I2C
+  	default n
+        help
+	  This driver provides support for the Winbond WPCE775XX Embedded
+	  Controller, which provides lcd backlight, LEDs, and Battery control.
+
 endif # HWMON
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 6237580..fb99aa8 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -94,6 +94,7 @@ obj-$(CONFIG_SENSORS_W83L786NG)	+= w83l786ng.o
 obj-$(CONFIG_SENSORS_WM831X)	+= wm831x-hwmon.o
 obj-$(CONFIG_SENSORS_WM8350)	+= wm8350-hwmon.o
 obj-$(CONFIG_SENSORS_ISL29011)  += isl29011.o
+obj-$(CONFIG_SENSORS_WPCE775X)  += wpce775x.o
 
 ifeq ($(CONFIG_HWMON_DEBUG_CHIP),y)
 EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/hwmon/wpce775x.c b/drivers/hwmon/wpce775x.c
new file mode 100755
index 0000000..dc296ea
--- /dev/null
+++ b/drivers/hwmon/wpce775x.c
@@ -0,0 +1,166 @@
+/* Quanta EC driver for the Winbond Embedded Controller
+ *
+ * Copyright (C) 2009 Quanta Computer Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/err.h>
+#include <linux/i2c.h>
+
+#define EC_ID_NAME          "qci-i2cec"
+#define EC_BUFFER_LEN		16
+#define EC_CMD_POWER_OFF	0xAC
+#define EC_CMD_RESTART	0xAB
+
+static struct i2c_client *g_i2cec_client;
+
+/* General structure to hold the driver data */
+struct i2cec_drv_data {
+		struct i2c_client *i2cec_client;
+		struct work_struct work;
+		char ec_data[EC_BUFFER_LEN+1];
+};
+
+static int __devinit wpce_probe(struct i2c_client *client,
+	const struct i2c_device_id *id);
+static int __devexit wpce_remove(struct i2c_client *kbd);
+
+#ifdef CONFIG_PM
+static int wpce_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int wpce_resume(struct device *dev)
+{
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PM
+static struct dev_pm_ops wpce_pm_ops = {
+	.suspend  = wpce_suspend,
+	.resume   = wpce_resume,
+};
+#endif
+
+static const struct i2c_device_id wpce_idtable[] = {
+       { EC_ID_NAME, 0 },
+       { }
+};
+
+static struct i2c_driver wpce_driver = {
+	.driver = {
+		.owner = THIS_MODULE,
+		.name  = EC_ID_NAME,
+#ifdef CONFIG_PM
+		.pm = &wpce_pm_ops,
+#endif
+	},
+	.probe	  = wpce_probe,
+	.remove	  = __devexit_p(wpce_remove),
+	.id_table   = wpce_idtable,
+};
+
+static int __devinit wpce_probe(struct i2c_client *client,
+				    const struct i2c_device_id *id)
+{
+	int err = -ENOMEM;
+	struct i2cec_drv_data *context = 0;
+
+	/* there is no need to call i2c_check_functionality() since it is the
+	client's job to use the interface (I2C vs SMBUS) appropriate for it. */
+	client->driver = &wpce_driver;
+	context = kzalloc(sizeof(struct i2cec_drv_data), GFP_KERNEL);
+	if (!context)
+		return err;
+
+	context->i2cec_client = client;
+	g_i2cec_client = client;
+	i2c_set_clientdata(context->i2cec_client, context);
+
+	return 0;
+}
+
+static int __devexit wpce_remove(struct i2c_client *dev)
+{
+	struct i2cec_drv_data *context = i2c_get_clientdata(dev);
+	g_i2cec_client = NULL;
+	kfree(context);
+
+	return 0;
+}
+
+static int __init wpce_init(void)
+{
+	return i2c_add_driver(&wpce_driver);
+}
+
+static void __exit wpce_exit(void)
+{
+	i2c_del_driver(&wpce_driver);
+}
+
+struct i2c_client *wpce_get_i2c_client(void)
+{
+	return g_i2cec_client;
+}
+EXPORT_SYMBOL_GPL(wpce_get_i2c_client);
+
+void wpce_poweroff(void)
+{
+	if (g_i2cec_client == NULL)
+		return;
+	i2c_smbus_write_byte(g_i2cec_client, EC_CMD_POWER_OFF);
+}
+EXPORT_SYMBOL_GPL(wpce_poweroff);
+
+void wpce_restart(void)
+{
+	if (g_i2cec_client == NULL)
+		return;
+	i2c_smbus_write_byte(g_i2cec_client, EC_CMD_RESTART);
+}
+EXPORT_SYMBOL_GPL(wpce_restart);
+
+int wpce_i2c_transfer(struct i2c_msg *msg)
+{
+	if (g_i2cec_client == NULL)
+		return -1;
+	msg->addr = g_i2cec_client->addr;
+	return i2c_transfer(g_i2cec_client->adapter, msg, 1);
+}
+EXPORT_SYMBOL_GPL(wpce_i2c_transfer);
+
+int wpce_smbus_write_word_data(u8 command, u16 value)
+{
+	if (g_i2cec_client == NULL)
+		return -1;
+	return i2c_smbus_write_word_data(g_i2cec_client, command, value);
+}
+EXPORT_SYMBOL_GPL(wpce_smbus_write_word_data);
+
+int wpce_smbus_write_byte_data(u8 command, u8 value)
+{
+	if (g_i2cec_client == NULL)
+		return -1;
+	return i2c_smbus_write_byte_data(g_i2cec_client, command, value);
+}
+EXPORT_SYMBOL_GPL(wpce_smbus_write_byte_data);
+
+module_init(wpce_init);
+module_exit(wpce_exit);
+
+MODULE_AUTHOR("Quanta Computer Inc.");
+MODULE_DESCRIPTION("Quanta Embedded Controller I2C Bridge Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/wpce775x.h b/include/linux/wpce775x.h
new file mode 100755
index 0000000..1803122
--- /dev/null
+++ b/include/linux/wpce775x.h
@@ -0,0 +1,30 @@
+/* Quanta EC driver for the Winbond Embedded Controller
+ *
+ * Copyright (C) 2009 Quanta Computer Inc.
+ * 
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#ifndef WPCE775X_DRV_H
+#define WPCE775X_DRV_H
+
+#include <linux/i2c.h>
+
+struct i2c_client *wpce_get_i2c_client(void);
+int wpce_smbus_write_word_data(u8 command, u16 value);
+struct i2c_client *wpce_get_i2c_client(void);
+void wpce_poweroff(void);
+void wpce_restart(void);
+int wpce_i2c_transfer(struct i2c_msg *msg);
+int wpce_smbus_write_word_data(u8 command, u16 value);
+int wpce_smbus_write_byte_data(u8 command, u8 value);
+
+#endif
-- 
1.7.0.4


  parent reply	other threads:[~2010-07-26  8:31 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-26  8:30 [RFC 01/36] [Driver][Qualcomm 1070][LCD] Resolve the booting to Chromium issue Wayne Lin
2010-07-26  8:30 ` [RFC 02/36] [Driver][Qualcomm 1070][USB] Register GPIO#109 for USB analog switch configuration Wayne Lin
2010-07-26  8:30 ` [RFC 04/36] [Driver][Qualcomm 1070][EC_KB] Adding new qci keyboard driver Wayne Lin
2010-07-26  8:55   ` Dmitry Torokhov
2010-07-26 11:16     ` Trilok Soni
2010-07-26  8:59   ` Datta, Shubhrajyoti
2010-07-26  8:30 ` [RFC 05/36] [Driver][Qualcomm 1070][TPM] Enable TPM module Wayne Lin
2010-07-26  8:30 ` Wayne Lin [this message]
2010-07-26  8:30 ` [RFC 07/36] [Driver][Qualcomm 1070][EC_BRG] Enable EC Bridge Wayne Lin
2010-07-26  8:30 ` [RFC 08/36] [Driver][Qualcomm 1070][EC_BAT] EC battery driver porting Wayne Lin
2010-07-26  8:30 ` [RFC 09/36] [Driver][Qualcomm 1070][EC_BAT] Enable EC battery Wayne Lin
2010-07-26  8:30 ` [RFC 11/36] [Driver][Qualcomm 1070][EC_G_SENSOR] Enable EC gravitation sensor Wayne Lin
2010-07-26  8:30 ` [RFC 12/36] [Driver][Qualcomm 1070][EC_C_SENSOR] EC compass sensor driver porting Wayne Lin
2010-07-26  8:30 ` [RFC 13/36] [Driver][Qualcomm 1070][EC_C_SENSOR] Enable EC compass sensor driver Wayne Lin
2010-07-26  8:30 ` [RFC 14/36] [Driver][Qualcomm 1070][CLOCK] Modify the AXI bus speed Wayne Lin
2010-07-26  8:30 ` [RFC 15/36] [Driver][Qualcomm 1070][VERSION] Adding version definition Wayne Lin
2010-07-26  8:30 ` [RFC 17/36] [Driver][Qualcomm 1070][WIFI/BT] Enable Athros WIFI driver Wayne Lin
2010-07-26  8:30 ` [RFC 18/36] [Driver][Qualcomm 1070][WIFI] Turn on the Athros WIFI power Wayne Lin
2010-07-26  8:30 ` [RFC 19/36] [Driver][Qualcomm 1070][BT] Enable Athros BT driver Wayne Lin
2010-07-26  8:30 ` [RFC 20/36] [Driver][Qualcomm 1070][WIFI/BT] Enable MMC1 dummy send read and configure Athros WIFI build-in driver Wayne Lin
2010-07-26  8:30 ` [RFC 21/36] Revert " [Driver][Qualcomm 1070][CLOCK] Modify the AXI bus speed" Wayne Lin
2010-07-26  8:46   ` Dmitry Torokhov
2010-07-26  8:30 ` [RFC 22/36] [Driver][Qualcomm 1070][CLOCK] Modify the AXI bus maximum speed Wayne Lin
2010-07-26  8:30 ` [RFC 23/36] [Driver][Qualcomm 1065][AT_COMMAND]retrieve message Wayne Lin
2010-07-26  8:30 ` [RFC 24/36] [Driver][Qualcomm 1070][CLOCK] Modify the AXI clock for 1.2Ghz Wayne Lin
2010-07-26  8:30 ` [RFC 25/36] [Driver][Qualcomm 1070][EC_BRG] Adding new EC bridge driver Wayne Lin
2010-07-26  8:30 ` [RFC 26/36] [Driver][Qualcomm 1070][EC_BL] New EC backlight driver porting Wayne Lin
2010-07-26  8:30 ` [RFC 27/36] [Driver][Qualcomm 1070][EC_BRG] Enable NuvoTon WPCE775X driver and disable WinBond WPCE775X driver Wayne Lin
2010-07-26  8:30 ` [RFC 28/36] [Driver][Qualcomm 1070][EC_BL] Enable QCI backlight driver Wayne Lin
2010-07-26  8:30 ` [RFC 29/36] [Driver][Qualcomm 1070][EC_BRG] Correct new EC bridge driver Makefile and Kconfig Wayne Lin
2010-07-26  8:30 ` [RFC 30/36] [Driver][Qualcomm 1070][EC_G_SENSOR] Enable EC gravitation sensor Wayne Lin
2010-07-26  8:30 ` [RFC 31/36] [Driver][Qualcomm 1070][VERSION] 0.1.1 Wayne Lin
2010-07-26  8:30 ` [RFC 32/36] [Driver][Qualcomm 1070][MMC] Enable MMC1 HW detection Wayne Lin
2010-07-26  8:30 ` [RFC 33/36] [Driver][Qualcomm 1070][VERSION] 0.1.2 Wayne Lin
2010-07-26  8:30 ` [RFC 34/36] [Driver][Qualcomm 1070][EC_BAT] Adding newer version battery driver Wayne Lin
2010-07-26  8:30 ` [RFC 35/36] [Driver][Qualcomm 1070][EC_BAT] Enable EC battery Wayne Lin
2010-07-26  8:30 ` [RFC 36/36] [Driver][Qualcomm 1070][VERSION] 0.2.0 Wayne Lin
2010-07-26  8:40   ` Premi, Sanjeev
2010-07-26  8:47   ` Premi, Sanjeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1280133045-25945-6-git-send-email-wayne.lin@quantatw.com \
    --to=00601wayne@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=wayne.lin@quantatw.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.