@@ -77,6 +77,21 @@ struct clk_notifier_data {
77
77
unsigned long new_rate ;
78
78
};
79
79
80
+ /**
81
+ * struct clk_bulk_data - Data used for bulk clk operations.
82
+ *
83
+ * @id: clock consumer ID
84
+ * @clk: struct clk * to store the associated clock
85
+ *
86
+ * The CLK APIs provide a series of clk_bulk_() API calls as
87
+ * a convenience to consumers which require multiple clks. This
88
+ * structure is used to manage data for these calls.
89
+ */
90
+ struct clk_bulk_data {
91
+ const char * id ;
92
+ struct clk * clk ;
93
+ };
94
+
80
95
#ifdef CONFIG_COMMON_CLK
81
96
82
97
/**
@@ -185,12 +200,20 @@ static inline bool clk_is_match(const struct clk *p, const struct clk *q)
185
200
*/
186
201
#ifdef CONFIG_HAVE_CLK_PREPARE
187
202
int clk_prepare (struct clk * clk );
203
+ int __must_check clk_bulk_prepare (int num_clks ,
204
+ const struct clk_bulk_data * clks );
188
205
#else
189
206
static inline int clk_prepare (struct clk * clk )
190
207
{
191
208
might_sleep ();
192
209
return 0 ;
193
210
}
211
+
212
+ static inline int clk_bulk_prepare (int num_clks , struct clk_bulk_data * clks )
213
+ {
214
+ might_sleep ();
215
+ return 0 ;
216
+ }
194
217
#endif
195
218
196
219
/**
@@ -204,11 +227,16 @@ static inline int clk_prepare(struct clk *clk)
204
227
*/
205
228
#ifdef CONFIG_HAVE_CLK_PREPARE
206
229
void clk_unprepare (struct clk * clk );
230
+ void clk_bulk_unprepare (int num_clks , const struct clk_bulk_data * clks );
207
231
#else
208
232
static inline void clk_unprepare (struct clk * clk )
209
233
{
210
234
might_sleep ();
211
235
}
236
+ static inline void clk_bulk_unprepare (int num_clks , struct clk_bulk_data * clks )
237
+ {
238
+ might_sleep ();
239
+ }
212
240
#endif
213
241
214
242
#ifdef CONFIG_HAVE_CLK
@@ -229,6 +257,29 @@ static inline void clk_unprepare(struct clk *clk)
229
257
*/
230
258
struct clk * clk_get (struct device * dev , const char * id );
231
259
260
+ /**
261
+ * clk_bulk_get - lookup and obtain a number of references to clock producer.
262
+ * @dev: device for clock "consumer"
263
+ * @num_clks: the number of clk_bulk_data
264
+ * @clks: the clk_bulk_data table of consumer
265
+ *
266
+ * This helper function allows drivers to get several clk consumers in one
267
+ * operation. If any of the clk cannot be acquired then any clks
268
+ * that were obtained will be freed before returning to the caller.
269
+ *
270
+ * Returns 0 if all clocks specified in clk_bulk_data table are obtained
271
+ * successfully, or valid IS_ERR() condition containing errno.
272
+ * The implementation uses @dev and @clk_bulk_data.id to determine the
273
+ * clock consumer, and thereby the clock producer.
274
+ * The clock returned is stored in each @clk_bulk_data.clk field.
275
+ *
276
+ * Drivers must assume that the clock source is not enabled.
277
+ *
278
+ * clk_bulk_get should not be called from within interrupt context.
279
+ */
280
+ int __must_check clk_bulk_get (struct device * dev , int num_clks ,
281
+ struct clk_bulk_data * clks );
282
+
232
283
/**
233
284
* devm_clk_get - lookup and obtain a managed reference to a clock producer.
234
285
* @dev: device for clock "consumer"
@@ -278,6 +329,18 @@ struct clk *devm_get_clk_from_child(struct device *dev,
278
329
*/
279
330
int clk_enable (struct clk * clk );
280
331
332
+ /**
333
+ * clk_bulk_enable - inform the system when the set of clks should be running.
334
+ * @num_clks: the number of clk_bulk_data
335
+ * @clks: the clk_bulk_data table of consumer
336
+ *
337
+ * May be called from atomic contexts.
338
+ *
339
+ * Returns success (0) or negative errno.
340
+ */
341
+ int __must_check clk_bulk_enable (int num_clks ,
342
+ const struct clk_bulk_data * clks );
343
+
281
344
/**
282
345
* clk_disable - inform the system when the clock source is no longer required.
283
346
* @clk: clock source
@@ -294,6 +357,24 @@ int clk_enable(struct clk *clk);
294
357
*/
295
358
void clk_disable (struct clk * clk );
296
359
360
+ /**
361
+ * clk_bulk_disable - inform the system when the set of clks is no
362
+ * longer required.
363
+ * @num_clks: the number of clk_bulk_data
364
+ * @clks: the clk_bulk_data table of consumer
365
+ *
366
+ * Inform the system that a set of clks is no longer required by
367
+ * a driver and may be shut down.
368
+ *
369
+ * May be called from atomic contexts.
370
+ *
371
+ * Implementation detail: if the set of clks is shared between
372
+ * multiple drivers, clk_bulk_enable() calls must be balanced by the
373
+ * same number of clk_bulk_disable() calls for the clock source to be
374
+ * disabled.
375
+ */
376
+ void clk_bulk_disable (int num_clks , const struct clk_bulk_data * clks );
377
+
297
378
/**
298
379
* clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
299
380
* This is only valid once the clock source has been enabled.
@@ -313,6 +394,19 @@ unsigned long clk_get_rate(struct clk *clk);
313
394
*/
314
395
void clk_put (struct clk * clk );
315
396
397
+ /**
398
+ * clk_bulk_put - "free" the clock source
399
+ * @num_clks: the number of clk_bulk_data
400
+ * @clks: the clk_bulk_data table of consumer
401
+ *
402
+ * Note: drivers must ensure that all clk_bulk_enable calls made on this
403
+ * clock source are balanced by clk_bulk_disable calls prior to calling
404
+ * this function.
405
+ *
406
+ * clk_bulk_put should not be called from within interrupt context.
407
+ */
408
+ void clk_bulk_put (int num_clks , struct clk_bulk_data * clks );
409
+
316
410
/**
317
411
* devm_clk_put - "free" a managed clock source
318
412
* @dev: device used to acquire the clock
@@ -445,6 +539,12 @@ static inline struct clk *clk_get(struct device *dev, const char *id)
445
539
return NULL ;
446
540
}
447
541
542
+ static inline int clk_bulk_get (struct device * dev , int num_clks ,
543
+ struct clk_bulk_data * clks )
544
+ {
545
+ return 0 ;
546
+ }
547
+
448
548
static inline struct clk * devm_clk_get (struct device * dev , const char * id )
449
549
{
450
550
return NULL ;
@@ -458,15 +558,26 @@ static inline struct clk *devm_get_clk_from_child(struct device *dev,
458
558
459
559
static inline void clk_put (struct clk * clk ) {}
460
560
561
+ static inline void clk_bulk_put (int num_clks , struct clk_bulk_data * clks ) {}
562
+
461
563
static inline void devm_clk_put (struct device * dev , struct clk * clk ) {}
462
564
463
565
static inline int clk_enable (struct clk * clk )
464
566
{
465
567
return 0 ;
466
568
}
467
569
570
+ static inline int clk_bulk_enable (int num_clks , struct clk_bulk_data * clks )
571
+ {
572
+ return 0 ;
573
+ }
574
+
468
575
static inline void clk_disable (struct clk * clk ) {}
469
576
577
+
578
+ static inline void clk_bulk_disable (int num_clks ,
579
+ struct clk_bulk_data * clks ) {}
580
+
470
581
static inline unsigned long clk_get_rate (struct clk * clk )
471
582
{
472
583
return 0 ;
0 commit comments