diff options
Diffstat (limited to 'drivers/net/can/sja1000/ems_pci.c')
-rw-r--r-- | drivers/net/can/sja1000/ems_pci.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c index 3cd2ff9165e3..121b64101d72 100644 --- a/drivers/net/can/sja1000/ems_pci.c +++ b/drivers/net/can/sja1000/ems_pci.c | |||
@@ -99,25 +99,21 @@ MODULE_DEVICE_TABLE(pci, ems_pci_tbl); | |||
99 | */ | 99 | */ |
100 | static u8 ems_pci_readb(struct ems_pci_card *card, unsigned int port) | 100 | static u8 ems_pci_readb(struct ems_pci_card *card, unsigned int port) |
101 | { | 101 | { |
102 | return readb((void __iomem *)card->base_addr | 102 | return readb(card->base_addr + (port * EMS_PCI_PORT_BYTES)); |
103 | + (port * EMS_PCI_PORT_BYTES)); | ||
104 | } | 103 | } |
105 | 104 | ||
106 | static u8 ems_pci_read_reg(const struct net_device *dev, int port) | 105 | static u8 ems_pci_read_reg(const struct sja1000_priv *priv, int port) |
107 | { | 106 | { |
108 | return readb((void __iomem *)dev->base_addr | 107 | return readb(priv->reg_base + (port * EMS_PCI_PORT_BYTES)); |
109 | + (port * EMS_PCI_PORT_BYTES)); | ||
110 | } | 108 | } |
111 | 109 | ||
112 | static void ems_pci_write_reg(const struct net_device *dev, int port, u8 val) | 110 | static void ems_pci_write_reg(const struct sja1000_priv *priv, int port, u8 val) |
113 | { | 111 | { |
114 | writeb(val, (void __iomem *)dev->base_addr | 112 | writeb(val, priv->reg_base + (port * EMS_PCI_PORT_BYTES)); |
115 | + (port * EMS_PCI_PORT_BYTES)); | ||
116 | } | 113 | } |
117 | 114 | ||
118 | static void ems_pci_post_irq(const struct net_device *dev) | 115 | static void ems_pci_post_irq(const struct sja1000_priv *priv) |
119 | { | 116 | { |
120 | struct sja1000_priv *priv = netdev_priv(dev); | ||
121 | struct ems_pci_card *card = (struct ems_pci_card *)priv->priv; | 117 | struct ems_pci_card *card = (struct ems_pci_card *)priv->priv; |
122 | 118 | ||
123 | /* reset int flag of pita */ | 119 | /* reset int flag of pita */ |
@@ -129,17 +125,17 @@ static void ems_pci_post_irq(const struct net_device *dev) | |||
129 | * Check if a CAN controller is present at the specified location | 125 | * Check if a CAN controller is present at the specified location |
130 | * by trying to set 'em into the PeliCAN mode | 126 | * by trying to set 'em into the PeliCAN mode |
131 | */ | 127 | */ |
132 | static inline int ems_pci_check_chan(struct net_device *dev) | 128 | static inline int ems_pci_check_chan(const struct sja1000_priv *priv) |
133 | { | 129 | { |
134 | unsigned char res; | 130 | unsigned char res; |
135 | 131 | ||
136 | /* Make sure SJA1000 is in reset mode */ | 132 | /* Make sure SJA1000 is in reset mode */ |
137 | ems_pci_write_reg(dev, REG_MOD, 1); | 133 | ems_pci_write_reg(priv, REG_MOD, 1); |
138 | 134 | ||
139 | ems_pci_write_reg(dev, REG_CDR, CDR_PELICAN); | 135 | ems_pci_write_reg(priv, REG_CDR, CDR_PELICAN); |
140 | 136 | ||
141 | /* read reset-values */ | 137 | /* read reset-values */ |
142 | res = ems_pci_read_reg(dev, REG_CDR); | 138 | res = ems_pci_read_reg(priv, REG_CDR); |
143 | 139 | ||
144 | if (res == CDR_PELICAN) | 140 | if (res == CDR_PELICAN) |
145 | return 1; | 141 | return 1; |
@@ -218,14 +214,12 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev, | |||
218 | card->conf_addr = pci_iomap(pdev, 0, EMS_PCI_MEM_SIZE); | 214 | card->conf_addr = pci_iomap(pdev, 0, EMS_PCI_MEM_SIZE); |
219 | if (card->conf_addr == NULL) { | 215 | if (card->conf_addr == NULL) { |
220 | err = -ENOMEM; | 216 | err = -ENOMEM; |
221 | |||
222 | goto failure_cleanup; | 217 | goto failure_cleanup; |
223 | } | 218 | } |
224 | 219 | ||
225 | card->base_addr = pci_iomap(pdev, 1, EMS_PCI_MEM_SIZE); | 220 | card->base_addr = pci_iomap(pdev, 1, EMS_PCI_MEM_SIZE); |
226 | if (card->base_addr == NULL) { | 221 | if (card->base_addr == NULL) { |
227 | err = -ENOMEM; | 222 | err = -ENOMEM; |
228 | |||
229 | goto failure_cleanup; | 223 | goto failure_cleanup; |
230 | } | 224 | } |
231 | 225 | ||
@@ -239,7 +233,6 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev, | |||
239 | ems_pci_readb(card, 3) != 0xCB || | 233 | ems_pci_readb(card, 3) != 0xCB || |
240 | ems_pci_readb(card, 4) != 0x11) { | 234 | ems_pci_readb(card, 4) != 0x11) { |
241 | dev_err(&pdev->dev, "Not EMS Dr. Thomas Wuensche interface\n"); | 235 | dev_err(&pdev->dev, "Not EMS Dr. Thomas Wuensche interface\n"); |
242 | |||
243 | err = -ENODEV; | 236 | err = -ENODEV; |
244 | goto failure_cleanup; | 237 | goto failure_cleanup; |
245 | } | 238 | } |
@@ -260,12 +253,11 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev, | |||
260 | priv->irq_flags = IRQF_SHARED; | 253 | priv->irq_flags = IRQF_SHARED; |
261 | 254 | ||
262 | dev->irq = pdev->irq; | 255 | dev->irq = pdev->irq; |
263 | dev->base_addr = (unsigned long)(card->base_addr | 256 | priv->reg_base = card->base_addr + EMS_PCI_CAN_BASE_OFFSET |
264 | + EMS_PCI_CAN_BASE_OFFSET | 257 | + (i * EMS_PCI_CAN_CTRL_SIZE); |
265 | + (i * EMS_PCI_CAN_CTRL_SIZE)); | ||
266 | 258 | ||
267 | /* Check if channel is present */ | 259 | /* Check if channel is present */ |
268 | if (ems_pci_check_chan(dev)) { | 260 | if (ems_pci_check_chan(priv)) { |
269 | priv->read_reg = ems_pci_read_reg; | 261 | priv->read_reg = ems_pci_read_reg; |
270 | priv->write_reg = ems_pci_write_reg; | 262 | priv->write_reg = ems_pci_write_reg; |
271 | priv->post_irq = ems_pci_post_irq; | 263 | priv->post_irq = ems_pci_post_irq; |
@@ -289,9 +281,8 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev, | |||
289 | 281 | ||
290 | card->channels++; | 282 | card->channels++; |
291 | 283 | ||
292 | dev_info(&pdev->dev, "Channel #%d at %#lX, irq %d\n", | 284 | dev_info(&pdev->dev, "Channel #%d at 0x%p, irq %d\n", |
293 | i + 1, dev->base_addr, | 285 | i + 1, priv->reg_base, dev->irq); |
294 | dev->irq); | ||
295 | } else { | 286 | } else { |
296 | free_sja1000dev(dev); | 287 | free_sja1000dev(dev); |
297 | } | 288 | } |