Lines Matching refs:madc

178 	struct twl4030_madc_data *madc = iio_priv(iio_dev);  in twl4030_madc_read()  local
182 req.method = madc->use_second_irq ? TWL4030_MADC_SW2 : TWL4030_MADC_SW1; in twl4030_madc_read()
308 static int twl4030_madc_channel_raw_read(struct twl4030_madc_data *madc, u8 reg) in twl4030_madc_channel_raw_read() argument
318 dev_err(madc->dev, "unable to read register 0x%X\n", reg); in twl4030_madc_channel_raw_read()
379 static int twl4030_madc_read_channels(struct twl4030_madc_data *madc, in twl4030_madc_read_channels() argument
390 buf[i] = twl4030_madc_channel_raw_read(madc, reg); in twl4030_madc_read_channels()
392 dev_err(madc->dev, "Unable to read register 0x%X\n", in twl4030_madc_read_channels()
404 dev_err(madc->dev, "err reading current\n"); in twl4030_madc_read_channels()
414 dev_err(madc->dev, "err reading temperature\n"); in twl4030_madc_read_channels()
448 static int twl4030_madc_disable_irq(struct twl4030_madc_data *madc, u8 id) in twl4030_madc_disable_irq() argument
453 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &val, madc->imr); in twl4030_madc_disable_irq()
455 dev_err(madc->dev, "unable to read imr register 0x%X\n", in twl4030_madc_disable_irq()
456 madc->imr); in twl4030_madc_disable_irq()
460 ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, val, madc->imr); in twl4030_madc_disable_irq()
462 dev_err(madc->dev, in twl4030_madc_disable_irq()
463 "unable to write imr register 0x%X\n", madc->imr); in twl4030_madc_disable_irq()
472 struct twl4030_madc_data *madc = _madc; in twl4030_madc_threaded_irq_handler() local
478 mutex_lock(&madc->lock); in twl4030_madc_threaded_irq_handler()
479 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &isr_val, madc->isr); in twl4030_madc_threaded_irq_handler()
481 dev_err(madc->dev, "unable to read isr register 0x%X\n", in twl4030_madc_threaded_irq_handler()
482 madc->isr); in twl4030_madc_threaded_irq_handler()
485 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &imr_val, madc->imr); in twl4030_madc_threaded_irq_handler()
487 dev_err(madc->dev, "unable to read imr register 0x%X\n", in twl4030_madc_threaded_irq_handler()
488 madc->imr); in twl4030_madc_threaded_irq_handler()
495 ret = twl4030_madc_disable_irq(madc, i); in twl4030_madc_threaded_irq_handler()
497 dev_dbg(madc->dev, "Disable interrupt failed %d\n", i); in twl4030_madc_threaded_irq_handler()
498 madc->requests[i].result_pending = true; in twl4030_madc_threaded_irq_handler()
501 r = &madc->requests[i]; in twl4030_madc_threaded_irq_handler()
507 twl4030_madc_read_channels(madc, method->rbase, in twl4030_madc_threaded_irq_handler()
513 mutex_unlock(&madc->lock); in twl4030_madc_threaded_irq_handler()
523 r = &madc->requests[i]; in twl4030_madc_threaded_irq_handler()
528 twl4030_madc_read_channels(madc, method->rbase, in twl4030_madc_threaded_irq_handler()
534 mutex_unlock(&madc->lock); in twl4030_madc_threaded_irq_handler()
547 static int twl4030_madc_start_conversion(struct twl4030_madc_data *madc, in twl4030_madc_start_conversion() argument
560 dev_err(madc->dev, "unable to write ctrl register 0x%X\n", in twl4030_madc_start_conversion()
575 static int twl4030_madc_wait_conversion_ready(struct twl4030_madc_data *madc, in twl4030_madc_wait_conversion_ready() argument
588 dev_err(madc->dev, in twl4030_madc_wait_conversion_ready()
597 dev_err(madc->dev, "conversion timeout!\n"); in twl4030_madc_wait_conversion_ready()
684 static int twl4030_madc_set_current_generator(struct twl4030_madc_data *madc, in twl4030_madc_set_current_generator() argument
694 dev_err(madc->dev, "unable to read BCICTL1 reg 0x%X", in twl4030_madc_set_current_generator()
708 dev_err(madc->dev, "unable to write BCICTL1 reg 0x%X\n", in twl4030_madc_set_current_generator()
722 static int twl4030_madc_set_power(struct twl4030_madc_data *madc, int on) in twl4030_madc_set_power() argument
730 dev_err(madc->dev, "unable to read madc ctrl1 reg 0x%X\n", in twl4030_madc_set_power()
740 dev_err(madc->dev, "unable to write madc ctrl1 reg 0x%X\n", in twl4030_madc_set_power()
753 struct twl4030_madc_data *madc; in twl4030_madc_probe() local
765 iio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*madc)); in twl4030_madc_probe()
771 madc = iio_priv(iio_dev); in twl4030_madc_probe()
772 madc->dev = &pdev->dev; in twl4030_madc_probe()
786 madc->use_second_irq = (pdata->irq_line != 1); in twl4030_madc_probe()
788 madc->use_second_irq = of_property_read_bool(np, in twl4030_madc_probe()
791 madc->imr = madc->use_second_irq ? TWL4030_MADC_IMR2 : in twl4030_madc_probe()
793 madc->isr = madc->use_second_irq ? TWL4030_MADC_ISR2 : in twl4030_madc_probe()
796 ret = twl4030_madc_set_power(madc, 1); in twl4030_madc_probe()
799 ret = twl4030_madc_set_current_generator(madc, 0, 1); in twl4030_madc_probe()
841 mutex_init(&madc->lock); in twl4030_madc_probe()
847 "twl4030_madc", madc); in twl4030_madc_probe()
852 twl4030_madc = madc; in twl4030_madc_probe()
872 madc->usb3v1 = devm_regulator_get(madc->dev, "vusb3v1"); in twl4030_madc_probe()
873 if (IS_ERR(madc->usb3v1)) { in twl4030_madc_probe()
878 ret = regulator_enable(madc->usb3v1); in twl4030_madc_probe()
880 dev_err(madc->dev, "could not enable 3v1 bias regulator\n"); in twl4030_madc_probe()
893 regulator_disable(madc->usb3v1); in twl4030_madc_probe()
895 twl4030_madc_set_current_generator(madc, 0, 0); in twl4030_madc_probe()
897 twl4030_madc_set_power(madc, 0); in twl4030_madc_probe()
904 struct twl4030_madc_data *madc = iio_priv(iio_dev); in twl4030_madc_remove() local
908 twl4030_madc_set_current_generator(madc, 0, 0); in twl4030_madc_remove()
909 twl4030_madc_set_power(madc, 0); in twl4030_madc_remove()
911 regulator_disable(madc->usb3v1); in twl4030_madc_remove()