mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
soc/tegra: Move Tegra flowctrl driver
The flowctrl driver is required for both ARM and ARM64 Tegra devices and in order to enable support for it for ARM64, move the Tegra flowctrl driver into drivers/soc/tegra. By moving the flowctrl driver, tegra_flowctrl_init() is now called by via an early initcall and to prevent this function from attempting to mapping IO space for a non-Tegra device, a test for 'soc_is_tegra()' is also added. Signed-off-by: Jon Hunter <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
This commit is contained in:
parent
07d76e953b
commit
7e10cf7436
12 changed files with 61 additions and 22 deletions
|
|
@ -12,6 +12,7 @@ config ARCH_TEGRA_2x_SOC
|
|||
select PINCTRL_TEGRA20
|
||||
select PL310_ERRATA_727915 if CACHE_L2X0
|
||||
select PL310_ERRATA_769419 if CACHE_L2X0
|
||||
select SOC_TEGRA_FLOWCTRL
|
||||
select SOC_TEGRA_PMC
|
||||
select TEGRA_TIMER
|
||||
help
|
||||
|
|
@ -24,6 +25,7 @@ config ARCH_TEGRA_3x_SOC
|
|||
select ARM_ERRATA_764369 if SMP
|
||||
select PINCTRL_TEGRA30
|
||||
select PL310_ERRATA_769419 if CACHE_L2X0
|
||||
select SOC_TEGRA_FLOWCTRL
|
||||
select SOC_TEGRA_PMC
|
||||
select TEGRA_TIMER
|
||||
help
|
||||
|
|
@ -35,6 +37,7 @@ config ARCH_TEGRA_114_SOC
|
|||
select ARM_ERRATA_798181 if SMP
|
||||
select HAVE_ARM_ARCH_TIMER
|
||||
select PINCTRL_TEGRA114
|
||||
select SOC_TEGRA_FLOWCTRL
|
||||
select SOC_TEGRA_PMC
|
||||
select TEGRA_TIMER
|
||||
help
|
||||
|
|
@ -45,6 +48,7 @@ config ARCH_TEGRA_124_SOC
|
|||
bool "Enable support for Tegra124 family"
|
||||
select HAVE_ARM_ARCH_TIMER
|
||||
select PINCTRL_TEGRA124
|
||||
select SOC_TEGRA_FLOWCTRL
|
||||
select SOC_TEGRA_PMC
|
||||
select TEGRA_TIMER
|
||||
help
|
||||
|
|
@ -101,6 +105,9 @@ config ARCH_TEGRA_186_SOC
|
|||
endif
|
||||
endif
|
||||
|
||||
config SOC_TEGRA_FLOWCTRL
|
||||
bool
|
||||
|
||||
config SOC_TEGRA_PMC
|
||||
bool
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
obj-y += fuse/
|
||||
|
||||
obj-y += common.o
|
||||
obj-$(CONFIG_SOC_TEGRA_FLOWCTRL) += flowctrl.o
|
||||
obj-$(CONFIG_SOC_TEGRA_PMC) += pmc.o
|
||||
obj-$(CONFIG_SOC_TEGRA_PMC_TEGRA186) += pmc-tegra186.o
|
||||
|
|
|
|||
187
drivers/soc/tegra/flowctrl.c
Normal file
187
drivers/soc/tegra/flowctrl.c
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* drivers/soc/tegra/flowctrl.c
|
||||
*
|
||||
* Functions and macros to control the flowcontroller
|
||||
*
|
||||
* Copyright (c) 2010-2012, NVIDIA Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
|
||||
#include <soc/tegra/common.h>
|
||||
#include <soc/tegra/flowctrl.h>
|
||||
#include <soc/tegra/fuse.h>
|
||||
|
||||
static u8 flowctrl_offset_halt_cpu[] = {
|
||||
FLOW_CTRL_HALT_CPU0_EVENTS,
|
||||
FLOW_CTRL_HALT_CPU1_EVENTS,
|
||||
FLOW_CTRL_HALT_CPU1_EVENTS + 8,
|
||||
FLOW_CTRL_HALT_CPU1_EVENTS + 16,
|
||||
};
|
||||
|
||||
static u8 flowctrl_offset_cpu_csr[] = {
|
||||
FLOW_CTRL_CPU0_CSR,
|
||||
FLOW_CTRL_CPU1_CSR,
|
||||
FLOW_CTRL_CPU1_CSR + 8,
|
||||
FLOW_CTRL_CPU1_CSR + 16,
|
||||
};
|
||||
|
||||
static void __iomem *tegra_flowctrl_base;
|
||||
|
||||
static void flowctrl_update(u8 offset, u32 value)
|
||||
{
|
||||
if (WARN_ONCE(!tegra_flowctrl_base,
|
||||
"Tegra flowctrl not initialised!\n"))
|
||||
return;
|
||||
|
||||
writel(value, tegra_flowctrl_base + offset);
|
||||
|
||||
/* ensure the update has reached the flow controller */
|
||||
wmb();
|
||||
readl_relaxed(tegra_flowctrl_base + offset);
|
||||
}
|
||||
|
||||
u32 flowctrl_read_cpu_csr(unsigned int cpuid)
|
||||
{
|
||||
u8 offset = flowctrl_offset_cpu_csr[cpuid];
|
||||
|
||||
if (WARN_ONCE(!tegra_flowctrl_base,
|
||||
"Tegra flowctrl not initialised!\n"))
|
||||
return 0;
|
||||
|
||||
return readl(tegra_flowctrl_base + offset);
|
||||
}
|
||||
|
||||
void flowctrl_write_cpu_csr(unsigned int cpuid, u32 value)
|
||||
{
|
||||
return flowctrl_update(flowctrl_offset_cpu_csr[cpuid], value);
|
||||
}
|
||||
|
||||
void flowctrl_write_cpu_halt(unsigned int cpuid, u32 value)
|
||||
{
|
||||
return flowctrl_update(flowctrl_offset_halt_cpu[cpuid], value);
|
||||
}
|
||||
|
||||
void flowctrl_cpu_suspend_enter(unsigned int cpuid)
|
||||
{
|
||||
unsigned int reg;
|
||||
int i;
|
||||
|
||||
reg = flowctrl_read_cpu_csr(cpuid);
|
||||
switch (tegra_get_chip_id()) {
|
||||
case TEGRA20:
|
||||
/* clear wfe bitmap */
|
||||
reg &= ~TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP;
|
||||
/* clear wfi bitmap */
|
||||
reg &= ~TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP;
|
||||
/* pwr gating on wfe */
|
||||
reg |= TEGRA20_FLOW_CTRL_CSR_WFE_CPU0 << cpuid;
|
||||
break;
|
||||
case TEGRA30:
|
||||
case TEGRA114:
|
||||
case TEGRA124:
|
||||
/* clear wfe bitmap */
|
||||
reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP;
|
||||
/* clear wfi bitmap */
|
||||
reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP;
|
||||
/* pwr gating on wfi */
|
||||
reg |= TEGRA30_FLOW_CTRL_CSR_WFI_CPU0 << cpuid;
|
||||
break;
|
||||
}
|
||||
reg |= FLOW_CTRL_CSR_INTR_FLAG; /* clear intr flag */
|
||||
reg |= FLOW_CTRL_CSR_EVENT_FLAG; /* clear event flag */
|
||||
reg |= FLOW_CTRL_CSR_ENABLE; /* pwr gating */
|
||||
flowctrl_write_cpu_csr(cpuid, reg);
|
||||
|
||||
for (i = 0; i < num_possible_cpus(); i++) {
|
||||
if (i == cpuid)
|
||||
continue;
|
||||
reg = flowctrl_read_cpu_csr(i);
|
||||
reg |= FLOW_CTRL_CSR_EVENT_FLAG;
|
||||
reg |= FLOW_CTRL_CSR_INTR_FLAG;
|
||||
flowctrl_write_cpu_csr(i, reg);
|
||||
}
|
||||
}
|
||||
|
||||
void flowctrl_cpu_suspend_exit(unsigned int cpuid)
|
||||
{
|
||||
unsigned int reg;
|
||||
|
||||
/* Disable powergating via flow controller for CPU0 */
|
||||
reg = flowctrl_read_cpu_csr(cpuid);
|
||||
switch (tegra_get_chip_id()) {
|
||||
case TEGRA20:
|
||||
/* clear wfe bitmap */
|
||||
reg &= ~TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP;
|
||||
/* clear wfi bitmap */
|
||||
reg &= ~TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP;
|
||||
break;
|
||||
case TEGRA30:
|
||||
case TEGRA114:
|
||||
case TEGRA124:
|
||||
/* clear wfe bitmap */
|
||||
reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP;
|
||||
/* clear wfi bitmap */
|
||||
reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP;
|
||||
break;
|
||||
}
|
||||
reg &= ~FLOW_CTRL_CSR_ENABLE; /* clear enable */
|
||||
reg |= FLOW_CTRL_CSR_INTR_FLAG; /* clear intr */
|
||||
reg |= FLOW_CTRL_CSR_EVENT_FLAG; /* clear event */
|
||||
flowctrl_write_cpu_csr(cpuid, reg);
|
||||
}
|
||||
|
||||
static const struct of_device_id matches[] __initconst = {
|
||||
{ .compatible = "nvidia,tegra124-flowctrl" },
|
||||
{ .compatible = "nvidia,tegra114-flowctrl" },
|
||||
{ .compatible = "nvidia,tegra30-flowctrl" },
|
||||
{ .compatible = "nvidia,tegra20-flowctrl" },
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init tegra_flowctrl_init(void)
|
||||
{
|
||||
/* hardcoded fallback if device tree node is missing */
|
||||
unsigned long base = 0x60007000;
|
||||
unsigned long size = SZ_4K;
|
||||
struct device_node *np;
|
||||
|
||||
if (!soc_is_tegra())
|
||||
return 0;
|
||||
|
||||
np = of_find_matching_node(NULL, matches);
|
||||
if (np) {
|
||||
struct resource res;
|
||||
|
||||
if (of_address_to_resource(np, 0, &res) == 0) {
|
||||
size = resource_size(&res);
|
||||
base = res.start;
|
||||
}
|
||||
|
||||
of_node_put(np);
|
||||
}
|
||||
|
||||
tegra_flowctrl_base = ioremap_nocache(base, size);
|
||||
if (!tegra_flowctrl_base)
|
||||
return -ENXIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
early_initcall(tegra_flowctrl_init);
|
||||
Loading…
Reference in a new issue