aboutsummaryrefslogtreecommitdiff
path: root/block/bsg.c
AgeCommit message (Expand)AuthorFilesLines
2015-02-04block: Simplify bsg complete allPeter Zijlstra1-47/+25
2014-08-29bsg: fix potential error pointer dereferenceJens Axboe1-0/+1
2014-08-28block,scsi: fixup blk_get_request dead queue scenariosJoe Lawrence1-4/+4
2014-06-06block: add blk_rq_set_block_pc()Jens Axboe1-1/+2
2014-04-16bsg: update check for rq based driver for blk-mqJens Axboe1-1/+1
2013-02-27hlist: drop the node parameter from iteratorsSasha Levin1-2/+1
2013-02-27block: convert to idr_alloc()Tejun Heo1-17/+9
2012-02-08bsg: fix sysfs link remove warningStanislaw Gruszka1-1/+2
2012-01-15Merge branch 'for-3.3/core' of git://git.kernel.dk/linux-blockLinus Torvalds1-3/+1
2012-01-03switch device_get_devnode() and ->devnode() to umode_t *Al Viro1-1/+1
2011-12-14block: misc updates to blk_get_queue()Tejun Heo1-3/+1
2011-06-20bsg: fix address space warning from sparseNamhyung Kim1-6/+6
2011-06-20bsg: remove unnecessary conditional expressionsNamhyung Kim1-2/+2
2011-06-20bsg: fix bsg_poll() to return POLLOUT properlyNamhyung Kim1-1/+1
2010-12-09[SCSI] bsg: correct fault if queue object removed while dev_t openJames Smart1-0/+8
2010-10-22Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bklLinus Torvalds1-0/+1
2010-10-22Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bklLinus Torvalds1-3/+0
2010-10-15[SCSI] bsg: fix incorrect device_status valueFUJITA Tomonori1-1/+1
2010-10-15llseek: automatically add .llseek fopArnd Bergmann1-0/+1
2010-10-05block: autoconvert trivial BKL users to private mutexArnd Bergmann1-3/+0
2010-03-30include cleanup: Update gfp.h and slab.h includes to prepare for breaking imp...Tejun Heo1-0/+1
2010-02-09tree-wide: Assorted spelling fixesDaniel Mack1-1/+1
2009-11-11block: jiffies fixesRandy Dunlap1-1/+2
2009-09-19Driver-Core: extend devnode callbacks to provide permissionsKay Sievers1-2/+2
2009-07-01block: get rid of queue-private command filterJens Axboe1-1/+1
2009-06-21block: revert "bsg: setting rq->bio to NULL"FUJITA Tomonori1-3/+0
2009-06-15Driver Core: bsg: add nodename for bsg driverKay Sievers1-0/+6
2009-06-11Merge branch 'for-2.6.31' of git://git.kernel.dk/linux-2.6-blockLinus Torvalds1-4/+4
2009-06-09bsg: setting rq->bio to NULLFUJITA Tomonori1-0/+3
2009-05-11block: add rq->resid_lenTejun Heo1-4/+4
2009-03-26bsg: Remove bogus check against request_queue->max_sectorsBoaz Harrosh1-3/+0
2009-03-24bsg: add support for tail queuingBoaz Harrosh1-2/+7
2009-02-18bsg: Fix sense buffer bug in SG_IOBoaz Harrosh1-7/+10
2009-01-06block: struct device - replace bus_id with dev_name(), dev_set_name()Kay Sievers1-3/+3
2008-12-05Enforce a minimum SG_IO timeoutLinus Torvalds1-0/+2
2008-10-21[PATCH] switch scsi_cmd_ioctl() to passing fmode_tAl Viro1-1/+1
2008-10-21[PATCH] introduce fmode_t, do annotationsAl Viro1-3/+4
2008-10-16device create: block: convert device_create_drvdata to device_createGreg Kroah-Hartman1-2/+1
2008-10-09block: introduce struct rq_map_data to use reserved pagesFUJITA Tomonori1-3/+4
2008-10-09block: add gfp_mask argument to blk_rq_map_user and blk_rq_map_user_iovFUJITA Tomonori1-2/+3
2008-08-27block: move cmdfilter from gendisk to request_queueFUJITA Tomonori1-33/+11
2008-07-21device create: block: convert device_create to device_create_drvdataGreg Kroah-Hartman1-1/+2
2008-07-15Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6Linus Torvalds1-3/+6
2008-07-14Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6Linus Torvalds1-1/+6
2008-07-14Merge commit 'v2.6.26' into bkl-removalJonathan Corbet1-1/+2
2008-07-14Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-blockLinus Torvalds1-11/+27
2008-07-12[SCSI] bsg: fix oops on removeJames Bottomley1-1/+2
2008-07-12[SCSI] bsg: fix bsg_mutex hang with device removalFUJITA Tomonori1-3/+6
2008-07-03allow userspace to modify scsi command filter on per device basisAdel Gadllah1-11/+27
2008-05-18bsg: cdev lock_kernel() pushdownJonathan Corbet1-1/+6
16' href='#n516'>516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/crc-ccitt.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/ihex.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/unaligned.h>

#define ILI2XXX_POLL_PERIOD	15

#define ILI210X_DATA_SIZE	64
#define ILI211X_DATA_SIZE	43
#define ILI251X_DATA_SIZE1	31
#define ILI251X_DATA_SIZE2	20

/* Touchscreen commands */
#define REG_TOUCHDATA		0x10
#define REG_PANEL_INFO		0x20
#define REG_FIRMWARE_VERSION	0x40
#define REG_PROTOCOL_VERSION	0x42
#define REG_KERNEL_VERSION	0x61
#define REG_IC_BUSY		0x80
#define REG_IC_BUSY_NOT_BUSY	0x50
#define REG_GET_MODE		0xc0
#define REG_GET_MODE_AP		0x5a
#define REG_GET_MODE_BL		0x55
#define REG_SET_MODE_AP		0xc1
#define REG_SET_MODE_BL		0xc2
#define REG_WRITE_DATA		0xc3
#define REG_WRITE_ENABLE	0xc4
#define REG_READ_DATA_CRC	0xc7
#define REG_CALIBRATE		0xcc

#define ILI251X_FW_FILENAME	"ilitek/ili251x.bin"

struct ili2xxx_chip {
	int (*read_reg)(struct i2c_client *client, u8 reg,
			void *buf, size_t len);
	int (*get_touch_data)(struct i2c_client *client, u8 *data);
	bool (*parse_touch_data)(const u8 *data, unsigned int finger,
				 unsigned int *x, unsigned int *y,
				 unsigned int *z);
	bool (*continue_polling)(const u8 *data, bool touch);
	unsigned int max_touches;
	unsigned int resolution;
	bool has_calibrate_reg;
	bool has_firmware_proto;
	bool has_pressure_reg;
};

struct ili210x {
	struct i2c_client *client;
	struct input_dev *input;
	struct gpio_desc *reset_gpio;
	struct touchscreen_properties prop;
	const struct ili2xxx_chip *chip;
	u8 version_firmware[8];
	u8 version_kernel[5];
	u8 version_proto[2];
	u8 ic_mode[2];
	bool stop;
};

static int ili210x_read_reg(struct i2c_client *client,
			    u8 reg, void *buf, size_t len)
{
	struct i2c_msg msg[] = {
		{
			.addr	= client->addr,
			.flags	= 0,
			.len	= 1,
			.buf	= &reg,
		},
		{
			.addr	= client->addr,
			.flags	= I2C_M_RD,
			.len	= len,
			.buf	= buf,
		}
	};
	int error, ret;

	ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
	if (ret != ARRAY_SIZE(msg)) {
		error = ret < 0 ? ret : -EIO;
		dev_err(&client->dev, "%s failed: %d\n", __func__, error);
		return error;
	}

	return 0;
}

static int ili210x_read_touch_data(struct i2c_client *client, u8 *data)
{
	return ili210x_read_reg(client, REG_TOUCHDATA,
				data, ILI210X_DATA_SIZE);
}

static bool ili210x_touchdata_to_coords(const u8 *touchdata,
					unsigned int finger,
					unsigned int *x, unsigned int *y,
					unsigned int *z)
{
	if (!(touchdata[0] & BIT(finger)))
		return false;

	*x = get_unaligned_be16(touchdata + 1 + (finger * 4) + 0);
	*y = get_unaligned_be16(touchdata + 1 + (finger * 4) + 2);

	return true;
}

static bool ili210x_check_continue_polling(const u8