#ifndef LINUX_SSB_DRIVER_GIGE_H_
#define LINUX_SSB_DRIVER_GIGE_H_
#include <linux/ssb/ssb.h>
#include <linux/bug.h>
#include <linux/pci.h>
#include <linux/spinlock.h>
#ifdef CONFIG_SSB_DRIVER_GIGE
#define SSB_GIGE_PCIIO …
#define SSB_GIGE_RESERVED …
#define SSB_GIGE_PCICFG …
#define SSB_GIGE_SHIM_FLUSHSTAT …
#define SSB_GIGE_SHIM_FLUSHRDA …
#define SSB_GIGE_SHIM_FLUSHTO …
#define SSB_GIGE_SHIM_BARRIER …
#define SSB_GIGE_SHIM_MAOCPSI …
#define SSB_GIGE_SHIM_SIOCPMA …
#define SSB_GIGE_TMSHIGH_RGMII …
#define SSB_GIGE_TMSLOW_TXBYPASS …
#define SSB_GIGE_TMSLOW_RXBYPASS …
#define SSB_GIGE_TMSLOW_DLLEN …
#define SSB_GIGE_BFL_ROBOSWITCH …
#define SSB_GIGE_MEM_RES_NAME …
#define SSB_GIGE_IO_RES_NAME …
struct ssb_gige {
struct ssb_device *dev;
spinlock_t lock;
bool has_rgmii;
struct pci_controller pci_controller;
struct pci_ops pci_ops;
struct resource mem_resource;
struct resource io_resource;
};
extern bool pdev_is_ssb_gige_core(struct pci_dev *pdev);
static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
{
if (!pdev_is_ssb_gige_core(pdev))
return NULL;
return container_of(pdev->bus->ops, struct ssb_gige, pci_ops);
}
static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
{
struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
return (dev ? dev->has_rgmii : 0);
}
static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
{
struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
if (dev)
return !!(dev->dev->bus->sprom.boardflags_lo &
SSB_GIGE_BFL_ROBOSWITCH);
return false;
}
static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
{
struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
if (dev)
return ((dev->dev->bus->chip_id == 0x4785) &&
(dev->dev->bus->chip_rev < 2));
return false;
}
static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
{
struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
if (dev)
return (dev->dev->bus->chip_id == 0x4785);
return false;
}
static inline int ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
{
struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
if (!dev)
return -ENODEV;
memcpy(macaddr, dev->dev->bus->sprom.et0mac, 6);
return 0;
}
static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev)
{
struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
if (!dev)
return -ENODEV;
return dev->dev->bus->sprom.et0phyaddr;
}
extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
struct pci_dev *pdev);
extern int ssb_gige_map_irq(struct ssb_device *sdev,
const struct pci_dev *pdev);
extern int ssb_gige_init(void);
static inline void ssb_gige_exit(void)
{
BUG();
}
#else
static inline int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
struct pci_dev *pdev)
{ … }
static inline int ssb_gige_map_irq(struct ssb_device *sdev,
const struct pci_dev *pdev)
{ … }
static inline int ssb_gige_init(void)
{ … }
static inline void ssb_gige_exit(void)
{ … }
static inline bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
{ … }
static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
{ … }
static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
{ … }
static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
{ … }
static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
{ … }
static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
{ … }
static inline int ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
{ … }
static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev)
{ … }
#endif
#endif