PCI: rcar: Factor out rcar_pcie_hw_init() call
rcar_pcie_hw_init_{h1|gen2|gen3}() only differ in the PCIe PHY init code and all end with a call to rcar_pcie_hw_init(), thus it makes sense to move that call into the driver's probe() method and then rename those functions to rcar_pcie_phy_init_{h1|gen2|gen3}(). Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> [lorenzo.pieralisi@arm.com: updated commit log] Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
This commit is contained in:
parent
517ca93a71
commit
9d5014e90e
|
@ -626,7 +626,7 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rcar_pcie_hw_init_h1(struct rcar_pcie *pcie)
|
static int rcar_pcie_phy_init_h1(struct rcar_pcie *pcie)
|
||||||
{
|
{
|
||||||
/* Initialize the phy */
|
/* Initialize the phy */
|
||||||
phy_write_reg(pcie, 0, 0x42, 0x1, 0x0EC34191);
|
phy_write_reg(pcie, 0, 0x42, 0x1, 0x0EC34191);
|
||||||
|
@ -646,10 +646,10 @@ static int rcar_pcie_hw_init_h1(struct rcar_pcie *pcie)
|
||||||
phy_write_reg(pcie, 0, 0x64, 0x1, 0x3F0F1F0F);
|
phy_write_reg(pcie, 0, 0x64, 0x1, 0x3F0F1F0F);
|
||||||
phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000);
|
phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000);
|
||||||
|
|
||||||
return rcar_pcie_hw_init(pcie);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rcar_pcie_hw_init_gen2(struct rcar_pcie *pcie)
|
static int rcar_pcie_phy_init_gen2(struct rcar_pcie *pcie)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* These settings come from the R-Car Series, 2nd Generation User's
|
* These settings come from the R-Car Series, 2nd Generation User's
|
||||||
|
@ -666,10 +666,10 @@ static int rcar_pcie_hw_init_gen2(struct rcar_pcie *pcie)
|
||||||
rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL);
|
rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL);
|
||||||
rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL);
|
rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL);
|
||||||
|
|
||||||
return rcar_pcie_hw_init(pcie);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rcar_pcie_hw_init_gen3(struct rcar_pcie *pcie)
|
static int rcar_pcie_phy_init_gen3(struct rcar_pcie *pcie)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -677,11 +677,7 @@ static int rcar_pcie_hw_init_gen3(struct rcar_pcie *pcie)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = phy_power_on(pcie->phy);
|
return phy_power_on(pcie->phy);
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
return rcar_pcie_hw_init(pcie);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rcar_msi_alloc(struct rcar_msi *chip)
|
static int rcar_msi_alloc(struct rcar_msi *chip)
|
||||||
|
@ -1070,17 +1066,18 @@ static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id rcar_pcie_of_match[] = {
|
static const struct of_device_id rcar_pcie_of_match[] = {
|
||||||
{ .compatible = "renesas,pcie-r8a7779", .data = rcar_pcie_hw_init_h1 },
|
{ .compatible = "renesas,pcie-r8a7779",
|
||||||
|
.data = rcar_pcie_phy_init_h1 },
|
||||||
{ .compatible = "renesas,pcie-r8a7790",
|
{ .compatible = "renesas,pcie-r8a7790",
|
||||||
.data = rcar_pcie_hw_init_gen2 },
|
.data = rcar_pcie_phy_init_gen2 },
|
||||||
{ .compatible = "renesas,pcie-r8a7791",
|
{ .compatible = "renesas,pcie-r8a7791",
|
||||||
.data = rcar_pcie_hw_init_gen2 },
|
.data = rcar_pcie_phy_init_gen2 },
|
||||||
{ .compatible = "renesas,pcie-rcar-gen2",
|
{ .compatible = "renesas,pcie-rcar-gen2",
|
||||||
.data = rcar_pcie_hw_init_gen2 },
|
.data = rcar_pcie_phy_init_gen2 },
|
||||||
{ .compatible = "renesas,pcie-r8a7795",
|
{ .compatible = "renesas,pcie-r8a7795",
|
||||||
.data = rcar_pcie_hw_init_gen3 },
|
.data = rcar_pcie_phy_init_gen3 },
|
||||||
{ .compatible = "renesas,pcie-rcar-gen3",
|
{ .compatible = "renesas,pcie-rcar-gen3",
|
||||||
.data = rcar_pcie_hw_init_gen3 },
|
.data = rcar_pcie_phy_init_gen3 },
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1128,7 +1125,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
|
||||||
struct rcar_pcie *pcie;
|
struct rcar_pcie *pcie;
|
||||||
unsigned int data;
|
unsigned int data;
|
||||||
int err;
|
int err;
|
||||||
int (*hw_init_fn)(struct rcar_pcie *);
|
int (*phy_init_fn)(struct rcar_pcie *);
|
||||||
struct pci_host_bridge *bridge;
|
struct pci_host_bridge *bridge;
|
||||||
|
|
||||||
bridge = pci_alloc_host_bridge(sizeof(*pcie));
|
bridge = pci_alloc_host_bridge(sizeof(*pcie));
|
||||||
|
@ -1162,10 +1159,15 @@ static int rcar_pcie_probe(struct platform_device *pdev)
|
||||||
if (err)
|
if (err)
|
||||||
goto err_pm_put;
|
goto err_pm_put;
|
||||||
|
|
||||||
/* Failure to get a link might just be that no cards are inserted */
|
phy_init_fn = of_device_get_match_data(dev);
|
||||||
hw_init_fn = of_device_get_match_data(dev);
|
err = phy_init_fn(pcie);
|
||||||
err = hw_init_fn(pcie);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
dev_err(dev, "failed to init PCIe PHY\n");
|
||||||
|
goto err_pm_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Failure to get a link might just be that no cards are inserted */
|
||||||
|
if (rcar_pcie_hw_init(pcie)) {
|
||||||
dev_info(dev, "PCIe link down\n");
|
dev_info(dev, "PCIe link down\n");
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
goto err_pm_put;
|
goto err_pm_put;
|
||||||
|
|
Loading…
Reference in New Issue