Lines Matching refs:info

163 	void (*init_hw)(struct exynos_adc *info);
164 void (*exit_hw)(struct exynos_adc *info);
165 void (*clear_irq)(struct exynos_adc *info);
166 void (*start_conv)(struct exynos_adc *info, unsigned long addr);
169 static void exynos_adc_unprepare_clk(struct exynos_adc *info) in exynos_adc_unprepare_clk() argument
171 if (info->data->needs_sclk) in exynos_adc_unprepare_clk()
172 clk_unprepare(info->sclk); in exynos_adc_unprepare_clk()
173 clk_unprepare(info->clk); in exynos_adc_unprepare_clk()
176 static int exynos_adc_prepare_clk(struct exynos_adc *info) in exynos_adc_prepare_clk() argument
180 ret = clk_prepare(info->clk); in exynos_adc_prepare_clk()
182 dev_err(info->dev, "failed preparing adc clock: %d\n", ret); in exynos_adc_prepare_clk()
186 if (info->data->needs_sclk) { in exynos_adc_prepare_clk()
187 ret = clk_prepare(info->sclk); in exynos_adc_prepare_clk()
189 clk_unprepare(info->clk); in exynos_adc_prepare_clk()
190 dev_err(info->dev, in exynos_adc_prepare_clk()
199 static void exynos_adc_disable_clk(struct exynos_adc *info) in exynos_adc_disable_clk() argument
201 if (info->data->needs_sclk) in exynos_adc_disable_clk()
202 clk_disable(info->sclk); in exynos_adc_disable_clk()
203 clk_disable(info->clk); in exynos_adc_disable_clk()
206 static int exynos_adc_enable_clk(struct exynos_adc *info) in exynos_adc_enable_clk() argument
210 ret = clk_enable(info->clk); in exynos_adc_enable_clk()
212 dev_err(info->dev, "failed enabling adc clock: %d\n", ret); in exynos_adc_enable_clk()
216 if (info->data->needs_sclk) { in exynos_adc_enable_clk()
217 ret = clk_enable(info->sclk); in exynos_adc_enable_clk()
219 clk_disable(info->clk); in exynos_adc_enable_clk()
220 dev_err(info->dev, in exynos_adc_enable_clk()
229 static void exynos_adc_v1_init_hw(struct exynos_adc *info) in exynos_adc_v1_init_hw() argument
233 if (info->data->needs_adc_phy) in exynos_adc_v1_init_hw()
234 regmap_write(info->pmu_map, info->data->phy_offset, 1); in exynos_adc_v1_init_hw()
241 writel(con1, ADC_V1_CON(info->regs)); in exynos_adc_v1_init_hw()
244 writel(info->delay, ADC_V1_DLY(info->regs)); in exynos_adc_v1_init_hw()
247 static void exynos_adc_v1_exit_hw(struct exynos_adc *info) in exynos_adc_v1_exit_hw() argument
251 if (info->data->needs_adc_phy) in exynos_adc_v1_exit_hw()
252 regmap_write(info->pmu_map, info->data->phy_offset, 0); in exynos_adc_v1_exit_hw()
254 con = readl(ADC_V1_CON(info->regs)); in exynos_adc_v1_exit_hw()
256 writel(con, ADC_V1_CON(info->regs)); in exynos_adc_v1_exit_hw()
259 static void exynos_adc_v1_clear_irq(struct exynos_adc *info) in exynos_adc_v1_clear_irq() argument
261 writel(1, ADC_V1_INTCLR(info->regs)); in exynos_adc_v1_clear_irq()
264 static void exynos_adc_v1_start_conv(struct exynos_adc *info, in exynos_adc_v1_start_conv() argument
269 writel(addr, ADC_V1_MUX(info->regs)); in exynos_adc_v1_start_conv()
271 con1 = readl(ADC_V1_CON(info->regs)); in exynos_adc_v1_start_conv()
272 writel(con1 | ADC_CON_EN_START, ADC_V1_CON(info->regs)); in exynos_adc_v1_start_conv()
310 static void exynos_adc_s3c2416_start_conv(struct exynos_adc *info, in exynos_adc_s3c2416_start_conv() argument
316 con1 = readl(ADC_V1_CON(info->regs)); in exynos_adc_s3c2416_start_conv()
318 writel(con1, ADC_V1_CON(info->regs)); in exynos_adc_s3c2416_start_conv()
321 writel(addr, ADC_S3C2410_MUX(info->regs)); in exynos_adc_s3c2416_start_conv()
323 con1 = readl(ADC_V1_CON(info->regs)); in exynos_adc_s3c2416_start_conv()
324 writel(con1 | ADC_CON_EN_START, ADC_V1_CON(info->regs)); in exynos_adc_s3c2416_start_conv()
336 static void exynos_adc_s3c2443_start_conv(struct exynos_adc *info, in exynos_adc_s3c2443_start_conv() argument
342 writel(addr, ADC_S3C2410_MUX(info->regs)); in exynos_adc_s3c2443_start_conv()
344 con1 = readl(ADC_V1_CON(info->regs)); in exynos_adc_s3c2443_start_conv()
345 writel(con1 | ADC_CON_EN_START, ADC_V1_CON(info->regs)); in exynos_adc_s3c2443_start_conv()
357 static void exynos_adc_s3c64xx_start_conv(struct exynos_adc *info, in exynos_adc_s3c64xx_start_conv() argument
362 con1 = readl(ADC_V1_CON(info->regs)); in exynos_adc_s3c64xx_start_conv()
365 writel(con1 | ADC_CON_EN_START, ADC_V1_CON(info->regs)); in exynos_adc_s3c64xx_start_conv()
387 static void exynos_adc_v2_init_hw(struct exynos_adc *info) in exynos_adc_v2_init_hw() argument
391 if (info->data->needs_adc_phy) in exynos_adc_v2_init_hw()
392 regmap_write(info->pmu_map, info->data->phy_offset, 1); in exynos_adc_v2_init_hw()
395 writel(con1, ADC_V2_CON1(info->regs)); in exynos_adc_v2_init_hw()
399 writel(con2, ADC_V2_CON2(info->regs)); in exynos_adc_v2_init_hw()
402 writel(1, ADC_V2_INT_EN(info->regs)); in exynos_adc_v2_init_hw()
405 static void exynos_adc_v2_exit_hw(struct exynos_adc *info) in exynos_adc_v2_exit_hw() argument
409 if (info->data->needs_adc_phy) in exynos_adc_v2_exit_hw()
410 regmap_write(info->pmu_map, info->data->phy_offset, 0); in exynos_adc_v2_exit_hw()
412 con = readl(ADC_V2_CON1(info->regs)); in exynos_adc_v2_exit_hw()
414 writel(con, ADC_V2_CON1(info->regs)); in exynos_adc_v2_exit_hw()
417 static void exynos_adc_v2_clear_irq(struct exynos_adc *info) in exynos_adc_v2_clear_irq() argument
419 writel(1, ADC_V2_INT_ST(info->regs)); in exynos_adc_v2_clear_irq()
422 static void exynos_adc_v2_start_conv(struct exynos_adc *info, in exynos_adc_v2_start_conv() argument
427 con2 = readl(ADC_V2_CON2(info->regs)); in exynos_adc_v2_start_conv()
430 writel(con2, ADC_V2_CON2(info->regs)); in exynos_adc_v2_start_conv()
432 con1 = readl(ADC_V2_CON1(info->regs)); in exynos_adc_v2_start_conv()
433 writel(con1 | ADC_CON_EN_START, ADC_V2_CON1(info->regs)); in exynos_adc_v2_start_conv()
461 static void exynos_adc_exynos7_init_hw(struct exynos_adc *info) in exynos_adc_exynos7_init_hw() argument
465 if (info->data->needs_adc_phy) in exynos_adc_exynos7_init_hw()
466 regmap_write(info->pmu_map, info->data->phy_offset, 1); in exynos_adc_exynos7_init_hw()
469 writel(con1, ADC_V2_CON1(info->regs)); in exynos_adc_exynos7_init_hw()
471 con2 = readl(ADC_V2_CON2(info->regs)); in exynos_adc_exynos7_init_hw()
474 writel(con2, ADC_V2_CON2(info->regs)); in exynos_adc_exynos7_init_hw()
477 writel(1, ADC_V2_INT_EN(info->regs)); in exynos_adc_exynos7_init_hw()
543 struct exynos_adc *info = iio_priv(indio_dev); in exynos_read_raw() local
551 reinit_completion(&info->completion); in exynos_read_raw()
554 if (info->data->start_conv) in exynos_read_raw()
555 info->data->start_conv(info, chan->address); in exynos_read_raw()
557 timeout = wait_for_completion_timeout(&info->completion, in exynos_read_raw()
561 if (info->data->init_hw) in exynos_read_raw()
562 info->data->init_hw(info); in exynos_read_raw()
565 *val = info->value; in exynos_read_raw()
577 struct exynos_adc *info = iio_priv(indio_dev); in exynos_read_s3c64xx_ts() local
582 info->read_ts = true; in exynos_read_s3c64xx_ts()
584 reinit_completion(&info->completion); in exynos_read_s3c64xx_ts()
587 ADC_V1_TSC(info->regs)); in exynos_read_s3c64xx_ts()
590 info->data->start_conv(info, ADC_S3C2410_MUX_TS); in exynos_read_s3c64xx_ts()
592 timeout = wait_for_completion_timeout(&info->completion, in exynos_read_s3c64xx_ts()
596 if (info->data->init_hw) in exynos_read_s3c64xx_ts()
597 info->data->init_hw(info); in exynos_read_s3c64xx_ts()
600 *x = info->ts_x; in exynos_read_s3c64xx_ts()
601 *y = info->ts_y; in exynos_read_s3c64xx_ts()
605 info->read_ts = false; in exynos_read_s3c64xx_ts()
613 struct exynos_adc *info = dev_id; in exynos_adc_isr() local
614 u32 mask = info->data->mask; in exynos_adc_isr()
617 if (info->read_ts) { in exynos_adc_isr()
618 info->ts_x = readl(ADC_V1_DATX(info->regs)); in exynos_adc_isr()
619 info->ts_y = readl(ADC_V1_DATY(info->regs)); in exynos_adc_isr()
620 writel(ADC_TSC_WAIT4INT | ADC_S3C2443_TSC_UD_SEN, ADC_V1_TSC(info->regs)); in exynos_adc_isr()
622 info->value = readl(ADC_V1_DATX(info->regs)) & mask; in exynos_adc_isr()
626 if (info->data->clear_irq) in exynos_adc_isr()
627 info->data->clear_irq(info); in exynos_adc_isr()
629 complete(&info->completion); in exynos_adc_isr()
643 struct exynos_adc *info = dev_id; in exynos_ts_isr() local
644 struct iio_dev *dev = dev_get_drvdata(info->dev); in exynos_ts_isr()
649 while (info->input->users) { in exynos_ts_isr()
656 input_report_key(info->input, BTN_TOUCH, 0); in exynos_ts_isr()
657 input_sync(info->input); in exynos_ts_isr()
661 input_report_abs(info->input, ABS_X, x & ADC_DATX_MASK); in exynos_ts_isr()
662 input_report_abs(info->input, ABS_Y, y & ADC_DATY_MASK); in exynos_ts_isr()
663 input_report_key(info->input, BTN_TOUCH, 1); in exynos_ts_isr()
664 input_sync(info->input); in exynos_ts_isr()
669 writel(0, ADC_V1_CLRINTPNDNUP(info->regs)); in exynos_ts_isr()
678 struct exynos_adc *info = iio_priv(indio_dev); in exynos_adc_reg_access() local
683 *readval = readl(info->regs + reg); in exynos_adc_reg_access()
726 struct exynos_adc *info = input_get_drvdata(dev); in exynos_adc_ts_open() local
728 enable_irq(info->tsirq); in exynos_adc_ts_open()
735 struct exynos_adc *info = input_get_drvdata(dev); in exynos_adc_ts_close() local
737 disable_irq(info->tsirq); in exynos_adc_ts_close()
740 static int exynos_adc_ts_init(struct exynos_adc *info) in exynos_adc_ts_init() argument
744 if (info->tsirq <= 0) in exynos_adc_ts_init()
747 info->input = input_allocate_device(); in exynos_adc_ts_init()
748 if (!info->input) in exynos_adc_ts_init()
751 info->input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in exynos_adc_ts_init()
752 info->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in exynos_adc_ts_init()
754 input_set_abs_params(info->input, ABS_X, 0, 0x3FF, 0, 0); in exynos_adc_ts_init()
755 input_set_abs_params(info->input, ABS_Y, 0, 0x3FF, 0, 0); in exynos_adc_ts_init()
757 info->input->name = "S3C24xx TouchScreen"; in exynos_adc_ts_init()
758 info->input->id.bustype = BUS_HOST; in exynos_adc_ts_init()
759 info->input->open = exynos_adc_ts_open; in exynos_adc_ts_init()
760 info->input->close = exynos_adc_ts_close; in exynos_adc_ts_init()
762 input_set_drvdata(info->input, info); in exynos_adc_ts_init()
764 ret = input_register_device(info->input); in exynos_adc_ts_init()
766 input_free_device(info->input); in exynos_adc_ts_init()
770 disable_irq(info->tsirq); in exynos_adc_ts_init()
771 ret = request_threaded_irq(info->tsirq, NULL, exynos_ts_isr, in exynos_adc_ts_init()
772 IRQF_ONESHOT, "touchscreen", info); in exynos_adc_ts_init()
774 input_unregister_device(info->input); in exynos_adc_ts_init()
781 struct exynos_adc *info = NULL; in exynos_adc_probe() local
796 info = iio_priv(indio_dev); in exynos_adc_probe()
798 info->data = exynos_adc_get_data(pdev); in exynos_adc_probe()
799 if (!info->data) { in exynos_adc_probe()
805 info->regs = devm_ioremap_resource(&pdev->dev, mem); in exynos_adc_probe()
806 if (IS_ERR(info->regs)) in exynos_adc_probe()
807 return PTR_ERR(info->regs); in exynos_adc_probe()
810 if (info->data->needs_adc_phy) { in exynos_adc_probe()
811 info->pmu_map = syscon_regmap_lookup_by_phandle( in exynos_adc_probe()
814 if (IS_ERR(info->pmu_map)) { in exynos_adc_probe()
816 return PTR_ERR(info->pmu_map); in exynos_adc_probe()
825 info->irq = irq; in exynos_adc_probe()
831 info->tsirq = irq; in exynos_adc_probe()
833 info->dev = &pdev->dev; in exynos_adc_probe()
835 init_completion(&info->completion); in exynos_adc_probe()
837 info->clk = devm_clk_get(&pdev->dev, "adc"); in exynos_adc_probe()
838 if (IS_ERR(info->clk)) { in exynos_adc_probe()
840 PTR_ERR(info->clk)); in exynos_adc_probe()
841 return PTR_ERR(info->clk); in exynos_adc_probe()
844 if (info->data->needs_sclk) { in exynos_adc_probe()
845 info->sclk = devm_clk_get(&pdev->dev, "sclk"); in exynos_adc_probe()
846 if (IS_ERR(info->sclk)) { in exynos_adc_probe()
849 PTR_ERR(info->sclk)); in exynos_adc_probe()
850 return PTR_ERR(info->sclk); in exynos_adc_probe()
854 info->vdd = devm_regulator_get(&pdev->dev, "vdd"); in exynos_adc_probe()
855 if (IS_ERR(info->vdd)) { in exynos_adc_probe()
857 PTR_ERR(info->vdd)); in exynos_adc_probe()
858 return PTR_ERR(info->vdd); in exynos_adc_probe()
861 ret = regulator_enable(info->vdd); in exynos_adc_probe()
865 ret = exynos_adc_prepare_clk(info); in exynos_adc_probe()
869 ret = exynos_adc_enable_clk(info); in exynos_adc_probe()
878 indio_dev->info = &exynos_adc_iio_info; in exynos_adc_probe()
881 indio_dev->num_channels = info->data->num_channels; in exynos_adc_probe()
883 ret = request_irq(info->irq, exynos_adc_isr, in exynos_adc_probe()
884 0, dev_name(&pdev->dev), info); in exynos_adc_probe()
887 info->irq); in exynos_adc_probe()
895 if (info->data->init_hw) in exynos_adc_probe()
896 info->data->init_hw(info); in exynos_adc_probe()
905 info->delay = pdata->delay; in exynos_adc_probe()
907 info->delay = 10000; in exynos_adc_probe()
910 ret = exynos_adc_ts_init(info); in exynos_adc_probe()
926 input_unregister_device(info->input); in exynos_adc_probe()
927 free_irq(info->tsirq, info); in exynos_adc_probe()
932 free_irq(info->irq, info); in exynos_adc_probe()
934 if (info->data->exit_hw) in exynos_adc_probe()
935 info->data->exit_hw(info); in exynos_adc_probe()
936 exynos_adc_disable_clk(info); in exynos_adc_probe()
938 exynos_adc_unprepare_clk(info); in exynos_adc_probe()
940 regulator_disable(info->vdd); in exynos_adc_probe()
947 struct exynos_adc *info = iio_priv(indio_dev); in exynos_adc_remove() local
949 if (IS_REACHABLE(CONFIG_INPUT) && info->input) { in exynos_adc_remove()
950 free_irq(info->tsirq, info); in exynos_adc_remove()
951 input_unregister_device(info->input); in exynos_adc_remove()
956 free_irq(info->irq, info); in exynos_adc_remove()
957 if (info->data->exit_hw) in exynos_adc_remove()
958 info->data->exit_hw(info); in exynos_adc_remove()
959 exynos_adc_disable_clk(info); in exynos_adc_remove()
960 exynos_adc_unprepare_clk(info); in exynos_adc_remove()
961 regulator_disable(info->vdd); in exynos_adc_remove()
970 struct exynos_adc *info = iio_priv(indio_dev); in exynos_adc_suspend() local
972 if (info->data->exit_hw) in exynos_adc_suspend()
973 info->data->exit_hw(info); in exynos_adc_suspend()
974 exynos_adc_disable_clk(info); in exynos_adc_suspend()
975 regulator_disable(info->vdd); in exynos_adc_suspend()
983 struct exynos_adc *info = iio_priv(indio_dev); in exynos_adc_resume() local
986 ret = regulator_enable(info->vdd); in exynos_adc_resume()
990 ret = exynos_adc_enable_clk(info); in exynos_adc_resume()
994 if (info->data->init_hw) in exynos_adc_resume()
995 info->data->init_hw(info); in exynos_adc_resume()