Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
On 6/21/23 04:55, Andre Przywara wrote: On Tue, 20 Jun 2023 16:11:48 -0600 Sam Edwards wrote: Hi Sam, pleasure to write with you ;-) Hi Andre, Likewise! Well, so this is actually the fallback implementation which should somewhat work on most SoCs: set a flag, reset, and catch the flag in the SPL. For modern SoCs with CPU hotplug support (the H616 is one one of those, and it looks like the T113s is as well), there is actually a more direct route: Oh man, I would definitely prefer a direct route that doesn't require the SPL coming up a second time, but... We put some magic and the FEL entry address into some special memory locations, then just reset. Now the *BootROM* will do the check already, and branch to the provided entry point, which would be the FEL routine. This doesn't rely on a prepared SPL to be loaded, so works without a boot device with mainline U-Boot around. Refer to section 3.4.2.3 and 3.4.2.4 of the T113-S3 user manual (v1.1). According to this, the magic would be 0xfa50392f, the magic's address is 0x070005C0, and CPU0's entry point address would be in 0x070005C4. I had a proof of concept implementation for the H616 using this method. ...I tried this and it seems that the 070005C* block hardware-resets to zero before BROM runs. Is there a softer reset method you had in mind that would avoid this? The only problem left would be that someone needs to clean the magic afterwards, otherwise any follow-up reset would trigger FEL mode again. That's at least pretty fixable though: instead of setting the entry address to the FEL entry point, set it to a thunk placed in SRAM that clears the flag before continuing onward to FEL. The "fel-reset" command (which is easier to type than what I have, "run fel_do_enter") would then call sunxi_fel_flag_set() and initiate a reset, and the SPL's early init just has to do sunxi_fel_flag_test() -> sunxi_fel_flag_clear() -> go_to_fel(). Seems easy enough. Could you recommend to me a sufficiently different chip to test my abstractions against? Something ARMv8 and *without* RTC? I think all ARMv8 parts have an RTC, so your generic approach might work there as well. The complication is that the SPL switches to AArch64 very early, in hand-stitched AArch32 assembly, check out arch/arm/include/asm/arch-sunxi/boot0.h. The check would need to be coded like this, then. I can then send in a series adding FEL support for that. (Also, did that H3 patch actually land? I didn't see anything but want to know if I should be refactoring my approach to extend what that H3 patch does or not.) https://patchwork.ozlabs.org/project/uboot/patch/c211aa414c59e7275fef82bf6f0035276d6e29f3.1656875482.git.msucha...@suse.de/ This approach seems close to mine, only my go_to_fel() enters by way of return_to_fel() after first modifying fel_stash.lr, since the return_to_fel() mechanism already takes care of restoring the core to a BROM-friendly state. One might abuse the board as a T113s dev board, maybe ;-) Does it work without any of the modules populated? Sure, if you're thinking about getting one. You just need an ATX-pinout PSU to power the BMC (it runs off of the 5V standby rail). ... having a board. So far you are the one contributor with access to the hardware, so: thanks for volunteering! ;-) Andre, please, I know you're being tongue-in-cheek here, but I said "no." We should have reached the agree-to-disagree point 2 emails ago: you've made your (very compelling) case for why downstream would benefit from the early expertise of the upstream DT reviewers, and how upstream would benefit from having the DT for a second "real" T113-using board, but at some point you need to trust that I understand that and that I must therefore have very good reasons not to be distracting myself with trying to (dual-)boot a mainline kernel yet. One thing at a time, y'know? :) The U-Boot build system support some kind of build time DT "overlay" feature: You put a file with the same name, but ending in "-u-boot.dtsi" in the arch/arm/dts directory, and it will be included into the DT which gets embedded into the U-Boot image. See arch/arm/dts/sun50i-a64-sopine-baseboard-u-boot.dts for an example, and doc/develop/devicetree/control.rst for the proper documentation. So we upstream a minimal, non-controversial and non-contradicting base .dts into the kernel tree, and can fix things up for the time being using this method. This hack can then go away if either the mainline kernel DT gets fixed and/or U-Boot learns the quad-SPI trick. Oh, good to know! I'll try to remember that this option exists when the time comes to use it. Someone from the board vendor company actually actively adding upstream support for their device early. There were some examples in the past where employees participated in upstreaming, but I cannot remember seeing this too often when it comes to the initial DT support. I brought this email thread to the attention of the firmware
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
On Tue, 20 Jun 2023 16:11:48 -0600 Sam Edwards wrote: Hi Sam, pleasure to write with you ;-) > On 6/20/23 06:42, Andre Przywara wrote: > > So yeah, the request of a "Enter FEL" command came up multiple times, but > > so far no one could be bothered to implement this properly. The idea would > > be to have a generic command (more like "fel-reset" than efex), and > > allow each SoC (family) to implement this differently, as every > > SoC requires something a bit different here (32-bit vs. 64-bit, having an > > RTC vs not, etc). > > > > If you could post your solution somewhere, we could start this effort. > > There was some patch for the H3 already, and it's relatively > > straight-forward on the newer SoCs (H616, IIRC), so if at least two > > popular, but different SoCs would be supported, we could make sure to have > > the right abstractions in place. > > I already have a "go_to_fel()" that does the right thing to enter FEL > from the SPL; I would pretty much just need to introduce the following > per-SoC(-family) functions: > - bool sunxi_fel_flag_test(void) > - void sunxi_fel_flag_clear(void) > - void sunxi_fel_flag_set(void) Well, so this is actually the fallback implementation which should somewhat work on most SoCs: set a flag, reset, and catch the flag in the SPL. For modern SoCs with CPU hotplug support (the H616 is one one of those, and it looks like the T113s is as well), there is actually a more direct route: We put some magic and the FEL entry address into some special memory locations, then just reset. Now the *BootROM* will do the check already, and branch to the provided entry point, which would be the FEL routine. This doesn't rely on a prepared SPL to be loaded, so works without a boot device with mainline U-Boot around. Refer to section 3.4.2.3 and 3.4.2.4 of the T113-S3 user manual (v1.1). According to this, the magic would be 0xfa50392f, the magic's address is 0x070005C0, and CPU0's entry point address would be in 0x070005C4. I had a proof of concept implementation for the H616 using this method. The only problem left would be that someone needs to clean the magic afterwards, otherwise any follow-up reset would trigger FEL mode again. > The "fel-reset" command (which is easier to type than what I have, "run > fel_do_enter") would then call sunxi_fel_flag_set() and initiate a > reset, and the SPL's early init just has to do sunxi_fel_flag_test() -> > sunxi_fel_flag_clear() -> go_to_fel(). Seems easy enough. > > Could you recommend to me a sufficiently different chip to test my > abstractions against? Something ARMv8 and *without* RTC? I think all ARMv8 parts have an RTC, so your generic approach might work there as well. The complication is that the SPL switches to AArch64 very early, in hand-stitched AArch32 assembly, check out arch/arm/include/asm/arch-sunxi/boot0.h. The check would need to be coded like this, then. > I can then send > in a series adding FEL support for that. (Also, did that H3 patch > actually land? I didn't see anything but want to know if I should be > refactoring my approach to extend what that H3 patch does or not.) https://patchwork.ozlabs.org/project/uboot/patch/c211aa414c59e7275fef82bf6f0035276d6e29f3.1656875482.git.msucha...@suse.de/ Another generic approach for ARMv7 parts would be to reset the peripherals as much as possible, then configure the core in a BROM compatible way (MMU off, etc) and just branch to the BROM FEL entry address. This idea is already somewhat used in our return-to-FEL code in the SPL, although we don't change too much of the core setup in the SPL. > > Ah, depending on the BSP kernel is indeed quite bad. I wonder what > > features of the kernel you rely on that upstream does not have? Or is it > > more about the BMC userland parts that are married to the Allwinner kernel > > and its own interfaces? > > I don't fully know; getting the kernel back on mainline is, as I said, a > push for another day. I'm very much making a point of not looking into > it before the bootloader can be upgraded to something that isn't a > crashy, hard-to-update, failure-prone mess. (I'm working in "biggest > fire, first out" order.) Fair enough, from a mainlining point of view you need to funnel the board .dts through the Linux tree first, though. Also, with the right DT, a mainline kernel would run on the board already, maybe just not with the full functionality you'd expect from it. What I mean to say: you can surely continue using Tina Linux for the BMC functionality on the board right now, but still upstream the board .dts. As mentioned, the DT just describes the hardware, so it doesn't dictate what to do with it. One might abuse the board as a T113s dev board, maybe ;-) Does it work without any of the modules populated? > That said, the first such dependent feature that leaps to mind is the > AWNAND driver's CONFIG_AW_SPINAND_SIMULATE_MULTIPLANE, which logically > interleaves pages of the NAND in a different ordering
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
Hi Andre, On 6/20/23 06:42, Andre Przywara wrote: So yeah, the request of a "Enter FEL" command came up multiple times, but so far no one could be bothered to implement this properly. The idea would be to have a generic command (more like "fel-reset" than efex), and allow each SoC (family) to implement this differently, as every SoC requires something a bit different here (32-bit vs. 64-bit, having an RTC vs not, etc). If you could post your solution somewhere, we could start this effort. There was some patch for the H3 already, and it's relatively straight-forward on the newer SoCs (H616, IIRC), so if at least two popular, but different SoCs would be supported, we could make sure to have the right abstractions in place. I already have a "go_to_fel()" that does the right thing to enter FEL from the SPL; I would pretty much just need to introduce the following per-SoC(-family) functions: - bool sunxi_fel_flag_test(void) - void sunxi_fel_flag_clear(void) - void sunxi_fel_flag_set(void) The "fel-reset" command (which is easier to type than what I have, "run fel_do_enter") would then call sunxi_fel_flag_set() and initiate a reset, and the SPL's early init just has to do sunxi_fel_flag_test() -> sunxi_fel_flag_clear() -> go_to_fel(). Seems easy enough. Could you recommend to me a sufficiently different chip to test my abstractions against? Something ARMv8 and *without* RTC? I can then send in a series adding FEL support for that. (Also, did that H3 patch actually land? I didn't see anything but want to know if I should be refactoring my approach to extend what that H3 patch does or not.) Ah, depending on the BSP kernel is indeed quite bad. I wonder what features of the kernel you rely on that upstream does not have? Or is it more about the BMC userland parts that are married to the Allwinner kernel and its own interfaces? I don't fully know; getting the kernel back on mainline is, as I said, a push for another day. I'm very much making a point of not looking into it before the bootloader can be upgraded to something that isn't a crashy, hard-to-update, failure-prone mess. (I'm working in "biggest fire, first out" order.) That said, the first such dependent feature that leaps to mind is the AWNAND driver's CONFIG_AW_SPINAND_SIMULATE_MULTIPLANE, which logically interleaves pages of the NAND in a different ordering vs. what the physical NAND (and mainline's spi-nand driver) does. Alas this is a feature we're dependent on not because it provides benefits to our users (it does not, and in downstream discussions I've been soapboxing about how it's likely wearing down people's NANDs) but because the boards are flashed at the factory with this flag enabled so we need it set for the NAND to be accessible. We've experimented with reflashing the board with that flag disabled, but that has so far only resulted in corrupted flash. Hope is not lost, though, for I have a half-written tool which shows some promise in being able to "unscramble the egg" and migrate existing NANDs over to the correct layout. That should be sufficient to get mainline U-Boot (and Tina Linux with the flag disabled) working, but I have no idea about mainline Linux still: this would only peel back one layer of the onion, and I don't know whether the next obstacle will be easier, harder, or about the same difficulty. But it does mean that, for now, we're stuck with Tina Linux. Final DT is a noble goal, but in reality there will always be room for improvement and additions. So what we typically do is to start with a simple .dts for the kernel tree, describing the basic peripherals, and everything that already works and is not subject to debate. If in doubt, include a node, and we will comment. Could you prepare such a patch? The peripheral-describing .dts that I have is for Tina Linux, and uses incompatible compatibles (ha), includes, dt-bindings, temporary hacks while better driver support can be developed, and would otherwise not fly upstream. I can send it in *anyway* if for some reason you think that's a good idea, but I really don't see that as being anything other than a waste of time. As well, I can't write a fresh .dts for mainline (one more likely to be accepted on the list). A mainline kernel has never been booted on this board, so I would do no better at this than a kernel contributor selected at random. The best I can do now is write something that *looks* like the correct .dts. As I keep saying, that may change in the future. But the answer today is still "no, I cannot." This should not contradict any DT nodes that U-Boot uses, so it's not a double effort. True, in theory it *shouldn't* but in practice, I've found it does. One way I've been bitten is that the sunxi SPI driver in U-Boot doesn't support Quad-SPI, so if the DT says the SPI-NAND is connected with a bus width of 4, the SPI-NAND driver requests Quad-SPI transfers, but the SPI master driver has no idea
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
On Sun, 18 Jun 2023 13:01:33 -0600 Sam Edwards wrote: Hi Sam, thanks for the reply, that's very helpful. > On 6/14/23 18:07, Andre Przywara wrote: > > So I finally found some time to address some issues in the series, > > especially in the first patches (pinctrl rework and preparation). > > I pushed a branch to https://github.com/apritzel/u-boot/commits/r528-rc > > I need to do more testing, most importantly regression testing on other > > SoCs, and will only be able to post something next week, I guess. > > > > If you could briefly list the things that are still missing, I could > > try to pick some low hanging fruits. > > Rebasing onto this branch ended up eliminating a good chunk of my local > hack commits. I've verified that everything is still working (but have > not yet retested NAND SPL). Great, thanks! > The remaining local changes I have are two additions to cpu_sunxi_ncat2.h: > +#define SUNXI_R_CPUCFG_BASE 0x07000400 /* for PSCI */ > +#define SUNXI_RTC_BASE 0x0709 /* for FEL */ Right, I will definitely take the PSCI bit, but not so sure about FEL yet. > The former can probably be brought into my PSCI series somehow (unless > we expect more chips with CPUX blocks which might move those soft entry > registers around, then it should be defined in cpu_sunxi_*.h). The > latter is to support a reimplementation of Allwinner's `efex` command > that I'm using for development (it pokes the magic number 0x5AA5A55A > into RTC's GP_DATA_REG[2] and then resets; SPL clears that magic number > and then does an early branch to BROM+0x0020 -- exactly what Allwinner's > fork does). So yeah, the request of a "Enter FEL" command came up multiple times, but so far no one could be bothered to implement this properly. The idea would be to have a generic command (more like "fel-reset" than efex), and allow each SoC (family) to implement this differently, as every SoC requires something a bit different here (32-bit vs. 64-bit, having an RTC vs not, etc). If you could post your solution somewhere, we could start this effort. There was some patch for the H3 already, and it's relatively straight-forward on the newer SoCs (H616, IIRC), so if at least two popular, but different SoCs would be supported, we could make sure to have the right abstractions in place. > I've also noticed exactly(!) one formatting difference in our clk_d1.c: > - .num_gates = ARRAY_SIZE(d1_gates), > + .num_gates = ARRAY_SIZE(d1_gates), > > Up to you if you prefer to align the = or not, but it does look > inconsistent when .gates and .resets are aligned and .num_* aren't - > might be a nitpick that comes up in patch review. Well, this is how it is in all the other clock drivers, so I chose to stay consistent with them ;-) > > Interesting, indeed this is left at 0, which I think will result in 288 > > MHz. > > Correct, at least that's what I was seeing. > > > What is that frequency in your case? Do you know what the BSP > > programs? > > 1008 MHz, both. > > > Traditionally we used something conservative that works > > without cooling and with the default voltage, but I don't know that > > value for the T113s. > > For what it's worth, this board has a bare T113-s3 and the current OS > does not reclock from 1008 MHz at all, and I don't know of any users of > the board having stability issues. > > In my own case, it idles at that clock at around ~35°C. OK, many thanks, it looks like 1008 MHz it is, then. > > I think CLK_SUN20I_D1 should be set by default now, so can you check > > that this is fixed? > > It is now gone from my defconfig and still working, so indeed this is fixed. > > > Why would we need H6 PSCI support? On the ARMv8 parts we use Trusted > > Firmware-A (TF-A) to provide PSCI services, which has a much more mature > > implementation. > > It's not about the H6 and more about me being unsure whether R528/T113 > is the first ARMv7-based SoC to use the new CPU management registers. If > it's not, and there's another such chip supported in U-Boot that just > lacks PSCI, it would make more sense for me to land my PSCI series > independently of our work here, and then you can add the R528 case > later. It sounds like R528/T113 may be the first such chip needing this > new code, though, so this may have to wait until the R528 series lands. > > > How would this conflict, exactly? I don't see any other I2C2 > > definition? > > Well, no, the other definitions haven't landed in U-Boot yet. But they > do exist in the kernel, datasheets, and physical chips themselves: > > PB0/PB1/PB8/PB9/PE4/PE5: i2c2 defined as muxval 4 > PC0/PC1/PD20/PD21/PG6/PG7/PG14/PG15: i2c2 defined as muxval 3 > PE12/PE13: i2c2 defined as muxval 2 > > Defining i2c2=2 universally would mean that the pins for i2c2 cannot be > changed, since it would conflict with every other definition. Well, we are well aware that the current pinmux code is limited, but we figured it does
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
Hi Andre, On 6/14/23 18:07, Andre Przywara wrote: So I finally found some time to address some issues in the series, especially in the first patches (pinctrl rework and preparation). I pushed a branch to https://github.com/apritzel/u-boot/commits/r528-rc I need to do more testing, most importantly regression testing on other SoCs, and will only be able to post something next week, I guess. If you could briefly list the things that are still missing, I could try to pick some low hanging fruits. Rebasing onto this branch ended up eliminating a good chunk of my local hack commits. I've verified that everything is still working (but have not yet retested NAND SPL). The remaining local changes I have are two additions to cpu_sunxi_ncat2.h: +#define SUNXI_R_CPUCFG_BASE0x07000400 /* for PSCI */ +#define SUNXI_RTC_BASE 0x0709 /* for FEL */ The former can probably be brought into my PSCI series somehow (unless we expect more chips with CPUX blocks which might move those soft entry registers around, then it should be defined in cpu_sunxi_*.h). The latter is to support a reimplementation of Allwinner's `efex` command that I'm using for development (it pokes the magic number 0x5AA5A55A into RTC's GP_DATA_REG[2] and then resets; SPL clears that magic number and then does an early branch to BROM+0x0020 -- exactly what Allwinner's fork does). I've also noticed exactly(!) one formatting difference in our clk_d1.c: - .num_gates = ARRAY_SIZE(d1_gates), + .num_gates = ARRAY_SIZE(d1_gates), Up to you if you prefer to align the = or not, but it does look inconsistent when .gates and .resets are aligned and .num_* aren't - might be a nitpick that comes up in patch review. Interesting, indeed this is left at 0, which I think will result in 288 MHz. Correct, at least that's what I was seeing. What is that frequency in your case? Do you know what the BSP programs? 1008 MHz, both. Traditionally we used something conservative that works without cooling and with the default voltage, but I don't know that value for the T113s. For what it's worth, this board has a bare T113-s3 and the current OS does not reclock from 1008 MHz at all, and I don't know of any users of the board having stability issues. In my own case, it idles at that clock at around ~35°C. I think CLK_SUN20I_D1 should be set by default now, so can you check that this is fixed? It is now gone from my defconfig and still working, so indeed this is fixed. Why would we need H6 PSCI support? On the ARMv8 parts we use Trusted Firmware-A (TF-A) to provide PSCI services, which has a much more mature implementation. It's not about the H6 and more about me being unsure whether R528/T113 is the first ARMv7-based SoC to use the new CPU management registers. If it's not, and there's another such chip supported in U-Boot that just lacks PSCI, it would make more sense for me to land my PSCI series independently of our work here, and then you can add the R528 case later. It sounds like R528/T113 may be the first such chip needing this new code, though, so this may have to wait until the R528 series lands. How would this conflict, exactly? I don't see any other I2C2 definition? Well, no, the other definitions haven't landed in U-Boot yet. But they do exist in the kernel, datasheets, and physical chips themselves: PB0/PB1/PB8/PB9/PE4/PE5: i2c2 defined as muxval 4 PC0/PC1/PD20/PD21/PG6/PG7/PG14/PG15: i2c2 defined as muxval 3 PE12/PE13: i2c2 defined as muxval 2 Defining i2c2=2 universally would mean that the pins for i2c2 cannot be changed, since it would conflict with every other definition. And what do you need I2C2 for, exactly? Pins PE12/PE13 host an I²C bus with the board ID EEPROM and an Ethernet switch that should be reset (and have a few registers set to configure proper port isolation) very shortly after power-on. Well, there are shortcuts. I sketched some simpler idea in the comment at the top of pinctrl-sunxi.c. My shortcut for the time being will probably be, "downstream patch." At this time I have no interest in upstreaming the DT. Why not? That might change in the future, but for now it's very much meant to be out-of-tree. Why is this? This only increases your update burden, and we might break something and not realise that, if your DT is not in the tree. The question to ask should be rather: why *not* to upstream the DT? Please keep in mind that this would block U-Boot support, since we need the DT approved in the kernel before we could merge it into U-Boot. Currently, downstream is still fairly dependent on the Tina Linux kernel, not mainline. This is a situation I'd like to change, but it's a push for another day -- my focus right now is only on improving the bootloader situation. This means that there are actually two DTs: one for the kernel, using the Tina Linux binding values, and one for U-Boot's control FDT, which can only support
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
Hi Andre, пт, 16 июн. 2023 г. в 19:36, Andre Przywara : [..] > > thanks for the reply! If you have anything that is missing or broken in > the new version of the patchset I put on github, please let me know. I tried the new version and everything looks pretty good for me. Great job! Just one note. Could you please add SUNXI_R_CPUCFG_BASE 0x07000400 to cpu_sunxi_ncat2.h file. This register is required for Sam's PCSI patches. Otherwise it leads to undeclared error: In file included from ./arch/arm/include/asm/armv7.h:60, from arch/arm/cpu/armv7/sunxi/psci.c:16: arch/arm/cpu/armv7/sunxi/psci.c: In function ‘sunxi_cpu_set_entry’: arch/arm/cpu/armv7/sunxi/psci.c:138:24: error: ‘SUNXI_R_CPUCFG_BASE’ undeclared (first use in this function); did you mean ‘SUNXI_CPUCFG_BASE’? 138 |SUNXI_R_CPUCFG_BASE + SUN8I_R528_SOFT_ENTRY); |^~~
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
On Fri, 16 Jun 2023 19:27:16 +0300 Maxim Kiselev wrote: Hi Maxim, thanks for the reply! If you have anything that is missing or broken in the new version of the patchset I put on github, please let me know. > пт, 16 июн. 2023 г. в 18:59, Andre Przywara : > > > > On Mon, 12 Jun 2023 15:18:17 -0600 > > Sam Edwards wrote: > > > > Hi Sam, > > > > something regarding "reset" below ... > > > > > On 6/11/23 18:20, Andre Przywara wrote: > > > > Thanks for the update and the list! Can you confirm where you > > > > still needed code changes compared to say my github branch plus the > > > > changes we already discussed? Trying some guesses below, please confirm > > > > or deny: > > > > > > Pretyyy much everything I've changed locally has been submitted > > > to the list or discussed in the relevant patchset. Have you updated your > > > GitHub branch recently (past couple of weeks)? I haven't been watching > > > it but I can pull it again and see which of my local changes are still > > > required. > > > > > > >> I have a build of U-Boot for my target, complete with: > > > >> - UART3 initialized correctly > > > > > > > > this is problematic because of the other pinmux used on your board, > > > > which cannot easily be encoded alongside the existing UART3 pinmux? > > > > > > Actually no, my board's UART3 is on PB6/PB7, nice and standard. > > > > > > >> - DRAM coming up correctly > > > >> - SPL sets configured boot clock correctly > > > > > > > > This should work as per github? > > > > > > Yep, everything was working satisfactorily once I figured out I needed > > > to set CONFIG_SYS_CLK_FREQ to get acceptable boot speeds. > > > > > > >> - SPI-NAND support (SPL and U-Boot proper) > > > > > > > > This is with Icenow's series? Any D1 specific changes needed there? > > > > > > Yes, with Icenowy's series (322733). > > > > > > I learned that the BROM sets the boot medium code to 0x04 when it's an > > > SPI-*NAND* (while older chips used 0x03 for "it's either SPI-NOR or > > > SPI-NAND, good luck figuring out which"). Since `env_get_location` > > > assumes BOOT_DEVICE_SPI is NOR (and my target needs to load env from UBI > > > iff booting from NAND), I'm hoping I can convince Icenowy to separate > > > out the SPI-NAND and SPI-NOR load methods entirely (vs. her current > > > try-NAND-then-NOR approach) with the aid of some disambiguation logic to > > > probe for an SPI-NAND on the older chips known to report these as 0x03. > > > > > > I also needed Maksim's patch series (355747) to support the D1 SPI master. > > > > > > >> - MMC support (SPL and U-Boot proper) > > > >> - SPL boot from FEL > > > > > > > > again worked already in github? > > > > > > Yes and yes. I was just confirming they're good; no local work needed > > > from me here. > > > > > > >> - USB gadget support > > > > > > > > So with the fixed SUNXI_SRAMC_BASE you said it worked? What about the > > > > USB PHY? That needs at least wiring in the compatible string? If you > > > > have such a patch, can you please rebase it on top of my v2 USB PHY > > > > series and post that? > > > > > > Yes, with corrected SUNXI_SRAMC_BASE -- though I also needed my patches > > > to make musb-new/sunxi.c use the UDC gadget model in DM (series 358842), > > > as I don't think there's another way to init the controller at runtime. > > > > > > I can't say whether the endpoint limit is correct or that mUSB *host* > > > operation works. > > > > > > The USB PHY only required that CONFIG_PHY_SUN4I_USB be enabled. The > > > correct compatible is already wired up. It does look like your PHY > > > series drops the explicit requirement to set PHY_SUN4I_USB so that's > > > better than what I was doing (adding a `select` directive under R528). > > > > > > I can test your series if you want but I doubt it intersects my work > > > here in any significant way. > > > > > > >> - Ethernet MAC+PHY support > > > > > > > > Anything surprising here? Is that using an already supported external > > > > PHY? > > > > > > The only surprise was this was how I noticed that CONFIG_CLK_SUN20I_D1 > > > was not being implicitly enabled. Enabling that was then how I found > > > that the clock driver wasn't compatible with current upstream (which I > > > already mentioned). > > > > > > The PHY is external and already supported, adding it to my DT required > > > very little work. > > > > > > >> - I²C support * > > > >> - GPIO support (LEDs, buttons, misc. board management) > > > > > > > > again should work out of the box, minus your board specific > > > > configuration? > > > > > > GPIO is completely OotB, yes. I²C is OotB once MVTWSI_CONTROL_CLEAR_IFLG > > > is set correctly. (The pinctrl requirements for it are a little harder, > > > more on that below.) > > > > > > >> - `reset` working (requries CONFIG_SYSRESET unset, WDT key) > > > > > > > > Isn't "CONFIG_SYSRESET unset" a hack? I dimly remember we had this for > > > > some other SoC initially, but later
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
Hi Andre, Sam, пт, 16 июн. 2023 г. в 18:59, Andre Przywara : > > On Mon, 12 Jun 2023 15:18:17 -0600 > Sam Edwards wrote: > > Hi Sam, > > something regarding "reset" below ... > > > On 6/11/23 18:20, Andre Przywara wrote: > > > Thanks for the update and the list! Can you confirm where you > > > still needed code changes compared to say my github branch plus the > > > changes we already discussed? Trying some guesses below, please confirm > > > or deny: > > > > Pretyyy much everything I've changed locally has been submitted > > to the list or discussed in the relevant patchset. Have you updated your > > GitHub branch recently (past couple of weeks)? I haven't been watching > > it but I can pull it again and see which of my local changes are still > > required. > > > > >> I have a build of U-Boot for my target, complete with: > > >> - UART3 initialized correctly > > > > > > this is problematic because of the other pinmux used on your board, > > > which cannot easily be encoded alongside the existing UART3 pinmux? > > > > Actually no, my board's UART3 is on PB6/PB7, nice and standard. > > > > >> - DRAM coming up correctly > > >> - SPL sets configured boot clock correctly > > > > > > This should work as per github? > > > > Yep, everything was working satisfactorily once I figured out I needed > > to set CONFIG_SYS_CLK_FREQ to get acceptable boot speeds. > > > > >> - SPI-NAND support (SPL and U-Boot proper) > > > > > > This is with Icenow's series? Any D1 specific changes needed there? > > > > Yes, with Icenowy's series (322733). > > > > I learned that the BROM sets the boot medium code to 0x04 when it's an > > SPI-*NAND* (while older chips used 0x03 for "it's either SPI-NOR or > > SPI-NAND, good luck figuring out which"). Since `env_get_location` > > assumes BOOT_DEVICE_SPI is NOR (and my target needs to load env from UBI > > iff booting from NAND), I'm hoping I can convince Icenowy to separate > > out the SPI-NAND and SPI-NOR load methods entirely (vs. her current > > try-NAND-then-NOR approach) with the aid of some disambiguation logic to > > probe for an SPI-NAND on the older chips known to report these as 0x03. > > > > I also needed Maksim's patch series (355747) to support the D1 SPI master. > > > > >> - MMC support (SPL and U-Boot proper) > > >> - SPL boot from FEL > > > > > > again worked already in github? > > > > Yes and yes. I was just confirming they're good; no local work needed > > from me here. > > > > >> - USB gadget support > > > > > > So with the fixed SUNXI_SRAMC_BASE you said it worked? What about the > > > USB PHY? That needs at least wiring in the compatible string? If you > > > have such a patch, can you please rebase it on top of my v2 USB PHY > > > series and post that? > > > > Yes, with corrected SUNXI_SRAMC_BASE -- though I also needed my patches > > to make musb-new/sunxi.c use the UDC gadget model in DM (series 358842), > > as I don't think there's another way to init the controller at runtime. > > > > I can't say whether the endpoint limit is correct or that mUSB *host* > > operation works. > > > > The USB PHY only required that CONFIG_PHY_SUN4I_USB be enabled. The > > correct compatible is already wired up. It does look like your PHY > > series drops the explicit requirement to set PHY_SUN4I_USB so that's > > better than what I was doing (adding a `select` directive under R528). > > > > I can test your series if you want but I doubt it intersects my work > > here in any significant way. > > > > >> - Ethernet MAC+PHY support > > > > > > Anything surprising here? Is that using an already supported external > > > PHY? > > > > The only surprise was this was how I noticed that CONFIG_CLK_SUN20I_D1 > > was not being implicitly enabled. Enabling that was then how I found > > that the clock driver wasn't compatible with current upstream (which I > > already mentioned). > > > > The PHY is external and already supported, adding it to my DT required > > very little work. > > > > >> - I²C support * > > >> - GPIO support (LEDs, buttons, misc. board management) > > > > > > again should work out of the box, minus your board specific > > > configuration? > > > > GPIO is completely OotB, yes. I²C is OotB once MVTWSI_CONTROL_CLEAR_IFLG > > is set correctly. (The pinctrl requirements for it are a little harder, > > more on that below.) > > > > >> - `reset` working (requries CONFIG_SYSRESET unset, WDT key) > > > > > > Isn't "CONFIG_SYSRESET unset" a hack? I dimly remember we had this for > > > some other SoC initially, but later got rid of it? > > > > Unsetting it is required for reset_cpu() to be defined. Your patchset > > updates that function (albeit without adding the WDT key, so the current > > patch is broken) to support NCAT2 already. U-Boot has no driver for > > "allwinner,sun20i-d1-wdt-reset", so this is the only way for `reset` to > > work. > > So I had a look at this, and it's a bit surprising: > The watchdog driver already supports "allwinner,sun20i-d1-wdt" for a > while. We
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
On Mon, 12 Jun 2023 15:18:17 -0600 Sam Edwards wrote: Hi Sam, something regarding "reset" below ... > On 6/11/23 18:20, Andre Przywara wrote: > > Thanks for the update and the list! Can you confirm where you > > still needed code changes compared to say my github branch plus the > > changes we already discussed? Trying some guesses below, please confirm > > or deny: > > Pretyyy much everything I've changed locally has been submitted > to the list or discussed in the relevant patchset. Have you updated your > GitHub branch recently (past couple of weeks)? I haven't been watching > it but I can pull it again and see which of my local changes are still > required. > > >> I have a build of U-Boot for my target, complete with: > >> - UART3 initialized correctly > > > > this is problematic because of the other pinmux used on your board, > > which cannot easily be encoded alongside the existing UART3 pinmux? > > Actually no, my board's UART3 is on PB6/PB7, nice and standard. > > >> - DRAM coming up correctly > >> - SPL sets configured boot clock correctly > > > > This should work as per github? > > Yep, everything was working satisfactorily once I figured out I needed > to set CONFIG_SYS_CLK_FREQ to get acceptable boot speeds. > > >> - SPI-NAND support (SPL and U-Boot proper) > > > > This is with Icenow's series? Any D1 specific changes needed there? > > Yes, with Icenowy's series (322733). > > I learned that the BROM sets the boot medium code to 0x04 when it's an > SPI-*NAND* (while older chips used 0x03 for "it's either SPI-NOR or > SPI-NAND, good luck figuring out which"). Since `env_get_location` > assumes BOOT_DEVICE_SPI is NOR (and my target needs to load env from UBI > iff booting from NAND), I'm hoping I can convince Icenowy to separate > out the SPI-NAND and SPI-NOR load methods entirely (vs. her current > try-NAND-then-NOR approach) with the aid of some disambiguation logic to > probe for an SPI-NAND on the older chips known to report these as 0x03. > > I also needed Maksim's patch series (355747) to support the D1 SPI master. > > >> - MMC support (SPL and U-Boot proper) > >> - SPL boot from FEL > > > > again worked already in github? > > Yes and yes. I was just confirming they're good; no local work needed > from me here. > > >> - USB gadget support > > > > So with the fixed SUNXI_SRAMC_BASE you said it worked? What about the > > USB PHY? That needs at least wiring in the compatible string? If you > > have such a patch, can you please rebase it on top of my v2 USB PHY > > series and post that? > > Yes, with corrected SUNXI_SRAMC_BASE -- though I also needed my patches > to make musb-new/sunxi.c use the UDC gadget model in DM (series 358842), > as I don't think there's another way to init the controller at runtime. > > I can't say whether the endpoint limit is correct or that mUSB *host* > operation works. > > The USB PHY only required that CONFIG_PHY_SUN4I_USB be enabled. The > correct compatible is already wired up. It does look like your PHY > series drops the explicit requirement to set PHY_SUN4I_USB so that's > better than what I was doing (adding a `select` directive under R528). > > I can test your series if you want but I doubt it intersects my work > here in any significant way. > > >> - Ethernet MAC+PHY support > > > > Anything surprising here? Is that using an already supported external > > PHY? > > The only surprise was this was how I noticed that CONFIG_CLK_SUN20I_D1 > was not being implicitly enabled. Enabling that was then how I found > that the clock driver wasn't compatible with current upstream (which I > already mentioned). > > The PHY is external and already supported, adding it to my DT required > very little work. > > >> - I²C support * > >> - GPIO support (LEDs, buttons, misc. board management) > > > > again should work out of the box, minus your board specific > > configuration? > > GPIO is completely OotB, yes. I²C is OotB once MVTWSI_CONTROL_CLEAR_IFLG > is set correctly. (The pinctrl requirements for it are a little harder, > more on that below.) > > >> - `reset` working (requries CONFIG_SYSRESET unset, WDT key) > > > > Isn't "CONFIG_SYSRESET unset" a hack? I dimly remember we had this for > > some other SoC initially, but later got rid of it? > > Unsetting it is required for reset_cpu() to be defined. Your patchset > updates that function (albeit without adding the WDT key, so the current > patch is broken) to support NCAT2 already. U-Boot has no driver for > "allwinner,sun20i-d1-wdt-reset", so this is the only way for `reset` to > work. So I had a look at this, and it's a bit surprising: The watchdog driver already supports "allwinner,sun20i-d1-wdt" for a while. We don't need to list the "-reset" version, because the normal compatible name acts as a fallback string. However the DT node in the base .dtsi sets: status = "reserved"; for this (and the other) watchdog, so
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
On Mon, 12 Jun 2023 15:18:17 -0600 Sam Edwards wrote: Hi Sam, > On 6/11/23 18:20, Andre Przywara wrote: > > Thanks for the update and the list! Can you confirm where you > > still needed code changes compared to say my github branch plus the > > changes we already discussed? Trying some guesses below, please confirm > > or deny: > > Pretyyy much everything I've changed locally has been submitted > to the list or discussed in the relevant patchset. Have you updated your > GitHub branch recently (past couple of weeks)? I haven't been watching > it but I can pull it again and see which of my local changes are still > required. So I finally found some time to address some issues in the series, especially in the first patches (pinctrl rework and preparation). I pushed a branch to https://github.com/apritzel/u-boot/commits/r528-rc I need to do more testing, most importantly regression testing on other SoCs, and will only be able to post something next week, I guess. If you could briefly list the things that are still missing, I could try to pick some low hanging fruits. > >> I have a build of U-Boot for my target, complete with: > >> - UART3 initialized correctly > > > > this is problematic because of the other pinmux used on your board, > > which cannot easily be encoded alongside the existing UART3 pinmux? > > Actually no, my board's UART3 is on PB6/PB7, nice and standard. > > >> - DRAM coming up correctly > >> - SPL sets configured boot clock correctly > > > > This should work as per github? > > Yep, everything was working satisfactorily once I figured out I needed > to set CONFIG_SYS_CLK_FREQ to get acceptable boot speeds. Interesting, indeed this is left at 0, which I think will result in 288 MHz. What is that frequency in your case? Do you know what the BSP programs? Traditionally we used something conservative that works without cooling and with the default voltage, but I don't know that value for the T113s. > >> - SPI-NAND support (SPL and U-Boot proper) > > > > This is with Icenow's series? Any D1 specific changes needed there? > > Yes, with Icenowy's series (322733). > > I learned that the BROM sets the boot medium code to 0x04 when it's an > SPI-*NAND* (while older chips used 0x03 for "it's either SPI-NOR or > SPI-NAND, good luck figuring out which"). Since `env_get_location` > assumes BOOT_DEVICE_SPI is NOR (and my target needs to load env from UBI > iff booting from NAND), I'm hoping I can convince Icenowy to separate > out the SPI-NAND and SPI-NOR load methods entirely (vs. her current > try-NAND-then-NOR approach) with the aid of some disambiguation logic to > probe for an SPI-NAND on the older chips known to report these as 0x03. > > I also needed Maksim's patch series (355747) to support the D1 SPI master. > > >> - MMC support (SPL and U-Boot proper) > >> - SPL boot from FEL > > > > again worked already in github? > > Yes and yes. I was just confirming they're good; no local work needed > from me here. > > >> - USB gadget support > > > > So with the fixed SUNXI_SRAMC_BASE you said it worked? What about the > > USB PHY? That needs at least wiring in the compatible string? If you > > have such a patch, can you please rebase it on top of my v2 USB PHY > > series and post that? > > Yes, with corrected SUNXI_SRAMC_BASE -- though I also needed my patches > to make musb-new/sunxi.c use the UDC gadget model in DM (series 358842), > as I don't think there's another way to init the controller at runtime. > > I can't say whether the endpoint limit is correct or that mUSB *host* > operation works. > > The USB PHY only required that CONFIG_PHY_SUN4I_USB be enabled. The > correct compatible is already wired up. It does look like your PHY > series drops the explicit requirement to set PHY_SUN4I_USB so that's > better than what I was doing (adding a `select` directive under R528). Ah, right, we already merged the "allwinner,sun20i-d1-usb-phy" patch. > I can test your series if you want but I doubt it intersects my work > here in any significant way. > > >> - Ethernet MAC+PHY support > > > > Anything surprising here? Is that using an already supported external > > PHY? > > The only surprise was this was how I noticed that CONFIG_CLK_SUN20I_D1 > was not being implicitly enabled. Enabling that was then how I found > that the clock driver wasn't compatible with current upstream (which I > already mentioned). I think CLK_SUN20I_D1 should be set by default now, so can you check that this is fixed? > The PHY is external and already supported, adding it to my DT required > very little work. > > >> - I²C support * > >> - GPIO support (LEDs, buttons, misc. board management) > > > > again should work out of the box, minus your board specific > > configuration? > > GPIO is completely OotB, yes. I²C is OotB once MVTWSI_CONTROL_CLEAR_IFLG > is set correctly. (The pinctrl requirements for it are a little harder, > more on that
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
Hey Andre, On 6/11/23 18:20, Andre Przywara wrote: Thanks for the update and the list! Can you confirm where you still needed code changes compared to say my github branch plus the changes we already discussed? Trying some guesses below, please confirm or deny: Pretyyy much everything I've changed locally has been submitted to the list or discussed in the relevant patchset. Have you updated your GitHub branch recently (past couple of weeks)? I haven't been watching it but I can pull it again and see which of my local changes are still required. I have a build of U-Boot for my target, complete with: - UART3 initialized correctly this is problematic because of the other pinmux used on your board, which cannot easily be encoded alongside the existing UART3 pinmux? Actually no, my board's UART3 is on PB6/PB7, nice and standard. - DRAM coming up correctly - SPL sets configured boot clock correctly This should work as per github? Yep, everything was working satisfactorily once I figured out I needed to set CONFIG_SYS_CLK_FREQ to get acceptable boot speeds. - SPI-NAND support (SPL and U-Boot proper) This is with Icenow's series? Any D1 specific changes needed there? Yes, with Icenowy's series (322733). I learned that the BROM sets the boot medium code to 0x04 when it's an SPI-*NAND* (while older chips used 0x03 for "it's either SPI-NOR or SPI-NAND, good luck figuring out which"). Since `env_get_location` assumes BOOT_DEVICE_SPI is NOR (and my target needs to load env from UBI iff booting from NAND), I'm hoping I can convince Icenowy to separate out the SPI-NAND and SPI-NOR load methods entirely (vs. her current try-NAND-then-NOR approach) with the aid of some disambiguation logic to probe for an SPI-NAND on the older chips known to report these as 0x03. I also needed Maksim's patch series (355747) to support the D1 SPI master. - MMC support (SPL and U-Boot proper) - SPL boot from FEL again worked already in github? Yes and yes. I was just confirming they're good; no local work needed from me here. - USB gadget support So with the fixed SUNXI_SRAMC_BASE you said it worked? What about the USB PHY? That needs at least wiring in the compatible string? If you have such a patch, can you please rebase it on top of my v2 USB PHY series and post that? Yes, with corrected SUNXI_SRAMC_BASE -- though I also needed my patches to make musb-new/sunxi.c use the UDC gadget model in DM (series 358842), as I don't think there's another way to init the controller at runtime. I can't say whether the endpoint limit is correct or that mUSB *host* operation works. The USB PHY only required that CONFIG_PHY_SUN4I_USB be enabled. The correct compatible is already wired up. It does look like your PHY series drops the explicit requirement to set PHY_SUN4I_USB so that's better than what I was doing (adding a `select` directive under R528). I can test your series if you want but I doubt it intersects my work here in any significant way. - Ethernet MAC+PHY support Anything surprising here? Is that using an already supported external PHY? The only surprise was this was how I noticed that CONFIG_CLK_SUN20I_D1 was not being implicitly enabled. Enabling that was then how I found that the clock driver wasn't compatible with current upstream (which I already mentioned). The PHY is external and already supported, adding it to my DT required very little work. - I²C support * - GPIO support (LEDs, buttons, misc. board management) again should work out of the box, minus your board specific configuration? GPIO is completely OotB, yes. I²C is OotB once MVTWSI_CONTROL_CLEAR_IFLG is set correctly. (The pinctrl requirements for it are a little harder, more on that below.) - `reset` working (requries CONFIG_SYSRESET unset, WDT key) Isn't "CONFIG_SYSRESET unset" a hack? I dimly remember we had this for some other SoC initially, but later got rid of it? Unsetting it is required for reset_cpu() to be defined. Your patchset updates that function (albeit without adding the WDT key, so the current patch is broken) to support NCAT2 already. U-Boot has no driver for "allwinner,sun20i-d1-wdt-reset", so this is the only way for `reset` to work. For the WDT key: it seems like Linux got a nice patch to integrate this neatly into the driver without quirking this too much, do you have something ready for U-Boot as well? Would love to see it on the list then ;-) I just hacked the correct value into the function; nothing really suitable for the list, sorry. - PSCI, nonsec ah yeah, owe you some reviews on this one ... It occurs to me that my work *might* support H6 as well (they both use CPUX blocks, right?) so perhaps it would be better if I de-RFC'd my series and instead worked to upstream it chasing H6, for you to come along later and tack on NCAT2 support with your R528 patchset? - Able to boot Linux ;) * Requires nonzero
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
On Fri, 9 Jun 2023 16:16:43 -0600 Sam Edwards wrote: Hi Sam, > On 12/5/22 17:45, Andre Przywara wrote: > > Please let me know if you have any opinions! > > I believe I promised you last month I'd let you know once I had a build > I'm happy with, and I'm pleased to say that I think I've reached that > point. I'm running quite rapidly out of sharp edges to sand down, too. Thanks for the update and the list! Can you confirm where you still needed code changes compared to say my github branch plus the changes we already discussed? Trying some guesses below, please confirm or deny: > I have a build of U-Boot for my target, complete with: > - UART3 initialized correctly this is problematic because of the other pinmux used on your board, which cannot easily be encoded alongside the existing UART3 pinmux? > - DRAM coming up correctly > - SPL sets configured boot clock correctly This should work as per github? > - SPI-NAND support (SPL and U-Boot proper) This is with Icenow's series? Any D1 specific changes needed there? > - MMC support (SPL and U-Boot proper) > - SPL boot from FEL again worked already in github? > - USB gadget support So with the fixed SUNXI_SRAMC_BASE you said it worked? What about the USB PHY? That needs at least wiring in the compatible string? If you have such a patch, can you please rebase it on top of my v2 USB PHY series and post that? > - Ethernet MAC+PHY support Anything surprising here? Is that using an already supported external PHY? > - I²C support * > - GPIO support (LEDs, buttons, misc. board management) again should work out of the box, minus your board specific configuration? > - `reset` working (requries CONFIG_SYSRESET unset, WDT key) Isn't "CONFIG_SYSRESET unset" a hack? I dimly remember we had this for some other SoC initially, but later got rid of it? For the WDT key: it seems like Linux got a nice patch to integrate this neatly into the driver without quirking this too much, do you have something ready for U-Boot as well? Would love to see it on the list then ;-) > - PSCI, nonsec ah yeah, owe you some reviews on this one ... > - Able to boot Linux ;) > > * Requires nonzero `MVTWSI_CONTROL_CLEAR_IFLG` for NCAT2, and a patch to > the pinctrl driver to configure the proper mux function for my necessary > pins. Are those pinmuxes straight forward to add to the pinctrl driver? Or are there conflicts similar to UART3? > I figured I'd share this list as a sort of checklist for your own work, > too. The remainder of my efforts now will probably be focused on > mainlining this stuff (let me know how else I can be of help), and then > I'm afraid I'll have to disappear back downstream to the Turing Pi 2 > development effort, but maybe our paths will cross again in the kernel > lists. :) Yeah, as you may know, the DT has to go through the kernel list. DT patches can be tedious to upstream, there is now much attention to every detail. Running checkpatch and dtbs_check should reveal most issues beforehand, though. Cheers, Andre > > Thank you greatly, > Sam > > P.S. I figure the reason there aren't I²C function defs in the d1 > pinctrl table already is because Allwinner tends to kick around the I²C > mux values a lot and we would need a per-pin lookup table that would eat > up too much valuable image space? > > In an entirely JUST FOR FUN exercise to give myself a break from staring > at datasheets/patches and do a "pure CS" coding challenge for a change, > I came up with a terse encoding scheme for this table. Here is the size > (in bits) for a selection of D1's functions (pin assignments harvested > from Linux): > > 'emac': 50, > 'i2c0': 101, > 'i2c1': 64, > 'i2c2': 109, > 'i2c3': 91, > 'mmc0': 23, > 'mmc1': 23, > 'mmc2': 20, > 'spi0': 41, > 'spi1': 48, > 'uart0': 78, > 'uart1': 87, > 'uart2': 88, > 'uart3': 102, > 'uart4': 68, > 'uart5': 66, > > ...and yes, it also identifies invalid pin assignments! I'd be willing > to contribute something like this if there's big interest, but I figure > needing to compress this at build-time might be a bit too complicated > for the U-Boot project's liking.
Re: [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
Hi Andre, On 12/5/22 17:45, Andre Przywara wrote: Please let me know if you have any opinions! I believe I promised you last month I'd let you know once I had a build I'm happy with, and I'm pleased to say that I think I've reached that point. I'm running quite rapidly out of sharp edges to sand down, too. I have a build of U-Boot for my target, complete with: - UART3 initialized correctly - DRAM coming up correctly - SPL sets configured boot clock correctly - SPI-NAND support (SPL and U-Boot proper) - MMC support (SPL and U-Boot proper) - SPL boot from FEL - USB gadget support - Ethernet MAC+PHY support - I²C support * - GPIO support (LEDs, buttons, misc. board management) - `reset` working (requries CONFIG_SYSRESET unset, WDT key) - PSCI, nonsec - Able to boot Linux ;) * Requires nonzero `MVTWSI_CONTROL_CLEAR_IFLG` for NCAT2, and a patch to the pinctrl driver to configure the proper mux function for my necessary pins. I figured I'd share this list as a sort of checklist for your own work, too. The remainder of my efforts now will probably be focused on mainlining this stuff (let me know how else I can be of help), and then I'm afraid I'll have to disappear back downstream to the Turing Pi 2 development effort, but maybe our paths will cross again in the kernel lists. :) Thank you greatly, Sam P.S. I figure the reason there aren't I²C function defs in the d1 pinctrl table already is because Allwinner tends to kick around the I²C mux values a lot and we would need a per-pin lookup table that would eat up too much valuable image space? In an entirely JUST FOR FUN exercise to give myself a break from staring at datasheets/patches and do a "pure CS" coding challenge for a change, I came up with a terse encoding scheme for this table. Here is the size (in bits) for a selection of D1's functions (pin assignments harvested from Linux): 'emac': 50, 'i2c0': 101, 'i2c1': 64, 'i2c2': 109, 'i2c3': 91, 'mmc0': 23, 'mmc1': 23, 'mmc2': 20, 'spi0': 41, 'spi1': 48, 'uart0': 78, 'uart1': 87, 'uart2': 88, 'uart3': 102, 'uart4': 68, 'uart5': 66, ...and yes, it also identifies invalid pin assignments! I'd be willing to contribute something like this if there's big interest, but I figure needing to compress this at build-time might be a bit too complicated for the U-Boot project's liking.
[RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support
Hi, this is some early attempt at supporting the new SoC series that covers the Allwinner D1 siblings R528 and T113s. They all share the same die, although the D1 and D1s use RISC-V cores, which requires more plumbing, to use the sunxi code across two architectures. Getting the R528 support in should help a bit in sorting out what's new peripheral code and what is architecture dependent. IIUC, Samuel has that running, although with some hacks, the number of which this series tries to reduce. The most interesting part of this is the pincontroller rework, this tackles two issues: - For the first time in the history of mainline Allwinner support the pincontroller changed the register layout. The code here tries to abstract the differences away, so both variants can share the code peacefully. - For the above mentioned reason, the pincontroller code is quite old, and is mostly spread out across arch/arm, in a pre-DM style, even though we have real DM support in U-Boot proper. We need the non-DM version for the (ARM-only?) legacy SPL, so can't get rid of that completely. This series also tries to modernise that code, and moves it into board/sunxi/, where it can be more easily shared with RISC-V. The preliminary MangoPi MQ-R bits on top are mostly for illustration purposes, and in case someone wants to give it a try. For some probably stupid reason MMC doesn't work, although the driver loads fine. Also this omits the DRAM code, although there is some GPLed code out there, which can be lifted into here, with some extra work. I would mostly appreciate to have some opinion on the pinctrl patches: I understand that patch 03/17 isn't strictly necessary, but I always disliked U-Boot's "use C structs to model MMIO register frames" approach, so thought now is the time to get rid of that ;-) Also I am unsure about patch 06/17, which seems like a step back (spreading per-SoC data over several files), but I actually aim at getting rid of cpu_sun[x]i.h altogether, since we should not really need it, except for some exceptions. The third patch I would like to hear feedback about is patch 08/17. Finally patch 14/17 would deserve some extra pair of eyes. Please let me know if you have any opinions! Cheers, Andre P.S. I understand there is some code to support those SoCs out there, apologies if I just re-implemented some of it. Please point me to patches that seem upstream-worthy, and I will happily integrate them in here, potentially replacing some of my patches. Andre Przywara (15): sunxi: remove CONFIG_SATAPWR sunxi: remove CONFIG_MACPWR pinctrl: sunxi: remove struct sunxi_gpio pinctrl: sunxi: add GPIO in/out wrappers pinctrl: sunxi: move pinctrl code and remove GPIO_EXTRA_HEADER pinctrl: sunxi: move PIO_BASE into sunxi_gpio.h pinctrl: sunxi: add new D1 pinctrl support sunxi: introduce NCAT2 generation model pinctrl: sunxi: add Allwinner D1 pinctrl description sunxi: clock: D1/R528: Enable PLL LDO during PLL1 setup sunxi: clock: support D1/R528 PLL6 clock sunxi: add early Allwinner R528/T113 SoC support sunxi: refactor serial base addresses to avoid asm/arch/cpu.h arm: sunxi: add Allwinner T113s devicetree stub sunxi: add preliminary MangoPi MQ-R board support Samuel Holland (2): clk: sunxi: Add support for the D1 CCU riscv: dts: allwinner: Add the D1/D1s SoC devicetree arch/arm/Kconfig | 3 +- arch/arm/cpu/armv7/sunxi/sram.c | 1 + arch/arm/cpu/armv8/fel_utils.S| 1 + arch/arm/dts/Makefile | 2 + arch/arm/dts/sun8i-t113s-mangopi-mq-r.dts | 54 ++ arch/arm/dts/sun8i-t113s.dtsi | 59 ++ arch/arm/include/asm/arch-sunxi/clock.h | 3 +- .../include/asm/arch-sunxi/clock_sun50i_h6.h | 8 + arch/arm/include/asm/arch-sunxi/cpu.h | 2 + arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 17 - .../include/asm/arch-sunxi/cpu_sun50i_h6.h| 7 - arch/arm/include/asm/arch-sunxi/cpu_sun9i.h | 9 - .../include/asm/arch-sunxi/cpu_sunxi_ncat2.h | 49 + arch/arm/include/asm/arch-sunxi/mmc.h | 2 +- arch/arm/include/asm/arch-sunxi/prcm.h| 2 +- arch/arm/include/asm/arch-sunxi/serial.h | 32 + arch/arm/include/asm/arch-sunxi/timer.h | 2 +- arch/arm/mach-sunxi/Kconfig | 51 +- arch/arm/mach-sunxi/Makefile | 2 +- arch/arm/mach-sunxi/board.c | 9 +- arch/arm/mach-sunxi/clock_sun50i_h6.c | 38 +- arch/arm/mach-sunxi/cpu_info.c| 2 + arch/arm/mach-sunxi/dram_suniv.c | 2 +- arch/arm/mach-sunxi/gtbus_sun9i.c | 1 + arch/arm/mach-sunxi/pinmux.c | 78 -- arch/arm/mach-sunxi/spl_spi_sunxi.c | 1 + arch/arm/mach-sunxi/timer.c | 1 + arch/riscv/dts/sun20i-d1.dtsi | 66 ++ arch/riscv/dts/sun20i-d1s.dtsi| 76 ++