Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013, Steffen Trumtrar <s.trumtrar@pengutronix.de> |
| 3 | * |
| 4 | * based on drivers/clk/tegra/clk.h |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef __SOCFPGA_CLK_H |
| 18 | #define __SOCFPGA_CLK_H |
| 19 | |
| 20 | #include <linux/clk-provider.h> |
Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 21 | |
| 22 | /* Clock Manager offsets */ |
| 23 | #define CLKMGR_CTRL 0x0 |
| 24 | #define CLKMGR_BYPASS 0x4 |
Dinh Nguyen | 34d5003 | 2015-07-24 22:30:18 -0500 | [diff] [blame] | 25 | #define CLKMGR_DBCTRL 0x10 |
Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 26 | #define CLKMGR_L4SRC 0x70 |
| 27 | #define CLKMGR_PERPLL_SRC 0xAC |
| 28 | |
Dinh Nguyen | 5611a5b | 2015-05-19 22:22:41 -0500 | [diff] [blame] | 29 | #define SOCFPGA_MAX_PARENTS 5 |
Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 30 | |
Dinh Nguyen | 5611a5b | 2015-05-19 22:22:41 -0500 | [diff] [blame] | 31 | #define streq(a, b) (strcmp((a), (b)) == 0) |
| 32 | #define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \ |
| 33 | ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0)) |
| 34 | |
Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 35 | extern void __iomem *clk_mgr_base_addr; |
Dinh Nguyen | 5343325 | 2015-05-19 22:22:42 -0500 | [diff] [blame] | 36 | extern void __iomem *clk_mgr_a10_base_addr; |
Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 37 | |
| 38 | void __init socfpga_pll_init(struct device_node *node); |
| 39 | void __init socfpga_periph_init(struct device_node *node); |
| 40 | void __init socfpga_gate_init(struct device_node *node); |
Dinh Nguyen | 5343325 | 2015-05-19 22:22:42 -0500 | [diff] [blame] | 41 | void socfpga_a10_pll_init(struct device_node *node); |
| 42 | void socfpga_a10_periph_init(struct device_node *node); |
| 43 | void socfpga_a10_gate_init(struct device_node *node); |
Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 44 | |
| 45 | struct socfpga_pll { |
| 46 | struct clk_gate hw; |
| 47 | }; |
| 48 | |
| 49 | struct socfpga_gate_clk { |
| 50 | struct clk_gate hw; |
| 51 | char *parent_name; |
| 52 | u32 fixed_div; |
| 53 | void __iomem *div_reg; |
Dinh Nguyen | 5343325 | 2015-05-19 22:22:42 -0500 | [diff] [blame] | 54 | struct regmap *sys_mgr_base_addr; |
Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 55 | u32 width; /* only valid if div_reg != 0 */ |
| 56 | u32 shift; /* only valid if div_reg != 0 */ |
| 57 | u32 clk_phase[2]; |
| 58 | }; |
| 59 | |
| 60 | struct socfpga_periph_clk { |
| 61 | struct clk_gate hw; |
| 62 | char *parent_name; |
| 63 | u32 fixed_div; |
Dinh Nguyen | 0691bb1 | 2014-05-12 12:27:22 -0500 | [diff] [blame] | 64 | void __iomem *div_reg; |
| 65 | u32 width; /* only valid if div_reg != 0 */ |
| 66 | u32 shift; /* only valid if div_reg != 0 */ |
Steffen Trumtrar | 97259e9 | 2014-01-06 10:27:37 -0600 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | #endif /* SOCFPGA_CLK_H */ |