| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * copyright (c) 2013 Freescale Semiconductor, Inc. |
|---|
| 3 | 4 | * Freescale IMX AHCI SATA platform driver |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * based on the AHCI SATA platform driver by Jeff Garzik and Anton Vorontsov |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 8 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 9 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 12 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 13 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 14 | | - * more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 17 | | - * this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 18 | 7 | */ |
|---|
| 19 | 8 | |
|---|
| 20 | 9 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 22 | 11 | #include <linux/platform_device.h> |
|---|
| 23 | 12 | #include <linux/regmap.h> |
|---|
| 24 | 13 | #include <linux/ahci_platform.h> |
|---|
| 14 | +#include <linux/gpio/consumer.h> |
|---|
| 25 | 15 | #include <linux/of_device.h> |
|---|
| 26 | | -#include <linux/of_gpio.h> |
|---|
| 27 | 16 | #include <linux/mfd/syscon.h> |
|---|
| 28 | 17 | #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> |
|---|
| 29 | 18 | #include <linux/libata.h> |
|---|
| .. | .. |
|---|
| 111 | 100 | struct clk *phy_pclk0; |
|---|
| 112 | 101 | struct clk *phy_pclk1; |
|---|
| 113 | 102 | void __iomem *phy_base; |
|---|
| 114 | | - int clkreq_gpio; |
|---|
| 103 | + struct gpio_desc *clkreq_gpiod; |
|---|
| 115 | 104 | struct regmap *gpr; |
|---|
| 116 | 105 | bool no_device; |
|---|
| 117 | 106 | bool first_time; |
|---|
| .. | .. |
|---|
| 793 | 782 | struct ata_host *host = dev_get_drvdata(ap->dev); |
|---|
| 794 | 783 | struct ahci_host_priv *hpriv = host->private_data; |
|---|
| 795 | 784 | struct imx_ahci_priv *imxpriv = hpriv->plat_data; |
|---|
| 796 | | - int ret = -EIO; |
|---|
| 785 | + int ret; |
|---|
| 797 | 786 | |
|---|
| 798 | 787 | if (imxpriv->type == AHCI_IMX53) |
|---|
| 799 | 788 | ret = ahci_pmp_retry_srst_ops.softreset(link, class, deadline); |
|---|
| .. | .. |
|---|
| 991 | 980 | |
|---|
| 992 | 981 | static int imx8_sata_probe(struct device *dev, struct imx_ahci_priv *imxpriv) |
|---|
| 993 | 982 | { |
|---|
| 994 | | - int ret; |
|---|
| 995 | 983 | struct resource *phy_res; |
|---|
| 996 | 984 | struct platform_device *pdev = imxpriv->ahci_pdev; |
|---|
| 997 | 985 | struct device_node *np = dev->of_node; |
|---|
| .. | .. |
|---|
| 1044 | 1032 | } |
|---|
| 1045 | 1033 | |
|---|
| 1046 | 1034 | /* Fetch GPIO, then enable the external OSC */ |
|---|
| 1047 | | - imxpriv->clkreq_gpio = of_get_named_gpio(np, "clkreq-gpio", 0); |
|---|
| 1048 | | - if (gpio_is_valid(imxpriv->clkreq_gpio)) { |
|---|
| 1049 | | - ret = devm_gpio_request_one(dev, imxpriv->clkreq_gpio, |
|---|
| 1050 | | - GPIOF_OUT_INIT_LOW, |
|---|
| 1051 | | - "SATA CLKREQ"); |
|---|
| 1052 | | - if (ret == -EBUSY) { |
|---|
| 1053 | | - dev_info(dev, "clkreq had been initialized.\n"); |
|---|
| 1054 | | - } else if (ret) { |
|---|
| 1055 | | - dev_err(dev, "%d unable to get clkreq.\n", ret); |
|---|
| 1056 | | - return ret; |
|---|
| 1057 | | - } |
|---|
| 1058 | | - } else if (imxpriv->clkreq_gpio == -EPROBE_DEFER) { |
|---|
| 1059 | | - return imxpriv->clkreq_gpio; |
|---|
| 1060 | | - } |
|---|
| 1035 | + imxpriv->clkreq_gpiod = devm_gpiod_get_optional(dev, "clkreq", |
|---|
| 1036 | + GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); |
|---|
| 1037 | + if (IS_ERR(imxpriv->clkreq_gpiod)) |
|---|
| 1038 | + return PTR_ERR(imxpriv->clkreq_gpiod); |
|---|
| 1039 | + if (imxpriv->clkreq_gpiod) |
|---|
| 1040 | + gpiod_set_consumer_name(imxpriv->clkreq_gpiod, "SATA CLKREQ"); |
|---|
| 1061 | 1041 | |
|---|
| 1062 | 1042 | return 0; |
|---|
| 1063 | 1043 | } |
|---|
| .. | .. |
|---|
| 1250 | 1230 | MODULE_DESCRIPTION("Freescale i.MX AHCI SATA platform driver"); |
|---|
| 1251 | 1231 | MODULE_AUTHOR("Richard Zhu <Hong-Xing.Zhu@freescale.com>"); |
|---|
| 1252 | 1232 | MODULE_LICENSE("GPL"); |
|---|
| 1253 | | -MODULE_ALIAS("ahci:imx"); |
|---|
| 1233 | +MODULE_ALIAS("platform:" DRV_NAME); |
|---|