2 * Finger Sensing Pad PS/2 mouse driver.
4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd.
5 * Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/module.h>
23 #include <linux/input.h>
24 #include <linux/ctype.h>
25 #include <linux/libps2.h>
26 #include <linux/serio.h>
27 #include <linux/jiffies.h>
28 #include <linux/slab.h>
34 * Timeout for FSP PS/2 command only (in milliseconds).
36 #define FSP_CMD_TIMEOUT 200
37 #define FSP_CMD_TIMEOUT2 30
39 /** Driver version. */
40 static const char fsp_drv_ver[] = "1.0.0-K";
43 * Make sure that the value being sent to FSP will not conflict with
44 * possible sample rate values.
46 static unsigned char fsp_test_swap_cmd(unsigned char reg_val)
49 case 10: case 20: case 40: case 60: case 80: case 100: case 200:
51 * The requested value being sent to FSP matched to possible
52 * sample rates, swap the given value such that the hardware
53 * wouldn't get confused.
55 return (reg_val >> 4) | (reg_val << 4);
57 return reg_val; /* swap isn't necessary */
62 * Make sure that the value being sent to FSP will not conflict with certain
65 static unsigned char fsp_test_invert_cmd(unsigned char reg_val)
68 case 0xe9: case 0xee: case 0xf2: case 0xff:
70 * The requested value being sent to FSP matched to certain
71 * commands, inverse the given value such that the hardware
72 * wouldn't get confused.
76 return reg_val; /* inversion isn't necessary */
80 static int fsp_reg_read(struct psmouse *psmouse, int reg_addr, int *reg_val)
82 struct ps2dev *ps2dev = &psmouse->ps2dev;
83 unsigned char param[3];
88 * We need to shut off the device and switch it into command
89 * mode so we don't confuse our protocol handler. We don't need
90 * to do that for writes because sysfs set helper does this for
93 psmouse_deactivate(psmouse);
95 ps2_begin_command(ps2dev);
97 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
100 /* should return 0xfe(request for resending) */
101 ps2_sendbyte(ps2dev, 0x66, FSP_CMD_TIMEOUT2);
102 /* should return 0xfc(failed) */
103 ps2_sendbyte(ps2dev, 0x88, FSP_CMD_TIMEOUT2);
105 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
108 if ((addr = fsp_test_invert_cmd(reg_addr)) != reg_addr) {
109 ps2_sendbyte(ps2dev, 0x68, FSP_CMD_TIMEOUT2);
110 } else if ((addr = fsp_test_swap_cmd(reg_addr)) != reg_addr) {
111 /* swapping is required */
112 ps2_sendbyte(ps2dev, 0xcc, FSP_CMD_TIMEOUT2);
115 /* swapping isn't necessary */
116 ps2_sendbyte(ps2dev, 0x66, FSP_CMD_TIMEOUT2);
119 /* should return 0xfc(failed) */
120 ps2_sendbyte(ps2dev, addr, FSP_CMD_TIMEOUT);
122 if (__ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO) < 0)
129 ps2_end_command(ps2dev);
130 psmouse_activate(psmouse);
131 dev_dbg(&ps2dev->serio->dev, "READ REG: 0x%02x is 0x%02x (rc = %d)\n",
132 reg_addr, *reg_val, rc);
136 static int fsp_reg_write(struct psmouse *psmouse, int reg_addr, int reg_val)
138 struct ps2dev *ps2dev = &psmouse->ps2dev;
142 ps2_begin_command(ps2dev);
144 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
147 if ((v = fsp_test_invert_cmd(reg_addr)) != reg_addr) {
148 /* inversion is required */
149 ps2_sendbyte(ps2dev, 0x74, FSP_CMD_TIMEOUT2);
151 if ((v = fsp_test_swap_cmd(reg_addr)) != reg_addr) {
152 /* swapping is required */
153 ps2_sendbyte(ps2dev, 0x77, FSP_CMD_TIMEOUT2);
155 /* swapping isn't necessary */
156 ps2_sendbyte(ps2dev, 0x55, FSP_CMD_TIMEOUT2);
159 /* write the register address in correct order */
160 ps2_sendbyte(ps2dev, v, FSP_CMD_TIMEOUT2);
162 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
165 if ((v = fsp_test_invert_cmd(reg_val)) != reg_val) {
166 /* inversion is required */
167 ps2_sendbyte(ps2dev, 0x47, FSP_CMD_TIMEOUT2);
168 } else if ((v = fsp_test_swap_cmd(reg_val)) != reg_val) {
169 /* swapping is required */
170 ps2_sendbyte(ps2dev, 0x44, FSP_CMD_TIMEOUT2);
172 /* swapping isn't necessary */
173 ps2_sendbyte(ps2dev, 0x33, FSP_CMD_TIMEOUT2);
176 /* write the register value in correct order */
177 ps2_sendbyte(ps2dev, v, FSP_CMD_TIMEOUT2);
181 ps2_end_command(ps2dev);
182 dev_dbg(&ps2dev->serio->dev, "WRITE REG: 0x%02x to 0x%02x (rc = %d)\n",
183 reg_addr, reg_val, rc);
187 /* Enable register clock gating for writing certain registers */
188 static int fsp_reg_write_enable(struct psmouse *psmouse, bool enable)
192 if (fsp_reg_read(psmouse, FSP_REG_SYSCTL1, &v) == -1)
196 nv = v | FSP_BIT_EN_REG_CLK;
198 nv = v & ~FSP_BIT_EN_REG_CLK;
200 /* only write if necessary */
202 if (fsp_reg_write(psmouse, FSP_REG_SYSCTL1, nv) == -1)
208 static int fsp_page_reg_read(struct psmouse *psmouse, int *reg_val)
210 struct ps2dev *ps2dev = &psmouse->ps2dev;
211 unsigned char param[3];
214 psmouse_deactivate(psmouse);
216 ps2_begin_command(ps2dev);
218 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
221 ps2_sendbyte(ps2dev, 0x66, FSP_CMD_TIMEOUT2);
222 ps2_sendbyte(ps2dev, 0x88, FSP_CMD_TIMEOUT2);
224 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
227 ps2_sendbyte(ps2dev, 0x83, FSP_CMD_TIMEOUT2);
228 ps2_sendbyte(ps2dev, 0x88, FSP_CMD_TIMEOUT2);
230 /* get the returned result */
231 if (__ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
238 ps2_end_command(ps2dev);
239 psmouse_activate(psmouse);
240 dev_dbg(&ps2dev->serio->dev, "READ PAGE REG: 0x%02x (rc = %d)\n",
245 static int fsp_page_reg_write(struct psmouse *psmouse, int reg_val)
247 struct ps2dev *ps2dev = &psmouse->ps2dev;
251 ps2_begin_command(ps2dev);
253 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
256 ps2_sendbyte(ps2dev, 0x38, FSP_CMD_TIMEOUT2);
257 ps2_sendbyte(ps2dev, 0x88, FSP_CMD_TIMEOUT2);
259 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
262 if ((v = fsp_test_invert_cmd(reg_val)) != reg_val) {
263 ps2_sendbyte(ps2dev, 0x47, FSP_CMD_TIMEOUT2);
264 } else if ((v = fsp_test_swap_cmd(reg_val)) != reg_val) {
265 /* swapping is required */
266 ps2_sendbyte(ps2dev, 0x44, FSP_CMD_TIMEOUT2);
268 /* swapping isn't necessary */
269 ps2_sendbyte(ps2dev, 0x33, FSP_CMD_TIMEOUT2);
272 ps2_sendbyte(ps2dev, v, FSP_CMD_TIMEOUT2);
276 ps2_end_command(ps2dev);
277 dev_dbg(&ps2dev->serio->dev, "WRITE PAGE REG: to 0x%02x (rc = %d)\n",
282 static int fsp_get_version(struct psmouse *psmouse, int *version)
284 if (fsp_reg_read(psmouse, FSP_REG_VERSION, version))
290 static int fsp_get_revision(struct psmouse *psmouse, int *rev)
292 if (fsp_reg_read(psmouse, FSP_REG_REVISION, rev))
298 static int fsp_get_buttons(struct psmouse *psmouse, int *btn)
300 static const int buttons[] = {
301 0x16, /* Left/Middle/Right/Forward/Backward & Scroll Up/Down */
302 0x06, /* Left/Middle/Right & Scroll Up/Down/Right/Left */
303 0x04, /* Left/Middle/Right & Scroll Up/Down */
304 0x02, /* Left/Middle/Right */
308 if (fsp_reg_read(psmouse, FSP_REG_TMOD_STATUS, &val) == -1)
311 *btn = buttons[(val & 0x30) >> 4];
315 /* Enable on-pad command tag output */
316 static int fsp_opc_tag_enable(struct psmouse *psmouse, bool enable)
321 if (fsp_reg_read(psmouse, FSP_REG_OPC_QDOWN, &v) == -1) {
322 dev_err(&psmouse->ps2dev.serio->dev, "Unable get OPC state.\n");
327 nv = v | FSP_BIT_EN_OPC_TAG;
329 nv = v & ~FSP_BIT_EN_OPC_TAG;
331 /* only write if necessary */
333 fsp_reg_write_enable(psmouse, true);
334 res = fsp_reg_write(psmouse, FSP_REG_OPC_QDOWN, nv);
335 fsp_reg_write_enable(psmouse, false);
339 dev_err(&psmouse->ps2dev.serio->dev,
340 "Unable to enable OPC tag.\n");
347 static int fsp_onpad_vscr(struct psmouse *psmouse, bool enable)
349 struct fsp_data *pad = psmouse->private;
352 if (fsp_reg_read(psmouse, FSP_REG_ONPAD_CTL, &val))
355 pad->vscroll = enable;
358 val |= (FSP_BIT_FIX_VSCR | FSP_BIT_ONPAD_ENABLE);
360 val &= ~FSP_BIT_FIX_VSCR;
362 if (fsp_reg_write(psmouse, FSP_REG_ONPAD_CTL, val))
368 static int fsp_onpad_hscr(struct psmouse *psmouse, bool enable)
370 struct fsp_data *pad = psmouse->private;
373 if (fsp_reg_read(psmouse, FSP_REG_ONPAD_CTL, &val))
376 if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &v2))
379 pad->hscroll = enable;
382 val |= (FSP_BIT_FIX_HSCR | FSP_BIT_ONPAD_ENABLE);
383 v2 |= FSP_BIT_EN_MSID6;
385 val &= ~FSP_BIT_FIX_HSCR;
386 v2 &= ~(FSP_BIT_EN_MSID6 | FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8);
389 if (fsp_reg_write(psmouse, FSP_REG_ONPAD_CTL, val))
392 /* reconfigure horizontal scrolling packet output */
393 if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, v2))
400 * Write device specific initial parameters.
402 * ex: 0xab 0xcd - write oxcd into register 0xab
404 static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data,
405 const char *buf, size_t count)
411 reg = simple_strtoul(buf, &rest, 16);
412 if (rest == buf || *rest != ' ' || reg > 0xff)
415 retval = kstrtoint(rest + 1, 16, &val);
422 if (fsp_reg_write_enable(psmouse, true))
425 retval = fsp_reg_write(psmouse, reg, val) < 0 ? -EIO : count;
427 fsp_reg_write_enable(psmouse, false);
432 PSMOUSE_DEFINE_WO_ATTR(setreg, S_IWUSR, NULL, fsp_attr_set_setreg);
434 static ssize_t fsp_attr_show_getreg(struct psmouse *psmouse,
435 void *data, char *buf)
437 struct fsp_data *pad = psmouse->private;
439 return sprintf(buf, "%02x%02x\n", pad->last_reg, pad->last_val);
443 * Read a register from device.
445 * ex: 0xab -- read content from register 0xab
447 static ssize_t fsp_attr_set_getreg(struct psmouse *psmouse, void *data,
448 const char *buf, size_t count)
450 struct fsp_data *pad = psmouse->private;
453 err = kstrtoint(buf, 16, ®);
460 if (fsp_reg_read(psmouse, reg, &val))
469 PSMOUSE_DEFINE_ATTR(getreg, S_IWUSR | S_IRUGO, NULL,
470 fsp_attr_show_getreg, fsp_attr_set_getreg);
472 static ssize_t fsp_attr_show_pagereg(struct psmouse *psmouse,
473 void *data, char *buf)
477 if (fsp_page_reg_read(psmouse, &val))
480 return sprintf(buf, "%02x\n", val);
483 static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data,
484 const char *buf, size_t count)
488 err = kstrtoint(buf, 16, &val);
495 if (fsp_page_reg_write(psmouse, val))
501 PSMOUSE_DEFINE_ATTR(page, S_IWUSR | S_IRUGO, NULL,
502 fsp_attr_show_pagereg, fsp_attr_set_pagereg);
504 static ssize_t fsp_attr_show_vscroll(struct psmouse *psmouse,
505 void *data, char *buf)
507 struct fsp_data *pad = psmouse->private;
509 return sprintf(buf, "%d\n", pad->vscroll);
512 static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data,
513 const char *buf, size_t count)
518 err = kstrtouint(buf, 10, &val);
525 fsp_onpad_vscr(psmouse, val);
530 PSMOUSE_DEFINE_ATTR(vscroll, S_IWUSR | S_IRUGO, NULL,
531 fsp_attr_show_vscroll, fsp_attr_set_vscroll);
533 static ssize_t fsp_attr_show_hscroll(struct psmouse *psmouse,
534 void *data, char *buf)
536 struct fsp_data *pad = psmouse->private;
538 return sprintf(buf, "%d\n", pad->hscroll);
541 static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data,
542 const char *buf, size_t count)
547 err = kstrtouint(buf, 10, &val);
554 fsp_onpad_hscr(psmouse, val);
559 PSMOUSE_DEFINE_ATTR(hscroll, S_IWUSR | S_IRUGO, NULL,
560 fsp_attr_show_hscroll, fsp_attr_set_hscroll);
562 static ssize_t fsp_attr_show_flags(struct psmouse *psmouse,
563 void *data, char *buf)
565 struct fsp_data *pad = psmouse->private;
567 return sprintf(buf, "%c\n",
568 pad->flags & FSPDRV_FLAG_EN_OPC ? 'C' : 'c');
571 static ssize_t fsp_attr_set_flags(struct psmouse *psmouse, void *data,
572 const char *buf, size_t count)
574 struct fsp_data *pad = psmouse->private;
577 for (i = 0; i < count; i++) {
580 pad->flags |= FSPDRV_FLAG_EN_OPC;
583 pad->flags &= ~FSPDRV_FLAG_EN_OPC;
592 PSMOUSE_DEFINE_ATTR(flags, S_IWUSR | S_IRUGO, NULL,
593 fsp_attr_show_flags, fsp_attr_set_flags);
595 static ssize_t fsp_attr_show_ver(struct psmouse *psmouse,
596 void *data, char *buf)
598 return sprintf(buf, "Sentelic FSP kernel module %s\n", fsp_drv_ver);
601 PSMOUSE_DEFINE_RO_ATTR(ver, S_IRUGO, NULL, fsp_attr_show_ver);
603 static struct attribute *fsp_attributes[] = {
604 &psmouse_attr_setreg.dattr.attr,
605 &psmouse_attr_getreg.dattr.attr,
606 &psmouse_attr_page.dattr.attr,
607 &psmouse_attr_vscroll.dattr.attr,
608 &psmouse_attr_hscroll.dattr.attr,
609 &psmouse_attr_flags.dattr.attr,
610 &psmouse_attr_ver.dattr.attr,
614 static struct attribute_group fsp_attribute_group = {
615 .attrs = fsp_attributes,
619 static void fsp_packet_debug(unsigned char packet[])
621 static unsigned int ps2_packet_cnt;
622 static unsigned int ps2_last_second;
623 unsigned int jiffies_msec;
626 jiffies_msec = jiffies_to_msecs(jiffies);
628 "%08dms PS/2 packets: %02x, %02x, %02x, %02x\n",
629 jiffies_msec, packet[0], packet[1], packet[2], packet[3]);
631 if (jiffies_msec - ps2_last_second > 1000) {
632 psmouse_dbg(psmouse, "PS/2 packets/sec = %d\n", ps2_packet_cnt);
634 ps2_last_second = jiffies_msec;
638 static void fsp_packet_debug(unsigned char packet[])
643 static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
645 struct input_dev *dev = psmouse->dev;
646 struct fsp_data *ad = psmouse->private;
647 unsigned char *packet = psmouse->packet;
648 unsigned char button_status = 0, lscroll = 0, rscroll = 0;
651 if (psmouse->pktcnt < 4)
652 return PSMOUSE_GOOD_DATA;
655 * Full packet accumulated, process it
658 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) {
659 case FSP_PKT_TYPE_ABS:
660 dev_warn(&psmouse->ps2dev.serio->dev,
661 "Unexpected absolute mode packet, ignored.\n");
664 case FSP_PKT_TYPE_NORMAL_OPC:
665 /* on-pad click, filter it if necessary */
666 if ((ad->flags & FSPDRV_FLAG_EN_OPC) != FSPDRV_FLAG_EN_OPC)
667 packet[0] &= ~BIT(0);
670 case FSP_PKT_TYPE_NORMAL:
672 /* special packet data translation from on-pad packets */
673 if (packet[3] != 0) {
674 if (packet[3] & BIT(0))
675 button_status |= 0x01; /* wheel down */
676 if (packet[3] & BIT(1))
677 button_status |= 0x0f; /* wheel up */
678 if (packet[3] & BIT(2))
679 button_status |= BIT(4);/* horizontal left */
680 if (packet[3] & BIT(3))
681 button_status |= BIT(5);/* horizontal right */
682 /* push back to packet queue */
683 if (button_status != 0)
684 packet[3] = button_status;
685 rscroll = (packet[3] >> 4) & 1;
686 lscroll = (packet[3] >> 5) & 1;
689 * Processing wheel up/down and extra button events
691 input_report_rel(dev, REL_WHEEL,
692 (int)(packet[3] & 8) - (int)(packet[3] & 7));
693 input_report_rel(dev, REL_HWHEEL, lscroll - rscroll);
694 input_report_key(dev, BTN_BACK, lscroll);
695 input_report_key(dev, BTN_FORWARD, rscroll);
698 * Standard PS/2 Mouse
700 input_report_key(dev, BTN_LEFT, packet[0] & 1);
701 input_report_key(dev, BTN_MIDDLE, (packet[0] >> 2) & 1);
702 input_report_key(dev, BTN_RIGHT, (packet[0] >> 1) & 1);
704 rel_x = packet[1] ? (int)packet[1] - (int)((packet[0] << 4) & 0x100) : 0;
705 rel_y = packet[2] ? (int)((packet[0] << 3) & 0x100) - (int)packet[2] : 0;
707 input_report_rel(dev, REL_X, rel_x);
708 input_report_rel(dev, REL_Y, rel_y);
714 fsp_packet_debug(packet);
716 return PSMOUSE_FULL_PACKET;
719 static int fsp_activate_protocol(struct psmouse *psmouse)
721 struct fsp_data *pad = psmouse->private;
722 struct ps2dev *ps2dev = &psmouse->ps2dev;
723 unsigned char param[2];
727 * Standard procedure to enter FSP Intellimouse mode
728 * (scrolling wheel, 4th and 5th buttons)
731 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
733 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
735 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
737 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
738 if (param[0] != 0x04) {
739 dev_err(&psmouse->ps2dev.serio->dev,
740 "Unable to enable 4 bytes packet format.\n");
744 if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &val)) {
745 dev_err(&psmouse->ps2dev.serio->dev,
746 "Unable to read SYSCTL5 register.\n");
750 val &= ~(FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8 | FSP_BIT_EN_AUTO_MSID8);
751 /* Ensure we are not in absolute mode */
752 val &= ~FSP_BIT_EN_PKT_G0;
753 if (pad->buttons == 0x06) {
754 /* Left/Middle/Right & Scroll Up/Down/Right/Left */
755 val |= FSP_BIT_EN_MSID6;
758 if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, val)) {
759 dev_err(&psmouse->ps2dev.serio->dev,
760 "Unable to set up required mode bits.\n");
765 * Enable OPC tags such that driver can tell the difference between
766 * on-pad and real button click
768 if (fsp_opc_tag_enable(psmouse, true))
769 dev_warn(&psmouse->ps2dev.serio->dev,
770 "Failed to enable OPC tag mode.\n");
772 /* Enable on-pad vertical and horizontal scrolling */
773 fsp_onpad_vscr(psmouse, true);
774 fsp_onpad_hscr(psmouse, true);
779 int fsp_detect(struct psmouse *psmouse, bool set_properties)
783 if (fsp_reg_read(psmouse, FSP_REG_DEVICE_ID, &id))
789 if (set_properties) {
790 psmouse->vendor = "Sentelic";
791 psmouse->name = "FingerSensingPad";
797 static void fsp_reset(struct psmouse *psmouse)
799 fsp_opc_tag_enable(psmouse, false);
800 fsp_onpad_vscr(psmouse, false);
801 fsp_onpad_hscr(psmouse, false);
804 static void fsp_disconnect(struct psmouse *psmouse)
806 sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj,
807 &fsp_attribute_group);
810 kfree(psmouse->private);
813 static int fsp_reconnect(struct psmouse *psmouse)
817 if (fsp_detect(psmouse, 0))
820 if (fsp_get_version(psmouse, &version))
823 if (fsp_activate_protocol(psmouse))
829 int fsp_init(struct psmouse *psmouse)
831 struct fsp_data *priv;
832 int ver, rev, buttons;
835 if (fsp_get_version(psmouse, &ver) ||
836 fsp_get_revision(psmouse, &rev) ||
837 fsp_get_buttons(psmouse, &buttons)) {
841 psmouse_info(psmouse,
842 "Finger Sensing Pad, hw: %d.%d.%d, sw: %s, buttons: %d\n",
843 ver >> 4, ver & 0x0F, rev, fsp_drv_ver, buttons & 7);
845 psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL);
851 priv->buttons = buttons;
853 /* enable on-pad click by default */
854 priv->flags |= FSPDRV_FLAG_EN_OPC;
856 /* Set up various supported input event bits */
857 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
858 __set_bit(BTN_BACK, psmouse->dev->keybit);
859 __set_bit(BTN_FORWARD, psmouse->dev->keybit);
860 __set_bit(REL_WHEEL, psmouse->dev->relbit);
861 __set_bit(REL_HWHEEL, psmouse->dev->relbit);
863 psmouse->protocol_handler = fsp_process_byte;
864 psmouse->disconnect = fsp_disconnect;
865 psmouse->reconnect = fsp_reconnect;
866 psmouse->cleanup = fsp_reset;
867 psmouse->pktsize = 4;
869 /* set default packet output based on number of buttons we found */
870 error = fsp_activate_protocol(psmouse);
874 error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj,
875 &fsp_attribute_group);
877 dev_err(&psmouse->ps2dev.serio->dev,
878 "Failed to create sysfs attributes (%d)", error);
885 kfree(psmouse->private);
886 psmouse->private = NULL;