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

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
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
......@@ -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,52 +108,57 @@ 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
0,
0,
0,
0,
0,
0,
0,
0, // 60
0,
0,
KEY_SEARCH, // add search key map
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, // 70
0,
0,
KEY_KP5, //73 for JP keyboard '\' key, report 0x4c
0,
0,
0,
0,
0,
0,
0,
0,
0,
KEY_KP9, //7d for JP keyboard '|' key, report 0x49
/* VK_OEM_102 */
KEY_102ND,
KEY_F11,
KEY_F12,
0,
0,
0,
0,
0,
0,
0,
/* 0x60 */
0,
0,
0,
KEY_SEARCH,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
/* 0x70 */
0,
0,
0,
KEY_KP5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
KEY_KP9,
};
static unsigned short extcode_tab_us102[] = {
......@@ -167,27 +178,35 @@ 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,
0, //VK_MEDIA_NEXT_TRACK,
/* 0x20 */
KEY_MUTE,
/* VK_LAUNCH_APP1 */
0,
/* VK_MEDIA_PLAY_PAUSE */
0,
0, //VK_RETURN,
KEY_RIGHTCTRL, //VK_RCONTROL,
0,
/* VK_MEDIA_STOP */
0,
KEY_MUTE, // 0xE0 0x20
0, //VK_LAUNCH_APP1
0, //VK_MEDIA_PLAY_PAUSE
0,
0, //VK_MEDIA_STOP
0,
0,
0,
......@@ -198,41 +217,54 @@ static unsigned short extcode_tab_us102[] = {
0,
0,
0,
/* 0x30 */
KEY_VOLUMEUP,
0,
KEY_VOLUMEUP, // 0xE0 0x30
/* 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,
/* 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
0,
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 };
static unsigned short *code_tabs[] = { code_tab_102us, extcode_tab_us102 };
This diff is collapsed.
/*
* 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
......@@ -17,7 +32,7 @@ typedef enum {
} how_care;
typedef enum {
NVEC_SYS=1,
NVEC_SYS = 1,
NVEC_BAT,
NVEC_KBD = 5,
NVEC_PS2,
......@@ -27,9 +42,9 @@ typedef enum {
} nvec_event;
typedef enum {
NVEC_WAIT,
NVEC_READ,
NVEC_WRITE
NVEC_WAIT,
NVEC_READ,
NVEC_WRITE
} nvec_state;
struct nvec_msg {
......@@ -64,22 +79,27 @@ struct nvec_chip {
struct work_struct rx_work, tx_work;
struct nvec_msg *rx, *tx;
/* sync write stuff */
/* sync write stuff */
struct semaphore sync_write_mutex;
struct completion sync_write;
u16 sync_write_pending;
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)
......
/*
* 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"
#define ACK_KBD_EVENT {'\x05', '\xed', '\x01'}
static unsigned char keycodes[ARRAY_SIZE(code_tab_102us)
+ ARRAY_SIZE(extcode_tab_us102)];
+ ARRAY_SIZE(extcode_tab_us102)];
struct nvec_keys {
struct input_dev *input;
......@@ -20,7 +35,7 @@ struct nvec_keys {
static struct nvec_keys keys_dev;
static int nvec_keys_notifier(struct notifier_block *nb,
unsigned long event_type, void *data)
unsigned long event_type, void *data)
{
int code, state;
unsigned char *msg = (unsigned char *)data;
......@@ -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;
......@@ -48,7 +64,7 @@ static int nvec_keys_notifier(struct notifier_block *nb,
}
static int nvec_kbd_event(struct input_dev *dev, unsigned int type,
unsigned int code, int value)
unsigned int code, int value)
{
unsigned char buf[] = ACK_KBD_EVENT;
struct nvec_chip *nvec = keys_dev.nvec;
......@@ -125,10 +141,10 @@ static int __devinit nvec_kbd_probe(struct platform_device *pdev)
}
static struct platform_driver nvec_kbd_driver = {
.probe = nvec_kbd_probe,
.driver = {
.name = "nvec-kbd",
.owner = THIS_MODULE,
.probe = nvec_kbd_probe,
.driver = {
.name = "nvec-kbd",
.owner = THIS_MODULE,
},
};
......@@ -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");
This diff is collapsed.
/*
* nvec_ps2: mouse 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>
* 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 <linux/module.h>
#include <linux/slab.h>
#include <linux/serio.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include "nvec.h"
#define START_STREAMING {'\x06','\x03','\x01'}
#define STOP_STREAMING {'\x06','\x04'}
#define SEND_COMMAND {'\x06','\x01','\xf4','\x01'}
#define START_STREAMING {'\x06', '\x03', '\x01'}
#define STOP_STREAMING {'\x06', '\x04'}
#define SEND_COMMAND {'\x06', '\x01', '\xf4', '\x01'}
struct nvec_ps2
{
static const unsigned char MOUSE_RESET[] = {'\x06', '\x01', '\xff', '\x03'};
struct nvec_ps2 {
struct serio *ser_dev;
struct notifier_block notifier;
struct nvec_chip *nvec;
......@@ -31,12 +48,6 @@ static void ps2_stopstreaming(struct serio *ser_dev)
nvec_write_async(ps2_dev.nvec, buf, sizeof(buf));
}
/* is this really needed?
static void nvec_resp_handler(unsigned char *data) {
serio_interrupt(ser_dev, data[4], 0);
}
*/
static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd)
{
unsigned char buf[] = SEND_COMMAND;
......@@ -50,47 +61,44 @@ static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd)
}
static int nvec_ps2_notifier(struct notifier_block *nb,
unsigned long event_type, void *data)
unsigned long event_type, void *data)
{
int i;
unsigned char *msg = (unsigned char *)data;
switch (event_type) {
case NVEC_PS2_EVT:
serio_interrupt(ps2_dev.ser_dev, msg[2], 0);
return NOTIFY_STOP;
case NVEC_PS2:
if (msg[2] == 1)
for(i = 0; i < (msg[1] - 2); i++)
serio_interrupt(ps2_dev.ser_dev, msg[i+4], 0);
else if (msg[1] != 2) /* !ack */
{
printk("nvec_ps2: unhandled mouse event ");
for(i = 0; i <= (msg[1]+1); i++)
printk("%02x ", msg[i]);
printk(".\n");
}
return NOTIFY_STOP;
case NVEC_PS2_EVT:
serio_interrupt(ps2_dev.ser_dev, msg[2], 0);
return NOTIFY_STOP;
case NVEC_PS2:
if (msg[2] == 1)
for (i = 0; i < (msg[1] - 2); i++)
serio_interrupt(ps2_dev.ser_dev, msg[i + 4], 0);
else if (msg[1] != 2) { /* !ack */
print_hex_dump(KERN_WARNING, "unhandled mouse event: ",
DUMP_PREFIX_NONE, 16, 1,
msg, msg[1] + 2, true);
}
return NOTIFY_STOP;
}
return NOTIFY_DONE;
}
static int __devinit nvec_mouse_probe(struct platform_device *pdev)
{
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
struct serio *ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL);
ser_dev->id.type=SERIO_8042;
ser_dev->write=ps2_sendcommand;
ser_dev->open=ps2_startstreaming;
ser_dev->close=ps2_stopstreaming;
ser_dev->id.type = SERIO_8042;
ser_dev->write = ps2_sendcommand;
ser_dev->open = ps2_startstreaming;
ser_dev->close = ps2_stopstreaming;
strlcpy(ser_dev->name, "NVEC PS2", sizeof(ser_dev->name));
strlcpy(ser_dev->phys, "NVEC I2C slave", sizeof(ser_dev->phys));
strlcpy(ser_dev->name, "nvec mouse", sizeof(ser_dev->name));
strlcpy(ser_dev->phys, "nvec", sizeof(ser_dev->phys));
ps2_dev.ser_dev = ser_dev;
ps2_dev.notifier.notifier_call = nvec_ps2_notifier;
......@@ -100,16 +108,16 @@ static int __devinit nvec_mouse_probe(struct platform_device *pdev)
serio_register_port(ser_dev);
/* mouse reset */
nvec_write_async(nvec, "\x06\x01\xff\x03", 4);
nvec_write_async(nvec, MOUSE_RESET, 4);
return 0;
}
static struct platform_driver nvec_mouse_driver = {
.probe = nvec_mouse_probe,
.driver = {
.name = "nvec-mouse",
.owner = THIS_MODULE,
.probe = nvec_mouse_probe,
.driver = {
.name = "nvec-mouse",
.owner = THIS_MODULE,
},
};
......@@ -119,3 +127,7 @@ static int __init nvec_mouse_init(void)
}
module_init(nvec_mouse_init);
MODULE_DESCRIPTION("NVEC mouse driver");
MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>");
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment