summaryrefslogtreecommitdiff
path: root/os/manga/archmanga.c
blob: 45b0f68c00edfa497cc8db233e1f0c5f98f6192e (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
/*
 * Manga Balance Plus
 */
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"../port/error.h"
#include	"io.h"

#include "../port/netif.h"
#include "etherif.h"
#include	"../port/flashif.h"

enum {
	/* GPIO assignment ... */

	Maxmac=	4,	/* number of MAC addresses taken from EEPROM */
};

static uchar	macaddrs[Maxmac][Eaddrlen] = {
[0] {0x00, 0x10, 0xa1, 0x00, 0x10, 0x01},
[1] {0x00, 0x11, 0x6E, 0x00, 0x4A, 0xD4},
[2] {0x00, 0x10, 0xa1, 0x00, 0x20, 0x01},	/* TO DO */
};

void
archreset(void)
{
	/* TO DO: set GPIO and other key registers? */
	GPIOREG->iopm |= (1<<GPIO_status_orange_o)|(1<<GPIO_status_green_o);
	GPIOREG->iopm &= ~(1<<GPIO_button_i);
	GPIOREG->iopd &= ~(1<<GPIO_status_orange_o);
	GPIOREG->iopd &= ~(1<<GPIO_status_green_o);
	GPIOREG->iopc |= 0x8888;
	m->cpuhz = 166000000;	/* system clock is 125 = 5*CLOCKFREQ */
	m->delayloop = m->cpuhz/1000;
/*
	uartdebuginit();
*/
}

void
ledset(int n)
{
	int s;

	s = splhi();
	if(n)
		GPIOREG->iopd |= 1<<GPIO_status_green_o;
	else
		GPIOREG->iopd &= ~(1<<GPIO_status_green_o);
	splx(s);
}

void
archconfinit(void)
{
	ulong *p;

	p = KADDR(PHYSMEMCR+0x30);
	conf.topofmem = (((p[0]>>22)<<16)|0xFFFF)+1;
//	w = PMGRREG->ppcr & 0x1f;
//	m->cpuhz = CLOCKFREQ*(27*2*2);
}

void
archuartpower(int, int)
{
}

void
kbdinit(void)
{
}

void
archreboot(void)
{
	dcflushall();
	GPIOREG->iopd |= 1<<GPIO_status_green_o;
	GPIOREG->iopd &= ~(1<<GPIO_status_orange_o);
//	mmuputctl(mmugetctl() & ~CpCaltivec);	/* restore bootstrap's vectors */
//	RESETREG->rsrr = 1;	/* software reset */
	for(;;)
		//spllo();
		splhi();
}

void
archflashwp(Flash*, int)
{
}

/*
 * for devflash.c:/^flashreset
 * retrieve flash type, virtual base and length and return 0;
 * return -1 on error (no flash)
 */
int
archflashreset(int bank, Flash *f)
{
	ulong *p;
	int w;

	p = KADDR(PHYSMEMCR+0x10);
iprint("Flash %8.8lux %8.8lux %8.8lux\n", p[0], p[1], p[4]);
	w = p[4]&3;
	if(bank > 0 || w == 0)
		return -1;
	if(w == 3)
		w = 4;
	f->type = "cfi8";
	f->addr = (void*)FLASHMEM;
	f->size = 0;
	f->width = w;
	f->interleave = 0;
	return 0;
}

/*
 * set ether parameters: the contents should be derived from EEPROM or NVRAM
 */
int
archether(int ctlno, Ether *ether)
{
	ether->nopt = 0;
	ether->itype = IRQ;
	switch(ctlno){
	case 0:
		sprint(ether->type, "ks8695");
		ether->mem = PHYSWANDMA;
		ether->port = 0;
		ether->irq = IRQwmrps;
		break;
	case 1:
		sprint(ether->type, "ks8695");
		ether->mem = PHYSLANDMA;
		ether->port = 1;
		ether->irq = IRQlmrps;
		ether->maxmtu = ETHERMAXTU+4;	/* 802.1[pQ] tags */
		break;
	case 2:
		sprint(ether->type, "rtl8139");
		ether->mem = 0;
		ether->port = 0;
		ether->irq = -1;
		break;
	default:
		return -1;
	}
	memmove(ether->ea, macaddrs[ctlno], Eaddrlen);
	return 1;
}

/*
 * TO DO: extract some boot data from user area of flash
 */

void
eepromscan(void)
{
}