cregit-Linux how code gets into the kernel

Release 4.14 drivers/soc/tegra/flowctrl.c

/*
 * 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 <linux/platform_device.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(IS_ERR_OR_NULL(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); }

Contributors

PersonTokensPropCommitsCommitProp
Peter 'p2' De Schrijver2657.78%125.00%
Jon Hunter1328.89%250.00%
Thierry Reding613.33%125.00%
Total45100.00%4100.00%


u32 flowctrl_read_cpu_csr(unsigned int cpuid) { u8 offset = flowctrl_offset_cpu_csr[cpuid]; if (WARN_ONCE(IS_ERR_OR_NULL(tegra_flowctrl_base), "Tegra flowctrl not initialised!\n")) return 0; return readl(tegra_flowctrl_base + offset); }

Contributors

PersonTokensPropCommitsCommitProp
Joseph Lo2255.00%125.00%
Jon Hunter1537.50%250.00%
Thierry Reding37.50%125.00%
Total40100.00%4100.00%


void flowctrl_write_cpu_csr(unsigned int cpuid, u32 value) { return flowctrl_update(flowctrl_offset_cpu_csr[cpuid], value); }

Contributors

PersonTokensPropCommitsCommitProp
Peter 'p2' De Schrijver23100.00%2100.00%
Total23100.00%2100.00%


void flowctrl_write_cpu_halt(unsigned int cpuid, u32 value) { return flowctrl_update(flowctrl_offset_halt_cpu[cpuid], value); }

Contributors

PersonTokensPropCommitsCommitProp
Peter 'p2' De Schrijver23100.00%2100.00%
Total23100.00%2100.00%


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); } }

Contributors

PersonTokensPropCommitsCommitProp
Joseph Lo14798.66%480.00%
Thierry Reding21.34%120.00%
Total149100.00%5100.00%


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); }

Contributors

PersonTokensPropCommitsCommitProp
Joseph Lo8797.75%480.00%
Thierry Reding22.25%120.00%
Total89100.00%5100.00%


static int tegra_flowctrl_probe(struct platform_device *pdev) { void __iomem *base = tegra_flowctrl_base; struct resource *res; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); tegra_flowctrl_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(tegra_flowctrl_base)) return PTR_ERR(tegra_flowctrl_base); iounmap(base); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter6698.51%150.00%
Christophe Jaillet11.49%150.00%
Total67100.00%2100.00%

static const struct of_device_id tegra_flowctrl_match[] = { { .compatible = "nvidia,tegra210-flowctrl" }, { .compatible = "nvidia,tegra124-flowctrl" }, { .compatible = "nvidia,tegra114-flowctrl" }, { .compatible = "nvidia,tegra30-flowctrl" }, { .compatible = "nvidia,tegra20-flowctrl" }, { } }; static struct platform_driver tegra_flowctrl_driver = { .driver = { .name = "tegra-flowctrl", .suppress_bind_attrs = true, .of_match_table = tegra_flowctrl_match, }, .probe = tegra_flowctrl_probe, }; builtin_platform_driver(tegra_flowctrl_driver);
static int __init tegra_flowctrl_init(void) { struct resource res; struct device_node *np; if (!soc_is_tegra()) return 0; np = of_find_matching_node(NULL, tegra_flowctrl_match); if (np) { if (of_address_to_resource(np, 0, &res) < 0) { pr_err("failed to get flowctrl register\n"); return -ENXIO; } of_node_put(np); } else if (IS_ENABLED(CONFIG_ARM)) { /* * Hardcoded fallback for 32-bit Tegra * devices if device tree node is missing. */ res.start = 0x60007000; res.end = 0x60007fff; res.flags = IORESOURCE_MEM; } else { /* * At this point we're running on a Tegra, * that doesn't support the flow controller * (eg. Tegra186), so just return. */ return 0; } tegra_flowctrl_base = ioremap_nocache(res.start, resource_size(&res)); if (!tegra_flowctrl_base) return -ENXIO; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter7857.78%375.00%
Thierry Reding5742.22%125.00%
Total135100.00%4100.00%

early_initcall(tegra_flowctrl_init);

Overall Contributors

PersonTokensPropCommitsCommitProp
Joseph Lo26035.42%428.57%
Jon Hunter23131.47%321.43%
Thierry Reding12116.49%321.43%
Peter 'p2' De Schrijver11916.21%214.29%
Hiroshi Doyu20.27%17.14%
Christophe Jaillet10.14%17.14%
Total734100.00%14100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.