21212 Commits

Author SHA1 Message Date
Samuel Holland
09e4ce4e25 sunxi: Add a U-Boot port for the Allwinner D1 Nezha
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-26 22:25:59 -05:00
Samuel Holland
69101a16e8 sunxi: Convert some Kconfig defaults to implies
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Samuel Holland
aaa79d79c3 usb: musb-new: Hack up the driver for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Samuel Holland
38cf2637b2 [BROKEN] spi: sunxi: Add support for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Samuel Holland
9adaadd1a1 spi: sunxi: Hack up the driver for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Samuel Holland
ec769db776 pinctrl: sunxi: Hack up the driver for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Samuel Holland
aa27bb201b pinctrl: sunxi: Add support for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Samuel Holland
60dd27bcc8 phy: sun4i-usb: Add support for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Samuel Holland
a81373a77d phy: sun4i-usb: Hack up the driver for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Andre Przywara
15f52babc9 phy: sun4i-usb: Rework HCI PHY (aka. "pmu_unk1") handling
As Icenowy pointed out, newer manuals (starting with H6) actually
document the register block at offset 0x800 as "HCI controller and PHY
interface", also describe the bits in our "PMU_UNK1" register.
Let's put proper names to those "unknown" variables and symbols.

While we are at it, generalise the existing code by allowing a bitmap
of bits to clear and set, to cover newer SoCs: The A100 and H616 use a
different bit for the SIDDQ control.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:04 -05:00
Samuel Holland
d8d52c48b9 net: sun8i-emac: Downgrade printf in probe to debug
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:04:03 -05:00
Samuel Holland
06522d448e net: sun8i_emac: Hack up the driver for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:01:54 -05:00
Samuel Holland
98333eb77f mmc: sunxi: Hack up the driver for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:01:54 -05:00
Samuel Holland
ae77de6048 gpio: sunxi: Hack up the driver for the D1
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 23:01:53 -05:00
Samuel Holland
e608887e69 Merge branch 'patch/axp-gpio' into allwinner 2022-05-25 22:52:19 -05:00
Samuel Holland
28ab59492e Merge branch 'patch/axp-vbus' into allwinner 2022-05-25 22:52:17 -05:00
Samuel Holland
83456cc1ad Merge branch 'patch/clk-support' into allwinner 2022-05-25 22:52:13 -05:00
Samuel Holland
535d476ed8 Merge branch 'patch/gpio-spl-fix' into allwinner 2022-05-25 22:52:08 -05:00
Samuel Holland
d0e956e3ce Merge branch 'patch/h3-scp' into allwinner 2022-05-25 22:52:04 -05:00
Samuel Holland
d5173c07ea Merge branch 'patch/musb-charging' into allwinner 2022-05-25 22:51:58 -05:00
Samuel Holland
39f25027cc mtd: nand: sunxi: Pass the device to the init function
This more closely matches the driver to the Linux version.

Series-to: sunxi

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:46:15 -05:00
Samuel Holland
2d99cb9a6a mtd: nand: sunxi: Convert to the driver model
Clocks, resets, and pinmuxes are now handled by the driver model, so the
only thing the "board" code needs to do is load the driver. This matches
the pattern used by other DM raw NAND drivers (there is no NAND uclass).

The actual board code is now only needed in SPL.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:41:39 -05:00
Samuel Holland
a8395a0415 mtd: nand: sunxi: Convert from fdtdec to ofnode
As a first step toward converting this driver to the driver model, use
the ofnode abstraction to replace direct references to the FDT blob.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:41:07 -05:00
Samuel Holland
8c48e40c20 mtd: nand: sunxi: Remove an unnecessary check
Each chip is required to have a unique CS number ("reg" property) in the
range 0-7, so there is no need to separately count the number of chips.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:41:02 -05:00
Samuel Holland
0acff93abb pinctrl: sunxi: Add NAND pinmuxes
NAND is always at function 2 on port C.

Pin lists and mux values were taken from the Linux drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:40:24 -05:00
Samuel Holland
6d76a27ced clk: sunxi: Add NAND clocks and resets
Currently NAND clock setup is done in board code, both in SPL and in
U-Boot proper. Add the NAND clocks/resets here so they can be used by
the "full" NAND driver once it is converted to the driver model.

The bit locations are copied from the Linux CCU drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:40:13 -05:00
Samuel Holland
794bc95ccf gpio: axp: Add pull-down support for AXP22x/AXP8xx variant
The AXP221 and newer PMICs support a pull-down function on their GPIOs.
Add support for it.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:36:04 -05:00
Samuel Holland
02392f7482 gpio: axp: Add support for getting the pin function
Implement the .get_function operation, so the gpio command can report
the current function. Since the GPIOF_FUNC (versus GPIOF_UNUSED) mux
values vary among the PMICs, report all non-GPIO mux values as UNKNOWN.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:36:04 -05:00
Samuel Holland
f8b1d4fcb6 gpio: axp: Select variant from compatible at runtime
There are three major variants of the AXP PMIC GPIO functionality (plus
PMICs with no GPIOs at all). Except for GPIO3 on the AXP209, which uses
a different register layout, it is straightforward to support all three
variants with a single driver. Do this, and in the process remove the
GPIO-related definitions from the PMIC-specific headers, and therefore
the dependency on AXP_PMIC_BUS.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:36:04 -05:00
Samuel Holland
05552f2ef0 gpio: axp: Use DM_PMIC functions for register access
Now that the PMIC driver implements the DM_PMIC uclass, those functions
can be used instead of the platform-specific "pmic_bus" functions.

Since the driver still uses the single set of register definitions from
axpXXX.h (as selected by AXPxxx_POWER), it still depends on one of those
choices, and therefore also AXP_PMIC_BUS.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:36:04 -05:00
Samuel Holland
6e46bf87dd gpio: axp: Bind via device tree
Now that the PMIC has a DM driver and binds device tree subnodes, the
GPIO device can be bound that way, instead of from inside board code.

Since the driver still uses the single set of register definitions from
axpXXX.h (as selected by AXPxxx_POWER), it does not differentiate among
the supported compatibles.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:36:04 -05:00
Samuel Holland
b1f8206841 gpio: axp: Consistently use the "axp_gpio" order
This is less confusing than half of the driver using "axp_gpio" and the
other half using "gpio_axp".

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:36:04 -05:00
Samuel Holland
ed83b33ef1 phy: sun4i-usb: Use DM_GPIO for id/vbus_det GPIOs
Now that the sunxi_gpio driver handles pull-up/down via the driver
model, we can switch to DM_GPIO for these pins with no loss in
functionality. Since the driver now gets its pin configuration from
the device tree, we can remove the Kconfig symbols.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:55 -05:00
Samuel Holland
94bfb90b25 gpio: axp/sunxi: Remove virtual VBUS enable GPIO
Now that this functionality is modeled using the device tree and
regulator uclass, the named GPIO is not referenced anywhere. Remove
it, along with the rest of the support for AXP virtual GPIOs.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:55 -05:00
Samuel Holland
ef89a1f535 phy: sun4i-usb: Control USB supplies via regulator uclass
The device tree binding for the PHY provides VBUS supplies as regulator
references. Now that all boards have the appropriate regulator uclass
drivers enabled, the PHY driver can switch to using them. This replaces
direct GPIO usage, which in some cases needed a special DM-incompatible
"virtual" GPIO from the PMIC.

The following boards provided a value for CONFIG_USB0_VBUS_PIN, but are
missing the "usb0_vbus-supply" property in their device tree. None of
them have the MUSB controller enabled in host or OTG mode, so they
should see no impact:
 - Ainol_AW1_defconfig / sun7i-a20-ainol-aw1
 - Ampe_A76_defconfig / sun5i-a13-ampe-a76
 - CHIP_pro_defconfig / sun5i-gr8-chip-pro
 - Cubieboard4_defconfig / sun9i-a80-cubieboard4
 - Merrii_A80_Optimus_defconfig / sun9i-a80-optimus
 - Sunchip_CX-A99_defconfig / sun9i-a80-cx-a99
 - Yones_Toptech_BD1078_defconfig / sun7i-a20-yones-toptech-bd1078
 - Yones_Toptech_BS1078_V2_defconfig /
   sun6i-a31s-yones-toptech-bs1078-v2
 - iNet_3F_defconfig / sun4i-a10-inet-3f
 - iNet_3W_defconfig / sun4i-a10-inet-3w
 - iNet_86VS_defconfig / sun5i-a13-inet-86vs
 - iNet_D978_rev2_defconfig / sun8i-a33-inet-d978-rev2
 - icnova-a20-swac_defconfig / sun7i-a20-icnova-swac
 - sun8i_a23_evb_defconfig / sun8i-a23-evb

Similarly, the following boards set CONFIG_USB1_VBUS_PIN, but do not
have "usb1_vbus-supply" in their device tree. Neither of them have USB
enabled at all, so again there should be no impact:
 - Cubieboard4_defconfig / sun9i-a80-cubieboard4 (also for USB3)
 - sun8i_a23_evb_defconfig / sun8i-a23-evb

The following boards use a different pin for USB1 VBUS between their
defconfig and their device tree. Depending on which is correct, they
may be broken:
 - Linksprite_pcDuino3_Nano_defconfig (PH11) /
   sun7i-a20-pcduino3-nano (PD2)
 - icnova-a20-swac_defconfig (PG10) / sun7i-a20-icnova-swac (PH6)

Finally, this board has conflicting pins given for its USB2 VBUS:
 - Lamobo_R1_defconfig (PH3) / sun7i-a20-lamobo-r1 (PH12)

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:54 -05:00
Samuel Holland
51f91585f0 power: pmic: axp: Probe the drivevbus regulator from the DT
Now that some regulator driver exists for this PMIC, add support for
probing regulator drivers from the device tree subnodes.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:54 -05:00
Samuel Holland
e531bb3dd8 power: regulator: Add a driver for the AXP PMIC drivevbus
The first AXP regulator converted to use the regulator uclass is the
drivevbus switch, since it is used by the USB PHY driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:54 -05:00
Samuel Holland
deb33625c7 gpio: axp/sunxi: Remove virtual VBUS detection GPIO
Now that this functionality is modeled using the device tree and
regulator uclass, the named GPIO is not referenced anywhere. Remove it.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:54 -05:00
Samuel Holland
4f66b1241b power: regulator: Add a driver for the AXP USB power supply
This driver reports the presence/absence of voltage on the PMIC's USB
VBUS pin. This information is used by the USB PHY driver. The
corresponding Linux driver uses the power supply class, which does not
exist in U-Boot. UCLASS_REGULATOR seems to be the closest match.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:54 -05:00
Samuel Holland
ba31fc9dd7 clk: sunxi: Add a driver for the legacy A31/A23/A33 PRCM
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:28 -05:00
Samuel Holland
9e6e63010e clk: sunxi: Add support for the D1 CCU
Since the D1 CCU binding is defined, we can add support for its
gates/resets, following the pattern of the existing drivers.

Series-to: sunxi

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:28 -05:00
Samuel Holland
44711b6485 clk: sunxi: Add additional RTC compatible strings
Compatible strings for some new RTC hardware variants were added to
the binding. Add them to the driver in preparation for supporting
those new SoCs.

Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:35:28 -05:00
Samuel Holland
d4a4d63a0b reset: sunxi: Reuse the platform data from the clock driver
The clock and reset drivers use the exact same platform data. Simplify
them by sharing the object. This is safe because the parent device
(the clock device) always gets its driver model callbacks run first.

Series-to: sunxi
Series-cc: Lukasz Majewski <lukma@denx.de>
Series-cc: Sean Anderson <seanga2@gmail.com>

Series-version: 2

Cover-letter:
clk: sunxi: Out-of-bounds access fix and driver cleanup
This series fixes an issue with out-of-bounds access to the gate array
(patches 1-2), uses the rearranged array size information to remove a
bunch of duplicate code (patches 3-4), and then simplifies how the reset
driver is bound (patches 5-7).

The original motivation for these changes was adding a driver for the
legacy A31/A23/A33 PRCM binding (which I will send separately), and
trying to use OF_PLATDATA in SPL (which did not work out). But I think
at least some of the cleanup is worth applying on its own.

Patch 4 is generally the same change I made between v1 and v2 of the
pinctrl series, using some #ifdefs to share a U_BOOT_DRIVER. It's not
quite as clean as the pinctrl case, because here the SoC-specific parts
are in different files, so all of the CCU descriptors have to be global.
END

Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:34:46 -05:00
Samuel Holland
7c576b083b reset: sunxi: Convert driver private data to platform data
The reason here is the same as the reason for changing the clock driver:
platform data can be provided when binding the driver.

Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:34:44 -05:00
Samuel Holland
5d7ee0828e clk: sunxi: Convert driver private data to platform data
All of the driver private data should really be platform data since it
is determined statically (selected by the compatible string or extracted
from the devicetree). Move everything to platform data, so it can be
provided when binding the driver. This is useful for SPL, or for
instantiating the driver as part of an MFD.

Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:34:43 -05:00
Samuel Holland
bec089a890 clk: sunxi: Use a single driver for all variants
Now that all of the variants use the same bind/probe functions and ops,
there is no need to have a separate driver for each variant. Since most
SoCs contain two variants (the main CCU and PRCM CCU), this saves a bit
of firmware size and RAM.

Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:34:41 -05:00
Samuel Holland
4849e7e3be reset: sunxi: Get the reset count from the CCU descriptor
This allows all of the clock drivers to use a common bind function.

Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:34:38 -05:00
Samuel Holland
c85ab45a95 clk: sunxi: Prevent out-of-bounds gate array access
Because the gate arrays are not given explicit sizes, the arrays are
only as large as the highest-numbered gate described in the driver.
However, only a subset of the CCU clocks are needed by U-Boot. So there
are valid clock specifiers with indexes greater than the size of the
arrays. Referencing any of these clocks causes out-of-bounds access.
Fix this by checking the identifier against the size of the array.

Series-changes: 2
 - Rebased on top of the dummy flag addition

Fixes: 0d47bc705651 ("clk: Add Allwinner A64 CLK driver")
Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:34:11 -05:00
Samuel Holland
a56b87a0b6 clk: sunxi: Store the array sizes in the CCU descriptor
The reset array size is currently used for bounds checking in the reset
driver. The same bounds check should really be done in the clock driver.

Currently, the array size is provided to the reset driver separately
from the CCU descriptor, which is a bit strange. Let's do this the usual
way, with the array sizes next to the arrays themselves.

Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:34:07 -05:00
Samuel Holland
21a63610cc remoteproc: Add a driver for the Allwinner AR100
Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-05-25 22:28:30 -05:00