Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ata: ahci-imx: Covert to use GPIO descriptor

This converts the i.MX AHCI driver to use a GPIO descriptor
instead of parsing the device tree by itself.

This driver is quite obviously device tree only, and the
GPIO line is treated as optional, so let's keep it as
optional.

None of the device trees in the kernel use this GPIO
facility today, so it is hard to test.

Cc: Egor Starkov <egor.starkov@ge.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+8 -17
+8 -17
drivers/ata/ahci_imx.c
··· 11 11 #include <linux/platform_device.h> 12 12 #include <linux/regmap.h> 13 13 #include <linux/ahci_platform.h> 14 + #include <linux/gpio/consumer.h> 14 15 #include <linux/of_device.h> 15 - #include <linux/of_gpio.h> 16 16 #include <linux/mfd/syscon.h> 17 17 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> 18 18 #include <linux/libata.h> ··· 100 100 struct clk *phy_pclk0; 101 101 struct clk *phy_pclk1; 102 102 void __iomem *phy_base; 103 - int clkreq_gpio; 103 + struct gpio_desc *clkreq_gpiod; 104 104 struct regmap *gpr; 105 105 bool no_device; 106 106 bool first_time; ··· 980 980 981 981 static int imx8_sata_probe(struct device *dev, struct imx_ahci_priv *imxpriv) 982 982 { 983 - int ret; 984 983 struct resource *phy_res; 985 984 struct platform_device *pdev = imxpriv->ahci_pdev; 986 985 struct device_node *np = dev->of_node; ··· 1032 1033 } 1033 1034 1034 1035 /* Fetch GPIO, then enable the external OSC */ 1035 - imxpriv->clkreq_gpio = of_get_named_gpio(np, "clkreq-gpio", 0); 1036 - if (gpio_is_valid(imxpriv->clkreq_gpio)) { 1037 - ret = devm_gpio_request_one(dev, imxpriv->clkreq_gpio, 1038 - GPIOF_OUT_INIT_LOW, 1039 - "SATA CLKREQ"); 1040 - if (ret == -EBUSY) { 1041 - dev_info(dev, "clkreq had been initialized.\n"); 1042 - } else if (ret) { 1043 - dev_err(dev, "%d unable to get clkreq.\n", ret); 1044 - return ret; 1045 - } 1046 - } else if (imxpriv->clkreq_gpio == -EPROBE_DEFER) { 1047 - return imxpriv->clkreq_gpio; 1048 - } 1036 + imxpriv->clkreq_gpiod = devm_gpiod_get_optional(dev, "clkreq", 1037 + GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); 1038 + if (IS_ERR(imxpriv->clkreq_gpiod)) 1039 + return PTR_ERR(imxpriv->clkreq_gpiod); 1040 + if (imxpriv->clkreq_gpiod) 1041 + gpiod_set_consumer_name(imxpriv->clkreq_gpiod, "SATA CLKREQ"); 1049 1042 1050 1043 return 0; 1051 1044 }