Lines Matching defs:madc

10  * Based on twl4030-madc.c
40 #include <linux/i2c/twl4030-madc.h>
51 * struct twl4030_madc_data - a container for madc info
52 * @dev - pointer to device structure for madc
138 * @madc - pointer to struct twl4030_madc_data
142 static int twl4030_madc_channel_raw_read(struct twl4030_madc_data *madc, u8 reg)
152 dev_err(madc->dev, "unable to read MSB register 0x%X\n",
158 dev_err(madc->dev, "unable to read LSB register 0x%X\n", reg);
210 * @madc - pointer to twl4030_madc_data struct
217 static int twl4030_madc_read_channels(struct twl4030_madc_data *madc,
226 buf[i] = twl4030_madc_channel_raw_read(madc, reg);
228 dev_err(madc->dev,
237 dev_err(madc->dev, "err reading current\n");
247 dev_err(madc->dev, "err reading temperature\n");
270 dev_err(madc->dev, "%d channel conversion failed\n", count_req);
277 * @madc - pointer to twl4030_madc_data struct
283 static int twl4030_madc_enable_irq(struct twl4030_madc_data *madc, u8 id)
288 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &val, madc->imr);
290 dev_err(madc->dev, "unable to read imr register 0x%X\n",
291 madc->imr);
295 ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, val, madc->imr);
297 dev_err(madc->dev,
298 "unable to write imr register 0x%X\n", madc->imr);
308 * @madc - pointer to twl4030_madc_data struct
314 static int twl4030_madc_disable_irq(struct twl4030_madc_data *madc, u8 id)
319 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &val, madc->imr);
321 dev_err(madc->dev, "unable to read imr register 0x%X\n",
322 madc->imr);
326 ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, val, madc->imr);
328 dev_err(madc->dev,
329 "unable to write imr register 0x%X\n", madc->imr);
338 struct twl4030_madc_data *madc = _madc;
344 mutex_lock(&madc->lock);
345 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &isr_val, madc->isr);
347 dev_err(madc->dev, "unable to read isr register 0x%X\n",
348 madc->isr);
351 ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &imr_val, madc->imr);
353 dev_err(madc->dev, "unable to read imr register 0x%X\n",
354 madc->imr);
361 ret = twl4030_madc_disable_irq(madc, i);
363 dev_dbg(madc->dev, "Disable interrupt failed%d\n", i);
364 madc->requests[i].result_pending = 1;
367 r = &madc->requests[i];
373 len = twl4030_madc_read_channels(madc, method->rbase,
384 mutex_unlock(&madc->lock);
394 r = &madc->requests[i];
399 len = twl4030_madc_read_channels(madc, method->rbase,
410 mutex_unlock(&madc->lock);
415 static int twl4030_madc_set_irq(struct twl4030_madc_data *madc,
421 p = &madc->requests[req->method];
423 ret = twl4030_madc_enable_irq(madc, req->method);
425 dev_err(madc->dev, "enable irq failed!!\n");
433 * Function which enables the madc conversion
435 * @madc - pointer to twl4030_madc_data struct
440 static int twl4030_madc_start_conversion(struct twl4030_madc_data *madc,
452 dev_err(madc->dev,
467 * @madc - pointer to twl4030_madc_data struct
472 static int twl4030_madc_wait_conversion_ready(struct twl4030_madc_data *madc,
485 dev_err(madc->dev,
494 dev_err(madc->dev, "conversion timeout!\n");
625 * @madc - pointer to twl4030_madc_data struct
632 static int twl4030_madc_set_current_generator(struct twl4030_madc_data *madc,
641 dev_err(madc->dev, "unable to read BCICTL1 reg 0x%X",
652 dev_err(madc->dev, "unable to write BCICTL1 reg 0x%X\n",
662 * @madc - pointer to twl4030_madc_data struct
666 static int twl4030_madc_set_power(struct twl4030_madc_data *madc, int on)
674 dev_err(madc->dev, "unable to read madc ctrl1 reg 0x%X\n",
684 dev_err(madc->dev, "unable to write madc ctrl1 reg 0x%X\n",
697 struct twl4030_madc_data *madc;
706 madc = kzalloc(sizeof(*madc), GFP_KERNEL);
707 if (!madc)
710 madc->dev = &pdev->dev;
717 madc->imr = (pdata->irq_line == 1) ?
719 madc->isr = (pdata->irq_line == 1) ?
721 ret = twl4030_madc_set_power(madc, 1);
724 ret = twl4030_madc_set_current_generator(madc, 0, 1);
765 platform_set_drvdata(pdev, madc);
766 mutex_init(&madc->lock);
769 IRQF_TRIGGER_RISING, "twl4030_madc", madc);
774 twl4030_madc = madc;
779 twl4030_madc_set_current_generator(madc, 0, 0);
781 twl4030_madc_set_power(madc, 0);
783 kfree(madc);
790 struct twl4030_madc_data *madc = platform_get_drvdata(pdev);
792 free_irq(platform_get_irq(pdev, 0), madc);
794 twl4030_madc_set_current_generator(madc, 0, 0);
795 twl4030_madc_set_power(madc, 0);
796 kfree(madc);