hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/ata/sata_highbank.c
....@@ -1,20 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Calxeda Highbank AHCI SATA platform driver
34 * Copyright 2012 Calxeda, Inc.
45 *
56 * 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/>.
187 */
198 #include <linux/kernel.h>
209 #include <linux/gfp.h>
....@@ -31,8 +20,7 @@
3120 #include <linux/interrupt.h>
3221 #include <linux/delay.h>
3322 #include <linux/export.h>
34
-#include <linux/gpio.h>
35
-#include <linux/of_gpio.h>
23
+#include <linux/gpio/consumer.h>
3624
3725 #include "ahci.h"
3826
....@@ -85,7 +73,7 @@
8573 /* number of extra clocks that the SGPIO PIC controller expects */
8674 u32 pre_clocks;
8775 u32 post_clocks;
88
- unsigned sgpio_gpio[SGPIO_PINS];
76
+ struct gpio_desc *sgpio_gpiod[SGPIO_PINS];
8977 u32 sgpio_pattern;
9078 u32 port_to_sgpio[SGPIO_PORTS];
9179 };
....@@ -131,9 +119,9 @@
131119 */
132120 static void ecx_led_cycle_clock(struct ecx_plat_data *pdata)
133121 {
134
- gpio_set_value(pdata->sgpio_gpio[SCLOCK], 1);
122
+ gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 1);
135123 udelay(50);
136
- gpio_set_value(pdata->sgpio_gpio[SCLOCK], 0);
124
+ gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 0);
137125 udelay(50);
138126 }
139127
....@@ -164,15 +152,15 @@
164152 for (i = 0; i < pdata->pre_clocks; i++)
165153 ecx_led_cycle_clock(pdata);
166154
167
- gpio_set_value(pdata->sgpio_gpio[SLOAD], 1);
155
+ gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 1);
168156 ecx_led_cycle_clock(pdata);
169
- gpio_set_value(pdata->sgpio_gpio[SLOAD], 0);
157
+ gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 0);
170158 /*
171159 * bit-bang out the SGPIO pattern, by consuming a bit and then
172160 * clocking it out.
173161 */
174162 for (i = 0; i < (SGPIO_SIGNALS * pdata->n_ports); i++) {
175
- gpio_set_value(pdata->sgpio_gpio[SDATA], sgpio_out & 1);
163
+ gpiod_set_value(pdata->sgpio_gpiod[SDATA], sgpio_out & 1);
176164 sgpio_out >>= 1;
177165 ecx_led_cycle_clock(pdata);
178166 }
....@@ -193,21 +181,19 @@
193181 struct device_node *np = dev->of_node;
194182 struct ecx_plat_data *pdata = hpriv->plat_data;
195183 int i;
196
- int err;
197184
198185 for (i = 0; i < SGPIO_PINS; i++) {
199
- err = of_get_named_gpio(np, "calxeda,sgpio-gpio", i);
200
- if (err < 0)
201
- return;
186
+ struct gpio_desc *gpiod;
202187
203
- pdata->sgpio_gpio[i] = err;
204
- err = gpio_request(pdata->sgpio_gpio[i], "CX SGPIO");
205
- if (err) {
206
- pr_err("sata_highbank gpio_request %d failed: %d\n",
207
- i, err);
208
- return;
188
+ gpiod = devm_gpiod_get_index(dev, "calxeda,sgpio", i,
189
+ GPIOD_OUT_HIGH);
190
+ if (IS_ERR(gpiod)) {
191
+ dev_err(dev, "failed to get GPIO %d\n", i);
192
+ continue;
209193 }
210
- gpio_direction_output(pdata->sgpio_gpio[i], 1);
194
+ gpiod_set_consumer_name(gpiod, "CX SGPIO");
195
+
196
+ pdata->sgpio_gpiod[i] = gpiod;
211197 }
212198 of_property_read_u32_array(np, "calxeda,led-order",
213199 pdata->port_to_sgpio,
....@@ -587,7 +573,6 @@
587573 struct ahci_host_priv *hpriv = host->private_data;
588574 void __iomem *mmio = hpriv->mmio;
589575 u32 ctl;
590
- int rc;
591576
592577 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
593578 dev_err(dev, "firmware update required for suspend/resume\n");
....@@ -604,11 +589,7 @@
604589 writel(ctl, mmio + HOST_CTL);
605590 readl(mmio + HOST_CTL); /* flush */
606591
607
- rc = ata_host_suspend(host, PMSG_SUSPEND);
608
- if (rc)
609
- return rc;
610
-
611
- return 0;
592
+ return ata_host_suspend(host, PMSG_SUSPEND);
612593 }
613594
614595 static int ahci_highbank_resume(struct device *dev)