Simon Glass | f26c8a8 | 2015-06-23 15:39:15 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Google, Inc |
| 3 | * Written by Simon Glass <sjg@chromium.org> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
Michal Simek | 08d0d6f | 2013-11-21 13:39:02 -0800 | [diff] [blame] | 8 | #ifndef _CLK_H_ |
| 9 | #define _CLK_H_ |
| 10 | |
Masahiro Yamada | ad1cf78 | 2016-01-13 13:16:09 +0900 | [diff] [blame^] | 11 | #include <linux/types.h> |
| 12 | |
| 13 | struct udevice; |
| 14 | |
Michal Simek | 08d0d6f | 2013-11-21 13:39:02 -0800 | [diff] [blame] | 15 | int soc_clk_dump(void); |
| 16 | |
Simon Glass | f26c8a8 | 2015-06-23 15:39:15 -0600 | [diff] [blame] | 17 | struct clk_ops { |
| 18 | /** |
| 19 | * get_rate() - Get current clock rate |
| 20 | * |
| 21 | * @dev: Device to check (UCLASS_CLK) |
| 22 | * @return clock rate in Hz, or -ve error code |
| 23 | */ |
| 24 | ulong (*get_rate)(struct udevice *dev); |
| 25 | |
| 26 | /** |
| 27 | * set_rate() - Set current clock rate |
| 28 | * |
| 29 | * @dev: Device to adjust |
| 30 | * @rate: New clock rate in Hz |
| 31 | * @return new rate, or -ve error code |
| 32 | */ |
| 33 | ulong (*set_rate)(struct udevice *dev, ulong rate); |
| 34 | |
| 35 | /** |
Masahiro Yamada | 8bdf9cf | 2016-01-13 13:16:08 +0900 | [diff] [blame] | 36 | * get_periph_rate() - Get clock rate for a peripheral |
| 37 | * |
| 38 | * @dev: Device to check (UCLASS_CLK) |
| 39 | * @periph: Peripheral ID to check |
| 40 | * @return clock rate in Hz, or -ve error code |
| 41 | */ |
Simon Glass | f26c8a8 | 2015-06-23 15:39:15 -0600 | [diff] [blame] | 42 | ulong (*get_periph_rate)(struct udevice *dev, int periph); |
| 43 | |
| 44 | /** |
Masahiro Yamada | 8bdf9cf | 2016-01-13 13:16:08 +0900 | [diff] [blame] | 45 | * set_periph_rate() - Set current clock rate for a peripheral |
Simon Glass | f26c8a8 | 2015-06-23 15:39:15 -0600 | [diff] [blame] | 46 | * |
| 47 | * @dev: Device to update (UCLASS_CLK) |
Masahiro Yamada | 8bdf9cf | 2016-01-13 13:16:08 +0900 | [diff] [blame] | 48 | * @periph: Peripheral ID to update |
Simon Glass | f26c8a8 | 2015-06-23 15:39:15 -0600 | [diff] [blame] | 49 | * @return new clock rate in Hz, or -ve error code |
| 50 | */ |
| 51 | ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate); |
| 52 | }; |
| 53 | |
| 54 | #define clk_get_ops(dev) ((struct clk_ops *)(dev)->driver->ops) |
| 55 | |
| 56 | /** |
| 57 | * clk_get_rate() - Get current clock rate |
| 58 | * |
| 59 | * @dev: Device to check (UCLASS_CLK) |
| 60 | * @return clock rate in Hz, or -ve error code |
| 61 | */ |
| 62 | ulong clk_get_rate(struct udevice *dev); |
| 63 | |
| 64 | /** |
Masahiro Yamada | 8bdf9cf | 2016-01-13 13:16:08 +0900 | [diff] [blame] | 65 | * clk_set_rate() - Set current clock rate |
Simon Glass | f26c8a8 | 2015-06-23 15:39:15 -0600 | [diff] [blame] | 66 | * |
| 67 | * @dev: Device to adjust |
| 68 | * @rate: New clock rate in Hz |
| 69 | * @return new rate, or -ve error code |
| 70 | */ |
| 71 | ulong clk_set_rate(struct udevice *dev, ulong rate); |
| 72 | |
| 73 | /** |
| 74 | * clk_get_periph_rate() - Get current clock rate for a peripheral |
| 75 | * |
| 76 | * @dev: Device to check (UCLASS_CLK) |
| 77 | * @return clock rate in Hz, -ve error code |
| 78 | */ |
| 79 | ulong clk_get_periph_rate(struct udevice *dev, int periph); |
| 80 | |
| 81 | /** |
| 82 | * clk_set_periph_rate() - Set current clock rate for a peripheral |
| 83 | * |
| 84 | * @dev: Device to update (UCLASS_CLK) |
Masahiro Yamada | 8bdf9cf | 2016-01-13 13:16:08 +0900 | [diff] [blame] | 85 | * @periph: Peripheral ID to update |
Simon Glass | f26c8a8 | 2015-06-23 15:39:15 -0600 | [diff] [blame] | 86 | * @return new clock rate in Hz, or -ve error code |
| 87 | */ |
| 88 | ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate); |
| 89 | |
Michal Simek | 08d0d6f | 2013-11-21 13:39:02 -0800 | [diff] [blame] | 90 | #endif /* _CLK_H_ */ |