History

Merge branches 'clk-bulk-optional', 'clk-kirkwood', 'clk-socfpga' and 'clk-docs' into clk-next

- 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/

Stephen Boyd committed 7 years ago

Commit dfe1d3a5 parents e02cb1f 179175d 88aa7af 16e3c57 65e22189 files · +120 −12Browse files

Unified · Split

9 files
  1. Documentation/devicetree/bindings/clock/mvebu-core-clock.txt +1 −0
  2. Documentation/driver-model/devres.txt +4 −0
  3. drivers/clk/clk-bulk.c +20 −3
  4. drivers/clk/clk-devres.c +19 −3
  5. drivers/clk/clk.c +2 −2
  6. drivers/clk/mvebu/kirkwood.c +17 −0
  7. drivers/clk/socfpga/clk-s10.c +7 −3
  8. include/dt-bindings/clock/stratix10-clock.h +3 −1
  9. include/linux/clk.h +47 −0
Documentation/devicetree/bindings/clock/mvebu-core-clock.txt+1−0
@@ -59,6 +59,7 @@ Required properties: · 58 unmodified lines
5959 "marvell,dove-core-clock" - for Dove SoC core clocks
6060 "marvell,kirkwood-core-clock" - for Kirkwood SoC (except mv88f6180)
6161 "marvell,mv88f6180-core-clock" - for Kirkwood MV88f6180 SoC
62+ "marvell,mv98dx1135-core-clock" - for Kirkwood 98dx1135 SoC
6263 "marvell,mv88f5181-core-clock" - for Orion MV88F5181 SoC
6364 "marvell,mv88f5182-core-clock" - for Orion MV88F5182 SoC
6465 "marvell,mv88f5281-core-clock" - for Orion MV88F5281 SoC
Documentation/driver-model/devres.txt+4−0
@@ -244,6 +244,10 @@ CLOCK · 243 unmodified lines
244244 devm_clk_get()
245245 devm_clk_get_optional()
246246 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()
247251 devm_clk_hw_register()
248252 devm_of_clk_add_hw_provider()
249253 devm_clk_hw_register_clkdev()
drivers/clk/clk-bulk.c+20−3
@@ -75,8 +75,8 @@ void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) · 74 unmodified lines
7575 }
7676 EXPORT_SYMBOL_GPL(clk_bulk_put);
7777
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)
8080 {
8181 int ret;
8282 int i;
@@ -88,10 +88,14 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks, · 5 unmodified lines
8888 clks[i].clk = clk_get(dev, clks[i].id);
8989 if (IS_ERR(clks[i].clk)) {
9090 ret = PTR_ERR(clks[i].clk);
91+ clks[i].clk = NULL;
92+
93+ if (ret == -ENOENT && optional)
94+ continue;
95+
9196 if (ret != -EPROBE_DEFER)
9297 dev_err(dev, "Failed to get clk '%s': %d\n",
9398 clks[i].id, ret);
94− clks[i].clk = NULL;
9599 goto err;
96100 }
97101 }
@@ -103,8 +107,21 @@ err: · 5 unmodified lines
103107
104108 return ret;
105109 }
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+}
106116 EXPORT_SYMBOL(clk_bulk_get);
107117
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+
108125 void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks)
109126 {
110127 if (IS_ERR_OR_NULL(clks))
drivers/clk/clk-devres.c+19−3
@@ -52,8 +52,8 @@ static void devm_clk_bulk_release(struct device *dev, void *res) · 51 unmodified lines
5252 clk_bulk_put(devres->num_clks, devres->clks);
5353 }
5454
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)
5757 {
5858 struct clk_bulk_devres *devres;
5959 int ret;
@@ -63,7 +63,10 @@ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, · 3 unmodified lines
6363 if (!devres)
6464 return -ENOMEM;
6565
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);
6770 if (!ret) {
6871 devres->clks = clks;
6972 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
7477
7578 return ret;
7679 }
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+}
7786 EXPORT_SYMBOL_GPL(devm_clk_bulk_get);
7887
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+
7995 int __must_check devm_clk_bulk_get_all(struct device *dev,
8096 struct clk_bulk_data **clks)
8197 {
drivers/clk/clk.c+2−2
@@ -2194,7 +2194,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate) · 2193 unmodified lines
21942194 EXPORT_SYMBOL_GPL(clk_set_rate);
21952195
21962196 /**
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
21982198 * @clk: the clk whose rate is being changed
21992199 * @rate: the new rate for clk
22002200 *
@@ -2202,7 +2202,7 @@ EXPORT_SYMBOL_GPL(clk_set_rate); · 1 unmodified line
22022202 * within a critical section
22032203 *
22042204 * 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
22062206 * same clock provider.
22072207 *
22082208 * The exclusivity is not applied if setting the rate failed.
drivers/clk/mvebu/kirkwood.c+17−0
@@ -185,6 +185,11 @@ static void __init mv88f6180_get_clk_ratio( · 184 unmodified lines
185185 }
186186 }
187187
188+static u32 __init mv98dx1135_get_tclk_freq(void __iomem *sar)
189+{
190+ return 166666667;
191+}
192+
188193 static const struct coreclk_soc_desc kirkwood_coreclks = {
189194 .get_tclk_freq = kirkwood_get_tclk_freq,
190195 .get_cpu_freq = kirkwood_get_cpu_freq,
@@ -201,6 +206,14 @@ static const struct coreclk_soc_desc mv88f6180_coreclks = { · 10 unmodified lines
201206 .num_ratios = ARRAY_SIZE(kirkwood_coreclk_ratios),
202207 };
203208
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+
204217 /*
205218 * Clock Gating Control
206219 */
@@ -325,6 +338,8 @@ static void __init kirkwood_clk_init(struct device_node *np) · 118 unmodified lines
325338
326339 if (of_device_is_compatible(np, "marvell,mv88f6180-core-clock"))
327340 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);
328343 else
329344 mvebu_coreclk_setup(np, &kirkwood_coreclks);
330345
@@ -339,3 +354,5 @@ CLK_OF_DECLARE(kirkwood_clk, "marvell,kirkwood-core-clock", · 8 unmodified lines
339354 kirkwood_clk_init);
340355 CLK_OF_DECLARE(mv88f6180_clk, "marvell,mv88f6180-core-clock",
341356 kirkwood_clk_init);
357+CLK_OF_DECLARE(98dx1135_clk, "marvell,mv98dx1135-core-clock",
358+ kirkwood_clk_init);
drivers/clk/socfpga/clk-s10.c+7−3
@@ -103,9 +103,9 @@ static const struct stratix10_perip_cnt_clock s10_main_perip_cnt_clks[] = { · 102 unmodified lines
103103 { STRATIX10_NOC_CLK, "noc_clk", NULL, noc_mux, ARRAY_SIZE(noc_mux),
104104 0, 0, 0, 0x3C, 1},
105105 { 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},
107107 { 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},
109109 { STRATIX10_EMAC_PTP_FREE_CLK, "emac_ptp_free_clk", NULL, emac_ptp_free_mux,
110110 ARRAY_SIZE(emac_ptp_free_mux), 0, 0, 4, 0xB0, 2},
111111 { 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
161161 8, 0, 0, 0, 0, 0, 0},
162162 { STRATIX10_SPI_M_CLK, "spi_m_clk", "l4_mp_clk", NULL, 1, 0, 0xA4,
163163 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,
165165 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},
166170 };
167171
168172 static int s10_clk_register_c_perip(const struct stratix10_perip_c_clock *clks,
include/dt-bindings/clock/stratix10-clock.h+3−1
@@ -79,6 +79,8 @@ · 78 unmodified lines
7979 #define STRATIX10_USB_CLK 59
8080 #define STRATIX10_SPI_M_CLK 60
8181 #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
8385
8486 #endif /* __STRATIX10_CLOCK_H */
include/linux/clk.h+47−0
@@ -332,6 +332,19 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks, · 331 unmodified lines
332332 */
333333 int __must_check clk_bulk_get_all(struct device *dev,
334334 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);
335348 /**
336349 * devm_clk_bulk_get - managed get multiple clk consumers
337350 * @dev: device for clock "consumer"
@@ -346,6 +359,28 @@ int __must_check clk_bulk_get_all(struct device *dev, · 8 unmodified lines
346359 */
347360 int __must_check devm_clk_bulk_get(struct device *dev, int num_clks,
348361 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);
349384 /**
350385 * devm_clk_bulk_get_all - managed get multiple clk consumers
351386 * @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
718753 return 0;
719754 }
720755
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+
721762 static inline int __must_check clk_bulk_get_all(struct device *dev,
722763 struct clk_bulk_data **clks)
723764 {
@@ -741,6 +782,12 @@ static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clk · 17 unmodified lines
741782 return 0;
742783 }
743784
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+
744791 static inline int __must_check devm_clk_bulk_get_all(struct device *dev,
745792 struct clk_bulk_data **clks)
746793 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t