blob: 26c3a265cf78a1e41202a6b3179f0719bf6fbc2f [file] [log] [blame]
Steffen Trumtrar97259e92014-01-06 10:27:37 -06001/*
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 Trumtrar97259e92014-01-06 10:27:37 -060021
22/* Clock Manager offsets */
23#define CLKMGR_CTRL 0x0
24#define CLKMGR_BYPASS 0x4
Dinh Nguyen34d50032015-07-24 22:30:18 -050025#define CLKMGR_DBCTRL 0x10
Steffen Trumtrar97259e92014-01-06 10:27:37 -060026#define CLKMGR_L4SRC 0x70
27#define CLKMGR_PERPLL_SRC 0xAC
28
Dinh Nguyen5611a5b2015-05-19 22:22:41 -050029#define SOCFPGA_MAX_PARENTS 5
Steffen Trumtrar97259e92014-01-06 10:27:37 -060030
Dinh Nguyen5611a5b2015-05-19 22:22:41 -050031#define streq(a, b) (strcmp((a), (b)) == 0)
32#define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \
33 ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0))
34
Dinh Nguyenb7f81012017-06-08 09:18:39 -050035#define SYSMGR_SDMMC_CTRL_SET_AS10(smplsel, drvsel) \
36 ((((smplsel) & 0x7) << 4) | (((drvsel) & 0x7) << 0))
37
Steffen Trumtrar97259e92014-01-06 10:27:37 -060038extern void __iomem *clk_mgr_base_addr;
Dinh Nguyen53433252015-05-19 22:22:42 -050039extern void __iomem *clk_mgr_a10_base_addr;
Steffen Trumtrar97259e92014-01-06 10:27:37 -060040
41void __init socfpga_pll_init(struct device_node *node);
42void __init socfpga_periph_init(struct device_node *node);
43void __init socfpga_gate_init(struct device_node *node);
Dinh Nguyen53433252015-05-19 22:22:42 -050044void socfpga_a10_pll_init(struct device_node *node);
45void socfpga_a10_periph_init(struct device_node *node);
46void socfpga_a10_gate_init(struct device_node *node);
Steffen Trumtrar97259e92014-01-06 10:27:37 -060047
48struct socfpga_pll {
49 struct clk_gate hw;
50};
51
52struct socfpga_gate_clk {
53 struct clk_gate hw;
54 char *parent_name;
55 u32 fixed_div;
56 void __iomem *div_reg;
Dinh Nguyen07afb8d2018-03-21 09:20:12 -050057 void __iomem *bypass_reg;
Dinh Nguyen53433252015-05-19 22:22:42 -050058 struct regmap *sys_mgr_base_addr;
Steffen Trumtrar97259e92014-01-06 10:27:37 -060059 u32 width; /* only valid if div_reg != 0 */
60 u32 shift; /* only valid if div_reg != 0 */
Dinh Nguyen07afb8d2018-03-21 09:20:12 -050061 u32 bypass_shift; /* only valid if bypass_reg != 0 */
Steffen Trumtrar97259e92014-01-06 10:27:37 -060062 u32 clk_phase[2];
63};
64
65struct socfpga_periph_clk {
66 struct clk_gate hw;
67 char *parent_name;
68 u32 fixed_div;
Dinh Nguyen0691bb12014-05-12 12:27:22 -050069 void __iomem *div_reg;
Dinh Nguyen07afb8d2018-03-21 09:20:12 -050070 void __iomem *bypass_reg;
Dinh Nguyen0691bb12014-05-12 12:27:22 -050071 u32 width; /* only valid if div_reg != 0 */
72 u32 shift; /* only valid if div_reg != 0 */
Dinh Nguyen07afb8d2018-03-21 09:20:12 -050073 u32 bypass_shift; /* only valid if bypass_reg != 0 */
Steffen Trumtrar97259e92014-01-06 10:27:37 -060074};
75
76#endif /* SOCFPGA_CLK_H */