diff mbox series

[059/120] MIPS: PS2: SIF: Enable the IOP to issue SIF commands

Message ID eada3aa266c9323eea975a70dd5bc5e99f78fc29.1567326213.git.noring@nocrew.org (mailing list archive)
State RFC
Headers show
Series Linux for the PlayStation 2 | expand

Commit Message

Fredrik Noring Sept. 1, 2019, 3:59 p.m. UTC
Send the SIF_CMD_INIT_CMD command with option argument 0 to let the IOP
issue SIF commands. The supplied address is the MAINADDR.

Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
 drivers/ps2/sif.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/drivers/ps2/sif.c b/drivers/ps2/sif.c
index fac1a5117d1c..b6c348974bdb 100644
--- a/drivers/ps2/sif.c
+++ b/drivers/ps2/sif.c
@@ -441,6 +441,13 @@  static int iop_reset(void)
 	return iop_reset_arg(IOP_RESET_ARGS);
 }
 
+static int sif_cmd_init(dma_addr_t cmd_buffer)
+{
+	const struct sif_cmd_change_addr_packet cmd = { .addr = cmd_buffer };
+
+	return sif_cmd_opt(SIF_CMD_INIT_CMD, 0, &cmd, sizeof(cmd));
+}
+
 static int sif_read_subaddr(dma_addr_t *subaddr)
 {
 	if (!completed(sif_smflag_cmdinit))
@@ -584,6 +591,8 @@  EXPORT_SYMBOL_GPL(iop_error_message);
  *
  * 11. Service SIF0 RPCs via interrupts.
  *
+ * 12. Enable the IOP to issue SIF commands.
+ *
  * Return: 0 on success, otherwise a negative error number
  */
 static int __init sif_init(void)
@@ -644,8 +653,17 @@  static int __init sif_init(void)
 		goto err_irq_sif0;
 	}
 
+	err = sif_cmd_init(virt_to_phys(sif0_buffer));
+	if (err) {
+		pr_err("sif: Failed to initialise commands with %d\n", err);
+		goto err_cmd_init;
+	}
+
 	return 0;
 
+err_cmd_init:
+	free_irq(IRQ_DMAC_SIF0, NULL);
+
 err_irq_sif0:
 	sif_disable_dma();