On 7/26/23 17:47, Andre Przywara wrote:
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b3115b054c8..422cc01e529 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1158,6 +1158,8 @@ config ARCH_SUNXI
        imply CMD_GPT
        imply CMD_UBI if MTD_RAW_NAND
        imply DISTRO_DEFAULTS
+       imply DM_REGULATOR
+       imply DM_REGULATOR_FIXED
        imply FAT_WRITE
        imply FIT
        imply OF_LIBFDT_OVERLAY
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index e20c3a3ee92..a7c5ae80a1e 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -1008,14 +1008,6 @@ config VIDEO_LCD_TL059WV5C0
endchoice -config SATAPWR
-       string "SATA power pin"
-       default ""
-       help
-         Set the pins used to power the SATA. This takes a string in the
-         format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of
-         port H.
-
  config GMAC_TX_DELAY
        int "GMAC Transmit Clock Delay Chain"
        default 0
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index f321cd58a6e..7ac50c4ae8c 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -187,7 +187,7 @@ enum env_location env_get_location(enum env_operation op, 
int prio)
  /* add board specific code here */
  int board_init(void)
  {
-       __maybe_unused int id_pfr1, ret, satapwr_pin, macpwr_pin;
+       __maybe_unused int id_pfr1, ret, macpwr_pin;
gd->bd->bi_boot_params = (PHYS_SDRAM_0 + 0x100); @@ -225,20 +225,6 @@ int board_init(void)
                return ret;
/* strcmp() would look better, but doesn't get optimised away. */
-       if (CONFIG_SATAPWR[0]) {
-               satapwr_pin = sunxi_name_to_gpio(CONFIG_SATAPWR);
-               if (satapwr_pin >= 0) {
-                       gpio_request(satapwr_pin, "satapwr");
-                       gpio_direction_output(satapwr_pin, 1);
-
-                       /*
-                        * Give the attached SATA device time to power-up
-                        * to avoid link timeouts
-                        */
-                       mdelay(500);
-               }
-       }
-
        if (CONFIG_MACPWR[0]) {
                macpwr_pin = sunxi_name_to_gpio(CONFIG_MACPWR);
                if (macpwr_pin >= 0) {
...
diff --git a/drivers/ata/ahci_sunxi.c b/drivers/ata/ahci_sunxi.c
index 94a3379c532..9064774e661 100644
--- a/drivers/ata/ahci_sunxi.c
+++ b/drivers/ata/ahci_sunxi.c
@@ -7,6 +7,7 @@
  #include <asm/io.h>
  #include <asm/gpio.h>
  #include <linux/delay.h>
+#include <power/regulator.h>
#define AHCI_PHYCS0R 0x00c0
  #define AHCI_PHYCS1R 0x00c4
@@ -74,6 +75,7 @@ static int sunxi_ahci_phy_init(u8 *reg_base)
static int sunxi_sata_probe(struct udevice *dev)
  {
+       struct udevice *reg_dev;
        ulong base;
        u8 *reg;
        int ret;
@@ -89,6 +91,13 @@ static int sunxi_sata_probe(struct udevice *dev)
                debug("%s: Failed to init phy (err=%d)\n", __func__, ret);
                return ret;
        }
+
+       ret = device_get_supply_regulator(dev, "target-supply", &reg_dev);
+       if (ret == 0) {
+               regulator_set_enable(reg_dev, true);
+               mdelay(500);
+       }
+
        ret = ahci_probe_scsi(dev, base);
        if (ret) {
                debug("%s: Failed to probe (err=%d)\n", __func__, ret);

Love these sorts of clean-ups. I don't have a sunxi with SATA so I can't test it, but I've been running my target on this patch in some form or another for several weeks, and the code looks good, so:
Reviewed-by: Sam Edwards <cfswo...@gmail.com>

Reply via email to