XPON #5

Open
opened 2025-11-13 00:49:00 +00:00 by Sirherobrine23 · 32 comments
Owner

en7512 based code or compatible

Notes

It appears that configuration communication is via I2C, as well as with MMIO together with serders to the new airoha_eth drive

+-----------------------------------------------------------------------------+
|                      USER SPACE / OPERATING SYSTEM                          |
|     ('ioctl' commands, Config Manager, OMCI Apps, Network Interface)        |
+--------------------------------------+--------------------------------------+
                                       |
                                       v
+-----------------------------------------------------------------------------+
|                        MAIN DRIVER (XPON DRV)                               |
|                  Location: private/xpon/src/xpondrv.c                       |
+-----------------------------------------------------------------------------+
|                                                                             |
|  [ xpondrv.c ] <------- Main Brain (Kernel Module Entry Point)              |
|        |                                                                    |
|        +--- [ xpon_daemon.c ]  (Background event and state monitor)         |
|        |                                                                    |
|        +--- [ pwan/xpon_netif.c ] (Creates network interfaces: nasX, ethX)  |
|                                                                             |
+--------------------------------------+--------------------------------------+
                                       |
                                       v
+-----------------------------------------------------------------------------+
|                   MAC ABSTRACTION LAYER (XMCS Interface)                    |
|                   Location: private/xpon/src/xmcs/                          |
+-----------------------------------------------------------------------------+
|  [ xmcs_if.c ]   (The "Switch" deciding who operates: GPON or EPON)         |
|  [ xmcs_mci.c ]  (Management Control Interface)                             |
+------------------+-------------------+--------------------------------------+
                   |                   |
      (If GPON mode active)    (If EPON mode active)
                   v                   v
+-------------------------+   +-------------------------+
|       GPON STACK        |   |       EPON STACK        |
| (private/xpon/src/gpon) |   | (private/xpon/src/epon) |
+-------------------------+   +-------------------------+
| [ gpon.c ] (Core)       |   | [ epon_main.c ] (Core)  |
|                         |   |                         |
| - ONU Mgmt (PLOAM):     |   | - MAC Control (MPCP):   |
|   [ gpon_ploam.c ]      |   |   [ epon_mpcp.c ]       |
|                         |   |                         |
| - Configuration (OMCI): |   | - Hardware IO:          |
|   [ gpon_omcis.c ]      |   |   [ epon_ioctl.c ]      |
|                         |   |                         |
| - GPON Hardware:        |   | - Utilities:            |
|   [ gpon_dev.c ]        |   |   [ epon_util.c ]       |
+-------------------------+   +-------------------------+
                   |                   |
                   +---------+---------+
                             |
                             v
+-----------------------------------------------------------------------------+
|                    MAC PHYSICAL INTERFACE (XMCS PHY)                        |
|               Location: private/xpon/src/xmcs/xmcs_phy.c                    |
|         (Abstracts communication between MAC logic and real PHY driver)     |
+-----------------------------------------------------------------------------+
                             |
                             v
+-----------------------------------------------------------------------------+
|                      PHYSICAL LAYER CONTROLLER (PHY)                        |
|                     Location: private/xpon_phy/src/                         |
+-----------------------------------------------------------------------------+
|  [ phy.c ]      (Central control logic for optical PHY)                     |
|  [ phy_init.c ] (Initialization and calibration of lasers/sensors)          |
|                                                                             |
|  HARDWARE SUB-MODULES:                                                      |
|  +------------------+     +------------------+     +------------------+     |
|  |   Transmission   |     |     Reception    |     |     Chipset      |     |
|  |   [ phy_tx.c ]   |     |   [ phy_rx.c ]   |     |  [ mt7570.c ]    |     |
|  +------------------+     +------------------+     +------------------+     |
|                                                                             |
|  +------------------+                                                       |
|  |   I2C Interface  | (Communication with optical modules/BOSA)             |
|  |    [ i2c.c ]     |                                                       |
|  +------------------+                                                       |
+-----------------------------------------------------------------------------+
┌─────────────────────────────────────────┐
│   Application (userspace)               │
└─────────────────────────────────────────┘
              ↓ syscalls
┌─────────────────────────────────────────┐
│   Kernel Network Stack (net_device)     │
└─────────────────────────────────────────┘
              ↓ phymodecconfig(), phytxburstconfig()
┌─────────────────────────────────────────┐
│   PHY Driver (phy.c, phy_init.c)        │
│   - Interrupt management                │
│   - GPON/EPON configuration             │
│   - Burst timing, FEC, etc.             │
└─────────────────────────────────────────┘
              ↓ IOSPHYREG/IOGPHYREG (MMIO)
┌─────────────────────────────────────────┐
│   PHY registers (MT7520/EN7521)         │
│   - SerDes (PHYCSRPHYSET*)              │
│   - MAC PON (PHYCSRGPON*)               │
│   - Timers/Burst Control                │
└─────────────────────────────────────────┘
              ↓ SERDES (serial data)
┌─────────────────────────────────────────┐
│   Optical Transceiver (MT7570/SFP)      │ ← Control via I2C phyI2Cread/write
│   - Laser driver                        │
│   - APD/TIA                             │
│   - DDMI (Digital Diagnostic)           │
└─────────────────────────────────────────┘
              ↓ ↑ optical signals Optical Fiber (1310nm/1490nm/1550nm)

4d76b59039/sdk/en7529/linux-4.4.115/arch/arm/boot/dts/en7523.dts (L406-L413)

4d76b59039/sdk/en7529/linux-4.4.115/arch/arm/boot/dts/en7523.dts (L391-L397)

- https://sirherobrine23.com.br/tplink_xx230v/gpl_tplink-xx230v/src/commit/4d76b590398d1e510a2a893f6fc4c69bfedb5768/sdk/en7529/linux-4.4.115/arch/arm/mach-econet/ecnt_xpon.c - https://sirherobrine23.com.br/tplink_xx230v/gpl_tplink-xx230v/src/commit/4d76b590398d1e510a2a893f6fc4c69bfedb5768/sdk/en7529/linux-4.4.115/arch/arm/mach-econet/ecnt_pon_phy.c ## en7512 based code or compatible - https://sirherobrine23.com.br/Openwrt-EcoNet/TP-Link_XR500v_v2-6/src/commit/aea3a43562e8d3dc0335624202fde08d713a18c2/tclinux_phoenix/modules/private/xpon_phy - https://sirherobrine23.com.br/Openwrt-EcoNet/TP-Link_XR500v_v2-6/src/commit/aea3a43562e8d3dc0335624202fde08d713a18c2/tclinux_phoenix/modules/private/xpon ### Notes It appears that configuration communication is via `I2C`, as well as with `MMIO` together with serders to the new `airoha_eth` drive ``` +-----------------------------------------------------------------------------+ | USER SPACE / OPERATING SYSTEM | | ('ioctl' commands, Config Manager, OMCI Apps, Network Interface) | +--------------------------------------+--------------------------------------+ | v +-----------------------------------------------------------------------------+ | MAIN DRIVER (XPON DRV) | | Location: private/xpon/src/xpondrv.c | +-----------------------------------------------------------------------------+ | | | [ xpondrv.c ] <------- Main Brain (Kernel Module Entry Point) | | | | | +--- [ xpon_daemon.c ] (Background event and state monitor) | | | | | +--- [ pwan/xpon_netif.c ] (Creates network interfaces: nasX, ethX) | | | +--------------------------------------+--------------------------------------+ | v +-----------------------------------------------------------------------------+ | MAC ABSTRACTION LAYER (XMCS Interface) | | Location: private/xpon/src/xmcs/ | +-----------------------------------------------------------------------------+ | [ xmcs_if.c ] (The "Switch" deciding who operates: GPON or EPON) | | [ xmcs_mci.c ] (Management Control Interface) | +------------------+-------------------+--------------------------------------+ | | (If GPON mode active) (If EPON mode active) v v +-------------------------+ +-------------------------+ | GPON STACK | | EPON STACK | | (private/xpon/src/gpon) | | (private/xpon/src/epon) | +-------------------------+ +-------------------------+ | [ gpon.c ] (Core) | | [ epon_main.c ] (Core) | | | | | | - ONU Mgmt (PLOAM): | | - MAC Control (MPCP): | | [ gpon_ploam.c ] | | [ epon_mpcp.c ] | | | | | | - Configuration (OMCI): | | - Hardware IO: | | [ gpon_omcis.c ] | | [ epon_ioctl.c ] | | | | | | - GPON Hardware: | | - Utilities: | | [ gpon_dev.c ] | | [ epon_util.c ] | +-------------------------+ +-------------------------+ | | +---------+---------+ | v +-----------------------------------------------------------------------------+ | MAC PHYSICAL INTERFACE (XMCS PHY) | | Location: private/xpon/src/xmcs/xmcs_phy.c | | (Abstracts communication between MAC logic and real PHY driver) | +-----------------------------------------------------------------------------+ | v +-----------------------------------------------------------------------------+ | PHYSICAL LAYER CONTROLLER (PHY) | | Location: private/xpon_phy/src/ | +-----------------------------------------------------------------------------+ | [ phy.c ] (Central control logic for optical PHY) | | [ phy_init.c ] (Initialization and calibration of lasers/sensors) | | | | HARDWARE SUB-MODULES: | | +------------------+ +------------------+ +------------------+ | | | Transmission | | Reception | | Chipset | | | | [ phy_tx.c ] | | [ phy_rx.c ] | | [ mt7570.c ] | | | +------------------+ +------------------+ +------------------+ | | | | +------------------+ | | | I2C Interface | (Communication with optical modules/BOSA) | | | [ i2c.c ] | | | +------------------+ | +-----------------------------------------------------------------------------+ ``` ```txt ┌─────────────────────────────────────────┐ │ Application (userspace) │ └─────────────────────────────────────────┘ ↓ syscalls ┌─────────────────────────────────────────┐ │ Kernel Network Stack (net_device) │ └─────────────────────────────────────────┘ ↓ phymodecconfig(), phytxburstconfig() ┌─────────────────────────────────────────┐ │ PHY Driver (phy.c, phy_init.c) │ │ - Interrupt management │ │ - GPON/EPON configuration │ │ - Burst timing, FEC, etc. │ └─────────────────────────────────────────┘ ↓ IOSPHYREG/IOGPHYREG (MMIO) ┌─────────────────────────────────────────┐ │ PHY registers (MT7520/EN7521) │ │ - SerDes (PHYCSRPHYSET*) │ │ - MAC PON (PHYCSRGPON*) │ │ - Timers/Burst Control │ └─────────────────────────────────────────┘ ↓ SERDES (serial data) ┌─────────────────────────────────────────┐ │ Optical Transceiver (MT7570/SFP) │ ← Control via I2C phyI2Cread/write │ - Laser driver │ │ - APD/TIA │ │ - DDMI (Digital Diagnostic) │ └─────────────────────────────────────────┘ ↓ ↑ optical signals Optical Fiber (1310nm/1490nm/1550nm) ``` --- https://sirherobrine23.com.br/tplink_xx230v/gpl_tplink-xx230v/src/commit/4d76b590398d1e510a2a893f6fc4c69bfedb5768/sdk/en7529/linux-4.4.115/arch/arm/boot/dts/en7523.dts#L406-L413 https://sirherobrine23.com.br/tplink_xx230v/gpl_tplink-xx230v/src/commit/4d76b590398d1e510a2a893f6fc4c69bfedb5768/sdk/en7529/linux-4.4.115/arch/arm/boot/dts/en7523.dts#L391-L397
Sirherobrine23 added the
Status
Blocked
1
Priority
Low
4
labels 2025-11-13 00:49:00 +00:00
Sirherobrine23 added a new dependency 2025-11-13 00:49:12 +00:00
Owner

Yeah, that is pretty much correct. One thing missing is a huge user space part called OMCI. It is for management and for xPON data path setup.

Yeah, that is pretty much correct. One thing missing is a huge user space part called OMCI. It is for management and for xPON data path setup.
Author
Owner

I'm going to gather the XPON code into a repository here within this project, many things are similar, and it seems we have an OMCI daemon within the private code

I'm going to gather the XPON code into a repository here within this project, many things are similar, and it seems we have an OMCI daemon within the private code
Author
Owner
OMCI: - https://sirherobrine23.com.br/tplink_xx230v/xpon/src/branch/main/apps/xpon/src/omci - https://sirherobrine23.com.br/tplink_xx230v/xpon/src/branch/main/apps/xpon/inc/omci
Sirherobrine23 changed title from XPON Support to XPON 2025-11-22 00:33:22 +00:00
Author
Owner

GPON and EPON will have to be built from scratch; some things will have to be done entirely from scratch, in addition to modernizing a good part of what's already there. Furthermore, we'll have to implement the GPON base in the kernel. I haven't found much related information, and from what I've seen, a lot of GPON-related code will have to be written. EPON might be simpler to implement. I don't understand much about networking, but that will come too late. Some ideas I'm having are using NetLink Generic to configure OAM, OMCI/PLOAM, and a generic abstraction for PON devices. I wish I could do this now, but it seems like it will be more work than anything else

GPON and EPON will have to be built from scratch; some things will have to be done entirely from scratch, in addition to modernizing a good part of what's already there. Furthermore, we'll have to implement the GPON base in the kernel. I haven't found much related information, and from what I've seen, a lot of GPON-related code will have to be written. EPON might be simpler to implement. I don't understand much about networking, but that will come too late. Some ideas I'm having are using NetLink Generic to configure OAM, OMCI/PLOAM, and a generic abstraction for PON devices. I wish I could do this now, but it seems like it will be more work than anything else
Member

Hi,

I found this issue because I'm starting to investigate the possibility to port the TP-Link XX530v v1 to OpenWrt and found some information that may be useful to you in this case.

For some reason TP-Link released some of the preprocessed files of the EN7571 xpon driver:

0932f2c9b3/sdk/en7529/linux-4.4.115/en7571.i
0932f2c9b3/sdk/en7529/linux-4.4.115/mt7570.i

It appears that in some cases the en7571 file uses the mt7570 API (function get_flash_matrix, for example) and in other cases a function was duplicated and is identical, like the functions mt7570_LOS_init and en7571_LOS_init.

Feel free to ignore this message if it does not make sense because despite having some years of experience on C and C++ I'm only now learning about kernel development.

Thanks.

Hi, I found this issue because I'm starting to investigate the possibility to port the TP-Link XX530v v1 to OpenWrt and found some information that may be useful to you in this case. For some reason TP-Link released some of the preprocessed files of the EN7571 xpon driver: https://sirherobrine23.com.br/tplink_gpl/tplink-xx530v_v1/src/commit/0932f2c9b3e2f753d161f147e60fc59c0866a9ee/sdk/en7529/linux-4.4.115/en7571.i https://sirherobrine23.com.br/tplink_gpl/tplink-xx530v_v1/src/commit/0932f2c9b3e2f753d161f147e60fc59c0866a9ee/sdk/en7529/linux-4.4.115/mt7570.i It appears that in some cases the en7571 file uses the mt7570 API (function `get_flash_matrix`, for example) and in other cases a function was duplicated and is identical, like the functions `mt7570_LOS_init` and `en7571_LOS_init`. Feel free to ignore this message if it does not make sense because despite having some years of experience on C and C++ I'm only now learning about kernel development. Thanks.
Author
Owner

@raphaelgz Hello, welcome!

The xx530v v1 is very similar to the xx230v v1, so porting it shouldn't be much of a problem. It seems to only change the wireless chips. I was going to buy one to add to OpenWRT. It's also my first time with the Linux kernel, but it's not far from any C program. For now, we have little support for the en7529, and merbanan managed to get the Ethernet working now, but we still have some problems. Feel free to contribute to this internal project, and update your profile based on your GitHub if you have one. If you have any changes you want to upload, just ask me for permission.

@raphaelgz Hello, welcome! The xx530v v1 is very similar to the xx230v v1, so porting it shouldn't be much of a problem. It seems to only change the wireless chips. I was going to buy one to add to OpenWRT. It's also my first time with the Linux kernel, but it's not far from any C program. For now, we have little support for the en7529, and merbanan managed to get the Ethernet working now, but we still have some problems. Feel free to contribute to this internal project, and update your profile based on your GitHub if you have one. If you have any changes you want to upload, just ask me for permission.
Author
Owner

Merbanan sent some changes yesterday and I merged them today. Now I'll be working with the server for the EN7529. I'm currently comparing some things from the EN7581 to see how it was ported to the mainline. A lot of things from the EN7581 are compatible with the EN7529. Any testing of new features can be useful if you first test with the EN7581 drivers before creating one for the EN7523

Merbanan sent some changes yesterday and I merged them today. Now I'll be working with the server for the EN7529. I'm currently comparing some things from the EN7581 to see how it was ported to the mainline. A lot of things from the EN7581 are compatible with the EN7529. Any testing of new features can be useful if you first test with the EN7581 drivers before creating one for the EN7523
Author
Owner

0932f2c9b3/sdk/en7529/linux-4.4.115/en7571.i
0932f2c9b3/sdk/en7529/linux-4.4.115/mt7570.i

It appears that in some cases the en7571 file uses the mt7570 API (function get_flash_matrix, for example) and in other cases a function was duplicated and is identical, like the functions mt7570_LOS_init and en7571_LOS_init.

In terms of code, as you said, they are identical, but with adaptations for the EN7571 for calibration and other things. I'm still thinking about many things for the PON on Linux; much of it will be based on these drivers: aea3a43562/tclinux_phoenix/modules/private

drive diff
--- en7571.i    2025-09-08 12:59:24.171475284 -0300
+++ mt7570.i    2025-09-08 12:59:24.898477566 -0300
@@ -1,4 +1,4 @@
-# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
+# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
 # 1 "<built-in>"
 # 1 "<command-line>"
 # 1 "././include/linux/kconfig.h" 1
@@ -8,7 +8,7 @@
 # 1 "include/generated/autoconf.h" 1
 # 5 "././include/linux/kconfig.h" 2
 # 1 "<command-line>" 2
-# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
+# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
 # 1 "include/linux/kernel.h" 1
 
 
@@ -2342,7 +2342,7 @@
  return 0;
 }
 static inline __attribute__((always_inline)) __attribute__((no_instrument_function)) void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
-# 2 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 2 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "include/linux/slab.h" 1
 # 14 "include/linux/slab.h"
 # 1 "include/linux/gfp.h" 1
@@ -11132,7 +11132,7 @@
 
 unsigned int kmem_cache_size(struct kmem_cache *s);
 void __attribute__ ((__section__(".init.text"))) __attribute__((__cold__)) __attribute__((no_instrument_function)) kmem_cache_init_late(void);
-# 3 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 3 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "include/linux/delay.h" 1
 # 12 "include/linux/delay.h"
 extern unsigned long loops_per_jiffy;
@@ -11188,7 +11188,7 @@
 {
  msleep(seconds * 1000);
 }
-# 4 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 4 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 
 # 1 "include/linux/proc_fs.h" 1
 
@@ -16353,7 +16353,7 @@
 {
  return proc_mkdir_data(name, 0, parent, net);
 }
-# 6 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 6 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "include/linux/module.h" 1
 # 13 "include/linux/module.h"
 # 1 "include/linux/kmod.h" 1
@@ -18384,9 +18384,7 @@
 {
  return true;
 }
-# 7 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
-
-
+# 7 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 
 
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/i2c.h" 1
@@ -18397,7 +18395,7 @@
 uint ioReadPhyReg32(ushort phyReg) ;
 int ioWritePhyReg32(ushort phyReg, uint value) ;
 int ioWritePhyReg8(ushort phyReg, unchar value) ;
-# 12 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 10 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_def.h" 1
 
 
@@ -22230,11 +22228,11 @@
  ushort tx_power_high_alarm_thod;
  ushort tx_power_low_alarm_thod;
 }PHY_TransAlarm_T, *PPHY_TransAlarm_T;
-# 13 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
-# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/en7571_reg.h" 1
-# 14 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
-# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/en7571_def.h" 1
-# 15 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 11 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
+# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/mt7570_reg.h" 1
+# 12 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
+# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/mt7570_def.h" 1
+# 13 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_global.h" 1
 
 
@@ -47935,7 +47933,7 @@
 
 
 extern PHY_GlbPriv_T *gpPhyPriv ;
-# 16 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 14 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_api.h" 1
 
 
@@ -48108,114 +48106,9 @@
 void Ibias_temperature_set(void);
 void mt7570_param_status_real(PPHY_TransParam_T transceiver_param);
 void phy_trans_param_status_real(PPHY_TransParam_T transceiver_param);
-# 17 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
-# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/en7571_api.h" 1
-
-
-
-
-int en7571_init(void);
-int en7571_ADC_temperature_get(void);
-int en7571_ADC_voltage_get(void);
-int en7571_EN7571_detection(void);
-int en7571_LOS_calibration(int LOS_thld_H, int LOS_thld_L);
-int en7571_Ibias_hysteresis(int Ibias_target , int pav_delta);
-int en7571_Imod_hysteresis(int Imod_now,int Imod_target);
-int en7571_Ibias_transfer(int Iav_target);
-int en7571_RogueONU_status(void);
-
-UINT16 en7571_temperature_get_8472(void);
-UINT16 en7571_supply_voltage_get_8472(void);
-UINT16 en7571_bias_current_get_8472(void);
-UINT16 en7571_TxPower_get_8472(void);
-UINT16 en7571_RxPower_get_8472(void);
-
-UINT32 en7571_info(uint select);
-UINT32 en7571_SVADC_get(void);
-UINT32 en7571_PWRADC_get(void);
-UINT32 en7571_RSSI_get(void);
-UINT32 en7571_dark_current(void);
-
-void en7571_TGEN(int xPON);
-void en7571_TxSD_level_set(void);
-void en7571_LOS_level_set(void);
-void en7571_ADC_calibration(void);
-void en7571_APD_initialization(void);
-void en7571_APD_control(void);
-void en7571_APD_DAC(UINT8 DAC);
-void en7571_load_Tx_cal_data(void);
-void en7571_RogueONU_clear(void);
-void en7571_safe_circuit_reset(void);
-void en7571_trans_model_setting(void);
-void en7571_tx_power_alarm_get(void);
-void en7571_rx_power_alarm_get(void);
-void en7571_PWRADC_calibration(void);
-void en7571_PWRADC_enable(void);
-void en7571_RSSI_calibration(void);
-void en7571_xPON_Tx_calibration(int input);
-void en7571_save_flash_APD(uint slope_up, uint slope_dn, uint VAPD25);
-void en7571_save_flash_LOS(void);
-void en7571_save_flash_DDMI_TxPower(uint TxPower, uint offset);
-void en7571_save_flash_DDMI_RxPower(uint RxPower, uint offset);
-void en7571_save_flash_Tx_data(void);
-void en7571_save_flash_EnvTemp(int temperature_input);
-void en7571_APD_I2C_write(unchar ptr[1]);
-void en7571_DDMI_check_8472(void);
-void en7571_BoB_info(void);
-void en7571_temperature_get(void);
-void en7571_calibration_pattern(int input);
-void en7571_disable_pattern(void);
-void en7571_CDR(int CDR_switch);
-void en7571_internal_clock(void);
-void en7571_HWKT(int input);
-void en7571_hw_reset(void);
-void en7571_reg_init(void);
-void en7571_mpdh_stepsize(int input);
-void en7571_T1delay_setting(int input);
-void en7571_7571_enable(void);
-void en7571_DCL_start(void);
-void en7571_DCL_stop(void);
-void en7571_sysotms(void);
-void en7571_cal_Iav_Imod(UINT32 Iav_mod_k, int I);
-void en7571_cal_Pav_P1(UINT32 Pav_P1_k, int P);
-void en7571_cal_force_mode(void);
-void en7571_sw_reset(void);
-void en7571_RSSI_gain_init(void);
-void en7571_LOS_init(void);
-void en7571_fine_tune_PWR_ER(int pwr_er,int up_dn);
-void en7571_SWKT(void);
-void en7571_OPKT(void);
-void en7571_change_Imod(UINT32 input);
-void en7571_change_Ibias(UINT32 input);
-void en7571_change_mpdh(UINT32 input);
-void en7571_cross_Imod(UINT32 input);
-void en7571_cross_Ibias(UINT32 input);
-void en7571_VBR_find(int High , int Low);
-void en7571_LOS_find(int LOS_find);
-void en7571_eFuse_temperature_get(void);
-void en7571_force_mode(void);
-void en7571_auto_lock_mode(void);
-void en7571_tune_KT(UINT16 input);
-void en7571_config(void);
-void en7571_link_reg(int input);
-void en7571_burst_ctrl(int input);
-void en7571_LUT_Tracking(void);
-void en7571_LUT_recover(void);
-void en7571_show_LUT(void);
-void en7571_SingleClosedLoopMode(void);
-void en7571_OpenLoopMode(int input);
-void MBI(int a, int b);
-void en7571_get_linkup_infor(void);
-void en7571_Pavg_close_loop(void);
-void en7571_islinkstauschange(void);
-void en7571_closeloop_reset(void);
-void en7571_Iavg_transfer(void);
-void en7571_WatchDog(void);
-void en7571_tuneBiasModCurrent(UINT16 bias, UINT16 mod);
-void en7571_param_status_real(PPHY_TransParam_T transceiver_param);
-# 18 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 15 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_types.h" 1
-# 19 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 16 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_debug.h" 1
 
 
@@ -48230,9 +48123,9 @@
  PHY_MSG_TRACE = 0x0008,
  PHY_MSG_DBG = 0x0010
 } xPON_PHY_DebugMsg_t ;
-# 20 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 17 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy.h" 1
-# 21 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 18 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_init.h" 1
 
 
@@ -48266,102 +48159,81 @@
 }
 
 extern struct workqueue_struct * i2c_access_queue;
-# 22 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
+# 19 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_tx.h" 1
 # 47 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_tx.h"
 int phy_gpon_preamble(PPHY_GponPreb_T pon_preb);
 int phy_tx_fec_status(void);
 void mt7570_safe_circuit_reset_for_work_queue(struct work_struct * worker);
 void en7571_safe_circuit_reset_for_work_queue(struct work_struct * worker);
-# 23 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2
-
-
-extern atomic_t i2c_protect;
-extern unsigned int en7571_delay1;
-extern unsigned int en7571_delay2;
-
-int en7571_version = 11;
-int en7571_internal_DDMI = 1;
-int en7571_fast_DDMI = 0;
-int en7571_xPON_mode = -1;
-int en7571_select = 0;
-int en7571_RSSI_Vref = 0;
-int en7571_RSSI_V = 0;
-int en7571_PatternEnabled = 0;
-int en7571_DDMI_rx_cal_flag = 0;
-int en7571_ERC = 0;
-int en7571_SCL = 0;
-int en7571_DOL = 0;
-int en7571_KT = 0;
-int en7571_Pav_loop = 0;
-int en7571_ver = -1;
-int en7571_sys_mode = 1;
-int en7571_cross = 1;
-int en7571_cross_cnt_Imod = 0;
-int en7571_cross_cnt_Ibias = 0;
-
-int Iav_linkup_now = 0;
-int Imod_linkup_now = 0;
-int Ibias_linkup_now = 0;
-int need_crossing_Ibias = 0;
-int need_crossing_Imod = 0;
-
-int en7571_delay_1 = 0;
-int en7571_delay_2 = 0;
-
-float en7571_IC_temperature = 25.0;
-float en7571_BOSA_temperature = 20.0;
-float en7571_Env_temperature = 25.0 ;
-float en7571_APD_voltage = 35.0;
-float en7571_ADC_slope = 0;
-float en7571_ADC_offset = 0;
-float en7571_eFuse_temperature_offset = 0 ;
-
-UINT16 en7571_DDMI_voltage = 0;
-UINT16 en7571_DDMI_current = 0;
-UINT16 en7571_DDMI_temperature = 0;
-UINT16 en7571_DDMI_tx_power = 0;
-UINT16 en7571_DDMI_rx_power = 0;
-
-UINT32 en7571_temperature_ADC = 0;
-UINT32 en7571_voltage_ADC = 0;
-UINT32 en7571_RSSI_current = 0;
-UINT32 en7571_PWRADC = 0;
-UINT32 en7571_PWRADC_offset = 0;
-UINT32 en7571_Tapd = 60;
-UINT32 en7571_alarm = 0;
-UINT32 en7571_flash_matrix[100];
-# 100 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-static unsigned long en7571_irq_flag = 0;
-
-void mbi_ctrl_set(u32 ctrl_val)
-{
- u32 mbi_ctrl_reg = 0;
- u32 mbi_ctrl = 0;
-
- u32 wan_cfg = GET_WAN_CONF();
-
-
-
-    mbi_ctrl_reg = (1 == (wan_cfg&0x03)) ? 0x6000 : 0x4160;
- mbi_ctrl = get_xpon_data(mbi_ctrl_reg);
- if(0 == ctrl_val){
-  mbi_ctrl |= (1 << 8);
-  do { do { ({ unsigned long __dummy; typeof(en7571_irq_flag) __dummy2; (void)(&__dummy == &__dummy2); 1; }); en7571_irq_flag = arch_local_irq_save(); } while (0); } while (0);
-  set_xpon_data(mbi_ctrl_reg, mbi_ctrl);
- }else{
-  mbi_ctrl &= ~(1 << 8);
-  set_xpon_data(mbi_ctrl_reg, mbi_ctrl);
-  do { do { ({ unsigned long __dummy; typeof(en7571_irq_flag) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_local_irq_restore(en7571_irq_flag); } while (0); } while (0);
- }
- set_xpon_data(mbi_ctrl_reg, mbi_ctrl);
-}
-
+# 20 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2
 
+int mt7570_version = 110;
 
+int internal_DDMI = 1;
+int fast_DDMI = 0;
+int TEC = 1;
+int TEC_switch = 0;
+int xPON_mode = -1;
+int mt7570_select = 0;
+int vEN7570 = 1;
+int BG1V76 = 0;
+int BG0V875 = 0;
+int RSSI_Vref = 0;
+int RSSI_V = 0;
+int ETC = 0;
+int FiberPlug = 0;
+int PatternEnabled = 0;
+
+float RSSI_factor = 0;
+int delay_cnt = 0;
+uint cnt7570 = 0;
+int MPD_current_cnt = 0;
+int T0C_extension = 0;
+float IC_temperature = 25.0;
+float BOSA_temperature = 20.0;
+float Env_temperature = 25.0;
+float APD_voltage = 35.0;
+float ADC_slope = 0;
+float ADC_offset = 0;
+
+int global_temperature_code = 0;
+int global_vcc_code = 0;
+
+uint global_bias_current = 0;
+uint global_MPDL = 0;
+uint global_MPDH = 0;
+uint global_modulation_current = 0;
+
+int global_rssi_current = 0;
+int global_mpd_current = 0;
+int global_RSSI_current = 0;
+int global_MPD_current = 0;
+int global_MPD_current_var = 0;
+int global_DDMI_rx_cal_flag =0;
+
+UINT16 global_supply_voltage_8472 = 0;
+UINT16 global_IC_temperature_8472 = 0;
+UINT16 global_bias_current_8472 = 0;
+UINT16 DDMI_voltage = 0;
+UINT16 DDMI_current = 0;
+UINT16 DDMI_temperature = 0;
+UINT16 DDMI_tx_power = 0;
+UINT16 DDMI_rx_power = 0;
+
+int Ibias_outputlow_flag = 0;
+int BER_result = 0 ;
+
+uint MPD_current_offset = 0;
+uint T_APD = 600;
+uint flash_matrix[100];
+uint mt7570_alarm = 0;
+uint SCL =0 ;
+uint DOL =0 ;
+uint BiasTracking_switch = 0;
+uint BOSA_Ith = 3000;
 
-
-uint en7571_LUT_Ibias_Imod[64][2] =
+uint LUT_Ibias_Imod[64][2] =
 {
 
  {0x106, 0x3b2},
@@ -48429,8 +48301,119 @@
  {0x666, 0x6ce},
  {0x666, 0x6ce}
 };
-# 207 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_save_flash_APD(uint slope_up, uint slope_dn, uint VAPD)
+
+
+
+
+
+atomic_t i2c_protect = { (0) };
+
+int
+i2c_access_protect(void){
+
+ int count = 10000;
+ while(({ union { typeof((&i2c_protect)->counter) __val; char __c[1]; } __u; if (1) __read_once_size(&((&i2c_protect)->counter), __u.__c, sizeof((&i2c_protect)->counter)); else __read_once_size_nocheck(&((&i2c_protect)->counter), __u.__c, sizeof((&i2c_protect)->counter)); __u.__val; }) == 1 ){
+  (__builtin_constant_p(1) ? ((1) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1));
+  if(count==0) return -1;
+  count --;
+ }
+ return 0;
+}
+# 185 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_register_dump(int length)
+{
+ int i = 0;
+ unchar ptr[4];
+ uint return_value = 0;
+ for(i = 0 ; i < length ; i++)
+ {
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (i<<2), ptr, 4);
+  return_value = ptr[0] | (ptr[1]<<8) | (ptr[2]<<16) | (ptr[3]<<24);
+  printk("EN7570 reg 0x%.3x", i*4);
+  printk("\t%.8x\n", return_value);
+ }
+}
+# 211 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int get_flash_register(int address_offset)
+{
+ uint return_int = 0;
+ return_int = flash_matrix[(address_offset>>2)];
+ return return_int;
+}
+# 229 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int get_flash_matrix(void)
+{
+
+ struct file *srcf = ((void *)0);
+ char *src = ((void *)0);
+ mm_segment_t orgfs;
+
+
+
+ src = "/tmp/7570_bob.conf";
+
+
+ orgfs = (current_thread_info()->addr_limit);
+ set_fs(0x00000000);
+
+  if (src && *src)
+  {
+   srcf = filp_open(src, 00000000, 0);
+   if (IS_ERR(srcf))
+   {
+    printk("--> Error opening \n");
+    goto error;
+   }
+   else
+   {
+
+    ecnt_kernel_fs_read(srcf, flash_matrix, sizeof(flash_matrix),&srcf->f_pos);
+    filp_close(srcf,((void *)0));
+   }
+  }
+  set_fs(orgfs);
+  return 0;
+
+error:
+  set_fs(orgfs);
+  return -1;
+
+}
+# 279 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register(uint reg, uint offset)
+{
+ flash_matrix[offset>>2] = reg;
+}
+# 295 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_default(void)
+{
+ int index = 0;
+ for(index = 0; index < 40; index++)
+   flash_matrix[index] = 0xffffffff;
+
+}
+# 314 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_BiasModCurrent(void)
+{
+ uint ibias = mt7570_information_output(0x03);
+ uint imod = mt7570_information_output(0x04 );
+ set_flash_register(ibias, (0x000));
+ set_flash_register(imod , (0x004) );
+ printk("Ibias = 0x%x\n", ibias);
+ printk("Imod = 0x%x\n" , imod );
+}
+# 335 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_P0P1(void)
+{
+ uint p0 = mt7570_information_output(0x05);
+ uint p1 = mt7570_information_output(0x06);
+ set_flash_register(p0, (0x008));
+ set_flash_register(p1, (0x00c));
+ printk("P0 = 0x%x\n", p0);
+ printk("P1 = 0x%x\n", p1);
+}
+# 356 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_APD(uint slope_up, uint slope_dn, uint VAPD)
 {
  set_flash_register(slope_up, (0x010));
  set_flash_register(slope_dn, (0x014));
@@ -48439,730 +48422,708 @@
  printk("slope down = 0x%x\n", slope_dn);
  printk("VAPD@25C = 0x%x\n" , VAPD );
 }
-# 224 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_save_flash_LOS(void)
+# 377 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_LOS(void)
 {
  unchar ptr[4];
- uint temp = 0;
-
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
  ptr[3] = ptr[3] & 0x7f;
  ptr[2] = ptr[2] & 0x7f;
- printk("LOS threshold = 0x%x\n", ptr[3]);
- printk("SD threshold = 0x%x\n", ptr[2]);
- temp = (ptr[2]<<16) | ptr[3];
- set_flash_register(temp, (0x020));
+ set_flash_register(ptr[3], (0x024));
+ set_flash_register(ptr[2], (0x020));
+ printk("LOS low = 0x%x\n", ptr[3]);
+ printk("LOS high = 0x%x\n", ptr[2]);
 }
-# 247 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_save_flash_DDMI_TxPower(uint TxPower, uint offset)
+# 400 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_DDMI_TxPower(uint TxPower, uint offset)
 {
  uint input = 0;
- input = ( (TxPower<<16)&0xffff0000 ) | (en7571_PWRADC_get()&0x0000ffff);
+ input = ( (TxPower<<16)&0xffff0000 ) | (mt7570_MPD_current()&0x0000ffff);
  set_flash_register(input, offset);
 
+ if( vEN7570==0 && offset==(0x040) )
+  set_flash_register(input&0x0000ffff, (0x088));
+
  printk("0x%08x\n", input);
 }
-# 265 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_save_flash_DDMI_RxPower(uint RxPower, uint offset)
+# 423 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_DDMI_RxPower(uint RxPower, uint offset)
 {
  uint input = 0;
- input = ( (RxPower<<16)&0xffff0000 ) | (en7571_RSSI_get()&0x0000ffff);
+ input = ( (RxPower<<16)&0xffff0000 ) | (mt7570_RSSI_current()&0x0000ffff);
  set_flash_register(input, offset);
  printk("0x%08x\n", input);
- en7571_DDMI_rx_cal_flag = 0;
+ global_DDMI_rx_cal_flag = 0;
 
 }
-# 282 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_save_flash_Tx_data(void)
+# 444 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_TIAGAIN(void)
 {
- unchar ptr[4];
- UINT32 imod = 0;
- UINT32 iav = 0;
- UINT32 write_data = 0;
- UINT32 pav = 0;
- UINT32 p1 = 0;
-
- if( get_flash_register((0x008)) != 0xffffffff )
- {
-  set_flash_register( 0x2, (0x090));
-  printk("Open loop saved\n");
-  return;
- }
-
-
- imod = en7571_info(0x04 );
- iav = en7571_info(0x02);
- printk("Ibias = 0x%x\n", en7571_info(0x03));
- printk("Imod = 0x%x\n" , imod );
- printk("Iav = 0x%x\n" , iav );
- write_data = (iav<<16) | imod;
- set_flash_register( write_data, (0x000));
-
- write_data = 0;
-
-
- p1 = en7571_info(0x06);
- pav = en7571_info(0x01);
- printk("P1 = 0x%x\n" , p1 );
- printk("Pav = 0x%x\n" , pav );
- write_data = (pav<<16) | p1;
- set_flash_register(write_data, (0x004));
-
- write_data = 0;
-
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4);
- ptr[1] = (ptr[1] & 0x7f);
- ptr[2] = (ptr[2] & 0x7f);
- printk("T0C = 0x%x\nT1C = 0x%x\n", ptr[2], ptr[1]);
- write_data = ( (ptr[1]<<8) | ptr[2] ) << 16;
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4);
- printk("T0/T1 delay = 0x%x\n", ptr[0]);
- write_data = write_data | (ptr[0]&0x000000ff);
- set_flash_register( write_data, (0x00c));
-
+ unchar ptr[1];
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000)+0x0001 , ptr, 1);
+ ptr[0] = ptr[0] >> 6;
+ set_flash_register(ptr[0], (0x028));
+ printk("TIAGAIN = 0x%x\n", ptr[0]);
 }
-# 340 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_save_flash_EnvTemp(int temperature_input)
+# 466 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_EnvTemp(int temperature_input)
 {
  uint write_data = 0;
  int Env_temperature_offset = 0;
 
 
- set_flash_register(temperature_input, (0x08c));
+ set_flash_register(temperature_input, (0x060));
  printk("Env_temperature = %d.%.1dC\n", temperature_input/10, temperature_input%10);
 
 
- en7571_temperature_get();
+ mt7570_temperature_get();
 
 
- Env_temperature_offset = en7571_IC_temperature*10 - temperature_input;
+ Env_temperature_offset = IC_temperature*10 - temperature_input;
  if( Env_temperature_offset < 0 )
   printk("Not thermal balance\n");
  else
  {
   printk("Env_temperature_offset = %d.%.1dC\n", Env_temperature_offset/10, Env_temperature_offset%10);
 
-  write_data = (Env_temperature_offset << 16) | (get_flash_register((0x024)) & 0x0000ffff);
-  set_flash_register(write_data, (0x024));
+  write_data = (Env_temperature_offset << 16) | (get_flash_register((0x084)) & 0x0000ffff);
+  set_flash_register(write_data, (0x084));
  }
 }
-# 374 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_xPON_Tx_calibration(int input)
+# 504 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_temperature_offset(uint temperature_input, uint slope)
 {
 
- en7571_ERC = 0;
- en7571_KT = 0;
- en7571_SCL = 0;
- en7571_DOL = 0;
-
- en7571_DCL_stop();
-
+ uint tmp;
 
- phy_mode_config(input, (1));
 
+ if (temperature_input > 0x500)
+ {
+  printk ("Please input temperature value in range : 0 ~ 0x500\n");
+  return;
+ }
 
- set_flash_register(0xffffffff, (0x00c));
-
+ if (slope == 0)
+  slope = 0xffff;
+ else
+  printk("Temperature slope = 0x%x\n",slope);
 
- en7571_TGEN(input);
 
+ tmp = (slope << 16) | 0xffff;
+ set_flash_register(tmp, (0x080));
 
- en7571_reg_init();
+ mt7570_temperature_get();
 
+ tmp = temperature_input - IC_temperature*10 + 495.8*10;
+ printk("Temperature offset = 0x%x\n",tmp);
 
- en7571_calibration_pattern(input);
+ tmp = (tmp & 0x0000ffff) | (slope << 16) ;
+ set_flash_register(tmp, (0x080));
 
+}
+# 548 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_T0T1delay(void)
+{
+ unchar ptr[1];
 
- en7571_cal_force_mode();
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 1);
 
+ set_flash_register(ptr[0], (0x098));
+ printk("T0/T1 delay = 0x%x\n", ptr[0]);
 }
-# 414 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_calibration_pattern(int input)
+# 571 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_T0CT1C(void)
 {
- printk("en7571_calibration_pattern \n");
-
+ unchar ptr[4];
 
-    REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_START);
- ( (__builtin_constant_p(500) && (500)<=2) ? (__builtin_constant_p((500)*1000) ? (((500)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((500)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((500)*1000)) : ({unsigned long __ms=(500); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4);
+ ptr[1] = (ptr[1] & 0x7f);
+ ptr[2] = (ptr[2] & 0x7f);
 
+ set_flash_register( ( (ptr[1]<<16) | ptr[2] ), (0x09c));
+ printk("T0C = 0x%x\nT1C = 0x%x\n", ptr[2], ptr[1]);
+}
+# 596 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void set_flash_register_Tx_data(void)
+{
+ set_flash_register_BiasModCurrent();
+ set_flash_register_P0P1();
+ set_flash_register_TIAGAIN();
+ set_flash_register_T0T1delay();
+ set_flash_register_T0CT1C();
+}
+# 617 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int save_flash_matrix(void)
+{
+ struct file *srcf = ((void *)0);
+
+ char *src = ((void *)0);
+ mm_segment_t orgfs;
+
+ src = "/tmp/7570_bob.conf";
+ orgfs = (current_thread_info()->addr_limit);
+ set_fs(0x00000000);
+ if (src && *src)
+ {
+  srcf = filp_open(src, 00000002|00000100, 0);
+  if (IS_ERR(srcf))
+  {
+   printk("--> Error opening \n");
+   goto error;
+  }
+  else
+  {
+   srcf->f_pos = 0;
+   if(ecnt_kernel_fs_write(srcf, flash_matrix, sizeof(flash_matrix), &srcf->f_pos) >0)
+   {
+    printk("--> write flash_matrix success \n");
+   }
+   else
+   {
+    printk("--> Error write \n");
+    filp_close(srcf,((void *)0));
+    goto error;
+   }
 
- en7571_CDR(0);
+   filp_close(srcf,((void *)0));
+  }
+ }
+ set_fs(orgfs);
+ return 0;
 
- en7571_DCL_stop();
- en7571_link_reg(0);
- en7571_sysotms();
- en7571_DCL_start();
+ error:
+ set_fs(orgfs);
+ return -1;
 
- if( input == PHY_GPON_CONFIG )
+}
+# 674 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void flash_dump(void)
+{
+ int i = 0;
+ int j = 0;
+ for(i=0; i<40; i++)
  {
-
-  phy_ben_switch((1));
-
-  phy_tx_test_pattern(0x06);
-  phy_mode_config(PHY_GPON_CONFIG, (1));
-  printk("PRBS23 enabled\n");
+  j = 4*i;
+  printk("FLASH address 0x%x", j);
+  printk("\t");
+  printk("0x%08x\n", get_flash_register(j));
  }
- else if( input == 0xa7050701 )
- {
+}
+# 699 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void DOL_flash_dump(void)
+{
+ int i = 0;
+ int j = 0;
 
-  phy_ben_switch((1));
+ printk("FLASH");
+ printk("\t");
+ printk("temperature");
+ printk("\t");
+ printk("Value\n");
 
-  phy_tx_test_pattern(0x06);
-  phy_mode_config(0xa7050701, (1));
-  printk("PRBS23 enabled\n");
+ for(i=0; i<16; i++)
+ {
+  j = 0xa0+4*i;
+  printk("0x%x", j);
+  printk("\t");
+  printk("%d", -40+(10*i));
+  printk("\t");
+  printk("\t");
+  printk("0x%08x\n", get_flash_register(j));
  }
+}
+# 735 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void GPON_Tx_calibration(void)
+{
 
- else if( input == PHY_EPON_CONFIG )
- {
+ mt7570_ERC_filter();
 
-  phy_ben_switch((1));
 
+ mt7570_load_init_current();
 
-  phy_tx_test_pattern(0x05);
 
-  phy_mode_config(PHY_EPON_CONFIG, (1));
-  printk("PRBS7 enabled\n");
- }
+ phy_mode_config(PHY_GPON_CONFIG, (1));
 
 
- en7571_safe_circuit_reset();
+ mt7570_TGEN(PHY_GPON_CONFIG);
 
 
- en7571_RogueONU_clear();
+ mt7570_calibration_pattern(PHY_GPON_CONFIG);
 
- en7571_PatternEnabled = 1;
- en7571_tune_KT(0xFFFF);
-}
-# 478 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_disable_pattern(void)
-{
 
+ mt7570_safe_circuit_reset();
 
- phy_ben_switch((0));
+ phy_trans_power_switch((1));
 
+ printk("GPON_Tx_calibration done\n");
+}
+# 772 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void EPON_Tx_calibration(void)
+{
 
-  phy_tx_test_pattern(0x00);
+ mt7570_ERC_filter();
 
 
+ mt7570_load_init_current();
 
- en7571_CDR(1);
 
- en7571_DCL_stop();
- en7571_link_reg(1);
- en7571_sysotms();
- en7571_DCL_start();
+ phy_mode_config(PHY_EPON_CONFIG, (1));
 
 
-    REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_STOP);
+ mt7570_TGEN(PHY_EPON_CONFIG);
 
 
- en7571_safe_circuit_reset();
+ mt7570_calibration_pattern(PHY_EPON_CONFIG);
 
 
- en7571_RogueONU_clear();
+ mt7570_safe_circuit_reset();
 
- printk("Pattern disabled\n");
- en7571_PatternEnabled = 0;
+ printk("EPON_Tx_calibration done\n");
 }
-# 519 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_CDR(int CDR_switch)
+# 807 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int GPON_BER(int pattern)
 {
+ int read_data = 0;
 
+ mt7570_CDR(1);
 
- uint read_data = 0;
- if( CDR_switch == 0 )
- {
+    REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_START);
 
+ ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
+ phy_mode_config(PHY_GPON_CONFIG, (1));
+ ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
 
+ set_pon_phy_data(0xbfaf0400 +0x00a0, 0x0);
 
-  read_data = get_pon_phy_data((0x1faf0000 + 0x4620));
-  set_pon_phy_data((0x1faf0000 + 0x4620), (read_data | 0x100000));
+ switch(pattern)
+ {
+  case 5:
 
-  read_data = get_pon_phy_data((0x1faf0000 + 0x4614));
-  set_pon_phy_data((0x1faf0000 + 0x4614), (read_data | 0x4000000));
+   set_pon_phy_data(0xbfaf0200 +0x00a0, 0x81fd53);
 
+   set_pon_phy_data(0xbfaf0200 +0x00a4, 0xffffff);
 
+   set_pon_phy_data(0xbfaf0400 +0x00a0, 0x5);
 
-  printk("CDR disabled\n");
- }
- else if( CDR_switch == 1 )
- {
+   set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1);
+   break;
+  case 6:
 
+   set_pon_phy_data(0xbfaf0200 +0x00a0, 0x71fd53);
 
+   set_pon_phy_data(0xbfaf0200 +0x00a4, 0x7fffff);
 
+   set_pon_phy_data(0xbfaf0400 +0x00a0, 0x6);
 
+   set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1);
+   break;
+  case 7:
 
-  read_data = get_pon_phy_data((0x1faf0000 + 0x4614));
-  set_pon_phy_data((0x1faf0000 + 0x4614), (read_data & 0xFBFFFFFF));
+   set_pon_phy_data(0xbfaf0200 +0x00a0, 0xff1fd53);
 
+   set_pon_phy_data(0xbfaf0200 +0x00a4, 0x7ffffff);
 
+   set_pon_phy_data(0xbfaf0400 +0x00a0, 0x7);
 
-  printk("CDR enabled\n");
+   set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1);
+   break;
+  default:
+   break;
  }
+ ( (__builtin_constant_p(250) && (250)<=2) ? (__builtin_constant_p((250)*1000) ? (((250)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((250)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((250)*1000)) : ({unsigned long __ms=(250); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+
+ read_data = get_pon_phy_data(0xbfaf0200 +0x00c4);
+
+ if( read_data == 5 )
+  printk("Pattern Aligned\n");
+ else
+  printk("Aligned Failed\n");
+
+  printk("%x\n", read_data);
+
+ return read_data;
 }
-# 569 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-int en7571_init(void)
+# 884 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int EPON_BER(int pattern)
 {
-    i2c_access_queue = __alloc_workqueue_key(("%s"), (WQ_MEM_RECLAIM), (1), ((void *)0), ((void *)0), ("i2c_access_queue"));
- do { __init_work(((&gpPhyPriv->EN7570_reset)), 0); ((&gpPhyPriv->EN7570_reset))->data = (atomic_long_t) { (WORK_STRUCT_NO_POOL) }; INIT_LIST_HEAD(&((&gpPhyPriv->EN7570_reset))->entry); ((&gpPhyPriv->EN7570_reset))->func = ((en7571_safe_circuit_reset_for_work_queue)); } while (0);
+ int read_data = 0;
 
+ mt7570_CDR(1);
 
- if(get_flash_matrix() == 0)
-  printk("FLASH matrix got\n");
- else
-  set_flash_register_default();
+    REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_START);
 
+ ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
+ phy_mode_config(PHY_EPON_CONFIG, (1));
+ ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
- en7571_sw_reset();
 
+ set_pon_phy_data(0xbfaf0400 +0x00a0, 0x0);
 
- en7571_hw_reset();
+ switch(pattern)
+ {
+  case 5:
 
+   set_pon_phy_data(0xbfaf0200 +0x00a0, 0x81fd53);
 
- en7571_7571_enable();
+   set_pon_phy_data(0xbfaf0200 +0x00a4, 0xffffff);
 
+   set_pon_phy_data(0xbfaf0400 +0x00a0, 0x5);
 
- en7571_PWRADC_calibration();
+   set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1);
+   break;
+  case 6:
 
+   set_pon_phy_data(0xbfaf0200 +0x00a0, 0x71fd53);
 
- en7571_PWRADC_enable();
+   set_pon_phy_data(0xbfaf0200 +0x00a4, 0x7fffff);
 
+   set_pon_phy_data(0xbfaf0400 +0x00a0, 0x6);
 
- en7571_ADC_calibration();
+   set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1);
+   break;
+  case 7:
 
+   set_pon_phy_data(0xbfaf0200 +0x00a0, 0xff1fd53);
 
- en7571_RSSI_calibration();
+   set_pon_phy_data(0xbfaf0200 +0x00a4, 0x7ffffff);
 
+   set_pon_phy_data(0xbfaf0400 +0x00a0, 0x7);
 
- en7571_eFuse_temperature_get();
+   set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1);
+   break;
+  default:
+   break;
+ }
+ ( (__builtin_constant_p(250) && (250)<=2) ? (__builtin_constant_p((250)*1000) ? (((250)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((250)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((250)*1000)) : ({unsigned long __ms=(250); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
+ read_data = get_pon_phy_data(0xbfaf0200 +0x00c4);
 
- set_pon_phy_data((0xbfaf0100 +0x0038), 0x10f);
+ if( read_data == 5 )
+  printk("Pattern Aligned\n");
+ else
+  printk("Aligned Failed\n");
 
+ return read_data;
+}
+# 959 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_restart_ERC(void)
+{
+  unchar ptr[4];
 
- if( get_flash_register((0x094)) == 0x07050701 )
- {
-  printk("Start GPON Tx Calibration\n");
-  phy_mode_config(PHY_GPON_CONFIG, (1));
-  en7571_xPON_mode = PHY_GPON_CONFIG;
 
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4);
+  ptr[0] = ptr[0] & 0xfe;
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 );
 
-  en7571_TGEN(PHY_GPON_CONFIG);
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4);
+  ptr[0] = ptr[0] & 0xfe;
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4 );
 
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4);
+  ptr[0] = (ptr[0] & 0xfe) | (0x01);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 );
 
-  en7571_APD_initialization();
-  if( get_flash_register((0x01c)) != 0xffffffff )
-  {
-   en7571_Tapd = get_flash_register((0x01c));
-   if( en7571_Tapd < 10 )
-   {
-    printk("APD update period is too short, reset to 10s\n");
-    en7571_Tapd=10;
-   }
-  }
-  en7571_APD_control();
- }
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4);
+  ptr[0] = (ptr[0] & 0xfe) | (0x01);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4 );
 
- else if( get_flash_register((0x094)) == 0xe7050701 )
- {
-  printk("Start EPON Tx Calibration\n");
-  phy_mode_config(PHY_EPON_CONFIG, (1));
-  en7571_xPON_mode = PHY_EPON_CONFIG;
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "ERC restarted\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 980) ; };
+}
+# 997 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_calibration_pattern(int input)
+{
 
+    REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_START);
 
-  en7571_TGEN(PHY_EPON_CONFIG);
 
- }
+ mt7570_CDR(0);
 
- else if( get_flash_register((0x094)) == 0xa7050701 )
+ if( input == PHY_GPON_CONFIG )
  {
-  printk("Start xPON Tx Calibration\n");
-  phy_mode_config(PHY_GPON_CONFIG, (1));
-  en7571_xPON_mode = PHY_GPON_CONFIG;
-
 
-  en7571_TGEN(0xa7050701);
 
+  phy_ben_switch((1));
 
-  en7571_APD_initialization();
-  if( get_flash_register((0x01c)) != 0xffffffff )
-  {
-   en7571_Tapd = get_flash_register((0x01c));
-   if( en7571_Tapd < 10 )
-   {
-    printk("APD update period is too short, reset to 10s\n");
-    en7571_Tapd=10;
-   }
-  }
-  en7571_APD_control();
+  phy_tx_test_pattern(0x06);
+  phy_mode_config(PHY_GPON_CONFIG, (1));
+  printk("PRBS23 enabled\n");
  }
-
- else
+ else if( input == PHY_EPON_CONFIG )
  {
-  en7571_LOS_init();
-  en7571_internal_DDMI = 0;
-  printk("Internal DDMI Disabled\n");
-  return 0;
- }
 
 
- en7571_reg_init();
+  phy_ben_switch((1));
 
+  phy_tx_test_pattern(0x0b);
+  phy_mode_config(PHY_EPON_CONFIG, (1));
+  printk("8B/10B pattern enabled\n");
+ }
 
- en7571_load_Tx_cal_data();
 
+ PatternEnabled = 1;
+}
+# 1043 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_disable_pattern(void)
+{
 
- en7571_TxSD_level_set();
+ phy_ben_switch((0));
 
 
- en7571_RSSI_gain_init();
+ phy_tx_test_pattern(0x00);
+ phy_tx_test_pattern(0x0c);
 
 
- en7571_LOS_level_set();
+ mt7570_CDR(1);
 
 
- en7571_RogueONU_clear();
+    REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_STOP);
 
 
- en7571_safe_circuit_reset();
+ printk("Pattern disabled\n");
+ PatternEnabled = 0;
+}
+# 1076 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_CDR(int CDR_switch)
+{
+ uint read_data = 0;
 
+ if( CDR_switch == 0 )
+ {
 
- en7571_link_reg(1);
 
 
- en7571_DCL_start();
 
 
- en7571_config();
+   read_data = get_pon_phy_data((0x1faf0000 + 0x4620));
+   set_pon_phy_data((0x1faf0000 + 0x4620), (read_data | 0x100000));
 
- printk("EN7571 Initialization Done!\n");
- return 0 ;
-}
-# 720 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_sysotms(void)
-{
- int i = 0;
- unchar ptr[1];
- unchar temRG[768];
+   read_data = get_pon_phy_data((0x1faf0000 + 0x4614));
+   set_pon_phy_data((0x1faf0000 + 0x4614), (read_data | 0x4000000));
 
- for(i = 0x000 ; i < 0x300 ; i++)
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, i, ptr, 1);
-  temRG[i]=ptr[0];
- }
 
- en7571_sw_reset();
 
- for(i = 0x000 ; i < 0x300 ; i++)
- {
-  ptr[0] = temRG[i];
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, i, ptr, 1);
+  printk("CDR disabled\n");
  }
+ else if( CDR_switch == 1 )
+ {
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
- ptr[0] = (ptr[0] & (0xfe)) | (0x01);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
 
 
-}
-# 756 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_HWKT(int input)
-{
- unchar ptr[4];
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0230), ptr, 3);
 
- if( input == 1 )
-  ptr[0] = (ptr[0] & 0xfe) | 0x01;
- else if( input == 0 )
-  ptr[0] = (ptr[0] & 0xfe);
+   read_data = get_pon_phy_data((0x1faf0000 + 0x4614));
+   printk("read data %x\n",read_data);
+   printk("write data %x\n",(read_data & 0xFBFFFFFF));
+   set_pon_phy_data((0x1faf0000 + 0x4614), (read_data & 0xFBFFFFFF));
 
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0230), ptr, 3);
-}
-# 777 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_hw_reset(void)
-{
- unchar ptr[4];
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4);
- ptr[1] = ptr[1] & 0xfe;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4);
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4);
- ptr[1] = (ptr[1]&0xfe) | 0x01;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4);
+  printk("CDR enabled\n");
+ }
 
 }
-# 799 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_reg_init(void)
+# 1127 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_init(void)
 {
- unchar ptr[4];
- UINT32 Ibias_min = 0x080;
- UINT32 Imod_min = 0x032;
- UINT32 Imax = 0xfff;
+ uint read_data = 0;
 
+    i2c_access_queue = __alloc_workqueue_key(("%s"), (WQ_MEM_RECLAIM), (1), ((void *)0), ((void *)0), ("i2c_access_queue"));
+    do { __init_work(((&gpPhyPriv->EN7570_reset)), 0); ((&gpPhyPriv->EN7570_reset))->data = (atomic_long_t) { (WORK_STRUCT_NO_POOL) }; INIT_LIST_HEAD(&((&gpPhyPriv->EN7570_reset))->entry); ((&gpPhyPriv->EN7570_reset))->func = ((mt7570_safe_circuit_reset_for_work_queue)); } while (0);
 
- printk("en7571_reg_init \n");
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0220), ptr, 4);
- ptr[3] = (ptr[3] & 0xf0) | (Ibias_min >> 8);
- ptr[2] = (ptr[2] & 0x00) | (Ibias_min & 0xff);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0220), ptr, 4);
+ if(get_flash_matrix() == 0)
+  printk("FLASH matrix got\n");
+ else
+  set_flash_register_default();
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0224), ptr, 4);
- ptr[3] = (ptr[3] & 0xf0) | (Imod_min >> 8);;
- ptr[2] = (ptr[2] & 0x00) | (Imod_min & 0xff);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0224), ptr, 4);
 
+ mt7570_sw_reset();
 
- ptr[3] = (Imax >> 8);
- ptr[2] = (Imax & 0xff);
- ptr[1] = 0x00;
- ptr[0] = 0x00;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0240), ptr, 4);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0244), ptr, 4);
 
+ mt7570_TIAGAIN_set();
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4);
+ mt7570_ERC_filter();
 
- ptr[3] = (ptr[3] & 0xf0) | (0x200 >> 8);
- ptr[2] = (0x200 & 0xff);
 
- ptr[1] = (ptr[1] & 0xf0) | (0x300 >> 8);
- ptr[0] = (0x300 & 0xff);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4);
+ mt7570_MPD_current_calibration();
 
 
+ mt7570_ADC_calibration();
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4);
- ptr[0] = (ptr[0] & 0xfc) | 0x02;
 
- ptr[3] = (ptr[3] & 0xc0) | 0x3f;
- ptr[2] = (ptr[2] & 0xc0) | 0x25;
- ptr[1] = (ptr[1] & 0xc0) | 0x3f;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4);
+ mt7570_RSSI_calibration();
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4);
- ptr[2] = (ptr[2] & 0xc0) | 0x25;
- ptr[1] = (ptr[1] & 0xc0) | 0x3f;
- ptr[0] = (ptr[0] & 0xc0) | 0x25;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4);
+ read_data = get_flash_register((0x094));
 
 
+ if(read_data == 0x07050700)
+ {
+  printk("Start GPON Tx Calibration\n");
+  phy_mode_config(PHY_GPON_CONFIG, (1));
+  xPON_mode = PHY_GPON_CONFIG;
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
- ptr[3] = (ptr[3] & 0xf8) | 0x01;
- ptr[1] = 0x02;
- ptr[0] = 0x04;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
 
+  mt7570_RSSI_gain_init();
 
 
+  mt7570_LOS_level_set();
 
 
- en7571_force_mode();
+  set_pon_phy_data((0xbfaf0100 +0x0038), 0x10f);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x023C), ptr, 4);
- ptr[1] = (ptr[1] & 0xfc) | (0x007 >> 8);
- ptr[0] = (0x007 & 0xff);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x023C), ptr, 4);
+  mt7570_TGEN(PHY_GPON_CONFIG);
 
 
+  mt7570_load_init_current();
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x022C), ptr, 4);
- ptr[3] = (ptr[3] & 0xc0) | 0x02;
- ptr[0] = (ptr[0] & 0xf8) | 0x07;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x022C), ptr, 4);
 
+  mt7570_load_MPDL_MPDH();
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0260), ptr, 4);
- ptr[3] = (ptr[3] & 0xf8) | 0x03;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0260), ptr, 4);
 
+  mt7570_TxSD_level_set();
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0254), ptr, 4);
- ptr[3] = 0x00;
- ptr[2] = 0x00;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0254), ptr, 4);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0250), ptr, 4);
- ptr[2] = ptr[2] & 0x80;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0250), ptr, 4);
+  mt7570_APD_initialization();
+  if( get_flash_register((0x01c)) != 0xffffffff )
+  {
+   T_APD = get_flash_register((0x01c));
+   if( T_APD < 10 )
+   {
+    printk("APD update period is too short, reset to 10s\n");
+    T_APD=10;
+   }
+  }
+  mt7570_APD_control();
+ }
 
-}
-# 908 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_mpdh_stepsize(int input)
-{
- unchar ptr[4];
 
- if( input == 0 )
+ else if(read_data == 0xe7050700)
  {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4);
-  ptr[2] = (ptr[2] & 0xc0);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4);
+  printk("Start EPON Tx Calibration\n");
+  phy_mode_config(PHY_EPON_CONFIG, (1));
+  xPON_mode = PHY_EPON_CONFIG;
 
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4);
-  ptr[2] = (ptr[2] & 0xc0);
-  ptr[0] = (ptr[0] & 0xc0);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4);
- }
- else if( input == 1 )
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4);
-  ptr[2] = (ptr[2] & 0xc0) | 0x25;
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4);
 
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4);
-  ptr[2] = (ptr[2] & 0xc0) | 0x25;
-  ptr[0] = (ptr[0] & 0xc0) | 0x25;
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4);
- }
-}
-# 943 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_7571_enable(void)
-{
- unchar ptr[4];
+  mt7570_RSSI_gain_init();
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
- ptr[0] = (ptr[0] & 0xfe) | 0x01;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
-}
-# 960 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_DCL_start(void)
-{
- unchar ptr[4];
+  mt7570_LOS_level_set();
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
- ptr[1] = (ptr[1] & 0xfe) | 0x01;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
-}
-# 977 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_DCL_stop(void)
-{
- unchar ptr[4];
+  set_pon_phy_data((0xbfaf0100 +0x0038), 0x10f);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
- ptr[1] = ptr[1] & 0xfe;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
-}
+  mt7570_TGEN(PHY_EPON_CONFIG);
 
 
+  mt7570_load_init_current();
 
 
-void en7571_cal_Iav_Imod(UINT32 input, int I)
-{
- unchar ptr[4];
- UINT32 keep_pav = en7571_info(0x01);
+  mt7570_load_MPDL_MPDH();
 
- en7571_DCL_stop();
 
- en7571_auto_lock_mode();
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4 );
- if( I == 1 )
- {
-  ptr[0] = input;
-  ptr[1] = (input >> 8);
-  ptr[2] = 0x200&0xff;
-  ptr[3] = (0x200 >> 8);
- }
- else if( I == 0 )
- {
-  ptr[2] = input;
-  ptr[3] = (input >> 8);
+  mt7570_TxSD_level_set();
  }
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4 );
-
- en7571_hw_reset();
- ( (__builtin_constant_p(200) && (200)<=2) ? (__builtin_constant_p((200)*1000) ? (((200)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((200)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((200)*1000)) : ({unsigned long __ms=(200); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
-
- en7571_DCL_start();
 
- if( I == 0 )
+ else
  {
-
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4 );
-  ptr[0] = keep_pav;
-  ptr[1] = (keep_pav >> 8);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
-
-  en7571_force_mode();
+  internal_DDMI = 0;
+  printk("Internal DDMI Disabled\n");
+  return 0;
  }
 
-}
-
-
 
-
-void en7571_cal_Pav_P1(UINT32 input, int P)
-{
- unchar ptr[4];
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
- if( P == 1 )
+ if( get_flash_register((0x070)) == 0x80000000)
  {
-  ptr[0] = input;
-  ptr[1] = (input >> 8);
+  SCL = 1;
+  mt7570_SingleClosedLoopMode();
  }
- else if( P == 0 )
+ else if( get_flash_register((0x070)) == 0xc0000000)
  {
-  ptr[2] = input;
-  ptr[3] = (input >> 8);
+  DOL = 1;
+  mt7570_LUT_recover();
+  mt7570_OpenLoopMode();
  }
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
-}
 
 
 
 
-void en7571_cal_force_mode(void)
-{
- unchar ptr[4];
- printk("en7571_cal_force_mode \n");
+ mt7570_RougeONU_clear();
 
- en7571_DCL_stop();
 
+ mt7570_safe_circuit_reset();
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
- ptr[1] = 0x00;
- ptr[0] = 0x00;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
 
 
+ if( get_flash_register((0x02c)) == 0 )
+ {
+  internal_DDMI = 0;
+  printk("Internal DDMI Disabled\n");
+ }
+ else
+ {
+  printk("Internal DDMI Enabled\n");
+  if( get_flash_register((0x02c)) == 2 )
+   fast_DDMI = 1;
+ }
 
- en7571_hw_reset();
 
- en7571_DCL_start();
+ if( get_flash_register((0x08c)) == 0 )
+ {
+  TEC = 0;
+  printk("TEC Disabled\n");
+ }
+ else if( get_flash_register((0x08c)) != 0xffffffff )
+ {
+  BOSA_Ith = get_flash_register((0x08c));
+  printk("TEC Enabled, BOSA's Ith = %duA\n", BOSA_Ith);
+ }
+ else
+ {
+  printk("TEC Enabled\n");
+ }
 
- ( (__builtin_constant_p(200) && (200)<=2) ? (__builtin_constant_p((200)*1000) ? (((200)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((200)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((200)*1000)) : ({unsigned long __ms=(200); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4 );
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
+ if( get_flash_register((0x07c)) == 1 )
+ {
+  ETC = 1;
+  printk("ETC = 1\n");
+ }
+ else if ( get_flash_register((0x07c)) == 2 )
+ {
+  ETC = 2;
+  printk("ETC = 2\n");
+ }
+ else if ( get_flash_register((0x07c)) == 3 )
+ {
+  ETC = 3;
+  mt7570_LUT_recover();
+  mt7570_temperature_get();
+  mt7570_BiasTracking();
+  printk("ETC = 3\n");
+  printk("BiasTracking Enabled\n");
+ }
+ else
+ {
+  printk("ETC Disabled\n");
+ }
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
- ptr[1] = 0x02;
- ptr[0] = 0x04;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
 
+ printk("EN7570 Initialization Done!\n");
+ return 0 ;
 }
-# 1096 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_sw_reset(void)
+# 1339 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_sw_reset(void)
 {
  unchar ptr[4];
 
@@ -49171,26 +49132,26 @@
  ptr[0] = (ptr[0] & 0xf8) | (0x01);
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0300), ptr, 4);
 }
-# 1113 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_RSSI_gain_init(void)
+# 1362 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_RSSI_gain_init(void)
 {
  unchar ptr[4];
 
 
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4);
- ptr[2] = (ptr[2] & 0xf8) | 0x05;
+ ptr[2] = (ptr[2] & 0xf8) | (0x05);
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4);
 }
-# 1133 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_TGEN(int xPON)
+# 1387 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_TGEN(int xPON)
 {
  unchar ptr[4];
- UINT8 RGS_T0C = 0;
- UINT8 RGS_T1C = 0;
+ uint RGS_T0C = 0;
+ uint RGS_T1C = 0;
  int i = 0;
 
 
- en7571_CDR(0);
+ mt7570_CDR(0);
 
 
 
@@ -49257,25 +49218,30 @@
 
 
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4);
- if( xPON == PHY_GPON_CONFIG )
+ if( get_flash_register((0x098)) != 0xffffffff )
  {
-  ptr[0] = (ptr[0] & 0x00) | 0xaa;
+  ptr[0] = (ptr[0] & 0x00) | (get_flash_register((0x098)) & 0xff);
+  printk("T0/T1 delay = 0x%02x\n", get_flash_register((0x098)) & 0xff);
  }
- else if( xPON == PHY_EPON_CONFIG )
+ else if( xPON == PHY_GPON_CONFIG )
  {
-   ptr[0] = (ptr[0] & 0x00) | 0x77;
+  ptr[0] = (ptr[0] & 0x00) | 0x9a;
+  printk("T0/T1 delay = 0x9a\n");
  }
- else if( xPON == 0xa7050701 )
+ else if( xPON == PHY_EPON_CONFIG )
  {
-   ptr[0] = (ptr[0] & 0x00) | 0x77;
+   ptr[0] = (ptr[0] & 0x00) | 0x47;
+   printk("T0/T1 delay = 0x47\n");
  }
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4 );
 
+ ( (__builtin_constant_p(10) && (10)<=2) ? (__builtin_constant_p((10)*1000) ? (((10)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((10)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((10)*1000)) : ({unsigned long __ms=(10); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+
 
- if( get_flash_register((0x00c)) != 0xffffffff)
+ if( get_flash_register((0x09c)) != 0xffffffff )
  {
-  RGS_T0C = (get_flash_register((0x00c)) & 0x00ff0000)>>16;
-  RGS_T1C = (get_flash_register((0x00c)) & 0xff000000)>>24;
+  RGS_T0C = get_flash_register((0x09c)) & 0x0000ffff;
+  RGS_T1C = (get_flash_register((0x09c)) & 0xffff0000)>>16;
  }
  printk("RGS_T0C = 0x%x\nRGS_T1C = 0x%x\n", RGS_T0C, RGS_T1C);
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4);
@@ -49302,7 +49268,7 @@
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4 );
 
 
- en7571_CDR(1);
+ mt7570_CDR(1);
 
 
 
@@ -49311,19 +49277,20 @@
 
  phy_tx_test_pattern(0x00);
 
+ printk("TGEN done\n");
 }
-# 1271 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_LOS_level_set(void)
+# 1535 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_LOS_level_set(void)
 {
  unchar ptr[4];
 
- en7571_LOS_init();
-
- if( get_flash_register((0x020)) != 0xffffffff )
+ mt7570_LOS_init();
+# 1558 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+ if((get_flash_register((0x020)) != 0xffffffff) && (get_flash_register((0x024)) != 0xffffffff))
  {
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
-  ptr[3] = (ptr[3] & (0x80)) | (get_flash_register((0x020))&0x0000007f);
-  ptr[2] = (ptr[2] & (0x80)) | ( (get_flash_register((0x020))&0x007f0000) >> 16 );
+  ptr[3] = (ptr[3] & (0x80)) | (get_flash_register((0x024)));
+  ptr[2] = (ptr[2] & (0x80)) | (get_flash_register((0x020)));
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
  }
  else
@@ -49335,93 +49302,114 @@
  }
  printk("Rx LOS is set\n");
 }
-# 1301 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_TxSD_level_set(void)
+# 1586 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_TxSD_level_set(void)
 {
- int tiaflt_A = 0;
- UINT32 txsd_offset = 0;
- int tiasd_B = 0;
- int read_Pav_D = 0;
- UINT32 tia_sd = 0;
- UINT8 tia_mux_default = 0;
+ int delta = 0;
+ uint tia_sd = 0;
+ uint MPDH = 0;
+ uint MPDL = 0;
  unchar ptr[4];
 
- txsd_offset = (en7571_PWRADC_offset >> 6);
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004), ptr, 4);
+  MPDH = ((ptr[1]<<8) | ptr[0]) & (0x3ff);
+  MPDL = ((ptr[3]<<8) | ptr[2]) & (0x3ff);
+
+  delta = mt7570_TxSD_level_calibration();
+  if ( delta >= 0 )
+  {
+   tia_sd = (0.1/2)*(MPDH + (MPDL>>2)) + (1.4/0.6)*delta;
+   ptr[0] = tia_sd & (0xff);
+   ptr[1] = (tia_sd >> 8) & (0x01);
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2 );
+   printk("Tx SD set\n");
+  }
+  else
+  {
+   printk("Tx SD error\n");
+  }
+}
+# 1626 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_TxSD_level_calibration(void)
+{
+ unchar ptr[2];
+ int tiaflt = 0;
+ int TIASD_0 = 0;
 
 
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
- tia_mux_default = ptr[0];
  ptr[0] = (ptr[0] & 0xf1) | 0x08;
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0208)+(0x03)), ptr, 1);
- ptr[0] = (ptr[0] & 0xff ) | 0x80;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0208)+(0x03)), ptr, 1);
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0204), ptr, 2);
- tiaflt_A = ((ptr[1]<<8) | ptr[0]) & (0x3ff);
- tiaflt_A = tiaflt_A - txsd_offset ;
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024)+0x02, ptr, 1);
+ ptr[0] = (ptr[0] & 0xef) | (0x10);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024)+0x02, ptr, 1);
+ ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+
+
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
+ ptr[0] = (ptr[0] & 0xe1) | (0x04);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
+ ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+
+
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+ ptr[0] = (ptr[0] & (0xef))|(0x10);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+ ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+
+
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+ tiaflt = (ptr[0] | (ptr[1]<<8));
+
+ ( (__builtin_constant_p(10) && (10)<=2) ? (__builtin_constant_p((10)*1000) ? (((10)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((10)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((10)*1000)) : ({unsigned long __ms=(10); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
 
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
- ptr[0] = (ptr[0] & 0xf1 ) | 0x02;
+ ptr[0] = (ptr[0] & 0xf1) | (0x02);
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
+ ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+
 
 
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2);
  ptr[0] = (ptr[0] & 0x00);
  ptr[1] = (ptr[1] & 0xfe);
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2);
+ ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0208)+(0x03)), ptr, 1);
- ptr[0] = (ptr[0] & 0xff ) | 0x80;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0208)+(0x03)), ptr, 1);
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+ ptr[0] = (ptr[0] & (0xef))|(0x10);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+ ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0204), ptr, 2);
- tiasd_B = ((ptr[1]<<8) | ptr[0]) & (0x3ff);
- tiasd_B= tiasd_B - txsd_offset;
 
-
- read_Pav_D = ( (get_flash_register((0x004))&0x0fff0000)>>18 ) - txsd_offset;
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+ TIASD_0 = (ptr[0] | (ptr[1]<<8));
 
 
- tia_sd = 0.1*2.8/1.8*read_Pav_D + (2.8/1.8)*(tiaflt_A - tiasd_B) + 6 ;
- printk("TIASD = 0x%x\n", tia_sd);
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2);
- ptr[0] = tia_sd & 0xff;
- ptr[1] = (tia_sd >> 8) & 0x01;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2 );
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024)+0x02, ptr, 1);
+ ptr[0] = (ptr[0] & 0xef);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024)+0x02, ptr, 1);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
- ptr[0] = tia_mux_default;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
-}
-# 1378 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT32 en7571_SVADC_get(void)
-{
- unchar ptr[2];
- UINT32 svadc_value = 0;
-
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158) + 0x001), ptr, 1);
- ptr[0] = (ptr[0]&0xef) | 0x10;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158) + 0x001), ptr, 1);
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
+ ptr[0] = (ptr[0] & 0xe1);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
- svadc_value = (ptr[0] | (ptr[1]<<8));
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
+ ptr[0] = (ptr[0] & 0xf1) | 0x08;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
 
- return svadc_value;
+ return (tiaflt - TIASD_0);
 }
-# 1402 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_ADC_calibration(void)
+# 1715 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_ADC_calibration(void)
 {
- int BG1V76 = 0;
- int BG0V875 = 0;
-
  unchar ptr[2];
  uint read_data = 0;
  uint cnt = 8;
@@ -49430,7 +49418,7 @@
 
  if( i2c_access_protect() == -1 )
  {
-  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 1415);
+  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 1725);
  }
  else
  {
@@ -49441,17 +49429,21 @@
   read_data = ptr[0];
   ptr[0] = (ptr[0] & 0xe1) | 0x06;
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
-
      for(i=0;i<cnt;i++)
   {
-   temp += en7571_SVADC_get();
-  }
 
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+   ptr[0] = (ptr[0]&0xef) | 0x10;
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+   temp += (ptr[0] | (ptr[1]<<8));
+  }
 
   ptr[0] = read_data;
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
-
   BG1V76 = ((temp>>2)+1)>>1;
+
   temp = 0;
 
 
@@ -49459,22 +49451,25 @@
   read_data = ptr[0];
   ptr[0] = (ptr[0] & (0xb3))|(0x4C);
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0024) + 0x01), ptr, 1);
-
   for(i=0;i<cnt;i++)
   {
-   temp += en7571_SVADC_get();
-  }
 
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+   ptr[0] = (ptr[0] & (0xef))|(0x10);
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+   temp += (ptr[0] | (ptr[1]<<8));
+  }
 
   ptr[0] = read_data;
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0024) + 0x01), ptr, 1);
-
   ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; });
-
   BG0V875 = ((temp>>2)+1)>>1;
+
   temp = 0;
 
-  printk("BG 1.76V = 0x%x\nBG 0.875V = 0x%x\n", BG1V76, BG0V875);
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "BG 1V76 = 0x%x\nBG 0V875 =0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1776, BG1V76, BG0V875) ; };
 
   if( (BG1V76-BG0V875) <= 0 )
   {
@@ -49482,12 +49477,12 @@
    return;
   }
 
-  en7571_ADC_slope = (1.76-0.875)/(float)(BG1V76-BG0V875);
-  en7571_ADC_offset = 1.76 - en7571_ADC_slope*(float)BG1V76;
+  ADC_slope = (1.76-0.875)/(float)(BG1V76-BG0V875);
+  ADC_offset = 1.76 - ADC_slope*(float)BG1V76;
  }
 }
-# 1479 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_APD_initialization(void)
+# 1801 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_APD_initialization(void)
 {
  unchar ptr[4];
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0030), ptr, 4);
@@ -49498,10 +49493,11 @@
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0030), ptr, 4);
  printk("APD initialization done\n");
 }
-# 1498 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_APD_control(void)
+# 1825 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_APD_control(void)
 {
-
+ if( get_flash_register(0x030)>0x0000ffff && get_flash_register(0x034)>0x0000ffff )
+ {
 
   unchar ptr[1];
   int a = 0;
@@ -49543,186 +49539,199 @@
   }
 
 
-  if( en7571_BOSA_temperature > 25 )
-   en7571_APD_voltage = APD_voltage_NT + APD_slope_up*( en7571_BOSA_temperature - 25 );
+  if( BOSA_temperature > 25 )
+   APD_voltage = APD_voltage_NT + APD_slope_up*( BOSA_temperature - 25 );
   else
-   en7571_APD_voltage = APD_voltage_NT - APD_slope_dn*( 25 - en7571_BOSA_temperature );
+   APD_voltage = APD_voltage_NT - APD_slope_dn*( 25 - BOSA_temperature );
 
 
-  a = (int)en7571_BOSA_temperature;
-  b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), char), (char)({ signed char __x = ((int)(en7571_BOSA_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "BOSA temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1550, a, b) ; };
+  a = (int)BOSA_temperature;
+  b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), char), (char)({ signed char __x = ((int)(BOSA_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "BOSA temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1878, a, b) ; };
 
-  a = (int)en7571_APD_voltage;
-  b = (int)(en7571_APD_voltage*10)%10;
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD Voltage = %d.%dV\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1554, a, b) ; };
+  a = (int)APD_voltage;
+  b = (int)(APD_voltage*10)%10;
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD Voltage = %d.%dV\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1882, a, b) ; };
 
 
-  if( en7571_APD_voltage < APD_voltage_0x80 )
+  if( APD_voltage < APD_voltage_0x80 )
   {
-   if( en7571_APD_voltage < APD_voltage_0x40 )
+   if( APD_voltage < APD_voltage_0x40 )
    {
     APD_voltage_step = (APD_voltage_0x40 - APD_voltage_0x00)/64;
-    ptr[0] = 0x00 + (int)( (en7571_APD_voltage - APD_voltage_0x00)/APD_voltage_step );
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 1\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1563) ; };
+    ptr[0] = 0x00 + (int)( (APD_voltage - APD_voltage_0x00)/APD_voltage_step );
+    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 1\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1891) ; };
    }
    else
    {
     APD_voltage_step = (APD_voltage_0x80 - APD_voltage_0x40)/64;
-    ptr[0] = 0x40 + (int)( (en7571_APD_voltage - APD_voltage_0x40)/APD_voltage_step );
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 2\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1569) ; };
+    ptr[0] = 0x40 + (int)( (APD_voltage - APD_voltage_0x40)/APD_voltage_step );
+    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 2\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1897) ; };
    }
 
   }
   else
   {
    APD_voltage_step = (APD_voltage_0xC0 - APD_voltage_0x80)/64;
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 3\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1576) ; };
+   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 3\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1904) ; };
 
-   if( en7571_APD_voltage < APD_voltage_0xC0 )
-    ptr[0] = 0x80 + (int)( (en7571_APD_voltage - APD_voltage_0x80)/APD_voltage_step );
+   if( APD_voltage < APD_voltage_0xC0 )
+    ptr[0] = 0x80 + (int)( (APD_voltage - APD_voltage_0x80)/APD_voltage_step );
    else
    {
-    ptr[0] = 0xC0 + (int)( (en7571_APD_voltage - APD_voltage_0xC0)/APD_voltage_step );
+    ptr[0] = 0xC0 + (int)( (APD_voltage - APD_voltage_0xC0)/APD_voltage_step );
     if( ptr[0] > 0xff )
      ptr[0] = 0xff;
    }
   }
 
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1588, ptr[0]) ; };
-  en7571_APD_I2C_write( ptr );
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1916, ptr[0]) ; };
+  mt7570_APD_I2C_write( ptr );
+ }
+ else
+ {
+  unchar ptr[1];
+  int a = 0;
+  int b = 0;
+  float APD_slope_up = 0.10;
+  float APD_slope_dn = 0.07;
+  float APD_voltage_NT = 35.0;
+  float APD_zero_code_voltage = 30.0;
+  float APD_voltage_step = 0.09375;
+
+
+  if(get_flash_register((0x010))!=0xffffffff)
+   APD_slope_up = ( (float) get_flash_register((0x010)) )/100;
+
+  if(get_flash_register((0x014))!=0xffffffff)
+   APD_slope_dn = ( (float) get_flash_register((0x014)) )/100;
+
+  if(get_flash_register((0x018))!=0xffffffff)
+   APD_voltage_NT = ( (float) get_flash_register((0x018)) )/100;
+
+  if(get_flash_register((0x034))!=0xffffffff)
+   APD_zero_code_voltage = ( (float) get_flash_register((0x034)) )/100;
+
+  if(get_flash_register((0x030))!=0xffffffff)
+   APD_voltage_step = ( (float) get_flash_register((0x030)) )/1000;
+
+
+  if( BOSA_temperature > 25 )
+   APD_voltage = APD_voltage_NT + APD_slope_up*( BOSA_temperature - 25 );
+  else
+   APD_voltage = APD_voltage_NT - APD_slope_dn*( 25 - BOSA_temperature );
+
+
+  a = (int)BOSA_temperature;
+  b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), char), (char)({ signed char __x = ((int)(BOSA_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "BOSA temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1955, a, b) ; };
+
+  a = (int)APD_voltage;
+  b = (int)(APD_voltage*10)%10;
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD Voltage = %d.%dV\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1959, a, b) ; };
+
+
+  ptr[0] = (int)( (APD_voltage - APD_zero_code_voltage)/APD_voltage_step );
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1963, ptr[0]) ; };
+
+  mt7570_APD_I2C_write( ptr );
 
-}
-# 1602 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_APD_DAC(UINT8 DAC)
-{
- unchar ptr[1];
 
- en7571_APD_initialization();
 
- ptr[0] = DAC;
- printk("DAC = 0x%x\n", ptr[0]);
- en7571_APD_I2C_write( ptr );
+ }
 }
-# 1622 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_APD_I2C_write(unchar ptr[1])
+# 1984 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_APD_I2C_write(unchar ptr[1])
 {
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD in en7571_APD_I2C_write = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1624, ptr[0]) ; };
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD in mt7570_APD_I2C_write = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1986, ptr[0]) ; };
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0030), ptr, 1);
 }
-# 1640 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT32 en7571_info(uint select)
+# 2001 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_information_output(uint select)
 {
- UINT32 output = 0;
+ uint output = 0;
  unchar ptr[4];
- unchar ptr_temp[4];
 
- if(select == 0x03)
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr_temp, 4);
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4);
-  if( ptr_temp[3] == ptr[3] )
-   output = ( (ptr[3]<<8) | ptr[2] ) & 0xfff;
-  else
+  if(select == 0x03)
   {
    phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4);
-   output = ( (ptr[3]<<8) | ptr[2] ) & 0xfff;
+   output = (ptr[2] | ((ptr[3] & 0x0f) << 8 ));
+   global_bias_current = output;
   }
- }
- else if(select == 0x04)
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr_temp, 4);
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4);
-  if( ptr_temp[3] == ptr[3] )
-   output = ( (ptr[3]<<8) | ptr[2] ) & 0xfff;
-  else
+  else if(select == 0x04)
   {
    phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4);
-   output = ( (ptr[3]<<8) | ptr[2] ) & 0xfff;
+   output = (ptr[2] | ((ptr[3] & 0x0f) << 8 ));
+   global_modulation_current = output;
   }
- }
- else if(select == 0x02)
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B0), ptr_temp, 4);
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B0), ptr, 4);
-  if( ptr_temp[1] == ptr[1] )
-   output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff;
-  else
+  else if(select == 0x05)
   {
-   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B0), ptr, 4);
-   output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff;
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004), ptr, 4);
+   output = (ptr[2] | ((ptr[3] & 0x03) << 8 ));
+   global_MPDL = output;
+  }
+  else if(select == 0x06)
+  {
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004), ptr, 4);
+   output = (ptr[0] | ((ptr[1] & 0x03) << 8 ));
+   global_MPDH = output;
   }
- }
- else if(select == 0x01)
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4);
-  output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff;
- }
- else if(select == 0x06)
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4);
-  output = ( (ptr[3]<<8) | ptr[2] ) & 0x3ff;
- }
- else if(select == 0x07)
- {
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr_temp, 4);
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4 );
- if( ptr_temp[1] == ptr[1] )
-  output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff;
- else
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4);
-  output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff;
- }
- }
- else if(select == 0x08)
- {
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4 );
-  output = ( (ptr[3]<<8) | ptr[2] ) & 0x3ff;
- }
 
  return output;
 }
-# 1725 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-int en7571_ADC_temperature_get(void)
+# 2044 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_ADC_temperature_get(void)
 {
  unchar ptr[4];
- UINT8 read_data = 0;
+ uint cnt = 8;
+ uint i = 0;
+ uint temp = 0;
 
  if( i2c_access_protect() == -1 )
  {
-  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 1732);
+  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2053);
+  return global_temperature_code;
  }
  else
  {
   ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((1)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; });
 
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024) , ptr, 1);
-  read_data = ptr[0];
   ptr[0] = (ptr[0] & (0xe1))|(0x08);
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
+  for(i=0;i<cnt;i++)
+  {
 
-  en7571_temperature_ADC = en7571_SVADC_get();
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "temperature ADC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1744, en7571_temperature_ADC) ; };
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+   ptr[0] = (ptr[0] & (0xef))|(0x10);
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
 
 
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+   temp += (ptr[0] | (ptr[1]<<8));
+  }
+
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024) , ptr, 1);
-  ptr[0] = read_data;
+  ptr[0] = ptr[0] & (0xe1);
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
-
         ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; });
+  global_temperature_code = ((temp>>2)+1)>>1;
+
+  temp = 0;
+
+  return global_temperature_code;
  }
- return en7571_temperature_ADC;
 }
-# 1768 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-int en7571_ADC_voltage_get(void)
+# 2099 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_ADC_voltage_get(void)
 {
  unchar ptr[4];
  uint read_data = 0;
 
  if( i2c_access_protect() == -1 )
  {
-  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 1775);
+  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2106);
+  return global_vcc_code;
  }
  else
  {
@@ -49739,8 +49748,14 @@
   ptr[0] = ptr[0] & (0xe1);
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 
-  en7571_voltage_ADC = en7571_SVADC_get();
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "VCC ADC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1793, en7571_voltage_ADC) ; };
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+  ptr[0] = (ptr[0] & (0xef))|(0x10);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+  global_vcc_code = (ptr[0] | (ptr[1]<<8));
 
 
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014) , ptr, 1);
@@ -49750,135 +49765,186 @@
 
   ptr[0] = read_data;
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
-
+# 2160 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
   ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; });
+  return global_vcc_code;
  }
-
- return en7571_voltage_ADC;
 }
-# 1817 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_load_Tx_cal_data(void)
+# 2179 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_load_init_current(void)
 {
  unchar ptr[4];
- unchar ptr_tmp[2];
- UINT32 read_data = 0;
+ uint read_data = 0;
+ int temperature_index = 0;
 
 
- if( get_flash_register((0x000)) != 0xffffffff)
+ if( (get_flash_register((0x000))!=0xffffffff) && (get_flash_register((0x004))!=0xffffffff) )
  {
 
-  read_data = get_flash_register((0x000))&0x0fff0000;
-  read_data = read_data >> 16;
+  read_data = get_flash_register((0x000));
+  read_data = read_data & (0xfff);
   ptr[0] = read_data;
   ptr[1] = (read_data >> 8);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2 );
 
-  read_data = get_flash_register((0x000))&0x00000fff;
-  ptr[2] = read_data;
-  ptr[3] = (read_data >> 8);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4 );
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x027C), ptr, 4 );
-  printk("Initial current loaded\n");
- }
-
-
- if( get_flash_register((0x004)) != 0xffffffff)
- {
 
-  read_data = get_flash_register((0x004))&0x0fff0000;
-  read_data = read_data >> 16;
+  read_data = get_flash_register((0x004));
+  read_data = read_data & (0xfff);
   ptr[0] = read_data;
   ptr[1] = (read_data >> 8);
-
-  read_data = get_flash_register((0x004))&0x000003ff;
-  ptr[2] = read_data;
-  ptr[3] = (read_data >> 8);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
-  ptr_tmp[0] = ptr[0];
-  ptr_tmp[1] = ptr[1];
-  ptr[0] = ptr[2];
-  ptr[1] = ptr[3];
-  ptr[2] = ptr_tmp[0];
-  ptr[3] = ptr_tmp[1];
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0280), ptr, 4 );
-  printk("PWR/ER loaded\n");
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 2 );
+  printk("Initial bias/mod current loaded from FLASH\n");
  }
 
-
- read_data = get_flash_register((0x008));
- if( read_data != 0xffffffff)
+ else
  {
 
-  ptr[0] = ((read_data&0x0fff0000)>>16)&0xFF;
-  ptr[1] = (read_data&0x0fff0000)>>24;
+  mt7570_temperature_get();
+  temperature_index = (int)( (BOSA_temperature+40)/2.5 );
+  if( temperature_index < 0 )
+   temperature_index = 0;
+
+
+  read_data = LUT_Ibias_Imod[temperature_index][0];
+  ptr[0] = read_data;
+  ptr[1] = (read_data >> 8);
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2 );
 
 
-  ptr[0] = (read_data&0x00000fff)&0xFF;
-  ptr[1] = (read_data&0x00000fff)>>8;
+  read_data = LUT_Ibias_Imod[temperature_index][1];
+  ptr[0] = read_data;
+  ptr[1] = (read_data >> 8);
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 2 );
-  printk("Open loop initial current loaded\n");
+  printk("Initial bias/mod current loaded from LUT\n");
  }
-
 }
-# 1888 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_temperature_get(void)
+# 2241 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_temperature_get(void)
 {
- UINT32 read_data = 0;
+ uint read_data = 0;
  float BOSA_temperature_offset = 5;
  float Env_temperature_offset = 10;
- float Efuse_offset = 3.44;
-    float sensor_voltage;
+ float T_V_slope = 327.5;
+ float T_V_offset = 495.8;
+     float sensor_voltage;
 
-    en7571_ADC_temperature_get();
- sensor_voltage = en7571_ADC_slope*((float)en7571_temperature_ADC)+en7571_ADC_offset;
+ if( (get_flash_register((0x080))& 0xffff0000) != 0xffff0000 )
+ {
+  read_data = get_flash_register((0x080));
+  T_V_slope = (float)((read_data & 0xffff0000) >> 16)/10;
+ }
+
+ if( (get_flash_register((0x080))& 0x0000ffff) != 0xffff )
+ {
+  read_data = get_flash_register((0x080));
+  T_V_offset = (float)(read_data & 0x0000ffff)/10;
+ }
 
- en7571_IC_temperature = 495.8 - ( 327.5 * sensor_voltage );
- en7571_IC_temperature = en7571_IC_temperature - en7571_eFuse_temperature_offset - Efuse_offset ;
 
- read_data = get_flash_register((0x024));
- if( (read_data & 0x0000ffff) != 0x0000ffff)
+    mt7570_ADC_temperature_get();
+ sensor_voltage = ADC_slope*((float)global_temperature_code)+ADC_offset;
+
+ IC_temperature = T_V_offset - ( T_V_slope * sensor_voltage );
+
+ read_data = get_flash_register((0x084));
+ if( (read_data & 0x0000ffff) != 0xffff )
   BOSA_temperature_offset = read_data & 0x0000ffff;
  if( (read_data & 0xffff0000)>>16 != 0xffff )
-  Env_temperature_offset = ((read_data & 0xffff0000)>>16)/10;
+  Env_temperature_offset = (float)((read_data & 0xffff0000)>>16)/10;
 
- en7571_BOSA_temperature = en7571_IC_temperature - (float)BOSA_temperature_offset;
- en7571_Env_temperature = en7571_IC_temperature - (float)Env_temperature_offset;
+ BOSA_temperature = IC_temperature - (float)BOSA_temperature_offset;
+ Env_temperature = IC_temperature - Env_temperature_offset;
+# 2285 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+}
+# 2299 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_load_MPDL_MPDH(void)
+{
+ unchar ptr[4];
+ uint read_data = 0;
+ if( (get_flash_register((0x00c)) != 0xffffffff) && (get_flash_register((0x008)) != 0xffffffff))
+ {
 
+  read_data = (get_flash_register((0x00c)) & (0x3ff)) | ((get_flash_register((0x008)) & (0x3ff)) << 16);
+  ptr[0] = read_data;
+  ptr[1] = (read_data >> 8);
+  ptr[2] = (read_data >> 16);
+  ptr[3] = (read_data >> 24);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004), ptr, 4 );
+
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4);
+  ptr[0] = (ptr[0] & 0xfe) | (0x01);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 );
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4);
+  ptr[0] = (ptr[0] & 0xfe) | (0x01);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4 );
+
+  printk("MPDL/MPDH loaded\n");
+ }
 }
-# 1925 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT16 en7571_temperature_get_8472(void)
+# 2337 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+UINT16 mt7570_temperature_get_8472(void)
 {
  int a = 0;
  int b = 0;
- UINT16 IC_temperature_8472 = 0;
- en7571_temperature_get();
- if( en7571_IC_temperature > 0)
-  IC_temperature_8472 = (UINT16)(en7571_IC_temperature*256);
+
+ mt7570_temperature_get();
+ if( IC_temperature > 0)
+  global_IC_temperature_8472 = (UINT16)(IC_temperature*256);
  else
-  IC_temperature_8472 = 65536 - (UINT16)( (-1)*en7571_IC_temperature*256 );
+  global_IC_temperature_8472 = 65536 - (UINT16)( (-1)*IC_temperature*256 );
 
- a = (int)en7571_IC_temperature;
- b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(en7571_IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "IC temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1938, a, b) ; };
+ a = (int)IC_temperature;
+ b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "IC temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2350, a, b) ; };
 
- return IC_temperature_8472;
+ return global_IC_temperature_8472;
 }
-# 1955 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT16 en7571_supply_voltage_get_8472(void)
+# 2365 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+UINT16 mt7570_supply_voltage_get_8472(void)
 {
- return ( 2*(en7571_ADC_slope*en7571_ADC_voltage_get()+en7571_ADC_offset)/0.0001 );
+
+
+
+
+
+
+
+ global_supply_voltage_8472 = 2*(ADC_slope*mt7570_ADC_voltage_get()+ADC_offset)/0.0001;
+ return global_supply_voltage_8472;
+# 2420 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
 }
-# 1972 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT16 en7571_bias_current_get_8472(void)
+# 2432 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+UINT16 mt7570_bias_current_get_8472(void)
 {
- return ( en7571_info(0x03)*0.02442*1000/2 );
+ UINT16 bias_current_8472 = 0;
+
+ bias_current_8472 = mt7570_information_output(0x03)*0.02442*1000/2;
+
+ if( FiberPlug == 1 && bias_current_8472 < 500 )
+ {
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Fiber isn't recovered\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2440) ; };
+ }
+ else
+ {
+  if( global_bias_current_8472 - bias_current_8472 > 500 )
+  {
+   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Fiber plugged\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2446) ; };
+   FiberPlug = 1;
+  }
+  else
+   FiberPlug = 0;
+ }
+
+ global_bias_current_8472 = bias_current_8472;
+ return global_bias_current_8472;
 }
-# 1984 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_RSSI_calibration(void)
+# 2467 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_RSSI_calibration(void)
 {
   unchar ptr[4];
   uint read_data = 0;
-  float RSSI_factor = 0;
 
 
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 2);
@@ -49896,16 +49962,28 @@
   ptr[0] = (ptr[0] & 0xe1) | 0x02;
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 
-  en7571_RSSI_Vref = en7571_SVADC_get();
-  printk("RSSI_Vref = 0x%x\n", en7571_RSSI_Vref);
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+  ptr[0] = (ptr[0] & (0xef))|(0x10);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+  RSSI_Vref = ptr[0] | (ptr[1]<<8);
+  printk("RSSI_Vref = 0x%x\n", RSSI_Vref);
 
 
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 2);
   ptr[1] = ptr[1] & 0xbf;
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 2);
 
-  en7571_RSSI_V = en7571_SVADC_get();
-  printk("RSSI_V = 0x%x\n", en7571_RSSI_V);
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+  ptr[0] = (ptr[0] & (0xef))|(0x10);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+  RSSI_V = ptr[0] | (ptr[1]<<8);
+  printk("RSSI_V = 0x%x\n", RSSI_V);
 
 
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 2);
@@ -49917,25 +49995,28 @@
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 
 
-  if( en7571_RSSI_V > en7571_RSSI_Vref )
-   RSSI_factor = ( en7571_ADC_slope*(en7571_RSSI_V- en7571_RSSI_Vref)+en7571_ADC_offset )/0.35;
+  if( RSSI_V > RSSI_Vref )
+   RSSI_factor = ( ADC_slope*(RSSI_V- RSSI_Vref)+ADC_offset )/0.35;
   else
    printk("RSSI calibration fail\n");
 }
-# 2045 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT32 en7571_RSSI_get(void)
+# 2537 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_RSSI_current(void)
 {
  unchar ptr[4];
  uint read_data = 0;
  uint RSSI_voltage = 0;
  uint RSSI_GAIN = 0;
  uint RSSI_GAIN_factor = 0;
+ uint cnt = 4;
+ uint temp = 0;
+ uint i = 0;
  int search_cnt = 0;
- UINT32 acc_num = 10;
- int vld = 0;
+
  if( i2c_access_protect() == -1 )
  {
-  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2057);
+  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2551);
+  return global_RSSI_current;
  }
  else
  {
@@ -49947,50 +50028,35 @@
   ptr[0] = (ptr[0] & 0xe1) | 0x02;
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 
-
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4);
-  ptr[3] = (ptr[3]&0x8f) | 0x70;
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4);
-
   for( search_cnt = 0; search_cnt < 6; search_cnt++ )
   {
-   RSSI_GAIN = 0x05 - search_cnt;
+   RSSI_GAIN = 5 - search_cnt;
    phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4);
    ptr[2] = (ptr[2] & 0xf8) | RSSI_GAIN;
    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4);
-
-
-   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4);
-   ptr[3] = (ptr[3]&0x7f) | 0x80;
-   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4);
-   ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
-
-   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4);
-   vld = (ptr[2]&0x80) >> 7;
-   if(vld == 1)
+   temp = 0;
+   for(i=0;i<cnt;i++)
    {
 
-    phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4);
-    RSSI_voltage = ( ( (ptr[2]<<16) | (ptr[1]<<8) | ptr[0] ) & 0xfffff )>>acc_num;
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "RSSI ADC = 0x%x\t" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2094, RSSI_voltage) ; };
+    phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+    ptr[0] = (ptr[0] & (0xef))|(0x10);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+
+    phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+    temp += ptr[0] | (ptr[1]<<8);
    }
+   RSSI_voltage = ((temp>>1)+1)>>1;
 
-   if(RSSI_voltage < en7571_RSSI_Vref - 0x32)
+   if(RSSI_voltage < RSSI_Vref - 0x32)
     break;
   }
   if (0xB7> RSSI_voltage)
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "\nRSSI ADC code lower than 0.5V, not precise!\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2101) ; };
-
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "\nRSSI GAIN = %d, RSSI_voltage = %x, \n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2103, RSSI_GAIN,RSSI_voltage) ; };
-
-
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 1);
-  ptr[3] = ptr[3]&0x8f;
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 1);
+   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "RSSI ADC code lower than 0.5V, not precise!\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2587) ; };
 
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "RSSI GAIN = %d, RSSI_voltage = %x, \n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2589, RSSI_GAIN,RSSI_voltage) ; };
 
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4);
-  ptr[2] = (ptr[2] & 0xf8) | 0x05;
+  ptr[2] = (ptr[2] & 0xf8) | (0x05);
   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4);
 
 
@@ -50021,21 +50087,20 @@
     break;
   }
 
-  if ( en7571_RSSI_Vref >= RSSI_voltage )
+  if ( RSSI_Vref >= RSSI_voltage )
   {
-   en7571_RSSI_current = (en7571_RSSI_Vref - RSSI_voltage)*RSSI_GAIN_factor;
+   global_RSSI_current = (RSSI_Vref - RSSI_voltage)*RSSI_GAIN_factor;
+   return global_RSSI_current;
   }
   else
   {
-   en7571_RSSI_current = 0;
+   global_RSSI_current = 0;
+   return global_RSSI_current;
   }
  }
-
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "RSSI = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2153, en7571_RSSI_current) ; };
- return en7571_RSSI_current;
 }
-# 2170 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT32 en7571_dark_current(void)
+# 2649 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_dark_current(void)
 {
  unchar ptr[4];
  uint read_data = 0;
@@ -50045,7 +50110,7 @@
  uint i = 0;
 
  if( i2c_access_protect() == -1 )
-  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2180);
+  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2659);
  else
  {
   ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((1)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; });
@@ -50064,9 +50129,17 @@
 
   for(i=0;i<cnt;i++)
   {
-   RSSI_voltage += en7571_SVADC_get();
+
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+   ptr[0] = (ptr[0] & (0xef))|(0x10);
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
+
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+   RSSI_voltage += ptr[0] | (ptr[1]<<8);
   }
 
+  printk("RSSI voltage = %x\n", RSSI_voltage);
+
 
   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4);
   ptr[2] = (ptr[2] & 0xf8) | (0x05);
@@ -50079,170 +50152,242 @@
   ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; });
  }
 
- return RSSI_voltage;
+ return 0;
 }
-# 2224 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-int en7571_RogueONU_status(void)
+# 2717 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_RougeONU_clear(void)
 {
- unchar ptr[2];
- int RogueONU_status = 0 ;
+ unchar ptr[1];
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168) + 0x01, ptr, 1);
+ ptr[0] = (ptr[0] & 0xfe) | 0x1;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168) + 0x01, ptr, 1);
+ printk("Rogue ONU clear\n");
+}
+# 2738 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_MPD_current_calibration(void)
+{
+  unchar ptr[2];
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168), ptr, 2);
- RogueONU_status = (ptr[1]>>2 & 0x1);
 
- return RogueONU_status;
 
-}
-# 2244 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_RogueONU_clear(void)
-{
- unchar ptr[1];
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168) + 0x1, ptr, 1);
- ptr[0] = (ptr[0] & 0xfe) | 0x1;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168) + 0x1, ptr, 1);
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
+  ptr[0] = (ptr[0] & 0xf1) | 0x08;
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
 
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rogue ONU clear\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2251) ; };
-}
-# 2261 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_PWRADC_enable(void)
-{
- unchar ptr[4];
+
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
+  ptr[0] = (ptr[0] & 0xe1) | 0x04;
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
- ptr[0] = ptr[0] & 0xf1;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+  ptr[0] = (ptr[0] & (0xef))|(0x10);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4);
- ptr[3] = ptr[3] & 0xef;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4);
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+  MPD_current_offset = (ptr[0] | (ptr[1]<<8));
+  global_MPD_current = MPD_current_offset;
+  printk("MPD Current Offset = 0x%x\n", MPD_current_offset);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B4), ptr, 1);
- ptr[0] = (ptr[0] & 0xfc) | 0x01;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B4), ptr, 1);
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
+  ptr[0] = (ptr[0] & 0xf1) | 0x08;
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
+
 
- printk("PWRADC ready\n");
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
+  ptr[0] = (ptr[0] & 0xe1);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 }
-# 2290 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_PWRADC_calibration(void)
+# 2788 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_MPD_current(void)
 {
- unchar ptr[4];
- int vld = 0;
+ unchar ptr[2];
+ uint MPD_current = 0;
+ uint temp = 0;
+ int i = 0;
+ int cnt = 0;
 
+ if( vEN7570 == 0 && TEC_switch )
+  cnt = 10;
+ else
+  cnt = 1;
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4);
- ptr[3] = (ptr[3] & 0xef) | 0x10;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4);
+ if( i2c_access_protect() == -1 )
+ {
+  printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2803);
+  return global_MPD_current;
+ }
+ else
+ {
+  ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((1)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; });
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- ptr[3] = (ptr[3]&0xf8 ) | 0x07;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
+  ptr[0] = (ptr[0] & 0xf1);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- ptr[3] = (ptr[3]&0x7f) | 0x80;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
+  ptr[0] = (ptr[0] & 0xe1) | 0x04;
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- vld = (ptr[2]&0x10) >> 4;
- if(vld == 1)
- {
+  for( i=0; i<cnt; i++ )
+  {
 
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
-  en7571_PWRADC_offset = ( (ptr[2]<<16) | (ptr[1]<<8) | ptr[0] ) & 0xfffff;
-  en7571_PWRADC_offset = en7571_PWRADC_offset >> 4;
-  printk("PWRADC offset = 0x%x\n", en7571_PWRADC_offset);
- }
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1);
+   ptr[0] = (ptr[0] & (0xef))|(0x10);
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- ptr[3] = ptr[3]&0xf8;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
 
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2);
+   MPD_current = (ptr[0] | (ptr[1]<<8));
+
+   if(temp == 0)
+    temp = MPD_current;
+   else if(temp < MPD_current)
+    temp = MPD_current;
+  }
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4);
- ptr[3] = ptr[3] & 0xef;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4);
 
-}
-# 2345 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT32 en7571_PWRADC_get(void)
-{
- unchar ptr[4];
- UINT32 ADC = 0;
- int vld = 0;
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
+  ptr[0] = (ptr[0] & 0xe1);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1);
 
- if( (gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_DOWN) && (en7571_PatternEnabled == 0) )
-  return en7571_PWRADC_offset;
 
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
+  ptr[0] = (ptr[0] & 0xf1) | 0x08;
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- ptr[3] = (ptr[3]&0xf8 ) | 0x07;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
+  ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; });
 
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD temp = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2849, temp) ; };
+  if( temp < MPD_current_offset )
+  {
+   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "No Tx power, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2852, MPD_current_offset) ; };
+   global_MPD_current = MPD_current_offset;
+   return global_MPD_current;
+  }
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- ptr[3] = (ptr[3]&0x7f) | 0x80;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+  if( vEN7570 == 0 && TEC_switch )
+  {
+   int div = 0;
+   int MPD_current_up = get_flash_register((0x088));
+   int MPD_current_dn = MPD_current_offset;
+   float slope = 0;
+   float tx_power = 0;
+   int tx_power_up = 0;
+   int tx_power_dn = 0;
+   UINT16 tx_power_8472 = 0;
+   int TX_POWER_THRESHOLD_up = 0;
+   int TX_POWER_THRESHOLD_dn = 0;
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- vld = (ptr[2]&0x10) >> 4;
- if(vld == 1)
- {
+   div = MPD_current_up - MPD_current_dn;
+   if( div == 0 )
+   {
+    printk("Invalid content of FLASH 0x88\n");
+    global_MPD_current = temp;
+    return global_MPD_current;
+   }
+   else
+   {
+    if( xPON_mode == PHY_GPON_CONFIG )
+    {
+     { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "GPON mode\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2881) ; };
+     tx_power_up = 0xb1;
+     TX_POWER_THRESHOLD_up = 25118;
+     TX_POWER_THRESHOLD_dn = 12589;
+    }
+    else if( xPON_mode == PHY_EPON_CONFIG )
+    {
+     { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "EPON mode\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2888) ; };
+     tx_power_up = 0x9e;
+     TX_POWER_THRESHOLD_up = 22387;
+     TX_POWER_THRESHOLD_dn = 11220;
+    }
 
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
-  ADC = ( (ptr[2]<<16) | (ptr[1]<<8) | ptr[0] ) & 0xfffff;
-  ADC = ADC >> 4;
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "PWRADC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2373, ADC) ; };
- }
+    slope = (float)(tx_power_up-tx_power_dn)/(float)(MPD_current_up-MPD_current_dn);
+    tx_power = (float)(temp-MPD_current_dn)*slope + tx_power_dn;
+    tx_power_8472 = (int)(10*tx_power)/0.1;
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
- ptr[3] = ptr[3]&0xf8;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4);
+    if( global_MPD_current_var==0 && tx_power_8472>TX_POWER_THRESHOLD_up)
+    {
+     MPD_current_cnt += 1;
+     if( MPD_current_cnt == 2)
+      global_MPD_current_var = temp - get_flash_register((0x088));
+    }
+    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD current var = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2904, global_MPD_current_var) ; };
 
- if( ADC < en7571_PWRADC_offset )
- {
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Tx off, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2382, en7571_PWRADC_offset) ; };
-  en7571_PWRADC = en7571_PWRADC_offset;
- }
- else
- {
-  en7571_PWRADC = ADC;
+    if( tx_power_8472>TX_POWER_THRESHOLD_up && global_MPD_current_var!=0 )
+    {
+     { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 1, Tx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2908, tx_power_8472) ; };
+     temp -= global_MPD_current_var;
+     { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "temp(var) = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2910, temp) ; };
+     tx_power = (float)(temp-MPD_current_dn)*slope + tx_power_dn;
+     tx_power_8472 = (int)(10*tx_power)/0.1;
+     if( tx_power_8472>TX_POWER_THRESHOLD_up || tx_power_8472<TX_POWER_THRESHOLD_dn)
+     {
+      { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 1a, Tx_power_8472 = %d, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2915, tx_power_8472, global_MPD_current) ; };
+      global_MPD_current_var = 0;
+      MPD_current_cnt = 1;
+      return global_MPD_current;
+     }
+     else
+     {
+      { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 1b, Tx_power_8472 = %d, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2922, tx_power_8472, temp) ; };
+      global_MPD_current = temp;
+      return global_MPD_current;
+     }
+    }
+    else if( tx_power_8472>TX_POWER_THRESHOLD_up && global_MPD_current_var==0 )
+    {
+     { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 2, Tx_power_8472 = %d, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2929, tx_power_8472, MPD_current_up) ; };
+     global_MPD_current = MPD_current_up;
+     return global_MPD_current;
+    }
+    else
+    {
+     { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 3, Tx_power_8472 = %d, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2935, tx_power_8472, temp) ; };
+     global_MPD_current = temp;
+     return global_MPD_current;
+    }
+   }
+  }
+  else
+  {
+   global_MPD_current = temp;
+   return global_MPD_current;
+  }
  }
-
- return en7571_PWRADC;
 }
-# 2407 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT16 en7571_RxPower_get_8472(void)
+# 2961 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+UINT16 mt7570_RxPower_get_8472(void)
 {
- UINT32 read_data = 0;
+ int read_data = 0;
 
- UINT32 RSSI_current_now = 0;
+ int RSSI_current = 0;
 
- float rx_power_now = 0;
+ int rx_power = 0;
  UINT16 rx_power_8472 = 0;
 
  float div = 0;
  float slope = 0;
- UINT32 RSSI_current_up = 0;
- UINT32 RSSI_current_md = 0;
- UINT32 RSSI_current_dn = 0;
-
- UINT32 rx_power_up = 0;
- UINT32 rx_power_md = 0;
- UINT32 rx_power_dn = 0;
+ int RSSI_current_up = 0;
+ int RSSI_current_md = 0;
+ int RSSI_current_dn = 0;
+
+ int rx_power_up = 0;
+ int rx_power_md = 0;
+ int rx_power_dn = 0;
 
  float RSSI_current_1, RSSI_current_2, RSSI_current_3, Rx_power_K1, Rx_power_K2, Rx_power_K3;
  static float d, e, f, g, x, y, z;
 
  if( (get_flash_register((0x05c))&0x0000000f) == 1 )
  {
-  if (en7571_DDMI_rx_cal_flag == 0)
+  if (global_DDMI_rx_cal_flag == 0)
   {
    read_data = get_flash_register((0x050));
    RSSI_current_1 = read_data & 0x0000ffff;
@@ -50264,7 +50409,7 @@
 
     if(d==0)
     {
-        { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid DDMI Rx power-RSSI mapping curve \n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2453) ; };
+        { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid DDMI Rx power-RSSI mapping curve \n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3007) ; };
     }
    else
    {
@@ -50273,21 +50418,20 @@
     z=g/d;
    }
 
-   en7571_DDMI_rx_cal_flag = 1;
+   global_DDMI_rx_cal_flag = 1;
   }
 
-  RSSI_current_now = en7571_RSSI_get();
-  rx_power_now = (float) RSSI_current_now*RSSI_current_now*x + (float)RSSI_current_now*y + z;
-
-  if(rx_power_now < 0)
-   rx_power_now = 0;
+  RSSI_current = mt7570_RSSI_current();
+  rx_power = (float) RSSI_current*RSSI_current*x + (float)RSSI_current*y + z;
 
+  if(rx_power < 0)
+   rx_power = 0;
 
 
  }
  else
  {
-  RSSI_current_now = en7571_RSSI_get();
+  RSSI_current = mt7570_RSSI_current();
   if( get_flash_register((0x050)) != 0xffffffff )
   {
    read_data = get_flash_register((0x050));
@@ -50307,1570 +50451,1175 @@
    rx_power_dn = (read_data & 0xffff0000) >> 16;
   }
 
-  if( RSSI_current_now <= RSSI_current_dn )
+  if( RSSI_current <= RSSI_current_dn )
   {
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 1\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2498) ; };
+   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 1\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3051) ; };
    div = RSSI_current_dn;
 
-   if(RSSI_current_dn!=0)
+   if(RSSI_current_dn !=0)
    {
     slope = (float)rx_power_dn/(float)RSSI_current_dn;
-    rx_power_now = RSSI_current_now*slope;
+    rx_power = RSSI_current*slope;
    }
    else
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2507) ; };
+    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3060) ; };
   }
-  else if( (RSSI_current_dn < RSSI_current_now) && (RSSI_current_now < RSSI_current_md) )
+  else if( (RSSI_current_dn < RSSI_current) && (RSSI_current < RSSI_current_md) )
   {
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 2\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2511) ; };
+   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 2\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3064) ; };
    div = RSSI_current_md-RSSI_current_dn;
    if(div != 0)
    {
     slope = (float)(rx_power_md-rx_power_dn)/(float)(RSSI_current_md-RSSI_current_dn);
-    rx_power_now = (RSSI_current_now-RSSI_current_dn)*slope + rx_power_dn;
+    rx_power = (RSSI_current-RSSI_current_dn)*slope + rx_power_dn;
    }
    else
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2519) ; };
+    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3072) ; };
   }
-  else if( RSSI_current_md <= RSSI_current_now )
+  else if( RSSI_current_md <= RSSI_current )
   {
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 3\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2523) ; };
+   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 3\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3076) ; };
    div = RSSI_current_up-RSSI_current_md;
    if(div != 0)
    {
     slope = (float)(rx_power_up-rx_power_md)/(float)(RSSI_current_up-RSSI_current_md);
-    rx_power_now = (RSSI_current_now-RSSI_current_md)*slope + rx_power_md;
+    rx_power = (RSSI_current-RSSI_current_md)*slope + rx_power_md;
    }
    else
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2531) ; };
+    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3084) ; };
   }
  }
 
 
- rx_power_8472 = rx_power_now/10;
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2537, rx_power_8472) ; };
+ rx_power_8472 = rx_power/10;
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3090, rx_power_8472) ; };
  return rx_power_8472;
 }
-# 2548 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_safe_circuit_reset(void)
+# 3108 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_safe_circuit_reset(void)
 {
  unchar ptr[4];
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0100), ptr, 4);
  ptr[1] = (ptr[1] & 0xbf) | (0x40);
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0100), ptr, 4);
 }
-# 2570 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-UINT16 en7571_TxPower_get_8472(void)
+# 3128 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+UINT16 mt7570_TxPower_get_8472(void)
 {
  int div = 0;
- UINT32 read_data = 0;
- UINT32 PWRADC_now = 0;
- UINT32 PWRADC_up = 0;
- UINT32 PWRADC_dn = en7571_PWRADC_offset;
+ int read_data = 0;
+ int MPD_current = 0;
+ int MPD_current_up = 0;
+ int MPD_current_dn = MPD_current_offset;
  float slope = 0;
- float tx_power_now = 0;
- UINT32 tx_power_up = 0;
- UINT32 tx_power_dn = 0;
+ float tx_power = 0;
+ int tx_power_up = 0;
+ int tx_power_dn = 0;
  UINT16 tx_power_8472 = 0;
 
- PWRADC_now = en7571_PWRADC_get();
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "PWRADC_now = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2584, PWRADC_now) ; };
- if( get_flash_register((0x040)) != 0xffffffff)
+ MPD_current = mt7570_MPD_current();
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD_current = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3142, MPD_current) ; };
+ if( get_flash_register((0x040)) != 0xffffffff )
  {
   read_data = get_flash_register((0x040));
-  PWRADC_up = read_data & 0x0000ffff;
+  MPD_current_up = read_data & 0x0000ffff;
   tx_power_up = (read_data & 0xffff0000)>>16;
  }
-
- div = PWRADC_up - PWRADC_dn;
+ if( get_flash_register((0x044)) != 0xffffffff )
+ {
+  read_data = get_flash_register((0x044));
+  MPD_current_dn = read_data & 0x0000ffff;
+  tx_power_dn = (read_data & (0xffff0000))>>16;
+ }
+ div = MPD_current_up - MPD_current_dn;
  if( div != 0 )
  {
-  slope = (float)(tx_power_up-tx_power_dn)/(float)(PWRADC_up-PWRADC_dn);
-  tx_power_now = (float)(PWRADC_now-PWRADC_dn)*slope + tx_power_dn;
+  slope = (float)(tx_power_up-tx_power_dn)/(float)(MPD_current_up-MPD_current_dn);
+  tx_power = (float)(MPD_current-MPD_current_dn)*slope + tx_power_dn;
  }
  else
  {
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Tx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2600) ; };
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Tx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3163) ; };
  }
 
-
- if( en7571_DOL == 1 )
-  if( (gpPhyPriv->phyCfg.flags.trafficStatus!=TRAFFIC_STATUS_DOWN) || (en7571_PatternEnabled==1) )
-   tx_power_now = tx_power_up;
-
- tx_power_8472 = (int)(10*tx_power_now)/0.1;
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Tx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2609, tx_power_8472) ; };
+ tx_power_8472 = (int)(10*tx_power)/0.1;
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Tx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3167, tx_power_8472) ; };
  return tx_power_8472;
 }
-# 2620 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_internal_clock(void)
+# 3181 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_internal_clock(void)
 {
- static UINT32 cnt;
 
 
- if( en7571_internal_DDMI == 1 )
+ if( internal_DDMI == 1 )
  {
-  if(cnt%en7571_Tapd == en7571_Tapd-1)
+  if(cnt7570%T_APD == T_APD-1)
   {
 
-   if( en7571_xPON_mode == PHY_GPON_CONFIG )
-    en7571_APD_control();
+   if( xPON_mode == PHY_GPON_CONFIG )
+    mt7570_APD_control();
   }
-  if(cnt%10 == 0 || en7571_fast_DDMI)
-   en7571_DDMI_voltage = en7571_supply_voltage_get_8472();
+  if(cnt7570%10 == 0 || fast_DDMI)
+   DDMI_voltage = mt7570_supply_voltage_get_8472();
 
-  if(cnt%10 == 2 || en7571_fast_DDMI)
-   en7571_DDMI_current = en7571_bias_current_get_8472();
 
-  if(cnt%10 == 4 || en7571_fast_DDMI)
-   en7571_DDMI_temperature = en7571_temperature_get_8472();
+  DDMI_current = mt7570_bias_current_get_8472();
 
-  if(cnt%10 == 6 || en7571_fast_DDMI)
+  if(cnt7570%10 == 4 || fast_DDMI)
+   DDMI_temperature = mt7570_temperature_get_8472();
+  if(cnt7570%10 == 6 || fast_DDMI)
   {
-   en7571_DDMI_tx_power = en7571_TxPower_get_8472();
-   en7571_tx_power_alarm_get();
+   DDMI_tx_power = mt7570_TxPower_get_8472();
+   mt7570_tx_power_alarm_get();
   }
-  if(cnt%10 == 8 || en7571_fast_DDMI)
+  if(cnt7570%10 == 8 || fast_DDMI)
   {
-   en7571_DDMI_rx_power = en7571_RxPower_get_8472();
-   en7571_rx_power_alarm_get();
-  }
-  if(cnt%10 == 9)
-  {
-   en7571_WatchDog();
+   DDMI_rx_power = mt7570_RxPower_get_8472();
+   mt7570_rx_power_alarm_get();
   }
  }
- else if( en7571_internal_DDMI == -1 )
- {
-  printk("Loop Frozen\n");
-  return;
- }
 
- if((en7571_sys_mode != 0) || (en7571_PatternEnabled==1) )
+
+
+
+ if ( SCL == 1 )
  {
-  if(1)
+  if( cnt7570%29 == 0 )
   {
-   if( en7571_KT != 0 )
-    en7571_SWKT();
-   else if( (en7571_SCL == 1) || (en7571_DOL ==1) )
-    en7571_LUT_Tracking();
+   if ( ETC == 3 )
+   {
+
+
+
+     mt7570_BiasTracking();
+   }
   }
  }
+ else if ( DOL == 1 )
+ {
+  if( cnt7570%5 == 0 )
+   mt7570_OpenLoopControl();
+ }
  else
  {
-  if( (en7571_SCL == 1) || (en7571_DOL ==1) )
-  {
-   if( (cnt%30)==(30 -3) )
-    en7571_LUT_Tracking();
-  }
-  else
-  {
-   en7571_islinkstauschange();
 
-   if((cnt%30)==(30 -3) )
+  if( xPON_mode != -1 && FiberPlug == 1 && PatternEnabled == 1 )
+   mt7570_FiberPlug_Protect();
+
+
+  if( cnt7570%30 == 29 )
+  {
+   if ( ETC == 1 )
    {
-    if( en7571_KT != 0 )
-     en7571_OPKT();
+    mt7570_ERTemperatureCompensation();
    }
-   else
+   else if ( ETC == 2 )
    {
-    if(en7571_Pav_loop !=0)
-     en7571_Pavg_close_loop();
-   }
 
-   if(cnt%5 == 2)
+   }
+   else if ( ETC == 3 )
    {
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Ibias_DAC now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2697, Ibias_linkup_now) ; };
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Imod_DAC now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2698, Imod_linkup_now) ; };
-    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Iav_DAC_now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2699, Iav_linkup_now) ; };
+    if( PatternEnabled || BiasTracking_switch )
+     mt7570_BiasTracking();
    }
+
   }
+
+
+
+  if( TEC != 0 && TEC_switch == 1 )
+   mt7570_TxEyeCorrection();
+
  }
- cnt ++;
+
+
+
+ if( cnt7570%120 == 119 )
+ {
+  if( xPON_mode != -1 )
+   mt7570_ADC_calibration();
+ }
+
+
+
+ cnt7570 ++;
+
 }
-# 2718 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_param_status_real(PPHY_TransParam_T transceiver_param)
+# 3291 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_param_status_real(PPHY_TransParam_T transceiver_param)
 {
 
- transceiver_param->temprature = en7571_DDMI_temperature;
- transceiver_param->supply_voltage = en7571_DDMI_voltage;
- transceiver_param->tx_current = en7571_DDMI_current;
- transceiver_param->tx_power = en7571_DDMI_tx_power;
- transceiver_param->rx_power = en7571_DDMI_rx_power;
+ transceiver_param->temprature = DDMI_temperature;
+ transceiver_param->supply_voltage = DDMI_voltage;
+ transceiver_param->tx_current = DDMI_current;
+ transceiver_param->tx_power = DDMI_tx_power;
+ transceiver_param->rx_power = DDMI_rx_power;
 }
-# 2741 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_DDMI_check_8472(void)
+# 3312 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void DDMI_check_8472(void)
 {
- en7571_DDMI_voltage = en7571_supply_voltage_get_8472();
- en7571_DDMI_current = en7571_bias_current_get_8472();
- en7571_DDMI_temperature = en7571_temperature_get_8472();
- en7571_DDMI_tx_power = en7571_TxPower_get_8472();
- en7571_DDMI_rx_power = en7571_RxPower_get_8472();
+ DDMI_voltage = mt7570_supply_voltage_get_8472();
+ DDMI_current = mt7570_bias_current_get_8472();
+ DDMI_temperature = mt7570_temperature_get_8472();
+ DDMI_tx_power = mt7570_TxPower_get_8472();
+ DDMI_rx_power = mt7570_RxPower_get_8472();
 
- printk("Supply Voltage = %05d\n" , en7571_DDMI_voltage );
- printk("Tx Bias Current = %05d\n", en7571_DDMI_current );
- printk("Temperature = %05d\n" , en7571_DDMI_temperature);
- printk("Tx power = %05d\n" , en7571_DDMI_tx_power );
- printk("Rx Power = %05d\n" , en7571_DDMI_rx_power );
+ printk("Supply Voltage = %05d\n" , DDMI_voltage );
+ printk("Tx Bias Current = %05d\n", DDMI_current );
+ printk("Temperature = %05d\n" , DDMI_temperature);
+ printk("Tx power = %05d\n" , DDMI_tx_power );
+ printk("Rx Power = %05d\n" , DDMI_rx_power );
 }
-# 2763 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-extern struct work_struct work_mt7571_safe_circuit_reset;
+# 3338 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+extern struct work_struct work_mt7570_safe_circuit_reset;
 
-void en7571_trans_model_setting(void)
+void mt7570_trans_model_setting(void)
 {
 
 
-  gpPhyPriv->phy_xpon_trans_val = 0x14f;
+        gpPhyPriv->phy_xpon_trans_val = 0x10f;
 
 
 
-
-
-
-
-  if(((void *)0) != i2c_access_queue){
-   queue_work(i2c_access_queue, &work_mt7571_safe_circuit_reset);
-  }
+        if(((void *)0) != i2c_access_queue){
+            queue_work(i2c_access_queue, &work_mt7570_safe_circuit_reset);
+        }
 
 
 
 
 }
-# 2793 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_trans_alarm_getting(PPHY_TransAlarm_T transceiver_alarm)
+# 3368 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_trans_alarm_getting(PPHY_TransAlarm_T transceiver_alarm)
 {
   transceiver_alarm->rx_power_high_alarm_thod = 0;
   transceiver_alarm->rx_power_low_alarm_thod = 0;
   transceiver_alarm->tx_power_high_alarm_thod = 0;
   transceiver_alarm->tx_power_low_alarm_thod = 0;
 
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power high alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2800, transceiver_alarm->rx_power_high_alarm_thod) ; };
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power low alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2801, transceiver_alarm->rx_power_low_alarm_thod) ; };
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "tx power high alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2802, transceiver_alarm->tx_power_high_alarm_thod) ; };
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power low alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2803, transceiver_alarm->tx_power_low_alarm_thod) ; };
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power high alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3375, transceiver_alarm->rx_power_high_alarm_thod) ; };
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power low alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3376, transceiver_alarm->rx_power_low_alarm_thod) ; };
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "tx power high alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3377, transceiver_alarm->tx_power_high_alarm_thod) ; };
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power low alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3378, transceiver_alarm->tx_power_low_alarm_thod) ; };
 }
-# 2819 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_tx_power_alarm_get(void)
+# 3392 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_tx_power_alarm_get(void)
 {
- if(en7571_DDMI_tx_power < 0x2710)
-  en7571_alarm |= PHY_TRANS_TX_LOW_POWER_ALARM;
+ if(DDMI_tx_power < 0x2710)
+  mt7570_alarm |= PHY_TRANS_TX_LOW_POWER_ALARM;
  else
-  en7571_alarm &= ~(PHY_TRANS_TX_LOW_POWER_ALARM);
+  mt7570_alarm &= ~(PHY_TRANS_TX_LOW_POWER_ALARM);
 
- if(en7571_DDMI_tx_power > 0x8a99)
-  en7571_alarm |= PHY_TRANS_TX_HIGH_POWER_ALARM;
+ if(DDMI_tx_power > 0x8a99)
+  mt7570_alarm |= PHY_TRANS_TX_HIGH_POWER_ALARM;
  else
-  en7571_alarm &= ~(PHY_TRANS_TX_HIGH_POWER_ALARM);
+  mt7570_alarm &= ~(PHY_TRANS_TX_HIGH_POWER_ALARM);
 
- if(en7571_DDMI_current < 0x1f4)
-  en7571_alarm |= PHY_TRANS_TX_LOW_CUR_ALARM;
+ if(DDMI_current < 0x1f4)
+  mt7570_alarm |= PHY_TRANS_TX_LOW_CUR_ALARM;
  else
-  en7571_alarm &= ~(PHY_TRANS_TX_LOW_CUR_ALARM);
+  mt7570_alarm &= ~(PHY_TRANS_TX_LOW_CUR_ALARM);
 
- if(en7571_DDMI_current > 0xc350)
-  en7571_alarm |= PHY_TRANS_TX_HIGH_CUR_ALARM;
+ if(DDMI_current > 0xc350)
+  mt7570_alarm |= PHY_TRANS_TX_HIGH_CUR_ALARM;
  else
-  en7571_alarm &= ~(PHY_TRANS_TX_HIGH_CUR_ALARM);
+  mt7570_alarm &= ~(PHY_TRANS_TX_HIGH_CUR_ALARM);
+
 }
-# 2855 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_rx_power_alarm_get(void)
+# 3427 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_rx_power_alarm_get(void)
 {
- if(en7571_DDMI_rx_power < 0xa)
-  en7571_alarm |= PHY_TRANS_RX_LOW_POWER_ALARM;
+ if(DDMI_rx_power < 0xa)
+  mt7570_alarm |= PHY_TRANS_RX_LOW_POWER_ALARM;
  else
-  en7571_alarm &= ~(PHY_TRANS_RX_LOW_POWER_ALARM);
+  mt7570_alarm &= ~(PHY_TRANS_RX_LOW_POWER_ALARM);
+
 
- if(en7571_DDMI_rx_power > 0x9cf)
-  en7571_alarm |= PHY_TRANS_RX_HIGH_POWER_ALARM;
+ if(DDMI_rx_power > 0x9cf)
+  mt7570_alarm |= PHY_TRANS_RX_HIGH_POWER_ALARM;
  else
-  en7571_alarm &= ~(PHY_TRANS_RX_HIGH_POWER_ALARM);
+  mt7570_alarm &= ~(PHY_TRANS_RX_HIGH_POWER_ALARM);
 }
-# 2882 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-int en7571_EN7571_detection(void)
+# 3453 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+int mt7570_EN7570_detection(void)
 {
  unchar ptr[1];
- UINT8 read_data_1 = 0;
- UINT8 read_data_2 = 0;
-
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0170), ptr, 1);
- read_data_1 = ptr[0];
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 1);
- read_data_2 = ptr[0];
-
- if( (read_data_1 == 0x03) && (read_data_2 >= 0x03) )
+ if( ptr[0] == 0x03 )
  {
-  en7571_select = 1;
-
-  printk("E3 patched\n");
-  {
-   en7571_ver = 2;
-   en7571_sys_mode = 0;
-  }
-
+  mt7570_select = 1;
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 1);
+  vEN7570 = ptr[0];
   return 1;
  }
  else
+ {
+  mt7570_select = 0;
   return 0;
+ }
 }
-# 2919 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-int en7571_LOS_calibration(int LOS_thld_H, int LOS_thld_L)
+# 3483 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void LOS_calibration(int LOS_thld_H, int LOS_thld_L)
 {
  unchar ptr[4];
- int LOS_status = 0;
 
+ mt7570_LOS_init();
+# 3506 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
  ptr[3] = (ptr[3] & (0x80)) | LOS_thld_L;
  ptr[2] = (ptr[2] & (0x80)) | LOS_thld_H;
  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
- ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
-
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0130), ptr, 4);
- LOS_status = ptr[3] & 0x01;
- return LOS_status;
+ printk("%s done\n", __FUNCTION__);
 }
+# 3525 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_ERC_filter(void)
+{
+ unchar ptr[4];
 
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x016C), ptr, 4);
+ ptr[2] = 0x58;
+ ptr[1] = 0xa7;
+ ptr[0] = 0xff;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x016C), ptr, 4);
+
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x016C), ptr, 4);
+ ptr[3] = (ptr[3] & 0xfe) | (0x01);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x016C), ptr, 4);
 
-
-
-float en7571_Taylor_series(float input)
+ printk("ERC filter set\n");
+}
+# 3553 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_TIAGAIN_set(void)
 {
- int i = 0;
- float temp = 0;
- float temp_2 = 0;
- float temp_3 = 0;
+ unchar ptr[1];
+ uint read_data = 0;
 
- for ( i=0; i<7 ; i++)
+ if( get_flash_register((0x028)) != 0xffffffff )
  {
-  if ( input >= 5 )
-   input = input/10;
-  else
-   break;
- }
-
- temp = (input-1)/input;
- temp_2 = temp*temp;
- temp_3 = temp*temp_2;
-
- temp = temp + temp_2/2 + temp_3/3 + (temp_2*temp_2)/4 + (temp_2*temp_3)/5 + (temp_3*temp_3)/6;
- temp = temp/2.302585093;
- temp -= 4-i;
- temp *= 10;
+  read_data = get_flash_register((0x028)) & 0x3;
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000)+0x0001 , ptr, 1);
+  ptr[0] = (ptr[0] & 0x3f) | (read_data<<6);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000)+0x0001, ptr, 1);
 
- return temp;
+  printk("TIAGAIN set 0x%x\n", read_data);
+ }
 }
-# 2973 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_BoB_info(void)
+# 3582 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void show_BoB_information(void)
 {
  unchar ptr[4];
  float temp = 0;
  int a = 0;
  int b = 0;
+ int i ;
 
 
- printk("Driver version = %d\n", en7571_version);
-
 
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0130), ptr, 4);
  ptr[3] = ptr[3] & 0x1;
- printk("LOS = %d\n", ptr[3]);
+ printk("LOS status = %d\n", ptr[3]);
+
+
+
+
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168), ptr, 2);
+ ptr[1] = (ptr[1]>>2 & 0x1);
+ printk("Rouge ONU status = %d\n", ptr[1]);
 
 
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168), ptr, 2);
  ptr[1] = (ptr[1]>>3 & 0x1);
- printk("Tx SD = %d\n", ptr[1]);
+ printk("Tx SD status = %d\n", ptr[1]);
 
 
  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0100), ptr, 2);
  ptr[1] = (ptr[1]>>7 & 0x1);
- printk("Tx fault = %d\n", ptr[1]);
+ printk("Tx fault status = %d\n", ptr[1]);
 
 
- temp = (float)en7571_info(0x03)*0.02442;
+ temp = (float)mt7570_information_output(0x03)*0.02442;
  a = (int)temp;
  b = (int)(temp*100)%100;
  printk("I bias = %d.%.2dmA\n", a, b);
 
 
- temp = (float)en7571_info(0x04)*0.02198;
+ temp = (float)mt7570_information_output(0x04)*0.02198;
  a = (int)temp;
  b = (int)(temp*100)%100;
  printk("I mod = %d.%.2dmA\n", a, b);
 
 
- if( en7571_DOL != 1 )
- {
-  if((gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_UP) &&(en7571_sys_mode ==0))
-  {
-   temp = (float)Iav_linkup_now*0.02198;
-   a = (int)temp;
-   b = (int)(temp*100)%100;
-   printk("I av = %d.%.2dmA\n", a, b);
-  }
-  else
-  {
-   temp = (float)en7571_info(0x02)*0.02198;
-   a = (int)temp;
-   b = (int)(temp*100)%100;
-   printk("I av = %d.%.2dmA\n", a, b);
-  }
- }
-
- a = (int)en7571_IC_temperature;
- b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(en7571_IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
- printk("IC temperature = %d.%d'C\n", a, b);
- a = (int)en7571_BOSA_temperature;
- printk("BOSA temperature = %d.%d'C\n", a, b);
- a = (int)en7571_Env_temperature;
- printk("Enviroment temperature = %d.%d'C\n", a, b);
+ a = (int)IC_temperature;
+ b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
+ printk("IC temperature = %d.%dC\n", a, b);
+ a = (int)BOSA_temperature;
+ printk("BOSA temperature = %d.%dC\n", a, b);
+ a = (int)Env_temperature;
+ b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), char), (char)({ signed char __x = ((int)(Env_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
+ printk("Enviroment temperature = %d.%dC\n", a, b);
 
 
- a = (int)en7571_APD_voltage;
- b = (int)(en7571_APD_voltage*10)%10;
+ a = (int)APD_voltage;
+ b = (int)(APD_voltage*10)%10;
  printk("APD Voltage = %d.%dV\n", a, b);
 
 
- a = (int)en7571_DDMI_voltage/10000;
- b = (int)en7571_DDMI_voltage%10000;
- printk("VCC = %d.%.2dV\n", a, b);
+ a = (int)global_supply_voltage_8472/10000;
+ b = (int)global_supply_voltage_8472%10000;
+ printk("VCC = %d.%.4dV\n", a, b);
 
 
- if( en7571_DDMI_tx_power == 0 )
+ temp = (float)DDMI_tx_power/1000/10;
+ if( temp == 0 )
   printk("Tx power = -40 dBm\n");
  else
  {
-  temp = en7571_Taylor_series( (float)en7571_DDMI_tx_power );
+  temp = (temp-1)/temp;
+  temp = temp + (temp*temp)/2 + (temp*temp*temp)/3 + (temp*temp*temp*temp)/4 + (temp*temp*temp*temp*temp)/5 + (temp*temp*temp*temp*temp*temp)/6;
+  temp = temp/2.302585093;
+  temp *= 10;
   a = (int)temp;
   b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed long long) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned long long), ({ signed long long __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed long) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned long), ({ signed long __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed int) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned int), ({ signed int __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed short) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned short), ({ signed short __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed char) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned char), ({ signed char __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), char), (char)({ signed char __x = ((int)(temp*100)%100); __x<0?-__x:__x; }), ((void)0)))))));
   printk("Tx power = %d.%.2d dBm\n", a, b);
  }
 
 
- if( en7571_DDMI_rx_power == 0 )
+ temp = (float)DDMI_rx_power;
+ for ( i=0; i<7 ; i++)
+ {
+  if ( temp >= 5)
+   temp = temp/10;
+  else
+   break;
+ }
+
+ if( temp == 0 )
   printk("Rx power = -40 dBm\n");
  else
  {
-  temp = en7571_Taylor_series( (float)en7571_DDMI_rx_power );
+  temp = (temp-1)/temp;
+  temp = temp + (temp*temp)/2 + (temp*temp*temp)/3 + (temp*temp*temp*temp)/4 + (temp*temp*temp*temp*temp)/5 + (temp*temp*temp*temp*temp*temp)/6 + (temp*temp*temp*temp*temp*temp*temp)/7 +(temp*temp*temp*temp*temp*temp*temp*temp)/8 ;
+  temp = temp/2.302585093;
+  temp -= 4-i;
+  temp *= 10;
   a = (int)temp;
   b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed long long) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned long long), ({ signed long long __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed long) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned long), ({ signed long __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed int) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned int), ({ signed int __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed short) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned short), ({ signed short __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed char) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned char), ({ signed char __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), char), (char)({ signed char __x = ((int)(temp*100)%100); __x<0?-__x:__x; }), ((void)0)))))));
   printk("Rx power = %d.%.2d dBm\n", a, b);
  }
 }
-# 3077 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_LOS_init(void)
+# 3696 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_TxEyeCorrection(void)
 {
+ uint MPDL = 0;
  unchar ptr[4];
+ static int TEC_cnt = 0;
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
- ptr[0] = (ptr[0] & (0xfe)) | (0x01);
+ if( TEC_cnt > 7 )
+  return;
 
- ptr[1] = (ptr[1] & (0xe0)) | (0x1f);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
+ if ( (global_bias_current_8472<<1) < BOSA_Ith )
+ {
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4);
- ptr[3] = (ptr[3] & (0xfb)) | (0x04);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4);
+  if( (ptr[0]&0x0f) == 0x5 )
+  {
+   MPDL = mt7570_information_output(0x05) + 0x4;
+   ptr[0] = MPDL;
+   ptr[1] = MPDL >> 8;
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4);
- ptr[2] = (ptr[2] & (0xbf)) | (0x40);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4);
+   mt7570_restart_ERC_P0();
+   printk("TEC done\n");
+   TEC_cnt++;
+  }
+
+
+
+
+ }
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0120), ptr, 4);
- ptr[1] = (ptr[1] & (0xe0)) | (0x1f);
 
- ptr[0] = (ptr[0] & (0x80)) | (0x05);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0120), ptr, 4);
 }
-# 3111 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_fine_tune_PWR_ER(int pwr_er,int up_dn)
+# 3742 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_OpenLoopMode(void)
 {
  unchar ptr[4];
- int pav = 0;
- int p1 = 0;
 
- en7571_ERC = 0;
- en7571_KT = 0;
 
- pav = en7571_info(0x01);
- p1 = en7571_info(0x06);
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
+ ptr[0] = (ptr[0] & 0xfc) | 0x02;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
 
- if( pwr_er )
- {
-  if( up_dn )
-   pav += 0x004;
-  else
-   pav -= 0x004;
 
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
+ ptr[0] = (ptr[0] & 0xfc) | 0x02;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
 
-  if( pav > 0xfff )
-   pav = 0xfff;
-  else if( pav < 0 )
-   pav = 0;
- }
- else
- {
-  if( up_dn )
-   p1 += 0x001;
-  else
-   p1 -= 0x001;
+ printk("Switch to Open-Loop Mode\n");
+}
+# 3770 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void Ibias_temperature_set(void)
+{
+ int a = 0;
+ int b = 0;
+ int read_data = 0;
+ unchar ptr[4];
+ float temp = 0;
+ mt7570_temperature_get();
+ a = (int)IC_temperature;
 
+ read_data = get_flash_register((0x060));
+ read_data = (read_data & 0xffff0000 ) | a;
+ set_flash_register(read_data ,(0x060));
+ printk("tempature %d degree save done\n",a);
+
+
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2);
+ read_data = get_flash_register((0x060));
+ read_data = ((read_data & 0x0000ffff )|( ptr[0] << 16 ) |( ptr[1] << 24 ));
+ set_flash_register(read_data ,(0x060));
 
-  if( p1 > 0x3ff )
-   p1 = 0x3ff;
-  else if( p1 < 0 )
-   p1 = 0;
- }
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
- ptr[0] = pav;
- ptr[1] = (pav >> 8);
- ptr[2] = p1;
- ptr[3] = (p1 >> 8);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
 
 
+ temp = (float)mt7570_information_output(0x03)*0.02442;
+ a = (int)temp;
+ b = (int)(temp*100)%100;
+ printk("Ibias current = %d.%.2dmA \n", a, b);
 
 }
-# 3168 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_SWKT(void)
+# 3815 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_DualClosedLoopMode(void)
 {
- int need_ERC = 0;
- int Imod_delta = 0;
- int ratio_now = 0;
+ unchar ptr[4];
 
- UINT32 Iav_cal = 0;
- UINT32 Imod_cal = 0;
- UINT32 Imod_now = 0;
- UINT32 MPDH_cal = 0;
- UINT32 Imod_target = 0;
- UINT32 factor_HT = 0;
- UINT32 factor_LT = 0;
 
- float Iav_delta = 0;
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
+ ptr[0] = (ptr[0] & 0xfc) | 0x01;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
 
- static int activated;
 
- Iav_cal = (get_flash_register((0x000))&0x0fff0000) >> 16;
- ratio_now = ( 100*en7571_info(0x02) )/Iav_cal - 100;
- Imod_cal = get_flash_register((0x000))&0x00000fff;
- Imod_now = en7571_info(0x04);
- factor_HT = get_flash_register((0x064))&0x0000ffff;
- factor_LT = (get_flash_register((0x064))&0xffff0000) >> 16;
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
+ ptr[0] = (ptr[0] & 0xfc) | 0x01;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
 
+ printk("Switch to Dual Closed-Loop Mode\n");
+}
+# 3844 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_Vtemp_ADC_get(void)
+{
+ float sensor_voltage;
 
- Iav_delta = (float)en7571_info(0x02) - (float)Iav_cal;
+ mt7570_ADC_temperature_get();
+ sensor_voltage = ADC_slope*((float)global_temperature_code)+ADC_offset;
+ printk("V_ADC = 0x%x\n", (uint)(sensor_voltage*10000));
+}
+# 3865 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_ERTemperatureCompensation(void)
+{
+ unchar ptr[4];
+ uint read_data = 0;
+ int norm_temp =40;
+ int Power_comp = 0;
 
- if( ratio_now >= 0 )
- {
-  if( en7571_KT == 3 )
-  {
-   Imod_target = (UINT32)( (float)Imod_cal*( 0x400 + (float)ratio_now*(float)factor_HT) );
-   Imod_target = Imod_target>>12;
-  }
-  else
-  {
-   Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 + Iav_delta*(float)factor_HT) );
-   Imod_target = Imod_target>>17;
-  }
+ uint Power_comp_P0_Hi = 0;
+ uint Power_comp_P1_Hi = 0;
+ uint Power_comp_P0_Lo = 0;
+ uint Power_comp_P1_Lo = 0;
 
-  Imod_delta = (int)Imod_target - (int)Imod_now;
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTFACTORHT = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3210, (int)factor_HT) ; };
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTTARGET = 0x%03x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3211, Imod_target) ; };
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTDELTA = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3212, Imod_delta) ; };
+ if((SCL ==1) || (DOL==1))
+  return;
 
-  if( Imod_delta > 0x02e )
-  {
-   MPDH_cal = en7571_info(0x06) + 1;
-   need_ERC = 1;
-  }
-  else if( (-1)*Imod_delta > 0x02e )
-  {
-   MPDH_cal = en7571_info(0x06) - 1;
-   need_ERC = 1;
-  }
- }
- else
+ if( (TEC != 0) && (TEC_switch == 1) )
  {
-  if( en7571_KT == 1 )
-  {
-   Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 + Iav_delta*(float)factor_LT) );
-   Imod_target = Imod_target>>17;
-  }
-  else if( en7571_KT == 2 )
-  {
-   Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 - Iav_delta*(float)factor_LT) );
-   Imod_target = Imod_target>>17;
-  }
-  else if( en7571_KT == 3 )
-  {
-   Imod_target = (UINT32)( (float)Imod_cal*( 0x400 + (float)ratio_now*(float)factor_LT) );
-   Imod_target = Imod_target>>12;
-  }
-
-  Imod_delta = (int)Imod_target - (int)Imod_now;
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTFACTORLT = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3244, (int)factor_LT) ; };
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTTARGET = 0x%03x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3245, Imod_target) ; };
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTDELTA = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3246, Imod_delta) ; };
-
-  if( Imod_delta > 0x02e )
-  {
-   MPDH_cal = en7571_info(0x06) + 1;
-   need_ERC = 1;
-  }
-  else if( (-1)*Imod_delta > 0x02e )
-  {
-   MPDH_cal = en7571_info(0x06) - 1;
-   need_ERC = 1;
-  }
- }
-
-
- if( (en7571_PatternEnabled==1) )
+  if (Ibias_outputlow_flag ==1)
  {
-  if( (ratio_now<-2) || (ratio_now>15) )
-  {
-   if( need_ERC == 1 )
-   {
-    en7571_change_mpdh(MPDH_cal);
-    activated = 1;
-   }
-  }
-  else
-  {
-   if( activated == 1 )
-   {
-    MPDH_cal = get_flash_register((0x004))&0x000003ff;
-    en7571_change_mpdh(MPDH_cal);
-    activated = 0;
-   }
+   printk("Ibias output lower\n");
+   return;
   }
  }
  else
  {
-  if( ratio_now >= 0 )
-   en7571_tune_KT(factor_HT);
-  else
-   en7571_tune_KT(factor_LT);
+  Ibias_outputlow_flag = 0;
  }
-}
-# 3297 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_OPKT(void)
-{
- int Imod_delta = 0;
- int ratio_now = 0;
- int Imod_target_hys = 0 ;
 
- UINT32 Iav_cal = 0;
- UINT32 Imod_cal = 0;
- UINT32 Imod_target = 0;
- UINT32 factor_HT = 0;
- UINT32 factor_LT = 0;
 
- float Iav_delta = 0;
+   printk("ETC\n");
 
- if(gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_UP)
- {
-
-  Iav_cal = (get_flash_register((0x000))&0x0fff0000) >> 16;
-  ratio_now = ( 100*(int)Iav_linkup_now )/Iav_cal - 100;
-  Imod_cal = get_flash_register((0x000))&0x00000fff;
-  factor_HT = get_flash_register((0x064))&0x0000ffff;
-  factor_LT = (get_flash_register((0x064))&0xffff0000) >> 16;
-
-
-  Iav_delta = (float)Iav_linkup_now- (float)Iav_cal;
-
-  if( ratio_now >= 0 )
-  {
-   if( en7571_KT == 3 )
+   if( (get_flash_register((0x060)) != 0xffffffff))
    {
-    Imod_target = (UINT32)( (float)Imod_cal*( 0x400 + (float)ratio_now*(float)factor_HT) );
-    Imod_target = Imod_target>>12;
+    norm_temp = (get_flash_register((0x060)) & 0xff) ;
    }
-   else
+
+   if( (get_flash_register((0x064))&0xff) != 0xff)
    {
-    Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 + Iav_delta*(float)factor_HT) );
-    Imod_target = Imod_target>>17;
+    Power_comp_P0_Hi = (get_flash_register((0x064)) & 0xff) ;
    }
-
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTFACTORHT = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3336, (int)factor_HT) ; };
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTTARGET = 0x%03x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3337, Imod_target) ; };
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTDELTA = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3338, Imod_delta) ; };
-
-  }
-  else
-  {
-   if( en7571_KT == 1 )
+   if( ((get_flash_register((0x064))>>8)&0xff) != 0xff)
    {
-    Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 + Iav_delta*(float)factor_LT) );
-    Imod_target = Imod_target>>17;
+    Power_comp_P1_Hi = ((get_flash_register((0x064))>>8)&0xff) ;
    }
-   else if( en7571_KT == 2 )
+   if( ((get_flash_register((0x064))>>16)&0xff) != 0xff)
    {
-    Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 - Iav_delta*(float)factor_LT) );
-    Imod_target = Imod_target>>17;
+    Power_comp_P0_Lo = ((get_flash_register((0x064))>>16)&0xff) ;
    }
-   else if( en7571_KT == 3 )
+   if( ((get_flash_register((0x064))>>24)&0xff) != 0xff)
    {
-    Imod_target = (UINT32)( (float)Imod_cal*( 0x400 + (float)ratio_now*(float)factor_LT) );
-    Imod_target = Imod_target>>12;
+    Power_comp_P1_Lo = ((get_flash_register((0x064))>>24)&0xff) ;
    }
 
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTFACTORLT = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3359, (int)factor_LT) ; };
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTTARGET = 0x%03x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3360, Imod_target) ; };
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTDELTA = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3361, Imod_delta) ; };
 
-  }
 
 
-  Imod_target_hys = en7571_Imod_hysteresis((int)Imod_linkup_now,(int)Imod_target);
 
-  if(need_crossing_Imod!=1)
-   en7571_change_Imod(Imod_target_hys);
-  else
-  {
-   en7571_cross_Imod(Imod_target_hys);
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Imod Crossing\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3373) ; };
-   en7571_cross_cnt_Imod++;
-   need_crossing_Imod = 0;
-  }
 
 
-  Imod_linkup_now = Imod_target_hys ;
-  en7571_Iavg_transfer();
+   if ( (int)(IC_temperature ) > norm_temp && ((Power_comp_P0_Hi+Power_comp_P1_Hi)!=0))
+   {
+    if((int)IC_temperature > (norm_temp+25))
+     Power_comp = Power_comp_P0_Hi;
+    else
+     Power_comp = (int)(((int)IC_temperature - norm_temp)*((float)Power_comp_P0_Hi/25.0)) ;
 
- }
+    read_data = (get_flash_register((0x008)) & (0x3ff));
 
-}
 
 
+    read_data = read_data + Power_comp ;
+    ptr[0] = read_data;
+    ptr[1] = (read_data >> 8);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2);
+    if((int)IC_temperature > (norm_temp+25))
+     Power_comp = Power_comp_P1_Hi;
+    else
+     Power_comp = (int)(((int)IC_temperature - norm_temp)*((float)Power_comp_P1_Hi/25.0)) ;
 
+    read_data = (get_flash_register((0x00c)) & (0x3ff));
 
-void en7571_change_Imod(UINT32 input)
-{
- unchar ptr[4];
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 4);
- ptr[1] = (ptr[1] & 0xf0) | (input >> 8);
- ptr[0] = (input & 0xff);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 4);
-}
 
+    read_data = read_data + Power_comp ;
+    ptr[0] = read_data;
+    ptr[1] = (read_data >> 8);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2);
 
+                mt7570_TxSD_level_set();
+   }
+   else if ( (int)(IC_temperature ) < (norm_temp-20) && ((Power_comp_P0_Lo+Power_comp_P1_Lo)!=0))
+   {
 
+    if((int)IC_temperature < (norm_temp-30))
+     Power_comp = Power_comp_P0_Lo*(-1);
+    else
+     Power_comp = (int)(((int)IC_temperature - (norm_temp-20))*((float)Power_comp_P0_Lo/10.0)) ;
 
-void en7571_change_Ibias(UINT32 input)
-{
- unchar ptr[4];
+    read_data = (get_flash_register((0x008)) & (0x3ff));
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 4);
- ptr[1] = (ptr[1] & 0xf0) | (input >> 8);
- ptr[0] = (input & 0xff);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 4);
-}
 
 
+    read_data = read_data + Power_comp ;
+    ptr[0] = read_data;
+    ptr[1] = (read_data >> 8);
 
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2);
+    if((int)IC_temperature < (norm_temp-30))
+     Power_comp = Power_comp_P1_Lo*(-1);
+    else
+     Power_comp = (int)(((int)IC_temperature - (norm_temp-20))*((float)Power_comp_P1_Lo/10.0)) ;
 
-void en7571_change_mpdh(UINT32 input)
-{
- unchar ptr[4];
+    read_data = (get_flash_register((0x00c)) & (0x3ff));
 
 
 
+    read_data = read_data + Power_comp ;
+    ptr[0] = read_data;
+    ptr[1] = (read_data >> 8);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2);
+                mt7570_TxSD_level_set();
+   }
+   else
+   {
 
+    read_data = (get_flash_register((0x00c)) & (0x3ff)) | ((get_flash_register((0x008)) & (0x3ff)) << 16);
+    ptr[0] = read_data;
+    ptr[1] = (read_data >> 8);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2 , ptr, 2);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
- ptr[1] = 0x00;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
+    ptr[2] = (read_data >> 16);
+    ptr[3] = (read_data >> 24);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 4);
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
- ptr[2] = input;
- ptr[3] = input>>8;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 );
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
- ptr[1] = 0x02;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4);
+                mt7570_TxSD_level_set();
+   }
 }
-
-
-
-
-void en7571_cross_Imod(UINT32 input)
+# 4019 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void SOL_mt7570_ERTemperatureCompensation(void)
 {
- unchar ptr[2];
- ptr[1] = (input >> 8);
- ptr[0] = (input & 0xff);
-
- if( en7571_cross == 1 )
- {
-  mbi_ctrl_set(0);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr,2);
-  mbi_ctrl_set(1);
- }
- else
- {
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 2);
- }
-}
-
-
+ unchar ptr[4];
+ uint read_data = 0;
 
+ int norm_temp =40;
+ int Power_comp = 0;
 
-void en7571_cross_Ibias(UINT32 input)
-{
+ float temp = 0;
+ int LT_turnning_point = 0;
+ int NT_turnning_point = 0;
+ int HT_turnning_point = 0;
+
+ int LT_turnning_point_ibias = 0;
+ int NT_turnning_point_ibias = 0;
+ int HT_turnning_point_ibias = 0;
+
+ uint Ibias_init_tmp = 0;
+ uint Ibias_slop1 = 0;
+ uint Ibias_slop2 = 0;
+ uint Ibias_slop3 = 0;
+ uint Ibias_slop4 = 0;
 
- unchar ptr[2];
- ptr[1] = (input >> 8);
- ptr[0] = (input & 0xff);
+ uint Power_comp_P1_Hi = 0;
+ uint Power_comp_P1_Lo = 0;
+ int a = 0;
+ int b = 0;
+ int Ibias_set = 0;
 
- if( en7571_cross == 1 )
+ if((get_flash_register((0x060)) | get_flash_register((0x070)) | get_flash_register((0x074)) | get_flash_register((0x00c)) )== 0xffffffff )
  {
-  mbi_ctrl_set(0);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr,2);
-  mbi_ctrl_set(1);
+  printk("SOL wrong flash setting \n");
  }
  else
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2);
-
-}
-# 3491 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
- void en7571_VBR_find(int High , int low)
-{
- unchar ptr[4];
- uint RSSI_voltage = 0x9000;
- unchar APD_DAC[1];
- int read = 0 ;
- int APD_low =0 ;
- int APD_high = 255 ;
- int counter = 1 ;
-
-  en7571_APD_initialization();
-
-  APD_DAC[0] = 0x7f ;
-  while((RSSI_voltage < 0x1000) || (RSSI_voltage> 0x6000))
-  {
-   en7571_APD_I2C_write(APD_DAC);
-   ( (__builtin_constant_p(50) && (50)<=2) ? (__builtin_constant_p((50)*1000) ? (((50)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((50)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((50)*1000)) : ({unsigned long __ms=(50); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
-   RSSI_voltage = en7571_dark_current();
-
-   read = APD_DAC[0] ;
-   if (RSSI_voltage< low)
-    {
-     APD_DAC[0] = (APD_low + read)/2 ;
-     APD_high = read;
-    }
-
-   if(RSSI_voltage > High)
-    {
-     APD_DAC[0] = (APD_high + read)/2 ;
-     APD_low = read ;
-    }
-
-
-   counter ++;
-
-   if (counter == 15)
-    {
-
-     break;
-    }
-  }
-
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0030), ptr, 1);
+ {
 
-  printk("APD_VBR = %x\n", ptr[0]);
+   if( (get_flash_register((0x060)) != 0xffffffff))
+   {
+    norm_temp = (get_flash_register((0x060)) & 0xff) ;
+   }
 
 
+   if( (get_flash_register((0x070))&0xff) != 0xff)
+   {
+    LT_turnning_point = (get_flash_register((0x070)) & 0xff) ;
+   }
 
+   if( ((get_flash_register((0x070))>>8 )&0xff) != 0xff)
+   {
+    NT_turnning_point = ((get_flash_register((0x070))>>8) & 0xff) ;
+   }
 
-}
-# 3549 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_LOS_find(int LOS_find)
-{
- unchar ptr[4];
- int LOS_status = 0 ;
- int read = 0 ;
- UINT8 LOS_thld_L = 0x00;
- UINT8 LOS_thld_H = 0x7f;
- int DAC = 0 ;
- int counter = 0 ;
+   if( ((get_flash_register((0x070))>>16 )&0xff) != 0xff)
+   {
+    HT_turnning_point = ((get_flash_register((0x070)) >>16) & 0xff) ;
+   }
 
- if (LOS_find == 0)
- {
 
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C)+(0x02), ptr, 1);
-  read = ptr[0] ;
 
+   if( (get_flash_register((0x074))&0xff) != 0xff)
+   {
+    Ibias_slop1 = (get_flash_register((0x074)) & 0xff) ;
+   }
 
-  en7571_LOS_calibration(0x00, 0x00);
-  ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+   if( ((get_flash_register((0x074)) >>8 )&0xff) != 0xff)
+   {
+    Ibias_slop2 = ((get_flash_register((0x074)) >> 8) & 0xff) ;
+   }
 
+   if( ((get_flash_register((0x074)) >>16 )&0xff) != 0xff)
+   {
+    Ibias_slop3 = ((get_flash_register((0x074)) >> 16) & 0xff) ;
+   }
 
-  LOS_status = en7571_LOS_calibration(0x7f, 0x00);
+   if( ((get_flash_register((0x074)) >>24 )&0xff) != 0xff)
+   {
+    Ibias_slop4 = ((get_flash_register((0x074)) >> 24) & 0xff) ;
+   }
 
-  if (LOS_status ==1 )
-  {
-   printk("LOS is high, error\n");
-  }
 
-  DAC = 0x3f ;
+   if( ((get_flash_register((0x060)) >> 16)&0xfff) != 0xfff)
+   {
+    Ibias_init_tmp = ((get_flash_register((0x060)) >> 16) & 0xfff) ;
+   }
+   else
+   {
+    printk("SOL Ibias equal to 0 , not correct \n");
+    return;
+   }
 
 
-  while (1)
-  {
-   LOS_status = en7571_LOS_calibration(0x7F, DAC);
-   ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
+   if( (get_flash_register((0x078))&0xff) != 0xff)
+   {
+    Power_comp_P1_Lo = (get_flash_register((0x078)) & 0xff) ;
+   }
 
-   if (LOS_status ==1)
+   if( ((get_flash_register((0x078)) >>16 )&0xff) != 0xff)
+   {
+    Power_comp_P1_Hi = ((get_flash_register((0x078)) >> 16) & 0xff) ;
+   }
+# 4135 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+   if ( (int)(IC_temperature ) > norm_temp )
+   {
+    if((int)IC_temperature > 60)
     {
-     LOS_thld_H = DAC ;
-     DAC = (LOS_thld_L + DAC)/2 ;
+     Power_comp = Power_comp_P1_Hi;
     }
-   if (LOS_status ==0)
+    else
     {
-     LOS_thld_L = DAC ;
-     DAC = (LOS_thld_H + DAC)/2 ;
+     Power_comp = (int)(((int)IC_temperature -norm_temp)*((float)Power_comp_P1_Hi/(60 - norm_temp ))) ;
     }
-   counter ++;
-   en7571_LOS_calibration(0x00, 0x00);
-   if (counter == 8)
-    break;
-  }
 
+    read_data = (get_flash_register((0x00c)) & (0x3ff));
 
-  printk("Rx LOS = 0x%x \n", DAC);
-  en7571_LOS_calibration(0x00, DAC);
-# 3628 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-  ptr[0] = (ptr[0] & (0x80)) | read;
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C)+(0x02) , ptr, 1);
 
- }
- else
- {
 
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C)+(0x03), ptr, 1);
-  read = ptr[0] ;
 
+    read_data = read_data + Power_comp ;
+    ptr[0] = read_data;
+    ptr[1] = (read_data >> 8);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2);
 
-  en7571_LOS_calibration(0x7f, 0x7f);
-  ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
-
-
-  LOS_status = en7571_LOS_calibration(0x7f, 0x00);
-
-  if (LOS_status == 0 )
-  {
-   printk("LOS is low, error\n");
-  }
+                mt7570_TxSD_level_set();
 
-
-  DAC = 0x3F ;
+   }
+   else if ( (int)(IC_temperature ) < (norm_temp) )
+   {
+    read_data = (get_flash_register((0x00c)) & (0x3ff));
+    if((int)IC_temperature < -10)
+    {
+     Power_comp = Power_comp_P1_Lo;
+     read_data = read_data - Power_comp ;
 
 
-  while (1)
-  {
-   LOS_status = en7571_LOS_calibration(DAC, 0x00);
-   ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
-   if (LOS_status ==1)
-    {
-     LOS_thld_H = DAC ;
-     DAC = (LOS_thld_L + DAC)/2 ;
     }
-   if (LOS_status ==0)
+    else
     {
-     LOS_thld_L = DAC ;
-     DAC = (LOS_thld_H + DAC)/2 ;
-    }
-   counter ++;
-   en7571_LOS_calibration(0x7F, 0x7F);
+     if((int)IC_temperature < 0)
+     {
+      Power_comp = (int)(((__builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed long long) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned long long), ({ signed long long __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed long) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned long), ({ signed long __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed int) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned int), ({ signed int __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed short) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned short), ({ signed short __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed char) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned char), ({ signed char __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), char), (char)({ signed char __x = ((int)IC_temperature); __x<0?-__x:__x; }), ((void)0))))))))+ norm_temp)*((float)Power_comp_P1_Lo/(norm_temp + 10))) ;
+      read_data = read_data - Power_comp ;
 
-   if (counter == 12)
-    break;
-  }
 
-  printk("Rx SD = 0x%x \n", DAC);
-  en7571_LOS_calibration(DAC, 0x00);
-# 3700 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-  ptr[0] = (ptr[0] & (0x80)) | read;
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C)+(0x03) , ptr, 1);
 
- }
-}
-# 3720 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_eFuse_temperature_get(void)
-{
- int a = 0 ;
- int b = 0 ;
- int read = 0 ;
- unchar ptr[4];
+     }
+     else
+     {
+      Power_comp = (int)(((int)IC_temperature-norm_temp)*((float)Power_comp_P1_Lo/(norm_temp + 10))) ;
+      read_data = read_data + Power_comp ;
 
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0044), ptr, 4);
- ptr[2] = (ptr[2]&0xfe) | 0x01;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0044), ptr, 4);
- ( (__builtin_constant_p(50) && (50)<=2) ? (__builtin_constant_p((50)*1000) ? (((50)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((50)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((50)*1000)) : ({unsigned long __ms=(50); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));}));
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0044), ptr, 4);
- read = ptr[0] ;
+     }
+    }
 
- if (read <127)
-  en7571_eFuse_temperature_offset = (float)read *0.3;
- else
-  en7571_eFuse_temperature_offset = (-0.3)*(float)(256 -read);
+    ptr[0] = read_data;
+    ptr[1] = (read_data >> 8);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2);
 
- printk("eFuse value = 0x%x\n", ptr[0]);
+                mt7570_TxSD_level_set();
+   }
+   else
+   {
+    read_data = (get_flash_register((0x00c)) & (0x3ff));
+    ptr[0] = read_data;
+    ptr[1] = (read_data >> 8);
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2);
 
- a = (int)en7571_eFuse_temperature_offset;
- b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned long long), ({ signed long long __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned long), ({ signed long __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned int), ({ signed int __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned short), ({ signed short __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned char), ({ signed char __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), char), (char)({ signed char __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
- printk("eFuse offset = %d.%d'C\n", a, b);
+                mt7570_TxSD_level_set();
+   }
 
-}
+   if((NT_turnning_point < LT_turnning_point ) || ( NT_turnning_point > HT_turnning_point ))
+   {
+    printk("turning point range error\n");
+    return;
+   }
 
 
+   if(( norm_temp > NT_turnning_point) &&( norm_temp < HT_turnning_point))
+   {
+    NT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop3*(norm_temp - NT_turnning_point);
+    HT_turnning_point_ibias = Ibias_init_tmp + Ibias_slop3*(HT_turnning_point -norm_temp);
+    LT_turnning_point_ibias = NT_turnning_point_ibias - Ibias_slop2*(NT_turnning_point - LT_turnning_point);
+   }
+   else if (( NT_turnning_point > norm_temp) && ( norm_temp > LT_turnning_point))
+   {
+    NT_turnning_point_ibias = Ibias_init_tmp + Ibias_slop2*(NT_turnning_point - norm_temp);
+    LT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop2*(norm_temp-LT_turnning_point);
+    HT_turnning_point_ibias = NT_turnning_point_ibias + Ibias_slop3*(HT_turnning_point - NT_turnning_point);
 
+   }
+   else if ( NT_turnning_point == norm_temp)
+   {
+    NT_turnning_point_ibias = Ibias_init_tmp ;
+    LT_turnning_point_ibias = NT_turnning_point_ibias - Ibias_slop2*(NT_turnning_point - LT_turnning_point);
+    HT_turnning_point_ibias = NT_turnning_point_ibias + Ibias_slop3*(HT_turnning_point - NT_turnning_point);
 
-void en7571_force_mode(void)
-{
- unchar ptr[4];
+   }
+   else if ( HT_turnning_point == norm_temp)
+   {
+    HT_turnning_point_ibias = Ibias_init_tmp;
+    NT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop3*(HT_turnning_point - NT_turnning_point);
+    LT_turnning_point_ibias = NT_turnning_point_ibias - Ibias_slop2*(NT_turnning_point-LT_turnning_point);
+   }
+   else if ( norm_temp > HT_turnning_point)
+   {
+    HT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop4*(norm_temp - HT_turnning_point);
+    NT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop3*(HT_turnning_point - NT_turnning_point);
+    LT_turnning_point_ibias = NT_turnning_point_ibias - Ibias_slop2*(NT_turnning_point-LT_turnning_point);
+   }
+   else if ( norm_temp <= LT_turnning_point)
+   {
+    printk("Calibration tempature too lower , Wrong setting \n");
+    return;
+   }
 
+   if((int)IC_temperature >= HT_turnning_point )
+   {
+    Ibias_set = HT_turnning_point_ibias + Ibias_slop4*(int)((int)IC_temperature - HT_turnning_point);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0258), ptr, 4);
- ptr[3] = (ptr[3] & 0xfc) | 0x03;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0258), ptr, 4);
-}
 
 
+   }
+   else if(((int)IC_temperature >= NT_turnning_point ) & ((int)IC_temperature < HT_turnning_point))
+   {
+    Ibias_set = NT_turnning_point_ibias + Ibias_slop3*(int)((int)IC_temperature - NT_turnning_point);
 
 
-void en7571_auto_lock_mode(void)
-{
- unchar ptr[4];
 
+   }
+   else if(((int)IC_temperature < NT_turnning_point ) & ((int)IC_temperature >= LT_turnning_point))
+   {
+    Ibias_set = LT_turnning_point_ibias + Ibias_slop2*(int)((int)IC_temperature - LT_turnning_point);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0258), ptr, 4);
- ptr[3] = (ptr[3] & 0xfc);
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0258), ptr, 4);
-}
 
 
+   }
+   else if ((int)IC_temperature < LT_turnning_point )
+   {
+    if((int)IC_temperature <0 )
+    {
+     Ibias_set = LT_turnning_point_ibias - Ibias_slop1 * ((__builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed long long) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned long long), ({ signed long long __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed long) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned long), ({ signed long __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed int) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned int), ({ signed int __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed short) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned short), ({ signed short __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed char) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned char), ({ signed char __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), char), (char)({ signed char __x = ((int)IC_temperature); __x<0?-__x:__x; }), ((void)0)))))))) + LT_turnning_point);
+    }
+    else
+    {
+     Ibias_set = LT_turnning_point_ibias + Ibias_slop1 * ((int)IC_temperature - LT_turnning_point);
+    }
 
 
-void en7571_tune_KT(UINT16 input)
-{
- unchar ptr[4];
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0230), ptr, 3);
- if(input==0xFFFF)
-  ptr[0] = (ptr[0] & 0xfe);
- else
- {
-  ptr[2] = (ptr[1] & 0xfc) | (input>>8);
-  ptr[1] = (ptr[0] & 0x00) | (input&0xff);
-  ptr[0] = (ptr[0] & 0xfe) | 0x01;
- }
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0230), ptr, 3);
-}
+   }
+# 4295 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+   phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4);
+   ptr[0] = (ptr[0] & 0xfc) | 0x02;
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C) , ptr, 4);
 
+   if (Ibias_set < 0x25)
+    Ibias_set = 0x25;
 
 
+   read_data = Ibias_set;
+   ptr[0] = read_data;
+   ptr[1] = (read_data >> 8);
+   phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138) , ptr, 2);
 
-void en7571_config(void)
-{
 
- if( get_flash_register((0x02c)) == 0 )
- {
-  en7571_internal_DDMI = 0;
-  printk("Internal DDMI Disabled\n");
- }
- else
- {
-  printk("Internal DDMI Enabled\n");
-  if( get_flash_register((0x02c)) == 2 )
-   en7571_fast_DDMI = 1;
- }
-
- if (get_flash_register((0x090)) == 1)
- {
-  en7571_SCL = 1;
-  en7571_SingleClosedLoopMode();
-  en7571_LUT_recover();
-  en7571_temperature_get();
-  en7571_LUT_Tracking();
-  printk("Single-closed Loop Mode Enabled\n");
- }
- else if (get_flash_register((0x090)) == 2)
- {
-  en7571_DOL = 1;
-  en7571_OpenLoopMode(1);
-  en7571_LUT_recover();
-  en7571_temperature_get();
-  en7571_LUT_Tracking();
-  printk("Open Loop Mode Enabled\n");
- }
- else if( get_flash_register((0x060)) != 0xffffffff )
- {
-  en7571_ERC = 1;
-  printk("ERC Enabled\n");
- }
- else
- {
-  if( get_flash_register((0x064)) == 0xffffffff )
-  {
-   set_flash_register(0x00060020, (0x064));
-   en7571_KT = 1;
-   printk("KT Enabled\n");
-  }
-  else
-  {
-   en7571_KT = 1;
-   printk("KT Enabled\n");
-  }
-
-  if( get_flash_register((0x068)) == 2 )
-  {
-   en7571_KT = 2;
-   printk("KT Inversed\n");
-  }
-  else if( get_flash_register((0x068)) == 3 )
-  {
-   en7571_KT = 3;
-   printk("KT Enhanced\n");
-  }
- }
-
- en7571_delay1 = 0;
- en7571_delay2 = 600;
- en7571_Pav_loop = 1 ;
-
- if( get_flash_register((0x06c)) == 0 )
-  en7571_cross = 0;
-
-}
 
+   temp = (float)global_bias_current*0.02442;
+   a = (int)temp;
+   b = (int)(temp*100)%100;
+   printk("SOL mode, Ibias = %d.%.2dmA", a, b);
 
 
+   printk("\t");
+   a = (int)IC_temperature;
+   b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0)))))));
+   printk("IC temperature = %d.%dC\n", a, b);
 
-void en7571_link_reg(int input)
-{
- if(en7571_ver==2)
- {
-  if(input==1)
-  {
-   en7571_mpdh_stepsize(0);
-   en7571_T1delay_setting(0);
-  }
-  else if(input==0)
-  {
-   en7571_mpdh_stepsize(1);
-   en7571_T1delay_setting(1);
-  }
-  en7571_burst_ctrl(input);
- }
- else
- {
-  en7571_HWKT(input);
-  if(input==1)
-  {
-   en7571_T1delay_setting(0);
-  }
-  else if(input==0)
-  {
-   en7571_T1delay_setting(1);
-  }
  }
 }
-
-
-
-
-void en7571_burst_ctrl(int input)
+# 4336 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_FiberPlug_Protect(void)
 {
- unchar ptr[4];
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4);
- ptr[1] = ( ptr[1] & 0xfb ) | 0x04;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4);
+ mt7570_restart_ERC();
 }
-
-
-
-
-void en7571_islinkstauschange(void)
+# 4355 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_restart_ERC_P0(void)
 {
- static int linkupstatus;
- int linkupstatus_now = 0;
- int needchange = 0 ;
-
- if(gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_DOWN)
-  linkupstatus_now = 0;
- else
-  linkupstatus_now = 1;
-
- if( (linkupstatus ^ linkupstatus_now)==1)
- {
-  needchange = 1 ;
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Link up status is change\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3932) ; };
- }
- else
- {
-  needchange = 0 ;
- }
+  unchar ptr[4];
 
 
- if( needchange && (linkupstatus_now==1))
- {
-  en7571_get_linkup_infor();
-  en7571_OpenLoopMode(1);
- }
- else if(needchange && (linkupstatus_now==0) )
- {
-  en7571_OpenLoopMode(0);
-  en7571_closeloop_reset();
- }
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4);
+  ptr[0] = ptr[0] & 0xfe;
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 );
 
- linkupstatus = linkupstatus_now ;
+  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4);
+  ptr[0] = (ptr[0] & 0xfe) | (0x01);
+  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 );
+  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "P0 ERC restarted\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4367) ; };
 }
-# 3961 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_Pavg_close_loop(void)
+# 4383 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_BiasTracking(void)
 {
- int pav_cal = 0;
- int pav_current = 0;
- int pav_delta =0;
- int Ibias_target = 0 ;
- int Iav_target =0 ;
- int Ibias_target_hys = 0 ;
- int temp = 0 ;
+ unchar ptr[4];
+ uint read_data = 0;
+ uint MPDL = 0;
+ uint Ibias_now = 0;
 
+ int temperature_index = 0;
+ int a = 0;
+ int b = 0;
 
- if( (en7571_PatternEnabled == 0) && (gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_UP))
- {
+ float temp = 0;
 
-  pav_cal = en7571_info(0x01);
-  pav_current = en7571_info(0x07);
 
 
-  pav_delta = pav_cal - pav_current ;
+ temperature_index = (int)( (Env_temperature+40)/2.5 );
+ if( temperature_index < 0 )
+  temperature_index = 0;
 
 
+ read_data = LUT_Ibias_Imod[temperature_index][0];
 
-  if(pav_delta<0)
-   temp = (-1)*pav_delta;
-  else
-   temp = pav_delta;
+ if( read_data == 0xfff )
+  return;
 
-  if(temp > 0x15)
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Pav_delta = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3989, pav_delta) ; };
+ ptr[0] = read_data;
+ ptr[1] = (read_data >> 8);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2 );
 
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target bias loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4412, read_data) ; };
+ temp = (float)read_data*0.02442;
+ a = (int)temp;
+ b = (int)(temp*100)%100;
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Ibias = %d.%.2dmA\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4416, a, b) ; };
 
+ Ibias_now = global_bias_current;
 
-  if(pav_delta <0 )
-  {
-   Iav_target = Iav_linkup_now - 0x4 ;
-  }
-  else if(pav_delta >0)
-  {
-   Iav_target = Iav_linkup_now + 0x4 ;
-  }
-  else
-  {
-   Iav_target = Iav_linkup_now ;
-  }
 
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
+ if( (ptr[0]&0x0f) == 0x5 )
+ {
 
-  if(Iav_linkup_now<0)
+  if ( read_data > Ibias_now )
   {
-   Iav_target = Iav_linkup_now + 0x80 ;
+   if ( read_data - Ibias_now > 0x14 )
+   {
+    MPDL = mt7570_information_output(0x05) + 0x4;
+    ptr[0] = MPDL;
+    ptr[1] = MPDL >> 8;
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2);
+    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Bias tracking done\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4433) ; };
+   }
   }
-
-
-  Ibias_target = en7571_Ibias_transfer(Iav_target);
-
-
-  Ibias_target_hys = en7571_Ibias_hysteresis(Ibias_target,pav_delta);
-
-
-  if(need_crossing_Ibias!=1)
-   en7571_change_Ibias(Ibias_target_hys);
-  else
+  else if ( read_data < Ibias_now )
   {
-   en7571_cross_Ibias(Ibias_target_hys);
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Ibias Crossing\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4024) ; };
-   en7571_cross_cnt_Ibias++;
-   need_crossing_Ibias = 0;
+   if( Ibias_now - read_data > 0x14 )
+   {
+    MPDL = mt7570_information_output(0x05) - 0x4;
+    ptr[0] = MPDL;
+    ptr[1] = MPDL >> 8;
+    phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2);
+    { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Bias tracking done\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4444) ; };
+   }
   }
 
-
-
-  Ibias_linkup_now = Ibias_target_hys ;
-  en7571_Iavg_transfer();
-
  }
 
 
-}
 
 
 
-
-void en7571_get_linkup_infor(void)
-{
-
- Imod_linkup_now = en7571_info(0x04);
- en7571_change_Imod(Imod_linkup_now);
-
- Ibias_linkup_now = en7571_info(0x03);
- en7571_change_Ibias(Ibias_linkup_now);
-
- Iav_linkup_now = en7571_info(0x02);
-
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Imod_DAC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4053, Imod_linkup_now) ; };
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Ibias_DAC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4054, Ibias_linkup_now) ; };
- { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Iav_linkup_now = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4055, Iav_linkup_now) ; };
-
-}
-
-
-
-
-int en7571_Ibias_transfer(int Iav_target)
-{
- int Ibias_target = 0 ;
- float Imod_now = 0 ;
- float Iav_now = 0 ;
-
- Imod_now = (float)Imod_linkup_now*0.02198;
- Iav_now = (float)Iav_target*0.02198;
-
- Ibias_target = (int) ((Iav_now - Imod_now/2)/0.02442);
-
- return Ibias_target ;
-
-}
-
-
-
-
-void en7571_Iavg_transfer(void)
-{
- float Ibias_now = 0 ;
- float Imod_now = 0 ;
-
- Imod_now = (float)Imod_linkup_now*0.02198;
- Ibias_now = (float)Ibias_linkup_now *0.02442;
-
- Iav_linkup_now = (int) ((Ibias_now + Imod_now/2)/0.02198);
-
-}
-
-
-
-
-void en7571_closeloop_reset(void)
-{
- unchar ptr[4];
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
- ptr[1] = ptr[1] & 0xfe;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
- ptr[0] = ptr[0] & 0xfe;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
-
- en7571_hw_reset();
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
- ptr[0] = (ptr[0]&0xfe) | 0x01;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
- ptr[1] = (ptr[1]&0xfe) | 0x01;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4);
-
-
 }
-
-
-
-
-int en7571_Ibias_hysteresis(int Ibias_target , int pav_delta)
+# 4470 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_LUT_recover(void)
 {
+ uint Init_Ibias = 0;
+ uint FLASH_Ibias = 0;
+ uint FLASH_Ibias_up = 0;
+ uint FLASH_Imod = 0;
+ uint FLASH_Imod_up = 0;
+ uint Ibias_offset = 0;
+ uint Ibias_recover = 0;
+ uint Imod_recover = 0;
+ uint Ibias_cal = 0;
 
- int HSB_target = 0 ;
- int HSB_now = 0 ;
- int hysteresis = 0 ;
- int Ibias_target_hys = 0;
-
-
-
- HSB_target = (Ibias_target >> 8) & 0xff ;
- HSB_now = (Ibias_linkup_now >> 8) & 0xff ;
+ int FLASH_index = 0;
+ int index = 0;
+ float temperature_cal = 25.0;
+ float temperature = 0;
 
- if(pav_delta<0)
-  pav_delta = (-1)*pav_delta;
 
- if(HSB_target != HSB_now)
+ if( DOL == 1 )
  {
-  if(pav_delta <= 0xf)
-  {
-   hysteresis = 1;
-  }
-  else
+  for( index = 0; index < 64; index ++ )
   {
-   hysteresis = 0;
-   need_crossing_Ibias = 1 ;
-  }
- }
- else
- {
-  hysteresis = 0;
-
- }
-
- if(hysteresis ==1)
- {
-  Ibias_target_hys = Ibias_linkup_now;
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Hysteresis, Ibias now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4160,Ibias_linkup_now) ; };
- }
- else
-  Ibias_target_hys = Ibias_target;
-
-
+   temperature = (float)index*2.5 - 40;
+   FLASH_index = (int)( (temperature+40)/10 );
 
-  if(Ibias_target_hys <= 0x080)
-   Ibias_target_hys = 0x080 ;
-  else if(Ibias_target_hys >=0xf7f)
-   Ibias_target_hys = 0xf7f;
+   if( FLASH_index < 0 )
+    FLASH_index = 0;
+   else if( FLASH_index >15 )
+    FLASH_index = 15;
 
- return Ibias_target_hys;
 
-}
+   FLASH_Ibias =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x0fff0000) >> 16;
+   FLASH_Ibias_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x0fff0000) >> 16;
+   FLASH_Imod =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x00000fff);
+   FLASH_Imod_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x00000fff);
 
 
+   if( FLASH_Ibias == 0xfff || FLASH_Ibias_up == 0xfff )
+   {
+    LUT_Ibias_Imod[index][0] = 0xfff;
+   }
+   else
+   {
+    if(FLASH_index < 4)
+     Ibias_recover = FLASH_Ibias + ((temperature +40) - (FLASH_index*10))*(FLASH_Ibias_up - FLASH_Ibias)/10;
+    else
+     Ibias_recover = FLASH_Ibias + (temperature - ((10*FLASH_index) -40))*(FLASH_Ibias_up - FLASH_Ibias)/10;
 
+    LUT_Ibias_Imod[index][0] = Ibias_recover;
+   }
 
-int en7571_Imod_hysteresis(int Imod_now, int Imod_target)
-{
 
- int LSB_now = 0 ;
- int HSB_now = 0 ;
- int LSB_target = 0 ;
- int HSB_target = 0 ;
- int hysteresis = 0 ;
+   if( FLASH_Imod == 0xfff || FLASH_Imod_up == 0xfff )
+   {
+    LUT_Ibias_Imod[index][1] = 0xfff;
+   }
+   else
+   {
+    if(FLASH_index < 4)
+     Imod_recover = FLASH_Imod + ((temperature +40) - (FLASH_index*10))*(FLASH_Imod_up - FLASH_Imod)/10;
+    else
+     Imod_recover = FLASH_Imod + (temperature - ((10*FLASH_index) -40))*(FLASH_Imod_up - FLASH_Imod)/10;
 
- int Imod_update = 0 ;
+    LUT_Ibias_Imod[index][1] = Imod_recover;
+   }
+  }
 
- LSB_now = Imod_now & 0xff;
- HSB_now = (Imod_now >> 8) & 0xff ;
- LSB_target = Imod_target & 0xff;
- HSB_target = (Imod_target >> 8) & 0xff ;
 
- if(HSB_now < HSB_target)
- {
-  if(LSB_target <= 0x10)
+  for( FLASH_index=0; FLASH_index<=15; FLASH_index++ )
   {
-   hysteresis = 1;
-   Imod_update = Imod_now;
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Hysteresis, Imod now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4201,Imod_now) ; };
+   index = 4*FLASH_index;
 
-  }
-  else
-  {
-   need_crossing_Imod= 1;
-   Imod_update = Imod_target;
-  }
- }
- else if(HSB_now > HSB_target)
- {
-  if(LSB_target >= 0xf0)
-  {
-   hysteresis = 1;
-   Imod_update = Imod_now;
-   { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Hysteresis, Imod now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4216,Imod_now) ; };
-  }
-  else
-  {
-   need_crossing_Imod = 1;
-   Imod_update = Imod_target;
+   if( ((get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ) != 0xfff )
+   {
+    LUT_Ibias_Imod[index][0] = ( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 );
+   }
+
+   if( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x00000fff) != 0xfff )
+   {
+    LUT_Ibias_Imod[index][1] = ( get_flash_register( 0xa0 + FLASH_index*4 ) & 0x00000fff );
+   }
   }
  }
  else
-  Imod_update = Imod_target;
-
-
- if(Imod_update <= 0x032)
-  Imod_update = 0x032 ;
- else if(Imod_update >=0xf7f)
-  Imod_update = 0xf7f;
-
- return Imod_update;
-
-}
-# 4244 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_LUT_Tracking(void)
-{
- uint Imod_target = 0;
- uint Ibias_target = 0;
-
- int temperature_index = 0;
-
-
- temperature_index = (int)( (en7571_Env_temperature+40)/2.5 );
- if( temperature_index < 0 )
-  temperature_index = 0;
-
- if(en7571_SCL ==1)
  {
-
- }
- else if(en7571_DOL==1)
- {
-  Ibias_target = en7571_LUT_Ibias_Imod[temperature_index][0];
-  Imod_target = en7571_LUT_Ibias_Imod[temperature_index][1];
-  if( (Ibias_target== 0xfff) || (Imod_target == 0xfff) )
-   return;
-
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Ibias loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4267, Ibias_target) ; };
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Imod loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4268, Imod_target) ; };
-
-  en7571_change_Ibias(Ibias_target);
-  en7571_change_Imod(Imod_target);
-  { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Using change fcn\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4272) ; };
- }
-}
-# 4283 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_LUT_recover(void)
-{
- uint Imod_cal = 0;
- uint Ibias_cal = 0;
- uint FLASH_Ibias = 0;
- uint FLASH_Ibias_up = 0;
- uint FLASH_Imod = 0;
- uint FLASH_Imod_up = 0;
- int Imod_offset = 0;
- int Ibias_offset = 0;
- uint Ibias_recover = 0;
- uint Imod_recover = 0;
- uint Imod_intp = 0;
- uint Ibias_intp = 0;
-
-
- int FLASH_index = 0;
- int index = 0;
- float temperature_cal = 25.0;
- float temperature = 0;
-
- if( en7571_DOL == 1 )
- {
-  if( get_flash_register((0x08c)) != 0xffffffff )
+  if( get_flash_register((0x060)) != 0xffffffff )
   {
-   temperature_cal = (float)get_flash_register((0x08c))/10;
+   temperature_cal = (float)get_flash_register((0x060))/10;
    if( (temperature_cal<0) || (temperature_cal>40))
    {
     printk("EnvTemp error\n");
@@ -51882,30 +51631,22 @@
 
   if (get_flash_register(0xa0+FLASH_index*4) == 0xffffffff)
   {
-   printk("Lack of Imod-current table\n");
+   printk("Lack of bias-current table\n");
    return;
   }
 
 
-  FLASH_Ibias =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x0fff0000) >> 16;
-  FLASH_Ibias_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x0fff0000) >> 16;
-  FLASH_Imod =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x00000fff);
-  FLASH_Imod_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x00000fff);
-
-  Ibias_intp = FLASH_Ibias + (temperature_cal - ((10*FLASH_index) -40))*(FLASH_Ibias_up - FLASH_Ibias)/10;
-  Imod_intp = FLASH_Imod + (temperature_cal - ((10*FLASH_index) -40))*(FLASH_Imod_up - FLASH_Imod)/10;
 
 
-  Imod_cal = get_flash_register((0x008))&0x00000fff;
-  Ibias_cal = (get_flash_register((0x008))&0x0fff0000) >> 16;
-
+  FLASH_Ibias =(get_flash_register(0xa0+FLASH_index*4) & 0x0fff0000) >> 16;
+  FLASH_Ibias_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x0fff0000) >> 16;
+  Ibias_cal = FLASH_Ibias + (temperature_cal - ((10*FLASH_index) -40))*(FLASH_Ibias_up - FLASH_Ibias)/10;
 
-  Imod_offset = (int)Imod_cal - (int)Imod_intp;
-  printk("Imod offset = %d\n", Imod_offset);
+  Init_Ibias = get_flash_register((0x000));
 
+  Ibias_offset = Init_Ibias - Ibias_cal;
+  printk("Bias offset = 0x%x\n", Ibias_offset);
 
-  Ibias_offset = (int)Ibias_cal - (int)Ibias_intp;
-  printk("Ibias offset = %d\n", Ibias_offset);
 
   for( index = 0; index < 64; index ++ )
   {
@@ -51920,13 +51661,10 @@
 
    FLASH_Ibias =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x0fff0000) >> 16;
    FLASH_Ibias_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x0fff0000) >> 16;
-   FLASH_Imod =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x00000fff);
-   FLASH_Imod_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x00000fff);
-
 
    if( FLASH_Ibias == 0xfff || FLASH_Ibias_up == 0xfff )
    {
-    en7571_LUT_Ibias_Imod[index][0] = 0xfff;
+    LUT_Ibias_Imod[index][0] = 0xfff;
    }
    else
    {
@@ -51935,46 +51673,31 @@
     else
      Ibias_recover = FLASH_Ibias + (temperature - ((10*FLASH_index) -40))*(FLASH_Ibias_up - FLASH_Ibias)/10;
 
-    en7571_LUT_Ibias_Imod[index][0] = Ibias_recover + Ibias_offset;
+    LUT_Ibias_Imod[index][0] = Ibias_recover + Ibias_offset;
    }
 
-
-   if( FLASH_Imod == 0xfff || FLASH_Imod_up == 0xfff )
+   if( LUT_Ibias_Imod[index][0] <= 0x0 )
    {
-    en7571_LUT_Ibias_Imod[index][1] = 0xfff;
+    printk("LUT recover failed\n");
+    return;
    }
-   else
-   {
-    if(FLASH_index < 4)
-     Imod_recover = FLASH_Imod + ((temperature +40) - (FLASH_index*10))*(FLASH_Imod_up - FLASH_Imod)/10;
-    else
-     Imod_recover = FLASH_Imod + (temperature - ((10*FLASH_index) -40))*(FLASH_Imod_up - FLASH_Imod)/10;
 
-    en7571_LUT_Ibias_Imod[index][1] = Imod_recover + Imod_offset;
-   }
   }
 
 
   for( FLASH_index=0; FLASH_index<=15; FLASH_index++ )
   {
    index = 4*FLASH_index;
-
    if( ((get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ) != 0xfff )
    {
-    en7571_LUT_Ibias_Imod[index][0] = ( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ) + Ibias_offset;
-   }
-
-   if( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x00000fff) != 0xfff )
-   {
-    en7571_LUT_Ibias_Imod[index][1] = ( get_flash_register( 0xa0 + FLASH_index*4 ) & 0x00000fff ) + Imod_offset;
+    LUT_Ibias_Imod[index][0] = ( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ) + Ibias_offset;
    }
   }
  }
 
-
 }
-# 4419 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_show_LUT(void)
+# 4648 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_show_LUT(void)
 {
  int index = 0;
 
@@ -51987,111 +51710,101 @@
 
  for( index = 0; index < 64; index ++ )
  {
-  printk("%03d.%01d\t\t0x%03x\t0x%03x\n", (index*25-400)/10, (int)(__builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed long long) || __builtin_types_compatible_p(typeof(index*25-400), unsigned long long), ({ signed long long __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed long) || __builtin_types_compatible_p(typeof(index*25-400), unsigned long), ({ signed long __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed int) || __builtin_types_compatible_p(typeof(index*25-400), unsigned int), ({ signed int __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed short) || __builtin_types_compatible_p(typeof(index*25-400), unsigned short), ({ signed short __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed char) || __builtin_types_compatible_p(typeof(index*25-400), unsigned char), ({ signed char __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), char), (char)({ signed char __x = (index*25-400); __x<0?-__x:__x; }), ((void)0)))))))%10), en7571_LUT_Ibias_Imod[index][0], en7571_LUT_Ibias_Imod[index][1] );
+  printk("%03d.%01d\t\t0x%03x\t0x%03x\n", (index*25-400)/10, (int)(__builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed long long) || __builtin_types_compatible_p(typeof(index*25-400), unsigned long long), ({ signed long long __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed long) || __builtin_types_compatible_p(typeof(index*25-400), unsigned long), ({ signed long __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed int) || __builtin_types_compatible_p(typeof(index*25-400), unsigned int), ({ signed int __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed short) || __builtin_types_compatible_p(typeof(index*25-400), unsigned short), ({ signed short __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed char) || __builtin_types_compatible_p(typeof(index*25-400), unsigned char), ({ signed char __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), char), (char)({ signed char __x = (index*25-400); __x<0?-__x:__x; }), ((void)0)))))))%10), LUT_Ibias_Imod[index][0], LUT_Ibias_Imod[index][1] );
  }
 
 }
-# 4444 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_SingleClosedLoopMode(void)
+# 4679 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_SingleClosedLoopMode(void)
 {
+ unchar ptr[4];
 
- en7571_DCL_stop();
- en7571_mpdh_stepsize(0);
- en7571_hw_reset();
- en7571_DCL_start();
 
-}
-# 4461 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_OpenLoopMode(int input)
-{
- unchar ptr[4];
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
+ ptr[0] = (ptr[0] & 0xfc) | 0x02;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
 
- if(input==1)
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
-  ptr[0] = (ptr[0] & 0xfc) | 0x02;
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
 
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
-  ptr[0] = (ptr[0] & 0xfc) | 0x02;
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
- }
- else if(input==0)
- {
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
-  ptr[0] = (ptr[0] & 0xfc);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1);
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
+ ptr[0] = (ptr[0] & 0xfc) | 0x01;
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
 
-  phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
-  ptr[0] = (ptr[0] & 0xfc);
-  phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1);
- }
+ printk("Switch to Single-closed Loop Mode\n");
 }
-# 4494 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_T1delay_setting(int input )
+# 4709 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_OpenLoopControl(void)
 {
  unchar ptr[4];
+ uint read_data = 0;
+
+ int temperature_index = 0;
+ int a = 0;
+ int b = 0;
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4);
- if ( input == 1)
- {
-  if( get_flash_register((0x094)) == 0x07050701 )
-  {
-   ptr[0] = (ptr[0] & 0x00) | 0xaa;
-  }
-  else if( get_flash_register((0x094)) == 0xe7050701 )
-  {
-    ptr[0] = (ptr[0] & 0x00) | 0x77;
-  }
-  else if( get_flash_register((0x094)) == 0xa7050701 )
-  {
-    ptr[0] = (ptr[0] & 0x00) | 0x77;
-  }
- }
- else if( input == 0)
- {
- ptr[0] = (ptr[0] & 0xf0) | 0x0;
- }
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4 );
-}
-# 4528 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c"
-void en7571_WatchDog(void)
-{
  float temp = 0;
- int LimitHold = 0;
 
- if(en7571_sys_mode == 1)
- {
-  if( (gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_DOWN) && (en7571_PatternEnabled == 0) )
-  {
-   temp = (float)en7571_info(0x02)*0.02198;
-   LimitHold = (int)temp;
-   if( LimitHold>85 )
-   {
-   printk("Watch Dog ON !!\n");
-   en7571_init();
-   }
-  }
- }
-}
 
 
-void en7571_tuneBiasModCurrent(UINT16 bias, UINT16 mod)
+ temperature_index = (int)( (Env_temperature+40)/2.5 );
+ if( temperature_index < 0 )
+  temperature_index = 0;
+
+
+ read_data = LUT_Ibias_Imod[temperature_index][0];
+
+ if( read_data == 0xfff )
+  return;
+
+ ptr[0] = read_data;
+ ptr[1] = (read_data >> 8);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2 );
+
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target bias loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4736, read_data) ; };
+ temp = (float)read_data*0.02442;
+ a = (int)temp;
+ b = (int)(temp*100)%100;
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Ibias = %d.%.2dmA\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4740, a, b) ; };
+
+
+
+ read_data = LUT_Ibias_Imod[temperature_index][1];
+
+ if( read_data == 0xfff )
+  return;
+
+ ptr[0] = read_data;
+ ptr[1] = (read_data >> 8);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 2 );
+
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target mod loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4753, read_data) ; };
+ temp = (float)read_data*0.02198;
+ a = (int)temp;
+ b = (int)(temp*100)%100;
+ { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Imod = %d.%.2dmA\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4757, a, b) ; };
+
+}
+# 4774 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c"
+void mt7570_LOS_init(void)
 {
  unchar ptr[4];
 
- bias&=0xFFF;
- mod&=0xFFF;
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
+ ptr[0] = (ptr[0] & (0xfe)) | (0x01);
 
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 4);
- ptr[0] = bias&0xFF;
- ptr[1] = bias>>8;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 4);
-
- phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 4);
- ptr[0] = mod&0xFF;
- ptr[1] = mod>>8;
- phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 4);
+ ptr[1] = (ptr[1] & (0xe0)) | (0x1f);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4);
 
- set_flash_register( ((bias<<16)|mod), (0x008));
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4);
+ ptr[3] = (ptr[3] & (0xfb)) | (0x04);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4);
+
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4);
+ ptr[2] = (ptr[2] & (0xbf)) | (0x40);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4);
+
+ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0120), ptr, 4);
+ ptr[1] = (ptr[1] & (0xe0)) | (0x1f);
+
+ ptr[0] = (ptr[0] & (0x80)) | (0x05);
+ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0120), ptr, 4);
 }
> [`0932f2c9b3/sdk/en7529/linux-4.4.115/en7571.i`](https://sirherobrine23.com.br/tplink_gpl/tplink-xx530v_v1/src/commit/0932f2c9b3e2f753d161f147e60fc59c0866a9ee/sdk/en7529/linux-4.4.115/en7571.i) > [`0932f2c9b3/sdk/en7529/linux-4.4.115/mt7570.i`](https://sirherobrine23.com.br/tplink_gpl/tplink-xx530v_v1/src/commit/0932f2c9b3e2f753d161f147e60fc59c0866a9ee/sdk/en7529/linux-4.4.115/mt7570.i) > > It appears that in some cases the en7571 file uses the mt7570 API (function `get_flash_matrix`, for example) and in other cases a function was duplicated and is identical, like the functions mt7570_LOS_init and `en7571_LOS_init`. > In terms of code, as you said, they are identical, but with adaptations for the EN7571 for calibration and other things. I'm still thinking about many things for the PON on Linux; much of it will be based on these drivers: https://sirherobrine23.com.br/econet/EN751221-Linux26/src/commit/aea3a43562e8d3dc0335624202fde08d713a18c2/tclinux_phoenix/modules/private <details> <summary>drive diff</summary> ```diff --- en7571.i 2025-09-08 12:59:24.171475284 -0300 +++ mt7570.i 2025-09-08 12:59:24.898477566 -0300 @@ -1,4 +1,4 @@ -# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" +# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "././include/linux/kconfig.h" 1 @@ -8,7 +8,7 @@ # 1 "include/generated/autoconf.h" 1 # 5 "././include/linux/kconfig.h" 2 # 1 "<command-line>" 2 -# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" +# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" # 1 "include/linux/kernel.h" 1 @@ -2342,7 +2342,7 @@ return 0; } static inline __attribute__((always_inline)) __attribute__((no_instrument_function)) void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } -# 2 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 2 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "include/linux/slab.h" 1 # 14 "include/linux/slab.h" # 1 "include/linux/gfp.h" 1 @@ -11132,7 +11132,7 @@ unsigned int kmem_cache_size(struct kmem_cache *s); void __attribute__ ((__section__(".init.text"))) __attribute__((__cold__)) __attribute__((no_instrument_function)) kmem_cache_init_late(void); -# 3 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 3 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "include/linux/delay.h" 1 # 12 "include/linux/delay.h" extern unsigned long loops_per_jiffy; @@ -11188,7 +11188,7 @@ { msleep(seconds * 1000); } -# 4 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 4 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "include/linux/proc_fs.h" 1 @@ -16353,7 +16353,7 @@ { return proc_mkdir_data(name, 0, parent, net); } -# 6 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 6 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "include/linux/module.h" 1 # 13 "include/linux/module.h" # 1 "include/linux/kmod.h" 1 @@ -18384,9 +18384,7 @@ { return true; } -# 7 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 - - +# 7 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/i2c.h" 1 @@ -18397,7 +18395,7 @@ uint ioReadPhyReg32(ushort phyReg) ; int ioWritePhyReg32(ushort phyReg, uint value) ; int ioWritePhyReg8(ushort phyReg, unchar value) ; -# 12 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 10 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_def.h" 1 @@ -22230,11 +22228,11 @@ ushort tx_power_high_alarm_thod; ushort tx_power_low_alarm_thod; }PHY_TransAlarm_T, *PPHY_TransAlarm_T; -# 13 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 -# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/en7571_reg.h" 1 -# 14 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 -# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/en7571_def.h" 1 -# 15 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 11 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 +# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/mt7570_reg.h" 1 +# 12 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 +# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/mt7570_def.h" 1 +# 13 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_global.h" 1 @@ -47935,7 +47933,7 @@ extern PHY_GlbPriv_T *gpPhyPriv ; -# 16 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 14 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_api.h" 1 @@ -48108,114 +48106,9 @@ void Ibias_temperature_set(void); void mt7570_param_status_real(PPHY_TransParam_T transceiver_param); void phy_trans_param_status_real(PPHY_TransParam_T transceiver_param); -# 17 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 -# 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/en7571_api.h" 1 - - - - -int en7571_init(void); -int en7571_ADC_temperature_get(void); -int en7571_ADC_voltage_get(void); -int en7571_EN7571_detection(void); -int en7571_LOS_calibration(int LOS_thld_H, int LOS_thld_L); -int en7571_Ibias_hysteresis(int Ibias_target , int pav_delta); -int en7571_Imod_hysteresis(int Imod_now,int Imod_target); -int en7571_Ibias_transfer(int Iav_target); -int en7571_RogueONU_status(void); - -UINT16 en7571_temperature_get_8472(void); -UINT16 en7571_supply_voltage_get_8472(void); -UINT16 en7571_bias_current_get_8472(void); -UINT16 en7571_TxPower_get_8472(void); -UINT16 en7571_RxPower_get_8472(void); - -UINT32 en7571_info(uint select); -UINT32 en7571_SVADC_get(void); -UINT32 en7571_PWRADC_get(void); -UINT32 en7571_RSSI_get(void); -UINT32 en7571_dark_current(void); - -void en7571_TGEN(int xPON); -void en7571_TxSD_level_set(void); -void en7571_LOS_level_set(void); -void en7571_ADC_calibration(void); -void en7571_APD_initialization(void); -void en7571_APD_control(void); -void en7571_APD_DAC(UINT8 DAC); -void en7571_load_Tx_cal_data(void); -void en7571_RogueONU_clear(void); -void en7571_safe_circuit_reset(void); -void en7571_trans_model_setting(void); -void en7571_tx_power_alarm_get(void); -void en7571_rx_power_alarm_get(void); -void en7571_PWRADC_calibration(void); -void en7571_PWRADC_enable(void); -void en7571_RSSI_calibration(void); -void en7571_xPON_Tx_calibration(int input); -void en7571_save_flash_APD(uint slope_up, uint slope_dn, uint VAPD25); -void en7571_save_flash_LOS(void); -void en7571_save_flash_DDMI_TxPower(uint TxPower, uint offset); -void en7571_save_flash_DDMI_RxPower(uint RxPower, uint offset); -void en7571_save_flash_Tx_data(void); -void en7571_save_flash_EnvTemp(int temperature_input); -void en7571_APD_I2C_write(unchar ptr[1]); -void en7571_DDMI_check_8472(void); -void en7571_BoB_info(void); -void en7571_temperature_get(void); -void en7571_calibration_pattern(int input); -void en7571_disable_pattern(void); -void en7571_CDR(int CDR_switch); -void en7571_internal_clock(void); -void en7571_HWKT(int input); -void en7571_hw_reset(void); -void en7571_reg_init(void); -void en7571_mpdh_stepsize(int input); -void en7571_T1delay_setting(int input); -void en7571_7571_enable(void); -void en7571_DCL_start(void); -void en7571_DCL_stop(void); -void en7571_sysotms(void); -void en7571_cal_Iav_Imod(UINT32 Iav_mod_k, int I); -void en7571_cal_Pav_P1(UINT32 Pav_P1_k, int P); -void en7571_cal_force_mode(void); -void en7571_sw_reset(void); -void en7571_RSSI_gain_init(void); -void en7571_LOS_init(void); -void en7571_fine_tune_PWR_ER(int pwr_er,int up_dn); -void en7571_SWKT(void); -void en7571_OPKT(void); -void en7571_change_Imod(UINT32 input); -void en7571_change_Ibias(UINT32 input); -void en7571_change_mpdh(UINT32 input); -void en7571_cross_Imod(UINT32 input); -void en7571_cross_Ibias(UINT32 input); -void en7571_VBR_find(int High , int Low); -void en7571_LOS_find(int LOS_find); -void en7571_eFuse_temperature_get(void); -void en7571_force_mode(void); -void en7571_auto_lock_mode(void); -void en7571_tune_KT(UINT16 input); -void en7571_config(void); -void en7571_link_reg(int input); -void en7571_burst_ctrl(int input); -void en7571_LUT_Tracking(void); -void en7571_LUT_recover(void); -void en7571_show_LUT(void); -void en7571_SingleClosedLoopMode(void); -void en7571_OpenLoopMode(int input); -void MBI(int a, int b); -void en7571_get_linkup_infor(void); -void en7571_Pavg_close_loop(void); -void en7571_islinkstauschange(void); -void en7571_closeloop_reset(void); -void en7571_Iavg_transfer(void); -void en7571_WatchDog(void); -void en7571_tuneBiasModCurrent(UINT16 bias, UINT16 mod); -void en7571_param_status_real(PPHY_TransParam_T transceiver_param); -# 18 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 15 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_types.h" 1 -# 19 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 16 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_debug.h" 1 @@ -48230,9 +48123,9 @@ PHY_MSG_TRACE = 0x0008, PHY_MSG_DBG = 0x0010 } xPON_PHY_DebugMsg_t ; -# 20 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 17 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy.h" 1 -# 21 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 18 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_init.h" 1 @@ -48266,102 +48159,81 @@ } extern struct workqueue_struct * i2c_access_queue; -# 22 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 +# 19 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 # 1 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_tx.h" 1 # 47 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/inc/phy_tx.h" int phy_gpon_preamble(PPHY_GponPreb_T pon_preb); int phy_tx_fec_status(void); void mt7570_safe_circuit_reset_for_work_queue(struct work_struct * worker); void en7571_safe_circuit_reset_for_work_queue(struct work_struct * worker); -# 23 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" 2 - - -extern atomic_t i2c_protect; -extern unsigned int en7571_delay1; -extern unsigned int en7571_delay2; - -int en7571_version = 11; -int en7571_internal_DDMI = 1; -int en7571_fast_DDMI = 0; -int en7571_xPON_mode = -1; -int en7571_select = 0; -int en7571_RSSI_Vref = 0; -int en7571_RSSI_V = 0; -int en7571_PatternEnabled = 0; -int en7571_DDMI_rx_cal_flag = 0; -int en7571_ERC = 0; -int en7571_SCL = 0; -int en7571_DOL = 0; -int en7571_KT = 0; -int en7571_Pav_loop = 0; -int en7571_ver = -1; -int en7571_sys_mode = 1; -int en7571_cross = 1; -int en7571_cross_cnt_Imod = 0; -int en7571_cross_cnt_Ibias = 0; - -int Iav_linkup_now = 0; -int Imod_linkup_now = 0; -int Ibias_linkup_now = 0; -int need_crossing_Ibias = 0; -int need_crossing_Imod = 0; - -int en7571_delay_1 = 0; -int en7571_delay_2 = 0; - -float en7571_IC_temperature = 25.0; -float en7571_BOSA_temperature = 20.0; -float en7571_Env_temperature = 25.0 ; -float en7571_APD_voltage = 35.0; -float en7571_ADC_slope = 0; -float en7571_ADC_offset = 0; -float en7571_eFuse_temperature_offset = 0 ; - -UINT16 en7571_DDMI_voltage = 0; -UINT16 en7571_DDMI_current = 0; -UINT16 en7571_DDMI_temperature = 0; -UINT16 en7571_DDMI_tx_power = 0; -UINT16 en7571_DDMI_rx_power = 0; - -UINT32 en7571_temperature_ADC = 0; -UINT32 en7571_voltage_ADC = 0; -UINT32 en7571_RSSI_current = 0; -UINT32 en7571_PWRADC = 0; -UINT32 en7571_PWRADC_offset = 0; -UINT32 en7571_Tapd = 60; -UINT32 en7571_alarm = 0; -UINT32 en7571_flash_matrix[100]; -# 100 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -static unsigned long en7571_irq_flag = 0; - -void mbi_ctrl_set(u32 ctrl_val) -{ - u32 mbi_ctrl_reg = 0; - u32 mbi_ctrl = 0; - - u32 wan_cfg = GET_WAN_CONF(); - - - - mbi_ctrl_reg = (1 == (wan_cfg&0x03)) ? 0x6000 : 0x4160; - mbi_ctrl = get_xpon_data(mbi_ctrl_reg); - if(0 == ctrl_val){ - mbi_ctrl |= (1 << 8); - do { do { ({ unsigned long __dummy; typeof(en7571_irq_flag) __dummy2; (void)(&__dummy == &__dummy2); 1; }); en7571_irq_flag = arch_local_irq_save(); } while (0); } while (0); - set_xpon_data(mbi_ctrl_reg, mbi_ctrl); - }else{ - mbi_ctrl &= ~(1 << 8); - set_xpon_data(mbi_ctrl_reg, mbi_ctrl); - do { do { ({ unsigned long __dummy; typeof(en7571_irq_flag) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_local_irq_restore(en7571_irq_flag); } while (0); } while (0); - } - set_xpon_data(mbi_ctrl_reg, mbi_ctrl); -} - +# 20 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" 2 +int mt7570_version = 110; +int internal_DDMI = 1; +int fast_DDMI = 0; +int TEC = 1; +int TEC_switch = 0; +int xPON_mode = -1; +int mt7570_select = 0; +int vEN7570 = 1; +int BG1V76 = 0; +int BG0V875 = 0; +int RSSI_Vref = 0; +int RSSI_V = 0; +int ETC = 0; +int FiberPlug = 0; +int PatternEnabled = 0; + +float RSSI_factor = 0; +int delay_cnt = 0; +uint cnt7570 = 0; +int MPD_current_cnt = 0; +int T0C_extension = 0; +float IC_temperature = 25.0; +float BOSA_temperature = 20.0; +float Env_temperature = 25.0; +float APD_voltage = 35.0; +float ADC_slope = 0; +float ADC_offset = 0; + +int global_temperature_code = 0; +int global_vcc_code = 0; + +uint global_bias_current = 0; +uint global_MPDL = 0; +uint global_MPDH = 0; +uint global_modulation_current = 0; + +int global_rssi_current = 0; +int global_mpd_current = 0; +int global_RSSI_current = 0; +int global_MPD_current = 0; +int global_MPD_current_var = 0; +int global_DDMI_rx_cal_flag =0; + +UINT16 global_supply_voltage_8472 = 0; +UINT16 global_IC_temperature_8472 = 0; +UINT16 global_bias_current_8472 = 0; +UINT16 DDMI_voltage = 0; +UINT16 DDMI_current = 0; +UINT16 DDMI_temperature = 0; +UINT16 DDMI_tx_power = 0; +UINT16 DDMI_rx_power = 0; + +int Ibias_outputlow_flag = 0; +int BER_result = 0 ; + +uint MPD_current_offset = 0; +uint T_APD = 600; +uint flash_matrix[100]; +uint mt7570_alarm = 0; +uint SCL =0 ; +uint DOL =0 ; +uint BiasTracking_switch = 0; +uint BOSA_Ith = 3000; - -uint en7571_LUT_Ibias_Imod[64][2] = +uint LUT_Ibias_Imod[64][2] = { {0x106, 0x3b2}, @@ -48429,8 +48301,119 @@ {0x666, 0x6ce}, {0x666, 0x6ce} }; -# 207 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_save_flash_APD(uint slope_up, uint slope_dn, uint VAPD) + + + + + +atomic_t i2c_protect = { (0) }; + +int +i2c_access_protect(void){ + + int count = 10000; + while(({ union { typeof((&i2c_protect)->counter) __val; char __c[1]; } __u; if (1) __read_once_size(&((&i2c_protect)->counter), __u.__c, sizeof((&i2c_protect)->counter)); else __read_once_size_nocheck(&((&i2c_protect)->counter), __u.__c, sizeof((&i2c_protect)->counter)); __u.__val; }) == 1 ){ + (__builtin_constant_p(1) ? ((1) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1)); + if(count==0) return -1; + count --; + } + return 0; +} +# 185 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_register_dump(int length) +{ + int i = 0; + unchar ptr[4]; + uint return_value = 0; + for(i = 0 ; i < length ; i++) + { + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (i<<2), ptr, 4); + return_value = ptr[0] | (ptr[1]<<8) | (ptr[2]<<16) | (ptr[3]<<24); + printk("EN7570 reg 0x%.3x", i*4); + printk("\t%.8x\n", return_value); + } +} +# 211 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int get_flash_register(int address_offset) +{ + uint return_int = 0; + return_int = flash_matrix[(address_offset>>2)]; + return return_int; +} +# 229 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int get_flash_matrix(void) +{ + + struct file *srcf = ((void *)0); + char *src = ((void *)0); + mm_segment_t orgfs; + + + + src = "/tmp/7570_bob.conf"; + + + orgfs = (current_thread_info()->addr_limit); + set_fs(0x00000000); + + if (src && *src) + { + srcf = filp_open(src, 00000000, 0); + if (IS_ERR(srcf)) + { + printk("--> Error opening \n"); + goto error; + } + else + { + + ecnt_kernel_fs_read(srcf, flash_matrix, sizeof(flash_matrix),&srcf->f_pos); + filp_close(srcf,((void *)0)); + } + } + set_fs(orgfs); + return 0; + +error: + set_fs(orgfs); + return -1; + +} +# 279 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register(uint reg, uint offset) +{ + flash_matrix[offset>>2] = reg; +} +# 295 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_default(void) +{ + int index = 0; + for(index = 0; index < 40; index++) + flash_matrix[index] = 0xffffffff; + +} +# 314 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_BiasModCurrent(void) +{ + uint ibias = mt7570_information_output(0x03); + uint imod = mt7570_information_output(0x04 ); + set_flash_register(ibias, (0x000)); + set_flash_register(imod , (0x004) ); + printk("Ibias = 0x%x\n", ibias); + printk("Imod = 0x%x\n" , imod ); +} +# 335 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_P0P1(void) +{ + uint p0 = mt7570_information_output(0x05); + uint p1 = mt7570_information_output(0x06); + set_flash_register(p0, (0x008)); + set_flash_register(p1, (0x00c)); + printk("P0 = 0x%x\n", p0); + printk("P1 = 0x%x\n", p1); +} +# 356 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_APD(uint slope_up, uint slope_dn, uint VAPD) { set_flash_register(slope_up, (0x010)); set_flash_register(slope_dn, (0x014)); @@ -48439,730 +48422,708 @@ printk("slope down = 0x%x\n", slope_dn); printk("VAPD@25C = 0x%x\n" , VAPD ); } -# 224 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_save_flash_LOS(void) +# 377 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_LOS(void) { unchar ptr[4]; - uint temp = 0; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); ptr[3] = ptr[3] & 0x7f; ptr[2] = ptr[2] & 0x7f; - printk("LOS threshold = 0x%x\n", ptr[3]); - printk("SD threshold = 0x%x\n", ptr[2]); - temp = (ptr[2]<<16) | ptr[3]; - set_flash_register(temp, (0x020)); + set_flash_register(ptr[3], (0x024)); + set_flash_register(ptr[2], (0x020)); + printk("LOS low = 0x%x\n", ptr[3]); + printk("LOS high = 0x%x\n", ptr[2]); } -# 247 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_save_flash_DDMI_TxPower(uint TxPower, uint offset) +# 400 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_DDMI_TxPower(uint TxPower, uint offset) { uint input = 0; - input = ( (TxPower<<16)&0xffff0000 ) | (en7571_PWRADC_get()&0x0000ffff); + input = ( (TxPower<<16)&0xffff0000 ) | (mt7570_MPD_current()&0x0000ffff); set_flash_register(input, offset); + if( vEN7570==0 && offset==(0x040) ) + set_flash_register(input&0x0000ffff, (0x088)); + printk("0x%08x\n", input); } -# 265 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_save_flash_DDMI_RxPower(uint RxPower, uint offset) +# 423 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_DDMI_RxPower(uint RxPower, uint offset) { uint input = 0; - input = ( (RxPower<<16)&0xffff0000 ) | (en7571_RSSI_get()&0x0000ffff); + input = ( (RxPower<<16)&0xffff0000 ) | (mt7570_RSSI_current()&0x0000ffff); set_flash_register(input, offset); printk("0x%08x\n", input); - en7571_DDMI_rx_cal_flag = 0; + global_DDMI_rx_cal_flag = 0; } -# 282 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_save_flash_Tx_data(void) +# 444 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_TIAGAIN(void) { - unchar ptr[4]; - UINT32 imod = 0; - UINT32 iav = 0; - UINT32 write_data = 0; - UINT32 pav = 0; - UINT32 p1 = 0; - - if( get_flash_register((0x008)) != 0xffffffff ) - { - set_flash_register( 0x2, (0x090)); - printk("Open loop saved\n"); - return; - } - - - imod = en7571_info(0x04 ); - iav = en7571_info(0x02); - printk("Ibias = 0x%x\n", en7571_info(0x03)); - printk("Imod = 0x%x\n" , imod ); - printk("Iav = 0x%x\n" , iav ); - write_data = (iav<<16) | imod; - set_flash_register( write_data, (0x000)); - - write_data = 0; - - - p1 = en7571_info(0x06); - pav = en7571_info(0x01); - printk("P1 = 0x%x\n" , p1 ); - printk("Pav = 0x%x\n" , pav ); - write_data = (pav<<16) | p1; - set_flash_register(write_data, (0x004)); - - write_data = 0; - - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4); - ptr[1] = (ptr[1] & 0x7f); - ptr[2] = (ptr[2] & 0x7f); - printk("T0C = 0x%x\nT1C = 0x%x\n", ptr[2], ptr[1]); - write_data = ( (ptr[1]<<8) | ptr[2] ) << 16; - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4); - printk("T0/T1 delay = 0x%x\n", ptr[0]); - write_data = write_data | (ptr[0]&0x000000ff); - set_flash_register( write_data, (0x00c)); - + unchar ptr[1]; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000)+0x0001 , ptr, 1); + ptr[0] = ptr[0] >> 6; + set_flash_register(ptr[0], (0x028)); + printk("TIAGAIN = 0x%x\n", ptr[0]); } -# 340 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_save_flash_EnvTemp(int temperature_input) +# 466 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_EnvTemp(int temperature_input) { uint write_data = 0; int Env_temperature_offset = 0; - set_flash_register(temperature_input, (0x08c)); + set_flash_register(temperature_input, (0x060)); printk("Env_temperature = %d.%.1dC\n", temperature_input/10, temperature_input%10); - en7571_temperature_get(); + mt7570_temperature_get(); - Env_temperature_offset = en7571_IC_temperature*10 - temperature_input; + Env_temperature_offset = IC_temperature*10 - temperature_input; if( Env_temperature_offset < 0 ) printk("Not thermal balance\n"); else { printk("Env_temperature_offset = %d.%.1dC\n", Env_temperature_offset/10, Env_temperature_offset%10); - write_data = (Env_temperature_offset << 16) | (get_flash_register((0x024)) & 0x0000ffff); - set_flash_register(write_data, (0x024)); + write_data = (Env_temperature_offset << 16) | (get_flash_register((0x084)) & 0x0000ffff); + set_flash_register(write_data, (0x084)); } } -# 374 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_xPON_Tx_calibration(int input) +# 504 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_temperature_offset(uint temperature_input, uint slope) { - en7571_ERC = 0; - en7571_KT = 0; - en7571_SCL = 0; - en7571_DOL = 0; - - en7571_DCL_stop(); - + uint tmp; - phy_mode_config(input, (1)); + if (temperature_input > 0x500) + { + printk ("Please input temperature value in range : 0 ~ 0x500\n"); + return; + } - set_flash_register(0xffffffff, (0x00c)); - + if (slope == 0) + slope = 0xffff; + else + printk("Temperature slope = 0x%x\n",slope); - en7571_TGEN(input); + tmp = (slope << 16) | 0xffff; + set_flash_register(tmp, (0x080)); - en7571_reg_init(); + mt7570_temperature_get(); + tmp = temperature_input - IC_temperature*10 + 495.8*10; + printk("Temperature offset = 0x%x\n",tmp); - en7571_calibration_pattern(input); + tmp = (tmp & 0x0000ffff) | (slope << 16) ; + set_flash_register(tmp, (0x080)); +} +# 548 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_T0T1delay(void) +{ + unchar ptr[1]; - en7571_cal_force_mode(); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 1); + set_flash_register(ptr[0], (0x098)); + printk("T0/T1 delay = 0x%x\n", ptr[0]); } -# 414 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_calibration_pattern(int input) +# 571 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_T0CT1C(void) { - printk("en7571_calibration_pattern \n"); - + unchar ptr[4]; - REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_START); - ( (__builtin_constant_p(500) && (500)<=2) ? (__builtin_constant_p((500)*1000) ? (((500)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((500)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((500)*1000)) : ({unsigned long __ms=(500); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4); + ptr[1] = (ptr[1] & 0x7f); + ptr[2] = (ptr[2] & 0x7f); + set_flash_register( ( (ptr[1]<<16) | ptr[2] ), (0x09c)); + printk("T0C = 0x%x\nT1C = 0x%x\n", ptr[2], ptr[1]); +} +# 596 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void set_flash_register_Tx_data(void) +{ + set_flash_register_BiasModCurrent(); + set_flash_register_P0P1(); + set_flash_register_TIAGAIN(); + set_flash_register_T0T1delay(); + set_flash_register_T0CT1C(); +} +# 617 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int save_flash_matrix(void) +{ + struct file *srcf = ((void *)0); + + char *src = ((void *)0); + mm_segment_t orgfs; + + src = "/tmp/7570_bob.conf"; + orgfs = (current_thread_info()->addr_limit); + set_fs(0x00000000); + if (src && *src) + { + srcf = filp_open(src, 00000002|00000100, 0); + if (IS_ERR(srcf)) + { + printk("--> Error opening \n"); + goto error; + } + else + { + srcf->f_pos = 0; + if(ecnt_kernel_fs_write(srcf, flash_matrix, sizeof(flash_matrix), &srcf->f_pos) >0) + { + printk("--> write flash_matrix success \n"); + } + else + { + printk("--> Error write \n"); + filp_close(srcf,((void *)0)); + goto error; + } - en7571_CDR(0); + filp_close(srcf,((void *)0)); + } + } + set_fs(orgfs); + return 0; - en7571_DCL_stop(); - en7571_link_reg(0); - en7571_sysotms(); - en7571_DCL_start(); + error: + set_fs(orgfs); + return -1; - if( input == PHY_GPON_CONFIG ) +} +# 674 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void flash_dump(void) +{ + int i = 0; + int j = 0; + for(i=0; i<40; i++) { - - phy_ben_switch((1)); - - phy_tx_test_pattern(0x06); - phy_mode_config(PHY_GPON_CONFIG, (1)); - printk("PRBS23 enabled\n"); + j = 4*i; + printk("FLASH address 0x%x", j); + printk("\t"); + printk("0x%08x\n", get_flash_register(j)); } - else if( input == 0xa7050701 ) - { +} +# 699 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void DOL_flash_dump(void) +{ + int i = 0; + int j = 0; - phy_ben_switch((1)); + printk("FLASH"); + printk("\t"); + printk("temperature"); + printk("\t"); + printk("Value\n"); - phy_tx_test_pattern(0x06); - phy_mode_config(0xa7050701, (1)); - printk("PRBS23 enabled\n"); + for(i=0; i<16; i++) + { + j = 0xa0+4*i; + printk("0x%x", j); + printk("\t"); + printk("%d", -40+(10*i)); + printk("\t"); + printk("\t"); + printk("0x%08x\n", get_flash_register(j)); } +} +# 735 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void GPON_Tx_calibration(void) +{ - else if( input == PHY_EPON_CONFIG ) - { + mt7570_ERC_filter(); - phy_ben_switch((1)); + mt7570_load_init_current(); - phy_tx_test_pattern(0x05); - phy_mode_config(PHY_EPON_CONFIG, (1)); - printk("PRBS7 enabled\n"); - } + phy_mode_config(PHY_GPON_CONFIG, (1)); - en7571_safe_circuit_reset(); + mt7570_TGEN(PHY_GPON_CONFIG); - en7571_RogueONU_clear(); + mt7570_calibration_pattern(PHY_GPON_CONFIG); - en7571_PatternEnabled = 1; - en7571_tune_KT(0xFFFF); -} -# 478 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_disable_pattern(void) -{ + mt7570_safe_circuit_reset(); - phy_ben_switch((0)); + phy_trans_power_switch((1)); + printk("GPON_Tx_calibration done\n"); +} +# 772 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void EPON_Tx_calibration(void) +{ - phy_tx_test_pattern(0x00); + mt7570_ERC_filter(); + mt7570_load_init_current(); - en7571_CDR(1); - en7571_DCL_stop(); - en7571_link_reg(1); - en7571_sysotms(); - en7571_DCL_start(); + phy_mode_config(PHY_EPON_CONFIG, (1)); - REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_STOP); + mt7570_TGEN(PHY_EPON_CONFIG); - en7571_safe_circuit_reset(); + mt7570_calibration_pattern(PHY_EPON_CONFIG); - en7571_RogueONU_clear(); + mt7570_safe_circuit_reset(); - printk("Pattern disabled\n"); - en7571_PatternEnabled = 0; + printk("EPON_Tx_calibration done\n"); } -# 519 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_CDR(int CDR_switch) +# 807 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int GPON_BER(int pattern) { + int read_data = 0; + mt7570_CDR(1); - uint read_data = 0; - if( CDR_switch == 0 ) - { + REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_START); + ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + phy_mode_config(PHY_GPON_CONFIG, (1)); + ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + set_pon_phy_data(0xbfaf0400 +0x00a0, 0x0); - read_data = get_pon_phy_data((0x1faf0000 + 0x4620)); - set_pon_phy_data((0x1faf0000 + 0x4620), (read_data | 0x100000)); + switch(pattern) + { + case 5: - read_data = get_pon_phy_data((0x1faf0000 + 0x4614)); - set_pon_phy_data((0x1faf0000 + 0x4614), (read_data | 0x4000000)); + set_pon_phy_data(0xbfaf0200 +0x00a0, 0x81fd53); + set_pon_phy_data(0xbfaf0200 +0x00a4, 0xffffff); + set_pon_phy_data(0xbfaf0400 +0x00a0, 0x5); - printk("CDR disabled\n"); - } - else if( CDR_switch == 1 ) - { + set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1); + break; + case 6: + set_pon_phy_data(0xbfaf0200 +0x00a0, 0x71fd53); + set_pon_phy_data(0xbfaf0200 +0x00a4, 0x7fffff); + set_pon_phy_data(0xbfaf0400 +0x00a0, 0x6); + set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1); + break; + case 7: - read_data = get_pon_phy_data((0x1faf0000 + 0x4614)); - set_pon_phy_data((0x1faf0000 + 0x4614), (read_data & 0xFBFFFFFF)); + set_pon_phy_data(0xbfaf0200 +0x00a0, 0xff1fd53); + set_pon_phy_data(0xbfaf0200 +0x00a4, 0x7ffffff); + set_pon_phy_data(0xbfaf0400 +0x00a0, 0x7); - printk("CDR enabled\n"); + set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1); + break; + default: + break; } + ( (__builtin_constant_p(250) && (250)<=2) ? (__builtin_constant_p((250)*1000) ? (((250)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((250)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((250)*1000)) : ({unsigned long __ms=(250); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + + read_data = get_pon_phy_data(0xbfaf0200 +0x00c4); + + if( read_data == 5 ) + printk("Pattern Aligned\n"); + else + printk("Aligned Failed\n"); + + printk("%x\n", read_data); + + return read_data; } -# 569 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -int en7571_init(void) +# 884 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int EPON_BER(int pattern) { - i2c_access_queue = __alloc_workqueue_key(("%s"), (WQ_MEM_RECLAIM), (1), ((void *)0), ((void *)0), ("i2c_access_queue")); - do { __init_work(((&gpPhyPriv->EN7570_reset)), 0); ((&gpPhyPriv->EN7570_reset))->data = (atomic_long_t) { (WORK_STRUCT_NO_POOL) }; INIT_LIST_HEAD(&((&gpPhyPriv->EN7570_reset))->entry); ((&gpPhyPriv->EN7570_reset))->func = ((en7571_safe_circuit_reset_for_work_queue)); } while (0); + int read_data = 0; + mt7570_CDR(1); - if(get_flash_matrix() == 0) - printk("FLASH matrix got\n"); - else - set_flash_register_default(); + REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_START); + ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + phy_mode_config(PHY_EPON_CONFIG, (1)); + ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - en7571_sw_reset(); + set_pon_phy_data(0xbfaf0400 +0x00a0, 0x0); - en7571_hw_reset(); + switch(pattern) + { + case 5: + set_pon_phy_data(0xbfaf0200 +0x00a0, 0x81fd53); - en7571_7571_enable(); + set_pon_phy_data(0xbfaf0200 +0x00a4, 0xffffff); + set_pon_phy_data(0xbfaf0400 +0x00a0, 0x5); - en7571_PWRADC_calibration(); + set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1); + break; + case 6: + set_pon_phy_data(0xbfaf0200 +0x00a0, 0x71fd53); - en7571_PWRADC_enable(); + set_pon_phy_data(0xbfaf0200 +0x00a4, 0x7fffff); + set_pon_phy_data(0xbfaf0400 +0x00a0, 0x6); - en7571_ADC_calibration(); + set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1); + break; + case 7: + set_pon_phy_data(0xbfaf0200 +0x00a0, 0xff1fd53); - en7571_RSSI_calibration(); + set_pon_phy_data(0xbfaf0200 +0x00a4, 0x7ffffff); + set_pon_phy_data(0xbfaf0400 +0x00a0, 0x7); - en7571_eFuse_temperature_get(); + set_pon_phy_data(0xbfaf0400 +0x00a4, 0x1); + break; + default: + break; + } + ( (__builtin_constant_p(250) && (250)<=2) ? (__builtin_constant_p((250)*1000) ? (((250)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((250)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((250)*1000)) : ({unsigned long __ms=(250); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + read_data = get_pon_phy_data(0xbfaf0200 +0x00c4); - set_pon_phy_data((0xbfaf0100 +0x0038), 0x10f); + if( read_data == 5 ) + printk("Pattern Aligned\n"); + else + printk("Aligned Failed\n"); + return read_data; +} +# 959 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_restart_ERC(void) +{ + unchar ptr[4]; - if( get_flash_register((0x094)) == 0x07050701 ) - { - printk("Start GPON Tx Calibration\n"); - phy_mode_config(PHY_GPON_CONFIG, (1)); - en7571_xPON_mode = PHY_GPON_CONFIG; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4); + ptr[0] = ptr[0] & 0xfe; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 ); - en7571_TGEN(PHY_GPON_CONFIG); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4); + ptr[0] = ptr[0] & 0xfe; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4 ); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4); + ptr[0] = (ptr[0] & 0xfe) | (0x01); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 ); - en7571_APD_initialization(); - if( get_flash_register((0x01c)) != 0xffffffff ) - { - en7571_Tapd = get_flash_register((0x01c)); - if( en7571_Tapd < 10 ) - { - printk("APD update period is too short, reset to 10s\n"); - en7571_Tapd=10; - } - } - en7571_APD_control(); - } + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4); + ptr[0] = (ptr[0] & 0xfe) | (0x01); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4 ); - else if( get_flash_register((0x094)) == 0xe7050701 ) - { - printk("Start EPON Tx Calibration\n"); - phy_mode_config(PHY_EPON_CONFIG, (1)); - en7571_xPON_mode = PHY_EPON_CONFIG; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "ERC restarted\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 980) ; }; +} +# 997 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_calibration_pattern(int input) +{ + REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_START); - en7571_TGEN(PHY_EPON_CONFIG); - } + mt7570_CDR(0); - else if( get_flash_register((0x094)) == 0xa7050701 ) + if( input == PHY_GPON_CONFIG ) { - printk("Start xPON Tx Calibration\n"); - phy_mode_config(PHY_GPON_CONFIG, (1)); - en7571_xPON_mode = PHY_GPON_CONFIG; - - en7571_TGEN(0xa7050701); + phy_ben_switch((1)); - en7571_APD_initialization(); - if( get_flash_register((0x01c)) != 0xffffffff ) - { - en7571_Tapd = get_flash_register((0x01c)); - if( en7571_Tapd < 10 ) - { - printk("APD update period is too short, reset to 10s\n"); - en7571_Tapd=10; - } - } - en7571_APD_control(); + phy_tx_test_pattern(0x06); + phy_mode_config(PHY_GPON_CONFIG, (1)); + printk("PRBS23 enabled\n"); } - - else + else if( input == PHY_EPON_CONFIG ) { - en7571_LOS_init(); - en7571_internal_DDMI = 0; - printk("Internal DDMI Disabled\n"); - return 0; - } - en7571_reg_init(); + phy_ben_switch((1)); + phy_tx_test_pattern(0x0b); + phy_mode_config(PHY_EPON_CONFIG, (1)); + printk("8B/10B pattern enabled\n"); + } - en7571_load_Tx_cal_data(); + PatternEnabled = 1; +} +# 1043 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_disable_pattern(void) +{ - en7571_TxSD_level_set(); + phy_ben_switch((0)); - en7571_RSSI_gain_init(); + phy_tx_test_pattern(0x00); + phy_tx_test_pattern(0x0c); - en7571_LOS_level_set(); + mt7570_CDR(1); - en7571_RogueONU_clear(); + REPORT_EVENT_TO_MAC(PHY_EVENT_CALIBRATION_STOP); - en7571_safe_circuit_reset(); + printk("Pattern disabled\n"); + PatternEnabled = 0; +} +# 1076 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_CDR(int CDR_switch) +{ + uint read_data = 0; + if( CDR_switch == 0 ) + { - en7571_link_reg(1); - en7571_DCL_start(); - en7571_config(); + read_data = get_pon_phy_data((0x1faf0000 + 0x4620)); + set_pon_phy_data((0x1faf0000 + 0x4620), (read_data | 0x100000)); - printk("EN7571 Initialization Done!\n"); - return 0 ; -} -# 720 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_sysotms(void) -{ - int i = 0; - unchar ptr[1]; - unchar temRG[768]; + read_data = get_pon_phy_data((0x1faf0000 + 0x4614)); + set_pon_phy_data((0x1faf0000 + 0x4614), (read_data | 0x4000000)); - for(i = 0x000 ; i < 0x300 ; i++) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, i, ptr, 1); - temRG[i]=ptr[0]; - } - en7571_sw_reset(); - for(i = 0x000 ; i < 0x300 ; i++) - { - ptr[0] = temRG[i]; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, i, ptr, 1); + printk("CDR disabled\n"); } + else if( CDR_switch == 1 ) + { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); - ptr[0] = (ptr[0] & (0xfe)) | (0x01); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); -} -# 756 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_HWKT(int input) -{ - unchar ptr[4]; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0230), ptr, 3); - if( input == 1 ) - ptr[0] = (ptr[0] & 0xfe) | 0x01; - else if( input == 0 ) - ptr[0] = (ptr[0] & 0xfe); + read_data = get_pon_phy_data((0x1faf0000 + 0x4614)); + printk("read data %x\n",read_data); + printk("write data %x\n",(read_data & 0xFBFFFFFF)); + set_pon_phy_data((0x1faf0000 + 0x4614), (read_data & 0xFBFFFFFF)); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0230), ptr, 3); -} -# 777 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_hw_reset(void) -{ - unchar ptr[4]; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4); - ptr[1] = ptr[1] & 0xfe; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4); - ptr[1] = (ptr[1]&0xfe) | 0x01; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4); + printk("CDR enabled\n"); + } } -# 799 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_reg_init(void) +# 1127 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_init(void) { - unchar ptr[4]; - UINT32 Ibias_min = 0x080; - UINT32 Imod_min = 0x032; - UINT32 Imax = 0xfff; + uint read_data = 0; + i2c_access_queue = __alloc_workqueue_key(("%s"), (WQ_MEM_RECLAIM), (1), ((void *)0), ((void *)0), ("i2c_access_queue")); + do { __init_work(((&gpPhyPriv->EN7570_reset)), 0); ((&gpPhyPriv->EN7570_reset))->data = (atomic_long_t) { (WORK_STRUCT_NO_POOL) }; INIT_LIST_HEAD(&((&gpPhyPriv->EN7570_reset))->entry); ((&gpPhyPriv->EN7570_reset))->func = ((mt7570_safe_circuit_reset_for_work_queue)); } while (0); - printk("en7571_reg_init \n"); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0220), ptr, 4); - ptr[3] = (ptr[3] & 0xf0) | (Ibias_min >> 8); - ptr[2] = (ptr[2] & 0x00) | (Ibias_min & 0xff); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0220), ptr, 4); + if(get_flash_matrix() == 0) + printk("FLASH matrix got\n"); + else + set_flash_register_default(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0224), ptr, 4); - ptr[3] = (ptr[3] & 0xf0) | (Imod_min >> 8);; - ptr[2] = (ptr[2] & 0x00) | (Imod_min & 0xff); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0224), ptr, 4); + mt7570_sw_reset(); - ptr[3] = (Imax >> 8); - ptr[2] = (Imax & 0xff); - ptr[1] = 0x00; - ptr[0] = 0x00; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0240), ptr, 4); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0244), ptr, 4); + mt7570_TIAGAIN_set(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4); + mt7570_ERC_filter(); - ptr[3] = (ptr[3] & 0xf0) | (0x200 >> 8); - ptr[2] = (0x200 & 0xff); - ptr[1] = (ptr[1] & 0xf0) | (0x300 >> 8); - ptr[0] = (0x300 & 0xff); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4); + mt7570_MPD_current_calibration(); + mt7570_ADC_calibration(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4); - ptr[0] = (ptr[0] & 0xfc) | 0x02; - ptr[3] = (ptr[3] & 0xc0) | 0x3f; - ptr[2] = (ptr[2] & 0xc0) | 0x25; - ptr[1] = (ptr[1] & 0xc0) | 0x3f; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4); + mt7570_RSSI_calibration(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4); - ptr[2] = (ptr[2] & 0xc0) | 0x25; - ptr[1] = (ptr[1] & 0xc0) | 0x3f; - ptr[0] = (ptr[0] & 0xc0) | 0x25; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4); + read_data = get_flash_register((0x094)); + if(read_data == 0x07050700) + { + printk("Start GPON Tx Calibration\n"); + phy_mode_config(PHY_GPON_CONFIG, (1)); + xPON_mode = PHY_GPON_CONFIG; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); - ptr[3] = (ptr[3] & 0xf8) | 0x01; - ptr[1] = 0x02; - ptr[0] = 0x04; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); + mt7570_RSSI_gain_init(); + mt7570_LOS_level_set(); - en7571_force_mode(); + set_pon_phy_data((0xbfaf0100 +0x0038), 0x10f); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x023C), ptr, 4); - ptr[1] = (ptr[1] & 0xfc) | (0x007 >> 8); - ptr[0] = (0x007 & 0xff); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x023C), ptr, 4); + mt7570_TGEN(PHY_GPON_CONFIG); + mt7570_load_init_current(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x022C), ptr, 4); - ptr[3] = (ptr[3] & 0xc0) | 0x02; - ptr[0] = (ptr[0] & 0xf8) | 0x07; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x022C), ptr, 4); + mt7570_load_MPDL_MPDH(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0260), ptr, 4); - ptr[3] = (ptr[3] & 0xf8) | 0x03; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0260), ptr, 4); + mt7570_TxSD_level_set(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0254), ptr, 4); - ptr[3] = 0x00; - ptr[2] = 0x00; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0254), ptr, 4); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0250), ptr, 4); - ptr[2] = ptr[2] & 0x80; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0250), ptr, 4); + mt7570_APD_initialization(); + if( get_flash_register((0x01c)) != 0xffffffff ) + { + T_APD = get_flash_register((0x01c)); + if( T_APD < 10 ) + { + printk("APD update period is too short, reset to 10s\n"); + T_APD=10; + } + } + mt7570_APD_control(); + } -} -# 908 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_mpdh_stepsize(int input) -{ - unchar ptr[4]; - if( input == 0 ) + else if(read_data == 0xe7050700) { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4); - ptr[2] = (ptr[2] & 0xc0); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4); + printk("Start EPON Tx Calibration\n"); + phy_mode_config(PHY_EPON_CONFIG, (1)); + xPON_mode = PHY_EPON_CONFIG; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4); - ptr[2] = (ptr[2] & 0xc0); - ptr[0] = (ptr[0] & 0xc0); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4); - } - else if( input == 1 ) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4); - ptr[2] = (ptr[2] & 0xc0) | 0x25; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0234), ptr, 4); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4); - ptr[2] = (ptr[2] & 0xc0) | 0x25; - ptr[0] = (ptr[0] & 0xc0) | 0x25; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0238), ptr, 4); - } -} -# 943 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_7571_enable(void) -{ - unchar ptr[4]; + mt7570_RSSI_gain_init(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - ptr[0] = (ptr[0] & 0xfe) | 0x01; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); -} -# 960 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_DCL_start(void) -{ - unchar ptr[4]; + mt7570_LOS_level_set(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - ptr[1] = (ptr[1] & 0xfe) | 0x01; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); -} -# 977 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_DCL_stop(void) -{ - unchar ptr[4]; + set_pon_phy_data((0xbfaf0100 +0x0038), 0x10f); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - ptr[1] = ptr[1] & 0xfe; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); -} + mt7570_TGEN(PHY_EPON_CONFIG); + mt7570_load_init_current(); -void en7571_cal_Iav_Imod(UINT32 input, int I) -{ - unchar ptr[4]; - UINT32 keep_pav = en7571_info(0x01); + mt7570_load_MPDL_MPDH(); - en7571_DCL_stop(); - en7571_auto_lock_mode(); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4 ); - if( I == 1 ) - { - ptr[0] = input; - ptr[1] = (input >> 8); - ptr[2] = 0x200&0xff; - ptr[3] = (0x200 >> 8); - } - else if( I == 0 ) - { - ptr[2] = input; - ptr[3] = (input >> 8); + mt7570_TxSD_level_set(); } - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4 ); - - en7571_hw_reset(); - ( (__builtin_constant_p(200) && (200)<=2) ? (__builtin_constant_p((200)*1000) ? (((200)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((200)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((200)*1000)) : ({unsigned long __ms=(200); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - - en7571_DCL_start(); - if( I == 0 ) + else { - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4 ); - ptr[0] = keep_pav; - ptr[1] = (keep_pav >> 8); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); - - en7571_force_mode(); + internal_DDMI = 0; + printk("Internal DDMI Disabled\n"); + return 0; } -} - - - -void en7571_cal_Pav_P1(UINT32 input, int P) -{ - unchar ptr[4]; - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); - if( P == 1 ) + if( get_flash_register((0x070)) == 0x80000000) { - ptr[0] = input; - ptr[1] = (input >> 8); + SCL = 1; + mt7570_SingleClosedLoopMode(); } - else if( P == 0 ) + else if( get_flash_register((0x070)) == 0xc0000000) { - ptr[2] = input; - ptr[3] = (input >> 8); + DOL = 1; + mt7570_LUT_recover(); + mt7570_OpenLoopMode(); } - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); -} -void en7571_cal_force_mode(void) -{ - unchar ptr[4]; - printk("en7571_cal_force_mode \n"); + mt7570_RougeONU_clear(); - en7571_DCL_stop(); + mt7570_safe_circuit_reset(); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); - ptr[1] = 0x00; - ptr[0] = 0x00; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); + if( get_flash_register((0x02c)) == 0 ) + { + internal_DDMI = 0; + printk("Internal DDMI Disabled\n"); + } + else + { + printk("Internal DDMI Enabled\n"); + if( get_flash_register((0x02c)) == 2 ) + fast_DDMI = 1; + } - en7571_hw_reset(); - en7571_DCL_start(); + if( get_flash_register((0x08c)) == 0 ) + { + TEC = 0; + printk("TEC Disabled\n"); + } + else if( get_flash_register((0x08c)) != 0xffffffff ) + { + BOSA_Ith = get_flash_register((0x08c)); + printk("TEC Enabled, BOSA's Ith = %duA\n", BOSA_Ith); + } + else + { + printk("TEC Enabled\n"); + } - ( (__builtin_constant_p(200) && (200)<=2) ? (__builtin_constant_p((200)*1000) ? (((200)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((200)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((200)*1000)) : ({unsigned long __ms=(200); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4 ); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); + if( get_flash_register((0x07c)) == 1 ) + { + ETC = 1; + printk("ETC = 1\n"); + } + else if ( get_flash_register((0x07c)) == 2 ) + { + ETC = 2; + printk("ETC = 2\n"); + } + else if ( get_flash_register((0x07c)) == 3 ) + { + ETC = 3; + mt7570_LUT_recover(); + mt7570_temperature_get(); + mt7570_BiasTracking(); + printk("ETC = 3\n"); + printk("BiasTracking Enabled\n"); + } + else + { + printk("ETC Disabled\n"); + } - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); - ptr[1] = 0x02; - ptr[0] = 0x04; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); + printk("EN7570 Initialization Done!\n"); + return 0 ; } -# 1096 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_sw_reset(void) +# 1339 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_sw_reset(void) { unchar ptr[4]; @@ -49171,26 +49132,26 @@ ptr[0] = (ptr[0] & 0xf8) | (0x01); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0300), ptr, 4); } -# 1113 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_RSSI_gain_init(void) +# 1362 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_RSSI_gain_init(void) { unchar ptr[4]; phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4); - ptr[2] = (ptr[2] & 0xf8) | 0x05; + ptr[2] = (ptr[2] & 0xf8) | (0x05); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4); } -# 1133 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_TGEN(int xPON) +# 1387 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_TGEN(int xPON) { unchar ptr[4]; - UINT8 RGS_T0C = 0; - UINT8 RGS_T1C = 0; + uint RGS_T0C = 0; + uint RGS_T1C = 0; int i = 0; - en7571_CDR(0); + mt7570_CDR(0); @@ -49257,25 +49218,30 @@ phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4); - if( xPON == PHY_GPON_CONFIG ) + if( get_flash_register((0x098)) != 0xffffffff ) { - ptr[0] = (ptr[0] & 0x00) | 0xaa; + ptr[0] = (ptr[0] & 0x00) | (get_flash_register((0x098)) & 0xff); + printk("T0/T1 delay = 0x%02x\n", get_flash_register((0x098)) & 0xff); } - else if( xPON == PHY_EPON_CONFIG ) + else if( xPON == PHY_GPON_CONFIG ) { - ptr[0] = (ptr[0] & 0x00) | 0x77; + ptr[0] = (ptr[0] & 0x00) | 0x9a; + printk("T0/T1 delay = 0x9a\n"); } - else if( xPON == 0xa7050701 ) + else if( xPON == PHY_EPON_CONFIG ) { - ptr[0] = (ptr[0] & 0x00) | 0x77; + ptr[0] = (ptr[0] & 0x00) | 0x47; + printk("T0/T1 delay = 0x47\n"); } phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4 ); + ( (__builtin_constant_p(10) && (10)<=2) ? (__builtin_constant_p((10)*1000) ? (((10)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((10)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((10)*1000)) : ({unsigned long __ms=(10); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + - if( get_flash_register((0x00c)) != 0xffffffff) + if( get_flash_register((0x09c)) != 0xffffffff ) { - RGS_T0C = (get_flash_register((0x00c)) & 0x00ff0000)>>16; - RGS_T1C = (get_flash_register((0x00c)) & 0xff000000)>>24; + RGS_T0C = get_flash_register((0x09c)) & 0x0000ffff; + RGS_T1C = (get_flash_register((0x09c)) & 0xffff0000)>>16; } printk("RGS_T0C = 0x%x\nRGS_T1C = 0x%x\n", RGS_T0C, RGS_T1C); phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4); @@ -49302,7 +49268,7 @@ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4 ); - en7571_CDR(1); + mt7570_CDR(1); @@ -49311,19 +49277,20 @@ phy_tx_test_pattern(0x00); + printk("TGEN done\n"); } -# 1271 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_LOS_level_set(void) +# 1535 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_LOS_level_set(void) { unchar ptr[4]; - en7571_LOS_init(); - - if( get_flash_register((0x020)) != 0xffffffff ) + mt7570_LOS_init(); +# 1558 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" + if((get_flash_register((0x020)) != 0xffffffff) && (get_flash_register((0x024)) != 0xffffffff)) { phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); - ptr[3] = (ptr[3] & (0x80)) | (get_flash_register((0x020))&0x0000007f); - ptr[2] = (ptr[2] & (0x80)) | ( (get_flash_register((0x020))&0x007f0000) >> 16 ); + ptr[3] = (ptr[3] & (0x80)) | (get_flash_register((0x024))); + ptr[2] = (ptr[2] & (0x80)) | (get_flash_register((0x020))); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); } else @@ -49335,93 +49302,114 @@ } printk("Rx LOS is set\n"); } -# 1301 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_TxSD_level_set(void) +# 1586 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_TxSD_level_set(void) { - int tiaflt_A = 0; - UINT32 txsd_offset = 0; - int tiasd_B = 0; - int read_Pav_D = 0; - UINT32 tia_sd = 0; - UINT8 tia_mux_default = 0; + int delta = 0; + uint tia_sd = 0; + uint MPDH = 0; + uint MPDL = 0; unchar ptr[4]; - txsd_offset = (en7571_PWRADC_offset >> 6); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004), ptr, 4); + MPDH = ((ptr[1]<<8) | ptr[0]) & (0x3ff); + MPDL = ((ptr[3]<<8) | ptr[2]) & (0x3ff); + + delta = mt7570_TxSD_level_calibration(); + if ( delta >= 0 ) + { + tia_sd = (0.1/2)*(MPDH + (MPDL>>2)) + (1.4/0.6)*delta; + ptr[0] = tia_sd & (0xff); + ptr[1] = (tia_sd >> 8) & (0x01); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2 ); + printk("Tx SD set\n"); + } + else + { + printk("Tx SD error\n"); + } +} +# 1626 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_TxSD_level_calibration(void) +{ + unchar ptr[2]; + int tiaflt = 0; + int TIASD_0 = 0; phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - tia_mux_default = ptr[0]; ptr[0] = (ptr[0] & 0xf1) | 0x08; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0208)+(0x03)), ptr, 1); - ptr[0] = (ptr[0] & 0xff ) | 0x80; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0208)+(0x03)), ptr, 1); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0204), ptr, 2); - tiaflt_A = ((ptr[1]<<8) | ptr[0]) & (0x3ff); - tiaflt_A = tiaflt_A - txsd_offset ; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024)+0x02, ptr, 1); + ptr[0] = (ptr[0] & 0xef) | (0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024)+0x02, ptr, 1); + ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); + ptr[0] = (ptr[0] & 0xe1) | (0x04); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); + ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + tiaflt = (ptr[0] | (ptr[1]<<8)); + + ( (__builtin_constant_p(10) && (10)<=2) ? (__builtin_constant_p((10)*1000) ? (((10)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((10)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((10)*1000)) : ({unsigned long __ms=(10); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - ptr[0] = (ptr[0] & 0xf1 ) | 0x02; + ptr[0] = (ptr[0] & 0xf1) | (0x02); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); + ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2); ptr[0] = (ptr[0] & 0x00); ptr[1] = (ptr[1] & 0xfe); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2); + ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0208)+(0x03)), ptr, 1); - ptr[0] = (ptr[0] & 0xff ) | 0x80; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0208)+(0x03)), ptr, 1); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + ( (__builtin_constant_p(1) && (1)<=2) ? (__builtin_constant_p((1)*1000) ? (((1)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((1)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((1)*1000)) : ({unsigned long __ms=(1); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0204), ptr, 2); - tiasd_B = ((ptr[1]<<8) | ptr[0]) & (0x3ff); - tiasd_B= tiasd_B - txsd_offset; - - read_Pav_D = ( (get_flash_register((0x004))&0x0fff0000)>>18 ) - txsd_offset; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + TIASD_0 = (ptr[0] | (ptr[1]<<8)); - tia_sd = 0.1*2.8/1.8*read_Pav_D + (2.8/1.8)*(tiaflt_A - tiasd_B) + 6 ; - printk("TIASD = 0x%x\n", tia_sd); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2); - ptr[0] = tia_sd & 0xff; - ptr[1] = (tia_sd >> 8) & 0x01; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x000C), ptr, 2 ); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024)+0x02, ptr, 1); + ptr[0] = (ptr[0] & 0xef); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024)+0x02, ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - ptr[0] = tia_mux_default; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); -} -# 1378 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT32 en7571_SVADC_get(void) -{ - unchar ptr[2]; - UINT32 svadc_value = 0; - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158) + 0x001), ptr, 1); - ptr[0] = (ptr[0]&0xef) | 0x10; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158) + 0x001), ptr, 1); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); + ptr[0] = (ptr[0] & 0xe1); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); - svadc_value = (ptr[0] | (ptr[1]<<8)); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); + ptr[0] = (ptr[0] & 0xf1) | 0x08; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - return svadc_value; + return (tiaflt - TIASD_0); } -# 1402 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_ADC_calibration(void) +# 1715 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_ADC_calibration(void) { - int BG1V76 = 0; - int BG0V875 = 0; - unchar ptr[2]; uint read_data = 0; uint cnt = 8; @@ -49430,7 +49418,7 @@ if( i2c_access_protect() == -1 ) { - printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 1415); + printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 1725); } else { @@ -49441,17 +49429,21 @@ read_data = ptr[0]; ptr[0] = (ptr[0] & 0xe1) | 0x06; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - for(i=0;i<cnt;i++) { - temp += en7571_SVADC_get(); - } + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0]&0xef) | 0x10; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + temp += (ptr[0] | (ptr[1]<<8)); + } ptr[0] = read_data; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - BG1V76 = ((temp>>2)+1)>>1; + temp = 0; @@ -49459,22 +49451,25 @@ read_data = ptr[0]; ptr[0] = (ptr[0] & (0xb3))|(0x4C); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0024) + 0x01), ptr, 1); - for(i=0;i<cnt;i++) { - temp += en7571_SVADC_get(); - } + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + temp += (ptr[0] | (ptr[1]<<8)); + } ptr[0] = read_data; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0024) + 0x01), ptr, 1); - ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; }); - BG0V875 = ((temp>>2)+1)>>1; + temp = 0; - printk("BG 1.76V = 0x%x\nBG 0.875V = 0x%x\n", BG1V76, BG0V875); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "BG 1V76 = 0x%x\nBG 0V875 =0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1776, BG1V76, BG0V875) ; }; if( (BG1V76-BG0V875) <= 0 ) { @@ -49482,12 +49477,12 @@ return; } - en7571_ADC_slope = (1.76-0.875)/(float)(BG1V76-BG0V875); - en7571_ADC_offset = 1.76 - en7571_ADC_slope*(float)BG1V76; + ADC_slope = (1.76-0.875)/(float)(BG1V76-BG0V875); + ADC_offset = 1.76 - ADC_slope*(float)BG1V76; } } -# 1479 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_APD_initialization(void) +# 1801 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_APD_initialization(void) { unchar ptr[4]; phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0030), ptr, 4); @@ -49498,10 +49493,11 @@ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0030), ptr, 4); printk("APD initialization done\n"); } -# 1498 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_APD_control(void) +# 1825 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_APD_control(void) { - + if( get_flash_register(0x030)>0x0000ffff && get_flash_register(0x034)>0x0000ffff ) + { unchar ptr[1]; int a = 0; @@ -49543,186 +49539,199 @@ } - if( en7571_BOSA_temperature > 25 ) - en7571_APD_voltage = APD_voltage_NT + APD_slope_up*( en7571_BOSA_temperature - 25 ); + if( BOSA_temperature > 25 ) + APD_voltage = APD_voltage_NT + APD_slope_up*( BOSA_temperature - 25 ); else - en7571_APD_voltage = APD_voltage_NT - APD_slope_dn*( 25 - en7571_BOSA_temperature ); + APD_voltage = APD_voltage_NT - APD_slope_dn*( 25 - BOSA_temperature ); - a = (int)en7571_BOSA_temperature; - b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(en7571_BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_BOSA_temperature*10)%10), char), (char)({ signed char __x = ((int)(en7571_BOSA_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "BOSA temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1550, a, b) ; }; + a = (int)BOSA_temperature; + b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), char), (char)({ signed char __x = ((int)(BOSA_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "BOSA temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1878, a, b) ; }; - a = (int)en7571_APD_voltage; - b = (int)(en7571_APD_voltage*10)%10; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD Voltage = %d.%dV\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1554, a, b) ; }; + a = (int)APD_voltage; + b = (int)(APD_voltage*10)%10; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD Voltage = %d.%dV\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1882, a, b) ; }; - if( en7571_APD_voltage < APD_voltage_0x80 ) + if( APD_voltage < APD_voltage_0x80 ) { - if( en7571_APD_voltage < APD_voltage_0x40 ) + if( APD_voltage < APD_voltage_0x40 ) { APD_voltage_step = (APD_voltage_0x40 - APD_voltage_0x00)/64; - ptr[0] = 0x00 + (int)( (en7571_APD_voltage - APD_voltage_0x00)/APD_voltage_step ); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 1\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1563) ; }; + ptr[0] = 0x00 + (int)( (APD_voltage - APD_voltage_0x00)/APD_voltage_step ); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 1\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1891) ; }; } else { APD_voltage_step = (APD_voltage_0x80 - APD_voltage_0x40)/64; - ptr[0] = 0x40 + (int)( (en7571_APD_voltage - APD_voltage_0x40)/APD_voltage_step ); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 2\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1569) ; }; + ptr[0] = 0x40 + (int)( (APD_voltage - APD_voltage_0x40)/APD_voltage_step ); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 2\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1897) ; }; } } else { APD_voltage_step = (APD_voltage_0xC0 - APD_voltage_0x80)/64; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 3\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1576) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD slope 3\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1904) ; }; - if( en7571_APD_voltage < APD_voltage_0xC0 ) - ptr[0] = 0x80 + (int)( (en7571_APD_voltage - APD_voltage_0x80)/APD_voltage_step ); + if( APD_voltage < APD_voltage_0xC0 ) + ptr[0] = 0x80 + (int)( (APD_voltage - APD_voltage_0x80)/APD_voltage_step ); else { - ptr[0] = 0xC0 + (int)( (en7571_APD_voltage - APD_voltage_0xC0)/APD_voltage_step ); + ptr[0] = 0xC0 + (int)( (APD_voltage - APD_voltage_0xC0)/APD_voltage_step ); if( ptr[0] > 0xff ) ptr[0] = 0xff; } } - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1588, ptr[0]) ; }; - en7571_APD_I2C_write( ptr ); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1916, ptr[0]) ; }; + mt7570_APD_I2C_write( ptr ); + } + else + { + unchar ptr[1]; + int a = 0; + int b = 0; + float APD_slope_up = 0.10; + float APD_slope_dn = 0.07; + float APD_voltage_NT = 35.0; + float APD_zero_code_voltage = 30.0; + float APD_voltage_step = 0.09375; + + + if(get_flash_register((0x010))!=0xffffffff) + APD_slope_up = ( (float) get_flash_register((0x010)) )/100; + + if(get_flash_register((0x014))!=0xffffffff) + APD_slope_dn = ( (float) get_flash_register((0x014)) )/100; + + if(get_flash_register((0x018))!=0xffffffff) + APD_voltage_NT = ( (float) get_flash_register((0x018)) )/100; + + if(get_flash_register((0x034))!=0xffffffff) + APD_zero_code_voltage = ( (float) get_flash_register((0x034)) )/100; + + if(get_flash_register((0x030))!=0xffffffff) + APD_voltage_step = ( (float) get_flash_register((0x030)) )/1000; + + + if( BOSA_temperature > 25 ) + APD_voltage = APD_voltage_NT + APD_slope_up*( BOSA_temperature - 25 ); + else + APD_voltage = APD_voltage_NT - APD_slope_dn*( 25 - BOSA_temperature ); + + + a = (int)BOSA_temperature; + b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(BOSA_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(BOSA_temperature*10)%10), char), (char)({ signed char __x = ((int)(BOSA_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "BOSA temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1955, a, b) ; }; + + a = (int)APD_voltage; + b = (int)(APD_voltage*10)%10; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD Voltage = %d.%dV\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1959, a, b) ; }; + + + ptr[0] = (int)( (APD_voltage - APD_zero_code_voltage)/APD_voltage_step ); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1963, ptr[0]) ; }; + + mt7570_APD_I2C_write( ptr ); -} -# 1602 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_APD_DAC(UINT8 DAC) -{ - unchar ptr[1]; - en7571_APD_initialization(); - ptr[0] = DAC; - printk("DAC = 0x%x\n", ptr[0]); - en7571_APD_I2C_write( ptr ); + } } -# 1622 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_APD_I2C_write(unchar ptr[1]) +# 1984 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_APD_I2C_write(unchar ptr[1]) { - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD in en7571_APD_I2C_write = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1624, ptr[0]) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "APD in mt7570_APD_I2C_write = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 1986, ptr[0]) ; }; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0030), ptr, 1); } -# 1640 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT32 en7571_info(uint select) +# 2001 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_information_output(uint select) { - UINT32 output = 0; + uint output = 0; unchar ptr[4]; - unchar ptr_temp[4]; - if(select == 0x03) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr_temp, 4); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4); - if( ptr_temp[3] == ptr[3] ) - output = ( (ptr[3]<<8) | ptr[2] ) & 0xfff; - else + if(select == 0x03) { phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4); - output = ( (ptr[3]<<8) | ptr[2] ) & 0xfff; + output = (ptr[2] | ((ptr[3] & 0x0f) << 8 )); + global_bias_current = output; } - } - else if(select == 0x04) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr_temp, 4); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4); - if( ptr_temp[3] == ptr[3] ) - output = ( (ptr[3]<<8) | ptr[2] ) & 0xfff; - else + else if(select == 0x04) { phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4); - output = ( (ptr[3]<<8) | ptr[2] ) & 0xfff; + output = (ptr[2] | ((ptr[3] & 0x0f) << 8 )); + global_modulation_current = output; } - } - else if(select == 0x02) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B0), ptr_temp, 4); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B0), ptr, 4); - if( ptr_temp[1] == ptr[1] ) - output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff; - else + else if(select == 0x05) { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B0), ptr, 4); - output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004), ptr, 4); + output = (ptr[2] | ((ptr[3] & 0x03) << 8 )); + global_MPDL = output; + } + else if(select == 0x06) + { + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004), ptr, 4); + output = (ptr[0] | ((ptr[1] & 0x03) << 8 )); + global_MPDH = output; } - } - else if(select == 0x01) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4); - output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff; - } - else if(select == 0x06) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4); - output = ( (ptr[3]<<8) | ptr[2] ) & 0x3ff; - } - else if(select == 0x07) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr_temp, 4); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4 ); - if( ptr_temp[1] == ptr[1] ) - output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff; - else - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4); - output = ( (ptr[1]<<8) | ptr[0] ) & 0xfff; - } - } - else if(select == 0x08) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02A4), ptr, 4 ); - output = ( (ptr[3]<<8) | ptr[2] ) & 0x3ff; - } return output; } -# 1725 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -int en7571_ADC_temperature_get(void) +# 2044 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_ADC_temperature_get(void) { unchar ptr[4]; - UINT8 read_data = 0; + uint cnt = 8; + uint i = 0; + uint temp = 0; if( i2c_access_protect() == -1 ) { - printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 1732); + printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2053); + return global_temperature_code; } else { ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((1)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; }); phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024) , ptr, 1); - read_data = ptr[0]; ptr[0] = (ptr[0] & (0xe1))|(0x08); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); + for(i=0;i<cnt;i++) + { - en7571_temperature_ADC = en7571_SVADC_get(); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "temperature ADC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1744, en7571_temperature_ADC) ; }; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + temp += (ptr[0] | (ptr[1]<<8)); + } + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024) , ptr, 1); - ptr[0] = read_data; + ptr[0] = ptr[0] & (0xe1); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; }); + global_temperature_code = ((temp>>2)+1)>>1; + + temp = 0; + + return global_temperature_code; } - return en7571_temperature_ADC; } -# 1768 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -int en7571_ADC_voltage_get(void) +# 2099 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_ADC_voltage_get(void) { unchar ptr[4]; uint read_data = 0; if( i2c_access_protect() == -1 ) { - printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 1775); + printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2106); + return global_vcc_code; } else { @@ -49739,8 +49748,14 @@ ptr[0] = ptr[0] & (0xe1); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - en7571_voltage_ADC = en7571_SVADC_get(); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "VCC ADC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1793, en7571_voltage_ADC) ; }; + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + global_vcc_code = (ptr[0] | (ptr[1]<<8)); phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014) , ptr, 1); @@ -49750,135 +49765,186 @@ ptr[0] = read_data; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - +# 2160 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; }); + return global_vcc_code; } - - return en7571_voltage_ADC; } -# 1817 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_load_Tx_cal_data(void) +# 2179 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_load_init_current(void) { unchar ptr[4]; - unchar ptr_tmp[2]; - UINT32 read_data = 0; + uint read_data = 0; + int temperature_index = 0; - if( get_flash_register((0x000)) != 0xffffffff) + if( (get_flash_register((0x000))!=0xffffffff) && (get_flash_register((0x004))!=0xffffffff) ) { - read_data = get_flash_register((0x000))&0x0fff0000; - read_data = read_data >> 16; + read_data = get_flash_register((0x000)); + read_data = read_data & (0xfff); ptr[0] = read_data; ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2 ); - read_data = get_flash_register((0x000))&0x00000fff; - ptr[2] = read_data; - ptr[3] = (read_data >> 8); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x024C), ptr, 4 ); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x027C), ptr, 4 ); - printk("Initial current loaded\n"); - } - - - if( get_flash_register((0x004)) != 0xffffffff) - { - read_data = get_flash_register((0x004))&0x0fff0000; - read_data = read_data >> 16; + read_data = get_flash_register((0x004)); + read_data = read_data & (0xfff); ptr[0] = read_data; ptr[1] = (read_data >> 8); - - read_data = get_flash_register((0x004))&0x000003ff; - ptr[2] = read_data; - ptr[3] = (read_data >> 8); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); - ptr_tmp[0] = ptr[0]; - ptr_tmp[1] = ptr[1]; - ptr[0] = ptr[2]; - ptr[1] = ptr[3]; - ptr[2] = ptr_tmp[0]; - ptr[3] = ptr_tmp[1]; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0280), ptr, 4 ); - printk("PWR/ER loaded\n"); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 2 ); + printk("Initial bias/mod current loaded from FLASH\n"); } - - read_data = get_flash_register((0x008)); - if( read_data != 0xffffffff) + else { - ptr[0] = ((read_data&0x0fff0000)>>16)&0xFF; - ptr[1] = (read_data&0x0fff0000)>>24; + mt7570_temperature_get(); + temperature_index = (int)( (BOSA_temperature+40)/2.5 ); + if( temperature_index < 0 ) + temperature_index = 0; + + + read_data = LUT_Ibias_Imod[temperature_index][0]; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2 ); - ptr[0] = (read_data&0x00000fff)&0xFF; - ptr[1] = (read_data&0x00000fff)>>8; + read_data = LUT_Ibias_Imod[temperature_index][1]; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 2 ); - printk("Open loop initial current loaded\n"); + printk("Initial bias/mod current loaded from LUT\n"); } - } -# 1888 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_temperature_get(void) +# 2241 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_temperature_get(void) { - UINT32 read_data = 0; + uint read_data = 0; float BOSA_temperature_offset = 5; float Env_temperature_offset = 10; - float Efuse_offset = 3.44; - float sensor_voltage; + float T_V_slope = 327.5; + float T_V_offset = 495.8; + float sensor_voltage; - en7571_ADC_temperature_get(); - sensor_voltage = en7571_ADC_slope*((float)en7571_temperature_ADC)+en7571_ADC_offset; + if( (get_flash_register((0x080))& 0xffff0000) != 0xffff0000 ) + { + read_data = get_flash_register((0x080)); + T_V_slope = (float)((read_data & 0xffff0000) >> 16)/10; + } + + if( (get_flash_register((0x080))& 0x0000ffff) != 0xffff ) + { + read_data = get_flash_register((0x080)); + T_V_offset = (float)(read_data & 0x0000ffff)/10; + } - en7571_IC_temperature = 495.8 - ( 327.5 * sensor_voltage ); - en7571_IC_temperature = en7571_IC_temperature - en7571_eFuse_temperature_offset - Efuse_offset ; - read_data = get_flash_register((0x024)); - if( (read_data & 0x0000ffff) != 0x0000ffff) + mt7570_ADC_temperature_get(); + sensor_voltage = ADC_slope*((float)global_temperature_code)+ADC_offset; + + IC_temperature = T_V_offset - ( T_V_slope * sensor_voltage ); + + read_data = get_flash_register((0x084)); + if( (read_data & 0x0000ffff) != 0xffff ) BOSA_temperature_offset = read_data & 0x0000ffff; if( (read_data & 0xffff0000)>>16 != 0xffff ) - Env_temperature_offset = ((read_data & 0xffff0000)>>16)/10; + Env_temperature_offset = (float)((read_data & 0xffff0000)>>16)/10; - en7571_BOSA_temperature = en7571_IC_temperature - (float)BOSA_temperature_offset; - en7571_Env_temperature = en7571_IC_temperature - (float)Env_temperature_offset; + BOSA_temperature = IC_temperature - (float)BOSA_temperature_offset; + Env_temperature = IC_temperature - Env_temperature_offset; +# 2285 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +} +# 2299 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_load_MPDL_MPDH(void) +{ + unchar ptr[4]; + uint read_data = 0; + if( (get_flash_register((0x00c)) != 0xffffffff) && (get_flash_register((0x008)) != 0xffffffff)) + { + read_data = (get_flash_register((0x00c)) & (0x3ff)) | ((get_flash_register((0x008)) & (0x3ff)) << 16); + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + ptr[2] = (read_data >> 16); + ptr[3] = (read_data >> 24); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004), ptr, 4 ); + + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4); + ptr[0] = (ptr[0] & 0xfe) | (0x01); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 ); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4); + ptr[0] = (ptr[0] & 0xfe) | (0x01); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 4 ); + + printk("MPDL/MPDH loaded\n"); + } } -# 1925 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT16 en7571_temperature_get_8472(void) +# 2337 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +UINT16 mt7570_temperature_get_8472(void) { int a = 0; int b = 0; - UINT16 IC_temperature_8472 = 0; - en7571_temperature_get(); - if( en7571_IC_temperature > 0) - IC_temperature_8472 = (UINT16)(en7571_IC_temperature*256); + + mt7570_temperature_get(); + if( IC_temperature > 0) + global_IC_temperature_8472 = (UINT16)(IC_temperature*256); else - IC_temperature_8472 = 65536 - (UINT16)( (-1)*en7571_IC_temperature*256 ); + global_IC_temperature_8472 = 65536 - (UINT16)( (-1)*IC_temperature*256 ); - a = (int)en7571_IC_temperature; - b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(en7571_IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "IC temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 1938, a, b) ; }; + a = (int)IC_temperature; + b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "IC temperature = %d.%dC\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2350, a, b) ; }; - return IC_temperature_8472; + return global_IC_temperature_8472; } -# 1955 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT16 en7571_supply_voltage_get_8472(void) +# 2365 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +UINT16 mt7570_supply_voltage_get_8472(void) { - return ( 2*(en7571_ADC_slope*en7571_ADC_voltage_get()+en7571_ADC_offset)/0.0001 ); + + + + + + + + global_supply_voltage_8472 = 2*(ADC_slope*mt7570_ADC_voltage_get()+ADC_offset)/0.0001; + return global_supply_voltage_8472; +# 2420 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" } -# 1972 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT16 en7571_bias_current_get_8472(void) +# 2432 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +UINT16 mt7570_bias_current_get_8472(void) { - return ( en7571_info(0x03)*0.02442*1000/2 ); + UINT16 bias_current_8472 = 0; + + bias_current_8472 = mt7570_information_output(0x03)*0.02442*1000/2; + + if( FiberPlug == 1 && bias_current_8472 < 500 ) + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Fiber isn't recovered\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2440) ; }; + } + else + { + if( global_bias_current_8472 - bias_current_8472 > 500 ) + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Fiber plugged\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2446) ; }; + FiberPlug = 1; + } + else + FiberPlug = 0; + } + + global_bias_current_8472 = bias_current_8472; + return global_bias_current_8472; } -# 1984 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_RSSI_calibration(void) +# 2467 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_RSSI_calibration(void) { unchar ptr[4]; uint read_data = 0; - float RSSI_factor = 0; phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 2); @@ -49896,16 +49962,28 @@ ptr[0] = (ptr[0] & 0xe1) | 0x02; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - en7571_RSSI_Vref = en7571_SVADC_get(); - printk("RSSI_Vref = 0x%x\n", en7571_RSSI_Vref); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + RSSI_Vref = ptr[0] | (ptr[1]<<8); + printk("RSSI_Vref = 0x%x\n", RSSI_Vref); phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 2); ptr[1] = ptr[1] & 0xbf; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 2); - en7571_RSSI_V = en7571_SVADC_get(); - printk("RSSI_V = 0x%x\n", en7571_RSSI_V); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + RSSI_V = ptr[0] | (ptr[1]<<8); + printk("RSSI_V = 0x%x\n", RSSI_V); phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 2); @@ -49917,25 +49995,28 @@ phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - if( en7571_RSSI_V > en7571_RSSI_Vref ) - RSSI_factor = ( en7571_ADC_slope*(en7571_RSSI_V- en7571_RSSI_Vref)+en7571_ADC_offset )/0.35; + if( RSSI_V > RSSI_Vref ) + RSSI_factor = ( ADC_slope*(RSSI_V- RSSI_Vref)+ADC_offset )/0.35; else printk("RSSI calibration fail\n"); } -# 2045 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT32 en7571_RSSI_get(void) +# 2537 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_RSSI_current(void) { unchar ptr[4]; uint read_data = 0; uint RSSI_voltage = 0; uint RSSI_GAIN = 0; uint RSSI_GAIN_factor = 0; + uint cnt = 4; + uint temp = 0; + uint i = 0; int search_cnt = 0; - UINT32 acc_num = 10; - int vld = 0; + if( i2c_access_protect() == -1 ) { - printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2057); + printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2551); + return global_RSSI_current; } else { @@ -49947,50 +50028,35 @@ ptr[0] = (ptr[0] & 0xe1) | 0x02; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4); - ptr[3] = (ptr[3]&0x8f) | 0x70; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4); - for( search_cnt = 0; search_cnt < 6; search_cnt++ ) { - RSSI_GAIN = 0x05 - search_cnt; + RSSI_GAIN = 5 - search_cnt; phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4); ptr[2] = (ptr[2] & 0xf8) | RSSI_GAIN; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4); - - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4); - ptr[3] = (ptr[3]&0x7f) | 0x80; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4); - ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4); - vld = (ptr[2]&0x80) >> 7; - if(vld == 1) + temp = 0; + for(i=0;i<cnt;i++) { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 4); - RSSI_voltage = ( ( (ptr[2]<<16) | (ptr[1]<<8) | ptr[0] ) & 0xfffff )>>acc_num; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "RSSI ADC = 0x%x\t" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2094, RSSI_voltage) ; }; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + temp += ptr[0] | (ptr[1]<<8); } + RSSI_voltage = ((temp>>1)+1)>>1; - if(RSSI_voltage < en7571_RSSI_Vref - 0x32) + if(RSSI_voltage < RSSI_Vref - 0x32) break; } if (0xB7> RSSI_voltage) - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "\nRSSI ADC code lower than 0.5V, not precise!\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2101) ; }; - - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "\nRSSI GAIN = %d, RSSI_voltage = %x, \n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2103, RSSI_GAIN,RSSI_voltage) ; }; - - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 1); - ptr[3] = ptr[3]&0x8f; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0200), ptr, 1); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "RSSI ADC code lower than 0.5V, not precise!\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2587) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "RSSI GAIN = %d, RSSI_voltage = %x, \n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2589, RSSI_GAIN,RSSI_voltage) ; }; phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4); - ptr[2] = (ptr[2] & 0xf8) | 0x05; + ptr[2] = (ptr[2] & 0xf8) | (0x05); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4); @@ -50021,21 +50087,20 @@ break; } - if ( en7571_RSSI_Vref >= RSSI_voltage ) + if ( RSSI_Vref >= RSSI_voltage ) { - en7571_RSSI_current = (en7571_RSSI_Vref - RSSI_voltage)*RSSI_GAIN_factor; + global_RSSI_current = (RSSI_Vref - RSSI_voltage)*RSSI_GAIN_factor; + return global_RSSI_current; } else { - en7571_RSSI_current = 0; + global_RSSI_current = 0; + return global_RSSI_current; } } - - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "RSSI = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2153, en7571_RSSI_current) ; }; - return en7571_RSSI_current; } -# 2170 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT32 en7571_dark_current(void) +# 2649 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_dark_current(void) { unchar ptr[4]; uint read_data = 0; @@ -50045,7 +50110,7 @@ uint i = 0; if( i2c_access_protect() == -1 ) - printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2180); + printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2659); else { ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((1)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; }); @@ -50064,9 +50129,17 @@ for(i=0;i<cnt;i++) { - RSSI_voltage += en7571_SVADC_get(); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + RSSI_voltage += ptr[0] | (ptr[1]<<8); } + printk("RSSI voltage = %x\n", RSSI_voltage); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0014), ptr, 4); ptr[2] = (ptr[2] & 0xf8) | (0x05); @@ -50079,170 +50152,242 @@ ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; }); } - return RSSI_voltage; + return 0; } -# 2224 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -int en7571_RogueONU_status(void) +# 2717 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_RougeONU_clear(void) { - unchar ptr[2]; - int RogueONU_status = 0 ; + unchar ptr[1]; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168) + 0x01, ptr, 1); + ptr[0] = (ptr[0] & 0xfe) | 0x1; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168) + 0x01, ptr, 1); + printk("Rogue ONU clear\n"); +} +# 2738 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_MPD_current_calibration(void) +{ + unchar ptr[2]; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168), ptr, 2); - RogueONU_status = (ptr[1]>>2 & 0x1); - return RogueONU_status; -} -# 2244 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_RogueONU_clear(void) -{ - unchar ptr[1]; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168) + 0x1, ptr, 1); - ptr[0] = (ptr[0] & 0xfe) | 0x1; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168) + 0x1, ptr, 1); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); + ptr[0] = (ptr[0] & 0xf1) | 0x08; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rogue ONU clear\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2251) ; }; -} -# 2261 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_PWRADC_enable(void) -{ - unchar ptr[4]; + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); + ptr[0] = (ptr[0] & 0xe1) | 0x04; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - ptr[0] = ptr[0] & 0xf1; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4); - ptr[3] = ptr[3] & 0xef; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + MPD_current_offset = (ptr[0] | (ptr[1]<<8)); + global_MPD_current = MPD_current_offset; + printk("MPD Current Offset = 0x%x\n", MPD_current_offset); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B4), ptr, 1); - ptr[0] = (ptr[0] & 0xfc) | 0x01; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x02B4), ptr, 1); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); + ptr[0] = (ptr[0] & 0xf1) | 0x08; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); + - printk("PWRADC ready\n"); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); + ptr[0] = (ptr[0] & 0xe1); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); } -# 2290 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_PWRADC_calibration(void) +# 2788 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_MPD_current(void) { - unchar ptr[4]; - int vld = 0; + unchar ptr[2]; + uint MPD_current = 0; + uint temp = 0; + int i = 0; + int cnt = 0; + if( vEN7570 == 0 && TEC_switch ) + cnt = 10; + else + cnt = 1; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4); - ptr[3] = (ptr[3] & 0xef) | 0x10; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4); + if( i2c_access_protect() == -1 ) + { + printk("\r\n atomic, [%s : %d]\r\n", __FUNCTION__ , 2803); + return global_MPD_current; + } + else + { + ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((1)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; }); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ptr[3] = (ptr[3]&0xf8 ) | 0x07; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); + ptr[0] = (ptr[0] & 0xf1); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ptr[3] = (ptr[3]&0x7f) | 0x80; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); + ptr[0] = (ptr[0] & 0xe1) | 0x04; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - vld = (ptr[2]&0x10) >> 4; - if(vld == 1) - { + for( i=0; i<cnt; i++ ) + { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - en7571_PWRADC_offset = ( (ptr[2]<<16) | (ptr[1]<<8) | ptr[0] ) & 0xfffff; - en7571_PWRADC_offset = en7571_PWRADC_offset >> 4; - printk("PWRADC offset = 0x%x\n", en7571_PWRADC_offset); - } + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)), ptr, 1); + ptr[0] = (ptr[0] & (0xef))|(0x10); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, ((0x0158)+(0x01)) , ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ptr[3] = ptr[3]&0xf8; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0154), ptr, 2); + MPD_current = (ptr[0] | (ptr[1]<<8)); + + if(temp == 0) + temp = MPD_current; + else if(temp < MPD_current) + temp = MPD_current; + } - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4); - ptr[3] = ptr[3] & 0xef; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0038), ptr, 4); -} -# 2345 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT32 en7571_PWRADC_get(void) -{ - unchar ptr[4]; - UINT32 ADC = 0; - int vld = 0; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); + ptr[0] = (ptr[0] & 0xe1); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 1); - if( (gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_DOWN) && (en7571_PatternEnabled == 0) ) - return en7571_PWRADC_offset; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); + ptr[0] = (ptr[0] & 0xf1) | 0x08; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ptr[3] = (ptr[3]&0xf8 ) | 0x07; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); + ({ union { typeof(((&i2c_protect)->counter)) __val; char __c[1]; } __u = { .__val = ( typeof(((&i2c_protect)->counter))) ((0)) }; __write_once_size(&(((&i2c_protect)->counter)), __u.__c, sizeof(((&i2c_protect)->counter))); __u.__val; }); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD temp = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2849, temp) ; }; + if( temp < MPD_current_offset ) + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "No Tx power, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2852, MPD_current_offset) ; }; + global_MPD_current = MPD_current_offset; + return global_MPD_current; + } - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ptr[3] = (ptr[3]&0x7f) | 0x80; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + if( vEN7570 == 0 && TEC_switch ) + { + int div = 0; + int MPD_current_up = get_flash_register((0x088)); + int MPD_current_dn = MPD_current_offset; + float slope = 0; + float tx_power = 0; + int tx_power_up = 0; + int tx_power_dn = 0; + UINT16 tx_power_8472 = 0; + int TX_POWER_THRESHOLD_up = 0; + int TX_POWER_THRESHOLD_dn = 0; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - vld = (ptr[2]&0x10) >> 4; - if(vld == 1) - { + div = MPD_current_up - MPD_current_dn; + if( div == 0 ) + { + printk("Invalid content of FLASH 0x88\n"); + global_MPD_current = temp; + return global_MPD_current; + } + else + { + if( xPON_mode == PHY_GPON_CONFIG ) + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "GPON mode\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2881) ; }; + tx_power_up = 0xb1; + TX_POWER_THRESHOLD_up = 25118; + TX_POWER_THRESHOLD_dn = 12589; + } + else if( xPON_mode == PHY_EPON_CONFIG ) + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "EPON mode\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2888) ; }; + tx_power_up = 0x9e; + TX_POWER_THRESHOLD_up = 22387; + TX_POWER_THRESHOLD_dn = 11220; + } - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ADC = ( (ptr[2]<<16) | (ptr[1]<<8) | ptr[0] ) & 0xfffff; - ADC = ADC >> 4; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "PWRADC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2373, ADC) ; }; - } + slope = (float)(tx_power_up-tx_power_dn)/(float)(MPD_current_up-MPD_current_dn); + tx_power = (float)(temp-MPD_current_dn)*slope + tx_power_dn; + tx_power_8472 = (int)(10*tx_power)/0.1; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); - ptr[3] = ptr[3]&0xf8; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0208), ptr, 4); + if( global_MPD_current_var==0 && tx_power_8472>TX_POWER_THRESHOLD_up) + { + MPD_current_cnt += 1; + if( MPD_current_cnt == 2) + global_MPD_current_var = temp - get_flash_register((0x088)); + } + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD current var = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2904, global_MPD_current_var) ; }; - if( ADC < en7571_PWRADC_offset ) - { - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Tx off, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2382, en7571_PWRADC_offset) ; }; - en7571_PWRADC = en7571_PWRADC_offset; - } - else - { - en7571_PWRADC = ADC; + if( tx_power_8472>TX_POWER_THRESHOLD_up && global_MPD_current_var!=0 ) + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 1, Tx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2908, tx_power_8472) ; }; + temp -= global_MPD_current_var; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "temp(var) = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2910, temp) ; }; + tx_power = (float)(temp-MPD_current_dn)*slope + tx_power_dn; + tx_power_8472 = (int)(10*tx_power)/0.1; + if( tx_power_8472>TX_POWER_THRESHOLD_up || tx_power_8472<TX_POWER_THRESHOLD_dn) + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 1a, Tx_power_8472 = %d, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2915, tx_power_8472, global_MPD_current) ; }; + global_MPD_current_var = 0; + MPD_current_cnt = 1; + return global_MPD_current; + } + else + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 1b, Tx_power_8472 = %d, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2922, tx_power_8472, temp) ; }; + global_MPD_current = temp; + return global_MPD_current; + } + } + else if( tx_power_8472>TX_POWER_THRESHOLD_up && global_MPD_current_var==0 ) + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 2, Tx_power_8472 = %d, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2929, tx_power_8472, MPD_current_up) ; }; + global_MPD_current = MPD_current_up; + return global_MPD_current; + } + else + { + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD in zone 3, Tx_power_8472 = %d, return %x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 2935, tx_power_8472, temp) ; }; + global_MPD_current = temp; + return global_MPD_current; + } + } + } + else + { + global_MPD_current = temp; + return global_MPD_current; + } } - - return en7571_PWRADC; } -# 2407 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT16 en7571_RxPower_get_8472(void) +# 2961 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +UINT16 mt7570_RxPower_get_8472(void) { - UINT32 read_data = 0; + int read_data = 0; - UINT32 RSSI_current_now = 0; + int RSSI_current = 0; - float rx_power_now = 0; + int rx_power = 0; UINT16 rx_power_8472 = 0; float div = 0; float slope = 0; - UINT32 RSSI_current_up = 0; - UINT32 RSSI_current_md = 0; - UINT32 RSSI_current_dn = 0; - - UINT32 rx_power_up = 0; - UINT32 rx_power_md = 0; - UINT32 rx_power_dn = 0; + int RSSI_current_up = 0; + int RSSI_current_md = 0; + int RSSI_current_dn = 0; + + int rx_power_up = 0; + int rx_power_md = 0; + int rx_power_dn = 0; float RSSI_current_1, RSSI_current_2, RSSI_current_3, Rx_power_K1, Rx_power_K2, Rx_power_K3; static float d, e, f, g, x, y, z; if( (get_flash_register((0x05c))&0x0000000f) == 1 ) { - if (en7571_DDMI_rx_cal_flag == 0) + if (global_DDMI_rx_cal_flag == 0) { read_data = get_flash_register((0x050)); RSSI_current_1 = read_data & 0x0000ffff; @@ -50264,7 +50409,7 @@ if(d==0) { - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid DDMI Rx power-RSSI mapping curve \n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2453) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid DDMI Rx power-RSSI mapping curve \n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3007) ; }; } else { @@ -50273,21 +50418,20 @@ z=g/d; } - en7571_DDMI_rx_cal_flag = 1; + global_DDMI_rx_cal_flag = 1; } - RSSI_current_now = en7571_RSSI_get(); - rx_power_now = (float) RSSI_current_now*RSSI_current_now*x + (float)RSSI_current_now*y + z; - - if(rx_power_now < 0) - rx_power_now = 0; + RSSI_current = mt7570_RSSI_current(); + rx_power = (float) RSSI_current*RSSI_current*x + (float)RSSI_current*y + z; + if(rx_power < 0) + rx_power = 0; } else { - RSSI_current_now = en7571_RSSI_get(); + RSSI_current = mt7570_RSSI_current(); if( get_flash_register((0x050)) != 0xffffffff ) { read_data = get_flash_register((0x050)); @@ -50307,1570 +50451,1175 @@ rx_power_dn = (read_data & 0xffff0000) >> 16; } - if( RSSI_current_now <= RSSI_current_dn ) + if( RSSI_current <= RSSI_current_dn ) { - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 1\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2498) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 1\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3051) ; }; div = RSSI_current_dn; - if(RSSI_current_dn!=0) + if(RSSI_current_dn !=0) { slope = (float)rx_power_dn/(float)RSSI_current_dn; - rx_power_now = RSSI_current_now*slope; + rx_power = RSSI_current*slope; } else - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2507) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3060) ; }; } - else if( (RSSI_current_dn < RSSI_current_now) && (RSSI_current_now < RSSI_current_md) ) + else if( (RSSI_current_dn < RSSI_current) && (RSSI_current < RSSI_current_md) ) { - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 2\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2511) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 2\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3064) ; }; div = RSSI_current_md-RSSI_current_dn; if(div != 0) { slope = (float)(rx_power_md-rx_power_dn)/(float)(RSSI_current_md-RSSI_current_dn); - rx_power_now = (RSSI_current_now-RSSI_current_dn)*slope + rx_power_dn; + rx_power = (RSSI_current-RSSI_current_dn)*slope + rx_power_dn; } else - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2519) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3072) ; }; } - else if( RSSI_current_md <= RSSI_current_now ) + else if( RSSI_current_md <= RSSI_current ) { - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 3\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2523) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx power in zone 3\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3076) ; }; div = RSSI_current_up-RSSI_current_md; if(div != 0) { slope = (float)(rx_power_up-rx_power_md)/(float)(RSSI_current_up-RSSI_current_md); - rx_power_now = (RSSI_current_now-RSSI_current_md)*slope + rx_power_md; + rx_power = (RSSI_current-RSSI_current_md)*slope + rx_power_md; } else - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2531) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Rx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3084) ; }; } } - rx_power_8472 = rx_power_now/10; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2537, rx_power_8472) ; }; + rx_power_8472 = rx_power/10; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Rx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3090, rx_power_8472) ; }; return rx_power_8472; } -# 2548 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_safe_circuit_reset(void) +# 3108 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_safe_circuit_reset(void) { unchar ptr[4]; phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0100), ptr, 4); ptr[1] = (ptr[1] & 0xbf) | (0x40); phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0100), ptr, 4); } -# 2570 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -UINT16 en7571_TxPower_get_8472(void) +# 3128 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +UINT16 mt7570_TxPower_get_8472(void) { int div = 0; - UINT32 read_data = 0; - UINT32 PWRADC_now = 0; - UINT32 PWRADC_up = 0; - UINT32 PWRADC_dn = en7571_PWRADC_offset; + int read_data = 0; + int MPD_current = 0; + int MPD_current_up = 0; + int MPD_current_dn = MPD_current_offset; float slope = 0; - float tx_power_now = 0; - UINT32 tx_power_up = 0; - UINT32 tx_power_dn = 0; + float tx_power = 0; + int tx_power_up = 0; + int tx_power_dn = 0; UINT16 tx_power_8472 = 0; - PWRADC_now = en7571_PWRADC_get(); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "PWRADC_now = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2584, PWRADC_now) ; }; - if( get_flash_register((0x040)) != 0xffffffff) + MPD_current = mt7570_MPD_current(); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "MPD_current = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3142, MPD_current) ; }; + if( get_flash_register((0x040)) != 0xffffffff ) { read_data = get_flash_register((0x040)); - PWRADC_up = read_data & 0x0000ffff; + MPD_current_up = read_data & 0x0000ffff; tx_power_up = (read_data & 0xffff0000)>>16; } - - div = PWRADC_up - PWRADC_dn; + if( get_flash_register((0x044)) != 0xffffffff ) + { + read_data = get_flash_register((0x044)); + MPD_current_dn = read_data & 0x0000ffff; + tx_power_dn = (read_data & (0xffff0000))>>16; + } + div = MPD_current_up - MPD_current_dn; if( div != 0 ) { - slope = (float)(tx_power_up-tx_power_dn)/(float)(PWRADC_up-PWRADC_dn); - tx_power_now = (float)(PWRADC_now-PWRADC_dn)*slope + tx_power_dn; + slope = (float)(tx_power_up-tx_power_dn)/(float)(MPD_current_up-MPD_current_dn); + tx_power = (float)(MPD_current-MPD_current_dn)*slope + tx_power_dn; } else { - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Tx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2600) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Invalid Tx power point\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3163) ; }; } - - if( en7571_DOL == 1 ) - if( (gpPhyPriv->phyCfg.flags.trafficStatus!=TRAFFIC_STATUS_DOWN) || (en7571_PatternEnabled==1) ) - tx_power_now = tx_power_up; - - tx_power_8472 = (int)(10*tx_power_now)/0.1; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Tx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2609, tx_power_8472) ; }; + tx_power_8472 = (int)(10*tx_power)/0.1; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Tx_power_8472 = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3167, tx_power_8472) ; }; return tx_power_8472; } -# 2620 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_internal_clock(void) +# 3181 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_internal_clock(void) { - static UINT32 cnt; - if( en7571_internal_DDMI == 1 ) + if( internal_DDMI == 1 ) { - if(cnt%en7571_Tapd == en7571_Tapd-1) + if(cnt7570%T_APD == T_APD-1) { - if( en7571_xPON_mode == PHY_GPON_CONFIG ) - en7571_APD_control(); + if( xPON_mode == PHY_GPON_CONFIG ) + mt7570_APD_control(); } - if(cnt%10 == 0 || en7571_fast_DDMI) - en7571_DDMI_voltage = en7571_supply_voltage_get_8472(); + if(cnt7570%10 == 0 || fast_DDMI) + DDMI_voltage = mt7570_supply_voltage_get_8472(); - if(cnt%10 == 2 || en7571_fast_DDMI) - en7571_DDMI_current = en7571_bias_current_get_8472(); - if(cnt%10 == 4 || en7571_fast_DDMI) - en7571_DDMI_temperature = en7571_temperature_get_8472(); + DDMI_current = mt7570_bias_current_get_8472(); - if(cnt%10 == 6 || en7571_fast_DDMI) + if(cnt7570%10 == 4 || fast_DDMI) + DDMI_temperature = mt7570_temperature_get_8472(); + if(cnt7570%10 == 6 || fast_DDMI) { - en7571_DDMI_tx_power = en7571_TxPower_get_8472(); - en7571_tx_power_alarm_get(); + DDMI_tx_power = mt7570_TxPower_get_8472(); + mt7570_tx_power_alarm_get(); } - if(cnt%10 == 8 || en7571_fast_DDMI) + if(cnt7570%10 == 8 || fast_DDMI) { - en7571_DDMI_rx_power = en7571_RxPower_get_8472(); - en7571_rx_power_alarm_get(); - } - if(cnt%10 == 9) - { - en7571_WatchDog(); + DDMI_rx_power = mt7570_RxPower_get_8472(); + mt7570_rx_power_alarm_get(); } } - else if( en7571_internal_DDMI == -1 ) - { - printk("Loop Frozen\n"); - return; - } - if((en7571_sys_mode != 0) || (en7571_PatternEnabled==1) ) + + + + if ( SCL == 1 ) { - if(1) + if( cnt7570%29 == 0 ) { - if( en7571_KT != 0 ) - en7571_SWKT(); - else if( (en7571_SCL == 1) || (en7571_DOL ==1) ) - en7571_LUT_Tracking(); + if ( ETC == 3 ) + { + + + + mt7570_BiasTracking(); + } } } + else if ( DOL == 1 ) + { + if( cnt7570%5 == 0 ) + mt7570_OpenLoopControl(); + } else { - if( (en7571_SCL == 1) || (en7571_DOL ==1) ) - { - if( (cnt%30)==(30 -3) ) - en7571_LUT_Tracking(); - } - else - { - en7571_islinkstauschange(); - if((cnt%30)==(30 -3) ) + if( xPON_mode != -1 && FiberPlug == 1 && PatternEnabled == 1 ) + mt7570_FiberPlug_Protect(); + + + if( cnt7570%30 == 29 ) + { + if ( ETC == 1 ) { - if( en7571_KT != 0 ) - en7571_OPKT(); + mt7570_ERTemperatureCompensation(); } - else + else if ( ETC == 2 ) { - if(en7571_Pav_loop !=0) - en7571_Pavg_close_loop(); - } - if(cnt%5 == 2) + } + else if ( ETC == 3 ) { - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Ibias_DAC now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2697, Ibias_linkup_now) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Imod_DAC now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2698, Imod_linkup_now) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Iav_DAC_now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2699, Iav_linkup_now) ; }; + if( PatternEnabled || BiasTracking_switch ) + mt7570_BiasTracking(); } + } + + + + if( TEC != 0 && TEC_switch == 1 ) + mt7570_TxEyeCorrection(); + } - cnt ++; + + + + if( cnt7570%120 == 119 ) + { + if( xPON_mode != -1 ) + mt7570_ADC_calibration(); + } + + + + cnt7570 ++; + } -# 2718 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_param_status_real(PPHY_TransParam_T transceiver_param) +# 3291 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_param_status_real(PPHY_TransParam_T transceiver_param) { - transceiver_param->temprature = en7571_DDMI_temperature; - transceiver_param->supply_voltage = en7571_DDMI_voltage; - transceiver_param->tx_current = en7571_DDMI_current; - transceiver_param->tx_power = en7571_DDMI_tx_power; - transceiver_param->rx_power = en7571_DDMI_rx_power; + transceiver_param->temprature = DDMI_temperature; + transceiver_param->supply_voltage = DDMI_voltage; + transceiver_param->tx_current = DDMI_current; + transceiver_param->tx_power = DDMI_tx_power; + transceiver_param->rx_power = DDMI_rx_power; } -# 2741 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_DDMI_check_8472(void) +# 3312 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void DDMI_check_8472(void) { - en7571_DDMI_voltage = en7571_supply_voltage_get_8472(); - en7571_DDMI_current = en7571_bias_current_get_8472(); - en7571_DDMI_temperature = en7571_temperature_get_8472(); - en7571_DDMI_tx_power = en7571_TxPower_get_8472(); - en7571_DDMI_rx_power = en7571_RxPower_get_8472(); + DDMI_voltage = mt7570_supply_voltage_get_8472(); + DDMI_current = mt7570_bias_current_get_8472(); + DDMI_temperature = mt7570_temperature_get_8472(); + DDMI_tx_power = mt7570_TxPower_get_8472(); + DDMI_rx_power = mt7570_RxPower_get_8472(); - printk("Supply Voltage = %05d\n" , en7571_DDMI_voltage ); - printk("Tx Bias Current = %05d\n", en7571_DDMI_current ); - printk("Temperature = %05d\n" , en7571_DDMI_temperature); - printk("Tx power = %05d\n" , en7571_DDMI_tx_power ); - printk("Rx Power = %05d\n" , en7571_DDMI_rx_power ); + printk("Supply Voltage = %05d\n" , DDMI_voltage ); + printk("Tx Bias Current = %05d\n", DDMI_current ); + printk("Temperature = %05d\n" , DDMI_temperature); + printk("Tx power = %05d\n" , DDMI_tx_power ); + printk("Rx Power = %05d\n" , DDMI_rx_power ); } -# 2763 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -extern struct work_struct work_mt7571_safe_circuit_reset; +# 3338 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +extern struct work_struct work_mt7570_safe_circuit_reset; -void en7571_trans_model_setting(void) +void mt7570_trans_model_setting(void) { - gpPhyPriv->phy_xpon_trans_val = 0x14f; + gpPhyPriv->phy_xpon_trans_val = 0x10f; - - - - - if(((void *)0) != i2c_access_queue){ - queue_work(i2c_access_queue, &work_mt7571_safe_circuit_reset); - } + if(((void *)0) != i2c_access_queue){ + queue_work(i2c_access_queue, &work_mt7570_safe_circuit_reset); + } } -# 2793 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_trans_alarm_getting(PPHY_TransAlarm_T transceiver_alarm) +# 3368 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_trans_alarm_getting(PPHY_TransAlarm_T transceiver_alarm) { transceiver_alarm->rx_power_high_alarm_thod = 0; transceiver_alarm->rx_power_low_alarm_thod = 0; transceiver_alarm->tx_power_high_alarm_thod = 0; transceiver_alarm->tx_power_low_alarm_thod = 0; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power high alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2800, transceiver_alarm->rx_power_high_alarm_thod) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power low alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2801, transceiver_alarm->rx_power_low_alarm_thod) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "tx power high alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2802, transceiver_alarm->tx_power_high_alarm_thod) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power low alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 2803, transceiver_alarm->tx_power_low_alarm_thod) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power high alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3375, transceiver_alarm->rx_power_high_alarm_thod) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power low alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3376, transceiver_alarm->rx_power_low_alarm_thod) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "tx power high alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3377, transceiver_alarm->tx_power_high_alarm_thod) ; }; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "rx power low alarm threshold: %.8x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 3378, transceiver_alarm->tx_power_low_alarm_thod) ; }; } -# 2819 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_tx_power_alarm_get(void) +# 3392 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_tx_power_alarm_get(void) { - if(en7571_DDMI_tx_power < 0x2710) - en7571_alarm |= PHY_TRANS_TX_LOW_POWER_ALARM; + if(DDMI_tx_power < 0x2710) + mt7570_alarm |= PHY_TRANS_TX_LOW_POWER_ALARM; else - en7571_alarm &= ~(PHY_TRANS_TX_LOW_POWER_ALARM); + mt7570_alarm &= ~(PHY_TRANS_TX_LOW_POWER_ALARM); - if(en7571_DDMI_tx_power > 0x8a99) - en7571_alarm |= PHY_TRANS_TX_HIGH_POWER_ALARM; + if(DDMI_tx_power > 0x8a99) + mt7570_alarm |= PHY_TRANS_TX_HIGH_POWER_ALARM; else - en7571_alarm &= ~(PHY_TRANS_TX_HIGH_POWER_ALARM); + mt7570_alarm &= ~(PHY_TRANS_TX_HIGH_POWER_ALARM); - if(en7571_DDMI_current < 0x1f4) - en7571_alarm |= PHY_TRANS_TX_LOW_CUR_ALARM; + if(DDMI_current < 0x1f4) + mt7570_alarm |= PHY_TRANS_TX_LOW_CUR_ALARM; else - en7571_alarm &= ~(PHY_TRANS_TX_LOW_CUR_ALARM); + mt7570_alarm &= ~(PHY_TRANS_TX_LOW_CUR_ALARM); - if(en7571_DDMI_current > 0xc350) - en7571_alarm |= PHY_TRANS_TX_HIGH_CUR_ALARM; + if(DDMI_current > 0xc350) + mt7570_alarm |= PHY_TRANS_TX_HIGH_CUR_ALARM; else - en7571_alarm &= ~(PHY_TRANS_TX_HIGH_CUR_ALARM); + mt7570_alarm &= ~(PHY_TRANS_TX_HIGH_CUR_ALARM); + } -# 2855 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_rx_power_alarm_get(void) +# 3427 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_rx_power_alarm_get(void) { - if(en7571_DDMI_rx_power < 0xa) - en7571_alarm |= PHY_TRANS_RX_LOW_POWER_ALARM; + if(DDMI_rx_power < 0xa) + mt7570_alarm |= PHY_TRANS_RX_LOW_POWER_ALARM; else - en7571_alarm &= ~(PHY_TRANS_RX_LOW_POWER_ALARM); + mt7570_alarm &= ~(PHY_TRANS_RX_LOW_POWER_ALARM); + - if(en7571_DDMI_rx_power > 0x9cf) - en7571_alarm |= PHY_TRANS_RX_HIGH_POWER_ALARM; + if(DDMI_rx_power > 0x9cf) + mt7570_alarm |= PHY_TRANS_RX_HIGH_POWER_ALARM; else - en7571_alarm &= ~(PHY_TRANS_RX_HIGH_POWER_ALARM); + mt7570_alarm &= ~(PHY_TRANS_RX_HIGH_POWER_ALARM); } -# 2882 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -int en7571_EN7571_detection(void) +# 3453 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +int mt7570_EN7570_detection(void) { unchar ptr[1]; - UINT8 read_data_1 = 0; - UINT8 read_data_2 = 0; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0170), ptr, 1); - read_data_1 = ptr[0]; - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 1); - read_data_2 = ptr[0]; - - if( (read_data_1 == 0x03) && (read_data_2 >= 0x03) ) + if( ptr[0] == 0x03 ) { - en7571_select = 1; - - printk("E3 patched\n"); - { - en7571_ver = 2; - en7571_sys_mode = 0; - } - + mt7570_select = 1; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 1); + vEN7570 = ptr[0]; return 1; } else + { + mt7570_select = 0; return 0; + } } -# 2919 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -int en7571_LOS_calibration(int LOS_thld_H, int LOS_thld_L) +# 3483 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void LOS_calibration(int LOS_thld_H, int LOS_thld_L) { unchar ptr[4]; - int LOS_status = 0; + mt7570_LOS_init(); +# 3506 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); ptr[3] = (ptr[3] & (0x80)) | LOS_thld_L; ptr[2] = (ptr[2] & (0x80)) | LOS_thld_H; phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); - ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0130), ptr, 4); - LOS_status = ptr[3] & 0x01; - return LOS_status; + printk("%s done\n", __FUNCTION__); } +# 3525 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_ERC_filter(void) +{ + unchar ptr[4]; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x016C), ptr, 4); + ptr[2] = 0x58; + ptr[1] = 0xa7; + ptr[0] = 0xff; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x016C), ptr, 4); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x016C), ptr, 4); + ptr[3] = (ptr[3] & 0xfe) | (0x01); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x016C), ptr, 4); - - -float en7571_Taylor_series(float input) + printk("ERC filter set\n"); +} +# 3553 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_TIAGAIN_set(void) { - int i = 0; - float temp = 0; - float temp_2 = 0; - float temp_3 = 0; + unchar ptr[1]; + uint read_data = 0; - for ( i=0; i<7 ; i++) + if( get_flash_register((0x028)) != 0xffffffff ) { - if ( input >= 5 ) - input = input/10; - else - break; - } - - temp = (input-1)/input; - temp_2 = temp*temp; - temp_3 = temp*temp_2; - - temp = temp + temp_2/2 + temp_3/3 + (temp_2*temp_2)/4 + (temp_2*temp_3)/5 + (temp_3*temp_3)/6; - temp = temp/2.302585093; - temp -= 4-i; - temp *= 10; + read_data = get_flash_register((0x028)) & 0x3; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000)+0x0001 , ptr, 1); + ptr[0] = (ptr[0] & 0x3f) | (read_data<<6); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0000)+0x0001, ptr, 1); - return temp; + printk("TIAGAIN set 0x%x\n", read_data); + } } -# 2973 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_BoB_info(void) +# 3582 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void show_BoB_information(void) { unchar ptr[4]; float temp = 0; int a = 0; int b = 0; + int i ; - printk("Driver version = %d\n", en7571_version); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0130), ptr, 4); ptr[3] = ptr[3] & 0x1; - printk("LOS = %d\n", ptr[3]); + printk("LOS status = %d\n", ptr[3]); + + + + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168), ptr, 2); + ptr[1] = (ptr[1]>>2 & 0x1); + printk("Rouge ONU status = %d\n", ptr[1]); phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0168), ptr, 2); ptr[1] = (ptr[1]>>3 & 0x1); - printk("Tx SD = %d\n", ptr[1]); + printk("Tx SD status = %d\n", ptr[1]); phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0100), ptr, 2); ptr[1] = (ptr[1]>>7 & 0x1); - printk("Tx fault = %d\n", ptr[1]); + printk("Tx fault status = %d\n", ptr[1]); - temp = (float)en7571_info(0x03)*0.02442; + temp = (float)mt7570_information_output(0x03)*0.02442; a = (int)temp; b = (int)(temp*100)%100; printk("I bias = %d.%.2dmA\n", a, b); - temp = (float)en7571_info(0x04)*0.02198; + temp = (float)mt7570_information_output(0x04)*0.02198; a = (int)temp; b = (int)(temp*100)%100; printk("I mod = %d.%.2dmA\n", a, b); - if( en7571_DOL != 1 ) - { - if((gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_UP) &&(en7571_sys_mode ==0)) - { - temp = (float)Iav_linkup_now*0.02198; - a = (int)temp; - b = (int)(temp*100)%100; - printk("I av = %d.%.2dmA\n", a, b); - } - else - { - temp = (float)en7571_info(0x02)*0.02198; - a = (int)temp; - b = (int)(temp*100)%100; - printk("I av = %d.%.2dmA\n", a, b); - } - } - - a = (int)en7571_IC_temperature; - b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(en7571_IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(en7571_IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); - printk("IC temperature = %d.%d'C\n", a, b); - a = (int)en7571_BOSA_temperature; - printk("BOSA temperature = %d.%d'C\n", a, b); - a = (int)en7571_Env_temperature; - printk("Enviroment temperature = %d.%d'C\n", a, b); + a = (int)IC_temperature; + b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); + printk("IC temperature = %d.%dC\n", a, b); + a = (int)BOSA_temperature; + printk("BOSA temperature = %d.%dC\n", a, b); + a = (int)Env_temperature; + b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(Env_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(Env_temperature*10)%10), char), (char)({ signed char __x = ((int)(Env_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); + printk("Enviroment temperature = %d.%dC\n", a, b); - a = (int)en7571_APD_voltage; - b = (int)(en7571_APD_voltage*10)%10; + a = (int)APD_voltage; + b = (int)(APD_voltage*10)%10; printk("APD Voltage = %d.%dV\n", a, b); - a = (int)en7571_DDMI_voltage/10000; - b = (int)en7571_DDMI_voltage%10000; - printk("VCC = %d.%.2dV\n", a, b); + a = (int)global_supply_voltage_8472/10000; + b = (int)global_supply_voltage_8472%10000; + printk("VCC = %d.%.4dV\n", a, b); - if( en7571_DDMI_tx_power == 0 ) + temp = (float)DDMI_tx_power/1000/10; + if( temp == 0 ) printk("Tx power = -40 dBm\n"); else { - temp = en7571_Taylor_series( (float)en7571_DDMI_tx_power ); + temp = (temp-1)/temp; + temp = temp + (temp*temp)/2 + (temp*temp*temp)/3 + (temp*temp*temp*temp)/4 + (temp*temp*temp*temp*temp)/5 + (temp*temp*temp*temp*temp*temp)/6; + temp = temp/2.302585093; + temp *= 10; a = (int)temp; b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed long long) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned long long), ({ signed long long __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed long) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned long), ({ signed long __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed int) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned int), ({ signed int __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed short) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned short), ({ signed short __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed char) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned char), ({ signed char __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), char), (char)({ signed char __x = ((int)(temp*100)%100); __x<0?-__x:__x; }), ((void)0))))))); printk("Tx power = %d.%.2d dBm\n", a, b); } - if( en7571_DDMI_rx_power == 0 ) + temp = (float)DDMI_rx_power; + for ( i=0; i<7 ; i++) + { + if ( temp >= 5) + temp = temp/10; + else + break; + } + + if( temp == 0 ) printk("Rx power = -40 dBm\n"); else { - temp = en7571_Taylor_series( (float)en7571_DDMI_rx_power ); + temp = (temp-1)/temp; + temp = temp + (temp*temp)/2 + (temp*temp*temp)/3 + (temp*temp*temp*temp)/4 + (temp*temp*temp*temp*temp)/5 + (temp*temp*temp*temp*temp*temp)/6 + (temp*temp*temp*temp*temp*temp*temp)/7 +(temp*temp*temp*temp*temp*temp*temp*temp)/8 ; + temp = temp/2.302585093; + temp -= 4-i; + temp *= 10; a = (int)temp; b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed long long) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned long long), ({ signed long long __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed long) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned long), ({ signed long __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed int) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned int), ({ signed int __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed short) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned short), ({ signed short __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), signed char) || __builtin_types_compatible_p(typeof((int)(temp*100)%100), unsigned char), ({ signed char __x = ((int)(temp*100)%100); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(temp*100)%100), char), (char)({ signed char __x = ((int)(temp*100)%100); __x<0?-__x:__x; }), ((void)0))))))); printk("Rx power = %d.%.2d dBm\n", a, b); } } -# 3077 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_LOS_init(void) +# 3696 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_TxEyeCorrection(void) { + uint MPDL = 0; unchar ptr[4]; + static int TEC_cnt = 0; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); - ptr[0] = (ptr[0] & (0xfe)) | (0x01); + if( TEC_cnt > 7 ) + return; - ptr[1] = (ptr[1] & (0xe0)) | (0x1f); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); + if ( (global_bias_current_8472<<1) < BOSA_Ith ) + { + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4); - ptr[3] = (ptr[3] & (0xfb)) | (0x04); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4); + if( (ptr[0]&0x0f) == 0x5 ) + { + MPDL = mt7570_information_output(0x05) + 0x4; + ptr[0] = MPDL; + ptr[1] = MPDL >> 8; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4); - ptr[2] = (ptr[2] & (0xbf)) | (0x40); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4); + mt7570_restart_ERC_P0(); + printk("TEC done\n"); + TEC_cnt++; + } + + + + + } - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0120), ptr, 4); - ptr[1] = (ptr[1] & (0xe0)) | (0x1f); - ptr[0] = (ptr[0] & (0x80)) | (0x05); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0120), ptr, 4); } -# 3111 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_fine_tune_PWR_ER(int pwr_er,int up_dn) +# 3742 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_OpenLoopMode(void) { unchar ptr[4]; - int pav = 0; - int p1 = 0; - en7571_ERC = 0; - en7571_KT = 0; - pav = en7571_info(0x01); - p1 = en7571_info(0x06); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); + ptr[0] = (ptr[0] & 0xfc) | 0x02; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); - if( pwr_er ) - { - if( up_dn ) - pav += 0x004; - else - pav -= 0x004; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); + ptr[0] = (ptr[0] & 0xfc) | 0x02; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); - if( pav > 0xfff ) - pav = 0xfff; - else if( pav < 0 ) - pav = 0; - } - else - { - if( up_dn ) - p1 += 0x001; - else - p1 -= 0x001; + printk("Switch to Open-Loop Mode\n"); +} +# 3770 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void Ibias_temperature_set(void) +{ + int a = 0; + int b = 0; + int read_data = 0; + unchar ptr[4]; + float temp = 0; + mt7570_temperature_get(); + a = (int)IC_temperature; + read_data = get_flash_register((0x060)); + read_data = (read_data & 0xffff0000 ) | a; + set_flash_register(read_data ,(0x060)); + printk("tempature %d degree save done\n",a); + + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2); + read_data = get_flash_register((0x060)); + read_data = ((read_data & 0x0000ffff )|( ptr[0] << 16 ) |( ptr[1] << 24 )); + set_flash_register(read_data ,(0x060)); - if( p1 > 0x3ff ) - p1 = 0x3ff; - else if( p1 < 0 ) - p1 = 0; - } - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); - ptr[0] = pav; - ptr[1] = (pav >> 8); - ptr[2] = p1; - ptr[3] = (p1 >> 8); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); + temp = (float)mt7570_information_output(0x03)*0.02442; + a = (int)temp; + b = (int)(temp*100)%100; + printk("Ibias current = %d.%.2dmA \n", a, b); } -# 3168 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_SWKT(void) +# 3815 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_DualClosedLoopMode(void) { - int need_ERC = 0; - int Imod_delta = 0; - int ratio_now = 0; + unchar ptr[4]; - UINT32 Iav_cal = 0; - UINT32 Imod_cal = 0; - UINT32 Imod_now = 0; - UINT32 MPDH_cal = 0; - UINT32 Imod_target = 0; - UINT32 factor_HT = 0; - UINT32 factor_LT = 0; - float Iav_delta = 0; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); + ptr[0] = (ptr[0] & 0xfc) | 0x01; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); - static int activated; - Iav_cal = (get_flash_register((0x000))&0x0fff0000) >> 16; - ratio_now = ( 100*en7571_info(0x02) )/Iav_cal - 100; - Imod_cal = get_flash_register((0x000))&0x00000fff; - Imod_now = en7571_info(0x04); - factor_HT = get_flash_register((0x064))&0x0000ffff; - factor_LT = (get_flash_register((0x064))&0xffff0000) >> 16; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); + ptr[0] = (ptr[0] & 0xfc) | 0x01; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); + printk("Switch to Dual Closed-Loop Mode\n"); +} +# 3844 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_Vtemp_ADC_get(void) +{ + float sensor_voltage; - Iav_delta = (float)en7571_info(0x02) - (float)Iav_cal; + mt7570_ADC_temperature_get(); + sensor_voltage = ADC_slope*((float)global_temperature_code)+ADC_offset; + printk("V_ADC = 0x%x\n", (uint)(sensor_voltage*10000)); +} +# 3865 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_ERTemperatureCompensation(void) +{ + unchar ptr[4]; + uint read_data = 0; + int norm_temp =40; + int Power_comp = 0; - if( ratio_now >= 0 ) - { - if( en7571_KT == 3 ) - { - Imod_target = (UINT32)( (float)Imod_cal*( 0x400 + (float)ratio_now*(float)factor_HT) ); - Imod_target = Imod_target>>12; - } - else - { - Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 + Iav_delta*(float)factor_HT) ); - Imod_target = Imod_target>>17; - } + uint Power_comp_P0_Hi = 0; + uint Power_comp_P1_Hi = 0; + uint Power_comp_P0_Lo = 0; + uint Power_comp_P1_Lo = 0; - Imod_delta = (int)Imod_target - (int)Imod_now; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTFACTORHT = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3210, (int)factor_HT) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTTARGET = 0x%03x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3211, Imod_target) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTDELTA = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3212, Imod_delta) ; }; + if((SCL ==1) || (DOL==1)) + return; - if( Imod_delta > 0x02e ) - { - MPDH_cal = en7571_info(0x06) + 1; - need_ERC = 1; - } - else if( (-1)*Imod_delta > 0x02e ) - { - MPDH_cal = en7571_info(0x06) - 1; - need_ERC = 1; - } - } - else + if( (TEC != 0) && (TEC_switch == 1) ) { - if( en7571_KT == 1 ) - { - Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 + Iav_delta*(float)factor_LT) ); - Imod_target = Imod_target>>17; - } - else if( en7571_KT == 2 ) - { - Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 - Iav_delta*(float)factor_LT) ); - Imod_target = Imod_target>>17; - } - else if( en7571_KT == 3 ) - { - Imod_target = (UINT32)( (float)Imod_cal*( 0x400 + (float)ratio_now*(float)factor_LT) ); - Imod_target = Imod_target>>12; - } - - Imod_delta = (int)Imod_target - (int)Imod_now; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTFACTORLT = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3244, (int)factor_LT) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTTARGET = 0x%03x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3245, Imod_target) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTDELTA = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3246, Imod_delta) ; }; - - if( Imod_delta > 0x02e ) - { - MPDH_cal = en7571_info(0x06) + 1; - need_ERC = 1; - } - else if( (-1)*Imod_delta > 0x02e ) - { - MPDH_cal = en7571_info(0x06) - 1; - need_ERC = 1; - } - } - - - if( (en7571_PatternEnabled==1) ) + if (Ibias_outputlow_flag ==1) { - if( (ratio_now<-2) || (ratio_now>15) ) - { - if( need_ERC == 1 ) - { - en7571_change_mpdh(MPDH_cal); - activated = 1; - } - } - else - { - if( activated == 1 ) - { - MPDH_cal = get_flash_register((0x004))&0x000003ff; - en7571_change_mpdh(MPDH_cal); - activated = 0; - } + printk("Ibias output lower\n"); + return; } } else { - if( ratio_now >= 0 ) - en7571_tune_KT(factor_HT); - else - en7571_tune_KT(factor_LT); + Ibias_outputlow_flag = 0; } -} -# 3297 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_OPKT(void) -{ - int Imod_delta = 0; - int ratio_now = 0; - int Imod_target_hys = 0 ; - UINT32 Iav_cal = 0; - UINT32 Imod_cal = 0; - UINT32 Imod_target = 0; - UINT32 factor_HT = 0; - UINT32 factor_LT = 0; - float Iav_delta = 0; + printk("ETC\n"); - if(gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_UP) - { - - Iav_cal = (get_flash_register((0x000))&0x0fff0000) >> 16; - ratio_now = ( 100*(int)Iav_linkup_now )/Iav_cal - 100; - Imod_cal = get_flash_register((0x000))&0x00000fff; - factor_HT = get_flash_register((0x064))&0x0000ffff; - factor_LT = (get_flash_register((0x064))&0xffff0000) >> 16; - - - Iav_delta = (float)Iav_linkup_now- (float)Iav_cal; - - if( ratio_now >= 0 ) - { - if( en7571_KT == 3 ) + if( (get_flash_register((0x060)) != 0xffffffff)) { - Imod_target = (UINT32)( (float)Imod_cal*( 0x400 + (float)ratio_now*(float)factor_HT) ); - Imod_target = Imod_target>>12; + norm_temp = (get_flash_register((0x060)) & 0xff) ; } - else + + if( (get_flash_register((0x064))&0xff) != 0xff) { - Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 + Iav_delta*(float)factor_HT) ); - Imod_target = Imod_target>>17; + Power_comp_P0_Hi = (get_flash_register((0x064)) & 0xff) ; } - - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTFACTORHT = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3336, (int)factor_HT) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTTARGET = 0x%03x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3337, Imod_target) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTDELTA = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3338, Imod_delta) ; }; - - } - else - { - if( en7571_KT == 1 ) + if( ((get_flash_register((0x064))>>8)&0xff) != 0xff) { - Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 + Iav_delta*(float)factor_LT) ); - Imod_target = Imod_target>>17; + Power_comp_P1_Hi = ((get_flash_register((0x064))>>8)&0xff) ; } - else if( en7571_KT == 2 ) + if( ((get_flash_register((0x064))>>16)&0xff) != 0xff) { - Imod_target = (UINT32)( (float)Imod_cal*( 0x20000 - Iav_delta*(float)factor_LT) ); - Imod_target = Imod_target>>17; + Power_comp_P0_Lo = ((get_flash_register((0x064))>>16)&0xff) ; } - else if( en7571_KT == 3 ) + if( ((get_flash_register((0x064))>>24)&0xff) != 0xff) { - Imod_target = (UINT32)( (float)Imod_cal*( 0x400 + (float)ratio_now*(float)factor_LT) ); - Imod_target = Imod_target>>12; + Power_comp_P1_Lo = ((get_flash_register((0x064))>>24)&0xff) ; } - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTFACTORLT = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3359, (int)factor_LT) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTTARGET = 0x%03x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3360, Imod_target) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "SWKTDELTA = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3361, Imod_delta) ; }; - } - Imod_target_hys = en7571_Imod_hysteresis((int)Imod_linkup_now,(int)Imod_target); - if(need_crossing_Imod!=1) - en7571_change_Imod(Imod_target_hys); - else - { - en7571_cross_Imod(Imod_target_hys); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Imod Crossing\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3373) ; }; - en7571_cross_cnt_Imod++; - need_crossing_Imod = 0; - } - Imod_linkup_now = Imod_target_hys ; - en7571_Iavg_transfer(); + if ( (int)(IC_temperature ) > norm_temp && ((Power_comp_P0_Hi+Power_comp_P1_Hi)!=0)) + { + if((int)IC_temperature > (norm_temp+25)) + Power_comp = Power_comp_P0_Hi; + else + Power_comp = (int)(((int)IC_temperature - norm_temp)*((float)Power_comp_P0_Hi/25.0)) ; - } + read_data = (get_flash_register((0x008)) & (0x3ff)); -} + read_data = read_data + Power_comp ; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2); + if((int)IC_temperature > (norm_temp+25)) + Power_comp = Power_comp_P1_Hi; + else + Power_comp = (int)(((int)IC_temperature - norm_temp)*((float)Power_comp_P1_Hi/25.0)) ; + read_data = (get_flash_register((0x00c)) & (0x3ff)); -void en7571_change_Imod(UINT32 input) -{ - unchar ptr[4]; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 4); - ptr[1] = (ptr[1] & 0xf0) | (input >> 8); - ptr[0] = (input & 0xff); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 4); -} + read_data = read_data + Power_comp ; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2); + mt7570_TxSD_level_set(); + } + else if ( (int)(IC_temperature ) < (norm_temp-20) && ((Power_comp_P0_Lo+Power_comp_P1_Lo)!=0)) + { + if((int)IC_temperature < (norm_temp-30)) + Power_comp = Power_comp_P0_Lo*(-1); + else + Power_comp = (int)(((int)IC_temperature - (norm_temp-20))*((float)Power_comp_P0_Lo/10.0)) ; -void en7571_change_Ibias(UINT32 input) -{ - unchar ptr[4]; + read_data = (get_flash_register((0x008)) & (0x3ff)); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 4); - ptr[1] = (ptr[1] & 0xf0) | (input >> 8); - ptr[0] = (input & 0xff); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 4); -} + read_data = read_data + Power_comp ; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2); + if((int)IC_temperature < (norm_temp-30)) + Power_comp = Power_comp_P1_Lo*(-1); + else + Power_comp = (int)(((int)IC_temperature - (norm_temp-20))*((float)Power_comp_P1_Lo/10.0)) ; -void en7571_change_mpdh(UINT32 input) -{ - unchar ptr[4]; + read_data = (get_flash_register((0x00c)) & (0x3ff)); + read_data = read_data + Power_comp ; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2); + mt7570_TxSD_level_set(); + } + else + { + read_data = (get_flash_register((0x00c)) & (0x3ff)) | ((get_flash_register((0x008)) & (0x3ff)) << 16); + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2 , ptr, 2); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); - ptr[1] = 0x00; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); + ptr[2] = (read_data >> 16); + ptr[3] = (read_data >> 24); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 4); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); - ptr[2] = input; - ptr[3] = input>>8; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x025C), ptr, 4 ); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); - ptr[1] = 0x02; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0248), ptr, 4); + mt7570_TxSD_level_set(); + } } - - - - -void en7571_cross_Imod(UINT32 input) +# 4019 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void SOL_mt7570_ERTemperatureCompensation(void) { - unchar ptr[2]; - ptr[1] = (input >> 8); - ptr[0] = (input & 0xff); - - if( en7571_cross == 1 ) - { - mbi_ctrl_set(0); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr,2); - mbi_ctrl_set(1); - } - else - { - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 2); - } -} - - + unchar ptr[4]; + uint read_data = 0; + int norm_temp =40; + int Power_comp = 0; -void en7571_cross_Ibias(UINT32 input) -{ + float temp = 0; + int LT_turnning_point = 0; + int NT_turnning_point = 0; + int HT_turnning_point = 0; + + int LT_turnning_point_ibias = 0; + int NT_turnning_point_ibias = 0; + int HT_turnning_point_ibias = 0; + + uint Ibias_init_tmp = 0; + uint Ibias_slop1 = 0; + uint Ibias_slop2 = 0; + uint Ibias_slop3 = 0; + uint Ibias_slop4 = 0; - unchar ptr[2]; - ptr[1] = (input >> 8); - ptr[0] = (input & 0xff); + uint Power_comp_P1_Hi = 0; + uint Power_comp_P1_Lo = 0; + int a = 0; + int b = 0; + int Ibias_set = 0; - if( en7571_cross == 1 ) + if((get_flash_register((0x060)) | get_flash_register((0x070)) | get_flash_register((0x074)) | get_flash_register((0x00c)) )== 0xffffffff ) { - mbi_ctrl_set(0); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr,2); - mbi_ctrl_set(1); + printk("SOL wrong flash setting \n"); } else - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2); - -} -# 3491 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" - void en7571_VBR_find(int High , int low) -{ - unchar ptr[4]; - uint RSSI_voltage = 0x9000; - unchar APD_DAC[1]; - int read = 0 ; - int APD_low =0 ; - int APD_high = 255 ; - int counter = 1 ; - - en7571_APD_initialization(); - - APD_DAC[0] = 0x7f ; - while((RSSI_voltage < 0x1000) || (RSSI_voltage> 0x6000)) - { - en7571_APD_I2C_write(APD_DAC); - ( (__builtin_constant_p(50) && (50)<=2) ? (__builtin_constant_p((50)*1000) ? (((50)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((50)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((50)*1000)) : ({unsigned long __ms=(50); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - RSSI_voltage = en7571_dark_current(); - - read = APD_DAC[0] ; - if (RSSI_voltage< low) - { - APD_DAC[0] = (APD_low + read)/2 ; - APD_high = read; - } - - if(RSSI_voltage > High) - { - APD_DAC[0] = (APD_high + read)/2 ; - APD_low = read ; - } - - - counter ++; - - if (counter == 15) - { - - break; - } - } - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0030), ptr, 1); + { - printk("APD_VBR = %x\n", ptr[0]); + if( (get_flash_register((0x060)) != 0xffffffff)) + { + norm_temp = (get_flash_register((0x060)) & 0xff) ; + } + if( (get_flash_register((0x070))&0xff) != 0xff) + { + LT_turnning_point = (get_flash_register((0x070)) & 0xff) ; + } + if( ((get_flash_register((0x070))>>8 )&0xff) != 0xff) + { + NT_turnning_point = ((get_flash_register((0x070))>>8) & 0xff) ; + } -} -# 3549 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_LOS_find(int LOS_find) -{ - unchar ptr[4]; - int LOS_status = 0 ; - int read = 0 ; - UINT8 LOS_thld_L = 0x00; - UINT8 LOS_thld_H = 0x7f; - int DAC = 0 ; - int counter = 0 ; + if( ((get_flash_register((0x070))>>16 )&0xff) != 0xff) + { + HT_turnning_point = ((get_flash_register((0x070)) >>16) & 0xff) ; + } - if (LOS_find == 0) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C)+(0x02), ptr, 1); - read = ptr[0] ; + if( (get_flash_register((0x074))&0xff) != 0xff) + { + Ibias_slop1 = (get_flash_register((0x074)) & 0xff) ; + } - en7571_LOS_calibration(0x00, 0x00); - ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + if( ((get_flash_register((0x074)) >>8 )&0xff) != 0xff) + { + Ibias_slop2 = ((get_flash_register((0x074)) >> 8) & 0xff) ; + } + if( ((get_flash_register((0x074)) >>16 )&0xff) != 0xff) + { + Ibias_slop3 = ((get_flash_register((0x074)) >> 16) & 0xff) ; + } - LOS_status = en7571_LOS_calibration(0x7f, 0x00); + if( ((get_flash_register((0x074)) >>24 )&0xff) != 0xff) + { + Ibias_slop4 = ((get_flash_register((0x074)) >> 24) & 0xff) ; + } - if (LOS_status ==1 ) - { - printk("LOS is high, error\n"); - } - DAC = 0x3f ; + if( ((get_flash_register((0x060)) >> 16)&0xfff) != 0xfff) + { + Ibias_init_tmp = ((get_flash_register((0x060)) >> 16) & 0xfff) ; + } + else + { + printk("SOL Ibias equal to 0 , not correct \n"); + return; + } - while (1) - { - LOS_status = en7571_LOS_calibration(0x7F, DAC); - ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); + if( (get_flash_register((0x078))&0xff) != 0xff) + { + Power_comp_P1_Lo = (get_flash_register((0x078)) & 0xff) ; + } - if (LOS_status ==1) + if( ((get_flash_register((0x078)) >>16 )&0xff) != 0xff) + { + Power_comp_P1_Hi = ((get_flash_register((0x078)) >> 16) & 0xff) ; + } +# 4135 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" + if ( (int)(IC_temperature ) > norm_temp ) + { + if((int)IC_temperature > 60) { - LOS_thld_H = DAC ; - DAC = (LOS_thld_L + DAC)/2 ; + Power_comp = Power_comp_P1_Hi; } - if (LOS_status ==0) + else { - LOS_thld_L = DAC ; - DAC = (LOS_thld_H + DAC)/2 ; + Power_comp = (int)(((int)IC_temperature -norm_temp)*((float)Power_comp_P1_Hi/(60 - norm_temp ))) ; } - counter ++; - en7571_LOS_calibration(0x00, 0x00); - if (counter == 8) - break; - } + read_data = (get_flash_register((0x00c)) & (0x3ff)); - printk("Rx LOS = 0x%x \n", DAC); - en7571_LOS_calibration(0x00, DAC); -# 3628 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" - ptr[0] = (ptr[0] & (0x80)) | read; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C)+(0x02) , ptr, 1); - } - else - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C)+(0x03), ptr, 1); - read = ptr[0] ; + read_data = read_data + Power_comp ; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2); - en7571_LOS_calibration(0x7f, 0x7f); - ( (__builtin_constant_p(100) && (100)<=2) ? (__builtin_constant_p((100)*1000) ? (((100)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((100)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((100)*1000)) : ({unsigned long __ms=(100); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - - - LOS_status = en7571_LOS_calibration(0x7f, 0x00); - - if (LOS_status == 0 ) - { - printk("LOS is low, error\n"); - } + mt7570_TxSD_level_set(); - - DAC = 0x3F ; + } + else if ( (int)(IC_temperature ) < (norm_temp) ) + { + read_data = (get_flash_register((0x00c)) & (0x3ff)); + if((int)IC_temperature < -10) + { + Power_comp = Power_comp_P1_Lo; + read_data = read_data - Power_comp ; - while (1) - { - LOS_status = en7571_LOS_calibration(DAC, 0x00); - ( (__builtin_constant_p(20) && (20)<=2) ? (__builtin_constant_p((20)*1000) ? (((20)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((20)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((20)*1000)) : ({unsigned long __ms=(20); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - if (LOS_status ==1) - { - LOS_thld_H = DAC ; - DAC = (LOS_thld_L + DAC)/2 ; } - if (LOS_status ==0) + else { - LOS_thld_L = DAC ; - DAC = (LOS_thld_H + DAC)/2 ; - } - counter ++; - en7571_LOS_calibration(0x7F, 0x7F); + if((int)IC_temperature < 0) + { + Power_comp = (int)(((__builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed long long) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned long long), ({ signed long long __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed long) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned long), ({ signed long __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed int) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned int), ({ signed int __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed short) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned short), ({ signed short __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed char) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned char), ({ signed char __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), char), (char)({ signed char __x = ((int)IC_temperature); __x<0?-__x:__x; }), ((void)0))))))))+ norm_temp)*((float)Power_comp_P1_Lo/(norm_temp + 10))) ; + read_data = read_data - Power_comp ; - if (counter == 12) - break; - } - printk("Rx SD = 0x%x \n", DAC); - en7571_LOS_calibration(DAC, 0x00); -# 3700 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" - ptr[0] = (ptr[0] & (0x80)) | read; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C)+(0x03) , ptr, 1); - } -} -# 3720 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_eFuse_temperature_get(void) -{ - int a = 0 ; - int b = 0 ; - int read = 0 ; - unchar ptr[4]; + } + else + { + Power_comp = (int)(((int)IC_temperature-norm_temp)*((float)Power_comp_P1_Lo/(norm_temp + 10))) ; + read_data = read_data + Power_comp ; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0044), ptr, 4); - ptr[2] = (ptr[2]&0xfe) | 0x01; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0044), ptr, 4); - ( (__builtin_constant_p(50) && (50)<=2) ? (__builtin_constant_p((50)*1000) ? (((50)*1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay(((50)*1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay((50)*1000)) : ({unsigned long __ms=(50); while (__ms--) (__builtin_constant_p(1000) ? ((1000) > (2 * 1000) ? __bad_udelay() : arm_delay_ops.const_udelay((1000) * (((2199023UL) * 100) >> 11))) : arm_delay_ops.udelay(1000));})); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0044), ptr, 4); - read = ptr[0] ; + } + } - if (read <127) - en7571_eFuse_temperature_offset = (float)read *0.3; - else - en7571_eFuse_temperature_offset = (-0.3)*(float)(256 -read); + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2); - printk("eFuse value = 0x%x\n", ptr[0]); + mt7570_TxSD_level_set(); + } + else + { + read_data = (get_flash_register((0x00c)) & (0x3ff)); + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) , ptr, 2); - a = (int)en7571_eFuse_temperature_offset; - b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned long long), ({ signed long long __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned long), ({ signed long __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned int), ({ signed int __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned short), ({ signed short __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), unsigned char), ({ signed char __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(en7571_eFuse_temperature_offset*10)%10), char), (char)({ signed char __x = ((int)(en7571_eFuse_temperature_offset*10)%10); __x<0?-__x:__x; }), ((void)0))))))); - printk("eFuse offset = %d.%d'C\n", a, b); + mt7570_TxSD_level_set(); + } -} + if((NT_turnning_point < LT_turnning_point ) || ( NT_turnning_point > HT_turnning_point )) + { + printk("turning point range error\n"); + return; + } + if(( norm_temp > NT_turnning_point) &&( norm_temp < HT_turnning_point)) + { + NT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop3*(norm_temp - NT_turnning_point); + HT_turnning_point_ibias = Ibias_init_tmp + Ibias_slop3*(HT_turnning_point -norm_temp); + LT_turnning_point_ibias = NT_turnning_point_ibias - Ibias_slop2*(NT_turnning_point - LT_turnning_point); + } + else if (( NT_turnning_point > norm_temp) && ( norm_temp > LT_turnning_point)) + { + NT_turnning_point_ibias = Ibias_init_tmp + Ibias_slop2*(NT_turnning_point - norm_temp); + LT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop2*(norm_temp-LT_turnning_point); + HT_turnning_point_ibias = NT_turnning_point_ibias + Ibias_slop3*(HT_turnning_point - NT_turnning_point); + } + else if ( NT_turnning_point == norm_temp) + { + NT_turnning_point_ibias = Ibias_init_tmp ; + LT_turnning_point_ibias = NT_turnning_point_ibias - Ibias_slop2*(NT_turnning_point - LT_turnning_point); + HT_turnning_point_ibias = NT_turnning_point_ibias + Ibias_slop3*(HT_turnning_point - NT_turnning_point); -void en7571_force_mode(void) -{ - unchar ptr[4]; + } + else if ( HT_turnning_point == norm_temp) + { + HT_turnning_point_ibias = Ibias_init_tmp; + NT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop3*(HT_turnning_point - NT_turnning_point); + LT_turnning_point_ibias = NT_turnning_point_ibias - Ibias_slop2*(NT_turnning_point-LT_turnning_point); + } + else if ( norm_temp > HT_turnning_point) + { + HT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop4*(norm_temp - HT_turnning_point); + NT_turnning_point_ibias = Ibias_init_tmp - Ibias_slop3*(HT_turnning_point - NT_turnning_point); + LT_turnning_point_ibias = NT_turnning_point_ibias - Ibias_slop2*(NT_turnning_point-LT_turnning_point); + } + else if ( norm_temp <= LT_turnning_point) + { + printk("Calibration tempature too lower , Wrong setting \n"); + return; + } + if((int)IC_temperature >= HT_turnning_point ) + { + Ibias_set = HT_turnning_point_ibias + Ibias_slop4*(int)((int)IC_temperature - HT_turnning_point); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0258), ptr, 4); - ptr[3] = (ptr[3] & 0xfc) | 0x03; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0258), ptr, 4); -} + } + else if(((int)IC_temperature >= NT_turnning_point ) & ((int)IC_temperature < HT_turnning_point)) + { + Ibias_set = NT_turnning_point_ibias + Ibias_slop3*(int)((int)IC_temperature - NT_turnning_point); -void en7571_auto_lock_mode(void) -{ - unchar ptr[4]; + } + else if(((int)IC_temperature < NT_turnning_point ) & ((int)IC_temperature >= LT_turnning_point)) + { + Ibias_set = LT_turnning_point_ibias + Ibias_slop2*(int)((int)IC_temperature - LT_turnning_point); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0258), ptr, 4); - ptr[3] = (ptr[3] & 0xfc); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0258), ptr, 4); -} + } + else if ((int)IC_temperature < LT_turnning_point ) + { + if((int)IC_temperature <0 ) + { + Ibias_set = LT_turnning_point_ibias - Ibias_slop1 * ((__builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed long long) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned long long), ({ signed long long __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed long) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned long), ({ signed long __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed int) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned int), ({ signed int __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed short) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned short), ({ signed short __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), signed char) || __builtin_types_compatible_p(typeof((int)IC_temperature), unsigned char), ({ signed char __x = ((int)IC_temperature); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)IC_temperature), char), (char)({ signed char __x = ((int)IC_temperature); __x<0?-__x:__x; }), ((void)0)))))))) + LT_turnning_point); + } + else + { + Ibias_set = LT_turnning_point_ibias + Ibias_slop1 * ((int)IC_temperature - LT_turnning_point); + } -void en7571_tune_KT(UINT16 input) -{ - unchar ptr[4]; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0230), ptr, 3); - if(input==0xFFFF) - ptr[0] = (ptr[0] & 0xfe); - else - { - ptr[2] = (ptr[1] & 0xfc) | (input>>8); - ptr[1] = (ptr[0] & 0x00) | (input&0xff); - ptr[0] = (ptr[0] & 0xfe) | 0x01; - } - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0230), ptr, 3); -} + } +# 4295 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4); + ptr[0] = (ptr[0] & 0xfc) | 0x02; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C) , ptr, 4); + if (Ibias_set < 0x25) + Ibias_set = 0x25; + read_data = Ibias_set; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138) , ptr, 2); -void en7571_config(void) -{ - if( get_flash_register((0x02c)) == 0 ) - { - en7571_internal_DDMI = 0; - printk("Internal DDMI Disabled\n"); - } - else - { - printk("Internal DDMI Enabled\n"); - if( get_flash_register((0x02c)) == 2 ) - en7571_fast_DDMI = 1; - } - - if (get_flash_register((0x090)) == 1) - { - en7571_SCL = 1; - en7571_SingleClosedLoopMode(); - en7571_LUT_recover(); - en7571_temperature_get(); - en7571_LUT_Tracking(); - printk("Single-closed Loop Mode Enabled\n"); - } - else if (get_flash_register((0x090)) == 2) - { - en7571_DOL = 1; - en7571_OpenLoopMode(1); - en7571_LUT_recover(); - en7571_temperature_get(); - en7571_LUT_Tracking(); - printk("Open Loop Mode Enabled\n"); - } - else if( get_flash_register((0x060)) != 0xffffffff ) - { - en7571_ERC = 1; - printk("ERC Enabled\n"); - } - else - { - if( get_flash_register((0x064)) == 0xffffffff ) - { - set_flash_register(0x00060020, (0x064)); - en7571_KT = 1; - printk("KT Enabled\n"); - } - else - { - en7571_KT = 1; - printk("KT Enabled\n"); - } - - if( get_flash_register((0x068)) == 2 ) - { - en7571_KT = 2; - printk("KT Inversed\n"); - } - else if( get_flash_register((0x068)) == 3 ) - { - en7571_KT = 3; - printk("KT Enhanced\n"); - } - } - - en7571_delay1 = 0; - en7571_delay2 = 600; - en7571_Pav_loop = 1 ; - - if( get_flash_register((0x06c)) == 0 ) - en7571_cross = 0; - -} + temp = (float)global_bias_current*0.02442; + a = (int)temp; + b = (int)(temp*100)%100; + printk("SOL mode, Ibias = %d.%.2dmA", a, b); + printk("\t"); + a = (int)IC_temperature; + b = __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long long), ({ signed long long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed long) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned long), ({ signed long __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed int) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned int), ({ signed int __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed short) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned short), ({ signed short __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), signed char) || __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), unsigned char), ({ signed char __x = ((int)(IC_temperature*10)%10); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof((int)(IC_temperature*10)%10), char), (char)({ signed char __x = ((int)(IC_temperature*10)%10); __x<0?-__x:__x; }), ((void)0))))))); + printk("IC temperature = %d.%dC\n", a, b); -void en7571_link_reg(int input) -{ - if(en7571_ver==2) - { - if(input==1) - { - en7571_mpdh_stepsize(0); - en7571_T1delay_setting(0); - } - else if(input==0) - { - en7571_mpdh_stepsize(1); - en7571_T1delay_setting(1); - } - en7571_burst_ctrl(input); - } - else - { - en7571_HWKT(input); - if(input==1) - { - en7571_T1delay_setting(0); - } - else if(input==0) - { - en7571_T1delay_setting(1); - } } } - - - - -void en7571_burst_ctrl(int input) +# 4336 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_FiberPlug_Protect(void) { - unchar ptr[4]; - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4); - ptr[1] = ( ptr[1] & 0xfb ) | 0x04; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x015C), ptr, 4); + mt7570_restart_ERC(); } - - - - -void en7571_islinkstauschange(void) +# 4355 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_restart_ERC_P0(void) { - static int linkupstatus; - int linkupstatus_now = 0; - int needchange = 0 ; - - if(gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_DOWN) - linkupstatus_now = 0; - else - linkupstatus_now = 1; - - if( (linkupstatus ^ linkupstatus_now)==1) - { - needchange = 1 ; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Link up status is change\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3932) ; }; - } - else - { - needchange = 0 ; - } + unchar ptr[4]; - if( needchange && (linkupstatus_now==1)) - { - en7571_get_linkup_infor(); - en7571_OpenLoopMode(1); - } - else if(needchange && (linkupstatus_now==0) ) - { - en7571_OpenLoopMode(0); - en7571_closeloop_reset(); - } + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4); + ptr[0] = ptr[0] & 0xfe; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 ); - linkupstatus = linkupstatus_now ; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4); + ptr[0] = (ptr[0] & 0xfe) | (0x01); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 4 ); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "P0 ERC restarted\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4367) ; }; } -# 3961 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_Pavg_close_loop(void) +# 4383 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_BiasTracking(void) { - int pav_cal = 0; - int pav_current = 0; - int pav_delta =0; - int Ibias_target = 0 ; - int Iav_target =0 ; - int Ibias_target_hys = 0 ; - int temp = 0 ; + unchar ptr[4]; + uint read_data = 0; + uint MPDL = 0; + uint Ibias_now = 0; + int temperature_index = 0; + int a = 0; + int b = 0; - if( (en7571_PatternEnabled == 0) && (gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_UP)) - { + float temp = 0; - pav_cal = en7571_info(0x01); - pav_current = en7571_info(0x07); - pav_delta = pav_cal - pav_current ; + temperature_index = (int)( (Env_temperature+40)/2.5 ); + if( temperature_index < 0 ) + temperature_index = 0; + read_data = LUT_Ibias_Imod[temperature_index][0]; - if(pav_delta<0) - temp = (-1)*pav_delta; - else - temp = pav_delta; + if( read_data == 0xfff ) + return; - if(temp > 0x15) - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Pav_delta = %d\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 3989, pav_delta) ; }; + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2 ); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target bias loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4412, read_data) ; }; + temp = (float)read_data*0.02442; + a = (int)temp; + b = (int)(temp*100)%100; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Ibias = %d.%.2dmA\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4416, a, b) ; }; + Ibias_now = global_bias_current; - if(pav_delta <0 ) - { - Iav_target = Iav_linkup_now - 0x4 ; - } - else if(pav_delta >0) - { - Iav_target = Iav_linkup_now + 0x4 ; - } - else - { - Iav_target = Iav_linkup_now ; - } + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); + if( (ptr[0]&0x0f) == 0x5 ) + { - if(Iav_linkup_now<0) + if ( read_data > Ibias_now ) { - Iav_target = Iav_linkup_now + 0x80 ; + if ( read_data - Ibias_now > 0x14 ) + { + MPDL = mt7570_information_output(0x05) + 0x4; + ptr[0] = MPDL; + ptr[1] = MPDL >> 8; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Bias tracking done\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4433) ; }; + } } - - - Ibias_target = en7571_Ibias_transfer(Iav_target); - - - Ibias_target_hys = en7571_Ibias_hysteresis(Ibias_target,pav_delta); - - - if(need_crossing_Ibias!=1) - en7571_change_Ibias(Ibias_target_hys); - else + else if ( read_data < Ibias_now ) { - en7571_cross_Ibias(Ibias_target_hys); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Ibias Crossing\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4024) ; }; - en7571_cross_cnt_Ibias++; - need_crossing_Ibias = 0; + if( Ibias_now - read_data > 0x14 ) + { + MPDL = mt7570_information_output(0x05) - 0x4; + ptr[0] = MPDL; + ptr[1] = MPDL >> 8; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0004) + 0x2, ptr, 2); + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Bias tracking done\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4444) ; }; + } } - - - Ibias_linkup_now = Ibias_target_hys ; - en7571_Iavg_transfer(); - } -} - -void en7571_get_linkup_infor(void) -{ - - Imod_linkup_now = en7571_info(0x04); - en7571_change_Imod(Imod_linkup_now); - - Ibias_linkup_now = en7571_info(0x03); - en7571_change_Ibias(Ibias_linkup_now); - - Iav_linkup_now = en7571_info(0x02); - - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Imod_DAC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4053, Imod_linkup_now) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Ibias_DAC = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4054, Ibias_linkup_now) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Iav_linkup_now = 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4055, Iav_linkup_now) ; }; - -} - - - - -int en7571_Ibias_transfer(int Iav_target) -{ - int Ibias_target = 0 ; - float Imod_now = 0 ; - float Iav_now = 0 ; - - Imod_now = (float)Imod_linkup_now*0.02198; - Iav_now = (float)Iav_target*0.02198; - - Ibias_target = (int) ((Iav_now - Imod_now/2)/0.02442); - - return Ibias_target ; - -} - - - - -void en7571_Iavg_transfer(void) -{ - float Ibias_now = 0 ; - float Imod_now = 0 ; - - Imod_now = (float)Imod_linkup_now*0.02198; - Ibias_now = (float)Ibias_linkup_now *0.02442; - - Iav_linkup_now = (int) ((Ibias_now + Imod_now/2)/0.02198); - -} - - - - -void en7571_closeloop_reset(void) -{ - unchar ptr[4]; - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - ptr[1] = ptr[1] & 0xfe; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - ptr[0] = ptr[0] & 0xfe; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - - en7571_hw_reset(); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - ptr[0] = (ptr[0]&0xfe) | 0x01; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - ptr[1] = (ptr[1]&0xfe) | 0x01; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0228), ptr, 4); - - } - - - - -int en7571_Ibias_hysteresis(int Ibias_target , int pav_delta) +# 4470 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_LUT_recover(void) { + uint Init_Ibias = 0; + uint FLASH_Ibias = 0; + uint FLASH_Ibias_up = 0; + uint FLASH_Imod = 0; + uint FLASH_Imod_up = 0; + uint Ibias_offset = 0; + uint Ibias_recover = 0; + uint Imod_recover = 0; + uint Ibias_cal = 0; - int HSB_target = 0 ; - int HSB_now = 0 ; - int hysteresis = 0 ; - int Ibias_target_hys = 0; - - - - HSB_target = (Ibias_target >> 8) & 0xff ; - HSB_now = (Ibias_linkup_now >> 8) & 0xff ; + int FLASH_index = 0; + int index = 0; + float temperature_cal = 25.0; + float temperature = 0; - if(pav_delta<0) - pav_delta = (-1)*pav_delta; - if(HSB_target != HSB_now) + if( DOL == 1 ) { - if(pav_delta <= 0xf) - { - hysteresis = 1; - } - else + for( index = 0; index < 64; index ++ ) { - hysteresis = 0; - need_crossing_Ibias = 1 ; - } - } - else - { - hysteresis = 0; - - } - - if(hysteresis ==1) - { - Ibias_target_hys = Ibias_linkup_now; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Hysteresis, Ibias now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4160,Ibias_linkup_now) ; }; - } - else - Ibias_target_hys = Ibias_target; - - + temperature = (float)index*2.5 - 40; + FLASH_index = (int)( (temperature+40)/10 ); - if(Ibias_target_hys <= 0x080) - Ibias_target_hys = 0x080 ; - else if(Ibias_target_hys >=0xf7f) - Ibias_target_hys = 0xf7f; + if( FLASH_index < 0 ) + FLASH_index = 0; + else if( FLASH_index >15 ) + FLASH_index = 15; - return Ibias_target_hys; -} + FLASH_Ibias =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x0fff0000) >> 16; + FLASH_Ibias_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x0fff0000) >> 16; + FLASH_Imod =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x00000fff); + FLASH_Imod_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x00000fff); + if( FLASH_Ibias == 0xfff || FLASH_Ibias_up == 0xfff ) + { + LUT_Ibias_Imod[index][0] = 0xfff; + } + else + { + if(FLASH_index < 4) + Ibias_recover = FLASH_Ibias + ((temperature +40) - (FLASH_index*10))*(FLASH_Ibias_up - FLASH_Ibias)/10; + else + Ibias_recover = FLASH_Ibias + (temperature - ((10*FLASH_index) -40))*(FLASH_Ibias_up - FLASH_Ibias)/10; + LUT_Ibias_Imod[index][0] = Ibias_recover; + } -int en7571_Imod_hysteresis(int Imod_now, int Imod_target) -{ - int LSB_now = 0 ; - int HSB_now = 0 ; - int LSB_target = 0 ; - int HSB_target = 0 ; - int hysteresis = 0 ; + if( FLASH_Imod == 0xfff || FLASH_Imod_up == 0xfff ) + { + LUT_Ibias_Imod[index][1] = 0xfff; + } + else + { + if(FLASH_index < 4) + Imod_recover = FLASH_Imod + ((temperature +40) - (FLASH_index*10))*(FLASH_Imod_up - FLASH_Imod)/10; + else + Imod_recover = FLASH_Imod + (temperature - ((10*FLASH_index) -40))*(FLASH_Imod_up - FLASH_Imod)/10; - int Imod_update = 0 ; + LUT_Ibias_Imod[index][1] = Imod_recover; + } + } - LSB_now = Imod_now & 0xff; - HSB_now = (Imod_now >> 8) & 0xff ; - LSB_target = Imod_target & 0xff; - HSB_target = (Imod_target >> 8) & 0xff ; - if(HSB_now < HSB_target) - { - if(LSB_target <= 0x10) + for( FLASH_index=0; FLASH_index<=15; FLASH_index++ ) { - hysteresis = 1; - Imod_update = Imod_now; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Hysteresis, Imod now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4201,Imod_now) ; }; + index = 4*FLASH_index; - } - else - { - need_crossing_Imod= 1; - Imod_update = Imod_target; - } - } - else if(HSB_now > HSB_target) - { - if(LSB_target >= 0xf0) - { - hysteresis = 1; - Imod_update = Imod_now; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Hysteresis, Imod now is 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4216,Imod_now) ; }; - } - else - { - need_crossing_Imod = 1; - Imod_update = Imod_target; + if( ((get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ) != 0xfff ) + { + LUT_Ibias_Imod[index][0] = ( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ); + } + + if( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x00000fff) != 0xfff ) + { + LUT_Ibias_Imod[index][1] = ( get_flash_register( 0xa0 + FLASH_index*4 ) & 0x00000fff ); + } } } else - Imod_update = Imod_target; - - - if(Imod_update <= 0x032) - Imod_update = 0x032 ; - else if(Imod_update >=0xf7f) - Imod_update = 0xf7f; - - return Imod_update; - -} -# 4244 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_LUT_Tracking(void) -{ - uint Imod_target = 0; - uint Ibias_target = 0; - - int temperature_index = 0; - - - temperature_index = (int)( (en7571_Env_temperature+40)/2.5 ); - if( temperature_index < 0 ) - temperature_index = 0; - - if(en7571_SCL ==1) { - - } - else if(en7571_DOL==1) - { - Ibias_target = en7571_LUT_Ibias_Imod[temperature_index][0]; - Imod_target = en7571_LUT_Ibias_Imod[temperature_index][1]; - if( (Ibias_target== 0xfff) || (Imod_target == 0xfff) ) - return; - - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Ibias loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4267, Ibias_target) ; }; - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Imod loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4268, Imod_target) ; }; - - en7571_change_Ibias(Ibias_target); - en7571_change_Imod(Imod_target); - { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Using change fcn\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c", '/') + 1, 4272) ; }; - } -} -# 4283 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_LUT_recover(void) -{ - uint Imod_cal = 0; - uint Ibias_cal = 0; - uint FLASH_Ibias = 0; - uint FLASH_Ibias_up = 0; - uint FLASH_Imod = 0; - uint FLASH_Imod_up = 0; - int Imod_offset = 0; - int Ibias_offset = 0; - uint Ibias_recover = 0; - uint Imod_recover = 0; - uint Imod_intp = 0; - uint Ibias_intp = 0; - - - int FLASH_index = 0; - int index = 0; - float temperature_cal = 25.0; - float temperature = 0; - - if( en7571_DOL == 1 ) - { - if( get_flash_register((0x08c)) != 0xffffffff ) + if( get_flash_register((0x060)) != 0xffffffff ) { - temperature_cal = (float)get_flash_register((0x08c))/10; + temperature_cal = (float)get_flash_register((0x060))/10; if( (temperature_cal<0) || (temperature_cal>40)) { printk("EnvTemp error\n"); @@ -51882,30 +51631,22 @@ if (get_flash_register(0xa0+FLASH_index*4) == 0xffffffff) { - printk("Lack of Imod-current table\n"); + printk("Lack of bias-current table\n"); return; } - FLASH_Ibias =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x0fff0000) >> 16; - FLASH_Ibias_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x0fff0000) >> 16; - FLASH_Imod =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x00000fff); - FLASH_Imod_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x00000fff); - - Ibias_intp = FLASH_Ibias + (temperature_cal - ((10*FLASH_index) -40))*(FLASH_Ibias_up - FLASH_Ibias)/10; - Imod_intp = FLASH_Imod + (temperature_cal - ((10*FLASH_index) -40))*(FLASH_Imod_up - FLASH_Imod)/10; - Imod_cal = get_flash_register((0x008))&0x00000fff; - Ibias_cal = (get_flash_register((0x008))&0x0fff0000) >> 16; - + FLASH_Ibias =(get_flash_register(0xa0+FLASH_index*4) & 0x0fff0000) >> 16; + FLASH_Ibias_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x0fff0000) >> 16; + Ibias_cal = FLASH_Ibias + (temperature_cal - ((10*FLASH_index) -40))*(FLASH_Ibias_up - FLASH_Ibias)/10; - Imod_offset = (int)Imod_cal - (int)Imod_intp; - printk("Imod offset = %d\n", Imod_offset); + Init_Ibias = get_flash_register((0x000)); + Ibias_offset = Init_Ibias - Ibias_cal; + printk("Bias offset = 0x%x\n", Ibias_offset); - Ibias_offset = (int)Ibias_cal - (int)Ibias_intp; - printk("Ibias offset = %d\n", Ibias_offset); for( index = 0; index < 64; index ++ ) { @@ -51920,13 +51661,10 @@ FLASH_Ibias =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x0fff0000) >> 16; FLASH_Ibias_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x0fff0000) >> 16; - FLASH_Imod =(get_flash_register(0xa0+ FLASH_index*4 ) & 0x00000fff); - FLASH_Imod_up =(get_flash_register(0xa0+(FLASH_index+1)*4) & 0x00000fff); - if( FLASH_Ibias == 0xfff || FLASH_Ibias_up == 0xfff ) { - en7571_LUT_Ibias_Imod[index][0] = 0xfff; + LUT_Ibias_Imod[index][0] = 0xfff; } else { @@ -51935,46 +51673,31 @@ else Ibias_recover = FLASH_Ibias + (temperature - ((10*FLASH_index) -40))*(FLASH_Ibias_up - FLASH_Ibias)/10; - en7571_LUT_Ibias_Imod[index][0] = Ibias_recover + Ibias_offset; + LUT_Ibias_Imod[index][0] = Ibias_recover + Ibias_offset; } - - if( FLASH_Imod == 0xfff || FLASH_Imod_up == 0xfff ) + if( LUT_Ibias_Imod[index][0] <= 0x0 ) { - en7571_LUT_Ibias_Imod[index][1] = 0xfff; + printk("LUT recover failed\n"); + return; } - else - { - if(FLASH_index < 4) - Imod_recover = FLASH_Imod + ((temperature +40) - (FLASH_index*10))*(FLASH_Imod_up - FLASH_Imod)/10; - else - Imod_recover = FLASH_Imod + (temperature - ((10*FLASH_index) -40))*(FLASH_Imod_up - FLASH_Imod)/10; - en7571_LUT_Ibias_Imod[index][1] = Imod_recover + Imod_offset; - } } for( FLASH_index=0; FLASH_index<=15; FLASH_index++ ) { index = 4*FLASH_index; - if( ((get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ) != 0xfff ) { - en7571_LUT_Ibias_Imod[index][0] = ( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ) + Ibias_offset; - } - - if( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x00000fff) != 0xfff ) - { - en7571_LUT_Ibias_Imod[index][1] = ( get_flash_register( 0xa0 + FLASH_index*4 ) & 0x00000fff ) + Imod_offset; + LUT_Ibias_Imod[index][0] = ( (get_flash_register( 0xa0 + FLASH_index*4 ) & 0x0fff0000) >> 16 ) + Ibias_offset; } } } - } -# 4419 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_show_LUT(void) +# 4648 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_show_LUT(void) { int index = 0; @@ -51987,111 +51710,101 @@ for( index = 0; index < 64; index ++ ) { - printk("%03d.%01d\t\t0x%03x\t0x%03x\n", (index*25-400)/10, (int)(__builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed long long) || __builtin_types_compatible_p(typeof(index*25-400), unsigned long long), ({ signed long long __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed long) || __builtin_types_compatible_p(typeof(index*25-400), unsigned long), ({ signed long __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed int) || __builtin_types_compatible_p(typeof(index*25-400), unsigned int), ({ signed int __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed short) || __builtin_types_compatible_p(typeof(index*25-400), unsigned short), ({ signed short __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed char) || __builtin_types_compatible_p(typeof(index*25-400), unsigned char), ({ signed char __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), char), (char)({ signed char __x = (index*25-400); __x<0?-__x:__x; }), ((void)0)))))))%10), en7571_LUT_Ibias_Imod[index][0], en7571_LUT_Ibias_Imod[index][1] ); + printk("%03d.%01d\t\t0x%03x\t0x%03x\n", (index*25-400)/10, (int)(__builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed long long) || __builtin_types_compatible_p(typeof(index*25-400), unsigned long long), ({ signed long long __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed long) || __builtin_types_compatible_p(typeof(index*25-400), unsigned long), ({ signed long __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed int) || __builtin_types_compatible_p(typeof(index*25-400), unsigned int), ({ signed int __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed short) || __builtin_types_compatible_p(typeof(index*25-400), unsigned short), ({ signed short __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), signed char) || __builtin_types_compatible_p(typeof(index*25-400), unsigned char), ({ signed char __x = (index*25-400); __x < 0 ? -__x : __x; }), __builtin_choose_expr( __builtin_types_compatible_p(typeof(index*25-400), char), (char)({ signed char __x = (index*25-400); __x<0?-__x:__x; }), ((void)0)))))))%10), LUT_Ibias_Imod[index][0], LUT_Ibias_Imod[index][1] ); } } -# 4444 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_SingleClosedLoopMode(void) +# 4679 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_SingleClosedLoopMode(void) { + unchar ptr[4]; - en7571_DCL_stop(); - en7571_mpdh_stepsize(0); - en7571_hw_reset(); - en7571_DCL_start(); -} -# 4461 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_OpenLoopMode(int input) -{ - unchar ptr[4]; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); + ptr[0] = (ptr[0] & 0xfc) | 0x02; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); - if(input==1) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); - ptr[0] = (ptr[0] & 0xfc) | 0x02; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); - ptr[0] = (ptr[0] & 0xfc) | 0x02; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); - } - else if(input==0) - { - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); - ptr[0] = (ptr[0] & 0xfc); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x013C), ptr, 1); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); + ptr[0] = (ptr[0] & 0xfc) | 0x01; + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); - ptr[0] = (ptr[0] & 0xfc); - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x014C), ptr, 1); - } + printk("Switch to Single-closed Loop Mode\n"); } -# 4494 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_T1delay_setting(int input ) +# 4709 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_OpenLoopControl(void) { unchar ptr[4]; + uint read_data = 0; + + int temperature_index = 0; + int a = 0; + int b = 0; - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4); - if ( input == 1) - { - if( get_flash_register((0x094)) == 0x07050701 ) - { - ptr[0] = (ptr[0] & 0x00) | 0xaa; - } - else if( get_flash_register((0x094)) == 0xe7050701 ) - { - ptr[0] = (ptr[0] & 0x00) | 0x77; - } - else if( get_flash_register((0x094)) == 0xa7050701 ) - { - ptr[0] = (ptr[0] & 0x00) | 0x77; - } - } - else if( input == 0) - { - ptr[0] = (ptr[0] & 0xf0) | 0x0; - } - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0008), ptr, 4 ); -} -# 4528 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/en7571.c" -void en7571_WatchDog(void) -{ float temp = 0; - int LimitHold = 0; - if(en7571_sys_mode == 1) - { - if( (gpPhyPriv->phyCfg.flags.trafficStatus == TRAFFIC_STATUS_DOWN) && (en7571_PatternEnabled == 0) ) - { - temp = (float)en7571_info(0x02)*0.02198; - LimitHold = (int)temp; - if( LimitHold>85 ) - { - printk("Watch Dog ON !!\n"); - en7571_init(); - } - } - } -} -void en7571_tuneBiasModCurrent(UINT16 bias, UINT16 mod) + temperature_index = (int)( (Env_temperature+40)/2.5 ); + if( temperature_index < 0 ) + temperature_index = 0; + + + read_data = LUT_Ibias_Imod[temperature_index][0]; + + if( read_data == 0xfff ) + return; + + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 2 ); + + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target bias loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4736, read_data) ; }; + temp = (float)read_data*0.02442; + a = (int)temp; + b = (int)(temp*100)%100; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Ibias = %d.%.2dmA\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4740, a, b) ; }; + + + + read_data = LUT_Ibias_Imod[temperature_index][1]; + + if( read_data == 0xfff ) + return; + + ptr[0] = read_data; + ptr[1] = (read_data >> 8); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 2 ); + + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target mod loaded, 0x%x\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4753, read_data) ; }; + temp = (float)read_data*0.02198; + a = (int)temp; + b = (int)(temp*100)%100; + { if(gpPhyPriv->debugLevel & PHY_MSG_DBG) printk("[%lu" "0ms" "][%s:%d] " "Target Imod = %d.%.2dmA\n" , jiffies, strrchr("/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c", '/') + 1, 4757, a, b) ; }; + +} +# 4774 "/opt/bba/bba_3_0_platform/sdk/en7529/modules/private/xpon_phy/src/mt7570.c" +void mt7570_LOS_init(void) { unchar ptr[4]; - bias&=0xFFF; - mod&=0xFFF; + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); + ptr[0] = (ptr[0] & (0xfe)) | (0x01); - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 4); - ptr[0] = bias&0xFF; - ptr[1] = bias>>8; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0138), ptr, 4); - - phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 4); - ptr[0] = mod&0xFF; - ptr[1] = mod>>8; - phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0148), ptr, 4); + ptr[1] = (ptr[1] & (0xe0)) | (0x1f); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x011C), ptr, 4); - set_flash_register( ((bias<<16)|mod), (0x008)); + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4); + ptr[3] = (ptr[3] & (0xfb)) | (0x04); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4); + ptr[2] = (ptr[2] & (0xbf)) | (0x40); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0024), ptr, 4); + + phy_I2C_read(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0120), ptr, 4); + ptr[1] = (ptr[1] & (0xe0)) | (0x1f); + + ptr[0] = (ptr[0] & (0x80)) | (0x05); + phy_I2C_write(0, gpPhyPriv->i2c_u2_clk_div, 0x70, 2, (0x0120), ptr, 4); } ``` </details>
Sirherobrine23 added a new dependency 2025-12-08 17:07:54 +00:00
Sirherobrine23 added this to the xPON milestone 2025-12-08 17:48:52 +00:00
Sirherobrine23 added reference airoha_en7523_xpon 2025-12-08 17:49:15 +00:00
Sirherobrine23 pinned this 2025-12-08 17:49:18 +00:00
Author
Owner
i found this https://sirherobrine23.com.br/airoha_en7523/docs/src/branch/main/en7523/ilide.info-xg-s-pon-driver-programming-guide-en-pr_5a9b872d2910abc7ac9da69ab376a1e8.pdf
Author
Owner

i found code for en7571 and mt7570 pon in archer vr600 v3 gpl code

i found code for en7571 and mt7570 pon in archer vr600 v3 gpl code - https://sirherobrine23.com.br/tplink_gpl/archer_vr600_v3/src/commit/cb0b6f99a41b5ad433e42800043d4f5401c8da1c/mtk/modules/private/xpon_phy - https://sirherobrine23.com.br/tplink_gpl/archer_vr600_v3/src/commit/cb0b6f99a41b5ad433e42800043d4f5401c8da1c/mtk/modules/private/xpon
Owner

Good that we have sources for both chips.

Good that we have sources for both chips.
Author
Owner

cjdelisle can take some things from this repository for the en7580 and some other mips chips

cjdelisle can take some things from this repository for the en7580 and some other mips chips
Owner

cjs ?

cjs ?
Author
Owner

Sorry, I'm writing from my phone

Sorry, I'm writing from my phone
Author
Owner

I will have to make minor changes between them, but it doesn't seem like much, but the integration with ecnt_pon_phy.c and ecnt_xpon.c

I will have to make minor changes between them, but it doesn't seem like much, but the integration with `ecnt_pon_phy.c` and `ecnt_xpon.c`
Author
Owner

One could make this really complicated but basically this is a SFP module on the pcb. IMO we should emulate how a real sfp module interfaces with a system. SFF-8472 describes the values that should be provided and the phy.c file also references alot of values.

Besides emulating the SFF-8472 interfaces we need the driver to load the calibration data and to support setting different modes during init (AE,EPON,GPON). This should be possible to configure in the dts.

If I understand the code correctly we should be able to wrap all mt7570/en7571 calls to SFF-8472 compatible i2c calls. If we are able to do that properly we have the perfect abi/api for the pon phy to integrate into.

A pon phy and pon mac and its integration into the soc eth driver will be a beast of its own. But lets not involve that in the laser driver.

My answer here is not complete enough to build a final driver. But we need the parts that can load the calibration data and perform internal calibration and also methods to extract the SFF-8472 data.

I'll try to post some logs that can describe this in more details.

Today I understand what you meant, but I still have doubts about how to integrate this into the kernel. I'll delve deeper into the closed-source driver to think about how to integrate it all

62085877ae/Documentation/devicetree/bindings/net/sff%2Csfp.yaml (L93-L143)

62085877ae/drivers/net/phy/sfp.c (L345-L345)

> One could make this really complicated but basically this is a SFP module on the pcb. IMO we should emulate how a real sfp module interfaces with a system. SFF-8472 describes the values that should be provided and the phy.c file also references alot of values. > > Besides emulating the SFF-8472 interfaces we need the driver to load the calibration data and to support setting different modes during init (AE,EPON,GPON). This should be possible to configure in the dts. > > If I understand the code correctly we should be able to wrap all mt7570/en7571 calls to SFF-8472 compatible i2c calls. If we are able to do that properly we have the perfect abi/api for the pon phy to integrate into. > > A pon phy and pon mac and its integration into the soc eth driver will be a beast of its own. But lets not involve that in the laser driver. > > My answer here is not complete enough to build a final driver. But we need the parts that can load the calibration data and perform internal calibration and also methods to extract the SFF-8472 data. > > I'll try to post some logs that can describe this in more details. Today I understand what you meant, but I still have doubts about how to integrate this into the kernel. I'll delve deeper into the closed-source driver to think about how to integrate it all https://sirherobrine23.com.br/linux/linux/src/commit/62085877ae6592be830c2267e35dc469cb706308/Documentation/devicetree/bindings/net/sff%2Csfp.yaml#L93-L143 https://sirherobrine23.com.br/linux/linux/src/commit/62085877ae6592be830c2267e35dc469cb706308/drivers/net/phy/sfp.c#L345-L345
Owner

Standard sfp modules answer on 0x50 (static rom part) and on 0x51 (dynamic debug interface). So my idea is that we emulate a complete i2c bus. On this bus on address 0x50 we attach a simple eeprom and fill it with static data. This code already exists you just have to enable to correct modules write the dts and create the rom data.

For the dynamic part we need a driver that attaches to 0x51 on this emulated bus and dynamically reroutes requests to the laser driver on the real i2c bus.

I think the first thing to do here is to write the dts so every part of the abstraction is understood. There are some details not fully understood also and that is the pon mac to laser driver configuration. I think it is a one off setting and then that config can be placed in the laser driver dts node.

Standard sfp modules answer on 0x50 (static rom part) and on 0x51 (dynamic debug interface). So my idea is that we emulate a complete i2c bus. On this bus on address 0x50 we attach a simple eeprom and fill it with static data. This code already exists you just have to enable to correct modules write the dts and create the rom data. For the dynamic part we need a driver that attaches to 0x51 on this emulated bus and dynamically reroutes requests to the laser driver on the real i2c bus. I think the first thing to do here is to write the dts so every part of the abstraction is understood. There are some details not fully understood also and that is the pon mac to laser driver configuration. I think it is a one off setting and then that config can be placed in the laser driver dts node.
Author
Owner

When possible, I will purchase this mini OLT to create a test environment for the EN7571, this OLT is only GPON, I will not be able to test EPON

When possible, I will purchase this [mini OLT](https://www.aliexpress.com/item/1005009662606061.html) to create a test environment for the EN7571, this OLT is only GPON, I will not be able to test EPON
Owner

Ok. This model claim HGU support which is interesting. Anyway make sure you get access to the management software. I know how to get omci debug data also but we need a working hardware setup.

I have the same module but I could not get any device to link up then. I have access to more hardware now so that might change.

Alot of things needs to work before we can implement our own things. So one working reference is needed before we start spending time.

Ok. This model claim HGU support which is interesting. Anyway make sure you get access to the management software. I know how to get omci debug data also but we need a working hardware setup. I have the same module but I could not get any device to link up then. I have access to more hardware now so that might change. Alot of things needs to work before we can implement our own things. So one working reference is needed before we start spending time.
Author
Owner

Today I was messing around with the web driver, but I've given up on messing with it for now. Starting today, I'll begin working with the xPON driver

Today I was messing around with the web driver, but I've given up on messing with it for now. Starting today, I'll begin working with the xPON driver
Author
Owner

From what I'm seeing, it has a management interface. The price will drop in a few days, and i intend to buy it as soon as possible. Importing anything from Brazil is very expensive, and it's difficult to find something similar or low-cost for testing here.

One question, what's your time zone? I don't want to bother you outside of your time

From what I'm seeing, it has a management interface. The price will drop in a few days, and i intend to buy it as soon as possible. Importing anything from Brazil is very expensive, and it's difficult to find something similar or low-cost for testing here. One question, what's your time zone? I don't want to bother you outside of your time
Owner

Gmt+1 but dont let that limit you. I was able to get access to the management software. I tried to linkup but was not able to get it to work.

Gmt+1 but dont let that limit you. I was able to get access to the management software. I tried to linkup but was not able to get it to work.
Author
Owner

EN7571 didn't identify the link, but is it in stock?

I don't think much, but did you configure anything on the OLT to make it work?

The driver in this repository isn't even functional yet.

EN7571 didn't identify the link, but is it in stock? I don't think much, but did you configure anything on the OLT to make it work? The driver in this repository isn't even functional yet.
Author
Owner

Gmt+1 but dont let that limit you.

2+ hours diferrence

> Gmt+1 but dont let that limit you. 2+ hours diferrence
Owner

I tried all the pon units I have access to but none was able to pass traffic. I need to retest and see if I can get it working. But there arent much you are supposed to do on the OLT side.

I tried all the pon units I have access to but none was able to pass traffic. I need to retest and see if I can get it working. But there arent much you are supposed to do on the OLT side.
Author
Owner

I have the same module but I could not get any device to link up then. I have access to more hardware now so that might change.

Do you remember which version you got?

Notes: The OLT STICK SFP does not work for both 2.5G and 1.25G SFP slots simultaneously.

Therefore, choose the 2.5G version for your 2.5G SFP slot and the 1.25G version for your 1.25G SFP slot.
> > > I have the same module but I could not get any device to link up then. I have access to more hardware now so that might change. > Do you remember which version you got? ``` Notes: The OLT STICK SFP does not work for both 2.5G and 1.25G SFP slots simultaneously. Therefore, choose the 2.5G version for your 2.5G SFP slot and the 1.25G version for your 1.25G SFP slot. ```
Owner

I have the 1.25G (16 users) version. That is the standard 1G sfp slot speed.

I have the 1.25G (16 users) version. That is the standard 1G sfp slot speed.
Author
Owner

That's strange, I'll buy one too, so I can test it. It will take up a good part of my salary, because I'll have to buy an SFP -> Ethernet module, a 20 cm cord, and an attenuator so as not to burn the BOSA with the high power emitted by the OLT at short distances

That's strange, I'll buy one too, so I can test it. It will take up a good part of my salary, because I'll have to buy an SFP -> Ethernet module, a 20 cm cord, and an attenuator so as not to burn the BOSA with the high power emitted by the OLT at short distances
Author
Owner

I will receive my salary tomorrow. With what's left over, I'll see if I can get some of the things I need to start testing pon module

I will receive my salary tomorrow. With what's left over, I'll see if I can get some of the things I need to start testing pon module
Author
Owner

I just bought this module with 32 clients + 1G SFP, I will wait for customs to clear it as soon as it arrives to buy the rest of the items. I hope to receive them by next week

I just bought this module with 32 clients + 1G SFP, I will wait for customs to clear it as soon as it arrives to buy the rest of the items. I hope to receive them by next week
Author
Owner

When possible, I will purchase this mini OLT to create a test environment for the EN7571, this OLT is only GPON, I will not be able to test EPON

This model is a clone, which is probably a clone of another SFP OLT

> When possible, I will purchase this [mini OLT](https://www.aliexpress.com/item/1005009662606061.html) to create a test environment for the EN7571, this OLT is only GPON, I will not be able to test EPON This model is a clone, which is probably a clone of another SFP OLT - [32 terminals](https://www.sczhgx.com/product/detail.html?id=941&language=en) - [16 terminals](https://www.sczhgx.com/product/detail.html?id=939&language=en) - [tools](https://www.sczhgx.com/service/dfu_download.html?t_id=45&language=en) - [local repo](https://sirherobrine23.com.br/Sirherobrine23/zh-volt)
Author
Owner

I hadn't noticed that when I was analyzing the xx230v files I had separated, but should it be something to put in pinctrl?

900ce0df3e/econet_private/xpon_phy/src/i2c.c (L231)

522a0ca806/econet_public/arch/arm/boot/dts/en7523.dtsi (L345-L350)

I hadn't noticed that when I was analyzing the xx230v files I had separated, but should it be something to put in pinctrl? https://sirherobrine23.com.br/airoha_en7523/xPON/src/commit/900ce0df3e7eb9ecec376ed05d941fd252f29535/econet_private/xpon_phy/src/i2c.c#L231 https://sirherobrine23.com.br/airoha_en7523/xPON/src/commit/522a0ca806cb136bb6ada912d202a3f5a66ea8e8/econet_public/arch/arm/boot/dts/en7523.dtsi#L345-L350
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Depends on
#2 Ethernet
airoha_en7523/kernel
#14 EN7571 laser driver
airoha_en7523/kernel
Reference: airoha_en7523/kernel#5