0001
0002 #ifndef LINUX_SSB_DRIVER_GIGE_H_
0003 #define LINUX_SSB_DRIVER_GIGE_H_
0004
0005 #include <linux/ssb/ssb.h>
0006 #include <linux/bug.h>
0007 #include <linux/pci.h>
0008 #include <linux/spinlock.h>
0009
0010
0011 #ifdef CONFIG_SSB_DRIVER_GIGE
0012
0013
0014 #define SSB_GIGE_PCIIO 0x0000
0015 #define SSB_GIGE_RESERVED 0x0400
0016 #define SSB_GIGE_PCICFG 0x0800
0017 #define SSB_GIGE_SHIM_FLUSHSTAT 0x0C00
0018 #define SSB_GIGE_SHIM_FLUSHRDA 0x0C04
0019 #define SSB_GIGE_SHIM_FLUSHTO 0x0C08
0020 #define SSB_GIGE_SHIM_BARRIER 0x0C0C
0021 #define SSB_GIGE_SHIM_MAOCPSI 0x0C10
0022 #define SSB_GIGE_SHIM_SIOCPMA 0x0C14
0023
0024
0025 #define SSB_GIGE_TMSHIGH_RGMII 0x00010000
0026
0027 #define SSB_GIGE_TMSLOW_TXBYPASS 0x00080000
0028 #define SSB_GIGE_TMSLOW_RXBYPASS 0x00100000
0029 #define SSB_GIGE_TMSLOW_DLLEN 0x01000000
0030
0031
0032 #define SSB_GIGE_BFL_ROBOSWITCH 0x0010
0033
0034
0035 #define SSB_GIGE_MEM_RES_NAME "SSB Broadcom 47xx GigE memory"
0036 #define SSB_GIGE_IO_RES_NAME "SSB Broadcom 47xx GigE I/O"
0037
0038 struct ssb_gige {
0039 struct ssb_device *dev;
0040
0041 spinlock_t lock;
0042
0043
0044
0045 bool has_rgmii;
0046
0047
0048 struct pci_controller pci_controller;
0049 struct pci_ops pci_ops;
0050 struct resource mem_resource;
0051 struct resource io_resource;
0052 };
0053
0054
0055 extern bool pdev_is_ssb_gige_core(struct pci_dev *pdev);
0056
0057
0058 static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
0059 {
0060 if (!pdev_is_ssb_gige_core(pdev))
0061 return NULL;
0062 return container_of(pdev->bus->ops, struct ssb_gige, pci_ops);
0063 }
0064
0065
0066 static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
0067 {
0068 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
0069 return (dev ? dev->has_rgmii : 0);
0070 }
0071
0072
0073 static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
0074 {
0075 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
0076 if (dev)
0077 return !!(dev->dev->bus->sprom.boardflags_lo &
0078 SSB_GIGE_BFL_ROBOSWITCH);
0079 return false;
0080 }
0081
0082
0083 static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
0084 {
0085 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
0086 if (dev)
0087 return ((dev->dev->bus->chip_id == 0x4785) &&
0088 (dev->dev->bus->chip_rev < 2));
0089 return false;
0090 }
0091
0092
0093 static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
0094 {
0095 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
0096 if (dev)
0097 return (dev->dev->bus->chip_id == 0x4785);
0098 return false;
0099 }
0100
0101
0102 static inline int ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
0103 {
0104 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
0105 if (!dev)
0106 return -ENODEV;
0107
0108 memcpy(macaddr, dev->dev->bus->sprom.et0mac, 6);
0109 return 0;
0110 }
0111
0112
0113 static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev)
0114 {
0115 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
0116 if (!dev)
0117 return -ENODEV;
0118
0119 return dev->dev->bus->sprom.et0phyaddr;
0120 }
0121
0122 extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
0123 struct pci_dev *pdev);
0124 extern int ssb_gige_map_irq(struct ssb_device *sdev,
0125 const struct pci_dev *pdev);
0126
0127
0128
0129 extern int ssb_gige_init(void);
0130 static inline void ssb_gige_exit(void)
0131 {
0132
0133
0134 BUG();
0135 }
0136
0137
0138 #else
0139
0140
0141
0142 static inline int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
0143 struct pci_dev *pdev)
0144 {
0145 return -ENOSYS;
0146 }
0147 static inline int ssb_gige_map_irq(struct ssb_device *sdev,
0148 const struct pci_dev *pdev)
0149 {
0150 return -ENOSYS;
0151 }
0152 static inline int ssb_gige_init(void)
0153 {
0154 return 0;
0155 }
0156 static inline void ssb_gige_exit(void)
0157 {
0158 }
0159
0160 static inline bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
0161 {
0162 return false;
0163 }
0164 static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
0165 {
0166 return NULL;
0167 }
0168 static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
0169 {
0170 return false;
0171 }
0172 static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
0173 {
0174 return false;
0175 }
0176 static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
0177 {
0178 return false;
0179 }
0180 static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
0181 {
0182 return false;
0183 }
0184 static inline int ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
0185 {
0186 return -ENODEV;
0187 }
0188 static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev)
0189 {
0190 return -ENODEV;
0191 }
0192
0193 #endif
0194 #endif