blob: f4f7ad89c5a850130ee4ffbf4012ca83c553d870 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * c 2001 PPC 64 Team, IBM Corp
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
Stephen Rothwelld3878992005-09-28 02:50:25 +10009#ifndef _ASM_POWERPC_PPC_PCI_H
10#define _ASM_POWERPC_PPC_PCI_H
Arnd Bergmann88ced032005-12-16 22:43:46 +010011#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Stephen Rothwellbed59272007-03-04 17:04:44 +110013#ifdef CONFIG_PCI
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/pci.h>
16#include <asm/pci-bridge.h>
17
18extern unsigned long isa_io_base;
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020extern void pci_setup_phb_io(struct pci_controller *hose, int primary);
21extern void pci_setup_phb_io_dynamic(struct pci_controller *hose, int primary);
22
23
24extern struct list_head hose_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Stephen Rothwell36241ce2007-03-04 17:07:38 +110026extern void find_and_init_phbs(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Benjamin Herrenschmidt3d5134e2007-06-04 15:15:36 +100028extern struct pci_dev *isa_bridge_pcidev; /* may be NULL if no ISA bus */
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
linasae65a392005-11-03 18:42:26 -060030/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
Nishanth Aravamudandda804a2010-09-15 08:13:19 +000031#define BUID_HI(buid) upper_32_bits(buid)
32#define BUID_LO(buid) lower_32_bits(buid)
linasae65a392005-11-03 18:42:26 -060033
Linus Torvalds1da177e2005-04-16 15:20:36 -070034/* PCI device_node operations */
35struct device_node;
36typedef void *(*traverse_func)(struct device_node *me, void *data);
37void *traverse_pci_devices(struct device_node *start, traverse_func pre,
38 void *data);
39
Benjamin Herrenschmidt4c9d2802006-11-11 17:25:08 +110040extern void pci_devs_phb_init(void);
41extern void pci_devs_phb_init_dynamic(struct pci_controller *phb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
John Rosedad32bb2005-06-23 17:09:54 +100043/* From rtas_pci.h */
Benjamin Herrenschmidt4c9d2802006-11-11 17:25:08 +110044extern void init_pci_config_tokens (void);
45extern unsigned long get_phb_buid (struct device_node *);
46extern int rtas_setup_phb(struct pci_controller *phb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Linas Vepstas6dee3fb2005-11-03 18:50:10 -060048/* ---- EEH internal-use-only related routines ---- */
49#ifdef CONFIG_EEH
Linas Vepstas5d5a0932005-11-03 18:53:07 -060050
51void pci_addr_cache_insert_device(struct pci_dev *dev);
52void pci_addr_cache_remove_device(struct pci_dev *dev);
53void pci_addr_cache_build(void);
54struct pci_dev *pci_get_device_by_addr(unsigned long addr);
55
Linas Vepstas6dee3fb2005-11-03 18:50:10 -060056/**
Linas Vepstas77bd7412005-11-03 18:52:49 -060057 * eeh_slot_error_detail -- record and EEH error condition to the log
Linas Vepstas17213c32007-05-10 02:38:11 +100058 * @pdn: pci device node
59 * @severity: EEH_LOG_TEMP_FAILURE or EEH_LOG_PERM_FAILURE
Linas Vepstas77bd7412005-11-03 18:52:49 -060060 *
Michael Opdenacker59c51592007-05-09 08:57:56 +020061 * Obtains the EEH error details from the RTAS subsystem,
Linas Vepstas77bd7412005-11-03 18:52:49 -060062 * and then logs these details with the RTAS error log system.
63 */
Linas Vepstas17213c32007-05-10 02:38:11 +100064#define EEH_LOG_TEMP_FAILURE 1
65#define EEH_LOG_PERM_FAILURE 2
Linas Vepstas77bd7412005-11-03 18:52:49 -060066void eeh_slot_error_detail (struct pci_dn *pdn, int severity);
67
68/**
Linas Vepstas9c547762007-03-19 14:58:07 -050069 * rtas_pci_enable - enable IO transfers for this slot
Linas Vepstas47b5c832006-09-15 18:57:42 -050070 * @pdn: pci device node
71 * @function: either EEH_THAW_MMIO or EEH_THAW_DMA
72 *
73 * Enable I/O transfers to this slot
74 */
75#define EEH_THAW_MMIO 2
76#define EEH_THAW_DMA 3
77int rtas_pci_enable(struct pci_dn *pdn, int function);
78
79/**
Linas Vepstas6dee3fb2005-11-03 18:50:10 -060080 * rtas_set_slot_reset -- unfreeze a frozen slot
Linas Vepstas17213c32007-05-10 02:38:11 +100081 * @pdn: pci device node
Linas Vepstas6dee3fb2005-11-03 18:50:10 -060082 *
83 * Clear the EEH-frozen condition on a slot. This routine
84 * does this by asserting the PCI #RST line for 1/8th of
85 * a second; this routine will sleep while the adapter is
86 * being reset.
Linas Vepstasb6495c02005-11-03 18:54:54 -060087 *
88 * Returns a non-zero value if the reset failed.
Linas Vepstas6dee3fb2005-11-03 18:50:10 -060089 */
Linas Vepstasb6495c02005-11-03 18:54:54 -060090int rtas_set_slot_reset (struct pci_dn *);
Linas Vepstas9c547762007-03-19 14:58:07 -050091int eeh_wait_for_slot_status(struct pci_dn *pdn, int max_wait_msecs);
Linas Vepstas6dee3fb2005-11-03 18:50:10 -060092
Linas Vepstas8b553f32005-11-03 18:50:17 -060093/**
94 * eeh_restore_bars - Restore device configuration info.
Linas Vepstas17213c32007-05-10 02:38:11 +100095 * @pdn: pci device node
Linas Vepstas8b553f32005-11-03 18:50:17 -060096 *
97 * A reset of a PCI device will clear out its config space.
98 * This routines will restore the config space for this
99 * device, and is children, to values previously obtained
100 * from the firmware.
101 */
102void eeh_restore_bars(struct pci_dn *);
103
104/**
105 * rtas_configure_bridge -- firmware initialization of pci bridge
Linas Vepstas17213c32007-05-10 02:38:11 +1000106 * @pdn: pci device node
Linas Vepstas8b553f32005-11-03 18:50:17 -0600107 *
108 * Ask the firmware to configure all PCI bridges devices
109 * located behind the indicated node. Required after a
110 * pci device reset. Does essentially the same hing as
111 * eeh_restore_bars, but for brdges, and lets firmware
112 * do the work.
113 */
114void rtas_configure_bridge(struct pci_dn *);
115
116int rtas_write_config(struct pci_dn *, int where, int size, u32 val);
Linas Vepstas7684b402005-11-03 18:55:19 -0600117int rtas_read_config(struct pci_dn *, int where, int size, u32 *val);
Linas Vepstas8b553f32005-11-03 18:50:17 -0600118
Linas Vepstasd9564ad2005-11-03 18:50:48 -0600119/**
Linas Vepstas17213c32007-05-10 02:38:11 +1000120 * eeh_mark_slot -- set mode flags for pertition endpoint
121 * @pdn: pci device node
122 *
Linas Vepstasd9564ad2005-11-03 18:50:48 -0600123 * mark and clear slots: find "partition endpoint" PE and set or
124 * clear the flags for each subnode of the PE.
125 */
126void eeh_mark_slot (struct device_node *dn, int mode_flag);
127void eeh_clear_slot (struct device_node *dn, int mode_flag);
128
Linas Vepstas17213c32007-05-10 02:38:11 +1000129/**
130 * find_device_pe -- Find the associated "Partiationable Endpoint" PE
131 * @pdn: pci device node
132 */
Linas Vepstas9fb40eb2005-11-03 18:54:29 -0600133struct device_node * find_device_pe(struct device_node *dn);
134
Linas Vepstase1d04c92007-05-24 03:16:46 +1000135void eeh_sysfs_add_device(struct pci_dev *pdev);
136void eeh_sysfs_remove_device(struct pci_dev *pdev);
137
Breno Leitao8d3d50b2010-02-03 05:56:41 +0000138static inline const char *eeh_pci_name(struct pci_dev *pdev)
139{
140 return pdev ? pci_name(pdev) : "<null>";
141}
142
Linas Vepstas17213c32007-05-10 02:38:11 +1000143#endif /* CONFIG_EEH */
Linas Vepstas6dee3fb2005-11-03 18:50:10 -0600144
Stephen Rothwellbed59272007-03-04 17:04:44 +1100145#else /* CONFIG_PCI */
146static inline void find_and_init_phbs(void) { }
147static inline void init_pci_config_tokens(void) { }
148#endif /* !CONFIG_PCI */
149
Arnd Bergmann88ced032005-12-16 22:43:46 +0100150#endif /* __KERNEL__ */
Stephen Rothwelld3878992005-09-28 02:50:25 +1000151#endif /* _ASM_POWERPC_PPC_PCI_H */