From mboxrd@z Thu Jan 1 00:00:00 1970 From: dmitry.torokhov@gmail.com (Dmitry Torokhov) Date: Tue, 5 Oct 2010 08:47:37 -0700 Subject: [PATCH V2 21/69] Keyboard: Adding support for spear-keyboard In-Reply-To: <584e4ecc7883807e1fae0e6c53b2837954935e53.1285933331.git.viresh.kumar@st.com> References: <584e4ecc7883807e1fae0e6c53b2837954935e53.1285933331.git.viresh.kumar@st.com> Message-ID: <20101005154737.GA19730@core.coreip.homeip.net> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Rajeev, On Fri, Oct 01, 2010 at 05:25:41PM +0530, Viresh KUMAR wrote: > + > +#define KEY_MASK 0xFF000000 > +#define KEY_VALUE 0x00FFFFFF > +#define ROW_MASK 0xF0 > +#define COLUMN_MASK 0x0F > +#define ROW_SHIFT 4 > + > +struct spear_kbd { > + struct input_dev *input; > + void __iomem *io_base; /* Keyboard Base Address */ > + struct clk *clk; > + u8 last_key ; > + u8 last_event; > + int *keymap; > + int keymapsize; > +}; > +/* TODO: Need to optimize this function */ > +static inline int get_key_value(struct spear_kbd *dev, int row, int col) > +{ > + int i, key; > + > + key = KEY(row, col, 0); > + for (i = 0; i < dev->keymapsize; i++) > + if ((dev->keymap[i] & KEY_MASK) == key) > + return dev->keymap[i] & KEY_VALUE; > + return -ENOKEY; > +} As discussed previously I'd like to see the driver using as much of matrix_keypad infrastructure as practical and also to see the initial keypad copied into the spear_kbd structure to ensure that the board code could be made const and bind/rebind of the device would restore the original keymap. Thanks. -- Dmitry