diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-11-20 06:12:26 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-02-12 12:32:39 -0500 |
commit | 0321cb83e1c3f3a4282bd620c6cec78c5b80b572 (patch) | |
tree | 5a72693de37c889cb5339a1556cd4ab5967a0864 /drivers/i2c | |
parent | a0dcf19f59d4f37150a6b7e115925d72aca15293 (diff) |
ARM: PNX4008: move i2c clock start/stop into driver
Acked-by: Vitaly Wool <vitalywool@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-pnx.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index bc8075514e53..98462671cdf7 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -20,6 +20,9 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/i2c-pnx.h> | 21 | #include <linux/i2c-pnx.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/err.h> | ||
24 | #include <linux/clk.h> | ||
25 | |||
23 | #include <mach/hardware.h> | 26 | #include <mach/hardware.h> |
24 | #include <mach/i2c.h> | 27 | #include <mach/i2c.h> |
25 | #include <asm/irq.h> | 28 | #include <asm/irq.h> |
@@ -550,13 +553,22 @@ static int i2c_pnx_controller_suspend(struct platform_device *pdev, | |||
550 | pm_message_t state) | 553 | pm_message_t state) |
551 | { | 554 | { |
552 | struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); | 555 | struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); |
553 | return i2c_pnx->set_clock_run(pdev); | 556 | struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data; |
557 | |||
558 | /* FIXME: disable clock? */ | ||
559 | clk_set_rate(alg_data->clk, 1); | ||
560 | |||
561 | return 0; | ||
554 | } | 562 | } |
555 | 563 | ||
556 | static int i2c_pnx_controller_resume(struct platform_device *pdev) | 564 | static int i2c_pnx_controller_resume(struct platform_device *pdev) |
557 | { | 565 | { |
558 | struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); | 566 | struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); |
559 | return i2c_pnx->set_clock_run(pdev); | 567 | struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data; |
568 | |||
569 | clk_set_rate(alg_data->clk, 1); | ||
570 | |||
571 | return 0; | ||
560 | } | 572 | } |
561 | #else | 573 | #else |
562 | #define i2c_pnx_controller_suspend NULL | 574 | #define i2c_pnx_controller_suspend NULL |
@@ -580,6 +592,15 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
580 | 592 | ||
581 | platform_set_drvdata(pdev, i2c_pnx); | 593 | platform_set_drvdata(pdev, i2c_pnx); |
582 | 594 | ||
595 | i2c_pnx->adapter->algo = &pnx_algorithm; | ||
596 | alg_data = i2c_pnx->adapter->algo_data; | ||
597 | |||
598 | alg_data->clk = clk_get(&pdev->dev, NULL); | ||
599 | if (IS_ERR(alg_data->clk)) { | ||
600 | ret = PTR_ERR(alg_data->clk); | ||
601 | goto out_drvdata; | ||
602 | } | ||
603 | |||
583 | if (i2c_pnx->calculate_input_freq) | 604 | if (i2c_pnx->calculate_input_freq) |
584 | freq_mhz = i2c_pnx->calculate_input_freq(pdev); | 605 | freq_mhz = i2c_pnx->calculate_input_freq(pdev); |
585 | else { | 606 | else { |
@@ -588,9 +609,6 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
588 | "%d MHz\n", freq_mhz); | 609 | "%d MHz\n", freq_mhz); |
589 | } | 610 | } |
590 | 611 | ||
591 | i2c_pnx->adapter->algo = &pnx_algorithm; | ||
592 | |||
593 | alg_data = i2c_pnx->adapter->algo_data; | ||
594 | init_timer(&alg_data->mif.timer); | 612 | init_timer(&alg_data->mif.timer); |
595 | alg_data->mif.timer.function = i2c_pnx_timeout; | 613 | alg_data->mif.timer.function = i2c_pnx_timeout; |
596 | alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; | 614 | alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; |
@@ -602,7 +620,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
602 | "I/O region 0x%08x for I2C already in use.\n", | 620 | "I/O region 0x%08x for I2C already in use.\n", |
603 | alg_data->base); | 621 | alg_data->base); |
604 | ret = -ENODEV; | 622 | ret = -ENODEV; |
605 | goto out_drvdata; | 623 | goto out_clkget; |
606 | } | 624 | } |
607 | 625 | ||
608 | if (!(alg_data->ioaddr = | 626 | if (!(alg_data->ioaddr = |
@@ -612,7 +630,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
612 | goto out_release; | 630 | goto out_release; |
613 | } | 631 | } |
614 | 632 | ||
615 | i2c_pnx->set_clock_run(pdev); | 633 | clk_set_rate(alg_data->clk, 1); |
616 | 634 | ||
617 | /* | 635 | /* |
618 | * Clock Divisor High This value is the number of system clocks | 636 | * Clock Divisor High This value is the number of system clocks |
@@ -658,11 +676,13 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
658 | out_irq: | 676 | out_irq: |
659 | free_irq(alg_data->irq, i2c_pnx->adapter); | 677 | free_irq(alg_data->irq, i2c_pnx->adapter); |
660 | out_clock: | 678 | out_clock: |
661 | i2c_pnx->set_clock_stop(pdev); | 679 | clk_set_rate(alg_data->clk, 0); |
662 | out_unmap: | 680 | out_unmap: |
663 | iounmap((void *)alg_data->ioaddr); | 681 | iounmap((void *)alg_data->ioaddr); |
664 | out_release: | 682 | out_release: |
665 | release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); | 683 | release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); |
684 | out_clkget: | ||
685 | clk_put(alg_data->clk); | ||
666 | out_drvdata: | 686 | out_drvdata: |
667 | platform_set_drvdata(pdev, NULL); | 687 | platform_set_drvdata(pdev, NULL); |
668 | out: | 688 | out: |
@@ -677,9 +697,10 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev) | |||
677 | 697 | ||
678 | free_irq(alg_data->irq, i2c_pnx->adapter); | 698 | free_irq(alg_data->irq, i2c_pnx->adapter); |
679 | i2c_del_adapter(adap); | 699 | i2c_del_adapter(adap); |
680 | i2c_pnx->set_clock_stop(pdev); | 700 | clk_set_rate(alg_data->clk, 0); |
681 | iounmap((void *)alg_data->ioaddr); | 701 | iounmap((void *)alg_data->ioaddr); |
682 | release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); | 702 | release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); |
703 | clk_put(alg_data->clk); | ||
683 | platform_set_drvdata(pdev, NULL); | 704 | platform_set_drvdata(pdev, NULL); |
684 | 705 | ||
685 | return 0; | 706 | return 0; |