blob: b09a5d50547e070b57c741d5467ad641d1c76b10 [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>
21#include <linux/clkdev.h>
22
23/* Clock Manager offsets */
24#define CLKMGR_CTRL 0x0
25#define CLKMGR_BYPASS 0x4
26#define CLKMGR_L4SRC 0x70
27#define CLKMGR_PERPLL_SRC 0xAC
28
Dinh Nguyen5611a5b2015-05-19 22:22:41 -050029#define SOCFPGA_MAX_PARENTS 5
Dinh Nguyen0691bb12014-05-12 12:27:22 -050030#define div_mask(width) ((1 << (width)) - 1)
Steffen Trumtrar97259e92014-01-06 10:27:37 -060031
Dinh Nguyen5611a5b2015-05-19 22:22:41 -050032#define streq(a, b) (strcmp((a), (b)) == 0)
33#define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \
34 ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0))
35
Steffen Trumtrar97259e92014-01-06 10:27:37 -060036extern void __iomem *clk_mgr_base_addr;
37
38void __init socfpga_pll_init(struct device_node *node);
39void __init socfpga_periph_init(struct device_node *node);
40void __init socfpga_gate_init(struct device_node *node);
41
42struct socfpga_pll {
43 struct clk_gate hw;
44};
45
46struct socfpga_gate_clk {
47 struct clk_gate hw;
48 char *parent_name;
49 u32 fixed_div;
50 void __iomem *div_reg;
51 u32 width; /* only valid if div_reg != 0 */
52 u32 shift; /* only valid if div_reg != 0 */
53 u32 clk_phase[2];
54};
55
56struct socfpga_periph_clk {
57 struct clk_gate hw;
58 char *parent_name;
59 u32 fixed_div;
Dinh Nguyen0691bb12014-05-12 12:27:22 -050060 void __iomem *div_reg;
61 u32 width; /* only valid if div_reg != 0 */
62 u32 shift; /* only valid if div_reg != 0 */
Steffen Trumtrar97259e92014-01-06 10:27:37 -060063};
64
65#endif /* SOCFPGA_CLK_H */