1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Cortina CS4315/CS4340 10G PHY drivers
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Copyright 2014 Freescale Semiconductor, Inc.
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun */
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun #include <config.h>
11*4882a593Smuzhiyun #include <common.h>
12*4882a593Smuzhiyun #include <malloc.h>
13*4882a593Smuzhiyun #include <linux/ctype.h>
14*4882a593Smuzhiyun #include <linux/string.h>
15*4882a593Smuzhiyun #include <linux/err.h>
16*4882a593Smuzhiyun #include <phy.h>
17*4882a593Smuzhiyun #include <cortina.h>
18*4882a593Smuzhiyun #ifdef CONFIG_SYS_CORTINA_FW_IN_NAND
19*4882a593Smuzhiyun #include <nand.h>
20*4882a593Smuzhiyun #elif defined(CONFIG_SYS_CORTINA_FW_IN_SPIFLASH)
21*4882a593Smuzhiyun #include <spi_flash.h>
22*4882a593Smuzhiyun #elif defined(CONFIG_SYS_CORTINA_FW_IN_MMC)
23*4882a593Smuzhiyun #include <mmc.h>
24*4882a593Smuzhiyun #endif
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun #ifndef CONFIG_PHYLIB_10G
27*4882a593Smuzhiyun #error The Cortina PHY needs 10G support
28*4882a593Smuzhiyun #endif
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun struct cortina_reg_config cortina_reg_cfg[] = {
31*4882a593Smuzhiyun /* CS4315_enable_sr_mode */
32*4882a593Smuzhiyun {VILLA_GLOBAL_MSEQCLKCTRL, 0x8004},
33*4882a593Smuzhiyun {VILLA_MSEQ_OPTIONS, 0xf},
34*4882a593Smuzhiyun {VILLA_MSEQ_PC, 0x0},
35*4882a593Smuzhiyun {VILLA_MSEQ_BANKSELECT, 0x4},
36*4882a593Smuzhiyun {VILLA_LINE_SDS_COMMON_SRX0_RX_CPA, 0x55},
37*4882a593Smuzhiyun {VILLA_LINE_SDS_COMMON_SRX0_RX_LOOP_FILTER, 0x30},
38*4882a593Smuzhiyun {VILLA_DSP_SDS_SERDES_SRX_DFE0_SELECT, 0x1},
39*4882a593Smuzhiyun {VILLA_DSP_SDS_DSP_COEF_DFE0_SELECT, 0x2},
40*4882a593Smuzhiyun {VILLA_LINE_SDS_COMMON_SRX0_RX_CPB, 0x2003},
41*4882a593Smuzhiyun {VILLA_DSP_SDS_SERDES_SRX_FFE_DELAY_CTRL, 0xF047},
42*4882a593Smuzhiyun {VILLA_MSEQ_ENABLE_MSB, 0x0000},
43*4882a593Smuzhiyun {VILLA_MSEQ_SPARE21_LSB, 0x6},
44*4882a593Smuzhiyun {VILLA_MSEQ_RESET_COUNT_LSB, 0x0},
45*4882a593Smuzhiyun {VILLA_MSEQ_SPARE12_MSB, 0x0000},
46*4882a593Smuzhiyun /*
47*4882a593Smuzhiyun * to invert the receiver path, uncomment the next line
48*4882a593Smuzhiyun * write (VILLA_MSEQ_SPARE12_MSB, 0x4000)
49*4882a593Smuzhiyun *
50*4882a593Smuzhiyun * SPARE2_LSB is used to configure the device while in sr mode to
51*4882a593Smuzhiyun * enable power savings and to use the optical module LOS signal.
52*4882a593Smuzhiyun * in power savings mode, the internal prbs checker can not be used.
53*4882a593Smuzhiyun * if the optical module LOS signal is used as an input to the micro
54*4882a593Smuzhiyun * code, then the micro code will wait until the optical module
55*4882a593Smuzhiyun * LOS = 0 before turning on the adaptive equalizer.
56*4882a593Smuzhiyun * Setting SPARE2_LSB bit 0 to 1 places the devie in power savings mode
57*4882a593Smuzhiyun * while setting bit 0 to 0 disables power savings mode.
58*4882a593Smuzhiyun * Setting SPARE2_LSB bit 2 to 0 configures the device to use the
59*4882a593Smuzhiyun * optical module LOS signal while setting bit 2 to 1 configures the
60*4882a593Smuzhiyun * device so that it will ignore the optical module LOS SPARE2_LSB = 0
61*4882a593Smuzhiyun */
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun /* enable power savings, ignore optical module LOS */
64*4882a593Smuzhiyun {VILLA_MSEQ_SPARE2_LSB, 0x5},
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun {VILLA_MSEQ_SPARE7_LSB, 0x1e},
67*4882a593Smuzhiyun {VILLA_MSEQ_BANKSELECT, 0x4},
68*4882a593Smuzhiyun {VILLA_MSEQ_SPARE9_LSB, 0x2},
69*4882a593Smuzhiyun {VILLA_MSEQ_SPARE3_LSB, 0x0F53},
70*4882a593Smuzhiyun {VILLA_MSEQ_SPARE3_MSB, 0x2006},
71*4882a593Smuzhiyun {VILLA_MSEQ_SPARE8_LSB, 0x3FF7},
72*4882a593Smuzhiyun {VILLA_MSEQ_SPARE8_MSB, 0x0A46},
73*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_FFE0_LSB, 0xD500},
74*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_FFE1_LSB, 0x0200},
75*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_FFE2_LSB, 0xBA00},
76*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_FFE3_LSB, 0x0100},
77*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_FFE4_LSB, 0x0300},
78*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_FFE5_LSB, 0x0300},
79*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_DFE0_LSB, 0x0700},
80*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_DFE0N_LSB, 0x0E00},
81*4882a593Smuzhiyun {VILLA_MSEQ_COEF8_DFE1_LSB, 0x0B00},
82*4882a593Smuzhiyun {VILLA_DSP_SDS_DSP_COEF_LARGE_LEAK, 0x2},
83*4882a593Smuzhiyun {VILLA_DSP_SDS_SERDES_SRX_DAC_ENABLEB_LSB, 0xD000},
84*4882a593Smuzhiyun {VILLA_MSEQ_POWER_DOWN_LSB, 0xFFFF},
85*4882a593Smuzhiyun {VILLA_MSEQ_POWER_DOWN_MSB, 0x0},
86*4882a593Smuzhiyun {VILLA_MSEQ_CAL_RX_SLICER, 0x80},
87*4882a593Smuzhiyun {VILLA_DSP_SDS_SERDES_SRX_DAC_BIAS_SELECT1_MSB, 0x3f},
88*4882a593Smuzhiyun {VILLA_GLOBAL_MSEQCLKCTRL, 0x4},
89*4882a593Smuzhiyun {VILLA_MSEQ_OPTIONS, 0x7},
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun /* set up min value for ffe1 */
92*4882a593Smuzhiyun {VILLA_MSEQ_COEF_INIT_SEL, 0x2},
93*4882a593Smuzhiyun {VILLA_DSP_SDS_DSP_PRECODEDINITFFE21, 0x41},
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun /* CS4315_sr_rx_pre_eq_set_4in */
96*4882a593Smuzhiyun {VILLA_GLOBAL_MSEQCLKCTRL, 0x8004},
97*4882a593Smuzhiyun {VILLA_MSEQ_OPTIONS, 0xf},
98*4882a593Smuzhiyun {VILLA_MSEQ_BANKSELECT, 0x4},
99*4882a593Smuzhiyun {VILLA_MSEQ_PC, 0x0},
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun /* for lengths from 3.5 to 4.5inches */
102*4882a593Smuzhiyun {VILLA_MSEQ_SERDES_PARAM_LSB, 0x0306},
103*4882a593Smuzhiyun {VILLA_MSEQ_SPARE25_LSB, 0x0306},
104*4882a593Smuzhiyun {VILLA_MSEQ_SPARE21_LSB, 0x2},
105*4882a593Smuzhiyun {VILLA_MSEQ_SPARE23_LSB, 0x2},
106*4882a593Smuzhiyun {VILLA_MSEQ_CAL_RX_DFE_EQ, 0x0},
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun {VILLA_GLOBAL_MSEQCLKCTRL, 0x4},
109*4882a593Smuzhiyun {VILLA_MSEQ_OPTIONS, 0x7},
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun /* CS4315_rx_drive_4inch */
112*4882a593Smuzhiyun /* for length 4inches */
113*4882a593Smuzhiyun {VILLA_GLOBAL_VILLA2_COMPATIBLE, 0x0000},
114*4882a593Smuzhiyun {VILLA_HOST_SDS_COMMON_STX0_TX_OUTPUT_CTRLA, 0x3023},
115*4882a593Smuzhiyun {VILLA_LINE_SDS_COMMON_STX0_TX_OUTPUT_CTRLB, 0xc01E},
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun /* CS4315_tx_drive_4inch */
118*4882a593Smuzhiyun /* for length 4inches */
119*4882a593Smuzhiyun {VILLA_GLOBAL_VILLA2_COMPATIBLE, 0x0000},
120*4882a593Smuzhiyun {VILLA_LINE_SDS_COMMON_STX0_TX_OUTPUT_CTRLA, 0x3023},
121*4882a593Smuzhiyun {VILLA_LINE_SDS_COMMON_STX0_TX_OUTPUT_CTRLB, 0xc01E},
122*4882a593Smuzhiyun };
123*4882a593Smuzhiyun
cs4340_upload_firmware(struct phy_device * phydev)124*4882a593Smuzhiyun void cs4340_upload_firmware(struct phy_device *phydev)
125*4882a593Smuzhiyun {
126*4882a593Smuzhiyun char line_temp[0x50] = {0};
127*4882a593Smuzhiyun char reg_addr[0x50] = {0};
128*4882a593Smuzhiyun char reg_data[0x50] = {0};
129*4882a593Smuzhiyun int i, line_cnt = 0, column_cnt = 0;
130*4882a593Smuzhiyun struct cortina_reg_config fw_temp;
131*4882a593Smuzhiyun char *addr = NULL;
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun #if defined(CONFIG_SYS_CORTINA_FW_IN_NOR) || \
134*4882a593Smuzhiyun defined(CONFIG_SYS_CORTINA_FW_IN_REMOTE)
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun addr = (char *)CONFIG_CORTINA_FW_ADDR;
137*4882a593Smuzhiyun #elif defined(CONFIG_SYS_CORTINA_FW_IN_NAND)
138*4882a593Smuzhiyun int ret;
139*4882a593Smuzhiyun size_t fw_length = CONFIG_CORTINA_FW_LENGTH;
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun addr = malloc(CONFIG_CORTINA_FW_LENGTH);
142*4882a593Smuzhiyun ret = nand_read(get_nand_dev_by_index(0),
143*4882a593Smuzhiyun (loff_t)CONFIG_CORTINA_FW_ADDR,
144*4882a593Smuzhiyun &fw_length, (u_char *)addr);
145*4882a593Smuzhiyun if (ret == -EUCLEAN) {
146*4882a593Smuzhiyun printf("NAND read of Cortina firmware at 0x%x failed %d\n",
147*4882a593Smuzhiyun CONFIG_CORTINA_FW_ADDR, ret);
148*4882a593Smuzhiyun }
149*4882a593Smuzhiyun #elif defined(CONFIG_SYS_CORTINA_FW_IN_SPIFLASH)
150*4882a593Smuzhiyun int ret;
151*4882a593Smuzhiyun struct spi_flash *ucode_flash;
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun addr = malloc(CONFIG_CORTINA_FW_LENGTH);
154*4882a593Smuzhiyun ucode_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
155*4882a593Smuzhiyun CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
156*4882a593Smuzhiyun if (!ucode_flash) {
157*4882a593Smuzhiyun puts("SF: probe for Cortina ucode failed\n");
158*4882a593Smuzhiyun } else {
159*4882a593Smuzhiyun ret = spi_flash_read(ucode_flash, CONFIG_CORTINA_FW_ADDR,
160*4882a593Smuzhiyun CONFIG_CORTINA_FW_LENGTH, addr);
161*4882a593Smuzhiyun if (ret)
162*4882a593Smuzhiyun puts("SF: read for Cortina ucode failed\n");
163*4882a593Smuzhiyun spi_flash_free(ucode_flash);
164*4882a593Smuzhiyun }
165*4882a593Smuzhiyun #elif defined(CONFIG_SYS_CORTINA_FW_IN_MMC)
166*4882a593Smuzhiyun int dev = CONFIG_SYS_MMC_ENV_DEV;
167*4882a593Smuzhiyun u32 cnt = CONFIG_CORTINA_FW_LENGTH / 512;
168*4882a593Smuzhiyun u32 blk = CONFIG_CORTINA_FW_ADDR / 512;
169*4882a593Smuzhiyun struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun if (!mmc) {
172*4882a593Smuzhiyun puts("Failed to find MMC device for Cortina ucode\n");
173*4882a593Smuzhiyun } else {
174*4882a593Smuzhiyun addr = malloc(CONFIG_CORTINA_FW_LENGTH);
175*4882a593Smuzhiyun printf("MMC read: dev # %u, block # %u, count %u ...\n",
176*4882a593Smuzhiyun dev, blk, cnt);
177*4882a593Smuzhiyun mmc_init(mmc);
178*4882a593Smuzhiyun (void)mmc->block_dev.block_read(&mmc->block_dev, blk, cnt,
179*4882a593Smuzhiyun addr);
180*4882a593Smuzhiyun }
181*4882a593Smuzhiyun #endif
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun while (*addr != 'Q') {
184*4882a593Smuzhiyun i = 0;
185*4882a593Smuzhiyun
186*4882a593Smuzhiyun while (*addr != 0x0a) {
187*4882a593Smuzhiyun line_temp[i++] = *addr++;
188*4882a593Smuzhiyun if (0x50 < i) {
189*4882a593Smuzhiyun printf("Not found Cortina PHY ucode at 0x%p\n",
190*4882a593Smuzhiyun (char *)CONFIG_CORTINA_FW_ADDR);
191*4882a593Smuzhiyun return;
192*4882a593Smuzhiyun }
193*4882a593Smuzhiyun }
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun addr++; /* skip '\n' */
196*4882a593Smuzhiyun line_cnt++;
197*4882a593Smuzhiyun column_cnt = i;
198*4882a593Smuzhiyun line_temp[column_cnt] = '\0';
199*4882a593Smuzhiyun
200*4882a593Smuzhiyun if (CONFIG_CORTINA_FW_LENGTH < line_cnt)
201*4882a593Smuzhiyun return;
202*4882a593Smuzhiyun
203*4882a593Smuzhiyun for (i = 0; i < column_cnt; i++) {
204*4882a593Smuzhiyun if (isspace(line_temp[i++]))
205*4882a593Smuzhiyun break;
206*4882a593Smuzhiyun }
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun memcpy(reg_addr, line_temp, i);
209*4882a593Smuzhiyun memcpy(reg_data, &line_temp[i], column_cnt - i);
210*4882a593Smuzhiyun strim(reg_addr);
211*4882a593Smuzhiyun strim(reg_data);
212*4882a593Smuzhiyun fw_temp.reg_addr = (simple_strtoul(reg_addr, NULL, 0)) & 0xffff;
213*4882a593Smuzhiyun fw_temp.reg_value = (simple_strtoul(reg_data, NULL, 0)) &
214*4882a593Smuzhiyun 0xffff;
215*4882a593Smuzhiyun phy_write(phydev, 0x00, fw_temp.reg_addr, fw_temp.reg_value);
216*4882a593Smuzhiyun }
217*4882a593Smuzhiyun }
218*4882a593Smuzhiyun
cs4340_phy_init(struct phy_device * phydev)219*4882a593Smuzhiyun int cs4340_phy_init(struct phy_device *phydev)
220*4882a593Smuzhiyun {
221*4882a593Smuzhiyun int timeout = 100; /* 100ms */
222*4882a593Smuzhiyun int reg_value;
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun /* step1: BIST test */
225*4882a593Smuzhiyun phy_write(phydev, 0x00, VILLA_GLOBAL_MSEQCLKCTRL, 0x0004);
226*4882a593Smuzhiyun phy_write(phydev, 0x00, VILLA_GLOBAL_LINE_SOFT_RESET, 0x0000);
227*4882a593Smuzhiyun phy_write(phydev, 0x00, VILLA_GLOBAL_BIST_CONTROL, 0x0001);
228*4882a593Smuzhiyun while (--timeout) {
229*4882a593Smuzhiyun reg_value = phy_read(phydev, 0x00, VILLA_GLOBAL_BIST_STATUS);
230*4882a593Smuzhiyun if (reg_value & mseq_edc_bist_done) {
231*4882a593Smuzhiyun if (0 == (reg_value & mseq_edc_bist_fail))
232*4882a593Smuzhiyun break;
233*4882a593Smuzhiyun }
234*4882a593Smuzhiyun udelay(1000);
235*4882a593Smuzhiyun }
236*4882a593Smuzhiyun
237*4882a593Smuzhiyun if (!timeout) {
238*4882a593Smuzhiyun printf("%s BIST mseq_edc_bist_done timeout!\n", __func__);
239*4882a593Smuzhiyun return -1;
240*4882a593Smuzhiyun }
241*4882a593Smuzhiyun
242*4882a593Smuzhiyun /* setp2: upload ucode */
243*4882a593Smuzhiyun cs4340_upload_firmware(phydev);
244*4882a593Smuzhiyun reg_value = phy_read(phydev, 0x00, VILLA_GLOBAL_DWNLD_CHECKSUM_STATUS);
245*4882a593Smuzhiyun if (reg_value) {
246*4882a593Smuzhiyun debug("%s checksum status failed.\n", __func__);
247*4882a593Smuzhiyun return -1;
248*4882a593Smuzhiyun }
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun return 0;
251*4882a593Smuzhiyun }
252*4882a593Smuzhiyun
cs4340_config(struct phy_device * phydev)253*4882a593Smuzhiyun int cs4340_config(struct phy_device *phydev)
254*4882a593Smuzhiyun {
255*4882a593Smuzhiyun cs4340_phy_init(phydev);
256*4882a593Smuzhiyun return 0;
257*4882a593Smuzhiyun }
258*4882a593Smuzhiyun
cs4340_probe(struct phy_device * phydev)259*4882a593Smuzhiyun int cs4340_probe(struct phy_device *phydev)
260*4882a593Smuzhiyun {
261*4882a593Smuzhiyun phydev->flags = PHY_FLAG_BROKEN_RESET;
262*4882a593Smuzhiyun return 0;
263*4882a593Smuzhiyun }
264*4882a593Smuzhiyun
cs4340_startup(struct phy_device * phydev)265*4882a593Smuzhiyun int cs4340_startup(struct phy_device *phydev)
266*4882a593Smuzhiyun {
267*4882a593Smuzhiyun phydev->link = 1;
268*4882a593Smuzhiyun
269*4882a593Smuzhiyun /* For now just lie and say it's 10G all the time */
270*4882a593Smuzhiyun phydev->speed = SPEED_10000;
271*4882a593Smuzhiyun phydev->duplex = DUPLEX_FULL;
272*4882a593Smuzhiyun return 0;
273*4882a593Smuzhiyun }
274*4882a593Smuzhiyun
275*4882a593Smuzhiyun struct phy_driver cs4340_driver = {
276*4882a593Smuzhiyun .name = "Cortina CS4315/CS4340",
277*4882a593Smuzhiyun .uid = PHY_UID_CS4340,
278*4882a593Smuzhiyun .mask = 0xfffffff0,
279*4882a593Smuzhiyun .features = PHY_10G_FEATURES,
280*4882a593Smuzhiyun .mmds = (MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS |
281*4882a593Smuzhiyun MDIO_DEVS_PHYXS | MDIO_DEVS_AN |
282*4882a593Smuzhiyun MDIO_DEVS_VEND1 | MDIO_DEVS_VEND2),
283*4882a593Smuzhiyun .config = &cs4340_config,
284*4882a593Smuzhiyun .probe = &cs4340_probe,
285*4882a593Smuzhiyun .startup = &cs4340_startup,
286*4882a593Smuzhiyun .shutdown = &gen10g_shutdown,
287*4882a593Smuzhiyun };
288*4882a593Smuzhiyun
phy_cortina_init(void)289*4882a593Smuzhiyun int phy_cortina_init(void)
290*4882a593Smuzhiyun {
291*4882a593Smuzhiyun phy_register(&cs4340_driver);
292*4882a593Smuzhiyun return 0;
293*4882a593Smuzhiyun }
294*4882a593Smuzhiyun
get_phy_id(struct mii_dev * bus,int addr,int devad,u32 * phy_id)295*4882a593Smuzhiyun int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
296*4882a593Smuzhiyun {
297*4882a593Smuzhiyun int phy_reg;
298*4882a593Smuzhiyun bool is_cortina_phy = false;
299*4882a593Smuzhiyun
300*4882a593Smuzhiyun switch (addr) {
301*4882a593Smuzhiyun #ifdef CORTINA_PHY_ADDR1
302*4882a593Smuzhiyun case CORTINA_PHY_ADDR1:
303*4882a593Smuzhiyun #endif
304*4882a593Smuzhiyun #ifdef CORTINA_PHY_ADDR2
305*4882a593Smuzhiyun case CORTINA_PHY_ADDR2:
306*4882a593Smuzhiyun #endif
307*4882a593Smuzhiyun #ifdef CORTINA_PHY_ADDR3
308*4882a593Smuzhiyun case CORTINA_PHY_ADDR3:
309*4882a593Smuzhiyun #endif
310*4882a593Smuzhiyun #ifdef CORTINA_PHY_ADDR4
311*4882a593Smuzhiyun case CORTINA_PHY_ADDR4:
312*4882a593Smuzhiyun #endif
313*4882a593Smuzhiyun is_cortina_phy = true;
314*4882a593Smuzhiyun break;
315*4882a593Smuzhiyun default:
316*4882a593Smuzhiyun break;
317*4882a593Smuzhiyun }
318*4882a593Smuzhiyun
319*4882a593Smuzhiyun /* Cortina PHY has non-standard offset of PHY ID registers */
320*4882a593Smuzhiyun if (is_cortina_phy)
321*4882a593Smuzhiyun phy_reg = bus->read(bus, addr, 0, VILLA_GLOBAL_CHIP_ID_LSB);
322*4882a593Smuzhiyun else
323*4882a593Smuzhiyun phy_reg = bus->read(bus, addr, devad, MII_PHYSID1);
324*4882a593Smuzhiyun
325*4882a593Smuzhiyun if (phy_reg < 0)
326*4882a593Smuzhiyun return -EIO;
327*4882a593Smuzhiyun
328*4882a593Smuzhiyun *phy_id = (phy_reg & 0xffff) << 16;
329*4882a593Smuzhiyun if (is_cortina_phy)
330*4882a593Smuzhiyun phy_reg = bus->read(bus, addr, 0, VILLA_GLOBAL_CHIP_ID_MSB);
331*4882a593Smuzhiyun else
332*4882a593Smuzhiyun phy_reg = bus->read(bus, addr, devad, MII_PHYSID2);
333*4882a593Smuzhiyun
334*4882a593Smuzhiyun if (phy_reg < 0)
335*4882a593Smuzhiyun return -EIO;
336*4882a593Smuzhiyun
337*4882a593Smuzhiyun *phy_id |= (phy_reg & 0xffff);
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun return 0;
340*4882a593Smuzhiyun }
341