/* * Copyright 2013 Freescale Semiconductor, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * clock driver for Freescale QorIQ SoCs. */#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt#include<linux/clk.h>#include<linux/clk-provider.h>#include<linux/fsl/guts.h>#include<linux/io.h>#include<linux/kernel.h>#include<linux/module.h>#include<linux/of_address.h>#include<linux/of_platform.h>#include<linux/of.h>#include<linux/slab.h>#define PLL_DIV1 0#define PLL_DIV2 1#define PLL_DIV3 2#define PLL_DIV4 3#define PLATFORM_PLL 0#define CGA_PLL1 1#define CGA_PLL2 2#define CGA_PLL3 3#define CGA_PLL4 4 /* only on clockgen-1.0, which lacks CGB */#define CGB_PLL1 4#define CGB_PLL2 5structclockgen_pll_div{structclk*clk;charname[32];};structclockgen_pll{structclockgen_pll_divdiv[4];};#define CLKSEL_VALID 1#define CLKSEL_80PCT 2 /* Only allowed if PLL <= 80% of max cpu freq */structclockgen_sourceinfo{u32flags;/* CLKSEL_xxx */intpll;/* CGx_PLLn */intdiv;/* PLL_DIVn */};#define NUM_MUX_PARENTS 16structclockgen_muxinfo{structclockgen_sourceinfoclksel[NUM_MUX_PARENTS];};#define NUM_HWACCEL 5#define NUM_CMUX 8structclockgen;/* * cmux freq must be >= platform pll. * If not set, cmux freq must be >= platform pll/2 */#define CG_CMUX_GE_PLAT 1#define CG_PLL_8BIT 2 /* PLLCnGSR[CFG] is 8 bits, not 6 */#define CG_VER3 4 /* version 3 cg: reg layout different */#define CG_LITTLE_ENDIAN 8structclockgen_chipinfo{constchar*compat,*guts_compat;conststructclockgen_muxinfo*cmux_groups[2];conststructclockgen_muxinfo*hwaccel[NUM_HWACCEL];void(*init_periph)(structclockgen*cg);intcmux_to_group[NUM_CMUX];/* -1 terminates if fewer than NUM_CMUX */u32pll_mask;/* 1 << n bit set if PLL n is valid */u32flags;/* CG_xxx */};structclockgen{structdevice_node*node;void__iomem*regs;structclockgen_chipinfoinfo;/* mutable copy */structclk*sysclk;structclockgen_pllpll[6];structclk*cmux[NUM_CMUX];structclk*hwaccel[NUM_HWACCEL];structclk*fman[2];structccsr_guts__iomem*guts;};staticstructclockgenclockgen;staticvoidcg_out(struct