//#define DEBUG_RX
//#define DEBUG_RX_SKB
-//#define CONFIG_RTL8180_IO_MAP
#include <linux/syscalls.h>
//#include <linux/fcntl.h>
//#include <asm/uaccess.h>
#include "ieee80211/dot11d.h"
-//#define CONFIG_RTL8180_IO_MAP
-
#ifndef PCI_VENDOR_ID_BELKIN
#define PCI_VENDOR_ID_BELKIN 0x1799
#endif
-#ifdef CONFIG_RTL8180_IO_MAP
-
-u8 read_nic_byte(struct net_device *dev, int x)
-{
- return 0xff&inb(dev->base_addr +x);
-}
-
-u32 read_nic_dword(struct net_device *dev, int x)
-{
- return inl(dev->base_addr +x);
-}
-
-u16 read_nic_word(struct net_device *dev, int x)
-{
- return inw(dev->base_addr +x);
-}
-
-void write_nic_byte(struct net_device *dev, int x,u8 y)
-{
- outb(y&0xff,dev->base_addr +x);
-}
-
-void write_nic_word(struct net_device *dev, int x,u16 y)
-{
- outw(y,dev->base_addr +x);
-}
-
-void write_nic_dword(struct net_device *dev, int x,u32 y)
-{
- outl(y,dev->base_addr +x);
-}
-
-#else /* RTL_IO_MAP */
u8 read_nic_byte(struct net_device *dev, int x)
{
udelay(20);
}
-#endif /* RTL_IO_MAP */
inline void force_pci_posting(struct net_device *dev)
{
read_nic_byte(dev,EPROM_CMD);
-#ifndef CONFIG_RTL8180_IO_MAP
mb();
-#endif
}
//u8 *ptr;
u8 unit = 0;
-#ifdef CONFIG_RTL8180_IO_MAP
- unsigned long pio_start, pio_len, pio_flags;
-#else
unsigned long pmem_start, pmem_len, pmem_flags;
-#endif //end #ifdef RTL_IO_MAP
DMESG("Configuring chip resources");
priv->pdev=pdev;
-#ifdef CONFIG_RTL8180_IO_MAP
-
- pio_start = (unsigned long)pci_resource_start (pdev, 0);
- pio_len = (unsigned long)pci_resource_len (pdev, 0);
- pio_flags = (unsigned long)pci_resource_flags (pdev, 0);
-
- if (!(pio_flags & IORESOURCE_IO)) {
- DMESG("region #0 not a PIO resource, aborting");
- goto fail;
- }
-
- //DMESG("IO space @ 0x%08lx", pio_start );
- if( ! request_region( pio_start, pio_len, RTL8180_MODULE_NAME ) ){
- DMESG("request_region failed!");
- goto fail;
- }
-
- ioaddr = pio_start;
- dev->base_addr = ioaddr; // device I/O address
-
-#else
pmem_start = pci_resource_start(pdev, 1);
pmem_len = pci_resource_len(pdev, 1);
dev->mem_start = ioaddr; // shared mem start
dev->mem_end = ioaddr + pci_resource_len(pdev, 0); // shared mem end
-#endif //end #ifdef RTL_IO_MAP
//pci_read_config_byte(pdev, 0x05, ptr);
//pci_write_config_byte(pdev, 0x05, (*ptr) & (~0x04));
fail1:
-#ifdef CONFIG_RTL8180_IO_MAP
-
- if( dev->base_addr != 0 ){
-
- release_region(dev->base_addr,
- pci_resource_len(pdev, 0) );
- }
-#else
if( dev->mem_start != (unsigned long)NULL ){
iounmap( (void *)dev->mem_start );
release_mem_region( pci_resource_start(pdev, 1),
pci_resource_len(pdev, 1) );
}
-#endif //end #ifdef RTL_IO_MAP
fail:
free_tx_desc_rings(dev);
// free_beacon_desc_ring(dev,priv->txbeaconcount);
-#ifdef CONFIG_RTL8180_IO_MAP
-
- if( dev->base_addr != 0 ){
-
- release_region(dev->base_addr,
- pci_resource_len(pdev, 0) );
- }
-#else
if( dev->mem_start != (unsigned long)NULL ){
iounmap( (void *)dev->mem_start );
release_mem_region( pci_resource_start(pdev, 1),
pci_resource_len(pdev, 1) );
}
-#endif /*end #ifdef RTL_IO_MAP*/
free_ieee80211(dev);
}
u8 data
)
{
-#ifndef CONFIG_RTL8180_IO_MAP
write_nic_byte(dev, offset, data);
read_nic_byte(dev, offset); // To make sure write operation is completed, 2005.11.09, by rcnjko.
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- write_nic_byte(dev, offset, data);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- write_nic_byte(dev, (offset & 0xff), data);
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIOWrite1Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
}
void
u16 data
)
{
-#ifndef CONFIG_RTL8180_IO_MAP
write_nic_word(dev, offset, data);
read_nic_word(dev, offset); // To make sure write operation is completed, 2005.11.09, by rcnjko.
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- write_nic_word(dev, offset, data);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- write_nic_word(dev, (offset & 0xff), data);
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIOWrite2Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
}
u8 PlatformIORead1Byte(struct net_device *dev, u32 offset);
u32 data
)
{
-#ifndef CONFIG_RTL8180_IO_MAP
//{by amy 080312
if (offset == PhyAddr)
{//For Base Band configuration.
write_nic_dword(dev, offset, data);
read_nic_dword(dev, offset); // To make sure write operation is completed, 2005.11.09, by rcnjko.
}
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- write_nic_word(dev, offset, data);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- write_nic_dword(dev, (offset & 0xff), data);
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIOWrite4Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
}
u8
{
u8 data = 0;
-#ifndef CONFIG_RTL8180_IO_MAP
data = read_nic_byte(dev, offset);
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- data = read_nic_byte(dev, offset);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- data = read_nic_byte(dev, (offset & 0xff));
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIORead1Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
return data;
}
{
u16 data = 0;
-#ifndef CONFIG_RTL8180_IO_MAP
data = read_nic_word(dev, offset);
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- data = read_nic_word(dev, offset);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- data = read_nic_word(dev, (offset & 0xff));
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIORead2Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
return data;
}
{
u32 data = 0;
-#ifndef CONFIG_RTL8180_IO_MAP
data = read_nic_dword(dev, offset);
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- data = read_nic_dword(dev, offset);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- data = read_nic_dword(dev, (offset & 0xff));
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIORead4Byte(): illegal page number: %d, offset: %#X\n", Page, offset);
- break;
- }
-#endif
return data;
}