diff options
Diffstat (limited to 'arch/arm/mach-omap2/devices.c')
-rw-r--r-- | arch/arm/mach-omap2/devices.c | 108 |
1 files changed, 26 insertions, 82 deletions
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index 5a0c148e23bc..381f4eb92352 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c | |||
@@ -638,6 +638,7 @@ static struct platform_device dummy_pdev = { | |||
638 | static void __init omap_hsmmc_reset(void) | 638 | static void __init omap_hsmmc_reset(void) |
639 | { | 639 | { |
640 | u32 i, nr_controllers; | 640 | u32 i, nr_controllers; |
641 | struct clk *iclk, *fclk; | ||
641 | 642 | ||
642 | if (cpu_is_omap242x()) | 643 | if (cpu_is_omap242x()) |
643 | return; | 644 | return; |
@@ -647,7 +648,6 @@ static void __init omap_hsmmc_reset(void) | |||
647 | 648 | ||
648 | for (i = 0; i < nr_controllers; i++) { | 649 | for (i = 0; i < nr_controllers; i++) { |
649 | u32 v, base = 0; | 650 | u32 v, base = 0; |
650 | struct clk *iclk, *fclk; | ||
651 | struct device *dev = &dummy_pdev.dev; | 651 | struct device *dev = &dummy_pdev.dev; |
652 | 652 | ||
653 | switch (i) { | 653 | switch (i) { |
@@ -678,19 +678,16 @@ static void __init omap_hsmmc_reset(void) | |||
678 | dummy_pdev.id = i; | 678 | dummy_pdev.id = i; |
679 | dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i); | 679 | dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i); |
680 | iclk = clk_get(dev, "ick"); | 680 | iclk = clk_get(dev, "ick"); |
681 | if (iclk && clk_enable(iclk)) | 681 | if (IS_ERR(iclk)) |
682 | iclk = NULL; | 682 | goto err1; |
683 | if (clk_enable(iclk)) | ||
684 | goto err2; | ||
683 | 685 | ||
684 | fclk = clk_get(dev, "fck"); | 686 | fclk = clk_get(dev, "fck"); |
685 | if (fclk && clk_enable(fclk)) | 687 | if (IS_ERR(fclk)) |
686 | fclk = NULL; | 688 | goto err3; |
687 | 689 | if (clk_enable(fclk)) | |
688 | if (!iclk || !fclk) { | 690 | goto err4; |
689 | printk(KERN_WARNING | ||
690 | "%s: Unable to enable clocks for MMC%d, " | ||
691 | "cannot reset.\n", __func__, i); | ||
692 | break; | ||
693 | } | ||
694 | 691 | ||
695 | omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG); | 692 | omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG); |
696 | v = omap_readl(base + MMCHS_SYSSTATUS); | 693 | v = omap_readl(base + MMCHS_SYSSTATUS); |
@@ -698,15 +695,22 @@ static void __init omap_hsmmc_reset(void) | |||
698 | MMCHS_SYSSTATUS_RESETDONE)) | 695 | MMCHS_SYSSTATUS_RESETDONE)) |
699 | cpu_relax(); | 696 | cpu_relax(); |
700 | 697 | ||
701 | if (fclk) { | 698 | clk_disable(fclk); |
702 | clk_disable(fclk); | 699 | clk_put(fclk); |
703 | clk_put(fclk); | 700 | clk_disable(iclk); |
704 | } | 701 | clk_put(iclk); |
705 | if (iclk) { | ||
706 | clk_disable(iclk); | ||
707 | clk_put(iclk); | ||
708 | } | ||
709 | } | 702 | } |
703 | return; | ||
704 | |||
705 | err4: | ||
706 | clk_put(fclk); | ||
707 | err3: | ||
708 | clk_disable(iclk); | ||
709 | err2: | ||
710 | clk_put(iclk); | ||
711 | err1: | ||
712 | printk(KERN_WARNING "%s: Unable to enable clocks for MMC%d, " | ||
713 | "cannot reset.\n", __func__, i); | ||
710 | } | 714 | } |
711 | #else | 715 | #else |
712 | static inline void omap_hsmmc_reset(void) {} | 716 | static inline void omap_hsmmc_reset(void) {} |
@@ -951,72 +955,12 @@ static inline void omap_init_vout(void) {} | |||
951 | 955 | ||
952 | /*-------------------------------------------------------------------------*/ | 956 | /*-------------------------------------------------------------------------*/ |
953 | 957 | ||
954 | /* | ||
955 | * Inorder to avoid any assumptions from bootloader regarding WDT | ||
956 | * settings, WDT module is reset during init. This enables the watchdog | ||
957 | * timer. Hence it is required to disable the watchdog after the WDT reset | ||
958 | * during init. Otherwise the system would reboot as per the default | ||
959 | * watchdog timer registers settings. | ||
960 | */ | ||
961 | #define OMAP_WDT_WPS (0x34) | ||
962 | #define OMAP_WDT_SPR (0x48) | ||
963 | |||
964 | static int omap2_disable_wdt(struct omap_hwmod *oh, void *unused) | ||
965 | { | ||
966 | void __iomem *base; | ||
967 | int ret; | ||
968 | |||
969 | if (!oh) { | ||
970 | pr_err("%s: Could not look up wdtimer_hwmod\n", __func__); | ||
971 | return -EINVAL; | ||
972 | } | ||
973 | |||
974 | base = omap_hwmod_get_mpu_rt_va(oh); | ||
975 | if (!base) { | ||
976 | pr_err("%s: Could not get the base address for %s\n", | ||
977 | oh->name, __func__); | ||
978 | return -EINVAL; | ||
979 | } | ||
980 | |||
981 | /* Enable the clocks before accessing the WDT registers */ | ||
982 | ret = omap_hwmod_enable(oh); | ||
983 | if (ret) { | ||
984 | pr_err("%s: Could not enable clocks for %s\n", | ||
985 | oh->name, __func__); | ||
986 | return ret; | ||
987 | } | ||
988 | |||
989 | /* sequence required to disable watchdog */ | ||
990 | __raw_writel(0xAAAA, base + OMAP_WDT_SPR); | ||
991 | while (__raw_readl(base + OMAP_WDT_WPS) & 0x10) | ||
992 | cpu_relax(); | ||
993 | |||
994 | __raw_writel(0x5555, base + OMAP_WDT_SPR); | ||
995 | while (__raw_readl(base + OMAP_WDT_WPS) & 0x10) | ||
996 | cpu_relax(); | ||
997 | |||
998 | ret = omap_hwmod_idle(oh); | ||
999 | if (ret) | ||
1000 | pr_err("%s: Could not disable clocks for %s\n", | ||
1001 | oh->name, __func__); | ||
1002 | |||
1003 | return ret; | ||
1004 | } | ||
1005 | |||
1006 | static void __init omap_disable_wdt(void) | ||
1007 | { | ||
1008 | if (cpu_class_is_omap2()) | ||
1009 | omap_hwmod_for_each_by_class("wd_timer", | ||
1010 | omap2_disable_wdt, NULL); | ||
1011 | return; | ||
1012 | } | ||
1013 | |||
1014 | static int __init omap2_init_devices(void) | 958 | static int __init omap2_init_devices(void) |
1015 | { | 959 | { |
1016 | /* please keep these calls, and their implementations above, | 960 | /* |
961 | * please keep these calls, and their implementations above, | ||
1017 | * in alphabetical order so they're easier to sort through. | 962 | * in alphabetical order so they're easier to sort through. |
1018 | */ | 963 | */ |
1019 | omap_disable_wdt(); | ||
1020 | omap_hsmmc_reset(); | 964 | omap_hsmmc_reset(); |
1021 | omap_init_audio(); | 965 | omap_init_audio(); |
1022 | omap_init_camera(); | 966 | omap_init_camera(); |