1 | /* |
---|
2 | * Acknowledgements: |
---|
3 | * Valuable information was obtained from the following drivers |
---|
4 | * netbsd: (C) Allegro Networks Inc; Wasabi Systems Inc. |
---|
5 | * linux: (C) MontaVista, Software, Inc; Chris Zankel, Mark A. Greer. |
---|
6 | * rtems: (C) Brookhaven National Laboratory; K. Feng |
---|
7 | * but this implementation is original work by the author. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * Authorship |
---|
12 | * ---------- |
---|
13 | * This software ('beatnik' RTEMS BSP for MVME6100 and MVME5500) was |
---|
14 | * created by Till Straumann <strauman@slac.stanford.edu>, 2005-2007, |
---|
15 | * Stanford Linear Accelerator Center, Stanford University. |
---|
16 | * |
---|
17 | * Acknowledgement of sponsorship |
---|
18 | * ------------------------------ |
---|
19 | * The 'beatnik' BSP was produced by |
---|
20 | * the Stanford Linear Accelerator Center, Stanford University, |
---|
21 | * under Contract DE-AC03-76SFO0515 with the Department of Energy. |
---|
22 | * |
---|
23 | * Government disclaimer of liability |
---|
24 | * ---------------------------------- |
---|
25 | * Neither the United States nor the United States Department of Energy, |
---|
26 | * nor any of their employees, makes any warranty, express or implied, or |
---|
27 | * assumes any legal liability or responsibility for the accuracy, |
---|
28 | * completeness, or usefulness of any data, apparatus, product, or process |
---|
29 | * disclosed, or represents that its use would not infringe privately owned |
---|
30 | * rights. |
---|
31 | * |
---|
32 | * Stanford disclaimer of liability |
---|
33 | * -------------------------------- |
---|
34 | * Stanford University makes no representations or warranties, express or |
---|
35 | * implied, nor assumes any liability for the use of this software. |
---|
36 | * |
---|
37 | * Stanford disclaimer of copyright |
---|
38 | * -------------------------------- |
---|
39 | * Stanford University, owner of the copyright, hereby disclaims its |
---|
40 | * copyright and all other rights in this software. Hence, anyone may |
---|
41 | * freely use it for any purpose without restriction. |
---|
42 | * |
---|
43 | * Maintenance of notices |
---|
44 | * ---------------------- |
---|
45 | * In the interest of clarity regarding the origin and status of this |
---|
46 | * SLAC software, this and all the preceding Stanford University notices |
---|
47 | * are to remain affixed to any copy or derivative of this software made |
---|
48 | * or distributed by the recipient and are to be affixed to any copy of |
---|
49 | * software made or distributed by the recipient that contains a copy or |
---|
50 | * derivative of this software. |
---|
51 | * |
---|
52 | * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 |
---|
53 | */ |
---|
54 | |
---|
55 | #include <rtems.h> |
---|
56 | #include <rtems/bspIo.h> |
---|
57 | #include <bsp.h> |
---|
58 | #include <bsp/gtreg.h> |
---|
59 | #include <bsp/pci.h> |
---|
60 | #include <stdint.h> |
---|
61 | |
---|
62 | #ifndef PCI_VENDOR_ID_MARVELL |
---|
63 | #define PCI_VENDOR_ID_MARVELL 0x11ab |
---|
64 | #endif |
---|
65 | |
---|
66 | #ifndef PCI_DEVICE_ID_MARVELL_GT64260 |
---|
67 | #define PCI_DEVICE_ID_MARVELL_GT64260 0x6430 |
---|
68 | #endif |
---|
69 | |
---|
70 | #ifndef PCI_DEVICE_ID_MARVELL_MV64360 |
---|
71 | #define PCI_DEVICE_ID_MARVELL_MV64360 0x6460 |
---|
72 | #endif |
---|
73 | |
---|
74 | #if 0 |
---|
75 | #define MV64x60_PCI0_CONFIG_ADDR (BSP_MV64x60_BASE + 0xcf8) |
---|
76 | #define MV64x60_PCI0_CONFIG_DATA (BSP_MV64x60_BASE + 0xcfc) |
---|
77 | |
---|
78 | /* read from bus/slot/fn 0/0/0 */ |
---|
79 | static unsigned long |
---|
80 | pci_early_config_read(int offset, int width) |
---|
81 | { |
---|
82 | out_be32((uint32_t*) pci.pci_config_addr, |
---|
83 | 0x80|(0<<8)|(PCI_DEVFN(0,0)<<16)|((offset&~3)<<24)); |
---|
84 | switch (width) { |
---|
85 | default: |
---|
86 | case 1: |
---|
87 | return in_8((uint8_t*)pci.pci_config_data + (offset&3)); |
---|
88 | case 2: |
---|
89 | return in_le16((uint16_t*)pci.pci_config_data + (offset&3)); |
---|
90 | case 4: |
---|
91 | return in_le32((uint32_t *)pci.pci_config_data + (offset&3)); |
---|
92 | } |
---|
93 | } |
---|
94 | #endif |
---|
95 | |
---|
96 | DiscoveryVersion |
---|
97 | BSP_getDiscoveryVersion(int assertion) |
---|
98 | { |
---|
99 | static DiscoveryVersion rval = unknown; |
---|
100 | |
---|
101 | if ( unknown ==rval ) { |
---|
102 | unsigned char dc; |
---|
103 | unsigned short ds; |
---|
104 | /* this must work before and after the call to BSP_pciInitialize() -- |
---|
105 | * since the host bridge is at 0,0,0 it doesn't matter if the hosed |
---|
106 | * access methods are installed or not (as a matter of fact this shouldn't |
---|
107 | * matter for any device on hose 0) |
---|
108 | */ |
---|
109 | printk("config addr is %p\n", BSP_pci_configuration.pci_config_addr); |
---|
110 | printk("config data is %p\n", BSP_pci_configuration.pci_config_data); |
---|
111 | pci_read_config_word(0,0,0,PCI_VENDOR_ID, &ds); |
---|
112 | if ( PCI_VENDOR_ID_MARVELL != ds ) { |
---|
113 | if ( assertion ) { |
---|
114 | printk("Host bridge vendor id: 0x%04x\n",ds); |
---|
115 | BSP_panic("Host bridge vendor @ pci(0,0,0) is not MARVELL"); |
---|
116 | } |
---|
117 | else return unknown; |
---|
118 | } |
---|
119 | pci_read_config_word(0,0,0,PCI_DEVICE_ID, &ds); |
---|
120 | pci_read_config_byte(0,0,0,PCI_REVISION_ID, &dc); |
---|
121 | switch (ds) { |
---|
122 | case PCI_DEVICE_ID_MARVELL_MV64360: |
---|
123 | rval = MV_64360; |
---|
124 | break; |
---|
125 | |
---|
126 | case PCI_DEVICE_ID_MARVELL_GT64260: |
---|
127 | switch (dc) { |
---|
128 | default: |
---|
129 | break; |
---|
130 | |
---|
131 | case 0x10: |
---|
132 | return (rval = GT_64260_A); |
---|
133 | |
---|
134 | case 0x20: |
---|
135 | return (rval = GT_64260_B); |
---|
136 | } |
---|
137 | |
---|
138 | default: |
---|
139 | if ( assertion ) { |
---|
140 | printk("Marvell device id 0x%04x, revision 0x%02x; check %s:%u\n", |
---|
141 | ds, dc, |
---|
142 | __FILE__,__LINE__); |
---|
143 | BSP_panic("Unknown Marvell bridge or revision@ pci(0,0,0) is not MARVELL"); |
---|
144 | } |
---|
145 | break; |
---|
146 | } |
---|
147 | } |
---|
148 | |
---|
149 | return rval; |
---|
150 | } |
---|