Skip to contentSkip to conversation

PXA LX platform support

PATCH In review Russell King - ARM Linux 5 participants 19 messages Apr 18, 2009 – Apr 22, 2009 7 messages not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover PXA LX platform support

The following series adds basic support for the LX platform. This platform is a portable small netbook style machine, with support for touch screen LCD, sound, MMC/SD, one serial port, CF, PCMCIA and MMC.

The entire series is posted to the linux-arm-kernel list; individual patches are only copied to relevent people/lists.

A message that is not in the archive (sent off-list or not yet received): 20090418141932.GA1236-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org

#2 lore raw

PATCH 1/5 pxa: lx: add PCON i2c driver

The PCON device on the LX platform is the heart of the platform, managing the power, providing battery information, booting, suspend/ resume and keyboard services to the PXA CPU.

Communication between the PXA and PCON is via a multi-master I2C bus, where both the PCON and PXA behave like an 256 byte EEPROM, and each reads and writes locations within that namespace.

It has a nasty habbit of resetting the PXA CPU if it sees something it doesn't like, so we have to be careful how we communicate with the PCON. This happens (eg) if we hold the I2C bus for any "unreasonable" length of time, or ignore the PCON's attempt to address us as a slave.

---
 arch/arm/mach-pxa/include/mach/lx-pcon.h |  117 ++++++++
 drivers/i2c/chips/Kconfig                |   10 +
 drivers/i2c/chips/Makefile               |    1 +
 drivers/i2c/chips/lx-pcon.c              |  428 ++++++++++++++++++++++++++++++
 4 files changed, 556 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-pxa/include/mach/lx-pcon.h
 create mode 100644 drivers/i2c/chips/lx-pcon.c
arch/arm/mach-pxa/include/mach/lx-pcon.h new file +117 -0
new file mode 100644
index 0000000..acc410d
@@ -0,0 +1,117 @@
+/*
+ * PCON addresses
+ */
+#define PCON_KEYBOARD_CMD_ADDR		(0x00)
+#define PCON_KEYBOARD_CMD_VAL_READY	(0)
+#define PCON_KEYBOARD_CMD_VAL_BUSY 	(1)
+#define PCON_POWER_CF_ADDR		(0x02)
+#define PCON_POWER_PCMCIA_ADDR		(0x03)
+#define PCON_POWER_CFG_ADDR		(0x04)
+#define PCON_PWRSTATE_ADDR		(0x05)
+#define PCON_CMD_ADDR			(0x0c)	/* 1 + 8 args */
+
+typedef enum pcon_pwrstate_e {
+	PCON_PWRSTATE_HWReset    = 0,
+	PCON_PWRSTATE_SWReset    = 1,
+	PCON_PWRSTATE_Off        = 2,
+	PCON_PWRSTATE_Suspend    = 3,
+	PCON_PWRSTATE_Sleep      = 4,
+	PCON_PWRSTATE_Booting    = 5,
+	PCON_PWRSTATE_LoadingOS  = 6,
+	PCON_PWRSTATE_Idle       = 7,
+	PCON_PWRSTATE_Run        = 8,
+	PCON_PWRSTATE_Comatose   = 9,
+	PCON_PWRSTATE_PowerFail  = 10
+} pcon_pwrstate_t;
+
+extern void lx_pwr_setstate(pcon_pwrstate_t);
+extern void pcon_pwr_setstate(pcon_pwrstate_t);
+
+typedef enum {
+	PCON_CMD_Ready          = 0,
+	PCON_CMD_ADCRead        = 9,
+	PCON_CMD_GetVersion     = 10,
+	PCON_CMD_SetMMCPower    = 11,
+	PCON_CMD_SetModemPower  = 12,
+	PCON_CMD_SetUSBPower    = 13,
+	PCON_CMD_SetRedLED      = 14,
+	PCON_CMD_SetSerialPower = 15,
+	PCON_CMD_GetSerialCfg   = 17,
+	PCON_CMD_BatteryMonitor = 18,
+	PCON_CMD_GetMMCPower    = 19,
+	PCON_CMD_GetVModemPower = 20,
+	PCON_CMD_GetUSBPower    = 21,
+	PCON_CMD_SetWakeupAlarm = 22,
+} pcon_cmd_t;
+
+/*
+ * Host EEPROM emulation addresses
+ */
+#define PHST_KEYBOARD_START		(0x00)
+#define PHST_KEYBOARD_SIZE		(1)
+#define PHST_SERIAL_START		(0x02)
+#define PHST_SERIAL_SIZE		(1)
+#define PHST_POWER_START		(0x05)
+#define PHST_POWER_SIZE			(1)
+#define PHST_CMDRESP_START		(0x0d)
+#define PHST_CMDRESP_SIZE		(8)
+
+struct lx_i2cslave_watcher {
+	u16 start;
+	u16 size;
+	void (*write)(void *, unsigned int addr, unsigned char newval);
+};
+
+struct lx_i2cslave_watch {
+	struct list_head node;
+	u16 start;
+	u16 end;
+	struct lx_i2cslave_watcher *ops;
+	void *data;
+};
+
+#define I2C_EEPROM_EMU_SIZE (256)
+
+struct lx_eeprom_emu {
+	u16 size;
+	u16 ptr;
+	unsigned int seen_start;
+	struct list_head watch;
+
+	unsigned char bytes[I2C_EEPROM_EMU_SIZE];
+};
+
+extern int lx_i2cslave_addwatcher(struct lx_i2cslave_watcher *, void *data);
+extern void lx_i2cslave_delwatcher(struct lx_i2cslave_watcher *, void *data);
+
+
+
+#define PCON_FLG_ASYNC          (1)
+
+/* exported functions */
+
+extern int pcon_simple_cmd(unsigned int, unsigned int, unsigned int);
+#define pcon_set_usbhost_power(on)	\
+	pcon_simple_cmd(PCON_CMD_SetUSBPower, !!(on), PCON_FLG_ASYNC)
+#define pcon_set_mmc_power(on)		\
+	pcon_simple_cmd(PCON_CMD_SetMMCPower, !!(on), 0)
+#define pcon_set_modem_power(on)	\
+	pcon_simple_cmd(PCON_CMD_SetModemPower, !!(on), 0)
+#define pcon_set_serial_power(on)	\
+	pcon_simple_cmd(PCON_CMD_SetSerialPower, !!(on), PCON_FLG_ASYNC)
+
+#define pcon_monitorbattery(on, flag)	\
+	pcon_simple_cmd(PCON_CMD_BatteryMonitor, !!(on), flag)
+#define pcon_setredled(on)		\
+	pcon_simple_cmd(PCON_CMD_SetRedLED, !!(on), 0)
+
+extern int pcon_simple_write(unsigned int, unsigned int, unsigned int);
+#define pcon_kbd_ack()			\
+	pcon_simple_write(PCON_KEYBOARD_CMD_ADDR, PCON_KEYBOARD_CMD_VAL_READY, PCON_FLG_ASYNC)
+#define pcon_set_pcmcia_power(on)	\
+	pcon_simple_write(PCON_POWER_PCMCIA_ADDR, !!(on), 0)
+#define pcon_set_cf_power(on)		\
+	pcon_simple_write(PCON_POWER_CF_ADDR, !!(on), 0)
+
+struct rtc_time;
+extern int pcon_rtc_wakeup(struct rtc_time *tm);
drivers/i2c/chips/Kconfig +10 -0
index 8f8c81e..501fb5d 100644
@@ -89,4 +89,14 @@ config SENSORS_TSL2550
 	  This driver can also be built as a module.  If so, the module
 	  will be called tsl2550.
 
+config LX_PCON
+	bool
+	depends on I2C=y && MACH_NETBOOKPRO
+	default y
+	help
+	  The LX PCON driver is required to communicate with the LX
+	  platform power control device.  This device is the heart
+	  of the system, providing power management and keyboard
+	  handling for the system.
+
 endmenu
drivers/i2c/chips/Makefile +1 -0
index 55a3760..871c8ae 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_SENSORS_MAX6875)	+= max6875.o
 obj-$(CONFIG_SENSORS_PCA9539)	+= pca9539.o
 obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
 obj-$(CONFIG_PCF8575)		+= pcf8575.o
+obj-$(CONFIG_LX_PCON)		+= lx-pcon.o
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 
 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
drivers/i2c/chips/lx-pcon.c new file +428 -0

428 lines not on this page · raw message

Signature · 1 line
1.6.0.6

A message that is not in the archive (sent off-list or not yet received): 1240064452-14691-1-git-send-email-linux-lFZ/[email protected]

#4 lore raw

Re: [PATCH 1/5] [ARM] pxa: lx: add PCON i2c driver

Quoted 13 lines · Russell King

The PCON device on the LX platform is the heart of the platform, managing the power, providing battery information, booting, suspend/ resume and keyboard services to the PXA CPU.

Communication between the PXA and PCON is via a multi-master I2C bus, where both the PCON and PXA behave like an 256 byte EEPROM, and each reads and writes locations within that namespace.

It has a nasty habbit of resetting the PXA CPU if it sees something it doesn't like, so we have to be careful how we communicate with the PCON. This happens (eg) if we hold the I2C bus for any "unreasonable" length of time, or ignore the PCON's attempt to address us as a slave.

Quoted 7 lines
---
 arch/arm/mach-pxa/include/mach/lx-pcon.h |  117 ++++++++
 drivers/i2c/chips/Kconfig                |   10 +
 drivers/i2c/chips/Makefile               |    1 +

Nack. Really, people, please read the files you modify, it isn't that hard.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [PATCH 1/5] [ARM] pxa: lx: add PCON i2c driver

Quoted 22 lines · Jean Delvare
Quoted 13 lines · Russell King

The PCON device on the LX platform is the heart of the platform, managing the power, providing battery information, booting, suspend/ resume and keyboard services to the PXA CPU.

Communication between the PXA and PCON is via a multi-master I2C bus, where both the PCON and PXA behave like an 256 byte EEPROM, and each reads and writes locations within that namespace.

It has a nasty habbit of resetting the PXA CPU if it sees something it doesn't like, so we have to be careful how we communicate with the PCON. This happens (eg) if we hold the I2C bus for any "unreasonable" length of time, or ignore the PCON's attempt to address us as a slave.

Quoted 7 lines
---
 arch/arm/mach-pxa/include/mach/lx-pcon.h |  117 ++++++++
 drivers/i2c/chips/Kconfig                |   10 +
 drivers/i2c/chips/Makefile               |    1 +
Quoted 2 lines

Nack. Really, people, please read the files you modify, it isn't that hard.

Maybe you can suggest a better place for it?

A message that is not in the archive (sent off-list or not yet received): 20090418144234.GB1236-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org

#8 lore raw

Re: [PATCH 1/5] [ARM] pxa: lx: add PCON i2c driver

Quoted 10 lines · Russell King - ARM Linux
Quoted 6 lines · Jean Delvare
Quoted 3 lines

The PCON device on the LX platform is the heart of the platform, managing the power, providing battery information, booting, suspend/ resume and keyboard services to the PXA CPU.

Nack. Really, people, please read the files you modify, it isn't that hard.

Maybe you can suggest a better place for it?

drivers/mfd?

#9 lore raw

Re: [PATCH 1/5] [ARM] pxa: lx: add PCON i2c driver

Quoted 7 lines · Mark Brown
Quoted 5 lines · Russell King - ARM Linux
Quoted 3 lines · Jean Delvare
Quoted 3 lines

The PCON device on the LX platform is the heart of the platform, managing the power, providing battery information, booting, suspend/ resume and keyboard services to the PXA CPU.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Nack. Really, people, please read the files you modify, it isn't that hard.

Maybe you can suggest a better place for it?

drivers/mfd?

It's not a multifunction device. It's a microcontroller.

-------------------------------------------------------------------

List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php

A message that is not in the archive (sent off-list or not yet received): 20090418181030.GC1236-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org

#11 lore raw

Re: [PATCH 1/5] [ARM] pxa: lx: add PCON i2c driver

Quoted 7 lines · Russell King - ARM Linux
Quoted 3 lines · Mark Brown
Quoted 1 line

Maybe you can suggest a better place for it?

drivers/mfd?

It's not a multifunction device. It's a microcontroller.

Surely that's just an implementation detail? As I understand your description the microcontroller is hiding the control interfaces of the other things it controls so the function is pretty similar.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw

Re: [PATCH 1/5] [ARM] pxa: lx: add PCON i2c driver

Quoted 5 lines · Mark Brown
Quoted 3 lines · Russell King - ARM Linux
Quoted 1 line · Mark Brown
Quoted 1 line

Maybe you can suggest a better place for it?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

drivers/mfd?

It's not a multifunction device. It's a microcontroller.

Surely that's just an implementation detail? As I understand your description the microcontroller is hiding the control interfaces of the other things it controls so the function is pretty similar.

No, it's a question of whether drivers/mfd is right. The "shovel everything that doesn't fit elsewhere into drivers/mfd" approach is just creating yet another problem, just like drivers/i2c/chips is percieved to be. The only difference is that it becomes someone elses problem.

I've a good mind to put it in arch/arm/mach-pxa/ purely as a way of bringing this issue to a close - it's far from ideal having drivers outside of the drivers/ tree, but if that's the way it has to be to progress, so be it.

A message that is not in the archive (sent off-list or not yet received): 20090420121805.GE3653-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org

#15 lore raw

Re: [PATCH 1/5] [ARM] pxa: lx: add PCON i2c driver

Quoted 11 lines · Russell King - ARM Linux
Quoted 3 lines · Mark Brown

Surely that's just an implementation detail? As I understand your description the microcontroller is hiding the control interfaces of the other things it controls so the function is pretty similar.

No, it's a question of whether drivers/mfd is right. The "shovel everything that doesn't fit elsewhere into drivers/mfd" approach is just creating yet another problem, just like drivers/i2c/chips is percieved to be. The only difference is that it becomes someone elses problem.

Well, my thinking was that it looks like you've got a bunch of subsystem-specific drivers for this chip with a core driver managing shared resources like I/O with the device. To my mind that's pretty much the use case for MFD.

As far as general dumping grounds goes we already have drivers/misc.

#16 lore raw

PATCH 3/5 pxa: lx: add keyboard driver

In reply to Russell King - ARM Linux

This adds support for the keyboard support on the LX platform. We aren't directly connected to the keyboard itself, but the keyboard is managed by PCON via the system I2C bus.

---
 drivers/input/keyboard/Kconfig  |    7 +
 drivers/input/keyboard/Makefile |    1 +
 drivers/input/keyboard/lx-kbd.c |  339 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 347 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/keyboard/lx-kbd.c
drivers/input/keyboard/Kconfig +7 -0
index ea2638b..54dc0fa 100644
@@ -289,6 +289,13 @@ config KEYBOARD_AAED2000
 	  To compile this driver as a module, choose M here: the
 	  module will be called aaed2000_kbd.
 
+config KEYBOARD_LX
+	tristate "LX Keyboard support"
+	depends on MACH_NETBOOKPRO && INPUT && INPUT_KEYBOARD
+	help
+	  Say Y here if you want to use the NetBookPro keyboard on your
+	  system.
+
 config KEYBOARD_GPIO
 	tristate "GPIO Buttons"
 	depends on GENERIC_GPIO
drivers/input/keyboard/Makefile +1 -0
index 36351e1..c475f79 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_KEYBOARD_OMAP)		+= omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)		+= pxa27x_keypad.o
 obj-$(CONFIG_KEYBOARD_PXA930_ROTARY)	+= pxa930_rotary.o
 obj-$(CONFIG_KEYBOARD_AAED2000)		+= aaed2000_kbd.o
+obj-$(CONFIG_KEYBOARD_LX)		+= lx-kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)		+= gpio_keys.o
 obj-$(CONFIG_KEYBOARD_HP6XX)		+= jornada680_kbd.o
 obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada720_kbd.o
drivers/input/keyboard/lx-kbd.c new file +339 -0

339 lines not on this page · raw message

Signature · 1 line
1.6.0.6
maintainer
#17 lore raw

Re: [PATCH 3/5] [ARM] pxa: lx: add keyboard driver

Hi Russell,

Quoted 4 lines · Russell King

This adds support for the keyboard support on the LX platform. We aren't directly connected to the keyboard itself, but the keyboard is managed by PCON via the system I2C bus.

Very nice driver. I prefer input devices having a private copy of keymap but I suppose there is just such device in the system anyways...

drivers/input/keyboard/Kconfig config KEYBOARD_AAED2000 · line 294

Quoted 4 lines
drivers/input/keyboard/Kconfig +3 -0
+config KEYBOARD_LX
+	tristate "LX Keyboard support"
+	depends on MACH_NETBOOKPRO && INPUT && INPUT_KEYBOARD

Dependancy on INPUT_KEYBOARD is not needed, strictly speaking. INPUT_KEYBOARD is only [menu]config syntactic sugar, there is no meat behind the option.

drivers/input/keyboard/lx-kbd.c line 207

Quoted 10 lines
drivers/input/keyboard/lx-kbd.c new file +10 -0
+
+	/*
+	 * Some keys have additional operations after we have
+	 * decoded them.  We don't report these "special" keys
+	 * to the input layer.
+	 */
+	switch (key) {
+	case KEY_BRIGHTNESSUP:
+	case KEY_BRIGHTNESSDOWN:
+		input_event(kbd, EV_PWR, key, !up);

Umm... some userspace apps might still want to get these. Strictly speaking KEY_* codes belong to EV_KEY namespace.

Quoted 21 lines
drivers/input/keyboard/lx-kbd.c new file +21 -0
+		break;
+
+	case KEY_SUSPEND:
+		input_event(kbd, EV_PWR, key, !up);
+#if defined(CONFIG_APM_EMULATION) && !defined(CONFIG_INPUT_APMPOWER)
+		if (!up)
+			apm_queue_event(APM_SYS_SUSPEND);
+#endif
+		break;
+
+	default:
+		input_report_key(kbd, key, !up);
+		break;
+	}
+}
+
+static void lx_keyb_reset(struct input_dev *kbd)
+{
+	unsigned char *map;
+	int key;
+

drivers/input/keyboard/lx-kbd.c line 238

Quoted 10 lines
drivers/input/keyboard/lx-kbd.c new file +10 -0
+	for (key = 0; key < LX_NUMKEYCODES; key++)
+		if (keystate[key] & KP_DOWN) {
+			map = normal_map;
+			if (keystate[key] & KP_FN)
+				map = fn_map;
+			else if (keystate[key] & KP_NUMLCK)
+				map = numlck_map;
+			keystate[key] = KP_NONE;
+			input_report_key(kbd, map[key], 0);
+		}

Why don't you just send 'up' event for all known keys? Input core will filter out the ones that have not been 'down'ed... Better yet, don't do anything here, I should finish adding forced release at suspend/resume to the input core shortly.

drivers/input/keyboard/lx-kbd.c line 245

Quoted 7 lines
drivers/input/keyboard/lx-kbd.c new file +7 -0
+
+	num_lck = 0;
+}
+
+static void lx_keyb_write(void *data, unsigned int addr, unsigned char val)
+{
+	struct input_dev *kbd = data;

Blank line between variables and the code is always appreciated ;)

Quoted 18 lines
drivers/input/keyboard/lx-kbd.c new file +18 -0
+	pcon_kbd_ack();
+	lx_keyb_process_key(kbd, val);
+}
+
+static struct lx_i2cslave_watcher lx_keyb_watcher = {
+	.start	= PHST_KEYBOARD_START,
+	.size	= PHST_KEYBOARD_SIZE,
+	.write	= lx_keyb_write,
+};
+
+static int lx_keyb_probe(struct platform_device *dev)
+{
+	struct input_dev *kbd;
+	int i, ret;
+
+	kbd = input_allocate_device();
+	if (!kbd)
+		return -ENOMEM;

drivers/input/keyboard/lx-kbd.c line 273

Quoted 10 lines
drivers/input/keyboard/lx-kbd.c new file +10 -0
+
+	kbd->name        = "LX Keyboard";
+	kbd->phys        = "pcon/input0";
+	kbd->dev.parent  = &dev->dev;
+	kbd->evbit[0]    = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
+			   BIT_MASK(EV_PWR);
+	kbd->keycode     = normal_map;
+	kbd->keycodesize = sizeof(unsigned char);
+	kbd->keycodemax  = ARRAY_SIZE(normal_map);
+

So we have 3 keymaps but only one can be changed form userspace... I suppose it is OK given how special the other 2 keymaps are. Or we could provide an alternative {get,set}keycode methods.

Quoted 42 lines
drivers/input/keyboard/lx-kbd.c new file +42 -0
+	for (i = 0; i < ARRAY_SIZE(normal_map); i++) {
+		if (normal_map[i])
+			__set_bit(normal_map[i], kbd->keybit);
+	}
+	for (i = 0; i < ARRAY_SIZE(numlck_map); i++) {
+		if (numlck_map[i])
+			__set_bit(numlck_map[i], kbd->keybit);
+	}
+	for (i = 0; i < ARRAY_SIZE(fn_map); i++) {
+		if (fn_map[i])
+			__set_bit(fn_map[i], kbd->keybit);
+	}
+
+	ret = input_register_device(kbd);
+	if (ret == 0) {
+		platform_set_drvdata(dev, kbd);
+		lx_i2cslave_addwatcher(&lx_keyb_watcher, kbd);
+	} else {
+		input_free_device(kbd);
+	}
+	return ret;
+}
+
+static int __devexit lx_keyb_remove(struct platform_device *dev)
+{
+	struct input_dev *kbd = platform_get_drvdata(dev);
+	platform_set_drvdata(dev, NULL);
+	lx_i2cslave_delwatcher(&lx_keyb_watcher, kbd);
+	input_unregister_device(kbd);
+	return 0;
+}
+
+static int lx_keyb_resume(struct platform_device *dev)
+{
+	struct input_dev *kbd = platform_get_drvdata(dev);
+	lx_keyb_reset(kbd);
+	return 0;
+}
+
+static struct platform_driver lx_kbd = {
+	.driver = {
+		.name	= "lx-kbd",

drivers/input/keyboard/lx-kbd.c line 325

Quoted 10 lines
drivers/input/keyboard/lx-kbd.c new file +10 -0
+		.owner	= THIS_MODULE,
+	},
+	.probe	= lx_keyb_probe,
+	.remove	= __devexit_p(lx_keyb_remove),
+	.resume	= lx_keyb_resume,
+};
+
+static int __init lx_keyb_init(void)
+{
+	printk(KERN_INFO "LX Keyboard Driver, (c) 2004 Simtec Electronics\n");

Is this needed? Input core will already add printk when input device is added and our boot is already chatty enough...

Thanks!

Signature · 1 line
Dmitry
#18 lore raw

Re: [PATCH 3/5] [ARM] pxa: lx: add keyboard driver

Quoted 9 lines · Dmitry Torokhov

Hi Russell,

drivers/input/keyboard/lx-kbd.c line 325

Quoted 3 lines · Russell King
drivers/input/keyboard/lx-kbd.c new file +3 -0
+static int __init lx_keyb_init(void)
+{
+	printk(KERN_INFO "LX Keyboard Driver, (c) 2004 Simtec Electronics\n");

Is this needed? Input core will already add printk when input device is added and our boot is already chatty enough...

Simtec themselves would need to remove that line.

maintainer
#19 lore raw

Re: [PATCH 3/5] [ARM] pxa: lx: add keyboard driver

Quoted 12 lines · On Monday 20 April 2009 01:25:13 Russell King - ARM Linux wrote:
Quoted 10 lines · Dmitry Torokhov

Hi Russell,

Quoted 4 lines · Russell King
drivers/input/keyboard/lx-kbd.c new file +3 -0
+static int __init lx_keyb_init(void)
+{
+	printk(KERN_INFO "LX Keyboard Driver, (c) 2004 Simtec

Electronics\n");

Is this needed? Input core will already add printk when input device is added and our boot is already chatty enough...

Quoted 1 line

Simtec themselves would need to remove that line.

Umm, why? We not removing copyright notice from the file, just the message...

Signature · 1 line
Dmitry
#20 lore raw

Re: [PATCH 3/5] [ARM] pxa: lx: add keyboard driver

Quoted 13 lines · Dmitry Torokhov
Quoted 12 lines · On Monday 20 April 2009 01:25:13 Russell King - ARM Linux wrote:
Quoted 10 lines · Dmitry Torokhov

Hi Russell,

Quoted 4 lines · Russell King
drivers/input/keyboard/lx-kbd.c new file +3 -0
+static int __init lx_keyb_init(void)
+{
+	printk(KERN_INFO "LX Keyboard Driver, (c) 2004 Simtec

Electronics\n");

Is this needed? Input core will already add printk when input device is added and our boot is already chatty enough...

Quoted 4 lines
Quoted 1 line

Simtec themselves would need to remove that line.

Umm, why? We not removing copyright notice from the file, just the message...

Because it's polite to at least ask them. I'm just the third party in this (although I've already done substantial cleaning up of this code.)

They've agreed to remove the line, so it's now gone.

#21 lore raw

Re: [PATCH 3/5] [ARM] pxa: lx: add keyboard driver

In reply to Dmitry Torokhov
Quoted 7 lines · Dmitry Torokhov

drivers/input/keyboard/Kconfig config KEYBOARD_AAED2000 · line 294

Quoted 3 lines
drivers/input/keyboard/Kconfig +3 -0
+config KEYBOARD_LX
+	tristate "LX Keyboard support"
+	depends on MACH_NETBOOKPRO && INPUT && INPUT_KEYBOARD

Dependancy on INPUT_KEYBOARD is not needed, strictly speaking. INPUT_KEYBOARD is only [menu]config syntactic sugar, there is no meat behind the option.

Gone.

Quoted 5 lines
Quoted 5 lines
drivers/input/keyboard/lx-kbd.c new file +5 -0
+
+	/*
+	 * Some keys have additional operations after we have
+	 * decoded them.  We don't report these "special" keys
+	 * to the input layer.
Quoted 8 lines

drivers/input/keyboard/lx-kbd.c line 207

Quoted 5 lines
drivers/input/keyboard/lx-kbd.c new file +5 -0
+	 */
+	switch (key) {
+	case KEY_BRIGHTNESSUP:
+	case KEY_BRIGHTNESSDOWN:
+		input_event(kbd, EV_PWR, key, !up);

Umm... some userspace apps might still want to get these. Strictly speaking KEY_* codes belong to EV_KEY namespace.

Maybe, if someone wants it I guess they can modify the driver.

Quoted 12 lines
Quoted 12 lines
drivers/input/keyboard/lx-kbd.c new file +12 -0
+static void lx_keyb_reset(struct input_dev *kbd)
+{
+	unsigned char *map;
+	int key;
+
+	for (key = 0; key < LX_NUMKEYCODES; key++)
+		if (keystate[key] & KP_DOWN) {
+			map = normal_map;
+			if (keystate[key] & KP_FN)
+				map = fn_map;
+			else if (keystate[key] & KP_NUMLCK)
+				map = numlck_map;
Quoted 8 lines

drivers/input/keyboard/lx-kbd.c line 238

Quoted 3 lines
drivers/input/keyboard/lx-kbd.c new file +3 -0
+			keystate[key] = KP_NONE;
+			input_report_key(kbd, map[key], 0);
+		}

Why don't you just send 'up' event for all known keys? Input core will filter out the ones that have not been 'down'ed... Better yet, don't do anything here, I should finish adding forced release at suspend/resume to the input core shortly.

I'll leave it as is until you've decided what to do with the input core.

Quoted 5 lines

drivers/input/keyboard/lx-kbd.c line 245

Quoted 3 lines
drivers/input/keyboard/lx-kbd.c new file +3 -0
+static void lx_keyb_write(void *data, unsigned int addr, unsigned char val)
+{
+	struct input_dev *kbd = data;

Blank line between variables and the code is always appreciated ;)

Added.

Quoted 5 lines
Quoted 5 lines
drivers/input/keyboard/lx-kbd.c new file +5 -0
+	kbd->name        = "LX Keyboard";
+	kbd->phys        = "pcon/input0";
+	kbd->dev.parent  = &dev->dev;
+	kbd->evbit[0]    = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
+			   BIT_MASK(EV_PWR);
Quoted 8 lines

drivers/input/keyboard/lx-kbd.c line 273

Quoted 4 lines
drivers/input/keyboard/lx-kbd.c new file +4 -0
+	kbd->keycode     = normal_map;
+	kbd->keycodesize = sizeof(unsigned char);
+	kbd->keycodemax  = ARRAY_SIZE(normal_map);
+

So we have 3 keymaps but only one can be changed form userspace... I suppose it is OK given how special the other 2 keymaps are. Or we could provide an alternative {get,set}keycode methods.

Yes, not sure what to do about those. It is a rather specialised keyboard in itself, so the standard maps wouldn't work with it.

The other issue here is that changing what's published may break the existing userspace (and since I didn't take a copy of the userspace build for this platform before the server was taken down, that could present something of a problem resulting in my use of the device being crippled.) Let's leave it as is and if someone does want to change it later...

Quoted 6 lines

drivers/input/keyboard/lx-kbd.c line 325

Quoted 3 lines
drivers/input/keyboard/lx-kbd.c new file +3 -0
+static int __init lx_keyb_init(void)
+{
+	printk(KERN_INFO "LX Keyboard Driver, (c) 2004 Simtec Electronics\n");

Is this needed? Input core will already add printk when input device is added and our boot is already chatty enough...

As mentioned in the other mail, now removed.

#22 lore raw

Re: [PATCH 3/5 UPDATED] [ARM] pxa: lx: add keyboard driver

This adds support for the keyboard support on the LX platform. We aren't directly connected to the keyboard itself, but the keyboard is managed by PCON via the system I2C bus.

---
 drivers/input/keyboard/Kconfig  |    9 +
 drivers/input/keyboard/Makefile |    1 +
 drivers/input/keyboard/lx-kbd.c |  347 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 357 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/keyboard/lx-kbd.c
drivers/input/keyboard/Kconfig +9 -0
index ea2638b..996ff38 100644
@@ -289,6 +289,15 @@ config KEYBOARD_AAED2000
 	  To compile this driver as a module, choose M here: the
 	  module will be called aaed2000_kbd.
 
+config KEYBOARD_LX
+	tristate "LX Keyboard support"
+	depends on MACH_NETBOOKPRO && INPUT
+	help
+	  Say Y here if you want to use the LX keyboard integrated in
+	  your system.
+
+	  If you have a LX platform, you should say Y.
+
 config KEYBOARD_GPIO
 	tristate "GPIO Buttons"
 	depends on GENERIC_GPIO
drivers/input/keyboard/Makefile +1 -0
index 36351e1..c475f79 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_KEYBOARD_OMAP)		+= omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)		+= pxa27x_keypad.o
 obj-$(CONFIG_KEYBOARD_PXA930_ROTARY)	+= pxa930_rotary.o
 obj-$(CONFIG_KEYBOARD_AAED2000)		+= aaed2000_kbd.o
+obj-$(CONFIG_KEYBOARD_LX)		+= lx-kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)		+= gpio_keys.o
 obj-$(CONFIG_KEYBOARD_HP6XX)		+= jornada680_kbd.o
 obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada720_kbd.o
drivers/input/keyboard/lx-kbd.c new file +347 -0

347 lines not on this page · raw message

Signature · 1 line
1.6.0.6
maintainer Acked-by
#23 lore raw

Re: [PATCH 3/5 UPDATED] [ARM] pxa: lx: add keyboard driver

Hi Russell,

Review

Quoted 2 lines · Russell King - ARM Linux
(quoted diff) +2 -0
+
+static unsigned char normal_map[LX_NUMKEYCODES] = {

Please chanege this to unsigned short since we _do_ allow changing this part of keymap from userspace and possible KEY_* values extend beyond unsigned char range.

drivers/input/keyboard/lx-kbd.c line 123

Quoted 2 lines
drivers/input/keyboard/lx-kbd.c new file +2 -0
+static unsigned char numlck_map[LX_NUMKEYCODES] = {
+static unsigned char fn_map[LX_NUMKEYCODES] = {

These 2 will have to be unisgned short as well, unless you want to adjust lx_keyb_process_key() to cope with different keymap sizes...

drivers/input/keyboard/lx-kbd.c line 278

Quoted 4 lines
drivers/input/keyboard/lx-kbd.c new file +4 -0
+	kbd->evbit[0]    = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
+			   BIT_MASK(EV_PWR);
+	kbd->keycode     = normal_map;
+	kbd->keycodesize = sizeof(unsigned char);

And this should be "sizeof(normal_map[0]);" then.

Otherwise you may add:

I assume the driver will be merged with the rest of LX changes through your tree, is that right?

Signature · 1 line
Dmitry
Acked-by Dmitry Torokhov
#24 lore raw

Re: [PATCH 3/5 UPDATED] [ARM] pxa: lx: add keyboard driver

Quoted 6 lines

Otherwise you may add:

I assume the driver will be merged with the rest of LX changes through your tree, is that right?

Yes.

Final version below, I'm assuming you have no further comments so added your acked by as above.

Subject: [PATCH] [ARM] pxa: lx: add keyboard driver

This adds support for the keyboard support on the LX platform. We aren't directly connected to the keyboard itself, but the keyboard is managed by PCON via the system I2C bus.

---
 drivers/input/keyboard/Kconfig  |    9 +
 drivers/input/keyboard/Makefile |    1 +
 drivers/input/keyboard/lx-kbd.c |  347 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 357 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/keyboard/lx-kbd.c
drivers/input/keyboard/Kconfig +9 -0
index ea2638b..996ff38 100644
@@ -289,6 +289,15 @@ config KEYBOARD_AAED2000
 	  To compile this driver as a module, choose M here: the
 	  module will be called aaed2000_kbd.
 
+config KEYBOARD_LX
+	tristate "LX Keyboard support"
+	depends on MACH_NETBOOKPRO && INPUT
+	help
+	  Say Y here if you want to use the LX keyboard integrated in
+	  your system.
+
+	  If you have a LX platform, you should say Y.
+
 config KEYBOARD_GPIO
 	tristate "GPIO Buttons"
 	depends on GENERIC_GPIO
drivers/input/keyboard/Makefile +1 -0
index 36351e1..c475f79 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_KEYBOARD_OMAP)		+= omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)		+= pxa27x_keypad.o
 obj-$(CONFIG_KEYBOARD_PXA930_ROTARY)	+= pxa930_rotary.o
 obj-$(CONFIG_KEYBOARD_AAED2000)		+= aaed2000_kbd.o
+obj-$(CONFIG_KEYBOARD_LX)		+= lx-kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)		+= gpio_keys.o
 obj-$(CONFIG_KEYBOARD_HP6XX)		+= jornada680_kbd.o
 obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada720_kbd.o
drivers/input/keyboard/lx-kbd.c new file +347 -0

347 lines not on this page · raw message

Signature · 1 line
1.6.0.6
maintainer
#25 lore raw

Re: [PATCH 3/5] [ARM] pxa: lx: add keyboard driver

In reply to Russell King - ARM Linux
Quoted 25 lines · Russell King - ARM Linux
Quoted 7 lines · Dmitry Torokhov

drivers/input/keyboard/Kconfig config KEYBOARD_AAED2000 · line 294

Quoted 3 lines
drivers/input/keyboard/Kconfig +3 -0
+config KEYBOARD_LX
+	tristate "LX Keyboard support"
+	depends on MACH_NETBOOKPRO && INPUT && INPUT_KEYBOARD

Dependancy on INPUT_KEYBOARD is not needed, strictly speaking. INPUT_KEYBOARD is only [menu]config syntactic sugar, there is no meat behind the option.

Gone.

Quoted 5 lines
Quoted 5 lines
drivers/input/keyboard/lx-kbd.c new file +5 -0
+
+	/*
+	 * Some keys have additional operations after we have
+	 * decoded them.  We don't report these "special" keys
+	 * to the input layer.
Quoted 8 lines

drivers/input/keyboard/lx-kbd.c line 207

Quoted 5 lines
drivers/input/keyboard/lx-kbd.c new file +5 -0
+	 */
+	switch (key) {
+	case KEY_BRIGHTNESSUP:
+	case KEY_BRIGHTNESSDOWN:
+		input_event(kbd, EV_PWR, key, !up);

Umm... some userspace apps might still want to get these. Strictly speaking KEY_* codes belong to EV_KEY namespace.

Quoted 2 lines

Maybe, if someone wants it I guess they can modify the driver.

OK.

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
drivers/input/keyboard/lx-kbd.c new file +12 -0
+static void lx_keyb_reset(struct input_dev *kbd)
+{
+	unsigned char *map;
+	int key;
+
+	for (key = 0; key < LX_NUMKEYCODES; key++)
+		if (keystate[key] & KP_DOWN) {
+			map = normal_map;
+			if (keystate[key] & KP_FN)
+				map = fn_map;
+			else if (keystate[key] & KP_NUMLCK)
+				map = numlck_map;
Quoted 8 lines

drivers/input/keyboard/lx-kbd.c line 238

Quoted 3 lines
drivers/input/keyboard/lx-kbd.c new file +3 -0
+			keystate[key] = KP_NONE;
+			input_report_key(kbd, map[key], 0);
+		}

Why don't you just send 'up' event for all known keys? Input core will filter out the ones that have not been 'down'ed... Better yet, don't do anything here, I should finish adding forced release at suspend/resume to the input core shortly.

Quoted 2 lines

I'll leave it as is until you've decided what to do with the input core.

Fair enough.

Quoted 25 lines
Quoted 5 lines

drivers/input/keyboard/lx-kbd.c line 245

Quoted 3 lines
drivers/input/keyboard/lx-kbd.c new file +3 -0
+static void lx_keyb_write(void *data, unsigned int addr, unsigned char val)
+{
+	struct input_dev *kbd = data;

Blank line between variables and the code is always appreciated ;)

Added.

Quoted 5 lines
Quoted 5 lines
drivers/input/keyboard/lx-kbd.c new file +5 -0
+	kbd->name        = "LX Keyboard";
+	kbd->phys        = "pcon/input0";
+	kbd->dev.parent  = &dev->dev;
+	kbd->evbit[0]    = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
+			   BIT_MASK(EV_PWR);
Quoted 8 lines

drivers/input/keyboard/lx-kbd.c line 273

Quoted 4 lines
drivers/input/keyboard/lx-kbd.c new file +4 -0
+	kbd->keycode     = normal_map;
+	kbd->keycodesize = sizeof(unsigned char);
+	kbd->keycodemax  = ARRAY_SIZE(normal_map);
+

So we have 3 keymaps but only one can be changed form userspace... I suppose it is OK given how special the other 2 keymaps are. Or we could provide an alternative {get,set}keycode methods.

Yes, not sure what to do about those. It is a rather specialised keyboard in itself, so the standard maps wouldn't work with it.

Quoted 7 lines

The other issue here is that changing what's published may break the existing userspace (and since I didn't take a copy of the userspace build for this platform before the server was taken down, that could present something of a problem resulting in my use of the device being crippled.) Let's leave it as is and if someone does want to change it later...

I did not mean we would change anything as far as default setup is concerned and is visible from userspace; it would be all internal adjustment that would also allow changing numlck_map and fn_map mapping in addition to changing normal_map. I will just put it on my TODO list...

Quoted 8 lines
Quoted 6 lines

drivers/input/keyboard/lx-kbd.c line 325

Quoted 3 lines
drivers/input/keyboard/lx-kbd.c new file +3 -0
+static int __init lx_keyb_init(void)
+{
+	printk(KERN_INFO "LX Keyboard Driver, (c) 2004 Simtec Electronics\n");

Is this needed? Input core will already add printk when input device is added and our boot is already chatty enough...

As mentioned in the other mail, now removed.

Thanks.

Signature · 1 line
Dmitry