forked from mirrors/linux
		
	ata: libahci_platform: comply to PHY framework
Current implementation of the libahci does not take into account the new PHY framework. Correct the situation by adding a call to phy_set_mode() before phy_power_on(). PHYs should also be handled at suspend/resume time. For this, call ahci_platform_enable/disable_phys() at suspend/resume_host() time. These calls are guarded by a HFLAG (AHCI_HFLAG_SUSPEND_PHYS) that the user of the libahci driver must set manually in hpriv->flags at probe time. This is to avoid breaking users that have not been tested with this change. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Suggested-by: Grzegorz Jaszczyk <jaz@semihalf.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
		
							parent
							
								
									a39c330d74
								
							
						
					
					
						commit
						49e54187ae
					
				
					 2 changed files with 15 additions and 0 deletions
				
			
		|  | @ -254,6 +254,8 @@ enum { | ||||||
| 	AHCI_HFLAG_IS_MOBILE		= (1 << 25), /* mobile chipset, use
 | 	AHCI_HFLAG_IS_MOBILE		= (1 << 25), /* mobile chipset, use
 | ||||||
| 							SATA_MOBILE_LPM_POLICY | 							SATA_MOBILE_LPM_POLICY | ||||||
| 							as default lpm_policy */ | 							as default lpm_policy */ | ||||||
|  | 	AHCI_HFLAG_SUSPEND_PHYS		= (1 << 26), /* handle PHYs during
 | ||||||
|  | 							suspend/resume */ | ||||||
| 
 | 
 | ||||||
| 	/* ap->flags bits */ | 	/* ap->flags bits */ | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -56,6 +56,12 @@ static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) | ||||||
| 		if (rc) | 		if (rc) | ||||||
| 			goto disable_phys; | 			goto disable_phys; | ||||||
| 
 | 
 | ||||||
|  | 		rc = phy_set_mode(hpriv->phys[i], PHY_MODE_SATA); | ||||||
|  | 		if (rc) { | ||||||
|  | 			phy_exit(hpriv->phys[i]); | ||||||
|  | 			goto disable_phys; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		rc = phy_power_on(hpriv->phys[i]); | 		rc = phy_power_on(hpriv->phys[i]); | ||||||
| 		if (rc) { | 		if (rc) { | ||||||
| 			phy_exit(hpriv->phys[i]); | 			phy_exit(hpriv->phys[i]); | ||||||
|  | @ -738,6 +744,9 @@ int ahci_platform_suspend_host(struct device *dev) | ||||||
| 	writel(ctl, mmio + HOST_CTL); | 	writel(ctl, mmio + HOST_CTL); | ||||||
| 	readl(mmio + HOST_CTL); /* flush */ | 	readl(mmio + HOST_CTL); /* flush */ | ||||||
| 
 | 
 | ||||||
|  | 	if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS) | ||||||
|  | 		ahci_platform_disable_phys(hpriv); | ||||||
|  | 
 | ||||||
| 	return ata_host_suspend(host, PMSG_SUSPEND); | 	return ata_host_suspend(host, PMSG_SUSPEND); | ||||||
| } | } | ||||||
| EXPORT_SYMBOL_GPL(ahci_platform_suspend_host); | EXPORT_SYMBOL_GPL(ahci_platform_suspend_host); | ||||||
|  | @ -756,6 +765,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_suspend_host); | ||||||
| int ahci_platform_resume_host(struct device *dev) | int ahci_platform_resume_host(struct device *dev) | ||||||
| { | { | ||||||
| 	struct ata_host *host = dev_get_drvdata(dev); | 	struct ata_host *host = dev_get_drvdata(dev); | ||||||
|  | 	struct ahci_host_priv *hpriv = host->private_data; | ||||||
| 	int rc; | 	int rc; | ||||||
| 
 | 
 | ||||||
| 	if (dev->power.power_state.event == PM_EVENT_SUSPEND) { | 	if (dev->power.power_state.event == PM_EVENT_SUSPEND) { | ||||||
|  | @ -766,6 +776,9 @@ int ahci_platform_resume_host(struct device *dev) | ||||||
| 		ahci_init_controller(host); | 		ahci_init_controller(host); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS) | ||||||
|  | 		ahci_platform_enable_phys(hpriv); | ||||||
|  | 
 | ||||||
| 	ata_host_resume(host); | 	ata_host_resume(host); | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Miquel Raynal
						Miquel Raynal