Lines Matching +full:codec +full:- +full:irq
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2009-2010 Pengutronix
4 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
51 if (!mutex_trylock(&mc13xxx->lock)) { in mc13xxx_lock()
52 dev_dbg(mc13xxx->dev, "wait for %s from %ps\n", in mc13xxx_lock()
55 mutex_lock(&mc13xxx->lock); in mc13xxx_lock()
57 dev_dbg(mc13xxx->dev, "%s from %ps\n", in mc13xxx_lock()
64 dev_dbg(mc13xxx->dev, "%s from %ps\n", in mc13xxx_unlock()
66 mutex_unlock(&mc13xxx->lock); in mc13xxx_unlock()
74 ret = regmap_read(mc13xxx->regmap, offset, val); in mc13xxx_reg_read()
75 dev_vdbg(mc13xxx->dev, "[0x%02x] -> 0x%06x\n", offset, *val); in mc13xxx_reg_read()
83 dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val); in mc13xxx_reg_write()
86 return -EINVAL; in mc13xxx_reg_write()
88 return regmap_write(mc13xxx->regmap, offset, val); in mc13xxx_reg_write()
96 dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x (mask: 0x%06x)\n", in mc13xxx_reg_rmw()
99 return regmap_update_bits(mc13xxx->regmap, offset, mask, val); in mc13xxx_reg_rmw()
103 int mc13xxx_irq_mask(struct mc13xxx *mc13xxx, int irq) in mc13xxx_irq_mask() argument
105 int virq = regmap_irq_get_virq(mc13xxx->irq_data, irq); in mc13xxx_irq_mask()
113 int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq) in mc13xxx_irq_unmask() argument
115 int virq = regmap_irq_get_virq(mc13xxx->irq_data, irq); in mc13xxx_irq_unmask()
123 int mc13xxx_irq_status(struct mc13xxx *mc13xxx, int irq, in mc13xxx_irq_status() argument
127 unsigned int offmask = irq < 24 ? MC13XXX_IRQMASK0 : MC13XXX_IRQMASK1; in mc13xxx_irq_status()
128 unsigned int offstat = irq < 24 ? MC13XXX_IRQSTAT0 : MC13XXX_IRQSTAT1; in mc13xxx_irq_status()
129 u32 irqbit = 1 << (irq < 24 ? irq : irq - 24); in mc13xxx_irq_status()
131 if (irq < 0 || irq >= ARRAY_SIZE(mc13xxx->irqs)) in mc13xxx_irq_status()
132 return -EINVAL; in mc13xxx_irq_status()
158 int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq, in mc13xxx_irq_request() argument
161 int virq = regmap_irq_get_virq(mc13xxx->irq_data, irq); in mc13xxx_irq_request()
163 return devm_request_threaded_irq(mc13xxx->dev, virq, NULL, handler, in mc13xxx_irq_request()
168 int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev) in mc13xxx_irq_free() argument
170 int virq = regmap_irq_get_virq(mc13xxx->irq_data, irq); in mc13xxx_irq_free()
172 devm_free_irq(mc13xxx->dev, virq, dev); in mc13xxx_irq_free()
180 dev_info(mc13xxx->dev, "%s: rev: %d.%d, " in mc13xxx_print_revision()
182 mc13xxx->variant->name, in mc13xxx_print_revision()
193 dev_info(mc13xxx->dev, "%s: rev %d.%d, fin: %d, fab: %d\n", in mc34708_print_revision()
194 mc13xxx->variant->name, in mc34708_print_revision()
201 /* These are only exported for mc13xxx-i2c and mc13xxx-spi */
222 return mc13xxx->variant->name; in mc13xxx_get_chipname()
227 return mc13xxx->flags; in mc13xxx_get_flags()
241 static irqreturn_t mc13xxx_handler_adcdone(int irq, void *data) in mc13xxx_handler_adcdone() argument
245 complete_all(&adcdone_data->done); in mc13xxx_handler_adcdone()
263 dev_dbg(mc13xxx->dev, "%s\n", __func__); in mc13xxx_adc_do_conversion()
267 if (mc13xxx->adcflags & MC13XXX_ADC_WORKING) { in mc13xxx_adc_do_conversion()
268 ret = -EBUSY; in mc13xxx_adc_do_conversion()
272 mc13xxx->adcflags |= MC13XXX_ADC_WORKING; in mc13xxx_adc_do_conversion()
284 * 7 - General purpose ADIN7 in mc13xxx_adc_do_conversion()
285 * 16 - UID in mc13xxx_adc_do_conversion()
286 * 17 - Die temperature in mc13xxx_adc_do_conversion()
318 return -EINVAL; in mc13xxx_adc_do_conversion()
325 dev_dbg(mc13xxx->dev, "%s: request irq\n", __func__); in mc13xxx_adc_do_conversion()
339 ret = -ETIMEDOUT; in mc13xxx_adc_do_conversion()
357 mc13xxx->adcflags &= ~MC13XXX_ADC_WORKING; in mc13xxx_adc_do_conversion()
376 /* there is no asnprintf in the kernel :-( */ in mc13xxx_add_subdevice_pdata()
378 return -E2BIG; in mc13xxx_add_subdevice_pdata()
382 return -ENOMEM; in mc13xxx_add_subdevice_pdata()
384 return mfd_add_devices(mc13xxx->dev, -1, &cell, 1, NULL, 0, in mc13xxx_add_subdevice_pdata()
385 regmap_irq_get_domain(mc13xxx->irq_data)); in mc13xxx_add_subdevice_pdata()
396 struct device_node *np = mc13xxx->dev->of_node; in mc13xxx_probe_flags_dt()
399 return -ENODEV; in mc13xxx_probe_flags_dt()
401 if (of_property_read_bool(np, "fsl,mc13xxx-uses-adc")) in mc13xxx_probe_flags_dt()
402 mc13xxx->flags |= MC13XXX_USE_ADC; in mc13xxx_probe_flags_dt()
404 if (of_property_read_bool(np, "fsl,mc13xxx-uses-codec")) in mc13xxx_probe_flags_dt()
405 mc13xxx->flags |= MC13XXX_USE_CODEC; in mc13xxx_probe_flags_dt()
407 if (of_property_read_bool(np, "fsl,mc13xxx-uses-rtc")) in mc13xxx_probe_flags_dt()
408 mc13xxx->flags |= MC13XXX_USE_RTC; in mc13xxx_probe_flags_dt()
410 if (of_property_read_bool(np, "fsl,mc13xxx-uses-touch")) in mc13xxx_probe_flags_dt()
411 mc13xxx->flags |= MC13XXX_USE_TOUCHSCREEN; in mc13xxx_probe_flags_dt()
418 return -ENODEV; in mc13xxx_probe_flags_dt()
429 mc13xxx->dev = dev; in mc13xxx_common_init()
435 mc13xxx->variant->print_revision(mc13xxx, revision); in mc13xxx_common_init()
442 for (i = 0; i < ARRAY_SIZE(mc13xxx->irqs); i++) { in mc13xxx_common_init()
443 mc13xxx->irqs[i].reg_offset = i / MC13XXX_IRQ_PER_REG; in mc13xxx_common_init()
444 mc13xxx->irqs[i].mask = BIT(i % MC13XXX_IRQ_PER_REG); in mc13xxx_common_init()
447 mc13xxx->irq_chip.name = dev_name(dev); in mc13xxx_common_init()
448 mc13xxx->irq_chip.status_base = MC13XXX_IRQSTAT0; in mc13xxx_common_init()
449 mc13xxx->irq_chip.mask_base = MC13XXX_IRQMASK0; in mc13xxx_common_init()
450 mc13xxx->irq_chip.ack_base = MC13XXX_IRQSTAT0; in mc13xxx_common_init()
451 mc13xxx->irq_chip.irq_reg_stride = MC13XXX_IRQSTAT1 - MC13XXX_IRQSTAT0; in mc13xxx_common_init()
452 mc13xxx->irq_chip.init_ack_masked = true; in mc13xxx_common_init()
453 mc13xxx->irq_chip.use_ack = true; in mc13xxx_common_init()
454 mc13xxx->irq_chip.num_regs = MC13XXX_IRQ_REG_CNT; in mc13xxx_common_init()
455 mc13xxx->irq_chip.irqs = mc13xxx->irqs; in mc13xxx_common_init()
456 mc13xxx->irq_chip.num_irqs = ARRAY_SIZE(mc13xxx->irqs); in mc13xxx_common_init()
458 ret = regmap_add_irq_chip(mc13xxx->regmap, mc13xxx->irq, IRQF_ONESHOT, in mc13xxx_common_init()
459 0, &mc13xxx->irq_chip, &mc13xxx->irq_data); in mc13xxx_common_init()
463 mutex_init(&mc13xxx->lock); in mc13xxx_common_init()
466 mc13xxx->flags = pdata->flags; in mc13xxx_common_init()
469 mc13xxx_add_subdevice_pdata(mc13xxx, "%s-regulator", in mc13xxx_common_init()
470 &pdata->regulators, sizeof(pdata->regulators)); in mc13xxx_common_init()
471 mc13xxx_add_subdevice_pdata(mc13xxx, "%s-led", in mc13xxx_common_init()
472 pdata->leds, sizeof(*pdata->leds)); in mc13xxx_common_init()
473 mc13xxx_add_subdevice_pdata(mc13xxx, "%s-pwrbutton", in mc13xxx_common_init()
474 pdata->buttons, sizeof(*pdata->buttons)); in mc13xxx_common_init()
475 if (mc13xxx->flags & MC13XXX_USE_CODEC) in mc13xxx_common_init()
476 mc13xxx_add_subdevice_pdata(mc13xxx, "%s-codec", in mc13xxx_common_init()
477 pdata->codec, sizeof(*pdata->codec)); in mc13xxx_common_init()
478 if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN) in mc13xxx_common_init()
479 mc13xxx_add_subdevice_pdata(mc13xxx, "%s-ts", in mc13xxx_common_init()
480 &pdata->touch, sizeof(pdata->touch)); in mc13xxx_common_init()
482 mc13xxx_add_subdevice(mc13xxx, "%s-regulator"); in mc13xxx_common_init()
483 mc13xxx_add_subdevice(mc13xxx, "%s-led"); in mc13xxx_common_init()
484 mc13xxx_add_subdevice(mc13xxx, "%s-pwrbutton"); in mc13xxx_common_init()
485 if (mc13xxx->flags & MC13XXX_USE_CODEC) in mc13xxx_common_init()
486 mc13xxx_add_subdevice(mc13xxx, "%s-codec"); in mc13xxx_common_init()
487 if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN) in mc13xxx_common_init()
488 mc13xxx_add_subdevice(mc13xxx, "%s-ts"); in mc13xxx_common_init()
491 if (mc13xxx->flags & MC13XXX_USE_ADC) in mc13xxx_common_init()
492 mc13xxx_add_subdevice(mc13xxx, "%s-adc"); in mc13xxx_common_init()
494 if (mc13xxx->flags & MC13XXX_USE_RTC) in mc13xxx_common_init()
495 mc13xxx_add_subdevice(mc13xxx, "%s-rtc"); in mc13xxx_common_init()
506 regmap_del_irq_chip(mc13xxx->irq, mc13xxx->irq_data); in mc13xxx_common_exit()
507 mutex_destroy(&mc13xxx->lock); in mc13xxx_common_exit()
512 MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>");