Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: OMAP: duplicate plat-omap/clock.c into mach-omap[12]/clock.c

Duplicate arch/arm/plat-omap/clock.c into arch/arm/mach-omap1/clock.c
and arch/arm/mach-omap2/clock.c. This is to support people who are working
on the ARM single image kernel and the OMAP common clock framework
conversion.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

authored by

Paul Walmsley and committed by
Tony Lindgren
1fe9be82 f7a9b8a1

+1010 -572
+499
arch/arm/mach-omap1/clock.c
··· 12 12 * published by the Free Software Foundation. 13 13 */ 14 14 #include <linux/kernel.h> 15 + #include <linux/export.h> 15 16 #include <linux/list.h> 16 17 #include <linux/errno.h> 17 18 #include <linux/err.h> ··· 37 36 38 37 __u32 arm_idlect1_mask; 39 38 struct clk *api_ck_p, *ck_dpll1_p, *ck_ref_p; 39 + 40 + static LIST_HEAD(clocks); 41 + static DEFINE_MUTEX(clocks_mutex); 42 + static DEFINE_SPINLOCK(clockfw_lock); 40 43 41 44 /* 42 45 * Omap1 specific clock functions ··· 613 608 } 614 609 615 610 #endif 611 + 612 + 613 + int clk_enable(struct clk *clk) 614 + { 615 + unsigned long flags; 616 + int ret; 617 + 618 + if (clk == NULL || IS_ERR(clk)) 619 + return -EINVAL; 620 + 621 + spin_lock_irqsave(&clockfw_lock, flags); 622 + ret = omap1_clk_enable(clk); 623 + spin_unlock_irqrestore(&clockfw_lock, flags); 624 + 625 + return ret; 626 + } 627 + EXPORT_SYMBOL(clk_enable); 628 + 629 + void clk_disable(struct clk *clk) 630 + { 631 + unsigned long flags; 632 + 633 + if (clk == NULL || IS_ERR(clk)) 634 + return; 635 + 636 + spin_lock_irqsave(&clockfw_lock, flags); 637 + if (clk->usecount == 0) { 638 + pr_err("Trying disable clock %s with 0 usecount\n", 639 + clk->name); 640 + WARN_ON(1); 641 + goto out; 642 + } 643 + 644 + omap1_clk_disable(clk); 645 + 646 + out: 647 + spin_unlock_irqrestore(&clockfw_lock, flags); 648 + } 649 + EXPORT_SYMBOL(clk_disable); 650 + 651 + unsigned long clk_get_rate(struct clk *clk) 652 + { 653 + unsigned long flags; 654 + unsigned long ret; 655 + 656 + if (clk == NULL || IS_ERR(clk)) 657 + return 0; 658 + 659 + spin_lock_irqsave(&clockfw_lock, flags); 660 + ret = clk->rate; 661 + spin_unlock_irqrestore(&clockfw_lock, flags); 662 + 663 + return ret; 664 + } 665 + EXPORT_SYMBOL(clk_get_rate); 666 + 667 + /* 668 + * Optional clock functions defined in include/linux/clk.h 669 + */ 670 + 671 + long clk_round_rate(struct clk *clk, unsigned long rate) 672 + { 673 + unsigned long flags; 674 + long ret; 675 + 676 + if (clk == NULL || IS_ERR(clk)) 677 + return 0; 678 + 679 + spin_lock_irqsave(&clockfw_lock, flags); 680 + ret = omap1_clk_round_rate(clk, rate); 681 + spin_unlock_irqrestore(&clockfw_lock, flags); 682 + 683 + return ret; 684 + } 685 + EXPORT_SYMBOL(clk_round_rate); 686 + 687 + int clk_set_rate(struct clk *clk, unsigned long rate) 688 + { 689 + unsigned long flags; 690 + int ret = -EINVAL; 691 + 692 + if (clk == NULL || IS_ERR(clk)) 693 + return ret; 694 + 695 + spin_lock_irqsave(&clockfw_lock, flags); 696 + ret = omap1_clk_set_rate(clk, rate); 697 + if (ret == 0) 698 + propagate_rate(clk); 699 + spin_unlock_irqrestore(&clockfw_lock, flags); 700 + 701 + return ret; 702 + } 703 + EXPORT_SYMBOL(clk_set_rate); 704 + 705 + int clk_set_parent(struct clk *clk, struct clk *parent) 706 + { 707 + WARN_ONCE(1, "clk_set_parent() not implemented for OMAP1\n"); 708 + 709 + return -EINVAL; 710 + } 711 + EXPORT_SYMBOL(clk_set_parent); 712 + 713 + struct clk *clk_get_parent(struct clk *clk) 714 + { 715 + return clk->parent; 716 + } 717 + EXPORT_SYMBOL(clk_get_parent); 718 + 719 + /* 720 + * OMAP specific clock functions shared between omap1 and omap2 721 + */ 722 + 723 + int __initdata mpurate; 724 + 725 + /* 726 + * By default we use the rate set by the bootloader. 727 + * You can override this with mpurate= cmdline option. 728 + */ 729 + static int __init omap_clk_setup(char *str) 730 + { 731 + get_option(&str, &mpurate); 732 + 733 + if (!mpurate) 734 + return 1; 735 + 736 + if (mpurate < 1000) 737 + mpurate *= 1000000; 738 + 739 + return 1; 740 + } 741 + __setup("mpurate=", omap_clk_setup); 742 + 743 + /* Used for clocks that always have same value as the parent clock */ 744 + unsigned long followparent_recalc(struct clk *clk) 745 + { 746 + return clk->parent->rate; 747 + } 748 + 749 + /* 750 + * Used for clocks that have the same value as the parent clock, 751 + * divided by some factor 752 + */ 753 + unsigned long omap_fixed_divisor_recalc(struct clk *clk) 754 + { 755 + WARN_ON(!clk->fixed_div); 756 + 757 + return clk->parent->rate / clk->fixed_div; 758 + } 759 + 760 + void clk_reparent(struct clk *child, struct clk *parent) 761 + { 762 + list_del_init(&child->sibling); 763 + if (parent) 764 + list_add(&child->sibling, &parent->children); 765 + child->parent = parent; 766 + 767 + /* now do the debugfs renaming to reattach the child 768 + to the proper parent */ 769 + } 770 + 771 + /* Propagate rate to children */ 772 + void propagate_rate(struct clk *tclk) 773 + { 774 + struct clk *clkp; 775 + 776 + list_for_each_entry(clkp, &tclk->children, sibling) { 777 + if (clkp->recalc) 778 + clkp->rate = clkp->recalc(clkp); 779 + propagate_rate(clkp); 780 + } 781 + } 782 + 783 + static LIST_HEAD(root_clks); 784 + 785 + /** 786 + * recalculate_root_clocks - recalculate and propagate all root clocks 787 + * 788 + * Recalculates all root clocks (clocks with no parent), which if the 789 + * clock's .recalc is set correctly, should also propagate their rates. 790 + * Called at init. 791 + */ 792 + void recalculate_root_clocks(void) 793 + { 794 + struct clk *clkp; 795 + 796 + list_for_each_entry(clkp, &root_clks, sibling) { 797 + if (clkp->recalc) 798 + clkp->rate = clkp->recalc(clkp); 799 + propagate_rate(clkp); 800 + } 801 + } 802 + 803 + /** 804 + * clk_preinit - initialize any fields in the struct clk before clk init 805 + * @clk: struct clk * to initialize 806 + * 807 + * Initialize any struct clk fields needed before normal clk initialization 808 + * can run. No return value. 809 + */ 810 + void clk_preinit(struct clk *clk) 811 + { 812 + INIT_LIST_HEAD(&clk->children); 813 + } 814 + 815 + int clk_register(struct clk *clk) 816 + { 817 + if (clk == NULL || IS_ERR(clk)) 818 + return -EINVAL; 819 + 820 + /* 821 + * trap out already registered clocks 822 + */ 823 + if (clk->node.next || clk->node.prev) 824 + return 0; 825 + 826 + mutex_lock(&clocks_mutex); 827 + if (clk->parent) 828 + list_add(&clk->sibling, &clk->parent->children); 829 + else 830 + list_add(&clk->sibling, &root_clks); 831 + 832 + list_add(&clk->node, &clocks); 833 + if (clk->init) 834 + clk->init(clk); 835 + mutex_unlock(&clocks_mutex); 836 + 837 + return 0; 838 + } 839 + EXPORT_SYMBOL(clk_register); 840 + 841 + void clk_unregister(struct clk *clk) 842 + { 843 + if (clk == NULL || IS_ERR(clk)) 844 + return; 845 + 846 + mutex_lock(&clocks_mutex); 847 + list_del(&clk->sibling); 848 + list_del(&clk->node); 849 + mutex_unlock(&clocks_mutex); 850 + } 851 + EXPORT_SYMBOL(clk_unregister); 852 + 853 + void clk_enable_init_clocks(void) 854 + { 855 + struct clk *clkp; 856 + 857 + list_for_each_entry(clkp, &clocks, node) 858 + if (clkp->flags & ENABLE_ON_INIT) 859 + clk_enable(clkp); 860 + } 861 + 862 + /** 863 + * omap_clk_get_by_name - locate OMAP struct clk by its name 864 + * @name: name of the struct clk to locate 865 + * 866 + * Locate an OMAP struct clk by its name. Assumes that struct clk 867 + * names are unique. Returns NULL if not found or a pointer to the 868 + * struct clk if found. 869 + */ 870 + struct clk *omap_clk_get_by_name(const char *name) 871 + { 872 + struct clk *c; 873 + struct clk *ret = NULL; 874 + 875 + mutex_lock(&clocks_mutex); 876 + 877 + list_for_each_entry(c, &clocks, node) { 878 + if (!strcmp(c->name, name)) { 879 + ret = c; 880 + break; 881 + } 882 + } 883 + 884 + mutex_unlock(&clocks_mutex); 885 + 886 + return ret; 887 + } 888 + 889 + int omap_clk_enable_autoidle_all(void) 890 + { 891 + struct clk *c; 892 + unsigned long flags; 893 + 894 + spin_lock_irqsave(&clockfw_lock, flags); 895 + 896 + list_for_each_entry(c, &clocks, node) 897 + if (c->ops->allow_idle) 898 + c->ops->allow_idle(c); 899 + 900 + spin_unlock_irqrestore(&clockfw_lock, flags); 901 + 902 + return 0; 903 + } 904 + 905 + int omap_clk_disable_autoidle_all(void) 906 + { 907 + struct clk *c; 908 + unsigned long flags; 909 + 910 + spin_lock_irqsave(&clockfw_lock, flags); 911 + 912 + list_for_each_entry(c, &clocks, node) 913 + if (c->ops->deny_idle) 914 + c->ops->deny_idle(c); 915 + 916 + spin_unlock_irqrestore(&clockfw_lock, flags); 917 + 918 + return 0; 919 + } 920 + 921 + /* 922 + * Low level helpers 923 + */ 924 + static int clkll_enable_null(struct clk *clk) 925 + { 926 + return 0; 927 + } 928 + 929 + static void clkll_disable_null(struct clk *clk) 930 + { 931 + } 932 + 933 + const struct clkops clkops_null = { 934 + .enable = clkll_enable_null, 935 + .disable = clkll_disable_null, 936 + }; 937 + 938 + /* 939 + * Dummy clock 940 + * 941 + * Used for clock aliases that are needed on some OMAPs, but not others 942 + */ 943 + struct clk dummy_ck = { 944 + .name = "dummy", 945 + .ops = &clkops_null, 946 + }; 947 + 948 + /* 949 + * 950 + */ 951 + 952 + #ifdef CONFIG_OMAP_RESET_CLOCKS 953 + /* 954 + * Disable any unused clocks left on by the bootloader 955 + */ 956 + static int __init clk_disable_unused(void) 957 + { 958 + struct clk *ck; 959 + unsigned long flags; 960 + 961 + pr_info("clock: disabling unused clocks to save power\n"); 962 + 963 + spin_lock_irqsave(&clockfw_lock, flags); 964 + list_for_each_entry(ck, &clocks, node) { 965 + if (ck->ops == &clkops_null) 966 + continue; 967 + 968 + if (ck->usecount > 0 || !ck->enable_reg) 969 + continue; 970 + 971 + omap1_clk_disable_unused(ck); 972 + } 973 + spin_unlock_irqrestore(&clockfw_lock, flags); 974 + 975 + return 0; 976 + } 977 + late_initcall(clk_disable_unused); 978 + late_initcall(omap_clk_enable_autoidle_all); 979 + #endif 980 + 981 + #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 982 + /* 983 + * debugfs support to trace clock tree hierarchy and attributes 984 + */ 985 + 986 + #include <linux/debugfs.h> 987 + #include <linux/seq_file.h> 988 + 989 + static struct dentry *clk_debugfs_root; 990 + 991 + static int clk_dbg_show_summary(struct seq_file *s, void *unused) 992 + { 993 + struct clk *c; 994 + struct clk *pa; 995 + 996 + mutex_lock(&clocks_mutex); 997 + seq_printf(s, "%-30s %-30s %-10s %s\n", 998 + "clock-name", "parent-name", "rate", "use-count"); 999 + 1000 + list_for_each_entry(c, &clocks, node) { 1001 + pa = c->parent; 1002 + seq_printf(s, "%-30s %-30s %-10lu %d\n", 1003 + c->name, pa ? pa->name : "none", c->rate, 1004 + c->usecount); 1005 + } 1006 + mutex_unlock(&clocks_mutex); 1007 + 1008 + return 0; 1009 + } 1010 + 1011 + static int clk_dbg_open(struct inode *inode, struct file *file) 1012 + { 1013 + return single_open(file, clk_dbg_show_summary, inode->i_private); 1014 + } 1015 + 1016 + static const struct file_operations debug_clock_fops = { 1017 + .open = clk_dbg_open, 1018 + .read = seq_read, 1019 + .llseek = seq_lseek, 1020 + .release = single_release, 1021 + }; 1022 + 1023 + static int clk_debugfs_register_one(struct clk *c) 1024 + { 1025 + int err; 1026 + struct dentry *d; 1027 + struct clk *pa = c->parent; 1028 + 1029 + d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root); 1030 + if (!d) 1031 + return -ENOMEM; 1032 + c->dent = d; 1033 + 1034 + d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount); 1035 + if (!d) { 1036 + err = -ENOMEM; 1037 + goto err_out; 1038 + } 1039 + d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate); 1040 + if (!d) { 1041 + err = -ENOMEM; 1042 + goto err_out; 1043 + } 1044 + d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags); 1045 + if (!d) { 1046 + err = -ENOMEM; 1047 + goto err_out; 1048 + } 1049 + return 0; 1050 + 1051 + err_out: 1052 + debugfs_remove_recursive(c->dent); 1053 + return err; 1054 + } 1055 + 1056 + static int clk_debugfs_register(struct clk *c) 1057 + { 1058 + int err; 1059 + struct clk *pa = c->parent; 1060 + 1061 + if (pa && !pa->dent) { 1062 + err = clk_debugfs_register(pa); 1063 + if (err) 1064 + return err; 1065 + } 1066 + 1067 + if (!c->dent) { 1068 + err = clk_debugfs_register_one(c); 1069 + if (err) 1070 + return err; 1071 + } 1072 + return 0; 1073 + } 1074 + 1075 + static int __init clk_debugfs_init(void) 1076 + { 1077 + struct clk *c; 1078 + struct dentry *d; 1079 + int err; 1080 + 1081 + d = debugfs_create_dir("clock", NULL); 1082 + if (!d) 1083 + return -ENOMEM; 1084 + clk_debugfs_root = d; 1085 + 1086 + list_for_each_entry(c, &clocks, node) { 1087 + err = clk_debugfs_register(c); 1088 + if (err) 1089 + goto err_out; 1090 + } 1091 + 1092 + d = debugfs_create_file("summary", S_IRUGO, 1093 + d, NULL, &debug_clock_fops); 1094 + if (!d) 1095 + return -ENOMEM; 1096 + 1097 + return 0; 1098 + err_out: 1099 + debugfs_remove_recursive(clk_debugfs_root); 1100 + return err; 1101 + } 1102 + late_initcall(clk_debugfs_init); 1103 + 1104 + #endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
-10
arch/arm/mach-omap1/clock_data.c
··· 766 766 * init 767 767 */ 768 768 769 - static struct clk_functions omap1_clk_functions = { 770 - .clk_enable = omap1_clk_enable, 771 - .clk_disable = omap1_clk_disable, 772 - .clk_round_rate = omap1_clk_round_rate, 773 - .clk_set_rate = omap1_clk_set_rate, 774 - .clk_disable_unused = omap1_clk_disable_unused, 775 - }; 776 - 777 769 static void __init omap1_show_rates(void) 778 770 { 779 771 pr_notice("Clocking rate (xtal/DPLL1/MPU): %ld.%01ld/%ld.%01ld/%ld.%01ld MHz\n", ··· 795 803 omap_writew(reg, SOFT_REQ_REG); 796 804 if (!cpu_is_omap15xx()) 797 805 omap_writew(0, SOFT_REQ_REG2); 798 - 799 - clk_init(&omap1_clk_functions); 800 806 801 807 /* By default all idlect1 clocks are allowed to idle */ 802 808 arm_idlect1_mask = ~0;
+510 -7
arch/arm/mach-omap2/clock.c
··· 15 15 #undef DEBUG 16 16 17 17 #include <linux/kernel.h> 18 + #include <linux/export.h> 18 19 #include <linux/list.h> 19 20 #include <linux/errno.h> 20 21 #include <linux/err.h> ··· 47 46 * afterwards. 48 47 */ 49 48 static bool clkdm_control = true; 49 + 50 + static LIST_HEAD(clocks); 51 + static DEFINE_MUTEX(clocks_mutex); 52 + static DEFINE_SPINLOCK(clockfw_lock); 50 53 51 54 /* 52 55 * OMAP2+ specific clock functions ··· 517 512 518 513 /* Common data */ 519 514 520 - struct clk_functions omap2_clk_functions = { 521 - .clk_enable = omap2_clk_enable, 522 - .clk_disable = omap2_clk_disable, 523 - .clk_round_rate = omap2_clk_round_rate, 524 - .clk_set_rate = omap2_clk_set_rate, 525 - .clk_set_parent = omap2_clk_set_parent, 526 - .clk_disable_unused = omap2_clk_disable_unused, 515 + int clk_enable(struct clk *clk) 516 + { 517 + unsigned long flags; 518 + int ret; 519 + 520 + if (clk == NULL || IS_ERR(clk)) 521 + return -EINVAL; 522 + 523 + spin_lock_irqsave(&clockfw_lock, flags); 524 + ret = omap2_clk_enable(clk); 525 + spin_unlock_irqrestore(&clockfw_lock, flags); 526 + 527 + return ret; 528 + } 529 + EXPORT_SYMBOL(clk_enable); 530 + 531 + void clk_disable(struct clk *clk) 532 + { 533 + unsigned long flags; 534 + 535 + if (clk == NULL || IS_ERR(clk)) 536 + return; 537 + 538 + spin_lock_irqsave(&clockfw_lock, flags); 539 + if (clk->usecount == 0) { 540 + pr_err("Trying disable clock %s with 0 usecount\n", 541 + clk->name); 542 + WARN_ON(1); 543 + goto out; 544 + } 545 + 546 + omap2_clk_disable(clk); 547 + 548 + out: 549 + spin_unlock_irqrestore(&clockfw_lock, flags); 550 + } 551 + EXPORT_SYMBOL(clk_disable); 552 + 553 + unsigned long clk_get_rate(struct clk *clk) 554 + { 555 + unsigned long flags; 556 + unsigned long ret; 557 + 558 + if (clk == NULL || IS_ERR(clk)) 559 + return 0; 560 + 561 + spin_lock_irqsave(&clockfw_lock, flags); 562 + ret = clk->rate; 563 + spin_unlock_irqrestore(&clockfw_lock, flags); 564 + 565 + return ret; 566 + } 567 + EXPORT_SYMBOL(clk_get_rate); 568 + 569 + /* 570 + * Optional clock functions defined in include/linux/clk.h 571 + */ 572 + 573 + long clk_round_rate(struct clk *clk, unsigned long rate) 574 + { 575 + unsigned long flags; 576 + long ret; 577 + 578 + if (clk == NULL || IS_ERR(clk)) 579 + return 0; 580 + 581 + spin_lock_irqsave(&clockfw_lock, flags); 582 + ret = omap2_clk_round_rate(clk, rate); 583 + spin_unlock_irqrestore(&clockfw_lock, flags); 584 + 585 + return ret; 586 + } 587 + EXPORT_SYMBOL(clk_round_rate); 588 + 589 + int clk_set_rate(struct clk *clk, unsigned long rate) 590 + { 591 + unsigned long flags; 592 + int ret = -EINVAL; 593 + 594 + if (clk == NULL || IS_ERR(clk)) 595 + return ret; 596 + 597 + spin_lock_irqsave(&clockfw_lock, flags); 598 + ret = omap2_clk_set_rate(clk, rate); 599 + if (ret == 0) 600 + propagate_rate(clk); 601 + spin_unlock_irqrestore(&clockfw_lock, flags); 602 + 603 + return ret; 604 + } 605 + EXPORT_SYMBOL(clk_set_rate); 606 + 607 + int clk_set_parent(struct clk *clk, struct clk *parent) 608 + { 609 + unsigned long flags; 610 + int ret = -EINVAL; 611 + 612 + if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent)) 613 + return ret; 614 + 615 + spin_lock_irqsave(&clockfw_lock, flags); 616 + if (clk->usecount == 0) { 617 + ret = omap2_clk_set_parent(clk, parent); 618 + if (ret == 0) 619 + propagate_rate(clk); 620 + } else { 621 + ret = -EBUSY; 622 + } 623 + spin_unlock_irqrestore(&clockfw_lock, flags); 624 + 625 + return ret; 626 + } 627 + EXPORT_SYMBOL(clk_set_parent); 628 + 629 + struct clk *clk_get_parent(struct clk *clk) 630 + { 631 + return clk->parent; 632 + } 633 + EXPORT_SYMBOL(clk_get_parent); 634 + 635 + /* 636 + * OMAP specific clock functions shared between omap1 and omap2 637 + */ 638 + 639 + int __initdata mpurate; 640 + 641 + /* 642 + * By default we use the rate set by the bootloader. 643 + * You can override this with mpurate= cmdline option. 644 + */ 645 + static int __init omap_clk_setup(char *str) 646 + { 647 + get_option(&str, &mpurate); 648 + 649 + if (!mpurate) 650 + return 1; 651 + 652 + if (mpurate < 1000) 653 + mpurate *= 1000000; 654 + 655 + return 1; 656 + } 657 + __setup("mpurate=", omap_clk_setup); 658 + 659 + /* Used for clocks that always have same value as the parent clock */ 660 + unsigned long followparent_recalc(struct clk *clk) 661 + { 662 + return clk->parent->rate; 663 + } 664 + 665 + /* 666 + * Used for clocks that have the same value as the parent clock, 667 + * divided by some factor 668 + */ 669 + unsigned long omap_fixed_divisor_recalc(struct clk *clk) 670 + { 671 + WARN_ON(!clk->fixed_div); 672 + 673 + return clk->parent->rate / clk->fixed_div; 674 + } 675 + 676 + void clk_reparent(struct clk *child, struct clk *parent) 677 + { 678 + list_del_init(&child->sibling); 679 + if (parent) 680 + list_add(&child->sibling, &parent->children); 681 + child->parent = parent; 682 + 683 + /* now do the debugfs renaming to reattach the child 684 + to the proper parent */ 685 + } 686 + 687 + /* Propagate rate to children */ 688 + void propagate_rate(struct clk *tclk) 689 + { 690 + struct clk *clkp; 691 + 692 + list_for_each_entry(clkp, &tclk->children, sibling) { 693 + if (clkp->recalc) 694 + clkp->rate = clkp->recalc(clkp); 695 + propagate_rate(clkp); 696 + } 697 + } 698 + 699 + static LIST_HEAD(root_clks); 700 + 701 + /** 702 + * recalculate_root_clocks - recalculate and propagate all root clocks 703 + * 704 + * Recalculates all root clocks (clocks with no parent), which if the 705 + * clock's .recalc is set correctly, should also propagate their rates. 706 + * Called at init. 707 + */ 708 + void recalculate_root_clocks(void) 709 + { 710 + struct clk *clkp; 711 + 712 + list_for_each_entry(clkp, &root_clks, sibling) { 713 + if (clkp->recalc) 714 + clkp->rate = clkp->recalc(clkp); 715 + propagate_rate(clkp); 716 + } 717 + } 718 + 719 + /** 720 + * clk_preinit - initialize any fields in the struct clk before clk init 721 + * @clk: struct clk * to initialize 722 + * 723 + * Initialize any struct clk fields needed before normal clk initialization 724 + * can run. No return value. 725 + */ 726 + void clk_preinit(struct clk *clk) 727 + { 728 + INIT_LIST_HEAD(&clk->children); 729 + } 730 + 731 + int clk_register(struct clk *clk) 732 + { 733 + if (clk == NULL || IS_ERR(clk)) 734 + return -EINVAL; 735 + 736 + /* 737 + * trap out already registered clocks 738 + */ 739 + if (clk->node.next || clk->node.prev) 740 + return 0; 741 + 742 + mutex_lock(&clocks_mutex); 743 + if (clk->parent) 744 + list_add(&clk->sibling, &clk->parent->children); 745 + else 746 + list_add(&clk->sibling, &root_clks); 747 + 748 + list_add(&clk->node, &clocks); 749 + if (clk->init) 750 + clk->init(clk); 751 + mutex_unlock(&clocks_mutex); 752 + 753 + return 0; 754 + } 755 + EXPORT_SYMBOL(clk_register); 756 + 757 + void clk_unregister(struct clk *clk) 758 + { 759 + if (clk == NULL || IS_ERR(clk)) 760 + return; 761 + 762 + mutex_lock(&clocks_mutex); 763 + list_del(&clk->sibling); 764 + list_del(&clk->node); 765 + mutex_unlock(&clocks_mutex); 766 + } 767 + EXPORT_SYMBOL(clk_unregister); 768 + 769 + void clk_enable_init_clocks(void) 770 + { 771 + struct clk *clkp; 772 + 773 + list_for_each_entry(clkp, &clocks, node) 774 + if (clkp->flags & ENABLE_ON_INIT) 775 + clk_enable(clkp); 776 + } 777 + 778 + /** 779 + * omap_clk_get_by_name - locate OMAP struct clk by its name 780 + * @name: name of the struct clk to locate 781 + * 782 + * Locate an OMAP struct clk by its name. Assumes that struct clk 783 + * names are unique. Returns NULL if not found or a pointer to the 784 + * struct clk if found. 785 + */ 786 + struct clk *omap_clk_get_by_name(const char *name) 787 + { 788 + struct clk *c; 789 + struct clk *ret = NULL; 790 + 791 + mutex_lock(&clocks_mutex); 792 + 793 + list_for_each_entry(c, &clocks, node) { 794 + if (!strcmp(c->name, name)) { 795 + ret = c; 796 + break; 797 + } 798 + } 799 + 800 + mutex_unlock(&clocks_mutex); 801 + 802 + return ret; 803 + } 804 + 805 + int omap_clk_enable_autoidle_all(void) 806 + { 807 + struct clk *c; 808 + unsigned long flags; 809 + 810 + spin_lock_irqsave(&clockfw_lock, flags); 811 + 812 + list_for_each_entry(c, &clocks, node) 813 + if (c->ops->allow_idle) 814 + c->ops->allow_idle(c); 815 + 816 + spin_unlock_irqrestore(&clockfw_lock, flags); 817 + 818 + return 0; 819 + } 820 + 821 + int omap_clk_disable_autoidle_all(void) 822 + { 823 + struct clk *c; 824 + unsigned long flags; 825 + 826 + spin_lock_irqsave(&clockfw_lock, flags); 827 + 828 + list_for_each_entry(c, &clocks, node) 829 + if (c->ops->deny_idle) 830 + c->ops->deny_idle(c); 831 + 832 + spin_unlock_irqrestore(&clockfw_lock, flags); 833 + 834 + return 0; 835 + } 836 + 837 + /* 838 + * Low level helpers 839 + */ 840 + static int clkll_enable_null(struct clk *clk) 841 + { 842 + return 0; 843 + } 844 + 845 + static void clkll_disable_null(struct clk *clk) 846 + { 847 + } 848 + 849 + const struct clkops clkops_null = { 850 + .enable = clkll_enable_null, 851 + .disable = clkll_disable_null, 527 852 }; 853 + 854 + /* 855 + * Dummy clock 856 + * 857 + * Used for clock aliases that are needed on some OMAPs, but not others 858 + */ 859 + struct clk dummy_ck = { 860 + .name = "dummy", 861 + .ops = &clkops_null, 862 + }; 863 + 864 + /* 865 + * 866 + */ 867 + 868 + #ifdef CONFIG_OMAP_RESET_CLOCKS 869 + /* 870 + * Disable any unused clocks left on by the bootloader 871 + */ 872 + static int __init clk_disable_unused(void) 873 + { 874 + struct clk *ck; 875 + unsigned long flags; 876 + 877 + pr_info("clock: disabling unused clocks to save power\n"); 878 + 879 + spin_lock_irqsave(&clockfw_lock, flags); 880 + list_for_each_entry(ck, &clocks, node) { 881 + if (ck->ops == &clkops_null) 882 + continue; 883 + 884 + if (ck->usecount > 0 || !ck->enable_reg) 885 + continue; 886 + 887 + omap2_clk_disable_unused(ck); 888 + } 889 + spin_unlock_irqrestore(&clockfw_lock, flags); 890 + 891 + return 0; 892 + } 893 + late_initcall(clk_disable_unused); 894 + late_initcall(omap_clk_enable_autoidle_all); 895 + #endif 896 + 897 + #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 898 + /* 899 + * debugfs support to trace clock tree hierarchy and attributes 900 + */ 901 + 902 + #include <linux/debugfs.h> 903 + #include <linux/seq_file.h> 904 + 905 + static struct dentry *clk_debugfs_root; 906 + 907 + static int clk_dbg_show_summary(struct seq_file *s, void *unused) 908 + { 909 + struct clk *c; 910 + struct clk *pa; 911 + 912 + mutex_lock(&clocks_mutex); 913 + seq_printf(s, "%-30s %-30s %-10s %s\n", 914 + "clock-name", "parent-name", "rate", "use-count"); 915 + 916 + list_for_each_entry(c, &clocks, node) { 917 + pa = c->parent; 918 + seq_printf(s, "%-30s %-30s %-10lu %d\n", 919 + c->name, pa ? pa->name : "none", c->rate, 920 + c->usecount); 921 + } 922 + mutex_unlock(&clocks_mutex); 923 + 924 + return 0; 925 + } 926 + 927 + static int clk_dbg_open(struct inode *inode, struct file *file) 928 + { 929 + return single_open(file, clk_dbg_show_summary, inode->i_private); 930 + } 931 + 932 + static const struct file_operations debug_clock_fops = { 933 + .open = clk_dbg_open, 934 + .read = seq_read, 935 + .llseek = seq_lseek, 936 + .release = single_release, 937 + }; 938 + 939 + static int clk_debugfs_register_one(struct clk *c) 940 + { 941 + int err; 942 + struct dentry *d; 943 + struct clk *pa = c->parent; 944 + 945 + d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root); 946 + if (!d) 947 + return -ENOMEM; 948 + c->dent = d; 949 + 950 + d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount); 951 + if (!d) { 952 + err = -ENOMEM; 953 + goto err_out; 954 + } 955 + d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate); 956 + if (!d) { 957 + err = -ENOMEM; 958 + goto err_out; 959 + } 960 + d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags); 961 + if (!d) { 962 + err = -ENOMEM; 963 + goto err_out; 964 + } 965 + return 0; 966 + 967 + err_out: 968 + debugfs_remove_recursive(c->dent); 969 + return err; 970 + } 971 + 972 + static int clk_debugfs_register(struct clk *c) 973 + { 974 + int err; 975 + struct clk *pa = c->parent; 976 + 977 + if (pa && !pa->dent) { 978 + err = clk_debugfs_register(pa); 979 + if (err) 980 + return err; 981 + } 982 + 983 + if (!c->dent) { 984 + err = clk_debugfs_register_one(c); 985 + if (err) 986 + return err; 987 + } 988 + return 0; 989 + } 990 + 991 + static int __init clk_debugfs_init(void) 992 + { 993 + struct clk *c; 994 + struct dentry *d; 995 + int err; 996 + 997 + d = debugfs_create_dir("clock", NULL); 998 + if (!d) 999 + return -ENOMEM; 1000 + clk_debugfs_root = d; 1001 + 1002 + list_for_each_entry(c, &clocks, node) { 1003 + err = clk_debugfs_register(c); 1004 + if (err) 1005 + goto err_out; 1006 + } 1007 + 1008 + d = debugfs_create_file("summary", S_IRUGO, 1009 + d, NULL, &debug_clock_fops); 1010 + if (!d) 1011 + return -ENOMEM; 1012 + 1013 + return 0; 1014 + err_out: 1015 + debugfs_remove_recursive(clk_debugfs_root); 1016 + return err; 1017 + } 1018 + late_initcall(clk_debugfs_init); 1019 + 1020 + #endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */ 528 1021
-2
arch/arm/mach-omap2/clock2420_data.c
··· 1935 1935 cpu_mask = RATE_IN_242X; 1936 1936 rate_table = omap2420_rate_table; 1937 1937 1938 - clk_init(&omap2_clk_functions); 1939 - 1940 1938 for (c = omap2420_clks; c < omap2420_clks + ARRAY_SIZE(omap2420_clks); 1941 1939 c++) 1942 1940 clk_preinit(c->lk.clk);
-2
arch/arm/mach-omap2/clock2430_data.c
··· 2034 2034 cpu_mask = RATE_IN_243X; 2035 2035 rate_table = omap2430_rate_table; 2036 2036 2037 - clk_init(&omap2_clk_functions); 2038 - 2039 2037 for (c = omap2430_clks; c < omap2430_clks + ARRAY_SIZE(omap2430_clks); 2040 2038 c++) 2041 2039 clk_preinit(c->lk.clk);
-2
arch/arm/mach-omap2/clock33xx_data.c
··· 1085 1085 cpu_clkflg = CK_AM33XX; 1086 1086 } 1087 1087 1088 - clk_init(&omap2_clk_functions); 1089 - 1090 1088 for (c = am33xx_clks; c < am33xx_clks + ARRAY_SIZE(am33xx_clks); c++) 1091 1089 clk_preinit(c->lk.clk); 1092 1090
-2
arch/arm/mach-omap2/clock3xxx_data.c
··· 3573 3573 else 3574 3574 dpll4_dd = dpll4_dd_34xx; 3575 3575 3576 - clk_init(&omap2_clk_functions); 3577 - 3578 3576 for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks); 3579 3577 c++) 3580 3578 clk_preinit(c->lk.clk);
-2
arch/arm/mach-omap2/clock44xx_data.c
··· 3366 3366 return 0; 3367 3367 } 3368 3368 3369 - clk_init(&omap2_clk_functions); 3370 - 3371 3369 /* 3372 3370 * Must stay commented until all OMAP SoC drivers are 3373 3371 * converted to runtime PM, or drivers may start crashing
+1 -1
arch/arm/plat-omap/Makefile
··· 3 3 # 4 4 5 5 # Common support 6 - obj-y := common.o sram.o clock.o dma.o fb.o counter_32k.o 6 + obj-y := common.o sram.o dma.o fb.o counter_32k.o 7 7 obj-m := 8 8 obj-n := 9 9 obj- :=
-544
arch/arm/plat-omap/clock.c
··· 1 - /* 2 - * linux/arch/arm/plat-omap/clock.c 3 - * 4 - * Copyright (C) 2004 - 2008 Nokia corporation 5 - * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> 6 - * 7 - * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com> 8 - * 9 - * This program is free software; you can redistribute it and/or modify 10 - * it under the terms of the GNU General Public License version 2 as 11 - * published by the Free Software Foundation. 12 - */ 13 - #include <linux/kernel.h> 14 - #include <linux/init.h> 15 - #include <linux/list.h> 16 - #include <linux/errno.h> 17 - #include <linux/export.h> 18 - #include <linux/err.h> 19 - #include <linux/string.h> 20 - #include <linux/clk.h> 21 - #include <linux/mutex.h> 22 - #include <linux/cpufreq.h> 23 - #include <linux/io.h> 24 - 25 - #include <plat/clock.h> 26 - 27 - static LIST_HEAD(clocks); 28 - static DEFINE_MUTEX(clocks_mutex); 29 - static DEFINE_SPINLOCK(clockfw_lock); 30 - 31 - static struct clk_functions *arch_clock; 32 - 33 - /* 34 - * Standard clock functions defined in include/linux/clk.h 35 - */ 36 - 37 - int clk_enable(struct clk *clk) 38 - { 39 - unsigned long flags; 40 - int ret; 41 - 42 - if (clk == NULL || IS_ERR(clk)) 43 - return -EINVAL; 44 - 45 - if (!arch_clock || !arch_clock->clk_enable) 46 - return -EINVAL; 47 - 48 - spin_lock_irqsave(&clockfw_lock, flags); 49 - ret = arch_clock->clk_enable(clk); 50 - spin_unlock_irqrestore(&clockfw_lock, flags); 51 - 52 - return ret; 53 - } 54 - EXPORT_SYMBOL(clk_enable); 55 - 56 - void clk_disable(struct clk *clk) 57 - { 58 - unsigned long flags; 59 - 60 - if (clk == NULL || IS_ERR(clk)) 61 - return; 62 - 63 - if (!arch_clock || !arch_clock->clk_disable) 64 - return; 65 - 66 - spin_lock_irqsave(&clockfw_lock, flags); 67 - if (clk->usecount == 0) { 68 - pr_err("Trying disable clock %s with 0 usecount\n", 69 - clk->name); 70 - WARN_ON(1); 71 - goto out; 72 - } 73 - 74 - arch_clock->clk_disable(clk); 75 - 76 - out: 77 - spin_unlock_irqrestore(&clockfw_lock, flags); 78 - } 79 - EXPORT_SYMBOL(clk_disable); 80 - 81 - unsigned long clk_get_rate(struct clk *clk) 82 - { 83 - unsigned long flags; 84 - unsigned long ret; 85 - 86 - if (clk == NULL || IS_ERR(clk)) 87 - return 0; 88 - 89 - spin_lock_irqsave(&clockfw_lock, flags); 90 - ret = clk->rate; 91 - spin_unlock_irqrestore(&clockfw_lock, flags); 92 - 93 - return ret; 94 - } 95 - EXPORT_SYMBOL(clk_get_rate); 96 - 97 - /* 98 - * Optional clock functions defined in include/linux/clk.h 99 - */ 100 - 101 - long clk_round_rate(struct clk *clk, unsigned long rate) 102 - { 103 - unsigned long flags; 104 - long ret; 105 - 106 - if (clk == NULL || IS_ERR(clk)) 107 - return 0; 108 - 109 - if (!arch_clock || !arch_clock->clk_round_rate) 110 - return 0; 111 - 112 - spin_lock_irqsave(&clockfw_lock, flags); 113 - ret = arch_clock->clk_round_rate(clk, rate); 114 - spin_unlock_irqrestore(&clockfw_lock, flags); 115 - 116 - return ret; 117 - } 118 - EXPORT_SYMBOL(clk_round_rate); 119 - 120 - int clk_set_rate(struct clk *clk, unsigned long rate) 121 - { 122 - unsigned long flags; 123 - int ret = -EINVAL; 124 - 125 - if (clk == NULL || IS_ERR(clk)) 126 - return ret; 127 - 128 - if (!arch_clock || !arch_clock->clk_set_rate) 129 - return ret; 130 - 131 - spin_lock_irqsave(&clockfw_lock, flags); 132 - ret = arch_clock->clk_set_rate(clk, rate); 133 - if (ret == 0) 134 - propagate_rate(clk); 135 - spin_unlock_irqrestore(&clockfw_lock, flags); 136 - 137 - return ret; 138 - } 139 - EXPORT_SYMBOL(clk_set_rate); 140 - 141 - int clk_set_parent(struct clk *clk, struct clk *parent) 142 - { 143 - unsigned long flags; 144 - int ret = -EINVAL; 145 - 146 - if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent)) 147 - return ret; 148 - 149 - if (!arch_clock || !arch_clock->clk_set_parent) 150 - return ret; 151 - 152 - spin_lock_irqsave(&clockfw_lock, flags); 153 - if (clk->usecount == 0) { 154 - ret = arch_clock->clk_set_parent(clk, parent); 155 - if (ret == 0) 156 - propagate_rate(clk); 157 - } else 158 - ret = -EBUSY; 159 - spin_unlock_irqrestore(&clockfw_lock, flags); 160 - 161 - return ret; 162 - } 163 - EXPORT_SYMBOL(clk_set_parent); 164 - 165 - struct clk *clk_get_parent(struct clk *clk) 166 - { 167 - return clk->parent; 168 - } 169 - EXPORT_SYMBOL(clk_get_parent); 170 - 171 - /* 172 - * OMAP specific clock functions shared between omap1 and omap2 173 - */ 174 - 175 - int __initdata mpurate; 176 - 177 - /* 178 - * By default we use the rate set by the bootloader. 179 - * You can override this with mpurate= cmdline option. 180 - */ 181 - static int __init omap_clk_setup(char *str) 182 - { 183 - get_option(&str, &mpurate); 184 - 185 - if (!mpurate) 186 - return 1; 187 - 188 - if (mpurate < 1000) 189 - mpurate *= 1000000; 190 - 191 - return 1; 192 - } 193 - __setup("mpurate=", omap_clk_setup); 194 - 195 - /* Used for clocks that always have same value as the parent clock */ 196 - unsigned long followparent_recalc(struct clk *clk) 197 - { 198 - return clk->parent->rate; 199 - } 200 - 201 - /* 202 - * Used for clocks that have the same value as the parent clock, 203 - * divided by some factor 204 - */ 205 - unsigned long omap_fixed_divisor_recalc(struct clk *clk) 206 - { 207 - WARN_ON(!clk->fixed_div); 208 - 209 - return clk->parent->rate / clk->fixed_div; 210 - } 211 - 212 - void clk_reparent(struct clk *child, struct clk *parent) 213 - { 214 - list_del_init(&child->sibling); 215 - if (parent) 216 - list_add(&child->sibling, &parent->children); 217 - child->parent = parent; 218 - 219 - /* now do the debugfs renaming to reattach the child 220 - to the proper parent */ 221 - } 222 - 223 - /* Propagate rate to children */ 224 - void propagate_rate(struct clk *tclk) 225 - { 226 - struct clk *clkp; 227 - 228 - list_for_each_entry(clkp, &tclk->children, sibling) { 229 - if (clkp->recalc) 230 - clkp->rate = clkp->recalc(clkp); 231 - propagate_rate(clkp); 232 - } 233 - } 234 - 235 - static LIST_HEAD(root_clks); 236 - 237 - /** 238 - * recalculate_root_clocks - recalculate and propagate all root clocks 239 - * 240 - * Recalculates all root clocks (clocks with no parent), which if the 241 - * clock's .recalc is set correctly, should also propagate their rates. 242 - * Called at init. 243 - */ 244 - void recalculate_root_clocks(void) 245 - { 246 - struct clk *clkp; 247 - 248 - list_for_each_entry(clkp, &root_clks, sibling) { 249 - if (clkp->recalc) 250 - clkp->rate = clkp->recalc(clkp); 251 - propagate_rate(clkp); 252 - } 253 - } 254 - 255 - /** 256 - * clk_preinit - initialize any fields in the struct clk before clk init 257 - * @clk: struct clk * to initialize 258 - * 259 - * Initialize any struct clk fields needed before normal clk initialization 260 - * can run. No return value. 261 - */ 262 - void clk_preinit(struct clk *clk) 263 - { 264 - INIT_LIST_HEAD(&clk->children); 265 - } 266 - 267 - int clk_register(struct clk *clk) 268 - { 269 - if (clk == NULL || IS_ERR(clk)) 270 - return -EINVAL; 271 - 272 - /* 273 - * trap out already registered clocks 274 - */ 275 - if (clk->node.next || clk->node.prev) 276 - return 0; 277 - 278 - mutex_lock(&clocks_mutex); 279 - if (clk->parent) 280 - list_add(&clk->sibling, &clk->parent->children); 281 - else 282 - list_add(&clk->sibling, &root_clks); 283 - 284 - list_add(&clk->node, &clocks); 285 - if (clk->init) 286 - clk->init(clk); 287 - mutex_unlock(&clocks_mutex); 288 - 289 - return 0; 290 - } 291 - EXPORT_SYMBOL(clk_register); 292 - 293 - void clk_unregister(struct clk *clk) 294 - { 295 - if (clk == NULL || IS_ERR(clk)) 296 - return; 297 - 298 - mutex_lock(&clocks_mutex); 299 - list_del(&clk->sibling); 300 - list_del(&clk->node); 301 - mutex_unlock(&clocks_mutex); 302 - } 303 - EXPORT_SYMBOL(clk_unregister); 304 - 305 - void clk_enable_init_clocks(void) 306 - { 307 - struct clk *clkp; 308 - 309 - list_for_each_entry(clkp, &clocks, node) { 310 - if (clkp->flags & ENABLE_ON_INIT) 311 - clk_enable(clkp); 312 - } 313 - } 314 - 315 - int omap_clk_enable_autoidle_all(void) 316 - { 317 - struct clk *c; 318 - unsigned long flags; 319 - 320 - spin_lock_irqsave(&clockfw_lock, flags); 321 - 322 - list_for_each_entry(c, &clocks, node) 323 - if (c->ops->allow_idle) 324 - c->ops->allow_idle(c); 325 - 326 - spin_unlock_irqrestore(&clockfw_lock, flags); 327 - 328 - return 0; 329 - } 330 - 331 - int omap_clk_disable_autoidle_all(void) 332 - { 333 - struct clk *c; 334 - unsigned long flags; 335 - 336 - spin_lock_irqsave(&clockfw_lock, flags); 337 - 338 - list_for_each_entry(c, &clocks, node) 339 - if (c->ops->deny_idle) 340 - c->ops->deny_idle(c); 341 - 342 - spin_unlock_irqrestore(&clockfw_lock, flags); 343 - 344 - return 0; 345 - } 346 - 347 - /* 348 - * Low level helpers 349 - */ 350 - static int clkll_enable_null(struct clk *clk) 351 - { 352 - return 0; 353 - } 354 - 355 - static void clkll_disable_null(struct clk *clk) 356 - { 357 - } 358 - 359 - const struct clkops clkops_null = { 360 - .enable = clkll_enable_null, 361 - .disable = clkll_disable_null, 362 - }; 363 - 364 - /* 365 - * Dummy clock 366 - * 367 - * Used for clock aliases that are needed on some OMAPs, but not others 368 - */ 369 - struct clk dummy_ck = { 370 - .name = "dummy", 371 - .ops = &clkops_null, 372 - }; 373 - 374 - /* 375 - * 376 - */ 377 - 378 - #ifdef CONFIG_OMAP_RESET_CLOCKS 379 - /* 380 - * Disable any unused clocks left on by the bootloader 381 - */ 382 - static int __init clk_disable_unused(void) 383 - { 384 - struct clk *ck; 385 - unsigned long flags; 386 - 387 - if (!arch_clock || !arch_clock->clk_disable_unused) 388 - return 0; 389 - 390 - pr_info("clock: disabling unused clocks to save power\n"); 391 - 392 - spin_lock_irqsave(&clockfw_lock, flags); 393 - list_for_each_entry(ck, &clocks, node) { 394 - if (ck->ops == &clkops_null) 395 - continue; 396 - 397 - if (ck->usecount > 0 || !ck->enable_reg) 398 - continue; 399 - 400 - arch_clock->clk_disable_unused(ck); 401 - } 402 - spin_unlock_irqrestore(&clockfw_lock, flags); 403 - 404 - return 0; 405 - } 406 - late_initcall(clk_disable_unused); 407 - late_initcall(omap_clk_enable_autoidle_all); 408 - #endif 409 - 410 - int __init clk_init(struct clk_functions * custom_clocks) 411 - { 412 - if (!custom_clocks) { 413 - pr_err("No custom clock functions registered\n"); 414 - BUG(); 415 - } 416 - 417 - arch_clock = custom_clocks; 418 - 419 - return 0; 420 - } 421 - 422 - #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 423 - /* 424 - * debugfs support to trace clock tree hierarchy and attributes 425 - */ 426 - 427 - #include <linux/debugfs.h> 428 - #include <linux/seq_file.h> 429 - 430 - static struct dentry *clk_debugfs_root; 431 - 432 - static int clk_dbg_show_summary(struct seq_file *s, void *unused) 433 - { 434 - struct clk *c; 435 - struct clk *pa; 436 - 437 - mutex_lock(&clocks_mutex); 438 - seq_printf(s, "%-30s %-30s %-10s %s\n", 439 - "clock-name", "parent-name", "rate", "use-count"); 440 - 441 - list_for_each_entry(c, &clocks, node) { 442 - pa = c->parent; 443 - seq_printf(s, "%-30s %-30s %-10lu %d\n", 444 - c->name, pa ? pa->name : "none", c->rate, c->usecount); 445 - } 446 - mutex_unlock(&clocks_mutex); 447 - 448 - return 0; 449 - } 450 - 451 - static int clk_dbg_open(struct inode *inode, struct file *file) 452 - { 453 - return single_open(file, clk_dbg_show_summary, inode->i_private); 454 - } 455 - 456 - static const struct file_operations debug_clock_fops = { 457 - .open = clk_dbg_open, 458 - .read = seq_read, 459 - .llseek = seq_lseek, 460 - .release = single_release, 461 - }; 462 - 463 - static int clk_debugfs_register_one(struct clk *c) 464 - { 465 - int err; 466 - struct dentry *d; 467 - struct clk *pa = c->parent; 468 - 469 - d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root); 470 - if (!d) 471 - return -ENOMEM; 472 - c->dent = d; 473 - 474 - d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount); 475 - if (!d) { 476 - err = -ENOMEM; 477 - goto err_out; 478 - } 479 - d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate); 480 - if (!d) { 481 - err = -ENOMEM; 482 - goto err_out; 483 - } 484 - d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags); 485 - if (!d) { 486 - err = -ENOMEM; 487 - goto err_out; 488 - } 489 - return 0; 490 - 491 - err_out: 492 - debugfs_remove_recursive(c->dent); 493 - return err; 494 - } 495 - 496 - static int clk_debugfs_register(struct clk *c) 497 - { 498 - int err; 499 - struct clk *pa = c->parent; 500 - 501 - if (pa && !pa->dent) { 502 - err = clk_debugfs_register(pa); 503 - if (err) 504 - return err; 505 - } 506 - 507 - if (!c->dent) { 508 - err = clk_debugfs_register_one(c); 509 - if (err) 510 - return err; 511 - } 512 - return 0; 513 - } 514 - 515 - static int __init clk_debugfs_init(void) 516 - { 517 - struct clk *c; 518 - struct dentry *d; 519 - int err; 520 - 521 - d = debugfs_create_dir("clock", NULL); 522 - if (!d) 523 - return -ENOMEM; 524 - clk_debugfs_root = d; 525 - 526 - list_for_each_entry(c, &clocks, node) { 527 - err = clk_debugfs_register(c); 528 - if (err) 529 - goto err_out; 530 - } 531 - 532 - d = debugfs_create_file("summary", S_IRUGO, 533 - d, NULL, &debug_clock_fops); 534 - if (!d) 535 - return -ENOMEM; 536 - 537 - return 0; 538 - err_out: 539 - debugfs_remove_recursive(clk_debugfs_root); 540 - return err; 541 - } 542 - late_initcall(clk_debugfs_init); 543 - 544 - #endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */