Skip to contentSkip to conversation

ZII RAVE platform driver

PATCH Applied Andrey Smirnov 5 participants 12 messages Aug 28, 2017 – Sep 4, 2017

Subsystems (2)

v6 of 17 Applied Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v6 cover ZII RAVE platform driver

Hi everyone,

This patch series is v6 of the driver for supervisory processor found on RAVE series of devices from ZII. Supervisory processor is a PIC microcontroller connected to various electrical subsystems on RAVE devices whose firmware implements protocol to command/qery them.

Changes since [v5]:

- Fixed a build break, introduced by a last minute change in [v5]

- Moved majority of attributes that were exposed over sysfs to debugfs

- Document remaining sysfs attributes in Documentation/ABI/testing/sysfs-platform-rave-sp

Changes since [v4]:

- Replaced usage of DEVICE_ATTR with DEVICE_ATTR_RW

- Fixed a number of warnings produces by sparse tool

- Incorporated event more feedback from Andy Shevchenko

- Collected Reviewed-by from Andy

Changes since [v3]:

- Re-collected lost Acked-by from Rob

- Incorporated further feedback from Andy Shevchenko

- Dropped useless change (stray newline) to drivers/mfd/Makefile

Changes since [v2]:

- Fixed swapped command codes in rave_sp_common_get_boot_source() and rave_sp_common_set_boot_source() revealed by further testing of the code

- Incorporated feedback from Andy Shevchenko

Changes since [v1]:

- Updated wording in DT-bindings as per Rob's request.

- Collected Rob's Acked-by for patch 2/2

NOTE:

* The driver for "zii,rave-sp-watchdog" exists, but I haven't submitted it yet, becuase I wanted to make sure that API exposed by this MFD is acceptable and doesn't need drastic changes.

* This driver is dependent on crc_ccitt_false() introduced in 2da9378d531f8cc6670c7497f20d936b706ab80b in 'linux-next'

Feedback is greatly appreciated!

Thanks,
Andrey Smirnov

[v5] lkml.kernel.org/r/[email protected] [v4] lkml.kernel.org/r/[email protected] [v3] lkml.kernel.org/r/[email protected] [v2] lkml.kernel.org/r/[email protected] [v1] lkml.kernel.org/r/[email protected]

Andrey Smirnov (2):
platform: Add driver for RAVE Supervisory Processor
dt-bindings: mfd: Add bindings for ZII RAVE devices

 Documentation/ABI/testing/sysfs-platform-rave-sp   |   35 +
 .../devicetree/bindings/mfd/zii,rave-sp.txt        |   39 +
 drivers/platform/Kconfig                           |    2 +
 drivers/platform/Makefile                          |    1 +
 drivers/platform/rave/Kconfig                      |   26 +
 drivers/platform/rave/Makefile                     |    1 +
 drivers/platform/rave/rave-sp.c                    | 1190 ++++++++++++++++++++
 include/linux/rave-sp.h                            |   54 +
 8 files changed, 1348 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-rave-sp
 create mode 100644 Documentation/devicetree/bindings/mfd/zii,rave-sp.txt
 create mode 100644 drivers/platform/rave/Kconfig
 create mode 100644 drivers/platform/rave/Makefile
 create mode 100644 drivers/platform/rave/rave-sp.c
 create mode 100644 include/linux/rave-sp.h
Signature · 1 line
2.13.5
#10 lore raw

PATCH v6 2/2 dt-bindings: mfd: Add bindings for ZII RAVE devices

Add Device Tree bindings for RAVE Supervisory Processor, an MCU implementing varoius bits of housekeeping functionality (watchdoging, backlight control, LED control, etc) on RAVE family of products by Zodiac Inflight Innovations.

---
 .../devicetree/bindings/mfd/zii,rave-sp.txt        | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/zii,rave-sp.txt
Documentation/devicetree/bindings/mfd/zii,rave-sp.txt new file +39 -0
new file mode 100644
index 000000000000..088eff9ddb78
@@ -0,0 +1,39 @@
+Zodiac Inflight Innovations RAVE Supervisory Processor
+
+RAVE Supervisory Processor communicates with SoC over UART. It is
+expected that its Device Tree node is specified as a child of a node
+corresponding to UART controller used for communication.
+
+Required parent device properties:
+
+ - compatible: Should be one of:
+	- "zii,rave-sp-niu"
+	- "zii,rave-sp-mezz"
+	- "zii,rave-sp-esb"
+	- "zii,rave-sp-rdu1"
+	- "zii,rave-sp-rdu2"
+
+ - current-speed: Should be set to baud rate SP device is using
+
+RAVE SP consists of the following sub-devices:
+
+Device				 Description
+------				 -----------
+rave-sp-wdt			: Watchdog
+rave-sp-nvmem			: Interface to onborad EEPROM
+rave-sp-backlight		: Display backlight
+rave-sp-hwmon			: Interface to onboard hardware sensors
+rave-sp-leds			: Interface to onboard LEDs
+rave-sp-input			: Interface to onboard power button
+
+Example of usage:
+
+	rdu {
+		compatible = "zii,rave-sp-rdu2";
+		current-speed = <1000000>;
+
+		watchdog {
+			compatible = "zii,rave-sp-watchdog";
+		};
+	};
+
Signature · 1 line
2.13.5
#1 lore raw

PATCH v6 1/2 platform: Add driver for RAVE Supervisory Processor

In reply to Andrey Smirnov

Add a driver for RAVE Supervisory Processor, an MCU implementing varoius bits of housekeeping functionality (watchdoging, backlight control, LED control, etc) on RAVE family of products by Zodiac Inflight Innovations.

This driver implementes core MFD/serdev device as well as communication subroutines necessary for commanding the device.

---
 Documentation/ABI/testing/sysfs-platform-rave-sp |   35 +
 drivers/platform/Kconfig                         |    2 +
 drivers/platform/Makefile                        |    1 +
 drivers/platform/rave/Kconfig                    |   26 +
 drivers/platform/rave/Makefile                   |    1 +
 drivers/platform/rave/rave-sp.c                  | 1190 ++++++++++++++++++++++
 include/linux/rave-sp.h                          |   54 +
 7 files changed, 1309 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-rave-sp
 create mode 100644 drivers/platform/rave/Kconfig
 create mode 100644 drivers/platform/rave/Makefile
 create mode 100644 drivers/platform/rave/rave-sp.c
 create mode 100644 include/linux/rave-sp.h
Documentation/ABI/testing/sysfs-platform-rave-sp new file +35 -0
new file mode 100644
index 000000000000..81bdc54ba857
@@ -0,0 +1,35 @@
+What:		/sys/devices/platform/*/serial*/serial*-*/reset_reason
+Date:		Aug 2017
+Contact:	"Andrey Smirnov" <[email protected]>
+Description:    (RO) Indicates reason for last reset.
+
+		The following values can be reported:
+		    * 0  -> Normal Power Off
+		    * 1  -> Hardware Watchdog
+		    * 2  -> Software Watchdog
+		    * 3  -> Input Voltage Out Of Range
+		    * 4  -> Host Requested
+		    * 5  -> Temperature Out Of Range
+		    * 6  -> User Requested (via long Power Button press)
+		    * 7  -> Illegal Configuration Word
+		    * 8  -> Illegal Insturction
+		    * 9  -> Illegal Trap
+		    * 10 -> Unknown
+		    * 11 -> Crew Panel Requested
+
+		 NOTE: Codes 7,8 and 9 pertain to exceptions happening
+		 in supervisory processor/its firmware and not host
+		 CPU.
+
+What:		/sys/devices/platform/*/serial*/serial*-*/boot_source
+Date:		Aug 2017
+Contact:	"Andrey Smirnov" <[email protected]>
+Description:    (RW) Indicates currently selected boot source.
+
+		The following values are valid:
+		    * 0  -> SD card
+		    * 1  -> eMMC
+		    * 2  -> SPI NOR
+
+		NOTE: Setting boot source on RDU1 hardware is
+		currently not implemented
drivers/platform/Kconfig +2 -0
index c11db8bceea1..e6db685bb895 100644
@@ -8,3 +8,5 @@ endif
 source "drivers/platform/goldfish/Kconfig"
 
 source "drivers/platform/chrome/Kconfig"
+
+source "drivers/platform/rave/Kconfig"
drivers/platform/Makefile +1 -0
index ca2692510733..17bdec5ece0c 100644
@@ -7,3 +7,4 @@ obj-$(CONFIG_MIPS)		+= mips/
 obj-$(CONFIG_OLPC)		+= olpc/
 obj-$(CONFIG_GOLDFISH)		+= goldfish/
 obj-$(CONFIG_CHROME_PLATFORMS)	+= chrome/
+obj-y += rave/
drivers/platform/rave/Kconfig new file +26 -0
new file mode 100644
index 000000000000..6fc50ade3871
@@ -0,0 +1,26 @@
+#
+# Platform support for Zodiac RAVE hardware
+#
+
+menuconfig RAVE_PLATFORMS
+	bool "Platform support for Zodiac RAVE hardware"
+	depends on SERIAL_DEV_BUS && SERIAL_DEV_CTRL_TTYPORT
+	help
+	  Say Y here to get to see options for platform support for
+	  various devices present in RAVE hardware. This option alone
+	  does not add any kernel code.
+
+	  If you say N, all options in this submenu will be skipped
+	  and disabled.
+
+if RAVE_PLATFORMS
+
+config RAVE_SP_CORE
+	tristate "RAVE SP MCU core driver"
+	select MFD_CORE
+	select CRC_CCITT
+	help
+	  Select this to get support for the Supervisory Processor
+	  device found on several devices in RAVE line of hardware.
+
+endif
drivers/platform/rave/Makefile new file +1 -0
new file mode 100644
index 000000000000..e4c21ab2d2f5
@@ -0,0 +1 @@
+obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o
drivers/platform/rave/rave-sp.c new file +1190 -0

1,190 lines not on this page · raw message

include/linux/rave-sp.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
2.13.5
#2 lore raw

Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor

Hi!

Quoted 19 lines

Add a driver for RAVE Supervisory Processor, an MCU implementing varoius bits of housekeeping functionality (watchdoging, backlight control, LED control, etc) on RAVE family of products by Zodiac Inflight Innovations.

This driver implementes core MFD/serdev device as well as communication subroutines necessary for commanding the device.

Documentation/ABI/testing/sysfs-platform-rave-sp new file +5 -0
new file mode 100644
index 000000000000..81bdc54ba857
@@ -0,0 +1,35 @@
+What:		/sys/devices/platform/*/serial*/serial*-*/reset_reason
+Date:		Aug 2017
+Contact:	"Andrey Smirnov" <[email protected]>
+Description:    (RO) Indicates reason for last reset.
+

Documentation/ABI/testing/sysfs-platform-rave-sp line 15

Quoted 10 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +10 -0
+		The following values can be reported:
+		    * 0  -> Normal Power Off
+		    * 1  -> Hardware Watchdog
+		    * 2  -> Software Watchdog
+		    * 3  -> Input Voltage Out Of Range
+		    * 4  -> Host Requested
+		    * 5  -> Temperature Out Of Range
+		    * 6  -> User Requested (via long Power Button press)
+		    * 7  -> Illegal Configuration Word
+		    * 8  -> Illegal Insturction

Typo here.

Documentation/ABI/testing/sysfs-platform-rave-sp line 18

Quoted 3 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +3 -0
+		    * 9  -> Illegal Trap
+		    * 10 -> Unknown
+		    * 11 -> Crew Panel Requested

Anyway... If you move management chip to .. I don't know, i2c, the path would change. Also it would be different path on N900. Userland should not have to deal with this.

And... this should really be string, as the list will need to grow on different hardware.

Plus we'll really need better explanations. What is difference between "normal power off" and "host requested"?

Documentation/ABI/testing/sysfs-platform-rave-sp line 35

Quoted 12 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +12 -0
+What:		/sys/devices/platform/*/serial*/serial*-*/boot_source
+Date:		Aug 2017
+Contact:	"Andrey Smirnov" <[email protected]>
+Description:    (RW) Indicates currently selected boot source.
+
+		The following values are valid:
+		    * 0  -> SD card
+		    * 1  -> eMMC
+		    * 2  -> SPI NOR
+
+		NOTE: Setting boot source on RDU1 hardware is
+		currently not implemented

Same comments apply here.

Documentation/ABI/testing/sysfs-platform-rave-sp

Quoted 8 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +8 -0
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(part_number_firmware);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(part_number_bootloader);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(copper_rev_deb);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(copper_rev_rmb);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(copper_mod_deb);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(copper_mod_rmb);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(silicon_devid);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(silicon_devrev);

Are these going to debugfs?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw

Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor

Quoted 38 lines · Pavel Machek

Hi!

Quoted 19 lines

Add a driver for RAVE Supervisory Processor, an MCU implementing varoius bits of housekeeping functionality (watchdoging, backlight control, LED control, etc) on RAVE family of products by Zodiac Inflight Innovations.

This driver implementes core MFD/serdev device as well as communication subroutines necessary for commanding the device.

Documentation/ABI/testing/sysfs-platform-rave-sp new file +5 -0
new file mode 100644
index 000000000000..81bdc54ba857
@@ -0,0 +1,35 @@
+What:                /sys/devices/platform/*/serial*/serial*-*/reset_reason
+Date:                Aug 2017
+Contact:     "Andrey Smirnov" <[email protected]>
+Description:    (RO) Indicates reason for last reset.
+

Documentation/ABI/testing/sysfs-platform-rave-sp line 15

Quoted 10 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +10 -0
+             The following values can be reported:
+                 * 0  -> Normal Power Off
+                 * 1  -> Hardware Watchdog
+                 * 2  -> Software Watchdog
+                 * 3  -> Input Voltage Out Of Range
+                 * 4  -> Host Requested
+                 * 5  -> Temperature Out Of Range
+                 * 6  -> User Requested (via long Power Button press)
+                 * 7  -> Illegal Configuration Word
+                 * 8  -> Illegal Insturction

Typo here.

Documentation/ABI/testing/sysfs-platform-rave-sp line 18

Quoted 3 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +3 -0
+                 * 9  -> Illegal Trap
+                 * 10 -> Unknown
+                 * 11 -> Crew Panel Requested
Quoted 7 lines

Anyway... If you move management chip to .. I don't know, i2c, the path would change. Also it would be different path on N900. Userland should not have to deal with this.

And... this should really be string, as the list will need to grow on different hardware.

I think we have a misunderstanding, with this part of the patch set I am not trying to propose a generic ABI that would be useful for any other driver but this one. Hence the lack of concern for different hardware paths (it's not going to change for this device) and device specific codes instead of generic strings. I can see how my choice of generic name such as "reset_reason" might suggest that, so I apologize for any confusion I might have caused. If said generic name is unacceptable I can change it to "rave_reset_reason" or something similar and if that is undesirable as well I am happy to drop this part of the patch and re-visit this later.

Quoted 3 lines

Plus we'll really need better explanations. What is difference between "normal power off" and "host requested"?

Short answer: I don't know, since this is as much information that ICD for that device gave me.

Long answer: It probably can be discerned from the source code of the firmware/schematic as well as by bothering the right people, but since I get a feeling that this attribute is not really desirable in its current from, I'll punt doing that.

Quoted 6 lines
Quoted 6 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +6 -0
+What:                /sys/devices/platform/*/serial*/serial*-*/boot_source
+Date:                Aug 2017
+Contact:     "Andrey Smirnov" <[email protected]>
+Description:    (RW) Indicates currently selected boot source.
+
+             The following values are valid:
Quoted 9 lines

Documentation/ABI/testing/sysfs-platform-rave-sp line 35

Quoted 6 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +6 -0
+                 * 0  -> SD card
+                 * 1  -> eMMC
+                 * 2  -> SPI NOR
+
+             NOTE: Setting boot source on RDU1 hardware is
+             currently not implemented

Same comments apply here.

Yep, same comment for me as well :-)

Quoted 10 lines

Documentation/ABI/testing/sysfs-platform-rave-sp

Quoted 8 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +8 -0
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(part_number_firmware);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(part_number_bootloader);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(copper_rev_deb);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(copper_rev_rmb);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(copper_mod_deb);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(copper_mod_rmb);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(silicon_devid);
+RAVE_SP_DEFINE_SEQ_FILE_PRINT_FUNCTION(silicon_devrev);

Are these going to debugfs?

They already are there. See rave_sp_debugfs_create() where those helper functions are being used.

Thanks,
Andrey Smirnov

#4 lore raw

Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor

Hi!

Quoted 8 lines
Quoted 8 lines

Documentation/ABI/testing/sysfs-platform-rave-sp line 18

Quoted 3 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +3 -0
+                 * 9  -> Illegal Trap
+                 * 10 -> Unknown
+                 * 11 -> Crew Panel Requested

Anyway... If you move management chip to .. I don't know, i2c, the path would change. Also it would be different path on N900. Userland should not have to deal with this.

Quoted 6 lines
Quoted 2 lines

And... this should really be string, as the list will need to grow on different hardware.

I think we have a misunderstanding, with this part of the patch set I am not trying to propose a generic ABI that would be useful for any other driver but this one. Hence the lack of concern for different

Yes, but sorry, that's no-go. Kernel should hide differences between different machiens, and it should be rather easy in this case.

Quoted 7 lines

hardware paths (it's not going to change for this device) and device specific codes instead of generic strings. I can see how my choice of generic name such as "reset_reason" might suggest that, so I apologize for any confusion I might have caused. If said generic name is unacceptable I can change it to "rave_reset_reason" or something similar and if that is undesirable as well I am happy to drop this part of the patch and re-visit this later.

Ok, can we do the re-visit thing? You may want to contact these people:

Date: Wed, 30 Aug 2017 12:59:55 +0200
From: Pavel Machek <[email protected]>
To: Vadim Pasternak <[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected],
[email protected], [email protected], [email protected]
Subject: Re: [patch v4 1/2] mfd: Add Mellanox regmap core driver

They are currently trying to add driver, including

Quoted 4 lines

Cause of reset nodes:
- cpu_kernel_panic
- cpu_shutdown
- bmc_warm_reset

...which sounds very similar to what you are doing.

Quoted 11 lines
Quoted 3 lines

Plus we'll really need better explanations. What is difference between "normal power off" and "host requested"?

Short answer: I don't know, since this is as much information that ICD for that device gave me.

Long answer: It probably can be discerned from the source code of the firmware/schematic as well as by bothering the right people, but since I get a feeling that this attribute is not really desirable in its current from, I'll punt doing that.

Ok.

Quoted 11 lines
Quoted 9 lines

Documentation/ABI/testing/sysfs-platform-rave-sp line 35

Quoted 7 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +7 -0
+             The following values are valid:
+                 * 0  -> SD card
+                 * 1  -> eMMC
+                 * 2  -> SPI NOR
+
+             NOTE: Setting boot source on RDU1 hardware is
+             currently not implemented

Same comments apply here.

Yep, same comment for me as well :-)

Ok :-).

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw

Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor

Quoted 13 lines · Pavel Machek

Hi!

Quoted 11 lines
Quoted 10 lines

Documentation/ABI/testing/sysfs-platform-rave-sp line 18

Quoted 3 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +3 -0
+                 * 9  -> Illegal Trap
+                 * 10 -> Unknown
+                 * 11 -> Crew Panel Requested

Anyway... If you move management chip to .. I don't know, i2c, the path would change. Also it would be different path on N900. Userland should not have to deal with this.

And... this should really be string, as the list will need to grow on different hardware.

Quoted 6 lines
Quoted 3 lines

I think we have a misunderstanding, with this part of the patch set I am not trying to propose a generic ABI that would be useful for any other driver but this one. Hence the lack of concern for different

Yes, but sorry, that's no-go. Kernel should hide differences between different machiens, and it should be rather easy in this case.

There is an interest to have reset reason exported on other ZII hardware as well.

I think that trying to make this generic is purely synthetic. This information is board-specific per it's nature, it comes from what board is designed for, different boards have quite different sets of possible reset reasons. What is needed is - pass this board-specific information to board-specific user space.

What's proper API for that, if not a sysfs attribute?

#6 lore raw

Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor

Quoted 26 lines · Nikita Yushchenko
Quoted 13 lines · Pavel Machek

Hi!

Quoted 11 lines
Quoted 10 lines

Documentation/ABI/testing/sysfs-platform-rave-sp line 18

Quoted 3 lines
Documentation/ABI/testing/sysfs-platform-rave-sp new file +3 -0
+                 * 9  -> Illegal Trap
+                 * 10 -> Unknown
+                 * 11 -> Crew Panel Requested

Anyway... If you move management chip to .. I don't know, i2c, the path would change. Also it would be different path on N900. Userland should not have to deal with this.

And... this should really be string, as the list will need to grow on different hardware.

Quoted 6 lines
Quoted 3 lines

I think we have a misunderstanding, with this part of the patch set I am not trying to propose a generic ABI that would be useful for any other driver but this one. Hence the lack of concern for different

Yes, but sorry, that's no-go. Kernel should hide differences between different machiens, and it should be rather easy in this case.

There is an interest to have reset reason exported on other ZII hardware as well.

Quoted 7 lines

I think that trying to make this generic is purely synthetic. This information is board-specific per it's nature, it comes from what board is designed for, different boards have quite different sets of possible reset reasons. What is needed is - pass this board-specific information to board-specific user space.

What's proper API for that, if not a sysfs attribute?

Please go through the thread.

Sysfs attribute is okay, but:

1) it should probably be a string

2) it should certainly be superset of all the reasons

3) it should be in generic place, say /sys/power/reset_reason

4) it should be documented what each state means
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#7 lore raw

Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor

Quoted 12 lines
Quoted 7 lines

I think that trying to make this generic is purely synthetic. This information is board-specific per it's nature, it comes from what board is designed for, different boards have quite different sets of possible reset reasons. What is needed is - pass this board-specific information to board-specific user space.

What's proper API for that, if not a sysfs attribute?

Please go through the thread.

Sysfs attribute is okay, but:

Quoted 7 lines

1) it should probably be a string

2) it should certainly be superset of all the reasons

3) it should be in generic place, say /sys/power/reset_reason

4) it should be documented what each state means

What I'm concerned here is that a requirement appears for kernel driver to keep and maintain knowledge of what all that codes mean. For me, it looks like information locality breakage. Information in question is application-specific, it definitely changes from board to board and probably will change for particular board over time.

It's desirable to keep this information application-private, and have kernel only passed it from hardware to application, unmodified and uninterpreted.

Requiring kernel driver to interpret application-specific information only increases complexity (i.e. any changes will have to be maintained in two places - in driver and in application).

So question is - is there any proper API to communicate application-private information from hardware through kernel to userspace without any in-kernel interpretation?

#8 lore raw

Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor

Quoted 14 lines · Nikita Yushchenko
Quoted 14 lines
Quoted 7 lines

I think that trying to make this generic is purely synthetic. This information is board-specific per it's nature, it comes from what board is designed for, different boards have quite different sets of possible reset reasons. What is needed is - pass this board-specific information to board-specific user space.

What's proper API for that, if not a sysfs attribute?

Please go through the thread.

Sysfs attribute is okay, but:

1) it should probably be a string

Quoted 8 lines
Quoted 5 lines

2) it should certainly be superset of all the reasons

3) it should be in generic place, say /sys/power/reset_reason

4) it should be documented what each state means

What I'm concerned here is that a requirement appears for kernel driver to keep and maintain knowledge of what all that codes mean. For me,

There's no way around that. Kernel interfaces need to be documented. If you are passing codes between kernel and application, _those codes need to be documented_.

Quoted 3 lines

So question is - is there any proper API to communicate application-private information from hardware through kernel to userspace without any in-kernel interpretation?

No.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw

Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor

In reply to Andrey Smirnov

drivers/platform/rave/rave-sp.c line 468

Quoted 7 lines · Andrey Smirnov
drivers/platform/rave/rave-sp.c new file +7 -0
+static int rave_sp_debugfs_create(struct rave_sp *sp)
+{
+	struct dentry *file;
+
+	sp->debugfs = debugfs_create_dir("rave", NULL);
+	if (!sp->debugfs)
+		return -ENOMEM;

Why do you care about the return value of the debugfs function? Hint, you don't...

You should never care if debugfs failed, was built in, or succeeded, your code should just do the same thing always. Any value returned from a debugfs call can just be passed to another one, regardless of the value returned from the first one.

So here, just save it, and don't check it.

drivers/platform/rave/rave-sp.c line 474

Quoted 5 lines
drivers/platform/rave/rave-sp.c new file +5 -0
+	file = debugfs_create_file("i2c_device_status", 0444,
+				   sp->debugfs, sp,
+				   &rave_sp_i2c_device_status);
+	if (!file)
+		goto error;

Nope, you don't care, just make the call.

drivers/platform/rave/rave-sp.c line 478

Quoted 4 lines
drivers/platform/rave/rave-sp.c new file +4 -0
+
+	file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, part_number_firmware);
+	if (!file)
+		goto error;

Same for all of these.

Quoted 20 lines
drivers/platform/rave/rave-sp.c new file +20 -0
+
+	file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, part_number_bootloader);
+	if (!file)
+		goto error;
+
+	file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, copper_rev_deb);
+	if (!file)
+		goto error;
+
+	file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, copper_rev_rmb);
+	if (!file)
+		goto error;
+
+	file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, copper_mod_deb);
+	if (!file)
+		goto error;
+
+	file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, copper_mod_rmb);
+	if (!file)
+		goto error;

drivers/platform/rave/rave-sp.c line 508

Quoted 10 lines
drivers/platform/rave/rave-sp.c new file +10 -0
+
+	file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, silicon_devrev);
+	if (!file)
+		goto error;
+
+	file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, silicon_devid);
+	if (!file)
+		goto error;
+
+	return 0;

And your function can not fail, no need for this to return anything.

Quoted 19 lines
drivers/platform/rave/rave-sp.c new file +19 -0
+error:
+	debugfs_remove_recursive(sp->debugfs);
+	return -ENOMEM;
+}
+
+static void rave_sp_degugfs_release(struct device *dev, void *res)
+{
+	struct rave_sp *sp = *(struct rave_sp **)res;
+
+	debugfs_remove_recursive(sp->debugfs);
+}
+
+static int devm_rave_sp_debugfs_create(struct rave_sp *sp)
+{
+	struct rave_sp **rcsp;
+	struct device *dev = &sp->serdev->dev;
+	int ret;
+
+	rcsp = devres_alloc(rave_sp_degugfs_release, sizeof(*rcsp), GFP_KERNEL);

drivers/platform/rave/rave-sp.c line 537

Quoted 10 lines
drivers/platform/rave/rave-sp.c new file +10 -0
+	if (!rcsp)
+		return -ENOMEM;
+
+	ret = rave_sp_debugfs_create(sp);
+	if (!ret) {
+		*rcsp = sp;
+		devres_add(dev, rcsp);
+	} else {
+		devres_free(rcsp);
+	}

You should not care what debugfs is doing, if it is working or not. So no need to check here either.

debugfs was written to make it dirt-simple to use, I don't know why people keep trying to put some error handling around it :)

thanks,

greg k-h

Applied
#11 lore raw

Re: [PATCH v6 2/2] dt-bindings: mfd: Add bindings for ZII RAVE devices

In reply to Andrey Smirnov
Quoted 17 lines · Andrey Smirnov

Add Device Tree bindings for RAVE Supervisory Processor, an MCU implementing varoius bits of housekeeping functionality (watchdoging, backlight control, LED control, etc) on RAVE family of products by Zodiac Inflight Innovations.

Quoted 4 lines
---
 .../devicetree/bindings/mfd/zii,rave-sp.txt        | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/zii,rave-sp.txt

Applied, thanks.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog