1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/alpha/kernel/core_polaris.c
5 * POLARIS chip-specific code
8 #define __EXTERN_INLINE inline
10 #include <asm/core_polaris.h>
11 #undef __EXTERN_INLINE
13 #include <linux/types.h>
14 #include <linux/pci.h>
15 #include <linux/sched.h>
16 #include <linux/init.h>
18 #include <asm/ptrace.h>
24 * BIOS32-style PCI interface:
27 #define DEBUG_CONFIG 0
30 # define DBG_CFG(args) printk args
32 # define DBG_CFG(args)
37 * Given a bus, device, and function number, compute resulting
38 * configuration space address. This is fairly straightforward
39 * on POLARIS, since the chip itself generates Type 0 or Type 1
40 * cycles automatically depending on the bus number (Bus 0 is
41 * hardwired to Type 0, all others are Type 1. Peer bridges
46 * 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
47 * 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
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * |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|
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * 23:16 bus number (8 bits = 128 possible buses)
53 * 15:11 Device number (5 bits)
54 * 10:8 function number
58 * The function number selects which function of a multi-function device
59 * (e.g., scsi and ethernet).
61 * The register selects a DWORD (32 bit) register offset. Hence it
62 * doesn't get shifted by 2 bits as we want to "drop" the bottom two
67 mk_conf_addr(struct pci_bus
*pbus
, unsigned int device_fn
, int where
,
68 unsigned long *pci_addr
, u8
*type1
)
70 u8 bus
= pbus
->number
;
72 *type1
= (bus
== 0) ? 0 : 1;
73 *pci_addr
= (bus
<< 16) | (device_fn
<< 8) | (where
) |
74 POLARIS_DENSE_CONFIG_BASE
;
76 DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x,"
77 " returning address 0x%p\n"
78 bus
, device_fn
, where
, *pci_addr
));
84 polaris_read_config(struct pci_bus
*bus
, unsigned int devfn
, int where
,
90 if (mk_conf_addr(bus
, devfn
, where
, &addr
, &type1
))
91 return PCIBIOS_DEVICE_NOT_FOUND
;
95 *value
= __kernel_ldbu(*(vucp
)addr
);
98 *value
= __kernel_ldwu(*(vusp
)addr
);
101 *value
= *(vuip
)addr
;
105 return PCIBIOS_SUCCESSFUL
;
110 polaris_write_config(struct pci_bus
*bus
, unsigned int devfn
, int where
,
116 if (mk_conf_addr(bus
, devfn
, where
, &addr
, &type1
))
117 return PCIBIOS_DEVICE_NOT_FOUND
;
121 __kernel_stb(value
, *(vucp
)addr
);
123 __kernel_ldbu(*(vucp
)addr
);
126 __kernel_stw(value
, *(vusp
)addr
);
128 __kernel_ldwu(*(vusp
)addr
);
137 return PCIBIOS_SUCCESSFUL
;
140 struct pci_ops polaris_pci_ops
=
142 .read
= polaris_read_config
,
143 .write
= polaris_write_config
,
147 polaris_init_arch(void)
149 struct pci_controller
*hose
;
151 /* May need to initialize error reporting (see PCICTL0/1), but
152 * for now assume that the firmware has done the right thing
156 printk("polaris_init_arch(): trusting firmware for setup\n");
160 * Create our single hose.
163 pci_isa_hose
= hose
= alloc_pci_controller();
164 hose
->io_space
= &ioport_resource
;
165 hose
->mem_space
= &iomem_resource
;
168 hose
->sparse_mem_base
= 0;
169 hose
->dense_mem_base
= POLARIS_DENSE_MEM_BASE
- IDENT_ADDR
;
170 hose
->sparse_io_base
= 0;
171 hose
->dense_io_base
= POLARIS_DENSE_IO_BASE
- IDENT_ADDR
;
173 hose
->sg_isa
= hose
->sg_pci
= NULL
;
175 /* The I/O window is fixed at 2G @ 2G. */
176 __direct_map_base
= 0x80000000;
177 __direct_map_size
= 0x80000000;
181 polaris_pci_clr_err(void)
183 *(vusp
)POLARIS_W_STATUS
;
184 /* Write 1's to settable bits to clear errors */
185 *(vusp
)POLARIS_W_STATUS
= 0x7800;
187 *(vusp
)POLARIS_W_STATUS
;
191 polaris_machine_check(unsigned long vector
, unsigned long la_ptr
)
193 /* Clear the error before any reporting. */
197 polaris_pci_clr_err();
201 process_mcheck_info(vector
, la_ptr
, "POLARIS",