1 /* 2 * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #include <common.h> 8 #include <netdev.h> 9 #include <asm/io.h> 10 #include "vct.h" 11 12 /* 13 * EBI initialization for SMC911x access 14 */ 15 int ebi_init_smc911x(void) 16 { 17 reg_write(EBI_DEV1_CONFIG1(EBI_BASE), 0x00003020); 18 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F); 19 20 reg_write(EBI_DEV1_TIM1_RD1(EBI_BASE), 0x00501100); 21 reg_write(EBI_DEV1_TIM1_RD2(EBI_BASE), 0x0FF02111); 22 23 reg_write(EBI_DEV1_TIM_EXT(EBI_BASE), 0xFFF00000); 24 reg_write(EBI_DEV1_EXT_ACC(EBI_BASE), 0x0FFFFFFF); 25 26 reg_write(EBI_DEV1_TIM1_WR1(EBI_BASE), 0x05001100); 27 reg_write(EBI_DEV1_TIM1_WR2(EBI_BASE), 0x3FC21110); 28 29 return 0; 30 } 31 32 /* 33 * Accessor functions replacing the "weak" functions in 34 * drivers/net/smc911x.c 35 */ 36 u32 smc911x_reg_read(struct eth_device *dev, u32 addr) 37 { 38 volatile u32 data; 39 40 addr += dev->iobase; 41 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F); 42 ebi_wait(); 43 reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr)); 44 ebi_wait(); 45 data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE)); 46 47 return (data); 48 } 49 50 void smc911x_reg_write(struct eth_device *dev, u32 addr, u32 data) 51 { 52 addr += dev->iobase; 53 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F); 54 ebi_wait(); 55 reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data); 56 reg_write(EBI_CPU_IO_ACCS(EBI_BASE), 57 EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr); 58 ebi_wait(); 59 } 60 61 void pkt_data_push(struct eth_device *dev, u32 addr, u32 data) 62 { 63 addr += dev->iobase; 64 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A); 65 ebi_wait(); 66 reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data); 67 reg_write(EBI_CPU_IO_ACCS(EBI_BASE), 68 EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr); 69 ebi_wait(); 70 71 return; 72 } 73 74 u32 pkt_data_pull(struct eth_device *dev, u32 addr) 75 { 76 volatile u32 data; 77 78 addr += dev->iobase; 79 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A); 80 ebi_wait(); 81 reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr)); 82 ebi_wait(); 83 data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE)); 84 85 return data; 86 } 87 88 int board_eth_init(bd_t *bis) 89 { 90 int rc = 0; 91 #ifdef CONFIG_SMC911X 92 rc = smc911x_initialize(0, CONFIG_DRIVER_SMC911X_BASE); 93 #endif 94 return rc; 95 } 96