tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / soc / nvidia / tegra132 / power.c
blobf41dd4bdb1c2e2fe81e5f212c0328302287a03d7
1 /*
2 * This file is part of the coreboot project.
4 * Copyright 2013 Google Inc.
5 * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <arch/io.h>
18 #include <assert.h>
19 #include <console/console.h>
20 #include <soc/addressmap.h>
21 #include <soc/pmc.h>
22 #include <soc/power.h>
24 static struct tegra_pmc_regs * const pmc = (void *)TEGRA_PMC_BASE;
26 static int partition_powered(int id)
28 return read32(&pmc->pwrgate_status) & (0x1 << id);
31 void power_ungate_partition(uint32_t id)
33 printk(BIOS_INFO, "Ungating power partition %d.\n", id);
35 if (!partition_powered(id)) {
36 uint32_t pwrgate_toggle = read32(&pmc->pwrgate_toggle);
37 pwrgate_toggle &= ~(PMC_PWRGATE_TOGGLE_PARTID_MASK);
38 pwrgate_toggle |= (id << PMC_PWRGATE_TOGGLE_PARTID_SHIFT);
39 pwrgate_toggle |= PMC_PWRGATE_TOGGLE_START;
40 write32(&pmc->pwrgate_toggle, pwrgate_toggle);
42 /* Wait for the request to be accepted. */
43 while (read32(&pmc->pwrgate_toggle) & PMC_PWRGATE_TOGGLE_START)
45 printk(BIOS_DEBUG, "Power gate toggle request accepted.\n");
47 /* Wait for the partition to be powered. */
48 while (!partition_powered(id))
52 printk(BIOS_INFO, "Ungated power partition %d.\n", id);
55 uint8_t pmc_rst_status(void)
57 return read32(&pmc->rst_status) & PMC_RST_STATUS_SOURCE_MASK;
60 static const char *pmc_rst_status_str[PMC_RST_STATUS_NUM_SOURCES] = {
61 [PMC_RST_STATUS_SOURCE_POR] = "POR",
62 [PMC_RST_STATUS_SOURCE_WATCHDOG] = "Watchdog",
63 [PMC_RST_STATUS_SOURCE_SENSOR] = "Sensor",
64 [PMC_RST_STATUS_SOURCE_SW_MAIN] = "SW Main",
65 [PMC_RST_STATUS_SOURCE_LP0] = "LP0",
68 void pmc_print_rst_status(void)
70 uint8_t rst_status = pmc_rst_status();
71 assert(rst_status < PMC_RST_STATUS_NUM_SOURCES);
72 printk(BIOS_INFO, "PMC Reset Status: %s\n",
73 pmc_rst_status_str[rst_status]);