mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
ARM: SoC cleanups for 3.16
Cleanups for 3.16. Among these are:
- A bunch of misc cleanups for Broadcom platforms, mostly housekeeping
- Enabling Common Clock Framework on the older s3c24xx Samsung chipsets
- Cleanup of the Versatile Express system controller code, moving it to syscon
- Power management cleanups for OMAP platforms
+ a handful of other cleanups across the place
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
iQIcBAABAgAGBQJTjMwHAAoJEIwa5zzehBx3MjMP/iELgDsqbNE2wxF9Fb5EEnoe
S11q1QIvVrMVdMcKFN5HfW7f+xNso6+4SwXW0cRrJokGvaqRE758WZWuZq0QBUeS
RYMhfpqmI6pTTJUyy6i6OyXhuRqu8rQ1NPEAatYrKzmtwFX1H4t25f1YtZWhBcK8
ONi45FHeH1OKGGpjpT63uhWEzLk+LZI2MtgxmWoFcemf7guX6vEPJVuVRi8eqLoS
9vl1cAkweYgGhjvQFcSXENaguV50dZlLc9C41dJk9KVvJfRt7o+/cRbG5YpGvnp5
Liu+OWM72w0BkgNk6wDN4kaPX5UGLF8QX11JlvDRCJ2FcPtM4NBG/C9TqLMfkKDR
Ze+ITiXh6NjefdTZWJaM4vzsd6vFws8EYAP24IWFlZ451bNLVN1lzlgqluPNoKmj
CAsFPZhY/x5X9a8VLZ72ohx3N17T/iMsOlbiWtnlfqDcL6N0IoLG1YkFFeQIKEAH
mpobWus8Myq1miWqSaeXh5wOqUVQmYR0I8jNoTfte1nBYSaIGhtMixoQhM6Zw50C
dgSh4p7qhrZUOnYmkPqFXr7NCJ9n3RD10Xu8d/3IIp0u9RJ5Kx6NCEg9adq22jZQ
XGrr/vH0sM8MzpKmfTMi5t2Cx5kP2G+O3enq0hQi4x3Cb4o8vwWQlMgydTd+xBjj
aLo3WTTw0h6nTuKkZL2p
=wuX4
-----END PGP SIGNATURE-----
Merge tag 'cleanup-for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc into next
Pull ARM SoC cleanups from Olof Johansson:
"Cleanups for 3.16. Among these are:
- a bunch of misc cleanups for Broadcom platforms, mostly
housekeeping
- enabling Common Clock Framework on the older s3c24xx Samsung
chipsets
- cleanup of the Versatile Express system controller code, moving it
to syscon
- power management cleanups for OMAP platforms
plus a handful of other cleanups across the place"
* tag 'cleanup-for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (87 commits)
ARM: kconfig: allow PCI support to be selected with ARCH_MULTIPLATFORM
clk: samsung: fix build error
ARM: vexpress: refine dependencies for new code
clk: samsung: clk-s3c2410-dlck: do not use PNAME macro as it declares __initdata
cpufreq: exynos: Fix the compile error
ARM: S3C24XX: move debug-macro.S into the common space
ARM: S3C24XX: use generic DEBUG_UART_PHY/_VIRT in debug macro
ARM: S3C24XX: trim down debug uart handling
ARM: compressed/head.S: remove s3c24xx special case
ARM: EXYNOS: Remove unnecessary inclusion of cpu.h
ARM: EXYNOS: Migrate Exynos specific macros from plat to mach
ARM: EXYNOS: Remove exynos_subsys registration
ARM: EXYNOS: Remove duplicate lines in Makefile
ARM: EXYNOS: use v7_exit_coherency_flush macro for cache disabling
ARM: OMAP4: PRCM: remove references to cm-regbits-44xx.h from PRCM core files
ARM: OMAP3/4: PRM: add support of late_init call to prm_ll_ops
ARM: OMAP3/OMAP4: PRM: add prm_features flags and add IO wakeup under it
ARM: OMAP3/4: PRM: provide io chain reconfig function through irq setup
ARM: OMAP2+: PRM: remove unnecessary cpu_is_XXX calls from prm_init / exit
ARM: OMAP2+: PRCM: cleanup some header includes
...
This commit is contained in:
commit
0a58471541
211 changed files with 4666 additions and 5172 deletions
|
|
@ -515,6 +515,15 @@ config SRAM
|
|||
the genalloc API. It is supposed to be used for small on-chip SRAM
|
||||
areas found on many SoCs.
|
||||
|
||||
config VEXPRESS_SYSCFG
|
||||
bool "Versatile Express System Configuration driver"
|
||||
depends on VEXPRESS_CONFIG
|
||||
default y
|
||||
help
|
||||
ARM Ltd. Versatile Express uses specialised platform configuration
|
||||
bus. System Configuration interface is one of the possible means
|
||||
of generating transactions on this bus.
|
||||
|
||||
source "drivers/misc/c2port/Kconfig"
|
||||
source "drivers/misc/eeprom/Kconfig"
|
||||
source "drivers/misc/cb710/Kconfig"
|
||||
|
|
|
|||
|
|
@ -55,3 +55,4 @@ obj-$(CONFIG_SRAM) += sram.o
|
|||
obj-y += mic/
|
||||
obj-$(CONFIG_GENWQE) += genwqe/
|
||||
obj-$(CONFIG_ECHO) += echo/
|
||||
obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
|
||||
|
|
|
|||
324
drivers/misc/vexpress-syscfg.c
Normal file
324
drivers/misc/vexpress-syscfg.c
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* Copyright (C) 2014 ARM Limited
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/syscore_ops.h>
|
||||
#include <linux/vexpress.h>
|
||||
|
||||
|
||||
#define SYS_CFGDATA 0x0
|
||||
|
||||
#define SYS_CFGCTRL 0x4
|
||||
#define SYS_CFGCTRL_START (1 << 31)
|
||||
#define SYS_CFGCTRL_WRITE (1 << 30)
|
||||
#define SYS_CFGCTRL_DCC(n) (((n) & 0xf) << 26)
|
||||
#define SYS_CFGCTRL_FUNC(n) (((n) & 0x3f) << 20)
|
||||
#define SYS_CFGCTRL_SITE(n) (((n) & 0x3) << 16)
|
||||
#define SYS_CFGCTRL_POSITION(n) (((n) & 0xf) << 12)
|
||||
#define SYS_CFGCTRL_DEVICE(n) (((n) & 0xfff) << 0)
|
||||
|
||||
#define SYS_CFGSTAT 0x8
|
||||
#define SYS_CFGSTAT_ERR (1 << 1)
|
||||
#define SYS_CFGSTAT_COMPLETE (1 << 0)
|
||||
|
||||
|
||||
struct vexpress_syscfg {
|
||||
struct device *dev;
|
||||
void __iomem *base;
|
||||
struct list_head funcs;
|
||||
};
|
||||
|
||||
struct vexpress_syscfg_func {
|
||||
struct list_head list;
|
||||
struct vexpress_syscfg *syscfg;
|
||||
struct regmap *regmap;
|
||||
int num_templates;
|
||||
u32 template[0]; /* Keep it last! */
|
||||
};
|
||||
|
||||
|
||||
static int vexpress_syscfg_exec(struct vexpress_syscfg_func *func,
|
||||
int index, bool write, u32 *data)
|
||||
{
|
||||
struct vexpress_syscfg *syscfg = func->syscfg;
|
||||
u32 command, status;
|
||||
int tries;
|
||||
long timeout;
|
||||
|
||||
if (WARN_ON(index > func->num_templates))
|
||||
return -EINVAL;
|
||||
|
||||
command = readl(syscfg->base + SYS_CFGCTRL);
|
||||
if (WARN_ON(command & SYS_CFGCTRL_START))
|
||||
return -EBUSY;
|
||||
|
||||
command = func->template[index];
|
||||
command |= SYS_CFGCTRL_START;
|
||||
command |= write ? SYS_CFGCTRL_WRITE : 0;
|
||||
|
||||
/* Use a canary for reads */
|
||||
if (!write)
|
||||
*data = 0xdeadbeef;
|
||||
|
||||
dev_dbg(syscfg->dev, "func %p, command %x, data %x\n",
|
||||
func, command, *data);
|
||||
writel(*data, syscfg->base + SYS_CFGDATA);
|
||||
writel(0, syscfg->base + SYS_CFGSTAT);
|
||||
writel(command, syscfg->base + SYS_CFGCTRL);
|
||||
mb();
|
||||
|
||||
/* The operation can take ages... Go to sleep, 100us initially */
|
||||
tries = 100;
|
||||
timeout = 100;
|
||||
do {
|
||||
if (!irqs_disabled()) {
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
schedule_timeout(usecs_to_jiffies(timeout));
|
||||
if (signal_pending(current))
|
||||
return -EINTR;
|
||||
} else {
|
||||
udelay(timeout);
|
||||
}
|
||||
|
||||
status = readl(syscfg->base + SYS_CFGSTAT);
|
||||
if (status & SYS_CFGSTAT_ERR)
|
||||
return -EFAULT;
|
||||
|
||||
if (timeout > 20)
|
||||
timeout -= 20;
|
||||
} while (--tries && !(status & SYS_CFGSTAT_COMPLETE));
|
||||
if (WARN_ON_ONCE(!tries))
|
||||
return -ETIMEDOUT;
|
||||
|
||||
if (!write) {
|
||||
*data = readl(syscfg->base + SYS_CFGDATA);
|
||||
dev_dbg(syscfg->dev, "func %p, read data %x\n", func, *data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vexpress_syscfg_read(void *context, unsigned int index,
|
||||
unsigned int *val)
|
||||
{
|
||||
struct vexpress_syscfg_func *func = context;
|
||||
|
||||
return vexpress_syscfg_exec(func, index, false, val);
|
||||
}
|
||||
|
||||
static int vexpress_syscfg_write(void *context, unsigned int index,
|
||||
unsigned int val)
|
||||
{
|
||||
struct vexpress_syscfg_func *func = context;
|
||||
|
||||
return vexpress_syscfg_exec(func, index, true, &val);
|
||||
}
|
||||
|
||||
struct regmap_config vexpress_syscfg_regmap_config = {
|
||||
.lock = vexpress_config_lock,
|
||||
.unlock = vexpress_config_unlock,
|
||||
.reg_bits = 32,
|
||||
.val_bits = 32,
|
||||
.reg_read = vexpress_syscfg_read,
|
||||
.reg_write = vexpress_syscfg_write,
|
||||
.reg_format_endian = REGMAP_ENDIAN_LITTLE,
|
||||
.val_format_endian = REGMAP_ENDIAN_LITTLE,
|
||||
};
|
||||
|
||||
|
||||
static struct regmap *vexpress_syscfg_regmap_init(struct device *dev,
|
||||
void *context)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct vexpress_syscfg *syscfg = context;
|
||||
struct vexpress_syscfg_func *func;
|
||||
struct property *prop;
|
||||
const __be32 *val = NULL;
|
||||
__be32 energy_quirk[4];
|
||||
int num;
|
||||
u32 site, position, dcc;
|
||||
int i;
|
||||
|
||||
if (dev->of_node) {
|
||||
int err = vexpress_config_get_topo(dev->of_node, &site,
|
||||
&position, &dcc);
|
||||
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
prop = of_find_property(dev->of_node,
|
||||
"arm,vexpress-sysreg,func", NULL);
|
||||
if (!prop)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
num = prop->length / sizeof(u32) / 2;
|
||||
val = prop->value;
|
||||
} else {
|
||||
if (pdev->num_resources != 1 ||
|
||||
pdev->resource[0].flags != IORESOURCE_BUS)
|
||||
return ERR_PTR(-EFAULT);
|
||||
|
||||
site = pdev->resource[0].start;
|
||||
if (site == VEXPRESS_SITE_MASTER)
|
||||
site = vexpress_config_get_master();
|
||||
position = 0;
|
||||
dcc = 0;
|
||||
num = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* "arm,vexpress-energy" function used to be described
|
||||
* by its first device only, now it requires both
|
||||
*/
|
||||
if (num == 1 && of_device_is_compatible(dev->of_node,
|
||||
"arm,vexpress-energy")) {
|
||||
num = 2;
|
||||
energy_quirk[0] = *val;
|
||||
energy_quirk[2] = *val++;
|
||||
energy_quirk[1] = *val;
|
||||
energy_quirk[3] = cpu_to_be32(be32_to_cpup(val) + 1);
|
||||
val = energy_quirk;
|
||||
}
|
||||
|
||||
func = kzalloc(sizeof(*func) + sizeof(*func->template) * num,
|
||||
GFP_KERNEL);
|
||||
if (!func)
|
||||
return NULL;
|
||||
|
||||
func->syscfg = syscfg;
|
||||
func->num_templates = num;
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
u32 function, device;
|
||||
|
||||
if (dev->of_node) {
|
||||
function = be32_to_cpup(val++);
|
||||
device = be32_to_cpup(val++);
|
||||
} else {
|
||||
function = pdev->resource[0].end;
|
||||
device = pdev->id;
|
||||
}
|
||||
|
||||
dev_dbg(dev, "func %p: %u/%u/%u/%u/%u\n",
|
||||
func, site, position, dcc,
|
||||
function, device);
|
||||
|
||||
func->template[i] = SYS_CFGCTRL_DCC(dcc);
|
||||
func->template[i] |= SYS_CFGCTRL_SITE(site);
|
||||
func->template[i] |= SYS_CFGCTRL_POSITION(position);
|
||||
func->template[i] |= SYS_CFGCTRL_FUNC(function);
|
||||
func->template[i] |= SYS_CFGCTRL_DEVICE(device);
|
||||
}
|
||||
|
||||
vexpress_syscfg_regmap_config.max_register = num - 1;
|
||||
|
||||
func->regmap = regmap_init(dev, NULL, func,
|
||||
&vexpress_syscfg_regmap_config);
|
||||
|
||||
if (IS_ERR(func->regmap))
|
||||
kfree(func);
|
||||
else
|
||||
list_add(&func->list, &syscfg->funcs);
|
||||
|
||||
return func->regmap;
|
||||
}
|
||||
|
||||
static void vexpress_syscfg_regmap_exit(struct regmap *regmap, void *context)
|
||||
{
|
||||
struct vexpress_syscfg *syscfg = context;
|
||||
struct vexpress_syscfg_func *func, *tmp;
|
||||
|
||||
regmap_exit(regmap);
|
||||
|
||||
list_for_each_entry_safe(func, tmp, &syscfg->funcs, list) {
|
||||
if (func->regmap == regmap) {
|
||||
list_del(&syscfg->funcs);
|
||||
kfree(func);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct vexpress_config_bridge_ops vexpress_syscfg_bridge_ops = {
|
||||
.regmap_init = vexpress_syscfg_regmap_init,
|
||||
.regmap_exit = vexpress_syscfg_regmap_exit,
|
||||
};
|
||||
|
||||
|
||||
/* Non-DT hack, to be gone... */
|
||||
static struct device *vexpress_syscfg_bridge;
|
||||
|
||||
int vexpress_syscfg_device_register(struct platform_device *pdev)
|
||||
{
|
||||
pdev->dev.parent = vexpress_syscfg_bridge;
|
||||
|
||||
return platform_device_register(pdev);
|
||||
}
|
||||
|
||||
|
||||
int vexpress_syscfg_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct vexpress_syscfg *syscfg;
|
||||
struct resource *res;
|
||||
struct device *bridge;
|
||||
|
||||
syscfg = devm_kzalloc(&pdev->dev, sizeof(*syscfg), GFP_KERNEL);
|
||||
if (!syscfg)
|
||||
return -ENOMEM;
|
||||
syscfg->dev = &pdev->dev;
|
||||
INIT_LIST_HEAD(&syscfg->funcs);
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!devm_request_mem_region(&pdev->dev, res->start,
|
||||
resource_size(res), pdev->name))
|
||||
return -EBUSY;
|
||||
|
||||
syscfg->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
|
||||
if (!syscfg->base)
|
||||
return -EFAULT;
|
||||
|
||||
/* Must use dev.parent (MFD), as that's where DT phandle points at... */
|
||||
bridge = vexpress_config_bridge_register(pdev->dev.parent,
|
||||
&vexpress_syscfg_bridge_ops, syscfg);
|
||||
if (IS_ERR(bridge))
|
||||
return PTR_ERR(bridge);
|
||||
|
||||
/* Non-DT case */
|
||||
if (!pdev->dev.of_node)
|
||||
vexpress_syscfg_bridge = bridge;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct platform_device_id vexpress_syscfg_id_table[] = {
|
||||
{ "vexpress-syscfg", },
|
||||
{},
|
||||
};
|
||||
|
||||
static struct platform_driver vexpress_syscfg_driver = {
|
||||
.driver.name = "vexpress-syscfg",
|
||||
.id_table = vexpress_syscfg_id_table,
|
||||
.probe = vexpress_syscfg_probe,
|
||||
};
|
||||
|
||||
static int __init vexpress_syscfg_init(void)
|
||||
{
|
||||
return platform_driver_register(&vexpress_syscfg_driver);
|
||||
}
|
||||
core_initcall(vexpress_syscfg_init);
|
||||
Loading…
Reference in a new issue