mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-14 04:46:01 +01:00
phy: stm32-usbphyc: add counter of PLL consumer
Add the counter of the PLL user n_pll_cons managed by the 2 functions stm32_usbphyc_pll_enable / stm32_usbphyc_pll_disable. This counter allow to remove the function stm32_usbphyc_is_init and it is a preliminary step for ck_usbo_48m introduction. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
This commit is contained in:
parent
0a1a755636
commit
3c2db62958
@ -144,6 +144,7 @@ struct stm32_usbphyc {
|
|||||||
bool init;
|
bool init;
|
||||||
bool powered;
|
bool powered;
|
||||||
} phys[MAX_PHYS];
|
} phys[MAX_PHYS];
|
||||||
|
int n_pll_cons;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void stm32_usbphyc_get_pll_params(u32 clk_rate,
|
static void stm32_usbphyc_get_pll_params(u32 clk_rate,
|
||||||
@ -203,18 +204,6 @@ static int stm32_usbphyc_pll_init(struct stm32_usbphyc *usbphyc)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool stm32_usbphyc_is_init(struct stm32_usbphyc *usbphyc)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_PHYS; i++) {
|
|
||||||
if (usbphyc->phys[i].init)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool stm32_usbphyc_is_powered(struct stm32_usbphyc *usbphyc)
|
static bool stm32_usbphyc_is_powered(struct stm32_usbphyc *usbphyc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -227,18 +216,17 @@ static bool stm32_usbphyc_is_powered(struct stm32_usbphyc *usbphyc)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stm32_usbphyc_phy_init(struct phy *phy)
|
static int stm32_usbphyc_pll_enable(struct stm32_usbphyc *usbphyc)
|
||||||
{
|
{
|
||||||
struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev);
|
|
||||||
struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + phy->id;
|
|
||||||
bool pllen = readl(usbphyc->base + STM32_USBPHYC_PLL) & PLLEN ?
|
bool pllen = readl(usbphyc->base + STM32_USBPHYC_PLL) & PLLEN ?
|
||||||
true : false;
|
true : false;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
dev_dbg(phy->dev, "phy ID = %lu\n", phy->id);
|
/* Check if one consumer has already configured the pll */
|
||||||
/* Check if one phy port has already configured the pll */
|
if (pllen && usbphyc->n_pll_cons) {
|
||||||
if (pllen && stm32_usbphyc_is_init(usbphyc))
|
usbphyc->n_pll_cons++;
|
||||||
goto initialized;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (usbphyc->vdda1v1) {
|
if (usbphyc->vdda1v1) {
|
||||||
ret = regulator_set_enable(usbphyc->vdda1v1, true);
|
ret = regulator_set_enable(usbphyc->vdda1v1, true);
|
||||||
@ -269,23 +257,19 @@ static int stm32_usbphyc_phy_init(struct phy *phy)
|
|||||||
if (!(readl(usbphyc->base + STM32_USBPHYC_PLL) & PLLEN))
|
if (!(readl(usbphyc->base + STM32_USBPHYC_PLL) & PLLEN))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
initialized:
|
usbphyc->n_pll_cons++;
|
||||||
usbphyc_phy->init = true;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stm32_usbphyc_phy_exit(struct phy *phy)
|
static int stm32_usbphyc_pll_disable(struct stm32_usbphyc *usbphyc)
|
||||||
{
|
{
|
||||||
struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev);
|
|
||||||
struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + phy->id;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
dev_dbg(phy->dev, "phy ID = %lu\n", phy->id);
|
usbphyc->n_pll_cons--;
|
||||||
usbphyc_phy->init = false;
|
|
||||||
|
|
||||||
/* Check if other phy port requires pllen */
|
/* Check if other consumer requires pllen */
|
||||||
if (stm32_usbphyc_is_init(usbphyc))
|
if (usbphyc->n_pll_cons)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clrbits_le32(usbphyc->base + STM32_USBPHYC_PLL, PLLEN);
|
clrbits_le32(usbphyc->base + STM32_USBPHYC_PLL, PLLEN);
|
||||||
@ -314,6 +298,42 @@ static int stm32_usbphyc_phy_exit(struct phy *phy)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int stm32_usbphyc_phy_init(struct phy *phy)
|
||||||
|
{
|
||||||
|
struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev);
|
||||||
|
struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + phy->id;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
dev_dbg(phy->dev, "phy ID = %lu\n", phy->id);
|
||||||
|
if (usbphyc_phy->init)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ret = stm32_usbphyc_pll_enable(usbphyc);
|
||||||
|
if (ret)
|
||||||
|
return log_ret(ret);
|
||||||
|
|
||||||
|
usbphyc_phy->init = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int stm32_usbphyc_phy_exit(struct phy *phy)
|
||||||
|
{
|
||||||
|
struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev);
|
||||||
|
struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + phy->id;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
dev_dbg(phy->dev, "phy ID = %lu\n", phy->id);
|
||||||
|
if (!usbphyc_phy->init)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ret = stm32_usbphyc_pll_disable(usbphyc);
|
||||||
|
|
||||||
|
usbphyc_phy->init = false;
|
||||||
|
|
||||||
|
return log_ret(ret);
|
||||||
|
}
|
||||||
|
|
||||||
static int stm32_usbphyc_phy_power_on(struct phy *phy)
|
static int stm32_usbphyc_phy_power_on(struct phy *phy)
|
||||||
{
|
{
|
||||||
struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev);
|
struct stm32_usbphyc *usbphyc = dev_get_priv(phy->dev);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user