···11+Samsung tm2-touchkey22+33+Required properties:44+- compatible: must be "cypress,tm2-touchkey"55+- reg: I2C address of the chip.66+- interrupt-parent: a phandle for the interrupt controller (see interrupt77+ binding[0]).88+- interrupts: interrupt to which the chip is connected (see interrupt99+ binding[0]).1010+- vcc-supply : internal regulator output. 1.8V1111+- vdd-supply : power supply for IC 3.3V1212+1313+[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt1414+1515+Example:1616+ &i2c0 {1717+ /* ... */1818+1919+ touchkey@20 {2020+ compatible = "cypress,tm2-touchkey";2121+ reg = <0x20>;2222+ interrupt-parent = <&gpa3>;2323+ interrupts = <2 IRQ_TYPE_EDGE_FALLING>;2424+ vcc-supply=<&ldo32_reg>;2525+ vdd-supply=<&ldo33_reg>;2626+ };2727+ };
···11+* Freescale MPR121 Controllor22+33+Required Properties:44+- compatible: Should be "fsl,mpr121-touchkey"55+- reg: The I2C slave address of the device.66+- interrupts: The interrupt number to the cpu.77+- vdd-supply: Phandle to the Vdd power supply.88+- linux,keycodes: Specifies an array of numeric keycode values to99+ be used for reporting button presses. The array can1010+ contain up to 12 entries.1111+1212+Optional Properties:1313+- wakeup-source: Use any event on keypad as wakeup event.1414+- autorepeat: Enable autorepeat feature.1515+1616+Example:1717+1818+#include "dt-bindings/input/input.h"1919+2020+ touchkey: mpr121@5a {2121+ compatible = "fsl,mpr121-touchkey";2222+ reg = <0x5a>;2323+ interrupt-parent = <&gpio1>;2424+ interrupts = <28 2>;2525+ autorepeat;2626+ vdd-supply = <&ldo4_reg>;2727+ linux,keycodes = <KEY_0>, <KEY_1>, <KEY_2>, <KEY_3>,2828+ <KEY_4> <KEY_5>, <KEY_6>, <KEY_7>,2929+ <KEY_8>, <KEY_9>, <KEY_A>, <KEY_B>;3030+ };
···55Required properties:66- compatible: should be "pwm-beeper"77- pwms: phandle to the physical PWM device88+99+Optional properties:1010+- amp-supply: phandle to a regulator that acts as an amplifier for the beeper1111+1212+Example:1313+1414+beeper_amp: amplifier {1515+ compatible = "fixed-regulator";1616+ gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;1717+};1818+1919+beeper {2020+ compatible = "pwm-beeper";2121+ pwms = <&pwm0>;2222+ amp-supply = <&beeper_amp>;2323+};
···94949595config INPUT_MOUSEDEV9696 tristate "Mouse interface"9797- default y9897 help9998 Say Y here if you want your mouse to be accessible as char devices10099 13:32+ - /dev/input/mouseX and 13:63 - /dev/input/mice as an···108109109110config INPUT_MOUSEDEV_PSAUX110111 bool "Provide legacy /dev/psaux device"111111- default y112112 depends on INPUT_MOUSEDEV113113 help114114 Say Y here if you want your mouse also be accessible as char device···115117 the same as the data from /dev/input/mice.116118117119 If unsure, say Y.118118-119120120121config INPUT_MOUSEDEV_SCREEN_X121122 int "Horizontal screen resolution"
+7-1
drivers/input/input.c
···17491749};17501750#endif /* CONFIG_PM */1751175117521752-static struct device_type input_dev_type = {17521752+static const struct device_type input_dev_type = {17531753 .groups = input_dev_attr_groups,17541754 .release = input_dev_release,17551755 .uevent = input_dev_uevent,···20902090 unsigned int packet_size;20912091 const char *path;20922092 int error;20932093+20942094+ if (test_bit(EV_ABS, dev->evbit) && !dev->absinfo) {20952095+ dev_err(&dev->dev,20962096+ "Absolute device without dev->absinfo, refusing to register\n");20972097+ return -EINVAL;20982098+ }2093209920942100 if (dev->devres_managed) {20952101 devres = devres_alloc(devm_input_device_unregister,
···320320 XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */321321 XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */322322 XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */323323+ XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */324324+ XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */323325 XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */324326 XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */325327 XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */326326- XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */327327- XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */328328- XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */329329- XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */330330- XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */331331- XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */332328 XPAD_XBOX360_VENDOR(0x1532), /* Razer Sabertooth */333329 XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */334330 XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */331331+ XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */332332+ XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */333333+ XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */334334+ XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */335335 { }336336};337337···389389390390static int xpad_init_input(struct usb_xpad *xpad);391391static void xpad_deinit_input(struct usb_xpad *xpad);392392+static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num);392393393394/*394395 * xpad_process_packet···609608}610609611610/*612612- * xpadone_process_buttons611611+ * xpadone_process_packet613612 *614614- * Process a button update packet from an Xbox one controller.613613+ * Completes a request by converting the data into events for the614614+ * input subsystem. This version is for the Xbox One controller.615615+ *616616+ * The report format was gleaned from617617+ * https://github.com/kylelemons/xbox/blob/master/xbox.go615618 */616616-static void xpadone_process_buttons(struct usb_xpad *xpad,617617- struct input_dev *dev,618618- unsigned char *data)619619+static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)619620{621621+ struct input_dev *dev = xpad->dev;622622+623623+ /* the xbox button has its own special report */624624+ if (data[0] == 0X07) {625625+ /*626626+ * The Xbox One S controller requires these reports to be627627+ * acked otherwise it continues sending them forever and628628+ * won't report further mode button events.629629+ */630630+ if (data[1] == 0x30)631631+ xpadone_ack_mode_report(xpad, data[2]);632632+633633+ input_report_key(dev, BTN_MODE, data[4] & 0x01);634634+ input_sync(dev);635635+ return;636636+ }637637+ /* check invalid packet */638638+ else if (data[0] != 0X20)639639+ return;640640+620641 /* menu/view buttons */621642 input_report_key(dev, BTN_START, data[4] & 0x04);622643 input_report_key(dev, BTN_SELECT, data[4] & 0x08);···699676 }700677701678 input_sync(dev);702702-}703703-704704-/*705705- * xpadone_process_packet706706- *707707- * Completes a request by converting the data into events for the708708- * input subsystem. This version is for the Xbox One controller.709709- *710710- * The report format was gleaned from711711- * https://github.com/kylelemons/xbox/blob/master/xbox.go712712- */713713-714714-static void xpadone_process_packet(struct usb_xpad *xpad,715715- u16 cmd, unsigned char *data)716716-{717717- struct input_dev *dev = xpad->dev;718718-719719- switch (data[0]) {720720- case 0x20:721721- xpadone_process_buttons(xpad, dev, data);722722- break;723723-724724- case 0x07:725725- /* the xbox button has its own special report */726726- input_report_key(dev, BTN_MODE, data[4] & 0x01);727727- input_sync(dev);728728- break;729729- }730679}731680732681static void xpad_irq_in(struct urb *urb)···845850 spin_unlock_irqrestore(&xpad->odata_lock, flags);846851}847852848848-static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)853853+static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad,854854+ struct usb_endpoint_descriptor *ep_irq_out)849855{850850- struct usb_endpoint_descriptor *ep_irq_out;851851- int ep_irq_out_idx;852856 int error;853857854858 if (xpad->xtype == XTYPE_UNKNOWN)···857863858864 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN,859865 GFP_KERNEL, &xpad->odata_dma);860860- if (!xpad->odata) {861861- error = -ENOMEM;862862- goto fail1;863863- }866866+ if (!xpad->odata)867867+ return -ENOMEM;864868865869 spin_lock_init(&xpad->odata_lock);866870867871 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL);868872 if (!xpad->irq_out) {869873 error = -ENOMEM;870870- goto fail2;874874+ goto err_free_coherent;871875 }872872-873873- /* Xbox One controller has in/out endpoints swapped. */874874- ep_irq_out_idx = xpad->xtype == XTYPE_XBOXONE ? 0 : 1;875875- ep_irq_out = &intf->cur_altsetting->endpoint[ep_irq_out_idx].desc;876876877877 usb_fill_int_urb(xpad->irq_out, xpad->udev,878878 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress),···877889878890 return 0;879891880880- fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);881881- fail1: return error;892892+err_free_coherent:893893+ usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);894894+ return error;882895}883896884897static void xpad_stop_output(struct usb_xpad *xpad)···961972 spin_unlock_irqrestore(&xpad->odata_lock, flags);962973963974 return retval;975975+}976976+977977+static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num)978978+{979979+ unsigned long flags;980980+ struct xpad_output_packet *packet =981981+ &xpad->out_packets[XPAD_OUT_CMD_IDX];982982+ static const u8 mode_report_ack[] = {983983+ 0x01, 0x20, 0x00, 0x09, 0x00, 0x07, 0x20, 0x02,984984+ 0x00, 0x00, 0x00, 0x00, 0x00985985+ };986986+987987+ spin_lock_irqsave(&xpad->odata_lock, flags);988988+989989+ packet->len = sizeof(mode_report_ack);990990+ memcpy(packet->data, mode_report_ack, packet->len);991991+ packet->data[2] = seq_num;992992+ packet->pending = true;993993+994994+ /* Reset the sequence so we send out the ack now */995995+ xpad->last_out_packet = -1;996996+ xpad_try_sending_next_out_packet(xpad);997997+998998+ spin_unlock_irqrestore(&xpad->odata_lock, flags);964999}96510009661001#ifdef CONFIG_JOYSTICK_XPAD_FF···12111198 led_cdev = &led->led_cdev;12121199 led_cdev->name = led->name;12131200 led_cdev->brightness_set = xpad_led_set;12011201+ led_cdev->flags = LED_CORE_SUSPENDRESUME;1214120212151203 error = led_classdev_register(&xpad->udev->dev, led_cdev);12161204 if (error)···14821468{14831469 struct usb_device *udev = interface_to_usbdev(intf);14841470 struct usb_xpad *xpad;14851485- struct usb_endpoint_descriptor *ep_irq_in;14861486- int ep_irq_in_idx;14711471+ struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out;14871472 int i, error;1488147314891474 if (intf->cur_altsetting->desc.bNumEndpoints != 2)···15521539 goto err_free_in_urb;15531540 }1554154115551555- error = xpad_init_output(intf, xpad);15421542+ ep_irq_in = ep_irq_out = NULL;15431543+15441544+ for (i = 0; i < 2; i++) {15451545+ struct usb_endpoint_descriptor *ep =15461546+ &intf->cur_altsetting->endpoint[i].desc;15471547+15481548+ if (usb_endpoint_dir_in(ep))15491549+ ep_irq_in = ep;15501550+ else15511551+ ep_irq_out = ep;15521552+ }15531553+15541554+ if (!ep_irq_in || !ep_irq_out) {15551555+ error = -ENODEV;15561556+ goto err_free_in_urb;15571557+ }15581558+15591559+ error = xpad_init_output(intf, xpad, ep_irq_out);15561560 if (error)15571561 goto err_free_in_urb;15581558-15591559- /* Xbox One controller has in/out endpoints swapped. */15601560- ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0;15611561- ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc;1562156215631563 usb_fill_int_urb(xpad->irq_in, udev,15641564 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),···16881662 retval = xpad360w_start_input(xpad);16891663 } else {16901664 mutex_lock(&input->mutex);16911691- if (input->users)16651665+ if (input->users) {16921666 retval = xpad_start_input(xpad);16671667+ } else if (xpad->xtype == XTYPE_XBOXONE) {16681668+ /*16691669+ * Even if there are no users, we'll send Xbox One pads16701670+ * the startup sequence so they don't sit there and16711671+ * blink until somebody opens the input device again.16721672+ */16731673+ retval = xpad_start_xbox_one(xpad);16741674+ }16931675 mutex_unlock(&input->mutex);16941676 }16951677
+11
drivers/input/keyboard/Kconfig
···666666 To compile this driver as a module, choose M here: the667667 module will be called tc3589x-keypad.668668669669+config KEYBOARD_TM2_TOUCHKEY670670+ tristate "TM2 touchkey support"671671+ depends on I2C672672+ depends on LEDS_CLASS673673+ help674674+ Say Y here to enable device driver for tm2-touchkey with675675+ LED control for the Exynos5433 TM2 board.676676+677677+ To compile this driver as a module, choose M here.678678+ module will be called tm2-touchkey.679679+669680config KEYBOARD_TWL4030670681 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"671682 depends on TWL4030_CORE
···3434#include <linux/mfd/cros_ec.h>3535#include <linux/mfd/cros_ec_commands.h>36363737+#include <asm/unaligned.h>3838+3739/*3840 * @rows: Number of rows in the keypad3941 * @cols: Number of columns in the keypad···4543 * @valid_keys: bitmap of existing keys for each matrix column4644 * @old_kb_state: bitmap of keys pressed last scan4745 * @dev: Device pointer4848- * @idev: Input device4946 * @ec: Top level ChromeOS device to use to talk to EC4747+ * @idev: The input device for the matrix keys.4848+ * @bs_idev: The input device for non-matrix buttons and switches (or NULL).5049 * @notifier: interrupt event notifier for transport devices5150 */5251struct cros_ec_keyb {···6057 uint8_t *old_kb_state;61586259 struct device *dev;6363- struct input_dev *idev;6460 struct cros_ec_device *ec;6161+6262+ struct input_dev *idev;6363+ struct input_dev *bs_idev;6564 struct notifier_block notifier;6665};67666767+6868+/**6969+ * cros_ec_bs_map - Struct mapping Linux keycodes to EC button/switch bitmap7070+ * #defines7171+ *7272+ * @ev_type: The type of the input event to generate (e.g., EV_KEY).7373+ * @code: A linux keycode7474+ * @bit: A #define like EC_MKBP_POWER_BUTTON or EC_MKBP_LID_OPEN7575+ * @inverted: If the #define and EV_SW have opposite meanings, this is true.7676+ * Only applicable to switches.7777+ */7878+struct cros_ec_bs_map {7979+ unsigned int ev_type;8080+ unsigned int code;8181+ u8 bit;8282+ bool inverted;8383+};8484+8585+/* cros_ec_keyb_bs - Map EC button/switch #defines into kernel ones */8686+static const struct cros_ec_bs_map cros_ec_keyb_bs[] = {8787+ /* Buttons */8888+ {8989+ .ev_type = EV_KEY,9090+ .code = KEY_POWER,9191+ .bit = EC_MKBP_POWER_BUTTON,9292+ },9393+ {9494+ .ev_type = EV_KEY,9595+ .code = KEY_VOLUMEUP,9696+ .bit = EC_MKBP_VOL_UP,9797+ },9898+ {9999+ .ev_type = EV_KEY,100100+ .code = KEY_VOLUMEDOWN,101101+ .bit = EC_MKBP_VOL_DOWN,102102+ },103103+104104+ /* Switches */105105+ {106106+ .ev_type = EV_SW,107107+ .code = SW_LID,108108+ .bit = EC_MKBP_LID_OPEN,109109+ .inverted = true,110110+ },111111+ {112112+ .ev_type = EV_SW,113113+ .code = SW_TABLET_MODE,114114+ .bit = EC_MKBP_TABLET_MODE,115115+ },116116+};6811769118/*70119 * Returns true when there is at least one combination of pressed keys that···204149 input_sync(ckdev->idev);205150}206151207207-static int cros_ec_keyb_open(struct input_dev *dev)152152+/**153153+ * cros_ec_keyb_report_bs - Report non-matrixed buttons or switches154154+ *155155+ * This takes a bitmap of buttons or switches from the EC and reports events,156156+ * syncing at the end.157157+ *158158+ * @ckdev: The keyboard device.159159+ * @ev_type: The input event type (e.g., EV_KEY).160160+ * @mask: A bitmap of buttons from the EC.161161+ */162162+static void cros_ec_keyb_report_bs(struct cros_ec_keyb *ckdev,163163+ unsigned int ev_type, u32 mask)164164+208165{209209- struct cros_ec_keyb *ckdev = input_get_drvdata(dev);166166+ struct input_dev *idev = ckdev->bs_idev;167167+ int i;210168211211- return blocking_notifier_chain_register(&ckdev->ec->event_notifier,212212- &ckdev->notifier);213213-}169169+ for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) {170170+ const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i];214171215215-static void cros_ec_keyb_close(struct input_dev *dev)216216-{217217- struct cros_ec_keyb *ckdev = input_get_drvdata(dev);172172+ if (map->ev_type != ev_type)173173+ continue;218174219219- blocking_notifier_chain_unregister(&ckdev->ec->event_notifier,220220- &ckdev->notifier);175175+ input_event(idev, ev_type, map->code,176176+ !!(mask & BIT(map->bit)) ^ map->inverted);177177+ }178178+ input_sync(idev);221179}222180223181static int cros_ec_keyb_work(struct notifier_block *nb,···238170{239171 struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb,240172 notifier);173173+ u32 val;174174+ unsigned int ev_type;241175242242- if (ckdev->ec->event_data.event_type != EC_MKBP_EVENT_KEY_MATRIX)176176+ switch (ckdev->ec->event_data.event_type) {177177+ case EC_MKBP_EVENT_KEY_MATRIX:178178+ /*179179+ * If EC is not the wake source, discard key state changes180180+ * during suspend.181181+ */182182+ if (queued_during_suspend)183183+ return NOTIFY_OK;184184+185185+ if (ckdev->ec->event_size != ckdev->cols) {186186+ dev_err(ckdev->dev,187187+ "Discarded incomplete key matrix event.\n");188188+ return NOTIFY_OK;189189+ }190190+ cros_ec_keyb_process(ckdev,191191+ ckdev->ec->event_data.data.key_matrix,192192+ ckdev->ec->event_size);193193+ break;194194+195195+ case EC_MKBP_EVENT_BUTTON:196196+ case EC_MKBP_EVENT_SWITCH:197197+ /*198198+ * If EC is not the wake source, discard key state199199+ * changes during suspend. Switches will be re-checked in200200+ * cros_ec_keyb_resume() to be sure nothing is lost.201201+ */202202+ if (queued_during_suspend)203203+ return NOTIFY_OK;204204+205205+ if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {206206+ val = get_unaligned_le32(207207+ &ckdev->ec->event_data.data.buttons);208208+ ev_type = EV_KEY;209209+ } else {210210+ val = get_unaligned_le32(211211+ &ckdev->ec->event_data.data.switches);212212+ ev_type = EV_SW;213213+ }214214+ cros_ec_keyb_report_bs(ckdev, ev_type, val);215215+ break;216216+217217+ default:243218 return NOTIFY_DONE;244244- /*245245- * If EC is not the wake source, discard key state changes during246246- * suspend.247247- */248248- if (queued_during_suspend)249249- return NOTIFY_OK;250250- if (ckdev->ec->event_size != ckdev->cols) {251251- dev_err(ckdev->dev,252252- "Discarded incomplete key matrix event.\n");253253- return NOTIFY_OK;254219 }255255- cros_ec_keyb_process(ckdev, ckdev->ec->event_data.data.key_matrix,256256- ckdev->ec->event_size);220220+257221 return NOTIFY_OK;258222}259223···313213 }314214}315215316316-static int cros_ec_keyb_probe(struct platform_device *pdev)216216+/**217217+ * cros_ec_keyb_info - Wrap the EC command EC_CMD_MKBP_INFO218218+ *219219+ * This wraps the EC_CMD_MKBP_INFO, abstracting out all of the marshalling and220220+ * unmarshalling and different version nonsense into something simple.221221+ *222222+ * @ec_dev: The EC device223223+ * @info_type: Either EC_MKBP_INFO_SUPPORTED or EC_MKBP_INFO_CURRENT.224224+ * @event_type: Either EC_MKBP_EVENT_BUTTON or EC_MKBP_EVENT_SWITCH. Actually225225+ * in some cases this could be EC_MKBP_EVENT_KEY_MATRIX or226226+ * EC_MKBP_EVENT_HOST_EVENT too but we don't use in this driver.227227+ * @result: Where we'll store the result; a union228228+ * @result_size: The size of the result. Expected to be the size of one of229229+ * the elements in the union.230230+ *231231+ * Returns 0 if no error or -error upon error.232232+ */233233+static int cros_ec_keyb_info(struct cros_ec_device *ec_dev,234234+ enum ec_mkbp_info_type info_type,235235+ enum ec_mkbp_event event_type,236236+ union ec_response_get_next_data *result,237237+ size_t result_size)317238{318318- struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent);319319- struct device *dev = &pdev->dev;320320- struct cros_ec_keyb *ckdev;239239+ struct ec_params_mkbp_info *params;240240+ struct cros_ec_command *msg;241241+ int ret;242242+243243+ msg = kzalloc(sizeof(*msg) + max_t(size_t, result_size,244244+ sizeof(*params)), GFP_KERNEL);245245+ if (!msg)246246+ return -ENOMEM;247247+248248+ msg->command = EC_CMD_MKBP_INFO;249249+ msg->version = 1;250250+ msg->outsize = sizeof(*params);251251+ msg->insize = result_size;252252+ params = (struct ec_params_mkbp_info *)msg->data;253253+ params->info_type = info_type;254254+ params->event_type = event_type;255255+256256+ ret = cros_ec_cmd_xfer(ec_dev, msg);257257+ if (ret < 0) {258258+ dev_warn(ec_dev->dev, "Transfer error %d/%d: %d\n",259259+ (int)info_type, (int)event_type, ret);260260+ } else if (msg->result == EC_RES_INVALID_VERSION) {261261+ /* With older ECs we just return 0 for everything */262262+ memset(result, 0, result_size);263263+ ret = 0;264264+ } else if (msg->result != EC_RES_SUCCESS) {265265+ dev_warn(ec_dev->dev, "Error getting info %d/%d: %d\n",266266+ (int)info_type, (int)event_type, msg->result);267267+ ret = -EPROTO;268268+ } else if (ret != result_size) {269269+ dev_warn(ec_dev->dev, "Wrong size %d/%d: %d != %zu\n",270270+ (int)info_type, (int)event_type,271271+ ret, result_size);272272+ ret = -EPROTO;273273+ } else {274274+ memcpy(result, msg->data, result_size);275275+ ret = 0;276276+ }277277+278278+ kfree(msg);279279+280280+ return ret;281281+}282282+283283+/**284284+ * cros_ec_keyb_query_switches - Query the state of switches and report285285+ *286286+ * This will ask the EC about the current state of switches and report to the287287+ * kernel. Note that we don't query for buttons because they are more288288+ * transitory and we'll get an update on the next release / press.289289+ *290290+ * @ckdev: The keyboard device291291+ *292292+ * Returns 0 if no error or -error upon error.293293+ */294294+static int cros_ec_keyb_query_switches(struct cros_ec_keyb *ckdev)295295+{296296+ struct cros_ec_device *ec_dev = ckdev->ec;297297+ union ec_response_get_next_data event_data = {};298298+ int ret;299299+300300+ ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_CURRENT,301301+ EC_MKBP_EVENT_SWITCH, &event_data,302302+ sizeof(event_data.switches));303303+ if (ret)304304+ return ret;305305+306306+ cros_ec_keyb_report_bs(ckdev, EV_SW,307307+ get_unaligned_le32(&event_data.switches));308308+309309+ return 0;310310+}311311+312312+/**313313+ * cros_ec_keyb_resume - Resume the keyboard314314+ *315315+ * We use the resume notification as a chance to query the EC for switches.316316+ *317317+ * @dev: The keyboard device318318+ *319319+ * Returns 0 if no error or -error upon error.320320+ */321321+static __maybe_unused int cros_ec_keyb_resume(struct device *dev)322322+{323323+ struct cros_ec_keyb *ckdev = dev_get_drvdata(dev);324324+325325+ if (ckdev->bs_idev)326326+ return cros_ec_keyb_query_switches(ckdev);327327+328328+ return 0;329329+}330330+331331+/**332332+ * cros_ec_keyb_register_bs - Register non-matrix buttons/switches333333+ *334334+ * Handles all the bits of the keyboard driver related to non-matrix buttons335335+ * and switches, including asking the EC about which are present and telling336336+ * the kernel to expect them.337337+ *338338+ * If this device has no support for buttons and switches we'll return no error339339+ * but the ckdev->bs_idev will remain NULL when this function exits.340340+ *341341+ * @ckdev: The keyboard device342342+ *343343+ * Returns 0 if no error or -error upon error.344344+ */345345+static int cros_ec_keyb_register_bs(struct cros_ec_keyb *ckdev)346346+{347347+ struct cros_ec_device *ec_dev = ckdev->ec;348348+ struct device *dev = ckdev->dev;321349 struct input_dev *idev;322322- struct device_node *np;350350+ union ec_response_get_next_data event_data = {};351351+ const char *phys;352352+ u32 buttons;353353+ u32 switches;354354+ int ret;355355+ int i;356356+357357+ ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_SUPPORTED,358358+ EC_MKBP_EVENT_BUTTON, &event_data,359359+ sizeof(event_data.buttons));360360+ if (ret)361361+ return ret;362362+ buttons = get_unaligned_le32(&event_data.buttons);363363+364364+ ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_SUPPORTED,365365+ EC_MKBP_EVENT_SWITCH, &event_data,366366+ sizeof(event_data.switches));367367+ if (ret)368368+ return ret;369369+ switches = get_unaligned_le32(&event_data.switches);370370+371371+ if (!buttons && !switches)372372+ return 0;373373+374374+ /*375375+ * We call the non-matrix buttons/switches 'input1', if present.376376+ * Allocate phys before input dev, to ensure correct tear-down377377+ * ordering.378378+ */379379+ phys = devm_kasprintf(dev, GFP_KERNEL, "%s/input1", ec_dev->phys_name);380380+ if (!phys)381381+ return -ENOMEM;382382+383383+ idev = devm_input_allocate_device(dev);384384+ if (!idev)385385+ return -ENOMEM;386386+387387+ idev->name = "cros_ec_buttons";388388+ idev->phys = phys;389389+ __set_bit(EV_REP, idev->evbit);390390+391391+ idev->id.bustype = BUS_VIRTUAL;392392+ idev->id.version = 1;393393+ idev->id.product = 0;394394+ idev->dev.parent = dev;395395+396396+ input_set_drvdata(idev, ckdev);397397+ ckdev->bs_idev = idev;398398+399399+ for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) {400400+ const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i];401401+402402+ if (buttons & BIT(map->bit))403403+ input_set_capability(idev, map->ev_type, map->code);404404+ }405405+406406+ ret = cros_ec_keyb_query_switches(ckdev);407407+ if (ret) {408408+ dev_err(dev, "cannot query switches\n");409409+ return ret;410410+ }411411+412412+ ret = input_register_device(ckdev->bs_idev);413413+ if (ret) {414414+ dev_err(dev, "cannot register input device\n");415415+ return ret;416416+ }417417+418418+ return 0;419419+}420420+421421+/**422422+ * cros_ec_keyb_register_bs - Register matrix keys423423+ *424424+ * Handles all the bits of the keyboard driver related to matrix keys.425425+ *426426+ * @ckdev: The keyboard device427427+ *428428+ * Returns 0 if no error or -error upon error.429429+ */430430+static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev)431431+{432432+ struct cros_ec_device *ec_dev = ckdev->ec;433433+ struct device *dev = ckdev->dev;434434+ struct input_dev *idev;435435+ const char *phys;323436 int err;324437325325- np = pdev->dev.of_node;326326- if (!np)327327- return -ENODEV;328328-329329- ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL);330330- if (!ckdev)331331- return -ENOMEM;332332- err = matrix_keypad_parse_of_params(dev, &ckdev->rows, &ckdev->cols);438438+ err = matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols);333439 if (err)334440 return err;335441···547241 if (!ckdev->old_kb_state)548242 return -ENOMEM;549243244244+ /*245245+ * We call the keyboard matrix 'input0'. Allocate phys before input246246+ * dev, to ensure correct tear-down ordering.247247+ */248248+ phys = devm_kasprintf(dev, GFP_KERNEL, "%s/input0", ec_dev->phys_name);249249+ if (!phys)250250+ return -ENOMEM;251251+550252 idev = devm_input_allocate_device(dev);551253 if (!idev)552254 return -ENOMEM;553255554554- ckdev->ec = ec;555555- ckdev->notifier.notifier_call = cros_ec_keyb_work;556556- ckdev->dev = dev;557557- dev_set_drvdata(dev, ckdev);558558-559256 idev->name = CROS_EC_DEV_NAME;560560- idev->phys = ec->phys_name;257257+ idev->phys = phys;561258 __set_bit(EV_REP, idev->evbit);562259563260 idev->id.bustype = BUS_VIRTUAL;564261 idev->id.version = 1;565262 idev->id.product = 0;566263 idev->dev.parent = dev;567567- idev->open = cros_ec_keyb_open;568568- idev->close = cros_ec_keyb_close;569264570570- ckdev->ghost_filter = of_property_read_bool(np,265265+ ckdev->ghost_filter = of_property_read_bool(dev->of_node,571266 "google,needs-ghost-filter");572267573268 err = matrix_keypad_build_keymap(NULL, NULL, ckdev->rows, ckdev->cols,···594287 return 0;595288}596289290290+static int cros_ec_keyb_probe(struct platform_device *pdev)291291+{292292+ struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent);293293+ struct device *dev = &pdev->dev;294294+ struct cros_ec_keyb *ckdev;295295+ int err;296296+297297+ if (!dev->of_node)298298+ return -ENODEV;299299+300300+ ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL);301301+ if (!ckdev)302302+ return -ENOMEM;303303+304304+ ckdev->ec = ec;305305+ ckdev->dev = dev;306306+ dev_set_drvdata(dev, ckdev);307307+308308+ err = cros_ec_keyb_register_matrix(ckdev);309309+ if (err) {310310+ dev_err(dev, "cannot register matrix inputs: %d\n", err);311311+ return err;312312+ }313313+314314+ err = cros_ec_keyb_register_bs(ckdev);315315+ if (err) {316316+ dev_err(dev, "cannot register non-matrix inputs: %d\n", err);317317+ return err;318318+ }319319+320320+ ckdev->notifier.notifier_call = cros_ec_keyb_work;321321+ err = blocking_notifier_chain_register(&ckdev->ec->event_notifier,322322+ &ckdev->notifier);323323+ if (err) {324324+ dev_err(dev, "cannot register notifier: %d\n", err);325325+ return err;326326+ }327327+328328+ return 0;329329+}330330+331331+static int cros_ec_keyb_remove(struct platform_device *pdev)332332+{333333+ struct cros_ec_keyb *ckdev = dev_get_drvdata(&pdev->dev);334334+335335+ blocking_notifier_chain_unregister(&ckdev->ec->event_notifier,336336+ &ckdev->notifier);337337+338338+ return 0;339339+}340340+597341#ifdef CONFIG_OF598342static const struct of_device_id cros_ec_keyb_of_match[] = {599343 { .compatible = "google,cros-ec-keyb" },···653295MODULE_DEVICE_TABLE(of, cros_ec_keyb_of_match);654296#endif655297298298+static const SIMPLE_DEV_PM_OPS(cros_ec_keyb_pm_ops, NULL, cros_ec_keyb_resume);299299+656300static struct platform_driver cros_ec_keyb_driver = {657301 .probe = cros_ec_keyb_probe,302302+ .remove = cros_ec_keyb_remove,658303 .driver = {659304 .name = "cros-ec-keyb",660305 .of_match_table = of_match_ptr(cros_ec_keyb_of_match),306306+ .pm = &cros_ec_keyb_pm_ops,661307 },662308};663309
···234234 To compile this driver as a module, choose M here: the235235 module will be called mma8450.236236237237-config INPUT_MPU3050238238- tristate "MPU3050 Triaxial gyroscope sensor"239239- depends on I2C240240- help241241- Say Y here if you want to support InvenSense MPU3050242242- connected via an I2C bus.243243-244244- To compile this driver as a module, choose M here: the245245- module will be called mpu3050.246246-247237config INPUT_APANEL248238 tristate "Fujitsu Lifebook Application Panel buttons"249239 depends on X86 && I2C && LEDS_CLASS
···11-/*22- * MPU3050 Tri-axis gyroscope driver33- *44- * Copyright (C) 2011 Wistron Co.Ltd55- * Joseph Lai <joseph_lai@wistron.com>66- *77- * Trimmed down by Alan Cox <alan@linux.intel.com> to produce this version88- *99- * This is a 'lite' version of the driver, while we consider the right way1010- * to present the other features to user space. In particular it requires the1111- * device has an IRQ, and it only provides an input interface, so is not much1212- * use for device orientation. A fuller version is available from the Meego1313- * tree.1414- *1515- * This program is based on bma023.c.1616- *1717- * This program is free software; you can redistribute it and/or modify1818- * it under the terms of the GNU General Public License as published by1919- * the Free Software Foundation; version 2 of the License.2020- *2121- * This program is distributed in the hope that it will be useful, but2222- * WITHOUT ANY WARRANTY; without even the implied warranty of2323- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU2424- * General Public License for more details.2525- *2626- * You should have received a copy of the GNU General Public License along2727- * with this program; if not, write to the Free Software Foundation, Inc.,2828- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.2929- *3030- */3131-3232-#include <linux/module.h>3333-#include <linux/interrupt.h>3434-#include <linux/platform_device.h>3535-#include <linux/mutex.h>3636-#include <linux/err.h>3737-#include <linux/i2c.h>3838-#include <linux/input.h>3939-#include <linux/delay.h>4040-#include <linux/slab.h>4141-#include <linux/pm_runtime.h>4242-4343-#define MPU3050_CHIP_ID 0x694444-4545-#define MPU3050_AUTO_DELAY 10004646-4747-#define MPU3050_MIN_VALUE -327684848-#define MPU3050_MAX_VALUE 327674949-5050-#define MPU3050_DEFAULT_POLL_INTERVAL 2005151-#define MPU3050_DEFAULT_FS_RANGE 35252-5353-/* Register map */5454-#define MPU3050_CHIP_ID_REG 0x005555-#define MPU3050_SMPLRT_DIV 0x155656-#define MPU3050_DLPF_FS_SYNC 0x165757-#define MPU3050_INT_CFG 0x175858-#define MPU3050_XOUT_H 0x1D5959-#define MPU3050_PWR_MGM 0x3E6060-#define MPU3050_PWR_MGM_POS 66161-6262-/* Register bits */6363-6464-/* DLPF_FS_SYNC */6565-#define MPU3050_EXT_SYNC_NONE 0x006666-#define MPU3050_EXT_SYNC_TEMP 0x206767-#define MPU3050_EXT_SYNC_GYROX 0x406868-#define MPU3050_EXT_SYNC_GYROY 0x606969-#define MPU3050_EXT_SYNC_GYROZ 0x807070-#define MPU3050_EXT_SYNC_ACCELX 0xA07171-#define MPU3050_EXT_SYNC_ACCELY 0xC07272-#define MPU3050_EXT_SYNC_ACCELZ 0xE07373-#define MPU3050_EXT_SYNC_MASK 0xE07474-#define MPU3050_FS_250DPS 0x007575-#define MPU3050_FS_500DPS 0x087676-#define MPU3050_FS_1000DPS 0x107777-#define MPU3050_FS_2000DPS 0x187878-#define MPU3050_FS_MASK 0x187979-#define MPU3050_DLPF_CFG_256HZ_NOLPF2 0x008080-#define MPU3050_DLPF_CFG_188HZ 0x018181-#define MPU3050_DLPF_CFG_98HZ 0x028282-#define MPU3050_DLPF_CFG_42HZ 0x038383-#define MPU3050_DLPF_CFG_20HZ 0x048484-#define MPU3050_DLPF_CFG_10HZ 0x058585-#define MPU3050_DLPF_CFG_5HZ 0x068686-#define MPU3050_DLPF_CFG_2100HZ_NOLPF 0x078787-#define MPU3050_DLPF_CFG_MASK 0x078888-/* INT_CFG */8989-#define MPU3050_RAW_RDY_EN 0x019090-#define MPU3050_MPU_RDY_EN 0x029191-#define MPU3050_LATCH_INT_EN 0x049292-/* PWR_MGM */9393-#define MPU3050_PWR_MGM_PLL_X 0x019494-#define MPU3050_PWR_MGM_PLL_Y 0x029595-#define MPU3050_PWR_MGM_PLL_Z 0x039696-#define MPU3050_PWR_MGM_CLKSEL 0x079797-#define MPU3050_PWR_MGM_STBY_ZG 0x089898-#define MPU3050_PWR_MGM_STBY_YG 0x109999-#define MPU3050_PWR_MGM_STBY_XG 0x20100100-#define MPU3050_PWR_MGM_SLEEP 0x40101101-#define MPU3050_PWR_MGM_RESET 0x80102102-#define MPU3050_PWR_MGM_MASK 0x40103103-104104-struct axis_data {105105- s16 x;106106- s16 y;107107- s16 z;108108-};109109-110110-struct mpu3050_sensor {111111- struct i2c_client *client;112112- struct device *dev;113113- struct input_dev *idev;114114-};115115-116116-/**117117- * mpu3050_xyz_read_reg - read the axes values118118- * @buffer: provide register addr and get register119119- * @length: length of register120120- *121121- * Reads the register values in one transaction or returns a negative122122- * error code on failure.123123- */124124-static int mpu3050_xyz_read_reg(struct i2c_client *client,125125- u8 *buffer, int length)126126-{127127- /*128128- * Annoying we can't make this const because the i2c layer doesn't129129- * declare input buffers const.130130- */131131- char cmd = MPU3050_XOUT_H;132132- struct i2c_msg msg[] = {133133- {134134- .addr = client->addr,135135- .flags = 0,136136- .len = 1,137137- .buf = &cmd,138138- },139139- {140140- .addr = client->addr,141141- .flags = I2C_M_RD,142142- .len = length,143143- .buf = buffer,144144- },145145- };146146-147147- return i2c_transfer(client->adapter, msg, 2);148148-}149149-150150-/**151151- * mpu3050_read_xyz - get co-ordinates from device152152- * @client: i2c address of sensor153153- * @coords: co-ordinates to update154154- *155155- * Return the converted X Y and Z co-ordinates from the sensor device156156- */157157-static void mpu3050_read_xyz(struct i2c_client *client,158158- struct axis_data *coords)159159-{160160- u16 buffer[3];161161-162162- mpu3050_xyz_read_reg(client, (u8 *)buffer, 6);163163- coords->x = be16_to_cpu(buffer[0]);164164- coords->y = be16_to_cpu(buffer[1]);165165- coords->z = be16_to_cpu(buffer[2]);166166- dev_dbg(&client->dev, "%s: x %d, y %d, z %d\n", __func__,167167- coords->x, coords->y, coords->z);168168-}169169-170170-/**171171- * mpu3050_set_power_mode - set the power mode172172- * @client: i2c client for the sensor173173- * @val: value to switch on/off of power, 1: normal power, 0: low power174174- *175175- * Put device to normal-power mode or low-power mode.176176- */177177-static void mpu3050_set_power_mode(struct i2c_client *client, u8 val)178178-{179179- u8 value;180180-181181- value = i2c_smbus_read_byte_data(client, MPU3050_PWR_MGM);182182- value = (value & ~MPU3050_PWR_MGM_MASK) |183183- (((val << MPU3050_PWR_MGM_POS) & MPU3050_PWR_MGM_MASK) ^184184- MPU3050_PWR_MGM_MASK);185185- i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, value);186186-}187187-188188-/**189189- * mpu3050_input_open - called on input event open190190- * @input: input dev of opened device191191- *192192- * The input layer calls this function when input event is opened. The193193- * function will push the device to resume. Then, the device is ready194194- * to provide data.195195- */196196-static int mpu3050_input_open(struct input_dev *input)197197-{198198- struct mpu3050_sensor *sensor = input_get_drvdata(input);199199- int error;200200-201201- pm_runtime_get(sensor->dev);202202-203203- /* Enable interrupts */204204- error = i2c_smbus_write_byte_data(sensor->client, MPU3050_INT_CFG,205205- MPU3050_LATCH_INT_EN |206206- MPU3050_RAW_RDY_EN |207207- MPU3050_MPU_RDY_EN);208208- if (error < 0) {209209- pm_runtime_put(sensor->dev);210210- return error;211211- }212212-213213- return 0;214214-}215215-216216-/**217217- * mpu3050_input_close - called on input event close218218- * @input: input dev of closed device219219- *220220- * The input layer calls this function when input event is closed. The221221- * function will push the device to suspend.222222- */223223-static void mpu3050_input_close(struct input_dev *input)224224-{225225- struct mpu3050_sensor *sensor = input_get_drvdata(input);226226-227227- pm_runtime_put(sensor->dev);228228-}229229-230230-/**231231- * mpu3050_interrupt_thread - handle an IRQ232232- * @irq: interrupt numner233233- * @data: the sensor234234- *235235- * Called by the kernel single threaded after an interrupt occurs. Read236236- * the sensor data and generate an input event for it.237237- */238238-static irqreturn_t mpu3050_interrupt_thread(int irq, void *data)239239-{240240- struct mpu3050_sensor *sensor = data;241241- struct axis_data axis;242242-243243- mpu3050_read_xyz(sensor->client, &axis);244244-245245- input_report_abs(sensor->idev, ABS_X, axis.x);246246- input_report_abs(sensor->idev, ABS_Y, axis.y);247247- input_report_abs(sensor->idev, ABS_Z, axis.z);248248- input_sync(sensor->idev);249249-250250- return IRQ_HANDLED;251251-}252252-253253-/**254254- * mpu3050_hw_init - initialize hardware255255- * @sensor: the sensor256256- *257257- * Called during device probe; configures the sampling method.258258- */259259-static int mpu3050_hw_init(struct mpu3050_sensor *sensor)260260-{261261- struct i2c_client *client = sensor->client;262262- int ret;263263- u8 reg;264264-265265- /* Reset */266266- ret = i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM,267267- MPU3050_PWR_MGM_RESET);268268- if (ret < 0)269269- return ret;270270-271271- ret = i2c_smbus_read_byte_data(client, MPU3050_PWR_MGM);272272- if (ret < 0)273273- return ret;274274-275275- ret &= ~MPU3050_PWR_MGM_CLKSEL;276276- ret |= MPU3050_PWR_MGM_PLL_Z;277277- ret = i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, ret);278278- if (ret < 0)279279- return ret;280280-281281- /* Output frequency divider. The poll interval */282282- ret = i2c_smbus_write_byte_data(client, MPU3050_SMPLRT_DIV,283283- MPU3050_DEFAULT_POLL_INTERVAL - 1);284284- if (ret < 0)285285- return ret;286286-287287- /* Set low pass filter and full scale */288288- reg = MPU3050_DEFAULT_FS_RANGE;289289- reg |= MPU3050_DLPF_CFG_42HZ << 3;290290- reg |= MPU3050_EXT_SYNC_NONE << 5;291291- ret = i2c_smbus_write_byte_data(client, MPU3050_DLPF_FS_SYNC, reg);292292- if (ret < 0)293293- return ret;294294-295295- return 0;296296-}297297-298298-/**299299- * mpu3050_probe - device detection callback300300- * @client: i2c client of found device301301- * @id: id match information302302- *303303- * The I2C layer calls us when it believes a sensor is present at this304304- * address. Probe to see if this is correct and to validate the device.305305- *306306- * If present install the relevant sysfs interfaces and input device.307307- */308308-static int mpu3050_probe(struct i2c_client *client,309309- const struct i2c_device_id *id)310310-{311311- struct mpu3050_sensor *sensor;312312- struct input_dev *idev;313313- int ret;314314- int error;315315-316316- sensor = kzalloc(sizeof(struct mpu3050_sensor), GFP_KERNEL);317317- idev = input_allocate_device();318318- if (!sensor || !idev) {319319- dev_err(&client->dev, "failed to allocate driver data\n");320320- error = -ENOMEM;321321- goto err_free_mem;322322- }323323-324324- sensor->client = client;325325- sensor->dev = &client->dev;326326- sensor->idev = idev;327327-328328- mpu3050_set_power_mode(client, 1);329329- msleep(10);330330-331331- ret = i2c_smbus_read_byte_data(client, MPU3050_CHIP_ID_REG);332332- if (ret < 0) {333333- dev_err(&client->dev, "failed to detect device\n");334334- error = -ENXIO;335335- goto err_free_mem;336336- }337337-338338- if (ret != MPU3050_CHIP_ID) {339339- dev_err(&client->dev, "unsupported chip id\n");340340- error = -ENXIO;341341- goto err_free_mem;342342- }343343-344344- idev->name = "MPU3050";345345- idev->id.bustype = BUS_I2C;346346- idev->dev.parent = &client->dev;347347-348348- idev->open = mpu3050_input_open;349349- idev->close = mpu3050_input_close;350350-351351- __set_bit(EV_ABS, idev->evbit);352352- input_set_abs_params(idev, ABS_X,353353- MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0);354354- input_set_abs_params(idev, ABS_Y,355355- MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0);356356- input_set_abs_params(idev, ABS_Z,357357- MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0);358358-359359- input_set_drvdata(idev, sensor);360360-361361- pm_runtime_set_active(&client->dev);362362-363363- error = mpu3050_hw_init(sensor);364364- if (error)365365- goto err_pm_set_suspended;366366-367367- error = request_threaded_irq(client->irq,368368- NULL, mpu3050_interrupt_thread,369369- IRQF_TRIGGER_RISING | IRQF_ONESHOT,370370- "mpu3050", sensor);371371- if (error) {372372- dev_err(&client->dev,373373- "can't get IRQ %d, error %d\n", client->irq, error);374374- goto err_pm_set_suspended;375375- }376376-377377- error = input_register_device(idev);378378- if (error) {379379- dev_err(&client->dev, "failed to register input device\n");380380- goto err_free_irq;381381- }382382-383383- pm_runtime_enable(&client->dev);384384- pm_runtime_set_autosuspend_delay(&client->dev, MPU3050_AUTO_DELAY);385385- i2c_set_clientdata(client, sensor);386386-387387- return 0;388388-389389-err_free_irq:390390- free_irq(client->irq, sensor);391391-err_pm_set_suspended:392392- pm_runtime_set_suspended(&client->dev);393393-err_free_mem:394394- input_free_device(idev);395395- kfree(sensor);396396- return error;397397-}398398-399399-/**400400- * mpu3050_remove - remove a sensor401401- * @client: i2c client of sensor being removed402402- *403403- * Our sensor is going away, clean up the resources.404404- */405405-static int mpu3050_remove(struct i2c_client *client)406406-{407407- struct mpu3050_sensor *sensor = i2c_get_clientdata(client);408408-409409- pm_runtime_disable(&client->dev);410410- pm_runtime_set_suspended(&client->dev);411411-412412- free_irq(client->irq, sensor);413413- input_unregister_device(sensor->idev);414414- kfree(sensor);415415-416416- return 0;417417-}418418-419419-#ifdef CONFIG_PM420420-/**421421- * mpu3050_suspend - called on device suspend422422- * @dev: device being suspended423423- *424424- * Put the device into sleep mode before we suspend the machine.425425- */426426-static int mpu3050_suspend(struct device *dev)427427-{428428- struct i2c_client *client = to_i2c_client(dev);429429-430430- mpu3050_set_power_mode(client, 0);431431-432432- return 0;433433-}434434-435435-/**436436- * mpu3050_resume - called on device resume437437- * @dev: device being resumed438438- *439439- * Put the device into powered mode on resume.440440- */441441-static int mpu3050_resume(struct device *dev)442442-{443443- struct i2c_client *client = to_i2c_client(dev);444444-445445- mpu3050_set_power_mode(client, 1);446446- msleep(100); /* wait for gyro chip resume */447447-448448- return 0;449449-}450450-#endif451451-452452-static UNIVERSAL_DEV_PM_OPS(mpu3050_pm, mpu3050_suspend, mpu3050_resume, NULL);453453-454454-static const struct i2c_device_id mpu3050_ids[] = {455455- { "mpu3050", 0 },456456- { }457457-};458458-MODULE_DEVICE_TABLE(i2c, mpu3050_ids);459459-460460-static const struct of_device_id mpu3050_of_match[] = {461461- { .compatible = "invn,mpu3050", },462462- { },463463-};464464-MODULE_DEVICE_TABLE(of, mpu3050_of_match);465465-466466-static struct i2c_driver mpu3050_i2c_driver = {467467- .driver = {468468- .name = "mpu3050",469469- .pm = &mpu3050_pm,470470- .of_match_table = mpu3050_of_match,471471- },472472- .probe = mpu3050_probe,473473- .remove = mpu3050_remove,474474- .id_table = mpu3050_ids,475475-};476476-477477-module_i2c_driver(mpu3050_i2c_driver);478478-479479-MODULE_AUTHOR("Wistron Corp.");480480-MODULE_DESCRIPTION("MPU3050 Tri-axis gyroscope driver");481481-MODULE_LICENSE("GPL");
···18551855 * Switch mouse to poll (remote) mode so motion data will not18561856 * get in our way18571857 */18581858- return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL);18581858+ return ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETPOLL);18591859}1860186018611861static int alps_monitor_mode_send_word(struct psmouse *psmouse, u16 word)
+1-1
drivers/input/mouse/bcm5974.c
···665665 char *data;666666667667 /* Type 3 does not require a mode switch */668668- if (dev->cfg.tp_type == TYPE3)668668+ if (c->tp_type == TYPE3)669669 return 0;670670671671 data = kmalloc(c->um_size, GFP_KERNEL);
+3-3
drivers/input/mouse/cyapa.c
···832832 int error;833833834834 if (device_can_wakeup(dev)) {835835- error = sysfs_merge_group(&client->dev.kobj,836836- &cyapa_power_wakeup_group);835835+ error = sysfs_merge_group(&dev->kobj,836836+ &cyapa_power_wakeup_group);837837 if (error) {838838 dev_err(dev, "failed to add power wakeup group: %d\n",839839 error);···13121312 return error;13131313 }1314131413151315- error = sysfs_create_group(&client->dev.kobj, &cyapa_sysfs_group);13151315+ error = sysfs_create_group(&dev->kobj, &cyapa_sysfs_group);13161316 if (error) {13171317 dev_err(dev, "failed to create sysfs entries: %d\n", error);13181318 return error;
+13-16
drivers/input/mouse/cyapa_gen3.c
···562562 * Wait for bootloader to exit, and operation mode to start.563563 * Normally, this takes at least 50 ms.564564 */565565- usleep_range(50000, 100000);565565+ msleep(50);566566 /*567567 * In addition, when a device boots for the first time after being568568 * updated to new firmware, it must first calibrate its sensors, which···789789 const char *buf, size_t count)790790{791791 struct cyapa *cyapa = dev_get_drvdata(dev);792792- int tries;792792+ unsigned long timeout;793793 int ret;794794795795 ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS);···812812 goto out;813813 }814814815815- tries = 20; /* max recalibration timeout 2s. */815815+ /* max recalibration timeout 2s. */816816+ timeout = jiffies + 2 * HZ;816817 do {817818 /*818819 * For this recalibration, the max time will not exceed 2s.819820 * The average time is approximately 500 - 700 ms, and we820821 * will check the status every 100 - 200ms.821822 */822822- usleep_range(100000, 200000);823823-823823+ msleep(100);824824 ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS);825825 if (ret < 0) {826826- dev_err(dev, "Error reading dev status: %d\n",827827- ret);826826+ dev_err(dev, "Error reading dev status: %d\n", ret);828827 goto out;829828 }830830- if ((ret & CYAPA_DEV_NORMAL) == CYAPA_DEV_NORMAL)831831- break;832832- } while (--tries);829829+ if ((ret & CYAPA_DEV_NORMAL) == CYAPA_DEV_NORMAL) {830830+ dev_dbg(dev, "Calibration successful.\n");831831+ goto out;832832+ }833833+ } while (time_is_after_jiffies(timeout));833834834834- if (tries == 0) {835835- dev_err(dev, "Failed to calibrate. Timeout.\n");836836- ret = -ETIMEDOUT;837837- goto out;838838- }839839- dev_dbg(dev, "Calibration successful.\n");835835+ dev_err(dev, "Failed to calibrate. Timeout.\n");836836+ ret = -ETIMEDOUT;840837841838out:842839 return ret < 0 ? ret : count;
···713713 * the upper bound. (in practice, it takes about 3 loops.)714714 */715715 for (timeo = 20; timeo > 0; timeo--) {716716- if (!ps2_sendbyte(&psmouse->ps2dev,717717- PSMOUSE_CMD_DISABLE, 20))716716+ if (!ps2_sendbyte(ps2dev, PSMOUSE_CMD_DISABLE, 20))718717 break;719718 msleep(25);720719 }···739740 psmouse_set_state(psmouse, PSMOUSE_IGNORE);740741741742 /* probably won't see an ACK, the touchpad will be off */742742- ps2_sendbyte(&psmouse->ps2dev, 0xec, 20);743743+ ps2_sendbyte(ps2dev, 0xec, 20);743744 }744745745746 return 0;
···597597 return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4;598598}599599600600-static void synaptics_pass_pt_packet(struct psmouse *psmouse,601601- struct serio *ptport,600600+static void synaptics_pass_pt_packet(struct serio *ptport,602601 unsigned char *packet)603602{604604- struct synaptics_data *priv = psmouse->private;605603 struct psmouse *child = serio_get_drvdata(ptport);606604607605 if (child && child->state == PSMOUSE_ACTIVATED) {608608- serio_interrupt(ptport, packet[1] | priv->pt_buttons, 0);606606+ serio_interrupt(ptport, packet[1], 0);609607 serio_interrupt(ptport, packet[4], 0);610608 serio_interrupt(ptport, packet[5], 0);611609 if (child->pktsize == 4)···854856 struct input_dev *dev = psmouse->dev;855857 struct synaptics_data *priv = psmouse->private;856858 int ext_bits = (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) + 1) >> 1;857857- char buf[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};858859 int i;859860860861 if (!SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap))···880883 * physically wired to the touchpad. Re-route them through881884 * the pass-through interface.882885 */883883- if (!priv->pt_port)884884- return;886886+ if (priv->pt_port) {887887+ u8 pt_buttons;885888886886- /* The trackstick expects at most 3 buttons */887887- priv->pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) |888888- SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 |889889- SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2;889889+ /* The trackstick expects at most 3 buttons */890890+ pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) |891891+ SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 |892892+ SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2;890893891891- synaptics_pass_pt_packet(psmouse, priv->pt_port, buf);894894+ serio_interrupt(priv->pt_port,895895+ PSMOUSE_OOB_EXTRA_BTNS, SERIO_OOB_DATA);896896+ serio_interrupt(priv->pt_port, pt_buttons, SERIO_OOB_DATA);897897+ }892898}893899894900static void synaptics_report_buttons(struct psmouse *psmouse,···11321132 if (SYN_CAP_PASS_THROUGH(priv->capabilities) &&11331133 synaptics_is_pt_packet(psmouse->packet)) {11341134 if (priv->pt_port)11351135- synaptics_pass_pt_packet(psmouse, priv->pt_port,11351135+ synaptics_pass_pt_packet(priv->pt_port,11361136 psmouse->packet);11371137 } else11381138 synaptics_process_packet(psmouse);
-1
drivers/input/mouse/synaptics.h
···183183 bool disable_gesture; /* disable gestures */184184185185 struct serio *pt_port; /* Pass-through serio port */186186- unsigned char pt_buttons; /* Pass-through buttons */187186188187 /*189188 * Last received Advanced Gesture Mode (AGM) packet. An AGM packet
+2-2
drivers/input/mouse/trackpoint.c
···379379 if (!set_properties)380380 return 0;381381382382- if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) {382382+ if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) {383383 psmouse_warn(psmouse, "failed to get extended button data\n");384384 button_info = 0;385385 }···402402403403 trackpoint_defaults(psmouse->private);404404405405- error = trackpoint_power_on_reset(&psmouse->ps2dev);405405+ error = trackpoint_power_on_reset(ps2dev);406406407407 /* Write defaults to TP only if reset fails. */408408 if (error)
+12-15
drivers/input/rmi4/Kconfig
···991010 If unsure, say Y.11111212+if RMI4_CORE1313+1214config RMI4_I2C1315 tristate "RMI4 I2C Support"1414- depends on RMI4_CORE && I2C1616+ depends on I2C1517 help1618 Say Y here if you want to support RMI4 devices connected to an I2C1719 bus.···22202321config RMI4_SPI2422 tristate "RMI4 SPI Support"2525- depends on RMI4_CORE && SPI2323+ depends on SPI2624 help2725 Say Y here if you want to support RMI4 devices connected to a SPI2826 bus.···31293230config RMI4_SMB3331 tristate "RMI4 SMB Support"3434- depends on RMI4_CORE && I2C3232+ depends on I2C3533 help3634 Say Y here if you want to support RMI4 devices connected to an SMB3735 bus.···4240 called rmi_smbus.43414442config RMI4_F034545- bool "RMI4 Function 03 (PS2 Guest)"4343+ bool "RMI4 Function 03 (PS2 Guest)"4644 depends on RMI4_CORE4747- help4848- Say Y here if you want to add support for RMI4 function 03.4545+ help4646+ Say Y here if you want to add support for RMI4 function 03.49475050- Function 03 provides PS2 guest support for RMI4 devices. This5151- includes support for TrackPoints on TouchPads.4848+ Function 03 provides PS2 guest support for RMI4 devices. This4949+ includes support for TrackPoints on TouchPads.52505351config RMI4_F03_SERIO5452 tristate···59576058config RMI4_2D_SENSOR6159 bool6262- depends on RMI4_CORE63606461config RMI4_F116562 bool "RMI4 Function 11 (2D pointing)"6663 select RMI4_2D_SENSOR6767- depends on RMI4_CORE6864 help6965 Say Y here if you want to add support for RMI4 function 11.7066···7373config RMI4_F127474 bool "RMI4 Function 12 (2D pointing)"7575 select RMI4_2D_SENSOR7676- depends on RMI4_CORE7776 help7877 Say Y here if you want to add support for RMI4 function 12.7978···82838384config RMI4_F308485 bool "RMI4 Function 30 (GPIO LED)"8585- depends on RMI4_CORE8686 help8787 Say Y here if you want to add support for RMI4 function 30.8888···90929193config RMI4_F349294 bool "RMI4 Function 34 (Device reflash)"9393- depends on RMI4_CORE9495 select FW_LOADER9596 help9697 Say Y here if you want to add support for RMI4 function 34.···100103101104config RMI4_F54102105 bool "RMI4 Function 54 (Analog diagnostics)"103103- depends on RMI4_CORE104106 depends on VIDEO_V4L2=y || (RMI4_CORE=m && VIDEO_V4L2=m)105107 select VIDEOBUF2_VMALLOC106108 select RMI4_F55···111115112116config RMI4_F55113117 bool "RMI4 Function 55 (Sensor tuning)"114114- depends on RMI4_CORE115118 help116119 Say Y here if you want to add support for RMI4 function 55117120118121 Function 55 provides access to the RMI4 touch sensor tuning119122 mechanism.123123+124124+endif # RMI_CORE
+6-1
drivers/input/rmi4/rmi_2d_sensor.c
···144144 int input_flags = 0;145145146146 if (sensor->report_abs) {147147- if (sensor->axis_align.swap_axes)147147+ if (sensor->axis_align.swap_axes) {148148 swap(sensor->max_x, sensor->max_y);149149+ swap(sensor->axis_align.clip_x_low,150150+ sensor->axis_align.clip_y_low);151151+ swap(sensor->axis_align.clip_x_high,152152+ sensor->axis_align.clip_y_high);153153+ }149154150155 sensor->min_x = sensor->axis_align.clip_x_low;151156 if (sensor->axis_align.clip_x_high)
···312312313313 for (i = 0; i < ((command >> 12) & 0xf); i++) {314314 error = i8042_wait_write();315315- if (error)315315+ if (error) {316316+ dbg(" -- i8042 (wait write timeout)\n");316317 return error;318318+ }317319 dbg("%02x -> i8042 (parameter)\n", param[i]);318320 i8042_write_data(param[i]);319321 }···323321 for (i = 0; i < ((command >> 8) & 0xf); i++) {324322 error = i8042_wait_read();325323 if (error) {326326- dbg(" -- i8042 (timeout)\n");324324+ dbg(" -- i8042 (wait read timeout)\n");327325 return error;328326 }329327
+3-4
drivers/input/serio/xilinx_ps2.c
···243243 unsigned int irq;244244 int error;245245246246- dev_info(dev, "Device Tree Probing \'%s\'\n",247247- ofdev->dev.of_node->name);246246+ dev_info(dev, "Device Tree Probing \'%s\'\n", dev->of_node->name);248247249248 /* Get iospace for the device */250250- error = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);249249+ error = of_address_to_resource(dev->of_node, 0, &r_mem);251250 if (error) {252251 dev_err(dev, "invalid address\n");253252 return error;254253 }255254256255 /* Get IRQ for the device */257257- irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);256256+ irq = irq_of_parse_and_map(dev->of_node, 0);258257 if (!irq) {259258 dev_err(dev, "no IRQ found\n");260259 return -ENODEV;
-3
drivers/input/touchscreen/88pm860x-ts.c
···240240 if (!touch)241241 return -ENOMEM;242242243243- platform_set_drvdata(pdev, touch);244244-245243 touch->idev = devm_input_allocate_device(&pdev->dev);246244 if (!touch->idev) {247245 dev_err(&pdev->dev, "Failed to allocate input device!\n");···283285 return ret;284286 }285287286286- platform_set_drvdata(pdev, touch);287288 return 0;288289}289290
+11-12
drivers/input/touchscreen/Kconfig
···546546 To compile this driver as a module, choose M here: the547547 module will be called inexio.548548549549-config TOUCHSCREEN_INTEL_MID550550- tristate "Intel MID platform resistive touchscreen"551551- depends on INTEL_SCU_IPC552552- help553553- Say Y here if you have a Intel MID based touchscreen in554554- your system.555555-556556- If unsure, say N.557557-558558- To compile this driver as a module, choose M here: the559559- module will be called intel_mid_touch.560560-561549config TOUCHSCREEN_MK712562550 tristate "ICS MicroClock MK712 touchscreen"563551 help···1164117611651177 To compile this driver as a module, choose M here: the11661178 module will be called tps6507x_ts.11791179+11801180+config TOUCHSCREEN_ZET622311811181+ tristate "Zeitec ZET6223 touchscreen driver"11821182+ depends on I2C11831183+ help11841184+ Say Y here if you have a touchscreen using Zeitec ZET622311851185+11861186+ If unsure, say N.11871187+11881188+ To compile this driver as a module, choose M here: the11891189+ module will be called zet6223.1167119011681191config TOUCHSCREEN_ZFORCE11691192 tristate "Neonode zForce infrared touchscreens"
···11+/*22+ * Copyright (C) 2016, Jelle van der Waa <jelle@vdwaa.nl>33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms of the GNU General Public License as published by the Free66+ * Software Foundation; either version 2 of the License, or (at your option)77+ * any later version.88+ *99+ * This program is distributed in the hope that it will be useful, but WITHOUT1010+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1111+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1212+ * more details.1313+ */1414+1515+#include <linux/delay.h>1616+#include <linux/i2c.h>1717+#include <linux/input.h>1818+#include <linux/input/mt.h>1919+#include <linux/input/touchscreen.h>2020+#include <linux/interrupt.h>2121+#include <linux/module.h>2222+#include <linux/regulator/consumer.h>2323+#include <asm/unaligned.h>2424+2525+#define ZET6223_MAX_FINGERS 162626+#define ZET6223_MAX_PKT_SIZE (3 + 4 * ZET6223_MAX_FINGERS)2727+2828+#define ZET6223_CMD_INFO 0xB22929+#define ZET6223_CMD_INFO_LENGTH 173030+#define ZET6223_VALID_PACKET 0x3c3131+3232+#define ZET6223_POWER_ON_DELAY_MSEC 303333+3434+struct zet6223_ts {3535+ struct i2c_client *client;3636+ struct input_dev *input;3737+ struct regulator *vcc;3838+ struct regulator *vio;3939+ struct touchscreen_properties prop;4040+ struct regulator_bulk_data supplies[2];4141+ u16 max_x;4242+ u16 max_y;4343+ u8 fingernum;4444+};4545+4646+static int zet6223_start(struct input_dev *dev)4747+{4848+ struct zet6223_ts *ts = input_get_drvdata(dev);4949+5050+ enable_irq(ts->client->irq);5151+5252+ return 0;5353+}5454+5555+static void zet6223_stop(struct input_dev *dev)5656+{5757+ struct zet6223_ts *ts = input_get_drvdata(dev);5858+5959+ disable_irq(ts->client->irq);6060+}6161+6262+static irqreturn_t zet6223_irq(int irq, void *dev_id)6363+{6464+ struct zet6223_ts *ts = dev_id;6565+ u16 finger_bits;6666+6767+ /*6868+ * First 3 bytes are an identifier, two bytes of finger data.6969+ * X, Y data per finger is 4 bytes.7070+ */7171+ u8 bufsize = 3 + 4 * ts->fingernum;7272+ u8 buf[ZET6223_MAX_PKT_SIZE];7373+ int i;7474+ int ret;7575+ int error;7676+7777+ ret = i2c_master_recv(ts->client, buf, bufsize);7878+ if (ret != bufsize) {7979+ error = ret < 0 ? ret : -EIO;8080+ dev_err_ratelimited(&ts->client->dev,8181+ "Error reading input data: %d\n", error);8282+ return IRQ_HANDLED;8383+ }8484+8585+ if (buf[0] != ZET6223_VALID_PACKET)8686+ return IRQ_HANDLED;8787+8888+ finger_bits = get_unaligned_be16(buf + 1);8989+ for (i = 0; i < ts->fingernum; i++) {9090+ if (!(finger_bits & BIT(15 - i)))9191+ continue;9292+9393+ input_mt_slot(ts->input, i);9494+ input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true);9595+ input_event(ts->input, EV_ABS, ABS_MT_POSITION_X,9696+ ((buf[i + 3] >> 4) << 8) + buf[i + 4]);9797+ input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y,9898+ ((buf[i + 3] & 0xF) << 8) + buf[i + 5]);9999+ }100100+101101+ input_mt_sync_frame(ts->input);102102+ input_sync(ts->input);103103+104104+ return IRQ_HANDLED;105105+}106106+107107+static void zet6223_power_off(void *_ts)108108+{109109+ struct zet6223_ts *ts = _ts;110110+111111+ regulator_bulk_disable(ARRAY_SIZE(ts->supplies), ts->supplies);112112+}113113+114114+static int zet6223_power_on(struct zet6223_ts *ts)115115+{116116+ struct device *dev = &ts->client->dev;117117+ int error;118118+119119+ ts->supplies[0].supply = "vio";120120+ ts->supplies[1].supply = "vcc";121121+122122+ error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->supplies),123123+ ts->supplies);124124+ if (error)125125+ return error;126126+127127+ error = regulator_bulk_enable(ARRAY_SIZE(ts->supplies), ts->supplies);128128+ if (error)129129+ return error;130130+131131+ msleep(ZET6223_POWER_ON_DELAY_MSEC);132132+133133+ error = devm_add_action_or_reset(dev, zet6223_power_off, ts);134134+ if (error) {135135+ dev_err(dev, "failed to install poweroff action: %d\n", error);136136+ return error;137137+ }138138+139139+ return 0;140140+}141141+142142+static int zet6223_query_device(struct zet6223_ts *ts)143143+{144144+ u8 buf[ZET6223_CMD_INFO_LENGTH];145145+ u8 cmd = ZET6223_CMD_INFO;146146+ int ret;147147+ int error;148148+149149+ ret = i2c_master_send(ts->client, &cmd, sizeof(cmd));150150+ if (ret != sizeof(cmd)) {151151+ error = ret < 0 ? ret : -EIO;152152+ dev_err(&ts->client->dev,153153+ "touchpanel info cmd failed: %d\n", error);154154+ return error;155155+ }156156+157157+ ret = i2c_master_recv(ts->client, buf, sizeof(buf));158158+ if (ret != sizeof(buf)) {159159+ error = ret < 0 ? ret : -EIO;160160+ dev_err(&ts->client->dev,161161+ "failed to retrieve touchpanel info: %d\n", error);162162+ return error;163163+ }164164+165165+ ts->fingernum = buf[15] & 0x7F;166166+ if (ts->fingernum > ZET6223_MAX_FINGERS) {167167+ dev_warn(&ts->client->dev,168168+ "touchpanel reports %d fingers, limiting to %d\n",169169+ ts->fingernum, ZET6223_MAX_FINGERS);170170+ ts->fingernum = ZET6223_MAX_FINGERS;171171+ }172172+173173+ ts->max_x = get_unaligned_le16(&buf[8]);174174+ ts->max_y = get_unaligned_le16(&buf[10]);175175+176176+ return 0;177177+}178178+179179+static int zet6223_probe(struct i2c_client *client,180180+ const struct i2c_device_id *id)181181+{182182+ struct device *dev = &client->dev;183183+ struct zet6223_ts *ts;184184+ struct input_dev *input;185185+ int error;186186+187187+ if (!client->irq) {188188+ dev_err(dev, "no irq specified\n");189189+ return -EINVAL;190190+ }191191+192192+ ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);193193+ if (!ts)194194+ return -ENOMEM;195195+196196+ ts->client = client;197197+198198+ error = zet6223_power_on(ts);199199+ if (error)200200+ return error;201201+202202+ error = zet6223_query_device(ts);203203+ if (error)204204+ return error;205205+206206+ ts->input = input = devm_input_allocate_device(dev);207207+ if (!input)208208+ return -ENOMEM;209209+210210+ input_set_drvdata(input, ts);211211+212212+ input->name = client->name;213213+ input->id.bustype = BUS_I2C;214214+ input->open = zet6223_start;215215+ input->close = zet6223_stop;216216+217217+ input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0);218218+ input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0);219219+220220+ touchscreen_parse_properties(input, true, &ts->prop);221221+222222+ error = input_mt_init_slots(input, ts->fingernum,223223+ INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);224224+ if (error)225225+ return error;226226+227227+ error = devm_request_threaded_irq(dev, client->irq, NULL, zet6223_irq,228228+ IRQF_ONESHOT, client->name, ts);229229+ if (error) {230230+ dev_err(dev, "failed to request irq %d: %d\n",231231+ client->irq, error);232232+ return error;233233+ }234234+235235+ zet6223_stop(input);236236+237237+ error = input_register_device(input);238238+ if (error)239239+ return error;240240+241241+ return 0;242242+}243243+244244+static const struct of_device_id zet6223_of_match[] = {245245+ { .compatible = "zeitec,zet6223" },246246+ { }247247+};248248+MODULE_DEVICE_TABLE(of, zet6223_of_match);249249+250250+static const struct i2c_device_id zet6223_id[] = {251251+ { "zet6223", 0},252252+ { }253253+};254254+MODULE_DEVICE_TABLE(i2c, zet6223_id);255255+256256+static struct i2c_driver zet6223_driver = {257257+ .driver = {258258+ .name = "zet6223",259259+ .of_match_table = zet6223_of_match,260260+ },261261+ .probe = zet6223_probe,262262+ .id_table = zet6223_id263263+};264264+module_i2c_driver(zet6223_driver);265265+266266+MODULE_AUTHOR("Jelle van der Waa <jelle@vdwaa.nl>");267267+MODULE_DESCRIPTION("ZEITEC zet622x I2C touchscreen driver");268268+MODULE_LICENSE("GPL");
-20
include/linux/i2c/mpr121_touchkey.h
···11-/* Header file for Freescale MPR121 Capacitive Touch Sensor */22-33-#ifndef _MPR121_TOUCHKEY_H44-#define _MPR121_TOUCHKEY_H55-66-/**77- * struct mpr121_platform_data - platform data for mpr121 sensor88- * @keymap: pointer to array of KEY_* values representing keymap99- * @keymap_size: size of the keymap1010- * @wakeup: configure the button as a wake-up source1111- * @vdd_uv: VDD voltage in uV1212- */1313-struct mpr121_platform_data {1414- const unsigned short *keymap;1515- unsigned int keymap_size;1616- bool wakeup;1717- int vdd_uv;1818-};1919-2020-#endif /* _MPR121_TOUCHKEY_H */
+3-18
include/linux/input/matrix_keypad.h
···8080 unsigned int rows, unsigned int cols,8181 unsigned short *keymap,8282 struct input_dev *input_dev);8383+int matrix_keypad_parse_properties(struct device *dev,8484+ unsigned int *rows, unsigned int *cols);83858484-#ifdef CONFIG_OF8585-/**8686- * matrix_keypad_parse_of_params() - Read parameters from matrix-keypad node8787- *8888- * @dev: Device containing of_node8989- * @rows: Returns number of matrix rows9090- * @cols: Returns number of matrix columns9191- * @return 0 if OK, <0 on error9292- */9393-int matrix_keypad_parse_of_params(struct device *dev,9494- unsigned int *rows, unsigned int *cols);9595-#else9696-static inline int matrix_keypad_parse_of_params(struct device *dev,9797- unsigned int *rows, unsigned int *cols)9898-{9999- return -ENOSYS;100100-}101101-#endif /* CONFIG_OF */8686+#define matrix_keypad_parse_of_params matrix_keypad_parse_properties1028710388#endif /* _MATRIX_KEYPAD_H */
-44
include/linux/input/tca8418_keypad.h
···11-/*22- * TCA8418 keypad platform support33- *44- * Copyright (C) 2011 Fuel7, Inc. All rights reserved.55- *66- * Author: Kyle Manna <kyle.manna@fuel7.com>77- *88- * This program is free software; you can redistribute it and/or99- * modify it under the terms of the GNU General Public1010- * License v2 as published by the Free Software Foundation.1111- *1212- * This program is distributed in the hope that it will be useful,1313- * but WITHOUT ANY WARRANTY; without even the implied warranty of1414- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU1515- * General Public License for more details.1616- *1717- * You should have received a copy of the GNU General Public1818- * License along with this program; if not, write to the1919- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,2020- * Boston, MA 021110-1307, USA.2121- *2222- * If you can't comply with GPLv2, alternative licensing terms may be2323- * arranged. Please contact Fuel7, Inc. (http://fuel7.com/) for proprietary2424- * alternative licensing inquiries.2525- */2626-2727-#ifndef _TCA8418_KEYPAD_H2828-#define _TCA8418_KEYPAD_H2929-3030-#include <linux/types.h>3131-#include <linux/input/matrix_keypad.h>3232-3333-#define TCA8418_I2C_ADDR 0x343434-#define TCA8418_NAME "tca8418_keypad"3535-3636-struct tca8418_keypad_platform_data {3737- const struct matrix_keymap_data *keymap_data;3838- unsigned rows;3939- unsigned cols;4040- bool rep;4141- bool irq_is_gpio;4242-};4343-4444-#endif
+72-2
include/linux/mfd/cros_ec_commands.h
···18391839 *18401840 * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for18411841 * expected response size.18421842+ *18431843+ * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT. If you wish18441844+ * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type18451845+ * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX.18421846 */18431847#define EC_CMD_MKBP_STATE 0x601844184818451845-/* Provide information about the matrix : number of rows and columns */18491849+/*18501850+ * Provide information about various MKBP things. See enum ec_mkbp_info_type.18511851+ */18461852#define EC_CMD_MKBP_INFO 0x611847185318481854struct ec_response_mkbp_info {18491855 uint32_t rows;18501856 uint32_t cols;18511851- uint8_t switches;18571857+ /* Formerly "switches", which was 0. */18581858+ uint8_t reserved;18521859} __packed;18601860+18611861+struct ec_params_mkbp_info {18621862+ uint8_t info_type;18631863+ uint8_t event_type;18641864+} __packed;18651865+18661866+enum ec_mkbp_info_type {18671867+ /*18681868+ * Info about the keyboard matrix: number of rows and columns.18691869+ *18701870+ * Returns struct ec_response_mkbp_info.18711871+ */18721872+ EC_MKBP_INFO_KBD = 0,18731873+18741874+ /*18751875+ * For buttons and switches, info about which specifically are18761876+ * supported. event_type must be set to one of the values in enum18771877+ * ec_mkbp_event.18781878+ *18791879+ * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte18801880+ * bitmask indicating which buttons or switches are present. See the18811881+ * bit inidices below.18821882+ */18831883+ EC_MKBP_INFO_SUPPORTED = 1,18841884+18851885+ /*18861886+ * Instantaneous state of buttons and switches.18871887+ *18881888+ * event_type must be set to one of the values in enum ec_mkbp_event.18891889+ *18901890+ * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13]18911891+ * indicating the current state of the keyboard matrix.18921892+ *18931893+ * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw18941894+ * event state.18951895+ *18961896+ * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the18971897+ * state of supported buttons.18981898+ *18991899+ * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the19001900+ * state of supported switches.19011901+ */19021902+ EC_MKBP_INFO_CURRENT = 2,19031903+};1853190418541905/* Simulate key press */18551906#define EC_CMD_MKBP_SIMULATE_KEY 0x62···20341983 /* New Sensor FIFO data. The event data is fifo_info structure. */20351984 EC_MKBP_EVENT_SENSOR_FIFO = 2,2036198519861986+ /* The state of the non-matrixed buttons have changed. */19871987+ EC_MKBP_EVENT_BUTTON = 3,19881988+19891989+ /* The state of the switches have changed. */19901990+ EC_MKBP_EVENT_SWITCH = 4,19911991+20371992 /* Number of MKBP events */20381993 EC_MKBP_EVENT_COUNT,20391994};···2049199220501993 /* Unaligned */20511994 uint32_t host_event;19951995+19961996+ uint32_t buttons;19971997+ uint32_t switches;20521998} __packed;2053199920542000struct ec_response_get_next_event {···20591999 /* Followed by event data if any */20602000 union ec_response_get_next_data data;20612001} __packed;20022002+20032003+/* Bit indices for buttons and switches.*/20042004+/* Buttons */20052005+#define EC_MKBP_POWER_BUTTON 020062006+#define EC_MKBP_VOL_UP 120072007+#define EC_MKBP_VOL_DOWN 220082008+20092009+/* Switches */20102010+#define EC_MKBP_LID_OPEN 020112011+#define EC_MKBP_TABLET_MODE 12062201220632013/*****************************************************************************/20642014/* Temperature sensor commands */
-34
include/linux/spi/tsc2005.h
···11-/*22- * This file is part of TSC2005 touchscreen driver33- *44- * Copyright (C) 2009-2010 Nokia Corporation55- *66- * This program is free software; you can redistribute it and/or modify77- * it under the terms of the GNU General Public License as published by88- * the Free Software Foundation; either version 2 of the License, or99- * (at your option) any later version.1010- *1111- * This program is distributed in the hope that it will be useful,1212- * but WITHOUT ANY WARRANTY; without even the implied warranty of1313- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414- * GNU General Public License for more details.1515- */1616-1717-#ifndef _LINUX_SPI_TSC2005_H1818-#define _LINUX_SPI_TSC2005_H1919-2020-#include <linux/types.h>2121-2222-struct tsc2005_platform_data {2323- int ts_pressure_max;2424- int ts_pressure_fudge;2525- int ts_x_max;2626- int ts_x_fudge;2727- int ts_y_max;2828- int ts_y_fudge;2929- int ts_x_plate_ohm;3030- unsigned int esd_timeout_ms;3131- void (*set_reset)(bool enable);3232-};3333-3434-#endif
+4-3
include/uapi/linux/serio.h
···1717/*1818 * bit masks for use in "interrupt" flags (3rd argument)1919 */2020-#define SERIO_TIMEOUT 12121-#define SERIO_PARITY 22222-#define SERIO_FRAME 42020+#define SERIO_TIMEOUT BIT(0)2121+#define SERIO_PARITY BIT(1)2222+#define SERIO_FRAME BIT(2)2323+#define SERIO_OOB_DATA BIT(3)23242425/*2526 * Serio types