Skip to contentSkip to conversation

RAVE SP MFD driver fixes/improvements

PATCH Applied Andrey Smirnov 2 participants 13 messages Jul 7, 2018 – Jul 13, 2018 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

cover RAVE SP MFD driver fixes/improvements

Lee:

This series is a number of small fixes the resulted from using RAVE SP driver on wider selection of ZII devices that initial driver was tested on. In addition to RDU1 and RDU2, the driver is now known to work reasonably well on SCU2 Mezz (being upstreamed currently) as well as SPU3 (not supported by upstream yet).

Hopefully all of the changes are straightforward.

Let me know if anything needs changing.

Thanks,
Andrey Smirnov

Andrey Smirnov (6):
mfd: rave-sp: Remove unused defines
mfd: rave-sp: Fix incorrectly specified checksum type
mfd: rave-sp: Initialize flow control and parity of the port
mfd: rave-sp: Add legacy EEPROM access command translation
mfd: rave-sp: Add legacy watchdog ping command translation
mfd: rave-sp: Emulate CMD_GET_STATUS on device that don't support it

 drivers/mfd/rave-sp.c       | 119 +++++++++++++++++++++++-------------
 include/linux/mfd/rave-sp.h |   1 +
 2 files changed, 76 insertions(+), 44 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/6 mfd: rave-sp: Remove unused defines

Remove unusded defines that are a leftover from earlier iterations of the driver.

---
 drivers/mfd/rave-sp.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/mfd/rave-sp.c +0 -10
index 36dcd98977d6..dfa4f5f1c376 100644
@@ -63,16 +63,6 @@
 #define RAVE_SP_TX_BUFFER_SIZE				\
 	(RAVE_SP_STX_ETX_SIZE + 2 * RAVE_SP_RX_BUFFER_SIZE)
 
-#define RAVE_SP_BOOT_SOURCE_GET		0
-#define RAVE_SP_BOOT_SOURCE_SET		1
-
-#define RAVE_SP_RDU2_BOARD_TYPE_RMB	0
-#define RAVE_SP_RDU2_BOARD_TYPE_DEB	1
-
-#define RAVE_SP_BOOT_SOURCE_SD		0
-#define RAVE_SP_BOOT_SOURCE_EMMC	1
-#define RAVE_SP_BOOT_SOURCE_NOR		2
-
 /**
  * enum rave_sp_deframer_state - Possible state for de-framer
  *
Signature · 1 line
2.17.1
Applied
#2 lore raw

Re: [PATCH 1/6] mfd: rave-sp: Remove unused defines

Quoted 9 lines · Andrey Smirnov

Remove unusded defines that are a leftover from earlier iterations of the driver.

Quoted 3 lines
---
 drivers/mfd/rave-sp.c | 10 ----------
 1 file changed, 10 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw

PATCH 2/6 mfd: rave-sp: Fix incorrectly specified checksum type

In reply to Andrey Smirnov

RAVE SP firmware covered by "legacy" variant uses 16-bit CCITT checksum algorithm. Change the code to correctly reflect that.

---
 drivers/mfd/rave-sp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/rave-sp.c +1 -1
index dfa4f5f1c376..a90ec4986b22 100644
@@ -697,7 +697,7 @@ static const struct rave_sp_checksum rave_sp_checksum_ccitt = {
 };
 
 static const struct rave_sp_variant rave_sp_legacy = {
-	.checksum = &rave_sp_checksum_8b2c,
+	.checksum = &rave_sp_checksum_ccitt,
 	.cmd = {
 		.translate = rave_sp_default_cmd_translate,
 	},
Signature · 1 line
2.17.1
Applied
#4 lore raw

Re: [PATCH 2/6] mfd: rave-sp: Fix incorrectly specified checksum type

Quoted 9 lines · Andrey Smirnov

RAVE SP firmware covered by "legacy" variant uses 16-bit CCITT checksum algorithm. Change the code to correctly reflect that.

Quoted 3 lines
---
 drivers/mfd/rave-sp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw

PATCH 3/6 mfd: rave-sp: Initialize flow control and parity of the port

In reply to Andrey Smirnov

Relying on serial port defaults for flow control and parity can result in complete breakdown of communication with RAVE SP on some platforms where defaults are not what we need them to be. One such case is VF610-base ZII SPU3 board (not supported upstream). To avoid this problem in the future, add code to explicitly configure both.

---
 drivers/mfd/rave-sp.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mfd/rave-sp.c +7 -0
index a90ec4986b22..aa75d5841ca0 100644
@@ -766,6 +766,13 @@ static int rave_sp_probe(struct serdev_device *serdev)
 		return ret;
 
 	serdev_device_set_baudrate(serdev, baud);
+	serdev_device_set_flow_control(serdev, false);
+
+	ret = serdev_device_set_parity(serdev, SERDEV_PARITY_NONE);
+	if (ret) {
+		dev_err(dev, "Failed to set parity\n");
+		return ret;
+	}
 
 	ret = rave_sp_get_status(sp);
 	if (ret) {
Signature · 1 line
2.17.1
Applied
#6 lore raw

Re: [PATCH 3/6] mfd: rave-sp: Initialize flow control and parity of the port

Quoted 12 lines · Andrey Smirnov

Relying on serial port defaults for flow control and parity can result in complete breakdown of communication with RAVE SP on some platforms where defaults are not what we need them to be. One such case is VF610-base ZII SPU3 board (not supported upstream). To avoid this problem in the future, add code to explicitly configure both.

Quoted 3 lines
---
 drivers/mfd/rave-sp.c | 7 +++++++
 1 file changed, 7 insertions(+)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#7 lore raw

PATCH 4/6 mfd: rave-sp: Add legacy EEPROM access command translation

In reply to Andrey Smirnov

This is needed to make rave-sp-eeprom driver work on "legacy" firmware.

---
 drivers/mfd/rave-sp.c       | 2 ++
 include/linux/mfd/rave-sp.h | 1 +
 2 files changed, 3 insertions(+)
drivers/mfd/rave-sp.c +2 -0
index aa75d5841ca0..a999fa721b03 100644
@@ -635,6 +635,8 @@ static int rave_sp_default_cmd_translate(enum rave_sp_command command)
 		return 0x1E;
 	case RAVE_SP_CMD_RESET_REASON:
 		return 0x1F;
+	case RAVE_SP_CMD_RMB_EEPROM:
+		return 0x20;
 	default:
 		return -EINVAL;
 	}
include/linux/mfd/rave-sp.h +1 -0
index fe0ce7bc59cf..11eef77ef976 100644
@@ -21,6 +21,7 @@ enum rave_sp_command {
 	RAVE_SP_CMD_STATUS			= 0xA0,
 	RAVE_SP_CMD_SW_WDT			= 0xA1,
 	RAVE_SP_CMD_PET_WDT			= 0xA2,
+	RAVE_SP_CMD_RMB_EEPROM			= 0xA4,
 	RAVE_SP_CMD_SET_BACKLIGHT		= 0xA6,
 	RAVE_SP_CMD_RESET			= 0xA7,
 	RAVE_SP_CMD_RESET_REASON		= 0xA8,
Signature · 1 line
2.17.1
Applied
#8 lore raw

Re: [PATCH 4/6] mfd: rave-sp: Add legacy EEPROM access command translation

Quoted 9 lines · Andrey Smirnov

This is needed to make rave-sp-eeprom driver work on "legacy" firmware.

Quoted 4 lines
---
 drivers/mfd/rave-sp.c       | 2 ++
 include/linux/mfd/rave-sp.h | 1 +
 2 files changed, 3 insertions(+)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#9 lore raw

PATCH 5/6 mfd: rave-sp: Add legacy watchdog ping command translation

In reply to Andrey Smirnov

This is needed to make rave-sp-wdt driver to properly ping the watchdog on "legacy" firmware.

---
 drivers/mfd/rave-sp.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mfd/rave-sp.c +2 -0
index a999fa721b03..eee62ba6874d 100644
@@ -631,6 +631,8 @@ static int rave_sp_default_cmd_translate(enum rave_sp_command command)
 		return 0x14;
 	case RAVE_SP_CMD_SW_WDT:
 		return 0x1C;
+	case RAVE_SP_CMD_PET_WDT:
+		return 0x1D;
 	case RAVE_SP_CMD_RESET:
 		return 0x1E;
 	case RAVE_SP_CMD_RESET_REASON:
Signature · 1 line
2.17.1
Applied
#10 lore raw

Re: [PATCH 5/6] mfd: rave-sp: Add legacy watchdog ping command translation

Quoted 9 lines · Andrey Smirnov

This is needed to make rave-sp-wdt driver to properly ping the watchdog on "legacy" firmware.

Quoted 3 lines
---
 drivers/mfd/rave-sp.c | 2 ++
 1 file changed, 2 insertions(+)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#11 lore raw

PATCH 6/6 mfd: rave-sp: Emulate CMD_GET_STATUS on device that don't support it

In reply to Andrey Smirnov

CMD_GET_STATUS is not supported by some devices implementing RDU2-compatible ICD as well as "legacy" devices. To account for that fact, add code that obtains the same information (app/bootloader FW version) using several different commands.

---
 drivers/mfd/rave-sp.c | 96 ++++++++++++++++++++++++++++---------------
 1 file changed, 63 insertions(+), 33 deletions(-)
drivers/mfd/rave-sp.c +63 -33
index eee62ba6874d..2a8369657e38 100644
@@ -117,14 +117,44 @@ struct rave_sp_checksum {
 	void (*subroutine)(const u8 *, size_t, u8 *);
 };
 
+struct rave_sp_version {
+	u8     hardware;
+	__le16 major;
+	u8     minor;
+	u8     letter[2];
+} __packed;
+
+struct rave_sp_status {
+	struct rave_sp_version bootloader_version;
+	struct rave_sp_version firmware_version;
+	u16 rdu_eeprom_flag;
+	u16 dds_eeprom_flag;
+	u8  pic_flag;
+	u8  orientation;
+	u32 etc;
+	s16 temp[2];
+	u8  backlight_current[3];
+	u8  dip_switch;
+	u8  host_interrupt;
+	u16 voltage_28;
+	u8  i2c_device_status;
+	u8  power_status;
+	u8  general_status;
+	u8  deprecated1;
+	u8  power_led_status;
+	u8  deprecated2;
+	u8  periph_power_shutoff;
+} __packed;
+
 /**
  * struct rave_sp_variant_cmds - Variant specific command routines
  *
  * @translate:	Generic to variant specific command mapping routine
- *
+ * @get_status: Variant specific implementation of CMD_GET_STATUS
  */
 struct rave_sp_variant_cmds {
 	int (*translate)(enum rave_sp_command);
+	int (*get_status)(struct rave_sp *sp, struct rave_sp_status *);
 };
 
 /**
@@ -170,35 +200,6 @@ struct rave_sp {
 	const char *part_number_bootloader;
 };
 
-struct rave_sp_version {
-	u8     hardware;
-	__le16 major;
-	u8     minor;
-	u8     letter[2];
-} __packed;
-
-struct rave_sp_status {
-	struct rave_sp_version bootloader_version;
-	struct rave_sp_version firmware_version;
-	u16 rdu_eeprom_flag;
-	u16 dds_eeprom_flag;
-	u8  pic_flag;
-	u8  orientation;
-	u32 etc;
-	s16 temp[2];
-	u8  backlight_current[3];
-	u8  dip_switch;
-	u8  host_interrupt;
-	u16 voltage_28;
-	u8  i2c_device_status;
-	u8  power_status;
-	u8  general_status;
-	u8  deprecated1;
-	u8  power_led_status;
-	u8  deprecated2;
-	u8  periph_power_shutoff;
-} __packed;
-
 static bool rave_sp_id_is_event(u8 code)
 {
 	return (code & 0xF0) == RAVE_SP_EVNT_BASE;
@@ -660,18 +661,44 @@ static const char *devm_rave_sp_version(struct device *dev,
 			      version->letter[1]);
 }
 
-static int rave_sp_get_status(struct rave_sp *sp)
+static int rave_sp_rdu1_get_status(struct rave_sp *sp,
+				   struct rave_sp_status *status)
 {
-	struct device *dev = &sp->serdev->dev;
 	u8 cmd[] = {
 		[0] = RAVE_SP_CMD_STATUS,
 		[1] = 0
 	};
+
+	return rave_sp_exec(sp, cmd, sizeof(cmd), status, sizeof(*status));
+}
+
+static int rave_sp_emulated_get_status(struct rave_sp *sp,
+				       struct rave_sp_status *status)
+{
+	u8 cmd[] = {
+		[0] = RAVE_SP_CMD_GET_FIRMWARE_VERSION,
+		[1] = 0,
+	};
+	int ret;
+
+	ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status->firmware_version,
+			   sizeof(status->firmware_version));
+	if (ret)
+		return ret;
+
+	cmd[0] = RAVE_SP_CMD_GET_BOOTLOADER_VERSION;
+	return rave_sp_exec(sp, cmd, sizeof(cmd), &status->bootloader_version,
+			    sizeof(status->bootloader_version));
+}
+
+static int rave_sp_get_status(struct rave_sp *sp)
+{
+	struct device *dev = &sp->serdev->dev;
 	struct rave_sp_status status;
 	const char *version;
 	int ret;
 
-	ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status, sizeof(status));
+	ret = sp->variant->cmd.get_status(sp, &status);
 	if (ret)
 		return ret;
 
@@ -704,6 +731,7 @@ static const struct rave_sp_variant rave_sp_legacy = {
 	.checksum = &rave_sp_checksum_ccitt,
 	.cmd = {
 		.translate = rave_sp_default_cmd_translate,
+		.get_status = rave_sp_emulated_get_status,
 	},
 };
 
@@ -711,6 +739,7 @@ static const struct rave_sp_variant rave_sp_rdu1 = {
 	.checksum = &rave_sp_checksum_8b2c,
 	.cmd = {
 		.translate = rave_sp_rdu1_cmd_translate,
+		.get_status = rave_sp_rdu1_get_status,
 	},
 };
 
@@ -718,6 +747,7 @@ static const struct rave_sp_variant rave_sp_rdu2 = {
 	.checksum = &rave_sp_checksum_ccitt,
 	.cmd = {
 		.translate = rave_sp_rdu2_cmd_translate,
+		.get_status = rave_sp_emulated_get_status,
 	},
 };
 
Signature · 1 line
2.17.1
Applied
#12 lore raw

Re: [PATCH 6/6] mfd: rave-sp: Emulate CMD_GET_STATUS on device that don't support it

Quoted 11 lines · Andrey Smirnov

CMD_GET_STATUS is not supported by some devices implementing RDU2-compatible ICD as well as "legacy" devices. To account for that fact, add code that obtains the same information (app/bootloader FW version) using several different commands.

Quoted 3 lines
---
 drivers/mfd/rave-sp.c | 96 ++++++++++++++++++++++++++++---------------
 1 file changed, 63 insertions(+), 33 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog