diff options
Diffstat (limited to 'drivers')
48 files changed, 1989 insertions, 1733 deletions
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile index ceeeba2c56c7..91f230939c1e 100644 --- a/drivers/base/power/Makefile +++ b/drivers/base/power/Makefile | |||
@@ -1,5 +1,6 @@ | |||
1 | obj-y := shutdown.o | 1 | obj-y := shutdown.o |
2 | obj-$(CONFIG_PM) += main.o suspend.o resume.o runtime.o sysfs.o | 2 | obj-$(CONFIG_PM) += main.o suspend.o resume.o runtime.o sysfs.o |
3 | obj-$(CONFIG_PM_TRACE) += trace.o | ||
3 | 4 | ||
4 | ifeq ($(CONFIG_DEBUG_DRIVER),y) | 5 | ifeq ($(CONFIG_DEBUG_DRIVER),y) |
5 | EXTRA_CFLAGS += -DDEBUG | 6 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c index 317edbf0feca..520679ce53a8 100644 --- a/drivers/base/power/resume.c +++ b/drivers/base/power/resume.c | |||
@@ -9,6 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/device.h> | 11 | #include <linux/device.h> |
12 | #include <linux/resume-trace.h> | ||
12 | #include "../base.h" | 13 | #include "../base.h" |
13 | #include "power.h" | 14 | #include "power.h" |
14 | 15 | ||
@@ -23,6 +24,8 @@ int resume_device(struct device * dev) | |||
23 | { | 24 | { |
24 | int error = 0; | 25 | int error = 0; |
25 | 26 | ||
27 | TRACE_DEVICE(dev); | ||
28 | TRACE_RESUME(0); | ||
26 | down(&dev->sem); | 29 | down(&dev->sem); |
27 | if (dev->power.pm_parent | 30 | if (dev->power.pm_parent |
28 | && dev->power.pm_parent->power.power_state.event) { | 31 | && dev->power.pm_parent->power.power_state.event) { |
@@ -36,6 +39,7 @@ int resume_device(struct device * dev) | |||
36 | error = dev->bus->resume(dev); | 39 | error = dev->bus->resume(dev); |
37 | } | 40 | } |
38 | up(&dev->sem); | 41 | up(&dev->sem); |
42 | TRACE_RESUME(error); | ||
39 | return error; | 43 | return error; |
40 | } | 44 | } |
41 | 45 | ||
diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c new file mode 100644 index 000000000000..a9ab30fefffc --- /dev/null +++ b/drivers/base/power/trace.c | |||
@@ -0,0 +1,228 @@ | |||
1 | /* | ||
2 | * drivers/base/power/trace.c | ||
3 | * | ||
4 | * Copyright (C) 2006 Linus Torvalds | ||
5 | * | ||
6 | * Trace facility for suspend/resume problems, when none of the | ||
7 | * devices may be working. | ||
8 | */ | ||
9 | |||
10 | #include <linux/resume-trace.h> | ||
11 | #include <linux/rtc.h> | ||
12 | |||
13 | #include <asm/rtc.h> | ||
14 | |||
15 | #include "power.h" | ||
16 | |||
17 | /* | ||
18 | * Horrid, horrid, horrid. | ||
19 | * | ||
20 | * It turns out that the _only_ piece of hardware that actually | ||
21 | * keeps its value across a hard boot (and, more importantly, the | ||
22 | * POST init sequence) is literally the realtime clock. | ||
23 | * | ||
24 | * Never mind that an RTC chip has 114 bytes (and often a whole | ||
25 | * other bank of an additional 128 bytes) of nice SRAM that is | ||
26 | * _designed_ to keep data - the POST will clear it. So we literally | ||
27 | * can just use the few bytes of actual time data, which means that | ||
28 | * we're really limited. | ||
29 | * | ||
30 | * It means, for example, that we can't use the seconds at all | ||
31 | * (since the time between the hang and the boot might be more | ||
32 | * than a minute), and we'd better not depend on the low bits of | ||
33 | * the minutes either. | ||
34 | * | ||
35 | * There are the wday fields etc, but I wouldn't guarantee those | ||
36 | * are dependable either. And if the date isn't valid, either the | ||
37 | * hw or POST will do strange things. | ||
38 | * | ||
39 | * So we're left with: | ||
40 | * - year: 0-99 | ||
41 | * - month: 0-11 | ||
42 | * - day-of-month: 1-28 | ||
43 | * - hour: 0-23 | ||
44 | * - min: (0-30)*2 | ||
45 | * | ||
46 | * Giving us a total range of 0-16128000 (0xf61800), ie less | ||
47 | * than 24 bits of actual data we can save across reboots. | ||
48 | * | ||
49 | * And if your box can't boot in less than three minutes, | ||
50 | * you're screwed. | ||
51 | * | ||
52 | * Now, almost 24 bits of data is pitifully small, so we need | ||
53 | * to be pretty dense if we want to use it for anything nice. | ||
54 | * What we do is that instead of saving off nice readable info, | ||
55 | * we save off _hashes_ of information that we can hopefully | ||
56 | * regenerate after the reboot. | ||
57 | * | ||
58 | * In particular, this means that we might be unlucky, and hit | ||
59 | * a case where we have a hash collision, and we end up not | ||
60 | * being able to tell for certain exactly which case happened. | ||
61 | * But that's hopefully unlikely. | ||
62 | * | ||
63 | * What we do is to take the bits we can fit, and split them | ||
64 | * into three parts (16*997*1009 = 16095568), and use the values | ||
65 | * for: | ||
66 | * - 0-15: user-settable | ||
67 | * - 0-996: file + line number | ||
68 | * - 0-1008: device | ||
69 | */ | ||
70 | #define USERHASH (16) | ||
71 | #define FILEHASH (997) | ||
72 | #define DEVHASH (1009) | ||
73 | |||
74 | #define DEVSEED (7919) | ||
75 | |||
76 | static unsigned int dev_hash_value; | ||
77 | |||
78 | static int set_magic_time(unsigned int user, unsigned int file, unsigned int device) | ||
79 | { | ||
80 | unsigned int n = user + USERHASH*(file + FILEHASH*device); | ||
81 | |||
82 | // June 7th, 2006 | ||
83 | static struct rtc_time time = { | ||
84 | .tm_sec = 0, | ||
85 | .tm_min = 0, | ||
86 | .tm_hour = 0, | ||
87 | .tm_mday = 7, | ||
88 | .tm_mon = 5, // June - counting from zero | ||
89 | .tm_year = 106, | ||
90 | .tm_wday = 3, | ||
91 | .tm_yday = 160, | ||
92 | .tm_isdst = 1 | ||
93 | }; | ||
94 | |||
95 | time.tm_year = (n % 100); | ||
96 | n /= 100; | ||
97 | time.tm_mon = (n % 12); | ||
98 | n /= 12; | ||
99 | time.tm_mday = (n % 28) + 1; | ||
100 | n /= 28; | ||
101 | time.tm_hour = (n % 24); | ||
102 | n /= 24; | ||
103 | time.tm_min = (n % 20) * 3; | ||
104 | n /= 20; | ||
105 | set_rtc_time(&time); | ||
106 | return n ? -1 : 0; | ||
107 | } | ||
108 | |||
109 | static unsigned int read_magic_time(void) | ||
110 | { | ||
111 | struct rtc_time time; | ||
112 | unsigned int val; | ||
113 | |||
114 | get_rtc_time(&time); | ||
115 | printk("Time: %2d:%02d:%02d Date: %02d/%02d/%02d\n", | ||
116 | time.tm_hour, time.tm_min, time.tm_sec, | ||
117 | time.tm_mon, time.tm_mday, time.tm_year); | ||
118 | val = time.tm_year; /* 100 years */ | ||
119 | if (val > 100) | ||
120 | val -= 100; | ||
121 | val += time.tm_mon * 100; /* 12 months */ | ||
122 | val += (time.tm_mday-1) * 100 * 12; /* 28 month-days */ | ||
123 | val += time.tm_hour * 100 * 12 * 28; /* 24 hours */ | ||
124 | val += (time.tm_min / 3) * 100 * 12 * 28 * 24; /* 20 3-minute intervals */ | ||
125 | return val; | ||
126 | } | ||
127 | |||
128 | /* | ||
129 | * This is just the sdbm hash function with a user-supplied | ||
130 | * seed and final size parameter. | ||
131 | */ | ||
132 | static unsigned int hash_string(unsigned int seed, const char *data, unsigned int mod) | ||
133 | { | ||
134 | unsigned char c; | ||
135 | while ((c = *data++) != 0) { | ||
136 | seed = (seed << 16) + (seed << 6) - seed + c; | ||
137 | } | ||
138 | return seed % mod; | ||
139 | } | ||
140 | |||
141 | void set_trace_device(struct device *dev) | ||
142 | { | ||
143 | dev_hash_value = hash_string(DEVSEED, dev->bus_id, DEVHASH); | ||
144 | } | ||
145 | |||
146 | /* | ||
147 | * We could just take the "tracedata" index into the .tracedata | ||
148 | * section instead. Generating a hash of the data gives us a | ||
149 | * chance to work across kernel versions, and perhaps more | ||
150 | * importantly it also gives us valid/invalid check (ie we will | ||
151 | * likely not give totally bogus reports - if the hash matches, | ||
152 | * it's not any guarantee, but it's a high _likelihood_ that | ||
153 | * the match is valid). | ||
154 | */ | ||
155 | void generate_resume_trace(void *tracedata, unsigned int user) | ||
156 | { | ||
157 | unsigned short lineno = *(unsigned short *)tracedata; | ||
158 | const char *file = *(const char **)(tracedata + 2); | ||
159 | unsigned int user_hash_value, file_hash_value; | ||
160 | |||
161 | user_hash_value = user % USERHASH; | ||
162 | file_hash_value = hash_string(lineno, file, FILEHASH); | ||
163 | set_magic_time(user_hash_value, file_hash_value, dev_hash_value); | ||
164 | } | ||
165 | |||
166 | extern char __tracedata_start, __tracedata_end; | ||
167 | static int show_file_hash(unsigned int value) | ||
168 | { | ||
169 | int match; | ||
170 | char *tracedata; | ||
171 | |||
172 | match = 0; | ||
173 | for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) { | ||
174 | unsigned short lineno = *(unsigned short *)tracedata; | ||
175 | const char *file = *(const char **)(tracedata + 2); | ||
176 | unsigned int hash = hash_string(lineno, file, FILEHASH); | ||
177 | if (hash != value) | ||
178 | continue; | ||
179 | printk(" hash matches %s:%u\n", file, lineno); | ||
180 | match++; | ||
181 | } | ||
182 | return match; | ||
183 | } | ||
184 | |||
185 | static int show_dev_hash(unsigned int value) | ||
186 | { | ||
187 | int match = 0; | ||
188 | struct list_head * entry = dpm_active.prev; | ||
189 | |||
190 | while (entry != &dpm_active) { | ||
191 | struct device * dev = to_device(entry); | ||
192 | unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH); | ||
193 | if (hash == value) { | ||
194 | printk(" hash matches device %s\n", dev->bus_id); | ||
195 | match++; | ||
196 | } | ||
197 | entry = entry->prev; | ||
198 | } | ||
199 | return match; | ||
200 | } | ||
201 | |||
202 | static unsigned int hash_value_early_read; | ||
203 | |||
204 | static int early_resume_init(void) | ||
205 | { | ||
206 | hash_value_early_read = read_magic_time(); | ||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | static int late_resume_init(void) | ||
211 | { | ||
212 | unsigned int val = hash_value_early_read; | ||
213 | unsigned int user, file, dev; | ||
214 | |||
215 | user = val % USERHASH; | ||
216 | val = val / USERHASH; | ||
217 | file = val % FILEHASH; | ||
218 | val = val / FILEHASH; | ||
219 | dev = val /* % DEVHASH */; | ||
220 | |||
221 | printk(" Magic number: %d:%d:%d\n", user, file, dev); | ||
222 | show_file_hash(file); | ||
223 | show_dev_hash(dev); | ||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | core_initcall(early_resume_init); | ||
228 | late_initcall(late_resume_init); | ||
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c index 9f4b8ce4c05e..a94233bdbc0e 100644 --- a/drivers/char/drm/i915_dma.c +++ b/drivers/char/drm/i915_dma.c | |||
@@ -758,7 +758,9 @@ drm_ioctl_desc_t i915_ioctls[] = { | |||
758 | [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, | 758 | [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, |
759 | [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 759 | [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
760 | [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH}, | 760 | [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH}, |
761 | [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY } | 761 | [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, |
762 | [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, | ||
763 | [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH }, | ||
762 | }; | 764 | }; |
763 | 765 | ||
764 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); | 766 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); |
diff --git a/drivers/char/drm/i915_drm.h b/drivers/char/drm/i915_drm.h index 4cb3da578330..5aa3e0e3bb45 100644 --- a/drivers/char/drm/i915_drm.h +++ b/drivers/char/drm/i915_drm.h | |||
@@ -124,6 +124,8 @@ typedef struct _drm_i915_sarea { | |||
124 | #define DRM_I915_INIT_HEAP 0x0a | 124 | #define DRM_I915_INIT_HEAP 0x0a |
125 | #define DRM_I915_CMDBUFFER 0x0b | 125 | #define DRM_I915_CMDBUFFER 0x0b |
126 | #define DRM_I915_DESTROY_HEAP 0x0c | 126 | #define DRM_I915_DESTROY_HEAP 0x0c |
127 | #define DRM_I915_SET_VBLANK_PIPE 0x0d | ||
128 | #define DRM_I915_GET_VBLANK_PIPE 0x0e | ||
127 | 129 | ||
128 | #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) | 130 | #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) |
129 | #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) | 131 | #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) |
@@ -138,6 +140,8 @@ typedef struct _drm_i915_sarea { | |||
138 | #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) | 140 | #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) |
139 | #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) | 141 | #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) |
140 | #define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t) | 142 | #define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t) |
143 | #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t) | ||
144 | #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t) | ||
141 | 145 | ||
142 | /* Allow drivers to submit batchbuffers directly to hardware, relying | 146 | /* Allow drivers to submit batchbuffers directly to hardware, relying |
143 | * on the security mechanisms provided by hardware. | 147 | * on the security mechanisms provided by hardware. |
@@ -224,4 +228,13 @@ typedef struct drm_i915_mem_destroy_heap { | |||
224 | int region; | 228 | int region; |
225 | } drm_i915_mem_destroy_heap_t; | 229 | } drm_i915_mem_destroy_heap_t; |
226 | 230 | ||
231 | /* Allow X server to configure which pipes to monitor for vblank signals | ||
232 | */ | ||
233 | #define DRM_I915_VBLANK_PIPE_A 1 | ||
234 | #define DRM_I915_VBLANK_PIPE_B 2 | ||
235 | |||
236 | typedef struct drm_i915_vblank_pipe { | ||
237 | int pipe; | ||
238 | } drm_i915_vblank_pipe_t; | ||
239 | |||
227 | #endif /* _I915_DRM_H_ */ | 240 | #endif /* _I915_DRM_H_ */ |
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h index 7a65666899e4..2d565031c002 100644 --- a/drivers/char/drm/i915_drv.h +++ b/drivers/char/drm/i915_drv.h | |||
@@ -45,9 +45,10 @@ | |||
45 | * 1.2: Add Power Management | 45 | * 1.2: Add Power Management |
46 | * 1.3: Add vblank support | 46 | * 1.3: Add vblank support |
47 | * 1.4: Fix cmdbuffer path, add heap destroy | 47 | * 1.4: Fix cmdbuffer path, add heap destroy |
48 | * 1.5: Add vblank pipe configuration | ||
48 | */ | 49 | */ |
49 | #define DRIVER_MAJOR 1 | 50 | #define DRIVER_MAJOR 1 |
50 | #define DRIVER_MINOR 4 | 51 | #define DRIVER_MINOR 5 |
51 | #define DRIVER_PATCHLEVEL 0 | 52 | #define DRIVER_PATCHLEVEL 0 |
52 | 53 | ||
53 | typedef struct _drm_i915_ring_buffer { | 54 | typedef struct _drm_i915_ring_buffer { |
@@ -96,6 +97,7 @@ typedef struct drm_i915_private { | |||
96 | int allow_batchbuffer; | 97 | int allow_batchbuffer; |
97 | struct mem_block *agp_heap; | 98 | struct mem_block *agp_heap; |
98 | unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds; | 99 | unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds; |
100 | int vblank_pipe; | ||
99 | } drm_i915_private_t; | 101 | } drm_i915_private_t; |
100 | 102 | ||
101 | extern drm_ioctl_desc_t i915_ioctls[]; | 103 | extern drm_ioctl_desc_t i915_ioctls[]; |
@@ -119,6 +121,8 @@ extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS); | |||
119 | extern void i915_driver_irq_preinstall(drm_device_t * dev); | 121 | extern void i915_driver_irq_preinstall(drm_device_t * dev); |
120 | extern void i915_driver_irq_postinstall(drm_device_t * dev); | 122 | extern void i915_driver_irq_postinstall(drm_device_t * dev); |
121 | extern void i915_driver_irq_uninstall(drm_device_t * dev); | 123 | extern void i915_driver_irq_uninstall(drm_device_t * dev); |
124 | extern int i915_vblank_pipe_set(DRM_IOCTL_ARGS); | ||
125 | extern int i915_vblank_pipe_get(DRM_IOCTL_ARGS); | ||
122 | 126 | ||
123 | /* i915_mem.c */ | 127 | /* i915_mem.c */ |
124 | extern int i915_mem_alloc(DRM_IOCTL_ARGS); | 128 | extern int i915_mem_alloc(DRM_IOCTL_ARGS); |
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c index a752afd86ab8..cd96cfa430db 100644 --- a/drivers/char/drm/i915_irq.c +++ b/drivers/char/drm/i915_irq.c | |||
@@ -44,7 +44,8 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) | |||
44 | u16 temp; | 44 | u16 temp; |
45 | 45 | ||
46 | temp = I915_READ16(I915REG_INT_IDENTITY_R); | 46 | temp = I915_READ16(I915REG_INT_IDENTITY_R); |
47 | temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG); | 47 | |
48 | temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG); | ||
48 | 49 | ||
49 | DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp); | 50 | DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp); |
50 | 51 | ||
@@ -58,7 +59,7 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) | |||
58 | if (temp & USER_INT_FLAG) | 59 | if (temp & USER_INT_FLAG) |
59 | DRM_WAKEUP(&dev_priv->irq_queue); | 60 | DRM_WAKEUP(&dev_priv->irq_queue); |
60 | 61 | ||
61 | if (temp & VSYNC_PIPEA_FLAG) { | 62 | if (temp & (VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG)) { |
62 | atomic_inc(&dev->vbl_received); | 63 | atomic_inc(&dev->vbl_received); |
63 | DRM_WAKEUP(&dev->vbl_queue); | 64 | DRM_WAKEUP(&dev->vbl_queue); |
64 | drm_vbl_send_signals(dev); | 65 | drm_vbl_send_signals(dev); |
@@ -182,6 +183,68 @@ int i915_irq_wait(DRM_IOCTL_ARGS) | |||
182 | return i915_wait_irq(dev, irqwait.irq_seq); | 183 | return i915_wait_irq(dev, irqwait.irq_seq); |
183 | } | 184 | } |
184 | 185 | ||
186 | static int i915_enable_interrupt (drm_device_t *dev) | ||
187 | { | ||
188 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | ||
189 | u16 flag; | ||
190 | |||
191 | flag = 0; | ||
192 | if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_A) | ||
193 | flag |= VSYNC_PIPEA_FLAG; | ||
194 | if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_B) | ||
195 | flag |= VSYNC_PIPEB_FLAG; | ||
196 | if (dev_priv->vblank_pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) { | ||
197 | DRM_ERROR("%s called with invalid pipe 0x%x\n", | ||
198 | __FUNCTION__, dev_priv->vblank_pipe); | ||
199 | return DRM_ERR(EINVAL); | ||
200 | } | ||
201 | I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | flag); | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | /* Set the vblank monitor pipe | ||
206 | */ | ||
207 | int i915_vblank_pipe_set(DRM_IOCTL_ARGS) | ||
208 | { | ||
209 | DRM_DEVICE; | ||
210 | drm_i915_private_t *dev_priv = dev->dev_private; | ||
211 | drm_i915_vblank_pipe_t pipe; | ||
212 | |||
213 | if (!dev_priv) { | ||
214 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | ||
215 | return DRM_ERR(EINVAL); | ||
216 | } | ||
217 | |||
218 | DRM_COPY_FROM_USER_IOCTL(pipe, (drm_i915_vblank_pipe_t __user *) data, | ||
219 | sizeof(pipe)); | ||
220 | |||
221 | dev_priv->vblank_pipe = pipe.pipe; | ||
222 | return i915_enable_interrupt (dev); | ||
223 | } | ||
224 | |||
225 | int i915_vblank_pipe_get(DRM_IOCTL_ARGS) | ||
226 | { | ||
227 | DRM_DEVICE; | ||
228 | drm_i915_private_t *dev_priv = dev->dev_private; | ||
229 | drm_i915_vblank_pipe_t pipe; | ||
230 | u16 flag; | ||
231 | |||
232 | if (!dev_priv) { | ||
233 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | ||
234 | return DRM_ERR(EINVAL); | ||
235 | } | ||
236 | |||
237 | flag = I915_READ(I915REG_INT_ENABLE_R); | ||
238 | pipe.pipe = 0; | ||
239 | if (flag & VSYNC_PIPEA_FLAG) | ||
240 | pipe.pipe |= DRM_I915_VBLANK_PIPE_A; | ||
241 | if (flag & VSYNC_PIPEB_FLAG) | ||
242 | pipe.pipe |= DRM_I915_VBLANK_PIPE_B; | ||
243 | DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_pipe_t __user *) data, pipe, | ||
244 | sizeof(pipe)); | ||
245 | return 0; | ||
246 | } | ||
247 | |||
185 | /* drm_dma.h hooks | 248 | /* drm_dma.h hooks |
186 | */ | 249 | */ |
187 | void i915_driver_irq_preinstall(drm_device_t * dev) | 250 | void i915_driver_irq_preinstall(drm_device_t * dev) |
@@ -197,7 +260,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev) | |||
197 | { | 260 | { |
198 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 261 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
199 | 262 | ||
200 | I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | VSYNC_PIPEA_FLAG); | 263 | i915_enable_interrupt(dev); |
201 | DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); | 264 | DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); |
202 | } | 265 | } |
203 | 266 | ||
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index 7f949c9c9691..5ad43ba7b5aa 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c | |||
@@ -39,7 +39,7 @@ | |||
39 | static int radeon_do_cleanup_cp(drm_device_t * dev); | 39 | static int radeon_do_cleanup_cp(drm_device_t * dev); |
40 | 40 | ||
41 | /* CP microcode (from ATI) */ | 41 | /* CP microcode (from ATI) */ |
42 | static u32 R200_cp_microcode[][2] = { | 42 | static const u32 R200_cp_microcode[][2] = { |
43 | {0x21007000, 0000000000}, | 43 | {0x21007000, 0000000000}, |
44 | {0x20007000, 0000000000}, | 44 | {0x20007000, 0000000000}, |
45 | {0x000000ab, 0x00000004}, | 45 | {0x000000ab, 0x00000004}, |
@@ -298,7 +298,7 @@ static u32 R200_cp_microcode[][2] = { | |||
298 | {0000000000, 0000000000}, | 298 | {0000000000, 0000000000}, |
299 | }; | 299 | }; |
300 | 300 | ||
301 | static u32 radeon_cp_microcode[][2] = { | 301 | static const u32 radeon_cp_microcode[][2] = { |
302 | {0x21007000, 0000000000}, | 302 | {0x21007000, 0000000000}, |
303 | {0x20007000, 0000000000}, | 303 | {0x20007000, 0000000000}, |
304 | {0x000000b4, 0x00000004}, | 304 | {0x000000b4, 0x00000004}, |
@@ -557,7 +557,7 @@ static u32 radeon_cp_microcode[][2] = { | |||
557 | {0000000000, 0000000000}, | 557 | {0000000000, 0000000000}, |
558 | }; | 558 | }; |
559 | 559 | ||
560 | static u32 R300_cp_microcode[][2] = { | 560 | static const u32 R300_cp_microcode[][2] = { |
561 | {0x4200e000, 0000000000}, | 561 | {0x4200e000, 0000000000}, |
562 | {0x4000e000, 0000000000}, | 562 | {0x4000e000, 0000000000}, |
563 | {0x000000af, 0x00000008}, | 563 | {0x000000af, 0x00000008}, |
diff --git a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h index c8e279e89c2e..8d6350dd5360 100644 --- a/drivers/char/drm/radeon_drm.h +++ b/drivers/char/drm/radeon_drm.h | |||
@@ -161,7 +161,8 @@ | |||
161 | #define R200_EMIT_PP_TXCTLALL_3 91 | 161 | #define R200_EMIT_PP_TXCTLALL_3 91 |
162 | #define R200_EMIT_PP_TXCTLALL_4 92 | 162 | #define R200_EMIT_PP_TXCTLALL_4 92 |
163 | #define R200_EMIT_PP_TXCTLALL_5 93 | 163 | #define R200_EMIT_PP_TXCTLALL_5 93 |
164 | #define RADEON_MAX_STATE_PACKETS 94 | 164 | #define R200_EMIT_VAP_PVS_CNTL 94 |
165 | #define RADEON_MAX_STATE_PACKETS 95 | ||
165 | 166 | ||
166 | /* Commands understood by cmd_buffer ioctl. More can be added but | 167 | /* Commands understood by cmd_buffer ioctl. More can be added but |
167 | * obviously these can't be removed or changed: | 168 | * obviously these can't be removed or changed: |
@@ -176,6 +177,7 @@ | |||
176 | #define RADEON_CMD_WAIT 8 /* emit hw wait commands -- note: | 177 | #define RADEON_CMD_WAIT 8 /* emit hw wait commands -- note: |
177 | * doesn't make the cpu wait, just | 178 | * doesn't make the cpu wait, just |
178 | * the graphics hardware */ | 179 | * the graphics hardware */ |
180 | #define RADEON_CMD_VECLINEAR 9 /* another r200 stopgap */ | ||
179 | 181 | ||
180 | typedef union { | 182 | typedef union { |
181 | int i; | 183 | int i; |
@@ -192,6 +194,9 @@ typedef union { | |||
192 | unsigned char cmd_type, offset, stride, count; | 194 | unsigned char cmd_type, offset, stride, count; |
193 | } vectors; | 195 | } vectors; |
194 | struct { | 196 | struct { |
197 | unsigned char cmd_type, addr_lo, addr_hi, count; | ||
198 | } veclinear; | ||
199 | struct { | ||
195 | unsigned char cmd_type, buf_idx, pad0, pad1; | 200 | unsigned char cmd_type, buf_idx, pad0, pad1; |
196 | } dma; | 201 | } dma; |
197 | struct { | 202 | struct { |
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h index 78345cee8f8e..e5a256f5429c 100644 --- a/drivers/char/drm/radeon_drv.h +++ b/drivers/char/drm/radeon_drv.h | |||
@@ -38,7 +38,7 @@ | |||
38 | 38 | ||
39 | #define DRIVER_NAME "radeon" | 39 | #define DRIVER_NAME "radeon" |
40 | #define DRIVER_DESC "ATI Radeon" | 40 | #define DRIVER_DESC "ATI Radeon" |
41 | #define DRIVER_DATE "20060225" | 41 | #define DRIVER_DATE "20060524" |
42 | 42 | ||
43 | /* Interface history: | 43 | /* Interface history: |
44 | * | 44 | * |
@@ -93,9 +93,11 @@ | |||
93 | * 1.22- Add support for texture cache flushes (R300_TX_CNTL) | 93 | * 1.22- Add support for texture cache flushes (R300_TX_CNTL) |
94 | * 1.23- Add new radeon memory map work from benh | 94 | * 1.23- Add new radeon memory map work from benh |
95 | * 1.24- Add general-purpose packet for manipulating scratch registers (r300) | 95 | * 1.24- Add general-purpose packet for manipulating scratch registers (r300) |
96 | * 1.25- Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL, | ||
97 | * new packet type) | ||
96 | */ | 98 | */ |
97 | #define DRIVER_MAJOR 1 | 99 | #define DRIVER_MAJOR 1 |
98 | #define DRIVER_MINOR 24 | 100 | #define DRIVER_MINOR 25 |
99 | #define DRIVER_PATCHLEVEL 0 | 101 | #define DRIVER_PATCHLEVEL 0 |
100 | 102 | ||
101 | /* | 103 | /* |
@@ -884,6 +886,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp, | |||
884 | #define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00 | 886 | #define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00 |
885 | #define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14 | 887 | #define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14 |
886 | 888 | ||
889 | #define RADEON_SE_TCL_STATE_FLUSH 0x2284 | ||
890 | |||
887 | #define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001 | 891 | #define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001 |
888 | #define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK 0x00010000 | 892 | #define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK 0x00010000 |
889 | #define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 0x00000012 | 893 | #define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 0x00000012 |
@@ -905,6 +909,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp, | |||
905 | #define R200_PP_AFS_0 0x2f80 | 909 | #define R200_PP_AFS_0 0x2f80 |
906 | #define R200_PP_AFS_1 0x2f00 /* same as txcblend_0 */ | 910 | #define R200_PP_AFS_1 0x2f00 /* same as txcblend_0 */ |
907 | 911 | ||
912 | #define R200_VAP_PVS_CNTL_1 0x22D0 | ||
913 | |||
908 | /* Constants */ | 914 | /* Constants */ |
909 | #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ | 915 | #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ |
910 | 916 | ||
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c index c5b8f774a599..5bb2234a9094 100644 --- a/drivers/char/drm/radeon_state.c +++ b/drivers/char/drm/radeon_state.c | |||
@@ -249,6 +249,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t * | |||
249 | case R200_EMIT_PP_TXCTLALL_3: | 249 | case R200_EMIT_PP_TXCTLALL_3: |
250 | case R200_EMIT_PP_TXCTLALL_4: | 250 | case R200_EMIT_PP_TXCTLALL_4: |
251 | case R200_EMIT_PP_TXCTLALL_5: | 251 | case R200_EMIT_PP_TXCTLALL_5: |
252 | case R200_EMIT_VAP_PVS_CNTL: | ||
252 | /* These packets don't contain memory offsets */ | 253 | /* These packets don't contain memory offsets */ |
253 | break; | 254 | break; |
254 | 255 | ||
@@ -626,6 +627,7 @@ static struct { | |||
626 | {R200_PP_TXFILTER_3, 8, "R200_PP_TXCTLALL_3"}, | 627 | {R200_PP_TXFILTER_3, 8, "R200_PP_TXCTLALL_3"}, |
627 | {R200_PP_TXFILTER_4, 8, "R200_PP_TXCTLALL_4"}, | 628 | {R200_PP_TXFILTER_4, 8, "R200_PP_TXCTLALL_4"}, |
628 | {R200_PP_TXFILTER_5, 8, "R200_PP_TXCTLALL_5"}, | 629 | {R200_PP_TXFILTER_5, 8, "R200_PP_TXCTLALL_5"}, |
630 | {R200_VAP_PVS_CNTL_1, 2, "R200_VAP_PVS_CNTL"}, | ||
629 | }; | 631 | }; |
630 | 632 | ||
631 | /* ================================================================ | 633 | /* ================================================================ |
@@ -2595,7 +2597,8 @@ static __inline__ int radeon_emit_vectors(drm_radeon_private_t *dev_priv, | |||
2595 | int stride = header.vectors.stride; | 2597 | int stride = header.vectors.stride; |
2596 | RING_LOCALS; | 2598 | RING_LOCALS; |
2597 | 2599 | ||
2598 | BEGIN_RING(3 + sz); | 2600 | BEGIN_RING(5 + sz); |
2601 | OUT_RING_REG(RADEON_SE_TCL_STATE_FLUSH, 0); | ||
2599 | OUT_RING(CP_PACKET0(RADEON_SE_TCL_VECTOR_INDX_REG, 0)); | 2602 | OUT_RING(CP_PACKET0(RADEON_SE_TCL_VECTOR_INDX_REG, 0)); |
2600 | OUT_RING(start | (stride << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT)); | 2603 | OUT_RING(start | (stride << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT)); |
2601 | OUT_RING(CP_PACKET0_TABLE(RADEON_SE_TCL_VECTOR_DATA_REG, (sz - 1))); | 2604 | OUT_RING(CP_PACKET0_TABLE(RADEON_SE_TCL_VECTOR_DATA_REG, (sz - 1))); |
@@ -2607,6 +2610,32 @@ static __inline__ int radeon_emit_vectors(drm_radeon_private_t *dev_priv, | |||
2607 | return 0; | 2610 | return 0; |
2608 | } | 2611 | } |
2609 | 2612 | ||
2613 | static __inline__ int radeon_emit_veclinear(drm_radeon_private_t *dev_priv, | ||
2614 | drm_radeon_cmd_header_t header, | ||
2615 | drm_radeon_kcmd_buffer_t *cmdbuf) | ||
2616 | { | ||
2617 | int sz = header.veclinear.count * 4; | ||
2618 | int start = header.veclinear.addr_lo | (header.veclinear.addr_hi << 8); | ||
2619 | RING_LOCALS; | ||
2620 | |||
2621 | if (!sz) | ||
2622 | return 0; | ||
2623 | if (sz * 4 > cmdbuf->bufsz) | ||
2624 | return DRM_ERR(EINVAL); | ||
2625 | |||
2626 | BEGIN_RING(5 + sz); | ||
2627 | OUT_RING_REG(RADEON_SE_TCL_STATE_FLUSH, 0); | ||
2628 | OUT_RING(CP_PACKET0(RADEON_SE_TCL_VECTOR_INDX_REG, 0)); | ||
2629 | OUT_RING(start | (1 << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT)); | ||
2630 | OUT_RING(CP_PACKET0_TABLE(RADEON_SE_TCL_VECTOR_DATA_REG, (sz - 1))); | ||
2631 | OUT_RING_TABLE(cmdbuf->buf, sz); | ||
2632 | ADVANCE_RING(); | ||
2633 | |||
2634 | cmdbuf->buf += sz * sizeof(int); | ||
2635 | cmdbuf->bufsz -= sz * sizeof(int); | ||
2636 | return 0; | ||
2637 | } | ||
2638 | |||
2610 | static int radeon_emit_packet3(drm_device_t * dev, | 2639 | static int radeon_emit_packet3(drm_device_t * dev, |
2611 | drm_file_t * filp_priv, | 2640 | drm_file_t * filp_priv, |
2612 | drm_radeon_kcmd_buffer_t *cmdbuf) | 2641 | drm_radeon_kcmd_buffer_t *cmdbuf) |
@@ -2865,6 +2894,14 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2865 | goto err; | 2894 | goto err; |
2866 | } | 2895 | } |
2867 | break; | 2896 | break; |
2897 | case RADEON_CMD_VECLINEAR: | ||
2898 | DRM_DEBUG("RADEON_CMD_VECLINEAR\n"); | ||
2899 | if (radeon_emit_veclinear(dev_priv, header, &cmdbuf)) { | ||
2900 | DRM_ERROR("radeon_emit_veclinear failed\n"); | ||
2901 | goto err; | ||
2902 | } | ||
2903 | break; | ||
2904 | |||
2868 | default: | 2905 | default: |
2869 | DRM_ERROR("bad cmd_type %d at %p\n", | 2906 | DRM_ERROR("bad cmd_type %d at %p\n", |
2870 | header.header.cmd_type, | 2907 | header.header.cmd_type, |
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index f6686fcce809..0897b0c8d528 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -928,7 +928,7 @@ static int __init rtc_init(void) | |||
928 | #ifdef __sparc__ | 928 | #ifdef __sparc__ |
929 | for_each_ebus(ebus) { | 929 | for_each_ebus(ebus) { |
930 | for_each_ebusdev(edev, ebus) { | 930 | for_each_ebusdev(edev, ebus) { |
931 | if(strcmp(edev->prom_name, "rtc") == 0) { | 931 | if(strcmp(edev->prom_node->name, "rtc") == 0) { |
932 | rtc_port = edev->resource[0].start; | 932 | rtc_port = edev->resource[0].start; |
933 | rtc_irq = edev->irqs[0]; | 933 | rtc_irq = edev->irqs[0]; |
934 | goto found; | 934 | goto found; |
@@ -938,7 +938,7 @@ static int __init rtc_init(void) | |||
938 | #ifdef __sparc_v9__ | 938 | #ifdef __sparc_v9__ |
939 | for_each_isa(isa_br) { | 939 | for_each_isa(isa_br) { |
940 | for_each_isadev(isa_dev, isa_br) { | 940 | for_each_isadev(isa_dev, isa_br) { |
941 | if (strcmp(isa_dev->prom_name, "rtc") == 0) { | 941 | if (strcmp(isa_dev->prom_node->name, "rtc") == 0) { |
942 | rtc_port = isa_dev->resource.start; | 942 | rtc_port = isa_dev->resource.start; |
943 | rtc_irq = isa_dev->irq; | 943 | rtc_irq = isa_dev->irq; |
944 | goto found; | 944 | goto found; |
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 4bad588d0e5d..a6dfc7455733 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -26,7 +26,7 @@ config INPUT_PCSPKR | |||
26 | 26 | ||
27 | config INPUT_SPARCSPKR | 27 | config INPUT_SPARCSPKR |
28 | tristate "SPARC Speaker support" | 28 | tristate "SPARC Speaker support" |
29 | depends on PCI && SPARC | 29 | depends on PCI && SPARC64 |
30 | help | 30 | help |
31 | Say Y here if you want the standard Speaker on Sparc PCI systems | 31 | Say Y here if you want the standard Speaker on Sparc PCI systems |
32 | to be used for bells and whistles. | 32 | to be used for bells and whistles. |
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index f0fd2c4740f1..42c11fbf3c79 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Driver for PC-speaker like devices found on various Sparc systems. | 2 | * Driver for PC-speaker like devices found on various Sparc systems. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 Vojtech Pavlik | 4 | * Copyright (c) 2002 Vojtech Pavlik |
5 | * Copyright (c) 2002 David S. Miller (davem@redhat.com) | 5 | * Copyright (c) 2002, 2006 David S. Miller (davem@davemloft.net) |
6 | */ | 6 | */ |
7 | #include <linux/config.h> | 7 | #include <linux/config.h> |
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
@@ -13,21 +13,23 @@ | |||
13 | 13 | ||
14 | #include <asm/io.h> | 14 | #include <asm/io.h> |
15 | #include <asm/ebus.h> | 15 | #include <asm/ebus.h> |
16 | #ifdef CONFIG_SPARC64 | ||
17 | #include <asm/isa.h> | 16 | #include <asm/isa.h> |
18 | #endif | ||
19 | 17 | ||
20 | MODULE_AUTHOR("David S. Miller <davem@redhat.com>"); | 18 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); |
21 | MODULE_DESCRIPTION("Sparc Speaker beeper driver"); | 19 | MODULE_DESCRIPTION("Sparc Speaker beeper driver"); |
22 | MODULE_LICENSE("GPL"); | 20 | MODULE_LICENSE("GPL"); |
23 | 21 | ||
24 | const char *beep_name; | 22 | struct sparcspkr_state { |
25 | static unsigned long beep_iobase; | 23 | const char *name; |
26 | static int (*beep_event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); | 24 | unsigned long iobase; |
27 | static DEFINE_SPINLOCK(beep_lock); | 25 | int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); |
26 | spinlock_t lock; | ||
27 | struct input_dev *input_dev; | ||
28 | }; | ||
28 | 29 | ||
29 | static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 30 | static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
30 | { | 31 | { |
32 | struct sparcspkr_state *state = dev_get_drvdata(dev->cdev.dev); | ||
31 | unsigned int count = 0; | 33 | unsigned int count = 0; |
32 | unsigned long flags; | 34 | unsigned long flags; |
33 | 35 | ||
@@ -43,24 +45,24 @@ static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned in | |||
43 | if (value > 20 && value < 32767) | 45 | if (value > 20 && value < 32767) |
44 | count = 1193182 / value; | 46 | count = 1193182 / value; |
45 | 47 | ||
46 | spin_lock_irqsave(&beep_lock, flags); | 48 | spin_lock_irqsave(&state->lock, flags); |
47 | 49 | ||
48 | /* EBUS speaker only has on/off state, the frequency does not | 50 | /* EBUS speaker only has on/off state, the frequency does not |
49 | * appear to be programmable. | 51 | * appear to be programmable. |
50 | */ | 52 | */ |
51 | if (beep_iobase & 0x2UL) | 53 | if (state->iobase & 0x2UL) |
52 | outb(!!count, beep_iobase); | 54 | outb(!!count, state->iobase); |
53 | else | 55 | else |
54 | outl(!!count, beep_iobase); | 56 | outl(!!count, state->iobase); |
55 | 57 | ||
56 | spin_unlock_irqrestore(&beep_lock, flags); | 58 | spin_unlock_irqrestore(&state->lock, flags); |
57 | 59 | ||
58 | return 0; | 60 | return 0; |
59 | } | 61 | } |
60 | 62 | ||
61 | #ifdef CONFIG_SPARC64 | ||
62 | static int isa_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 63 | static int isa_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
63 | { | 64 | { |
65 | struct sparcspkr_state *state = dev_get_drvdata(dev->cdev.dev); | ||
64 | unsigned int count = 0; | 66 | unsigned int count = 0; |
65 | unsigned long flags; | 67 | unsigned long flags; |
66 | 68 | ||
@@ -76,29 +78,29 @@ static int isa_spkr_event(struct input_dev *dev, unsigned int type, unsigned int | |||
76 | if (value > 20 && value < 32767) | 78 | if (value > 20 && value < 32767) |
77 | count = 1193182 / value; | 79 | count = 1193182 / value; |
78 | 80 | ||
79 | spin_lock_irqsave(&beep_lock, flags); | 81 | spin_lock_irqsave(&state->lock, flags); |
80 | 82 | ||
81 | if (count) { | 83 | if (count) { |
82 | /* enable counter 2 */ | 84 | /* enable counter 2 */ |
83 | outb(inb(beep_iobase + 0x61) | 3, beep_iobase + 0x61); | 85 | outb(inb(state->iobase + 0x61) | 3, state->iobase + 0x61); |
84 | /* set command for counter 2, 2 byte write */ | 86 | /* set command for counter 2, 2 byte write */ |
85 | outb(0xB6, beep_iobase + 0x43); | 87 | outb(0xB6, state->iobase + 0x43); |
86 | /* select desired HZ */ | 88 | /* select desired HZ */ |
87 | outb(count & 0xff, beep_iobase + 0x42); | 89 | outb(count & 0xff, state->iobase + 0x42); |
88 | outb((count >> 8) & 0xff, beep_iobase + 0x42); | 90 | outb((count >> 8) & 0xff, state->iobase + 0x42); |
89 | } else { | 91 | } else { |
90 | /* disable counter 2 */ | 92 | /* disable counter 2 */ |
91 | outb(inb_p(beep_iobase + 0x61) & 0xFC, beep_iobase + 0x61); | 93 | outb(inb_p(state->iobase + 0x61) & 0xFC, state->iobase + 0x61); |
92 | } | 94 | } |
93 | 95 | ||
94 | spin_unlock_irqrestore(&beep_lock, flags); | 96 | spin_unlock_irqrestore(&state->lock, flags); |
95 | 97 | ||
96 | return 0; | 98 | return 0; |
97 | } | 99 | } |
98 | #endif | ||
99 | 100 | ||
100 | static int __devinit sparcspkr_probe(struct platform_device *dev) | 101 | static int __devinit sparcspkr_probe(struct device *dev) |
101 | { | 102 | { |
103 | struct sparcspkr_state *state = dev_get_drvdata(dev); | ||
102 | struct input_dev *input_dev; | 104 | struct input_dev *input_dev; |
103 | int error; | 105 | int error; |
104 | 106 | ||
@@ -106,18 +108,18 @@ static int __devinit sparcspkr_probe(struct platform_device *dev) | |||
106 | if (!input_dev) | 108 | if (!input_dev) |
107 | return -ENOMEM; | 109 | return -ENOMEM; |
108 | 110 | ||
109 | input_dev->name = beep_name; | 111 | input_dev->name = state->name; |
110 | input_dev->phys = "sparc/input0"; | 112 | input_dev->phys = "sparc/input0"; |
111 | input_dev->id.bustype = BUS_ISA; | 113 | input_dev->id.bustype = BUS_ISA; |
112 | input_dev->id.vendor = 0x001f; | 114 | input_dev->id.vendor = 0x001f; |
113 | input_dev->id.product = 0x0001; | 115 | input_dev->id.product = 0x0001; |
114 | input_dev->id.version = 0x0100; | 116 | input_dev->id.version = 0x0100; |
115 | input_dev->cdev.dev = &dev->dev; | 117 | input_dev->cdev.dev = dev; |
116 | 118 | ||
117 | input_dev->evbit[0] = BIT(EV_SND); | 119 | input_dev->evbit[0] = BIT(EV_SND); |
118 | input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | 120 | input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); |
119 | 121 | ||
120 | input_dev->event = beep_event; | 122 | input_dev->event = state->event; |
121 | 123 | ||
122 | error = input_register_device(input_dev); | 124 | error = input_register_device(input_dev); |
123 | if (error) { | 125 | if (error) { |
@@ -125,111 +127,137 @@ static int __devinit sparcspkr_probe(struct platform_device *dev) | |||
125 | return error; | 127 | return error; |
126 | } | 128 | } |
127 | 129 | ||
128 | platform_set_drvdata(dev, input_dev); | 130 | state->input_dev = input_dev; |
129 | 131 | ||
130 | return 0; | 132 | return 0; |
131 | } | 133 | } |
132 | 134 | ||
133 | static int __devexit sparcspkr_remove(struct platform_device *dev) | 135 | static int __devexit sparcspkr_remove(struct of_device *dev) |
134 | { | 136 | { |
135 | struct input_dev *input_dev = platform_get_drvdata(dev); | 137 | struct sparcspkr_state *state = dev_get_drvdata(&dev->dev); |
138 | struct input_dev *input_dev = state->input_dev; | ||
136 | 139 | ||
137 | input_unregister_device(input_dev); | ||
138 | platform_set_drvdata(dev, NULL); | ||
139 | /* turn off the speaker */ | 140 | /* turn off the speaker */ |
140 | beep_event(NULL, EV_SND, SND_BELL, 0); | 141 | state->event(input_dev, EV_SND, SND_BELL, 0); |
142 | |||
143 | input_unregister_device(input_dev); | ||
144 | |||
145 | dev_set_drvdata(&dev->dev, NULL); | ||
146 | kfree(state); | ||
141 | 147 | ||
142 | return 0; | 148 | return 0; |
143 | } | 149 | } |
144 | 150 | ||
145 | static void sparcspkr_shutdown(struct platform_device *dev) | 151 | static int sparcspkr_shutdown(struct of_device *dev) |
146 | { | 152 | { |
153 | struct sparcspkr_state *state = dev_get_drvdata(&dev->dev); | ||
154 | struct input_dev *input_dev = state->input_dev; | ||
155 | |||
147 | /* turn off the speaker */ | 156 | /* turn off the speaker */ |
148 | beep_event(NULL, EV_SND, SND_BELL, 0); | 157 | state->event(input_dev, EV_SND, SND_BELL, 0); |
158 | |||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | static int __devinit ebus_beep_probe(struct of_device *dev, const struct of_device_id *match) | ||
163 | { | ||
164 | struct linux_ebus_device *edev = to_ebus_device(&dev->dev); | ||
165 | struct sparcspkr_state *state; | ||
166 | int err; | ||
167 | |||
168 | state = kzalloc(sizeof(*state), GFP_KERNEL); | ||
169 | if (!state) | ||
170 | return -ENOMEM; | ||
171 | |||
172 | state->name = "Sparc EBUS Speaker"; | ||
173 | state->iobase = edev->resource[0].start; | ||
174 | state->event = ebus_spkr_event; | ||
175 | spin_lock_init(&state->lock); | ||
176 | |||
177 | dev_set_drvdata(&dev->dev, state); | ||
178 | |||
179 | err = sparcspkr_probe(&dev->dev); | ||
180 | if (err) { | ||
181 | dev_set_drvdata(&dev->dev, NULL); | ||
182 | kfree(state); | ||
183 | } | ||
184 | |||
185 | return 0; | ||
149 | } | 186 | } |
150 | 187 | ||
151 | static struct platform_driver sparcspkr_platform_driver = { | 188 | static struct of_device_id ebus_beep_match[] = { |
152 | .driver = { | 189 | { |
153 | .name = "sparcspkr", | 190 | .name = "beep", |
154 | .owner = THIS_MODULE, | ||
155 | }, | 191 | }, |
156 | .probe = sparcspkr_probe, | 192 | {}, |
157 | .remove = __devexit_p(sparcspkr_remove), | ||
158 | .shutdown = sparcspkr_shutdown, | ||
159 | }; | 193 | }; |
160 | 194 | ||
161 | static struct platform_device *sparcspkr_platform_device; | 195 | static struct of_platform_driver ebus_beep_driver = { |
196 | .name = "beep", | ||
197 | .match_table = ebus_beep_match, | ||
198 | .probe = ebus_beep_probe, | ||
199 | .remove = sparcspkr_remove, | ||
200 | .shutdown = sparcspkr_shutdown, | ||
201 | }; | ||
162 | 202 | ||
163 | static int __init sparcspkr_drv_init(void) | 203 | static int __devinit isa_beep_probe(struct of_device *dev, const struct of_device_id *match) |
164 | { | 204 | { |
165 | int error; | 205 | struct sparc_isa_device *idev = to_isa_device(&dev->dev); |
206 | struct sparcspkr_state *state; | ||
207 | int err; | ||
166 | 208 | ||
167 | error = platform_driver_register(&sparcspkr_platform_driver); | 209 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
168 | if (error) | 210 | if (!state) |
169 | return error; | 211 | return -ENOMEM; |
170 | 212 | ||
171 | sparcspkr_platform_device = platform_device_alloc("sparcspkr", -1); | 213 | state->name = "Sparc ISA Speaker"; |
172 | if (!sparcspkr_platform_device) { | 214 | state->iobase = idev->resource.start; |
173 | error = -ENOMEM; | 215 | state->event = isa_spkr_event; |
174 | goto err_unregister_driver; | 216 | spin_lock_init(&state->lock); |
175 | } | 217 | |
218 | dev_set_drvdata(&dev->dev, state); | ||
176 | 219 | ||
177 | error = platform_device_add(sparcspkr_platform_device); | 220 | err = sparcspkr_probe(&dev->dev); |
178 | if (error) | 221 | if (err) { |
179 | goto err_free_device; | 222 | dev_set_drvdata(&dev->dev, NULL); |
223 | kfree(state); | ||
224 | } | ||
180 | 225 | ||
181 | return 0; | 226 | return 0; |
227 | } | ||
182 | 228 | ||
183 | err_free_device: | 229 | static struct of_device_id isa_beep_match[] = { |
184 | platform_device_put(sparcspkr_platform_device); | 230 | { |
185 | err_unregister_driver: | 231 | .name = "dma", |
186 | platform_driver_unregister(&sparcspkr_platform_driver); | 232 | }, |
233 | {}, | ||
234 | }; | ||
187 | 235 | ||
188 | return error; | 236 | static struct of_platform_driver isa_beep_driver = { |
189 | } | 237 | .name = "beep", |
238 | .match_table = isa_beep_match, | ||
239 | .probe = isa_beep_probe, | ||
240 | .remove = sparcspkr_remove, | ||
241 | .shutdown = sparcspkr_shutdown, | ||
242 | }; | ||
190 | 243 | ||
191 | static int __init sparcspkr_init(void) | 244 | static int __init sparcspkr_init(void) |
192 | { | 245 | { |
193 | struct linux_ebus *ebus; | 246 | int err = of_register_driver(&ebus_beep_driver, &ebus_bus_type); |
194 | struct linux_ebus_device *edev; | 247 | |
195 | #ifdef CONFIG_SPARC64 | 248 | if (!err) { |
196 | struct sparc_isa_bridge *isa_br; | 249 | err = of_register_driver(&isa_beep_driver, &isa_bus_type); |
197 | struct sparc_isa_device *isa_dev; | 250 | if (err) |
198 | #endif | 251 | of_unregister_driver(&ebus_beep_driver); |
199 | |||
200 | for_each_ebus(ebus) { | ||
201 | for_each_ebusdev(edev, ebus) { | ||
202 | if (!strcmp(edev->prom_name, "beep")) { | ||
203 | beep_name = "Sparc EBUS Speaker"; | ||
204 | beep_event = ebus_spkr_event; | ||
205 | beep_iobase = edev->resource[0].start; | ||
206 | return sparcspkr_drv_init(); | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | #ifdef CONFIG_SPARC64 | ||
211 | for_each_isa(isa_br) { | ||
212 | for_each_isadev(isa_dev, isa_br) { | ||
213 | /* A hack, the beep device's base lives in | ||
214 | * the DMA isa node. | ||
215 | */ | ||
216 | if (!strcmp(isa_dev->prom_name, "dma")) { | ||
217 | beep_name = "Sparc ISA Speaker"; | ||
218 | beep_event = isa_spkr_event, | ||
219 | beep_iobase = isa_dev->resource.start; | ||
220 | return sparcspkr_drv_init(); | ||
221 | } | ||
222 | } | ||
223 | } | 252 | } |
224 | #endif | ||
225 | 253 | ||
226 | return -ENODEV; | 254 | return err; |
227 | } | 255 | } |
228 | 256 | ||
229 | static void __exit sparcspkr_exit(void) | 257 | static void __exit sparcspkr_exit(void) |
230 | { | 258 | { |
231 | platform_device_unregister(sparcspkr_platform_device); | 259 | of_unregister_driver(&ebus_beep_driver); |
232 | platform_driver_unregister(&sparcspkr_platform_driver); | 260 | of_unregister_driver(&isa_beep_driver); |
233 | } | 261 | } |
234 | 262 | ||
235 | module_init(sparcspkr_init); | 263 | module_init(sparcspkr_init); |
diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h index ed9446f6d7e3..6d66351805a2 100644 --- a/drivers/input/serio/i8042-sparcio.h +++ b/drivers/input/serio/i8042-sparcio.h | |||
@@ -74,7 +74,7 @@ static int __init i8042_platform_init(void) | |||
74 | 74 | ||
75 | for_each_ebus(ebus) { | 75 | for_each_ebus(ebus) { |
76 | for_each_ebusdev(edev, ebus) { | 76 | for_each_ebusdev(edev, ebus) { |
77 | if (!strcmp(edev->prom_name, "8042")) | 77 | if (!strcmp(edev->prom_node->name, "8042")) |
78 | goto edev_found; | 78 | goto edev_found; |
79 | } | 79 | } |
80 | } | 80 | } |
@@ -82,14 +82,14 @@ static int __init i8042_platform_init(void) | |||
82 | 82 | ||
83 | edev_found: | 83 | edev_found: |
84 | for_each_edevchild(edev, child) { | 84 | for_each_edevchild(edev, child) { |
85 | if (!strcmp(child->prom_name, OBP_PS2KBD_NAME1) || | 85 | if (!strcmp(child->prom_node->name, OBP_PS2KBD_NAME1) || |
86 | !strcmp(child->prom_name, OBP_PS2KBD_NAME2)) { | 86 | !strcmp(child->prom_node->name, OBP_PS2KBD_NAME2)) { |
87 | i8042_kbd_irq = child->irqs[0]; | 87 | i8042_kbd_irq = child->irqs[0]; |
88 | kbd_iobase = | 88 | kbd_iobase = |
89 | ioremap(child->resource[0].start, 8); | 89 | ioremap(child->resource[0].start, 8); |
90 | } | 90 | } |
91 | if (!strcmp(child->prom_name, OBP_PS2MS_NAME1) || | 91 | if (!strcmp(child->prom_node->name, OBP_PS2MS_NAME1) || |
92 | !strcmp(child->prom_name, OBP_PS2MS_NAME2)) | 92 | !strcmp(child->prom_node->name, OBP_PS2MS_NAME2)) |
93 | i8042_aux_irq = child->irqs[0]; | 93 | i8042_aux_irq = child->irqs[0]; |
94 | } | 94 | } |
95 | if (i8042_kbd_irq == -1 || | 95 | if (i8042_kbd_irq == -1 || |
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c index 6c86dca62e2a..d9f616fea3d9 100644 --- a/drivers/net/myri_sbus.c +++ b/drivers/net/myri_sbus.c | |||
@@ -1,10 +1,10 @@ | |||
1 | /* myri_sbus.h: MyriCOM MyriNET SBUS card driver. | 1 | /* myri_sbus.c: MyriCOM MyriNET SBUS card driver. |
2 | * | 2 | * |
3 | * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com) | 3 | * Copyright (C) 1996, 1999, 2006 David S. Miller (davem@davemloft.net) |
4 | */ | 4 | */ |
5 | 5 | ||
6 | static char version[] = | 6 | static char version[] = |
7 | "myri_sbus.c:v1.9 12/Sep/99 David S. Miller (davem@redhat.com)\n"; | 7 | "myri_sbus.c:v2.0 June 23, 2006 David S. Miller (davem@davemloft.net)\n"; |
8 | 8 | ||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/config.h> | 10 | #include <linux/config.h> |
@@ -81,10 +81,6 @@ static char version[] = | |||
81 | #define DHDR(x) | 81 | #define DHDR(x) |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | #ifdef MODULE | ||
85 | static struct myri_eth *root_myri_dev; | ||
86 | #endif | ||
87 | |||
88 | static void myri_reset_off(void __iomem *lp, void __iomem *cregs) | 84 | static void myri_reset_off(void __iomem *lp, void __iomem *cregs) |
89 | { | 85 | { |
90 | /* Clear IRQ mask. */ | 86 | /* Clear IRQ mask. */ |
@@ -896,8 +892,9 @@ static void dump_eeprom(struct myri_eth *mp) | |||
896 | } | 892 | } |
897 | #endif | 893 | #endif |
898 | 894 | ||
899 | static int __init myri_ether_init(struct sbus_dev *sdev, int num) | 895 | static int __init myri_ether_init(struct sbus_dev *sdev) |
900 | { | 896 | { |
897 | static int num; | ||
901 | static unsigned version_printed; | 898 | static unsigned version_printed; |
902 | struct net_device *dev; | 899 | struct net_device *dev; |
903 | struct myri_eth *mp; | 900 | struct myri_eth *mp; |
@@ -913,6 +910,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num) | |||
913 | if (version_printed++ == 0) | 910 | if (version_printed++ == 0) |
914 | printk(version); | 911 | printk(version); |
915 | 912 | ||
913 | SET_MODULE_OWNER(dev); | ||
914 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | ||
915 | |||
916 | mp = (struct myri_eth *) dev->priv; | 916 | mp = (struct myri_eth *) dev->priv; |
917 | spin_lock_init(&mp->irq_lock); | 917 | spin_lock_init(&mp->irq_lock); |
918 | mp->myri_sdev = sdev; | 918 | mp->myri_sdev = sdev; |
@@ -1092,10 +1092,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num) | |||
1092 | goto err_free_irq; | 1092 | goto err_free_irq; |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | #ifdef MODULE | 1095 | dev_set_drvdata(&sdev->ofdev.dev, mp); |
1096 | mp->next_module = root_myri_dev; | 1096 | |
1097 | root_myri_dev = mp; | 1097 | num++; |
1098 | #endif | ||
1099 | 1098 | ||
1100 | printk("%s: MyriCOM MyriNET Ethernet ", dev->name); | 1099 | printk("%s: MyriCOM MyriNET Ethernet ", dev->name); |
1101 | 1100 | ||
@@ -1114,61 +1113,68 @@ err: | |||
1114 | return -ENODEV; | 1113 | return -ENODEV; |
1115 | } | 1114 | } |
1116 | 1115 | ||
1117 | static int __init myri_sbus_match(struct sbus_dev *sdev) | ||
1118 | { | ||
1119 | char *name = sdev->prom_name; | ||
1120 | 1116 | ||
1121 | if (!strcmp(name, "MYRICOM,mlanai") || | 1117 | static int __devinit myri_sbus_probe(struct of_device *dev, const struct of_device_id *match) |
1122 | !strcmp(name, "myri")) | 1118 | { |
1123 | return 1; | 1119 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); |
1124 | 1120 | ||
1125 | return 0; | 1121 | return myri_ether_init(sdev); |
1126 | } | 1122 | } |
1127 | 1123 | ||
1128 | static int __init myri_sbus_probe(void) | 1124 | static int __devexit myri_sbus_remove(struct of_device *dev) |
1129 | { | 1125 | { |
1130 | struct sbus_bus *bus; | 1126 | struct myri_eth *mp = dev_get_drvdata(&dev->dev); |
1131 | struct sbus_dev *sdev = NULL; | 1127 | struct net_device *net_dev = mp->dev; |
1132 | static int called; | ||
1133 | int cards = 0, v; | ||
1134 | 1128 | ||
1135 | #ifdef MODULE | 1129 | unregister_netdevice(net_dev); |
1136 | root_myri_dev = NULL; | ||
1137 | #endif | ||
1138 | 1130 | ||
1139 | if (called) | 1131 | free_irq(net_dev->irq, net_dev); |
1140 | return -ENODEV; | 1132 | |
1141 | called++; | 1133 | if (mp->eeprom.cpuvers < CPUVERS_4_0) { |
1142 | 1134 | sbus_iounmap(mp->regs, mp->reg_size); | |
1143 | for_each_sbus(bus) { | 1135 | } else { |
1144 | for_each_sbusdev(sdev, bus) { | 1136 | sbus_iounmap(mp->cregs, PAGE_SIZE); |
1145 | if (myri_sbus_match(sdev)) { | 1137 | sbus_iounmap(mp->lregs, (256 * 1024)); |
1146 | cards++; | 1138 | sbus_iounmap(mp->lanai, (512 * 1024)); |
1147 | DET(("Found myricom myrinet as %s\n", sdev->prom_name)); | ||
1148 | if ((v = myri_ether_init(sdev, (cards - 1)))) | ||
1149 | return v; | ||
1150 | } | ||
1151 | } | ||
1152 | } | 1139 | } |
1153 | if (!cards) | 1140 | |
1154 | return -ENODEV; | 1141 | free_netdev(net_dev); |
1142 | |||
1143 | dev_set_drvdata(&dev->dev, NULL); | ||
1144 | |||
1155 | return 0; | 1145 | return 0; |
1156 | } | 1146 | } |
1157 | 1147 | ||
1158 | static void __exit myri_sbus_cleanup(void) | 1148 | static struct of_device_id myri_sbus_match[] = { |
1149 | { | ||
1150 | .name = "MYRICOM,mlanai", | ||
1151 | }, | ||
1152 | { | ||
1153 | .name = "myri", | ||
1154 | }, | ||
1155 | {}, | ||
1156 | }; | ||
1157 | |||
1158 | MODULE_DEVICE_TABLE(of, myri_sbus_match); | ||
1159 | |||
1160 | static struct of_platform_driver myri_sbus_driver = { | ||
1161 | .name = "myri", | ||
1162 | .match_table = myri_sbus_match, | ||
1163 | .probe = myri_sbus_probe, | ||
1164 | .remove = __devexit_p(myri_sbus_remove), | ||
1165 | }; | ||
1166 | |||
1167 | static int __init myri_sbus_init(void) | ||
1168 | { | ||
1169 | return of_register_driver(&myri_sbus_driver, &sbus_bus_type); | ||
1170 | } | ||
1171 | |||
1172 | static void __exit myri_sbus_exit(void) | ||
1159 | { | 1173 | { |
1160 | #ifdef MODULE | 1174 | of_unregister_driver(&myri_sbus_driver); |
1161 | while (root_myri_dev) { | ||
1162 | struct myri_eth *next = root_myri_dev->next_module; | ||
1163 | |||
1164 | unregister_netdev(root_myri_dev->dev); | ||
1165 | /* this will also free the co-allocated 'root_myri_dev' */ | ||
1166 | free_netdev(root_myri_dev->dev); | ||
1167 | root_myri_dev = next; | ||
1168 | } | ||
1169 | #endif /* MODULE */ | ||
1170 | } | 1175 | } |
1171 | 1176 | ||
1172 | module_init(myri_sbus_probe); | 1177 | module_init(myri_sbus_init); |
1173 | module_exit(myri_sbus_cleanup); | 1178 | module_exit(myri_sbus_exit); |
1179 | |||
1174 | MODULE_LICENSE("GPL"); | 1180 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/net/myri_sbus.h b/drivers/net/myri_sbus.h index 47722f708a41..2f69ef7cdccb 100644 --- a/drivers/net/myri_sbus.h +++ b/drivers/net/myri_sbus.h | |||
@@ -290,7 +290,6 @@ struct myri_eth { | |||
290 | unsigned int reg_size; /* Size of register space. */ | 290 | unsigned int reg_size; /* Size of register space. */ |
291 | unsigned int shmem_base; /* Offset to shared ram. */ | 291 | unsigned int shmem_base; /* Offset to shared ram. */ |
292 | struct sbus_dev *myri_sdev; /* Our SBUS device struct. */ | 292 | struct sbus_dev *myri_sdev; /* Our SBUS device struct. */ |
293 | struct myri_eth *next_module; /* Next in adapter chain. */ | ||
294 | }; | 293 | }; |
295 | 294 | ||
296 | /* We use this to acquire receive skb's that we can DMA directly into. */ | 295 | /* We use this to acquire receive skb's that we can DMA directly into. */ |
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c index cfaf47c63c58..7127f0f36f0e 100644 --- a/drivers/net/sunbmac.c +++ b/drivers/net/sunbmac.c | |||
@@ -72,8 +72,6 @@ MODULE_LICENSE("GPL"); | |||
72 | #define DIRQ(x) | 72 | #define DIRQ(x) |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | static struct bigmac *root_bigmac_dev; | ||
76 | |||
77 | #define DEFAULT_JAMSIZE 4 /* Toe jam */ | 75 | #define DEFAULT_JAMSIZE 4 /* Toe jam */ |
78 | 76 | ||
79 | #define QEC_RESET_TRIES 200 | 77 | #define QEC_RESET_TRIES 200 |
@@ -491,7 +489,7 @@ static void bigmac_tcvr_init(struct bigmac *bp) | |||
491 | } | 489 | } |
492 | } | 490 | } |
493 | 491 | ||
494 | static int bigmac_init(struct bigmac *, int); | 492 | static int bigmac_init_hw(struct bigmac *, int); |
495 | 493 | ||
496 | static int try_next_permutation(struct bigmac *bp, void __iomem *tregs) | 494 | static int try_next_permutation(struct bigmac *bp, void __iomem *tregs) |
497 | { | 495 | { |
@@ -551,7 +549,7 @@ static void bigmac_timer(unsigned long data) | |||
551 | if (ret == -1) { | 549 | if (ret == -1) { |
552 | printk(KERN_ERR "%s: Link down, cable problem?\n", | 550 | printk(KERN_ERR "%s: Link down, cable problem?\n", |
553 | bp->dev->name); | 551 | bp->dev->name); |
554 | ret = bigmac_init(bp, 0); | 552 | ret = bigmac_init_hw(bp, 0); |
555 | if (ret) { | 553 | if (ret) { |
556 | printk(KERN_ERR "%s: Error, cannot re-init the " | 554 | printk(KERN_ERR "%s: Error, cannot re-init the " |
557 | "BigMAC.\n", bp->dev->name); | 555 | "BigMAC.\n", bp->dev->name); |
@@ -621,7 +619,7 @@ static void bigmac_begin_auto_negotiation(struct bigmac *bp) | |||
621 | add_timer(&bp->bigmac_timer); | 619 | add_timer(&bp->bigmac_timer); |
622 | } | 620 | } |
623 | 621 | ||
624 | static int bigmac_init(struct bigmac *bp, int from_irq) | 622 | static int bigmac_init_hw(struct bigmac *bp, int from_irq) |
625 | { | 623 | { |
626 | void __iomem *gregs = bp->gregs; | 624 | void __iomem *gregs = bp->gregs; |
627 | void __iomem *cregs = bp->creg; | 625 | void __iomem *cregs = bp->creg; |
@@ -752,7 +750,7 @@ static void bigmac_is_medium_rare(struct bigmac *bp, u32 qec_status, u32 bmac_st | |||
752 | } | 750 | } |
753 | 751 | ||
754 | printk(" RESET\n"); | 752 | printk(" RESET\n"); |
755 | bigmac_init(bp, 1); | 753 | bigmac_init_hw(bp, 1); |
756 | } | 754 | } |
757 | 755 | ||
758 | /* BigMAC transmit complete service routines. */ | 756 | /* BigMAC transmit complete service routines. */ |
@@ -926,7 +924,7 @@ static int bigmac_open(struct net_device *dev) | |||
926 | return ret; | 924 | return ret; |
927 | } | 925 | } |
928 | init_timer(&bp->bigmac_timer); | 926 | init_timer(&bp->bigmac_timer); |
929 | ret = bigmac_init(bp, 0); | 927 | ret = bigmac_init_hw(bp, 0); |
930 | if (ret) | 928 | if (ret) |
931 | free_irq(dev->irq, bp); | 929 | free_irq(dev->irq, bp); |
932 | return ret; | 930 | return ret; |
@@ -950,7 +948,7 @@ static void bigmac_tx_timeout(struct net_device *dev) | |||
950 | { | 948 | { |
951 | struct bigmac *bp = (struct bigmac *) dev->priv; | 949 | struct bigmac *bp = (struct bigmac *) dev->priv; |
952 | 950 | ||
953 | bigmac_init(bp, 0); | 951 | bigmac_init_hw(bp, 0); |
954 | netif_wake_queue(dev); | 952 | netif_wake_queue(dev); |
955 | } | 953 | } |
956 | 954 | ||
@@ -1104,6 +1102,8 @@ static int __init bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1104 | bp->qec_sdev = qec_sdev; | 1102 | bp->qec_sdev = qec_sdev; |
1105 | bp->bigmac_sdev = qec_sdev->child; | 1103 | bp->bigmac_sdev = qec_sdev->child; |
1106 | 1104 | ||
1105 | SET_NETDEV_DEV(dev, &bp->bigmac_sdev->ofdev.dev); | ||
1106 | |||
1107 | spin_lock_init(&bp->lock); | 1107 | spin_lock_init(&bp->lock); |
1108 | 1108 | ||
1109 | /* Verify the registers we expect, are actually there. */ | 1109 | /* Verify the registers we expect, are actually there. */ |
@@ -1226,11 +1226,7 @@ static int __init bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1226 | goto fail_and_cleanup; | 1226 | goto fail_and_cleanup; |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | /* Put us into the list of instances attached for later driver | 1229 | dev_set_drvdata(&bp->bigmac_sdev->ofdev.dev, bp); |
1230 | * exit. | ||
1231 | */ | ||
1232 | bp->next_module = root_bigmac_dev; | ||
1233 | root_bigmac_dev = bp; | ||
1234 | 1230 | ||
1235 | printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name); | 1231 | printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name); |
1236 | for (i = 0; i < 6; i++) | 1232 | for (i = 0; i < 6; i++) |
@@ -1266,69 +1262,68 @@ fail_and_cleanup: | |||
1266 | /* QEC can be the parent of either QuadEthernet or | 1262 | /* QEC can be the parent of either QuadEthernet or |
1267 | * a BigMAC. We want the latter. | 1263 | * a BigMAC. We want the latter. |
1268 | */ | 1264 | */ |
1269 | static int __init bigmac_match(struct sbus_dev *sdev) | 1265 | static int __devinit bigmac_sbus_probe(struct of_device *dev, const struct of_device_id *match) |
1270 | { | 1266 | { |
1271 | struct sbus_dev *child = sdev->child; | 1267 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); |
1268 | struct device_node *dp = dev->node; | ||
1272 | 1269 | ||
1273 | if (strcmp(sdev->prom_name, "qec") != 0) | 1270 | if (!strcmp(dp->name, "be")) |
1274 | return 0; | 1271 | sdev = sdev->parent; |
1275 | 1272 | ||
1276 | if (child == NULL) | 1273 | return bigmac_ether_init(sdev); |
1277 | return 0; | ||
1278 | |||
1279 | if (strcmp(child->prom_name, "be") != 0) | ||
1280 | return 0; | ||
1281 | |||
1282 | return 1; | ||
1283 | } | 1274 | } |
1284 | 1275 | ||
1285 | static int __init bigmac_probe(void) | 1276 | static int __devexit bigmac_sbus_remove(struct of_device *dev) |
1286 | { | 1277 | { |
1287 | struct sbus_bus *sbus; | 1278 | struct bigmac *bp = dev_get_drvdata(&dev->dev); |
1288 | struct sbus_dev *sdev = NULL; | 1279 | struct net_device *net_dev = bp->dev; |
1289 | static int called; | 1280 | |
1290 | int cards = 0, v; | 1281 | unregister_netdevice(net_dev); |
1291 | 1282 | ||
1292 | root_bigmac_dev = NULL; | 1283 | sbus_iounmap(bp->gregs, GLOB_REG_SIZE); |
1293 | 1284 | sbus_iounmap(bp->creg, CREG_REG_SIZE); | |
1294 | if (called) | 1285 | sbus_iounmap(bp->bregs, BMAC_REG_SIZE); |
1295 | return -ENODEV; | 1286 | sbus_iounmap(bp->tregs, TCVR_REG_SIZE); |
1296 | called++; | 1287 | sbus_free_consistent(bp->bigmac_sdev, |
1297 | 1288 | PAGE_SIZE, | |
1298 | for_each_sbus(sbus) { | 1289 | bp->bmac_block, |
1299 | for_each_sbusdev(sdev, sbus) { | 1290 | bp->bblock_dvma); |
1300 | if (bigmac_match(sdev)) { | 1291 | |
1301 | cards++; | 1292 | free_netdev(net_dev); |
1302 | if ((v = bigmac_ether_init(sdev))) | 1293 | |
1303 | return v; | 1294 | dev_set_drvdata(&dev->dev, NULL); |
1304 | } | 1295 | |
1305 | } | ||
1306 | } | ||
1307 | if (!cards) | ||
1308 | return -ENODEV; | ||
1309 | return 0; | 1296 | return 0; |
1310 | } | 1297 | } |
1311 | 1298 | ||
1312 | static void __exit bigmac_cleanup(void) | 1299 | static struct of_device_id bigmac_sbus_match[] = { |
1313 | { | 1300 | { |
1314 | while (root_bigmac_dev) { | 1301 | .name = "qec", |
1315 | struct bigmac *bp = root_bigmac_dev; | 1302 | }, |
1316 | struct bigmac *bp_nxt = root_bigmac_dev->next_module; | 1303 | { |
1304 | .name = "be", | ||
1305 | }, | ||
1306 | {}, | ||
1307 | }; | ||
1317 | 1308 | ||
1318 | sbus_iounmap(bp->gregs, GLOB_REG_SIZE); | 1309 | MODULE_DEVICE_TABLE(of, bigmac_sbus_match); |
1319 | sbus_iounmap(bp->creg, CREG_REG_SIZE); | ||
1320 | sbus_iounmap(bp->bregs, BMAC_REG_SIZE); | ||
1321 | sbus_iounmap(bp->tregs, TCVR_REG_SIZE); | ||
1322 | sbus_free_consistent(bp->bigmac_sdev, | ||
1323 | PAGE_SIZE, | ||
1324 | bp->bmac_block, | ||
1325 | bp->bblock_dvma); | ||
1326 | 1310 | ||
1327 | unregister_netdev(bp->dev); | 1311 | static struct of_platform_driver bigmac_sbus_driver = { |
1328 | free_netdev(bp->dev); | 1312 | .name = "sunbmac", |
1329 | root_bigmac_dev = bp_nxt; | 1313 | .match_table = bigmac_sbus_match, |
1330 | } | 1314 | .probe = bigmac_sbus_probe, |
1315 | .remove = __devexit_p(bigmac_sbus_remove), | ||
1316 | }; | ||
1317 | |||
1318 | static int __init bigmac_init(void) | ||
1319 | { | ||
1320 | return of_register_driver(&bigmac_sbus_driver, &sbus_bus_type); | ||
1321 | } | ||
1322 | |||
1323 | static void __exit bigmac_exit(void) | ||
1324 | { | ||
1325 | of_unregister_driver(&bigmac_sbus_driver); | ||
1331 | } | 1326 | } |
1332 | 1327 | ||
1333 | module_init(bigmac_probe); | 1328 | module_init(bigmac_init); |
1334 | module_exit(bigmac_cleanup); | 1329 | module_exit(bigmac_exit); |
diff --git a/drivers/net/sunbmac.h b/drivers/net/sunbmac.h index b0dbc5187143..b563d3c2993e 100644 --- a/drivers/net/sunbmac.h +++ b/drivers/net/sunbmac.h | |||
@@ -332,7 +332,6 @@ struct bigmac { | |||
332 | struct sbus_dev *qec_sdev; | 332 | struct sbus_dev *qec_sdev; |
333 | struct sbus_dev *bigmac_sdev; | 333 | struct sbus_dev *bigmac_sdev; |
334 | struct net_device *dev; | 334 | struct net_device *dev; |
335 | struct bigmac *next_module; | ||
336 | }; | 335 | }; |
337 | 336 | ||
338 | /* We use this to acquire receive skb's that we can DMA directly into. */ | 337 | /* We use this to acquire receive skb's that we can DMA directly into. */ |
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 38cd30cb7c75..5248670d29f7 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c | |||
@@ -2880,17 +2880,20 @@ static int __devinit gem_get_device_address(struct gem *gp) | |||
2880 | #if defined(__sparc__) | 2880 | #if defined(__sparc__) |
2881 | struct pci_dev *pdev = gp->pdev; | 2881 | struct pci_dev *pdev = gp->pdev; |
2882 | struct pcidev_cookie *pcp = pdev->sysdata; | 2882 | struct pcidev_cookie *pcp = pdev->sysdata; |
2883 | int node = -1; | 2883 | int use_idprom = 1; |
2884 | 2884 | ||
2885 | if (pcp != NULL) { | 2885 | if (pcp != NULL) { |
2886 | node = pcp->prom_node; | 2886 | unsigned char *addr; |
2887 | if (prom_getproplen(node, "local-mac-address") == 6) | 2887 | int len; |
2888 | prom_getproperty(node, "local-mac-address", | 2888 | |
2889 | dev->dev_addr, 6); | 2889 | addr = of_get_property(pcp->prom_node, "local-mac-address", |
2890 | else | 2890 | &len); |
2891 | node = -1; | 2891 | if (addr && len == 6) { |
2892 | use_idprom = 0; | ||
2893 | memcpy(dev->dev_addr, addr, 6); | ||
2894 | } | ||
2892 | } | 2895 | } |
2893 | if (node == -1) | 2896 | if (use_idprom) |
2894 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); | 2897 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); |
2895 | #elif defined(CONFIG_PPC_PMAC) | 2898 | #elif defined(CONFIG_PPC_PMAC) |
2896 | unsigned char *addr; | 2899 | unsigned char *addr; |
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index bd5d2668a362..c33ead3470db 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* $Id: sunhme.c,v 1.124 2002/01/15 06:25:51 davem Exp $ | 1 | /* sunhme.c: Sparc HME/BigMac 10/100baseT half/full duplex auto switching, |
2 | * sunhme.c: Sparc HME/BigMac 10/100baseT half/full duplex auto switching, | ||
3 | * auto carrier detecting ethernet driver. Also known as the | 2 | * auto carrier detecting ethernet driver. Also known as the |
4 | * "Happy Meal Ethernet" found on SunSwift SBUS cards. | 3 | * "Happy Meal Ethernet" found on SunSwift SBUS cards. |
5 | * | 4 | * |
6 | * Copyright (C) 1996, 1998, 1999, 2002, 2003 David S. Miller (davem@redhat.com) | 5 | * Copyright (C) 1996, 1998, 1999, 2002, 2003, |
6 | 2006 David S. Miller (davem@davemloft.net) | ||
7 | * | 7 | * |
8 | * Changes : | 8 | * Changes : |
9 | * 2000/11/11 Willy Tarreau <willy AT meta-x.org> | 9 | * 2000/11/11 Willy Tarreau <willy AT meta-x.org> |
@@ -40,15 +40,13 @@ | |||
40 | #include <asm/dma.h> | 40 | #include <asm/dma.h> |
41 | #include <asm/byteorder.h> | 41 | #include <asm/byteorder.h> |
42 | 42 | ||
43 | #ifdef __sparc__ | 43 | #ifdef CONFIG_SPARC |
44 | #include <asm/idprom.h> | 44 | #include <asm/idprom.h> |
45 | #include <asm/sbus.h> | 45 | #include <asm/sbus.h> |
46 | #include <asm/openprom.h> | 46 | #include <asm/openprom.h> |
47 | #include <asm/oplib.h> | 47 | #include <asm/oplib.h> |
48 | #include <asm/prom.h> | ||
48 | #include <asm/auxio.h> | 49 | #include <asm/auxio.h> |
49 | #ifndef __sparc_v9__ | ||
50 | #include <asm/io-unit.h> | ||
51 | #endif | ||
52 | #endif | 50 | #endif |
53 | #include <asm/uaccess.h> | 51 | #include <asm/uaccess.h> |
54 | 52 | ||
@@ -57,7 +55,7 @@ | |||
57 | 55 | ||
58 | #ifdef CONFIG_PCI | 56 | #ifdef CONFIG_PCI |
59 | #include <linux/pci.h> | 57 | #include <linux/pci.h> |
60 | #ifdef __sparc__ | 58 | #ifdef CONFIG_SPARC |
61 | #include <asm/pbm.h> | 59 | #include <asm/pbm.h> |
62 | #endif | 60 | #endif |
63 | #endif | 61 | #endif |
@@ -65,9 +63,9 @@ | |||
65 | #include "sunhme.h" | 63 | #include "sunhme.h" |
66 | 64 | ||
67 | #define DRV_NAME "sunhme" | 65 | #define DRV_NAME "sunhme" |
68 | #define DRV_VERSION "2.02" | 66 | #define DRV_VERSION "3.00" |
69 | #define DRV_RELDATE "8/24/03" | 67 | #define DRV_RELDATE "June 23, 2006" |
70 | #define DRV_AUTHOR "David S. Miller (davem@redhat.com)" | 68 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" |
71 | 69 | ||
72 | static char version[] = | 70 | static char version[] = |
73 | DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; | 71 | DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; |
@@ -83,8 +81,6 @@ static int macaddr[6]; | |||
83 | module_param_array(macaddr, int, NULL, 0); | 81 | module_param_array(macaddr, int, NULL, 0); |
84 | MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set"); | 82 | MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set"); |
85 | 83 | ||
86 | static struct happy_meal *root_happy_dev; | ||
87 | |||
88 | #ifdef CONFIG_SBUS | 84 | #ifdef CONFIG_SBUS |
89 | static struct quattro *qfe_sbus_list; | 85 | static struct quattro *qfe_sbus_list; |
90 | #endif | 86 | #endif |
@@ -181,26 +177,6 @@ static __inline__ void tx_dump_ring(struct happy_meal *hp) | |||
181 | #define DEFAULT_IPG2 4 /* For all modes */ | 177 | #define DEFAULT_IPG2 4 /* For all modes */ |
182 | #define DEFAULT_JAMSIZE 4 /* Toe jam */ | 178 | #define DEFAULT_JAMSIZE 4 /* Toe jam */ |
183 | 179 | ||
184 | #if defined(CONFIG_PCI) && defined(MODULE) | ||
185 | /* This happy_pci_ids is declared __initdata because it is only used | ||
186 | as an advisory to depmod. If this is ported to the new PCI interface | ||
187 | where it could be referenced at any time due to hot plugging, | ||
188 | the __initdata reference should be removed. */ | ||
189 | |||
190 | static struct pci_device_id happymeal_pci_ids[] = { | ||
191 | { | ||
192 | .vendor = PCI_VENDOR_ID_SUN, | ||
193 | .device = PCI_DEVICE_ID_SUN_HAPPYMEAL, | ||
194 | .subvendor = PCI_ANY_ID, | ||
195 | .subdevice = PCI_ANY_ID, | ||
196 | }, | ||
197 | { } /* Terminating entry */ | ||
198 | }; | ||
199 | |||
200 | MODULE_DEVICE_TABLE(pci, happymeal_pci_ids); | ||
201 | |||
202 | #endif | ||
203 | |||
204 | /* NOTE: In the descriptor writes one _must_ write the address | 180 | /* NOTE: In the descriptor writes one _must_ write the address |
205 | * member _first_. The card must not be allowed to see | 181 | * member _first_. The card must not be allowed to see |
206 | * the updated descriptor flags until the address is | 182 | * the updated descriptor flags until the address is |
@@ -1610,7 +1586,7 @@ static int happy_meal_init(struct happy_meal *hp) | |||
1610 | HMD(("happy_meal_init: old[%08x] bursts<", | 1586 | HMD(("happy_meal_init: old[%08x] bursts<", |
1611 | hme_read32(hp, gregs + GREG_CFG))); | 1587 | hme_read32(hp, gregs + GREG_CFG))); |
1612 | 1588 | ||
1613 | #ifndef __sparc__ | 1589 | #ifndef CONFIG_SPARC |
1614 | /* It is always PCI and can handle 64byte bursts. */ | 1590 | /* It is always PCI and can handle 64byte bursts. */ |
1615 | hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST64); | 1591 | hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST64); |
1616 | #else | 1592 | #else |
@@ -1647,7 +1623,7 @@ static int happy_meal_init(struct happy_meal *hp) | |||
1647 | HMD(("XXX>")); | 1623 | HMD(("XXX>")); |
1648 | hme_write32(hp, gregs + GREG_CFG, 0); | 1624 | hme_write32(hp, gregs + GREG_CFG, 0); |
1649 | } | 1625 | } |
1650 | #endif /* __sparc__ */ | 1626 | #endif /* CONFIG_SPARC */ |
1651 | 1627 | ||
1652 | /* Turn off interrupts we do not want to hear. */ | 1628 | /* Turn off interrupts we do not want to hear. */ |
1653 | HMD((", enable global interrupts, ")); | 1629 | HMD((", enable global interrupts, ")); |
@@ -2592,14 +2568,10 @@ static void __init quattro_apply_ranges(struct quattro *qp, struct happy_meal *h | |||
2592 | */ | 2568 | */ |
2593 | static struct quattro * __init quattro_sbus_find(struct sbus_dev *goal_sdev) | 2569 | static struct quattro * __init quattro_sbus_find(struct sbus_dev *goal_sdev) |
2594 | { | 2570 | { |
2595 | struct sbus_bus *sbus; | ||
2596 | struct sbus_dev *sdev; | 2571 | struct sbus_dev *sdev; |
2597 | struct quattro *qp; | 2572 | struct quattro *qp; |
2598 | int i; | 2573 | int i; |
2599 | 2574 | ||
2600 | if (qfe_sbus_list == NULL) | ||
2601 | goto found; | ||
2602 | |||
2603 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { | 2575 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { |
2604 | for (i = 0, sdev = qp->quattro_dev; | 2576 | for (i = 0, sdev = qp->quattro_dev; |
2605 | (sdev != NULL) && (i < 4); | 2577 | (sdev != NULL) && (i < 4); |
@@ -2608,17 +2580,7 @@ static struct quattro * __init quattro_sbus_find(struct sbus_dev *goal_sdev) | |||
2608 | return qp; | 2580 | return qp; |
2609 | } | 2581 | } |
2610 | } | 2582 | } |
2611 | for_each_sbus(sbus) { | ||
2612 | for_each_sbusdev(sdev, sbus) { | ||
2613 | if (sdev == goal_sdev) | ||
2614 | goto found; | ||
2615 | } | ||
2616 | } | ||
2617 | |||
2618 | /* Cannot find quattro parent, fail. */ | ||
2619 | return NULL; | ||
2620 | 2583 | ||
2621 | found: | ||
2622 | qp = kmalloc(sizeof(struct quattro), GFP_KERNEL); | 2584 | qp = kmalloc(sizeof(struct quattro), GFP_KERNEL); |
2623 | if (qp != NULL) { | 2585 | if (qp != NULL) { |
2624 | int i; | 2586 | int i; |
@@ -2655,6 +2617,17 @@ static void __init quattro_sbus_register_irqs(void) | |||
2655 | } | 2617 | } |
2656 | } | 2618 | } |
2657 | } | 2619 | } |
2620 | |||
2621 | static void __devexit quattro_sbus_free_irqs(void) | ||
2622 | { | ||
2623 | struct quattro *qp; | ||
2624 | |||
2625 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { | ||
2626 | struct sbus_dev *sdev = qp->quattro_dev; | ||
2627 | |||
2628 | free_irq(sdev->irqs[0], qp); | ||
2629 | } | ||
2630 | } | ||
2658 | #endif /* CONFIG_SBUS */ | 2631 | #endif /* CONFIG_SBUS */ |
2659 | 2632 | ||
2660 | #ifdef CONFIG_PCI | 2633 | #ifdef CONFIG_PCI |
@@ -2689,8 +2662,9 @@ static struct quattro * __init quattro_pci_find(struct pci_dev *pdev) | |||
2689 | #endif /* CONFIG_PCI */ | 2662 | #endif /* CONFIG_PCI */ |
2690 | 2663 | ||
2691 | #ifdef CONFIG_SBUS | 2664 | #ifdef CONFIG_SBUS |
2692 | static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) | 2665 | static int __init happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe) |
2693 | { | 2666 | { |
2667 | struct device_node *dp = sdev->ofdev.node; | ||
2694 | struct quattro *qp = NULL; | 2668 | struct quattro *qp = NULL; |
2695 | struct happy_meal *hp; | 2669 | struct happy_meal *hp; |
2696 | struct net_device *dev; | 2670 | struct net_device *dev; |
@@ -2713,6 +2687,7 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) | |||
2713 | if (!dev) | 2687 | if (!dev) |
2714 | goto err_out; | 2688 | goto err_out; |
2715 | SET_MODULE_OWNER(dev); | 2689 | SET_MODULE_OWNER(dev); |
2690 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | ||
2716 | 2691 | ||
2717 | if (hme_version_printed++ == 0) | 2692 | if (hme_version_printed++ == 0) |
2718 | printk(KERN_INFO "%s", version); | 2693 | printk(KERN_INFO "%s", version); |
@@ -2728,13 +2703,16 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) | |||
2728 | for (i = 0; i < 6; i++) | 2703 | for (i = 0; i < 6; i++) |
2729 | dev->dev_addr[i] = macaddr[i]; | 2704 | dev->dev_addr[i] = macaddr[i]; |
2730 | macaddr[5]++; | 2705 | macaddr[5]++; |
2731 | } else if (qfe_slot != -1 && | ||
2732 | prom_getproplen(sdev->prom_node, | ||
2733 | "local-mac-address") == 6) { | ||
2734 | prom_getproperty(sdev->prom_node, "local-mac-address", | ||
2735 | dev->dev_addr, 6); | ||
2736 | } else { | 2706 | } else { |
2737 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); | 2707 | unsigned char *addr; |
2708 | int len; | ||
2709 | |||
2710 | addr = of_get_property(dp, "local-mac-address", &len); | ||
2711 | |||
2712 | if (qfe_slot != -1 && addr && len == 6) | ||
2713 | memcpy(dev->dev_addr, addr, 6); | ||
2714 | else | ||
2715 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); | ||
2738 | } | 2716 | } |
2739 | 2717 | ||
2740 | hp = dev->priv; | 2718 | hp = dev->priv; |
@@ -2745,9 +2723,8 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) | |||
2745 | 2723 | ||
2746 | err = -ENODEV; | 2724 | err = -ENODEV; |
2747 | if (sdev->num_registers != 5) { | 2725 | if (sdev->num_registers != 5) { |
2748 | printk(KERN_ERR "happymeal: Device does not have 5 regs, it has %d.\n", | 2726 | printk(KERN_ERR "happymeal: Device needs 5 regs, has %d.\n", |
2749 | sdev->num_registers); | 2727 | sdev->num_registers); |
2750 | printk(KERN_ERR "happymeal: Would you like that for here or to go?\n"); | ||
2751 | goto err_out_free_netdev; | 2728 | goto err_out_free_netdev; |
2752 | } | 2729 | } |
2753 | 2730 | ||
@@ -2761,39 +2738,39 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) | |||
2761 | hp->gregs = sbus_ioremap(&sdev->resource[0], 0, | 2738 | hp->gregs = sbus_ioremap(&sdev->resource[0], 0, |
2762 | GREG_REG_SIZE, "HME Global Regs"); | 2739 | GREG_REG_SIZE, "HME Global Regs"); |
2763 | if (!hp->gregs) { | 2740 | if (!hp->gregs) { |
2764 | printk(KERN_ERR "happymeal: Cannot map Happy Meal global registers.\n"); | 2741 | printk(KERN_ERR "happymeal: Cannot map global registers.\n"); |
2765 | goto err_out_free_netdev; | 2742 | goto err_out_free_netdev; |
2766 | } | 2743 | } |
2767 | 2744 | ||
2768 | hp->etxregs = sbus_ioremap(&sdev->resource[1], 0, | 2745 | hp->etxregs = sbus_ioremap(&sdev->resource[1], 0, |
2769 | ETX_REG_SIZE, "HME TX Regs"); | 2746 | ETX_REG_SIZE, "HME TX Regs"); |
2770 | if (!hp->etxregs) { | 2747 | if (!hp->etxregs) { |
2771 | printk(KERN_ERR "happymeal: Cannot map Happy Meal MAC Transmit registers.\n"); | 2748 | printk(KERN_ERR "happymeal: Cannot map MAC TX registers.\n"); |
2772 | goto err_out_iounmap; | 2749 | goto err_out_iounmap; |
2773 | } | 2750 | } |
2774 | 2751 | ||
2775 | hp->erxregs = sbus_ioremap(&sdev->resource[2], 0, | 2752 | hp->erxregs = sbus_ioremap(&sdev->resource[2], 0, |
2776 | ERX_REG_SIZE, "HME RX Regs"); | 2753 | ERX_REG_SIZE, "HME RX Regs"); |
2777 | if (!hp->erxregs) { | 2754 | if (!hp->erxregs) { |
2778 | printk(KERN_ERR "happymeal: Cannot map Happy Meal MAC Receive registers.\n"); | 2755 | printk(KERN_ERR "happymeal: Cannot map MAC RX registers.\n"); |
2779 | goto err_out_iounmap; | 2756 | goto err_out_iounmap; |
2780 | } | 2757 | } |
2781 | 2758 | ||
2782 | hp->bigmacregs = sbus_ioremap(&sdev->resource[3], 0, | 2759 | hp->bigmacregs = sbus_ioremap(&sdev->resource[3], 0, |
2783 | BMAC_REG_SIZE, "HME BIGMAC Regs"); | 2760 | BMAC_REG_SIZE, "HME BIGMAC Regs"); |
2784 | if (!hp->bigmacregs) { | 2761 | if (!hp->bigmacregs) { |
2785 | printk(KERN_ERR "happymeal: Cannot map Happy Meal BIGMAC registers.\n"); | 2762 | printk(KERN_ERR "happymeal: Cannot map BIGMAC registers.\n"); |
2786 | goto err_out_iounmap; | 2763 | goto err_out_iounmap; |
2787 | } | 2764 | } |
2788 | 2765 | ||
2789 | hp->tcvregs = sbus_ioremap(&sdev->resource[4], 0, | 2766 | hp->tcvregs = sbus_ioremap(&sdev->resource[4], 0, |
2790 | TCVR_REG_SIZE, "HME Tranceiver Regs"); | 2767 | TCVR_REG_SIZE, "HME Tranceiver Regs"); |
2791 | if (!hp->tcvregs) { | 2768 | if (!hp->tcvregs) { |
2792 | printk(KERN_ERR "happymeal: Cannot map Happy Meal Tranceiver registers.\n"); | 2769 | printk(KERN_ERR "happymeal: Cannot map TCVR registers.\n"); |
2793 | goto err_out_iounmap; | 2770 | goto err_out_iounmap; |
2794 | } | 2771 | } |
2795 | 2772 | ||
2796 | hp->hm_revision = prom_getintdefault(sdev->prom_node, "hm-rev", 0xff); | 2773 | hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); |
2797 | if (hp->hm_revision == 0xff) | 2774 | if (hp->hm_revision == 0xff) |
2798 | hp->hm_revision = 0xa0; | 2775 | hp->hm_revision = 0xa0; |
2799 | 2776 | ||
@@ -2807,8 +2784,8 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) | |||
2807 | hp->happy_flags |= HFLAG_QUATTRO; | 2784 | hp->happy_flags |= HFLAG_QUATTRO; |
2808 | 2785 | ||
2809 | /* Get the supported DVMA burst sizes from our Happy SBUS. */ | 2786 | /* Get the supported DVMA burst sizes from our Happy SBUS. */ |
2810 | hp->happy_bursts = prom_getintdefault(sdev->bus->prom_node, | 2787 | hp->happy_bursts = of_getintprop_default(sdev->bus->ofdev.node, |
2811 | "burst-sizes", 0x00); | 2788 | "burst-sizes", 0x00); |
2812 | 2789 | ||
2813 | hp->happy_block = sbus_alloc_consistent(hp->happy_dev, | 2790 | hp->happy_block = sbus_alloc_consistent(hp->happy_dev, |
2814 | PAGE_SIZE, | 2791 | PAGE_SIZE, |
@@ -2871,6 +2848,8 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) | |||
2871 | goto err_out_free_consistent; | 2848 | goto err_out_free_consistent; |
2872 | } | 2849 | } |
2873 | 2850 | ||
2851 | dev_set_drvdata(&sdev->ofdev.dev, hp); | ||
2852 | |||
2874 | if (qfe_slot != -1) | 2853 | if (qfe_slot != -1) |
2875 | printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ", | 2854 | printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ", |
2876 | dev->name, qfe_slot); | 2855 | dev->name, qfe_slot); |
@@ -2883,12 +2862,6 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) | |||
2883 | dev->dev_addr[i], i == 5 ? ' ' : ':'); | 2862 | dev->dev_addr[i], i == 5 ? ' ' : ':'); |
2884 | printk("\n"); | 2863 | printk("\n"); |
2885 | 2864 | ||
2886 | /* We are home free at this point, link us in to the happy | ||
2887 | * device list. | ||
2888 | */ | ||
2889 | hp->next_module = root_happy_dev; | ||
2890 | root_happy_dev = hp; | ||
2891 | |||
2892 | return 0; | 2865 | return 0; |
2893 | 2866 | ||
2894 | err_out_free_consistent: | 2867 | err_out_free_consistent: |
@@ -2918,7 +2891,7 @@ err_out: | |||
2918 | #endif | 2891 | #endif |
2919 | 2892 | ||
2920 | #ifdef CONFIG_PCI | 2893 | #ifdef CONFIG_PCI |
2921 | #ifndef __sparc__ | 2894 | #ifndef CONFIG_SPARC |
2922 | static int is_quattro_p(struct pci_dev *pdev) | 2895 | static int is_quattro_p(struct pci_dev *pdev) |
2923 | { | 2896 | { |
2924 | struct pci_dev *busdev = pdev->bus->self; | 2897 | struct pci_dev *busdev = pdev->bus->self; |
@@ -3006,14 +2979,14 @@ static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr) | |||
3006 | get_random_bytes(&dev_addr[3], 3); | 2979 | get_random_bytes(&dev_addr[3], 3); |
3007 | return; | 2980 | return; |
3008 | } | 2981 | } |
3009 | #endif /* !(__sparc__) */ | 2982 | #endif /* !(CONFIG_SPARC) */ |
3010 | 2983 | ||
3011 | static int __init happy_meal_pci_init(struct pci_dev *pdev) | 2984 | static int __devinit happy_meal_pci_probe(struct pci_dev *pdev, |
2985 | const struct pci_device_id *ent) | ||
3012 | { | 2986 | { |
3013 | struct quattro *qp = NULL; | 2987 | struct quattro *qp = NULL; |
3014 | #ifdef __sparc__ | 2988 | #ifdef CONFIG_SPARC |
3015 | struct pcidev_cookie *pcp; | 2989 | struct pcidev_cookie *pcp; |
3016 | int node; | ||
3017 | #endif | 2990 | #endif |
3018 | struct happy_meal *hp; | 2991 | struct happy_meal *hp; |
3019 | struct net_device *dev; | 2992 | struct net_device *dev; |
@@ -3024,15 +2997,14 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev) | |||
3024 | int err; | 2997 | int err; |
3025 | 2998 | ||
3026 | /* Now make sure pci_dev cookie is there. */ | 2999 | /* Now make sure pci_dev cookie is there. */ |
3027 | #ifdef __sparc__ | 3000 | #ifdef CONFIG_SPARC |
3028 | pcp = pdev->sysdata; | 3001 | pcp = pdev->sysdata; |
3029 | if (pcp == NULL || pcp->prom_node == -1) { | 3002 | if (pcp == NULL) { |
3030 | printk(KERN_ERR "happymeal(PCI): Some PCI device info missing\n"); | 3003 | printk(KERN_ERR "happymeal(PCI): Some PCI device info missing\n"); |
3031 | return -ENODEV; | 3004 | return -ENODEV; |
3032 | } | 3005 | } |
3033 | node = pcp->prom_node; | ||
3034 | 3006 | ||
3035 | prom_getstring(node, "name", prom_name, sizeof(prom_name)); | 3007 | strcpy(prom_name, pcp->prom_node->name); |
3036 | #else | 3008 | #else |
3037 | if (is_quattro_p(pdev)) | 3009 | if (is_quattro_p(pdev)) |
3038 | strcpy(prom_name, "SUNW,qfe"); | 3010 | strcpy(prom_name, "SUNW,qfe"); |
@@ -3103,11 +3075,15 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev) | |||
3103 | dev->dev_addr[i] = macaddr[i]; | 3075 | dev->dev_addr[i] = macaddr[i]; |
3104 | macaddr[5]++; | 3076 | macaddr[5]++; |
3105 | } else { | 3077 | } else { |
3106 | #ifdef __sparc__ | 3078 | #ifdef CONFIG_SPARC |
3079 | unsigned char *addr; | ||
3080 | int len; | ||
3081 | |||
3107 | if (qfe_slot != -1 && | 3082 | if (qfe_slot != -1 && |
3108 | prom_getproplen(node, "local-mac-address") == 6) { | 3083 | (addr = of_get_property(pcp->prom_node, |
3109 | prom_getproperty(node, "local-mac-address", | 3084 | "local-mac-address", &len)) != NULL |
3110 | dev->dev_addr, 6); | 3085 | && len == 6) { |
3086 | memcpy(dev->dev_addr, addr, 6); | ||
3111 | } else { | 3087 | } else { |
3112 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); | 3088 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); |
3113 | } | 3089 | } |
@@ -3123,8 +3099,8 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev) | |||
3123 | hp->bigmacregs = (hpreg_base + 0x6000UL); | 3099 | hp->bigmacregs = (hpreg_base + 0x6000UL); |
3124 | hp->tcvregs = (hpreg_base + 0x7000UL); | 3100 | hp->tcvregs = (hpreg_base + 0x7000UL); |
3125 | 3101 | ||
3126 | #ifdef __sparc__ | 3102 | #ifdef CONFIG_SPARC |
3127 | hp->hm_revision = prom_getintdefault(node, "hm-rev", 0xff); | 3103 | hp->hm_revision = of_getintprop_default(pcp->prom_node, "hm-rev", 0xff); |
3128 | if (hp->hm_revision == 0xff) { | 3104 | if (hp->hm_revision == 0xff) { |
3129 | unsigned char prev; | 3105 | unsigned char prev; |
3130 | 3106 | ||
@@ -3148,7 +3124,7 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev) | |||
3148 | /* And of course, indicate this is PCI. */ | 3124 | /* And of course, indicate this is PCI. */ |
3149 | hp->happy_flags |= HFLAG_PCI; | 3125 | hp->happy_flags |= HFLAG_PCI; |
3150 | 3126 | ||
3151 | #ifdef __sparc__ | 3127 | #ifdef CONFIG_SPARC |
3152 | /* Assume PCI happy meals can handle all burst sizes. */ | 3128 | /* Assume PCI happy meals can handle all burst sizes. */ |
3153 | hp->happy_bursts = DMA_BURSTBITS; | 3129 | hp->happy_bursts = DMA_BURSTBITS; |
3154 | #endif | 3130 | #endif |
@@ -3211,6 +3187,8 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev) | |||
3211 | goto err_out_iounmap; | 3187 | goto err_out_iounmap; |
3212 | } | 3188 | } |
3213 | 3189 | ||
3190 | dev_set_drvdata(&pdev->dev, hp); | ||
3191 | |||
3214 | if (!qfe_slot) { | 3192 | if (!qfe_slot) { |
3215 | struct pci_dev *qpdev = qp->quattro_dev; | 3193 | struct pci_dev *qpdev = qp->quattro_dev; |
3216 | 3194 | ||
@@ -3240,12 +3218,6 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev) | |||
3240 | 3218 | ||
3241 | printk("\n"); | 3219 | printk("\n"); |
3242 | 3220 | ||
3243 | /* We are home free at this point, link us in to the happy | ||
3244 | * device list. | ||
3245 | */ | ||
3246 | hp->next_module = root_happy_dev; | ||
3247 | root_happy_dev = hp; | ||
3248 | |||
3249 | return 0; | 3221 | return 0; |
3250 | 3222 | ||
3251 | err_out_iounmap: | 3223 | err_out_iounmap: |
@@ -3263,136 +3235,146 @@ err_out_clear_quattro: | |||
3263 | err_out: | 3235 | err_out: |
3264 | return err; | 3236 | return err; |
3265 | } | 3237 | } |
3266 | #endif | ||
3267 | 3238 | ||
3268 | #ifdef CONFIG_SBUS | 3239 | static void __devexit happy_meal_pci_remove(struct pci_dev *pdev) |
3269 | static int __init happy_meal_sbus_probe(void) | ||
3270 | { | 3240 | { |
3271 | struct sbus_bus *sbus; | 3241 | struct happy_meal *hp = dev_get_drvdata(&pdev->dev); |
3272 | struct sbus_dev *sdev; | 3242 | struct net_device *net_dev = hp->dev; |
3273 | int cards = 0; | 3243 | |
3274 | char model[128]; | 3244 | unregister_netdev(net_dev); |
3275 | 3245 | ||
3276 | for_each_sbus(sbus) { | 3246 | pci_free_consistent(hp->happy_dev, |
3277 | for_each_sbusdev(sdev, sbus) { | 3247 | PAGE_SIZE, |
3278 | char *name = sdev->prom_name; | 3248 | hp->happy_block, |
3279 | 3249 | hp->hblock_dvma); | |
3280 | if (!strcmp(name, "SUNW,hme")) { | 3250 | iounmap(hp->gregs); |
3281 | cards++; | 3251 | pci_release_regions(hp->happy_dev); |
3282 | prom_getstring(sdev->prom_node, "model", | 3252 | |
3283 | model, sizeof(model)); | 3253 | free_netdev(net_dev); |
3284 | if (!strcmp(model, "SUNW,sbus-qfe")) | 3254 | |
3285 | happy_meal_sbus_init(sdev, 1); | 3255 | dev_set_drvdata(&pdev->dev, NULL); |
3286 | else | ||
3287 | happy_meal_sbus_init(sdev, 0); | ||
3288 | } else if (!strcmp(name, "qfe") || | ||
3289 | !strcmp(name, "SUNW,qfe")) { | ||
3290 | cards++; | ||
3291 | happy_meal_sbus_init(sdev, 1); | ||
3292 | } | ||
3293 | } | ||
3294 | } | ||
3295 | if (cards != 0) | ||
3296 | quattro_sbus_register_irqs(); | ||
3297 | return cards; | ||
3298 | } | 3256 | } |
3299 | #endif | ||
3300 | 3257 | ||
3301 | #ifdef CONFIG_PCI | 3258 | static struct pci_device_id happymeal_pci_ids[] = { |
3302 | static int __init happy_meal_pci_probe(void) | 3259 | { |
3260 | .vendor = PCI_VENDOR_ID_SUN, | ||
3261 | .device = PCI_DEVICE_ID_SUN_HAPPYMEAL, | ||
3262 | .subvendor = PCI_ANY_ID, | ||
3263 | .subdevice = PCI_ANY_ID, | ||
3264 | }, | ||
3265 | { } /* Terminating entry */ | ||
3266 | }; | ||
3267 | |||
3268 | MODULE_DEVICE_TABLE(pci, happymeal_pci_ids); | ||
3269 | |||
3270 | static struct pci_driver hme_pci_driver = { | ||
3271 | .name = "hme", | ||
3272 | .id_table = happymeal_pci_ids, | ||
3273 | .probe = happy_meal_pci_probe, | ||
3274 | .remove = __devexit_p(happy_meal_pci_remove), | ||
3275 | }; | ||
3276 | |||
3277 | static int __init happy_meal_pci_init(void) | ||
3303 | { | 3278 | { |
3304 | struct pci_dev *pdev = NULL; | 3279 | return pci_module_init(&hme_pci_driver); |
3305 | int cards = 0; | 3280 | } |
3306 | 3281 | ||
3307 | while ((pdev = pci_find_device(PCI_VENDOR_ID_SUN, | 3282 | static void happy_meal_pci_exit(void) |
3308 | PCI_DEVICE_ID_SUN_HAPPYMEAL, pdev)) != NULL) { | 3283 | { |
3309 | if (pci_enable_device(pdev)) | 3284 | pci_unregister_driver(&hme_pci_driver); |
3310 | continue; | 3285 | |
3311 | pci_set_master(pdev); | 3286 | while (qfe_pci_list) { |
3312 | cards++; | 3287 | struct quattro *qfe = qfe_pci_list; |
3313 | happy_meal_pci_init(pdev); | 3288 | struct quattro *next = qfe->next; |
3289 | |||
3290 | kfree(qfe); | ||
3291 | |||
3292 | qfe_pci_list = next; | ||
3314 | } | 3293 | } |
3315 | return cards; | ||
3316 | } | 3294 | } |
3295 | |||
3317 | #endif | 3296 | #endif |
3318 | 3297 | ||
3319 | static int __init happy_meal_probe(void) | 3298 | #ifdef CONFIG_SBUS |
3299 | static int __devinit hme_sbus_probe(struct of_device *dev, const struct of_device_id *match) | ||
3320 | { | 3300 | { |
3321 | static int called = 0; | 3301 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); |
3322 | int cards; | 3302 | struct device_node *dp = dev->node; |
3303 | char *model = of_get_property(dp, "model", NULL); | ||
3304 | int is_qfe = (match->data != NULL); | ||
3323 | 3305 | ||
3324 | root_happy_dev = NULL; | 3306 | if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) |
3307 | is_qfe = 1; | ||
3325 | 3308 | ||
3326 | if (called) | 3309 | return happy_meal_sbus_probe_one(sdev, is_qfe); |
3327 | return -ENODEV; | 3310 | } |
3328 | called++; | 3311 | |
3312 | static int __devexit hme_sbus_remove(struct of_device *dev) | ||
3313 | { | ||
3314 | struct happy_meal *hp = dev_get_drvdata(&dev->dev); | ||
3315 | struct net_device *net_dev = hp->dev; | ||
3316 | |||
3317 | unregister_netdevice(net_dev); | ||
3318 | |||
3319 | /* XXX qfe parent interrupt... */ | ||
3320 | |||
3321 | sbus_iounmap(hp->gregs, GREG_REG_SIZE); | ||
3322 | sbus_iounmap(hp->etxregs, ETX_REG_SIZE); | ||
3323 | sbus_iounmap(hp->erxregs, ERX_REG_SIZE); | ||
3324 | sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE); | ||
3325 | sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE); | ||
3326 | sbus_free_consistent(hp->happy_dev, | ||
3327 | PAGE_SIZE, | ||
3328 | hp->happy_block, | ||
3329 | hp->hblock_dvma); | ||
3330 | |||
3331 | free_netdev(net_dev); | ||
3332 | |||
3333 | dev_set_drvdata(&dev->dev, NULL); | ||
3329 | 3334 | ||
3330 | cards = 0; | ||
3331 | #ifdef CONFIG_SBUS | ||
3332 | cards += happy_meal_sbus_probe(); | ||
3333 | #endif | ||
3334 | #ifdef CONFIG_PCI | ||
3335 | cards += happy_meal_pci_probe(); | ||
3336 | #endif | ||
3337 | if (!cards) | ||
3338 | return -ENODEV; | ||
3339 | return 0; | 3335 | return 0; |
3340 | } | 3336 | } |
3341 | 3337 | ||
3338 | static struct of_device_id hme_sbus_match[] = { | ||
3339 | { | ||
3340 | .name = "SUNW,hme", | ||
3341 | }, | ||
3342 | { | ||
3343 | .name = "SUNW,qfe", | ||
3344 | .data = (void *) 1, | ||
3345 | }, | ||
3346 | { | ||
3347 | .name = "qfe", | ||
3348 | .data = (void *) 1, | ||
3349 | }, | ||
3350 | {}, | ||
3351 | }; | ||
3342 | 3352 | ||
3343 | static void __exit happy_meal_cleanup_module(void) | 3353 | MODULE_DEVICE_TABLE(of, hme_sbus_match); |
3344 | { | ||
3345 | #ifdef CONFIG_SBUS | ||
3346 | struct quattro *last_seen_qfe = NULL; | ||
3347 | #endif | ||
3348 | 3354 | ||
3349 | while (root_happy_dev) { | 3355 | static struct of_platform_driver hme_sbus_driver = { |
3350 | struct happy_meal *hp = root_happy_dev; | 3356 | .name = "hme", |
3351 | struct happy_meal *next = root_happy_dev->next_module; | 3357 | .match_table = hme_sbus_match, |
3352 | struct net_device *dev = hp->dev; | 3358 | .probe = hme_sbus_probe, |
3359 | .remove = __devexit_p(hme_sbus_remove), | ||
3360 | }; | ||
3353 | 3361 | ||
3354 | /* Unregister netdev before unmapping registers as this | 3362 | static int __init happy_meal_sbus_init(void) |
3355 | * call can end up trying to access those registers. | 3363 | { |
3356 | */ | 3364 | int err; |
3357 | unregister_netdev(dev); | ||
3358 | 3365 | ||
3359 | #ifdef CONFIG_SBUS | 3366 | err = of_register_driver(&hme_sbus_driver, &sbus_bus_type); |
3360 | if (!(hp->happy_flags & HFLAG_PCI)) { | 3367 | if (!err) |
3361 | if (hp->happy_flags & HFLAG_QUATTRO) { | 3368 | quattro_sbus_register_irqs(); |
3362 | if (hp->qfe_parent != last_seen_qfe) { | ||
3363 | free_irq(dev->irq, hp->qfe_parent); | ||
3364 | last_seen_qfe = hp->qfe_parent; | ||
3365 | } | ||
3366 | } | ||
3367 | 3369 | ||
3368 | sbus_iounmap(hp->gregs, GREG_REG_SIZE); | 3370 | return err; |
3369 | sbus_iounmap(hp->etxregs, ETX_REG_SIZE); | 3371 | } |
3370 | sbus_iounmap(hp->erxregs, ERX_REG_SIZE); | ||
3371 | sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE); | ||
3372 | sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE); | ||
3373 | sbus_free_consistent(hp->happy_dev, | ||
3374 | PAGE_SIZE, | ||
3375 | hp->happy_block, | ||
3376 | hp->hblock_dvma); | ||
3377 | } | ||
3378 | #endif | ||
3379 | #ifdef CONFIG_PCI | ||
3380 | if ((hp->happy_flags & HFLAG_PCI)) { | ||
3381 | pci_free_consistent(hp->happy_dev, | ||
3382 | PAGE_SIZE, | ||
3383 | hp->happy_block, | ||
3384 | hp->hblock_dvma); | ||
3385 | iounmap(hp->gregs); | ||
3386 | pci_release_regions(hp->happy_dev); | ||
3387 | } | ||
3388 | #endif | ||
3389 | free_netdev(dev); | ||
3390 | 3372 | ||
3391 | root_happy_dev = next; | 3373 | static void happy_meal_sbus_exit(void) |
3392 | } | 3374 | { |
3375 | of_unregister_driver(&hme_sbus_driver); | ||
3376 | quattro_sbus_free_irqs(); | ||
3393 | 3377 | ||
3394 | /* Now cleanup the quattro lists. */ | ||
3395 | #ifdef CONFIG_SBUS | ||
3396 | while (qfe_sbus_list) { | 3378 | while (qfe_sbus_list) { |
3397 | struct quattro *qfe = qfe_sbus_list; | 3379 | struct quattro *qfe = qfe_sbus_list; |
3398 | struct quattro *next = qfe->next; | 3380 | struct quattro *next = qfe->next; |
@@ -3401,18 +3383,39 @@ static void __exit happy_meal_cleanup_module(void) | |||
3401 | 3383 | ||
3402 | qfe_sbus_list = next; | 3384 | qfe_sbus_list = next; |
3403 | } | 3385 | } |
3386 | } | ||
3404 | #endif | 3387 | #endif |
3405 | #ifdef CONFIG_PCI | ||
3406 | while (qfe_pci_list) { | ||
3407 | struct quattro *qfe = qfe_pci_list; | ||
3408 | struct quattro *next = qfe->next; | ||
3409 | 3388 | ||
3410 | kfree(qfe); | 3389 | static int __init happy_meal_probe(void) |
3390 | { | ||
3391 | int err = 0; | ||
3411 | 3392 | ||
3412 | qfe_pci_list = next; | 3393 | #ifdef CONFIG_SBUS |
3394 | err = happy_meal_sbus_init(); | ||
3395 | #endif | ||
3396 | #ifdef CONFIG_PCI | ||
3397 | if (!err) { | ||
3398 | err = happy_meal_pci_init(); | ||
3399 | #ifdef CONFIG_SBUS | ||
3400 | if (err) | ||
3401 | happy_meal_sbus_exit(); | ||
3402 | #endif | ||
3413 | } | 3403 | } |
3414 | #endif | 3404 | #endif |
3405 | |||
3406 | return err; | ||
3407 | } | ||
3408 | |||
3409 | |||
3410 | static void __exit happy_meal_exit(void) | ||
3411 | { | ||
3412 | #ifdef CONFIG_SBUS | ||
3413 | happy_meal_sbus_exit(); | ||
3414 | #endif | ||
3415 | #ifdef CONFIG_PCI | ||
3416 | happy_meal_pci_exit(); | ||
3417 | #endif | ||
3415 | } | 3418 | } |
3416 | 3419 | ||
3417 | module_init(happy_meal_probe); | 3420 | module_init(happy_meal_probe); |
3418 | module_exit(happy_meal_cleanup_module); | 3421 | module_exit(happy_meal_exit); |
diff --git a/drivers/net/sunhme.h b/drivers/net/sunhme.h index 34e9f953cea4..9b7ccaeeee89 100644 --- a/drivers/net/sunhme.h +++ b/drivers/net/sunhme.h | |||
@@ -461,7 +461,6 @@ struct happy_meal { | |||
461 | struct net_device *dev; /* Backpointer */ | 461 | struct net_device *dev; /* Backpointer */ |
462 | struct quattro *qfe_parent; /* For Quattro cards */ | 462 | struct quattro *qfe_parent; /* For Quattro cards */ |
463 | int qfe_ent; /* Which instance on quattro */ | 463 | int qfe_ent; /* Which instance on quattro */ |
464 | struct happy_meal *next_module; | ||
465 | }; | 464 | }; |
466 | 465 | ||
467 | /* Here are the happy flags. */ | 466 | /* Here are the happy flags. */ |
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c index 6381243d8d00..2c239ab63a80 100644 --- a/drivers/net/sunlance.c +++ b/drivers/net/sunlance.c | |||
@@ -266,7 +266,6 @@ struct lance_private { | |||
266 | char *name; | 266 | char *name; |
267 | dma_addr_t init_block_dvma; | 267 | dma_addr_t init_block_dvma; |
268 | struct net_device *dev; /* Backpointer */ | 268 | struct net_device *dev; /* Backpointer */ |
269 | struct lance_private *next_module; | ||
270 | struct sbus_dev *sdev; | 269 | struct sbus_dev *sdev; |
271 | struct timer_list multicast_timer; | 270 | struct timer_list multicast_timer; |
272 | }; | 271 | }; |
@@ -298,8 +297,6 @@ int sparc_lance_debug = 2; | |||
298 | 297 | ||
299 | #define LANCE_ADDR(x) ((long)(x) & ~0xff000000) | 298 | #define LANCE_ADDR(x) ((long)(x) & ~0xff000000) |
300 | 299 | ||
301 | static struct lance_private *root_lance_dev; | ||
302 | |||
303 | /* Load the CSR registers */ | 300 | /* Load the CSR registers */ |
304 | static void load_csrs(struct lance_private *lp) | 301 | static void load_csrs(struct lance_private *lp) |
305 | { | 302 | { |
@@ -1327,9 +1324,9 @@ static struct ethtool_ops sparc_lance_ethtool_ops = { | |||
1327 | .get_link = sparc_lance_get_link, | 1324 | .get_link = sparc_lance_get_link, |
1328 | }; | 1325 | }; |
1329 | 1326 | ||
1330 | static int __init sparc_lance_init(struct sbus_dev *sdev, | 1327 | static int __init sparc_lance_probe_one(struct sbus_dev *sdev, |
1331 | struct sbus_dma *ledma, | 1328 | struct sbus_dma *ledma, |
1332 | struct sbus_dev *lebuffer) | 1329 | struct sbus_dev *lebuffer) |
1333 | { | 1330 | { |
1334 | static unsigned version_printed; | 1331 | static unsigned version_printed; |
1335 | struct net_device *dev; | 1332 | struct net_device *dev; |
@@ -1473,6 +1470,7 @@ no_link_test: | |||
1473 | 1470 | ||
1474 | lp->dev = dev; | 1471 | lp->dev = dev; |
1475 | SET_MODULE_OWNER(dev); | 1472 | SET_MODULE_OWNER(dev); |
1473 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | ||
1476 | dev->open = &lance_open; | 1474 | dev->open = &lance_open; |
1477 | dev->stop = &lance_close; | 1475 | dev->stop = &lance_close; |
1478 | dev->hard_start_xmit = &lance_start_xmit; | 1476 | dev->hard_start_xmit = &lance_start_xmit; |
@@ -1500,8 +1498,7 @@ no_link_test: | |||
1500 | goto fail; | 1498 | goto fail; |
1501 | } | 1499 | } |
1502 | 1500 | ||
1503 | lp->next_module = root_lance_dev; | 1501 | dev_set_drvdata(&sdev->ofdev.dev, lp); |
1504 | root_lance_dev = lp; | ||
1505 | 1502 | ||
1506 | printk(KERN_INFO "%s: LANCE ", dev->name); | 1503 | printk(KERN_INFO "%s: LANCE ", dev->name); |
1507 | 1504 | ||
@@ -1536,88 +1533,112 @@ static inline struct sbus_dma *find_ledma(struct sbus_dev *sdev) | |||
1536 | #include <asm/machines.h> | 1533 | #include <asm/machines.h> |
1537 | 1534 | ||
1538 | /* Find all the lance cards on the system and initialize them */ | 1535 | /* Find all the lance cards on the system and initialize them */ |
1539 | static int __init sparc_lance_probe(void) | 1536 | static struct sbus_dev sun4_sdev; |
1537 | static int __init sparc_lance_init(void) | ||
1540 | { | 1538 | { |
1541 | static struct sbus_dev sdev; | ||
1542 | static int called; | ||
1543 | |||
1544 | root_lance_dev = NULL; | ||
1545 | |||
1546 | if (called) | ||
1547 | return -ENODEV; | ||
1548 | called++; | ||
1549 | |||
1550 | if ((idprom->id_machtype == (SM_SUN4|SM_4_330)) || | 1539 | if ((idprom->id_machtype == (SM_SUN4|SM_4_330)) || |
1551 | (idprom->id_machtype == (SM_SUN4|SM_4_470))) { | 1540 | (idprom->id_machtype == (SM_SUN4|SM_4_470))) { |
1552 | memset(&sdev, 0, sizeof(sdev)); | 1541 | memset(&sun4_sdev, 0, sizeof(sdev)); |
1553 | sdev.reg_addrs[0].phys_addr = sun4_eth_physaddr; | 1542 | sun4_sdev.reg_addrs[0].phys_addr = sun4_eth_physaddr; |
1554 | sdev.irqs[0] = 6; | 1543 | sun4_sdev.irqs[0] = 6; |
1555 | return sparc_lance_init(&sdev, NULL, NULL); | 1544 | return sparc_lance_probe_one(&sun4_sdev, NULL, NULL); |
1556 | } | 1545 | } |
1557 | return -ENODEV; | 1546 | return -ENODEV; |
1558 | } | 1547 | } |
1559 | 1548 | ||
1560 | #else /* !CONFIG_SUN4 */ | 1549 | static int __exit sunlance_sun4_remove(void) |
1561 | |||
1562 | /* Find all the lance cards on the system and initialize them */ | ||
1563 | static int __init sparc_lance_probe(void) | ||
1564 | { | 1550 | { |
1565 | struct sbus_bus *bus; | 1551 | struct lance_private *lp = dev_get_drvdata(&sun4_sdev->dev); |
1566 | struct sbus_dev *sdev = NULL; | 1552 | struct net_device *net_dev = lp->dev; |
1567 | struct sbus_dma *ledma = NULL; | 1553 | |
1568 | static int called; | 1554 | unregister_netdevice(net_dev); |
1569 | int cards = 0, v; | 1555 | |
1570 | 1556 | lance_free_hwresources(root_lance_dev); | |
1571 | root_lance_dev = NULL; | 1557 | |
1572 | 1558 | free_netdev(net_dev); | |
1573 | if (called) | 1559 | |
1574 | return -ENODEV; | 1560 | dev_set_drvdata(&sun4_sdev->dev, NULL); |
1575 | called++; | 1561 | |
1576 | |||
1577 | for_each_sbus (bus) { | ||
1578 | for_each_sbusdev (sdev, bus) { | ||
1579 | if (strcmp(sdev->prom_name, "le") == 0) { | ||
1580 | cards++; | ||
1581 | if ((v = sparc_lance_init(sdev, NULL, NULL))) | ||
1582 | return v; | ||
1583 | continue; | ||
1584 | } | ||
1585 | if (strcmp(sdev->prom_name, "ledma") == 0) { | ||
1586 | cards++; | ||
1587 | ledma = find_ledma(sdev); | ||
1588 | if ((v = sparc_lance_init(sdev->child, | ||
1589 | ledma, NULL))) | ||
1590 | return v; | ||
1591 | continue; | ||
1592 | } | ||
1593 | if (strcmp(sdev->prom_name, "lebuffer") == 0){ | ||
1594 | cards++; | ||
1595 | if ((v = sparc_lance_init(sdev->child, | ||
1596 | NULL, sdev))) | ||
1597 | return v; | ||
1598 | continue; | ||
1599 | } | ||
1600 | } /* for each sbusdev */ | ||
1601 | } /* for each sbus */ | ||
1602 | if (!cards) | ||
1603 | return -ENODEV; | ||
1604 | return 0; | 1562 | return 0; |
1605 | } | 1563 | } |
1606 | #endif /* !CONFIG_SUN4 */ | ||
1607 | 1564 | ||
1608 | static void __exit sparc_lance_cleanup(void) | 1565 | #else /* !CONFIG_SUN4 */ |
1566 | |||
1567 | static int __devinit sunlance_sbus_probe(struct of_device *dev, const struct of_device_id *match) | ||
1609 | { | 1568 | { |
1610 | struct lance_private *lp; | 1569 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); |
1570 | struct device_node *dp = dev->node; | ||
1571 | int err; | ||
1572 | |||
1573 | if (!strcmp(dp->name, "le")) { | ||
1574 | err = sparc_lance_probe_one(sdev, NULL, NULL); | ||
1575 | } else if (!strcmp(dp->name, "ledma")) { | ||
1576 | struct sbus_dma *ledma = find_ledma(sdev); | ||
1611 | 1577 | ||
1612 | while (root_lance_dev) { | 1578 | err = sparc_lance_probe_one(sdev->child, ledma, NULL); |
1613 | lp = root_lance_dev->next_module; | 1579 | } else { |
1580 | BUG_ON(strcmp(dp->name, "lebuffer")); | ||
1614 | 1581 | ||
1615 | unregister_netdev(root_lance_dev->dev); | 1582 | err = sparc_lance_probe_one(sdev->child, NULL, sdev); |
1616 | lance_free_hwresources(root_lance_dev); | ||
1617 | free_netdev(root_lance_dev->dev); | ||
1618 | root_lance_dev = lp; | ||
1619 | } | 1583 | } |
1584 | |||
1585 | return err; | ||
1586 | } | ||
1587 | |||
1588 | static int __devexit sunlance_sbus_remove(struct of_device *dev) | ||
1589 | { | ||
1590 | struct lance_private *lp = dev_get_drvdata(&dev->dev); | ||
1591 | struct net_device *net_dev = lp->dev; | ||
1592 | |||
1593 | unregister_netdevice(net_dev); | ||
1594 | |||
1595 | lance_free_hwresources(lp); | ||
1596 | |||
1597 | free_netdev(net_dev); | ||
1598 | |||
1599 | dev_set_drvdata(&dev->dev, NULL); | ||
1600 | |||
1601 | return 0; | ||
1602 | } | ||
1603 | |||
1604 | static struct of_device_id sunlance_sbus_match[] = { | ||
1605 | { | ||
1606 | .name = "le", | ||
1607 | }, | ||
1608 | { | ||
1609 | .name = "ledma", | ||
1610 | }, | ||
1611 | { | ||
1612 | .name = "lebuffer", | ||
1613 | }, | ||
1614 | {}, | ||
1615 | }; | ||
1616 | |||
1617 | MODULE_DEVICE_TABLE(of, sunlance_sbus_match); | ||
1618 | |||
1619 | static struct of_platform_driver sunlance_sbus_driver = { | ||
1620 | .name = "sunlance", | ||
1621 | .match_table = sunlance_sbus_match, | ||
1622 | .probe = sunlance_sbus_probe, | ||
1623 | .remove = __devexit_p(sunlance_sbus_remove), | ||
1624 | }; | ||
1625 | |||
1626 | |||
1627 | /* Find all the lance cards on the system and initialize them */ | ||
1628 | static int __init sparc_lance_init(void) | ||
1629 | { | ||
1630 | return of_register_driver(&sunlance_sbus_driver, &sbus_bus_type); | ||
1631 | } | ||
1632 | #endif /* !CONFIG_SUN4 */ | ||
1633 | |||
1634 | static void __exit sparc_lance_exit(void) | ||
1635 | { | ||
1636 | #ifdef CONFIG_SUN4 | ||
1637 | sunlance_sun4_remove(); | ||
1638 | #else | ||
1639 | of_unregister_driver(&sunlance_sbus_driver); | ||
1640 | #endif | ||
1620 | } | 1641 | } |
1621 | 1642 | ||
1622 | module_init(sparc_lance_probe); | 1643 | module_init(sparc_lance_init); |
1623 | module_exit(sparc_lance_cleanup); | 1644 | module_exit(sparc_lance_exit); |
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c index 1f2323be60d4..9da6d5b87173 100644 --- a/drivers/net/sunqe.c +++ b/drivers/net/sunqe.c | |||
@@ -1,10 +1,9 @@ | |||
1 | /* $Id: sunqe.c,v 1.55 2002/01/15 06:48:55 davem Exp $ | 1 | /* sunqe.c: Sparc QuadEthernet 10baseT SBUS card driver. |
2 | * sunqe.c: Sparc QuadEthernet 10baseT SBUS card driver. | ||
3 | * Once again I am out to prove that every ethernet | 2 | * Once again I am out to prove that every ethernet |
4 | * controller out there can be most efficiently programmed | 3 | * controller out there can be most efficiently programmed |
5 | * if you make it look like a LANCE. | 4 | * if you make it look like a LANCE. |
6 | * | 5 | * |
7 | * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com) | 6 | * Copyright (C) 1996, 1999, 2003, 2006 David S. Miller (davem@davemloft.net) |
8 | */ | 7 | */ |
9 | 8 | ||
10 | #include <linux/module.h> | 9 | #include <linux/module.h> |
@@ -41,9 +40,9 @@ | |||
41 | #include "sunqe.h" | 40 | #include "sunqe.h" |
42 | 41 | ||
43 | #define DRV_NAME "sunqe" | 42 | #define DRV_NAME "sunqe" |
44 | #define DRV_VERSION "3.0" | 43 | #define DRV_VERSION "4.0" |
45 | #define DRV_RELDATE "8/24/03" | 44 | #define DRV_RELDATE "June 23, 2006" |
46 | #define DRV_AUTHOR "David S. Miller (davem@redhat.com)" | 45 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" |
47 | 46 | ||
48 | static char version[] = | 47 | static char version[] = |
49 | DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; | 48 | DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; |
@@ -755,298 +754,269 @@ static inline void qec_init_once(struct sunqec *qecp, struct sbus_dev *qsdev) | |||
755 | qecp->gregs + GLOB_RSIZE); | 754 | qecp->gregs + GLOB_RSIZE); |
756 | } | 755 | } |
757 | 756 | ||
758 | /* Four QE's per QEC card. */ | 757 | static u8 __init qec_get_burst(struct device_node *dp) |
759 | static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev) | ||
760 | { | 758 | { |
761 | static unsigned version_printed; | ||
762 | struct net_device *qe_devs[4]; | ||
763 | struct sunqe *qeps[4]; | ||
764 | struct sbus_dev *qesdevs[4]; | ||
765 | struct sbus_dev *child; | ||
766 | struct sunqec *qecp = NULL; | ||
767 | u8 bsizes, bsizes_more; | 759 | u8 bsizes, bsizes_more; |
768 | int i, j, res = -ENOMEM; | ||
769 | 760 | ||
770 | for (i = 0; i < 4; i++) { | 761 | /* Find and set the burst sizes for the QEC, since it |
771 | qe_devs[i] = alloc_etherdev(sizeof(struct sunqe)); | 762 | * does the actual dma for all 4 channels. |
772 | if (!qe_devs[i]) | 763 | */ |
773 | goto out; | 764 | bsizes = of_getintprop_default(dp, "burst-sizes", 0xff); |
774 | } | 765 | bsizes &= 0xff; |
766 | bsizes_more = of_getintprop_default(dp->parent, "burst-sizes", 0xff); | ||
775 | 767 | ||
776 | if (version_printed++ == 0) | 768 | if (bsizes_more != 0xff) |
777 | printk(KERN_INFO "%s", version); | 769 | bsizes &= bsizes_more; |
770 | if (bsizes == 0xff || (bsizes & DMA_BURST16) == 0 || | ||
771 | (bsizes & DMA_BURST32)==0) | ||
772 | bsizes = (DMA_BURST32 - 1); | ||
778 | 773 | ||
779 | for (i = 0; i < 4; i++) { | 774 | return bsizes; |
780 | qeps[i] = (struct sunqe *) qe_devs[i]->priv; | 775 | } |
781 | for (j = 0; j < 6; j++) | ||
782 | qe_devs[i]->dev_addr[j] = idprom->id_ethaddr[j]; | ||
783 | qeps[i]->channel = i; | ||
784 | spin_lock_init(&qeps[i]->lock); | ||
785 | } | ||
786 | 776 | ||
787 | qecp = kmalloc(sizeof(struct sunqec), GFP_KERNEL); | 777 | static struct sunqec * __init get_qec(struct sbus_dev *child_sdev) |
788 | if (qecp == NULL) | 778 | { |
789 | goto out1; | 779 | struct sbus_dev *qec_sdev = child_sdev->parent; |
790 | qecp->qec_sdev = sdev; | 780 | struct sunqec *qecp; |
791 | 781 | ||
792 | for (i = 0; i < 4; i++) { | 782 | for (qecp = root_qec_dev; qecp; qecp = qecp->next_module) { |
793 | qecp->qes[i] = qeps[i]; | 783 | if (qecp->qec_sdev == qec_sdev) |
794 | qeps[i]->dev = qe_devs[i]; | 784 | break; |
795 | qeps[i]->parent = qecp; | ||
796 | } | 785 | } |
786 | if (!qecp) { | ||
787 | qecp = kzalloc(sizeof(struct sunqec), GFP_KERNEL); | ||
788 | if (qecp) { | ||
789 | u32 ctrl; | ||
790 | |||
791 | qecp->qec_sdev = qec_sdev; | ||
792 | qecp->gregs = sbus_ioremap(&qec_sdev->resource[0], 0, | ||
793 | GLOB_REG_SIZE, | ||
794 | "QEC Global Registers"); | ||
795 | if (!qecp->gregs) | ||
796 | goto fail; | ||
797 | |||
798 | /* Make sure the QEC is in MACE mode. */ | ||
799 | ctrl = sbus_readl(qecp->gregs + GLOB_CTRL); | ||
800 | ctrl &= 0xf0000000; | ||
801 | if (ctrl != GLOB_CTRL_MMODE) { | ||
802 | printk(KERN_ERR "qec: Not in MACE mode!\n"); | ||
803 | goto fail; | ||
804 | } | ||
797 | 805 | ||
798 | res = -ENODEV; | 806 | if (qec_global_reset(qecp->gregs)) |
807 | goto fail; | ||
799 | 808 | ||
800 | for (i = 0, child = sdev->child; i < 4; i++, child = child->next) { | 809 | qecp->qec_bursts = qec_get_burst(qec_sdev->ofdev.node); |
801 | /* Link in channel */ | ||
802 | j = prom_getintdefault(child->prom_node, "channel#", -1); | ||
803 | if (j == -1) | ||
804 | goto out2; | ||
805 | qesdevs[j] = child; | ||
806 | } | ||
807 | 810 | ||
808 | for (i = 0; i < 4; i++) | 811 | qec_init_once(qecp, qec_sdev); |
809 | qeps[i]->qe_sdev = qesdevs[i]; | ||
810 | 812 | ||
811 | /* Now map in the registers, QEC globals first. */ | 813 | if (request_irq(qec_sdev->irqs[0], &qec_interrupt, |
812 | qecp->gregs = sbus_ioremap(&sdev->resource[0], 0, | 814 | SA_SHIRQ, "qec", (void *) qecp)) { |
813 | GLOB_REG_SIZE, "QEC Global Registers"); | 815 | printk(KERN_ERR "qec: Can't register irq.\n"); |
814 | if (!qecp->gregs) { | 816 | goto fail; |
815 | printk(KERN_ERR "QuadEther: Cannot map QEC global registers.\n"); | 817 | } |
816 | goto out2; | ||
817 | } | ||
818 | 818 | ||
819 | /* Make sure the QEC is in MACE mode. */ | 819 | qecp->next_module = root_qec_dev; |
820 | if ((sbus_readl(qecp->gregs + GLOB_CTRL) & 0xf0000000) != GLOB_CTRL_MMODE) { | 820 | root_qec_dev = qecp; |
821 | printk(KERN_ERR "QuadEther: AIEEE, QEC is not in MACE mode!\n"); | 821 | } |
822 | goto out3; | ||
823 | } | 822 | } |
824 | 823 | ||
825 | /* Reset the QEC. */ | 824 | return qecp; |
826 | if (qec_global_reset(qecp->gregs)) | ||
827 | goto out3; | ||
828 | 825 | ||
829 | /* Find and set the burst sizes for the QEC, since it does | 826 | fail: |
830 | * the actual dma for all 4 channels. | 827 | if (qecp->gregs) |
831 | */ | 828 | sbus_iounmap(qecp->gregs, GLOB_REG_SIZE); |
832 | bsizes = prom_getintdefault(sdev->prom_node, "burst-sizes", 0xff); | 829 | kfree(qecp); |
833 | bsizes &= 0xff; | 830 | return NULL; |
834 | bsizes_more = prom_getintdefault(sdev->bus->prom_node, "burst-sizes", 0xff); | 831 | } |
835 | 832 | ||
836 | if (bsizes_more != 0xff) | 833 | static int __init qec_ether_init(struct sbus_dev *sdev) |
837 | bsizes &= bsizes_more; | 834 | { |
838 | if (bsizes == 0xff || (bsizes & DMA_BURST16) == 0 || | 835 | static unsigned version_printed; |
839 | (bsizes & DMA_BURST32)==0) | 836 | struct net_device *dev; |
840 | bsizes = (DMA_BURST32 - 1); | 837 | struct sunqe *qe; |
838 | struct sunqec *qecp; | ||
839 | int i, res; | ||
841 | 840 | ||
842 | qecp->qec_bursts = bsizes; | 841 | if (version_printed++ == 0) |
842 | printk(KERN_INFO "%s", version); | ||
843 | 843 | ||
844 | /* Perform one time QEC initialization, we never touch the QEC | 844 | dev = alloc_etherdev(sizeof(struct sunqe)); |
845 | * globals again after this. | 845 | if (!dev) |
846 | */ | 846 | return -ENOMEM; |
847 | qec_init_once(qecp, sdev); | ||
848 | |||
849 | for (i = 0; i < 4; i++) { | ||
850 | struct sunqe *qe = qeps[i]; | ||
851 | /* Map in QEC per-channel control registers. */ | ||
852 | qe->qcregs = sbus_ioremap(&qe->qe_sdev->resource[0], 0, | ||
853 | CREG_REG_SIZE, "QEC Channel Registers"); | ||
854 | if (!qe->qcregs) { | ||
855 | printk(KERN_ERR "QuadEther: Cannot map QE %d's channel registers.\n", i); | ||
856 | goto out4; | ||
857 | } | ||
858 | 847 | ||
859 | /* Map in per-channel AMD MACE registers. */ | 848 | qe = netdev_priv(dev); |
860 | qe->mregs = sbus_ioremap(&qe->qe_sdev->resource[1], 0, | ||
861 | MREGS_REG_SIZE, "QE MACE Registers"); | ||
862 | if (!qe->mregs) { | ||
863 | printk(KERN_ERR "QuadEther: Cannot map QE %d's MACE registers.\n", i); | ||
864 | goto out4; | ||
865 | } | ||
866 | 849 | ||
867 | qe->qe_block = sbus_alloc_consistent(qe->qe_sdev, | 850 | i = of_getintprop_default(sdev->ofdev.node, "channel#", -1); |
868 | PAGE_SIZE, | 851 | if (i == -1) { |
869 | &qe->qblock_dvma); | 852 | struct sbus_dev *td = sdev->parent->child; |
870 | qe->buffers = sbus_alloc_consistent(qe->qe_sdev, | 853 | i = 0; |
871 | sizeof(struct sunqe_buffers), | 854 | while (td != sdev) { |
872 | &qe->buffers_dvma); | 855 | td = td->next; |
873 | if (qe->qe_block == NULL || qe->qblock_dvma == 0 || | 856 | i++; |
874 | qe->buffers == NULL || qe->buffers_dvma == 0) { | ||
875 | goto out4; | ||
876 | } | 857 | } |
877 | |||
878 | /* Stop this QE. */ | ||
879 | qe_stop(qe); | ||
880 | } | 858 | } |
859 | qe->channel = i; | ||
860 | spin_lock_init(&qe->lock); | ||
861 | |||
862 | res = -ENODEV; | ||
863 | qecp = get_qec(sdev); | ||
864 | if (!qecp) | ||
865 | goto fail; | ||
881 | 866 | ||
882 | for (i = 0; i < 4; i++) { | 867 | qecp->qes[qe->channel] = qe; |
883 | SET_MODULE_OWNER(qe_devs[i]); | 868 | qe->dev = dev; |
884 | qe_devs[i]->open = qe_open; | 869 | qe->parent = qecp; |
885 | qe_devs[i]->stop = qe_close; | 870 | qe->qe_sdev = sdev; |
886 | qe_devs[i]->hard_start_xmit = qe_start_xmit; | ||
887 | qe_devs[i]->get_stats = qe_get_stats; | ||
888 | qe_devs[i]->set_multicast_list = qe_set_multicast; | ||
889 | qe_devs[i]->tx_timeout = qe_tx_timeout; | ||
890 | qe_devs[i]->watchdog_timeo = 5*HZ; | ||
891 | qe_devs[i]->irq = sdev->irqs[0]; | ||
892 | qe_devs[i]->dma = 0; | ||
893 | qe_devs[i]->ethtool_ops = &qe_ethtool_ops; | ||
894 | } | ||
895 | 871 | ||
896 | /* QEC receives interrupts from each QE, then it sends the actual | 872 | res = -ENOMEM; |
897 | * IRQ to the cpu itself. Since QEC is the single point of | 873 | qe->qcregs = sbus_ioremap(&qe->qe_sdev->resource[0], 0, |
898 | * interrupt for all QE channels we register the IRQ handler | 874 | CREG_REG_SIZE, "QEC Channel Registers"); |
899 | * for it now. | 875 | if (!qe->qcregs) { |
900 | */ | 876 | printk(KERN_ERR "qe: Cannot map channel registers.\n"); |
901 | if (request_irq(sdev->irqs[0], &qec_interrupt, | 877 | goto fail; |
902 | SA_SHIRQ, "QuadEther", (void *) qecp)) { | ||
903 | printk(KERN_ERR "QuadEther: Can't register QEC master irq handler.\n"); | ||
904 | res = -EAGAIN; | ||
905 | goto out4; | ||
906 | } | 878 | } |
907 | 879 | ||
908 | for (i = 0; i < 4; i++) { | 880 | qe->mregs = sbus_ioremap(&qe->qe_sdev->resource[1], 0, |
909 | if (register_netdev(qe_devs[i]) != 0) | 881 | MREGS_REG_SIZE, "QE MACE Registers"); |
910 | goto out5; | 882 | if (!qe->mregs) { |
883 | printk(KERN_ERR "qe: Cannot map MACE registers.\n"); | ||
884 | goto fail; | ||
911 | } | 885 | } |
912 | 886 | ||
913 | /* Report the QE channels. */ | 887 | qe->qe_block = sbus_alloc_consistent(qe->qe_sdev, |
914 | for (i = 0; i < 4; i++) { | 888 | PAGE_SIZE, |
915 | printk(KERN_INFO "%s: QuadEthernet channel[%d] ", qe_devs[i]->name, i); | 889 | &qe->qblock_dvma); |
916 | for (j = 0; j < 6; j++) | 890 | qe->buffers = sbus_alloc_consistent(qe->qe_sdev, |
917 | printk ("%2.2x%c", | 891 | sizeof(struct sunqe_buffers), |
918 | qe_devs[i]->dev_addr[j], | 892 | &qe->buffers_dvma); |
919 | j == 5 ? ' ': ':'); | 893 | if (qe->qe_block == NULL || qe->qblock_dvma == 0 || |
920 | printk("\n"); | 894 | qe->buffers == NULL || qe->buffers_dvma == 0) |
921 | } | 895 | goto fail; |
896 | |||
897 | /* Stop this QE. */ | ||
898 | qe_stop(qe); | ||
899 | |||
900 | SET_MODULE_OWNER(dev); | ||
901 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | ||
902 | |||
903 | dev->open = qe_open; | ||
904 | dev->stop = qe_close; | ||
905 | dev->hard_start_xmit = qe_start_xmit; | ||
906 | dev->get_stats = qe_get_stats; | ||
907 | dev->set_multicast_list = qe_set_multicast; | ||
908 | dev->tx_timeout = qe_tx_timeout; | ||
909 | dev->watchdog_timeo = 5*HZ; | ||
910 | dev->irq = sdev->irqs[0]; | ||
911 | dev->dma = 0; | ||
912 | dev->ethtool_ops = &qe_ethtool_ops; | ||
913 | |||
914 | res = register_netdev(dev); | ||
915 | if (res) | ||
916 | goto fail; | ||
917 | |||
918 | dev_set_drvdata(&sdev->ofdev.dev, qe); | ||
919 | |||
920 | printk(KERN_INFO "%s: qe channel[%d] ", dev->name, qe->channel); | ||
921 | for (i = 0; i < 6; i++) | ||
922 | printk ("%2.2x%c", | ||
923 | dev->dev_addr[i], | ||
924 | i == 5 ? ' ': ':'); | ||
925 | printk("\n"); | ||
922 | 926 | ||
923 | /* We are home free at this point, link the qe's into | ||
924 | * the master list for later driver exit. | ||
925 | */ | ||
926 | qecp->next_module = root_qec_dev; | ||
927 | root_qec_dev = qecp; | ||
928 | 927 | ||
929 | return 0; | 928 | return 0; |
930 | 929 | ||
931 | out5: | 930 | fail: |
932 | while (i--) | 931 | if (qe->qcregs) |
933 | unregister_netdev(qe_devs[i]); | 932 | sbus_iounmap(qe->qcregs, CREG_REG_SIZE); |
934 | free_irq(sdev->irqs[0], (void *)qecp); | 933 | if (qe->mregs) |
935 | out4: | 934 | sbus_iounmap(qe->mregs, MREGS_REG_SIZE); |
936 | for (i = 0; i < 4; i++) { | 935 | if (qe->qe_block) |
937 | struct sunqe *qe = (struct sunqe *)qe_devs[i]->priv; | 936 | sbus_free_consistent(qe->qe_sdev, |
938 | 937 | PAGE_SIZE, | |
939 | if (qe->qcregs) | 938 | qe->qe_block, |
940 | sbus_iounmap(qe->qcregs, CREG_REG_SIZE); | 939 | qe->qblock_dvma); |
941 | if (qe->mregs) | 940 | if (qe->buffers) |
942 | sbus_iounmap(qe->mregs, MREGS_REG_SIZE); | 941 | sbus_free_consistent(qe->qe_sdev, |
943 | if (qe->qe_block) | 942 | sizeof(struct sunqe_buffers), |
944 | sbus_free_consistent(qe->qe_sdev, | 943 | qe->buffers, |
945 | PAGE_SIZE, | 944 | qe->buffers_dvma); |
946 | qe->qe_block, | 945 | |
947 | qe->qblock_dvma); | 946 | free_netdev(dev); |
948 | if (qe->buffers) | 947 | |
949 | sbus_free_consistent(qe->qe_sdev, | ||
950 | sizeof(struct sunqe_buffers), | ||
951 | qe->buffers, | ||
952 | qe->buffers_dvma); | ||
953 | } | ||
954 | out3: | ||
955 | sbus_iounmap(qecp->gregs, GLOB_REG_SIZE); | ||
956 | out2: | ||
957 | kfree(qecp); | ||
958 | out1: | ||
959 | i = 4; | ||
960 | out: | ||
961 | while (i--) | ||
962 | free_netdev(qe_devs[i]); | ||
963 | return res; | 948 | return res; |
964 | } | 949 | } |
965 | 950 | ||
966 | static int __init qec_match(struct sbus_dev *sdev) | 951 | static int __devinit qec_sbus_probe(struct of_device *dev, const struct of_device_id *match) |
967 | { | 952 | { |
968 | struct sbus_dev *sibling; | 953 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); |
969 | int i; | ||
970 | |||
971 | if (strcmp(sdev->prom_name, "qec") != 0) | ||
972 | return 0; | ||
973 | 954 | ||
974 | /* QEC can be parent of either QuadEthernet or BigMAC | 955 | return qec_ether_init(sdev); |
975 | * children. Do not confuse this with qfe/SUNW,qfe | ||
976 | * which is a quad-happymeal card and handled by | ||
977 | * a different driver. | ||
978 | */ | ||
979 | sibling = sdev->child; | ||
980 | for (i = 0; i < 4; i++) { | ||
981 | if (sibling == NULL) | ||
982 | return 0; | ||
983 | if (strcmp(sibling->prom_name, "qe") != 0) | ||
984 | return 0; | ||
985 | sibling = sibling->next; | ||
986 | } | ||
987 | return 1; | ||
988 | } | 956 | } |
989 | 957 | ||
990 | static int __init qec_probe(void) | 958 | static int __devexit qec_sbus_remove(struct of_device *dev) |
991 | { | 959 | { |
992 | struct net_device *dev = NULL; | 960 | struct sunqe *qp = dev_get_drvdata(&dev->dev); |
993 | struct sbus_bus *bus; | 961 | struct net_device *net_dev = qp->dev; |
994 | struct sbus_dev *sdev = NULL; | 962 | |
995 | static int called; | 963 | unregister_netdevice(net_dev); |
996 | int cards = 0, v; | 964 | |
997 | 965 | sbus_iounmap(qp->qcregs, CREG_REG_SIZE); | |
998 | root_qec_dev = NULL; | 966 | sbus_iounmap(qp->mregs, MREGS_REG_SIZE); |
999 | 967 | sbus_free_consistent(qp->qe_sdev, | |
1000 | if (called) | 968 | PAGE_SIZE, |
1001 | return -ENODEV; | 969 | qp->qe_block, |
1002 | called++; | 970 | qp->qblock_dvma); |
1003 | 971 | sbus_free_consistent(qp->qe_sdev, | |
1004 | for_each_sbus(bus) { | 972 | sizeof(struct sunqe_buffers), |
1005 | for_each_sbusdev(sdev, bus) { | 973 | qp->buffers, |
1006 | if (cards) | 974 | qp->buffers_dvma); |
1007 | dev = NULL; | 975 | |
1008 | 976 | free_netdev(net_dev); | |
1009 | if (qec_match(sdev)) { | 977 | |
1010 | cards++; | 978 | dev_set_drvdata(&dev->dev, NULL); |
1011 | if ((v = qec_ether_init(dev, sdev))) | 979 | |
1012 | return v; | ||
1013 | } | ||
1014 | } | ||
1015 | } | ||
1016 | if (!cards) | ||
1017 | return -ENODEV; | ||
1018 | return 0; | 980 | return 0; |
1019 | } | 981 | } |
1020 | 982 | ||
1021 | static void __exit qec_cleanup(void) | 983 | static struct of_device_id qec_sbus_match[] = { |
984 | { | ||
985 | .name = "qe", | ||
986 | }, | ||
987 | {}, | ||
988 | }; | ||
989 | |||
990 | MODULE_DEVICE_TABLE(of, qec_sbus_match); | ||
991 | |||
992 | static struct of_platform_driver qec_sbus_driver = { | ||
993 | .name = "qec", | ||
994 | .match_table = qec_sbus_match, | ||
995 | .probe = qec_sbus_probe, | ||
996 | .remove = __devexit_p(qec_sbus_remove), | ||
997 | }; | ||
998 | |||
999 | static int __init qec_init(void) | ||
1000 | { | ||
1001 | return of_register_driver(&qec_sbus_driver, &sbus_bus_type); | ||
1002 | } | ||
1003 | |||
1004 | static void __exit qec_exit(void) | ||
1022 | { | 1005 | { |
1023 | struct sunqec *next_qec; | 1006 | of_unregister_driver(&qec_sbus_driver); |
1024 | int i; | ||
1025 | 1007 | ||
1026 | while (root_qec_dev) { | 1008 | while (root_qec_dev) { |
1027 | next_qec = root_qec_dev->next_module; | 1009 | struct sunqec *next = root_qec_dev->next_module; |
1028 | 1010 | ||
1029 | /* Release all four QE channels, then the QEC itself. */ | 1011 | free_irq(root_qec_dev->qec_sdev->irqs[0], |
1030 | for (i = 0; i < 4; i++) { | 1012 | (void *) root_qec_dev); |
1031 | unregister_netdev(root_qec_dev->qes[i]->dev); | ||
1032 | sbus_iounmap(root_qec_dev->qes[i]->qcregs, CREG_REG_SIZE); | ||
1033 | sbus_iounmap(root_qec_dev->qes[i]->mregs, MREGS_REG_SIZE); | ||
1034 | sbus_free_consistent(root_qec_dev->qes[i]->qe_sdev, | ||
1035 | PAGE_SIZE, | ||
1036 | root_qec_dev->qes[i]->qe_block, | ||
1037 | root_qec_dev->qes[i]->qblock_dvma); | ||
1038 | sbus_free_consistent(root_qec_dev->qes[i]->qe_sdev, | ||
1039 | sizeof(struct sunqe_buffers), | ||
1040 | root_qec_dev->qes[i]->buffers, | ||
1041 | root_qec_dev->qes[i]->buffers_dvma); | ||
1042 | free_netdev(root_qec_dev->qes[i]->dev); | ||
1043 | } | ||
1044 | free_irq(root_qec_dev->qec_sdev->irqs[0], (void *)root_qec_dev); | ||
1045 | sbus_iounmap(root_qec_dev->gregs, GLOB_REG_SIZE); | 1013 | sbus_iounmap(root_qec_dev->gregs, GLOB_REG_SIZE); |
1014 | |||
1046 | kfree(root_qec_dev); | 1015 | kfree(root_qec_dev); |
1047 | root_qec_dev = next_qec; | 1016 | |
1017 | root_qec_dev = next; | ||
1048 | } | 1018 | } |
1049 | } | 1019 | } |
1050 | 1020 | ||
1051 | module_init(qec_probe); | 1021 | module_init(qec_init); |
1052 | module_exit(qec_cleanup); | 1022 | module_exit(qec_exit); |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index e3e380f90f86..35f931638750 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -10549,11 +10549,13 @@ static int __devinit tg3_get_macaddr_sparc(struct tg3 *tp) | |||
10549 | struct pcidev_cookie *pcp = pdev->sysdata; | 10549 | struct pcidev_cookie *pcp = pdev->sysdata; |
10550 | 10550 | ||
10551 | if (pcp != NULL) { | 10551 | if (pcp != NULL) { |
10552 | int node = pcp->prom_node; | 10552 | unsigned char *addr; |
10553 | int len; | ||
10553 | 10554 | ||
10554 | if (prom_getproplen(node, "local-mac-address") == 6) { | 10555 | addr = of_get_property(pcp->prom_node, "local-mac-address", |
10555 | prom_getproperty(node, "local-mac-address", | 10556 | &len); |
10556 | dev->dev_addr, 6); | 10557 | if (addr && len == 6) { |
10558 | memcpy(dev->dev_addr, addr, 6); | ||
10557 | memcpy(dev->perm_addr, dev->dev_addr, 6); | 10559 | memcpy(dev->perm_addr, dev->dev_addr, 6); |
10558 | return 0; | 10560 | return 0; |
10559 | } | 10561 | } |
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c index cabdf894e21e..e0de66739a42 100644 --- a/drivers/net/tulip/tulip_core.c +++ b/drivers/net/tulip/tulip_core.c | |||
@@ -1550,10 +1550,14 @@ static int __devinit tulip_init_one (struct pci_dev *pdev, | |||
1550 | dev->dev_addr[i] = last_phys_addr[i]; | 1550 | dev->dev_addr[i] = last_phys_addr[i]; |
1551 | dev->dev_addr[i] = last_phys_addr[i] + 1; | 1551 | dev->dev_addr[i] = last_phys_addr[i] + 1; |
1552 | #if defined(__sparc__) | 1552 | #if defined(__sparc__) |
1553 | if ((pcp != NULL) && prom_getproplen(pcp->prom_node, | 1553 | if (pcp) { |
1554 | "local-mac-address") == 6) { | 1554 | unsigned char *addr; |
1555 | prom_getproperty(pcp->prom_node, "local-mac-address", | 1555 | int len; |
1556 | dev->dev_addr, 6); | 1556 | |
1557 | addr = of_get_property(pcp->prom_node, | ||
1558 | "local-mac-address", &len); | ||
1559 | if (addr && len == 6) | ||
1560 | memcpy(dev->dev_addr, addr, 6); | ||
1557 | } | 1561 | } |
1558 | #endif | 1562 | #endif |
1559 | #if defined(__i386__) || defined(__x86_64__) /* Patch up x86 BIOS bug. */ | 1563 | #if defined(__i386__) || defined(__x86_64__) /* Patch up x86 BIOS bug. */ |
diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c index 36a1556e64c7..69a4bbd4cbee 100644 --- a/drivers/parport/parport_sunbpp.c +++ b/drivers/parport/parport_sunbpp.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: parport_sunbpp.c,v 1.12 2001/05/26 03:01:42 davem Exp $ | 1 | /* parport_sunbpp.c: Parallel-port routines for SBUS |
2 | * Parallel-port routines for Sun architecture | ||
3 | * | 2 | * |
4 | * Author: Derrick J. Brashear <shadow@dementia.org> | 3 | * Author: Derrick J. Brashear <shadow@dementia.org> |
5 | * | 4 | * |
@@ -14,6 +13,9 @@ | |||
14 | * Gus Baldauf (gbaldauf@ix.netcom.com) | 13 | * Gus Baldauf (gbaldauf@ix.netcom.com) |
15 | * Peter Zaitcev | 14 | * Peter Zaitcev |
16 | * Tom Dyas | 15 | * Tom Dyas |
16 | * | ||
17 | * Updated to new SBUS device framework: David S. Miller <davem@davemloft.net> | ||
18 | * | ||
17 | */ | 19 | */ |
18 | 20 | ||
19 | #include <linux/string.h> | 21 | #include <linux/string.h> |
@@ -287,14 +289,7 @@ static struct parport_operations parport_sunbpp_ops = | |||
287 | .owner = THIS_MODULE, | 289 | .owner = THIS_MODULE, |
288 | }; | 290 | }; |
289 | 291 | ||
290 | typedef struct { | 292 | static int __devinit init_one_port(struct sbus_dev *sdev) |
291 | struct list_head list; | ||
292 | struct parport *port; | ||
293 | } Node; | ||
294 | /* no locks, everything's serialized */ | ||
295 | static LIST_HEAD(port_list); | ||
296 | |||
297 | static int __init init_one_port(struct sbus_dev *sdev) | ||
298 | { | 293 | { |
299 | struct parport *p; | 294 | struct parport *p; |
300 | /* at least in theory there may be a "we don't dma" case */ | 295 | /* at least in theory there may be a "we don't dma" case */ |
@@ -303,109 +298,120 @@ static int __init init_one_port(struct sbus_dev *sdev) | |||
303 | int irq, dma, err = 0, size; | 298 | int irq, dma, err = 0, size; |
304 | struct bpp_regs __iomem *regs; | 299 | struct bpp_regs __iomem *regs; |
305 | unsigned char value_tcr; | 300 | unsigned char value_tcr; |
306 | Node *node; | ||
307 | |||
308 | dprintk((KERN_DEBUG "init_one_port(%p): ranges, alloc_io, ", sdev)); | ||
309 | node = kmalloc(sizeof(Node), GFP_KERNEL); | ||
310 | if (!node) | ||
311 | goto out0; | ||
312 | 301 | ||
313 | irq = sdev->irqs[0]; | 302 | irq = sdev->irqs[0]; |
314 | base = sbus_ioremap(&sdev->resource[0], 0, | 303 | base = sbus_ioremap(&sdev->resource[0], 0, |
315 | sdev->reg_addrs[0].reg_size, | 304 | sdev->reg_addrs[0].reg_size, |
316 | "sunbpp"); | 305 | "sunbpp"); |
317 | if (!base) | 306 | if (!base) |
318 | goto out1; | 307 | return -ENODEV; |
319 | 308 | ||
320 | size = sdev->reg_addrs[0].reg_size; | 309 | size = sdev->reg_addrs[0].reg_size; |
321 | dma = PARPORT_DMA_NONE; | 310 | dma = PARPORT_DMA_NONE; |
322 | 311 | ||
323 | dprintk(("alloc(ppops), ")); | 312 | ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL); |
324 | ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL); | ||
325 | if (!ops) | 313 | if (!ops) |
326 | goto out2; | 314 | goto out_unmap; |
327 | 315 | ||
328 | memcpy (ops, &parport_sunbpp_ops, sizeof (struct parport_operations)); | 316 | memcpy (ops, &parport_sunbpp_ops, sizeof (struct parport_operations)); |
329 | 317 | ||
330 | dprintk(("register_port\n")); | 318 | dprintk(("register_port\n")); |
331 | if (!(p = parport_register_port((unsigned long)base, irq, dma, ops))) | 319 | if (!(p = parport_register_port((unsigned long)base, irq, dma, ops))) |
332 | goto out3; | 320 | goto out_free_ops; |
333 | 321 | ||
334 | p->size = size; | 322 | p->size = size; |
335 | 323 | ||
336 | dprintk((KERN_DEBUG "init_one_port: request_irq(%08x:%p:%x:%s:%p) ", | ||
337 | p->irq, parport_sunbpp_interrupt, SA_SHIRQ, p->name, p)); | ||
338 | if ((err = request_irq(p->irq, parport_sunbpp_interrupt, | 324 | if ((err = request_irq(p->irq, parport_sunbpp_interrupt, |
339 | SA_SHIRQ, p->name, p)) != 0) { | 325 | SA_SHIRQ, p->name, p)) != 0) { |
340 | dprintk(("ERROR %d\n", err)); | 326 | goto out_put_port; |
341 | goto out4; | ||
342 | } | 327 | } |
343 | dprintk(("OK\n")); | 328 | |
344 | parport_sunbpp_enable_irq(p); | 329 | parport_sunbpp_enable_irq(p); |
345 | 330 | ||
346 | regs = (struct bpp_regs __iomem *)p->base; | 331 | regs = (struct bpp_regs __iomem *)p->base; |
347 | dprintk((KERN_DEBUG "forward\n")); | 332 | |
348 | value_tcr = sbus_readb(®s->p_tcr); | 333 | value_tcr = sbus_readb(®s->p_tcr); |
349 | value_tcr &= ~P_TCR_DIR; | 334 | value_tcr &= ~P_TCR_DIR; |
350 | sbus_writeb(value_tcr, ®s->p_tcr); | 335 | sbus_writeb(value_tcr, ®s->p_tcr); |
351 | 336 | ||
352 | printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base); | 337 | printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base); |
353 | node->port = p; | ||
354 | list_add(&node->list, &port_list); | ||
355 | parport_announce_port (p); | ||
356 | 338 | ||
357 | return 1; | 339 | dev_set_drvdata(&sdev->ofdev.dev, p); |
340 | |||
341 | parport_announce_port(p); | ||
342 | |||
343 | return 0; | ||
358 | 344 | ||
359 | out4: | 345 | out_put_port: |
360 | parport_put_port(p); | 346 | parport_put_port(p); |
361 | out3: | 347 | |
348 | out_free_ops: | ||
362 | kfree(ops); | 349 | kfree(ops); |
363 | out2: | 350 | |
351 | out_unmap: | ||
364 | sbus_iounmap(base, size); | 352 | sbus_iounmap(base, size); |
365 | out1: | 353 | |
366 | kfree(node); | ||
367 | out0: | ||
368 | return err; | 354 | return err; |
369 | } | 355 | } |
370 | 356 | ||
371 | static int __init parport_sunbpp_init(void) | 357 | static int __devinit bpp_probe(struct of_device *dev, const struct of_device_id *match) |
372 | { | 358 | { |
373 | struct sbus_bus *sbus; | 359 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); |
374 | struct sbus_dev *sdev; | 360 | |
375 | int count = 0; | 361 | return init_one_port(sdev); |
376 | 362 | } | |
377 | for_each_sbus(sbus) { | 363 | |
378 | for_each_sbusdev(sdev, sbus) { | 364 | static int __devexit bpp_remove(struct of_device *dev) |
379 | if (!strcmp(sdev->prom_name, "SUNW,bpp")) | 365 | { |
380 | count += init_one_port(sdev); | 366 | struct parport *p = dev_get_drvdata(&dev->dev); |
381 | } | 367 | struct parport_operations *ops = p->ops; |
368 | |||
369 | parport_remove_port(p); | ||
370 | |||
371 | if (p->irq != PARPORT_IRQ_NONE) { | ||
372 | parport_sunbpp_disable_irq(p); | ||
373 | free_irq(p->irq, p); | ||
382 | } | 374 | } |
383 | return count ? 0 : -ENODEV; | 375 | |
376 | sbus_iounmap((void __iomem *) p->base, p->size); | ||
377 | parport_put_port(p); | ||
378 | kfree(ops); | ||
379 | |||
380 | dev_set_drvdata(&dev->dev, NULL); | ||
381 | |||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | static struct of_device_id bpp_match[] = { | ||
386 | { | ||
387 | .name = "SUNW,bpp", | ||
388 | }, | ||
389 | {}, | ||
390 | }; | ||
391 | |||
392 | MODULE_DEVICE_TABLE(of, qec_sbus_match); | ||
393 | |||
394 | static struct of_platform_driver bpp_sbus_driver = { | ||
395 | .name = "bpp", | ||
396 | .match_table = bpp_match, | ||
397 | .probe = bpp_probe, | ||
398 | .remove = __devexit_p(bpp_remove), | ||
399 | }; | ||
400 | |||
401 | static int __init parport_sunbpp_init(void) | ||
402 | { | ||
403 | return of_register_driver(&bpp_sbus_driver, &sbus_bus_type); | ||
384 | } | 404 | } |
385 | 405 | ||
386 | static void __exit parport_sunbpp_exit(void) | 406 | static void __exit parport_sunbpp_exit(void) |
387 | { | 407 | { |
388 | while (!list_empty(&port_list)) { | 408 | of_unregister_driver(&bpp_sbus_driver); |
389 | Node *node = list_entry(port_list.next, Node, list); | ||
390 | struct parport *p = node->port; | ||
391 | struct parport_operations *ops = p->ops; | ||
392 | parport_remove_port(p); | ||
393 | |||
394 | if (p->irq != PARPORT_IRQ_NONE) { | ||
395 | parport_sunbpp_disable_irq(p); | ||
396 | free_irq(p->irq, p); | ||
397 | } | ||
398 | sbus_iounmap((void __iomem *)p->base, p->size); | ||
399 | parport_put_port(p); | ||
400 | kfree (ops); | ||
401 | list_del(&node->list); | ||
402 | kfree (node); | ||
403 | } | ||
404 | } | 409 | } |
405 | 410 | ||
406 | MODULE_AUTHOR("Derrick J Brashear"); | 411 | MODULE_AUTHOR("Derrick J Brashear"); |
407 | MODULE_DESCRIPTION("Parport Driver for Sparc bidirectional Port"); | 412 | MODULE_DESCRIPTION("Parport Driver for Sparc bidirectional Port"); |
408 | MODULE_SUPPORTED_DEVICE("Sparc Bidirectional Parallel Port"); | 413 | MODULE_SUPPORTED_DEVICE("Sparc Bidirectional Parallel Port"); |
414 | MODULE_VERSION("2.0"); | ||
409 | MODULE_LICENSE("GPL"); | 415 | MODULE_LICENSE("GPL"); |
410 | 416 | ||
411 | module_init(parport_sunbpp_init) | 417 | module_init(parport_sunbpp_init) |
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c index d89f83f769f5..1cc706e11119 100644 --- a/drivers/sbus/char/bbc_envctrl.c +++ b/drivers/sbus/char/bbc_envctrl.c | |||
@@ -575,9 +575,9 @@ int bbc_envctrl_init(void) | |||
575 | int devidx = 0; | 575 | int devidx = 0; |
576 | 576 | ||
577 | while ((echild = bbc_i2c_getdev(devidx++)) != NULL) { | 577 | while ((echild = bbc_i2c_getdev(devidx++)) != NULL) { |
578 | if (!strcmp(echild->prom_name, "temperature")) | 578 | if (!strcmp(echild->prom_node->name, "temperature")) |
579 | attach_one_temp(echild, temp_index++); | 579 | attach_one_temp(echild, temp_index++); |
580 | if (!strcmp(echild->prom_name, "fan-control")) | 580 | if (!strcmp(echild->prom_node->name, "fan-control")) |
581 | attach_one_fan(echild, fan_index++); | 581 | attach_one_fan(echild, fan_index++); |
582 | } | 582 | } |
583 | if (temp_index != 0 && fan_index != 0) { | 583 | if (temp_index != 0 && fan_index != 0) { |
diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c index 3e156e005f2e..73634371393b 100644 --- a/drivers/sbus/char/bbc_i2c.c +++ b/drivers/sbus/char/bbc_i2c.c | |||
@@ -423,7 +423,7 @@ static int __init bbc_present(void) | |||
423 | 423 | ||
424 | for_each_ebus(ebus) { | 424 | for_each_ebus(ebus) { |
425 | for_each_ebusdev(edev, ebus) { | 425 | for_each_ebusdev(edev, ebus) { |
426 | if (!strcmp(edev->prom_name, "bbc")) | 426 | if (!strcmp(edev->prom_node->name, "bbc")) |
427 | return 1; | 427 | return 1; |
428 | } | 428 | } |
429 | } | 429 | } |
@@ -446,7 +446,7 @@ static int __init bbc_i2c_init(void) | |||
446 | 446 | ||
447 | for_each_ebus(ebus) { | 447 | for_each_ebus(ebus) { |
448 | for_each_ebusdev(edev, ebus) { | 448 | for_each_ebusdev(edev, ebus) { |
449 | if (!strcmp(edev->prom_name, "i2c")) { | 449 | if (!strcmp(edev->prom_node->name, "i2c")) { |
450 | if (!attach_one_i2c(edev, index)) | 450 | if (!attach_one_i2c(edev, index)) |
451 | index++; | 451 | index++; |
452 | } | 452 | } |
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index c3a51d1fae5d..d92bc8827a9e 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c | |||
@@ -184,7 +184,7 @@ static int __init d7s_init(void) | |||
184 | 184 | ||
185 | for_each_ebus(ebus) { | 185 | for_each_ebus(ebus) { |
186 | for_each_ebusdev(edev, ebus) { | 186 | for_each_ebusdev(edev, ebus) { |
187 | if (!strcmp(edev->prom_name, D7S_OBPNAME)) | 187 | if (!strcmp(edev->prom_node->name, D7S_OBPNAME)) |
188 | goto ebus_done; | 188 | goto ebus_done; |
189 | } | 189 | } |
190 | } | 190 | } |
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index 19e8eddf887a..cf97e9efe9b6 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c | |||
@@ -768,16 +768,14 @@ static void envctrl_set_mon(struct i2c_child_t *pchild, | |||
768 | * decoding tables, monitor type, optional properties. | 768 | * decoding tables, monitor type, optional properties. |
769 | * Return: None. | 769 | * Return: None. |
770 | */ | 770 | */ |
771 | static void envctrl_init_adc(struct i2c_child_t *pchild, int node) | 771 | static void envctrl_init_adc(struct i2c_child_t *pchild, struct device_node *dp) |
772 | { | 772 | { |
773 | char chnls_desc[CHANNEL_DESC_SZ]; | ||
774 | int i = 0, len; | 773 | int i = 0, len; |
775 | char *pos = chnls_desc; | 774 | char *pos; |
775 | unsigned int *pval; | ||
776 | 776 | ||
777 | /* Firmware describe channels into a stream separated by a '\0'. */ | 777 | /* Firmware describe channels into a stream separated by a '\0'. */ |
778 | len = prom_getproperty(node, "channels-description", chnls_desc, | 778 | pos = of_get_property(dp, "channels-description", &len); |
779 | CHANNEL_DESC_SZ); | ||
780 | chnls_desc[CHANNEL_DESC_SZ - 1] = '\0'; | ||
781 | 779 | ||
782 | while (len > 0) { | 780 | while (len > 0) { |
783 | int l = strlen(pos) + 1; | 781 | int l = strlen(pos) + 1; |
@@ -787,10 +785,13 @@ static void envctrl_init_adc(struct i2c_child_t *pchild, int node) | |||
787 | } | 785 | } |
788 | 786 | ||
789 | /* Get optional properties. */ | 787 | /* Get optional properties. */ |
790 | len = prom_getproperty(node, "warning-temp", (char *)&warning_temperature, | 788 | pval = of_get_property(dp, "warning-temp", NULL); |
791 | sizeof(warning_temperature)); | 789 | if (pval) |
792 | len = prom_getproperty(node, "shutdown-temp", (char *)&shutdown_temperature, | 790 | warning_temperature = *pval; |
793 | sizeof(shutdown_temperature)); | 791 | |
792 | pval = of_get_property(dp, "shutdown-temp", NULL); | ||
793 | if (pval) | ||
794 | shutdown_temperature = *pval; | ||
794 | } | 795 | } |
795 | 796 | ||
796 | /* Function Description: Initialize child device monitoring fan status. | 797 | /* Function Description: Initialize child device monitoring fan status. |
@@ -864,21 +865,18 @@ static void envctrl_init_voltage_status(struct i2c_child_t *pchild) | |||
864 | static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, | 865 | static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, |
865 | struct i2c_child_t *pchild) | 866 | struct i2c_child_t *pchild) |
866 | { | 867 | { |
867 | int node, len, i, tbls_size = 0; | 868 | int len, i, tbls_size = 0; |
868 | 869 | struct device_node *dp = edev_child->prom_node; | |
869 | node = edev_child->prom_node; | 870 | void *pval; |
870 | 871 | ||
871 | /* Get device address. */ | 872 | /* Get device address. */ |
872 | len = prom_getproperty(node, "reg", | 873 | pval = of_get_property(dp, "reg", &len); |
873 | (char *) &(pchild->addr), | 874 | memcpy(&pchild->addr, pval, len); |
874 | sizeof(pchild->addr)); | ||
875 | 875 | ||
876 | /* Get tables property. Read firmware temperature tables. */ | 876 | /* Get tables property. Read firmware temperature tables. */ |
877 | len = prom_getproperty(node, "translation", | 877 | pval = of_get_property(dp, "translation", &len); |
878 | (char *) pchild->tblprop_array, | 878 | if (pval && len > 0) { |
879 | (PCF8584_MAX_CHANNELS * | 879 | memcpy(pchild->tblprop_array, pval, len); |
880 | sizeof(struct pcf8584_tblprop))); | ||
881 | if (len > 0) { | ||
882 | pchild->total_tbls = len / sizeof(struct pcf8584_tblprop); | 880 | pchild->total_tbls = len / sizeof(struct pcf8584_tblprop); |
883 | for (i = 0; i < pchild->total_tbls; i++) { | 881 | for (i = 0; i < pchild->total_tbls; i++) { |
884 | if ((pchild->tblprop_array[i].size + pchild->tblprop_array[i].offset) > tbls_size) { | 882 | if ((pchild->tblprop_array[i].size + pchild->tblprop_array[i].offset) > tbls_size) { |
@@ -891,12 +889,12 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, | |||
891 | printk("envctrl: Failed to allocate table.\n"); | 889 | printk("envctrl: Failed to allocate table.\n"); |
892 | return; | 890 | return; |
893 | } | 891 | } |
894 | len = prom_getproperty(node, "tables", | 892 | pval = of_get_property(dp, "tables", &len); |
895 | (char *) pchild->tables, tbls_size); | 893 | if (!pval || len <= 0) { |
896 | if (len <= 0) { | ||
897 | printk("envctrl: Failed to get table.\n"); | 894 | printk("envctrl: Failed to get table.\n"); |
898 | return; | 895 | return; |
899 | } | 896 | } |
897 | memcpy(pchild->tables, pval, len); | ||
900 | } | 898 | } |
901 | 899 | ||
902 | /* SPARCengine ASM Reference Manual (ref. SMI doc 805-7581-04) | 900 | /* SPARCengine ASM Reference Manual (ref. SMI doc 805-7581-04) |
@@ -907,12 +905,11 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, | |||
907 | * 'NULL' monitor type. | 905 | * 'NULL' monitor type. |
908 | */ | 906 | */ |
909 | if (ENVCTRL_CPCI_IGNORED_NODE == pchild->addr) { | 907 | if (ENVCTRL_CPCI_IGNORED_NODE == pchild->addr) { |
908 | struct device_node *root_node; | ||
910 | int len; | 909 | int len; |
911 | char prop[56]; | ||
912 | 910 | ||
913 | len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop)); | 911 | root_node = of_find_node_by_path("/"); |
914 | if (0 < len && (0 == strncmp(prop, "SUNW,UltraSPARC-IIi-cEngine", len))) | 912 | if (!strcmp(root_node->name, "SUNW,UltraSPARC-IIi-cEngine")) { |
915 | { | ||
916 | for (len = 0; len < PCF8584_MAX_CHANNELS; ++len) { | 913 | for (len = 0; len < PCF8584_MAX_CHANNELS; ++len) { |
917 | pchild->mon_type[len] = ENVCTRL_NOMON; | 914 | pchild->mon_type[len] = ENVCTRL_NOMON; |
918 | } | 915 | } |
@@ -921,16 +918,14 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, | |||
921 | } | 918 | } |
922 | 919 | ||
923 | /* Get the monitor channels. */ | 920 | /* Get the monitor channels. */ |
924 | len = prom_getproperty(node, "channels-in-use", | 921 | pval = of_get_property(dp, "channels-in-use", &len); |
925 | (char *) pchild->chnl_array, | 922 | memcpy(pchild->chnl_array, pval, len); |
926 | (PCF8584_MAX_CHANNELS * | ||
927 | sizeof(struct pcf8584_channel))); | ||
928 | pchild->total_chnls = len / sizeof(struct pcf8584_channel); | 923 | pchild->total_chnls = len / sizeof(struct pcf8584_channel); |
929 | 924 | ||
930 | for (i = 0; i < pchild->total_chnls; i++) { | 925 | for (i = 0; i < pchild->total_chnls; i++) { |
931 | switch (pchild->chnl_array[i].type) { | 926 | switch (pchild->chnl_array[i].type) { |
932 | case PCF8584_TEMP_TYPE: | 927 | case PCF8584_TEMP_TYPE: |
933 | envctrl_init_adc(pchild, node); | 928 | envctrl_init_adc(pchild, dp); |
934 | break; | 929 | break; |
935 | 930 | ||
936 | case PCF8584_GLOBALADDR_TYPE: | 931 | case PCF8584_GLOBALADDR_TYPE: |
@@ -945,7 +940,7 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, | |||
945 | 940 | ||
946 | case PCF8584_VOLTAGE_TYPE: | 941 | case PCF8584_VOLTAGE_TYPE: |
947 | if (pchild->i2ctype == I2C_ADC) { | 942 | if (pchild->i2ctype == I2C_ADC) { |
948 | envctrl_init_adc(pchild,node); | 943 | envctrl_init_adc(pchild,dp); |
949 | } else { | 944 | } else { |
950 | envctrl_init_voltage_status(pchild); | 945 | envctrl_init_voltage_status(pchild); |
951 | } | 946 | } |
@@ -1046,7 +1041,7 @@ static int __init envctrl_init(void) | |||
1046 | 1041 | ||
1047 | for_each_ebus(ebus) { | 1042 | for_each_ebus(ebus) { |
1048 | for_each_ebusdev(edev, ebus) { | 1043 | for_each_ebusdev(edev, ebus) { |
1049 | if (!strcmp(edev->prom_name, "bbc")) { | 1044 | if (!strcmp(edev->prom_node->name, "bbc")) { |
1050 | /* If we find a boot-bus controller node, | 1045 | /* If we find a boot-bus controller node, |
1051 | * then this envctrl driver is not for us. | 1046 | * then this envctrl driver is not for us. |
1052 | */ | 1047 | */ |
@@ -1060,14 +1055,14 @@ static int __init envctrl_init(void) | |||
1060 | */ | 1055 | */ |
1061 | for_each_ebus(ebus) { | 1056 | for_each_ebus(ebus) { |
1062 | for_each_ebusdev(edev, ebus) { | 1057 | for_each_ebusdev(edev, ebus) { |
1063 | if (!strcmp(edev->prom_name, "i2c")) { | 1058 | if (!strcmp(edev->prom_node->name, "i2c")) { |
1064 | i2c = ioremap(edev->resource[0].start, 0x2); | 1059 | i2c = ioremap(edev->resource[0].start, 0x2); |
1065 | for_each_edevchild(edev, edev_child) { | 1060 | for_each_edevchild(edev, edev_child) { |
1066 | if (!strcmp("gpio", edev_child->prom_name)) { | 1061 | if (!strcmp("gpio", edev_child->prom_node->name)) { |
1067 | i2c_childlist[i].i2ctype = I2C_GPIO; | 1062 | i2c_childlist[i].i2ctype = I2C_GPIO; |
1068 | envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++])); | 1063 | envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++])); |
1069 | } | 1064 | } |
1070 | if (!strcmp("adc", edev_child->prom_name)) { | 1065 | if (!strcmp("adc", edev_child->prom_node->name)) { |
1071 | i2c_childlist[i].i2ctype = I2C_ADC; | 1066 | i2c_childlist[i].i2ctype = I2C_ADC; |
1072 | envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++])); | 1067 | envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++])); |
1073 | } | 1068 | } |
diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c index 2beb3dded087..5ae684c011f8 100644 --- a/drivers/sbus/char/flash.c +++ b/drivers/sbus/char/flash.c | |||
@@ -192,9 +192,11 @@ static int __init flash_init(void) | |||
192 | } | 192 | } |
193 | if (!sdev) { | 193 | if (!sdev) { |
194 | #ifdef CONFIG_PCI | 194 | #ifdef CONFIG_PCI |
195 | struct linux_prom_registers *ebus_regs; | ||
196 | |||
195 | for_each_ebus(ebus) { | 197 | for_each_ebus(ebus) { |
196 | for_each_ebusdev(edev, ebus) { | 198 | for_each_ebusdev(edev, ebus) { |
197 | if (!strcmp(edev->prom_name, "flashprom")) | 199 | if (!strcmp(edev->prom_node->name, "flashprom")) |
198 | goto ebus_done; | 200 | goto ebus_done; |
199 | } | 201 | } |
200 | } | 202 | } |
@@ -202,23 +204,23 @@ static int __init flash_init(void) | |||
202 | if (!edev) | 204 | if (!edev) |
203 | return -ENODEV; | 205 | return -ENODEV; |
204 | 206 | ||
205 | len = prom_getproperty(edev->prom_node, "reg", (void *)regs, sizeof(regs)); | 207 | ebus_regs = of_get_property(edev->prom_node, "reg", &len); |
206 | if ((len % sizeof(regs[0])) != 0) { | 208 | if (!ebus_regs || (len % sizeof(regs[0])) != 0) { |
207 | printk("flash: Strange reg property size %d\n", len); | 209 | printk("flash: Strange reg property size %d\n", len); |
208 | return -ENODEV; | 210 | return -ENODEV; |
209 | } | 211 | } |
210 | 212 | ||
211 | nregs = len / sizeof(regs[0]); | 213 | nregs = len / sizeof(ebus_regs[0]); |
212 | 214 | ||
213 | flash.read_base = edev->resource[0].start; | 215 | flash.read_base = edev->resource[0].start; |
214 | flash.read_size = regs[0].reg_size; | 216 | flash.read_size = ebus_regs[0].reg_size; |
215 | 217 | ||
216 | if (nregs == 1) { | 218 | if (nregs == 1) { |
217 | flash.write_base = edev->resource[0].start; | 219 | flash.write_base = edev->resource[0].start; |
218 | flash.write_size = regs[0].reg_size; | 220 | flash.write_size = ebus_regs[0].reg_size; |
219 | } else if (nregs == 2) { | 221 | } else if (nregs == 2) { |
220 | flash.write_base = edev->resource[1].start; | 222 | flash.write_base = edev->resource[1].start; |
221 | flash.write_size = regs[1].reg_size; | 223 | flash.write_size = ebus_regs[1].reg_size; |
222 | } else { | 224 | } else { |
223 | printk("flash: Strange number of regs %d\n", nregs); | 225 | printk("flash: Strange number of regs %d\n", nregs); |
224 | return -ENODEV; | 226 | return -ENODEV; |
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c index 239e108b8ed1..cf5b476b5496 100644 --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c | |||
@@ -243,8 +243,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file, | |||
243 | ((int *) opp->oprom_array)[1]); | 243 | ((int *) opp->oprom_array)[1]); |
244 | 244 | ||
245 | pcp = pdev->sysdata; | 245 | pcp = pdev->sysdata; |
246 | if (pcp != NULL && pcp->prom_node != -1 && pcp->prom_node) { | 246 | if (pcp != NULL) { |
247 | node = pcp->prom_node; | 247 | node = pcp->prom_node->node; |
248 | data->current_node = node; | 248 | data->current_node = node; |
249 | *((int *)opp->oprom_array) = node; | 249 | *((int *)opp->oprom_array) = node; |
250 | opp->oprom_size = sizeof(int); | 250 | opp->oprom_size = sizeof(int); |
diff --git a/drivers/sbus/sbus.c b/drivers/sbus/sbus.c index 5d30a3ebfccd..387a6aa8c020 100644 --- a/drivers/sbus/sbus.c +++ b/drivers/sbus/sbus.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* $Id: sbus.c,v 1.100 2002/01/24 15:36:24 davem Exp $ | 1 | /* sbus.c: SBus support routines. |
2 | * sbus.c: SBus support routines. | ||
3 | * | 2 | * |
4 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | 3 | * Copyright (C) 1995, 2006 David S. Miller (davem@davemloft.net) |
5 | */ | 4 | */ |
6 | 5 | ||
7 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
@@ -14,237 +13,76 @@ | |||
14 | #include <asm/sbus.h> | 13 | #include <asm/sbus.h> |
15 | #include <asm/dma.h> | 14 | #include <asm/dma.h> |
16 | #include <asm/oplib.h> | 15 | #include <asm/oplib.h> |
16 | #include <asm/prom.h> | ||
17 | #include <asm/of_device.h> | ||
17 | #include <asm/bpp.h> | 18 | #include <asm/bpp.h> |
18 | #include <asm/irq.h> | 19 | #include <asm/irq.h> |
19 | 20 | ||
20 | struct sbus_bus *sbus_root = NULL; | 21 | struct sbus_bus *sbus_root; |
21 | 22 | ||
22 | static struct linux_prom_irqs irqs[PROMINTR_MAX] __initdata = { { 0 } }; | 23 | static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sdev) |
23 | #ifdef CONFIG_SPARC32 | ||
24 | static int interrupts[PROMINTR_MAX] __initdata = { 0 }; | ||
25 | #endif | ||
26 | |||
27 | #ifdef CONFIG_PCI | ||
28 | extern int pcic_present(void); | ||
29 | #endif | ||
30 | |||
31 | /* Perhaps when I figure out more about the iommu we'll put a | ||
32 | * device registration routine here that probe_sbus() calls to | ||
33 | * setup the iommu for each Sbus. | ||
34 | */ | ||
35 | |||
36 | /* We call this for each SBus device, and fill the structure based | ||
37 | * upon the prom device tree. We return the start of memory after | ||
38 | * the things we have allocated. | ||
39 | */ | ||
40 | |||
41 | /* #define DEBUG_FILL */ | ||
42 | |||
43 | static void __init fill_sbus_device(int prom_node, struct sbus_dev *sdev) | ||
44 | { | 24 | { |
45 | unsigned long address, base; | 25 | unsigned long base; |
26 | void *pval; | ||
46 | int len; | 27 | int len; |
47 | 28 | ||
48 | sdev->prom_node = prom_node; | 29 | sdev->prom_node = dp->node; |
49 | prom_getstring(prom_node, "name", | 30 | strcpy(sdev->prom_name, dp->name); |
50 | sdev->prom_name, sizeof(sdev->prom_name)); | ||
51 | address = prom_getint(prom_node, "address"); | ||
52 | len = prom_getproperty(prom_node, "reg", | ||
53 | (char *) sdev->reg_addrs, | ||
54 | sizeof(sdev->reg_addrs)); | ||
55 | if (len == -1) { | ||
56 | sdev->num_registers = 0; | ||
57 | goto no_regs; | ||
58 | } | ||
59 | 31 | ||
60 | if (len % sizeof(struct linux_prom_registers)) { | 32 | pval = of_get_property(dp, "reg", &len); |
61 | prom_printf("fill_sbus_device: proplen for regs of %s " | 33 | sdev->num_registers = 0; |
62 | " was %d, need multiple of %d\n", | 34 | if (pval) { |
63 | sdev->prom_name, len, | 35 | memcpy(sdev->reg_addrs, pval, len); |
64 | (int) sizeof(struct linux_prom_registers)); | ||
65 | prom_halt(); | ||
66 | } | ||
67 | if (len > (sizeof(struct linux_prom_registers) * PROMREG_MAX)) { | ||
68 | prom_printf("fill_sbus_device: Too many register properties " | ||
69 | "for device %s, len=%d\n", | ||
70 | sdev->prom_name, len); | ||
71 | prom_halt(); | ||
72 | } | ||
73 | sdev->num_registers = len / sizeof(struct linux_prom_registers); | ||
74 | sdev->ranges_applied = 0; | ||
75 | 36 | ||
76 | base = (unsigned long) sdev->reg_addrs[0].phys_addr; | 37 | sdev->num_registers = |
38 | len / sizeof(struct linux_prom_registers); | ||
77 | 39 | ||
78 | /* Compute the slot number. */ | 40 | base = (unsigned long) sdev->reg_addrs[0].phys_addr; |
79 | if (base >= SUN_SBUS_BVADDR && sparc_cpu_model == sun4m) { | ||
80 | sdev->slot = sbus_dev_slot(base); | ||
81 | } else { | ||
82 | sdev->slot = sdev->reg_addrs[0].which_io; | ||
83 | } | ||
84 | 41 | ||
85 | no_regs: | 42 | /* Compute the slot number. */ |
86 | len = prom_getproperty(prom_node, "ranges", | 43 | if (base >= SUN_SBUS_BVADDR && sparc_cpu_model == sun4m) |
87 | (char *)sdev->device_ranges, | 44 | sdev->slot = sbus_dev_slot(base); |
88 | sizeof(sdev->device_ranges)); | 45 | else |
89 | if (len == -1) { | 46 | sdev->slot = sdev->reg_addrs[0].which_io; |
90 | sdev->num_device_ranges = 0; | ||
91 | goto no_ranges; | ||
92 | } | ||
93 | if (len % sizeof(struct linux_prom_ranges)) { | ||
94 | prom_printf("fill_sbus_device: proplen for ranges of %s " | ||
95 | " was %d, need multiple of %d\n", | ||
96 | sdev->prom_name, len, | ||
97 | (int) sizeof(struct linux_prom_ranges)); | ||
98 | prom_halt(); | ||
99 | } | ||
100 | if (len > (sizeof(struct linux_prom_ranges) * PROMREG_MAX)) { | ||
101 | prom_printf("fill_sbus_device: Too many range properties " | ||
102 | "for device %s, len=%d\n", | ||
103 | sdev->prom_name, len); | ||
104 | prom_halt(); | ||
105 | } | 47 | } |
106 | sdev->num_device_ranges = | 48 | |
107 | len / sizeof(struct linux_prom_ranges); | 49 | pval = of_get_property(dp, "ranges", &len); |
108 | 50 | sdev->num_device_ranges = 0; | |
109 | no_ranges: | 51 | if (pval) { |
110 | /* XXX Unfortunately, IRQ issues are very arch specific. | 52 | memcpy(sdev->device_ranges, pval, len); |
111 | * XXX Pull this crud out into an arch specific area | 53 | sdev->num_device_ranges = |
112 | * XXX at some point. -DaveM | 54 | len / sizeof(struct linux_prom_ranges); |
113 | */ | ||
114 | #ifdef CONFIG_SPARC64 | ||
115 | len = prom_getproperty(prom_node, "interrupts", | ||
116 | (char *) irqs, sizeof(irqs)); | ||
117 | if (len == -1 || len == 0) { | ||
118 | sdev->irqs[0] = 0; | ||
119 | sdev->num_irqs = 0; | ||
120 | } else { | ||
121 | unsigned int pri = irqs[0].pri; | ||
122 | |||
123 | sdev->num_irqs = 1; | ||
124 | if (pri < 0x20) | ||
125 | pri += sdev->slot * 8; | ||
126 | |||
127 | sdev->irqs[0] = sbus_build_irq(sdev->bus, pri); | ||
128 | } | 55 | } |
129 | #endif /* CONFIG_SPARC64 */ | ||
130 | |||
131 | #ifdef CONFIG_SPARC32 | ||
132 | len = prom_getproperty(prom_node, "intr", | ||
133 | (char *)irqs, sizeof(irqs)); | ||
134 | if (len != -1) { | ||
135 | sdev->num_irqs = len / 8; | ||
136 | if (sdev->num_irqs == 0) { | ||
137 | sdev->irqs[0] = 0; | ||
138 | } else if (sparc_cpu_model == sun4d) { | ||
139 | extern unsigned int sun4d_build_irq(struct sbus_dev *sdev, int irq); | ||
140 | |||
141 | for (len = 0; len < sdev->num_irqs; len++) | ||
142 | sdev->irqs[len] = sun4d_build_irq(sdev, irqs[len].pri); | ||
143 | } else { | ||
144 | for (len = 0; len < sdev->num_irqs; len++) | ||
145 | sdev->irqs[len] = irqs[len].pri; | ||
146 | } | ||
147 | } else { | ||
148 | /* No "intr" node found-- check for "interrupts" node. | ||
149 | * This node contains SBus interrupt levels, not IPLs | ||
150 | * as in "intr", and no vector values. We convert | ||
151 | * SBus interrupt levels to PILs (platform specific). | ||
152 | */ | ||
153 | len = prom_getproperty(prom_node, "interrupts", | ||
154 | (char *)interrupts, sizeof(interrupts)); | ||
155 | if (len == -1) { | ||
156 | sdev->irqs[0] = 0; | ||
157 | sdev->num_irqs = 0; | ||
158 | } else { | ||
159 | sdev->num_irqs = len / sizeof(int); | ||
160 | for (len = 0; len < sdev->num_irqs; len++) { | ||
161 | sdev->irqs[len] = sbint_to_irq(sdev, interrupts[len]); | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | #endif /* CONFIG_SPARC32 */ | ||
166 | } | ||
167 | 56 | ||
168 | /* This routine gets called from whoever needs the sbus first, to scan | 57 | sbus_fill_device_irq(sdev); |
169 | * the SBus device tree. Currently it just prints out the devices | ||
170 | * found on the bus and builds trees of SBUS structs and attached | ||
171 | * devices. | ||
172 | */ | ||
173 | 58 | ||
174 | extern void iommu_init(int iommu_node, struct sbus_bus *sbus); | 59 | sdev->ofdev.node = dp; |
175 | extern void iounit_init(int sbi_node, int iounit_node, struct sbus_bus *sbus); | 60 | if (sdev->parent) |
176 | void sun4_init(void); | 61 | sdev->ofdev.dev.parent = &sdev->parent->ofdev.dev; |
177 | #ifdef CONFIG_SUN_AUXIO | 62 | else |
178 | extern void auxio_probe(void); | 63 | sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev; |
179 | #endif | 64 | sdev->ofdev.dev.bus = &sbus_bus_type; |
180 | 65 | strcpy(sdev->ofdev.dev.bus_id, dp->path_component_name); | |
181 | static void __init sbus_do_child_siblings(int start_node, | ||
182 | struct sbus_dev *child, | ||
183 | struct sbus_dev *parent, | ||
184 | struct sbus_bus *sbus) | ||
185 | { | ||
186 | struct sbus_dev *this_dev = child; | ||
187 | int this_node = start_node; | ||
188 | |||
189 | /* Child already filled in, just need to traverse siblings. */ | ||
190 | child->child = NULL; | ||
191 | child->parent = parent; | ||
192 | while((this_node = prom_getsibling(this_node)) != 0) { | ||
193 | this_dev->next = kmalloc(sizeof(struct sbus_dev), GFP_ATOMIC); | ||
194 | this_dev = this_dev->next; | ||
195 | this_dev->next = NULL; | ||
196 | this_dev->parent = parent; | ||
197 | |||
198 | this_dev->bus = sbus; | ||
199 | fill_sbus_device(this_node, this_dev); | ||
200 | |||
201 | if(prom_getchild(this_node)) { | ||
202 | this_dev->child = kmalloc(sizeof(struct sbus_dev), | ||
203 | GFP_ATOMIC); | ||
204 | this_dev->child->bus = sbus; | ||
205 | this_dev->child->next = NULL; | ||
206 | fill_sbus_device(prom_getchild(this_node), this_dev->child); | ||
207 | sbus_do_child_siblings(prom_getchild(this_node), | ||
208 | this_dev->child, this_dev, sbus); | ||
209 | } else { | ||
210 | this_dev->child = NULL; | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | 66 | ||
215 | /* | 67 | if (of_device_register(&sdev->ofdev) != 0) |
216 | * XXX This functions appears to be a distorted version of | 68 | printk(KERN_DEBUG "sbus: device registration error for %s!\n", |
217 | * prom_sbus_ranges_init(), with all sun4d stuff cut away. | 69 | sdev->ofdev.dev.bus_id); |
218 | * Ask DaveM what is going on here, how is sun4d supposed to work... XXX | 70 | } |
219 | */ | ||
220 | /* added back sun4d patch from Thomas Bogendoerfer - should be OK (crn) */ | ||
221 | 71 | ||
222 | static void __init sbus_bus_ranges_init(int parent_node, struct sbus_bus *sbus) | 72 | static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus) |
223 | { | 73 | { |
74 | void *pval; | ||
224 | int len; | 75 | int len; |
225 | 76 | ||
226 | len = prom_getproperty(sbus->prom_node, "ranges", | 77 | pval = of_get_property(dp, "ranges", &len); |
227 | (char *) sbus->sbus_ranges, | 78 | sbus->num_sbus_ranges = 0; |
228 | sizeof(sbus->sbus_ranges)); | 79 | if (pval) { |
229 | if (len == -1 || len == 0) { | 80 | memcpy(sbus->sbus_ranges, pval, len); |
230 | sbus->num_sbus_ranges = 0; | 81 | sbus->num_sbus_ranges = |
231 | return; | 82 | len / sizeof(struct linux_prom_ranges); |
232 | } | 83 | |
233 | sbus->num_sbus_ranges = len / sizeof(struct linux_prom_ranges); | 84 | sbus_arch_bus_ranges_init(dp->parent, sbus); |
234 | #ifdef CONFIG_SPARC32 | ||
235 | if (sparc_cpu_model == sun4d) { | ||
236 | struct linux_prom_ranges iounit_ranges[PROMREG_MAX]; | ||
237 | int num_iounit_ranges; | ||
238 | |||
239 | len = prom_getproperty(parent_node, "ranges", | ||
240 | (char *) iounit_ranges, | ||
241 | sizeof (iounit_ranges)); | ||
242 | if (len != -1) { | ||
243 | num_iounit_ranges = (len/sizeof(struct linux_prom_ranges)); | ||
244 | prom_adjust_ranges (sbus->sbus_ranges, sbus->num_sbus_ranges, iounit_ranges, num_iounit_ranges); | ||
245 | } | ||
246 | } | 85 | } |
247 | #endif | ||
248 | } | 86 | } |
249 | 87 | ||
250 | static void __init __apply_ranges_to_regs(struct linux_prom_ranges *ranges, | 88 | static void __init __apply_ranges_to_regs(struct linux_prom_ranges *ranges, |
@@ -322,241 +160,127 @@ static void __init sbus_fixup_all_regs(struct sbus_dev *first_sdev) | |||
322 | } | 160 | } |
323 | } | 161 | } |
324 | 162 | ||
325 | extern void register_proc_sparc_ioport(void); | 163 | /* We preserve the "probe order" of these bus and device lists to give |
326 | extern void firetruck_init(void); | 164 | * the same ordering as the old code. |
165 | */ | ||
166 | static void __init sbus_insert(struct sbus_bus *sbus, struct sbus_bus **root) | ||
167 | { | ||
168 | while (*root) | ||
169 | root = &(*root)->next; | ||
170 | *root = sbus; | ||
171 | sbus->next = NULL; | ||
172 | } | ||
327 | 173 | ||
328 | #ifdef CONFIG_SUN4 | 174 | static void __init sdev_insert(struct sbus_dev *sdev, struct sbus_dev **root) |
329 | extern void sun4_dvma_init(void); | 175 | { |
330 | #endif | 176 | while (*root) |
177 | root = &(*root)->next; | ||
178 | *root = sdev; | ||
179 | sdev->next = NULL; | ||
180 | } | ||
331 | 181 | ||
332 | static int __init sbus_init(void) | 182 | static void __init walk_children(struct device_node *dp, struct sbus_dev *parent, struct sbus_bus *sbus) |
333 | { | 183 | { |
334 | int nd, this_sbus, sbus_devs, topnd, iommund; | 184 | dp = dp->child; |
335 | unsigned int sbus_clock; | 185 | while (dp) { |
336 | struct sbus_bus *sbus; | 186 | struct sbus_dev *sdev; |
337 | struct sbus_dev *this_dev; | ||
338 | int num_sbus = 0; /* How many did we find? */ | ||
339 | 187 | ||
340 | #ifdef CONFIG_SPARC32 | 188 | sdev = kzalloc(sizeof(struct sbus_dev), GFP_ATOMIC); |
341 | register_proc_sparc_ioport(); | 189 | if (sdev) { |
342 | #endif | 190 | sdev_insert(sdev, &parent->child); |
343 | 191 | ||
344 | #ifdef CONFIG_SUN4 | 192 | sdev->bus = sbus; |
345 | sun4_dvma_init(); | 193 | sdev->parent = parent; |
346 | return 0; | 194 | |
347 | #endif | 195 | fill_sbus_device(dp, sdev); |
348 | 196 | ||
349 | topnd = prom_getchild(prom_root_node); | 197 | walk_children(dp, sdev, sbus); |
350 | |||
351 | /* Finding the first sbus is a special case... */ | ||
352 | iommund = 0; | ||
353 | if(sparc_cpu_model == sun4u) { | ||
354 | nd = prom_searchsiblings(topnd, "sbus"); | ||
355 | if(nd == 0) { | ||
356 | #ifdef CONFIG_PCI | ||
357 | if (!pcic_present()) { | ||
358 | prom_printf("Neither SBUS nor PCI found.\n"); | ||
359 | prom_halt(); | ||
360 | } else { | ||
361 | #ifdef CONFIG_SPARC64 | ||
362 | firetruck_init(); | ||
363 | #endif | ||
364 | } | ||
365 | return 0; | ||
366 | #else | ||
367 | prom_printf("YEEE, UltraSparc sbus not found\n"); | ||
368 | prom_halt(); | ||
369 | #endif | ||
370 | } | ||
371 | } else if(sparc_cpu_model == sun4d) { | ||
372 | if((iommund = prom_searchsiblings(topnd, "io-unit")) == 0 || | ||
373 | (nd = prom_getchild(iommund)) == 0 || | ||
374 | (nd = prom_searchsiblings(nd, "sbi")) == 0) { | ||
375 | panic("sbi not found"); | ||
376 | } | ||
377 | } else if((nd = prom_searchsiblings(topnd, "sbus")) == 0) { | ||
378 | if((iommund = prom_searchsiblings(topnd, "iommu")) == 0 || | ||
379 | (nd = prom_getchild(iommund)) == 0 || | ||
380 | (nd = prom_searchsiblings(nd, "sbus")) == 0) { | ||
381 | #ifdef CONFIG_PCI | ||
382 | if (!pcic_present()) { | ||
383 | prom_printf("Neither SBUS nor PCI found.\n"); | ||
384 | prom_halt(); | ||
385 | } | ||
386 | return 0; | ||
387 | #else | ||
388 | /* No reason to run further - the data access trap will occur. */ | ||
389 | panic("sbus not found"); | ||
390 | #endif | ||
391 | } | 198 | } |
199 | dp = dp->sibling; | ||
392 | } | 200 | } |
201 | } | ||
393 | 202 | ||
394 | /* Ok, we've found the first one, allocate first SBus struct | 203 | static void __init build_one_sbus(struct device_node *dp, int num_sbus) |
395 | * and place in chain. | 204 | { |
396 | */ | 205 | struct sbus_bus *sbus; |
397 | sbus = sbus_root = kmalloc(sizeof(struct sbus_bus), GFP_ATOMIC); | 206 | unsigned int sbus_clock; |
398 | sbus->next = NULL; | 207 | struct device_node *dev_dp; |
399 | sbus->prom_node = nd; | ||
400 | this_sbus = nd; | ||
401 | 208 | ||
402 | if(iommund && sparc_cpu_model != sun4u && sparc_cpu_model != sun4d) | 209 | sbus = kzalloc(sizeof(struct sbus_bus), GFP_ATOMIC); |
403 | iommu_init(iommund, sbus); | 210 | if (!sbus) |
211 | return; | ||
404 | 212 | ||
405 | /* Loop until we find no more SBUS's */ | 213 | sbus_insert(sbus, &sbus_root); |
406 | while(this_sbus) { | 214 | sbus->prom_node = dp->node; |
407 | #ifdef CONFIG_SPARC64 | ||
408 | /* IOMMU hides inside SBUS/SYSIO prom node on Ultra. */ | ||
409 | if(sparc_cpu_model == sun4u) { | ||
410 | extern void sbus_iommu_init(int prom_node, struct sbus_bus *sbus); | ||
411 | 215 | ||
412 | sbus_iommu_init(this_sbus, sbus); | 216 | sbus_setup_iommu(sbus, dp); |
413 | } | ||
414 | #endif /* CONFIG_SPARC64 */ | ||
415 | |||
416 | #ifdef CONFIG_SPARC32 | ||
417 | if (sparc_cpu_model == sun4d) | ||
418 | iounit_init(this_sbus, iommund, sbus); | ||
419 | #endif /* CONFIG_SPARC32 */ | ||
420 | printk("sbus%d: ", num_sbus); | ||
421 | sbus_clock = prom_getint(this_sbus, "clock-frequency"); | ||
422 | if(sbus_clock == -1) | ||
423 | sbus_clock = (25*1000*1000); | ||
424 | printk("Clock %d.%d MHz\n", (int) ((sbus_clock/1000)/1000), | ||
425 | (int) (((sbus_clock/1000)%1000 != 0) ? | ||
426 | (((sbus_clock/1000)%1000) + 1000) : 0)); | ||
427 | |||
428 | prom_getstring(this_sbus, "name", | ||
429 | sbus->prom_name, sizeof(sbus->prom_name)); | ||
430 | sbus->clock_freq = sbus_clock; | ||
431 | #ifdef CONFIG_SPARC32 | ||
432 | if (sparc_cpu_model == sun4d) { | ||
433 | sbus->devid = prom_getint(iommund, "device-id"); | ||
434 | sbus->board = prom_getint(iommund, "board#"); | ||
435 | } | ||
436 | #endif | ||
437 | |||
438 | sbus_bus_ranges_init(iommund, sbus); | ||
439 | |||
440 | sbus_devs = prom_getchild(this_sbus); | ||
441 | if (!sbus_devs) { | ||
442 | sbus->devices = NULL; | ||
443 | goto next_bus; | ||
444 | } | ||
445 | 217 | ||
446 | sbus->devices = kmalloc(sizeof(struct sbus_dev), GFP_ATOMIC); | 218 | printk("sbus%d: ", num_sbus); |
447 | |||
448 | this_dev = sbus->devices; | ||
449 | this_dev->next = NULL; | ||
450 | |||
451 | this_dev->bus = sbus; | ||
452 | this_dev->parent = NULL; | ||
453 | fill_sbus_device(sbus_devs, this_dev); | ||
454 | |||
455 | /* Should we traverse for children? */ | ||
456 | if(prom_getchild(sbus_devs)) { | ||
457 | /* Allocate device node */ | ||
458 | this_dev->child = kmalloc(sizeof(struct sbus_dev), | ||
459 | GFP_ATOMIC); | ||
460 | /* Fill it */ | ||
461 | this_dev->child->bus = sbus; | ||
462 | this_dev->child->next = NULL; | ||
463 | fill_sbus_device(prom_getchild(sbus_devs), | ||
464 | this_dev->child); | ||
465 | sbus_do_child_siblings(prom_getchild(sbus_devs), | ||
466 | this_dev->child, | ||
467 | this_dev, | ||
468 | sbus); | ||
469 | } else { | ||
470 | this_dev->child = NULL; | ||
471 | } | ||
472 | 219 | ||
473 | while((sbus_devs = prom_getsibling(sbus_devs)) != 0) { | 220 | sbus_clock = of_getintprop_default(dp, "clock-frequency", |
474 | /* Allocate device node */ | 221 | (25*1000*1000)); |
475 | this_dev->next = kmalloc(sizeof(struct sbus_dev), | 222 | sbus->clock_freq = sbus_clock; |
476 | GFP_ATOMIC); | 223 | |
477 | this_dev = this_dev->next; | 224 | printk("Clock %d.%d MHz\n", (int) ((sbus_clock/1000)/1000), |
478 | this_dev->next = NULL; | 225 | (int) (((sbus_clock/1000)%1000 != 0) ? |
479 | 226 | (((sbus_clock/1000)%1000) + 1000) : 0)); | |
480 | /* Fill it */ | 227 | |
481 | this_dev->bus = sbus; | 228 | strcpy(sbus->prom_name, dp->name); |
482 | this_dev->parent = NULL; | 229 | |
483 | fill_sbus_device(sbus_devs, this_dev); | 230 | sbus_setup_arch_props(sbus, dp); |
484 | 231 | ||
485 | /* Is there a child node hanging off of us? */ | 232 | sbus_bus_ranges_init(dp, sbus); |
486 | if(prom_getchild(sbus_devs)) { | 233 | |
487 | /* Get new device struct */ | 234 | sbus->ofdev.node = dp; |
488 | this_dev->child = kmalloc(sizeof(struct sbus_dev), | 235 | sbus->ofdev.dev.parent = NULL; |
489 | GFP_ATOMIC); | 236 | sbus->ofdev.dev.bus = &sbus_bus_type; |
490 | /* Fill it */ | 237 | strcpy(sbus->ofdev.dev.bus_id, dp->path_component_name); |
491 | this_dev->child->bus = sbus; | 238 | |
492 | this_dev->child->next = NULL; | 239 | if (of_device_register(&sbus->ofdev) != 0) |
493 | fill_sbus_device(prom_getchild(sbus_devs), | 240 | printk(KERN_DEBUG "sbus: device registration error for %s!\n", |
494 | this_dev->child); | 241 | sbus->ofdev.dev.bus_id); |
495 | sbus_do_child_siblings(prom_getchild(sbus_devs), | 242 | |
496 | this_dev->child, | 243 | dev_dp = dp->child; |
497 | this_dev, | 244 | while (dev_dp) { |
498 | sbus); | 245 | struct sbus_dev *sdev; |
499 | } else { | 246 | |
500 | this_dev->child = NULL; | 247 | sdev = kzalloc(sizeof(struct sbus_dev), GFP_ATOMIC); |
501 | } | 248 | if (sdev) { |
249 | sdev_insert(sdev, &sbus->devices); | ||
250 | |||
251 | sdev->bus = sbus; | ||
252 | sdev->parent = NULL; | ||
253 | fill_sbus_device(dev_dp, sdev); | ||
254 | |||
255 | walk_children(dev_dp, sdev, sbus); | ||
502 | } | 256 | } |
257 | dev_dp = dev_dp->sibling; | ||
258 | } | ||
503 | 259 | ||
504 | /* Walk all devices and apply parent ranges. */ | 260 | sbus_fixup_all_regs(sbus->devices); |
505 | sbus_fixup_all_regs(sbus->devices); | ||
506 | 261 | ||
507 | dvma_init(sbus); | 262 | dvma_init(sbus); |
508 | next_bus: | 263 | } |
264 | |||
265 | static int __init sbus_init(void) | ||
266 | { | ||
267 | struct device_node *dp; | ||
268 | const char *sbus_name = "sbus"; | ||
269 | int num_sbus = 0; | ||
270 | |||
271 | if (sbus_arch_preinit()) | ||
272 | return 0; | ||
273 | |||
274 | if (sparc_cpu_model == sun4d) | ||
275 | sbus_name = "sbi"; | ||
276 | |||
277 | for_each_node_by_name(dp, sbus_name) { | ||
278 | build_one_sbus(dp, num_sbus); | ||
509 | num_sbus++; | 279 | num_sbus++; |
510 | if(sparc_cpu_model == sun4u) { | ||
511 | this_sbus = prom_getsibling(this_sbus); | ||
512 | if(!this_sbus) | ||
513 | break; | ||
514 | this_sbus = prom_searchsiblings(this_sbus, "sbus"); | ||
515 | } else if(sparc_cpu_model == sun4d) { | ||
516 | iommund = prom_getsibling(iommund); | ||
517 | if(!iommund) | ||
518 | break; | ||
519 | iommund = prom_searchsiblings(iommund, "io-unit"); | ||
520 | if(!iommund) | ||
521 | break; | ||
522 | this_sbus = prom_searchsiblings(prom_getchild(iommund), "sbi"); | ||
523 | } else { | ||
524 | this_sbus = prom_getsibling(this_sbus); | ||
525 | if(!this_sbus) | ||
526 | break; | ||
527 | this_sbus = prom_searchsiblings(this_sbus, "sbus"); | ||
528 | } | ||
529 | if(this_sbus) { | ||
530 | sbus->next = kmalloc(sizeof(struct sbus_bus), GFP_ATOMIC); | ||
531 | sbus = sbus->next; | ||
532 | sbus->next = NULL; | ||
533 | sbus->prom_node = this_sbus; | ||
534 | } else { | ||
535 | break; | ||
536 | } | ||
537 | } /* while(this_sbus) */ | ||
538 | 280 | ||
539 | if (sparc_cpu_model == sun4d) { | ||
540 | extern void sun4d_init_sbi_irq(void); | ||
541 | sun4d_init_sbi_irq(); | ||
542 | } | ||
543 | |||
544 | #ifdef CONFIG_SPARC64 | ||
545 | if (sparc_cpu_model == sun4u) { | ||
546 | firetruck_init(); | ||
547 | } | 281 | } |
548 | #endif | 282 | |
549 | #ifdef CONFIG_SUN_AUXIO | 283 | sbus_arch_postinit(); |
550 | if (sparc_cpu_model == sun4u) | ||
551 | auxio_probe (); | ||
552 | #endif | ||
553 | #ifdef CONFIG_SPARC64 | ||
554 | if (sparc_cpu_model == sun4u) { | ||
555 | extern void clock_probe(void); | ||
556 | |||
557 | clock_probe(); | ||
558 | } | ||
559 | #endif | ||
560 | 284 | ||
561 | return 0; | 285 | return 0; |
562 | } | 286 | } |
diff --git a/drivers/scsi/esp.c b/drivers/scsi/esp.c index 0a3e45d7a972..ddb512463b45 100644 --- a/drivers/scsi/esp.c +++ b/drivers/scsi/esp.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* $Id: esp.c,v 1.101 2002/01/15 06:48:55 davem Exp $ | 1 | /* esp.c: ESP Sun SCSI driver. |
2 | * esp.c: EnhancedScsiProcessor Sun SCSI driver code. | ||
3 | * | 2 | * |
4 | * Copyright (C) 1995, 1998 David S. Miller (davem@caip.rutgers.edu) | 3 | * Copyright (C) 1995, 1998, 2006 David S. Miller (davem@davemloft.net) |
5 | */ | 4 | */ |
6 | 5 | ||
7 | /* TODO: | 6 | /* TODO: |
@@ -185,11 +184,6 @@ enum { | |||
185 | /*5*/ do_intr_end | 184 | /*5*/ do_intr_end |
186 | }; | 185 | }; |
187 | 186 | ||
188 | /* The master ring of all esp hosts we are managing in this driver. */ | ||
189 | static struct esp *espchain; | ||
190 | static DEFINE_SPINLOCK(espchain_lock); | ||
191 | static int esps_running = 0; | ||
192 | |||
193 | /* Forward declarations. */ | 187 | /* Forward declarations. */ |
194 | static irqreturn_t esp_intr(int irq, void *dev_id, struct pt_regs *pregs); | 188 | static irqreturn_t esp_intr(int irq, void *dev_id, struct pt_regs *pregs); |
195 | 189 | ||
@@ -694,36 +688,6 @@ static void __init esp_bootup_reset(struct esp *esp) | |||
694 | sbus_readb(esp->eregs + ESP_INTRPT); | 688 | sbus_readb(esp->eregs + ESP_INTRPT); |
695 | } | 689 | } |
696 | 690 | ||
697 | static void esp_chain_add(struct esp *esp) | ||
698 | { | ||
699 | spin_lock_irq(&espchain_lock); | ||
700 | if (espchain) { | ||
701 | struct esp *elink = espchain; | ||
702 | while (elink->next) | ||
703 | elink = elink->next; | ||
704 | elink->next = esp; | ||
705 | } else { | ||
706 | espchain = esp; | ||
707 | } | ||
708 | esp->next = NULL; | ||
709 | spin_unlock_irq(&espchain_lock); | ||
710 | } | ||
711 | |||
712 | static void esp_chain_del(struct esp *esp) | ||
713 | { | ||
714 | spin_lock_irq(&espchain_lock); | ||
715 | if (espchain == esp) { | ||
716 | espchain = esp->next; | ||
717 | } else { | ||
718 | struct esp *elink = espchain; | ||
719 | while (elink->next != esp) | ||
720 | elink = elink->next; | ||
721 | elink->next = esp->next; | ||
722 | } | ||
723 | esp->next = NULL; | ||
724 | spin_unlock_irq(&espchain_lock); | ||
725 | } | ||
726 | |||
727 | static int __init esp_find_dvma(struct esp *esp, struct sbus_dev *dma_sdev) | 691 | static int __init esp_find_dvma(struct esp *esp, struct sbus_dev *dma_sdev) |
728 | { | 692 | { |
729 | struct sbus_dev *sdev = esp->sdev; | 693 | struct sbus_dev *sdev = esp->sdev; |
@@ -830,19 +794,20 @@ static int __init esp_register_irq(struct esp *esp) | |||
830 | static void __init esp_get_scsi_id(struct esp *esp) | 794 | static void __init esp_get_scsi_id(struct esp *esp) |
831 | { | 795 | { |
832 | struct sbus_dev *sdev = esp->sdev; | 796 | struct sbus_dev *sdev = esp->sdev; |
797 | struct device_node *dp = sdev->ofdev.node; | ||
833 | 798 | ||
834 | esp->scsi_id = prom_getintdefault(esp->prom_node, | 799 | esp->scsi_id = of_getintprop_default(dp, |
835 | "initiator-id", | 800 | "initiator-id", |
836 | -1); | 801 | -1); |
837 | if (esp->scsi_id == -1) | 802 | if (esp->scsi_id == -1) |
838 | esp->scsi_id = prom_getintdefault(esp->prom_node, | 803 | esp->scsi_id = of_getintprop_default(dp, |
839 | "scsi-initiator-id", | 804 | "scsi-initiator-id", |
840 | -1); | 805 | -1); |
841 | if (esp->scsi_id == -1) | 806 | if (esp->scsi_id == -1) |
842 | esp->scsi_id = (sdev->bus == NULL) ? 7 : | 807 | esp->scsi_id = (sdev->bus == NULL) ? 7 : |
843 | prom_getintdefault(sdev->bus->prom_node, | 808 | of_getintprop_default(sdev->bus->ofdev.node, |
844 | "scsi-initiator-id", | 809 | "scsi-initiator-id", |
845 | 7); | 810 | 7); |
846 | esp->ehost->this_id = esp->scsi_id; | 811 | esp->ehost->this_id = esp->scsi_id; |
847 | esp->scsi_id_mask = (1 << esp->scsi_id); | 812 | esp->scsi_id_mask = (1 << esp->scsi_id); |
848 | 813 | ||
@@ -1067,28 +1032,30 @@ static void __init esp_init_swstate(struct esp *esp) | |||
1067 | esp->prev_hme_dmacsr = 0xffffffff; | 1032 | esp->prev_hme_dmacsr = 0xffffffff; |
1068 | } | 1033 | } |
1069 | 1034 | ||
1070 | static int __init detect_one_esp(struct scsi_host_template *tpnt, struct sbus_dev *esp_dev, | 1035 | static int __init detect_one_esp(struct scsi_host_template *tpnt, |
1071 | struct sbus_dev *espdma, struct sbus_bus *sbus, | 1036 | struct device *dev, |
1072 | int id, int hme) | 1037 | struct sbus_dev *esp_dev, |
1038 | struct sbus_dev *espdma, | ||
1039 | struct sbus_bus *sbus, | ||
1040 | int hme) | ||
1073 | { | 1041 | { |
1074 | struct Scsi_Host *esp_host = scsi_register(tpnt, sizeof(struct esp)); | 1042 | static int instance; |
1043 | struct Scsi_Host *esp_host = scsi_host_alloc(tpnt, sizeof(struct esp)); | ||
1075 | struct esp *esp; | 1044 | struct esp *esp; |
1076 | 1045 | ||
1077 | if (!esp_host) { | 1046 | if (!esp_host) |
1078 | printk("ESP: Cannot register SCSI host\n"); | 1047 | return -ENOMEM; |
1079 | return -1; | 1048 | |
1080 | } | ||
1081 | if (hme) | 1049 | if (hme) |
1082 | esp_host->max_id = 16; | 1050 | esp_host->max_id = 16; |
1083 | esp = (struct esp *) esp_host->hostdata; | 1051 | esp = (struct esp *) esp_host->hostdata; |
1084 | esp->ehost = esp_host; | 1052 | esp->ehost = esp_host; |
1085 | esp->sdev = esp_dev; | 1053 | esp->sdev = esp_dev; |
1086 | esp->esp_id = id; | 1054 | esp->esp_id = instance; |
1087 | esp->prom_node = esp_dev->prom_node; | 1055 | esp->prom_node = esp_dev->prom_node; |
1088 | prom_getstring(esp->prom_node, "name", esp->prom_name, | 1056 | prom_getstring(esp->prom_node, "name", esp->prom_name, |
1089 | sizeof(esp->prom_name)); | 1057 | sizeof(esp->prom_name)); |
1090 | 1058 | ||
1091 | esp_chain_add(esp); | ||
1092 | if (esp_find_dvma(esp, espdma) < 0) | 1059 | if (esp_find_dvma(esp, espdma) < 0) |
1093 | goto fail_unlink; | 1060 | goto fail_unlink; |
1094 | if (esp_map_regs(esp, hme) < 0) { | 1061 | if (esp_map_regs(esp, hme) < 0) { |
@@ -1115,8 +1082,19 @@ static int __init detect_one_esp(struct scsi_host_template *tpnt, struct sbus_de | |||
1115 | 1082 | ||
1116 | esp_bootup_reset(esp); | 1083 | esp_bootup_reset(esp); |
1117 | 1084 | ||
1085 | if (scsi_add_host(esp_host, dev)) | ||
1086 | goto fail_free_irq; | ||
1087 | |||
1088 | dev_set_drvdata(&esp_dev->ofdev.dev, esp); | ||
1089 | |||
1090 | scsi_scan_host(esp_host); | ||
1091 | instance++; | ||
1092 | |||
1118 | return 0; | 1093 | return 0; |
1119 | 1094 | ||
1095 | fail_free_irq: | ||
1096 | free_irq(esp->ehost->irq, esp); | ||
1097 | |||
1120 | fail_unmap_cmdarea: | 1098 | fail_unmap_cmdarea: |
1121 | sbus_free_consistent(esp->sdev, 16, | 1099 | sbus_free_consistent(esp->sdev, 16, |
1122 | (void *) esp->esp_command, | 1100 | (void *) esp->esp_command, |
@@ -1129,119 +1107,98 @@ fail_dvma_release: | |||
1129 | esp->dma->allocated = 0; | 1107 | esp->dma->allocated = 0; |
1130 | 1108 | ||
1131 | fail_unlink: | 1109 | fail_unlink: |
1132 | esp_chain_del(esp); | 1110 | scsi_host_put(esp_host); |
1133 | scsi_unregister(esp_host); | ||
1134 | return -1; | 1111 | return -1; |
1135 | } | 1112 | } |
1136 | 1113 | ||
1137 | /* Detecting ESP chips on the machine. This is the simple and easy | 1114 | /* Detecting ESP chips on the machine. This is the simple and easy |
1138 | * version. | 1115 | * version. |
1139 | */ | 1116 | */ |
1117 | static int __devexit esp_remove_common(struct esp *esp) | ||
1118 | { | ||
1119 | unsigned int irq = esp->ehost->irq; | ||
1120 | |||
1121 | scsi_remove_host(esp->ehost); | ||
1122 | |||
1123 | ESP_INTSOFF(esp->dregs); | ||
1124 | #if 0 | ||
1125 | esp_reset_dma(esp); | ||
1126 | esp_reset_esp(esp); | ||
1127 | #endif | ||
1128 | |||
1129 | free_irq(irq, esp); | ||
1130 | sbus_free_consistent(esp->sdev, 16, | ||
1131 | (void *) esp->esp_command, esp->esp_command_dvma); | ||
1132 | sbus_iounmap(esp->eregs, ESP_REG_SIZE); | ||
1133 | esp->dma->allocated = 0; | ||
1134 | |||
1135 | scsi_host_put(esp->ehost); | ||
1136 | |||
1137 | return 0; | ||
1138 | } | ||
1139 | |||
1140 | 1140 | ||
1141 | #ifdef CONFIG_SUN4 | 1141 | #ifdef CONFIG_SUN4 |
1142 | 1142 | ||
1143 | #include <asm/sun4paddr.h> | 1143 | #include <asm/sun4paddr.h> |
1144 | 1144 | ||
1145 | static int __init esp_detect(struct scsi_host_template *tpnt) | 1145 | static struct sbus_dev sun4_esp_dev; |
1146 | { | ||
1147 | static struct sbus_dev esp_dev; | ||
1148 | int esps_in_use = 0; | ||
1149 | |||
1150 | espchain = NULL; | ||
1151 | 1146 | ||
1147 | static int __init esp_sun4_probe(struct scsi_host_template *tpnt) | ||
1148 | { | ||
1152 | if (sun4_esp_physaddr) { | 1149 | if (sun4_esp_physaddr) { |
1153 | memset (&esp_dev, 0, sizeof(esp_dev)); | 1150 | memset(&sun4_esp_dev, 0, sizeof(esp_dev)); |
1154 | esp_dev.reg_addrs[0].phys_addr = sun4_esp_physaddr; | 1151 | sun4_esp_dev.reg_addrs[0].phys_addr = sun4_esp_physaddr; |
1155 | esp_dev.irqs[0] = 4; | 1152 | sun4_esp_dev.irqs[0] = 4; |
1156 | esp_dev.resource[0].start = sun4_esp_physaddr; | 1153 | sun4_esp_dev.resource[0].start = sun4_esp_physaddr; |
1157 | esp_dev.resource[0].end = sun4_esp_physaddr + ESP_REG_SIZE - 1; | 1154 | sun4_esp_dev.resource[0].end = |
1158 | esp_dev.resource[0].flags = IORESOURCE_IO; | 1155 | sun4_esp_physaddr + ESP_REG_SIZE - 1; |
1159 | 1156 | sun4_esp_dev.resource[0].flags = IORESOURCE_IO; | |
1160 | if (!detect_one_esp(tpnt, &esp_dev, NULL, NULL, 0, 0)) | 1157 | |
1161 | esps_in_use++; | 1158 | return detect_one_esp(tpnt, NULL, |
1162 | printk("ESP: Total of 1 ESP hosts found, %d actually in use.\n", esps_in_use); | 1159 | &sun4_esp_dev, NULL, NULL, 0); |
1163 | esps_running = esps_in_use; | ||
1164 | } | 1160 | } |
1165 | return esps_in_use; | 1161 | return 0; |
1166 | } | 1162 | } |
1167 | 1163 | ||
1168 | #else /* !CONFIG_SUN4 */ | 1164 | static int __devexit esp_sun4_remove(void) |
1169 | |||
1170 | static int __init esp_detect(struct scsi_host_template *tpnt) | ||
1171 | { | 1165 | { |
1172 | struct sbus_bus *sbus; | 1166 | struct esp *esp = dev_get_drvdata(&dev->dev); |
1173 | struct sbus_dev *esp_dev, *sbdev_iter; | ||
1174 | int nesps = 0, esps_in_use = 0; | ||
1175 | 1167 | ||
1176 | espchain = 0; | 1168 | return esp_remove_common(esp); |
1177 | if (!sbus_root) { | ||
1178 | #ifdef CONFIG_PCI | ||
1179 | return 0; | ||
1180 | #else | ||
1181 | panic("No SBUS in esp_detect()"); | ||
1182 | #endif | ||
1183 | } | ||
1184 | for_each_sbus(sbus) { | ||
1185 | for_each_sbusdev(sbdev_iter, sbus) { | ||
1186 | struct sbus_dev *espdma = NULL; | ||
1187 | int hme = 0; | ||
1188 | |||
1189 | /* Is it an esp sbus device? */ | ||
1190 | esp_dev = sbdev_iter; | ||
1191 | if (strcmp(esp_dev->prom_name, "esp") && | ||
1192 | strcmp(esp_dev->prom_name, "SUNW,esp")) { | ||
1193 | if (!strcmp(esp_dev->prom_name, "SUNW,fas")) { | ||
1194 | hme = 1; | ||
1195 | espdma = esp_dev; | ||
1196 | } else { | ||
1197 | if (!esp_dev->child || | ||
1198 | (strcmp(esp_dev->prom_name, "espdma") && | ||
1199 | strcmp(esp_dev->prom_name, "dma"))) | ||
1200 | continue; /* nope... */ | ||
1201 | espdma = esp_dev; | ||
1202 | esp_dev = esp_dev->child; | ||
1203 | if (strcmp(esp_dev->prom_name, "esp") && | ||
1204 | strcmp(esp_dev->prom_name, "SUNW,esp")) | ||
1205 | continue; /* how can this happen? */ | ||
1206 | } | ||
1207 | } | ||
1208 | |||
1209 | if (detect_one_esp(tpnt, esp_dev, espdma, sbus, nesps++, hme) < 0) | ||
1210 | continue; | ||
1211 | |||
1212 | esps_in_use++; | ||
1213 | } /* for each sbusdev */ | ||
1214 | } /* for each sbus */ | ||
1215 | printk("ESP: Total of %d ESP hosts found, %d actually in use.\n", nesps, | ||
1216 | esps_in_use); | ||
1217 | esps_running = esps_in_use; | ||
1218 | return esps_in_use; | ||
1219 | } | 1169 | } |
1220 | 1170 | ||
1221 | #endif /* !CONFIG_SUN4 */ | 1171 | #else /* !CONFIG_SUN4 */ |
1222 | 1172 | ||
1223 | /* | 1173 | static int __devinit esp_sbus_probe(struct of_device *dev, const struct of_device_id *match) |
1224 | */ | ||
1225 | static int esp_release(struct Scsi_Host *host) | ||
1226 | { | 1174 | { |
1227 | struct esp *esp = (struct esp *) host->hostdata; | 1175 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); |
1176 | struct device_node *dp = dev->node; | ||
1177 | struct sbus_dev *dma_sdev = NULL; | ||
1178 | int hme = 0; | ||
1179 | |||
1180 | if (dp->parent && | ||
1181 | (!strcmp(dp->parent->name, "espdma") || | ||
1182 | !strcmp(dp->parent->name, "dma"))) | ||
1183 | dma_sdev = sdev->parent; | ||
1184 | else if (!strcmp(dp->name, "SUNW,fas")) { | ||
1185 | dma_sdev = sdev; | ||
1186 | hme = 1; | ||
1187 | } | ||
1228 | 1188 | ||
1229 | ESP_INTSOFF(esp->dregs); | 1189 | return detect_one_esp(match->data, &dev->dev, |
1230 | #if 0 | 1190 | sdev, dma_sdev, sdev->bus, hme); |
1231 | esp_reset_dma(esp); | 1191 | } |
1232 | esp_reset_esp(esp); | ||
1233 | #endif | ||
1234 | 1192 | ||
1235 | free_irq(esp->ehost->irq, esp); | 1193 | static int __devexit esp_sbus_remove(struct of_device *dev) |
1236 | sbus_free_consistent(esp->sdev, 16, | 1194 | { |
1237 | (void *) esp->esp_command, esp->esp_command_dvma); | 1195 | struct esp *esp = dev_get_drvdata(&dev->dev); |
1238 | sbus_iounmap(esp->eregs, ESP_REG_SIZE); | ||
1239 | esp->dma->allocated = 0; | ||
1240 | esp_chain_del(esp); | ||
1241 | 1196 | ||
1242 | return 0; | 1197 | return esp_remove_common(esp); |
1243 | } | 1198 | } |
1244 | 1199 | ||
1200 | #endif /* !CONFIG_SUN4 */ | ||
1201 | |||
1245 | /* The info function will return whatever useful | 1202 | /* The info function will return whatever useful |
1246 | * information the developer sees fit. If not provided, then | 1203 | * information the developer sees fit. If not provided, then |
1247 | * the name field will be used instead. | 1204 | * the name field will be used instead. |
@@ -1415,18 +1372,11 @@ static int esp_host_info(struct esp *esp, char *ptr, off_t offset, int len) | |||
1415 | static int esp_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, | 1372 | static int esp_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, |
1416 | int length, int inout) | 1373 | int length, int inout) |
1417 | { | 1374 | { |
1418 | struct esp *esp; | 1375 | struct esp *esp = (struct esp *) host->hostdata; |
1419 | 1376 | ||
1420 | if (inout) | 1377 | if (inout) |
1421 | return -EINVAL; /* not yet */ | 1378 | return -EINVAL; /* not yet */ |
1422 | 1379 | ||
1423 | for_each_esp(esp) { | ||
1424 | if (esp->ehost == host) | ||
1425 | break; | ||
1426 | } | ||
1427 | if (!esp) | ||
1428 | return -EINVAL; | ||
1429 | |||
1430 | if (start) | 1380 | if (start) |
1431 | *start = buffer; | 1381 | *start = buffer; |
1432 | 1382 | ||
@@ -4377,15 +4327,12 @@ static void esp_slave_destroy(struct scsi_device *SDptr) | |||
4377 | SDptr->hostdata = NULL; | 4327 | SDptr->hostdata = NULL; |
4378 | } | 4328 | } |
4379 | 4329 | ||
4380 | static struct scsi_host_template driver_template = { | 4330 | static struct scsi_host_template esp_template = { |
4381 | .proc_name = "esp", | 4331 | .module = THIS_MODULE, |
4382 | .proc_info = esp_proc_info, | 4332 | .name = "esp", |
4383 | .name = "Sun ESP 100/100a/200", | 4333 | .info = esp_info, |
4384 | .detect = esp_detect, | ||
4385 | .slave_alloc = esp_slave_alloc, | 4334 | .slave_alloc = esp_slave_alloc, |
4386 | .slave_destroy = esp_slave_destroy, | 4335 | .slave_destroy = esp_slave_destroy, |
4387 | .release = esp_release, | ||
4388 | .info = esp_info, | ||
4389 | .queuecommand = esp_queue, | 4336 | .queuecommand = esp_queue, |
4390 | .eh_abort_handler = esp_abort, | 4337 | .eh_abort_handler = esp_abort, |
4391 | .eh_bus_reset_handler = esp_reset, | 4338 | .eh_bus_reset_handler = esp_reset, |
@@ -4394,12 +4341,58 @@ static struct scsi_host_template driver_template = { | |||
4394 | .sg_tablesize = SG_ALL, | 4341 | .sg_tablesize = SG_ALL, |
4395 | .cmd_per_lun = 1, | 4342 | .cmd_per_lun = 1, |
4396 | .use_clustering = ENABLE_CLUSTERING, | 4343 | .use_clustering = ENABLE_CLUSTERING, |
4344 | .proc_name = "esp", | ||
4345 | .proc_info = esp_proc_info, | ||
4346 | }; | ||
4347 | |||
4348 | #ifndef CONFIG_SUN4 | ||
4349 | static struct of_device_id esp_match[] = { | ||
4350 | { | ||
4351 | .name = "SUNW,esp", | ||
4352 | .data = &esp_template, | ||
4353 | }, | ||
4354 | { | ||
4355 | .name = "SUNW,fas", | ||
4356 | .data = &esp_template, | ||
4357 | }, | ||
4358 | { | ||
4359 | .name = "esp", | ||
4360 | .data = &esp_template, | ||
4361 | }, | ||
4362 | {}, | ||
4363 | }; | ||
4364 | MODULE_DEVICE_TABLE(of, esp_match); | ||
4365 | |||
4366 | static struct of_platform_driver esp_sbus_driver = { | ||
4367 | .name = "esp", | ||
4368 | .match_table = esp_match, | ||
4369 | .probe = esp_sbus_probe, | ||
4370 | .remove = __devexit_p(esp_sbus_remove), | ||
4397 | }; | 4371 | }; |
4372 | #endif | ||
4373 | |||
4374 | static int __init esp_init(void) | ||
4375 | { | ||
4376 | #ifdef CONFIG_SUN4 | ||
4377 | return esp_sun4_probe(&esp_template); | ||
4378 | #else | ||
4379 | return of_register_driver(&esp_sbus_driver, &sbus_bus_type); | ||
4380 | #endif | ||
4381 | } | ||
4398 | 4382 | ||
4399 | #include "scsi_module.c" | 4383 | static void __exit esp_exit(void) |
4384 | { | ||
4385 | #ifdef CONFIG_SUN4 | ||
4386 | esp_sun4_remove(); | ||
4387 | #else | ||
4388 | of_unregister_driver(&esp_sbus_driver); | ||
4389 | #endif | ||
4390 | } | ||
4400 | 4391 | ||
4401 | MODULE_DESCRIPTION("EnhancedScsiProcessor Sun SCSI driver"); | 4392 | MODULE_DESCRIPTION("ESP Sun SCSI driver"); |
4402 | MODULE_AUTHOR("David S. Miller (davem@redhat.com)"); | 4393 | MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); |
4403 | MODULE_LICENSE("GPL"); | 4394 | MODULE_LICENSE("GPL"); |
4404 | MODULE_VERSION(DRV_VERSION); | 4395 | MODULE_VERSION(DRV_VERSION); |
4405 | 4396 | ||
4397 | module_init(esp_init); | ||
4398 | module_exit(esp_exit); | ||
diff --git a/drivers/scsi/esp.h b/drivers/scsi/esp.h index 73f7d6968ab6..a98cda9121fc 100644 --- a/drivers/scsi/esp.h +++ b/drivers/scsi/esp.h | |||
@@ -403,8 +403,4 @@ struct esp { | |||
403 | #define ESP_MHZ_TO_CYCLE(mhertz) ((1000000000) / ((mhertz) / 1000)) | 403 | #define ESP_MHZ_TO_CYCLE(mhertz) ((1000000000) / ((mhertz) / 1000)) |
404 | #define ESP_TICK(ccf, cycle) ((7682 * (ccf) * (cycle) / 1000)) | 404 | #define ESP_TICK(ccf, cycle) ((7682 * (ccf) * (cycle) / 1000)) |
405 | 405 | ||
406 | /* For our interrupt engine. */ | ||
407 | #define for_each_esp(esp) \ | ||
408 | for((esp) = espchain; (esp); (esp) = (esp)->next) | ||
409 | |||
410 | #endif /* !(_SPARC_ESP_H) */ | 406 | #endif /* !(_SPARC_ESP_H) */ |
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index 2203103adced..329ead263714 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* qlogicpti.c: Performance Technologies QlogicISP sbus card driver. | 1 | /* qlogicpti.c: Performance Technologies QlogicISP sbus card driver. |
2 | * | 2 | * |
3 | * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu) | 3 | * Copyright (C) 1996, 2006 David S. Miller (davem@davemloft.net) |
4 | * | 4 | * |
5 | * A lot of this driver was directly stolen from Erik H. Moe's PCI | 5 | * A lot of this driver was directly stolen from Erik H. Moe's PCI |
6 | * Qlogic ISP driver. Mucho kudos to him for this code. | 6 | * Qlogic ISP driver. Mucho kudos to him for this code. |
@@ -46,8 +46,6 @@ | |||
46 | #include <scsi/scsi_tcq.h> | 46 | #include <scsi/scsi_tcq.h> |
47 | #include <scsi/scsi_host.h> | 47 | #include <scsi/scsi_host.h> |
48 | 48 | ||
49 | |||
50 | |||
51 | #define MAX_TARGETS 16 | 49 | #define MAX_TARGETS 16 |
52 | #define MAX_LUNS 8 /* 32 for 1.31 F/W */ | 50 | #define MAX_LUNS 8 /* 32 for 1.31 F/W */ |
53 | 51 | ||
@@ -57,7 +55,6 @@ | |||
57 | 55 | ||
58 | static struct qlogicpti *qptichain = NULL; | 56 | static struct qlogicpti *qptichain = NULL; |
59 | static DEFINE_SPINLOCK(qptichain_lock); | 57 | static DEFINE_SPINLOCK(qptichain_lock); |
60 | static int qptis_running = 0; | ||
61 | 58 | ||
62 | #define PACKB(a, b) (((a)<<4)|(b)) | 59 | #define PACKB(a, b) (((a)<<4)|(b)) |
63 | 60 | ||
@@ -815,173 +812,6 @@ static int __init qpti_map_queues(struct qlogicpti *qpti) | |||
815 | return 0; | 812 | return 0; |
816 | } | 813 | } |
817 | 814 | ||
818 | /* Detect all PTI Qlogic ISP's in the machine. */ | ||
819 | static int __init qlogicpti_detect(struct scsi_host_template *tpnt) | ||
820 | { | ||
821 | struct qlogicpti *qpti; | ||
822 | struct Scsi_Host *qpti_host; | ||
823 | struct sbus_bus *sbus; | ||
824 | struct sbus_dev *sdev; | ||
825 | int nqptis = 0, nqptis_in_use = 0; | ||
826 | |||
827 | tpnt->proc_name = "qlogicpti"; | ||
828 | for_each_sbus(sbus) { | ||
829 | for_each_sbusdev(sdev, sbus) { | ||
830 | /* Is this a red snapper? */ | ||
831 | if (strcmp(sdev->prom_name, "ptisp") && | ||
832 | strcmp(sdev->prom_name, "PTI,ptisp") && | ||
833 | strcmp(sdev->prom_name, "QLGC,isp") && | ||
834 | strcmp(sdev->prom_name, "SUNW,isp")) | ||
835 | continue; | ||
836 | |||
837 | /* Sometimes Antares cards come up not completely | ||
838 | * setup, and we get a report of a zero IRQ. | ||
839 | * Skip over them in such cases so we survive. | ||
840 | */ | ||
841 | if (sdev->irqs[0] == 0) { | ||
842 | printk("qpti%d: Adapter reports no interrupt, " | ||
843 | "skipping over this card.", nqptis); | ||
844 | continue; | ||
845 | } | ||
846 | |||
847 | /* Yep, register and allocate software state. */ | ||
848 | qpti_host = scsi_register(tpnt, sizeof(struct qlogicpti)); | ||
849 | if (!qpti_host) { | ||
850 | printk("QPTI: Cannot register PTI Qlogic ISP SCSI host"); | ||
851 | continue; | ||
852 | } | ||
853 | qpti = (struct qlogicpti *) qpti_host->hostdata; | ||
854 | |||
855 | /* We are wide capable, 16 targets. */ | ||
856 | qpti_host->max_id = MAX_TARGETS; | ||
857 | |||
858 | /* Setup back pointers and misc. state. */ | ||
859 | qpti->qhost = qpti_host; | ||
860 | qpti->sdev = sdev; | ||
861 | qpti->qpti_id = nqptis++; | ||
862 | qpti->prom_node = sdev->prom_node; | ||
863 | prom_getstring(qpti->prom_node, "name", | ||
864 | qpti->prom_name, | ||
865 | sizeof(qpti->prom_name)); | ||
866 | |||
867 | /* This is not correct, actually. There's a switch | ||
868 | * on the PTI cards that put them into "emulation" | ||
869 | * mode- i.e., report themselves as QLGC,isp | ||
870 | * instead of PTI,ptisp. The only real substantive | ||
871 | * difference between non-pti and pti cards is | ||
872 | * the tmon register. Which is possibly even | ||
873 | * there for Qlogic cards, but non-functional. | ||
874 | */ | ||
875 | qpti->is_pti = (strcmp (qpti->prom_name, "QLGC,isp") != 0); | ||
876 | |||
877 | qpti_chain_add(qpti); | ||
878 | if (qpti_map_regs(qpti) < 0) | ||
879 | goto fail_unlink; | ||
880 | |||
881 | if (qpti_register_irq(qpti) < 0) | ||
882 | goto fail_unmap_regs; | ||
883 | |||
884 | qpti_get_scsi_id(qpti); | ||
885 | qpti_get_bursts(qpti); | ||
886 | qpti_get_clock(qpti); | ||
887 | |||
888 | /* Clear out scsi_cmnd array. */ | ||
889 | memset(qpti->cmd_slots, 0, sizeof(qpti->cmd_slots)); | ||
890 | |||
891 | if (qpti_map_queues(qpti) < 0) | ||
892 | goto fail_free_irq; | ||
893 | |||
894 | /* Load the firmware. */ | ||
895 | if (qlogicpti_load_firmware(qpti)) | ||
896 | goto fail_unmap_queues; | ||
897 | if (qpti->is_pti) { | ||
898 | /* Check the PTI status reg. */ | ||
899 | if (qlogicpti_verify_tmon(qpti)) | ||
900 | goto fail_unmap_queues; | ||
901 | } | ||
902 | |||
903 | /* Reset the ISP and init res/req queues. */ | ||
904 | if (qlogicpti_reset_hardware(qpti_host)) | ||
905 | goto fail_unmap_queues; | ||
906 | |||
907 | printk("(Firmware v%d.%d.%d)", qpti->fware_majrev, | ||
908 | qpti->fware_minrev, qpti->fware_micrev); | ||
909 | { | ||
910 | char buffer[60]; | ||
911 | |||
912 | prom_getstring (qpti->prom_node, | ||
913 | "isp-fcode", buffer, 60); | ||
914 | if (buffer[0]) | ||
915 | printk("(Firmware %s)", buffer); | ||
916 | if (prom_getbool(qpti->prom_node, "differential")) | ||
917 | qpti->differential = 1; | ||
918 | } | ||
919 | |||
920 | printk (" [%s Wide, using %s interface]\n", | ||
921 | (qpti->ultra ? "Ultra" : "Fast"), | ||
922 | (qpti->differential ? "differential" : "single ended")); | ||
923 | |||
924 | nqptis_in_use++; | ||
925 | continue; | ||
926 | |||
927 | fail_unmap_queues: | ||
928 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | ||
929 | sbus_free_consistent(qpti->sdev, | ||
930 | QSIZE(RES_QUEUE_LEN), | ||
931 | qpti->res_cpu, qpti->res_dvma); | ||
932 | sbus_free_consistent(qpti->sdev, | ||
933 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | ||
934 | qpti->req_cpu, qpti->req_dvma); | ||
935 | #undef QSIZE | ||
936 | fail_free_irq: | ||
937 | free_irq(qpti->irq, qpti); | ||
938 | |||
939 | fail_unmap_regs: | ||
940 | sbus_iounmap(qpti->qregs, | ||
941 | qpti->sdev->reg_addrs[0].reg_size); | ||
942 | if (qpti->is_pti) | ||
943 | sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | ||
944 | fail_unlink: | ||
945 | qpti_chain_del(qpti); | ||
946 | scsi_unregister(qpti->qhost); | ||
947 | } | ||
948 | } | ||
949 | if (nqptis) | ||
950 | printk("QPTI: Total of %d PTI Qlogic/ISP hosts found, %d actually in use.\n", | ||
951 | nqptis, nqptis_in_use); | ||
952 | qptis_running = nqptis_in_use; | ||
953 | return nqptis; | ||
954 | } | ||
955 | |||
956 | static int qlogicpti_release(struct Scsi_Host *host) | ||
957 | { | ||
958 | struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata; | ||
959 | |||
960 | /* Remove visibility from IRQ handlers. */ | ||
961 | qpti_chain_del(qpti); | ||
962 | |||
963 | /* Shut up the card. */ | ||
964 | sbus_writew(0, qpti->qregs + SBUS_CTRL); | ||
965 | |||
966 | /* Free IRQ handler and unmap Qlogic,ISP and PTI status regs. */ | ||
967 | free_irq(qpti->irq, qpti); | ||
968 | |||
969 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | ||
970 | sbus_free_consistent(qpti->sdev, | ||
971 | QSIZE(RES_QUEUE_LEN), | ||
972 | qpti->res_cpu, qpti->res_dvma); | ||
973 | sbus_free_consistent(qpti->sdev, | ||
974 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | ||
975 | qpti->req_cpu, qpti->req_dvma); | ||
976 | #undef QSIZE | ||
977 | |||
978 | sbus_iounmap(qpti->qregs, qpti->sdev->reg_addrs[0].reg_size); | ||
979 | if (qpti->is_pti) | ||
980 | sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | ||
981 | |||
982 | return 0; | ||
983 | } | ||
984 | |||
985 | const char *qlogicpti_info(struct Scsi_Host *host) | 815 | const char *qlogicpti_info(struct Scsi_Host *host) |
986 | { | 816 | { |
987 | static char buf[80]; | 817 | static char buf[80]; |
@@ -1551,9 +1381,9 @@ static int qlogicpti_reset(struct scsi_cmnd *Cmnd) | |||
1551 | return return_status; | 1381 | return return_status; |
1552 | } | 1382 | } |
1553 | 1383 | ||
1554 | static struct scsi_host_template driver_template = { | 1384 | static struct scsi_host_template qpti_template = { |
1555 | .detect = qlogicpti_detect, | 1385 | .module = THIS_MODULE, |
1556 | .release = qlogicpti_release, | 1386 | .name = "qlogicpti", |
1557 | .info = qlogicpti_info, | 1387 | .info = qlogicpti_info, |
1558 | .queuecommand = qlogicpti_queuecommand_slow, | 1388 | .queuecommand = qlogicpti_queuecommand_slow, |
1559 | .eh_abort_handler = qlogicpti_abort, | 1389 | .eh_abort_handler = qlogicpti_abort, |
@@ -1565,8 +1395,189 @@ static struct scsi_host_template driver_template = { | |||
1565 | .use_clustering = ENABLE_CLUSTERING, | 1395 | .use_clustering = ENABLE_CLUSTERING, |
1566 | }; | 1396 | }; |
1567 | 1397 | ||
1398 | static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_device_id *match) | ||
1399 | { | ||
1400 | static int nqptis; | ||
1401 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | ||
1402 | struct device_node *dp = dev->node; | ||
1403 | struct scsi_host_template *tpnt = match->data; | ||
1404 | struct Scsi_Host *host; | ||
1405 | struct qlogicpti *qpti; | ||
1406 | char *fcode; | ||
1407 | |||
1408 | /* Sometimes Antares cards come up not completely | ||
1409 | * setup, and we get a report of a zero IRQ. | ||
1410 | */ | ||
1411 | if (sdev->irqs[0] == 0) | ||
1412 | return -ENODEV; | ||
1413 | |||
1414 | host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); | ||
1415 | if (!host) | ||
1416 | return -ENOMEM; | ||
1417 | |||
1418 | qpti = (struct qlogicpti *) host->hostdata; | ||
1419 | |||
1420 | host->max_id = MAX_TARGETS; | ||
1421 | qpti->qhost = host; | ||
1422 | qpti->sdev = sdev; | ||
1423 | qpti->qpti_id = nqptis; | ||
1424 | qpti->prom_node = sdev->prom_node; | ||
1425 | strcpy(qpti->prom_name, sdev->ofdev.node->name); | ||
1426 | qpti->is_pti = strcmp(qpti->prom_name, "QLGC,isp"); | ||
1427 | |||
1428 | if (qpti_map_regs(qpti) < 0) | ||
1429 | goto fail_unlink; | ||
1430 | |||
1431 | if (qpti_register_irq(qpti) < 0) | ||
1432 | goto fail_unmap_regs; | ||
1433 | |||
1434 | qpti_get_scsi_id(qpti); | ||
1435 | qpti_get_bursts(qpti); | ||
1436 | qpti_get_clock(qpti); | ||
1437 | |||
1438 | /* Clear out scsi_cmnd array. */ | ||
1439 | memset(qpti->cmd_slots, 0, sizeof(qpti->cmd_slots)); | ||
1440 | |||
1441 | if (qpti_map_queues(qpti) < 0) | ||
1442 | goto fail_free_irq; | ||
1443 | |||
1444 | /* Load the firmware. */ | ||
1445 | if (qlogicpti_load_firmware(qpti)) | ||
1446 | goto fail_unmap_queues; | ||
1447 | if (qpti->is_pti) { | ||
1448 | /* Check the PTI status reg. */ | ||
1449 | if (qlogicpti_verify_tmon(qpti)) | ||
1450 | goto fail_unmap_queues; | ||
1451 | } | ||
1452 | |||
1453 | /* Reset the ISP and init res/req queues. */ | ||
1454 | if (qlogicpti_reset_hardware(host)) | ||
1455 | goto fail_unmap_queues; | ||
1456 | |||
1457 | if (scsi_add_host(host, &dev->dev)) | ||
1458 | goto fail_unmap_queues; | ||
1459 | |||
1460 | printk("(Firmware v%d.%d.%d)", qpti->fware_majrev, | ||
1461 | qpti->fware_minrev, qpti->fware_micrev); | ||
1462 | |||
1463 | fcode = of_get_property(dp, "isp-fcode", NULL); | ||
1464 | if (fcode && fcode[0]) | ||
1465 | printk("(Firmware %s)", fcode); | ||
1466 | if (of_find_property(dp, "differential", NULL) != NULL) | ||
1467 | qpti->differential = 1; | ||
1468 | |||
1469 | printk (" [%s Wide, using %s interface]\n", | ||
1470 | (qpti->ultra ? "Ultra" : "Fast"), | ||
1471 | (qpti->differential ? "differential" : "single ended")); | ||
1472 | |||
1473 | dev_set_drvdata(&sdev->ofdev.dev, qpti); | ||
1474 | |||
1475 | qpti_chain_add(qpti); | ||
1476 | |||
1477 | scsi_scan_host(host); | ||
1478 | nqptis++; | ||
1479 | |||
1480 | return 0; | ||
1481 | |||
1482 | fail_unmap_queues: | ||
1483 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | ||
1484 | sbus_free_consistent(qpti->sdev, | ||
1485 | QSIZE(RES_QUEUE_LEN), | ||
1486 | qpti->res_cpu, qpti->res_dvma); | ||
1487 | sbus_free_consistent(qpti->sdev, | ||
1488 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | ||
1489 | qpti->req_cpu, qpti->req_dvma); | ||
1490 | #undef QSIZE | ||
1491 | |||
1492 | fail_unmap_regs: | ||
1493 | sbus_iounmap(qpti->qregs, | ||
1494 | qpti->sdev->reg_addrs[0].reg_size); | ||
1495 | if (qpti->is_pti) | ||
1496 | sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | ||
1497 | |||
1498 | fail_free_irq: | ||
1499 | free_irq(qpti->irq, qpti); | ||
1500 | |||
1501 | fail_unlink: | ||
1502 | scsi_host_put(host); | ||
1503 | |||
1504 | return -ENODEV; | ||
1505 | } | ||
1506 | |||
1507 | static int __devexit qpti_sbus_remove(struct of_device *dev) | ||
1508 | { | ||
1509 | struct qlogicpti *qpti = dev_get_drvdata(&dev->dev); | ||
1510 | |||
1511 | qpti_chain_del(qpti); | ||
1512 | |||
1513 | scsi_remove_host(qpti->qhost); | ||
1514 | |||
1515 | /* Shut up the card. */ | ||
1516 | sbus_writew(0, qpti->qregs + SBUS_CTRL); | ||
1517 | |||
1518 | /* Free IRQ handler and unmap Qlogic,ISP and PTI status regs. */ | ||
1519 | free_irq(qpti->irq, qpti); | ||
1520 | |||
1521 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | ||
1522 | sbus_free_consistent(qpti->sdev, | ||
1523 | QSIZE(RES_QUEUE_LEN), | ||
1524 | qpti->res_cpu, qpti->res_dvma); | ||
1525 | sbus_free_consistent(qpti->sdev, | ||
1526 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | ||
1527 | qpti->req_cpu, qpti->req_dvma); | ||
1528 | #undef QSIZE | ||
1529 | |||
1530 | sbus_iounmap(qpti->qregs, qpti->sdev->reg_addrs[0].reg_size); | ||
1531 | if (qpti->is_pti) | ||
1532 | sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | ||
1533 | |||
1534 | scsi_host_put(qpti->qhost); | ||
1535 | |||
1536 | return 0; | ||
1537 | } | ||
1538 | |||
1539 | static struct of_device_id qpti_match[] = { | ||
1540 | { | ||
1541 | .name = "ptisp", | ||
1542 | .data = &qpti_template, | ||
1543 | }, | ||
1544 | { | ||
1545 | .name = "PTI,ptisp", | ||
1546 | .data = &qpti_template, | ||
1547 | }, | ||
1548 | { | ||
1549 | .name = "QLGC,isp", | ||
1550 | .data = &qpti_template, | ||
1551 | }, | ||
1552 | { | ||
1553 | .name = "SUNW,isp", | ||
1554 | .data = &qpti_template, | ||
1555 | }, | ||
1556 | {}, | ||
1557 | }; | ||
1558 | MODULE_DEVICE_TABLE(of, qpti_match); | ||
1559 | |||
1560 | static struct of_platform_driver qpti_sbus_driver = { | ||
1561 | .name = "qpti", | ||
1562 | .match_table = qpti_match, | ||
1563 | .probe = qpti_sbus_probe, | ||
1564 | .remove = __devexit_p(qpti_sbus_remove), | ||
1565 | }; | ||
1568 | 1566 | ||
1569 | #include "scsi_module.c" | 1567 | static int __init qpti_init(void) |
1568 | { | ||
1569 | return of_register_driver(&qpti_sbus_driver, &sbus_bus_type); | ||
1570 | } | ||
1571 | |||
1572 | static void __exit qpti_exit(void) | ||
1573 | { | ||
1574 | of_unregister_driver(&qpti_sbus_driver); | ||
1575 | } | ||
1570 | 1576 | ||
1577 | MODULE_DESCRIPTION("QlogicISP SBUS driver"); | ||
1578 | MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); | ||
1571 | MODULE_LICENSE("GPL"); | 1579 | MODULE_LICENSE("GPL"); |
1580 | MODULE_VERSION("2.0"); | ||
1572 | 1581 | ||
1582 | module_init(qpti_init); | ||
1583 | module_exit(qpti_exit); | ||
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index bef4a9622ed7..5b48ac22c9c5 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -354,21 +354,24 @@ config SERIAL_CLPS711X_CONSOLE | |||
354 | kernel at boot time.) | 354 | kernel at boot time.) |
355 | 355 | ||
356 | config SERIAL_S3C2410 | 356 | config SERIAL_S3C2410 |
357 | tristate "Samsung S3C2410 Serial port support" | 357 | tristate "Samsung S3C2410/S3C2440/S3C2442/S3C2412 Serial port support" |
358 | depends on ARM && ARCH_S3C2410 | 358 | depends on ARM && ARCH_S3C2410 |
359 | select SERIAL_CORE | 359 | select SERIAL_CORE |
360 | help | 360 | help |
361 | Support for the on-chip UARTs on the Samsung S3C2410X CPU, | 361 | Support for the on-chip UARTs on the Samsung S3C24XX series CPUs, |
362 | providing /dev/ttySAC0, 1 and 2 (note, some machines may not | 362 | providing /dev/ttySAC0, 1 and 2 (note, some machines may not |
363 | provide all of these ports, depending on how the serial port | 363 | provide all of these ports, depending on how the serial port |
364 | pins are configured. | 364 | pins are configured. |
365 | 365 | ||
366 | Currently this driver supports the UARTS on the S3C2410, S3C2440, | ||
367 | S3C2442, S3C2412 and S3C2413 CPUs. | ||
368 | |||
366 | config SERIAL_S3C2410_CONSOLE | 369 | config SERIAL_S3C2410_CONSOLE |
367 | bool "Support for console on S3C2410 serial port" | 370 | bool "Support for console on S3C2410 serial port" |
368 | depends on SERIAL_S3C2410=y | 371 | depends on SERIAL_S3C2410=y |
369 | select SERIAL_CORE_CONSOLE | 372 | select SERIAL_CORE_CONSOLE |
370 | help | 373 | help |
371 | Allow selection of the S3C2410 on-board serial ports for use as | 374 | Allow selection of the S3C24XX on-board serial ports for use as |
372 | an virtual console. | 375 | an virtual console. |
373 | 376 | ||
374 | Even if you say Y here, the currently visible virtual console | 377 | Even if you say Y here, the currently visible virtual console |
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index 53c2465bad2d..837b6da520b3 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c | |||
@@ -872,6 +872,8 @@ static const char *s3c24xx_serial_type(struct uart_port *port) | |||
872 | return "S3C2410"; | 872 | return "S3C2410"; |
873 | case PORT_S3C2440: | 873 | case PORT_S3C2440: |
874 | return "S3C2440"; | 874 | return "S3C2440"; |
875 | case PORT_S3C2412: | ||
876 | return "S3C2412"; | ||
875 | default: | 877 | default: |
876 | return NULL; | 878 | return NULL; |
877 | } | 879 | } |
@@ -1528,6 +1530,141 @@ static inline void s3c2440_serial_exit(void) | |||
1528 | #define s3c2440_uart_inf_at NULL | 1530 | #define s3c2440_uart_inf_at NULL |
1529 | #endif /* CONFIG_CPU_S3C2440 */ | 1531 | #endif /* CONFIG_CPU_S3C2440 */ |
1530 | 1532 | ||
1533 | #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) | ||
1534 | |||
1535 | static int s3c2412_serial_setsource(struct uart_port *port, | ||
1536 | struct s3c24xx_uart_clksrc *clk) | ||
1537 | { | ||
1538 | unsigned long ucon = rd_regl(port, S3C2410_UCON); | ||
1539 | |||
1540 | ucon &= ~S3C2412_UCON_CLKMASK; | ||
1541 | |||
1542 | if (strcmp(clk->name, "uclk") == 0) | ||
1543 | ucon |= S3C2440_UCON_UCLK; | ||
1544 | else if (strcmp(clk->name, "pclk") == 0) | ||
1545 | ucon |= S3C2440_UCON_PCLK; | ||
1546 | else if (strcmp(clk->name, "usysclk") == 0) | ||
1547 | ucon |= S3C2412_UCON_USYSCLK; | ||
1548 | else { | ||
1549 | printk(KERN_ERR "unknown clock source %s\n", clk->name); | ||
1550 | return -EINVAL; | ||
1551 | } | ||
1552 | |||
1553 | wr_regl(port, S3C2410_UCON, ucon); | ||
1554 | return 0; | ||
1555 | } | ||
1556 | |||
1557 | |||
1558 | static int s3c2412_serial_getsource(struct uart_port *port, | ||
1559 | struct s3c24xx_uart_clksrc *clk) | ||
1560 | { | ||
1561 | unsigned long ucon = rd_regl(port, S3C2410_UCON); | ||
1562 | |||
1563 | switch (ucon & S3C2412_UCON_CLKMASK) { | ||
1564 | case S3C2412_UCON_UCLK: | ||
1565 | clk->divisor = 1; | ||
1566 | clk->name = "uclk"; | ||
1567 | break; | ||
1568 | |||
1569 | case S3C2412_UCON_PCLK: | ||
1570 | case S3C2412_UCON_PCLK2: | ||
1571 | clk->divisor = 1; | ||
1572 | clk->name = "pclk"; | ||
1573 | break; | ||
1574 | |||
1575 | case S3C2412_UCON_USYSCLK: | ||
1576 | clk->divisor = 1; | ||
1577 | clk->name = "usysclk"; | ||
1578 | break; | ||
1579 | } | ||
1580 | |||
1581 | return 0; | ||
1582 | } | ||
1583 | |||
1584 | static int s3c2412_serial_resetport(struct uart_port *port, | ||
1585 | struct s3c2410_uartcfg *cfg) | ||
1586 | { | ||
1587 | unsigned long ucon = rd_regl(port, S3C2410_UCON); | ||
1588 | |||
1589 | dbg("%s: port=%p (%08lx), cfg=%p\n", | ||
1590 | __FUNCTION__, port, port->mapbase, cfg); | ||
1591 | |||
1592 | /* ensure we don't change the clock settings... */ | ||
1593 | |||
1594 | ucon &= S3C2412_UCON_CLKMASK; | ||
1595 | |||
1596 | wr_regl(port, S3C2410_UCON, ucon | cfg->ucon); | ||
1597 | wr_regl(port, S3C2410_ULCON, cfg->ulcon); | ||
1598 | |||
1599 | /* reset both fifos */ | ||
1600 | |||
1601 | wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH); | ||
1602 | wr_regl(port, S3C2410_UFCON, cfg->ufcon); | ||
1603 | |||
1604 | return 0; | ||
1605 | } | ||
1606 | |||
1607 | static struct s3c24xx_uart_info s3c2412_uart_inf = { | ||
1608 | .name = "Samsung S3C2412 UART", | ||
1609 | .type = PORT_S3C2412, | ||
1610 | .fifosize = 64, | ||
1611 | .rx_fifomask = S3C2440_UFSTAT_RXMASK, | ||
1612 | .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT, | ||
1613 | .rx_fifofull = S3C2440_UFSTAT_RXFULL, | ||
1614 | .tx_fifofull = S3C2440_UFSTAT_TXFULL, | ||
1615 | .tx_fifomask = S3C2440_UFSTAT_TXMASK, | ||
1616 | .tx_fifoshift = S3C2440_UFSTAT_TXSHIFT, | ||
1617 | .get_clksrc = s3c2412_serial_getsource, | ||
1618 | .set_clksrc = s3c2412_serial_setsource, | ||
1619 | .reset_port = s3c2412_serial_resetport, | ||
1620 | }; | ||
1621 | |||
1622 | /* device management */ | ||
1623 | |||
1624 | static int s3c2412_serial_probe(struct platform_device *dev) | ||
1625 | { | ||
1626 | dbg("s3c2440_serial_probe: dev=%p\n", dev); | ||
1627 | return s3c24xx_serial_probe(dev, &s3c2440_uart_inf); | ||
1628 | } | ||
1629 | |||
1630 | static struct platform_driver s3c2412_serial_drv = { | ||
1631 | .probe = s3c2412_serial_probe, | ||
1632 | .remove = s3c24xx_serial_remove, | ||
1633 | .suspend = s3c24xx_serial_suspend, | ||
1634 | .resume = s3c24xx_serial_resume, | ||
1635 | .driver = { | ||
1636 | .name = "s3c2412-uart", | ||
1637 | .owner = THIS_MODULE, | ||
1638 | }, | ||
1639 | }; | ||
1640 | |||
1641 | |||
1642 | static inline int s3c2412_serial_init(void) | ||
1643 | { | ||
1644 | return s3c24xx_serial_init(&s3c2412_serial_drv, &s3c2412_uart_inf); | ||
1645 | } | ||
1646 | |||
1647 | static inline void s3c2412_serial_exit(void) | ||
1648 | { | ||
1649 | platform_driver_unregister(&s3c2412_serial_drv); | ||
1650 | } | ||
1651 | |||
1652 | #define s3c2412_uart_inf_at &s3c2412_uart_inf | ||
1653 | #else | ||
1654 | |||
1655 | static inline int s3c2412_serial_init(void) | ||
1656 | { | ||
1657 | return 0; | ||
1658 | } | ||
1659 | |||
1660 | static inline void s3c2412_serial_exit(void) | ||
1661 | { | ||
1662 | } | ||
1663 | |||
1664 | #define s3c2412_uart_inf_at NULL | ||
1665 | #endif /* CONFIG_CPU_S3C2440 */ | ||
1666 | |||
1667 | |||
1531 | /* module initialisation code */ | 1668 | /* module initialisation code */ |
1532 | 1669 | ||
1533 | static int __init s3c24xx_serial_modinit(void) | 1670 | static int __init s3c24xx_serial_modinit(void) |
@@ -1542,6 +1679,7 @@ static int __init s3c24xx_serial_modinit(void) | |||
1542 | 1679 | ||
1543 | s3c2400_serial_init(); | 1680 | s3c2400_serial_init(); |
1544 | s3c2410_serial_init(); | 1681 | s3c2410_serial_init(); |
1682 | s3c2412_serial_init(); | ||
1545 | s3c2440_serial_init(); | 1683 | s3c2440_serial_init(); |
1546 | 1684 | ||
1547 | return 0; | 1685 | return 0; |
@@ -1551,6 +1689,7 @@ static void __exit s3c24xx_serial_modexit(void) | |||
1551 | { | 1689 | { |
1552 | s3c2400_serial_exit(); | 1690 | s3c2400_serial_exit(); |
1553 | s3c2410_serial_exit(); | 1691 | s3c2410_serial_exit(); |
1692 | s3c2412_serial_exit(); | ||
1554 | s3c2440_serial_exit(); | 1693 | s3c2440_serial_exit(); |
1555 | 1694 | ||
1556 | uart_unregister_driver(&s3c24xx_uart_drv); | 1695 | uart_unregister_driver(&s3c24xx_uart_drv); |
@@ -1773,6 +1912,8 @@ static int s3c24xx_serial_initconsole(void) | |||
1773 | info = s3c2410_uart_inf_at; | 1912 | info = s3c2410_uart_inf_at; |
1774 | } else if (strcmp(dev->name, "s3c2440-uart") == 0) { | 1913 | } else if (strcmp(dev->name, "s3c2440-uart") == 0) { |
1775 | info = s3c2440_uart_inf_at; | 1914 | info = s3c2440_uart_inf_at; |
1915 | } else if (strcmp(dev->name, "s3c2412-uart") == 0) { | ||
1916 | info = s3c2412_uart_inf_at; | ||
1776 | } else { | 1917 | } else { |
1777 | printk(KERN_ERR "s3c24xx: no driver for %s\n", dev->name); | 1918 | printk(KERN_ERR "s3c24xx: no driver for %s\n", dev->name); |
1778 | return 0; | 1919 | return 0; |
@@ -1796,4 +1937,4 @@ console_initcall(s3c24xx_serial_initconsole); | |||
1796 | 1937 | ||
1797 | MODULE_LICENSE("GPL"); | 1938 | MODULE_LICENSE("GPL"); |
1798 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); | 1939 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); |
1799 | MODULE_DESCRIPTION("Samsung S3C2410/S3C2440 Serial port driver"); | 1940 | MODULE_DESCRIPTION("Samsung S3C2410/S3C2440/S3C2412 Serial port driver"); |
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c index f137804b3133..ba22e256c6f7 100644 --- a/drivers/serial/sunhv.c +++ b/drivers/serial/sunhv.c | |||
@@ -427,31 +427,32 @@ static int __init hv_console_compatible(char *buf, int len) | |||
427 | 427 | ||
428 | static unsigned int __init get_interrupt(void) | 428 | static unsigned int __init get_interrupt(void) |
429 | { | 429 | { |
430 | const char *cons_str = "console"; | 430 | struct device_node *dev_node; |
431 | const char *compat_str = "compatible"; | ||
432 | int node = prom_getchild(sun4v_vdev_root); | ||
433 | char buf[64]; | ||
434 | int err, len; | ||
435 | |||
436 | node = prom_searchsiblings(node, cons_str); | ||
437 | if (!node) | ||
438 | return 0; | ||
439 | 431 | ||
440 | len = prom_getproplen(node, compat_str); | 432 | dev_node = sun4v_vdev_root->child; |
441 | if (len == 0 || len == -1) | 433 | while (dev_node != NULL) { |
442 | return 0; | 434 | struct property *prop; |
443 | 435 | ||
444 | err = prom_getproperty(node, compat_str, buf, 64); | 436 | if (strcmp(dev_node->name, "console")) |
445 | if (err == -1) | 437 | goto next_sibling; |
446 | return 0; | 438 | |
439 | prop = of_find_property(dev_node, "compatible", NULL); | ||
440 | if (!prop) | ||
441 | goto next_sibling; | ||
447 | 442 | ||
448 | if (!hv_console_compatible(buf, len)) | 443 | if (hv_console_compatible(prop->value, prop->length)) |
444 | break; | ||
445 | |||
446 | next_sibling: | ||
447 | dev_node = dev_node->sibling; | ||
448 | } | ||
449 | if (!dev_node) | ||
449 | return 0; | 450 | return 0; |
450 | 451 | ||
451 | /* Ok, the this is the OBP node for the sun4v hypervisor | 452 | /* Ok, the this is the OBP node for the sun4v hypervisor |
452 | * console device. Decode the interrupt. | 453 | * console device. Decode the interrupt. |
453 | */ | 454 | */ |
454 | return sun4v_vdev_device_interrupt(node); | 455 | return sun4v_vdev_device_interrupt(dev_node); |
455 | } | 456 | } |
456 | 457 | ||
457 | static int __init sunhv_init(void) | 458 | static int __init sunhv_init(void) |
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index bfbe9dc90cca..e4c0fd2d6a9d 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -984,19 +984,19 @@ static void __init for_each_sab_edev(void (*callback)(struct linux_ebus_device * | |||
984 | 984 | ||
985 | for_each_ebus(ebus) { | 985 | for_each_ebus(ebus) { |
986 | for_each_ebusdev(edev, ebus) { | 986 | for_each_ebusdev(edev, ebus) { |
987 | if (!strcmp(edev->prom_name, "se")) { | 987 | if (!strcmp(edev->prom_node->name, "se")) { |
988 | callback(edev, arg); | 988 | callback(edev, arg); |
989 | continue; | 989 | continue; |
990 | } else if (!strcmp(edev->prom_name, "serial")) { | 990 | } else if (!strcmp(edev->prom_node->name, "serial")) { |
991 | char compat[32]; | 991 | char *compat; |
992 | int clen; | 992 | int clen; |
993 | 993 | ||
994 | /* On RIO this can be an SE, check it. We could | 994 | /* On RIO this can be an SE, check it. We could |
995 | * just check ebus->is_rio, but this is more portable. | 995 | * just check ebus->is_rio, but this is more portable. |
996 | */ | 996 | */ |
997 | clen = prom_getproperty(edev->prom_node, "compatible", | 997 | compat = of_get_property(edev->prom_node, |
998 | compat, sizeof(compat)); | 998 | "compatible", &clen); |
999 | if (clen > 0) { | 999 | if (compat && clen > 0) { |
1000 | if (strncmp(compat, "sab82532", 8) == 0) { | 1000 | if (strncmp(compat, "sab82532", 8) == 0) { |
1001 | callback(edev, arg); | 1001 | callback(edev, arg); |
1002 | continue; | 1002 | continue; |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 4cdb610cdd37..0268b307c01e 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -1053,7 +1053,7 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) | |||
1053 | */ | 1053 | */ |
1054 | for_each_ebus(ebus) { | 1054 | for_each_ebus(ebus) { |
1055 | for_each_ebusdev(dev, ebus) { | 1055 | for_each_ebusdev(dev, ebus) { |
1056 | if (dev->prom_node == up->port_node) { | 1056 | if (dev->prom_node->node == up->port_node) { |
1057 | /* | 1057 | /* |
1058 | * The EBus is broken on sparc; it delivers | 1058 | * The EBus is broken on sparc; it delivers |
1059 | * virtual addresses in resources. Oh well... | 1059 | * virtual addresses in resources. Oh well... |
@@ -1073,7 +1073,7 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) | |||
1073 | #ifdef CONFIG_SPARC64 | 1073 | #ifdef CONFIG_SPARC64 |
1074 | for_each_isa(isa_br) { | 1074 | for_each_isa(isa_br) { |
1075 | for_each_isadev(isa_dev, isa_br) { | 1075 | for_each_isadev(isa_dev, isa_br) { |
1076 | if (isa_dev->prom_node == up->port_node) { | 1076 | if (isa_dev->prom_node->node == up->port_node) { |
1077 | /* Same on sparc64. Cool architecure... */ | 1077 | /* Same on sparc64. Cool architecure... */ |
1078 | up->port.membase = (char *) isa_dev->resource.start; | 1078 | up->port.membase = (char *) isa_dev->resource.start; |
1079 | up->port.mapbase = isa_dev->resource.start; | 1079 | up->port.mapbase = isa_dev->resource.start; |
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index 5b6569728a9c..76c9bac9271f 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -1106,7 +1106,7 @@ static struct zilog_layout __iomem * __init get_zs_sun4u(int chip, int zsnode) | |||
1106 | + FHC_UREGS_ICLR; | 1106 | + FHC_UREGS_ICLR; |
1107 | imap = central_bus->child->fhc_regs.uregs | 1107 | imap = central_bus->child->fhc_regs.uregs |
1108 | + FHC_UREGS_IMAP; | 1108 | + FHC_UREGS_IMAP; |
1109 | zilog_irq = build_irq(12, 0, iclr, imap); | 1109 | zilog_irq = build_irq(0, iclr, imap); |
1110 | } else { | 1110 | } else { |
1111 | err = prom_getproperty(zsnode, "interrupts", | 1111 | err = prom_getproperty(zsnode, "interrupts", |
1112 | (char *) &sun4u_ino, | 1112 | (char *) &sun4u_ino, |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 3f8e06279c92..bcbeaf7101d1 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -1078,9 +1078,7 @@ static int proc_submiturb(struct dev_state *ps, void __user *arg) | |||
1078 | if (copy_from_user(&uurb, arg, sizeof(uurb))) | 1078 | if (copy_from_user(&uurb, arg, sizeof(uurb))) |
1079 | return -EFAULT; | 1079 | return -EFAULT; |
1080 | 1080 | ||
1081 | return proc_do_submiturb(ps, &uurb, | 1081 | return proc_do_submiturb(ps, &uurb, (((struct usbdevfs_urb __user *)arg)->iso_frame_desc), arg); |
1082 | (struct usbdevfs_iso_packet_desc __user *)uurb.iso_frame_desc, | ||
1083 | arg); | ||
1084 | } | 1082 | } |
1085 | 1083 | ||
1086 | static int proc_unlinkurb(struct dev_state *ps, void __user *arg) | 1084 | static int proc_unlinkurb(struct dev_state *ps, void __user *arg) |
@@ -1205,9 +1203,7 @@ static int proc_submiturb_compat(struct dev_state *ps, void __user *arg) | |||
1205 | if (get_urb32(&uurb,(struct usbdevfs_urb32 *)arg)) | 1203 | if (get_urb32(&uurb,(struct usbdevfs_urb32 *)arg)) |
1206 | return -EFAULT; | 1204 | return -EFAULT; |
1207 | 1205 | ||
1208 | return proc_do_submiturb(ps, &uurb, | 1206 | return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, arg); |
1209 | (struct usbdevfs_iso_packet_desc __user *)uurb.iso_frame_desc, | ||
1210 | arg); | ||
1211 | } | 1207 | } |
1212 | 1208 | ||
1213 | static int processcompl_compat(struct async *as, void __user * __user *arg) | 1209 | static int processcompl_compat(struct async *as, void __user * __user *arg) |
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index eb6aa42be60e..c054bb28b1c4 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c | |||
@@ -2966,7 +2966,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, | |||
2966 | } | 2966 | } |
2967 | 2967 | ||
2968 | pcp = pdev->sysdata; | 2968 | pcp = pdev->sysdata; |
2969 | if (node == pcp->prom_node) { | 2969 | if (node == pcp->prom_node->node) { |
2970 | struct fb_var_screeninfo *var = &default_var; | 2970 | struct fb_var_screeninfo *var = &default_var; |
2971 | unsigned int N, P, Q, M, T, R; | 2971 | unsigned int N, P, Q, M, T, R; |
2972 | u32 v_total, h_total; | 2972 | u32 v_total, h_total; |
diff --git a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h index 469b06c29180..e290d7460e1b 100644 --- a/drivers/video/intelfb/intelfb.h +++ b/drivers/video/intelfb/intelfb.h | |||
@@ -237,7 +237,7 @@ struct intelfb_info { | |||
237 | u32 fb_start; | 237 | u32 fb_start; |
238 | 238 | ||
239 | /* ring buffer */ | 239 | /* ring buffer */ |
240 | u8 __iomem *ring_head; | 240 | u32 ring_head; |
241 | u32 ring_tail; | 241 | u32 ring_tail; |
242 | u32 ring_tail_mask; | 242 | u32 ring_tail_mask; |
243 | u32 ring_space; | 243 | u32 ring_space; |
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c index 076fa56be192..0a0a8b199ecc 100644 --- a/drivers/video/intelfb/intelfbdrv.c +++ b/drivers/video/intelfb/intelfbdrv.c | |||
@@ -707,7 +707,7 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
707 | + (dinfo->ring.offset << 12); | 707 | + (dinfo->ring.offset << 12); |
708 | dinfo->ring.virtual = dinfo->aperture.virtual | 708 | dinfo->ring.virtual = dinfo->aperture.virtual |
709 | + (dinfo->ring.offset << 12); | 709 | + (dinfo->ring.offset << 12); |
710 | dinfo->ring_head = dinfo->ring.virtual; | 710 | dinfo->ring_head = 0; |
711 | } | 711 | } |
712 | if (dinfo->hwcursor) { | 712 | if (dinfo->hwcursor) { |
713 | agp_memtype = dinfo->mobile ? AGP_PHYSICAL_MEMORY | 713 | agp_memtype = dinfo->mobile ? AGP_PHYSICAL_MEMORY |
@@ -766,18 +766,18 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
766 | if (mtrr) | 766 | if (mtrr) |
767 | set_mtrr(dinfo); | 767 | set_mtrr(dinfo); |
768 | 768 | ||
769 | DBG_MSG("fb: 0x%x(+ 0x%x)/0x%x (0x%x)\n", | 769 | DBG_MSG("fb: 0x%x(+ 0x%x)/0x%x (0x%p)\n", |
770 | dinfo->fb.physical, dinfo->fb.offset, dinfo->fb.size, | 770 | dinfo->fb.physical, dinfo->fb.offset, dinfo->fb.size, |
771 | (u32 __iomem ) dinfo->fb.virtual); | 771 | dinfo->fb.virtual); |
772 | DBG_MSG("MMIO: 0x%x/0x%x (0x%x)\n", | 772 | DBG_MSG("MMIO: 0x%x/0x%x (0x%p)\n", |
773 | dinfo->mmio_base_phys, INTEL_REG_SIZE, | 773 | dinfo->mmio_base_phys, INTEL_REG_SIZE, |
774 | (u32 __iomem) dinfo->mmio_base); | 774 | dinfo->mmio_base); |
775 | DBG_MSG("ring buffer: 0x%x/0x%x (0x%x)\n", | 775 | DBG_MSG("ring buffer: 0x%x/0x%x (0x%p)\n", |
776 | dinfo->ring.physical, dinfo->ring.size, | 776 | dinfo->ring.physical, dinfo->ring.size, |
777 | (u32 __iomem ) dinfo->ring.virtual); | 777 | dinfo->ring.virtual); |
778 | DBG_MSG("HW cursor: 0x%x/0x%x (0x%x) (offset 0x%x) (phys 0x%x)\n", | 778 | DBG_MSG("HW cursor: 0x%x/0x%x (0x%p) (offset 0x%x) (phys 0x%x)\n", |
779 | dinfo->cursor.physical, dinfo->cursor.size, | 779 | dinfo->cursor.physical, dinfo->cursor.size, |
780 | (u32 __iomem ) dinfo->cursor.virtual, dinfo->cursor.offset, | 780 | dinfo->cursor.virtual, dinfo->cursor.offset, |
781 | dinfo->cursor.physical); | 781 | dinfo->cursor.physical); |
782 | 782 | ||
783 | DBG_MSG("options: vram = %d, accel = %d, hwcursor = %d, fixed = %d, " | 783 | DBG_MSG("options: vram = %d, accel = %d, hwcursor = %d, fixed = %d, " |
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c index 426b7430b125..7533b3dd08ac 100644 --- a/drivers/video/intelfb/intelfbhw.c +++ b/drivers/video/intelfb/intelfbhw.c | |||
@@ -1423,19 +1423,17 @@ wait_ring(struct intelfb_info *dinfo, int n) | |||
1423 | 1423 | ||
1424 | end = jiffies + (HZ * 3); | 1424 | end = jiffies + (HZ * 3); |
1425 | while (dinfo->ring_space < n) { | 1425 | while (dinfo->ring_space < n) { |
1426 | dinfo->ring_head = (u8 __iomem *)(INREG(PRI_RING_HEAD) & | 1426 | dinfo->ring_head = INREG(PRI_RING_HEAD) & RING_HEAD_MASK; |
1427 | RING_HEAD_MASK); | 1427 | if (dinfo->ring_tail + RING_MIN_FREE < dinfo->ring_head) |
1428 | if (dinfo->ring_tail + RING_MIN_FREE < | 1428 | dinfo->ring_space = dinfo->ring_head |
1429 | (u32 __iomem) dinfo->ring_head) | ||
1430 | dinfo->ring_space = (u32 __iomem) dinfo->ring_head | ||
1431 | - (dinfo->ring_tail + RING_MIN_FREE); | 1429 | - (dinfo->ring_tail + RING_MIN_FREE); |
1432 | else | 1430 | else |
1433 | dinfo->ring_space = (dinfo->ring.size + | 1431 | dinfo->ring_space = (dinfo->ring.size + |
1434 | (u32 __iomem) dinfo->ring_head) | 1432 | dinfo->ring_head) |
1435 | - (dinfo->ring_tail + RING_MIN_FREE); | 1433 | - (dinfo->ring_tail + RING_MIN_FREE); |
1436 | if ((u32 __iomem) dinfo->ring_head != last_head) { | 1434 | if (dinfo->ring_head != last_head) { |
1437 | end = jiffies + (HZ * 3); | 1435 | end = jiffies + (HZ * 3); |
1438 | last_head = (u32 __iomem) dinfo->ring_head; | 1436 | last_head = dinfo->ring_head; |
1439 | } | 1437 | } |
1440 | i++; | 1438 | i++; |
1441 | if (time_before(end, jiffies)) { | 1439 | if (time_before(end, jiffies)) { |
@@ -1495,15 +1493,13 @@ refresh_ring(struct intelfb_info *dinfo) | |||
1495 | DBG_MSG("refresh_ring\n"); | 1493 | DBG_MSG("refresh_ring\n"); |
1496 | #endif | 1494 | #endif |
1497 | 1495 | ||
1498 | dinfo->ring_head = (u8 __iomem *) (INREG(PRI_RING_HEAD) & | 1496 | dinfo->ring_head = INREG(PRI_RING_HEAD) & RING_HEAD_MASK; |
1499 | RING_HEAD_MASK); | ||
1500 | dinfo->ring_tail = INREG(PRI_RING_TAIL) & RING_TAIL_MASK; | 1497 | dinfo->ring_tail = INREG(PRI_RING_TAIL) & RING_TAIL_MASK; |
1501 | if (dinfo->ring_tail + RING_MIN_FREE < (u32 __iomem)dinfo->ring_head) | 1498 | if (dinfo->ring_tail + RING_MIN_FREE < dinfo->ring_head) |
1502 | dinfo->ring_space = (u32 __iomem) dinfo->ring_head | 1499 | dinfo->ring_space = dinfo->ring_head |
1503 | - (dinfo->ring_tail + RING_MIN_FREE); | 1500 | - (dinfo->ring_tail + RING_MIN_FREE); |
1504 | else | 1501 | else |
1505 | dinfo->ring_space = (dinfo->ring.size + | 1502 | dinfo->ring_space = (dinfo->ring.size + dinfo->ring_head) |
1506 | (u32 __iomem) dinfo->ring_head) | ||
1507 | - (dinfo->ring_tail + RING_MIN_FREE); | 1503 | - (dinfo->ring_tail + RING_MIN_FREE); |
1508 | } | 1504 | } |
1509 | 1505 | ||