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

clk: Add rate constraints to clocks

Adds a way for clock consumers to set maximum and minimum rates. This
can be used for thermal drivers to set minimum rates, or by misc.
drivers to set maximum rates to assure a minimum performance level.

Changes the signature of the determine_rate callback by adding the
parameters min_rate and max_rate.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[sboyd@codeaurora.org: set req_rate in __clk_init]
Signed-off-by: Michael Turquette <mturquette@linaro.org>
[mturquette@linaro.org: min/max rate for sun6i_ahb1_clk_determine_rate
migrated clk-private.h changes to clk.c]

authored by

Tomeu Vizoso and committed by
Michael Turquette
1c8e6004 b09d6d99

+321 -68
+2
Documentation/clk.txt
··· 73 73 unsigned long *parent_rate); 74 74 long (*determine_rate)(struct clk_hw *hw, 75 75 unsigned long rate, 76 + unsigned long min_rate, 77 + unsigned long max_rate, 76 78 unsigned long *best_parent_rate, 77 79 struct clk_hw **best_parent_clk); 78 80 int (*set_parent)(struct clk_hw *hw, u8 index);
+2
arch/arm/mach-omap2/dpll3xxx.c
··· 473 473 * in failure. 474 474 */ 475 475 long omap3_noncore_dpll_determine_rate(struct clk_hw *hw, unsigned long rate, 476 + unsigned long min_rate, 477 + unsigned long max_rate, 476 478 unsigned long *best_parent_rate, 477 479 struct clk_hw **best_parent_clk) 478 480 {
+2
arch/arm/mach-omap2/dpll44xx.c
··· 222 222 * in failure. 223 223 */ 224 224 long omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw, unsigned long rate, 225 + unsigned long min_rate, 226 + unsigned long max_rate, 225 227 unsigned long *best_parent_rate, 226 228 struct clk_hw **best_parent_clk) 227 229 {
+8
arch/mips/alchemy/common/clock.c
··· 373 373 } 374 374 375 375 static long alchemy_clk_fgcs_detr(struct clk_hw *hw, unsigned long rate, 376 + unsigned long min_rate, 377 + unsigned long max_rate, 376 378 unsigned long *best_parent_rate, 377 379 struct clk_hw **best_parent_clk, 378 380 int scale, int maxdiv) ··· 548 546 } 549 547 550 548 static long alchemy_clk_fgv1_detr(struct clk_hw *hw, unsigned long rate, 549 + unsigned long min_rate, 550 + unsigned long max_rate, 551 551 unsigned long *best_parent_rate, 552 552 struct clk_hw **best_parent_clk) 553 553 { ··· 682 678 } 683 679 684 680 static long alchemy_clk_fgv2_detr(struct clk_hw *hw, unsigned long rate, 681 + unsigned long min_rate, 682 + unsigned long max_rate, 685 683 unsigned long *best_parent_rate, 686 684 struct clk_hw **best_parent_clk) 687 685 { ··· 903 897 } 904 898 905 899 static long alchemy_clk_csrc_detr(struct clk_hw *hw, unsigned long rate, 900 + unsigned long min_rate, 901 + unsigned long max_rate, 906 902 unsigned long *best_parent_rate, 907 903 struct clk_hw **best_parent_clk) 908 904 {
+2
drivers/clk/at91/clk-programmable.c
··· 56 56 57 57 static long clk_programmable_determine_rate(struct clk_hw *hw, 58 58 unsigned long rate, 59 + unsigned long min_rate, 60 + unsigned long max_rate, 59 61 unsigned long *best_parent_rate, 60 62 struct clk_hw **best_parent_hw) 61 63 {
+2
drivers/clk/bcm/clk-kona.c
··· 1032 1032 } 1033 1033 1034 1034 static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate, 1035 + unsigned long min_rate, 1036 + unsigned long max_rate, 1035 1037 unsigned long *best_parent_rate, struct clk_hw **best_parent) 1036 1038 { 1037 1039 struct kona_clk *bcm_clk = to_kona_clk(hw);
+7 -2
drivers/clk/clk-composite.c
··· 56 56 } 57 57 58 58 static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate, 59 + unsigned long min_rate, 60 + unsigned long max_rate, 59 61 unsigned long *best_parent_rate, 60 62 struct clk_hw **best_parent_p) 61 63 { ··· 75 73 76 74 if (rate_hw && rate_ops && rate_ops->determine_rate) { 77 75 rate_hw->clk = hw->clk; 78 - return rate_ops->determine_rate(rate_hw, rate, best_parent_rate, 76 + return rate_ops->determine_rate(rate_hw, rate, min_rate, 77 + max_rate, 78 + best_parent_rate, 79 79 best_parent_p); 80 80 } else if (rate_hw && rate_ops && rate_ops->round_rate && 81 81 mux_hw && mux_ops && mux_ops->set_parent) { ··· 121 117 return best_rate; 122 118 } else if (mux_hw && mux_ops && mux_ops->determine_rate) { 123 119 mux_hw->clk = hw->clk; 124 - return mux_ops->determine_rate(mux_hw, rate, best_parent_rate, 120 + return mux_ops->determine_rate(mux_hw, rate, min_rate, 121 + max_rate, best_parent_rate, 125 122 best_parent_p); 126 123 } else { 127 124 pr_err("clk: clk_composite_determine_rate function called, but no mux or rate callback set!\n");
+225 -61
drivers/clk/clk.c
··· 42 42 static int clk_core_get_phase(struct clk_core *clk); 43 43 static bool clk_core_is_prepared(struct clk_core *clk); 44 44 static bool clk_core_is_enabled(struct clk_core *clk); 45 - static unsigned long clk_core_round_rate_nolock(struct clk_core *clk, 46 - unsigned long rate); 47 45 static struct clk_core *clk_core_lookup(const char *name); 48 46 49 47 /*** private data structures ***/ ··· 57 59 u8 num_parents; 58 60 u8 new_parent_index; 59 61 unsigned long rate; 62 + unsigned long req_rate; 60 63 unsigned long new_rate; 61 64 struct clk_core *new_parent; 62 65 struct clk_core *new_child; ··· 69 70 struct hlist_head children; 70 71 struct hlist_node child_node; 71 72 struct hlist_node debug_node; 73 + struct hlist_head clks; 72 74 unsigned int notifier_count; 73 75 #ifdef CONFIG_DEBUG_FS 74 76 struct dentry *dentry; ··· 81 81 struct clk_core *core; 82 82 const char *dev_id; 83 83 const char *con_id; 84 + unsigned long min_rate; 85 + unsigned long max_rate; 86 + struct hlist_node child_node; 84 87 }; 85 88 86 89 /*** locking ***/ ··· 786 783 787 784 static long 788 785 clk_mux_determine_rate_flags(struct clk_hw *hw, unsigned long rate, 786 + unsigned long min_rate, 787 + unsigned long max_rate, 789 788 unsigned long *best_parent_rate, 790 789 struct clk_hw **best_parent_p, 791 790 unsigned long flags) ··· 800 795 if (core->flags & CLK_SET_RATE_NO_REPARENT) { 801 796 parent = core->parent; 802 797 if (core->flags & CLK_SET_RATE_PARENT) 803 - best = clk_core_round_rate_nolock(parent, rate); 798 + best = __clk_determine_rate(parent->hw, rate, 799 + min_rate, max_rate); 804 800 else if (parent) 805 801 best = clk_core_get_rate_nolock(parent); 806 802 else ··· 816 810 if (!parent) 817 811 continue; 818 812 if (core->flags & CLK_SET_RATE_PARENT) 819 - parent_rate = clk_core_round_rate_nolock(parent, rate); 813 + parent_rate = __clk_determine_rate(parent->hw, rate, 814 + min_rate, 815 + max_rate); 820 816 else 821 817 parent_rate = clk_core_get_rate_nolock(parent); 822 818 if (mux_is_better_rate(rate, parent_rate, best, flags)) { ··· 842 834 return !core ? NULL : core->hw->clk; 843 835 } 844 836 837 + static void clk_core_get_boundaries(struct clk_core *clk, 838 + unsigned long *min_rate, 839 + unsigned long *max_rate) 840 + { 841 + struct clk *clk_user; 842 + 843 + *min_rate = 0; 844 + *max_rate = ULONG_MAX; 845 + 846 + hlist_for_each_entry(clk_user, &clk->clks, child_node) 847 + *min_rate = max(*min_rate, clk_user->min_rate); 848 + 849 + hlist_for_each_entry(clk_user, &clk->clks, child_node) 850 + *max_rate = min(*max_rate, clk_user->max_rate); 851 + } 852 + 845 853 /* 846 854 * Helper for finding best parent to provide a given frequency. This can be used 847 855 * directly as a determine_rate callback (e.g. for a mux), or from a more 848 856 * complex clock that may combine a mux with other operations. 849 857 */ 850 858 long __clk_mux_determine_rate(struct clk_hw *hw, unsigned long rate, 859 + unsigned long min_rate, 860 + unsigned long max_rate, 851 861 unsigned long *best_parent_rate, 852 862 struct clk_hw **best_parent_p) 853 863 { 854 - return clk_mux_determine_rate_flags(hw, rate, best_parent_rate, 864 + return clk_mux_determine_rate_flags(hw, rate, min_rate, max_rate, 865 + best_parent_rate, 855 866 best_parent_p, 0); 856 867 } 857 868 EXPORT_SYMBOL_GPL(__clk_mux_determine_rate); 858 869 859 870 long __clk_mux_determine_rate_closest(struct clk_hw *hw, unsigned long rate, 871 + unsigned long min_rate, 872 + unsigned long max_rate, 860 873 unsigned long *best_parent_rate, 861 874 struct clk_hw **best_parent_p) 862 875 { 863 - return clk_mux_determine_rate_flags(hw, rate, best_parent_rate, 876 + return clk_mux_determine_rate_flags(hw, rate, min_rate, max_rate, 877 + best_parent_rate, 864 878 best_parent_p, 865 879 CLK_MUX_ROUND_CLOSEST); 866 880 } ··· 1098 1068 EXPORT_SYMBOL_GPL(clk_enable); 1099 1069 1100 1070 static unsigned long clk_core_round_rate_nolock(struct clk_core *clk, 1101 - unsigned long rate) 1071 + unsigned long rate, 1072 + unsigned long min_rate, 1073 + unsigned long max_rate) 1102 1074 { 1103 1075 unsigned long parent_rate = 0; 1104 1076 struct clk_core *parent; ··· 1115 1083 1116 1084 if (clk->ops->determine_rate) { 1117 1085 parent_hw = parent ? parent->hw : NULL; 1118 - return clk->ops->determine_rate(clk->hw, rate, &parent_rate, 1119 - &parent_hw); 1086 + return clk->ops->determine_rate(clk->hw, rate, 1087 + min_rate, max_rate, 1088 + &parent_rate, &parent_hw); 1120 1089 } else if (clk->ops->round_rate) 1121 1090 return clk->ops->round_rate(clk->hw, rate, &parent_rate); 1122 1091 else if (clk->flags & CLK_SET_RATE_PARENT) 1123 - return clk_core_round_rate_nolock(clk->parent, rate); 1092 + return clk_core_round_rate_nolock(clk->parent, rate, min_rate, 1093 + max_rate); 1124 1094 else 1125 1095 return clk->rate; 1126 1096 } 1097 + 1098 + /** 1099 + * __clk_determine_rate - get the closest rate actually supported by a clock 1100 + * @hw: determine the rate of this clock 1101 + * @rate: target rate 1102 + * @min_rate: returned rate must be greater than this rate 1103 + * @max_rate: returned rate must be less than this rate 1104 + * 1105 + * Caller must hold prepare_lock. Useful for clk_ops such as .set_rate and 1106 + * .determine_rate. 1107 + */ 1108 + unsigned long __clk_determine_rate(struct clk_hw *hw, 1109 + unsigned long rate, 1110 + unsigned long min_rate, 1111 + unsigned long max_rate) 1112 + { 1113 + if (!hw) 1114 + return 0; 1115 + 1116 + return clk_core_round_rate_nolock(hw->core, rate, min_rate, max_rate); 1117 + } 1118 + EXPORT_SYMBOL_GPL(__clk_determine_rate); 1127 1119 1128 1120 /** 1129 1121 * __clk_round_rate - round the given rate for a clk ··· 1158 1102 */ 1159 1103 unsigned long __clk_round_rate(struct clk *clk, unsigned long rate) 1160 1104 { 1105 + unsigned long min_rate; 1106 + unsigned long max_rate; 1107 + 1161 1108 if (!clk) 1162 1109 return 0; 1163 1110 1164 - return clk_core_round_rate_nolock(clk->core, rate); 1111 + clk_core_get_boundaries(clk->core, &min_rate, &max_rate); 1112 + 1113 + return clk_core_round_rate_nolock(clk->core, rate, min_rate, max_rate); 1165 1114 } 1166 1115 EXPORT_SYMBOL_GPL(__clk_round_rate); 1167 1116 ··· 1187 1126 return 0; 1188 1127 1189 1128 clk_prepare_lock(); 1190 - ret = clk_core_round_rate_nolock(clk->core, rate); 1129 + ret = __clk_round_rate(clk, rate); 1191 1130 clk_prepare_unlock(); 1192 1131 1193 1132 return ret; ··· 1578 1517 struct clk_hw *parent_hw; 1579 1518 unsigned long best_parent_rate = 0; 1580 1519 unsigned long new_rate; 1520 + unsigned long min_rate; 1521 + unsigned long max_rate; 1581 1522 int p_index = 0; 1582 1523 1583 1524 /* sanity */ ··· 1591 1528 if (parent) 1592 1529 best_parent_rate = parent->rate; 1593 1530 1531 + clk_core_get_boundaries(clk, &min_rate, &max_rate); 1532 + 1594 1533 /* find the closest rate and parent clk/rate */ 1595 1534 if (clk->ops->determine_rate) { 1596 1535 parent_hw = parent ? parent->hw : NULL; 1597 1536 new_rate = clk->ops->determine_rate(clk->hw, rate, 1537 + min_rate, 1538 + max_rate, 1598 1539 &best_parent_rate, 1599 1540 &parent_hw); 1600 1541 parent = parent_hw ? parent_hw->core : NULL; 1601 1542 } else if (clk->ops->round_rate) { 1602 1543 new_rate = clk->ops->round_rate(clk->hw, rate, 1603 1544 &best_parent_rate); 1545 + if (new_rate < min_rate || new_rate > max_rate) 1546 + return NULL; 1604 1547 } else if (!parent || !(clk->flags & CLK_SET_RATE_PARENT)) { 1605 1548 /* pass-through clock without adjustable parent */ 1606 1549 clk->new_rate = clk->rate; ··· 1744 1675 clk_change_rate(clk->new_child); 1745 1676 } 1746 1677 1678 + static int clk_core_set_rate_nolock(struct clk_core *clk, 1679 + unsigned long req_rate) 1680 + { 1681 + struct clk_core *top, *fail_clk; 1682 + unsigned long rate = req_rate; 1683 + int ret = 0; 1684 + 1685 + if (!clk) 1686 + return 0; 1687 + 1688 + /* bail early if nothing to do */ 1689 + if (rate == clk_core_get_rate_nolock(clk)) 1690 + return 0; 1691 + 1692 + if ((clk->flags & CLK_SET_RATE_GATE) && clk->prepare_count) 1693 + return -EBUSY; 1694 + 1695 + /* calculate new rates and get the topmost changed clock */ 1696 + top = clk_calc_new_rates(clk, rate); 1697 + if (!top) 1698 + return -EINVAL; 1699 + 1700 + /* notify that we are about to change rates */ 1701 + fail_clk = clk_propagate_rate_change(top, PRE_RATE_CHANGE); 1702 + if (fail_clk) { 1703 + pr_debug("%s: failed to set %s rate\n", __func__, 1704 + fail_clk->name); 1705 + clk_propagate_rate_change(top, ABORT_RATE_CHANGE); 1706 + return -EBUSY; 1707 + } 1708 + 1709 + /* change the rates */ 1710 + clk_change_rate(top); 1711 + 1712 + clk->req_rate = req_rate; 1713 + 1714 + return ret; 1715 + } 1716 + 1747 1717 /** 1748 1718 * clk_set_rate - specify a new rate for clk 1749 1719 * @clk: the clk whose rate is being changed ··· 1806 1698 */ 1807 1699 int clk_set_rate(struct clk *clk, unsigned long rate) 1808 1700 { 1809 - struct clk_core *top, *fail_clk; 1810 - int ret = 0; 1701 + int ret; 1811 1702 1812 1703 if (!clk) 1813 1704 return 0; ··· 1814 1707 /* prevent racing with updates to the clock topology */ 1815 1708 clk_prepare_lock(); 1816 1709 1817 - /* bail early if nothing to do */ 1818 - if (rate == clk_get_rate(clk)) 1819 - goto out; 1710 + ret = clk_core_set_rate_nolock(clk->core, rate); 1820 1711 1821 - if ((clk->core->flags & CLK_SET_RATE_GATE) && 1822 - clk->core->prepare_count) { 1823 - ret = -EBUSY; 1824 - goto out; 1825 - } 1826 - 1827 - /* calculate new rates and get the topmost changed clock */ 1828 - top = clk_calc_new_rates(clk->core, rate); 1829 - if (!top) { 1830 - ret = -EINVAL; 1831 - goto out; 1832 - } 1833 - 1834 - /* notify that we are about to change rates */ 1835 - fail_clk = clk_propagate_rate_change(top, PRE_RATE_CHANGE); 1836 - if (fail_clk) { 1837 - pr_debug("%s: failed to set %s rate\n", __func__, 1838 - fail_clk->name); 1839 - clk_propagate_rate_change(top, ABORT_RATE_CHANGE); 1840 - ret = -EBUSY; 1841 - goto out; 1842 - } 1843 - 1844 - /* change the rates */ 1845 - clk_change_rate(top); 1846 - 1847 - out: 1848 1712 clk_prepare_unlock(); 1849 1713 1850 1714 return ret; 1851 1715 } 1852 1716 EXPORT_SYMBOL_GPL(clk_set_rate); 1717 + 1718 + /** 1719 + * clk_set_rate_range - set a rate range for a clock source 1720 + * @clk: clock source 1721 + * @min: desired minimum clock rate in Hz, inclusive 1722 + * @max: desired maximum clock rate in Hz, inclusive 1723 + * 1724 + * Returns success (0) or negative errno. 1725 + */ 1726 + int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) 1727 + { 1728 + int ret = 0; 1729 + 1730 + if (!clk) 1731 + return 0; 1732 + 1733 + if (min > max) { 1734 + pr_err("%s: clk %s dev %s con %s: invalid range [%lu, %lu]\n", 1735 + __func__, clk->core->name, clk->dev_id, clk->con_id, 1736 + min, max); 1737 + return -EINVAL; 1738 + } 1739 + 1740 + clk_prepare_lock(); 1741 + 1742 + if (min != clk->min_rate || max != clk->max_rate) { 1743 + clk->min_rate = min; 1744 + clk->max_rate = max; 1745 + ret = clk_core_set_rate_nolock(clk->core, clk->core->req_rate); 1746 + } 1747 + 1748 + clk_prepare_unlock(); 1749 + 1750 + return ret; 1751 + } 1752 + EXPORT_SYMBOL_GPL(clk_set_rate_range); 1753 + 1754 + /** 1755 + * clk_set_min_rate - set a minimum clock rate for a clock source 1756 + * @clk: clock source 1757 + * @rate: desired minimum clock rate in Hz, inclusive 1758 + * 1759 + * Returns success (0) or negative errno. 1760 + */ 1761 + int clk_set_min_rate(struct clk *clk, unsigned long rate) 1762 + { 1763 + if (!clk) 1764 + return 0; 1765 + 1766 + return clk_set_rate_range(clk, rate, clk->max_rate); 1767 + } 1768 + EXPORT_SYMBOL_GPL(clk_set_min_rate); 1769 + 1770 + /** 1771 + * clk_set_max_rate - set a maximum clock rate for a clock source 1772 + * @clk: clock source 1773 + * @rate: desired maximum clock rate in Hz, inclusive 1774 + * 1775 + * Returns success (0) or negative errno. 1776 + */ 1777 + int clk_set_max_rate(struct clk *clk, unsigned long rate) 1778 + { 1779 + if (!clk) 1780 + return 0; 1781 + 1782 + return clk_set_rate_range(clk, clk->min_rate, rate); 1783 + } 1784 + EXPORT_SYMBOL_GPL(clk_set_max_rate); 1853 1785 1854 1786 /** 1855 1787 * clk_get_parent - return the parent of a clk ··· 2184 2038 struct clk_core *orphan; 2185 2039 struct hlist_node *tmp2; 2186 2040 struct clk_core *clk; 2041 + unsigned long rate; 2187 2042 2188 2043 if (!clk_user) 2189 2044 return -EINVAL; ··· 2309 2162 * then rate is set to zero. 2310 2163 */ 2311 2164 if (clk->ops->recalc_rate) 2312 - clk->rate = clk->ops->recalc_rate(clk->hw, 2165 + rate = clk->ops->recalc_rate(clk->hw, 2313 2166 clk_core_get_rate_nolock(clk->parent)); 2314 2167 else if (clk->parent) 2315 - clk->rate = clk->parent->rate; 2168 + rate = clk->parent->rate; 2316 2169 else 2317 - clk->rate = 0; 2170 + rate = 0; 2171 + clk->rate = clk->req_rate = rate; 2318 2172 2319 2173 /* 2320 2174 * walk the list of orphan clocks and reparent any that are children of ··· 2373 2225 clk->core = hw->core; 2374 2226 clk->dev_id = dev_id; 2375 2227 clk->con_id = con_id; 2228 + clk->max_rate = ULONG_MAX; 2229 + 2230 + clk_prepare_lock(); 2231 + hlist_add_head(&clk->child_node, &hw->core->clks); 2232 + clk_prepare_unlock(); 2376 2233 2377 2234 return clk; 2235 + } 2236 + 2237 + static void __clk_free_clk(struct clk *clk) 2238 + { 2239 + clk_prepare_lock(); 2240 + hlist_del(&clk->child_node); 2241 + clk_prepare_unlock(); 2242 + 2243 + kfree(clk); 2378 2244 } 2379 2245 2380 2246 /** ··· 2450 2288 } 2451 2289 } 2452 2290 2291 + INIT_HLIST_HEAD(&clk->clks); 2292 + 2453 2293 hw->clk = __clk_create_clk(hw, NULL, NULL); 2454 2294 if (IS_ERR(hw->clk)) { 2455 2295 pr_err("%s: could not allocate per-user clk\n", __func__); ··· 2463 2299 if (!ret) 2464 2300 return hw->clk; 2465 2301 2466 - kfree(hw->clk); 2302 + __clk_free_clk(hw->clk); 2467 2303 hw->clk = NULL; 2304 + 2468 2305 fail_parent_names_copy: 2469 2306 while (--i >= 0) 2470 2307 kfree(clk->parent_names[i]); ··· 2654 2489 return 1; 2655 2490 } 2656 2491 2657 - static void clk_core_put(struct clk_core *core) 2492 + void __clk_put(struct clk *clk) 2658 2493 { 2659 2494 struct module *owner; 2660 2495 2661 - owner = core->owner; 2662 - 2663 - clk_prepare_lock(); 2664 - kref_put(&core->ref, __clk_release); 2665 - clk_prepare_unlock(); 2666 - 2667 - module_put(owner); 2668 - } 2669 - 2670 - void __clk_put(struct clk *clk) 2671 - { 2672 2496 if (!clk || WARN_ON_ONCE(IS_ERR(clk))) 2673 2497 return; 2674 2498 2675 - clk_core_put(clk->core); 2499 + clk_prepare_lock(); 2500 + 2501 + hlist_del(&clk->child_node); 2502 + clk_core_set_rate_nolock(clk->core, clk->core->req_rate); 2503 + owner = clk->core->owner; 2504 + kref_put(&clk->core->ref, __clk_release); 2505 + 2506 + clk_prepare_unlock(); 2507 + 2508 + module_put(owner); 2509 + 2676 2510 kfree(clk); 2677 2511 } 2678 2512
+2
drivers/clk/hisilicon/clk-hi3620.c
··· 295 295 } 296 296 297 297 static long mmc_clk_determine_rate(struct clk_hw *hw, unsigned long rate, 298 + unsigned long min_rate, 299 + unsigned long max_rate, 298 300 unsigned long *best_parent_rate, 299 301 struct clk_hw **best_parent_p) 300 302 {
+2
drivers/clk/mmp/clk-mix.c
··· 202 202 } 203 203 204 204 static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, 205 + unsigned long min_rate, 206 + unsigned long max_rate, 205 207 unsigned long *best_parent_rate, 206 208 struct clk_hw **best_parent_clk) 207 209 {
+1
drivers/clk/qcom/clk-pll.c
··· 141 141 142 142 static long 143 143 clk_pll_determine_rate(struct clk_hw *hw, unsigned long rate, 144 + unsigned long min_rate, unsigned long max_rate, 144 145 unsigned long *p_rate, struct clk_hw **p) 145 146 { 146 147 struct clk_pll *pll = to_clk_pll(hw);
+8 -2
drivers/clk/qcom/clk-rcg.c
··· 368 368 369 369 static long _freq_tbl_determine_rate(struct clk_hw *hw, 370 370 const struct freq_tbl *f, unsigned long rate, 371 + unsigned long min_rate, unsigned long max_rate, 371 372 unsigned long *p_rate, struct clk_hw **p_hw) 372 373 { 373 374 unsigned long clk_flags; ··· 398 397 } 399 398 400 399 static long clk_rcg_determine_rate(struct clk_hw *hw, unsigned long rate, 400 + unsigned long min_rate, unsigned long max_rate, 401 401 unsigned long *p_rate, struct clk_hw **p) 402 402 { 403 403 struct clk_rcg *rcg = to_clk_rcg(hw); 404 404 405 - return _freq_tbl_determine_rate(hw, rcg->freq_tbl, rate, p_rate, p); 405 + return _freq_tbl_determine_rate(hw, rcg->freq_tbl, rate, min_rate, 406 + max_rate, p_rate, p); 406 407 } 407 408 408 409 static long clk_dyn_rcg_determine_rate(struct clk_hw *hw, unsigned long rate, 410 + unsigned long min_rate, unsigned long max_rate, 409 411 unsigned long *p_rate, struct clk_hw **p) 410 412 { 411 413 struct clk_dyn_rcg *rcg = to_clk_dyn_rcg(hw); 412 414 413 - return _freq_tbl_determine_rate(hw, rcg->freq_tbl, rate, p_rate, p); 415 + return _freq_tbl_determine_rate(hw, rcg->freq_tbl, rate, min_rate, 416 + max_rate, p_rate, p); 414 417 } 415 418 416 419 static long clk_rcg_bypass_determine_rate(struct clk_hw *hw, unsigned long rate, 420 + unsigned long min_rate, unsigned long max_rate, 417 421 unsigned long *p_rate, struct clk_hw **p_hw) 418 422 { 419 423 struct clk_rcg *rcg = to_clk_rcg(hw);
+6
drivers/clk/qcom/clk-rcg2.c
··· 208 208 } 209 209 210 210 static long clk_rcg2_determine_rate(struct clk_hw *hw, unsigned long rate, 211 + unsigned long min_rate, unsigned long max_rate, 211 212 unsigned long *p_rate, struct clk_hw **p) 212 213 { 213 214 struct clk_rcg2 *rcg = to_clk_rcg2(hw); ··· 362 361 } 363 362 364 363 static long clk_edp_pixel_determine_rate(struct clk_hw *hw, unsigned long rate, 364 + unsigned long min_rate, 365 + unsigned long max_rate, 365 366 unsigned long *p_rate, struct clk_hw **p) 366 367 { 367 368 struct clk_rcg2 *rcg = to_clk_rcg2(hw); ··· 415 412 EXPORT_SYMBOL_GPL(clk_edp_pixel_ops); 416 413 417 414 static long clk_byte_determine_rate(struct clk_hw *hw, unsigned long rate, 415 + unsigned long min_rate, unsigned long max_rate, 418 416 unsigned long *p_rate, struct clk_hw **p_hw) 419 417 { 420 418 struct clk_rcg2 *rcg = to_clk_rcg2(hw); ··· 480 476 }; 481 477 482 478 static long clk_pixel_determine_rate(struct clk_hw *hw, unsigned long rate, 479 + unsigned long min_rate, 480 + unsigned long max_rate, 483 481 unsigned long *p_rate, struct clk_hw **p) 484 482 { 485 483 struct clk_rcg2 *rcg = to_clk_rcg2(hw);
+2
drivers/clk/sunxi/clk-factors.c
··· 80 80 } 81 81 82 82 static long clk_factors_determine_rate(struct clk_hw *hw, unsigned long rate, 83 + unsigned long min_rate, 84 + unsigned long max_rate, 83 85 unsigned long *best_parent_rate, 84 86 struct clk_hw **best_parent_p) 85 87 {
+2
drivers/clk/sunxi/clk-sun6i-ar100.c
··· 45 45 } 46 46 47 47 static long ar100_determine_rate(struct clk_hw *hw, unsigned long rate, 48 + unsigned long min_rate, 49 + unsigned long max_rate, 48 50 unsigned long *best_parent_rate, 49 51 struct clk_hw **best_parent_clk) 50 52 {
+2
drivers/clk/sunxi/clk-sunxi.c
··· 119 119 } 120 120 121 121 static long sun6i_ahb1_clk_determine_rate(struct clk_hw *hw, unsigned long rate, 122 + unsigned long min_rate, 123 + unsigned long max_rate, 122 124 unsigned long *best_parent_rate, 123 125 struct clk_hw **best_parent_clk) 124 126 {
+14 -3
include/linux/clk-provider.h
··· 175 175 unsigned long parent_rate); 176 176 long (*round_rate)(struct clk_hw *hw, unsigned long rate, 177 177 unsigned long *parent_rate); 178 - long (*determine_rate)(struct clk_hw *hw, unsigned long rate, 179 - unsigned long *best_parent_rate, 180 - struct clk_hw **best_parent_hw); 178 + long (*determine_rate)(struct clk_hw *hw, 179 + unsigned long rate, 180 + unsigned long min_rate, 181 + unsigned long max_rate, 182 + unsigned long *best_parent_rate, 183 + struct clk_hw **best_parent_hw); 181 184 int (*set_parent)(struct clk_hw *hw, u8 index); 182 185 u8 (*get_parent)(struct clk_hw *hw); 183 186 int (*set_rate)(struct clk_hw *hw, unsigned long rate, ··· 576 573 bool __clk_is_enabled(struct clk *clk); 577 574 struct clk *__clk_lookup(const char *name); 578 575 long __clk_mux_determine_rate(struct clk_hw *hw, unsigned long rate, 576 + unsigned long min_rate, 577 + unsigned long max_rate, 579 578 unsigned long *best_parent_rate, 580 579 struct clk_hw **best_parent_p); 580 + unsigned long __clk_determine_rate(struct clk_hw *core, 581 + unsigned long rate, 582 + unsigned long min_rate, 583 + unsigned long max_rate); 581 584 long __clk_mux_determine_rate_closest(struct clk_hw *hw, unsigned long rate, 585 + unsigned long min_rate, 586 + unsigned long max_rate, 582 587 unsigned long *best_parent_rate, 583 588 struct clk_hw **best_parent_p); 584 589
+28
include/linux/clk.h
··· 314 314 bool clk_has_parent(struct clk *clk, struct clk *parent); 315 315 316 316 /** 317 + * clk_set_rate_range - set a rate range for a clock source 318 + * @clk: clock source 319 + * @min: desired minimum clock rate in Hz, inclusive 320 + * @max: desired maximum clock rate in Hz, inclusive 321 + * 322 + * Returns success (0) or negative errno. 323 + */ 324 + int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max); 325 + 326 + /** 327 + * clk_set_min_rate - set a minimum clock rate for a clock source 328 + * @clk: clock source 329 + * @rate: desired minimum clock rate in Hz, inclusive 330 + * 331 + * Returns success (0) or negative errno. 332 + */ 333 + int clk_set_min_rate(struct clk *clk, unsigned long rate); 334 + 335 + /** 336 + * clk_set_max_rate - set a maximum clock rate for a clock source 337 + * @clk: clock source 338 + * @rate: desired maximum clock rate in Hz, inclusive 339 + * 340 + * Returns success (0) or negative errno. 341 + */ 342 + int clk_set_max_rate(struct clk *clk, unsigned long rate); 343 + 344 + /** 317 345 * clk_set_parent - set the parent clock source for this clock 318 346 * @clk: clock source 319 347 * @parent: parent clock source
+4
include/linux/clk/ti.h
··· 271 271 u8 index); 272 272 long omap3_noncore_dpll_determine_rate(struct clk_hw *hw, 273 273 unsigned long rate, 274 + unsigned long min_rate, 275 + unsigned long max_rate, 274 276 unsigned long *best_parent_rate, 275 277 struct clk_hw **best_parent_clk); 276 278 unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw, ··· 282 280 unsigned long *parent_rate); 283 281 long omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw, 284 282 unsigned long rate, 283 + unsigned long min_rate, 284 + unsigned long max_rate, 285 285 unsigned long *best_parent_rate, 286 286 struct clk_hw **best_parent_clk); 287 287 u8 omap2_init_dpll_parent(struct clk_hw *hw);