summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2018-12-12 16:28:24 -0500
committerOlof Johansson <olof@lixom.net>2018-12-12 16:28:24 -0500
commit4a598c7b3f00e30148a3cc2e314961328f8a277e (patch)
tree323eb27af0e088227e9afef378a814a00a82745c
parent48ff08dd9aa9353ece8f5bebd217e824f1c6098c (diff)
parente3e403c218cd07b497127a29e604fc26a71e8558 (diff)
Merge tag 'tegra-for-4.21-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into next/drivers
soc/tegra: Changes for v4.21-rc1 These changes are mostly cleanups to the PMC driver, but they also add support for wake events on Tegra186 and Tegra194, which can be used to wake the system from sleep. With this and the corresponding device tree additions suspend/resume is finally working on these SoCs. * tag 'tegra-for-4.21-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux: soc/tegra: pmc: Add initial Tegra194 wake events soc/tegra: pmc: Add initial Tegra186 wake events soc/tegra: pmc: Add wake event support soc/tegra: pmc: Add Tegra194 support soc/tegra: pmc: Change to use DEFINE_SHOW_ATTRIBUTE macro soc/tegra: Don't leak device tree node reference soc/tegra: fuse: Remove duplicated function declaration soc/tegra: pmc: Drop locking from tegra_powergate_is_powered() soc/tegra: pmc: Add sysfs entries for reset info soc/tegra: pmc: Don't power-up XUSB power-domains Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r--drivers/soc/tegra/common.c6
-rw-r--r--drivers/soc/tegra/pmc.c472
-rw-r--r--include/soc/tegra/fuse.h1
-rw-r--r--include/soc/tegra/pmc.h21
4 files changed, 462 insertions, 38 deletions
diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c
index cd8f41351add..7bfb154d6fa5 100644
--- a/drivers/soc/tegra/common.c
+++ b/drivers/soc/tegra/common.c
@@ -22,11 +22,15 @@ static const struct of_device_id tegra_machine_match[] = {
22 22
23bool soc_is_tegra(void) 23bool soc_is_tegra(void)
24{ 24{
25 const struct of_device_id *match;
25 struct device_node *root; 26 struct device_node *root;
26 27
27 root = of_find_node_by_path("/"); 28 root = of_find_node_by_path("/");
28 if (!root) 29 if (!root)
29 return false; 30 return false;
30 31
31 return of_match_node(tegra_machine_match, root) != NULL; 32 match = of_match_node(tegra_machine_match, root);
33 of_node_put(root);
34
35 return match != NULL;
32} 36}
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 1fa840e3d930..8c46b0aace0b 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -2,6 +2,7 @@
2 * drivers/soc/tegra/pmc.c 2 * drivers/soc/tegra/pmc.c
3 * 3 *
4 * Copyright (c) 2010 Google, Inc 4 * Copyright (c) 2010 Google, Inc
5 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
5 * 6 *
6 * Author: 7 * Author:
7 * Colin Cross <ccross@google.com> 8 * Colin Cross <ccross@google.com>
@@ -29,9 +30,12 @@
29#include <linux/init.h> 30#include <linux/init.h>
30#include <linux/io.h> 31#include <linux/io.h>
31#include <linux/iopoll.h> 32#include <linux/iopoll.h>
33#include <linux/irq.h>
34#include <linux/irqdomain.h>
32#include <linux/of.h> 35#include <linux/of.h>
33#include <linux/of_address.h> 36#include <linux/of_address.h>
34#include <linux/of_clk.h> 37#include <linux/of_clk.h>
38#include <linux/of_irq.h>
35#include <linux/of_platform.h> 39#include <linux/of_platform.h>
36#include <linux/pinctrl/pinctrl.h> 40#include <linux/pinctrl/pinctrl.h>
37#include <linux/pinctrl/pinconf.h> 41#include <linux/pinctrl/pinconf.h>
@@ -48,7 +52,10 @@
48#include <soc/tegra/fuse.h> 52#include <soc/tegra/fuse.h>
49#include <soc/tegra/pmc.h> 53#include <soc/tegra/pmc.h>
50 54
55#include <dt-bindings/interrupt-controller/arm-gic.h>
51#include <dt-bindings/pinctrl/pinctrl-tegra-io-pad.h> 56#include <dt-bindings/pinctrl/pinctrl-tegra-io-pad.h>
57#include <dt-bindings/gpio/tegra186-gpio.h>
58#include <dt-bindings/gpio/tegra194-gpio.h>
52 59
53#define PMC_CNTRL 0x0 60#define PMC_CNTRL 0x0
54#define PMC_CNTRL_INTR_POLARITY BIT(17) /* inverts INTR polarity */ 61#define PMC_CNTRL_INTR_POLARITY BIT(17) /* inverts INTR polarity */
@@ -92,7 +99,6 @@
92#define PMC_SENSOR_CTRL_SCRATCH_WRITE BIT(2) 99#define PMC_SENSOR_CTRL_SCRATCH_WRITE BIT(2)
93#define PMC_SENSOR_CTRL_ENABLE_RST BIT(1) 100#define PMC_SENSOR_CTRL_ENABLE_RST BIT(1)
94 101
95#define PMC_RST_STATUS 0x1b4
96#define PMC_RST_STATUS_POR 0 102#define PMC_RST_STATUS_POR 0
97#define PMC_RST_STATUS_WATCHDOG 1 103#define PMC_RST_STATUS_WATCHDOG 1
98#define PMC_RST_STATUS_SENSOR 2 104#define PMC_RST_STATUS_SENSOR 2
@@ -126,6 +132,16 @@
126#define GPU_RG_CNTRL 0x2d4 132#define GPU_RG_CNTRL 0x2d4
127 133
128/* Tegra186 and later */ 134/* Tegra186 and later */
135#define WAKE_AOWAKE_CNTRL(x) (0x000 + ((x) << 2))
136#define WAKE_AOWAKE_CNTRL_LEVEL (1 << 3)
137#define WAKE_AOWAKE_MASK_W(x) (0x180 + ((x) << 2))
138#define WAKE_AOWAKE_MASK_R(x) (0x300 + ((x) << 2))
139#define WAKE_AOWAKE_STATUS_W(x) (0x30c + ((x) << 2))
140#define WAKE_AOWAKE_STATUS_R(x) (0x48c + ((x) << 2))
141#define WAKE_AOWAKE_TIER0_ROUTING(x) (0x4b4 + ((x) << 2))
142#define WAKE_AOWAKE_TIER1_ROUTING(x) (0x4c0 + ((x) << 2))
143#define WAKE_AOWAKE_TIER2_ROUTING(x) (0x4cc + ((x) << 2))
144
129#define WAKE_AOWAKE_CTRL 0x4f4 145#define WAKE_AOWAKE_CTRL 0x4f4
130#define WAKE_AOWAKE_CTRL_INTR_POLARITY BIT(0) 146#define WAKE_AOWAKE_CTRL_INTR_POLARITY BIT(0)
131 147
@@ -151,8 +167,45 @@ struct tegra_pmc_regs {
151 unsigned int dpd_status; 167 unsigned int dpd_status;
152 unsigned int dpd2_req; 168 unsigned int dpd2_req;
153 unsigned int dpd2_status; 169 unsigned int dpd2_status;
170 unsigned int rst_status;
171 unsigned int rst_source_shift;
172 unsigned int rst_source_mask;
173 unsigned int rst_level_shift;
174 unsigned int rst_level_mask;
175};
176
177struct tegra_wake_event {
178 const char *name;
179 unsigned int id;
180 unsigned int irq;
181 struct {
182 unsigned int instance;
183 unsigned int pin;
184 } gpio;
154}; 185};
155 186
187#define TEGRA_WAKE_IRQ(_name, _id, _irq) \
188 { \
189 .name = _name, \
190 .id = _id, \
191 .irq = _irq, \
192 .gpio = { \
193 .instance = UINT_MAX, \
194 .pin = UINT_MAX, \
195 }, \
196 }
197
198#define TEGRA_WAKE_GPIO(_name, _id, _instance, _pin) \
199 { \
200 .name = _name, \
201 .id = _id, \
202 .irq = 0, \
203 .gpio = { \
204 .instance = _instance, \
205 .pin = _pin, \
206 }, \
207 }
208
156struct tegra_pmc_soc { 209struct tegra_pmc_soc {
157 unsigned int num_powergates; 210 unsigned int num_powergates;
158 const char *const *powergates; 211 const char *const *powergates;
@@ -175,6 +228,45 @@ struct tegra_pmc_soc {
175 void (*setup_irq_polarity)(struct tegra_pmc *pmc, 228 void (*setup_irq_polarity)(struct tegra_pmc *pmc,
176 struct device_node *np, 229 struct device_node *np,
177 bool invert); 230 bool invert);
231
232 const char * const *reset_sources;
233 unsigned int num_reset_sources;
234 const char * const *reset_levels;
235 unsigned int num_reset_levels;
236
237 const struct tegra_wake_event *wake_events;
238 unsigned int num_wake_events;
239};
240
241static const char * const tegra186_reset_sources[] = {
242 "SYS_RESET",
243 "AOWDT",
244 "MCCPLEXWDT",
245 "BPMPWDT",
246 "SCEWDT",
247 "SPEWDT",
248 "APEWDT",
249 "BCCPLEXWDT",
250 "SENSOR",
251 "AOTAG",
252 "VFSENSOR",
253 "SWREST",
254 "SC7",
255 "HSM",
256 "CORESIGHT"
257};
258
259static const char * const tegra186_reset_levels[] = {
260 "L0", "L1", "L2", "WARM"
261};
262
263static const char * const tegra30_reset_sources[] = {
264 "POWER_ON_RESET",
265 "WATCHDOG",
266 "SENSOR",
267 "SW_MAIN",
268 "LP0",
269 "AOTAG"
178}; 270};
179 271
180/** 272/**
@@ -230,6 +322,9 @@ struct tegra_pmc {
230 struct mutex powergates_lock; 322 struct mutex powergates_lock;
231 323
232 struct pinctrl_dev *pctl_dev; 324 struct pinctrl_dev *pctl_dev;
325
326 struct irq_domain *domain;
327 struct irq_chip irq;
233}; 328};
234 329
235static struct tegra_pmc *pmc = &(struct tegra_pmc) { 330static struct tegra_pmc *pmc = &(struct tegra_pmc) {
@@ -538,16 +633,10 @@ EXPORT_SYMBOL(tegra_powergate_power_off);
538 */ 633 */
539int tegra_powergate_is_powered(unsigned int id) 634int tegra_powergate_is_powered(unsigned int id)
540{ 635{
541 int status;
542
543 if (!tegra_powergate_is_valid(id)) 636 if (!tegra_powergate_is_valid(id))
544 return -EINVAL; 637 return -EINVAL;
545 638
546 mutex_lock(&pmc->powergates_lock); 639 return tegra_powergate_state(id);
547 status = tegra_powergate_state(id);
548 mutex_unlock(&pmc->powergates_lock);
549
550 return status;
551} 640}
552 641
553/** 642/**
@@ -717,17 +806,7 @@ static int powergate_show(struct seq_file *s, void *data)
717 return 0; 806 return 0;
718} 807}
719 808
720static int powergate_open(struct inode *inode, struct file *file) 809DEFINE_SHOW_ATTRIBUTE(powergate);
721{
722 return single_open(file, powergate_show, inode->i_private);
723}
724
725static const struct file_operations powergate_fops = {
726 .open = powergate_open,
727 .read = seq_read,
728 .llseek = seq_lseek,
729 .release = single_release,
730};
731 810
732static int tegra_powergate_debugfs_init(void) 811static int tegra_powergate_debugfs_init(void)
733{ 812{
@@ -847,22 +926,6 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)
847 goto remove_resets; 926 goto remove_resets;
848 } 927 }
849 928
850 /*
851 * FIXME: If XHCI is enabled for Tegra, then power-up the XUSB
852 * host and super-speed partitions. Once the XHCI driver
853 * manages the partitions itself this code can be removed. Note
854 * that we don't register these partitions with the genpd core
855 * to avoid it from powering down the partitions as they appear
856 * to be unused.
857 */
858 if (IS_ENABLED(CONFIG_USB_XHCI_TEGRA) &&
859 (id == TEGRA_POWERGATE_XUSBA || id == TEGRA_POWERGATE_XUSBC)) {
860 if (off)
861 WARN_ON(tegra_powergate_power_up(pg, true));
862
863 goto remove_resets;
864 }
865
866 err = pm_genpd_init(&pg->genpd, NULL, off); 929 err = pm_genpd_init(&pg->genpd, NULL, off);
867 if (err < 0) { 930 if (err < 0) {
868 pr_err("failed to initialise PM domain %pOFn: %d\n", np, 931 pr_err("failed to initialise PM domain %pOFn: %d\n", np,
@@ -1543,6 +1606,225 @@ static int tegra_pmc_pinctrl_init(struct tegra_pmc *pmc)
1543 return err; 1606 return err;
1544} 1607}
1545 1608
1609static ssize_t reset_reason_show(struct device *dev,
1610 struct device_attribute *attr, char *buf)
1611{
1612 u32 value, rst_src;
1613
1614 value = tegra_pmc_readl(pmc->soc->regs->rst_status);
1615 rst_src = (value & pmc->soc->regs->rst_source_mask) >>
1616 pmc->soc->regs->rst_source_shift;
1617
1618 return sprintf(buf, "%s\n", pmc->soc->reset_sources[rst_src]);
1619}
1620
1621static DEVICE_ATTR_RO(reset_reason);
1622
1623static ssize_t reset_level_show(struct device *dev,
1624 struct device_attribute *attr, char *buf)
1625{
1626 u32 value, rst_lvl;
1627
1628 value = tegra_pmc_readl(pmc->soc->regs->rst_status);
1629 rst_lvl = (value & pmc->soc->regs->rst_level_mask) >>
1630 pmc->soc->regs->rst_level_shift;
1631
1632 return sprintf(buf, "%s\n", pmc->soc->reset_levels[rst_lvl]);
1633}
1634
1635static DEVICE_ATTR_RO(reset_level);
1636
1637static void tegra_pmc_reset_sysfs_init(struct tegra_pmc *pmc)
1638{
1639 struct device *dev = pmc->dev;
1640 int err = 0;
1641
1642 if (pmc->soc->reset_sources) {
1643 err = device_create_file(dev, &dev_attr_reset_reason);
1644 if (err < 0)
1645 dev_warn(dev,
1646 "failed to create attr \"reset_reason\": %d\n",
1647 err);
1648 }
1649
1650 if (pmc->soc->reset_levels) {
1651 err = device_create_file(dev, &dev_attr_reset_level);
1652 if (err < 0)
1653 dev_warn(dev,
1654 "failed to create attr \"reset_level\": %d\n",
1655 err);
1656 }
1657}
1658
1659static int tegra_pmc_irq_translate(struct irq_domain *domain,
1660 struct irq_fwspec *fwspec,
1661 unsigned long *hwirq,
1662 unsigned int *type)
1663{
1664 if (WARN_ON(fwspec->param_count < 2))
1665 return -EINVAL;
1666
1667 *hwirq = fwspec->param[0];
1668 *type = fwspec->param[1];
1669
1670 return 0;
1671}
1672
1673static int tegra_pmc_irq_alloc(struct irq_domain *domain, unsigned int virq,
1674 unsigned int num_irqs, void *data)
1675{
1676 struct tegra_pmc *pmc = domain->host_data;
1677 const struct tegra_pmc_soc *soc = pmc->soc;
1678 struct irq_fwspec *fwspec = data;
1679 unsigned int i;
1680 int err = 0;
1681
1682 for (i = 0; i < soc->num_wake_events; i++) {
1683 const struct tegra_wake_event *event = &soc->wake_events[i];
1684
1685 if (fwspec->param_count == 2) {
1686 struct irq_fwspec spec;
1687
1688 if (event->id != fwspec->param[0])
1689 continue;
1690
1691 err = irq_domain_set_hwirq_and_chip(domain, virq,
1692 event->id,
1693 &pmc->irq, pmc);
1694 if (err < 0)
1695 break;
1696
1697 spec.fwnode = &pmc->dev->of_node->fwnode;
1698 spec.param_count = 3;
1699 spec.param[0] = GIC_SPI;
1700 spec.param[1] = event->irq;
1701 spec.param[2] = fwspec->param[1];
1702
1703 err = irq_domain_alloc_irqs_parent(domain, virq,
1704 num_irqs, &spec);
1705
1706 break;
1707 }
1708
1709 if (fwspec->param_count == 3) {
1710 if (event->gpio.instance != fwspec->param[0] ||
1711 event->gpio.pin != fwspec->param[1])
1712 continue;
1713
1714 err = irq_domain_set_hwirq_and_chip(domain, virq,
1715 event->id,
1716 &pmc->irq, pmc);
1717
1718 break;
1719 }
1720 }
1721
1722 if (i == soc->num_wake_events)
1723 err = irq_domain_set_hwirq_and_chip(domain, virq, ULONG_MAX,
1724 &pmc->irq, pmc);
1725
1726 return err;
1727}
1728
1729static const struct irq_domain_ops tegra_pmc_irq_domain_ops = {
1730 .translate = tegra_pmc_irq_translate,
1731 .alloc = tegra_pmc_irq_alloc,
1732};
1733
1734static int tegra_pmc_irq_set_wake(struct irq_data *data, unsigned int on)
1735{
1736 struct tegra_pmc *pmc = irq_data_get_irq_chip_data(data);
1737 unsigned int offset, bit;
1738 u32 value;
1739
1740 offset = data->hwirq / 32;
1741 bit = data->hwirq % 32;
1742
1743 /* clear wake status */
1744 writel(0x1, pmc->wake + WAKE_AOWAKE_STATUS_W(data->hwirq));
1745
1746 /* route wake to tier 2 */
1747 value = readl(pmc->wake + WAKE_AOWAKE_TIER2_ROUTING(offset));
1748
1749 if (!on)
1750 value &= ~(1 << bit);
1751 else
1752 value |= 1 << bit;
1753
1754 writel(value, pmc->wake + WAKE_AOWAKE_TIER2_ROUTING(offset));
1755
1756 /* enable wakeup event */
1757 writel(!!on, pmc->wake + WAKE_AOWAKE_MASK_W(data->hwirq));
1758
1759 return 0;
1760}
1761
1762static int tegra_pmc_irq_set_type(struct irq_data *data, unsigned int type)
1763{
1764 struct tegra_pmc *pmc = irq_data_get_irq_chip_data(data);
1765 u32 value;
1766
1767 if (data->hwirq == ULONG_MAX)
1768 return 0;
1769
1770 value = readl(pmc->wake + WAKE_AOWAKE_CNTRL(data->hwirq));
1771
1772 switch (type) {
1773 case IRQ_TYPE_EDGE_RISING:
1774 case IRQ_TYPE_LEVEL_HIGH:
1775 value |= WAKE_AOWAKE_CNTRL_LEVEL;
1776 break;
1777
1778 case IRQ_TYPE_EDGE_FALLING:
1779 case IRQ_TYPE_LEVEL_LOW:
1780 value &= ~WAKE_AOWAKE_CNTRL_LEVEL;
1781 break;
1782
1783 case IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING:
1784 value ^= WAKE_AOWAKE_CNTRL_LEVEL;
1785 break;
1786
1787 default:
1788 return -EINVAL;
1789 }
1790
1791 writel(value, pmc->wake + WAKE_AOWAKE_CNTRL(data->hwirq));
1792
1793 return 0;
1794}
1795
1796static int tegra_pmc_irq_init(struct tegra_pmc *pmc)
1797{
1798 struct irq_domain *parent = NULL;
1799 struct device_node *np;
1800
1801 np = of_irq_find_parent(pmc->dev->of_node);
1802 if (np) {
1803 parent = irq_find_host(np);
1804 of_node_put(np);
1805 }
1806
1807 if (!parent)
1808 return 0;
1809
1810 pmc->irq.name = dev_name(pmc->dev);
1811 pmc->irq.irq_mask = irq_chip_mask_parent;
1812 pmc->irq.irq_unmask = irq_chip_unmask_parent;
1813 pmc->irq.irq_eoi = irq_chip_eoi_parent;
1814 pmc->irq.irq_set_affinity = irq_chip_set_affinity_parent;
1815 pmc->irq.irq_set_type = tegra_pmc_irq_set_type;
1816 pmc->irq.irq_set_wake = tegra_pmc_irq_set_wake;
1817
1818 pmc->domain = irq_domain_add_hierarchy(parent, 0, 96, pmc->dev->of_node,
1819 &tegra_pmc_irq_domain_ops, pmc);
1820 if (!pmc->domain) {
1821 dev_err(pmc->dev, "failed to allocate domain\n");
1822 return -ENOMEM;
1823 }
1824
1825 return 0;
1826}
1827
1546static int tegra_pmc_probe(struct platform_device *pdev) 1828static int tegra_pmc_probe(struct platform_device *pdev)
1547{ 1829{
1548 void __iomem *base; 1830 void __iomem *base;
@@ -1612,6 +1894,8 @@ static int tegra_pmc_probe(struct platform_device *pdev)
1612 1894
1613 tegra_pmc_init_tsense_reset(pmc); 1895 tegra_pmc_init_tsense_reset(pmc);
1614 1896
1897 tegra_pmc_reset_sysfs_init(pmc);
1898
1615 if (IS_ENABLED(CONFIG_DEBUG_FS)) { 1899 if (IS_ENABLED(CONFIG_DEBUG_FS)) {
1616 err = tegra_powergate_debugfs_init(); 1900 err = tegra_powergate_debugfs_init();
1617 if (err < 0) 1901 if (err < 0)
@@ -1629,6 +1913,10 @@ static int tegra_pmc_probe(struct platform_device *pdev)
1629 if (err) 1913 if (err)
1630 goto cleanup_restart_handler; 1914 goto cleanup_restart_handler;
1631 1915
1916 err = tegra_pmc_irq_init(pmc);
1917 if (err < 0)
1918 goto cleanup_restart_handler;
1919
1632 mutex_lock(&pmc->powergates_lock); 1920 mutex_lock(&pmc->powergates_lock);
1633 iounmap(pmc->base); 1921 iounmap(pmc->base);
1634 pmc->base = base; 1922 pmc->base = base;
@@ -1678,6 +1966,11 @@ static const struct tegra_pmc_regs tegra20_pmc_regs = {
1678 .dpd_status = 0x1bc, 1966 .dpd_status = 0x1bc,
1679 .dpd2_req = 0x1c0, 1967 .dpd2_req = 0x1c0,
1680 .dpd2_status = 0x1c4, 1968 .dpd2_status = 0x1c4,
1969 .rst_status = 0x1b4,
1970 .rst_source_shift = 0x0,
1971 .rst_source_mask = 0x7,
1972 .rst_level_shift = 0x0,
1973 .rst_level_mask = 0x0,
1681}; 1974};
1682 1975
1683static void tegra20_pmc_init(struct tegra_pmc *pmc) 1976static void tegra20_pmc_init(struct tegra_pmc *pmc)
@@ -1735,6 +2028,10 @@ static const struct tegra_pmc_soc tegra20_pmc_soc = {
1735 .regs = &tegra20_pmc_regs, 2028 .regs = &tegra20_pmc_regs,
1736 .init = tegra20_pmc_init, 2029 .init = tegra20_pmc_init,
1737 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity, 2030 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity,
2031 .reset_sources = NULL,
2032 .num_reset_sources = 0,
2033 .reset_levels = NULL,
2034 .num_reset_levels = 0,
1738}; 2035};
1739 2036
1740static const char * const tegra30_powergates[] = { 2037static const char * const tegra30_powergates[] = {
@@ -1776,6 +2073,10 @@ static const struct tegra_pmc_soc tegra30_pmc_soc = {
1776 .regs = &tegra20_pmc_regs, 2073 .regs = &tegra20_pmc_regs,
1777 .init = tegra20_pmc_init, 2074 .init = tegra20_pmc_init,
1778 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity, 2075 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity,
2076 .reset_sources = tegra30_reset_sources,
2077 .num_reset_sources = 5,
2078 .reset_levels = NULL,
2079 .num_reset_levels = 0,
1779}; 2080};
1780 2081
1781static const char * const tegra114_powergates[] = { 2082static const char * const tegra114_powergates[] = {
@@ -1821,6 +2122,10 @@ static const struct tegra_pmc_soc tegra114_pmc_soc = {
1821 .regs = &tegra20_pmc_regs, 2122 .regs = &tegra20_pmc_regs,
1822 .init = tegra20_pmc_init, 2123 .init = tegra20_pmc_init,
1823 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity, 2124 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity,
2125 .reset_sources = tegra30_reset_sources,
2126 .num_reset_sources = 5,
2127 .reset_levels = NULL,
2128 .num_reset_levels = 0,
1824}; 2129};
1825 2130
1826static const char * const tegra124_powergates[] = { 2131static const char * const tegra124_powergates[] = {
@@ -1926,6 +2231,10 @@ static const struct tegra_pmc_soc tegra124_pmc_soc = {
1926 .regs = &tegra20_pmc_regs, 2231 .regs = &tegra20_pmc_regs,
1927 .init = tegra20_pmc_init, 2232 .init = tegra20_pmc_init,
1928 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity, 2233 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity,
2234 .reset_sources = tegra30_reset_sources,
2235 .num_reset_sources = 5,
2236 .reset_levels = NULL,
2237 .num_reset_levels = 0,
1929}; 2238};
1930 2239
1931static const char * const tegra210_powergates[] = { 2240static const char * const tegra210_powergates[] = {
@@ -2027,6 +2336,10 @@ static const struct tegra_pmc_soc tegra210_pmc_soc = {
2027 .regs = &tegra20_pmc_regs, 2336 .regs = &tegra20_pmc_regs,
2028 .init = tegra20_pmc_init, 2337 .init = tegra20_pmc_init,
2029 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity, 2338 .setup_irq_polarity = tegra20_pmc_setup_irq_polarity,
2339 .reset_sources = tegra30_reset_sources,
2340 .num_reset_sources = 5,
2341 .reset_levels = NULL,
2342 .num_reset_levels = 0,
2030}; 2343};
2031 2344
2032#define TEGRA186_IO_PAD_TABLE(_pad) \ 2345#define TEGRA186_IO_PAD_TABLE(_pad) \
@@ -2084,6 +2397,11 @@ static const struct tegra_pmc_regs tegra186_pmc_regs = {
2084 .dpd_status = 0x78, 2397 .dpd_status = 0x78,
2085 .dpd2_req = 0x7c, 2398 .dpd2_req = 0x7c,
2086 .dpd2_status = 0x80, 2399 .dpd2_status = 0x80,
2400 .rst_status = 0x70,
2401 .rst_source_shift = 0x2,
2402 .rst_source_mask = 0x3C,
2403 .rst_level_shift = 0x0,
2404 .rst_level_mask = 0x3,
2087}; 2405};
2088 2406
2089static void tegra186_pmc_setup_irq_polarity(struct tegra_pmc *pmc, 2407static void tegra186_pmc_setup_irq_polarity(struct tegra_pmc *pmc,
@@ -2121,6 +2439,11 @@ static void tegra186_pmc_setup_irq_polarity(struct tegra_pmc *pmc,
2121 iounmap(wake); 2439 iounmap(wake);
2122} 2440}
2123 2441
2442static const struct tegra_wake_event tegra186_wake_events[] = {
2443 TEGRA_WAKE_GPIO("power", 29, 1, TEGRA_AON_GPIO(FF, 0)),
2444 TEGRA_WAKE_IRQ("rtc", 73, 10),
2445};
2446
2124static const struct tegra_pmc_soc tegra186_pmc_soc = { 2447static const struct tegra_pmc_soc tegra186_pmc_soc = {
2125 .num_powergates = 0, 2448 .num_powergates = 0,
2126 .powergates = NULL, 2449 .powergates = NULL,
@@ -2136,10 +2459,87 @@ static const struct tegra_pmc_soc tegra186_pmc_soc = {
2136 .regs = &tegra186_pmc_regs, 2459 .regs = &tegra186_pmc_regs,
2137 .init = NULL, 2460 .init = NULL,
2138 .setup_irq_polarity = tegra186_pmc_setup_irq_polarity, 2461 .setup_irq_polarity = tegra186_pmc_setup_irq_polarity,
2462 .reset_sources = tegra186_reset_sources,
2463 .num_reset_sources = 14,
2464 .reset_levels = tegra186_reset_levels,
2465 .num_reset_levels = 3,
2466 .num_wake_events = ARRAY_SIZE(tegra186_wake_events),
2467 .wake_events = tegra186_wake_events,
2468};
2469
2470static const struct tegra_io_pad_soc tegra194_io_pads[] = {
2471 { .id = TEGRA_IO_PAD_CSIA, .dpd = 0, .voltage = UINT_MAX },
2472 { .id = TEGRA_IO_PAD_CSIB, .dpd = 1, .voltage = UINT_MAX },
2473 { .id = TEGRA_IO_PAD_MIPI_BIAS, .dpd = 3, .voltage = UINT_MAX },
2474 { .id = TEGRA_IO_PAD_PEX_CLK_BIAS, .dpd = 4, .voltage = UINT_MAX },
2475 { .id = TEGRA_IO_PAD_PEX_CLK3, .dpd = 5, .voltage = UINT_MAX },
2476 { .id = TEGRA_IO_PAD_PEX_CLK2, .dpd = 6, .voltage = UINT_MAX },
2477 { .id = TEGRA_IO_PAD_PEX_CLK1, .dpd = 7, .voltage = UINT_MAX },
2478 { .id = TEGRA_IO_PAD_EQOS, .dpd = 8, .voltage = UINT_MAX },
2479 { .id = TEGRA_IO_PAD_PEX_CLK2_BIAS, .dpd = 9, .voltage = UINT_MAX },
2480 { .id = TEGRA_IO_PAD_PEX_CLK2, .dpd = 10, .voltage = UINT_MAX },
2481 { .id = TEGRA_IO_PAD_DAP3, .dpd = 11, .voltage = UINT_MAX },
2482 { .id = TEGRA_IO_PAD_DAP5, .dpd = 12, .voltage = UINT_MAX },
2483 { .id = TEGRA_IO_PAD_UART, .dpd = 14, .voltage = UINT_MAX },
2484 { .id = TEGRA_IO_PAD_PWR_CTL, .dpd = 15, .voltage = UINT_MAX },
2485 { .id = TEGRA_IO_PAD_SOC_GPIO53, .dpd = 16, .voltage = UINT_MAX },
2486 { .id = TEGRA_IO_PAD_AUDIO, .dpd = 17, .voltage = UINT_MAX },
2487 { .id = TEGRA_IO_PAD_GP_PWM2, .dpd = 18, .voltage = UINT_MAX },
2488 { .id = TEGRA_IO_PAD_GP_PWM3, .dpd = 19, .voltage = UINT_MAX },
2489 { .id = TEGRA_IO_PAD_SOC_GPIO12, .dpd = 20, .voltage = UINT_MAX },
2490 { .id = TEGRA_IO_PAD_SOC_GPIO13, .dpd = 21, .voltage = UINT_MAX },
2491 { .id = TEGRA_IO_PAD_SOC_GPIO10, .dpd = 22, .voltage = UINT_MAX },
2492 { .id = TEGRA_IO_PAD_UART4, .dpd = 23, .voltage = UINT_MAX },
2493 { .id = TEGRA_IO_PAD_UART5, .dpd = 24, .voltage = UINT_MAX },
2494 { .id = TEGRA_IO_PAD_DBG, .dpd = 25, .voltage = UINT_MAX },
2495 { .id = TEGRA_IO_PAD_HDMI_DP3, .dpd = 26, .voltage = UINT_MAX },
2496 { .id = TEGRA_IO_PAD_HDMI_DP2, .dpd = 27, .voltage = UINT_MAX },
2497 { .id = TEGRA_IO_PAD_HDMI_DP0, .dpd = 28, .voltage = UINT_MAX },
2498 { .id = TEGRA_IO_PAD_HDMI_DP1, .dpd = 29, .voltage = UINT_MAX },
2499 { .id = TEGRA_IO_PAD_PEX_CNTRL, .dpd = 32, .voltage = UINT_MAX },
2500 { .id = TEGRA_IO_PAD_PEX_CTL2, .dpd = 33, .voltage = UINT_MAX },
2501 { .id = TEGRA_IO_PAD_PEX_L0_RST_N, .dpd = 34, .voltage = UINT_MAX },
2502 { .id = TEGRA_IO_PAD_PEX_L1_RST_N, .dpd = 35, .voltage = UINT_MAX },
2503 { .id = TEGRA_IO_PAD_SDMMC4, .dpd = 36, .voltage = UINT_MAX },
2504 { .id = TEGRA_IO_PAD_PEX_L5_RST_N, .dpd = 37, .voltage = UINT_MAX },
2505 { .id = TEGRA_IO_PAD_CSIC, .dpd = 43, .voltage = UINT_MAX },
2506 { .id = TEGRA_IO_PAD_CSID, .dpd = 44, .voltage = UINT_MAX },
2507 { .id = TEGRA_IO_PAD_CSIE, .dpd = 45, .voltage = UINT_MAX },
2508 { .id = TEGRA_IO_PAD_CSIF, .dpd = 46, .voltage = UINT_MAX },
2509 { .id = TEGRA_IO_PAD_SPI, .dpd = 47, .voltage = UINT_MAX },
2510 { .id = TEGRA_IO_PAD_UFS, .dpd = 49, .voltage = UINT_MAX },
2511 { .id = TEGRA_IO_PAD_CSIG, .dpd = 50, .voltage = UINT_MAX },
2512 { .id = TEGRA_IO_PAD_CSIH, .dpd = 51, .voltage = UINT_MAX },
2513 { .id = TEGRA_IO_PAD_EDP, .dpd = 53, .voltage = UINT_MAX },
2514 { .id = TEGRA_IO_PAD_SDMMC1_HV, .dpd = 55, .voltage = UINT_MAX },
2515 { .id = TEGRA_IO_PAD_SDMMC3_HV, .dpd = 56, .voltage = UINT_MAX },
2516 { .id = TEGRA_IO_PAD_CONN, .dpd = 60, .voltage = UINT_MAX },
2517 { .id = TEGRA_IO_PAD_AUDIO_HV, .dpd = 61, .voltage = UINT_MAX },
2518};
2519
2520static const struct tegra_wake_event tegra194_wake_events[] = {
2521 TEGRA_WAKE_GPIO("power", 29, 1, TEGRA194_AON_GPIO(EE, 4)),
2522 TEGRA_WAKE_IRQ("rtc", 73, 10),
2523};
2524
2525static const struct tegra_pmc_soc tegra194_pmc_soc = {
2526 .num_powergates = 0,
2527 .powergates = NULL,
2528 .num_cpu_powergates = 0,
2529 .cpu_powergates = NULL,
2530 .has_tsense_reset = false,
2531 .has_gpu_clamps = false,
2532 .num_io_pads = ARRAY_SIZE(tegra194_io_pads),
2533 .io_pads = tegra194_io_pads,
2534 .regs = &tegra186_pmc_regs,
2535 .init = NULL,
2536 .setup_irq_polarity = tegra186_pmc_setup_irq_polarity,
2537 .num_wake_events = ARRAY_SIZE(tegra194_wake_events),
2538 .wake_events = tegra194_wake_events,
2139}; 2539};
2140 2540
2141static const struct of_device_id tegra_pmc_match[] = { 2541static const struct of_device_id tegra_pmc_match[] = {
2142 { .compatible = "nvidia,tegra194-pmc", .data = &tegra186_pmc_soc }, 2542 { .compatible = "nvidia,tegra194-pmc", .data = &tegra194_pmc_soc },
2143 { .compatible = "nvidia,tegra186-pmc", .data = &tegra186_pmc_soc }, 2543 { .compatible = "nvidia,tegra186-pmc", .data = &tegra186_pmc_soc },
2144 { .compatible = "nvidia,tegra210-pmc", .data = &tegra210_pmc_soc }, 2544 { .compatible = "nvidia,tegra210-pmc", .data = &tegra210_pmc_soc },
2145 { .compatible = "nvidia,tegra132-pmc", .data = &tegra124_pmc_soc }, 2545 { .compatible = "nvidia,tegra132-pmc", .data = &tegra124_pmc_soc },
diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h
index 9b6ea0c72117..8fb2f8a87339 100644
--- a/include/soc/tegra/fuse.h
+++ b/include/soc/tegra/fuse.h
@@ -60,7 +60,6 @@ struct tegra_sku_info {
60 60
61u32 tegra_read_straps(void); 61u32 tegra_read_straps(void);
62u32 tegra_read_ram_code(void); 62u32 tegra_read_ram_code(void);
63u32 tegra_read_chipid(void);
64int tegra_fuse_readl(unsigned long offset, u32 *value); 63int tegra_fuse_readl(unsigned long offset, u32 *value);
65 64
66extern struct tegra_sku_info tegra_sku_info; 65extern struct tegra_sku_info tegra_sku_info;
diff --git a/include/soc/tegra/pmc.h b/include/soc/tegra/pmc.h
index 562426812ab2..fd816f6aa9cc 100644
--- a/include/soc/tegra/pmc.h
+++ b/include/soc/tegra/pmc.h
@@ -90,6 +90,10 @@ enum tegra_io_pad {
90 TEGRA_IO_PAD_CSID, 90 TEGRA_IO_PAD_CSID,
91 TEGRA_IO_PAD_CSIE, 91 TEGRA_IO_PAD_CSIE,
92 TEGRA_IO_PAD_CSIF, 92 TEGRA_IO_PAD_CSIF,
93 TEGRA_IO_PAD_CSIG,
94 TEGRA_IO_PAD_CSIH,
95 TEGRA_IO_PAD_DAP3,
96 TEGRA_IO_PAD_DAP5,
93 TEGRA_IO_PAD_DBG, 97 TEGRA_IO_PAD_DBG,
94 TEGRA_IO_PAD_DEBUG_NONAO, 98 TEGRA_IO_PAD_DEBUG_NONAO,
95 TEGRA_IO_PAD_DMIC, 99 TEGRA_IO_PAD_DMIC,
@@ -102,10 +106,15 @@ enum tegra_io_pad {
102 TEGRA_IO_PAD_EDP, 106 TEGRA_IO_PAD_EDP,
103 TEGRA_IO_PAD_EMMC, 107 TEGRA_IO_PAD_EMMC,
104 TEGRA_IO_PAD_EMMC2, 108 TEGRA_IO_PAD_EMMC2,
109 TEGRA_IO_PAD_EQOS,
105 TEGRA_IO_PAD_GPIO, 110 TEGRA_IO_PAD_GPIO,
111 TEGRA_IO_PAD_GP_PWM2,
112 TEGRA_IO_PAD_GP_PWM3,
106 TEGRA_IO_PAD_HDMI, 113 TEGRA_IO_PAD_HDMI,
107 TEGRA_IO_PAD_HDMI_DP0, 114 TEGRA_IO_PAD_HDMI_DP0,
108 TEGRA_IO_PAD_HDMI_DP1, 115 TEGRA_IO_PAD_HDMI_DP1,
116 TEGRA_IO_PAD_HDMI_DP2,
117 TEGRA_IO_PAD_HDMI_DP3,
109 TEGRA_IO_PAD_HSIC, 118 TEGRA_IO_PAD_HSIC,
110 TEGRA_IO_PAD_HV, 119 TEGRA_IO_PAD_HV,
111 TEGRA_IO_PAD_LVDS, 120 TEGRA_IO_PAD_LVDS,
@@ -115,8 +124,14 @@ enum tegra_io_pad {
115 TEGRA_IO_PAD_PEX_CLK_BIAS, 124 TEGRA_IO_PAD_PEX_CLK_BIAS,
116 TEGRA_IO_PAD_PEX_CLK1, 125 TEGRA_IO_PAD_PEX_CLK1,
117 TEGRA_IO_PAD_PEX_CLK2, 126 TEGRA_IO_PAD_PEX_CLK2,
127 TEGRA_IO_PAD_PEX_CLK2_BIAS,
118 TEGRA_IO_PAD_PEX_CLK3, 128 TEGRA_IO_PAD_PEX_CLK3,
119 TEGRA_IO_PAD_PEX_CNTRL, 129 TEGRA_IO_PAD_PEX_CNTRL,
130 TEGRA_IO_PAD_PEX_CTL2,
131 TEGRA_IO_PAD_PEX_L0_RST_N,
132 TEGRA_IO_PAD_PEX_L1_RST_N,
133 TEGRA_IO_PAD_PEX_L5_RST_N,
134 TEGRA_IO_PAD_PWR_CTL,
120 TEGRA_IO_PAD_SDMMC1, 135 TEGRA_IO_PAD_SDMMC1,
121 TEGRA_IO_PAD_SDMMC1_HV, 136 TEGRA_IO_PAD_SDMMC1_HV,
122 TEGRA_IO_PAD_SDMMC2, 137 TEGRA_IO_PAD_SDMMC2,
@@ -124,10 +139,16 @@ enum tegra_io_pad {
124 TEGRA_IO_PAD_SDMMC3, 139 TEGRA_IO_PAD_SDMMC3,
125 TEGRA_IO_PAD_SDMMC3_HV, 140 TEGRA_IO_PAD_SDMMC3_HV,
126 TEGRA_IO_PAD_SDMMC4, 141 TEGRA_IO_PAD_SDMMC4,
142 TEGRA_IO_PAD_SOC_GPIO10,
143 TEGRA_IO_PAD_SOC_GPIO12,
144 TEGRA_IO_PAD_SOC_GPIO13,
145 TEGRA_IO_PAD_SOC_GPIO53,
127 TEGRA_IO_PAD_SPI, 146 TEGRA_IO_PAD_SPI,
128 TEGRA_IO_PAD_SPI_HV, 147 TEGRA_IO_PAD_SPI_HV,
129 TEGRA_IO_PAD_SYS_DDC, 148 TEGRA_IO_PAD_SYS_DDC,
130 TEGRA_IO_PAD_UART, 149 TEGRA_IO_PAD_UART,
150 TEGRA_IO_PAD_UART4,
151 TEGRA_IO_PAD_UART5,
131 TEGRA_IO_PAD_UFS, 152 TEGRA_IO_PAD_UFS,
132 TEGRA_IO_PAD_USB0, 153 TEGRA_IO_PAD_USB0,
133 TEGRA_IO_PAD_USB1, 154 TEGRA_IO_PAD_USB1,