Kinetis Support RMII clock source select

This defined the RMII clock source select bits and allows
  the selection to be made via Kconfig
This commit is contained in:
David Sidrane 2017-02-15 11:01:45 -10:00
parent be7a904d1b
commit a95a6c43d3
3 changed files with 58 additions and 6 deletions

View File

@ -713,6 +713,21 @@ config KINETIS_ENET_NORXER
If selected, then the MII/RMII RXER output will be configured as a
GPIO and pulled low.
choice
prompt "RMII Clock Source"
default KINETIS_EMAC_RMIICLKEXTAL
depends on !KINETIS_ENETUSEMII && (ARCH_FAMILY_K64 || ARCH_FAMILY_K66)
---help---
The RMII clock can be selected between EXTAL or ENET_1588_CLKIN
config KINETIS_EMAC_RMIICLKEXTAL
bool "Use EXTAL for RMII Clock"
config KINETIS_EMAC_RMIICLK1588CLKIN
bool "Use ENET_1588_CLKIN for RMII Clock"
endchoice # RMII Clock Source
choice
prompt "Work queue"
default KINETIS_EMAC_LPWORK if SCHED_LPWORK

View File

@ -1,8 +1,9 @@
/************************************************************************************
* arch/arm/src/kinetis/chip/kinetis_sim.h
*
* Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Copyright (C) 2011, 2016, 2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* David Sidrane <david_s5@nscdg.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -136,8 +137,17 @@
/* Bit 17: Reserved */
#define SIM_SOPT2_USBSRC (1 << 18) /* Bit 18: USB clock source select */
/* Bit 19: Reserved */
#ifdef KINETIS_K60
# define SIM_SOPT2_TIMESRC (1 << 20) /* Bit 20: IEEE 1588 timestamp clock source select (K60) */
#if defined(KINETIS_K60) || defined(KINETIS_K64) || defined(KINETIS_K66)
# define SIM_SOPT2_RMIISRC_SHIFT (19) /* Bit 19: RMII clock source select */
# define SIM_SOPT2_RMIISRC_EXTAL (0 << SIM_SOPT2_RMIISRC_SHIFT) /* EXTAL clock */
# define SIM_SOPT2_RMIISRC_EXTBYP (1 << SIM_SOPT2_RMIISRC_SHIFT) /* External bypass clock (ENET_1588_CLKIN) */
# define SIM_SOPT2_TIMESRC_SHIFT (20) /* Bit 20-21: IEEE 1588 timestamp clock source select (K60) */
# define SIM_SOPT2_TIMESRC_MASK (3 << SIM_SOPT2_TIMESRC_SHIFT)
# define SIM_SOPT2_TIMESRC_CORE (0 << SIM_SOPT2_TIMESRC_SHIFT) /* Core/system clock */
# define SIM_SOPT2_TIMESRC_PLLSEL (1 << SIM_SOPT2_TIMESRC_SHIFT) /* MCGFLLCLK,MCGPLLCLK,IRC48M,USB1 PFD
clock as selected by SOPT2[PLLFLLSEL] */
# define SIM_SOPT2_TIMESRC_OSCERCLK (2 << SIM_SOPT2_TIMESRC_SHIFT) /* OSCERCLK clock */
# define SIM_SOPT2_TIMESRC_EXTBYP (0 << SIM_SOPT2_TIMESRC_SHIFT) /* External bypass clock (ENET_1588_CLKIN) */
#endif
/* Bits 12-23: Reserved */
#define SIM_SOPT2_I2SSRC_SHIFT (24) /* Bits 24-25: I2S master clock source select */

View File

@ -1,8 +1,9 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_enet.c
*
* Copyright (C) 2011-2012, 2014-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Copyright (C) 2011-2012, 2014-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* David Sidrane <david_s5@nscdg.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -200,6 +201,17 @@
#define KINETIS_BUF_SIZE ((CONFIG_NET_ETH_MTU & 0xfffffff0) + 0x10)
/* If this SoC has the RMII Clock Source selection configure it */
#if defined(CONFIG_KINETIS_EMAC_RMIICLKEXTAL)
# define SIM_SOPT2_RMIISRC SIM_SOPT2_RMIISRC_EXTAL
#endif
#if defined(CONFIG_KINETIS_EMAC_RMIICLK1588CLKIN)
# define SIM_SOPT2_RMIISRC SIM_SOPT2_RMIISRC_EXTBYP
#endif
/****************************************************************************
* Private Types
****************************************************************************/
@ -1989,6 +2001,21 @@ int kinetis_netinitialize(int intf)
DEBUGASSERT(intf < CONFIG_KINETIS_ENETNETHIFS);
priv = &g_enet[intf];
#if defined(SIM_SOPT2_RMIISRC)
/* If this Soc has RMII clock select then select the RMII clock source.
* First if the source is ENET_1588_CLKIN - configure the pin to apply the
* clock to the block. Then select it as the source.
*/
# if SIM_SOPT2_RMIISRC == SIM_SOPT2_RMIISRC_EXTBYP
kinetis_pinconfig(PIN_ENET_1588_CLKIN);
# endif
regval = getreg32(KINETIS_SIM_SOPT2);
regval |= SIM_SOPT2_RMIISRC;
putreg32(regval, KINETIS_SIM_SOPT2);
#endif
/* Enable the ENET clock */
regval = getreg32(KINETIS_SIM_SCGC2);