Re: [PATCH] input: joystick: Adding Austria Microsystem AS5011 joystick driver (second version)

Previous thread: [PATCH][zram] Do not check for init flag before starting I/O by Nitin Gupta on Thursday, December 30, 2010 - 2:07 am. (4 messages)

Next thread: [RFC V8 7/7] drivers:media:radio: Update Kconfig and Makefile for wl128x FM driver. by manjunatha_halli on Thursday, December 30, 2010 - 4:11 am. (1 message)
From: Fabien Marteau
Date: Thursday, December 30, 2010 - 3:37 am

Driver for EasyPoint AS5011 2 axis joystick chip. This chip is plugged
on an I2C bus. It has been tested on ARM processor (i.MX27).

Interruptions are now managed by threaded irq.

Signed-off-by: Fabien Marteau <fabien.marteau@armadeus.com>
---
 drivers/input/joystick/Kconfig  |    9 +
 drivers/input/joystick/Makefile |    1 +
 drivers/input/joystick/as5011.c |  417 +++++++++++++++++++++++++++++++++++++++
 include/linux/as5011.h          |   76 +++++++
 4 files changed, 503 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/joystick/as5011.c
 create mode 100644 include/linux/as5011.h

diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
index 5b59616..5fad03e 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -255,6 +255,15 @@ config JOYSTICK_AMIGA
 	  To compile this driver as a module, choose M here: the
 	  module will be called amijoy.

+config JOYSTICK_AS5011
+	tristate "Austria Microsystem AS5011 joystick"
+	depends on I2C
+	help
+	  Say Y here if you have an AS5011 digital joystick.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called as5011.
+
 config JOYSTICK_JOYDUMP
 	tristate "Gameport data dumper"
 	select GAMEPORT
diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
index f3a8cbe..92dc0de 100644
--- a/drivers/input/joystick/Makefile
+++ b/drivers/input/joystick/Makefile
@@ -7,6 +7,7 @@
 obj-$(CONFIG_JOYSTICK_A3D)		+= a3d.o
 obj-$(CONFIG_JOYSTICK_ADI)		+= adi.o
 obj-$(CONFIG_JOYSTICK_AMIGA)		+= amijoy.o
+obj-$(CONFIG_JOYSTICK_AS5011)		+= as5011.o
 obj-$(CONFIG_JOYSTICK_ANALOG)		+= analog.o
 obj-$(CONFIG_JOYSTICK_COBRA)		+= cobra.o
 obj-$(CONFIG_JOYSTICK_DB9)		+= db9.o
diff --git a/drivers/input/joystick/as5011.c b/drivers/input/joystick/as5011.c
new file mode 100644
index 0000000..9f65357
--- /dev/null
+++ b/drivers/input/joystick/as5011.c
@@ -0,0 +1,417 @@
+/*
+ * Copyright (c) 2010 Fabien Marteau ...
From: Trilok Soni
Date: Friday, December 31, 2010 - 3:14 am

Hi Fabien,




Please re-arrange these functions in such a way that you don't need















You should better do gpio_request/free etc, in the driver itself,



---Trilok Soni


-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--

From: Fabien Marteau
Date: Friday, December 31, 2010 - 4:38 am

It's for interruptions name, if several as5011 joystick I set a number different for each joystick :

	scnprintf(plat_dat->button_irq_name,
		  SIZE_NAME,
		  "as5011_%d_button",

It's required for i2c register reading. To read register as5011 chip use this i2c frames :
	S Addr Rd [A] Register_addr [A] [Data] NA P
Wich is not conform to i2c protocol, i2c protocol require a repeated start to do that :
	S Addr Wr [A] Register_addr [A] S Addr Rd [Data] NA P


Yes, but on my platform, requesting gpio are specific. And I have to configure irq edge on initialization :
static int as5011_init_gpio(void)
{
	int ret;

	ret = mxc_gpio_setup_multiple_pins(as5011_pins0,
					   ARRAY_SIZE(as5011_pins0),
					   "AS5011_0");
	if (ret < 0) {
		goto as5011_gpio_setup_error;
	}
	set_irq_type(AS5011_INT_IRQ, IRQ_TYPE_EDGE_FALLING);
	set_irq_type(AS5011_BUTTON_IRQ, IRQ_TYPE_EDGE_BOTH);
	return ret;

	mxc_gpio_release_multiple_pins(as5011_pins0, ARRAY_SIZE(as5011_pins0));
as5011_gpio_setup_error:
	return ret;
Thanks for the review.

--- Fabien Marteau
--

From: Dmitry Torokhov
Date: Sunday, January 2, 2011 - 12:41 am

Hi Fabien,




Right, but who cares about having different names? Just mark all
interrupts as5011_button and as5011_joystick or even simply use "as5011"
for everything and call it a day.

-- 
Dmitry
--

From: Dmitry Torokhov
Date: Sunday, January 2, 2011 - 12:58 am

This is improper value for 'uniq' which has to be globally unique


__set_bit() is shorter and generally safer (no chance of writing to
wrong longword).

-- 
Dmitry
--

Previous thread: [PATCH][zram] Do not check for init flag before starting I/O by Nitin Gupta on Thursday, December 30, 2010 - 2:07 am. (4 messages)

Next thread: [RFC V8 7/7] drivers:media:radio: Update Kconfig and Makefile for wl128x FM driver. by manjunatha_halli on Thursday, December 30, 2010 - 4:11 am. (1 message)