public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Patrice CHOTARD <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/6] board: stm32mp1: Add board_interface_eth_init
Date: Tue, 11 Jun 2019 07:34:55 +0000	[thread overview]
Message-ID: <044d9cdf-718a-ebfc-5ec4-2f609dfeda2f@st.com> (raw)
In-Reply-To: <20190517130847.13144-3-christophe.roullier@st.com>



On 5/17/19 3:08 PM, Christophe Roullier wrote:
> Called to configure Ethernet PHY interface selection and
> configure clock selection in RCC Ethernet clock tree.
> 
> Signed-off-by: Christophe Roullier <christophe.roullier@st.com>
> ---
> 
> Changes in v2: None
> 
>  board/st/stm32mp1/stm32mp1.c | 68 ++++++++++++++++++++++++++++++++++--
>  1 file changed, 65 insertions(+), 3 deletions(-)
> 
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 76917b022ed..e120fc57223 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -51,9 +51,9 @@
>  #define SYSCFG_PMCSETR_ETH_SELMII	BIT(20)
>  
>  #define SYSCFG_PMCSETR_ETH_SEL_MASK	GENMASK(23, 21)
> -#define SYSCFG_PMCSETR_ETH_SEL_GMII_MII	(0 << 21)
> -#define SYSCFG_PMCSETR_ETH_SEL_RGMII	(1 << 21)
> -#define SYSCFG_PMCSETR_ETH_SEL_RMII	(4 << 21)
> +#define SYSCFG_PMCSETR_ETH_SEL_GMII_MII	0
> +#define SYSCFG_PMCSETR_ETH_SEL_RGMII	BIT(21)
> +#define SYSCFG_PMCSETR_ETH_SEL_RMII	BIT(23)
>  
>  /*
>   * Get a global data pointer
> @@ -504,3 +504,65 @@ void board_quiesce_devices(void)
>  {
>  	setup_led(LEDST_OFF);
>  }
> +
> +/* board interface eth init */
> +/* this is a weak define that we are overriding */
> +int board_interface_eth_init(phy_interface_t interface_type,
> +			     bool eth_clk_sel_reg, bool eth_ref_clk_sel_reg)
> +{
> +	u8 *syscfg;
> +	u32 value;
> +
> +	syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
> +
> +	if (!syscfg)
> +		return -ENODEV;
> +
> +	switch (interface_type) {
> +	case PHY_INTERFACE_MODE_MII:
> +		value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
> +			SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
> +		debug("%s: PHY_INTERFACE_MODE_MII\n", __func__);
> +		break;
> +	case PHY_INTERFACE_MODE_GMII:
> +		if (eth_clk_sel_reg)
> +			value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
> +				SYSCFG_PMCSETR_ETH_CLK_SEL;
> +		else
> +			value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII;
> +		debug("%s: PHY_INTERFACE_MODE_GMII\n", __func__);
> +		break;
> +	case PHY_INTERFACE_MODE_RMII:
> +		if (eth_ref_clk_sel_reg)
> +			value = SYSCFG_PMCSETR_ETH_SEL_RMII |
> +				SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
> +		else
> +			value = SYSCFG_PMCSETR_ETH_SEL_RMII;
> +		debug("%s: PHY_INTERFACE_MODE_RMII\n", __func__);
> +		break;
> +	case PHY_INTERFACE_MODE_RGMII:
> +	case PHY_INTERFACE_MODE_RGMII_ID:
> +	case PHY_INTERFACE_MODE_RGMII_RXID:
> +	case PHY_INTERFACE_MODE_RGMII_TXID:
> +		if (eth_clk_sel_reg)
> +			value = SYSCFG_PMCSETR_ETH_SEL_RGMII |
> +				SYSCFG_PMCSETR_ETH_CLK_SEL;
> +		else
> +			value = SYSCFG_PMCSETR_ETH_SEL_RGMII;
> +		debug("%s: PHY_INTERFACE_MODE_RGMII\n", __func__);
> +		break;
> +	default:
> +		debug("%s: Do not manage %d interface\n",
> +		      __func__, interface_type);
> +		/* Do not manage others interfaces */
> +		return -EINVAL;
> +	}
> +
> +	/* clear and set ETH configuration bits */
> +	writel(SYSCFG_PMCSETR_ETH_SEL_MASK | SYSCFG_PMCSETR_ETH_SELMII |
> +	       SYSCFG_PMCSETR_ETH_REF_CLK_SEL | SYSCFG_PMCSETR_ETH_CLK_SEL,
> +	       syscfg + SYSCFG_PMCCLRR);
> +	writel(value, syscfg + SYSCFG_PMCSETR);
> +
> +	return 0;
> +}
> 


Applied

Thanks

  reply	other threads:[~2019-06-11  7:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 13:08 [U-Boot] [PATCH v2 0/6] - Add Ethernet support for stm32mpu Christophe Roullier
2019-05-17 13:08 ` [U-Boot] [PATCH v2 1/6] stm32mp1: clk: use the correct identifier for ethck Christophe Roullier
2019-06-11  7:34   ` Patrice CHOTARD
2019-05-17 13:08 ` [U-Boot] [PATCH v2 2/6] board: stm32mp1: Add board_interface_eth_init Christophe Roullier
2019-06-11  7:34   ` Patrice CHOTARD [this message]
2019-05-17 13:08 ` [U-Boot] [PATCH v2 3/6] net: dwc_eth_qos: add Ethernet stm32mp1 support Christophe Roullier
2019-06-01 10:58   ` Joe Hershberger
2019-06-11  7:35   ` Patrice CHOTARD
2019-05-17 13:08 ` [U-Boot] [PATCH v2 4/6] ARM: dts: stm32: Add Ethernet support on stm32mp1 Christophe Roullier
2019-06-11  7:35   ` Patrice CHOTARD
2019-05-17 13:08 ` [U-Boot] [PATCH v2 5/6] stm32mp1: Add Ethernet support for stm32mp1 board Christophe Roullier
2019-06-11  7:35   ` Patrice CHOTARD
2019-05-17 13:08 ` [U-Boot] [PATCH v2 6/6] configs: stm32mp15: Enable Ethernet feature Christophe Roullier
2019-06-01 10:53   ` Joe Hershberger
2019-06-11  7:35   ` Patrice CHOTARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=044d9cdf-718a-ebfc-5ec4-2f609dfeda2f@st.com \
    --to=patrice.chotard@st.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox