Skip to content

Commit b6a47d9

Browse files
committed
ethdrivers,imx6: Add NIC_CONFIG_NO_CLOCK_SYS flag
Add NIC_CONFIG_NO_CLOCK_SYS flag which prevents the ethernet driver from trying to initialize a clock_sys driver (which requires CCM hardware resources) during initialization. This flag should be used when the clocks are setup independently from the driver. Signed-off-by: Kent McLeod <kent@kry10.com>
1 parent 535cc12 commit b6a47d9

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

libethdrivers/plat_include/imx6/ethdrivers/plat/eth_plat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#include <ethdrivers/imx6.h>
1111
#include <utils/attribute.h>
1212
#include <ethdrivers/raw.h>
13-
#include "../src/plat/imx6/enet.h"
1413

1514
struct enet *get_enet_from_driver(struct eth_driver *driver);
1615

1716
enum {
1817
NIC_CONFIG_FORCE_MAC = 1u << 0, /**< Use MAC from config (if not 0) */
1918
NIC_CONFIG_PROMISCUOUS_MODE = 1u << 1, /**< Enable promiscuous mode */
2019
NIC_CONFIG_DROP_FRAME_CRC = 1u << 2, /**< Drop ethernet frame CRC */
20+
NIC_CONFIG_NO_CLOCK_SYS = 1u << 3, /**< Don't use clock_sys interface */
2121
} nic_config_flags_t;
2222

2323
typedef int (*sync_func_t)(void);

libethdrivers/src/plat/imx6/enet.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ void enet_crc_strip_disable(struct enet *enet)
529529
regs->rcr &= ~RCR_CRCSTRIP;
530530
}
531531

532-
struct enet *enet_init(void *mapped_peripheral, uintptr_t tx_phys,
532+
struct enet *enet_init(const nic_config_t *nic_config, void *mapped_peripheral, uintptr_t tx_phys,
533533
uintptr_t rx_phys, size_t rx_bufsize, uint64_t mac,
534534
ps_io_ops_t *io_ops)
535535
{
@@ -552,11 +552,13 @@ struct enet *enet_init(void *mapped_peripheral, uintptr_t tx_phys,
552552

553553
#if defined(CONFIG_PLAT_IMX6)
554554

555-
/* Set the ethernet clock frequency */
556-
clock_sys_t *clk_sys = malloc(sizeof(clock_sys_t));
557-
clock_sys_init(io_ops, clk_sys);
558-
enet_clk_ptr = clk_get_clock(clk_sys, CLK_ENET);
559-
clk_set_freq(enet_clk_ptr, ENET_FREQ);
555+
if (!(nic_config && (nic_config->flags & NIC_CONFIG_NO_CLOCK_SYS))) {
556+
/* Set the ethernet clock frequency */
557+
clock_sys_t *clk_sys = malloc(sizeof(clock_sys_t));
558+
clock_sys_init(io_ops, clk_sys);
559+
enet_clk_ptr = clk_get_clock(clk_sys, CLK_ENET);
560+
clk_set_freq(enet_clk_ptr, ENET_FREQ);
561+
}
560562

561563
#elif defined(CONFIG_PLAT_IMX8MQ_EVK)
562564

@@ -592,10 +594,12 @@ struct enet *enet_init(void *mapped_peripheral, uintptr_t tx_phys,
592594

593595
#endif
594596

595-
/* Set the MDIO clock frequency */
596-
mdc_clk.priv = (void *)regs;
597-
clk_register_child(enet_clk_ptr, &mdc_clk);
598-
clk_set_freq(&mdc_clk, MDC_FREQ);
597+
if (!(nic_config && (nic_config->flags & NIC_CONFIG_NO_CLOCK_SYS))) {
598+
/* Set the MDIO clock frequency */
599+
mdc_clk.priv = (void *)regs;
600+
clk_register_child(enet_clk_ptr, &mdc_clk);
601+
clk_set_freq(&mdc_clk, MDC_FREQ);
602+
}
599603

600604
/* Clear out MIB */
601605
enet_clear_mib(enet);

libethdrivers/src/plat/imx6/enet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <stdint.h>
1111
#include <platsupport/io.h>
12+
#include <ethdrivers/plat/eth_plat.h>
1213

1314
#define NETIRQ_BABR (1UL << 30) /* Babbling Receive Error */
1415
#define NETIRQ_BABT (1UL << 29) /* Babbling Transmit Error */
@@ -30,6 +31,7 @@
3031
struct enet;
3132

3233
struct enet *enet_init(
34+
const nic_config_t *nic_config,
3335
void *mapped_peripheral,
3436
uintptr_t tx_phys,
3537
uintptr_t rx_phys,

libethdrivers/src/plat/imx6/imx6.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ static int init_device(struct eth_driver *driver, const nic_config_t *nic_config
705705

706706
/* Initialise the RGMII interface, clears and masks all interrupts */
707707
dev->enet = enet_init(
708+
nic_config,
708709
mapped_peripheral,
709710
dev->tx.phys,
710711
dev->rx.phys,

0 commit comments

Comments
 (0)