#ifndef SONY_FPGA_XPT_H
#define SONY_FPGA_XPT_H

#include <linux/types.h>
#include "sony_fpga.h"
#include "sony_fpga_cmd.h"
#include "sony_fpga_local_if_i2c.h"


enum {
    RETIMER_UP,
    RETIMER_DOWN
};
// I2Cスレーブアドレス
#define I2C_SLAVE_ADDR_IOEXPANDER1     0x21
#define I2C_SLAVE_ADDR_IOEXPANDER2     0x22
#define I2C_SLAVE_ADDR_IOEXPANDER3     0x23
#define I2C_SLAVE_ADDR_QSFP            0x50

#define I2C_SLAVE_ADDR_RTM0            0x18
#define I2C_SLAVE_ADDR_RTM1            0x19
#define I2C_SLAVE_ADDR_RTM2            0x1a
#define I2C_SLAVE_ADDR_RTM3            0x1b
#define I2C_SLAVE_ADDR_RTM4            0x1c
#define I2C_SLAVE_ADDR_RTM5            0x1d
#define I2C_SLAVE_ADDR_RTM6            0x1e
#define I2C_SLAVE_ADDR_RTM7            0x1f
#define I2C_SLAVE_ADDR_RTM8            0x20
#define I2C_SLAVE_ADDR_RTM9            0x25
#define I2C_SLAVE_ADDR_RTM10           0x22
#define I2C_SLAVE_ADDR_RTM11           0x23

// I2C Driver Address
#define QSFP_1_BASE_ADDR               0x00060000
#define QSFP_2_BASE_ADDR               0x00061000
#define QSFP_3_BASE_ADDR               0x00062000
#define QSFP_CTRL1_BASE_ADDR           0x00064000
#define QSFP_CTRL2_BASE_ADDR           0x00065000
#define QSFP_CTRL3_BASE_ADDR           0x00066000
#define RTM_BASE_ADDR                  0x00063000
#define EXT_MOD_PRS_L_BASE_ADDR        0x00067020

#define XPT_BOARD_REV11 0
#define XPT_BOARD_REV12 1
#define XPT_BOARD_REV13 2
#define XPT_BOARD_REV21 3

extern int sony_fpga_xpt_fpga_probe(struct sony_fpga_ctrl* ctrl);
extern int sony_fpga_xpt_i2c_request(struct sony_fpga_ctrl* ctrl, struct i2c_param* param, bool is_read);
extern int sony_fpga_pause_qsfp_thread(struct sony_fpga_ctrl* ctrl, u32 control);
extern int sony_fpga_resume_qsfp_thread(struct sony_fpga_ctrl* ctrl, u32 control);
extern int sony_fpga_xpt_qsfp_setting(struct sony_fpga_ctrl* ctrl, u32 qsfp_number);
extern int sony_fpga_xpt_qsfp_cdr_reset(struct sony_fpga_ctrl* ctrl, u32 qsfp_number);

extern const u32 qsfp_number_resolve[][2];
#endif
