Commit 162c7d8c authored by Marc Dietrich's avatar Marc Dietrich Committed by Greg Kroah-Hartman
Browse files

staging: nvec: coding style fixes / add copyright notice



This patch fixes coding style and adds copyright notices.

Signed-off-by: default avatarMarc Dietrich <marvin24@gmx.de>
[jak@jak-linux.org: Merge later cleanup into that patch]
Signed-off-by: default avatarJulian Andres Klode <jak@jak-linux.org>
Acked-by: default avatarMarc Dietrich <marvin24@gmx.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7974035c
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
ToDo list (incomplete, unordered)
	- convert mouse, keyboard, and power to platform devices
	- add copyright / driver author / license
	- add compile as module support
	- move nvec devices to mfd cells?
	- adjust to kernel style
	- fix clk usage
	  should not be using clk_get_sys(), but clk_get(&pdev->dev, conn)
	  where conn is either NULL if the device only has one clock, or
	  the device specific name if it has multiple clocks.
	- move half of the nvec init stuff to i2c-tegra.c
+133 −92
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@
 */

static unsigned short code_tab_102us[] = {
	KEY_GRAVE,	// 0x00
	/* 0x00 */
	KEY_GRAVE,
	KEY_ESC,
	KEY_1,
	KEY_2,
@@ -38,7 +39,8 @@ static unsigned short code_tab_102us[] = {
	KEY_EQUAL,
	KEY_BACKSPACE,
	KEY_TAB,
	KEY_Q,		// 0x10
	/* 0x10 */
	KEY_Q,
	KEY_W,
	KEY_E,
	KEY_R,
@@ -54,7 +56,8 @@ static unsigned short code_tab_102us[] = {
	KEY_LEFTCTRL,
	KEY_A,
	KEY_S,
	KEY_D,		// 0x20
	/* 0x20 */
	KEY_D,
	KEY_F,
	KEY_G,
	KEY_H,
@@ -70,7 +73,8 @@ static unsigned short code_tab_102us[] = {
	KEY_X,
	KEY_C,
	KEY_V,
	KEY_B,		// 0x30
	/* 0x30 */
	KEY_B,
	KEY_N,
	KEY_M,
	KEY_COMMA,
@@ -86,13 +90,15 @@ static unsigned short code_tab_102us[] = {
	KEY_F3,
	KEY_F4,
	KEY_F5,
	KEY_F6,		// 0x40
	/* 0x40 */
	KEY_F6,
	KEY_F7,
	KEY_F8,
	KEY_F9,
	KEY_F10,
	KEY_FN,
	0,		//VK_SCROLL
	/* VK_SCROLL */
	0,
	KEY_KP7,
	KEY_KP8,
	KEY_KP9,
@@ -102,26 +108,30 @@ static unsigned short code_tab_102us[] = {
	KEY_KP6,
	KEY_KPPLUS,
	KEY_KP1,
	KEY_KP2,	// 0x50
	/* 0x50 */
	KEY_KP2,
	KEY_KP3,
	KEY_KP0,
	KEY_KPDOT,
	KEY_MENU,		//VK_SNAPSHOT
	/* VK_SNAPSHOT */
	KEY_MENU,
	KEY_POWER,
	KEY_102ND,		//VK_OEM_102   henry+ 0x2B (43) BACKSLASH have been used,change to use 0X56 (86)
	KEY_F11,		//VK_F11
	KEY_F12,		//VK_F12
	/* VK_OEM_102 */
	KEY_102ND,
	KEY_F11,
	KEY_F12,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	/* 0x60 */
	0,
	0, // 60 
	0,
	0,
	KEY_SEARCH, // add search key map 
	KEY_SEARCH,
	0,
	0,
	0,
@@ -134,10 +144,11 @@ static unsigned short code_tab_102us[] = {
	0,
	0,
	0,
	0, // 70 
	/* 0x70 */
	0,
	0,
	KEY_KP5,  //73 for JP keyboard '\' key, report 0x4c
	0,
	KEY_KP5,
	0,
	0,
	0,
@@ -147,7 +158,7 @@ static unsigned short code_tab_102us[] = {
	0,
	0,
	0,
	KEY_KP9, //7d  for JP keyboard '|' key, report 0x49
	KEY_KP9,
};

static unsigned short extcode_tab_us102[] = {
@@ -167,72 +178,93 @@ static unsigned short extcode_tab_us102[] = {
	0,
	0,
	0,
	0,		// 0xE0 0x10
	/* 0x10 */
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	/* VK_MEDIA_NEXT_TRACK */
	0,
	0,
	0,
	/* VK_RETURN */
	0,
	KEY_RIGHTCTRL,
	0,
	0,
	/* 0x20 */
	KEY_MUTE,
	/* VK_LAUNCH_APP1 */
	0,
	/* VK_MEDIA_PLAY_PAUSE */
	0,
	0,
	/* VK_MEDIA_STOP */
	0,
	0,
	0,
	0,		//VK_MEDIA_NEXT_TRACK,
	0,
	0,
	0,		//VK_RETURN,
	KEY_RIGHTCTRL,		//VK_RCONTROL,
	0,
	0,
	KEY_MUTE,	// 0xE0 0x20
	0,		//VK_LAUNCH_APP1
	0,		//VK_MEDIA_PLAY_PAUSE
	0,
	0,		//VK_MEDIA_STOP
	0,
	0,
	0,
	0,
	/* 0x30 */
	KEY_VOLUMEUP,
	0,
	/* VK_BROWSER_HOME */
	0,
	0,
	0,
	/* VK_DIVIDE */
	KEY_KPSLASH,
	0,
	/* VK_SNAPSHOT */
	KEY_SYSRQ,
	/* VK_RMENU */
	KEY_RIGHTALT,
	/* VK_OEM_NV_BACKLIGHT_UP */
	0,
	/* VK_OEM_NV_BACKLIGHT_DN */
	0,
	KEY_VOLUMEUP,	// 0xE0 0x30
	/* VK_OEM_NV_BACKLIGHT_AUTOTOGGLE */
	0,
	/* VK_OEM_NV_POWER_INFO */
	0,
	/* VK_OEM_NV_WIFI_TOGGLE */
	0,
	/* VK_OEM_NV_DISPLAY_SELECT */
	0,
	/* VK_OEM_NV_AIRPLANE_TOGGLE */
	0,
	/* 0x40 */
	0,
	KEY_LEFT,
	0,
	0,		//VK_BROWSER_HOME
	0,
	0,
	KEY_KPSLASH,	//VK_DIVIDE
	0,
	KEY_SYSRQ,		//VK_SNAPSHOT
	KEY_RIGHTALT,		//VK_RMENU
	0,		//VK_OEM_NV_BACKLIGHT_UP
	0,		//VK_OEM_NV_BACKLIGHT_DN
	0,		//VK_OEM_NV_BACKLIGHT_AUTOTOGGLE
	0,		//VK_OEM_NV_POWER_INFO
	0,		//VK_OEM_NV_WIFI_TOGGLE
	0,		//VK_OEM_NV_DISPLAY_SELECT
	0,		//VK_OEM_NV_AIRPLANE_TOGGLE
	0,		//0xE0 0x40
	KEY_LEFT,		//VK_OEM_NV_RESERVED    henry+ for JP keyboard
	0,		//VK_OEM_NV_RESERVED
	0,		//VK_OEM_NV_RESERVED
	0,		//VK_OEM_NV_RESERVED
	0,		//VK_OEM_NV_RESERVED
	KEY_CANCEL,
	KEY_HOME,
	KEY_UP,
	KEY_PAGEUP,		//VK_PRIOR
	KEY_PAGEUP,
	0,
	KEY_LEFT,
	0,
	KEY_RIGHT,
	0,
	KEY_END,
	KEY_DOWN,	// 0xE0 0x50
	KEY_PAGEDOWN,		//VK_NEXT
	/* 0x50 */
	KEY_DOWN,
	KEY_PAGEDOWN,
	KEY_INSERT,
	KEY_DELETE,
	0,
@@ -242,25 +274,34 @@ static unsigned short extcode_tab_us102[] = {
	0,
	0,
	0,
	KEY_LEFTMETA,	//VK_LWIN
	0,		//VK_RWIN
	KEY_ESC,	//VK_APPS
	KEY_KPMINUS, //for power button workaround
	KEY_LEFTMETA,
	0,
	KEY_ESC,
	KEY_KPMINUS,
	0,
	0,
	0,
	0,
	0,
	0,
	/* VK_BROWSER_SEARCH */
	0,
	/* VK_BROWSER_FAVORITES */
	0,
	/* VK_BROWSER_REFRESH */
	0,
	/* VK_BROWSER_STOP */
	0,
	/* VK_BROWSER_FORWARD */
	0,
	/* VK_BROWSER_BACK */
	0,
	/* VK_LAUNCH_APP2 */
	0,
	/* VK_LAUNCH_MAIL */
	0,
	/* VK_LAUNCH_MEDIA_SELECT */
	0,
	0,		//VK_BROWSER_SEARCH
	0,		//VK_BROWSER_FAVORITES
	0,		//VK_BROWSER_REFRESH
	0,		//VK_BROWSER_STOP
	0,		//VK_BROWSER_FORWARD
	0,		//VK_BROWSER_BACK
	0,		//VK_LAUNCH_APP2
	0,		//VK_LAUNCH_MAIL
	0,		//VK_LAUNCH_MEDIA_SELECT
};

static unsigned short *code_tabs[] = { code_tab_102us, extcode_tab_us102 };
+97 −94
Original line number Diff line number Diff line
// #define DEBUG

/* ToDo list (incomplete, unorderd)
	- convert mouse, keyboard, and power to platform devices
/*
 * NVEC: NVIDIA compliant embedded controller interface
 *
 * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.lauchpad.net>
 *
 * Authors:  Pierre-Hugues Husson <phhusson@free.fr>
 *           Ilya Petrov <ilya.muromec@gmail.com>
 *           Marc Dietrich <marvin24@gmx.de>
 *
 * 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.
 *
 */

#include <asm/io.h>
/* #define DEBUG */

#include <asm/irq.h>

#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/slab.h>
#include <linux/gpio.h>
@@ -16,18 +28,21 @@
#include <linux/input.h>
#include <linux/workqueue.h>
#include <linux/clk.h>
#include <mach/iomap.h>
#include <mach/clk.h>

#include <linux/semaphore.h>
#include <linux/list.h>
#include <linux/notifier.h>
#include <linux/platform_device.h>
#include <linux/mfd/core.h>

#include <mach/iomap.h>
#include <mach/clk.h>

#include "nvec.h"

static unsigned char EC_DISABLE_EVENT_REPORTING[] =	{'\x04','\x00','\x00'};
static unsigned char EC_ENABLE_EVENT_REPORTING[] =	{'\x04','\x00','\x01'};
static unsigned char EC_GET_FIRMWARE_VERSION[] =	{'\x07','\x15'};
static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00";
static const unsigned char EC_ENABLE_EVENT_REPORTING[3]  = "\x04\x00\x01";
static const unsigned char EC_GET_FIRMWARE_VERSION[2]    = "\x07\x15";

static struct nvec_chip *nvec_power_handle;

@@ -57,8 +72,8 @@ int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb,
}
EXPORT_SYMBOL_GPL(nvec_register_notifier);

static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_type,
				void *data)
static int nvec_status_notifier(struct notifier_block *nb,
				unsigned long event_type, void *data)
{
	unsigned char *msg = (unsigned char *)data;
	int i;
@@ -66,7 +81,7 @@ static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_t
	if (event_type != NVEC_CNTL)
		return NOTIFY_DONE;

	printk("unhandled msg type %ld, payload: ", event_type);
	printk(KERN_WARNING "unhandled msg type %ld, payload: ", event_type);
	for (i = 0; i < msg[1]; i++)
		printk("%0x ", msg[i+2]);
	printk("\n");
@@ -74,7 +89,8 @@ static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_t
	return NOTIFY_OK;
}

void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size)
void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data,
			short size)
{
	struct nvec_msg *msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT);

@@ -95,42 +111,43 @@ static void nvec_request_master(struct work_struct *work)
{
	struct nvec_chip *nvec = container_of(work, struct nvec_chip, tx_work);

	if(!list_empty(&nvec->tx_data)) {
	if (!list_empty(&nvec->tx_data))
		gpio_set_value(nvec->gpio, 0);
}
}

static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg)
{
	int i;

	if ((msg->data[0] & 1 << 7) == 0 && msg->data[3]) {
		dev_err(nvec->dev, "ec responded %02x %02x %02x %02x\n", msg->data[0],
			msg->data[1], msg->data[2], msg->data[3]);
		dev_err(nvec->dev, "ec responded %02x %02x %02x %02x\n",
			msg->data[0], msg->data[1], msg->data[2], msg->data[3]);
		return -EINVAL;
	}

	if ((msg->data[0] >> 7 ) == 1 && (msg->data[0] & 0x0f) == 5)
	{
	if ((msg->data[0] >> 7) == 1 && (msg->data[0] & 0x0f) == 5) {
		dev_warn(nvec->dev, "ec system event ");
		for (i = 0; i < msg->data[1]; i++)
			dev_warn(nvec->dev, "%02x ", msg->data[2+i]);
		dev_warn(nvec->dev, "\n");
	}

	atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f, msg->data);
	atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f,
				   msg->data);

	return 0;
}

static struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, unsigned char *data, short size)
static struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
					const unsigned char *data, short size)
{
	down(&nvec->sync_write_mutex);

	nvec->sync_write_pending = (data[1] << 8) + data[0];
	nvec_write_async(nvec, data, size);

	dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", nvec->sync_write_pending);
	dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n",
		nvec->sync_write_pending);
	wait_for_completion(&nvec->sync_write);
	dev_dbg(nvec->dev, "nvec_sync_write: pong!\n");

@@ -145,13 +162,12 @@ static void nvec_dispatch(struct work_struct *work)
	struct nvec_chip *nvec = container_of(work, struct nvec_chip, rx_work);
	struct nvec_msg *msg;

	while(!list_empty(&nvec->rx_data))
	{
	while (!list_empty(&nvec->rx_data)) {
		msg = list_first_entry(&nvec->rx_data, struct nvec_msg, node);
		list_del_init(&msg->node);

		if(nvec->sync_write_pending == (msg->data[2] << 8) + msg->data[0])
		{
		if (nvec->sync_write_pending ==
		    (msg->data[2] << 8) + msg->data[0]) {
			dev_dbg(nvec->dev, "sync write completed!\n");
			nvec->sync_write_pending = 0;
			nvec->last_sync_msg = msg;
@@ -159,7 +175,8 @@ static void nvec_dispatch(struct work_struct *work)
		} else {
			parse_msg(nvec, msg);
			if ((!msg) || (!msg->data))
				dev_warn(nvec->dev, "attempt access zero pointer\n");
				dev_warn(nvec->dev,
					"attempt access zero pointer\n");
			else {
				kfree(msg->data);
				kfree(msg);
@@ -179,20 +196,13 @@ static irqreturn_t nvec_interrupt(int irq, void *dev)

	status = readl(base + I2C_SL_STATUS);

	if(!(status & I2C_SL_IRQ))
	{
	if (!(status & I2C_SL_IRQ)) {
		dev_warn(nvec->dev, "nvec Spurious IRQ\n");
		//Yup, handled. ahum.
		goto handled;
	}
	if(status & END_TRANS && !(status & RCVD))
	{
		//Reenable IRQ only when even has been sent
		//printk("Write sequence ended !\n");
                //parse_msg(nvec);
	if (status & END_TRANS && !(status & RCVD)) {
		nvec->state = NVEC_WAIT;
		if(nvec->rx->size > 1)
		{
		if (nvec->rx->size > 1) {
			list_add_tail(&nvec->rx->node, &nvec->rx_data);
			schedule_work(&nvec->rx_work);
		} else {
@@ -200,41 +210,31 @@ static irqreturn_t nvec_interrupt(int irq, void *dev)
			kfree(nvec->rx);
		}
		return IRQ_HANDLED;
	} else if(status & RNW)
	{
		// Work around for AP20 New Slave Hw Bug. Give 1us extra.
		// nvec/smbus/nvec_i2c_transport.c in NV`s crap for reference
	} else if (status & RNW) {
		if (status & RCVD)
			udelay(3);

		if (status & RCVD)
		{
			nvec->state = NVEC_WRITE;
			//Master wants something from us. New communication
//			dev_dbg(nvec->dev, "New read comm!\n");
		} else {
			//Master wants something from us from a communication we've already started
//			dev_dbg(nvec->dev, "Read comm cont !\n");
		}
		//if(msg_pos<msg_size) {
		if(list_empty(&nvec->tx_data))
		{

		if (list_empty(&nvec->tx_data)) {
			dev_err(nvec->dev, "nvec empty tx - sending no-op\n");
			to_send = 0x8a;
			nvec_write_async(nvec, "\x07\x02", 2);
//			to_send = 0x01;
		} else {
			msg = list_first_entry(&nvec->tx_data, struct nvec_msg, node);
			msg =
			    list_first_entry(&nvec->tx_data, struct nvec_msg,
					     node);
			if (msg->pos < msg->size) {
				to_send = msg->data[msg->pos];
				msg->pos++;
			} else {
				dev_err(nvec->dev, "nvec crap! %d\n", msg->size);
				dev_err(nvec->dev, "nvec crap! %d\n",
					msg->size);
				to_send = 0x01;
			}

			if(msg->pos >= msg->size)
			{
			if (msg->pos >= msg->size) {
				list_del_init(&msg->node);
				kfree(msg->data);
				kfree(msg);
@@ -251,14 +251,13 @@ static irqreturn_t nvec_interrupt(int irq, void *dev)
		goto handled;
	} else {
		received = readl(base + I2C_SL_RCVD);
		//Workaround?

		if (status & RCVD) {
			writel(0, base + I2C_SL_RCVD);
			goto handled;
		}

		if (nvec->state == NVEC_WAIT)
		{
		if (nvec->state == NVEC_WAIT) {
			nvec->state = NVEC_READ;
			msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT);
			msg->data = kzalloc(32, GFP_NOWAIT);
@@ -272,7 +271,8 @@ static irqreturn_t nvec_interrupt(int irq, void *dev)
		msg->data[msg->pos] = received;
		msg->pos++;
		msg->size = msg->pos;
		dev_dbg(nvec->dev, "Got %02lx from Master (pos: %d)!\n", received, msg->pos);
		dev_dbg(nvec->dev, "Got %02lx from Master (pos: %d)!\n",
			received, msg->pos);
	}
handled:
	return IRQ_HANDLED;
@@ -460,8 +460,8 @@ static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state)
	return 0;
}

static int tegra_nvec_resume(struct platform_device *pdev) {

static int tegra_nvec_resume(struct platform_device *pdev)
{
	struct nvec_chip *nvec = platform_get_drvdata(pdev);

	dev_dbg(nvec->dev, "resuming\n");
@@ -476,8 +476,7 @@ static int tegra_nvec_resume(struct platform_device *pdev) {
#define tegra_nvec_resume NULL
#endif

static struct platform_driver nvec_device_driver =
{
static struct platform_driver nvec_device_driver = {
	.probe   = tegra_nvec_probe,
	.remove  = __devexit_p(tegra_nvec_remove),
	.suspend = tegra_nvec_suspend,
@@ -494,4 +493,8 @@ static int __init tegra_nvec_init(void)
}

module_init(tegra_nvec_init);

MODULE_ALIAS("platform:nvec");
MODULE_DESCRIPTION("NVIDIA compliant embedded controller interface");
MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>");
MODULE_LICENSE("GPL");
+29 −9
Original line number Diff line number Diff line
/*
 * NVEC: NVIDIA compliant embedded controller interface
 *
 * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.launchpad.net>
 *
 * Authors:  Pierre-Hugues Husson <phhusson@free.fr>
 *           Ilya Petrov <ilya.muromec@gmail.com>
 *           Marc Dietrich <marvin24@gmx.de>
 *
 * 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.
 *
 */

#ifndef __LINUX_MFD_NVEC
#define __LINUX_MFD_NVEC

@@ -71,15 +86,20 @@ struct nvec_chip {
	struct nvec_msg *last_sync_msg;
};

extern void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size);
extern void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data,
			     short size);

extern int nvec_register_notifier(struct nvec_chip *nvec,
		 struct notifier_block *nb, unsigned int events);
				  struct notifier_block *nb,
				  unsigned int events);

extern int nvec_unregister_notifier(struct device *dev,
		struct notifier_block *nb, unsigned int events);
				    struct notifier_block *nb,
				    unsigned int events);

const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, how_care care_resp, void (*rt_handler)(unsigned char *data));
const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size,
			  how_care care_resp,
			  void (*rt_handler) (unsigned char *data));

#define I2C_CNFG			0x00
#define I2C_CNFG_PACKET_MODE_EN		(1<<10)
+28 −8
Original line number Diff line number Diff line
/*
 * nvec_kbd: keyboard driver for a NVIDIA compliant embedded controller
 *
 * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.launchpad.net>
 *
 * Authors:  Pierre-Hugues Husson <phhusson@free.fr>
 *           Marc Dietrich <marvin24@gmx.de>
 *
 * 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.
 *
 */

#include <linux/module.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/delay.h>
#include <linux/platform_device.h>

#include "nvec-keytable.h"
#include "nvec.h"

@@ -38,7 +53,8 @@ static int nvec_keys_notifier(struct notifier_block *nb,
		code = msg[1] & 0x7f;
		state = msg[1] & 0x80;

		input_report_key(keys_dev.input, code_tabs[_size][code], !state);
		input_report_key(keys_dev.input, code_tabs[_size][code],
				 !state);
		input_sync(keys_dev.input);

		return NOTIFY_STOP;
@@ -138,3 +154,7 @@ static int __init nvec_kbd_init(void)
}

module_init(nvec_kbd_init);

MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>");
MODULE_DESCRIPTION("NVEC keyboard driver");
MODULE_LICENSE("GPL");
Loading