diff options
| -rw-r--r-- | drivers/ata/sata_highbank.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c index e67815b896fc..c8fc9280d6e4 100644 --- a/drivers/ata/sata_highbank.c +++ b/drivers/ata/sata_highbank.c | |||
| @@ -31,8 +31,7 @@ | |||
| 31 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
| 32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
| 33 | #include <linux/export.h> | 33 | #include <linux/export.h> |
| 34 | #include <linux/gpio.h> | 34 | #include <linux/gpio/consumer.h> |
| 35 | #include <linux/of_gpio.h> | ||
| 36 | 35 | ||
| 37 | #include "ahci.h" | 36 | #include "ahci.h" |
| 38 | 37 | ||
| @@ -85,7 +84,7 @@ struct ecx_plat_data { | |||
| 85 | /* number of extra clocks that the SGPIO PIC controller expects */ | 84 | /* number of extra clocks that the SGPIO PIC controller expects */ |
| 86 | u32 pre_clocks; | 85 | u32 pre_clocks; |
| 87 | u32 post_clocks; | 86 | u32 post_clocks; |
| 88 | unsigned sgpio_gpio[SGPIO_PINS]; | 87 | struct gpio_desc *sgpio_gpiod[SGPIO_PINS]; |
| 89 | u32 sgpio_pattern; | 88 | u32 sgpio_pattern; |
| 90 | u32 port_to_sgpio[SGPIO_PORTS]; | 89 | u32 port_to_sgpio[SGPIO_PORTS]; |
| 91 | }; | 90 | }; |
| @@ -131,9 +130,9 @@ static void ecx_parse_sgpio(struct ecx_plat_data *pdata, u32 port, u32 state) | |||
| 131 | */ | 130 | */ |
| 132 | static void ecx_led_cycle_clock(struct ecx_plat_data *pdata) | 131 | static void ecx_led_cycle_clock(struct ecx_plat_data *pdata) |
| 133 | { | 132 | { |
| 134 | gpio_set_value(pdata->sgpio_gpio[SCLOCK], 1); | 133 | gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 1); |
| 135 | udelay(50); | 134 | udelay(50); |
| 136 | gpio_set_value(pdata->sgpio_gpio[SCLOCK], 0); | 135 | gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 0); |
| 137 | udelay(50); | 136 | udelay(50); |
| 138 | } | 137 | } |
| 139 | 138 | ||
| @@ -164,15 +163,15 @@ static ssize_t ecx_transmit_led_message(struct ata_port *ap, u32 state, | |||
| 164 | for (i = 0; i < pdata->pre_clocks; i++) | 163 | for (i = 0; i < pdata->pre_clocks; i++) |
| 165 | ecx_led_cycle_clock(pdata); | 164 | ecx_led_cycle_clock(pdata); |
| 166 | 165 | ||
| 167 | gpio_set_value(pdata->sgpio_gpio[SLOAD], 1); | 166 | gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 1); |
| 168 | ecx_led_cycle_clock(pdata); | 167 | ecx_led_cycle_clock(pdata); |
| 169 | gpio_set_value(pdata->sgpio_gpio[SLOAD], 0); | 168 | gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 0); |
| 170 | /* | 169 | /* |
| 171 | * bit-bang out the SGPIO pattern, by consuming a bit and then | 170 | * bit-bang out the SGPIO pattern, by consuming a bit and then |
| 172 | * clocking it out. | 171 | * clocking it out. |
| 173 | */ | 172 | */ |
| 174 | for (i = 0; i < (SGPIO_SIGNALS * pdata->n_ports); i++) { | 173 | for (i = 0; i < (SGPIO_SIGNALS * pdata->n_ports); i++) { |
| 175 | gpio_set_value(pdata->sgpio_gpio[SDATA], sgpio_out & 1); | 174 | gpiod_set_value(pdata->sgpio_gpiod[SDATA], sgpio_out & 1); |
| 176 | sgpio_out >>= 1; | 175 | sgpio_out >>= 1; |
| 177 | ecx_led_cycle_clock(pdata); | 176 | ecx_led_cycle_clock(pdata); |
| 178 | } | 177 | } |
| @@ -193,21 +192,19 @@ static void highbank_set_em_messages(struct device *dev, | |||
| 193 | struct device_node *np = dev->of_node; | 192 | struct device_node *np = dev->of_node; |
| 194 | struct ecx_plat_data *pdata = hpriv->plat_data; | 193 | struct ecx_plat_data *pdata = hpriv->plat_data; |
| 195 | int i; | 194 | int i; |
| 196 | int err; | ||
| 197 | 195 | ||
| 198 | for (i = 0; i < SGPIO_PINS; i++) { | 196 | for (i = 0; i < SGPIO_PINS; i++) { |
| 199 | err = of_get_named_gpio(np, "calxeda,sgpio-gpio", i); | 197 | struct gpio_desc *gpiod; |
| 200 | if (err < 0) | 198 | |
| 201 | return; | 199 | gpiod = devm_gpiod_get_index(dev, "calxeda,sgpio", i, |
| 202 | 200 | GPIOD_OUT_HIGH); | |
| 203 | pdata->sgpio_gpio[i] = err; | 201 | if (IS_ERR(gpiod)) { |
| 204 | err = gpio_request(pdata->sgpio_gpio[i], "CX SGPIO"); | 202 | dev_err(dev, "failed to get GPIO %d\n", i); |
| 205 | if (err) { | 203 | continue; |
| 206 | pr_err("sata_highbank gpio_request %d failed: %d\n", | ||
| 207 | i, err); | ||
| 208 | return; | ||
| 209 | } | 204 | } |
| 210 | gpio_direction_output(pdata->sgpio_gpio[i], 1); | 205 | gpiod_set_consumer_name(gpiod, "CX SGPIO"); |
| 206 | |||
| 207 | pdata->sgpio_gpiod[i] = gpiod; | ||
| 211 | } | 208 | } |
| 212 | of_property_read_u32_array(np, "calxeda,led-order", | 209 | of_property_read_u32_array(np, "calxeda,led-order", |
| 213 | pdata->port_to_sgpio, | 210 | pdata->port_to_sgpio, |
