• Home
  • Raw
  • Download

Lines Matching full:phy

11 #include <linux/phy/phy.h>
41 static inline u32 mphy_readl(struct ufs_mtk_phy *phy, u32 reg) in mphy_readl() argument
43 return readl(phy->mmio + reg); in mphy_readl()
46 static inline void mphy_writel(struct ufs_mtk_phy *phy, u32 val, u32 reg) in mphy_writel() argument
48 writel(val, phy->mmio + reg); in mphy_writel()
51 static void mphy_set_bit(struct ufs_mtk_phy *phy, u32 reg, u32 bit) in mphy_set_bit() argument
55 val = mphy_readl(phy, reg); in mphy_set_bit()
57 mphy_writel(phy, val, reg); in mphy_set_bit()
60 static void mphy_clr_bit(struct ufs_mtk_phy *phy, u32 reg, u32 bit) in mphy_clr_bit() argument
64 val = mphy_readl(phy, reg); in mphy_clr_bit()
66 mphy_writel(phy, val, reg); in mphy_clr_bit()
69 static struct ufs_mtk_phy *get_ufs_mtk_phy(struct phy *generic_phy) in get_ufs_mtk_phy()
74 static int ufs_mtk_phy_clk_init(struct ufs_mtk_phy *phy) in ufs_mtk_phy_clk_init() argument
76 struct device *dev = phy->dev; in ufs_mtk_phy_clk_init()
78 phy->unipro_clk = devm_clk_get(dev, "unipro"); in ufs_mtk_phy_clk_init()
79 if (IS_ERR(phy->unipro_clk)) { in ufs_mtk_phy_clk_init()
81 return PTR_ERR(phy->unipro_clk); in ufs_mtk_phy_clk_init()
84 phy->mp_clk = devm_clk_get(dev, "mp"); in ufs_mtk_phy_clk_init()
85 if (IS_ERR(phy->mp_clk)) { in ufs_mtk_phy_clk_init()
87 return PTR_ERR(phy->mp_clk); in ufs_mtk_phy_clk_init()
93 static void ufs_mtk_phy_set_active(struct ufs_mtk_phy *phy) in ufs_mtk_phy_set_active() argument
96 mphy_set_bit(phy, MP_GLB_DIG_8C, PLL_PWR_ON); in ufs_mtk_phy_set_active()
97 mphy_clr_bit(phy, MP_GLB_DIG_8C, FRC_FRC_PWR_ON); in ufs_mtk_phy_set_active()
100 mphy_clr_bit(phy, MP_GLB_DIG_8C, PLL_ISO_EN); in ufs_mtk_phy_set_active()
101 mphy_clr_bit(phy, MP_GLB_DIG_8C, FRC_PLL_ISO_EN); in ufs_mtk_phy_set_active()
104 mphy_set_bit(phy, MP_LN_RX_44, CDR_PWR_ON); in ufs_mtk_phy_set_active()
105 mphy_clr_bit(phy, MP_LN_RX_44, FRC_CDR_PWR_ON); in ufs_mtk_phy_set_active()
108 mphy_clr_bit(phy, MP_LN_RX_44, CDR_ISO_EN); in ufs_mtk_phy_set_active()
109 mphy_clr_bit(phy, MP_LN_RX_44, FRC_CDR_ISO_EN); in ufs_mtk_phy_set_active()
112 mphy_set_bit(phy, MP_LN_DIG_RX_AC, RX_SQ_EN); in ufs_mtk_phy_set_active()
113 mphy_clr_bit(phy, MP_LN_DIG_RX_AC, FRC_RX_SQ_EN); in ufs_mtk_phy_set_active()
119 mphy_clr_bit(phy, MP_LN_DIG_RX_9C, FSM_DIFZ_FRC); in ufs_mtk_phy_set_active()
122 static void ufs_mtk_phy_set_deep_hibern(struct ufs_mtk_phy *phy) in ufs_mtk_phy_set_deep_hibern() argument
125 mphy_set_bit(phy, MP_LN_DIG_RX_9C, FSM_DIFZ_FRC); in ufs_mtk_phy_set_deep_hibern()
128 mphy_set_bit(phy, MP_LN_DIG_RX_AC, FRC_RX_SQ_EN); in ufs_mtk_phy_set_deep_hibern()
129 mphy_clr_bit(phy, MP_LN_DIG_RX_AC, RX_SQ_EN); in ufs_mtk_phy_set_deep_hibern()
132 mphy_set_bit(phy, MP_LN_RX_44, FRC_CDR_ISO_EN); in ufs_mtk_phy_set_deep_hibern()
133 mphy_set_bit(phy, MP_LN_RX_44, CDR_ISO_EN); in ufs_mtk_phy_set_deep_hibern()
136 mphy_set_bit(phy, MP_LN_RX_44, FRC_CDR_PWR_ON); in ufs_mtk_phy_set_deep_hibern()
137 mphy_clr_bit(phy, MP_LN_RX_44, CDR_PWR_ON); in ufs_mtk_phy_set_deep_hibern()
140 mphy_set_bit(phy, MP_GLB_DIG_8C, FRC_PLL_ISO_EN); in ufs_mtk_phy_set_deep_hibern()
141 mphy_set_bit(phy, MP_GLB_DIG_8C, PLL_ISO_EN); in ufs_mtk_phy_set_deep_hibern()
144 mphy_set_bit(phy, MP_GLB_DIG_8C, FRC_FRC_PWR_ON); in ufs_mtk_phy_set_deep_hibern()
145 mphy_clr_bit(phy, MP_GLB_DIG_8C, PLL_PWR_ON); in ufs_mtk_phy_set_deep_hibern()
148 static int ufs_mtk_phy_power_on(struct phy *generic_phy) in ufs_mtk_phy_power_on()
150 struct ufs_mtk_phy *phy = get_ufs_mtk_phy(generic_phy); in ufs_mtk_phy_power_on() local
153 ret = clk_prepare_enable(phy->unipro_clk); in ufs_mtk_phy_power_on()
155 dev_err(phy->dev, "unipro_clk enable failed %d\n", ret); in ufs_mtk_phy_power_on()
159 ret = clk_prepare_enable(phy->mp_clk); in ufs_mtk_phy_power_on()
161 dev_err(phy->dev, "mp_clk enable failed %d\n", ret); in ufs_mtk_phy_power_on()
165 ufs_mtk_phy_set_active(phy); in ufs_mtk_phy_power_on()
170 clk_disable_unprepare(phy->unipro_clk); in ufs_mtk_phy_power_on()
175 static int ufs_mtk_phy_power_off(struct phy *generic_phy) in ufs_mtk_phy_power_off()
177 struct ufs_mtk_phy *phy = get_ufs_mtk_phy(generic_phy); in ufs_mtk_phy_power_off() local
179 ufs_mtk_phy_set_deep_hibern(phy); in ufs_mtk_phy_power_off()
181 clk_disable_unprepare(phy->unipro_clk); in ufs_mtk_phy_power_off()
182 clk_disable_unprepare(phy->mp_clk); in ufs_mtk_phy_power_off()
196 struct phy *generic_phy; in ufs_mtk_phy_probe()
199 struct ufs_mtk_phy *phy; in ufs_mtk_phy_probe() local
202 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); in ufs_mtk_phy_probe()
203 if (!phy) in ufs_mtk_phy_probe()
207 phy->mmio = devm_ioremap_resource(dev, res); in ufs_mtk_phy_probe()
208 if (IS_ERR(phy->mmio)) in ufs_mtk_phy_probe()
209 return PTR_ERR(phy->mmio); in ufs_mtk_phy_probe()
211 phy->dev = dev; in ufs_mtk_phy_probe()
213 ret = ufs_mtk_phy_clk_init(phy); in ufs_mtk_phy_probe()
221 phy_set_drvdata(generic_phy, phy); in ufs_mtk_phy_probe()