Re: [RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support
Add support for the BootMii 'mini' firmware replacement for the Starlet processor. 'mini' is an open source IOS replacement written from scratch by Team Twiizers. It's not a replacement, it doesn't have any of the same functionality. I didn't know 'replacement' had that semantics. It's ambiguous. My intention was to say that 'mini' firmware is an alternative to the stock IOS firmware, not trying to imply that it behaves like it or it is compatible with it. Point taken. I'll use 'mini' alternate firmware if that's ok. Alternative firmware is fine. +enum starlet_ipc_flavour { +STARLET_IPC_IOS, +STARLET_IPC_MINI, +}; I thought you don't support IOS at all anymore? I don't plan to mainline IOS support. But to make runtime decisions I need to know if we are running along the 'mini' firmware or the default IOS firmware. That's the intention of that enum. Modern mini will always have AHBPROT set up to give you full access, so this isn't needed either. So we have two options here: - assume that whatever firmware is running properly sets AHBPROT and hope it works - or try to use the existing firmware interfaces to check and make sure that AHBPROT is indeed properly set I chose the second option here. It is much much simpler to simply require a new enough mini :-) Do you need this driver to boot? If not, it might be best to leave it out for now. Strictly speaking, we don't need the driver to boot if we asume that AHBPROT is properly set. But we'll need it later to shutdown 'mini' drivers, unless 'mini' is changed to boot PowerPC code with all hardware already relinquished. That is not true for the last available version of 'mini' firmware. That version still boots PowerPC code with at least the SDHCI controller driven by 'mini'. I'll fix this. Segher ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support
Segher Boessenkool wrote: Add support for the BootMii 'mini' firmware replacement for the Starlet processor. 'mini' is an open source IOS replacement written from scratch by Team Twiizers. It's not a replacement, it doesn't have any of the same functionality. I didn't know 'replacement' had that semantics. My intention was to say that 'mini' firmware is an alternative to the stock IOS firmware, not trying to imply that it behaves like it or it is compatible with it. Point taken. I'll use 'mini' alternate firmware if that's ok. It grants full access to the hardware found on the Nintendo Wii video game console via a custom IPC mechanism. This is out of date, you get full register-level hardware access now. Yes, as I already said in one of my messages. That description doesn't try to imply that you cannot access the hardware via other means. It describes what the IPC mechanism is about. If the comment is misleading I can change the comment or enhance it. Do you want to mainline any of the drivers that work via mini proxy? If not, you can remove quite some bit of code here I think. Yes, that I already said too :) +enum starlet_ipc_flavour { +STARLET_IPC_IOS, +STARLET_IPC_MINI, +}; I thought you don't support IOS at all anymore? I don't plan to mainline IOS support. But to make runtime decisions I need to know if we are running along the 'mini' firmware or the default IOS firmware. That's the intention of that enum. +config STARLET_MINI +bool BootMii Starlet 'mini' firmware support +depends on WII EXPERIMENTAL Given that this is the only supported starlet firmware interface, does it make sense to expose the option to the user? You're right. We can just select it until we have another alternate firmware and its support available. big snip, see my remove stuff comment above +static void mipc_init_ahbprot(struct mipc_device *ipc_dev) +{ +void __iomem *hw_ahbprot; +u32 initial_ahbprot, ahbprot = 0; + +hw_ahbprot = mipc_get_hw_reg(HW_AHBPROT_OF_COMPATIBLE); +if (!hw_ahbprot) +goto done; + +initial_ahbprot = mipc_readl(hw_ahbprot); +if (initial_ahbprot != 0x) { +pr_debug(AHBPROT=%08X (before)\n, initial_ahbprot); +/* enable full access from the PowerPC side */ +mipc_writel(0x, hw_ahbprot); +} + +ahbprot = mipc_readl(hw_ahbprot); +if (initial_ahbprot != ahbprot) +pr_debug(AHBPROT=%08X (after)\n, ahbprot); +done: +if (ahbprot != 0x) +pr_err(failed to set AHBPROT\n); +} Modern mini will always have AHBPROT set up to give you full access, so this isn't needed either. So we have two options here: - assume that whatever firmware is running properly sets AHBPROT and hope it works - or try to use the existing firmware interfaces to check and make sure that AHBPROT is indeed properly set I chose the second option here. +#ifdef CONFIG_HLWD_PIC +/* + * Setup the Hollywood interrupt controller as soon as + * we detect that we are running under the mini firmware. + */ +hlwd_pic_probe(); +#endif Why? The comment doesn't say. Same as before, we don't try to setup the Hollywood interrupt controller until we have verified that we can directly access the hardware. Do you need this driver to boot? If not, it might be best to leave it out for now. Strictly speaking, we don't need the driver to boot if we asume that AHBPROT is properly set. But we'll need it later to shutdown 'mini' drivers, unless 'mini' is changed to boot PowerPC code with all hardware already relinquished. That is not true for the last available version of 'mini' firmware. That version still boots PowerPC code with at least the SDHCI controller driven by 'mini'. We need to issue a IPC_SDHC_EXIT to the firmware to force it to stop using the SDHCI controller. Thanks, Albert ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support
Add support for the BootMii 'mini' firmware replacement for the Starlet processor. 'mini' is an open source IOS replacement written from scratch by Team Twiizers. It's not a replacement, it doesn't have any of the same functionality. It grants full access to the hardware found on the Nintendo Wii video game console via a custom IPC mechanism. This is out of date, you get full register-level hardware access now. Do you want to mainline any of the drivers that work via mini proxy? If not, you can remove quite some bit of code here I think. +enum starlet_ipc_flavour { + STARLET_IPC_IOS, + STARLET_IPC_MINI, +}; I thought you don't support IOS at all anymore? +config STARLET_MINI + bool BootMii Starlet 'mini' firmware support + depends on WII EXPERIMENTAL Given that this is the only supported starlet firmware interface, does it make sense to expose the option to the user? big snip, see my remove stuff comment above +static void mipc_init_ahbprot(struct mipc_device *ipc_dev) +{ + void __iomem *hw_ahbprot; + u32 initial_ahbprot, ahbprot = 0; + + hw_ahbprot = mipc_get_hw_reg(HW_AHBPROT_OF_COMPATIBLE); + if (!hw_ahbprot) + goto done; + + initial_ahbprot = mipc_readl(hw_ahbprot); + if (initial_ahbprot != 0x) { + pr_debug(AHBPROT=%08X (before)\n, initial_ahbprot); + /* enable full access from the PowerPC side */ + mipc_writel(0x, hw_ahbprot); + } + + ahbprot = mipc_readl(hw_ahbprot); + if (initial_ahbprot != ahbprot) + pr_debug(AHBPROT=%08X (after)\n, ahbprot); +done: + if (ahbprot != 0x) + pr_err(failed to set AHBPROT\n); +} Modern mini will always have AHBPROT set up to give you full access, so this isn't needed either. +#ifdef CONFIG_HLWD_PIC + /* +* Setup the Hollywood interrupt controller as soon as +* we detect that we are running under the mini firmware. +*/ + hlwd_pic_probe(); +#endif Why? The comment doesn't say. Do you need this driver to boot? If not, it might be best to leave it out for now. Segher ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support
Arnd Bergmann wrote: On Sunday 22 November 2009, Albert Herranz wrote: + * + */ +struct mipc_device { +void __iomem *io_base; +int irq; + +struct device *dev; + +spinlock_t call_lock; /* serialize firmware calls */ +spinlock_t io_lock; /* serialize access to io registers */ + +struct mipc_infohdr *hdr; + +struct mipc_req *in_ring; +size_t in_ring_size; +volatile u16 intail_idx; + +struct mipc_req *out_ring; +size_t out_ring_size; +volatile u16 outhead_idx; + +u32 tag; +}; The 'volatile' here seems out of place. What are you trying to protect against? Nothing. I'll get rid of it. It slipped through from ancient versions of the patch. The rest of the patch seems to be made up of layers of wrappers. They are all well coded, but I got a feeling that the same could be achieved with less of it. The code provides a complete emulation layer of hardware accessors via ipc calls to the firmware. This was a requirement to access part of the hardware until a magic register was found allowing direct hardware access from the PowerPC side. I can get rid of the currently unused infrastructure and leave the strictly needed code (i.e. code to make sure that the firmware SDHC driver is shutdown and that the ahbprot register is properly setup). I'll look into that. Thanks. Cheers, Albert ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support
Add support for the BootMii 'mini' firmware replacement for the Starlet processor. 'mini' is an open source IOS replacement written from scratch by Team Twiizers. It grants full access to the hardware found on the Nintendo Wii video game console via a custom IPC mechanism. Signed-off-by: Albert Herranz albert_herr...@yahoo.es --- arch/powerpc/include/asm/starlet-mini.h | 175 arch/powerpc/include/asm/starlet.h| 26 + arch/powerpc/platforms/embedded6xx/Kconfig| 14 +- arch/powerpc/platforms/embedded6xx/Makefile |1 + arch/powerpc/platforms/embedded6xx/starlet-mipc.c | 1053 + 5 files changed, 1268 insertions(+), 1 deletions(-) create mode 100644 arch/powerpc/include/asm/starlet-mini.h create mode 100644 arch/powerpc/include/asm/starlet.h create mode 100644 arch/powerpc/platforms/embedded6xx/starlet-mipc.c diff --git a/arch/powerpc/include/asm/starlet-mini.h b/arch/powerpc/include/asm/starlet-mini.h new file mode 100644 index 000..bfa2a2c --- /dev/null +++ b/arch/powerpc/include/asm/starlet-mini.h @@ -0,0 +1,175 @@ +/* + * arch/powerpc/include/asm/starlet-mini.h + * + * Definitions for the 'mini' firmware replacement for Starlet + * Copyright (C) 2009 The GameCube Linux Team + * Copyright (C) 2009 Albert Herranz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + */ + +#ifndef __STARLET_MINI_H +#define __STARLET_MINI_H + +#ifdef CONFIG_STARLET_MINI + +/* + * mini ipc call numbering scheme + */ + +#define _MIPC_FAST0x01 +#define _MIPC_SLOW0x00 + +#define _MIPC_DEV_SYS 0x00 +#define _MIPC_DEV_NAND0x01 +#define _MIPC_DEV_SDHC0x02 +#define _MIPC_DEV_KEYS0x03 +#define _MIPC_DEV_AES 0x04 +#define _MIPC_DEV_BOOT2 0x05 +#define _MIPC_DEV_PPC 0x06 +#define _MIPC_DEV_SDMMC 0x07 + +#define _MIPC_SYS_PING0x +#define _MIPC_SYS_JUMP0x0001 +#define _MIPC_SYS_GETVERS 0x0002 +#define _MIPC_SYS_GETGITS 0x0003 +#define _MIPC_SYS_WRITE32 0x0100 +#define _MIPC_SYS_WRITE16 0x0101 +#define _MIPC_SYS_WRITE8 0x0102 +#define _MIPC_SYS_READ32 0x0103 +#define _MIPC_SYS_READ16 0x0104 +#define _MIPC_SYS_READ8 0x0105 +#define _MIPC_SYS_SET32 0x0106 +#define _MIPC_SYS_SET16 0x0107 +#define _MIPC_SYS_SET80x0108 +#define _MIPC_SYS_CLEAR32 0x0109 +#define _MIPC_SYS_CLEAR16 0x010a +#define _MIPC_SYS_CLEAR8 0x010b +#define _MIPC_SYS_MASK32 0x010c +#define _MIPC_SYS_MASK16 0x010d +#define _MIPC_SYS_MASK8 0x010e + +#define _MIPC_NAND_RESET 0x +#define _MIPC_NAND_GETID 0x0001 +#define _MIPC_NAND_READ 0x0002 +#define _MIPC_NAND_WRITE 0x0003 +#define _MIPC_NAND_ERASE 0x0004 +#define _MIPC_NAND_STATUS 0x0005 + +#define _MIPC_SDHC_DISCOVER 0x +#define _MIPC_SDHC_EXIT0x0001 + +#define _MIPC_SDMMC_ACK 0x +#define _MIPC_SDMMC_READ 0x0001 +#define _MIPC_SDMMC_WRITE 0x0002 +#define _MIPC_SDMMC_STATE 0x0003 +#define _MIPC_SDMMC_SIZE 0x0004 + +#define _MIPC_KEYS_GETOTP 0x +#define _MIPC_KEYS_GETEEP 0x0001 + +#define _MIPC_AES_RESET 0x +#define _MIPC_AES_SETIV 0x0001 +#define _MIPC_AES_SETKEY 0x0002 +#define _MIPC_AES_DECRYPT 0x0003 + +#define _MIPC_BOOT2_RUN 0x +#define _MIPC_BOOT2_TMD 0x0001 + +#define _MIPC_PPC_BOOT0x + + +/* + * + */ + +#define _MIPC_MODEBITS 8 +#define _MIPC_DEVBITS 8 +#define _MIPC_NRBITS 16 + +#define _MIPC_MODEMASK ((1 _MIPC_MODEBITS)-1) +#define _MIPC_DEVMASK ((1 _MIPC_DEVBITS)-1) +#define _MIPC_NRMASK ((1 _MIPC_NRBITS)-1) + +#define _MIPC_MODESHIFT(_MIPC_DEVSHIFT + _MIPC_DEVBITS) +#define _MIPC_DEVSHIFT (_MIPC_NRSHIFT + _MIPC_NRBITS) +#define _MIPC_NRSHIFT 0 + +#define _MIPC(mode, dev, nr) \ + (((mode) _MIPC_MODESHIFT) | \ +((dev) _MIPC_DEVSHIFT) | \ +((nr) _MIPC_NRSHIFT)) + +#define _MIPC_FAST_SYS(nr) _MIPC(_MIPC_FAST, _MIPC_DEV_SYS, nr) + +#define MIPC_SYS_PING _MIPC_FAST_SYS(_MIPC_SYS_PING) +#define MIPC_SYS_WRITE32 _MIPC_FAST_SYS(_MIPC_SYS_WRITE32) +#define MIPC_SYS_WRITE16 _MIPC_FAST_SYS(_MIPC_SYS_WRITE16) +#define MIPC_SYS_WRITE8_MIPC_FAST_SYS(_MIPC_SYS_WRITE8) +#define MIPC_SYS_READ32_MIPC_FAST_SYS(_MIPC_SYS_READ32) +#define MIPC_SYS_READ16_MIPC_FAST_SYS(_MIPC_SYS_READ16) +#define MIPC_SYS_READ8 _MIPC_FAST_SYS(_MIPC_SYS_READ8) +#define MIPC_SYS_SET32 _MIPC_FAST_SYS(_MIPC_SYS_SET32) +#define MIPC_SYS_SET16 _MIPC_FAST_SYS(_MIPC_SYS_SET16) +#define MIPC_SYS_SET8 _MIPC_FAST_SYS(_MIPC_SYS_SET8) +#define MIPC_SYS_CLEAR32 _MIPC_FAST_SYS(_MIPC_SYS_CLEAR32) +#define MIPC_SYS_CLEAR16 _MIPC_FAST_SYS(_MIPC_SYS_CLEAR16) +#define MIPC_SYS_CLEAR8_MIPC_FAST_SYS(_MIPC_SYS_CLEAR8) +#define MIPC_SYS_MASK32
Re: [RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support
On Sunday 22 November 2009, Albert Herranz wrote: + * + */ +struct mipc_device { + void __iomem *io_base; + int irq; + + struct device *dev; + + spinlock_t call_lock; /* serialize firmware calls */ + spinlock_t io_lock; /* serialize access to io registers */ + + struct mipc_infohdr *hdr; + + struct mipc_req *in_ring; + size_t in_ring_size; + volatile u16 intail_idx; + + struct mipc_req *out_ring; + size_t out_ring_size; + volatile u16 outhead_idx; + + u32 tag; +}; The 'volatile' here seems out of place. What are you trying to protect against? The rest of the patch seems to be made up of layers of wrappers. They are all well coded, but I got a feeling that the same could be achieved with less of it. Arnd ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev