1*50752790SStefan Roese /*
2*50752790SStefan Roese  * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering
3*50752790SStefan Roese  *
4*50752790SStefan Roese  * This program is free software; you can redistribute it and/or
5*50752790SStefan Roese  * modify it under the terms of the GNU General Public License as
6*50752790SStefan Roese  * published by the Free Software Foundation; either version 2 of
7*50752790SStefan Roese  * the License, or (at your option) any later version.
8*50752790SStefan Roese  *
9*50752790SStefan Roese  * This program is distributed in the hope that it will be useful,
10*50752790SStefan Roese  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*50752790SStefan Roese  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*50752790SStefan Roese  * GNU General Public License for more details.
13*50752790SStefan Roese  *
14*50752790SStefan Roese  * You should have received a copy of the GNU General Public License
15*50752790SStefan Roese  * along with this program; if not, write to the Free Software
16*50752790SStefan Roese  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17*50752790SStefan Roese  * MA 02111-1307 USA
18*50752790SStefan Roese  */
19*50752790SStefan Roese 
20*50752790SStefan Roese #include <common.h>
21*50752790SStefan Roese #include <asm/io.h>
22*50752790SStefan Roese #include "vct.h"
23*50752790SStefan Roese 
24*50752790SStefan Roese /*
25*50752790SStefan Roese  * EBI initialization for SMC911x access
26*50752790SStefan Roese  */
27*50752790SStefan Roese int ebi_init_smc911x(void)
28*50752790SStefan Roese {
29*50752790SStefan Roese 	reg_write(EBI_DEV1_CONFIG1(EBI_BASE), 0x00003020);
30*50752790SStefan Roese 	reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
31*50752790SStefan Roese 
32*50752790SStefan Roese 	reg_write(EBI_DEV1_TIM1_RD1(EBI_BASE), 0x00501100);
33*50752790SStefan Roese 	reg_write(EBI_DEV1_TIM1_RD2(EBI_BASE), 0x0FF02111);
34*50752790SStefan Roese 
35*50752790SStefan Roese 	reg_write(EBI_DEV1_TIM_EXT(EBI_BASE), 0xFFF00000);
36*50752790SStefan Roese 	reg_write(EBI_DEV1_EXT_ACC(EBI_BASE), 0x0FFFFFFF);
37*50752790SStefan Roese 
38*50752790SStefan Roese 	reg_write(EBI_DEV1_TIM1_WR1(EBI_BASE), 0x05001100);
39*50752790SStefan Roese 	reg_write(EBI_DEV1_TIM1_WR2(EBI_BASE), 0x3FC21110);
40*50752790SStefan Roese 
41*50752790SStefan Roese 	return 0;
42*50752790SStefan Roese }
43*50752790SStefan Roese 
44*50752790SStefan Roese /*
45*50752790SStefan Roese  * Accessor functions replacing the "weak" functions in
46*50752790SStefan Roese  * drivers/net/smc911x.c
47*50752790SStefan Roese  */
48*50752790SStefan Roese u32 smc911x_reg_read(u32 addr)
49*50752790SStefan Roese {
50*50752790SStefan Roese 	volatile u32 data;
51*50752790SStefan Roese 
52*50752790SStefan Roese 	reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
53*50752790SStefan Roese 	ebi_wait();
54*50752790SStefan Roese 	reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr));
55*50752790SStefan Roese 	ebi_wait();
56*50752790SStefan Roese 	data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
57*50752790SStefan Roese 
58*50752790SStefan Roese 	return (data);
59*50752790SStefan Roese }
60*50752790SStefan Roese 
61*50752790SStefan Roese void smc911x_reg_write(u32 addr, u32 data)
62*50752790SStefan Roese {
63*50752790SStefan Roese 	reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
64*50752790SStefan Roese 	ebi_wait();
65*50752790SStefan Roese 	reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data);
66*50752790SStefan Roese 	reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
67*50752790SStefan Roese 		  EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr);
68*50752790SStefan Roese 	ebi_wait();
69*50752790SStefan Roese }
70*50752790SStefan Roese 
71*50752790SStefan Roese void pkt_data_push(u32 addr, u32 data)
72*50752790SStefan Roese {
73*50752790SStefan Roese 	reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A);
74*50752790SStefan Roese 	ebi_wait();
75*50752790SStefan Roese 	reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data);
76*50752790SStefan Roese 	reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
77*50752790SStefan Roese 		  EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr);
78*50752790SStefan Roese 	ebi_wait();
79*50752790SStefan Roese 
80*50752790SStefan Roese 	return;
81*50752790SStefan Roese }
82*50752790SStefan Roese 
83*50752790SStefan Roese u32 pkt_data_pull(u32 addr)
84*50752790SStefan Roese {
85*50752790SStefan Roese 	volatile u32 data;
86*50752790SStefan Roese 
87*50752790SStefan Roese 	reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A);
88*50752790SStefan Roese 	ebi_wait();
89*50752790SStefan Roese 	reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr));
90*50752790SStefan Roese 	ebi_wait();
91*50752790SStefan Roese 	data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
92*50752790SStefan Roese 
93*50752790SStefan Roese 	return data;
94*50752790SStefan Roese }
95