aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firewire/Makefile1
-rw-r--r--drivers/firewire/init_ohci1394_dma.c (renamed from drivers/ieee1394/init_ohci1394_dma.c)76
-rw-r--r--drivers/ieee1394/Makefile2
3 files changed, 51 insertions, 28 deletions
diff --git a/drivers/firewire/Makefile b/drivers/firewire/Makefile
index 3c6a7fb20aa7..e3870d5c43dd 100644
--- a/drivers/firewire/Makefile
+++ b/drivers/firewire/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_FIREWIRE_OHCI) += firewire-ohci.o
13obj-$(CONFIG_FIREWIRE_SBP2) += firewire-sbp2.o 13obj-$(CONFIG_FIREWIRE_SBP2) += firewire-sbp2.o
14obj-$(CONFIG_FIREWIRE_NET) += firewire-net.o 14obj-$(CONFIG_FIREWIRE_NET) += firewire-net.o
15obj-$(CONFIG_FIREWIRE_NOSY) += nosy.o 15obj-$(CONFIG_FIREWIRE_NOSY) += nosy.o
16obj-$(CONFIG_PROVIDE_OHCI1394_DMA_INIT) += init_ohci1394_dma.o
diff --git a/drivers/ieee1394/init_ohci1394_dma.c b/drivers/firewire/init_ohci1394_dma.c
index ddaab6eb8ace..a9a347adb353 100644
--- a/drivers/ieee1394/init_ohci1394_dma.c
+++ b/drivers/firewire/init_ohci1394_dma.c
@@ -32,23 +32,41 @@
32 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 32 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 */ 33 */
34 34
35#include <linux/interrupt.h> /* for ohci1394.h */
36#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/io.h>
37#include <linux/kernel.h>
37#include <linux/pci.h> /* for PCI defines */ 38#include <linux/pci.h> /* for PCI defines */
38#include <linux/init_ohci1394_dma.h> 39#include <linux/string.h>
40
39#include <asm/pci-direct.h> /* for direct PCI config space access */ 41#include <asm/pci-direct.h> /* for direct PCI config space access */
40#include <asm/fixmap.h> 42#include <asm/fixmap.h>
41 43
42#include "ieee1394_types.h" 44#include <linux/init_ohci1394_dma.h>
43#include "ohci1394.h" 45#include "ohci.h"
44 46
45int __initdata init_ohci1394_dma_early; 47int __initdata init_ohci1394_dma_early;
46 48
49struct ohci {
50 void __iomem *registers;
51};
52
53static inline void reg_write(const struct ohci *ohci, int offset, u32 data)
54{
55 writel(data, ohci->registers + offset);
56}
57
58static inline u32 reg_read(const struct ohci *ohci, int offset)
59{
60 return readl(ohci->registers + offset);
61}
62
63#define OHCI_LOOP_COUNT 100 /* Number of loops for reg read waits */
64
47/* Reads a PHY register of an OHCI-1394 controller */ 65/* Reads a PHY register of an OHCI-1394 controller */
48static inline u8 __init get_phy_reg(struct ti_ohci *ohci, u8 addr) 66static inline u8 __init get_phy_reg(struct ohci *ohci, u8 addr)
49{ 67{
50 int i; 68 int i;
51 quadlet_t r; 69 u32 r;
52 70
53 reg_write(ohci, OHCI1394_PhyControl, (addr << 8) | 0x00008000); 71 reg_write(ohci, OHCI1394_PhyControl, (addr << 8) | 0x00008000);
54 72
@@ -63,22 +81,22 @@ static inline u8 __init get_phy_reg(struct ti_ohci *ohci, u8 addr)
63} 81}
64 82
65/* Writes to a PHY register of an OHCI-1394 controller */ 83/* Writes to a PHY register of an OHCI-1394 controller */
66static inline void __init set_phy_reg(struct ti_ohci *ohci, u8 addr, u8 data) 84static inline void __init set_phy_reg(struct ohci *ohci, u8 addr, u8 data)
67{ 85{
68 int i; 86 int i;
69 87
70 reg_write(ohci, OHCI1394_PhyControl, (addr << 8) | data | 0x00004000); 88 reg_write(ohci, OHCI1394_PhyControl, (addr << 8) | data | 0x00004000);
71 89
72 for (i = 0; i < OHCI_LOOP_COUNT; i++) { 90 for (i = 0; i < OHCI_LOOP_COUNT; i++) {
73 u32 r = reg_read(ohci, OHCI1394_PhyControl); 91 if (!(reg_read(ohci, OHCI1394_PhyControl) & 0x00004000))
74 if (!(r & 0x00004000))
75 break; 92 break;
76 mdelay(1); 93 mdelay(1);
77 } 94 }
78} 95}
79 96
80/* Resets an OHCI-1394 controller (for sane state before initialization) */ 97/* Resets an OHCI-1394 controller (for sane state before initialization) */
81static inline void __init init_ohci1394_soft_reset(struct ti_ohci *ohci) { 98static inline void __init init_ohci1394_soft_reset(struct ohci *ohci)
99{
82 int i; 100 int i;
83 101
84 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset); 102 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset);
@@ -91,10 +109,14 @@ static inline void __init init_ohci1394_soft_reset(struct ti_ohci *ohci) {
91 } 109 }
92} 110}
93 111
112#define OHCI1394_MAX_AT_REQ_RETRIES 0xf
113#define OHCI1394_MAX_AT_RESP_RETRIES 0x2
114#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8
115
94/* Basic OHCI-1394 register and port inititalization */ 116/* Basic OHCI-1394 register and port inititalization */
95static inline void __init init_ohci1394_initialize(struct ti_ohci *ohci) 117static inline void __init init_ohci1394_initialize(struct ohci *ohci)
96{ 118{
97 quadlet_t bus_options; 119 u32 bus_options;
98 int num_ports, i; 120 int num_ports, i;
99 121
100 /* Put some defaults to these undefined bus options */ 122 /* Put some defaults to these undefined bus options */
@@ -116,7 +138,7 @@ static inline void __init init_ohci1394_initialize(struct ti_ohci *ohci)
116 138
117 /* enable phys */ 139 /* enable phys */
118 reg_write(ohci, OHCI1394_LinkControlSet, 140 reg_write(ohci, OHCI1394_LinkControlSet,
119 OHCI1394_LinkControl_RcvPhyPkt); 141 OHCI1394_LinkControl_rcvPhyPkt);
120 142
121 /* Don't accept phy packets into AR request context */ 143 /* Don't accept phy packets into AR request context */
122 reg_write(ohci, OHCI1394_LinkControlClear, 0x00000400); 144 reg_write(ohci, OHCI1394_LinkControlClear, 0x00000400);
@@ -128,7 +150,7 @@ static inline void __init init_ohci1394_initialize(struct ti_ohci *ohci)
128 reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 0xffffffff); 150 reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 0xffffffff);
129 151
130 /* Accept asyncronous transfer requests from all nodes for now */ 152 /* Accept asyncronous transfer requests from all nodes for now */
131 reg_write(ohci,OHCI1394_AsReqFilterHiSet, 0x80000000); 153 reg_write(ohci, OHCI1394_AsReqFilterHiSet, 0x80000000);
132 154
133 /* Specify asyncronous transfer retries */ 155 /* Specify asyncronous transfer retries */
134 reg_write(ohci, OHCI1394_ATRetries, 156 reg_write(ohci, OHCI1394_ATRetries,
@@ -137,7 +159,8 @@ static inline void __init init_ohci1394_initialize(struct ti_ohci *ohci)
137 (OHCI1394_MAX_PHYS_RESP_RETRIES<<8)); 159 (OHCI1394_MAX_PHYS_RESP_RETRIES<<8));
138 160
139 /* We don't want hardware swapping */ 161 /* We don't want hardware swapping */
140 reg_write(ohci, OHCI1394_HCControlClear, OHCI1394_HCControl_noByteSwap); 162 reg_write(ohci, OHCI1394_HCControlClear,
163 OHCI1394_HCControl_noByteSwapData);
141 164
142 /* Enable link */ 165 /* Enable link */
143 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_linkEnable); 166 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_linkEnable);
@@ -164,11 +187,11 @@ static inline void __init init_ohci1394_initialize(struct ti_ohci *ohci)
164 * has to be enabled after each bus reset when needed. We resort 187 * has to be enabled after each bus reset when needed. We resort
165 * to polling here because on early boot, we have no interrupts. 188 * to polling here because on early boot, we have no interrupts.
166 */ 189 */
167static inline void __init init_ohci1394_wait_for_busresets(struct ti_ohci *ohci) 190static inline void __init init_ohci1394_wait_for_busresets(struct ohci *ohci)
168{ 191{
169 int i, events; 192 int i, events;
170 193
171 for (i=0; i < 9; i++) { 194 for (i = 0; i < 9; i++) {
172 mdelay(200); 195 mdelay(200);
173 events = reg_read(ohci, OHCI1394_IntEventSet); 196 events = reg_read(ohci, OHCI1394_IntEventSet);
174 if (events & OHCI1394_busReset) 197 if (events & OHCI1394_busReset)
@@ -182,18 +205,18 @@ static inline void __init init_ohci1394_wait_for_busresets(struct ti_ohci *ohci)
182 * This enables remote DMA access over IEEE1394 from every host for the low 205 * This enables remote DMA access over IEEE1394 from every host for the low
183 * 4GB of address space. DMA accesses above 4GB are not available currently. 206 * 4GB of address space. DMA accesses above 4GB are not available currently.
184 */ 207 */
185static inline void __init init_ohci1394_enable_physical_dma(struct ti_ohci *hci) 208static inline void __init init_ohci1394_enable_physical_dma(struct ohci *ohci)
186{ 209{
187 reg_write(hci, OHCI1394_PhyReqFilterHiSet, 0xffffffff); 210 reg_write(ohci, OHCI1394_PhyReqFilterHiSet, 0xffffffff);
188 reg_write(hci, OHCI1394_PhyReqFilterLoSet, 0xffffffff); 211 reg_write(ohci, OHCI1394_PhyReqFilterLoSet, 0xffffffff);
189 reg_write(hci, OHCI1394_PhyUpperBound, 0xffff0000); 212 reg_write(ohci, OHCI1394_PhyUpperBound, 0xffff0000);
190} 213}
191 214
192/** 215/**
193 * init_ohci1394_reset_and_init_dma - init controller and enable DMA 216 * init_ohci1394_reset_and_init_dma - init controller and enable DMA
194 * This initializes the given controller and enables physical DMA engine in it. 217 * This initializes the given controller and enables physical DMA engine in it.
195 */ 218 */
196static inline void __init init_ohci1394_reset_and_init_dma(struct ti_ohci *ohci) 219static inline void __init init_ohci1394_reset_and_init_dma(struct ohci *ohci)
197{ 220{
198 /* Start off with a soft reset, clears everything to a sane state. */ 221 /* Start off with a soft reset, clears everything to a sane state. */
199 init_ohci1394_soft_reset(ohci); 222 init_ohci1394_soft_reset(ohci);
@@ -225,7 +248,7 @@ static inline void __init init_ohci1394_reset_and_init_dma(struct ti_ohci *ohci)
225static inline void __init init_ohci1394_controller(int num, int slot, int func) 248static inline void __init init_ohci1394_controller(int num, int slot, int func)
226{ 249{
227 unsigned long ohci_base; 250 unsigned long ohci_base;
228 struct ti_ohci ohci; 251 struct ohci ohci;
229 252
230 printk(KERN_INFO "init_ohci1394_dma: initializing OHCI-1394" 253 printk(KERN_INFO "init_ohci1394_dma: initializing OHCI-1394"
231 " at %02x:%02x.%x\n", num, slot, func); 254 " at %02x:%02x.%x\n", num, slot, func);
@@ -235,7 +258,7 @@ static inline void __init init_ohci1394_controller(int num, int slot, int func)
235 258
236 set_fixmap_nocache(FIX_OHCI1394_BASE, ohci_base); 259 set_fixmap_nocache(FIX_OHCI1394_BASE, ohci_base);
237 260
238 ohci.registers = (void *)fix_to_virt(FIX_OHCI1394_BASE); 261 ohci.registers = (void __iomem *)fix_to_virt(FIX_OHCI1394_BASE);
239 262
240 init_ohci1394_reset_and_init_dma(&ohci); 263 init_ohci1394_reset_and_init_dma(&ohci);
241} 264}
@@ -247,6 +270,7 @@ static inline void __init init_ohci1394_controller(int num, int slot, int func)
247void __init init_ohci1394_dma_on_all_controllers(void) 270void __init init_ohci1394_dma_on_all_controllers(void)
248{ 271{
249 int num, slot, func; 272 int num, slot, func;
273 u32 class;
250 274
251 if (!early_pci_allowed()) 275 if (!early_pci_allowed())
252 return; 276 return;
@@ -255,9 +279,9 @@ void __init init_ohci1394_dma_on_all_controllers(void)
255 for (num = 0; num < 32; num++) { 279 for (num = 0; num < 32; num++) {
256 for (slot = 0; slot < 32; slot++) { 280 for (slot = 0; slot < 32; slot++) {
257 for (func = 0; func < 8; func++) { 281 for (func = 0; func < 8; func++) {
258 u32 class = read_pci_config(num,slot,func, 282 class = read_pci_config(num, slot, func,
259 PCI_CLASS_REVISION); 283 PCI_CLASS_REVISION);
260 if ((class == 0xffffffff)) 284 if (class == 0xffffffff)
261 continue; /* No device at this func */ 285 continue; /* No device at this func */
262 286
263 if (class>>8 != PCI_CLASS_SERIAL_FIREWIRE_OHCI) 287 if (class>>8 != PCI_CLASS_SERIAL_FIREWIRE_OHCI)
diff --git a/drivers/ieee1394/Makefile b/drivers/ieee1394/Makefile
index 1f8153b57503..427b86b87760 100644
--- a/drivers/ieee1394/Makefile
+++ b/drivers/ieee1394/Makefile
@@ -14,5 +14,3 @@ obj-$(CONFIG_IEEE1394_RAWIO) += raw1394.o
14obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o 14obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o
15obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o 15obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o
16obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o 16obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o
17
18obj-$(CONFIG_PROVIDE_OHCI1394_DMA_INIT) += init_ohci1394_dma.o