diff options
| -rw-r--r-- | drivers/input/mouse/sentelic.c | 143 | ||||
| -rw-r--r-- | drivers/input/mouse/sentelic.h | 13 |
2 files changed, 94 insertions, 62 deletions
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c index 2a77a52d2e62..62fa69825671 100644 --- a/drivers/input/mouse/sentelic.c +++ b/drivers/input/mouse/sentelic.c | |||
| @@ -128,8 +128,9 @@ static int fsp_reg_read(struct psmouse *psmouse, int reg_addr, int *reg_val) | |||
| 128 | out: | 128 | out: |
| 129 | ps2_end_command(ps2dev); | 129 | ps2_end_command(ps2dev); |
| 130 | psmouse_activate(psmouse); | 130 | psmouse_activate(psmouse); |
| 131 | dev_dbg(&ps2dev->serio->dev, "READ REG: 0x%02x is 0x%02x (rc = %d)\n", | 131 | psmouse_dbg(psmouse, |
| 132 | reg_addr, *reg_val, rc); | 132 | "READ REG: 0x%02x is 0x%02x (rc = %d)\n", |
| 133 | reg_addr, *reg_val, rc); | ||
| 133 | return rc; | 134 | return rc; |
| 134 | } | 135 | } |
| 135 | 136 | ||
| @@ -179,8 +180,9 @@ static int fsp_reg_write(struct psmouse *psmouse, int reg_addr, int reg_val) | |||
| 179 | 180 | ||
| 180 | out: | 181 | out: |
| 181 | ps2_end_command(ps2dev); | 182 | ps2_end_command(ps2dev); |
| 182 | dev_dbg(&ps2dev->serio->dev, "WRITE REG: 0x%02x to 0x%02x (rc = %d)\n", | 183 | psmouse_dbg(psmouse, |
| 183 | reg_addr, reg_val, rc); | 184 | "WRITE REG: 0x%02x to 0x%02x (rc = %d)\n", |
| 185 | reg_addr, reg_val, rc); | ||
| 184 | return rc; | 186 | return rc; |
| 185 | } | 187 | } |
| 186 | 188 | ||
| @@ -237,8 +239,9 @@ static int fsp_page_reg_read(struct psmouse *psmouse, int *reg_val) | |||
| 237 | out: | 239 | out: |
| 238 | ps2_end_command(ps2dev); | 240 | ps2_end_command(ps2dev); |
| 239 | psmouse_activate(psmouse); | 241 | psmouse_activate(psmouse); |
| 240 | dev_dbg(&ps2dev->serio->dev, "READ PAGE REG: 0x%02x (rc = %d)\n", | 242 | psmouse_dbg(psmouse, |
| 241 | *reg_val, rc); | 243 | "READ PAGE REG: 0x%02x (rc = %d)\n", |
| 244 | *reg_val, rc); | ||
| 242 | return rc; | 245 | return rc; |
| 243 | } | 246 | } |
| 244 | 247 | ||
| @@ -274,8 +277,9 @@ static int fsp_page_reg_write(struct psmouse *psmouse, int reg_val) | |||
| 274 | 277 | ||
| 275 | out: | 278 | out: |
| 276 | ps2_end_command(ps2dev); | 279 | ps2_end_command(ps2dev); |
| 277 | dev_dbg(&ps2dev->serio->dev, "WRITE PAGE REG: to 0x%02x (rc = %d)\n", | 280 | psmouse_dbg(psmouse, |
| 278 | reg_val, rc); | 281 | "WRITE PAGE REG: to 0x%02x (rc = %d)\n", |
| 282 | reg_val, rc); | ||
| 279 | return rc; | 283 | return rc; |
| 280 | } | 284 | } |
| 281 | 285 | ||
| @@ -319,7 +323,7 @@ static int fsp_opc_tag_enable(struct psmouse *psmouse, bool enable) | |||
| 319 | int res = 0; | 323 | int res = 0; |
| 320 | 324 | ||
| 321 | if (fsp_reg_read(psmouse, FSP_REG_OPC_QDOWN, &v) == -1) { | 325 | if (fsp_reg_read(psmouse, FSP_REG_OPC_QDOWN, &v) == -1) { |
| 322 | dev_err(&psmouse->ps2dev.serio->dev, "Unable get OPC state.\n"); | 326 | psmouse_err(psmouse, "Unable get OPC state.\n"); |
| 323 | return -EIO; | 327 | return -EIO; |
| 324 | } | 328 | } |
| 325 | 329 | ||
| @@ -336,8 +340,7 @@ static int fsp_opc_tag_enable(struct psmouse *psmouse, bool enable) | |||
| 336 | } | 340 | } |
| 337 | 341 | ||
| 338 | if (res != 0) { | 342 | if (res != 0) { |
| 339 | dev_err(&psmouse->ps2dev.serio->dev, | 343 | psmouse_err(psmouse, "Unable to enable OPC tag.\n"); |
| 340 | "Unable to enable OPC tag.\n"); | ||
| 341 | res = -EIO; | 344 | res = -EIO; |
| 342 | } | 345 | } |
| 343 | 346 | ||
| @@ -657,8 +660,8 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse) | |||
| 657 | 660 | ||
| 658 | switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) { | 661 | switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) { |
| 659 | case FSP_PKT_TYPE_ABS: | 662 | case FSP_PKT_TYPE_ABS: |
| 660 | dev_warn(&psmouse->ps2dev.serio->dev, | 663 | psmouse_warn(psmouse, |
| 661 | "Unexpected absolute mode packet, ignored.\n"); | 664 | "Unexpected absolute mode packet, ignored.\n"); |
| 662 | break; | 665 | break; |
| 663 | 666 | ||
| 664 | case FSP_PKT_TYPE_NORMAL_OPC: | 667 | case FSP_PKT_TYPE_NORMAL_OPC: |
| @@ -736,42 +739,69 @@ static int fsp_activate_protocol(struct psmouse *psmouse) | |||
| 736 | 739 | ||
| 737 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETID); | 740 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETID); |
| 738 | if (param[0] != 0x04) { | 741 | if (param[0] != 0x04) { |
| 739 | dev_err(&psmouse->ps2dev.serio->dev, | 742 | psmouse_err(psmouse, |
| 740 | "Unable to enable 4 bytes packet format.\n"); | 743 | "Unable to enable 4 bytes packet format.\n"); |
| 741 | return -EIO; | 744 | return -EIO; |
| 742 | } | 745 | } |
| 743 | 746 | ||
| 744 | if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &val)) { | 747 | if (pad->ver < FSP_VER_STL3888_C0) { |
| 745 | dev_err(&psmouse->ps2dev.serio->dev, | 748 | /* Preparing relative coordinates output for older hardware */ |
| 746 | "Unable to read SYSCTL5 register.\n"); | 749 | if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &val)) { |
| 747 | return -EIO; | 750 | psmouse_err(psmouse, |
| 748 | } | 751 | "Unable to read SYSCTL5 register.\n"); |
| 752 | return -EIO; | ||
| 753 | } | ||
| 749 | 754 | ||
| 750 | val &= ~(FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8 | FSP_BIT_EN_AUTO_MSID8); | 755 | if (fsp_get_buttons(psmouse, &pad->buttons)) { |
| 751 | /* Ensure we are not in absolute mode */ | 756 | psmouse_err(psmouse, |
| 752 | val &= ~FSP_BIT_EN_PKT_G0; | 757 | "Unable to retrieve number of buttons.\n"); |
| 753 | if (pad->buttons == 0x06) { | 758 | return -EIO; |
| 754 | /* Left/Middle/Right & Scroll Up/Down/Right/Left */ | 759 | } |
| 755 | val |= FSP_BIT_EN_MSID6; | ||
| 756 | } | ||
| 757 | 760 | ||
| 758 | if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, val)) { | 761 | val &= ~(FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8 | FSP_BIT_EN_AUTO_MSID8); |
| 759 | dev_err(&psmouse->ps2dev.serio->dev, | 762 | /* Ensure we are not in absolute mode */ |
| 760 | "Unable to set up required mode bits.\n"); | 763 | val &= ~FSP_BIT_EN_PKT_G0; |
| 761 | return -EIO; | 764 | if (pad->buttons == 0x06) { |
| 765 | /* Left/Middle/Right & Scroll Up/Down/Right/Left */ | ||
| 766 | val |= FSP_BIT_EN_MSID6; | ||
| 767 | } | ||
| 768 | |||
| 769 | if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, val)) { | ||
| 770 | psmouse_err(psmouse, | ||
| 771 | "Unable to set up required mode bits.\n"); | ||
| 772 | return -EIO; | ||
| 773 | } | ||
| 774 | |||
| 775 | /* | ||
| 776 | * Enable OPC tags such that driver can tell the difference | ||
| 777 | * between on-pad and real button click | ||
| 778 | */ | ||
| 779 | if (fsp_opc_tag_enable(psmouse, true)) | ||
| 780 | psmouse_warn(psmouse, | ||
| 781 | "Failed to enable OPC tag mode.\n"); | ||
| 782 | /* enable on-pad click by default */ | ||
| 783 | pad->flags |= FSPDRV_FLAG_EN_OPC; | ||
| 784 | |||
| 785 | /* Enable on-pad vertical and horizontal scrolling */ | ||
| 786 | fsp_onpad_vscr(psmouse, true); | ||
| 787 | fsp_onpad_hscr(psmouse, true); | ||
| 762 | } | 788 | } |
| 763 | 789 | ||
| 764 | /* | 790 | return 0; |
| 765 | * Enable OPC tags such that driver can tell the difference between | 791 | } |
| 766 | * on-pad and real button click | 792 | |
| 767 | */ | 793 | static int fsp_set_input_params(struct psmouse *psmouse) |
| 768 | if (fsp_opc_tag_enable(psmouse, true)) | 794 | { |
| 769 | dev_warn(&psmouse->ps2dev.serio->dev, | 795 | struct input_dev *dev = psmouse->dev; |
| 770 | "Failed to enable OPC tag mode.\n"); | 796 | struct fsp_data *pad = psmouse->private; |
| 771 | 797 | ||
| 772 | /* Enable on-pad vertical and horizontal scrolling */ | 798 | if (pad->ver < FSP_VER_STL3888_C0) { |
| 773 | fsp_onpad_vscr(psmouse, true); | 799 | __set_bit(BTN_MIDDLE, dev->keybit); |
| 774 | fsp_onpad_hscr(psmouse, true); | 800 | __set_bit(BTN_BACK, dev->keybit); |
| 801 | __set_bit(BTN_FORWARD, dev->keybit); | ||
| 802 | __set_bit(REL_WHEEL, dev->relbit); | ||
| 803 | __set_bit(REL_HWHEEL, dev->relbit); | ||
| 804 | } | ||
| 775 | 805 | ||
| 776 | return 0; | 806 | return 0; |
| 777 | } | 807 | } |
| @@ -829,18 +859,16 @@ static int fsp_reconnect(struct psmouse *psmouse) | |||
| 829 | int fsp_init(struct psmouse *psmouse) | 859 | int fsp_init(struct psmouse *psmouse) |
| 830 | { | 860 | { |
| 831 | struct fsp_data *priv; | 861 | struct fsp_data *priv; |
| 832 | int ver, rev, buttons; | 862 | int ver, rev; |
| 833 | int error; | 863 | int error; |
| 834 | 864 | ||
| 835 | if (fsp_get_version(psmouse, &ver) || | 865 | if (fsp_get_version(psmouse, &ver) || |
| 836 | fsp_get_revision(psmouse, &rev) || | 866 | fsp_get_revision(psmouse, &rev)) { |
| 837 | fsp_get_buttons(psmouse, &buttons)) { | ||
| 838 | return -ENODEV; | 867 | return -ENODEV; |
| 839 | } | 868 | } |
| 840 | 869 | ||
| 841 | psmouse_info(psmouse, | 870 | psmouse_info(psmouse, "Finger Sensing Pad, hw: %d.%d.%d, sw: %s\n", |
| 842 | "Finger Sensing Pad, hw: %d.%d.%d, sw: %s, buttons: %d\n", | 871 | ver >> 4, ver & 0x0F, rev, fsp_drv_ver); |
| 843 | ver >> 4, ver & 0x0F, rev, fsp_drv_ver, buttons & 7); | ||
| 844 | 872 | ||
| 845 | psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL); | 873 | psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL); |
| 846 | if (!priv) | 874 | if (!priv) |
| @@ -848,17 +876,6 @@ int fsp_init(struct psmouse *psmouse) | |||
| 848 | 876 | ||
| 849 | priv->ver = ver; | 877 | priv->ver = ver; |
| 850 | priv->rev = rev; | 878 | priv->rev = rev; |
| 851 | priv->buttons = buttons; | ||
| 852 | |||
| 853 | /* enable on-pad click by default */ | ||
| 854 | priv->flags |= FSPDRV_FLAG_EN_OPC; | ||
| 855 | |||
| 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); | ||
| 862 | 879 | ||
| 863 | psmouse->protocol_handler = fsp_process_byte; | 880 | psmouse->protocol_handler = fsp_process_byte; |
| 864 | psmouse->disconnect = fsp_disconnect; | 881 | psmouse->disconnect = fsp_disconnect; |
| @@ -866,16 +883,20 @@ int fsp_init(struct psmouse *psmouse) | |||
| 866 | psmouse->cleanup = fsp_reset; | 883 | psmouse->cleanup = fsp_reset; |
| 867 | psmouse->pktsize = 4; | 884 | psmouse->pktsize = 4; |
| 868 | 885 | ||
| 869 | /* set default packet output based on number of buttons we found */ | ||
| 870 | error = fsp_activate_protocol(psmouse); | 886 | error = fsp_activate_protocol(psmouse); |
| 871 | if (error) | 887 | if (error) |
| 872 | goto err_out; | 888 | goto err_out; |
| 873 | 889 | ||
| 890 | /* Set up various supported input event bits */ | ||
| 891 | error = fsp_set_input_params(psmouse); | ||
| 892 | if (error) | ||
| 893 | goto err_out; | ||
| 894 | |||
| 874 | error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj, | 895 | error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj, |
| 875 | &fsp_attribute_group); | 896 | &fsp_attribute_group); |
| 876 | if (error) { | 897 | if (error) { |
| 877 | dev_err(&psmouse->ps2dev.serio->dev, | 898 | psmouse_err(psmouse, |
| 878 | "Failed to create sysfs attributes (%d)", error); | 899 | "Failed to create sysfs attributes (%d)", error); |
| 879 | goto err_out; | 900 | goto err_out; |
| 880 | } | 901 | } |
| 881 | 902 | ||
diff --git a/drivers/input/mouse/sentelic.h b/drivers/input/mouse/sentelic.h index 2e4af24f8c15..23bd25e539ba 100644 --- a/drivers/input/mouse/sentelic.h +++ b/drivers/input/mouse/sentelic.h | |||
| @@ -64,12 +64,23 @@ | |||
| 64 | #define FSP_PKT_TYPE_NORMAL_OPC (0x03) | 64 | #define FSP_PKT_TYPE_NORMAL_OPC (0x03) |
| 65 | #define FSP_PKT_TYPE_SHIFT (6) | 65 | #define FSP_PKT_TYPE_SHIFT (6) |
| 66 | 66 | ||
| 67 | /* hardware revisions */ | ||
| 68 | #define FSP_VER_STL3888_A4 (0xC1) | ||
| 69 | #define FSP_VER_STL3888_B0 (0xD0) | ||
| 70 | #define FSP_VER_STL3888_B1 (0xD1) | ||
| 71 | #define FSP_VER_STL3888_B2 (0xD2) | ||
| 72 | #define FSP_VER_STL3888_C0 (0xE0) | ||
| 73 | #define FSP_VER_STL3888_C1 (0xE1) | ||
| 74 | #define FSP_VER_STL3888_D0 (0xE2) | ||
| 75 | #define FSP_VER_STL3888_D1 (0xE3) | ||
| 76 | #define FSP_VER_STL3888_E0 (0xE4) | ||
| 77 | |||
| 67 | #ifdef __KERNEL__ | 78 | #ifdef __KERNEL__ |
| 68 | 79 | ||
| 69 | struct fsp_data { | 80 | struct fsp_data { |
| 70 | unsigned char ver; /* hardware version */ | 81 | unsigned char ver; /* hardware version */ |
| 71 | unsigned char rev; /* hardware revison */ | 82 | unsigned char rev; /* hardware revison */ |
| 72 | unsigned char buttons; /* Number of buttons */ | 83 | unsigned int buttons; /* Number of buttons */ |
| 73 | unsigned int flags; | 84 | unsigned int flags; |
| 74 | #define FSPDRV_FLAG_EN_OPC (0x001) /* enable on-pad clicking */ | 85 | #define FSPDRV_FLAG_EN_OPC (0x001) /* enable on-pad clicking */ |
| 75 | 86 | ||
