diff options
| author | Kevin Hilman <khilman@linaro.org> | 2013-08-21 13:16:55 -0400 |
|---|---|---|
| committer | Kevin Hilman <khilman@linaro.org> | 2013-08-21 13:17:18 -0400 |
| commit | bfa664f21b0357f2ad9cdf519f594ece36ec8f64 (patch) | |
| tree | f377028eba58633d917d65c1141977b2e8ca9529 | |
| parent | 5515d9981f5f30e82d096921f86ba016911c9ea8 (diff) | |
| parent | b4f173752a56187bd55752b0474429202f2ab1d3 (diff) | |
Merge tag 'tegra-for-3.12-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra into next/soc
From: Stephen Warren:
ARM: tegra: core SoC enhancements for 3.12
This branch includes a number of enhancements to core SoC support for
Tegra devices. The major new features are:
* Adds a new CPU-power-gated cpuidle state for Tegra114.
* Adds initial system suspend support for Tegra114, initially supporting
just CPU-power-gating during suspend.
* Adds "LP1" suspend mode support for all of Tegra20/30/114. This mode
both gates CPU power, and places the DRAM into self-refresh mode.
* A new DT-driven PCIe driver to Tegra20/30. The driver is also moved
from arch/arm/mach-tegra/ to drivers/pci/host/.
The PCIe driver work depends on the following tag from Thomas Petazzoni:
git://git.infradead.org/linux-mvebu.git mis-3.12.2
... which is merged into the middle of this pull request.
* tag 'tegra-for-3.12-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra: (33 commits)
ARM: tegra: disable LP2 cpuidle state if PCIe is enabled
MAINTAINERS: Add myself as Tegra PCIe maintainer
PCI: tegra: set up PADS_REFCLK_CFG1
PCI: tegra: Add Tegra 30 PCIe support
PCI: tegra: Move PCIe driver to drivers/pci/host
PCI: msi: add default MSI operations for !HAVE_GENERIC_HARDIRQS platforms
ARM: tegra: add LP1 suspend support for Tegra114
ARM: tegra: add LP1 suspend support for Tegra20
ARM: tegra: add LP1 suspend support for Tegra30
ARM: tegra: add common LP1 suspend support
clk: tegra114: add LP1 suspend/resume support
ARM: tegra: config the polarity of the request of sys clock
ARM: tegra: add common resume handling code for LP1 resuming
ARM: pci: add ->add_bus() and ->remove_bus() hooks to hw_pci
of: pci: add registry of MSI chips
PCI: Introduce new MSI chip infrastructure
PCI: remove ARCH_SUPPORTS_MSI kconfig option
PCI: use weak functions for MSI arch-specific functions
ARM: tegra: unify Tegra's Kconfig a bit more
ARM: tegra: remove the limitation that Tegra114 can't support suspend
...
Signed-off-by: Kevin Hilman <khilman@linaro.org>
60 files changed, 3521 insertions, 1150 deletions
diff --git a/Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt b/Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt new file mode 100644 index 000000000000..6b7510775c50 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt | |||
| @@ -0,0 +1,163 @@ | |||
| 1 | NVIDIA Tegra PCIe controller | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible: "nvidia,tegra20-pcie" or "nvidia,tegra30-pcie" | ||
| 5 | - device_type: Must be "pci" | ||
| 6 | - reg: A list of physical base address and length for each set of controller | ||
| 7 | registers. Must contain an entry for each entry in the reg-names property. | ||
| 8 | - reg-names: Must include the following entries: | ||
| 9 | "pads": PADS registers | ||
| 10 | "afi": AFI registers | ||
| 11 | "cs": configuration space region | ||
| 12 | - interrupts: A list of interrupt outputs of the controller. Must contain an | ||
| 13 | entry for each entry in the interrupt-names property. | ||
| 14 | - interrupt-names: Must include the following entries: | ||
| 15 | "intr": The Tegra interrupt that is asserted for controller interrupts | ||
| 16 | "msi": The Tegra interrupt that is asserted when an MSI is received | ||
| 17 | - pex-clk-supply: Supply voltage for internal reference clock | ||
| 18 | - vdd-supply: Power supply for controller (1.05V) | ||
| 19 | - avdd-supply: Power supply for controller (1.05V) (not required for Tegra20) | ||
| 20 | - bus-range: Range of bus numbers associated with this controller | ||
| 21 | - #address-cells: Address representation for root ports (must be 3) | ||
| 22 | - cell 0 specifies the bus and device numbers of the root port: | ||
| 23 | [23:16]: bus number | ||
| 24 | [15:11]: device number | ||
| 25 | - cell 1 denotes the upper 32 address bits and should be 0 | ||
| 26 | - cell 2 contains the lower 32 address bits and is used to translate to the | ||
| 27 | CPU address space | ||
| 28 | - #size-cells: Size representation for root ports (must be 2) | ||
| 29 | - ranges: Describes the translation of addresses for root ports and standard | ||
| 30 | PCI regions. The entries must be 6 cells each, where the first three cells | ||
| 31 | correspond to the address as described for the #address-cells property | ||
| 32 | above, the fourth cell is the physical CPU address to translate to and the | ||
| 33 | fifth and six cells are as described for the #size-cells property above. | ||
| 34 | - The first two entries are expected to translate the addresses for the root | ||
| 35 | port registers, which are referenced by the assigned-addresses property of | ||
| 36 | the root port nodes (see below). | ||
| 37 | - The remaining entries setup the mapping for the standard I/O, memory and | ||
| 38 | prefetchable PCI regions. The first cell determines the type of region | ||
| 39 | that is setup: | ||
| 40 | - 0x81000000: I/O memory region | ||
| 41 | - 0x82000000: non-prefetchable memory region | ||
| 42 | - 0xc2000000: prefetchable memory region | ||
| 43 | Please refer to the standard PCI bus binding document for a more detailed | ||
| 44 | explanation. | ||
| 45 | - clocks: List of clock inputs of the controller. Must contain an entry for | ||
| 46 | each entry in the clock-names property. | ||
| 47 | - clock-names: Must include the following entries: | ||
| 48 | "pex": The Tegra clock of that name | ||
| 49 | "afi": The Tegra clock of that name | ||
| 50 | "pcie_xclk": The Tegra clock of that name | ||
| 51 | "pll_e": The Tegra clock of that name | ||
| 52 | "cml": The Tegra clock of that name (not required for Tegra20) | ||
| 53 | |||
| 54 | Root ports are defined as subnodes of the PCIe controller node. | ||
| 55 | |||
| 56 | Required properties: | ||
| 57 | - device_type: Must be "pci" | ||
| 58 | - assigned-addresses: Address and size of the port configuration registers | ||
| 59 | - reg: PCI bus address of the root port | ||
| 60 | - #address-cells: Must be 3 | ||
| 61 | - #size-cells: Must be 2 | ||
| 62 | - ranges: Sub-ranges distributed from the PCIe controller node. An empty | ||
| 63 | property is sufficient. | ||
| 64 | - nvidia,num-lanes: Number of lanes to use for this port. Valid combinations | ||
| 65 | are: | ||
| 66 | - Root port 0 uses 4 lanes, root port 1 is unused. | ||
| 67 | - Both root ports use 2 lanes. | ||
| 68 | |||
| 69 | Example: | ||
| 70 | |||
| 71 | SoC DTSI: | ||
| 72 | |||
| 73 | pcie-controller { | ||
| 74 | compatible = "nvidia,tegra20-pcie"; | ||
| 75 | device_type = "pci"; | ||
| 76 | reg = <0x80003000 0x00000800 /* PADS registers */ | ||
| 77 | 0x80003800 0x00000200 /* AFI registers */ | ||
| 78 | 0x90000000 0x10000000>; /* configuration space */ | ||
| 79 | reg-names = "pads", "afi", "cs"; | ||
| 80 | interrupts = <0 98 0x04 /* controller interrupt */ | ||
| 81 | 0 99 0x04>; /* MSI interrupt */ | ||
| 82 | interrupt-names = "intr", "msi"; | ||
| 83 | |||
| 84 | bus-range = <0x00 0xff>; | ||
| 85 | #address-cells = <3>; | ||
| 86 | #size-cells = <2>; | ||
| 87 | |||
| 88 | ranges = <0x82000000 0 0x80000000 0x80000000 0 0x00001000 /* port 0 registers */ | ||
| 89 | 0x82000000 0 0x80001000 0x80001000 0 0x00001000 /* port 1 registers */ | ||
| 90 | 0x81000000 0 0 0x82000000 0 0x00010000 /* downstream I/O */ | ||
| 91 | 0x82000000 0 0xa0000000 0xa0000000 0 0x10000000 /* non-prefetchable memory */ | ||
| 92 | 0xc2000000 0 0xb0000000 0xb0000000 0 0x10000000>; /* prefetchable memory */ | ||
| 93 | |||
| 94 | clocks = <&tegra_car 70>, <&tegra_car 72>, <&tegra_car 74>, | ||
| 95 | <&tegra_car 118>; | ||
| 96 | clock-names = "pex", "afi", "pcie_xclk", "pll_e"; | ||
| 97 | status = "disabled"; | ||
| 98 | |||
| 99 | pci@1,0 { | ||
| 100 | device_type = "pci"; | ||
| 101 | assigned-addresses = <0x82000800 0 0x80000000 0 0x1000>; | ||
| 102 | reg = <0x000800 0 0 0 0>; | ||
| 103 | status = "disabled"; | ||
| 104 | |||
| 105 | #address-cells = <3>; | ||
| 106 | #size-cells = <2>; | ||
| 107 | |||
| 108 | ranges; | ||
| 109 | |||
| 110 | nvidia,num-lanes = <2>; | ||
| 111 | }; | ||
| 112 | |||
| 113 | pci@2,0 { | ||
| 114 | device_type = "pci"; | ||
| 115 | assigned-addresses = <0x82001000 0 0x80001000 0 0x1000>; | ||
| 116 | reg = <0x001000 0 0 0 0>; | ||
| 117 | status = "disabled"; | ||
| 118 | |||
| 119 | #address-cells = <3>; | ||
| 120 | #size-cells = <2>; | ||
| 121 | |||
| 122 | ranges; | ||
| 123 | |||
| 124 | nvidia,num-lanes = <2>; | ||
| 125 | }; | ||
| 126 | }; | ||
| 127 | |||
| 128 | |||
| 129 | Board DTS: | ||
| 130 | |||
| 131 | pcie-controller { | ||
| 132 | status = "okay"; | ||
| 133 | |||
| 134 | vdd-supply = <&pci_vdd_reg>; | ||
| 135 | pex-clk-supply = <&pci_clk_reg>; | ||
| 136 | |||
| 137 | /* root port 00:01.0 */ | ||
| 138 | pci@1,0 { | ||
| 139 | status = "okay"; | ||
| 140 | |||
| 141 | /* bridge 01:00.0 (optional) */ | ||
| 142 | pci@0,0 { | ||
| 143 | reg = <0x010000 0 0 0 0>; | ||
| 144 | |||
| 145 | #address-cells = <3>; | ||
| 146 | #size-cells = <2>; | ||
| 147 | |||
| 148 | device_type = "pci"; | ||
| 149 | |||
| 150 | /* endpoint 02:00.0 */ | ||
| 151 | pci@0,0 { | ||
| 152 | reg = <0x020000 0 0 0 0>; | ||
| 153 | }; | ||
| 154 | }; | ||
| 155 | }; | ||
| 156 | }; | ||
| 157 | |||
| 158 | Note that devices on the PCI bus are dynamically discovered using PCI's bus | ||
| 159 | enumeration and therefore don't need corresponding device nodes in DT. However | ||
| 160 | if a device on the PCI bus provides a non-probeable bus such as I2C or SPI, | ||
| 161 | device nodes need to be added in order to allow the bus' children to be | ||
| 162 | instantiated at the proper location in the operating system's device tree (as | ||
| 163 | illustrated by the optional nodes in the example above). | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 7cacc88dc79c..8a261b59d64a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -6275,6 +6275,13 @@ F: Documentation/PCI/ | |||
| 6275 | F: drivers/pci/ | 6275 | F: drivers/pci/ |
| 6276 | F: include/linux/pci* | 6276 | F: include/linux/pci* |
| 6277 | 6277 | ||
| 6278 | PCI DRIVER FOR NVIDIA TEGRA | ||
| 6279 | M: Thierry Reding <thierry.reding@gmail.com> | ||
| 6280 | L: linux-tegra@vger.kernel.org | ||
| 6281 | S: Supported | ||
| 6282 | F: Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt | ||
| 6283 | F: drivers/pci/host/pci-tegra.c | ||
| 6284 | |||
| 6278 | PCMCIA SUBSYSTEM | 6285 | PCMCIA SUBSYSTEM |
| 6279 | P: Linux PCMCIA Team | 6286 | P: Linux PCMCIA Team |
| 6280 | L: linux-pcmcia@lists.infradead.org | 6287 | L: linux-pcmcia@lists.infradead.org |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 50eada8260a9..a3267d795c77 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -441,7 +441,6 @@ config ARCH_NETX | |||
| 441 | config ARCH_IOP13XX | 441 | config ARCH_IOP13XX |
| 442 | bool "IOP13xx-based" | 442 | bool "IOP13xx-based" |
| 443 | depends on MMU | 443 | depends on MMU |
| 444 | select ARCH_SUPPORTS_MSI | ||
| 445 | select CPU_XSC3 | 444 | select CPU_XSC3 |
| 446 | select NEED_MACH_MEMORY_H | 445 | select NEED_MACH_MEMORY_H |
| 447 | select NEED_RET_TO_USER | 446 | select NEED_RET_TO_USER |
diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h index a1c90d7feb0e..454d642a4070 100644 --- a/arch/arm/include/asm/mach/pci.h +++ b/arch/arm/include/asm/mach/pci.h | |||
| @@ -36,6 +36,8 @@ struct hw_pci { | |||
| 36 | resource_size_t start, | 36 | resource_size_t start, |
| 37 | resource_size_t size, | 37 | resource_size_t size, |
| 38 | resource_size_t align); | 38 | resource_size_t align); |
| 39 | void (*add_bus)(struct pci_bus *bus); | ||
| 40 | void (*remove_bus)(struct pci_bus *bus); | ||
| 39 | }; | 41 | }; |
| 40 | 42 | ||
| 41 | /* | 43 | /* |
| @@ -63,6 +65,8 @@ struct pci_sys_data { | |||
| 63 | resource_size_t start, | 65 | resource_size_t start, |
| 64 | resource_size_t size, | 66 | resource_size_t size, |
| 65 | resource_size_t align); | 67 | resource_size_t align); |
| 68 | void (*add_bus)(struct pci_bus *bus); | ||
| 69 | void (*remove_bus)(struct pci_bus *bus); | ||
| 66 | void *private_data; /* platform controller private data */ | 70 | void *private_data; /* platform controller private data */ |
| 67 | }; | 71 | }; |
| 68 | 72 | ||
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 261fcc826169..1ec9c8701c26 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c | |||
| @@ -363,6 +363,20 @@ void pcibios_fixup_bus(struct pci_bus *bus) | |||
| 363 | } | 363 | } |
| 364 | EXPORT_SYMBOL(pcibios_fixup_bus); | 364 | EXPORT_SYMBOL(pcibios_fixup_bus); |
| 365 | 365 | ||
| 366 | void pcibios_add_bus(struct pci_bus *bus) | ||
| 367 | { | ||
| 368 | struct pci_sys_data *sys = bus->sysdata; | ||
| 369 | if (sys->add_bus) | ||
| 370 | sys->add_bus(bus); | ||
| 371 | } | ||
| 372 | |||
| 373 | void pcibios_remove_bus(struct pci_bus *bus) | ||
| 374 | { | ||
| 375 | struct pci_sys_data *sys = bus->sysdata; | ||
| 376 | if (sys->remove_bus) | ||
| 377 | sys->remove_bus(bus); | ||
| 378 | } | ||
| 379 | |||
| 366 | /* | 380 | /* |
| 367 | * Swizzle the device pin each time we cross a bridge. If a platform does | 381 | * Swizzle the device pin each time we cross a bridge. If a platform does |
| 368 | * not provide a swizzle function, we perform the standard PCI swizzling. | 382 | * not provide a swizzle function, we perform the standard PCI swizzling. |
| @@ -464,6 +478,8 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, | |||
| 464 | sys->swizzle = hw->swizzle; | 478 | sys->swizzle = hw->swizzle; |
| 465 | sys->map_irq = hw->map_irq; | 479 | sys->map_irq = hw->map_irq; |
| 466 | sys->align_resource = hw->align_resource; | 480 | sys->align_resource = hw->align_resource; |
| 481 | sys->add_bus = hw->add_bus; | ||
| 482 | sys->remove_bus = hw->remove_bus; | ||
| 467 | INIT_LIST_HEAD(&sys->resources); | 483 | INIT_LIST_HEAD(&sys->resources); |
| 468 | 484 | ||
| 469 | if (hw->private_data) | 485 | if (hw->private_data) |
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig index ef3a8da49b2d..def056493260 100644 --- a/arch/arm/mach-tegra/Kconfig +++ b/arch/arm/mach-tegra/Kconfig | |||
| @@ -2,19 +2,27 @@ config ARCH_TEGRA | |||
| 2 | bool "NVIDIA Tegra" if ARCH_MULTI_V7 | 2 | bool "NVIDIA Tegra" if ARCH_MULTI_V7 |
| 3 | select ARCH_HAS_CPUFREQ | 3 | select ARCH_HAS_CPUFREQ |
| 4 | select ARCH_REQUIRE_GPIOLIB | 4 | select ARCH_REQUIRE_GPIOLIB |
| 5 | select ARM_GIC | ||
| 5 | select CLKDEV_LOOKUP | 6 | select CLKDEV_LOOKUP |
| 6 | select CLKSRC_MMIO | 7 | select CLKSRC_MMIO |
| 7 | select CLKSRC_OF | 8 | select CLKSRC_OF |
| 8 | select COMMON_CLK | 9 | select COMMON_CLK |
| 10 | select CPU_V7 | ||
| 9 | select GENERIC_CLOCKEVENTS | 11 | select GENERIC_CLOCKEVENTS |
| 10 | select HAVE_ARM_SCU if SMP | 12 | select HAVE_ARM_SCU if SMP |
| 11 | select HAVE_ARM_TWD if LOCAL_TIMERS | 13 | select HAVE_ARM_TWD if LOCAL_TIMERS |
| 12 | select HAVE_CLK | 14 | select HAVE_CLK |
| 13 | select HAVE_SMP | 15 | select HAVE_SMP |
| 14 | select MIGHT_HAVE_CACHE_L2X0 | 16 | select MIGHT_HAVE_CACHE_L2X0 |
| 17 | select PINCTRL | ||
| 15 | select SOC_BUS | 18 | select SOC_BUS |
| 16 | select SPARSE_IRQ | 19 | select SPARSE_IRQ |
| 20 | select USB_ARCH_HAS_EHCI if USB_SUPPORT | ||
| 21 | select USB_ULPI if USB_PHY | ||
| 22 | select USB_ULPI_VIEWPORT if USB_PHY | ||
| 17 | select USE_OF | 23 | select USE_OF |
| 24 | select MIGHT_HAVE_PCI | ||
| 25 | select ARCH_SUPPORTS_MSI | ||
| 18 | help | 26 | help |
| 19 | This enables support for NVIDIA Tegra based systems. | 27 | This enables support for NVIDIA Tegra based systems. |
| 20 | 28 | ||
| @@ -27,15 +35,9 @@ config ARCH_TEGRA_2x_SOC | |||
| 27 | select ARM_ERRATA_720789 | 35 | select ARM_ERRATA_720789 |
| 28 | select ARM_ERRATA_754327 if SMP | 36 | select ARM_ERRATA_754327 if SMP |
| 29 | select ARM_ERRATA_764369 if SMP | 37 | select ARM_ERRATA_764369 if SMP |
| 30 | select ARM_GIC | ||
| 31 | select CPU_V7 | ||
| 32 | select PINCTRL | ||
| 33 | select PINCTRL_TEGRA20 | 38 | select PINCTRL_TEGRA20 |
| 34 | select PL310_ERRATA_727915 if CACHE_L2X0 | 39 | select PL310_ERRATA_727915 if CACHE_L2X0 |
| 35 | select PL310_ERRATA_769419 if CACHE_L2X0 | 40 | select PL310_ERRATA_769419 if CACHE_L2X0 |
| 36 | select USB_ARCH_HAS_EHCI if USB_SUPPORT | ||
| 37 | select USB_ULPI if USB_PHY | ||
| 38 | select USB_ULPI_VIEWPORT if USB_PHY | ||
| 39 | help | 41 | help |
| 40 | Support for NVIDIA Tegra AP20 and T20 processors, based on the | 42 | Support for NVIDIA Tegra AP20 and T20 processors, based on the |
| 41 | ARM CortexA9MP CPU and the ARM PL310 L2 cache controller | 43 | ARM CortexA9MP CPU and the ARM PL310 L2 cache controller |
| @@ -44,14 +46,8 @@ config ARCH_TEGRA_3x_SOC | |||
| 44 | bool "Enable support for Tegra30 family" | 46 | bool "Enable support for Tegra30 family" |
| 45 | select ARM_ERRATA_754322 | 47 | select ARM_ERRATA_754322 |
| 46 | select ARM_ERRATA_764369 if SMP | 48 | select ARM_ERRATA_764369 if SMP |
| 47 | select ARM_GIC | ||
| 48 | select CPU_V7 | ||
| 49 | select PINCTRL | ||
| 50 | select PINCTRL_TEGRA30 | 49 | select PINCTRL_TEGRA30 |
| 51 | select PL310_ERRATA_769419 if CACHE_L2X0 | 50 | select PL310_ERRATA_769419 if CACHE_L2X0 |
| 52 | select USB_ARCH_HAS_EHCI if USB_SUPPORT | ||
| 53 | select USB_ULPI if USB_PHY | ||
| 54 | select USB_ULPI_VIEWPORT if USB_PHY | ||
| 55 | help | 51 | help |
| 56 | Support for NVIDIA Tegra T30 processor family, based on the | 52 | Support for NVIDIA Tegra T30 processor family, based on the |
| 57 | ARM CortexA9MP CPU and the ARM PL310 L2 cache controller | 53 | ARM CortexA9MP CPU and the ARM PL310 L2 cache controller |
| @@ -59,20 +55,13 @@ config ARCH_TEGRA_3x_SOC | |||
| 59 | config ARCH_TEGRA_114_SOC | 55 | config ARCH_TEGRA_114_SOC |
| 60 | bool "Enable support for Tegra114 family" | 56 | bool "Enable support for Tegra114 family" |
| 61 | select HAVE_ARM_ARCH_TIMER | 57 | select HAVE_ARM_ARCH_TIMER |
| 62 | select ARM_GIC | 58 | select ARM_ERRATA_798181 |
| 63 | select ARM_L1_CACHE_SHIFT_6 | 59 | select ARM_L1_CACHE_SHIFT_6 |
| 64 | select CPU_V7 | ||
| 65 | select PINCTRL | ||
| 66 | select PINCTRL_TEGRA114 | 60 | select PINCTRL_TEGRA114 |
| 67 | help | 61 | help |
| 68 | Support for NVIDIA Tegra T114 processor family, based on the | 62 | Support for NVIDIA Tegra T114 processor family, based on the |
| 69 | ARM CortexA15MP CPU | 63 | ARM CortexA15MP CPU |
| 70 | 64 | ||
| 71 | config TEGRA_PCI | ||
| 72 | bool "PCI Express support" | ||
| 73 | depends on ARCH_TEGRA_2x_SOC | ||
| 74 | select PCI | ||
| 75 | |||
| 76 | config TEGRA_AHB | 65 | config TEGRA_AHB |
| 77 | bool "Enable AHB driver for NVIDIA Tegra SoCs" | 66 | bool "Enable AHB driver for NVIDIA Tegra SoCs" |
| 78 | default y | 67 | default y |
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile index 98b184efc110..e7e5f45c6558 100644 --- a/arch/arm/mach-tegra/Makefile +++ b/arch/arm/mach-tegra/Makefile | |||
| @@ -17,24 +17,24 @@ obj-$(CONFIG_CPU_IDLE) += cpuidle.o | |||
| 17 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20_speedo.o | 17 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20_speedo.o |
| 18 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o | 18 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o |
| 19 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += sleep-tegra20.o | 19 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += sleep-tegra20.o |
| 20 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += pm-tegra20.o | ||
| 20 | ifeq ($(CONFIG_CPU_IDLE),y) | 21 | ifeq ($(CONFIG_CPU_IDLE),y) |
| 21 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += cpuidle-tegra20.o | 22 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += cpuidle-tegra20.o |
| 22 | endif | 23 | endif |
| 23 | obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra30_speedo.o | 24 | obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra30_speedo.o |
| 24 | obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += sleep-tegra30.o | 25 | obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += sleep-tegra30.o |
| 26 | obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += pm-tegra30.o | ||
| 25 | ifeq ($(CONFIG_CPU_IDLE),y) | 27 | ifeq ($(CONFIG_CPU_IDLE),y) |
| 26 | obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += cpuidle-tegra30.o | 28 | obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += cpuidle-tegra30.o |
| 27 | endif | 29 | endif |
| 28 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o | 30 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o |
| 29 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o | 31 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o |
| 30 | obj-$(CONFIG_TEGRA_PCI) += pcie.o | ||
| 31 | 32 | ||
| 32 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += tegra114_speedo.o | 33 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += tegra114_speedo.o |
| 33 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += sleep-tegra30.o | 34 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += sleep-tegra30.o |
| 35 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += pm-tegra30.o | ||
| 34 | ifeq ($(CONFIG_CPU_IDLE),y) | 36 | ifeq ($(CONFIG_CPU_IDLE),y) |
| 35 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += cpuidle-tegra114.o | 37 | obj-$(CONFIG_ARCH_TEGRA_114_SOC) += cpuidle-tegra114.o |
| 36 | endif | 38 | endif |
| 37 | 39 | ||
| 38 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-harmony-pcie.o | ||
| 39 | |||
| 40 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-paz00.o | 40 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-paz00.o |
diff --git a/arch/arm/mach-tegra/board-harmony-pcie.c b/arch/arm/mach-tegra/board-harmony-pcie.c deleted file mode 100644 index 035b240b9e15..000000000000 --- a/arch/arm/mach-tegra/board-harmony-pcie.c +++ /dev/null | |||
| @@ -1,89 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * arch/arm/mach-tegra/board-harmony-pcie.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 CompuLab, Ltd. | ||
| 5 | * Mike Rapoport <mike@compulab.co.il> | ||
| 6 | * | ||
| 7 | * This software is licensed under the terms of the GNU General Public | ||
| 8 | * License version 2, as published by the Free Software Foundation, and | ||
| 9 | * may be copied, distributed, and modified under those terms. | ||
| 10 | * | ||
| 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. | ||
| 15 | * | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <linux/kernel.h> | ||
| 19 | #include <linux/gpio.h> | ||
| 20 | #include <linux/err.h> | ||
| 21 | #include <linux/of_gpio.h> | ||
| 22 | #include <linux/regulator/consumer.h> | ||
| 23 | |||
| 24 | #include <asm/mach-types.h> | ||
| 25 | |||
| 26 | #include "board.h" | ||
| 27 | |||
| 28 | #ifdef CONFIG_TEGRA_PCI | ||
| 29 | |||
| 30 | int __init harmony_pcie_init(void) | ||
| 31 | { | ||
| 32 | struct device_node *np; | ||
| 33 | int en_vdd_1v05; | ||
| 34 | struct regulator *regulator = NULL; | ||
| 35 | int err; | ||
| 36 | |||
| 37 | np = of_find_node_by_path("/regulators/regulator@3"); | ||
| 38 | if (!np) { | ||
| 39 | pr_err("%s: of_find_node_by_path failed\n", __func__); | ||
| 40 | return -ENODEV; | ||
| 41 | } | ||
| 42 | |||
| 43 | en_vdd_1v05 = of_get_named_gpio(np, "gpio", 0); | ||
| 44 | if (en_vdd_1v05 < 0) { | ||
| 45 | pr_err("%s: of_get_named_gpio failed: %d\n", __func__, | ||
| 46 | en_vdd_1v05); | ||
| 47 | return en_vdd_1v05; | ||
| 48 | } | ||
| 49 | |||
| 50 | err = gpio_request(en_vdd_1v05, "EN_VDD_1V05"); | ||
| 51 | if (err) { | ||
| 52 | pr_err("%s: gpio_request failed: %d\n", __func__, err); | ||
| 53 | return err; | ||
| 54 | } | ||
| 55 | |||
| 56 | gpio_direction_output(en_vdd_1v05, 1); | ||
| 57 | |||
| 58 | regulator = regulator_get(NULL, "vdd_ldo0,vddio_pex_clk"); | ||
| 59 | if (IS_ERR(regulator)) { | ||
| 60 | err = PTR_ERR(regulator); | ||
| 61 | pr_err("%s: regulator_get failed: %d\n", __func__, err); | ||
| 62 | goto err_reg; | ||
| 63 | } | ||
| 64 | |||
| 65 | err = regulator_enable(regulator); | ||
| 66 | if (err) { | ||
| 67 | pr_err("%s: regulator_enable failed: %d\n", __func__, err); | ||
| 68 | goto err_en; | ||
| 69 | } | ||
| 70 | |||
| 71 | err = tegra_pcie_init(true, true); | ||
| 72 | if (err) { | ||
| 73 | pr_err("%s: tegra_pcie_init failed: %d\n", __func__, err); | ||
| 74 | goto err_pcie; | ||
| 75 | } | ||
| 76 | |||
| 77 | return 0; | ||
| 78 | |||
| 79 | err_pcie: | ||
| 80 | regulator_disable(regulator); | ||
| 81 | err_en: | ||
| 82 | regulator_put(regulator); | ||
| 83 | err_reg: | ||
| 84 | gpio_free(en_vdd_1v05); | ||
| 85 | |||
| 86 | return err; | ||
| 87 | } | ||
| 88 | |||
| 89 | #endif | ||
diff --git a/arch/arm/mach-tegra/board.h b/arch/arm/mach-tegra/board.h index 9a6659fe2dc2..db6810dc0b3d 100644 --- a/arch/arm/mach-tegra/board.h +++ b/arch/arm/mach-tegra/board.h | |||
| @@ -31,7 +31,6 @@ void __init tegra_init_early(void); | |||
| 31 | void __init tegra_map_common_io(void); | 31 | void __init tegra_map_common_io(void); |
| 32 | void __init tegra_init_irq(void); | 32 | void __init tegra_init_irq(void); |
| 33 | void __init tegra_dt_init_irq(void); | 33 | void __init tegra_dt_init_irq(void); |
| 34 | int __init tegra_pcie_init(bool init_port0, bool init_port1); | ||
| 35 | 34 | ||
| 36 | void tegra_init_late(void); | 35 | void tegra_init_late(void); |
| 37 | 36 | ||
| @@ -48,13 +47,6 @@ int __init tegra_powergate_debugfs_init(void); | |||
| 48 | static inline int tegra_powergate_debugfs_init(void) { return 0; } | 47 | static inline int tegra_powergate_debugfs_init(void) { return 0; } |
| 49 | #endif | 48 | #endif |
| 50 | 49 | ||
| 51 | int __init harmony_regulator_init(void); | ||
| 52 | #ifdef CONFIG_TEGRA_PCI | ||
| 53 | int __init harmony_pcie_init(void); | ||
| 54 | #else | ||
| 55 | static inline int harmony_pcie_init(void) { return 0; } | ||
| 56 | #endif | ||
| 57 | |||
| 58 | void __init tegra_paz00_wifikill_init(void); | 50 | void __init tegra_paz00_wifikill_init(void); |
| 59 | 51 | ||
| 60 | #endif | 52 | #endif |
diff --git a/arch/arm/mach-tegra/common.h b/arch/arm/mach-tegra/common.h index 32f8eb3fe344..5900cc44f780 100644 --- a/arch/arm/mach-tegra/common.h +++ b/arch/arm/mach-tegra/common.h | |||
| @@ -2,4 +2,3 @@ extern struct smp_operations tegra_smp_ops; | |||
| 2 | 2 | ||
| 3 | extern int tegra_cpu_kill(unsigned int cpu); | 3 | extern int tegra_cpu_kill(unsigned int cpu); |
| 4 | extern void tegra_cpu_die(unsigned int cpu); | 4 | extern void tegra_cpu_die(unsigned int cpu); |
| 5 | extern int tegra_cpu_disable(unsigned int cpu); | ||
diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c index 1d1c6023f4a2..e0b87300243d 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra114.c +++ b/arch/arm/mach-tegra/cpuidle-tegra114.c | |||
| @@ -17,15 +17,64 @@ | |||
| 17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/cpuidle.h> | 19 | #include <linux/cpuidle.h> |
| 20 | #include <linux/cpu_pm.h> | ||
| 21 | #include <linux/clockchips.h> | ||
| 20 | 22 | ||
| 21 | #include <asm/cpuidle.h> | 23 | #include <asm/cpuidle.h> |
| 24 | #include <asm/suspend.h> | ||
| 25 | #include <asm/smp_plat.h> | ||
| 26 | |||
| 27 | #include "pm.h" | ||
| 28 | #include "sleep.h" | ||
| 29 | |||
| 30 | #ifdef CONFIG_PM_SLEEP | ||
| 31 | #define TEGRA114_MAX_STATES 2 | ||
| 32 | #else | ||
| 33 | #define TEGRA114_MAX_STATES 1 | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #ifdef CONFIG_PM_SLEEP | ||
| 37 | static int tegra114_idle_power_down(struct cpuidle_device *dev, | ||
| 38 | struct cpuidle_driver *drv, | ||
| 39 | int index) | ||
| 40 | { | ||
| 41 | local_fiq_disable(); | ||
| 42 | |||
| 43 | tegra_set_cpu_in_lp2(); | ||
| 44 | cpu_pm_enter(); | ||
| 45 | |||
| 46 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu); | ||
| 47 | |||
| 48 | cpu_suspend(0, tegra30_sleep_cpu_secondary_finish); | ||
| 49 | |||
| 50 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu); | ||
| 51 | |||
| 52 | cpu_pm_exit(); | ||
| 53 | tegra_clear_cpu_in_lp2(); | ||
| 54 | |||
| 55 | local_fiq_enable(); | ||
| 56 | |||
| 57 | return index; | ||
| 58 | } | ||
| 59 | #endif | ||
| 22 | 60 | ||
| 23 | static struct cpuidle_driver tegra_idle_driver = { | 61 | static struct cpuidle_driver tegra_idle_driver = { |
| 24 | .name = "tegra_idle", | 62 | .name = "tegra_idle", |
| 25 | .owner = THIS_MODULE, | 63 | .owner = THIS_MODULE, |
| 26 | .state_count = 1, | 64 | .state_count = TEGRA114_MAX_STATES, |
| 27 | .states = { | 65 | .states = { |
| 28 | [0] = ARM_CPUIDLE_WFI_STATE_PWR(600), | 66 | [0] = ARM_CPUIDLE_WFI_STATE_PWR(600), |
| 67 | #ifdef CONFIG_PM_SLEEP | ||
| 68 | [1] = { | ||
| 69 | .enter = tegra114_idle_power_down, | ||
| 70 | .exit_latency = 500, | ||
| 71 | .target_residency = 1000, | ||
| 72 | .power_usage = 0, | ||
| 73 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
| 74 | .name = "powered-down", | ||
| 75 | .desc = "CPU power gated", | ||
| 76 | }, | ||
| 77 | #endif | ||
| 29 | }, | 78 | }, |
| 30 | }; | 79 | }; |
| 31 | 80 | ||
diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c index 706aa4215c36..b82dcaee2ef4 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c | |||
| @@ -211,6 +211,18 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev, | |||
| 211 | } | 211 | } |
| 212 | #endif | 212 | #endif |
| 213 | 213 | ||
| 214 | /* | ||
| 215 | * Tegra20 HW appears to have a bug such that PCIe device interrupts, whether | ||
| 216 | * they are legacy IRQs or MSI, are lost when LP2 is enabled. To work around | ||
| 217 | * this, simply disable LP2 if the PCI driver and DT node are both enabled. | ||
| 218 | */ | ||
| 219 | void tegra20_cpuidle_pcie_irqs_in_use(void) | ||
| 220 | { | ||
| 221 | pr_info_once( | ||
| 222 | "Disabling cpuidle LP2 state, since PCIe IRQs are in use\n"); | ||
| 223 | tegra_idle_driver.states[1].disabled = true; | ||
| 224 | } | ||
| 225 | |||
| 214 | int __init tegra20_cpuidle_init(void) | 226 | int __init tegra20_cpuidle_init(void) |
| 215 | { | 227 | { |
| 216 | return cpuidle_register(&tegra_idle_driver, cpu_possible_mask); | 228 | return cpuidle_register(&tegra_idle_driver, cpu_possible_mask); |
diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c index e85973cef037..0961dfcf83a4 100644 --- a/arch/arm/mach-tegra/cpuidle.c +++ b/arch/arm/mach-tegra/cpuidle.c | |||
| @@ -44,3 +44,13 @@ void __init tegra_cpuidle_init(void) | |||
| 44 | break; | 44 | break; |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | |||
| 48 | void tegra_cpuidle_pcie_irqs_in_use(void) | ||
| 49 | { | ||
| 50 | switch (tegra_chip_id) { | ||
| 51 | case TEGRA20: | ||
| 52 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) | ||
| 53 | tegra20_cpuidle_pcie_irqs_in_use(); | ||
| 54 | break; | ||
| 55 | } | ||
| 56 | } | ||
diff --git a/arch/arm/mach-tegra/cpuidle.h b/arch/arm/mach-tegra/cpuidle.h index 9ec2c1ab0fa4..c017dab60ffa 100644 --- a/arch/arm/mach-tegra/cpuidle.h +++ b/arch/arm/mach-tegra/cpuidle.h | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | #ifdef CONFIG_CPU_IDLE | 20 | #ifdef CONFIG_CPU_IDLE |
| 21 | int tegra20_cpuidle_init(void); | 21 | int tegra20_cpuidle_init(void); |
| 22 | void tegra20_cpuidle_pcie_irqs_in_use(void); | ||
| 22 | int tegra30_cpuidle_init(void); | 23 | int tegra30_cpuidle_init(void); |
| 23 | int tegra114_cpuidle_init(void); | 24 | int tegra114_cpuidle_init(void); |
| 24 | void tegra_cpuidle_init(void); | 25 | void tegra_cpuidle_init(void); |
diff --git a/arch/arm/mach-tegra/flowctrl.c b/arch/arm/mach-tegra/flowctrl.c index b477ef310dcd..5348543382bf 100644 --- a/arch/arm/mach-tegra/flowctrl.c +++ b/arch/arm/mach-tegra/flowctrl.c | |||
| @@ -86,6 +86,7 @@ void flowctrl_cpu_suspend_enter(unsigned int cpuid) | |||
| 86 | reg |= TEGRA20_FLOW_CTRL_CSR_WFE_CPU0 << cpuid; | 86 | reg |= TEGRA20_FLOW_CTRL_CSR_WFE_CPU0 << cpuid; |
| 87 | break; | 87 | break; |
| 88 | case TEGRA30: | 88 | case TEGRA30: |
| 89 | case TEGRA114: | ||
| 89 | /* clear wfe bitmap */ | 90 | /* clear wfe bitmap */ |
| 90 | reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP; | 91 | reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP; |
| 91 | /* clear wfi bitmap */ | 92 | /* clear wfi bitmap */ |
| @@ -123,6 +124,7 @@ void flowctrl_cpu_suspend_exit(unsigned int cpuid) | |||
| 123 | reg &= ~TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP; | 124 | reg &= ~TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP; |
| 124 | break; | 125 | break; |
| 125 | case TEGRA30: | 126 | case TEGRA30: |
| 127 | case TEGRA114: | ||
| 126 | /* clear wfe bitmap */ | 128 | /* clear wfe bitmap */ |
| 127 | reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP; | 129 | reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP; |
| 128 | /* clear wfi bitmap */ | 130 | /* clear wfi bitmap */ |
diff --git a/arch/arm/mach-tegra/flowctrl.h b/arch/arm/mach-tegra/flowctrl.h index 7a29bae799a7..c89aac60a143 100644 --- a/arch/arm/mach-tegra/flowctrl.h +++ b/arch/arm/mach-tegra/flowctrl.h | |||
| @@ -28,9 +28,18 @@ | |||
| 28 | #define FLOW_CTRL_SCLK_RESUME (1 << 27) | 28 | #define FLOW_CTRL_SCLK_RESUME (1 << 27) |
| 29 | #define FLOW_CTRL_HALT_CPU_IRQ (1 << 10) | 29 | #define FLOW_CTRL_HALT_CPU_IRQ (1 << 10) |
| 30 | #define FLOW_CTRL_HALT_CPU_FIQ (1 << 8) | 30 | #define FLOW_CTRL_HALT_CPU_FIQ (1 << 8) |
| 31 | #define FLOW_CTRL_HALT_LIC_IRQ (1 << 11) | ||
| 32 | #define FLOW_CTRL_HALT_LIC_FIQ (1 << 10) | ||
| 33 | #define FLOW_CTRL_HALT_GIC_IRQ (1 << 9) | ||
| 34 | #define FLOW_CTRL_HALT_GIC_FIQ (1 << 8) | ||
| 31 | #define FLOW_CTRL_CPU0_CSR 0x8 | 35 | #define FLOW_CTRL_CPU0_CSR 0x8 |
| 32 | #define FLOW_CTRL_CSR_INTR_FLAG (1 << 15) | 36 | #define FLOW_CTRL_CSR_INTR_FLAG (1 << 15) |
| 33 | #define FLOW_CTRL_CSR_EVENT_FLAG (1 << 14) | 37 | #define FLOW_CTRL_CSR_EVENT_FLAG (1 << 14) |
| 38 | #define FLOW_CTRL_CSR_ENABLE_EXT_CRAIL (1 << 13) | ||
| 39 | #define FLOW_CTRL_CSR_ENABLE_EXT_NCPU (1 << 12) | ||
| 40 | #define FLOW_CTRL_CSR_ENABLE_EXT_MASK ( \ | ||
| 41 | FLOW_CTRL_CSR_ENABLE_EXT_NCPU | \ | ||
| 42 | FLOW_CTRL_CSR_ENABLE_EXT_CRAIL) | ||
| 34 | #define FLOW_CTRL_CSR_ENABLE (1 << 0) | 43 | #define FLOW_CTRL_CSR_ENABLE (1 << 0) |
| 35 | #define FLOW_CTRL_HALT_CPU1_EVENTS 0x14 | 44 | #define FLOW_CTRL_HALT_CPU1_EVENTS 0x14 |
| 36 | #define FLOW_CTRL_CPU1_CSR 0x18 | 45 | #define FLOW_CTRL_CPU1_CSR 0x18 |
diff --git a/arch/arm/mach-tegra/headsmp.S b/arch/arm/mach-tegra/headsmp.S index 045c16f2dd51..2072e7322c39 100644 --- a/arch/arm/mach-tegra/headsmp.S +++ b/arch/arm/mach-tegra/headsmp.S | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | .section ".text.head", "ax" | 6 | .section ".text.head", "ax" |
| 7 | 7 | ||
| 8 | ENTRY(tegra_secondary_startup) | 8 | ENTRY(tegra_secondary_startup) |
| 9 | bl v7_invalidate_l1 | 9 | check_cpu_part_num 0xc09, r8, r9 |
| 10 | bleq v7_invalidate_l1 | ||
| 10 | b secondary_startup | 11 | b secondary_startup |
| 11 | ENDPROC(tegra_secondary_startup) | 12 | ENDPROC(tegra_secondary_startup) |
diff --git a/arch/arm/mach-tegra/hotplug.c b/arch/arm/mach-tegra/hotplug.c index a52c10e0a857..04de2e860923 100644 --- a/arch/arm/mach-tegra/hotplug.c +++ b/arch/arm/mach-tegra/hotplug.c | |||
| @@ -37,7 +37,7 @@ int tegra_cpu_kill(unsigned cpu) | |||
| 37 | void __ref tegra_cpu_die(unsigned int cpu) | 37 | void __ref tegra_cpu_die(unsigned int cpu) |
| 38 | { | 38 | { |
| 39 | /* Clean L1 data cache */ | 39 | /* Clean L1 data cache */ |
| 40 | tegra_disable_clean_inv_dcache(); | 40 | tegra_disable_clean_inv_dcache(TEGRA_FLUSH_CACHE_LOUIS); |
| 41 | 41 | ||
| 42 | /* Shut down the current CPU. */ | 42 | /* Shut down the current CPU. */ |
| 43 | tegra_hotplug_shutdown(); | 43 | tegra_hotplug_shutdown(); |
| @@ -46,17 +46,6 @@ void __ref tegra_cpu_die(unsigned int cpu) | |||
| 46 | BUG(); | 46 | BUG(); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | int tegra_cpu_disable(unsigned int cpu) | ||
| 50 | { | ||
| 51 | switch (tegra_chip_id) { | ||
| 52 | case TEGRA20: | ||
| 53 | case TEGRA30: | ||
| 54 | return cpu == 0 ? -EPERM : 0; | ||
| 55 | default: | ||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | void __init tegra_hotplug_init(void) | 49 | void __init tegra_hotplug_init(void) |
| 61 | { | 50 | { |
| 62 | if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) | 51 | if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) |
diff --git a/arch/arm/mach-tegra/iomap.h b/arch/arm/mach-tegra/iomap.h index 399fbca27102..3f5fa0749bde 100644 --- a/arch/arm/mach-tegra/iomap.h +++ b/arch/arm/mach-tegra/iomap.h | |||
| @@ -24,6 +24,8 @@ | |||
| 24 | #define TEGRA_IRAM_BASE 0x40000000 | 24 | #define TEGRA_IRAM_BASE 0x40000000 |
| 25 | #define TEGRA_IRAM_SIZE SZ_256K | 25 | #define TEGRA_IRAM_SIZE SZ_256K |
| 26 | 26 | ||
| 27 | #define TEGRA_IRAM_CODE_AREA (TEGRA_IRAM_BASE + SZ_4K) | ||
| 28 | |||
| 27 | #define TEGRA_HOST1X_BASE 0x50000000 | 29 | #define TEGRA_HOST1X_BASE 0x50000000 |
| 28 | #define TEGRA_HOST1X_SIZE 0x24000 | 30 | #define TEGRA_HOST1X_SIZE 0x24000 |
| 29 | 31 | ||
| @@ -237,6 +239,12 @@ | |||
| 237 | #define TEGRA_KFUSE_BASE 0x7000FC00 | 239 | #define TEGRA_KFUSE_BASE 0x7000FC00 |
| 238 | #define TEGRA_KFUSE_SIZE SZ_1K | 240 | #define TEGRA_KFUSE_SIZE SZ_1K |
| 239 | 241 | ||
| 242 | #define TEGRA_EMC0_BASE 0x7001A000 | ||
| 243 | #define TEGRA_EMC0_SIZE SZ_2K | ||
| 244 | |||
| 245 | #define TEGRA_EMC1_BASE 0x7001A800 | ||
| 246 | #define TEGRA_EMC1_SIZE SZ_2K | ||
| 247 | |||
| 240 | #define TEGRA_CSITE_BASE 0x70040000 | 248 | #define TEGRA_CSITE_BASE 0x70040000 |
| 241 | #define TEGRA_CSITE_SIZE SZ_256K | 249 | #define TEGRA_CSITE_SIZE SZ_256K |
| 242 | 250 | ||
| @@ -278,9 +286,6 @@ | |||
| 278 | #define IO_APB_VIRT IOMEM(0xFE300000) | 286 | #define IO_APB_VIRT IOMEM(0xFE300000) |
| 279 | #define IO_APB_SIZE SZ_1M | 287 | #define IO_APB_SIZE SZ_1M |
| 280 | 288 | ||
| 281 | #define TEGRA_PCIE_BASE 0x80000000 | ||
| 282 | #define TEGRA_PCIE_IO_BASE (TEGRA_PCIE_BASE + SZ_4M) | ||
| 283 | |||
| 284 | #define IO_TO_VIRT_BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz))) | 289 | #define IO_TO_VIRT_BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz))) |
| 285 | #define IO_TO_VIRT_XLATE(p, pst, vst) (((p) - (pst) + (vst))) | 290 | #define IO_TO_VIRT_XLATE(p, pst, vst) (((p) - (pst) + (vst))) |
| 286 | 291 | ||
diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c index 0de4eed1493d..1a74d562dca1 100644 --- a/arch/arm/mach-tegra/irq.c +++ b/arch/arm/mach-tegra/irq.c | |||
| @@ -18,10 +18,12 @@ | |||
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
| 21 | #include <linux/cpu_pm.h> | ||
| 21 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
| 22 | #include <linux/irq.h> | 23 | #include <linux/irq.h> |
| 23 | #include <linux/io.h> | 24 | #include <linux/io.h> |
| 24 | #include <linux/of.h> | 25 | #include <linux/of.h> |
| 26 | #include <linux/of_address.h> | ||
| 25 | #include <linux/irqchip/arm-gic.h> | 27 | #include <linux/irqchip/arm-gic.h> |
| 26 | #include <linux/syscore_ops.h> | 28 | #include <linux/syscore_ops.h> |
| 27 | 29 | ||
| @@ -65,6 +67,7 @@ static u32 cpu_ier[TEGRA_MAX_NUM_ICTLRS]; | |||
| 65 | static u32 cpu_iep[TEGRA_MAX_NUM_ICTLRS]; | 67 | static u32 cpu_iep[TEGRA_MAX_NUM_ICTLRS]; |
| 66 | 68 | ||
| 67 | static u32 ictlr_wake_mask[TEGRA_MAX_NUM_ICTLRS]; | 69 | static u32 ictlr_wake_mask[TEGRA_MAX_NUM_ICTLRS]; |
| 70 | static void __iomem *tegra_gic_cpu_base; | ||
| 68 | #endif | 71 | #endif |
| 69 | 72 | ||
| 70 | bool tegra_pending_sgi(void) | 73 | bool tegra_pending_sgi(void) |
| @@ -213,8 +216,43 @@ int tegra_legacy_irq_syscore_init(void) | |||
| 213 | 216 | ||
| 214 | return 0; | 217 | return 0; |
| 215 | } | 218 | } |
| 219 | |||
| 220 | static int tegra_gic_notifier(struct notifier_block *self, | ||
| 221 | unsigned long cmd, void *v) | ||
| 222 | { | ||
| 223 | switch (cmd) { | ||
| 224 | case CPU_PM_ENTER: | ||
| 225 | writel_relaxed(0x1E0, tegra_gic_cpu_base + GIC_CPU_CTRL); | ||
| 226 | break; | ||
| 227 | } | ||
| 228 | |||
| 229 | return NOTIFY_OK; | ||
| 230 | } | ||
| 231 | |||
| 232 | static struct notifier_block tegra_gic_notifier_block = { | ||
| 233 | .notifier_call = tegra_gic_notifier, | ||
| 234 | }; | ||
| 235 | |||
| 236 | static const struct of_device_id tegra114_dt_gic_match[] __initconst = { | ||
| 237 | { .compatible = "arm,cortex-a15-gic" }, | ||
| 238 | { } | ||
| 239 | }; | ||
| 240 | |||
| 241 | static void tegra114_gic_cpu_pm_registration(void) | ||
| 242 | { | ||
| 243 | struct device_node *dn; | ||
| 244 | |||
| 245 | dn = of_find_matching_node(NULL, tegra114_dt_gic_match); | ||
| 246 | if (!dn) | ||
| 247 | return; | ||
| 248 | |||
| 249 | tegra_gic_cpu_base = of_iomap(dn, 1); | ||
| 250 | |||
| 251 | cpu_pm_register_notifier(&tegra_gic_notifier_block); | ||
| 252 | } | ||
| 216 | #else | 253 | #else |
| 217 | #define tegra_set_wake NULL | 254 | #define tegra_set_wake NULL |
| 255 | static void tegra114_gic_cpu_pm_registration(void) { } | ||
| 218 | #endif | 256 | #endif |
| 219 | 257 | ||
| 220 | void __init tegra_init_irq(void) | 258 | void __init tegra_init_irq(void) |
| @@ -252,4 +290,6 @@ void __init tegra_init_irq(void) | |||
| 252 | if (!of_have_populated_dt()) | 290 | if (!of_have_populated_dt()) |
| 253 | gic_init(0, 29, distbase, | 291 | gic_init(0, 29, distbase, |
| 254 | IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x100)); | 292 | IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x100)); |
| 293 | |||
| 294 | tegra114_gic_cpu_pm_registration(); | ||
| 255 | } | 295 | } |
diff --git a/arch/arm/mach-tegra/pcie.c b/arch/arm/mach-tegra/pcie.c deleted file mode 100644 index 46144a19a7e7..000000000000 --- a/arch/arm/mach-tegra/pcie.c +++ /dev/null | |||
| @@ -1,886 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * arch/arm/mach-tegra/pci.c | ||
| 3 | * | ||
| 4 | * PCIe host controller driver for TEGRA(2) SOCs | ||
| 5 | * | ||
| 6 | * Copyright (c) 2010, CompuLab, Ltd. | ||
| 7 | * Author: Mike Rapoport <mike@compulab.co.il> | ||
| 8 | * | ||
| 9 | * Based on NVIDIA PCIe driver | ||
| 10 | * Copyright (c) 2008-2009, NVIDIA Corporation. | ||
| 11 | * | ||
| 12 | * Bits taken from arch/arm/mach-dove/pcie.c | ||
| 13 | * | ||
| 14 | * This program is free software; you can redistribute it and/or modify | ||
| 15 | * it under the terms of the GNU General Public License as published by | ||
| 16 | * the Free Software Foundation; either version 2 of the License, or | ||
| 17 | * (at your option) any later version. | ||
| 18 | * | ||
| 19 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 22 | * more details. | ||
| 23 | * | ||
| 24 | * You should have received a copy of the GNU General Public License along | ||
| 25 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 26 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include <linux/kernel.h> | ||
| 30 | #include <linux/pci.h> | ||
| 31 | #include <linux/interrupt.h> | ||
| 32 | #include <linux/irq.h> | ||
| 33 | #include <linux/clk.h> | ||
| 34 | #include <linux/delay.h> | ||
| 35 | #include <linux/export.h> | ||
| 36 | #include <linux/clk/tegra.h> | ||
| 37 | #include <linux/tegra-powergate.h> | ||
| 38 | |||
| 39 | #include <asm/sizes.h> | ||
| 40 | #include <asm/mach/pci.h> | ||
| 41 | |||
| 42 | #include "board.h" | ||
| 43 | #include "iomap.h" | ||
| 44 | |||
| 45 | /* Hack - need to parse this from DT */ | ||
| 46 | #define INT_PCIE_INTR 130 | ||
| 47 | |||
| 48 | /* register definitions */ | ||
| 49 | #define AFI_OFFSET 0x3800 | ||
| 50 | #define PADS_OFFSET 0x3000 | ||
| 51 | #define RP0_OFFSET 0x0000 | ||
| 52 | #define RP1_OFFSET 0x1000 | ||
| 53 | |||
| 54 | #define AFI_AXI_BAR0_SZ 0x00 | ||
| 55 | #define AFI_AXI_BAR1_SZ 0x04 | ||
| 56 | #define AFI_AXI_BAR2_SZ 0x08 | ||
| 57 | #define AFI_AXI_BAR3_SZ 0x0c | ||
| 58 | #define AFI_AXI_BAR4_SZ 0x10 | ||
| 59 | #define AFI_AXI_BAR5_SZ 0x14 | ||
| 60 | |||
| 61 | #define AFI_AXI_BAR0_START 0x18 | ||
| 62 | #define AFI_AXI_BAR1_START 0x1c | ||
| 63 | #define AFI_AXI_BAR2_START 0x20 | ||
| 64 | #define AFI_AXI_BAR3_START 0x24 | ||
| 65 | #define AFI_AXI_BAR4_START 0x28 | ||
| 66 | #define AFI_AXI_BAR5_START 0x2c | ||
| 67 | |||
| 68 | #define AFI_FPCI_BAR0 0x30 | ||
| 69 | #define AFI_FPCI_BAR1 0x34 | ||
| 70 | #define AFI_FPCI_BAR2 0x38 | ||
| 71 | #define AFI_FPCI_BAR3 0x3c | ||
| 72 | #define AFI_FPCI_BAR4 0x40 | ||
| 73 | #define AFI_FPCI_BAR5 0x44 | ||
| 74 | |||
| 75 | #define AFI_CACHE_BAR0_SZ 0x48 | ||
| 76 | #define AFI_CACHE_BAR0_ST 0x4c | ||
| 77 | #define AFI_CACHE_BAR1_SZ 0x50 | ||
| 78 | #define AFI_CACHE_BAR1_ST 0x54 | ||
| 79 | |||
| 80 | #define AFI_MSI_BAR_SZ 0x60 | ||
| 81 | #define AFI_MSI_FPCI_BAR_ST 0x64 | ||
| 82 | #define AFI_MSI_AXI_BAR_ST 0x68 | ||
| 83 | |||
| 84 | #define AFI_CONFIGURATION 0xac | ||
| 85 | #define AFI_CONFIGURATION_EN_FPCI (1 << 0) | ||
| 86 | |||
| 87 | #define AFI_FPCI_ERROR_MASKS 0xb0 | ||
| 88 | |||
| 89 | #define AFI_INTR_MASK 0xb4 | ||
| 90 | #define AFI_INTR_MASK_INT_MASK (1 << 0) | ||
| 91 | #define AFI_INTR_MASK_MSI_MASK (1 << 8) | ||
| 92 | |||
| 93 | #define AFI_INTR_CODE 0xb8 | ||
| 94 | #define AFI_INTR_CODE_MASK 0xf | ||
| 95 | #define AFI_INTR_MASTER_ABORT 4 | ||
| 96 | #define AFI_INTR_LEGACY 6 | ||
| 97 | |||
| 98 | #define AFI_INTR_SIGNATURE 0xbc | ||
| 99 | #define AFI_SM_INTR_ENABLE 0xc4 | ||
| 100 | |||
| 101 | #define AFI_AFI_INTR_ENABLE 0xc8 | ||
| 102 | #define AFI_INTR_EN_INI_SLVERR (1 << 0) | ||
| 103 | #define AFI_INTR_EN_INI_DECERR (1 << 1) | ||
| 104 | #define AFI_INTR_EN_TGT_SLVERR (1 << 2) | ||
| 105 | #define AFI_INTR_EN_TGT_DECERR (1 << 3) | ||
| 106 | #define AFI_INTR_EN_TGT_WRERR (1 << 4) | ||
| 107 | #define AFI_INTR_EN_DFPCI_DECERR (1 << 5) | ||
| 108 | #define AFI_INTR_EN_AXI_DECERR (1 << 6) | ||
| 109 | #define AFI_INTR_EN_FPCI_TIMEOUT (1 << 7) | ||
| 110 | |||
| 111 | #define AFI_PCIE_CONFIG 0x0f8 | ||
| 112 | #define AFI_PCIE_CONFIG_PCIEC0_DISABLE_DEVICE (1 << 1) | ||
| 113 | #define AFI_PCIE_CONFIG_PCIEC1_DISABLE_DEVICE (1 << 2) | ||
| 114 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK (0xf << 20) | ||
| 115 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_SINGLE (0x0 << 20) | ||
| 116 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_DUAL (0x1 << 20) | ||
| 117 | |||
| 118 | #define AFI_FUSE 0x104 | ||
| 119 | #define AFI_FUSE_PCIE_T0_GEN2_DIS (1 << 2) | ||
| 120 | |||
| 121 | #define AFI_PEX0_CTRL 0x110 | ||
| 122 | #define AFI_PEX1_CTRL 0x118 | ||
| 123 | #define AFI_PEX_CTRL_RST (1 << 0) | ||
| 124 | #define AFI_PEX_CTRL_REFCLK_EN (1 << 3) | ||
| 125 | |||
| 126 | #define RP_VEND_XP 0x00000F00 | ||
| 127 | #define RP_VEND_XP_DL_UP (1 << 30) | ||
| 128 | |||
| 129 | #define RP_LINK_CONTROL_STATUS 0x00000090 | ||
| 130 | #define RP_LINK_CONTROL_STATUS_LINKSTAT_MASK 0x3fff0000 | ||
| 131 | |||
| 132 | #define PADS_CTL_SEL 0x0000009C | ||
| 133 | |||
| 134 | #define PADS_CTL 0x000000A0 | ||
| 135 | #define PADS_CTL_IDDQ_1L (1 << 0) | ||
| 136 | #define PADS_CTL_TX_DATA_EN_1L (1 << 6) | ||
| 137 | #define PADS_CTL_RX_DATA_EN_1L (1 << 10) | ||
| 138 | |||
| 139 | #define PADS_PLL_CTL 0x000000B8 | ||
| 140 | #define PADS_PLL_CTL_RST_B4SM (1 << 1) | ||
| 141 | #define PADS_PLL_CTL_LOCKDET (1 << 8) | ||
| 142 | #define PADS_PLL_CTL_REFCLK_MASK (0x3 << 16) | ||
| 143 | #define PADS_PLL_CTL_REFCLK_INTERNAL_CML (0 << 16) | ||
| 144 | #define PADS_PLL_CTL_REFCLK_INTERNAL_CMOS (1 << 16) | ||
| 145 | #define PADS_PLL_CTL_REFCLK_EXTERNAL (2 << 16) | ||
| 146 | #define PADS_PLL_CTL_TXCLKREF_MASK (0x1 << 20) | ||
| 147 | #define PADS_PLL_CTL_TXCLKREF_DIV10 (0 << 20) | ||
| 148 | #define PADS_PLL_CTL_TXCLKREF_DIV5 (1 << 20) | ||
| 149 | |||
| 150 | /* PMC access is required for PCIE xclk (un)clamping */ | ||
| 151 | #define PMC_SCRATCH42 0x144 | ||
| 152 | #define PMC_SCRATCH42_PCX_CLAMP (1 << 0) | ||
| 153 | |||
| 154 | static void __iomem *reg_pmc_base = IO_ADDRESS(TEGRA_PMC_BASE); | ||
| 155 | |||
| 156 | #define pmc_writel(value, reg) \ | ||
| 157 | __raw_writel(value, reg_pmc_base + (reg)) | ||
| 158 | #define pmc_readl(reg) \ | ||
| 159 | __raw_readl(reg_pmc_base + (reg)) | ||
| 160 | |||
| 161 | /* | ||
| 162 | * Tegra2 defines 1GB in the AXI address map for PCIe. | ||
| 163 | * | ||
| 164 | * That address space is split into different regions, with sizes and | ||
| 165 | * offsets as follows: | ||
| 166 | * | ||
| 167 | * 0x80000000 - 0x80003fff - PCI controller registers | ||
| 168 | * 0x80004000 - 0x80103fff - PCI configuration space | ||
| 169 | * 0x80104000 - 0x80203fff - PCI extended configuration space | ||
| 170 | * 0x80203fff - 0x803fffff - unused | ||
| 171 | * 0x80400000 - 0x8040ffff - downstream IO | ||
| 172 | * 0x80410000 - 0x8fffffff - unused | ||
| 173 | * 0x90000000 - 0x9fffffff - non-prefetchable memory | ||
| 174 | * 0xa0000000 - 0xbfffffff - prefetchable memory | ||
| 175 | */ | ||
| 176 | #define PCIE_REGS_SZ SZ_16K | ||
| 177 | #define PCIE_CFG_OFF PCIE_REGS_SZ | ||
| 178 | #define PCIE_CFG_SZ SZ_1M | ||
| 179 | #define PCIE_EXT_CFG_OFF (PCIE_CFG_SZ + PCIE_CFG_OFF) | ||
| 180 | #define PCIE_EXT_CFG_SZ SZ_1M | ||
| 181 | #define PCIE_IOMAP_SZ (PCIE_REGS_SZ + PCIE_CFG_SZ + PCIE_EXT_CFG_SZ) | ||
| 182 | |||
| 183 | #define MEM_BASE_0 (TEGRA_PCIE_BASE + SZ_256M) | ||
| 184 | #define MEM_SIZE_0 SZ_128M | ||
| 185 | #define MEM_BASE_1 (MEM_BASE_0 + MEM_SIZE_0) | ||
| 186 | #define MEM_SIZE_1 SZ_128M | ||
| 187 | #define PREFETCH_MEM_BASE_0 (MEM_BASE_1 + MEM_SIZE_1) | ||
| 188 | #define PREFETCH_MEM_SIZE_0 SZ_128M | ||
| 189 | #define PREFETCH_MEM_BASE_1 (PREFETCH_MEM_BASE_0 + PREFETCH_MEM_SIZE_0) | ||
| 190 | #define PREFETCH_MEM_SIZE_1 SZ_128M | ||
| 191 | |||
| 192 | #define PCIE_CONF_BUS(b) ((b) << 16) | ||
| 193 | #define PCIE_CONF_DEV(d) ((d) << 11) | ||
| 194 | #define PCIE_CONF_FUNC(f) ((f) << 8) | ||
| 195 | #define PCIE_CONF_REG(r) \ | ||
| 196 | (((r) & ~0x3) | (((r) < 256) ? PCIE_CFG_OFF : PCIE_EXT_CFG_OFF)) | ||
| 197 | |||
| 198 | struct tegra_pcie_port { | ||
| 199 | int index; | ||
| 200 | u8 root_bus_nr; | ||
| 201 | void __iomem *base; | ||
| 202 | |||
| 203 | bool link_up; | ||
| 204 | |||
| 205 | char mem_space_name[16]; | ||
| 206 | char prefetch_space_name[20]; | ||
| 207 | struct resource res[2]; | ||
| 208 | }; | ||
| 209 | |||
| 210 | struct tegra_pcie_info { | ||
| 211 | struct tegra_pcie_port port[2]; | ||
| 212 | int num_ports; | ||
| 213 | |||
| 214 | void __iomem *regs; | ||
| 215 | struct resource res_mmio; | ||
| 216 | |||
| 217 | struct clk *pex_clk; | ||
| 218 | struct clk *afi_clk; | ||
| 219 | struct clk *pcie_xclk; | ||
| 220 | struct clk *pll_e; | ||
| 221 | }; | ||
| 222 | |||
| 223 | static struct tegra_pcie_info tegra_pcie; | ||
| 224 | |||
| 225 | static inline void afi_writel(u32 value, unsigned long offset) | ||
| 226 | { | ||
| 227 | writel(value, offset + AFI_OFFSET + tegra_pcie.regs); | ||
| 228 | } | ||
| 229 | |||
| 230 | static inline u32 afi_readl(unsigned long offset) | ||
| 231 | { | ||
| 232 | return readl(offset + AFI_OFFSET + tegra_pcie.regs); | ||
| 233 | } | ||
| 234 | |||
| 235 | static inline void pads_writel(u32 value, unsigned long offset) | ||
| 236 | { | ||
| 237 | writel(value, offset + PADS_OFFSET + tegra_pcie.regs); | ||
| 238 | } | ||
| 239 | |||
| 240 | static inline u32 pads_readl(unsigned long offset) | ||
| 241 | { | ||
| 242 | return readl(offset + PADS_OFFSET + tegra_pcie.regs); | ||
| 243 | } | ||
| 244 | |||
| 245 | static struct tegra_pcie_port *bus_to_port(int bus) | ||
| 246 | { | ||
| 247 | int i; | ||
| 248 | |||
| 249 | for (i = tegra_pcie.num_ports - 1; i >= 0; i--) { | ||
| 250 | int rbus = tegra_pcie.port[i].root_bus_nr; | ||
| 251 | if (rbus != -1 && rbus == bus) | ||
| 252 | break; | ||
| 253 | } | ||
| 254 | |||
| 255 | return i >= 0 ? tegra_pcie.port + i : NULL; | ||
| 256 | } | ||
| 257 | |||
| 258 | static int tegra_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, | ||
| 259 | int where, int size, u32 *val) | ||
| 260 | { | ||
| 261 | struct tegra_pcie_port *pp = bus_to_port(bus->number); | ||
| 262 | void __iomem *addr; | ||
| 263 | |||
| 264 | if (pp) { | ||
| 265 | if (devfn != 0) { | ||
| 266 | *val = 0xffffffff; | ||
| 267 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 268 | } | ||
| 269 | |||
| 270 | addr = pp->base + (where & ~0x3); | ||
| 271 | } else { | ||
| 272 | addr = tegra_pcie.regs + (PCIE_CONF_BUS(bus->number) + | ||
| 273 | PCIE_CONF_DEV(PCI_SLOT(devfn)) + | ||
| 274 | PCIE_CONF_FUNC(PCI_FUNC(devfn)) + | ||
| 275 | PCIE_CONF_REG(where)); | ||
| 276 | } | ||
| 277 | |||
| 278 | *val = readl(addr); | ||
| 279 | |||
| 280 | if (size == 1) | ||
| 281 | *val = (*val >> (8 * (where & 3))) & 0xff; | ||
| 282 | else if (size == 2) | ||
| 283 | *val = (*val >> (8 * (where & 3))) & 0xffff; | ||
| 284 | |||
| 285 | return PCIBIOS_SUCCESSFUL; | ||
| 286 | } | ||
| 287 | |||
| 288 | static int tegra_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, | ||
| 289 | int where, int size, u32 val) | ||
| 290 | { | ||
| 291 | struct tegra_pcie_port *pp = bus_to_port(bus->number); | ||
| 292 | void __iomem *addr; | ||
| 293 | |||
| 294 | u32 mask; | ||
| 295 | u32 tmp; | ||
| 296 | |||
| 297 | if (pp) { | ||
| 298 | if (devfn != 0) | ||
| 299 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 300 | |||
| 301 | addr = pp->base + (where & ~0x3); | ||
| 302 | } else { | ||
| 303 | addr = tegra_pcie.regs + (PCIE_CONF_BUS(bus->number) + | ||
| 304 | PCIE_CONF_DEV(PCI_SLOT(devfn)) + | ||
| 305 | PCIE_CONF_FUNC(PCI_FUNC(devfn)) + | ||
| 306 | PCIE_CONF_REG(where)); | ||
| 307 | } | ||
| 308 | |||
| 309 | if (size == 4) { | ||
| 310 | writel(val, addr); | ||
| 311 | return PCIBIOS_SUCCESSFUL; | ||
| 312 | } | ||
| 313 | |||
| 314 | if (size == 2) | ||
| 315 | mask = ~(0xffff << ((where & 0x3) * 8)); | ||
| 316 | else if (size == 1) | ||
| 317 | mask = ~(0xff << ((where & 0x3) * 8)); | ||
| 318 | else | ||
| 319 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
| 320 | |||
| 321 | tmp = readl(addr) & mask; | ||
| 322 | tmp |= val << ((where & 0x3) * 8); | ||
| 323 | writel(tmp, addr); | ||
| 324 | |||
| 325 | return PCIBIOS_SUCCESSFUL; | ||
| 326 | } | ||
| 327 | |||
| 328 | static struct pci_ops tegra_pcie_ops = { | ||
| 329 | .read = tegra_pcie_read_conf, | ||
| 330 | .write = tegra_pcie_write_conf, | ||
| 331 | }; | ||
| 332 | |||
| 333 | static void tegra_pcie_fixup_bridge(struct pci_dev *dev) | ||
| 334 | { | ||
| 335 | u16 reg; | ||
| 336 | |||
| 337 | if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) { | ||
| 338 | pci_read_config_word(dev, PCI_COMMAND, ®); | ||
| 339 | reg |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | | ||
| 340 | PCI_COMMAND_MASTER | PCI_COMMAND_SERR); | ||
| 341 | pci_write_config_word(dev, PCI_COMMAND, reg); | ||
| 342 | } | ||
| 343 | } | ||
| 344 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_fixup_bridge); | ||
| 345 | |||
| 346 | /* Tegra PCIE root complex wrongly reports device class */ | ||
| 347 | static void tegra_pcie_fixup_class(struct pci_dev *dev) | ||
| 348 | { | ||
| 349 | dev->class = PCI_CLASS_BRIDGE_PCI << 8; | ||
| 350 | } | ||
| 351 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf0, tegra_pcie_fixup_class); | ||
| 352 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf1, tegra_pcie_fixup_class); | ||
| 353 | |||
| 354 | /* Tegra PCIE requires relaxed ordering */ | ||
| 355 | static void tegra_pcie_relax_enable(struct pci_dev *dev) | ||
| 356 | { | ||
| 357 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN); | ||
| 358 | } | ||
| 359 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_relax_enable); | ||
| 360 | |||
| 361 | static int tegra_pcie_setup(int nr, struct pci_sys_data *sys) | ||
| 362 | { | ||
| 363 | struct tegra_pcie_port *pp; | ||
| 364 | |||
| 365 | if (nr >= tegra_pcie.num_ports) | ||
| 366 | return 0; | ||
| 367 | |||
| 368 | pp = tegra_pcie.port + nr; | ||
| 369 | pp->root_bus_nr = sys->busnr; | ||
| 370 | |||
| 371 | pci_ioremap_io(nr * SZ_64K, TEGRA_PCIE_IO_BASE); | ||
| 372 | |||
| 373 | /* | ||
| 374 | * IORESOURCE_MEM | ||
| 375 | */ | ||
| 376 | snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), | ||
| 377 | "PCIe %d MEM", pp->index); | ||
| 378 | pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; | ||
| 379 | pp->res[0].name = pp->mem_space_name; | ||
| 380 | if (pp->index == 0) { | ||
| 381 | pp->res[0].start = MEM_BASE_0; | ||
| 382 | pp->res[0].end = pp->res[0].start + MEM_SIZE_0 - 1; | ||
| 383 | } else { | ||
| 384 | pp->res[0].start = MEM_BASE_1; | ||
| 385 | pp->res[0].end = pp->res[0].start + MEM_SIZE_1 - 1; | ||
| 386 | } | ||
| 387 | pp->res[0].flags = IORESOURCE_MEM; | ||
| 388 | if (request_resource(&iomem_resource, &pp->res[0])) | ||
| 389 | panic("Request PCIe Memory resource failed\n"); | ||
| 390 | pci_add_resource_offset(&sys->resources, &pp->res[0], sys->mem_offset); | ||
| 391 | |||
| 392 | /* | ||
| 393 | * IORESOURCE_MEM | IORESOURCE_PREFETCH | ||
| 394 | */ | ||
| 395 | snprintf(pp->prefetch_space_name, sizeof(pp->prefetch_space_name), | ||
| 396 | "PCIe %d PREFETCH MEM", pp->index); | ||
| 397 | pp->prefetch_space_name[sizeof(pp->prefetch_space_name) - 1] = 0; | ||
| 398 | pp->res[1].name = pp->prefetch_space_name; | ||
| 399 | if (pp->index == 0) { | ||
| 400 | pp->res[1].start = PREFETCH_MEM_BASE_0; | ||
| 401 | pp->res[1].end = pp->res[1].start + PREFETCH_MEM_SIZE_0 - 1; | ||
| 402 | } else { | ||
| 403 | pp->res[1].start = PREFETCH_MEM_BASE_1; | ||
| 404 | pp->res[1].end = pp->res[1].start + PREFETCH_MEM_SIZE_1 - 1; | ||
| 405 | } | ||
| 406 | pp->res[1].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; | ||
| 407 | if (request_resource(&iomem_resource, &pp->res[1])) | ||
| 408 | panic("Request PCIe Prefetch Memory resource failed\n"); | ||
| 409 | pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); | ||
| 410 | |||
| 411 | return 1; | ||
| 412 | } | ||
| 413 | |||
| 414 | static int tegra_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | ||
| 415 | { | ||
| 416 | return INT_PCIE_INTR; | ||
| 417 | } | ||
| 418 | |||
| 419 | static struct pci_bus __init *tegra_pcie_scan_bus(int nr, | ||
| 420 | struct pci_sys_data *sys) | ||
| 421 | { | ||
| 422 | struct tegra_pcie_port *pp; | ||
| 423 | |||
| 424 | if (nr >= tegra_pcie.num_ports) | ||
| 425 | return NULL; | ||
| 426 | |||
| 427 | pp = tegra_pcie.port + nr; | ||
| 428 | pp->root_bus_nr = sys->busnr; | ||
| 429 | |||
| 430 | return pci_scan_root_bus(NULL, sys->busnr, &tegra_pcie_ops, sys, | ||
| 431 | &sys->resources); | ||
| 432 | } | ||
| 433 | |||
| 434 | static struct hw_pci tegra_pcie_hw __initdata = { | ||
| 435 | .nr_controllers = 2, | ||
| 436 | .setup = tegra_pcie_setup, | ||
| 437 | .scan = tegra_pcie_scan_bus, | ||
| 438 | .map_irq = tegra_pcie_map_irq, | ||
| 439 | }; | ||
| 440 | |||
| 441 | |||
| 442 | static irqreturn_t tegra_pcie_isr(int irq, void *arg) | ||
| 443 | { | ||
| 444 | const char *err_msg[] = { | ||
| 445 | "Unknown", | ||
| 446 | "AXI slave error", | ||
| 447 | "AXI decode error", | ||
| 448 | "Target abort", | ||
| 449 | "Master abort", | ||
| 450 | "Invalid write", | ||
| 451 | "Response decoding error", | ||
| 452 | "AXI response decoding error", | ||
| 453 | "Transcation timeout", | ||
| 454 | }; | ||
| 455 | |||
| 456 | u32 code, signature; | ||
| 457 | |||
| 458 | code = afi_readl(AFI_INTR_CODE) & AFI_INTR_CODE_MASK; | ||
| 459 | signature = afi_readl(AFI_INTR_SIGNATURE); | ||
| 460 | afi_writel(0, AFI_INTR_CODE); | ||
| 461 | |||
| 462 | if (code == AFI_INTR_LEGACY) | ||
| 463 | return IRQ_NONE; | ||
| 464 | |||
| 465 | if (code >= ARRAY_SIZE(err_msg)) | ||
| 466 | code = 0; | ||
| 467 | |||
| 468 | /* | ||
| 469 | * do not pollute kernel log with master abort reports since they | ||
| 470 | * happen a lot during enumeration | ||
| 471 | */ | ||
| 472 | if (code == AFI_INTR_MASTER_ABORT) | ||
| 473 | pr_debug("PCIE: %s, signature: %08x\n", err_msg[code], signature); | ||
| 474 | else | ||
| 475 | pr_err("PCIE: %s, signature: %08x\n", err_msg[code], signature); | ||
| 476 | |||
| 477 | return IRQ_HANDLED; | ||
| 478 | } | ||
| 479 | |||
| 480 | static void tegra_pcie_setup_translations(void) | ||
| 481 | { | ||
| 482 | u32 fpci_bar; | ||
| 483 | u32 size; | ||
| 484 | u32 axi_address; | ||
| 485 | |||
| 486 | /* Bar 0: config Bar */ | ||
| 487 | fpci_bar = ((u32)0xfdff << 16); | ||
| 488 | size = PCIE_CFG_SZ; | ||
| 489 | axi_address = TEGRA_PCIE_BASE + PCIE_CFG_OFF; | ||
| 490 | afi_writel(axi_address, AFI_AXI_BAR0_START); | ||
| 491 | afi_writel(size >> 12, AFI_AXI_BAR0_SZ); | ||
| 492 | afi_writel(fpci_bar, AFI_FPCI_BAR0); | ||
| 493 | |||
| 494 | /* Bar 1: extended config Bar */ | ||
| 495 | fpci_bar = ((u32)0xfe1 << 20); | ||
| 496 | size = PCIE_EXT_CFG_SZ; | ||
| 497 | axi_address = TEGRA_PCIE_BASE + PCIE_EXT_CFG_OFF; | ||
| 498 | afi_writel(axi_address, AFI_AXI_BAR1_START); | ||
| 499 | afi_writel(size >> 12, AFI_AXI_BAR1_SZ); | ||
| 500 | afi_writel(fpci_bar, AFI_FPCI_BAR1); | ||
| 501 | |||
| 502 | /* Bar 2: downstream IO bar */ | ||
| 503 | fpci_bar = ((__u32)0xfdfc << 16); | ||
| 504 | size = SZ_128K; | ||
| 505 | axi_address = TEGRA_PCIE_IO_BASE; | ||
| 506 | afi_writel(axi_address, AFI_AXI_BAR2_START); | ||
| 507 | afi_writel(size >> 12, AFI_AXI_BAR2_SZ); | ||
| 508 | afi_writel(fpci_bar, AFI_FPCI_BAR2); | ||
| 509 | |||
| 510 | /* Bar 3: prefetchable memory BAR */ | ||
| 511 | fpci_bar = (((PREFETCH_MEM_BASE_0 >> 12) & 0x0fffffff) << 4) | 0x1; | ||
| 512 | size = PREFETCH_MEM_SIZE_0 + PREFETCH_MEM_SIZE_1; | ||
| 513 | axi_address = PREFETCH_MEM_BASE_0; | ||
| 514 | afi_writel(axi_address, AFI_AXI_BAR3_START); | ||
| 515 | afi_writel(size >> 12, AFI_AXI_BAR3_SZ); | ||
| 516 | afi_writel(fpci_bar, AFI_FPCI_BAR3); | ||
| 517 | |||
| 518 | /* Bar 4: non prefetchable memory BAR */ | ||
| 519 | fpci_bar = (((MEM_BASE_0 >> 12) & 0x0FFFFFFF) << 4) | 0x1; | ||
| 520 | size = MEM_SIZE_0 + MEM_SIZE_1; | ||
| 521 | axi_address = MEM_BASE_0; | ||
| 522 | afi_writel(axi_address, AFI_AXI_BAR4_START); | ||
| 523 | afi_writel(size >> 12, AFI_AXI_BAR4_SZ); | ||
| 524 | afi_writel(fpci_bar, AFI_FPCI_BAR4); | ||
| 525 | |||
| 526 | /* Bar 5: NULL out the remaining BAR as it is not used */ | ||
| 527 | fpci_bar = 0; | ||
| 528 | size = 0; | ||
| 529 | axi_address = 0; | ||
| 530 | afi_writel(axi_address, AFI_AXI_BAR5_START); | ||
| 531 | afi_writel(size >> 12, AFI_AXI_BAR5_SZ); | ||
| 532 | afi_writel(fpci_bar, AFI_FPCI_BAR5); | ||
| 533 | |||
| 534 | /* map all upstream transactions as uncached */ | ||
| 535 | afi_writel(PHYS_OFFSET, AFI_CACHE_BAR0_ST); | ||
| 536 | afi_writel(0, AFI_CACHE_BAR0_SZ); | ||
| 537 | afi_writel(0, AFI_CACHE_BAR1_ST); | ||
| 538 | afi_writel(0, AFI_CACHE_BAR1_SZ); | ||
| 539 | |||
| 540 | /* No MSI */ | ||
| 541 | afi_writel(0, AFI_MSI_FPCI_BAR_ST); | ||
| 542 | afi_writel(0, AFI_MSI_BAR_SZ); | ||
| 543 | afi_writel(0, AFI_MSI_AXI_BAR_ST); | ||
| 544 | afi_writel(0, AFI_MSI_BAR_SZ); | ||
| 545 | } | ||
| 546 | |||
| 547 | static int tegra_pcie_enable_controller(void) | ||
| 548 | { | ||
| 549 | u32 val, reg; | ||
| 550 | int i, timeout; | ||
| 551 | |||
| 552 | /* Enable slot clock and pulse the reset signals */ | ||
| 553 | for (i = 0, reg = AFI_PEX0_CTRL; i < 2; i++, reg += 0x8) { | ||
| 554 | val = afi_readl(reg) | AFI_PEX_CTRL_REFCLK_EN; | ||
| 555 | afi_writel(val, reg); | ||
| 556 | val &= ~AFI_PEX_CTRL_RST; | ||
| 557 | afi_writel(val, reg); | ||
| 558 | |||
| 559 | val = afi_readl(reg) | AFI_PEX_CTRL_RST; | ||
| 560 | afi_writel(val, reg); | ||
| 561 | } | ||
| 562 | |||
| 563 | /* Enable dual controller and both ports */ | ||
| 564 | val = afi_readl(AFI_PCIE_CONFIG); | ||
| 565 | val &= ~(AFI_PCIE_CONFIG_PCIEC0_DISABLE_DEVICE | | ||
| 566 | AFI_PCIE_CONFIG_PCIEC1_DISABLE_DEVICE | | ||
| 567 | AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK); | ||
| 568 | val |= AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_DUAL; | ||
| 569 | afi_writel(val, AFI_PCIE_CONFIG); | ||
| 570 | |||
| 571 | val = afi_readl(AFI_FUSE) & ~AFI_FUSE_PCIE_T0_GEN2_DIS; | ||
| 572 | afi_writel(val, AFI_FUSE); | ||
| 573 | |||
| 574 | /* Initialze internal PHY, enable up to 16 PCIE lanes */ | ||
| 575 | pads_writel(0x0, PADS_CTL_SEL); | ||
| 576 | |||
| 577 | /* override IDDQ to 1 on all 4 lanes */ | ||
| 578 | val = pads_readl(PADS_CTL) | PADS_CTL_IDDQ_1L; | ||
| 579 | pads_writel(val, PADS_CTL); | ||
| 580 | |||
| 581 | /* | ||
| 582 | * set up PHY PLL inputs select PLLE output as refclock, | ||
| 583 | * set TX ref sel to div10 (not div5) | ||
| 584 | */ | ||
| 585 | val = pads_readl(PADS_PLL_CTL); | ||
| 586 | val &= ~(PADS_PLL_CTL_REFCLK_MASK | PADS_PLL_CTL_TXCLKREF_MASK); | ||
| 587 | val |= (PADS_PLL_CTL_REFCLK_INTERNAL_CML | PADS_PLL_CTL_TXCLKREF_DIV10); | ||
| 588 | pads_writel(val, PADS_PLL_CTL); | ||
| 589 | |||
| 590 | /* take PLL out of reset */ | ||
| 591 | val = pads_readl(PADS_PLL_CTL) | PADS_PLL_CTL_RST_B4SM; | ||
| 592 | pads_writel(val, PADS_PLL_CTL); | ||
| 593 | |||
| 594 | /* | ||
| 595 | * Hack, set the clock voltage to the DEFAULT provided by hw folks. | ||
| 596 | * This doesn't exist in the documentation | ||
| 597 | */ | ||
| 598 | pads_writel(0xfa5cfa5c, 0xc8); | ||
| 599 | |||
| 600 | /* Wait for the PLL to lock */ | ||
| 601 | timeout = 300; | ||
| 602 | do { | ||
| 603 | val = pads_readl(PADS_PLL_CTL); | ||
| 604 | usleep_range(1000, 1000); | ||
| 605 | if (--timeout == 0) { | ||
| 606 | pr_err("Tegra PCIe error: timeout waiting for PLL\n"); | ||
| 607 | return -EBUSY; | ||
| 608 | } | ||
| 609 | } while (!(val & PADS_PLL_CTL_LOCKDET)); | ||
| 610 | |||
| 611 | /* turn off IDDQ override */ | ||
| 612 | val = pads_readl(PADS_CTL) & ~PADS_CTL_IDDQ_1L; | ||
| 613 | pads_writel(val, PADS_CTL); | ||
| 614 | |||
| 615 | /* enable TX/RX data */ | ||
| 616 | val = pads_readl(PADS_CTL); | ||
| 617 | val |= (PADS_CTL_TX_DATA_EN_1L | PADS_CTL_RX_DATA_EN_1L); | ||
| 618 | pads_writel(val, PADS_CTL); | ||
| 619 | |||
| 620 | /* Take the PCIe interface module out of reset */ | ||
| 621 | tegra_periph_reset_deassert(tegra_pcie.pcie_xclk); | ||
| 622 | |||
| 623 | /* Finally enable PCIe */ | ||
| 624 | val = afi_readl(AFI_CONFIGURATION) | AFI_CONFIGURATION_EN_FPCI; | ||
| 625 | afi_writel(val, AFI_CONFIGURATION); | ||
| 626 | |||
| 627 | val = (AFI_INTR_EN_INI_SLVERR | AFI_INTR_EN_INI_DECERR | | ||
| 628 | AFI_INTR_EN_TGT_SLVERR | AFI_INTR_EN_TGT_DECERR | | ||
| 629 | AFI_INTR_EN_TGT_WRERR | AFI_INTR_EN_DFPCI_DECERR); | ||
| 630 | afi_writel(val, AFI_AFI_INTR_ENABLE); | ||
| 631 | afi_writel(0xffffffff, AFI_SM_INTR_ENABLE); | ||
| 632 | |||
| 633 | /* FIXME: No MSI for now, only INT */ | ||
| 634 | afi_writel(AFI_INTR_MASK_INT_MASK, AFI_INTR_MASK); | ||
| 635 | |||
| 636 | /* Disable all execptions */ | ||
| 637 | afi_writel(0, AFI_FPCI_ERROR_MASKS); | ||
| 638 | |||
| 639 | return 0; | ||
| 640 | } | ||
| 641 | |||
| 642 | static void tegra_pcie_xclk_clamp(bool clamp) | ||
| 643 | { | ||
| 644 | u32 reg; | ||
| 645 | |||
| 646 | reg = pmc_readl(PMC_SCRATCH42) & ~PMC_SCRATCH42_PCX_CLAMP; | ||
| 647 | |||
| 648 | if (clamp) | ||
| 649 | reg |= PMC_SCRATCH42_PCX_CLAMP; | ||
| 650 | |||
| 651 | pmc_writel(reg, PMC_SCRATCH42); | ||
| 652 | } | ||
| 653 | |||
| 654 | static void tegra_pcie_power_off(void) | ||
| 655 | { | ||
| 656 | tegra_periph_reset_assert(tegra_pcie.pcie_xclk); | ||
| 657 | tegra_periph_reset_assert(tegra_pcie.afi_clk); | ||
| 658 | tegra_periph_reset_assert(tegra_pcie.pex_clk); | ||
| 659 | |||
| 660 | tegra_powergate_power_off(TEGRA_POWERGATE_PCIE); | ||
| 661 | tegra_pcie_xclk_clamp(true); | ||
| 662 | } | ||
| 663 | |||
| 664 | static int tegra_pcie_power_regate(void) | ||
| 665 | { | ||
| 666 | int err; | ||
| 667 | |||
| 668 | tegra_pcie_power_off(); | ||
| 669 | |||
| 670 | tegra_pcie_xclk_clamp(true); | ||
| 671 | |||
| 672 | tegra_periph_reset_assert(tegra_pcie.pcie_xclk); | ||
| 673 | tegra_periph_reset_assert(tegra_pcie.afi_clk); | ||
| 674 | |||
| 675 | err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_PCIE, | ||
| 676 | tegra_pcie.pex_clk); | ||
| 677 | if (err) { | ||
| 678 | pr_err("PCIE: powerup sequence failed: %d\n", err); | ||
| 679 | return err; | ||
| 680 | } | ||
| 681 | |||
| 682 | tegra_periph_reset_deassert(tegra_pcie.afi_clk); | ||
| 683 | |||
| 684 | tegra_pcie_xclk_clamp(false); | ||
| 685 | |||
| 686 | clk_prepare_enable(tegra_pcie.afi_clk); | ||
| 687 | clk_prepare_enable(tegra_pcie.pex_clk); | ||
| 688 | return clk_prepare_enable(tegra_pcie.pll_e); | ||
| 689 | } | ||
| 690 | |||
| 691 | static int tegra_pcie_clocks_get(void) | ||
| 692 | { | ||
| 693 | int err; | ||
| 694 | |||
| 695 | tegra_pcie.pex_clk = clk_get(NULL, "pex"); | ||
| 696 | if (IS_ERR(tegra_pcie.pex_clk)) | ||
| 697 | return PTR_ERR(tegra_pcie.pex_clk); | ||
| 698 | |||
| 699 | tegra_pcie.afi_clk = clk_get(NULL, "afi"); | ||
| 700 | if (IS_ERR(tegra_pcie.afi_clk)) { | ||
| 701 | err = PTR_ERR(tegra_pcie.afi_clk); | ||
| 702 | goto err_afi_clk; | ||
| 703 | } | ||
| 704 | |||
| 705 | tegra_pcie.pcie_xclk = clk_get(NULL, "pcie_xclk"); | ||
| 706 | if (IS_ERR(tegra_pcie.pcie_xclk)) { | ||
| 707 | err = PTR_ERR(tegra_pcie.pcie_xclk); | ||
| 708 | goto err_pcie_xclk; | ||
| 709 | } | ||
| 710 | |||
| 711 | tegra_pcie.pll_e = clk_get_sys(NULL, "pll_e"); | ||
| 712 | if (IS_ERR(tegra_pcie.pll_e)) { | ||
| 713 | err = PTR_ERR(tegra_pcie.pll_e); | ||
| 714 | goto err_pll_e; | ||
| 715 | } | ||
| 716 | |||
| 717 | return 0; | ||
| 718 | |||
| 719 | err_pll_e: | ||
| 720 | clk_put(tegra_pcie.pcie_xclk); | ||
| 721 | err_pcie_xclk: | ||
| 722 | clk_put(tegra_pcie.afi_clk); | ||
| 723 | err_afi_clk: | ||
| 724 | clk_put(tegra_pcie.pex_clk); | ||
| 725 | |||
| 726 | return err; | ||
| 727 | } | ||
| 728 | |||
| 729 | static void tegra_pcie_clocks_put(void) | ||
| 730 | { | ||
| 731 | clk_put(tegra_pcie.pll_e); | ||
| 732 | clk_put(tegra_pcie.pcie_xclk); | ||
| 733 | clk_put(tegra_pcie.afi_clk); | ||
| 734 | clk_put(tegra_pcie.pex_clk); | ||
| 735 | } | ||
| 736 | |||
| 737 | static int __init tegra_pcie_get_resources(void) | ||
| 738 | { | ||
| 739 | int err; | ||
| 740 | |||
| 741 | err = tegra_pcie_clocks_get(); | ||
| 742 | if (err) { | ||
| 743 | pr_err("PCIE: failed to get clocks: %d\n", err); | ||
| 744 | return err; | ||
| 745 | } | ||
| 746 | |||
| 747 | err = tegra_pcie_power_regate(); | ||
| 748 | if (err) { | ||
| 749 | pr_err("PCIE: failed to power up: %d\n", err); | ||
| 750 | goto err_pwr_on; | ||
| 751 | } | ||
| 752 | |||
| 753 | tegra_pcie.regs = ioremap_nocache(TEGRA_PCIE_BASE, PCIE_IOMAP_SZ); | ||
| 754 | if (tegra_pcie.regs == NULL) { | ||
| 755 | pr_err("PCIE: Failed to map PCI/AFI registers\n"); | ||
| 756 | err = -ENOMEM; | ||
| 757 | goto err_map_reg; | ||
| 758 | } | ||
| 759 | |||
| 760 | err = request_irq(INT_PCIE_INTR, tegra_pcie_isr, | ||
| 761 | IRQF_SHARED, "PCIE", &tegra_pcie); | ||
| 762 | if (err) { | ||
| 763 | pr_err("PCIE: Failed to register IRQ: %d\n", err); | ||
| 764 | goto err_req_io; | ||
| 765 | } | ||
| 766 | set_irq_flags(INT_PCIE_INTR, IRQF_VALID); | ||
| 767 | |||
| 768 | return 0; | ||
| 769 | |||
| 770 | err_req_io: | ||
| 771 | iounmap(tegra_pcie.regs); | ||
| 772 | err_map_reg: | ||
| 773 | tegra_pcie_power_off(); | ||
| 774 | err_pwr_on: | ||
| 775 | tegra_pcie_clocks_put(); | ||
| 776 | |||
| 777 | return err; | ||
| 778 | } | ||
| 779 | |||
| 780 | /* | ||
| 781 | * FIXME: If there are no PCIe cards attached, then calling this function | ||
| 782 | * can result in the increase of the bootup time as there are big timeout | ||
| 783 | * loops. | ||
| 784 | */ | ||
| 785 | #define TEGRA_PCIE_LINKUP_TIMEOUT 200 /* up to 1.2 seconds */ | ||
| 786 | static bool tegra_pcie_check_link(struct tegra_pcie_port *pp, int idx, | ||
| 787 | u32 reset_reg) | ||
| 788 | { | ||
| 789 | u32 reg; | ||
| 790 | int retries = 3; | ||
| 791 | int timeout; | ||
| 792 | |||
| 793 | do { | ||
| 794 | timeout = TEGRA_PCIE_LINKUP_TIMEOUT; | ||
| 795 | while (timeout) { | ||
| 796 | reg = readl(pp->base + RP_VEND_XP); | ||
| 797 | |||
| 798 | if (reg & RP_VEND_XP_DL_UP) | ||
| 799 | break; | ||
| 800 | |||
| 801 | mdelay(1); | ||
| 802 | timeout--; | ||
| 803 | } | ||
| 804 | |||
| 805 | if (!timeout) { | ||
| 806 | pr_err("PCIE: port %d: link down, retrying\n", idx); | ||
| 807 | goto retry; | ||
| 808 | } | ||
| 809 | |||
| 810 | timeout = TEGRA_PCIE_LINKUP_TIMEOUT; | ||
| 811 | while (timeout) { | ||
| 812 | reg = readl(pp->base + RP_LINK_CONTROL_STATUS); | ||
| 813 | |||
| 814 | if (reg & 0x20000000) | ||
| 815 | return true; | ||
| 816 | |||
| 817 | mdelay(1); | ||
| 818 | timeout--; | ||
| 819 | } | ||
| 820 | |||
| 821 | retry: | ||
| 822 | /* Pulse the PEX reset */ | ||
| 823 | reg = afi_readl(reset_reg) | AFI_PEX_CTRL_RST; | ||
| 824 | afi_writel(reg, reset_reg); | ||
| 825 | mdelay(1); | ||
| 826 | reg = afi_readl(reset_reg) & ~AFI_PEX_CTRL_RST; | ||
| 827 | afi_writel(reg, reset_reg); | ||
| 828 | |||
| 829 | retries--; | ||
| 830 | } while (retries); | ||
| 831 | |||
| 832 | return false; | ||
| 833 | } | ||
| 834 | |||
| 835 | static void __init tegra_pcie_add_port(int index, u32 offset, u32 reset_reg) | ||
| 836 | { | ||
| 837 | struct tegra_pcie_port *pp; | ||
| 838 | |||
| 839 | pp = tegra_pcie.port + tegra_pcie.num_ports; | ||
| 840 | |||
| 841 | pp->index = -1; | ||
| 842 | pp->base = tegra_pcie.regs + offset; | ||
| 843 | pp->link_up = tegra_pcie_check_link(pp, index, reset_reg); | ||
| 844 | |||
| 845 | if (!pp->link_up) { | ||
| 846 | pp->base = NULL; | ||
| 847 | printk(KERN_INFO "PCIE: port %d: link down, ignoring\n", index); | ||
| 848 | return; | ||
| 849 | } | ||
| 850 | |||
| 851 | tegra_pcie.num_ports++; | ||
| 852 | pp->index = index; | ||
| 853 | pp->root_bus_nr = -1; | ||
| 854 | memset(pp->res, 0, sizeof(pp->res)); | ||
| 855 | } | ||
| 856 | |||
| 857 | int __init tegra_pcie_init(bool init_port0, bool init_port1) | ||
| 858 | { | ||
| 859 | int err; | ||
| 860 | |||
| 861 | if (!(init_port0 || init_port1)) | ||
| 862 | return -ENODEV; | ||
| 863 | |||
| 864 | pcibios_min_mem = 0; | ||
| 865 | |||
| 866 | err = tegra_pcie_get_resources(); | ||
| 867 | if (err) | ||
| 868 | return err; | ||
| 869 | |||
| 870 | err = tegra_pcie_enable_controller(); | ||
| 871 | if (err) | ||
| 872 | return err; | ||
| 873 | |||
| 874 | /* setup the AFI address translations */ | ||
| 875 | tegra_pcie_setup_translations(); | ||
| 876 | |||
| 877 | if (init_port0) | ||
| 878 | tegra_pcie_add_port(0, RP0_OFFSET, AFI_PEX0_CTRL); | ||
| 879 | |||
| 880 | if (init_port1) | ||
| 881 | tegra_pcie_add_port(1, RP1_OFFSET, AFI_PEX1_CTRL); | ||
| 882 | |||
| 883 | pci_common_init(&tegra_pcie_hw); | ||
| 884 | |||
| 885 | return 0; | ||
| 886 | } | ||
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c index 97b33a2a2d75..2d0203627fbb 100644 --- a/arch/arm/mach-tegra/platsmp.c +++ b/arch/arm/mach-tegra/platsmp.c | |||
| @@ -196,6 +196,5 @@ struct smp_operations tegra_smp_ops __initdata = { | |||
| 196 | #ifdef CONFIG_HOTPLUG_CPU | 196 | #ifdef CONFIG_HOTPLUG_CPU |
| 197 | .cpu_kill = tegra_cpu_kill, | 197 | .cpu_kill = tegra_cpu_kill, |
| 198 | .cpu_die = tegra_cpu_die, | 198 | .cpu_die = tegra_cpu_die, |
| 199 | .cpu_disable = tegra_cpu_disable, | ||
| 200 | #endif | 199 | #endif |
| 201 | }; | 200 | }; |
diff --git a/arch/arm/mach-tegra/pm-tegra20.c b/arch/arm/mach-tegra/pm-tegra20.c new file mode 100644 index 000000000000..d65e1d786400 --- /dev/null +++ b/arch/arm/mach-tegra/pm-tegra20.c | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2013, NVIDIA Corporation. All rights reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | |||
| 18 | #include "pm.h" | ||
| 19 | |||
| 20 | #ifdef CONFIG_PM_SLEEP | ||
| 21 | extern u32 tegra20_iram_start, tegra20_iram_end; | ||
| 22 | extern void tegra20_sleep_core_finish(unsigned long); | ||
| 23 | |||
| 24 | void tegra20_lp1_iram_hook(void) | ||
| 25 | { | ||
| 26 | tegra_lp1_iram.start_addr = &tegra20_iram_start; | ||
| 27 | tegra_lp1_iram.end_addr = &tegra20_iram_end; | ||
| 28 | } | ||
| 29 | |||
| 30 | void tegra20_sleep_core_init(void) | ||
| 31 | { | ||
| 32 | tegra_sleep_core_finish = tegra20_sleep_core_finish; | ||
| 33 | } | ||
| 34 | #endif | ||
diff --git a/arch/arm/mach-tegra/pm-tegra30.c b/arch/arm/mach-tegra/pm-tegra30.c new file mode 100644 index 000000000000..8fa326d6ff1a --- /dev/null +++ b/arch/arm/mach-tegra/pm-tegra30.c | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2013, NVIDIA Corporation. All rights reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | |||
| 18 | #include "pm.h" | ||
| 19 | |||
| 20 | #ifdef CONFIG_PM_SLEEP | ||
| 21 | extern u32 tegra30_iram_start, tegra30_iram_end; | ||
| 22 | extern void tegra30_sleep_core_finish(unsigned long); | ||
| 23 | |||
| 24 | void tegra30_lp1_iram_hook(void) | ||
| 25 | { | ||
| 26 | tegra_lp1_iram.start_addr = &tegra30_iram_start; | ||
| 27 | tegra_lp1_iram.end_addr = &tegra30_iram_end; | ||
| 28 | } | ||
| 29 | |||
| 30 | void tegra30_sleep_core_init(void) | ||
| 31 | { | ||
| 32 | tegra_sleep_core_finish = tegra30_sleep_core_finish; | ||
| 33 | } | ||
| 34 | #endif | ||
diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 261fec140c06..ed294a04e1d3 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c | |||
| @@ -37,12 +37,18 @@ | |||
| 37 | #include "reset.h" | 37 | #include "reset.h" |
| 38 | #include "flowctrl.h" | 38 | #include "flowctrl.h" |
| 39 | #include "fuse.h" | 39 | #include "fuse.h" |
| 40 | #include "pm.h" | ||
| 40 | #include "pmc.h" | 41 | #include "pmc.h" |
| 41 | #include "sleep.h" | 42 | #include "sleep.h" |
| 42 | 43 | ||
| 43 | #ifdef CONFIG_PM_SLEEP | 44 | #ifdef CONFIG_PM_SLEEP |
| 44 | static DEFINE_SPINLOCK(tegra_lp2_lock); | 45 | static DEFINE_SPINLOCK(tegra_lp2_lock); |
| 46 | static u32 iram_save_size; | ||
| 47 | static void *iram_save_addr; | ||
| 48 | struct tegra_lp1_iram tegra_lp1_iram; | ||
| 45 | void (*tegra_tear_down_cpu)(void); | 49 | void (*tegra_tear_down_cpu)(void); |
| 50 | void (*tegra_sleep_core_finish)(unsigned long v2p); | ||
| 51 | static int (*tegra_sleep_func)(unsigned long v2p); | ||
| 46 | 52 | ||
| 47 | static void tegra_tear_down_cpu_init(void) | 53 | static void tegra_tear_down_cpu_init(void) |
| 48 | { | 54 | { |
| @@ -52,7 +58,9 @@ static void tegra_tear_down_cpu_init(void) | |||
| 52 | tegra_tear_down_cpu = tegra20_tear_down_cpu; | 58 | tegra_tear_down_cpu = tegra20_tear_down_cpu; |
| 53 | break; | 59 | break; |
| 54 | case TEGRA30: | 60 | case TEGRA30: |
| 55 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC)) | 61 | case TEGRA114: |
| 62 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || | ||
| 63 | IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC)) | ||
| 56 | tegra_tear_down_cpu = tegra30_tear_down_cpu; | 64 | tegra_tear_down_cpu = tegra30_tear_down_cpu; |
| 57 | break; | 65 | break; |
| 58 | } | 66 | } |
| @@ -171,19 +179,109 @@ void tegra_idle_lp2_last(void) | |||
| 171 | enum tegra_suspend_mode tegra_pm_validate_suspend_mode( | 179 | enum tegra_suspend_mode tegra_pm_validate_suspend_mode( |
| 172 | enum tegra_suspend_mode mode) | 180 | enum tegra_suspend_mode mode) |
| 173 | { | 181 | { |
| 174 | /* Tegra114 didn't support any suspending mode yet. */ | ||
| 175 | if (tegra_chip_id == TEGRA114) | ||
| 176 | return TEGRA_SUSPEND_NONE; | ||
| 177 | |||
| 178 | /* | 182 | /* |
| 179 | * The Tegra devices only support suspending to LP2 currently. | 183 | * The Tegra devices support suspending to LP1 or lower currently. |
| 180 | */ | 184 | */ |
| 181 | if (mode > TEGRA_SUSPEND_LP2) | 185 | if (mode > TEGRA_SUSPEND_LP1) |
| 182 | return TEGRA_SUSPEND_LP2; | 186 | return TEGRA_SUSPEND_LP1; |
| 183 | 187 | ||
| 184 | return mode; | 188 | return mode; |
| 185 | } | 189 | } |
| 186 | 190 | ||
| 191 | static int tegra_sleep_core(unsigned long v2p) | ||
| 192 | { | ||
| 193 | setup_mm_for_reboot(); | ||
| 194 | tegra_sleep_core_finish(v2p); | ||
| 195 | |||
| 196 | /* should never here */ | ||
| 197 | BUG(); | ||
| 198 | |||
| 199 | return 0; | ||
| 200 | } | ||
| 201 | |||
| 202 | /* | ||
| 203 | * tegra_lp1_iram_hook | ||
| 204 | * | ||
| 205 | * Hooking the address of LP1 reset vector and SDRAM self-refresh code in | ||
| 206 | * SDRAM. These codes not be copied to IRAM in this fuction. We need to | ||
| 207 | * copy these code to IRAM before LP0/LP1 suspend and restore the content | ||
| 208 | * of IRAM after resume. | ||
| 209 | */ | ||
| 210 | static bool tegra_lp1_iram_hook(void) | ||
| 211 | { | ||
| 212 | switch (tegra_chip_id) { | ||
| 213 | case TEGRA20: | ||
| 214 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) | ||
| 215 | tegra20_lp1_iram_hook(); | ||
| 216 | break; | ||
| 217 | case TEGRA30: | ||
| 218 | case TEGRA114: | ||
| 219 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || | ||
| 220 | IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC)) | ||
| 221 | tegra30_lp1_iram_hook(); | ||
| 222 | break; | ||
| 223 | default: | ||
| 224 | break; | ||
| 225 | } | ||
| 226 | |||
| 227 | if (!tegra_lp1_iram.start_addr || !tegra_lp1_iram.end_addr) | ||
| 228 | return false; | ||
| 229 | |||
| 230 | iram_save_size = tegra_lp1_iram.end_addr - tegra_lp1_iram.start_addr; | ||
| 231 | iram_save_addr = kmalloc(iram_save_size, GFP_KERNEL); | ||
| 232 | if (!iram_save_addr) | ||
| 233 | return false; | ||
| 234 | |||
| 235 | return true; | ||
| 236 | } | ||
| 237 | |||
| 238 | static bool tegra_sleep_core_init(void) | ||
| 239 | { | ||
| 240 | switch (tegra_chip_id) { | ||
| 241 | case TEGRA20: | ||
| 242 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) | ||
| 243 | tegra20_sleep_core_init(); | ||
| 244 | break; | ||
| 245 | case TEGRA30: | ||
| 246 | case TEGRA114: | ||
| 247 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) || | ||
| 248 | IS_ENABLED(CONFIG_ARCH_TEGRA_114_SOC)) | ||
| 249 | tegra30_sleep_core_init(); | ||
| 250 | break; | ||
| 251 | default: | ||
| 252 | break; | ||
| 253 | } | ||
| 254 | |||
| 255 | if (!tegra_sleep_core_finish) | ||
| 256 | return false; | ||
| 257 | |||
| 258 | return true; | ||
| 259 | } | ||
| 260 | |||
| 261 | static void tegra_suspend_enter_lp1(void) | ||
| 262 | { | ||
| 263 | tegra_pmc_suspend(); | ||
| 264 | |||
| 265 | /* copy the reset vector & SDRAM shutdown code into IRAM */ | ||
| 266 | memcpy(iram_save_addr, IO_ADDRESS(TEGRA_IRAM_CODE_AREA), | ||
| 267 | iram_save_size); | ||
| 268 | memcpy(IO_ADDRESS(TEGRA_IRAM_CODE_AREA), tegra_lp1_iram.start_addr, | ||
| 269 | iram_save_size); | ||
| 270 | |||
| 271 | *((u32 *)tegra_cpu_lp1_mask) = 1; | ||
| 272 | } | ||
| 273 | |||
| 274 | static void tegra_suspend_exit_lp1(void) | ||
| 275 | { | ||
| 276 | tegra_pmc_resume(); | ||
| 277 | |||
| 278 | /* restore IRAM */ | ||
| 279 | memcpy(IO_ADDRESS(TEGRA_IRAM_CODE_AREA), iram_save_addr, | ||
| 280 | iram_save_size); | ||
| 281 | |||
| 282 | *(u32 *)tegra_cpu_lp1_mask = 0; | ||
| 283 | } | ||
| 284 | |||
| 187 | static const char *lp_state[TEGRA_MAX_SUSPEND_MODE] = { | 285 | static const char *lp_state[TEGRA_MAX_SUSPEND_MODE] = { |
| 188 | [TEGRA_SUSPEND_NONE] = "none", | 286 | [TEGRA_SUSPEND_NONE] = "none", |
| 189 | [TEGRA_SUSPEND_LP2] = "LP2", | 287 | [TEGRA_SUSPEND_LP2] = "LP2", |
| @@ -207,6 +305,9 @@ static int tegra_suspend_enter(suspend_state_t state) | |||
| 207 | 305 | ||
| 208 | suspend_cpu_complex(); | 306 | suspend_cpu_complex(); |
| 209 | switch (mode) { | 307 | switch (mode) { |
| 308 | case TEGRA_SUSPEND_LP1: | ||
| 309 | tegra_suspend_enter_lp1(); | ||
| 310 | break; | ||
| 210 | case TEGRA_SUSPEND_LP2: | 311 | case TEGRA_SUSPEND_LP2: |
| 211 | tegra_set_cpu_in_lp2(); | 312 | tegra_set_cpu_in_lp2(); |
| 212 | break; | 313 | break; |
| @@ -214,9 +315,12 @@ static int tegra_suspend_enter(suspend_state_t state) | |||
| 214 | break; | 315 | break; |
| 215 | } | 316 | } |
| 216 | 317 | ||
| 217 | cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); | 318 | cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, tegra_sleep_func); |
| 218 | 319 | ||
| 219 | switch (mode) { | 320 | switch (mode) { |
| 321 | case TEGRA_SUSPEND_LP1: | ||
| 322 | tegra_suspend_exit_lp1(); | ||
| 323 | break; | ||
| 220 | case TEGRA_SUSPEND_LP2: | 324 | case TEGRA_SUSPEND_LP2: |
| 221 | tegra_clear_cpu_in_lp2(); | 325 | tegra_clear_cpu_in_lp2(); |
| 222 | break; | 326 | break; |
| @@ -237,12 +341,36 @@ static const struct platform_suspend_ops tegra_suspend_ops = { | |||
| 237 | 341 | ||
| 238 | void __init tegra_init_suspend(void) | 342 | void __init tegra_init_suspend(void) |
| 239 | { | 343 | { |
| 240 | if (tegra_pmc_get_suspend_mode() == TEGRA_SUSPEND_NONE) | 344 | enum tegra_suspend_mode mode = tegra_pmc_get_suspend_mode(); |
| 345 | |||
| 346 | if (mode == TEGRA_SUSPEND_NONE) | ||
| 241 | return; | 347 | return; |
| 242 | 348 | ||
| 243 | tegra_tear_down_cpu_init(); | 349 | tegra_tear_down_cpu_init(); |
| 244 | tegra_pmc_suspend_init(); | 350 | tegra_pmc_suspend_init(); |
| 245 | 351 | ||
| 352 | if (mode >= TEGRA_SUSPEND_LP1) { | ||
| 353 | if (!tegra_lp1_iram_hook() || !tegra_sleep_core_init()) { | ||
| 354 | pr_err("%s: unable to allocate memory for SDRAM" | ||
| 355 | "self-refresh -- LP0/LP1 unavailable\n", | ||
| 356 | __func__); | ||
| 357 | tegra_pmc_set_suspend_mode(TEGRA_SUSPEND_LP2); | ||
| 358 | mode = TEGRA_SUSPEND_LP2; | ||
| 359 | } | ||
| 360 | } | ||
| 361 | |||
| 362 | /* set up sleep function for cpu_suspend */ | ||
| 363 | switch (mode) { | ||
| 364 | case TEGRA_SUSPEND_LP1: | ||
| 365 | tegra_sleep_func = tegra_sleep_core; | ||
| 366 | break; | ||
| 367 | case TEGRA_SUSPEND_LP2: | ||
| 368 | tegra_sleep_func = tegra_sleep_cpu; | ||
| 369 | break; | ||
| 370 | default: | ||
| 371 | break; | ||
| 372 | } | ||
| 373 | |||
| 246 | suspend_set_ops(&tegra_suspend_ops); | 374 | suspend_set_ops(&tegra_suspend_ops); |
| 247 | } | 375 | } |
| 248 | #endif | 376 | #endif |
diff --git a/arch/arm/mach-tegra/pm.h b/arch/arm/mach-tegra/pm.h index 94c4b9d9077c..fe204e5256e7 100644 --- a/arch/arm/mach-tegra/pm.h +++ b/arch/arm/mach-tegra/pm.h | |||
| @@ -23,6 +23,18 @@ | |||
| 23 | 23 | ||
| 24 | #include "pmc.h" | 24 | #include "pmc.h" |
| 25 | 25 | ||
| 26 | struct tegra_lp1_iram { | ||
| 27 | void *start_addr; | ||
| 28 | void *end_addr; | ||
| 29 | }; | ||
| 30 | extern struct tegra_lp1_iram tegra_lp1_iram; | ||
| 31 | extern void (*tegra_sleep_core_finish)(unsigned long v2p); | ||
| 32 | |||
| 33 | void tegra20_lp1_iram_hook(void); | ||
| 34 | void tegra20_sleep_core_init(void); | ||
| 35 | void tegra30_lp1_iram_hook(void); | ||
| 36 | void tegra30_sleep_core_init(void); | ||
| 37 | |||
| 26 | extern unsigned long l2x0_saved_regs_addr; | 38 | extern unsigned long l2x0_saved_regs_addr; |
| 27 | 39 | ||
| 28 | void save_cpu_arch_register(void); | 40 | void save_cpu_arch_register(void); |
diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c index eb3fa4aee0e4..8acb881f7cfe 100644 --- a/arch/arm/mach-tegra/pmc.c +++ b/arch/arm/mach-tegra/pmc.c | |||
| @@ -21,11 +21,14 @@ | |||
| 21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
| 22 | #include <linux/of_address.h> | 22 | #include <linux/of_address.h> |
| 23 | 23 | ||
| 24 | #include "flowctrl.h" | ||
| 24 | #include "fuse.h" | 25 | #include "fuse.h" |
| 25 | #include "pm.h" | 26 | #include "pm.h" |
| 26 | #include "pmc.h" | 27 | #include "pmc.h" |
| 27 | #include "sleep.h" | 28 | #include "sleep.h" |
| 28 | 29 | ||
| 30 | #define TEGRA_POWER_SYSCLK_POLARITY (1 << 10) /* sys clk polarity */ | ||
| 31 | #define TEGRA_POWER_SYSCLK_OE (1 << 11) /* system clock enable */ | ||
| 29 | #define TEGRA_POWER_EFFECT_LP0 (1 << 14) /* LP0 when CPU pwr gated */ | 32 | #define TEGRA_POWER_EFFECT_LP0 (1 << 14) /* LP0 when CPU pwr gated */ |
| 30 | #define TEGRA_POWER_CPU_PWRREQ_POLARITY (1 << 15) /* CPU pwr req polarity */ | 33 | #define TEGRA_POWER_CPU_PWRREQ_POLARITY (1 << 15) /* CPU pwr req polarity */ |
| 31 | #define TEGRA_POWER_CPU_PWRREQ_OE (1 << 16) /* CPU pwr req enable */ | 34 | #define TEGRA_POWER_CPU_PWRREQ_OE (1 << 16) /* CPU pwr req enable */ |
| @@ -193,16 +196,50 @@ enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void) | |||
| 193 | return pmc_pm_data.suspend_mode; | 196 | return pmc_pm_data.suspend_mode; |
| 194 | } | 197 | } |
| 195 | 198 | ||
| 199 | void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode) | ||
| 200 | { | ||
| 201 | if (mode < TEGRA_SUSPEND_NONE || mode >= TEGRA_MAX_SUSPEND_MODE) | ||
| 202 | return; | ||
| 203 | |||
| 204 | pmc_pm_data.suspend_mode = mode; | ||
| 205 | } | ||
| 206 | |||
| 207 | void tegra_pmc_suspend(void) | ||
| 208 | { | ||
| 209 | tegra_pmc_writel(virt_to_phys(tegra_resume), PMC_SCRATCH41); | ||
| 210 | } | ||
| 211 | |||
| 212 | void tegra_pmc_resume(void) | ||
| 213 | { | ||
| 214 | tegra_pmc_writel(0x0, PMC_SCRATCH41); | ||
| 215 | } | ||
| 216 | |||
| 196 | void tegra_pmc_pm_set(enum tegra_suspend_mode mode) | 217 | void tegra_pmc_pm_set(enum tegra_suspend_mode mode) |
| 197 | { | 218 | { |
| 198 | u32 reg; | 219 | u32 reg, csr_reg; |
| 199 | unsigned long rate = 0; | 220 | unsigned long rate = 0; |
| 200 | 221 | ||
| 201 | reg = tegra_pmc_readl(PMC_CTRL); | 222 | reg = tegra_pmc_readl(PMC_CTRL); |
| 202 | reg |= TEGRA_POWER_CPU_PWRREQ_OE; | 223 | reg |= TEGRA_POWER_CPU_PWRREQ_OE; |
| 203 | reg &= ~TEGRA_POWER_EFFECT_LP0; | 224 | reg &= ~TEGRA_POWER_EFFECT_LP0; |
| 204 | 225 | ||
| 226 | switch (tegra_chip_id) { | ||
| 227 | case TEGRA20: | ||
| 228 | case TEGRA30: | ||
| 229 | break; | ||
| 230 | default: | ||
| 231 | /* Turn off CRAIL */ | ||
| 232 | csr_reg = flowctrl_read_cpu_csr(0); | ||
| 233 | csr_reg &= ~FLOW_CTRL_CSR_ENABLE_EXT_MASK; | ||
| 234 | csr_reg |= FLOW_CTRL_CSR_ENABLE_EXT_CRAIL; | ||
| 235 | flowctrl_write_cpu_csr(0, csr_reg); | ||
| 236 | break; | ||
| 237 | } | ||
| 238 | |||
| 205 | switch (mode) { | 239 | switch (mode) { |
| 240 | case TEGRA_SUSPEND_LP1: | ||
| 241 | rate = 32768; | ||
| 242 | break; | ||
| 206 | case TEGRA_SUSPEND_LP2: | 243 | case TEGRA_SUSPEND_LP2: |
| 207 | rate = clk_get_rate(tegra_pclk); | 244 | rate = clk_get_rate(tegra_pclk); |
| 208 | break; | 245 | break; |
| @@ -224,6 +261,20 @@ void tegra_pmc_suspend_init(void) | |||
| 224 | reg = tegra_pmc_readl(PMC_CTRL); | 261 | reg = tegra_pmc_readl(PMC_CTRL); |
| 225 | reg |= TEGRA_POWER_CPU_PWRREQ_OE; | 262 | reg |= TEGRA_POWER_CPU_PWRREQ_OE; |
| 226 | tegra_pmc_writel(reg, PMC_CTRL); | 263 | tegra_pmc_writel(reg, PMC_CTRL); |
| 264 | |||
| 265 | reg = tegra_pmc_readl(PMC_CTRL); | ||
| 266 | |||
| 267 | if (!pmc_pm_data.sysclkreq_high) | ||
| 268 | reg |= TEGRA_POWER_SYSCLK_POLARITY; | ||
| 269 | else | ||
| 270 | reg &= ~TEGRA_POWER_SYSCLK_POLARITY; | ||
| 271 | |||
| 272 | /* configure the output polarity while the request is tristated */ | ||
| 273 | tegra_pmc_writel(reg, PMC_CTRL); | ||
| 274 | |||
| 275 | /* now enable the request */ | ||
| 276 | reg |= TEGRA_POWER_SYSCLK_OE; | ||
| 277 | tegra_pmc_writel(reg, PMC_CTRL); | ||
| 227 | } | 278 | } |
| 228 | #endif | 279 | #endif |
| 229 | 280 | ||
diff --git a/arch/arm/mach-tegra/pmc.h b/arch/arm/mach-tegra/pmc.h index e1c2df272f7d..549f8c7b762c 100644 --- a/arch/arm/mach-tegra/pmc.h +++ b/arch/arm/mach-tegra/pmc.h | |||
| @@ -28,6 +28,9 @@ enum tegra_suspend_mode { | |||
| 28 | 28 | ||
| 29 | #ifdef CONFIG_PM_SLEEP | 29 | #ifdef CONFIG_PM_SLEEP |
| 30 | enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void); | 30 | enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void); |
| 31 | void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode); | ||
| 32 | void tegra_pmc_suspend(void); | ||
| 33 | void tegra_pmc_resume(void); | ||
| 31 | void tegra_pmc_pm_set(enum tegra_suspend_mode mode); | 34 | void tegra_pmc_pm_set(enum tegra_suspend_mode mode); |
| 32 | void tegra_pmc_suspend_init(void); | 35 | void tegra_pmc_suspend_init(void); |
| 33 | #endif | 36 | #endif |
diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 39dc9e7834f3..f527b2c2dea7 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S | |||
| @@ -40,9 +40,12 @@ | |||
| 40 | * re-enabling sdram. | 40 | * re-enabling sdram. |
| 41 | * | 41 | * |
| 42 | * r6: SoC ID | 42 | * r6: SoC ID |
| 43 | * r8: CPU part number | ||
| 43 | */ | 44 | */ |
| 44 | ENTRY(tegra_resume) | 45 | ENTRY(tegra_resume) |
| 45 | bl v7_invalidate_l1 | 46 | check_cpu_part_num 0xc09, r8, r9 |
| 47 | bleq v7_invalidate_l1 | ||
| 48 | blne tegra_init_l2_for_a15 | ||
| 46 | 49 | ||
| 47 | cpu_id r0 | 50 | cpu_id r0 |
| 48 | tegra_get_soc_id TEGRA_APB_MISC_BASE, r6 | 51 | tegra_get_soc_id TEGRA_APB_MISC_BASE, r6 |
| @@ -70,7 +73,8 @@ no_cpu0_chk: | |||
| 70 | str r1, [r2] | 73 | str r1, [r2] |
| 71 | 1: | 74 | 1: |
| 72 | 75 | ||
| 73 | check_cpu_part_num 0xc09, r8, r9 | 76 | mov32 r9, 0xc09 |
| 77 | cmp r8, r9 | ||
| 74 | bne not_ca9 | 78 | bne not_ca9 |
| 75 | #ifdef CONFIG_HAVE_ARM_SCU | 79 | #ifdef CONFIG_HAVE_ARM_SCU |
| 76 | /* enable SCU */ | 80 | /* enable SCU */ |
| @@ -178,6 +182,19 @@ after_errata: | |||
| 178 | 1: | 182 | 1: |
| 179 | #endif | 183 | #endif |
| 180 | 184 | ||
| 185 | /* Waking up from LP1? */ | ||
| 186 | ldr r8, [r12, #RESET_DATA(MASK_LP1)] | ||
| 187 | tst r8, r11 @ if in_lp1 | ||
| 188 | beq __is_not_lp1 | ||
| 189 | cmp r10, #0 | ||
| 190 | bne __die @ only CPU0 can be here | ||
| 191 | ldr lr, [r12, #RESET_DATA(STARTUP_LP1)] | ||
| 192 | cmp lr, #0 | ||
| 193 | bleq __die @ no LP1 startup handler | ||
| 194 | THUMB( add lr, lr, #1 ) @ switch to Thumb mode | ||
| 195 | bx lr | ||
| 196 | __is_not_lp1: | ||
| 197 | |||
| 181 | /* Waking up from LP2? */ | 198 | /* Waking up from LP2? */ |
| 182 | ldr r9, [r12, #RESET_DATA(MASK_LP2)] | 199 | ldr r9, [r12, #RESET_DATA(MASK_LP2)] |
| 183 | tst r9, r11 @ if in_lp2 | 200 | tst r9, r11 @ if in_lp2 |
diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c index 1ac434e0068f..fd0bbf8a6c94 100644 --- a/arch/arm/mach-tegra/reset.c +++ b/arch/arm/mach-tegra/reset.c | |||
| @@ -81,6 +81,8 @@ void __init tegra_cpu_reset_handler_init(void) | |||
| 81 | #endif | 81 | #endif |
| 82 | 82 | ||
| 83 | #ifdef CONFIG_PM_SLEEP | 83 | #ifdef CONFIG_PM_SLEEP |
| 84 | __tegra_cpu_reset_handler_data[TEGRA_RESET_STARTUP_LP1] = | ||
| 85 | TEGRA_IRAM_CODE_AREA; | ||
| 84 | __tegra_cpu_reset_handler_data[TEGRA_RESET_STARTUP_LP2] = | 86 | __tegra_cpu_reset_handler_data[TEGRA_RESET_STARTUP_LP2] = |
| 85 | virt_to_phys((void *)tegra_resume); | 87 | virt_to_phys((void *)tegra_resume); |
| 86 | #endif | 88 | #endif |
diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h index c90d8e9c4ad2..76a93434c6ee 100644 --- a/arch/arm/mach-tegra/reset.h +++ b/arch/arm/mach-tegra/reset.h | |||
| @@ -39,6 +39,10 @@ void __tegra_cpu_reset_handler_end(void); | |||
| 39 | void tegra_secondary_startup(void); | 39 | void tegra_secondary_startup(void); |
| 40 | 40 | ||
| 41 | #ifdef CONFIG_PM_SLEEP | 41 | #ifdef CONFIG_PM_SLEEP |
| 42 | #define tegra_cpu_lp1_mask \ | ||
| 43 | (IO_ADDRESS(TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET + \ | ||
| 44 | ((u32)&__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_LP1] - \ | ||
| 45 | (u32)__tegra_cpu_reset_handler_start))) | ||
| 42 | #define tegra_cpu_lp2_mask \ | 46 | #define tegra_cpu_lp2_mask \ |
| 43 | (IO_ADDRESS(TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET + \ | 47 | (IO_ADDRESS(TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET + \ |
| 44 | ((u32)&__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_LP2] - \ | 48 | ((u32)&__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_LP2] - \ |
diff --git a/arch/arm/mach-tegra/sleep-tegra20.S b/arch/arm/mach-tegra/sleep-tegra20.S index e3f2417c420e..5c3bd11c9838 100644 --- a/arch/arm/mach-tegra/sleep-tegra20.S +++ b/arch/arm/mach-tegra/sleep-tegra20.S | |||
| @@ -23,10 +23,49 @@ | |||
| 23 | #include <asm/assembler.h> | 23 | #include <asm/assembler.h> |
| 24 | #include <asm/proc-fns.h> | 24 | #include <asm/proc-fns.h> |
| 25 | #include <asm/cp15.h> | 25 | #include <asm/cp15.h> |
| 26 | #include <asm/cache.h> | ||
| 26 | 27 | ||
| 27 | #include "sleep.h" | 28 | #include "sleep.h" |
| 28 | #include "flowctrl.h" | 29 | #include "flowctrl.h" |
| 29 | 30 | ||
| 31 | #define EMC_CFG 0xc | ||
| 32 | #define EMC_ADR_CFG 0x10 | ||
| 33 | #define EMC_REFRESH 0x70 | ||
| 34 | #define EMC_NOP 0xdc | ||
| 35 | #define EMC_SELF_REF 0xe0 | ||
| 36 | #define EMC_REQ_CTRL 0x2b0 | ||
| 37 | #define EMC_EMC_STATUS 0x2b4 | ||
| 38 | |||
| 39 | #define CLK_RESET_CCLK_BURST 0x20 | ||
| 40 | #define CLK_RESET_CCLK_DIVIDER 0x24 | ||
| 41 | #define CLK_RESET_SCLK_BURST 0x28 | ||
| 42 | #define CLK_RESET_SCLK_DIVIDER 0x2c | ||
| 43 | #define CLK_RESET_PLLC_BASE 0x80 | ||
| 44 | #define CLK_RESET_PLLM_BASE 0x90 | ||
| 45 | #define CLK_RESET_PLLP_BASE 0xa0 | ||
| 46 | |||
| 47 | #define APB_MISC_XM2CFGCPADCTRL 0x8c8 | ||
| 48 | #define APB_MISC_XM2CFGDPADCTRL 0x8cc | ||
| 49 | #define APB_MISC_XM2CLKCFGPADCTRL 0x8d0 | ||
| 50 | #define APB_MISC_XM2COMPPADCTRL 0x8d4 | ||
| 51 | #define APB_MISC_XM2VTTGENPADCTRL 0x8d8 | ||
| 52 | #define APB_MISC_XM2CFGCPADCTRL2 0x8e4 | ||
| 53 | #define APB_MISC_XM2CFGDPADCTRL2 0x8e8 | ||
| 54 | |||
| 55 | .macro pll_enable, rd, r_car_base, pll_base | ||
| 56 | ldr \rd, [\r_car_base, #\pll_base] | ||
| 57 | tst \rd, #(1 << 30) | ||
| 58 | orreq \rd, \rd, #(1 << 30) | ||
| 59 | streq \rd, [\r_car_base, #\pll_base] | ||
| 60 | .endm | ||
| 61 | |||
| 62 | .macro emc_device_mask, rd, base | ||
| 63 | ldr \rd, [\base, #EMC_ADR_CFG] | ||
| 64 | tst \rd, #(0x3 << 24) | ||
| 65 | moveq \rd, #(0x1 << 8) @ just 1 device | ||
| 66 | movne \rd, #(0x3 << 8) @ 2 devices | ||
| 67 | .endm | ||
| 68 | |||
| 30 | #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP) | 69 | #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP) |
| 31 | /* | 70 | /* |
| 32 | * tegra20_hotplug_shutdown(void) | 71 | * tegra20_hotplug_shutdown(void) |
| @@ -181,6 +220,28 @@ ENTRY(tegra20_cpu_is_resettable_soon) | |||
| 181 | ENDPROC(tegra20_cpu_is_resettable_soon) | 220 | ENDPROC(tegra20_cpu_is_resettable_soon) |
| 182 | 221 | ||
| 183 | /* | 222 | /* |
| 223 | * tegra20_sleep_core_finish(unsigned long v2p) | ||
| 224 | * | ||
| 225 | * Enters suspend in LP0 or LP1 by turning off the mmu and jumping to | ||
| 226 | * tegra20_tear_down_core in IRAM | ||
| 227 | */ | ||
| 228 | ENTRY(tegra20_sleep_core_finish) | ||
| 229 | /* Flush, disable the L1 data cache and exit SMP */ | ||
| 230 | bl tegra_disable_clean_inv_dcache | ||
| 231 | |||
| 232 | mov32 r3, tegra_shut_off_mmu | ||
| 233 | add r3, r3, r0 | ||
| 234 | |||
| 235 | mov32 r0, tegra20_tear_down_core | ||
| 236 | mov32 r1, tegra20_iram_start | ||
| 237 | sub r0, r0, r1 | ||
| 238 | mov32 r1, TEGRA_IRAM_CODE_AREA | ||
| 239 | add r0, r0, r1 | ||
| 240 | |||
| 241 | mov pc, r3 | ||
| 242 | ENDPROC(tegra20_sleep_core_finish) | ||
| 243 | |||
| 244 | /* | ||
| 184 | * tegra20_sleep_cpu_secondary_finish(unsigned long v2p) | 245 | * tegra20_sleep_cpu_secondary_finish(unsigned long v2p) |
| 185 | * | 246 | * |
| 186 | * Enters WFI on secondary CPU by exiting coherency. | 247 | * Enters WFI on secondary CPU by exiting coherency. |
| @@ -191,6 +252,7 @@ ENTRY(tegra20_sleep_cpu_secondary_finish) | |||
| 191 | mrc p15, 0, r11, c1, c0, 1 @ save actlr before exiting coherency | 252 | mrc p15, 0, r11, c1, c0, 1 @ save actlr before exiting coherency |
| 192 | 253 | ||
| 193 | /* Flush and disable the L1 data cache */ | 254 | /* Flush and disable the L1 data cache */ |
| 255 | mov r0, #TEGRA_FLUSH_CACHE_LOUIS | ||
| 194 | bl tegra_disable_clean_inv_dcache | 256 | bl tegra_disable_clean_inv_dcache |
| 195 | 257 | ||
| 196 | mov32 r0, TEGRA_PMC_VIRT + PMC_SCRATCH41 | 258 | mov32 r0, TEGRA_PMC_VIRT + PMC_SCRATCH41 |
| @@ -250,6 +312,150 @@ ENTRY(tegra20_tear_down_cpu) | |||
| 250 | b tegra20_enter_sleep | 312 | b tegra20_enter_sleep |
| 251 | ENDPROC(tegra20_tear_down_cpu) | 313 | ENDPROC(tegra20_tear_down_cpu) |
| 252 | 314 | ||
| 315 | /* START OF ROUTINES COPIED TO IRAM */ | ||
| 316 | .align L1_CACHE_SHIFT | ||
| 317 | .globl tegra20_iram_start | ||
| 318 | tegra20_iram_start: | ||
| 319 | |||
| 320 | /* | ||
| 321 | * tegra20_lp1_reset | ||
| 322 | * | ||
| 323 | * reset vector for LP1 restore; copied into IRAM during suspend. | ||
| 324 | * Brings the system back up to a safe staring point (SDRAM out of | ||
| 325 | * self-refresh, PLLC, PLLM and PLLP reenabled, CPU running on PLLP, | ||
| 326 | * system clock running on the same PLL that it suspended at), and | ||
| 327 | * jumps to tegra_resume to restore virtual addressing and PLLX. | ||
| 328 | * The physical address of tegra_resume expected to be stored in | ||
| 329 | * PMC_SCRATCH41. | ||
| 330 | * | ||
| 331 | * NOTE: THIS *MUST* BE RELOCATED TO TEGRA_IRAM_CODE_AREA. | ||
| 332 | */ | ||
| 333 | ENTRY(tegra20_lp1_reset) | ||
| 334 | /* | ||
| 335 | * The CPU and system bus are running at 32KHz and executing from | ||
| 336 | * IRAM when this code is executed; immediately switch to CLKM and | ||
| 337 | * enable PLLM, PLLP, PLLC. | ||
| 338 | */ | ||
| 339 | mov32 r0, TEGRA_CLK_RESET_BASE | ||
| 340 | |||
| 341 | mov r1, #(1 << 28) | ||
| 342 | str r1, [r0, #CLK_RESET_SCLK_BURST] | ||
| 343 | str r1, [r0, #CLK_RESET_CCLK_BURST] | ||
| 344 | mov r1, #0 | ||
| 345 | str r1, [r0, #CLK_RESET_CCLK_DIVIDER] | ||
| 346 | str r1, [r0, #CLK_RESET_SCLK_DIVIDER] | ||
| 347 | |||
| 348 | pll_enable r1, r0, CLK_RESET_PLLM_BASE | ||
| 349 | pll_enable r1, r0, CLK_RESET_PLLP_BASE | ||
| 350 | pll_enable r1, r0, CLK_RESET_PLLC_BASE | ||
| 351 | |||
| 352 | adr r2, tegra20_sdram_pad_address | ||
| 353 | adr r4, tegra20_sdram_pad_save | ||
| 354 | mov r5, #0 | ||
| 355 | |||
| 356 | ldr r6, tegra20_sdram_pad_size | ||
| 357 | padload: | ||
| 358 | ldr r7, [r2, r5] @ r7 is the addr in the pad_address | ||
| 359 | |||
| 360 | ldr r1, [r4, r5] | ||
| 361 | str r1, [r7] @ restore the value in pad_save | ||
| 362 | |||
| 363 | add r5, r5, #4 | ||
| 364 | cmp r6, r5 | ||
| 365 | bne padload | ||
| 366 | |||
| 367 | padload_done: | ||
| 368 | /* 255uS delay for PLL stabilization */ | ||
| 369 | mov32 r7, TEGRA_TMRUS_BASE | ||
| 370 | ldr r1, [r7] | ||
| 371 | add r1, r1, #0xff | ||
| 372 | wait_until r1, r7, r9 | ||
| 373 | |||
| 374 | adr r4, tegra20_sclk_save | ||
| 375 | ldr r4, [r4] | ||
| 376 | str r4, [r0, #CLK_RESET_SCLK_BURST] | ||
| 377 | mov32 r4, ((1 << 28) | (4)) @ burst policy is PLLP | ||
| 378 | str r4, [r0, #CLK_RESET_CCLK_BURST] | ||
| 379 | |||
| 380 | mov32 r0, TEGRA_EMC_BASE | ||
| 381 | ldr r1, [r0, #EMC_CFG] | ||
| 382 | bic r1, r1, #(1 << 31) @ disable DRAM_CLK_STOP | ||
| 383 | str r1, [r0, #EMC_CFG] | ||
| 384 | |||
| 385 | mov r1, #0 | ||
| 386 | str r1, [r0, #EMC_SELF_REF] @ take DRAM out of self refresh | ||
| 387 | mov r1, #1 | ||
| 388 | str r1, [r0, #EMC_NOP] | ||
| 389 | str r1, [r0, #EMC_NOP] | ||
| 390 | str r1, [r0, #EMC_REFRESH] | ||
| 391 | |||
| 392 | emc_device_mask r1, r0 | ||
| 393 | |||
| 394 | exit_selfrefresh_loop: | ||
| 395 | ldr r2, [r0, #EMC_EMC_STATUS] | ||
| 396 | ands r2, r2, r1 | ||
| 397 | bne exit_selfrefresh_loop | ||
| 398 | |||
| 399 | mov r1, #0 @ unstall all transactions | ||
| 400 | str r1, [r0, #EMC_REQ_CTRL] | ||
| 401 | |||
| 402 | mov32 r0, TEGRA_PMC_BASE | ||
| 403 | ldr r0, [r0, #PMC_SCRATCH41] | ||
| 404 | mov pc, r0 @ jump to tegra_resume | ||
| 405 | ENDPROC(tegra20_lp1_reset) | ||
| 406 | |||
| 407 | /* | ||
| 408 | * tegra20_tear_down_core | ||
| 409 | * | ||
| 410 | * copied into and executed from IRAM | ||
| 411 | * puts memory in self-refresh for LP0 and LP1 | ||
| 412 | */ | ||
| 413 | tegra20_tear_down_core: | ||
| 414 | bl tegra20_sdram_self_refresh | ||
| 415 | bl tegra20_switch_cpu_to_clk32k | ||
| 416 | b tegra20_enter_sleep | ||
| 417 | |||
| 418 | /* | ||
| 419 | * tegra20_switch_cpu_to_clk32k | ||
| 420 | * | ||
| 421 | * In LP0 and LP1 all PLLs will be turned off. Switch the CPU and system clock | ||
| 422 | * to the 32KHz clock. | ||
| 423 | */ | ||
| 424 | tegra20_switch_cpu_to_clk32k: | ||
| 425 | /* | ||
| 426 | * start by switching to CLKM to safely disable PLLs, then switch to | ||
| 427 | * CLKS. | ||
| 428 | */ | ||
| 429 | mov r0, #(1 << 28) | ||
| 430 | str r0, [r5, #CLK_RESET_SCLK_BURST] | ||
| 431 | str r0, [r5, #CLK_RESET_CCLK_BURST] | ||
| 432 | mov r0, #0 | ||
| 433 | str r0, [r5, #CLK_RESET_CCLK_DIVIDER] | ||
| 434 | str r0, [r5, #CLK_RESET_SCLK_DIVIDER] | ||
| 435 | |||
| 436 | /* 2uS delay delay between changing SCLK and disabling PLLs */ | ||
| 437 | mov32 r7, TEGRA_TMRUS_BASE | ||
| 438 | ldr r1, [r7] | ||
| 439 | add r1, r1, #2 | ||
| 440 | wait_until r1, r7, r9 | ||
| 441 | |||
| 442 | /* disable PLLM, PLLP and PLLC */ | ||
| 443 | ldr r0, [r5, #CLK_RESET_PLLM_BASE] | ||
| 444 | bic r0, r0, #(1 << 30) | ||
| 445 | str r0, [r5, #CLK_RESET_PLLM_BASE] | ||
| 446 | ldr r0, [r5, #CLK_RESET_PLLP_BASE] | ||
| 447 | bic r0, r0, #(1 << 30) | ||
| 448 | str r0, [r5, #CLK_RESET_PLLP_BASE] | ||
| 449 | ldr r0, [r5, #CLK_RESET_PLLC_BASE] | ||
| 450 | bic r0, r0, #(1 << 30) | ||
| 451 | str r0, [r5, #CLK_RESET_PLLC_BASE] | ||
| 452 | |||
| 453 | /* switch to CLKS */ | ||
| 454 | mov r0, #0 /* brust policy = 32KHz */ | ||
| 455 | str r0, [r5, #CLK_RESET_SCLK_BURST] | ||
| 456 | |||
| 457 | mov pc, lr | ||
| 458 | |||
| 253 | /* | 459 | /* |
| 254 | * tegra20_enter_sleep | 460 | * tegra20_enter_sleep |
| 255 | * | 461 | * |
| @@ -274,4 +480,95 @@ halted: | |||
| 274 | isb | 480 | isb |
| 275 | b halted | 481 | b halted |
| 276 | 482 | ||
| 483 | /* | ||
| 484 | * tegra20_sdram_self_refresh | ||
| 485 | * | ||
| 486 | * called with MMU off and caches disabled | ||
| 487 | * puts sdram in self refresh | ||
| 488 | * must be executed from IRAM | ||
| 489 | */ | ||
| 490 | tegra20_sdram_self_refresh: | ||
| 491 | mov32 r1, TEGRA_EMC_BASE @ r1 reserved for emc base addr | ||
| 492 | |||
| 493 | mov r2, #3 | ||
| 494 | str r2, [r1, #EMC_REQ_CTRL] @ stall incoming DRAM requests | ||
| 495 | |||
| 496 | emcidle: | ||
| 497 | ldr r2, [r1, #EMC_EMC_STATUS] | ||
| 498 | tst r2, #4 | ||
| 499 | beq emcidle | ||
| 500 | |||
| 501 | mov r2, #1 | ||
| 502 | str r2, [r1, #EMC_SELF_REF] | ||
| 503 | |||
| 504 | emc_device_mask r2, r1 | ||
| 505 | |||
| 506 | emcself: | ||
| 507 | ldr r3, [r1, #EMC_EMC_STATUS] | ||
| 508 | and r3, r3, r2 | ||
| 509 | cmp r3, r2 | ||
| 510 | bne emcself @ loop until DDR in self-refresh | ||
| 511 | |||
| 512 | adr r2, tegra20_sdram_pad_address | ||
| 513 | adr r3, tegra20_sdram_pad_safe | ||
| 514 | adr r4, tegra20_sdram_pad_save | ||
| 515 | mov r5, #0 | ||
| 516 | |||
| 517 | ldr r6, tegra20_sdram_pad_size | ||
| 518 | padsave: | ||
| 519 | ldr r0, [r2, r5] @ r0 is the addr in the pad_address | ||
| 520 | |||
| 521 | ldr r1, [r0] | ||
| 522 | str r1, [r4, r5] @ save the content of the addr | ||
| 523 | |||
| 524 | ldr r1, [r3, r5] | ||
| 525 | str r1, [r0] @ set the save val to the addr | ||
| 526 | |||
| 527 | add r5, r5, #4 | ||
| 528 | cmp r6, r5 | ||
| 529 | bne padsave | ||
| 530 | padsave_done: | ||
| 531 | |||
| 532 | mov32 r5, TEGRA_CLK_RESET_BASE | ||
| 533 | ldr r0, [r5, #CLK_RESET_SCLK_BURST] | ||
| 534 | adr r2, tegra20_sclk_save | ||
| 535 | str r0, [r2] | ||
| 536 | dsb | ||
| 537 | mov pc, lr | ||
| 538 | |||
| 539 | tegra20_sdram_pad_address: | ||
| 540 | .word TEGRA_APB_MISC_BASE + APB_MISC_XM2CFGCPADCTRL | ||
| 541 | .word TEGRA_APB_MISC_BASE + APB_MISC_XM2CFGDPADCTRL | ||
| 542 | .word TEGRA_APB_MISC_BASE + APB_MISC_XM2CLKCFGPADCTRL | ||
| 543 | .word TEGRA_APB_MISC_BASE + APB_MISC_XM2COMPPADCTRL | ||
| 544 | .word TEGRA_APB_MISC_BASE + APB_MISC_XM2VTTGENPADCTRL | ||
| 545 | .word TEGRA_APB_MISC_BASE + APB_MISC_XM2CFGCPADCTRL2 | ||
| 546 | .word TEGRA_APB_MISC_BASE + APB_MISC_XM2CFGDPADCTRL2 | ||
| 547 | |||
| 548 | tegra20_sdram_pad_size: | ||
| 549 | .word tegra20_sdram_pad_size - tegra20_sdram_pad_address | ||
| 550 | |||
| 551 | tegra20_sdram_pad_safe: | ||
| 552 | .word 0x8 | ||
| 553 | .word 0x8 | ||
| 554 | .word 0x0 | ||
| 555 | .word 0x8 | ||
| 556 | .word 0x5500 | ||
| 557 | .word 0x08080040 | ||
| 558 | .word 0x0 | ||
| 559 | |||
| 560 | tegra20_sclk_save: | ||
| 561 | .word 0x0 | ||
| 562 | |||
| 563 | tegra20_sdram_pad_save: | ||
| 564 | .rept (tegra20_sdram_pad_size - tegra20_sdram_pad_address) / 4 | ||
| 565 | .long 0 | ||
| 566 | .endr | ||
| 567 | |||
| 568 | .ltorg | ||
| 569 | /* dummy symbol for end of IRAM */ | ||
| 570 | .align L1_CACHE_SHIFT | ||
| 571 | .globl tegra20_iram_end | ||
| 572 | tegra20_iram_end: | ||
| 573 | b . | ||
| 277 | #endif | 574 | #endif |
diff --git a/arch/arm/mach-tegra/sleep-tegra30.S b/arch/arm/mach-tegra/sleep-tegra30.S index ada8821b48be..63fa91b5fafb 100644 --- a/arch/arm/mach-tegra/sleep-tegra30.S +++ b/arch/arm/mach-tegra/sleep-tegra30.S | |||
| @@ -18,13 +18,118 @@ | |||
| 18 | 18 | ||
| 19 | #include <asm/assembler.h> | 19 | #include <asm/assembler.h> |
| 20 | #include <asm/asm-offsets.h> | 20 | #include <asm/asm-offsets.h> |
| 21 | #include <asm/cache.h> | ||
| 21 | 22 | ||
| 22 | #include "fuse.h" | 23 | #include "fuse.h" |
| 23 | #include "sleep.h" | 24 | #include "sleep.h" |
| 24 | #include "flowctrl.h" | 25 | #include "flowctrl.h" |
| 25 | 26 | ||
| 27 | #define EMC_CFG 0xc | ||
| 28 | #define EMC_ADR_CFG 0x10 | ||
| 29 | #define EMC_TIMING_CONTROL 0x28 | ||
| 30 | #define EMC_REFRESH 0x70 | ||
| 31 | #define EMC_NOP 0xdc | ||
| 32 | #define EMC_SELF_REF 0xe0 | ||
| 33 | #define EMC_MRW 0xe8 | ||
| 34 | #define EMC_FBIO_CFG5 0x104 | ||
| 35 | #define EMC_AUTO_CAL_CONFIG 0x2a4 | ||
| 36 | #define EMC_AUTO_CAL_INTERVAL 0x2a8 | ||
| 37 | #define EMC_AUTO_CAL_STATUS 0x2ac | ||
| 38 | #define EMC_REQ_CTRL 0x2b0 | ||
| 39 | #define EMC_CFG_DIG_DLL 0x2bc | ||
| 40 | #define EMC_EMC_STATUS 0x2b4 | ||
| 41 | #define EMC_ZCAL_INTERVAL 0x2e0 | ||
| 42 | #define EMC_ZQ_CAL 0x2ec | ||
| 43 | #define EMC_XM2VTTGENPADCTRL 0x310 | ||
| 44 | #define EMC_XM2VTTGENPADCTRL2 0x314 | ||
| 45 | |||
| 46 | #define PMC_CTRL 0x0 | ||
| 47 | #define PMC_CTRL_SIDE_EFFECT_LP0 (1 << 14) /* enter LP0 when CPU pwr gated */ | ||
| 48 | |||
| 49 | #define PMC_PLLP_WB0_OVERRIDE 0xf8 | ||
| 50 | #define PMC_IO_DPD_REQ 0x1b8 | ||
| 51 | #define PMC_IO_DPD_STATUS 0x1bc | ||
| 52 | |||
| 53 | #define CLK_RESET_CCLK_BURST 0x20 | ||
| 54 | #define CLK_RESET_CCLK_DIVIDER 0x24 | ||
| 55 | #define CLK_RESET_SCLK_BURST 0x28 | ||
| 56 | #define CLK_RESET_SCLK_DIVIDER 0x2c | ||
| 57 | |||
| 58 | #define CLK_RESET_PLLC_BASE 0x80 | ||
| 59 | #define CLK_RESET_PLLC_MISC 0x8c | ||
| 60 | #define CLK_RESET_PLLM_BASE 0x90 | ||
| 61 | #define CLK_RESET_PLLM_MISC 0x9c | ||
| 62 | #define CLK_RESET_PLLP_BASE 0xa0 | ||
| 63 | #define CLK_RESET_PLLP_MISC 0xac | ||
| 64 | #define CLK_RESET_PLLA_BASE 0xb0 | ||
| 65 | #define CLK_RESET_PLLA_MISC 0xbc | ||
| 66 | #define CLK_RESET_PLLX_BASE 0xe0 | ||
| 67 | #define CLK_RESET_PLLX_MISC 0xe4 | ||
| 68 | #define CLK_RESET_PLLX_MISC3 0x518 | ||
| 69 | #define CLK_RESET_PLLX_MISC3_IDDQ 3 | ||
| 70 | #define CLK_RESET_PLLM_MISC_IDDQ 5 | ||
| 71 | #define CLK_RESET_PLLC_MISC_IDDQ 26 | ||
| 72 | |||
| 73 | #define CLK_RESET_CLK_SOURCE_MSELECT 0x3b4 | ||
| 74 | |||
| 75 | #define MSELECT_CLKM (0x3 << 30) | ||
| 76 | |||
| 77 | #define LOCK_DELAY 50 /* safety delay after lock is detected */ | ||
| 78 | |||
| 26 | #define TEGRA30_POWER_HOTPLUG_SHUTDOWN (1 << 27) /* Hotplug shutdown */ | 79 | #define TEGRA30_POWER_HOTPLUG_SHUTDOWN (1 << 27) /* Hotplug shutdown */ |
| 27 | 80 | ||
| 81 | .macro emc_device_mask, rd, base | ||
| 82 | ldr \rd, [\base, #EMC_ADR_CFG] | ||
| 83 | tst \rd, #0x1 | ||
| 84 | moveq \rd, #(0x1 << 8) @ just 1 device | ||
| 85 | movne \rd, #(0x3 << 8) @ 2 devices | ||
| 86 | .endm | ||
| 87 | |||
| 88 | .macro emc_timing_update, rd, base | ||
| 89 | mov \rd, #1 | ||
| 90 | str \rd, [\base, #EMC_TIMING_CONTROL] | ||
| 91 | 1001: | ||
| 92 | ldr \rd, [\base, #EMC_EMC_STATUS] | ||
| 93 | tst \rd, #(0x1<<23) @ wait EMC_STATUS_TIMING_UPDATE_STALLED is clear | ||
| 94 | bne 1001b | ||
| 95 | .endm | ||
| 96 | |||
| 97 | .macro pll_enable, rd, r_car_base, pll_base, pll_misc | ||
| 98 | ldr \rd, [\r_car_base, #\pll_base] | ||
| 99 | tst \rd, #(1 << 30) | ||
| 100 | orreq \rd, \rd, #(1 << 30) | ||
| 101 | streq \rd, [\r_car_base, #\pll_base] | ||
| 102 | /* Enable lock detector */ | ||
| 103 | .if \pll_misc | ||
| 104 | ldr \rd, [\r_car_base, #\pll_misc] | ||
| 105 | bic \rd, \rd, #(1 << 18) | ||
| 106 | str \rd, [\r_car_base, #\pll_misc] | ||
| 107 | ldr \rd, [\r_car_base, #\pll_misc] | ||
| 108 | ldr \rd, [\r_car_base, #\pll_misc] | ||
| 109 | orr \rd, \rd, #(1 << 18) | ||
| 110 | str \rd, [\r_car_base, #\pll_misc] | ||
| 111 | .endif | ||
| 112 | .endm | ||
| 113 | |||
| 114 | .macro pll_locked, rd, r_car_base, pll_base | ||
| 115 | 1: | ||
| 116 | ldr \rd, [\r_car_base, #\pll_base] | ||
| 117 | tst \rd, #(1 << 27) | ||
| 118 | beq 1b | ||
| 119 | .endm | ||
| 120 | |||
| 121 | .macro pll_iddq_exit, rd, car, iddq, iddq_bit | ||
| 122 | ldr \rd, [\car, #\iddq] | ||
| 123 | bic \rd, \rd, #(1<<\iddq_bit) | ||
| 124 | str \rd, [\car, #\iddq] | ||
| 125 | .endm | ||
| 126 | |||
| 127 | .macro pll_iddq_entry, rd, car, iddq, iddq_bit | ||
| 128 | ldr \rd, [\car, #\iddq] | ||
| 129 | orr \rd, \rd, #(1<<\iddq_bit) | ||
| 130 | str \rd, [\car, #\iddq] | ||
| 131 | .endm | ||
| 132 | |||
| 28 | #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP) | 133 | #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP) |
| 29 | /* | 134 | /* |
| 30 | * tegra30_hotplug_shutdown(void) | 135 | * tegra30_hotplug_shutdown(void) |
| @@ -99,6 +204,8 @@ flow_ctrl_setting_for_lp2: | |||
| 99 | cmp r10, #TEGRA30 | 204 | cmp r10, #TEGRA30 |
| 100 | moveq r3, #FLOW_CTRL_WAIT_FOR_INTERRUPT @ For LP2 | 205 | moveq r3, #FLOW_CTRL_WAIT_FOR_INTERRUPT @ For LP2 |
| 101 | movne r3, #FLOW_CTRL_WAITEVENT | 206 | movne r3, #FLOW_CTRL_WAITEVENT |
| 207 | orrne r3, r3, #FLOW_CTRL_HALT_GIC_IRQ | ||
| 208 | orrne r3, r3, #FLOW_CTRL_HALT_GIC_FIQ | ||
| 102 | flow_ctrl_done: | 209 | flow_ctrl_done: |
| 103 | cmp r10, #TEGRA30 | 210 | cmp r10, #TEGRA30 |
| 104 | str r3, [r2] | 211 | str r3, [r2] |
| @@ -127,6 +234,41 @@ ENDPROC(tegra30_cpu_shutdown) | |||
| 127 | 234 | ||
| 128 | #ifdef CONFIG_PM_SLEEP | 235 | #ifdef CONFIG_PM_SLEEP |
| 129 | /* | 236 | /* |
| 237 | * tegra30_sleep_core_finish(unsigned long v2p) | ||
| 238 | * | ||
| 239 | * Enters suspend in LP0 or LP1 by turning off the MMU and jumping to | ||
| 240 | * tegra30_tear_down_core in IRAM | ||
| 241 | */ | ||
| 242 | ENTRY(tegra30_sleep_core_finish) | ||
| 243 | /* Flush, disable the L1 data cache and exit SMP */ | ||
| 244 | bl tegra_disable_clean_inv_dcache | ||
| 245 | |||
| 246 | /* | ||
| 247 | * Preload all the address literals that are needed for the | ||
| 248 | * CPU power-gating process, to avoid loading from SDRAM which | ||
| 249 | * are not supported once SDRAM is put into self-refresh. | ||
| 250 | * LP0 / LP1 use physical address, since the MMU needs to be | ||
| 251 | * disabled before putting SDRAM into self-refresh to avoid | ||
| 252 | * memory access due to page table walks. | ||
| 253 | */ | ||
| 254 | mov32 r4, TEGRA_PMC_BASE | ||
| 255 | mov32 r5, TEGRA_CLK_RESET_BASE | ||
| 256 | mov32 r6, TEGRA_FLOW_CTRL_BASE | ||
| 257 | mov32 r7, TEGRA_TMRUS_BASE | ||
| 258 | |||
| 259 | mov32 r3, tegra_shut_off_mmu | ||
| 260 | add r3, r3, r0 | ||
| 261 | |||
| 262 | mov32 r0, tegra30_tear_down_core | ||
| 263 | mov32 r1, tegra30_iram_start | ||
| 264 | sub r0, r0, r1 | ||
| 265 | mov32 r1, TEGRA_IRAM_CODE_AREA | ||
| 266 | add r0, r0, r1 | ||
| 267 | |||
| 268 | mov pc, r3 | ||
| 269 | ENDPROC(tegra30_sleep_core_finish) | ||
| 270 | |||
| 271 | /* | ||
| 130 | * tegra30_sleep_cpu_secondary_finish(unsigned long v2p) | 272 | * tegra30_sleep_cpu_secondary_finish(unsigned long v2p) |
| 131 | * | 273 | * |
| 132 | * Enters LP2 on secondary CPU by exiting coherency and powergating the CPU. | 274 | * Enters LP2 on secondary CPU by exiting coherency and powergating the CPU. |
| @@ -135,6 +277,7 @@ ENTRY(tegra30_sleep_cpu_secondary_finish) | |||
| 135 | mov r7, lr | 277 | mov r7, lr |
| 136 | 278 | ||
| 137 | /* Flush and disable the L1 data cache */ | 279 | /* Flush and disable the L1 data cache */ |
| 280 | mov r0, #TEGRA_FLUSH_CACHE_LOUIS | ||
| 138 | bl tegra_disable_clean_inv_dcache | 281 | bl tegra_disable_clean_inv_dcache |
| 139 | 282 | ||
| 140 | /* Powergate this CPU. */ | 283 | /* Powergate this CPU. */ |
| @@ -155,6 +298,351 @@ ENTRY(tegra30_tear_down_cpu) | |||
| 155 | b tegra30_enter_sleep | 298 | b tegra30_enter_sleep |
| 156 | ENDPROC(tegra30_tear_down_cpu) | 299 | ENDPROC(tegra30_tear_down_cpu) |
| 157 | 300 | ||
| 301 | /* START OF ROUTINES COPIED TO IRAM */ | ||
| 302 | .align L1_CACHE_SHIFT | ||
| 303 | .globl tegra30_iram_start | ||
| 304 | tegra30_iram_start: | ||
| 305 | |||
| 306 | /* | ||
| 307 | * tegra30_lp1_reset | ||
| 308 | * | ||
| 309 | * reset vector for LP1 restore; copied into IRAM during suspend. | ||
| 310 | * Brings the system back up to a safe staring point (SDRAM out of | ||
| 311 | * self-refresh, PLLC, PLLM and PLLP reenabled, CPU running on PLLX, | ||
| 312 | * system clock running on the same PLL that it suspended at), and | ||
| 313 | * jumps to tegra_resume to restore virtual addressing. | ||
| 314 | * The physical address of tegra_resume expected to be stored in | ||
| 315 | * PMC_SCRATCH41. | ||
| 316 | * | ||
| 317 | * NOTE: THIS *MUST* BE RELOCATED TO TEGRA_IRAM_CODE_AREA. | ||
| 318 | */ | ||
| 319 | ENTRY(tegra30_lp1_reset) | ||
| 320 | /* | ||
| 321 | * The CPU and system bus are running at 32KHz and executing from | ||
| 322 | * IRAM when this code is executed; immediately switch to CLKM and | ||
| 323 | * enable PLLP, PLLM, PLLC, PLLA and PLLX. | ||
| 324 | */ | ||
| 325 | mov32 r0, TEGRA_CLK_RESET_BASE | ||
| 326 | |||
| 327 | mov r1, #(1 << 28) | ||
| 328 | str r1, [r0, #CLK_RESET_SCLK_BURST] | ||
| 329 | str r1, [r0, #CLK_RESET_CCLK_BURST] | ||
| 330 | mov r1, #0 | ||
| 331 | str r1, [r0, #CLK_RESET_CCLK_DIVIDER] | ||
| 332 | str r1, [r0, #CLK_RESET_SCLK_DIVIDER] | ||
| 333 | |||
| 334 | tegra_get_soc_id TEGRA_APB_MISC_BASE, r10 | ||
| 335 | cmp r10, #TEGRA30 | ||
| 336 | beq _no_pll_iddq_exit | ||
| 337 | |||
| 338 | pll_iddq_exit r1, r0, CLK_RESET_PLLM_MISC, CLK_RESET_PLLM_MISC_IDDQ | ||
| 339 | pll_iddq_exit r1, r0, CLK_RESET_PLLC_MISC, CLK_RESET_PLLC_MISC_IDDQ | ||
| 340 | pll_iddq_exit r1, r0, CLK_RESET_PLLX_MISC3, CLK_RESET_PLLX_MISC3_IDDQ | ||
| 341 | |||
| 342 | mov32 r7, TEGRA_TMRUS_BASE | ||
| 343 | ldr r1, [r7] | ||
| 344 | add r1, r1, #2 | ||
| 345 | wait_until r1, r7, r3 | ||
| 346 | |||
| 347 | /* enable PLLM via PMC */ | ||
| 348 | mov32 r2, TEGRA_PMC_BASE | ||
| 349 | ldr r1, [r2, #PMC_PLLP_WB0_OVERRIDE] | ||
| 350 | orr r1, r1, #(1 << 12) | ||
| 351 | str r1, [r2, #PMC_PLLP_WB0_OVERRIDE] | ||
| 352 | |||
| 353 | pll_enable r1, r0, CLK_RESET_PLLM_BASE, 0 | ||
| 354 | pll_enable r1, r0, CLK_RESET_PLLC_BASE, 0 | ||
| 355 | pll_enable r1, r0, CLK_RESET_PLLX_BASE, 0 | ||
| 356 | |||
| 357 | b _pll_m_c_x_done | ||
| 358 | |||
| 359 | _no_pll_iddq_exit: | ||
| 360 | /* enable PLLM via PMC */ | ||
| 361 | mov32 r2, TEGRA_PMC_BASE | ||
| 362 | ldr r1, [r2, #PMC_PLLP_WB0_OVERRIDE] | ||
| 363 | orr r1, r1, #(1 << 12) | ||
| 364 | str r1, [r2, #PMC_PLLP_WB0_OVERRIDE] | ||
| 365 | |||
| 366 | pll_enable r1, r0, CLK_RESET_PLLM_BASE, CLK_RESET_PLLM_MISC | ||
| 367 | pll_enable r1, r0, CLK_RESET_PLLC_BASE, CLK_RESET_PLLC_MISC | ||
| 368 | pll_enable r1, r0, CLK_RESET_PLLX_BASE, CLK_RESET_PLLX_MISC | ||
| 369 | |||
| 370 | _pll_m_c_x_done: | ||
| 371 | pll_enable r1, r0, CLK_RESET_PLLP_BASE, CLK_RESET_PLLP_MISC | ||
| 372 | pll_enable r1, r0, CLK_RESET_PLLA_BASE, CLK_RESET_PLLA_MISC | ||
| 373 | |||
| 374 | pll_locked r1, r0, CLK_RESET_PLLM_BASE | ||
| 375 | pll_locked r1, r0, CLK_RESET_PLLP_BASE | ||
| 376 | pll_locked r1, r0, CLK_RESET_PLLA_BASE | ||
| 377 | pll_locked r1, r0, CLK_RESET_PLLC_BASE | ||
| 378 | pll_locked r1, r0, CLK_RESET_PLLX_BASE | ||
| 379 | |||
| 380 | mov32 r7, TEGRA_TMRUS_BASE | ||
| 381 | ldr r1, [r7] | ||
| 382 | add r1, r1, #LOCK_DELAY | ||
| 383 | wait_until r1, r7, r3 | ||
| 384 | |||
| 385 | adr r5, tegra30_sdram_pad_save | ||
| 386 | |||
| 387 | ldr r4, [r5, #0x18] @ restore CLK_SOURCE_MSELECT | ||
| 388 | str r4, [r0, #CLK_RESET_CLK_SOURCE_MSELECT] | ||
| 389 | |||
| 390 | ldr r4, [r5, #0x1C] @ restore SCLK_BURST | ||
| 391 | str r4, [r0, #CLK_RESET_SCLK_BURST] | ||
| 392 | |||
| 393 | cmp r10, #TEGRA30 | ||
| 394 | movweq r4, #:lower16:((1 << 28) | (0x8)) @ burst policy is PLLX | ||
| 395 | movteq r4, #:upper16:((1 << 28) | (0x8)) | ||
| 396 | movwne r4, #:lower16:((1 << 28) | (0xe)) | ||
| 397 | movtne r4, #:upper16:((1 << 28) | (0xe)) | ||
| 398 | str r4, [r0, #CLK_RESET_CCLK_BURST] | ||
| 399 | |||
| 400 | /* Restore pad power state to normal */ | ||
| 401 | ldr r1, [r5, #0x14] @ PMC_IO_DPD_STATUS | ||
| 402 | mvn r1, r1 | ||
| 403 | bic r1, r1, #(1 << 31) | ||
| 404 | orr r1, r1, #(1 << 30) | ||
| 405 | str r1, [r2, #PMC_IO_DPD_REQ] @ DPD_OFF | ||
| 406 | |||
| 407 | cmp r10, #TEGRA30 | ||
| 408 | movweq r0, #:lower16:TEGRA_EMC_BASE @ r0 reserved for emc base | ||
| 409 | movteq r0, #:upper16:TEGRA_EMC_BASE | ||
| 410 | movwne r0, #:lower16:TEGRA_EMC0_BASE | ||
| 411 | movtne r0, #:upper16:TEGRA_EMC0_BASE | ||
| 412 | |||
| 413 | exit_self_refresh: | ||
| 414 | ldr r1, [r5, #0xC] @ restore EMC_XM2VTTGENPADCTRL | ||
| 415 | str r1, [r0, #EMC_XM2VTTGENPADCTRL] | ||
| 416 | ldr r1, [r5, #0x10] @ restore EMC_XM2VTTGENPADCTRL2 | ||
| 417 | str r1, [r0, #EMC_XM2VTTGENPADCTRL2] | ||
| 418 | ldr r1, [r5, #0x8] @ restore EMC_AUTO_CAL_INTERVAL | ||
| 419 | str r1, [r0, #EMC_AUTO_CAL_INTERVAL] | ||
| 420 | |||
| 421 | /* Relock DLL */ | ||
| 422 | ldr r1, [r0, #EMC_CFG_DIG_DLL] | ||
| 423 | orr r1, r1, #(1 << 30) @ set DLL_RESET | ||
| 424 | str r1, [r0, #EMC_CFG_DIG_DLL] | ||
| 425 | |||
| 426 | emc_timing_update r1, r0 | ||
| 427 | |||
| 428 | cmp r10, #TEGRA114 | ||
| 429 | movweq r1, #:lower16:TEGRA_EMC1_BASE | ||
| 430 | movteq r1, #:upper16:TEGRA_EMC1_BASE | ||
| 431 | cmpeq r0, r1 | ||
| 432 | |||
| 433 | ldr r1, [r0, #EMC_AUTO_CAL_CONFIG] | ||
| 434 | orr r1, r1, #(1 << 31) @ set AUTO_CAL_ACTIVE | ||
| 435 | orreq r1, r1, #(1 << 27) @ set slave mode for channel 1 | ||
| 436 | str r1, [r0, #EMC_AUTO_CAL_CONFIG] | ||
| 437 | |||
| 438 | emc_wait_auto_cal_onetime: | ||
| 439 | ldr r1, [r0, #EMC_AUTO_CAL_STATUS] | ||
| 440 | tst r1, #(1 << 31) @ wait until AUTO_CAL_ACTIVE is cleared | ||
| 441 | bne emc_wait_auto_cal_onetime | ||
| 442 | |||
| 443 | ldr r1, [r0, #EMC_CFG] | ||
| 444 | bic r1, r1, #(1 << 31) @ disable DRAM_CLK_STOP_PD | ||
| 445 | str r1, [r0, #EMC_CFG] | ||
| 446 | |||
| 447 | mov r1, #0 | ||
| 448 | str r1, [r0, #EMC_SELF_REF] @ take DRAM out of self refresh | ||
| 449 | mov r1, #1 | ||
| 450 | cmp r10, #TEGRA30 | ||
| 451 | streq r1, [r0, #EMC_NOP] | ||
| 452 | streq r1, [r0, #EMC_NOP] | ||
| 453 | streq r1, [r0, #EMC_REFRESH] | ||
| 454 | |||
| 455 | emc_device_mask r1, r0 | ||
| 456 | |||
| 457 | exit_selfrefresh_loop: | ||
| 458 | ldr r2, [r0, #EMC_EMC_STATUS] | ||
| 459 | ands r2, r2, r1 | ||
| 460 | bne exit_selfrefresh_loop | ||
| 461 | |||
| 462 | lsr r1, r1, #8 @ devSel, bit0:dev0, bit1:dev1 | ||
| 463 | |||
| 464 | mov32 r7, TEGRA_TMRUS_BASE | ||
| 465 | ldr r2, [r0, #EMC_FBIO_CFG5] | ||
| 466 | |||
| 467 | and r2, r2, #3 @ check DRAM_TYPE | ||
| 468 | cmp r2, #2 | ||
| 469 | beq emc_lpddr2 | ||
| 470 | |||
| 471 | /* Issue a ZQ_CAL for dev0 - DDR3 */ | ||
| 472 | mov32 r2, 0x80000011 @ DEV_SELECTION=2, LENGTH=LONG, CMD=1 | ||
| 473 | str r2, [r0, #EMC_ZQ_CAL] | ||
| 474 | ldr r2, [r7] | ||
| 475 | add r2, r2, #10 | ||
| 476 | wait_until r2, r7, r3 | ||
| 477 | |||
| 478 | tst r1, #2 | ||
| 479 | beq zcal_done | ||
| 480 | |||
| 481 | /* Issue a ZQ_CAL for dev1 - DDR3 */ | ||
| 482 | mov32 r2, 0x40000011 @ DEV_SELECTION=1, LENGTH=LONG, CMD=1 | ||
| 483 | str r2, [r0, #EMC_ZQ_CAL] | ||
| 484 | ldr r2, [r7] | ||
| 485 | add r2, r2, #10 | ||
| 486 | wait_until r2, r7, r3 | ||
| 487 | b zcal_done | ||
| 488 | |||
| 489 | emc_lpddr2: | ||
| 490 | /* Issue a ZQ_CAL for dev0 - LPDDR2 */ | ||
| 491 | mov32 r2, 0x800A00AB @ DEV_SELECTION=2, MA=10, OP=0xAB | ||
| 492 | str r2, [r0, #EMC_MRW] | ||
| 493 | ldr r2, [r7] | ||
| 494 | add r2, r2, #1 | ||
| 495 | wait_until r2, r7, r3 | ||
| 496 | |||
| 497 | tst r1, #2 | ||
| 498 | beq zcal_done | ||
| 499 | |||
| 500 | /* Issue a ZQ_CAL for dev0 - LPDDR2 */ | ||
| 501 | mov32 r2, 0x400A00AB @ DEV_SELECTION=1, MA=10, OP=0xAB | ||
| 502 | str r2, [r0, #EMC_MRW] | ||
| 503 | ldr r2, [r7] | ||
| 504 | add r2, r2, #1 | ||
| 505 | wait_until r2, r7, r3 | ||
| 506 | |||
| 507 | zcal_done: | ||
| 508 | mov r1, #0 @ unstall all transactions | ||
| 509 | str r1, [r0, #EMC_REQ_CTRL] | ||
| 510 | ldr r1, [r5, #0x4] @ restore EMC_ZCAL_INTERVAL | ||
| 511 | str r1, [r0, #EMC_ZCAL_INTERVAL] | ||
| 512 | ldr r1, [r5, #0x0] @ restore EMC_CFG | ||
| 513 | str r1, [r0, #EMC_CFG] | ||
| 514 | |||
| 515 | /* Tegra114 had dual EMC channel, now config the other one */ | ||
| 516 | cmp r10, #TEGRA114 | ||
| 517 | bne __no_dual_emc_chanl | ||
| 518 | mov32 r1, TEGRA_EMC1_BASE | ||
| 519 | cmp r0, r1 | ||
| 520 | movne r0, r1 | ||
| 521 | addne r5, r5, #0x20 | ||
| 522 | bne exit_self_refresh | ||
| 523 | __no_dual_emc_chanl: | ||
| 524 | |||
| 525 | mov32 r0, TEGRA_PMC_BASE | ||
| 526 | ldr r0, [r0, #PMC_SCRATCH41] | ||
| 527 | mov pc, r0 @ jump to tegra_resume | ||
| 528 | ENDPROC(tegra30_lp1_reset) | ||
| 529 | |||
| 530 | .align L1_CACHE_SHIFT | ||
| 531 | tegra30_sdram_pad_address: | ||
| 532 | .word TEGRA_EMC_BASE + EMC_CFG @0x0 | ||
| 533 | .word TEGRA_EMC_BASE + EMC_ZCAL_INTERVAL @0x4 | ||
| 534 | .word TEGRA_EMC_BASE + EMC_AUTO_CAL_INTERVAL @0x8 | ||
| 535 | .word TEGRA_EMC_BASE + EMC_XM2VTTGENPADCTRL @0xc | ||
| 536 | .word TEGRA_EMC_BASE + EMC_XM2VTTGENPADCTRL2 @0x10 | ||
| 537 | .word TEGRA_PMC_BASE + PMC_IO_DPD_STATUS @0x14 | ||
| 538 | .word TEGRA_CLK_RESET_BASE + CLK_RESET_CLK_SOURCE_MSELECT @0x18 | ||
| 539 | .word TEGRA_CLK_RESET_BASE + CLK_RESET_SCLK_BURST @0x1c | ||
| 540 | |||
| 541 | tegra114_sdram_pad_address: | ||
| 542 | .word TEGRA_EMC0_BASE + EMC_CFG @0x0 | ||
| 543 | .word TEGRA_EMC0_BASE + EMC_ZCAL_INTERVAL @0x4 | ||
| 544 | .word TEGRA_EMC0_BASE + EMC_AUTO_CAL_INTERVAL @0x8 | ||
| 545 | .word TEGRA_EMC0_BASE + EMC_XM2VTTGENPADCTRL @0xc | ||
| 546 | .word TEGRA_EMC0_BASE + EMC_XM2VTTGENPADCTRL2 @0x10 | ||
| 547 | .word TEGRA_PMC_BASE + PMC_IO_DPD_STATUS @0x14 | ||
| 548 | .word TEGRA_CLK_RESET_BASE + CLK_RESET_CLK_SOURCE_MSELECT @0x18 | ||
| 549 | .word TEGRA_CLK_RESET_BASE + CLK_RESET_SCLK_BURST @0x1c | ||
| 550 | .word TEGRA_EMC1_BASE + EMC_CFG @0x20 | ||
| 551 | .word TEGRA_EMC1_BASE + EMC_ZCAL_INTERVAL @0x24 | ||
| 552 | .word TEGRA_EMC1_BASE + EMC_AUTO_CAL_INTERVAL @0x28 | ||
| 553 | .word TEGRA_EMC1_BASE + EMC_XM2VTTGENPADCTRL @0x2c | ||
| 554 | .word TEGRA_EMC1_BASE + EMC_XM2VTTGENPADCTRL2 @0x30 | ||
| 555 | |||
| 556 | tegra30_sdram_pad_size: | ||
| 557 | .word tegra114_sdram_pad_address - tegra30_sdram_pad_address | ||
| 558 | |||
| 559 | tegra114_sdram_pad_size: | ||
| 560 | .word tegra30_sdram_pad_size - tegra114_sdram_pad_address | ||
| 561 | |||
| 562 | .type tegra30_sdram_pad_save, %object | ||
| 563 | tegra30_sdram_pad_save: | ||
| 564 | .rept (tegra30_sdram_pad_size - tegra114_sdram_pad_address) / 4 | ||
| 565 | .long 0 | ||
| 566 | .endr | ||
| 567 | |||
| 568 | /* | ||
| 569 | * tegra30_tear_down_core | ||
| 570 | * | ||
| 571 | * copied into and executed from IRAM | ||
| 572 | * puts memory in self-refresh for LP0 and LP1 | ||
| 573 | */ | ||
| 574 | tegra30_tear_down_core: | ||
| 575 | bl tegra30_sdram_self_refresh | ||
| 576 | bl tegra30_switch_cpu_to_clk32k | ||
| 577 | b tegra30_enter_sleep | ||
| 578 | |||
| 579 | /* | ||
| 580 | * tegra30_switch_cpu_to_clk32k | ||
| 581 | * | ||
| 582 | * In LP0 and LP1 all PLLs will be turned off. Switching the CPU and System CLK | ||
| 583 | * to the 32KHz clock. | ||
| 584 | * r4 = TEGRA_PMC_BASE | ||
| 585 | * r5 = TEGRA_CLK_RESET_BASE | ||
| 586 | * r6 = TEGRA_FLOW_CTRL_BASE | ||
| 587 | * r7 = TEGRA_TMRUS_BASE | ||
| 588 | * r10= SoC ID | ||
| 589 | */ | ||
| 590 | tegra30_switch_cpu_to_clk32k: | ||
| 591 | /* | ||
| 592 | * start by jumping to CLKM to safely disable PLLs, then jump to | ||
| 593 | * CLKS. | ||
| 594 | */ | ||
| 595 | mov r0, #(1 << 28) | ||
| 596 | str r0, [r5, #CLK_RESET_SCLK_BURST] | ||
| 597 | /* 2uS delay delay between changing SCLK and CCLK */ | ||
| 598 | ldr r1, [r7] | ||
| 599 | add r1, r1, #2 | ||
| 600 | wait_until r1, r7, r9 | ||
| 601 | str r0, [r5, #CLK_RESET_CCLK_BURST] | ||
| 602 | mov r0, #0 | ||
| 603 | str r0, [r5, #CLK_RESET_CCLK_DIVIDER] | ||
| 604 | str r0, [r5, #CLK_RESET_SCLK_DIVIDER] | ||
| 605 | |||
| 606 | /* switch the clock source of mselect to be CLK_M */ | ||
| 607 | ldr r0, [r5, #CLK_RESET_CLK_SOURCE_MSELECT] | ||
| 608 | orr r0, r0, #MSELECT_CLKM | ||
| 609 | str r0, [r5, #CLK_RESET_CLK_SOURCE_MSELECT] | ||
| 610 | |||
| 611 | /* 2uS delay delay between changing SCLK and disabling PLLs */ | ||
| 612 | ldr r1, [r7] | ||
| 613 | add r1, r1, #2 | ||
| 614 | wait_until r1, r7, r9 | ||
| 615 | |||
| 616 | /* disable PLLM via PMC in LP1 */ | ||
| 617 | ldr r0, [r4, #PMC_PLLP_WB0_OVERRIDE] | ||
| 618 | bic r0, r0, #(1 << 12) | ||
| 619 | str r0, [r4, #PMC_PLLP_WB0_OVERRIDE] | ||
| 620 | |||
| 621 | /* disable PLLP, PLLA, PLLC and PLLX */ | ||
| 622 | ldr r0, [r5, #CLK_RESET_PLLP_BASE] | ||
| 623 | bic r0, r0, #(1 << 30) | ||
| 624 | str r0, [r5, #CLK_RESET_PLLP_BASE] | ||
| 625 | ldr r0, [r5, #CLK_RESET_PLLA_BASE] | ||
| 626 | bic r0, r0, #(1 << 30) | ||
| 627 | str r0, [r5, #CLK_RESET_PLLA_BASE] | ||
| 628 | ldr r0, [r5, #CLK_RESET_PLLC_BASE] | ||
| 629 | bic r0, r0, #(1 << 30) | ||
| 630 | str r0, [r5, #CLK_RESET_PLLC_BASE] | ||
| 631 | ldr r0, [r5, #CLK_RESET_PLLX_BASE] | ||
| 632 | bic r0, r0, #(1 << 30) | ||
| 633 | str r0, [r5, #CLK_RESET_PLLX_BASE] | ||
| 634 | |||
| 635 | cmp r10, #TEGRA30 | ||
| 636 | beq _no_pll_in_iddq | ||
| 637 | pll_iddq_entry r1, r5, CLK_RESET_PLLX_MISC3, CLK_RESET_PLLX_MISC3_IDDQ | ||
| 638 | _no_pll_in_iddq: | ||
| 639 | |||
| 640 | /* switch to CLKS */ | ||
| 641 | mov r0, #0 /* brust policy = 32KHz */ | ||
| 642 | str r0, [r5, #CLK_RESET_SCLK_BURST] | ||
| 643 | |||
| 644 | mov pc, lr | ||
| 645 | |||
| 158 | /* | 646 | /* |
| 159 | * tegra30_enter_sleep | 647 | * tegra30_enter_sleep |
| 160 | * | 648 | * |
| @@ -172,8 +660,12 @@ tegra30_enter_sleep: | |||
| 172 | orr r0, r0, #FLOW_CTRL_CSR_ENABLE | 660 | orr r0, r0, #FLOW_CTRL_CSR_ENABLE |
| 173 | str r0, [r6, r2] | 661 | str r0, [r6, r2] |
| 174 | 662 | ||
| 663 | tegra_get_soc_id TEGRA_APB_MISC_BASE, r10 | ||
| 664 | cmp r10, #TEGRA30 | ||
| 175 | mov r0, #FLOW_CTRL_WAIT_FOR_INTERRUPT | 665 | mov r0, #FLOW_CTRL_WAIT_FOR_INTERRUPT |
| 176 | orr r0, r0, #FLOW_CTRL_HALT_CPU_IRQ | FLOW_CTRL_HALT_CPU_FIQ | 666 | orreq r0, r0, #FLOW_CTRL_HALT_CPU_IRQ | FLOW_CTRL_HALT_CPU_FIQ |
| 667 | orrne r0, r0, #FLOW_CTRL_HALT_LIC_IRQ | FLOW_CTRL_HALT_LIC_FIQ | ||
| 668 | |||
| 177 | cpu_to_halt_reg r2, r1 | 669 | cpu_to_halt_reg r2, r1 |
| 178 | str r0, [r6, r2] | 670 | str r0, [r6, r2] |
| 179 | dsb | 671 | dsb |
| @@ -187,4 +679,126 @@ halted: | |||
| 187 | /* !!!FIXME!!! Implement halt failure handler */ | 679 | /* !!!FIXME!!! Implement halt failure handler */ |
| 188 | b halted | 680 | b halted |
| 189 | 681 | ||
| 682 | /* | ||
| 683 | * tegra30_sdram_self_refresh | ||
| 684 | * | ||
| 685 | * called with MMU off and caches disabled | ||
| 686 | * must be executed from IRAM | ||
| 687 | * r4 = TEGRA_PMC_BASE | ||
| 688 | * r5 = TEGRA_CLK_RESET_BASE | ||
| 689 | * r6 = TEGRA_FLOW_CTRL_BASE | ||
| 690 | * r7 = TEGRA_TMRUS_BASE | ||
| 691 | * r10= SoC ID | ||
| 692 | */ | ||
| 693 | tegra30_sdram_self_refresh: | ||
| 694 | |||
| 695 | adr r8, tegra30_sdram_pad_save | ||
| 696 | tegra_get_soc_id TEGRA_APB_MISC_BASE, r10 | ||
| 697 | cmp r10, #TEGRA30 | ||
| 698 | adreq r2, tegra30_sdram_pad_address | ||
| 699 | ldreq r3, tegra30_sdram_pad_size | ||
| 700 | adrne r2, tegra114_sdram_pad_address | ||
| 701 | ldrne r3, tegra114_sdram_pad_size | ||
| 702 | mov r9, #0 | ||
| 703 | |||
| 704 | padsave: | ||
| 705 | ldr r0, [r2, r9] @ r0 is the addr in the pad_address | ||
| 706 | |||
| 707 | ldr r1, [r0] | ||
| 708 | str r1, [r8, r9] @ save the content of the addr | ||
| 709 | |||
| 710 | add r9, r9, #4 | ||
| 711 | cmp r3, r9 | ||
| 712 | bne padsave | ||
| 713 | padsave_done: | ||
| 714 | |||
| 715 | dsb | ||
| 716 | |||
| 717 | cmp r10, #TEGRA30 | ||
| 718 | ldreq r0, =TEGRA_EMC_BASE @ r0 reserved for emc base addr | ||
| 719 | ldrne r0, =TEGRA_EMC0_BASE | ||
| 720 | |||
| 721 | enter_self_refresh: | ||
| 722 | cmp r10, #TEGRA30 | ||
| 723 | mov r1, #0 | ||
| 724 | str r1, [r0, #EMC_ZCAL_INTERVAL] | ||
| 725 | str r1, [r0, #EMC_AUTO_CAL_INTERVAL] | ||
| 726 | ldr r1, [r0, #EMC_CFG] | ||
| 727 | bic r1, r1, #(1 << 28) | ||
| 728 | bicne r1, r1, #(1 << 29) | ||
| 729 | str r1, [r0, #EMC_CFG] @ disable DYN_SELF_REF | ||
| 730 | |||
| 731 | emc_timing_update r1, r0 | ||
| 732 | |||
| 733 | ldr r1, [r7] | ||
| 734 | add r1, r1, #5 | ||
| 735 | wait_until r1, r7, r2 | ||
| 736 | |||
| 737 | emc_wait_auto_cal: | ||
| 738 | ldr r1, [r0, #EMC_AUTO_CAL_STATUS] | ||
| 739 | tst r1, #(1 << 31) @ wait until AUTO_CAL_ACTIVE is cleared | ||
| 740 | bne emc_wait_auto_cal | ||
| 741 | |||
| 742 | mov r1, #3 | ||
| 743 | str r1, [r0, #EMC_REQ_CTRL] @ stall incoming DRAM requests | ||
| 744 | |||
| 745 | emcidle: | ||
| 746 | ldr r1, [r0, #EMC_EMC_STATUS] | ||
| 747 | tst r1, #4 | ||
| 748 | beq emcidle | ||
| 749 | |||
| 750 | mov r1, #1 | ||
| 751 | str r1, [r0, #EMC_SELF_REF] | ||
| 752 | |||
| 753 | emc_device_mask r1, r0 | ||
| 754 | |||
| 755 | emcself: | ||
| 756 | ldr r2, [r0, #EMC_EMC_STATUS] | ||
| 757 | and r2, r2, r1 | ||
| 758 | cmp r2, r1 | ||
| 759 | bne emcself @ loop until DDR in self-refresh | ||
| 760 | |||
| 761 | /* Put VTTGEN in the lowest power mode */ | ||
| 762 | ldr r1, [r0, #EMC_XM2VTTGENPADCTRL] | ||
| 763 | mov32 r2, 0xF8F8FFFF @ clear XM2VTTGEN_DRVUP and XM2VTTGEN_DRVDN | ||
| 764 | and r1, r1, r2 | ||
| 765 | str r1, [r0, #EMC_XM2VTTGENPADCTRL] | ||
| 766 | ldr r1, [r0, #EMC_XM2VTTGENPADCTRL2] | ||
| 767 | cmp r10, #TEGRA30 | ||
| 768 | orreq r1, r1, #7 @ set E_NO_VTTGEN | ||
| 769 | orrne r1, r1, #0x3f | ||
| 770 | str r1, [r0, #EMC_XM2VTTGENPADCTRL2] | ||
| 771 | |||
| 772 | emc_timing_update r1, r0 | ||
| 773 | |||
| 774 | /* Tegra114 had dual EMC channel, now config the other one */ | ||
| 775 | cmp r10, #TEGRA114 | ||
| 776 | bne no_dual_emc_chanl | ||
| 777 | mov32 r1, TEGRA_EMC1_BASE | ||
| 778 | cmp r0, r1 | ||
| 779 | movne r0, r1 | ||
| 780 | bne enter_self_refresh | ||
| 781 | no_dual_emc_chanl: | ||
| 782 | |||
| 783 | ldr r1, [r4, #PMC_CTRL] | ||
| 784 | tst r1, #PMC_CTRL_SIDE_EFFECT_LP0 | ||
| 785 | bne pmc_io_dpd_skip | ||
| 786 | /* | ||
| 787 | * Put DDR_DATA, DISC_ADDR_CMD, DDR_ADDR_CMD, POP_ADDR_CMD, POP_CLK | ||
| 788 | * and COMP in the lowest power mode when LP1. | ||
| 789 | */ | ||
| 790 | mov32 r1, 0x8EC00000 | ||
| 791 | str r1, [r4, #PMC_IO_DPD_REQ] | ||
| 792 | pmc_io_dpd_skip: | ||
| 793 | |||
| 794 | dsb | ||
| 795 | |||
| 796 | mov pc, lr | ||
| 797 | |||
| 798 | .ltorg | ||
| 799 | /* dummy symbol for end of IRAM */ | ||
| 800 | .align L1_CACHE_SHIFT | ||
| 801 | .global tegra30_iram_end | ||
| 802 | tegra30_iram_end: | ||
| 803 | b . | ||
| 190 | #endif | 804 | #endif |
diff --git a/arch/arm/mach-tegra/sleep.S b/arch/arm/mach-tegra/sleep.S index 9daaef26b0f6..8d06213fbc47 100644 --- a/arch/arm/mach-tegra/sleep.S +++ b/arch/arm/mach-tegra/sleep.S | |||
| @@ -56,7 +56,9 @@ ENTRY(tegra_disable_clean_inv_dcache) | |||
| 56 | isb | 56 | isb |
| 57 | 57 | ||
| 58 | /* Flush the D-cache */ | 58 | /* Flush the D-cache */ |
| 59 | bl v7_flush_dcache_louis | 59 | cmp r0, #TEGRA_FLUSH_CACHE_ALL |
| 60 | blne v7_flush_dcache_louis | ||
| 61 | bleq v7_flush_dcache_all | ||
| 60 | 62 | ||
| 61 | /* Trun off coherency */ | 63 | /* Trun off coherency */ |
| 62 | exit_smp r4, r5 | 64 | exit_smp r4, r5 |
| @@ -67,15 +69,40 @@ ENDPROC(tegra_disable_clean_inv_dcache) | |||
| 67 | 69 | ||
| 68 | #ifdef CONFIG_PM_SLEEP | 70 | #ifdef CONFIG_PM_SLEEP |
| 69 | /* | 71 | /* |
| 72 | * tegra_init_l2_for_a15 | ||
| 73 | * | ||
| 74 | * set up the correct L2 cache data RAM latency | ||
| 75 | */ | ||
| 76 | ENTRY(tegra_init_l2_for_a15) | ||
| 77 | mrc p15, 0, r0, c0, c0, 5 | ||
| 78 | ubfx r0, r0, #8, #4 | ||
| 79 | tst r0, #1 @ only need for cluster 0 | ||
| 80 | bne _exit_init_l2_a15 | ||
| 81 | |||
| 82 | mrc p15, 0x1, r0, c9, c0, 2 | ||
| 83 | and r0, r0, #7 | ||
| 84 | cmp r0, #2 | ||
| 85 | bicne r0, r0, #7 | ||
| 86 | orrne r0, r0, #2 | ||
| 87 | mcrne p15, 0x1, r0, c9, c0, 2 | ||
| 88 | _exit_init_l2_a15: | ||
| 89 | |||
| 90 | mov pc, lr | ||
| 91 | ENDPROC(tegra_init_l2_for_a15) | ||
| 92 | |||
| 93 | /* | ||
| 70 | * tegra_sleep_cpu_finish(unsigned long v2p) | 94 | * tegra_sleep_cpu_finish(unsigned long v2p) |
| 71 | * | 95 | * |
| 72 | * enters suspend in LP2 by turning off the mmu and jumping to | 96 | * enters suspend in LP2 by turning off the mmu and jumping to |
| 73 | * tegra?_tear_down_cpu | 97 | * tegra?_tear_down_cpu |
| 74 | */ | 98 | */ |
| 75 | ENTRY(tegra_sleep_cpu_finish) | 99 | ENTRY(tegra_sleep_cpu_finish) |
| 100 | mov r4, r0 | ||
| 76 | /* Flush and disable the L1 data cache */ | 101 | /* Flush and disable the L1 data cache */ |
| 102 | mov r0, #TEGRA_FLUSH_CACHE_ALL | ||
| 77 | bl tegra_disable_clean_inv_dcache | 103 | bl tegra_disable_clean_inv_dcache |
| 78 | 104 | ||
| 105 | mov r0, r4 | ||
| 79 | mov32 r6, tegra_tear_down_cpu | 106 | mov32 r6, tegra_tear_down_cpu |
| 80 | ldr r1, [r6] | 107 | ldr r1, [r6] |
| 81 | add r1, r1, r0 | 108 | add r1, r1, r0 |
| @@ -107,10 +134,10 @@ ENTRY(tegra_shut_off_mmu) | |||
| 107 | #ifdef CONFIG_CACHE_L2X0 | 134 | #ifdef CONFIG_CACHE_L2X0 |
| 108 | /* Disable L2 cache */ | 135 | /* Disable L2 cache */ |
| 109 | check_cpu_part_num 0xc09, r9, r10 | 136 | check_cpu_part_num 0xc09, r9, r10 |
| 110 | movweq r4, #:lower16:(TEGRA_ARM_PERIF_BASE + 0x3000) | 137 | movweq r2, #:lower16:(TEGRA_ARM_PERIF_BASE + 0x3000) |
| 111 | movteq r4, #:upper16:(TEGRA_ARM_PERIF_BASE + 0x3000) | 138 | movteq r2, #:upper16:(TEGRA_ARM_PERIF_BASE + 0x3000) |
| 112 | moveq r5, #0 | 139 | moveq r3, #0 |
| 113 | streq r5, [r4, #L2X0_CTRL] | 140 | streq r3, [r2, #L2X0_CTRL] |
| 114 | #endif | 141 | #endif |
| 115 | mov pc, r0 | 142 | mov pc, r0 |
| 116 | ENDPROC(tegra_shut_off_mmu) | 143 | ENDPROC(tegra_shut_off_mmu) |
diff --git a/arch/arm/mach-tegra/sleep.h b/arch/arm/mach-tegra/sleep.h index 98b7da698f2b..a4edbb3abd3d 100644 --- a/arch/arm/mach-tegra/sleep.h +++ b/arch/arm/mach-tegra/sleep.h | |||
| @@ -41,7 +41,19 @@ | |||
| 41 | #define CPU_NOT_RESETTABLE 0 | 41 | #define CPU_NOT_RESETTABLE 0 |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | /* flag of tegra_disable_clean_inv_dcache to do LoUIS or all */ | ||
| 45 | #define TEGRA_FLUSH_CACHE_LOUIS 0 | ||
| 46 | #define TEGRA_FLUSH_CACHE_ALL 1 | ||
| 47 | |||
| 44 | #ifdef __ASSEMBLY__ | 48 | #ifdef __ASSEMBLY__ |
| 49 | /* waits until the microsecond counter (base) is > rn */ | ||
| 50 | .macro wait_until, rn, base, tmp | ||
| 51 | add \rn, \rn, #1 | ||
| 52 | 1001: ldr \tmp, [\base] | ||
| 53 | cmp \tmp, \rn | ||
| 54 | bmi 1001b | ||
| 55 | .endm | ||
| 56 | |||
| 45 | /* returns the offset of the flow controller halt register for a cpu */ | 57 | /* returns the offset of the flow controller halt register for a cpu */ |
| 46 | .macro cpu_to_halt_reg rd, rcpu | 58 | .macro cpu_to_halt_reg rd, rcpu |
| 47 | cmp \rcpu, #0 | 59 | cmp \rcpu, #0 |
| @@ -144,7 +156,7 @@ void tegra_pen_lock(void); | |||
| 144 | void tegra_pen_unlock(void); | 156 | void tegra_pen_unlock(void); |
| 145 | void tegra_resume(void); | 157 | void tegra_resume(void); |
| 146 | int tegra_sleep_cpu_finish(unsigned long); | 158 | int tegra_sleep_cpu_finish(unsigned long); |
| 147 | void tegra_disable_clean_inv_dcache(void); | 159 | void tegra_disable_clean_inv_dcache(u32 flag); |
| 148 | 160 | ||
| 149 | #ifdef CONFIG_HOTPLUG_CPU | 161 | #ifdef CONFIG_HOTPLUG_CPU |
| 150 | void tegra20_hotplug_shutdown(void); | 162 | void tegra20_hotplug_shutdown(void); |
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index 0d1e4128d460..fe56fcafdf15 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c | |||
| @@ -116,28 +116,6 @@ out: | |||
| 116 | tegra20_auxdata_lookup, parent); | 116 | tegra20_auxdata_lookup, parent); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | static void __init trimslice_init(void) | ||
| 120 | { | ||
| 121 | #ifdef CONFIG_TEGRA_PCI | ||
| 122 | int ret; | ||
| 123 | |||
| 124 | ret = tegra_pcie_init(true, true); | ||
| 125 | if (ret) | ||
| 126 | pr_err("tegra_pci_init() failed: %d\n", ret); | ||
| 127 | #endif | ||
| 128 | } | ||
| 129 | |||
| 130 | static void __init harmony_init(void) | ||
| 131 | { | ||
| 132 | #ifdef CONFIG_TEGRA_PCI | ||
| 133 | int ret; | ||
| 134 | |||
| 135 | ret = harmony_pcie_init(); | ||
| 136 | if (ret) | ||
| 137 | pr_err("harmony_pcie_init() failed: %d\n", ret); | ||
| 138 | #endif | ||
| 139 | } | ||
| 140 | |||
| 141 | static void __init paz00_init(void) | 119 | static void __init paz00_init(void) |
| 142 | { | 120 | { |
| 143 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) | 121 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) |
| @@ -148,8 +126,6 @@ static struct { | |||
| 148 | char *machine; | 126 | char *machine; |
| 149 | void (*init)(void); | 127 | void (*init)(void); |
| 150 | } board_init_funcs[] = { | 128 | } board_init_funcs[] = { |
| 151 | { "compulab,trimslice", trimslice_init }, | ||
| 152 | { "nvidia,harmony", harmony_init }, | ||
| 153 | { "compal,paz00", paz00_init }, | 129 | { "compal,paz00", paz00_init }, |
| 154 | }; | 130 | }; |
| 155 | 131 | ||
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 5a768ad8e893..098602b939a9 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig | |||
| @@ -9,7 +9,6 @@ config IA64 | |||
| 9 | select PCI if (!IA64_HP_SIM) | 9 | select PCI if (!IA64_HP_SIM) |
| 10 | select ACPI if (!IA64_HP_SIM) | 10 | select ACPI if (!IA64_HP_SIM) |
| 11 | select PM if (!IA64_HP_SIM) | 11 | select PM if (!IA64_HP_SIM) |
| 12 | select ARCH_SUPPORTS_MSI | ||
| 13 | select HAVE_UNSTABLE_SCHED_CLOCK | 12 | select HAVE_UNSTABLE_SCHED_CLOCK |
| 14 | select HAVE_IDE | 13 | select HAVE_IDE |
| 15 | select HAVE_OPROFILE | 14 | select HAVE_OPROFILE |
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index e12764c2a9d0..1e31fcb91157 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
| @@ -727,7 +727,6 @@ config CAVIUM_OCTEON_SOC | |||
| 727 | select SYS_HAS_CPU_CAVIUM_OCTEON | 727 | select SYS_HAS_CPU_CAVIUM_OCTEON |
| 728 | select SWAP_IO_SPACE | 728 | select SWAP_IO_SPACE |
| 729 | select HW_HAS_PCI | 729 | select HW_HAS_PCI |
| 730 | select ARCH_SUPPORTS_MSI | ||
| 731 | select ZONE_DMA32 | 730 | select ZONE_DMA32 |
| 732 | select USB_ARCH_HAS_OHCI | 731 | select USB_ARCH_HAS_OHCI |
| 733 | select USB_ARCH_HAS_EHCI | 732 | select USB_ARCH_HAS_EHCI |
| @@ -763,7 +762,6 @@ config NLM_XLR_BOARD | |||
| 763 | select CEVT_R4K | 762 | select CEVT_R4K |
| 764 | select CSRC_R4K | 763 | select CSRC_R4K |
| 765 | select IRQ_CPU | 764 | select IRQ_CPU |
| 766 | select ARCH_SUPPORTS_MSI | ||
| 767 | select ZONE_DMA32 if 64BIT | 765 | select ZONE_DMA32 if 64BIT |
| 768 | select SYNC_R4K | 766 | select SYNC_R4K |
| 769 | select SYS_HAS_EARLY_PRINTK | 767 | select SYS_HAS_EARLY_PRINTK |
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h index fa8e0aa250ca..f194c08bd057 100644 --- a/arch/mips/include/asm/pci.h +++ b/arch/mips/include/asm/pci.h | |||
| @@ -136,11 +136,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) | |||
| 136 | return channel ? 15 : 14; | 136 | return channel ? 15 : 14; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | #ifdef CONFIG_CPU_CAVIUM_OCTEON | ||
| 140 | /* MSI arch hook for OCTEON */ | ||
| 141 | #define arch_setup_msi_irqs arch_setup_msi_irqs | ||
| 142 | #endif | ||
| 143 | |||
| 144 | extern char * (*pcibios_plat_setup)(char *str); | 139 | extern char * (*pcibios_plat_setup)(char *str); |
| 145 | 140 | ||
| 146 | #ifdef CONFIG_OF | 141 | #ifdef CONFIG_OF |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index dbd9d3c991e8..3a678697b695 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
| @@ -727,7 +727,6 @@ config PCI | |||
| 727 | default y if !40x && !CPM2 && !8xx && !PPC_83xx \ | 727 | default y if !40x && !CPM2 && !8xx && !PPC_83xx \ |
| 728 | && !PPC_85xx && !PPC_86xx && !GAMECUBE_COMMON | 728 | && !PPC_85xx && !PPC_86xx && !GAMECUBE_COMMON |
| 729 | default PCI_QSPAN if !4xx && !CPM2 && 8xx | 729 | default PCI_QSPAN if !4xx && !CPM2 && 8xx |
| 730 | select ARCH_SUPPORTS_MSI | ||
| 731 | select GENERIC_PCI_IOMAP | 730 | select GENERIC_PCI_IOMAP |
| 732 | help | 731 | help |
| 733 | Find out whether your system includes a PCI bus. PCI is the name of | 732 | Find out whether your system includes a PCI bus. PCI is the name of |
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 6653f2743c4e..95145a15c708 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h | |||
| @@ -113,11 +113,6 @@ extern int pci_domain_nr(struct pci_bus *bus); | |||
| 113 | /* Decide whether to display the domain number in /proc */ | 113 | /* Decide whether to display the domain number in /proc */ |
| 114 | extern int pci_proc_domain(struct pci_bus *bus); | 114 | extern int pci_proc_domain(struct pci_bus *bus); |
| 115 | 115 | ||
| 116 | /* MSI arch hooks */ | ||
| 117 | #define arch_setup_msi_irqs arch_setup_msi_irqs | ||
| 118 | #define arch_teardown_msi_irqs arch_teardown_msi_irqs | ||
| 119 | #define arch_msi_check_device arch_msi_check_device | ||
| 120 | |||
| 121 | struct vm_area_struct; | 116 | struct vm_area_struct; |
| 122 | /* Map a range of PCI memory or I/O space for a device into user space */ | 117 | /* Map a range of PCI memory or I/O space for a device into user space */ |
| 123 | int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma, | 118 | int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma, |
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 8a4cae78f03c..21e5c165df28 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig | |||
| @@ -430,7 +430,6 @@ menuconfig PCI | |||
| 430 | bool "PCI support" | 430 | bool "PCI support" |
| 431 | default n | 431 | default n |
| 432 | depends on 64BIT | 432 | depends on 64BIT |
| 433 | select ARCH_SUPPORTS_MSI | ||
| 434 | select PCI_MSI | 433 | select PCI_MSI |
| 435 | help | 434 | help |
| 436 | Enable PCI support. | 435 | Enable PCI support. |
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 6e577ba0e5da..262b91bb8811 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h | |||
| @@ -21,10 +21,6 @@ void pci_iounmap(struct pci_dev *, void __iomem *); | |||
| 21 | int pci_domain_nr(struct pci_bus *); | 21 | int pci_domain_nr(struct pci_bus *); |
| 22 | int pci_proc_domain(struct pci_bus *); | 22 | int pci_proc_domain(struct pci_bus *); |
| 23 | 23 | ||
| 24 | /* MSI arch hooks */ | ||
| 25 | #define arch_setup_msi_irqs arch_setup_msi_irqs | ||
| 26 | #define arch_teardown_msi_irqs arch_teardown_msi_irqs | ||
| 27 | |||
| 28 | #define ZPCI_BUS_NR 0 /* default bus number */ | 24 | #define ZPCI_BUS_NR 0 /* default bus number */ |
| 29 | #define ZPCI_DEVFN 0 /* default device number */ | 25 | #define ZPCI_DEVFN 0 /* default device number */ |
| 30 | 26 | ||
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index a00cbd356db5..1570ad2802b3 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
| @@ -52,7 +52,6 @@ config SPARC32 | |||
| 52 | 52 | ||
| 53 | config SPARC64 | 53 | config SPARC64 |
| 54 | def_bool 64BIT | 54 | def_bool 64BIT |
| 55 | select ARCH_SUPPORTS_MSI | ||
| 56 | select HAVE_FUNCTION_TRACER | 55 | select HAVE_FUNCTION_TRACER |
| 57 | select HAVE_FUNCTION_GRAPH_TRACER | 56 | select HAVE_FUNCTION_GRAPH_TRACER |
| 58 | select HAVE_FUNCTION_GRAPH_FP_TEST | 57 | select HAVE_FUNCTION_GRAPH_FP_TEST |
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 24565a7ffe6d..74dff908a70f 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig | |||
| @@ -380,7 +380,6 @@ config PCI | |||
| 380 | select PCI_DOMAINS | 380 | select PCI_DOMAINS |
| 381 | select GENERIC_PCI_IOMAP | 381 | select GENERIC_PCI_IOMAP |
| 382 | select TILE_GXIO_TRIO if TILEGX | 382 | select TILE_GXIO_TRIO if TILEGX |
| 383 | select ARCH_SUPPORTS_MSI if TILEGX | ||
| 384 | select PCI_MSI if TILEGX | 383 | select PCI_MSI if TILEGX |
| 385 | ---help--- | 384 | ---help--- |
| 386 | Enable PCI root complex support, so PCIe endpoint devices can | 385 | Enable PCI root complex support, so PCIe endpoint devices can |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index b32ebf92b0ce..5db62ef37804 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -2014,7 +2014,6 @@ menu "Bus options (PCI etc.)" | |||
| 2014 | config PCI | 2014 | config PCI |
| 2015 | bool "PCI support" | 2015 | bool "PCI support" |
| 2016 | default y | 2016 | default y |
| 2017 | select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC) | ||
| 2018 | ---help--- | 2017 | ---help--- |
| 2019 | Find out whether you have a PCI motherboard. PCI is the name of a | 2018 | Find out whether you have a PCI motherboard. PCI is the name of a |
| 2020 | bus system, i.e. the way the CPU talks to the other stuff inside | 2019 | bus system, i.e. the way the CPU talks to the other stuff inside |
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h index d9e9e6c7ed32..7d7443283a9d 100644 --- a/arch/x86/include/asm/pci.h +++ b/arch/x86/include/asm/pci.h | |||
| @@ -100,29 +100,6 @@ static inline void early_quirks(void) { } | |||
| 100 | extern void pci_iommu_alloc(void); | 100 | extern void pci_iommu_alloc(void); |
| 101 | 101 | ||
| 102 | #ifdef CONFIG_PCI_MSI | 102 | #ifdef CONFIG_PCI_MSI |
| 103 | /* MSI arch specific hooks */ | ||
| 104 | static inline int x86_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | ||
| 105 | { | ||
| 106 | return x86_msi.setup_msi_irqs(dev, nvec, type); | ||
| 107 | } | ||
| 108 | |||
| 109 | static inline void x86_teardown_msi_irqs(struct pci_dev *dev) | ||
| 110 | { | ||
| 111 | x86_msi.teardown_msi_irqs(dev); | ||
| 112 | } | ||
| 113 | |||
| 114 | static inline void x86_teardown_msi_irq(unsigned int irq) | ||
| 115 | { | ||
| 116 | x86_msi.teardown_msi_irq(irq); | ||
| 117 | } | ||
| 118 | static inline void x86_restore_msi_irqs(struct pci_dev *dev, int irq) | ||
| 119 | { | ||
| 120 | x86_msi.restore_msi_irqs(dev, irq); | ||
| 121 | } | ||
| 122 | #define arch_setup_msi_irqs x86_setup_msi_irqs | ||
| 123 | #define arch_teardown_msi_irqs x86_teardown_msi_irqs | ||
| 124 | #define arch_teardown_msi_irq x86_teardown_msi_irq | ||
| 125 | #define arch_restore_msi_irqs x86_restore_msi_irqs | ||
| 126 | /* implemented in arch/x86/kernel/apic/io_apic. */ | 103 | /* implemented in arch/x86/kernel/apic/io_apic. */ |
| 127 | struct msi_desc; | 104 | struct msi_desc; |
| 128 | int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); | 105 | int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); |
| @@ -130,16 +107,9 @@ void native_teardown_msi_irq(unsigned int irq); | |||
| 130 | void native_restore_msi_irqs(struct pci_dev *dev, int irq); | 107 | void native_restore_msi_irqs(struct pci_dev *dev, int irq); |
| 131 | int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, | 108 | int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, |
| 132 | unsigned int irq_base, unsigned int irq_offset); | 109 | unsigned int irq_base, unsigned int irq_offset); |
| 133 | /* default to the implementation in drivers/lib/msi.c */ | ||
| 134 | #define HAVE_DEFAULT_MSI_TEARDOWN_IRQS | ||
| 135 | #define HAVE_DEFAULT_MSI_RESTORE_IRQS | ||
| 136 | void default_teardown_msi_irqs(struct pci_dev *dev); | ||
| 137 | void default_restore_msi_irqs(struct pci_dev *dev, int irq); | ||
| 138 | #else | 110 | #else |
| 139 | #define native_setup_msi_irqs NULL | 111 | #define native_setup_msi_irqs NULL |
| 140 | #define native_teardown_msi_irq NULL | 112 | #define native_teardown_msi_irq NULL |
| 141 | #define default_teardown_msi_irqs NULL | ||
| 142 | #define default_restore_msi_irqs NULL | ||
| 143 | #endif | 113 | #endif |
| 144 | 114 | ||
| 145 | #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) | 115 | #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) |
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index 5f24c71accaa..8ce0072cd700 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c | |||
| @@ -107,6 +107,8 @@ struct x86_platform_ops x86_platform = { | |||
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | EXPORT_SYMBOL_GPL(x86_platform); | 109 | EXPORT_SYMBOL_GPL(x86_platform); |
| 110 | |||
| 111 | #if defined(CONFIG_PCI_MSI) | ||
| 110 | struct x86_msi_ops x86_msi = { | 112 | struct x86_msi_ops x86_msi = { |
| 111 | .setup_msi_irqs = native_setup_msi_irqs, | 113 | .setup_msi_irqs = native_setup_msi_irqs, |
| 112 | .compose_msi_msg = native_compose_msi_msg, | 114 | .compose_msi_msg = native_compose_msi_msg, |
| @@ -116,6 +118,28 @@ struct x86_msi_ops x86_msi = { | |||
| 116 | .setup_hpet_msi = default_setup_hpet_msi, | 118 | .setup_hpet_msi = default_setup_hpet_msi, |
| 117 | }; | 119 | }; |
| 118 | 120 | ||
| 121 | /* MSI arch specific hooks */ | ||
| 122 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | ||
| 123 | { | ||
| 124 | return x86_msi.setup_msi_irqs(dev, nvec, type); | ||
| 125 | } | ||
| 126 | |||
| 127 | void arch_teardown_msi_irqs(struct pci_dev *dev) | ||
| 128 | { | ||
| 129 | x86_msi.teardown_msi_irqs(dev); | ||
| 130 | } | ||
| 131 | |||
| 132 | void arch_teardown_msi_irq(unsigned int irq) | ||
| 133 | { | ||
| 134 | x86_msi.teardown_msi_irq(irq); | ||
| 135 | } | ||
| 136 | |||
| 137 | void arch_restore_msi_irqs(struct pci_dev *dev, int irq) | ||
| 138 | { | ||
| 139 | x86_msi.restore_msi_irqs(dev, irq); | ||
| 140 | } | ||
| 141 | #endif | ||
| 142 | |||
| 119 | struct x86_io_apic_ops x86_io_apic_ops = { | 143 | struct x86_io_apic_ops x86_io_apic_ops = { |
| 120 | .init = native_io_apic_init_mappings, | 144 | .init = native_io_apic_init_mappings, |
| 121 | .read = native_io_apic_read, | 145 | .read = native_io_apic_read, |
diff --git a/drivers/clk/tegra/clk-tegra114.c b/drivers/clk/tegra/clk-tegra114.c index b6015cb4fc01..806d80366c54 100644 --- a/drivers/clk/tegra/clk-tegra114.c +++ b/drivers/clk/tegra/clk-tegra114.c | |||
| @@ -290,6 +290,14 @@ | |||
| 290 | /* Tegra CPU clock and reset control regs */ | 290 | /* Tegra CPU clock and reset control regs */ |
| 291 | #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470 | 291 | #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470 |
| 292 | 292 | ||
| 293 | #ifdef CONFIG_PM_SLEEP | ||
| 294 | static struct cpu_clk_suspend_context { | ||
| 295 | u32 clk_csite_src; | ||
| 296 | u32 cclkg_burst; | ||
| 297 | u32 cclkg_divider; | ||
| 298 | } tegra114_cpu_clk_sctx; | ||
| 299 | #endif | ||
| 300 | |||
| 293 | static int periph_clk_enb_refcnt[CLK_OUT_ENB_NUM * 32]; | 301 | static int periph_clk_enb_refcnt[CLK_OUT_ENB_NUM * 32]; |
| 294 | 302 | ||
| 295 | static void __iomem *clk_base; | 303 | static void __iomem *clk_base; |
| @@ -2142,9 +2150,39 @@ static void tegra114_disable_cpu_clock(u32 cpu) | |||
| 2142 | /* flow controller would take care in the power sequence. */ | 2150 | /* flow controller would take care in the power sequence. */ |
| 2143 | } | 2151 | } |
| 2144 | 2152 | ||
| 2153 | #ifdef CONFIG_PM_SLEEP | ||
| 2154 | static void tegra114_cpu_clock_suspend(void) | ||
| 2155 | { | ||
| 2156 | /* switch coresite to clk_m, save off original source */ | ||
| 2157 | tegra114_cpu_clk_sctx.clk_csite_src = | ||
| 2158 | readl(clk_base + CLK_SOURCE_CSITE); | ||
| 2159 | writel(3 << 30, clk_base + CLK_SOURCE_CSITE); | ||
| 2160 | |||
| 2161 | tegra114_cpu_clk_sctx.cclkg_burst = | ||
| 2162 | readl(clk_base + CCLKG_BURST_POLICY); | ||
| 2163 | tegra114_cpu_clk_sctx.cclkg_divider = | ||
| 2164 | readl(clk_base + CCLKG_BURST_POLICY + 4); | ||
| 2165 | } | ||
| 2166 | |||
| 2167 | static void tegra114_cpu_clock_resume(void) | ||
| 2168 | { | ||
| 2169 | writel(tegra114_cpu_clk_sctx.clk_csite_src, | ||
| 2170 | clk_base + CLK_SOURCE_CSITE); | ||
| 2171 | |||
| 2172 | writel(tegra114_cpu_clk_sctx.cclkg_burst, | ||
| 2173 | clk_base + CCLKG_BURST_POLICY); | ||
| 2174 | writel(tegra114_cpu_clk_sctx.cclkg_divider, | ||
| 2175 | clk_base + CCLKG_BURST_POLICY + 4); | ||
| 2176 | } | ||
| 2177 | #endif | ||
| 2178 | |||
| 2145 | static struct tegra_cpu_car_ops tegra114_cpu_car_ops = { | 2179 | static struct tegra_cpu_car_ops tegra114_cpu_car_ops = { |
| 2146 | .wait_for_reset = tegra114_wait_cpu_in_reset, | 2180 | .wait_for_reset = tegra114_wait_cpu_in_reset, |
| 2147 | .disable_clock = tegra114_disable_cpu_clock, | 2181 | .disable_clock = tegra114_disable_cpu_clock, |
| 2182 | #ifdef CONFIG_PM_SLEEP | ||
| 2183 | .suspend = tegra114_cpu_clock_suspend, | ||
| 2184 | .resume = tegra114_cpu_clock_resume, | ||
| 2185 | #endif | ||
| 2148 | }; | 2186 | }; |
| 2149 | 2187 | ||
| 2150 | static const struct of_device_id pmc_match[] __initconst = { | 2188 | static const struct of_device_id pmc_match[] __initconst = { |
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 42c687a820ac..e5ca00893c0c 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c | |||
| @@ -89,3 +89,48 @@ int of_pci_parse_bus_range(struct device_node *node, struct resource *res) | |||
| 89 | return 0; | 89 | return 0; |
| 90 | } | 90 | } |
| 91 | EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); | 91 | EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); |
| 92 | |||
| 93 | #ifdef CONFIG_PCI_MSI | ||
| 94 | |||
| 95 | static LIST_HEAD(of_pci_msi_chip_list); | ||
| 96 | static DEFINE_MUTEX(of_pci_msi_chip_mutex); | ||
| 97 | |||
| 98 | int of_pci_msi_chip_add(struct msi_chip *chip) | ||
| 99 | { | ||
| 100 | if (!of_property_read_bool(chip->of_node, "msi-controller")) | ||
| 101 | return -EINVAL; | ||
| 102 | |||
| 103 | mutex_lock(&of_pci_msi_chip_mutex); | ||
| 104 | list_add(&chip->list, &of_pci_msi_chip_list); | ||
| 105 | mutex_unlock(&of_pci_msi_chip_mutex); | ||
| 106 | |||
| 107 | return 0; | ||
| 108 | } | ||
| 109 | EXPORT_SYMBOL_GPL(of_pci_msi_chip_add); | ||
| 110 | |||
| 111 | void of_pci_msi_chip_remove(struct msi_chip *chip) | ||
| 112 | { | ||
| 113 | mutex_lock(&of_pci_msi_chip_mutex); | ||
| 114 | list_del(&chip->list); | ||
| 115 | mutex_unlock(&of_pci_msi_chip_mutex); | ||
| 116 | } | ||
| 117 | EXPORT_SYMBOL_GPL(of_pci_msi_chip_remove); | ||
| 118 | |||
| 119 | struct msi_chip *of_pci_find_msi_chip_by_node(struct device_node *of_node) | ||
| 120 | { | ||
| 121 | struct msi_chip *c; | ||
| 122 | |||
| 123 | mutex_lock(&of_pci_msi_chip_mutex); | ||
| 124 | list_for_each_entry(c, &of_pci_msi_chip_list, list) { | ||
| 125 | if (c->of_node == of_node) { | ||
| 126 | mutex_unlock(&of_pci_msi_chip_mutex); | ||
| 127 | return c; | ||
| 128 | } | ||
| 129 | } | ||
| 130 | mutex_unlock(&of_pci_msi_chip_mutex); | ||
| 131 | |||
| 132 | return NULL; | ||
| 133 | } | ||
| 134 | EXPORT_SYMBOL_GPL(of_pci_find_msi_chip_by_node); | ||
| 135 | |||
| 136 | #endif /* CONFIG_PCI_MSI */ | ||
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 81944fb73116..b6a99f7a9b20 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig | |||
| @@ -1,13 +1,9 @@ | |||
| 1 | # | 1 | # |
| 2 | # PCI configuration | 2 | # PCI configuration |
| 3 | # | 3 | # |
| 4 | config ARCH_SUPPORTS_MSI | ||
| 5 | bool | ||
| 6 | |||
| 7 | config PCI_MSI | 4 | config PCI_MSI |
| 8 | bool "Message Signaled Interrupts (MSI and MSI-X)" | 5 | bool "Message Signaled Interrupts (MSI and MSI-X)" |
| 9 | depends on PCI | 6 | depends on PCI |
| 10 | depends on ARCH_SUPPORTS_MSI | ||
| 11 | help | 7 | help |
| 12 | This allows device drivers to enable MSI (Message Signaled | 8 | This allows device drivers to enable MSI (Message Signaled |
| 13 | Interrupts). Message Signaled Interrupts enable a device to | 9 | Interrupts). Message Signaled Interrupts enable a device to |
diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index 1184ff6fe864..5f33746c925b 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig | |||
| @@ -14,4 +14,8 @@ config PCI_EXYNOS | |||
| 14 | select PCIEPORTBUS | 14 | select PCIEPORTBUS |
| 15 | select PCIE_DW | 15 | select PCIE_DW |
| 16 | 16 | ||
| 17 | config PCI_TEGRA | ||
| 18 | bool "NVIDIA Tegra PCIe controller" | ||
| 19 | depends on ARCH_TEGRA | ||
| 20 | |||
| 17 | endmenu | 21 | endmenu |
diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile index 086d8500e849..a733fb0f7856 100644 --- a/drivers/pci/host/Makefile +++ b/drivers/pci/host/Makefile | |||
| @@ -1,2 +1,3 @@ | |||
| 1 | obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o | 1 | obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o |
| 2 | obj-$(CONFIG_PCIE_DW) += pcie-designware.o | 2 | obj-$(CONFIG_PCIE_DW) += pcie-designware.o |
| 3 | obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o | ||
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c new file mode 100644 index 000000000000..7356741de36b --- /dev/null +++ b/drivers/pci/host/pci-tegra.c | |||
| @@ -0,0 +1,1702 @@ | |||
| 1 | /* | ||
| 2 | * PCIe host controller driver for Tegra SoCs | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010, CompuLab, Ltd. | ||
| 5 | * Author: Mike Rapoport <mike@compulab.co.il> | ||
| 6 | * | ||
| 7 | * Based on NVIDIA PCIe driver | ||
| 8 | * Copyright (c) 2008-2009, NVIDIA Corporation. | ||
| 9 | * | ||
| 10 | * Bits taken from arch/arm/mach-dove/pcie.c | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify | ||
| 13 | * it under the terms of the GNU General Public License as published by | ||
| 14 | * the Free Software Foundation; either version 2 of the License, or | ||
| 15 | * (at your option) any later version. | ||
| 16 | * | ||
| 17 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 20 | * more details. | ||
| 21 | * | ||
| 22 | * You should have received a copy of the GNU General Public License along | ||
| 23 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include <linux/clk.h> | ||
| 28 | #include <linux/clk/tegra.h> | ||
| 29 | #include <linux/delay.h> | ||
| 30 | #include <linux/export.h> | ||
| 31 | #include <linux/interrupt.h> | ||
| 32 | #include <linux/irq.h> | ||
| 33 | #include <linux/irqdomain.h> | ||
| 34 | #include <linux/kernel.h> | ||
| 35 | #include <linux/module.h> | ||
| 36 | #include <linux/msi.h> | ||
| 37 | #include <linux/of_address.h> | ||
| 38 | #include <linux/of_pci.h> | ||
| 39 | #include <linux/of_platform.h> | ||
| 40 | #include <linux/pci.h> | ||
| 41 | #include <linux/platform_device.h> | ||
| 42 | #include <linux/sizes.h> | ||
| 43 | #include <linux/slab.h> | ||
| 44 | #include <linux/tegra-cpuidle.h> | ||
| 45 | #include <linux/tegra-powergate.h> | ||
| 46 | #include <linux/vmalloc.h> | ||
| 47 | #include <linux/regulator/consumer.h> | ||
| 48 | |||
| 49 | #include <asm/mach/irq.h> | ||
| 50 | #include <asm/mach/map.h> | ||
| 51 | #include <asm/mach/pci.h> | ||
| 52 | |||
| 53 | #define INT_PCI_MSI_NR (8 * 32) | ||
| 54 | |||
| 55 | /* register definitions */ | ||
| 56 | |||
| 57 | #define AFI_AXI_BAR0_SZ 0x00 | ||
| 58 | #define AFI_AXI_BAR1_SZ 0x04 | ||
| 59 | #define AFI_AXI_BAR2_SZ 0x08 | ||
| 60 | #define AFI_AXI_BAR3_SZ 0x0c | ||
| 61 | #define AFI_AXI_BAR4_SZ 0x10 | ||
| 62 | #define AFI_AXI_BAR5_SZ 0x14 | ||
| 63 | |||
| 64 | #define AFI_AXI_BAR0_START 0x18 | ||
| 65 | #define AFI_AXI_BAR1_START 0x1c | ||
| 66 | #define AFI_AXI_BAR2_START 0x20 | ||
| 67 | #define AFI_AXI_BAR3_START 0x24 | ||
| 68 | #define AFI_AXI_BAR4_START 0x28 | ||
| 69 | #define AFI_AXI_BAR5_START 0x2c | ||
| 70 | |||
| 71 | #define AFI_FPCI_BAR0 0x30 | ||
| 72 | #define AFI_FPCI_BAR1 0x34 | ||
| 73 | #define AFI_FPCI_BAR2 0x38 | ||
| 74 | #define AFI_FPCI_BAR3 0x3c | ||
| 75 | #define AFI_FPCI_BAR4 0x40 | ||
| 76 | #define AFI_FPCI_BAR5 0x44 | ||
| 77 | |||
| 78 | #define AFI_CACHE_BAR0_SZ 0x48 | ||
| 79 | #define AFI_CACHE_BAR0_ST 0x4c | ||
| 80 | #define AFI_CACHE_BAR1_SZ 0x50 | ||
| 81 | #define AFI_CACHE_BAR1_ST 0x54 | ||
| 82 | |||
| 83 | #define AFI_MSI_BAR_SZ 0x60 | ||
| 84 | #define AFI_MSI_FPCI_BAR_ST 0x64 | ||
| 85 | #define AFI_MSI_AXI_BAR_ST 0x68 | ||
| 86 | |||
| 87 | #define AFI_MSI_VEC0 0x6c | ||
| 88 | #define AFI_MSI_VEC1 0x70 | ||
| 89 | #define AFI_MSI_VEC2 0x74 | ||
| 90 | #define AFI_MSI_VEC3 0x78 | ||
| 91 | #define AFI_MSI_VEC4 0x7c | ||
| 92 | #define AFI_MSI_VEC5 0x80 | ||
| 93 | #define AFI_MSI_VEC6 0x84 | ||
| 94 | #define AFI_MSI_VEC7 0x88 | ||
| 95 | |||
| 96 | #define AFI_MSI_EN_VEC0 0x8c | ||
| 97 | #define AFI_MSI_EN_VEC1 0x90 | ||
| 98 | #define AFI_MSI_EN_VEC2 0x94 | ||
| 99 | #define AFI_MSI_EN_VEC3 0x98 | ||
| 100 | #define AFI_MSI_EN_VEC4 0x9c | ||
| 101 | #define AFI_MSI_EN_VEC5 0xa0 | ||
| 102 | #define AFI_MSI_EN_VEC6 0xa4 | ||
| 103 | #define AFI_MSI_EN_VEC7 0xa8 | ||
| 104 | |||
| 105 | #define AFI_CONFIGURATION 0xac | ||
| 106 | #define AFI_CONFIGURATION_EN_FPCI (1 << 0) | ||
| 107 | |||
| 108 | #define AFI_FPCI_ERROR_MASKS 0xb0 | ||
| 109 | |||
| 110 | #define AFI_INTR_MASK 0xb4 | ||
| 111 | #define AFI_INTR_MASK_INT_MASK (1 << 0) | ||
| 112 | #define AFI_INTR_MASK_MSI_MASK (1 << 8) | ||
| 113 | |||
| 114 | #define AFI_INTR_CODE 0xb8 | ||
| 115 | #define AFI_INTR_CODE_MASK 0xf | ||
| 116 | #define AFI_INTR_AXI_SLAVE_ERROR 1 | ||
| 117 | #define AFI_INTR_AXI_DECODE_ERROR 2 | ||
| 118 | #define AFI_INTR_TARGET_ABORT 3 | ||
| 119 | #define AFI_INTR_MASTER_ABORT 4 | ||
| 120 | #define AFI_INTR_INVALID_WRITE 5 | ||
| 121 | #define AFI_INTR_LEGACY 6 | ||
| 122 | #define AFI_INTR_FPCI_DECODE_ERROR 7 | ||
| 123 | |||
| 124 | #define AFI_INTR_SIGNATURE 0xbc | ||
| 125 | #define AFI_UPPER_FPCI_ADDRESS 0xc0 | ||
| 126 | #define AFI_SM_INTR_ENABLE 0xc4 | ||
| 127 | #define AFI_SM_INTR_INTA_ASSERT (1 << 0) | ||
| 128 | #define AFI_SM_INTR_INTB_ASSERT (1 << 1) | ||
| 129 | #define AFI_SM_INTR_INTC_ASSERT (1 << 2) | ||
| 130 | #define AFI_SM_INTR_INTD_ASSERT (1 << 3) | ||
| 131 | #define AFI_SM_INTR_INTA_DEASSERT (1 << 4) | ||
| 132 | #define AFI_SM_INTR_INTB_DEASSERT (1 << 5) | ||
| 133 | #define AFI_SM_INTR_INTC_DEASSERT (1 << 6) | ||
| 134 | #define AFI_SM_INTR_INTD_DEASSERT (1 << 7) | ||
| 135 | |||
| 136 | #define AFI_AFI_INTR_ENABLE 0xc8 | ||
| 137 | #define AFI_INTR_EN_INI_SLVERR (1 << 0) | ||
| 138 | #define AFI_INTR_EN_INI_DECERR (1 << 1) | ||
| 139 | #define AFI_INTR_EN_TGT_SLVERR (1 << 2) | ||
| 140 | #define AFI_INTR_EN_TGT_DECERR (1 << 3) | ||
| 141 | #define AFI_INTR_EN_TGT_WRERR (1 << 4) | ||
| 142 | #define AFI_INTR_EN_DFPCI_DECERR (1 << 5) | ||
| 143 | #define AFI_INTR_EN_AXI_DECERR (1 << 6) | ||
| 144 | #define AFI_INTR_EN_FPCI_TIMEOUT (1 << 7) | ||
| 145 | #define AFI_INTR_EN_PRSNT_SENSE (1 << 8) | ||
| 146 | |||
| 147 | #define AFI_PCIE_CONFIG 0x0f8 | ||
| 148 | #define AFI_PCIE_CONFIG_PCIE_DISABLE(x) (1 << ((x) + 1)) | ||
| 149 | #define AFI_PCIE_CONFIG_PCIE_DISABLE_ALL 0xe | ||
| 150 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK (0xf << 20) | ||
| 151 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_SINGLE (0x0 << 20) | ||
| 152 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_420 (0x0 << 20) | ||
| 153 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_DUAL (0x1 << 20) | ||
| 154 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_222 (0x1 << 20) | ||
| 155 | #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_411 (0x2 << 20) | ||
| 156 | |||
| 157 | #define AFI_FUSE 0x104 | ||
| 158 | #define AFI_FUSE_PCIE_T0_GEN2_DIS (1 << 2) | ||
| 159 | |||
| 160 | #define AFI_PEX0_CTRL 0x110 | ||
| 161 | #define AFI_PEX1_CTRL 0x118 | ||
| 162 | #define AFI_PEX2_CTRL 0x128 | ||
| 163 | #define AFI_PEX_CTRL_RST (1 << 0) | ||
| 164 | #define AFI_PEX_CTRL_CLKREQ_EN (1 << 1) | ||
| 165 | #define AFI_PEX_CTRL_REFCLK_EN (1 << 3) | ||
| 166 | |||
| 167 | #define AFI_PEXBIAS_CTRL_0 0x168 | ||
| 168 | |||
| 169 | #define RP_VEND_XP 0x00000F00 | ||
| 170 | #define RP_VEND_XP_DL_UP (1 << 30) | ||
| 171 | |||
| 172 | #define RP_LINK_CONTROL_STATUS 0x00000090 | ||
| 173 | #define RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE 0x20000000 | ||
| 174 | #define RP_LINK_CONTROL_STATUS_LINKSTAT_MASK 0x3fff0000 | ||
| 175 | |||
| 176 | #define PADS_CTL_SEL 0x0000009C | ||
| 177 | |||
| 178 | #define PADS_CTL 0x000000A0 | ||
| 179 | #define PADS_CTL_IDDQ_1L (1 << 0) | ||
| 180 | #define PADS_CTL_TX_DATA_EN_1L (1 << 6) | ||
| 181 | #define PADS_CTL_RX_DATA_EN_1L (1 << 10) | ||
| 182 | |||
| 183 | #define PADS_PLL_CTL_TEGRA20 0x000000B8 | ||
| 184 | #define PADS_PLL_CTL_TEGRA30 0x000000B4 | ||
| 185 | #define PADS_PLL_CTL_RST_B4SM (1 << 1) | ||
| 186 | #define PADS_PLL_CTL_LOCKDET (1 << 8) | ||
| 187 | #define PADS_PLL_CTL_REFCLK_MASK (0x3 << 16) | ||
| 188 | #define PADS_PLL_CTL_REFCLK_INTERNAL_CML (0 << 16) | ||
| 189 | #define PADS_PLL_CTL_REFCLK_INTERNAL_CMOS (1 << 16) | ||
| 190 | #define PADS_PLL_CTL_REFCLK_EXTERNAL (2 << 16) | ||
| 191 | #define PADS_PLL_CTL_TXCLKREF_MASK (0x1 << 20) | ||
| 192 | #define PADS_PLL_CTL_TXCLKREF_DIV10 (0 << 20) | ||
| 193 | #define PADS_PLL_CTL_TXCLKREF_DIV5 (1 << 20) | ||
| 194 | #define PADS_PLL_CTL_TXCLKREF_BUF_EN (1 << 22) | ||
| 195 | |||
| 196 | #define PADS_REFCLK_CFG0 0x000000C8 | ||
| 197 | #define PADS_REFCLK_CFG1 0x000000CC | ||
| 198 | |||
| 199 | /* | ||
| 200 | * Fields in PADS_REFCLK_CFG*. Those registers form an array of 16-bit | ||
| 201 | * entries, one entry per PCIe port. These field definitions and desired | ||
| 202 | * values aren't in the TRM, but do come from NVIDIA. | ||
| 203 | */ | ||
| 204 | #define PADS_REFCLK_CFG_TERM_SHIFT 2 /* 6:2 */ | ||
| 205 | #define PADS_REFCLK_CFG_E_TERM_SHIFT 7 | ||
| 206 | #define PADS_REFCLK_CFG_PREDI_SHIFT 8 /* 11:8 */ | ||
| 207 | #define PADS_REFCLK_CFG_DRVI_SHIFT 12 /* 15:12 */ | ||
| 208 | |||
| 209 | /* Default value provided by HW engineering is 0xfa5c */ | ||
| 210 | #define PADS_REFCLK_CFG_VALUE \ | ||
| 211 | ( \ | ||
| 212 | (0x17 << PADS_REFCLK_CFG_TERM_SHIFT) | \ | ||
| 213 | (0 << PADS_REFCLK_CFG_E_TERM_SHIFT) | \ | ||
| 214 | (0xa << PADS_REFCLK_CFG_PREDI_SHIFT) | \ | ||
| 215 | (0xf << PADS_REFCLK_CFG_DRVI_SHIFT) \ | ||
| 216 | ) | ||
| 217 | |||
| 218 | struct tegra_msi { | ||
| 219 | struct msi_chip chip; | ||
| 220 | DECLARE_BITMAP(used, INT_PCI_MSI_NR); | ||
| 221 | struct irq_domain *domain; | ||
| 222 | unsigned long pages; | ||
| 223 | struct mutex lock; | ||
| 224 | int irq; | ||
| 225 | }; | ||
| 226 | |||
| 227 | /* used to differentiate between Tegra SoC generations */ | ||
| 228 | struct tegra_pcie_soc_data { | ||
| 229 | unsigned int num_ports; | ||
| 230 | unsigned int msi_base_shift; | ||
| 231 | u32 pads_pll_ctl; | ||
| 232 | u32 tx_ref_sel; | ||
| 233 | bool has_pex_clkreq_en; | ||
| 234 | bool has_pex_bias_ctrl; | ||
| 235 | bool has_intr_prsnt_sense; | ||
| 236 | bool has_avdd_supply; | ||
| 237 | bool has_cml_clk; | ||
| 238 | }; | ||
| 239 | |||
| 240 | static inline struct tegra_msi *to_tegra_msi(struct msi_chip *chip) | ||
| 241 | { | ||
| 242 | return container_of(chip, struct tegra_msi, chip); | ||
| 243 | } | ||
| 244 | |||
| 245 | struct tegra_pcie { | ||
| 246 | struct device *dev; | ||
| 247 | |||
| 248 | void __iomem *pads; | ||
| 249 | void __iomem *afi; | ||
| 250 | int irq; | ||
| 251 | |||
| 252 | struct list_head busses; | ||
| 253 | struct resource *cs; | ||
| 254 | |||
| 255 | struct resource io; | ||
| 256 | struct resource mem; | ||
| 257 | struct resource prefetch; | ||
| 258 | struct resource busn; | ||
| 259 | |||
| 260 | struct clk *pex_clk; | ||
| 261 | struct clk *afi_clk; | ||
| 262 | struct clk *pcie_xclk; | ||
| 263 | struct clk *pll_e; | ||
| 264 | struct clk *cml_clk; | ||
| 265 | |||
| 266 | struct tegra_msi msi; | ||
| 267 | |||
| 268 | struct list_head ports; | ||
| 269 | unsigned int num_ports; | ||
| 270 | u32 xbar_config; | ||
| 271 | |||
| 272 | struct regulator *pex_clk_supply; | ||
| 273 | struct regulator *vdd_supply; | ||
| 274 | struct regulator *avdd_supply; | ||
| 275 | |||
| 276 | const struct tegra_pcie_soc_data *soc_data; | ||
| 277 | }; | ||
| 278 | |||
| 279 | struct tegra_pcie_port { | ||
| 280 | struct tegra_pcie *pcie; | ||
| 281 | struct list_head list; | ||
| 282 | struct resource regs; | ||
| 283 | void __iomem *base; | ||
| 284 | unsigned int index; | ||
| 285 | unsigned int lanes; | ||
| 286 | }; | ||
| 287 | |||
| 288 | struct tegra_pcie_bus { | ||
| 289 | struct vm_struct *area; | ||
| 290 | struct list_head list; | ||
| 291 | unsigned int nr; | ||
| 292 | }; | ||
| 293 | |||
| 294 | static inline struct tegra_pcie *sys_to_pcie(struct pci_sys_data *sys) | ||
| 295 | { | ||
| 296 | return sys->private_data; | ||
| 297 | } | ||
| 298 | |||
| 299 | static inline void afi_writel(struct tegra_pcie *pcie, u32 value, | ||
| 300 | unsigned long offset) | ||
| 301 | { | ||
| 302 | writel(value, pcie->afi + offset); | ||
| 303 | } | ||
| 304 | |||
| 305 | static inline u32 afi_readl(struct tegra_pcie *pcie, unsigned long offset) | ||
| 306 | { | ||
| 307 | return readl(pcie->afi + offset); | ||
| 308 | } | ||
| 309 | |||
| 310 | static inline void pads_writel(struct tegra_pcie *pcie, u32 value, | ||
| 311 | unsigned long offset) | ||
| 312 | { | ||
| 313 | writel(value, pcie->pads + offset); | ||
| 314 | } | ||
| 315 | |||
| 316 | static inline u32 pads_readl(struct tegra_pcie *pcie, unsigned long offset) | ||
| 317 | { | ||
| 318 | return readl(pcie->pads + offset); | ||
| 319 | } | ||
| 320 | |||
| 321 | /* | ||
| 322 | * The configuration space mapping on Tegra is somewhat similar to the ECAM | ||
| 323 | * defined by PCIe. However it deviates a bit in how the 4 bits for extended | ||
| 324 | * register accesses are mapped: | ||
| 325 | * | ||
| 326 | * [27:24] extended register number | ||
| 327 | * [23:16] bus number | ||
| 328 | * [15:11] device number | ||
| 329 | * [10: 8] function number | ||
| 330 | * [ 7: 0] register number | ||
| 331 | * | ||
| 332 | * Mapping the whole extended configuration space would require 256 MiB of | ||
| 333 | * virtual address space, only a small part of which will actually be used. | ||
| 334 | * To work around this, a 1 MiB of virtual addresses are allocated per bus | ||
| 335 | * when the bus is first accessed. When the physical range is mapped, the | ||
| 336 | * the bus number bits are hidden so that the extended register number bits | ||
| 337 | * appear as bits [19:16]. Therefore the virtual mapping looks like this: | ||
| 338 | * | ||
| 339 | * [19:16] extended register number | ||
| 340 | * [15:11] device number | ||
| 341 | * [10: 8] function number | ||
| 342 | * [ 7: 0] register number | ||
| 343 | * | ||
| 344 | * This is achieved by stitching together 16 chunks of 64 KiB of physical | ||
| 345 | * address space via the MMU. | ||
| 346 | */ | ||
| 347 | static unsigned long tegra_pcie_conf_offset(unsigned int devfn, int where) | ||
| 348 | { | ||
| 349 | return ((where & 0xf00) << 8) | (PCI_SLOT(devfn) << 11) | | ||
| 350 | (PCI_FUNC(devfn) << 8) | (where & 0xfc); | ||
| 351 | } | ||
| 352 | |||
| 353 | static struct tegra_pcie_bus *tegra_pcie_bus_alloc(struct tegra_pcie *pcie, | ||
| 354 | unsigned int busnr) | ||
| 355 | { | ||
| 356 | pgprot_t prot = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_XN | | ||
| 357 | L_PTE_MT_DEV_SHARED | L_PTE_SHARED; | ||
| 358 | phys_addr_t cs = pcie->cs->start; | ||
| 359 | struct tegra_pcie_bus *bus; | ||
| 360 | unsigned int i; | ||
| 361 | int err; | ||
| 362 | |||
| 363 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); | ||
| 364 | if (!bus) | ||
| 365 | return ERR_PTR(-ENOMEM); | ||
| 366 | |||
| 367 | INIT_LIST_HEAD(&bus->list); | ||
| 368 | bus->nr = busnr; | ||
| 369 | |||
| 370 | /* allocate 1 MiB of virtual addresses */ | ||
| 371 | bus->area = get_vm_area(SZ_1M, VM_IOREMAP); | ||
| 372 | if (!bus->area) { | ||
| 373 | err = -ENOMEM; | ||
| 374 | goto free; | ||
| 375 | } | ||
| 376 | |||
| 377 | /* map each of the 16 chunks of 64 KiB each */ | ||
| 378 | for (i = 0; i < 16; i++) { | ||
| 379 | unsigned long virt = (unsigned long)bus->area->addr + | ||
| 380 | i * SZ_64K; | ||
| 381 | phys_addr_t phys = cs + i * SZ_1M + busnr * SZ_64K; | ||
| 382 | |||
| 383 | err = ioremap_page_range(virt, virt + SZ_64K, phys, prot); | ||
| 384 | if (err < 0) { | ||
| 385 | dev_err(pcie->dev, "ioremap_page_range() failed: %d\n", | ||
| 386 | err); | ||
| 387 | goto unmap; | ||
| 388 | } | ||
| 389 | } | ||
| 390 | |||
| 391 | return bus; | ||
| 392 | |||
| 393 | unmap: | ||
| 394 | vunmap(bus->area->addr); | ||
| 395 | free: | ||
| 396 | kfree(bus); | ||
| 397 | return ERR_PTR(err); | ||
| 398 | } | ||
| 399 | |||
| 400 | /* | ||
| 401 | * Look up a virtual address mapping for the specified bus number. If no such | ||
| 402 | * mapping existis, try to create one. | ||
| 403 | */ | ||
| 404 | static void __iomem *tegra_pcie_bus_map(struct tegra_pcie *pcie, | ||
| 405 | unsigned int busnr) | ||
| 406 | { | ||
| 407 | struct tegra_pcie_bus *bus; | ||
| 408 | |||
| 409 | list_for_each_entry(bus, &pcie->busses, list) | ||
| 410 | if (bus->nr == busnr) | ||
| 411 | return bus->area->addr; | ||
| 412 | |||
| 413 | bus = tegra_pcie_bus_alloc(pcie, busnr); | ||
| 414 | if (IS_ERR(bus)) | ||
| 415 | return NULL; | ||
| 416 | |||
| 417 | list_add_tail(&bus->list, &pcie->busses); | ||
| 418 | |||
| 419 | return bus->area->addr; | ||
| 420 | } | ||
| 421 | |||
| 422 | static void __iomem *tegra_pcie_conf_address(struct pci_bus *bus, | ||
| 423 | unsigned int devfn, | ||
| 424 | int where) | ||
| 425 | { | ||
| 426 | struct tegra_pcie *pcie = sys_to_pcie(bus->sysdata); | ||
| 427 | void __iomem *addr = NULL; | ||
| 428 | |||
| 429 | if (bus->number == 0) { | ||
| 430 | unsigned int slot = PCI_SLOT(devfn); | ||
| 431 | struct tegra_pcie_port *port; | ||
| 432 | |||
| 433 | list_for_each_entry(port, &pcie->ports, list) { | ||
| 434 | if (port->index + 1 == slot) { | ||
| 435 | addr = port->base + (where & ~3); | ||
| 436 | break; | ||
| 437 | } | ||
| 438 | } | ||
| 439 | } else { | ||
| 440 | addr = tegra_pcie_bus_map(pcie, bus->number); | ||
| 441 | if (!addr) { | ||
| 442 | dev_err(pcie->dev, | ||
| 443 | "failed to map cfg. space for bus %u\n", | ||
| 444 | bus->number); | ||
| 445 | return NULL; | ||
| 446 | } | ||
| 447 | |||
| 448 | addr += tegra_pcie_conf_offset(devfn, where); | ||
| 449 | } | ||
| 450 | |||
| 451 | return addr; | ||
| 452 | } | ||
| 453 | |||
| 454 | static int tegra_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, | ||
| 455 | int where, int size, u32 *value) | ||
| 456 | { | ||
| 457 | void __iomem *addr; | ||
| 458 | |||
| 459 | addr = tegra_pcie_conf_address(bus, devfn, where); | ||
| 460 | if (!addr) { | ||
| 461 | *value = 0xffffffff; | ||
| 462 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 463 | } | ||
| 464 | |||
| 465 | *value = readl(addr); | ||
| 466 | |||
| 467 | if (size == 1) | ||
| 468 | *value = (*value >> (8 * (where & 3))) & 0xff; | ||
| 469 | else if (size == 2) | ||
| 470 | *value = (*value >> (8 * (where & 3))) & 0xffff; | ||
| 471 | |||
| 472 | return PCIBIOS_SUCCESSFUL; | ||
| 473 | } | ||
| 474 | |||
| 475 | static int tegra_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, | ||
| 476 | int where, int size, u32 value) | ||
| 477 | { | ||
| 478 | void __iomem *addr; | ||
| 479 | u32 mask, tmp; | ||
| 480 | |||
| 481 | addr = tegra_pcie_conf_address(bus, devfn, where); | ||
| 482 | if (!addr) | ||
| 483 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 484 | |||
| 485 | if (size == 4) { | ||
| 486 | writel(value, addr); | ||
| 487 | return PCIBIOS_SUCCESSFUL; | ||
| 488 | } | ||
| 489 | |||
| 490 | if (size == 2) | ||
| 491 | mask = ~(0xffff << ((where & 0x3) * 8)); | ||
| 492 | else if (size == 1) | ||
| 493 | mask = ~(0xff << ((where & 0x3) * 8)); | ||
| 494 | else | ||
| 495 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
| 496 | |||
| 497 | tmp = readl(addr) & mask; | ||
| 498 | tmp |= value << ((where & 0x3) * 8); | ||
| 499 | writel(tmp, addr); | ||
| 500 | |||
| 501 | return PCIBIOS_SUCCESSFUL; | ||
| 502 | } | ||
| 503 | |||
| 504 | static struct pci_ops tegra_pcie_ops = { | ||
| 505 | .read = tegra_pcie_read_conf, | ||
| 506 | .write = tegra_pcie_write_conf, | ||
| 507 | }; | ||
| 508 | |||
| 509 | static unsigned long tegra_pcie_port_get_pex_ctrl(struct tegra_pcie_port *port) | ||
| 510 | { | ||
| 511 | unsigned long ret = 0; | ||
| 512 | |||
| 513 | switch (port->index) { | ||
| 514 | case 0: | ||
| 515 | ret = AFI_PEX0_CTRL; | ||
| 516 | break; | ||
| 517 | |||
| 518 | case 1: | ||
| 519 | ret = AFI_PEX1_CTRL; | ||
| 520 | break; | ||
| 521 | |||
| 522 | case 2: | ||
| 523 | ret = AFI_PEX2_CTRL; | ||
| 524 | break; | ||
| 525 | } | ||
| 526 | |||
| 527 | return ret; | ||
| 528 | } | ||
| 529 | |||
| 530 | static void tegra_pcie_port_reset(struct tegra_pcie_port *port) | ||
| 531 | { | ||
| 532 | unsigned long ctrl = tegra_pcie_port_get_pex_ctrl(port); | ||
| 533 | unsigned long value; | ||
| 534 | |||
| 535 | /* pulse reset signal */ | ||
| 536 | value = afi_readl(port->pcie, ctrl); | ||
| 537 | value &= ~AFI_PEX_CTRL_RST; | ||
| 538 | afi_writel(port->pcie, value, ctrl); | ||
| 539 | |||
| 540 | usleep_range(1000, 2000); | ||
| 541 | |||
| 542 | value = afi_readl(port->pcie, ctrl); | ||
| 543 | value |= AFI_PEX_CTRL_RST; | ||
| 544 | afi_writel(port->pcie, value, ctrl); | ||
| 545 | } | ||
| 546 | |||
| 547 | static void tegra_pcie_port_enable(struct tegra_pcie_port *port) | ||
| 548 | { | ||
| 549 | const struct tegra_pcie_soc_data *soc = port->pcie->soc_data; | ||
| 550 | unsigned long ctrl = tegra_pcie_port_get_pex_ctrl(port); | ||
| 551 | unsigned long value; | ||
| 552 | |||
| 553 | /* enable reference clock */ | ||
| 554 | value = afi_readl(port->pcie, ctrl); | ||
| 555 | value |= AFI_PEX_CTRL_REFCLK_EN; | ||
| 556 | |||
| 557 | if (soc->has_pex_clkreq_en) | ||
| 558 | value |= AFI_PEX_CTRL_CLKREQ_EN; | ||
| 559 | |||
| 560 | afi_writel(port->pcie, value, ctrl); | ||
| 561 | |||
| 562 | tegra_pcie_port_reset(port); | ||
| 563 | } | ||
| 564 | |||
| 565 | static void tegra_pcie_port_disable(struct tegra_pcie_port *port) | ||
| 566 | { | ||
| 567 | unsigned long ctrl = tegra_pcie_port_get_pex_ctrl(port); | ||
| 568 | unsigned long value; | ||
| 569 | |||
| 570 | /* assert port reset */ | ||
| 571 | value = afi_readl(port->pcie, ctrl); | ||
| 572 | value &= ~AFI_PEX_CTRL_RST; | ||
| 573 | afi_writel(port->pcie, value, ctrl); | ||
| 574 | |||
| 575 | /* disable reference clock */ | ||
| 576 | value = afi_readl(port->pcie, ctrl); | ||
| 577 | value &= ~AFI_PEX_CTRL_REFCLK_EN; | ||
| 578 | afi_writel(port->pcie, value, ctrl); | ||
| 579 | } | ||
| 580 | |||
| 581 | static void tegra_pcie_port_free(struct tegra_pcie_port *port) | ||
| 582 | { | ||
| 583 | struct tegra_pcie *pcie = port->pcie; | ||
| 584 | |||
| 585 | devm_iounmap(pcie->dev, port->base); | ||
| 586 | devm_release_mem_region(pcie->dev, port->regs.start, | ||
| 587 | resource_size(&port->regs)); | ||
| 588 | list_del(&port->list); | ||
| 589 | devm_kfree(pcie->dev, port); | ||
| 590 | } | ||
| 591 | |||
| 592 | static void tegra_pcie_fixup_bridge(struct pci_dev *dev) | ||
| 593 | { | ||
| 594 | u16 reg; | ||
| 595 | |||
| 596 | if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) { | ||
| 597 | pci_read_config_word(dev, PCI_COMMAND, ®); | ||
| 598 | reg |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | | ||
| 599 | PCI_COMMAND_MASTER | PCI_COMMAND_SERR); | ||
| 600 | pci_write_config_word(dev, PCI_COMMAND, reg); | ||
| 601 | } | ||
| 602 | } | ||
| 603 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_fixup_bridge); | ||
| 604 | |||
| 605 | /* Tegra PCIE root complex wrongly reports device class */ | ||
| 606 | static void tegra_pcie_fixup_class(struct pci_dev *dev) | ||
| 607 | { | ||
| 608 | dev->class = PCI_CLASS_BRIDGE_PCI << 8; | ||
| 609 | } | ||
| 610 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf0, tegra_pcie_fixup_class); | ||
| 611 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf1, tegra_pcie_fixup_class); | ||
| 612 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0e1c, tegra_pcie_fixup_class); | ||
| 613 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0e1d, tegra_pcie_fixup_class); | ||
| 614 | |||
| 615 | /* Tegra PCIE requires relaxed ordering */ | ||
| 616 | static void tegra_pcie_relax_enable(struct pci_dev *dev) | ||
| 617 | { | ||
| 618 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN); | ||
| 619 | } | ||
| 620 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_relax_enable); | ||
| 621 | |||
| 622 | static int tegra_pcie_setup(int nr, struct pci_sys_data *sys) | ||
| 623 | { | ||
| 624 | struct tegra_pcie *pcie = sys_to_pcie(sys); | ||
| 625 | |||
| 626 | pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset); | ||
| 627 | pci_add_resource_offset(&sys->resources, &pcie->prefetch, | ||
| 628 | sys->mem_offset); | ||
| 629 | pci_add_resource(&sys->resources, &pcie->busn); | ||
| 630 | |||
| 631 | pci_ioremap_io(nr * SZ_64K, pcie->io.start); | ||
| 632 | |||
| 633 | return 1; | ||
| 634 | } | ||
| 635 | |||
| 636 | static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin) | ||
| 637 | { | ||
| 638 | struct tegra_pcie *pcie = sys_to_pcie(pdev->bus->sysdata); | ||
| 639 | |||
| 640 | tegra_cpuidle_pcie_irqs_in_use(); | ||
| 641 | |||
| 642 | return pcie->irq; | ||
| 643 | } | ||
| 644 | |||
| 645 | static void tegra_pcie_add_bus(struct pci_bus *bus) | ||
| 646 | { | ||
| 647 | if (IS_ENABLED(CONFIG_PCI_MSI)) { | ||
| 648 | struct tegra_pcie *pcie = sys_to_pcie(bus->sysdata); | ||
| 649 | |||
| 650 | bus->msi = &pcie->msi.chip; | ||
| 651 | } | ||
| 652 | } | ||
| 653 | |||
| 654 | static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys) | ||
| 655 | { | ||
| 656 | struct tegra_pcie *pcie = sys_to_pcie(sys); | ||
| 657 | struct pci_bus *bus; | ||
| 658 | |||
| 659 | bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys, | ||
| 660 | &sys->resources); | ||
| 661 | if (!bus) | ||
| 662 | return NULL; | ||
| 663 | |||
| 664 | pci_scan_child_bus(bus); | ||
| 665 | |||
| 666 | return bus; | ||
| 667 | } | ||
| 668 | |||
| 669 | static irqreturn_t tegra_pcie_isr(int irq, void *arg) | ||
| 670 | { | ||
| 671 | const char *err_msg[] = { | ||
| 672 | "Unknown", | ||
| 673 | "AXI slave error", | ||
| 674 | "AXI decode error", | ||
| 675 | "Target abort", | ||
| 676 | "Master abort", | ||
| 677 | "Invalid write", | ||
| 678 | "Response decoding error", | ||
| 679 | "AXI response decoding error", | ||
| 680 | "Transaction timeout", | ||
| 681 | }; | ||
| 682 | struct tegra_pcie *pcie = arg; | ||
| 683 | u32 code, signature; | ||
| 684 | |||
| 685 | code = afi_readl(pcie, AFI_INTR_CODE) & AFI_INTR_CODE_MASK; | ||
| 686 | signature = afi_readl(pcie, AFI_INTR_SIGNATURE); | ||
| 687 | afi_writel(pcie, 0, AFI_INTR_CODE); | ||
| 688 | |||
| 689 | if (code == AFI_INTR_LEGACY) | ||
| 690 | return IRQ_NONE; | ||
| 691 | |||
| 692 | if (code >= ARRAY_SIZE(err_msg)) | ||
| 693 | code = 0; | ||
| 694 | |||
| 695 | /* | ||
| 696 | * do not pollute kernel log with master abort reports since they | ||
| 697 | * happen a lot during enumeration | ||
| 698 | */ | ||
| 699 | if (code == AFI_INTR_MASTER_ABORT) | ||
| 700 | dev_dbg(pcie->dev, "%s, signature: %08x\n", err_msg[code], | ||
| 701 | signature); | ||
| 702 | else | ||
| 703 | dev_err(pcie->dev, "%s, signature: %08x\n", err_msg[code], | ||
| 704 | signature); | ||
| 705 | |||
| 706 | if (code == AFI_INTR_TARGET_ABORT || code == AFI_INTR_MASTER_ABORT || | ||
| 707 | code == AFI_INTR_FPCI_DECODE_ERROR) { | ||
| 708 | u32 fpci = afi_readl(pcie, AFI_UPPER_FPCI_ADDRESS) & 0xff; | ||
| 709 | u64 address = (u64)fpci << 32 | (signature & 0xfffffffc); | ||
| 710 | |||
| 711 | if (code == AFI_INTR_MASTER_ABORT) | ||
| 712 | dev_dbg(pcie->dev, " FPCI address: %10llx\n", address); | ||
| 713 | else | ||
| 714 | dev_err(pcie->dev, " FPCI address: %10llx\n", address); | ||
| 715 | } | ||
| 716 | |||
| 717 | return IRQ_HANDLED; | ||
| 718 | } | ||
| 719 | |||
| 720 | /* | ||
| 721 | * FPCI map is as follows: | ||
| 722 | * - 0xfdfc000000: I/O space | ||
| 723 | * - 0xfdfe000000: type 0 configuration space | ||
| 724 | * - 0xfdff000000: type 1 configuration space | ||
| 725 | * - 0xfe00000000: type 0 extended configuration space | ||
| 726 | * - 0xfe10000000: type 1 extended configuration space | ||
| 727 | */ | ||
| 728 | static void tegra_pcie_setup_translations(struct tegra_pcie *pcie) | ||
| 729 | { | ||
| 730 | u32 fpci_bar, size, axi_address; | ||
| 731 | |||
| 732 | /* Bar 0: type 1 extended configuration space */ | ||
| 733 | fpci_bar = 0xfe100000; | ||
| 734 | size = resource_size(pcie->cs); | ||
| 735 | axi_address = pcie->cs->start; | ||
| 736 | afi_writel(pcie, axi_address, AFI_AXI_BAR0_START); | ||
| 737 | afi_writel(pcie, size >> 12, AFI_AXI_BAR0_SZ); | ||
| 738 | afi_writel(pcie, fpci_bar, AFI_FPCI_BAR0); | ||
| 739 | |||
| 740 | /* Bar 1: downstream IO bar */ | ||
| 741 | fpci_bar = 0xfdfc0000; | ||
| 742 | size = resource_size(&pcie->io); | ||
| 743 | axi_address = pcie->io.start; | ||
| 744 | afi_writel(pcie, axi_address, AFI_AXI_BAR1_START); | ||
| 745 | afi_writel(pcie, size >> 12, AFI_AXI_BAR1_SZ); | ||
| 746 | afi_writel(pcie, fpci_bar, AFI_FPCI_BAR1); | ||
| 747 | |||
| 748 | /* Bar 2: prefetchable memory BAR */ | ||
| 749 | fpci_bar = (((pcie->prefetch.start >> 12) & 0x0fffffff) << 4) | 0x1; | ||
| 750 | size = resource_size(&pcie->prefetch); | ||
| 751 | axi_address = pcie->prefetch.start; | ||
| 752 | afi_writel(pcie, axi_address, AFI_AXI_BAR2_START); | ||
| 753 | afi_writel(pcie, size >> 12, AFI_AXI_BAR2_SZ); | ||
| 754 | afi_writel(pcie, fpci_bar, AFI_FPCI_BAR2); | ||
| 755 | |||
| 756 | /* Bar 3: non prefetchable memory BAR */ | ||
| 757 | fpci_bar = (((pcie->mem.start >> 12) & 0x0fffffff) << 4) | 0x1; | ||
| 758 | size = resource_size(&pcie->mem); | ||
| 759 | axi_address = pcie->mem.start; | ||
| 760 | afi_writel(pcie, axi_address, AFI_AXI_BAR3_START); | ||
| 761 | afi_writel(pcie, size >> 12, AFI_AXI_BAR3_SZ); | ||
| 762 | afi_writel(pcie, fpci_bar, AFI_FPCI_BAR3); | ||
| 763 | |||
| 764 | /* NULL out the remaining BARs as they are not used */ | ||
| 765 | afi_writel(pcie, 0, AFI_AXI_BAR4_START); | ||
| 766 | afi_writel(pcie, 0, AFI_AXI_BAR4_SZ); | ||
| 767 | afi_writel(pcie, 0, AFI_FPCI_BAR4); | ||
| 768 | |||
| 769 | afi_writel(pcie, 0, AFI_AXI_BAR5_START); | ||
| 770 | afi_writel(pcie, 0, AFI_AXI_BAR5_SZ); | ||
| 771 | afi_writel(pcie, 0, AFI_FPCI_BAR5); | ||
| 772 | |||
| 773 | /* map all upstream transactions as uncached */ | ||
| 774 | afi_writel(pcie, PHYS_OFFSET, AFI_CACHE_BAR0_ST); | ||
| 775 | afi_writel(pcie, 0, AFI_CACHE_BAR0_SZ); | ||
| 776 | afi_writel(pcie, 0, AFI_CACHE_BAR1_ST); | ||
| 777 | afi_writel(pcie, 0, AFI_CACHE_BAR1_SZ); | ||
| 778 | |||
| 779 | /* MSI translations are setup only when needed */ | ||
| 780 | afi_writel(pcie, 0, AFI_MSI_FPCI_BAR_ST); | ||
| 781 | afi_writel(pcie, 0, AFI_MSI_BAR_SZ); | ||
| 782 | afi_writel(pcie, 0, AFI_MSI_AXI_BAR_ST); | ||
| 783 | afi_writel(pcie, 0, AFI_MSI_BAR_SZ); | ||
| 784 | } | ||
| 785 | |||
| 786 | static int tegra_pcie_enable_controller(struct tegra_pcie *pcie) | ||
| 787 | { | ||
| 788 | const struct tegra_pcie_soc_data *soc = pcie->soc_data; | ||
| 789 | struct tegra_pcie_port *port; | ||
| 790 | unsigned int timeout; | ||
| 791 | unsigned long value; | ||
| 792 | |||
| 793 | /* power down PCIe slot clock bias pad */ | ||
| 794 | if (soc->has_pex_bias_ctrl) | ||
| 795 | afi_writel(pcie, 0, AFI_PEXBIAS_CTRL_0); | ||
| 796 | |||
| 797 | /* configure mode and disable all ports */ | ||
| 798 | value = afi_readl(pcie, AFI_PCIE_CONFIG); | ||
| 799 | value &= ~AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK; | ||
| 800 | value |= AFI_PCIE_CONFIG_PCIE_DISABLE_ALL | pcie->xbar_config; | ||
| 801 | |||
| 802 | list_for_each_entry(port, &pcie->ports, list) | ||
| 803 | value &= ~AFI_PCIE_CONFIG_PCIE_DISABLE(port->index); | ||
| 804 | |||
| 805 | afi_writel(pcie, value, AFI_PCIE_CONFIG); | ||
| 806 | |||
| 807 | value = afi_readl(pcie, AFI_FUSE); | ||
| 808 | value &= ~AFI_FUSE_PCIE_T0_GEN2_DIS; | ||
| 809 | afi_writel(pcie, value, AFI_FUSE); | ||
| 810 | |||
| 811 | /* initialze internal PHY, enable up to 16 PCIE lanes */ | ||
| 812 | pads_writel(pcie, 0x0, PADS_CTL_SEL); | ||
| 813 | |||
| 814 | /* override IDDQ to 1 on all 4 lanes */ | ||
| 815 | value = pads_readl(pcie, PADS_CTL); | ||
| 816 | value |= PADS_CTL_IDDQ_1L; | ||
| 817 | pads_writel(pcie, value, PADS_CTL); | ||
| 818 | |||
| 819 | /* | ||
| 820 | * Set up PHY PLL inputs select PLLE output as refclock, | ||
| 821 | * set TX ref sel to div10 (not div5). | ||
| 822 | */ | ||
| 823 | value = pads_readl(pcie, soc->pads_pll_ctl); | ||
| 824 | value &= ~(PADS_PLL_CTL_REFCLK_MASK | PADS_PLL_CTL_TXCLKREF_MASK); | ||
| 825 | value |= PADS_PLL_CTL_REFCLK_INTERNAL_CML | soc->tx_ref_sel; | ||
| 826 | pads_writel(pcie, value, soc->pads_pll_ctl); | ||
| 827 | |||
| 828 | /* take PLL out of reset */ | ||
| 829 | value = pads_readl(pcie, soc->pads_pll_ctl); | ||
| 830 | value |= PADS_PLL_CTL_RST_B4SM; | ||
| 831 | pads_writel(pcie, value, soc->pads_pll_ctl); | ||
| 832 | |||
| 833 | /* Configure the reference clock driver */ | ||
| 834 | value = PADS_REFCLK_CFG_VALUE | (PADS_REFCLK_CFG_VALUE << 16); | ||
| 835 | pads_writel(pcie, value, PADS_REFCLK_CFG0); | ||
| 836 | if (soc->num_ports > 2) | ||
| 837 | pads_writel(pcie, PADS_REFCLK_CFG_VALUE, PADS_REFCLK_CFG1); | ||
| 838 | |||
| 839 | /* wait for the PLL to lock */ | ||
| 840 | timeout = 300; | ||
| 841 | do { | ||
| 842 | value = pads_readl(pcie, soc->pads_pll_ctl); | ||
| 843 | usleep_range(1000, 2000); | ||
| 844 | if (--timeout == 0) { | ||
| 845 | pr_err("Tegra PCIe error: timeout waiting for PLL\n"); | ||
| 846 | return -EBUSY; | ||
| 847 | } | ||
| 848 | } while (!(value & PADS_PLL_CTL_LOCKDET)); | ||
| 849 | |||
| 850 | /* turn off IDDQ override */ | ||
| 851 | value = pads_readl(pcie, PADS_CTL); | ||
| 852 | value &= ~PADS_CTL_IDDQ_1L; | ||
| 853 | pads_writel(pcie, value, PADS_CTL); | ||
| 854 | |||
| 855 | /* enable TX/RX data */ | ||
| 856 | value = pads_readl(pcie, PADS_CTL); | ||
| 857 | value |= PADS_CTL_TX_DATA_EN_1L | PADS_CTL_RX_DATA_EN_1L; | ||
| 858 | pads_writel(pcie, value, PADS_CTL); | ||
| 859 | |||
| 860 | /* take the PCIe interface module out of reset */ | ||
| 861 | tegra_periph_reset_deassert(pcie->pcie_xclk); | ||
| 862 | |||
| 863 | /* finally enable PCIe */ | ||
| 864 | value = afi_readl(pcie, AFI_CONFIGURATION); | ||
| 865 | value |= AFI_CONFIGURATION_EN_FPCI; | ||
| 866 | afi_writel(pcie, value, AFI_CONFIGURATION); | ||
| 867 | |||
| 868 | value = AFI_INTR_EN_INI_SLVERR | AFI_INTR_EN_INI_DECERR | | ||
| 869 | AFI_INTR_EN_TGT_SLVERR | AFI_INTR_EN_TGT_DECERR | | ||
| 870 | AFI_INTR_EN_TGT_WRERR | AFI_INTR_EN_DFPCI_DECERR; | ||
| 871 | |||
| 872 | if (soc->has_intr_prsnt_sense) | ||
| 873 | value |= AFI_INTR_EN_PRSNT_SENSE; | ||
| 874 | |||
| 875 | afi_writel(pcie, value, AFI_AFI_INTR_ENABLE); | ||
| 876 | afi_writel(pcie, 0xffffffff, AFI_SM_INTR_ENABLE); | ||
| 877 | |||
| 878 | /* don't enable MSI for now, only when needed */ | ||
| 879 | afi_writel(pcie, AFI_INTR_MASK_INT_MASK, AFI_INTR_MASK); | ||
| 880 | |||
| 881 | /* disable all exceptions */ | ||
| 882 | afi_writel(pcie, 0, AFI_FPCI_ERROR_MASKS); | ||
| 883 | |||
| 884 | return 0; | ||
| 885 | } | ||
| 886 | |||
| 887 | static void tegra_pcie_power_off(struct tegra_pcie *pcie) | ||
| 888 | { | ||
| 889 | const struct tegra_pcie_soc_data *soc = pcie->soc_data; | ||
| 890 | int err; | ||
| 891 | |||
| 892 | /* TODO: disable and unprepare clocks? */ | ||
| 893 | |||
| 894 | tegra_periph_reset_assert(pcie->pcie_xclk); | ||
| 895 | tegra_periph_reset_assert(pcie->afi_clk); | ||
| 896 | tegra_periph_reset_assert(pcie->pex_clk); | ||
| 897 | |||
| 898 | tegra_powergate_power_off(TEGRA_POWERGATE_PCIE); | ||
| 899 | |||
| 900 | if (soc->has_avdd_supply) { | ||
| 901 | err = regulator_disable(pcie->avdd_supply); | ||
| 902 | if (err < 0) | ||
| 903 | dev_warn(pcie->dev, | ||
| 904 | "failed to disable AVDD regulator: %d\n", | ||
| 905 | err); | ||
| 906 | } | ||
| 907 | |||
| 908 | err = regulator_disable(pcie->pex_clk_supply); | ||
| 909 | if (err < 0) | ||
| 910 | dev_warn(pcie->dev, "failed to disable pex-clk regulator: %d\n", | ||
| 911 | err); | ||
| 912 | |||
| 913 | err = regulator_disable(pcie->vdd_supply); | ||
| 914 | if (err < 0) | ||
| 915 | dev_warn(pcie->dev, "failed to disable VDD regulator: %d\n", | ||
| 916 | err); | ||
| 917 | } | ||
| 918 | |||
| 919 | static int tegra_pcie_power_on(struct tegra_pcie *pcie) | ||
| 920 | { | ||
| 921 | const struct tegra_pcie_soc_data *soc = pcie->soc_data; | ||
| 922 | int err; | ||
| 923 | |||
| 924 | tegra_periph_reset_assert(pcie->pcie_xclk); | ||
| 925 | tegra_periph_reset_assert(pcie->afi_clk); | ||
| 926 | tegra_periph_reset_assert(pcie->pex_clk); | ||
| 927 | |||
| 928 | tegra_powergate_power_off(TEGRA_POWERGATE_PCIE); | ||
| 929 | |||
| 930 | /* enable regulators */ | ||
| 931 | err = regulator_enable(pcie->vdd_supply); | ||
| 932 | if (err < 0) { | ||
| 933 | dev_err(pcie->dev, "failed to enable VDD regulator: %d\n", err); | ||
| 934 | return err; | ||
| 935 | } | ||
| 936 | |||
| 937 | err = regulator_enable(pcie->pex_clk_supply); | ||
| 938 | if (err < 0) { | ||
| 939 | dev_err(pcie->dev, "failed to enable pex-clk regulator: %d\n", | ||
| 940 | err); | ||
| 941 | return err; | ||
| 942 | } | ||
| 943 | |||
| 944 | if (soc->has_avdd_supply) { | ||
| 945 | err = regulator_enable(pcie->avdd_supply); | ||
| 946 | if (err < 0) { | ||
| 947 | dev_err(pcie->dev, | ||
| 948 | "failed to enable AVDD regulator: %d\n", | ||
| 949 | err); | ||
| 950 | return err; | ||
| 951 | } | ||
| 952 | } | ||
| 953 | |||
| 954 | err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_PCIE, | ||
| 955 | pcie->pex_clk); | ||
| 956 | if (err) { | ||
| 957 | dev_err(pcie->dev, "powerup sequence failed: %d\n", err); | ||
| 958 | return err; | ||
| 959 | } | ||
| 960 | |||
| 961 | tegra_periph_reset_deassert(pcie->afi_clk); | ||
| 962 | |||
| 963 | err = clk_prepare_enable(pcie->afi_clk); | ||
| 964 | if (err < 0) { | ||
| 965 | dev_err(pcie->dev, "failed to enable AFI clock: %d\n", err); | ||
| 966 | return err; | ||
| 967 | } | ||
| 968 | |||
| 969 | if (soc->has_cml_clk) { | ||
| 970 | err = clk_prepare_enable(pcie->cml_clk); | ||
| 971 | if (err < 0) { | ||
| 972 | dev_err(pcie->dev, "failed to enable CML clock: %d\n", | ||
| 973 | err); | ||
| 974 | return err; | ||
| 975 | } | ||
| 976 | } | ||
| 977 | |||
| 978 | err = clk_prepare_enable(pcie->pll_e); | ||
| 979 | if (err < 0) { | ||
| 980 | dev_err(pcie->dev, "failed to enable PLLE clock: %d\n", err); | ||
| 981 | return err; | ||
| 982 | } | ||
| 983 | |||
| 984 | return 0; | ||
| 985 | } | ||
| 986 | |||
| 987 | static int tegra_pcie_clocks_get(struct tegra_pcie *pcie) | ||
| 988 | { | ||
| 989 | const struct tegra_pcie_soc_data *soc = pcie->soc_data; | ||
| 990 | |||
| 991 | pcie->pex_clk = devm_clk_get(pcie->dev, "pex"); | ||
| 992 | if (IS_ERR(pcie->pex_clk)) | ||
| 993 | return PTR_ERR(pcie->pex_clk); | ||
| 994 | |||
| 995 | pcie->afi_clk = devm_clk_get(pcie->dev, "afi"); | ||
| 996 | if (IS_ERR(pcie->afi_clk)) | ||
| 997 | return PTR_ERR(pcie->afi_clk); | ||
| 998 | |||
| 999 | pcie->pcie_xclk = devm_clk_get(pcie->dev, "pcie_xclk"); | ||
| 1000 | if (IS_ERR(pcie->pcie_xclk)) | ||
| 1001 | return PTR_ERR(pcie->pcie_xclk); | ||
| 1002 | |||
| 1003 | pcie->pll_e = devm_clk_get(pcie->dev, "pll_e"); | ||
| 1004 | if (IS_ERR(pcie->pll_e)) | ||
| 1005 | return PTR_ERR(pcie->pll_e); | ||
| 1006 | |||
| 1007 | if (soc->has_cml_clk) { | ||
| 1008 | pcie->cml_clk = devm_clk_get(pcie->dev, "cml"); | ||
| 1009 | if (IS_ERR(pcie->cml_clk)) | ||
| 1010 | return PTR_ERR(pcie->cml_clk); | ||
| 1011 | } | ||
| 1012 | |||
| 1013 | return 0; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | static int tegra_pcie_get_resources(struct tegra_pcie *pcie) | ||
| 1017 | { | ||
| 1018 | struct platform_device *pdev = to_platform_device(pcie->dev); | ||
| 1019 | struct resource *pads, *afi, *res; | ||
| 1020 | int err; | ||
| 1021 | |||
| 1022 | err = tegra_pcie_clocks_get(pcie); | ||
| 1023 | if (err) { | ||
| 1024 | dev_err(&pdev->dev, "failed to get clocks: %d\n", err); | ||
| 1025 | return err; | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | err = tegra_pcie_power_on(pcie); | ||
| 1029 | if (err) { | ||
| 1030 | dev_err(&pdev->dev, "failed to power up: %d\n", err); | ||
| 1031 | return err; | ||
| 1032 | } | ||
| 1033 | |||
| 1034 | /* request and remap controller registers */ | ||
| 1035 | pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads"); | ||
| 1036 | if (!pads) { | ||
| 1037 | err = -EADDRNOTAVAIL; | ||
| 1038 | goto poweroff; | ||
| 1039 | } | ||
| 1040 | |||
| 1041 | afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi"); | ||
| 1042 | if (!afi) { | ||
| 1043 | err = -EADDRNOTAVAIL; | ||
| 1044 | goto poweroff; | ||
| 1045 | } | ||
| 1046 | |||
| 1047 | pcie->pads = devm_request_and_ioremap(&pdev->dev, pads); | ||
| 1048 | if (!pcie->pads) { | ||
| 1049 | err = -EADDRNOTAVAIL; | ||
| 1050 | goto poweroff; | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | pcie->afi = devm_request_and_ioremap(&pdev->dev, afi); | ||
| 1054 | if (!pcie->afi) { | ||
| 1055 | err = -EADDRNOTAVAIL; | ||
| 1056 | goto poweroff; | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | /* request and remap configuration space */ | ||
| 1060 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs"); | ||
| 1061 | if (!res) { | ||
| 1062 | err = -EADDRNOTAVAIL; | ||
| 1063 | goto poweroff; | ||
| 1064 | } | ||
| 1065 | |||
| 1066 | pcie->cs = devm_request_mem_region(pcie->dev, res->start, | ||
| 1067 | resource_size(res), res->name); | ||
| 1068 | if (!pcie->cs) { | ||
| 1069 | err = -EADDRNOTAVAIL; | ||
| 1070 | goto poweroff; | ||
| 1071 | } | ||
| 1072 | |||
| 1073 | /* request interrupt */ | ||
| 1074 | err = platform_get_irq_byname(pdev, "intr"); | ||
| 1075 | if (err < 0) { | ||
| 1076 | dev_err(&pdev->dev, "failed to get IRQ: %d\n", err); | ||
| 1077 | goto poweroff; | ||
| 1078 | } | ||
| 1079 | |||
| 1080 | pcie->irq = err; | ||
| 1081 | |||
| 1082 | err = request_irq(pcie->irq, tegra_pcie_isr, IRQF_SHARED, "PCIE", pcie); | ||
| 1083 | if (err) { | ||
| 1084 | dev_err(&pdev->dev, "failed to register IRQ: %d\n", err); | ||
| 1085 | goto poweroff; | ||
| 1086 | } | ||
| 1087 | |||
| 1088 | return 0; | ||
| 1089 | |||
| 1090 | poweroff: | ||
| 1091 | tegra_pcie_power_off(pcie); | ||
| 1092 | return err; | ||
| 1093 | } | ||
| 1094 | |||
| 1095 | static int tegra_pcie_put_resources(struct tegra_pcie *pcie) | ||
| 1096 | { | ||
| 1097 | if (pcie->irq > 0) | ||
| 1098 | free_irq(pcie->irq, pcie); | ||
| 1099 | |||
| 1100 | tegra_pcie_power_off(pcie); | ||
| 1101 | return 0; | ||
| 1102 | } | ||
| 1103 | |||
| 1104 | static int tegra_msi_alloc(struct tegra_msi *chip) | ||
| 1105 | { | ||
| 1106 | int msi; | ||
| 1107 | |||
| 1108 | mutex_lock(&chip->lock); | ||
| 1109 | |||
| 1110 | msi = find_first_zero_bit(chip->used, INT_PCI_MSI_NR); | ||
| 1111 | if (msi < INT_PCI_MSI_NR) | ||
| 1112 | set_bit(msi, chip->used); | ||
| 1113 | else | ||
| 1114 | msi = -ENOSPC; | ||
| 1115 | |||
| 1116 | mutex_unlock(&chip->lock); | ||
| 1117 | |||
| 1118 | return msi; | ||
| 1119 | } | ||
| 1120 | |||
| 1121 | static void tegra_msi_free(struct tegra_msi *chip, unsigned long irq) | ||
| 1122 | { | ||
| 1123 | struct device *dev = chip->chip.dev; | ||
| 1124 | |||
| 1125 | mutex_lock(&chip->lock); | ||
| 1126 | |||
| 1127 | if (!test_bit(irq, chip->used)) | ||
| 1128 | dev_err(dev, "trying to free unused MSI#%lu\n", irq); | ||
| 1129 | else | ||
| 1130 | clear_bit(irq, chip->used); | ||
| 1131 | |||
| 1132 | mutex_unlock(&chip->lock); | ||
| 1133 | } | ||
| 1134 | |||
| 1135 | static irqreturn_t tegra_pcie_msi_irq(int irq, void *data) | ||
| 1136 | { | ||
| 1137 | struct tegra_pcie *pcie = data; | ||
| 1138 | struct tegra_msi *msi = &pcie->msi; | ||
| 1139 | unsigned int i, processed = 0; | ||
| 1140 | |||
| 1141 | for (i = 0; i < 8; i++) { | ||
| 1142 | unsigned long reg = afi_readl(pcie, AFI_MSI_VEC0 + i * 4); | ||
| 1143 | |||
| 1144 | while (reg) { | ||
| 1145 | unsigned int offset = find_first_bit(®, 32); | ||
| 1146 | unsigned int index = i * 32 + offset; | ||
| 1147 | unsigned int irq; | ||
| 1148 | |||
| 1149 | /* clear the interrupt */ | ||
| 1150 | afi_writel(pcie, 1 << offset, AFI_MSI_VEC0 + i * 4); | ||
| 1151 | |||
| 1152 | irq = irq_find_mapping(msi->domain, index); | ||
| 1153 | if (irq) { | ||
| 1154 | if (test_bit(index, msi->used)) | ||
| 1155 | generic_handle_irq(irq); | ||
| 1156 | else | ||
| 1157 | dev_info(pcie->dev, "unhandled MSI\n"); | ||
| 1158 | } else { | ||
| 1159 | /* | ||
| 1160 | * that's weird who triggered this? | ||
| 1161 | * just clear it | ||
| 1162 | */ | ||
| 1163 | dev_info(pcie->dev, "unexpected MSI\n"); | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | /* see if there's any more pending in this vector */ | ||
| 1167 | reg = afi_readl(pcie, AFI_MSI_VEC0 + i * 4); | ||
| 1168 | |||
| 1169 | processed++; | ||
| 1170 | } | ||
| 1171 | } | ||
| 1172 | |||
| 1173 | return processed > 0 ? IRQ_HANDLED : IRQ_NONE; | ||
| 1174 | } | ||
| 1175 | |||
| 1176 | static int tegra_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, | ||
| 1177 | struct msi_desc *desc) | ||
| 1178 | { | ||
| 1179 | struct tegra_msi *msi = to_tegra_msi(chip); | ||
| 1180 | struct msi_msg msg; | ||
| 1181 | unsigned int irq; | ||
| 1182 | int hwirq; | ||
| 1183 | |||
| 1184 | hwirq = tegra_msi_alloc(msi); | ||
| 1185 | if (hwirq < 0) | ||
| 1186 | return hwirq; | ||
| 1187 | |||
| 1188 | irq = irq_create_mapping(msi->domain, hwirq); | ||
| 1189 | if (!irq) | ||
| 1190 | return -EINVAL; | ||
| 1191 | |||
| 1192 | irq_set_msi_desc(irq, desc); | ||
| 1193 | |||
| 1194 | msg.address_lo = virt_to_phys((void *)msi->pages); | ||
| 1195 | /* 32 bit address only */ | ||
| 1196 | msg.address_hi = 0; | ||
| 1197 | msg.data = hwirq; | ||
| 1198 | |||
| 1199 | write_msi_msg(irq, &msg); | ||
| 1200 | |||
| 1201 | return 0; | ||
| 1202 | } | ||
| 1203 | |||
| 1204 | static void tegra_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) | ||
| 1205 | { | ||
| 1206 | struct tegra_msi *msi = to_tegra_msi(chip); | ||
| 1207 | struct irq_data *d = irq_get_irq_data(irq); | ||
| 1208 | |||
| 1209 | tegra_msi_free(msi, d->hwirq); | ||
| 1210 | } | ||
| 1211 | |||
| 1212 | static struct irq_chip tegra_msi_irq_chip = { | ||
| 1213 | .name = "Tegra PCIe MSI", | ||
| 1214 | .irq_enable = unmask_msi_irq, | ||
| 1215 | .irq_disable = mask_msi_irq, | ||
| 1216 | .irq_mask = mask_msi_irq, | ||
| 1217 | .irq_unmask = unmask_msi_irq, | ||
| 1218 | }; | ||
| 1219 | |||
| 1220 | static int tegra_msi_map(struct irq_domain *domain, unsigned int irq, | ||
| 1221 | irq_hw_number_t hwirq) | ||
| 1222 | { | ||
| 1223 | irq_set_chip_and_handler(irq, &tegra_msi_irq_chip, handle_simple_irq); | ||
| 1224 | irq_set_chip_data(irq, domain->host_data); | ||
| 1225 | set_irq_flags(irq, IRQF_VALID); | ||
| 1226 | |||
| 1227 | tegra_cpuidle_pcie_irqs_in_use(); | ||
| 1228 | |||
| 1229 | return 0; | ||
| 1230 | } | ||
| 1231 | |||
| 1232 | static const struct irq_domain_ops msi_domain_ops = { | ||
| 1233 | .map = tegra_msi_map, | ||
| 1234 | }; | ||
| 1235 | |||
| 1236 | static int tegra_pcie_enable_msi(struct tegra_pcie *pcie) | ||
| 1237 | { | ||
| 1238 | struct platform_device *pdev = to_platform_device(pcie->dev); | ||
| 1239 | const struct tegra_pcie_soc_data *soc = pcie->soc_data; | ||
| 1240 | struct tegra_msi *msi = &pcie->msi; | ||
| 1241 | unsigned long base; | ||
| 1242 | int err; | ||
| 1243 | u32 reg; | ||
| 1244 | |||
| 1245 | mutex_init(&msi->lock); | ||
| 1246 | |||
| 1247 | msi->chip.dev = pcie->dev; | ||
| 1248 | msi->chip.setup_irq = tegra_msi_setup_irq; | ||
| 1249 | msi->chip.teardown_irq = tegra_msi_teardown_irq; | ||
| 1250 | |||
| 1251 | msi->domain = irq_domain_add_linear(pcie->dev->of_node, INT_PCI_MSI_NR, | ||
| 1252 | &msi_domain_ops, &msi->chip); | ||
| 1253 | if (!msi->domain) { | ||
| 1254 | dev_err(&pdev->dev, "failed to create IRQ domain\n"); | ||
| 1255 | return -ENOMEM; | ||
| 1256 | } | ||
| 1257 | |||
| 1258 | err = platform_get_irq_byname(pdev, "msi"); | ||
| 1259 | if (err < 0) { | ||
| 1260 | dev_err(&pdev->dev, "failed to get IRQ: %d\n", err); | ||
| 1261 | goto err; | ||
| 1262 | } | ||
| 1263 | |||
| 1264 | msi->irq = err; | ||
| 1265 | |||
| 1266 | err = request_irq(msi->irq, tegra_pcie_msi_irq, 0, | ||
| 1267 | tegra_msi_irq_chip.name, pcie); | ||
| 1268 | if (err < 0) { | ||
| 1269 | dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); | ||
| 1270 | goto err; | ||
| 1271 | } | ||
| 1272 | |||
| 1273 | /* setup AFI/FPCI range */ | ||
| 1274 | msi->pages = __get_free_pages(GFP_KERNEL, 0); | ||
| 1275 | base = virt_to_phys((void *)msi->pages); | ||
| 1276 | |||
| 1277 | afi_writel(pcie, base >> soc->msi_base_shift, AFI_MSI_FPCI_BAR_ST); | ||
| 1278 | afi_writel(pcie, base, AFI_MSI_AXI_BAR_ST); | ||
| 1279 | /* this register is in 4K increments */ | ||
| 1280 | afi_writel(pcie, 1, AFI_MSI_BAR_SZ); | ||
| 1281 | |||
| 1282 | /* enable all MSI vectors */ | ||
| 1283 | afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC0); | ||
| 1284 | afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC1); | ||
| 1285 | afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC2); | ||
| 1286 | afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC3); | ||
| 1287 | afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC4); | ||
| 1288 | afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC5); | ||
| 1289 | afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC6); | ||
| 1290 | afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC7); | ||
| 1291 | |||
| 1292 | /* and unmask the MSI interrupt */ | ||
| 1293 | reg = afi_readl(pcie, AFI_INTR_MASK); | ||
| 1294 | reg |= AFI_INTR_MASK_MSI_MASK; | ||
| 1295 | afi_writel(pcie, reg, AFI_INTR_MASK); | ||
| 1296 | |||
| 1297 | return 0; | ||
| 1298 | |||
| 1299 | err: | ||
| 1300 | irq_domain_remove(msi->domain); | ||
| 1301 | return err; | ||
| 1302 | } | ||
| 1303 | |||
| 1304 | static int tegra_pcie_disable_msi(struct tegra_pcie *pcie) | ||
| 1305 | { | ||
| 1306 | struct tegra_msi *msi = &pcie->msi; | ||
| 1307 | unsigned int i, irq; | ||
| 1308 | u32 value; | ||
| 1309 | |||
| 1310 | /* mask the MSI interrupt */ | ||
| 1311 | value = afi_readl(pcie, AFI_INTR_MASK); | ||
| 1312 | value &= ~AFI_INTR_MASK_MSI_MASK; | ||
| 1313 | afi_writel(pcie, value, AFI_INTR_MASK); | ||
| 1314 | |||
| 1315 | /* disable all MSI vectors */ | ||
| 1316 | afi_writel(pcie, 0, AFI_MSI_EN_VEC0); | ||
| 1317 | afi_writel(pcie, 0, AFI_MSI_EN_VEC1); | ||
| 1318 | afi_writel(pcie, 0, AFI_MSI_EN_VEC2); | ||
| 1319 | afi_writel(pcie, 0, AFI_MSI_EN_VEC3); | ||
| 1320 | afi_writel(pcie, 0, AFI_MSI_EN_VEC4); | ||
| 1321 | afi_writel(pcie, 0, AFI_MSI_EN_VEC5); | ||
| 1322 | afi_writel(pcie, 0, AFI_MSI_EN_VEC6); | ||
| 1323 | afi_writel(pcie, 0, AFI_MSI_EN_VEC7); | ||
| 1324 | |||
| 1325 | free_pages(msi->pages, 0); | ||
| 1326 | |||
| 1327 | if (msi->irq > 0) | ||
| 1328 | free_irq(msi->irq, pcie); | ||
| 1329 | |||
| 1330 | for (i = 0; i < INT_PCI_MSI_NR; i++) { | ||
| 1331 | irq = irq_find_mapping(msi->domain, i); | ||
| 1332 | if (irq > 0) | ||
| 1333 | irq_dispose_mapping(irq); | ||
| 1334 | } | ||
| 1335 | |||
| 1336 | irq_domain_remove(msi->domain); | ||
| 1337 | |||
| 1338 | return 0; | ||
| 1339 | } | ||
| 1340 | |||
| 1341 | static int tegra_pcie_get_xbar_config(struct tegra_pcie *pcie, u32 lanes, | ||
| 1342 | u32 *xbar) | ||
| 1343 | { | ||
| 1344 | struct device_node *np = pcie->dev->of_node; | ||
| 1345 | |||
| 1346 | if (of_device_is_compatible(np, "nvidia,tegra30-pcie")) { | ||
| 1347 | switch (lanes) { | ||
| 1348 | case 0x00000204: | ||
| 1349 | dev_info(pcie->dev, "4x1, 2x1 configuration\n"); | ||
| 1350 | *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_420; | ||
| 1351 | return 0; | ||
| 1352 | |||
| 1353 | case 0x00020202: | ||
| 1354 | dev_info(pcie->dev, "2x3 configuration\n"); | ||
| 1355 | *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_222; | ||
| 1356 | return 0; | ||
| 1357 | |||
| 1358 | case 0x00010104: | ||
| 1359 | dev_info(pcie->dev, "4x1, 1x2 configuration\n"); | ||
| 1360 | *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_411; | ||
| 1361 | return 0; | ||
| 1362 | } | ||
| 1363 | } else if (of_device_is_compatible(np, "nvidia,tegra20-pcie")) { | ||
| 1364 | switch (lanes) { | ||
| 1365 | case 0x00000004: | ||
| 1366 | dev_info(pcie->dev, "single-mode configuration\n"); | ||
| 1367 | *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_SINGLE; | ||
| 1368 | return 0; | ||
| 1369 | |||
| 1370 | case 0x00000202: | ||
| 1371 | dev_info(pcie->dev, "dual-mode configuration\n"); | ||
| 1372 | *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_DUAL; | ||
| 1373 | return 0; | ||
| 1374 | } | ||
| 1375 | } | ||
| 1376 | |||
| 1377 | return -EINVAL; | ||
| 1378 | } | ||
| 1379 | |||
| 1380 | static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) | ||
| 1381 | { | ||
| 1382 | const struct tegra_pcie_soc_data *soc = pcie->soc_data; | ||
| 1383 | struct device_node *np = pcie->dev->of_node, *port; | ||
| 1384 | struct of_pci_range_parser parser; | ||
| 1385 | struct of_pci_range range; | ||
| 1386 | struct resource res; | ||
| 1387 | u32 lanes = 0; | ||
| 1388 | int err; | ||
| 1389 | |||
| 1390 | if (of_pci_range_parser_init(&parser, np)) { | ||
| 1391 | dev_err(pcie->dev, "missing \"ranges\" property\n"); | ||
| 1392 | return -EINVAL; | ||
| 1393 | } | ||
| 1394 | |||
| 1395 | pcie->vdd_supply = devm_regulator_get(pcie->dev, "vdd"); | ||
| 1396 | if (IS_ERR(pcie->vdd_supply)) | ||
| 1397 | return PTR_ERR(pcie->vdd_supply); | ||
| 1398 | |||
| 1399 | pcie->pex_clk_supply = devm_regulator_get(pcie->dev, "pex-clk"); | ||
| 1400 | if (IS_ERR(pcie->pex_clk_supply)) | ||
| 1401 | return PTR_ERR(pcie->pex_clk_supply); | ||
| 1402 | |||
| 1403 | if (soc->has_avdd_supply) { | ||
| 1404 | pcie->avdd_supply = devm_regulator_get(pcie->dev, "avdd"); | ||
| 1405 | if (IS_ERR(pcie->avdd_supply)) | ||
| 1406 | return PTR_ERR(pcie->avdd_supply); | ||
| 1407 | } | ||
| 1408 | |||
| 1409 | for_each_of_pci_range(&parser, &range) { | ||
| 1410 | of_pci_range_to_resource(&range, np, &res); | ||
| 1411 | |||
| 1412 | switch (res.flags & IORESOURCE_TYPE_BITS) { | ||
| 1413 | case IORESOURCE_IO: | ||
| 1414 | memcpy(&pcie->io, &res, sizeof(res)); | ||
| 1415 | pcie->io.name = "I/O"; | ||
| 1416 | break; | ||
| 1417 | |||
| 1418 | case IORESOURCE_MEM: | ||
| 1419 | if (res.flags & IORESOURCE_PREFETCH) { | ||
| 1420 | memcpy(&pcie->prefetch, &res, sizeof(res)); | ||
| 1421 | pcie->prefetch.name = "PREFETCH"; | ||
| 1422 | } else { | ||
| 1423 | memcpy(&pcie->mem, &res, sizeof(res)); | ||
| 1424 | pcie->mem.name = "MEM"; | ||
| 1425 | } | ||
| 1426 | break; | ||
| 1427 | } | ||
| 1428 | } | ||
| 1429 | |||
| 1430 | err = of_pci_parse_bus_range(np, &pcie->busn); | ||
| 1431 | if (err < 0) { | ||
| 1432 | dev_err(pcie->dev, "failed to parse ranges property: %d\n", | ||
| 1433 | err); | ||
| 1434 | pcie->busn.name = np->name; | ||
| 1435 | pcie->busn.start = 0; | ||
| 1436 | pcie->busn.end = 0xff; | ||
| 1437 | pcie->busn.flags = IORESOURCE_BUS; | ||
| 1438 | } | ||
| 1439 | |||
| 1440 | /* parse root ports */ | ||
| 1441 | for_each_child_of_node(np, port) { | ||
| 1442 | struct tegra_pcie_port *rp; | ||
| 1443 | unsigned int index; | ||
| 1444 | u32 value; | ||
| 1445 | |||
| 1446 | err = of_pci_get_devfn(port); | ||
| 1447 | if (err < 0) { | ||
| 1448 | dev_err(pcie->dev, "failed to parse address: %d\n", | ||
| 1449 | err); | ||
| 1450 | return err; | ||
| 1451 | } | ||
| 1452 | |||
| 1453 | index = PCI_SLOT(err); | ||
| 1454 | |||
| 1455 | if (index < 1 || index > soc->num_ports) { | ||
| 1456 | dev_err(pcie->dev, "invalid port number: %d\n", index); | ||
| 1457 | return -EINVAL; | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | index--; | ||
| 1461 | |||
| 1462 | err = of_property_read_u32(port, "nvidia,num-lanes", &value); | ||
| 1463 | if (err < 0) { | ||
| 1464 | dev_err(pcie->dev, "failed to parse # of lanes: %d\n", | ||
| 1465 | err); | ||
| 1466 | return err; | ||
| 1467 | } | ||
| 1468 | |||
| 1469 | if (value > 16) { | ||
| 1470 | dev_err(pcie->dev, "invalid # of lanes: %u\n", value); | ||
| 1471 | return -EINVAL; | ||
| 1472 | } | ||
| 1473 | |||
| 1474 | lanes |= value << (index << 3); | ||
| 1475 | |||
| 1476 | if (!of_device_is_available(port)) | ||
| 1477 | continue; | ||
| 1478 | |||
| 1479 | rp = devm_kzalloc(pcie->dev, sizeof(*rp), GFP_KERNEL); | ||
| 1480 | if (!rp) | ||
| 1481 | return -ENOMEM; | ||
| 1482 | |||
| 1483 | err = of_address_to_resource(port, 0, &rp->regs); | ||
| 1484 | if (err < 0) { | ||
| 1485 | dev_err(pcie->dev, "failed to parse address: %d\n", | ||
| 1486 | err); | ||
| 1487 | return err; | ||
| 1488 | } | ||
| 1489 | |||
| 1490 | INIT_LIST_HEAD(&rp->list); | ||
| 1491 | rp->index = index; | ||
| 1492 | rp->lanes = value; | ||
| 1493 | rp->pcie = pcie; | ||
| 1494 | |||
| 1495 | rp->base = devm_request_and_ioremap(pcie->dev, &rp->regs); | ||
| 1496 | if (!rp->base) | ||
| 1497 | return -EADDRNOTAVAIL; | ||
| 1498 | |||
| 1499 | list_add_tail(&rp->list, &pcie->ports); | ||
| 1500 | } | ||
| 1501 | |||
| 1502 | err = tegra_pcie_get_xbar_config(pcie, lanes, &pcie->xbar_config); | ||
| 1503 | if (err < 0) { | ||
| 1504 | dev_err(pcie->dev, "invalid lane configuration\n"); | ||
| 1505 | return err; | ||
| 1506 | } | ||
| 1507 | |||
| 1508 | return 0; | ||
| 1509 | } | ||
| 1510 | |||
| 1511 | /* | ||
| 1512 | * FIXME: If there are no PCIe cards attached, then calling this function | ||
| 1513 | * can result in the increase of the bootup time as there are big timeout | ||
| 1514 | * loops. | ||
| 1515 | */ | ||
| 1516 | #define TEGRA_PCIE_LINKUP_TIMEOUT 200 /* up to 1.2 seconds */ | ||
| 1517 | static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port) | ||
| 1518 | { | ||
| 1519 | unsigned int retries = 3; | ||
| 1520 | unsigned long value; | ||
| 1521 | |||
| 1522 | do { | ||
| 1523 | unsigned int timeout = TEGRA_PCIE_LINKUP_TIMEOUT; | ||
| 1524 | |||
| 1525 | do { | ||
| 1526 | value = readl(port->base + RP_VEND_XP); | ||
| 1527 | |||
| 1528 | if (value & RP_VEND_XP_DL_UP) | ||
| 1529 | break; | ||
| 1530 | |||
| 1531 | usleep_range(1000, 2000); | ||
| 1532 | } while (--timeout); | ||
| 1533 | |||
| 1534 | if (!timeout) { | ||
| 1535 | dev_err(port->pcie->dev, "link %u down, retrying\n", | ||
| 1536 | port->index); | ||
| 1537 | goto retry; | ||
| 1538 | } | ||
| 1539 | |||
| 1540 | timeout = TEGRA_PCIE_LINKUP_TIMEOUT; | ||
| 1541 | |||
| 1542 | do { | ||
| 1543 | value = readl(port->base + RP_LINK_CONTROL_STATUS); | ||
| 1544 | |||
| 1545 | if (value & RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE) | ||
| 1546 | return true; | ||
| 1547 | |||
| 1548 | usleep_range(1000, 2000); | ||
| 1549 | } while (--timeout); | ||
| 1550 | |||
| 1551 | retry: | ||
| 1552 | tegra_pcie_port_reset(port); | ||
| 1553 | } while (--retries); | ||
| 1554 | |||
| 1555 | return false; | ||
| 1556 | } | ||
| 1557 | |||
| 1558 | static int tegra_pcie_enable(struct tegra_pcie *pcie) | ||
| 1559 | { | ||
| 1560 | struct tegra_pcie_port *port, *tmp; | ||
| 1561 | struct hw_pci hw; | ||
| 1562 | |||
| 1563 | list_for_each_entry_safe(port, tmp, &pcie->ports, list) { | ||
| 1564 | dev_info(pcie->dev, "probing port %u, using %u lanes\n", | ||
| 1565 | port->index, port->lanes); | ||
| 1566 | |||
| 1567 | tegra_pcie_port_enable(port); | ||
| 1568 | |||
| 1569 | if (tegra_pcie_port_check_link(port)) | ||
| 1570 | continue; | ||
| 1571 | |||
| 1572 | dev_info(pcie->dev, "link %u down, ignoring\n", port->index); | ||
| 1573 | |||
| 1574 | tegra_pcie_port_disable(port); | ||
| 1575 | tegra_pcie_port_free(port); | ||
| 1576 | } | ||
| 1577 | |||
| 1578 | memset(&hw, 0, sizeof(hw)); | ||
| 1579 | |||
| 1580 | hw.nr_controllers = 1; | ||
| 1581 | hw.private_data = (void **)&pcie; | ||
| 1582 | hw.setup = tegra_pcie_setup; | ||
| 1583 | hw.map_irq = tegra_pcie_map_irq; | ||
| 1584 | hw.add_bus = tegra_pcie_add_bus; | ||
| 1585 | hw.scan = tegra_pcie_scan_bus; | ||
| 1586 | hw.ops = &tegra_pcie_ops; | ||
| 1587 | |||
| 1588 | pci_common_init_dev(pcie->dev, &hw); | ||
| 1589 | |||
| 1590 | return 0; | ||
| 1591 | } | ||
| 1592 | |||
| 1593 | static const struct tegra_pcie_soc_data tegra20_pcie_data = { | ||
| 1594 | .num_ports = 2, | ||
| 1595 | .msi_base_shift = 0, | ||
| 1596 | .pads_pll_ctl = PADS_PLL_CTL_TEGRA20, | ||
| 1597 | .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_DIV10, | ||
| 1598 | .has_pex_clkreq_en = false, | ||
| 1599 | .has_pex_bias_ctrl = false, | ||
| 1600 | .has_intr_prsnt_sense = false, | ||
| 1601 | .has_avdd_supply = false, | ||
| 1602 | .has_cml_clk = false, | ||
| 1603 | }; | ||
| 1604 | |||
| 1605 | static const struct tegra_pcie_soc_data tegra30_pcie_data = { | ||
| 1606 | .num_ports = 3, | ||
| 1607 | .msi_base_shift = 8, | ||
| 1608 | .pads_pll_ctl = PADS_PLL_CTL_TEGRA30, | ||
| 1609 | .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_BUF_EN, | ||
| 1610 | .has_pex_clkreq_en = true, | ||
| 1611 | .has_pex_bias_ctrl = true, | ||
| 1612 | .has_intr_prsnt_sense = true, | ||
| 1613 | .has_avdd_supply = true, | ||
| 1614 | .has_cml_clk = true, | ||
| 1615 | }; | ||
| 1616 | |||
| 1617 | static const struct of_device_id tegra_pcie_of_match[] = { | ||
| 1618 | { .compatible = "nvidia,tegra30-pcie", .data = &tegra30_pcie_data }, | ||
| 1619 | { .compatible = "nvidia,tegra20-pcie", .data = &tegra20_pcie_data }, | ||
| 1620 | { }, | ||
| 1621 | }; | ||
| 1622 | MODULE_DEVICE_TABLE(of, tegra_pcie_of_match); | ||
| 1623 | |||
| 1624 | static int tegra_pcie_probe(struct platform_device *pdev) | ||
| 1625 | { | ||
| 1626 | const struct of_device_id *match; | ||
| 1627 | struct tegra_pcie *pcie; | ||
| 1628 | int err; | ||
| 1629 | |||
| 1630 | match = of_match_device(tegra_pcie_of_match, &pdev->dev); | ||
| 1631 | if (!match) | ||
| 1632 | return -ENODEV; | ||
| 1633 | |||
| 1634 | pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL); | ||
| 1635 | if (!pcie) | ||
| 1636 | return -ENOMEM; | ||
| 1637 | |||
| 1638 | INIT_LIST_HEAD(&pcie->busses); | ||
| 1639 | INIT_LIST_HEAD(&pcie->ports); | ||
| 1640 | pcie->soc_data = match->data; | ||
| 1641 | pcie->dev = &pdev->dev; | ||
| 1642 | |||
| 1643 | err = tegra_pcie_parse_dt(pcie); | ||
| 1644 | if (err < 0) | ||
| 1645 | return err; | ||
| 1646 | |||
| 1647 | pcibios_min_mem = 0; | ||
| 1648 | |||
| 1649 | err = tegra_pcie_get_resources(pcie); | ||
| 1650 | if (err < 0) { | ||
| 1651 | dev_err(&pdev->dev, "failed to request resources: %d\n", err); | ||
| 1652 | return err; | ||
| 1653 | } | ||
| 1654 | |||
| 1655 | err = tegra_pcie_enable_controller(pcie); | ||
| 1656 | if (err) | ||
| 1657 | goto put_resources; | ||
| 1658 | |||
| 1659 | /* setup the AFI address translations */ | ||
| 1660 | tegra_pcie_setup_translations(pcie); | ||
| 1661 | |||
| 1662 | if (IS_ENABLED(CONFIG_PCI_MSI)) { | ||
| 1663 | err = tegra_pcie_enable_msi(pcie); | ||
| 1664 | if (err < 0) { | ||
| 1665 | dev_err(&pdev->dev, | ||
| 1666 | "failed to enable MSI support: %d\n", | ||
| 1667 | err); | ||
| 1668 | goto put_resources; | ||
| 1669 | } | ||
| 1670 | } | ||
| 1671 | |||
| 1672 | err = tegra_pcie_enable(pcie); | ||
| 1673 | if (err < 0) { | ||
| 1674 | dev_err(&pdev->dev, "failed to enable PCIe ports: %d\n", err); | ||
| 1675 | goto disable_msi; | ||
| 1676 | } | ||
| 1677 | |||
| 1678 | platform_set_drvdata(pdev, pcie); | ||
| 1679 | return 0; | ||
| 1680 | |||
| 1681 | disable_msi: | ||
| 1682 | if (IS_ENABLED(CONFIG_PCI_MSI)) | ||
| 1683 | tegra_pcie_disable_msi(pcie); | ||
| 1684 | put_resources: | ||
| 1685 | tegra_pcie_put_resources(pcie); | ||
| 1686 | return err; | ||
| 1687 | } | ||
| 1688 | |||
| 1689 | static struct platform_driver tegra_pcie_driver = { | ||
| 1690 | .driver = { | ||
| 1691 | .name = "tegra-pcie", | ||
| 1692 | .owner = THIS_MODULE, | ||
| 1693 | .of_match_table = tegra_pcie_of_match, | ||
| 1694 | .suppress_bind_attrs = true, | ||
| 1695 | }, | ||
| 1696 | .probe = tegra_pcie_probe, | ||
| 1697 | }; | ||
| 1698 | module_platform_driver(tegra_pcie_driver); | ||
| 1699 | |||
| 1700 | MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>"); | ||
| 1701 | MODULE_DESCRIPTION("NVIDIA Tegra PCIe driver"); | ||
| 1702 | MODULE_LICENSE("GPLv2"); | ||
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index aca7578b05e5..b35f93c232cf 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
| @@ -30,20 +30,60 @@ static int pci_msi_enable = 1; | |||
| 30 | 30 | ||
| 31 | /* Arch hooks */ | 31 | /* Arch hooks */ |
| 32 | 32 | ||
| 33 | #ifndef arch_msi_check_device | 33 | #if defined(CONFIG_GENERIC_HARDIRQS) |
| 34 | int arch_msi_check_device(struct pci_dev *dev, int nvec, int type) | 34 | int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) |
| 35 | { | 35 | { |
| 36 | struct msi_chip *chip = dev->bus->msi; | ||
| 37 | int err; | ||
| 38 | |||
| 39 | if (!chip || !chip->setup_irq) | ||
| 40 | return -EINVAL; | ||
| 41 | |||
| 42 | err = chip->setup_irq(chip, dev, desc); | ||
| 43 | if (err < 0) | ||
| 44 | return err; | ||
| 45 | |||
| 46 | irq_set_chip_data(desc->irq, chip); | ||
| 47 | |||
| 36 | return 0; | 48 | return 0; |
| 37 | } | 49 | } |
| 38 | #endif | ||
| 39 | 50 | ||
| 40 | #ifndef arch_setup_msi_irqs | 51 | void __weak arch_teardown_msi_irq(unsigned int irq) |
| 41 | # define arch_setup_msi_irqs default_setup_msi_irqs | 52 | { |
| 42 | # define HAVE_DEFAULT_MSI_SETUP_IRQS | 53 | struct msi_chip *chip = irq_get_chip_data(irq); |
| 43 | #endif | ||
| 44 | 54 | ||
| 45 | #ifdef HAVE_DEFAULT_MSI_SETUP_IRQS | 55 | if (!chip || !chip->teardown_irq) |
| 46 | int default_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | 56 | return; |
| 57 | |||
| 58 | chip->teardown_irq(chip, irq); | ||
| 59 | } | ||
| 60 | |||
| 61 | int __weak arch_msi_check_device(struct pci_dev *dev, int nvec, int type) | ||
| 62 | { | ||
| 63 | struct msi_chip *chip = dev->bus->msi; | ||
| 64 | |||
| 65 | if (!chip || !chip->check_device) | ||
| 66 | return 0; | ||
| 67 | |||
| 68 | return chip->check_device(chip, dev, nvec, type); | ||
| 69 | } | ||
| 70 | #else | ||
| 71 | int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) | ||
| 72 | { | ||
| 73 | return -ENOSYS; | ||
| 74 | } | ||
| 75 | |||
| 76 | void __weak arch_teardown_msi_irq(unsigned int irq) | ||
| 77 | { | ||
| 78 | } | ||
| 79 | |||
| 80 | int __weak arch_msi_check_device(struct pci_dev *dev, int nvec, int type) | ||
| 81 | { | ||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | #endif /* CONFIG_GENERIC_HARDIRQS */ | ||
| 85 | |||
| 86 | int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | ||
| 47 | { | 87 | { |
| 48 | struct msi_desc *entry; | 88 | struct msi_desc *entry; |
| 49 | int ret; | 89 | int ret; |
| @@ -65,14 +105,11 @@ int default_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | |||
| 65 | 105 | ||
| 66 | return 0; | 106 | return 0; |
| 67 | } | 107 | } |
| 68 | #endif | ||
| 69 | |||
| 70 | #ifndef arch_teardown_msi_irqs | ||
| 71 | # define arch_teardown_msi_irqs default_teardown_msi_irqs | ||
| 72 | # define HAVE_DEFAULT_MSI_TEARDOWN_IRQS | ||
| 73 | #endif | ||
| 74 | 108 | ||
| 75 | #ifdef HAVE_DEFAULT_MSI_TEARDOWN_IRQS | 109 | /* |
| 110 | * We have a default implementation available as a separate non-weak | ||
| 111 | * function, as it is used by the Xen x86 PCI code | ||
| 112 | */ | ||
| 76 | void default_teardown_msi_irqs(struct pci_dev *dev) | 113 | void default_teardown_msi_irqs(struct pci_dev *dev) |
| 77 | { | 114 | { |
| 78 | struct msi_desc *entry; | 115 | struct msi_desc *entry; |
| @@ -89,14 +126,12 @@ void default_teardown_msi_irqs(struct pci_dev *dev) | |||
| 89 | arch_teardown_msi_irq(entry->irq + i); | 126 | arch_teardown_msi_irq(entry->irq + i); |
| 90 | } | 127 | } |
| 91 | } | 128 | } |
| 92 | #endif | ||
| 93 | 129 | ||
| 94 | #ifndef arch_restore_msi_irqs | 130 | void __weak arch_teardown_msi_irqs(struct pci_dev *dev) |
| 95 | # define arch_restore_msi_irqs default_restore_msi_irqs | 131 | { |
| 96 | # define HAVE_DEFAULT_MSI_RESTORE_IRQS | 132 | return default_teardown_msi_irqs(dev); |
| 97 | #endif | 133 | } |
| 98 | 134 | ||
| 99 | #ifdef HAVE_DEFAULT_MSI_RESTORE_IRQS | ||
| 100 | void default_restore_msi_irqs(struct pci_dev *dev, int irq) | 135 | void default_restore_msi_irqs(struct pci_dev *dev, int irq) |
| 101 | { | 136 | { |
| 102 | struct msi_desc *entry; | 137 | struct msi_desc *entry; |
| @@ -114,7 +149,11 @@ void default_restore_msi_irqs(struct pci_dev *dev, int irq) | |||
| 114 | if (entry) | 149 | if (entry) |
| 115 | write_msi_msg(irq, &entry->msg); | 150 | write_msi_msg(irq, &entry->msg); |
| 116 | } | 151 | } |
| 117 | #endif | 152 | |
| 153 | void __weak arch_restore_msi_irqs(struct pci_dev *dev, int irq) | ||
| 154 | { | ||
| 155 | return default_restore_msi_irqs(dev, irq); | ||
| 156 | } | ||
| 118 | 157 | ||
| 119 | static void msi_set_enable(struct pci_dev *dev, int enable) | 158 | static void msi_set_enable(struct pci_dev *dev, int enable) |
| 120 | { | 159 | { |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 46ada5c098eb..b8eaa8167849 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
| @@ -666,6 +666,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
| 666 | 666 | ||
| 667 | child->parent = parent; | 667 | child->parent = parent; |
| 668 | child->ops = parent->ops; | 668 | child->ops = parent->ops; |
| 669 | child->msi = parent->msi; | ||
| 669 | child->sysdata = parent->sysdata; | 670 | child->sysdata = parent->sysdata; |
| 670 | child->bus_flags = parent->bus_flags; | 671 | child->bus_flags = parent->bus_flags; |
| 671 | 672 | ||
diff --git a/include/linux/msi.h b/include/linux/msi.h index ee66f3a12fb6..b17ead818aec 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h | |||
| @@ -51,12 +51,31 @@ struct msi_desc { | |||
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | /* | 53 | /* |
| 54 | * The arch hook for setup up msi irqs | 54 | * The arch hooks to setup up msi irqs. Those functions are |
| 55 | * implemented as weak symbols so that they /can/ be overriden by | ||
| 56 | * architecture specific code if needed. | ||
| 55 | */ | 57 | */ |
| 56 | int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc); | 58 | int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc); |
| 57 | void arch_teardown_msi_irq(unsigned int irq); | 59 | void arch_teardown_msi_irq(unsigned int irq); |
| 58 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); | 60 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); |
| 59 | void arch_teardown_msi_irqs(struct pci_dev *dev); | 61 | void arch_teardown_msi_irqs(struct pci_dev *dev); |
| 60 | int arch_msi_check_device(struct pci_dev* dev, int nvec, int type); | 62 | int arch_msi_check_device(struct pci_dev* dev, int nvec, int type); |
| 63 | void arch_restore_msi_irqs(struct pci_dev *dev, int irq); | ||
| 64 | |||
| 65 | void default_teardown_msi_irqs(struct pci_dev *dev); | ||
| 66 | void default_restore_msi_irqs(struct pci_dev *dev, int irq); | ||
| 67 | |||
| 68 | struct msi_chip { | ||
| 69 | struct module *owner; | ||
| 70 | struct device *dev; | ||
| 71 | struct device_node *of_node; | ||
| 72 | struct list_head list; | ||
| 73 | |||
| 74 | int (*setup_irq)(struct msi_chip *chip, struct pci_dev *dev, | ||
| 75 | struct msi_desc *desc); | ||
| 76 | void (*teardown_irq)(struct msi_chip *chip, unsigned int irq); | ||
| 77 | int (*check_device)(struct msi_chip *chip, struct pci_dev *dev, | ||
| 78 | int nvec, int type); | ||
| 79 | }; | ||
| 61 | 80 | ||
| 62 | #endif /* LINUX_MSI_H */ | 81 | #endif /* LINUX_MSI_H */ |
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 7a04826018c0..fd9c408631a0 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #define __OF_PCI_H | 2 | #define __OF_PCI_H |
| 3 | 3 | ||
| 4 | #include <linux/pci.h> | 4 | #include <linux/pci.h> |
| 5 | #include <linux/msi.h> | ||
| 5 | 6 | ||
| 6 | struct pci_dev; | 7 | struct pci_dev; |
| 7 | struct of_irq; | 8 | struct of_irq; |
| @@ -13,4 +14,15 @@ struct device_node *of_pci_find_child_device(struct device_node *parent, | |||
| 13 | int of_pci_get_devfn(struct device_node *np); | 14 | int of_pci_get_devfn(struct device_node *np); |
| 14 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res); | 15 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res); |
| 15 | 16 | ||
| 17 | #if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI) | ||
| 18 | int of_pci_msi_chip_add(struct msi_chip *chip); | ||
| 19 | void of_pci_msi_chip_remove(struct msi_chip *chip); | ||
| 20 | struct msi_chip *of_pci_find_msi_chip_by_node(struct device_node *of_node); | ||
| 21 | #else | ||
| 22 | static inline int of_pci_msi_chip_add(struct msi_chip *chip) { return -EINVAL; } | ||
| 23 | static inline void of_pci_msi_chip_remove(struct msi_chip *chip) { } | ||
| 24 | static inline struct msi_chip * | ||
| 25 | of_pci_find_msi_chip_by_node(struct device_node *of_node) { return NULL; } | ||
| 26 | #endif | ||
| 27 | |||
| 16 | #endif | 28 | #endif |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 0fd1f1582fa1..4044e3c00609 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -433,6 +433,7 @@ struct pci_bus { | |||
| 433 | struct resource busn_res; /* bus numbers routed to this bus */ | 433 | struct resource busn_res; /* bus numbers routed to this bus */ |
| 434 | 434 | ||
| 435 | struct pci_ops *ops; /* configuration access functions */ | 435 | struct pci_ops *ops; /* configuration access functions */ |
| 436 | struct msi_chip *msi; /* MSI controller */ | ||
| 436 | void *sysdata; /* hook for sys-specific extension */ | 437 | void *sysdata; /* hook for sys-specific extension */ |
| 437 | struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ | 438 | struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ |
| 438 | 439 | ||
diff --git a/include/linux/tegra-cpuidle.h b/include/linux/tegra-cpuidle.h new file mode 100644 index 000000000000..dda3647242a4 --- /dev/null +++ b/include/linux/tegra-cpuidle.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #ifndef __LINUX_TEGRA_CPUIDLE_H__ | ||
| 15 | #define __LINUX_TEGRA_CPUIDLE_H__ | ||
| 16 | |||
| 17 | void tegra_cpuidle_pcie_irqs_in_use(void); | ||
| 18 | |||
| 19 | #endif | ||
