Blame view

arch/mips/sni/pcit.c 6.22 KB
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
1
2
3
4
5
6
7
8
9
10
11
12
  /*
   * PCI Tower specific code
   *
   * This file is subject to the terms and conditions of the GNU General Public
   * License.  See the file "COPYING" in the main directory of this archive
   * for more details.
   *
   * Copyright (C) 2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
   */
  
  #include <linux/init.h>
  #include <linux/interrupt.h>
ca4d3e674   David Howells   MIPS: Add missing...
13
  #include <linux/irq.h>
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
14
15
  #include <linux/pci.h>
  #include <linux/serial_8250.h>
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
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
  #include <asm/sni.h>
  #include <asm/time.h>
  #include <asm/irq_cpu.h>
  
  
  #define PORT(_base,_irq)				\
  	{						\
  		.iobase		= _base,		\
  		.irq		= _irq,			\
  		.uartclk	= 1843200,		\
  		.iotype		= UPIO_PORT,		\
  		.flags		= UPF_BOOT_AUTOCONF,	\
  	}
  
  static struct plat_serial8250_port pcit_data[] = {
  	PORT(0x3f8, 0),
  	PORT(0x2f8, 3),
  	{ },
  };
  
  static struct platform_device pcit_serial8250_device = {
  	.name			= "serial8250",
  	.id			= PLAT8250_DEV_PLATFORM,
  	.dev			= {
  		.platform_data	= pcit_data,
  	},
  };
  
  static struct plat_serial8250_port pcit_cplus_data[] = {
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
45
  	PORT(0x3f8, 0),
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
46
47
48
49
50
51
52
53
54
55
56
57
58
  	PORT(0x2f8, 3),
  	PORT(0x3e8, 4),
  	PORT(0x2e8, 3),
  	{ },
  };
  
  static struct platform_device pcit_cplus_serial8250_device = {
  	.name			= "serial8250",
  	.id			= PLAT8250_DEV_PLATFORM,
  	.dev			= {
  		.platform_data	= pcit_cplus_data,
  	},
  };
06cf5583f   Thomas Bogendoerfer   [MIPS] SNI RM upd...
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  static struct resource pcit_cmos_rsrc[] = {
          {
                  .start = 0x70,
                  .end   = 0x71,
                  .flags = IORESOURCE_IO
          },
          {
                  .start = 8,
                  .end   = 8,
                  .flags = IORESOURCE_IRQ
          }
  };
  
  static struct platform_device pcit_cmos_device = {
          .name           = "rtc_cmos",
          .num_resources  = ARRAY_SIZE(pcit_cmos_rsrc),
          .resource       = pcit_cmos_rsrc
  };
19388fb09   Ralf Baechle   [MIPS] Cleanup pc...
77
78
79
80
  static struct platform_device pcit_pcspeaker_pdev = {
  	.name		= "pcspkr",
  	.id		= -1,
  };
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
81
  static struct resource sni_io_resource = {
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
82
  	.start	= 0x00000000UL,
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
83
  	.end	= 0x03bfffffUL,
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
84
  	.name	= "PCIT IO",
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
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
  	.flags	= IORESOURCE_IO,
  };
  
  static struct resource pcit_io_resources[] = {
  	{
  		.start	= 0x00,
  		.end	= 0x1f,
  		.name	= "dma1",
  		.flags	= IORESOURCE_BUSY
  	}, {
  		.start	=  0x40,
  		.end	= 0x5f,
  		.name	= "timer",
  		.flags	= IORESOURCE_BUSY
  	}, {
  		.start	=  0x60,
  		.end	= 0x6f,
  		.name	= "keyboard",
  		.flags	= IORESOURCE_BUSY
  	}, {
  		.start	=  0x80,
  		.end	= 0x8f,
  		.name	= "dma page reg",
  		.flags	= IORESOURCE_BUSY
  	}, {
  		.start	=  0xc0,
  		.end	= 0xdf,
  		.name	= "dma2",
  		.flags	= IORESOURCE_BUSY
  	}, {
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
115
116
117
118
119
  		.start	=  0xcf8,
  		.end	= 0xcfb,
  		.name	= "PCI config addr",
  		.flags	= IORESOURCE_BUSY
  	}, {
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
120
121
122
123
124
125
126
127
  		.start	=  0xcfc,
  		.end	= 0xcff,
  		.name	= "PCI config data",
  		.flags	= IORESOURCE_BUSY
  	}
  };
  
  static struct resource sni_mem_resource = {
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
128
129
  	.start	= 0x18000000UL,
  	.end	= 0x1fbfffffUL,
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
130
131
132
  	.name	= "PCIT PCI MEM",
  	.flags	= IORESOURCE_MEM
  };
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
133
134
135
136
137
138
  static void __init sni_pcit_resource_init(void)
  {
  	int i;
  
  	/* request I/O space for devices used on all i[345]86 PCs */
  	for (i = 0; i < ARRAY_SIZE(pcit_io_resources); i++)
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
139
  		request_resource(&sni_io_resource, pcit_io_resources + i);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
140
141
142
143
144
145
146
147
  }
  
  
  extern struct pci_ops sni_pcit_ops;
  
  static struct pci_controller sni_pcit_controller = {
  	.pci_ops	= &sni_pcit_ops,
  	.mem_resource	= &sni_mem_resource,
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
148
  	.mem_offset	= 0x00000000UL,
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
149
  	.io_resource	= &sni_io_resource,
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
150
151
  	.io_offset	= 0x00000000UL,
  	.io_map_base    = SNI_PORT_BASE
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
152
  };
0b888c7f3   Thomas Gleixner   MIPS: SNI: Conver...
153
  static void enable_pcit_irq(struct irq_data *d)
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
154
  {
0b888c7f3   Thomas Gleixner   MIPS: SNI: Conver...
155
  	u32 mask = 1 << (d->irq - SNI_PCIT_INT_START + 24);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
156
157
158
  
  	*(volatile u32 *)SNI_PCIT_INT_REG |= mask;
  }
0b888c7f3   Thomas Gleixner   MIPS: SNI: Conver...
159
  void disable_pcit_irq(struct irq_data *d)
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
160
  {
0b888c7f3   Thomas Gleixner   MIPS: SNI: Conver...
161
  	u32 mask = 1 << (d->irq - SNI_PCIT_INT_START + 24);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
162
163
164
  
  	*(volatile u32 *)SNI_PCIT_INT_REG &= ~mask;
  }
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
165
  static struct irq_chip pcit_irq_type = {
8922f79ee   Thomas Gleixner   MIPS: Fixup last ...
166
  	.name = "PCIT",
0b888c7f3   Thomas Gleixner   MIPS: SNI: Conver...
167
168
  	.irq_mask = disable_pcit_irq,
  	.irq_unmask = enable_pcit_irq,
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
169
170
171
172
173
174
175
176
177
178
179
  };
  
  static void pcit_hwint1(void)
  {
  	u32 pending = *(volatile u32 *)SNI_PCIT_INT_REG;
  	int irq;
  
  	clear_c0_status(IE_IRQ1);
  	irq = ffs((pending >> 16) & 0x7f);
  
  	if (likely(irq > 0))
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
180
181
  		do_IRQ(irq + SNI_PCIT_INT_START - 1);
  	set_c0_status(IE_IRQ1);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
182
183
184
185
186
187
188
189
  }
  
  static void pcit_hwint0(void)
  {
  	u32 pending = *(volatile u32 *)SNI_PCIT_INT_REG;
  	int irq;
  
  	clear_c0_status(IE_IRQ0);
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
190
  	irq = ffs((pending >> 16) & 0x3f);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
191
192
  
  	if (likely(irq > 0))
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
193
194
  		do_IRQ(irq + SNI_PCIT_INT_START - 1);
  	set_c0_status(IE_IRQ0);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
195
196
197
198
  }
  
  static void sni_pcit_hwint(void)
  {
119537c09   Thiemo Seufer   [MIPS] Misc fixes...
199
  	u32 pending = read_c0_cause() & read_c0_status();
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
200
201
202
203
  
  	if (pending & C_IRQ1)
  		pcit_hwint1();
  	else if (pending & C_IRQ2)
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
204
  		do_IRQ(MIPS_CPU_IRQ_BASE + 4);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
205
  	else if (pending & C_IRQ3)
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
206
  		do_IRQ(MIPS_CPU_IRQ_BASE + 5);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
207
  	else if (pending & C_IRQ5)
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
208
  		do_IRQ(MIPS_CPU_IRQ_BASE + 7);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
209
210
211
212
  }
  
  static void sni_pcit_hwint_cplus(void)
  {
119537c09   Thiemo Seufer   [MIPS] Misc fixes...
213
  	u32 pending = read_c0_cause() & read_c0_status();
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
214
215
216
  
  	if (pending & C_IRQ0)
  		pcit_hwint0();
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
217
  	else if (pending & C_IRQ1)
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
218
  		do_IRQ(MIPS_CPU_IRQ_BASE + 3);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
219
  	else if (pending & C_IRQ2)
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
220
  		do_IRQ(MIPS_CPU_IRQ_BASE + 4);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
221
  	else if (pending & C_IRQ3)
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
222
  		do_IRQ(MIPS_CPU_IRQ_BASE + 5);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
223
  	else if (pending & C_IRQ5)
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
224
  		do_IRQ(MIPS_CPU_IRQ_BASE + 7);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
225
226
227
228
229
230
231
232
  }
  
  void __init sni_pcit_irq_init(void)
  {
  	int i;
  
  	mips_cpu_irq_init();
  	for (i = SNI_PCIT_INT_START; i <= SNI_PCIT_INT_END; i++)
e4ec7989b   Thomas Gleixner   MIPS: Convert the...
233
  		irq_set_chip_and_handler(i, &pcit_irq_type, handle_level_irq);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
234
235
236
  	*(volatile u32 *)SNI_PCIT_INT_REG = 0;
  	sni_hwint = sni_pcit_hwint;
  	change_c0_status(ST0_IM, IE_IRQ1);
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
237
  	setup_irq(SNI_PCIT_INT_START + 6, &sni_isa_irq);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
238
239
240
241
242
243
244
245
  }
  
  void __init sni_pcit_cplus_irq_init(void)
  {
  	int i;
  
  	mips_cpu_irq_init();
  	for (i = SNI_PCIT_INT_START; i <= SNI_PCIT_INT_END; i++)
e4ec7989b   Thomas Gleixner   MIPS: Convert the...
246
  		irq_set_chip_and_handler(i, &pcit_irq_type, handle_level_irq);
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
247
  	*(volatile u32 *)SNI_PCIT_INT_REG = 0x40000000;
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
248
249
  	sni_hwint = sni_pcit_hwint_cplus;
  	change_c0_status(ST0_IM, IE_IRQ0);
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
250
  	setup_irq(MIPS_CPU_IRQ_BASE + 3, &sni_isa_irq);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
251
  }
06cf5583f   Thomas Bogendoerfer   [MIPS] SNI RM upd...
252
  void __init sni_pcit_init(void)
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
253
  {
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
254
  	ioport_resource.end = sni_io_resource.end;
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
255
  #ifdef CONFIG_PCI
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
256
  	PCIBIOS_MIN_IO = 0x9000;
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
257
258
  	register_pci_controller(&sni_pcit_controller);
  #endif
bea771751   Thomas Bogendoerfer   [MIPS] Change PCI...
259
  	sni_pcit_resource_init();
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
260
261
262
263
264
265
266
  }
  
  static int __init snirm_pcit_setup_devinit(void)
  {
  	switch (sni_brd_type) {
  	case SNI_BRD_PCI_TOWER:
  	        platform_device_register(&pcit_serial8250_device);
06cf5583f   Thomas Bogendoerfer   [MIPS] SNI RM upd...
267
  	        platform_device_register(&pcit_cmos_device);
19388fb09   Ralf Baechle   [MIPS] Cleanup pc...
268
  		platform_device_register(&pcit_pcspeaker_pdev);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
269
270
271
272
  	        break;
  
  	case SNI_BRD_PCI_TOWER_CPLUS:
  	        platform_device_register(&pcit_cplus_serial8250_device);
06cf5583f   Thomas Bogendoerfer   [MIPS] SNI RM upd...
273
  	        platform_device_register(&pcit_cmos_device);
19388fb09   Ralf Baechle   [MIPS] Cleanup pc...
274
  		platform_device_register(&pcit_pcspeaker_pdev);
c066a32a8   Thomas Bogendoerfer   [MIPS] Support fo...
275
276
277
278
279
280
  	        break;
  	}
  	return 0;
  }
  
  device_initcall(snirm_pcit_setup_devinit);