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 | |
| 11 | int soc_clk_dump(void); |
| 12 | |
Simon Glass | f26c8a8 | 2015-06-23 15:39:15 -0600 | [diff] [blame] | 13 | struct clk_ops { |
| 14 | /** |
| 15 | * get_rate() - Get current clock rate |
| 16 | * |
| 17 | * @dev: Device to check (UCLASS_CLK) |
| 18 | * @return clock rate in Hz, or -ve error code |
| 19 | */ |
| 20 | ulong (*get_rate)(struct udevice *dev); |
| 21 | |
| 22 | /** |
| 23 | * set_rate() - Set current clock rate |
| 24 | * |
| 25 | * @dev: Device to adjust |
| 26 | * @rate: New clock rate in Hz |
| 27 | * @return new rate, or -ve error code |
| 28 | */ |
| 29 | ulong (*set_rate)(struct udevice *dev, ulong rate); |
| 30 | |
| 31 | /** |
| 32 | * clk_set_periph_rate() - Set clock rate for a peripheral |
| 33 | * |
| 34 | * @dev: Device to adjust (UCLASS_CLK) |
| 35 | * @rate: New clock rate in Hz |
| 36 | * @return new clock rate in Hz, or -ve error code |
| 37 | */ |
| 38 | ulong (*get_periph_rate)(struct udevice *dev, int periph); |
| 39 | |
| 40 | /** |
| 41 | * clk_set_periph_rate() - Set current clock rate for a peripheral |
| 42 | * |
| 43 | * @dev: Device to update (UCLASS_CLK) |
| 44 | * @periph: Peripheral ID to cupdate |
| 45 | * @return new clock rate in Hz, or -ve error code |
| 46 | */ |
| 47 | ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate); |
| 48 | }; |
| 49 | |
| 50 | #define clk_get_ops(dev) ((struct clk_ops *)(dev)->driver->ops) |
| 51 | |
| 52 | /** |
| 53 | * clk_get_rate() - Get current clock rate |
| 54 | * |
| 55 | * @dev: Device to check (UCLASS_CLK) |
| 56 | * @return clock rate in Hz, or -ve error code |
| 57 | */ |
| 58 | ulong clk_get_rate(struct udevice *dev); |
| 59 | |
| 60 | /** |
| 61 | * set_rate() - Set current clock rate |
| 62 | * |
| 63 | * @dev: Device to adjust |
| 64 | * @rate: New clock rate in Hz |
| 65 | * @return new rate, or -ve error code |
| 66 | */ |
| 67 | ulong clk_set_rate(struct udevice *dev, ulong rate); |
| 68 | |
| 69 | /** |
| 70 | * clk_get_periph_rate() - Get current clock rate for a peripheral |
| 71 | * |
| 72 | * @dev: Device to check (UCLASS_CLK) |
| 73 | * @return clock rate in Hz, -ve error code |
| 74 | */ |
| 75 | ulong clk_get_periph_rate(struct udevice *dev, int periph); |
| 76 | |
| 77 | /** |
| 78 | * clk_set_periph_rate() - Set current clock rate for a peripheral |
| 79 | * |
| 80 | * @dev: Device to update (UCLASS_CLK) |
| 81 | * @periph: Peripheral ID to cupdate |
| 82 | * @return new clock rate in Hz, or -ve error code |
| 83 | */ |
| 84 | ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate); |
| 85 | |
Michal Simek | 08d0d6f | 2013-11-21 13:39:02 -0800 | [diff] [blame] | 86 | #endif /* _CLK_H_ */ |