initial keypad support
PATCH 1/2 initial keypad support
Hello,
Please consider this for inclusion
Here is an attempt to add PXA27x keypad support. It currently only supports the matrix type interface. It still needs direct and mulitswitch support added.
Just wanted to get something out there for folks to pound on.
Comment and feedback welcome.
-Armin
hw/pxa.h +74 -0
@@ -13,6 +13,7 @@# define PXA2XX_PIC_SSP3 0# define PXA2XX_PIC_USBH2 2# define PXA2XX_PIC_USBH1 3 +# define PXA2XX_PIC_KEYPAD 4# define PXA2XX_PIC_PWRI2C 6# define PXA25X_PIC_HWUART 7# define PXA27X_PIC_OST_4_11 7
@@ -61,6 +62,52 @@# define PXA2XX_INTERNAL_BASE 0x5c000000# define PXA2XX_INTERNAL_SIZE 0x40000 +/* Keypad defines */ +#define KPC_AS (0x1 << 30)/* Automatic Scan bit */ +#define KPC_ASACT (0x1 << 29)/* Automatic Scan on Activity */ +#define KPC_MI (0x1 << 22)/* Matrix interrupt bit */ +#define KPC_IMKP (0x1 << 21)/* Ignore Multiple Key Press */ +#define KPC_MS7 (0x1 << 20)/* Matrix scan line 7 */ +#define KPC_MS6 (0x1 << 19)/* Matrix scan line 6 */ +#define KPC_MS5 (0x1 << 18)/* Matrix scan line 5 */ +#define KPC_MS4 (0x1 << 17)/* Matrix scan line 4 */ +#define KPC_MS3 (0x1 << 16)/* Matrix scan line 3 */ +#define KPC_MS2 (0x1 << 15)/* Matrix scan line 2 */ +#define KPC_MS1 (0x1 << 14)/* Matrix scan line 1 */ +#define KPC_MS0 (0x1 << 13)/* Matrix scan line 0 */ +#define KPC_ME (0x1 << 12)/* Matrix Keypad Enable */ +#define KPC_MIE (0x1 << 11)/* Matrix Interrupt Enable */ +#define KPC_DK_DEB_SEL (0x1 << 9)/* Direct Keypad Debounce Select */ +#define KPC_DI (0x1 << 5)/* Direct key interrupt bit */ +#define KPC_RE_ZERO_DEB (0x1 << 4)/* Rotary Encoder Zero Debounce */ +#define KPC_REE1 (0x1 << 3)/* Rotary Encoder1 Enable */ +#define KPC_REE0 (0x1 << 2)/* Rotary Encoder0 Enable */ +#define KPC_DE (0x1 << 1)/* Direct Keypad Enable */ +#define KPC_DIE (0x1 << 0)/* Direct Keypad interrupt Enable */ + +#define KPDK_DKP (0x1 << 31) +#define KPDK_DK7 (0x1 << 7) +#define KPDK_DK6 (0x1 << 6) +#define KPDK_DK5 (0x1 << 5) +#define KPDK_DK4 (0x1 << 4) +#define KPDK_DK3 (0x1 << 3) +#define KPDK_DK2 (0x1 << 2) +#define KPDK_DK1 (0x1 << 1) +#define KPDK_DK0 (0x1 << 0) + +#define KPREC_OF1 (0x1 << 31) +#define kPREC_UF1 (0x1 << 30) +#define KPREC_OF0 (0x1 << 15) +#define KPREC_UF0 (0x1 << 14) + +#define KPMK_MKP (0x1 << 31) +#define KPAS_SO (0x1 << 31) +#define KPASMKPx_SO (0x1 << 31) + + +#define KPASMKPx_MKC (row, col) (1 << (row + 16 * (col % 2))) + +/* pxa2xx_pic.c */ qemu_irq *pxa2xx_pic_init (target_phys_addr_t base,CPUState *env);
@@ -120,6 +167,13 @@ i2c_bus *pxa2xx_i2c_bus(struct pxa2xx_i2struct pxa2xx_i2s_s ;struct pxa2xx_fir_s ; +/* pxa2xx_kpad.c */ +struct pxa2xx_keypad_s ; +struct pxa2xx_keypad_s *pxa27x_keypad_init (target_phys_addr_t base, +qemu_irq irq); +void pxa27_register_keyboard (struct pxa2xx_keypad_s *kp,int **keymap,int +size); +struct pxa2xx_state_s {CPUState *env;qemu_irq *pic;
@@ -133,6 +187,7 @@ struct pxa2xx_state_s {struct pxa2xx_pcmcia_s *pcmcia[2 ];struct pxa2xx_i2s_s *i2s;struct pxa2xx_fir_s *fir; +struct pxa2xx_keypad_s *kp;/* Power management */ target_phys_addr_t pm_base;
@@ -200,6 +255,25 @@ struct pxa2xx_i2s_s {uint32_t fifo[16 ]; }; +#define PXAKBD_MAXROW 8 +#define PXAKBD_MAXCOL 8 + +struct pxa2xx_keypad_s { +target_phys_addr_t base; +qemu_irq irq; +int keymap[PXAKBD_MAXCOL ][PXAKBD_MAXROW ]; +uint32_t kpc; +uint32_t kpdk; +uint32_t kprec; +uint32_t kpmk; +uint32_t kpas; +uint32_t kpasmkp0; +uint32_t kpasmkp1; +uint32_t kpasmkp2; +uint32_t kpasmkp3; +uint32_t kpkdi; +}; +# define PA_FMT "0x%08lx"# define REG_FMT "0x" TARGET_FMT_plx
hw/pxa2xx.c +1 -0
@@ -2156,6 +2156,7 @@ struct pxa2xx_state_s *pxa270_init(unsig/* GPIO1 resets the processor */ /* The handler can be overridden by board-specific code */ pxa2xx_gpio_out_set (s->gpio,1 , s->reset); + s->kp =pxa27x_keypad_init (0x41500000 , s->pic[PXA2XX_PIC_KEYPAD ]);return s; }
hw/pxa2xx_keypad.c new file +257 -0
257 lines not on this page · raw message
Makefile.target +1 -1
@@ -494,7 +494,7 @@ VL_OBJS+= armv7m.o armv7m_nvic.o stellar VL_OBJS+= pl061.o VL_OBJS+= arm-semi.o VL_OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o -VL_OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o +VL_OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o VL_OBJS+= pflash_cfi01.o gumstix.o VL_OBJS+= spitz.o ide.o serial.o nand.o ecc.o VL_OBJS+= omap.o omap_lcdc.o omap1_clk.o omap_mmc.o omap_i2c.o
Hi,
Quoted 7 lines · Armin
Here is an attempt to add PXA27x keypad support. It currently only supports the matrix type interface. It still needs direct and mulitswitch support added.
Just wanted to get something out there for folks to pound on.
Comment and feedback welcome.
Here are some comments:
* Several bits in KPC and KPREC should be reset on read. The IRQ should be reset when it becomes masked in KPC, and potentially asserted when it becomes unmasked.
* It's wasteful to go through all keys in the 8x8 matrix on every event. It can be avoided easily by mapping qemu keycode to matrix position, rather than position to keycode, for example the PalmT|E matrix keypad does that.
* Please convert the indentation in the file to use spaces, before considering for inclusion.
* The bit definitions and pxa2xx_keypad_s struct are local to the keypad module so they shouldn't be in the header file exposed to the whole world.
* Please set a copyright owner.
Regarding mainstone keypad patch:
* Probably not worth to stick the keymap in a file of its own since it is not shared between different machines - it's an integral part of mainstone.
Thanks,
Andrew
Quoted 10 lines · andrzej zaborowski
Hi,
Quoted 6 lines · Armin
Here is an attempt to add PXA27x keypad support. It currently only supports the matrix type interface. It still needs direct and mulitswitch support added.
Just wanted to get something out there for folks to pound on.
Quoted 9 lines
Quoted 2 lines
Comment and feedback welcome.
Here are some comments:
* Several bits in KPC and KPREC should be reset on read. The IRQ should be reset when it becomes masked in KPC, and potentially asserted when it becomes unmasked.
Done, I think I got the reset on read .
The MI and DI interrupt bits are set after a scan has completed and then the IRQ is asserted. I think I got it.
Quoted 5 lines
* It's wasteful to go through all keys in the 8x8 matrix on every event. It can be avoided easily by mapping qemu keycode to matrix position, rather than position to keycode, for example the PalmT|E matrix keypad does that.
Yeah, that was a bit overkill ; )
Quoted 4 lines
* Please convert the indentation in the file to use spaces, before considering for inclusion.
sure thing
Quoted 4 lines
* The bit definitions and
pxa2xx_keypad_sstruct are local to the keypad module so they shouldn't be in the header file exposed to the whole world.
Ok.
Quoted 2 lines
* Please set a copyright owner.
Ok.
Quoted 6 lines
Regarding mainstone keypad patch:
* Probably not worth to stick the keymap in a file of its own since it is not shared between different machines - it's an integral part of mainstone.
Done
Thanks for the feedback.
New patches to follow.
-Armin