197259e99SSteffen Trumtrar /* 297259e99SSteffen Trumtrar * Copyright (c) 2013, Steffen Trumtrar <s.trumtrar@pengutronix.de> 397259e99SSteffen Trumtrar * 497259e99SSteffen Trumtrar * based on drivers/clk/tegra/clk.h 597259e99SSteffen Trumtrar * 697259e99SSteffen Trumtrar * This program is free software; you can redistribute it and/or modify it 797259e99SSteffen Trumtrar * under the terms and conditions of the GNU General Public License, 897259e99SSteffen Trumtrar * version 2, as published by the Free Software Foundation. 997259e99SSteffen Trumtrar * 1097259e99SSteffen Trumtrar * This program is distributed in the hope it will be useful, but WITHOUT 1197259e99SSteffen Trumtrar * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1297259e99SSteffen Trumtrar * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 1397259e99SSteffen Trumtrar * more details. 1497259e99SSteffen Trumtrar * 1597259e99SSteffen Trumtrar */ 1697259e99SSteffen Trumtrar 1797259e99SSteffen Trumtrar #ifndef __SOCFPGA_CLK_H 1897259e99SSteffen Trumtrar #define __SOCFPGA_CLK_H 1997259e99SSteffen Trumtrar 2097259e99SSteffen Trumtrar #include <linux/clk-provider.h> 2197259e99SSteffen Trumtrar 2297259e99SSteffen Trumtrar /* Clock Manager offsets */ 2397259e99SSteffen Trumtrar #define CLKMGR_CTRL 0x0 2497259e99SSteffen Trumtrar #define CLKMGR_BYPASS 0x4 2534d5003bSDinh Nguyen #define CLKMGR_DBCTRL 0x10 2697259e99SSteffen Trumtrar #define CLKMGR_L4SRC 0x70 2797259e99SSteffen Trumtrar #define CLKMGR_PERPLL_SRC 0xAC 2897259e99SSteffen Trumtrar 295611a5baSDinh Nguyen #define SOCFPGA_MAX_PARENTS 5 3097259e99SSteffen Trumtrar 315611a5baSDinh Nguyen #define streq(a, b) (strcmp((a), (b)) == 0) 325611a5baSDinh Nguyen #define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \ 335611a5baSDinh Nguyen ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0)) 345611a5baSDinh Nguyen 35b7f8101dSDinh Nguyen #define SYSMGR_SDMMC_CTRL_SET_AS10(smplsel, drvsel) \ 36b7f8101dSDinh Nguyen ((((smplsel) & 0x7) << 4) | (((drvsel) & 0x7) << 0)) 37b7f8101dSDinh Nguyen 3897259e99SSteffen Trumtrar extern void __iomem *clk_mgr_base_addr; 395343325fSDinh Nguyen extern void __iomem *clk_mgr_a10_base_addr; 4097259e99SSteffen Trumtrar 4197259e99SSteffen Trumtrar void __init socfpga_pll_init(struct device_node *node); 4297259e99SSteffen Trumtrar void __init socfpga_periph_init(struct device_node *node); 4397259e99SSteffen Trumtrar void __init socfpga_gate_init(struct device_node *node); 445343325fSDinh Nguyen void socfpga_a10_pll_init(struct device_node *node); 455343325fSDinh Nguyen void socfpga_a10_periph_init(struct device_node *node); 465343325fSDinh Nguyen void socfpga_a10_gate_init(struct device_node *node); 4797259e99SSteffen Trumtrar 4897259e99SSteffen Trumtrar struct socfpga_pll { 4997259e99SSteffen Trumtrar struct clk_gate hw; 5097259e99SSteffen Trumtrar }; 5197259e99SSteffen Trumtrar 5297259e99SSteffen Trumtrar struct socfpga_gate_clk { 5397259e99SSteffen Trumtrar struct clk_gate hw; 5497259e99SSteffen Trumtrar char *parent_name; 5597259e99SSteffen Trumtrar u32 fixed_div; 5697259e99SSteffen Trumtrar void __iomem *div_reg; 575343325fSDinh Nguyen struct regmap *sys_mgr_base_addr; 5897259e99SSteffen Trumtrar u32 width; /* only valid if div_reg != 0 */ 5997259e99SSteffen Trumtrar u32 shift; /* only valid if div_reg != 0 */ 6097259e99SSteffen Trumtrar u32 clk_phase[2]; 6197259e99SSteffen Trumtrar }; 6297259e99SSteffen Trumtrar 6397259e99SSteffen Trumtrar struct socfpga_periph_clk { 6497259e99SSteffen Trumtrar struct clk_gate hw; 6597259e99SSteffen Trumtrar char *parent_name; 6697259e99SSteffen Trumtrar u32 fixed_div; 670691bb1bSDinh Nguyen void __iomem *div_reg; 680691bb1bSDinh Nguyen u32 width; /* only valid if div_reg != 0 */ 690691bb1bSDinh Nguyen u32 shift; /* only valid if div_reg != 0 */ 7097259e99SSteffen Trumtrar }; 7197259e99SSteffen Trumtrar 7297259e99SSteffen Trumtrar #endif /* SOCFPGA_CLK_H */ 73