| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Calxeda Highbank AHCI SATA platform driver |
|---|
| 3 | 4 | * Copyright 2012 Calxeda, Inc. |
|---|
| 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 | #include <linux/kernel.h> |
|---|
| 20 | 9 | #include <linux/gfp.h> |
|---|
| .. | .. |
|---|
| 31 | 20 | #include <linux/interrupt.h> |
|---|
| 32 | 21 | #include <linux/delay.h> |
|---|
| 33 | 22 | #include <linux/export.h> |
|---|
| 34 | | -#include <linux/gpio.h> |
|---|
| 35 | | -#include <linux/of_gpio.h> |
|---|
| 23 | +#include <linux/gpio/consumer.h> |
|---|
| 36 | 24 | |
|---|
| 37 | 25 | #include "ahci.h" |
|---|
| 38 | 26 | |
|---|
| .. | .. |
|---|
| 85 | 73 | /* number of extra clocks that the SGPIO PIC controller expects */ |
|---|
| 86 | 74 | u32 pre_clocks; |
|---|
| 87 | 75 | u32 post_clocks; |
|---|
| 88 | | - unsigned sgpio_gpio[SGPIO_PINS]; |
|---|
| 76 | + struct gpio_desc *sgpio_gpiod[SGPIO_PINS]; |
|---|
| 89 | 77 | u32 sgpio_pattern; |
|---|
| 90 | 78 | u32 port_to_sgpio[SGPIO_PORTS]; |
|---|
| 91 | 79 | }; |
|---|
| .. | .. |
|---|
| 131 | 119 | */ |
|---|
| 132 | 120 | static void ecx_led_cycle_clock(struct ecx_plat_data *pdata) |
|---|
| 133 | 121 | { |
|---|
| 134 | | - gpio_set_value(pdata->sgpio_gpio[SCLOCK], 1); |
|---|
| 122 | + gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 1); |
|---|
| 135 | 123 | udelay(50); |
|---|
| 136 | | - gpio_set_value(pdata->sgpio_gpio[SCLOCK], 0); |
|---|
| 124 | + gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 0); |
|---|
| 137 | 125 | udelay(50); |
|---|
| 138 | 126 | } |
|---|
| 139 | 127 | |
|---|
| .. | .. |
|---|
| 164 | 152 | for (i = 0; i < pdata->pre_clocks; i++) |
|---|
| 165 | 153 | ecx_led_cycle_clock(pdata); |
|---|
| 166 | 154 | |
|---|
| 167 | | - gpio_set_value(pdata->sgpio_gpio[SLOAD], 1); |
|---|
| 155 | + gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 1); |
|---|
| 168 | 156 | ecx_led_cycle_clock(pdata); |
|---|
| 169 | | - gpio_set_value(pdata->sgpio_gpio[SLOAD], 0); |
|---|
| 157 | + gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 0); |
|---|
| 170 | 158 | /* |
|---|
| 171 | 159 | * bit-bang out the SGPIO pattern, by consuming a bit and then |
|---|
| 172 | 160 | * clocking it out. |
|---|
| 173 | 161 | */ |
|---|
| 174 | 162 | 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); |
|---|
| 176 | 164 | sgpio_out >>= 1; |
|---|
| 177 | 165 | ecx_led_cycle_clock(pdata); |
|---|
| 178 | 166 | } |
|---|
| .. | .. |
|---|
| 193 | 181 | struct device_node *np = dev->of_node; |
|---|
| 194 | 182 | struct ecx_plat_data *pdata = hpriv->plat_data; |
|---|
| 195 | 183 | int i; |
|---|
| 196 | | - int err; |
|---|
| 197 | 184 | |
|---|
| 198 | 185 | 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; |
|---|
| 202 | 187 | |
|---|
| 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; |
|---|
| 209 | 193 | } |
|---|
| 210 | | - gpio_direction_output(pdata->sgpio_gpio[i], 1); |
|---|
| 194 | + gpiod_set_consumer_name(gpiod, "CX SGPIO"); |
|---|
| 195 | + |
|---|
| 196 | + pdata->sgpio_gpiod[i] = gpiod; |
|---|
| 211 | 197 | } |
|---|
| 212 | 198 | of_property_read_u32_array(np, "calxeda,led-order", |
|---|
| 213 | 199 | pdata->port_to_sgpio, |
|---|
| .. | .. |
|---|
| 587 | 573 | struct ahci_host_priv *hpriv = host->private_data; |
|---|
| 588 | 574 | void __iomem *mmio = hpriv->mmio; |
|---|
| 589 | 575 | u32 ctl; |
|---|
| 590 | | - int rc; |
|---|
| 591 | 576 | |
|---|
| 592 | 577 | if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { |
|---|
| 593 | 578 | dev_err(dev, "firmware update required for suspend/resume\n"); |
|---|
| .. | .. |
|---|
| 604 | 589 | writel(ctl, mmio + HOST_CTL); |
|---|
| 605 | 590 | readl(mmio + HOST_CTL); /* flush */ |
|---|
| 606 | 591 | |
|---|
| 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); |
|---|
| 612 | 593 | } |
|---|
| 613 | 594 | |
|---|
| 614 | 595 | static int ahci_highbank_resume(struct device *dev) |
|---|