Skip to content

Commit 24e6272

Browse files
authored
Merge pull request #1637 from anholt/rpi-4.4.y-firmware-kms
Rpi 4.4.y firmware kms
2 parents 57b92a3 + 9194941 commit 24e6272

File tree

11 files changed

+815
-14
lines changed

11 files changed

+815
-14
lines changed

arch/arm/boot/dts/bcm2708_common.dtsi

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,26 @@
284284
status = "disabled";
285285
};
286286

287+
firmwarekms: firmwarekms@7e600000 {
288+
compatible = "raspberrypi,rpi-firmware-kms";
289+
/* SMI interrupt reg */
290+
reg = <0x7e600000 0x100>;
291+
interrupts = <2 16>;
292+
brcm,firmware = <&firmware>;
293+
status = "disabled";
294+
};
295+
296+
smi: smi@7e600000 {
297+
compatible = "brcm,bcm2835-smi";
298+
reg = <0x7e600000 0x44>, <0x7e1010b0 0x8>;
299+
interrupts = <2 16>;
300+
brcm,smi-clock-source = <6>;
301+
brcm,smi-clock-divisor = <4>;
302+
dmas = <&dma 4>;
303+
dma-names = "rx-tx";
304+
status = "disabled";
305+
};
306+
287307
dsi1: dsi@7e700000 {
288308
#address-cells = <1>;
289309
#size-cells = <0>;
@@ -325,17 +345,6 @@
325345
status = "disabled";
326346
};
327347

328-
smi: smi@7e600000 {
329-
compatible = "brcm,bcm2835-smi";
330-
reg = <0x7e600000 0x44>, <0x7e1010b0 0x8>;
331-
interrupts = <2 16>;
332-
brcm,smi-clock-source = <6>;
333-
brcm,smi-clock-divisor = <4>;
334-
dmas = <&dma 4>;
335-
dma-names = "rx-tx";
336-
status = "disabled";
337-
};
338-
339348
pixelvalve2: pixelvalve@7e807000 {
340349
compatible = "brcm,bcm2835-pixelvalve2";
341350
reg = <0x7e807000 0x100>;

arch/arm/boot/dts/overlays/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ dtbo-$(RPI_DT_OVERLAYS) += spi2-2cs.dtbo
9696
dtbo-$(RPI_DT_OVERLAYS) += spi2-3cs.dtbo
9797
dtbo-$(RPI_DT_OVERLAYS) += tinylcd35.dtbo
9898
dtbo-$(RPI_DT_OVERLAYS) += uart1.dtbo
99+
dtbo-$(RPI_DT_OVERLAYS) += vc4-fkms-v3d.dtbo
99100
dtbo-$(RPI_DT_OVERLAYS) += vc4-kms-v3d.dtbo
100101
dtbo-$(RPI_DT_OVERLAYS) += vga666.dtbo
101102
dtbo-$(RPI_DT_OVERLAYS) += w1-gpio.dtbo

arch/arm/boot/dts/overlays/README

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,17 @@ Params: txd1_pin GPIO pin for TXD1 (14, 32 or 40 - default 14)
12151215
rxd1_pin GPIO pin for RXD1 (15, 33 or 41 - default 15)
12161216

12171217

1218+
Name: vc4-fkms-v3d
1219+
Info: Enable Eric Anholt's DRM VC4 V3D driver on top of the dispmanx
1220+
display stack.
1221+
Load: dtoverlay=vc4-fkms-v3d,<param>
1222+
Params: cma-256 CMA is 256MB, 256MB-aligned (needs 1GB)
1223+
cma-192 CMA is 192MB, 256MB-aligned (needs 1GB)
1224+
cma-128 CMA is 128MB, 128MB-aligned
1225+
cma-96 CMA is 96MB, 128MB-aligned
1226+
cma-64 CMA is 64MB, 64MB-aligned
1227+
1228+
12181229
Name: vc4-kms-v3d
12191230
Info: Enable Eric Anholt's DRM VC4 HDMI/HVS/V3D driver. Running startx or
12201231
booting to GUI while this overlay is in use will cause interesting
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* vc4-fkms-v3d-overlay.dts
3+
*/
4+
5+
/dts-v1/;
6+
/plugin/;
7+
8+
/ {
9+
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
10+
11+
fragment@0 {
12+
target-path = "/chosen";
13+
__overlay__ {
14+
bootargs = "cma=256M@256M";
15+
};
16+
};
17+
18+
fragment@1 {
19+
target-path = "/chosen";
20+
__dormant__ {
21+
bootargs = "cma=192M@256M";
22+
};
23+
};
24+
25+
fragment@2 {
26+
target-path = "/chosen";
27+
__dormant__ {
28+
bootargs = "cma=128M@128M";
29+
};
30+
};
31+
32+
fragment@3 {
33+
target-path = "/chosen";
34+
__dormant__ {
35+
bootargs = "cma=96M@128M";
36+
};
37+
};
38+
39+
fragment@4 {
40+
target-path = "/chosen";
41+
__dormant__ {
42+
bootargs = "cma=64M@64M";
43+
};
44+
};
45+
46+
fragment@5 {
47+
target = <&fb>;
48+
__overlay__ {
49+
status = "disabled";
50+
};
51+
};
52+
53+
fragment@6 {
54+
target = <&firmwarekms>;
55+
__overlay__ {
56+
status = "okay";
57+
};
58+
};
59+
60+
fragment@7 {
61+
target = <&v3d>;
62+
__overlay__ {
63+
interrupts = <1 10>;
64+
status = "okay";
65+
};
66+
};
67+
68+
fragment@8 {
69+
target = <&gpu>;
70+
__overlay__ {
71+
status = "okay";
72+
};
73+
};
74+
75+
fragment@9 {
76+
target-path = "/soc/dma";
77+
__overlay__ {
78+
brcm,dma-channel-mask = <0x7f35>;
79+
};
80+
};
81+
82+
__overrides__ {
83+
cma-256 = <0>,"+0-1-2-3-4";
84+
cma-192 = <0>,"-0+1-2-3-4";
85+
cma-128 = <0>,"-0-1+2-3-4";
86+
cma-96 = <0>,"-0-1-2+3-4";
87+
cma-64 = <0>,"-0-1-2-3+4";
88+
};
89+
};

drivers/firmware/raspberrypi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void response_callback(struct mbox_client *cl, void *msg)
4242
* Sends a request to the firmware through the BCM2835 mailbox driver,
4343
* and synchronously waits for the reply.
4444
*/
45-
static int
45+
int
4646
rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data)
4747
{
4848
u32 message = MBOX_MSG(chan, data);
@@ -63,6 +63,7 @@ rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data)
6363

6464
return ret;
6565
}
66+
EXPORT_SYMBOL_GPL(rpi_firmware_transaction);
6667

6768
/**
6869
* rpi_firmware_property_list - Submit firmware property list

drivers/gpu/drm/vc4/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ vc4-y := \
99
vc4_drv.o \
1010
vc4_dpi.o \
1111
vc4_dsi.o \
12+
vc4_firmware_kms.o \
1213
vc4_kms.o \
1314
vc4_gem.o \
1415
vc4_hdmi.o \

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
151151
int vblank_lines;
152152
int ret = 0;
153153

154+
if (vc4->firmware_kms)
155+
return 0;
156+
154157
/*
155158
* XXX Doesn't work well in interlaced mode yet, partially due
156159
* to problems in vc4 kms or drm core interlaced mode handling,
@@ -639,6 +642,11 @@ int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
639642
struct vc4_dev *vc4 = to_vc4_dev(dev);
640643
struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
641644

645+
if (vc4->firmware_kms) {
646+
/* XXX: Can we mask the SMI interrupt? */
647+
return 0;
648+
}
649+
642650
CRTC_WRITE(PV_INTEN, PV_INT_VFP_START);
643651

644652
return 0;
@@ -649,6 +657,11 @@ void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id)
649657
struct vc4_dev *vc4 = to_vc4_dev(dev);
650658
struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
651659

660+
if (vc4->firmware_kms) {
661+
/* XXX: Can we mask the SMI interrupt? */
662+
return;
663+
}
664+
652665
CRTC_WRITE(PV_INTEN, 0);
653666
}
654667

drivers/gpu/drm/vc4/vc4_drv.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index)
4747

4848
static void vc4_drm_preclose(struct drm_device *dev, struct drm_file *file)
4949
{
50+
struct vc4_dev *vc4 = to_vc4_dev(dev);
5051
struct drm_crtc *crtc;
5152

52-
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
53-
vc4_cancel_page_flip(crtc, file);
53+
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
54+
if (vc4->firmware_kms)
55+
vc4_fkms_cancel_page_flip(crtc, file);
56+
else
57+
vc4_cancel_page_flip(crtc, file);
58+
}
5459
}
5560

5661
void vc4_dump_regs32(const struct debugfs_reg32 *regs, unsigned int num_regs,
@@ -331,6 +336,7 @@ static struct platform_driver *const component_drivers[] = {
331336
&vc4_dsi_driver,
332337
&vc4_hvs_driver,
333338
&vc4_crtc_driver,
339+
&vc4_firmware_kms_driver,
334340
&vc4_v3d_driver,
335341
};
336342

drivers/gpu/drm/vc4/vc4_drv.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ struct debugfs_reg32;
1414
struct vc4_dev {
1515
struct drm_device *dev;
1616

17+
bool firmware_kms;
18+
struct rpi_firmware *firmware;
19+
1720
struct vc4_hdmi *hdmi;
1821
struct vc4_hvs *hvs;
1922
struct vc4_crtc *crtc[3];
@@ -461,6 +464,10 @@ int vc4_dpi_debugfs_regs(struct seq_file *m, void *unused);
461464
extern struct platform_driver vc4_dsi_driver;
462465
int vc4_dsi_debugfs_regs(struct seq_file *m, void *unused);
463466

467+
/* vc4_firmware_kms.c */
468+
extern struct platform_driver vc4_firmware_kms_driver;
469+
void vc4_fkms_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
470+
464471
/* vc4_gem.c */
465472
void vc4_gem_init(struct drm_device *dev);
466473
void vc4_gem_destroy(struct drm_device *dev);

0 commit comments

Comments
 (0)