2013-04-12 10:28:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Lucas Stach <l.stach@pengutronix.de>
|
|
|
|
*
|
|
|
|
* 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 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Device driver for the Tegra 20 power management controller.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2014-06-03 20:34:51 +00:00
|
|
|
#include <command.h>
|
2013-04-12 10:28:21 +00:00
|
|
|
#include <init.h>
|
|
|
|
#include <io.h>
|
|
|
|
|
|
|
|
#include <mach/tegra20-pmc.h>
|
|
|
|
|
|
|
|
static void __iomem *pmc_base;
|
|
|
|
|
|
|
|
/* main SoC reset trigger */
|
|
|
|
void __noreturn reset_cpu(ulong addr)
|
|
|
|
{
|
|
|
|
writel(PMC_CNTRL_MAIN_RST, pmc_base + PMC_CNTRL);
|
|
|
|
|
|
|
|
unreachable();
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(reset_cpu);
|
|
|
|
|
|
|
|
static int tegra20_pmc_probe(struct device_d *dev)
|
|
|
|
{
|
|
|
|
pmc_base = dev_request_mem_region(dev, 0);
|
|
|
|
if (!pmc_base) {
|
|
|
|
dev_err(dev, "could not get memory region\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-03 20:34:51 +00:00
|
|
|
static int do_tegrarcm(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
writel(2, pmc_base + PMC_SCRATCH(0));
|
|
|
|
reset_cpu(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-12 10:28:21 +00:00
|
|
|
static __maybe_unused struct of_device_id tegra20_pmc_dt_ids[] = {
|
|
|
|
{
|
|
|
|
.compatible = "nvidia,tegra20-pmc",
|
2014-06-03 20:34:50 +00:00
|
|
|
}, {
|
|
|
|
.compatible = "nvidia,tegra30-pmc",
|
2014-06-03 20:35:14 +00:00
|
|
|
}, {
|
|
|
|
.compatible = "nvidia,tegra124-pmc",
|
2013-04-12 10:28:21 +00:00
|
|
|
}, {
|
|
|
|
/* sentinel */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct driver_d tegra20_pmc_driver = {
|
|
|
|
.probe = tegra20_pmc_probe,
|
|
|
|
.name = "tegra20-pmc",
|
|
|
|
.of_compatible = DRV_OF_COMPAT(tegra20_pmc_dt_ids),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int tegra20_pmc_init(void)
|
|
|
|
{
|
|
|
|
return platform_driver_register(&tegra20_pmc_driver);
|
|
|
|
}
|
|
|
|
coredevice_initcall(tegra20_pmc_init);
|
2014-06-03 20:34:51 +00:00
|
|
|
|
|
|
|
BAREBOX_CMD_HELP_START(tegrarcm)
|
|
|
|
BAREBOX_CMD_HELP_TEXT("Get into recovery mode without using a physical switch\n")
|
|
|
|
BAREBOX_CMD_HELP_END
|
|
|
|
|
|
|
|
BAREBOX_CMD_START(tegrarcm)
|
|
|
|
.cmd = do_tegrarcm,
|
|
|
|
BAREBOX_CMD_DESC("Usage: tegrarcm")
|
|
|
|
BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
|
|
|
|
BAREBOX_CMD_HELP(cmd_tegrarcm_help)
|
|
|
|
BAREBOX_CMD_END
|