blob: 932e9aa2b60ee56b8bf8983b090d26f6bce4c0eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/*
* Copyright 2006, Realtek Semiconductor Corp.
*
* arch/rlx/rlxocp/setup.c
* Interrupt and exception initialization for RTL8198
*
* Tony Wu (tonywu@realtek.com.tw)
* Nov. 7, 2006
*/
#include <linux/console.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
#include <asm/addrspace.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/bootinfo.h>
#include <asm/time.h>
#include <asm/reboot.h>
#include <asm/rlxbsp.h>
#include <asm/rtl865x/rtl865xc_asicregs.h>
#include "bspchip.h"
extern int bsp_swcore_init(unsigned int version);
static void prom_putchar(char c)
{
#define UART0_BASE 0xB8002000
#define UART0_THR (UART0_BASE + 0x000)
#define UART0_FCR (UART0_BASE + 0x008)
#define UART0_LSR (UART0_BASE + 0x014)
#define TXRST 0x04
#define CHAR_TRIGGER_14 0xC0
#define LSR_THRE 0x20
#define TxCHAR_AVAIL 0x00
#define TxCHAR_EMPTY 0x20
unsigned int busy_cnt = 0;
do
{
/* Prevent Hanging */
if (busy_cnt++ >= 30000)
{
/* Reset Tx FIFO */
REG8(UART0_FCR) = TXRST | CHAR_TRIGGER_14;
return;
}
} while ((REG8(UART0_LSR) & LSR_THRE) == TxCHAR_AVAIL);
/* Send Character */
REG8(UART0_THR) = c;
}
static void early_console_write(const char *s, unsigned n)
{
while (n-- && *s) {
if (*s == '\n')
prom_putchar('\r');
prom_putchar(*s);
s++;
}
}
static void shutdown_netdev(void)
{
struct net_device *dev;
printk("Shutdown network interface\n");
read_lock(&dev_base_lock);
for_each_netdev(&init_net, dev)
{
if(dev->flags &IFF_UP)
{
printk("%s:===>\n",dev->name);
rtnl_lock();
#if defined(CONFIG_COMPAT_NET_DEV_OPS)
if(dev->stop)
dev->stop(dev);
#else
if ((dev->netdev_ops)&&(dev->netdev_ops->ndo_stop))
dev->netdev_ops->ndo_stop(dev);
#endif
rtnl_unlock();
}
}
#if defined(CONFIG_RTL8192CD) || defined(CONFIG_RTL8192E)
{
extern void force_stop_wlan_hw(void);
force_stop_wlan_hw();
}
#endif
read_unlock(&dev_base_lock);
}
static void bsp_machine_restart(char *command)
{
static void (*back_to_prom)(void) = (void (*)(void)) 0xbfc00000;
REG32(GIMR)=0;
local_irq_disable();
#ifdef CONFIG_NET
shutdown_netdev();
#endif
REG32(BSP_WDTCNR) = 0; //enable watch dog
while (1) ;
/* Reboot */
back_to_prom();
}
static void bsp_machine_halt(void)
{
while(1);
}
static void bsp_machine_power_off(void)
{
while(1);
}
/*
* callback function
*/
#define REG32(reg) (*(volatile unsigned int *)(reg))
extern void _imem_dmem_init(void);
void __init bsp_setup(void)
{
int ret= -1;
unsigned int version = 0;
if((REG32(0xb8000000)&0xf)<3)
{
REG32(0xb8000088)= (REG32(0xb8000088) & ( ~(3<<5)&~(0xF<<0)));
printk("0xb8000088=%x\n",REG32(0xb8000088));
REG32(0xb8000088) =(REG32(0xb8000088)|(1<<4));
printk("0xb8000088=%x\n",REG32(0xb8000088));
REG32(0xb8000088) = REG32(0xb8000088) & (~(3<<7));
printk("0xb8000088=%x\n",REG32(0xb8000088));
}
/* define io/mem region */
ioport_resource.start = 0x18000000;
ioport_resource.end = 0x1fffffff;
iomem_resource.start = 0x18000000;
iomem_resource.end = 0x1fffffff;
/* set reset vectors */
_machine_restart = bsp_machine_restart;
_machine_halt = bsp_machine_halt;
pm_power_off = bsp_machine_power_off;
#if defined(CONFIG_RTL_DUAL_PCIESLOT_BIWLAN_D)
{
unsigned int tmp=0,tmp1=0,tmp2=0;
tmp1=REG32(0xb8001004);
if((REG32(0xb8001000)&0x80000000)==0x80000000)
{
//REG32(0xb8001008)=0x6d13a4c0;
REG32(0xb8001004)=tmp1;
}
}
#endif
version = 8;
/* initialize uart */
bsp_serial_init();
_imem_dmem_init();
/* initialize switch core */
#if defined(CONFIG_RTL_819X)
ret = bsp_swcore_init(version);
if(ret != 0)
{
bsp_machine_halt();
}
#endif
}
pure_initcall(rtl819x_add_device_usb);
|