frno7 / linux

Linux 2.2, 2.6, 3.x, 4.x and 5.x kernels for the PlayStation 2.
Other
84 stars 5 forks source link

reboot / halt / shutdown support #67

Closed nickb834 closed 2 years ago

nickb834 commented 2 years ago

I've noticed that reboot / shutdown / halt doesn't work - I'm guessing this is something to do with the busybox source needs a patch to deal with the hardware on a PS2 - I've had a quick look through this repo but I can't tell if halt / reboot etc are actually expected to be supported.

Is there a workaround? or is it the case that it's unsupported or is this an issue with my build?

frno7 commented 2 years ago

Powering off is indeed supported, try poweroff -f. It may be the swiftest shutdown you’ve ever seen for a Linux machine. :-) Likewise halt -f, but reboot -f isn’t serviceable as of yet. Confer commit 92375ad22b6ee40e08723d7ff9e7f7cd7796bd88 for details.

If memory serves me the -f option skips a failed attempt by Busybox to run a shutdown script via init, that I suppose isn’t installed with your INITRAMFS. Such scripts normally unmount filesystems, etc. We ought to write a note about this on the Busybox wiki page.

uyjulian commented 2 years ago

IIRC poweroff scmd won't work if dev9 is turned on.

Also, on older SCPH-1xxxx hardware, poweroff scmd won't work at all since the mechacon on those consoles does not support that command.

frno7 commented 2 years ago

@uyjulian, yes, disclaimers apply. :-) The SCPH-1xxxx models are currently listed as incompatible, mainly due to issue #28, and we’ve got (for scmd_read_machine_name)

https://github.com/frno7/linux/blob/59a11ab94a4020408c7dfbf92bd55778e17b43f1/arch/mips/ps2/scmd.c#L226-L227

and we’ll eventually need to do something similar to

https://github.com/frno7/linux/blob/59a11ab94a4020408c7dfbf92bd55778e17b43f1/arch/mips/ps2/identify.c#L58-L73

for scmd_power_off too...

IIRC poweroff scmd won't work if dev9 is turned on.

Hmm, it works in combination with the expansion bay ATA driver, which surely needs dev9 powered on, doesn’t it? See comment https://github.com/frno7/linux/issues/18#issuecomment-877668862 et al.

uyjulian commented 2 years ago

Hmm, it works in combination with the expansion bay ATA driver, which surely needs dev9 powered on, doesn’t it? See comment #18 (comment) et al.

On the expansion bay connector there is the PWR_CTRL / POW_CTRL signal tied to the syscon and this appears to be tied to the value of the register 0xBF80146C. In this case I'll refer to this as dev9 power.
This, among other things, controls the power off behavior (e.g. what happens when you press the power button or the power off scmd is sent). IIRC sending the power off scmd with dev9 powered on will result in nothing happening, so it needs to be powered off e.g. https://github.com/ps2dev/ps2sdk/blob/f4e8415ebd4146f414670150a92f472dca9ddba3/iop/dev9/dev9/src/ps2dev9.c#L359 before sending the power off scmd.

frno7 commented 2 years ago

Yes, we have the corresponding power operations in the Linux kernel here:

https://github.com/frno7/linux/blob/36e7c3030580bb898f6985129a87a95194aeec0f/drivers/ps2/iop-dev9.c#L84-L216

It’s supposed to be powered off by iop_dev9_exit

https://github.com/frno7/linux/blob/36e7c3030580bb898f6985129a87a95194aeec0f/drivers/ps2/iop-dev9.c#L296-L344

but I’m not completely sure that’s needed for powering off the system via SCMD.

A lot of the dev9 is presently unclear, including the names and purposes of most registers, unfortunately. Is there a good, reliable and reasonably complete write up of it somewhere? I’ve seen DEV9C.txt 2017-02-11 by Wisi.

uyjulian commented 2 years ago

DEV9C.txt and SPEED.txt in IOP_DMAC_DEV9_SPEED_docs_2017.02.11.zip are pretty much the documents out there.

DEV9C.txt is related to the Dev9 controller on the PS2 side, which would be physically located near the expansion bay connector.
SPEED.txt is related to the SPEED chip physically located in the network adapter attached to the expansion bay connector.

It also helps if you also refer to the service manual for the SCPH-39000 as the aforementioned documents refer to signals as written in the schematics in the service manual.