platform/kernel/linux-rpi.git
4 years agoPCI: brcmstb: Add MSI support
Jim Quinlan [Mon, 16 Dec 2019 11:01:10 +0000 (12:01 +0100)]
PCI: brcmstb: Add MSI support

commit 40ca1bf580ef24df30702032ba5e40dfdcaa200b upstream.

This adds MSI support to the Broadcom STB PCIe host controller. The MSI
controller is physically located within the PCIe block, however, there
is no reason why the MSI controller could not be moved elsewhere in the
future. MSIX is not supported by the HW.

Since the internal Brcmstb MSI controller is intertwined with the PCIe
controller, it is not its own platform device but rather part of the
PCIe platform device.

Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
Co-developed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
4 years agoPCI: brcmstb: Add Broadcom STB PCIe host controller driver
Jim Quinlan [Mon, 16 Dec 2019 11:01:09 +0000 (12:01 +0100)]
PCI: brcmstb: Add Broadcom STB PCIe host controller driver

commit c0452137034bda8f686dd9a2e167949bfffd6776 upstream.

This adds a basic driver for Broadcom's STB PCIe controller, for now
aimed at Raspberry Pi 4's SoC, bcm2711.

Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
Co-developed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
[lorenzo.pieralisi@arm.com: updated brcm_pcie_get_rc_bar2_size_and_offset()according to https://lore.kernel.org/linux-pci/be8ddb33a7360af1815cf686f77f3f0913d02be3.camel@suse.de]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
4 years agoARM: dts: bcm2711: Enable PCIe controller
Nicolas Saenz Julienne [Mon, 16 Dec 2019 11:01:08 +0000 (12:01 +0100)]
ARM: dts: bcm2711: Enable PCIe controller

commit d5c8dc0d4c880fbde5293cc186b1ab23466254c4 upstream.

This enables bcm2711's PCIe bus, which is hardwired to a VIA
Technologies XHCI USB 3.0 controller.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
4 years agodma-mapping: treat dev->bus_dma_mask as a DMA limit
Nicolas Saenz Julienne [Thu, 21 Nov 2019 09:26:44 +0000 (10:26 +0100)]
dma-mapping: treat dev->bus_dma_mask as a DMA limit

commit a7ba70f1787f977f970cd116076c6fce4b9e01cc upstream.

Using a mask to represent bus DMA constraints has a set of limitations.
The biggest one being it can only hold a power of two (minus one). The
DMA mapping code is already aware of this and treats dev->bus_dma_mask
as a limit. This quirk is already used by some architectures although
still rare.

With the introduction of the Raspberry Pi 4 we've found a new contender
for the use of bus DMA limits, as its PCIe bus can only address the
lower 3GB of memory (of a total of 4GB). This is impossible to represent
with a mask. To make things worse the device-tree code rounds non power
of two bus DMA limits to the next power of two, which is unacceptable in
this case.

In the light of this, rename dev->bus_dma_mask to dev->bus_dma_limit all
over the tree and treat it as such. Note that dev->bus_dma_limit should
contain the higher accessible DMA address.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
4 years agodma-direct: exclude dma_direct_map_resource from the min_low_pfn check
Christoph Hellwig [Tue, 19 Nov 2019 16:38:58 +0000 (17:38 +0100)]
dma-direct: exclude dma_direct_map_resource from the min_low_pfn check

commit 68a33b1794665ba8a1d1ef1d3bfcc7c587d380a6 upstream.

The valid memory address check in dma_capable only makes sense when mapping
normal memory, not when using dma_map_resource to map a device resource.
Add a new boolean argument to dma_capable to exclude that check for the
dma_map_resource case.

Fixes: b12d66278dd6 ("dma-direct: check for overflows on 32 bit DMA addresses")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 years agodma-direct: avoid a forward declaration for phys_to_dma
Christoph Hellwig [Tue, 12 Nov 2019 16:07:43 +0000 (17:07 +0100)]
dma-direct: avoid a forward declaration for phys_to_dma

Move dma_capable down a bit so that we don't need a forward declaration
for phys_to_dma.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
(cherry picked from commit c7345159f7db6fb69ec1c3b3f8f28cd05c731be2)

4 years agodma-direct: unify the dma_capable definitions
Christoph Hellwig [Tue, 12 Nov 2019 16:06:04 +0000 (17:06 +0100)]
dma-direct: unify the dma_capable definitions

commit 130c1ccbf55330b55e82612a6e54eebb82c9d746 upstream.

Currently each architectures that wants to override dma_to_phys and
phys_to_dma also has to provide dma_capable.  But there isn't really
any good reason for that.  powerpc and mips just have copies of the
generic one minus the latests fix, and the arm one was the inspiration
for said fix, but misses the bus_dma_mask handling.
Make all architectures use the generic version instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
4 years agoPCI: of: Add inbound resource parsing to helpers
Rob Herring [Wed, 30 Oct 2019 22:30:57 +0000 (17:30 -0500)]
PCI: of: Add inbound resource parsing to helpers

Extend devm_of_pci_get_host_bridge_resources() and
pci_parse_request_of_pci_ranges() helpers to also parse the inbound
addresses from DT 'dma-ranges' and populate a resource list with the
translated addresses. This will help ensure 'dma-ranges' is always
parsed in a consistent way.

Tested-by: Srinath Mannam <srinath.mannam@broadcom.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> # for AArdvark
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Srinath Mannam <srinath.mannam@broadcom.com>
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Will Deacon <will@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Toan Le <toan@os.amperecomputing.com>
Cc: Ley Foon Tan <lftan@altera.com>
Cc: Tom Joseph <tjoseph@cadence.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: Ryder Lee <ryder.lee@mediatek.com>
Cc: Karthikeyan Mitran <m.karthikeyan@mobiveil.co.in>
Cc: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Shawn Lin <shawn.lin@rock-chips.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: rfi@lists.rocketboards.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
(cherry picked from commit 331f63457165a30c708280de2c77f1742c6351dc)

4 years agox86/PCI: sta2x11: use default DMA address translation
Nicolas Saenz Julienne [Thu, 7 Nov 2019 15:06:45 +0000 (16:06 +0100)]
x86/PCI: sta2x11: use default DMA address translation

commit e380a0394c36a3a878c858418d5dd7f5f195b6fc upstream.

The devices found behind this PCIe chip have unusual DMA mapping
constraints as there is an AMBA interconnect placed in between them and
the different PCI endpoints. The offset between physical memory
addresses and AMBA's view is provided by reading a PCI config register,
which is saved and used whenever DMA mapping is needed.

It turns out that this DMA setup can be represented by properly setting
'dma_pfn_offset', 'dma_bus_mask' and 'dma_mask' during the PCI device
enable fixup. And ultimately allows us to get rid of this device's
custom DMA functions.

Aside from the code deletion and DMA setup, sta2x11_pdev_to_mapping() is
moved to avoid warnings whenever CONFIG_PM is not enabled.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
4 years agodma-direct: check for overflows on 32 bit DMA addresses
Nicolas Saenz Julienne [Thu, 7 Nov 2019 15:06:44 +0000 (16:06 +0100)]
dma-direct: check for overflows on 32 bit DMA addresses

As seen on the new Raspberry Pi 4 and sta2x11's DMA implementation it is
possible for a device configured with 32 bit DMA addresses and a partial
DMA mapping located at the end of the address space to overflow. It
happens when a higher physical address, not DMAable, is translated to
it's DMA counterpart.

For example the Raspberry Pi 4, configurable up to 4 GB of memory, has
an interconnect capable of addressing the lower 1 GB of physical memory
with a DMA offset of 0xc0000000. It transpires that, any attempt to
translate physical addresses higher than the first GB will result in an
overflow which dma_capable() can't detect as it only checks for
addresses bigger then the maximum allowed DMA address.

Fix this by verifying in dma_capable() if the DMA address range provided
is at any point lower than the minimum possible DMA address on the bus.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
(cherry picked from commit b12d66278dd627cbe1ea7c000aa4715aaf8830c8)

4 years agodma/direct: turn ARCH_ZONE_DMA_BITS into a variable
Nicolas Saenz Julienne [Mon, 14 Oct 2019 18:31:03 +0000 (20:31 +0200)]
dma/direct: turn ARCH_ZONE_DMA_BITS into a variable

commit 8b5369ea580964dbc982781bfb9fb93459fc5e8d upstream.

Some architectures, notably ARM, are interested in tweaking this
depending on their runtime DMA addressing limitations.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoresource: Add a resource_list_first_type helper
Rob Herring [Mon, 28 Oct 2019 16:32:32 +0000 (11:32 -0500)]
resource: Add a resource_list_first_type helper

commit 494f8b10d832456a96be4ee7317425f6936cabc8 upstream.

A common pattern is looping over a resource_list just to get a matching
entry with a specific type. Add resource_list_first_type() helper which
implements this.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
4 years agomm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type'
Nicolas Saenz Julienne [Wed, 11 Sep 2019 18:25:46 +0000 (20:25 +0200)]
mm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type'

commit 734f9246e791d8da278957b2c326d7709b2a97c0 upstream.

These zones usage has evolved with time and the comments were outdated.
This joins both ZONE_DMA and ZONE_DMA32 explanation and gives up to date
examples on how they are used on different architectures.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoarm64: use both ZONE_DMA and ZONE_DMA32
Nicolas Saenz Julienne [Wed, 11 Sep 2019 18:25:45 +0000 (20:25 +0200)]
arm64: use both ZONE_DMA and ZONE_DMA32

commit 1a8e1cef7603e218339ac63cb3178b25554524e5 upstream.

So far all arm64 devices have supported 32 bit DMA masks for their
peripherals. This is not true anymore for the Raspberry Pi 4 as most of
it's peripherals can only address the first GB of memory on a total of
up to 4 GB.

This goes against ZONE_DMA32's intent, as it's expected for ZONE_DMA32
to be addressable with a 32 bit mask. So it was decided to re-introduce
ZONE_DMA in arm64.

ZONE_DMA will contain the lower 1G of memory, which is currently the
memory area addressable by any peripheral on an arm64 device.
ZONE_DMA32 will contain the rest of the 32 bit addressable memory.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoarm64: rename variables used to calculate ZONE_DMA32's size
Nicolas Saenz Julienne [Wed, 11 Sep 2019 18:25:44 +0000 (20:25 +0200)]
arm64: rename variables used to calculate ZONE_DMA32's size

commit a573cdd7973dedd87e62196c400332896bb236c8 upstream.

Let the name indicate that they are used to calculate ZONE_DMA32's size
as opposed to ZONE_DMA.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoarm64: mm: use arm64_dma_phys_limit instead of calling max_zone_dma_phys()
Nicolas Saenz Julienne [Wed, 11 Sep 2019 18:25:43 +0000 (20:25 +0200)]
arm64: mm: use arm64_dma_phys_limit instead of calling max_zone_dma_phys()

commit ae970dc096b2d39f65f2e18d142e3978dc9ee1c7 upstream.

By the time we call zones_sizes_init() arm64_dma_phys_limit already
contains the result of max_zone_dma_phys(). We use the variable instead
of calling the function directly to save some precious cpu time.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoof: Make of_dma_get_range() work on bus nodes
Robin Murphy [Wed, 3 Jul 2019 17:42:20 +0000 (18:42 +0100)]
of: Make of_dma_get_range() work on bus nodes

commit 951d48855d86e72e0d6de73440fe09d363168064 upstream.

Since the "dma-ranges" property is only valid for a node representing a
bus, of_dma_get_range() currently assumes the node passed in is a leaf
representing a device, and starts the walk from its parent. In cases
like PCI host controllers on typical FDT systems, however, where the PCI
endpoints are probed dynamically the initial leaf node represents the
'bus' itself, and this logic means we fail to consider any "dma-ranges"
describing the host bridge itself. Rework the logic such that
of_dma_get_range() also works correctly starting from a bus node
containing "dma-ranges".

While this does mean "dma-ranges" could incorrectly be in a device leaf
node, there isn't really any way in this function to ensure that a leaf
node is or isn't a bus node.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
[robh: Allow for the bus child node to still be passed in]
Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
4 years agoof/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'
Rob Herring [Wed, 4 Sep 2019 10:43:30 +0000 (11:43 +0100)]
of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

commit 81db12ee15cb83926e290a8a3654a2dfebc80935 upstream.

'dma-ranges' frequently exists without parent nodes having 'dma-ranges'.
While this is an error for 'ranges', this is fine because DMA capable
devices always have a translatable DMA address. Also, with no
'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with
no restrictions unless perhaps the device itself has implicit
restrictions.

Cc: Robin Murphy <robin.murphy@arm.com>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Rob Herring <robh@kernel.org>
4 years agoof: Factor out #{addr,size}-cells parsing
Robin Murphy [Tue, 2 Jul 2019 17:42:39 +0000 (18:42 +0100)]
of: Factor out #{addr,size}-cells parsing

In some cases such as PCI host controllers, we may have a "parent bus"
which is an OF leaf node, but still need to correctly parse ranges from
the point of view of that bus. For that, factor out variants of the
"#addr-cells" and "#size-cells" parsers which do not assume they have a
device node and thus immediately traverse upwards before reading the
relevant property.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
[robh: don't make of_bus_n_{addr,size}_cells() public]
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Rob Herring <robh@kernel.org>
(cherry picked from commit b68ac8dc22ebbf003e26e44bf4dd3030c076df5a)

4 years agoof: address: Follow DMA parent for "dma-coherent"
Robin Murphy [Wed, 3 Jul 2019 13:47:31 +0000 (14:47 +0100)]
of: address: Follow DMA parent for "dma-coherent"

commit c60bf3eb888a362100aa1bdbea351dab681e262a upstream.

Much like for address translation, when checking for DMA coherence we
should be sure to walk up the DMA hierarchy, rather than the MMIO one,
now that we can accommodate them being different.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Rob Herring <robh@kernel.org>
4 years agoof/address: Introduce of_get_next_dma_parent() helper
Robin Murphy [Wed, 3 Jul 2019 17:23:01 +0000 (18:23 +0100)]
of/address: Introduce of_get_next_dma_parent() helper

commit 862ab5578f754117742c8b8c8e5ddf98bdb190ba upstream.

Add of_get_next_dma_parent() helper which is similar to
__of_get_dma_parent(), but can be used in iterators and decrements the
ref count on the prior parent.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Rob Herring <robh@kernel.org>
4 years agoRevert "dma-direct: check for overflows on 32 bit DMA addresses"
Phil Elwell [Thu, 12 Mar 2020 14:06:04 +0000 (14:06 +0000)]
Revert "dma-direct: check for overflows on 32 bit DMA addresses"

This reverts commit e44850bd4205a8cf17f23c44668c0f8d28ad40b1.

4 years agoRevert "arm64/mm: Limit the DMA zone for arm64"
Phil Elwell [Thu, 12 Mar 2020 12:16:18 +0000 (12:16 +0000)]
Revert "arm64/mm: Limit the DMA zone for arm64"

This reverts commit 47fec0dcefa53f44985e95785021447d646daa2b.

4 years agoRevert "PCI: brcmstb: Add Broadcom STB PCIe host controller driver"
Phil Elwell [Mon, 9 Mar 2020 10:10:54 +0000 (10:10 +0000)]
Revert "PCI: brcmstb: Add Broadcom STB PCIe host controller driver"

This reverts commit 79624ca23c53064fefee774a89952a587b72cc01.

4 years agoRevert "PCI: brcmstb: Add dma-range mapping for inbound traffic"
Phil Elwell [Mon, 9 Mar 2020 10:08:49 +0000 (10:08 +0000)]
Revert "PCI: brcmstb: Add dma-range mapping for inbound traffic"

This reverts commit d45590eb858ac7a2578d477791881ba7ffb1e615.

4 years agoRevert "PCI: brcmstb: Add MSI capability"
Phil Elwell [Mon, 9 Mar 2020 10:08:35 +0000 (10:08 +0000)]
Revert "PCI: brcmstb: Add MSI capability"

This reverts commit b1619c83208e7b804e2c3547dbf24bb02b3be239.

4 years agoRevert "pcie-brcmstb: Changes for BCM2711"
Phil Elwell [Mon, 9 Mar 2020 10:07:39 +0000 (10:07 +0000)]
Revert "pcie-brcmstb: Changes for BCM2711"

This reverts commit 1dab5ded41ed07adc12f26e529aa64209a7c44b6.

4 years agoRevert "bcm2835-dma: Add proper 40-bit DMA support"
Phil Elwell [Mon, 9 Mar 2020 10:07:15 +0000 (10:07 +0000)]
Revert "bcm2835-dma: Add proper 40-bit DMA support"

This reverts commit 773a2db89ad2785d72b215673d87c0a51d769f61.

4 years agoRevert "bcm2835-dma: Correct SoC name"
Phil Elwell [Mon, 9 Mar 2020 10:06:59 +0000 (10:06 +0000)]
Revert "bcm2835-dma: Correct SoC name"

This reverts commit f498861a16d0b9a189a329080da1aa64d6e9bda7.

4 years agoRevert "pcie-brcmstb: Don't set DMA ops for root complex"
Phil Elwell [Fri, 6 Mar 2020 17:00:16 +0000 (17:00 +0000)]
Revert "pcie-brcmstb: Don't set DMA ops for root complex"

This reverts commit 510a127017a0aada2734dbf57d25aaa0189198ff.

4 years agoRevert "Ported pcie-brcmstb bounce buffer implementation to ARM64. (#3144)"
Phil Elwell [Fri, 6 Mar 2020 17:00:01 +0000 (17:00 +0000)]
Revert "Ported pcie-brcmstb bounce buffer implementation to ARM64. (#3144)"

This reverts commit 60f3db31d4cb785befed715b80c430f60f647701.

4 years agoRevert "pcie-brcmstb-bounce64.c: dev_err() -> dev_info() for info messages"
Phil Elwell [Fri, 6 Mar 2020 16:59:51 +0000 (16:59 +0000)]
Revert "pcie-brcmstb-bounce64.c: dev_err() -> dev_info() for info messages"

This reverts commit 2340a88a493d750dc3fcfa48de880fc4b8e479d2.

4 years agoRevert "pcie-brcmstb: Eliminate arch_dma_ops error message"
Phil Elwell [Fri, 6 Mar 2020 16:59:39 +0000 (16:59 +0000)]
Revert "pcie-brcmstb: Eliminate arch_dma_ops error message"

This reverts commit 27cf0ad95cdf30f52a5fc6c69014a0d7bf5a1222.

4 years agoRevert "pcie-brcmstb: Bounce buffer support is for BCM2711B0"
Phil Elwell [Fri, 6 Mar 2020 16:59:23 +0000 (16:59 +0000)]
Revert "pcie-brcmstb: Bounce buffer support is for BCM2711B0"

This reverts commit 58ac2d4474e531300f9f83773aa4d09e95ee2626.

4 years agoRevert "pcie-brcmstb: Correct SoC name"
Phil Elwell [Fri, 6 Mar 2020 16:59:11 +0000 (16:59 +0000)]
Revert "pcie-brcmstb: Correct SoC name"

This reverts commit 900b4ad0814df7dbacb01318bf49af5bab605fa0.

4 years agooverlays: sc16ic750-i2c: Fix xtal parameter
Phil Elwell [Tue, 3 Mar 2020 09:43:41 +0000 (09:43 +0000)]
overlays: sc16ic750-i2c: Fix xtal parameter

The xtal parameter is targetting the wrong node - fix it.

See: https://github.com/raspberrypi/linux/issues/3156

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Add KVM support to arm64 bcm2711_defconfig
Phil Elwell [Wed, 5 Feb 2020 17:25:52 +0000 (17:25 +0000)]
configs: Add KVM support to arm64 bcm2711_defconfig

See: https://github.com/raspberrypi/linux/issues/3035

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Add CONFIG_EXT4_ENCRYPTION=y
Phil Elwell [Thu, 27 Feb 2020 11:23:09 +0000 (11:23 +0000)]
configs: Add CONFIG_EXT4_ENCRYPTION=y

Enable EXT4 encryption support for all configurations except those
based on the original BCM2835, i.e. not on B+, Zero, etc. This
exception is because it would consume at least an additional 68KB,
which is a lot on a platform that may only have 128MB.

See: https://github.com/raspberrypi/linux/issues/2486

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Add CONFIG_HID_STEAM=m
Phil Elwell [Mon, 24 Feb 2020 11:13:09 +0000 (11:13 +0000)]
configs: Add CONFIG_HID_STEAM=m

See: https://github.com/raspberrypi/linux/issues/3344

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoof: overlay: Correct symbol path fixups
Phil Elwell [Thu, 6 Feb 2020 12:23:15 +0000 (12:23 +0000)]
of: overlay: Correct symbol path fixups

When symbols from overlays are added to the live tree their paths must
be rebased. The translated symbol is normally the result of joining
the fragment-relative path (with a leading "/") to the target path
(either copied directly from the "target-path" property or resolved
from the phandle). This translation fails when the target is the root
node (a common case for Raspberry Pi overlays) because the resulting
path starts with a double slash. For example, if target-path is "/" and
the fragment adds a node called "newnode", the label associated with
that node will be assigned the path "//newnode", which can't be found
in the tree.

Fix the failure case by explicitly replacing a target path of "/" with
an empty string.

Fixes: d1651b03c2df ("of: overlay: add overlay symbols to live device tree")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agobcmrpi3_defconfig: align RC config with bcm2711_defconfig
Matthias Reichl [Mon, 10 Feb 2020 17:21:02 +0000 (18:21 +0100)]
bcmrpi3_defconfig: align RC config with bcm2711_defconfig

Signed-off-by: Matthias Reichl <hias@horus.com>
4 years agodefconfigs: enable CONFIG_BPF_LIRC_MODE2
Matthias Reichl [Mon, 10 Feb 2020 14:47:07 +0000 (15:47 +0100)]
defconfigs: enable CONFIG_BPF_LIRC_MODE2

This enables support for IR decoding via BPF programs.

Signed-off-by: Matthias Reichl <hias@horus.com>
4 years agooverlays: Add timeout_ms parameter to gpio-poweroff
Phil Elwell [Fri, 7 Feb 2020 09:51:31 +0000 (09:51 +0000)]
overlays: Add timeout_ms parameter to gpio-poweroff

The timeout_ms parameter specifies in milliseconds how long the kernel
waits for power-down before issuing a WARN. The default value is 3000 ms.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agostaging: vc04_services: Fix vcsm overflow bug when counting transactions
Naushir Patuck [Thu, 30 Jan 2020 12:35:44 +0000 (12:35 +0000)]
staging: vc04_services: Fix vcsm overflow bug when counting transactions

The response block and local state were using u16 and u32 respectively
to represent transaction id.  When the former would wrap, there is a
mismatch and subsequent transactions will be marked as failures.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agoARM: dts: overlays: Create custom clocks in /
Phil Elwell [Fri, 28 Feb 2020 11:22:40 +0000 (11:22 +0000)]
ARM: dts: overlays: Create custom clocks in /

Change [1] removes the simple-bus compatible string from the "/clocks"
node, preventing any custom clocks placed there from being initialised.
Rather than reinstate the compatible string and trigger DT warnings at
kernel build time, change the overlays to instantiate those clocks under
the root node ("/").

See: https://github.com/raspberrypi/linux/issues/3481

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
[1] 4b2d24662126 ("ARM: dts: bcm283x: Remove simple-bus from fixed clocks")

4 years agoRevert "ARM: dts: bcm283x: Restore simple-bus to /clocks"
Phil Elwell [Fri, 28 Feb 2020 10:22:48 +0000 (10:22 +0000)]
Revert "ARM: dts: bcm283x: Restore simple-bus to /clocks"

This reverts commit 894dece014e4df68c9f6a11a0761fba1fcfc844f.

4 years agoARM: dts: bcm283x: Restore simple-bus to /clocks
Phil Elwell [Thu, 27 Feb 2020 13:34:08 +0000 (13:34 +0000)]
ARM: dts: bcm283x: Restore simple-bus to /clocks

Commit [1] ([2] upstream) removed the "simple-bus" compatible string,
"#address-cells" and "#size-cells" to fix some DT scheme warnings. In
doing so it prevented the child clocks from being instantiated - the
node might as well be absent.

Fix the problem (at least with regards to functionality) by restoring
"simple-bus" and the sizes.

See: https://github.com/raspberrypi/linux/issues/3481
Fixes: [1] 238506ebdea7 ("ARM: dts: bcm283x: Remove simple-bus from fixed clocks")
Fixes: [2] 4b2d24662126 ("ARM: dts: bcm283x: Remove simple-bus from fixed clocks")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoARM: dts: Move audio node under the vchiq parent
Phil Elwell [Mon, 3 Feb 2020 17:03:29 +0000 (17:03 +0000)]
ARM: dts: Move audio node under the vchiq parent

VCHIQ kernel clients are now instantiated as platform drivers rather
than using DT, but the children of the vchiq device can optionally be
given a sub-node of the vchiq parent for configuration and to disable
them.

Move the existing audio node beneath the vchiq parent, to prevent
multiple instantiation and unpleasant warnings. Note that the node
name has to match the module name - "bcm2835_audio".

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agostaging: vchiq_arm: Add a matching unregister call
Phil Elwell [Mon, 3 Feb 2020 17:33:01 +0000 (17:33 +0000)]
staging: vchiq_arm: Add a matching unregister call

All the registered children of vchiq have a corresponding call to
platform_device_unregister except bcm2835_audio. Fix that.

Fixes: 25c7597af20d ("staging: vchiq_arm: Register a platform device for audio")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agostaging: vchiq_arm: Give vchiq children DT nodes
Phil Elwell [Mon, 3 Feb 2020 17:30:46 +0000 (17:30 +0000)]
staging: vchiq_arm: Give vchiq children DT nodes

vchiq kernel clients are now instantiated as platform drivers rather
than using DT, but the children of the vchiq interface may still
benefit from access to DT properties. Give them the option of a
a sub-node of the vchiq parent for configuration and to allow
them to be disabled.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agostaging: vchiq_arm: Register a platform device for audio
Stefan Wahren [Thu, 6 Dec 2018 18:28:55 +0000 (19:28 +0100)]
staging: vchiq_arm: Register a platform device for audio

Following Eric's commit 37b7b3087a2f ("staging/vc04_services: Register a
platform device for the camera driver.") this register the audio driver as
a platform device, too.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoARM: dts: Remove CMA allocation from Pi 4 dts
Phil Elwell [Sat, 1 Feb 2020 08:58:11 +0000 (08:58 +0000)]
ARM: dts: Remove CMA allocation from Pi 4 dts

The 5.5 tree includes a patch to disable the CMA command line
parameter and replace it with properties from a DT node.
The upstream Pi 4 .dts, now used downstream with modifications,
includes the "linux,cma" node, but only reserves 32MB which is
often not enough.

Temporarily remove the "linux,cma" node to reenable the command line
parameter.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoARM: dts: Correct SoC name
Phil Elwell [Fri, 31 Jan 2020 15:24:59 +0000 (15:24 +0000)]
ARM: dts: Correct SoC name

The Pi 4 SoC is called BCM2711, not BCM2838.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agopcie-brcmstb: Correct SoC name
Phil Elwell [Fri, 31 Jan 2020 09:39:40 +0000 (09:39 +0000)]
pcie-brcmstb: Correct SoC name

The Pi 4 SoC is called BCM2711, not BCM2838.

Fixes: "bcm2835-dma: Add proper 40-bit DMA support"
Fixes: "Ported pcie-brcmstb bounce buffer implementation to ARM64."

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agohwrng: iproc-rng200: Correct SoC name
Phil Elwell [Fri, 31 Jan 2020 09:36:57 +0000 (09:36 +0000)]
hwrng: iproc-rng200: Correct SoC name

The Pi 4 SoC is called BCM2711, not BCM2838.

Fixes: "hwrng: iproc-rng200: Add BCM2838 support"

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agothermal: brcmstb_thermal: Correct SoC name
Phil Elwell [Fri, 31 Jan 2020 09:33:40 +0000 (09:33 +0000)]
thermal: brcmstb_thermal: Correct SoC name

The Pi 4 SoC is called BCM2711, not BCM2838.

Fixes: "thermal: brcmstb_thermal: Add BCM2838 support"

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agobcm2835-dma: Correct SoC name
Phil Elwell [Fri, 31 Jan 2020 09:28:57 +0000 (09:28 +0000)]
bcm2835-dma: Correct SoC name

The Pi 4 SoC is called BCM2711, not BCM2838.

Fixes: "bcm2835-dma: Add proper 40-bit DMA support"

4 years agostaging/vchiq_arm: Fix bcm2711 compatible string
Phil Elwell [Fri, 31 Jan 2020 09:26:18 +0000 (09:26 +0000)]
staging/vchiq_arm: Fix bcm2711 compatible string

Fixes: "vchiq: Add 36-bit address support"

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoRevert "bcm2711: Retain support for old dtbs"
Phil Elwell [Fri, 31 Jan 2020 15:47:43 +0000 (15:47 +0000)]
Revert "bcm2711: Retain support for old dtbs"

This reverts commit 61a505c739150c8dbb57a73db5c6c720d5160157.

4 years agoARM: dts: Rebuild downstream DTS files
Phil Elwell [Thu, 30 Jan 2020 15:48:00 +0000 (15:48 +0000)]
ARM: dts: Rebuild downstream DTS files

Refactor the tree of downstream DTS files to achieve approximately the
same end result but wihout modifying upstream files (except for
bcm2711-rpi-4-b.dts).

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoARM: dts: bcm2711: fix soc's node dma-ranges
Nicolas Saenz Julienne [Wed, 4 Dec 2019 12:56:33 +0000 (13:56 +0100)]
ARM: dts: bcm2711: fix soc's node dma-ranges

Raspberry Pi's firmware has a feature to select how much memory to
reserve for its GPU called 'gpu_mem'. The possible values go from 16MB
to 944MB, with a default of 64MB. This memory resides in the topmost
part of the lower 1GB memory area and grows bigger expanding towards the
begging of memory.

It turns out that with low 'gpu_mem' values (16MB and 32MB) the size of
the memory available to the system in the lower 1GB area can outgrow the
interconnect's dma-range as its size was selected based on the maximum
system memory available given the default gpu_mem configuration. This
makes that memory slice unavailable for DMA. And may cause nasty kernel
warnings if CMA happens to include it.

Change soc's dma-ranges to really reflect it's HW limitation, which is
being able to only DMA to the lower 1GB area.

Fixes: 7dbe8c62ceeb ("ARM: dts: Add minimal Raspberry Pi 4 support")
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
4 years agoARM: dts: bcm2711-rpi-4: Enable GENET support
Stefan Wahren [Mon, 11 Nov 2019 19:49:26 +0000 (20:49 +0100)]
ARM: dts: bcm2711-rpi-4: Enable GENET support

This enables the Gigabit Ethernet support on the Raspberry Pi 4.
The defined PHY mode is equivalent to the default register settings
in the downstream tree.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
4 years agoARM: dts: bcm2711: force CMA into first GB of memory
Nicolas Saenz Julienne [Wed, 6 Nov 2019 09:59:44 +0000 (10:59 +0100)]
ARM: dts: bcm2711: force CMA into first GB of memory

arm64 places the CMA in ZONE_DMA32, which is not good enough for the
Raspberry Pi 4 since it contains peripherals that can only address the
first GB of memory. Explicitly place the CMA into that area.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Acked-by: Stefan Wahren <wahrenst@gmx.net>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
4 years agoARM: dts: Add minimal Raspberry Pi 4 support
Stefan Wahren [Sun, 6 Oct 2019 13:41:25 +0000 (15:41 +0200)]
ARM: dts: Add minimal Raspberry Pi 4 support

This adds minimal support for the new Raspberry Pi 4 without the
fancy stuff like GENET, PCIe, xHCI, 40 bit DMA and V3D. The RPi 4 is
available in 3 different variants (1, 2 and 4 GB RAM), so leave the memory
size to zero and let the bootloader take care of it. The DWC2 is still
usable as peripheral via the USB-C port.

Other differences to the Raspberry Pi 3:
- additional GIC 400 Interrupt controller
- new thermal IP and HWRNG
- additional MMC interface (emmc2)
- additional UART, I2C, SPI and PWM interfaces
- clock stretching bug in I2C IP has been fixed

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Florian Fanelli <f.fainelli@gmail.com>
4 years agoARM: dts: Clean out downstream BCM2711/2838 files
Phil Elwell [Fri, 31 Jan 2020 16:53:13 +0000 (16:53 +0000)]
ARM: dts: Clean out downstream BCM2711/2838 files

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoARM: dts: Revert all changes to upstream dts files
Phil Elwell [Thu, 30 Jan 2020 11:39:39 +0000 (11:39 +0000)]
ARM: dts: Revert all changes to upstream dts files

With the possible exception of bcm2711* files where there is a name
clash, we should not be modifying upstream DTS files.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agobrcmfmac: Increase power saving delay to 2s
Phil Elwell [Mon, 3 Feb 2020 09:32:22 +0000 (09:32 +0000)]
brcmfmac: Increase power saving delay to 2s

Increase the delay before entering the lower power state to 2 seconds
(the maximum allowed) in order to reduce the packet latencies,
particularly for inbound packets.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoRevert "brcmfmac: Disable power management"
Phil Elwell [Wed, 13 Nov 2019 16:28:10 +0000 (16:28 +0000)]
Revert "brcmfmac: Disable power management"

Shortly after the release of the Pi 3B, a loss of SSH connectivity
over WiFi was traced to the power management handling, so power
management was disabled. And so it has remained ever since.

Enabling power management saves 55mA (~270mW) on a Pi 4B, so is very
much worth the minimal effort of reverting this patch, which was
squashed and rebased many times since then to the commit hash is
meaningless.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agooverlays: add hdmi-backlight-hwhack-gpio-overlay
Michael Kaplan [Wed, 5 Feb 2020 09:27:23 +0000 (10:27 +0100)]
overlays: add hdmi-backlight-hwhack-gpio-overlay

This is a Devicetree overlay for GPIO based backlight on/off capability.

Use this if you have one of those HDMI displays whose backlight cannot be controlled via DPMS over HDMI and plan to do a little soldering to use an RPi gpio pin for on/off switching.

See: https://www.waveshare.com/wiki/7inch_HDMI_LCD_(C)#Backlight_Control

This was tested with a clone of the Waveshare "7 inch HDMI Touch LCD C" where I soldered two mosfets to override the backlight dip-switch.
When the overlay is loaded, a sysfs backlight node appears which can be used to modify the brightness value (0 or 1), and is even used by DPMS to switch the display backlight off after the configured timeout.
(On current Raspbian Buster Desktop, it's also possible to wakeup the display via a tap on the touch display :-) )

Signed-off-by: Michael Kaplan <m.kaplan@evva.com>
4 years agoSQUASH: Fix spi driver compiler warnings
Phil Elwell [Tue, 4 Feb 2020 16:35:12 +0000 (16:35 +0000)]
SQUASH: Fix spi driver compiler warnings

Squash with "spi: spi-bcm2835: Disable forced software CS"

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agooverlays: Fix mcp23017's addr parameter
Phil Elwell [Tue, 4 Feb 2020 15:22:55 +0000 (15:22 +0000)]
overlays: Fix mcp23017's addr parameter

The addr parameter of the mcp23017 overlay was broken by the addition
of the noints parameter; splitting the mcp node in two without also
modifying the second half from the addr parameter would cause the two
halves to separate. Change the implementation strategy to patch
fragment 2 (as was originally proposed). This will prevent the
overlay from being applied at runtime until the "dtoverlay" command
is improved, but the overlay already has this restriction due to
fragment 3 so this isn't a step backwards.

See: https://github.com/raspberrypi/linux/issues/3449

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agooverlays: dwc2: Increase RX FIFO size
Phil Elwell [Tue, 4 Feb 2020 13:03:21 +0000 (13:03 +0000)]
overlays: dwc2: Increase RX FIFO size

The previous version of the dwc2 overlay set the RX FIFO size to
256 4-byte words. This sounds large enough for a 1024 byte packet (the
largest isochronous high speed packet allowed), but it doesn't take
into account some extra space needed by the hardware.

Minas Harutyunyan at Synopsys (the source of the DWC OTG design)
came up with a more correct value, 301, but since there is spare packet
RAM this can be increased to 558 to allow two packets per frame.

Also update the upstream overlay to match.

See: https://github.com/raspberrypi/linux/issues/3447

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Add NFS 4.2 support
Phil Elwell [Tue, 4 Feb 2020 12:42:27 +0000 (12:42 +0000)]
configs: Add NFS 4.2 support

See: https://github.com/raspberrypi/linux/issues/3397

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agooverlays: Add ssd1306-spi, ssh1106-spi, ssd-1351-spi
MikeDK [Fri, 31 Jan 2020 09:57:21 +0000 (10:57 +0100)]
overlays: Add ssd1306-spi, ssh1106-spi, ssd-1351-spi

Add overlays for SSD1306, SH1106 and SSD1351 based OLED displays.
SH1106 is present in many 1.3 inch OLEDs and SSD1351 is present in
1.5 inch RGB OLEDs from AliExpress.

This will load the staging fbtft drivers.

Signed-off-by: Michael Kaplan <m.kaplan@evva.com>
4 years agoARM: dts: Add sd_poll_once dtparam to bcm283x/2711
Phil Elwell [Thu, 30 Jan 2020 09:47:00 +0000 (09:47 +0000)]
ARM: dts: Add sd_poll_once dtparam to bcm283x/2711

The old sdtweak overlay allowed the SD interface to be effectively
disabled unless there was a card present at boot time, but that
overlay doesn't work on bcm2711 and has largely been replaced by
a set of sd_* dtparams (which have the advantage of being board-
specific.

Add an sd_poll_once dtparam to allow the same functionality on
all Raspberry Pi boards.

See: https://github.com/raspberrypi/linux/issues/3286

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agoRevert "staging: vchiq_arm: Register a platform device for audio"
popcornmix [Thu, 30 Jan 2020 12:42:07 +0000 (12:42 +0000)]
Revert "staging: vchiq_arm: Register a platform device for audio"

This reverts commit 25c7597af20d2b1d042bafd9be84eaa69c1690b7.

4 years agooverlays: Correct the eth_led* colour assignments
Phil Elwell [Wed, 29 Jan 2020 14:32:51 +0000 (14:32 +0000)]
overlays: Correct the eth_led* colour assignments

See: https://github.com/raspberrypi/firmware/issues/1311

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agousb: xhci: Raspberry Pi FW loader for VIA VL805
Tim Gover [Wed, 15 Jan 2020 11:26:19 +0000 (11:26 +0000)]
usb: xhci: Raspberry Pi FW loader for VIA VL805

The VL805 FW may either be loaded from an SPI EEPROM or alternatively
loaded directly by the VideoCore firmware. A PCI reset will reset
the VL805 XHCI controller on the Raspberry Pi4 requiring the firmware
to be reloaded if an SPI EEPROM is not present.

Use a VideoCore mailbox to trigger the loading of the VL805
firmware (if necessary) after a PCI reset.

Signed-off-by: Tim Gover <tim.gover@raspberrypi.org>
4 years agotty: amba-pl011: Avoid rare write-when-full error
Phil Elwell [Wed, 29 Jan 2020 09:35:19 +0000 (09:35 +0000)]
tty: amba-pl011: Avoid rare write-when-full error

Under some circumstances on BCM283x processors data loss can be
observed - a single byte missing from the TX output stream. These bytes
are always the last byte of a batch of 8 written from pl011_tx_chars
when from_irq is true, meaning that the FIFO full flag is not checked
before writing.

The transmit optimisation relies on the FIFO being half-empty when the
TX interrupt is raised. Instrumenting the driver further showed that
the failure case correlated with the TX FIFO full flag being set at the
point where the last byte was written to the data register, which
explains the data loss but not how the FIFO appeared to be prematurely
full. A possible explanation is that a FIFO write was in flight at the
time the interrupt was raised, but as yet there is no hypothesis as to
how this might occur.

In the absence of a clear understanding of the failure mechanism, avoid
the problem by checking the FIFO levels before writing the last byte of
the group, which will have minimal performance impact.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agoARM: dts: Remove bcm2838-rpi-4-b.dts
Phil Elwell [Wed, 29 Jan 2020 11:29:06 +0000 (11:29 +0000)]
ARM: dts: Remove bcm2838-rpi-4-b.dts

Upstream are not going to use the bcm2838 identifier, so begin the
cleanup by removing the suggested upstream Pi 4 .dts file.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agobcm2838.dtsi: Use BCM2711 PCIe compatible string
Phil Elwell [Fri, 12 Jul 2019 10:43:03 +0000 (11:43 +0100)]
bcm2838.dtsi: Use BCM2711 PCIe compatible string

The BCM2711 PCIe controller has a limited address range in the B0
silicon, and the driver uses a compatible string to identify the
limitation. The current Pi 4 firmware will override the compatible
string if it detects a downstream DTB and it is running on a newer
revision but set the default value to enable the workaround for
backwards-compatibility with old firmware.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agopcie-brcmstb: Bounce buffer support is for BCM2711B0
Phil Elwell [Fri, 12 Jul 2019 10:41:25 +0000 (11:41 +0100)]
pcie-brcmstb: Bounce buffer support is for BCM2711B0

Add a new compatible string to identify BCM2711B0, as later revisions
don't require the bounce buffer support.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agoARM: dts: Declare RPi 4B SD card power regulator
Phil Elwell [Tue, 30 Jul 2019 11:37:02 +0000 (12:37 +0100)]
ARM: dts: Declare RPi 4B SD card power regulator

Later revisions of the Raspberry Pi 4B have a separate control over the
SD card power. Expose that control to Linux as a fixed regulator with
a GPIO enable.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agommc: sdhci-iproc: Fix vmmc regulators on iProc
Phil Elwell [Fri, 2 Aug 2019 14:20:11 +0000 (15:20 +0100)]
mmc: sdhci-iproc: Fix vmmc regulators on iProc

The Linux support for controlling card power via regulators appears to
be contentious. I would argue that the default behaviour is contrary to
the SDHCI spec - turning off the power writes a reserved value to the
SD Bus Voltage Select field of the Power Control Register, which
seems to kill the Arasan/iProc controller - but fortunately there is a
hook in sdhci_ops to override the behaviour. Borrow the implementation
from sdhci_arasan_set_power.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agopisound: Added reading Pisound board hardware revision and exposing it (#3425)
gtrainavicius [Tue, 28 Jan 2020 12:16:37 +0000 (14:16 +0200)]
pisound: Added reading Pisound board hardware revision and exposing it (#3425)

pisound: Added reading Pisound board hardware revision and exposing it in kernel log and sysfs file:

/sys/kernel/pisound/hw_version

Signed-off-by: Giedrius <giedrius@blokas.io>
4 years agoadds LED OFF feature to HiFiBerry DAC+/DAC+PRO sound cards
j-schambacher [Mon, 27 Jan 2020 19:58:24 +0000 (20:58 +0100)]
adds LED OFF feature to HiFiBerry DAC+/DAC+PRO sound cards

This adds a DT overlay parameter 'leds_off' which allows
to switch off the onboard activity LEDs at all times
which has been requested by some users.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
4 years agoadds LED OFF feature to HiFiBerry DAC+ADC sound card
j-schambacher [Mon, 27 Jan 2020 19:37:34 +0000 (20:37 +0100)]
adds LED OFF feature to HiFiBerry DAC+ADC sound card

This adds a DT overlay parameter 'leds_off' which allows
to switch off the onboard activity LEDs at all times
which has been requested by some users.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
4 years agoadds LED OFF feature to HiFiBerry DAC+ADC PRO sound card
j-schambacher [Mon, 27 Jan 2020 16:45:51 +0000 (17:45 +0100)]
adds LED OFF feature to HiFiBerry DAC+ADC PRO sound card

This adds a DT overlay parameter 'leds_off' which allows
to switch off the onboard activity LEDs at all times
which has been requested by some users.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
4 years agoFix i2c-pwm-pca9685a overlay
MikeDK [Sun, 26 Jan 2020 22:33:54 +0000 (23:33 +0100)]
Fix i2c-pwm-pca9685a overlay

4 years agotty: amba-pl011: Add un/throttle support
Phil Elwell [Fri, 24 Jan 2020 11:38:28 +0000 (11:38 +0000)]
tty: amba-pl011: Add un/throttle support

The PL011 driver lacks throttle and unthrottle methods. As a result,
sending more data to the Pi than it can immediately sink while CRTSCTS
is enabled causes a NULL pointer to be followed.

Add a throttle handler that disables the RX interrupts, and an
unthrottle handler that reenables them.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agooverlays: Use preferred compatible strings
Phil Elwell [Fri, 24 Jan 2020 09:02:37 +0000 (09:02 +0000)]
overlays: Use preferred compatible strings

Make sure all overlays have correct compatible strings before enabling
the automated checking.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agoFix master mode settings of HiFiBerry DAC+ADC PRO card (#3424)
Jörg Schambacher [Thu, 23 Jan 2020 12:32:13 +0000 (13:32 +0100)]
Fix master mode settings of HiFiBerry DAC+ADC PRO card (#3424)

This patch fixes the board DAI setting when in master-mode.
Wrong setting could have caused random pop noise.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
4 years agoInitialise rpi-firmware before clk-bcm2835
Luke Hinds [Wed, 22 Jan 2020 16:03:00 +0000 (16:03 +0000)]
Initialise rpi-firmware before clk-bcm2835

The IMA (Integrity Measurement Architecture) looks for a TPM (Trusted
Platform Module) having been registered when it initialises; otherwise
it assumes there is no TPM. It has been observed on BCM2835 that IMA
is initialised before TPM, and that initialising the BCM2835 clock
driver before the firmware driver has the effect of reversing this
order.

Change the firmware driver to initialise at core_initcall, delaying the
BCM2835 clock driver to postcore_initcall.

See: https://github.com/raspberrypi/linux/issues/3291
     https://github.com/raspberrypi/linux/pull/3297

Signed-off-by: Luke Hinds <lhinds@redhat.com>
Co-authored-by: Phil Elwell <phil@raspberrypi.org>
4 years agoconfigs: Add missing HIFIBERRYs to bcmrpi3_defconfig
Phil Elwell [Tue, 21 Jan 2020 15:02:05 +0000 (15:02 +0000)]
configs: Add missing HIFIBERRYs to bcmrpi3_defconfig

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agosound: Add the HiFiBerry DAC+HD version
Jörg Schambacher [Tue, 21 Jan 2020 14:58:39 +0000 (15:58 +0100)]
sound: Add the HiFiBerry DAC+HD version

This adds the driver for the DAC+HD version supporting HiFiBerry's
PCM179x based DACs. It also adds PLL control for clock generation.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
4 years agoAdd universal device tree overlay for SPI devices
Ed Spiridonov [Tue, 10 Dec 2019 19:45:04 +0000 (22:45 +0300)]
Add universal device tree overlay for SPI devices

Just specify the SPI address and device name ("compatible" property).
This overlay lacks any device-specific parameter support!
(some of them could be added later)

Examples:
1. SPI NOR flash on spi0.1, maximum SPI clock frequency 45MHz:
    dtoverlay=anyspi:spi0-1,dev="jedec,spi-nor",speed=45000000
2. MCP3204 ADC on spi1.2, maximum SPI clock frequency 500kHz:
    dtoverlay=anyspi:spi1-2,dev="microchip,mcp3204"

Signed-off-by: Ed Spiridonov <edo.rus@gmail.com>
4 years agodwc_otg: fiq_fsm: add a barrier on entry into FIQ handler(s)
Jonathan Bell [Mon, 13 Jan 2020 15:54:55 +0000 (15:54 +0000)]
dwc_otg: fiq_fsm: add a barrier on entry into FIQ handler(s)

On BCM2835, there is no hardware guarantee that multiple outstanding
reads to different peripherals will complete in-order. The FIQ code
uses peripheral reads without barriers for performance, so in the case
where a read to a slow peripheral was issued immediately prior to FIQ
entry, the first peripheral read that the FIQ did could end up with
wrong read data returned.

Add dsb(sy) on entry so that all outstanding reads are retired.

The FIQ only issues reads to the dwc_otg core, so per-read barriers
in the handler itself are not required.

On BCM2836 and BCM2837 the barrier is not strictly required due to
differences in how the peripheral bus is implemented, but having
arch-specific handlers that introduce different latencies is risky.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 years agodwc_otg: fiq_fsm: pause when cancelling split transactions
Jonathan Bell [Wed, 8 Jan 2020 12:48:09 +0000 (12:48 +0000)]
dwc_otg: fiq_fsm: pause when cancelling split transactions

Non-periodic splits will DMA to/from the driver-provided transfer_buffer,
which may be freed immediately after the dequeue call returns. Block until
we know the transfer is complete.

A similar delay is needed when cleaning up disconnects, as the FIQ could
have started a periodic transfer in the previous microframe to the one
that triggered a disconnect.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 years agodwc_otg: constrain endpoint max packet and transfer size on split IN
Jonathan Bell [Tue, 7 Jan 2020 10:08:19 +0000 (10:08 +0000)]
dwc_otg: constrain endpoint max packet and transfer size on split IN

The hcd would unconditionally set the transfer length to the endpoint
packet size for non-isoc IN transfers. If the remaining buffer length
was less than the length of returned data, random memory would get
scribbled over, with bad effects if it crossed a page boundary.

Force a babble error if this happens by limiting the max transfer size
to the available buffer space. DMA will stop writing to memory on a
babble condition.

The hardware expects xfersize to be an integer multiple of maxpacket
size, so override hcchar.b.mps as well.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 years agoconfigs: Add BME680
Willem Remie [Thu, 9 Jan 2020 20:54:11 +0000 (21:54 +0100)]
configs: Add BME680