* [PATCH 0/5] Driver for pre-DCP apple display controller.
@ 2024-11-24 22:29 Sasha Finkelstein via B4 Relay
2024-11-24 22:29 ` [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings Sasha Finkelstein via B4 Relay
` (4 more replies)
0 siblings, 5 replies; 32+ messages in thread
From: Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 UTC (permalink / raw)
To: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong,
Jessica Zhang, asahi
Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel,
Sasha Finkelstein, Janne Grunau, Nick Chan
Hi.
This patch series adds support for a secondary display controller
present on Apple M1/M2 chips and used to drive the display of the
"touchbar" touch panel present on those.
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
---
Sasha Finkelstein (5):
dt-bindgins: display: Add Apple pre-DCP display controller bindings
gpu: drm: adp: Add Apple Display Pipe driver
gpu: drm: adp: Add a backlight driver for the Summit LCD
arm64: dts: apple: Add touchbar screen nodes
MAINTAINERS: Add entries for touchbar display driver
.../bindings/display/apple,display-pipe.yaml | 59 ++
.../bindings/display/panel/apple,summit.yaml | 24 +
MAINTAINERS | 2 +
arch/arm64/boot/dts/apple/t8103-j293.dts | 8 +
arch/arm64/boot/dts/apple/t8103.dtsi | 26 +
arch/arm64/boot/dts/apple/t8112-j493.dts | 15 +
arch/arm64/boot/dts/apple/t8112.dtsi | 25 +
drivers/gpu/drm/Kconfig | 2 +
drivers/gpu/drm/Makefile | 1 +
drivers/gpu/drm/adp/Kconfig | 14 +
drivers/gpu/drm/adp/Makefile | 5 +
drivers/gpu/drm/adp/adp_drv.c | 814 +++++++++++++++++++++
drivers/gpu/drm/adp/panel-summit.c | 108 +++
13 files changed, 1103 insertions(+)
---
base-commit: 9f16d5e6f220661f73b36a4be1b21575651d8833
change-id: 20241124-adpdrm-25fce3dd8a71
^ permalink raw reply [flat|nested] 32+ messages in thread* [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings 2024-11-24 22:29 [PATCH 0/5] Driver for pre-DCP apple display controller Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 ` Sasha Finkelstein via B4 Relay 2024-11-25 2:06 ` Rob Herring (Arm) 2024-11-25 7:45 ` Krzysztof Kozlowski 2024-11-24 22:29 ` [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver Sasha Finkelstein via B4 Relay ` (3 subsequent siblings) 4 siblings, 2 replies; 32+ messages in thread From: Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 UTC (permalink / raw) To: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Sasha Finkelstein From: Sasha Finkelstein <fnkl.kernel@gmail.com> Add bindings for a secondary display controller present on certain Apple laptops. Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> --- .../bindings/display/apple,display-pipe.yaml | 59 ++++++++++++++++++++++ .../bindings/display/panel/apple,summit.yaml | 24 +++++++++ 2 files changed, 83 insertions(+) diff --git a/Documentation/devicetree/bindings/display/apple,display-pipe.yaml b/Documentation/devicetree/bindings/display/apple,display-pipe.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bd25ddc6e09dd636c0221c854e594113f6011866 --- /dev/null +++ b/Documentation/devicetree/bindings/display/apple,display-pipe.yaml @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/apple,display-pipe.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple pre-DCP display controller. + +maintainers: + - asahi@lists.linux.dev + - Sasha Finkelstein <fnkl.kernel@gmail.com> + +description: | + A secondary display controller used to drive the "touchbar" on certain + Apple laptops. + +properties: + compatible: + items: + - enum: + - "apple,t8112-display-pipe" + - "apple,t8103-display-pipe" + - const: "apple,h7-display-pipe" + + reg: + minItems: 3 + maxItems: 3 + + reg-names: + items: + - const: be + - const: fe + - const: mipi + + power-domains: true + + interrupts: + minItems: 2 + maxItems: 2 + + interrupt-names: + items: + - const: be + - const: fe + + iommus: true + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +additionalProperties: true + +required: + - compatible + - reg + - interrupts diff --git a/Documentation/devicetree/bindings/display/panel/apple,summit.yaml b/Documentation/devicetree/bindings/display/panel/apple,summit.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dc281c1f52c1ed07cc2f7f804dcfd2f3b4239d89 --- /dev/null +++ b/Documentation/devicetree/bindings/display/panel/apple,summit.yaml @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/apple,summit.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple "Summit" display panel. + +maintainers: + - asahi@lists.linux.dev + - Sasha Finkelstein <fnkl.kernel@gmail.com> + +properties: + compatible: + const: apple,summit + + reg: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg -- 2.47.0 ^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings 2024-11-24 22:29 ` [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings Sasha Finkelstein via B4 Relay @ 2024-11-25 2:06 ` Rob Herring (Arm) 2024-11-25 7:45 ` Krzysztof Kozlowski 1 sibling, 0 replies; 32+ messages in thread From: Rob Herring (Arm) @ 2024-11-25 2:06 UTC (permalink / raw) To: Sasha Finkelstein Cc: Maarten Lankhorst, Maxime Ripard, Conor Dooley, Thomas Zimmermann, asahi, David Airlie, devicetree, Alyssa Rosenzweig, linux-arm-kernel, Jessica Zhang, Krzysztof Kozlowski, Neil Armstrong, Hector Martin, linux-kernel, dri-devel, Simona Vetter, Sven Peter On Sun, 24 Nov 2024 23:29:24 +0100, Sasha Finkelstein wrote: > Add bindings for a secondary display controller present on certain > Apple laptops. > > Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> > --- > .../bindings/display/apple,display-pipe.yaml | 59 ++++++++++++++++++++++ > .../bindings/display/panel/apple,summit.yaml | 24 +++++++++ > 2 files changed, 83 insertions(+) > My bot found errors running 'make dt_binding_check' on your patch: yamllint warnings/errors: ./Documentation/devicetree/bindings/display/apple,display-pipe.yaml:21:9: [warning] wrong indentation: expected 10 but found 8 (indentation) dtschema/dtc warnings/errors: doc reference errors (make refcheckdocs): See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20241124-adpdrm-v1-1-3191d8e6e49a@gmail.com The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema. ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings 2024-11-24 22:29 ` [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings Sasha Finkelstein via B4 Relay 2024-11-25 2:06 ` Rob Herring (Arm) @ 2024-11-25 7:45 ` Krzysztof Kozlowski 2024-11-25 14:14 ` Hector Martin 1 sibling, 1 reply; 32+ messages in thread From: Krzysztof Kozlowski @ 2024-11-25 7:45 UTC (permalink / raw) To: Sasha Finkelstein Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel On Sun, Nov 24, 2024 at 11:29:24PM +0100, Sasha Finkelstein wrote: > Add bindings for a secondary display controller present on certain > Apple laptops. > > Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> > --- > .../bindings/display/apple,display-pipe.yaml | 59 ++++++++++++++++++++++ > .../bindings/display/panel/apple,summit.yaml | 24 +++++++++ > 2 files changed, 83 insertions(+) > > diff --git a/Documentation/devicetree/bindings/display/apple,display-pipe.yaml b/Documentation/devicetree/bindings/display/apple,display-pipe.yaml > new file mode 100644 > index 0000000000000000000000000000000000000000..bd25ddc6e09dd636c0221c854e594113f6011866 > --- /dev/null > +++ b/Documentation/devicetree/bindings/display/apple,display-pipe.yaml No, use fallback compatible as filename. > @@ -0,0 +1,59 @@ > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/display/apple,display-pipe.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Apple pre-DCP display controller. > + > +maintainers: > + - asahi@lists.linux.dev > + - Sasha Finkelstein <fnkl.kernel@gmail.com> > + > +description: | Drop | > + A secondary display controller used to drive the "touchbar" on certain > + Apple laptops. > + > +properties: > + compatible: > + items: > + - enum: > + - "apple,t8112-display-pipe" > + - "apple,t8103-display-pipe" > + - const: "apple,h7-display-pipe" This wasn't tested... Drop all quotes. Do you see any file with quotes? Why doing things entirely different than everyone else? > + > + reg: > + minItems: 3 Drop > + maxItems: 3 > + > + reg-names: > + items: > + - const: be > + - const: fe > + - const: mipi > + > + power-domains: true List the items instead or maxItems: 1. > + > + interrupts: > + minItems: 2 Drop > + maxItems: 2 > + > + interrupt-names: > + items: > + - const: be > + - const: fe > + > + iommus: true maxItems: 1 > + > + "#address-cells": > + const: 1 > + > + "#size-cells": > + const: 0 > + > +additionalProperties: true This cannot be true. Must be false. > + > +required: > + - compatible > + - reg > + - interrupts This goes before additionalProperties. Missing example: that's a strong NAK and prove that this could not be even tested. Do you see any device schema without example? No. Do not develop things differently, Apple is not unique, special or exceptional. > diff --git a/Documentation/devicetree/bindings/display/panel/apple,summit.yaml b/Documentation/devicetree/bindings/display/panel/apple,summit.yaml > new file mode 100644 > index 0000000000000000000000000000000000000000..dc281c1f52c1ed07cc2f7f804dcfd2f3b4239d89 > --- /dev/null > +++ b/Documentation/devicetree/bindings/display/panel/apple,summit.yaml > @@ -0,0 +1,24 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/display/panel/apple,summit.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Apple "Summit" display panel. > + > +maintainers: > + - asahi@lists.linux.dev > + - Sasha Finkelstein <fnkl.kernel@gmail.com> > + > +properties: > + compatible: > + const: apple,summit No, too generic. Panels need much more properties, this is heavily incomplete. See other panel bindings. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings 2024-11-25 7:45 ` Krzysztof Kozlowski @ 2024-11-25 14:14 ` Hector Martin 2024-11-25 14:53 ` Krzysztof Kozlowski 0 siblings, 1 reply; 32+ messages in thread From: Hector Martin @ 2024-11-25 14:14 UTC (permalink / raw) To: Krzysztof Kozlowski, Sasha Finkelstein Cc: Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel On 2024/11/25 16:45, Krzysztof Kozlowski wrote: > On Sun, Nov 24, 2024 at 11:29:24PM +0100, Sasha Finkelstein wrote: >> Add bindings for a secondary display controller present on certain >> Apple laptops. >> >> Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> >> --- >> .../bindings/display/apple,display-pipe.yaml | 59 ++++++++++++++++++++++ >> .../bindings/display/panel/apple,summit.yaml | 24 +++++++++ >> 2 files changed, 83 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/display/apple,display-pipe.yaml b/Documentation/devicetree/bindings/display/apple,display-pipe.yaml >> new file mode 100644 >> index 0000000000000000000000000000000000000000..bd25ddc6e09dd636c0221c854e594113f6011866 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/display/apple,display-pipe.yaml > > No, use fallback compatible as filename. > >> @@ -0,0 +1,59 @@ >> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) >> +%YAML 1.2 >> +--- >> +$id: http://devicetree.org/schemas/display/apple,display-pipe.yaml# >> +$schema: http://devicetree.org/meta-schemas/core.yaml# >> + >> +title: Apple pre-DCP display controller. >> + >> +maintainers: >> + - asahi@lists.linux.dev >> + - Sasha Finkelstein <fnkl.kernel@gmail.com> >> + >> +description: | > > Drop | > >> + A secondary display controller used to drive the "touchbar" on certain >> + Apple laptops. >> + >> +properties: >> + compatible: >> + items: >> + - enum: >> + - "apple,t8112-display-pipe" >> + - "apple,t8103-display-pipe" >> + - const: "apple,h7-display-pipe" > > > This wasn't tested... Drop all quotes. Do you see any file with quotes? > Why doing things entirely different than everyone else? > >> + >> + reg: >> + minItems: 3 > > Drop > >> + maxItems: 3 >> + >> + reg-names: >> + items: >> + - const: be >> + - const: fe >> + - const: mipi >> + >> + power-domains: true > > List the items instead or maxItems: 1. > >> + >> + interrupts: >> + minItems: 2 > > Drop > >> + maxItems: 2 >> + >> + interrupt-names: >> + items: >> + - const: be >> + - const: fe >> + >> + iommus: true > > > maxItems: 1 > >> + >> + "#address-cells": >> + const: 1 >> + >> + "#size-cells": >> + const: 0 >> + >> +additionalProperties: true > > This cannot be true. Must be false. > >> + >> +required: >> + - compatible >> + - reg >> + - interrupts > > This goes before additionalProperties. > > Missing example: that's a strong NAK and prove that this could not be > even tested. > > Do you see any device schema without example? No. Do not develop things > differently, Apple is not unique, special or exceptional. Krzysztof, it is entirely possible to express this same feedback without being condescending and rude. I'm pretty sure you can do better than this. > > >> diff --git a/Documentation/devicetree/bindings/display/panel/apple,summit.yaml b/Documentation/devicetree/bindings/display/panel/apple,summit.yaml >> new file mode 100644 >> index 0000000000000000000000000000000000000000..dc281c1f52c1ed07cc2f7f804dcfd2f3b4239d89 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/display/panel/apple,summit.yaml >> @@ -0,0 +1,24 @@ >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >> +%YAML 1.2 >> +--- >> +$id: http://devicetree.org/schemas/display/panel/apple,summit.yaml# >> +$schema: http://devicetree.org/meta-schemas/core.yaml# >> + >> +title: Apple "Summit" display panel. >> + >> +maintainers: >> + - asahi@lists.linux.dev >> + - Sasha Finkelstein <fnkl.kernel@gmail.com> >> + >> +properties: >> + compatible: >> + const: apple,summit > > No, too generic. Panels need much more properties, this is heavily > incomplete. See other panel bindings. > > Best regards, > Krzysztof > > > - Hector ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings 2024-11-25 14:14 ` Hector Martin @ 2024-11-25 14:53 ` Krzysztof Kozlowski 2024-11-25 15:29 ` Hector Martin 0 siblings, 1 reply; 32+ messages in thread From: Krzysztof Kozlowski @ 2024-11-25 14:53 UTC (permalink / raw) To: Hector Martin, Sasha Finkelstein Cc: Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel On 25/11/2024 15:14, Hector Martin wrote: >>> + >>> + "#address-cells": >>> + const: 1 >>> + >>> + "#size-cells": >>> + const: 0 >>> + >>> +additionalProperties: true >> >> This cannot be true. Must be false. >> >>> + >>> +required: >>> + - compatible >>> + - reg >>> + - interrupts >> >> This goes before additionalProperties. >> >> Missing example: that's a strong NAK and prove that this could not be >> even tested. >> >> Do you see any device schema without example? No. Do not develop things >> differently, Apple is not unique, special or exceptional. > > Krzysztof, it is entirely possible to express this same feedback without > being condescending and rude. I'm pretty sure you can do better than this. Please kindly trim the replies from unnecessary context. It makes it much easier to find new content. Instead of patronizing, note that this was just pure observation - this was done entirely than other bindings, which should be taken as an example. Or example-schema should be taken as example... Pointing out issues and inconsistencies is not rude or condescending. Basically now you are condescending people's feedback which further restricts review process allowing comments which you approve. You got here one day review, enjoy that. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings 2024-11-25 14:53 ` Krzysztof Kozlowski @ 2024-11-25 15:29 ` Hector Martin 0 siblings, 0 replies; 32+ messages in thread From: Hector Martin @ 2024-11-25 15:29 UTC (permalink / raw) To: Krzysztof Kozlowski, Sasha Finkelstein Cc: Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel On 2024/11/25 23:53, Krzysztof Kozlowski wrote: > On 25/11/2024 15:14, Hector Martin wrote: >>>> + >>>> + "#address-cells": >>>> + const: 1 >>>> + >>>> + "#size-cells": >>>> + const: 0 >>>> + >>>> +additionalProperties: true >>> >>> This cannot be true. Must be false. >>> >>>> + >>>> +required: >>>> + - compatible >>>> + - reg >>>> + - interrupts >>> >>> This goes before additionalProperties. >>> >>> Missing example: that's a strong NAK and prove that this could not be >>> even tested. >>> >>> Do you see any device schema without example? No. Do not develop things >>> differently, Apple is not unique, special or exceptional. >> >> Krzysztof, it is entirely possible to express this same feedback without >> being condescending and rude. I'm pretty sure you can do better than this. > > Please kindly trim the replies from unnecessary context. It makes it > much easier to find new content. Noted. > Instead of patronizing, note that this was just pure observation - this > was done entirely than other bindings, which should be taken as an > example. Or example-schema should be taken as example... Pointing out > issues and inconsistencies is not rude or condescending. Basically now > you are condescending people's feedback which further restricts review > process allowing comments which you approve. > No, that was certainly not pure observation. The observation is that the schema was inconsistent with other schemas, and was missing an example. The way you *expressed* that observation was unnecessarily rude and condescending, both in tone and message. Usage of "NAK" is strongly confrontational and discouraging to newcomers, and completely inappropriate here because the intent of the patch is clearly fine and it just needs some style and procedural issues fixed. "Do you ...? No." wording is condescending, like you're talking down to a child. The gratuitous Apple reference is completely unnecessary, implying we're attempting to be a special snowflake in any (non-technically-justified) way, never mind that none of us works nor has any professional relationship with Apple. Your observation and feedback could have been conveyed much more appropriately, kindly, and effectively, such as: == The schema is missing an example. Examples are required for schemas, as they are part of how the schema is tested by the automated tooling. Please see other schemas and `example-schema.yaml` for examples on how to do this, and `writing-schema.rst` for more information and how to run the checks. == - Hector ^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-24 22:29 [PATCH 0/5] Driver for pre-DCP apple display controller Sasha Finkelstein via B4 Relay 2024-11-24 22:29 ` [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 ` Sasha Finkelstein via B4 Relay 2024-11-25 8:50 ` Neil Armstrong ` (2 more replies) 2024-11-24 22:29 ` [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD Sasha Finkelstein via B4 Relay ` (2 subsequent siblings) 4 siblings, 3 replies; 32+ messages in thread From: Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 UTC (permalink / raw) To: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Sasha Finkelstein, Janne Grunau From: Sasha Finkelstein <fnkl.kernel@gmail.com> This display controller is present on M-series chips and is used to drive the touchbar display. Co-developed-by: Janne Grunau <j@jannau.net> Signed-off-by: Janne Grunau <j@jannau.net> Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> --- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/adp/Kconfig | 14 + drivers/gpu/drm/adp/Makefile | 5 + drivers/gpu/drm/adp/adp_drv.c | 814 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 836 insertions(+) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 5504721007cc190e7d768d42aa9633baa0115f5e..acd1111f1773ef044c306c62ad9f850996259ef1 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -499,6 +499,8 @@ source "drivers/gpu/drm/mcde/Kconfig" source "drivers/gpu/drm/tidss/Kconfig" +source "drivers/gpu/drm/adp/Kconfig" + source "drivers/gpu/drm/xlnx/Kconfig" source "drivers/gpu/drm/gud/Kconfig" diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 463afad1b5ca6275e61223adc8ca036c3d4d6b03..acd8d8943ef2bf85c80db7c218c59a7ec2df56da 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -213,6 +213,7 @@ obj-y += mxsfb/ obj-y += tiny/ obj-$(CONFIG_DRM_PL111) += pl111/ obj-$(CONFIG_DRM_TVE200) += tve200/ +obj-$(CONFIG_DRM_ADP) += adp/ obj-$(CONFIG_DRM_XEN) += xen/ obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/ obj-$(CONFIG_DRM_LIMA) += lima/ diff --git a/drivers/gpu/drm/adp/Kconfig b/drivers/gpu/drm/adp/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..3c570aeb14700611edd7e2738367090ebb30c346 --- /dev/null +++ b/drivers/gpu/drm/adp/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only OR MIT +config DRM_ADP + tristate "DRM Support for pre-DCP Apple display controllers" + depends on DRM && OF && ARM64 + depends on ARCH_APPLE || COMPILE_TEST + select DRM_KMS_HELPER + select DRM_KMS_DMA_HELPER + select DRM_GEM_DMA_HELPER + select VIDEOMODE_HELPERS + select DRM_MIPI_DSI + help + Chose this option if you have an Apple Arm laptop with a touchbar. + + If M is selected, this module will be called adpdrm. diff --git a/drivers/gpu/drm/adp/Makefile b/drivers/gpu/drm/adp/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..28a5d4b4a267f3e2abe9f0ea9e11fae51ca18b88 --- /dev/null +++ b/drivers/gpu/drm/adp/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only OR MIT + +adpdrm-y := adp_drv.o +obj-$(CONFIG_DRM_ADP) += adpdrm.o +obj-$(CONFIG_DRM_ADP) += panel-summit.o diff --git a/drivers/gpu/drm/adp/adp_drv.c b/drivers/gpu/drm/adp/adp_drv.c new file mode 100644 index 0000000000000000000000000000000000000000..36510194e18161ef6514885c764b2e7085c587e5 --- /dev/null +++ b/drivers/gpu/drm/adp/adp_drv.c @@ -0,0 +1,814 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/anon_inodes.h> +#include <linux/dma-mapping.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/file.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/types.h> + +#include <asm/current.h> + +#include <drm/drm_atomic.h> +#include <drm/drm_atomic_helper.h> +#include <drm/drm_damage_helper.h> +#include <drm/drm_device.h> +#include <drm/drm_drv.h> +#include <drm/drm_edid.h> +#include <drm/drm_fb_dma_helper.h> +#include <drm/drm_file.h> +#include <drm/drm_framebuffer.h> +#include <drm/drm_gem_atomic_helper.h> +#include <drm/drm_gem_dma_helper.h> +#include <drm/drm_gem_framebuffer_helper.h> +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_probe_helper.h> +#include <drm/drm_simple_kms_helper.h> +#include <drm/drm_vblank.h> + +#define ADP_INT_STATUS 0x34 +#define ADP_INT_STATUS_INT_MASK 0x7 +#define ADP_INT_STATUS_VBLANK 0x1 +#define ADP_CTRL 0x100 +#define ADP_CTRL_VBLANK_ON 0x12 +#define ADP_CTRL_FIFO_ON 0x601 +#define ADP_SCREEN_SIZE 0x0c +#define ADP_SCREEN_HSIZE GENMASK(15, 0) +#define ADP_SCREEN_VSIZE GENMASK(31, 16) + +#define ADBE_FIFO 0x10c0 +#define ADBE_FIFO_SYNC 0xc0000000 + +#define ADBE_BLEND_BYPASS 0x2020 +#define ADBE_BLEND_EN1 0x2028 +#define ADBE_BLEND_EN2 0x2074 +#define ADBE_BLEND_EN3 0x202c +#define ADBE_BLEND_EN4 0x2034 +#define ADBE_MASK_BUF 0x2200 + +#define ADBE_SRC_START 0x4040 +#define ADBE_SRC_SIZE 0x4048 +#define ADBE_DST_START 0x4050 +#define ADBE_DST_SIZE 0x4054 +#define ADBE_STRIDE 0x4038 +#define ADBE_FB_BASE 0x4030 + +#define ADBE_LAYER_EN1 0x4020 +#define ADBE_LAYER_EN2 0x4068 +#define ADBE_LAYER_EN3 0x40b4 +#define ADBE_LAYER_EN4 0x40f4 +#define ADBE_SCALE_CTL 0x40ac +#define ADBE_SCALE_CTL_BYPASS 0x100000 + +#define ADBE_LAYER_CTL 0x1038 +#define ADBE_LAYER_CTL_ENABLE 0x10000 + +#define ADBE_PIX_FMT 0x402c +#define ADBE_PIX_FMT_XRGB32 0x53e4001 + +#define DSI_GEN_HDR 0x6c +#define DSI_GEN_PLD_DATA 0x70 + +#define DSI_CMD_PKT_STATUS 0x74 + +#define GEN_PLD_R_EMPTY BIT(4) +#define GEN_PLD_W_FULL BIT(3) +#define GEN_PLD_W_EMPTY BIT(2) +#define GEN_CMD_FULL BIT(1) +#define GEN_CMD_EMPTY BIT(0) +#define GEN_RD_CMD_BUSY BIT(6) +#define CMD_PKT_STATUS_TIMEOUT_US 20000 + +static int adp_open(struct inode *inode, struct file *filp) +{ + /* + * The modesetting driver does not check the non-desktop connector + * property and keeps the device open and locked. If the touchbar daemon + * opens the device first modesetting breaks the whole X session. + * Simply refuse to open the device for X11 server processes as + * workaround. + */ + if (current->comm[0] == 'X') + return -EBUSY; + + return drm_open(inode, filp); +} + +static const struct file_operations adp_fops = { + .owner = THIS_MODULE, + .open = adp_open, + .release = drm_release, + .unlocked_ioctl = drm_ioctl, + .compat_ioctl = drm_compat_ioctl, + .poll = drm_poll, + .read = drm_read, + .llseek = noop_llseek, + .mmap = drm_gem_mmap, + .fop_flags = FOP_UNSIGNED_OFFSET, + DRM_GEM_DMA_UNMAPPED_AREA_FOPS +}; + +static int adp_drm_gem_dumb_create(struct drm_file *file_priv, + struct drm_device *drm, + struct drm_mode_create_dumb *args) +{ + args->height = ALIGN(args->height, 64); + args->size = args->pitch * args->height; + + return drm_gem_dma_dumb_create_internal(file_priv, drm, args); +} + +static const struct drm_driver adp_driver = { + .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, + .fops = &adp_fops, + DRM_GEM_DMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE(adp_drm_gem_dumb_create), + .name = "adp", + .desc = "Apple Display Pipe DRM Driver", + .date = "20230412", + .major = 0, + .minor = 1, +}; + +struct adp_drv_private { + struct drm_device drm; + struct drm_crtc crtc; + struct drm_encoder encoder; + struct drm_connector connector; + struct mipi_dsi_host dsi; + void __iomem *be; + void __iomem *fe; + void __iomem *mipi; + u32 *mask_buf; + u64 mask_buf_size; + dma_addr_t mask_iova; + int be_irq; + int fe_irq; + spinlock_t irq_lock; + struct drm_pending_vblank_event *event; +}; + +struct adp_plane { + struct drm_plane base_plane; + u8 id; +}; + +#define to_adp(x) container_of(x, struct adp_drv_private, drm) +#define crtc_to_adp(x) container_of(x, struct adp_drv_private, crtc) +#define conn_to_adp(x) container_of(x, struct adp_drv_private, connector) +#define mipi_to_adp(x) container_of(x, struct adp_drv_private, dsi) + +static int adp_plane_atomic_check(struct drm_plane *plane, + struct drm_atomic_state *state) +{ + struct drm_plane_state *new_plane_state; + struct drm_crtc_state *crtc_state; + + new_plane_state = drm_atomic_get_new_plane_state(state, plane); + + if (!new_plane_state->crtc) + return 0; + + crtc_state = drm_atomic_get_crtc_state(state, new_plane_state->crtc); + if (IS_ERR(crtc_state)) + return PTR_ERR(crtc_state); + return drm_atomic_helper_check_plane_state(new_plane_state, + crtc_state, + DRM_PLANE_NO_SCALING, + DRM_PLANE_NO_SCALING, + true, true); +} + +static void adp_plane_atomic_update(struct drm_plane *plane, + struct drm_atomic_state *state) +{ + struct adp_drv_private *adp; + struct drm_rect src_rect; + struct drm_gem_dma_object *obj; + struct drm_framebuffer *fb; + struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); + u32 src_pos, src_size, dst_pos, dst_size; + + if (!plane || !new_state) + return; + + fb = new_state->fb; + if (!fb) + return; + adp = to_adp(plane->dev); + + drm_rect_fp_to_int(&src_rect, &new_state->src); + src_pos = src_rect.x1 << 16 | src_rect.y1; + dst_pos = new_state->dst.x1 << 16 | new_state->dst.y1; + src_size = drm_rect_width(&src_rect) << 16 | drm_rect_height(&src_rect); + dst_size = drm_rect_width(&new_state->dst) << 16 | + drm_rect_height(&new_state->dst); + writel(src_pos, adp->be + ADBE_SRC_START); + writel(src_size, adp->be + ADBE_SRC_SIZE); + writel(dst_pos, adp->be + ADBE_DST_START); + writel(dst_size, adp->be + ADBE_DST_SIZE); + writel(fb->pitches[0], adp->be + ADBE_STRIDE); + obj = drm_fb_dma_get_gem_obj(fb, 0); + if (obj) + writel(obj->dma_addr + fb->offsets[0], adp->be + ADBE_FB_BASE); + + writel(0x1, adp->be + ADBE_LAYER_EN1); + writel(0x1, adp->be + ADBE_LAYER_EN2); + writel(0x1, adp->be + ADBE_LAYER_EN3); + writel(0x1, adp->be + ADBE_LAYER_EN4); + writel(ADBE_SCALE_CTL_BYPASS, adp->be + ADBE_SCALE_CTL); + writel(ADBE_LAYER_CTL_ENABLE | 0x1, adp->be + ADBE_LAYER_CTL); + writel(ADBE_PIX_FMT_XRGB32, adp->be + ADBE_PIX_FMT); + +} + +static void adp_plane_atomic_disable(struct drm_plane *plane, + struct drm_atomic_state *state) +{ + struct adp_drv_private *adp = to_adp(plane->dev); + + writel(0x0, adp->be + ADBE_LAYER_EN1); + writel(0x0, adp->be + ADBE_LAYER_EN2); + writel(0x0, adp->be + ADBE_LAYER_EN3); + writel(0x0, adp->be + ADBE_LAYER_EN4); + writel(ADBE_LAYER_CTL_ENABLE, adp->be + ADBE_LAYER_CTL); +} + +static const struct drm_plane_helper_funcs adp_plane_helper_funcs = { + .atomic_check = adp_plane_atomic_check, + .atomic_update = adp_plane_atomic_update, + .atomic_disable = adp_plane_atomic_disable, + DRM_GEM_SHADOW_PLANE_HELPER_FUNCS +}; + +static const struct drm_plane_funcs adp_plane_funcs = { + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, + DRM_GEM_SHADOW_PLANE_FUNCS +}; + +static const u32 plane_formats[] = { + DRM_FORMAT_XRGB8888, +}; + +#define ALL_CRTCS 1 + +static struct adp_plane *adp_plane_new(struct adp_drv_private *adp, u8 id) +{ + struct drm_device *drm = &adp->drm; + struct adp_plane *plane; + enum drm_plane_type plane_type; + + plane_type = (id == 0) ? DRM_PLANE_TYPE_PRIMARY : + DRM_PLANE_TYPE_OVERLAY; + + plane = drmm_universal_plane_alloc(drm, struct adp_plane, base_plane, + ALL_CRTCS, &adp_plane_funcs, + plane_formats, ARRAY_SIZE(plane_formats), + NULL, plane_type, "plane %d", id); + if (!plane) { + drm_err(drm, "failed to allocate plane"); + return ERR_PTR(-ENOMEM); + } + plane->id = id; + + drm_plane_helper_add(&plane->base_plane, &adp_plane_helper_funcs); + return plane; +} + +static void adp_enable_vblank(struct adp_drv_private *adp) +{ + u32 cur_ctrl; + + writel(ADP_INT_STATUS_INT_MASK, adp->fe + ADP_INT_STATUS); + + cur_ctrl = readl(adp->fe + ADP_CTRL); + writel(cur_ctrl | ADP_CTRL_VBLANK_ON, adp->fe + ADP_CTRL); +} + +static int adp_crtc_enable_vblank(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct adp_drv_private *adp = to_adp(dev); + + adp_enable_vblank(adp); + + return 0; +} + +static void adp_disable_vblank(struct adp_drv_private *adp) +{ + u32 cur_ctrl; + + cur_ctrl = readl(adp->fe + ADP_CTRL); + writel(cur_ctrl & ~ADP_CTRL_VBLANK_ON, adp->fe + ADP_CTRL); + writel(ADP_INT_STATUS_INT_MASK, adp->fe + ADP_INT_STATUS); +} + +static void adp_crtc_disable_vblank(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct adp_drv_private *adp = to_adp(dev); + + adp_disable_vblank(adp); +} + + +static void adp_crtc_atomic_enable(struct drm_crtc *crtc, + struct drm_atomic_state *state) +{ + struct adp_drv_private *adp = crtc_to_adp(crtc); + + writel(0x1, adp->be + ADBE_BLEND_EN2); + writel(0x10, adp->be + ADBE_BLEND_EN1); + writel(0x1, adp->be + ADBE_BLEND_EN3); + writel(0x1, adp->be + ADBE_BLEND_BYPASS); + writel(0x1, adp->be + ADBE_BLEND_EN4); +} + +static void adp_crtc_atomic_disable(struct drm_crtc *crtc, + struct drm_atomic_state *state) +{ + struct adp_drv_private *adp = crtc_to_adp(crtc); + struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc); + + drm_atomic_helper_disable_planes_on_crtc(old_state, false); + + writel(0x0, adp->be + ADBE_BLEND_EN2); + writel(0x0, adp->be + ADBE_BLEND_EN1); + writel(0x0, adp->be + ADBE_BLEND_EN3); + writel(0x0, adp->be + ADBE_BLEND_BYPASS); + writel(0x0, adp->be + ADBE_BLEND_EN4); + drm_crtc_vblank_off(crtc); +} + +static void adp_crtc_atomic_flush(struct drm_crtc *crtc, + struct drm_atomic_state *state) +{ + u32 frame_num = 1; + struct adp_drv_private *adp = crtc_to_adp(crtc); + struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc); + u64 new_size = ALIGN(new_state->mode.hdisplay * + new_state->mode.vdisplay * 4, PAGE_SIZE); + + if (new_size != adp->mask_buf_size) { + if (adp->mask_buf) + dma_free_coherent(crtc->dev->dev, adp->mask_buf_size, + adp->mask_buf, adp->mask_iova); + adp->mask_buf = NULL; + if (new_size != 0) { + adp->mask_buf = dma_alloc_coherent(crtc->dev->dev, new_size, + &adp->mask_iova, GFP_KERNEL); + memset(adp->mask_buf, 0xFF, new_size); + writel(adp->mask_iova, adp->be + ADBE_MASK_BUF); + } + adp->mask_buf_size = new_size; + } + writel(ADBE_FIFO_SYNC | frame_num, adp->be + ADBE_FIFO); + //FIXME: use adbe flush interrupt + spin_lock_irq(&crtc->dev->event_lock); + if (crtc->state->event) { + drm_crtc_vblank_get(crtc); + adp->event = crtc->state->event; + } + crtc->state->event = NULL; + spin_unlock_irq(&crtc->dev->event_lock); +} + +static const struct drm_crtc_funcs adp_crtc_funcs = { + .destroy = drm_crtc_cleanup, + .set_config = drm_atomic_helper_set_config, + .page_flip = drm_atomic_helper_page_flip, + .reset = drm_atomic_helper_crtc_reset, + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, + .enable_vblank = adp_crtc_enable_vblank, + .disable_vblank = adp_crtc_disable_vblank, +}; + + +static const struct drm_crtc_helper_funcs adp_crtc_helper_funcs = { + .atomic_enable = adp_crtc_atomic_enable, + .atomic_disable = adp_crtc_atomic_disable, + .atomic_flush = adp_crtc_atomic_flush, +}; + +static int adp_setup_crtc(struct adp_drv_private *adp) +{ + struct drm_device *drm = &adp->drm; + struct adp_plane *primary; + int ret; + + primary = adp_plane_new(adp, 0); + if (IS_ERR(primary)) + return PTR_ERR(primary); + + ret = drm_crtc_init_with_planes(drm, &adp->crtc, &primary->base_plane, + NULL, &adp_crtc_funcs, NULL); + if (ret) + return ret; + + drm_crtc_helper_add(&adp->crtc, &adp_crtc_helper_funcs); + return 0; +} + +static int adp_get_modes(struct drm_connector *connector) +{ + struct adp_drv_private *adp = conn_to_adp(connector); + struct drm_display_mode *mode; + u32 size; + + size = readl(adp->fe + ADP_SCREEN_SIZE); + mode = drm_mode_create(connector->dev); + + mode->vdisplay = FIELD_GET(ADP_SCREEN_VSIZE, size); + mode->hdisplay = FIELD_GET(ADP_SCREEN_HSIZE, size); + mode->hsync_start = mode->hdisplay + 8; + mode->hsync_end = mode->hsync_start + 80; + mode->htotal = mode->hsync_end + 40; + mode->vsync_start = mode->vdisplay + 1; + mode->vsync_end = mode->vsync_start + 15; + mode->vtotal = mode->vsync_end + 6; + mode->clock = (mode->vtotal * mode->htotal * 60) / 1000; + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; + mode->flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC; + drm_mode_set_name(mode); + drm_mode_probed_add(connector, mode); + return 1; +} + +static int adp_detect_ctx(struct drm_connector *connector, + struct drm_modeset_acquire_ctx *ctx, + bool force) +{ + connector->display_info.non_desktop = true; + drm_object_property_set_value(&connector->base, + connector->dev->mode_config.non_desktop_property, + connector->display_info.non_desktop); + return connector_status_connected; +} + +static const struct drm_connector_funcs adp_connector_funcs = { + .fill_modes = drm_helper_probe_single_connector_modes, + .destroy = drm_connector_cleanup, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +}; + +static const struct drm_connector_helper_funcs adp_connector_helper_funcs = { + .get_modes = adp_get_modes, + .detect_ctx = adp_detect_ctx, +}; + +static const struct drm_mode_config_funcs adp_mode_config_funcs = { + .fb_create = drm_gem_fb_create_with_dirty, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, +}; + +static int adp_setup_mode_config(struct adp_drv_private *adp) +{ + struct drm_device *drm = &adp->drm; + int ret; + u32 size; + + ret = drmm_mode_config_init(drm); + if (ret) + return ret; + + /* + * Query screen size restrict the frame buffer size to the screen size + * aligned to the next multiple of 64. This is not necessary but can be + * used as simple check for non-desktop devices. + * Xorg's modesetting driver does not care about the connector + * "non-desktop" property. The max frame buffer width or height can be + * easily checked and a device can be reject if the max width/height is + * smaller than 120 for example. + * Any touchbar daemon is not limited by this small framebuffer size. + */ + size = readl(adp->fe + ADP_SCREEN_SIZE); + + drm->mode_config.min_width = 32; + drm->mode_config.min_height = 32; + drm->mode_config.max_width = ALIGN(FIELD_GET(ADP_SCREEN_HSIZE, size), 64); + drm->mode_config.max_height = ALIGN(FIELD_GET(ADP_SCREEN_VSIZE, size), 64); + drm->mode_config.preferred_depth = 24; + drm->mode_config.prefer_shadow = 0; + drm->mode_config.funcs = &adp_mode_config_funcs; + + ret = adp_setup_crtc(adp); + if (ret) { + drm_err(drm, "failed to create crtc"); + return ret; + } + + adp->encoder.possible_crtcs = ALL_CRTCS; + ret = drm_simple_encoder_init(drm, &adp->encoder, DRM_MODE_ENCODER_DSI); + if (ret) { + drm_err(drm, "failed to init encoder"); + return ret; + } + drm_connector_helper_add(&adp->connector, + &adp_connector_helper_funcs); + ret = drm_connector_init(drm, &adp->connector, &adp_connector_funcs, + DRM_MODE_CONNECTOR_DSI); + if (ret) + return ret; + + drm_connector_attach_encoder(&adp->connector, &adp->encoder); + + ret = drm_vblank_init(drm, drm->mode_config.num_crtc); + if (ret < 0) { + drm_err(drm, "failed to initialize vblank"); + return ret; + } + + drm_mode_config_reset(drm); + + return 0; +} + +static int adp_parse_of(struct platform_device *pdev, struct adp_drv_private *adp) +{ + adp->be = devm_platform_ioremap_resource_byname(pdev, "be"); + if (IS_ERR(adp->be)) { + dev_err(&pdev->dev, "failed to map display backend mmio"); + return PTR_ERR(adp->be); + } + + adp->fe = devm_platform_ioremap_resource_byname(pdev, "fe"); + if (IS_ERR(adp->fe)) { + dev_err(&pdev->dev, "failed to map display pipe mmio"); + return PTR_ERR(adp->fe); + } + + adp->mipi = devm_platform_ioremap_resource_byname(pdev, "mipi"); + if (IS_ERR(adp->mipi)) { + dev_err(&pdev->dev, "failed to map mipi mmio"); + return PTR_ERR(adp->mipi); + } + + adp->be_irq = platform_get_irq_byname(pdev, "be"); + if (adp->be_irq < 0) { + dev_err(&pdev->dev, "failed to find be irq"); + return adp->be_irq; + } + + adp->fe_irq = platform_get_irq_byname(pdev, "fe"); + if (adp->fe_irq < 0) { + dev_err(&pdev->dev, "failed to find fe irq"); + return adp->fe_irq; + } + return 0; +} + + +static int adp_dsi_gen_pkt_hdr_write(struct adp_drv_private *adp, u32 hdr_val) +{ + int ret; + u32 val, mask; + + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, + val, !(val & GEN_CMD_FULL), 1000, + CMD_PKT_STATUS_TIMEOUT_US); + if (ret) { + dev_err(adp->drm.dev, "failed to get available command FIFO\n"); + return ret; + } + + writel(hdr_val, adp->mipi + DSI_GEN_HDR); + + mask = GEN_CMD_EMPTY | GEN_PLD_W_EMPTY; + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, + val, (val & mask) == mask, + 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret) { + dev_err(adp->drm.dev, "failed to write command FIFO\n"); + return ret; + } + + return 0; +} + +static int adp_dsi_write(struct adp_drv_private *adp, + const struct mipi_dsi_packet *packet) +{ + const u8 *tx_buf = packet->payload; + int len = packet->payload_length, pld_data_bytes = sizeof(u32), ret; + __le32 word; + u32 val; + + while (len) { + if (len < pld_data_bytes) { + word = 0; + memcpy(&word, tx_buf, len); + writel(le32_to_cpu(word), adp->mipi + DSI_GEN_PLD_DATA); + len = 0; + } else { + memcpy(&word, tx_buf, pld_data_bytes); + writel(le32_to_cpu(word), adp->mipi + DSI_GEN_PLD_DATA); + tx_buf += pld_data_bytes; + len -= pld_data_bytes; + } + + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, + val, !(val & GEN_PLD_W_FULL), 1000, + CMD_PKT_STATUS_TIMEOUT_US); + if (ret) { + dev_err(adp->drm.dev, + "failed to get available write payload FIFO\n"); + return ret; + } + } + + word = 0; + memcpy(&word, packet->header, sizeof(packet->header)); + return adp_dsi_gen_pkt_hdr_write(adp, le32_to_cpu(word)); +} + +static int adp_dsi_read(struct adp_drv_private *adp, + const struct mipi_dsi_msg *msg) +{ + int i, j, ret, len = msg->rx_len; + u8 *buf = msg->rx_buf; + u32 val; + + /* Wait end of the read operation */ + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, + val, !(val & GEN_RD_CMD_BUSY), + 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret) { + dev_err(adp->drm.dev, "Timeout during read operation\n"); + return ret; + } + + for (i = 0; i < len; i += 4) { + /* Read fifo must not be empty before all bytes are read */ + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, + val, !(val & GEN_PLD_R_EMPTY), + 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret) { + dev_err(adp->drm.dev, "Read payload FIFO is empty\n"); + return ret; + } + + val = readl(adp->mipi + DSI_GEN_PLD_DATA); + for (j = 0; j < 4 && j + i < len; j++) + buf[i + j] = val >> (8 * j); + } + + return ret; +} + +static ssize_t adp_dsi_host_transfer(struct mipi_dsi_host *host, + const struct mipi_dsi_msg *msg) +{ + struct adp_drv_private *adp = mipi_to_adp(host); + struct mipi_dsi_packet packet; + int ret, nb_bytes; + + ret = mipi_dsi_create_packet(&packet, msg); + if (ret) { + dev_err(adp->drm.dev, "failed to create packet: %d\n", ret); + return ret; + } + + ret = adp_dsi_write(adp, &packet); + if (ret) + return ret; + + if (msg->rx_buf && msg->rx_len) { + ret = adp_dsi_read(adp, msg); + if (ret) + return ret; + nb_bytes = msg->rx_len; + } else { + nb_bytes = packet.size; + } + + return nb_bytes; +} + +static int adp_dsi_host_attach(struct mipi_dsi_host *host, + struct mipi_dsi_device *dev) +{ + return 0; +} + +static int adp_dsi_host_detach(struct mipi_dsi_host *host, + struct mipi_dsi_device *dev) +{ + return 0; +} + +static const struct mipi_dsi_host_ops adp_dsi_host_ops = { + .transfer = adp_dsi_host_transfer, + .attach = adp_dsi_host_attach, + .detach = adp_dsi_host_detach, +}; + +static irqreturn_t adp_fe_irq(int irq, void *arg) +{ + struct adp_drv_private *adp = (struct adp_drv_private *)arg; + u32 int_status; + u32 int_ctl; + + spin_lock(&adp->irq_lock); + + int_status = readl(adp->fe + ADP_INT_STATUS); + if (int_status & ADP_INT_STATUS_VBLANK) { + drm_crtc_handle_vblank(&adp->crtc); + spin_lock(&adp->crtc.dev->event_lock); + if (adp->event) { + int_ctl = readl(adp->fe + ADP_CTRL); + if ((int_ctl & 0xF00) == 0x600) { + drm_crtc_send_vblank_event(&adp->crtc, adp->event); + adp->event = NULL; + drm_crtc_vblank_put(&adp->crtc); + } + } + spin_unlock(&adp->crtc.dev->event_lock); + } + + writel(int_status, adp->fe + ADP_INT_STATUS); + + spin_unlock(&adp->irq_lock); + + return IRQ_HANDLED; +} + +static int adp_probe(struct platform_device *pdev) +{ + struct adp_drv_private *adp; + int err; + + adp = devm_drm_dev_alloc(&pdev->dev, &adp_driver, struct adp_drv_private, drm); + if (IS_ERR(adp)) + return PTR_ERR(adp); + + spin_lock_init(&adp->irq_lock); + + dev_set_drvdata(&pdev->dev, &adp->drm); + + err = adp_parse_of(pdev, adp); + if (err < 0) + return err; + + adp->dsi.dev = &pdev->dev; + adp->dsi.ops = &adp_dsi_host_ops; + err = mipi_dsi_host_register(&adp->dsi); + if (err < 0) + return err; + + adp_disable_vblank(adp); + writel(ADP_CTRL_FIFO_ON | ADP_CTRL_VBLANK_ON, adp->fe + ADP_CTRL); + + err = adp_setup_mode_config(adp); + if (err < 0) + return err; + + err = devm_request_irq(&pdev->dev, adp->fe_irq, adp_fe_irq, 0, + "adp-fe", adp); + if (err) + return err; + + err = drm_dev_register(&adp->drm, 0); + if (err) + return err; + return 0; +} + +static void adp_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct drm_device *drm = dev_get_drvdata(dev); + struct adp_drv_private *adp = to_adp(drm); + + adp_disable_vblank(adp); + mipi_dsi_host_unregister(&adp->dsi); + drm_dev_unregister(drm); + dev_set_drvdata(dev, NULL); + drm_atomic_helper_shutdown(drm); +} + +static const struct of_device_id adp_of_match[] = { + { .compatible = "apple,h7-display-pipe", }, + { }, +}; +MODULE_DEVICE_TABLE(of, adp_of_match); + +static struct platform_driver adp_platform_driver = { + .driver = { + .name = "adp", + .of_match_table = adp_of_match, + }, + .probe = adp_probe, + .remove = adp_remove, +}; + +module_platform_driver(adp_platform_driver); + +MODULE_DESCRIPTION("Apple Display Pipe DRM driver"); +MODULE_LICENSE("GPL"); -- 2.47.0 ^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-24 22:29 ` [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver Sasha Finkelstein via B4 Relay @ 2024-11-25 8:50 ` Neil Armstrong 2024-11-25 11:24 ` Sasha Finkelstein 2024-11-25 9:04 ` Jani Nikula 2024-11-25 10:59 ` Alyssa Ross 2 siblings, 1 reply; 32+ messages in thread From: Neil Armstrong @ 2024-11-25 8:50 UTC (permalink / raw) To: fnkl.kernel, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau Hi, On 24/11/2024 23:29, Sasha Finkelstein via B4 Relay wrote: > From: Sasha Finkelstein <fnkl.kernel@gmail.com> Please use "drm: " and drop gpu from commit title. > > This display controller is present on M-series chips and is used > to drive the touchbar display. > > Co-developed-by: Janne Grunau <j@jannau.net> > Signed-off-by: Janne Grunau <j@jannau.net> > Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> > --- > drivers/gpu/drm/Kconfig | 2 + > drivers/gpu/drm/Makefile | 1 + > drivers/gpu/drm/adp/Kconfig | 14 + > drivers/gpu/drm/adp/Makefile | 5 + > drivers/gpu/drm/adp/adp_drv.c | 814 ++++++++++++++++++++++++++++++++++++++++++ > 5 files changed, 836 insertions(+) > > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig > index 5504721007cc190e7d768d42aa9633baa0115f5e..acd1111f1773ef044c306c62ad9f850996259ef1 100644 > --- a/drivers/gpu/drm/Kconfig > +++ b/drivers/gpu/drm/Kconfig > @@ -499,6 +499,8 @@ source "drivers/gpu/drm/mcde/Kconfig" > > source "drivers/gpu/drm/tidss/Kconfig" > > +source "drivers/gpu/drm/adp/Kconfig" > + > source "drivers/gpu/drm/xlnx/Kconfig" > > source "drivers/gpu/drm/gud/Kconfig" > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index 463afad1b5ca6275e61223adc8ca036c3d4d6b03..acd8d8943ef2bf85c80db7c218c59a7ec2df56da 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -213,6 +213,7 @@ obj-y += mxsfb/ > obj-y += tiny/ > obj-$(CONFIG_DRM_PL111) += pl111/ > obj-$(CONFIG_DRM_TVE200) += tve200/ > +obj-$(CONFIG_DRM_ADP) += adp/ > obj-$(CONFIG_DRM_XEN) += xen/ > obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/ > obj-$(CONFIG_DRM_LIMA) += lima/ > diff --git a/drivers/gpu/drm/adp/Kconfig b/drivers/gpu/drm/adp/Kconfig > new file mode 100644 > index 0000000000000000000000000000000000000000..3c570aeb14700611edd7e2738367090ebb30c346 > --- /dev/null > +++ b/drivers/gpu/drm/adp/Kconfig > @@ -0,0 +1,14 @@ > +# SPDX-License-Identifier: GPL-2.0-only OR MIT > +config DRM_ADP > + tristate "DRM Support for pre-DCP Apple display controllers" > + depends on DRM && OF && ARM64 > + depends on ARCH_APPLE || COMPILE_TEST > + select DRM_KMS_HELPER > + select DRM_KMS_DMA_HELPER > + select DRM_GEM_DMA_HELPER > + select VIDEOMODE_HELPERS > + select DRM_MIPI_DSI > + help > + Chose this option if you have an Apple Arm laptop with a touchbar. > + > + If M is selected, this module will be called adpdrm. > diff --git a/drivers/gpu/drm/adp/Makefile b/drivers/gpu/drm/adp/Makefile > new file mode 100644 > index 0000000000000000000000000000000000000000..28a5d4b4a267f3e2abe9f0ea9e11fae51ca18b88 > --- /dev/null > +++ b/drivers/gpu/drm/adp/Makefile > @@ -0,0 +1,5 @@ > +# SPDX-License-Identifier: GPL-2.0-only OR MIT > + > +adpdrm-y := adp_drv.o > +obj-$(CONFIG_DRM_ADP) += adpdrm.o > +obj-$(CONFIG_DRM_ADP) += panel-summit.o > diff --git a/drivers/gpu/drm/adp/adp_drv.c b/drivers/gpu/drm/adp/adp_drv.c > new file mode 100644 > index 0000000000000000000000000000000000000000..36510194e18161ef6514885c764b2e7085c587e5 > --- /dev/null > +++ b/drivers/gpu/drm/adp/adp_drv.c > @@ -0,0 +1,814 @@ > +// SPDX-License-Identifier: GPL-2.0-only > + > +#include <linux/anon_inodes.h> > +#include <linux/dma-mapping.h> > +#include <linux/io.h> > +#include <linux/iopoll.h> > +#include <linux/file.h> > +#include <linux/of.h> > +#include <linux/platform_device.h> > +#include <linux/types.h> > + > +#include <asm/current.h> > + > +#include <drm/drm_atomic.h> > +#include <drm/drm_atomic_helper.h> > +#include <drm/drm_damage_helper.h> > +#include <drm/drm_device.h> > +#include <drm/drm_drv.h> > +#include <drm/drm_edid.h> > +#include <drm/drm_fb_dma_helper.h> > +#include <drm/drm_file.h> > +#include <drm/drm_framebuffer.h> > +#include <drm/drm_gem_atomic_helper.h> > +#include <drm/drm_gem_dma_helper.h> > +#include <drm/drm_gem_framebuffer_helper.h> > +#include <drm/drm_mipi_dsi.h> > +#include <drm/drm_probe_helper.h> > +#include <drm/drm_simple_kms_helper.h> > +#include <drm/drm_vblank.h> > + > +#define ADP_INT_STATUS 0x34 > +#define ADP_INT_STATUS_INT_MASK 0x7 > +#define ADP_INT_STATUS_VBLANK 0x1 > +#define ADP_CTRL 0x100 > +#define ADP_CTRL_VBLANK_ON 0x12 > +#define ADP_CTRL_FIFO_ON 0x601 > +#define ADP_SCREEN_SIZE 0x0c > +#define ADP_SCREEN_HSIZE GENMASK(15, 0) > +#define ADP_SCREEN_VSIZE GENMASK(31, 16) > + > +#define ADBE_FIFO 0x10c0 > +#define ADBE_FIFO_SYNC 0xc0000000 > + > +#define ADBE_BLEND_BYPASS 0x2020 > +#define ADBE_BLEND_EN1 0x2028 > +#define ADBE_BLEND_EN2 0x2074 > +#define ADBE_BLEND_EN3 0x202c > +#define ADBE_BLEND_EN4 0x2034 > +#define ADBE_MASK_BUF 0x2200 > + > +#define ADBE_SRC_START 0x4040 > +#define ADBE_SRC_SIZE 0x4048 > +#define ADBE_DST_START 0x4050 > +#define ADBE_DST_SIZE 0x4054 > +#define ADBE_STRIDE 0x4038 > +#define ADBE_FB_BASE 0x4030 > + > +#define ADBE_LAYER_EN1 0x4020 > +#define ADBE_LAYER_EN2 0x4068 > +#define ADBE_LAYER_EN3 0x40b4 > +#define ADBE_LAYER_EN4 0x40f4 > +#define ADBE_SCALE_CTL 0x40ac > +#define ADBE_SCALE_CTL_BYPASS 0x100000 > + > +#define ADBE_LAYER_CTL 0x1038 > +#define ADBE_LAYER_CTL_ENABLE 0x10000 > + > +#define ADBE_PIX_FMT 0x402c > +#define ADBE_PIX_FMT_XRGB32 0x53e4001 > + > +#define DSI_GEN_HDR 0x6c > +#define DSI_GEN_PLD_DATA 0x70 > + > +#define DSI_CMD_PKT_STATUS 0x74 > + > +#define GEN_PLD_R_EMPTY BIT(4) > +#define GEN_PLD_W_FULL BIT(3) > +#define GEN_PLD_W_EMPTY BIT(2) > +#define GEN_CMD_FULL BIT(1) > +#define GEN_CMD_EMPTY BIT(0) > +#define GEN_RD_CMD_BUSY BIT(6) > +#define CMD_PKT_STATUS_TIMEOUT_US 20000 > + > +static int adp_open(struct inode *inode, struct file *filp) > +{ > + /* > + * The modesetting driver does not check the non-desktop connector > + * property and keeps the device open and locked. If the touchbar daemon > + * opens the device first modesetting breaks the whole X session. > + * Simply refuse to open the device for X11 server processes as > + * workaround. > + */ > + if (current->comm[0] == 'X') > + return -EBUSY; > + > + return drm_open(inode, filp); > +} > + > +static const struct file_operations adp_fops = { > + .owner = THIS_MODULE, > + .open = adp_open, > + .release = drm_release, > + .unlocked_ioctl = drm_ioctl, > + .compat_ioctl = drm_compat_ioctl, > + .poll = drm_poll, > + .read = drm_read, > + .llseek = noop_llseek, > + .mmap = drm_gem_mmap, > + .fop_flags = FOP_UNSIGNED_OFFSET, > + DRM_GEM_DMA_UNMAPPED_AREA_FOPS > +}; > + > +static int adp_drm_gem_dumb_create(struct drm_file *file_priv, > + struct drm_device *drm, > + struct drm_mode_create_dumb *args) > +{ > + args->height = ALIGN(args->height, 64); > + args->size = args->pitch * args->height; > + > + return drm_gem_dma_dumb_create_internal(file_priv, drm, args); > +} > + > +static const struct drm_driver adp_driver = { > + .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, > + .fops = &adp_fops, > + DRM_GEM_DMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE(adp_drm_gem_dumb_create), > + .name = "adp", > + .desc = "Apple Display Pipe DRM Driver", > + .date = "20230412", > + .major = 0, > + .minor = 1, > +}; > + > +struct adp_drv_private { > + struct drm_device drm; > + struct drm_crtc crtc; > + struct drm_encoder encoder; > + struct drm_connector connector; > + struct mipi_dsi_host dsi; > + void __iomem *be; > + void __iomem *fe; > + void __iomem *mipi; > + u32 *mask_buf; > + u64 mask_buf_size; > + dma_addr_t mask_iova; > + int be_irq; > + int fe_irq; > + spinlock_t irq_lock; > + struct drm_pending_vblank_event *event; > +}; > + > +struct adp_plane { > + struct drm_plane base_plane; > + u8 id; > +}; > + > +#define to_adp(x) container_of(x, struct adp_drv_private, drm) > +#define crtc_to_adp(x) container_of(x, struct adp_drv_private, crtc) > +#define conn_to_adp(x) container_of(x, struct adp_drv_private, connector) > +#define mipi_to_adp(x) container_of(x, struct adp_drv_private, dsi) > + > +static int adp_plane_atomic_check(struct drm_plane *plane, > + struct drm_atomic_state *state) > +{ > + struct drm_plane_state *new_plane_state; > + struct drm_crtc_state *crtc_state; > + > + new_plane_state = drm_atomic_get_new_plane_state(state, plane); > + > + if (!new_plane_state->crtc) > + return 0; > + > + crtc_state = drm_atomic_get_crtc_state(state, new_plane_state->crtc); > + if (IS_ERR(crtc_state)) > + return PTR_ERR(crtc_state); > + return drm_atomic_helper_check_plane_state(new_plane_state, > + crtc_state, > + DRM_PLANE_NO_SCALING, > + DRM_PLANE_NO_SCALING, > + true, true); > +} > + > +static void adp_plane_atomic_update(struct drm_plane *plane, > + struct drm_atomic_state *state) > +{ > + struct adp_drv_private *adp; > + struct drm_rect src_rect; > + struct drm_gem_dma_object *obj; > + struct drm_framebuffer *fb; > + struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); > + u32 src_pos, src_size, dst_pos, dst_size; > + > + if (!plane || !new_state) > + return; > + > + fb = new_state->fb; > + if (!fb) > + return; > + adp = to_adp(plane->dev); > + > + drm_rect_fp_to_int(&src_rect, &new_state->src); > + src_pos = src_rect.x1 << 16 | src_rect.y1; > + dst_pos = new_state->dst.x1 << 16 | new_state->dst.y1; > + src_size = drm_rect_width(&src_rect) << 16 | drm_rect_height(&src_rect); > + dst_size = drm_rect_width(&new_state->dst) << 16 | > + drm_rect_height(&new_state->dst); > + writel(src_pos, adp->be + ADBE_SRC_START); > + writel(src_size, adp->be + ADBE_SRC_SIZE); > + writel(dst_pos, adp->be + ADBE_DST_START); > + writel(dst_size, adp->be + ADBE_DST_SIZE); > + writel(fb->pitches[0], adp->be + ADBE_STRIDE); > + obj = drm_fb_dma_get_gem_obj(fb, 0); > + if (obj) > + writel(obj->dma_addr + fb->offsets[0], adp->be + ADBE_FB_BASE); > + > + writel(0x1, adp->be + ADBE_LAYER_EN1); > + writel(0x1, adp->be + ADBE_LAYER_EN2); > + writel(0x1, adp->be + ADBE_LAYER_EN3); > + writel(0x1, adp->be + ADBE_LAYER_EN4); BIT(0) ? > + writel(ADBE_SCALE_CTL_BYPASS, adp->be + ADBE_SCALE_CTL); > + writel(ADBE_LAYER_CTL_ENABLE | 0x1, adp->be + ADBE_LAYER_CTL); BIT(0) ? > + writel(ADBE_PIX_FMT_XRGB32, adp->be + ADBE_PIX_FMT); > + > +} > + > +static void adp_plane_atomic_disable(struct drm_plane *plane, > + struct drm_atomic_state *state) > +{ > + struct adp_drv_private *adp = to_adp(plane->dev); > + > + writel(0x0, adp->be + ADBE_LAYER_EN1); > + writel(0x0, adp->be + ADBE_LAYER_EN2); > + writel(0x0, adp->be + ADBE_LAYER_EN3); > + writel(0x0, adp->be + ADBE_LAYER_EN4); > + writel(ADBE_LAYER_CTL_ENABLE, adp->be + ADBE_LAYER_CTL); > +} > + > +static const struct drm_plane_helper_funcs adp_plane_helper_funcs = { > + .atomic_check = adp_plane_atomic_check, > + .atomic_update = adp_plane_atomic_update, > + .atomic_disable = adp_plane_atomic_disable, > + DRM_GEM_SHADOW_PLANE_HELPER_FUNCS > +}; > + > +static const struct drm_plane_funcs adp_plane_funcs = { > + .update_plane = drm_atomic_helper_update_plane, > + .disable_plane = drm_atomic_helper_disable_plane, > + DRM_GEM_SHADOW_PLANE_FUNCS > +}; > + > +static const u32 plane_formats[] = { > + DRM_FORMAT_XRGB8888, > +}; > + > +#define ALL_CRTCS 1 > + > +static struct adp_plane *adp_plane_new(struct adp_drv_private *adp, u8 id) > +{ > + struct drm_device *drm = &adp->drm; > + struct adp_plane *plane; > + enum drm_plane_type plane_type; > + > + plane_type = (id == 0) ? DRM_PLANE_TYPE_PRIMARY : > + DRM_PLANE_TYPE_OVERLAY; > + > + plane = drmm_universal_plane_alloc(drm, struct adp_plane, base_plane, > + ALL_CRTCS, &adp_plane_funcs, > + plane_formats, ARRAY_SIZE(plane_formats), > + NULL, plane_type, "plane %d", id); > + if (!plane) { > + drm_err(drm, "failed to allocate plane"); > + return ERR_PTR(-ENOMEM); > + } > + plane->id = id; > + > + drm_plane_helper_add(&plane->base_plane, &adp_plane_helper_funcs); > + return plane; > +} > + > +static void adp_enable_vblank(struct adp_drv_private *adp) > +{ > + u32 cur_ctrl; > + > + writel(ADP_INT_STATUS_INT_MASK, adp->fe + ADP_INT_STATUS); > + > + cur_ctrl = readl(adp->fe + ADP_CTRL); > + writel(cur_ctrl | ADP_CTRL_VBLANK_ON, adp->fe + ADP_CTRL); > +} > + > +static int adp_crtc_enable_vblank(struct drm_crtc *crtc) > +{ > + struct drm_device *dev = crtc->dev; > + struct adp_drv_private *adp = to_adp(dev); > + > + adp_enable_vblank(adp); > + > + return 0; > +} > + > +static void adp_disable_vblank(struct adp_drv_private *adp) > +{ > + u32 cur_ctrl; > + > + cur_ctrl = readl(adp->fe + ADP_CTRL); > + writel(cur_ctrl & ~ADP_CTRL_VBLANK_ON, adp->fe + ADP_CTRL); > + writel(ADP_INT_STATUS_INT_MASK, adp->fe + ADP_INT_STATUS); > +} > + > +static void adp_crtc_disable_vblank(struct drm_crtc *crtc) > +{ > + struct drm_device *dev = crtc->dev; > + struct adp_drv_private *adp = to_adp(dev); > + > + adp_disable_vblank(adp); > +} > + > + Duplicate empty line > +static void adp_crtc_atomic_enable(struct drm_crtc *crtc, > + struct drm_atomic_state *state) > +{ > + struct adp_drv_private *adp = crtc_to_adp(crtc); > + > + writel(0x1, adp->be + ADBE_BLEND_EN2); > + writel(0x10, adp->be + ADBE_BLEND_EN1); BIT(4) ? > + writel(0x1, adp->be + ADBE_BLEND_EN3); > + writel(0x1, adp->be + ADBE_BLEND_BYPASS); > + writel(0x1, adp->be + ADBE_BLEND_EN4); BIT(0) ? > +} > + > +static void adp_crtc_atomic_disable(struct drm_crtc *crtc, > + struct drm_atomic_state *state) > +{ > + struct adp_drv_private *adp = crtc_to_adp(crtc); > + struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc); > + > + drm_atomic_helper_disable_planes_on_crtc(old_state, false); > + > + writel(0x0, adp->be + ADBE_BLEND_EN2); > + writel(0x0, adp->be + ADBE_BLEND_EN1); > + writel(0x0, adp->be + ADBE_BLEND_EN3); > + writel(0x0, adp->be + ADBE_BLEND_BYPASS); > + writel(0x0, adp->be + ADBE_BLEND_EN4); > + drm_crtc_vblank_off(crtc); > +} > + > +static void adp_crtc_atomic_flush(struct drm_crtc *crtc, > + struct drm_atomic_state *state) > +{ > + u32 frame_num = 1; > + struct adp_drv_private *adp = crtc_to_adp(crtc); > + struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc); > + u64 new_size = ALIGN(new_state->mode.hdisplay * > + new_state->mode.vdisplay * 4, PAGE_SIZE); > + > + if (new_size != adp->mask_buf_size) { > + if (adp->mask_buf) > + dma_free_coherent(crtc->dev->dev, adp->mask_buf_size, > + adp->mask_buf, adp->mask_iova); > + adp->mask_buf = NULL; > + if (new_size != 0) { > + adp->mask_buf = dma_alloc_coherent(crtc->dev->dev, new_size, > + &adp->mask_iova, GFP_KERNEL); > + memset(adp->mask_buf, 0xFF, new_size); > + writel(adp->mask_iova, adp->be + ADBE_MASK_BUF); > + } > + adp->mask_buf_size = new_size; > + } > + writel(ADBE_FIFO_SYNC | frame_num, adp->be + ADBE_FIFO); > + //FIXME: use adbe flush interrupt > + spin_lock_irq(&crtc->dev->event_lock); > + if (crtc->state->event) { > + drm_crtc_vblank_get(crtc); > + adp->event = crtc->state->event; > + } > + crtc->state->event = NULL; > + spin_unlock_irq(&crtc->dev->event_lock); > +} > + > +static const struct drm_crtc_funcs adp_crtc_funcs = { > + .destroy = drm_crtc_cleanup, > + .set_config = drm_atomic_helper_set_config, > + .page_flip = drm_atomic_helper_page_flip, > + .reset = drm_atomic_helper_crtc_reset, > + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, > + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, > + .enable_vblank = adp_crtc_enable_vblank, > + .disable_vblank = adp_crtc_disable_vblank, > +}; > + > + > +static const struct drm_crtc_helper_funcs adp_crtc_helper_funcs = { > + .atomic_enable = adp_crtc_atomic_enable, > + .atomic_disable = adp_crtc_atomic_disable, > + .atomic_flush = adp_crtc_atomic_flush, > +}; > + > +static int adp_setup_crtc(struct adp_drv_private *adp) > +{ > + struct drm_device *drm = &adp->drm; > + struct adp_plane *primary; > + int ret; > + > + primary = adp_plane_new(adp, 0); > + if (IS_ERR(primary)) > + return PTR_ERR(primary); > + > + ret = drm_crtc_init_with_planes(drm, &adp->crtc, &primary->base_plane, > + NULL, &adp_crtc_funcs, NULL); > + if (ret) > + return ret; > + > + drm_crtc_helper_add(&adp->crtc, &adp_crtc_helper_funcs); > + return 0; > +} > + > +static int adp_get_modes(struct drm_connector *connector) > +{ > + struct adp_drv_private *adp = conn_to_adp(connector); > + struct drm_display_mode *mode; > + u32 size; > + > + size = readl(adp->fe + ADP_SCREEN_SIZE); > + mode = drm_mode_create(connector->dev); > + > + mode->vdisplay = FIELD_GET(ADP_SCREEN_VSIZE, size); > + mode->hdisplay = FIELD_GET(ADP_SCREEN_HSIZE, size); > + mode->hsync_start = mode->hdisplay + 8; > + mode->hsync_end = mode->hsync_start + 80; > + mode->htotal = mode->hsync_end + 40; > + mode->vsync_start = mode->vdisplay + 1; > + mode->vsync_end = mode->vsync_start + 15; > + mode->vtotal = mode->vsync_end + 6; > + mode->clock = (mode->vtotal * mode->htotal * 60) / 1000; > + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; > + mode->flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC; > + drm_mode_set_name(mode); > + drm_mode_probed_add(connector, mode); > + return 1; > +} So this controller only supports a single mode ??????? > + > +static int adp_detect_ctx(struct drm_connector *connector, > + struct drm_modeset_acquire_ctx *ctx, > + bool force) > +{ > + connector->display_info.non_desktop = true; > + drm_object_property_set_value(&connector->base, > + connector->dev->mode_config.non_desktop_property, > + connector->display_info.non_desktop); > + return connector_status_connected; > +} > + > +static const struct drm_connector_funcs adp_connector_funcs = { > + .fill_modes = drm_helper_probe_single_connector_modes, > + .destroy = drm_connector_cleanup, > + .reset = drm_atomic_helper_connector_reset, > + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, > + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, > +}; > + > +static const struct drm_connector_helper_funcs adp_connector_helper_funcs = { > + .get_modes = adp_get_modes, > + .detect_ctx = adp_detect_ctx, > +}; > + > +static const struct drm_mode_config_funcs adp_mode_config_funcs = { > + .fb_create = drm_gem_fb_create_with_dirty, > + .atomic_check = drm_atomic_helper_check, > + .atomic_commit = drm_atomic_helper_commit, > +}; > + > +static int adp_setup_mode_config(struct adp_drv_private *adp) > +{ > + struct drm_device *drm = &adp->drm; > + int ret; > + u32 size; > + > + ret = drmm_mode_config_init(drm); > + if (ret) > + return ret; > + > + /* > + * Query screen size restrict the frame buffer size to the screen size > + * aligned to the next multiple of 64. This is not necessary but can be > + * used as simple check for non-desktop devices. > + * Xorg's modesetting driver does not care about the connector > + * "non-desktop" property. The max frame buffer width or height can be > + * easily checked and a device can be reject if the max width/height is > + * smaller than 120 for example. > + * Any touchbar daemon is not limited by this small framebuffer size. > + */ > + size = readl(adp->fe + ADP_SCREEN_SIZE); > + > + drm->mode_config.min_width = 32; > + drm->mode_config.min_height = 32; > + drm->mode_config.max_width = ALIGN(FIELD_GET(ADP_SCREEN_HSIZE, size), 64); > + drm->mode_config.max_height = ALIGN(FIELD_GET(ADP_SCREEN_VSIZE, size), 64); > + drm->mode_config.preferred_depth = 24; > + drm->mode_config.prefer_shadow = 0; > + drm->mode_config.funcs = &adp_mode_config_funcs; > + > + ret = adp_setup_crtc(adp); > + if (ret) { > + drm_err(drm, "failed to create crtc"); > + return ret; > + } > + > + adp->encoder.possible_crtcs = ALL_CRTCS; > + ret = drm_simple_encoder_init(drm, &adp->encoder, DRM_MODE_ENCODER_DSI); > + if (ret) { > + drm_err(drm, "failed to init encoder"); > + return ret; > + } > + drm_connector_helper_add(&adp->connector, > + &adp_connector_helper_funcs); > + ret = drm_connector_init(drm, &adp->connector, &adp_connector_funcs, > + DRM_MODE_CONNECTOR_DSI); > + if (ret) > + return ret; > + > + drm_connector_attach_encoder(&adp->connector, &adp->encoder); > + > + ret = drm_vblank_init(drm, drm->mode_config.num_crtc); > + if (ret < 0) { > + drm_err(drm, "failed to initialize vblank"); > + return ret; > + } > + > + drm_mode_config_reset(drm); > + > + return 0; > +} > + > +static int adp_parse_of(struct platform_device *pdev, struct adp_drv_private *adp) > +{ > + adp->be = devm_platform_ioremap_resource_byname(pdev, "be"); > + if (IS_ERR(adp->be)) { > + dev_err(&pdev->dev, "failed to map display backend mmio"); > + return PTR_ERR(adp->be); > + } > + > + adp->fe = devm_platform_ioremap_resource_byname(pdev, "fe"); > + if (IS_ERR(adp->fe)) { > + dev_err(&pdev->dev, "failed to map display pipe mmio"); > + return PTR_ERR(adp->fe); > + } > + > + adp->mipi = devm_platform_ioremap_resource_byname(pdev, "mipi"); > + if (IS_ERR(adp->mipi)) { > + dev_err(&pdev->dev, "failed to map mipi mmio"); > + return PTR_ERR(adp->mipi); > + } > + > + adp->be_irq = platform_get_irq_byname(pdev, "be"); > + if (adp->be_irq < 0) { > + dev_err(&pdev->dev, "failed to find be irq"); > + return adp->be_irq; > + } > + > + adp->fe_irq = platform_get_irq_byname(pdev, "fe"); > + if (adp->fe_irq < 0) { > + dev_err(&pdev->dev, "failed to find fe irq"); > + return adp->fe_irq; > + } > + return 0; > +} > + > + > +static int adp_dsi_gen_pkt_hdr_write(struct adp_drv_private *adp, u32 hdr_val) > +{ > + int ret; > + u32 val, mask; > + > + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, > + val, !(val & GEN_CMD_FULL), 1000, > + CMD_PKT_STATUS_TIMEOUT_US); > + if (ret) { > + dev_err(adp->drm.dev, "failed to get available command FIFO\n"); > + return ret; > + } > + > + writel(hdr_val, adp->mipi + DSI_GEN_HDR); > + > + mask = GEN_CMD_EMPTY | GEN_PLD_W_EMPTY; > + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, > + val, (val & mask) == mask, > + 1000, CMD_PKT_STATUS_TIMEOUT_US); > + if (ret) { > + dev_err(adp->drm.dev, "failed to write command FIFO\n"); > + return ret; > + } > + > + return 0; > +} > + > +static int adp_dsi_write(struct adp_drv_private *adp, > + const struct mipi_dsi_packet *packet) > +{ > + const u8 *tx_buf = packet->payload; > + int len = packet->payload_length, pld_data_bytes = sizeof(u32), ret; > + __le32 word; > + u32 val; > + > + while (len) { > + if (len < pld_data_bytes) { > + word = 0; > + memcpy(&word, tx_buf, len); > + writel(le32_to_cpu(word), adp->mipi + DSI_GEN_PLD_DATA); > + len = 0; > + } else { > + memcpy(&word, tx_buf, pld_data_bytes); > + writel(le32_to_cpu(word), adp->mipi + DSI_GEN_PLD_DATA); > + tx_buf += pld_data_bytes; > + len -= pld_data_bytes; > + } > + > + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, > + val, !(val & GEN_PLD_W_FULL), 1000, > + CMD_PKT_STATUS_TIMEOUT_US); > + if (ret) { > + dev_err(adp->drm.dev, > + "failed to get available write payload FIFO\n"); > + return ret; > + } > + } > + > + word = 0; > + memcpy(&word, packet->header, sizeof(packet->header)); > + return adp_dsi_gen_pkt_hdr_write(adp, le32_to_cpu(word)); > +} > + > +static int adp_dsi_read(struct adp_drv_private *adp, > + const struct mipi_dsi_msg *msg) > +{ > + int i, j, ret, len = msg->rx_len; > + u8 *buf = msg->rx_buf; > + u32 val; > + > + /* Wait end of the read operation */ > + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, > + val, !(val & GEN_RD_CMD_BUSY), > + 1000, CMD_PKT_STATUS_TIMEOUT_US); > + if (ret) { > + dev_err(adp->drm.dev, "Timeout during read operation\n"); > + return ret; > + } > + > + for (i = 0; i < len; i += 4) { > + /* Read fifo must not be empty before all bytes are read */ > + ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS, > + val, !(val & GEN_PLD_R_EMPTY), > + 1000, CMD_PKT_STATUS_TIMEOUT_US); > + if (ret) { > + dev_err(adp->drm.dev, "Read payload FIFO is empty\n"); > + return ret; > + } > + > + val = readl(adp->mipi + DSI_GEN_PLD_DATA); > + for (j = 0; j < 4 && j + i < len; j++) > + buf[i + j] = val >> (8 * j); > + } > + > + return ret; > +} > + > +static ssize_t adp_dsi_host_transfer(struct mipi_dsi_host *host, > + const struct mipi_dsi_msg *msg) > +{ > + struct adp_drv_private *adp = mipi_to_adp(host); > + struct mipi_dsi_packet packet; > + int ret, nb_bytes; > + > + ret = mipi_dsi_create_packet(&packet, msg); > + if (ret) { > + dev_err(adp->drm.dev, "failed to create packet: %d\n", ret); > + return ret; > + } > + > + ret = adp_dsi_write(adp, &packet); > + if (ret) > + return ret; > + > + if (msg->rx_buf && msg->rx_len) { > + ret = adp_dsi_read(adp, msg); > + if (ret) > + return ret; > + nb_bytes = msg->rx_len; > + } else { > + nb_bytes = packet.size; > + } > + > + return nb_bytes; > +} > + > +static int adp_dsi_host_attach(struct mipi_dsi_host *host, > + struct mipi_dsi_device *dev) > +{ > + return 0; > +} > + > +static int adp_dsi_host_detach(struct mipi_dsi_host *host, > + struct mipi_dsi_device *dev) > +{ > + return 0; > +} > + > +static const struct mipi_dsi_host_ops adp_dsi_host_ops = { > + .transfer = adp_dsi_host_transfer, > + .attach = adp_dsi_host_attach, > + .detach = adp_dsi_host_detach, > +}; > + > +static irqreturn_t adp_fe_irq(int irq, void *arg) > +{ > + struct adp_drv_private *adp = (struct adp_drv_private *)arg; > + u32 int_status; > + u32 int_ctl; > + > + spin_lock(&adp->irq_lock); > + > + int_status = readl(adp->fe + ADP_INT_STATUS); > + if (int_status & ADP_INT_STATUS_VBLANK) { > + drm_crtc_handle_vblank(&adp->crtc); > + spin_lock(&adp->crtc.dev->event_lock); > + if (adp->event) { > + int_ctl = readl(adp->fe + ADP_CTRL); > + if ((int_ctl & 0xF00) == 0x600) { > + drm_crtc_send_vblank_event(&adp->crtc, adp->event); > + adp->event = NULL; > + drm_crtc_vblank_put(&adp->crtc); > + } > + } > + spin_unlock(&adp->crtc.dev->event_lock); > + } > + > + writel(int_status, adp->fe + ADP_INT_STATUS); > + > + spin_unlock(&adp->irq_lock); > + > + return IRQ_HANDLED; > +} > + > +static int adp_probe(struct platform_device *pdev) > +{ > + struct adp_drv_private *adp; > + int err; > + > + adp = devm_drm_dev_alloc(&pdev->dev, &adp_driver, struct adp_drv_private, drm); > + if (IS_ERR(adp)) > + return PTR_ERR(adp); > + > + spin_lock_init(&adp->irq_lock); > + > + dev_set_drvdata(&pdev->dev, &adp->drm); > + > + err = adp_parse_of(pdev, adp); > + if (err < 0) > + return err; > + > + adp->dsi.dev = &pdev->dev; > + adp->dsi.ops = &adp_dsi_host_ops; > + err = mipi_dsi_host_register(&adp->dsi); > + if (err < 0) > + return err; > + > + adp_disable_vblank(adp); > + writel(ADP_CTRL_FIFO_ON | ADP_CTRL_VBLANK_ON, adp->fe + ADP_CTRL); > + > + err = adp_setup_mode_config(adp); > + if (err < 0) > + return err; > + > + err = devm_request_irq(&pdev->dev, adp->fe_irq, adp_fe_irq, 0, > + "adp-fe", adp); > + if (err) > + return err; > + > + err = drm_dev_register(&adp->drm, 0); > + if (err) > + return err; > + return 0; > +} > + > +static void adp_remove(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct drm_device *drm = dev_get_drvdata(dev); > + struct adp_drv_private *adp = to_adp(drm); > + > + adp_disable_vblank(adp); > + mipi_dsi_host_unregister(&adp->dsi); > + drm_dev_unregister(drm); > + dev_set_drvdata(dev, NULL); > + drm_atomic_helper_shutdown(drm); > +} > + > +static const struct of_device_id adp_of_match[] = { > + { .compatible = "apple,h7-display-pipe", }, > + { }, > +}; > +MODULE_DEVICE_TABLE(of, adp_of_match); > + > +static struct platform_driver adp_platform_driver = { > + .driver = { > + .name = "adp", > + .of_match_table = adp_of_match, > + }, > + .probe = adp_probe, > + .remove = adp_remove, > +}; > + > +module_platform_driver(adp_platform_driver); > + > +MODULE_DESCRIPTION("Apple Display Pipe DRM driver"); > +MODULE_LICENSE("GPL"); > ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-25 8:50 ` Neil Armstrong @ 2024-11-25 11:24 ` Sasha Finkelstein 2024-11-25 12:57 ` neil.armstrong 2024-11-25 14:24 ` Hector Martin 0 siblings, 2 replies; 32+ messages in thread From: Sasha Finkelstein @ 2024-11-25 11:24 UTC (permalink / raw) To: neil.armstrong Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau On Mon, 25 Nov 2024 at 09:50, Neil Armstrong <neil.armstrong@linaro.org> wrote: > > So this controller only supports a single mode ??????? > Most likely. On all devices it is connected to a single built-in display. Ack on all other changes, will be fixed for v2. ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-25 11:24 ` Sasha Finkelstein @ 2024-11-25 12:57 ` neil.armstrong 2024-11-25 13:14 ` Sasha Finkelstein 2024-11-25 14:24 ` Hector Martin 1 sibling, 1 reply; 32+ messages in thread From: neil.armstrong @ 2024-11-25 12:57 UTC (permalink / raw) To: Sasha Finkelstein Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau On 25/11/2024 12:24, Sasha Finkelstein wrote: > On Mon, 25 Nov 2024 at 09:50, Neil Armstrong <neil.armstrong@linaro.org> wrote: >> >> So this controller only supports a single mode ??????? >> > Most likely. On all devices it is connected to a single built-in display. > > Ack on all other changes, will be fixed for v2. OK, so instead make the panel driver return this single mode and from the display driver just filter out anything that's not ADP_SCREEN_VSIZE & ADP_SCREEN_HSIZE. Neil ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-25 12:57 ` neil.armstrong @ 2024-11-25 13:14 ` Sasha Finkelstein 2024-11-25 13:16 ` neil.armstrong 0 siblings, 1 reply; 32+ messages in thread From: Sasha Finkelstein @ 2024-11-25 13:14 UTC (permalink / raw) To: neil.armstrong Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau On Mon, 25 Nov 2024 at 13:57, <neil.armstrong@linaro.org> wrote: > > On 25/11/2024 12:24, Sasha Finkelstein wrote: > > On Mon, 25 Nov 2024 at 09:50, Neil Armstrong <neil.armstrong@linaro.org> wrote: > >> > >> So this controller only supports a single mode ??????? > >> > > Most likely. On all devices it is connected to a single built-in display. > > > > Ack on all other changes, will be fixed for v2. > > OK, so instead make the panel driver return this single mode > and from the display driver just filter out anything that's > not ADP_SCREEN_VSIZE & ADP_SCREEN_HSIZE. Not sure i follow, you want the mode hardcoded in the panel driver and the controller driver to fetch and return that? ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-25 13:14 ` Sasha Finkelstein @ 2024-11-25 13:16 ` neil.armstrong 0 siblings, 0 replies; 32+ messages in thread From: neil.armstrong @ 2024-11-25 13:16 UTC (permalink / raw) To: Sasha Finkelstein Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau On 25/11/2024 14:14, Sasha Finkelstein wrote: > On Mon, 25 Nov 2024 at 13:57, <neil.armstrong@linaro.org> wrote: >> >> On 25/11/2024 12:24, Sasha Finkelstein wrote: >>> On Mon, 25 Nov 2024 at 09:50, Neil Armstrong <neil.armstrong@linaro.org> wrote: >>>> >>>> So this controller only supports a single mode ??????? >>>> >>> Most likely. On all devices it is connected to a single built-in display. >>> >>> Ack on all other changes, will be fixed for v2. >> >> OK, so instead make the panel driver return this single mode >> and from the display driver just filter out anything that's >> not ADP_SCREEN_VSIZE & ADP_SCREEN_HSIZE. > > Not sure i follow, you want the mode hardcoded in the panel driver > and the controller driver to fetch and return that? Yes, like a classic panel driver. Neil ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-25 11:24 ` Sasha Finkelstein 2024-11-25 12:57 ` neil.armstrong @ 2024-11-25 14:24 ` Hector Martin 2024-11-25 15:28 ` Maxime Ripard 2024-11-25 15:37 ` neil.armstrong 1 sibling, 2 replies; 32+ messages in thread From: Hector Martin @ 2024-11-25 14:24 UTC (permalink / raw) To: Sasha Finkelstein, neil.armstrong Cc: Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau On 2024/11/25 20:24, Sasha Finkelstein wrote: > On Mon, 25 Nov 2024 at 09:50, Neil Armstrong <neil.armstrong@linaro.org> wrote: >> >> So this controller only supports a single mode ??????? >> > Most likely. On all devices it is connected to a single built-in display. More specifically, the controller obviously supports multiple modes but it is pre-initialized by the bootloader for the single hardwired display's only mode. So as far as the driver is concerned, there is a single possible mode, and there's no point in trying to be more generic if there is no hardware that would use that. In general, it is not possible/practical to be generic for reverse engineered hardware with no specs documenting how to drive it generically. You just can't know how to implement the options that are never used in practice. I spent a lot of time on exceptions to this rule for the GPIO and SPI controllers, and that's not going to happen for more complex hardware like MIPI DSI. - Hector ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-25 14:24 ` Hector Martin @ 2024-11-25 15:28 ` Maxime Ripard 2024-11-25 15:55 ` Hector Martin 2024-11-25 15:37 ` neil.armstrong 1 sibling, 1 reply; 32+ messages in thread From: Maxime Ripard @ 2024-11-25 15:28 UTC (permalink / raw) To: Hector Martin Cc: Sasha Finkelstein, neil.armstrong, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau [-- Attachment #1: Type: text/plain, Size: 1595 bytes --] On Mon, Nov 25, 2024 at 11:24:25PM +0900, Hector Martin wrote: > > > On 2024/11/25 20:24, Sasha Finkelstein wrote: > > On Mon, 25 Nov 2024 at 09:50, Neil Armstrong <neil.armstrong@linaro.org> wrote: > >> > >> So this controller only supports a single mode ??????? > >> > > Most likely. On all devices it is connected to a single built-in display. > > More specifically, the controller obviously supports multiple modes but > it is pre-initialized by the bootloader for the single hardwired > display's only mode. So as far as the driver is concerned, there is a > single possible mode, and there's no point in trying to be more generic > if there is no hardware that would use that. It's not only about being generic, it's also about fitting nicely in the usual abstractions. You could also always register a single panel, with a single timing set, and the driver would never see anything else. And still fall within the usual pattern. > In general, it is not possible/practical to be generic for reverse > engineered hardware with no specs documenting how to drive it > generically. You just can't know how to implement the options that are > never used in practice. I spent a lot of time on exceptions to this > rule for the GPIO and SPI controllers, and that's not going to happen > for more complex hardware like MIPI DSI. How is GPIO or SPI even remotely related to that discussion? We are different maintainers, with different concerns, and different things to care about. Also, "My way or the highway" is never a great discussion opener. Maxime [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 273 bytes --] ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-25 15:28 ` Maxime Ripard @ 2024-11-25 15:55 ` Hector Martin 0 siblings, 0 replies; 32+ messages in thread From: Hector Martin @ 2024-11-25 15:55 UTC (permalink / raw) To: Maxime Ripard Cc: Sasha Finkelstein, neil.armstrong, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau On November 25, 2024 4:28:00 PM GMT+01:00, Maxime Ripard <mripard@kernel.org> wrote: >On Mon, Nov 25, 2024 at 11:24:25PM +0900, Hector Martin wrote: >> >> >> On 2024/11/25 20:24, Sasha Finkelstein wrote: >> > On Mon, 25 Nov 2024 at 09:50, Neil Armstrong <neil.armstrong@linaro.org> wrote: >> >> >> >> So this controller only supports a single mode ??????? >> >> >> > Most likely. On all devices it is connected to a single built-in display. >> >> More specifically, the controller obviously supports multiple modes but >> it is pre-initialized by the bootloader for the single hardwired >> display's only mode. So as far as the driver is concerned, there is a >> single possible mode, and there's no point in trying to be more generic >> if there is no hardware that would use that. > >It's not only about being generic, it's also about fitting nicely in the >usual abstractions. You could also always register a single panel, with >a single timing set, and the driver would never see anything else. And >still fall within the usual pattern. > >> In general, it is not possible/practical to be generic for reverse >> engineered hardware with no specs documenting how to drive it >> generically. You just can't know how to implement the options that are >> never used in practice. I spent a lot of time on exceptions to this >> rule for the GPIO and SPI controllers, and that's not going to happen >> for more complex hardware like MIPI DSI. > >How is GPIO or SPI even remotely related to that discussion? We are >different maintainers, with different concerns, and different things to >care about. > >Also, "My way or the highway" is never a great discussion opener. This was not an attempt to push back on the review feedback at all. I was just trying to add context about *why* the controller will never be used with nor support more than a single mode, not argue about how that should be implemented. Sorry if it came across as otherwise. GPIO and SPI are relevant not because of anything related to the kernel, but because I was able to reverse engineer the generic features of those controllers quite comprehensively by literally probing a GPIO routed to an external USB-C port with a custom test bench and an oscilloscope (for GPIO) and by using the GPIO registers along with a bespoke bare-metal test platform as a "software" logic analyzer to inspect the signals generated as I twiddled register bits (for SPI). I'd love to have all hardware comprehensively documented like that (I did GPIO and SPI because I wanted to, not because any maintainer asked for it), but as you might imagine, this kind of deep hardware RE doesn't scale and isn't practical for anything more complex, and I was just trying to convey that fact. (Sending from mobile, apologies for the likely dodgy line wrap) -- Hector ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-25 14:24 ` Hector Martin 2024-11-25 15:28 ` Maxime Ripard @ 2024-11-25 15:37 ` neil.armstrong 1 sibling, 0 replies; 32+ messages in thread From: neil.armstrong @ 2024-11-25 15:37 UTC (permalink / raw) To: Hector Martin, Sasha Finkelstein Cc: Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau Hi Hector, On 25/11/2024 15:24, Hector Martin wrote: > > > On 2024/11/25 20:24, Sasha Finkelstein wrote: >> On Mon, 25 Nov 2024 at 09:50, Neil Armstrong <neil.armstrong@linaro.org> wrote: >>> >>> So this controller only supports a single mode ??????? >>> >> Most likely. On all devices it is connected to a single built-in display. > > More specifically, the controller obviously supports multiple modes but > it is pre-initialized by the bootloader for the single hardwired > display's only mode. So as far as the driver is concerned, there is a > single possible mode, and there's no point in trying to be more generic > if there is no hardware that would use that. I totally got the point, I just asked to slightly change the design to fit the overall DRM/DSI/Panel architecture. > > In general, it is not possible/practical to be generic for reverse > engineered hardware with no specs documenting how to drive it > generically. You just can't know how to implement the options that are > never used in practice. I spent a lot of time on exceptions to this rule > for the GPIO and SPI controllers, and that's not going to happen for > more complex hardware like MIPI DSI. I'm fine with the overall actual design since it's a special usecase for a special display present on only a few SKUs. Nevertheless, as Maxime expressed, you should still try to fit nicely on the abstractions, or change the abstractions. Neil > > - Hector > ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-24 22:29 ` [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver Sasha Finkelstein via B4 Relay 2024-11-25 8:50 ` Neil Armstrong @ 2024-11-25 9:04 ` Jani Nikula 2024-11-25 10:59 ` Alyssa Ross 2 siblings, 0 replies; 32+ messages in thread From: Jani Nikula @ 2024-11-25 9:04 UTC (permalink / raw) To: Sasha Finkelstein via B4 Relay, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Sasha Finkelstein, Janne Grunau On Sun, 24 Nov 2024, Sasha Finkelstein via B4 Relay <devnull+fnkl.kernel.gmail.com@kernel.org> wrote: > diff --git a/drivers/gpu/drm/adp/adp_drv.c b/drivers/gpu/drm/adp/adp_drv.c > new file mode 100644 > index 0000000000000000000000000000000000000000..36510194e18161ef6514885c764b2e7085c587e5 > --- /dev/null > +++ b/drivers/gpu/drm/adp/adp_drv.c > @@ -0,0 +1,814 @@ > +// SPDX-License-Identifier: GPL-2.0-only > + > +#include <linux/anon_inodes.h> > +#include <linux/dma-mapping.h> > +#include <linux/io.h> > +#include <linux/iopoll.h> > +#include <linux/file.h> > +#include <linux/of.h> > +#include <linux/platform_device.h> > +#include <linux/types.h> > + > +#include <asm/current.h> > + > +#include <drm/drm_atomic.h> > +#include <drm/drm_atomic_helper.h> > +#include <drm/drm_damage_helper.h> > +#include <drm/drm_device.h> > +#include <drm/drm_drv.h> > +#include <drm/drm_edid.h> > +#include <drm/drm_fb_dma_helper.h> > +#include <drm/drm_file.h> > +#include <drm/drm_framebuffer.h> > +#include <drm/drm_gem_atomic_helper.h> > +#include <drm/drm_gem_dma_helper.h> > +#include <drm/drm_gem_framebuffer_helper.h> > +#include <drm/drm_mipi_dsi.h> > +#include <drm/drm_probe_helper.h> > +#include <drm/drm_simple_kms_helper.h> > +#include <drm/drm_vblank.h> Please only include what you use. BR, Jani. -- Jani Nikula, Intel ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver 2024-11-24 22:29 ` [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver Sasha Finkelstein via B4 Relay 2024-11-25 8:50 ` Neil Armstrong 2024-11-25 9:04 ` Jani Nikula @ 2024-11-25 10:59 ` Alyssa Ross 2 siblings, 0 replies; 32+ messages in thread From: Alyssa Ross @ 2024-11-25 10:59 UTC (permalink / raw) To: Sasha Finkelstein Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau [-- Attachment #1: Type: text/plain, Size: 1843 bytes --] This still has the bug that I originally reported at: https://github.com/AsahiLinux/linux/issues/258 On Sun, Nov 24, 2024 at 11:29:25PM +0100, Sasha Finkelstein via B4 Relay wrote: > +static int adp_probe(struct platform_device *pdev) > +{ > + struct adp_drv_private *adp; > + int err; > + > + adp = devm_drm_dev_alloc(&pdev->dev, &adp_driver, struct adp_drv_private, drm); > + if (IS_ERR(adp)) > + return PTR_ERR(adp); Here a child device of pdev->dev is created. It is not a MIPI DSI device. > + > + spin_lock_init(&adp->irq_lock); > + > + dev_set_drvdata(&pdev->dev, &adp->drm); > + > + err = adp_parse_of(pdev, adp); > + if (err < 0) > + return err; > + > + adp->dsi.dev = &pdev->dev; > + adp->dsi.ops = &adp_dsi_host_ops; > + err = mipi_dsi_host_register(&adp->dsi); Here a MIPI DSI host is registered, with its device set to pdev->dev. It is expected that the child devices of a DSI host device are all MIPI DSI devices — see mipi_dsi_host_unregister() and mipi_dsi_remove_device_fn(). This means that, when mipi_dsi_host_unregister() is called, which it will be as part of unloading adpdrm, it will try to find the MIPI DSI device for adp using container_of() (via to_mipi_dsi_device()), but there isn't one, so it interprets some other memory as a struct mipi_dsi_device. For me, this causes a null pointer dereference. > + if (err < 0) > + return err; > + > + adp_disable_vblank(adp); > + writel(ADP_CTRL_FIFO_ON | ADP_CTRL_VBLANK_ON, adp->fe + ADP_CTRL); > + > + err = adp_setup_mode_config(adp); > + if (err < 0) > + return err; > + > + err = devm_request_irq(&pdev->dev, adp->fe_irq, adp_fe_irq, 0, > + "adp-fe", adp); > + if (err) > + return err; > + > + err = drm_dev_register(&adp->drm, 0); > + if (err) > + return err; > + return 0; > +} [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD 2024-11-24 22:29 [PATCH 0/5] Driver for pre-DCP apple display controller Sasha Finkelstein via B4 Relay 2024-11-24 22:29 ` [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings Sasha Finkelstein via B4 Relay 2024-11-24 22:29 ` [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 ` Sasha Finkelstein via B4 Relay 2024-11-25 8:45 ` Neil Armstrong 2024-11-25 14:49 ` Krzysztof Kozlowski 2024-11-24 22:29 ` [PATCH 4/5] arm64: dts: apple: Add touchbar screen nodes Sasha Finkelstein via B4 Relay 2024-11-24 22:29 ` [PATCH 5/5] MAINTAINERS: Add entries for touchbar display driver Sasha Finkelstein via B4 Relay 4 siblings, 2 replies; 32+ messages in thread From: Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 UTC (permalink / raw) To: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Sasha Finkelstein, Nick Chan From: Sasha Finkelstein <fnkl.kernel@gmail.com> This is the display panel used for the touchbar on laptops that have it. Co-developed-by: Nick Chan <towinchenmi@gmail.com> Signed-off-by: Nick Chan <towinchenmi@gmail.com> Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> --- drivers/gpu/drm/adp/panel-summit.c | 108 +++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/drivers/gpu/drm/adp/panel-summit.c b/drivers/gpu/drm/adp/panel-summit.c new file mode 100644 index 0000000000000000000000000000000000000000..2dcbddd925ce3863742aa60164369ba9db0bbfff --- /dev/null +++ b/drivers/gpu/drm/adp/panel-summit.c @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/backlight.h> +#include <drm/drm_mipi_dsi.h> +#include <video/mipi_display.h> + +struct summit_data { + struct mipi_dsi_device *dsi; + struct backlight_device *bl; +}; + +static int summit_set_brightness(struct device *dev) +{ + struct summit_data *panel = dev_get_drvdata(dev); + int level = backlight_get_brightness(panel->bl); + int err = mipi_dsi_dcs_set_display_brightness(panel->dsi, level); + + if (err < 0) + return err; + return 0; +} + +static int summit_bl_update_status(struct backlight_device *dev) +{ + return summit_set_brightness(&dev->dev); +} + +static int summit_bl_get_brightness(struct backlight_device *dev) +{ + return backlight_get_brightness(dev); +} + +static const struct backlight_ops summit_bl_ops = { + .get_brightness = summit_bl_get_brightness, + .update_status = summit_bl_update_status, +}; + +static int summit_probe(struct mipi_dsi_device *dsi) +{ + struct backlight_properties props = { 0 }; + struct device *dev = &dsi->dev; + struct summit_data *panel; + + panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); + if (!panel) + return -ENOMEM; + + mipi_dsi_set_drvdata(dsi, panel); + panel->dsi = dsi; + + int ret = device_property_read_u32(dev, "max-brightness", &props.max_brightness); + + if (ret) + props.max_brightness = 255; + props.type = BACKLIGHT_RAW; + + panel->bl = devm_backlight_device_register(dev, dev_name(dev), + dev, panel, &summit_bl_ops, &props); + if (IS_ERR(panel->bl)) + return PTR_ERR(panel->bl); + + return mipi_dsi_attach(dsi); +} + +static void summit_remove(struct mipi_dsi_device *dsi) +{ + mipi_dsi_detach(dsi); +} + +static int summit_resume(struct device *dev) +{ + return summit_set_brightness(dev); +} + +static int summit_suspend(struct device *dev) +{ + struct summit_data *panel = dev_get_drvdata(dev); + + int err = mipi_dsi_dcs_set_display_brightness(panel->dsi, 0); + + if (err < 0) + return err; + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(summit_pm_ops, summit_suspend, + summit_resume); + +static const struct of_device_id summit_of_match[] = { + { .compatible = "apple,summit" }, + {}, +}; + +MODULE_DEVICE_TABLE(of, summit_of_match); + +static struct mipi_dsi_driver summit_driver = { + .probe = summit_probe, + .remove = summit_remove, + .driver = { + .name = "panel-summit", + .of_match_table = summit_of_match, + .pm = pm_sleep_ptr(&summit_pm_ops), + }, +}; +module_mipi_dsi_driver(summit_driver); + +MODULE_DESCRIPTION("Summit Display Panel Driver"); +MODULE_LICENSE("GPL"); -- 2.47.0 ^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD 2024-11-24 22:29 ` [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD Sasha Finkelstein via B4 Relay @ 2024-11-25 8:45 ` Neil Armstrong 2024-11-25 11:28 ` Sasha Finkelstein 2024-11-25 14:49 ` Krzysztof Kozlowski 1 sibling, 1 reply; 32+ messages in thread From: Neil Armstrong @ 2024-11-25 8:45 UTC (permalink / raw) To: fnkl.kernel, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Nick Chan Hi, On 24/11/2024 23:29, Sasha Finkelstein via B4 Relay wrote: > From: Sasha Finkelstein <fnkl.kernel@gmail.com> > > This is the display panel used for the touchbar on laptops that have it. > > Co-developed-by: Nick Chan <towinchenmi@gmail.com> > Signed-off-by: Nick Chan <towinchenmi@gmail.com> > Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> > --- > drivers/gpu/drm/adp/panel-summit.c | 108 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 108 insertions(+) > > diff --git a/drivers/gpu/drm/adp/panel-summit.c b/drivers/gpu/drm/adp/panel-summit.c > new file mode 100644 > index 0000000000000000000000000000000000000000..2dcbddd925ce3863742aa60164369ba9db0bbfff > --- /dev/null > +++ b/drivers/gpu/drm/adp/panel-summit.c > @@ -0,0 +1,108 @@ > +// SPDX-License-Identifier: GPL-2.0-only > + > +#include <linux/backlight.h> > +#include <drm/drm_mipi_dsi.h> > +#include <video/mipi_display.h> > + > +struct summit_data { > + struct mipi_dsi_device *dsi; > + struct backlight_device *bl; > +}; > + > +static int summit_set_brightness(struct device *dev) > +{ > + struct summit_data *panel = dev_get_drvdata(dev); > + int level = backlight_get_brightness(panel->bl); > + int err = mipi_dsi_dcs_set_display_brightness(panel->dsi, level); > + > + if (err < 0) > + return err; > + return 0; Just return err here. > +} > + > +static int summit_bl_update_status(struct backlight_device *dev) > +{ > + return summit_set_brightness(&dev->dev); > +} > + > +static int summit_bl_get_brightness(struct backlight_device *dev) > +{ > + return backlight_get_brightness(dev); > +} > + > +static const struct backlight_ops summit_bl_ops = { > + .get_brightness = summit_bl_get_brightness, > + .update_status = summit_bl_update_status, > +}; > + > +static int summit_probe(struct mipi_dsi_device *dsi) > +{ > + struct backlight_properties props = { 0 }; > + struct device *dev = &dsi->dev; > + struct summit_data *panel; > + > + panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); > + if (!panel) > + return -ENOMEM; > + > + mipi_dsi_set_drvdata(dsi, panel); > + panel->dsi = dsi; > + > + int ret = device_property_read_u32(dev, "max-brightness", &props.max_brightness); > + > + if (ret) > + props.max_brightness = 255; > + props.type = BACKLIGHT_RAW; > + > + panel->bl = devm_backlight_device_register(dev, dev_name(dev), > + dev, panel, &summit_bl_ops, &props); > + if (IS_ERR(panel->bl)) > + return PTR_ERR(panel->bl); > + > + return mipi_dsi_attach(dsi); > +} > + > +static void summit_remove(struct mipi_dsi_device *dsi) > +{ > + mipi_dsi_detach(dsi); > +} > + > +static int summit_resume(struct device *dev) > +{ > + return summit_set_brightness(dev); > +} > + > +static int summit_suspend(struct device *dev) > +{ > + struct summit_data *panel = dev_get_drvdata(dev); > + > + int err = mipi_dsi_dcs_set_display_brightness(panel->dsi, 0); > + > + if (err < 0) > + return err; > + return 0; Just return err here, add a common function to set a brighness value and avoid duplicate code like here. Neil > +} > + > +static DEFINE_SIMPLE_DEV_PM_OPS(summit_pm_ops, summit_suspend, > + summit_resume); > + > +static const struct of_device_id summit_of_match[] = { > + { .compatible = "apple,summit" }, > + {}, > +}; > + > +MODULE_DEVICE_TABLE(of, summit_of_match); > + > +static struct mipi_dsi_driver summit_driver = { > + .probe = summit_probe, > + .remove = summit_remove, > + .driver = { > + .name = "panel-summit", > + .of_match_table = summit_of_match, > + .pm = pm_sleep_ptr(&summit_pm_ops), > + }, > +}; > +module_mipi_dsi_driver(summit_driver); > + > +MODULE_DESCRIPTION("Summit Display Panel Driver"); > +MODULE_LICENSE("GPL"); > Please move the driver into drivers/gpu/drm/panels Thanks, Neil ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD 2024-11-25 8:45 ` Neil Armstrong @ 2024-11-25 11:28 ` Sasha Finkelstein 0 siblings, 0 replies; 32+ messages in thread From: Sasha Finkelstein @ 2024-11-25 11:28 UTC (permalink / raw) To: neil.armstrong Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel, Nick Chan On Mon, 25 Nov 2024 at 09:45, Neil Armstrong <neil.armstrong@linaro.org> wrote: > > +static int summit_suspend(struct device *dev) > > +{ > > + struct summit_data *panel = dev_get_drvdata(dev); > > + > > + int err = mipi_dsi_dcs_set_display_brightness(panel->dsi, 0); > > + > > + if (err < 0) > > + return err; > > + return 0; > > Just return err here, add a common function to set a brighness value and > avoid duplicate code like here. I felt that mipi_dsi_dcs_set_display_brightness is common enough, is it not? Ack on all other changes, will be done for v2. ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD 2024-11-24 22:29 ` [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD Sasha Finkelstein via B4 Relay 2024-11-25 8:45 ` Neil Armstrong @ 2024-11-25 14:49 ` Krzysztof Kozlowski 2024-11-25 15:03 ` Nick Chan 1 sibling, 1 reply; 32+ messages in thread From: Krzysztof Kozlowski @ 2024-11-25 14:49 UTC (permalink / raw) To: fnkl.kernel, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Nick Chan On 24/11/2024 23:29, Sasha Finkelstein via B4 Relay wrote: > From: Sasha Finkelstein <fnkl.kernel@gmail.com> > > This is the display panel used for the touchbar on laptops that have it. ... > +static int summit_probe(struct mipi_dsi_device *dsi) > +{ > + struct backlight_properties props = { 0 }; > + struct device *dev = &dsi->dev; > + struct summit_data *panel; > + > + panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); > + if (!panel) > + return -ENOMEM; > + > + mipi_dsi_set_drvdata(dsi, panel); > + panel->dsi = dsi; > + > + int ret = device_property_read_u32(dev, "max-brightness", &props.max_brightness); That's an undocumented property, which suggests you did not test your DTS. It does not look like you tested the DTS against bindings. Please run `make dtbs_check W=1` (see Documentation/devicetree/bindings/writing-schema.rst or https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/ for instructions). Best regards, Krzysztof ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD 2024-11-25 14:49 ` Krzysztof Kozlowski @ 2024-11-25 15:03 ` Nick Chan 2024-11-25 15:06 ` Krzysztof Kozlowski 0 siblings, 1 reply; 32+ messages in thread From: Nick Chan @ 2024-11-25 15:03 UTC (permalink / raw) To: Krzysztof Kozlowski, fnkl.kernel, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel Krzysztof Kozlowski 於 2024/11/25 晚上10:49 寫道: > On 24/11/2024 23:29, Sasha Finkelstein via B4 Relay wrote: >> From: Sasha Finkelstein <fnkl.kernel@gmail.com> >> >> This is the display panel used for the touchbar on laptops that have it. > > > ... > > >> +static int summit_probe(struct mipi_dsi_device *dsi) >> +{ >> + struct backlight_properties props = { 0 }; >> + struct device *dev = &dsi->dev; >> + struct summit_data *panel; >> + >> + panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); >> + if (!panel) >> + return -ENOMEM; >> + >> + mipi_dsi_set_drvdata(dsi, panel); >> + panel->dsi = dsi; >> + >> + int ret = device_property_read_u32(dev, "max-brightness", &props.max_brightness); > That's an undocumented property, which suggests you did not test your DTS. Actually, testing the DTS would not have caught this issue. For more context, all summit panels found in touch bar have a max brightness of 255, but the summit panel in Apple A11 devices like the iPhone X is latter found to have a max brightness of 2047. However, A11 cannot be properly supported right now due to not having a driver for the DART IOMMU. In the meantime, max-brightness could documented and be made required, and the default 255 brightness could be removed. > > It does not look like you tested the DTS against bindings. Please run > `make dtbs_check W=1` (see > Documentation/devicetree/bindings/writing-schema.rst or > https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/ > for instructions). > > Best regards, > Krzysztof Nick Chan ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD 2024-11-25 15:03 ` Nick Chan @ 2024-11-25 15:06 ` Krzysztof Kozlowski 2024-11-26 16:34 ` Sasha Finkelstein 0 siblings, 1 reply; 32+ messages in thread From: Krzysztof Kozlowski @ 2024-11-25 15:06 UTC (permalink / raw) To: Nick Chan, fnkl.kernel, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel On 25/11/2024 16:03, Nick Chan wrote: >>> +static int summit_probe(struct mipi_dsi_device *dsi) >>> +{ >>> + struct backlight_properties props = { 0 }; >>> + struct device *dev = &dsi->dev; >>> + struct summit_data *panel; >>> + >>> + panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); >>> + if (!panel) >>> + return -ENOMEM; >>> + >>> + mipi_dsi_set_drvdata(dsi, panel); >>> + panel->dsi = dsi; >>> + >>> + int ret = device_property_read_u32(dev, "max-brightness", &props.max_brightness); >> That's an undocumented property, which suggests you did not test your DTS. > > Actually, testing the DTS would not have caught this issue. For more > context, If you mean that property is not in your DTS, then right, it would not be caught. But otherwise it would. Anyway, I pointed out testing as helping tool for your development, just like building with clang W=1 will spare you some review comments or bugs. > all summit panels found in touch bar have a max brightness of 255, but the > summit panel in Apple A11 devices like the iPhone X is latter found to have > a max brightness of 2047. > > However, A11 cannot be properly supported right now due to not having a > driver > for the DART IOMMU. > > In the meantime, max-brightness could documented and be made required, > and the > default 255 brightness could be removed. BTW, max-brightness is a property of backlight, not panel, I think. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD 2024-11-25 15:06 ` Krzysztof Kozlowski @ 2024-11-26 16:34 ` Sasha Finkelstein 2024-11-26 16:52 ` Krzysztof Kozlowski 0 siblings, 1 reply; 32+ messages in thread From: Sasha Finkelstein @ 2024-11-26 16:34 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: Nick Chan, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel On Mon, 25 Nov 2024 at 16:07, Krzysztof Kozlowski <krzk@kernel.org> wrote: > > BTW, max-brightness is a property of backlight, not panel, I think. This is an oled panel, so no separate backlight device, the mipi commands just change the pixel brightness. There is prior art in other bindings on having the max-brightness property attached to the panel itself. ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD 2024-11-26 16:34 ` Sasha Finkelstein @ 2024-11-26 16:52 ` Krzysztof Kozlowski 0 siblings, 0 replies; 32+ messages in thread From: Krzysztof Kozlowski @ 2024-11-26 16:52 UTC (permalink / raw) To: Sasha Finkelstein Cc: Nick Chan, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi, linux-arm-kernel, dri-devel, devicetree, linux-kernel On 26/11/2024 17:34, Sasha Finkelstein wrote: > On Mon, 25 Nov 2024 at 16:07, Krzysztof Kozlowski <krzk@kernel.org> wrote: >> >> BTW, max-brightness is a property of backlight, not panel, I think. > This is an oled panel, so no separate backlight device, the mipi commands > just change the pixel brightness. There is prior art in other bindings on having > the max-brightness property attached to the panel itself. Where? git grep gave me only one result for bindings - old Samsung panel from 15 years ago. If you refer to this one, then use it as example for the bindings with similar explanation as the commit introducing brightness? Best regards, Krzysztof ^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 4/5] arm64: dts: apple: Add touchbar screen nodes 2024-11-24 22:29 [PATCH 0/5] Driver for pre-DCP apple display controller Sasha Finkelstein via B4 Relay ` (2 preceding siblings ...) 2024-11-24 22:29 ` [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 ` Sasha Finkelstein via B4 Relay 2024-11-25 8:39 ` Nick Chan 2024-11-25 8:43 ` Nick Chan 2024-11-24 22:29 ` [PATCH 5/5] MAINTAINERS: Add entries for touchbar display driver Sasha Finkelstein via B4 Relay 4 siblings, 2 replies; 32+ messages in thread From: Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 UTC (permalink / raw) To: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Sasha Finkelstein, Janne Grunau From: Sasha Finkelstein <fnkl.kernel@gmail.com> Adds device tree entries for the touchbar screen Co-developed-by: Janne Grunau <j@jannau.net> Signed-off-by: Janne Grunau <j@jannau.net> Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> --- arch/arm64/boot/dts/apple/t8103-j293.dts | 8 ++++++++ arch/arm64/boot/dts/apple/t8103.dtsi | 26 ++++++++++++++++++++++++++ arch/arm64/boot/dts/apple/t8112-j493.dts | 15 +++++++++++++++ arch/arm64/boot/dts/apple/t8112.dtsi | 25 +++++++++++++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8103-j293.dts b/arch/arm64/boot/dts/apple/t8103-j293.dts index 56b0c67bfcda321b60c621de092643017693ff91..349a8fce6b0b8ccf3305f940ba7242e2c1a67754 100644 --- a/arch/arm64/boot/dts/apple/t8103-j293.dts +++ b/arch/arm64/boot/dts/apple/t8103-j293.dts @@ -49,3 +49,11 @@ &i2c4 { &fpwm1 { status = "okay"; }; + +&display_dfr { + status = "okay"; + dfr_panel: panel@0 { + compatible = "apple,summit"; + reg = <0>; + }; +}; diff --git a/arch/arm64/boot/dts/apple/t8103.dtsi b/arch/arm64/boot/dts/apple/t8103.dtsi index 9b0dad6b618444ac6b1c9735c50cccfc3965f947..b377c92c5db3cb4fea53ae2c5dd85acf038429a3 100644 --- a/arch/arm64/boot/dts/apple/t8103.dtsi +++ b/arch/arm64/boot/dts/apple/t8103.dtsi @@ -356,6 +356,32 @@ cpufreq_p: performance-controller@211e20000 { #performance-domain-cells = <0>; }; + display_dfr: display-pipe@228200000 { + compatible = "apple,t8103-display-pipe", "apple,h7-display-pipe"; + reg-names = "be", "fe", "mipi"; + reg = <0x2 0x28200000 0x0 0xc000>, + <0x2 0x28400000 0x0 0x4000>, + <0x2 0x28600000 0x0 0x100000>; + power-domains = <&ps_dispdfr_fe>, <&ps_dispdfr_be>, <&ps_mipi_dsi>; + interrupt-parent = <&aic>; + interrupts = <AIC_IRQ 502 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 506 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "be", "fe"; + status = "disabled"; + iommus = <&displaydfr_dart 0>; + #address-cells = <1>; + #size-cells = <0>; + }; + + displaydfr_dart: iommu@228304000 { + compatible = "apple,t8103-dart"; + reg = <0x2 0x28304000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = <AIC_IRQ 504 IRQ_TYPE_LEVEL_HIGH>; + #iommu-cells = <1>; + power-domains = <&ps_dispdfr_fe>; + }; + sio_dart: iommu@235004000 { compatible = "apple,t8103-dart"; reg = <0x2 0x35004000 0x0 0x4000>; diff --git a/arch/arm64/boot/dts/apple/t8112-j493.dts b/arch/arm64/boot/dts/apple/t8112-j493.dts index 0ad908349f55406783942735a2e9dad54cda00ec..80e371495f3e097f91e94549c7ac2949609f566f 100644 --- a/arch/arm64/boot/dts/apple/t8112-j493.dts +++ b/arch/arm64/boot/dts/apple/t8112-j493.dts @@ -35,6 +35,21 @@ led-0 { }; }; +&display_dfr { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + dfr_panel: panel@0 { + compatible = "apple,summit"; + reg = <0>; + }; +}; + +&displaydfr_dart { + status = "okay"; +}; + /* * Force the bus number assignments so that we can declare some of the * on-board devices and properties that are populated by the bootloader diff --git a/arch/arm64/boot/dts/apple/t8112.dtsi b/arch/arm64/boot/dts/apple/t8112.dtsi index 1666e6ab250bc0be9b8318e3c8fc903ccd3f3760..726b11376692580abb129b9be35107bee1550a93 100644 --- a/arch/arm64/boot/dts/apple/t8112.dtsi +++ b/arch/arm64/boot/dts/apple/t8112.dtsi @@ -379,6 +379,31 @@ cpufreq_p: cpufreq@211e20000 { #performance-domain-cells = <0>; }; + display_dfr: display-pipe@228200000 { + compatible = "apple,t8112-display-pipe", "apple,h7-display-pipe"; + reg-names = "be", "fe", "mipi"; + reg = <0x2 0x28200000 0x0 0xc000>, + <0x2 0x28400000 0x0 0x4000>, + <0x2 0x28600000 0x0 0x100000>; + power-domains = <&ps_dispdfr_fe>, <&ps_dispdfr_be>, <&ps_mipi_dsi>; + interrupt-parent = <&aic>; + interrupts = <AIC_IRQ 614 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 618 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "be", "fe"; + status = "disabled"; + iommus = <&displaydfr_dart 0>; + }; + + displaydfr_dart: iommu@228304000 { + compatible = "apple,t8110-dart"; + reg = <0x2 0x28304000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = <AIC_IRQ 616 IRQ_TYPE_LEVEL_HIGH>; + #iommu-cells = <1>; + power-domains = <&ps_dispdfr_fe>; + status = "disabled"; + }; + sio_dart: iommu@235004000 { compatible = "apple,t8110-dart"; reg = <0x2 0x35004000 0x0 0x4000>; -- 2.47.0 ^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 4/5] arm64: dts: apple: Add touchbar screen nodes 2024-11-24 22:29 ` [PATCH 4/5] arm64: dts: apple: Add touchbar screen nodes Sasha Finkelstein via B4 Relay @ 2024-11-25 8:39 ` Nick Chan 2024-11-25 8:43 ` Nick Chan 1 sibling, 0 replies; 32+ messages in thread From: Nick Chan @ 2024-11-25 8:39 UTC (permalink / raw) To: fnkl.kernel, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau Sasha Finkelstein via B4 Relay 於 2024/11/25 早上6:29 寫道: > From: Sasha Finkelstein <fnkl.kernel@gmail.com> > > Adds device tree entries for the touchbar screen > > Co-developed-by: Janne Grunau <j@jannau.net> > Signed-off-by: Janne Grunau <j@jannau.net> > Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> > --- > arch/arm64/boot/dts/apple/t8103-j293.dts | 8 ++++++++ > arch/arm64/boot/dts/apple/t8103.dtsi | 26 ++++++++++++++++++++++++++ > arch/arm64/boot/dts/apple/t8112-j493.dts | 15 +++++++++++++++ > arch/arm64/boot/dts/apple/t8112.dtsi | 25 +++++++++++++++++++++++++ > 4 files changed, 74 insertions(+) > > diff --git a/arch/arm64/boot/dts/apple/t8103-j293.dts b/arch/arm64/boot/dts/apple/t8103-j293.dts > index 56b0c67bfcda321b60c621de092643017693ff91..349a8fce6b0b8ccf3305f940ba7242e2c1a67754 100644 > --- a/arch/arm64/boot/dts/apple/t8103-j293.dts > +++ b/arch/arm64/boot/dts/apple/t8103-j293.dts > @@ -49,3 +49,11 @@ &i2c4 { > &fpwm1 { > status = "okay"; > }; > + > +&display_dfr { Inconsistent placement of #address-cells and #size-cells. > + status = "okay"; There should be a blank line here. > + dfr_panel: panel@0 { > + compatible = "apple,summit"; > + reg = <0>; > + }; > +}; > diff --git a/arch/arm64/boot/dts/apple/t8103.dtsi b/arch/arm64/boot/dts/apple/t8103.dtsi > index 9b0dad6b618444ac6b1c9735c50cccfc3965f947..b377c92c5db3cb4fea53ae2c5dd85acf038429a3 100644 > --- a/arch/arm64/boot/dts/apple/t8103.dtsi > +++ b/arch/arm64/boot/dts/apple/t8103.dtsi > @@ -356,6 +356,32 @@ cpufreq_p: performance-controller@211e20000 { > #performance-domain-cells = <0>; > }; > > + display_dfr: display-pipe@228200000 { > + compatible = "apple,t8103-display-pipe", "apple,h7-display-pipe"; > + reg-names = "be", "fe", "mipi"; > + reg = <0x2 0x28200000 0x0 0xc000>, > + <0x2 0x28400000 0x0 0x4000>, > + <0x2 0x28600000 0x0 0x100000>; > + power-domains = <&ps_dispdfr_fe>, <&ps_dispdfr_be>, <&ps_mipi_dsi>; > + interrupt-parent = <&aic>; > + interrupts = <AIC_IRQ 502 IRQ_TYPE_LEVEL_HIGH>, > + <AIC_IRQ 506 IRQ_TYPE_LEVEL_HIGH>; > + interrupt-names = "be", "fe"; > + status = "disabled"; > + iommus = <&displaydfr_dart 0>; > + #address-cells = <1>; > + #size-cells = <0>; Inconsistent placement of #address-cells and #size-cells. > + }; > + > + displaydfr_dart: iommu@228304000 { > + compatible = "apple,t8103-dart"; > + reg = <0x2 0x28304000 0x0 0x4000>; > + interrupt-parent = <&aic>; > + interrupts = <AIC_IRQ 504 IRQ_TYPE_LEVEL_HIGH>; > + #iommu-cells = <1>; > + power-domains = <&ps_dispdfr_fe>; Not every M1 (T8103) device has a touch bar. Disable it here and then enable it in t8103-j293.dts. > + }; > + > sio_dart: iommu@235004000 { > compatible = "apple,t8103-dart"; > reg = <0x2 0x35004000 0x0 0x4000>; > diff --git a/arch/arm64/boot/dts/apple/t8112-j493.dts b/arch/arm64/boot/dts/apple/t8112-j493.dts > index 0ad908349f55406783942735a2e9dad54cda00ec..80e371495f3e097f91e94549c7ac2949609f566f 100644 > --- a/arch/arm64/boot/dts/apple/t8112-j493.dts > +++ b/arch/arm64/boot/dts/apple/t8112-j493.dts > @@ -35,6 +35,21 @@ led-0 { > }; > }; > > +&display_dfr { > + status = "okay"; status should be after other properties, before child nodes. > + #address-cells = <1>; > + #size-cells = <0>; Inconsistent placement of #address-cells and #size-cells. I would place them in t8112.dtsi. > + > + dfr_panel: panel@0 { > + compatible = "apple,summit"; > + reg = <0>; > + }; > +}; > + > +&displaydfr_dart { > + status = "okay"; > +}; > + > /* > * Force the bus number assignments so that we can declare some of the > * on-board devices and properties that are populated by the bootloader > diff --git a/arch/arm64/boot/dts/apple/t8112.dtsi b/arch/arm64/boot/dts/apple/t8112.dtsi > index 1666e6ab250bc0be9b8318e3c8fc903ccd3f3760..726b11376692580abb129b9be35107bee1550a93 100644 > --- a/arch/arm64/boot/dts/apple/t8112.dtsi > +++ b/arch/arm64/boot/dts/apple/t8112.dtsi > @@ -379,6 +379,31 @@ cpufreq_p: cpufreq@211e20000 { > #performance-domain-cells = <0>; > }; > > + display_dfr: display-pipe@228200000 { > + compatible = "apple,t8112-display-pipe", "apple,h7-display-pipe"; > + reg-names = "be", "fe", "mipi"; > + reg = <0x2 0x28200000 0x0 0xc000>, > + <0x2 0x28400000 0x0 0x4000>, > + <0x2 0x28600000 0x0 0x100000>; > + power-domains = <&ps_dispdfr_fe>, <&ps_dispdfr_be>, <&ps_mipi_dsi>; > + interrupt-parent = <&aic>; > + interrupts = <AIC_IRQ 614 IRQ_TYPE_LEVEL_HIGH>, > + <AIC_IRQ 618 IRQ_TYPE_LEVEL_HIGH>; > + interrupt-names = "be", "fe"; > + status = "disabled"; > + iommus = <&displaydfr_dart 0>; > + }; > + > + displaydfr_dart: iommu@228304000 { > + compatible = "apple,t8110-dart"; > + reg = <0x2 0x28304000 0x0 0x4000>; > + interrupt-parent = <&aic>; > + interrupts = <AIC_IRQ 616 IRQ_TYPE_LEVEL_HIGH>; > + #iommu-cells = <1>; > + power-domains = <&ps_dispdfr_fe>; > + status = "disabled"; > + }; > + > sio_dart: iommu@235004000 { > compatible = "apple,t8110-dart"; > reg = <0x2 0x35004000 0x0 0x4000>; > Nick Chan ^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 4/5] arm64: dts: apple: Add touchbar screen nodes 2024-11-24 22:29 ` [PATCH 4/5] arm64: dts: apple: Add touchbar screen nodes Sasha Finkelstein via B4 Relay 2024-11-25 8:39 ` Nick Chan @ 2024-11-25 8:43 ` Nick Chan 1 sibling, 0 replies; 32+ messages in thread From: Nick Chan @ 2024-11-25 8:43 UTC (permalink / raw) To: fnkl.kernel, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Janne Grunau Sasha Finkelstein via B4 Relay 於 2024/11/25 早上6:29 寫道: [...] > diff --git a/arch/arm64/boot/dts/apple/t8112.dtsi b/arch/arm64/boot/dts/apple/t8112.dtsi > index 1666e6ab250bc0be9b8318e3c8fc903ccd3f3760..726b11376692580abb129b9be35107bee1550a93 100644 > --- a/arch/arm64/boot/dts/apple/t8112.dtsi > +++ b/arch/arm64/boot/dts/apple/t8112.dtsi > @@ -379,6 +379,31 @@ cpufreq_p: cpufreq@211e20000 { > #performance-domain-cells = <0>; > }; > > + display_dfr: display-pipe@228200000 { > + compatible = "apple,t8112-display-pipe", "apple,h7-display-pipe"; > + reg-names = "be", "fe", "mipi"; > + reg = <0x2 0x28200000 0x0 0xc000>, > + <0x2 0x28400000 0x0 0x4000>, > + <0x2 0x28600000 0x0 0x100000>; > + power-domains = <&ps_dispdfr_fe>, <&ps_dispdfr_be>, <&ps_mipi_dsi>; > + interrupt-parent = <&aic>; > + interrupts = <AIC_IRQ 614 IRQ_TYPE_LEVEL_HIGH>, > + <AIC_IRQ 618 IRQ_TYPE_LEVEL_HIGH>; > + interrupt-names = "be", "fe"; > + status = "disabled"; Forgot to add, status should go after other properties here as well. > + iommus = <&displaydfr_dart 0>; > + }; [...] Nick Chan ^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 5/5] MAINTAINERS: Add entries for touchbar display driver 2024-11-24 22:29 [PATCH 0/5] Driver for pre-DCP apple display controller Sasha Finkelstein via B4 Relay ` (3 preceding siblings ...) 2024-11-24 22:29 ` [PATCH 4/5] arm64: dts: apple: Add touchbar screen nodes Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 ` Sasha Finkelstein via B4 Relay 2024-11-25 9:24 ` Nick Chan 4 siblings, 1 reply; 32+ messages in thread From: Sasha Finkelstein via B4 Relay @ 2024-11-24 22:29 UTC (permalink / raw) To: Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel, Sasha Finkelstein From: Sasha Finkelstein <fnkl.kernel@gmail.com> Add the MAINTAINERS entries for the driver Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index e7f0170977013889ca7c39b17727ba36d32e92dc..1964bb705cae0b0f12e2174fc96c5cd123d31520 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2164,6 +2164,7 @@ F: Documentation/devicetree/bindings/arm/apple.yaml F: Documentation/devicetree/bindings/arm/apple/* F: Documentation/devicetree/bindings/clock/apple,nco.yaml F: Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml +F: Documentation/devicetree/bindings/display/apple,display-pipe.yaml F: Documentation/devicetree/bindings/dma/apple,admac.yaml F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml F: Documentation/devicetree/bindings/interrupt-controller/apple,* @@ -2183,6 +2184,7 @@ F: drivers/bluetooth/hci_bcm4377.c F: drivers/clk/clk-apple-nco.c F: drivers/cpufreq/apple-soc-cpufreq.c F: drivers/dma/apple-admac.c +F: drivers/gpu/drm/adp/ F: drivers/pmdomain/apple/ F: drivers/i2c/busses/i2c-pasemi-core.c F: drivers/i2c/busses/i2c-pasemi-platform.c -- 2.47.0 ^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 5/5] MAINTAINERS: Add entries for touchbar display driver 2024-11-24 22:29 ` [PATCH 5/5] MAINTAINERS: Add entries for touchbar display driver Sasha Finkelstein via B4 Relay @ 2024-11-25 9:24 ` Nick Chan 0 siblings, 0 replies; 32+ messages in thread From: Nick Chan @ 2024-11-25 9:24 UTC (permalink / raw) To: fnkl.kernel, Hector Martin, Sven Peter, Alyssa Rosenzweig, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Jessica Zhang, asahi Cc: linux-arm-kernel, dri-devel, devicetree, linux-kernel Sasha Finkelstein via B4 Relay 於 2024/11/25 早上6:29 寫道: > From: Sasha Finkelstein <fnkl.kernel@gmail.com> > > Add the MAINTAINERS entries for the driver > > Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> > --- > MAINTAINERS | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index e7f0170977013889ca7c39b17727ba36d32e92dc..1964bb705cae0b0f12e2174fc96c5cd123d31520 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -2164,6 +2164,7 @@ F: Documentation/devicetree/bindings/arm/apple.yaml > F: Documentation/devicetree/bindings/arm/apple/* > F: Documentation/devicetree/bindings/clock/apple,nco.yaml > F: Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml > +F: Documentation/devicetree/bindings/display/apple,display-pipe.yaml Missing F: Documentation/devicetree/bindings/display/panel/apple,summit.yaml > F: Documentation/devicetree/bindings/dma/apple,admac.yaml > F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml > F: Documentation/devicetree/bindings/interrupt-controller/apple,* > @@ -2183,6 +2184,7 @@ F: drivers/bluetooth/hci_bcm4377.c > F: drivers/clk/clk-apple-nco.c > F: drivers/cpufreq/apple-soc-cpufreq.c > F: drivers/dma/apple-admac.c > +F: drivers/gpu/drm/adp/ > F: drivers/pmdomain/apple/ > F: drivers/i2c/busses/i2c-pasemi-core.c > F: drivers/i2c/busses/i2c-pasemi-platform.c > Nick Chan ^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2024-11-26 16:53 UTC | newest] Thread overview: 32+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-11-24 22:29 [PATCH 0/5] Driver for pre-DCP apple display controller Sasha Finkelstein via B4 Relay 2024-11-24 22:29 ` [PATCH 1/5] dt-bindgins: display: Add Apple pre-DCP display controller bindings Sasha Finkelstein via B4 Relay 2024-11-25 2:06 ` Rob Herring (Arm) 2024-11-25 7:45 ` Krzysztof Kozlowski 2024-11-25 14:14 ` Hector Martin 2024-11-25 14:53 ` Krzysztof Kozlowski 2024-11-25 15:29 ` Hector Martin 2024-11-24 22:29 ` [PATCH 2/5] gpu: drm: adp: Add Apple Display Pipe driver Sasha Finkelstein via B4 Relay 2024-11-25 8:50 ` Neil Armstrong 2024-11-25 11:24 ` Sasha Finkelstein 2024-11-25 12:57 ` neil.armstrong 2024-11-25 13:14 ` Sasha Finkelstein 2024-11-25 13:16 ` neil.armstrong 2024-11-25 14:24 ` Hector Martin 2024-11-25 15:28 ` Maxime Ripard 2024-11-25 15:55 ` Hector Martin 2024-11-25 15:37 ` neil.armstrong 2024-11-25 9:04 ` Jani Nikula 2024-11-25 10:59 ` Alyssa Ross 2024-11-24 22:29 ` [PATCH 3/5] gpu: drm: adp: Add a backlight driver for the Summit LCD Sasha Finkelstein via B4 Relay 2024-11-25 8:45 ` Neil Armstrong 2024-11-25 11:28 ` Sasha Finkelstein 2024-11-25 14:49 ` Krzysztof Kozlowski 2024-11-25 15:03 ` Nick Chan 2024-11-25 15:06 ` Krzysztof Kozlowski 2024-11-26 16:34 ` Sasha Finkelstein 2024-11-26 16:52 ` Krzysztof Kozlowski 2024-11-24 22:29 ` [PATCH 4/5] arm64: dts: apple: Add touchbar screen nodes Sasha Finkelstein via B4 Relay 2024-11-25 8:39 ` Nick Chan 2024-11-25 8:43 ` Nick Chan 2024-11-24 22:29 ` [PATCH 5/5] MAINTAINERS: Add entries for touchbar display driver Sasha Finkelstein via B4 Relay 2024-11-25 9:24 ` Nick Chan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).