blob: 9e59f0a2de23b6f06b7f67dba9e4c4dd94be99ca [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese50752792009-01-21 17:24:39 +01002/*
3 * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering
Stefan Roese50752792009-01-21 17:24:39 +01004 */
5
6#include <common.h>
Ben Warren736fead2009-07-20 22:01:11 -07007#include <netdev.h>
Stefan Roese50752792009-01-21 17:24:39 +01008#include <asm/io.h>
9#include "vct.h"
10
11/*
12 * EBI initialization for SMC911x access
13 */
14int ebi_init_smc911x(void)
15{
16 reg_write(EBI_DEV1_CONFIG1(EBI_BASE), 0x00003020);
17 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
18
19 reg_write(EBI_DEV1_TIM1_RD1(EBI_BASE), 0x00501100);
20 reg_write(EBI_DEV1_TIM1_RD2(EBI_BASE), 0x0FF02111);
21
22 reg_write(EBI_DEV1_TIM_EXT(EBI_BASE), 0xFFF00000);
23 reg_write(EBI_DEV1_EXT_ACC(EBI_BASE), 0x0FFFFFFF);
24
25 reg_write(EBI_DEV1_TIM1_WR1(EBI_BASE), 0x05001100);
26 reg_write(EBI_DEV1_TIM1_WR2(EBI_BASE), 0x3FC21110);
27
28 return 0;
29}
30
31/*
32 * Accessor functions replacing the "weak" functions in
33 * drivers/net/smc911x.c
34 */
Ben Warren736fead2009-07-20 22:01:11 -070035u32 smc911x_reg_read(struct eth_device *dev, u32 addr)
Stefan Roese50752792009-01-21 17:24:39 +010036{
37 volatile u32 data;
38
Ben Warren736fead2009-07-20 22:01:11 -070039 addr += dev->iobase;
Stefan Roese50752792009-01-21 17:24:39 +010040 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
41 ebi_wait();
42 reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr));
43 ebi_wait();
44 data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
45
46 return (data);
47}
48
Ben Warren736fead2009-07-20 22:01:11 -070049void smc911x_reg_write(struct eth_device *dev, u32 addr, u32 data)
Stefan Roese50752792009-01-21 17:24:39 +010050{
Ben Warren736fead2009-07-20 22:01:11 -070051 addr += dev->iobase;
Stefan Roese50752792009-01-21 17:24:39 +010052 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004F);
53 ebi_wait();
54 reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data);
55 reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
56 EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr);
57 ebi_wait();
58}
59
Ben Warren736fead2009-07-20 22:01:11 -070060void pkt_data_push(struct eth_device *dev, u32 addr, u32 data)
Stefan Roese50752792009-01-21 17:24:39 +010061{
Ben Warren736fead2009-07-20 22:01:11 -070062 addr += dev->iobase;
Stefan Roese50752792009-01-21 17:24:39 +010063 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A);
64 ebi_wait();
65 reg_write(EBI_IO_ACCS_DATA(EBI_BASE), data);
66 reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
67 EXT_DEVICE_CHANNEL_1 | EBI_CPU_WRITE | addr);
68 ebi_wait();
69
70 return;
71}
72
Ben Warren736fead2009-07-20 22:01:11 -070073u32 pkt_data_pull(struct eth_device *dev, u32 addr)
Stefan Roese50752792009-01-21 17:24:39 +010074{
75 volatile u32 data;
76
Ben Warren736fead2009-07-20 22:01:11 -070077 addr += dev->iobase;
Stefan Roese50752792009-01-21 17:24:39 +010078 reg_write(EBI_DEV1_CONFIG2(EBI_BASE), 0x0000004A);
79 ebi_wait();
80 reg_write(EBI_CPU_IO_ACCS(EBI_BASE), (EXT_DEVICE_CHANNEL_1 | addr));
81 ebi_wait();
82 data = reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
83
84 return data;
85}
Ben Warren736fead2009-07-20 22:01:11 -070086
87int board_eth_init(bd_t *bis)
88{
89 int rc = 0;
90#ifdef CONFIG_SMC911X
91 rc = smc911x_initialize(0, CONFIG_DRIVER_SMC911X_BASE);
92#endif
93 return rc;
94}