clk-bcm281xx.c 9.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright (C) 2013 Broadcom Corporation
 * Copyright 2013 Linaro Limited
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation version 2.
 *
 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
 * kind, whether express or implied; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include "clk-kona.h"
#include "dt-bindings/clock/bcm281xx.h"

18 19 20 21
#define BCM281XX_CCU_COMMON(_name, _ucase_name) \
	KONA_CCU_COMMON(BCM281XX, _name, _ucase_name)

/* Root CCU */
22 23 24 25 26 27 28 29

static struct peri_clk_data frac_1m_data = {
	.gate		= HW_SW_GATE(0x214, 16, 0, 1),
	.trig		= TRIGGER(0x0e04, 0),
	.div		= FRAC_DIVIDER(0x0e00, 0, 22, 16),
	.clocks		= CLOCKS("ref_crystal"),
};

30 31
static struct ccu_data root_ccu_data = {
	BCM281XX_CCU_COMMON(root, ROOT),
32 33 34 35 36
	.kona_clks	= {
		[BCM281XX_ROOT_CCU_FRAC_1M] =
			KONA_CLK(root, frac_1m, peri),
		[BCM281XX_ROOT_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
	},
37 38 39
};

/* AON CCU */
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

static struct peri_clk_data hub_timer_data = {
	.gate		= HW_SW_GATE(0x0414, 16, 0, 1),
	.clocks		= CLOCKS("bbl_32k",
				 "frac_1m",
				 "dft_19_5m"),
	.sel		= SELECTOR(0x0a10, 0, 2),
	.trig		= TRIGGER(0x0a40, 4),
};

static struct peri_clk_data pmu_bsc_data = {
	.gate		= HW_SW_GATE(0x0418, 16, 0, 1),
	.clocks		= CLOCKS("ref_crystal",
				 "pmu_bsc_var",
				 "bbl_32k"),
	.sel		= SELECTOR(0x0a04, 0, 2),
	.div		= DIVIDER(0x0a04, 3, 4),
	.trig		= TRIGGER(0x0a40, 0),
};

static struct peri_clk_data pmu_bsc_var_data = {
	.clocks		= CLOCKS("var_312m",
				 "ref_312m"),
	.sel		= SELECTOR(0x0a00, 0, 2),
	.div		= DIVIDER(0x0a00, 4, 5),
	.trig		= TRIGGER(0x0a40, 2),
};

68 69
static struct ccu_data aon_ccu_data = {
	BCM281XX_CCU_COMMON(aon, AON),
70 71 72 73 74 75 76 77 78
	.kona_clks	= {
		[BCM281XX_AON_CCU_HUB_TIMER] =
			KONA_CLK(aon, hub_timer, peri),
		[BCM281XX_AON_CCU_PMU_BSC] =
			KONA_CLK(aon, pmu_bsc, peri),
		[BCM281XX_AON_CCU_PMU_BSC_VAR] =
			KONA_CLK(aon, pmu_bsc_var, peri),
		[BCM281XX_AON_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
	},
79 80 81
};

/* Hub CCU */
82 83 84 85 86 87 88 89 90

static struct peri_clk_data tmon_1m_data = {
	.gate		= HW_SW_GATE(0x04a4, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "frac_1m"),
	.sel		= SELECTOR(0x0e74, 0, 2),
	.trig		= TRIGGER(0x0e84, 1),
};

91 92
static struct ccu_data hub_ccu_data = {
	BCM281XX_CCU_COMMON(hub, HUB),
93 94 95 96 97
	.kona_clks	= {
		[BCM281XX_HUB_CCU_TMON_1M] =
			KONA_CLK(hub, tmon_1m, peri),
		[BCM281XX_HUB_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
	},
98 99 100
};

/* Master CCU */
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182

static struct peri_clk_data sdio1_data = {
	.gate		= HW_SW_GATE(0x0358, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_52m",
				 "ref_52m",
				 "var_96m",
				 "ref_96m"),
	.sel		= SELECTOR(0x0a28, 0, 3),
	.div		= DIVIDER(0x0a28, 4, 14),
	.trig		= TRIGGER(0x0afc, 9),
};

static struct peri_clk_data sdio2_data = {
	.gate		= HW_SW_GATE(0x035c, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_52m",
				 "ref_52m",
				 "var_96m",
				 "ref_96m"),
	.sel		= SELECTOR(0x0a2c, 0, 3),
	.div		= DIVIDER(0x0a2c, 4, 14),
	.trig		= TRIGGER(0x0afc, 10),
};

static struct peri_clk_data sdio3_data = {
	.gate		= HW_SW_GATE(0x0364, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_52m",
				 "ref_52m",
				 "var_96m",
				 "ref_96m"),
	.sel		= SELECTOR(0x0a34, 0, 3),
	.div		= DIVIDER(0x0a34, 4, 14),
	.trig		= TRIGGER(0x0afc, 12),
};

static struct peri_clk_data sdio4_data = {
	.gate		= HW_SW_GATE(0x0360, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_52m",
				 "ref_52m",
				 "var_96m",
				 "ref_96m"),
	.sel		= SELECTOR(0x0a30, 0, 3),
	.div		= DIVIDER(0x0a30, 4, 14),
	.trig		= TRIGGER(0x0afc, 11),
};

static struct peri_clk_data usb_ic_data = {
	.gate		= HW_SW_GATE(0x0354, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_96m",
				 "ref_96m"),
	.div		= FIXED_DIVIDER(2),
	.sel		= SELECTOR(0x0a24, 0, 2),
	.trig		= TRIGGER(0x0afc, 7),
};

/* also called usbh_48m */
static struct peri_clk_data hsic2_48m_data = {
	.gate		= HW_SW_GATE(0x0370, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_96m",
				 "ref_96m"),
	.sel		= SELECTOR(0x0a38, 0, 2),
	.div		= FIXED_DIVIDER(2),
	.trig		= TRIGGER(0x0afc, 5),
};

/* also called usbh_12m */
static struct peri_clk_data hsic2_12m_data = {
	.gate		= HW_SW_GATE(0x0370, 20, 4, 5),
	.div		= DIVIDER(0x0a38, 12, 2),
	.clocks		= CLOCKS("ref_crystal",
				 "var_96m",
				 "ref_96m"),
	.pre_div	= FIXED_DIVIDER(2),
	.sel		= SELECTOR(0x0a38, 0, 2),
	.trig		= TRIGGER(0x0afc, 5),
};

183 184
static struct ccu_data master_ccu_data = {
	BCM281XX_CCU_COMMON(master, MASTER),
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
	.kona_clks	= {
		[BCM281XX_MASTER_CCU_SDIO1] =
			KONA_CLK(master, sdio1, peri),
		[BCM281XX_MASTER_CCU_SDIO2] =
			KONA_CLK(master, sdio2, peri),
		[BCM281XX_MASTER_CCU_SDIO3] =
			KONA_CLK(master, sdio3, peri),
		[BCM281XX_MASTER_CCU_SDIO4] =
			KONA_CLK(master, sdio4, peri),
		[BCM281XX_MASTER_CCU_USB_IC] =
			KONA_CLK(master, usb_ic, peri),
		[BCM281XX_MASTER_CCU_HSIC2_48M] =
			KONA_CLK(master, hsic2_48m, peri),
		[BCM281XX_MASTER_CCU_HSIC2_12M] =
			KONA_CLK(master, hsic2_12m, peri),
		[BCM281XX_MASTER_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
	},
202 203 204
};

/* Slave CCU */
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311

static struct peri_clk_data uartb_data = {
	.gate		= HW_SW_GATE(0x0400, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_156m",
				 "ref_156m"),
	.sel		= SELECTOR(0x0a10, 0, 2),
	.div		= FRAC_DIVIDER(0x0a10, 4, 12, 8),
	.trig		= TRIGGER(0x0afc, 2),
};

static struct peri_clk_data uartb2_data = {
	.gate		= HW_SW_GATE(0x0404, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_156m",
				 "ref_156m"),
	.sel		= SELECTOR(0x0a14, 0, 2),
	.div		= FRAC_DIVIDER(0x0a14, 4, 12, 8),
	.trig		= TRIGGER(0x0afc, 3),
};

static struct peri_clk_data uartb3_data = {
	.gate		= HW_SW_GATE(0x0408, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_156m",
				 "ref_156m"),
	.sel		= SELECTOR(0x0a18, 0, 2),
	.div		= FRAC_DIVIDER(0x0a18, 4, 12, 8),
	.trig		= TRIGGER(0x0afc, 4),
};

static struct peri_clk_data uartb4_data = {
	.gate		= HW_SW_GATE(0x0408, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_156m",
				 "ref_156m"),
	.sel		= SELECTOR(0x0a1c, 0, 2),
	.div		= FRAC_DIVIDER(0x0a1c, 4, 12, 8),
	.trig		= TRIGGER(0x0afc, 5),
};

static struct peri_clk_data ssp0_data = {
	.gate		= HW_SW_GATE(0x0410, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_104m",
				 "ref_104m",
				 "var_96m",
				 "ref_96m"),
	.sel		= SELECTOR(0x0a20, 0, 3),
	.div		= DIVIDER(0x0a20, 4, 14),
	.trig		= TRIGGER(0x0afc, 6),
};

static struct peri_clk_data ssp2_data = {
	.gate		= HW_SW_GATE(0x0418, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_104m",
				 "ref_104m",
				 "var_96m",
				 "ref_96m"),
	.sel		= SELECTOR(0x0a28, 0, 3),
	.div		= DIVIDER(0x0a28, 4, 14),
	.trig		= TRIGGER(0x0afc, 8),
};

static struct peri_clk_data bsc1_data = {
	.gate		= HW_SW_GATE(0x0458, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_104m",
				 "ref_104m",
				 "var_13m",
				 "ref_13m"),
	.sel		= SELECTOR(0x0a64, 0, 3),
	.trig		= TRIGGER(0x0afc, 23),
};

static struct peri_clk_data bsc2_data = {
	.gate		= HW_SW_GATE(0x045c, 18, 2, 3),
	.clocks	= CLOCKS("ref_crystal",
				 "var_104m",
				 "ref_104m",
				 "var_13m",
				 "ref_13m"),
	.sel		= SELECTOR(0x0a68, 0, 3),
	.trig		= TRIGGER(0x0afc, 24),
};

static struct peri_clk_data bsc3_data = {
	.gate		= HW_SW_GATE(0x0484, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_104m",
				 "ref_104m",
				 "var_13m",
				 "ref_13m"),
	.sel		= SELECTOR(0x0a84, 0, 3),
	.trig		= TRIGGER(0x0b00, 2),
};

static struct peri_clk_data pwm_data = {
	.gate		= HW_SW_GATE(0x0468, 18, 2, 3),
	.clocks		= CLOCKS("ref_crystal",
				 "var_104m"),
	.sel		= SELECTOR(0x0a70, 0, 2),
	.div		= DIVIDER(0x0a70, 4, 3),
	.trig		= TRIGGER(0x0afc, 15),
};

312 313
static struct ccu_data slave_ccu_data = {
	BCM281XX_CCU_COMMON(slave, SLAVE),
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
	.kona_clks	= {
		[BCM281XX_SLAVE_CCU_UARTB] =
			KONA_CLK(slave, uartb, peri),
		[BCM281XX_SLAVE_CCU_UARTB2] =
			KONA_CLK(slave, uartb2, peri),
		[BCM281XX_SLAVE_CCU_UARTB3] =
			KONA_CLK(slave, uartb3, peri),
		[BCM281XX_SLAVE_CCU_UARTB4] =
			KONA_CLK(slave, uartb4, peri),
		[BCM281XX_SLAVE_CCU_SSP0] =
			KONA_CLK(slave, ssp0, peri),
		[BCM281XX_SLAVE_CCU_SSP2] =
			KONA_CLK(slave, ssp2, peri),
		[BCM281XX_SLAVE_CCU_BSC1] =
			KONA_CLK(slave, bsc1, peri),
		[BCM281XX_SLAVE_CCU_BSC2] =
			KONA_CLK(slave, bsc2, peri),
		[BCM281XX_SLAVE_CCU_BSC3] =
			KONA_CLK(slave, bsc3, peri),
		[BCM281XX_SLAVE_CCU_PWM] =
			KONA_CLK(slave, pwm, peri),
		[BCM281XX_SLAVE_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
	},
337 338
};

339 340 341 342
/* Device tree match table callback functions */

static void __init kona_dt_root_ccu_setup(struct device_node *node)
{
343
	kona_dt_ccu_setup(&root_ccu_data, node);
344 345 346 347
}

static void __init kona_dt_aon_ccu_setup(struct device_node *node)
{
348
	kona_dt_ccu_setup(&aon_ccu_data, node);
349 350 351 352
}

static void __init kona_dt_hub_ccu_setup(struct device_node *node)
{
353
	kona_dt_ccu_setup(&hub_ccu_data, node);
354 355 356 357
}

static void __init kona_dt_master_ccu_setup(struct device_node *node)
{
358
	kona_dt_ccu_setup(&master_ccu_data, node);
359 360 361 362
}

static void __init kona_dt_slave_ccu_setup(struct device_node *node)
{
363
	kona_dt_ccu_setup(&slave_ccu_data, node);
364 365
}

366
CLK_OF_DECLARE(bcm281xx_root_ccu, BCM281XX_DT_ROOT_CCU_COMPAT,
367
			kona_dt_root_ccu_setup);
368
CLK_OF_DECLARE(bcm281xx_aon_ccu, BCM281XX_DT_AON_CCU_COMPAT,
369
			kona_dt_aon_ccu_setup);
370
CLK_OF_DECLARE(bcm281xx_hub_ccu, BCM281XX_DT_HUB_CCU_COMPAT,
371
			kona_dt_hub_ccu_setup);
372
CLK_OF_DECLARE(bcm281xx_master_ccu, BCM281XX_DT_MASTER_CCU_COMPAT,
373
			kona_dt_master_ccu_setup);
374
CLK_OF_DECLARE(bcm281xx_slave_ccu, BCM281XX_DT_SLAVE_CCU_COMPAT,
375
			kona_dt_slave_ccu_setup);