2 * linux/arch/alpha/kernel/core_polaris.c
4 * POLARIS chip-specific code
7 #define __EXTERN_INLINE inline
9 #include <asm/core_polaris.h>
10 #undef __EXTERN_INLINE
12 #include <linux/types.h>
13 #include <linux/pci.h>
14 #include <linux/sched.h>
15 #include <linux/init.h>
17 #include <asm/ptrace.h>
23 * BIOS32-style PCI interface:
26 #define DEBUG_CONFIG 0
29 # define DBG_CFG(args) printk args
31 # define DBG_CFG(args)
36 * Given a bus, device, and function number, compute resulting
37 * configuration space address. This is fairly straightforward
38 * on POLARIS, since the chip itself generates Type 0 or Type 1
39 * cycles automatically depending on the bus number (Bus 0 is
40 * hardwired to Type 0, all others are Type 1. Peer bridges
45 * 3 3 3 3|3 3 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
46 * 9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * |1|1|1|1|1|0|0|1|1|1|1|1|1|1|1|0|B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|x|x|
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * 23:16 bus number (8 bits = 128 possible buses)
52 * 15:11 Device number (5 bits)
53 * 10:8 function number
57 * The function number selects which function of a multi-function device
58 * (e.g., scsi and ethernet).
60 * The register selects a DWORD (32 bit) register offset. Hence it
61 * doesn't get shifted by 2 bits as we want to "drop" the bottom two
66 mk_conf_addr(struct pci_bus
*pbus
, unsigned int device_fn
, int where
,
67 unsigned long *pci_addr
, u8
*type1
)
69 u8 bus
= pbus
->number
;
71 *type1
= (bus
== 0) ? 0 : 1;
72 *pci_addr
= (bus
<< 16) | (device_fn
<< 8) | (where
) |
73 POLARIS_DENSE_CONFIG_BASE
;
75 DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x,"
76 " returning address 0x%p\n"
77 bus
, device_fn
, where
, *pci_addr
));
83 polaris_read_config(struct pci_bus
*bus
, unsigned int devfn
, int where
,
89 if (mk_conf_addr(bus
, devfn
, where
, &addr
, &type1
))
90 return PCIBIOS_DEVICE_NOT_FOUND
;
94 *value
= __kernel_ldbu(*(vucp
)addr
);
97 *value
= __kernel_ldwu(*(vusp
)addr
);
100 *value
= *(vuip
)addr
;
104 return PCIBIOS_SUCCESSFUL
;
109 polaris_write_config(struct pci_bus
*bus
, unsigned int devfn
, int where
,
115 if (mk_conf_addr(bus
, devfn
, where
, &addr
, &type1
))
116 return PCIBIOS_DEVICE_NOT_FOUND
;
120 __kernel_stb(value
, *(vucp
)addr
);
122 __kernel_ldbu(*(vucp
)addr
);
125 __kernel_stw(value
, *(vusp
)addr
);
127 __kernel_ldwu(*(vusp
)addr
);
136 return PCIBIOS_SUCCESSFUL
;
139 struct pci_ops polaris_pci_ops
=
141 .read
= polaris_read_config
,
142 .write
= polaris_write_config
,
146 polaris_init_arch(void)
148 struct pci_controller
*hose
;
150 /* May need to initialize error reporting (see PCICTL0/1), but
151 * for now assume that the firmware has done the right thing
155 printk("polaris_init_arch(): trusting firmware for setup\n");
159 * Create our single hose.
162 pci_isa_hose
= hose
= alloc_pci_controller();
163 hose
->io_space
= &ioport_resource
;
164 hose
->mem_space
= &iomem_resource
;
167 hose
->sparse_mem_base
= 0;
168 hose
->dense_mem_base
= POLARIS_DENSE_MEM_BASE
- IDENT_ADDR
;
169 hose
->sparse_io_base
= 0;
170 hose
->dense_io_base
= POLARIS_DENSE_IO_BASE
- IDENT_ADDR
;
172 hose
->sg_isa
= hose
->sg_pci
= NULL
;
174 /* The I/O window is fixed at 2G @ 2G. */
175 __direct_map_base
= 0x80000000;
176 __direct_map_size
= 0x80000000;
180 polaris_pci_clr_err(void)
182 *(vusp
)POLARIS_W_STATUS
;
183 /* Write 1's to settable bits to clear errors */
184 *(vusp
)POLARIS_W_STATUS
= 0x7800;
186 *(vusp
)POLARIS_W_STATUS
;
190 polaris_machine_check(unsigned long vector
, unsigned long la_ptr
)
192 /* Clear the error before any reporting. */
196 polaris_pci_clr_err();
200 process_mcheck_info(vector
, la_ptr
, "POLARIS",