Documentation
arch
alpha
arc
arm
boot
common
configs
crypto
firmware
include
kernel
kvm
lib
mach-alpine
mach-artpec
mach-asm9260
mach-aspeed
mach-at91
mach-axxia
mach-bcm
mach-berlin
mach-clps711x
mach-cns3xxx
mach-davinci
mach-digicolor
mach-dove
mach-ebsa110
mach-efm32
mach-ep93xx
mach-exynos
mach-footbridge
mach-gemini
mach-highbank
mach-hisi
mach-imx
mach-integrator
mach-iop13xx
mach-iop32x
mach-iop33x
mach-ixp4xx
mach-keystone
mach-ks8695
mach-lpc18xx
mach-lpc32xx
mach-mediatek
mach-meson
mach-mmp
mach-moxart
mach-mv78xx0
mach-mvebu
mach-mxs
mach-netx
mach-nomadik
mach-nspire
mach-omap1
mach-omap2
include
Kconfig
Makefile
am33xx-restart.c
am33xx.h
board-flash.c
board-flash.h
board-generic.c
board-n8x0.c
clkt2xxx_dpll.c
clkt2xxx_dpllcore.c
clkt2xxx_virt_prcm_set.c
clock.c
clock.h
clock2xxx.h
clock3xxx.h
clockdomain.c
clockdomain.h
clockdomains2420_data.c
clockdomains2430_data.c
clockdomains2xxx_3xxx_data.c
clockdomains33xx_data.c
clockdomains3xxx_data.c
clockdomains43xx_data.c
clockdomains44xx_data.c
clockdomains54xx_data.c
clockdomains7xx_data.c
clockdomains81xx_data.c
cm-regbits-24xx.h
cm-regbits-33xx.h
cm-regbits-34xx.h
cm-regbits-44xx.h
cm-regbits-54xx.h
cm-regbits-7xx.h
cm.h
cm1_44xx.h
cm1_54xx.h
cm1_7xx.h
cm2_44xx.h
cm2_54xx.h
cm2_7xx.h
cm2xxx.c
cm2xxx.h
cm2xxx_3xxx.h
cm33xx.c
cm33xx.h
cm3xxx.c
cm3xxx.h
cm44xx.h
cm81xx.h
cm_common.c
cminst44xx.c
common-board-devices.c
common-board-devices.h
common.c
common.h
control.c
control.h
cpuidle34xx.c
cpuidle44xx.c
ctrl_module_wkup_44xx.h
devices.c
display.c
display.h
dma.c
drm.c
dss-common.c
dss-common.h
fb.c
gpio.c
gpmc-nand.c
gpmc-onenand.c
gpmc-smsc911x.c
gpmc-smsc911x.h
gpmc.h
hdq1w.c
hdq1w.h
hsmmc.c
hsmmc.h
i2c.c
i2c.h
id.c
id.h
io.c
iomap.h
l3_2xxx.h
l3_3xxx.h
l4_2xxx.h
l4_3xxx.h
mcbsp.c
mmc.h
msdi.c
mux.c
mux.h
mux34xx.c
mux34xx.h
omap-headsmp.S
omap-hotplug.c
omap-mpuss-lowpower.c
omap-pm-noop.c
omap-pm.h
omap-secure.c
omap-secure.h
omap-smc.S
omap-smp.c
omap-wakeupgen.c
omap-wakeupgen.h
omap2-restart.c
omap24xx.h
omap3-restart.c
omap34xx.h
omap4-common.c
omap4-restart.c
omap4-sar-layout.h
omap44xx.h
omap54xx.h
omap_device.c
omap_device.h
omap_hwmod.c
omap_hwmod.h
omap_hwmod_2420_data.c
omap_hwmod_2430_data.c
omap_hwmod_2xxx_3xxx_interconnect_data.c
omap_hwmod_2xxx_3xxx_ipblock_data.c
omap_hwmod_2xxx_interconnect_data.c
omap_hwmod_2xxx_ipblock_data.c
omap_hwmod_33xx_43xx_common_data.h
omap_hwmod_33xx_43xx_interconnect_data.c
omap_hwmod_33xx_43xx_ipblock_data.c
omap_hwmod_33xx_data.c
omap_hwmod_3xxx_data.c
omap_hwmod_43xx_data.c
omap_hwmod_44xx_data.c
omap_hwmod_54xx_data.c
omap_hwmod_7xx_data.c
omap_hwmod_81xx_data.c
omap_hwmod_common_data.c
omap_hwmod_common_data.h
omap_hwmod_common_ipblock_data.c
omap_hwmod_reset.c
omap_opp_data.h
omap_phy_internal.c
omap_twl.c
opp.c
opp2420_data.c
opp2430_data.c
opp2xxx.h
opp3xxx_data.c
opp4xxx_data.c
pdata-quirks.c
pm-debug.c
pm.c
pm.h
pm24xx.c
pm34xx.c
pm44xx.c
pmu.c
powerdomain-common.c
powerdomain.c
powerdomain.h
powerdomains2xxx_3xxx_data.c
powerdomains2xxx_3xxx_data.h
powerdomains2xxx_data.c
powerdomains33xx_data.c
powerdomains3xxx_data.c
powerdomains43xx_data.c
powerdomains44xx_data.c
powerdomains54xx_data.c
powerdomains7xx_data.c
prcm-common.h
prcm43xx.h
prcm44xx.h
prcm_mpu44xx.c
prcm_mpu44xx.h
prcm_mpu54xx.h
prcm_mpu7xx.h
prcm_mpu_44xx_54xx.h
prm-regbits-24xx.h
prm-regbits-33xx.h
prm-regbits-34xx.h
prm-regbits-44xx.h
prm.h
prm2xxx.c
prm2xxx.h
prm2xxx_3xxx.c
prm2xxx_3xxx.h
prm33xx.c
prm33xx.h
prm3xxx.c
prm3xxx.h
prm44xx.c
prm44xx.h
prm44xx_54xx.h
prm54xx.h
prm7xx.h
prm_common.c
prminst44xx.c
prminst44xx.h
scrm44xx.h
scrm54xx.h
sdram-hynix-h8mbx00u0mer-0em.h
sdram-micron-mt46h32m32lf-6.h
sdram-nokia.c
sdram-nokia.h
sdram-numonyx-m65kxxxxam.h
sdram-qimonda-hyb18m512160af-6.h
sdrc.c
sdrc.h
sdrc2xxx.c
serial.c
serial.h
sleep24xx.S
sleep34xx.S
sleep44xx.S
smartreflex-class3.c
soc.h
sr_device.c
sram.c
sram.h
sram242x.S
sram243x.S
ti81xx-restart.c
ti81xx.h
timer.c
twl-common.c
twl-common.h
usb-host.c
usb-musb.c
usb-tusb6010.c
usb.h
vc.c
vc.h
vc3xxx_data.c
vc44xx_data.c
voltage.c
voltage.h
voltagedomains2xxx_data.c
voltagedomains3xxx_data.c
voltagedomains44xx_data.c
voltagedomains54xx_data.c
vp.c
vp.h
vp3xxx_data.c
vp44xx_data.c
wd_timer.c
wd_timer.h
mach-orion5x
mach-oxnas
mach-picoxcell
mach-prima2
mach-pxa
mach-qcom
mach-realview
mach-rockchip
mach-rpc
mach-s3c24xx
mach-s3c64xx
mach-s5pv210
mach-sa1100
mach-shmobile
mach-socfpga
mach-spear
mach-sti
mach-stm32
mach-sunxi
mach-tango
mach-tegra
mach-u300
mach-uniphier
mach-ux500
mach-versatile
mach-vexpress
mach-vt8500
mach-w90x900
mach-zx
mach-zynq
mm
net
nwfpe
oprofile
plat-iop
plat-omap
plat-orion
plat-pxa
plat-samsung
plat-versatile
probes
tools
vdso
vfp
xen
Kconfig
Kconfig-nommu
Kconfig.debug
Makefile
arm64
avr32
blackfin
c6x
cris
frv
h8300
hexagon
ia64
m32r
m68k
metag
microblaze
mips
mn10300
nios2
openrisc
parisc
powerpc
s390
score
sh
sparc
tile
um
unicore32
x86
xtensa
.gitignore
Kconfig
block
certs
crypto
drivers
firmware
fs
include
init
ipc
kernel
lib
mm
ndm
net
samples
scripts
security
sound
tools
usr
virt
.cocciconfig
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
REPORTING-BUGS
build.config.aarch64
build.config.common
build.config.cuttlefish.aarch64
build.config.cuttlefish.x86_64
build.config.goldfish.arm
build.config.goldfish.arm64
build.config.goldfish.mips
build.config.goldfish.mips64
build.config.goldfish.x86
build.config.goldfish.x86_64
build.config.x86_64
localversion-ndm
verity_dev_keys.x509
git: https://android.googlesource.com/kernel/common branch: android-4.9 commit: 03fcc2fe71308c2d164b4e6cbfc738c63e670444
371 lines
10 KiB
C
371 lines
10 KiB
C
/*
|
|
* OMAP2+ common Clock Management (CM) IP block functions
|
|
*
|
|
* Copyright (C) 2012 Texas Instruments, Inc.
|
|
* Paul Walmsley
|
|
*
|
|
* 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.
|
|
*
|
|
* XXX This code should eventually be moved to a CM driver.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/bug.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_address.h>
|
|
|
|
#include "cm2xxx.h"
|
|
#include "cm3xxx.h"
|
|
#include "cm33xx.h"
|
|
#include "cm44xx.h"
|
|
#include "clock.h"
|
|
|
|
/*
|
|
* cm_ll_data: function pointers to SoC-specific implementations of
|
|
* common CM functions
|
|
*/
|
|
static struct cm_ll_data null_cm_ll_data;
|
|
static struct cm_ll_data *cm_ll_data = &null_cm_ll_data;
|
|
|
|
/* cm_base: base virtual address of the CM IP block */
|
|
void __iomem *cm_base;
|
|
|
|
/* cm2_base: base virtual address of the CM2 IP block (OMAP44xx only) */
|
|
void __iomem *cm2_base;
|
|
|
|
#define CM_NO_CLOCKS 0x1
|
|
#define CM_SINGLE_INSTANCE 0x2
|
|
|
|
/**
|
|
* omap2_set_globals_cm - set the CM/CM2 base addresses (for early use)
|
|
* @cm: CM base virtual address
|
|
* @cm2: CM2 base virtual address (if present on the booted SoC)
|
|
*
|
|
* XXX Will be replaced when the PRM/CM drivers are completed.
|
|
*/
|
|
void __init omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2)
|
|
{
|
|
cm_base = cm;
|
|
cm2_base = cm2;
|
|
}
|
|
|
|
/**
|
|
* cm_split_idlest_reg - split CM_IDLEST reg addr into its components
|
|
* @idlest_reg: CM_IDLEST* virtual address
|
|
* @prcm_inst: pointer to an s16 to return the PRCM instance offset
|
|
* @idlest_reg_id: pointer to a u8 to return the CM_IDLESTx register ID
|
|
*
|
|
* Given an absolute CM_IDLEST register address @idlest_reg, passes
|
|
* the PRCM instance offset and IDLEST register ID back to the caller
|
|
* via the @prcm_inst and @idlest_reg_id. Returns -EINVAL upon error,
|
|
* or 0 upon success. XXX This function is only needed until absolute
|
|
* register addresses are removed from the OMAP struct clk records.
|
|
*/
|
|
int cm_split_idlest_reg(void __iomem *idlest_reg, s16 *prcm_inst,
|
|
u8 *idlest_reg_id)
|
|
{
|
|
if (!cm_ll_data->split_idlest_reg) {
|
|
WARN_ONCE(1, "cm: %s: no low-level function defined\n",
|
|
__func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
return cm_ll_data->split_idlest_reg(idlest_reg, prcm_inst,
|
|
idlest_reg_id);
|
|
}
|
|
|
|
/**
|
|
* omap_cm_wait_module_ready - wait for a module to leave idle or standby
|
|
* @part: PRCM partition
|
|
* @prcm_mod: PRCM module offset
|
|
* @idlest_reg: CM_IDLESTx register
|
|
* @idlest_shift: shift of the bit in the CM_IDLEST* register to check
|
|
*
|
|
* Wait for the PRCM to indicate that the module identified by
|
|
* (@prcm_mod, @idlest_id, @idlest_shift) is clocked. Return 0 upon
|
|
* success, -EBUSY if the module doesn't enable in time, or -EINVAL if
|
|
* no per-SoC wait_module_ready() function pointer has been registered
|
|
* or if the idlest register is unknown on the SoC.
|
|
*/
|
|
int omap_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_reg,
|
|
u8 idlest_shift)
|
|
{
|
|
if (!cm_ll_data->wait_module_ready) {
|
|
WARN_ONCE(1, "cm: %s: no low-level function defined\n",
|
|
__func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
return cm_ll_data->wait_module_ready(part, prcm_mod, idlest_reg,
|
|
idlest_shift);
|
|
}
|
|
|
|
/**
|
|
* omap_cm_wait_module_idle - wait for a module to enter idle or standby
|
|
* @part: PRCM partition
|
|
* @prcm_mod: PRCM module offset
|
|
* @idlest_reg: CM_IDLESTx register
|
|
* @idlest_shift: shift of the bit in the CM_IDLEST* register to check
|
|
*
|
|
* Wait for the PRCM to indicate that the module identified by
|
|
* (@prcm_mod, @idlest_id, @idlest_shift) is no longer clocked. Return
|
|
* 0 upon success, -EBUSY if the module doesn't enable in time, or
|
|
* -EINVAL if no per-SoC wait_module_idle() function pointer has been
|
|
* registered or if the idlest register is unknown on the SoC.
|
|
*/
|
|
int omap_cm_wait_module_idle(u8 part, s16 prcm_mod, u16 idlest_reg,
|
|
u8 idlest_shift)
|
|
{
|
|
if (!cm_ll_data->wait_module_idle) {
|
|
WARN_ONCE(1, "cm: %s: no low-level function defined\n",
|
|
__func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
return cm_ll_data->wait_module_idle(part, prcm_mod, idlest_reg,
|
|
idlest_shift);
|
|
}
|
|
|
|
/**
|
|
* omap_cm_module_enable - enable a module
|
|
* @mode: target mode for the module
|
|
* @part: PRCM partition
|
|
* @inst: PRCM instance
|
|
* @clkctrl_offs: CM_CLKCTRL register offset for the module
|
|
*
|
|
* Enables clocks for a module identified by (@part, @inst, @clkctrl_offs)
|
|
* making its IO space accessible. Return 0 upon success, -EINVAL if no
|
|
* per-SoC module_enable() function pointer has been registered.
|
|
*/
|
|
int omap_cm_module_enable(u8 mode, u8 part, u16 inst, u16 clkctrl_offs)
|
|
{
|
|
if (!cm_ll_data->module_enable) {
|
|
WARN_ONCE(1, "cm: %s: no low-level function defined\n",
|
|
__func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
cm_ll_data->module_enable(mode, part, inst, clkctrl_offs);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* omap_cm_module_disable - disable a module
|
|
* @part: PRCM partition
|
|
* @inst: PRCM instance
|
|
* @clkctrl_offs: CM_CLKCTRL register offset for the module
|
|
*
|
|
* Disables clocks for a module identified by (@part, @inst, @clkctrl_offs)
|
|
* makings its IO space inaccessible. Return 0 upon success, -EINVAL if
|
|
* no per-SoC module_disable() function pointer has been registered.
|
|
*/
|
|
int omap_cm_module_disable(u8 part, u16 inst, u16 clkctrl_offs)
|
|
{
|
|
if (!cm_ll_data->module_disable) {
|
|
WARN_ONCE(1, "cm: %s: no low-level function defined\n",
|
|
__func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
cm_ll_data->module_disable(part, inst, clkctrl_offs);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* cm_register - register per-SoC low-level data with the CM
|
|
* @cld: low-level per-SoC OMAP CM data & function pointers to register
|
|
*
|
|
* Register per-SoC low-level OMAP CM data and function pointers with
|
|
* the OMAP CM common interface. The caller must keep the data
|
|
* pointed to by @cld valid until it calls cm_unregister() and
|
|
* it returns successfully. Returns 0 upon success, -EINVAL if @cld
|
|
* is NULL, or -EEXIST if cm_register() has already been called
|
|
* without an intervening cm_unregister().
|
|
*/
|
|
int cm_register(struct cm_ll_data *cld)
|
|
{
|
|
if (!cld)
|
|
return -EINVAL;
|
|
|
|
if (cm_ll_data != &null_cm_ll_data)
|
|
return -EEXIST;
|
|
|
|
cm_ll_data = cld;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* cm_unregister - unregister per-SoC low-level data & function pointers
|
|
* @cld: low-level per-SoC OMAP CM data & function pointers to unregister
|
|
*
|
|
* Unregister per-SoC low-level OMAP CM data and function pointers
|
|
* that were previously registered with cm_register(). The
|
|
* caller may not destroy any of the data pointed to by @cld until
|
|
* this function returns successfully. Returns 0 upon success, or
|
|
* -EINVAL if @cld is NULL or if @cld does not match the struct
|
|
* cm_ll_data * previously registered by cm_register().
|
|
*/
|
|
int cm_unregister(struct cm_ll_data *cld)
|
|
{
|
|
if (!cld || cm_ll_data != cld)
|
|
return -EINVAL;
|
|
|
|
cm_ll_data = &null_cm_ll_data;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
|
|
defined(CONFIG_SOC_DRA7XX)
|
|
static struct omap_prcm_init_data cm_data __initdata = {
|
|
.index = TI_CLKM_CM,
|
|
.init = omap4_cm_init,
|
|
};
|
|
|
|
static struct omap_prcm_init_data cm2_data __initdata = {
|
|
.index = TI_CLKM_CM2,
|
|
.init = omap4_cm_init,
|
|
};
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARCH_OMAP2
|
|
static struct omap_prcm_init_data omap2_prcm_data __initdata = {
|
|
.index = TI_CLKM_CM,
|
|
.init = omap2xxx_cm_init,
|
|
.flags = CM_NO_CLOCKS | CM_SINGLE_INSTANCE,
|
|
};
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARCH_OMAP3
|
|
static struct omap_prcm_init_data omap3_cm_data __initdata = {
|
|
.index = TI_CLKM_CM,
|
|
.init = omap3xxx_cm_init,
|
|
.flags = CM_SINGLE_INSTANCE,
|
|
|
|
/*
|
|
* IVA2 offset is a negative value, must offset the cm_base address
|
|
* by this to get it to positive side on the iomap
|
|
*/
|
|
.offset = -OMAP3430_IVA2_MOD,
|
|
};
|
|
#endif
|
|
|
|
#if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_TI81XX)
|
|
static struct omap_prcm_init_data am3_prcm_data __initdata = {
|
|
.index = TI_CLKM_CM,
|
|
.flags = CM_NO_CLOCKS | CM_SINGLE_INSTANCE,
|
|
.init = am33xx_cm_init,
|
|
};
|
|
#endif
|
|
|
|
#ifdef CONFIG_SOC_AM43XX
|
|
static struct omap_prcm_init_data am4_prcm_data __initdata = {
|
|
.index = TI_CLKM_CM,
|
|
.flags = CM_NO_CLOCKS | CM_SINGLE_INSTANCE,
|
|
.init = omap4_cm_init,
|
|
};
|
|
#endif
|
|
|
|
static const struct of_device_id omap_cm_dt_match_table[] __initconst = {
|
|
#ifdef CONFIG_ARCH_OMAP2
|
|
{ .compatible = "ti,omap2-prcm", .data = &omap2_prcm_data },
|
|
#endif
|
|
#ifdef CONFIG_ARCH_OMAP3
|
|
{ .compatible = "ti,omap3-cm", .data = &omap3_cm_data },
|
|
#endif
|
|
#ifdef CONFIG_ARCH_OMAP4
|
|
{ .compatible = "ti,omap4-cm1", .data = &cm_data },
|
|
{ .compatible = "ti,omap4-cm2", .data = &cm2_data },
|
|
#endif
|
|
#ifdef CONFIG_SOC_OMAP5
|
|
{ .compatible = "ti,omap5-cm-core-aon", .data = &cm_data },
|
|
{ .compatible = "ti,omap5-cm-core", .data = &cm2_data },
|
|
#endif
|
|
#ifdef CONFIG_SOC_DRA7XX
|
|
{ .compatible = "ti,dra7-cm-core-aon", .data = &cm_data },
|
|
{ .compatible = "ti,dra7-cm-core", .data = &cm2_data },
|
|
#endif
|
|
#ifdef CONFIG_SOC_AM33XX
|
|
{ .compatible = "ti,am3-prcm", .data = &am3_prcm_data },
|
|
#endif
|
|
#ifdef CONFIG_SOC_AM43XX
|
|
{ .compatible = "ti,am4-prcm", .data = &am4_prcm_data },
|
|
#endif
|
|
#ifdef CONFIG_SOC_TI81XX
|
|
{ .compatible = "ti,dm814-prcm", .data = &am3_prcm_data },
|
|
{ .compatible = "ti,dm816-prcm", .data = &am3_prcm_data },
|
|
#endif
|
|
{ }
|
|
};
|
|
|
|
/**
|
|
* omap2_cm_base_init - initialize iomappings for the CM drivers
|
|
*
|
|
* Detects and initializes the iomappings for the CM driver, based
|
|
* on the DT data. Returns 0 in success, negative error value
|
|
* otherwise.
|
|
*/
|
|
int __init omap2_cm_base_init(void)
|
|
{
|
|
struct device_node *np;
|
|
const struct of_device_id *match;
|
|
struct omap_prcm_init_data *data;
|
|
void __iomem *mem;
|
|
|
|
for_each_matching_node_and_match(np, omap_cm_dt_match_table, &match) {
|
|
data = (struct omap_prcm_init_data *)match->data;
|
|
|
|
mem = of_iomap(np, 0);
|
|
if (!mem)
|
|
return -ENOMEM;
|
|
|
|
if (data->index == TI_CLKM_CM)
|
|
cm_base = mem + data->offset;
|
|
|
|
if (data->index == TI_CLKM_CM2)
|
|
cm2_base = mem + data->offset;
|
|
|
|
data->mem = mem;
|
|
|
|
data->np = np;
|
|
|
|
if (data->init && (data->flags & CM_SINGLE_INSTANCE ||
|
|
(cm_base && cm2_base)))
|
|
data->init(data);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* omap_cm_init - low level init for the CM drivers
|
|
*
|
|
* Initializes the low level clock infrastructure for CM drivers.
|
|
* Returns 0 in success, negative error value in failure.
|
|
*/
|
|
int __init omap_cm_init(void)
|
|
{
|
|
struct device_node *np;
|
|
const struct of_device_id *match;
|
|
const struct omap_prcm_init_data *data;
|
|
int ret;
|
|
|
|
for_each_matching_node_and_match(np, omap_cm_dt_match_table, &match) {
|
|
data = match->data;
|
|
|
|
if (data->flags & CM_NO_CLOCKS)
|
|
continue;
|
|
|
|
ret = omap2_clk_provider_init(np, data->index, NULL, data->mem);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|