ata: libahci_platform: move port_map parameters into the AHCI structure
This patch moves force_port_map and mask_port_map into the ahci_host_priv structure. This allows to modify them into the AHCI framework. This is needed by the new dt bindings representing ports as the port_map mask is computed automatically. Parameters modifying force_port_map, mask_port_map and flags have been removed from the ahci_platform_init_host() function, and inputs in the ahci_host_priv structure are now directly filed. Signed-off-by: Antoine Ténart <antoine.tenart@free-electrons.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
		
							parent
							
								
									e8f781836d
								
							
						
					
					
						commit
						725c7b570f
					
				| @ -441,7 +441,7 @@ static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id | |||||||
| 	hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; | 	hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; | ||||||
| 
 | 
 | ||||||
| 	/* save initial config */ | 	/* save initial config */ | ||||||
| 	ahci_save_initial_config(&pdev->dev, hpriv, 0, 0); | 	ahci_save_initial_config(&pdev->dev, hpriv); | ||||||
| 
 | 
 | ||||||
| 	/* prepare host */ | 	/* prepare host */ | ||||||
| 	if (hpriv->cap & HOST_CAP_NCQ) | 	if (hpriv->cap & HOST_CAP_NCQ) | ||||||
|  | |||||||
| @ -526,8 +526,7 @@ static void ahci_pci_save_initial_config(struct pci_dev *pdev, | |||||||
| 			  "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n"); | 			  "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	ahci_save_initial_config(&pdev->dev, hpriv, force_port_map, | 	ahci_save_initial_config(&pdev->dev, hpriv); | ||||||
| 				 mask_port_map); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int ahci_pci_reset_controller(struct ata_host *host) | static int ahci_pci_reset_controller(struct ata_host *host) | ||||||
|  | |||||||
| @ -316,8 +316,12 @@ struct ahci_port_priv { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct ahci_host_priv { | struct ahci_host_priv { | ||||||
| 	void __iomem *		mmio;		/* bus-independent mem map */ | 	/* Input fields */ | ||||||
| 	unsigned int		flags;		/* AHCI_HFLAG_* */ | 	unsigned int		flags;		/* AHCI_HFLAG_* */ | ||||||
|  | 	u32			force_port_map;	/* force port map */ | ||||||
|  | 	u32			mask_port_map;	/* mask out particular bits */ | ||||||
|  | 
 | ||||||
|  | 	void __iomem *		mmio;		/* bus-independent mem map */ | ||||||
| 	u32			cap;		/* cap to use */ | 	u32			cap;		/* cap to use */ | ||||||
| 	u32			cap2;		/* cap2 to use */ | 	u32			cap2;		/* cap2 to use */ | ||||||
| 	u32			port_map;	/* port map to use */ | 	u32			port_map;	/* port map to use */ | ||||||
| @ -361,9 +365,7 @@ unsigned int ahci_dev_classify(struct ata_port *ap); | |||||||
| void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, | void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, | ||||||
| 			u32 opts); | 			u32 opts); | ||||||
| void ahci_save_initial_config(struct device *dev, | void ahci_save_initial_config(struct device *dev, | ||||||
| 			      struct ahci_host_priv *hpriv, | 			      struct ahci_host_priv *hpriv); | ||||||
| 			      unsigned int force_port_map, |  | ||||||
| 			      unsigned int mask_port_map); |  | ||||||
| void ahci_init_controller(struct ata_host *host); | void ahci_init_controller(struct ata_host *host); | ||||||
| int ahci_reset_controller(struct ata_host *host); | int ahci_reset_controller(struct ata_host *host); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -85,8 +85,7 @@ static int ahci_da850_probe(struct platform_device *pdev) | |||||||
| 
 | 
 | ||||||
| 	da850_sata_init(dev, pwrdn_reg, hpriv->mmio); | 	da850_sata_init(dev, pwrdn_reg, hpriv->mmio); | ||||||
| 
 | 
 | ||||||
| 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info, | 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info); | ||||||
| 				     0, 0, 0); |  | ||||||
| 	if (rc) | 	if (rc) | ||||||
| 		goto disable_resources; | 		goto disable_resources; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -620,8 +620,7 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||||||
| 	reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; | 	reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; | ||||||
| 	writel(reg_val, hpriv->mmio + IMX_TIMER1MS); | 	writel(reg_val, hpriv->mmio + IMX_TIMER1MS); | ||||||
| 
 | 
 | ||||||
| 	ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, | 	ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info); | ||||||
| 				      0, 0, 0); |  | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		goto disable_sata; | 		goto disable_sata; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -88,8 +88,7 @@ static int ahci_mvebu_probe(struct platform_device *pdev) | |||||||
| 	ahci_mvebu_mbus_config(hpriv, dram); | 	ahci_mvebu_mbus_config(hpriv, dram); | ||||||
| 	ahci_mvebu_regret_option(hpriv); | 	ahci_mvebu_regret_option(hpriv); | ||||||
| 
 | 
 | ||||||
| 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_mvebu_port_info, | 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_mvebu_port_info); | ||||||
| 				     0, 0, 0); |  | ||||||
| 	if (rc) | 	if (rc) | ||||||
| 		goto disable_resources; | 		goto disable_resources; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -34,7 +34,6 @@ static int ahci_probe(struct platform_device *pdev) | |||||||
| 	struct device *dev = &pdev->dev; | 	struct device *dev = &pdev->dev; | ||||||
| 	struct ahci_platform_data *pdata = dev_get_platdata(dev); | 	struct ahci_platform_data *pdata = dev_get_platdata(dev); | ||||||
| 	struct ahci_host_priv *hpriv; | 	struct ahci_host_priv *hpriv; | ||||||
| 	unsigned long hflags = 0; |  | ||||||
| 	int rc; | 	int rc; | ||||||
| 
 | 
 | ||||||
| 	hpriv = ahci_platform_get_resources(pdev); | 	hpriv = ahci_platform_get_resources(pdev); | ||||||
| @ -58,10 +57,9 @@ static int ahci_probe(struct platform_device *pdev) | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) | 	if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) | ||||||
| 		hflags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; | 		hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; | ||||||
| 
 | 
 | ||||||
| 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info, | 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info); | ||||||
| 				     hflags, 0, 0); |  | ||||||
| 	if (rc) | 	if (rc) | ||||||
| 		goto pdata_exit; | 		goto pdata_exit; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -166,7 +166,7 @@ static int st_ahci_probe(struct platform_device *pdev) | |||||||
| 	if (err) | 	if (err) | ||||||
| 		return err; | 		return err; | ||||||
| 
 | 
 | ||||||
| 	err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info, 0, 0, 0); | 	err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info); | ||||||
| 	if (err) { | 	if (err) { | ||||||
| 		ahci_platform_disable_resources(hpriv); | 		ahci_platform_disable_resources(hpriv); | ||||||
| 		return err; | 		return err; | ||||||
|  | |||||||
| @ -167,7 +167,6 @@ static int ahci_sunxi_probe(struct platform_device *pdev) | |||||||
| { | { | ||||||
| 	struct device *dev = &pdev->dev; | 	struct device *dev = &pdev->dev; | ||||||
| 	struct ahci_host_priv *hpriv; | 	struct ahci_host_priv *hpriv; | ||||||
| 	unsigned long hflags; |  | ||||||
| 	int rc; | 	int rc; | ||||||
| 
 | 
 | ||||||
| 	hpriv = ahci_platform_get_resources(pdev); | 	hpriv = ahci_platform_get_resources(pdev); | ||||||
| @ -184,11 +183,10 @@ static int ahci_sunxi_probe(struct platform_device *pdev) | |||||||
| 	if (rc) | 	if (rc) | ||||||
| 		goto disable_resources; | 		goto disable_resources; | ||||||
| 
 | 
 | ||||||
| 	hflags = AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI | | 	hpriv->flags = AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI | | ||||||
| 		       AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; | 		       AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; | ||||||
| 
 | 
 | ||||||
| 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_sunxi_port_info, | 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_sunxi_port_info); | ||||||
| 				     hflags, 0, 0); |  | ||||||
| 	if (rc) | 	if (rc) | ||||||
| 		goto disable_resources; | 		goto disable_resources; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -348,8 +348,7 @@ static int tegra_ahci_probe(struct platform_device *pdev) | |||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	ret = ahci_platform_init_host(pdev, hpriv, &ahci_tegra_port_info, | 	ret = ahci_platform_init_host(pdev, hpriv, &ahci_tegra_port_info); | ||||||
| 				      0, 0, 0); |  | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		goto deinit_controller; | 		goto deinit_controller; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -422,7 +422,6 @@ static int xgene_ahci_probe(struct platform_device *pdev) | |||||||
| 	struct ahci_host_priv *hpriv; | 	struct ahci_host_priv *hpriv; | ||||||
| 	struct xgene_ahci_context *ctx; | 	struct xgene_ahci_context *ctx; | ||||||
| 	struct resource *res; | 	struct resource *res; | ||||||
| 	unsigned long hflags; |  | ||||||
| 	int rc; | 	int rc; | ||||||
| 
 | 
 | ||||||
| 	hpriv = ahci_platform_get_resources(pdev); | 	hpriv = ahci_platform_get_resources(pdev); | ||||||
| @ -481,10 +480,9 @@ static int xgene_ahci_probe(struct platform_device *pdev) | |||||||
| 	/* Configure the host controller */ | 	/* Configure the host controller */ | ||||||
| 	xgene_ahci_hw_init(hpriv); | 	xgene_ahci_hw_init(hpriv); | ||||||
| 
 | 
 | ||||||
| 	hflags = AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; | 	hpriv->flags = AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; | ||||||
| 
 | 
 | ||||||
| 	rc = ahci_platform_init_host(pdev, hpriv, &xgene_ahci_port_info, | 	rc = ahci_platform_init_host(pdev, hpriv, &xgene_ahci_port_info); | ||||||
| 				     hflags, 0, 0); |  | ||||||
| 	if (rc) | 	if (rc) | ||||||
| 		goto disable_resources; | 		goto disable_resources; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -382,8 +382,6 @@ static ssize_t ahci_show_em_supported(struct device *dev, | |||||||
|  *	ahci_save_initial_config - Save and fixup initial config values |  *	ahci_save_initial_config - Save and fixup initial config values | ||||||
|  *	@dev: target AHCI device |  *	@dev: target AHCI device | ||||||
|  *	@hpriv: host private area to store config values |  *	@hpriv: host private area to store config values | ||||||
|  *	@force_port_map: force port map to a specified value |  | ||||||
|  *	@mask_port_map: mask out particular bits from port map |  | ||||||
|  * |  * | ||||||
|  *	Some registers containing configuration info might be setup by |  *	Some registers containing configuration info might be setup by | ||||||
|  *	BIOS and might be cleared on reset.  This function saves the |  *	BIOS and might be cleared on reset.  This function saves the | ||||||
| @ -398,10 +396,7 @@ static ssize_t ahci_show_em_supported(struct device *dev, | |||||||
|  *	LOCKING: |  *	LOCKING: | ||||||
|  *	None. |  *	None. | ||||||
|  */ |  */ | ||||||
| void ahci_save_initial_config(struct device *dev, | void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv) | ||||||
| 			      struct ahci_host_priv *hpriv, |  | ||||||
| 			      unsigned int force_port_map, |  | ||||||
| 			      unsigned int mask_port_map) |  | ||||||
| { | { | ||||||
| 	void __iomem *mmio = hpriv->mmio; | 	void __iomem *mmio = hpriv->mmio; | ||||||
| 	u32 cap, cap2, vers, port_map; | 	u32 cap, cap2, vers, port_map; | ||||||
| @ -468,17 +463,17 @@ void ahci_save_initial_config(struct device *dev, | |||||||
| 		cap &= ~HOST_CAP_FBS; | 		cap &= ~HOST_CAP_FBS; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (force_port_map && port_map != force_port_map) { | 	if (hpriv->force_port_map && port_map != hpriv->force_port_map) { | ||||||
| 		dev_info(dev, "forcing port_map 0x%x -> 0x%x\n", | 		dev_info(dev, "forcing port_map 0x%x -> 0x%x\n", | ||||||
| 			 port_map, force_port_map); | 			 port_map, hpriv->force_port_map); | ||||||
| 		port_map = force_port_map; | 		port_map = hpriv->force_port_map; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (mask_port_map) { | 	if (hpriv->mask_port_map) { | ||||||
| 		dev_warn(dev, "masking port_map 0x%x -> 0x%x\n", | 		dev_warn(dev, "masking port_map 0x%x -> 0x%x\n", | ||||||
| 			port_map, | 			port_map, | ||||||
| 			port_map & mask_port_map); | 			port_map & hpriv->mask_port_map); | ||||||
| 		port_map &= mask_port_map; | 		port_map &= hpriv->mask_port_map; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* cross check port_map and cap.n_ports */ | 	/* cross check port_map and cap.n_ports */ | ||||||
|  | |||||||
| @ -288,9 +288,6 @@ EXPORT_SYMBOL_GPL(ahci_platform_get_resources); | |||||||
|  * @pdev: platform device pointer for the host |  * @pdev: platform device pointer for the host | ||||||
|  * @hpriv: ahci-host private data for the host |  * @hpriv: ahci-host private data for the host | ||||||
|  * @pi_template: template for the ata_port_info to use |  * @pi_template: template for the ata_port_info to use | ||||||
|  * @host_flags: ahci host flags used in ahci_host_priv |  | ||||||
|  * @force_port_map: param passed to ahci_save_initial_config |  | ||||||
|  * @mask_port_map: param passed to ahci_save_initial_config |  | ||||||
|  * |  * | ||||||
|  * This function does all the usual steps needed to bring up an |  * This function does all the usual steps needed to bring up an | ||||||
|  * ahci-platform host, note any necessary resources (ie clks, phy, etc.) |  * ahci-platform host, note any necessary resources (ie clks, phy, etc.) | ||||||
| @ -301,10 +298,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_get_resources); | |||||||
|  */ |  */ | ||||||
| int ahci_platform_init_host(struct platform_device *pdev, | int ahci_platform_init_host(struct platform_device *pdev, | ||||||
| 			    struct ahci_host_priv *hpriv, | 			    struct ahci_host_priv *hpriv, | ||||||
| 			    const struct ata_port_info *pi_template, | 			    const struct ata_port_info *pi_template) | ||||||
| 			    unsigned long host_flags, |  | ||||||
| 			    unsigned int force_port_map, |  | ||||||
| 			    unsigned int mask_port_map) |  | ||||||
| { | { | ||||||
| 	struct device *dev = &pdev->dev; | 	struct device *dev = &pdev->dev; | ||||||
| 	struct ata_port_info pi = *pi_template; | 	struct ata_port_info pi = *pi_template; | ||||||
| @ -319,10 +313,9 @@ int ahci_platform_init_host(struct platform_device *pdev, | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* prepare host */ | 	/* prepare host */ | ||||||
| 	pi.private_data = (void *)host_flags; | 	pi.private_data = (void *)hpriv->flags; | ||||||
| 	hpriv->flags |= host_flags; |  | ||||||
| 
 | 
 | ||||||
| 	ahci_save_initial_config(dev, hpriv, force_port_map, mask_port_map); | 	ahci_save_initial_config(dev, hpriv); | ||||||
| 
 | 
 | ||||||
| 	if (hpriv->cap & HOST_CAP_NCQ) | 	if (hpriv->cap & HOST_CAP_NCQ) | ||||||
| 		pi.flags |= ATA_FLAG_NCQ; | 		pi.flags |= ATA_FLAG_NCQ; | ||||||
|  | |||||||
| @ -512,7 +512,7 @@ static int ahci_highbank_probe(struct platform_device *pdev) | |||||||
| 		return rc; | 		return rc; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	ahci_save_initial_config(dev, hpriv, 0, 0); | 	ahci_save_initial_config(dev, hpriv); | ||||||
| 
 | 
 | ||||||
| 	/* prepare host */ | 	/* prepare host */ | ||||||
| 	if (hpriv->cap & HOST_CAP_NCQ) | 	if (hpriv->cap & HOST_CAP_NCQ) | ||||||
|  | |||||||
| @ -43,10 +43,7 @@ struct ahci_host_priv *ahci_platform_get_resources( | |||||||
| 	struct platform_device *pdev); | 	struct platform_device *pdev); | ||||||
| int ahci_platform_init_host(struct platform_device *pdev, | int ahci_platform_init_host(struct platform_device *pdev, | ||||||
| 			    struct ahci_host_priv *hpriv, | 			    struct ahci_host_priv *hpriv, | ||||||
| 			    const struct ata_port_info *pi_template, | 			    const struct ata_port_info *pi_template); | ||||||
| 			    unsigned long host_flags, |  | ||||||
| 			    unsigned int force_port_map, |  | ||||||
| 			    unsigned int mask_port_map); |  | ||||||
| 
 | 
 | ||||||
| int ahci_platform_suspend_host(struct device *dev); | int ahci_platform_suspend_host(struct device *dev); | ||||||
| int ahci_platform_resume_host(struct device *dev); | int ahci_platform_resume_host(struct device *dev); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user