/*
 *  Copyright (C) 2024 Texas Instruments Incorporated
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *    Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 *    Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the
 *    distribution.
 *
 *    Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef ETHPHY_DP83822_H_
#define ETHPHY_DP83822_H_

/* ========================================================================== */
/*                             Include Files                                  */
/* ========================================================================== */

#include <board/ethphy.h>

#ifdef __cplusplus
extern "C" {
#endif

/* ========================================================================== */
/*                           Macros & Typedefs                                */
/* ========================================================================== */

/**
 *  \anchor ETHPHY_DP83822_LED_BLINK_RATES
 *  \name ETHPHY DP83822 LED BLINK RATES
 *
 *  Blink rate encoding for LEDCR[10:9] in the DP83822 LED Control Register.
 *
 *  @{
 */
#define ETHPHY_DP83822_LED_BLINK_RATE_50_MS                     (0x0U)
#define ETHPHY_DP83822_LED_BLINK_RATE_100_MS                    (0x1U)
#define ETHPHY_DP83822_LED_BLINK_RATE_200_MS                    (0x2U)
#define ETHPHY_DP83822_LED_BLINK_RATE_500_MS                    (0x3U)
/** @} */

/**
 *  \anchor ETHPHY_DP83822_FAST_LINKDOWN_MODES
 *  \name ETHPHY DP83822 FAST LINKDOWN MODES
 *
 *  Bit-field values for CR3 fast link-down detection modes.
 *  Multiple modes may be combined with bitwise OR.
 *
 *  @{
 */
#define ETHPHY_DP83822_FAST_LINKDOWN_MODE_ENERGY_LOST           (1U << 0)
#define ETHPHY_DP83822_FAST_LINKDOWN_MODE_LOW_SNR               (1U << 1)
#define ETHPHY_DP83822_FAST_LINKDOWN_MODE_MLT3_ERR              (1U << 2)
#define ETHPHY_DP83822_FAST_LINKDOWN_MODE_RX_ERR                (1U << 3)
/** @} */

/* ========================================================================== */
/*                         Structure Declarations                             */
/* ========================================================================== */

/**
 * \brief Driver object for ETHPHY DP83822.
 *
 * Reserved for future use; no state is currently maintained by this driver.
 */
typedef struct ETHPHY_DP83822_Object_s
{
    uint32_t reserved; /**< Reserved for future use */
} ETHPHY_DP83822_Object;

/**
 * \brief Configuration data for \ref ETHPHY_CMD_CONFIGURE_LED_BLINK_RATE
 *        when used with the DP83822 PHY.
 */
typedef struct ETHPHY_DP83822_LedBlinkRateConfig_s
{
    uint32_t rate; /**< LED blink rate. Allowed values from
                        \ref ETHPHY_DP83822_LED_BLINK_RATES */
} ETHPHY_DP83822_LedBlinkRateConfig;

/**
 * \brief Configuration data for \ref ETHPHY_CMD_ENABLE_FAST_LINK_DOWN_DETECTION
 *        when used with the DP83822 PHY.
 */
typedef struct ETHPHY_DP83822_FastLinkDownDetectionConfig_s
{
    uint32_t mode; /**< Fast link-down detection mode. One or more values from
                        \ref ETHPHY_DP83822_FAST_LINKDOWN_MODES combined with
                        bitwise OR. */
} ETHPHY_DP83822_FastLinkDownDetectionConfig;

/* ========================================================================== */
/*                            Global Variables                                */
/* ========================================================================== */

/** \brief ETHPHY function table for the DP83822 PHY driver */
extern ETHPHY_Fxns gEthPhyFxns_DP83822;

#ifdef __cplusplus
}
#endif

#endif /* #ifndef ETHPHY_DP83822_H_ */
