Skip to content

Commit f0f5671

Browse files
khayash1htejun
authored andcommitted
ata: ahci-platform: add reset control support
Add support to get and control a list of resets for the device as optional and shared. These resets must be kept de-asserted until the device is enabled. This is specified as shared because some SoCs like UniPhier series have common reset controls with all ahci controller instances. Signed-off-by: Kunihiko Hayashi <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 3d6f22b commit f0f5671

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Documentation/devicetree/bindings/ata/ahci-platform.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ compatible:
3030
Optional properties:
3131
- dma-coherent : Present if dma operations are coherent
3232
- clocks : a list of phandle + clock specifier pairs
33+
- resets : a list of phandle + reset specifier pairs
3334
- target-supply : regulator for SATA target power
3435
- phys : reference to the SATA PHY node
3536
- phy-names : must be "sata-phy"

drivers/ata/ahci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ struct ahci_host_priv {
350350
u32 em_msg_type; /* EM message type */
351351
bool got_runtime_pm; /* Did we do pm_runtime_get? */
352352
struct clk *clks[AHCI_MAX_CLKS]; /* Optional */
353+
struct reset_control *rsts; /* Optional */
353354
struct regulator **target_pwrs; /* Optional */
354355
/*
355356
* If platform uses PHYs. There is a 1:1 relation between the port number and

drivers/ata/libahci_platform.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/phy/phy.h>
2626
#include <linux/pm_runtime.h>
2727
#include <linux/of_platform.h>
28+
#include <linux/reset.h>
2829
#include "ahci.h"
2930

3031
static void ahci_host_stop(struct ata_host *host);
@@ -195,7 +196,8 @@ EXPORT_SYMBOL_GPL(ahci_platform_disable_regulators);
195196
* following order:
196197
* 1) Regulator
197198
* 2) Clocks (through ahci_platform_enable_clks)
198-
* 3) Phys
199+
* 3) Resets
200+
* 4) Phys
199201
*
200202
* If resource enabling fails at any point the previous enabled resources
201203
* are disabled in reverse order.
@@ -215,12 +217,19 @@ int ahci_platform_enable_resources(struct ahci_host_priv *hpriv)
215217
if (rc)
216218
goto disable_regulator;
217219

218-
rc = ahci_platform_enable_phys(hpriv);
220+
rc = reset_control_deassert(hpriv->rsts);
219221
if (rc)
220222
goto disable_clks;
221223

224+
rc = ahci_platform_enable_phys(hpriv);
225+
if (rc)
226+
goto disable_resets;
227+
222228
return 0;
223229

230+
disable_resets:
231+
reset_control_assert(hpriv->rsts);
232+
224233
disable_clks:
225234
ahci_platform_disable_clks(hpriv);
226235

@@ -239,12 +248,15 @@ EXPORT_SYMBOL_GPL(ahci_platform_enable_resources);
239248
* following order:
240249
* 1) Phys
241250
* 2) Clocks (through ahci_platform_disable_clks)
242-
* 3) Regulator
251+
* 3) Resets
252+
* 4) Regulator
243253
*/
244254
void ahci_platform_disable_resources(struct ahci_host_priv *hpriv)
245255
{
246256
ahci_platform_disable_phys(hpriv);
247257

258+
reset_control_assert(hpriv->rsts);
259+
248260
ahci_platform_disable_clks(hpriv);
249261

250262
ahci_platform_disable_regulators(hpriv);
@@ -393,6 +405,12 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
393405
hpriv->clks[i] = clk;
394406
}
395407

408+
hpriv->rsts = devm_reset_control_array_get_optional_shared(dev);
409+
if (IS_ERR(hpriv->rsts)) {
410+
rc = PTR_ERR(hpriv->rsts);
411+
goto err_out;
412+
}
413+
396414
hpriv->nports = child_nodes = of_get_child_count(dev->of_node);
397415

398416
/*

0 commit comments

Comments
 (0)