Lines Matching +full:stmpe +full:- +full:adc

1 // SPDX-License-Identifier: GPL-2.0-only
3 * ST Microelectronics MFD: stmpe's driver
5 * Copyright (C) ST-Ericsson SA 2010
7 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
24 #include "stmpe.h"
27 * struct stmpe_platform_data - STMPE platform data
31 * @autosleep: bool to enable/disable stmpe autosleep
47 static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks) in __stmpe_enable() argument
49 return stmpe->variant->enable(stmpe, blocks, true); in __stmpe_enable()
52 static int __stmpe_disable(struct stmpe *stmpe, unsigned int blocks) in __stmpe_disable() argument
54 return stmpe->variant->enable(stmpe, blocks, false); in __stmpe_disable()
57 static int __stmpe_reg_read(struct stmpe *stmpe, u8 reg) in __stmpe_reg_read() argument
61 ret = stmpe->ci->read_byte(stmpe, reg); in __stmpe_reg_read()
63 dev_err(stmpe->dev, "failed to read reg %#x: %d\n", reg, ret); in __stmpe_reg_read()
65 dev_vdbg(stmpe->dev, "rd: reg %#x => data %#x\n", reg, ret); in __stmpe_reg_read()
70 static int __stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 val) in __stmpe_reg_write() argument
74 dev_vdbg(stmpe->dev, "wr: reg %#x <= %#x\n", reg, val); in __stmpe_reg_write()
76 ret = stmpe->ci->write_byte(stmpe, reg, val); in __stmpe_reg_write()
78 dev_err(stmpe->dev, "failed to write reg %#x: %d\n", reg, ret); in __stmpe_reg_write()
83 static int __stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val) in __stmpe_set_bits() argument
87 ret = __stmpe_reg_read(stmpe, reg); in __stmpe_set_bits()
94 return __stmpe_reg_write(stmpe, reg, ret); in __stmpe_set_bits()
97 static int __stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length, in __stmpe_block_read() argument
102 ret = stmpe->ci->read_block(stmpe, reg, length, values); in __stmpe_block_read()
104 dev_err(stmpe->dev, "failed to read regs %#x: %d\n", reg, ret); in __stmpe_block_read()
106 dev_vdbg(stmpe->dev, "rd: reg %#x (%d) => ret %#x\n", reg, length, ret); in __stmpe_block_read()
107 stmpe_dump_bytes("stmpe rd: ", values, length); in __stmpe_block_read()
112 static int __stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length, in __stmpe_block_write() argument
117 dev_vdbg(stmpe->dev, "wr: regs %#x (%d)\n", reg, length); in __stmpe_block_write()
118 stmpe_dump_bytes("stmpe wr: ", values, length); in __stmpe_block_write()
120 ret = stmpe->ci->write_block(stmpe, reg, length, values); in __stmpe_block_write()
122 dev_err(stmpe->dev, "failed to write regs %#x: %d\n", reg, ret); in __stmpe_block_write()
128 * stmpe_enable - enable blocks on an STMPE device
129 * @stmpe: Device to work on
132 int stmpe_enable(struct stmpe *stmpe, unsigned int blocks) in stmpe_enable() argument
136 mutex_lock(&stmpe->lock); in stmpe_enable()
137 ret = __stmpe_enable(stmpe, blocks); in stmpe_enable()
138 mutex_unlock(&stmpe->lock); in stmpe_enable()
145 * stmpe_disable - disable blocks on an STMPE device
146 * @stmpe: Device to work on
149 int stmpe_disable(struct stmpe *stmpe, unsigned int blocks) in stmpe_disable() argument
153 mutex_lock(&stmpe->lock); in stmpe_disable()
154 ret = __stmpe_disable(stmpe, blocks); in stmpe_disable()
155 mutex_unlock(&stmpe->lock); in stmpe_disable()
162 * stmpe_reg_read() - read a single STMPE register
163 * @stmpe: Device to read from
166 int stmpe_reg_read(struct stmpe *stmpe, u8 reg) in stmpe_reg_read() argument
170 mutex_lock(&stmpe->lock); in stmpe_reg_read()
171 ret = __stmpe_reg_read(stmpe, reg); in stmpe_reg_read()
172 mutex_unlock(&stmpe->lock); in stmpe_reg_read()
179 * stmpe_reg_write() - write a single STMPE register
180 * @stmpe: Device to write to
184 int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 val) in stmpe_reg_write() argument
188 mutex_lock(&stmpe->lock); in stmpe_reg_write()
189 ret = __stmpe_reg_write(stmpe, reg, val); in stmpe_reg_write()
190 mutex_unlock(&stmpe->lock); in stmpe_reg_write()
197 * stmpe_set_bits() - set the value of a bitfield in a STMPE register
198 * @stmpe: Device to write to
203 int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val) in stmpe_set_bits() argument
207 mutex_lock(&stmpe->lock); in stmpe_set_bits()
208 ret = __stmpe_set_bits(stmpe, reg, mask, val); in stmpe_set_bits()
209 mutex_unlock(&stmpe->lock); in stmpe_set_bits()
216 * stmpe_block_read() - read multiple STMPE registers
217 * @stmpe: Device to read from
222 int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values) in stmpe_block_read() argument
226 mutex_lock(&stmpe->lock); in stmpe_block_read()
227 ret = __stmpe_block_read(stmpe, reg, length, values); in stmpe_block_read()
228 mutex_unlock(&stmpe->lock); in stmpe_block_read()
235 * stmpe_block_write() - write multiple STMPE registers
236 * @stmpe: Device to write to
241 int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length, in stmpe_block_write() argument
246 mutex_lock(&stmpe->lock); in stmpe_block_write()
247 ret = __stmpe_block_write(stmpe, reg, length, values); in stmpe_block_write()
248 mutex_unlock(&stmpe->lock); in stmpe_block_write()
255 * stmpe_set_altfunc()- set the alternate function for STMPE pins
256 * @stmpe: Device to configure
266 int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block) in stmpe_set_altfunc() argument
268 struct stmpe_variant_info *variant = stmpe->variant; in stmpe_set_altfunc()
269 u8 regaddr = stmpe->regs[STMPE_IDX_GPAFR_U_MSB]; in stmpe_set_altfunc()
270 int af_bits = variant->af_bits; in stmpe_set_altfunc()
271 int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8); in stmpe_set_altfunc()
272 int mask = (1 << af_bits) - 1; in stmpe_set_altfunc()
276 if (!variant->get_altfunc) in stmpe_set_altfunc()
280 mutex_lock(&stmpe->lock); in stmpe_set_altfunc()
282 ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO); in stmpe_set_altfunc()
286 ret = __stmpe_block_read(stmpe, regaddr, numregs, regs); in stmpe_set_altfunc()
290 af = variant->get_altfunc(stmpe, block); in stmpe_set_altfunc()
294 int regoffset = numregs - (pin / afperreg) - 1; in stmpe_set_altfunc()
303 ret = __stmpe_block_write(stmpe, regaddr, numregs, regs); in stmpe_set_altfunc()
306 mutex_unlock(&stmpe->lock); in stmpe_set_altfunc()
323 .name = "stmpe-gpio",
324 .of_compatible = "st,stmpe-gpio",
330 .name = "stmpe-gpio",
331 .of_compatible = "st,stmpe-gpio",
352 .name = "stmpe-keypad",
353 .of_compatible = "st,stmpe-keypad",
378 .name = "stmpe-pwm",
379 .of_compatible = "st,stmpe-pwm",
414 static int stmpe801_enable(struct stmpe *stmpe, unsigned int blocks, in stmpe801_enable() argument
420 return -EINVAL; in stmpe801_enable()
463 .name = "stmpe-ts",
464 .of_compatible = "st,stmpe-ts",
470 * ADC (STMPE811)
486 .name = "stmpe-adc",
487 .of_compatible = "st,stmpe-adc",
533 static int stmpe811_enable(struct stmpe *stmpe, unsigned int blocks, in stmpe811_enable() argument
547 return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2], mask, in stmpe811_enable()
551 int stmpe811_adc_common_init(struct stmpe *stmpe) in stmpe811_adc_common_init() argument
556 adc_ctrl1 = STMPE_SAMPLE_TIME(stmpe->sample_time) | in stmpe811_adc_common_init()
557 STMPE_MOD_12B(stmpe->mod_12b) | in stmpe811_adc_common_init()
558 STMPE_REF_SEL(stmpe->ref_sel); in stmpe811_adc_common_init()
562 ret = stmpe_set_bits(stmpe, STMPE811_REG_ADC_CTRL1, in stmpe811_adc_common_init()
565 dev_err(stmpe->dev, "Could not setup ADC\n"); in stmpe811_adc_common_init()
569 ret = stmpe_set_bits(stmpe, STMPE811_REG_ADC_CTRL2, in stmpe811_adc_common_init()
570 STMPE_ADC_FREQ(0xff), STMPE_ADC_FREQ(stmpe->adc_freq)); in stmpe811_adc_common_init()
572 dev_err(stmpe->dev, "Could not setup ADC\n"); in stmpe811_adc_common_init()
580 static int stmpe811_get_altfunc(struct stmpe *stmpe, enum stmpe_block block) in stmpe811_get_altfunc() argument
617 * Compared to all others STMPE variant, LSB and MSB regs are located in this
648 static int stmpe1600_enable(struct stmpe *stmpe, unsigned int blocks, in stmpe1600_enable() argument
654 return -EINVAL; in stmpe1600_enable()
739 return -EINVAL; in stmpe_round_timeout()
742 static int stmpe_autosleep(struct stmpe *stmpe, int autosleep_timeout) in stmpe_autosleep() argument
746 if (!stmpe->variant->enable_autosleep) in stmpe_autosleep()
747 return -ENOSYS; in stmpe_autosleep()
749 mutex_lock(&stmpe->lock); in stmpe_autosleep()
750 ret = stmpe->variant->enable_autosleep(stmpe, autosleep_timeout); in stmpe_autosleep()
751 mutex_unlock(&stmpe->lock); in stmpe_autosleep()
757 * Both stmpe 1601/2403 support same layout for autosleep
759 static int stmpe1601_autosleep(struct stmpe *stmpe, in stmpe1601_autosleep() argument
767 dev_err(stmpe->dev, "invalid timeout\n"); in stmpe1601_autosleep()
771 ret = __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2], in stmpe1601_autosleep()
777 return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2], in stmpe1601_autosleep()
782 static int stmpe1601_enable(struct stmpe *stmpe, unsigned int blocks, in stmpe1601_enable() argument
802 return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL], mask, in stmpe1601_enable()
806 static int stmpe1601_get_altfunc(struct stmpe *stmpe, enum stmpe_block block) in stmpe1601_get_altfunc() argument
883 static int stmpe1801_enable(struct stmpe *stmpe, unsigned int blocks, in stmpe1801_enable() argument
893 return __stmpe_set_bits(stmpe, STMPE1801_REG_INT_EN_MASK_LOW, mask, in stmpe1801_enable()
897 static int stmpe_reset(struct stmpe *stmpe) in stmpe_reset() argument
899 u16 id_val = stmpe->variant->id_val; in stmpe_reset()
908 /* all other STMPE variant use bit 7 of SYS_CTRL register */ in stmpe_reset()
911 ret = __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL], in stmpe_reset()
920 ret = __stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL]); in stmpe_reset()
927 return -EIO; in stmpe_reset()
1005 static int stmpe24xx_enable(struct stmpe *stmpe, unsigned int blocks, in stmpe24xx_enable() argument
1016 return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL], mask, in stmpe24xx_enable()
1020 static int stmpe24xx_get_altfunc(struct stmpe *stmpe, enum stmpe_block block) in stmpe24xx_get_altfunc() argument
1077 * These devices can be connected in a 'no-irq' configuration - the irq pin
1079 * devices which support this configuration - the driver will fail probing
1088 struct stmpe *stmpe = data; in stmpe_irq() local
1089 struct stmpe_variant_info *variant = stmpe->variant; in stmpe_irq()
1090 int num = DIV_ROUND_UP(variant->num_irqs, 8); in stmpe_irq()
1096 if (variant->id_val == STMPE801_ID || in stmpe_irq()
1097 variant->id_val == STMPE1600_ID) { in stmpe_irq()
1098 int base = irq_find_mapping(stmpe->domain, 0); in stmpe_irq()
1104 if (variant->id_val == STMPE1801_ID) in stmpe_irq()
1105 israddr = stmpe->regs[STMPE_IDX_ISR_LSB]; in stmpe_irq()
1107 israddr = stmpe->regs[STMPE_IDX_ISR_MSB]; in stmpe_irq()
1109 ret = stmpe_block_read(stmpe, israddr, num, isr); in stmpe_irq()
1114 int bank = num - i - 1; in stmpe_irq()
1118 status &= stmpe->ier[bank]; in stmpe_irq()
1126 int nestedirq = irq_find_mapping(stmpe->domain, line); in stmpe_irq()
1132 stmpe_reg_write(stmpe, israddr + i, clear); in stmpe_irq()
1140 struct stmpe *stmpe = irq_data_get_irq_chip_data(data); in stmpe_irq_lock() local
1142 mutex_lock(&stmpe->irq_lock); in stmpe_irq_lock()
1147 struct stmpe *stmpe = irq_data_get_irq_chip_data(data); in stmpe_irq_sync_unlock() local
1148 struct stmpe_variant_info *variant = stmpe->variant; in stmpe_irq_sync_unlock()
1149 int num = DIV_ROUND_UP(variant->num_irqs, 8); in stmpe_irq_sync_unlock()
1153 u8 new = stmpe->ier[i]; in stmpe_irq_sync_unlock()
1154 u8 old = stmpe->oldier[i]; in stmpe_irq_sync_unlock()
1159 stmpe->oldier[i] = new; in stmpe_irq_sync_unlock()
1160 stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_IER_LSB + i], new); in stmpe_irq_sync_unlock()
1163 mutex_unlock(&stmpe->irq_lock); in stmpe_irq_sync_unlock()
1168 struct stmpe *stmpe = irq_data_get_irq_chip_data(data); in stmpe_irq_mask() local
1169 int offset = data->hwirq; in stmpe_irq_mask()
1173 stmpe->ier[regoffset] &= ~mask; in stmpe_irq_mask()
1178 struct stmpe *stmpe = irq_data_get_irq_chip_data(data); in stmpe_irq_unmask() local
1179 int offset = data->hwirq; in stmpe_irq_unmask()
1183 stmpe->ier[regoffset] |= mask; in stmpe_irq_unmask()
1187 .name = "stmpe",
1197 struct stmpe *stmpe = d->host_data; in stmpe_irq_map() local
1200 if (stmpe->variant->id_val != STMPE801_ID) in stmpe_irq_map()
1203 irq_set_chip_data(virq, stmpe); in stmpe_irq_map()
1223 static int stmpe_irq_init(struct stmpe *stmpe, struct device_node *np) in stmpe_irq_init() argument
1226 int num_irqs = stmpe->variant->num_irqs; in stmpe_irq_init()
1228 stmpe->domain = irq_domain_add_simple(np, num_irqs, base, in stmpe_irq_init()
1229 &stmpe_irq_ops, stmpe); in stmpe_irq_init()
1230 if (!stmpe->domain) { in stmpe_irq_init()
1231 dev_err(stmpe->dev, "Failed to create irqdomain\n"); in stmpe_irq_init()
1232 return -ENOSYS; in stmpe_irq_init()
1238 static int stmpe_chip_init(struct stmpe *stmpe) in stmpe_chip_init() argument
1240 unsigned int irq_trigger = stmpe->pdata->irq_trigger; in stmpe_chip_init()
1241 int autosleep_timeout = stmpe->pdata->autosleep_timeout; in stmpe_chip_init()
1242 struct stmpe_variant_info *variant = stmpe->variant; in stmpe_chip_init()
1248 ret = stmpe_block_read(stmpe, stmpe->regs[STMPE_IDX_CHIP_ID], in stmpe_chip_init()
1254 if ((id & variant->id_mask) != variant->id_val) { in stmpe_chip_init()
1255 dev_err(stmpe->dev, "unknown chip id: %#x\n", id); in stmpe_chip_init()
1256 return -EINVAL; in stmpe_chip_init()
1259 dev_info(stmpe->dev, "%s detected, chip id: %#x\n", variant->name, id); in stmpe_chip_init()
1261 /* Disable all modules -- subdrivers should enable what they need. */ in stmpe_chip_init()
1262 ret = stmpe_disable(stmpe, ~0); in stmpe_chip_init()
1266 ret = stmpe_reset(stmpe); in stmpe_chip_init()
1270 if (stmpe->irq >= 0) { in stmpe_chip_init()
1292 if (stmpe->pdata->autosleep) { in stmpe_chip_init()
1293 ret = stmpe_autosleep(stmpe, autosleep_timeout); in stmpe_chip_init()
1298 return stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_ICR_LSB], icr); in stmpe_chip_init()
1301 static int stmpe_add_device(struct stmpe *stmpe, const struct mfd_cell *cell) in stmpe_add_device() argument
1303 return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1, in stmpe_add_device()
1304 NULL, 0, stmpe->domain); in stmpe_add_device()
1307 static int stmpe_devices_init(struct stmpe *stmpe) in stmpe_devices_init() argument
1309 struct stmpe_variant_info *variant = stmpe->variant; in stmpe_devices_init()
1310 unsigned int platform_blocks = stmpe->pdata->blocks; in stmpe_devices_init()
1311 int ret = -EINVAL; in stmpe_devices_init()
1314 for (i = 0; i < variant->num_blocks; i++) { in stmpe_devices_init()
1315 struct stmpe_variant_block *block = &variant->blocks[i]; in stmpe_devices_init()
1317 if (!(platform_blocks & block->block)) in stmpe_devices_init()
1320 for (j = 0; j < block->cell->num_resources; j++) { in stmpe_devices_init()
1322 (struct resource *) &block->cell->resources[j]; in stmpe_devices_init()
1325 if (res->flags & IORESOURCE_IRQ) in stmpe_devices_init()
1326 res->start = res->end = block->irq + j; in stmpe_devices_init()
1329 platform_blocks &= ~block->block; in stmpe_devices_init()
1330 ret = stmpe_add_device(stmpe, block->cell); in stmpe_devices_init()
1336 dev_warn(stmpe->dev, in stmpe_devices_init()
1348 pdata->id = of_alias_get_id(np, "stmpe-i2c"); in stmpe_of_probe()
1349 if (pdata->id < 0) in stmpe_of_probe()
1350 pdata->id = -1; in stmpe_of_probe()
1352 pdata->irq_gpio = of_get_named_gpio_flags(np, "irq-gpio", 0, in stmpe_of_probe()
1353 &pdata->irq_trigger); in stmpe_of_probe()
1354 if (gpio_is_valid(pdata->irq_gpio)) in stmpe_of_probe()
1355 pdata->irq_over_gpio = 1; in stmpe_of_probe()
1357 pdata->irq_trigger = IRQF_TRIGGER_NONE; in stmpe_of_probe()
1359 of_property_read_u32(np, "st,autosleep-timeout", in stmpe_of_probe()
1360 &pdata->autosleep_timeout); in stmpe_of_probe()
1362 pdata->autosleep = (pdata->autosleep_timeout) ? true : false; in stmpe_of_probe()
1366 pdata->blocks |= STMPE_BLOCK_GPIO; in stmpe_of_probe()
1368 pdata->blocks |= STMPE_BLOCK_KEYPAD; in stmpe_of_probe()
1370 pdata->blocks |= STMPE_BLOCK_TOUCHSCREEN; in stmpe_of_probe()
1372 pdata->blocks |= STMPE_BLOCK_ADC; in stmpe_of_probe()
1374 pdata->blocks |= STMPE_BLOCK_PWM; in stmpe_of_probe()
1376 pdata->blocks |= STMPE_BLOCK_ROTATOR; in stmpe_of_probe()
1385 struct device_node *np = ci->dev->of_node; in stmpe_probe()
1386 struct stmpe *stmpe; in stmpe_probe() local
1390 pdata = devm_kzalloc(ci->dev, sizeof(*pdata), GFP_KERNEL); in stmpe_probe()
1392 return -ENOMEM; in stmpe_probe()
1397 ci->irq = -1; in stmpe_probe()
1399 stmpe = devm_kzalloc(ci->dev, sizeof(struct stmpe), GFP_KERNEL); in stmpe_probe()
1400 if (!stmpe) in stmpe_probe()
1401 return -ENOMEM; in stmpe_probe()
1403 mutex_init(&stmpe->irq_lock); in stmpe_probe()
1404 mutex_init(&stmpe->lock); in stmpe_probe()
1406 if (!of_property_read_u32(np, "st,sample-time", &val)) in stmpe_probe()
1407 stmpe->sample_time = val; in stmpe_probe()
1408 if (!of_property_read_u32(np, "st,mod-12b", &val)) in stmpe_probe()
1409 stmpe->mod_12b = val; in stmpe_probe()
1410 if (!of_property_read_u32(np, "st,ref-sel", &val)) in stmpe_probe()
1411 stmpe->ref_sel = val; in stmpe_probe()
1412 if (!of_property_read_u32(np, "st,adc-freq", &val)) in stmpe_probe()
1413 stmpe->adc_freq = val; in stmpe_probe()
1415 stmpe->dev = ci->dev; in stmpe_probe()
1416 stmpe->client = ci->client; in stmpe_probe()
1417 stmpe->pdata = pdata; in stmpe_probe()
1418 stmpe->ci = ci; in stmpe_probe()
1419 stmpe->partnum = partnum; in stmpe_probe()
1420 stmpe->variant = stmpe_variant_info[partnum]; in stmpe_probe()
1421 stmpe->regs = stmpe->variant->regs; in stmpe_probe()
1422 stmpe->num_gpios = stmpe->variant->num_gpios; in stmpe_probe()
1423 stmpe->vcc = devm_regulator_get_optional(ci->dev, "vcc"); in stmpe_probe()
1424 if (!IS_ERR(stmpe->vcc)) { in stmpe_probe()
1425 ret = regulator_enable(stmpe->vcc); in stmpe_probe()
1427 dev_warn(ci->dev, "failed to enable VCC supply\n"); in stmpe_probe()
1429 stmpe->vio = devm_regulator_get_optional(ci->dev, "vio"); in stmpe_probe()
1430 if (!IS_ERR(stmpe->vio)) { in stmpe_probe()
1431 ret = regulator_enable(stmpe->vio); in stmpe_probe()
1433 dev_warn(ci->dev, "failed to enable VIO supply\n"); in stmpe_probe()
1435 dev_set_drvdata(stmpe->dev, stmpe); in stmpe_probe()
1437 if (ci->init) in stmpe_probe()
1438 ci->init(stmpe); in stmpe_probe()
1440 if (pdata->irq_over_gpio) { in stmpe_probe()
1441 ret = devm_gpio_request_one(ci->dev, pdata->irq_gpio, in stmpe_probe()
1442 GPIOF_DIR_IN, "stmpe"); in stmpe_probe()
1444 dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", in stmpe_probe()
1449 stmpe->irq = gpio_to_irq(pdata->irq_gpio); in stmpe_probe()
1451 stmpe->irq = ci->irq; in stmpe_probe()
1454 if (stmpe->irq < 0) { in stmpe_probe()
1455 /* use alternate variant info for no-irq mode, if supported */ in stmpe_probe()
1456 dev_info(stmpe->dev, in stmpe_probe()
1457 "%s configured in no-irq mode by platform data\n", in stmpe_probe()
1458 stmpe->variant->name); in stmpe_probe()
1459 if (!stmpe_noirq_variant_info[stmpe->partnum]) { in stmpe_probe()
1460 dev_err(stmpe->dev, in stmpe_probe()
1461 "%s does not support no-irq mode!\n", in stmpe_probe()
1462 stmpe->variant->name); in stmpe_probe()
1463 return -ENODEV; in stmpe_probe()
1465 stmpe->variant = stmpe_noirq_variant_info[stmpe->partnum]; in stmpe_probe()
1466 } else if (pdata->irq_trigger == IRQF_TRIGGER_NONE) { in stmpe_probe()
1467 pdata->irq_trigger = irq_get_trigger_type(stmpe->irq); in stmpe_probe()
1470 ret = stmpe_chip_init(stmpe); in stmpe_probe()
1474 if (stmpe->irq >= 0) { in stmpe_probe()
1475 ret = stmpe_irq_init(stmpe, np); in stmpe_probe()
1479 ret = devm_request_threaded_irq(ci->dev, stmpe->irq, NULL, in stmpe_probe()
1480 stmpe_irq, pdata->irq_trigger | IRQF_ONESHOT, in stmpe_probe()
1481 "stmpe", stmpe); in stmpe_probe()
1483 dev_err(stmpe->dev, "failed to request IRQ: %d\n", in stmpe_probe()
1489 ret = stmpe_devices_init(stmpe); in stmpe_probe()
1493 dev_err(stmpe->dev, "failed to add children\n"); in stmpe_probe()
1494 mfd_remove_devices(stmpe->dev); in stmpe_probe()
1499 int stmpe_remove(struct stmpe *stmpe) in stmpe_remove() argument
1501 if (!IS_ERR(stmpe->vio)) in stmpe_remove()
1502 regulator_disable(stmpe->vio); in stmpe_remove()
1503 if (!IS_ERR(stmpe->vcc)) in stmpe_remove()
1504 regulator_disable(stmpe->vcc); in stmpe_remove()
1506 __stmpe_disable(stmpe, STMPE_BLOCK_ADC); in stmpe_remove()
1508 mfd_remove_devices(stmpe->dev); in stmpe_remove()
1516 struct stmpe *stmpe = dev_get_drvdata(dev); in stmpe_suspend() local
1518 if (stmpe->irq >= 0 && device_may_wakeup(dev)) in stmpe_suspend()
1519 enable_irq_wake(stmpe->irq); in stmpe_suspend()
1526 struct stmpe *stmpe = dev_get_drvdata(dev); in stmpe_resume() local
1528 if (stmpe->irq >= 0 && device_may_wakeup(dev)) in stmpe_resume()
1529 disable_irq_wake(stmpe->irq); in stmpe_resume()