Ensure all lines that should be omitted from public includes are marked
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / mips / yeeloong / pci.h
blob199bac048919f9a3c92542f08ac43ce0d632bdb5
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_MACHINE_PCI_H
20 #define GRUB_MACHINE_PCI_H 1
22 #ifndef ASM_FILE
23 #include <grub/types.h>
24 #include <grub/cpu/io.h>
25 #endif
27 #define GRUB_YEELOONG_OHCI_PCIID 0x00351033
28 #define GRUB_YEELOONG_EHCI_PCIID 0x00e01033
29 #define GRUB_YEELOONG_OHCI_GHOST_FUNCTION 4
30 #define GRUB_YEELOONG_EHCI_GHOST_FUNCTION 5
32 #define GRUB_PCI_NUM_BUS 1
33 #define GRUB_PCI_NUM_DEVICES 16
35 #define GRUB_MACHINE_PCI_IO_BASE 0xbfd00000
36 #define GRUB_MACHINE_PCI_CONFSPACE 0xbfe80000
37 #define GRUB_MACHINE_PCI_CONTROLLER_HEADER 0xbfe00000
39 #define GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR 0xbfe00118
41 #ifndef ASM_FILE
42 #define GRUB_MACHINE_PCI_CONF_CTRL_REG (*(volatile grub_uint32_t *) \
43 GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR)
44 #define GRUB_MACHINE_PCI_IO_CTRL_REG (*(volatile grub_uint32_t *) 0xbfe00110)
45 #endif
46 #define GRUB_MACHINE_PCI_WIN_MASK_SIZE 6
47 #define GRUB_MACHINE_PCI_WIN_MASK ((1 << GRUB_MACHINE_PCI_WIN_MASK_SIZE) - 1)
49 /* We have 3 PCI windows. */
50 #define GRUB_MACHINE_PCI_NUM_WIN 3
51 /* Each window is 64MiB. */
52 #define GRUB_MACHINE_PCI_WIN_SHIFT 26
53 #define GRUB_MACHINE_PCI_WIN_OFFSET_MASK ((1 << GRUB_MACHINE_PCI_WIN_SHIFT) - 1)
55 #define GRUB_MACHINE_PCI_WIN_SIZE 0x04000000
56 /* Graphical acceleration takes 1 MiB away. */
57 #define GRUB_MACHINE_PCI_WIN1_SIZE 0x03f00000
59 #define GRUB_MACHINE_PCI_WIN1_ADDR 0xb0000000
60 #define GRUB_MACHINE_PCI_WIN2_ADDR 0xb4000000
61 #define GRUB_MACHINE_PCI_WIN3_ADDR 0xb8000000
63 #ifndef ASM_FILE
64 static inline grub_uint32_t
65 grub_pci_read (grub_pci_address_t addr)
67 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
68 return *(volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONFSPACE
69 | (addr & 0x03ff));
72 static inline grub_uint16_t
73 grub_pci_read_word (grub_pci_address_t addr)
75 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
76 return *(volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONFSPACE
77 | (addr & 0x03ff));
80 static inline grub_uint8_t
81 grub_pci_read_byte (grub_pci_address_t addr)
83 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
84 return *(volatile grub_uint8_t *) (GRUB_MACHINE_PCI_CONFSPACE
85 | (addr & 0x03ff));
88 static inline void
89 grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
91 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
92 *(volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONFSPACE
93 | (addr & 0x03ff)) = data;
96 static inline void
97 grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
99 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
100 *(volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONFSPACE
101 | (addr & 0x03ff)) = data;
104 static inline void
105 grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
107 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
108 *(volatile grub_uint8_t *) (GRUB_MACHINE_PCI_CONFSPACE
109 | (addr & 0x03ff)) = data;
112 volatile void *
113 EXPORT_FUNC (grub_pci_device_map_range) (grub_pci_device_t dev,
114 grub_addr_t base, grub_size_t size);
115 void
116 EXPORT_FUNC (grub_pci_device_unmap_range) (grub_pci_device_t dev,
117 volatile void *mem,
118 grub_size_t size);
119 #endif
121 #endif /* GRUB_MACHINE_PCI_H */