blob: 2628f9993648fafc923a630009b124e57f82438e [file] [log] [blame]
Stefan Roese50752792009-01-21 17:24:39 +01001/*
2 * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Stefan Roese50752792009-01-21 17:24:39 +01005 */
6
7#include <common.h>
Ben Warren736fead2009-07-20 22:01:11 -07008#include <netdev.h>
Stefan Roese50752792009-01-21 17:24:39 +01009#include <asm/io.h>
10#include "vct.h"
11
12/*
13 * EBI initialization for SMC911x access
14 */
15int 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 Warren736fead2009-07-20 22:01:11 -070036u32 smc911x_reg_read(struct eth_device *dev, u32 addr)
Stefan Roese50752792009-01-21 17:24:39 +010037{
38 volatile u32 data;
39
Ben Warren736fead2009-07-20 22:01:11 -070040 addr += dev->iobase;
Stefan Roese50752792009-01-21 17:24:39 +010041 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 Warren736fead2009-07-20 22:01:11 -070050void smc911x_reg_write(struct eth_device *dev, u32 addr, u32 data)
Stefan Roese50752792009-01-21 17:24:39 +010051{
Ben Warren736fead2009-07-20 22:01:11 -070052 addr += dev->iobase;
Stefan Roese50752792009-01-21 17:24:39 +010053 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 Warren736fead2009-07-20 22:01:11 -070061void pkt_data_push(struct eth_device *dev, u32 addr, u32 data)
Stefan Roese50752792009-01-21 17:24:39 +010062{
Ben Warren736fead2009-07-20 22:01:11 -070063 addr += dev->iobase;
Stefan Roese50752792009-01-21 17:24:39 +010064 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 Warren736fead2009-07-20 22:01:11 -070074u32 pkt_data_pull(struct eth_device *dev, u32 addr)
Stefan Roese50752792009-01-21 17:24:39 +010075{
76 volatile u32 data;
77
Ben Warren736fead2009-07-20 22:01:11 -070078 addr += dev->iobase;
Stefan Roese50752792009-01-21 17:24:39 +010079 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 Warren736fead2009-07-20 22:01:11 -070087
88int 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}