Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging/iio/adc/touchscreen/MXS: remove old touchscreen detection implementation

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Tested-by: Marek Vasut <marex@denx.de>
Acked-by: Marek Vasut <marex@denx.de>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

CC: linux-arm-kernel@lists.infradead.org
CC: linux-input@vger.kernel.org
CC: devel@driverdev.osuosl.org
CC: Marek Vasut <marex@denx.de>
CC: Fabio Estevam <fabio.estevam@freescale.com>

authored by

Juergen Beisert and committed by
Jonathan Cameron
cd6c5586 dee05308

-163
-163
drivers/staging/iio/adc/mxs-lradc.c
··· 186 186 bool use_touchbutton; 187 187 188 188 struct input_dev *ts_input; 189 - struct work_struct ts_work; 190 189 191 190 enum mxs_lradc_id soc; 192 191 enum lradc_ts_plate cur_plate; /* statemachine */ ··· 828 829 .driver_module = THIS_MODULE, 829 830 .read_raw = mxs_lradc_read_raw, 830 831 }; 831 - 832 - static int mxs_lradc_ts_touched(struct mxs_lradc *lradc) 833 - { 834 - uint32_t reg; 835 - 836 - /* Enable touch detection. */ 837 - mxs_lradc_reg_clear(lradc, mxs_lradc_plate_mask(lradc), LRADC_CTRL0); 838 - mxs_lradc_reg_set(lradc, mxs_lradc_touch_detect_bit(lradc), 839 - LRADC_CTRL0); 840 - 841 - msleep(LRADC_TS_SAMPLE_DELAY_MS); 842 - 843 - reg = readl(lradc->base + LRADC_STATUS); 844 - 845 - return reg & LRADC_STATUS_TOUCH_DETECT_RAW; 846 - } 847 - 848 - static int32_t mxs_lradc_ts_sample(struct mxs_lradc *lradc, 849 - enum lradc_ts_plate plate, int change) 850 - { 851 - unsigned long delay, jiff; 852 - uint32_t reg, ctrl0 = 0, chan = 0; 853 - /* The touchscreen always uses CTRL4 slot #7. */ 854 - const uint8_t slot = 7; 855 - uint32_t val; 856 - 857 - /* 858 - * There are three correct configurations of the controller sampling 859 - * the touchscreen, each of these configuration provides different 860 - * information from the touchscreen. 861 - * 862 - * The following table describes the sampling configurations: 863 - * +-------------+-------+-------+-------+ 864 - * | Wire \ Axis | X | Y | Z | 865 - * +---------------------+-------+-------+ 866 - * | X+ (CH2) | HI | TS | TS | 867 - * +-------------+-------+-------+-------+ 868 - * | X- (CH4) | LO | SH | HI | 869 - * +-------------+-------+-------+-------+ 870 - * | Y+ (CH3) | SH | HI | HI | 871 - * +-------------+-------+-------+-------+ 872 - * | Y- (CH5) | TS | LO | SH | 873 - * +-------------+-------+-------+-------+ 874 - * 875 - * HI ... strong '1' ; LO ... strong '0' 876 - * SH ... sample here ; TS ... tri-state 877 - * 878 - * There are a few other ways of obtaining the Z coordinate 879 - * (aka. pressure), but the one in the table seems to be the 880 - * most reliable one. 881 - */ 882 - switch (plate) { 883 - case LRADC_SAMPLE_X: 884 - ctrl0 = mxs_lradc_drive_x_plate(lradc); 885 - chan = 3; 886 - break; 887 - case LRADC_SAMPLE_Y: 888 - ctrl0 = mxs_lradc_drive_y_plate(lradc); 889 - chan = 4; 890 - break; 891 - case LRADC_SAMPLE_PRESSURE: 892 - ctrl0 = mxs_lradc_drive_pressure(lradc); 893 - chan = 5; 894 - break; 895 - } 896 - 897 - if (change) { 898 - mxs_lradc_reg_clear(lradc, mxs_lradc_plate_mask(lradc), 899 - LRADC_CTRL0); 900 - mxs_lradc_reg_set(lradc, ctrl0, LRADC_CTRL0); 901 - 902 - mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(slot), 903 - LRADC_CTRL4); 904 - mxs_lradc_reg_set(lradc, 905 - chan << LRADC_CTRL4_LRADCSELECT_OFFSET(slot), 906 - LRADC_CTRL4); 907 - } 908 - 909 - mxs_lradc_reg_clear(lradc, 0xffffffff, LRADC_CH(slot)); 910 - mxs_lradc_reg_set(lradc, 1 << slot, LRADC_CTRL0); 911 - 912 - delay = jiffies + msecs_to_jiffies(LRADC_TS_SAMPLE_DELAY_MS); 913 - do { 914 - jiff = jiffies; 915 - reg = readl_relaxed(lradc->base + LRADC_CTRL1); 916 - if (reg & LRADC_CTRL1_LRADC_IRQ(slot)) 917 - break; 918 - } while (time_before(jiff, delay)); 919 - 920 - mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(slot), LRADC_CTRL1); 921 - 922 - if (time_after_eq(jiff, delay)) 923 - return -ETIMEDOUT; 924 - 925 - val = readl(lradc->base + LRADC_CH(slot)); 926 - val &= LRADC_CH_VALUE_MASK; 927 - 928 - return val; 929 - } 930 - 931 - static int32_t mxs_lradc_ts_sample_filter(struct mxs_lradc *lradc, 932 - enum lradc_ts_plate plate) 933 - { 934 - int32_t val, tot = 0; 935 - int i; 936 - 937 - val = mxs_lradc_ts_sample(lradc, plate, 1); 938 - 939 - /* Delay a bit so the touchscreen is stable. */ 940 - mdelay(2); 941 - 942 - for (i = 0; i < LRADC_TS_SAMPLE_AMOUNT; i++) { 943 - val = mxs_lradc_ts_sample(lradc, plate, 0); 944 - tot += val; 945 - } 946 - 947 - return tot / LRADC_TS_SAMPLE_AMOUNT; 948 - } 949 - 950 - static void mxs_lradc_ts_work(struct work_struct *ts_work) 951 - { 952 - struct mxs_lradc *lradc = container_of(ts_work, 953 - struct mxs_lradc, ts_work); 954 - int val_x, val_y, val_p; 955 - bool valid = false; 956 - 957 - while (mxs_lradc_ts_touched(lradc)) { 958 - /* Disable touch detector so we can sample the touchscreen. */ 959 - mxs_lradc_reg_clear(lradc, mxs_lradc_touch_detect_bit(lradc), 960 - LRADC_CTRL0); 961 - 962 - if (likely(valid)) { 963 - input_report_abs(lradc->ts_input, ABS_X, val_x); 964 - input_report_abs(lradc->ts_input, ABS_Y, val_y); 965 - input_report_abs(lradc->ts_input, ABS_PRESSURE, val_p); 966 - input_report_key(lradc->ts_input, BTN_TOUCH, 1); 967 - input_sync(lradc->ts_input); 968 - } 969 - 970 - valid = false; 971 - 972 - val_x = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_X); 973 - if (val_x < 0) 974 - continue; 975 - val_y = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_Y); 976 - if (val_y < 0) 977 - continue; 978 - val_p = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_PRESSURE); 979 - if (val_p < 0) 980 - continue; 981 - 982 - valid = true; 983 - } 984 - 985 - input_report_abs(lradc->ts_input, ABS_PRESSURE, 0); 986 - input_report_key(lradc->ts_input, BTN_TOUCH, 0); 987 - input_sync(lradc->ts_input); 988 - 989 - /* Restart the touchscreen interrupts. */ 990 - mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ, LRADC_CTRL1); 991 - mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); 992 - } 993 832 994 833 static int mxs_lradc_ts_open(struct input_dev *dev) 995 834 {