summaryrefslogtreecommitdiff
path: root/lwis_clock.h
blob: 440df31fd9750183ad1f5ba39f10a30a626b534f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * Google LWIS Clock Interface
 *
 * Copyright (c) 2018 Google, LLC
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef LWIS_CLOCK_H_
#define LWIS_CLOCK_H_

#include <linux/clk.h>
#include <linux/device.h>

/*
 *  LWIS Clock Structures
 */

struct lwis_clock {
	struct clk *clk;
	char *name;
	uint32_t rate;
};

struct lwis_clock_list {
	struct lwis_clock *clk;
	int count;
};

/*
 *  LWIS Clock Interface Functions
 */

/*
 *  lwis_clock_list_alloc: Allocate an instance of the lwis_clock_list
 *  and initialize the data structures according to the number of clocks
 *  specified.
 *  NOTE: This does not register the clock structs.
 */
struct lwis_clock_list *lwis_clock_list_alloc(int num_clks);

/*
 *  lwis_clock_list_free: Deallocate the lwis_clock_list structure.
 */
void lwis_clock_list_free(struct lwis_clock_list *list);

/*
 *  lwis_clock_get: Register the clock by name and store its assigned
 *  clock rate.
 *  Returns: index number (>= 0) if success, -ve if error
 */
int lwis_clock_get(struct lwis_clock_list *list, char *name, struct device *dev, uint32_t rate);

/*
 *  lwis_clock_put_by_idx: Unregister the clock by index.
 *  Returns: 0 if success, -ve if error
 */
int lwis_clock_put_by_idx(struct lwis_clock_list *list, int index, struct device *dev);

/*
 *  lwis_clock_put_by_name: Unregister the clock by name.
 *  Returns: 0 if success, -ve if error
 */
int lwis_clock_put_by_name(struct lwis_clock_list *list, char *name, struct device *dev);

/*
 *  lwis_clock_enable_by_idx: Enable clock by index.
 *  Returns: 0 if success, -ve if error
 */
int lwis_clock_enable_by_idx(struct lwis_clock_list *list, int index);

/*
 *  lwis_clock_enable_by_name: Enable clock by name.
 *  Returns: 0 if success, -ve if error
 */
int lwis_clock_enable_by_name(struct lwis_clock_list *list, char *name);

/*
 *  lwis_clock_enable_all: Enable all clocks.
 *  Returns: 0 if success, -ve if error
 */
int lwis_clock_enable_all(struct lwis_clock_list *list);

/*
 *  lwis_clock_disable_by_idx: Disable clock by index.
 */
void lwis_clock_disable_by_idx(struct lwis_clock_list *list, int index);

/*
 *  lwis_clock_disable_by_name: Disable clock by name.
 */
void lwis_clock_disable_by_name(struct lwis_clock_list *list, char *name);

/*
 *  lwis_clock_disable_all: Disable all clocks.
 */
void lwis_clock_disable_all(struct lwis_clock_list *list);

/*
 *  lwis_clock_print: Debug function to print all the clocks in the
 *  supplied list.
 */
void lwis_clock_print(struct lwis_clock_list *list);

#endif /* LWIS_CLOCK_H_ */