[drivers rtl8180] Fix a couple bugs, add a bunch of debugging
authorJoshua Oreman <oremanj@xenon.get-linux.org>
Mon, 8 Jun 2009 06:31:59 +0000 (23:31 -0700)
committerJoshua Oreman <oremanj@xenon.get-linux.org>
Mon, 8 Jun 2009 06:31:59 +0000 (23:31 -0700)
Fixed a few small bugs: no .id_count in rtl8180_driver, EEPROM read/write bits
reversed, netdev->pdev wasn't set properly.

Current state of the card: it gets set up fine, and can even rx small packets
(at least 64 bytes), but anything bigger than 85 bytes (or possibly smaller)
triggers a DMA failure indication.

src/drivers/net/rtl818x/rtl8180.c

index e08ba88..e019d4d 100644 (file)
@@ -75,6 +75,8 @@ static void rtl8180_handle_rx(struct net80211_device *dev)
                             RTL818X_RX_DESC_FLAG_FOF |
                             RTL818X_RX_DESC_FLAG_RX_ERR |
                             RTL818X_RX_DESC_FLAG_CRC32_ERR)) {
+                       DBG2("rtl8180 RX:%d fail: flags %08x\n", priv->rx_idx,
+                            flags);
                        net80211_rx_err(dev, NULL, EIO);
                } else {
                        u32 flags2 = le32_to_cpu(entry->flags2);
@@ -84,6 +86,9 @@ static void rtl8180_handle_rx(struct net80211_device *dev)
                                goto done;
                        }
 
+                       DBG2("rtl8180 RX:%d success: flags %08x %08x\n",
+                            priv->rx_idx, flags, flags2);
+
                        iob_put(iob, flags & 0xFFF);
 
                        net80211_rx(dev, iob, (flags2 >> 8) & 0x7f);
@@ -99,6 +104,9 @@ static void rtl8180_handle_rx(struct net80211_device *dev)
                if (priv->rx_idx == RTL8180_RX_RING_SIZE - 1)
                        entry->flags |= cpu_to_le32(RTL818X_RX_DESC_FLAG_EOR);
 
+               DBG2("rtl8180 RX:%d prepare into %08x flags %08x\n",
+                    priv->rx_idx, entry->rx_buf, entry->flags);
+
                priv->rx_idx = (priv->rx_idx + 1) % RTL8180_RX_RING_SIZE;
        }
 }
@@ -374,7 +382,7 @@ static void rtl8180_free_tx_ring(struct net80211_device *dev)
 {
        struct rtl8180_priv *priv = dev->priv;
        int i;
-       
+
        for (i = 0; i < RTL8180_TX_RING_SIZE; i++) {
                if (priv->tx_buf[i])
                        net80211_tx_complete(dev, priv->tx_buf[i], ECANCELED);
@@ -546,7 +554,7 @@ static int rtl8180_config(struct net80211_device *dev, int changed)
                             rtl818x_rates[hw_rate] != dev->rates[dev->rate];
                     hw_rate++)
                        ;
-               if (hw_rate >= 16)
+               if (hw_rate >= RTL818X_NR_RATES)
                        return -EINVAL;
 
                priv->hw_rate = hw_rate;
@@ -557,8 +565,8 @@ static int rtl8180_config(struct net80211_device *dev, int changed)
 
 static const u8 rtl8180_eeprom_bits[] = {
        [SPI_BIT_SCLK] = RTL818X_EEPROM_CMD_CK,
-       [SPI_BIT_MOSI] = RTL818X_EEPROM_CMD_READ,
-       [SPI_BIT_MISO] = RTL818X_EEPROM_CMD_WRITE,
+       [SPI_BIT_MISO] = RTL818X_EEPROM_CMD_READ,
+       [SPI_BIT_MOSI] = RTL818X_EEPROM_CMD_WRITE,
        [SPI_BIT_SS(0)] = RTL818X_EEPROM_CMD_CS,
 };
 
@@ -646,6 +654,7 @@ static int rtl8180_probe(struct pci_device *pdev,
 
        priv = dev->priv;
        priv->pdev = pdev;
+       dev->netdev->dev = &pdev->dev;
 
        priv->map = (struct rtl818x_csr *)pdev->ioaddr;
        if (!priv->map)
@@ -695,6 +704,8 @@ static int rtl8180_probe(struct pci_device *pdev,
        priv->spibit.bus.mode = SPI_MODE_THREEWIRE;
        init_spi_bit_basher(&priv->spibit);
 
+       DBG2("rtl8180 RX_CONF: %08x\n", rtl818x_ioread32(priv, &priv->map->RX_CONF));
+
        if (rtl818x_ioread32(priv, &priv->map->RX_CONF) & (1 << 6))
                init_at93c66(&priv->eeprom, 16);
        else
@@ -706,6 +717,7 @@ static int rtl8180_probe(struct pci_device *pdev,
        udelay(10);
 
        nvs_read(&priv->eeprom.nvs, 0x06, &eeprom_val, 2);
+       DBG2("rtl8180 eeprom val = %04x\n", eeprom_val);
        eeprom_val &= 0xFF;
 
        priv->rf = NULL;
@@ -802,6 +814,7 @@ static struct pci_device_id rtl8180_nics[] = {
 
 struct pci_driver rtl8180_driver __pci_driver = {
        .ids            = rtl8180_nics,
+       .id_count       = sizeof(rtl8180_nics) / sizeof(rtl8180_nics[0]),
        .probe          = rtl8180_probe,
        .remove         = rtl8180_remove,
 };