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)
407 unsigned long reg, val;
411 reg = simple_strtoul(buf, &rest, 16);
412 if (rest == buf || *rest != ' ' || reg > 0xff)
415 if (strict_strtoul(rest + 1, 16, &val) || val > 0xff)
418 if (fsp_reg_write_enable(psmouse, true))
421 retval = fsp_reg_write(psmouse, reg, val) < 0 ? -EIO : count;
423 fsp_reg_write_enable(psmouse, false);
428 PSMOUSE_DEFINE_WO_ATTR(setreg, S_IWUSR, NULL, fsp_attr_set_setreg);
430 static ssize_t fsp_attr_show_getreg(struct psmouse *psmouse,
431 void *data, char *buf)
433 struct fsp_data *pad = psmouse->private;
435 return sprintf(buf, "%02x%02x\n", pad->last_reg, pad->last_val);
439 * Read a register from device.
441 * ex: 0xab -- read content from register 0xab
443 static ssize_t fsp_attr_set_getreg(struct psmouse *psmouse, void *data,
444 const char *buf, size_t count)
446 struct fsp_data *pad = psmouse->private;
450 if (strict_strtoul(buf, 16, ®) || reg > 0xff)
453 if (fsp_reg_read(psmouse, reg, &val))
462 PSMOUSE_DEFINE_ATTR(getreg, S_IWUSR | S_IRUGO, NULL,
463 fsp_attr_show_getreg, fsp_attr_set_getreg);
465 static ssize_t fsp_attr_show_pagereg(struct psmouse *psmouse,
466 void *data, char *buf)
470 if (fsp_page_reg_read(psmouse, &val))
473 return sprintf(buf, "%02x\n", val);
476 static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data,
477 const char *buf, size_t count)
481 if (strict_strtoul(buf, 16, &val) || val > 0xff)
484 if (fsp_page_reg_write(psmouse, val))
490 PSMOUSE_DEFINE_ATTR(page, S_IWUSR | S_IRUGO, NULL,
491 fsp_attr_show_pagereg, fsp_attr_set_pagereg);
493 static ssize_t fsp_attr_show_vscroll(struct psmouse *psmouse,
494 void *data, char *buf)
496 struct fsp_data *pad = psmouse->private;
498 return sprintf(buf, "%d\n", pad->vscroll);
501 static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data,
502 const char *buf, size_t count)
506 if (strict_strtoul(buf, 10, &val) || val > 1)
509 fsp_onpad_vscr(psmouse, val);
514 PSMOUSE_DEFINE_ATTR(vscroll, S_IWUSR | S_IRUGO, NULL,
515 fsp_attr_show_vscroll, fsp_attr_set_vscroll);
517 static ssize_t fsp_attr_show_hscroll(struct psmouse *psmouse,
518 void *data, char *buf)
520 struct fsp_data *pad = psmouse->private;
522 return sprintf(buf, "%d\n", pad->hscroll);
525 static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data,
526 const char *buf, size_t count)
530 if (strict_strtoul(buf, 10, &val) || val > 1)
533 fsp_onpad_hscr(psmouse, val);
538 PSMOUSE_DEFINE_ATTR(hscroll, S_IWUSR | S_IRUGO, NULL,
539 fsp_attr_show_hscroll, fsp_attr_set_hscroll);
541 static ssize_t fsp_attr_show_flags(struct psmouse *psmouse,
542 void *data, char *buf)
544 struct fsp_data *pad = psmouse->private;
546 return sprintf(buf, "%c\n",
547 pad->flags & FSPDRV_FLAG_EN_OPC ? 'C' : 'c');
550 static ssize_t fsp_attr_set_flags(struct psmouse *psmouse, void *data,
551 const char *buf, size_t count)
553 struct fsp_data *pad = psmouse->private;
556 for (i = 0; i < count; i++) {
559 pad->flags |= FSPDRV_FLAG_EN_OPC;
562 pad->flags &= ~FSPDRV_FLAG_EN_OPC;
571 PSMOUSE_DEFINE_ATTR(flags, S_IWUSR | S_IRUGO, NULL,
572 fsp_attr_show_flags, fsp_attr_set_flags);
574 static ssize_t fsp_attr_show_ver(struct psmouse *psmouse,
575 void *data, char *buf)
577 return sprintf(buf, "Sentelic FSP kernel module %s\n", fsp_drv_ver);
580 PSMOUSE_DEFINE_RO_ATTR(ver, S_IRUGO, NULL, fsp_attr_show_ver);
582 static struct attribute *fsp_attributes[] = {
583 &psmouse_attr_setreg.dattr.attr,
584 &psmouse_attr_getreg.dattr.attr,
585 &psmouse_attr_page.dattr.attr,
586 &psmouse_attr_vscroll.dattr.attr,
587 &psmouse_attr_hscroll.dattr.attr,
588 &psmouse_attr_flags.dattr.attr,
589 &psmouse_attr_ver.dattr.attr,
593 static struct attribute_group fsp_attribute_group = {
594 .attrs = fsp_attributes,
598 static void fsp_packet_debug(unsigned char packet[])
600 static unsigned int ps2_packet_cnt;
601 static unsigned int ps2_last_second;
602 unsigned int jiffies_msec;
605 jiffies_msec = jiffies_to_msecs(jiffies);
607 "%08dms PS/2 packets: %02x, %02x, %02x, %02x\n",
608 jiffies_msec, packet[0], packet[1], packet[2], packet[3]);
610 if (jiffies_msec - ps2_last_second > 1000) {
611 psmouse_dbg(psmouse, "PS/2 packets/sec = %d\n", ps2_packet_cnt);
613 ps2_last_second = jiffies_msec;
617 static void fsp_packet_debug(unsigned char packet[])
622 static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
624 struct input_dev *dev = psmouse->dev;
625 struct fsp_data *ad = psmouse->private;
626 unsigned char *packet = psmouse->packet;
627 unsigned char button_status = 0, lscroll = 0, rscroll = 0;
630 if (psmouse->pktcnt < 4)
631 return PSMOUSE_GOOD_DATA;
634 * Full packet accumulated, process it
637 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) {
638 case FSP_PKT_TYPE_ABS:
639 dev_warn(&psmouse->ps2dev.serio->dev,
640 "Unexpected absolute mode packet, ignored.\n");
643 case FSP_PKT_TYPE_NORMAL_OPC:
644 /* on-pad click, filter it if necessary */
645 if ((ad->flags & FSPDRV_FLAG_EN_OPC) != FSPDRV_FLAG_EN_OPC)
646 packet[0] &= ~BIT(0);
649 case FSP_PKT_TYPE_NORMAL:
651 /* special packet data translation from on-pad packets */
652 if (packet[3] != 0) {
653 if (packet[3] & BIT(0))
654 button_status |= 0x01; /* wheel down */
655 if (packet[3] & BIT(1))
656 button_status |= 0x0f; /* wheel up */
657 if (packet[3] & BIT(2))
658 button_status |= BIT(4);/* horizontal left */
659 if (packet[3] & BIT(3))
660 button_status |= BIT(5);/* horizontal right */
661 /* push back to packet queue */
662 if (button_status != 0)
663 packet[3] = button_status;
664 rscroll = (packet[3] >> 4) & 1;
665 lscroll = (packet[3] >> 5) & 1;
668 * Processing wheel up/down and extra button events
670 input_report_rel(dev, REL_WHEEL,
671 (int)(packet[3] & 8) - (int)(packet[3] & 7));
672 input_report_rel(dev, REL_HWHEEL, lscroll - rscroll);
673 input_report_key(dev, BTN_BACK, lscroll);
674 input_report_key(dev, BTN_FORWARD, rscroll);
677 * Standard PS/2 Mouse
679 input_report_key(dev, BTN_LEFT, packet[0] & 1);
680 input_report_key(dev, BTN_MIDDLE, (packet[0] >> 2) & 1);
681 input_report_key(dev, BTN_RIGHT, (packet[0] >> 1) & 1);
683 rel_x = packet[1] ? (int)packet[1] - (int)((packet[0] << 4) & 0x100) : 0;
684 rel_y = packet[2] ? (int)((packet[0] << 3) & 0x100) - (int)packet[2] : 0;
686 input_report_rel(dev, REL_X, rel_x);
687 input_report_rel(dev, REL_Y, rel_y);
693 fsp_packet_debug(packet);
695 return PSMOUSE_FULL_PACKET;
698 static int fsp_activate_protocol(struct psmouse *psmouse)
700 struct fsp_data *pad = psmouse->private;
701 struct ps2dev *ps2dev = &psmouse->ps2dev;
702 unsigned char param[2];
706 * Standard procedure to enter FSP Intellimouse mode
707 * (scrolling wheel, 4th and 5th buttons)
710 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
712 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
714 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
716 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
717 if (param[0] != 0x04) {
718 dev_err(&psmouse->ps2dev.serio->dev,
719 "Unable to enable 4 bytes packet format.\n");
723 if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &val)) {
724 dev_err(&psmouse->ps2dev.serio->dev,
725 "Unable to read SYSCTL5 register.\n");
729 val &= ~(FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8 | FSP_BIT_EN_AUTO_MSID8);
730 /* Ensure we are not in absolute mode */
731 val &= ~FSP_BIT_EN_PKT_G0;
732 if (pad->buttons == 0x06) {
733 /* Left/Middle/Right & Scroll Up/Down/Right/Left */
734 val |= FSP_BIT_EN_MSID6;
737 if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, val)) {
738 dev_err(&psmouse->ps2dev.serio->dev,
739 "Unable to set up required mode bits.\n");
744 * Enable OPC tags such that driver can tell the difference between
745 * on-pad and real button click
747 if (fsp_opc_tag_enable(psmouse, true))
748 dev_warn(&psmouse->ps2dev.serio->dev,
749 "Failed to enable OPC tag mode.\n");
751 /* Enable on-pad vertical and horizontal scrolling */
752 fsp_onpad_vscr(psmouse, true);
753 fsp_onpad_hscr(psmouse, true);
758 int fsp_detect(struct psmouse *psmouse, bool set_properties)
762 if (fsp_reg_read(psmouse, FSP_REG_DEVICE_ID, &id))
768 if (set_properties) {
769 psmouse->vendor = "Sentelic";
770 psmouse->name = "FingerSensingPad";
776 static void fsp_reset(struct psmouse *psmouse)
778 fsp_opc_tag_enable(psmouse, false);
779 fsp_onpad_vscr(psmouse, false);
780 fsp_onpad_hscr(psmouse, false);
783 static void fsp_disconnect(struct psmouse *psmouse)
785 sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj,
786 &fsp_attribute_group);
789 kfree(psmouse->private);
792 static int fsp_reconnect(struct psmouse *psmouse)
796 if (fsp_detect(psmouse, 0))
799 if (fsp_get_version(psmouse, &version))
802 if (fsp_activate_protocol(psmouse))
808 int fsp_init(struct psmouse *psmouse)
810 struct fsp_data *priv;
811 int ver, rev, buttons;
814 if (fsp_get_version(psmouse, &ver) ||
815 fsp_get_revision(psmouse, &rev) ||
816 fsp_get_buttons(psmouse, &buttons)) {
820 psmouse_info(psmouse,
821 "Finger Sensing Pad, hw: %d.%d.%d, sw: %s, buttons: %d\n",
822 ver >> 4, ver & 0x0F, rev, fsp_drv_ver, buttons & 7);
824 psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL);
830 priv->buttons = buttons;
832 /* enable on-pad click by default */
833 priv->flags |= FSPDRV_FLAG_EN_OPC;
835 /* Set up various supported input event bits */
836 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
837 __set_bit(BTN_BACK, psmouse->dev->keybit);
838 __set_bit(BTN_FORWARD, psmouse->dev->keybit);
839 __set_bit(REL_WHEEL, psmouse->dev->relbit);
840 __set_bit(REL_HWHEEL, psmouse->dev->relbit);
842 psmouse->protocol_handler = fsp_process_byte;
843 psmouse->disconnect = fsp_disconnect;
844 psmouse->reconnect = fsp_reconnect;
845 psmouse->cleanup = fsp_reset;
846 psmouse->pktsize = 4;
848 /* set default packet output based on number of buttons we found */
849 error = fsp_activate_protocol(psmouse);
853 error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj,
854 &fsp_attribute_group);
856 dev_err(&psmouse->ps2dev.serio->dev,
857 "Failed to create sysfs attributes (%d)", error);
864 kfree(psmouse->private);
865 psmouse->private = NULL;