[armhf] Add support for BCM2836 and Raspberry Pi 2
- Patches for BCM283x drivers taken from linux-next - A few more changes requested for 4.5: http://thread.gmane.org/gmane.linux.kernel/2115942 - Enable all the drivers - Add SD and USB controller drivers to udebs
This commit is contained in:
parent
0a44c00d5c
commit
6642f73533
|
@ -5,6 +5,34 @@ linux (4.4~rc7-1~exp1) UNRELEASED; urgency=medium
|
|||
[ Ben Hutchings ]
|
||||
* [rt] Update to 4.4-rc6-rt1 and re-enable
|
||||
* [rt] Fix build error in kernel/time/hrtimer.c
|
||||
* [armhf] Add support for BCM2836 and Raspberry Pi 2:
|
||||
- pwm: bcm2835: Calculate scaler in ->config()
|
||||
- pwm: bcm2835: Prevent division by zero
|
||||
- drm: Create a driver hook for allocating GEM object structs
|
||||
- drm/vc4: Add a BO cache
|
||||
- drm/vc4: Add create and map BO ioctls
|
||||
- drm/vc4: Add an API for creating GPU shaders in GEM BOs
|
||||
- drm/vc4: Fix a typo in a V3D debug register
|
||||
- drm/vc4: Bind and initialize the V3D engine
|
||||
- drm/vc4: Add support for drawing 3D frames
|
||||
- drm/vc4: Add support for async pageflips
|
||||
- drm/vc4: Add an interface for capturing the GPU state after a hang
|
||||
- drm/vc4: copy_to_user() returns the number of bytes remaining
|
||||
- drm/vc4: allocate enough memory in vc4_save_hang_state()
|
||||
- drm/vc4: fix an error code
|
||||
- bcm2835: Add a compat string for bcm2836 machine probe
|
||||
- bcm2835: Add Kconfig support for bcm2836
|
||||
- bcm2835: Define two new packets from the latest firmware
|
||||
- bcm2835: add rpi power domain driver
|
||||
- bcm2835: Split the DT for peripherals from the DT for the CPU
|
||||
- bcm2835: Move the CPU/peripheral include out of common RPi DT
|
||||
- bcm2835: Add devicetree for bcm2836 and Raspberry Pi 2 B
|
||||
- bcm2835: Add the auxiliary clocks to the device tree
|
||||
- Enable ARCH_BCM, ARCH_BCM2835, DMA_BCM2835, BCM2835_MBOX,
|
||||
RASPBERRYPI_FIRMWARE, RASPBERRYPI_POWER
|
||||
- Enable DRM_VC4, I2C_BCM2835, MMC_SDHCI_BCM2835, PWM_BCM2835, SPI_BCM2835,
|
||||
SPI_BCM2835AUX, USB_DWC2, BCM2835_WDT, SND_BCM2835_SOC_I2S as modules
|
||||
- udeb: Add sdhci-bcm2835 to mmc-modules, dwc2 to usb-modules
|
||||
|
||||
-- Ben Hutchings <ben@decadent.org.uk> Thu, 24 Dec 2015 21:28:51 +0000
|
||||
|
||||
|
|
|
@ -33,6 +33,12 @@ CONFIG_NEON=y
|
|||
#. DEBUG_LL is incompatible with multiplatform
|
||||
# CONFIG_DEBUG_LL is not set
|
||||
|
||||
##
|
||||
## file: arch/arm/mach-bcm/Kconfig
|
||||
##
|
||||
CONFIG_ARCH_BCM=y
|
||||
CONFIG_ARCH_BCM2835=y
|
||||
|
||||
##
|
||||
## file: arch/arm/mach-exynos/Kconfig
|
||||
##
|
||||
|
@ -193,6 +199,7 @@ CONFIG_CRYPTO_DEV_SUN4I_SS=m
|
|||
##
|
||||
CONFIG_DMADEVICES=y
|
||||
CONFIG_AMBA_PL08X=y
|
||||
CONFIG_DMA_BCM2835=y
|
||||
CONFIG_DMA_OMAP=y
|
||||
CONFIG_DMA_SUN6I=m
|
||||
CONFIG_IMX_DMA=y
|
||||
|
@ -210,6 +217,11 @@ CONFIG_TI_EDMA=y
|
|||
CONFIG_EXTCON=m
|
||||
CONFIG_EXTCON_PALMAS=m
|
||||
|
||||
##
|
||||
## file: drivers/firmware/Kconfig
|
||||
##
|
||||
CONFIG_RASPBERRYPI_FIRMWARE=y
|
||||
|
||||
##
|
||||
## file: drivers/gpio/Kconfig
|
||||
##
|
||||
|
@ -258,6 +270,11 @@ CONFIG_DRM_TEGRA_FBDEV=y
|
|||
##
|
||||
CONFIG_DRM_TILCDC=m
|
||||
|
||||
##
|
||||
## file: drivers/gpu/drm/vc4/Kconfig
|
||||
##
|
||||
CONFIG_DRM_VC4=m
|
||||
|
||||
##
|
||||
## file: drivers/gpu/host1x/Kconfig
|
||||
##
|
||||
|
@ -299,6 +316,7 @@ CONFIG_HWSPINLOCK_OMAP=m
|
|||
##
|
||||
## file: drivers/i2c/busses/Kconfig
|
||||
##
|
||||
CONFIG_I2C_BCM2835=m
|
||||
CONFIG_I2C_EXYNOS5=m
|
||||
CONFIG_I2C_GPIO=y
|
||||
CONFIG_I2C_IMX=m
|
||||
|
@ -395,6 +413,7 @@ CONFIG_LEDS_TRIGGER_GPIO=m
|
|||
CONFIG_MAILBOX=y
|
||||
CONFIG_OMAP2PLUS_MBOX=y
|
||||
CONFIG_OMAP_MBOX_KFIFO_SIZE=256
|
||||
CONFIG_BCM2835_MBOX=y
|
||||
|
||||
##
|
||||
## file: drivers/media/Kconfig
|
||||
|
@ -471,6 +490,7 @@ CONFIG_MMC_SDHCI=m
|
|||
CONFIG_MMC_SDHCI_PLTFM=m
|
||||
CONFIG_MMC_SDHCI_ESDHC_IMX=m
|
||||
CONFIG_MMC_SDHCI_TEGRA=m
|
||||
CONFIG_MMC_SDHCI_BCM2835=m
|
||||
CONFIG_MMC_OMAP=m
|
||||
CONFIG_MMC_OMAP_HS=m
|
||||
CONFIG_MMC_MVSDIO=m
|
||||
|
@ -728,6 +748,7 @@ CONFIG_POWER_RESET_SYSCON_POWEROFF=y
|
|||
## file: drivers/pwm/Kconfig
|
||||
##
|
||||
CONFIG_PWM=y
|
||||
CONFIG_PWM_BCM2835=m
|
||||
CONFIG_PWM_IMX=m
|
||||
CONFIG_PWM_SUN4I=m
|
||||
CONFIG_PWM_TEGRA=m
|
||||
|
@ -790,10 +811,17 @@ CONFIG_RTC_DRV_SNVS=y
|
|||
CONFIG_SCSI_DMX3191D=m
|
||||
CONFIG_SCSI_AM53C974=m
|
||||
|
||||
##
|
||||
## file: drivers/soc/bcm/Kconfig
|
||||
##
|
||||
CONFIG_RASPBERRYPI_POWER=y
|
||||
|
||||
##
|
||||
## file: drivers/spi/Kconfig
|
||||
##
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPI_BCM2835=m
|
||||
CONFIG_SPI_BCM2835AUX=m
|
||||
CONFIG_SPI_GPIO=y
|
||||
CONFIG_SPI_IMX=m
|
||||
CONFIG_SPI_OMAP24XX=m
|
||||
|
@ -869,6 +897,14 @@ CONFIG_USB_CHIPIDEA_UDC=y
|
|||
CONFIG_USB_CHIPIDEA_HOST=y
|
||||
CONFIG_USB_CHIPIDEA_DEBUG=y
|
||||
|
||||
##
|
||||
## file: drivers/usb/dwc2/Kconfig
|
||||
##
|
||||
CONFIG_USB_DWC2=m
|
||||
## choice: DWC2 Mode Selection
|
||||
CONFIG_USB_DWC2_DUAL_ROLE=y
|
||||
## end choice
|
||||
|
||||
##
|
||||
## file: drivers/usb/dwc3/Kconfig
|
||||
##
|
||||
|
@ -995,6 +1031,7 @@ CONFIG_SUNXI_WATCHDOG=m
|
|||
CONFIG_TWL4030_WATCHDOG=m
|
||||
CONFIG_IMX2_WDT=m
|
||||
CONFIG_TEGRA_WATCHDOG=m
|
||||
CONFIG_BCM2835_WDT=m
|
||||
|
||||
##
|
||||
## file: kernel/power/Kconfig
|
||||
|
@ -1017,6 +1054,11 @@ CONFIG_SND_HDA_TEGRA=m
|
|||
##
|
||||
CONFIG_SND_SOC=m
|
||||
|
||||
##
|
||||
## file: sound/soc/bcm/Kconfig
|
||||
##
|
||||
CONFIG_SND_BCM2835_SOC_I2S=m
|
||||
|
||||
##
|
||||
## file: sound/soc/fsl/Kconfig
|
||||
##
|
||||
|
|
|
@ -6,3 +6,4 @@ omap_hsmmc
|
|||
sunxi-mmc
|
||||
dw_mmc-exynos
|
||||
pbias-regulator
|
||||
sdhci-bcm2835
|
||||
|
|
|
@ -12,3 +12,4 @@ phy-exynos-usb2
|
|||
phy-omap-usb2
|
||||
ci_hdrc_imx
|
||||
phy-mxs-usb
|
||||
dwc2
|
||||
|
|
30
debian/patches/features/arm/rpi/arm-bcm2835-add-a-compat-string-for-bcm2836-machine-.patch
vendored
Normal file
30
debian/patches/features/arm/rpi/arm-bcm2835-add-a-compat-string-for-bcm2836-machine-.patch
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Wed, 16 Dec 2015 15:55:14 -0800
|
||||
Subject: [2/3] ARM: bcm2835: Add a compat string for bcm2836 machine probe
|
||||
Origin: https://github.com/anholt/linux/commit/c1be3c1fc6178ca48750b4e66f1acb7c22b64997
|
||||
|
||||
Supporting the 2836 requires using the new interrupt controller, which
|
||||
we have support for.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
arch/arm/mach-bcm/board_bcm2835.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/arch/arm/mach-bcm/board_bcm2835.c b/arch/arm/mach-bcm/board_bcm2835.c
|
||||
index 0f7b9ea..834d676 100644
|
||||
--- a/arch/arm/mach-bcm/board_bcm2835.c
|
||||
+++ b/arch/arm/mach-bcm/board_bcm2835.c
|
||||
@@ -36,7 +36,12 @@ static void __init bcm2835_init(void)
|
||||
}
|
||||
|
||||
static const char * const bcm2835_compat[] = {
|
||||
+#ifdef CONFIG_ARCH_MULTI_V6
|
||||
"brcm,bcm2835",
|
||||
+#endif
|
||||
+#ifdef CONFIG_ARCH_MULTI_V7
|
||||
+ "brcm,bcm2836",
|
||||
+#endif
|
||||
NULL
|
||||
};
|
||||
|
156
debian/patches/features/arm/rpi/arm-bcm2835-add-devicetree-for-bcm2836-and-raspberry.patch
vendored
Normal file
156
debian/patches/features/arm/rpi/arm-bcm2835-add-devicetree-for-bcm2836-and-raspberry.patch
vendored
Normal file
|
@ -0,0 +1,156 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Thu, 16 Apr 2015 15:26:45 -0700
|
||||
Subject: [3/4] ARM: bcm2835: Add devicetree for bcm2836 and Raspberry Pi 2 B
|
||||
Origin: https://github.com/anholt/linux/commit/c33319cd945001741d1b381655c8b7310d756163
|
||||
|
||||
The Pi 2 B ends up like a Pi 1 B+, with the same peripherals and
|
||||
pinout, but the CPU and memory layout changed to use the 2836.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
arch/arm/boot/dts/Makefile | 3 +-
|
||||
arch/arm/boot/dts/bcm2836-rpi-2-b.dts | 35 ++++++++++++++++
|
||||
arch/arm/boot/dts/bcm2836.dtsi | 78 +++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 115 insertions(+), 1 deletion(-)
|
||||
create mode 100644 arch/arm/boot/dts/bcm2836-rpi-2-b.dts
|
||||
create mode 100644 arch/arm/boot/dts/bcm2836.dtsi
|
||||
|
||||
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
|
||||
index 30bbc37..54e8f6b 100644
|
||||
--- a/arch/arm/boot/dts/Makefile
|
||||
+++ b/arch/arm/boot/dts/Makefile
|
||||
@@ -60,7 +60,8 @@ dtb-$(CONFIG_ARCH_BCM2835) += \
|
||||
bcm2835-rpi-b.dtb \
|
||||
bcm2835-rpi-b-rev2.dtb \
|
||||
bcm2835-rpi-b-plus.dtb \
|
||||
- bcm2835-rpi-a-plus.dtb
|
||||
+ bcm2835-rpi-a-plus.dtb \
|
||||
+ bcm2836-rpi-2-b.dtb
|
||||
dtb-$(CONFIG_ARCH_BCM_5301X) += \
|
||||
bcm4708-asus-rt-ac56u.dtb \
|
||||
bcm4708-asus-rt-ac68u.dtb \
|
||||
diff --git a/arch/arm/boot/dts/bcm2836-rpi-2-b.dts b/arch/arm/boot/dts/bcm2836-rpi-2-b.dts
|
||||
new file mode 100644
|
||||
index 0000000..ff94666
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/bcm2836-rpi-2-b.dts
|
||||
@@ -0,0 +1,35 @@
|
||||
+/dts-v1/;
|
||||
+#include "bcm2836.dtsi"
|
||||
+#include "bcm2835-rpi.dtsi"
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "raspberrypi,2-model-b", "brcm,bcm2836";
|
||||
+ model = "Raspberry Pi 2 Model B";
|
||||
+
|
||||
+ memory {
|
||||
+ reg = <0 0x40000000>;
|
||||
+ };
|
||||
+
|
||||
+ leds {
|
||||
+ act {
|
||||
+ gpios = <&gpio 47 0>;
|
||||
+ };
|
||||
+
|
||||
+ pwr {
|
||||
+ label = "PWR";
|
||||
+ gpios = <&gpio 35 0>;
|
||||
+ default-state = "keep";
|
||||
+ linux,default-trigger = "default-on";
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&gpio {
|
||||
+ pinctrl-0 = <&gpioout &alt0 &i2s_alt0 &alt3>;
|
||||
+
|
||||
+ /* I2S interface */
|
||||
+ i2s_alt0: i2s_alt0 {
|
||||
+ brcm,pins = <18 19 20 21>;
|
||||
+ brcm,function = <BCM2835_FSEL_ALT0>;
|
||||
+ };
|
||||
+};
|
||||
diff --git a/arch/arm/boot/dts/bcm2836.dtsi b/arch/arm/boot/dts/bcm2836.dtsi
|
||||
new file mode 100644
|
||||
index 0000000..9d0651d
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/bcm2836.dtsi
|
||||
@@ -0,0 +1,78 @@
|
||||
+#include "bcm283x.dtsi"
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "brcm,bcm2836";
|
||||
+
|
||||
+ soc {
|
||||
+ ranges = <0x7e000000 0x3f000000 0x1000000>,
|
||||
+ <0x40000000 0x40000000 0x00001000>;
|
||||
+ dma-ranges = <0xc0000000 0x00000000 0x3f000000>;
|
||||
+
|
||||
+ local_intc: local_intc {
|
||||
+ compatible = "brcm,bcm2836-l1-intc";
|
||||
+ reg = <0x40000000 0x100>;
|
||||
+ interrupt-controller;
|
||||
+ #interrupt-cells = <1>;
|
||||
+ interrupt-parent = <&local_intc>;
|
||||
+ };
|
||||
+
|
||||
+ arm-pmu {
|
||||
+ compatible = "arm,cortex-a7-pmu";
|
||||
+ interrupt-parent = <&local_intc>;
|
||||
+ interrupts = <9>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ timer {
|
||||
+ compatible = "arm,armv7-timer";
|
||||
+ interrupt-parent = <&local_intc>;
|
||||
+ interrupts = <0>, // PHYS_SECURE_PPI
|
||||
+ <1>, // PHYS_NONSECURE_PPI
|
||||
+ <3>, // VIRT_PPI
|
||||
+ <2>; // HYP_PPI
|
||||
+ always-on;
|
||||
+ };
|
||||
+
|
||||
+ cpus: cpus {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ v7_cpu0: cpu@0 {
|
||||
+ device_type = "cpu";
|
||||
+ compatible = "arm,cortex-a7";
|
||||
+ reg = <0xf00>;
|
||||
+ clock-frequency = <800000000>;
|
||||
+ };
|
||||
+
|
||||
+ v7_cpu1: cpu@1 {
|
||||
+ device_type = "cpu";
|
||||
+ compatible = "arm,cortex-a7";
|
||||
+ reg = <0xf01>;
|
||||
+ clock-frequency = <800000000>;
|
||||
+ };
|
||||
+
|
||||
+ v7_cpu2: cpu@2 {
|
||||
+ device_type = "cpu";
|
||||
+ compatible = "arm,cortex-a7";
|
||||
+ reg = <0xf02>;
|
||||
+ clock-frequency = <800000000>;
|
||||
+ };
|
||||
+
|
||||
+ v7_cpu3: cpu@3 {
|
||||
+ device_type = "cpu";
|
||||
+ compatible = "arm,cortex-a7";
|
||||
+ reg = <0xf03>;
|
||||
+ clock-frequency = <800000000>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+/* Make the BCM2835-style global interrupt controller be a child of the
|
||||
+ * CPU-local interrupt controller.
|
||||
+ */
|
||||
+&intc {
|
||||
+ compatible = "brcm,bcm2836-armctrl-ic";
|
||||
+ reg = <0x7e00b200 0x200>;
|
||||
+ interrupt-parent = <&local_intc>;
|
||||
+ interrupts = <8>;
|
||||
+};
|
76
debian/patches/features/arm/rpi/arm-bcm2835-add-kconfig-support-for-bcm2836.patch
vendored
Normal file
76
debian/patches/features/arm/rpi/arm-bcm2835-add-kconfig-support-for-bcm2836.patch
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Tue, 24 Feb 2015 15:07:55 +0000
|
||||
Subject: [3/3] ARM: bcm2835: Add Kconfig support for bcm2836
|
||||
Origin: https://github.com/anholt/linux/commit/5234c34e4cd7695647ccc1cabb50c3e7720dd3fb
|
||||
|
||||
This should be a complete port of bcm2835 functionality to bcm2836
|
||||
(Raspberry Pi 2).
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
arch/arm/Kconfig.debug | 10 ++++++++--
|
||||
arch/arm/mach-bcm/Kconfig | 9 +++++----
|
||||
2 files changed, 13 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
|
||||
index 259c0ca..957b876 100644
|
||||
--- a/arch/arm/Kconfig.debug
|
||||
+++ b/arch/arm/Kconfig.debug
|
||||
@@ -143,7 +143,12 @@ choice
|
||||
|
||||
config DEBUG_BCM2835
|
||||
bool "Kernel low-level debugging on BCM2835 PL011 UART"
|
||||
- depends on ARCH_BCM2835
|
||||
+ depends on ARCH_BCM2835 && ARCH_MULTI_V6
|
||||
+ select DEBUG_UART_PL01X
|
||||
+
|
||||
+ config DEBUG_BCM2836
|
||||
+ bool "Kernel low-level debugging on BCM2836 PL011 UART"
|
||||
+ depends on ARCH_BCM2835 && ARCH_MULTI_V7
|
||||
select DEBUG_UART_PL01X
|
||||
|
||||
config DEBUG_BCM_5301X
|
||||
@@ -1402,6 +1407,7 @@ config DEBUG_UART_PHYS
|
||||
default 0x20064000 if DEBUG_RK29_UART1 || DEBUG_RK3X_UART2
|
||||
default 0x20068000 if DEBUG_RK29_UART2 || DEBUG_RK3X_UART3
|
||||
default 0x20201000 if DEBUG_BCM2835
|
||||
+ default 0x3f201000 if DEBUG_BCM2836
|
||||
default 0x3e000000 if DEBUG_BCM_KONA_UART
|
||||
default 0x4000e400 if DEBUG_LL_UART_EFM32
|
||||
default 0x40081000 if DEBUG_LPC18XX_UART0
|
||||
@@ -1485,7 +1491,7 @@ config DEBUG_UART_VIRT
|
||||
default 0xf0000be0 if ARCH_EBSA110
|
||||
default 0xf0010000 if DEBUG_ASM9260_UART
|
||||
default 0xf01fb000 if DEBUG_NOMADIK_UART
|
||||
- default 0xf0201000 if DEBUG_BCM2835
|
||||
+ default 0xf0201000 if DEBUG_BCM2835 || DEBUG_BCM2836
|
||||
default 0xf1000300 if DEBUG_BCM_5301X
|
||||
default 0xf1002000 if DEBUG_MT8127_UART0
|
||||
default 0xf1006000 if DEBUG_MT6589_UART0
|
||||
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
|
||||
index 8c53c55..3b2acf4 100644
|
||||
--- a/arch/arm/mach-bcm/Kconfig
|
||||
+++ b/arch/arm/mach-bcm/Kconfig
|
||||
@@ -122,17 +122,18 @@ config ARCH_BCM_MOBILE_SMP
|
||||
comment "Other Architectures"
|
||||
|
||||
config ARCH_BCM2835
|
||||
- bool "Broadcom BCM2835 family" if ARCH_MULTI_V6
|
||||
+ bool "Broadcom BCM2835 family" if ARCH_MULTI_V6 || ARCH_MULTI_V7
|
||||
select ARCH_REQUIRE_GPIOLIB
|
||||
select ARM_AMBA
|
||||
- select ARM_ERRATA_411920
|
||||
+ select ARM_ERRATA_411920 if ARCH_MULTI_V6
|
||||
select ARM_TIMER_SP804
|
||||
+ select HAVE_ARM_ARCH_TIMER if ARCH_MULTI_V7
|
||||
select CLKSRC_OF
|
||||
select PINCTRL
|
||||
select PINCTRL_BCM2835
|
||||
help
|
||||
- This enables support for the Broadcom BCM2835 SoC. This SoC is
|
||||
- used in the Raspberry Pi and Roku 2 devices.
|
||||
+ This enables support for the Broadcom BCM2835 and BCM2836 SoCs.
|
||||
+ This SoC is used in the Raspberry Pi and Roku 2 devices.
|
||||
|
||||
config ARCH_BCM_63XX
|
||||
bool "Broadcom BCM63xx DSL SoC" if ARCH_MULTI_V7
|
376
debian/patches/features/arm/rpi/arm-bcm2835-add-rpi-power-domain-driver.patch
vendored
Normal file
376
debian/patches/features/arm/rpi/arm-bcm2835-add-rpi-power-domain-driver.patch
vendored
Normal file
|
@ -0,0 +1,376 @@
|
|||
From: Alexander Aring <alex.aring@gmail.com>
|
||||
Date: Wed, 16 Dec 2015 16:26:47 -0800
|
||||
Subject: [3/3] ARM: bcm2835: add rpi power domain driver
|
||||
Origin: https://github.com/anholt/linux/commit/a09cd356586d33f64cbe64ee4f5c1a7c4a6abee5
|
||||
|
||||
This patch adds support for several power domains on Raspberry Pi,
|
||||
including USB (so it can be enabled even if the bootloader didn't do
|
||||
it), and graphics.
|
||||
|
||||
This patch is the combined work of Eric Anholt (who wrote USB support
|
||||
inside of the Raspberry Pi firmware driver, and wrote the non-USB
|
||||
domain support) and Alexander Aring (who separated the original USB
|
||||
work out from the firmware driver).
|
||||
|
||||
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
|
||||
Reviewed-by: Kevin Hilman <khilman@linaro.org>
|
||||
---
|
||||
drivers/soc/Kconfig | 1 +
|
||||
drivers/soc/Makefile | 1 +
|
||||
drivers/soc/bcm/Kconfig | 9 +
|
||||
drivers/soc/bcm/Makefile | 1 +
|
||||
drivers/soc/bcm/raspberrypi-power.c | 247 ++++++++++++++++++++++++++
|
||||
include/dt-bindings/power/raspberrypi-power.h | 41 +++++
|
||||
6 files changed, 300 insertions(+)
|
||||
create mode 100644 drivers/soc/bcm/Kconfig
|
||||
create mode 100644 drivers/soc/bcm/Makefile
|
||||
create mode 100644 drivers/soc/bcm/raspberrypi-power.c
|
||||
create mode 100644 include/dt-bindings/power/raspberrypi-power.h
|
||||
|
||||
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
|
||||
index 4e853ed..8441426 100644
|
||||
--- a/drivers/soc/Kconfig
|
||||
+++ b/drivers/soc/Kconfig
|
||||
@@ -1,5 +1,6 @@
|
||||
menu "SOC (System On Chip) specific Drivers"
|
||||
|
||||
+source "drivers/soc/bcm/Kconfig"
|
||||
source "drivers/soc/brcmstb/Kconfig"
|
||||
source "drivers/soc/mediatek/Kconfig"
|
||||
source "drivers/soc/qcom/Kconfig"
|
||||
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
|
||||
index f2ba2e9..f3f955c 100644
|
||||
--- a/drivers/soc/Makefile
|
||||
+++ b/drivers/soc/Makefile
|
||||
@@ -2,6 +2,7 @@
|
||||
# Makefile for the Linux Kernel SOC specific device drivers.
|
||||
#
|
||||
|
||||
+obj-y += bcm/
|
||||
obj-$(CONFIG_SOC_BRCMSTB) += brcmstb/
|
||||
obj-$(CONFIG_MACH_DOVE) += dove/
|
||||
obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
|
||||
diff --git a/drivers/soc/bcm/Kconfig b/drivers/soc/bcm/Kconfig
|
||||
new file mode 100644
|
||||
index 0000000..5ba1827
|
||||
--- /dev/null
|
||||
+++ b/drivers/soc/bcm/Kconfig
|
||||
@@ -0,0 +1,9 @@
|
||||
+config RASPBERRYPI_POWER
|
||||
+ bool "Raspberry Pi power domain driver"
|
||||
+ depends on ARCH_BCM2835 || COMPILE_TEST
|
||||
+ depends on RASPBERRYPI_FIRMWARE
|
||||
+ select PM_GENERIC_DOMAINS if PM
|
||||
+ select PM_GENERIC_DOMAINS_OF if PM
|
||||
+ help
|
||||
+ This enables support for the RPi power domains which can be enabled
|
||||
+ or disabled via the RPi firmware.
|
||||
diff --git a/drivers/soc/bcm/Makefile b/drivers/soc/bcm/Makefile
|
||||
new file mode 100644
|
||||
index 0000000..63aa3eb
|
||||
--- /dev/null
|
||||
+++ b/drivers/soc/bcm/Makefile
|
||||
@@ -0,0 +1 @@
|
||||
+obj-$(CONFIG_RASPBERRYPI_POWER) += raspberrypi-power.o
|
||||
diff --git a/drivers/soc/bcm/raspberrypi-power.c b/drivers/soc/bcm/raspberrypi-power.c
|
||||
new file mode 100644
|
||||
index 0000000..fe96a8b
|
||||
--- /dev/null
|
||||
+++ b/drivers/soc/bcm/raspberrypi-power.c
|
||||
@@ -0,0 +1,247 @@
|
||||
+/* (C) 2015 Pengutronix, Alexander Aring <aar@pengutronix.de>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License version 2 as
|
||||
+ * published by the Free Software Foundation.
|
||||
+ *
|
||||
+ * Authors:
|
||||
+ * Alexander Aring <aar@pengutronix.de>
|
||||
+ * Eric Anholt <eric@anholt.net>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/of_platform.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/pm_domain.h>
|
||||
+#include <dt-bindings/power/raspberrypi-power.h>
|
||||
+#include <soc/bcm2835/raspberrypi-firmware.h>
|
||||
+
|
||||
+/*
|
||||
+ * Firmware indices for the old power domains interface. Only a few
|
||||
+ * of them were actually implemented.
|
||||
+ */
|
||||
+#define RPI_OLD_POWER_DOMAIN_USB 3
|
||||
+#define RPI_OLD_POWER_DOMAIN_V3D 10
|
||||
+
|
||||
+struct rpi_power_domain {
|
||||
+ u32 domain;
|
||||
+ bool enabled;
|
||||
+ bool old_interface;
|
||||
+ struct generic_pm_domain base;
|
||||
+ struct rpi_firmware *fw;
|
||||
+};
|
||||
+
|
||||
+struct rpi_power_domains {
|
||||
+ bool has_new_interface;
|
||||
+ struct genpd_onecell_data xlate;
|
||||
+ struct rpi_firmware *fw;
|
||||
+ struct rpi_power_domain domains[RPI_POWER_DOMAIN_COUNT];
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ * Packet definition used by RPI_FIRMWARE_SET_POWER_STATE and
|
||||
+ * RPI_FIRMWARE_SET_DOMAIN_STATE
|
||||
+ */
|
||||
+struct rpi_power_domain_packet {
|
||||
+ u32 domain;
|
||||
+ u32 on;
|
||||
+} __packet;
|
||||
+
|
||||
+/*
|
||||
+ * Asks the firmware to enable or disable power on a specific power
|
||||
+ * domain.
|
||||
+ */
|
||||
+static int rpi_firmware_set_power(struct rpi_power_domain *rpi_domain, bool on)
|
||||
+{
|
||||
+ struct rpi_power_domain_packet packet;
|
||||
+
|
||||
+ packet.domain = rpi_domain->domain;
|
||||
+ packet.on = on;
|
||||
+ return rpi_firmware_property(rpi_domain->fw,
|
||||
+ rpi_domain->old_interface ?
|
||||
+ RPI_FIRMWARE_SET_POWER_STATE :
|
||||
+ RPI_FIRMWARE_SET_DOMAIN_STATE,
|
||||
+ &packet, sizeof(packet));
|
||||
+}
|
||||
+
|
||||
+static int rpi_domain_off(struct generic_pm_domain *domain)
|
||||
+{
|
||||
+ struct rpi_power_domain *rpi_domain =
|
||||
+ container_of(domain, struct rpi_power_domain, base);
|
||||
+
|
||||
+ return rpi_firmware_set_power(rpi_domain, false);
|
||||
+}
|
||||
+
|
||||
+static int rpi_domain_on(struct generic_pm_domain *domain)
|
||||
+{
|
||||
+ struct rpi_power_domain *rpi_domain =
|
||||
+ container_of(domain, struct rpi_power_domain, base);
|
||||
+
|
||||
+ return rpi_firmware_set_power(rpi_domain, true);
|
||||
+}
|
||||
+
|
||||
+static void rpi_common_init_power_domain(struct rpi_power_domains *rpi_domains,
|
||||
+ int xlate_index, const char *name)
|
||||
+{
|
||||
+ struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index];
|
||||
+
|
||||
+ dom->fw = rpi_domains->fw;
|
||||
+
|
||||
+ dom->base.name = name;
|
||||
+ dom->base.power_on = rpi_domain_on;
|
||||
+ dom->base.power_off = rpi_domain_off;
|
||||
+
|
||||
+ /*
|
||||
+ * Treat all power domains as off at boot.
|
||||
+ *
|
||||
+ * The firmware itself may be keeping some domains on, but
|
||||
+ * from Linux's perspective all we control is the refcounts
|
||||
+ * that we give to the firmware, and we can't ask the firmware
|
||||
+ * to turn off something that we haven't ourselves turned on.
|
||||
+ */
|
||||
+ pm_genpd_init(&dom->base, NULL, true);
|
||||
+
|
||||
+ rpi_domains->xlate.domains[xlate_index] = &dom->base;
|
||||
+}
|
||||
+
|
||||
+static void rpi_init_power_domain(struct rpi_power_domains *rpi_domains,
|
||||
+ int xlate_index, const char *name)
|
||||
+{
|
||||
+ struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index];
|
||||
+
|
||||
+ if (!rpi_domains->has_new_interface)
|
||||
+ return;
|
||||
+
|
||||
+ /* The DT binding index is the firmware's domain index minus one. */
|
||||
+ dom->domain = xlate_index + 1;
|
||||
+
|
||||
+ rpi_common_init_power_domain(rpi_domains, xlate_index, name);
|
||||
+}
|
||||
+
|
||||
+static void rpi_init_old_power_domain(struct rpi_power_domains *rpi_domains,
|
||||
+ int xlate_index, int domain,
|
||||
+ const char *name)
|
||||
+{
|
||||
+ struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index];
|
||||
+
|
||||
+ dom->old_interface = true;
|
||||
+ dom->domain = domain;
|
||||
+
|
||||
+ rpi_common_init_power_domain(rpi_domains, xlate_index, name);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Detects whether the firmware supports the new power domains interface.
|
||||
+ *
|
||||
+ * The firmware doesn't actually return an error on an unknown tag,
|
||||
+ * and just skips over it, so we do the detection by putting an
|
||||
+ * unexpected value in the return field and checking if it was
|
||||
+ * unchanged.
|
||||
+ */
|
||||
+static bool
|
||||
+rpi_has_new_domain_support(struct rpi_power_domains *rpi_domains)
|
||||
+{
|
||||
+ struct rpi_power_domain_packet packet;
|
||||
+ int ret;
|
||||
+
|
||||
+ packet.domain = RPI_POWER_DOMAIN_ARM;
|
||||
+ packet.on = ~0;
|
||||
+
|
||||
+ ret = rpi_firmware_property(rpi_domains->fw,
|
||||
+ RPI_FIRMWARE_GET_DOMAIN_STATE,
|
||||
+ &packet, sizeof(packet));
|
||||
+
|
||||
+ return ret == 0 && packet.on != ~0;
|
||||
+}
|
||||
+
|
||||
+static int rpi_power_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device_node *fw_np;
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct rpi_power_domains *rpi_domains;
|
||||
+
|
||||
+ rpi_domains = devm_kzalloc(dev, sizeof(*rpi_domains), GFP_KERNEL);
|
||||
+ if (!rpi_domains)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ rpi_domains->xlate.domains =
|
||||
+ devm_kzalloc(dev, sizeof(*rpi_domains->xlate.domains) *
|
||||
+ RPI_POWER_DOMAIN_COUNT, GFP_KERNEL);
|
||||
+ if (!rpi_domains->xlate.domains)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ rpi_domains->xlate.num_domains = RPI_POWER_DOMAIN_COUNT;
|
||||
+
|
||||
+ fw_np = of_parse_phandle(pdev->dev.of_node, "firmware", 0);
|
||||
+ if (!fw_np) {
|
||||
+ dev_err(&pdev->dev, "no firmware node\n");
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ rpi_domains->fw = rpi_firmware_get(fw_np);
|
||||
+ of_node_put(fw_np);
|
||||
+ if (!rpi_domains->fw)
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ rpi_domains->has_new_interface =
|
||||
+ rpi_has_new_domain_support(rpi_domains);
|
||||
+
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_I2C0, "I2C0");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_I2C1, "I2C1");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_I2C2, "I2C2");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_VIDEO_SCALER,
|
||||
+ "VIDEO_SCALER");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_VPU1, "VPU1");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_HDMI, "HDMI");
|
||||
+
|
||||
+ /*
|
||||
+ * Use the old firmware interface for USB power, so that we
|
||||
+ * can turn it on even if the firmware hasn't been updated.
|
||||
+ */
|
||||
+ rpi_init_old_power_domain(rpi_domains, RPI_POWER_DOMAIN_USB,
|
||||
+ RPI_OLD_POWER_DOMAIN_USB, "USB");
|
||||
+
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_VEC, "VEC");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_JPEG, "JPEG");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_H264, "H264");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_V3D, "V3D");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_ISP, "ISP");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_UNICAM0, "UNICAM0");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_UNICAM1, "UNICAM1");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CCP2RX, "CCP2RX");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CSI2, "CSI2");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CPI, "CPI");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_DSI0, "DSI0");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_DSI1, "DSI1");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_TRANSPOSER,
|
||||
+ "TRANSPOSER");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CCP2TX, "CCP2TX");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_CDP, "CDP");
|
||||
+ rpi_init_power_domain(rpi_domains, RPI_POWER_DOMAIN_ARM, "ARM");
|
||||
+
|
||||
+ of_genpd_add_provider_onecell(dev->of_node, &rpi_domains->xlate);
|
||||
+
|
||||
+ platform_set_drvdata(pdev, rpi_domains);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id rpi_power_of_match[] = {
|
||||
+ { .compatible = "raspberrypi,bcm2835-power", },
|
||||
+ {},
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, rpi_power_of_match);
|
||||
+
|
||||
+static struct platform_driver rpi_power_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "raspberrypi-power",
|
||||
+ .of_match_table = rpi_power_of_match,
|
||||
+ },
|
||||
+ .probe = rpi_power_probe,
|
||||
+};
|
||||
+builtin_platform_driver(rpi_power_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Alexander Aring <aar@pengutronix.de>");
|
||||
+MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
|
||||
+MODULE_DESCRIPTION("Raspberry Pi power domain driver");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
diff --git a/include/dt-bindings/power/raspberrypi-power.h b/include/dt-bindings/power/raspberrypi-power.h
|
||||
new file mode 100644
|
||||
index 0000000..b3ff8e0
|
||||
--- /dev/null
|
||||
+++ b/include/dt-bindings/power/raspberrypi-power.h
|
||||
@@ -0,0 +1,41 @@
|
||||
+/*
|
||||
+ * Copyright © 2015 Broadcom
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License version 2 as
|
||||
+ * published by the Free Software Foundation.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _DT_BINDINGS_ARM_BCM2835_RPI_POWER_H
|
||||
+#define _DT_BINDINGS_ARM_BCM2835_RPI_POWER_H
|
||||
+
|
||||
+/* These power domain indices are the firmware interface's indices
|
||||
+ * minus one.
|
||||
+ */
|
||||
+#define RPI_POWER_DOMAIN_I2C0 0
|
||||
+#define RPI_POWER_DOMAIN_I2C1 1
|
||||
+#define RPI_POWER_DOMAIN_I2C2 2
|
||||
+#define RPI_POWER_DOMAIN_VIDEO_SCALER 3
|
||||
+#define RPI_POWER_DOMAIN_VPU1 4
|
||||
+#define RPI_POWER_DOMAIN_HDMI 5
|
||||
+#define RPI_POWER_DOMAIN_USB 6
|
||||
+#define RPI_POWER_DOMAIN_VEC 7
|
||||
+#define RPI_POWER_DOMAIN_JPEG 8
|
||||
+#define RPI_POWER_DOMAIN_H264 9
|
||||
+#define RPI_POWER_DOMAIN_V3D 10
|
||||
+#define RPI_POWER_DOMAIN_ISP 11
|
||||
+#define RPI_POWER_DOMAIN_UNICAM0 12
|
||||
+#define RPI_POWER_DOMAIN_UNICAM1 13
|
||||
+#define RPI_POWER_DOMAIN_CCP2RX 14
|
||||
+#define RPI_POWER_DOMAIN_CSI2 15
|
||||
+#define RPI_POWER_DOMAIN_CPI 16
|
||||
+#define RPI_POWER_DOMAIN_DSI0 17
|
||||
+#define RPI_POWER_DOMAIN_DSI1 18
|
||||
+#define RPI_POWER_DOMAIN_TRANSPOSER 19
|
||||
+#define RPI_POWER_DOMAIN_CCP2TX 20
|
||||
+#define RPI_POWER_DOMAIN_CDP 21
|
||||
+#define RPI_POWER_DOMAIN_ARM 22
|
||||
+
|
||||
+#define RPI_POWER_DOMAIN_COUNT 23
|
||||
+
|
||||
+#endif /* _DT_BINDINGS_ARM_BCM2835_RPI_POWER_H */
|
30
debian/patches/features/arm/rpi/arm-bcm2835-add-the-auxiliary-clocks-to-the-device-t.patch
vendored
Normal file
30
debian/patches/features/arm/rpi/arm-bcm2835-add-the-auxiliary-clocks-to-the-device-t.patch
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Tue, 15 Dec 2015 15:35:59 -0800
|
||||
Subject: [4/4] ARM: bcm2835: Add the auxiliary clocks to the device tree.
|
||||
Origin: https://github.com/anholt/linux/commit/53b6084357a44d7c34044504e1bf149d9156934f
|
||||
|
||||
These will be used for enabling UART1, SPI1, and SPI2.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
arch/arm/boot/dts/bcm283x.dtsi | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
|
||||
index 8a7e727..971e741 100644
|
||||
--- a/arch/arm/boot/dts/bcm283x.dtsi
|
||||
+++ b/arch/arm/boot/dts/bcm283x.dtsi
|
||||
@@ -152,6 +152,13 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ aux: aux@0x7e215000 {
|
||||
+ compatible = "brcm,bcm2835-aux";
|
||||
+ #clock-cells = <1>;
|
||||
+ reg = <0x7e215000 0x8>;
|
||||
+ clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
+ };
|
||||
+
|
||||
sdhci: sdhci@7e300000 {
|
||||
compatible = "brcm,bcm2835-sdhci";
|
||||
reg = <0x7e300000 0x100>;
|
32
debian/patches/features/arm/rpi/arm-bcm2835-define-two-new-packets-from-the-latest-f.patch
vendored
Normal file
32
debian/patches/features/arm/rpi/arm-bcm2835-define-two-new-packets-from-the-latest-f.patch
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Tue, 1 Dec 2015 16:49:12 -0800
|
||||
Subject: [1/3] ARM: bcm2835: Define two new packets from the latest firmware.
|
||||
Origin: https://github.com/anholt/linux/commit/60d56333e869be6ad6926cdba3ba974512b2183b
|
||||
|
||||
These packets give us direct access to the firmware's power management
|
||||
code, as opposed to GET/SET_POWER_STATE packets that only had a couple
|
||||
of domains implemented.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
Reviewed-by: Kevin Hilman <khilman@linaro.org>
|
||||
---
|
||||
include/soc/bcm2835/raspberrypi-firmware.h | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h
|
||||
index c07d74a..3fb3571 100644
|
||||
--- a/include/soc/bcm2835/raspberrypi-firmware.h
|
||||
+++ b/include/soc/bcm2835/raspberrypi-firmware.h
|
||||
@@ -72,10 +72,12 @@ enum rpi_firmware_property_tag {
|
||||
RPI_FIRMWARE_SET_ENABLE_QPU = 0x00030012,
|
||||
RPI_FIRMWARE_GET_DISPMANX_RESOURCE_MEM_HANDLE = 0x00030014,
|
||||
RPI_FIRMWARE_GET_EDID_BLOCK = 0x00030020,
|
||||
+ RPI_FIRMWARE_GET_DOMAIN_STATE = 0x00030030,
|
||||
RPI_FIRMWARE_SET_CLOCK_STATE = 0x00038001,
|
||||
RPI_FIRMWARE_SET_CLOCK_RATE = 0x00038002,
|
||||
RPI_FIRMWARE_SET_VOLTAGE = 0x00038003,
|
||||
RPI_FIRMWARE_SET_TURBO = 0x00038009,
|
||||
+ RPI_FIRMWARE_SET_DOMAIN_STATE = 0x00038030,
|
||||
|
||||
/* Dispmanx TAGS */
|
||||
RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE = 0x00040001,
|
68
debian/patches/features/arm/rpi/arm-bcm2835-move-the-cpu-peripheral-include-out-of-c.patch
vendored
Normal file
68
debian/patches/features/arm/rpi/arm-bcm2835-move-the-cpu-peripheral-include-out-of-c.patch
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Wed, 16 Dec 2015 15:55:12 -0800
|
||||
Subject: [2/4] ARM: bcm2835: Move the CPU/peripheral include out of common RPi
|
||||
DT.
|
||||
Origin: https://github.com/anholt/linux/commit/bafa68c08c33ddde3bc10d2d7e5d3b77b4a6c8ed
|
||||
|
||||
For Raspberry Pi 2, we want to use the same general pin assignment
|
||||
bits, but need to use bcm2836.dtsi for the CPU instead.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
arch/arm/boot/dts/bcm2835-rpi-a-plus.dts | 1 +
|
||||
arch/arm/boot/dts/bcm2835-rpi-b-plus.dts | 1 +
|
||||
arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts | 1 +
|
||||
arch/arm/boot/dts/bcm2835-rpi-b.dts | 1 +
|
||||
arch/arm/boot/dts/bcm2835-rpi.dtsi | 2 --
|
||||
5 files changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/boot/dts/bcm2835-rpi-a-plus.dts b/arch/arm/boot/dts/bcm2835-rpi-a-plus.dts
|
||||
index b2bff43..228614f 100644
|
||||
--- a/arch/arm/boot/dts/bcm2835-rpi-a-plus.dts
|
||||
+++ b/arch/arm/boot/dts/bcm2835-rpi-a-plus.dts
|
||||
@@ -1,4 +1,5 @@
|
||||
/dts-v1/;
|
||||
+#include "bcm2835.dtsi"
|
||||
#include "bcm2835-rpi.dtsi"
|
||||
|
||||
/ {
|
||||
diff --git a/arch/arm/boot/dts/bcm2835-rpi-b-plus.dts b/arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
|
||||
index 668442b..ef54050 100644
|
||||
--- a/arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
|
||||
+++ b/arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
|
||||
@@ -1,4 +1,5 @@
|
||||
/dts-v1/;
|
||||
+#include "bcm2835.dtsi"
|
||||
#include "bcm2835-rpi.dtsi"
|
||||
|
||||
/ {
|
||||
diff --git a/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts b/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts
|
||||
index eab8b591..86f1f2f 100644
|
||||
--- a/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts
|
||||
+++ b/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts
|
||||
@@ -1,4 +1,5 @@
|
||||
/dts-v1/;
|
||||
+#include "bcm2835.dtsi"
|
||||
#include "bcm2835-rpi.dtsi"
|
||||
|
||||
/ {
|
||||
diff --git a/arch/arm/boot/dts/bcm2835-rpi-b.dts b/arch/arm/boot/dts/bcm2835-rpi-b.dts
|
||||
index ff6b2d1..4859e9d 100644
|
||||
--- a/arch/arm/boot/dts/bcm2835-rpi-b.dts
|
||||
+++ b/arch/arm/boot/dts/bcm2835-rpi-b.dts
|
||||
@@ -1,4 +1,5 @@
|
||||
/dts-v1/;
|
||||
+#include "bcm2835.dtsi"
|
||||
#include "bcm2835-rpi.dtsi"
|
||||
|
||||
/ {
|
||||
diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi
|
||||
index 3572f03..3afb9fe 100644
|
||||
--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
|
||||
+++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi
|
||||
@@ -1,5 +1,3 @@
|
||||
-#include "bcm2835.dtsi"
|
||||
-
|
||||
/ {
|
||||
memory {
|
||||
reg = <0 0x10000000>;
|
440
debian/patches/features/arm/rpi/arm-bcm2835-split-the-dt-for-peripherals-from-the-dt.patch
vendored
Normal file
440
debian/patches/features/arm/rpi/arm-bcm2835-split-the-dt-for-peripherals-from-the-dt.patch
vendored
Normal file
|
@ -0,0 +1,440 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Wed, 16 Dec 2015 13:24:40 -0800
|
||||
Subject: [1/4] ARM: bcm2835: Split the DT for peripherals from the DT for the
|
||||
CPU
|
||||
Origin: https://github.com/anholt/linux/commit/482626063d446eac1809e025a79ad0a7d45bc22d
|
||||
|
||||
The set of peripherals remained constant across bcm2835 (Raspberry Pi
|
||||
1) and bcm2836 (Raspberry Pi 2), but the CPU was swapped out. Split
|
||||
the files so that we can include just peripheral setup in 2836.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
arch/arm/boot/dts/bcm2835.dtsi | 194 +-------------------------------------
|
||||
arch/arm/boot/dts/bcm283x.dtsi | 205 +++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 206 insertions(+), 193 deletions(-)
|
||||
create mode 100644 arch/arm/boot/dts/bcm283x.dtsi
|
||||
|
||||
diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi
|
||||
index aef64de..b83b326 100644
|
||||
--- a/arch/arm/boot/dts/bcm2835.dtsi
|
||||
+++ b/arch/arm/boot/dts/bcm2835.dtsi
|
||||
@@ -1,206 +1,14 @@
|
||||
-#include <dt-bindings/pinctrl/bcm2835.h>
|
||||
-#include <dt-bindings/clock/bcm2835.h>
|
||||
-#include "skeleton.dtsi"
|
||||
+#include "bcm283x.dtsi"
|
||||
|
||||
/ {
|
||||
compatible = "brcm,bcm2835";
|
||||
- model = "BCM2835";
|
||||
- interrupt-parent = <&intc>;
|
||||
-
|
||||
- chosen {
|
||||
- bootargs = "earlyprintk console=ttyAMA0";
|
||||
- };
|
||||
|
||||
soc {
|
||||
- compatible = "simple-bus";
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <1>;
|
||||
ranges = <0x7e000000 0x20000000 0x02000000>;
|
||||
dma-ranges = <0x40000000 0x00000000 0x20000000>;
|
||||
|
||||
- timer@7e003000 {
|
||||
- compatible = "brcm,bcm2835-system-timer";
|
||||
- reg = <0x7e003000 0x1000>;
|
||||
- interrupts = <1 0>, <1 1>, <1 2>, <1 3>;
|
||||
- /* This could be a reference to BCM2835_CLOCK_TIMER,
|
||||
- * but we don't have the driver using the common clock
|
||||
- * support yet.
|
||||
- */
|
||||
- clock-frequency = <1000000>;
|
||||
- };
|
||||
-
|
||||
- dma: dma@7e007000 {
|
||||
- compatible = "brcm,bcm2835-dma";
|
||||
- reg = <0x7e007000 0xf00>;
|
||||
- interrupts = <1 16>,
|
||||
- <1 17>,
|
||||
- <1 18>,
|
||||
- <1 19>,
|
||||
- <1 20>,
|
||||
- <1 21>,
|
||||
- <1 22>,
|
||||
- <1 23>,
|
||||
- <1 24>,
|
||||
- <1 25>,
|
||||
- <1 26>,
|
||||
- <1 27>,
|
||||
- <1 28>;
|
||||
-
|
||||
- #dma-cells = <1>;
|
||||
- brcm,dma-channel-mask = <0x7f35>;
|
||||
- };
|
||||
-
|
||||
- intc: interrupt-controller@7e00b200 {
|
||||
- compatible = "brcm,bcm2835-armctrl-ic";
|
||||
- reg = <0x7e00b200 0x200>;
|
||||
- interrupt-controller;
|
||||
- #interrupt-cells = <2>;
|
||||
- };
|
||||
-
|
||||
- watchdog@7e100000 {
|
||||
- compatible = "brcm,bcm2835-pm-wdt";
|
||||
- reg = <0x7e100000 0x28>;
|
||||
- };
|
||||
-
|
||||
- clocks: cprman@7e101000 {
|
||||
- compatible = "brcm,bcm2835-cprman";
|
||||
- #clock-cells = <1>;
|
||||
- reg = <0x7e101000 0x2000>;
|
||||
-
|
||||
- /* CPRMAN derives everything from the platform's
|
||||
- * oscillator.
|
||||
- */
|
||||
- clocks = <&clk_osc>;
|
||||
- };
|
||||
-
|
||||
- rng@7e104000 {
|
||||
- compatible = "brcm,bcm2835-rng";
|
||||
- reg = <0x7e104000 0x10>;
|
||||
- };
|
||||
-
|
||||
- mailbox: mailbox@7e00b800 {
|
||||
- compatible = "brcm,bcm2835-mbox";
|
||||
- reg = <0x7e00b880 0x40>;
|
||||
- interrupts = <0 1>;
|
||||
- #mbox-cells = <0>;
|
||||
- };
|
||||
-
|
||||
- gpio: gpio@7e200000 {
|
||||
- compatible = "brcm,bcm2835-gpio";
|
||||
- reg = <0x7e200000 0xb4>;
|
||||
- /*
|
||||
- * The GPIO IP block is designed for 3 banks of GPIOs.
|
||||
- * Each bank has a GPIO interrupt for itself.
|
||||
- * There is an overall "any bank" interrupt.
|
||||
- * In order, these are GIC interrupts 17, 18, 19, 20.
|
||||
- * Since the BCM2835 only has 2 banks, the 2nd bank
|
||||
- * interrupt output appears to be mirrored onto the
|
||||
- * 3rd bank's interrupt signal.
|
||||
- * So, a bank0 interrupt shows up on 17, 20, and
|
||||
- * a bank1 interrupt shows up on 18, 19, 20!
|
||||
- */
|
||||
- interrupts = <2 17>, <2 18>, <2 19>, <2 20>;
|
||||
-
|
||||
- gpio-controller;
|
||||
- #gpio-cells = <2>;
|
||||
-
|
||||
- interrupt-controller;
|
||||
- #interrupt-cells = <2>;
|
||||
- };
|
||||
-
|
||||
- uart0: uart@7e201000 {
|
||||
- compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell";
|
||||
- reg = <0x7e201000 0x1000>;
|
||||
- interrupts = <2 25>;
|
||||
- clocks = <&clocks BCM2835_CLOCK_UART>,
|
||||
- <&clocks BCM2835_CLOCK_VPU>;
|
||||
- clock-names = "uartclk", "apb_pclk";
|
||||
- arm,primecell-periphid = <0x00241011>;
|
||||
- };
|
||||
-
|
||||
- i2s: i2s@7e203000 {
|
||||
- compatible = "brcm,bcm2835-i2s";
|
||||
- reg = <0x7e203000 0x20>,
|
||||
- <0x7e101098 0x02>;
|
||||
-
|
||||
- dmas = <&dma 2>,
|
||||
- <&dma 3>;
|
||||
- dma-names = "tx", "rx";
|
||||
- status = "disabled";
|
||||
- };
|
||||
-
|
||||
- spi: spi@7e204000 {
|
||||
- compatible = "brcm,bcm2835-spi";
|
||||
- reg = <0x7e204000 0x1000>;
|
||||
- interrupts = <2 22>;
|
||||
- clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
- status = "disabled";
|
||||
- };
|
||||
-
|
||||
- i2c0: i2c@7e205000 {
|
||||
- compatible = "brcm,bcm2835-i2c";
|
||||
- reg = <0x7e205000 0x1000>;
|
||||
- interrupts = <2 21>;
|
||||
- clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
- status = "disabled";
|
||||
- };
|
||||
-
|
||||
- sdhci: sdhci@7e300000 {
|
||||
- compatible = "brcm,bcm2835-sdhci";
|
||||
- reg = <0x7e300000 0x100>;
|
||||
- interrupts = <2 30>;
|
||||
- clocks = <&clocks BCM2835_CLOCK_EMMC>;
|
||||
- status = "disabled";
|
||||
- };
|
||||
-
|
||||
- i2c1: i2c@7e804000 {
|
||||
- compatible = "brcm,bcm2835-i2c";
|
||||
- reg = <0x7e804000 0x1000>;
|
||||
- interrupts = <2 21>;
|
||||
- clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
- status = "disabled";
|
||||
- };
|
||||
-
|
||||
- i2c2: i2c@7e805000 {
|
||||
- compatible = "brcm,bcm2835-i2c";
|
||||
- reg = <0x7e805000 0x1000>;
|
||||
- interrupts = <2 21>;
|
||||
- clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
- status = "disabled";
|
||||
- };
|
||||
-
|
||||
- usb@7e980000 {
|
||||
- compatible = "brcm,bcm2835-usb";
|
||||
- reg = <0x7e980000 0x10000>;
|
||||
- interrupts = <1 9>;
|
||||
- };
|
||||
-
|
||||
arm-pmu {
|
||||
compatible = "arm,arm1176-pmu";
|
||||
};
|
||||
};
|
||||
-
|
||||
- clocks {
|
||||
- compatible = "simple-bus";
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
-
|
||||
- /* The oscillator is the root of the clock tree. */
|
||||
- clk_osc: clock@3 {
|
||||
- compatible = "fixed-clock";
|
||||
- reg = <3>;
|
||||
- #clock-cells = <0>;
|
||||
- clock-output-names = "osc";
|
||||
- clock-frequency = <19200000>;
|
||||
- };
|
||||
-
|
||||
- };
|
||||
};
|
||||
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
|
||||
new file mode 100644
|
||||
index 0000000..8a7e727
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/bcm283x.dtsi
|
||||
@@ -0,0 +1,205 @@
|
||||
+#include <dt-bindings/pinctrl/bcm2835.h>
|
||||
+#include <dt-bindings/clock/bcm2835.h>
|
||||
+#include "skeleton.dtsi"
|
||||
+
|
||||
+/* This include file covers the common peripherals and configuration between
|
||||
+ * bcm2835 and bcm2836 implementations, leaving the CPU configuration to
|
||||
+ * bcm2835.dtsi and bcm2836.dtsi.
|
||||
+ */
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "brcm,bcm2835";
|
||||
+ model = "BCM2835";
|
||||
+ interrupt-parent = <&intc>;
|
||||
+
|
||||
+ chosen {
|
||||
+ bootargs = "earlyprintk console=ttyAMA0";
|
||||
+ };
|
||||
+
|
||||
+ soc {
|
||||
+ compatible = "simple-bus";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <1>;
|
||||
+
|
||||
+ timer@7e003000 {
|
||||
+ compatible = "brcm,bcm2835-system-timer";
|
||||
+ reg = <0x7e003000 0x1000>;
|
||||
+ interrupts = <1 0>, <1 1>, <1 2>, <1 3>;
|
||||
+ /* This could be a reference to BCM2835_CLOCK_TIMER,
|
||||
+ * but we don't have the driver using the common clock
|
||||
+ * support yet.
|
||||
+ */
|
||||
+ clock-frequency = <1000000>;
|
||||
+ };
|
||||
+
|
||||
+ dma: dma@7e007000 {
|
||||
+ compatible = "brcm,bcm2835-dma";
|
||||
+ reg = <0x7e007000 0xf00>;
|
||||
+ interrupts = <1 16>,
|
||||
+ <1 17>,
|
||||
+ <1 18>,
|
||||
+ <1 19>,
|
||||
+ <1 20>,
|
||||
+ <1 21>,
|
||||
+ <1 22>,
|
||||
+ <1 23>,
|
||||
+ <1 24>,
|
||||
+ <1 25>,
|
||||
+ <1 26>,
|
||||
+ <1 27>,
|
||||
+ <1 28>;
|
||||
+
|
||||
+ #dma-cells = <1>;
|
||||
+ brcm,dma-channel-mask = <0x7f35>;
|
||||
+ };
|
||||
+
|
||||
+ intc: interrupt-controller@7e00b200 {
|
||||
+ compatible = "brcm,bcm2835-armctrl-ic";
|
||||
+ reg = <0x7e00b200 0x200>;
|
||||
+ interrupt-controller;
|
||||
+ #interrupt-cells = <2>;
|
||||
+ };
|
||||
+
|
||||
+ watchdog@7e100000 {
|
||||
+ compatible = "brcm,bcm2835-pm-wdt";
|
||||
+ reg = <0x7e100000 0x28>;
|
||||
+ };
|
||||
+
|
||||
+ clocks: cprman@7e101000 {
|
||||
+ compatible = "brcm,bcm2835-cprman";
|
||||
+ #clock-cells = <1>;
|
||||
+ reg = <0x7e101000 0x2000>;
|
||||
+
|
||||
+ /* CPRMAN derives everything from the platform's
|
||||
+ * oscillator.
|
||||
+ */
|
||||
+ clocks = <&clk_osc>;
|
||||
+ };
|
||||
+
|
||||
+ rng@7e104000 {
|
||||
+ compatible = "brcm,bcm2835-rng";
|
||||
+ reg = <0x7e104000 0x10>;
|
||||
+ };
|
||||
+
|
||||
+ mailbox: mailbox@7e00b800 {
|
||||
+ compatible = "brcm,bcm2835-mbox";
|
||||
+ reg = <0x7e00b880 0x40>;
|
||||
+ interrupts = <0 1>;
|
||||
+ #mbox-cells = <0>;
|
||||
+ };
|
||||
+
|
||||
+ gpio: gpio@7e200000 {
|
||||
+ compatible = "brcm,bcm2835-gpio";
|
||||
+ reg = <0x7e200000 0xb4>;
|
||||
+ /*
|
||||
+ * The GPIO IP block is designed for 3 banks of GPIOs.
|
||||
+ * Each bank has a GPIO interrupt for itself.
|
||||
+ * There is an overall "any bank" interrupt.
|
||||
+ * In order, these are GIC interrupts 17, 18, 19, 20.
|
||||
+ * Since the BCM2835 only has 2 banks, the 2nd bank
|
||||
+ * interrupt output appears to be mirrored onto the
|
||||
+ * 3rd bank's interrupt signal.
|
||||
+ * So, a bank0 interrupt shows up on 17, 20, and
|
||||
+ * a bank1 interrupt shows up on 18, 19, 20!
|
||||
+ */
|
||||
+ interrupts = <2 17>, <2 18>, <2 19>, <2 20>;
|
||||
+
|
||||
+ gpio-controller;
|
||||
+ #gpio-cells = <2>;
|
||||
+
|
||||
+ interrupt-controller;
|
||||
+ #interrupt-cells = <2>;
|
||||
+ };
|
||||
+
|
||||
+ uart0: uart@7e201000 {
|
||||
+ compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell";
|
||||
+ reg = <0x7e201000 0x1000>;
|
||||
+ interrupts = <2 25>;
|
||||
+ clocks = <&clocks BCM2835_CLOCK_UART>,
|
||||
+ <&clocks BCM2835_CLOCK_VPU>;
|
||||
+ clock-names = "uartclk", "apb_pclk";
|
||||
+ arm,primecell-periphid = <0x00241011>;
|
||||
+ };
|
||||
+
|
||||
+ i2s: i2s@7e203000 {
|
||||
+ compatible = "brcm,bcm2835-i2s";
|
||||
+ reg = <0x7e203000 0x20>,
|
||||
+ <0x7e101098 0x02>;
|
||||
+
|
||||
+ dmas = <&dma 2>,
|
||||
+ <&dma 3>;
|
||||
+ dma-names = "tx", "rx";
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ spi: spi@7e204000 {
|
||||
+ compatible = "brcm,bcm2835-spi";
|
||||
+ reg = <0x7e204000 0x1000>;
|
||||
+ interrupts = <2 22>;
|
||||
+ clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ i2c0: i2c@7e205000 {
|
||||
+ compatible = "brcm,bcm2835-i2c";
|
||||
+ reg = <0x7e205000 0x1000>;
|
||||
+ interrupts = <2 21>;
|
||||
+ clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ sdhci: sdhci@7e300000 {
|
||||
+ compatible = "brcm,bcm2835-sdhci";
|
||||
+ reg = <0x7e300000 0x100>;
|
||||
+ interrupts = <2 30>;
|
||||
+ clocks = <&clocks BCM2835_CLOCK_EMMC>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ i2c1: i2c@7e804000 {
|
||||
+ compatible = "brcm,bcm2835-i2c";
|
||||
+ reg = <0x7e804000 0x1000>;
|
||||
+ interrupts = <2 21>;
|
||||
+ clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ i2c2: i2c@7e805000 {
|
||||
+ compatible = "brcm,bcm2835-i2c";
|
||||
+ reg = <0x7e805000 0x1000>;
|
||||
+ interrupts = <2 21>;
|
||||
+ clocks = <&clocks BCM2835_CLOCK_VPU>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ usb@7e980000 {
|
||||
+ compatible = "brcm,bcm2835-usb";
|
||||
+ reg = <0x7e980000 0x10000>;
|
||||
+ interrupts = <1 9>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ clocks {
|
||||
+ compatible = "simple-bus";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ /* The oscillator is the root of the clock tree. */
|
||||
+ clk_osc: clock@3 {
|
||||
+ compatible = "fixed-clock";
|
||||
+ reg = <3>;
|
||||
+ #clock-cells = <0>;
|
||||
+ clock-output-names = "osc";
|
||||
+ clock-frequency = <19200000>;
|
||||
+ };
|
||||
+
|
||||
+ };
|
||||
+};
|
58
debian/patches/features/arm/rpi/drm-create-a-driver-hook-for-allocating-gem-object-s.patch
vendored
Normal file
58
debian/patches/features/arm/rpi/drm-create-a-driver-hook-for-allocating-gem-object-s.patch
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Mon, 30 Nov 2015 10:55:13 -0800
|
||||
Subject: drm: Create a driver hook for allocating GEM object structs.
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=10028c5ab107d3765c7fc282b6c45324d1602155
|
||||
|
||||
The CMA helpers had no way for a driver to extend the struct with its
|
||||
own fields. Since the CMA helpers are mostly "Allocate a
|
||||
drm_gem_cma_object, then fill in a few fields", it's hard to write as
|
||||
pure helpers without passing in a driver callback for the allocate
|
||||
step.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
|
||||
---
|
||||
drivers/gpu/drm/drm_gem_cma_helper.c | 10 ++++++----
|
||||
include/drm/drmP.h | 7 +++++++
|
||||
2 files changed, 13 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
|
||||
index e109b49..0f7b00ba 100644
|
||||
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
|
||||
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
|
||||
@@ -59,11 +59,13 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)
|
||||
struct drm_gem_object *gem_obj;
|
||||
int ret;
|
||||
|
||||
- cma_obj = kzalloc(sizeof(*cma_obj), GFP_KERNEL);
|
||||
- if (!cma_obj)
|
||||
+ if (drm->driver->gem_create_object)
|
||||
+ gem_obj = drm->driver->gem_create_object(drm, size);
|
||||
+ else
|
||||
+ gem_obj = kzalloc(sizeof(*cma_obj), GFP_KERNEL);
|
||||
+ if (!gem_obj)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
-
|
||||
- gem_obj = &cma_obj->base;
|
||||
+ cma_obj = container_of(gem_obj, struct drm_gem_cma_object, base);
|
||||
|
||||
ret = drm_gem_object_init(drm, gem_obj, size);
|
||||
if (ret)
|
||||
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
|
||||
index 0b921ae..22ff162 100644
|
||||
--- a/include/drm/drmP.h
|
||||
+++ b/include/drm/drmP.h
|
||||
@@ -580,6 +580,13 @@ struct drm_driver {
|
||||
int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
|
||||
void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
|
||||
|
||||
+ /**
|
||||
+ * Hook for allocating the GEM object struct, for use by core
|
||||
+ * helpers.
|
||||
+ */
|
||||
+ struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
|
||||
+ size_t size);
|
||||
+
|
||||
/* prime: */
|
||||
/* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
|
||||
int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
|
|
@ -0,0 +1,509 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Fri, 9 Oct 2015 20:25:07 -0700
|
||||
Subject: [01/16] drm/vc4: Add a BO cache.
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=c826a6e1064419f78855463cf29ce9e8b9d25bf4
|
||||
|
||||
We need to allocate new BOs in the kernel as part of each frame, but
|
||||
the CMA allocator is way too slow for that. As an optimization, keep
|
||||
track of recently-freed BOs and reuse them, with a 1 second timeout to
|
||||
fully free them back to the system.
|
||||
|
||||
This improves 3D performance by about 15%.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_bo.c | 336 +++++++++++++++++++++++++++++++++++++-
|
||||
drivers/gpu/drm/vc4/vc4_debugfs.c | 1 +
|
||||
drivers/gpu/drm/vc4/vc4_drv.c | 6 +-
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 49 +++++-
|
||||
4 files changed, 384 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
|
||||
index ab9f510..18faa5b 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_bo.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
|
||||
@@ -12,19 +12,229 @@
|
||||
* access to system memory with no MMU in between. To support it, we
|
||||
* use the GEM CMA helper functions to allocate contiguous ranges of
|
||||
* physical memory for our BOs.
|
||||
+ *
|
||||
+ * Since the CMA allocator is very slow, we keep a cache of recently
|
||||
+ * freed BOs around so that the kernel's allocation of objects for 3D
|
||||
+ * rendering can return quickly.
|
||||
*/
|
||||
|
||||
#include "vc4_drv.h"
|
||||
|
||||
-struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size)
|
||||
+static void vc4_bo_stats_dump(struct vc4_dev *vc4)
|
||||
+{
|
||||
+ DRM_INFO("num bos allocated: %d\n",
|
||||
+ vc4->bo_stats.num_allocated);
|
||||
+ DRM_INFO("size bos allocated: %dkb\n",
|
||||
+ vc4->bo_stats.size_allocated / 1024);
|
||||
+ DRM_INFO("num bos used: %d\n",
|
||||
+ vc4->bo_stats.num_allocated - vc4->bo_stats.num_cached);
|
||||
+ DRM_INFO("size bos used: %dkb\n",
|
||||
+ (vc4->bo_stats.size_allocated -
|
||||
+ vc4->bo_stats.size_cached) / 1024);
|
||||
+ DRM_INFO("num bos cached: %d\n",
|
||||
+ vc4->bo_stats.num_cached);
|
||||
+ DRM_INFO("size bos cached: %dkb\n",
|
||||
+ vc4->bo_stats.size_cached / 1024);
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_DEBUG_FS
|
||||
+int vc4_bo_stats_debugfs(struct seq_file *m, void *unused)
|
||||
+{
|
||||
+ struct drm_info_node *node = (struct drm_info_node *)m->private;
|
||||
+ struct drm_device *dev = node->minor->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ struct vc4_bo_stats stats;
|
||||
+
|
||||
+ /* Take a snapshot of the current stats with the lock held. */
|
||||
+ mutex_lock(&vc4->bo_lock);
|
||||
+ stats = vc4->bo_stats;
|
||||
+ mutex_unlock(&vc4->bo_lock);
|
||||
+
|
||||
+ seq_printf(m, "num bos allocated: %d\n",
|
||||
+ stats.num_allocated);
|
||||
+ seq_printf(m, "size bos allocated: %dkb\n",
|
||||
+ stats.size_allocated / 1024);
|
||||
+ seq_printf(m, "num bos used: %d\n",
|
||||
+ stats.num_allocated - stats.num_cached);
|
||||
+ seq_printf(m, "size bos used: %dkb\n",
|
||||
+ (stats.size_allocated - stats.size_cached) / 1024);
|
||||
+ seq_printf(m, "num bos cached: %d\n",
|
||||
+ stats.num_cached);
|
||||
+ seq_printf(m, "size bos cached: %dkb\n",
|
||||
+ stats.size_cached / 1024);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static uint32_t bo_page_index(size_t size)
|
||||
+{
|
||||
+ return (size / PAGE_SIZE) - 1;
|
||||
+}
|
||||
+
|
||||
+/* Must be called with bo_lock held. */
|
||||
+static void vc4_bo_destroy(struct vc4_bo *bo)
|
||||
{
|
||||
+ struct drm_gem_object *obj = &bo->base.base;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(obj->dev);
|
||||
+
|
||||
+ vc4->bo_stats.num_allocated--;
|
||||
+ vc4->bo_stats.size_allocated -= obj->size;
|
||||
+ drm_gem_cma_free_object(obj);
|
||||
+}
|
||||
+
|
||||
+/* Must be called with bo_lock held. */
|
||||
+static void vc4_bo_remove_from_cache(struct vc4_bo *bo)
|
||||
+{
|
||||
+ struct drm_gem_object *obj = &bo->base.base;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(obj->dev);
|
||||
+
|
||||
+ vc4->bo_stats.num_cached--;
|
||||
+ vc4->bo_stats.size_cached -= obj->size;
|
||||
+
|
||||
+ list_del(&bo->unref_head);
|
||||
+ list_del(&bo->size_head);
|
||||
+}
|
||||
+
|
||||
+static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev,
|
||||
+ size_t size)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ uint32_t page_index = bo_page_index(size);
|
||||
+
|
||||
+ if (vc4->bo_cache.size_list_size <= page_index) {
|
||||
+ uint32_t new_size = max(vc4->bo_cache.size_list_size * 2,
|
||||
+ page_index + 1);
|
||||
+ struct list_head *new_list;
|
||||
+ uint32_t i;
|
||||
+
|
||||
+ new_list = kmalloc_array(new_size, sizeof(struct list_head),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!new_list)
|
||||
+ return NULL;
|
||||
+
|
||||
+ /* Rebase the old cached BO lists to their new list
|
||||
+ * head locations.
|
||||
+ */
|
||||
+ for (i = 0; i < vc4->bo_cache.size_list_size; i++) {
|
||||
+ struct list_head *old_list =
|
||||
+ &vc4->bo_cache.size_list[i];
|
||||
+
|
||||
+ if (list_empty(old_list))
|
||||
+ INIT_LIST_HEAD(&new_list[i]);
|
||||
+ else
|
||||
+ list_replace(old_list, &new_list[i]);
|
||||
+ }
|
||||
+ /* And initialize the brand new BO list heads. */
|
||||
+ for (i = vc4->bo_cache.size_list_size; i < new_size; i++)
|
||||
+ INIT_LIST_HEAD(&new_list[i]);
|
||||
+
|
||||
+ kfree(vc4->bo_cache.size_list);
|
||||
+ vc4->bo_cache.size_list = new_list;
|
||||
+ vc4->bo_cache.size_list_size = new_size;
|
||||
+ }
|
||||
+
|
||||
+ return &vc4->bo_cache.size_list[page_index];
|
||||
+}
|
||||
+
|
||||
+void vc4_bo_cache_purge(struct drm_device *dev)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+
|
||||
+ mutex_lock(&vc4->bo_lock);
|
||||
+ while (!list_empty(&vc4->bo_cache.time_list)) {
|
||||
+ struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
|
||||
+ struct vc4_bo, unref_head);
|
||||
+ vc4_bo_remove_from_cache(bo);
|
||||
+ vc4_bo_destroy(bo);
|
||||
+ }
|
||||
+ mutex_unlock(&vc4->bo_lock);
|
||||
+}
|
||||
+
|
||||
+static struct vc4_bo *vc4_bo_get_from_cache(struct drm_device *dev,
|
||||
+ uint32_t size)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ uint32_t page_index = bo_page_index(size);
|
||||
+ struct vc4_bo *bo = NULL;
|
||||
+
|
||||
+ size = roundup(size, PAGE_SIZE);
|
||||
+
|
||||
+ mutex_lock(&vc4->bo_lock);
|
||||
+ if (page_index >= vc4->bo_cache.size_list_size)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (list_empty(&vc4->bo_cache.size_list[page_index]))
|
||||
+ goto out;
|
||||
+
|
||||
+ bo = list_first_entry(&vc4->bo_cache.size_list[page_index],
|
||||
+ struct vc4_bo, size_head);
|
||||
+ vc4_bo_remove_from_cache(bo);
|
||||
+ kref_init(&bo->base.base.refcount);
|
||||
+
|
||||
+out:
|
||||
+ mutex_unlock(&vc4->bo_lock);
|
||||
+ return bo;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * vc4_gem_create_object - Implementation of driver->gem_create_object.
|
||||
+ *
|
||||
+ * This lets the CMA helpers allocate object structs for us, and keep
|
||||
+ * our BO stats correct.
|
||||
+ */
|
||||
+struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ struct vc4_bo *bo;
|
||||
+
|
||||
+ bo = kzalloc(sizeof(*bo), GFP_KERNEL);
|
||||
+ if (!bo)
|
||||
+ return ERR_PTR(-ENOMEM);
|
||||
+
|
||||
+ mutex_lock(&vc4->bo_lock);
|
||||
+ vc4->bo_stats.num_allocated++;
|
||||
+ vc4->bo_stats.size_allocated += size;
|
||||
+ mutex_unlock(&vc4->bo_lock);
|
||||
+
|
||||
+ return &bo->base.base;
|
||||
+}
|
||||
+
|
||||
+struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
|
||||
+ bool from_cache)
|
||||
+{
|
||||
+ size_t size = roundup(unaligned_size, PAGE_SIZE);
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
struct drm_gem_cma_object *cma_obj;
|
||||
|
||||
- cma_obj = drm_gem_cma_create(dev, size);
|
||||
- if (IS_ERR(cma_obj))
|
||||
+ if (size == 0)
|
||||
return NULL;
|
||||
- else
|
||||
- return to_vc4_bo(&cma_obj->base);
|
||||
+
|
||||
+ /* First, try to get a vc4_bo from the kernel BO cache. */
|
||||
+ if (from_cache) {
|
||||
+ struct vc4_bo *bo = vc4_bo_get_from_cache(dev, size);
|
||||
+
|
||||
+ if (bo)
|
||||
+ return bo;
|
||||
+ }
|
||||
+
|
||||
+ cma_obj = drm_gem_cma_create(dev, size);
|
||||
+ if (IS_ERR(cma_obj)) {
|
||||
+ /*
|
||||
+ * If we've run out of CMA memory, kill the cache of
|
||||
+ * CMA allocations we've got laying around and try again.
|
||||
+ */
|
||||
+ vc4_bo_cache_purge(dev);
|
||||
+
|
||||
+ cma_obj = drm_gem_cma_create(dev, size);
|
||||
+ if (IS_ERR(cma_obj)) {
|
||||
+ DRM_ERROR("Failed to allocate from CMA:\n");
|
||||
+ vc4_bo_stats_dump(vc4);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return to_vc4_bo(&cma_obj->base);
|
||||
}
|
||||
|
||||
int vc4_dumb_create(struct drm_file *file_priv,
|
||||
@@ -41,7 +251,7 @@ int vc4_dumb_create(struct drm_file *file_priv,
|
||||
if (args->size < args->pitch * args->height)
|
||||
args->size = args->pitch * args->height;
|
||||
|
||||
- bo = vc4_bo_create(dev, roundup(args->size, PAGE_SIZE));
|
||||
+ bo = vc4_bo_create(dev, args->size, false);
|
||||
if (!bo)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -50,3 +260,117 @@ int vc4_dumb_create(struct drm_file *file_priv,
|
||||
|
||||
return ret;
|
||||
}
|
||||
+
|
||||
+/* Must be called with bo_lock held. */
|
||||
+static void vc4_bo_cache_free_old(struct drm_device *dev)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ unsigned long expire_time = jiffies - msecs_to_jiffies(1000);
|
||||
+
|
||||
+ while (!list_empty(&vc4->bo_cache.time_list)) {
|
||||
+ struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
|
||||
+ struct vc4_bo, unref_head);
|
||||
+ if (time_before(expire_time, bo->free_time)) {
|
||||
+ mod_timer(&vc4->bo_cache.time_timer,
|
||||
+ round_jiffies_up(jiffies +
|
||||
+ msecs_to_jiffies(1000)));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ vc4_bo_remove_from_cache(bo);
|
||||
+ vc4_bo_destroy(bo);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* Called on the last userspace/kernel unreference of the BO. Returns
|
||||
+ * it to the BO cache if possible, otherwise frees it.
|
||||
+ *
|
||||
+ * Note that this is called with the struct_mutex held.
|
||||
+ */
|
||||
+void vc4_free_object(struct drm_gem_object *gem_bo)
|
||||
+{
|
||||
+ struct drm_device *dev = gem_bo->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ struct vc4_bo *bo = to_vc4_bo(gem_bo);
|
||||
+ struct list_head *cache_list;
|
||||
+
|
||||
+ mutex_lock(&vc4->bo_lock);
|
||||
+ /* If the object references someone else's memory, we can't cache it.
|
||||
+ */
|
||||
+ if (gem_bo->import_attach) {
|
||||
+ vc4_bo_destroy(bo);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ /* Don't cache if it was publicly named. */
|
||||
+ if (gem_bo->name) {
|
||||
+ vc4_bo_destroy(bo);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ cache_list = vc4_get_cache_list_for_size(dev, gem_bo->size);
|
||||
+ if (!cache_list) {
|
||||
+ vc4_bo_destroy(bo);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ bo->free_time = jiffies;
|
||||
+ list_add(&bo->size_head, cache_list);
|
||||
+ list_add(&bo->unref_head, &vc4->bo_cache.time_list);
|
||||
+
|
||||
+ vc4->bo_stats.num_cached++;
|
||||
+ vc4->bo_stats.size_cached += gem_bo->size;
|
||||
+
|
||||
+ vc4_bo_cache_free_old(dev);
|
||||
+
|
||||
+out:
|
||||
+ mutex_unlock(&vc4->bo_lock);
|
||||
+}
|
||||
+
|
||||
+static void vc4_bo_cache_time_work(struct work_struct *work)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 =
|
||||
+ container_of(work, struct vc4_dev, bo_cache.time_work);
|
||||
+ struct drm_device *dev = vc4->dev;
|
||||
+
|
||||
+ mutex_lock(&vc4->bo_lock);
|
||||
+ vc4_bo_cache_free_old(dev);
|
||||
+ mutex_unlock(&vc4->bo_lock);
|
||||
+}
|
||||
+
|
||||
+static void vc4_bo_cache_time_timer(unsigned long data)
|
||||
+{
|
||||
+ struct drm_device *dev = (struct drm_device *)data;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+
|
||||
+ schedule_work(&vc4->bo_cache.time_work);
|
||||
+}
|
||||
+
|
||||
+void vc4_bo_cache_init(struct drm_device *dev)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+
|
||||
+ mutex_init(&vc4->bo_lock);
|
||||
+
|
||||
+ INIT_LIST_HEAD(&vc4->bo_cache.time_list);
|
||||
+
|
||||
+ INIT_WORK(&vc4->bo_cache.time_work, vc4_bo_cache_time_work);
|
||||
+ setup_timer(&vc4->bo_cache.time_timer,
|
||||
+ vc4_bo_cache_time_timer,
|
||||
+ (unsigned long)dev);
|
||||
+}
|
||||
+
|
||||
+void vc4_bo_cache_destroy(struct drm_device *dev)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+
|
||||
+ del_timer(&vc4->bo_cache.time_timer);
|
||||
+ cancel_work_sync(&vc4->bo_cache.time_work);
|
||||
+
|
||||
+ vc4_bo_cache_purge(dev);
|
||||
+
|
||||
+ if (vc4->bo_stats.num_allocated) {
|
||||
+ DRM_ERROR("Destroying BO cache while BOs still allocated:\n");
|
||||
+ vc4_bo_stats_dump(vc4);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_debugfs.c b/drivers/gpu/drm/vc4/vc4_debugfs.c
|
||||
index 4297b0a5..6bcf96e 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_debugfs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_debugfs.c
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "vc4_regs.h"
|
||||
|
||||
static const struct drm_info_list vc4_debugfs_list[] = {
|
||||
+ {"bo_stats", vc4_bo_stats_debugfs, 0},
|
||||
{"hdmi_regs", vc4_hdmi_debugfs_regs, 0},
|
||||
{"hvs_regs", vc4_hvs_debugfs_regs, 0},
|
||||
{"crtc0_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)0},
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
index 6e73060..da041fa 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
@@ -92,7 +92,8 @@ static struct drm_driver vc4_drm_driver = {
|
||||
.debugfs_cleanup = vc4_debugfs_cleanup,
|
||||
#endif
|
||||
|
||||
- .gem_free_object = drm_gem_cma_free_object,
|
||||
+ .gem_create_object = vc4_create_object,
|
||||
+ .gem_free_object = vc4_free_object,
|
||||
.gem_vm_ops = &drm_gem_cma_vm_ops,
|
||||
|
||||
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
||||
@@ -170,6 +171,8 @@ static int vc4_drm_bind(struct device *dev)
|
||||
|
||||
drm_dev_set_unique(drm, dev_name(dev));
|
||||
|
||||
+ vc4_bo_cache_init(drm);
|
||||
+
|
||||
drm_mode_config_init(drm);
|
||||
if (ret)
|
||||
goto unref;
|
||||
@@ -202,6 +205,7 @@ unbind_all:
|
||||
component_unbind_all(dev, drm);
|
||||
unref:
|
||||
drm_dev_unref(drm);
|
||||
+ vc4_bo_cache_destroy(drm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
index fd8319f..39a1ff5 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -17,6 +17,37 @@ struct vc4_dev {
|
||||
struct vc4_crtc *crtc[3];
|
||||
|
||||
struct drm_fbdev_cma *fbdev;
|
||||
+
|
||||
+ /* The kernel-space BO cache. Tracks buffers that have been
|
||||
+ * unreferenced by all other users (refcounts of 0!) but not
|
||||
+ * yet freed, so we can do cheap allocations.
|
||||
+ */
|
||||
+ struct vc4_bo_cache {
|
||||
+ /* Array of list heads for entries in the BO cache,
|
||||
+ * based on number of pages, so we can do O(1) lookups
|
||||
+ * in the cache when allocating.
|
||||
+ */
|
||||
+ struct list_head *size_list;
|
||||
+ uint32_t size_list_size;
|
||||
+
|
||||
+ /* List of all BOs in the cache, ordered by age, so we
|
||||
+ * can do O(1) lookups when trying to free old
|
||||
+ * buffers.
|
||||
+ */
|
||||
+ struct list_head time_list;
|
||||
+ struct work_struct time_work;
|
||||
+ struct timer_list time_timer;
|
||||
+ } bo_cache;
|
||||
+
|
||||
+ struct vc4_bo_stats {
|
||||
+ u32 num_allocated;
|
||||
+ u32 size_allocated;
|
||||
+ u32 num_cached;
|
||||
+ u32 size_cached;
|
||||
+ } bo_stats;
|
||||
+
|
||||
+ /* Protects bo_cache and the BO stats. */
|
||||
+ struct mutex bo_lock;
|
||||
};
|
||||
|
||||
static inline struct vc4_dev *
|
||||
@@ -27,6 +58,17 @@ to_vc4_dev(struct drm_device *dev)
|
||||
|
||||
struct vc4_bo {
|
||||
struct drm_gem_cma_object base;
|
||||
+
|
||||
+ /* List entry for the BO's position in either
|
||||
+ * vc4_exec_info->unref_list or vc4_dev->bo_cache.time_list
|
||||
+ */
|
||||
+ struct list_head unref_head;
|
||||
+
|
||||
+ /* Time in jiffies when the BO was put in vc4->bo_cache. */
|
||||
+ unsigned long free_time;
|
||||
+
|
||||
+ /* List entry for the BO's position in vc4_dev->bo_cache.size_list */
|
||||
+ struct list_head size_head;
|
||||
};
|
||||
|
||||
static inline struct vc4_bo *
|
||||
@@ -104,13 +146,18 @@ to_vc4_encoder(struct drm_encoder *encoder)
|
||||
#define wait_for(COND, MS) _wait_for(COND, MS, 1)
|
||||
|
||||
/* vc4_bo.c */
|
||||
+struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size);
|
||||
void vc4_free_object(struct drm_gem_object *gem_obj);
|
||||
-struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size);
|
||||
+struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size,
|
||||
+ bool from_cache);
|
||||
int vc4_dumb_create(struct drm_file *file_priv,
|
||||
struct drm_device *dev,
|
||||
struct drm_mode_create_dumb *args);
|
||||
struct dma_buf *vc4_prime_export(struct drm_device *dev,
|
||||
struct drm_gem_object *obj, int flags);
|
||||
+void vc4_bo_cache_init(struct drm_device *dev);
|
||||
+void vc4_bo_cache_destroy(struct drm_device *dev);
|
||||
+int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
|
||||
|
||||
/* vc4_crtc.c */
|
||||
extern struct platform_driver vc4_crtc_driver;
|
1165
debian/patches/features/arm/rpi/drm-vc4-add-an-api-for-creating-gpu-shaders-in-gem-b.patch
vendored
Normal file
1165
debian/patches/features/arm/rpi/drm-vc4-add-an-api-for-creating-gpu-shaders-in-gem-b.patch
vendored
Normal file
File diff suppressed because it is too large
Load Diff
330
debian/patches/features/arm/rpi/drm-vc4-add-an-interface-for-capturing-the-gpu-state.patch
vendored
Normal file
330
debian/patches/features/arm/rpi/drm-vc4-add-an-interface-for-capturing-the-gpu-state.patch
vendored
Normal file
|
@ -0,0 +1,330 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Fri, 30 Oct 2015 10:09:02 -0700
|
||||
Subject: [08/16] drm/vc4: Add an interface for capturing the GPU state after a
|
||||
hang.
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=214613656b5179f0daab6e0a080814b5100d45f0
|
||||
|
||||
This can be parsed with vc4-gpu-tools tools for trying to figure out
|
||||
what was going on.
|
||||
|
||||
v2: Use __u32-style types.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_drv.c | 2 +
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 4 +
|
||||
drivers/gpu/drm/vc4/vc4_gem.c | 185 ++++++++++++++++++++++++++++++++++++++++++
|
||||
include/uapi/drm/vc4_drm.h | 45 ++++++++++
|
||||
4 files changed, 236 insertions(+)
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
index 2cfee59..97226b6 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
@@ -80,6 +80,8 @@ static const struct drm_ioctl_desc vc4_drm_ioctls[] = {
|
||||
DRM_IOCTL_DEF_DRV(VC4_CREATE_BO, vc4_create_bo_ioctl, 0),
|
||||
DRM_IOCTL_DEF_DRV(VC4_MMAP_BO, vc4_mmap_bo_ioctl, 0),
|
||||
DRM_IOCTL_DEF_DRV(VC4_CREATE_SHADER_BO, vc4_create_shader_bo_ioctl, 0),
|
||||
+ DRM_IOCTL_DEF_DRV(VC4_GET_HANG_STATE, vc4_get_hang_state_ioctl,
|
||||
+ DRM_ROOT_ONLY),
|
||||
};
|
||||
|
||||
static struct drm_driver vc4_drm_driver = {
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
index f9927d8..080865e 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -19,6 +19,8 @@ struct vc4_dev {
|
||||
|
||||
struct drm_fbdev_cma *fbdev;
|
||||
|
||||
+ struct vc4_hang_state *hang_state;
|
||||
+
|
||||
/* The kernel-space BO cache. Tracks buffers that have been
|
||||
* unreferenced by all other users (refcounts of 0!) but not
|
||||
* yet freed, so we can do cheap allocations.
|
||||
@@ -361,6 +363,8 @@ int vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
|
||||
struct drm_file *file_priv);
|
||||
int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data,
|
||||
struct drm_file *file_priv);
|
||||
+int vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
|
||||
+ struct drm_file *file_priv);
|
||||
int vc4_mmap(struct file *filp, struct vm_area_struct *vma);
|
||||
int vc4_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
|
||||
void *vc4_prime_vmap(struct drm_gem_object *obj);
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
index 5fb0556..39f29e7 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
@@ -40,6 +40,186 @@ vc4_queue_hangcheck(struct drm_device *dev)
|
||||
round_jiffies_up(jiffies + msecs_to_jiffies(100)));
|
||||
}
|
||||
|
||||
+struct vc4_hang_state {
|
||||
+ struct drm_vc4_get_hang_state user_state;
|
||||
+
|
||||
+ u32 bo_count;
|
||||
+ struct drm_gem_object **bo;
|
||||
+};
|
||||
+
|
||||
+static void
|
||||
+vc4_free_hang_state(struct drm_device *dev, struct vc4_hang_state *state)
|
||||
+{
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ mutex_lock(&dev->struct_mutex);
|
||||
+ for (i = 0; i < state->user_state.bo_count; i++)
|
||||
+ drm_gem_object_unreference(state->bo[i]);
|
||||
+ mutex_unlock(&dev->struct_mutex);
|
||||
+
|
||||
+ kfree(state);
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
|
||||
+ struct drm_file *file_priv)
|
||||
+{
|
||||
+ struct drm_vc4_get_hang_state *get_state = data;
|
||||
+ struct drm_vc4_get_hang_state_bo *bo_state;
|
||||
+ struct vc4_hang_state *kernel_state;
|
||||
+ struct drm_vc4_get_hang_state *state;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ unsigned long irqflags;
|
||||
+ u32 i;
|
||||
+ int ret;
|
||||
+
|
||||
+ spin_lock_irqsave(&vc4->job_lock, irqflags);
|
||||
+ kernel_state = vc4->hang_state;
|
||||
+ if (!kernel_state) {
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+ return -ENOENT;
|
||||
+ }
|
||||
+ state = &kernel_state->user_state;
|
||||
+
|
||||
+ /* If the user's array isn't big enough, just return the
|
||||
+ * required array size.
|
||||
+ */
|
||||
+ if (get_state->bo_count < state->bo_count) {
|
||||
+ get_state->bo_count = state->bo_count;
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ vc4->hang_state = NULL;
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+
|
||||
+ /* Save the user's BO pointer, so we don't stomp it with the memcpy. */
|
||||
+ state->bo = get_state->bo;
|
||||
+ memcpy(get_state, state, sizeof(*state));
|
||||
+
|
||||
+ bo_state = kcalloc(state->bo_count, sizeof(*bo_state), GFP_KERNEL);
|
||||
+ if (!bo_state) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto err_free;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < state->bo_count; i++) {
|
||||
+ struct vc4_bo *vc4_bo = to_vc4_bo(kernel_state->bo[i]);
|
||||
+ u32 handle;
|
||||
+
|
||||
+ ret = drm_gem_handle_create(file_priv, kernel_state->bo[i],
|
||||
+ &handle);
|
||||
+
|
||||
+ if (ret) {
|
||||
+ state->bo_count = i - 1;
|
||||
+ goto err;
|
||||
+ }
|
||||
+ bo_state[i].handle = handle;
|
||||
+ bo_state[i].paddr = vc4_bo->base.paddr;
|
||||
+ bo_state[i].size = vc4_bo->base.base.size;
|
||||
+ }
|
||||
+
|
||||
+ ret = copy_to_user((void __user *)(uintptr_t)get_state->bo,
|
||||
+ bo_state,
|
||||
+ state->bo_count * sizeof(*bo_state));
|
||||
+ kfree(bo_state);
|
||||
+
|
||||
+err_free:
|
||||
+
|
||||
+ vc4_free_hang_state(dev, kernel_state);
|
||||
+
|
||||
+err:
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+vc4_save_hang_state(struct drm_device *dev)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ struct drm_vc4_get_hang_state *state;
|
||||
+ struct vc4_hang_state *kernel_state;
|
||||
+ struct vc4_exec_info *exec;
|
||||
+ struct vc4_bo *bo;
|
||||
+ unsigned long irqflags;
|
||||
+ unsigned int i, unref_list_count;
|
||||
+
|
||||
+ kernel_state = kcalloc(1, sizeof(*state), GFP_KERNEL);
|
||||
+ if (!kernel_state)
|
||||
+ return;
|
||||
+
|
||||
+ state = &kernel_state->user_state;
|
||||
+
|
||||
+ spin_lock_irqsave(&vc4->job_lock, irqflags);
|
||||
+ exec = vc4_first_job(vc4);
|
||||
+ if (!exec) {
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ unref_list_count = 0;
|
||||
+ list_for_each_entry(bo, &exec->unref_list, unref_head)
|
||||
+ unref_list_count++;
|
||||
+
|
||||
+ state->bo_count = exec->bo_count + unref_list_count;
|
||||
+ kernel_state->bo = kcalloc(state->bo_count, sizeof(*kernel_state->bo),
|
||||
+ GFP_ATOMIC);
|
||||
+ if (!kernel_state->bo) {
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < exec->bo_count; i++) {
|
||||
+ drm_gem_object_reference(&exec->bo[i]->base);
|
||||
+ kernel_state->bo[i] = &exec->bo[i]->base;
|
||||
+ }
|
||||
+
|
||||
+ list_for_each_entry(bo, &exec->unref_list, unref_head) {
|
||||
+ drm_gem_object_reference(&bo->base.base);
|
||||
+ kernel_state->bo[i] = &bo->base.base;
|
||||
+ i++;
|
||||
+ }
|
||||
+
|
||||
+ state->start_bin = exec->ct0ca;
|
||||
+ state->start_render = exec->ct1ca;
|
||||
+
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+
|
||||
+ state->ct0ca = V3D_READ(V3D_CTNCA(0));
|
||||
+ state->ct0ea = V3D_READ(V3D_CTNEA(0));
|
||||
+
|
||||
+ state->ct1ca = V3D_READ(V3D_CTNCA(1));
|
||||
+ state->ct1ea = V3D_READ(V3D_CTNEA(1));
|
||||
+
|
||||
+ state->ct0cs = V3D_READ(V3D_CTNCS(0));
|
||||
+ state->ct1cs = V3D_READ(V3D_CTNCS(1));
|
||||
+
|
||||
+ state->ct0ra0 = V3D_READ(V3D_CT00RA0);
|
||||
+ state->ct1ra0 = V3D_READ(V3D_CT01RA0);
|
||||
+
|
||||
+ state->bpca = V3D_READ(V3D_BPCA);
|
||||
+ state->bpcs = V3D_READ(V3D_BPCS);
|
||||
+ state->bpoa = V3D_READ(V3D_BPOA);
|
||||
+ state->bpos = V3D_READ(V3D_BPOS);
|
||||
+
|
||||
+ state->vpmbase = V3D_READ(V3D_VPMBASE);
|
||||
+
|
||||
+ state->dbge = V3D_READ(V3D_DBGE);
|
||||
+ state->fdbgo = V3D_READ(V3D_FDBGO);
|
||||
+ state->fdbgb = V3D_READ(V3D_FDBGB);
|
||||
+ state->fdbgr = V3D_READ(V3D_FDBGR);
|
||||
+ state->fdbgs = V3D_READ(V3D_FDBGS);
|
||||
+ state->errstat = V3D_READ(V3D_ERRSTAT);
|
||||
+
|
||||
+ spin_lock_irqsave(&vc4->job_lock, irqflags);
|
||||
+ if (vc4->hang_state) {
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+ vc4_free_hang_state(dev, kernel_state);
|
||||
+ } else {
|
||||
+ vc4->hang_state = kernel_state;
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void
|
||||
vc4_reset(struct drm_device *dev)
|
||||
{
|
||||
@@ -64,6 +244,8 @@ vc4_reset_work(struct work_struct *work)
|
||||
struct vc4_dev *vc4 =
|
||||
container_of(work, struct vc4_dev, hangcheck.reset_work);
|
||||
|
||||
+ vc4_save_hang_state(vc4->dev);
|
||||
+
|
||||
vc4_reset(vc4->dev);
|
||||
}
|
||||
|
||||
@@ -679,4 +861,7 @@ vc4_gem_destroy(struct drm_device *dev)
|
||||
}
|
||||
|
||||
vc4_bo_cache_destroy(dev);
|
||||
+
|
||||
+ if (vc4->hang_state)
|
||||
+ vc4_free_hang_state(dev, vc4->hang_state);
|
||||
}
|
||||
diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h
|
||||
index fe4161b..eeb37e3 100644
|
||||
--- a/include/uapi/drm/vc4_drm.h
|
||||
+++ b/include/uapi/drm/vc4_drm.h
|
||||
@@ -32,6 +32,7 @@
|
||||
#define DRM_VC4_CREATE_BO 0x03
|
||||
#define DRM_VC4_MMAP_BO 0x04
|
||||
#define DRM_VC4_CREATE_SHADER_BO 0x05
|
||||
+#define DRM_VC4_GET_HANG_STATE 0x06
|
||||
|
||||
#define DRM_IOCTL_VC4_SUBMIT_CL DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SUBMIT_CL, struct drm_vc4_submit_cl)
|
||||
#define DRM_IOCTL_VC4_WAIT_SEQNO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_SEQNO, struct drm_vc4_wait_seqno)
|
||||
@@ -39,6 +40,7 @@
|
||||
#define DRM_IOCTL_VC4_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo)
|
||||
#define DRM_IOCTL_VC4_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_MMAP_BO, struct drm_vc4_mmap_bo)
|
||||
#define DRM_IOCTL_VC4_CREATE_SHADER_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_SHADER_BO, struct drm_vc4_create_shader_bo)
|
||||
+#define DRM_IOCTL_VC4_GET_HANG_STATE DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_HANG_STATE, struct drm_vc4_get_hang_state)
|
||||
|
||||
struct drm_vc4_submit_rcl_surface {
|
||||
__u32 hindex; /* Handle index, or ~0 if not present. */
|
||||
@@ -231,4 +233,47 @@ struct drm_vc4_create_shader_bo {
|
||||
__u32 pad;
|
||||
};
|
||||
|
||||
+struct drm_vc4_get_hang_state_bo {
|
||||
+ __u32 handle;
|
||||
+ __u32 paddr;
|
||||
+ __u32 size;
|
||||
+ __u32 pad;
|
||||
+};
|
||||
+
|
||||
+/**
|
||||
+ * struct drm_vc4_hang_state - ioctl argument for collecting state
|
||||
+ * from a GPU hang for analysis.
|
||||
+*/
|
||||
+struct drm_vc4_get_hang_state {
|
||||
+ /** Pointer to array of struct drm_vc4_get_hang_state_bo. */
|
||||
+ __u64 bo;
|
||||
+ /**
|
||||
+ * On input, the size of the bo array. Output is the number
|
||||
+ * of bos to be returned.
|
||||
+ */
|
||||
+ __u32 bo_count;
|
||||
+
|
||||
+ __u32 start_bin, start_render;
|
||||
+
|
||||
+ __u32 ct0ca, ct0ea;
|
||||
+ __u32 ct1ca, ct1ea;
|
||||
+ __u32 ct0cs, ct1cs;
|
||||
+ __u32 ct0ra0, ct1ra0;
|
||||
+
|
||||
+ __u32 bpca, bpcs;
|
||||
+ __u32 bpoa, bpos;
|
||||
+
|
||||
+ __u32 vpmbase;
|
||||
+
|
||||
+ __u32 dbge;
|
||||
+ __u32 fdbgo;
|
||||
+ __u32 fdbgb;
|
||||
+ __u32 fdbgr;
|
||||
+ __u32 fdbgs;
|
||||
+ __u32 errstat;
|
||||
+
|
||||
+ /* Pad that we may save more registers into in the future. */
|
||||
+ __u32 pad[16];
|
||||
+};
|
||||
+
|
||||
#endif /* _UAPI_VC4_DRM_H_ */
|
|
@ -0,0 +1,201 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Sun, 18 Jan 2015 09:33:17 +1300
|
||||
Subject: [02/16] drm/vc4: Add create and map BO ioctls.
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=d5bc60f6ad05b3c676b057bec662cfafc3ee24dd
|
||||
|
||||
While there exist dumb APIs for creating and mapping BOs, one of the
|
||||
rules is that drivers doing 3D acceleration have to provide their own
|
||||
APIs for buffer allocation (besides, the pitch/height parameters of
|
||||
the dumb alloc don't really make sense for a lot of 3D allocations).
|
||||
|
||||
v2: Use __u32-style types, use "drm.h" instead of <drm/drm.h>.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_bo.c | 41 ++++++++++++++++++++++++++
|
||||
drivers/gpu/drm/vc4/vc4_drv.c | 3 ++
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 4 +++
|
||||
include/uapi/drm/Kbuild | 1 +
|
||||
include/uapi/drm/vc4_drm.h | 68 +++++++++++++++++++++++++++++++++++++++++++
|
||||
5 files changed, 117 insertions(+)
|
||||
create mode 100644 include/uapi/drm/vc4_drm.h
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
|
||||
index 18faa5b..06cba26 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_bo.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "vc4_drv.h"
|
||||
+#include "uapi/drm/vc4_drm.h"
|
||||
|
||||
static void vc4_bo_stats_dump(struct vc4_dev *vc4)
|
||||
{
|
||||
@@ -346,6 +347,46 @@ static void vc4_bo_cache_time_timer(unsigned long data)
|
||||
schedule_work(&vc4->bo_cache.time_work);
|
||||
}
|
||||
|
||||
+int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
|
||||
+ struct drm_file *file_priv)
|
||||
+{
|
||||
+ struct drm_vc4_create_bo *args = data;
|
||||
+ struct vc4_bo *bo = NULL;
|
||||
+ int ret;
|
||||
+
|
||||
+ /*
|
||||
+ * We can't allocate from the BO cache, because the BOs don't
|
||||
+ * get zeroed, and that might leak data between users.
|
||||
+ */
|
||||
+ bo = vc4_bo_create(dev, args->size, false);
|
||||
+ if (!bo)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
|
||||
+ drm_gem_object_unreference_unlocked(&bo->base.base);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data,
|
||||
+ struct drm_file *file_priv)
|
||||
+{
|
||||
+ struct drm_vc4_mmap_bo *args = data;
|
||||
+ struct drm_gem_object *gem_obj;
|
||||
+
|
||||
+ gem_obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
+ if (!gem_obj) {
|
||||
+ DRM_ERROR("Failed to look up GEM BO %d\n", args->handle);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ /* The mmap offset was set up at BO allocation time. */
|
||||
+ args->offset = drm_vma_node_offset_addr(&gem_obj->vma_node);
|
||||
+
|
||||
+ drm_gem_object_unreference_unlocked(gem_obj);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
void vc4_bo_cache_init(struct drm_device *dev)
|
||||
{
|
||||
struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
index da041fa..5fa4688 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include "drm_fb_cma_helper.h"
|
||||
|
||||
+#include "uapi/drm/vc4_drm.h"
|
||||
#include "vc4_drv.h"
|
||||
#include "vc4_regs.h"
|
||||
|
||||
@@ -73,6 +74,8 @@ static const struct file_operations vc4_drm_fops = {
|
||||
};
|
||||
|
||||
static const struct drm_ioctl_desc vc4_drm_ioctls[] = {
|
||||
+ DRM_IOCTL_DEF_DRV(VC4_CREATE_BO, vc4_create_bo_ioctl, 0),
|
||||
+ DRM_IOCTL_DEF_DRV(VC4_MMAP_BO, vc4_mmap_bo_ioctl, 0),
|
||||
};
|
||||
|
||||
static struct drm_driver vc4_drm_driver = {
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
index 39a1ff5..fddb0a0 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -155,6 +155,10 @@ int vc4_dumb_create(struct drm_file *file_priv,
|
||||
struct drm_mode_create_dumb *args);
|
||||
struct dma_buf *vc4_prime_export(struct drm_device *dev,
|
||||
struct drm_gem_object *obj, int flags);
|
||||
+int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
|
||||
+ struct drm_file *file_priv);
|
||||
+int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data,
|
||||
+ struct drm_file *file_priv);
|
||||
void vc4_bo_cache_init(struct drm_device *dev);
|
||||
void vc4_bo_cache_destroy(struct drm_device *dev);
|
||||
int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
|
||||
diff --git a/include/uapi/drm/Kbuild b/include/uapi/drm/Kbuild
|
||||
index 38d4370..974fcd5 100644
|
||||
--- a/include/uapi/drm/Kbuild
|
||||
+++ b/include/uapi/drm/Kbuild
|
||||
@@ -17,4 +17,5 @@ header-y += tegra_drm.h
|
||||
header-y += via_drm.h
|
||||
header-y += vmwgfx_drm.h
|
||||
header-y += msm_drm.h
|
||||
+header-y += vc4_drm.h
|
||||
header-y += virtgpu_drm.h
|
||||
diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h
|
||||
new file mode 100644
|
||||
index 0000000..219d34c
|
||||
--- /dev/null
|
||||
+++ b/include/uapi/drm/vc4_drm.h
|
||||
@@ -0,0 +1,68 @@
|
||||
+/*
|
||||
+ * Copyright © 2014-2015 Broadcom
|
||||
+ *
|
||||
+ * Permission is hereby granted, free of charge, to any person obtaining a
|
||||
+ * copy of this software and associated documentation files (the "Software"),
|
||||
+ * to deal in the Software without restriction, including without limitation
|
||||
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
+ * and/or sell copies of the Software, and to permit persons to whom the
|
||||
+ * Software is furnished to do so, subject to the following conditions:
|
||||
+ *
|
||||
+ * The above copyright notice and this permission notice (including the next
|
||||
+ * paragraph) shall be included in all copies or substantial portions of the
|
||||
+ * Software.
|
||||
+ *
|
||||
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
+ * IN THE SOFTWARE.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _UAPI_VC4_DRM_H_
|
||||
+#define _UAPI_VC4_DRM_H_
|
||||
+
|
||||
+#include "drm.h"
|
||||
+
|
||||
+#define DRM_VC4_CREATE_BO 0x03
|
||||
+#define DRM_VC4_MMAP_BO 0x04
|
||||
+
|
||||
+#define DRM_IOCTL_VC4_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo)
|
||||
+#define DRM_IOCTL_VC4_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_MMAP_BO, struct drm_vc4_mmap_bo)
|
||||
+
|
||||
+/**
|
||||
+ * struct drm_vc4_create_bo - ioctl argument for creating VC4 BOs.
|
||||
+ *
|
||||
+ * There are currently no values for the flags argument, but it may be
|
||||
+ * used in a future extension.
|
||||
+ */
|
||||
+struct drm_vc4_create_bo {
|
||||
+ __u32 size;
|
||||
+ __u32 flags;
|
||||
+ /** Returned GEM handle for the BO. */
|
||||
+ __u32 handle;
|
||||
+ __u32 pad;
|
||||
+};
|
||||
+
|
||||
+/**
|
||||
+ * struct drm_vc4_mmap_bo - ioctl argument for mapping VC4 BOs.
|
||||
+ *
|
||||
+ * This doesn't actually perform an mmap. Instead, it returns the
|
||||
+ * offset you need to use in an mmap on the DRM device node. This
|
||||
+ * means that tools like valgrind end up knowing about the mapped
|
||||
+ * memory.
|
||||
+ *
|
||||
+ * There are currently no values for the flags argument, but it may be
|
||||
+ * used in a future extension.
|
||||
+ */
|
||||
+struct drm_vc4_mmap_bo {
|
||||
+ /** Handle for the object being mapped. */
|
||||
+ __u32 handle;
|
||||
+ __u32 flags;
|
||||
+ /** offset into the drm node to use for subsequent mmap call. */
|
||||
+ __u64 offset;
|
||||
+};
|
||||
+
|
||||
+#endif /* _UAPI_VC4_DRM_H_ */
|
508
debian/patches/features/arm/rpi/drm-vc4-add-support-for-async-pageflips.patch
vendored
Normal file
508
debian/patches/features/arm/rpi/drm-vc4-add-support-for-async-pageflips.patch
vendored
Normal file
|
@ -0,0 +1,508 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Mon, 30 Nov 2015 12:34:01 -0800
|
||||
Subject: [07/16] drm/vc4: Add support for async pageflips.
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=b501bacc6060fd62654b756469cc3091eb53de3a
|
||||
|
||||
An async pageflip stores the modeset to be done and executes it once
|
||||
the BOs are ready to be displayed. This gets us about 3x performance
|
||||
in full screen rendering with pageflipping.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_crtc.c | 99 +++++++++++++++++++++++++-
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 16 +++++
|
||||
drivers/gpu/drm/vc4/vc4_gem.c | 40 +++++++++++
|
||||
drivers/gpu/drm/vc4/vc4_kms.c | 149 +++++++++++++++++++++++++++++++++++++++-
|
||||
drivers/gpu/drm/vc4/vc4_plane.c | 40 +++++++++++
|
||||
5 files changed, 342 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
index 7a9f476..a319332 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "drm_atomic_helper.h"
|
||||
#include "drm_crtc_helper.h"
|
||||
#include "linux/clk.h"
|
||||
+#include "drm_fb_cma_helper.h"
|
||||
#include "linux/component.h"
|
||||
#include "linux/of_device.h"
|
||||
#include "vc4_drv.h"
|
||||
@@ -475,10 +476,106 @@ static irqreturn_t vc4_crtc_irq_handler(int irq, void *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
+struct vc4_async_flip_state {
|
||||
+ struct drm_crtc *crtc;
|
||||
+ struct drm_framebuffer *fb;
|
||||
+ struct drm_pending_vblank_event *event;
|
||||
+
|
||||
+ struct vc4_seqno_cb cb;
|
||||
+};
|
||||
+
|
||||
+/* Called when the V3D execution for the BO being flipped to is done, so that
|
||||
+ * we can actually update the plane's address to point to it.
|
||||
+ */
|
||||
+static void
|
||||
+vc4_async_page_flip_complete(struct vc4_seqno_cb *cb)
|
||||
+{
|
||||
+ struct vc4_async_flip_state *flip_state =
|
||||
+ container_of(cb, struct vc4_async_flip_state, cb);
|
||||
+ struct drm_crtc *crtc = flip_state->crtc;
|
||||
+ struct drm_device *dev = crtc->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ struct drm_plane *plane = crtc->primary;
|
||||
+
|
||||
+ vc4_plane_async_set_fb(plane, flip_state->fb);
|
||||
+ if (flip_state->event) {
|
||||
+ unsigned long flags;
|
||||
+
|
||||
+ spin_lock_irqsave(&dev->event_lock, flags);
|
||||
+ drm_crtc_send_vblank_event(crtc, flip_state->event);
|
||||
+ spin_unlock_irqrestore(&dev->event_lock, flags);
|
||||
+ }
|
||||
+
|
||||
+ drm_framebuffer_unreference(flip_state->fb);
|
||||
+ kfree(flip_state);
|
||||
+
|
||||
+ up(&vc4->async_modeset);
|
||||
+}
|
||||
+
|
||||
+/* Implements async (non-vblank-synced) page flips.
|
||||
+ *
|
||||
+ * The page flip ioctl needs to return immediately, so we grab the
|
||||
+ * modeset semaphore on the pipe, and queue the address update for
|
||||
+ * when V3D is done with the BO being flipped to.
|
||||
+ */
|
||||
+static int vc4_async_page_flip(struct drm_crtc *crtc,
|
||||
+ struct drm_framebuffer *fb,
|
||||
+ struct drm_pending_vblank_event *event,
|
||||
+ uint32_t flags)
|
||||
+{
|
||||
+ struct drm_device *dev = crtc->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ struct drm_plane *plane = crtc->primary;
|
||||
+ int ret = 0;
|
||||
+ struct vc4_async_flip_state *flip_state;
|
||||
+ struct drm_gem_cma_object *cma_bo = drm_fb_cma_get_gem_obj(fb, 0);
|
||||
+ struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
|
||||
+
|
||||
+ flip_state = kzalloc(sizeof(*flip_state), GFP_KERNEL);
|
||||
+ if (!flip_state)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ drm_framebuffer_reference(fb);
|
||||
+ flip_state->fb = fb;
|
||||
+ flip_state->crtc = crtc;
|
||||
+ flip_state->event = event;
|
||||
+
|
||||
+ /* Make sure all other async modesetes have landed. */
|
||||
+ ret = down_interruptible(&vc4->async_modeset);
|
||||
+ if (ret) {
|
||||
+ kfree(flip_state);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* Immediately update the plane's legacy fb pointer, so that later
|
||||
+ * modeset prep sees the state that will be present when the semaphore
|
||||
+ * is released.
|
||||
+ */
|
||||
+ drm_atomic_set_fb_for_plane(plane->state, fb);
|
||||
+ plane->fb = fb;
|
||||
+
|
||||
+ vc4_queue_seqno_cb(dev, &flip_state->cb, bo->seqno,
|
||||
+ vc4_async_page_flip_complete);
|
||||
+
|
||||
+ /* Driver takes ownership of state on successful async commit. */
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int vc4_page_flip(struct drm_crtc *crtc,
|
||||
+ struct drm_framebuffer *fb,
|
||||
+ struct drm_pending_vblank_event *event,
|
||||
+ uint32_t flags)
|
||||
+{
|
||||
+ if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
|
||||
+ return vc4_async_page_flip(crtc, fb, event, flags);
|
||||
+ else
|
||||
+ return drm_atomic_helper_page_flip(crtc, fb, event, flags);
|
||||
+}
|
||||
+
|
||||
static const struct drm_crtc_funcs vc4_crtc_funcs = {
|
||||
.set_config = drm_atomic_helper_set_config,
|
||||
.destroy = vc4_crtc_destroy,
|
||||
- .page_flip = drm_atomic_helper_page_flip,
|
||||
+ .page_flip = vc4_page_flip,
|
||||
.set_property = NULL,
|
||||
.cursor_set = NULL, /* handled by drm_mode_cursor_universal */
|
||||
.cursor_move = NULL, /* handled by drm_mode_cursor_universal */
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
index 0bc8c57..f9927d8 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -76,6 +76,11 @@ struct vc4_dev {
|
||||
wait_queue_head_t job_wait_queue;
|
||||
struct work_struct job_done_work;
|
||||
|
||||
+ /* List of struct vc4_seqno_cb for callbacks to be made from a
|
||||
+ * workqueue when the given seqno is passed.
|
||||
+ */
|
||||
+ struct list_head seqno_cb_list;
|
||||
+
|
||||
/* The binner overflow memory that's currently set up in
|
||||
* BPOA/BPOS registers. When overflow occurs and a new one is
|
||||
* allocated, the previous one will be moved to
|
||||
@@ -128,6 +133,12 @@ to_vc4_bo(struct drm_gem_object *bo)
|
||||
return (struct vc4_bo *)bo;
|
||||
}
|
||||
|
||||
+struct vc4_seqno_cb {
|
||||
+ struct work_struct work;
|
||||
+ uint64_t seqno;
|
||||
+ void (*func)(struct vc4_seqno_cb *cb);
|
||||
+};
|
||||
+
|
||||
struct vc4_v3d {
|
||||
struct platform_device *pdev;
|
||||
void __iomem *regs;
|
||||
@@ -384,6 +395,9 @@ void vc4_submit_next_job(struct drm_device *dev);
|
||||
int vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno,
|
||||
uint64_t timeout_ns, bool interruptible);
|
||||
void vc4_job_handle_completed(struct vc4_dev *vc4);
|
||||
+int vc4_queue_seqno_cb(struct drm_device *dev,
|
||||
+ struct vc4_seqno_cb *cb, uint64_t seqno,
|
||||
+ void (*func)(struct vc4_seqno_cb *cb));
|
||||
|
||||
/* vc4_hdmi.c */
|
||||
extern struct platform_driver vc4_hdmi_driver;
|
||||
@@ -409,6 +423,8 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev,
|
||||
enum drm_plane_type type);
|
||||
u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
|
||||
u32 vc4_plane_dlist_size(struct drm_plane_state *state);
|
||||
+void vc4_plane_async_set_fb(struct drm_plane *plane,
|
||||
+ struct drm_framebuffer *fb);
|
||||
|
||||
/* vc4_v3d.c */
|
||||
extern struct platform_driver vc4_v3d_driver;
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
index 936dddf..5fb0556 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
@@ -461,6 +461,7 @@ void
|
||||
vc4_job_handle_completed(struct vc4_dev *vc4)
|
||||
{
|
||||
unsigned long irqflags;
|
||||
+ struct vc4_seqno_cb *cb, *cb_temp;
|
||||
|
||||
spin_lock_irqsave(&vc4->job_lock, irqflags);
|
||||
while (!list_empty(&vc4->job_done_list)) {
|
||||
@@ -473,7 +474,45 @@ vc4_job_handle_completed(struct vc4_dev *vc4)
|
||||
vc4_complete_exec(vc4->dev, exec);
|
||||
spin_lock_irqsave(&vc4->job_lock, irqflags);
|
||||
}
|
||||
+
|
||||
+ list_for_each_entry_safe(cb, cb_temp, &vc4->seqno_cb_list, work.entry) {
|
||||
+ if (cb->seqno <= vc4->finished_seqno) {
|
||||
+ list_del_init(&cb->work.entry);
|
||||
+ schedule_work(&cb->work);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+}
|
||||
+
|
||||
+static void vc4_seqno_cb_work(struct work_struct *work)
|
||||
+{
|
||||
+ struct vc4_seqno_cb *cb = container_of(work, struct vc4_seqno_cb, work);
|
||||
+
|
||||
+ cb->func(cb);
|
||||
+}
|
||||
+
|
||||
+int vc4_queue_seqno_cb(struct drm_device *dev,
|
||||
+ struct vc4_seqno_cb *cb, uint64_t seqno,
|
||||
+ void (*func)(struct vc4_seqno_cb *cb))
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ int ret = 0;
|
||||
+ unsigned long irqflags;
|
||||
+
|
||||
+ cb->func = func;
|
||||
+ INIT_WORK(&cb->work, vc4_seqno_cb_work);
|
||||
+
|
||||
+ spin_lock_irqsave(&vc4->job_lock, irqflags);
|
||||
+ if (seqno > vc4->finished_seqno) {
|
||||
+ cb->seqno = seqno;
|
||||
+ list_add_tail(&cb->work.entry, &vc4->seqno_cb_list);
|
||||
+ } else {
|
||||
+ schedule_work(&cb->work);
|
||||
+ }
|
||||
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
|
||||
+
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
/* Scheduled when any job has been completed, this walks the list of
|
||||
@@ -610,6 +649,7 @@ vc4_gem_init(struct drm_device *dev)
|
||||
|
||||
INIT_LIST_HEAD(&vc4->job_list);
|
||||
INIT_LIST_HEAD(&vc4->job_done_list);
|
||||
+ INIT_LIST_HEAD(&vc4->seqno_cb_list);
|
||||
spin_lock_init(&vc4->job_lock);
|
||||
|
||||
INIT_WORK(&vc4->hangcheck.reset_work, vc4_reset_work);
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
|
||||
index 2e5597d..f95f2df 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_kms.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "drm_crtc.h"
|
||||
+#include "drm_atomic.h"
|
||||
#include "drm_atomic_helper.h"
|
||||
#include "drm_crtc_helper.h"
|
||||
#include "drm_plane_helper.h"
|
||||
@@ -29,10 +30,152 @@ static void vc4_output_poll_changed(struct drm_device *dev)
|
||||
drm_fbdev_cma_hotplug_event(vc4->fbdev);
|
||||
}
|
||||
|
||||
+struct vc4_commit {
|
||||
+ struct drm_device *dev;
|
||||
+ struct drm_atomic_state *state;
|
||||
+ struct vc4_seqno_cb cb;
|
||||
+};
|
||||
+
|
||||
+static void
|
||||
+vc4_atomic_complete_commit(struct vc4_commit *c)
|
||||
+{
|
||||
+ struct drm_atomic_state *state = c->state;
|
||||
+ struct drm_device *dev = state->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+
|
||||
+ drm_atomic_helper_commit_modeset_disables(dev, state);
|
||||
+
|
||||
+ drm_atomic_helper_commit_planes(dev, state, false);
|
||||
+
|
||||
+ drm_atomic_helper_commit_modeset_enables(dev, state);
|
||||
+
|
||||
+ drm_atomic_helper_wait_for_vblanks(dev, state);
|
||||
+
|
||||
+ drm_atomic_helper_cleanup_planes(dev, state);
|
||||
+
|
||||
+ drm_atomic_state_free(state);
|
||||
+
|
||||
+ up(&vc4->async_modeset);
|
||||
+
|
||||
+ kfree(c);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+vc4_atomic_complete_commit_seqno_cb(struct vc4_seqno_cb *cb)
|
||||
+{
|
||||
+ struct vc4_commit *c = container_of(cb, struct vc4_commit, cb);
|
||||
+
|
||||
+ vc4_atomic_complete_commit(c);
|
||||
+}
|
||||
+
|
||||
+static struct vc4_commit *commit_init(struct drm_atomic_state *state)
|
||||
+{
|
||||
+ struct vc4_commit *c = kzalloc(sizeof(*c), GFP_KERNEL);
|
||||
+
|
||||
+ if (!c)
|
||||
+ return NULL;
|
||||
+ c->dev = state->dev;
|
||||
+ c->state = state;
|
||||
+
|
||||
+ return c;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * vc4_atomic_commit - commit validated state object
|
||||
+ * @dev: DRM device
|
||||
+ * @state: the driver state object
|
||||
+ * @async: asynchronous commit
|
||||
+ *
|
||||
+ * This function commits a with drm_atomic_helper_check() pre-validated state
|
||||
+ * object. This can still fail when e.g. the framebuffer reservation fails. For
|
||||
+ * now this doesn't implement asynchronous commits.
|
||||
+ *
|
||||
+ * RETURNS
|
||||
+ * Zero for success or -errno.
|
||||
+ */
|
||||
+static int vc4_atomic_commit(struct drm_device *dev,
|
||||
+ struct drm_atomic_state *state,
|
||||
+ bool async)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ int ret;
|
||||
+ int i;
|
||||
+ uint64_t wait_seqno = 0;
|
||||
+ struct vc4_commit *c;
|
||||
+
|
||||
+ c = commit_init(state);
|
||||
+ if (!c)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ /* Make sure that any outstanding modesets have finished. */
|
||||
+ ret = down_interruptible(&vc4->async_modeset);
|
||||
+ if (ret) {
|
||||
+ kfree(c);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = drm_atomic_helper_prepare_planes(dev, state);
|
||||
+ if (ret) {
|
||||
+ kfree(c);
|
||||
+ up(&vc4->async_modeset);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < dev->mode_config.num_total_plane; i++) {
|
||||
+ struct drm_plane *plane = state->planes[i];
|
||||
+ struct drm_plane_state *new_state = state->plane_states[i];
|
||||
+
|
||||
+ if (!plane)
|
||||
+ continue;
|
||||
+
|
||||
+ if ((plane->state->fb != new_state->fb) && new_state->fb) {
|
||||
+ struct drm_gem_cma_object *cma_bo =
|
||||
+ drm_fb_cma_get_gem_obj(new_state->fb, 0);
|
||||
+ struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
|
||||
+
|
||||
+ wait_seqno = max(bo->seqno, wait_seqno);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * This is the point of no return - everything below never fails except
|
||||
+ * when the hw goes bonghits. Which means we can commit the new state on
|
||||
+ * the software side now.
|
||||
+ */
|
||||
+
|
||||
+ drm_atomic_helper_swap_state(dev, state);
|
||||
+
|
||||
+ /*
|
||||
+ * Everything below can be run asynchronously without the need to grab
|
||||
+ * any modeset locks at all under one condition: It must be guaranteed
|
||||
+ * that the asynchronous work has either been cancelled (if the driver
|
||||
+ * supports it, which at least requires that the framebuffers get
|
||||
+ * cleaned up with drm_atomic_helper_cleanup_planes()) or completed
|
||||
+ * before the new state gets committed on the software side with
|
||||
+ * drm_atomic_helper_swap_state().
|
||||
+ *
|
||||
+ * This scheme allows new atomic state updates to be prepared and
|
||||
+ * checked in parallel to the asynchronous completion of the previous
|
||||
+ * update. Which is important since compositors need to figure out the
|
||||
+ * composition of the next frame right after having submitted the
|
||||
+ * current layout.
|
||||
+ */
|
||||
+
|
||||
+ if (async) {
|
||||
+ vc4_queue_seqno_cb(dev, &c->cb, wait_seqno,
|
||||
+ vc4_atomic_complete_commit_seqno_cb);
|
||||
+ } else {
|
||||
+ vc4_wait_for_seqno(dev, wait_seqno, ~0ull, false);
|
||||
+ vc4_atomic_complete_commit(c);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static const struct drm_mode_config_funcs vc4_mode_funcs = {
|
||||
.output_poll_changed = vc4_output_poll_changed,
|
||||
.atomic_check = drm_atomic_helper_check,
|
||||
- .atomic_commit = drm_atomic_helper_commit,
|
||||
+ .atomic_commit = vc4_atomic_commit,
|
||||
.fb_create = drm_fb_cma_create,
|
||||
};
|
||||
|
||||
@@ -41,6 +184,8 @@ int vc4_kms_load(struct drm_device *dev)
|
||||
struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
int ret;
|
||||
|
||||
+ sema_init(&vc4->async_modeset, 1);
|
||||
+
|
||||
ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
|
||||
if (ret < 0) {
|
||||
dev_err(dev->dev, "failed to initialize vblank\n");
|
||||
@@ -51,6 +196,8 @@ int vc4_kms_load(struct drm_device *dev)
|
||||
dev->mode_config.max_height = 2048;
|
||||
dev->mode_config.funcs = &vc4_mode_funcs;
|
||||
dev->mode_config.preferred_depth = 24;
|
||||
+ dev->mode_config.async_page_flip = true;
|
||||
+
|
||||
dev->vblank_disable_allowed = true;
|
||||
|
||||
drm_mode_config_reset(dev);
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
index cdd8b10..db32c373 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
@@ -29,6 +29,14 @@ struct vc4_plane_state {
|
||||
u32 *dlist;
|
||||
u32 dlist_size; /* Number of dwords in allocated for the display list */
|
||||
u32 dlist_count; /* Number of used dwords in the display list. */
|
||||
+
|
||||
+ /* Offset in the dlist to pointer word 0. */
|
||||
+ u32 pw0_offset;
|
||||
+
|
||||
+ /* Offset where the plane's dlist was last stored in the
|
||||
+ hardware at vc4_crtc_atomic_flush() time.
|
||||
+ */
|
||||
+ u32 *hw_dlist;
|
||||
};
|
||||
|
||||
static inline struct vc4_plane_state *
|
||||
@@ -197,6 +205,8 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
|
||||
/* Position Word 3: Context. Written by the HVS. */
|
||||
vc4_dlist_write(vc4_state, 0xc0c0c0c0);
|
||||
|
||||
+ vc4_state->pw0_offset = vc4_state->dlist_count;
|
||||
+
|
||||
/* Pointer Word 0: RGB / Y Pointer */
|
||||
vc4_dlist_write(vc4_state, bo->paddr + offset);
|
||||
|
||||
@@ -248,6 +258,8 @@ u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist)
|
||||
struct vc4_plane_state *vc4_state = to_vc4_plane_state(plane->state);
|
||||
int i;
|
||||
|
||||
+ vc4_state->hw_dlist = dlist;
|
||||
+
|
||||
/* Can't memcpy_toio() because it needs to be 32-bit writes. */
|
||||
for (i = 0; i < vc4_state->dlist_count; i++)
|
||||
writel(vc4_state->dlist[i], &dlist[i]);
|
||||
@@ -262,6 +274,34 @@ u32 vc4_plane_dlist_size(struct drm_plane_state *state)
|
||||
return vc4_state->dlist_count;
|
||||
}
|
||||
|
||||
+/* Updates the plane to immediately (well, once the FIFO needs
|
||||
+ * refilling) scan out from at a new framebuffer.
|
||||
+ */
|
||||
+void vc4_plane_async_set_fb(struct drm_plane *plane, struct drm_framebuffer *fb)
|
||||
+{
|
||||
+ struct vc4_plane_state *vc4_state = to_vc4_plane_state(plane->state);
|
||||
+ struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
|
||||
+ uint32_t addr;
|
||||
+
|
||||
+ /* We're skipping the address adjustment for negative origin,
|
||||
+ * because this is only called on the primary plane.
|
||||
+ */
|
||||
+ WARN_ON_ONCE(plane->state->crtc_x < 0 || plane->state->crtc_y < 0);
|
||||
+ addr = bo->paddr + fb->offsets[0];
|
||||
+
|
||||
+ /* Write the new address into the hardware immediately. The
|
||||
+ * scanout will start from this address as soon as the FIFO
|
||||
+ * needs to refill with pixels.
|
||||
+ */
|
||||
+ writel(addr, &vc4_state->hw_dlist[vc4_state->pw0_offset]);
|
||||
+
|
||||
+ /* Also update the CPU-side dlist copy, so that any later
|
||||
+ * atomic updates that don't do a new modeset on our plane
|
||||
+ * also use our updated address.
|
||||
+ */
|
||||
+ vc4_state->dlist[vc4_state->pw0_offset] = addr;
|
||||
+}
|
||||
+
|
||||
static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = {
|
||||
.prepare_fb = NULL,
|
||||
.cleanup_fb = NULL,
|
3474
debian/patches/features/arm/rpi/drm-vc4-add-support-for-drawing-3d-frames.patch
vendored
Normal file
3474
debian/patches/features/arm/rpi/drm-vc4-add-support-for-drawing-3d-frames.patch
vendored
Normal file
File diff suppressed because it is too large
Load Diff
27
debian/patches/features/arm/rpi/drm-vc4-allocate-enough-memory-in-vc4_save_hang_stat.patch
vendored
Normal file
27
debian/patches/features/arm/rpi/drm-vc4-allocate-enough-memory-in-vc4_save_hang_stat.patch
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
From: Dan Carpenter <dan.carpenter@oracle.com>
|
||||
Date: Thu, 17 Dec 2015 15:39:08 +0300
|
||||
Subject: [14/16] drm/vc4: allocate enough memory in vc4_save_hang_state()
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=7e5082fbc00cc157e57a70cdb6b9bbb21289afb1
|
||||
|
||||
"state" is smaller than "kernel_state" so we end up corrupting memory.
|
||||
|
||||
Fixes: 214613656b51 ('drm/vc4: Add an interface for capturing the GPU state after a hang.')
|
||||
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
|
||||
Reviewed-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
index 461a16c..1928c0a 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
@@ -145,7 +145,7 @@ vc4_save_hang_state(struct drm_device *dev)
|
||||
unsigned long irqflags;
|
||||
unsigned int i, unref_list_count;
|
||||
|
||||
- kernel_state = kcalloc(1, sizeof(*state), GFP_KERNEL);
|
||||
+ kernel_state = kcalloc(1, sizeof(*kernel_state), GFP_KERNEL);
|
||||
if (!kernel_state)
|
||||
return;
|
||||
|
330
debian/patches/features/arm/rpi/drm-vc4-bind-and-initialize-the-v3d-engine.patch
vendored
Normal file
330
debian/patches/features/arm/rpi/drm-vc4-bind-and-initialize-the-v3d-engine.patch
vendored
Normal file
|
@ -0,0 +1,330 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Mon, 2 Mar 2015 13:01:12 -0800
|
||||
Subject: [05/16] drm/vc4: Bind and initialize the V3D engine.
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=d3f5168a0810005920e7a3d5ba83e249bd9a750c
|
||||
|
||||
This is the component of the GPU that does 3D rendering.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/Makefile | 1 +
|
||||
drivers/gpu/drm/vc4/vc4_debugfs.c | 2 +
|
||||
drivers/gpu/drm/vc4/vc4_drv.c | 1 +
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 13 +++
|
||||
drivers/gpu/drm/vc4/vc4_v3d.c | 225 ++++++++++++++++++++++++++++++++++++++
|
||||
5 files changed, 242 insertions(+)
|
||||
create mode 100644 drivers/gpu/drm/vc4/vc4_v3d.c
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/Makefile b/drivers/gpu/drm/vc4/Makefile
|
||||
index eb776a6..e87a6f2 100644
|
||||
--- a/drivers/gpu/drm/vc4/Makefile
|
||||
+++ b/drivers/gpu/drm/vc4/Makefile
|
||||
@@ -11,6 +11,7 @@ vc4-y := \
|
||||
vc4_hdmi.o \
|
||||
vc4_hvs.o \
|
||||
vc4_plane.o \
|
||||
+ vc4_v3d.o \
|
||||
vc4_validate_shaders.o
|
||||
|
||||
vc4-$(CONFIG_DEBUG_FS) += vc4_debugfs.o
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_debugfs.c b/drivers/gpu/drm/vc4/vc4_debugfs.c
|
||||
index 6bcf96e..d76ad10 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_debugfs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_debugfs.c
|
||||
@@ -22,6 +22,8 @@ static const struct drm_info_list vc4_debugfs_list[] = {
|
||||
{"crtc0_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)0},
|
||||
{"crtc1_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)1},
|
||||
{"crtc2_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)2},
|
||||
+ {"v3d_ident", vc4_v3d_debugfs_ident, 0},
|
||||
+ {"v3d_regs", vc4_v3d_debugfs_regs, 0},
|
||||
};
|
||||
|
||||
#define VC4_DEBUGFS_ENTRIES ARRAY_SIZE(vc4_debugfs_list)
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
index da4be9c8..db58d74 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
@@ -236,6 +236,7 @@ static struct platform_driver *const component_drivers[] = {
|
||||
&vc4_hdmi_driver,
|
||||
&vc4_crtc_driver,
|
||||
&vc4_hvs_driver,
|
||||
+ &vc4_v3d_driver,
|
||||
};
|
||||
|
||||
static int vc4_platform_drm_probe(struct platform_device *pdev)
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
index bd77d55..8945463 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -15,6 +15,7 @@ struct vc4_dev {
|
||||
struct vc4_hdmi *hdmi;
|
||||
struct vc4_hvs *hvs;
|
||||
struct vc4_crtc *crtc[3];
|
||||
+ struct vc4_v3d *v3d;
|
||||
|
||||
struct drm_fbdev_cma *fbdev;
|
||||
|
||||
@@ -82,6 +83,11 @@ to_vc4_bo(struct drm_gem_object *bo)
|
||||
return (struct vc4_bo *)bo;
|
||||
}
|
||||
|
||||
+struct vc4_v3d {
|
||||
+ struct platform_device *pdev;
|
||||
+ void __iomem *regs;
|
||||
+};
|
||||
+
|
||||
struct vc4_hvs {
|
||||
struct platform_device *pdev;
|
||||
void __iomem *regs;
|
||||
@@ -119,6 +125,8 @@ to_vc4_encoder(struct drm_encoder *encoder)
|
||||
return container_of(encoder, struct vc4_encoder, base);
|
||||
}
|
||||
|
||||
+#define V3D_READ(offset) readl(vc4->v3d->regs + offset)
|
||||
+#define V3D_WRITE(offset, val) writel(val, vc4->v3d->regs + offset)
|
||||
#define HVS_READ(offset) readl(vc4->hvs->regs + offset)
|
||||
#define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
|
||||
|
||||
@@ -241,6 +249,11 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev,
|
||||
u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
|
||||
u32 vc4_plane_dlist_size(struct drm_plane_state *state);
|
||||
|
||||
+/* vc4_v3d.c */
|
||||
+extern struct platform_driver vc4_v3d_driver;
|
||||
+int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused);
|
||||
+int vc4_v3d_debugfs_regs(struct seq_file *m, void *unused);
|
||||
+
|
||||
/* vc4_validate_shader.c */
|
||||
struct vc4_validated_shader_info *
|
||||
vc4_validate_shader(struct drm_gem_cma_object *shader_obj);
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
|
||||
new file mode 100644
|
||||
index 0000000..040ad0d
|
||||
--- /dev/null
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
|
||||
@@ -0,0 +1,225 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2014 The Linux Foundation. All rights reserved.
|
||||
+ * Copyright (C) 2013 Red Hat
|
||||
+ * Author: Rob Clark <robdclark@gmail.com>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License version 2 as published by
|
||||
+ * the Free Software Foundation.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
+ * more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License along with
|
||||
+ * this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+#include "linux/component.h"
|
||||
+#include "vc4_drv.h"
|
||||
+#include "vc4_regs.h"
|
||||
+
|
||||
+#ifdef CONFIG_DEBUG_FS
|
||||
+#define REGDEF(reg) { reg, #reg }
|
||||
+static const struct {
|
||||
+ uint32_t reg;
|
||||
+ const char *name;
|
||||
+} vc4_reg_defs[] = {
|
||||
+ REGDEF(V3D_IDENT0),
|
||||
+ REGDEF(V3D_IDENT1),
|
||||
+ REGDEF(V3D_IDENT2),
|
||||
+ REGDEF(V3D_SCRATCH),
|
||||
+ REGDEF(V3D_L2CACTL),
|
||||
+ REGDEF(V3D_SLCACTL),
|
||||
+ REGDEF(V3D_INTCTL),
|
||||
+ REGDEF(V3D_INTENA),
|
||||
+ REGDEF(V3D_INTDIS),
|
||||
+ REGDEF(V3D_CT0CS),
|
||||
+ REGDEF(V3D_CT1CS),
|
||||
+ REGDEF(V3D_CT0EA),
|
||||
+ REGDEF(V3D_CT1EA),
|
||||
+ REGDEF(V3D_CT0CA),
|
||||
+ REGDEF(V3D_CT1CA),
|
||||
+ REGDEF(V3D_CT00RA0),
|
||||
+ REGDEF(V3D_CT01RA0),
|
||||
+ REGDEF(V3D_CT0LC),
|
||||
+ REGDEF(V3D_CT1LC),
|
||||
+ REGDEF(V3D_CT0PC),
|
||||
+ REGDEF(V3D_CT1PC),
|
||||
+ REGDEF(V3D_PCS),
|
||||
+ REGDEF(V3D_BFC),
|
||||
+ REGDEF(V3D_RFC),
|
||||
+ REGDEF(V3D_BPCA),
|
||||
+ REGDEF(V3D_BPCS),
|
||||
+ REGDEF(V3D_BPOA),
|
||||
+ REGDEF(V3D_BPOS),
|
||||
+ REGDEF(V3D_BXCF),
|
||||
+ REGDEF(V3D_SQRSV0),
|
||||
+ REGDEF(V3D_SQRSV1),
|
||||
+ REGDEF(V3D_SQCNTL),
|
||||
+ REGDEF(V3D_SRQPC),
|
||||
+ REGDEF(V3D_SRQUA),
|
||||
+ REGDEF(V3D_SRQUL),
|
||||
+ REGDEF(V3D_SRQCS),
|
||||
+ REGDEF(V3D_VPACNTL),
|
||||
+ REGDEF(V3D_VPMBASE),
|
||||
+ REGDEF(V3D_PCTRC),
|
||||
+ REGDEF(V3D_PCTRE),
|
||||
+ REGDEF(V3D_PCTR0),
|
||||
+ REGDEF(V3D_PCTRS0),
|
||||
+ REGDEF(V3D_PCTR1),
|
||||
+ REGDEF(V3D_PCTRS1),
|
||||
+ REGDEF(V3D_PCTR2),
|
||||
+ REGDEF(V3D_PCTRS2),
|
||||
+ REGDEF(V3D_PCTR3),
|
||||
+ REGDEF(V3D_PCTRS3),
|
||||
+ REGDEF(V3D_PCTR4),
|
||||
+ REGDEF(V3D_PCTRS4),
|
||||
+ REGDEF(V3D_PCTR5),
|
||||
+ REGDEF(V3D_PCTRS5),
|
||||
+ REGDEF(V3D_PCTR6),
|
||||
+ REGDEF(V3D_PCTRS6),
|
||||
+ REGDEF(V3D_PCTR7),
|
||||
+ REGDEF(V3D_PCTRS7),
|
||||
+ REGDEF(V3D_PCTR8),
|
||||
+ REGDEF(V3D_PCTRS8),
|
||||
+ REGDEF(V3D_PCTR9),
|
||||
+ REGDEF(V3D_PCTRS9),
|
||||
+ REGDEF(V3D_PCTR10),
|
||||
+ REGDEF(V3D_PCTRS10),
|
||||
+ REGDEF(V3D_PCTR11),
|
||||
+ REGDEF(V3D_PCTRS11),
|
||||
+ REGDEF(V3D_PCTR12),
|
||||
+ REGDEF(V3D_PCTRS12),
|
||||
+ REGDEF(V3D_PCTR13),
|
||||
+ REGDEF(V3D_PCTRS13),
|
||||
+ REGDEF(V3D_PCTR14),
|
||||
+ REGDEF(V3D_PCTRS14),
|
||||
+ REGDEF(V3D_PCTR15),
|
||||
+ REGDEF(V3D_PCTRS15),
|
||||
+ REGDEF(V3D_DBGE),
|
||||
+ REGDEF(V3D_FDBGO),
|
||||
+ REGDEF(V3D_FDBGB),
|
||||
+ REGDEF(V3D_FDBGR),
|
||||
+ REGDEF(V3D_FDBGS),
|
||||
+ REGDEF(V3D_ERRSTAT),
|
||||
+};
|
||||
+
|
||||
+int vc4_v3d_debugfs_regs(struct seq_file *m, void *unused)
|
||||
+{
|
||||
+ struct drm_info_node *node = (struct drm_info_node *)m->private;
|
||||
+ struct drm_device *dev = node->minor->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(vc4_reg_defs); i++) {
|
||||
+ seq_printf(m, "%s (0x%04x): 0x%08x\n",
|
||||
+ vc4_reg_defs[i].name, vc4_reg_defs[i].reg,
|
||||
+ V3D_READ(vc4_reg_defs[i].reg));
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused)
|
||||
+{
|
||||
+ struct drm_info_node *node = (struct drm_info_node *)m->private;
|
||||
+ struct drm_device *dev = node->minor->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ uint32_t ident1 = V3D_READ(V3D_IDENT1);
|
||||
+ uint32_t nslc = VC4_GET_FIELD(ident1, V3D_IDENT1_NSLC);
|
||||
+ uint32_t tups = VC4_GET_FIELD(ident1, V3D_IDENT1_TUPS);
|
||||
+ uint32_t qups = VC4_GET_FIELD(ident1, V3D_IDENT1_QUPS);
|
||||
+
|
||||
+ seq_printf(m, "Revision: %d\n",
|
||||
+ VC4_GET_FIELD(ident1, V3D_IDENT1_REV));
|
||||
+ seq_printf(m, "Slices: %d\n", nslc);
|
||||
+ seq_printf(m, "TMUs: %d\n", nslc * tups);
|
||||
+ seq_printf(m, "QPUs: %d\n", nslc * qups);
|
||||
+ seq_printf(m, "Semaphores: %d\n",
|
||||
+ VC4_GET_FIELD(ident1, V3D_IDENT1_NSEM));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif /* CONFIG_DEBUG_FS */
|
||||
+
|
||||
+static void vc4_v3d_init_hw(struct drm_device *dev)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+
|
||||
+ /* Take all the memory that would have been reserved for user
|
||||
+ * QPU programs, since we don't have an interface for running
|
||||
+ * them, anyway.
|
||||
+ */
|
||||
+ V3D_WRITE(V3D_VPMBASE, 0);
|
||||
+}
|
||||
+
|
||||
+static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
|
||||
+{
|
||||
+ struct platform_device *pdev = to_platform_device(dev);
|
||||
+ struct drm_device *drm = dev_get_drvdata(master);
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(drm);
|
||||
+ struct vc4_v3d *v3d = NULL;
|
||||
+
|
||||
+ v3d = devm_kzalloc(&pdev->dev, sizeof(*v3d), GFP_KERNEL);
|
||||
+ if (!v3d)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ v3d->pdev = pdev;
|
||||
+
|
||||
+ v3d->regs = vc4_ioremap_regs(pdev, 0);
|
||||
+ if (IS_ERR(v3d->regs))
|
||||
+ return PTR_ERR(v3d->regs);
|
||||
+
|
||||
+ vc4->v3d = v3d;
|
||||
+
|
||||
+ if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) {
|
||||
+ DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n",
|
||||
+ V3D_READ(V3D_IDENT0), V3D_EXPECTED_IDENT0);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ vc4_v3d_init_hw(drm);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void vc4_v3d_unbind(struct device *dev, struct device *master,
|
||||
+ void *data)
|
||||
+{
|
||||
+ struct drm_device *drm = dev_get_drvdata(master);
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(drm);
|
||||
+
|
||||
+ vc4->v3d = NULL;
|
||||
+}
|
||||
+
|
||||
+static const struct component_ops vc4_v3d_ops = {
|
||||
+ .bind = vc4_v3d_bind,
|
||||
+ .unbind = vc4_v3d_unbind,
|
||||
+};
|
||||
+
|
||||
+static int vc4_v3d_dev_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ return component_add(&pdev->dev, &vc4_v3d_ops);
|
||||
+}
|
||||
+
|
||||
+static int vc4_v3d_dev_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ component_del(&pdev->dev, &vc4_v3d_ops);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id vc4_v3d_dt_match[] = {
|
||||
+ { .compatible = "brcm,vc4-v3d" },
|
||||
+ {}
|
||||
+};
|
||||
+
|
||||
+struct platform_driver vc4_v3d_driver = {
|
||||
+ .probe = vc4_v3d_dev_probe,
|
||||
+ .remove = vc4_v3d_dev_remove,
|
||||
+ .driver = {
|
||||
+ .name = "vc4_v3d",
|
||||
+ .of_match_table = vc4_v3d_dt_match,
|
||||
+ },
|
||||
+};
|
87
debian/patches/features/arm/rpi/drm-vc4-copy_to_user-returns-the-number-of-bytes-rem.patch
vendored
Normal file
87
debian/patches/features/arm/rpi/drm-vc4-copy_to_user-returns-the-number-of-bytes-rem.patch
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
From: Dan Carpenter <dan.carpenter@oracle.com>
|
||||
Date: Thu, 17 Dec 2015 15:36:28 +0300
|
||||
Subject: [13/16] drm/vc4: copy_to_user() returns the number of bytes remaining
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=65c4777de54a39b2722a4b1ff3306d044014d511
|
||||
|
||||
The copy_to/from_user() functions return the number of bytes remaining
|
||||
to be copied. We want to return error codes here.
|
||||
|
||||
Also it's a bad idea to print an error message if a copy from user fails
|
||||
because users can use that to spam /var/log/messages which is annoying
|
||||
so I removed those.
|
||||
|
||||
Fixes: 214613656b51 ('drm/vc4: Add an interface for capturing the GPU state after a hang.')
|
||||
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
|
||||
Reviewed-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_gem.c | 37 ++++++++++++++++++-------------------
|
||||
1 file changed, 18 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
index 39f29e7..461a16c 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
@@ -71,7 +71,7 @@ vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
|
||||
struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
unsigned long irqflags;
|
||||
u32 i;
|
||||
- int ret;
|
||||
+ int ret = 0;
|
||||
|
||||
spin_lock_irqsave(&vc4->job_lock, irqflags);
|
||||
kernel_state = vc4->hang_state;
|
||||
@@ -119,9 +119,11 @@ vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
|
||||
bo_state[i].size = vc4_bo->base.base.size;
|
||||
}
|
||||
|
||||
- ret = copy_to_user((void __user *)(uintptr_t)get_state->bo,
|
||||
- bo_state,
|
||||
- state->bo_count * sizeof(*bo_state));
|
||||
+ if (copy_to_user((void __user *)(uintptr_t)get_state->bo,
|
||||
+ bo_state,
|
||||
+ state->bo_count * sizeof(*bo_state)))
|
||||
+ ret = -EFAULT;
|
||||
+
|
||||
kfree(bo_state);
|
||||
|
||||
err_free:
|
||||
@@ -554,27 +556,24 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)
|
||||
exec->shader_state = temp + exec_size;
|
||||
exec->shader_state_size = args->shader_rec_count;
|
||||
|
||||
- ret = copy_from_user(bin,
|
||||
- (void __user *)(uintptr_t)args->bin_cl,
|
||||
- args->bin_cl_size);
|
||||
- if (ret) {
|
||||
- DRM_ERROR("Failed to copy in bin cl\n");
|
||||
+ if (copy_from_user(bin,
|
||||
+ (void __user *)(uintptr_t)args->bin_cl,
|
||||
+ args->bin_cl_size)) {
|
||||
+ ret = -EFAULT;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- ret = copy_from_user(exec->shader_rec_u,
|
||||
- (void __user *)(uintptr_t)args->shader_rec,
|
||||
- args->shader_rec_size);
|
||||
- if (ret) {
|
||||
- DRM_ERROR("Failed to copy in shader recs\n");
|
||||
+ if (copy_from_user(exec->shader_rec_u,
|
||||
+ (void __user *)(uintptr_t)args->shader_rec,
|
||||
+ args->shader_rec_size)) {
|
||||
+ ret = -EFAULT;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- ret = copy_from_user(exec->uniforms_u,
|
||||
- (void __user *)(uintptr_t)args->uniforms,
|
||||
- args->uniforms_size);
|
||||
- if (ret) {
|
||||
- DRM_ERROR("Failed to copy in uniforms cl\n");
|
||||
+ if (copy_from_user(exec->uniforms_u,
|
||||
+ (void __user *)(uintptr_t)args->uniforms,
|
||||
+ args->uniforms_size)) {
|
||||
+ ret = -EFAULT;
|
||||
goto fail;
|
||||
}
|
||||
|
23
debian/patches/features/arm/rpi/drm-vc4-fix-a-typo-in-a-v3d-debug-register.patch
vendored
Normal file
23
debian/patches/features/arm/rpi/drm-vc4-fix-a-typo-in-a-v3d-debug-register.patch
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Fri, 23 Oct 2015 14:57:22 +0100
|
||||
Subject: [04/16] drm/vc4: Fix a typo in a V3D debug register.
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=1fa81589bbac16af6baf153ccc9b3f38fb16a498
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_regs.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_regs.h b/drivers/gpu/drm/vc4/vc4_regs.h
|
||||
index 9e4e904..4e52a0a 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_regs.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_regs.h
|
||||
@@ -154,7 +154,7 @@
|
||||
#define V3D_PCTRS14 0x006f4
|
||||
#define V3D_PCTR15 0x006f8
|
||||
#define V3D_PCTRS15 0x006fc
|
||||
-#define V3D_BGE 0x00f00
|
||||
+#define V3D_DBGE 0x00f00
|
||||
#define V3D_FDBGO 0x00f04
|
||||
#define V3D_FDBGB 0x00f08
|
||||
#define V3D_FDBGR 0x00f0c
|
|
@ -0,0 +1,28 @@
|
|||
From: Dan Carpenter <dan.carpenter@oracle.com>
|
||||
Date: Thu, 17 Dec 2015 15:40:20 +0300
|
||||
Subject: [15/16] drm/vc4: fix an error code
|
||||
Origin: http://cgit.freedesktop.org/~airlied/linux/commit?id=5645e785cea2f33acdc5e5cee62b3ce8a00f1169
|
||||
|
||||
"exec->exec_bo" is NULL at this point so this code returns success. We
|
||||
want to return -ENOMEM.
|
||||
|
||||
Fixes: d5b1a78a772f ('drm/vc4: Add support for drawing 3D frames.')
|
||||
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
|
||||
Reviewed-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
index 1928c0a..48ce30a 100644
|
||||
--- a/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
|
||||
@@ -580,7 +580,7 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)
|
||||
bo = vc4_bo_create(dev, exec_size, true);
|
||||
if (!bo) {
|
||||
DRM_ERROR("Couldn't allocate BO for binning\n");
|
||||
- ret = PTR_ERR(exec->exec_bo);
|
||||
+ ret = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
exec->exec_bo = &bo->base;
|
26
debian/patches/features/arm/rpi/dt-bindings-add-root-properties-for-raspberry-pi-2.patch
vendored
Normal file
26
debian/patches/features/arm/rpi/dt-bindings-add-root-properties-for-raspberry-pi-2.patch
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Tue, 21 Apr 2015 09:42:21 -0700
|
||||
Subject: [1/3] dt-bindings: Add root properties for Raspberry Pi 2
|
||||
Origin: https://github.com/anholt/linux/commit/57e5c6d95b2cde884634586d833b02f54ba1c79d
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
Acked-by: Rob Herring <robh@kernel.org>
|
||||
---
|
||||
Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt b/Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt
|
||||
index c78576b..11d3056 100644
|
||||
--- a/Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt
|
||||
+++ b/Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt
|
||||
@@ -26,6 +26,10 @@ Raspberry Pi Model B+
|
||||
Required root node properties:
|
||||
compatible = "raspberrypi,model-b-plus", "brcm,bcm2835";
|
||||
|
||||
+Raspberry Pi 2 Model B
|
||||
+Required root node properties:
|
||||
+compatible = "raspberrypi,2-model-b", "brcm,bcm2836";
|
||||
+
|
||||
Raspberry Pi Compute Module
|
||||
Required root node properties:
|
||||
compatible = "raspberrypi,compute-module", "brcm,bcm2835";
|
71
debian/patches/features/arm/rpi/dt-bindings-add-rpi-power-domain-driver-bindings.patch
vendored
Normal file
71
debian/patches/features/arm/rpi/dt-bindings-add-rpi-power-domain-driver-bindings.patch
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
From: Alexander Aring <alex.aring@gmail.com>
|
||||
Date: Wed, 16 Dec 2015 16:26:48 -0800
|
||||
Subject: [2/3] dt-bindings: add rpi power domain driver bindings
|
||||
Origin: https://github.com/anholt/linux/commit/4c8b338f9ae38dee9c77bda023babc7f7543f52c
|
||||
|
||||
This patch adds devicetree tree bindings for the Raspberry Pi power
|
||||
domain driver.
|
||||
|
||||
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
Acked-by: Rob Herring <robh@kernel.org>
|
||||
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
|
||||
Reviewed-by: Kevin Hilman <khilman@linaro.org>
|
||||
---
|
||||
.../bindings/soc/bcm/raspberrypi,bcm2835-power.txt | 47 ++++++++++++++++++++++
|
||||
1 file changed, 47 insertions(+)
|
||||
create mode 100644 Documentation/devicetree/bindings/soc/bcm/raspberrypi,bcm2835-power.txt
|
||||
|
||||
diff --git a/Documentation/devicetree/bindings/soc/bcm/raspberrypi,bcm2835-power.txt b/Documentation/devicetree/bindings/soc/bcm/raspberrypi,bcm2835-power.txt
|
||||
new file mode 100644
|
||||
index 0000000..30942cf
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/soc/bcm/raspberrypi,bcm2835-power.txt
|
||||
@@ -0,0 +1,47 @@
|
||||
+Raspberry Pi power domain driver
|
||||
+
|
||||
+Required properties:
|
||||
+
|
||||
+- compatible: Should be "raspberrypi,bcm2835-power".
|
||||
+- firmware: Reference to the RPi firmware device node.
|
||||
+- #power-domain-cells: Should be <1>, we providing multiple power domains.
|
||||
+
|
||||
+The valid defines for power domain are:
|
||||
+
|
||||
+ RPI_POWER_DOMAIN_I2C0
|
||||
+ RPI_POWER_DOMAIN_I2C1
|
||||
+ RPI_POWER_DOMAIN_I2C2
|
||||
+ RPI_POWER_DOMAIN_VIDEO_SCALER
|
||||
+ RPI_POWER_DOMAIN_VPU1
|
||||
+ RPI_POWER_DOMAIN_HDMI
|
||||
+ RPI_POWER_DOMAIN_USB
|
||||
+ RPI_POWER_DOMAIN_VEC
|
||||
+ RPI_POWER_DOMAIN_JPEG
|
||||
+ RPI_POWER_DOMAIN_H264
|
||||
+ RPI_POWER_DOMAIN_V3D
|
||||
+ RPI_POWER_DOMAIN_ISP
|
||||
+ RPI_POWER_DOMAIN_UNICAM0
|
||||
+ RPI_POWER_DOMAIN_UNICAM1
|
||||
+ RPI_POWER_DOMAIN_CCP2RX
|
||||
+ RPI_POWER_DOMAIN_CSI2
|
||||
+ RPI_POWER_DOMAIN_CPI
|
||||
+ RPI_POWER_DOMAIN_DSI0
|
||||
+ RPI_POWER_DOMAIN_DSI1
|
||||
+ RPI_POWER_DOMAIN_TRANSPOSER
|
||||
+ RPI_POWER_DOMAIN_CCP2TX
|
||||
+ RPI_POWER_DOMAIN_CDP
|
||||
+ RPI_POWER_DOMAIN_ARM
|
||||
+
|
||||
+Example:
|
||||
+
|
||||
+power: power {
|
||||
+ compatible = "raspberrypi,bcm2835-power";
|
||||
+ firmware = <&firmware>;
|
||||
+ #power-domain-cells = <1>;
|
||||
+};
|
||||
+
|
||||
+Example for using power domain:
|
||||
+
|
||||
+&usb {
|
||||
+ power-domains = <&power RPI_POWER_DOMAIN_USB>;
|
||||
+};
|
57
debian/patches/features/arm/rpi/pwm-bcm2835-calculate-scaler-in-config.patch
vendored
Normal file
57
debian/patches/features/arm/rpi/pwm-bcm2835-calculate-scaler-in-config.patch
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
From: Stefan Wahren <stefan.wahren@i2se.com>
|
||||
Date: Tue, 1 Dec 2015 22:55:39 +0000
|
||||
Subject: [1/3] pwm: bcm2835: Calculate scaler in ->config()
|
||||
Origin: https://git.kernel.org/cgit/linux/kernel/git/thierry.reding/linux-pwm.git/commit?id=ebe88b6ae41ff8f2b48608b6019c4341aa24bcea
|
||||
|
||||
Currently pwm-bcm2835 assumes a fixed clock rate and stores the
|
||||
resulting scaler in the driver structure. But with the upcoming
|
||||
PWM clock support for clk-bcm2835 the rate could change, so
|
||||
calculate the scaler in the ->config() callback.
|
||||
|
||||
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
|
||||
Reviewed-by: Eric Anholt <eric@anholt.net>
|
||||
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
|
||||
---
|
||||
drivers/pwm/pwm-bcm2835.c | 8 +++-----
|
||||
1 file changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
|
||||
index b4c7f95..174cca9 100644
|
||||
--- a/drivers/pwm/pwm-bcm2835.c
|
||||
+++ b/drivers/pwm/pwm-bcm2835.c
|
||||
@@ -29,7 +29,6 @@
|
||||
struct bcm2835_pwm {
|
||||
struct pwm_chip chip;
|
||||
struct device *dev;
|
||||
- unsigned long scaler;
|
||||
void __iomem *base;
|
||||
struct clk *clk;
|
||||
};
|
||||
@@ -66,6 +65,7 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
int duty_ns, int period_ns)
|
||||
{
|
||||
struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
|
||||
+ unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
|
||||
|
||||
if (period_ns <= MIN_PERIOD) {
|
||||
dev_err(pc->dev, "period %d not supported, minimum %d\n",
|
||||
@@ -73,8 +73,8 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- writel(duty_ns / pc->scaler, pc->base + DUTY(pwm->hwpwm));
|
||||
- writel(period_ns / pc->scaler, pc->base + PERIOD(pwm->hwpwm));
|
||||
+ writel(duty_ns / scaler, pc->base + DUTY(pwm->hwpwm));
|
||||
+ writel(period_ns / scaler, pc->base + PERIOD(pwm->hwpwm));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -156,8 +156,6 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- pc->scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
|
||||
-
|
||||
pc->chip.dev = &pdev->dev;
|
||||
pc->chip.ops = &bcm2835_pwm_ops;
|
||||
pc->chip.npwm = 2;
|
24
debian/patches/features/arm/rpi/pwm-bcm2835-fix-email-address-specification.patch
vendored
Normal file
24
debian/patches/features/arm/rpi/pwm-bcm2835-fix-email-address-specification.patch
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
From: Stefan Wahren <stefan.wahren@i2se.com>
|
||||
Date: Tue, 1 Dec 2015 22:55:41 +0000
|
||||
Subject: [3/3] pwm: bcm2835: Fix email address specification
|
||||
Origin: https://git.kernel.org/cgit/linux/kernel/git/thierry.reding/linux-pwm.git/commit?id=6ef7d1c46f0cbe2b8e9c66d5d95ffa5a612df45d
|
||||
|
||||
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
|
||||
Reviewed-by: Eric Anholt <eric@anholt.net>
|
||||
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
|
||||
---
|
||||
drivers/pwm/pwm-bcm2835.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
|
||||
index 31a6992..c5dbf16 100644
|
||||
--- a/drivers/pwm/pwm-bcm2835.c
|
||||
+++ b/drivers/pwm/pwm-bcm2835.c
|
||||
@@ -206,6 +206,6 @@ static struct platform_driver bcm2835_pwm_driver = {
|
||||
};
|
||||
module_platform_driver(bcm2835_pwm_driver);
|
||||
|
||||
-MODULE_AUTHOR("Bart Tanghe <bart.tanghe@thomasmore.be");
|
||||
+MODULE_AUTHOR("Bart Tanghe <bart.tanghe@thomasmore.be>");
|
||||
MODULE_DESCRIPTION("Broadcom BCM2835 PWM driver");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -0,0 +1,36 @@
|
|||
From: Stefan Wahren <stefan.wahren@i2se.com>
|
||||
Date: Tue, 1 Dec 2015 22:55:40 +0000
|
||||
Subject: [2/3] pwm: bcm2835: Prevent division by zero
|
||||
Origin: https://git.kernel.org/cgit/linux/kernel/git/thierry.reding/linux-pwm.git/commit?id=fd13c14426299e75983a0cd3edf53dfa4083a70a
|
||||
|
||||
It's possible that the PWM clock becomes an orphan. So better check the
|
||||
result of clk_get_rate() in order to prevent a division by zero.
|
||||
|
||||
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
|
||||
Reviewed-by: Eric Anholt <eric@anholt.net>
|
||||
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
|
||||
---
|
||||
drivers/pwm/pwm-bcm2835.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
|
||||
index 174cca9..31a6992 100644
|
||||
--- a/drivers/pwm/pwm-bcm2835.c
|
||||
+++ b/drivers/pwm/pwm-bcm2835.c
|
||||
@@ -65,7 +65,15 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
int duty_ns, int period_ns)
|
||||
{
|
||||
struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
|
||||
- unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
|
||||
+ unsigned long rate = clk_get_rate(pc->clk);
|
||||
+ unsigned long scaler;
|
||||
+
|
||||
+ if (!rate) {
|
||||
+ dev_err(pc->dev, "failed to get clock rate\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ scaler = NSEC_PER_SEC / rate;
|
||||
|
||||
if (period_ns <= MIN_PERIOD) {
|
||||
dev_err(pc->dev, "period %d not supported, minimum %d\n",
|
|
@ -67,3 +67,28 @@ features/all/grsecurity/grkernsec_perf_harden.patch
|
|||
bugfix/all/usbvision-fix-overflow-of-interfaces-array.patch
|
||||
bugfix/all/media-usbvision-fix-crash-on-detecting-device-with-i.patch
|
||||
bugfix/x86/drm-i915-shut-up-gen8-sde-irq-dmesg-noise.patch
|
||||
features/arm/rpi/pwm-bcm2835-calculate-scaler-in-config.patch
|
||||
features/arm/rpi/pwm-bcm2835-prevent-division-by-zero.patch
|
||||
features/arm/rpi/pwm-bcm2835-fix-email-address-specification.patch
|
||||
features/arm/rpi/drm-create-a-driver-hook-for-allocating-gem-object-s.patch
|
||||
features/arm/rpi/drm-vc4-add-a-bo-cache.patch
|
||||
features/arm/rpi/drm-vc4-add-create-and-map-bo-ioctls.patch
|
||||
features/arm/rpi/drm-vc4-add-an-api-for-creating-gpu-shaders-in-gem-b.patch
|
||||
features/arm/rpi/drm-vc4-fix-a-typo-in-a-v3d-debug-register.patch
|
||||
features/arm/rpi/drm-vc4-bind-and-initialize-the-v3d-engine.patch
|
||||
features/arm/rpi/drm-vc4-add-support-for-drawing-3d-frames.patch
|
||||
features/arm/rpi/drm-vc4-add-support-for-async-pageflips.patch
|
||||
features/arm/rpi/drm-vc4-add-an-interface-for-capturing-the-gpu-state.patch
|
||||
features/arm/rpi/drm-vc4-copy_to_user-returns-the-number-of-bytes-rem.patch
|
||||
features/arm/rpi/drm-vc4-allocate-enough-memory-in-vc4_save_hang_stat.patch
|
||||
features/arm/rpi/drm-vc4-fix-an-error-code.patch
|
||||
features/arm/rpi/dt-bindings-add-root-properties-for-raspberry-pi-2.patch
|
||||
features/arm/rpi/arm-bcm2835-add-a-compat-string-for-bcm2836-machine-.patch
|
||||
features/arm/rpi/arm-bcm2835-add-kconfig-support-for-bcm2836.patch
|
||||
features/arm/rpi/arm-bcm2835-define-two-new-packets-from-the-latest-f.patch
|
||||
features/arm/rpi/dt-bindings-add-rpi-power-domain-driver-bindings.patch
|
||||
features/arm/rpi/arm-bcm2835-add-rpi-power-domain-driver.patch
|
||||
features/arm/rpi/arm-bcm2835-split-the-dt-for-peripherals-from-the-dt.patch
|
||||
features/arm/rpi/arm-bcm2835-move-the-cpu-peripheral-include-out-of-c.patch
|
||||
features/arm/rpi/arm-bcm2835-add-devicetree-for-bcm2836-and-raspberry.patch
|
||||
features/arm/rpi/arm-bcm2835-add-the-auxiliary-clocks-to-the-device-t.patch
|
||||
|
|
Loading…
Reference in New Issue