Lines Matching refs:madc

180 	struct twl4030_madc_data *madc = iio_priv(iio_dev);  in twl4030_madc_read()  local
184 req.method = madc->use_second_irq ? TWL4030_MADC_SW2 : TWL4030_MADC_SW1; in twl4030_madc_read()
303 static int twl4030_madc_channel_raw_read(struct twl4030_madc_data *madc, u8 reg) in twl4030_madc_channel_raw_read() argument
313 dev_err(madc->dev, "unable to read register 0x%X\n", reg); in twl4030_madc_channel_raw_read()
374 static int twl4030_madc_read_channels(struct twl4030_madc_data *madc, in twl4030_madc_read_channels() argument
385 buf[i] = twl4030_madc_channel_raw_read(madc, reg); in twl4030_madc_read_channels()
387 dev_err(madc->dev, "Unable to read register 0x%X\n", in twl4030_madc_read_channels()
399 dev_err(madc->dev, "err reading current\n"); in twl4030_madc_read_channels()
409 dev_err(madc->dev, "err reading temperature\n"); in twl4030_madc_read_channels()
443 static int twl4030_madc_disable_irq(struct twl4030_madc_data *madc, u8 id) in twl4030_madc_disable_irq() argument
448 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &val, madc->imr); in twl4030_madc_disable_irq()
450 dev_err(madc->dev, "unable to read imr register 0x%X\n", in twl4030_madc_disable_irq()
451 madc->imr); in twl4030_madc_disable_irq()
455 ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, val, madc->imr); in twl4030_madc_disable_irq()
457 dev_err(madc->dev, in twl4030_madc_disable_irq()
458 "unable to write imr register 0x%X\n", madc->imr); in twl4030_madc_disable_irq()
467 struct twl4030_madc_data *madc = _madc; in twl4030_madc_threaded_irq_handler() local
473 mutex_lock(&madc->lock); in twl4030_madc_threaded_irq_handler()
474 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &isr_val, madc->isr); in twl4030_madc_threaded_irq_handler()
476 dev_err(madc->dev, "unable to read isr register 0x%X\n", in twl4030_madc_threaded_irq_handler()
477 madc->isr); in twl4030_madc_threaded_irq_handler()
480 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &imr_val, madc->imr); in twl4030_madc_threaded_irq_handler()
482 dev_err(madc->dev, "unable to read imr register 0x%X\n", in twl4030_madc_threaded_irq_handler()
483 madc->imr); in twl4030_madc_threaded_irq_handler()
490 ret = twl4030_madc_disable_irq(madc, i); in twl4030_madc_threaded_irq_handler()
492 dev_dbg(madc->dev, "Disable interrupt failed %d\n", i); in twl4030_madc_threaded_irq_handler()
493 madc->requests[i].result_pending = true; in twl4030_madc_threaded_irq_handler()
496 r = &madc->requests[i]; in twl4030_madc_threaded_irq_handler()
502 twl4030_madc_read_channels(madc, method->rbase, in twl4030_madc_threaded_irq_handler()
508 mutex_unlock(&madc->lock); in twl4030_madc_threaded_irq_handler()
518 r = &madc->requests[i]; in twl4030_madc_threaded_irq_handler()
523 twl4030_madc_read_channels(madc, method->rbase, in twl4030_madc_threaded_irq_handler()
529 mutex_unlock(&madc->lock); in twl4030_madc_threaded_irq_handler()
542 static int twl4030_madc_start_conversion(struct twl4030_madc_data *madc, in twl4030_madc_start_conversion() argument
555 dev_err(madc->dev, "unable to write ctrl register 0x%X\n", in twl4030_madc_start_conversion()
570 static int twl4030_madc_wait_conversion_ready(struct twl4030_madc_data *madc, in twl4030_madc_wait_conversion_ready() argument
583 dev_err(madc->dev, in twl4030_madc_wait_conversion_ready()
592 dev_err(madc->dev, "conversion timeout!\n"); in twl4030_madc_wait_conversion_ready()
679 static int twl4030_madc_set_current_generator(struct twl4030_madc_data *madc, in twl4030_madc_set_current_generator() argument
689 dev_err(madc->dev, "unable to read BCICTL1 reg 0x%X", in twl4030_madc_set_current_generator()
703 dev_err(madc->dev, "unable to write BCICTL1 reg 0x%X\n", in twl4030_madc_set_current_generator()
717 static int twl4030_madc_set_power(struct twl4030_madc_data *madc, int on) in twl4030_madc_set_power() argument
725 dev_err(madc->dev, "unable to read madc ctrl1 reg 0x%X\n", in twl4030_madc_set_power()
735 dev_err(madc->dev, "unable to write madc ctrl1 reg 0x%X\n", in twl4030_madc_set_power()
750 struct twl4030_madc_data *madc; in twl4030_madc_probe() local
760 iio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*madc)); in twl4030_madc_probe()
766 madc = iio_priv(iio_dev); in twl4030_madc_probe()
767 madc->dev = &pdev->dev; in twl4030_madc_probe()
781 madc->use_second_irq = (pdata->irq_line != 1); in twl4030_madc_probe()
783 madc->use_second_irq = device_property_read_bool(dev, in twl4030_madc_probe()
786 madc->imr = madc->use_second_irq ? TWL4030_MADC_IMR2 : in twl4030_madc_probe()
788 madc->isr = madc->use_second_irq ? TWL4030_MADC_ISR2 : in twl4030_madc_probe()
791 ret = twl4030_madc_set_power(madc, 1); in twl4030_madc_probe()
794 ret = twl4030_madc_set_current_generator(madc, 0, 1); in twl4030_madc_probe()
836 mutex_init(&madc->lock); in twl4030_madc_probe()
842 "twl4030_madc", madc); in twl4030_madc_probe()
847 twl4030_madc = madc; in twl4030_madc_probe()
867 madc->usb3v1 = devm_regulator_get(madc->dev, "vusb3v1"); in twl4030_madc_probe()
868 if (IS_ERR(madc->usb3v1)) { in twl4030_madc_probe()
873 ret = regulator_enable(madc->usb3v1); in twl4030_madc_probe()
875 dev_err(madc->dev, "could not enable 3v1 bias regulator\n"); in twl4030_madc_probe()
888 regulator_disable(madc->usb3v1); in twl4030_madc_probe()
890 twl4030_madc_set_current_generator(madc, 0, 0); in twl4030_madc_probe()
892 twl4030_madc_set_power(madc, 0); in twl4030_madc_probe()
899 struct twl4030_madc_data *madc = iio_priv(iio_dev); in twl4030_madc_remove() local
903 twl4030_madc_set_current_generator(madc, 0, 0); in twl4030_madc_remove()
904 twl4030_madc_set_power(madc, 0); in twl4030_madc_remove()
906 regulator_disable(madc->usb3v1); in twl4030_madc_remove()