Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:52

0001 /* 
0002  * Acknowledgements:
0003  * Valuable information was obtained from the following drivers
0004  *   netbsd: (C) Allegro Networks Inc; Wasabi Systems Inc.
0005  *   linux:  (C) MontaVista, Software, Inc; Chris Zankel, Mark A. Greer.
0006  *   rtems:  (C) Brookhaven National Laboratory; K. Feng
0007  * but this implementation is original work by the author.
0008  */
0009 
0010 /* 
0011  * Authorship
0012  * ----------
0013  * This software ('beatnik' RTEMS BSP for MVME6100 and MVME5500) was
0014  *     created by Till Straumann <strauman@slac.stanford.edu>, 2005-2007,
0015  *     Stanford Linear Accelerator Center, Stanford University.
0016  * 
0017  * Acknowledgement of sponsorship
0018  * ------------------------------
0019  * The 'beatnik' BSP was produced by
0020  *     the Stanford Linear Accelerator Center, Stanford University,
0021  *     under Contract DE-AC03-76SFO0515 with the Department of Energy.
0022  * 
0023  * Government disclaimer of liability
0024  * ----------------------------------
0025  * Neither the United States nor the United States Department of Energy,
0026  * nor any of their employees, makes any warranty, express or implied, or
0027  * assumes any legal liability or responsibility for the accuracy,
0028  * completeness, or usefulness of any data, apparatus, product, or process
0029  * disclosed, or represents that its use would not infringe privately owned
0030  * rights.
0031  * 
0032  * Stanford disclaimer of liability
0033  * --------------------------------
0034  * Stanford University makes no representations or warranties, express or
0035  * implied, nor assumes any liability for the use of this software.
0036  * 
0037  * Stanford disclaimer of copyright
0038  * --------------------------------
0039  * Stanford University, owner of the copyright, hereby disclaims its
0040  * copyright and all other rights in this software.  Hence, anyone may
0041  * freely use it for any purpose without restriction.  
0042  * 
0043  * Maintenance of notices
0044  * ----------------------
0045  * In the interest of clarity regarding the origin and status of this
0046  * SLAC software, this and all the preceding Stanford University notices
0047  * are to remain affixed to any copy or derivative of this software made
0048  * or distributed by the recipient and are to be affixed to any copy of
0049  * software made or distributed by the recipient that contains a copy or
0050  * derivative of this software.
0051  * 
0052  * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
0053  */ 
0054 
0055 #include <rtems.h>
0056 #include <rtems/bspIo.h>
0057 #include <bsp.h>
0058 #include <bsp/gtreg.h>
0059 #include <bsp/pci.h>
0060 #include <stdint.h>
0061 
0062 #ifndef PCI_VENDOR_ID_MARVELL
0063 #define PCI_VENDOR_ID_MARVELL 0x11ab
0064 #endif
0065 
0066 #ifndef PCI_DEVICE_ID_MARVELL_GT64260
0067 #define PCI_DEVICE_ID_MARVELL_GT64260 0x6430
0068 #endif
0069 
0070 #ifndef PCI_DEVICE_ID_MARVELL_MV64360
0071 #define PCI_DEVICE_ID_MARVELL_MV64360 0x6460
0072 #endif
0073 
0074 #if 0
0075 #define MV64x60_PCI0_CONFIG_ADDR    (BSP_MV64x60_BASE + 0xcf8)
0076 #define MV64x60_PCI0_CONFIG_DATA    (BSP_MV64x60_BASE + 0xcfc)
0077 
0078 /* read from bus/slot/fn 0/0/0 */
0079 static unsigned long
0080 pci_early_config_read(int offset, int width)
0081 {
0082     out_be32((uint32_t*) pci.pci_config_addr,
0083          0x80|(0<<8)|(PCI_DEVFN(0,0)<<16)|((offset&~3)<<24));
0084     switch (width) {
0085         default:
0086         case 1:
0087             return in_8((uint8_t*)pci.pci_config_data + (offset&3));
0088         case 2:
0089             return in_le16((uint16_t*)pci.pci_config_data + (offset&3));
0090         case 4:
0091             return in_le32((uint32_t *)pci.pci_config_data + (offset&3));
0092     }
0093 }
0094 #endif
0095 
0096 DiscoveryVersion
0097 BSP_getDiscoveryVersion(int assertion)
0098 {
0099 static DiscoveryVersion rval = unknown;
0100 
0101     if ( unknown ==rval ) {
0102         unsigned char   dc;
0103         unsigned short  ds;
0104         /* this must work before and after the call to BSP_pciInitialize() --
0105          * since the host bridge is at 0,0,0 it doesn't matter if the hosed
0106          * access methods are installed or not (as a matter of fact this shouldn't
0107          * matter for any device on hose 0)
0108          */
0109 printk("config addr is %p\n", BSP_pci_configuration.pci_config_addr);
0110 printk("config data is %p\n", BSP_pci_configuration.pci_config_data);
0111         pci_read_config_word(0,0,0,PCI_VENDOR_ID, &ds);
0112         if ( PCI_VENDOR_ID_MARVELL != ds ) {
0113             if ( assertion ) {
0114                 printk("Host bridge vendor id: 0x%04x\n",ds);
0115                 rtems_panic("Host bridge vendor @ pci(0,0,0) is not MARVELL");
0116             }
0117             else return unknown;
0118         }
0119         pci_read_config_word(0,0,0,PCI_DEVICE_ID, &ds);
0120         pci_read_config_byte(0,0,0,PCI_REVISION_ID, &dc);
0121         switch (ds) {
0122             case PCI_DEVICE_ID_MARVELL_MV64360:
0123                 rval = MV_64360;
0124             break;
0125 
0126             case PCI_DEVICE_ID_MARVELL_GT64260:
0127                 switch (dc) {
0128                     default:
0129                     break;
0130 
0131                     case 0x10:
0132                     return (rval = GT_64260_A);
0133 
0134                     case 0x20:
0135                     return (rval = GT_64260_B);
0136                 }
0137 
0138             default:
0139                 if ( assertion ) {
0140                     printk("Marvell device id 0x%04x, revision 0x%02x; check %s:%u\n",
0141                             ds, dc,
0142                             __FILE__,__LINE__);
0143                     rtems_panic("Unknown Marvell bridge or revision@ pci(0,0,0) is not MARVELL");
0144                 }
0145             break;
0146         }
0147     }
0148 
0149     return rval;
0150 }