.. | .. |
---|
63 | 63 | /* this driver doesn't aim at the peak continuous sample rate */ |
---|
64 | 64 | #define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */) |
---|
65 | 65 | |
---|
66 | | -struct ts_event { |
---|
67 | | - /* |
---|
68 | | - * For portability, we can't read 12 bit values using SPI (which |
---|
69 | | - * would make the controller deliver them as native byte order u16 |
---|
70 | | - * with msbs zeroed). Instead, we read them as two 8-bit values, |
---|
71 | | - * *** WHICH NEED BYTESWAPPING *** and range adjustment. |
---|
72 | | - */ |
---|
73 | | - u16 x; |
---|
74 | | - u16 y; |
---|
75 | | - u16 z1, z2; |
---|
76 | | - bool ignore; |
---|
77 | | - u8 x_buf[3]; |
---|
78 | | - u8 y_buf[3]; |
---|
| 66 | +struct ads7846_buf { |
---|
| 67 | + u8 cmd; |
---|
| 68 | + __be16 data; |
---|
| 69 | +} __packed; |
---|
| 70 | + |
---|
| 71 | +struct ads7846_buf_layout { |
---|
| 72 | + unsigned int offset; |
---|
| 73 | + unsigned int count; |
---|
| 74 | + unsigned int skip; |
---|
79 | 75 | }; |
---|
80 | 76 | |
---|
81 | 77 | /* |
---|
.. | .. |
---|
84 | 80 | * systems where main memory is not DMA-coherent (most non-x86 boards). |
---|
85 | 81 | */ |
---|
86 | 82 | struct ads7846_packet { |
---|
87 | | - u8 read_x, read_y, read_z1, read_z2, pwrdown; |
---|
88 | | - u16 dummy; /* for the pwrdown read */ |
---|
89 | | - struct ts_event tc; |
---|
90 | | - /* for ads7845 with mpc5121 psc spi we use 3-byte buffers */ |
---|
91 | | - u8 read_x_cmd[3], read_y_cmd[3], pwrdown_cmd[3]; |
---|
| 83 | + unsigned int count; |
---|
| 84 | + unsigned int count_skip; |
---|
| 85 | + unsigned int cmds; |
---|
| 86 | + unsigned int last_cmd_idx; |
---|
| 87 | + struct ads7846_buf_layout l[5]; |
---|
| 88 | + struct ads7846_buf *rx; |
---|
| 89 | + struct ads7846_buf *tx; |
---|
| 90 | + |
---|
| 91 | + struct ads7846_buf pwrdown_cmd; |
---|
| 92 | + |
---|
| 93 | + bool ignore; |
---|
| 94 | + u16 x, y, z1, z2; |
---|
92 | 95 | }; |
---|
93 | 96 | |
---|
94 | 97 | struct ads7846 { |
---|
.. | .. |
---|
187 | 190 | #define READ_Y(vref) (READ_12BIT_DFR(y, 1, vref)) |
---|
188 | 191 | #define READ_Z1(vref) (READ_12BIT_DFR(z1, 1, vref)) |
---|
189 | 192 | #define READ_Z2(vref) (READ_12BIT_DFR(z2, 1, vref)) |
---|
190 | | - |
---|
191 | 193 | #define READ_X(vref) (READ_12BIT_DFR(x, 1, vref)) |
---|
192 | 194 | #define PWRDOWN (READ_12BIT_DFR(y, 0, 0)) /* LAST */ |
---|
193 | 195 | |
---|
.. | .. |
---|
199 | 201 | |
---|
200 | 202 | #define REF_ON (READ_12BIT_DFR(x, 1, 1)) |
---|
201 | 203 | #define REF_OFF (READ_12BIT_DFR(y, 0, 0)) |
---|
| 204 | + |
---|
| 205 | +/* Order commands in the most optimal way to reduce Vref switching and |
---|
| 206 | + * settling time: |
---|
| 207 | + * Measure: X; Vref: X+, X-; IN: Y+ |
---|
| 208 | + * Measure: Y; Vref: Y+, Y-; IN: X+ |
---|
| 209 | + * Measure: Z1; Vref: Y+, X-; IN: X+ |
---|
| 210 | + * Measure: Z2; Vref: Y+, X-; IN: Y- |
---|
| 211 | + */ |
---|
| 212 | +enum ads7846_cmds { |
---|
| 213 | + ADS7846_X, |
---|
| 214 | + ADS7846_Y, |
---|
| 215 | + ADS7846_Z1, |
---|
| 216 | + ADS7846_Z2, |
---|
| 217 | + ADS7846_PWDOWN, |
---|
| 218 | +}; |
---|
202 | 219 | |
---|
203 | 220 | static int get_pendown_state(struct ads7846 *ts) |
---|
204 | 221 | { |
---|
.. | .. |
---|
682 | 699 | return ADS7846_FILTER_OK; |
---|
683 | 700 | } |
---|
684 | 701 | |
---|
685 | | -static int ads7846_get_value(struct ads7846 *ts, struct spi_message *m) |
---|
| 702 | +static int ads7846_get_value(struct ads7846_buf *buf) |
---|
686 | 703 | { |
---|
687 | 704 | int value; |
---|
688 | | - struct spi_transfer *t = |
---|
689 | | - list_entry(m->transfers.prev, struct spi_transfer, transfer_list); |
---|
690 | 705 | |
---|
691 | | - if (ts->model == 7845) { |
---|
692 | | - value = be16_to_cpup((__be16 *)&(((char *)t->rx_buf)[1])); |
---|
693 | | - } else { |
---|
694 | | - /* |
---|
695 | | - * adjust: on-wire is a must-ignore bit, a BE12 value, then |
---|
696 | | - * padding; built from two 8 bit values written msb-first. |
---|
697 | | - */ |
---|
698 | | - value = be16_to_cpup((__be16 *)t->rx_buf); |
---|
699 | | - } |
---|
| 706 | + value = be16_to_cpup(&buf->data); |
---|
700 | 707 | |
---|
701 | 708 | /* enforce ADC output is 12 bits width */ |
---|
702 | 709 | return (value >> 3) & 0xfff; |
---|
703 | 710 | } |
---|
704 | 711 | |
---|
705 | | -static void ads7846_update_value(struct spi_message *m, int val) |
---|
| 712 | +static void ads7846_set_cmd_val(struct ads7846 *ts, enum ads7846_cmds cmd_idx, |
---|
| 713 | + u16 val) |
---|
706 | 714 | { |
---|
707 | | - struct spi_transfer *t = |
---|
708 | | - list_entry(m->transfers.prev, struct spi_transfer, transfer_list); |
---|
| 715 | + struct ads7846_packet *packet = ts->packet; |
---|
709 | 716 | |
---|
710 | | - *(u16 *)t->rx_buf = val; |
---|
| 717 | + switch (cmd_idx) { |
---|
| 718 | + case ADS7846_Y: |
---|
| 719 | + packet->y = val; |
---|
| 720 | + break; |
---|
| 721 | + case ADS7846_X: |
---|
| 722 | + packet->x = val; |
---|
| 723 | + break; |
---|
| 724 | + case ADS7846_Z1: |
---|
| 725 | + packet->z1 = val; |
---|
| 726 | + break; |
---|
| 727 | + case ADS7846_Z2: |
---|
| 728 | + packet->z2 = val; |
---|
| 729 | + break; |
---|
| 730 | + default: |
---|
| 731 | + WARN_ON_ONCE(1); |
---|
| 732 | + } |
---|
| 733 | +} |
---|
| 734 | + |
---|
| 735 | +static u8 ads7846_get_cmd(enum ads7846_cmds cmd_idx, int vref) |
---|
| 736 | +{ |
---|
| 737 | + switch (cmd_idx) { |
---|
| 738 | + case ADS7846_Y: |
---|
| 739 | + return READ_Y(vref); |
---|
| 740 | + case ADS7846_X: |
---|
| 741 | + return READ_X(vref); |
---|
| 742 | + |
---|
| 743 | + /* 7846 specific commands */ |
---|
| 744 | + case ADS7846_Z1: |
---|
| 745 | + return READ_Z1(vref); |
---|
| 746 | + case ADS7846_Z2: |
---|
| 747 | + return READ_Z2(vref); |
---|
| 748 | + case ADS7846_PWDOWN: |
---|
| 749 | + return PWRDOWN; |
---|
| 750 | + default: |
---|
| 751 | + WARN_ON_ONCE(1); |
---|
| 752 | + } |
---|
| 753 | + |
---|
| 754 | + return 0; |
---|
| 755 | +} |
---|
| 756 | + |
---|
| 757 | +static bool ads7846_cmd_need_settle(enum ads7846_cmds cmd_idx) |
---|
| 758 | +{ |
---|
| 759 | + switch (cmd_idx) { |
---|
| 760 | + case ADS7846_X: |
---|
| 761 | + case ADS7846_Y: |
---|
| 762 | + case ADS7846_Z1: |
---|
| 763 | + case ADS7846_Z2: |
---|
| 764 | + return true; |
---|
| 765 | + case ADS7846_PWDOWN: |
---|
| 766 | + return false; |
---|
| 767 | + default: |
---|
| 768 | + WARN_ON_ONCE(1); |
---|
| 769 | + } |
---|
| 770 | + |
---|
| 771 | + return false; |
---|
| 772 | +} |
---|
| 773 | + |
---|
| 774 | +static int ads7846_filter(struct ads7846 *ts) |
---|
| 775 | +{ |
---|
| 776 | + struct ads7846_packet *packet = ts->packet; |
---|
| 777 | + int action; |
---|
| 778 | + int val; |
---|
| 779 | + unsigned int cmd_idx, b; |
---|
| 780 | + |
---|
| 781 | + packet->ignore = false; |
---|
| 782 | + for (cmd_idx = packet->last_cmd_idx; cmd_idx < packet->cmds - 1; cmd_idx++) { |
---|
| 783 | + struct ads7846_buf_layout *l = &packet->l[cmd_idx]; |
---|
| 784 | + |
---|
| 785 | + packet->last_cmd_idx = cmd_idx; |
---|
| 786 | + |
---|
| 787 | + for (b = l->skip; b < l->count; b++) { |
---|
| 788 | + val = ads7846_get_value(&packet->rx[l->offset + b]); |
---|
| 789 | + |
---|
| 790 | + action = ts->filter(ts->filter_data, cmd_idx, &val); |
---|
| 791 | + if (action == ADS7846_FILTER_REPEAT) { |
---|
| 792 | + if (b == l->count - 1) |
---|
| 793 | + return -EAGAIN; |
---|
| 794 | + } else if (action == ADS7846_FILTER_OK) { |
---|
| 795 | + ads7846_set_cmd_val(ts, cmd_idx, val); |
---|
| 796 | + break; |
---|
| 797 | + } else { |
---|
| 798 | + packet->ignore = true; |
---|
| 799 | + return 0; |
---|
| 800 | + } |
---|
| 801 | + } |
---|
| 802 | + } |
---|
| 803 | + |
---|
| 804 | + return 0; |
---|
711 | 805 | } |
---|
712 | 806 | |
---|
713 | 807 | static void ads7846_read_state(struct ads7846 *ts) |
---|
.. | .. |
---|
715 | 809 | struct ads7846_packet *packet = ts->packet; |
---|
716 | 810 | struct spi_message *m; |
---|
717 | 811 | int msg_idx = 0; |
---|
718 | | - int val; |
---|
719 | | - int action; |
---|
720 | 812 | int error; |
---|
721 | 813 | |
---|
722 | | - while (msg_idx < ts->msg_count) { |
---|
| 814 | + packet->last_cmd_idx = 0; |
---|
723 | 815 | |
---|
| 816 | + while (true) { |
---|
724 | 817 | ts->wait_for_sync(); |
---|
725 | 818 | |
---|
726 | 819 | m = &ts->msg[msg_idx]; |
---|
727 | 820 | error = spi_sync(ts->spi, m); |
---|
728 | 821 | if (error) { |
---|
729 | 822 | dev_err(&ts->spi->dev, "spi_sync --> %d\n", error); |
---|
730 | | - packet->tc.ignore = true; |
---|
| 823 | + packet->ignore = true; |
---|
731 | 824 | return; |
---|
732 | 825 | } |
---|
733 | 826 | |
---|
734 | | - /* |
---|
735 | | - * Last message is power down request, no need to convert |
---|
736 | | - * or filter the value. |
---|
737 | | - */ |
---|
738 | | - if (msg_idx < ts->msg_count - 1) { |
---|
| 827 | + error = ads7846_filter(ts); |
---|
| 828 | + if (error) |
---|
| 829 | + continue; |
---|
739 | 830 | |
---|
740 | | - val = ads7846_get_value(ts, m); |
---|
741 | | - |
---|
742 | | - action = ts->filter(ts->filter_data, msg_idx, &val); |
---|
743 | | - switch (action) { |
---|
744 | | - case ADS7846_FILTER_REPEAT: |
---|
745 | | - continue; |
---|
746 | | - |
---|
747 | | - case ADS7846_FILTER_IGNORE: |
---|
748 | | - packet->tc.ignore = true; |
---|
749 | | - msg_idx = ts->msg_count - 1; |
---|
750 | | - continue; |
---|
751 | | - |
---|
752 | | - case ADS7846_FILTER_OK: |
---|
753 | | - ads7846_update_value(m, val); |
---|
754 | | - packet->tc.ignore = false; |
---|
755 | | - msg_idx++; |
---|
756 | | - break; |
---|
757 | | - |
---|
758 | | - default: |
---|
759 | | - BUG(); |
---|
760 | | - } |
---|
761 | | - } else { |
---|
762 | | - msg_idx++; |
---|
763 | | - } |
---|
| 831 | + return; |
---|
764 | 832 | } |
---|
765 | 833 | } |
---|
766 | 834 | |
---|
.. | .. |
---|
770 | 838 | unsigned int Rt; |
---|
771 | 839 | u16 x, y, z1, z2; |
---|
772 | 840 | |
---|
773 | | - /* |
---|
774 | | - * ads7846_get_value() does in-place conversion (including byte swap) |
---|
775 | | - * from on-the-wire format as part of debouncing to get stable |
---|
776 | | - * readings. |
---|
777 | | - */ |
---|
| 841 | + x = packet->x; |
---|
| 842 | + y = packet->y; |
---|
778 | 843 | if (ts->model == 7845) { |
---|
779 | | - x = *(u16 *)packet->tc.x_buf; |
---|
780 | | - y = *(u16 *)packet->tc.y_buf; |
---|
781 | 844 | z1 = 0; |
---|
782 | 845 | z2 = 0; |
---|
783 | 846 | } else { |
---|
784 | | - x = packet->tc.x; |
---|
785 | | - y = packet->tc.y; |
---|
786 | | - z1 = packet->tc.z1; |
---|
787 | | - z2 = packet->tc.z2; |
---|
| 847 | + z1 = packet->z1; |
---|
| 848 | + z2 = packet->z2; |
---|
788 | 849 | } |
---|
789 | 850 | |
---|
790 | 851 | /* range filtering */ |
---|
791 | 852 | if (x == MAX_12BIT) |
---|
792 | 853 | x = 0; |
---|
793 | 854 | |
---|
794 | | - if (ts->model == 7843) { |
---|
| 855 | + if (ts->model == 7843 || ts->model == 7845) { |
---|
795 | 856 | Rt = ts->pressure_max / 2; |
---|
796 | | - } else if (ts->model == 7845) { |
---|
797 | | - if (get_pendown_state(ts)) |
---|
798 | | - Rt = ts->pressure_max / 2; |
---|
799 | | - else |
---|
800 | | - Rt = 0; |
---|
801 | | - dev_vdbg(&ts->spi->dev, "x/y: %d/%d, PD %d\n", x, y, Rt); |
---|
802 | 857 | } else if (likely(x && z1)) { |
---|
803 | 858 | /* compute touch pressure resistance using equation #2 */ |
---|
804 | 859 | Rt = z2; |
---|
.. | .. |
---|
817 | 872 | * the maximum. Don't report it to user space, repeat at least |
---|
818 | 873 | * once more the measurement |
---|
819 | 874 | */ |
---|
820 | | - if (packet->tc.ignore || Rt > ts->pressure_max) { |
---|
| 875 | + if (packet->ignore || Rt > ts->pressure_max) { |
---|
821 | 876 | dev_vdbg(&ts->spi->dev, "ignored %d pressure %d\n", |
---|
822 | | - packet->tc.ignore, Rt); |
---|
| 877 | + packet->ignore, Rt); |
---|
823 | 878 | return; |
---|
824 | 879 | } |
---|
825 | 880 | |
---|
.. | .. |
---|
980 | 1035 | * Set up the transfers to read touchscreen state; this assumes we |
---|
981 | 1036 | * use formula #2 for pressure, not #3. |
---|
982 | 1037 | */ |
---|
983 | | -static void ads7846_setup_spi_msg(struct ads7846 *ts, |
---|
| 1038 | +static int ads7846_setup_spi_msg(struct ads7846 *ts, |
---|
984 | 1039 | const struct ads7846_platform_data *pdata) |
---|
985 | 1040 | { |
---|
986 | 1041 | struct spi_message *m = &ts->msg[0]; |
---|
987 | 1042 | struct spi_transfer *x = ts->xfer; |
---|
988 | 1043 | struct ads7846_packet *packet = ts->packet; |
---|
989 | 1044 | int vref = pdata->keep_vref_on; |
---|
| 1045 | + unsigned int count, offset = 0; |
---|
| 1046 | + unsigned int cmd_idx, b; |
---|
| 1047 | + unsigned long time; |
---|
| 1048 | + size_t size = 0; |
---|
| 1049 | + |
---|
| 1050 | + /* time per bit */ |
---|
| 1051 | + time = NSEC_PER_SEC / ts->spi->max_speed_hz; |
---|
| 1052 | + |
---|
| 1053 | + count = pdata->settle_delay_usecs * NSEC_PER_USEC / time; |
---|
| 1054 | + packet->count_skip = DIV_ROUND_UP(count, 24); |
---|
| 1055 | + |
---|
| 1056 | + if (ts->debounce_max && ts->debounce_rep) |
---|
| 1057 | + /* ads7846_debounce_filter() is making ts->debounce_rep + 2 |
---|
| 1058 | + * reads. So we need to get all samples for normal case. */ |
---|
| 1059 | + packet->count = ts->debounce_rep + 2; |
---|
| 1060 | + else |
---|
| 1061 | + packet->count = 1; |
---|
| 1062 | + |
---|
| 1063 | + if (ts->model == 7846) |
---|
| 1064 | + packet->cmds = 5; /* x, y, z1, z2, pwdown */ |
---|
| 1065 | + else |
---|
| 1066 | + packet->cmds = 3; /* x, y, pwdown */ |
---|
| 1067 | + |
---|
| 1068 | + for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) { |
---|
| 1069 | + struct ads7846_buf_layout *l = &packet->l[cmd_idx]; |
---|
| 1070 | + unsigned int max_count; |
---|
| 1071 | + |
---|
| 1072 | + if (cmd_idx == packet->cmds - 1) |
---|
| 1073 | + cmd_idx = ADS7846_PWDOWN; |
---|
| 1074 | + |
---|
| 1075 | + if (ads7846_cmd_need_settle(cmd_idx)) |
---|
| 1076 | + max_count = packet->count + packet->count_skip; |
---|
| 1077 | + else |
---|
| 1078 | + max_count = packet->count; |
---|
| 1079 | + |
---|
| 1080 | + l->offset = offset; |
---|
| 1081 | + offset += max_count; |
---|
| 1082 | + l->count = max_count; |
---|
| 1083 | + l->skip = packet->count_skip; |
---|
| 1084 | + size += sizeof(*packet->tx) * max_count; |
---|
| 1085 | + } |
---|
| 1086 | + |
---|
| 1087 | + packet->tx = devm_kzalloc(&ts->spi->dev, size, GFP_KERNEL); |
---|
| 1088 | + if (!packet->tx) |
---|
| 1089 | + return -ENOMEM; |
---|
| 1090 | + |
---|
| 1091 | + packet->rx = devm_kzalloc(&ts->spi->dev, size, GFP_KERNEL); |
---|
| 1092 | + if (!packet->rx) |
---|
| 1093 | + return -ENOMEM; |
---|
990 | 1094 | |
---|
991 | 1095 | if (ts->model == 7873) { |
---|
992 | 1096 | /* |
---|
.. | .. |
---|
1002 | 1106 | spi_message_init(m); |
---|
1003 | 1107 | m->context = ts; |
---|
1004 | 1108 | |
---|
1005 | | - if (ts->model == 7845) { |
---|
1006 | | - packet->read_y_cmd[0] = READ_Y(vref); |
---|
1007 | | - packet->read_y_cmd[1] = 0; |
---|
1008 | | - packet->read_y_cmd[2] = 0; |
---|
1009 | | - x->tx_buf = &packet->read_y_cmd[0]; |
---|
1010 | | - x->rx_buf = &packet->tc.y_buf[0]; |
---|
1011 | | - x->len = 3; |
---|
1012 | | - spi_message_add_tail(x, m); |
---|
1013 | | - } else { |
---|
1014 | | - /* y- still on; turn on only y+ (and ADC) */ |
---|
1015 | | - packet->read_y = READ_Y(vref); |
---|
1016 | | - x->tx_buf = &packet->read_y; |
---|
1017 | | - x->len = 1; |
---|
1018 | | - spi_message_add_tail(x, m); |
---|
| 1109 | + for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) { |
---|
| 1110 | + struct ads7846_buf_layout *l = &packet->l[cmd_idx]; |
---|
| 1111 | + u8 cmd; |
---|
1019 | 1112 | |
---|
1020 | | - x++; |
---|
1021 | | - x->rx_buf = &packet->tc.y; |
---|
1022 | | - x->len = 2; |
---|
1023 | | - spi_message_add_tail(x, m); |
---|
| 1113 | + if (cmd_idx == packet->cmds - 1) |
---|
| 1114 | + cmd_idx = ADS7846_PWDOWN; |
---|
| 1115 | + |
---|
| 1116 | + cmd = ads7846_get_cmd(cmd_idx, vref); |
---|
| 1117 | + |
---|
| 1118 | + for (b = 0; b < l->count; b++) |
---|
| 1119 | + packet->tx[l->offset + b].cmd = cmd; |
---|
1024 | 1120 | } |
---|
1025 | 1121 | |
---|
1026 | | - /* |
---|
1027 | | - * The first sample after switching drivers can be low quality; |
---|
1028 | | - * optionally discard it, using a second one after the signals |
---|
1029 | | - * have had enough time to stabilize. |
---|
1030 | | - */ |
---|
1031 | | - if (pdata->settle_delay_usecs) { |
---|
1032 | | - x->delay.value = pdata->settle_delay_usecs; |
---|
1033 | | - x->delay.unit = SPI_DELAY_UNIT_USECS; |
---|
1034 | | - |
---|
1035 | | - x++; |
---|
1036 | | - x->tx_buf = &packet->read_y; |
---|
1037 | | - x->len = 1; |
---|
1038 | | - spi_message_add_tail(x, m); |
---|
1039 | | - |
---|
1040 | | - x++; |
---|
1041 | | - x->rx_buf = &packet->tc.y; |
---|
1042 | | - x->len = 2; |
---|
1043 | | - spi_message_add_tail(x, m); |
---|
1044 | | - } |
---|
1045 | | - |
---|
1046 | | - ts->msg_count++; |
---|
1047 | | - m++; |
---|
1048 | | - spi_message_init(m); |
---|
1049 | | - m->context = ts; |
---|
1050 | | - |
---|
1051 | | - if (ts->model == 7845) { |
---|
1052 | | - x++; |
---|
1053 | | - packet->read_x_cmd[0] = READ_X(vref); |
---|
1054 | | - packet->read_x_cmd[1] = 0; |
---|
1055 | | - packet->read_x_cmd[2] = 0; |
---|
1056 | | - x->tx_buf = &packet->read_x_cmd[0]; |
---|
1057 | | - x->rx_buf = &packet->tc.x_buf[0]; |
---|
1058 | | - x->len = 3; |
---|
1059 | | - spi_message_add_tail(x, m); |
---|
1060 | | - } else { |
---|
1061 | | - /* turn y- off, x+ on, then leave in lowpower */ |
---|
1062 | | - x++; |
---|
1063 | | - packet->read_x = READ_X(vref); |
---|
1064 | | - x->tx_buf = &packet->read_x; |
---|
1065 | | - x->len = 1; |
---|
1066 | | - spi_message_add_tail(x, m); |
---|
1067 | | - |
---|
1068 | | - x++; |
---|
1069 | | - x->rx_buf = &packet->tc.x; |
---|
1070 | | - x->len = 2; |
---|
1071 | | - spi_message_add_tail(x, m); |
---|
1072 | | - } |
---|
1073 | | - |
---|
1074 | | - /* ... maybe discard first sample ... */ |
---|
1075 | | - if (pdata->settle_delay_usecs) { |
---|
1076 | | - x->delay.value = pdata->settle_delay_usecs; |
---|
1077 | | - x->delay.unit = SPI_DELAY_UNIT_USECS; |
---|
1078 | | - |
---|
1079 | | - x++; |
---|
1080 | | - x->tx_buf = &packet->read_x; |
---|
1081 | | - x->len = 1; |
---|
1082 | | - spi_message_add_tail(x, m); |
---|
1083 | | - |
---|
1084 | | - x++; |
---|
1085 | | - x->rx_buf = &packet->tc.x; |
---|
1086 | | - x->len = 2; |
---|
1087 | | - spi_message_add_tail(x, m); |
---|
1088 | | - } |
---|
1089 | | - |
---|
1090 | | - /* turn y+ off, x- on; we'll use formula #2 */ |
---|
1091 | | - if (ts->model == 7846) { |
---|
1092 | | - ts->msg_count++; |
---|
1093 | | - m++; |
---|
1094 | | - spi_message_init(m); |
---|
1095 | | - m->context = ts; |
---|
1096 | | - |
---|
1097 | | - x++; |
---|
1098 | | - packet->read_z1 = READ_Z1(vref); |
---|
1099 | | - x->tx_buf = &packet->read_z1; |
---|
1100 | | - x->len = 1; |
---|
1101 | | - spi_message_add_tail(x, m); |
---|
1102 | | - |
---|
1103 | | - x++; |
---|
1104 | | - x->rx_buf = &packet->tc.z1; |
---|
1105 | | - x->len = 2; |
---|
1106 | | - spi_message_add_tail(x, m); |
---|
1107 | | - |
---|
1108 | | - /* ... maybe discard first sample ... */ |
---|
1109 | | - if (pdata->settle_delay_usecs) { |
---|
1110 | | - x->delay.value = pdata->settle_delay_usecs; |
---|
1111 | | - x->delay.unit = SPI_DELAY_UNIT_USECS; |
---|
1112 | | - |
---|
1113 | | - x++; |
---|
1114 | | - x->tx_buf = &packet->read_z1; |
---|
1115 | | - x->len = 1; |
---|
1116 | | - spi_message_add_tail(x, m); |
---|
1117 | | - |
---|
1118 | | - x++; |
---|
1119 | | - x->rx_buf = &packet->tc.z1; |
---|
1120 | | - x->len = 2; |
---|
1121 | | - spi_message_add_tail(x, m); |
---|
1122 | | - } |
---|
1123 | | - |
---|
1124 | | - ts->msg_count++; |
---|
1125 | | - m++; |
---|
1126 | | - spi_message_init(m); |
---|
1127 | | - m->context = ts; |
---|
1128 | | - |
---|
1129 | | - x++; |
---|
1130 | | - packet->read_z2 = READ_Z2(vref); |
---|
1131 | | - x->tx_buf = &packet->read_z2; |
---|
1132 | | - x->len = 1; |
---|
1133 | | - spi_message_add_tail(x, m); |
---|
1134 | | - |
---|
1135 | | - x++; |
---|
1136 | | - x->rx_buf = &packet->tc.z2; |
---|
1137 | | - x->len = 2; |
---|
1138 | | - spi_message_add_tail(x, m); |
---|
1139 | | - |
---|
1140 | | - /* ... maybe discard first sample ... */ |
---|
1141 | | - if (pdata->settle_delay_usecs) { |
---|
1142 | | - x->delay.value = pdata->settle_delay_usecs; |
---|
1143 | | - x->delay.unit = SPI_DELAY_UNIT_USECS; |
---|
1144 | | - |
---|
1145 | | - x++; |
---|
1146 | | - x->tx_buf = &packet->read_z2; |
---|
1147 | | - x->len = 1; |
---|
1148 | | - spi_message_add_tail(x, m); |
---|
1149 | | - |
---|
1150 | | - x++; |
---|
1151 | | - x->rx_buf = &packet->tc.z2; |
---|
1152 | | - x->len = 2; |
---|
1153 | | - spi_message_add_tail(x, m); |
---|
1154 | | - } |
---|
1155 | | - } |
---|
1156 | | - |
---|
1157 | | - /* power down */ |
---|
1158 | | - ts->msg_count++; |
---|
1159 | | - m++; |
---|
1160 | | - spi_message_init(m); |
---|
1161 | | - m->context = ts; |
---|
1162 | | - |
---|
1163 | | - if (ts->model == 7845) { |
---|
1164 | | - x++; |
---|
1165 | | - packet->pwrdown_cmd[0] = PWRDOWN; |
---|
1166 | | - packet->pwrdown_cmd[1] = 0; |
---|
1167 | | - packet->pwrdown_cmd[2] = 0; |
---|
1168 | | - x->tx_buf = &packet->pwrdown_cmd[0]; |
---|
1169 | | - x->len = 3; |
---|
1170 | | - } else { |
---|
1171 | | - x++; |
---|
1172 | | - packet->pwrdown = PWRDOWN; |
---|
1173 | | - x->tx_buf = &packet->pwrdown; |
---|
1174 | | - x->len = 1; |
---|
1175 | | - spi_message_add_tail(x, m); |
---|
1176 | | - |
---|
1177 | | - x++; |
---|
1178 | | - x->rx_buf = &packet->dummy; |
---|
1179 | | - x->len = 2; |
---|
1180 | | - } |
---|
1181 | | - |
---|
1182 | | - CS_CHANGE(*x); |
---|
| 1122 | + x->tx_buf = packet->tx; |
---|
| 1123 | + x->rx_buf = packet->rx; |
---|
| 1124 | + x->len = size; |
---|
1183 | 1125 | spi_message_add_tail(x, m); |
---|
| 1126 | + |
---|
| 1127 | + return 0; |
---|
1184 | 1128 | } |
---|
1185 | 1129 | |
---|
1186 | 1130 | #ifdef CONFIG_OF |
---|
.. | .. |
---|
1381 | 1325 | pdata->y_min ? : 0, |
---|
1382 | 1326 | pdata->y_max ? : MAX_12BIT, |
---|
1383 | 1327 | 0, 0); |
---|
1384 | | - input_set_abs_params(input_dev, ABS_PRESSURE, |
---|
1385 | | - pdata->pressure_min, pdata->pressure_max, 0, 0); |
---|
| 1328 | + if (ts->model != 7845) |
---|
| 1329 | + input_set_abs_params(input_dev, ABS_PRESSURE, |
---|
| 1330 | + pdata->pressure_min, pdata->pressure_max, 0, 0); |
---|
1386 | 1331 | |
---|
1387 | 1332 | /* |
---|
1388 | 1333 | * Parse common framework properties. Must be done here to ensure the |
---|