Re: [PATCH v7 3/3] phy: intel: Add driver support for ComboPhy

From: Dilip Kota
Date: Mon May 04 2020 - 04:26:33 EST



On 5/4/2020 3:29 PM, Vinod Koul wrote:
On 30-04-20, 15:15, Dilip Kota wrote:

+enum {
+ PHY_0,
+ PHY_1,
+ PHY_MAX_NUM
PHY_MAX_NUM = PHY_1?
Driver is using it for no. of PHYs/maximum PHY id.

Code snippets:

struct intel_combo_phy {
...
ÂÂÂÂÂÂÂ struct reset_controlÂÂÂ *phy_rst;
ÂÂÂÂÂÂÂ struct reset_controlÂÂÂ *core_rst;
ÂÂÂÂÂÂÂ struct intel_cbphy_iphy iphy[PHY_MAX_NUM];
...
}

....

static int intel_cbphy_create(struct intel_combo_phy *cbphy)
{
ÂÂÂÂÂÂÂ struct phy_provider *phy_provider;
ÂÂÂÂÂÂÂ struct device *dev = cbphy->dev;
ÂÂÂÂÂÂÂ struct intel_cbphy_iphy *iphy;
ÂÂÂÂÂÂÂ int i;

ÂÂÂÂÂÂÂ for (i = 0; i < PHY_MAX_NUM; i++) {

...


+static inline void combo_phy_w32_off_mask(void __iomem *base, unsigned int reg,
+ u32 mask, u32 val)
+{
+ u32 reg_val;
+
+ reg_val = readl(base + reg);
+ reg_val &= ~mask;
+ reg_val |= FIELD_PREP(mask, val);
+ writel(reg_val, base + reg);
bypassing regmap here... why?
It is not regmap address, one of the below two addresses are passed to this function.

struct intel_combo_phy {
...
ÂÂÂÂÂÂÂ void __iomemÂÂÂÂÂÂÂÂÂÂÂ *app_base;
ÂÂÂÂÂÂÂ void __iomemÂÂÂÂÂÂÂÂÂÂÂ *cr_base;
...
}



+static int intel_cbphy_calibrate(struct phy *phy)
+{
+ struct intel_cbphy_iphy *iphy = phy_get_drvdata(phy);
+ struct intel_combo_phy *cbphy = iphy->parent;
+ void __iomem *cr_base = cbphy->cr_base;
+ int val, ret, id;
+
+ if (cbphy->phy_mode != PHY_XPCS_MODE)
+ return 0;
+
+ id = PHY_ID(iphy);
+
+ /* trigger auto RX adaptation */
+ combo_phy_w32_off_mask(cr_base, CR_ADDR(PCS_XF_ATE_OVRD_IN_2, id),
+ ADAPT_REQ_MSK, 3);
+ /* Wait RX adaptation to finish */
+ ret = readl_poll_timeout(cr_base + CR_ADDR(PCS_XF_RX_ADAPT_ACK, id),
+ val, val & RX_ADAPT_ACK_BIT, 10, 5000);
+ if (ret)
+ dev_err(cbphy->dev, "RX Adaptation failed!\n");
you want to continue her and not return error?

Next step is stopping the Adaptation, it should be done in both error and success case.

Regards,
Dilip