/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Lenovo NE2580 CPLD Definitions
 *
 * Copyright (C) 2019 Cumulus Networks, Inc.  All rights reserved.
 * Author: David Yen <dhyen@cumulusnetworks.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.
 */

#ifndef LENOVO_NE2580_CPLD_H__
#define LENOVO_NE2580_CPLD_H__

/*******************************************************************************
 *
 *				Useful Macros
 *
 *  These macros provide field and bit maniplation.
 *
 ******************************************************************************/

/**
 *  @brief Retrieve the value of a field in a register. This doesn't actually
 *	   access the hardware, it merely isolates and shifts a value to extract
 *	   a field.
 *  @param [in] _reg The register value which contains the _field
 *  @param [in] _field The name of the field, from the constants, below, without
 *	   the trailing _LSB or _MSB.
 *  @return The value of the field
 */
#define GET_FIELD(_reg, _field) \
	(((_reg) & GENMASK(_field##_MSB, _field##_LSB)) >> _field##_LSB)

/**
 *  @brief Set the value of a field in a register. This doesn't actually access
 *	   the hardware, it merely isolates and shifts a field within a value to
 *	   place that field within the value.
 *  @param [in] _reg The register value which contains the _field
 *  @param [in] _field The name of the field, from the constants, below, without
 *	   the trailing _LSB or _MSB.
 *  @param [in] _val The value of the field to place within the register.
 *  @return The new register value with the modified field value
 */
#define PUT_FIELD(_reg, _field, _val) \
	(((_reg) & ~GENMASK(_field##_MSB, _field##_LSB)) | \
	 ((_val) << _field##_LSB))

/**
 *  @brief Get the width of a field in a register.
 *  @param [in] _field The name of the field, from the constants, below, without
 *	   the trailing _LSB or _MSB.
 *  @return The number of bits in the field
 */
#define FIELD_WIDTH(_field) \
	(_field##_MSB - _field##_LSB + 1)

/**
 *  @brief Get the value of a bit in a register. Very similar to #GET_FIELD
 *	   except it operates on only one bit.
 *  @param [in] _reg The register value which contains the _bit
 *  @param [in] _bit The name of the bit field, from the constants, below,
 *	   without the trailing _BIT.
 *  @return The of the bit field
 */
#define GET_BIT(_reg, _bit) \
	(((_reg) >> _bit##_BIT) & 1)

/**
 *  @brief Put the value of a bit in a register. Very similar to #PUT_FIELD
 *	   except it operates on only one bit.
 *  @param [in] _reg The register value which contains the _bit
 *  @param [in] _bit The name of the bit field, from the constants, below,
 *	   without the trailing _BIT.
 *  @param [in] _val The value of the bit. Any non-zero value is 1.
 *  @return The new register value with the modified bit field value
 */
#define PUT_BIT(_reg, _bit, _val) \
	(((_reg) & ~(1 << _bit##_BIT)) | ((!!(_val)) << _bit##_BIT))

/* Some useful macros for defining bitfields */

#define cpld_bf_ro(_name, _reg, _field, _values, _flags) \
	mk_bf_ro(cpld, _name, _reg, _field##_LSB, FIELD_WIDTH(_field), \
		 _values, _flags)

#define cpld_bf_rw(_name, _reg, _field, _values, _flags) \
	mk_bf_rw(cpld, _name, _reg, _field##_LSB, FIELD_WIDTH(_field), \
		 _values, _flags)

#define cpld_bt_ro(_name, _reg, _field, _values, _flags) \
	mk_bf_ro(cpld, _name, _reg, _field##_BIT, 1, _values, _flags)

#define cpld_bt_rw(_name, _reg, _field, _values, _flags) \
	mk_bf_rw(cpld, _name, _reg, _field##_BIT, 1, _values, _flags)

#define cpld_rg_ro(_name, _reg, _values, _flags) \
	mk_bf_ro(cpld, _name, _reg, 0, 32, _values, _flags)

#define cpld_rg_rw(_name, _reg, _values, _flags) \
	mk_bf_rw(cpld, _name, _reg, 0, 32, _values, _flags)

/*------------------------------------------------------------------------------
 *
 * This platform has two CPLD devices
 *
 *------------------------------------------------------------------------------
 */

#define NE2580_PLATFORM_NAME "ne2580_platform"
#define NE2580_CPLD1_NAME    "ne2580_cpld1"
#define NE2580_CPLD2_NAME    "ne2580_cpld2"

/*------------------------------------------------------------------------------
 *
 *			       CPLD1 Registers
 *
 *------------------------------------------------------------------------------
 */

#define LENOVO_NE2580_CPLD1_PCB_VERSION_REG				 0x00
#  define LENOVO_NE2580_CPLD1_SYS_AIR_DIR_BIT				 7
#  define LENOVO_NE2580_CPLD1_TRITON_MODEL_SEL_MSB			 6
#  define LENOVO_NE2580_CPLD1_TRITON_MODEL_SEL_LSB			 5
#  define LENOVO_NE2580_CPLD1_HW_VERSION_MSB				 3
#  define LENOVO_NE2580_CPLD1_HW_VERSION_LSB				 0

#define LENOVO_NE2580_CPLD1_VERSION_REG					 0x01
#  define LENOVO_NE2580_CPLD1_MAJOR_VERSION_MSB				 7
#  define LENOVO_NE2580_CPLD1_MAJOR_VERSION_LSB				 4
#  define LENOVO_NE2580_CPLD1_MINOR_VERSION_MSB				 3
#  define LENOVO_NE2580_CPLD1_MINOR_VERSION_LSB				 0

#define LENOVO_NE2580_CPLD1_RELEASE_DATE_1_REG				 0x02
#  define LENOVO_NE2580_CPLD1_RELEASE_YEAR_MSB				 7
#  define LENOVO_NE2580_CPLD1_RELEASE_YEAR_LSB				 4
#  define LENOVO_NE2580_CPLD1_RELEASE_MONTH_MSB				 3
#  define LENOVO_NE2580_CPLD1_RELEASE_MONTH_LSB				 0

#define LENOVO_NE2580_CPLD1_RELEASE_DATE_2_REG				 0x03
#  define LENOVO_NE2580_CPLD1_RELEASE_DATE_MSB				 4
#  define LENOVO_NE2580_CPLD1_RELEASE_DATE_LSB				 0

#define LENOVO_NE2580_CPLD1_SWITCH_READY_REG				 0x0c
#  define LENOVO_NE2580_CPLD1_SYS_RDY_BIT				 0

#define LENOVO_NE2580_CPLD1_SYSTEM_STATUS_LED_CONTROL_REG		 0x2e
#  define LENOVO_NE2580_CPLD1_SVR_LED_MSB				 7
#  define LENOVO_NE2580_CPLD1_SVR_LED_LSB				 6
#  define LENOVO_NE2580_CPLD1_PWR_LED_MSB				 5
#  define LENOVO_NE2580_CPLD1_PWR_LED_LSB				 4
#  define LENOVO_NE2580_CPLD1_FAN_LED_MSB				 3
#  define LENOVO_NE2580_CPLD1_FAN_LED_LSB				 2
#  define LENOVO_NE2580_CPLD1_STK_LED_MSB				 1
#  define LENOVO_NE2580_CPLD1_STK_LED_LSB				 0

#define LENOVO_NE2580_CPLD1_SYSTEM_RESET_CONTROL_2_REG			 0x71
#  define LENOVO_NE2580_CPLD1_PLTRST_BCM56873_N_BIT			 4
#  define LENOVO_NE2580_CPLD1_PCIE_RESET_L_BIT				 3

#define LENOVO_NE2580_CPLD1_RESET_CAUSE_REG				 0x76
#  define LENOVO_NE2580_CPLD1_SYS_THERMAL_TRIP_BIT			 5
#  define LENOVO_NE2580_CPLD1_PANIC_BIT					 4
#  define LENOVO_NE2580_CPLD1_RB_RST_BIT				 3
#  define LENOVO_NE2580_CPLD1_SW_RST_BIT				 2
#  define LENOVO_NE2580_CPLD1_WD_RST_BIT				 1
#  define LENOVO_NE2580_CPLD1_PO_RST_BIT				 0

#define LENOVO_NE2580_CPLD1_WATCHDOG_CURRENT_COUNTER_REG		 0x77
#  define LENOVO_NE2580_CPLD1_WATCHDOG_CURRENT_COUNTER_MSB		 7
#  define LENOVO_NE2580_CPLD1_WATCHDOG_CURRENT_COUNTER_LSB		 0

#define LENOVO_NE2580_CPLD1_WATCHDOG_TIMER_REG				 0x78
#  define LENOVO_NE2580_CPLD1_WATCHDOG_TIMER_MSB			 7
#  define LENOVO_NE2580_CPLD1_WATCHDOG_TIMER_LSB			 0

#define LENOVO_NE2580_CPLD1_WATCHDOG_ENABLE_REG				 0x79
#  define LENOVO_NE2580_CPLD1_WD_CLR_BIT				 1
#  define LENOVO_NE2580_CPLD1_WD_EN_BIT					 0

#define LENOVO_NE2580_CPLD1_SYSTEM_RESET_CONTROL_6_REG			 0x7b
#  define LENOVO_NE2580_CPLD1_SYSTEM_RST_SEL_BIT			 0

#define LENOVO_NE2580_CPLD1_PANIC_REG					 0x7e
#  define LENOVO_NE2580_CPLD1_PANIC_CODE_MSB				 7
#  define LENOVO_NE2580_CPLD1_PANIC_CODE_LSB				 0

/*------------------------------------------------------------------------------
 *
 *			       CPLD2 Registers
 *
 *------------------------------------------------------------------------------
 */

#define LENOVO_NE2580_CPLD2_SYSTEM_BOARD_STATUS_REG			 0x00
#  define LENOVO_NE2580_CPLD2_SYS_AIR_DIR_BIT				 7
#  define LENOVO_NE2580_CPLD2_TRITON_MODEL_SEL_BIT			 5

#define LENOVO_NE2580_CPLD2_VERSION_REG					 0x01
#  define LENOVO_NE2580_CPLD2_MAJOR_VERSION_MSB				 7
#  define LENOVO_NE2580_CPLD2_MAJOR_VERSION_LSB				 4
#  define LENOVO_NE2580_CPLD2_MINOR_VERSION_MSB				 3
#  define LENOVO_NE2580_CPLD2_MINOR_VERSION_LSB				 0

#define LENOVO_NE2580_CPLD2_RELEASE_DATE_1_REG				 0x02
#  define LENOVO_NE2580_CPLD2_RELEASE_YEAR_MSB				 7
#  define LENOVO_NE2580_CPLD2_RELEASE_YEAR_LSB				 4
#  define LENOVO_NE2580_CPLD2_RELEASE_MONTH_MSB				 3
#  define LENOVO_NE2580_CPLD2_RELEASE_MONTH_LSB				 0

#define LENOVO_NE2580_CPLD2_RELEASE_DATE_2_REG				 0x03
#  define LENOVO_NE2580_CPLD2_RELEASE_DATE_MSB				 4
#  define LENOVO_NE2580_CPLD2_RELEASE_DATE_LSB				 0

#define LENOVO_NE2580_CPLD2_SWITCH_READY_REG				 0x0c
#  define LENOVO_NE2580_CPLD2_SYS_RDY_BIT				 0

#define LENOVO_NE2580_CPLD2_SYSTEM_STATUS_LED_CONTROL_REG		 0x2e
#  define LENOVO_NE2580_CPLD2_PWR_LED_MSB				 5
#  define LENOVO_NE2580_CPLD2_PWR_LED_LSB				 4
#  define LENOVO_NE2580_CPLD2_FAN_LED_MSB				 3
#  define LENOVO_NE2580_CPLD2_FAN_LED_LSB				 2

#define LENOVO_NE2580_CPLD2_PSU_STATUS_REG				 0x40
#  define LENOVO_NE2580_CPLD2_PSU2_TYPE_BIT				 6
#  define LENOVO_NE2580_CPLD2_PSU2_PRESNT_N_BIT				 5
#  define LENOVO_NE2580_CPLD2_PSU2_PWROK_BIT				 4
#  define LENOVO_NE2580_CPLD2_PSU1_TYPE_BIT				 2
#  define LENOVO_NE2580_CPLD2_PSU1_PRESNT_N_BIT				 1
#  define LENOVO_NE2580_CPLD2_PSU1_PWROK_BIT				 0

#define LENOVO_NE2580_CPLD2_FAN1_PWM_REG				 0x50
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN1_MSB				 7
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN1_LSB				 0

#define LENOVO_NE2580_CPLD2_FAN2_PWM_REG				 0x51
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN2_MSB				 7
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN2_LSB				 0

#define LENOVO_NE2580_CPLD2_FAN3_PWM_REG				 0x52
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN3_MSB				 7
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN3_LSB				 0

#define LENOVO_NE2580_CPLD2_FAN4_PWM_REG				 0x53
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN4_MSB				 7
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN4_LSB				 0

#define LENOVO_NE2580_CPLD2_FAN5_PWM_REG				 0x54
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN5_MSB				 7
#  define LENOVO_NE2580_CPLD2_PLD_PWM_FAN5_LSB				 0

#define LENOVO_NE2580_CPLD2_FAN1_INLET_TACH_1_REG			 0x55
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN1_INLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN1_INLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN1_INLET_TACH_2_REG			 0x56
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN1_INLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN1_INLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN1_OUTLET_TACH_1_REG			 0x57
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN1_OUTLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN1_OUTLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN1_OUTLET_TACH_2_REG			 0x58
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN1_OUTLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN1_OUTLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN2_INLET_TACH_1_REG			 0x59
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN2_INLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN2_INLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN2_INLET_TACH_2_REG			 0x5a
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN2_INLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN2_INLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN2_OUTLET_TACH_1_REG			 0x5b
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN2_OUTLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN2_OUTLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN2_OUTLET_TACH_2_REG			 0x5c
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN2_OUTLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN2_OUTLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN3_INLET_TACH_1_REG			 0x5d
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN3_INLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN3_INLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN3_INLET_TACH_2_REG			 0x5e
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN3_INLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN3_INLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN3_OUTLET_TACH_1_REG			 0x5f
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN3_OUTLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN3_OUTLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN3_OUTLET_TACH_2_REG			 0x60
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN3_OUTLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN3_OUTLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN4_INLET_TACH_1_REG			 0x61
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN4_INLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN4_INLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN4_INLET_TACH_2_REG			 0x62
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN4_INLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN4_INLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN4_OUTLET_TACH_1_REG			 0x63
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN4_OUTLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN4_OUTLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN4_OUTLET_TACH_2_REG			 0x64
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN4_OUTLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN4_OUTLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN5_INLET_TACH_1_REG			 0x65
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN5_INLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN5_INLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN5_INLET_TACH_2_REG			 0x66
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN5_INLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN5_INLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN5_OUTLET_TACH_1_REG			 0x67
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN5_OUTLET_HI_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN5_OUTLET_HI_LSB		 0
#define LENOVO_NE2580_CPLD2_FAN5_OUTLET_TACH_2_REG			 0x68
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN5_OUTLET_LO_MSB		 7
#  define LENOVO_NE2580_CPLD2_PLD_TACH_FAN5_OUTLET_LO_LSB		 0

#define LENOVO_NE2580_CPLD2_FAN_STATUS_1_REG				 0x69
#  define LENOVO_NE2580_CPLD2_PLD_FAN5_DIR_BIT				 4
#  define LENOVO_NE2580_CPLD2_PLD_FAN4_DIR_BIT				 3
#  define LENOVO_NE2580_CPLD2_PLD_FAN3_DIR_BIT				 2
#  define LENOVO_NE2580_CPLD2_PLD_FAN2_DIR_BIT				 1
#  define LENOVO_NE2580_CPLD2_PLD_FAN1_DIR_BIT				 0

#define LENOVO_NE2580_CPLD2_FAN_STATUS_2_REG				 0x6a
#  define LENOVO_NE2580_CPLD2_PLD_FAN5_PRES_N_BIT			 4
#  define LENOVO_NE2580_CPLD2_PLD_FAN4_PRES_N_BIT			 3
#  define LENOVO_NE2580_CPLD2_PLD_FAN3_PRES_N_BIT			 2
#  define LENOVO_NE2580_CPLD2_PLD_FAN2_PRES_N_BIT			 1
#  define LENOVO_NE2580_CPLD2_PLD_FAN1_PRES_N_BIT			 0

#define LENOVO_NE2580_CPLD2_FAN_LED_CONTROL_1_REG			 0x6b
#  define LENOVO_NE2580_CPLD2_PLD_LED_GRN_PSOC_FAN5_BIT			 4
#  define LENOVO_NE2580_CPLD2_PLD_LED_GRN_PSOC_FAN4_BIT			 3
#  define LENOVO_NE2580_CPLD2_PLD_LED_GRN_PSOC_FAN3_BIT			 2
#  define LENOVO_NE2580_CPLD2_PLD_LED_GRN_PSOC_FAN2_BIT			 1
#  define LENOVO_NE2580_CPLD2_PLD_LED_GRN_PSOC_FAN1_BIT			 0

#define LENOVO_NE2580_CPLD2_FAN_LED_CONTROL_2_REG			 0x6c
#  define LENOVO_NE2580_CPLD2_PLD_LED_RED_PSOC_FAN5_BIT			 4
#  define LENOVO_NE2580_CPLD2_PLD_LED_RED_PSOC_FAN4_BIT			 3
#  define LENOVO_NE2580_CPLD2_PLD_LED_RED_PSOC_FAN3_BIT			 2
#  define LENOVO_NE2580_CPLD2_PLD_LED_RED_PSOC_FAN2_BIT			 1
#  define LENOVO_NE2580_CPLD2_PLD_LED_RED_PSOC_FAN1_BIT			 0

#define LENOVO_NE2580_CPLD2_FAN_SPEED_CONTROL_REG			 0x6d
#  define LENOVO_NE2580_CPLD2_FAN_SPEED_MAX_BIT				 7

/*------------------------------------------------------------------------------
 *
 *			       GPIO Pins
 *
 *------------------------------------------------------------------------------
 */

/* mux channel 0 */

#define LENOVO_NE2580_GPIO020_BASE					 0
#define LENOVO_NE2580_GPIO020_PIN_COUNT					 16
#define LENOVO_NE2580_PORT49_MODSEL					 0
#define LENOVO_NE2580_PORT50_MODSEL					 1
#define LENOVO_NE2580_PORT51_MODSEL					 2
#define LENOVO_NE2580_PORT52_MODSEL					 3
#define LENOVO_NE2580_PORT53_MODSEL					 4
#define LENOVO_NE2580_PORT54_MODSEL					 5
#define LENOVO_NE2580_PORT55_MODSEL					 6
#define LENOVO_NE2580_PORT56_MODSEL					 7
#define LENOVO_NE2580_PORT49_RESET					 8
#define LENOVO_NE2580_PORT50_RESET					 9
#define LENOVO_NE2580_PORT51_RESET					 10
#define LENOVO_NE2580_PORT52_RESET					 11
#define LENOVO_NE2580_PORT53_RESET					 12
#define LENOVO_NE2580_PORT54_RESET					 13
#define LENOVO_NE2580_PORT55_RESET					 14
#define LENOVO_NE2580_PORT56_RESET					 15

#define LENOVO_NE2580_GPIO021_BASE					 20
#define LENOVO_NE2580_GPIO021_PIN_COUNT					 16
#define LENOVO_NE2580_PORT49_LPMODE					 0
#define LENOVO_NE2580_PORT50_LPMODE					 1
#define LENOVO_NE2580_PORT51_LPMODE					 2
#define LENOVO_NE2580_PORT52_LPMODE					 3
#define LENOVO_NE2580_PORT53_LPMODE					 4
#define LENOVO_NE2580_PORT54_LPMODE					 5
#define LENOVO_NE2580_PORT55_LPMODE					 6
#define LENOVO_NE2580_PORT56_LPMODE					 7

#define LENOVO_NE2580_GPIO022_BASE					 40
#define LENOVO_NE2580_GPIO022_PIN_COUNT					 16
#define LENOVO_NE2580_PORT49_RXLOS					 0
#define LENOVO_NE2580_PORT50_RXLOS					 1
#define LENOVO_NE2580_PORT51_RXLOS					 2
#define LENOVO_NE2580_PORT52_RXLOS					 3
#define LENOVO_NE2580_PORT53_RXLOS					 4
#define LENOVO_NE2580_PORT54_RXLOS					 5
#define LENOVO_NE2580_PORT55_RXLOS					 6
#define LENOVO_NE2580_PORT56_RXLOS					 7
#define LENOVO_NE2580_PORT49_MODABS					 8
#define LENOVO_NE2580_PORT50_MODABS					 9
#define LENOVO_NE2580_PORT51_MODABS					 10
#define LENOVO_NE2580_PORT52_MODABS					 11
#define LENOVO_NE2580_PORT53_MODABS					 12
#define LENOVO_NE2580_PORT54_MODABS					 13
#define LENOVO_NE2580_PORT55_MODABS					 14
#define LENOVO_NE2580_PORT56_MODABS					 15

/* mux channel 1 */

#define LENOVO_NE2580_GPIO120_BASE					 100
#define LENOVO_NE2580_GPIO120_PIN_COUNT					 16
#define LENOVO_NE2580_PORT1_TXFAULT					 0
#define LENOVO_NE2580_PORT2_TXFAULT					 1
#define LENOVO_NE2580_PORT3_TXFAULT					 2
#define LENOVO_NE2580_PORT4_TXFAULT					 3
#define LENOVO_NE2580_PORT1_MODABS					 4
#define LENOVO_NE2580_PORT2_MODABS					 5
#define LENOVO_NE2580_PORT3_MODABS					 6
#define LENOVO_NE2580_PORT4_MODABS					 7
#define LENOVO_NE2580_PORT1_TXDISABLE					 8
#define LENOVO_NE2580_PORT2_TXDISABLE					 9
#define LENOVO_NE2580_PORT3_TXDISABLE					 10
#define LENOVO_NE2580_PORT4_TXDISABLE					 11
#define LENOVO_NE2580_PORT1_RXLOS					 12
#define LENOVO_NE2580_PORT2_RXLOS					 13
#define LENOVO_NE2580_PORT3_RXLOS					 14
#define LENOVO_NE2580_PORT4_RXLOS					 15

#define LENOVO_NE2580_GPIO121_BASE					 120
#define LENOVO_NE2580_GPIO121_PIN_COUNT					 16
#define LENOVO_NE2580_PORT5_TXFAULT					 0
#define LENOVO_NE2580_PORT6_TXFAULT					 1
#define LENOVO_NE2580_PORT7_TXFAULT					 2
#define LENOVO_NE2580_PORT8_TXFAULT					 3
#define LENOVO_NE2580_PORT5_MODABS					 4
#define LENOVO_NE2580_PORT6_MODABS					 5
#define LENOVO_NE2580_PORT7_MODABS					 6
#define LENOVO_NE2580_PORT8_MODABS					 7
#define LENOVO_NE2580_PORT5_TXDISABLE					 8
#define LENOVO_NE2580_PORT6_TXDISABLE					 9
#define LENOVO_NE2580_PORT7_TXDISABLE					 10
#define LENOVO_NE2580_PORT8_TXDISABLE					 11
#define LENOVO_NE2580_PORT5_RXLOS					 12
#define LENOVO_NE2580_PORT6_RXLOS					 13
#define LENOVO_NE2580_PORT7_RXLOS					 14
#define LENOVO_NE2580_PORT8_RXLOS					 15

#define LENOVO_NE2580_GPIO122_BASE					 140
#define LENOVO_NE2580_GPIO122_PIN_COUNT					 16
#define LENOVO_NE2580_PORT1_RS0						 0
#define LENOVO_NE2580_PORT1_RS1						 1
#define LENOVO_NE2580_PORT2_RS0						 2
#define LENOVO_NE2580_PORT2_RS1						 3
#define LENOVO_NE2580_PORT3_RS0						 4
#define LENOVO_NE2580_PORT3_RS1						 5
#define LENOVO_NE2580_PORT4_RS0						 6
#define LENOVO_NE2580_PORT4_RS1						 7
#define LENOVO_NE2580_PORT5_RS0						 8
#define LENOVO_NE2580_PORT5_RS1						 9
#define LENOVO_NE2580_PORT6_RS0						 10
#define LENOVO_NE2580_PORT6_RS1						 11
#define LENOVO_NE2580_PORT7_RS0						 12
#define LENOVO_NE2580_PORT7_RS1						 13
#define LENOVO_NE2580_PORT8_RS0						 14
#define LENOVO_NE2580_PORT8_RS1						 15

/* mux channel 2 */

#define LENOVO_NE2580_GPIO220_BASE					 200
#define LENOVO_NE2580_GPIO220_PIN_COUNT					 16
#define LENOVO_NE2580_PORT9_TXFAULT					 0
#define LENOVO_NE2580_PORT10_TXFAULT					 1
#define LENOVO_NE2580_PORT11_TXFAULT					 2
#define LENOVO_NE2580_PORT12_TXFAULT					 3
#define LENOVO_NE2580_PORT9_MODABS					 4
#define LENOVO_NE2580_PORT10_MODABS					 5
#define LENOVO_NE2580_PORT11_MODABS					 6
#define LENOVO_NE2580_PORT12_MODABS					 7
#define LENOVO_NE2580_PORT9_TXDISABLE					 8
#define LENOVO_NE2580_PORT10_TXDISABLE					 9
#define LENOVO_NE2580_PORT11_TXDISABLE					 10
#define LENOVO_NE2580_PORT12_TXDISABLE					 11
#define LENOVO_NE2580_PORT9_RXLOS					 12
#define LENOVO_NE2580_PORT10_RXLOS					 13
#define LENOVO_NE2580_PORT11_RXLOS					 14
#define LENOVO_NE2580_PORT12_RXLOS					 15

#define LENOVO_NE2580_GPIO221_BASE					 220
#define LENOVO_NE2580_GPIO221_PIN_COUNT					 16
#define LENOVO_NE2580_PORT13_TXFAULT					 0
#define LENOVO_NE2580_PORT14_TXFAULT					 1
#define LENOVO_NE2580_PORT15_TXFAULT					 2
#define LENOVO_NE2580_PORT16_TXFAULT					 3
#define LENOVO_NE2580_PORT13_MODABS					 4
#define LENOVO_NE2580_PORT14_MODABS					 5
#define LENOVO_NE2580_PORT15_MODABS					 6
#define LENOVO_NE2580_PORT16_MODABS					 7
#define LENOVO_NE2580_PORT13_TXDISABLE					 8
#define LENOVO_NE2580_PORT14_TXDISABLE					 9
#define LENOVO_NE2580_PORT15_TXDISABLE					 10
#define LENOVO_NE2580_PORT16_TXDISABLE					 11
#define LENOVO_NE2580_PORT13_RXLOS					 12
#define LENOVO_NE2580_PORT14_RXLOS					 13
#define LENOVO_NE2580_PORT15_RXLOS					 14
#define LENOVO_NE2580_PORT16_RXLOS					 15

#define LENOVO_NE2580_GPIO222_BASE					 240
#define LENOVO_NE2580_GPIO222_PIN_COUNT					 16
#define LENOVO_NE2580_PORT9_RS0						 0
#define LENOVO_NE2580_PORT9_RS1						 1
#define LENOVO_NE2580_PORT10_RS0					 2
#define LENOVO_NE2580_PORT10_RS1					 3
#define LENOVO_NE2580_PORT11_RS0					 4
#define LENOVO_NE2580_PORT11_RS1					 5
#define LENOVO_NE2580_PORT12_RS0					 6
#define LENOVO_NE2580_PORT12_RS1					 7
#define LENOVO_NE2580_PORT13_RS0					 8
#define LENOVO_NE2580_PORT13_RS1					 9
#define LENOVO_NE2580_PORT14_RS0					 10
#define LENOVO_NE2580_PORT14_RS1					 11
#define LENOVO_NE2580_PORT15_RS0					 12
#define LENOVO_NE2580_PORT15_RS1					 13
#define LENOVO_NE2580_PORT16_RS0					 14
#define LENOVO_NE2580_PORT16_RS1					 15

/* mux channel 3 */

#define LENOVO_NE2580_GPIO320_BASE					 300
#define LENOVO_NE2580_GPIO320_PIN_COUNT					 16
#define LENOVO_NE2580_PORT17_TXFAULT					 0
#define LENOVO_NE2580_PORT18_TXFAULT					 1
#define LENOVO_NE2580_PORT19_TXFAULT					 2
#define LENOVO_NE2580_PORT20_TXFAULT					 3
#define LENOVO_NE2580_PORT17_MODABS					 4
#define LENOVO_NE2580_PORT18_MODABS					 5
#define LENOVO_NE2580_PORT19_MODABS					 6
#define LENOVO_NE2580_PORT20_MODABS					 7
#define LENOVO_NE2580_PORT17_TXDISABLE					 8
#define LENOVO_NE2580_PORT18_TXDISABLE					 9
#define LENOVO_NE2580_PORT19_TXDISABLE					 10
#define LENOVO_NE2580_PORT20_TXDISABLE					 11
#define LENOVO_NE2580_PORT17_RXLOS					 12
#define LENOVO_NE2580_PORT18_RXLOS					 13
#define LENOVO_NE2580_PORT19_RXLOS					 14
#define LENOVO_NE2580_PORT20_RXLOS					 15

#define LENOVO_NE2580_GPIO321_BASE					 320
#define LENOVO_NE2580_GPIO321_PIN_COUNT					 16
#define LENOVO_NE2580_PORT21_TXFAULT					 0
#define LENOVO_NE2580_PORT22_TXFAULT					 1
#define LENOVO_NE2580_PORT23_TXFAULT					 2
#define LENOVO_NE2580_PORT24_TXFAULT					 3
#define LENOVO_NE2580_PORT21_MODABS					 4
#define LENOVO_NE2580_PORT22_MODABS					 5
#define LENOVO_NE2580_PORT23_MODABS					 6
#define LENOVO_NE2580_PORT24_MODABS					 7
#define LENOVO_NE2580_PORT21_TXDISABLE					 8
#define LENOVO_NE2580_PORT22_TXDISABLE					 9
#define LENOVO_NE2580_PORT23_TXDISABLE					 10
#define LENOVO_NE2580_PORT24_TXDISABLE					 11
#define LENOVO_NE2580_PORT21_RXLOS					 12
#define LENOVO_NE2580_PORT22_RXLOS					 13
#define LENOVO_NE2580_PORT23_RXLOS					 14
#define LENOVO_NE2580_PORT24_RXLOS					 15

#define LENOVO_NE2580_GPIO322_BASE					 340
#define LENOVO_NE2580_GPIO322_PIN_COUNT					 16
#define LENOVO_NE2580_PORT17_RS0					 0
#define LENOVO_NE2580_PORT17_RS1					 1
#define LENOVO_NE2580_PORT18_RS0					 2
#define LENOVO_NE2580_PORT18_RS1					 3
#define LENOVO_NE2580_PORT19_RS0					 4
#define LENOVO_NE2580_PORT19_RS1					 5
#define LENOVO_NE2580_PORT20_RS0					 6
#define LENOVO_NE2580_PORT20_RS1					 7
#define LENOVO_NE2580_PORT21_RS0					 8
#define LENOVO_NE2580_PORT21_RS1					 9
#define LENOVO_NE2580_PORT22_RS0					 10
#define LENOVO_NE2580_PORT22_RS1					 11
#define LENOVO_NE2580_PORT23_RS0					 12
#define LENOVO_NE2580_PORT23_RS1					 13
#define LENOVO_NE2580_PORT24_RS0					 14
#define LENOVO_NE2580_PORT24_RS1					 15

/* mux channel 4 */

#define LENOVO_NE2580_GPIO420_BASE					 400
#define LENOVO_NE2580_GPIO420_PIN_COUNT					 16
#define LENOVO_NE2580_PORT25_TXFAULT					 0
#define LENOVO_NE2580_PORT26_TXFAULT					 1
#define LENOVO_NE2580_PORT27_TXFAULT					 2
#define LENOVO_NE2580_PORT28_TXFAULT					 3
#define LENOVO_NE2580_PORT25_MODABS					 4
#define LENOVO_NE2580_PORT26_MODABS					 5
#define LENOVO_NE2580_PORT27_MODABS					 6
#define LENOVO_NE2580_PORT28_MODABS					 7
#define LENOVO_NE2580_PORT25_TXDISABLE					 8
#define LENOVO_NE2580_PORT26_TXDISABLE					 9
#define LENOVO_NE2580_PORT27_TXDISABLE					 10
#define LENOVO_NE2580_PORT28_TXDISABLE					 11
#define LENOVO_NE2580_PORT25_RXLOS					 12
#define LENOVO_NE2580_PORT26_RXLOS					 13
#define LENOVO_NE2580_PORT27_RXLOS					 14
#define LENOVO_NE2580_PORT28_RXLOS					 15

#define LENOVO_NE2580_GPIO421_BASE					 420
#define LENOVO_NE2580_GPIO421_PIN_COUNT					 16
#define LENOVO_NE2580_PORT29_TXFAULT					 0
#define LENOVO_NE2580_PORT30_TXFAULT					 1
#define LENOVO_NE2580_PORT31_TXFAULT					 2
#define LENOVO_NE2580_PORT32_TXFAULT					 3
#define LENOVO_NE2580_PORT29_MODABS					 4
#define LENOVO_NE2580_PORT30_MODABS					 5
#define LENOVO_NE2580_PORT31_MODABS					 6
#define LENOVO_NE2580_PORT32_MODABS					 7
#define LENOVO_NE2580_PORT29_TXDISABLE					 8
#define LENOVO_NE2580_PORT30_TXDISABLE					 9
#define LENOVO_NE2580_PORT31_TXDISABLE					 10
#define LENOVO_NE2580_PORT32_TXDISABLE					 11
#define LENOVO_NE2580_PORT29_RXLOS					 12
#define LENOVO_NE2580_PORT30_RXLOS					 13
#define LENOVO_NE2580_PORT31_RXLOS					 14
#define LENOVO_NE2580_PORT32_RXLOS					 15

#define LENOVO_NE2580_GPIO422_BASE					 440
#define LENOVO_NE2580_GPIO422_PIN_COUNT					 16
#define LENOVO_NE2580_PORT25_RS0					 0
#define LENOVO_NE2580_PORT25_RS1					 1
#define LENOVO_NE2580_PORT26_RS0					 2
#define LENOVO_NE2580_PORT26_RS1					 3
#define LENOVO_NE2580_PORT27_RS0					 4
#define LENOVO_NE2580_PORT27_RS1					 5
#define LENOVO_NE2580_PORT28_RS0					 6
#define LENOVO_NE2580_PORT28_RS1					 7
#define LENOVO_NE2580_PORT29_RS0					 8
#define LENOVO_NE2580_PORT29_RS1					 9
#define LENOVO_NE2580_PORT30_RS0					 10
#define LENOVO_NE2580_PORT30_RS1					 11
#define LENOVO_NE2580_PORT31_RS0					 12
#define LENOVO_NE2580_PORT31_RS1					 13
#define LENOVO_NE2580_PORT32_RS0					 14
#define LENOVO_NE2580_PORT32_RS1					 15

/* mux channel 5 */

#define LENOVO_NE2580_GPIO520_BASE					 500
#define LENOVO_NE2580_GPIO520_PIN_COUNT					 16
#define LENOVO_NE2580_PORT33_TXFAULT					 0
#define LENOVO_NE2580_PORT34_TXFAULT					 1
#define LENOVO_NE2580_PORT35_TXFAULT					 2
#define LENOVO_NE2580_PORT36_TXFAULT					 3
#define LENOVO_NE2580_PORT33_MODABS					 4
#define LENOVO_NE2580_PORT34_MODABS					 5
#define LENOVO_NE2580_PORT35_MODABS					 6
#define LENOVO_NE2580_PORT36_MODABS					 7
#define LENOVO_NE2580_PORT33_TXDISABLE					 8
#define LENOVO_NE2580_PORT34_TXDISABLE					 9
#define LENOVO_NE2580_PORT35_TXDISABLE					 10
#define LENOVO_NE2580_PORT36_TXDISABLE					 11
#define LENOVO_NE2580_PORT33_RXLOS					 12
#define LENOVO_NE2580_PORT34_RXLOS					 13
#define LENOVO_NE2580_PORT35_RXLOS					 14
#define LENOVO_NE2580_PORT36_RXLOS					 15

#define LENOVO_NE2580_GPIO521_BASE					 520
#define LENOVO_NE2580_GPIO521_PIN_COUNT					 16
#define LENOVO_NE2580_PORT37_TXFAULT					 0
#define LENOVO_NE2580_PORT38_TXFAULT					 1
#define LENOVO_NE2580_PORT39_TXFAULT					 2
#define LENOVO_NE2580_PORT40_TXFAULT					 3
#define LENOVO_NE2580_PORT37_MODABS					 4
#define LENOVO_NE2580_PORT38_MODABS					 5
#define LENOVO_NE2580_PORT39_MODABS					 6
#define LENOVO_NE2580_PORT40_MODABS					 7
#define LENOVO_NE2580_PORT37_TXDISABLE					 8
#define LENOVO_NE2580_PORT38_TXDISABLE					 9
#define LENOVO_NE2580_PORT39_TXDISABLE					 10
#define LENOVO_NE2580_PORT40_TXDISABLE					 11
#define LENOVO_NE2580_PORT37_RXLOS					 12
#define LENOVO_NE2580_PORT38_RXLOS					 13
#define LENOVO_NE2580_PORT39_RXLOS					 14
#define LENOVO_NE2580_PORT40_RXLOS					 15

#define LENOVO_NE2580_GPIO522_BASE					 540
#define LENOVO_NE2580_GPIO522_PIN_COUNT					 16
#define LENOVO_NE2580_PORT33_RS0					 0
#define LENOVO_NE2580_PORT33_RS1					 1
#define LENOVO_NE2580_PORT34_RS0					 2
#define LENOVO_NE2580_PORT34_RS1					 3
#define LENOVO_NE2580_PORT35_RS0					 4
#define LENOVO_NE2580_PORT35_RS1					 5
#define LENOVO_NE2580_PORT36_RS0					 6
#define LENOVO_NE2580_PORT36_RS1					 7
#define LENOVO_NE2580_PORT37_RS0					 8
#define LENOVO_NE2580_PORT37_RS1					 9
#define LENOVO_NE2580_PORT38_RS0					 10
#define LENOVO_NE2580_PORT38_RS1					 11
#define LENOVO_NE2580_PORT39_RS0					 12
#define LENOVO_NE2580_PORT39_RS1					 13
#define LENOVO_NE2580_PORT40_RS0					 14
#define LENOVO_NE2580_PORT40_RS1					 15

/* mux channel 6 */

#define LENOVO_NE2580_GPIO620_BASE					 600
#define LENOVO_NE2580_GPIO620_PIN_COUNT					 16
#define LENOVO_NE2580_PORT41_TXFAULT					 0
#define LENOVO_NE2580_PORT42_TXFAULT					 1
#define LENOVO_NE2580_PORT43_TXFAULT					 2
#define LENOVO_NE2580_PORT44_TXFAULT					 3
#define LENOVO_NE2580_PORT41_MODABS					 4
#define LENOVO_NE2580_PORT42_MODABS					 5
#define LENOVO_NE2580_PORT43_MODABS					 6
#define LENOVO_NE2580_PORT44_MODABS					 7
#define LENOVO_NE2580_PORT41_TXDISABLE					 8
#define LENOVO_NE2580_PORT42_TXDISABLE					 9
#define LENOVO_NE2580_PORT43_TXDISABLE					 10
#define LENOVO_NE2580_PORT44_TXDISABLE					 11
#define LENOVO_NE2580_PORT41_RXLOS					 12
#define LENOVO_NE2580_PORT42_RXLOS					 13
#define LENOVO_NE2580_PORT43_RXLOS					 14
#define LENOVO_NE2580_PORT44_RXLOS					 15

#define LENOVO_NE2580_GPIO621_BASE					 620
#define LENOVO_NE2580_GPIO621_PIN_COUNT					 16
#define LENOVO_NE2580_PORT45_TXFAULT					 0
#define LENOVO_NE2580_PORT46_TXFAULT					 1
#define LENOVO_NE2580_PORT47_TXFAULT					 2
#define LENOVO_NE2580_PORT48_TXFAULT					 3
#define LENOVO_NE2580_PORT45_MODABS					 4
#define LENOVO_NE2580_PORT46_MODABS					 5
#define LENOVO_NE2580_PORT47_MODABS					 6
#define LENOVO_NE2580_PORT48_MODABS					 7
#define LENOVO_NE2580_PORT45_TXDISABLE					 8
#define LENOVO_NE2580_PORT46_TXDISABLE					 9
#define LENOVO_NE2580_PORT47_TXDISABLE					 10
#define LENOVO_NE2580_PORT48_TXDISABLE					 11
#define LENOVO_NE2580_PORT45_RXLOS					 12
#define LENOVO_NE2580_PORT46_RXLOS					 13
#define LENOVO_NE2580_PORT47_RXLOS					 14
#define LENOVO_NE2580_PORT48_RXLOS					 15

#define LENOVO_NE2580_GPIO622_BASE					 640
#define LENOVO_NE2580_GPIO622_PIN_COUNT					 16
#define LENOVO_NE2580_PORT41_RS0					 0
#define LENOVO_NE2580_PORT41_RS1					 1
#define LENOVO_NE2580_PORT42_RS0					 2
#define LENOVO_NE2580_PORT42_RS1					 3
#define LENOVO_NE2580_PORT43_RS0					 4
#define LENOVO_NE2580_PORT43_RS1					 5
#define LENOVO_NE2580_PORT44_RS0					 6
#define LENOVO_NE2580_PORT44_RS1					 7
#define LENOVO_NE2580_PORT45_RS0					 8
#define LENOVO_NE2580_PORT45_RS1					 9
#define LENOVO_NE2580_PORT46_RS0					 10
#define LENOVO_NE2580_PORT46_RS1					 11
#define LENOVO_NE2580_PORT47_RS0					 12
#define LENOVO_NE2580_PORT47_RS1					 13
#define LENOVO_NE2580_PORT48_RS0					 14
#define LENOVO_NE2580_PORT48_RS1					 15

#endif	/* LENOVO_NE2580_CPLD_H__ */
