From 76842aa3ff48d7f799be268ba78a225ddbabfd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Mon, 18 May 2015 17:18:28 +0200 Subject: [PATCH 1/6] fbdev: bcm2708_fb: Add ARCH_BCM2835 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Device Tree support. Pass the device to dma_alloc_coherent() in order to get the correct bus address on ARCH_BCM2835. Use the new DMA legacy API header file. Including is not necessary. Signed-off-by: Noralf Trønnes --- drivers/video/fbdev/bcm2708_fb.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/bcm2708_fb.c b/drivers/video/fbdev/bcm2708_fb.c index 345c15e2b16be1..f6ac7dad2af357 100644 --- a/drivers/video/fbdev/bcm2708_fb.c +++ b/drivers/video/fbdev/bcm2708_fb.c @@ -24,16 +24,13 @@ #include #include #include +#include #include #include #include #include #include #include - -#include -#include - #include #include #include @@ -628,7 +625,7 @@ static int bcm2708_fb_register(struct bcm2708_fb *fb) void *mem; mem = - dma_alloc_coherent(NULL, PAGE_ALIGN(sizeof(*fb->info)), &dma, + dma_alloc_coherent(&fb->dev->dev, PAGE_ALIGN(sizeof(*fb->info)), &dma, GFP_KERNEL); if (NULL == mem) { @@ -783,12 +780,19 @@ static int bcm2708_fb_remove(struct platform_device *dev) return 0; } +static const struct of_device_id bcm2708_fb_of_match_table[] = { + { .compatible = "brcm,bcm2708-fb", }, + {}, +}; +MODULE_DEVICE_TABLE(of, bcm2708_fb_of_match_table); + static struct platform_driver bcm2708_fb_driver = { .probe = bcm2708_fb_probe, .remove = bcm2708_fb_remove, .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, + .of_match_table = bcm2708_fb_of_match_table, }, }; From 8e4daae27742ef8bb1146e1b8a5c738aa6c4b9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Mon, 18 May 2015 17:20:00 +0200 Subject: [PATCH 2/6] BCM270x: Remove header file mach/dma.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This header file can be removed since there are no more users. Signed-off-by: Noralf Trønnes --- arch/arm/mach-bcm2708/include/mach/dma.h | 2 -- arch/arm/mach-bcm2709/include/mach/dma.h | 2 -- 2 files changed, 4 deletions(-) delete mode 100644 arch/arm/mach-bcm2708/include/mach/dma.h delete mode 100644 arch/arm/mach-bcm2709/include/mach/dma.h diff --git a/arch/arm/mach-bcm2708/include/mach/dma.h b/arch/arm/mach-bcm2708/include/mach/dma.h deleted file mode 100644 index d826705e1574e2..00000000000000 --- a/arch/arm/mach-bcm2708/include/mach/dma.h +++ /dev/null @@ -1,2 +0,0 @@ -/* This file can be removed when all the drivers have been updated */ -#include diff --git a/arch/arm/mach-bcm2709/include/mach/dma.h b/arch/arm/mach-bcm2709/include/mach/dma.h deleted file mode 100644 index d826705e1574e2..00000000000000 --- a/arch/arm/mach-bcm2709/include/mach/dma.h +++ /dev/null @@ -1,2 +0,0 @@ -/* This file can be removed when all the drivers have been updated */ -#include From 61021b5883fc0c64fad65e9d6c4d3fc4eb3c5274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Mon, 18 May 2015 17:21:31 +0200 Subject: [PATCH 3/6] BCM270x_DT: Add bcm2708-fb device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add bcm2708-fb to Device Tree and don't add the platform device when booting in DT mode. Signed-off-by: Noralf Trønnes --- arch/arm/boot/dts/bcm2708-rpi-b-plus.dts | 4 ++++ arch/arm/boot/dts/bcm2708-rpi-b.dts | 4 ++++ arch/arm/boot/dts/bcm2708_common.dtsi | 5 +++++ arch/arm/boot/dts/bcm2709-rpi-2-b.dts | 4 ++++ arch/arm/mach-bcm2708/bcm2708.c | 2 +- arch/arm/mach-bcm2709/bcm2709.c | 2 +- 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts b/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts index f25563aee35d8e..9a8fed03ada7ba 100644 --- a/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts +++ b/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts @@ -49,6 +49,10 @@ bus-width = <4>; }; +&fb { + status = "okay"; +}; + &spi0 { pinctrl-names = "default"; pinctrl-0 = <&spi0_pins>; diff --git a/arch/arm/boot/dts/bcm2708-rpi-b.dts b/arch/arm/boot/dts/bcm2708-rpi-b.dts index 17b4b8c7d12a1e..cf67ec94e91c2e 100644 --- a/arch/arm/boot/dts/bcm2708-rpi-b.dts +++ b/arch/arm/boot/dts/bcm2708-rpi-b.dts @@ -49,6 +49,10 @@ bus-width = <4>; }; +&fb { + status = "okay"; +}; + &spi0 { pinctrl-names = "default"; pinctrl-0 = <&spi0_pins>; diff --git a/arch/arm/boot/dts/bcm2708_common.dtsi b/arch/arm/boot/dts/bcm2708_common.dtsi index 1c8c1af9a1ff61..c5ed34bda23758 100644 --- a/arch/arm/boot/dts/bcm2708_common.dtsi +++ b/arch/arm/boot/dts/bcm2708_common.dtsi @@ -109,6 +109,11 @@ leds: leds { compatible = "gpio-leds"; }; + + fb: fb { + compatible = "brcm,bcm2708-fb"; + status = "disabled"; + }; }; clocks { diff --git a/arch/arm/boot/dts/bcm2709-rpi-2-b.dts b/arch/arm/boot/dts/bcm2709-rpi-2-b.dts index c73249b2f2f018..1c865de5daf74a 100644 --- a/arch/arm/boot/dts/bcm2709-rpi-2-b.dts +++ b/arch/arm/boot/dts/bcm2709-rpi-2-b.dts @@ -49,6 +49,10 @@ bus-width = <4>; }; +&fb { + status = "okay"; +}; + &spi0 { pinctrl-names = "default"; pinctrl-0 = <&spi0_pins>; diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c index 7cc47c1fdb7147..cde2124566fe00 100644 --- a/arch/arm/mach-bcm2708/bcm2708.c +++ b/arch/arm/mach-bcm2708/bcm2708.c @@ -928,7 +928,7 @@ void __init bcm2708_init(void) bcm_register_device_dt(&w1_device); #endif bcm_register_device(&bcm2708_systemtimer_device); - bcm_register_device(&bcm2708_fb_device); + bcm_register_device_dt(&bcm2708_fb_device); bcm_register_device(&bcm2708_usb_device); bcm_register_device(&bcm2708_uart1_device); bcm_register_device(&bcm2708_powerman_device); diff --git a/arch/arm/mach-bcm2709/bcm2709.c b/arch/arm/mach-bcm2709/bcm2709.c index 2c0a664825f047..95db41ff2601fb 100644 --- a/arch/arm/mach-bcm2709/bcm2709.c +++ b/arch/arm/mach-bcm2709/bcm2709.c @@ -951,7 +951,7 @@ void __init bcm2709_init(void) #ifdef SYSTEM_TIMER bcm_register_device(&bcm2708_systemtimer_device); #endif - bcm_register_device(&bcm2708_fb_device); + bcm_register_device_dt(&bcm2708_fb_device); bcm_register_device(&bcm2708_usb_device); bcm_register_device(&bcm2708_uart1_device); bcm_register_device(&bcm2708_powerman_device); From 48473996dc49383dbe90050287fc55e59fe2e496 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 5 May 2015 13:10:11 -0700 Subject: [PATCH 4/6] ARM: bcm2835: Use 0x4 prefix for DMA bus addresses to SDRAM. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There exists a tiny MMU, configurable only by the VC (running the closed firmware), which maps from the ARM's physical addresses to bus addresses. These bus addresses determine the caching behavior in the VC's L1/L2 (note: separate from the ARM's L1/L2) according to the top 2 bits. The bits in the bus address mean: From the VideoCore processor: 0x0... L1 and L2 cache allocating and coherent 0x4... L1 non-allocating, but coherent. L2 allocating and coherent 0x8... L1 non-allocating, but coherent. L2 non-allocating, but coherent 0xc... SDRAM alias. Cache is bypassed. Not L1 or L2 allocating or coherent From the GPU peripherals (note: all peripherals bypass the L1 cache. The ARM will see this view once through the VC MMU): 0x0... Do not use 0x4... L1 non-allocating, and incoherent. L2 allocating and coherent. 0x8... L1 non-allocating, and incoherent. L2 non-allocating, but coherent 0xc... SDRAM alias. Cache is bypassed. Not L1 or L2 allocating or coherent The 2835 firmware always configures the MMU to turn ARM physical addresses with 0x0 top bits to 0x4, meaning present in L2 but incoherent with L1. However, any bus addresses we were generating in the kernel to be passed to a device had 0x0 bits. That would be a reserved (possibly totally incoherent) value if sent to a GPU peripheral like USB, or L1 allocating if sent to the VC (like a firmware property request). By setting dma-ranges, all of the devices below it get a dev->dma_pfn_offset, so that dma_alloc_coherent() and friends return addresses with 0x4 bits and avoid cache incoherency. This matches the behavior in the downstream 2708 kernel (see BUS_OFFSET in arch/arm/mach-bcm2708/include/mach/memory.h). Signed-off-by: Eric Anholt Tested-by: Noralf Trønnes Acked-by: Stephen Warren Cc: popcornmix@gmail.com --- arch/arm/boot/dts/bcm2835.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi index 06cba29c964593..f91db907c96dff 100644 --- a/arch/arm/boot/dts/bcm2835.dtsi +++ b/arch/arm/boot/dts/bcm2835.dtsi @@ -14,6 +14,7 @@ #address-cells = <1>; #size-cells = <1>; ranges = <0x7e000000 0x20000000 0x02000000>; + dma-ranges = <0x40000000 0x00000000 0x20000000>; timer@7e003000 { compatible = "brcm,bcm2835-system-timer"; From 16ed47cb1d2f92dcb6394e65995050a925e0eaf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Mon, 18 May 2015 17:24:13 +0200 Subject: [PATCH 5/6] bcm2835: Add bcm2708-fb to Device Tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add framebuffer device to Device Tree. Signed-off-by: Noralf Trønnes --- arch/arm/boot/dts/bcm2835-rpi.dtsi | 4 ++++ arch/arm/boot/dts/bcm2835.dtsi | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi index 9f4ed2f4d2e420..f2ce8031a2a5b0 100644 --- a/arch/arm/boot/dts/bcm2835-rpi.dtsi +++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi @@ -49,3 +49,7 @@ status = "okay"; bus-width = <4>; }; + +&fb { + status = "okay"; +}; diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi index f91db907c96dff..f3ab9b3839722a 100644 --- a/arch/arm/boot/dts/bcm2835.dtsi +++ b/arch/arm/boot/dts/bcm2835.dtsi @@ -159,6 +159,11 @@ arm-pmu { compatible = "arm,arm1176-pmu"; }; + + fb: fb { + compatible = "brcm,bcm2708-fb"; + status = "disabled"; + }; }; clocks { From 182827458d3ac2b530c0c41414793a3379a3243a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Mon, 18 May 2015 17:24:35 +0200 Subject: [PATCH 6/6] bcm2835: bcm2835_defconfig use FB_BCM2708 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable the bcm2708 framebuffer driver. Disable the simple framebuffer driver, which matches the device handed over by u-boot. Signed-off-by: Noralf Trønnes --- arch/arm/configs/bcm2835_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/configs/bcm2835_defconfig b/arch/arm/configs/bcm2835_defconfig index 26b4c758837343..1af6069fcaf2b3 100644 --- a/arch/arm/configs/bcm2835_defconfig +++ b/arch/arm/configs/bcm2835_defconfig @@ -72,7 +72,7 @@ CONFIG_SPI_BCM2835=y CONFIG_GPIO_SYSFS=y # CONFIG_HWMON is not set CONFIG_FB=y -CONFIG_FB_SIMPLE=y +CONFIG_FB_BCM2708=y CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y CONFIG_USB=y