blob: c9ef33d9510d92e40fbaa0c94832949955224b28 [file] [log] [blame]
Stefan Roese9182d2f2009-01-21 17:24:39 +01001/*
2 * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 * MA 02111-1307 USA
18 */
19
20#include <common.h>
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070021#include <netdev.h>
Stefan Roese9182d2f2009-01-21 17:24:39 +010022#include <asm/io.h>
23#include "vct.h"
24
25/*
26 * EBI initialization for SMC911x access
27 */
28int ebi_init_smc911x(void)
29{
30 reg_write(EBI_DEV1_CONFIG1(EBI_BASE), 0x00003020);
31 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
32
33 reg_write(EBI_DEV1_TIM1_RD1(EBI_BASE), 0x00501100);
34 reg_write(EBI_DEV1_TIM1_RD2(EBI_BASE), 0x0FF02111);
35
36 reg_write(EBI_DEV1_TIM_EXT(EBI_BASE), 0xFFF00000);
37 reg_write(EBI_DEV1_EXT_ACC(EBI_BASE), 0x0FFFFFFF);
38
39 reg_write(EBI_DEV1_TIM1_WR1(EBI_BASE), 0x05001100);
40 reg_write(EBI_DEV1_TIM1_WR2(EBI_BASE), 0x3FC21110);
41
42 return 0;
43}
44
45/*
46 * Accessor functions replacing the "weak" functions in
47 * drivers/net/smc911x.c
48 */
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070049u32 smc911x_reg_read(struct eth_device *dev, u32 addr)
Stefan Roese9182d2f2009-01-21 17:24:39 +010050{
51 volatile u32 data;
52
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070053 addr += dev->iobase;
Stefan Roese9182d2f2009-01-21 17:24:39 +010054 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
55 ebi_wait();
56 reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr));
57 ebi_wait();
58 data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
59
60 return (data);
61}
62
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070063void smc911x_reg_write(struct eth_device *dev, u32 addr, u32 data)
Stefan Roese9182d2f2009-01-21 17:24:39 +010064{
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070065 addr += dev->iobase;
Stefan Roese9182d2f2009-01-21 17:24:39 +010066 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
67 ebi_wait();
68 reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data);
69 reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
70 EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr);
71 ebi_wait();
72}
73
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070074void pkt_data_push(struct eth_device *dev, u32 addr, u32 data)
Stefan Roese9182d2f2009-01-21 17:24:39 +010075{
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070076 addr += dev->iobase;
Stefan Roese9182d2f2009-01-21 17:24:39 +010077 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A);
78 ebi_wait();
79 reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data);
80 reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
81 EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr);
82 ebi_wait();
83
84 return;
85}
86
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070087u32 pkt_data_pull(struct eth_device *dev, u32 addr)
Stefan Roese9182d2f2009-01-21 17:24:39 +010088{
89 volatile u32 data;
90
Ben Warrenfbfdd3a2009-07-20 22:01:11 -070091 addr += dev->iobase;
Stefan Roese9182d2f2009-01-21 17:24:39 +010092 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A);
93 ebi_wait();
94 reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr));
95 ebi_wait();
96 data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
97
98 return data;
99}
Ben Warrenfbfdd3a2009-07-20 22:01:11 -0700100
101int board_eth_init(bd_t *bis)
102{
103 int rc = 0;
104#ifdef CONFIG_SMC911X
105 rc = smc911x_initialize(0, CONFIG_DRIVER_SMC911X_BASE);
106#endif
107 return rc;
108}