static void mxskbd_hwinit(struct platform_device *pdev) { int i; int mask = 0; struct mxskbd_data *d = platform_get_drvdata(pdev); for (i = 0; i < MAX_CH; i++) { hw_lradc_init_ladder(d->chan[i], LRADC_DELAY_TRIGGER_BUTTON, LRADC_DELAY); mask |= BM_LRADC_CTRL1_LRADC0_IRQ << d->chan[i]; } __raw_writel(mask, d->base + HW_LRADC_CTRL1_CLR); /* set vddio lradc manually */ hw_lradc_configure_channel(VDDIO_VOLTAGE_CH, 0, 0, 0); /* no dev2 */ hw_lradc_set_delay_trigger(LRADC_DELAY_TRIGGER_BUTTON, 1 << VDDIO_VOLTAGE_CH, 1 << LRADC_DELAY_TRIGGER_BUTTON, 0, LRADC_DELAY); /* used only one interrupt */ __raw_writel(BM_LRADC_CTRL1_LRADC0_IRQ_EN << d->chan[0], d->base + HW_LRADC_CTRL1_SET); hw_lradc_set_delay_trigger_kick(LRADC_DELAY_TRIGGER_BUTTON, !0); }
int hw_lradc_init_ladder(int channel, int trigger, unsigned sampling) { /* * check if the lradc channel is present in this product */ if (!hw_lradc_present(channel)) return -ENODEV; hw_lradc_configure_channel(channel, !0 /* div2 */ , 0 /* acc */ , 0 /* num_samples */); /* Setup the trigger loop forever */ hw_lradc_set_delay_trigger(trigger, 1 << channel, 1 << trigger, 0, sampling); /* Clear the accumulator & NUM_SAMPLES */ __raw_writel(0xFFFFFFFF, mxs_lradc.base + HW_LRADC_CHn_CLR(channel)); return 0; }
static int stmp3xxx_ts_probe(struct platform_device *pdev) { struct input_dev *idev; struct stmp3xxx_ts_info *info; int ret = 0; struct resource *res; idev = input_allocate_device(); info = kzalloc(sizeof(struct stmp3xxx_ts_info), GFP_KERNEL); if (idev == NULL || info == NULL) { ret = -ENOMEM; goto out_nomem; } idev->name = "STMP3XXX touchscreen"; idev->evbit[0] = BIT(EV_ABS); input_set_abs_params(idev, ABS_X, 0, 0xFFF, 0, 0); input_set_abs_params(idev, ABS_Y, 0, 0xFFF, 0, 0); input_set_abs_params(idev, ABS_PRESSURE, 0, 1, 0, 0); ret = input_register_device(idev); if (ret) goto out_nomem; info->idev = idev; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { printk(KERN_ERR "%s: couldn't get IRQ resource\n", __func__); ret = -ENODEV; goto out_nodev; } info->touch_irq = res->start; res = platform_get_resource(pdev, IORESOURCE_IRQ, 1); if (!res) { printk(KERN_ERR "%s: couldn't get IRQ resource\n", __func__); ret = -ENODEV; goto out_nodev; } info->device_irq = res->start; ret = request_irq(info->touch_irq, ts_handler, IRQF_DISABLED, "stmp3xxx_ts_touch", info); if (ret) goto out_nodev; ret = request_irq(info->device_irq, ts_handler, IRQF_DISABLED, "stmp3xxx_ts_dev", info); if (ret) { free_irq(info->touch_irq, info); goto out_nodev; } enter_state_touch_detect(info); hw_lradc_use_channel(LRADC_CH2); hw_lradc_use_channel(LRADC_CH3); hw_lradc_use_channel(LRADC_CH5); hw_lradc_configure_channel(LRADC_CH2, 0, 0, 0); hw_lradc_configure_channel(LRADC_CH3, 0, 0, 0); hw_lradc_configure_channel(LRADC_CH5, 0, 0, 0); /* Clear the accumulator & NUM_SAMPLES for the channels */ __raw_writel(0xFFFFFFFF, REGS_LRADC_BASE + HW_LRADC_CHn_CLR(LRADC_CH2)); __raw_writel(0xFFFFFFFF, REGS_LRADC_BASE + HW_LRADC_CHn_CLR(LRADC_CH3)); __raw_writel(0xFFFFFFFF, REGS_LRADC_BASE + HW_LRADC_CHn_CLR(LRADC_CH5)); hw_lradc_set_delay_trigger(LRADC_DELAY_TRIGGER_TOUCHSCREEN, 0x3c, 0, 0, 8); __raw_writel(BM_LRADC_CTRL1_LRADC5_IRQ, REGS_LRADC_BASE + HW_LRADC_CTRL1_CLR); __raw_writel(BM_LRADC_CTRL1_TOUCH_DETECT_IRQ, REGS_LRADC_BASE + HW_LRADC_CTRL1_CLR); __raw_writel(BM_LRADC_CTRL1_LRADC5_IRQ_EN, REGS_LRADC_BASE + HW_LRADC_CTRL1_SET); __raw_writel(BM_LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, REGS_LRADC_BASE + HW_LRADC_CTRL1_SET); platform_set_drvdata(pdev, info); device_init_wakeup(&pdev->dev, 1); goto out; out_nodev: input_free_device(idev); out_nomem: kfree(idev); kfree(info); out: return ret; }