TI's J721E SoC uses Cadence Sierra SERDES for USB, PCIe and SGMII.
TI has a wrapper named WIZ to control input signals to Sierra and
Torrent SERDES.
This patch series:
1) Add support to WIZ module present in TI's J721E SoC
2) Adapt Cadence Sierra PHY driver to be used for J721E SoC
Changes from v1:
*) Change the dt binding Documentation of WIZ wrapper to YAML format
*) Fix an issue in Sierra while doimg rmmod
Anil Varughese (1):
phy: cadence: Sierra: Configure both lane cdb and common cdb registers
for external SSC
Kishon Vijay Abraham I (13):
dt-bindings: phy: Sierra: Add bindings for Sierra in TI's J721E
phy: cadence: Sierra: Make "phy_clk" and "sierra_apb" optional
resources
phy: cadence: Sierra: Use "regmap" for read and write to Sierra
registers
phy: cadence: Sierra: Add support for SERDES_16G used in J721E SoC
phy: cadence: Sierra: Make cdns_sierra_phy_init() as phy_ops
phy: cadence: Sierra: Modify register macro names to be in sync with
Sierra user guide
phy: cadence: Sierra: Get reset control "array" for each link
phy: cadence: Sierra: Check for PLL lock during PHY power on
phy: cadence: Sierra: Change MAX_LANES of Sierra to 16
phy: cadence: Sierra: Set cmn_refclk/cmn_refclk1 frequency to 25MHz
phy: cadence: Sierra: Use correct dev pointer in
cdns_sierra_phy_remove()
dt-bindings: phy: Document WIZ (SERDES wrapper) bindings
phy: ti: j721e-wiz: Add support for WIZ module present in TI J721E SoC
.../bindings/phy/phy-cadence-sierra.txt | 13 +-
.../bindings/phy/ti,phy-j721e-wiz.yaml | 159 +++
drivers/phy/cadence/phy-cadence-sierra.c | 697 +++++++++++---
drivers/phy/ti/Kconfig | 15 +
drivers/phy/ti/Makefile | 1 +
drivers/phy/ti/phy-j721e-wiz.c | 904 ++++++++++++++++++
6 files changed, 1650 insertions(+), 139 deletions(-)
create mode 100644 Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
create mode 100644 drivers/phy/ti/phy-j721e-wiz.c
--
2.17.1
Add DT binding documentation for Sierra PHY IP used in TI's J721E
SoC.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
.../devicetree/bindings/phy/phy-cadence-sierra.txt | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt b/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
index 6e1b47bfce43..bf90ef7e005e 100644
--- a/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
+++ b/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
@@ -2,21 +2,24 @@ Cadence Sierra PHY
-----------------------
Required properties:
-- compatible: cdns,sierra-phy-t0
-- clocks: Must contain an entry in clock-names.
- See ../clocks/clock-bindings.txt for details.
-- clock-names: Must be "phy_clk"
+- compatible: Must be "cdns,sierra-phy-t0" for Sierra in Cadence platform
+ Must be "ti,sierra-phy-t0" for Sierra in TI's J721E SoC.
- resets: Must contain an entry for each in reset-names.
See ../reset/reset.txt for details.
- reset-names: Must include "sierra_reset" and "sierra_apb".
"sierra_reset" must control the reset line to the PHY.
"sierra_apb" must control the reset line to the APB PHY
- interface.
+ interface ("sierra_apb" is optional).
- reg: register range for the PHY.
- #address-cells: Must be 1
- #size-cells: Must be 0
Optional properties:
+- clocks: Must contain an entry in clock-names.
+ See ../clocks/clock-bindings.txt for details.
+- clock-names: Must be "phy_clk". Must contain "cmn_refclk" and
+ "cmn_refclk1" for configuring the frequency of the
+ clock to the lanes.
- cdns,autoconf: A boolean property whose presence indicates that the
PHY registers will be configured by hardware. If not
present, all sub-node optional properties must be
--
2.17.1
Certain platforms like TI J721E using Cadence Sierra Serdes
doesn't provide explicit phy_clk and reset (APB reset) control.
Make them optional here.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index de10402f2931..bed68c25682f 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -193,7 +193,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, sp);
- sp->clk = devm_clk_get(dev, "phy_clk");
+ sp->clk = devm_clk_get_optional(dev, "phy_clk");
if (IS_ERR(sp->clk)) {
dev_err(dev, "failed to get clock phy_clk\n");
return PTR_ERR(sp->clk);
@@ -205,7 +205,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
return PTR_ERR(sp->phy_rst);
}
- sp->apb_rst = devm_reset_control_get(dev, "sierra_apb");
+ sp->apb_rst = devm_reset_control_get_optional(dev, "sierra_apb");
if (IS_ERR(sp->apb_rst)) {
dev_err(dev, "failed to get apb reset\n");
return PTR_ERR(sp->apb_rst);
--
2.17.1
Use "regmap" for read and write to Sierra registers. This is in
perparation for adding SERDES_16G support present in TI's J721E
SoC.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 289 ++++++++++++++++++-----
1 file changed, 235 insertions(+), 54 deletions(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index bed68c25682f..d0e7ae1c67b1 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -22,49 +22,61 @@
#include <dt-bindings/phy/phy.h>
/* PHY register offsets */
-#define SIERRA_PHY_PLL_CFG (0xc00e << 2)
-#define SIERRA_DET_STANDEC_A (0x4000 << 2)
-#define SIERRA_DET_STANDEC_B (0x4001 << 2)
-#define SIERRA_DET_STANDEC_C (0x4002 << 2)
-#define SIERRA_DET_STANDEC_D (0x4003 << 2)
-#define SIERRA_DET_STANDEC_E (0x4004 << 2)
-#define SIERRA_PSM_LANECAL (0x4008 << 2)
-#define SIERRA_PSM_DIAG (0x4015 << 2)
-#define SIERRA_PSC_TX_A0 (0x4028 << 2)
-#define SIERRA_PSC_TX_A1 (0x4029 << 2)
-#define SIERRA_PSC_TX_A2 (0x402A << 2)
-#define SIERRA_PSC_TX_A3 (0x402B << 2)
-#define SIERRA_PSC_RX_A0 (0x4030 << 2)
-#define SIERRA_PSC_RX_A1 (0x4031 << 2)
-#define SIERRA_PSC_RX_A2 (0x4032 << 2)
-#define SIERRA_PSC_RX_A3 (0x4033 << 2)
-#define SIERRA_PLLCTRL_SUBRATE (0x403A << 2)
-#define SIERRA_PLLCTRL_GEN_D (0x403E << 2)
-#define SIERRA_DRVCTRL_ATTEN (0x406A << 2)
-#define SIERRA_CLKPATHCTRL_TMR (0x4081 << 2)
-#define SIERRA_RX_CREQ_FLTR_A_MODE1 (0x4087 << 2)
-#define SIERRA_RX_CREQ_FLTR_A_MODE0 (0x4088 << 2)
-#define SIERRA_CREQ_CCLKDET_MODE01 (0x408E << 2)
-#define SIERRA_RX_CTLE_MAINTENANCE (0x4091 << 2)
-#define SIERRA_CREQ_FSMCLK_SEL (0x4092 << 2)
-#define SIERRA_CTLELUT_CTRL (0x4098 << 2)
-#define SIERRA_DFE_ECMP_RATESEL (0x40C0 << 2)
-#define SIERRA_DFE_SMP_RATESEL (0x40C1 << 2)
-#define SIERRA_DEQ_VGATUNE_CTRL (0x40E1 << 2)
-#define SIERRA_TMRVAL_MODE3 (0x416E << 2)
-#define SIERRA_TMRVAL_MODE2 (0x416F << 2)
-#define SIERRA_TMRVAL_MODE1 (0x4170 << 2)
-#define SIERRA_TMRVAL_MODE0 (0x4171 << 2)
-#define SIERRA_PICNT_MODE1 (0x4174 << 2)
-#define SIERRA_CPI_OUTBUF_RATESEL (0x417C << 2)
-#define SIERRA_LFPSFILT_NS (0x418A << 2)
-#define SIERRA_LFPSFILT_RD (0x418B << 2)
-#define SIERRA_LFPSFILT_MP (0x418C << 2)
-#define SIERRA_SDFILT_H2L_A (0x4191 << 2)
+#define SIERRA_COMMON_CDB_OFFSET 0x0
+#define SIERRA_MACRO_ID_REG 0x0
+
+#define SIERRA_LANE_CDB_OFFSET(ln, offset) \
+ (0x4000 + ((ln) * (0x800 >> (2 - (offset)))))
+#define SIERRA_DET_STANDEC_A 0x000
+#define SIERRA_DET_STANDEC_B 0x001
+#define SIERRA_DET_STANDEC_C 0x002
+#define SIERRA_DET_STANDEC_D 0x003
+#define SIERRA_DET_STANDEC_E 0x004
+#define SIERRA_PSM_LANECAL 0x008
+#define SIERRA_PSM_DIAG 0x015
+#define SIERRA_PSC_TX_A0 0x028
+#define SIERRA_PSC_TX_A1 0x029
+#define SIERRA_PSC_TX_A2 0x02A
+#define SIERRA_PSC_TX_A3 0x02B
+#define SIERRA_PSC_RX_A0 0x030
+#define SIERRA_PSC_RX_A1 0x031
+#define SIERRA_PSC_RX_A2 0x032
+#define SIERRA_PSC_RX_A3 0x033
+#define SIERRA_PLLCTRL_SUBRATE 0x03A
+#define SIERRA_PLLCTRL_GEN_D 0x03E
+#define SIERRA_DRVCTRL_ATTEN 0x06A
+#define SIERRA_CLKPATHCTRL_TMR 0x081
+#define SIERRA_RX_CREQ_FLTR_A_MODE1 0x087
+#define SIERRA_RX_CREQ_FLTR_A_MODE0 0x088
+#define SIERRA_CREQ_CCLKDET_MODE01 0x08E
+#define SIERRA_RX_CTLE_MAINTENANCE 0x091
+#define SIERRA_CREQ_FSMCLK_SEL 0x092
+#define SIERRA_CTLELUT_CTRL 0x098
+#define SIERRA_DFE_ECMP_RATESEL 0x0C0
+#define SIERRA_DFE_SMP_RATESEL 0x0C1
+#define SIERRA_DEQ_VGATUNE_CTRL 0x0E1
+#define SIERRA_TMRVAL_MODE3 0x16E
+#define SIERRA_TMRVAL_MODE2 0x16F
+#define SIERRA_TMRVAL_MODE1 0x170
+#define SIERRA_TMRVAL_MODE0 0x171
+#define SIERRA_PICNT_MODE1 0x174
+#define SIERRA_CPI_OUTBUF_RATESEL 0x17C
+#define SIERRA_LFPSFILT_NS 0x18A
+#define SIERRA_LFPSFILT_RD 0x18B
+#define SIERRA_LFPSFILT_MP 0x18C
+#define SIERRA_SDFILT_H2L_A 0x191
+
+#define SIERRA_PHY_CONFIG_CTRL_OFFSET 0xc000
+#define SIERRA_PHY_PLL_CFG 0xe
#define SIERRA_MACRO_ID 0x00007364
#define SIERRA_MAX_LANES 4
+static const struct reg_field macro_id_type =
+ REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
+static const struct reg_field phy_pll_cfg_1 =
+ REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
+
struct cdns_sierra_inst {
struct phy *phy;
u32 phy_type;
@@ -80,28 +92,93 @@ struct cdns_reg_pairs {
struct cdns_sierra_data {
u32 id_value;
+ u8 block_offset_shift;
+ u8 reg_offset_shift;
u32 pcie_regs;
u32 usb_regs;
struct cdns_reg_pairs *pcie_vals;
struct cdns_reg_pairs *usb_vals;
};
-struct cdns_sierra_phy {
+struct cdns_regmap_cdb_context {
struct device *dev;
void __iomem *base;
+ u8 reg_offset_shift;
+};
+
+struct cdns_sierra_phy {
+ struct device *dev;
+ struct regmap *regmap;
struct cdns_sierra_data *init_data;
struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
struct reset_control *phy_rst;
struct reset_control *apb_rst;
+ struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
+ struct regmap *regmap_phy_config_ctrl;
+ struct regmap *regmap_common_cdb;
+ struct regmap_field *macro_id_type;
+ struct regmap_field *phy_pll_cfg_1;
struct clk *clk;
int nsubnodes;
bool autoconf;
};
+static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
+{
+ struct cdns_regmap_cdb_context *ctx = context;
+ u32 offset = reg << ctx->reg_offset_shift;
+
+ writew(val, ctx->base + offset);
+
+ return 0;
+}
+
+static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
+{
+ struct cdns_regmap_cdb_context *ctx = context;
+ u32 offset = reg << ctx->reg_offset_shift;
+
+ *val = readw(ctx->base + offset);
+ return 0;
+}
+
+#define SIERRA_LANE_CDB_REGMAP_CONF(n) \
+{ \
+ .name = "sierra_lane" n "_cdb", \
+ .reg_stride = 1, \
+ .fast_io = true, \
+ .reg_write = cdns_regmap_write, \
+ .reg_read = cdns_regmap_read, \
+}
+
+static struct regmap_config cdns_sierra_lane_cdb_config[] = {
+ SIERRA_LANE_CDB_REGMAP_CONF("0"),
+ SIERRA_LANE_CDB_REGMAP_CONF("1"),
+ SIERRA_LANE_CDB_REGMAP_CONF("2"),
+ SIERRA_LANE_CDB_REGMAP_CONF("3"),
+};
+
+static struct regmap_config cdns_sierra_common_cdb_config = {
+ .name = "sierra_common_cdb",
+ .reg_stride = 1,
+ .fast_io = true,
+ .reg_write = cdns_regmap_write,
+ .reg_read = cdns_regmap_read,
+};
+
+static struct regmap_config cdns_sierra_phy_config_ctrl_config = {
+ .name = "sierra_phy_config_ctrl",
+ .reg_stride = 1,
+ .fast_io = true,
+ .reg_write = cdns_regmap_write,
+ .reg_read = cdns_regmap_read,
+};
+
static void cdns_sierra_phy_init(struct phy *gphy)
{
struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
+ struct regmap *regmap = phy->regmap;
int i, j;
struct cdns_reg_pairs *vals;
u32 num_regs;
@@ -115,10 +192,12 @@ static void cdns_sierra_phy_init(struct phy *gphy)
} else {
return;
}
- for (i = 0; i < ins->num_lanes; i++)
- for (j = 0; j < num_regs ; j++)
- writel(vals[j].val, phy->base +
- vals[j].off + (i + ins->mlane) * 0x800);
+ for (i = 0; i < ins->num_lanes; i++) {
+ for (j = 0; j < num_regs ; j++) {
+ regmap = phy->regmap_lane_cdb[i + ins->mlane];
+ regmap_write(regmap, vals[j].off, vals[j].val);
+ }
+ }
}
static int cdns_sierra_phy_on(struct phy *gphy)
@@ -159,37 +238,136 @@ static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
static const struct of_device_id cdns_sierra_id_table[];
+static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
+ u32 block_offset, u8 block_offset_shift,
+ u8 reg_offset_shift,
+ const struct regmap_config *config)
+{
+ struct cdns_regmap_cdb_context *ctx;
+
+ ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return ERR_PTR(-ENOMEM);
+
+ ctx->dev = dev;
+ ctx->base = base + (block_offset << block_offset_shift);
+ ctx->reg_offset_shift = reg_offset_shift;
+
+ return devm_regmap_init(dev, NULL, ctx, config);
+}
+
+static int cdns_regfield_init(struct cdns_sierra_phy *sp)
+{
+ struct device *dev = sp->dev;
+ struct regmap_field *field;
+ struct regmap *regmap;
+
+ regmap = sp->regmap_common_cdb;
+ field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
+ if (IS_ERR(field)) {
+ dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
+ return PTR_ERR(field);
+ }
+ sp->macro_id_type = field;
+
+ regmap = sp->regmap_phy_config_ctrl;
+ field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
+ if (IS_ERR(field)) {
+ dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
+ return PTR_ERR(field);
+ }
+ sp->phy_pll_cfg_1 = field;
+
+ return 0;
+}
+
+static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
+ void __iomem *base, u8 block_offset_shift,
+ u8 reg_offset_shift)
+{
+ struct device *dev = sp->dev;
+ struct regmap *regmap;
+ u32 block_offset;
+ int i;
+
+ for (i = 0; i < SIERRA_MAX_LANES; i++) {
+ block_offset = SIERRA_LANE_CDB_OFFSET(i, reg_offset_shift);
+ regmap = cdns_regmap_init(dev, base, block_offset,
+ block_offset_shift, reg_offset_shift,
+ &cdns_sierra_lane_cdb_config[i]);
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "Failed to init lane CDB regmap\n");
+ return PTR_ERR(regmap);
+ }
+ sp->regmap_lane_cdb[i] = regmap;
+ }
+
+ regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
+ block_offset_shift, reg_offset_shift,
+ &cdns_sierra_common_cdb_config);
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "Failed to init common CDB regmap\n");
+ return PTR_ERR(regmap);
+ }
+ sp->regmap_common_cdb = regmap;
+
+ regmap = cdns_regmap_init(dev, base, SIERRA_PHY_CONFIG_CTRL_OFFSET,
+ block_offset_shift, reg_offset_shift,
+ &cdns_sierra_phy_config_ctrl_config);
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "Failed to init PHY config and control regmap\n");
+ return PTR_ERR(regmap);
+ }
+ sp->regmap_phy_config_ctrl = regmap;
+
+ return 0;
+}
+
static int cdns_sierra_phy_probe(struct platform_device *pdev)
{
struct cdns_sierra_phy *sp;
struct phy_provider *phy_provider;
struct device *dev = &pdev->dev;
const struct of_device_id *match;
+ struct cdns_sierra_data *data;
+ unsigned int id_value;
struct resource *res;
int i, ret, node = 0;
+ void __iomem *base;
struct device_node *dn = dev->of_node, *child;
if (of_get_child_count(dn) == 0)
return -ENODEV;
+ /* Get init data for this PHY */
+ match = of_match_device(cdns_sierra_id_table, dev);
+ if (!match)
+ return -EINVAL;
+
+ data = (struct cdns_sierra_data *)match->data;
+
sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL);
if (!sp)
return -ENOMEM;
dev_set_drvdata(dev, sp);
sp->dev = dev;
+ sp->init_data = data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- sp->base = devm_ioremap_resource(dev, res);
- if (IS_ERR(sp->base)) {
+ base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(base)) {
dev_err(dev, "missing \"reg\"\n");
- return PTR_ERR(sp->base);
+ return PTR_ERR(base);
}
- /* Get init data for this PHY */
- match = of_match_device(cdns_sierra_id_table, dev);
- if (!match)
- return -EINVAL;
- sp->init_data = (struct cdns_sierra_data *)match->data;
+ ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
+ data->reg_offset_shift);
+ if (ret)
+ return ret;
+
+ ret = cdns_regfield_init(sp);
+ if (ret)
+ return ret;
platform_set_drvdata(pdev, sp);
@@ -219,7 +397,8 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
reset_control_deassert(sp->apb_rst);
/* Check that PHY is present */
- if (sp->init_data->id_value != readl(sp->base)) {
+ regmap_field_read(sp->macro_id_type, &id_value);
+ if (sp->init_data->id_value != id_value) {
ret = -EINVAL;
goto clk_disable;
}
@@ -267,7 +446,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
/* If more than one subnode, configure the PHY as multilink */
if (!sp->autoconf && sp->nsubnodes > 1)
- writel(2, sp->base + SIERRA_PHY_PLL_CFG);
+ regmap_field_write(sp->phy_pll_cfg_1, 0x1);
pm_runtime_enable(dev);
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
@@ -364,6 +543,8 @@ static struct cdns_reg_pairs cdns_pcie_regs[] = {
static const struct cdns_sierra_data cdns_map_sierra = {
SIERRA_MACRO_ID,
+ 0x2,
+ 0x2,
ARRAY_SIZE(cdns_pcie_regs),
ARRAY_SIZE(cdns_usb_regs),
cdns_pcie_regs,
--
2.17.1
A link may have multiple lanes each with a separate reset. Get
reset control "array" in order to reset all the lanes associated
with the link.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index b555d4c3633b..2648a01f90b3 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -497,7 +497,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
struct phy *gphy;
sp->phys[node].lnk_rst =
- of_reset_control_get_exclusive_by_index(child, 0);
+ of_reset_control_array_get_exclusive(child);
if (IS_ERR(sp->phys[node].lnk_rst)) {
dev_err(dev, "failed to get reset %s\n",
--
2.17.1
Instead of invoking cdns_sierra_phy_init() from probe, add it in
phy_ops so that it's initialized when the PHY consumer invokes
phy_init()
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index 89a3b732c311..5c617248841f 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -174,7 +174,7 @@ static struct regmap_config cdns_sierra_phy_config_ctrl_config = {
.reg_read = cdns_regmap_read,
};
-static void cdns_sierra_phy_init(struct phy *gphy)
+static int cdns_sierra_phy_init(struct phy *gphy)
{
struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
@@ -183,6 +183,10 @@ static void cdns_sierra_phy_init(struct phy *gphy)
struct cdns_reg_pairs *vals;
u32 num_regs;
+ /* Initialise the PHY registers, unless auto configured */
+ if (phy->autoconf)
+ return 0;
+
if (ins->phy_type == PHY_TYPE_PCIE) {
num_regs = phy->init_data->pcie_regs;
vals = phy->init_data->pcie_vals;
@@ -190,7 +194,7 @@ static void cdns_sierra_phy_init(struct phy *gphy)
num_regs = phy->init_data->usb_regs;
vals = phy->init_data->usb_vals;
} else {
- return;
+ return -EINVAL;
}
for (i = 0; i < ins->num_lanes; i++) {
for (j = 0; j < num_regs ; j++) {
@@ -198,6 +202,8 @@ static void cdns_sierra_phy_init(struct phy *gphy)
regmap_write(regmap, vals[j].off, vals[j].val);
}
}
+
+ return 0;
}
static int cdns_sierra_phy_on(struct phy *gphy)
@@ -216,6 +222,7 @@ static int cdns_sierra_phy_off(struct phy *gphy)
}
static const struct phy_ops ops = {
+ .init = cdns_sierra_phy_init,
.power_on = cdns_sierra_phy_on,
.power_off = cdns_sierra_phy_off,
.owner = THIS_MODULE,
@@ -436,10 +443,6 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
sp->phys[node].phy = gphy;
phy_set_drvdata(gphy, &sp->phys[node]);
- /* Initialise the PHY registers, unless auto configured */
- if (!sp->autoconf)
- cdns_sierra_phy_init(gphy);
-
node++;
}
sp->nsubnodes = node;
--
2.17.1
Sierra SERDES IP supports upto 16 lanes (though not all of it
will be enabled in a platform). Allow Sierra driver to support a
maximum of upto 16 lanes.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index 82f7617b2dac..dd54a0ab89b7 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -139,7 +139,7 @@
#define SIERRA_PHY_PLL_CFG 0xe
#define SIERRA_MACRO_ID 0x00007364
-#define SIERRA_MAX_LANES 4
+#define SIERRA_MAX_LANES 16
#define PLL_LOCK_TIME 100000
static const struct reg_field macro_id_type =
@@ -197,6 +197,7 @@ struct cdns_sierra_phy {
struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
struct clk *clk;
int nsubnodes;
+ u32 num_lanes;
bool autoconf;
};
@@ -233,6 +234,18 @@ static struct regmap_config cdns_sierra_lane_cdb_config[] = {
SIERRA_LANE_CDB_REGMAP_CONF("1"),
SIERRA_LANE_CDB_REGMAP_CONF("2"),
SIERRA_LANE_CDB_REGMAP_CONF("3"),
+ SIERRA_LANE_CDB_REGMAP_CONF("4"),
+ SIERRA_LANE_CDB_REGMAP_CONF("5"),
+ SIERRA_LANE_CDB_REGMAP_CONF("6"),
+ SIERRA_LANE_CDB_REGMAP_CONF("7"),
+ SIERRA_LANE_CDB_REGMAP_CONF("8"),
+ SIERRA_LANE_CDB_REGMAP_CONF("9"),
+ SIERRA_LANE_CDB_REGMAP_CONF("10"),
+ SIERRA_LANE_CDB_REGMAP_CONF("11"),
+ SIERRA_LANE_CDB_REGMAP_CONF("12"),
+ SIERRA_LANE_CDB_REGMAP_CONF("13"),
+ SIERRA_LANE_CDB_REGMAP_CONF("14"),
+ SIERRA_LANE_CDB_REGMAP_CONF("15"),
};
static struct regmap_config cdns_sierra_common_cdb_config = {
@@ -546,6 +559,8 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
}
}
+ sp->num_lanes += sp->phys[node].num_lanes;
+
gphy = devm_phy_create(dev, child, &ops);
if (IS_ERR(gphy)) {
@@ -559,6 +574,11 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
}
sp->nsubnodes = node;
+ if (sp->num_lanes > SIERRA_MAX_LANES) {
+ dev_err(dev, "Invalid lane configuration\n");
+ goto put_child2;
+ }
+
/* If more than one subnode, configure the PHY as multilink */
if (!sp->autoconf && sp->nsubnodes > 1)
regmap_field_write(sp->phy_pll_cfg_1, 0x1);
--
2.17.1
SERDES_16G in TI's J721E SoC uses Cadence Sierra PHY. Add
support to use Cadence Sierra driver in J721E SoC.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index d0e7ae1c67b1..89a3b732c311 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -551,11 +551,25 @@ static const struct cdns_sierra_data cdns_map_sierra = {
cdns_usb_regs
};
+static const struct cdns_sierra_data cdns_ti_map_sierra = {
+ SIERRA_MACRO_ID,
+ 0x0,
+ 0x1,
+ ARRAY_SIZE(cdns_pcie_regs),
+ ARRAY_SIZE(cdns_usb_regs),
+ cdns_pcie_regs,
+ cdns_usb_regs
+};
+
static const struct of_device_id cdns_sierra_id_table[] = {
{
.compatible = "cdns,sierra-phy-t0",
.data = &cdns_map_sierra,
},
+ {
+ .compatible = "ti,sierra-phy-t0",
+ .data = &cdns_ti_map_sierra,
+ },
{}
};
MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
--
2.17.1
commit 44d30d622821d3b ("phy: cadence: Add driver for Sierra PHY"),
incorrectly used parent device pointer to get driver data. Fix it here.
Fixes: 44d30d622821d3b ("phy: cadence: Add driver for Sierra PHY")
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index affede8c4368..04c28cbb6d39 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -623,7 +623,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
static int cdns_sierra_phy_remove(struct platform_device *pdev)
{
- struct cdns_sierra_phy *phy = dev_get_drvdata(pdev->dev.parent);
+ struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
int i;
reset_control_assert(phy->phy_rst);
--
2.17.1
Add DT binding documentation for WIZ (SERDES wrapper). WIZ is *NOT* a
PHY but a wrapper used to configure some of the input signals to the
SERDES. It is used with both Sierra(16G) and Torrent(10G) serdes.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
[[email protected]: Add separate compatible for Sierra(16G) and Torrent(10G)
SERDES]
Signed-off-by: Jyri Sarha <[email protected]>
---
.../bindings/phy/ti,phy-j721e-wiz.yaml | 159 ++++++++++++++++++
1 file changed, 159 insertions(+)
create mode 100644 Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
diff --git a/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
new file mode 100644
index 000000000000..8a1eccee6c1d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0)
+# Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/ti,phy-j721e-wiz.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: TI J721E WIZ (SERDES Wrapper)
+
+maintainers:
+ - Kishon Vijay Abraham I <[email protected]>
+
+properties:
+ compatible:
+ oneOf:
+ - items:
+ - enum:
+ - ti,j721e-wiz-16g
+ - ti,j721e-wiz-10g
+
+ power-domains:
+ maxItems: 1
+
+ clocks:
+ maxItems: 3
+ description: clock-specifier to represent input to the WIZ
+
+ clock-names:
+ items:
+ - const: fck
+ - const: core_ref_clk
+ - const: ext_ref_clk
+
+ num-lanes:
+ maxItems: 1
+ minimum: 1
+ maximum: 4
+
+ "#address-cells":
+ const: 2
+
+ "#size-cells":
+ const: 2
+
+ "#reset-cells":
+ const: 1
+
+ ranges: true
+
+ assigned-clocks:
+ maxItems: 2
+
+ assigned-clock-parents:
+ maxItems: 2
+
+patternProperties:
+ "^pll[0|1]_refclk$":
+ type: object
+ description: |
+ WIZ node should have subnodes for each of the PLLs present in
+ the SERDES.
+
+ "^cmn_refclk1?$":
+ type: object
+ description: |
+ WIZ node should have subnodes for each of the PMA common refclock
+ provided by the SERDES.
+
+ "^refclk_dig$":
+ type: object
+ description: |
+ WIZ node should have subnode for refclk_dig to select the reference
+ clock source for the reference clock used in the PHY and PMA digital
+ logic.
+
+ "^serdes@[0-9a-f]+$":
+ type: object
+ description: |
+ WIZ node should have '1' subnode for the SERDES. It could be either
+ Sierra SERDES or Torrent SERDES. Sierra SERDES should follow the
+ bindings specified in
+ Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
+ Torrent SERDES should follow the bindings specified in
+ Documentation/devicetree/bindings/phy/phy-cadence-dp.txt
+
+required:
+ - compatible
+ - power-domains
+ - clocks
+ - clock-names
+ - num-lanes
+ - "#address-cells"
+ - "#size-cells"
+ - "#reset-cells"
+
+examples:
+ - |
+ #include <dt-bindings/soc/ti,sci_pm_domain.h>
+
+ wiz@5000000 {
+ compatible = "ti,j721e-wiz-16g";
+ #address-cells = <2>;
+ #size-cells = <2>;
+ power-domains = <&k3_pds 292 TI_SCI_PD_EXCLUSIVE>;
+ clocks = <&k3_clks 292 5>, <&k3_clks 292 11>, <&dummy_cmn_refclk>;
+ clock-names = "fck", "core_ref_clk", "ext_ref_clk";
+ assigned-clocks = <&k3_clks 292 11>, <&k3_clks 292 0>;
+ assigned-clock-parents = <&k3_clks 292 15>, <&k3_clks 292 4>;
+ num-lanes = <2>;
+ #reset-cells = <1>;
+
+ pll0_refclk {
+ clocks = <&k3_clks 293 13>, <&dummy_cmn_refclk>;
+ clock-output-names = "wiz1_pll0_refclk";
+ #clock-cells = <0>;
+ assigned-clocks = <&wiz1_pll0_refclk>;
+ assigned-clock-parents = <&k3_clks 293 13>;
+ };
+
+ pll1_refclk {
+ clocks = <&k3_clks 293 0>, <&dummy_cmn_refclk1>;
+ clock-output-names = "wiz1_pll1_refclk";
+ #clock-cells = <0>;
+ assigned-clocks = <&wiz1_pll1_refclk>;
+ assigned-clock-parents = <&k3_clks 293 0>;
+ };
+
+ cmn_refclk {
+ clocks = <&wiz1_refclk_dig>;
+ clock-output-names = "wiz1_cmn_refclk";
+ #clock-cells = <0>;
+ };
+
+ cmn_refclk1 {
+ clocks = <&wiz1_pll1_refclk>;
+ clock-output-names = "wiz1_cmn_refclk1";
+ #clock-cells = <0>;
+ };
+
+ refclk_dig {
+ clocks = <&k3_clks 292 11>, <&k3_clks 292 0>, <&dummy_cmn_refclk>, <&dummy_cmn_refclk1>;
+ clock-output-names = "wiz0_refclk_dig";
+ #clock-cells = <0>;
+ assigned-clocks = <&wiz0_refclk_dig>;
+ assigned-clock-parents = <&k3_clks 292 11>;
+ };
+
+ serdes@5000000 {
+ compatible = "cdns,ti,sierra-phy-t0";
+ reg-names = "serdes";
+ reg = <0x00 0x5000000 0x00 0x10000>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ resets = <&serdes_wiz0 0>;
+ reset-names = "sierra_reset";
+ clocks = <&wiz0_cmn_refclk>, <&wiz0_cmn_refclk1>;
+ clock-names = "cmn_refclk", "cmn_refclk1";
+ };
+ };
--
2.17.1
From: Anil Varughese <[email protected]>
The existing configuration done in Cadence Sierra driver is only for
reference and is not used in any platforms. Remove them and configure
both lane cdb and common cdb registers to be used with external
SSC configuration. This is validated in TI J721E platform.
Signed-off-by: Anil Varughese <[email protected]>
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 356 ++++++++++++++++-------
1 file changed, 257 insertions(+), 99 deletions(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index c0ea0863d050..b555d4c3633b 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -22,56 +22,123 @@
#include <dt-bindings/phy/phy.h>
/* PHY register offsets */
-#define SIERRA_COMMON_CDB_OFFSET 0x0
-#define SIERRA_MACRO_ID_REG 0x0
+#define SIERRA_COMMON_CDB_OFFSET 0x0
+#define SIERRA_MACRO_ID_REG 0x0
+#define SIERRA_CMN_PLLLC_MODE_PREG 0x48
+#define SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG 0x49
+#define SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG 0x4A
+#define SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG 0x4B
+#define SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG 0x4F
+#define SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG 0x50
+#define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG 0x62
#define SIERRA_LANE_CDB_OFFSET(ln, offset) \
(0x4000 + ((ln) * (0x800 >> (2 - (offset)))))
-#define SIERRA_DET_STANDEC_A_PREG 0x000
-#define SIERRA_DET_STANDEC_B_PREG 0x001
-#define SIERRA_DET_STANDEC_C_PREG 0x002
-#define SIERRA_DET_STANDEC_D_PREG 0x003
-#define SIERRA_DET_STANDEC_E_PREG 0x004
-#define SIERRA_PSM_LANECAL_PREG 0x008
-#define SIERRA_PSM_DIAG_PREG 0x015
-#define SIERRA_PSC_TX_A0_PREG 0x028
-#define SIERRA_PSC_TX_A1_PREG 0x029
-#define SIERRA_PSC_TX_A2_PREG 0x02A
-#define SIERRA_PSC_TX_A3_PREG 0x02B
-#define SIERRA_PSC_RX_A0_PREG 0x030
-#define SIERRA_PSC_RX_A1_PREG 0x031
-#define SIERRA_PSC_RX_A2_PREG 0x032
-#define SIERRA_PSC_RX_A3_PREG 0x033
-#define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A
-#define SIERRA_PLLCTRL_GEN_D_PREG 0x03E
-#define SIERRA_DRVCTRL_ATTEN_PREG 0x06A
-#define SIERRA_CLKPATHCTRL_TMR_PREG 0x081
-#define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG 0x087
-#define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG 0x088
-#define SIERRA_CREQ_CCLKDET_MODE01_PREG 0x08E
-#define SIERRA_RX_CTLE_MAINTENANCE_PREG 0x091
-#define SIERRA_CREQ_FSMCLK_SEL_PREG 0x092
-#define SIERRA_CTLELUT_CTRL_PREG 0x098
-#define SIERRA_DFE_ECMP_RATESEL_PREG 0x0C0
-#define SIERRA_DFE_SMP_RATESEL_PREG 0x0C1
-#define SIERRA_DEQ_VGATUNE_CTRL_PREG 0x0E1
-#define SIERRA_TMRVAL_MODE3_PREG 0x16E
-#define SIERRA_TMRVAL_MODE2_PREG 0x16F
-#define SIERRA_TMRVAL_MODE1_PREG 0x170
-#define SIERRA_TMRVAL_MODE0_PREG 0x171
-#define SIERRA_PICNT_MODE1_PREG 0x174
-#define SIERRA_CPI_OUTBUF_RATESEL_PREG 0x17C
-#define SIERRA_LFPSFILT_NS_PREG 0x18A
-#define SIERRA_LFPSFILT_RD_PREG 0x18B
-#define SIERRA_LFPSFILT_MP_PREG 0x18C
-#define SIERRA_SDFILT_H2L_A_PREG 0x191
-
-#define SIERRA_PHY_CONFIG_CTRL_OFFSET 0xc000
-#define SIERRA_PHY_PLL_CFG 0xe
-
-#define SIERRA_MACRO_ID 0x00007364
-#define SIERRA_MAX_LANES 4
+#define SIERRA_DET_STANDEC_A_PREG 0x000
+#define SIERRA_DET_STANDEC_B_PREG 0x001
+#define SIERRA_DET_STANDEC_C_PREG 0x002
+#define SIERRA_DET_STANDEC_D_PREG 0x003
+#define SIERRA_DET_STANDEC_E_PREG 0x004
+#define SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG 0x008
+#define SIERRA_PSM_A0IN_TMR_PREG 0x009
+#define SIERRA_PSM_DIAG_PREG 0x015
+#define SIERRA_PSC_TX_A0_PREG 0x028
+#define SIERRA_PSC_TX_A1_PREG 0x029
+#define SIERRA_PSC_TX_A2_PREG 0x02A
+#define SIERRA_PSC_TX_A3_PREG 0x02B
+#define SIERRA_PSC_RX_A0_PREG 0x030
+#define SIERRA_PSC_RX_A1_PREG 0x031
+#define SIERRA_PSC_RX_A2_PREG 0x032
+#define SIERRA_PSC_RX_A3_PREG 0x033
+#define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A
+#define SIERRA_PLLCTRL_GEN_D_PREG 0x03E
+#define SIERRA_PLLCTRL_CPGAIN_MODE_PREG 0x03F
+#define SIERRA_CLKPATH_BIASTRIM_PREG 0x04B
+#define SIERRA_DFE_BIASTRIM_PREG 0x04C
+#define SIERRA_DRVCTRL_ATTEN_PREG 0x06A
+#define SIERRA_CLKPATHCTRL_TMR_PREG 0x081
+#define SIERRA_RX_CREQ_FLTR_A_MODE3_PREG 0x085
+#define SIERRA_RX_CREQ_FLTR_A_MODE2_PREG 0x086
+#define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG 0x087
+#define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG 0x088
+#define SIERRA_CREQ_CCLKDET_MODE01_PREG 0x08E
+#define SIERRA_RX_CTLE_MAINTENANCE_PREG 0x091
+#define SIERRA_CREQ_FSMCLK_SEL_PREG 0x092
+#define SIERRA_CREQ_EQ_CTRL_PREG 0x093
+#define SIERRA_CREQ_SPARE_PREG 0x096
+#define SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG 0x097
+#define SIERRA_CTLELUT_CTRL_PREG 0x098
+#define SIERRA_DFE_ECMP_RATESEL_PREG 0x0C0
+#define SIERRA_DFE_SMP_RATESEL_PREG 0x0C1
+#define SIERRA_DEQ_PHALIGN_CTRL 0x0C4
+#define SIERRA_DEQ_CONCUR_CTRL1_PREG 0x0C8
+#define SIERRA_DEQ_CONCUR_CTRL2_PREG 0x0C9
+#define SIERRA_DEQ_EPIPWR_CTRL2_PREG 0x0CD
+#define SIERRA_DEQ_FAST_MAINT_CYCLES_PREG 0x0CE
+#define SIERRA_DEQ_ERRCMP_CTRL_PREG 0x0D0
+#define SIERRA_DEQ_OFFSET_CTRL_PREG 0x0D8
+#define SIERRA_DEQ_GAIN_CTRL_PREG 0x0E0
+#define SIERRA_DEQ_VGATUNE_CTRL_PREG 0x0E1
+#define SIERRA_DEQ_GLUT0 0x0E8
+#define SIERRA_DEQ_GLUT1 0x0E9
+#define SIERRA_DEQ_GLUT2 0x0EA
+#define SIERRA_DEQ_GLUT3 0x0EB
+#define SIERRA_DEQ_GLUT4 0x0EC
+#define SIERRA_DEQ_GLUT5 0x0ED
+#define SIERRA_DEQ_GLUT6 0x0EE
+#define SIERRA_DEQ_GLUT7 0x0EF
+#define SIERRA_DEQ_GLUT8 0x0F0
+#define SIERRA_DEQ_GLUT9 0x0F1
+#define SIERRA_DEQ_GLUT10 0x0F2
+#define SIERRA_DEQ_GLUT11 0x0F3
+#define SIERRA_DEQ_GLUT12 0x0F4
+#define SIERRA_DEQ_GLUT13 0x0F5
+#define SIERRA_DEQ_GLUT14 0x0F6
+#define SIERRA_DEQ_GLUT15 0x0F7
+#define SIERRA_DEQ_GLUT16 0x0F8
+#define SIERRA_DEQ_ALUT0 0x108
+#define SIERRA_DEQ_ALUT1 0x109
+#define SIERRA_DEQ_ALUT2 0x10A
+#define SIERRA_DEQ_ALUT3 0x10B
+#define SIERRA_DEQ_ALUT4 0x10C
+#define SIERRA_DEQ_ALUT5 0x10D
+#define SIERRA_DEQ_ALUT6 0x10E
+#define SIERRA_DEQ_ALUT7 0x10F
+#define SIERRA_DEQ_ALUT8 0x110
+#define SIERRA_DEQ_ALUT9 0x111
+#define SIERRA_DEQ_ALUT10 0x112
+#define SIERRA_DEQ_ALUT11 0x113
+#define SIERRA_DEQ_ALUT12 0x114
+#define SIERRA_DEQ_ALUT13 0x115
+#define SIERRA_DEQ_DFETAP_CTRL_PREG 0x128
+#define SIERRA_DFE_EN_1010_IGNORE_PREG 0x134
+#define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150
+#define SIERRA_DEQ_TAU_CTRL2_PREG 0x151
+#define SIERRA_DEQ_PICTRL_PREG 0x161
+#define SIERRA_CPICAL_TMRVAL_MODE1_PREG 0x170
+#define SIERRA_CPICAL_TMRVAL_MODE0_PREG 0x171
+#define SIERRA_CPICAL_PICNT_MODE1_PREG 0x174
+#define SIERRA_CPI_OUTBUF_RATESEL_PREG 0x17C
+#define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG 0x183
+#define SIERRA_LFPSDET_SUPPORT_PREG 0x188
+#define SIERRA_LFPSFILT_NS_PREG 0x18A
+#define SIERRA_LFPSFILT_RD_PREG 0x18B
+#define SIERRA_LFPSFILT_MP_PREG 0x18C
+#define SIERRA_SIGDET_SUPPORT_PREG 0x190
+#define SIERRA_SDFILT_H2L_A_PREG 0x191
+#define SIERRA_SDFILT_L2H_PREG 0x193
+#define SIERRA_RXBUFFER_CTLECTRL_PREG 0x19E
+#define SIERRA_RXBUFFER_RCDFECTRL_PREG 0x19F
+#define SIERRA_RXBUFFER_DFECTRL_PREG 0x1A0
+#define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG 0x14F
+#define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150
+
+#define SIERRA_PHY_CONFIG_CTRL_OFFSET 0xc000
+#define SIERRA_PHY_PLL_CFG 0xe
+
+#define SIERRA_MACRO_ID 0x00007364
+#define SIERRA_MAX_LANES 4
static const struct reg_field macro_id_type =
REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
@@ -95,10 +162,14 @@ struct cdns_sierra_data {
u32 id_value;
u8 block_offset_shift;
u8 reg_offset_shift;
- u32 pcie_regs;
- u32 usb_regs;
- struct cdns_reg_pairs *pcie_vals;
- struct cdns_reg_pairs *usb_vals;
+ u32 pcie_cmn_regs;
+ u32 pcie_ln_regs;
+ u32 usb_cmn_regs;
+ u32 usb_ln_regs;
+ struct cdns_reg_pairs *pcie_cmn_vals;
+ struct cdns_reg_pairs *pcie_ln_vals;
+ struct cdns_reg_pairs *usb_cmn_vals;
+ struct cdns_reg_pairs *usb_ln_vals;
};
struct cdns_regmap_cdb_context {
@@ -181,26 +252,35 @@ static int cdns_sierra_phy_init(struct phy *gphy)
struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
struct regmap *regmap = phy->regmap;
int i, j;
- struct cdns_reg_pairs *vals;
- u32 num_regs;
+ struct cdns_reg_pairs *cmn_vals, *ln_vals;
+ u32 num_cmn_regs, num_ln_regs;
/* Initialise the PHY registers, unless auto configured */
if (phy->autoconf)
return 0;
if (ins->phy_type == PHY_TYPE_PCIE) {
- num_regs = phy->init_data->pcie_regs;
- vals = phy->init_data->pcie_vals;
+ num_cmn_regs = phy->init_data->pcie_cmn_regs;
+ num_ln_regs = phy->init_data->pcie_ln_regs;
+ cmn_vals = phy->init_data->pcie_cmn_vals;
+ ln_vals = phy->init_data->pcie_ln_vals;
} else if (ins->phy_type == PHY_TYPE_USB3) {
- num_regs = phy->init_data->usb_regs;
- vals = phy->init_data->usb_vals;
+ num_cmn_regs = phy->init_data->usb_cmn_regs;
+ num_ln_regs = phy->init_data->usb_ln_regs;
+ cmn_vals = phy->init_data->usb_cmn_vals;
+ ln_vals = phy->init_data->usb_ln_vals;
} else {
return -EINVAL;
}
+
+ regmap = phy->regmap_common_cdb;
+ for (j = 0; j < num_cmn_regs ; j++)
+ regmap_write(regmap, cmn_vals[j].off, cmn_vals[j].val);
+
for (i = 0; i < ins->num_lanes; i++) {
- for (j = 0; j < num_regs ; j++) {
+ for (j = 0; j < num_ln_regs ; j++) {
regmap = phy->regmap_lane_cdb[i + ins->mlane];
- regmap_write(regmap, vals[j].off, vals[j].val);
+ regmap_write(regmap, ln_vals[j].off, ln_vals[j].val);
}
}
@@ -489,80 +569,158 @@ static int cdns_sierra_phy_remove(struct platform_device *pdev)
return 0;
}
-static struct cdns_reg_pairs cdns_usb_regs[] = {
- /*
- * Write USB configuration parameters to the PHY.
- * These values are specific to this specific hardware
- * configuration.
- */
+/* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
+static struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
+ {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
+ {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
+ {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
+ {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
+ {0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
+};
+
+/* refclk100MHz_32b_PCIe_ln_ext_ssc */
+static struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
+ {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
+ {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
+ {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
+ {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
+ {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
+ {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
+ {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}
+};
+
+/* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
+static struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
+ {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
+ {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
+ {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
+ {0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
+};
+
+/* refclk100MHz_20b_USB_ln_ext_ssc */
+static struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
{0xFE0A, SIERRA_DET_STANDEC_A_PREG},
{0x000F, SIERRA_DET_STANDEC_B_PREG},
- {0x55A5, SIERRA_DET_STANDEC_C_PREG},
- {0x69AD, SIERRA_DET_STANDEC_D_PREG},
+ {0x00A5, SIERRA_DET_STANDEC_C_PREG},
+ {0x69ad, SIERRA_DET_STANDEC_D_PREG},
{0x0241, SIERRA_DET_STANDEC_E_PREG},
- {0x0110, SIERRA_PSM_LANECAL_PREG},
+ {0x0010, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
+ {0x0014, SIERRA_PSM_A0IN_TMR_PREG},
{0xCF00, SIERRA_PSM_DIAG_PREG},
{0x001F, SIERRA_PSC_TX_A0_PREG},
{0x0007, SIERRA_PSC_TX_A1_PREG},
{0x0003, SIERRA_PSC_TX_A2_PREG},
{0x0003, SIERRA_PSC_TX_A3_PREG},
{0x0FFF, SIERRA_PSC_RX_A0_PREG},
- {0x0003, SIERRA_PSC_RX_A1_PREG},
+ {0x0619, SIERRA_PSC_RX_A1_PREG},
{0x0003, SIERRA_PSC_RX_A2_PREG},
{0x0001, SIERRA_PSC_RX_A3_PREG},
{0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
{0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
+ {0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
+ {0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
+ {0x2512, SIERRA_DFE_BIASTRIM_PREG},
{0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
- {0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
- {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
- {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
+ {0x873E, SIERRA_CLKPATHCTRL_TMR_PREG},
+ {0x03CF, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
+ {0x01CE, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
{0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
- {0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
+ {0x033F, SIERRA_RX_CTLE_MAINTENANCE_PREG},
{0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
- {0x8452, SIERRA_CTLELUT_CTRL_PREG},
- {0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
- {0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
- {0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
- {0x0330, SIERRA_TMRVAL_MODE0_PREG},
- {0x01FF, SIERRA_PICNT_MODE1_PREG},
+ {0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
+ {0x8000, SIERRA_CREQ_SPARE_PREG},
+ {0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
+ {0x8453, SIERRA_CTLELUT_CTRL_PREG},
+ {0x4110, SIERRA_DFE_ECMP_RATESEL_PREG},
+ {0x4110, SIERRA_DFE_SMP_RATESEL_PREG},
+ {0x0002, SIERRA_DEQ_PHALIGN_CTRL},
+ {0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
+ {0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
+ {0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
+ {0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
+ {0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
+ {0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
+ {0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
+ {0x9A8A, SIERRA_DEQ_VGATUNE_CTRL_PREG},
+ {0x0014, SIERRA_DEQ_GLUT0},
+ {0x0014, SIERRA_DEQ_GLUT1},
+ {0x0014, SIERRA_DEQ_GLUT2},
+ {0x0014, SIERRA_DEQ_GLUT3},
+ {0x0014, SIERRA_DEQ_GLUT4},
+ {0x0014, SIERRA_DEQ_GLUT5},
+ {0x0014, SIERRA_DEQ_GLUT6},
+ {0x0014, SIERRA_DEQ_GLUT7},
+ {0x0014, SIERRA_DEQ_GLUT8},
+ {0x0014, SIERRA_DEQ_GLUT9},
+ {0x0014, SIERRA_DEQ_GLUT10},
+ {0x0014, SIERRA_DEQ_GLUT11},
+ {0x0014, SIERRA_DEQ_GLUT12},
+ {0x0014, SIERRA_DEQ_GLUT13},
+ {0x0014, SIERRA_DEQ_GLUT14},
+ {0x0014, SIERRA_DEQ_GLUT15},
+ {0x0014, SIERRA_DEQ_GLUT16},
+ {0x0BAE, SIERRA_DEQ_ALUT0},
+ {0x0AEB, SIERRA_DEQ_ALUT1},
+ {0x0A28, SIERRA_DEQ_ALUT2},
+ {0x0965, SIERRA_DEQ_ALUT3},
+ {0x08A2, SIERRA_DEQ_ALUT4},
+ {0x07DF, SIERRA_DEQ_ALUT5},
+ {0x071C, SIERRA_DEQ_ALUT6},
+ {0x0659, SIERRA_DEQ_ALUT7},
+ {0x0596, SIERRA_DEQ_ALUT8},
+ {0x0514, SIERRA_DEQ_ALUT9},
+ {0x0492, SIERRA_DEQ_ALUT10},
+ {0x0410, SIERRA_DEQ_ALUT11},
+ {0x038E, SIERRA_DEQ_ALUT12},
+ {0x030C, SIERRA_DEQ_ALUT13},
+ {0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
+ {0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
+ {0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
+ {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
+ {0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
+ {0x0033, SIERRA_DEQ_PICTRL_PREG},
+ {0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
+ {0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
+ {0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
{0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
+ {0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
+ {0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
{0x000F, SIERRA_LFPSFILT_NS_PREG},
{0x0009, SIERRA_LFPSFILT_RD_PREG},
{0x0001, SIERRA_LFPSFILT_MP_PREG},
{0x8013, SIERRA_SDFILT_H2L_A_PREG},
- {0x0400, SIERRA_TMRVAL_MODE1_PREG},
-};
-
-static struct cdns_reg_pairs cdns_pcie_regs[] = {
- /*
- * Write PCIe configuration parameters to the PHY.
- * These values are specific to this specific hardware
- * configuration.
- */
- {0x891f, SIERRA_DET_STANDEC_D_PREG},
- {0x0053, SIERRA_DET_STANDEC_E_PREG},
- {0x0400, SIERRA_TMRVAL_MODE2_PREG},
- {0x0200, SIERRA_TMRVAL_MODE3_PREG},
+ {0x8009, SIERRA_SDFILT_L2H_PREG},
+ {0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
+ {0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
+ {0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
};
static const struct cdns_sierra_data cdns_map_sierra = {
SIERRA_MACRO_ID,
0x2,
0x2,
- ARRAY_SIZE(cdns_pcie_regs),
- ARRAY_SIZE(cdns_usb_regs),
- cdns_pcie_regs,
- cdns_usb_regs
+ ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
+ ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
+ ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
+ ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
+ cdns_pcie_cmn_regs_ext_ssc,
+ cdns_pcie_ln_regs_ext_ssc,
+ cdns_usb_cmn_regs_ext_ssc,
+ cdns_usb_ln_regs_ext_ssc,
};
static const struct cdns_sierra_data cdns_ti_map_sierra = {
SIERRA_MACRO_ID,
0x0,
0x1,
- ARRAY_SIZE(cdns_pcie_regs),
- ARRAY_SIZE(cdns_usb_regs),
- cdns_pcie_regs,
- cdns_usb_regs
+ ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
+ ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
+ ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
+ ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
+ cdns_pcie_cmn_regs_ext_ssc,
+ cdns_pcie_ln_regs_ext_ssc,
+ cdns_usb_cmn_regs_ext_ssc,
+ cdns_usb_ln_regs_ext_ssc,
};
static const struct of_device_id cdns_sierra_id_table[] = {
--
2.17.1
Add support for WIZ module present in TI's J721E SoC. WIZ is a SERDES
wrapper used to configure some of the input signals to the SERDES. It is
used with both Sierra(16G) and Torrent(10G) SERDES. This driver configures
three clock selects (pll0, pll1, dig), two divider clocks and supports
resets for each of the lanes.
[[email protected]: Add support for Torrent(10G) SERDES wrapper]
Signed-off-by: Jyri Sarha <[email protected]>
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/ti/Kconfig | 15 +
drivers/phy/ti/Makefile | 1 +
drivers/phy/ti/phy-j721e-wiz.c | 904 +++++++++++++++++++++++++++++++++
3 files changed, 920 insertions(+)
create mode 100644 drivers/phy/ti/phy-j721e-wiz.c
diff --git a/drivers/phy/ti/Kconfig b/drivers/phy/ti/Kconfig
index c3fa1840f8de..af6213b734e6 100644
--- a/drivers/phy/ti/Kconfig
+++ b/drivers/phy/ti/Kconfig
@@ -33,6 +33,21 @@ config PHY_AM654_SERDES
This option enables support for TI AM654 SerDes PHY used for
PCIe.
+config PHY_J721E_WIZ
+ tristate "TI J721E WIZ (SERDES Wrapper) support"
+ depends on OF && ARCH_K3 || COMPILE_TEST
+ depends on COMMON_CLK
+ select GENERIC_PHY
+ select MULTIPLEXER
+ select REGMAP_MMIO
+ select MUX_MMIO
+ help
+ This option enables support for WIZ module present in TI's J721E
+ SoC. WIZ is a serdes wrapper used to configure some of the input
+ signals to the SERDES (Sierra/Torrent). This driver configures
+ three clock selects (pll0, pll1, dig) and resets for each of the
+ lanes.
+
config OMAP_CONTROL_PHY
tristate "OMAP CONTROL PHY Driver"
depends on ARCH_OMAP2PLUS || COMPILE_TEST
diff --git a/drivers/phy/ti/Makefile b/drivers/phy/ti/Makefile
index bff901eb0ecc..dcba2571c9bd 100644
--- a/drivers/phy/ti/Makefile
+++ b/drivers/phy/ti/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o
obj-$(CONFIG_PHY_AM654_SERDES) += phy-am654-serdes.o
obj-$(CONFIG_PHY_TI_GMII_SEL) += phy-gmii-sel.o
+obj-$(CONFIG_PHY_J721E_WIZ) += phy-j721e-wiz.o
diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c
new file mode 100644
index 000000000000..2a95da843e9f
--- /dev/null
+++ b/drivers/phy/ti/phy-j721e-wiz.c
@@ -0,0 +1,904 @@
+// SPDX-License-Identifier: GPL-2.0
+/**
+ * Wrapper driver for SERDES used in J721E
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Kishon Vijay Abraham I <[email protected]>
+ */
+
+#include <dt-bindings/phy/phy.h>
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mux/consumer.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/reset-controller.h>
+
+#define WIZ_SERDES_CTRL 0x404
+#define WIZ_SERDES_TOP_CTRL 0x408
+#define WIZ_SERDES_RST 0x40c
+#define WIZ_LANECTL(n) (0x480 + (0x40 * (n)))
+
+#define WIZ_MAX_LANES 4
+#define WIZ_MUX_NUM_CLOCKS 3
+#define WIZ_DIV_NUM_CLOCKS_16G 2
+#define WIZ_DIV_NUM_CLOCKS_10G 1
+
+enum wiz_lane_standard_mode {
+ LANE_MODE_GEN1,
+ LANE_MODE_GEN2,
+ LANE_MODE_GEN3,
+ LANE_MODE_GEN4,
+};
+
+enum wiz_refclk_mux_sel {
+ PLL0_REFCLK,
+ PLL1_REFCLK,
+ REFCLK_DIG,
+};
+
+enum wiz_refclk_div_sel {
+ CMN_REFCLK,
+ CMN_REFCLK1,
+};
+
+static const struct reg_field por_en = REG_FIELD(WIZ_SERDES_CTRL, 31, 31);
+static const struct reg_field phy_reset_n = REG_FIELD(WIZ_SERDES_RST, 31, 31);
+static const struct reg_field pll1_refclk_mux_sel =
+ REG_FIELD(WIZ_SERDES_RST, 29, 29);
+static const struct reg_field pll0_refclk_mux_sel =
+ REG_FIELD(WIZ_SERDES_RST, 28, 28);
+static const struct reg_field refclk_dig_sel_16g =
+ REG_FIELD(WIZ_SERDES_RST, 24, 25);
+static const struct reg_field refclk_dig_sel_10g =
+ REG_FIELD(WIZ_SERDES_RST, 24, 24);
+static const struct reg_field pma_cmn_refclk_int_mode =
+ REG_FIELD(WIZ_SERDES_TOP_CTRL, 28, 29);
+static const struct reg_field pma_cmn_refclk_mode =
+ REG_FIELD(WIZ_SERDES_TOP_CTRL, 30, 31);
+static const struct reg_field pma_cmn_refclk_dig_div =
+ REG_FIELD(WIZ_SERDES_TOP_CTRL, 26, 27);
+static const struct reg_field pma_cmn_refclk1_dig_div =
+ REG_FIELD(WIZ_SERDES_TOP_CTRL, 24, 25);
+
+static const struct reg_field p_enable[WIZ_MAX_LANES] = {
+ REG_FIELD(WIZ_LANECTL(0), 30, 31),
+ REG_FIELD(WIZ_LANECTL(1), 30, 31),
+ REG_FIELD(WIZ_LANECTL(2), 30, 31),
+ REG_FIELD(WIZ_LANECTL(3), 30, 31),
+};
+
+static const struct reg_field p_align[WIZ_MAX_LANES] = {
+ REG_FIELD(WIZ_LANECTL(0), 29, 29),
+ REG_FIELD(WIZ_LANECTL(1), 29, 29),
+ REG_FIELD(WIZ_LANECTL(2), 29, 29),
+ REG_FIELD(WIZ_LANECTL(3), 29, 29),
+};
+
+static const struct reg_field p_raw_auto_start[WIZ_MAX_LANES] = {
+ REG_FIELD(WIZ_LANECTL(0), 28, 28),
+ REG_FIELD(WIZ_LANECTL(1), 28, 28),
+ REG_FIELD(WIZ_LANECTL(2), 28, 28),
+ REG_FIELD(WIZ_LANECTL(3), 28, 28),
+};
+
+static const struct reg_field p_standard_mode[WIZ_MAX_LANES] = {
+ REG_FIELD(WIZ_LANECTL(0), 24, 25),
+ REG_FIELD(WIZ_LANECTL(1), 24, 25),
+ REG_FIELD(WIZ_LANECTL(2), 24, 25),
+ REG_FIELD(WIZ_LANECTL(3), 24, 25),
+};
+
+struct wiz_clk_mux {
+ struct clk_hw hw;
+ struct regmap_field *field;
+ u32 *table;
+ struct clk_init_data clk_data;
+};
+
+#define to_wiz_clk_mux(_hw) container_of(_hw, struct wiz_clk_mux, hw)
+
+struct wiz_clk_divider {
+ struct clk_hw hw;
+ struct regmap_field *field;
+ struct clk_div_table *table;
+ struct clk_init_data clk_data;
+};
+
+#define to_wiz_clk_div(_hw) container_of(_hw, struct wiz_clk_divider, hw)
+
+struct wiz_clk_mux_sel {
+ struct regmap_field *field;
+ u32 table[4];
+ const char *node_name;
+};
+
+struct wiz_clk_div_sel {
+ struct regmap_field *field;
+ struct clk_div_table *table;
+ const char *node_name;
+};
+
+static struct wiz_clk_mux_sel clk_mux_sel_16g[] = {
+ {
+ /*
+ * Mux value to be configured for each of the input clocks
+ * in the order populated in device tree
+ */
+ .table = { 1, 0 },
+ .node_name = "pll0_refclk",
+ },
+ {
+ .table = { 1, 0 },
+ .node_name = "pll1_refclk",
+ },
+ {
+ .table = { 1, 3, 0, 2 },
+ .node_name = "refclk_dig",
+ },
+};
+
+static struct wiz_clk_mux_sel clk_mux_sel_10g[] = {
+ {
+ /*
+ * Mux value to be configured for each of the input clocks
+ * in the order populated in device tree
+ */
+ .table = { 1, 0 },
+ .node_name = "pll0_refclk",
+ },
+ {
+ .table = { 1, 0 },
+ .node_name = "pll1_refclk",
+ },
+ {
+ .table = { 1, 0 },
+ .node_name = "refclk_dig",
+ },
+};
+
+static struct clk_div_table clk_div_table[] = {
+ { .val = 0, .div = 1, },
+ { .val = 1, .div = 2, },
+ { .val = 2, .div = 4, },
+ { .val = 3, .div = 8, },
+};
+
+static struct wiz_clk_div_sel clk_div_sel[] = {
+ {
+ .table = clk_div_table,
+ .node_name = "cmn_refclk",
+ },
+ {
+ .table = clk_div_table,
+ .node_name = "cmn_refclk1",
+ },
+};
+
+enum wiz_type {
+ J721E_WIZ_16G,
+ J721E_WIZ_10G,
+};
+
+struct wiz {
+ struct regmap *regmap;
+ enum wiz_type type;
+ struct wiz_clk_mux_sel *clk_mux_sel;
+ struct wiz_clk_div_sel *clk_div_sel;
+ unsigned int clk_div_sel_num;
+ struct regmap_field *por_en;
+ struct regmap_field *phy_reset_n;
+ struct regmap_field *p_enable[WIZ_MAX_LANES];
+ struct regmap_field *p_align[WIZ_MAX_LANES];
+ struct regmap_field *p_raw_auto_start[WIZ_MAX_LANES];
+ struct regmap_field *p_standard_mode[WIZ_MAX_LANES];
+ struct regmap_field *pma_cmn_refclk_int_mode;
+ struct regmap_field *pma_cmn_refclk_mode;
+ struct regmap_field *pma_cmn_refclk_dig_div;
+ struct regmap_field *pma_cmn_refclk1_dig_div;
+
+ struct device *dev;
+ u32 num_lanes;
+ struct platform_device *serdes_pdev;
+ struct reset_controller_dev wiz_phy_reset_dev;
+};
+
+static int wiz_reset(struct wiz *wiz)
+{
+ int ret;
+
+ ret = regmap_field_write(wiz->por_en, 0x1);
+ if (ret)
+ return ret;
+
+ mdelay(1);
+
+ ret = regmap_field_write(wiz->por_en, 0x0);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int wiz_mode_select(struct wiz *wiz)
+{
+ u32 num_lanes = wiz->num_lanes;
+ int ret;
+ int i;
+
+ for (i = 0; i < num_lanes; i++) {
+ ret = regmap_field_write(wiz->p_standard_mode[i],
+ LANE_MODE_GEN4);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int wiz_init_raw_interface(struct wiz *wiz, bool enable)
+{
+ u32 num_lanes = wiz->num_lanes;
+ int i;
+ int ret;
+
+ for (i = 0; i < num_lanes; i++) {
+ ret = regmap_field_write(wiz->p_align[i], enable);
+ if (ret)
+ return ret;
+
+ ret = regmap_field_write(wiz->p_raw_auto_start[i], enable);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int wiz_init(struct wiz *wiz)
+{
+ struct device *dev = wiz->dev;
+ int ret;
+
+ ret = wiz_reset(wiz);
+ if (ret) {
+ dev_err(dev, "WIZ reset failed\n");
+ return ret;
+ }
+
+ ret = wiz_mode_select(wiz);
+ if (ret) {
+ dev_err(dev, "WIZ mode select failed\n");
+ return ret;
+ }
+
+ ret = wiz_init_raw_interface(wiz, true);
+ if (ret) {
+ dev_err(dev, "WIZ interface initialization failed\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int wiz_regfield_init(struct wiz *wiz)
+{
+ struct wiz_clk_mux_sel *clk_mux_sel;
+ struct wiz_clk_div_sel *clk_div_sel;
+ struct regmap *regmap = wiz->regmap;
+ int num_lanes = wiz->num_lanes;
+ struct device *dev = wiz->dev;
+ int i;
+
+ wiz->por_en = devm_regmap_field_alloc(dev, regmap, por_en);
+ if (IS_ERR(wiz->por_en)) {
+ dev_err(dev, "POR_EN reg field init failed\n");
+ return PTR_ERR(wiz->por_en);
+ }
+
+ wiz->phy_reset_n = devm_regmap_field_alloc(dev, regmap,
+ phy_reset_n);
+ if (IS_ERR(wiz->phy_reset_n)) {
+ dev_err(dev, "PHY_RESET_N reg field init failed\n");
+ return PTR_ERR(wiz->phy_reset_n);
+ }
+
+ wiz->pma_cmn_refclk_int_mode =
+ devm_regmap_field_alloc(dev, regmap, pma_cmn_refclk_int_mode);
+ if (IS_ERR(wiz->pma_cmn_refclk_int_mode)) {
+ dev_err(dev, "PMA_CMN_REFCLK_INT_MODE reg field init failed\n");
+ return PTR_ERR(wiz->pma_cmn_refclk_int_mode);
+ }
+
+ wiz->pma_cmn_refclk_mode =
+ devm_regmap_field_alloc(dev, regmap, pma_cmn_refclk_mode);
+ if (IS_ERR(wiz->pma_cmn_refclk_mode)) {
+ dev_err(dev, "PMA_CMN_REFCLK_MODE reg field init failed\n");
+ return PTR_ERR(wiz->pma_cmn_refclk_mode);
+ }
+
+ clk_div_sel = &wiz->clk_div_sel[CMN_REFCLK];
+ clk_div_sel->field = devm_regmap_field_alloc(dev, regmap,
+ pma_cmn_refclk_dig_div);
+ if (IS_ERR(clk_div_sel->field)) {
+ dev_err(dev, "PMA_CMN_REFCLK_DIG_DIV reg field init failed\n");
+ return PTR_ERR(clk_div_sel->field);
+ }
+
+ if (wiz->type == J721E_WIZ_16G) {
+ clk_div_sel = &wiz->clk_div_sel[CMN_REFCLK1];
+ clk_div_sel->field =
+ devm_regmap_field_alloc(dev, regmap,
+ pma_cmn_refclk1_dig_div);
+ if (IS_ERR(clk_div_sel->field)) {
+ dev_err(dev, "PMA_CMN_REFCLK1_DIG_DIV reg field init failed\n");
+ return PTR_ERR(clk_div_sel->field);
+ }
+ }
+
+ clk_mux_sel = &wiz->clk_mux_sel[PLL0_REFCLK];
+ clk_mux_sel->field = devm_regmap_field_alloc(dev, regmap,
+ pll0_refclk_mux_sel);
+ if (IS_ERR(clk_mux_sel->field)) {
+ dev_err(dev, "PLL0_REFCLK_SEL reg field init failed\n");
+ return PTR_ERR(clk_mux_sel->field);
+ }
+
+ clk_mux_sel = &wiz->clk_mux_sel[PLL1_REFCLK];
+ clk_mux_sel->field = devm_regmap_field_alloc(dev, regmap,
+ pll1_refclk_mux_sel);
+ if (IS_ERR(clk_mux_sel->field)) {
+ dev_err(dev, "PLL1_REFCLK_SEL reg field init failed\n");
+ return PTR_ERR(clk_mux_sel->field);
+ }
+
+ clk_mux_sel = &wiz->clk_mux_sel[REFCLK_DIG];
+ if (wiz->type == J721E_WIZ_10G)
+ clk_mux_sel->field =
+ devm_regmap_field_alloc(dev, regmap,
+ refclk_dig_sel_10g);
+ else
+ clk_mux_sel->field =
+ devm_regmap_field_alloc(dev, regmap,
+ refclk_dig_sel_16g);
+
+ if (IS_ERR(clk_mux_sel->field)) {
+ dev_err(dev, "REFCLK_DIG_SEL reg field init failed\n");
+ return PTR_ERR(clk_mux_sel->field);
+ }
+
+ for (i = 0; i < num_lanes; i++) {
+ wiz->p_enable[i] = devm_regmap_field_alloc(dev, regmap,
+ p_enable[i]);
+ if (IS_ERR(wiz->p_enable[i])) {
+ dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
+ return PTR_ERR(wiz->p_enable[i]);
+ }
+
+ wiz->p_align[i] = devm_regmap_field_alloc(dev, regmap,
+ p_align[i]);
+ if (IS_ERR(wiz->p_align[i])) {
+ dev_err(dev, "P%d_ALIGN reg field init failed\n", i);
+ return PTR_ERR(wiz->p_align[i]);
+ }
+
+ wiz->p_raw_auto_start[i] =
+ devm_regmap_field_alloc(dev, regmap, p_raw_auto_start[i]);
+ if (IS_ERR(wiz->p_raw_auto_start[i])) {
+ dev_err(dev, "P%d_RAW_AUTO_START reg field init fail\n",
+ i);
+ return PTR_ERR(wiz->p_raw_auto_start[i]);
+ }
+
+ wiz->p_standard_mode[i] =
+ devm_regmap_field_alloc(dev, regmap, p_standard_mode[i]);
+ if (IS_ERR(wiz->p_standard_mode[i])) {
+ dev_err(dev, "P%d_STANDARD_MODE reg field init fail\n",
+ i);
+ return PTR_ERR(wiz->p_standard_mode[i]);
+ }
+ }
+
+ return 0;
+}
+
+static u8 wiz_clk_mux_get_parent(struct clk_hw *hw)
+{
+ struct wiz_clk_mux *mux = to_wiz_clk_mux(hw);
+ struct regmap_field *field = mux->field;
+ unsigned int val;
+
+ regmap_field_read(field, &val);
+ return clk_mux_val_to_index(hw, mux->table, 0, val);
+}
+
+static int wiz_clk_mux_set_parent(struct clk_hw *hw, u8 index)
+{
+ struct wiz_clk_mux *mux = to_wiz_clk_mux(hw);
+ struct regmap_field *field = mux->field;
+ int val;
+
+ val = mux->table[index];
+ return regmap_field_write(field, val);
+}
+
+static const struct clk_ops wiz_clk_mux_ops = {
+ .set_parent = wiz_clk_mux_set_parent,
+ .get_parent = wiz_clk_mux_get_parent,
+};
+
+static int wiz_mux_clk_register(struct wiz *wiz, struct device_node *node,
+ struct regmap_field *field, u32 *table)
+{
+ struct device *dev = wiz->dev;
+ struct clk_init_data *init;
+ const char **parent_names;
+ unsigned int num_parents;
+ struct wiz_clk_mux *mux;
+ const char *clk_name;
+ struct clk *clk;
+ int ret;
+
+ mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
+ if (!mux)
+ return -ENOMEM;
+
+ num_parents = of_clk_get_parent_count(node);
+ if (num_parents < 2) {
+ dev_err(dev, "SERDES clock must have parents\n");
+ return -EINVAL;
+ }
+
+ parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents),
+ GFP_KERNEL);
+ if (!parent_names)
+ return -ENOMEM;
+
+ of_clk_parent_fill(node, parent_names, num_parents);
+
+ ret = of_property_read_string(node, "clock-output-names", &clk_name);
+ if (ret) {
+ dev_err(dev, "Unable to read clock-output-names DT property\n");
+ return ret;
+ }
+
+ init = &mux->clk_data;
+
+ init->ops = &wiz_clk_mux_ops;
+ init->flags = CLK_SET_RATE_NO_REPARENT;
+ init->parent_names = parent_names;
+ init->num_parents = num_parents;
+ init->name = clk_name;
+
+ mux->field = field;
+ mux->table = table;
+ mux->hw.init = init;
+
+ clk = devm_clk_register(dev, &mux->hw);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
+ if (ret)
+ dev_err(dev, "Failed to add clock provider: %s\n", clk_name);
+
+ return ret;
+}
+
+static unsigned long wiz_clk_div_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct wiz_clk_divider *div = to_wiz_clk_div(hw);
+ struct regmap_field *field = div->field;
+ int val;
+
+ regmap_field_read(field, &val);
+
+ return divider_recalc_rate(hw, parent_rate, val, div->table, 0x0, 2);
+}
+
+static long wiz_clk_div_round_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long *prate)
+{
+ struct wiz_clk_divider *div = to_wiz_clk_div(hw);
+
+ return divider_round_rate(hw, rate, prate, div->table, 2, 0x0);
+}
+
+static int wiz_clk_div_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ struct wiz_clk_divider *div = to_wiz_clk_div(hw);
+ struct regmap_field *field = div->field;
+ int val;
+
+ val = divider_get_val(rate, parent_rate, div->table, 2, 0x0);
+ if (val < 0)
+ return val;
+
+ return regmap_field_write(field, val);
+}
+
+static const struct clk_ops wiz_clk_div_ops = {
+ .recalc_rate = wiz_clk_div_recalc_rate,
+ .round_rate = wiz_clk_div_round_rate,
+ .set_rate = wiz_clk_div_set_rate,
+};
+
+static int wiz_div_clk_register(struct wiz *wiz, struct device_node *node,
+ struct regmap_field *field,
+ struct clk_div_table *table)
+{
+ struct device *dev = wiz->dev;
+ struct wiz_clk_divider *div;
+ struct clk_init_data *init;
+ const char **parent_names;
+ const char *clk_name;
+ struct clk *clk;
+ int ret;
+
+ div = devm_kzalloc(dev, sizeof(*div), GFP_KERNEL);
+ if (!div)
+ return -ENOMEM;
+
+ ret = of_property_read_string(node, "clock-output-names", &clk_name);
+ if (ret) {
+ dev_err(dev, "Unable to read clock-output-names DT property\n");
+ return ret;
+ }
+
+ parent_names = devm_kzalloc(dev, sizeof(char *), GFP_KERNEL);
+ if (!parent_names)
+ return -ENOMEM;
+
+ of_clk_parent_fill(node, parent_names, 1);
+
+ init = &div->clk_data;
+
+ init->ops = &wiz_clk_div_ops;
+ init->flags = 0;
+ init->parent_names = parent_names;
+ init->num_parents = 1;
+ init->name = clk_name;
+
+ div->field = field;
+ div->table = table;
+ div->hw.init = init;
+
+ clk = devm_clk_register(dev, &div->hw);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
+ if (ret)
+ dev_err(dev, "Failed to add clock provider: %s\n", clk_name);
+
+ return ret;
+}
+
+static void wiz_clock_cleanup(struct wiz *wiz, struct device_node *node)
+{
+ struct wiz_clk_mux_sel *clk_mux_sel = wiz->clk_mux_sel;
+ struct device_node *clk_node;
+ int i;
+
+ for (i = 0; i < WIZ_MUX_NUM_CLOCKS; i++) {
+ clk_node = of_get_child_by_name(node, clk_mux_sel[i].node_name);
+ of_clk_del_provider(clk_node);
+ of_node_put(clk_node);
+ }
+}
+
+static int wiz_clock_init(struct wiz *wiz, struct device_node *node)
+{
+ struct wiz_clk_mux_sel *clk_mux_sel = wiz->clk_mux_sel;
+ struct device *dev = wiz->dev;
+ struct device_node *clk_node;
+ const char *node_name;
+ unsigned long rate;
+ struct clk *clk;
+ int ret;
+ int i;
+
+ clk = devm_clk_get(dev, "core_ref_clk");
+ if (IS_ERR(clk)) {
+ dev_err(dev, "core_ref_clk clock not found\n");
+ ret = PTR_ERR(clk);
+ return ret;
+ }
+
+ rate = clk_get_rate(clk);
+ if (rate >= 100000000)
+ regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x1);
+ else
+ regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x3);
+
+ clk = devm_clk_get(dev, "ext_ref_clk");
+ if (IS_ERR(clk)) {
+ dev_err(dev, "ext_ref_clk clock not found\n");
+ ret = PTR_ERR(clk);
+ return ret;
+ }
+
+ rate = clk_get_rate(clk);
+ if (rate >= 100000000)
+ regmap_field_write(wiz->pma_cmn_refclk_mode, 0x0);
+ else
+ regmap_field_write(wiz->pma_cmn_refclk_mode, 0x2);
+
+ for (i = 0; i < WIZ_MUX_NUM_CLOCKS; i++) {
+ node_name = clk_mux_sel[i].node_name;
+ clk_node = of_get_child_by_name(node, node_name);
+ if (!clk_node) {
+ dev_err(dev, "Unable to get %s node\n", node_name);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ ret = wiz_mux_clk_register(wiz, clk_node, clk_mux_sel[i].field,
+ clk_mux_sel[i].table);
+ if (ret) {
+ dev_err(dev, "Failed to register %s clock\n",
+ node_name);
+ of_node_put(clk_node);
+ goto err;
+ }
+
+ of_node_put(clk_node);
+ }
+
+ for (i = 0; i < wiz->clk_div_sel_num; i++) {
+ node_name = clk_div_sel[i].node_name;
+ clk_node = of_get_child_by_name(node, node_name);
+ if (!clk_node) {
+ dev_err(dev, "Unable to get %s node\n", node_name);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ ret = wiz_div_clk_register(wiz, clk_node, clk_div_sel[i].field,
+ clk_div_sel[i].table);
+ if (ret) {
+ dev_err(dev, "Failed to register %s clock\n",
+ node_name);
+ of_node_put(clk_node);
+ goto err;
+ }
+
+ of_node_put(clk_node);
+ }
+
+ return 0;
+err:
+ wiz_clock_cleanup(wiz, node);
+
+ return ret;
+}
+
+static int wiz_phy_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct device *dev = rcdev->dev;
+ struct wiz *wiz = dev_get_drvdata(dev);
+ int ret = 0;
+
+ if (id == 0) {
+ ret = regmap_field_write(wiz->phy_reset_n, false);
+ return ret;
+ }
+
+ ret = regmap_field_write(wiz->p_enable[id - 1], false);
+ return ret;
+}
+
+static int wiz_phy_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct device *dev = rcdev->dev;
+ struct wiz *wiz = dev_get_drvdata(dev);
+ int ret;
+
+ if (id == 0) {
+ ret = regmap_field_write(wiz->phy_reset_n, true);
+ return ret;
+ }
+
+ ret = regmap_field_write(wiz->p_enable[id - 1], true);
+ return ret;
+}
+
+static const struct reset_control_ops wiz_phy_reset_ops = {
+ .assert = wiz_phy_reset_assert,
+ .deassert = wiz_phy_reset_deassert,
+};
+
+static struct regmap_config wiz_regmap_config = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+ .fast_io = true,
+};
+
+static const struct of_device_id wiz_id_table[] = {
+ {
+ .compatible = "ti,j721e-wiz-16g", .data = (void *)J721E_WIZ_16G
+ },
+ {
+ .compatible = "ti,j721e-wiz-10g", .data = (void *)J721E_WIZ_10G
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, wiz_id_table);
+
+static int wiz_probe(struct platform_device *pdev)
+{
+ struct reset_controller_dev *phy_reset_dev;
+ struct device *dev = &pdev->dev;
+ struct device_node *node = dev->of_node;
+ struct platform_device *serdes_pdev;
+ struct device_node *child_node;
+ struct regmap *regmap;
+ struct resource res;
+ void __iomem *base;
+ struct wiz *wiz;
+ u32 num_lanes;
+ int ret;
+
+ wiz = devm_kzalloc(dev, sizeof(*wiz), GFP_KERNEL);
+ if (!wiz)
+ return -ENOMEM;
+
+ wiz->type = (enum wiz_type)of_device_get_match_data(dev);
+
+ child_node = of_get_child_by_name(node, "serdes");
+ if (!child_node) {
+ dev_err(dev, "Failed to get SERDES child DT node\n");
+ return -ENODEV;
+ }
+
+ ret = of_address_to_resource(child_node, 0, &res);
+ if (ret) {
+ dev_err(dev, "Failed to get memory resource\n");
+ goto err_addr_to_resource;
+ }
+
+ base = devm_ioremap(dev, res.start, resource_size(&res));
+ if (IS_ERR(base))
+ goto err_addr_to_resource;
+
+ regmap = devm_regmap_init_mmio(dev, base, &wiz_regmap_config);
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "Failed to initialize regmap\n");
+ ret = PTR_ERR(regmap);
+ goto err_addr_to_resource;
+ }
+
+ ret = of_property_read_u32(node, "num-lanes", &num_lanes);
+ if (ret) {
+ dev_err(dev, "Failed to read num-lanes property\n");
+ goto err_addr_to_resource;
+ }
+
+ if (num_lanes > WIZ_MAX_LANES) {
+ dev_err(dev, "Cannot support %d lanes\n", num_lanes);
+ goto err_addr_to_resource;
+ }
+
+ wiz->dev = dev;
+ wiz->regmap = regmap;
+ wiz->num_lanes = num_lanes;
+ if (wiz->type == J721E_WIZ_10G)
+ wiz->clk_mux_sel = clk_mux_sel_10g;
+ else
+ wiz->clk_mux_sel = clk_mux_sel_16g;
+
+ wiz->clk_div_sel = clk_div_sel;
+
+ if (wiz->type == J721E_WIZ_10G)
+ wiz->clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_10G;
+ else
+ wiz->clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_16G;
+
+ platform_set_drvdata(pdev, wiz);
+
+ ret = wiz_regfield_init(wiz);
+ if (ret) {
+ dev_err(dev, "Failed to initialize regfields\n");
+ goto err_addr_to_resource;
+ }
+
+ phy_reset_dev = &wiz->wiz_phy_reset_dev;
+ phy_reset_dev->dev = dev;
+ phy_reset_dev->ops = &wiz_phy_reset_ops,
+ phy_reset_dev->owner = THIS_MODULE,
+ phy_reset_dev->of_node = node;
+ /* Reset for each of the lane and one for the entire SERDES */
+ phy_reset_dev->nr_resets = num_lanes + 1;
+
+ ret = devm_reset_controller_register(dev, phy_reset_dev);
+ if (ret < 0) {
+ dev_warn(dev, "Failed to register reset controller\n");
+ goto err_addr_to_resource;
+ }
+
+ pm_runtime_enable(dev);
+ ret = pm_runtime_get_sync(dev);
+ if (ret < 0) {
+ dev_err(dev, "pm_runtime_get_sync failed\n");
+ goto err_get_sync;
+ }
+
+ ret = wiz_clock_init(wiz, node);
+ if (ret < 0) {
+ dev_warn(dev, "Failed to initialize clocks\n");
+ goto err_get_sync;
+ }
+
+ serdes_pdev = of_platform_device_create(child_node, NULL, dev);
+ if (!serdes_pdev) {
+ dev_WARN(dev, "Unable to create SERDES platform device\n");
+ goto err_pdev_create;
+ }
+ wiz->serdes_pdev = serdes_pdev;
+
+ ret = wiz_init(wiz);
+ if (ret) {
+ dev_err(dev, "WIZ initialization failed\n");
+ goto err_wiz_init;
+ }
+
+ of_node_put(child_node);
+ return 0;
+
+err_wiz_init:
+ of_platform_device_destroy(&serdes_pdev->dev, NULL);
+
+err_pdev_create:
+ wiz_clock_cleanup(wiz, node);
+
+err_get_sync:
+ pm_runtime_put(dev);
+ pm_runtime_disable(dev);
+
+err_addr_to_resource:
+ of_node_put(child_node);
+
+ return ret;
+}
+
+static int wiz_remove(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct device_node *node = dev->of_node;
+ struct platform_device *serdes_pdev;
+ struct wiz *wiz;
+
+ wiz = dev_get_drvdata(dev);
+ serdes_pdev = wiz->serdes_pdev;
+
+ of_platform_device_destroy(&serdes_pdev->dev, NULL);
+ wiz_clock_cleanup(wiz, node);
+ pm_runtime_put(dev);
+ pm_runtime_disable(dev);
+
+ return 0;
+}
+
+static struct platform_driver wiz_driver = {
+ .probe = wiz_probe,
+ .remove = wiz_remove,
+ .driver = {
+ .name = "wiz",
+ .of_match_table = wiz_id_table,
+ },
+};
+module_platform_driver(wiz_driver);
+
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_DESCRIPTION("TI J721E WIZ driver");
+MODULE_LICENSE("GPL v2");
--
2.17.1
Set cmn_refclk/cmn_refclk1 frequency to 25MHz as specified in
"Common Module Clock Configurations" of the Cadence Sierra 16FFC
Multi-Protocol PHYPMA Specification. It is set to 25MHz since
the only user of Cadence Sierra SERDES, TI J721E SoC provides
input clock frequency of 100MHz. For other frequencies,
cmn_refclk/cmn_refclk1 should be configured based on the
"Common Module Clock Configurations".
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index dd54a0ab89b7..affede8c4368 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -196,6 +196,8 @@ struct cdns_sierra_phy {
struct regmap_field *phy_pll_cfg_1;
struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
struct clk *clk;
+ struct clk *cmn_refclk;
+ struct clk *cmn_refclk1;
int nsubnodes;
u32 num_lanes;
bool autoconf;
@@ -277,6 +279,8 @@ static int cdns_sierra_phy_init(struct phy *gphy)
if (phy->autoconf)
return 0;
+ clk_set_rate(phy->cmn_refclk, 25000000);
+ clk_set_rate(phy->cmn_refclk1, 25000000);
if (ins->phy_type == PHY_TYPE_PCIE) {
num_cmn_regs = phy->init_data->pcie_cmn_regs;
num_ln_regs = phy->init_data->pcie_ln_regs;
@@ -466,6 +470,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
struct resource *res;
int i, ret, node = 0;
void __iomem *base;
+ struct clk *clk;
struct device_node *dn = dev->of_node, *child;
if (of_get_child_count(dn) == 0)
@@ -521,6 +526,22 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
return PTR_ERR(sp->apb_rst);
}
+ clk = devm_clk_get_optional(dev, "cmn_refclk");
+ if (IS_ERR(clk)) {
+ dev_err(dev, "core_ref_clk clock not found\n");
+ ret = PTR_ERR(clk);
+ return ret;
+ }
+ sp->cmn_refclk = clk;
+
+ clk = devm_clk_get_optional(dev, "cmn_refclk1");
+ if (IS_ERR(clk)) {
+ dev_err(dev, "core_ref_clk clock not found\n");
+ ret = PTR_ERR(clk);
+ return ret;
+ }
+ sp->cmn_refclk1 = clk;
+
ret = clk_prepare_enable(sp->clk);
if (ret)
return ret;
--
2.17.1
Check for PLL lock during PHY power on.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 33 +++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index 2648a01f90b3..82f7617b2dac 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -54,6 +54,7 @@
#define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A
#define SIERRA_PLLCTRL_GEN_D_PREG 0x03E
#define SIERRA_PLLCTRL_CPGAIN_MODE_PREG 0x03F
+#define SIERRA_PLLCTRL_STATUS_PREG 0x044
#define SIERRA_CLKPATH_BIASTRIM_PREG 0x04B
#define SIERRA_DFE_BIASTRIM_PREG 0x04C
#define SIERRA_DRVCTRL_ATTEN_PREG 0x06A
@@ -139,11 +140,14 @@
#define SIERRA_MACRO_ID 0x00007364
#define SIERRA_MAX_LANES 4
+#define PLL_LOCK_TIME 100000
static const struct reg_field macro_id_type =
REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
static const struct reg_field phy_pll_cfg_1 =
REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
+static const struct reg_field pllctrl_lock =
+ REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0);
struct cdns_sierra_inst {
struct phy *phy;
@@ -190,6 +194,7 @@ struct cdns_sierra_phy {
struct regmap *regmap_common_cdb;
struct regmap_field *macro_id_type;
struct regmap_field *phy_pll_cfg_1;
+ struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
struct clk *clk;
int nsubnodes;
bool autoconf;
@@ -289,10 +294,25 @@ static int cdns_sierra_phy_init(struct phy *gphy)
static int cdns_sierra_phy_on(struct phy *gphy)
{
+ struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
+ struct device *dev = sp->dev;
+ u32 val;
+ int ret;
/* Take the PHY lane group out of reset */
- return reset_control_deassert(ins->lnk_rst);
+ ret = reset_control_deassert(ins->lnk_rst);
+ if (ret) {
+ dev_err(dev, "Failed to take the PHY lane out of reset\n");
+ return ret;
+ }
+
+ ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
+ val, val, 1000, PLL_LOCK_TIME);
+ if (ret < 0)
+ dev_err(dev, "PLL lock of lane failed\n");
+
+ return ret;
}
static int cdns_sierra_phy_off(struct phy *gphy)
@@ -349,6 +369,7 @@ static int cdns_regfield_init(struct cdns_sierra_phy *sp)
struct device *dev = sp->dev;
struct regmap_field *field;
struct regmap *regmap;
+ int i;
regmap = sp->regmap_common_cdb;
field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
@@ -366,6 +387,16 @@ static int cdns_regfield_init(struct cdns_sierra_phy *sp)
}
sp->phy_pll_cfg_1 = field;
+ for (i = 0; i < SIERRA_MAX_LANES; i++) {
+ regmap = sp->regmap_lane_cdb[i];
+ field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
+ if (IS_ERR(field)) {
+ dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
+ return PTR_ERR(field);
+ }
+ sp->pllctrl_lock[i] = field;
+ }
+
return 0;
}
--
2.17.1
No functional change. Modify register offset macro names to be in sync with
Sierra user guide.
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/phy/cadence/phy-cadence-sierra.c | 173 ++++++++++++-----------
1 file changed, 87 insertions(+), 86 deletions(-)
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index 5c617248841f..c0ea0863d050 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -22,55 +22,56 @@
#include <dt-bindings/phy/phy.h>
/* PHY register offsets */
-#define SIERRA_COMMON_CDB_OFFSET 0x0
-#define SIERRA_MACRO_ID_REG 0x0
+#define SIERRA_COMMON_CDB_OFFSET 0x0
+#define SIERRA_MACRO_ID_REG 0x0
#define SIERRA_LANE_CDB_OFFSET(ln, offset) \
(0x4000 + ((ln) * (0x800 >> (2 - (offset)))))
-#define SIERRA_DET_STANDEC_A 0x000
-#define SIERRA_DET_STANDEC_B 0x001
-#define SIERRA_DET_STANDEC_C 0x002
-#define SIERRA_DET_STANDEC_D 0x003
-#define SIERRA_DET_STANDEC_E 0x004
-#define SIERRA_PSM_LANECAL 0x008
-#define SIERRA_PSM_DIAG 0x015
-#define SIERRA_PSC_TX_A0 0x028
-#define SIERRA_PSC_TX_A1 0x029
-#define SIERRA_PSC_TX_A2 0x02A
-#define SIERRA_PSC_TX_A3 0x02B
-#define SIERRA_PSC_RX_A0 0x030
-#define SIERRA_PSC_RX_A1 0x031
-#define SIERRA_PSC_RX_A2 0x032
-#define SIERRA_PSC_RX_A3 0x033
-#define SIERRA_PLLCTRL_SUBRATE 0x03A
-#define SIERRA_PLLCTRL_GEN_D 0x03E
-#define SIERRA_DRVCTRL_ATTEN 0x06A
-#define SIERRA_CLKPATHCTRL_TMR 0x081
-#define SIERRA_RX_CREQ_FLTR_A_MODE1 0x087
-#define SIERRA_RX_CREQ_FLTR_A_MODE0 0x088
-#define SIERRA_CREQ_CCLKDET_MODE01 0x08E
-#define SIERRA_RX_CTLE_MAINTENANCE 0x091
-#define SIERRA_CREQ_FSMCLK_SEL 0x092
-#define SIERRA_CTLELUT_CTRL 0x098
-#define SIERRA_DFE_ECMP_RATESEL 0x0C0
-#define SIERRA_DFE_SMP_RATESEL 0x0C1
-#define SIERRA_DEQ_VGATUNE_CTRL 0x0E1
-#define SIERRA_TMRVAL_MODE3 0x16E
-#define SIERRA_TMRVAL_MODE2 0x16F
-#define SIERRA_TMRVAL_MODE1 0x170
-#define SIERRA_TMRVAL_MODE0 0x171
-#define SIERRA_PICNT_MODE1 0x174
-#define SIERRA_CPI_OUTBUF_RATESEL 0x17C
-#define SIERRA_LFPSFILT_NS 0x18A
-#define SIERRA_LFPSFILT_RD 0x18B
-#define SIERRA_LFPSFILT_MP 0x18C
-#define SIERRA_SDFILT_H2L_A 0x191
-
-#define SIERRA_PHY_CONFIG_CTRL_OFFSET 0xc000
-#define SIERRA_PHY_PLL_CFG 0xe
-
-#define SIERRA_MACRO_ID 0x00007364
-#define SIERRA_MAX_LANES 4
+
+#define SIERRA_DET_STANDEC_A_PREG 0x000
+#define SIERRA_DET_STANDEC_B_PREG 0x001
+#define SIERRA_DET_STANDEC_C_PREG 0x002
+#define SIERRA_DET_STANDEC_D_PREG 0x003
+#define SIERRA_DET_STANDEC_E_PREG 0x004
+#define SIERRA_PSM_LANECAL_PREG 0x008
+#define SIERRA_PSM_DIAG_PREG 0x015
+#define SIERRA_PSC_TX_A0_PREG 0x028
+#define SIERRA_PSC_TX_A1_PREG 0x029
+#define SIERRA_PSC_TX_A2_PREG 0x02A
+#define SIERRA_PSC_TX_A3_PREG 0x02B
+#define SIERRA_PSC_RX_A0_PREG 0x030
+#define SIERRA_PSC_RX_A1_PREG 0x031
+#define SIERRA_PSC_RX_A2_PREG 0x032
+#define SIERRA_PSC_RX_A3_PREG 0x033
+#define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A
+#define SIERRA_PLLCTRL_GEN_D_PREG 0x03E
+#define SIERRA_DRVCTRL_ATTEN_PREG 0x06A
+#define SIERRA_CLKPATHCTRL_TMR_PREG 0x081
+#define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG 0x087
+#define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG 0x088
+#define SIERRA_CREQ_CCLKDET_MODE01_PREG 0x08E
+#define SIERRA_RX_CTLE_MAINTENANCE_PREG 0x091
+#define SIERRA_CREQ_FSMCLK_SEL_PREG 0x092
+#define SIERRA_CTLELUT_CTRL_PREG 0x098
+#define SIERRA_DFE_ECMP_RATESEL_PREG 0x0C0
+#define SIERRA_DFE_SMP_RATESEL_PREG 0x0C1
+#define SIERRA_DEQ_VGATUNE_CTRL_PREG 0x0E1
+#define SIERRA_TMRVAL_MODE3_PREG 0x16E
+#define SIERRA_TMRVAL_MODE2_PREG 0x16F
+#define SIERRA_TMRVAL_MODE1_PREG 0x170
+#define SIERRA_TMRVAL_MODE0_PREG 0x171
+#define SIERRA_PICNT_MODE1_PREG 0x174
+#define SIERRA_CPI_OUTBUF_RATESEL_PREG 0x17C
+#define SIERRA_LFPSFILT_NS_PREG 0x18A
+#define SIERRA_LFPSFILT_RD_PREG 0x18B
+#define SIERRA_LFPSFILT_MP_PREG 0x18C
+#define SIERRA_SDFILT_H2L_A_PREG 0x191
+
+#define SIERRA_PHY_CONFIG_CTRL_OFFSET 0xc000
+#define SIERRA_PHY_PLL_CFG 0xe
+
+#define SIERRA_MACRO_ID 0x00007364
+#define SIERRA_MAX_LANES 4
static const struct reg_field macro_id_type =
REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
@@ -494,42 +495,42 @@ static struct cdns_reg_pairs cdns_usb_regs[] = {
* These values are specific to this specific hardware
* configuration.
*/
- {0xFE0A, SIERRA_DET_STANDEC_A},
- {0x000F, SIERRA_DET_STANDEC_B},
- {0x55A5, SIERRA_DET_STANDEC_C},
- {0x69AD, SIERRA_DET_STANDEC_D},
- {0x0241, SIERRA_DET_STANDEC_E},
- {0x0110, SIERRA_PSM_LANECAL},
- {0xCF00, SIERRA_PSM_DIAG},
- {0x001F, SIERRA_PSC_TX_A0},
- {0x0007, SIERRA_PSC_TX_A1},
- {0x0003, SIERRA_PSC_TX_A2},
- {0x0003, SIERRA_PSC_TX_A3},
- {0x0FFF, SIERRA_PSC_RX_A0},
- {0x0003, SIERRA_PSC_RX_A1},
- {0x0003, SIERRA_PSC_RX_A2},
- {0x0001, SIERRA_PSC_RX_A3},
- {0x0001, SIERRA_PLLCTRL_SUBRATE},
- {0x0406, SIERRA_PLLCTRL_GEN_D},
- {0x0000, SIERRA_DRVCTRL_ATTEN},
- {0x823E, SIERRA_CLKPATHCTRL_TMR},
- {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1},
- {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0},
- {0x7B3C, SIERRA_CREQ_CCLKDET_MODE01},
- {0x023C, SIERRA_RX_CTLE_MAINTENANCE},
- {0x3232, SIERRA_CREQ_FSMCLK_SEL},
- {0x8452, SIERRA_CTLELUT_CTRL},
- {0x4121, SIERRA_DFE_ECMP_RATESEL},
- {0x4121, SIERRA_DFE_SMP_RATESEL},
- {0x9999, SIERRA_DEQ_VGATUNE_CTRL},
- {0x0330, SIERRA_TMRVAL_MODE0},
- {0x01FF, SIERRA_PICNT_MODE1},
- {0x0009, SIERRA_CPI_OUTBUF_RATESEL},
- {0x000F, SIERRA_LFPSFILT_NS},
- {0x0009, SIERRA_LFPSFILT_RD},
- {0x0001, SIERRA_LFPSFILT_MP},
- {0x8013, SIERRA_SDFILT_H2L_A},
- {0x0400, SIERRA_TMRVAL_MODE1},
+ {0xFE0A, SIERRA_DET_STANDEC_A_PREG},
+ {0x000F, SIERRA_DET_STANDEC_B_PREG},
+ {0x55A5, SIERRA_DET_STANDEC_C_PREG},
+ {0x69AD, SIERRA_DET_STANDEC_D_PREG},
+ {0x0241, SIERRA_DET_STANDEC_E_PREG},
+ {0x0110, SIERRA_PSM_LANECAL_PREG},
+ {0xCF00, SIERRA_PSM_DIAG_PREG},
+ {0x001F, SIERRA_PSC_TX_A0_PREG},
+ {0x0007, SIERRA_PSC_TX_A1_PREG},
+ {0x0003, SIERRA_PSC_TX_A2_PREG},
+ {0x0003, SIERRA_PSC_TX_A3_PREG},
+ {0x0FFF, SIERRA_PSC_RX_A0_PREG},
+ {0x0003, SIERRA_PSC_RX_A1_PREG},
+ {0x0003, SIERRA_PSC_RX_A2_PREG},
+ {0x0001, SIERRA_PSC_RX_A3_PREG},
+ {0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
+ {0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
+ {0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
+ {0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
+ {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
+ {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
+ {0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
+ {0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
+ {0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
+ {0x8452, SIERRA_CTLELUT_CTRL_PREG},
+ {0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
+ {0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
+ {0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
+ {0x0330, SIERRA_TMRVAL_MODE0_PREG},
+ {0x01FF, SIERRA_PICNT_MODE1_PREG},
+ {0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
+ {0x000F, SIERRA_LFPSFILT_NS_PREG},
+ {0x0009, SIERRA_LFPSFILT_RD_PREG},
+ {0x0001, SIERRA_LFPSFILT_MP_PREG},
+ {0x8013, SIERRA_SDFILT_H2L_A_PREG},
+ {0x0400, SIERRA_TMRVAL_MODE1_PREG},
};
static struct cdns_reg_pairs cdns_pcie_regs[] = {
@@ -538,10 +539,10 @@ static struct cdns_reg_pairs cdns_pcie_regs[] = {
* These values are specific to this specific hardware
* configuration.
*/
- {0x891f, SIERRA_DET_STANDEC_D},
- {0x0053, SIERRA_DET_STANDEC_E},
- {0x0400, SIERRA_TMRVAL_MODE2},
- {0x0200, SIERRA_TMRVAL_MODE3},
+ {0x891f, SIERRA_DET_STANDEC_D_PREG},
+ {0x0053, SIERRA_DET_STANDEC_E_PREG},
+ {0x0400, SIERRA_TMRVAL_MODE2_PREG},
+ {0x0200, SIERRA_TMRVAL_MODE3_PREG},
};
static const struct cdns_sierra_data cdns_map_sierra = {
--
2.17.1
Hi Rob,
On 23/10/19 6:27 PM, Kishon Vijay Abraham I wrote:
> Add DT binding documentation for WIZ (SERDES wrapper). WIZ is *NOT* a
> PHY but a wrapper used to configure some of the input signals to the
> SERDES. It is used with both Sierra(16G) and Torrent(10G) serdes.
>
> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
> [[email protected]: Add separate compatible for Sierra(16G) and Torrent(10G)
> SERDES]
> Signed-off-by: Jyri Sarha <[email protected]>
Since you've reviewed the other patches posted after this one, wanted to check
if this somehow slipped out of your radar.
Thanks
Kishon
> ---
> .../bindings/phy/ti,phy-j721e-wiz.yaml | 159 ++++++++++++++++++
> 1 file changed, 159 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
>
> diff --git a/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
> new file mode 100644
> index 000000000000..8a1eccee6c1d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
> @@ -0,0 +1,159 @@
> +# SPDX-License-Identifier: (GPL-2.0)
> +# Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/phy/ti,phy-j721e-wiz.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: TI J721E WIZ (SERDES Wrapper)
> +
> +maintainers:
> + - Kishon Vijay Abraham I <[email protected]>
> +
> +properties:
> + compatible:
> + oneOf:
> + - items:
> + - enum:
> + - ti,j721e-wiz-16g
> + - ti,j721e-wiz-10g
> +
> + power-domains:
> + maxItems: 1
> +
> + clocks:
> + maxItems: 3
> + description: clock-specifier to represent input to the WIZ
> +
> + clock-names:
> + items:
> + - const: fck
> + - const: core_ref_clk
> + - const: ext_ref_clk
> +
> + num-lanes:
> + maxItems: 1
> + minimum: 1
> + maximum: 4
> +
> + "#address-cells":
> + const: 2
> +
> + "#size-cells":
> + const: 2
> +
> + "#reset-cells":
> + const: 1
> +
> + ranges: true
> +
> + assigned-clocks:
> + maxItems: 2
> +
> + assigned-clock-parents:
> + maxItems: 2
> +
> +patternProperties:
> + "^pll[0|1]_refclk$":
> + type: object
> + description: |
> + WIZ node should have subnodes for each of the PLLs present in
> + the SERDES.
> +
> + "^cmn_refclk1?$":
> + type: object
> + description: |
> + WIZ node should have subnodes for each of the PMA common refclock
> + provided by the SERDES.
> +
> + "^refclk_dig$":
> + type: object
> + description: |
> + WIZ node should have subnode for refclk_dig to select the reference
> + clock source for the reference clock used in the PHY and PMA digital
> + logic.
> +
> + "^serdes@[0-9a-f]+$":
> + type: object
> + description: |
> + WIZ node should have '1' subnode for the SERDES. It could be either
> + Sierra SERDES or Torrent SERDES. Sierra SERDES should follow the
> + bindings specified in
> + Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> + Torrent SERDES should follow the bindings specified in
> + Documentation/devicetree/bindings/phy/phy-cadence-dp.txt
> +
> +required:
> + - compatible
> + - power-domains
> + - clocks
> + - clock-names
> + - num-lanes
> + - "#address-cells"
> + - "#size-cells"
> + - "#reset-cells"
> +
> +examples:
> + - |
> + #include <dt-bindings/soc/ti,sci_pm_domain.h>
> +
> + wiz@5000000 {
> + compatible = "ti,j721e-wiz-16g";
> + #address-cells = <2>;
> + #size-cells = <2>;
> + power-domains = <&k3_pds 292 TI_SCI_PD_EXCLUSIVE>;
> + clocks = <&k3_clks 292 5>, <&k3_clks 292 11>, <&dummy_cmn_refclk>;
> + clock-names = "fck", "core_ref_clk", "ext_ref_clk";
> + assigned-clocks = <&k3_clks 292 11>, <&k3_clks 292 0>;
> + assigned-clock-parents = <&k3_clks 292 15>, <&k3_clks 292 4>;
> + num-lanes = <2>;
> + #reset-cells = <1>;
> +
> + pll0_refclk {
> + clocks = <&k3_clks 293 13>, <&dummy_cmn_refclk>;
> + clock-output-names = "wiz1_pll0_refclk";
> + #clock-cells = <0>;
> + assigned-clocks = <&wiz1_pll0_refclk>;
> + assigned-clock-parents = <&k3_clks 293 13>;
> + };
> +
> + pll1_refclk {
> + clocks = <&k3_clks 293 0>, <&dummy_cmn_refclk1>;
> + clock-output-names = "wiz1_pll1_refclk";
> + #clock-cells = <0>;
> + assigned-clocks = <&wiz1_pll1_refclk>;
> + assigned-clock-parents = <&k3_clks 293 0>;
> + };
> +
> + cmn_refclk {
> + clocks = <&wiz1_refclk_dig>;
> + clock-output-names = "wiz1_cmn_refclk";
> + #clock-cells = <0>;
> + };
> +
> + cmn_refclk1 {
> + clocks = <&wiz1_pll1_refclk>;
> + clock-output-names = "wiz1_cmn_refclk1";
> + #clock-cells = <0>;
> + };
> +
> + refclk_dig {
> + clocks = <&k3_clks 292 11>, <&k3_clks 292 0>, <&dummy_cmn_refclk>, <&dummy_cmn_refclk1>;
> + clock-output-names = "wiz0_refclk_dig";
> + #clock-cells = <0>;
> + assigned-clocks = <&wiz0_refclk_dig>;
> + assigned-clock-parents = <&k3_clks 292 11>;
> + };
> +
> + serdes@5000000 {
> + compatible = "cdns,ti,sierra-phy-t0";
> + reg-names = "serdes";
> + reg = <0x00 0x5000000 0x00 0x10000>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + resets = <&serdes_wiz0 0>;
> + reset-names = "sierra_reset";
> + clocks = <&wiz0_cmn_refclk>, <&wiz0_cmn_refclk1>;
> + clock-names = "cmn_refclk", "cmn_refclk1";
> + };
> + };
>
On Wed, Oct 23, 2019 at 06:27:22PM +0530, Kishon Vijay Abraham I wrote:
> Add DT binding documentation for Sierra PHY IP used in TI's J721E
> SoC.
>
> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
> ---
> .../devicetree/bindings/phy/phy-cadence-sierra.txt | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt b/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> index 6e1b47bfce43..bf90ef7e005e 100644
> --- a/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> +++ b/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> @@ -2,21 +2,24 @@ Cadence Sierra PHY
> -----------------------
>
> Required properties:
> -- compatible: cdns,sierra-phy-t0
> -- clocks: Must contain an entry in clock-names.
> - See ../clocks/clock-bindings.txt for details.
> -- clock-names: Must be "phy_clk"
> +- compatible: Must be "cdns,sierra-phy-t0" for Sierra in Cadence platform
> + Must be "ti,sierra-phy-t0" for Sierra in TI's J721E SoC.
> - resets: Must contain an entry for each in reset-names.
> See ../reset/reset.txt for details.
> - reset-names: Must include "sierra_reset" and "sierra_apb".
> "sierra_reset" must control the reset line to the PHY.
> "sierra_apb" must control the reset line to the APB PHY
> - interface.
> + interface ("sierra_apb" is optional).
> - reg: register range for the PHY.
> - #address-cells: Must be 1
> - #size-cells: Must be 0
>
> Optional properties:
> +- clocks: Must contain an entry in clock-names.
> + See ../clocks/clock-bindings.txt for details.
> +- clock-names: Must be "phy_clk". Must contain "cmn_refclk" and
> + "cmn_refclk1" for configuring the frequency of the
> + clock to the lanes.
I don't understand how the same block can have completely different
clocks. Did the original binding forget some?
TI needs 0, 1 or 3 clocks? Reads like it could be any.
Rob
On Wed, Oct 23, 2019 at 06:27:34PM +0530, Kishon Vijay Abraham I wrote:
> Add DT binding documentation for WIZ (SERDES wrapper). WIZ is *NOT* a
> PHY but a wrapper used to configure some of the input signals to the
> SERDES. It is used with both Sierra(16G) and Torrent(10G) serdes.
>
> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
> [[email protected]: Add separate compatible for Sierra(16G) and Torrent(10G)
> SERDES]
> Signed-off-by: Jyri Sarha <[email protected]>
> ---
> .../bindings/phy/ti,phy-j721e-wiz.yaml | 159 ++++++++++++++++++
> 1 file changed, 159 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
>
> diff --git a/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
> new file mode 100644
> index 000000000000..8a1eccee6c1d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
> @@ -0,0 +1,159 @@
> +# SPDX-License-Identifier: (GPL-2.0)
(GPL-2.0-only OR BSD-2-Clause) for new bindings please.
> +# Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/phy/ti,phy-j721e-wiz.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: TI J721E WIZ (SERDES Wrapper)
> +
> +maintainers:
> + - Kishon Vijay Abraham I <[email protected]>
> +
> +properties:
> + compatible:
> + oneOf:
> + - items:
> + - enum:
> + - ti,j721e-wiz-16g
> + - ti,j721e-wiz-10g
You can drop oneOf and items.
> +
> + power-domains:
> + maxItems: 1
> +
> + clocks:
> + maxItems: 3
> + description: clock-specifier to represent input to the WIZ
> +
> + clock-names:
> + items:
> + - const: fck
> + - const: core_ref_clk
> + - const: ext_ref_clk
> +
> + num-lanes:
> + maxItems: 1
> + minimum: 1
> + maximum: 4
You've mixed array and scalar schema keywords. Drop maxItems.
Update dtschema and run 'make dt_binding_check'. We should catch that
now.
> +
> + "#address-cells":
> + const: 2
> +
> + "#size-cells":
> + const: 2
> +
> + "#reset-cells":
> + const: 1
> +
> + ranges: true
> +
> + assigned-clocks:
> + maxItems: 2
> +
> + assigned-clock-parents:
> + maxItems: 2
> +
> +patternProperties:
> + "^pll[0|1]_refclk$":
> + type: object
> + description: |
> + WIZ node should have subnodes for each of the PLLs present in
> + the SERDES.
> +
> + "^cmn_refclk1?$":
> + type: object
> + description: |
> + WIZ node should have subnodes for each of the PMA common refclock
> + provided by the SERDES.
> +
> + "^refclk_dig$":
> + type: object
> + description: |
> + WIZ node should have subnode for refclk_dig to select the reference
> + clock source for the reference clock used in the PHY and PMA digital
> + logic.
> +
> + "^serdes@[0-9a-f]+$":
> + type: object
> + description: |
> + WIZ node should have '1' subnode for the SERDES. It could be either
> + Sierra SERDES or Torrent SERDES. Sierra SERDES should follow the
> + bindings specified in
> + Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> + Torrent SERDES should follow the bindings specified in
> + Documentation/devicetree/bindings/phy/phy-cadence-dp.txt
> +
> +required:
> + - compatible
> + - power-domains
> + - clocks
> + - clock-names
> + - num-lanes
> + - "#address-cells"
> + - "#size-cells"
> + - "#reset-cells"
> +
> +examples:
> + - |
> + #include <dt-bindings/soc/ti,sci_pm_domain.h>
> +
> + wiz@5000000 {
> + compatible = "ti,j721e-wiz-16g";
> + #address-cells = <2>;
> + #size-cells = <2>;
Really need 64-bits of address space for the child nodes?
> + power-domains = <&k3_pds 292 TI_SCI_PD_EXCLUSIVE>;
> + clocks = <&k3_clks 292 5>, <&k3_clks 292 11>, <&dummy_cmn_refclk>;
> + clock-names = "fck", "core_ref_clk", "ext_ref_clk";
> + assigned-clocks = <&k3_clks 292 11>, <&k3_clks 292 0>;
> + assigned-clock-parents = <&k3_clks 292 15>, <&k3_clks 292 4>;
> + num-lanes = <2>;
> + #reset-cells = <1>;
Unless you have additional registers, I'm not a fan of wrapper nodes.
> +
> + pll0_refclk {
> + clocks = <&k3_clks 293 13>, <&dummy_cmn_refclk>;
> + clock-output-names = "wiz1_pll0_refclk";
> + #clock-cells = <0>;
> + assigned-clocks = <&wiz1_pll0_refclk>;
> + assigned-clock-parents = <&k3_clks 293 13>;
> + };
> +
> + pll1_refclk {
> + clocks = <&k3_clks 293 0>, <&dummy_cmn_refclk1>;
> + clock-output-names = "wiz1_pll1_refclk";
> + #clock-cells = <0>;
> + assigned-clocks = <&wiz1_pll1_refclk>;
> + assigned-clock-parents = <&k3_clks 293 0>;
> + };
> +
> + cmn_refclk {
> + clocks = <&wiz1_refclk_dig>;
> + clock-output-names = "wiz1_cmn_refclk";
> + #clock-cells = <0>;
> + };
> +
> + cmn_refclk1 {
> + clocks = <&wiz1_pll1_refclk>;
> + clock-output-names = "wiz1_cmn_refclk1";
> + #clock-cells = <0>;
> + };
> +
> + refclk_dig {
> + clocks = <&k3_clks 292 11>, <&k3_clks 292 0>, <&dummy_cmn_refclk>, <&dummy_cmn_refclk1>;
> + clock-output-names = "wiz0_refclk_dig";
> + #clock-cells = <0>;
> + assigned-clocks = <&wiz0_refclk_dig>;
> + assigned-clock-parents = <&k3_clks 292 11>;
> + };
How are all these clocks programmed?
> +
> + serdes@5000000 {
> + compatible = "cdns,ti,sierra-phy-t0";
> + reg-names = "serdes";
> + reg = <0x00 0x5000000 0x00 0x10000>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + resets = <&serdes_wiz0 0>;
> + reset-names = "sierra_reset";
> + clocks = <&wiz0_cmn_refclk>, <&wiz0_cmn_refclk1>;
> + clock-names = "cmn_refclk", "cmn_refclk1";
> + };
> + };
> --
> 2.17.1
>
Hi Rob,
On 30/10/19 12:29 AM, Rob Herring wrote:
> On Wed, Oct 23, 2019 at 06:27:22PM +0530, Kishon Vijay Abraham I wrote:
>> Add DT binding documentation for Sierra PHY IP used in TI's J721E
>> SoC.
>>
>> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
>> ---
>> .../devicetree/bindings/phy/phy-cadence-sierra.txt | 13 ++++++++-----
>> 1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt b/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
>> index 6e1b47bfce43..bf90ef7e005e 100644
>> --- a/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
>> +++ b/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
>> @@ -2,21 +2,24 @@ Cadence Sierra PHY
>> -----------------------
>>
>> Required properties:
>> -- compatible: cdns,sierra-phy-t0
>> -- clocks: Must contain an entry in clock-names.
>> - See ../clocks/clock-bindings.txt for details.
>> -- clock-names: Must be "phy_clk"
>> +- compatible: Must be "cdns,sierra-phy-t0" for Sierra in Cadence platform
>> + Must be "ti,sierra-phy-t0" for Sierra in TI's J721E SoC.
>> - resets: Must contain an entry for each in reset-names.
>> See ../reset/reset.txt for details.
>> - reset-names: Must include "sierra_reset" and "sierra_apb".
>> "sierra_reset" must control the reset line to the PHY.
>> "sierra_apb" must control the reset line to the APB PHY
>> - interface.
>> + interface ("sierra_apb" is optional).
>> - reg: register range for the PHY.
>> - #address-cells: Must be 1
>> - #size-cells: Must be 0
>>
>> Optional properties:
>> +- clocks: Must contain an entry in clock-names.
>> + See ../clocks/clock-bindings.txt for details.
>> +- clock-names: Must be "phy_clk". Must contain "cmn_refclk" and
>> + "cmn_refclk1" for configuring the frequency of the
>> + clock to the lanes.
>
> I don't understand how the same block can have completely different
> clocks. Did the original binding forget some?
>
> TI needs 0, 1 or 3 clocks? Reads like it could be any.
For TI, phy_clk is not needed. Anil, can you clarify what this clock actually
corresponds to? Is it a functional clock of PHY?
Sierra SERDES actually has a number of clocks which can be configured. The
initial dt-binding didn't model all these clocks. The "cmn_refclk" and
"cmn_refclk1" are used to program the dividers withing the Sierra. The actual
registers for programming the dividers are in the Sierra wrapper though. The
original Sierra driver and dt-binding didn't try to change the default divider
values.
Thanks
Kishon
>
> Rob
>
Hi,
On 30/10/19 12:38 AM, Rob Herring wrote:
> On Wed, Oct 23, 2019 at 06:27:34PM +0530, Kishon Vijay Abraham I wrote:
>> Add DT binding documentation for WIZ (SERDES wrapper). WIZ is *NOT* a
>> PHY but a wrapper used to configure some of the input signals to the
>> SERDES. It is used with both Sierra(16G) and Torrent(10G) serdes.
>>
>> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
>> [[email protected]: Add separate compatible for Sierra(16G) and Torrent(10G)
>> SERDES]
>> Signed-off-by: Jyri Sarha <[email protected]>
>> ---
>> .../bindings/phy/ti,phy-j721e-wiz.yaml | 159 ++++++++++++++++++
>> 1 file changed, 159 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
>> new file mode 100644
>> index 000000000000..8a1eccee6c1d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
>> @@ -0,0 +1,159 @@
>> +# SPDX-License-Identifier: (GPL-2.0)
>
> (GPL-2.0-only OR BSD-2-Clause) for new bindings please.
>
>> +# Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
>> +%YAML 1.2
>> +---
>> +$id: "http://devicetree.org/schemas/phy/ti,phy-j721e-wiz.yaml#"
>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
>> +
>> +title: TI J721E WIZ (SERDES Wrapper)
>> +
>> +maintainers:
>> + - Kishon Vijay Abraham I <[email protected]>
>> +
>> +properties:
>> + compatible:
>> + oneOf:
>> + - items:
>> + - enum:
>> + - ti,j721e-wiz-16g
>> + - ti,j721e-wiz-10g
>
> You can drop oneOf and items.
>
>> +
>> + power-domains:
>> + maxItems: 1
>> +
>> + clocks:
>> + maxItems: 3
>> + description: clock-specifier to represent input to the WIZ
>> +
>> + clock-names:
>> + items:
>> + - const: fck
>> + - const: core_ref_clk
>> + - const: ext_ref_clk
>> +
>> + num-lanes:
>> + maxItems: 1
>> + minimum: 1
>> + maximum: 4
>
> You've mixed array and scalar schema keywords. Drop maxItems.
>
> Update dtschema and run 'make dt_binding_check'. We should catch that
> now.
Sure.
>
>> +
>> + "#address-cells":
>> + const: 2
>> +
>> + "#size-cells":
>> + const: 2
>> +
>> + "#reset-cells":
>> + const: 1
>> +
>> + ranges: true
>> +
>> + assigned-clocks:
>> + maxItems: 2
>> +
>> + assigned-clock-parents:
>> + maxItems: 2
>> +
>> +patternProperties:
>> + "^pll[0|1]_refclk$":
>> + type: object
>> + description: |
>> + WIZ node should have subnodes for each of the PLLs present in
>> + the SERDES.
>> +
>> + "^cmn_refclk1?$":
>> + type: object
>> + description: |
>> + WIZ node should have subnodes for each of the PMA common refclock
>> + provided by the SERDES.
>> +
>> + "^refclk_dig$":
>> + type: object
>> + description: |
>> + WIZ node should have subnode for refclk_dig to select the reference
>> + clock source for the reference clock used in the PHY and PMA digital
>> + logic.
>> +
>> + "^serdes@[0-9a-f]+$":
>> + type: object
>> + description: |
>> + WIZ node should have '1' subnode for the SERDES. It could be either
>> + Sierra SERDES or Torrent SERDES. Sierra SERDES should follow the
>> + bindings specified in
>> + Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
>> + Torrent SERDES should follow the bindings specified in
>> + Documentation/devicetree/bindings/phy/phy-cadence-dp.txt
>> +
>> +required:
>> + - compatible
>> + - power-domains
>> + - clocks
>> + - clock-names
>> + - num-lanes
>> + - "#address-cells"
>> + - "#size-cells"
>> + - "#reset-cells"
>> +
>> +examples:
>> + - |
>> + #include <dt-bindings/soc/ti,sci_pm_domain.h>
>> +
>> + wiz@5000000 {
>> + compatible = "ti,j721e-wiz-16g";
>> + #address-cells = <2>;
>> + #size-cells = <2>;
>
> Really need 64-bits of address space for the child nodes?
hmm, the register space for the child nodes are in the 32-bit address space
region. I'll fix this.
>
>> + power-domains = <&k3_pds 292 TI_SCI_PD_EXCLUSIVE>;
>> + clocks = <&k3_clks 292 5>, <&k3_clks 292 11>, <&dummy_cmn_refclk>;
>> + clock-names = "fck", "core_ref_clk", "ext_ref_clk";
>> + assigned-clocks = <&k3_clks 292 11>, <&k3_clks 292 0>;
>> + assigned-clock-parents = <&k3_clks 292 15>, <&k3_clks 292 4>;
>> + num-lanes = <2>;
>> + #reset-cells = <1>;
>
> Unless you have additional registers, I'm not a fan of wrapper nodes.
The wrapper node has TI specific registers while the child node has Cadence
Sierra specific registers. It also has clock nodes which are input to the
Sierra IP.
>
>> +
>> + pll0_refclk {
>> + clocks = <&k3_clks 293 13>, <&dummy_cmn_refclk>;
>> + clock-output-names = "wiz1_pll0_refclk";
>> + #clock-cells = <0>;
>> + assigned-clocks = <&wiz1_pll0_refclk>;
>> + assigned-clock-parents = <&k3_clks 293 13>;
>> + };
>> +
>> + pll1_refclk {
>> + clocks = <&k3_clks 293 0>, <&dummy_cmn_refclk1>;
>> + clock-output-names = "wiz1_pll1_refclk";
>> + #clock-cells = <0>;
>> + assigned-clocks = <&wiz1_pll1_refclk>;
>> + assigned-clock-parents = <&k3_clks 293 0>;
>> + };
>> +
>> + cmn_refclk {
>> + clocks = <&wiz1_refclk_dig>;
>> + clock-output-names = "wiz1_cmn_refclk";
>> + #clock-cells = <0>;
>> + };
>> +
>> + cmn_refclk1 {
>> + clocks = <&wiz1_pll1_refclk>;
>> + clock-output-names = "wiz1_cmn_refclk1";
>> + #clock-cells = <0>;
>> + };
>> +
>> + refclk_dig {
>> + clocks = <&k3_clks 292 11>, <&k3_clks 292 0>, <&dummy_cmn_refclk>, <&dummy_cmn_refclk1>;
>> + clock-output-names = "wiz0_refclk_dig";
>> + #clock-cells = <0>;
>> + assigned-clocks = <&wiz0_refclk_dig>;
>> + assigned-clock-parents = <&k3_clks 292 11>;
>> + };
>
> How are all these clocks programmed?
All these are programmed in the WIZ driver which is implemented in 14/14 of
this series.
Thanks
Kishon
On Wed, Oct 30, 2019 at 12:46 AM Kishon Vijay Abraham I <[email protected]> wrote:
>
> Hi,
>
> On 30/10/19 12:38 AM, Rob Herring wrote:
> > On Wed, Oct 23, 2019 at 06:27:34PM +0530, Kishon Vijay Abraham I wrote:
> >> Add DT binding documentation for WIZ (SERDES wrapper). WIZ is *NOT* a
> >> PHY but a wrapper used to configure some of the input signals to the
> >> SERDES. It is used with both Sierra(16G) and Torrent(10G) serdes.
> >>
> >> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
> >> [[email protected]: Add separate compatible for Sierra(16G) and Torrent(10G)
> >> SERDES]
> >> Signed-off-by: Jyri Sarha <[email protected]>
> >> ---
> >> .../bindings/phy/ti,phy-j721e-wiz.yaml | 159 ++++++++++++++++++
> >> 1 file changed, 159 insertions(+)
> >> create mode 100644 Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
> >>
> >> diff --git a/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
> >> new file mode 100644
> >> index 000000000000..8a1eccee6c1d
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
> >> @@ -0,0 +1,159 @@
> >> +# SPDX-License-Identifier: (GPL-2.0)
> >
> > (GPL-2.0-only OR BSD-2-Clause) for new bindings please.
> >
> >> +# Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
> >> +%YAML 1.2
> >> +---
> >> +$id: "http://devicetree.org/schemas/phy/ti,phy-j721e-wiz.yaml#"
> >> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> >> +
> >> +title: TI J721E WIZ (SERDES Wrapper)
> >> +
> >> +maintainers:
> >> + - Kishon Vijay Abraham I <[email protected]>
> >> +
> >> +properties:
> >> + compatible:
> >> + oneOf:
> >> + - items:
> >> + - enum:
> >> + - ti,j721e-wiz-16g
> >> + - ti,j721e-wiz-10g
> >
> > You can drop oneOf and items.
> >
> >> +
> >> + power-domains:
> >> + maxItems: 1
> >> +
> >> + clocks:
> >> + maxItems: 3
> >> + description: clock-specifier to represent input to the WIZ
> >> +
> >> + clock-names:
> >> + items:
> >> + - const: fck
> >> + - const: core_ref_clk
> >> + - const: ext_ref_clk
> >> +
> >> + num-lanes:
> >> + maxItems: 1
> >> + minimum: 1
> >> + maximum: 4
> >
> > You've mixed array and scalar schema keywords. Drop maxItems.
> >
> > Update dtschema and run 'make dt_binding_check'. We should catch that
> > now.
>
> Sure.
> >
> >> +
> >> + "#address-cells":
> >> + const: 2
> >> +
> >> + "#size-cells":
> >> + const: 2
> >> +
> >> + "#reset-cells":
> >> + const: 1
> >> +
> >> + ranges: true
> >> +
> >> + assigned-clocks:
> >> + maxItems: 2
> >> +
> >> + assigned-clock-parents:
> >> + maxItems: 2
> >> +
> >> +patternProperties:
> >> + "^pll[0|1]_refclk$":
> >> + type: object
> >> + description: |
> >> + WIZ node should have subnodes for each of the PLLs present in
> >> + the SERDES.
> >> +
> >> + "^cmn_refclk1?$":
> >> + type: object
> >> + description: |
> >> + WIZ node should have subnodes for each of the PMA common refclock
> >> + provided by the SERDES.
> >> +
> >> + "^refclk_dig$":
> >> + type: object
> >> + description: |
> >> + WIZ node should have subnode for refclk_dig to select the reference
> >> + clock source for the reference clock used in the PHY and PMA digital
> >> + logic.
> >> +
> >> + "^serdes@[0-9a-f]+$":
> >> + type: object
> >> + description: |
> >> + WIZ node should have '1' subnode for the SERDES. It could be either
> >> + Sierra SERDES or Torrent SERDES. Sierra SERDES should follow the
> >> + bindings specified in
> >> + Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> >> + Torrent SERDES should follow the bindings specified in
> >> + Documentation/devicetree/bindings/phy/phy-cadence-dp.txt
> >> +
> >> +required:
> >> + - compatible
> >> + - power-domains
> >> + - clocks
> >> + - clock-names
> >> + - num-lanes
> >> + - "#address-cells"
> >> + - "#size-cells"
> >> + - "#reset-cells"
> >> +
> >> +examples:
> >> + - |
> >> + #include <dt-bindings/soc/ti,sci_pm_domain.h>
> >> +
> >> + wiz@5000000 {
> >> + compatible = "ti,j721e-wiz-16g";
> >> + #address-cells = <2>;
> >> + #size-cells = <2>;
> >
> > Really need 64-bits of address space for the child nodes?
>
> hmm, the register space for the child nodes are in the 32-bit address space
> region. I'll fix this.
> >
> >> + power-domains = <&k3_pds 292 TI_SCI_PD_EXCLUSIVE>;
> >> + clocks = <&k3_clks 292 5>, <&k3_clks 292 11>, <&dummy_cmn_refclk>;
> >> + clock-names = "fck", "core_ref_clk", "ext_ref_clk";
> >> + assigned-clocks = <&k3_clks 292 11>, <&k3_clks 292 0>;
> >> + assigned-clock-parents = <&k3_clks 292 15>, <&k3_clks 292 4>;
> >> + num-lanes = <2>;
> >> + #reset-cells = <1>;
> >
> > Unless you have additional registers, I'm not a fan of wrapper nodes.
>
> The wrapper node has TI specific registers while the child node has Cadence
> Sierra specific registers. It also has clock nodes which are input to the
> Sierra IP.
Yeah? Where's 'reg'?
> >
> >> +
> >> + pll0_refclk {
> >> + clocks = <&k3_clks 293 13>, <&dummy_cmn_refclk>;
> >> + clock-output-names = "wiz1_pll0_refclk";
> >> + #clock-cells = <0>;
> >> + assigned-clocks = <&wiz1_pll0_refclk>;
> >> + assigned-clock-parents = <&k3_clks 293 13>;
> >> + };
> >> +
> >> + pll1_refclk {
> >> + clocks = <&k3_clks 293 0>, <&dummy_cmn_refclk1>;
> >> + clock-output-names = "wiz1_pll1_refclk";
> >> + #clock-cells = <0>;
> >> + assigned-clocks = <&wiz1_pll1_refclk>;
> >> + assigned-clock-parents = <&k3_clks 293 0>;
> >> + };
> >> +
> >> + cmn_refclk {
> >> + clocks = <&wiz1_refclk_dig>;
> >> + clock-output-names = "wiz1_cmn_refclk";
> >> + #clock-cells = <0>;
> >> + };
> >> +
> >> + cmn_refclk1 {
> >> + clocks = <&wiz1_pll1_refclk>;
> >> + clock-output-names = "wiz1_cmn_refclk1";
> >> + #clock-cells = <0>;
> >> + };
> >> +
> >> + refclk_dig {
> >> + clocks = <&k3_clks 292 11>, <&k3_clks 292 0>, <&dummy_cmn_refclk>, <&dummy_cmn_refclk1>;
> >> + clock-output-names = "wiz0_refclk_dig";
> >> + #clock-cells = <0>;
> >> + assigned-clocks = <&wiz0_refclk_dig>;
> >> + assigned-clock-parents = <&k3_clks 292 11>;
> >> + };
> >
> > How are all these clocks programmed?
>
> All these are programmed in the WIZ driver which is implemented in 14/14 of
> this series.
Not what I meant... How does one access the h/w because there's
nothing defined here to do so.
Rob
Hi Rob,
On 31/10/19 12:56 AM, Rob Herring wrote:
> On Wed, Oct 30, 2019 at 12:46 AM Kishon Vijay Abraham I <[email protected]> wrote:
>>
>> Hi,
>>
>> On 30/10/19 12:38 AM, Rob Herring wrote:
>>> On Wed, Oct 23, 2019 at 06:27:34PM +0530, Kishon Vijay Abraham I wrote:
>>>> Add DT binding documentation for WIZ (SERDES wrapper). WIZ is *NOT* a
>>>> PHY but a wrapper used to configure some of the input signals to the
>>>> SERDES. It is used with both Sierra(16G) and Torrent(10G) serdes.
>>>>
>>>> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
>>>> [[email protected]: Add separate compatible for Sierra(16G) and Torrent(10G)
>>>> SERDES]
>>>> Signed-off-by: Jyri Sarha <[email protected]>
>>>> ---
>>>> .../bindings/phy/ti,phy-j721e-wiz.yaml | 159 ++++++++++++++++++
>>>> 1 file changed, 159 insertions(+)
>>>> create mode 100644 Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
>>>> new file mode 100644
>>>> index 000000000000..8a1eccee6c1d
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
>>>> @@ -0,0 +1,159 @@
>>>> +# SPDX-License-Identifier: (GPL-2.0)
>>>
>>> (GPL-2.0-only OR BSD-2-Clause) for new bindings please.
>>>
>>>> +# Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
>>>> +%YAML 1.2
>>>> +---
>>>> +$id: "http://devicetree.org/schemas/phy/ti,phy-j721e-wiz.yaml#"
>>>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
>>>> +
>>>> +title: TI J721E WIZ (SERDES Wrapper)
>>>> +
>>>> +maintainers:
>>>> + - Kishon Vijay Abraham I <[email protected]>
>>>> +
>>>> +properties:
>>>> + compatible:
>>>> + oneOf:
>>>> + - items:
>>>> + - enum:
>>>> + - ti,j721e-wiz-16g
>>>> + - ti,j721e-wiz-10g
>>>
>>> You can drop oneOf and items.
>>>
>>>> +
>>>> + power-domains:
>>>> + maxItems: 1
>>>> +
>>>> + clocks:
>>>> + maxItems: 3
>>>> + description: clock-specifier to represent input to the WIZ
>>>> +
>>>> + clock-names:
>>>> + items:
>>>> + - const: fck
>>>> + - const: core_ref_clk
>>>> + - const: ext_ref_clk
>>>> +
>>>> + num-lanes:
>>>> + maxItems: 1
>>>> + minimum: 1
>>>> + maximum: 4
>>>
>>> You've mixed array and scalar schema keywords. Drop maxItems.
>>>
>>> Update dtschema and run 'make dt_binding_check'. We should catch that
>>> now.
>>
>> Sure.
>>>
>>>> +
>>>> + "#address-cells":
>>>> + const: 2
>>>> +
>>>> + "#size-cells":
>>>> + const: 2
>>>> +
>>>> + "#reset-cells":
>>>> + const: 1
>>>> +
>>>> + ranges: true
>>>> +
>>>> + assigned-clocks:
>>>> + maxItems: 2
>>>> +
>>>> + assigned-clock-parents:
>>>> + maxItems: 2
>>>> +
>>>> +patternProperties:
>>>> + "^pll[0|1]_refclk$":
>>>> + type: object
>>>> + description: |
>>>> + WIZ node should have subnodes for each of the PLLs present in
>>>> + the SERDES.
>>>> +
>>>> + "^cmn_refclk1?$":
>>>> + type: object
>>>> + description: |
>>>> + WIZ node should have subnodes for each of the PMA common refclock
>>>> + provided by the SERDES.
>>>> +
>>>> + "^refclk_dig$":
>>>> + type: object
>>>> + description: |
>>>> + WIZ node should have subnode for refclk_dig to select the reference
>>>> + clock source for the reference clock used in the PHY and PMA digital
>>>> + logic.
>>>> +
>>>> + "^serdes@[0-9a-f]+$":
>>>> + type: object
>>>> + description: |
>>>> + WIZ node should have '1' subnode for the SERDES. It could be either
>>>> + Sierra SERDES or Torrent SERDES. Sierra SERDES should follow the
>>>> + bindings specified in
>>>> + Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
>>>> + Torrent SERDES should follow the bindings specified in
>>>> + Documentation/devicetree/bindings/phy/phy-cadence-dp.txt
>>>> +
>>>> +required:
>>>> + - compatible
>>>> + - power-domains
>>>> + - clocks
>>>> + - clock-names
>>>> + - num-lanes
>>>> + - "#address-cells"
>>>> + - "#size-cells"
>>>> + - "#reset-cells"
>>>> +
>>>> +examples:
>>>> + - |
>>>> + #include <dt-bindings/soc/ti,sci_pm_domain.h>
>>>> +
>>>> + wiz@5000000 {
>>>> + compatible = "ti,j721e-wiz-16g";
>>>> + #address-cells = <2>;
>>>> + #size-cells = <2>;
>>>
>>> Really need 64-bits of address space for the child nodes?
>>
>> hmm, the register space for the child nodes are in the 32-bit address space
>> region. I'll fix this.
>>>
>>>> + power-domains = <&k3_pds 292 TI_SCI_PD_EXCLUSIVE>;
>>>> + clocks = <&k3_clks 292 5>, <&k3_clks 292 11>, <&dummy_cmn_refclk>;
>>>> + clock-names = "fck", "core_ref_clk", "ext_ref_clk";
>>>> + assigned-clocks = <&k3_clks 292 11>, <&k3_clks 292 0>;
>>>> + assigned-clock-parents = <&k3_clks 292 15>, <&k3_clks 292 4>;
>>>> + num-lanes = <2>;
>>>> + #reset-cells = <1>;
>>>
>>> Unless you have additional registers, I'm not a fan of wrapper nodes.
>>
>> The wrapper node has TI specific registers while the child node has Cadence
>> Sierra specific registers. It also has clock nodes which are input to the
>> Sierra IP.
>
> Yeah? Where's 'reg'?
The TI specific PHY registers use some of the reserved space within the Cadence
region. So the WIZ wrapper driver will get the address from the "serdes" child
node.
>
>>>
>>>> +
>>>> + pll0_refclk {
>>>> + clocks = <&k3_clks 293 13>, <&dummy_cmn_refclk>;
>>>> + clock-output-names = "wiz1_pll0_refclk";
>>>> + #clock-cells = <0>;
>>>> + assigned-clocks = <&wiz1_pll0_refclk>;
>>>> + assigned-clock-parents = <&k3_clks 293 13>;
>>>> + };
>>>> +
>>>> + pll1_refclk {
>>>> + clocks = <&k3_clks 293 0>, <&dummy_cmn_refclk1>;
>>>> + clock-output-names = "wiz1_pll1_refclk";
>>>> + #clock-cells = <0>;
>>>> + assigned-clocks = <&wiz1_pll1_refclk>;
>>>> + assigned-clock-parents = <&k3_clks 293 0>;
>>>> + };
>>>> +
>>>> + cmn_refclk {
>>>> + clocks = <&wiz1_refclk_dig>;
>>>> + clock-output-names = "wiz1_cmn_refclk";
>>>> + #clock-cells = <0>;
>>>> + };
>>>> +
>>>> + cmn_refclk1 {
>>>> + clocks = <&wiz1_pll1_refclk>;
>>>> + clock-output-names = "wiz1_cmn_refclk1";
>>>> + #clock-cells = <0>;
>>>> + };
>>>> +
>>>> + refclk_dig {
>>>> + clocks = <&k3_clks 292 11>, <&k3_clks 292 0>, <&dummy_cmn_refclk>, <&dummy_cmn_refclk1>;
>>>> + clock-output-names = "wiz0_refclk_dig";
>>>> + #clock-cells = <0>;
>>>> + assigned-clocks = <&wiz0_refclk_dig>;
>>>> + assigned-clock-parents = <&k3_clks 292 11>;
>>>> + };
>>>
>>> How are all these clocks programmed?
>>
>> All these are programmed in the WIZ driver which is implemented in 14/14 of
>> this series.
>
> Not what I meant... How does one access the h/w because there's
> nothing defined here to do so.
As mentioned above the WIZ wrapper driver gets the address from "serdes" child
node and use it for programming all these clocks.
Thanks
Kishon
Hi Kishon/Rob
My comments are below.
> -----Original Message-----
> From: Kishon Vijay Abraham I <[email protected]>
> Sent: Wednesday, October 30, 2019 11:06 AM
> To: Rob Herring <[email protected]>; Anil Joy Varughese
> <[email protected]>
> Cc: Roger Quadros <[email protected]>; Jyri Sarha <[email protected]>; linux-
> [email protected]; [email protected]
> Subject: Re: [PATCH v2 01/14] dt-bindings: phy: Sierra: Add bindings for Sierra
> in TI's J721E
>
> EXTERNAL MAIL
>
>
> Hi Rob,
>
> On 30/10/19 12:29 AM, Rob Herring wrote:
> > On Wed, Oct 23, 2019 at 06:27:22PM +0530, Kishon Vijay Abraham I wrote:
> >> Add DT binding documentation for Sierra PHY IP used in TI's J721E
> >> SoC.
> >>
> >> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
> >> ---
> >> .../devicetree/bindings/phy/phy-cadence-sierra.txt | 13
> >> ++++++++-----
> >> 1 file changed, 8 insertions(+), 5 deletions(-)
> >>
> >> diff --git
> >> a/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> >> b/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> >> index 6e1b47bfce43..bf90ef7e005e 100644
> >> --- a/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> >> +++ b/Documentation/devicetree/bindings/phy/phy-cadence-sierra.txt
> >> @@ -2,21 +2,24 @@ Cadence Sierra PHY
> >> -----------------------
> >>
> >> Required properties:
> >> -- compatible: cdns,sierra-phy-t0
> >> -- clocks: Must contain an entry in clock-names.
> >> - See ../clocks/clock-bindings.txt for details.
> >> -- clock-names: Must be "phy_clk"
> >> +- compatible: Must be "cdns,sierra-phy-t0" for Sierra in Cadence
> platform
> >> + Must be "ti,sierra-phy-t0" for Sierra in TI's J721E SoC.
> >> - resets: Must contain an entry for each in reset-names.
> >> See ../reset/reset.txt for details.
> >> - reset-names: Must include "sierra_reset" and "sierra_apb".
> >> "sierra_reset" must control the reset line to the PHY.
> >> "sierra_apb" must control the reset line to the APB PHY
> >> - interface.
> >> + interface ("sierra_apb" is optional).
> >> - reg: register range for the PHY.
> >> - #address-cells: Must be 1
> >> - #size-cells: Must be 0
> >>
> >> Optional properties:
> >> +- clocks: Must contain an entry in clock-names.
> >> + See ../clocks/clock-bindings.txt for details.
> >> +- clock-names: Must be "phy_clk". Must contain "cmn_refclk"
> and
> >> + "cmn_refclk1" for configuring the frequency of the
> >> + clock to the lanes.
> >
> > I don't understand how the same block can have completely different
> > clocks. Did the original binding forget some?
> >
> > TI needs 0, 1 or 3 clocks? Reads like it could be any.
>
> For TI, phy_clk is not needed. Anil, can you clarify what this clock actually
> corresponds to? Is it a functional clock of PHY?
When we had designed the DT binding for Sierra we thought of using phy_clk as a common interface for the clock inputs and there was no specific requirement for splitting it into multiple clocks then and also we had used a simulation environment for testing our IP. We can deprecate the phy_clk property.
Thanks,
Anil
> Sierra SERDES actually has a number of clocks which can be configured. The
> initial dt-binding didn't model all these clocks. The "cmn_refclk" and
> "cmn_refclk1" are used to program the dividers withing the Sierra. The actual
> registers for programming the dividers are in the Sierra wrapper though. The
> original Sierra driver and dt-binding didn't try to change the default divider
> values.
>
> Thanks
> Kishon
> >
> > Rob
> >