Lines Matching +full:power +full:- +full:role
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2016-2018 NXP
3 * Copyright (c) 2018-2019, Vladimir Oltean <olteanv@gmail.com>
107 sja1105_packing(buf, &idiv->clksrc, 28, 24, size, op); in sja1105_cgu_idiv_packing()
108 sja1105_packing(buf, &idiv->autoblock, 11, 11, size, op); in sja1105_cgu_idiv_packing()
109 sja1105_packing(buf, &idiv->idiv, 5, 2, size, op); in sja1105_cgu_idiv_packing()
110 sja1105_packing(buf, &idiv->pd, 0, 0, size, op); in sja1105_cgu_idiv_packing()
116 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_idiv_config()
117 struct device *dev = priv->ds->dev; in sja1105_cgu_idiv_config()
121 if (regs->cgu_idiv[port] == SJA1105_RSV_ADDR) in sja1105_cgu_idiv_config()
126 return -ERANGE; in sja1105_cgu_idiv_config()
132 idiv.idiv = factor - 1; /* Divide by 1 or 10 */ in sja1105_cgu_idiv_config()
133 idiv.pd = enabled ? 0 : 1; /* Power down? */ in sja1105_cgu_idiv_config()
136 return sja1105_xfer_buf(priv, SPI_WRITE, regs->cgu_idiv[port], in sja1105_cgu_idiv_config()
146 sja1105_packing(buf, &cmd->clksrc, 28, 24, size, op); in sja1105_cgu_mii_control_packing()
147 sja1105_packing(buf, &cmd->autoblock, 11, 11, size, op); in sja1105_cgu_mii_control_packing()
148 sja1105_packing(buf, &cmd->pd, 0, 0, size, op); in sja1105_cgu_mii_control_packing()
152 int port, sja1105_mii_role_t role) in sja1105_cgu_mii_tx_clk_config() argument
154 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_mii_tx_clk_config()
173 if (regs->mii_tx_clk[port] == SJA1105_RSV_ADDR) in sja1105_cgu_mii_tx_clk_config()
176 if (role == XMII_MAC) in sja1105_cgu_mii_tx_clk_config()
184 mii_tx_clk.pd = 0; /* Power Down off => enabled */ in sja1105_cgu_mii_tx_clk_config()
187 return sja1105_xfer_buf(priv, SPI_WRITE, regs->mii_tx_clk[port], in sja1105_cgu_mii_tx_clk_config()
194 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_mii_rx_clk_config()
205 if (regs->mii_rx_clk[port] == SJA1105_RSV_ADDR) in sja1105_cgu_mii_rx_clk_config()
211 mii_rx_clk.pd = 0; /* Power Down off => enabled */ in sja1105_cgu_mii_rx_clk_config()
214 return sja1105_xfer_buf(priv, SPI_WRITE, regs->mii_rx_clk[port], in sja1105_cgu_mii_rx_clk_config()
221 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_mii_ext_tx_clk_config()
232 if (regs->mii_ext_tx_clk[port] == SJA1105_RSV_ADDR) in sja1105_cgu_mii_ext_tx_clk_config()
238 mii_ext_tx_clk.pd = 0; /* Power Down off => enabled */ in sja1105_cgu_mii_ext_tx_clk_config()
241 return sja1105_xfer_buf(priv, SPI_WRITE, regs->mii_ext_tx_clk[port], in sja1105_cgu_mii_ext_tx_clk_config()
248 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_mii_ext_rx_clk_config()
259 if (regs->mii_ext_rx_clk[port] == SJA1105_RSV_ADDR) in sja1105_cgu_mii_ext_rx_clk_config()
265 mii_ext_rx_clk.pd = 0; /* Power Down off => enabled */ in sja1105_cgu_mii_ext_rx_clk_config()
268 return sja1105_xfer_buf(priv, SPI_WRITE, regs->mii_ext_rx_clk[port], in sja1105_cgu_mii_ext_rx_clk_config()
273 sja1105_mii_role_t role) in sja1105_mii_clocking_setup() argument
275 struct device *dev = priv->ds->dev; in sja1105_mii_clocking_setup()
278 dev_dbg(dev, "Configuring MII-%s clocking\n", in sja1105_mii_clocking_setup()
279 (role == XMII_MAC) ? "MAC" : "PHY"); in sja1105_mii_clocking_setup()
280 /* If role is MAC, disable IDIV in sja1105_mii_clocking_setup()
281 * If role is PHY, enable IDIV and configure for 1/1 divider in sja1105_mii_clocking_setup()
283 rc = sja1105_cgu_idiv_config(priv, port, (role == XMII_PHY), 1); in sja1105_mii_clocking_setup()
288 * * If role is MAC, select TX_CLK_n in sja1105_mii_clocking_setup()
289 * * If role is PHY, select IDIV_n in sja1105_mii_clocking_setup()
291 rc = sja1105_cgu_mii_tx_clk_config(priv, port, role); in sja1105_mii_clocking_setup()
302 if (role == XMII_PHY) { in sja1105_mii_clocking_setup()
328 sja1105_packing(buf, &cmd->pllclksrc, 28, 24, size, op); in sja1105_cgu_pll_control_packing()
329 sja1105_packing(buf, &cmd->msel, 23, 16, size, op); in sja1105_cgu_pll_control_packing()
330 sja1105_packing(buf, &cmd->autoblock, 11, 11, size, op); in sja1105_cgu_pll_control_packing()
331 sja1105_packing(buf, &cmd->psel, 9, 8, size, op); in sja1105_cgu_pll_control_packing()
332 sja1105_packing(buf, &cmd->direct, 7, 7, size, op); in sja1105_cgu_pll_control_packing()
333 sja1105_packing(buf, &cmd->fbsel, 6, 6, size, op); in sja1105_cgu_pll_control_packing()
334 sja1105_packing(buf, &cmd->bypass, 1, 1, size, op); in sja1105_cgu_pll_control_packing()
335 sja1105_packing(buf, &cmd->pd, 0, 0, size, op); in sja1105_cgu_pll_control_packing()
341 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_rgmii_tx_clk_config()
346 if (regs->rgmii_tx_clk[port] == SJA1105_RSV_ADDR) in sja1105_cgu_rgmii_tx_clk_config()
349 if (speed == priv->info->port_speed[SJA1105_SPEED_1000MBPS]) { in sja1105_cgu_rgmii_tx_clk_config()
361 /* Power Down off => enabled */ in sja1105_cgu_rgmii_tx_clk_config()
365 return sja1105_xfer_buf(priv, SPI_WRITE, regs->rgmii_tx_clk[port], in sja1105_cgu_rgmii_tx_clk_config()
376 sja1105_packing(buf, &cmd->d32_os, 28, 27, size, op); in sja1105_cfg_pad_mii_packing()
377 sja1105_packing(buf, &cmd->d32_ih, 26, 26, size, op); in sja1105_cfg_pad_mii_packing()
378 sja1105_packing(buf, &cmd->d32_ipud, 25, 24, size, op); in sja1105_cfg_pad_mii_packing()
379 sja1105_packing(buf, &cmd->d10_os, 20, 19, size, op); in sja1105_cfg_pad_mii_packing()
380 sja1105_packing(buf, &cmd->d10_ih, 18, 18, size, op); in sja1105_cfg_pad_mii_packing()
381 sja1105_packing(buf, &cmd->d10_ipud, 17, 16, size, op); in sja1105_cfg_pad_mii_packing()
382 sja1105_packing(buf, &cmd->ctrl_os, 12, 11, size, op); in sja1105_cfg_pad_mii_packing()
383 sja1105_packing(buf, &cmd->ctrl_ih, 10, 10, size, op); in sja1105_cfg_pad_mii_packing()
384 sja1105_packing(buf, &cmd->ctrl_ipud, 9, 8, size, op); in sja1105_cfg_pad_mii_packing()
385 sja1105_packing(buf, &cmd->clk_os, 4, 3, size, op); in sja1105_cfg_pad_mii_packing()
386 sja1105_packing(buf, &cmd->clk_ih, 2, 2, size, op); in sja1105_cfg_pad_mii_packing()
387 sja1105_packing(buf, &cmd->clk_ipud, 1, 0, size, op); in sja1105_cfg_pad_mii_packing()
393 const struct sja1105_regs *regs = priv->info->regs; in sja1105_rgmii_cfg_pad_tx_config()
397 if (regs->pad_mii_tx[port] == SJA1105_RSV_ADDR) in sja1105_rgmii_cfg_pad_tx_config()
416 return sja1105_xfer_buf(priv, SPI_WRITE, regs->pad_mii_tx[port], in sja1105_rgmii_cfg_pad_tx_config()
422 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cfg_pad_rx_config()
426 if (regs->pad_mii_rx[port] == SJA1105_RSV_ADDR) in sja1105_cfg_pad_rx_config()
431 /* non-Schmitt (default) */ in sja1105_cfg_pad_rx_config()
432 pad_mii_rx.d32_ipud = 2; /* RXD[3:2] input weak pull-up/down */ in sja1105_cfg_pad_rx_config()
435 /* non-Schmitt (default) */ in sja1105_cfg_pad_rx_config()
436 pad_mii_rx.d10_ipud = 2; /* RXD[1:0] input weak pull-up/down */ in sja1105_cfg_pad_rx_config()
440 /* non-Schmitt (default) */ in sja1105_cfg_pad_rx_config()
442 /* input stage weak pull-up/down: */ in sja1105_cfg_pad_rx_config()
443 /* pull-down */ in sja1105_cfg_pad_rx_config()
447 /* non-Schmitt (default) */ in sja1105_cfg_pad_rx_config()
448 pad_mii_rx.clk_ipud = 2; /* RX_CLK/RXC input pull-up/down: */ in sja1105_cfg_pad_rx_config()
452 return sja1105_xfer_buf(priv, SPI_WRITE, regs->pad_mii_rx[port], in sja1105_cfg_pad_rx_config()
462 sja1105_packing(buf, &cmd->rxc_stable_ovr, 15, 15, size, op); in sja1105_cfg_pad_mii_id_packing()
463 sja1105_packing(buf, &cmd->rxc_delay, 14, 10, size, op); in sja1105_cfg_pad_mii_id_packing()
464 sja1105_packing(buf, &cmd->rxc_bypass, 9, 9, size, op); in sja1105_cfg_pad_mii_id_packing()
465 sja1105_packing(buf, &cmd->rxc_pd, 8, 8, size, op); in sja1105_cfg_pad_mii_id_packing()
466 sja1105_packing(buf, &cmd->txc_stable_ovr, 7, 7, size, op); in sja1105_cfg_pad_mii_id_packing()
467 sja1105_packing(buf, &cmd->txc_delay, 6, 2, size, op); in sja1105_cfg_pad_mii_id_packing()
468 sja1105_packing(buf, &cmd->txc_bypass, 1, 1, size, op); in sja1105_cfg_pad_mii_id_packing()
469 sja1105_packing(buf, &cmd->txc_pd, 0, 0, size, op); in sja1105_cfg_pad_mii_id_packing()
489 sja1105_packing(buf, &cmd->rxc_stable_ovr, 26, 26, size, op); in sja1110_cfg_pad_mii_id_packing()
490 sja1105_packing(buf, &cmd->rxc_delay, 25, 21, size, op); in sja1110_cfg_pad_mii_id_packing()
492 sja1105_packing(buf, &cmd->rxc_bypass, 17, 17, size, op); in sja1110_cfg_pad_mii_id_packing()
493 sja1105_packing(buf, &cmd->rxc_pd, 16, 16, size, op); in sja1110_cfg_pad_mii_id_packing()
494 sja1105_packing(buf, &cmd->txc_stable_ovr, 10, 10, size, op); in sja1110_cfg_pad_mii_id_packing()
495 sja1105_packing(buf, &cmd->txc_delay, 9, 5, size, op); in sja1110_cfg_pad_mii_id_packing()
497 sja1105_packing(buf, &cmd->txc_bypass, 1, 1, size, op); in sja1110_cfg_pad_mii_id_packing()
498 sja1105_packing(buf, &cmd->txc_pd, 0, 0, size, op); in sja1110_cfg_pad_mii_id_packing()
501 /* The RGMII delay setup procedure is 2-step and gets called upon each
505 * The easiest way to recover from this is to temporarily power down the TDL,
506 * as it will re-lock at the new frequency afterwards.
511 const struct sja1105_regs *regs = priv->info->regs; in sja1105pqrs_setup_rgmii_delay()
513 int rx_delay = priv->rgmii_rx_delay_ps[port]; in sja1105pqrs_setup_rgmii_delay()
514 int tx_delay = priv->rgmii_tx_delay_ps[port]; in sja1105pqrs_setup_rgmii_delay()
530 rc = sja1105_xfer_buf(priv, SPI_WRITE, regs->pad_mii_id[port], in sja1105pqrs_setup_rgmii_delay()
546 return sja1105_xfer_buf(priv, SPI_WRITE, regs->pad_mii_id[port], in sja1105pqrs_setup_rgmii_delay()
553 const struct sja1105_regs *regs = priv->info->regs; in sja1110_setup_rgmii_delay()
555 int rx_delay = priv->rgmii_rx_delay_ps[port]; in sja1110_setup_rgmii_delay()
556 int tx_delay = priv->rgmii_tx_delay_ps[port]; in sja1110_setup_rgmii_delay()
577 return sja1105_xfer_buf(priv, SPI_WRITE, regs->pad_mii_id[port], in sja1110_setup_rgmii_delay()
582 sja1105_mii_role_t role) in sja1105_rgmii_clocking_setup() argument
584 struct device *dev = priv->ds->dev; in sja1105_rgmii_clocking_setup()
589 mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; in sja1105_rgmii_clocking_setup()
595 if (speed == priv->info->port_speed[SJA1105_SPEED_1000MBPS]) { in sja1105_rgmii_clocking_setup()
598 } else if (speed == priv->info->port_speed[SJA1105_SPEED_100MBPS]) { in sja1105_rgmii_clocking_setup()
601 } else if (speed == priv->info->port_speed[SJA1105_SPEED_10MBPS]) { in sja1105_rgmii_clocking_setup()
604 } else if (speed == priv->info->port_speed[SJA1105_SPEED_AUTO]) { in sja1105_rgmii_clocking_setup()
611 rc = -EINVAL; in sja1105_rgmii_clocking_setup()
629 if (!priv->info->setup_rgmii_delay) in sja1105_rgmii_clocking_setup()
632 return priv->info->setup_rgmii_delay(priv, port); in sja1105_rgmii_clocking_setup()
638 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_rmii_ref_clk_config()
649 if (regs->rmii_ref_clk[port] == SJA1105_RSV_ADDR) in sja1105_cgu_rmii_ref_clk_config()
655 ref_clk.pd = 0; /* Power Down off => enabled */ in sja1105_cgu_rmii_ref_clk_config()
658 return sja1105_xfer_buf(priv, SPI_WRITE, regs->rmii_ref_clk[port], in sja1105_cgu_rmii_ref_clk_config()
665 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_rmii_ext_tx_clk_config()
669 if (regs->rmii_ext_tx_clk[port] == SJA1105_RSV_ADDR) in sja1105_cgu_rmii_ext_tx_clk_config()
675 ext_tx_clk.pd = 0; /* Power Down off => enabled */ in sja1105_cgu_rmii_ext_tx_clk_config()
678 return sja1105_xfer_buf(priv, SPI_WRITE, regs->rmii_ext_tx_clk[port], in sja1105_cgu_rmii_ext_tx_clk_config()
684 const struct sja1105_regs *regs = priv->info->regs; in sja1105_cgu_rmii_pll_config()
687 struct device *dev = priv->ds->dev; in sja1105_cgu_rmii_pll_config()
690 if (regs->rmii_pll1 == SJA1105_RSV_ADDR) in sja1105_cgu_rmii_pll_config()
696 * power down (PD) 0x0A010940. in sja1105_cgu_rmii_pll_config()
710 rc = sja1105_xfer_buf(priv, SPI_WRITE, regs->rmii_pll1, packed_buf, in sja1105_cgu_rmii_pll_config()
721 rc = sja1105_xfer_buf(priv, SPI_WRITE, regs->rmii_pll1, packed_buf, in sja1105_cgu_rmii_pll_config()
731 sja1105_mii_role_t role) in sja1105_rmii_clocking_setup() argument
733 struct device *dev = priv->ds->dev; in sja1105_rmii_clocking_setup()
736 dev_dbg(dev, "Configuring RMII-%s clocking\n", in sja1105_rmii_clocking_setup()
737 (role == XMII_MAC) ? "MAC" : "PHY"); in sja1105_rmii_clocking_setup()
739 if (role == XMII_MAC) { in sja1105_rmii_clocking_setup()
753 if (role == XMII_MAC) { in sja1105_rmii_clocking_setup()
764 struct device *dev = priv->ds->dev; in sja1105_clocking_setup_port()
766 sja1105_mii_role_t role; in sja1105_clocking_setup_port() local
769 mii = priv->static_config.tables[BLK_IDX_XMII_PARAMS].entries; in sja1105_clocking_setup_port()
772 phy_mode = mii->xmii_mode[port]; in sja1105_clocking_setup_port()
774 role = mii->phy_mac[port]; in sja1105_clocking_setup_port()
778 rc = sja1105_mii_clocking_setup(priv, port, role); in sja1105_clocking_setup_port()
781 rc = sja1105_rmii_clocking_setup(priv, port, role); in sja1105_clocking_setup_port()
784 rc = sja1105_rgmii_clocking_setup(priv, port, role); in sja1105_clocking_setup_port()
793 return -EINVAL; in sja1105_clocking_setup_port()
807 struct dsa_switch *ds = priv->ds; in sja1105_clocking_setup()
810 for (port = 0; port < ds->num_ports; port++) { in sja1105_clocking_setup()
824 sja1105_packing(buf, &outclk->clksrc, 27, 24, size, op); in sja1110_cgu_outclk_packing()
825 sja1105_packing(buf, &outclk->autoblock, 11, 11, size, op); in sja1110_cgu_outclk_packing()
826 sja1105_packing(buf, &outclk->pd, 0, 0, size, op); in sja1110_cgu_outclk_packing()
842 /* Power down the BASE_TIMER_CLK to disable the watchdog timer */ in sja1110_disable_microcontroller()
850 /* Power down the BASE_MCSS_CLOCK to gate the microcontroller off */ in sja1110_disable_microcontroller()