| .. | .. |
|---|
| 315 | 315 | return IRQ_HANDLED; |
|---|
| 316 | 316 | } |
|---|
| 317 | 317 | |
|---|
| 318 | | -static int imx6ul_tsc_open(struct input_dev *input_dev) |
|---|
| 318 | +static int imx6ul_tsc_start(struct imx6ul_tsc *tsc) |
|---|
| 319 | 319 | { |
|---|
| 320 | | - struct imx6ul_tsc *tsc = input_get_drvdata(input_dev); |
|---|
| 321 | 320 | int err; |
|---|
| 322 | 321 | |
|---|
| 323 | 322 | err = clk_prepare_enable(tsc->adc_clk); |
|---|
| .. | .. |
|---|
| 349 | 348 | return err; |
|---|
| 350 | 349 | } |
|---|
| 351 | 350 | |
|---|
| 352 | | -static void imx6ul_tsc_close(struct input_dev *input_dev) |
|---|
| 351 | +static void imx6ul_tsc_stop(struct imx6ul_tsc *tsc) |
|---|
| 353 | 352 | { |
|---|
| 354 | | - struct imx6ul_tsc *tsc = input_get_drvdata(input_dev); |
|---|
| 355 | | - |
|---|
| 356 | 353 | imx6ul_tsc_disable(tsc); |
|---|
| 357 | 354 | |
|---|
| 358 | 355 | clk_disable_unprepare(tsc->tsc_clk); |
|---|
| 359 | 356 | clk_disable_unprepare(tsc->adc_clk); |
|---|
| 357 | +} |
|---|
| 358 | + |
|---|
| 359 | + |
|---|
| 360 | +static int imx6ul_tsc_open(struct input_dev *input_dev) |
|---|
| 361 | +{ |
|---|
| 362 | + struct imx6ul_tsc *tsc = input_get_drvdata(input_dev); |
|---|
| 363 | + |
|---|
| 364 | + return imx6ul_tsc_start(tsc); |
|---|
| 365 | +} |
|---|
| 366 | + |
|---|
| 367 | +static void imx6ul_tsc_close(struct input_dev *input_dev) |
|---|
| 368 | +{ |
|---|
| 369 | + struct imx6ul_tsc *tsc = input_get_drvdata(input_dev); |
|---|
| 370 | + |
|---|
| 371 | + imx6ul_tsc_stop(tsc); |
|---|
| 360 | 372 | } |
|---|
| 361 | 373 | |
|---|
| 362 | 374 | static int imx6ul_tsc_probe(struct platform_device *pdev) |
|---|
| .. | .. |
|---|
| 364 | 376 | struct device_node *np = pdev->dev.of_node; |
|---|
| 365 | 377 | struct imx6ul_tsc *tsc; |
|---|
| 366 | 378 | struct input_dev *input_dev; |
|---|
| 367 | | - struct resource *tsc_mem; |
|---|
| 368 | | - struct resource *adc_mem; |
|---|
| 369 | 379 | int err; |
|---|
| 370 | 380 | int tsc_irq; |
|---|
| 371 | 381 | int adc_irq; |
|---|
| .. | .. |
|---|
| 403 | 413 | return err; |
|---|
| 404 | 414 | } |
|---|
| 405 | 415 | |
|---|
| 406 | | - tsc_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 407 | | - tsc->tsc_regs = devm_ioremap_resource(&pdev->dev, tsc_mem); |
|---|
| 416 | + tsc->tsc_regs = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 408 | 417 | if (IS_ERR(tsc->tsc_regs)) { |
|---|
| 409 | 418 | err = PTR_ERR(tsc->tsc_regs); |
|---|
| 410 | 419 | dev_err(&pdev->dev, "failed to remap tsc memory: %d\n", err); |
|---|
| 411 | 420 | return err; |
|---|
| 412 | 421 | } |
|---|
| 413 | 422 | |
|---|
| 414 | | - adc_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
|---|
| 415 | | - tsc->adc_regs = devm_ioremap_resource(&pdev->dev, adc_mem); |
|---|
| 423 | + tsc->adc_regs = devm_platform_ioremap_resource(pdev, 1); |
|---|
| 416 | 424 | if (IS_ERR(tsc->adc_regs)) { |
|---|
| 417 | 425 | err = PTR_ERR(tsc->adc_regs); |
|---|
| 418 | 426 | dev_err(&pdev->dev, "failed to remap adc memory: %d\n", err); |
|---|
| .. | .. |
|---|
| 434 | 442 | } |
|---|
| 435 | 443 | |
|---|
| 436 | 444 | tsc_irq = platform_get_irq(pdev, 0); |
|---|
| 437 | | - if (tsc_irq < 0) { |
|---|
| 438 | | - dev_err(&pdev->dev, "no tsc irq resource?\n"); |
|---|
| 445 | + if (tsc_irq < 0) |
|---|
| 439 | 446 | return tsc_irq; |
|---|
| 440 | | - } |
|---|
| 441 | 447 | |
|---|
| 442 | 448 | adc_irq = platform_get_irq(pdev, 1); |
|---|
| 443 | | - if (adc_irq < 0) { |
|---|
| 444 | | - dev_err(&pdev->dev, "no adc irq resource?\n"); |
|---|
| 449 | + if (adc_irq < 0) |
|---|
| 445 | 450 | return adc_irq; |
|---|
| 446 | | - } |
|---|
| 447 | 451 | |
|---|
| 448 | 452 | err = devm_request_threaded_irq(tsc->dev, tsc_irq, |
|---|
| 449 | 453 | NULL, tsc_irq_fn, IRQF_ONESHOT, |
|---|
| .. | .. |
|---|
| 517 | 521 | |
|---|
| 518 | 522 | mutex_lock(&input_dev->mutex); |
|---|
| 519 | 523 | |
|---|
| 520 | | - if (input_dev->users) { |
|---|
| 521 | | - imx6ul_tsc_disable(tsc); |
|---|
| 522 | | - |
|---|
| 523 | | - clk_disable_unprepare(tsc->tsc_clk); |
|---|
| 524 | | - clk_disable_unprepare(tsc->adc_clk); |
|---|
| 525 | | - } |
|---|
| 524 | + if (input_dev->users) |
|---|
| 525 | + imx6ul_tsc_stop(tsc); |
|---|
| 526 | 526 | |
|---|
| 527 | 527 | mutex_unlock(&input_dev->mutex); |
|---|
| 528 | 528 | |
|---|
| .. | .. |
|---|
| 538 | 538 | |
|---|
| 539 | 539 | mutex_lock(&input_dev->mutex); |
|---|
| 540 | 540 | |
|---|
| 541 | | - if (!input_dev->users) |
|---|
| 542 | | - goto out; |
|---|
| 541 | + if (input_dev->users) |
|---|
| 542 | + retval = imx6ul_tsc_start(tsc); |
|---|
| 543 | 543 | |
|---|
| 544 | | - retval = clk_prepare_enable(tsc->adc_clk); |
|---|
| 545 | | - if (retval) |
|---|
| 546 | | - goto out; |
|---|
| 547 | | - |
|---|
| 548 | | - retval = clk_prepare_enable(tsc->tsc_clk); |
|---|
| 549 | | - if (retval) { |
|---|
| 550 | | - clk_disable_unprepare(tsc->adc_clk); |
|---|
| 551 | | - goto out; |
|---|
| 552 | | - } |
|---|
| 553 | | - |
|---|
| 554 | | - retval = imx6ul_tsc_init(tsc); |
|---|
| 555 | | - if (retval) { |
|---|
| 556 | | - clk_disable_unprepare(tsc->tsc_clk); |
|---|
| 557 | | - clk_disable_unprepare(tsc->adc_clk); |
|---|
| 558 | | - goto out; |
|---|
| 559 | | - } |
|---|
| 560 | | -out: |
|---|
| 561 | 544 | mutex_unlock(&input_dev->mutex); |
|---|
| 545 | + |
|---|
| 562 | 546 | return retval; |
|---|
| 563 | 547 | } |
|---|
| 564 | 548 | |
|---|