Skip to content

Commit 5ef216c

Browse files
committed
arcnet: com20020-pci: add rotary index support
The EAE PLX-PCI card has a special rotary encoder to configure the address of every card individually. We take this information for the initial setup of the cards dev_id. Signed-off-by: Michael Grzeschik <[email protected]>
1 parent ae8ede6 commit 5ef216c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

drivers/net/arcnet/com20020-pci.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
6868
const struct pci_device_id *id)
6969
{
7070
struct com20020_pci_card_info *ci;
71+
struct com20020_pci_channel_map *mm;
7172
struct net_device *dev;
7273
struct arcnet_local *lp;
7374
struct com20020_priv *priv;
@@ -84,9 +85,22 @@ static int com20020pci_probe(struct pci_dev *pdev,
8485

8586
ci = (struct com20020_pci_card_info *)id->driver_data;
8687
priv->ci = ci;
88+
mm = &ci->misc_map;
8789

8890
INIT_LIST_HEAD(&priv->list_dev);
8991

92+
if (mm->size) {
93+
ioaddr = pci_resource_start(pdev, mm->bar) + mm->offset;
94+
r = devm_request_region(&pdev->dev, ioaddr, mm->size,
95+
"com20020-pci");
96+
if (!r) {
97+
pr_err("IO region %xh-%xh already allocated.\n",
98+
ioaddr, ioaddr + mm->size - 1);
99+
return -EBUSY;
100+
}
101+
priv->misc = ioaddr;
102+
}
103+
90104
for (i = 0; i < ci->devcount; i++) {
91105
struct com20020_pci_channel_map *cm = &ci->chan_map_tbl[i];
92106
struct com20020_dev *card;
@@ -132,6 +146,13 @@ static int com20020pci_probe(struct pci_dev *pdev,
132146
lp->timeout = timeout;
133147
lp->hw.owner = THIS_MODULE;
134148

149+
/* Get the dev_id from the PLX rotary coder */
150+
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
151+
dev->dev_id = 0xc;
152+
dev->dev_id ^= inb(priv->misc + ci->rotary) >> 4;
153+
154+
snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, i);
155+
135156
if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
136157
pr_err("IO address %Xh is empty!\n", ioaddr);
137158
ret = -EIO;
@@ -235,6 +256,12 @@ static struct com20020_pci_card_info card_info_eae_arc1 = {
235256
.size = 0x08,
236257
},
237258
},
259+
.misc_map = {
260+
.bar = 2,
261+
.offset = 0x10,
262+
.size = 0x04,
263+
},
264+
.rotary = 0x0,
238265
.flags = ARC_CAN_10MBIT,
239266
};
240267

@@ -252,6 +279,12 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
252279
.size = 0x08,
253280
}
254281
},
282+
.misc_map = {
283+
.bar = 2,
284+
.offset = 0x10,
285+
.size = 0x04,
286+
},
287+
.rotary = 0x0,
255288
.flags = ARC_CAN_10MBIT,
256289
};
257290

drivers/net/arcnet/com20020.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ struct com20020_pci_card_info {
4747
int devcount;
4848

4949
struct com20020_pci_channel_map chan_map_tbl[PLX_PCI_MAX_CARDS];
50+
struct com20020_pci_channel_map misc_map;
51+
52+
int rotary;
5053

5154
unsigned int flags;
5255
};
5356

5457
struct com20020_priv {
5558
struct com20020_pci_card_info *ci;
5659
struct list_head list_dev;
60+
resource_size_t misc;
5761
};
5862

5963
struct com20020_dev {

0 commit comments

Comments
 (0)