summaryrefslogtreecommitdiffstats
path: root/arch/mips/sgi-ip22/ip22-platform.c
blob: a14fd32b76bdae03383e19e35ae71e663da1c802 (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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#include <linux/init.h>
#include <linux/if_ether.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>

#include <asm/paccess.h>
#include <asm/sgi/ip22.h>
#include <asm/sgi/hpc3.h>
#include <asm/sgi/mc.h>
#include <asm/sgi/seeq.h>
#include <asm/sgi/wd.h>

static struct resource sgiwd93_0_resources[] = {
	{
		.name	= "eth0 irq",
		.start	= SGI_WD93_0_IRQ,
		.end	= SGI_WD93_0_IRQ,
		.flags	= IORESOURCE_IRQ
	}
};

static struct sgiwd93_platform_data sgiwd93_0_pd = {
	.unit	= 0,
	.irq	= SGI_WD93_0_IRQ,
};

static struct platform_device sgiwd93_0_device = {
	.name		= "sgiwd93",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(sgiwd93_0_resources),
	.resource	= sgiwd93_0_resources,
	.dev = {
		.platform_data = &sgiwd93_0_pd,
	},
};

static struct resource sgiwd93_1_resources[] = {
	{
		.name	= "eth0 irq",
		.start	= SGI_WD93_1_IRQ,
		.end	= SGI_WD93_1_IRQ,
		.flags	= IORESOURCE_IRQ
	}
};

static struct sgiwd93_platform_data sgiwd93_1_pd = {
	.unit	= 1,
	.irq	= SGI_WD93_1_IRQ,
};

static struct platform_device sgiwd93_1_device = {
	.name		= "sgiwd93",
	.id		= 1,
	.num_resources	= ARRAY_SIZE(sgiwd93_1_resources),
	.resource	= sgiwd93_1_resources,
	.dev = {
		.platform_data = &sgiwd93_1_pd,
	},
};

/*
 * Create a platform device for the GPI port that receives the
 * image data from the embedded camera.
 */
static int __init sgiwd93_devinit(void)
{
	int res;

	sgiwd93_0_pd.hregs	= &hpc3c0->scsi_chan0;
	sgiwd93_0_pd.wdregs	= (unsigned char *) hpc3c0->scsi0_ext;

	res = platform_device_register(&sgiwd93_0_device);
	if (res)
		return res;

	if (!ip22_is_fullhouse())
		return 0;

	sgiwd93_1_pd.hregs	= &hpc3c0->scsi_chan1;
	sgiwd93_1_pd.wdregs	= (unsigned char *) hpc3c0->scsi1_ext;

	return platform_device_register(&sgiwd93_1_device);
}

device_initcall(sgiwd93_devinit);

static struct resource sgiseeq_0_resources[] = {
	{
		.name	= "eth0 irq",
		.start	= SGI_ENET_IRQ,
		.end	= SGI_ENET_IRQ,
		.flags	= IORESOURCE_IRQ
	}
};

static struct sgiseeq_platform_data eth0_pd;

static struct platform_device eth0_device = {
	.name		= "sgiseeq",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(sgiseeq_0_resources),
	.resource	= sgiseeq_0_resources,
	.dev = {
		.platform_data = &eth0_pd,
	},
};

static struct resource sgiseeq_1_resources[] = {
	{
		.name	= "eth1 irq",
		.start	= SGI_GIO_0_IRQ,
		.end	= SGI_GIO_0_IRQ,
		.flags	= IORESOURCE_IRQ
	}
};

static struct sgiseeq_platform_data eth1_pd;

static struct platform_device eth1_device = {
	.name		= "sgiseeq",
	.id		= 1,
	.num_resources	= ARRAY_SIZE(sgiseeq_1_resources),
	.resource	= sgiseeq_1_resources,
	.dev = {
		.platform_data = &eth1_pd,
	},
};

/*
 * Create a platform device for the GPI port that receives the
 * image data from the embedded camera.
 */
static int __init sgiseeq_devinit(void)
{
	unsigned int pbdma __maybe_unused;
	int res, i;

	eth0_pd.hpc = hpc3c0;
	eth0_pd.irq = SGI_ENET_IRQ;
#define EADDR_NVOFS	250
	for (i = 0; i < 3; i++) {
		unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);

		eth0_pd.mac[2 * i]     = tmp >> 8;
		eth0_pd.mac[2 * i + 1] = tmp & 0xff;
	}

	res = platform_device_register(&eth0_device);
	if (res)
		return res;

	/* Second HPC is missing? */
	if (ip22_is_fullhouse() ||
	    get_dbe(pbdma, (unsigned int *)&hpc3c1->pbdma[1]))
		return 0;

	sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 |
			 SGIMC_GIOPAR_HPC264;
	hpc3c1->pbus_piocfg[0][0] = 0x3ffff;
	/* interrupt/config register on Challenge S Mezz board */
	hpc3c1->pbus_extregs[0][0] = 0x30;

	eth1_pd.hpc = hpc3c1;
	eth1_pd.irq = SGI_GIO_0_IRQ;
#define EADDR_NVOFS	250
	for (i = 0; i < 3; i++) {
		unsigned short tmp = ip22_eeprom_read(&hpc3c1->eeprom,
						      EADDR_NVOFS / 2 + i);

		eth1_pd.mac[2 * i]     = tmp >> 8;
		eth1_pd.mac[2 * i + 1] = tmp & 0xff;
	}

	return platform_device_register(&eth1_device);
}

device_initcall(sgiseeq_devinit);

static int __init sgi_hal2_devinit(void)
{
	return IS_ERR(platform_device_register_simple("sgihal2", 0, NULL, 0));
}

device_initcall(sgi_hal2_devinit);

static int __init sgi_button_devinit(void)
{
	if (ip22_is_fullhouse())
		return 0; /* full house has no volume buttons */

	return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
}

device_initcall(sgi_button_devinit);

static int __init sgi_ds1286_devinit(void)
{
	struct resource res;

	memset(&res, 0, sizeof(res));
	res.start = HPC3_CHIP0_BASE + offsetof(struct hpc3_regs, rtcregs);
	res.end = res.start + sizeof(hpc3c0->rtcregs) - 1;
	res.flags = IORESOURCE_MEM;

	return IS_ERR(platform_device_register_simple("rtc-ds1286", -1,
						      &res, 1));
}

device_initcall(sgi_ds1286_devinit);