astlpc: add a dummy KCS data write for KCS status updates

Some hardware KCS implementations may not trigger an interrupt when only
the status register is written. To handle these, we perform a write to
the data register too, using a protocol-defined dummy value of 0xff.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Change-Id: I4ce000e378e98b1fc1414b5ce500724540853b50
diff --git a/astlpc.c b/astlpc.c
index 085cb6d..5218c92 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -88,9 +88,19 @@
 static int mctp_astlpc_kcs_set_status(struct mctp_binding_astlpc *astlpc,
 		uint8_t status)
 {
+	uint8_t buf[2];
 	int rc;
 
-	rc = pwrite(astlpc->kcs_fd, &status, 1, KCS_REG_STATUS);
+	/* Since we're setting the status register, we want the other endpoint
+	 * to be interrupted. However, some hardware may only raise a host-side
+	 * interrupt on an ODR event.
+	 * So, write a dummy value of 0xff to ODR, which will ensure that an
+	 * interrupt is triggered, and can be ignored by the host.
+	 */
+	buf[KCS_REG_DATA] = 0xff;
+	buf[KCS_REG_STATUS] = status;
+
+	rc = pwrite(astlpc->kcs_fd, buf, 2, 0);
 	if (rc != 1) {
 		mctp_prwarn("KCS status write failed");
 		return -1;
@@ -218,6 +228,9 @@
 	case 0x2:
 		mctp_astlpc_tx_complete(astlpc);
 		break;
+	case 0xff:
+		/* reserved value for dummy data writes; do nothing */
+		break;
 	default:
 		mctp_prwarn("unknown message 0x%x", data);
 	}