aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2014-10-30 06:21:24 -0400
committerKishon Vijay Abraham I <kishon@ti.com>2014-11-13 01:19:43 -0500
commita98d41d6a1204b61bac03bb3eabdbc2fe93b495d (patch)
tree1e2c853c7b63141b8da96aec148060860c9ce782
parent6827a46f59942208d45e0c40e53f649bfc7792ed (diff)
phy: berlin-sata: Move PHY_BASE into private data struct
Currently, Berlin SATA PHY driver assumes PHY_BASE address being constant. While this PHY_BASE is correct for BG2Q, older BG2 PHY_BASE is different. Prepare the driver for BG2 support by moving the phy_base into private driver data. Acked-by: Antoine Ténart <antoine.tenart@free-electrons.com> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
-rw-r--r--drivers/phy/phy-berlin-sata.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/phy/phy-berlin-sata.c b/drivers/phy/phy-berlin-sata.c
index 69ced52d72aa..cdb46d1203a4 100644
--- a/drivers/phy/phy-berlin-sata.c
+++ b/drivers/phy/phy-berlin-sata.c
@@ -30,7 +30,7 @@
30#define MBUS_WRITE_REQUEST_SIZE_128 (BIT(2) << 16) 30#define MBUS_WRITE_REQUEST_SIZE_128 (BIT(2) << 16)
31#define MBUS_READ_REQUEST_SIZE_128 (BIT(2) << 19) 31#define MBUS_READ_REQUEST_SIZE_128 (BIT(2) << 19)
32 32
33#define PHY_BASE 0x200 33#define BG2Q_PHY_BASE 0x200
34 34
35/* register 0x01 */ 35/* register 0x01 */
36#define REF_FREF_SEL_25 BIT(0) 36#define REF_FREF_SEL_25 BIT(0)
@@ -61,15 +61,16 @@ struct phy_berlin_priv {
61 struct clk *clk; 61 struct clk *clk;
62 struct phy_berlin_desc **phys; 62 struct phy_berlin_desc **phys;
63 unsigned nphys; 63 unsigned nphys;
64 u32 phy_base;
64}; 65};
65 66
66static inline void phy_berlin_sata_reg_setbits(void __iomem *ctrl_reg, u32 reg, 67static inline void phy_berlin_sata_reg_setbits(void __iomem *ctrl_reg,
67 u32 mask, u32 val) 68 u32 phy_base, u32 reg, u32 mask, u32 val)
68{ 69{
69 u32 regval; 70 u32 regval;
70 71
71 /* select register */ 72 /* select register */
72 writel(PHY_BASE + reg, ctrl_reg + PORT_VSR_ADDR); 73 writel(phy_base + reg, ctrl_reg + PORT_VSR_ADDR);
73 74
74 /* set bits */ 75 /* set bits */
75 regval = readl(ctrl_reg + PORT_VSR_DATA); 76 regval = readl(ctrl_reg + PORT_VSR_DATA);
@@ -103,17 +104,20 @@ static int phy_berlin_sata_power_on(struct phy *phy)
103 writel(regval, priv->base + HOST_VSA_DATA); 104 writel(regval, priv->base + HOST_VSA_DATA);
104 105
105 /* set PHY mode and ref freq to 25 MHz */ 106 /* set PHY mode and ref freq to 25 MHz */
106 phy_berlin_sata_reg_setbits(ctrl_reg, 0x1, 0xff, 107 phy_berlin_sata_reg_setbits(ctrl_reg, priv->phy_base, 0x01,
107 REF_FREF_SEL_25 | PHY_MODE_SATA); 108 0x00ff, REF_FREF_SEL_25 | PHY_MODE_SATA);
108 109
109 /* set PHY up to 6 Gbps */ 110 /* set PHY up to 6 Gbps */
110 phy_berlin_sata_reg_setbits(ctrl_reg, 0x25, 0xc00, PHY_GEN_MAX_6_0); 111 phy_berlin_sata_reg_setbits(ctrl_reg, priv->phy_base, 0x25,
112 0x0c00, PHY_GEN_MAX_6_0);
111 113
112 /* set 40 bits width */ 114 /* set 40 bits width */
113 phy_berlin_sata_reg_setbits(ctrl_reg, 0x23, 0xc00, DATA_BIT_WIDTH_40); 115 phy_berlin_sata_reg_setbits(ctrl_reg, priv->phy_base, 0x23,
116 0x0c00, DATA_BIT_WIDTH_40);
114 117
115 /* use max pll rate */ 118 /* use max pll rate */
116 phy_berlin_sata_reg_setbits(ctrl_reg, 0x2, 0x0, USE_MAX_PLL_RATE); 119 phy_berlin_sata_reg_setbits(ctrl_reg, priv->phy_base, 0x02,
120 0x0000, USE_MAX_PLL_RATE);
117 121
118 /* set Gen3 controller speed */ 122 /* set Gen3 controller speed */
119 regval = readl(ctrl_reg + PORT_SCR_CTL); 123 regval = readl(ctrl_reg + PORT_SCR_CTL);
@@ -218,6 +222,8 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
218 if (!priv->phys) 222 if (!priv->phys)
219 return -ENOMEM; 223 return -ENOMEM;
220 224
225 priv->phy_base = BG2Q_PHY_BASE;
226
221 dev_set_drvdata(dev, priv); 227 dev_set_drvdata(dev, priv);
222 spin_lock_init(&priv->lock); 228 spin_lock_init(&priv->lock);
223 229