author | Dave Page <dave.page@gleeble.com> |
Thu, 26 Mar 2015 15:16:21 -0400 | |
changeset 2609 | 777d1a8b3a27 |
parent 2589 | 2b9c78543663 |
permissions | -rw-r--r-- |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
Network Driver for Beckhoff CCAT communication controller |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
Copyright (C) 2014 Beckhoff Automation GmbH |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
Author: Patrick Bruenn <p.bruenn@beckhoff.com> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
This program is free software; you can redistribute it and/or modify |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
it under the terms of the GNU General Public License as published by |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
the Free Software Foundation; either version 2 of the License, or |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
(at your option) any later version. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
This program is distributed in the hope that it will be useful, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
GNU General Public License for more details. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
You should have received a copy of the GNU General Public License along |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
with this program; if not, write to the Free Software Foundation, Inc., |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
#include <asm/dma.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
#include <linux/etherdevice.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
#include <linux/module.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
#include <linux/netdevice.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
#include <linux/version.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
#include "module.h" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
#include "netdev.h" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
#include "update.h" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
MODULE_DESCRIPTION(DRV_DESCRIPTION); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
MODULE_AUTHOR("Patrick Bruenn <p.bruenn@beckhoff.com>"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
MODULE_LICENSE("GPL"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
MODULE_VERSION(DRV_VERSION); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
static void ccat_bar_free(struct ccat_bar *bar) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
if (bar->ioaddr) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
const struct ccat_bar tmp = *bar; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
memset(bar, 0, sizeof(*bar)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
iounmap(tmp.ioaddr); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
release_mem_region(tmp.start, tmp.len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
pr_warn("%s(): %p was already done.\n", __FUNCTION__, bar); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
* ccat_bar_init() - Initialize a CCAT pci bar |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
* @bar object which should be initialized |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
* @index 0 and 2 are valid for CCAT, meaning pci bar0 or pci bar2 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
* @pdev the pci device as which the CCAT was recognized before |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
* Reading PCI config space; request and map memory region. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
static int ccat_bar_init(struct ccat_bar *bar, size_t index, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
struct pci_dev *pdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
struct resource *res; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
bar->start = pci_resource_start(pdev, index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
bar->end = pci_resource_end(pdev, index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
bar->len = pci_resource_len(pdev, index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
bar->flags = pci_resource_flags(pdev, index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
if (!(IORESOURCE_MEM & bar->flags)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
pr_info("bar%llu is no mem_region -> abort.\n", (u64) index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
return -EIO; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
res = request_mem_region(bar->start, bar->len, KBUILD_MODNAME); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
if (!res) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
pr_info("allocate mem_region failed.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
return -EIO; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
pr_debug("bar%llu at [%lx,%lx] len=%lu res: %p.\n", (u64) index, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
bar->start, bar->end, bar->len, res); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
bar->ioaddr = ioremap(bar->start, bar->len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
if (!bar->ioaddr) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
pr_info("bar%llu ioremap failed.\n", (u64) index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
release_mem_region(bar->start, bar->len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
return -EIO; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
pr_debug("bar%llu I/O mem mapped to %p.\n", (u64) index, bar->ioaddr); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
void ccat_dma_free(struct ccat_dma *const dma) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
const struct ccat_dma tmp = *dma; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
free_dma(dma->channel); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
memset(dma, 0, sizeof(*dma)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
dma_free_coherent(tmp.dev, tmp.size, tmp.virt, tmp.phys); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
* ccat_dma_init() - Initialize CCAT and host memory for DMA transfer |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
* @dma object for management data which will be initialized |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
* @channel number of the DMA channel |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
* @ioaddr of the pci bar2 configspace used to calculate the address of the pci dma configuration |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
* @dev which should be configured for DMA |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
int ccat_dma_init(struct ccat_dma *const dma, size_t channel, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
void __iomem * const ioaddr, struct device *const dev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
void *frame; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
u64 addr; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
u32 translateAddr; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
u32 memTranslate; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
u32 memSize; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
u32 data = 0xffffffff; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
u32 offset = (sizeof(u64) * channel) + 0x1000; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
dma->channel = channel; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
dma->dev = dev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
/* calculate size and alignments */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
iowrite32(data, ioaddr + offset); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
wmb(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
data = ioread32(ioaddr + offset); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
memTranslate = data & 0xfffffffc; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
memSize = (~memTranslate) + 1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
dma->size = 2 * memSize - PAGE_SIZE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
dma->virt = dma_zalloc_coherent(dev, dma->size, &dma->phys, GFP_KERNEL); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
if (!dma->virt || !dma->phys) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
pr_info("init DMA%llu memory failed.\n", (u64) channel); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
if (request_dma(channel, KBUILD_MODNAME)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
pr_info("request dma channel %llu failed\n", (u64) channel); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
ccat_dma_free(dma); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
translateAddr = (dma->phys + memSize - PAGE_SIZE) & memTranslate; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
addr = translateAddr; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
memcpy_toio(ioaddr + offset, &addr, sizeof(addr)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
frame = dma->virt + translateAddr - dma->phys; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
pr_debug |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
("DMA%llu mem initialized\n virt: 0x%p\n phys: 0x%llx\n translated: 0x%llx\n pci addr: 0x%08x%x\n memTranslate: 0x%x\n size: %llu bytes.\n", |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
(u64) channel, dma->virt, (u64) (dma->phys), addr, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
ioread32(ioaddr + offset + 4), ioread32(ioaddr + offset), |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
memTranslate, (u64) dma->size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
* Initialize all available CCAT functions. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
* Return: count of failed functions |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
static int ccat_functions_init(struct ccat_device *const ccatdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
static const size_t block_size = sizeof(struct ccat_info_block); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
void __iomem *addr = ccatdev->bar[0].ioaddr; /** first block is the CCAT information block entry */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
const u8 num_func = ioread8(addr + 4); /** number of CCAT function blocks is at offset 0x4 */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
const void __iomem *end = addr + (block_size * num_func); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
int status = 0; /** count init function failures */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
while (addr < end) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
const u8 type = ioread16(addr); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
switch (type) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
case CCATINFO_NOTUSED: |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
break; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
case CCATINFO_EPCS_PROM: |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
pr_info("Found: CCAT update(EPCS_PROM) -> init()\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
ccatdev->update = ccat_update_init(ccatdev, addr); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
status += (NULL == ccatdev->update); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
break; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
case CCATINFO_ETHERCAT_MASTER_DMA: |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
pr_info("Found: ETHERCAT_MASTER_DMA -> init()\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
ccatdev->ethdev = ccat_eth_init(ccatdev, addr); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
status += (NULL == ccatdev->ethdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
break; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
default: |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
pr_info("Found: 0x%04x not supported\n", type); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
break; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
addr += block_size; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
return status; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
* Destroy all previously initialized CCAT functions |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
static void ccat_functions_remove(struct ccat_device *const ccatdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
if (!ccatdev->ethdev) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
pr_warn("%s(): 'ethdev' was not initialized.\n", __FUNCTION__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
struct ccat_eth_priv *const ethdev = ccatdev->ethdev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
ccatdev->ethdev = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
ccat_eth_remove(ethdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
if (!ccatdev->update) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
pr_warn("%s(): 'update' was not initialized.\n", __FUNCTION__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
struct ccat_update *const update = ccatdev->update; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
ccatdev->update = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
ccat_update_remove(update); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
static int ccat_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
int status; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
u8 revision; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
struct ccat_device *ccatdev = kmalloc(sizeof(*ccatdev), GFP_KERNEL); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
if (!ccatdev) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
pr_err("%s() out of memory.\n", __FUNCTION__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
return -ENOMEM; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
memset(ccatdev, 0, sizeof(*ccatdev)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
ccatdev->pdev = pdev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
pci_set_drvdata(pdev, ccatdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
status = pci_enable_device_mem(pdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
if (status) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
pr_info("enable %s failed: %d\n", pdev->dev.kobj.name, status); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
return status; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
status = pci_read_config_byte(pdev, PCI_REVISION_ID, &revision); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
if (status) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
pr_warn("read CCAT pci revision failed with %d\n", status); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
return status; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
pr_debug("64 bit DMA supported, pci rev: %u\n", revision); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
} else if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
pr_debug("32 bit DMA supported, pci rev: %u\n", revision); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
pr_warn("No suitable DMA available, pci rev: %u\n", revision); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
#else |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
pr_debug("64 bit DMA supported, pci rev: %u\n", revision); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
} else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
pr_debug("32 bit DMA supported, pci rev: %u\n", revision); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
pr_warn("No suitable DMA available, pci rev: %u\n", revision); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
if (ccat_bar_init(&ccatdev->bar[0], 0, pdev)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
pr_warn("initialization of bar0 failed.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
return -EIO; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
if (ccat_bar_init(&ccatdev->bar[2], 2, pdev)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
pr_warn("initialization of bar2 failed.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
return -EIO; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
pci_set_master(pdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
if (ccat_functions_init(ccatdev)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
pr_warn("some functions couldn't be initialized\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
static void ccat_remove(struct pci_dev *pdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
struct ccat_device *ccatdev = pci_get_drvdata(pdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
if (ccatdev) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
ccat_functions_remove(ccatdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
ccat_bar_free(&ccatdev->bar[2]); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
ccat_bar_free(&ccatdev->bar[0]); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
pci_disable_device(pdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
pci_set_drvdata(pdev, NULL); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
kfree(ccatdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
pr_debug("%s() done.\n", __FUNCTION__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
#define PCI_DEVICE_ID_BECKHOFF_CCAT 0x5000 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
#define PCI_VENDOR_ID_BECKHOFF 0x15EC |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
static const struct pci_device_id pci_ids[] = { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
{PCI_DEVICE(PCI_VENDOR_ID_BECKHOFF, PCI_DEVICE_ID_BECKHOFF_CCAT)}, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
{0,}, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
}; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
289 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
#if 0 /* prevent auto-loading */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
MODULE_DEVICE_TABLE(pci, pci_ids); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
static struct pci_driver pci_driver = { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
.name = KBUILD_MODNAME, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
.id_table = pci_ids, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
297 |
.probe = ccat_probe, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
.remove = ccat_remove, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
299 |
}; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
301 |
static void __exit ccat_exit_module(void) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
302 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
pci_unregister_driver(&pci_driver); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
304 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
305 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
static int __init ccat_init_module(void) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
308 |
pr_info("%s, %s\n", DRV_DESCRIPTION, DRV_VERSION); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
309 |
return pci_register_driver(&pci_driver); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
310 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
311 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
312 |
module_exit(ccat_exit_module); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
313 |
module_init(ccat_init_module); |