- Add a clk_bulk_get_optional() API (with devm too) - Support for Marvell 98DX1135 SoCs * clk-bulk-optional: clk: Document some devm_clk_bulk*() APIs clk: Add devm_clk_bulk_get_optional() function clk: Add clk_bulk_get_optional() function * clk-kirkwood: clk: kirkwood: Add support for MV98DX1135 dt-bindings: clock: mvebu: Add compatible string for 98dx1135 core clock * clk-socfpga: clk: socfpga: stratix10: fix divider entry for the emac clocks clk: socfpga: stratix10: add additional clocks needed for the NAND IP * clk-docs: clk: Grammar missing "and", Spelling s/statisfied/satisfied/
Unified · Split
| @@ -59,6 +59,7 @@ Required properties: · 58 unmodified lines | ||
| 59 | 59 | "marvell,dove-core-clock" - for Dove SoC core clocks |
| 60 | 60 | "marvell,kirkwood-core-clock" - for Kirkwood SoC (except mv88f6180) |
| 61 | 61 | "marvell,mv88f6180-core-clock" - for Kirkwood MV88f6180 SoC |
| 62 | + "marvell,mv98dx1135-core-clock" - for Kirkwood 98dx1135 SoC | |
| 62 | 63 | "marvell,mv88f5181-core-clock" - for Orion MV88F5181 SoC |
| 63 | 64 | "marvell,mv88f5182-core-clock" - for Orion MV88F5182 SoC |
| 64 | 65 | "marvell,mv88f5281-core-clock" - for Orion MV88F5281 SoC |
| @@ -244,6 +244,10 @@ CLOCK · 243 unmodified lines | ||
| 244 | 244 | devm_clk_get() |
| 245 | 245 | devm_clk_get_optional() |
| 246 | 246 | devm_clk_put() |
| 247 | + devm_clk_bulk_get() | |
| 248 | + devm_clk_bulk_get_all() | |
| 249 | + devm_clk_bulk_get_optional() | |
| 250 | + devm_get_clk_from_childl() | |
| 247 | 251 | devm_clk_hw_register() |
| 248 | 252 | devm_of_clk_add_hw_provider() |
| 249 | 253 | devm_clk_hw_register_clkdev() |
| @@ -75,8 +75,8 @@ void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) · 74 unmodified lines | ||
| 75 | 75 | } |
| 76 | 76 | EXPORT_SYMBOL_GPL(clk_bulk_put); |
| 77 | 77 | |
| 78 | −int __must_check clk_bulk_get(struct device *dev, int num_clks, | |
| 79 | − struct clk_bulk_data *clks) | |
| 78 | +static int __clk_bulk_get(struct device *dev, int num_clks, | |
| 79 | + struct clk_bulk_data *clks, bool optional) | |
| 80 | 80 | { |
| 81 | 81 | int ret; |
| 82 | 82 | int i; |
| @@ -88,10 +88,14 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks, · 5 unmodified lines | ||
| 88 | 88 | clks[i].clk = clk_get(dev, clks[i].id); |
| 89 | 89 | if (IS_ERR(clks[i].clk)) { |
| 90 | 90 | ret = PTR_ERR(clks[i].clk); |
| 91 | + clks[i].clk = NULL; | |
| 92 | + | |
| 93 | + if (ret == -ENOENT && optional) | |
| 94 | + continue; | |
| 95 | + | |
| 91 | 96 | if (ret != -EPROBE_DEFER) |
| 92 | 97 | dev_err(dev, "Failed to get clk '%s': %d\n", |
| 93 | 98 | clks[i].id, ret); |
| 94 | − clks[i].clk = NULL; | |
| 95 | 99 | goto err; |
| 96 | 100 | } |
| 97 | 101 | } |
| @@ -103,8 +107,21 @@ err: · 5 unmodified lines | ||
| 103 | 107 | |
| 104 | 108 | return ret; |
| 105 | 109 | } |
| 110 | + | |
| 111 | +int __must_check clk_bulk_get(struct device *dev, int num_clks, | |
| 112 | + struct clk_bulk_data *clks) | |
| 113 | +{ | |
| 114 | + return __clk_bulk_get(dev, num_clks, clks, false); | |
| 115 | +} | |
| 106 | 116 | EXPORT_SYMBOL(clk_bulk_get); |
| 107 | 117 | |
| 118 | +int __must_check clk_bulk_get_optional(struct device *dev, int num_clks, | |
| 119 | + struct clk_bulk_data *clks) | |
| 120 | +{ | |
| 121 | + return __clk_bulk_get(dev, num_clks, clks, true); | |
| 122 | +} | |
| 123 | +EXPORT_SYMBOL_GPL(clk_bulk_get_optional); | |
| 124 | + | |
| 108 | 125 | void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) |
| 109 | 126 | { |
| 110 | 127 | if (IS_ERR_OR_NULL(clks)) |
| @@ -52,8 +52,8 @@ static void devm_clk_bulk_release(struct device *dev, void *res) · 51 unmodified lines | ||
| 52 | 52 | clk_bulk_put(devres->num_clks, devres->clks); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | −int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, | |
| 56 | − struct clk_bulk_data *clks) | |
| 55 | +static int __devm_clk_bulk_get(struct device *dev, int num_clks, | |
| 56 | + struct clk_bulk_data *clks, bool optional) | |
| 57 | 57 | { |
| 58 | 58 | struct clk_bulk_devres *devres; |
| 59 | 59 | int ret; |
| @@ -63,7 +63,10 @@ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, · 3 unmodified lines | ||
| 63 | 63 | if (!devres) |
| 64 | 64 | return -ENOMEM; |
| 65 | 65 | |
| 66 | − ret = clk_bulk_get(dev, num_clks, clks); | |
| 66 | + if (optional) | |
| 67 | + ret = clk_bulk_get_optional(dev, num_clks, clks); | |
| 68 | + else | |
| 69 | + ret = clk_bulk_get(dev, num_clks, clks); | |
| 67 | 70 | if (!ret) { |
| 68 | 71 | devres->clks = clks; |
| 69 | 72 | devres->num_clks = num_clks; |
| @@ -74,8 +77,21 @@ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, · 4 unmodified lines | ||
| 74 | 77 | |
| 75 | 78 | return ret; |
| 76 | 79 | } |
| 80 | + | |
| 81 | +int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, | |
| 82 | + struct clk_bulk_data *clks) | |
| 83 | +{ | |
| 84 | + return __devm_clk_bulk_get(dev, num_clks, clks, false); | |
| 85 | +} | |
| 77 | 86 | EXPORT_SYMBOL_GPL(devm_clk_bulk_get); |
| 78 | 87 | |
| 88 | +int __must_check devm_clk_bulk_get_optional(struct device *dev, int num_clks, | |
| 89 | + struct clk_bulk_data *clks) | |
| 90 | +{ | |
| 91 | + return __devm_clk_bulk_get(dev, num_clks, clks, true); | |
| 92 | +} | |
| 93 | +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_optional); | |
| 94 | + | |
| 79 | 95 | int __must_check devm_clk_bulk_get_all(struct device *dev, |
| 80 | 96 | struct clk_bulk_data **clks) |
| 81 | 97 | { |
| @@ -2194,7 +2194,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate) · 2193 unmodified lines | ||
| 2194 | 2194 | EXPORT_SYMBOL_GPL(clk_set_rate); |
| 2195 | 2195 | |
| 2196 | 2196 | /** |
| 2197 | − * clk_set_rate_exclusive - specify a new rate get exclusive control | |
| 2197 | + * clk_set_rate_exclusive - specify a new rate and get exclusive control | |
| 2198 | 2198 | * @clk: the clk whose rate is being changed |
| 2199 | 2199 | * @rate: the new rate for clk |
| 2200 | 2200 | * |
| @@ -2202,7 +2202,7 @@ EXPORT_SYMBOL_GPL(clk_set_rate); · 1 unmodified line | ||
| 2202 | 2202 | * within a critical section |
| 2203 | 2203 | * |
| 2204 | 2204 | * This can be used initially to ensure that at least 1 consumer is |
| 2205 | − * statisfied when several consumers are competing for exclusivity over the | |
| 2205 | + * satisfied when several consumers are competing for exclusivity over the | |
| 2206 | 2206 | * same clock provider. |
| 2207 | 2207 | * |
| 2208 | 2208 | * The exclusivity is not applied if setting the rate failed. |
| @@ -185,6 +185,11 @@ static void __init mv88f6180_get_clk_ratio( · 184 unmodified lines | ||
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | +static u32 __init mv98dx1135_get_tclk_freq(void __iomem *sar) | |
| 189 | +{ | |
| 190 | + return 166666667; | |
| 191 | +} | |
| 192 | + | |
| 188 | 193 | static const struct coreclk_soc_desc kirkwood_coreclks = { |
| 189 | 194 | .get_tclk_freq = kirkwood_get_tclk_freq, |
| 190 | 195 | .get_cpu_freq = kirkwood_get_cpu_freq, |
| @@ -201,6 +206,14 @@ static const struct coreclk_soc_desc mv88f6180_coreclks = { · 10 unmodified lines | ||
| 201 | 206 | .num_ratios = ARRAY_SIZE(kirkwood_coreclk_ratios), |
| 202 | 207 | }; |
| 203 | 208 | |
| 209 | +static const struct coreclk_soc_desc mv98dx1135_coreclks = { | |
| 210 | + .get_tclk_freq = mv98dx1135_get_tclk_freq, | |
| 211 | + .get_cpu_freq = kirkwood_get_cpu_freq, | |
| 212 | + .get_clk_ratio = kirkwood_get_clk_ratio, | |
| 213 | + .ratios = kirkwood_coreclk_ratios, | |
| 214 | + .num_ratios = ARRAY_SIZE(kirkwood_coreclk_ratios), | |
| 215 | +}; | |
| 216 | + | |
| 204 | 217 | /* |
| 205 | 218 | * Clock Gating Control |
| 206 | 219 | */ |
| @@ -325,6 +338,8 @@ static void __init kirkwood_clk_init(struct device_node *np) · 118 unmodified lines | ||
| 325 | 338 | |
| 326 | 339 | if (of_device_is_compatible(np, "marvell,mv88f6180-core-clock")) |
| 327 | 340 | mvebu_coreclk_setup(np, &mv88f6180_coreclks); |
| 341 | + else if (of_device_is_compatible(np, "marvell,mv98dx1135-core-clock")) | |
| 342 | + mvebu_coreclk_setup(np, &mv98dx1135_coreclks); | |
| 328 | 343 | else |
| 329 | 344 | mvebu_coreclk_setup(np, &kirkwood_coreclks); |
| 330 | 345 | |
| @@ -339,3 +354,5 @@ CLK_OF_DECLARE(kirkwood_clk, "marvell,kirkwood-core-clock", · 8 unmodified lines | ||
| 339 | 354 | kirkwood_clk_init); |
| 340 | 355 | CLK_OF_DECLARE(mv88f6180_clk, "marvell,mv88f6180-core-clock", |
| 341 | 356 | kirkwood_clk_init); |
| 357 | +CLK_OF_DECLARE(98dx1135_clk, "marvell,mv98dx1135-core-clock", | |
| 358 | + kirkwood_clk_init); | |
| @@ -103,9 +103,9 @@ static const struct stratix10_perip_cnt_clock s10_main_perip_cnt_clks[] = { · 102 unmodified lines | ||
| 103 | 103 | { STRATIX10_NOC_CLK, "noc_clk", NULL, noc_mux, ARRAY_SIZE(noc_mux), |
| 104 | 104 | 0, 0, 0, 0x3C, 1}, |
| 105 | 105 | { STRATIX10_EMAC_A_FREE_CLK, "emaca_free_clk", NULL, emaca_free_mux, ARRAY_SIZE(emaca_free_mux), |
| 106 | − 0, 0, 4, 0xB0, 0}, | |
| 106 | + 0, 0, 2, 0xB0, 0}, | |
| 107 | 107 | { STRATIX10_EMAC_B_FREE_CLK, "emacb_free_clk", NULL, emacb_free_mux, ARRAY_SIZE(emacb_free_mux), |
| 108 | − 0, 0, 4, 0xB0, 1}, | |
| 108 | + 0, 0, 2, 0xB0, 1}, | |
| 109 | 109 | { STRATIX10_EMAC_PTP_FREE_CLK, "emac_ptp_free_clk", NULL, emac_ptp_free_mux, |
| 110 | 110 | ARRAY_SIZE(emac_ptp_free_mux), 0, 0, 4, 0xB0, 2}, |
| 111 | 111 | { STRATIX10_GPIO_DB_FREE_CLK, "gpio_db_free_clk", NULL, gpio_db_free_mux, |
| @@ -161,8 +161,12 @@ static const struct stratix10_gate_clock s10_gate_clks[] = { · 49 unmodified lines | ||
| 161 | 161 | 8, 0, 0, 0, 0, 0, 0}, |
| 162 | 162 | { STRATIX10_SPI_M_CLK, "spi_m_clk", "l4_mp_clk", NULL, 1, 0, 0xA4, |
| 163 | 163 | 9, 0, 0, 0, 0, 0, 0}, |
| 164 | − { STRATIX10_NAND_CLK, "nand_clk", "l4_main_clk", NULL, 1, 0, 0xA4, | |
| 164 | + { STRATIX10_NAND_X_CLK, "nand_x_clk", "l4_mp_clk", NULL, 1, 0, 0xA4, | |
| 165 | 165 | 10, 0, 0, 0, 0, 0, 0}, |
| 166 | + { STRATIX10_NAND_CLK, "nand_clk", "nand_x_clk", NULL, 1, 0, 0xA4, | |
| 167 | + 10, 0, 0, 0, 0, 0, 4}, | |
| 168 | + { STRATIX10_NAND_ECC_CLK, "nand_ecc_clk", "nand_x_clk", NULL, 1, 0, 0xA4, | |
| 169 | + 10, 0, 0, 0, 0, 0, 4}, | |
| 166 | 170 | }; |
| 167 | 171 | |
| 168 | 172 | static int s10_clk_register_c_perip(const struct stratix10_perip_c_clock *clks, |
| @@ -79,6 +79,8 @@ · 78 unmodified lines | ||
| 79 | 79 | #define STRATIX10_USB_CLK 59 |
| 80 | 80 | #define STRATIX10_SPI_M_CLK 60 |
| 81 | 81 | #define STRATIX10_NAND_CLK 61 |
| 82 | −#define STRATIX10_NUM_CLKS 62 | |
| 82 | +#define STRATIX10_NAND_X_CLK 62 | |
| 83 | +#define STRATIX10_NAND_ECC_CLK 63 | |
| 84 | +#define STRATIX10_NUM_CLKS 64 | |
| 83 | 85 | |
| 84 | 86 | #endif /* __STRATIX10_CLOCK_H */ |
| @@ -332,6 +332,19 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks, · 331 unmodified lines | ||
| 332 | 332 | */ |
| 333 | 333 | int __must_check clk_bulk_get_all(struct device *dev, |
| 334 | 334 | struct clk_bulk_data **clks); |
| 335 | + | |
| 336 | +/** | |
| 337 | + * clk_bulk_get_optional - lookup and obtain a number of references to clock producer | |
| 338 | + * @dev: device for clock "consumer" | |
| 339 | + * @num_clks: the number of clk_bulk_data | |
| 340 | + * @clks: the clk_bulk_data table of consumer | |
| 341 | + * | |
| 342 | + * Behaves the same as clk_bulk_get() except where there is no clock producer. | |
| 343 | + * In this case, instead of returning -ENOENT, the function returns 0 and | |
| 344 | + * NULL for a clk for which a clock producer could not be determined. | |
| 345 | + */ | |
| 346 | +int __must_check clk_bulk_get_optional(struct device *dev, int num_clks, | |
| 347 | + struct clk_bulk_data *clks); | |
| 335 | 348 | /** |
| 336 | 349 | * devm_clk_bulk_get - managed get multiple clk consumers |
| 337 | 350 | * @dev: device for clock "consumer" |
| @@ -346,6 +359,28 @@ int __must_check clk_bulk_get_all(struct device *dev, · 8 unmodified lines | ||
| 346 | 359 | */ |
| 347 | 360 | int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, |
| 348 | 361 | struct clk_bulk_data *clks); |
| 362 | +/** | |
| 363 | + * devm_clk_bulk_get_optional - managed get multiple optional consumer clocks | |
| 364 | + * @dev: device for clock "consumer" | |
| 365 | + * @clks: pointer to the clk_bulk_data table of consumer | |
| 366 | + * | |
| 367 | + * Behaves the same as devm_clk_bulk_get() except where there is no clock | |
| 368 | + * producer. In this case, instead of returning -ENOENT, the function returns | |
| 369 | + * NULL for given clk. It is assumed all clocks in clk_bulk_data are optional. | |
| 370 | + * | |
| 371 | + * Returns 0 if all clocks specified in clk_bulk_data table are obtained | |
| 372 | + * successfully or for any clk there was no clk provider available, otherwise | |
| 373 | + * returns valid IS_ERR() condition containing errno. | |
| 374 | + * The implementation uses @dev and @clk_bulk_data.id to determine the | |
| 375 | + * clock consumer, and thereby the clock producer. | |
| 376 | + * The clock returned is stored in each @clk_bulk_data.clk field. | |
| 377 | + * | |
| 378 | + * Drivers must assume that the clock source is not enabled. | |
| 379 | + * | |
| 380 | + * clk_bulk_get should not be called from within interrupt context. | |
| 381 | + */ | |
| 382 | +int __must_check devm_clk_bulk_get_optional(struct device *dev, int num_clks, | |
| 383 | + struct clk_bulk_data *clks); | |
| 349 | 384 | /** |
| 350 | 385 | * devm_clk_bulk_get_all - managed get multiple clk consumers |
| 351 | 386 | * @dev: device for clock "consumer" |
| @@ -718,6 +753,12 @@ static inline int __must_check clk_bulk_get(struct device *dev, int num_clks, · 366 unmodified lines | ||
| 718 | 753 | return 0; |
| 719 | 754 | } |
| 720 | 755 | |
| 756 | +static inline int __must_check clk_bulk_get_optional(struct device *dev, | |
| 757 | + int num_clks, struct clk_bulk_data *clks) | |
| 758 | +{ | |
| 759 | + return 0; | |
| 760 | +} | |
| 761 | + | |
| 721 | 762 | static inline int __must_check clk_bulk_get_all(struct device *dev, |
| 722 | 763 | struct clk_bulk_data **clks) |
| 723 | 764 | { |
| @@ -741,6 +782,12 @@ static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clk · 17 unmodified lines | ||
| 741 | 782 | return 0; |
| 742 | 783 | } |
| 743 | 784 | |
| 785 | +static inline int __must_check devm_clk_bulk_get_optional(struct device *dev, | |
| 786 | + int num_clks, struct clk_bulk_data *clks) | |
| 787 | +{ | |
| 788 | + return 0; | |
| 789 | +} | |
| 790 | + | |
| 744 | 791 | static inline int __must_check devm_clk_bulk_get_all(struct device *dev, |
| 745 | 792 | struct clk_bulk_data **clks) |
| 746 | 793 | { |