^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * mainstone-wm97xx.c -- Mainstone Continuous Touch screen driver for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Wolfson WM97xx AC97 Codecs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright 2004, 2007 Wolfson Microelectronics PLC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Author: Liam Girdwood <lrg@slimlogic.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Parts Copyright : Ian Molton <spyro@f2s.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Andrew Zabolotny <zap@homelink.ru>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This is a wm97xx extended touch driver to capture touch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * data in a continuous manner on the Intel XScale architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Features:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * - codecs supported:- WM9705, WM9712, WM9713
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * - processors supported:- Intel XScale PXA25x, PXA26x, PXA27x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/wm97xx.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <mach/regs-ac97.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct continuous {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) u16 id; /* codec id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u8 code; /* continuous code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) u8 reads; /* number of coord reads per read cycle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) u32 speed; /* number of coords per second */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define WM_READS(sp) ((sp / HZ) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static const struct continuous cinfo[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {WM9705_ID2, 0, WM_READS(94), 94},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {WM9705_ID2, 1, WM_READS(188), 188},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {WM9705_ID2, 2, WM_READS(375), 375},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {WM9705_ID2, 3, WM_READS(750), 750},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {WM9712_ID2, 0, WM_READS(94), 94},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {WM9712_ID2, 1, WM_READS(188), 188},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {WM9712_ID2, 2, WM_READS(375), 375},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {WM9712_ID2, 3, WM_READS(750), 750},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {WM9713_ID2, 0, WM_READS(94), 94},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {WM9713_ID2, 1, WM_READS(120), 120},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {WM9713_ID2, 2, WM_READS(154), 154},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {WM9713_ID2, 3, WM_READS(188), 188},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* continuous speed index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static int sp_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static u16 last, tries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * Pen sampling frequency (Hz) in continuous mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static int cont_rate = 200;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) module_param(cont_rate, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) MODULE_PARM_DESC(cont_rate, "Sampling rate in continuous mode (Hz)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * Pen down detection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * This driver can either poll or use an interrupt to indicate a pen down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * event. If the irq request fails then it will fall back to polling mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static int pen_int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) module_param(pen_int, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) MODULE_PARM_DESC(pen_int, "Pen down detection (1 = interrupt, 0 = polling)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * Pressure readback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * Set to 1 to read back pen down pressure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static int pressure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) module_param(pressure, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) MODULE_PARM_DESC(pressure, "Pressure readback (1 = pressure, 0 = no pressure)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * AC97 touch data slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * Touch screen readback data ac97 slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) static int ac97_touch_slot = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) module_param(ac97_touch_slot, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) MODULE_PARM_DESC(ac97_touch_slot, "Touch screen data slot AC97 number");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /* flush AC97 slot 5 FIFO on pxa machines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #ifdef CONFIG_PXA27x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static void wm97xx_acc_pen_up(struct wm97xx *wm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) schedule_timeout_uninterruptible(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) while (MISR & (1 << 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) MODR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static void wm97xx_acc_pen_up(struct wm97xx *wm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) unsigned int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) schedule_timeout_uninterruptible(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) for (count = 0; count < 16; count++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) MODR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static int wm97xx_acc_pen_down(struct wm97xx *wm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u16 x, y, p = 0x100 | WM97XX_ADCSEL_PRES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int reads = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* When the AC97 queue has been drained we need to allow time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * to buffer up samples otherwise we end up spinning polling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * for samples. The controller can't have a suitably low
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * threshold set to use the notifications it gives.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) schedule_timeout_uninterruptible(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) if (tries > 5) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) tries = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return RC_PENUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) x = MODR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (x == last) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) tries++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return RC_AGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) last = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (reads)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) x = MODR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) y = MODR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (pressure)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) p = MODR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) x, y, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* are samples valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if ((x & WM97XX_ADCSEL_MASK) != WM97XX_ADCSEL_X ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) (y & WM97XX_ADCSEL_MASK) != WM97XX_ADCSEL_Y ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) (p & WM97XX_ADCSEL_MASK) != WM97XX_ADCSEL_PRES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) goto up;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* coordinate is good */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) tries = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) input_report_abs(wm->input_dev, ABS_X, x & 0xfff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) input_report_abs(wm->input_dev, ABS_Y, y & 0xfff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) input_report_abs(wm->input_dev, ABS_PRESSURE, p & 0xfff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) input_report_key(wm->input_dev, BTN_TOUCH, (p != 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) input_sync(wm->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) reads++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) } while (reads < cinfo[sp_idx].reads);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) up:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return RC_PENDOWN | RC_AGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static int wm97xx_acc_startup(struct wm97xx *wm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) int idx = 0, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /* check we have a codec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (wm->ac97 == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /* Go you big red fire engine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) for (idx = 0; idx < ARRAY_SIZE(cinfo); idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (wm->id != cinfo[idx].id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) sp_idx = idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (cont_rate <= cinfo[idx].speed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) wm->acc_rate = cinfo[sp_idx].code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) wm->acc_slot = ac97_touch_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) dev_info(wm->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) "mainstone accelerated touchscreen driver, %d samples/sec\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) cinfo[sp_idx].speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /* IRQ driven touchscreen is used on Palm hardware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (machine_is_palmt5() || machine_is_palmtx() || machine_is_palmld()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) pen_int = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) irq = 27;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) /* There is some obscure mutant of WM9712 interbred with WM9713
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * used on Palm HW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) wm->variant = WM97xx_WM1613;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) } else if (machine_is_mainstone() && pen_int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) irq = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) ret = gpio_request(irq, "Touchscreen IRQ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) ret = gpio_direction_input(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) gpio_free(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) wm->pen_irq = gpio_to_irq(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) irq_set_irq_type(wm->pen_irq, IRQ_TYPE_EDGE_BOTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) } else /* pen irq not supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) pen_int = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* codec specific irq config */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (pen_int) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) switch (wm->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) case WM9705_ID2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) case WM9712_ID2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) case WM9713_ID2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /* use PEN_DOWN GPIO 13 to assert IRQ on GPIO line 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) WM97XX_GPIO_POL_HIGH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) WM97XX_GPIO_STICKY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) WM97XX_GPIO_WAKE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) wm97xx_config_gpio(wm, WM97XX_GPIO_2, WM97XX_GPIO_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) WM97XX_GPIO_POL_HIGH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) WM97XX_GPIO_NOTSTICKY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) WM97XX_GPIO_NOWAKE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) dev_err(wm->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) "pen down irq not supported on this device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) pen_int = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static void wm97xx_acc_shutdown(struct wm97xx *wm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) /* codec specific deconfig */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (pen_int) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) gpio_free(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) wm->pen_irq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static void wm97xx_irq_enable(struct wm97xx *wm, int enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) enable_irq(wm->pen_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) disable_irq_nosync(wm->pen_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static struct wm97xx_mach_ops mainstone_mach_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) .acc_enabled = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) .acc_pen_up = wm97xx_acc_pen_up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) .acc_pen_down = wm97xx_acc_pen_down,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) .acc_startup = wm97xx_acc_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) .acc_shutdown = wm97xx_acc_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) .irq_enable = wm97xx_irq_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) .irq_gpio = WM97XX_GPIO_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static int mainstone_wm97xx_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct wm97xx *wm = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) return wm97xx_register_mach_ops(wm, &mainstone_mach_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) static int mainstone_wm97xx_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) struct wm97xx *wm = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) wm97xx_unregister_mach_ops(wm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static struct platform_driver mainstone_wm97xx_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) .probe = mainstone_wm97xx_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) .remove = mainstone_wm97xx_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) .name = "wm97xx-touch",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) module_platform_driver(mainstone_wm97xx_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) /* Module information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) MODULE_DESCRIPTION("wm97xx continuous touch driver for mainstone");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) MODULE_LICENSE("GPL");