Add Apple Mac System Management Controller GPIOs
Subsystems (7)
v2 cover Add Apple Mac System Management Controller GPIOs
Hi,
[Andy dropped from the Cc lists; he's taking a break.]
This series adds support for the Apple Mac GPIO driver. These GPIOs are hadled via the System Management Controller.
The first two patches add the DT binding documentation for the new drivers. No changes from the first posting (I think there's still some discussion going on about how best to handle these.)
Patch 3 adds apple_rtkit_poll() and has had no changes since v1.
Patch 4 is new, extending the existing FourCC format code to be able to print other endian FourCC codes.
Patch 5 adds the SMC core and rtkit driver. Changes in v2 include properly limiting the data size (since it is limited to the width of the size fields in the mailbox messages, not the shmem size) and also to properly cleanup after failure to send the initialisation message.
Patch 6 adds the SMC GPIO support. Changes in v2 include some of the issues Andy pointed out,
Patch 7 is new, adding the SMC nodes to the dtsi.
Patches taken from the Asahi project.
Documentation/core-api/printk-formats.rst | 32 ++ .../devicetree/bindings/gpio/gpio-macsmc.yaml | 28 ++ .../devicetree/bindings/mfd/apple,smc.yaml | 65 +++ arch/arm64/boot/dts/apple/t8103.dtsi | 26 ++ drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-macsmc.c | 242 +++++++++++ drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/apple/Kconfig | 49 +++ drivers/platform/apple/Makefile | 11 + drivers/platform/apple/smc.h | 28 ++ drivers/platform/apple/smc_core.c | 249 +++++++++++ drivers/platform/apple/smc_rtkit.c | 453 +++++++++++++++++++++ drivers/soc/apple/rtkit.c | 6 + include/linux/mfd/macsmc.h | 86 ++++ include/linux/soc/apple/rtkit.h | 12 + lib/vsprintf.c | 35 +- 18 files changed, 1331 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-macsmc.yaml create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml create mode 100644 drivers/gpio/gpio-macsmc.c create mode 100644 drivers/platform/apple/Kconfig create mode 100644 drivers/platform/apple/Makefile create mode 100644 drivers/platform/apple/smc.h create mode 100644 drivers/platform/apple/smc_core.c create mode 100644 drivers/platform/apple/smc_rtkit.c create mode 100644 include/linux/mfd/macsmc.h
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
PATCH 1/7 dt-bindings: mfd: add binding for Apple Mac System Management Controller
Add a DT binding for the Apple Mac System Management Controller.
--- .../devicetree/bindings/mfd/apple,smc.yaml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +61 -0
@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/apple,smc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mac System Management Controller + +maintainers: + - Hector Martin <[email protected]> + +description: + Apple Mac System Management Controller implements various functions + such as GPIO, RTC, power, reboot. + +properties: + compatible: + items: + - enum: + - apple,t6000-smc + - apple,t8103-smc + - apple,t8112-smc + - const: apple,smc + + reg: + items: + - description: SMC area + - description: SRAM area + + reg-names: + items: + - const: smc + - const: sram + + mboxes: + maxItems: 1 + description: + A phandle to the mailbox channel + +additionalProperties: false + +required: + - compatible + - reg + - reg-names + - mboxes + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + smc@23e400000 { + compatible = "apple,t8103-smc", "apple,smc"; + reg = <0x2 0x3e400000 0x0 0x4000>, + <0x2 0x3fe00000 0x0 0x100000>; + reg-names = "smc", "sram"; + mboxes = <&smc_mbox>; + }; + };
Signature · 1 line
2.30.2
Re: [PATCH 1/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller
Quoted 6 lines
From: "Russell King (Oracle)" <[email protected]>
Date: Tue, 06 Sep 2022 14:19:29 +0100Add a DT binding for the Apple Mac System Management Controller.
Signed-off-by Russell King (Oracle) <[email protected]>
Quoted 81 lines
--- .../devicetree/bindings/mfd/apple,smc.yaml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yamlDocumentation/devicetree/bindings/mfd/apple,smc.yaml new file +61
-0@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/apple,smc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mac System Management Controller + +maintainers: + - Hector Martin <[email protected]> + +description: + Apple Mac System Management Controller implements various functions + such as GPIO, RTC, power, reboot. + +properties: + compatible: + items: + - enum: + - apple,t6000-smc + - apple,t8103-smc + - apple,t8112-smc + - const: apple,smc + + reg: + items: + - description: SMC area + - description: SRAM area + + reg-names: + items: + - const: smc + - const: sram + + mboxes: + maxItems: 1 + description: + A phandle to the mailbox channel + +additionalProperties: false + +required: + - compatible + - reg + - reg-names + - mboxes + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + smc@23e400000 { + compatible = "apple,t8103-smc", "apple,smc"; + reg = <0x2 0x3e400000 0x0 0x4000>, + <0x2 0x3fe00000 0x0 0x100000>; + reg-names = "smc", "sram"; + mboxes = <&smc_mbox>; + }; + };Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Rob Herring
maintainerRe: [PATCH 1/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller
In reply to Russell King (Oracle)Quoted 42 lines · Russell King (Oracle)
Add a DT binding for the Apple Mac System Management Controller.
Signed-off-by Russell King (Oracle) <[email protected]>--- .../devicetree/bindings/mfd/apple,smc.yaml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yamlDocumentation/devicetree/bindings/mfd/apple,smc.yaml new file +28
-0@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/apple,smc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mac System Management Controller + +maintainers: + - Hector Martin <[email protected]> + +description: + Apple Mac System Management Controller implements various functions + such as GPIO, RTC, power, reboot. + +properties: + compatible: + items: + - enum: + - apple,t6000-smc + - apple,t8103-smc + - apple,t8112-smc + - const: apple,smc + + reg: + items: + - description: SMC area + - description: SRAM area
Documentation/devicetree/bindings/mfd/apple,smc.yaml line 38
Quoted 10 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +10
-0+ + reg-names: + items: + - const: smc + - const: sram + + mboxes: + maxItems: 1 + description: + A phandle to the mailbox channel
That's every 'mboxes'. Drop generic descriptions on common properties.
Quoted 27 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +23
-0+ +additionalProperties: false + +required: + - compatible + - reg + - reg-names + - mboxes + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + smc@23e400000 { + compatible = "apple,t8103-smc", "apple,smc"; + reg = <0x2 0x3e400000 0x0 0x4000>, + <0x2 0x3fe00000 0x0 0x100000>; + reg-names = "smc", "sram"; + mboxes = <&smc_mbox>; + }; + };Signature · 1 line
2.30.2
PATCH 2/7 dt-bindings: gpio: add binding for the GPIO block for Apple Mac SMC
In reply to Russell King (Oracle)Add the DT binding for the Apple Mac System Management Controller GPIOs.
--- .../devicetree/bindings/gpio/gpio-macsmc.yaml | 28 +++++++++++++++++++ .../devicetree/bindings/mfd/apple,smc.yaml | 4 +++ 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-macsmc.yaml
Documentation/devicetree/bindings/gpio/gpio-macsmc.yaml new file +28 -0
@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/gpio-macsmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mac System Management Controller GPIO + +maintainers: + - Hector Martin <[email protected]> + +description: + This describes the binding for the Apple Mac System Management Controller + GPIO block. + +properties: + gpio-controller: true + '#gpio-cells': + const: 2 + +additionalProperties: false + +examples: + - | + smc_gpio: gpio { + gpio-controller; + #gpio-cells = <2>; + };
Documentation/devicetree/bindings/mfd/apple,smc.yaml +4 -0
@@ -37,6 +37,10 @@ title: Apple Mac System Management Controller description: A phandle to the mailbox channel +patternProperties: + gpio: + $ref: /schemas/gpio/gpio-macsmc.yaml + additionalProperties: false required:
Signature · 1 line
2.30.2
Re: [PATCH 2/7] dt-bindings: gpio: add binding for the GPIO block for Apple Mac SMC
Quoted 6 lines
From: "Russell King (Oracle)" <[email protected]>
Date: Tue, 06 Sep 2022 14:19:34 +0100Add the DT binding for the Apple Mac System Management Controller GPIOs.
Signed-off-by Russell King (Oracle) <[email protected]>
Quoted 64 lines
--- .../devicetree/bindings/gpio/gpio-macsmc.yaml | 28 +++++++++++++++++++ .../devicetree/bindings/mfd/apple,smc.yaml | 4 +++ 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-macsmc.yamlDocumentation/devicetree/bindings/gpio/gpio-macsmc.yaml new file +28
-0@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/gpio-macsmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mac System Management Controller GPIO + +maintainers: + - Hector Martin <[email protected]> + +description: + This describes the binding for the Apple Mac System Management Controller + GPIO block. + +properties: + gpio-controller: true + '#gpio-cells': + const: 2 + +additionalProperties: false + +examples: + - | + smc_gpio: gpio { + gpio-controller; + #gpio-cells = <2>; + };Documentation/devicetree/bindings/mfd/apple,smc.yaml +4
-0@@ -37,6 +37,10 @@ title: Apple Mac System Management Controller description: A phandle to the mailbox channel +patternProperties: + gpio: + $ref: /schemas/gpio/gpio-macsmc.yaml + additionalProperties: false required:Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Rob Herring
maintainerRe: [PATCH 2/7] dt-bindings: gpio: add binding for the GPIO block for Apple Mac SMC
In reply to Russell King (Oracle)Quoted 33 lines · Russell King (Oracle)
Add the DT binding for the Apple Mac System Management Controller GPIOs.
Signed-off-by Russell King (Oracle) <[email protected]>--- .../devicetree/bindings/gpio/gpio-macsmc.yaml | 28 +++++++++++++++++++ .../devicetree/bindings/mfd/apple,smc.yaml | 4 +++ 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-macsmc.yamlDocumentation/devicetree/bindings/gpio/gpio-macsmc.yaml new file +18
-0@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/gpio-macsmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mac System Management Controller GPIO + +maintainers: + - Hector Martin <[email protected]> + +description: + This describes the binding for the Apple Mac System Management Controller + GPIO block. + +properties: + gpio-controller: true + '#gpio-cells':
Documentation/devicetree/bindings/gpio/gpio-macsmc.yaml line 28
Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio-macsmc.yaml new file +10
-0+ const: 2 + +additionalProperties: false + +examples: + - | + smc_gpio: gpio { + gpio-controller; + #gpio-cells = <2>; + };
Please move the example to the mfd schema. One complete example rather than piecemeal examples.
Documentation/devicetree/bindings/mfd/apple,smc.yaml title: Apple Mac System Management Controller · line 43
Quoted 12 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml +4
-0@@ -37,6 +37,10 @@ title: Apple Mac System Management Controller description: A phandle to the mailbox channel +patternProperties: + gpio: + $ref: /schemas/gpio/gpio-macsmc.yaml +
Reorder the patches such that the MFD binding is last and this hunk can be part of it.
Rob
Re: [PATCH 2/7] dt-bindings: gpio: add binding for the GPIO block for Apple Mac SMC
In reply to Russell King (Oracle)Quoted 48 lines · Russell King (Oracle)
Add the DT binding for the Apple Mac System Management Controller GPIOs.
Signed-off-by Russell King (Oracle) <[email protected]>--- .../devicetree/bindings/gpio/gpio-macsmc.yaml | 28 +++++++++++++++++++ .../devicetree/bindings/mfd/apple,smc.yaml | 4 +++ 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-macsmc.yamlDocumentation/devicetree/bindings/gpio/gpio-macsmc.yaml new file +28
-0@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/gpio-macsmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mac System Management Controller GPIO + +maintainers: + - Hector Martin <[email protected]> + +description: + This describes the binding for the Apple Mac System Management Controller + GPIO block. + +properties: + gpio-controller: true + '#gpio-cells': + const: 2 + +additionalProperties: false + +examples: + - | + smc_gpio: gpio { + gpio-controller; + #gpio-cells = <2>; + };Documentation/devicetree/bindings/mfd/apple,smc.yaml +0
-0
Documentation/devicetree/bindings/mfd/apple,smc.yaml title: Apple Mac System Management Controller · line 41
Quoted 5 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml +2
-0@@ -37,6 +37,10 @@ title: Apple Mac System Management Controller description: A phandle to the mailbox channel +patternProperties: + gpio:
This is not a pattern. Should be in properties.
Please run make dt_binding_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions).
Best regards,
Krzysztof
Re: [PATCH 2/7] dt-bindings: gpio: add binding for the GPIO block for Apple Mac SMC
Quoted 52 lines · Krzysztof Kozlowski
Quoted 51 lines · Russell King (Oracle)
Add the DT binding for the Apple Mac System Management Controller GPIOs.
Signed-off-by Russell King (Oracle) <[email protected]>--- .../devicetree/bindings/gpio/gpio-macsmc.yaml | 28 +++++++++++++++++++ .../devicetree/bindings/mfd/apple,smc.yaml | 4 +++ 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-macsmc.yamlDocumentation/devicetree/bindings/gpio/gpio-macsmc.yaml new file +28
-0@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/gpio-macsmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mac System Management Controller GPIO + +maintainers: + - Hector Martin <[email protected]> + +description: + This describes the binding for the Apple Mac System Management Controller + GPIO block. + +properties: + gpio-controller: true + '#gpio-cells': + const: 2 + +additionalProperties: false + +examples: + - | + smc_gpio: gpio { + gpio-controller; + #gpio-cells = <2>; + };Documentation/devicetree/bindings/mfd/apple,smc.yaml +0
-0@@ -37,6 +37,10 @@ title: Apple Mac System Management Controller description: A phandle to the mailbox channel
Quoted 7 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml title: Apple Mac System Management Controller · line 41
Quoted 2 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml +2
-0+patternProperties: + gpio:This is not a pattern. Should be in properties.
Please run
make dt_binding_check(seeDocumentation/devicetree/bindings/writing-schema.rstfor instructions).
I did. It didn't warn for me. Yes, I had updated it immediately prior. Yes I had installed the lint package.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
PATCH 3/7 soc: apple: rtkit: Add apple_rtkit_poll
In reply to Russell King (Oracle)From: Hector Martin <[email protected]>
This allows a client to receive messages in atomic context, by polling.
--- drivers/soc/apple/rtkit.c | 6 ++++++ include/linux/soc/apple/rtkit.h | 12 ++++++++++++ 2 files changed, 18 insertions(+)
drivers/soc/apple/rtkit.c +6 -0
@@ -660,6 +660,12 @@ int apple_rtkit_send_message_wait(struct apple_rtkit *rtk, u8 ep, u64 message, }EXPORT_SYMBOL_GPL (apple_rtkit_send_message_wait); +int apple_rtkit_poll (struct apple_rtkit *rtk) +{ +return mbox_client_peek_data (rtk->mbox_chan); +} +EXPORT_SYMBOL_GPL (apple_rtkit_poll); +int apple_rtkit_start_ep (struct apple_rtkit *rtk,u8 endpoint) {u64 msg;
include/linux/soc/apple/rtkit.h +12 -0
@@ -152,4 +152,16 @@ int apple_rtkit_send_message(struct apple_rtkit *rtk, u8 ep, u64 message,int apple_rtkit_send_message_wait (struct apple_rtkit *rtk,u8 ep,u64 message,unsigned long timeout,bool atomic); +/* +* Process incoming messages in atomic context. +* This only guarantees that messages arrive as far as the recv_message_early +* callback; drivers expecting to handle incoming messages synchronously +* by calling this function must do it that way. +* Will return 1 if some data was processed, 0 if none was, or a +* negative error code on failure. +* +* @rtk: RTKit reference +*/ +int apple_rtkit_poll (struct apple_rtkit *rtk); +#endif /* _LINUX_APPLE_RTKIT_H_ */
Signature · 1 line
2.30.2
PATCH 4/7 lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
In reply to Russell King (Oracle)From: Hector Martin <[email protected]>
%p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but it's useful to be able to print generic 4-character codes formatted as an integer. Extend it to add format specifiers for printing generic 32-bit FOURCCs with various endian semantics:
%p4ch Host-endian
%p4cl Little-endian
%p4cb Big-endian
%p4cr Reverse-endian
The endianness determines how bytes are interpreted as a u32, and the FOURCC is then always printed MSByte-first (this is the opposite of V4L/DRM FOURCCs). This covers most practical cases, e.g. %p4cr would allow printing LSByte-first FOURCCs stored in host endian order (other than the hex form being in character order, not the integer value).
--- Documentation/core-api/printk-formats.rst | 32 +++++++++++++++++++++ lib/vsprintf.c | 35 +++++++++++++++++++---- 2 files changed, 61 insertions(+), 6 deletions(-)
Documentation/core-api/printk-formats.rst +32 -0
@@ -625,6 +625,38 @@ Passed by reference. %p4cc Y10 little-endian (0x20303159) %p4cc NV12 big-endian (0xb231564e) +Generic FourCC code +------------------- + +:: + %p4c[hnbl] gP00 (0x67503030) + +Print a generic FourCC code, as both ASCII characters and its numerical +value as hexadecimal. + +The additional ``h``, ``r``, ``b``, and ``l`` specifiers are used to specify +host, reversed, big or little endian order data respectively. Host endian +order means the data is interpreted as a 32-bit integer and the most +significant byte is printed first; that is, the character code as printed +matches the byte order stored in memory on big-endian systems, and is reversed +on little-endian systems. + +Passed by reference. + +Examples for a little-endian machine, given &(u32)0x67503030:: + + %p4ch gP00 (0x67503030) + %p4cl gP00 (0x67503030) + %p4cb 00Pg (0x30305067) + %p4cr 00Pg (0x30305067) + +Examples for a big-endian machine, given &(u32)0x67503030:: + + %p4ch gP00 (0x67503030) + %p4cl 00Pg (0x30305067) + %p4cb gP00 (0x67503030) + %p4cr 00Pg (0x30305067) + Thanks ======
lib/vsprintf.c +29 -6
@@ -1757,27 +1757,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,char output[sizeof ("0123 little-endian (0x01234567)" )];char *p = output;unsigned int i; +bool pix_fmt = false;u32 orig, val; -if (fmt[1 ] !='c' || fmt[2 ] !='c' ) +if (fmt[1 ] !='c' )return error_string (buf, end,"(%p4?)" , spec);if (check_pointer (&buf, end, fourcc, spec))return buf; orig =get_unaligned (fourcc); - val = orig & ~BIT (31 ); +switch (fmt[2 ]) { +case 'h' : + val = orig; +break ; +case 'r' : + val = orig =swab32 (orig); +break ; +case 'l' : + val = orig =le32_to_cpu (orig); +break ; +case 'b' : + val = orig =be32_to_cpu (orig); +break ; +case 'c' : +/* Pixel formats are printed LSB-first */ + val =swab32 (orig & ~BIT (31 )); + pix_fmt = true; +break ; +default : +return error_string (buf, end,"(%p4?)" , spec); + }for (i =0 ; i <sizeof (u32); i++) { -unsigned char c = val >> (i *8 ); +unsigned char c = val >> ((3 - i) *8 );/* Print non-control ASCII characters as-is, dot otherwise */ *p++ =isascii (c) &&isprint (c) ? c :'.' ; } - *p++ =' ' ; -strcpy (p, orig &BIT (31 ) ?"big-endian" :"little-endian" ); - p +=strlen (p); +if (pix_fmt) { + *p++ =' ' ; +strcpy (p, orig &BIT (31 ) ?"big-endian" :"little-endian" ); + p +=strlen (p); + } *p++ =' ' ; *p++ ='(' ;
Signature · 1 line
2.30.2
Rasmus Villemoes
reviewerRe: [PATCH 4/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
Quoted 11 lines · Russell King (Oracle)
From: Hector Martin <[email protected]>
%p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but it's useful to be able to print generic 4-character codes formatted as an integer. Extend it to add format specifiers for printing generic 32-bit FOURCCs with various endian semantics:
Documentation/core-api/printk-formats.rst | 32 +++++++++++++++++++++ lib/vsprintf.c | 35 +++++++++++++++++++---- 2 files changed, 61 insertions(+), 6 deletions(-)
Please also update lib/test_printf.c with a few test cases when modifying/extending vsnprintf().
Quoted 5 lines
Documentation/core-api/printk-formats.rst +0
-0
Documentation/core-api/printk-formats.rst Passed by reference. · line 633
Quoted 9 lines
Documentation/core-api/printk-formats.rst +6
-0@@ -625,6 +625,38 @@ Passed by reference. %p4cc Y10 little-endian (0x20303159) %p4cc NV12 big-endian (0xb231564e) +Generic FourCC code +------------------- + +:: + %p4c[hnbl] gP00 (0x67503030) +
Typo, I think. hrbl ?
Rasmus
Petr Mladek
maintainerRe: [PATCH 4/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
In reply to Russell King (Oracle)Quoted 39 lines · Russell King
From: Hector Martin <[email protected]>
%p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but it's useful to be able to print generic 4-character codes formatted as an integer. Extend it to add format specifiers for printing generic 32-bit FOURCCs with various endian semantics:
%p4ch Host-endian
%p4cl Little-endian
%p4cb Big-endian
%p4cr Reverse-endianThe endianness determines how bytes are interpreted as a u32, and the FOURCC is then always printed MSByte-first (this is the opposite of V4L/DRM FOURCCs). This covers most practical cases, e.g. %p4cr would allow printing LSByte-first FOURCCs stored in host endian order (other than the hex form being in character order, not the integer value).
Documentation/core-api/printk-formats.rst +14
-0@@ -625,6 +625,38 @@ Passed by reference. %p4cc Y10 little-endian (0x20303159) %p4cc NV12 big-endian (0xb231564e) +Generic FourCC code +------------------- + +:: + %p4c[hnbl] gP00 (0x67503030) + +Print a generic FourCC code, as both ASCII characters and its numerical +value as hexadecimal. + +The additional ``h``, ``r``, ``b``, and ``l`` specifiers are used to specify +host, reversed, big or little endian order data respectively. Host endian +order means the data is interpreted as a 32-bit integer and the most +significant byte is printed first; that is, the character code as printed +matches the byte order stored in memory on big-endian systems, and is reversed
Documentation/core-api/printk-formats.rst Passed by reference. · line 651
Quoted 10 lines
Documentation/core-api/printk-formats.rst +10
-0+on little-endian systems. + +Passed by reference. + +Examples for a little-endian machine, given &(u32)0x67503030:: + + %p4ch gP00 (0x67503030) + %p4cl gP00 (0x67503030) + %p4cb 00Pg (0x30305067) + %p4cr 00Pg (0x30305067)
Nit: I would prefer to keep the same order (h,r,b,l) everywhere.
I guess that you wanted to show exactly the same results next to each other. But it is not the case on big-endian anyway.
Documentation/core-api/printk-formats.rst Passed by reference. · line 658
Quoted 7 lines
Documentation/core-api/printk-formats.rst +7
-0+ +Examples for a big-endian machine, given &(u32)0x67503030:: + + %p4ch gP00 (0x67503030) + %p4cl 00Pg (0x30305067) + %p4cb gP00 (0x67503030) + %p4cr 00Pg (0x30305067)
Same here.
lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1760
Quoted 13 lines
Documentation/core-api/printk-formats.rst +1
-0+ Thanks ======lib/vsprintf.c +1
-0@@ -1757,27 +1757,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,char output[sizeof ("0123 little-endian (0x01234567)" )];char *p = output;unsigned int i; +bool pix_fmt = false;
Nit: I would prefer "pixel_fmt". I am not a graphics guy and wondered
what "pix" did stands for ;-)
Quoted 26 lines
lib/vsprintf.c +16
-2u32 orig, val; -if (fmt[1 ] !='c' || fmt[2 ] !='c' ) +if (fmt[1 ] !='c' )return error_string (buf, end,"(%p4?)" , spec);if (check_pointer (&buf, end, fourcc, spec))return buf; orig =get_unaligned (fourcc); - val = orig & ~BIT (31 ); +switch (fmt[2 ]) { +case 'h' : + val = orig; +break ; +case 'r' : + val = orig =swab32 (orig); +break ; +case 'l' : + val = orig =le32_to_cpu (orig); +break ; +case 'b' : + val = orig =be32_to_cpu (orig); +break ; +case 'c' : +/* Pixel formats are printed LSB-first */
lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1793
Quoted 10 lines
lib/vsprintf.c +7
-1+ val =swab32 (orig & ~BIT (31 )); + pix_fmt = true; +break ; +default : +return error_string (buf, end,"(%p4?)" , spec); + }for (i =0 ; i <sizeof (u32); i++) { -unsigned char c = val >> (i *8 ); +unsigned char c = val >> ((3 - i) *8 );
This hardcodes '3' but the for-cycle uses i < sizeof(u32). We should be consistent.
A solution would be:
int i;
for (i = sizeof(u32); --i >= 0;) {
unsigned char c = val >> (i * 8);Quoted 5 lines
lib/vsprintf.c +0
-1/* Print non-control ASCII characters as-is, dot otherwise */ *p++ =isascii (c) &&isprint (c) ? c :'.' ; } - *p++ =' ' ;
lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1806
Quoted 10 lines
lib/vsprintf.c +5
-2-strcpy (p, orig &BIT (31 ) ?"big-endian" :"little-endian" ); - p +=strlen (p); +if (pix_fmt) { + *p++ =' ' ; +strcpy (p, orig &BIT (31 ) ?"big-endian" :"little-endian" ); + p +=strlen (p); + } *p++ =' ' ; *p++ ='(' ;
Best Regards,
Petr
Andy Shevchenko
reviewerRe: [PATCH 4/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
Quoted 2 lines · Petr Mladek
Quoted 1 line · Russell King
From: Hector Martin <[email protected]>
...
Quoted 7 lines
lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1793
Quoted 3 lines
lib/vsprintf.c +1
-1for (i =0 ; i <sizeof (u32); i++) { -unsigned char c = val >> (i *8 ); +unsigned char c = val >> ((3 - i) *8 );This hardcodes '3' but the for-cycle uses i < sizeof(u32). We should be consistent.
Quoted 6 lines
A solution would be:
int i; for (i = sizeof(u32); --i >= 0;) { unsigned char c = val >> (i * 8);
With while-loop it might be more readable:
unsigned int i = sizeof(u32);
while (i--) {
...
}Quoted 3 lines
Quoted 3 lines
lib/vsprintf.c +0
-0/* Print non-control ASCII characters as-is, dot otherwise */ *p++ =isascii (c) &&isprint (c) ? c :'.' ; }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 4/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
In reply to Petr MladekQuoted 3 lines · Petr Mladek
Quoted 2 lines · Russell King
From: Hector Martin <[email protected]>
...
Quoted 27 lines
Quoted 14 lines
Documentation/core-api/printk-formats.rst +14
-0+Generic FourCC code +------------------- + +:: + %p4c[hnbl] gP00 (0x67503030) + +Print a generic FourCC code, as both ASCII characters and its numerical +value as hexadecimal. + +The additional ``h``, ``r``, ``b``, and ``l`` specifiers are used to specify +host, reversed, big or little endian order data respectively. Host endian +order means the data is interpreted as a 32-bit integer and the most +significant byte is printed first; that is, the character code as printed +matches the byte order stored in memory on big-endian systems, and is reversedDocumentation/core-api/printk-formats.rst Passed by reference. · line 651
Quoted 10 lines
Documentation/core-api/printk-formats.rst +10
-0+on little-endian systems. + +Passed by reference. + +Examples for a little-endian machine, given &(u32)0x67503030:: + + %p4ch gP00 (0x67503030) + %p4cl gP00 (0x67503030) + %p4cb 00Pg (0x30305067) + %p4cr 00Pg (0x30305067)Nit: I would prefer to keep the same order (h,r,b,l) everywhere.
Quoted 2 lines
I guess that you wanted to show exactly the same results next to each other. But it is not the case on big-endian anyway.
This is straight from the Asahi kernel tree, and is unmodified. I'm guessing you're use of "you" here refers to Hector rather than me.
So, Hector, any opinions on Petr's comments please?
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH 4/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
Quoted 32 lines · Russell King (Oracle)
Quoted 3 lines · Petr Mladek
Quoted 2 lines · Russell King
From: Hector Martin <[email protected]>
...
Quoted 27 lines
Quoted 14 lines
Documentation/core-api/printk-formats.rst +14
-0+Generic FourCC code +------------------- + +:: + %p4c[hnbl] gP00 (0x67503030) + +Print a generic FourCC code, as both ASCII characters and its numerical +value as hexadecimal. + +The additional ``h``, ``r``, ``b``, and ``l`` specifiers are used to specify +host, reversed, big or little endian order data respectively. Host endian +order means the data is interpreted as a 32-bit integer and the most +significant byte is printed first; that is, the character code as printed +matches the byte order stored in memory on big-endian systems, and is reversedDocumentation/core-api/printk-formats.rst Passed by reference. · line 651
Quoted 10 lines
Documentation/core-api/printk-formats.rst +10
-0+on little-endian systems. + +Passed by reference. + +Examples for a little-endian machine, given &(u32)0x67503030:: + + %p4ch gP00 (0x67503030) + %p4cl gP00 (0x67503030) + %p4cb 00Pg (0x30305067) + %p4cr 00Pg (0x30305067)Nit: I would prefer to keep the same order (h,r,b,l) everywhere.
Quoted 7 lines
Quoted 2 lines
I guess that you wanted to show exactly the same results next to each other. But it is not the case on big-endian anyway.
This is straight from the Asahi kernel tree, and is unmodified. I'm guessing you're use of "you" here refers to Hector rather than me.
So, Hector, any opinions on Petr's comments please?
Fine with me, feel free to make the changes :)
- Hector
PATCH 5/7 platform/apple: Add new Apple Mac SMC driver
In reply to Russell King (Oracle)From: Hector Martin <[email protected]>
This driver implements support for the SMC (System Management Controller) in Apple Macs. In contrast to the existing applesmc driver, it uses pluggable backends that allow it to support different SMC implementations, and uses the MFD subsystem to expose the core SMC functionality so that specific features (gpio, hwmon, battery, etc.) can be implemented by separate drivers in their respective downstream subsystems.
The initial RTKit backend adds support for Apple Silicon Macs (M1 et al). We hope a backend for T2 Macs will be written in the future (since those are not supported by applesmc), and eventually an x86 backend would allow us to fully deprecate applesmc in favor of this driver.
--- drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/apple/Kconfig | 49 ++++ drivers/platform/apple/Makefile | 11 + drivers/platform/apple/smc.h | 28 ++ drivers/platform/apple/smc_core.c | 249 ++++++++++++++++ drivers/platform/apple/smc_rtkit.c | 453 +++++++++++++++++++++++++++++ include/linux/mfd/macsmc.h | 86 ++++++ 8 files changed, 879 insertions(+) create mode 100644 drivers/platform/apple/Kconfig create mode 100644 drivers/platform/apple/Makefile create mode 100644 drivers/platform/apple/smc.h create mode 100644 drivers/platform/apple/smc_core.c create mode 100644 drivers/platform/apple/smc_rtkit.c create mode 100644 include/linux/mfd/macsmc.h
drivers/platform/Kconfig +2 -0
@@ -13,4 +13,6 @@ source "drivers/platform/olpc/Kconfig" source "drivers/platform/surface/Kconfig" +source "drivers/platform/apple/Kconfig" + source "drivers/platform/x86/Kconfig"
drivers/platform/Makefile +1 -0
@@ -10,3 +10,4 @@ obj-$(CONFIG_OLPC_EC) += olpc/ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_CHROME_PLATFORMS) += chrome/ obj-$(CONFIG_SURFACE_PLATFORMS) += surface/ +obj-$(CONFIG_APPLE_PLATFORMS) += apple/
drivers/platform/apple/Kconfig new file +49 -0
49 lines not on this page · raw message
drivers/platform/apple/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for linux/drivers/platform/apple +# Apple Platform-Specific Drivers +# + +macsmc-y += smc_core.o +macsmc-rtkit-y += smc_rtkit.o + +obj-$(CONFIG_APPLE_SMC) += macsmc.o +obj-$(CONFIG_APPLE_SMC_RTKIT) += macsmc-rtkit.o
drivers/platform/apple/smc.h new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* +* Apple SMC internal core definitions +* Copyright (C) The Asahi Linux Contributors +*/ + +#ifndef _SMC_H +#define _SMC_H + +#include <linux/mfd/macsmc.h> + +struct apple_smc_backend_ops { +int (*read_key)(void *cookie,smc_key key,void *buf,size_t size); +int (*write_key)(void *cookie,smc_key key,void *buf,size_t size); +int (*write_key_atomic)(void *cookie,smc_key key,void *buf,size_t size); +int (*rw_key)(void *cookie,smc_key key,void *wbuf,size_t wsize, +void *rbuf,size_t rsize); +int (*get_key_by_index)(void *cookie,int index,smc_key *key); +int (*get_key_info)(void *cookie,smc_key key,struct apple_smc_key_info *info); +}; + +struct apple_smc *apple_smc_probe (struct device *dev,const struct apple_smc_backend_ops *ops, +void *cookie); +void *apple_smc_get_cookie (struct apple_smc *smc); +int apple_smc_remove (struct apple_smc *smc); +void apple_smc_event_received (struct apple_smc *smc,uint32_t event); + +#endif
drivers/platform/apple/smc_core.c new file +249 -0
249 lines not on this page · raw message
drivers/platform/apple/smc_rtkit.c new file +453 -0
453 lines not on this page · raw message
include/linux/mfd/macsmc.h new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH 5/7] platform/apple: Add new Apple Mac SMC driver
Quoted 10 lines · Russell King
From: Hector Martin <[email protected]>
This driver implements support for the SMC (System Management Controller) in Apple Macs. In contrast to the existing applesmc driver, it uses pluggable backends that allow it to support different SMC implementations, and uses the MFD subsystem to expose the core SMC functionality so that specific features (gpio, hwmon, battery, etc.) can be implemented by separate drivers in their respective downstream subsystems.
Quoted 8 lines
The initial RTKit backend adds support for Apple Silicon Macs (M1 et al). We hope a backend for T2 Macs will be written in the future (since those are not supported by applesmc), and eventually an x86 backend would allow us to fully deprecate applesmc in favor of this driver.
Signed-off-by Hector Martin <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>
PATCH 6/7 gpio: Add new gpio-macsmc driver for Apple Macs
In reply to Russell King (Oracle)From: Hector Martin <[email protected]>
This driver implements the GPIO service on top of the SMC framework on Apple Mac machines. In particular, these are the GPIOs present in the PMU IC which are used to control power to certain on-board devices.
Although the underlying hardware supports various pin config settings (input/output, open drain, etc.), this driver does not implement that functionality and leaves it up to the firmware to configure things properly. We also don't yet support interrupts/events. This is sufficient for device power control, which is the only thing we need to support at this point. More features will be implemented when needed.
To our knowledge, only Apple Silicon Macs implement this SMC feature.
--- drivers/gpio/Kconfig | 11 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-macsmc.c | 242 +++++++++++++++++++++++++++++++++++++ 3 files changed, 254 insertions(+) create mode 100644 drivers/gpio/gpio-macsmc.c
drivers/gpio/Kconfig +11 -0
@@ -1292,6 +1292,17 @@ config GPIO_LP87565 This driver can also be built as a module. If so, the module will be called gpio-lp87565. +config GPIO_MACSMC + tristate "Apple Mac SMC GPIO" + depends on APPLE_SMC + default ARCH_APPLE + help + Support for GPIOs controlled by the SMC microcontroller on Apple Mac + systems. + + This driver can also be built as a module. If so, the module will be + called gpio-macsmc. + config GPIO_MADERA tristate "Cirrus Logic Madera class codecs" depends on PINCTRL_MADERA
drivers/gpio/Makefile +1 -0
@@ -83,6 +83,7 @@ obj-$(CONFIG_GPIO_LP873X) += gpio-lp873x.o obj-$(CONFIG_GPIO_LP87565) += gpio-lp87565.o obj-$(CONFIG_GPIO_LPC18XX) += gpio-lpc18xx.o obj-$(CONFIG_GPIO_LPC32XX) += gpio-lpc32xx.o +obj-$(CONFIG_GPIO_MACSMC) += gpio-macsmc.o obj-$(CONFIG_GPIO_MADERA) += gpio-madera.o obj-$(CONFIG_GPIO_MAX3191X) += gpio-max3191x.o obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o
drivers/gpio/gpio-macsmc.c new file +242 -0
242 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH 6/7] gpio: Add new gpio-macsmc driver for Apple Macs
Quoted 13 lines · Russell King
From: Hector Martin <[email protected]>
This driver implements the GPIO service on top of the SMC framework on Apple Mac machines. In particular, these are the GPIOs present in the PMU IC which are used to control power to certain on-board devices.
Although the underlying hardware supports various pin config settings (input/output, open drain, etc.), this driver does not implement that functionality and leaves it up to the firmware to configure things properly. We also don't yet support interrupts/events. This is sufficient for device power control, which is the only thing we need to support at this point. More features will be implemented when needed.
Quoted 4 lines
To our knowledge, only Apple Silicon Macs implement this SMC feature.
Signed-off-by Hector Martin <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>
PATCH 7/7 arm64: dts: apple: Add SMC node to t8103/t6001 devicetrees
In reply to Russell King (Oracle)From: Hector Martin <[email protected]>
--- arch/arm64/boot/dts/apple/t8103.dtsi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/arm64/boot/dts/apple/t8103.dtsi +26 -0
@@ -336,6 +336,32 @@ wdt: watchdog@23d2b0000 { interrupts = <AIC_IRQ 338 IRQ_TYPE_LEVEL_HIGH>; }; + smc_mbox: mbox@23e408000 { + compatible = "apple,t8103-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x2 0x3e408000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = <AIC_IRQ 400 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 401 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 402 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 403 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + smc: smc@23e400000 { + compatible = "apple,t8103-smc", "apple,smc"; + reg = <0x2 0x3e400000 0x0 0x4000>, + <0x2 0x3fe00000 0x0 0x100000>; + reg-names = "smc", "sram"; + mboxes = <&smc_mbox>; + + smc_gpio: gpio { + gpio-controller; + #gpio-cells = <2>; + }; + }; + pinctrl_smc: pinctrl@23e820000 { compatible = "apple,t8103-pinctrl", "apple,pinctrl"; reg = <0x2 0x3e820000 0x0 0x4000>;
Signature · 1 line
2.30.2
Re: [PATCH 7/7] arm64: dts: apple: Add SMC node to t8103/t6001 devicetrees
Quoted 21 lines · Russell King
From: Hector Martin <[email protected]>
Signed-off-by Hector Martin <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>--- arch/arm64/boot/dts/apple/t8103.dtsi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)arch/arm64/boot/dts/apple/t8103.dtsi +4
-0@@ -336,6 +336,32 @@ wdt: watchdog@23d2b0000 { interrupts = <AIC_IRQ 338 IRQ_TYPE_LEVEL_HIGH>; }; + smc_mbox: mbox@23e408000 { + compatible = "apple,t8103-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x2 0x3e408000 0x0 0x4000>; + interrupt-parent = <&aic>;
arch/arm64/boot/dts/apple/t8103.dtsi wdt: watchdog@23d2b0000 { · line 352
Quoted 10 lines
arch/arm64/boot/dts/apple/t8103.dtsi +10
-0+ interrupts = <AIC_IRQ 400 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 401 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 402 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 403 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + smc: smc@23e400000 {
Usually we sort these nodes by their address to prevent merge conflicts. I guess it doesn't really matter here though since nothing will be between these two nodes.
Either way,
Quoted 17 lines
arch/arm64/boot/dts/apple/t8103.dtsi +12
-0+ compatible = "apple,t8103-smc", "apple,smc"; + reg = <0x2 0x3e400000 0x0 0x4000>, + <0x2 0x3fe00000 0x0 0x100000>; + reg-names = "smc", "sram"; + mboxes = <&smc_mbox>; + + smc_gpio: gpio { + gpio-controller; + #gpio-cells = <2>; + }; + }; + pinctrl_smc: pinctrl@23e820000 { compatible = "apple,t8103-pinctrl", "apple,pinctrl"; reg = <0x2 0x3e820000 0x0 0x4000>;Signature · 1 line
2.30.2
Re: [PATCH 7/7] arm64: dts: apple: Add SMC node to t8103/t6001 devicetrees
Quoted 31 lines · Sven Peter
Quoted 28 lines · Russell King
From: Hector Martin <[email protected]>
Signed-off-by Hector Martin <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>--- arch/arm64/boot/dts/apple/t8103.dtsi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)arch/arm64/boot/dts/apple/t8103.dtsi +11
-0@@ -336,6 +336,32 @@ wdt: watchdog@23d2b0000 { interrupts = <AIC_IRQ 338 IRQ_TYPE_LEVEL_HIGH>; }; + smc_mbox: mbox@23e408000 { + compatible = "apple,t8103-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x2 0x3e408000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = <AIC_IRQ 400 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 401 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 402 IRQ_TYPE_LEVEL_HIGH>, + <AIC_IRQ 403 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>;
Quoted 8 lines
arch/arm64/boot/dts/apple/t8103.dtsi wdt: watchdog@23d2b0000 { · line 352
Quoted 3 lines
arch/arm64/boot/dts/apple/t8103.dtsi +3
-0+ }; + + smc: smc@23e400000 {Usually we sort these nodes by their address to prevent merge conflicts. I guess it doesn't really matter here though since nothing will be between these two nodes.
Either way,
If that's how the nodes should be sorted, let's do it now so we don't end up with another patch that re-ordering this - I've made the change.
Quoted 1 line
Reviewed-by Sven Peter <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Janne Grunau
maintainerRe: [PATCH 7/7] arm64: dts: apple: Add SMC node to t8103/t6001 devicetrees
In reply to Russell King (Oracle)Quoted 7 lines · Russell King
From: Hector Martin <[email protected]>
Signed-off-by Hector Martin <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>--- arch/arm64/boot/dts/apple/t8103.dtsi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
nit: the commit message mentions t600x but the commit doesn't contain it since the t600x devicetrees are not upstream yet. Please fix if you send another version. I plan to send the t600x devicetrees later today but I don't think it's worth to create a dependency between the series. Let's submit the t600x macsmc bits separately later.
Janne
Quoted 6 lines · Russell King (Oracle)
This series adds support for the Apple Mac GPIO driver. These GPIOs are hadled via the System Management Controller.
The first two patches add the DT binding documentation for the new drivers. No changes from the first posting (I think there's still some discussion going on about how best to handle these.)
The series:
I'm happy with this, and it will be possible to augment easily for future needs.
Yours,
Linus Walleij
Quoted 58 lines · Russell King (Oracle)
Hi,
[Andy dropped from the Cc lists; he's taking a break.]
This series adds support for the Apple Mac GPIO driver. These GPIOs are hadled via the System Management Controller.
The first two patches add the DT binding documentation for the new drivers. No changes from the first posting (I think there's still some discussion going on about how best to handle these.)
Patch 3 adds
apple_rtkit_poll()and has had no changes since v1.Patch 4 is new, extending the existing FourCC format code to be able to print other endian FourCC codes.
Patch 5 adds the SMC core and rtkit driver. Changes in v2 include properly limiting the data size (since it is limited to the width of the size fields in the mailbox messages, not the shmem size) and also to properly cleanup after failure to send the initialisation message.
Patch 6 adds the SMC GPIO support. Changes in v2 include some of the issues Andy pointed out,
Patch 7 is new, adding the SMC nodes to the dtsi.
Patches taken from the Asahi project.
Documentation/core-api/printk-formats.rst | 32 ++ .../devicetree/bindings/gpio/gpio-macsmc.yaml | 28 ++ .../devicetree/bindings/mfd/apple,smc.yaml | 65 +++ arch/arm64/boot/dts/apple/t8103.dtsi | 26 ++ drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-macsmc.c | 242 +++++++++++ drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/apple/Kconfig | 49 +++ drivers/platform/apple/Makefile | 11 + drivers/platform/apple/smc.h | 28 ++ drivers/platform/apple/smc_core.c | 249 +++++++++++ drivers/platform/apple/smc_rtkit.c | 453 +++++++++++++++++++++ drivers/soc/apple/rtkit.c | 6 + include/linux/mfd/macsmc.h | 86 ++++ include/linux/soc/apple/rtkit.h | 12 + lib/vsprintf.c | 35 +- 18 files changed, 1331 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-macsmc.yaml create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml create mode 100644 drivers/gpio/gpio-macsmc.c create mode 100644 drivers/platform/apple/Kconfig create mode 100644 drivers/platform/apple/Makefile create mode 100644 drivers/platform/apple/smc.h create mode 100644 drivers/platform/apple/smc_core.c create mode 100644 drivers/platform/apple/smc_rtkit.c create mode 100644 include/linux/mfd/macsmc.h
Quoted 3 lines
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
For GPIO: