Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 8 | #include <netdev.h> |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 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 | */ |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 36 | u32 smc911x_reg_read(struct eth_device *dev, u32 addr) |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 37 | { |
| 38 | volatile u32 data; |
| 39 | |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 40 | addr += dev->iobase; |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 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 | |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 50 | void smc911x_reg_write(struct eth_device *dev, u32 addr, u32 data) |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 51 | { |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 52 | addr += dev->iobase; |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 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 | |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 61 | void pkt_data_push(struct eth_device *dev, u32 addr, u32 data) |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 62 | { |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 63 | addr += dev->iobase; |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 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 | |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 74 | u32 pkt_data_pull(struct eth_device *dev, u32 addr) |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 75 | { |
| 76 | volatile u32 data; |
| 77 | |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 78 | addr += dev->iobase; |
Stefan Roese | 9182d2f | 2009-01-21 17:24:39 +0100 | [diff] [blame] | 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 | } |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 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 | } |