diff options
Diffstat (limited to 'drivers')
376 files changed, 16579 insertions, 10726 deletions
diff --git a/drivers/Makefile b/drivers/Makefile index 26ca9031ea49..adad2f3d438a 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -36,6 +36,7 @@ obj-$(CONFIG_FC4) += fc4/ | |||
36 | obj-$(CONFIG_SCSI) += scsi/ | 36 | obj-$(CONFIG_SCSI) += scsi/ |
37 | obj-$(CONFIG_ATA) += ata/ | 37 | obj-$(CONFIG_ATA) += ata/ |
38 | obj-$(CONFIG_FUSION) += message/ | 38 | obj-$(CONFIG_FUSION) += message/ |
39 | obj-$(CONFIG_FIREWIRE) += firewire/ | ||
39 | obj-$(CONFIG_IEEE1394) += ieee1394/ | 40 | obj-$(CONFIG_IEEE1394) += ieee1394/ |
40 | obj-y += cdrom/ | 41 | obj-y += cdrom/ |
41 | obj-y += auxdisplay/ | 42 | obj-y += auxdisplay/ |
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 1683e5c5b94c..1cbe61905824 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c | |||
@@ -231,8 +231,10 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, | |||
231 | * Obtain the method mutex if necessary. Do not acquire mutex for a | 231 | * Obtain the method mutex if necessary. Do not acquire mutex for a |
232 | * recursive call. | 232 | * recursive call. |
233 | */ | 233 | */ |
234 | if (acpi_os_get_thread_id() != | 234 | if (!walk_state || |
235 | obj_desc->method.mutex->mutex.owner_thread_id) { | 235 | !obj_desc->method.mutex->mutex.owner_thread || |
236 | (walk_state->thread != | ||
237 | obj_desc->method.mutex->mutex.owner_thread)) { | ||
236 | /* | 238 | /* |
237 | * Acquire the method mutex. This releases the interpreter if we | 239 | * Acquire the method mutex. This releases the interpreter if we |
238 | * block (and reacquires it before it returns) | 240 | * block (and reacquires it before it returns) |
@@ -246,14 +248,14 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, | |||
246 | } | 248 | } |
247 | 249 | ||
248 | /* Update the mutex and walk info and save the original sync_level */ | 250 | /* Update the mutex and walk info and save the original sync_level */ |
249 | obj_desc->method.mutex->mutex.owner_thread_id = | ||
250 | acpi_os_get_thread_id(); | ||
251 | 251 | ||
252 | if (walk_state) { | 252 | if (walk_state) { |
253 | obj_desc->method.mutex->mutex. | 253 | obj_desc->method.mutex->mutex. |
254 | original_sync_level = | 254 | original_sync_level = |
255 | walk_state->thread->current_sync_level; | 255 | walk_state->thread->current_sync_level; |
256 | 256 | ||
257 | obj_desc->method.mutex->mutex.owner_thread = | ||
258 | walk_state->thread; | ||
257 | walk_state->thread->current_sync_level = | 259 | walk_state->thread->current_sync_level = |
258 | obj_desc->method.sync_level; | 260 | obj_desc->method.sync_level; |
259 | } else { | 261 | } else { |
@@ -567,7 +569,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc, | |||
567 | 569 | ||
568 | acpi_os_release_mutex(method_desc->method.mutex->mutex. | 570 | acpi_os_release_mutex(method_desc->method.mutex->mutex. |
569 | os_mutex); | 571 | os_mutex); |
570 | method_desc->method.mutex->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; | 572 | method_desc->method.mutex->mutex.owner_thread = NULL; |
571 | } | 573 | } |
572 | } | 574 | } |
573 | 575 | ||
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index 6c6104a7a247..fc9da4879cbf 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c | |||
@@ -866,8 +866,7 @@ acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, | |||
866 | ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && | 866 | ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && |
867 | (op->common.parent->common.aml_opcode != | 867 | (op->common.parent->common.aml_opcode != |
868 | AML_VAR_PACKAGE_OP) | 868 | AML_VAR_PACKAGE_OP) |
869 | && (op->common.parent->common.aml_opcode != | 869 | && (op->common.parent->common.aml_opcode != AML_NAME_OP))) { |
870 | AML_NAME_OP))) { | ||
871 | walk_state->result_obj = obj_desc; | 870 | walk_state->result_obj = obj_desc; |
872 | } | 871 | } |
873 | } | 872 | } |
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c index e4073e05a75c..71503c036f7c 100644 --- a/drivers/acpi/dispatcher/dsutils.c +++ b/drivers/acpi/dispatcher/dsutils.c | |||
@@ -556,10 +556,9 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, | |||
556 | * indicate this to the interpreter, set the | 556 | * indicate this to the interpreter, set the |
557 | * object to the root | 557 | * object to the root |
558 | */ | 558 | */ |
559 | obj_desc = | 559 | obj_desc = ACPI_CAST_PTR(union |
560 | ACPI_CAST_PTR(union | 560 | acpi_operand_object, |
561 | acpi_operand_object, | 561 | acpi_gbl_root_node); |
562 | acpi_gbl_root_node); | ||
563 | status = AE_OK; | 562 | status = AE_OK; |
564 | } else { | 563 | } else { |
565 | /* | 564 | /* |
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index 16c8e38b51ef..5afcdd9c7449 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c | |||
@@ -630,12 +630,9 @@ struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread) | |||
630 | * | 630 | * |
631 | ******************************************************************************/ | 631 | ******************************************************************************/ |
632 | 632 | ||
633 | struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, | 633 | struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, union acpi_parse_object |
634 | union acpi_parse_object | 634 | *origin, union acpi_operand_object |
635 | *origin, | 635 | *method_desc, struct acpi_thread_state |
636 | union acpi_operand_object | ||
637 | *method_desc, | ||
638 | struct acpi_thread_state | ||
639 | *thread) | 636 | *thread) |
640 | { | 637 | { |
641 | struct acpi_walk_state *walk_state; | 638 | struct acpi_walk_state *walk_state; |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index e08cf98f504f..82f496c07675 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -147,9 +147,10 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event, | |||
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | 149 | ||
150 | static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, unsigned count) | 150 | static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, |
151 | unsigned count, int force_poll) | ||
151 | { | 152 | { |
152 | if (acpi_ec_mode == EC_POLL) { | 153 | if (unlikely(force_poll) || acpi_ec_mode == EC_POLL) { |
153 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); | 154 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); |
154 | while (time_before(jiffies, delay)) { | 155 | while (time_before(jiffies, delay)) { |
155 | if (acpi_ec_check_status(ec, event, 0)) | 156 | if (acpi_ec_check_status(ec, event, 0)) |
@@ -173,14 +174,15 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, unsigned count) | |||
173 | 174 | ||
174 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | 175 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, |
175 | const u8 * wdata, unsigned wdata_len, | 176 | const u8 * wdata, unsigned wdata_len, |
176 | u8 * rdata, unsigned rdata_len) | 177 | u8 * rdata, unsigned rdata_len, |
178 | int force_poll) | ||
177 | { | 179 | { |
178 | int result = 0; | 180 | int result = 0; |
179 | unsigned count = atomic_read(&ec->event_count); | 181 | unsigned count = atomic_read(&ec->event_count); |
180 | acpi_ec_write_cmd(ec, command); | 182 | acpi_ec_write_cmd(ec, command); |
181 | 183 | ||
182 | for (; wdata_len > 0; --wdata_len) { | 184 | for (; wdata_len > 0; --wdata_len) { |
183 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count); | 185 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count, force_poll); |
184 | if (result) { | 186 | if (result) { |
185 | printk(KERN_ERR PREFIX | 187 | printk(KERN_ERR PREFIX |
186 | "write_cmd timeout, command = %d\n", command); | 188 | "write_cmd timeout, command = %d\n", command); |
@@ -191,7 +193,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | |||
191 | } | 193 | } |
192 | 194 | ||
193 | if (!rdata_len) { | 195 | if (!rdata_len) { |
194 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count); | 196 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count, force_poll); |
195 | if (result) { | 197 | if (result) { |
196 | printk(KERN_ERR PREFIX | 198 | printk(KERN_ERR PREFIX |
197 | "finish-write timeout, command = %d\n", command); | 199 | "finish-write timeout, command = %d\n", command); |
@@ -202,7 +204,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | |||
202 | } | 204 | } |
203 | 205 | ||
204 | for (; rdata_len > 0; --rdata_len) { | 206 | for (; rdata_len > 0; --rdata_len) { |
205 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, count); | 207 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, count, force_poll); |
206 | if (result) { | 208 | if (result) { |
207 | printk(KERN_ERR PREFIX "read timeout, command = %d\n", | 209 | printk(KERN_ERR PREFIX "read timeout, command = %d\n", |
208 | command); | 210 | command); |
@@ -217,7 +219,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | |||
217 | 219 | ||
218 | static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | 220 | static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, |
219 | const u8 * wdata, unsigned wdata_len, | 221 | const u8 * wdata, unsigned wdata_len, |
220 | u8 * rdata, unsigned rdata_len) | 222 | u8 * rdata, unsigned rdata_len, |
223 | int force_poll) | ||
221 | { | 224 | { |
222 | int status; | 225 | int status; |
223 | u32 glk; | 226 | u32 glk; |
@@ -240,7 +243,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | |||
240 | /* Make sure GPE is enabled before doing transaction */ | 243 | /* Make sure GPE is enabled before doing transaction */ |
241 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 244 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); |
242 | 245 | ||
243 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); | 246 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0, 0); |
244 | if (status) { | 247 | if (status) { |
245 | printk(KERN_DEBUG PREFIX | 248 | printk(KERN_DEBUG PREFIX |
246 | "input buffer is not empty, aborting transaction\n"); | 249 | "input buffer is not empty, aborting transaction\n"); |
@@ -249,7 +252,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | |||
249 | 252 | ||
250 | status = acpi_ec_transaction_unlocked(ec, command, | 253 | status = acpi_ec_transaction_unlocked(ec, command, |
251 | wdata, wdata_len, | 254 | wdata, wdata_len, |
252 | rdata, rdata_len); | 255 | rdata, rdata_len, |
256 | force_poll); | ||
253 | 257 | ||
254 | end: | 258 | end: |
255 | 259 | ||
@@ -267,12 +271,12 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | |||
267 | int acpi_ec_burst_enable(struct acpi_ec *ec) | 271 | int acpi_ec_burst_enable(struct acpi_ec *ec) |
268 | { | 272 | { |
269 | u8 d; | 273 | u8 d; |
270 | return acpi_ec_transaction(ec, ACPI_EC_BURST_ENABLE, NULL, 0, &d, 1); | 274 | return acpi_ec_transaction(ec, ACPI_EC_BURST_ENABLE, NULL, 0, &d, 1, 0); |
271 | } | 275 | } |
272 | 276 | ||
273 | int acpi_ec_burst_disable(struct acpi_ec *ec) | 277 | int acpi_ec_burst_disable(struct acpi_ec *ec) |
274 | { | 278 | { |
275 | return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0); | 279 | return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0, 0); |
276 | } | 280 | } |
277 | 281 | ||
278 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) | 282 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) |
@@ -281,7 +285,7 @@ static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) | |||
281 | u8 d; | 285 | u8 d; |
282 | 286 | ||
283 | result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ, | 287 | result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ, |
284 | &address, 1, &d, 1); | 288 | &address, 1, &d, 1, 0); |
285 | *data = d; | 289 | *data = d; |
286 | return result; | 290 | return result; |
287 | } | 291 | } |
@@ -290,7 +294,7 @@ static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) | |||
290 | { | 294 | { |
291 | u8 wdata[2] = { address, data }; | 295 | u8 wdata[2] = { address, data }; |
292 | return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE, | 296 | return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE, |
293 | wdata, 2, NULL, 0); | 297 | wdata, 2, NULL, 0, 0); |
294 | } | 298 | } |
295 | 299 | ||
296 | /* | 300 | /* |
@@ -349,13 +353,15 @@ EXPORT_SYMBOL(ec_write); | |||
349 | 353 | ||
350 | int ec_transaction(u8 command, | 354 | int ec_transaction(u8 command, |
351 | const u8 * wdata, unsigned wdata_len, | 355 | const u8 * wdata, unsigned wdata_len, |
352 | u8 * rdata, unsigned rdata_len) | 356 | u8 * rdata, unsigned rdata_len, |
357 | int force_poll) | ||
353 | { | 358 | { |
354 | if (!first_ec) | 359 | if (!first_ec) |
355 | return -ENODEV; | 360 | return -ENODEV; |
356 | 361 | ||
357 | return acpi_ec_transaction(first_ec, command, wdata, | 362 | return acpi_ec_transaction(first_ec, command, wdata, |
358 | wdata_len, rdata, rdata_len); | 363 | wdata_len, rdata, rdata_len, |
364 | force_poll); | ||
359 | } | 365 | } |
360 | 366 | ||
361 | EXPORT_SYMBOL(ec_transaction); | 367 | EXPORT_SYMBOL(ec_transaction); |
@@ -374,7 +380,7 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 * data) | |||
374 | * bit to be cleared (and thus clearing the interrupt source). | 380 | * bit to be cleared (and thus clearing the interrupt source). |
375 | */ | 381 | */ |
376 | 382 | ||
377 | result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1); | 383 | result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1, 0); |
378 | if (result) | 384 | if (result) |
379 | return result; | 385 | return result; |
380 | 386 | ||
@@ -410,6 +416,7 @@ static u32 acpi_ec_gpe_handler(void *data) | |||
410 | acpi_status status = AE_OK; | 416 | acpi_status status = AE_OK; |
411 | u8 value; | 417 | u8 value; |
412 | struct acpi_ec *ec = data; | 418 | struct acpi_ec *ec = data; |
419 | |||
413 | atomic_inc(&ec->event_count); | 420 | atomic_inc(&ec->event_count); |
414 | 421 | ||
415 | if (acpi_ec_mode == EC_INTR) { | 422 | if (acpi_ec_mode == EC_INTR) { |
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index 635ba449ebc2..e22f4a973c0f 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c | |||
@@ -341,9 +341,8 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, | |||
341 | 341 | ||
342 | /* A Non-NULL gpe_device means this is a GPE Block Device */ | 342 | /* A Non-NULL gpe_device means this is a GPE Block Device */ |
343 | 343 | ||
344 | obj_desc = | 344 | obj_desc = acpi_ns_get_attached_object((struct acpi_namespace_node *) |
345 | acpi_ns_get_attached_object((struct acpi_namespace_node *) | 345 | gpe_device); |
346 | gpe_device); | ||
347 | if (!obj_desc || !obj_desc->device.gpe_block) { | 346 | if (!obj_desc || !obj_desc->device.gpe_block) { |
348 | return (NULL); | 347 | return (NULL); |
349 | } | 348 | } |
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index ad5bc76edf46..902c287b3a4f 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c | |||
@@ -1033,8 +1033,7 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, | |||
1033 | 1033 | ||
1034 | if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | 1034 | if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == |
1035 | ACPI_GPE_DISPATCH_METHOD) | 1035 | ACPI_GPE_DISPATCH_METHOD) |
1036 | && (gpe_event_info-> | 1036 | && (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { |
1037 | flags & ACPI_GPE_TYPE_RUNTIME)) { | ||
1038 | gpe_enabled_count++; | 1037 | gpe_enabled_count++; |
1039 | } | 1038 | } |
1040 | 1039 | ||
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index cae786ca8600..21cb749d0c75 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c | |||
@@ -196,15 +196,12 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, | |||
196 | notify_info->notify.value = (u16) notify_value; | 196 | notify_info->notify.value = (u16) notify_value; |
197 | notify_info->notify.handler_obj = handler_obj; | 197 | notify_info->notify.handler_obj = handler_obj; |
198 | 198 | ||
199 | acpi_ex_exit_interpreter(); | 199 | status = |
200 | 200 | acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_notify_dispatch, | |
201 | acpi_ev_notify_dispatch(notify_info); | 201 | notify_info); |
202 | |||
203 | status = acpi_ex_enter_interpreter(); | ||
204 | if (ACPI_FAILURE(status)) { | 202 | if (ACPI_FAILURE(status)) { |
205 | return_ACPI_STATUS(status); | 203 | acpi_ut_delete_generic_state(notify_info); |
206 | } | 204 | } |
207 | |||
208 | } | 205 | } |
209 | 206 | ||
210 | if (!handler_obj) { | 207 | if (!handler_obj) { |
@@ -323,8 +320,9 @@ static u32 acpi_ev_global_lock_handler(void *context) | |||
323 | acpi_gbl_global_lock_acquired = TRUE; | 320 | acpi_gbl_global_lock_acquired = TRUE; |
324 | /* Send a unit to the semaphore */ | 321 | /* Send a unit to the semaphore */ |
325 | 322 | ||
326 | if (ACPI_FAILURE(acpi_os_signal_semaphore( | 323 | if (ACPI_FAILURE |
327 | acpi_gbl_global_lock_semaphore, 1))) { | 324 | (acpi_os_signal_semaphore |
325 | (acpi_gbl_global_lock_semaphore, 1))) { | ||
328 | ACPI_ERROR((AE_INFO, | 326 | ACPI_ERROR((AE_INFO, |
329 | "Could not signal Global Lock semaphore")); | 327 | "Could not signal Global Lock semaphore")); |
330 | } | 328 | } |
@@ -450,7 +448,9 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout) | |||
450 | } | 448 | } |
451 | 449 | ||
452 | if (ACPI_FAILURE(status)) { | 450 | if (ACPI_FAILURE(status)) { |
453 | status = acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex, timeout); | 451 | status = |
452 | acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex, | ||
453 | timeout); | ||
454 | } | 454 | } |
455 | if (ACPI_FAILURE(status)) { | 455 | if (ACPI_FAILURE(status)) { |
456 | return_ACPI_STATUS(status); | 456 | return_ACPI_STATUS(status); |
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c index 96b0e8431748..e99f0c435a47 100644 --- a/drivers/acpi/events/evregion.c +++ b/drivers/acpi/events/evregion.c | |||
@@ -291,7 +291,6 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, | |||
291 | u32 bit_width, acpi_integer * value) | 291 | u32 bit_width, acpi_integer * value) |
292 | { | 292 | { |
293 | acpi_status status; | 293 | acpi_status status; |
294 | acpi_status status2; | ||
295 | acpi_adr_space_handler handler; | 294 | acpi_adr_space_handler handler; |
296 | acpi_adr_space_setup region_setup; | 295 | acpi_adr_space_setup region_setup; |
297 | union acpi_operand_object *handler_desc; | 296 | union acpi_operand_object *handler_desc; |
@@ -345,7 +344,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, | |||
345 | * setup will potentially execute control methods | 344 | * setup will potentially execute control methods |
346 | * (e.g., _REG method for this region) | 345 | * (e.g., _REG method for this region) |
347 | */ | 346 | */ |
348 | acpi_ex_exit_interpreter(); | 347 | acpi_ex_relinquish_interpreter(); |
349 | 348 | ||
350 | status = region_setup(region_obj, ACPI_REGION_ACTIVATE, | 349 | status = region_setup(region_obj, ACPI_REGION_ACTIVATE, |
351 | handler_desc->address_space.context, | 350 | handler_desc->address_space.context, |
@@ -353,10 +352,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, | |||
353 | 352 | ||
354 | /* Re-enter the interpreter */ | 353 | /* Re-enter the interpreter */ |
355 | 354 | ||
356 | status2 = acpi_ex_enter_interpreter(); | 355 | acpi_ex_reacquire_interpreter(); |
357 | if (ACPI_FAILURE(status2)) { | ||
358 | return_ACPI_STATUS(status2); | ||
359 | } | ||
360 | 356 | ||
361 | /* Check for failure of the Region Setup */ | 357 | /* Check for failure of the Region Setup */ |
362 | 358 | ||
@@ -409,7 +405,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, | |||
409 | * exit the interpreter because the handler *might* block -- we don't | 405 | * exit the interpreter because the handler *might* block -- we don't |
410 | * know what it will do, so we can't hold the lock on the intepreter. | 406 | * know what it will do, so we can't hold the lock on the intepreter. |
411 | */ | 407 | */ |
412 | acpi_ex_exit_interpreter(); | 408 | acpi_ex_relinquish_interpreter(); |
413 | } | 409 | } |
414 | 410 | ||
415 | /* Call the handler */ | 411 | /* Call the handler */ |
@@ -430,10 +426,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, | |||
430 | * We just returned from a non-default handler, we must re-enter the | 426 | * We just returned from a non-default handler, we must re-enter the |
431 | * interpreter | 427 | * interpreter |
432 | */ | 428 | */ |
433 | status2 = acpi_ex_enter_interpreter(); | 429 | acpi_ex_reacquire_interpreter(); |
434 | if (ACPI_FAILURE(status2)) { | ||
435 | return_ACPI_STATUS(status2); | ||
436 | } | ||
437 | } | 430 | } |
438 | 431 | ||
439 | return_ACPI_STATUS(status); | 432 | return_ACPI_STATUS(status); |
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c index a4fa7e6822a3..400d90fca966 100644 --- a/drivers/acpi/events/evrgnini.c +++ b/drivers/acpi/events/evrgnini.c | |||
@@ -228,7 +228,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle, | |||
228 | 228 | ||
229 | /* Install a handler for this PCI root bridge */ | 229 | /* Install a handler for this PCI root bridge */ |
230 | 230 | ||
231 | status = acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); | 231 | status = |
232 | acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); | ||
232 | if (ACPI_FAILURE(status)) { | 233 | if (ACPI_FAILURE(status)) { |
233 | if (status == AE_SAME_HANDLER) { | 234 | if (status == AE_SAME_HANDLER) { |
234 | /* | 235 | /* |
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index a3379bafa676..6d866a01f5f4 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c | |||
@@ -91,7 +91,6 @@ acpi_status acpi_install_exception_handler(acpi_exception_handler handler) | |||
91 | 91 | ||
92 | ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) | 92 | ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) |
93 | #endif /* ACPI_FUTURE_USAGE */ | 93 | #endif /* ACPI_FUTURE_USAGE */ |
94 | |||
95 | /******************************************************************************* | 94 | /******************************************************************************* |
96 | * | 95 | * |
97 | * FUNCTION: acpi_install_fixed_event_handler | 96 | * FUNCTION: acpi_install_fixed_event_handler |
@@ -768,11 +767,9 @@ acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle) | |||
768 | return (AE_BAD_PARAMETER); | 767 | return (AE_BAD_PARAMETER); |
769 | } | 768 | } |
770 | 769 | ||
771 | status = acpi_ex_enter_interpreter(); | 770 | /* Must lock interpreter to prevent race conditions */ |
772 | if (ACPI_FAILURE(status)) { | ||
773 | return (status); | ||
774 | } | ||
775 | 771 | ||
772 | acpi_ex_enter_interpreter(); | ||
776 | status = acpi_ev_acquire_global_lock(timeout); | 773 | status = acpi_ev_acquire_global_lock(timeout); |
777 | acpi_ex_exit_interpreter(); | 774 | acpi_ex_exit_interpreter(); |
778 | 775 | ||
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index 17065e98807c..9cbd3414a574 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c | |||
@@ -472,7 +472,6 @@ acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | |||
472 | } | 472 | } |
473 | 473 | ||
474 | ACPI_EXPORT_SYMBOL(acpi_clear_gpe) | 474 | ACPI_EXPORT_SYMBOL(acpi_clear_gpe) |
475 | |||
476 | #ifdef ACPI_FUTURE_USAGE | 475 | #ifdef ACPI_FUTURE_USAGE |
477 | /******************************************************************************* | 476 | /******************************************************************************* |
478 | * | 477 | * |
@@ -568,7 +567,6 @@ acpi_get_gpe_status(acpi_handle gpe_device, | |||
568 | 567 | ||
569 | ACPI_EXPORT_SYMBOL(acpi_get_gpe_status) | 568 | ACPI_EXPORT_SYMBOL(acpi_get_gpe_status) |
570 | #endif /* ACPI_FUTURE_USAGE */ | 569 | #endif /* ACPI_FUTURE_USAGE */ |
571 | |||
572 | /******************************************************************************* | 570 | /******************************************************************************* |
573 | * | 571 | * |
574 | * FUNCTION: acpi_install_gpe_block | 572 | * FUNCTION: acpi_install_gpe_block |
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index d470e8b1f4ea..79f2c0d42c06 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c | |||
@@ -512,9 +512,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, | |||
512 | * Create a new string object and string buffer | 512 | * Create a new string object and string buffer |
513 | * (-1 because of extra separator included in string_length from above) | 513 | * (-1 because of extra separator included in string_length from above) |
514 | */ | 514 | */ |
515 | return_desc = | 515 | return_desc = acpi_ut_create_string_object((acpi_size) |
516 | acpi_ut_create_string_object((acpi_size) | 516 | (string_length - 1)); |
517 | (string_length - 1)); | ||
518 | if (!return_desc) { | 517 | if (!return_desc) { |
519 | return_ACPI_STATUS(AE_NO_MEMORY); | 518 | return_ACPI_STATUS(AE_NO_MEMORY); |
520 | } | 519 | } |
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c index ae97812681a3..6e9a23e47fef 100644 --- a/drivers/acpi/executer/excreate.c +++ b/drivers/acpi/executer/excreate.c | |||
@@ -50,7 +50,6 @@ | |||
50 | 50 | ||
51 | #define _COMPONENT ACPI_EXECUTER | 51 | #define _COMPONENT ACPI_EXECUTER |
52 | ACPI_MODULE_NAME("excreate") | 52 | ACPI_MODULE_NAME("excreate") |
53 | |||
54 | #ifndef ACPI_NO_METHOD_EXECUTION | 53 | #ifndef ACPI_NO_METHOD_EXECUTION |
55 | /******************************************************************************* | 54 | /******************************************************************************* |
56 | * | 55 | * |
@@ -583,10 +582,7 @@ acpi_ex_create_method(u8 * aml_start, | |||
583 | * Get the sync_level. If method is serialized, a mutex will be | 582 | * Get the sync_level. If method is serialized, a mutex will be |
584 | * created for this method when it is parsed. | 583 | * created for this method when it is parsed. |
585 | */ | 584 | */ |
586 | if (acpi_gbl_all_methods_serialized) { | 585 | if (method_flags & AML_METHOD_SERIALIZED) { |
587 | obj_desc->method.sync_level = 0; | ||
588 | obj_desc->method.method_flags |= AML_METHOD_SERIALIZED; | ||
589 | } else if (method_flags & AML_METHOD_SERIALIZED) { | ||
590 | /* | 586 | /* |
591 | * ACPI 1.0: sync_level = 0 | 587 | * ACPI 1.0: sync_level = 0 |
592 | * ACPI 2.0: sync_level = sync_level in method declaration | 588 | * ACPI 2.0: sync_level = sync_level in method declaration |
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 1a73c14df2c5..51c9c29987c3 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c | |||
@@ -134,7 +134,7 @@ static struct acpi_exdump_info acpi_ex_dump_method[8] = { | |||
134 | static struct acpi_exdump_info acpi_ex_dump_mutex[5] = { | 134 | static struct acpi_exdump_info acpi_ex_dump_mutex[5] = { |
135 | {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL}, | 135 | {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL}, |
136 | {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"}, | 136 | {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"}, |
137 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread_id), "Owner Thread"}, | 137 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"}, |
138 | {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), | 138 | {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), |
139 | "Acquire Depth"}, | 139 | "Acquire Depth"}, |
140 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"} | 140 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"} |
@@ -451,9 +451,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) | |||
451 | 451 | ||
452 | ACPI_FUNCTION_NAME(ex_dump_operand) | 452 | ACPI_FUNCTION_NAME(ex_dump_operand) |
453 | 453 | ||
454 | if (! | 454 | if (!((ACPI_LV_EXEC & acpi_dbg_level) |
455 | ((ACPI_LV_EXEC & acpi_dbg_level) | 455 | && (_COMPONENT & acpi_dbg_layer))) { |
456 | && (_COMPONENT & acpi_dbg_layer))) { | ||
457 | return; | 456 | return; |
458 | } | 457 | } |
459 | 458 | ||
@@ -844,9 +843,8 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags) | |||
844 | ACPI_FUNCTION_ENTRY(); | 843 | ACPI_FUNCTION_ENTRY(); |
845 | 844 | ||
846 | if (!flags) { | 845 | if (!flags) { |
847 | if (! | 846 | if (!((ACPI_LV_OBJECTS & acpi_dbg_level) |
848 | ((ACPI_LV_OBJECTS & acpi_dbg_level) | 847 | && (_COMPONENT & acpi_dbg_layer))) { |
849 | && (_COMPONENT & acpi_dbg_layer))) { | ||
850 | return; | 848 | return; |
851 | } | 849 | } |
852 | } | 850 | } |
@@ -1011,9 +1009,8 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags) | |||
1011 | } | 1009 | } |
1012 | 1010 | ||
1013 | if (!flags) { | 1011 | if (!flags) { |
1014 | if (! | 1012 | if (!((ACPI_LV_OBJECTS & acpi_dbg_level) |
1015 | ((ACPI_LV_OBJECTS & acpi_dbg_level) | 1013 | && (_COMPONENT & acpi_dbg_layer))) { |
1016 | && (_COMPONENT & acpi_dbg_layer))) { | ||
1017 | return_VOID; | 1014 | return_VOID; |
1018 | } | 1015 | } |
1019 | } | 1016 | } |
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c index 4eb883bda6ae..6748e3ef0997 100644 --- a/drivers/acpi/executer/exmutex.c +++ b/drivers/acpi/executer/exmutex.c | |||
@@ -66,9 +66,10 @@ acpi_ex_link_mutex(union acpi_operand_object *obj_desc, | |||
66 | * | 66 | * |
67 | ******************************************************************************/ | 67 | ******************************************************************************/ |
68 | 68 | ||
69 | void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc, | 69 | void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc) |
70 | struct acpi_thread_state *thread) | ||
71 | { | 70 | { |
71 | struct acpi_thread_state *thread = obj_desc->mutex.owner_thread; | ||
72 | |||
72 | if (!thread) { | 73 | if (!thread) { |
73 | return; | 74 | return; |
74 | } | 75 | } |
@@ -173,13 +174,16 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, | |||
173 | 174 | ||
174 | /* Support for multiple acquires by the owning thread */ | 175 | /* Support for multiple acquires by the owning thread */ |
175 | 176 | ||
176 | if (obj_desc->mutex.owner_thread_id == acpi_os_get_thread_id()) { | 177 | if (obj_desc->mutex.owner_thread) { |
177 | /* | 178 | if (obj_desc->mutex.owner_thread->thread_id == |
178 | * The mutex is already owned by this thread, just increment the | 179 | walk_state->thread->thread_id) { |
179 | * acquisition depth | 180 | /* |
180 | */ | 181 | * The mutex is already owned by this thread, just increment the |
181 | obj_desc->mutex.acquisition_depth++; | 182 | * acquisition depth |
182 | return_ACPI_STATUS(AE_OK); | 183 | */ |
184 | obj_desc->mutex.acquisition_depth++; | ||
185 | return_ACPI_STATUS(AE_OK); | ||
186 | } | ||
183 | } | 187 | } |
184 | 188 | ||
185 | /* Acquire the mutex, wait if necessary. Special case for Global Lock */ | 189 | /* Acquire the mutex, wait if necessary. Special case for Global Lock */ |
@@ -202,7 +206,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, | |||
202 | 206 | ||
203 | /* Have the mutex: update mutex and walk info and save the sync_level */ | 207 | /* Have the mutex: update mutex and walk info and save the sync_level */ |
204 | 208 | ||
205 | obj_desc->mutex.owner_thread_id = acpi_os_get_thread_id(); | 209 | obj_desc->mutex.owner_thread = walk_state->thread; |
206 | obj_desc->mutex.acquisition_depth = 1; | 210 | obj_desc->mutex.acquisition_depth = 1; |
207 | obj_desc->mutex.original_sync_level = | 211 | obj_desc->mutex.original_sync_level = |
208 | walk_state->thread->current_sync_level; | 212 | walk_state->thread->current_sync_level; |
@@ -242,7 +246,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
242 | 246 | ||
243 | /* The mutex must have been previously acquired in order to release it */ | 247 | /* The mutex must have been previously acquired in order to release it */ |
244 | 248 | ||
245 | if (!obj_desc->mutex.owner_thread_id) { | 249 | if (!obj_desc->mutex.owner_thread) { |
246 | ACPI_ERROR((AE_INFO, | 250 | ACPI_ERROR((AE_INFO, |
247 | "Cannot release Mutex [%4.4s], not acquired", | 251 | "Cannot release Mutex [%4.4s], not acquired", |
248 | acpi_ut_get_node_name(obj_desc->mutex.node))); | 252 | acpi_ut_get_node_name(obj_desc->mutex.node))); |
@@ -262,14 +266,15 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
262 | * The Mutex is owned, but this thread must be the owner. | 266 | * The Mutex is owned, but this thread must be the owner. |
263 | * Special case for Global Lock, any thread can release | 267 | * Special case for Global Lock, any thread can release |
264 | */ | 268 | */ |
265 | if ((obj_desc->mutex.owner_thread_id != | 269 | if ((obj_desc->mutex.owner_thread->thread_id != |
266 | walk_state->thread->thread_id) | 270 | walk_state->thread->thread_id) |
267 | && (obj_desc->mutex.os_mutex != acpi_gbl_global_lock_mutex)) { | 271 | && (obj_desc->mutex.os_mutex != acpi_gbl_global_lock_mutex)) { |
268 | ACPI_ERROR((AE_INFO, | 272 | ACPI_ERROR((AE_INFO, |
269 | "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX", | 273 | "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX", |
270 | (unsigned long)walk_state->thread->thread_id, | 274 | (unsigned long)walk_state->thread->thread_id, |
271 | acpi_ut_get_node_name(obj_desc->mutex.node), | 275 | acpi_ut_get_node_name(obj_desc->mutex.node), |
272 | (unsigned long)obj_desc->mutex.owner_thread_id)); | 276 | (unsigned long)obj_desc->mutex.owner_thread-> |
277 | thread_id)); | ||
273 | return_ACPI_STATUS(AE_AML_NOT_OWNER); | 278 | return_ACPI_STATUS(AE_AML_NOT_OWNER); |
274 | } | 279 | } |
275 | 280 | ||
@@ -296,7 +301,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
296 | 301 | ||
297 | /* Unlink the mutex from the owner's list */ | 302 | /* Unlink the mutex from the owner's list */ |
298 | 303 | ||
299 | acpi_ex_unlink_mutex(obj_desc, walk_state->thread); | 304 | acpi_ex_unlink_mutex(obj_desc); |
300 | 305 | ||
301 | /* Release the mutex, special case for Global Lock */ | 306 | /* Release the mutex, special case for Global Lock */ |
302 | 307 | ||
@@ -308,7 +313,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
308 | 313 | ||
309 | /* Update the mutex and restore sync_level */ | 314 | /* Update the mutex and restore sync_level */ |
310 | 315 | ||
311 | obj_desc->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; | 316 | obj_desc->mutex.owner_thread = NULL; |
312 | walk_state->thread->current_sync_level = | 317 | walk_state->thread->current_sync_level = |
313 | obj_desc->mutex.original_sync_level; | 318 | obj_desc->mutex.original_sync_level; |
314 | 319 | ||
@@ -363,7 +368,7 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread) | |||
363 | 368 | ||
364 | /* Mark mutex unowned */ | 369 | /* Mark mutex unowned */ |
365 | 370 | ||
366 | obj_desc->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; | 371 | obj_desc->mutex.owner_thread = NULL; |
367 | 372 | ||
368 | /* Update Thread sync_level (Last mutex is the important one) */ | 373 | /* Update Thread sync_level (Last mutex is the important one) */ |
369 | 374 | ||
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index 1ee4fb1175c6..308eae52dc05 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c | |||
@@ -177,8 +177,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) | |||
177 | 177 | ||
178 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n")); | 178 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n")); |
179 | 179 | ||
180 | for (index = 0; | 180 | for (index = 0; (index < ACPI_NAME_SIZE) |
181 | (index < ACPI_NAME_SIZE) | ||
182 | && (acpi_ut_valid_acpi_char(*aml_address, 0)); index++) { | 181 | && (acpi_ut_valid_acpi_char(*aml_address, 0)); index++) { |
183 | char_buf[index] = *aml_address++; | 182 | char_buf[index] = *aml_address++; |
184 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index])); | 183 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index])); |
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c index a6696621ff1b..efe5d4b461a4 100644 --- a/drivers/acpi/executer/exprep.c +++ b/drivers/acpi/executer/exprep.c | |||
@@ -242,7 +242,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, | |||
242 | obj_desc->common_field.bit_length, | 242 | obj_desc->common_field.bit_length, |
243 | 0xFFFFFFFF | 243 | 0xFFFFFFFF |
244 | /* Temp until we pass region_length as parameter */ | 244 | /* Temp until we pass region_length as parameter */ |
245 | ); | 245 | ); |
246 | bit_length = byte_alignment * 8; | 246 | bit_length = byte_alignment * 8; |
247 | #endif | 247 | #endif |
248 | 248 | ||
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index ba761862a599..09d897b3f6d5 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c | |||
@@ -354,8 +354,7 @@ acpi_ex_resolve_operands(u16 opcode, | |||
354 | if ((opcode == AML_STORE_OP) && | 354 | if ((opcode == AML_STORE_OP) && |
355 | (ACPI_GET_OBJECT_TYPE(*stack_ptr) == | 355 | (ACPI_GET_OBJECT_TYPE(*stack_ptr) == |
356 | ACPI_TYPE_LOCAL_REFERENCE) | 356 | ACPI_TYPE_LOCAL_REFERENCE) |
357 | && ((*stack_ptr)->reference.opcode == | 357 | && ((*stack_ptr)->reference.opcode == AML_INDEX_OP)) { |
358 | AML_INDEX_OP)) { | ||
359 | goto next_operand; | 358 | goto next_operand; |
360 | } | 359 | } |
361 | break; | 360 | break; |
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c index b2edf620ba89..9460baff3032 100644 --- a/drivers/acpi/executer/exsystem.c +++ b/drivers/acpi/executer/exsystem.c | |||
@@ -66,7 +66,6 @@ ACPI_MODULE_NAME("exsystem") | |||
66 | acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) | 66 | acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) |
67 | { | 67 | { |
68 | acpi_status status; | 68 | acpi_status status; |
69 | acpi_status status2; | ||
70 | 69 | ||
71 | ACPI_FUNCTION_TRACE(ex_system_wait_semaphore); | 70 | ACPI_FUNCTION_TRACE(ex_system_wait_semaphore); |
72 | 71 | ||
@@ -79,7 +78,7 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) | |||
79 | 78 | ||
80 | /* We must wait, so unlock the interpreter */ | 79 | /* We must wait, so unlock the interpreter */ |
81 | 80 | ||
82 | acpi_ex_exit_interpreter(); | 81 | acpi_ex_relinquish_interpreter(); |
83 | 82 | ||
84 | status = acpi_os_wait_semaphore(semaphore, 1, timeout); | 83 | status = acpi_os_wait_semaphore(semaphore, 1, timeout); |
85 | 84 | ||
@@ -89,13 +88,7 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) | |||
89 | 88 | ||
90 | /* Reacquire the interpreter */ | 89 | /* Reacquire the interpreter */ |
91 | 90 | ||
92 | status2 = acpi_ex_enter_interpreter(); | 91 | acpi_ex_reacquire_interpreter(); |
93 | if (ACPI_FAILURE(status2)) { | ||
94 | |||
95 | /* Report fatal error, could not acquire interpreter */ | ||
96 | |||
97 | return_ACPI_STATUS(status2); | ||
98 | } | ||
99 | } | 92 | } |
100 | 93 | ||
101 | return_ACPI_STATUS(status); | 94 | return_ACPI_STATUS(status); |
@@ -119,7 +112,6 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) | |||
119 | acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout) | 112 | acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout) |
120 | { | 113 | { |
121 | acpi_status status; | 114 | acpi_status status; |
122 | acpi_status status2; | ||
123 | 115 | ||
124 | ACPI_FUNCTION_TRACE(ex_system_wait_mutex); | 116 | ACPI_FUNCTION_TRACE(ex_system_wait_mutex); |
125 | 117 | ||
@@ -132,7 +124,7 @@ acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout) | |||
132 | 124 | ||
133 | /* We must wait, so unlock the interpreter */ | 125 | /* We must wait, so unlock the interpreter */ |
134 | 126 | ||
135 | acpi_ex_exit_interpreter(); | 127 | acpi_ex_relinquish_interpreter(); |
136 | 128 | ||
137 | status = acpi_os_acquire_mutex(mutex, timeout); | 129 | status = acpi_os_acquire_mutex(mutex, timeout); |
138 | 130 | ||
@@ -142,13 +134,7 @@ acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout) | |||
142 | 134 | ||
143 | /* Reacquire the interpreter */ | 135 | /* Reacquire the interpreter */ |
144 | 136 | ||
145 | status2 = acpi_ex_enter_interpreter(); | 137 | acpi_ex_reacquire_interpreter(); |
146 | if (ACPI_FAILURE(status2)) { | ||
147 | |||
148 | /* Report fatal error, could not acquire interpreter */ | ||
149 | |||
150 | return_ACPI_STATUS(status2); | ||
151 | } | ||
152 | } | 138 | } |
153 | 139 | ||
154 | return_ACPI_STATUS(status); | 140 | return_ACPI_STATUS(status); |
@@ -209,20 +195,18 @@ acpi_status acpi_ex_system_do_stall(u32 how_long) | |||
209 | 195 | ||
210 | acpi_status acpi_ex_system_do_suspend(acpi_integer how_long) | 196 | acpi_status acpi_ex_system_do_suspend(acpi_integer how_long) |
211 | { | 197 | { |
212 | acpi_status status; | ||
213 | |||
214 | ACPI_FUNCTION_ENTRY(); | 198 | ACPI_FUNCTION_ENTRY(); |
215 | 199 | ||
216 | /* Since this thread will sleep, we must release the interpreter */ | 200 | /* Since this thread will sleep, we must release the interpreter */ |
217 | 201 | ||
218 | acpi_ex_exit_interpreter(); | 202 | acpi_ex_relinquish_interpreter(); |
219 | 203 | ||
220 | acpi_os_sleep(how_long); | 204 | acpi_os_sleep(how_long); |
221 | 205 | ||
222 | /* And now we must get the interpreter again */ | 206 | /* And now we must get the interpreter again */ |
223 | 207 | ||
224 | status = acpi_ex_enter_interpreter(); | 208 | acpi_ex_reacquire_interpreter(); |
225 | return (status); | 209 | return (AE_OK); |
226 | } | 210 | } |
227 | 211 | ||
228 | /******************************************************************************* | 212 | /******************************************************************************* |
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index aea461f3a48c..6b0aeccbb69b 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c | |||
@@ -76,14 +76,15 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base); | |||
76 | * | 76 | * |
77 | * PARAMETERS: None | 77 | * PARAMETERS: None |
78 | * | 78 | * |
79 | * RETURN: Status | 79 | * RETURN: None |
80 | * | 80 | * |
81 | * DESCRIPTION: Enter the interpreter execution region. Failure to enter | 81 | * DESCRIPTION: Enter the interpreter execution region. Failure to enter |
82 | * the interpreter region is a fatal system error | 82 | * the interpreter region is a fatal system error. Used in |
83 | * conjunction with exit_interpreter. | ||
83 | * | 84 | * |
84 | ******************************************************************************/ | 85 | ******************************************************************************/ |
85 | 86 | ||
86 | acpi_status acpi_ex_enter_interpreter(void) | 87 | void acpi_ex_enter_interpreter(void) |
87 | { | 88 | { |
88 | acpi_status status; | 89 | acpi_status status; |
89 | 90 | ||
@@ -91,31 +92,55 @@ acpi_status acpi_ex_enter_interpreter(void) | |||
91 | 92 | ||
92 | status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); | 93 | status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); |
93 | if (ACPI_FAILURE(status)) { | 94 | if (ACPI_FAILURE(status)) { |
94 | ACPI_ERROR((AE_INFO, "Could not acquire interpreter mutex")); | 95 | ACPI_ERROR((AE_INFO, |
96 | "Could not acquire AML Interpreter mutex")); | ||
95 | } | 97 | } |
96 | 98 | ||
97 | return_ACPI_STATUS(status); | 99 | return_VOID; |
98 | } | 100 | } |
99 | 101 | ||
100 | /******************************************************************************* | 102 | /******************************************************************************* |
101 | * | 103 | * |
102 | * FUNCTION: acpi_ex_exit_interpreter | 104 | * FUNCTION: acpi_ex_reacquire_interpreter |
103 | * | 105 | * |
104 | * PARAMETERS: None | 106 | * PARAMETERS: None |
105 | * | 107 | * |
106 | * RETURN: None | 108 | * RETURN: None |
107 | * | 109 | * |
108 | * DESCRIPTION: Exit the interpreter execution region | 110 | * DESCRIPTION: Reacquire the interpreter execution region from within the |
111 | * interpreter code. Failure to enter the interpreter region is a | ||
112 | * fatal system error. Used in conjuction with | ||
113 | * relinquish_interpreter | ||
114 | * | ||
115 | ******************************************************************************/ | ||
116 | |||
117 | void acpi_ex_reacquire_interpreter(void) | ||
118 | { | ||
119 | ACPI_FUNCTION_TRACE(ex_reacquire_interpreter); | ||
120 | |||
121 | /* | ||
122 | * If the global serialized flag is set, do not release the interpreter, | ||
123 | * since it was not actually released by acpi_ex_relinquish_interpreter. | ||
124 | * This forces the interpreter to be single threaded. | ||
125 | */ | ||
126 | if (!acpi_gbl_all_methods_serialized) { | ||
127 | acpi_ex_enter_interpreter(); | ||
128 | } | ||
129 | |||
130 | return_VOID; | ||
131 | } | ||
132 | |||
133 | /******************************************************************************* | ||
134 | * | ||
135 | * FUNCTION: acpi_ex_exit_interpreter | ||
136 | * | ||
137 | * PARAMETERS: None | ||
138 | * | ||
139 | * RETURN: None | ||
109 | * | 140 | * |
110 | * Cases where the interpreter is unlocked: | 141 | * DESCRIPTION: Exit the interpreter execution region. This is the top level |
111 | * 1) Completion of the execution of a control method | 142 | * routine used to exit the interpreter when all processing has |
112 | * 2) Method blocked on a Sleep() AML opcode | 143 | * been completed. |
113 | * 3) Method blocked on an Acquire() AML opcode | ||
114 | * 4) Method blocked on a Wait() AML opcode | ||
115 | * 5) Method blocked to acquire the global lock | ||
116 | * 6) Method blocked to execute a serialized control method that is | ||
117 | * already executing | ||
118 | * 7) About to invoke a user-installed opregion handler | ||
119 | * | 144 | * |
120 | ******************************************************************************/ | 145 | ******************************************************************************/ |
121 | 146 | ||
@@ -127,7 +152,46 @@ void acpi_ex_exit_interpreter(void) | |||
127 | 152 | ||
128 | status = acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); | 153 | status = acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); |
129 | if (ACPI_FAILURE(status)) { | 154 | if (ACPI_FAILURE(status)) { |
130 | ACPI_ERROR((AE_INFO, "Could not release interpreter mutex")); | 155 | ACPI_ERROR((AE_INFO, |
156 | "Could not release AML Interpreter mutex")); | ||
157 | } | ||
158 | |||
159 | return_VOID; | ||
160 | } | ||
161 | |||
162 | /******************************************************************************* | ||
163 | * | ||
164 | * FUNCTION: acpi_ex_relinquish_interpreter | ||
165 | * | ||
166 | * PARAMETERS: None | ||
167 | * | ||
168 | * RETURN: None | ||
169 | * | ||
170 | * DESCRIPTION: Exit the interpreter execution region, from within the | ||
171 | * interpreter - before attempting an operation that will possibly | ||
172 | * block the running thread. | ||
173 | * | ||
174 | * Cases where the interpreter is unlocked internally | ||
175 | * 1) Method to be blocked on a Sleep() AML opcode | ||
176 | * 2) Method to be blocked on an Acquire() AML opcode | ||
177 | * 3) Method to be blocked on a Wait() AML opcode | ||
178 | * 4) Method to be blocked to acquire the global lock | ||
179 | * 5) Method to be blocked waiting to execute a serialized control method | ||
180 | * that is currently executing | ||
181 | * 6) About to invoke a user-installed opregion handler | ||
182 | * | ||
183 | ******************************************************************************/ | ||
184 | |||
185 | void acpi_ex_relinquish_interpreter(void) | ||
186 | { | ||
187 | ACPI_FUNCTION_TRACE(ex_relinquish_interpreter); | ||
188 | |||
189 | /* | ||
190 | * If the global serialized flag is set, do not release the interpreter. | ||
191 | * This forces the interpreter to be single threaded. | ||
192 | */ | ||
193 | if (!acpi_gbl_all_methods_serialized) { | ||
194 | acpi_ex_exit_interpreter(); | ||
131 | } | 195 | } |
132 | 196 | ||
133 | return_VOID; | 197 | return_VOID; |
@@ -141,8 +205,8 @@ void acpi_ex_exit_interpreter(void) | |||
141 | * | 205 | * |
142 | * RETURN: none | 206 | * RETURN: none |
143 | * | 207 | * |
144 | * DESCRIPTION: Truncate a number to 32-bits if the currently executing method | 208 | * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is |
145 | * belongs to a 32-bit ACPI table. | 209 | * 32-bit, as determined by the revision of the DSDT. |
146 | * | 210 | * |
147 | ******************************************************************************/ | 211 | ******************************************************************************/ |
148 | 212 | ||
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index c84b1faba28c..76c525dc590b 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c | |||
@@ -152,7 +152,6 @@ acpi_get_firmware_waking_vector(acpi_physical_address * physical_address) | |||
152 | 152 | ||
153 | ACPI_EXPORT_SYMBOL(acpi_get_firmware_waking_vector) | 153 | ACPI_EXPORT_SYMBOL(acpi_get_firmware_waking_vector) |
154 | #endif | 154 | #endif |
155 | |||
156 | /******************************************************************************* | 155 | /******************************************************************************* |
157 | * | 156 | * |
158 | * FUNCTION: acpi_enter_sleep_state_prep | 157 | * FUNCTION: acpi_enter_sleep_state_prep |
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c index 26fd0dd6953d..97b2ac57c16b 100644 --- a/drivers/acpi/namespace/nseval.c +++ b/drivers/acpi/namespace/nseval.c | |||
@@ -75,7 +75,7 @@ ACPI_MODULE_NAME("nseval") | |||
75 | * MUTEX: Locks interpreter | 75 | * MUTEX: Locks interpreter |
76 | * | 76 | * |
77 | ******************************************************************************/ | 77 | ******************************************************************************/ |
78 | acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info) | 78 | acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) |
79 | { | 79 | { |
80 | acpi_status status; | 80 | acpi_status status; |
81 | 81 | ||
@@ -154,11 +154,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info) | |||
154 | * Execute the method via the interpreter. The interpreter is locked | 154 | * Execute the method via the interpreter. The interpreter is locked |
155 | * here before calling into the AML parser | 155 | * here before calling into the AML parser |
156 | */ | 156 | */ |
157 | status = acpi_ex_enter_interpreter(); | 157 | acpi_ex_enter_interpreter(); |
158 | if (ACPI_FAILURE(status)) { | ||
159 | return_ACPI_STATUS(status); | ||
160 | } | ||
161 | |||
162 | status = acpi_ps_execute_method(info); | 158 | status = acpi_ps_execute_method(info); |
163 | acpi_ex_exit_interpreter(); | 159 | acpi_ex_exit_interpreter(); |
164 | } else { | 160 | } else { |
@@ -182,10 +178,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info) | |||
182 | * resolution, we must lock it because we could access an opregion. | 178 | * resolution, we must lock it because we could access an opregion. |
183 | * The opregion access code assumes that the interpreter is locked. | 179 | * The opregion access code assumes that the interpreter is locked. |
184 | */ | 180 | */ |
185 | status = acpi_ex_enter_interpreter(); | 181 | acpi_ex_enter_interpreter(); |
186 | if (ACPI_FAILURE(status)) { | ||
187 | return_ACPI_STATUS(status); | ||
188 | } | ||
189 | 182 | ||
190 | /* Function has a strange interface */ | 183 | /* Function has a strange interface */ |
191 | 184 | ||
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index c4ab615f77fe..33db2241044e 100644 --- a/drivers/acpi/namespace/nsinit.c +++ b/drivers/acpi/namespace/nsinit.c | |||
@@ -214,7 +214,7 @@ acpi_ns_init_one_object(acpi_handle obj_handle, | |||
214 | u32 level, void *context, void **return_value) | 214 | u32 level, void *context, void **return_value) |
215 | { | 215 | { |
216 | acpi_object_type type; | 216 | acpi_object_type type; |
217 | acpi_status status; | 217 | acpi_status status = AE_OK; |
218 | struct acpi_init_walk_info *info = | 218 | struct acpi_init_walk_info *info = |
219 | (struct acpi_init_walk_info *)context; | 219 | (struct acpi_init_walk_info *)context; |
220 | struct acpi_namespace_node *node = | 220 | struct acpi_namespace_node *node = |
@@ -268,10 +268,7 @@ acpi_ns_init_one_object(acpi_handle obj_handle, | |||
268 | /* | 268 | /* |
269 | * Must lock the interpreter before executing AML code | 269 | * Must lock the interpreter before executing AML code |
270 | */ | 270 | */ |
271 | status = acpi_ex_enter_interpreter(); | 271 | acpi_ex_enter_interpreter(); |
272 | if (ACPI_FAILURE(status)) { | ||
273 | return (status); | ||
274 | } | ||
275 | 272 | ||
276 | /* | 273 | /* |
277 | * Each of these types can contain executable AML code within the | 274 | * Each of these types can contain executable AML code within the |
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c index 94eb8f332d94..280b8357c46c 100644 --- a/drivers/acpi/namespace/nswalk.c +++ b/drivers/acpi/namespace/nswalk.c | |||
@@ -65,10 +65,8 @@ ACPI_MODULE_NAME("nswalk") | |||
65 | * within Scope is returned. | 65 | * within Scope is returned. |
66 | * | 66 | * |
67 | ******************************************************************************/ | 67 | ******************************************************************************/ |
68 | struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, | 68 | struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, struct acpi_namespace_node |
69 | struct acpi_namespace_node | 69 | *parent_node, struct acpi_namespace_node |
70 | *parent_node, | ||
71 | struct acpi_namespace_node | ||
72 | *child_node) | 70 | *child_node) |
73 | { | 71 | { |
74 | struct acpi_namespace_node *next_node = NULL; | 72 | struct acpi_namespace_node *next_node = NULL; |
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index 8904d0fae6a2..be4f2899de74 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c | |||
@@ -48,7 +48,6 @@ | |||
48 | 48 | ||
49 | #define _COMPONENT ACPI_NAMESPACE | 49 | #define _COMPONENT ACPI_NAMESPACE |
50 | ACPI_MODULE_NAME("nsxfeval") | 50 | ACPI_MODULE_NAME("nsxfeval") |
51 | |||
52 | #ifdef ACPI_FUTURE_USAGE | 51 | #ifdef ACPI_FUTURE_USAGE |
53 | /******************************************************************************* | 52 | /******************************************************************************* |
54 | * | 53 | * |
@@ -73,8 +72,8 @@ ACPI_MODULE_NAME("nsxfeval") | |||
73 | acpi_status | 72 | acpi_status |
74 | acpi_evaluate_object_typed(acpi_handle handle, | 73 | acpi_evaluate_object_typed(acpi_handle handle, |
75 | acpi_string pathname, | 74 | acpi_string pathname, |
76 | struct acpi_object_list * external_params, | 75 | struct acpi_object_list *external_params, |
77 | struct acpi_buffer * return_buffer, | 76 | struct acpi_buffer *return_buffer, |
78 | acpi_object_type return_type) | 77 | acpi_object_type return_type) |
79 | { | 78 | { |
80 | acpi_status status; | 79 | acpi_status status; |
@@ -143,7 +142,6 @@ acpi_evaluate_object_typed(acpi_handle handle, | |||
143 | 142 | ||
144 | ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed) | 143 | ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed) |
145 | #endif /* ACPI_FUTURE_USAGE */ | 144 | #endif /* ACPI_FUTURE_USAGE */ |
146 | |||
147 | /******************************************************************************* | 145 | /******************************************************************************* |
148 | * | 146 | * |
149 | * FUNCTION: acpi_evaluate_object | 147 | * FUNCTION: acpi_evaluate_object |
@@ -170,7 +168,6 @@ acpi_evaluate_object(acpi_handle handle, | |||
170 | struct acpi_buffer *return_buffer) | 168 | struct acpi_buffer *return_buffer) |
171 | { | 169 | { |
172 | acpi_status status; | 170 | acpi_status status; |
173 | acpi_status status2; | ||
174 | struct acpi_evaluate_info *info; | 171 | struct acpi_evaluate_info *info; |
175 | acpi_size buffer_space_needed; | 172 | acpi_size buffer_space_needed; |
176 | u32 i; | 173 | u32 i; |
@@ -329,14 +326,12 @@ acpi_evaluate_object(acpi_handle handle, | |||
329 | * Delete the internal return object. NOTE: Interpreter must be | 326 | * Delete the internal return object. NOTE: Interpreter must be |
330 | * locked to avoid race condition. | 327 | * locked to avoid race condition. |
331 | */ | 328 | */ |
332 | status2 = acpi_ex_enter_interpreter(); | 329 | acpi_ex_enter_interpreter(); |
333 | if (ACPI_SUCCESS(status2)) { | ||
334 | 330 | ||
335 | /* Remove one reference on the return object (should delete it) */ | 331 | /* Remove one reference on the return object (should delete it) */ |
336 | 332 | ||
337 | acpi_ut_remove_reference(info->return_object); | 333 | acpi_ut_remove_reference(info->return_object); |
338 | acpi_ex_exit_interpreter(); | 334 | acpi_ex_exit_interpreter(); |
339 | } | ||
340 | } | 335 | } |
341 | 336 | ||
342 | cleanup: | 337 | cleanup: |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index c2bed56915e1..b998340e23d4 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -71,6 +71,7 @@ static unsigned int acpi_irq_irq; | |||
71 | static acpi_osd_handler acpi_irq_handler; | 71 | static acpi_osd_handler acpi_irq_handler; |
72 | static void *acpi_irq_context; | 72 | static void *acpi_irq_context; |
73 | static struct workqueue_struct *kacpid_wq; | 73 | static struct workqueue_struct *kacpid_wq; |
74 | static struct workqueue_struct *kacpi_notify_wq; | ||
74 | 75 | ||
75 | static void __init acpi_request_region (struct acpi_generic_address *addr, | 76 | static void __init acpi_request_region (struct acpi_generic_address *addr, |
76 | unsigned int length, char *desc) | 77 | unsigned int length, char *desc) |
@@ -137,8 +138,9 @@ acpi_status acpi_os_initialize1(void) | |||
137 | return AE_NULL_ENTRY; | 138 | return AE_NULL_ENTRY; |
138 | } | 139 | } |
139 | kacpid_wq = create_singlethread_workqueue("kacpid"); | 140 | kacpid_wq = create_singlethread_workqueue("kacpid"); |
141 | kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify"); | ||
140 | BUG_ON(!kacpid_wq); | 142 | BUG_ON(!kacpid_wq); |
141 | 143 | BUG_ON(!kacpi_notify_wq); | |
142 | return AE_OK; | 144 | return AE_OK; |
143 | } | 145 | } |
144 | 146 | ||
@@ -150,6 +152,7 @@ acpi_status acpi_os_terminate(void) | |||
150 | } | 152 | } |
151 | 153 | ||
152 | destroy_workqueue(kacpid_wq); | 154 | destroy_workqueue(kacpid_wq); |
155 | destroy_workqueue(kacpi_notify_wq); | ||
153 | 156 | ||
154 | return AE_OK; | 157 | return AE_OK; |
155 | } | 158 | } |
@@ -603,6 +606,23 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ | |||
603 | static void acpi_os_execute_deferred(struct work_struct *work) | 606 | static void acpi_os_execute_deferred(struct work_struct *work) |
604 | { | 607 | { |
605 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); | 608 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); |
609 | if (!dpc) { | ||
610 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); | ||
611 | return; | ||
612 | } | ||
613 | |||
614 | dpc->function(dpc->context); | ||
615 | kfree(dpc); | ||
616 | |||
617 | /* Yield cpu to notify thread */ | ||
618 | cond_resched(); | ||
619 | |||
620 | return; | ||
621 | } | ||
622 | |||
623 | static void acpi_os_execute_notify(struct work_struct *work) | ||
624 | { | ||
625 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); | ||
606 | 626 | ||
607 | if (!dpc) { | 627 | if (!dpc) { |
608 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); | 628 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); |
@@ -637,14 +657,12 @@ acpi_status acpi_os_execute(acpi_execute_type type, | |||
637 | acpi_status status = AE_OK; | 657 | acpi_status status = AE_OK; |
638 | struct acpi_os_dpc *dpc; | 658 | struct acpi_os_dpc *dpc; |
639 | 659 | ||
640 | ACPI_FUNCTION_TRACE("os_queue_for_execution"); | ||
641 | |||
642 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 660 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
643 | "Scheduling function [%p(%p)] for deferred execution.\n", | 661 | "Scheduling function [%p(%p)] for deferred execution.\n", |
644 | function, context)); | 662 | function, context)); |
645 | 663 | ||
646 | if (!function) | 664 | if (!function) |
647 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 665 | return AE_BAD_PARAMETER; |
648 | 666 | ||
649 | /* | 667 | /* |
650 | * Allocate/initialize DPC structure. Note that this memory will be | 668 | * Allocate/initialize DPC structure. Note that this memory will be |
@@ -662,14 +680,21 @@ acpi_status acpi_os_execute(acpi_execute_type type, | |||
662 | dpc->function = function; | 680 | dpc->function = function; |
663 | dpc->context = context; | 681 | dpc->context = context; |
664 | 682 | ||
665 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | 683 | if (type == OSL_NOTIFY_HANDLER) { |
666 | if (!queue_work(kacpid_wq, &dpc->work)) { | 684 | INIT_WORK(&dpc->work, acpi_os_execute_notify); |
667 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 685 | if (!queue_work(kacpi_notify_wq, &dpc->work)) { |
686 | status = AE_ERROR; | ||
687 | kfree(dpc); | ||
688 | } | ||
689 | } else { | ||
690 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | ||
691 | if (!queue_work(kacpid_wq, &dpc->work)) { | ||
692 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
668 | "Call to queue_work() failed.\n")); | 693 | "Call to queue_work() failed.\n")); |
669 | kfree(dpc); | 694 | status = AE_ERROR; |
670 | status = AE_ERROR; | 695 | kfree(dpc); |
696 | } | ||
671 | } | 697 | } |
672 | |||
673 | return_ACPI_STATUS(status); | 698 | return_ACPI_STATUS(status); |
674 | } | 699 | } |
675 | 700 | ||
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c index 16d8b6cc3c22..9296e86761d7 100644 --- a/drivers/acpi/parser/psopcode.c +++ b/drivers/acpi/parser/psopcode.c | |||
@@ -185,459 +185,453 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { | |||
185 | /* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ | 185 | /* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ |
186 | 186 | ||
187 | /* 00 */ ACPI_OP("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, | 187 | /* 00 */ ACPI_OP("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, |
188 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), | 188 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), |
189 | /* 01 */ ACPI_OP("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, | 189 | /* 01 */ ACPI_OP("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, |
190 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), | 190 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), |
191 | /* 02 */ ACPI_OP("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, | 191 | /* 02 */ ACPI_OP("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, |
192 | ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, | 192 | ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, |
193 | AML_TYPE_NAMED_SIMPLE, | 193 | AML_TYPE_NAMED_SIMPLE, |
194 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 194 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
195 | AML_NSNODE | AML_NAMED), | 195 | AML_NSNODE | AML_NAMED), |
196 | /* 03 */ ACPI_OP("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, | 196 | /* 03 */ ACPI_OP("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, |
197 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, | 197 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, |
198 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 198 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
199 | AML_NSNODE | AML_NAMED), | 199 | AML_NSNODE | AML_NAMED), |
200 | /* 04 */ ACPI_OP("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, | 200 | /* 04 */ ACPI_OP("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, |
201 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | 201 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, |
202 | AML_TYPE_LITERAL, AML_CONSTANT), | 202 | AML_TYPE_LITERAL, AML_CONSTANT), |
203 | /* 05 */ ACPI_OP("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, | 203 | /* 05 */ ACPI_OP("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, |
204 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | 204 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, |
205 | AML_TYPE_LITERAL, AML_CONSTANT), | 205 | AML_TYPE_LITERAL, AML_CONSTANT), |
206 | /* 06 */ ACPI_OP("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, | 206 | /* 06 */ ACPI_OP("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, |
207 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | 207 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, |
208 | AML_TYPE_LITERAL, AML_CONSTANT), | 208 | AML_TYPE_LITERAL, AML_CONSTANT), |
209 | /* 07 */ ACPI_OP("String", ARGP_STRING_OP, ARGI_STRING_OP, | 209 | /* 07 */ ACPI_OP("String", ARGP_STRING_OP, ARGI_STRING_OP, |
210 | ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, | 210 | ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, |
211 | AML_TYPE_LITERAL, AML_CONSTANT), | 211 | AML_TYPE_LITERAL, AML_CONSTANT), |
212 | /* 08 */ ACPI_OP("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, | 212 | /* 08 */ ACPI_OP("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, |
213 | ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, | 213 | ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, |
214 | AML_TYPE_NAMED_NO_OBJ, | 214 | AML_TYPE_NAMED_NO_OBJ, |
215 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 215 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
216 | AML_NSNODE | AML_NAMED), | 216 | AML_NSNODE | AML_NAMED), |
217 | /* 09 */ ACPI_OP("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, | 217 | /* 09 */ ACPI_OP("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, |
218 | ACPI_TYPE_BUFFER, AML_CLASS_CREATE, | 218 | ACPI_TYPE_BUFFER, AML_CLASS_CREATE, |
219 | AML_TYPE_CREATE_OBJECT, | 219 | AML_TYPE_CREATE_OBJECT, |
220 | AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), | 220 | AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), |
221 | /* 0A */ ACPI_OP("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, | 221 | /* 0A */ ACPI_OP("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, |
222 | ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, | 222 | ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, |
223 | AML_TYPE_CREATE_OBJECT, | 223 | AML_TYPE_CREATE_OBJECT, |
224 | AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), | 224 | AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), |
225 | /* 0B */ ACPI_OP("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, | 225 | /* 0B */ ACPI_OP("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, |
226 | ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, | 226 | ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, |
227 | AML_TYPE_NAMED_COMPLEX, | 227 | AML_TYPE_NAMED_COMPLEX, |
228 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 228 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
229 | AML_NSNODE | AML_NAMED | AML_DEFER), | 229 | AML_NSNODE | AML_NAMED | AML_DEFER), |
230 | /* 0C */ ACPI_OP("Local0", ARGP_LOCAL0, ARGI_LOCAL0, | 230 | /* 0C */ ACPI_OP("Local0", ARGP_LOCAL0, ARGI_LOCAL0, |
231 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 231 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
232 | AML_TYPE_LOCAL_VARIABLE, 0), | 232 | AML_TYPE_LOCAL_VARIABLE, 0), |
233 | /* 0D */ ACPI_OP("Local1", ARGP_LOCAL1, ARGI_LOCAL1, | 233 | /* 0D */ ACPI_OP("Local1", ARGP_LOCAL1, ARGI_LOCAL1, |
234 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 234 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
235 | AML_TYPE_LOCAL_VARIABLE, 0), | 235 | AML_TYPE_LOCAL_VARIABLE, 0), |
236 | /* 0E */ ACPI_OP("Local2", ARGP_LOCAL2, ARGI_LOCAL2, | 236 | /* 0E */ ACPI_OP("Local2", ARGP_LOCAL2, ARGI_LOCAL2, |
237 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 237 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
238 | AML_TYPE_LOCAL_VARIABLE, 0), | 238 | AML_TYPE_LOCAL_VARIABLE, 0), |
239 | /* 0F */ ACPI_OP("Local3", ARGP_LOCAL3, ARGI_LOCAL3, | 239 | /* 0F */ ACPI_OP("Local3", ARGP_LOCAL3, ARGI_LOCAL3, |
240 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 240 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
241 | AML_TYPE_LOCAL_VARIABLE, 0), | 241 | AML_TYPE_LOCAL_VARIABLE, 0), |
242 | /* 10 */ ACPI_OP("Local4", ARGP_LOCAL4, ARGI_LOCAL4, | 242 | /* 10 */ ACPI_OP("Local4", ARGP_LOCAL4, ARGI_LOCAL4, |
243 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 243 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
244 | AML_TYPE_LOCAL_VARIABLE, 0), | 244 | AML_TYPE_LOCAL_VARIABLE, 0), |
245 | /* 11 */ ACPI_OP("Local5", ARGP_LOCAL5, ARGI_LOCAL5, | 245 | /* 11 */ ACPI_OP("Local5", ARGP_LOCAL5, ARGI_LOCAL5, |
246 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 246 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
247 | AML_TYPE_LOCAL_VARIABLE, 0), | 247 | AML_TYPE_LOCAL_VARIABLE, 0), |
248 | /* 12 */ ACPI_OP("Local6", ARGP_LOCAL6, ARGI_LOCAL6, | 248 | /* 12 */ ACPI_OP("Local6", ARGP_LOCAL6, ARGI_LOCAL6, |
249 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 249 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
250 | AML_TYPE_LOCAL_VARIABLE, 0), | 250 | AML_TYPE_LOCAL_VARIABLE, 0), |
251 | /* 13 */ ACPI_OP("Local7", ARGP_LOCAL7, ARGI_LOCAL7, | 251 | /* 13 */ ACPI_OP("Local7", ARGP_LOCAL7, ARGI_LOCAL7, |
252 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 252 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
253 | AML_TYPE_LOCAL_VARIABLE, 0), | 253 | AML_TYPE_LOCAL_VARIABLE, 0), |
254 | /* 14 */ ACPI_OP("Arg0", ARGP_ARG0, ARGI_ARG0, | 254 | /* 14 */ ACPI_OP("Arg0", ARGP_ARG0, ARGI_ARG0, |
255 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 255 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
256 | AML_TYPE_METHOD_ARGUMENT, 0), | 256 | AML_TYPE_METHOD_ARGUMENT, 0), |
257 | /* 15 */ ACPI_OP("Arg1", ARGP_ARG1, ARGI_ARG1, | 257 | /* 15 */ ACPI_OP("Arg1", ARGP_ARG1, ARGI_ARG1, |
258 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 258 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
259 | AML_TYPE_METHOD_ARGUMENT, 0), | 259 | AML_TYPE_METHOD_ARGUMENT, 0), |
260 | /* 16 */ ACPI_OP("Arg2", ARGP_ARG2, ARGI_ARG2, | 260 | /* 16 */ ACPI_OP("Arg2", ARGP_ARG2, ARGI_ARG2, |
261 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 261 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
262 | AML_TYPE_METHOD_ARGUMENT, 0), | 262 | AML_TYPE_METHOD_ARGUMENT, 0), |
263 | /* 17 */ ACPI_OP("Arg3", ARGP_ARG3, ARGI_ARG3, | 263 | /* 17 */ ACPI_OP("Arg3", ARGP_ARG3, ARGI_ARG3, |
264 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 264 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
265 | AML_TYPE_METHOD_ARGUMENT, 0), | 265 | AML_TYPE_METHOD_ARGUMENT, 0), |
266 | /* 18 */ ACPI_OP("Arg4", ARGP_ARG4, ARGI_ARG4, | 266 | /* 18 */ ACPI_OP("Arg4", ARGP_ARG4, ARGI_ARG4, |
267 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 267 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
268 | AML_TYPE_METHOD_ARGUMENT, 0), | 268 | AML_TYPE_METHOD_ARGUMENT, 0), |
269 | /* 19 */ ACPI_OP("Arg5", ARGP_ARG5, ARGI_ARG5, | 269 | /* 19 */ ACPI_OP("Arg5", ARGP_ARG5, ARGI_ARG5, |
270 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 270 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
271 | AML_TYPE_METHOD_ARGUMENT, 0), | 271 | AML_TYPE_METHOD_ARGUMENT, 0), |
272 | /* 1A */ ACPI_OP("Arg6", ARGP_ARG6, ARGI_ARG6, | 272 | /* 1A */ ACPI_OP("Arg6", ARGP_ARG6, ARGI_ARG6, |
273 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 273 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
274 | AML_TYPE_METHOD_ARGUMENT, 0), | 274 | AML_TYPE_METHOD_ARGUMENT, 0), |
275 | /* 1B */ ACPI_OP("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, | 275 | /* 1B */ ACPI_OP("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, |
276 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | 276 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, |
277 | AML_FLAGS_EXEC_1A_1T_1R), | 277 | AML_FLAGS_EXEC_1A_1T_1R), |
278 | /* 1C */ ACPI_OP("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, | 278 | /* 1C */ ACPI_OP("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, |
279 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, | 279 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, |
280 | AML_FLAGS_EXEC_1A_0T_1R), | 280 | AML_FLAGS_EXEC_1A_0T_1R), |
281 | /* 1D */ ACPI_OP("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, | 281 | /* 1D */ ACPI_OP("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, |
282 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | 282 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, |
283 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 283 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
284 | /* 1E */ ACPI_OP("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, | 284 | /* 1E */ ACPI_OP("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, |
285 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 285 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
286 | AML_TYPE_EXEC_2A_1T_1R, | 286 | AML_TYPE_EXEC_2A_1T_1R, |
287 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | 287 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), |
288 | /* 1F */ ACPI_OP("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, | 288 | /* 1F */ ACPI_OP("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, |
289 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 289 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
290 | AML_TYPE_EXEC_2A_1T_1R, | 290 | AML_TYPE_EXEC_2A_1T_1R, |
291 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 291 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
292 | /* 20 */ ACPI_OP("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, | 292 | /* 20 */ ACPI_OP("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, |
293 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 293 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
294 | AML_TYPE_EXEC_1A_0T_1R, | 294 | AML_TYPE_EXEC_1A_0T_1R, |
295 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), | 295 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), |
296 | /* 21 */ ACPI_OP("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, | 296 | /* 21 */ ACPI_OP("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, |
297 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 297 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
298 | AML_TYPE_EXEC_1A_0T_1R, | 298 | AML_TYPE_EXEC_1A_0T_1R, |
299 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), | 299 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), |
300 | /* 22 */ ACPI_OP("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, | 300 | /* 22 */ ACPI_OP("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, |
301 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 301 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
302 | AML_TYPE_EXEC_2A_1T_1R, | 302 | AML_TYPE_EXEC_2A_1T_1R, |
303 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 303 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
304 | /* 23 */ ACPI_OP("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, | 304 | /* 23 */ ACPI_OP("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, |
305 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 305 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
306 | AML_TYPE_EXEC_2A_2T_1R, | 306 | AML_TYPE_EXEC_2A_2T_1R, |
307 | AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), | 307 | AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), |
308 | /* 24 */ ACPI_OP("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, | 308 | /* 24 */ ACPI_OP("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, |
309 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 309 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
310 | AML_TYPE_EXEC_2A_1T_1R, | 310 | AML_TYPE_EXEC_2A_1T_1R, |
311 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 311 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
312 | /* 25 */ ACPI_OP("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, | 312 | /* 25 */ ACPI_OP("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, |
313 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 313 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
314 | AML_TYPE_EXEC_2A_1T_1R, | 314 | AML_TYPE_EXEC_2A_1T_1R, |
315 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 315 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
316 | /* 26 */ ACPI_OP("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, | 316 | /* 26 */ ACPI_OP("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, |
317 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | 317 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, |
318 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 318 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
319 | /* 27 */ ACPI_OP("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, | 319 | /* 27 */ ACPI_OP("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, |
320 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 320 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
321 | AML_TYPE_EXEC_2A_1T_1R, | 321 | AML_TYPE_EXEC_2A_1T_1R, |
322 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 322 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
323 | /* 28 */ ACPI_OP("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, | 323 | /* 28 */ ACPI_OP("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, |
324 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | 324 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, |
325 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 325 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
326 | /* 29 */ ACPI_OP("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, | 326 | /* 29 */ ACPI_OP("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, |
327 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | 327 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, |
328 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 328 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
329 | /* 2A */ ACPI_OP("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, | 329 | /* 2A */ ACPI_OP("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, |
330 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | 330 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, |
331 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), | 331 | AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), |
332 | /* 2B */ ACPI_OP("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, | 332 | /* 2B */ ACPI_OP("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, |
333 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | 333 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, |
334 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 334 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
335 | /* 2C */ ACPI_OP("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, | 335 | /* 2C */ ACPI_OP("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, |
336 | ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, | 336 | ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, |
337 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | 337 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, |
338 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 338 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
339 | /* 2D */ ACPI_OP("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP, | 339 | /* 2D */ ACPI_OP("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP, |
340 | ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, | 340 | ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, |
341 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | 341 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, |
342 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 342 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
343 | /* 2E */ ACPI_OP("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, | 343 | /* 2E */ ACPI_OP("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, |
344 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 344 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
345 | AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), | 345 | AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), |
346 | /* 2F */ ACPI_OP("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, | 346 | /* 2F */ ACPI_OP("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, |
347 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 347 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
348 | AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), | 348 | AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), |
349 | /* 30 */ ACPI_OP("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, | 349 | /* 30 */ ACPI_OP("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, |
350 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 350 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
351 | AML_TYPE_EXEC_1A_0T_1R, | 351 | AML_TYPE_EXEC_1A_0T_1R, |
352 | AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), | 352 | AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), |
353 | /* 31 */ ACPI_OP("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, | 353 | /* 31 */ ACPI_OP("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, |
354 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | 354 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, |
355 | AML_FLAGS_EXEC_2A_1T_1R), | 355 | AML_FLAGS_EXEC_2A_1T_1R), |
356 | /* 32 */ ACPI_OP("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, | 356 | /* 32 */ ACPI_OP("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, |
357 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, | 357 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, |
358 | AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), | 358 | AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), |
359 | /* 33 */ ACPI_OP("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP, | 359 | /* 33 */ ACPI_OP("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP, |
360 | ARGI_CREATE_DWORD_FIELD_OP, | 360 | ARGI_CREATE_DWORD_FIELD_OP, |
361 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | 361 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, |
362 | AML_TYPE_CREATE_FIELD, | 362 | AML_TYPE_CREATE_FIELD, |
363 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | 363 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | |
364 | AML_DEFER | AML_CREATE), | 364 | AML_DEFER | AML_CREATE), |
365 | /* 34 */ ACPI_OP("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, | 365 | /* 34 */ ACPI_OP("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, |
366 | ARGI_CREATE_WORD_FIELD_OP, | 366 | ARGI_CREATE_WORD_FIELD_OP, |
367 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | 367 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, |
368 | AML_TYPE_CREATE_FIELD, | 368 | AML_TYPE_CREATE_FIELD, |
369 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | 369 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | |
370 | AML_DEFER | AML_CREATE), | 370 | AML_DEFER | AML_CREATE), |
371 | /* 35 */ ACPI_OP("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, | 371 | /* 35 */ ACPI_OP("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, |
372 | ARGI_CREATE_BYTE_FIELD_OP, | 372 | ARGI_CREATE_BYTE_FIELD_OP, |
373 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | 373 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, |
374 | AML_TYPE_CREATE_FIELD, | 374 | AML_TYPE_CREATE_FIELD, |
375 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | 375 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | |
376 | AML_DEFER | AML_CREATE), | 376 | AML_DEFER | AML_CREATE), |
377 | /* 36 */ ACPI_OP("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, | 377 | /* 36 */ ACPI_OP("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, |
378 | ARGI_CREATE_BIT_FIELD_OP, | 378 | ARGI_CREATE_BIT_FIELD_OP, |
379 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | 379 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, |
380 | AML_TYPE_CREATE_FIELD, | 380 | AML_TYPE_CREATE_FIELD, |
381 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | 381 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | |
382 | AML_DEFER | AML_CREATE), | 382 | AML_DEFER | AML_CREATE), |
383 | /* 37 */ ACPI_OP("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, | 383 | /* 37 */ ACPI_OP("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, |
384 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 384 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
385 | AML_TYPE_EXEC_1A_0T_1R, | 385 | AML_TYPE_EXEC_1A_0T_1R, |
386 | AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), | 386 | AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), |
387 | /* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, | 387 | /* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, |
388 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | 388 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, |
389 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | | 389 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), |
390 | AML_CONSTANT), | ||
391 | /* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, | 390 | /* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, |
392 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | 391 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, |
393 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | | 392 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), |
394 | AML_CONSTANT), | ||
395 | /* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, | 393 | /* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, |
396 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, | 394 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, |
397 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), | 395 | AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), |
398 | /* 3B */ ACPI_OP("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, | 396 | /* 3B */ ACPI_OP("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, |
399 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 397 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
400 | AML_TYPE_EXEC_2A_0T_1R, | 398 | AML_TYPE_EXEC_2A_0T_1R, |
401 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), | 399 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), |
402 | /* 3C */ ACPI_OP("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, | 400 | /* 3C */ ACPI_OP("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, |
403 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 401 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
404 | AML_TYPE_EXEC_2A_0T_1R, | 402 | AML_TYPE_EXEC_2A_0T_1R, |
405 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), | 403 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), |
406 | /* 3D */ ACPI_OP("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, | 404 | /* 3D */ ACPI_OP("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, |
407 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | 405 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, |
408 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), | 406 | AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), |
409 | /* 3E */ ACPI_OP("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, | 407 | /* 3E */ ACPI_OP("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, |
410 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), | 408 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), |
411 | /* 3F */ ACPI_OP("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, | 409 | /* 3F */ ACPI_OP("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, |
412 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), | 410 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), |
413 | /* 40 */ ACPI_OP("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, | 411 | /* 40 */ ACPI_OP("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, |
414 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), | 412 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), |
415 | /* 41 */ ACPI_OP("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, | 413 | /* 41 */ ACPI_OP("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, |
416 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), | 414 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), |
417 | /* 42 */ ACPI_OP("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, | 415 | /* 42 */ ACPI_OP("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, |
418 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, | 416 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, |
419 | AML_TYPE_CONTROL, AML_HAS_ARGS), | 417 | AML_TYPE_CONTROL, AML_HAS_ARGS), |
420 | /* 43 */ ACPI_OP("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, | 418 | /* 43 */ ACPI_OP("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, |
421 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), | 419 | AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), |
422 | /* 44 */ ACPI_OP("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, | 420 | /* 44 */ ACPI_OP("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, |
423 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), | 421 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), |
424 | /* 45 */ ACPI_OP("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, | 422 | /* 45 */ ACPI_OP("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, |
425 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), | 423 | AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), |
426 | 424 | ||
427 | /* Prefixed opcodes (Two-byte opcodes with a prefix op) */ | 425 | /* Prefixed opcodes (Two-byte opcodes with a prefix op) */ |
428 | 426 | ||
429 | /* 46 */ ACPI_OP("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, | 427 | /* 46 */ ACPI_OP("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, |
430 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, | 428 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, |
431 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 429 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
432 | AML_NSNODE | AML_NAMED), | 430 | AML_NSNODE | AML_NAMED), |
433 | /* 47 */ ACPI_OP("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, | 431 | /* 47 */ ACPI_OP("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, |
434 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, | 432 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, |
435 | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), | 433 | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), |
436 | /* 48 */ ACPI_OP("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, | 434 | /* 48 */ ACPI_OP("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, |
437 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 435 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
438 | AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), | 436 | AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), |
439 | /* 49 */ ACPI_OP("CreateField", ARGP_CREATE_FIELD_OP, | 437 | /* 49 */ ACPI_OP("CreateField", ARGP_CREATE_FIELD_OP, |
440 | ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, | 438 | ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, |
441 | AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, | 439 | AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, |
442 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | 440 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | |
443 | AML_DEFER | AML_FIELD | AML_CREATE), | 441 | AML_DEFER | AML_FIELD | AML_CREATE), |
444 | /* 4A */ ACPI_OP("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, | 442 | /* 4A */ ACPI_OP("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, |
445 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, | 443 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, |
446 | AML_FLAGS_EXEC_1A_1T_0R), | 444 | AML_FLAGS_EXEC_1A_1T_0R), |
447 | /* 4B */ ACPI_OP("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, | 445 | /* 4B */ ACPI_OP("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, |
448 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, | 446 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, |
449 | AML_FLAGS_EXEC_1A_0T_0R), | 447 | AML_FLAGS_EXEC_1A_0T_0R), |
450 | /* 4C */ ACPI_OP("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, | 448 | /* 4C */ ACPI_OP("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, |
451 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, | 449 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, |
452 | AML_FLAGS_EXEC_1A_0T_0R), | 450 | AML_FLAGS_EXEC_1A_0T_0R), |
453 | /* 4D */ ACPI_OP("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, | 451 | /* 4D */ ACPI_OP("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, |
454 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 452 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
455 | AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), | 453 | AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), |
456 | /* 4E */ ACPI_OP("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, | 454 | /* 4E */ ACPI_OP("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, |
457 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 455 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
458 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), | 456 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), |
459 | /* 4F */ ACPI_OP("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, | 457 | /* 4F */ ACPI_OP("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, |
460 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, | 458 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, |
461 | AML_FLAGS_EXEC_2A_0T_1R), | 459 | AML_FLAGS_EXEC_2A_0T_1R), |
462 | /* 50 */ ACPI_OP("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, | 460 | /* 50 */ ACPI_OP("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, |
463 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, | 461 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, |
464 | AML_FLAGS_EXEC_1A_0T_0R), | 462 | AML_FLAGS_EXEC_1A_0T_0R), |
465 | /* 51 */ ACPI_OP("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, | 463 | /* 51 */ ACPI_OP("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, |
466 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 464 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
467 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), | 465 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), |
468 | /* 52 */ ACPI_OP("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, | 466 | /* 52 */ ACPI_OP("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, |
469 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 467 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
470 | AML_TYPE_EXEC_1A_1T_1R, | 468 | AML_TYPE_EXEC_1A_1T_1R, |
471 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 469 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
472 | /* 53 */ ACPI_OP("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, | 470 | /* 53 */ ACPI_OP("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, |
473 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | 471 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, |
474 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 472 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
475 | /* 54 */ ACPI_OP("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, | 473 | /* 54 */ ACPI_OP("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, |
476 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 474 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
477 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), | 475 | AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), |
478 | /* 55 */ ACPI_OP("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, | 476 | /* 55 */ ACPI_OP("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, |
479 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | 477 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, |
480 | AML_TYPE_CONSTANT, 0), | 478 | AML_TYPE_CONSTANT, 0), |
481 | /* 56 */ ACPI_OP("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, | 479 | /* 56 */ ACPI_OP("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, |
482 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 480 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
483 | AML_TYPE_CONSTANT, 0), | 481 | AML_TYPE_CONSTANT, 0), |
484 | /* 57 */ ACPI_OP("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, | 482 | /* 57 */ ACPI_OP("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, |
485 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, | 483 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, |
486 | AML_FLAGS_EXEC_3A_0T_0R), | 484 | AML_FLAGS_EXEC_3A_0T_0R), |
487 | /* 58 */ ACPI_OP("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, | 485 | /* 58 */ ACPI_OP("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, |
488 | ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, | 486 | ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, |
489 | AML_TYPE_NAMED_COMPLEX, | 487 | AML_TYPE_NAMED_COMPLEX, |
490 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 488 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
491 | AML_NSNODE | AML_NAMED | AML_DEFER), | 489 | AML_NSNODE | AML_NAMED | AML_DEFER), |
492 | /* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, | 490 | /* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, |
493 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, | 491 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, |
494 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 492 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), |
495 | AML_FIELD), | ||
496 | /* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, | 493 | /* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, |
497 | ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, | 494 | ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, |
498 | AML_TYPE_NAMED_NO_OBJ, | 495 | AML_TYPE_NAMED_NO_OBJ, |
499 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 496 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
500 | AML_NSNODE | AML_NAMED), | 497 | AML_NSNODE | AML_NAMED), |
501 | /* 5B */ ACPI_OP("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, | 498 | /* 5B */ ACPI_OP("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, |
502 | ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, | 499 | ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, |
503 | AML_TYPE_NAMED_SIMPLE, | 500 | AML_TYPE_NAMED_SIMPLE, |
504 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 501 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
505 | AML_NSNODE | AML_NAMED), | 502 | AML_NSNODE | AML_NAMED), |
506 | /* 5C */ ACPI_OP("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, | 503 | /* 5C */ ACPI_OP("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, |
507 | ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, | 504 | ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, |
508 | AML_TYPE_NAMED_SIMPLE, | 505 | AML_TYPE_NAMED_SIMPLE, |
509 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 506 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
510 | AML_NSNODE | AML_NAMED), | 507 | AML_NSNODE | AML_NAMED), |
511 | /* 5D */ ACPI_OP("ThermalZone", ARGP_THERMAL_ZONE_OP, | 508 | /* 5D */ ACPI_OP("ThermalZone", ARGP_THERMAL_ZONE_OP, |
512 | ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, | 509 | ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, |
513 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, | 510 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, |
514 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 511 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
515 | AML_NSNODE | AML_NAMED), | 512 | AML_NSNODE | AML_NAMED), |
516 | /* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, | 513 | /* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, |
517 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, | 514 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, |
518 | AML_TYPE_NAMED_FIELD, | 515 | AML_TYPE_NAMED_FIELD, |
519 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 516 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), |
520 | AML_FIELD), | ||
521 | /* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, | 517 | /* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, |
522 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, | 518 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, |
523 | AML_TYPE_NAMED_FIELD, | 519 | AML_TYPE_NAMED_FIELD, |
524 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 520 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), |
525 | AML_FIELD), | ||
526 | 521 | ||
527 | /* Internal opcodes that map to invalid AML opcodes */ | 522 | /* Internal opcodes that map to invalid AML opcodes */ |
528 | 523 | ||
529 | /* 60 */ ACPI_OP("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, | 524 | /* 60 */ ACPI_OP("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, |
530 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, | 525 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, |
531 | AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), | 526 | AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), |
532 | /* 61 */ ACPI_OP("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, | 527 | /* 61 */ ACPI_OP("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, |
533 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, | 528 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, |
534 | AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), | 529 | AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), |
535 | /* 62 */ ACPI_OP("LGreaterEqual", ARGP_LGREATEREQUAL_OP, | 530 | /* 62 */ ACPI_OP("LGreaterEqual", ARGP_LGREATEREQUAL_OP, |
536 | ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, | 531 | ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, |
537 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, | 532 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, |
538 | AML_HAS_ARGS | AML_CONSTANT), | 533 | AML_HAS_ARGS | AML_CONSTANT), |
539 | /* 63 */ ACPI_OP("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, | 534 | /* 63 */ ACPI_OP("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, |
540 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, | 535 | ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, |
541 | AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE), | 536 | AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE), |
542 | /* 64 */ ACPI_OP("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, | 537 | /* 64 */ ACPI_OP("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, |
543 | ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, | 538 | ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, |
544 | AML_TYPE_METHOD_CALL, | 539 | AML_TYPE_METHOD_CALL, |
545 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), | 540 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), |
546 | /* 65 */ ACPI_OP("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, | 541 | /* 65 */ ACPI_OP("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, |
547 | ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, | 542 | ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, |
548 | AML_TYPE_LITERAL, 0), | 543 | AML_TYPE_LITERAL, 0), |
549 | /* 66 */ ACPI_OP("-ReservedField-", ARGP_RESERVEDFIELD_OP, | 544 | /* 66 */ ACPI_OP("-ReservedField-", ARGP_RESERVEDFIELD_OP, |
550 | ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, | 545 | ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, |
551 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), | 546 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), |
552 | /* 67 */ ACPI_OP("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, | 547 | /* 67 */ ACPI_OP("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, |
553 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, | 548 | ACPI_TYPE_ANY, AML_CLASS_INTERNAL, |
554 | AML_TYPE_BOGUS, | 549 | AML_TYPE_BOGUS, |
555 | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), | 550 | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), |
556 | /* 68 */ ACPI_OP("-AccessField-", ARGP_ACCESSFIELD_OP, | 551 | /* 68 */ ACPI_OP("-AccessField-", ARGP_ACCESSFIELD_OP, |
557 | ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, | 552 | ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, |
558 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), | 553 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), |
559 | /* 69 */ ACPI_OP("-StaticString", ARGP_STATICSTRING_OP, | 554 | /* 69 */ ACPI_OP("-StaticString", ARGP_STATICSTRING_OP, |
560 | ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, | 555 | ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, |
561 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), | 556 | AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), |
562 | /* 6A */ ACPI_OP("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, | 557 | /* 6A */ ACPI_OP("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, |
563 | AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, | 558 | AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, |
564 | AML_HAS_ARGS | AML_HAS_RETVAL), | 559 | AML_HAS_ARGS | AML_HAS_RETVAL), |
565 | /* 6B */ ACPI_OP("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, | 560 | /* 6B */ ACPI_OP("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, |
566 | AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), | 561 | AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), |
567 | /* 6C */ ACPI_OP("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, | 562 | /* 6C */ ACPI_OP("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, |
568 | AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), | 563 | AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), |
569 | /* 6D */ ACPI_OP("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, | 564 | /* 6D */ ACPI_OP("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, |
570 | AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), | 565 | AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), |
571 | 566 | ||
572 | /* ACPI 2.0 opcodes */ | 567 | /* ACPI 2.0 opcodes */ |
573 | 568 | ||
574 | /* 6E */ ACPI_OP("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, | 569 | /* 6E */ ACPI_OP("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, |
575 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, | 570 | ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, |
576 | AML_TYPE_LITERAL, AML_CONSTANT), | 571 | AML_TYPE_LITERAL, AML_CONSTANT), |
577 | /* 6F */ ACPI_OP("Package", /* Var */ ARGP_VAR_PACKAGE_OP, | 572 | /* 6F */ ACPI_OP("Package", /* Var */ ARGP_VAR_PACKAGE_OP, |
578 | ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, | 573 | ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, |
579 | AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, | 574 | AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, |
580 | AML_HAS_ARGS | AML_DEFER), | 575 | AML_HAS_ARGS | AML_DEFER), |
581 | /* 70 */ ACPI_OP("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, | 576 | /* 70 */ ACPI_OP("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, |
582 | ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, | 577 | ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, |
583 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | 578 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, |
584 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | 579 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), |
585 | /* 71 */ ACPI_OP("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, | 580 | /* 71 */ ACPI_OP("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, |
586 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, | 581 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, |
587 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | 582 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), |
588 | /* 72 */ ACPI_OP("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP, | 583 | /* 72 */ ACPI_OP("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP, |
589 | ARGI_CREATE_QWORD_FIELD_OP, | 584 | ARGI_CREATE_QWORD_FIELD_OP, |
590 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, | 585 | ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, |
591 | AML_TYPE_CREATE_FIELD, | 586 | AML_TYPE_CREATE_FIELD, |
592 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | | 587 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | |
593 | AML_DEFER | AML_CREATE), | 588 | AML_DEFER | AML_CREATE), |
594 | /* 73 */ ACPI_OP("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, | 589 | /* 73 */ ACPI_OP("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, |
595 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 590 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
596 | AML_TYPE_EXEC_1A_1T_1R, | 591 | AML_TYPE_EXEC_1A_1T_1R, |
597 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 592 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
598 | /* 74 */ ACPI_OP("ToDecimalString", ARGP_TO_DEC_STR_OP, | 593 | /* 74 */ ACPI_OP("ToDecimalString", ARGP_TO_DEC_STR_OP, |
599 | ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, | 594 | ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, |
600 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, | 595 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, |
601 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 596 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
602 | /* 75 */ ACPI_OP("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, | 597 | /* 75 */ ACPI_OP("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, |
603 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 598 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
604 | AML_TYPE_EXEC_1A_1T_1R, | 599 | AML_TYPE_EXEC_1A_1T_1R, |
605 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 600 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
606 | /* 76 */ ACPI_OP("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, | 601 | /* 76 */ ACPI_OP("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, |
607 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 602 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
608 | AML_TYPE_EXEC_1A_1T_1R, | 603 | AML_TYPE_EXEC_1A_1T_1R, |
609 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), | 604 | AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), |
610 | /* 77 */ ACPI_OP("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, | 605 | /* 77 */ ACPI_OP("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, |
611 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 606 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
612 | AML_TYPE_EXEC_2A_1T_1R, | 607 | AML_TYPE_EXEC_2A_1T_1R, |
613 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | 608 | AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), |
614 | /* 78 */ ACPI_OP("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, | 609 | /* 78 */ ACPI_OP("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, |
615 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 610 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
616 | AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), | 611 | AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), |
617 | /* 79 */ ACPI_OP("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, | 612 | /* 79 */ ACPI_OP("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, |
618 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, | 613 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, |
619 | AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), | 614 | AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), |
620 | /* 7A */ ACPI_OP("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, | 615 | /* 7A */ ACPI_OP("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, |
621 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), | 616 | ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), |
622 | /* 7B */ ACPI_OP("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, | 617 | /* 7B */ ACPI_OP("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, |
623 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, | 618 | ACPI_TYPE_ANY, AML_CLASS_EXECUTE, |
624 | AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), | 619 | AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), |
625 | /* 7C */ ACPI_OP("DataTableRegion", ARGP_DATA_REGION_OP, | 620 | /* 7C */ ACPI_OP("DataTableRegion", ARGP_DATA_REGION_OP, |
626 | ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, | 621 | ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, |
627 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, | 622 | AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, |
628 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 623 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | |
629 | AML_NSNODE | AML_NAMED), | 624 | AML_NSNODE | AML_NAMED), |
630 | /* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, | 625 | /* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, |
631 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, | 626 | ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, |
632 | AML_TYPE_NAMED_NO_OBJ, | 627 | AML_TYPE_NAMED_NO_OBJ, |
633 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | | 628 | AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), |
634 | AML_NSNODE), | ||
635 | 629 | ||
636 | /* ACPI 3.0 opcodes */ | 630 | /* ACPI 3.0 opcodes */ |
637 | 631 | ||
638 | /* 7E */ ACPI_OP("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, | 632 | /* 7E */ ACPI_OP("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, |
639 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, | 633 | AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, |
640 | AML_FLAGS_EXEC_0A_0T_1R) | 634 | AML_FLAGS_EXEC_0A_0T_1R) |
641 | 635 | ||
642 | /*! [End] no source code translation !*/ | 636 | /*! [End] no source code translation !*/ |
643 | }; | 637 | }; |
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index 8c6d3fdec38a..0dd2ce8a3475 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c | |||
@@ -567,7 +567,8 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
567 | (*sub_object_list)->string. | 567 | (*sub_object_list)->string. |
568 | length + 1); | 568 | length + 1); |
569 | } else { | 569 | } else { |
570 | temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node); | 570 | temp_size_needed += |
571 | acpi_ns_get_pathname_length((*sub_object_list)->reference.node); | ||
571 | } | 572 | } |
572 | } else { | 573 | } else { |
573 | /* | 574 | /* |
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index cc48ab05676c..50da494c3ee2 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c | |||
@@ -267,16 +267,19 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
267 | * If BIOS erroneously reversed the _PRT source_name and source_index, | 267 | * If BIOS erroneously reversed the _PRT source_name and source_index, |
268 | * then reverse them back. | 268 | * then reverse them back. |
269 | */ | 269 | */ |
270 | if (ACPI_GET_OBJECT_TYPE (sub_object_list[3]) != ACPI_TYPE_INTEGER) { | 270 | if (ACPI_GET_OBJECT_TYPE(sub_object_list[3]) != |
271 | ACPI_TYPE_INTEGER) { | ||
271 | if (acpi_gbl_enable_interpreter_slack) { | 272 | if (acpi_gbl_enable_interpreter_slack) { |
272 | source_name_index = 3; | 273 | source_name_index = 3; |
273 | source_index_index = 2; | 274 | source_index_index = 2; |
274 | printk(KERN_WARNING "ACPI: Handling Garbled _PRT entry\n"); | 275 | printk(KERN_WARNING |
276 | "ACPI: Handling Garbled _PRT entry\n"); | ||
275 | } else { | 277 | } else { |
276 | ACPI_ERROR((AE_INFO, | 278 | ACPI_ERROR((AE_INFO, |
277 | "(PRT[%X].source_index) Need Integer, found %s", | 279 | "(PRT[%X].source_index) Need Integer, found %s", |
278 | index, | 280 | index, |
279 | acpi_ut_get_object_type_name(sub_object_list[3]))); | 281 | acpi_ut_get_object_type_name |
282 | (sub_object_list[3]))); | ||
280 | return_ACPI_STATUS(AE_BAD_DATA); | 283 | return_ACPI_STATUS(AE_BAD_DATA); |
281 | } | 284 | } |
282 | } | 285 | } |
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index de20a5d6decf..46da116a4030 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c | |||
@@ -46,7 +46,6 @@ | |||
46 | 46 | ||
47 | #define _COMPONENT ACPI_RESOURCES | 47 | #define _COMPONENT ACPI_RESOURCES |
48 | ACPI_MODULE_NAME("rsdump") | 48 | ACPI_MODULE_NAME("rsdump") |
49 | |||
50 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | 49 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) |
51 | /* Local prototypes */ | 50 | /* Local prototypes */ |
52 | static void acpi_rs_out_string(char *title, char *value); | 51 | static void acpi_rs_out_string(char *title, char *value); |
@@ -489,10 +488,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
489 | /* | 488 | /* |
490 | * Optional resource_source for Address resources | 489 | * Optional resource_source for Address resources |
491 | */ | 490 | */ |
492 | acpi_rs_dump_resource_source(ACPI_CAST_PTR | 491 | acpi_rs_dump_resource_source(ACPI_CAST_PTR(struct |
493 | (struct | 492 | acpi_resource_source, |
494 | acpi_resource_source, | 493 | target)); |
495 | target)); | ||
496 | break; | 494 | break; |
497 | 495 | ||
498 | default: | 496 | default: |
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index 7e3c335ab320..2c2adb6292c1 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c | |||
@@ -142,7 +142,7 @@ struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = { | |||
142 | }; | 142 | }; |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | #endif /* ACPI_FUTURE_USAGE */ | 145 | #endif /* ACPI_FUTURE_USAGE */ |
146 | /* | 146 | /* |
147 | * Base sizes for external AML resource descriptors, indexed by internal type. | 147 | * Base sizes for external AML resource descriptors, indexed by internal type. |
148 | * Includes size of the descriptor header (1 byte for small descriptors, | 148 | * Includes size of the descriptor header (1 byte for small descriptors, |
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index a92755c8877d..ca21e4660c79 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c | |||
@@ -153,10 +153,9 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | |||
153 | 153 | ||
154 | /* Perform the conversion */ | 154 | /* Perform the conversion */ |
155 | 155 | ||
156 | status = acpi_rs_convert_resource_to_aml(resource, | 156 | status = acpi_rs_convert_resource_to_aml(resource, ACPI_CAST_PTR(union |
157 | ACPI_CAST_PTR(union | 157 | aml_resource, |
158 | aml_resource, | 158 | aml), |
159 | aml), | ||
160 | acpi_gbl_set_resource_dispatch | 159 | acpi_gbl_set_resource_dispatch |
161 | [resource->type]); | 160 | [resource->type]); |
162 | if (ACPI_FAILURE(status)) { | 161 | if (ACPI_FAILURE(status)) { |
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index 3b63b561b94e..c7081afa893a 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c | |||
@@ -46,7 +46,6 @@ | |||
46 | 46 | ||
47 | #define _COMPONENT ACPI_RESOURCES | 47 | #define _COMPONENT ACPI_RESOURCES |
48 | ACPI_MODULE_NAME("rsmisc") | 48 | ACPI_MODULE_NAME("rsmisc") |
49 | |||
50 | #define INIT_RESOURCE_TYPE(i) i->resource_offset | 49 | #define INIT_RESOURCE_TYPE(i) i->resource_offset |
51 | #define INIT_RESOURCE_LENGTH(i) i->aml_offset | 50 | #define INIT_RESOURCE_LENGTH(i) i->aml_offset |
52 | #define INIT_TABLE_LENGTH(i) i->value | 51 | #define INIT_TABLE_LENGTH(i) i->value |
@@ -429,8 +428,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, | |||
429 | * Optional resource_source (Index and String) | 428 | * Optional resource_source (Index and String) |
430 | */ | 429 | */ |
431 | aml_length = | 430 | aml_length = |
432 | acpi_rs_set_resource_source(aml, | 431 | acpi_rs_set_resource_source(aml, (acpi_rs_length) |
433 | (acpi_rs_length) | ||
434 | aml_length, source); | 432 | aml_length, source); |
435 | acpi_rs_set_resource_length(aml_length, aml); | 433 | acpi_rs_set_resource_length(aml_length, aml); |
436 | break; | 434 | break; |
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 2442a8f8df57..11c0bd7b9cfd 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c | |||
@@ -353,10 +353,8 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, | |||
353 | * | 353 | * |
354 | * Zero the entire area of the buffer. | 354 | * Zero the entire area of the buffer. |
355 | */ | 355 | */ |
356 | total_length = | 356 | total_length = (u32) |
357 | (u32) | 357 | ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + 1; |
358 | ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + | ||
359 | 1; | ||
360 | total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length); | 358 | total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length); |
361 | 359 | ||
362 | ACPI_MEMSET(resource_source->string_ptr, 0, total_length); | 360 | ACPI_MEMSET(resource_source->string_ptr, 0, total_length); |
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 991f8901498c..f63813a358c5 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c | |||
@@ -217,7 +217,6 @@ acpi_get_current_resources(acpi_handle device_handle, | |||
217 | } | 217 | } |
218 | 218 | ||
219 | ACPI_EXPORT_SYMBOL(acpi_get_current_resources) | 219 | ACPI_EXPORT_SYMBOL(acpi_get_current_resources) |
220 | |||
221 | #ifdef ACPI_FUTURE_USAGE | 220 | #ifdef ACPI_FUTURE_USAGE |
222 | /******************************************************************************* | 221 | /******************************************************************************* |
223 | * | 222 | * |
@@ -261,7 +260,6 @@ acpi_get_possible_resources(acpi_handle device_handle, | |||
261 | 260 | ||
262 | ACPI_EXPORT_SYMBOL(acpi_get_possible_resources) | 261 | ACPI_EXPORT_SYMBOL(acpi_get_possible_resources) |
263 | #endif /* ACPI_FUTURE_USAGE */ | 262 | #endif /* ACPI_FUTURE_USAGE */ |
264 | |||
265 | /******************************************************************************* | 263 | /******************************************************************************* |
266 | * | 264 | * |
267 | * FUNCTION: acpi_set_current_resources | 265 | * FUNCTION: acpi_set_current_resources |
@@ -496,7 +494,6 @@ ACPI_EXPORT_SYMBOL(acpi_rs_match_vendor_resource) | |||
496 | * each resource in the list. | 494 | * each resource in the list. |
497 | * | 495 | * |
498 | ******************************************************************************/ | 496 | ******************************************************************************/ |
499 | |||
500 | acpi_status | 497 | acpi_status |
501 | acpi_walk_resources(acpi_handle device_handle, | 498 | acpi_walk_resources(acpi_handle device_handle, |
502 | char *name, | 499 | char *name, |
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index 52b23471dd69..bc7e16ec8393 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -222,7 +222,7 @@ static struct hibernation_ops acpi_hibernation_ops = { | |||
222 | .enter = acpi_hibernation_enter, | 222 | .enter = acpi_hibernation_enter, |
223 | .finish = acpi_hibernation_finish, | 223 | .finish = acpi_hibernation_finish, |
224 | }; | 224 | }; |
225 | #endif /* CONFIG_SOFTWARE_SUSPEND */ | 225 | #endif /* CONFIG_SOFTWARE_SUSPEND */ |
226 | 226 | ||
227 | /* | 227 | /* |
228 | * Toshiba fails to preserve interrupts over S1, reinitialization | 228 | * Toshiba fails to preserve interrupts over S1, reinitialization |
@@ -276,4 +276,3 @@ int __init acpi_sleep_init(void) | |||
276 | 276 | ||
277 | return 0; | 277 | return 0; |
278 | } | 278 | } |
279 | |||
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 76b45f0b8341..61f1822cc350 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c | |||
@@ -349,8 +349,7 @@ acpi_system_write_alarm(struct file *file, | |||
349 | end: | 349 | end: |
350 | return_VALUE(result ? result : count); | 350 | return_VALUE(result ? result : count); |
351 | } | 351 | } |
352 | #endif /* HAVE_ACPI_LEGACY_ALARM */ | 352 | #endif /* HAVE_ACPI_LEGACY_ALARM */ |
353 | |||
354 | 353 | ||
355 | extern struct list_head acpi_wakeup_device_list; | 354 | extern struct list_head acpi_wakeup_device_list; |
356 | extern spinlock_t acpi_device_lock; | 355 | extern spinlock_t acpi_device_lock; |
@@ -380,8 +379,8 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) | |||
380 | dev->wakeup.state.enabled ? "enabled" : "disabled"); | 379 | dev->wakeup.state.enabled ? "enabled" : "disabled"); |
381 | if (ldev) | 380 | if (ldev) |
382 | seq_printf(seq, "%s:%s", | 381 | seq_printf(seq, "%s:%s", |
383 | ldev->bus ? ldev->bus->name : "no-bus", | 382 | ldev->bus ? ldev->bus->name : "no-bus", |
384 | ldev->bus_id); | 383 | ldev->bus_id); |
385 | seq_printf(seq, "\n"); | 384 | seq_printf(seq, "\n"); |
386 | put_device(ldev); | 385 | put_device(ldev); |
387 | 386 | ||
@@ -490,7 +489,7 @@ static u32 rtc_handler(void *context) | |||
490 | 489 | ||
491 | return ACPI_INTERRUPT_HANDLED; | 490 | return ACPI_INTERRUPT_HANDLED; |
492 | } | 491 | } |
493 | #endif /* HAVE_ACPI_LEGACY_ALARM */ | 492 | #endif /* HAVE_ACPI_LEGACY_ALARM */ |
494 | 493 | ||
495 | static int __init acpi_sleep_proc_init(void) | 494 | static int __init acpi_sleep_proc_init(void) |
496 | { | 495 | { |
@@ -517,7 +516,7 @@ static int __init acpi_sleep_proc_init(void) | |||
517 | entry->proc_fops = &acpi_system_alarm_fops; | 516 | entry->proc_fops = &acpi_system_alarm_fops; |
518 | 517 | ||
519 | acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL); | 518 | acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL); |
520 | #endif /* HAVE_ACPI_LEGACY_ALARM */ | 519 | #endif /* HAVE_ACPI_LEGACY_ALARM */ |
521 | 520 | ||
522 | /* 'wakeup device' [R/W] */ | 521 | /* 'wakeup device' [R/W] */ |
523 | entry = | 522 | entry = |
diff --git a/drivers/acpi/tables/tbfadt.c b/drivers/acpi/tables/tbfadt.c index 1db833eb2417..1285e91474fb 100644 --- a/drivers/acpi/tables/tbfadt.c +++ b/drivers/acpi/tables/tbfadt.c | |||
@@ -334,7 +334,8 @@ static void acpi_tb_convert_fadt(void) | |||
334 | (acpi_gbl_FADT.xpm1a_event_block.address + | 334 | (acpi_gbl_FADT.xpm1a_event_block.address + |
335 | pm1_register_length)); | 335 | pm1_register_length)); |
336 | /* Don't forget to copy space_id of the GAS */ | 336 | /* Don't forget to copy space_id of the GAS */ |
337 | acpi_gbl_xpm1a_enable.space_id = acpi_gbl_FADT.xpm1a_event_block.space_id; | 337 | acpi_gbl_xpm1a_enable.space_id = |
338 | acpi_gbl_FADT.xpm1a_event_block.space_id; | ||
338 | 339 | ||
339 | /* The PM1B register block is optional, ignore if not present */ | 340 | /* The PM1B register block is optional, ignore if not present */ |
340 | 341 | ||
@@ -344,7 +345,8 @@ static void acpi_tb_convert_fadt(void) | |||
344 | (acpi_gbl_FADT.xpm1b_event_block. | 345 | (acpi_gbl_FADT.xpm1b_event_block. |
345 | address + pm1_register_length)); | 346 | address + pm1_register_length)); |
346 | /* Don't forget to copy space_id of the GAS */ | 347 | /* Don't forget to copy space_id of the GAS */ |
347 | acpi_gbl_xpm1b_enable.space_id = acpi_gbl_FADT.xpm1a_event_block.space_id; | 348 | acpi_gbl_xpm1b_enable.space_id = |
349 | acpi_gbl_FADT.xpm1a_event_block.space_id; | ||
348 | 350 | ||
349 | } | 351 | } |
350 | 352 | ||
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index 417ef5fa7666..5b302c4e293f 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c | |||
@@ -201,6 +201,7 @@ acpi_status acpi_reallocate_root_table(void) | |||
201 | 201 | ||
202 | return_ACPI_STATUS(AE_OK); | 202 | return_ACPI_STATUS(AE_OK); |
203 | } | 203 | } |
204 | |||
204 | /******************************************************************************* | 205 | /******************************************************************************* |
205 | * | 206 | * |
206 | * FUNCTION: acpi_load_table | 207 | * FUNCTION: acpi_load_table |
@@ -262,7 +263,7 @@ ACPI_EXPORT_SYMBOL(acpi_load_table) | |||
262 | acpi_status | 263 | acpi_status |
263 | acpi_get_table_header(char *signature, | 264 | acpi_get_table_header(char *signature, |
264 | acpi_native_uint instance, | 265 | acpi_native_uint instance, |
265 | struct acpi_table_header *out_table_header) | 266 | struct acpi_table_header * out_table_header) |
266 | { | 267 | { |
267 | acpi_native_uint i; | 268 | acpi_native_uint i; |
268 | acpi_native_uint j; | 269 | acpi_native_uint j; |
@@ -321,7 +322,6 @@ acpi_get_table_header(char *signature, | |||
321 | 322 | ||
322 | ACPI_EXPORT_SYMBOL(acpi_get_table_header) | 323 | ACPI_EXPORT_SYMBOL(acpi_get_table_header) |
323 | 324 | ||
324 | |||
325 | /****************************************************************************** | 325 | /****************************************************************************** |
326 | * | 326 | * |
327 | * FUNCTION: acpi_unload_table_id | 327 | * FUNCTION: acpi_unload_table_id |
@@ -346,11 +346,11 @@ acpi_status acpi_unload_table_id(acpi_owner_id id) | |||
346 | continue; | 346 | continue; |
347 | } | 347 | } |
348 | /* | 348 | /* |
349 | * Delete all namespace objects owned by this table. Note that these | 349 | * Delete all namespace objects owned by this table. Note that these |
350 | * objects can appear anywhere in the namespace by virtue of the AML | 350 | * objects can appear anywhere in the namespace by virtue of the AML |
351 | * "Scope" operator. Thus, we need to track ownership by an ID, not | 351 | * "Scope" operator. Thus, we need to track ownership by an ID, not |
352 | * simply a position within the hierarchy | 352 | * simply a position within the hierarchy |
353 | */ | 353 | */ |
354 | acpi_tb_delete_namespace_by_owner(i); | 354 | acpi_tb_delete_namespace_by_owner(i); |
355 | status = acpi_tb_release_owner_id(i); | 355 | status = acpi_tb_release_owner_id(i); |
356 | acpi_tb_set_table_loaded_flag(i, FALSE); | 356 | acpi_tb_set_table_loaded_flag(i, FALSE); |
@@ -376,7 +376,7 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id) | |||
376 | *****************************************************************************/ | 376 | *****************************************************************************/ |
377 | acpi_status | 377 | acpi_status |
378 | acpi_get_table(char *signature, | 378 | acpi_get_table(char *signature, |
379 | acpi_native_uint instance, struct acpi_table_header ** out_table) | 379 | acpi_native_uint instance, struct acpi_table_header **out_table) |
380 | { | 380 | { |
381 | acpi_native_uint i; | 381 | acpi_native_uint i; |
382 | acpi_native_uint j; | 382 | acpi_native_uint j; |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 589b98b7b216..1ada017d01ef 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -59,8 +59,6 @@ | |||
59 | #define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 | 59 | #define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 |
60 | #define ACPI_THERMAL_NOTIFY_HOT 0xF1 | 60 | #define ACPI_THERMAL_NOTIFY_HOT 0xF1 |
61 | #define ACPI_THERMAL_MODE_ACTIVE 0x00 | 61 | #define ACPI_THERMAL_MODE_ACTIVE 0x00 |
62 | #define ACPI_THERMAL_MODE_PASSIVE 0x01 | ||
63 | #define ACPI_THERMAL_MODE_CRITICAL 0xff | ||
64 | #define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff" | 62 | #define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff" |
65 | 63 | ||
66 | #define ACPI_THERMAL_MAX_ACTIVE 10 | 64 | #define ACPI_THERMAL_MAX_ACTIVE 10 |
@@ -86,9 +84,6 @@ static int acpi_thermal_resume(struct acpi_device *device); | |||
86 | static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); | 84 | static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); |
87 | static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); | 85 | static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); |
88 | static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); | 86 | static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); |
89 | static ssize_t acpi_thermal_write_trip_points(struct file *, | ||
90 | const char __user *, size_t, | ||
91 | loff_t *); | ||
92 | static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); | 87 | static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); |
93 | static ssize_t acpi_thermal_write_cooling_mode(struct file *, | 88 | static ssize_t acpi_thermal_write_cooling_mode(struct file *, |
94 | const char __user *, size_t, | 89 | const char __user *, size_t, |
@@ -167,7 +162,6 @@ struct acpi_thermal { | |||
167 | unsigned long temperature; | 162 | unsigned long temperature; |
168 | unsigned long last_temperature; | 163 | unsigned long last_temperature; |
169 | unsigned long polling_frequency; | 164 | unsigned long polling_frequency; |
170 | u8 cooling_mode; | ||
171 | volatile u8 zombie; | 165 | volatile u8 zombie; |
172 | struct acpi_thermal_flags flags; | 166 | struct acpi_thermal_flags flags; |
173 | struct acpi_thermal_state state; | 167 | struct acpi_thermal_state state; |
@@ -193,7 +187,6 @@ static const struct file_operations acpi_thermal_temp_fops = { | |||
193 | static const struct file_operations acpi_thermal_trip_fops = { | 187 | static const struct file_operations acpi_thermal_trip_fops = { |
194 | .open = acpi_thermal_trip_open_fs, | 188 | .open = acpi_thermal_trip_open_fs, |
195 | .read = seq_read, | 189 | .read = seq_read, |
196 | .write = acpi_thermal_write_trip_points, | ||
197 | .llseek = seq_lseek, | 190 | .llseek = seq_lseek, |
198 | .release = single_release, | 191 | .release = single_release, |
199 | }; | 192 | }; |
@@ -297,11 +290,6 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) | |||
297 | if (ACPI_FAILURE(status)) | 290 | if (ACPI_FAILURE(status)) |
298 | return -ENODEV; | 291 | return -ENODEV; |
299 | 292 | ||
300 | tz->cooling_mode = mode; | ||
301 | |||
302 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", | ||
303 | mode ? "passive" : "active")); | ||
304 | |||
305 | return 0; | 293 | return 0; |
306 | } | 294 | } |
307 | 295 | ||
@@ -889,67 +877,6 @@ static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file) | |||
889 | return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data); | 877 | return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data); |
890 | } | 878 | } |
891 | 879 | ||
892 | static ssize_t | ||
893 | acpi_thermal_write_trip_points(struct file *file, | ||
894 | const char __user * buffer, | ||
895 | size_t count, loff_t * ppos) | ||
896 | { | ||
897 | struct seq_file *m = file->private_data; | ||
898 | struct acpi_thermal *tz = m->private; | ||
899 | |||
900 | char *limit_string; | ||
901 | int num, critical, hot, passive; | ||
902 | int *active; | ||
903 | int i = 0; | ||
904 | |||
905 | |||
906 | limit_string = kzalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); | ||
907 | if (!limit_string) | ||
908 | return -ENOMEM; | ||
909 | |||
910 | active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); | ||
911 | if (!active) { | ||
912 | kfree(limit_string); | ||
913 | return -ENOMEM; | ||
914 | } | ||
915 | |||
916 | if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { | ||
917 | count = -EINVAL; | ||
918 | goto end; | ||
919 | } | ||
920 | |||
921 | if (copy_from_user(limit_string, buffer, count)) { | ||
922 | count = -EFAULT; | ||
923 | goto end; | ||
924 | } | ||
925 | |||
926 | limit_string[count] = '\0'; | ||
927 | |||
928 | num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", | ||
929 | &critical, &hot, &passive, | ||
930 | &active[0], &active[1], &active[2], &active[3], &active[4], | ||
931 | &active[5], &active[6], &active[7], &active[8], | ||
932 | &active[9]); | ||
933 | if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { | ||
934 | count = -EINVAL; | ||
935 | goto end; | ||
936 | } | ||
937 | |||
938 | tz->trips.critical.temperature = CELSIUS_TO_KELVIN(critical); | ||
939 | tz->trips.hot.temperature = CELSIUS_TO_KELVIN(hot); | ||
940 | tz->trips.passive.temperature = CELSIUS_TO_KELVIN(passive); | ||
941 | for (i = 0; i < num - 3; i++) { | ||
942 | if (!(tz->trips.active[i].flags.valid)) | ||
943 | break; | ||
944 | tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]); | ||
945 | } | ||
946 | |||
947 | end: | ||
948 | kfree(active); | ||
949 | kfree(limit_string); | ||
950 | return count; | ||
951 | } | ||
952 | |||
953 | static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) | 880 | static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) |
954 | { | 881 | { |
955 | struct acpi_thermal *tz = seq->private; | 882 | struct acpi_thermal *tz = seq->private; |
@@ -958,15 +885,10 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) | |||
958 | if (!tz) | 885 | if (!tz) |
959 | goto end; | 886 | goto end; |
960 | 887 | ||
961 | if (!tz->flags.cooling_mode) { | 888 | if (!tz->flags.cooling_mode) |
962 | seq_puts(seq, "<setting not supported>\n"); | 889 | seq_puts(seq, "<setting not supported>\n"); |
963 | } | ||
964 | |||
965 | if (tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL) | ||
966 | seq_printf(seq, "cooling mode: critical\n"); | ||
967 | else | 890 | else |
968 | seq_printf(seq, "cooling mode: %s\n", | 891 | seq_puts(seq, "0 - Active; 1 - Passive\n"); |
969 | tz->cooling_mode ? "passive" : "active"); | ||
970 | 892 | ||
971 | end: | 893 | end: |
972 | return 0; | 894 | return 0; |
@@ -1223,28 +1145,6 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz) | |||
1223 | result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); | 1145 | result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); |
1224 | if (!result) | 1146 | if (!result) |
1225 | tz->flags.cooling_mode = 1; | 1147 | tz->flags.cooling_mode = 1; |
1226 | else { | ||
1227 | /* Oh,we have not _SCP method. | ||
1228 | Generally show cooling_mode by _ACx, _PSV,spec 12.2 */ | ||
1229 | tz->flags.cooling_mode = 0; | ||
1230 | if (tz->trips.active[0].flags.valid | ||
1231 | && tz->trips.passive.flags.valid) { | ||
1232 | if (tz->trips.passive.temperature > | ||
1233 | tz->trips.active[0].temperature) | ||
1234 | tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; | ||
1235 | else | ||
1236 | tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; | ||
1237 | } else if (!tz->trips.active[0].flags.valid | ||
1238 | && tz->trips.passive.flags.valid) { | ||
1239 | tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; | ||
1240 | } else if (tz->trips.active[0].flags.valid | ||
1241 | && !tz->trips.passive.flags.valid) { | ||
1242 | tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; | ||
1243 | } else { | ||
1244 | /* _ACx and _PSV are optional, but _CRT is required */ | ||
1245 | tz->cooling_mode = ACPI_THERMAL_MODE_CRITICAL; | ||
1246 | } | ||
1247 | } | ||
1248 | 1148 | ||
1249 | /* Get default polling frequency [_TZP] (optional) */ | 1149 | /* Get default polling frequency [_TZP] (optional) */ |
1250 | if (tzp) | 1150 | if (tzp) |
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 55a764807499..6e56d5f7c43a 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c | |||
@@ -107,7 +107,6 @@ acpi_status acpi_ut_create_caches(void) | |||
107 | if (ACPI_FAILURE(status)) { | 107 | if (ACPI_FAILURE(status)) { |
108 | return (status); | 108 | return (status); |
109 | } | 109 | } |
110 | |||
111 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | 110 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
112 | 111 | ||
113 | /* Memory allocation lists */ | 112 | /* Memory allocation lists */ |
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c index 870f6edeb5f2..285a0f531760 100644 --- a/drivers/acpi/utilities/utcache.c +++ b/drivers/acpi/utilities/utcache.c | |||
@@ -45,7 +45,6 @@ | |||
45 | 45 | ||
46 | #define _COMPONENT ACPI_UTILITIES | 46 | #define _COMPONENT ACPI_UTILITIES |
47 | ACPI_MODULE_NAME("utcache") | 47 | ACPI_MODULE_NAME("utcache") |
48 | |||
49 | #ifdef ACPI_USE_LOCAL_CACHE | 48 | #ifdef ACPI_USE_LOCAL_CACHE |
50 | /******************************************************************************* | 49 | /******************************************************************************* |
51 | * | 50 | * |
@@ -64,7 +63,7 @@ ACPI_MODULE_NAME("utcache") | |||
64 | acpi_status | 63 | acpi_status |
65 | acpi_os_create_cache(char *cache_name, | 64 | acpi_os_create_cache(char *cache_name, |
66 | u16 object_size, | 65 | u16 object_size, |
67 | u16 max_depth, struct acpi_memory_list **return_cache) | 66 | u16 max_depth, struct acpi_memory_list ** return_cache) |
68 | { | 67 | { |
69 | struct acpi_memory_list *cache; | 68 | struct acpi_memory_list *cache; |
70 | 69 | ||
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 84d529db0a66..4c1e00874dff 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c | |||
@@ -814,7 +814,9 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type, | |||
814 | /* | 814 | /* |
815 | * Create the object array | 815 | * Create the object array |
816 | */ | 816 | */ |
817 | target_object->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) source_object->package.count + 1) * sizeof(void *)); | 817 | target_object->package.elements = |
818 | ACPI_ALLOCATE_ZEROED(((acpi_size) source_object->package. | ||
819 | count + 1) * sizeof(void *)); | ||
818 | if (!target_object->package.elements) { | 820 | if (!target_object->package.elements) { |
819 | status = AE_NO_MEMORY; | 821 | status = AE_NO_MEMORY; |
820 | goto error_exit; | 822 | goto error_exit; |
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index 61ad4f2daee2..c7e128e5369b 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c | |||
@@ -45,7 +45,6 @@ | |||
45 | 45 | ||
46 | #define _COMPONENT ACPI_UTILITIES | 46 | #define _COMPONENT ACPI_UTILITIES |
47 | ACPI_MODULE_NAME("utdebug") | 47 | ACPI_MODULE_NAME("utdebug") |
48 | |||
49 | #ifdef ACPI_DEBUG_OUTPUT | 48 | #ifdef ACPI_DEBUG_OUTPUT |
50 | static acpi_thread_id acpi_gbl_prev_thread_id; | 49 | static acpi_thread_id acpi_gbl_prev_thread_id; |
51 | static char *acpi_gbl_fn_entry_str = "----Entry"; | 50 | static char *acpi_gbl_fn_entry_str = "----Entry"; |
@@ -181,7 +180,8 @@ acpi_ut_debug_print(u32 requested_debug_level, | |||
181 | if (ACPI_LV_THREADS & acpi_dbg_level) { | 180 | if (ACPI_LV_THREADS & acpi_dbg_level) { |
182 | acpi_os_printf | 181 | acpi_os_printf |
183 | ("\n**** Context Switch from TID %lX to TID %lX ****\n\n", | 182 | ("\n**** Context Switch from TID %lX to TID %lX ****\n\n", |
184 | (unsigned long)acpi_gbl_prev_thread_id, (unsigned long)thread_id); | 183 | (unsigned long)acpi_gbl_prev_thread_id, |
184 | (unsigned long)thread_id); | ||
185 | } | 185 | } |
186 | 186 | ||
187 | acpi_gbl_prev_thread_id = thread_id; | 187 | acpi_gbl_prev_thread_id = thread_id; |
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index 673a0caa4073..f777cebdc46d 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c | |||
@@ -170,6 +170,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) | |||
170 | acpi_os_delete_mutex(object->mutex.os_mutex); | 170 | acpi_os_delete_mutex(object->mutex.os_mutex); |
171 | acpi_gbl_global_lock_mutex = NULL; | 171 | acpi_gbl_global_lock_mutex = NULL; |
172 | } else { | 172 | } else { |
173 | acpi_ex_unlink_mutex(object); | ||
173 | acpi_os_delete_mutex(object->mutex.os_mutex); | 174 | acpi_os_delete_mutex(object->mutex.os_mutex); |
174 | } | 175 | } |
175 | break; | 176 | break; |
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index af33358a964b..1621655d6e2b 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c | |||
@@ -55,12 +55,10 @@ ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) | |||
55 | * Static global variable initialization. | 55 | * Static global variable initialization. |
56 | * | 56 | * |
57 | ******************************************************************************/ | 57 | ******************************************************************************/ |
58 | |||
59 | /* | 58 | /* |
60 | * We want the debug switches statically initialized so they | 59 | * We want the debug switches statically initialized so they |
61 | * are already set when the debugger is entered. | 60 | * are already set when the debugger is entered. |
62 | */ | 61 | */ |
63 | |||
64 | /* Debug switch - level and trace mask */ | 62 | /* Debug switch - level and trace mask */ |
65 | u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; | 63 | u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; |
66 | 64 | ||
@@ -735,5 +733,5 @@ void acpi_ut_init_globals(void) | |||
735 | } | 733 | } |
736 | 734 | ||
737 | ACPI_EXPORT_SYMBOL(acpi_dbg_level) | 735 | ACPI_EXPORT_SYMBOL(acpi_dbg_level) |
738 | ACPI_EXPORT_SYMBOL(acpi_dbg_layer) | 736 | ACPI_EXPORT_SYMBOL(acpi_dbg_layer) |
739 | ACPI_EXPORT_SYMBOL(acpi_gpe_count) | 737 | ACPI_EXPORT_SYMBOL(acpi_gpe_count) |
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 50133fffe420..2d19f71e9cfa 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c | |||
@@ -802,9 +802,8 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer) | |||
802 | 802 | ||
803 | valid_digits++; | 803 | valid_digits++; |
804 | 804 | ||
805 | if (sign_of0x | 805 | if (sign_of0x && ((valid_digits > 16) |
806 | && ((valid_digits > 16) | 806 | || ((valid_digits > 8) && mode32))) { |
807 | || ((valid_digits > 8) && mode32))) { | ||
808 | /* | 807 | /* |
809 | * This is to_integer operation case. | 808 | * This is to_integer operation case. |
810 | * No any restrictions for string-to-integer conversion, | 809 | * No any restrictions for string-to-integer conversion, |
@@ -1049,6 +1048,7 @@ acpi_ut_exception(char *module_name, | |||
1049 | acpi_os_vprintf(format, args); | 1048 | acpi_os_vprintf(format, args); |
1050 | acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); | 1049 | acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); |
1051 | } | 1050 | } |
1051 | |||
1052 | EXPORT_SYMBOL(acpi_ut_exception); | 1052 | EXPORT_SYMBOL(acpi_ut_exception); |
1053 | 1053 | ||
1054 | void ACPI_INTERNAL_VAR_XFACE | 1054 | void ACPI_INTERNAL_VAR_XFACE |
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c index cbad2ef5987d..4820bc86d1f5 100644 --- a/drivers/acpi/utilities/utmutex.c +++ b/drivers/acpi/utilities/utmutex.c | |||
@@ -244,7 +244,7 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) | |||
244 | 244 | ||
245 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | 245 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
246 | "Thread %lX attempting to acquire Mutex [%s]\n", | 246 | "Thread %lX attempting to acquire Mutex [%s]\n", |
247 | (unsigned long) this_thread_id, | 247 | (unsigned long)this_thread_id, |
248 | acpi_ut_get_mutex_name(mutex_id))); | 248 | acpi_ut_get_mutex_name(mutex_id))); |
249 | 249 | ||
250 | status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, | 250 | status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, |
@@ -252,7 +252,7 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) | |||
252 | if (ACPI_SUCCESS(status)) { | 252 | if (ACPI_SUCCESS(status)) { |
253 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | 253 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
254 | "Thread %lX acquired Mutex [%s]\n", | 254 | "Thread %lX acquired Mutex [%s]\n", |
255 | (unsigned long) this_thread_id, | 255 | (unsigned long)this_thread_id, |
256 | acpi_ut_get_mutex_name(mutex_id))); | 256 | acpi_ut_get_mutex_name(mutex_id))); |
257 | 257 | ||
258 | acpi_gbl_mutex_info[mutex_id].use_count++; | 258 | acpi_gbl_mutex_info[mutex_id].use_count++; |
@@ -260,7 +260,7 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) | |||
260 | } else { | 260 | } else { |
261 | ACPI_EXCEPTION((AE_INFO, status, | 261 | ACPI_EXCEPTION((AE_INFO, status, |
262 | "Thread %lX could not acquire Mutex [%X]", | 262 | "Thread %lX could not acquire Mutex [%X]", |
263 | (unsigned long) this_thread_id, mutex_id)); | 263 | (unsigned long)this_thread_id, mutex_id)); |
264 | } | 264 | } |
265 | 265 | ||
266 | return (status); | 266 | return (status); |
@@ -287,7 +287,7 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) | |||
287 | this_thread_id = acpi_os_get_thread_id(); | 287 | this_thread_id = acpi_os_get_thread_id(); |
288 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | 288 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
289 | "Thread %lX releasing Mutex [%s]\n", | 289 | "Thread %lX releasing Mutex [%s]\n", |
290 | (unsigned long) this_thread_id, | 290 | (unsigned long)this_thread_id, |
291 | acpi_ut_get_mutex_name(mutex_id))); | 291 | acpi_ut_get_mutex_name(mutex_id))); |
292 | 292 | ||
293 | if (mutex_id > ACPI_MAX_MUTEX) { | 293 | if (mutex_id > ACPI_MAX_MUTEX) { |
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c index e8fe1ba6cc24..cbbd3315a1e2 100644 --- a/drivers/acpi/utilities/utresrc.c +++ b/drivers/acpi/utilities/utresrc.c | |||
@@ -46,7 +46,6 @@ | |||
46 | 46 | ||
47 | #define _COMPONENT ACPI_UTILITIES | 47 | #define _COMPONENT ACPI_UTILITIES |
48 | ACPI_MODULE_NAME("utresrc") | 48 | ACPI_MODULE_NAME("utresrc") |
49 | |||
50 | #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) | 49 | #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) |
51 | /* | 50 | /* |
52 | * Strings used to decode resource descriptors. | 51 | * Strings used to decode resource descriptors. |
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index de3276f4f468..e9a57806cd34 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c | |||
@@ -337,7 +337,6 @@ acpi_status acpi_terminate(void) | |||
337 | } | 337 | } |
338 | 338 | ||
339 | ACPI_EXPORT_SYMBOL(acpi_terminate) | 339 | ACPI_EXPORT_SYMBOL(acpi_terminate) |
340 | |||
341 | #ifdef ACPI_FUTURE_USAGE | 340 | #ifdef ACPI_FUTURE_USAGE |
342 | /******************************************************************************* | 341 | /******************************************************************************* |
343 | * | 342 | * |
@@ -470,7 +469,6 @@ acpi_install_initialization_handler(acpi_init_handler handler, u32 function) | |||
470 | 469 | ||
471 | ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler) | 470 | ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler) |
472 | #endif /* ACPI_FUTURE_USAGE */ | 471 | #endif /* ACPI_FUTURE_USAGE */ |
473 | |||
474 | /***************************************************************************** | 472 | /***************************************************************************** |
475 | * | 473 | * |
476 | * FUNCTION: acpi_purge_cached_objects | 474 | * FUNCTION: acpi_purge_cached_objects |
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index c7219663f2b9..ad1f59c1b3fc 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -2,10 +2,9 @@ | |||
2 | # SATA/PATA driver configuration | 2 | # SATA/PATA driver configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Serial ATA (prod) and Parallel ATA (experimental) drivers" | 5 | menuconfig ATA |
6 | 6 | tristate "Serial ATA (prod) and Parallel ATA (experimental) drivers" | |
7 | config ATA | 7 | depends on HAS_IOMEM |
8 | tristate "ATA device support" | ||
9 | depends on BLOCK | 8 | depends on BLOCK |
10 | depends on !(M32R || M68K) || BROKEN | 9 | depends on !(M32R || M68K) || BROKEN |
11 | depends on !SUN4 || BROKEN | 10 | depends on !SUN4 || BROKEN |
@@ -23,6 +22,19 @@ config ATA_NONSTANDARD | |||
23 | bool | 22 | bool |
24 | default n | 23 | default n |
25 | 24 | ||
25 | config ATA_ACPI | ||
26 | bool | ||
27 | depends on ACPI && PCI | ||
28 | default y | ||
29 | help | ||
30 | This option adds support for ATA-related ACPI objects. | ||
31 | These ACPI objects add the ability to retrieve taskfiles | ||
32 | from the ACPI BIOS and write them to the disk controller. | ||
33 | These objects may be related to performance, security, | ||
34 | power management, or other areas. | ||
35 | You can disable this at kernel boot time by using the | ||
36 | option libata.noacpi=1 | ||
37 | |||
26 | config SATA_AHCI | 38 | config SATA_AHCI |
27 | tristate "AHCI SATA support" | 39 | tristate "AHCI SATA support" |
28 | depends on PCI | 40 | depends on PCI |
@@ -156,19 +168,6 @@ config SATA_INIC162X | |||
156 | help | 168 | help |
157 | This option enables support for Initio 162x Serial ATA. | 169 | This option enables support for Initio 162x Serial ATA. |
158 | 170 | ||
159 | config SATA_ACPI | ||
160 | bool | ||
161 | depends on ACPI && PCI | ||
162 | default y | ||
163 | help | ||
164 | This option adds support for SATA-related ACPI objects. | ||
165 | These ACPI objects add the ability to retrieve taskfiles | ||
166 | from the ACPI BIOS and write them to the disk controller. | ||
167 | These objects may be related to performance, security, | ||
168 | power management, or other areas. | ||
169 | You can disable this at kernel boot time by using the | ||
170 | option libata.noacpi=1 | ||
171 | |||
172 | config PATA_ALI | 171 | config PATA_ALI |
173 | tristate "ALi PATA support (Experimental)" | 172 | tristate "ALi PATA support (Experimental)" |
174 | depends on PCI && EXPERIMENTAL | 173 | depends on PCI && EXPERIMENTAL |
@@ -584,6 +583,4 @@ config PATA_SCC | |||
584 | 583 | ||
585 | If unsure, say N. | 584 | If unsure, say N. |
586 | 585 | ||
587 | endif | 586 | endif # ATA |
588 | endmenu | ||
589 | |||
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 6f42a0e2812d..8149c68ac2c7 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
@@ -69,4 +69,4 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic.o | |||
69 | obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o | 69 | obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o |
70 | 70 | ||
71 | libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o | 71 | libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o |
72 | libata-$(CONFIG_SATA_ACPI) += libata-acpi.o | 72 | libata-$(CONFIG_ATA_ACPI) += libata-acpi.o |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index d9617892fc23..1ae443d7ab92 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -250,10 +250,6 @@ static struct scsi_host_template ahci_sht = { | |||
250 | .slave_configure = ata_scsi_slave_config, | 250 | .slave_configure = ata_scsi_slave_config, |
251 | .slave_destroy = ata_scsi_slave_destroy, | 251 | .slave_destroy = ata_scsi_slave_destroy, |
252 | .bios_param = ata_std_bios_param, | 252 | .bios_param = ata_std_bios_param, |
253 | #ifdef CONFIG_PM | ||
254 | .suspend = ata_scsi_device_suspend, | ||
255 | .resume = ata_scsi_device_resume, | ||
256 | #endif | ||
257 | }; | 253 | }; |
258 | 254 | ||
259 | static const struct ata_port_operations ahci_ops = { | 255 | static const struct ata_port_operations ahci_ops = { |
@@ -400,6 +396,7 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
400 | 396 | ||
401 | /* ATI */ | 397 | /* ATI */ |
402 | { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ | 398 | { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ |
399 | { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700 */ | ||
403 | 400 | ||
404 | /* VIA */ | 401 | /* VIA */ |
405 | { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ | 402 | { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ |
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c index 92a491ddd030..c3d753296bc6 100644 --- a/drivers/ata/ata_generic.c +++ b/drivers/ata/ata_generic.c | |||
@@ -54,7 +54,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) | |||
54 | 54 | ||
55 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 55 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
56 | struct ata_device *dev = &ap->device[i]; | 56 | struct ata_device *dev = &ap->device[i]; |
57 | if (ata_dev_ready(dev)) { | 57 | if (ata_dev_enabled(dev)) { |
58 | /* We don't really care */ | 58 | /* We don't really care */ |
59 | dev->pio_mode = XFER_PIO_0; | 59 | dev->pio_mode = XFER_PIO_0; |
60 | dev->dma_mode = XFER_MW_DMA_0; | 60 | dev->dma_mode = XFER_MW_DMA_0; |
@@ -90,10 +90,6 @@ static struct scsi_host_template generic_sht = { | |||
90 | .slave_configure = ata_scsi_slave_config, | 90 | .slave_configure = ata_scsi_slave_config, |
91 | .slave_destroy = ata_scsi_slave_destroy, | 91 | .slave_destroy = ata_scsi_slave_destroy, |
92 | .bios_param = ata_std_bios_param, | 92 | .bios_param = ata_std_bios_param, |
93 | #ifdef CONFIG_PM | ||
94 | .resume = ata_scsi_device_resume, | ||
95 | .suspend = ata_scsi_device_suspend, | ||
96 | #endif | ||
97 | }; | 93 | }; |
98 | 94 | ||
99 | static struct ata_port_operations generic_port_ops = { | 95 | static struct ata_port_operations generic_port_ops = { |
@@ -145,7 +141,7 @@ static int all_generic_ide; /* Set to claim all devices */ | |||
145 | static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 141 | static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
146 | { | 142 | { |
147 | u16 command; | 143 | u16 command; |
148 | static struct ata_port_info info = { | 144 | static const struct ata_port_info info = { |
149 | .sht = &generic_sht, | 145 | .sht = &generic_sht, |
150 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 146 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
151 | .pio_mask = 0x1f, | 147 | .pio_mask = 0x1f, |
@@ -153,7 +149,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id | |||
153 | .udma_mask = 0x3f, | 149 | .udma_mask = 0x3f, |
154 | .port_ops = &generic_port_ops | 150 | .port_ops = &generic_port_ops |
155 | }; | 151 | }; |
156 | static struct ata_port_info *port_info[2] = { &info, &info }; | 152 | const struct ata_port_info *ppi[] = { &info, NULL }; |
157 | 153 | ||
158 | /* Don't use the generic entry unless instructed to do so */ | 154 | /* Don't use the generic entry unless instructed to do so */ |
159 | if (id->driver_data == 1 && all_generic_ide == 0) | 155 | if (id->driver_data == 1 && all_generic_ide == 0) |
@@ -179,7 +175,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id | |||
179 | if (dev->vendor == PCI_VENDOR_ID_AL) | 175 | if (dev->vendor == PCI_VENDOR_ID_AL) |
180 | ata_pci_clear_simplex(dev); | 176 | ata_pci_clear_simplex(dev); |
181 | 177 | ||
182 | return ata_pci_init_one(dev, port_info, 2); | 178 | return ata_pci_init_one(dev, ppi); |
183 | } | 179 | } |
184 | 180 | ||
185 | static struct pci_device_id ata_generic[] = { | 181 | static struct pci_device_id ata_generic[] = { |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 4a795fdb6a02..13b6b1df2ac4 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -275,10 +275,6 @@ static struct scsi_host_template piix_sht = { | |||
275 | .slave_configure = ata_scsi_slave_config, | 275 | .slave_configure = ata_scsi_slave_config, |
276 | .slave_destroy = ata_scsi_slave_destroy, | 276 | .slave_destroy = ata_scsi_slave_destroy, |
277 | .bios_param = ata_std_bios_param, | 277 | .bios_param = ata_std_bios_param, |
278 | #ifdef CONFIG_PM | ||
279 | .resume = ata_scsi_device_resume, | ||
280 | .suspend = ata_scsi_device_suspend, | ||
281 | #endif | ||
282 | }; | 278 | }; |
283 | 279 | ||
284 | static const struct ata_port_operations piix_pata_ops = { | 280 | static const struct ata_port_operations piix_pata_ops = { |
@@ -1034,7 +1030,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1034 | static int printed_version; | 1030 | static int printed_version; |
1035 | struct device *dev = &pdev->dev; | 1031 | struct device *dev = &pdev->dev; |
1036 | struct ata_port_info port_info[2]; | 1032 | struct ata_port_info port_info[2]; |
1037 | struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; | 1033 | const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] }; |
1038 | struct piix_host_priv *hpriv; | 1034 | struct piix_host_priv *hpriv; |
1039 | unsigned long port_flags; | 1035 | unsigned long port_flags; |
1040 | 1036 | ||
@@ -1093,7 +1089,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1093 | port_info[1].mwdma_mask = 0; | 1089 | port_info[1].mwdma_mask = 0; |
1094 | port_info[1].udma_mask = 0; | 1090 | port_info[1].udma_mask = 0; |
1095 | } | 1091 | } |
1096 | return ata_pci_init_one(pdev, ppinfo, 2); | 1092 | return ata_pci_init_one(pdev, ppi); |
1097 | } | 1093 | } |
1098 | 1094 | ||
1099 | static int __init piix_init(void) | 1095 | static int __init piix_init(void) |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index cb3eab6e379d..ed4138e24b0c 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -270,8 +270,7 @@ out: | |||
270 | 270 | ||
271 | /** | 271 | /** |
272 | * do_drive_get_GTF - get the drive bootup default taskfile settings | 272 | * do_drive_get_GTF - get the drive bootup default taskfile settings |
273 | * @ap: the ata_port for the drive | 273 | * @dev: target ATA device |
274 | * @ix: target ata_device (drive) index | ||
275 | * @gtf_length: number of bytes of _GTF data returned at @gtf_address | 274 | * @gtf_length: number of bytes of _GTF data returned at @gtf_address |
276 | * @gtf_address: buffer containing _GTF taskfile arrays | 275 | * @gtf_address: buffer containing _GTF taskfile arrays |
277 | * | 276 | * |
@@ -286,20 +285,19 @@ out: | |||
286 | * The returned @gtf_length and @gtf_address are only valid if the | 285 | * The returned @gtf_length and @gtf_address are only valid if the |
287 | * function return value is 0. | 286 | * function return value is 0. |
288 | */ | 287 | */ |
289 | static int do_drive_get_GTF(struct ata_port *ap, int ix, | 288 | static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, |
290 | unsigned int *gtf_length, unsigned long *gtf_address, | 289 | unsigned long *gtf_address, unsigned long *obj_loc) |
291 | unsigned long *obj_loc) | ||
292 | { | 290 | { |
293 | acpi_status status; | 291 | struct ata_port *ap = dev->ap; |
294 | acpi_handle dev_handle = NULL; | 292 | acpi_status status; |
295 | acpi_handle chan_handle, drive_handle; | 293 | acpi_handle dev_handle = NULL; |
296 | acpi_integer pcidevfn = 0; | 294 | acpi_handle chan_handle, drive_handle; |
297 | u32 dev_adr; | 295 | acpi_integer pcidevfn = 0; |
298 | struct acpi_buffer output; | 296 | u32 dev_adr; |
299 | union acpi_object *out_obj; | 297 | struct acpi_buffer output; |
300 | struct device *dev = ap->host->dev; | 298 | union acpi_object *out_obj; |
301 | struct ata_device *atadev = &ap->device[ix]; | 299 | struct device *gdev = ap->host->dev; |
302 | int err = -ENODEV; | 300 | int err = -ENODEV; |
303 | 301 | ||
304 | *gtf_length = 0; | 302 | *gtf_length = 0; |
305 | *gtf_address = 0UL; | 303 | *gtf_address = 0UL; |
@@ -309,14 +307,14 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
309 | return 0; | 307 | return 0; |
310 | 308 | ||
311 | if (ata_msg_probe(ap)) | 309 | if (ata_msg_probe(ap)) |
312 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", | 310 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", |
313 | __FUNCTION__, ap->port_no); | 311 | __FUNCTION__, ap->port_no); |
314 | 312 | ||
315 | if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) { | 313 | if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) { |
316 | if (ata_msg_probe(ap)) | 314 | if (ata_msg_probe(ap)) |
317 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ERR: " | 315 | ata_dev_printk(dev, KERN_DEBUG, "%s: ERR: " |
318 | "ata_dev_present: %d, PORT_DISABLED: %lu\n", | 316 | "ata_dev_present: %d, PORT_DISABLED: %lu\n", |
319 | __FUNCTION__, ata_dev_enabled(atadev), | 317 | __FUNCTION__, ata_dev_enabled(dev), |
320 | ap->flags & ATA_FLAG_DISABLED); | 318 | ap->flags & ATA_FLAG_DISABLED); |
321 | goto out; | 319 | goto out; |
322 | } | 320 | } |
@@ -324,19 +322,19 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
324 | /* Don't continue if device has no _ADR method. | 322 | /* Don't continue if device has no _ADR method. |
325 | * _GTF is intended for known motherboard devices. */ | 323 | * _GTF is intended for known motherboard devices. */ |
326 | if (!(ap->cbl == ATA_CBL_SATA)) { | 324 | if (!(ap->cbl == ATA_CBL_SATA)) { |
327 | err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn); | 325 | err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn); |
328 | if (err < 0) { | 326 | if (err < 0) { |
329 | if (ata_msg_probe(ap)) | 327 | if (ata_msg_probe(ap)) |
330 | ata_dev_printk(atadev, KERN_DEBUG, | 328 | ata_dev_printk(dev, KERN_DEBUG, |
331 | "%s: pata_get_dev_handle failed (%d)\n", | 329 | "%s: pata_get_dev_handle failed (%d)\n", |
332 | __FUNCTION__, err); | 330 | __FUNCTION__, err); |
333 | goto out; | 331 | goto out; |
334 | } | 332 | } |
335 | } else { | 333 | } else { |
336 | err = sata_get_dev_handle(dev, &dev_handle, &pcidevfn); | 334 | err = sata_get_dev_handle(gdev, &dev_handle, &pcidevfn); |
337 | if (err < 0) { | 335 | if (err < 0) { |
338 | if (ata_msg_probe(ap)) | 336 | if (ata_msg_probe(ap)) |
339 | ata_dev_printk(atadev, KERN_DEBUG, | 337 | ata_dev_printk(dev, KERN_DEBUG, |
340 | "%s: sata_get_dev_handle failed (%d\n", | 338 | "%s: sata_get_dev_handle failed (%d\n", |
341 | __FUNCTION__, err); | 339 | __FUNCTION__, err); |
342 | goto out; | 340 | goto out; |
@@ -344,7 +342,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
344 | } | 342 | } |
345 | 343 | ||
346 | /* Get this drive's _ADR info. if not already known. */ | 344 | /* Get this drive's _ADR info. if not already known. */ |
347 | if (!atadev->obj_handle) { | 345 | if (!dev->obj_handle) { |
348 | if (!(ap->cbl == ATA_CBL_SATA)) { | 346 | if (!(ap->cbl == ATA_CBL_SATA)) { |
349 | /* get child objects of dev_handle == channel objects, | 347 | /* get child objects of dev_handle == channel objects, |
350 | * + _their_ children == drive objects */ | 348 | * + _their_ children == drive objects */ |
@@ -352,7 +350,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
352 | chan_handle = acpi_get_child(dev_handle, | 350 | chan_handle = acpi_get_child(dev_handle, |
353 | ap->port_no); | 351 | ap->port_no); |
354 | if (ata_msg_probe(ap)) | 352 | if (ata_msg_probe(ap)) |
355 | ata_dev_printk(atadev, KERN_DEBUG, | 353 | ata_dev_printk(dev, KERN_DEBUG, |
356 | "%s: chan adr=%d: chan_handle=0x%p\n", | 354 | "%s: chan adr=%d: chan_handle=0x%p\n", |
357 | __FUNCTION__, ap->port_no, | 355 | __FUNCTION__, ap->port_no, |
358 | chan_handle); | 356 | chan_handle); |
@@ -361,26 +359,26 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
361 | goto out; | 359 | goto out; |
362 | } | 360 | } |
363 | /* TBD: could also check ACPI object VALID bits */ | 361 | /* TBD: could also check ACPI object VALID bits */ |
364 | drive_handle = acpi_get_child(chan_handle, ix); | 362 | drive_handle = acpi_get_child(chan_handle, dev->devno); |
365 | if (!drive_handle) { | 363 | if (!drive_handle) { |
366 | err = -ENODEV; | 364 | err = -ENODEV; |
367 | goto out; | 365 | goto out; |
368 | } | 366 | } |
369 | dev_adr = ix; | 367 | dev_adr = dev->devno; |
370 | atadev->obj_handle = drive_handle; | 368 | dev->obj_handle = drive_handle; |
371 | } else { /* for SATA mode */ | 369 | } else { /* for SATA mode */ |
372 | dev_adr = SATA_ADR_RSVD; | 370 | dev_adr = SATA_ADR_RSVD; |
373 | err = get_sata_adr(dev, dev_handle, pcidevfn, 0, | 371 | err = get_sata_adr(gdev, dev_handle, pcidevfn, 0, |
374 | ap, atadev, &dev_adr); | 372 | ap, dev, &dev_adr); |
375 | } | 373 | } |
376 | if (err < 0 || dev_adr == SATA_ADR_RSVD || | 374 | if (err < 0 || dev_adr == SATA_ADR_RSVD || |
377 | !atadev->obj_handle) { | 375 | !dev->obj_handle) { |
378 | if (ata_msg_probe(ap)) | 376 | if (ata_msg_probe(ap)) |
379 | ata_dev_printk(atadev, KERN_DEBUG, | 377 | ata_dev_printk(dev, KERN_DEBUG, |
380 | "%s: get_sata/pata_adr failed: " | 378 | "%s: get_sata/pata_adr failed: " |
381 | "err=%d, dev_adr=%u, obj_handle=0x%p\n", | 379 | "err=%d, dev_adr=%u, obj_handle=0x%p\n", |
382 | __FUNCTION__, err, dev_adr, | 380 | __FUNCTION__, err, dev_adr, |
383 | atadev->obj_handle); | 381 | dev->obj_handle); |
384 | goto out; | 382 | goto out; |
385 | } | 383 | } |
386 | } | 384 | } |
@@ -391,11 +389,11 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
391 | 389 | ||
392 | /* _GTF has no input parameters */ | 390 | /* _GTF has no input parameters */ |
393 | err = -EIO; | 391 | err = -EIO; |
394 | status = acpi_evaluate_object(atadev->obj_handle, "_GTF", | 392 | status = acpi_evaluate_object(dev->obj_handle, "_GTF", |
395 | NULL, &output); | 393 | NULL, &output); |
396 | if (ACPI_FAILURE(status)) { | 394 | if (ACPI_FAILURE(status)) { |
397 | if (ata_msg_probe(ap)) | 395 | if (ata_msg_probe(ap)) |
398 | ata_dev_printk(atadev, KERN_DEBUG, | 396 | ata_dev_printk(dev, KERN_DEBUG, |
399 | "%s: Run _GTF error: status = 0x%x\n", | 397 | "%s: Run _GTF error: status = 0x%x\n", |
400 | __FUNCTION__, status); | 398 | __FUNCTION__, status); |
401 | goto out; | 399 | goto out; |
@@ -403,7 +401,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
403 | 401 | ||
404 | if (!output.length || !output.pointer) { | 402 | if (!output.length || !output.pointer) { |
405 | if (ata_msg_probe(ap)) | 403 | if (ata_msg_probe(ap)) |
406 | ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " | 404 | ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " |
407 | "length or ptr is NULL (0x%llx, 0x%p)\n", | 405 | "length or ptr is NULL (0x%llx, 0x%p)\n", |
408 | __FUNCTION__, | 406 | __FUNCTION__, |
409 | (unsigned long long)output.length, | 407 | (unsigned long long)output.length, |
@@ -416,7 +414,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
416 | if (out_obj->type != ACPI_TYPE_BUFFER) { | 414 | if (out_obj->type != ACPI_TYPE_BUFFER) { |
417 | kfree(output.pointer); | 415 | kfree(output.pointer); |
418 | if (ata_msg_probe(ap)) | 416 | if (ata_msg_probe(ap)) |
419 | ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " | 417 | ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " |
420 | "error: expected object type of " | 418 | "error: expected object type of " |
421 | " ACPI_TYPE_BUFFER, got 0x%x\n", | 419 | " ACPI_TYPE_BUFFER, got 0x%x\n", |
422 | __FUNCTION__, out_obj->type); | 420 | __FUNCTION__, out_obj->type); |
@@ -427,7 +425,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
427 | if (!out_obj->buffer.length || !out_obj->buffer.pointer || | 425 | if (!out_obj->buffer.length || !out_obj->buffer.pointer || |
428 | out_obj->buffer.length % REGS_PER_GTF) { | 426 | out_obj->buffer.length % REGS_PER_GTF) { |
429 | if (ata_msg_drv(ap)) | 427 | if (ata_msg_drv(ap)) |
430 | ata_dev_printk(atadev, KERN_ERR, | 428 | ata_dev_printk(dev, KERN_ERR, |
431 | "%s: unexpected GTF length (%d) or addr (0x%p)\n", | 429 | "%s: unexpected GTF length (%d) or addr (0x%p)\n", |
432 | __FUNCTION__, out_obj->buffer.length, | 430 | __FUNCTION__, out_obj->buffer.length, |
433 | out_obj->buffer.pointer); | 431 | out_obj->buffer.pointer); |
@@ -439,7 +437,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
439 | *gtf_address = (unsigned long)out_obj->buffer.pointer; | 437 | *gtf_address = (unsigned long)out_obj->buffer.pointer; |
440 | *obj_loc = (unsigned long)out_obj; | 438 | *obj_loc = (unsigned long)out_obj; |
441 | if (ata_msg_probe(ap)) | 439 | if (ata_msg_probe(ap)) |
442 | ata_dev_printk(atadev, KERN_DEBUG, "%s: returning " | 440 | ata_dev_printk(dev, KERN_DEBUG, "%s: returning " |
443 | "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", | 441 | "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", |
444 | __FUNCTION__, *gtf_length, *gtf_address, *obj_loc); | 442 | __FUNCTION__, *gtf_length, *gtf_address, *obj_loc); |
445 | err = 0; | 443 | err = 0; |
@@ -449,7 +447,7 @@ out: | |||
449 | 447 | ||
450 | /** | 448 | /** |
451 | * taskfile_load_raw - send taskfile registers to host controller | 449 | * taskfile_load_raw - send taskfile registers to host controller |
452 | * @ap: Port to which output is sent | 450 | * @dev: target ATA device |
453 | * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) | 451 | * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) |
454 | * | 452 | * |
455 | * Outputs ATA taskfile to standard ATA host controller using MMIO | 453 | * Outputs ATA taskfile to standard ATA host controller using MMIO |
@@ -466,15 +464,15 @@ out: | |||
466 | * LOCKING: TBD: | 464 | * LOCKING: TBD: |
467 | * Inherited from caller. | 465 | * Inherited from caller. |
468 | */ | 466 | */ |
469 | static void taskfile_load_raw(struct ata_port *ap, | 467 | static void taskfile_load_raw(struct ata_device *dev, |
470 | struct ata_device *atadev, | 468 | const struct taskfile_array *gtf) |
471 | const struct taskfile_array *gtf) | ||
472 | { | 469 | { |
470 | struct ata_port *ap = dev->ap; | ||
473 | struct ata_taskfile tf; | 471 | struct ata_taskfile tf; |
474 | unsigned int err; | 472 | unsigned int err; |
475 | 473 | ||
476 | if (ata_msg_probe(ap)) | 474 | if (ata_msg_probe(ap)) |
477 | ata_dev_printk(atadev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " | 475 | ata_dev_printk(dev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " |
478 | "%02x %02x %02x %02x %02x %02x %02x\n", | 476 | "%02x %02x %02x %02x %02x %02x %02x\n", |
479 | __FUNCTION__, | 477 | __FUNCTION__, |
480 | gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], | 478 | gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], |
@@ -485,7 +483,7 @@ static void taskfile_load_raw(struct ata_port *ap, | |||
485 | && (gtf->tfa[6] == 0)) | 483 | && (gtf->tfa[6] == 0)) |
486 | return; | 484 | return; |
487 | 485 | ||
488 | ata_tf_init(atadev, &tf); | 486 | ata_tf_init(dev, &tf); |
489 | 487 | ||
490 | /* convert gtf to tf */ | 488 | /* convert gtf to tf */ |
491 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ | 489 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ |
@@ -498,17 +496,16 @@ static void taskfile_load_raw(struct ata_port *ap, | |||
498 | tf.device = gtf->tfa[5]; /* 0x1f6 */ | 496 | tf.device = gtf->tfa[5]; /* 0x1f6 */ |
499 | tf.command = gtf->tfa[6]; /* 0x1f7 */ | 497 | tf.command = gtf->tfa[6]; /* 0x1f7 */ |
500 | 498 | ||
501 | err = ata_exec_internal(atadev, &tf, NULL, DMA_NONE, NULL, 0); | 499 | err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); |
502 | if (err && ata_msg_probe(ap)) | 500 | if (err && ata_msg_probe(ap)) |
503 | ata_dev_printk(atadev, KERN_ERR, | 501 | ata_dev_printk(dev, KERN_ERR, |
504 | "%s: ata_exec_internal failed: %u\n", | 502 | "%s: ata_exec_internal failed: %u\n", |
505 | __FUNCTION__, err); | 503 | __FUNCTION__, err); |
506 | } | 504 | } |
507 | 505 | ||
508 | /** | 506 | /** |
509 | * do_drive_set_taskfiles - write the drive taskfile settings from _GTF | 507 | * do_drive_set_taskfiles - write the drive taskfile settings from _GTF |
510 | * @ap: the ata_port for the drive | 508 | * @dev: target ATA device |
511 | * @atadev: target ata_device | ||
512 | * @gtf_length: total number of bytes of _GTF taskfiles | 509 | * @gtf_length: total number of bytes of _GTF taskfiles |
513 | * @gtf_address: location of _GTF taskfile arrays | 510 | * @gtf_address: location of _GTF taskfile arrays |
514 | * | 511 | * |
@@ -517,30 +514,31 @@ static void taskfile_load_raw(struct ata_port *ap, | |||
517 | * Write {gtf_address, length gtf_length} in groups of | 514 | * Write {gtf_address, length gtf_length} in groups of |
518 | * REGS_PER_GTF bytes. | 515 | * REGS_PER_GTF bytes. |
519 | */ | 516 | */ |
520 | static int do_drive_set_taskfiles(struct ata_port *ap, | 517 | static int do_drive_set_taskfiles(struct ata_device *dev, |
521 | struct ata_device *atadev, unsigned int gtf_length, | 518 | unsigned int gtf_length, |
522 | unsigned long gtf_address) | 519 | unsigned long gtf_address) |
523 | { | 520 | { |
524 | int err = -ENODEV; | 521 | struct ata_port *ap = dev->ap; |
525 | int gtf_count = gtf_length / REGS_PER_GTF; | 522 | int err = -ENODEV; |
526 | int ix; | 523 | int gtf_count = gtf_length / REGS_PER_GTF; |
524 | int ix; | ||
527 | struct taskfile_array *gtf; | 525 | struct taskfile_array *gtf; |
528 | 526 | ||
529 | if (ata_msg_probe(ap)) | 527 | if (ata_msg_probe(ap)) |
530 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", | 528 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", |
531 | __FUNCTION__, ap->port_no); | 529 | __FUNCTION__, ap->port_no); |
532 | 530 | ||
533 | if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) | 531 | if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) |
534 | return 0; | 532 | return 0; |
535 | 533 | ||
536 | if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) | 534 | if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) |
537 | goto out; | 535 | goto out; |
538 | if (!gtf_count) /* shouldn't be here */ | 536 | if (!gtf_count) /* shouldn't be here */ |
539 | goto out; | 537 | goto out; |
540 | 538 | ||
541 | if (gtf_length % REGS_PER_GTF) { | 539 | if (gtf_length % REGS_PER_GTF) { |
542 | if (ata_msg_drv(ap)) | 540 | if (ata_msg_drv(ap)) |
543 | ata_dev_printk(atadev, KERN_ERR, | 541 | ata_dev_printk(dev, KERN_ERR, |
544 | "%s: unexpected GTF length (%d)\n", | 542 | "%s: unexpected GTF length (%d)\n", |
545 | __FUNCTION__, gtf_length); | 543 | __FUNCTION__, gtf_length); |
546 | goto out; | 544 | goto out; |
@@ -551,7 +549,7 @@ static int do_drive_set_taskfiles(struct ata_port *ap, | |||
551 | (gtf_address + ix * REGS_PER_GTF); | 549 | (gtf_address + ix * REGS_PER_GTF); |
552 | 550 | ||
553 | /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ | 551 | /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ |
554 | taskfile_load_raw(ap, atadev, gtf); | 552 | taskfile_load_raw(dev, gtf); |
555 | } | 553 | } |
556 | 554 | ||
557 | err = 0; | 555 | err = 0; |
@@ -567,11 +565,11 @@ out: | |||
567 | */ | 565 | */ |
568 | int ata_acpi_exec_tfs(struct ata_port *ap) | 566 | int ata_acpi_exec_tfs(struct ata_port *ap) |
569 | { | 567 | { |
570 | int ix; | 568 | int ix; |
571 | int ret =0; | 569 | int ret = 0; |
572 | unsigned int gtf_length; | 570 | unsigned int gtf_length; |
573 | unsigned long gtf_address; | 571 | unsigned long gtf_address; |
574 | unsigned long obj_loc; | 572 | unsigned long obj_loc; |
575 | 573 | ||
576 | if (libata_noacpi) | 574 | if (libata_noacpi) |
577 | return 0; | 575 | return 0; |
@@ -584,11 +582,13 @@ int ata_acpi_exec_tfs(struct ata_port *ap) | |||
584 | return 0; | 582 | return 0; |
585 | 583 | ||
586 | for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { | 584 | for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { |
587 | if (!ata_dev_enabled(&ap->device[ix])) | 585 | struct ata_device *dev = &ap->device[ix]; |
586 | |||
587 | if (!ata_dev_enabled(dev)) | ||
588 | continue; | 588 | continue; |
589 | 589 | ||
590 | ret = do_drive_get_GTF(ap, ix, | 590 | ret = do_drive_get_GTF(dev, >f_length, >f_address, |
591 | >f_length, >f_address, &obj_loc); | 591 | &obj_loc); |
592 | if (ret < 0) { | 592 | if (ret < 0) { |
593 | if (ata_msg_probe(ap)) | 593 | if (ata_msg_probe(ap)) |
594 | ata_port_printk(ap, KERN_DEBUG, | 594 | ata_port_printk(ap, KERN_DEBUG, |
@@ -597,8 +597,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap) | |||
597 | break; | 597 | break; |
598 | } | 598 | } |
599 | 599 | ||
600 | ret = do_drive_set_taskfiles(ap, &ap->device[ix], | 600 | ret = do_drive_set_taskfiles(dev, gtf_length, gtf_address); |
601 | gtf_length, gtf_address); | ||
602 | kfree((void *)obj_loc); | 601 | kfree((void *)obj_loc); |
603 | if (ret < 0) { | 602 | if (ret < 0) { |
604 | if (ata_msg_probe(ap)) | 603 | if (ata_msg_probe(ap)) |
@@ -614,8 +613,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap) | |||
614 | 613 | ||
615 | /** | 614 | /** |
616 | * ata_acpi_push_id - send Identify data to drive | 615 | * ata_acpi_push_id - send Identify data to drive |
617 | * @ap: the ata_port for the drive | 616 | * @dev: target ATA device |
618 | * @ix: drive index | ||
619 | * | 617 | * |
620 | * _SDD ACPI object: for SATA mode only | 618 | * _SDD ACPI object: for SATA mode only |
621 | * Must be after Identify (Packet) Device -- uses its data | 619 | * Must be after Identify (Packet) Device -- uses its data |
@@ -623,57 +621,57 @@ int ata_acpi_exec_tfs(struct ata_port *ap) | |||
623 | * method and if it fails for whatever reason, we should still | 621 | * method and if it fails for whatever reason, we should still |
624 | * just keep going. | 622 | * just keep going. |
625 | */ | 623 | */ |
626 | int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) | 624 | int ata_acpi_push_id(struct ata_device *dev) |
627 | { | 625 | { |
628 | acpi_handle handle; | 626 | struct ata_port *ap = dev->ap; |
629 | acpi_integer pcidevfn; | 627 | acpi_handle handle; |
630 | int err; | 628 | acpi_integer pcidevfn; |
631 | struct device *dev = ap->host->dev; | 629 | int err; |
632 | struct ata_device *atadev = &ap->device[ix]; | 630 | struct device *gdev = ap->host->dev; |
633 | u32 dev_adr; | 631 | u32 dev_adr; |
634 | acpi_status status; | 632 | acpi_status status; |
635 | struct acpi_object_list input; | 633 | struct acpi_object_list input; |
636 | union acpi_object in_params[1]; | 634 | union acpi_object in_params[1]; |
637 | 635 | ||
638 | if (libata_noacpi) | 636 | if (libata_noacpi) |
639 | return 0; | 637 | return 0; |
640 | 638 | ||
641 | if (ata_msg_probe(ap)) | 639 | if (ata_msg_probe(ap)) |
642 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", | 640 | ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", |
643 | __FUNCTION__, ix, ap->port_no); | 641 | __FUNCTION__, dev->devno, ap->port_no); |
644 | 642 | ||
645 | /* Don't continue if not a SATA device. */ | 643 | /* Don't continue if not a SATA device. */ |
646 | if (!(ap->cbl == ATA_CBL_SATA)) { | 644 | if (!(ap->cbl == ATA_CBL_SATA)) { |
647 | if (ata_msg_probe(ap)) | 645 | if (ata_msg_probe(ap)) |
648 | ata_dev_printk(atadev, KERN_DEBUG, | 646 | ata_dev_printk(dev, KERN_DEBUG, |
649 | "%s: Not a SATA device\n", __FUNCTION__); | 647 | "%s: Not a SATA device\n", __FUNCTION__); |
650 | goto out; | 648 | goto out; |
651 | } | 649 | } |
652 | 650 | ||
653 | /* Don't continue if device has no _ADR method. | 651 | /* Don't continue if device has no _ADR method. |
654 | * _SDD is intended for known motherboard devices. */ | 652 | * _SDD is intended for known motherboard devices. */ |
655 | err = sata_get_dev_handle(dev, &handle, &pcidevfn); | 653 | err = sata_get_dev_handle(gdev, &handle, &pcidevfn); |
656 | if (err < 0) { | 654 | if (err < 0) { |
657 | if (ata_msg_probe(ap)) | 655 | if (ata_msg_probe(ap)) |
658 | ata_dev_printk(atadev, KERN_DEBUG, | 656 | ata_dev_printk(dev, KERN_DEBUG, |
659 | "%s: sata_get_dev_handle failed (%d\n", | 657 | "%s: sata_get_dev_handle failed (%d\n", |
660 | __FUNCTION__, err); | 658 | __FUNCTION__, err); |
661 | goto out; | 659 | goto out; |
662 | } | 660 | } |
663 | 661 | ||
664 | /* Get this drive's _ADR info, if not already known */ | 662 | /* Get this drive's _ADR info, if not already known */ |
665 | if (!atadev->obj_handle) { | 663 | if (!dev->obj_handle) { |
666 | dev_adr = SATA_ADR_RSVD; | 664 | dev_adr = SATA_ADR_RSVD; |
667 | err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev, | 665 | err = get_sata_adr(gdev, handle, pcidevfn, dev->devno, ap, dev, |
668 | &dev_adr); | 666 | &dev_adr); |
669 | if (err < 0 || dev_adr == SATA_ADR_RSVD || | 667 | if (err < 0 || dev_adr == SATA_ADR_RSVD || |
670 | !atadev->obj_handle) { | 668 | !dev->obj_handle) { |
671 | if (ata_msg_probe(ap)) | 669 | if (ata_msg_probe(ap)) |
672 | ata_dev_printk(atadev, KERN_DEBUG, | 670 | ata_dev_printk(dev, KERN_DEBUG, |
673 | "%s: get_sata_adr failed: " | 671 | "%s: get_sata_adr failed: " |
674 | "err=%d, dev_adr=%u, obj_handle=0x%p\n", | 672 | "err=%d, dev_adr=%u, obj_handle=0x%p\n", |
675 | __FUNCTION__, err, dev_adr, | 673 | __FUNCTION__, err, dev_adr, |
676 | atadev->obj_handle); | 674 | dev->obj_handle); |
677 | goto out; | 675 | goto out; |
678 | } | 676 | } |
679 | } | 677 | } |
@@ -683,19 +681,19 @@ int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) | |||
683 | input.count = 1; | 681 | input.count = 1; |
684 | input.pointer = in_params; | 682 | input.pointer = in_params; |
685 | in_params[0].type = ACPI_TYPE_BUFFER; | 683 | in_params[0].type = ACPI_TYPE_BUFFER; |
686 | in_params[0].buffer.length = sizeof(atadev->id[0]) * ATA_ID_WORDS; | 684 | in_params[0].buffer.length = sizeof(dev->id[0]) * ATA_ID_WORDS; |
687 | in_params[0].buffer.pointer = (u8 *)atadev->id; | 685 | in_params[0].buffer.pointer = (u8 *)dev->id; |
688 | /* Output buffer: _SDD has no output */ | 686 | /* Output buffer: _SDD has no output */ |
689 | 687 | ||
690 | /* It's OK for _SDD to be missing too. */ | 688 | /* It's OK for _SDD to be missing too. */ |
691 | swap_buf_le16(atadev->id, ATA_ID_WORDS); | 689 | swap_buf_le16(dev->id, ATA_ID_WORDS); |
692 | status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL); | 690 | status = acpi_evaluate_object(dev->obj_handle, "_SDD", &input, NULL); |
693 | swap_buf_le16(atadev->id, ATA_ID_WORDS); | 691 | swap_buf_le16(dev->id, ATA_ID_WORDS); |
694 | 692 | ||
695 | err = ACPI_FAILURE(status) ? -EIO : 0; | 693 | err = ACPI_FAILURE(status) ? -EIO : 0; |
696 | if (err < 0) { | 694 | if (err < 0) { |
697 | if (ata_msg_probe(ap)) | 695 | if (ata_msg_probe(ap)) |
698 | ata_dev_printk(atadev, KERN_DEBUG, | 696 | ata_dev_printk(dev, KERN_DEBUG, |
699 | "%s _SDD error: status = 0x%x\n", | 697 | "%s _SDD error: status = 0x%x\n", |
700 | __FUNCTION__, status); | 698 | __FUNCTION__, status); |
701 | } | 699 | } |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4595d1f8cf60..4166407eb47c 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -101,6 +101,12 @@ int libata_noacpi = 1; | |||
101 | module_param_named(noacpi, libata_noacpi, int, 0444); | 101 | module_param_named(noacpi, libata_noacpi, int, 0444); |
102 | MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); | 102 | MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); |
103 | 103 | ||
104 | int ata_spindown_compat = 1; | ||
105 | module_param_named(spindown_compat, ata_spindown_compat, int, 0644); | ||
106 | MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown " | ||
107 | "behavior. Will be removed. More info can be found in " | ||
108 | "Documentation/feature-removal-schedule.txt\n"); | ||
109 | |||
104 | MODULE_AUTHOR("Jeff Garzik"); | 110 | MODULE_AUTHOR("Jeff Garzik"); |
105 | MODULE_DESCRIPTION("Library module for ATA devices"); | 111 | MODULE_DESCRIPTION("Library module for ATA devices"); |
106 | MODULE_LICENSE("GPL"); | 112 | MODULE_LICENSE("GPL"); |
@@ -1654,7 +1660,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1654 | struct ata_taskfile tf; | 1660 | struct ata_taskfile tf; |
1655 | unsigned int err_mask = 0; | 1661 | unsigned int err_mask = 0; |
1656 | const char *reason; | 1662 | const char *reason; |
1657 | int tried_spinup = 0; | 1663 | int may_fallback = 1, tried_spinup = 0; |
1658 | int rc; | 1664 | int rc; |
1659 | 1665 | ||
1660 | if (ata_msg_ctl(ap)) | 1666 | if (ata_msg_ctl(ap)) |
@@ -1698,11 +1704,31 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1698 | return -ENOENT; | 1704 | return -ENOENT; |
1699 | } | 1705 | } |
1700 | 1706 | ||
1707 | /* Device or controller might have reported the wrong | ||
1708 | * device class. Give a shot at the other IDENTIFY if | ||
1709 | * the current one is aborted by the device. | ||
1710 | */ | ||
1711 | if (may_fallback && | ||
1712 | (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { | ||
1713 | may_fallback = 0; | ||
1714 | |||
1715 | if (class == ATA_DEV_ATA) | ||
1716 | class = ATA_DEV_ATAPI; | ||
1717 | else | ||
1718 | class = ATA_DEV_ATA; | ||
1719 | goto retry; | ||
1720 | } | ||
1721 | |||
1701 | rc = -EIO; | 1722 | rc = -EIO; |
1702 | reason = "I/O error"; | 1723 | reason = "I/O error"; |
1703 | goto err_out; | 1724 | goto err_out; |
1704 | } | 1725 | } |
1705 | 1726 | ||
1727 | /* Falling back doesn't make sense if ID data was read | ||
1728 | * successfully at least once. | ||
1729 | */ | ||
1730 | may_fallback = 0; | ||
1731 | |||
1706 | swap_buf_le16(id, ATA_ID_WORDS); | 1732 | swap_buf_le16(id, ATA_ID_WORDS); |
1707 | 1733 | ||
1708 | /* sanity check */ | 1734 | /* sanity check */ |
@@ -1843,7 +1869,7 @@ int ata_dev_configure(struct ata_device *dev) | |||
1843 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); | 1869 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); |
1844 | 1870 | ||
1845 | /* set _SDD */ | 1871 | /* set _SDD */ |
1846 | rc = ata_acpi_push_id(ap, dev->devno); | 1872 | rc = ata_acpi_push_id(dev); |
1847 | if (rc) { | 1873 | if (rc) { |
1848 | ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n", | 1874 | ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n", |
1849 | rc); | 1875 | rc); |
@@ -2860,7 +2886,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2860 | dev = &ap->device[i]; | 2886 | dev = &ap->device[i]; |
2861 | 2887 | ||
2862 | /* don't update suspended devices' xfer mode */ | 2888 | /* don't update suspended devices' xfer mode */ |
2863 | if (!ata_dev_ready(dev)) | 2889 | if (!ata_dev_enabled(dev)) |
2864 | continue; | 2890 | continue; |
2865 | 2891 | ||
2866 | rc = ata_dev_set_mode(dev); | 2892 | rc = ata_dev_set_mode(dev); |
@@ -5845,37 +5871,11 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg, | |||
5845 | */ | 5871 | */ |
5846 | int ata_host_suspend(struct ata_host *host, pm_message_t mesg) | 5872 | int ata_host_suspend(struct ata_host *host, pm_message_t mesg) |
5847 | { | 5873 | { |
5848 | int i, j, rc; | 5874 | int rc; |
5849 | 5875 | ||
5850 | rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); | 5876 | rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); |
5851 | if (rc) | 5877 | if (rc == 0) |
5852 | goto fail; | 5878 | host->dev->power.power_state = mesg; |
5853 | |||
5854 | /* EH is quiescent now. Fail if we have any ready device. | ||
5855 | * This happens if hotplug occurs between completion of device | ||
5856 | * suspension and here. | ||
5857 | */ | ||
5858 | for (i = 0; i < host->n_ports; i++) { | ||
5859 | struct ata_port *ap = host->ports[i]; | ||
5860 | |||
5861 | for (j = 0; j < ATA_MAX_DEVICES; j++) { | ||
5862 | struct ata_device *dev = &ap->device[j]; | ||
5863 | |||
5864 | if (ata_dev_ready(dev)) { | ||
5865 | ata_port_printk(ap, KERN_WARNING, | ||
5866 | "suspend failed, device %d " | ||
5867 | "still active\n", dev->devno); | ||
5868 | rc = -EBUSY; | ||
5869 | goto fail; | ||
5870 | } | ||
5871 | } | ||
5872 | } | ||
5873 | |||
5874 | host->dev->power.power_state = mesg; | ||
5875 | return 0; | ||
5876 | |||
5877 | fail: | ||
5878 | ata_host_resume(host); | ||
5879 | return rc; | 5879 | return rc; |
5880 | } | 5880 | } |
5881 | 5881 | ||
@@ -5984,6 +5984,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
5984 | if (!ap) | 5984 | if (!ap) |
5985 | return NULL; | 5985 | return NULL; |
5986 | 5986 | ||
5987 | ap->pflags |= ATA_PFLAG_INITIALIZING; | ||
5987 | ap->lock = &host->lock; | 5988 | ap->lock = &host->lock; |
5988 | ap->flags = ATA_FLAG_DISABLED; | 5989 | ap->flags = ATA_FLAG_DISABLED; |
5989 | ap->print_id = -1; | 5990 | ap->print_id = -1; |
@@ -6352,6 +6353,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6352 | ehi->action |= ATA_EH_SOFTRESET; | 6353 | ehi->action |= ATA_EH_SOFTRESET; |
6353 | ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; | 6354 | ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; |
6354 | 6355 | ||
6356 | ap->pflags &= ~ATA_PFLAG_INITIALIZING; | ||
6355 | ap->pflags |= ATA_PFLAG_LOADING; | 6357 | ap->pflags |= ATA_PFLAG_LOADING; |
6356 | ata_port_schedule_eh(ap); | 6358 | ata_port_schedule_eh(ap); |
6357 | 6359 | ||
@@ -6876,6 +6878,7 @@ EXPORT_SYMBOL_GPL(ata_timing_merge); | |||
6876 | #ifdef CONFIG_PCI | 6878 | #ifdef CONFIG_PCI |
6877 | EXPORT_SYMBOL_GPL(pci_test_config_bits); | 6879 | EXPORT_SYMBOL_GPL(pci_test_config_bits); |
6878 | EXPORT_SYMBOL_GPL(ata_pci_init_native_host); | 6880 | EXPORT_SYMBOL_GPL(ata_pci_init_native_host); |
6881 | EXPORT_SYMBOL_GPL(ata_pci_init_bmdma); | ||
6879 | EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host); | 6882 | EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host); |
6880 | EXPORT_SYMBOL_GPL(ata_pci_init_one); | 6883 | EXPORT_SYMBOL_GPL(ata_pci_init_one); |
6881 | EXPORT_SYMBOL_GPL(ata_pci_remove_one); | 6884 | EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
@@ -6889,11 +6892,6 @@ EXPORT_SYMBOL_GPL(ata_pci_default_filter); | |||
6889 | EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); | 6892 | EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); |
6890 | #endif /* CONFIG_PCI */ | 6893 | #endif /* CONFIG_PCI */ |
6891 | 6894 | ||
6892 | #ifdef CONFIG_PM | ||
6893 | EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); | ||
6894 | EXPORT_SYMBOL_GPL(ata_scsi_device_resume); | ||
6895 | #endif /* CONFIG_PM */ | ||
6896 | |||
6897 | EXPORT_SYMBOL_GPL(ata_eng_timeout); | 6895 | EXPORT_SYMBOL_GPL(ata_eng_timeout); |
6898 | EXPORT_SYMBOL_GPL(ata_port_schedule_eh); | 6896 | EXPORT_SYMBOL_GPL(ata_port_schedule_eh); |
6899 | EXPORT_SYMBOL_GPL(ata_port_abort); | 6897 | EXPORT_SYMBOL_GPL(ata_port_abort); |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 8256655ce7d9..5309c312f517 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -77,29 +77,12 @@ static void ata_eh_finish(struct ata_port *ap); | |||
77 | #ifdef CONFIG_PM | 77 | #ifdef CONFIG_PM |
78 | static void ata_eh_handle_port_suspend(struct ata_port *ap); | 78 | static void ata_eh_handle_port_suspend(struct ata_port *ap); |
79 | static void ata_eh_handle_port_resume(struct ata_port *ap); | 79 | static void ata_eh_handle_port_resume(struct ata_port *ap); |
80 | static int ata_eh_suspend(struct ata_port *ap, | ||
81 | struct ata_device **r_failed_dev); | ||
82 | static void ata_eh_prep_resume(struct ata_port *ap); | ||
83 | static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev); | ||
84 | #else /* CONFIG_PM */ | 80 | #else /* CONFIG_PM */ |
85 | static void ata_eh_handle_port_suspend(struct ata_port *ap) | 81 | static void ata_eh_handle_port_suspend(struct ata_port *ap) |
86 | { } | 82 | { } |
87 | 83 | ||
88 | static void ata_eh_handle_port_resume(struct ata_port *ap) | 84 | static void ata_eh_handle_port_resume(struct ata_port *ap) |
89 | { } | 85 | { } |
90 | |||
91 | static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev) | ||
92 | { | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static void ata_eh_prep_resume(struct ata_port *ap) | ||
97 | { } | ||
98 | |||
99 | static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev) | ||
100 | { | ||
101 | return 0; | ||
102 | } | ||
103 | #endif /* CONFIG_PM */ | 86 | #endif /* CONFIG_PM */ |
104 | 87 | ||
105 | static void ata_ering_record(struct ata_ering *ering, int is_io, | 88 | static void ata_ering_record(struct ata_ering *ering, int is_io, |
@@ -568,6 +551,9 @@ void ata_port_schedule_eh(struct ata_port *ap) | |||
568 | { | 551 | { |
569 | WARN_ON(!ap->ops->error_handler); | 552 | WARN_ON(!ap->ops->error_handler); |
570 | 553 | ||
554 | if (ap->pflags & ATA_PFLAG_INITIALIZING) | ||
555 | return; | ||
556 | |||
571 | ap->pflags |= ATA_PFLAG_EH_PENDING; | 557 | ap->pflags |= ATA_PFLAG_EH_PENDING; |
572 | scsi_schedule_eh(ap->scsi_host); | 558 | scsi_schedule_eh(ap->scsi_host); |
573 | 559 | ||
@@ -1791,7 +1777,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, | |||
1791 | if (ehc->i.flags & ATA_EHI_DID_RESET) | 1777 | if (ehc->i.flags & ATA_EHI_DID_RESET) |
1792 | readid_flags |= ATA_READID_POSTRESET; | 1778 | readid_flags |= ATA_READID_POSTRESET; |
1793 | 1779 | ||
1794 | if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { | 1780 | if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { |
1795 | if (ata_port_offline(ap)) { | 1781 | if (ata_port_offline(ap)) { |
1796 | rc = -EIO; | 1782 | rc = -EIO; |
1797 | goto err; | 1783 | goto err; |
@@ -1872,166 +1858,6 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, | |||
1872 | return rc; | 1858 | return rc; |
1873 | } | 1859 | } |
1874 | 1860 | ||
1875 | #ifdef CONFIG_PM | ||
1876 | /** | ||
1877 | * ata_eh_suspend - handle suspend EH action | ||
1878 | * @ap: target host port | ||
1879 | * @r_failed_dev: result parameter to indicate failing device | ||
1880 | * | ||
1881 | * Handle suspend EH action. Disk devices are spinned down and | ||
1882 | * other types of devices are just marked suspended. Once | ||
1883 | * suspended, no EH action to the device is allowed until it is | ||
1884 | * resumed. | ||
1885 | * | ||
1886 | * LOCKING: | ||
1887 | * Kernel thread context (may sleep). | ||
1888 | * | ||
1889 | * RETURNS: | ||
1890 | * 0 on success, -errno otherwise | ||
1891 | */ | ||
1892 | static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev) | ||
1893 | { | ||
1894 | struct ata_device *dev; | ||
1895 | int i, rc = 0; | ||
1896 | |||
1897 | DPRINTK("ENTER\n"); | ||
1898 | |||
1899 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
1900 | unsigned long flags; | ||
1901 | unsigned int action, err_mask; | ||
1902 | |||
1903 | dev = &ap->device[i]; | ||
1904 | action = ata_eh_dev_action(dev); | ||
1905 | |||
1906 | if (!ata_dev_enabled(dev) || !(action & ATA_EH_SUSPEND)) | ||
1907 | continue; | ||
1908 | |||
1909 | WARN_ON(dev->flags & ATA_DFLAG_SUSPENDED); | ||
1910 | |||
1911 | ata_eh_about_to_do(ap, dev, ATA_EH_SUSPEND); | ||
1912 | |||
1913 | if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) { | ||
1914 | /* flush cache */ | ||
1915 | rc = ata_flush_cache(dev); | ||
1916 | if (rc) | ||
1917 | break; | ||
1918 | |||
1919 | /* spin down */ | ||
1920 | err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); | ||
1921 | if (err_mask) { | ||
1922 | ata_dev_printk(dev, KERN_ERR, "failed to " | ||
1923 | "spin down (err_mask=0x%x)\n", | ||
1924 | err_mask); | ||
1925 | rc = -EIO; | ||
1926 | break; | ||
1927 | } | ||
1928 | } | ||
1929 | |||
1930 | spin_lock_irqsave(ap->lock, flags); | ||
1931 | dev->flags |= ATA_DFLAG_SUSPENDED; | ||
1932 | spin_unlock_irqrestore(ap->lock, flags); | ||
1933 | |||
1934 | ata_eh_done(ap, dev, ATA_EH_SUSPEND); | ||
1935 | } | ||
1936 | |||
1937 | if (rc) | ||
1938 | *r_failed_dev = dev; | ||
1939 | |||
1940 | DPRINTK("EXIT\n"); | ||
1941 | return rc; | ||
1942 | } | ||
1943 | |||
1944 | /** | ||
1945 | * ata_eh_prep_resume - prep for resume EH action | ||
1946 | * @ap: target host port | ||
1947 | * | ||
1948 | * Clear SUSPENDED in preparation for scheduled resume actions. | ||
1949 | * This allows other parts of EH to access the devices being | ||
1950 | * resumed. | ||
1951 | * | ||
1952 | * LOCKING: | ||
1953 | * Kernel thread context (may sleep). | ||
1954 | */ | ||
1955 | static void ata_eh_prep_resume(struct ata_port *ap) | ||
1956 | { | ||
1957 | struct ata_device *dev; | ||
1958 | unsigned long flags; | ||
1959 | int i; | ||
1960 | |||
1961 | DPRINTK("ENTER\n"); | ||
1962 | |||
1963 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
1964 | unsigned int action; | ||
1965 | |||
1966 | dev = &ap->device[i]; | ||
1967 | action = ata_eh_dev_action(dev); | ||
1968 | |||
1969 | if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME)) | ||
1970 | continue; | ||
1971 | |||
1972 | spin_lock_irqsave(ap->lock, flags); | ||
1973 | dev->flags &= ~ATA_DFLAG_SUSPENDED; | ||
1974 | spin_unlock_irqrestore(ap->lock, flags); | ||
1975 | } | ||
1976 | |||
1977 | DPRINTK("EXIT\n"); | ||
1978 | } | ||
1979 | |||
1980 | /** | ||
1981 | * ata_eh_resume - handle resume EH action | ||
1982 | * @ap: target host port | ||
1983 | * @r_failed_dev: result parameter to indicate failing device | ||
1984 | * | ||
1985 | * Handle resume EH action. Target devices are already reset and | ||
1986 | * revalidated. Spinning up is the only operation left. | ||
1987 | * | ||
1988 | * LOCKING: | ||
1989 | * Kernel thread context (may sleep). | ||
1990 | * | ||
1991 | * RETURNS: | ||
1992 | * 0 on success, -errno otherwise | ||
1993 | */ | ||
1994 | static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev) | ||
1995 | { | ||
1996 | struct ata_device *dev; | ||
1997 | int i, rc = 0; | ||
1998 | |||
1999 | DPRINTK("ENTER\n"); | ||
2000 | |||
2001 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
2002 | unsigned int action, err_mask; | ||
2003 | |||
2004 | dev = &ap->device[i]; | ||
2005 | action = ata_eh_dev_action(dev); | ||
2006 | |||
2007 | if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME)) | ||
2008 | continue; | ||
2009 | |||
2010 | ata_eh_about_to_do(ap, dev, ATA_EH_RESUME); | ||
2011 | |||
2012 | if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) { | ||
2013 | err_mask = ata_do_simple_cmd(dev, | ||
2014 | ATA_CMD_IDLEIMMEDIATE); | ||
2015 | if (err_mask) { | ||
2016 | ata_dev_printk(dev, KERN_ERR, "failed to " | ||
2017 | "spin up (err_mask=0x%x)\n", | ||
2018 | err_mask); | ||
2019 | rc = -EIO; | ||
2020 | break; | ||
2021 | } | ||
2022 | } | ||
2023 | |||
2024 | ata_eh_done(ap, dev, ATA_EH_RESUME); | ||
2025 | } | ||
2026 | |||
2027 | if (rc) | ||
2028 | *r_failed_dev = dev; | ||
2029 | |||
2030 | DPRINTK("EXIT\n"); | ||
2031 | return 0; | ||
2032 | } | ||
2033 | #endif /* CONFIG_PM */ | ||
2034 | |||
2035 | static int ata_port_nr_enabled(struct ata_port *ap) | 1861 | static int ata_port_nr_enabled(struct ata_port *ap) |
2036 | { | 1862 | { |
2037 | int i, cnt = 0; | 1863 | int i, cnt = 0; |
@@ -2057,17 +1883,6 @@ static int ata_eh_skip_recovery(struct ata_port *ap) | |||
2057 | struct ata_eh_context *ehc = &ap->eh_context; | 1883 | struct ata_eh_context *ehc = &ap->eh_context; |
2058 | int i; | 1884 | int i; |
2059 | 1885 | ||
2060 | /* skip if all possible devices are suspended */ | ||
2061 | for (i = 0; i < ata_port_max_devices(ap); i++) { | ||
2062 | struct ata_device *dev = &ap->device[i]; | ||
2063 | |||
2064 | if (!(dev->flags & ATA_DFLAG_SUSPENDED)) | ||
2065 | break; | ||
2066 | } | ||
2067 | |||
2068 | if (i == ata_port_max_devices(ap)) | ||
2069 | return 1; | ||
2070 | |||
2071 | /* thaw frozen port, resume link and recover failed devices */ | 1886 | /* thaw frozen port, resume link and recover failed devices */ |
2072 | if ((ap->pflags & ATA_PFLAG_FROZEN) || | 1887 | if ((ap->pflags & ATA_PFLAG_FROZEN) || |
2073 | (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) | 1888 | (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) |
@@ -2147,9 +1962,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2147 | if (ap->pflags & ATA_PFLAG_UNLOADING) | 1962 | if (ap->pflags & ATA_PFLAG_UNLOADING) |
2148 | goto out; | 1963 | goto out; |
2149 | 1964 | ||
2150 | /* prep for resume */ | ||
2151 | ata_eh_prep_resume(ap); | ||
2152 | |||
2153 | /* skip EH if possible. */ | 1965 | /* skip EH if possible. */ |
2154 | if (ata_eh_skip_recovery(ap)) | 1966 | if (ata_eh_skip_recovery(ap)) |
2155 | ehc->i.action = 0; | 1967 | ehc->i.action = 0; |
@@ -2177,11 +1989,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2177 | if (rc) | 1989 | if (rc) |
2178 | goto dev_fail; | 1990 | goto dev_fail; |
2179 | 1991 | ||
2180 | /* resume devices */ | ||
2181 | rc = ata_eh_resume(ap, &dev); | ||
2182 | if (rc) | ||
2183 | goto dev_fail; | ||
2184 | |||
2185 | /* configure transfer mode if necessary */ | 1992 | /* configure transfer mode if necessary */ |
2186 | if (ehc->i.flags & ATA_EHI_SETMODE) { | 1993 | if (ehc->i.flags & ATA_EHI_SETMODE) { |
2187 | rc = ata_set_mode(ap, &dev); | 1994 | rc = ata_set_mode(ap, &dev); |
@@ -2190,25 +1997,16 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2190 | ehc->i.flags &= ~ATA_EHI_SETMODE; | 1997 | ehc->i.flags &= ~ATA_EHI_SETMODE; |
2191 | } | 1998 | } |
2192 | 1999 | ||
2193 | /* suspend devices */ | ||
2194 | rc = ata_eh_suspend(ap, &dev); | ||
2195 | if (rc) | ||
2196 | goto dev_fail; | ||
2197 | |||
2198 | goto out; | 2000 | goto out; |
2199 | 2001 | ||
2200 | dev_fail: | 2002 | dev_fail: |
2201 | ehc->tries[dev->devno]--; | 2003 | ehc->tries[dev->devno]--; |
2202 | 2004 | ||
2203 | switch (rc) { | 2005 | switch (rc) { |
2204 | case -EINVAL: | ||
2205 | /* eeek, something went very wrong, give up */ | ||
2206 | ehc->tries[dev->devno] = 0; | ||
2207 | break; | ||
2208 | |||
2209 | case -ENODEV: | 2006 | case -ENODEV: |
2210 | /* device missing or wrong IDENTIFY data, schedule probing */ | 2007 | /* device missing or wrong IDENTIFY data, schedule probing */ |
2211 | ehc->i.probe_mask |= (1 << dev->devno); | 2008 | ehc->i.probe_mask |= (1 << dev->devno); |
2009 | case -EINVAL: | ||
2212 | /* give it just one more chance */ | 2010 | /* give it just one more chance */ |
2213 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); | 2011 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); |
2214 | case -EIO: | 2012 | case -EIO: |
@@ -2390,22 +2188,13 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap) | |||
2390 | * | 2188 | * |
2391 | * Resume @ap. | 2189 | * Resume @ap. |
2392 | * | 2190 | * |
2393 | * This function also waits upto one second until all devices | ||
2394 | * hanging off this port requests resume EH action. This is to | ||
2395 | * prevent invoking EH and thus reset multiple times on resume. | ||
2396 | * | ||
2397 | * On DPM resume, where some of devices might not be resumed | ||
2398 | * together, this may delay port resume upto one second, but such | ||
2399 | * DPM resumes are rare and 1 sec delay isn't too bad. | ||
2400 | * | ||
2401 | * LOCKING: | 2191 | * LOCKING: |
2402 | * Kernel thread context (may sleep). | 2192 | * Kernel thread context (may sleep). |
2403 | */ | 2193 | */ |
2404 | static void ata_eh_handle_port_resume(struct ata_port *ap) | 2194 | static void ata_eh_handle_port_resume(struct ata_port *ap) |
2405 | { | 2195 | { |
2406 | unsigned long timeout; | ||
2407 | unsigned long flags; | 2196 | unsigned long flags; |
2408 | int i, rc = 0; | 2197 | int rc = 0; |
2409 | 2198 | ||
2410 | /* are we resuming? */ | 2199 | /* are we resuming? */ |
2411 | spin_lock_irqsave(ap->lock, flags); | 2200 | spin_lock_irqsave(ap->lock, flags); |
@@ -2416,31 +2205,12 @@ static void ata_eh_handle_port_resume(struct ata_port *ap) | |||
2416 | } | 2205 | } |
2417 | spin_unlock_irqrestore(ap->lock, flags); | 2206 | spin_unlock_irqrestore(ap->lock, flags); |
2418 | 2207 | ||
2419 | /* spurious? */ | 2208 | WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); |
2420 | if (!(ap->pflags & ATA_PFLAG_SUSPENDED)) | ||
2421 | goto done; | ||
2422 | 2209 | ||
2423 | if (ap->ops->port_resume) | 2210 | if (ap->ops->port_resume) |
2424 | rc = ap->ops->port_resume(ap); | 2211 | rc = ap->ops->port_resume(ap); |
2425 | 2212 | ||
2426 | /* give devices time to request EH */ | 2213 | /* report result */ |
2427 | timeout = jiffies + HZ; /* 1s max */ | ||
2428 | while (1) { | ||
2429 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
2430 | struct ata_device *dev = &ap->device[i]; | ||
2431 | unsigned int action = ata_eh_dev_action(dev); | ||
2432 | |||
2433 | if ((dev->flags & ATA_DFLAG_SUSPENDED) && | ||
2434 | !(action & ATA_EH_RESUME)) | ||
2435 | break; | ||
2436 | } | ||
2437 | |||
2438 | if (i == ATA_MAX_DEVICES || time_after(jiffies, timeout)) | ||
2439 | break; | ||
2440 | msleep(10); | ||
2441 | } | ||
2442 | |||
2443 | done: | ||
2444 | spin_lock_irqsave(ap->lock, flags); | 2214 | spin_lock_irqsave(ap->lock, flags); |
2445 | ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); | 2215 | ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); |
2446 | if (ap->pm_result) { | 2216 | if (ap->pm_result) { |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 9afba2ba489e..dd81fa78cdcf 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -510,133 +510,6 @@ static void ata_dump_status(unsigned id, struct ata_taskfile *tf) | |||
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
513 | #ifdef CONFIG_PM | ||
514 | /** | ||
515 | * ata_scsi_device_suspend - suspend ATA device associated with sdev | ||
516 | * @sdev: the SCSI device to suspend | ||
517 | * @mesg: target power management message | ||
518 | * | ||
519 | * Request suspend EH action on the ATA device associated with | ||
520 | * @sdev and wait for the operation to complete. | ||
521 | * | ||
522 | * LOCKING: | ||
523 | * Kernel thread context (may sleep). | ||
524 | * | ||
525 | * RETURNS: | ||
526 | * 0 on success, -errno otherwise. | ||
527 | */ | ||
528 | int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg) | ||
529 | { | ||
530 | struct ata_port *ap = ata_shost_to_port(sdev->host); | ||
531 | struct ata_device *dev = ata_scsi_find_dev(ap, sdev); | ||
532 | unsigned long flags; | ||
533 | unsigned int action; | ||
534 | int rc = 0; | ||
535 | |||
536 | if (!dev) | ||
537 | goto out; | ||
538 | |||
539 | spin_lock_irqsave(ap->lock, flags); | ||
540 | |||
541 | /* wait for the previous resume to complete */ | ||
542 | while (dev->flags & ATA_DFLAG_SUSPENDED) { | ||
543 | spin_unlock_irqrestore(ap->lock, flags); | ||
544 | ata_port_wait_eh(ap); | ||
545 | spin_lock_irqsave(ap->lock, flags); | ||
546 | } | ||
547 | |||
548 | /* if @sdev is already detached, nothing to do */ | ||
549 | if (sdev->sdev_state == SDEV_OFFLINE || | ||
550 | sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL) | ||
551 | goto out_unlock; | ||
552 | |||
553 | /* request suspend */ | ||
554 | action = ATA_EH_SUSPEND; | ||
555 | if (mesg.event != PM_EVENT_SUSPEND) | ||
556 | action |= ATA_EH_PM_FREEZE; | ||
557 | ap->eh_info.dev_action[dev->devno] |= action; | ||
558 | ap->eh_info.flags |= ATA_EHI_QUIET; | ||
559 | ata_port_schedule_eh(ap); | ||
560 | |||
561 | spin_unlock_irqrestore(ap->lock, flags); | ||
562 | |||
563 | /* wait for EH to do the job */ | ||
564 | ata_port_wait_eh(ap); | ||
565 | |||
566 | spin_lock_irqsave(ap->lock, flags); | ||
567 | |||
568 | /* If @sdev is still attached but the associated ATA device | ||
569 | * isn't suspended, the operation failed. | ||
570 | */ | ||
571 | if (sdev->sdev_state != SDEV_OFFLINE && | ||
572 | sdev->sdev_state != SDEV_CANCEL && sdev->sdev_state != SDEV_DEL && | ||
573 | !(dev->flags & ATA_DFLAG_SUSPENDED)) | ||
574 | rc = -EIO; | ||
575 | |||
576 | out_unlock: | ||
577 | spin_unlock_irqrestore(ap->lock, flags); | ||
578 | out: | ||
579 | if (rc == 0) | ||
580 | sdev->sdev_gendev.power.power_state = mesg; | ||
581 | return rc; | ||
582 | } | ||
583 | |||
584 | /** | ||
585 | * ata_scsi_device_resume - resume ATA device associated with sdev | ||
586 | * @sdev: the SCSI device to resume | ||
587 | * | ||
588 | * Request resume EH action on the ATA device associated with | ||
589 | * @sdev and return immediately. This enables parallel | ||
590 | * wakeup/spinup of devices. | ||
591 | * | ||
592 | * LOCKING: | ||
593 | * Kernel thread context (may sleep). | ||
594 | * | ||
595 | * RETURNS: | ||
596 | * 0. | ||
597 | */ | ||
598 | int ata_scsi_device_resume(struct scsi_device *sdev) | ||
599 | { | ||
600 | struct ata_port *ap = ata_shost_to_port(sdev->host); | ||
601 | struct ata_device *dev = ata_scsi_find_dev(ap, sdev); | ||
602 | struct ata_eh_info *ehi = &ap->eh_info; | ||
603 | unsigned long flags; | ||
604 | unsigned int action; | ||
605 | |||
606 | if (!dev) | ||
607 | goto out; | ||
608 | |||
609 | spin_lock_irqsave(ap->lock, flags); | ||
610 | |||
611 | /* if @sdev is already detached, nothing to do */ | ||
612 | if (sdev->sdev_state == SDEV_OFFLINE || | ||
613 | sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL) | ||
614 | goto out_unlock; | ||
615 | |||
616 | /* request resume */ | ||
617 | action = ATA_EH_RESUME; | ||
618 | if (sdev->sdev_gendev.power.power_state.event == PM_EVENT_SUSPEND) | ||
619 | __ata_ehi_hotplugged(ehi); | ||
620 | else | ||
621 | action |= ATA_EH_PM_FREEZE | ATA_EH_SOFTRESET; | ||
622 | ehi->dev_action[dev->devno] |= action; | ||
623 | |||
624 | /* We don't want autopsy and verbose EH messages. Disable | ||
625 | * those if we're the only device on this link. | ||
626 | */ | ||
627 | if (ata_port_max_devices(ap) == 1) | ||
628 | ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; | ||
629 | |||
630 | ata_port_schedule_eh(ap); | ||
631 | |||
632 | out_unlock: | ||
633 | spin_unlock_irqrestore(ap->lock, flags); | ||
634 | out: | ||
635 | sdev->sdev_gendev.power.power_state = PMSG_ON; | ||
636 | return 0; | ||
637 | } | ||
638 | #endif /* CONFIG_PM */ | ||
639 | |||
640 | /** | 513 | /** |
641 | * ata_to_sense_error - convert ATA error to SCSI error | 514 | * ata_to_sense_error - convert ATA error to SCSI error |
642 | * @id: ATA device number | 515 | * @id: ATA device number |
@@ -929,6 +802,8 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
929 | 802 | ||
930 | blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); | 803 | blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); |
931 | 804 | ||
805 | sdev->manage_start_stop = 1; | ||
806 | |||
932 | if (dev) | 807 | if (dev) |
933 | ata_scsi_dev_config(sdev, dev); | 808 | ata_scsi_dev_config(sdev, dev); |
934 | 809 | ||
@@ -1069,9 +944,35 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) | |||
1069 | } | 944 | } |
1070 | 945 | ||
1071 | tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ | 946 | tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ |
1072 | } else | 947 | } else { |
948 | /* XXX: This is for backward compatibility, will be | ||
949 | * removed. Read Documentation/feature-removal-schedule.txt | ||
950 | * for more info. | ||
951 | */ | ||
952 | if (ata_spindown_compat && | ||
953 | (system_state == SYSTEM_HALT || | ||
954 | system_state == SYSTEM_POWER_OFF)) { | ||
955 | static int warned = 0; | ||
956 | |||
957 | if (!warned) { | ||
958 | spin_unlock_irq(qc->ap->lock); | ||
959 | ata_dev_printk(qc->dev, KERN_WARNING, | ||
960 | "DISK MIGHT NOT BE SPUN DOWN PROPERLY. " | ||
961 | "UPDATE SHUTDOWN UTILITY\n"); | ||
962 | ata_dev_printk(qc->dev, KERN_WARNING, | ||
963 | "For more info, visit " | ||
964 | "http://linux-ata.org/shutdown.html\n"); | ||
965 | warned = 1; | ||
966 | ssleep(5); | ||
967 | spin_lock_irq(qc->ap->lock); | ||
968 | } | ||
969 | scmd->result = SAM_STAT_GOOD; | ||
970 | return 1; | ||
971 | } | ||
972 | |||
1073 | /* Issue ATA STANDBY IMMEDIATE command */ | 973 | /* Issue ATA STANDBY IMMEDIATE command */ |
1074 | tf->command = ATA_CMD_STANDBYNOW1; | 974 | tf->command = ATA_CMD_STANDBYNOW1; |
975 | } | ||
1075 | 976 | ||
1076 | /* | 977 | /* |
1077 | * Standby and Idle condition timers could be implemented but that | 978 | * Standby and Idle condition timers could be implemented but that |
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index d211db6b35a2..e35d13466c69 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -544,7 +544,7 @@ static int ata_resources_present(struct pci_dev *pdev, int port) | |||
544 | * RETURNS: | 544 | * RETURNS: |
545 | * 0 on success, -errno otherwise. | 545 | * 0 on success, -errno otherwise. |
546 | */ | 546 | */ |
547 | static int ata_pci_init_bmdma(struct ata_host *host) | 547 | int ata_pci_init_bmdma(struct ata_host *host) |
548 | { | 548 | { |
549 | struct device *gdev = host->dev; | 549 | struct device *gdev = host->dev; |
550 | struct pci_dev *pdev = to_pci_dev(gdev); | 550 | struct pci_dev *pdev = to_pci_dev(gdev); |
@@ -566,7 +566,7 @@ static int ata_pci_init_bmdma(struct ata_host *host) | |||
566 | } | 566 | } |
567 | host->iomap = pcim_iomap_table(pdev); | 567 | host->iomap = pcim_iomap_table(pdev); |
568 | 568 | ||
569 | for (i = 0; i < host->n_ports; i++) { | 569 | for (i = 0; i < 2; i++) { |
570 | struct ata_port *ap = host->ports[i]; | 570 | struct ata_port *ap = host->ports[i]; |
571 | void __iomem *bmdma = host->iomap[4] + 8 * i; | 571 | void __iomem *bmdma = host->iomap[4] + 8 * i; |
572 | 572 | ||
@@ -585,54 +585,52 @@ static int ata_pci_init_bmdma(struct ata_host *host) | |||
585 | /** | 585 | /** |
586 | * ata_pci_init_native_host - acquire native ATA resources and init host | 586 | * ata_pci_init_native_host - acquire native ATA resources and init host |
587 | * @host: target ATA host | 587 | * @host: target ATA host |
588 | * @port_mask: ports to consider | ||
589 | * | 588 | * |
590 | * Acquire native PCI ATA resources for @host and initialize | 589 | * Acquire native PCI ATA resources for @host and initialize the |
591 | * @host accordoingly. | 590 | * first two ports of @host accordingly. Ports marked dummy are |
591 | * skipped and allocation failure makes the port dummy. | ||
592 | * | 592 | * |
593 | * LOCKING: | 593 | * LOCKING: |
594 | * Inherited from calling layer (may sleep). | 594 | * Inherited from calling layer (may sleep). |
595 | * | 595 | * |
596 | * RETURNS: | 596 | * RETURNS: |
597 | * 0 on success, -errno otherwise. | 597 | * 0 if at least one port is initialized, -ENODEV if no port is |
598 | * available. | ||
598 | */ | 599 | */ |
599 | int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) | 600 | int ata_pci_init_native_host(struct ata_host *host) |
600 | { | 601 | { |
601 | struct device *gdev = host->dev; | 602 | struct device *gdev = host->dev; |
602 | struct pci_dev *pdev = to_pci_dev(gdev); | 603 | struct pci_dev *pdev = to_pci_dev(gdev); |
604 | unsigned int mask = 0; | ||
603 | int i, rc; | 605 | int i, rc; |
604 | 606 | ||
605 | /* Discard disabled ports. Some controllers show their unused | ||
606 | * channels this way. Disabled ports are made dummy. | ||
607 | */ | ||
608 | for (i = 0; i < 2; i++) { | ||
609 | if ((port_mask & (1 << i)) && !ata_resources_present(pdev, i)) { | ||
610 | host->ports[i]->ops = &ata_dummy_port_ops; | ||
611 | port_mask &= ~(1 << i); | ||
612 | } | ||
613 | } | ||
614 | |||
615 | if (!port_mask) { | ||
616 | dev_printk(KERN_ERR, gdev, "no available port\n"); | ||
617 | return -ENODEV; | ||
618 | } | ||
619 | |||
620 | /* request, iomap BARs and init port addresses accordingly */ | 607 | /* request, iomap BARs and init port addresses accordingly */ |
621 | for (i = 0; i < 2; i++) { | 608 | for (i = 0; i < 2; i++) { |
622 | struct ata_port *ap = host->ports[i]; | 609 | struct ata_port *ap = host->ports[i]; |
623 | int base = i * 2; | 610 | int base = i * 2; |
624 | void __iomem * const *iomap; | 611 | void __iomem * const *iomap; |
625 | 612 | ||
626 | if (!(port_mask & (1 << i))) | 613 | if (ata_port_is_dummy(ap)) |
614 | continue; | ||
615 | |||
616 | /* Discard disabled ports. Some controllers show | ||
617 | * their unused channels this way. Disabled ports are | ||
618 | * made dummy. | ||
619 | */ | ||
620 | if (!ata_resources_present(pdev, i)) { | ||
621 | ap->ops = &ata_dummy_port_ops; | ||
627 | continue; | 622 | continue; |
623 | } | ||
628 | 624 | ||
629 | rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME); | 625 | rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME); |
630 | if (rc) { | 626 | if (rc) { |
631 | dev_printk(KERN_ERR, gdev, "failed to request/iomap " | 627 | dev_printk(KERN_WARNING, gdev, |
632 | "BARs for port %d (errno=%d)\n", i, rc); | 628 | "failed to request/iomap BARs for port %d " |
629 | "(errno=%d)\n", i, rc); | ||
633 | if (rc == -EBUSY) | 630 | if (rc == -EBUSY) |
634 | pcim_pin_device(pdev); | 631 | pcim_pin_device(pdev); |
635 | return rc; | 632 | ap->ops = &ata_dummy_port_ops; |
633 | continue; | ||
636 | } | 634 | } |
637 | host->iomap = iomap = pcim_iomap_table(pdev); | 635 | host->iomap = iomap = pcim_iomap_table(pdev); |
638 | 636 | ||
@@ -641,6 +639,13 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) | |||
641 | ap->ioaddr.ctl_addr = (void __iomem *) | 639 | ap->ioaddr.ctl_addr = (void __iomem *) |
642 | ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS); | 640 | ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS); |
643 | ata_std_ports(&ap->ioaddr); | 641 | ata_std_ports(&ap->ioaddr); |
642 | |||
643 | mask |= 1 << i; | ||
644 | } | ||
645 | |||
646 | if (!mask) { | ||
647 | dev_printk(KERN_ERR, gdev, "no available native port\n"); | ||
648 | return -ENODEV; | ||
644 | } | 649 | } |
645 | 650 | ||
646 | return 0; | 651 | return 0; |
@@ -649,8 +654,7 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) | |||
649 | /** | 654 | /** |
650 | * ata_pci_prepare_native_host - helper to prepare native PCI ATA host | 655 | * ata_pci_prepare_native_host - helper to prepare native PCI ATA host |
651 | * @pdev: target PCI device | 656 | * @pdev: target PCI device |
652 | * @ppi: array of port_info | 657 | * @ppi: array of port_info, must be enough for two ports |
653 | * @n_ports: number of ports to allocate | ||
654 | * @r_host: out argument for the initialized ATA host | 658 | * @r_host: out argument for the initialized ATA host |
655 | * | 659 | * |
656 | * Helper to allocate ATA host for @pdev, acquire all native PCI | 660 | * Helper to allocate ATA host for @pdev, acquire all native PCI |
@@ -664,10 +668,9 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) | |||
664 | */ | 668 | */ |
665 | int ata_pci_prepare_native_host(struct pci_dev *pdev, | 669 | int ata_pci_prepare_native_host(struct pci_dev *pdev, |
666 | const struct ata_port_info * const * ppi, | 670 | const struct ata_port_info * const * ppi, |
667 | int n_ports, struct ata_host **r_host) | 671 | struct ata_host **r_host) |
668 | { | 672 | { |
669 | struct ata_host *host; | 673 | struct ata_host *host; |
670 | unsigned int port_mask; | ||
671 | int rc; | 674 | int rc; |
672 | 675 | ||
673 | if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) | 676 | if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) |
@@ -681,11 +684,7 @@ int ata_pci_prepare_native_host(struct pci_dev *pdev, | |||
681 | goto err_out; | 684 | goto err_out; |
682 | } | 685 | } |
683 | 686 | ||
684 | port_mask = ATA_PORT_PRIMARY; | 687 | rc = ata_pci_init_native_host(host); |
685 | if (n_ports > 1) | ||
686 | port_mask |= ATA_PORT_SECONDARY; | ||
687 | |||
688 | rc = ata_pci_init_native_host(host, port_mask); | ||
689 | if (rc) | 688 | if (rc) |
690 | goto err_out; | 689 | goto err_out; |
691 | 690 | ||
@@ -777,8 +776,11 @@ static int ata_init_legacy_port(struct ata_port *ap, | |||
777 | /* iomap cmd and ctl ports */ | 776 | /* iomap cmd and ctl ports */ |
778 | legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8); | 777 | legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8); |
779 | legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1); | 778 | legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1); |
780 | if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) | 779 | if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) { |
780 | dev_printk(KERN_WARNING, host->dev, | ||
781 | "failed to map cmd/ctl ports\n"); | ||
781 | return -ENOMEM; | 782 | return -ENOMEM; |
783 | } | ||
782 | 784 | ||
783 | /* init IO addresses */ | 785 | /* init IO addresses */ |
784 | ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no]; | 786 | ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no]; |
@@ -792,19 +794,20 @@ static int ata_init_legacy_port(struct ata_port *ap, | |||
792 | /** | 794 | /** |
793 | * ata_init_legacy_host - acquire legacy ATA resources and init ATA host | 795 | * ata_init_legacy_host - acquire legacy ATA resources and init ATA host |
794 | * @host: target ATA host | 796 | * @host: target ATA host |
795 | * @legacy_mask: out parameter, mask indicating ports is in legacy mode | ||
796 | * @was_busy: out parameter, indicates whether any port was busy | 797 | * @was_busy: out parameter, indicates whether any port was busy |
797 | * | 798 | * |
798 | * Acquire legacy ATA resources for ports. | 799 | * Acquire legacy ATA resources for the first two ports of @host |
800 | * and initialize it accordingly. Ports marked dummy are skipped | ||
801 | * and resource acquistion failure makes the port dummy. | ||
799 | * | 802 | * |
800 | * LOCKING: | 803 | * LOCKING: |
801 | * Inherited from calling layer (may sleep). | 804 | * Inherited from calling layer (may sleep). |
802 | * | 805 | * |
803 | * RETURNS: | 806 | * RETURNS: |
804 | * 0 on success, -errno otherwise. | 807 | * 0 if at least one port is initialized, -ENODEV if no port is |
808 | * available. | ||
805 | */ | 809 | */ |
806 | static int ata_init_legacy_host(struct ata_host *host, | 810 | static int ata_init_legacy_host(struct ata_host *host, int *was_busy) |
807 | unsigned int *legacy_mask, int *was_busy) | ||
808 | { | 811 | { |
809 | struct device *gdev = host->dev; | 812 | struct device *gdev = host->dev; |
810 | struct ata_legacy_devres *legacy_dr; | 813 | struct ata_legacy_devres *legacy_dr; |
@@ -821,22 +824,23 @@ static int ata_init_legacy_host(struct ata_host *host, | |||
821 | devres_add(gdev, legacy_dr); | 824 | devres_add(gdev, legacy_dr); |
822 | 825 | ||
823 | for (i = 0; i < 2; i++) { | 826 | for (i = 0; i < 2; i++) { |
824 | *legacy_mask &= ~(1 << i); | 827 | if (ata_port_is_dummy(host->ports[i])) |
828 | continue; | ||
829 | |||
825 | rc = ata_init_legacy_port(host->ports[i], legacy_dr); | 830 | rc = ata_init_legacy_port(host->ports[i], legacy_dr); |
826 | if (rc == 0) | 831 | if (rc == 0) |
827 | legacy_dr->mask |= 1 << i; | 832 | legacy_dr->mask |= 1 << i; |
828 | else if (rc == -EBUSY) | 833 | else { |
829 | (*was_busy)++; | 834 | if (rc == -EBUSY) |
830 | } | 835 | (*was_busy)++; |
831 | |||
832 | if (!legacy_dr->mask) | ||
833 | return -EBUSY; | ||
834 | |||
835 | for (i = 0; i < 2; i++) | ||
836 | if (!(legacy_dr->mask & (1 << i))) | ||
837 | host->ports[i]->ops = &ata_dummy_port_ops; | 836 | host->ports[i]->ops = &ata_dummy_port_ops; |
837 | } | ||
838 | } | ||
838 | 839 | ||
839 | *legacy_mask |= legacy_dr->mask; | 840 | if (!legacy_dr->mask) { |
841 | dev_printk(KERN_ERR, gdev, "no available legacy port\n"); | ||
842 | return -ENODEV; | ||
843 | } | ||
840 | 844 | ||
841 | devres_remove_group(gdev, NULL); | 845 | devres_remove_group(gdev, NULL); |
842 | return 0; | 846 | return 0; |
@@ -875,7 +879,7 @@ static int ata_request_legacy_irqs(struct ata_host *host, | |||
875 | legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL); | 879 | legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL); |
876 | BUG_ON(!legacy_dr); | 880 | BUG_ON(!legacy_dr); |
877 | 881 | ||
878 | for (i = 0; i < host->n_ports; i++) { | 882 | for (i = 0; i < 2; i++) { |
879 | unsigned int irq; | 883 | unsigned int irq; |
880 | 884 | ||
881 | /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */ | 885 | /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */ |
@@ -923,8 +927,7 @@ static int ata_request_legacy_irqs(struct ata_host *host, | |||
923 | /** | 927 | /** |
924 | * ata_pci_init_one - Initialize/register PCI IDE host controller | 928 | * ata_pci_init_one - Initialize/register PCI IDE host controller |
925 | * @pdev: Controller to be initialized | 929 | * @pdev: Controller to be initialized |
926 | * @port_info: Information from low-level host driver | 930 | * @ppi: array of port_info, must be enough for two ports |
927 | * @n_ports: Number of ports attached to host controller | ||
928 | * | 931 | * |
929 | * This is a helper function which can be called from a driver's | 932 | * This is a helper function which can be called from a driver's |
930 | * xxx_init_one() probe function if the hardware uses traditional | 933 | * xxx_init_one() probe function if the hardware uses traditional |
@@ -944,26 +947,34 @@ static int ata_request_legacy_irqs(struct ata_host *host, | |||
944 | * RETURNS: | 947 | * RETURNS: |
945 | * Zero on success, negative on errno-based value on error. | 948 | * Zero on success, negative on errno-based value on error. |
946 | */ | 949 | */ |
947 | 950 | int ata_pci_init_one(struct pci_dev *pdev, | |
948 | int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | 951 | const struct ata_port_info * const * ppi) |
949 | unsigned int n_ports) | ||
950 | { | 952 | { |
951 | struct device *dev = &pdev->dev; | 953 | struct device *dev = &pdev->dev; |
954 | const struct ata_port_info *pi = NULL; | ||
952 | struct ata_host *host = NULL; | 955 | struct ata_host *host = NULL; |
953 | const struct ata_port_info *port[2]; | ||
954 | u8 mask; | 956 | u8 mask; |
955 | unsigned int legacy_mode = 0; | 957 | int legacy_mode = 0; |
956 | int rc; | 958 | int i, rc; |
957 | 959 | ||
958 | DPRINTK("ENTER\n"); | 960 | DPRINTK("ENTER\n"); |
959 | 961 | ||
960 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) | 962 | /* look up the first valid port_info */ |
961 | return -ENOMEM; | 963 | for (i = 0; i < 2 && ppi[i]; i++) { |
964 | if (ppi[i]->port_ops != &ata_dummy_port_ops) { | ||
965 | pi = ppi[i]; | ||
966 | break; | ||
967 | } | ||
968 | } | ||
962 | 969 | ||
963 | BUG_ON(n_ports < 1 || n_ports > 2); | 970 | if (!pi) { |
971 | dev_printk(KERN_ERR, &pdev->dev, | ||
972 | "no valid port_info specified\n"); | ||
973 | return -EINVAL; | ||
974 | } | ||
964 | 975 | ||
965 | port[0] = port_info[0]; | 976 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) |
966 | port[1] = (n_ports > 1) ? port_info[1] : NULL; | 977 | return -ENOMEM; |
967 | 978 | ||
968 | /* FIXME: Really for ATA it isn't safe because the device may be | 979 | /* FIXME: Really for ATA it isn't safe because the device may be |
969 | multi-purpose and we want to leave it alone if it was already | 980 | multi-purpose and we want to leave it alone if it was already |
@@ -984,7 +995,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
984 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); | 995 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); |
985 | mask = (1 << 2) | (1 << 0); | 996 | mask = (1 << 2) | (1 << 0); |
986 | if ((tmp8 & mask) != mask) | 997 | if ((tmp8 & mask) != mask) |
987 | legacy_mode = (1 << 3); | 998 | legacy_mode = 1; |
988 | #if defined(CONFIG_NO_ATA_LEGACY) | 999 | #if defined(CONFIG_NO_ATA_LEGACY) |
989 | /* Some platforms with PCI limits cannot address compat | 1000 | /* Some platforms with PCI limits cannot address compat |
990 | port space. In that case we punt if their firmware has | 1001 | port space. In that case we punt if their firmware has |
@@ -998,7 +1009,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
998 | } | 1009 | } |
999 | 1010 | ||
1000 | /* alloc and init host */ | 1011 | /* alloc and init host */ |
1001 | host = ata_host_alloc_pinfo(dev, port, n_ports); | 1012 | host = ata_host_alloc_pinfo(dev, ppi, 2); |
1002 | if (!host) { | 1013 | if (!host) { |
1003 | dev_printk(KERN_ERR, &pdev->dev, | 1014 | dev_printk(KERN_ERR, &pdev->dev, |
1004 | "failed to allocate ATA host\n"); | 1015 | "failed to allocate ATA host\n"); |
@@ -1007,19 +1018,13 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1007 | } | 1018 | } |
1008 | 1019 | ||
1009 | if (!legacy_mode) { | 1020 | if (!legacy_mode) { |
1010 | unsigned int port_mask; | 1021 | rc = ata_pci_init_native_host(host); |
1011 | |||
1012 | port_mask = ATA_PORT_PRIMARY; | ||
1013 | if (n_ports > 1) | ||
1014 | port_mask |= ATA_PORT_SECONDARY; | ||
1015 | |||
1016 | rc = ata_pci_init_native_host(host, port_mask); | ||
1017 | if (rc) | 1022 | if (rc) |
1018 | goto err_out; | 1023 | goto err_out; |
1019 | } else { | 1024 | } else { |
1020 | int was_busy = 0; | 1025 | int was_busy = 0; |
1021 | 1026 | ||
1022 | rc = ata_init_legacy_host(host, &legacy_mode, &was_busy); | 1027 | rc = ata_init_legacy_host(host, &was_busy); |
1023 | if (was_busy) | 1028 | if (was_busy) |
1024 | pcim_pin_device(pdev); | 1029 | pcim_pin_device(pdev); |
1025 | if (rc) | 1030 | if (rc) |
@@ -1040,8 +1045,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1040 | goto err_out; | 1045 | goto err_out; |
1041 | 1046 | ||
1042 | if (!legacy_mode) | 1047 | if (!legacy_mode) |
1043 | rc = devm_request_irq(dev, pdev->irq, | 1048 | rc = devm_request_irq(dev, pdev->irq, pi->port_ops->irq_handler, |
1044 | port_info[0]->port_ops->irq_handler, | ||
1045 | IRQF_SHARED, DRV_NAME, host); | 1049 | IRQF_SHARED, DRV_NAME, host); |
1046 | else { | 1050 | else { |
1047 | irq_handler_t handler[2] = { host->ops->irq_handler, | 1051 | irq_handler_t handler[2] = { host->ops->irq_handler, |
@@ -1055,7 +1059,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1055 | goto err_out; | 1059 | goto err_out; |
1056 | 1060 | ||
1057 | /* register */ | 1061 | /* register */ |
1058 | rc = ata_host_register(host, port_info[0]->sht); | 1062 | rc = ata_host_register(host, pi->sht); |
1059 | if (rc) | 1063 | if (rc) |
1060 | goto err_out; | 1064 | goto err_out; |
1061 | 1065 | ||
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 5f4d40cd3288..8b71b73a199c 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -58,6 +58,7 @@ extern int atapi_enabled; | |||
58 | extern int atapi_dmadir; | 58 | extern int atapi_dmadir; |
59 | extern int libata_fua; | 59 | extern int libata_fua; |
60 | extern int libata_noacpi; | 60 | extern int libata_noacpi; |
61 | extern int ata_spindown_compat; | ||
61 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); | 62 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); |
62 | extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, | 63 | extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, |
63 | u64 block, u32 n_block, unsigned int tf_flags, | 64 | u64 block, u32 n_block, unsigned int tf_flags, |
@@ -96,15 +97,15 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); | |||
96 | extern struct ata_port *ata_port_alloc(struct ata_host *host); | 97 | extern struct ata_port *ata_port_alloc(struct ata_host *host); |
97 | 98 | ||
98 | /* libata-acpi.c */ | 99 | /* libata-acpi.c */ |
99 | #ifdef CONFIG_SATA_ACPI | 100 | #ifdef CONFIG_ATA_ACPI |
100 | extern int ata_acpi_exec_tfs(struct ata_port *ap); | 101 | extern int ata_acpi_exec_tfs(struct ata_port *ap); |
101 | extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix); | 102 | extern int ata_acpi_push_id(struct ata_device *dev); |
102 | #else | 103 | #else |
103 | static inline int ata_acpi_exec_tfs(struct ata_port *ap) | 104 | static inline int ata_acpi_exec_tfs(struct ata_port *ap) |
104 | { | 105 | { |
105 | return 0; | 106 | return 0; |
106 | } | 107 | } |
107 | static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) | 108 | static inline int ata_acpi_push_id(struct ata_device *dev) |
108 | { | 109 | { |
109 | return 0; | 110 | return 0; |
110 | } | 111 | } |
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index d40edebb510a..3c55a5ff74c7 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c | |||
@@ -291,10 +291,6 @@ static struct scsi_host_template ali_sht = { | |||
291 | .slave_configure = ata_scsi_slave_config, | 291 | .slave_configure = ata_scsi_slave_config, |
292 | .slave_destroy = ata_scsi_slave_destroy, | 292 | .slave_destroy = ata_scsi_slave_destroy, |
293 | .bios_param = ata_std_bios_param, | 293 | .bios_param = ata_std_bios_param, |
294 | #ifdef CONFIG_PM | ||
295 | .resume = ata_scsi_device_resume, | ||
296 | .suspend = ata_scsi_device_suspend, | ||
297 | #endif | ||
298 | }; | 294 | }; |
299 | 295 | ||
300 | /* | 296 | /* |
@@ -522,14 +518,14 @@ static void ali_init_chipset(struct pci_dev *pdev) | |||
522 | 518 | ||
523 | static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 519 | static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
524 | { | 520 | { |
525 | static struct ata_port_info info_early = { | 521 | static const struct ata_port_info info_early = { |
526 | .sht = &ali_sht, | 522 | .sht = &ali_sht, |
527 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 523 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
528 | .pio_mask = 0x1f, | 524 | .pio_mask = 0x1f, |
529 | .port_ops = &ali_early_port_ops | 525 | .port_ops = &ali_early_port_ops |
530 | }; | 526 | }; |
531 | /* Revision 0x20 added DMA */ | 527 | /* Revision 0x20 added DMA */ |
532 | static struct ata_port_info info_20 = { | 528 | static const struct ata_port_info info_20 = { |
533 | .sht = &ali_sht, | 529 | .sht = &ali_sht, |
534 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 530 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
535 | .pio_mask = 0x1f, | 531 | .pio_mask = 0x1f, |
@@ -537,7 +533,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
537 | .port_ops = &ali_20_port_ops | 533 | .port_ops = &ali_20_port_ops |
538 | }; | 534 | }; |
539 | /* Revision 0x20 with support logic added UDMA */ | 535 | /* Revision 0x20 with support logic added UDMA */ |
540 | static struct ata_port_info info_20_udma = { | 536 | static const struct ata_port_info info_20_udma = { |
541 | .sht = &ali_sht, | 537 | .sht = &ali_sht, |
542 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 538 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
543 | .pio_mask = 0x1f, | 539 | .pio_mask = 0x1f, |
@@ -546,7 +542,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
546 | .port_ops = &ali_20_port_ops | 542 | .port_ops = &ali_20_port_ops |
547 | }; | 543 | }; |
548 | /* Revision 0xC2 adds UDMA66 */ | 544 | /* Revision 0xC2 adds UDMA66 */ |
549 | static struct ata_port_info info_c2 = { | 545 | static const struct ata_port_info info_c2 = { |
550 | .sht = &ali_sht, | 546 | .sht = &ali_sht, |
551 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 547 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
552 | .pio_mask = 0x1f, | 548 | .pio_mask = 0x1f, |
@@ -555,7 +551,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
555 | .port_ops = &ali_c2_port_ops | 551 | .port_ops = &ali_c2_port_ops |
556 | }; | 552 | }; |
557 | /* Revision 0xC3 is UDMA100 */ | 553 | /* Revision 0xC3 is UDMA100 */ |
558 | static struct ata_port_info info_c3 = { | 554 | static const struct ata_port_info info_c3 = { |
559 | .sht = &ali_sht, | 555 | .sht = &ali_sht, |
560 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 556 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
561 | .pio_mask = 0x1f, | 557 | .pio_mask = 0x1f, |
@@ -564,7 +560,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
564 | .port_ops = &ali_c2_port_ops | 560 | .port_ops = &ali_c2_port_ops |
565 | }; | 561 | }; |
566 | /* Revision 0xC4 is UDMA133 */ | 562 | /* Revision 0xC4 is UDMA133 */ |
567 | static struct ata_port_info info_c4 = { | 563 | static const struct ata_port_info info_c4 = { |
568 | .sht = &ali_sht, | 564 | .sht = &ali_sht, |
569 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, | 565 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, |
570 | .pio_mask = 0x1f, | 566 | .pio_mask = 0x1f, |
@@ -573,7 +569,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
573 | .port_ops = &ali_c2_port_ops | 569 | .port_ops = &ali_c2_port_ops |
574 | }; | 570 | }; |
575 | /* Revision 0xC5 is UDMA133 with LBA48 DMA */ | 571 | /* Revision 0xC5 is UDMA133 with LBA48 DMA */ |
576 | static struct ata_port_info info_c5 = { | 572 | static const struct ata_port_info info_c5 = { |
577 | .sht = &ali_sht, | 573 | .sht = &ali_sht, |
578 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 574 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
579 | .pio_mask = 0x1f, | 575 | .pio_mask = 0x1f, |
@@ -582,7 +578,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
582 | .port_ops = &ali_c5_port_ops | 578 | .port_ops = &ali_c5_port_ops |
583 | }; | 579 | }; |
584 | 580 | ||
585 | static struct ata_port_info *port_info[2]; | 581 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
586 | u8 rev, tmp; | 582 | u8 rev, tmp; |
587 | struct pci_dev *isa_bridge; | 583 | struct pci_dev *isa_bridge; |
588 | 584 | ||
@@ -594,17 +590,17 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
594 | */ | 590 | */ |
595 | 591 | ||
596 | if (rev < 0x20) { | 592 | if (rev < 0x20) { |
597 | port_info[0] = port_info[1] = &info_early; | 593 | ppi[0] = &info_early; |
598 | } else if (rev < 0xC2) { | 594 | } else if (rev < 0xC2) { |
599 | port_info[0] = port_info[1] = &info_20; | 595 | ppi[0] = &info_20; |
600 | } else if (rev == 0xC2) { | 596 | } else if (rev == 0xC2) { |
601 | port_info[0] = port_info[1] = &info_c2; | 597 | ppi[0] = &info_c2; |
602 | } else if (rev == 0xC3) { | 598 | } else if (rev == 0xC3) { |
603 | port_info[0] = port_info[1] = &info_c3; | 599 | ppi[0] = &info_c3; |
604 | } else if (rev == 0xC4) { | 600 | } else if (rev == 0xC4) { |
605 | port_info[0] = port_info[1] = &info_c4; | 601 | ppi[0] = &info_c4; |
606 | } else | 602 | } else |
607 | port_info[0] = port_info[1] = &info_c5; | 603 | ppi[0] = &info_c5; |
608 | 604 | ||
609 | ali_init_chipset(pdev); | 605 | ali_init_chipset(pdev); |
610 | 606 | ||
@@ -613,10 +609,10 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
613 | /* Are we paired with a UDMA capable chip */ | 609 | /* Are we paired with a UDMA capable chip */ |
614 | pci_read_config_byte(isa_bridge, 0x5E, &tmp); | 610 | pci_read_config_byte(isa_bridge, 0x5E, &tmp); |
615 | if ((tmp & 0x1E) == 0x12) | 611 | if ((tmp & 0x1E) == 0x12) |
616 | port_info[0] = port_info[1] = &info_20_udma; | 612 | ppi[0] = &info_20_udma; |
617 | pci_dev_put(isa_bridge); | 613 | pci_dev_put(isa_bridge); |
618 | } | 614 | } |
619 | return ata_pci_init_one(pdev, port_info, 2); | 615 | return ata_pci_init_one(pdev, ppi); |
620 | } | 616 | } |
621 | 617 | ||
622 | #ifdef CONFIG_PM | 618 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c index 67c7e87dec04..b439351f1fd3 100644 --- a/drivers/ata/pata_amd.c +++ b/drivers/ata/pata_amd.c | |||
@@ -324,10 +324,6 @@ static struct scsi_host_template amd_sht = { | |||
324 | .slave_configure = ata_scsi_slave_config, | 324 | .slave_configure = ata_scsi_slave_config, |
325 | .slave_destroy = ata_scsi_slave_destroy, | 325 | .slave_destroy = ata_scsi_slave_destroy, |
326 | .bios_param = ata_std_bios_param, | 326 | .bios_param = ata_std_bios_param, |
327 | #ifdef CONFIG_PM | ||
328 | .resume = ata_scsi_device_resume, | ||
329 | .suspend = ata_scsi_device_suspend, | ||
330 | #endif | ||
331 | }; | 327 | }; |
332 | 328 | ||
333 | static struct ata_port_operations amd33_port_ops = { | 329 | static struct ata_port_operations amd33_port_ops = { |
@@ -542,7 +538,7 @@ static struct ata_port_operations nv133_port_ops = { | |||
542 | 538 | ||
543 | static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 539 | static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
544 | { | 540 | { |
545 | static struct ata_port_info info[10] = { | 541 | static const struct ata_port_info info[10] = { |
546 | { /* 0: AMD 7401 */ | 542 | { /* 0: AMD 7401 */ |
547 | .sht = &amd_sht, | 543 | .sht = &amd_sht, |
548 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 544 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -624,7 +620,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
624 | .port_ops = &amd100_port_ops | 620 | .port_ops = &amd100_port_ops |
625 | } | 621 | } |
626 | }; | 622 | }; |
627 | static struct ata_port_info *port_info[2]; | 623 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
628 | static int printed_version; | 624 | static int printed_version; |
629 | int type = id->driver_data; | 625 | int type = id->driver_data; |
630 | u8 rev; | 626 | u8 rev; |
@@ -656,9 +652,8 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
656 | ata_pci_clear_simplex(pdev); | 652 | ata_pci_clear_simplex(pdev); |
657 | 653 | ||
658 | /* And fire it up */ | 654 | /* And fire it up */ |
659 | 655 | ppi[0] = &info[type]; | |
660 | port_info[0] = port_info[1] = &info[type]; | 656 | return ata_pci_init_one(pdev, ppi); |
661 | return ata_pci_init_one(pdev, port_info, 2); | ||
662 | } | 657 | } |
663 | 658 | ||
664 | #ifdef CONFIG_PM | 659 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c index ef51940c3adb..9861059dd673 100644 --- a/drivers/ata/pata_artop.c +++ b/drivers/ata/pata_artop.c | |||
@@ -414,7 +414,7 @@ static const struct ata_port_operations artop6260_ops = { | |||
414 | static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | 414 | static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) |
415 | { | 415 | { |
416 | static int printed_version; | 416 | static int printed_version; |
417 | static struct ata_port_info info_6210 = { | 417 | static const struct ata_port_info info_6210 = { |
418 | .sht = &artop_sht, | 418 | .sht = &artop_sht, |
419 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 419 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
420 | .pio_mask = 0x1f, /* pio0-4 */ | 420 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -422,7 +422,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | |||
422 | .udma_mask = ATA_UDMA2, | 422 | .udma_mask = ATA_UDMA2, |
423 | .port_ops = &artop6210_ops, | 423 | .port_ops = &artop6210_ops, |
424 | }; | 424 | }; |
425 | static struct ata_port_info info_626x = { | 425 | static const struct ata_port_info info_626x = { |
426 | .sht = &artop_sht, | 426 | .sht = &artop_sht, |
427 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 427 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
428 | .pio_mask = 0x1f, /* pio0-4 */ | 428 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -430,7 +430,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | |||
430 | .udma_mask = ATA_UDMA4, | 430 | .udma_mask = ATA_UDMA4, |
431 | .port_ops = &artop6260_ops, | 431 | .port_ops = &artop6260_ops, |
432 | }; | 432 | }; |
433 | static struct ata_port_info info_626x_fast = { | 433 | static const struct ata_port_info info_626x_fast = { |
434 | .sht = &artop_sht, | 434 | .sht = &artop_sht, |
435 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 435 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
436 | .pio_mask = 0x1f, /* pio0-4 */ | 436 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -438,32 +438,30 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | |||
438 | .udma_mask = ATA_UDMA5, | 438 | .udma_mask = ATA_UDMA5, |
439 | .port_ops = &artop6260_ops, | 439 | .port_ops = &artop6260_ops, |
440 | }; | 440 | }; |
441 | struct ata_port_info *port_info[2]; | 441 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
442 | struct ata_port_info *info = NULL; | ||
443 | int ports = 2; | ||
444 | 442 | ||
445 | if (!printed_version++) | 443 | if (!printed_version++) |
446 | dev_printk(KERN_DEBUG, &pdev->dev, | 444 | dev_printk(KERN_DEBUG, &pdev->dev, |
447 | "version " DRV_VERSION "\n"); | 445 | "version " DRV_VERSION "\n"); |
448 | 446 | ||
449 | if (id->driver_data == 0) { /* 6210 variant */ | 447 | if (id->driver_data == 0) { /* 6210 variant */ |
450 | info = &info_6210; | 448 | ppi[0] = &info_6210; |
449 | ppi[1] = &ata_dummy_port_info; | ||
451 | /* BIOS may have left us in UDMA, clear it before libata probe */ | 450 | /* BIOS may have left us in UDMA, clear it before libata probe */ |
452 | pci_write_config_byte(pdev, 0x54, 0); | 451 | pci_write_config_byte(pdev, 0x54, 0); |
453 | /* For the moment (also lacks dsc) */ | 452 | /* For the moment (also lacks dsc) */ |
454 | printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); | 453 | printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); |
455 | printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); | 454 | printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); |
456 | ports = 1; | ||
457 | } | 455 | } |
458 | else if (id->driver_data == 1) /* 6260 */ | 456 | else if (id->driver_data == 1) /* 6260 */ |
459 | info = &info_626x; | 457 | ppi[0] = &info_626x; |
460 | else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ | 458 | else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ |
461 | unsigned long io = pci_resource_start(pdev, 4); | 459 | unsigned long io = pci_resource_start(pdev, 4); |
462 | u8 reg; | 460 | u8 reg; |
463 | 461 | ||
464 | info = &info_626x; | 462 | ppi[0] = &info_626x; |
465 | if (inb(io) & 0x10) | 463 | if (inb(io) & 0x10) |
466 | info = &info_626x_fast; | 464 | ppi[0] = &info_626x_fast; |
467 | /* Mac systems come up with some registers not set as we | 465 | /* Mac systems come up with some registers not set as we |
468 | will need them */ | 466 | will need them */ |
469 | 467 | ||
@@ -484,10 +482,9 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | |||
484 | 482 | ||
485 | } | 483 | } |
486 | 484 | ||
487 | BUG_ON(info == NULL); | 485 | BUG_ON(ppi[0] == NULL); |
488 | 486 | ||
489 | port_info[0] = port_info[1] = info; | 487 | return ata_pci_init_one(pdev, ppi); |
490 | return ata_pci_init_one(pdev, port_info, ports); | ||
491 | } | 488 | } |
492 | 489 | ||
493 | static const struct pci_device_id artop_pci_tbl[] = { | 490 | static const struct pci_device_id artop_pci_tbl[] = { |
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c index 21515381b5b3..844914681a2a 100644 --- a/drivers/ata/pata_atiixp.c +++ b/drivers/ata/pata_atiixp.c | |||
@@ -229,10 +229,6 @@ static struct scsi_host_template atiixp_sht = { | |||
229 | .slave_configure = ata_scsi_slave_config, | 229 | .slave_configure = ata_scsi_slave_config, |
230 | .slave_destroy = ata_scsi_slave_destroy, | 230 | .slave_destroy = ata_scsi_slave_destroy, |
231 | .bios_param = ata_std_bios_param, | 231 | .bios_param = ata_std_bios_param, |
232 | #ifdef CONFIG_PM | ||
233 | .resume = ata_scsi_device_resume, | ||
234 | .suspend = ata_scsi_device_suspend, | ||
235 | #endif | ||
236 | }; | 232 | }; |
237 | 233 | ||
238 | static struct ata_port_operations atiixp_port_ops = { | 234 | static struct ata_port_operations atiixp_port_ops = { |
@@ -272,7 +268,7 @@ static struct ata_port_operations atiixp_port_ops = { | |||
272 | 268 | ||
273 | static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 269 | static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
274 | { | 270 | { |
275 | static struct ata_port_info info = { | 271 | static const struct ata_port_info info = { |
276 | .sht = &atiixp_sht, | 272 | .sht = &atiixp_sht, |
277 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 273 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
278 | .pio_mask = 0x1f, | 274 | .pio_mask = 0x1f, |
@@ -280,8 +276,8 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
280 | .udma_mask = 0x3F, | 276 | .udma_mask = 0x3F, |
281 | .port_ops = &atiixp_port_ops | 277 | .port_ops = &atiixp_port_ops |
282 | }; | 278 | }; |
283 | static struct ata_port_info *port_info[2] = { &info, &info }; | 279 | const struct ata_port_info *ppi[] = { &info, NULL }; |
284 | return ata_pci_init_one(dev, port_info, 2); | 280 | return ata_pci_init_one(dev, ppi); |
285 | } | 281 | } |
286 | 282 | ||
287 | static const struct pci_device_id atiixp[] = { | 283 | static const struct pci_device_id atiixp[] = { |
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c index 2105985a8013..ed00fa9d53be 100644 --- a/drivers/ata/pata_cmd640.c +++ b/drivers/ata/pata_cmd640.c | |||
@@ -181,10 +181,6 @@ static struct scsi_host_template cmd640_sht = { | |||
181 | .slave_configure = ata_scsi_slave_config, | 181 | .slave_configure = ata_scsi_slave_config, |
182 | .slave_destroy = ata_scsi_slave_destroy, | 182 | .slave_destroy = ata_scsi_slave_destroy, |
183 | .bios_param = ata_std_bios_param, | 183 | .bios_param = ata_std_bios_param, |
184 | #ifdef CONFIG_PM | ||
185 | .resume = ata_scsi_device_resume, | ||
186 | .suspend = ata_scsi_device_suspend, | ||
187 | #endif | ||
188 | }; | 184 | }; |
189 | 185 | ||
190 | static struct ata_port_operations cmd640_port_ops = { | 186 | static struct ata_port_operations cmd640_port_ops = { |
@@ -253,17 +249,16 @@ static void cmd640_hardware_init(struct pci_dev *pdev) | |||
253 | 249 | ||
254 | static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 250 | static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
255 | { | 251 | { |
256 | static struct ata_port_info info = { | 252 | static const struct ata_port_info info = { |
257 | .sht = &cmd640_sht, | 253 | .sht = &cmd640_sht, |
258 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 254 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
259 | .pio_mask = 0x1f, | 255 | .pio_mask = 0x1f, |
260 | .port_ops = &cmd640_port_ops | 256 | .port_ops = &cmd640_port_ops |
261 | }; | 257 | }; |
262 | 258 | const struct ata_port_info *ppi[] = { &info, NULL }; | |
263 | static struct ata_port_info *port_info[2] = { &info, &info }; | ||
264 | 259 | ||
265 | cmd640_hardware_init(pdev); | 260 | cmd640_hardware_init(pdev); |
266 | return ata_pci_init_one(pdev, port_info, 2); | 261 | return ata_pci_init_one(pdev, ppi); |
267 | } | 262 | } |
268 | 263 | ||
269 | static int cmd640_reinit_one(struct pci_dev *pdev) | 264 | static int cmd640_reinit_one(struct pci_dev *pdev) |
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c index 3989cc577fcd..2a79b335cfcc 100644 --- a/drivers/ata/pata_cmd64x.c +++ b/drivers/ata/pata_cmd64x.c | |||
@@ -266,10 +266,6 @@ static struct scsi_host_template cmd64x_sht = { | |||
266 | .slave_configure = ata_scsi_slave_config, | 266 | .slave_configure = ata_scsi_slave_config, |
267 | .slave_destroy = ata_scsi_slave_destroy, | 267 | .slave_destroy = ata_scsi_slave_destroy, |
268 | .bios_param = ata_std_bios_param, | 268 | .bios_param = ata_std_bios_param, |
269 | #ifdef CONFIG_PM | ||
270 | .resume = ata_scsi_device_resume, | ||
271 | .suspend = ata_scsi_device_suspend, | ||
272 | #endif | ||
273 | }; | 269 | }; |
274 | 270 | ||
275 | static struct ata_port_operations cmd64x_port_ops = { | 271 | static struct ata_port_operations cmd64x_port_ops = { |
@@ -381,7 +377,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
381 | { | 377 | { |
382 | u32 class_rev; | 378 | u32 class_rev; |
383 | 379 | ||
384 | static struct ata_port_info cmd_info[6] = { | 380 | static const struct ata_port_info cmd_info[6] = { |
385 | { /* CMD 643 - no UDMA */ | 381 | { /* CMD 643 - no UDMA */ |
386 | .sht = &cmd64x_sht, | 382 | .sht = &cmd64x_sht, |
387 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 383 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -428,11 +424,9 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
428 | .port_ops = &cmd648_port_ops | 424 | .port_ops = &cmd648_port_ops |
429 | } | 425 | } |
430 | }; | 426 | }; |
431 | static struct ata_port_info *port_info[2], *info; | 427 | const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL }; |
432 | u8 mrdmode; | 428 | u8 mrdmode; |
433 | 429 | ||
434 | info = &cmd_info[id->driver_data]; | ||
435 | |||
436 | pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); | 430 | pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); |
437 | class_rev &= 0xFF; | 431 | class_rev &= 0xFF; |
438 | 432 | ||
@@ -442,10 +436,10 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
442 | if (pdev->device == PCI_DEVICE_ID_CMD_646) { | 436 | if (pdev->device == PCI_DEVICE_ID_CMD_646) { |
443 | /* Does UDMA work ? */ | 437 | /* Does UDMA work ? */ |
444 | if (class_rev > 4) | 438 | if (class_rev > 4) |
445 | info = &cmd_info[2]; | 439 | ppi[0] = &cmd_info[2]; |
446 | /* Early rev with other problems ? */ | 440 | /* Early rev with other problems ? */ |
447 | else if (class_rev == 1) | 441 | else if (class_rev == 1) |
448 | info = &cmd_info[3]; | 442 | ppi[0] = &cmd_info[3]; |
449 | } | 443 | } |
450 | 444 | ||
451 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); | 445 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); |
@@ -461,8 +455,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
461 | pci_write_config_byte(pdev, UDIDETCR0, 0xF0); | 455 | pci_write_config_byte(pdev, UDIDETCR0, 0xF0); |
462 | #endif | 456 | #endif |
463 | 457 | ||
464 | port_info[0] = port_info[1] = info; | 458 | return ata_pci_init_one(pdev, ppi); |
465 | return ata_pci_init_one(pdev, port_info, 2); | ||
466 | } | 459 | } |
467 | 460 | ||
468 | #ifdef CONFIG_PM | 461 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c index 79bef0d1fad3..83bcc5b32597 100644 --- a/drivers/ata/pata_cs5520.c +++ b/drivers/ata/pata_cs5520.c | |||
@@ -155,10 +155,6 @@ static struct scsi_host_template cs5520_sht = { | |||
155 | .slave_configure = ata_scsi_slave_config, | 155 | .slave_configure = ata_scsi_slave_config, |
156 | .slave_destroy = ata_scsi_slave_destroy, | 156 | .slave_destroy = ata_scsi_slave_destroy, |
157 | .bios_param = ata_std_bios_param, | 157 | .bios_param = ata_std_bios_param, |
158 | #ifdef CONFIG_PM | ||
159 | .resume = ata_scsi_device_resume, | ||
160 | .suspend = ata_scsi_device_suspend, | ||
161 | #endif | ||
162 | }; | 158 | }; |
163 | 159 | ||
164 | static struct ata_port_operations cs5520_port_ops = { | 160 | static struct ata_port_operations cs5520_port_ops = { |
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c index 29642d5ee189..1b67923d7a4e 100644 --- a/drivers/ata/pata_cs5530.c +++ b/drivers/ata/pata_cs5530.c | |||
@@ -176,10 +176,6 @@ static struct scsi_host_template cs5530_sht = { | |||
176 | .slave_configure = ata_scsi_slave_config, | 176 | .slave_configure = ata_scsi_slave_config, |
177 | .slave_destroy = ata_scsi_slave_destroy, | 177 | .slave_destroy = ata_scsi_slave_destroy, |
178 | .bios_param = ata_std_bios_param, | 178 | .bios_param = ata_std_bios_param, |
179 | #ifdef CONFIG_PM | ||
180 | .resume = ata_scsi_device_resume, | ||
181 | .suspend = ata_scsi_device_suspend, | ||
182 | #endif | ||
183 | }; | 179 | }; |
184 | 180 | ||
185 | static struct ata_port_operations cs5530_port_ops = { | 181 | static struct ata_port_operations cs5530_port_ops = { |
@@ -339,7 +335,7 @@ fail_put: | |||
339 | 335 | ||
340 | static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 336 | static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
341 | { | 337 | { |
342 | static struct ata_port_info info = { | 338 | static const struct ata_port_info info = { |
343 | .sht = &cs5530_sht, | 339 | .sht = &cs5530_sht, |
344 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 340 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
345 | .pio_mask = 0x1f, | 341 | .pio_mask = 0x1f, |
@@ -348,23 +344,23 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
348 | .port_ops = &cs5530_port_ops | 344 | .port_ops = &cs5530_port_ops |
349 | }; | 345 | }; |
350 | /* The docking connector doesn't do UDMA, and it seems not MWDMA */ | 346 | /* The docking connector doesn't do UDMA, and it seems not MWDMA */ |
351 | static struct ata_port_info info_palmax_secondary = { | 347 | static const struct ata_port_info info_palmax_secondary = { |
352 | .sht = &cs5530_sht, | 348 | .sht = &cs5530_sht, |
353 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 349 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
354 | .pio_mask = 0x1f, | 350 | .pio_mask = 0x1f, |
355 | .port_ops = &cs5530_port_ops | 351 | .port_ops = &cs5530_port_ops |
356 | }; | 352 | }; |
357 | static struct ata_port_info *port_info[2] = { &info, &info }; | 353 | const struct ata_port_info *ppi[] = { &info, NULL }; |
358 | 354 | ||
359 | /* Chip initialisation */ | 355 | /* Chip initialisation */ |
360 | if (cs5530_init_chip()) | 356 | if (cs5530_init_chip()) |
361 | return -ENODEV; | 357 | return -ENODEV; |
362 | 358 | ||
363 | if (cs5530_is_palmax()) | 359 | if (cs5530_is_palmax()) |
364 | port_info[1] = &info_palmax_secondary; | 360 | ppi[1] = &info_palmax_secondary; |
365 | 361 | ||
366 | /* Now kick off ATA set up */ | 362 | /* Now kick off ATA set up */ |
367 | return ata_pci_init_one(pdev, port_info, 2); | 363 | return ata_pci_init_one(pdev, ppi); |
368 | } | 364 | } |
369 | 365 | ||
370 | #ifdef CONFIG_PM | 366 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c index 22006ae71941..f37d4cd812a1 100644 --- a/drivers/ata/pata_cs5535.c +++ b/drivers/ata/pata_cs5535.c | |||
@@ -173,10 +173,6 @@ static struct scsi_host_template cs5535_sht = { | |||
173 | .slave_configure = ata_scsi_slave_config, | 173 | .slave_configure = ata_scsi_slave_config, |
174 | .slave_destroy = ata_scsi_slave_destroy, | 174 | .slave_destroy = ata_scsi_slave_destroy, |
175 | .bios_param = ata_std_bios_param, | 175 | .bios_param = ata_std_bios_param, |
176 | #ifdef CONFIG_PM | ||
177 | .resume = ata_scsi_device_resume, | ||
178 | .suspend = ata_scsi_device_suspend, | ||
179 | #endif | ||
180 | }; | 176 | }; |
181 | 177 | ||
182 | static struct ata_port_operations cs5535_port_ops = { | 178 | static struct ata_port_operations cs5535_port_ops = { |
@@ -227,7 +223,7 @@ static struct ata_port_operations cs5535_port_ops = { | |||
227 | 223 | ||
228 | static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 224 | static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
229 | { | 225 | { |
230 | static struct ata_port_info info = { | 226 | static const struct ata_port_info info = { |
231 | .sht = &cs5535_sht, | 227 | .sht = &cs5535_sht, |
232 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 228 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
233 | .pio_mask = 0x1f, | 229 | .pio_mask = 0x1f, |
@@ -235,7 +231,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
235 | .udma_mask = 0x1f, | 231 | .udma_mask = 0x1f, |
236 | .port_ops = &cs5535_port_ops | 232 | .port_ops = &cs5535_port_ops |
237 | }; | 233 | }; |
238 | struct ata_port_info *ports[1] = { &info }; | 234 | const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; |
239 | 235 | ||
240 | u32 timings, dummy; | 236 | u32 timings, dummy; |
241 | 237 | ||
@@ -247,7 +243,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
247 | rdmsr(ATAC_CH0D1_PIO, timings, dummy); | 243 | rdmsr(ATAC_CH0D1_PIO, timings, dummy); |
248 | if (CS5535_BAD_PIO(timings)) | 244 | if (CS5535_BAD_PIO(timings)) |
249 | wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); | 245 | wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); |
250 | return ata_pci_init_one(dev, ports, 1); | 246 | return ata_pci_init_one(dev, ppi); |
251 | } | 247 | } |
252 | 248 | ||
253 | static const struct pci_device_id cs5535[] = { | 249 | static const struct pci_device_id cs5535[] = { |
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c index 6ec049c3b1dc..27b9f29c01e3 100644 --- a/drivers/ata/pata_cypress.c +++ b/drivers/ata/pata_cypress.c | |||
@@ -125,10 +125,6 @@ static struct scsi_host_template cy82c693_sht = { | |||
125 | .slave_configure = ata_scsi_slave_config, | 125 | .slave_configure = ata_scsi_slave_config, |
126 | .slave_destroy = ata_scsi_slave_destroy, | 126 | .slave_destroy = ata_scsi_slave_destroy, |
127 | .bios_param = ata_std_bios_param, | 127 | .bios_param = ata_std_bios_param, |
128 | #ifdef CONFIG_PM | ||
129 | .resume = ata_scsi_device_resume, | ||
130 | .suspend = ata_scsi_device_suspend, | ||
131 | #endif | ||
132 | }; | 128 | }; |
133 | 129 | ||
134 | static struct ata_port_operations cy82c693_port_ops = { | 130 | static struct ata_port_operations cy82c693_port_ops = { |
@@ -169,14 +165,14 @@ static struct ata_port_operations cy82c693_port_ops = { | |||
169 | 165 | ||
170 | static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 166 | static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
171 | { | 167 | { |
172 | static struct ata_port_info info = { | 168 | static const struct ata_port_info info = { |
173 | .sht = &cy82c693_sht, | 169 | .sht = &cy82c693_sht, |
174 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 170 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
175 | .pio_mask = 0x1f, | 171 | .pio_mask = 0x1f, |
176 | .mwdma_mask = 0x07, | 172 | .mwdma_mask = 0x07, |
177 | .port_ops = &cy82c693_port_ops | 173 | .port_ops = &cy82c693_port_ops |
178 | }; | 174 | }; |
179 | static struct ata_port_info *port_info[1] = { &info }; | 175 | const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; |
180 | 176 | ||
181 | /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2. | 177 | /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2. |
182 | For the moment we don't handle the secondary. FIXME */ | 178 | For the moment we don't handle the secondary. FIXME */ |
@@ -184,7 +180,7 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i | |||
184 | if (PCI_FUNC(pdev->devfn) != 1) | 180 | if (PCI_FUNC(pdev->devfn) != 1) |
185 | return -ENODEV; | 181 | return -ENODEV; |
186 | 182 | ||
187 | return ata_pci_init_one(pdev, port_info, 1); | 183 | return ata_pci_init_one(pdev, ppi); |
188 | } | 184 | } |
189 | 185 | ||
190 | static const struct pci_device_id cy82c693[] = { | 186 | static const struct pci_device_id cy82c693[] = { |
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c index d0f52e034906..079248a9b460 100644 --- a/drivers/ata/pata_efar.c +++ b/drivers/ata/pata_efar.c | |||
@@ -247,10 +247,6 @@ static struct scsi_host_template efar_sht = { | |||
247 | .slave_configure = ata_scsi_slave_config, | 247 | .slave_configure = ata_scsi_slave_config, |
248 | .slave_destroy = ata_scsi_slave_destroy, | 248 | .slave_destroy = ata_scsi_slave_destroy, |
249 | .bios_param = ata_std_bios_param, | 249 | .bios_param = ata_std_bios_param, |
250 | #ifdef CONFIG_PM | ||
251 | .resume = ata_scsi_device_resume, | ||
252 | .suspend = ata_scsi_device_suspend, | ||
253 | #endif | ||
254 | }; | 250 | }; |
255 | 251 | ||
256 | static const struct ata_port_operations efar_ops = { | 252 | static const struct ata_port_operations efar_ops = { |
@@ -305,7 +301,7 @@ static const struct ata_port_operations efar_ops = { | |||
305 | static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 301 | static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
306 | { | 302 | { |
307 | static int printed_version; | 303 | static int printed_version; |
308 | static struct ata_port_info info = { | 304 | static const struct ata_port_info info = { |
309 | .sht = &efar_sht, | 305 | .sht = &efar_sht, |
310 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 306 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
311 | .pio_mask = 0x1f, /* pio0-4 */ | 307 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -313,13 +309,13 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
313 | .udma_mask = 0x0f, /* UDMA 66 */ | 309 | .udma_mask = 0x0f, /* UDMA 66 */ |
314 | .port_ops = &efar_ops, | 310 | .port_ops = &efar_ops, |
315 | }; | 311 | }; |
316 | static struct ata_port_info *port_info[2] = { &info, &info }; | 312 | const struct ata_port_info *ppi[] = { &info, NULL }; |
317 | 313 | ||
318 | if (!printed_version++) | 314 | if (!printed_version++) |
319 | dev_printk(KERN_DEBUG, &pdev->dev, | 315 | dev_printk(KERN_DEBUG, &pdev->dev, |
320 | "version " DRV_VERSION "\n"); | 316 | "version " DRV_VERSION "\n"); |
321 | 317 | ||
322 | return ata_pci_init_one(pdev, port_info, 2); | 318 | return ata_pci_init_one(pdev, ppi); |
323 | } | 319 | } |
324 | 320 | ||
325 | static const struct pci_device_id efar_pci_tbl[] = { | 321 | static const struct pci_device_id efar_pci_tbl[] = { |
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index e64e05e5c7fe..c6c8a8bb06d0 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c | |||
@@ -331,10 +331,6 @@ static struct scsi_host_template hpt36x_sht = { | |||
331 | .slave_configure = ata_scsi_slave_config, | 331 | .slave_configure = ata_scsi_slave_config, |
332 | .slave_destroy = ata_scsi_slave_destroy, | 332 | .slave_destroy = ata_scsi_slave_destroy, |
333 | .bios_param = ata_std_bios_param, | 333 | .bios_param = ata_std_bios_param, |
334 | #ifdef CONFIG_PM | ||
335 | .resume = ata_scsi_device_resume, | ||
336 | .suspend = ata_scsi_device_suspend, | ||
337 | #endif | ||
338 | }; | 334 | }; |
339 | 335 | ||
340 | /* | 336 | /* |
@@ -421,7 +417,7 @@ static void hpt36x_init_chipset(struct pci_dev *dev) | |||
421 | 417 | ||
422 | static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 418 | static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
423 | { | 419 | { |
424 | static struct ata_port_info info_hpt366 = { | 420 | static const struct ata_port_info info_hpt366 = { |
425 | .sht = &hpt36x_sht, | 421 | .sht = &hpt36x_sht, |
426 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 422 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
427 | .pio_mask = 0x1f, | 423 | .pio_mask = 0x1f, |
@@ -429,7 +425,8 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
429 | .udma_mask = 0x1f, | 425 | .udma_mask = 0x1f, |
430 | .port_ops = &hpt366_port_ops | 426 | .port_ops = &hpt366_port_ops |
431 | }; | 427 | }; |
432 | struct ata_port_info *port_info[2] = {&info_hpt366, &info_hpt366}; | 428 | struct ata_port_info info = info_hpt366; |
429 | const struct ata_port_info *ppi[] = { &info, NULL }; | ||
433 | 430 | ||
434 | u32 class_rev; | 431 | u32 class_rev; |
435 | u32 reg1; | 432 | u32 reg1; |
@@ -450,17 +447,17 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
450 | /* info_hpt366 is safe against re-entry so we can scribble on it */ | 447 | /* info_hpt366 is safe against re-entry so we can scribble on it */ |
451 | switch((reg1 & 0x700) >> 8) { | 448 | switch((reg1 & 0x700) >> 8) { |
452 | case 5: | 449 | case 5: |
453 | info_hpt366.private_data = &hpt366_40; | 450 | info.private_data = &hpt366_40; |
454 | break; | 451 | break; |
455 | case 9: | 452 | case 9: |
456 | info_hpt366.private_data = &hpt366_25; | 453 | info.private_data = &hpt366_25; |
457 | break; | 454 | break; |
458 | default: | 455 | default: |
459 | info_hpt366.private_data = &hpt366_33; | 456 | info.private_data = &hpt366_33; |
460 | break; | 457 | break; |
461 | } | 458 | } |
462 | /* Now kick off ATA set up */ | 459 | /* Now kick off ATA set up */ |
463 | return ata_pci_init_one(dev, port_info, 2); | 460 | return ata_pci_init_one(dev, ppi); |
464 | } | 461 | } |
465 | 462 | ||
466 | #ifdef CONFIG_PM | 463 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 1614e8c822a4..5a0a410654e2 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c | |||
@@ -887,7 +887,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev) | |||
887 | static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 887 | static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
888 | { | 888 | { |
889 | /* HPT370 - UDMA100 */ | 889 | /* HPT370 - UDMA100 */ |
890 | static struct ata_port_info info_hpt370 = { | 890 | static const struct ata_port_info info_hpt370 = { |
891 | .sht = &hpt37x_sht, | 891 | .sht = &hpt37x_sht, |
892 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 892 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
893 | .pio_mask = 0x1f, | 893 | .pio_mask = 0x1f, |
@@ -896,7 +896,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
896 | .port_ops = &hpt370_port_ops | 896 | .port_ops = &hpt370_port_ops |
897 | }; | 897 | }; |
898 | /* HPT370A - UDMA100 */ | 898 | /* HPT370A - UDMA100 */ |
899 | static struct ata_port_info info_hpt370a = { | 899 | static const struct ata_port_info info_hpt370a = { |
900 | .sht = &hpt37x_sht, | 900 | .sht = &hpt37x_sht, |
901 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 901 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
902 | .pio_mask = 0x1f, | 902 | .pio_mask = 0x1f, |
@@ -905,7 +905,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
905 | .port_ops = &hpt370a_port_ops | 905 | .port_ops = &hpt370a_port_ops |
906 | }; | 906 | }; |
907 | /* HPT370 - UDMA100 */ | 907 | /* HPT370 - UDMA100 */ |
908 | static struct ata_port_info info_hpt370_33 = { | 908 | static const struct ata_port_info info_hpt370_33 = { |
909 | .sht = &hpt37x_sht, | 909 | .sht = &hpt37x_sht, |
910 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 910 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
911 | .pio_mask = 0x1f, | 911 | .pio_mask = 0x1f, |
@@ -914,7 +914,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
914 | .port_ops = &hpt370_port_ops | 914 | .port_ops = &hpt370_port_ops |
915 | }; | 915 | }; |
916 | /* HPT370A - UDMA100 */ | 916 | /* HPT370A - UDMA100 */ |
917 | static struct ata_port_info info_hpt370a_33 = { | 917 | static const struct ata_port_info info_hpt370a_33 = { |
918 | .sht = &hpt37x_sht, | 918 | .sht = &hpt37x_sht, |
919 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 919 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
920 | .pio_mask = 0x1f, | 920 | .pio_mask = 0x1f, |
@@ -923,7 +923,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
923 | .port_ops = &hpt370a_port_ops | 923 | .port_ops = &hpt370a_port_ops |
924 | }; | 924 | }; |
925 | /* HPT371, 372 and friends - UDMA133 */ | 925 | /* HPT371, 372 and friends - UDMA133 */ |
926 | static struct ata_port_info info_hpt372 = { | 926 | static const struct ata_port_info info_hpt372 = { |
927 | .sht = &hpt37x_sht, | 927 | .sht = &hpt37x_sht, |
928 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 928 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
929 | .pio_mask = 0x1f, | 929 | .pio_mask = 0x1f, |
@@ -932,7 +932,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
932 | .port_ops = &hpt372_port_ops | 932 | .port_ops = &hpt372_port_ops |
933 | }; | 933 | }; |
934 | /* HPT371, 372 and friends - UDMA100 at 50MHz clock */ | 934 | /* HPT371, 372 and friends - UDMA100 at 50MHz clock */ |
935 | static struct ata_port_info info_hpt372_50 = { | 935 | static const struct ata_port_info info_hpt372_50 = { |
936 | .sht = &hpt37x_sht, | 936 | .sht = &hpt37x_sht, |
937 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 937 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
938 | .pio_mask = 0x1f, | 938 | .pio_mask = 0x1f, |
@@ -941,7 +941,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
941 | .port_ops = &hpt372_port_ops | 941 | .port_ops = &hpt372_port_ops |
942 | }; | 942 | }; |
943 | /* HPT374 - UDMA133 */ | 943 | /* HPT374 - UDMA133 */ |
944 | static struct ata_port_info info_hpt374 = { | 944 | static const struct ata_port_info info_hpt374 = { |
945 | .sht = &hpt37x_sht, | 945 | .sht = &hpt37x_sht, |
946 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 946 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
947 | .pio_mask = 0x1f, | 947 | .pio_mask = 0x1f, |
@@ -951,9 +951,10 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
951 | }; | 951 | }; |
952 | 952 | ||
953 | static const int MHz[4] = { 33, 40, 50, 66 }; | 953 | static const int MHz[4] = { 33, 40, 50, 66 }; |
954 | 954 | const struct ata_port_info *port; | |
955 | struct ata_port_info *port_info[2]; | 955 | void *private_data = NULL; |
956 | struct ata_port_info *port; | 956 | struct ata_port_info port_info; |
957 | const struct ata_port_info *ppi[] = { &port_info, NULL }; | ||
957 | 958 | ||
958 | u8 irqmask; | 959 | u8 irqmask; |
959 | u32 class_rev; | 960 | u32 class_rev; |
@@ -1124,13 +1125,13 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1124 | return -ENODEV; | 1125 | return -ENODEV; |
1125 | } | 1126 | } |
1126 | if (clock_slot == 3) | 1127 | if (clock_slot == 3) |
1127 | port->private_data = (void *)hpt37x_timings_66; | 1128 | private_data = (void *)hpt37x_timings_66; |
1128 | else | 1129 | else |
1129 | port->private_data = (void *)hpt37x_timings_50; | 1130 | private_data = (void *)hpt37x_timings_50; |
1130 | 1131 | ||
1131 | printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); | 1132 | printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); |
1132 | } else { | 1133 | } else { |
1133 | port->private_data = (void *)chip_table->clocks[clock_slot]; | 1134 | private_data = (void *)chip_table->clocks[clock_slot]; |
1134 | /* | 1135 | /* |
1135 | * Perform a final fixup. Note that we will have used the | 1136 | * Perform a final fixup. Note that we will have used the |
1136 | * DPLL on the HPT372 which means we don't have to worry | 1137 | * DPLL on the HPT372 which means we don't have to worry |
@@ -1144,9 +1145,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1144 | printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); | 1145 | printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); |
1145 | } | 1146 | } |
1146 | 1147 | ||
1147 | port_info[0] = port_info[1] = port; | ||
1148 | /* Now kick off ATA set up */ | 1148 | /* Now kick off ATA set up */ |
1149 | return ata_pci_init_one(dev, port_info, 2); | 1149 | port_info = *port; |
1150 | port_info.private_data = private_data; | ||
1151 | |||
1152 | return ata_pci_init_one(dev, ppi); | ||
1150 | } | 1153 | } |
1151 | 1154 | ||
1152 | static const struct pci_device_id hpt37x[] = { | 1155 | static const struct pci_device_id hpt37x[] = { |
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c index ea1037d67860..f25154aed75d 100644 --- a/drivers/ata/pata_hpt3x2n.c +++ b/drivers/ata/pata_hpt3x2n.c | |||
@@ -488,7 +488,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev) | |||
488 | static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 488 | static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
489 | { | 489 | { |
490 | /* HPT372N and friends - UDMA133 */ | 490 | /* HPT372N and friends - UDMA133 */ |
491 | static struct ata_port_info info = { | 491 | static const struct ata_port_info info = { |
492 | .sht = &hpt3x2n_sht, | 492 | .sht = &hpt3x2n_sht, |
493 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 493 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
494 | .pio_mask = 0x1f, | 494 | .pio_mask = 0x1f, |
@@ -496,8 +496,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
496 | .udma_mask = 0x7f, | 496 | .udma_mask = 0x7f, |
497 | .port_ops = &hpt3x2n_port_ops | 497 | .port_ops = &hpt3x2n_port_ops |
498 | }; | 498 | }; |
499 | struct ata_port_info *port_info[2]; | 499 | struct ata_port_info port = info; |
500 | struct ata_port_info *port = &info; | 500 | const struct ata_port_info *ppi[] = { &port, NULL }; |
501 | 501 | ||
502 | u8 irqmask; | 502 | u8 irqmask; |
503 | u32 class_rev; | 503 | u32 class_rev; |
@@ -585,9 +585,9 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
585 | 585 | ||
586 | /* Set our private data up. We only need a few flags so we use | 586 | /* Set our private data up. We only need a few flags so we use |
587 | it directly */ | 587 | it directly */ |
588 | port->private_data = NULL; | 588 | port.private_data = NULL; |
589 | if (pci_mhz > 60) { | 589 | if (pci_mhz > 60) { |
590 | port->private_data = (void *)PCI66; | 590 | port.private_data = (void *)PCI66; |
591 | /* | 591 | /* |
592 | * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in | 592 | * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in |
593 | * the MISC. register to stretch the UltraDMA Tss timing. | 593 | * the MISC. register to stretch the UltraDMA Tss timing. |
@@ -598,8 +598,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
598 | } | 598 | } |
599 | 599 | ||
600 | /* Now kick off ATA set up */ | 600 | /* Now kick off ATA set up */ |
601 | port_info[0] = port_info[1] = port; | 601 | return ata_pci_init_one(dev, ppi); |
602 | return ata_pci_init_one(dev, port_info, 2); | ||
603 | } | 602 | } |
604 | 603 | ||
605 | static const struct pci_device_id hpt3x2n[] = { | 604 | static const struct pci_device_id hpt3x2n[] = { |
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c index ac28ec8c50aa..bbabe7902fbb 100644 --- a/drivers/ata/pata_hpt3x3.c +++ b/drivers/ata/pata_hpt3x3.c | |||
@@ -100,10 +100,6 @@ static struct scsi_host_template hpt3x3_sht = { | |||
100 | .slave_configure = ata_scsi_slave_config, | 100 | .slave_configure = ata_scsi_slave_config, |
101 | .slave_destroy = ata_scsi_slave_destroy, | 101 | .slave_destroy = ata_scsi_slave_destroy, |
102 | .bios_param = ata_std_bios_param, | 102 | .bios_param = ata_std_bios_param, |
103 | #ifdef CONFIG_PM | ||
104 | .resume = ata_scsi_device_resume, | ||
105 | .suspend = ata_scsi_device_suspend, | ||
106 | #endif | ||
107 | }; | 103 | }; |
108 | 104 | ||
109 | static struct ata_port_operations hpt3x3_port_ops = { | 105 | static struct ata_port_operations hpt3x3_port_ops = { |
@@ -175,7 +171,7 @@ static void hpt3x3_init_chipset(struct pci_dev *dev) | |||
175 | 171 | ||
176 | static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 172 | static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
177 | { | 173 | { |
178 | static struct ata_port_info info = { | 174 | static const struct ata_port_info info = { |
179 | .sht = &hpt3x3_sht, | 175 | .sht = &hpt3x3_sht, |
180 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 176 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
181 | .pio_mask = 0x1f, | 177 | .pio_mask = 0x1f, |
@@ -183,11 +179,11 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
183 | .udma_mask = 0x07, | 179 | .udma_mask = 0x07, |
184 | .port_ops = &hpt3x3_port_ops | 180 | .port_ops = &hpt3x3_port_ops |
185 | }; | 181 | }; |
186 | static struct ata_port_info *port_info[2] = { &info, &info }; | 182 | const struct ata_port_info *ppi[] = { &info, NULL }; |
187 | 183 | ||
188 | hpt3x3_init_chipset(dev); | 184 | hpt3x3_init_chipset(dev); |
189 | /* Now kick off ATA set up */ | 185 | /* Now kick off ATA set up */ |
190 | return ata_pci_init_one(dev, port_info, 2); | 186 | return ata_pci_init_one(dev, ppi); |
191 | } | 187 | } |
192 | 188 | ||
193 | #ifdef CONFIG_PM | 189 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c index dbc8ee2adcf0..c791a46df461 100644 --- a/drivers/ata/pata_icside.c +++ b/drivers/ata/pata_icside.c | |||
@@ -60,6 +60,18 @@ struct pata_icside_state { | |||
60 | struct scatterlist sg[PATA_ICSIDE_MAX_SG]; | 60 | struct scatterlist sg[PATA_ICSIDE_MAX_SG]; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | struct pata_icside_info { | ||
64 | struct pata_icside_state *state; | ||
65 | struct expansion_card *ec; | ||
66 | void __iomem *base; | ||
67 | void __iomem *irqaddr; | ||
68 | unsigned int irqmask; | ||
69 | const expansioncard_ops_t *irqops; | ||
70 | unsigned int mwdma_mask; | ||
71 | unsigned int nr_ports; | ||
72 | const struct portinfo *port[2]; | ||
73 | }; | ||
74 | |||
63 | #define ICS_TYPE_A3IN 0 | 75 | #define ICS_TYPE_A3IN 0 |
64 | #define ICS_TYPE_A3USER 1 | 76 | #define ICS_TYPE_A3USER 1 |
65 | #define ICS_TYPE_V6 3 | 77 | #define ICS_TYPE_V6 3 |
@@ -269,9 +281,10 @@ static u8 pata_icside_bmdma_status(struct ata_port *ap) | |||
269 | return readb(irq_port) & 1 ? ATA_DMA_INTR : 0; | 281 | return readb(irq_port) & 1 ? ATA_DMA_INTR : 0; |
270 | } | 282 | } |
271 | 283 | ||
272 | static int icside_dma_init(struct ata_probe_ent *ae, struct expansion_card *ec) | 284 | static int icside_dma_init(struct pata_icside_info *info) |
273 | { | 285 | { |
274 | struct pata_icside_state *state = ae->private_data; | 286 | struct pata_icside_state *state = info->state; |
287 | struct expansion_card *ec = info->ec; | ||
275 | int i; | 288 | int i; |
276 | 289 | ||
277 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 290 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
@@ -281,7 +294,7 @@ static int icside_dma_init(struct ata_probe_ent *ae, struct expansion_card *ec) | |||
281 | 294 | ||
282 | if (ec->dma != NO_DMA && !request_dma(ec->dma, DRV_NAME)) { | 295 | if (ec->dma != NO_DMA && !request_dma(ec->dma, DRV_NAME)) { |
283 | state->dma = ec->dma; | 296 | state->dma = ec->dma; |
284 | ae->mwdma_mask = 0x07; /* MW0..2 */ | 297 | info->mwdma_mask = 0x07; /* MW0..2 */ |
285 | } | 298 | } |
286 | 299 | ||
287 | return 0; | 300 | return 0; |
@@ -371,6 +384,8 @@ static struct ata_port_operations pata_icside_port_ops = { | |||
371 | .check_status = ata_check_status, | 384 | .check_status = ata_check_status, |
372 | .dev_select = ata_std_dev_select, | 385 | .dev_select = ata_std_dev_select, |
373 | 386 | ||
387 | .cable_detect = ata_cable_40wire, | ||
388 | |||
374 | .bmdma_setup = pata_icside_bmdma_setup, | 389 | .bmdma_setup = pata_icside_bmdma_setup, |
375 | .bmdma_start = pata_icside_bmdma_start, | 390 | .bmdma_start = pata_icside_bmdma_start, |
376 | 391 | ||
@@ -385,7 +400,6 @@ static struct ata_port_operations pata_icside_port_ops = { | |||
385 | .error_handler = ata_bmdma_error_handler, | 400 | .error_handler = ata_bmdma_error_handler, |
386 | .post_internal_cmd = pata_icside_bmdma_stop, | 401 | .post_internal_cmd = pata_icside_bmdma_stop, |
387 | 402 | ||
388 | .irq_handler = ata_interrupt, | ||
389 | .irq_clear = ata_dummy_noret, | 403 | .irq_clear = ata_dummy_noret, |
390 | .irq_on = ata_irq_on, | 404 | .irq_on = ata_irq_on, |
391 | .irq_ack = pata_icside_irq_ack, | 405 | .irq_ack = pata_icside_irq_ack, |
@@ -396,11 +410,10 @@ static struct ata_port_operations pata_icside_port_ops = { | |||
396 | .bmdma_status = pata_icside_bmdma_status, | 410 | .bmdma_status = pata_icside_bmdma_status, |
397 | }; | 411 | }; |
398 | 412 | ||
399 | static void | 413 | static void __devinit |
400 | pata_icside_add_port(struct ata_probe_ent *ae, void __iomem *base, | 414 | pata_icside_setup_ioaddr(struct ata_ioports *ioaddr, void __iomem *base, |
401 | const struct portinfo *info) | 415 | const struct portinfo *info) |
402 | { | 416 | { |
403 | struct ata_ioports *ioaddr = &ae->port[ae->n_ports++]; | ||
404 | void __iomem *cmd = base + info->dataoffset; | 417 | void __iomem *cmd = base + info->dataoffset; |
405 | 418 | ||
406 | ioaddr->cmd_addr = cmd; | 419 | ioaddr->cmd_addr = cmd; |
@@ -419,58 +432,44 @@ pata_icside_add_port(struct ata_probe_ent *ae, void __iomem *base, | |||
419 | ioaddr->altstatus_addr = ioaddr->ctl_addr; | 432 | ioaddr->altstatus_addr = ioaddr->ctl_addr; |
420 | } | 433 | } |
421 | 434 | ||
422 | static int __init | 435 | static int __devinit pata_icside_register_v5(struct pata_icside_info *info) |
423 | pata_icside_register_v5(struct ata_probe_ent *ae, struct expansion_card *ec) | ||
424 | { | 436 | { |
425 | struct pata_icside_state *state = ae->private_data; | 437 | struct pata_icside_state *state = info->state; |
426 | void __iomem *base; | 438 | void __iomem *base; |
427 | 439 | ||
428 | base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), | 440 | base = ecardm_iomap(info->ec, ECARD_RES_MEMC, 0, 0); |
429 | ecard_resource_len(ec, ECARD_RES_MEMC)); | ||
430 | if (!base) | 441 | if (!base) |
431 | return -ENOMEM; | 442 | return -ENOMEM; |
432 | 443 | ||
433 | state->irq_port = base; | 444 | state->irq_port = base; |
434 | 445 | ||
435 | ec->irqaddr = base + ICS_ARCIN_V5_INTRSTAT; | 446 | info->base = base; |
436 | ec->irqmask = 1; | 447 | info->irqaddr = base + ICS_ARCIN_V5_INTRSTAT; |
437 | ec->irq_data = state; | 448 | info->irqmask = 1; |
438 | ec->ops = &pata_icside_ops_arcin_v5; | 449 | info->irqops = &pata_icside_ops_arcin_v5; |
439 | 450 | info->nr_ports = 1; | |
440 | /* | 451 | info->port[0] = &pata_icside_portinfo_v5; |
441 | * Be on the safe side - disable interrupts | ||
442 | */ | ||
443 | ec->ops->irqdisable(ec, ec->irq); | ||
444 | |||
445 | pata_icside_add_port(ae, base, &pata_icside_portinfo_v5); | ||
446 | 452 | ||
447 | return 0; | 453 | return 0; |
448 | } | 454 | } |
449 | 455 | ||
450 | static int __init | 456 | static int __devinit pata_icside_register_v6(struct pata_icside_info *info) |
451 | pata_icside_register_v6(struct ata_probe_ent *ae, struct expansion_card *ec) | ||
452 | { | 457 | { |
453 | struct pata_icside_state *state = ae->private_data; | 458 | struct pata_icside_state *state = info->state; |
459 | struct expansion_card *ec = info->ec; | ||
454 | void __iomem *ioc_base, *easi_base; | 460 | void __iomem *ioc_base, *easi_base; |
455 | unsigned int sel = 0; | 461 | unsigned int sel = 0; |
456 | int ret; | ||
457 | 462 | ||
458 | ioc_base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST), | 463 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
459 | ecard_resource_len(ec, ECARD_RES_IOCFAST)); | 464 | if (!ioc_base) |
460 | if (!ioc_base) { | 465 | return -ENOMEM; |
461 | ret = -ENOMEM; | ||
462 | goto out; | ||
463 | } | ||
464 | 466 | ||
465 | easi_base = ioc_base; | 467 | easi_base = ioc_base; |
466 | 468 | ||
467 | if (ecard_resource_flags(ec, ECARD_RES_EASI)) { | 469 | if (ecard_resource_flags(ec, ECARD_RES_EASI)) { |
468 | easi_base = ioremap(ecard_resource_start(ec, ECARD_RES_EASI), | 470 | easi_base = ecardm_iomap(ec, ECARD_RES_EASI, 0, 0); |
469 | ecard_resource_len(ec, ECARD_RES_EASI)); | 471 | if (!easi_base) |
470 | if (!easi_base) { | 472 | return -ENOMEM; |
471 | ret = -ENOMEM; | ||
472 | goto unmap_slot; | ||
473 | } | ||
474 | 473 | ||
475 | /* | 474 | /* |
476 | * Enable access to the EASI region. | 475 | * Enable access to the EASI region. |
@@ -480,45 +479,72 @@ pata_icside_register_v6(struct ata_probe_ent *ae, struct expansion_card *ec) | |||
480 | 479 | ||
481 | writeb(sel, ioc_base); | 480 | writeb(sel, ioc_base); |
482 | 481 | ||
483 | ec->irq_data = state; | ||
484 | ec->ops = &pata_icside_ops_arcin_v6; | ||
485 | |||
486 | state->irq_port = easi_base; | 482 | state->irq_port = easi_base; |
487 | state->ioc_base = ioc_base; | 483 | state->ioc_base = ioc_base; |
488 | state->port[0].port_sel = sel; | 484 | state->port[0].port_sel = sel; |
489 | state->port[1].port_sel = sel | 1; | 485 | state->port[1].port_sel = sel | 1; |
490 | 486 | ||
491 | /* | 487 | /* |
492 | * Be on the safe side - disable interrupts | ||
493 | */ | ||
494 | ec->ops->irqdisable(ec, ec->irq); | ||
495 | |||
496 | /* | ||
497 | * Find and register the interfaces. | ||
498 | */ | ||
499 | pata_icside_add_port(ae, easi_base, &pata_icside_portinfo_v6_1); | ||
500 | pata_icside_add_port(ae, easi_base, &pata_icside_portinfo_v6_2); | ||
501 | |||
502 | /* | ||
503 | * FIXME: work around libata's aversion to calling port_disable. | 488 | * FIXME: work around libata's aversion to calling port_disable. |
504 | * This permanently disables interrupts on port 0 - bad luck if | 489 | * This permanently disables interrupts on port 0 - bad luck if |
505 | * you have a drive on that port. | 490 | * you have a drive on that port. |
506 | */ | 491 | */ |
507 | state->port[0].disabled = 1; | 492 | state->port[0].disabled = 1; |
508 | 493 | ||
509 | return icside_dma_init(ae, ec); | 494 | info->base = easi_base; |
495 | info->irqops = &pata_icside_ops_arcin_v6; | ||
496 | info->nr_ports = 2; | ||
497 | info->port[0] = &pata_icside_portinfo_v6_1; | ||
498 | info->port[1] = &pata_icside_portinfo_v6_2; | ||
510 | 499 | ||
511 | unmap_slot: | 500 | return icside_dma_init(info); |
512 | iounmap(ioc_base); | 501 | } |
513 | out: | 502 | |
514 | return ret; | 503 | static int __devinit pata_icside_add_ports(struct pata_icside_info *info) |
504 | { | ||
505 | struct expansion_card *ec = info->ec; | ||
506 | struct ata_host *host; | ||
507 | int i; | ||
508 | |||
509 | if (info->irqaddr) { | ||
510 | ec->irqaddr = info->irqaddr; | ||
511 | ec->irqmask = info->irqmask; | ||
512 | } | ||
513 | if (info->irqops) | ||
514 | ecard_setirq(ec, info->irqops, info->state); | ||
515 | |||
516 | /* | ||
517 | * Be on the safe side - disable interrupts | ||
518 | */ | ||
519 | ec->ops->irqdisable(ec, ec->irq); | ||
520 | |||
521 | host = ata_host_alloc(&ec->dev, info->nr_ports); | ||
522 | if (!host) | ||
523 | return -ENOMEM; | ||
524 | |||
525 | host->private_data = info->state; | ||
526 | host->flags = ATA_HOST_SIMPLEX; | ||
527 | |||
528 | for (i = 0; i < info->nr_ports; i++) { | ||
529 | struct ata_port *ap = host->ports[i]; | ||
530 | |||
531 | ap->pio_mask = 0x1f; | ||
532 | ap->mwdma_mask = info->mwdma_mask; | ||
533 | ap->flags |= ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | ||
534 | ap->ops = &pata_icside_port_ops; | ||
535 | |||
536 | pata_icside_setup_ioaddr(&ap->ioaddr, info->base, info->port[i]); | ||
537 | } | ||
538 | |||
539 | return ata_host_activate(host, ec->irq, ata_interrupt, 0, | ||
540 | &pata_icside_sht); | ||
515 | } | 541 | } |
516 | 542 | ||
517 | static int __devinit | 543 | static int __devinit |
518 | pata_icside_probe(struct expansion_card *ec, const struct ecard_id *id) | 544 | pata_icside_probe(struct expansion_card *ec, const struct ecard_id *id) |
519 | { | 545 | { |
520 | struct pata_icside_state *state; | 546 | struct pata_icside_state *state; |
521 | struct ata_probe_ent ae; | 547 | struct pata_icside_info info; |
522 | void __iomem *idmem; | 548 | void __iomem *idmem; |
523 | int ret; | 549 | int ret; |
524 | 550 | ||
@@ -526,7 +552,7 @@ pata_icside_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
526 | if (ret) | 552 | if (ret) |
527 | goto out; | 553 | goto out; |
528 | 554 | ||
529 | state = kzalloc(sizeof(struct pata_icside_state), GFP_KERNEL); | 555 | state = devm_kzalloc(&ec->dev, sizeof(*state), GFP_KERNEL); |
530 | if (!state) { | 556 | if (!state) { |
531 | ret = -ENOMEM; | 557 | ret = -ENOMEM; |
532 | goto release; | 558 | goto release; |
@@ -535,8 +561,7 @@ pata_icside_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
535 | state->type = ICS_TYPE_NOTYPE; | 561 | state->type = ICS_TYPE_NOTYPE; |
536 | state->dma = NO_DMA; | 562 | state->dma = NO_DMA; |
537 | 563 | ||
538 | idmem = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST), | 564 | idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
539 | ecard_resource_len(ec, ECARD_RES_IOCFAST)); | ||
540 | if (idmem) { | 565 | if (idmem) { |
541 | unsigned int type; | 566 | unsigned int type; |
542 | 567 | ||
@@ -544,21 +569,14 @@ pata_icside_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
544 | type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1; | 569 | type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1; |
545 | type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2; | 570 | type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2; |
546 | type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3; | 571 | type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3; |
547 | iounmap(idmem); | 572 | ecardm_iounmap(ec, idmem); |
548 | 573 | ||
549 | state->type = type; | 574 | state->type = type; |
550 | } | 575 | } |
551 | 576 | ||
552 | memset(&ae, 0, sizeof(ae)); | 577 | memset(&info, 0, sizeof(info)); |
553 | INIT_LIST_HEAD(&ae.node); | 578 | info.state = state; |
554 | ae.dev = &ec->dev; | 579 | info.ec = ec; |
555 | ae.port_ops = &pata_icside_port_ops; | ||
556 | ae.sht = &pata_icside_sht; | ||
557 | ae.pio_mask = 0x1f; | ||
558 | ae.irq = ec->irq; | ||
559 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | ||
560 | ae._host_flags = ATA_HOST_SIMPLEX; | ||
561 | ae.private_data = state; | ||
562 | 580 | ||
563 | switch (state->type) { | 581 | switch (state->type) { |
564 | case ICS_TYPE_A3IN: | 582 | case ICS_TYPE_A3IN: |
@@ -572,11 +590,11 @@ pata_icside_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
572 | break; | 590 | break; |
573 | 591 | ||
574 | case ICS_TYPE_V5: | 592 | case ICS_TYPE_V5: |
575 | ret = pata_icside_register_v5(&ae, ec); | 593 | ret = pata_icside_register_v5(&info); |
576 | break; | 594 | break; |
577 | 595 | ||
578 | case ICS_TYPE_V6: | 596 | case ICS_TYPE_V6: |
579 | ret = pata_icside_register_v6(&ae, ec); | 597 | ret = pata_icside_register_v6(&info); |
580 | break; | 598 | break; |
581 | 599 | ||
582 | default: | 600 | default: |
@@ -586,12 +604,11 @@ pata_icside_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
586 | } | 604 | } |
587 | 605 | ||
588 | if (ret == 0) | 606 | if (ret == 0) |
589 | ret = ata_device_add(&ae) == 0 ? -ENODEV : 0; | 607 | ret = pata_icside_add_ports(&info); |
590 | 608 | ||
591 | if (ret == 0) | 609 | if (ret == 0) |
592 | goto out; | 610 | goto out; |
593 | 611 | ||
594 | kfree(state); | ||
595 | release: | 612 | release: |
596 | ecard_release_resources(ec); | 613 | ecard_release_resources(ec); |
597 | out: | 614 | out: |
@@ -609,8 +626,7 @@ static void pata_icside_shutdown(struct expansion_card *ec) | |||
609 | * this register via that region. | 626 | * this register via that region. |
610 | */ | 627 | */ |
611 | local_irq_save(flags); | 628 | local_irq_save(flags); |
612 | if (ec->ops) | 629 | ec->ops->irqdisable(ec, ec->irq); |
613 | ec->ops->irqdisable(ec, ec->irq); | ||
614 | local_irq_restore(flags); | 630 | local_irq_restore(flags); |
615 | 631 | ||
616 | /* | 632 | /* |
@@ -638,17 +654,9 @@ static void __devexit pata_icside_remove(struct expansion_card *ec) | |||
638 | * don't NULL out the drvdata - devres/libata wants it | 654 | * don't NULL out the drvdata - devres/libata wants it |
639 | * to free the ata_host structure. | 655 | * to free the ata_host structure. |
640 | */ | 656 | */ |
641 | ec->ops = NULL; | ||
642 | ec->irq_data = NULL; | ||
643 | |||
644 | if (state->dma != NO_DMA) | 657 | if (state->dma != NO_DMA) |
645 | free_dma(state->dma); | 658 | free_dma(state->dma); |
646 | if (state->ioc_base) | ||
647 | iounmap(state->ioc_base); | ||
648 | if (state->ioc_base != state->irq_port) | ||
649 | iounmap(state->irq_port); | ||
650 | 659 | ||
651 | kfree(state); | ||
652 | ecard_release_resources(ec); | 660 | ecard_release_resources(ec); |
653 | } | 661 | } |
654 | 662 | ||
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c index 17bf9f3ed013..a769952646e1 100644 --- a/drivers/ata/pata_it8213.c +++ b/drivers/ata/pata_it8213.c | |||
@@ -257,10 +257,6 @@ static struct scsi_host_template it8213_sht = { | |||
257 | .dma_boundary = ATA_DMA_BOUNDARY, | 257 | .dma_boundary = ATA_DMA_BOUNDARY, |
258 | .slave_configure = ata_scsi_slave_config, | 258 | .slave_configure = ata_scsi_slave_config, |
259 | .bios_param = ata_std_bios_param, | 259 | .bios_param = ata_std_bios_param, |
260 | #ifdef CONFIG_PM | ||
261 | .resume = ata_scsi_device_resume, | ||
262 | .suspend = ata_scsi_device_suspend, | ||
263 | #endif | ||
264 | }; | 260 | }; |
265 | 261 | ||
266 | static const struct ata_port_operations it8213_ops = { | 262 | static const struct ata_port_operations it8213_ops = { |
@@ -315,7 +311,7 @@ static const struct ata_port_operations it8213_ops = { | |||
315 | static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 311 | static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
316 | { | 312 | { |
317 | static int printed_version; | 313 | static int printed_version; |
318 | static struct ata_port_info info = { | 314 | static const struct ata_port_info info = { |
319 | .sht = &it8213_sht, | 315 | .sht = &it8213_sht, |
320 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 316 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
321 | .pio_mask = 0x1f, /* pio0-4 */ | 317 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -323,14 +319,14 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en | |||
323 | .udma_mask = 0x1f, /* UDMA 100 */ | 319 | .udma_mask = 0x1f, /* UDMA 100 */ |
324 | .port_ops = &it8213_ops, | 320 | .port_ops = &it8213_ops, |
325 | }; | 321 | }; |
326 | static struct ata_port_info *port_info[2] = { &info, &info }; | 322 | /* Current IT8213 stuff is single port */ |
323 | const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; | ||
327 | 324 | ||
328 | if (!printed_version++) | 325 | if (!printed_version++) |
329 | dev_printk(KERN_DEBUG, &pdev->dev, | 326 | dev_printk(KERN_DEBUG, &pdev->dev, |
330 | "version " DRV_VERSION "\n"); | 327 | "version " DRV_VERSION "\n"); |
331 | 328 | ||
332 | /* Current IT8213 stuff is single port */ | 329 | return ata_pci_init_one(pdev, ppi); |
333 | return ata_pci_init_one(pdev, port_info, 1); | ||
334 | } | 330 | } |
335 | 331 | ||
336 | static const struct pci_device_id it8213_pci_tbl[] = { | 332 | static const struct pci_device_id it8213_pci_tbl[] = { |
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index f1f8cec8c224..ff9a6fd36657 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c | |||
@@ -620,10 +620,6 @@ static struct scsi_host_template it821x_sht = { | |||
620 | .slave_configure = ata_scsi_slave_config, | 620 | .slave_configure = ata_scsi_slave_config, |
621 | .slave_destroy = ata_scsi_slave_destroy, | 621 | .slave_destroy = ata_scsi_slave_destroy, |
622 | .bios_param = ata_std_bios_param, | 622 | .bios_param = ata_std_bios_param, |
623 | #ifdef CONFIG_PM | ||
624 | .resume = ata_scsi_device_resume, | ||
625 | .suspend = ata_scsi_device_suspend, | ||
626 | #endif | ||
627 | }; | 623 | }; |
628 | 624 | ||
629 | static struct ata_port_operations it821x_smart_port_ops = { | 625 | static struct ata_port_operations it821x_smart_port_ops = { |
@@ -722,14 +718,14 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
722 | { | 718 | { |
723 | u8 conf; | 719 | u8 conf; |
724 | 720 | ||
725 | static struct ata_port_info info_smart = { | 721 | static const struct ata_port_info info_smart = { |
726 | .sht = &it821x_sht, | 722 | .sht = &it821x_sht, |
727 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 723 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
728 | .pio_mask = 0x1f, | 724 | .pio_mask = 0x1f, |
729 | .mwdma_mask = 0x07, | 725 | .mwdma_mask = 0x07, |
730 | .port_ops = &it821x_smart_port_ops | 726 | .port_ops = &it821x_smart_port_ops |
731 | }; | 727 | }; |
732 | static struct ata_port_info info_passthru = { | 728 | static const struct ata_port_info info_passthru = { |
733 | .sht = &it821x_sht, | 729 | .sht = &it821x_sht, |
734 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 730 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
735 | .pio_mask = 0x1f, | 731 | .pio_mask = 0x1f, |
@@ -737,8 +733,8 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
737 | .udma_mask = 0x7f, | 733 | .udma_mask = 0x7f, |
738 | .port_ops = &it821x_passthru_port_ops | 734 | .port_ops = &it821x_passthru_port_ops |
739 | }; | 735 | }; |
740 | static struct ata_port_info *port_info[2]; | ||
741 | 736 | ||
737 | const struct ata_port_info *ppi[] = { NULL, NULL }; | ||
742 | static char *mode[2] = { "pass through", "smart" }; | 738 | static char *mode[2] = { "pass through", "smart" }; |
743 | 739 | ||
744 | /* Force the card into bypass mode if so requested */ | 740 | /* Force the card into bypass mode if so requested */ |
@@ -751,11 +747,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
751 | 747 | ||
752 | printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]); | 748 | printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]); |
753 | if (conf == 0) | 749 | if (conf == 0) |
754 | port_info[0] = port_info[1] = &info_passthru; | 750 | ppi[0] = &info_passthru; |
755 | else | 751 | else |
756 | port_info[0] = port_info[1] = &info_smart; | 752 | ppi[0] = &info_smart; |
757 | 753 | ||
758 | return ata_pci_init_one(pdev, port_info, 2); | 754 | return ata_pci_init_one(pdev, ppi); |
759 | } | 755 | } |
760 | 756 | ||
761 | #ifdef CONFIG_PM | 757 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index 420c343e5711..b994351fbcd0 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c | |||
@@ -31,7 +31,7 @@ static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error) | |||
31 | 31 | ||
32 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 32 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
33 | struct ata_device *dev = &ap->device[i]; | 33 | struct ata_device *dev = &ap->device[i]; |
34 | if (ata_dev_ready(dev)) { | 34 | if (ata_dev_enabled(dev)) { |
35 | ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); | 35 | ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); |
36 | dev->pio_mode = XFER_PIO_0; | 36 | dev->pio_mode = XFER_PIO_0; |
37 | dev->xfer_mode = XFER_PIO_0; | 37 | dev->xfer_mode = XFER_PIO_0; |
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index 1daf78ac6efb..8d799e87f752 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c | |||
@@ -138,10 +138,6 @@ static struct scsi_host_template jmicron_sht = { | |||
138 | .slave_destroy = ata_scsi_slave_destroy, | 138 | .slave_destroy = ata_scsi_slave_destroy, |
139 | /* Use standard CHS mapping rules */ | 139 | /* Use standard CHS mapping rules */ |
140 | .bios_param = ata_std_bios_param, | 140 | .bios_param = ata_std_bios_param, |
141 | #ifdef CONFIG_PM | ||
142 | .suspend = ata_scsi_device_suspend, | ||
143 | .resume = ata_scsi_device_resume, | ||
144 | #endif | ||
145 | }; | 141 | }; |
146 | 142 | ||
147 | static const struct ata_port_operations jmicron_ops = { | 143 | static const struct ata_port_operations jmicron_ops = { |
@@ -195,7 +191,7 @@ static const struct ata_port_operations jmicron_ops = { | |||
195 | 191 | ||
196 | static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | 192 | static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id) |
197 | { | 193 | { |
198 | static struct ata_port_info info = { | 194 | static const struct ata_port_info info = { |
199 | .sht = &jmicron_sht, | 195 | .sht = &jmicron_sht, |
200 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 196 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
201 | 197 | ||
@@ -205,9 +201,9 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i | |||
205 | 201 | ||
206 | .port_ops = &jmicron_ops, | 202 | .port_ops = &jmicron_ops, |
207 | }; | 203 | }; |
208 | struct ata_port_info *port_info[2] = { &info, &info }; | 204 | const struct ata_port_info *ppi[] = { &info, NULL }; |
209 | 205 | ||
210 | return ata_pci_init_one(pdev, port_info, 2); | 206 | return ata_pci_init_one(pdev, ppi); |
211 | } | 207 | } |
212 | 208 | ||
213 | static const struct pci_device_id jmicron_pci_tbl[] = { | 209 | static const struct pci_device_id jmicron_pci_tbl[] = { |
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c index 837b7fe77dc7..edbfe0dbbf78 100644 --- a/drivers/ata/pata_marvell.c +++ b/drivers/ata/pata_marvell.c | |||
@@ -107,10 +107,6 @@ static struct scsi_host_template marvell_sht = { | |||
107 | .slave_destroy = ata_scsi_slave_destroy, | 107 | .slave_destroy = ata_scsi_slave_destroy, |
108 | /* Use standard CHS mapping rules */ | 108 | /* Use standard CHS mapping rules */ |
109 | .bios_param = ata_std_bios_param, | 109 | .bios_param = ata_std_bios_param, |
110 | #ifdef CONFIG_PM | ||
111 | .resume = ata_scsi_device_resume, | ||
112 | .suspend = ata_scsi_device_suspend, | ||
113 | #endif | ||
114 | }; | 110 | }; |
115 | 111 | ||
116 | static const struct ata_port_operations marvell_ops = { | 112 | static const struct ata_port_operations marvell_ops = { |
@@ -165,7 +161,7 @@ static const struct ata_port_operations marvell_ops = { | |||
165 | 161 | ||
166 | static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) | 162 | static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) |
167 | { | 163 | { |
168 | static struct ata_port_info info = { | 164 | static const struct ata_port_info info = { |
169 | .sht = &marvell_sht, | 165 | .sht = &marvell_sht, |
170 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 166 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
171 | 167 | ||
@@ -175,7 +171,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i | |||
175 | 171 | ||
176 | .port_ops = &marvell_ops, | 172 | .port_ops = &marvell_ops, |
177 | }; | 173 | }; |
178 | static struct ata_port_info info_sata = { | 174 | static const struct ata_port_info info_sata = { |
179 | .sht = &marvell_sht, | 175 | .sht = &marvell_sht, |
180 | /* Slave possible as its magically mapped not real */ | 176 | /* Slave possible as its magically mapped not real */ |
181 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 177 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -186,13 +182,12 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i | |||
186 | 182 | ||
187 | .port_ops = &marvell_ops, | 183 | .port_ops = &marvell_ops, |
188 | }; | 184 | }; |
189 | struct ata_port_info *port_info[2] = { &info, &info_sata }; | 185 | const struct ata_port_info *ppi[] = { &info, &info_sata }; |
190 | int n_port = 2; | ||
191 | 186 | ||
192 | if (pdev->device == 0x6101) | 187 | if (pdev->device == 0x6101) |
193 | n_port = 1; | 188 | ppi[1] = &ata_dummy_port_info; |
194 | 189 | ||
195 | return ata_pci_init_one(pdev, port_info, n_port); | 190 | return ata_pci_init_one(pdev, ppi); |
196 | } | 191 | } |
197 | 192 | ||
198 | static const struct pci_device_id marvell_pci_tbl[] = { | 193 | static const struct pci_device_id marvell_pci_tbl[] = { |
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c index 9587a89f9683..368fac7d168b 100644 --- a/drivers/ata/pata_mpc52xx.c +++ b/drivers/ata/pata_mpc52xx.c | |||
@@ -280,10 +280,6 @@ static struct scsi_host_template mpc52xx_ata_sht = { | |||
280 | .dma_boundary = ATA_DMA_BOUNDARY, | 280 | .dma_boundary = ATA_DMA_BOUNDARY, |
281 | .slave_configure = ata_scsi_slave_config, | 281 | .slave_configure = ata_scsi_slave_config, |
282 | .bios_param = ata_std_bios_param, | 282 | .bios_param = ata_std_bios_param, |
283 | #ifdef CONFIG_PM | ||
284 | .suspend = ata_scsi_device_suspend, | ||
285 | .resume = ata_scsi_device_resume, | ||
286 | #endif | ||
287 | }; | 283 | }; |
288 | 284 | ||
289 | static struct ata_port_operations mpc52xx_ata_port_ops = { | 285 | static struct ata_port_operations mpc52xx_ata_port_ops = { |
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c index 3bfbd495f643..4ea42838297e 100644 --- a/drivers/ata/pata_mpiix.c +++ b/drivers/ata/pata_mpiix.c | |||
@@ -165,10 +165,6 @@ static struct scsi_host_template mpiix_sht = { | |||
165 | .slave_configure = ata_scsi_slave_config, | 165 | .slave_configure = ata_scsi_slave_config, |
166 | .slave_destroy = ata_scsi_slave_destroy, | 166 | .slave_destroy = ata_scsi_slave_destroy, |
167 | .bios_param = ata_std_bios_param, | 167 | .bios_param = ata_std_bios_param, |
168 | #ifdef CONFIG_PM | ||
169 | .resume = ata_scsi_device_resume, | ||
170 | .suspend = ata_scsi_device_suspend, | ||
171 | #endif | ||
172 | }; | 168 | }; |
173 | 169 | ||
174 | static struct ata_port_operations mpiix_port_ops = { | 170 | static struct ata_port_operations mpiix_port_ops = { |
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c index dbba5b77d79c..81f563458666 100644 --- a/drivers/ata/pata_netcell.c +++ b/drivers/ata/pata_netcell.c | |||
@@ -37,10 +37,6 @@ static struct scsi_host_template netcell_sht = { | |||
37 | .slave_destroy = ata_scsi_slave_destroy, | 37 | .slave_destroy = ata_scsi_slave_destroy, |
38 | /* Use standard CHS mapping rules */ | 38 | /* Use standard CHS mapping rules */ |
39 | .bios_param = ata_std_bios_param, | 39 | .bios_param = ata_std_bios_param, |
40 | #ifdef CONFIG_PM | ||
41 | .resume = ata_scsi_device_resume, | ||
42 | .suspend = ata_scsi_device_suspend, | ||
43 | #endif | ||
44 | }; | 40 | }; |
45 | 41 | ||
46 | static const struct ata_port_operations netcell_ops = { | 42 | static const struct ata_port_operations netcell_ops = { |
@@ -96,7 +92,7 @@ static const struct ata_port_operations netcell_ops = { | |||
96 | static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 92 | static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
97 | { | 93 | { |
98 | static int printed_version; | 94 | static int printed_version; |
99 | static struct ata_port_info info = { | 95 | static const struct ata_port_info info = { |
100 | .sht = &netcell_sht, | 96 | .sht = &netcell_sht, |
101 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 97 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
102 | /* Actually we don't really care about these as the | 98 | /* Actually we don't really care about these as the |
@@ -106,7 +102,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
106 | .udma_mask = 0x3f, /* UDMA 133 */ | 102 | .udma_mask = 0x3f, /* UDMA 133 */ |
107 | .port_ops = &netcell_ops, | 103 | .port_ops = &netcell_ops, |
108 | }; | 104 | }; |
109 | static struct ata_port_info *port_info[2] = { &info, &info }; | 105 | const struct ata_port_info *port_info[] = { &info, NULL }; |
110 | 106 | ||
111 | if (!printed_version++) | 107 | if (!printed_version++) |
112 | dev_printk(KERN_DEBUG, &pdev->dev, | 108 | dev_printk(KERN_DEBUG, &pdev->dev, |
@@ -116,7 +112,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
116 | ata_pci_clear_simplex(pdev); | 112 | ata_pci_clear_simplex(pdev); |
117 | 113 | ||
118 | /* And let the library code do the work */ | 114 | /* And let the library code do the work */ |
119 | return ata_pci_init_one(pdev, port_info, 2); | 115 | return ata_pci_init_one(pdev, port_info); |
120 | } | 116 | } |
121 | 117 | ||
122 | static const struct pci_device_id netcell_pci_tbl[] = { | 118 | static const struct pci_device_id netcell_pci_tbl[] = { |
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c index ebc58a907d26..ea70ec744879 100644 --- a/drivers/ata/pata_ns87410.c +++ b/drivers/ata/pata_ns87410.c | |||
@@ -158,10 +158,6 @@ static struct scsi_host_template ns87410_sht = { | |||
158 | .slave_configure = ata_scsi_slave_config, | 158 | .slave_configure = ata_scsi_slave_config, |
159 | .slave_destroy = ata_scsi_slave_destroy, | 159 | .slave_destroy = ata_scsi_slave_destroy, |
160 | .bios_param = ata_std_bios_param, | 160 | .bios_param = ata_std_bios_param, |
161 | #ifdef CONFIG_PM | ||
162 | .resume = ata_scsi_device_resume, | ||
163 | .suspend = ata_scsi_device_suspend, | ||
164 | #endif | ||
165 | }; | 161 | }; |
166 | 162 | ||
167 | static struct ata_port_operations ns87410_port_ops = { | 163 | static struct ata_port_operations ns87410_port_ops = { |
@@ -195,14 +191,14 @@ static struct ata_port_operations ns87410_port_ops = { | |||
195 | 191 | ||
196 | static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 192 | static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
197 | { | 193 | { |
198 | static struct ata_port_info info = { | 194 | static const struct ata_port_info info = { |
199 | .sht = &ns87410_sht, | 195 | .sht = &ns87410_sht, |
200 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 196 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
201 | .pio_mask = 0x0F, | 197 | .pio_mask = 0x0F, |
202 | .port_ops = &ns87410_port_ops | 198 | .port_ops = &ns87410_port_ops |
203 | }; | 199 | }; |
204 | static struct ata_port_info *port_info[2] = {&info, &info}; | 200 | const struct ata_port_info *ppi[] = { &info, NULL }; |
205 | return ata_pci_init_one(dev, port_info, 2); | 201 | return ata_pci_init_one(dev, ppi); |
206 | } | 202 | } |
207 | 203 | ||
208 | static const struct pci_device_id ns87410[] = { | 204 | static const struct pci_device_id ns87410[] = { |
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c index 4d75d32e5826..29c23ddd6550 100644 --- a/drivers/ata/pata_oldpiix.c +++ b/drivers/ata/pata_oldpiix.c | |||
@@ -234,10 +234,6 @@ static struct scsi_host_template oldpiix_sht = { | |||
234 | .slave_configure = ata_scsi_slave_config, | 234 | .slave_configure = ata_scsi_slave_config, |
235 | .slave_destroy = ata_scsi_slave_destroy, | 235 | .slave_destroy = ata_scsi_slave_destroy, |
236 | .bios_param = ata_std_bios_param, | 236 | .bios_param = ata_std_bios_param, |
237 | #ifdef CONFIG_PM | ||
238 | .resume = ata_scsi_device_resume, | ||
239 | .suspend = ata_scsi_device_suspend, | ||
240 | #endif | ||
241 | }; | 237 | }; |
242 | 238 | ||
243 | static const struct ata_port_operations oldpiix_pata_ops = { | 239 | static const struct ata_port_operations oldpiix_pata_ops = { |
@@ -293,20 +289,20 @@ static const struct ata_port_operations oldpiix_pata_ops = { | |||
293 | static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 289 | static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
294 | { | 290 | { |
295 | static int printed_version; | 291 | static int printed_version; |
296 | static struct ata_port_info info = { | 292 | static const struct ata_port_info info = { |
297 | .sht = &oldpiix_sht, | 293 | .sht = &oldpiix_sht, |
298 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 294 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
299 | .pio_mask = 0x1f, /* pio0-4 */ | 295 | .pio_mask = 0x1f, /* pio0-4 */ |
300 | .mwdma_mask = 0x07, /* mwdma1-2 */ | 296 | .mwdma_mask = 0x07, /* mwdma1-2 */ |
301 | .port_ops = &oldpiix_pata_ops, | 297 | .port_ops = &oldpiix_pata_ops, |
302 | }; | 298 | }; |
303 | static struct ata_port_info *port_info[2] = { &info, &info }; | 299 | const struct ata_port_info *ppi[] = { &info, NULL }; |
304 | 300 | ||
305 | if (!printed_version++) | 301 | if (!printed_version++) |
306 | dev_printk(KERN_DEBUG, &pdev->dev, | 302 | dev_printk(KERN_DEBUG, &pdev->dev, |
307 | "version " DRV_VERSION "\n"); | 303 | "version " DRV_VERSION "\n"); |
308 | 304 | ||
309 | return ata_pci_init_one(pdev, port_info, 2); | 305 | return ata_pci_init_one(pdev, ppi); |
310 | } | 306 | } |
311 | 307 | ||
312 | static const struct pci_device_id oldpiix_pci_tbl[] = { | 308 | static const struct pci_device_id oldpiix_pci_tbl[] = { |
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c index 0af8a2c77cc9..1c44653e1e06 100644 --- a/drivers/ata/pata_opti.c +++ b/drivers/ata/pata_opti.c | |||
@@ -179,10 +179,6 @@ static struct scsi_host_template opti_sht = { | |||
179 | .slave_configure = ata_scsi_slave_config, | 179 | .slave_configure = ata_scsi_slave_config, |
180 | .slave_destroy = ata_scsi_slave_destroy, | 180 | .slave_destroy = ata_scsi_slave_destroy, |
181 | .bios_param = ata_std_bios_param, | 181 | .bios_param = ata_std_bios_param, |
182 | #ifdef CONFIG_PM | ||
183 | .resume = ata_scsi_device_resume, | ||
184 | .suspend = ata_scsi_device_suspend, | ||
185 | #endif | ||
186 | }; | 182 | }; |
187 | 183 | ||
188 | static struct ata_port_operations opti_port_ops = { | 184 | static struct ata_port_operations opti_port_ops = { |
@@ -220,19 +216,19 @@ static struct ata_port_operations opti_port_ops = { | |||
220 | 216 | ||
221 | static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 217 | static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
222 | { | 218 | { |
223 | static struct ata_port_info info = { | 219 | static const struct ata_port_info info = { |
224 | .sht = &opti_sht, | 220 | .sht = &opti_sht, |
225 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 221 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
226 | .pio_mask = 0x1f, | 222 | .pio_mask = 0x1f, |
227 | .port_ops = &opti_port_ops | 223 | .port_ops = &opti_port_ops |
228 | }; | 224 | }; |
229 | static struct ata_port_info *port_info[2] = { &info, &info }; | 225 | const struct ata_port_info *ppi[] = { &info, NULL }; |
230 | static int printed_version; | 226 | static int printed_version; |
231 | 227 | ||
232 | if (!printed_version++) | 228 | if (!printed_version++) |
233 | dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); | 229 | dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); |
234 | 230 | ||
235 | return ata_pci_init_one(dev, port_info, 2); | 231 | return ata_pci_init_one(dev, ppi); |
236 | } | 232 | } |
237 | 233 | ||
238 | static const struct pci_device_id opti[] = { | 234 | static const struct pci_device_id opti[] = { |
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c index 2843e480f216..3093b02286ce 100644 --- a/drivers/ata/pata_optidma.c +++ b/drivers/ata/pata_optidma.c | |||
@@ -363,10 +363,6 @@ static struct scsi_host_template optidma_sht = { | |||
363 | .slave_configure = ata_scsi_slave_config, | 363 | .slave_configure = ata_scsi_slave_config, |
364 | .slave_destroy = ata_scsi_slave_destroy, | 364 | .slave_destroy = ata_scsi_slave_destroy, |
365 | .bios_param = ata_std_bios_param, | 365 | .bios_param = ata_std_bios_param, |
366 | #ifdef CONFIG_PM | ||
367 | .resume = ata_scsi_device_resume, | ||
368 | .suspend = ata_scsi_device_suspend, | ||
369 | #endif | ||
370 | }; | 366 | }; |
371 | 367 | ||
372 | static struct ata_port_operations optidma_port_ops = { | 368 | static struct ata_port_operations optidma_port_ops = { |
@@ -486,14 +482,14 @@ done_nomsg: /* Wrong chip revision */ | |||
486 | 482 | ||
487 | static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 483 | static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
488 | { | 484 | { |
489 | static struct ata_port_info info_82c700 = { | 485 | static const struct ata_port_info info_82c700 = { |
490 | .sht = &optidma_sht, | 486 | .sht = &optidma_sht, |
491 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 487 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
492 | .pio_mask = 0x1f, | 488 | .pio_mask = 0x1f, |
493 | .mwdma_mask = 0x07, | 489 | .mwdma_mask = 0x07, |
494 | .port_ops = &optidma_port_ops | 490 | .port_ops = &optidma_port_ops |
495 | }; | 491 | }; |
496 | static struct ata_port_info info_82c700_udma = { | 492 | static const struct ata_port_info info_82c700_udma = { |
497 | .sht = &optidma_sht, | 493 | .sht = &optidma_sht, |
498 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 494 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
499 | .pio_mask = 0x1f, | 495 | .pio_mask = 0x1f, |
@@ -501,8 +497,7 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
501 | .udma_mask = 0x07, | 497 | .udma_mask = 0x07, |
502 | .port_ops = &optiplus_port_ops | 498 | .port_ops = &optiplus_port_ops |
503 | }; | 499 | }; |
504 | static struct ata_port_info *port_info[2]; | 500 | const struct ata_port_info *ppi[] = { &info_82c700, NULL }; |
505 | struct ata_port_info *info = &info_82c700; | ||
506 | static int printed_version; | 501 | static int printed_version; |
507 | 502 | ||
508 | if (!printed_version++) | 503 | if (!printed_version++) |
@@ -514,10 +509,9 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
514 | pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ | 509 | pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ |
515 | 510 | ||
516 | if (optiplus_with_udma(dev)) | 511 | if (optiplus_with_udma(dev)) |
517 | info = &info_82c700_udma; | 512 | ppi[0] = &info_82c700_udma; |
518 | 513 | ||
519 | port_info[0] = port_info[1] = info; | 514 | return ata_pci_init_one(dev, ppi); |
520 | return ata_pci_init_one(dev, port_info, 2); | ||
521 | } | 515 | } |
522 | 516 | ||
523 | static const struct pci_device_id optidma[] = { | 517 | static const struct pci_device_id optidma[] = { |
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 11245e331f77..4d44c7555db1 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -397,6 +397,7 @@ static struct pcmcia_device_id pcmcia_devices[] = { | |||
397 | PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), | 397 | PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), |
398 | PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), | 398 | PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), |
399 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), | 399 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), |
400 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2), | ||
400 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), | 401 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), |
401 | PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), | 402 | PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), |
402 | PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), | 403 | PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), |
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c index ee636beb05e1..edbaf9d653b8 100644 --- a/drivers/ata/pata_pdc202xx_old.c +++ b/drivers/ata/pata_pdc202xx_old.c | |||
@@ -244,10 +244,6 @@ static struct scsi_host_template pdc202xx_sht = { | |||
244 | .slave_configure = ata_scsi_slave_config, | 244 | .slave_configure = ata_scsi_slave_config, |
245 | .slave_destroy = ata_scsi_slave_destroy, | 245 | .slave_destroy = ata_scsi_slave_destroy, |
246 | .bios_param = ata_std_bios_param, | 246 | .bios_param = ata_std_bios_param, |
247 | #ifdef CONFIG_PM | ||
248 | .resume = ata_scsi_device_resume, | ||
249 | .suspend = ata_scsi_device_suspend, | ||
250 | #endif | ||
251 | }; | 247 | }; |
252 | 248 | ||
253 | static struct ata_port_operations pdc2024x_port_ops = { | 249 | static struct ata_port_operations pdc2024x_port_ops = { |
@@ -321,7 +317,7 @@ static struct ata_port_operations pdc2026x_port_ops = { | |||
321 | 317 | ||
322 | static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 318 | static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
323 | { | 319 | { |
324 | static struct ata_port_info info[3] = { | 320 | static const struct ata_port_info info[3] = { |
325 | { | 321 | { |
326 | .sht = &pdc202xx_sht, | 322 | .sht = &pdc202xx_sht, |
327 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 323 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -348,9 +344,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id | |||
348 | } | 344 | } |
349 | 345 | ||
350 | }; | 346 | }; |
351 | static struct ata_port_info *port_info[2]; | 347 | const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; |
352 | |||
353 | port_info[0] = port_info[1] = &info[id->driver_data]; | ||
354 | 348 | ||
355 | if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { | 349 | if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { |
356 | struct pci_dev *bridge = dev->bus->self; | 350 | struct pci_dev *bridge = dev->bus->self; |
@@ -362,7 +356,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id | |||
362 | return -ENODEV; | 356 | return -ENODEV; |
363 | } | 357 | } |
364 | } | 358 | } |
365 | return ata_pci_init_one(dev, port_info, 2); | 359 | return ata_pci_init_one(dev, ppi); |
366 | } | 360 | } |
367 | 361 | ||
368 | static const struct pci_device_id pdc202xx[] = { | 362 | static const struct pci_device_id pdc202xx[] = { |
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index a0a650c7f272..1f6384895a4f 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c | |||
@@ -48,6 +48,8 @@ static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unuse | |||
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | static int ata_dummy_ret0(struct ata_port *ap) { return 0; } | ||
52 | |||
51 | static struct scsi_host_template pata_platform_sht = { | 53 | static struct scsi_host_template pata_platform_sht = { |
52 | .module = THIS_MODULE, | 54 | .module = THIS_MODULE, |
53 | .name = DRV_NAME, | 55 | .name = DRV_NAME, |
@@ -91,7 +93,7 @@ static struct ata_port_operations pata_platform_port_ops = { | |||
91 | .irq_on = ata_irq_on, | 93 | .irq_on = ata_irq_on, |
92 | .irq_ack = ata_irq_ack, | 94 | .irq_ack = ata_irq_ack, |
93 | 95 | ||
94 | .port_start = ata_port_start, | 96 | .port_start = ata_dummy_ret0, |
95 | }; | 97 | }; |
96 | 98 | ||
97 | static void pata_platform_setup_port(struct ata_ioports *ioaddr, | 99 | static void pata_platform_setup_port(struct ata_ioports *ioaddr, |
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c index 1c54673e008d..ba96b54f5b87 100644 --- a/drivers/ata/pata_radisys.c +++ b/drivers/ata/pata_radisys.c | |||
@@ -200,10 +200,6 @@ static struct scsi_host_template radisys_sht = { | |||
200 | .slave_configure = ata_scsi_slave_config, | 200 | .slave_configure = ata_scsi_slave_config, |
201 | .slave_destroy = ata_scsi_slave_destroy, | 201 | .slave_destroy = ata_scsi_slave_destroy, |
202 | .bios_param = ata_std_bios_param, | 202 | .bios_param = ata_std_bios_param, |
203 | #ifdef CONFIG_PM | ||
204 | .resume = ata_scsi_device_resume, | ||
205 | .suspend = ata_scsi_device_suspend, | ||
206 | #endif | ||
207 | }; | 203 | }; |
208 | 204 | ||
209 | static const struct ata_port_operations radisys_pata_ops = { | 205 | static const struct ata_port_operations radisys_pata_ops = { |
@@ -259,7 +255,7 @@ static const struct ata_port_operations radisys_pata_ops = { | |||
259 | static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 255 | static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
260 | { | 256 | { |
261 | static int printed_version; | 257 | static int printed_version; |
262 | static struct ata_port_info info = { | 258 | static const struct ata_port_info info = { |
263 | .sht = &radisys_sht, | 259 | .sht = &radisys_sht, |
264 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 260 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
265 | .pio_mask = 0x1f, /* pio0-4 */ | 261 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -267,13 +263,13 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
267 | .udma_mask = 0x14, /* UDMA33/66 only */ | 263 | .udma_mask = 0x14, /* UDMA33/66 only */ |
268 | .port_ops = &radisys_pata_ops, | 264 | .port_ops = &radisys_pata_ops, |
269 | }; | 265 | }; |
270 | static struct ata_port_info *port_info[2] = { &info, &info }; | 266 | const struct ata_port_info *ppi[] = { &info, NULL }; |
271 | 267 | ||
272 | if (!printed_version++) | 268 | if (!printed_version++) |
273 | dev_printk(KERN_DEBUG, &pdev->dev, | 269 | dev_printk(KERN_DEBUG, &pdev->dev, |
274 | "version " DRV_VERSION "\n"); | 270 | "version " DRV_VERSION "\n"); |
275 | 271 | ||
276 | return ata_pci_init_one(pdev, port_info, 2); | 272 | return ata_pci_init_one(pdev, ppi); |
277 | } | 273 | } |
278 | 274 | ||
279 | static const struct pci_device_id radisys_pci_tbl[] = { | 275 | static const struct pci_device_id radisys_pci_tbl[] = { |
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c index 85c45290eeee..2bfd7ef42af5 100644 --- a/drivers/ata/pata_rz1000.c +++ b/drivers/ata/pata_rz1000.c | |||
@@ -40,7 +40,7 @@ static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused) | |||
40 | 40 | ||
41 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 41 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
42 | struct ata_device *dev = &ap->device[i]; | 42 | struct ata_device *dev = &ap->device[i]; |
43 | if (ata_dev_ready(dev)) { | 43 | if (ata_dev_enabled(dev)) { |
44 | /* We don't really care */ | 44 | /* We don't really care */ |
45 | dev->pio_mode = XFER_PIO_0; | 45 | dev->pio_mode = XFER_PIO_0; |
46 | dev->xfer_mode = XFER_PIO_0; | 46 | dev->xfer_mode = XFER_PIO_0; |
@@ -69,10 +69,6 @@ static struct scsi_host_template rz1000_sht = { | |||
69 | .slave_configure = ata_scsi_slave_config, | 69 | .slave_configure = ata_scsi_slave_config, |
70 | .slave_destroy = ata_scsi_slave_destroy, | 70 | .slave_destroy = ata_scsi_slave_destroy, |
71 | .bios_param = ata_std_bios_param, | 71 | .bios_param = ata_std_bios_param, |
72 | #ifdef CONFIG_PM | ||
73 | .resume = ata_scsi_device_resume, | ||
74 | .suspend = ata_scsi_device_suspend, | ||
75 | #endif | ||
76 | }; | 72 | }; |
77 | 73 | ||
78 | static struct ata_port_operations rz1000_port_ops = { | 74 | static struct ata_port_operations rz1000_port_ops = { |
@@ -135,22 +131,20 @@ static int rz1000_fifo_disable(struct pci_dev *pdev) | |||
135 | static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 131 | static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
136 | { | 132 | { |
137 | static int printed_version; | 133 | static int printed_version; |
138 | struct ata_port_info *port_info[2]; | 134 | static const struct ata_port_info info = { |
139 | static struct ata_port_info info = { | ||
140 | .sht = &rz1000_sht, | 135 | .sht = &rz1000_sht, |
141 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 136 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
142 | .pio_mask = 0x1f, | 137 | .pio_mask = 0x1f, |
143 | .port_ops = &rz1000_port_ops | 138 | .port_ops = &rz1000_port_ops |
144 | }; | 139 | }; |
140 | const struct ata_port_info *ppi[] = { &info, NULL }; | ||
145 | 141 | ||
146 | if (!printed_version++) | 142 | if (!printed_version++) |
147 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 143 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); |
148 | 144 | ||
149 | if (rz1000_fifo_disable(pdev) == 0) { | 145 | if (rz1000_fifo_disable(pdev) == 0) |
150 | port_info[0] = &info; | 146 | return ata_pci_init_one(pdev, ppi); |
151 | port_info[1] = &info; | 147 | |
152 | return ata_pci_init_one(pdev, port_info, 2); | ||
153 | } | ||
154 | printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); | 148 | printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); |
155 | /* Not safe to use so skip */ | 149 | /* Not safe to use so skip */ |
156 | return -ENODEV; | 150 | return -ENODEV; |
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c index 66e8ff467c8d..225013ecf4b6 100644 --- a/drivers/ata/pata_sc1200.c +++ b/drivers/ata/pata_sc1200.c | |||
@@ -194,10 +194,6 @@ static struct scsi_host_template sc1200_sht = { | |||
194 | .slave_configure = ata_scsi_slave_config, | 194 | .slave_configure = ata_scsi_slave_config, |
195 | .slave_destroy = ata_scsi_slave_destroy, | 195 | .slave_destroy = ata_scsi_slave_destroy, |
196 | .bios_param = ata_std_bios_param, | 196 | .bios_param = ata_std_bios_param, |
197 | #ifdef CONFIG_PM | ||
198 | .resume = ata_scsi_device_resume, | ||
199 | .suspend = ata_scsi_device_suspend, | ||
200 | #endif | ||
201 | }; | 197 | }; |
202 | 198 | ||
203 | static struct ata_port_operations sc1200_port_ops = { | 199 | static struct ata_port_operations sc1200_port_ops = { |
@@ -247,7 +243,7 @@ static struct ata_port_operations sc1200_port_ops = { | |||
247 | 243 | ||
248 | static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 244 | static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
249 | { | 245 | { |
250 | static struct ata_port_info info = { | 246 | static const struct ata_port_info info = { |
251 | .sht = &sc1200_sht, | 247 | .sht = &sc1200_sht, |
252 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | 248 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, |
253 | .pio_mask = 0x1f, | 249 | .pio_mask = 0x1f, |
@@ -255,10 +251,10 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
255 | .udma_mask = 0x07, | 251 | .udma_mask = 0x07, |
256 | .port_ops = &sc1200_port_ops | 252 | .port_ops = &sc1200_port_ops |
257 | }; | 253 | }; |
258 | static struct ata_port_info *port_info[2] = { &info, &info }; | ||
259 | |||
260 | /* Can't enable port 2 yet, see top comments */ | 254 | /* Can't enable port 2 yet, see top comments */ |
261 | return ata_pci_init_one(dev, port_info, 1); | 255 | const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; |
256 | |||
257 | return ata_pci_init_one(dev, ppi); | ||
262 | } | 258 | } |
263 | 259 | ||
264 | static const struct pci_device_id sc1200[] = { | 260 | static const struct pci_device_id sc1200[] = { |
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c index 203f463ac39f..cca3aa225efe 100644 --- a/drivers/ata/pata_scc.c +++ b/drivers/ata/pata_scc.c | |||
@@ -984,10 +984,6 @@ static struct scsi_host_template scc_sht = { | |||
984 | .slave_configure = ata_scsi_slave_config, | 984 | .slave_configure = ata_scsi_slave_config, |
985 | .slave_destroy = ata_scsi_slave_destroy, | 985 | .slave_destroy = ata_scsi_slave_destroy, |
986 | .bios_param = ata_std_bios_param, | 986 | .bios_param = ata_std_bios_param, |
987 | #ifdef CONFIG_PM | ||
988 | .resume = ata_scsi_device_resume, | ||
989 | .suspend = ata_scsi_device_suspend, | ||
990 | #endif | ||
991 | }; | 987 | }; |
992 | 988 | ||
993 | static const struct ata_port_operations scc_pata_ops = { | 989 | static const struct ata_port_operations scc_pata_ops = { |
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c index b6e020383dd9..dee6e211949d 100644 --- a/drivers/ata/pata_serverworks.c +++ b/drivers/ata/pata_serverworks.c | |||
@@ -315,10 +315,6 @@ static struct scsi_host_template serverworks_sht = { | |||
315 | .slave_configure = ata_scsi_slave_config, | 315 | .slave_configure = ata_scsi_slave_config, |
316 | .slave_destroy = ata_scsi_slave_destroy, | 316 | .slave_destroy = ata_scsi_slave_destroy, |
317 | .bios_param = ata_std_bios_param, | 317 | .bios_param = ata_std_bios_param, |
318 | #ifdef CONFIG_PM | ||
319 | .resume = ata_scsi_device_resume, | ||
320 | .suspend = ata_scsi_device_suspend, | ||
321 | #endif | ||
322 | }; | 318 | }; |
323 | 319 | ||
324 | static struct ata_port_operations serverworks_osb4_port_ops = { | 320 | static struct ata_port_operations serverworks_osb4_port_ops = { |
@@ -479,8 +475,7 @@ static void serverworks_fixup_ht1000(struct pci_dev *pdev) | |||
479 | 475 | ||
480 | static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 476 | static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
481 | { | 477 | { |
482 | int ports = 2; | 478 | static const struct ata_port_info info[4] = { |
483 | static struct ata_port_info info[4] = { | ||
484 | { /* OSB4 */ | 479 | { /* OSB4 */ |
485 | .sht = &serverworks_sht, | 480 | .sht = &serverworks_sht, |
486 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 481 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
@@ -511,8 +506,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id | |||
511 | .port_ops = &serverworks_csb_port_ops | 506 | .port_ops = &serverworks_csb_port_ops |
512 | } | 507 | } |
513 | }; | 508 | }; |
514 | static struct ata_port_info *port_info[2]; | 509 | const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; |
515 | struct ata_port_info *devinfo = &info[id->driver_data]; | ||
516 | 510 | ||
517 | /* Force master latency timer to 64 PCI clocks */ | 511 | /* Force master latency timer to 64 PCI clocks */ |
518 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); | 512 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); |
@@ -521,7 +515,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id | |||
521 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { | 515 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { |
522 | /* Select non UDMA capable OSB4 if we can't do fixups */ | 516 | /* Select non UDMA capable OSB4 if we can't do fixups */ |
523 | if ( serverworks_fixup_osb4(pdev) < 0) | 517 | if ( serverworks_fixup_osb4(pdev) < 0) |
524 | devinfo = &info[1]; | 518 | ppi[0] = &info[1]; |
525 | } | 519 | } |
526 | /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ | 520 | /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ |
527 | else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || | 521 | else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || |
@@ -531,11 +525,11 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id | |||
531 | /* If the returned btr is the newer revision then | 525 | /* If the returned btr is the newer revision then |
532 | select the right info block */ | 526 | select the right info block */ |
533 | if (serverworks_fixup_csb(pdev) == 3) | 527 | if (serverworks_fixup_csb(pdev) == 3) |
534 | devinfo = &info[3]; | 528 | ppi[0] = &info[3]; |
535 | 529 | ||
536 | /* Is this the 3rd channel CSB6 IDE ? */ | 530 | /* Is this the 3rd channel CSB6 IDE ? */ |
537 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) | 531 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) |
538 | ports = 1; | 532 | ppi[1] = &ata_dummy_port_info; |
539 | } | 533 | } |
540 | /* setup HT1000E */ | 534 | /* setup HT1000E */ |
541 | else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) | 535 | else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) |
@@ -544,8 +538,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id | |||
544 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) | 538 | if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) |
545 | ata_pci_clear_simplex(pdev); | 539 | ata_pci_clear_simplex(pdev); |
546 | 540 | ||
547 | port_info[0] = port_info[1] = devinfo; | 541 | return ata_pci_init_one(pdev, ppi); |
548 | return ata_pci_init_one(pdev, port_info, ports); | ||
549 | } | 542 | } |
550 | 543 | ||
551 | #ifdef CONFIG_PM | 544 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index a5886f061c0b..440e2cb6ee75 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c | |||
@@ -232,10 +232,6 @@ static struct scsi_host_template sil680_sht = { | |||
232 | .slave_configure = ata_scsi_slave_config, | 232 | .slave_configure = ata_scsi_slave_config, |
233 | .slave_destroy = ata_scsi_slave_destroy, | 233 | .slave_destroy = ata_scsi_slave_destroy, |
234 | .bios_param = ata_std_bios_param, | 234 | .bios_param = ata_std_bios_param, |
235 | #ifdef CONFIG_PM | ||
236 | .suspend = ata_scsi_device_suspend, | ||
237 | .resume = ata_scsi_device_resume, | ||
238 | #endif | ||
239 | }; | 235 | }; |
240 | 236 | ||
241 | static struct ata_port_operations sil680_port_ops = { | 237 | static struct ata_port_operations sil680_port_ops = { |
@@ -345,7 +341,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev) | |||
345 | 341 | ||
346 | static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 342 | static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
347 | { | 343 | { |
348 | static struct ata_port_info info = { | 344 | static const struct ata_port_info info = { |
349 | .sht = &sil680_sht, | 345 | .sht = &sil680_sht, |
350 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 346 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
351 | .pio_mask = 0x1f, | 347 | .pio_mask = 0x1f, |
@@ -353,7 +349,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
353 | .udma_mask = 0x7f, | 349 | .udma_mask = 0x7f, |
354 | .port_ops = &sil680_port_ops | 350 | .port_ops = &sil680_port_ops |
355 | }; | 351 | }; |
356 | static struct ata_port_info info_slow = { | 352 | static const struct ata_port_info info_slow = { |
357 | .sht = &sil680_sht, | 353 | .sht = &sil680_sht, |
358 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 354 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
359 | .pio_mask = 0x1f, | 355 | .pio_mask = 0x1f, |
@@ -361,7 +357,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
361 | .udma_mask = 0x3f, | 357 | .udma_mask = 0x3f, |
362 | .port_ops = &sil680_port_ops | 358 | .port_ops = &sil680_port_ops |
363 | }; | 359 | }; |
364 | static struct ata_port_info *port_info[2] = {&info, &info}; | 360 | const struct ata_port_info *ppi[] = { &info, NULL }; |
365 | static int printed_version; | 361 | static int printed_version; |
366 | 362 | ||
367 | if (!printed_version++) | 363 | if (!printed_version++) |
@@ -370,12 +366,12 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
370 | switch(sil680_init_chip(pdev)) | 366 | switch(sil680_init_chip(pdev)) |
371 | { | 367 | { |
372 | case 0: | 368 | case 0: |
373 | port_info[0] = port_info[1] = &info_slow; | 369 | ppi[0] = &info_slow; |
374 | break; | 370 | break; |
375 | case 0x30: | 371 | case 0x30: |
376 | return -ENODEV; | 372 | return -ENODEV; |
377 | } | 373 | } |
378 | return ata_pci_init_one(pdev, port_info, 2); | 374 | return ata_pci_init_one(pdev, ppi); |
379 | } | 375 | } |
380 | 376 | ||
381 | #ifdef CONFIG_PM | 377 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index f5838cc11728..f2231267e011 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c | |||
@@ -38,8 +38,8 @@ | |||
38 | #define DRV_VERSION "0.5.1" | 38 | #define DRV_VERSION "0.5.1" |
39 | 39 | ||
40 | struct sis_chipset { | 40 | struct sis_chipset { |
41 | u16 device; /* PCI host ID */ | 41 | u16 device; /* PCI host ID */ |
42 | struct ata_port_info *info; /* Info block */ | 42 | const struct ata_port_info *info; /* Info block */ |
43 | /* Probably add family, cable detect type etc here to clean | 43 | /* Probably add family, cable detect type etc here to clean |
44 | up code later */ | 44 | up code later */ |
45 | }; | 45 | }; |
@@ -524,10 +524,6 @@ static struct scsi_host_template sis_sht = { | |||
524 | .slave_configure = ata_scsi_slave_config, | 524 | .slave_configure = ata_scsi_slave_config, |
525 | .slave_destroy = ata_scsi_slave_destroy, | 525 | .slave_destroy = ata_scsi_slave_destroy, |
526 | .bios_param = ata_std_bios_param, | 526 | .bios_param = ata_std_bios_param, |
527 | #ifdef CONFIG_PM | ||
528 | .resume = ata_scsi_device_resume, | ||
529 | .suspend = ata_scsi_device_suspend, | ||
530 | #endif | ||
531 | }; | 527 | }; |
532 | 528 | ||
533 | static const struct ata_port_operations sis_133_ops = { | 529 | static const struct ata_port_operations sis_133_ops = { |
@@ -700,7 +696,7 @@ static const struct ata_port_operations sis_old_ops = { | |||
700 | .port_start = ata_port_start, | 696 | .port_start = ata_port_start, |
701 | }; | 697 | }; |
702 | 698 | ||
703 | static struct ata_port_info sis_info = { | 699 | static const struct ata_port_info sis_info = { |
704 | .sht = &sis_sht, | 700 | .sht = &sis_sht, |
705 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 701 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
706 | .pio_mask = 0x1f, /* pio0-4 */ | 702 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -708,7 +704,7 @@ static struct ata_port_info sis_info = { | |||
708 | .udma_mask = 0, | 704 | .udma_mask = 0, |
709 | .port_ops = &sis_old_ops, | 705 | .port_ops = &sis_old_ops, |
710 | }; | 706 | }; |
711 | static struct ata_port_info sis_info33 = { | 707 | static const struct ata_port_info sis_info33 = { |
712 | .sht = &sis_sht, | 708 | .sht = &sis_sht, |
713 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 709 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
714 | .pio_mask = 0x1f, /* pio0-4 */ | 710 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -716,35 +712,35 @@ static struct ata_port_info sis_info33 = { | |||
716 | .udma_mask = ATA_UDMA2, /* UDMA 33 */ | 712 | .udma_mask = ATA_UDMA2, /* UDMA 33 */ |
717 | .port_ops = &sis_old_ops, | 713 | .port_ops = &sis_old_ops, |
718 | }; | 714 | }; |
719 | static struct ata_port_info sis_info66 = { | 715 | static const struct ata_port_info sis_info66 = { |
720 | .sht = &sis_sht, | 716 | .sht = &sis_sht, |
721 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 717 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
722 | .pio_mask = 0x1f, /* pio0-4 */ | 718 | .pio_mask = 0x1f, /* pio0-4 */ |
723 | .udma_mask = ATA_UDMA4, /* UDMA 66 */ | 719 | .udma_mask = ATA_UDMA4, /* UDMA 66 */ |
724 | .port_ops = &sis_66_ops, | 720 | .port_ops = &sis_66_ops, |
725 | }; | 721 | }; |
726 | static struct ata_port_info sis_info100 = { | 722 | static const struct ata_port_info sis_info100 = { |
727 | .sht = &sis_sht, | 723 | .sht = &sis_sht, |
728 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 724 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
729 | .pio_mask = 0x1f, /* pio0-4 */ | 725 | .pio_mask = 0x1f, /* pio0-4 */ |
730 | .udma_mask = ATA_UDMA5, | 726 | .udma_mask = ATA_UDMA5, |
731 | .port_ops = &sis_100_ops, | 727 | .port_ops = &sis_100_ops, |
732 | }; | 728 | }; |
733 | static struct ata_port_info sis_info100_early = { | 729 | static const struct ata_port_info sis_info100_early = { |
734 | .sht = &sis_sht, | 730 | .sht = &sis_sht, |
735 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 731 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
736 | .udma_mask = ATA_UDMA5, | 732 | .udma_mask = ATA_UDMA5, |
737 | .pio_mask = 0x1f, /* pio0-4 */ | 733 | .pio_mask = 0x1f, /* pio0-4 */ |
738 | .port_ops = &sis_66_ops, | 734 | .port_ops = &sis_66_ops, |
739 | }; | 735 | }; |
740 | struct ata_port_info sis_info133 = { | 736 | const struct ata_port_info sis_info133 = { |
741 | .sht = &sis_sht, | 737 | .sht = &sis_sht, |
742 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 738 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
743 | .pio_mask = 0x1f, /* pio0-4 */ | 739 | .pio_mask = 0x1f, /* pio0-4 */ |
744 | .udma_mask = ATA_UDMA6, | 740 | .udma_mask = ATA_UDMA6, |
745 | .port_ops = &sis_133_ops, | 741 | .port_ops = &sis_133_ops, |
746 | }; | 742 | }; |
747 | static struct ata_port_info sis_info133_early = { | 743 | static const struct ata_port_info sis_info133_early = { |
748 | .sht = &sis_sht, | 744 | .sht = &sis_sht, |
749 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 745 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
750 | .pio_mask = 0x1f, /* pio0-4 */ | 746 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -827,8 +823,8 @@ static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis) | |||
827 | static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 823 | static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
828 | { | 824 | { |
829 | static int printed_version; | 825 | static int printed_version; |
830 | static struct ata_port_info *port_info[2]; | 826 | struct ata_port_info port; |
831 | struct ata_port_info *port; | 827 | const struct ata_port_info *ppi[] = { &port, NULL }; |
832 | struct pci_dev *host = NULL; | 828 | struct pci_dev *host = NULL; |
833 | struct sis_chipset *chipset = NULL; | 829 | struct sis_chipset *chipset = NULL; |
834 | struct sis_chipset *sets; | 830 | struct sis_chipset *sets; |
@@ -968,13 +964,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
968 | if (chipset == NULL) | 964 | if (chipset == NULL) |
969 | return -ENODEV; | 965 | return -ENODEV; |
970 | 966 | ||
971 | port = chipset->info; | 967 | port = *chipset->info; |
972 | port->private_data = chipset; | 968 | port.private_data = chipset; |
973 | 969 | ||
974 | sis_fixup(pdev, chipset); | 970 | sis_fixup(pdev, chipset); |
975 | 971 | ||
976 | port_info[0] = port_info[1] = port; | 972 | return ata_pci_init_one(pdev, ppi); |
977 | return ata_pci_init_one(pdev, port_info, 2); | ||
978 | } | 973 | } |
979 | 974 | ||
980 | static const struct pci_device_id sis_pci_tbl[] = { | 975 | static const struct pci_device_id sis_pci_tbl[] = { |
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c index 9aeffdbe2829..f48491ad5f3a 100644 --- a/drivers/ata/pata_sl82c105.c +++ b/drivers/ata/pata_sl82c105.c | |||
@@ -301,20 +301,22 @@ static int sl82c105_bridge_revision(struct pci_dev *pdev) | |||
301 | 301 | ||
302 | static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 302 | static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
303 | { | 303 | { |
304 | static struct ata_port_info info_dma = { | 304 | static const struct ata_port_info info_dma = { |
305 | .sht = &sl82c105_sht, | 305 | .sht = &sl82c105_sht, |
306 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 306 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
307 | .pio_mask = 0x1f, | 307 | .pio_mask = 0x1f, |
308 | .mwdma_mask = 0x07, | 308 | .mwdma_mask = 0x07, |
309 | .port_ops = &sl82c105_port_ops | 309 | .port_ops = &sl82c105_port_ops |
310 | }; | 310 | }; |
311 | static struct ata_port_info info_early = { | 311 | static const struct ata_port_info info_early = { |
312 | .sht = &sl82c105_sht, | 312 | .sht = &sl82c105_sht, |
313 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 313 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
314 | .pio_mask = 0x1f, | 314 | .pio_mask = 0x1f, |
315 | .port_ops = &sl82c105_port_ops | 315 | .port_ops = &sl82c105_port_ops |
316 | }; | 316 | }; |
317 | static struct ata_port_info *port_info[2] = { &info_early, &info_early }; | 317 | /* for now use only the first port */ |
318 | const struct ata_port_info *ppi[] = { &info_early, | ||
319 | &ata_dummy_port_info }; | ||
318 | u32 val; | 320 | u32 val; |
319 | int rev; | 321 | int rev; |
320 | 322 | ||
@@ -324,17 +326,14 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id | |||
324 | dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); | 326 | dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); |
325 | else if (rev <= 5) | 327 | else if (rev <= 5) |
326 | dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); | 328 | dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); |
327 | else { | 329 | else |
328 | port_info[0] = &info_dma; | 330 | ppi[0] = &info_dma; |
329 | port_info[1] = &info_dma; | ||
330 | } | ||
331 | 331 | ||
332 | pci_read_config_dword(dev, 0x40, &val); | 332 | pci_read_config_dword(dev, 0x40, &val); |
333 | val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; | 333 | val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; |
334 | pci_write_config_dword(dev, 0x40, val); | 334 | pci_write_config_dword(dev, 0x40, val); |
335 | 335 | ||
336 | 336 | return ata_pci_init_one(dev, ppi); | |
337 | return ata_pci_init_one(dev, port_info, 1); /* For now */ | ||
338 | } | 337 | } |
339 | 338 | ||
340 | static const struct pci_device_id sl82c105[] = { | 339 | static const struct pci_device_id sl82c105[] = { |
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c index 349887bf5b93..b1d3076dfe51 100644 --- a/drivers/ata/pata_triflex.c +++ b/drivers/ata/pata_triflex.c | |||
@@ -194,10 +194,6 @@ static struct scsi_host_template triflex_sht = { | |||
194 | .slave_configure = ata_scsi_slave_config, | 194 | .slave_configure = ata_scsi_slave_config, |
195 | .slave_destroy = ata_scsi_slave_destroy, | 195 | .slave_destroy = ata_scsi_slave_destroy, |
196 | .bios_param = ata_std_bios_param, | 196 | .bios_param = ata_std_bios_param, |
197 | #ifdef CONFIG_PM | ||
198 | .resume = ata_scsi_device_resume, | ||
199 | .suspend = ata_scsi_device_suspend, | ||
200 | #endif | ||
201 | }; | 197 | }; |
202 | 198 | ||
203 | static struct ata_port_operations triflex_port_ops = { | 199 | static struct ata_port_operations triflex_port_ops = { |
@@ -237,20 +233,20 @@ static struct ata_port_operations triflex_port_ops = { | |||
237 | 233 | ||
238 | static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 234 | static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
239 | { | 235 | { |
240 | static struct ata_port_info info = { | 236 | static const struct ata_port_info info = { |
241 | .sht = &triflex_sht, | 237 | .sht = &triflex_sht, |
242 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 238 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, |
243 | .pio_mask = 0x1f, | 239 | .pio_mask = 0x1f, |
244 | .mwdma_mask = 0x07, | 240 | .mwdma_mask = 0x07, |
245 | .port_ops = &triflex_port_ops | 241 | .port_ops = &triflex_port_ops |
246 | }; | 242 | }; |
247 | static struct ata_port_info *port_info[2] = { &info, &info }; | 243 | const struct ata_port_info *ppi[] = { &info, NULL }; |
248 | static int printed_version; | 244 | static int printed_version; |
249 | 245 | ||
250 | if (!printed_version++) | 246 | if (!printed_version++) |
251 | dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); | 247 | dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); |
252 | 248 | ||
253 | return ata_pci_init_one(dev, port_info, 2); | 249 | return ata_pci_init_one(dev, ppi); |
254 | } | 250 | } |
255 | 251 | ||
256 | static const struct pci_device_id triflex[] = { | 252 | static const struct pci_device_id triflex[] = { |
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 362beb2f489c..e4c71f76bd55 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -301,10 +301,6 @@ static struct scsi_host_template via_sht = { | |||
301 | .slave_configure = ata_scsi_slave_config, | 301 | .slave_configure = ata_scsi_slave_config, |
302 | .slave_destroy = ata_scsi_slave_destroy, | 302 | .slave_destroy = ata_scsi_slave_destroy, |
303 | .bios_param = ata_std_bios_param, | 303 | .bios_param = ata_std_bios_param, |
304 | #ifdef CONFIG_PM | ||
305 | .resume = ata_scsi_device_resume, | ||
306 | .suspend = ata_scsi_device_suspend, | ||
307 | #endif | ||
308 | }; | 304 | }; |
309 | 305 | ||
310 | static struct ata_port_operations via_port_ops = { | 306 | static struct ata_port_operations via_port_ops = { |
@@ -425,7 +421,7 @@ static void via_config_fifo(struct pci_dev *pdev, unsigned int flags) | |||
425 | static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 421 | static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
426 | { | 422 | { |
427 | /* Early VIA without UDMA support */ | 423 | /* Early VIA without UDMA support */ |
428 | static struct ata_port_info via_mwdma_info = { | 424 | static const struct ata_port_info via_mwdma_info = { |
429 | .sht = &via_sht, | 425 | .sht = &via_sht, |
430 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 426 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
431 | .pio_mask = 0x1f, | 427 | .pio_mask = 0x1f, |
@@ -433,7 +429,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
433 | .port_ops = &via_port_ops | 429 | .port_ops = &via_port_ops |
434 | }; | 430 | }; |
435 | /* Ditto with IRQ masking required */ | 431 | /* Ditto with IRQ masking required */ |
436 | static struct ata_port_info via_mwdma_info_borked = { | 432 | static const struct ata_port_info via_mwdma_info_borked = { |
437 | .sht = &via_sht, | 433 | .sht = &via_sht, |
438 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 434 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
439 | .pio_mask = 0x1f, | 435 | .pio_mask = 0x1f, |
@@ -441,7 +437,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
441 | .port_ops = &via_port_ops_noirq, | 437 | .port_ops = &via_port_ops_noirq, |
442 | }; | 438 | }; |
443 | /* VIA UDMA 33 devices (and borked 66) */ | 439 | /* VIA UDMA 33 devices (and borked 66) */ |
444 | static struct ata_port_info via_udma33_info = { | 440 | static const struct ata_port_info via_udma33_info = { |
445 | .sht = &via_sht, | 441 | .sht = &via_sht, |
446 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 442 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
447 | .pio_mask = 0x1f, | 443 | .pio_mask = 0x1f, |
@@ -450,7 +446,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
450 | .port_ops = &via_port_ops | 446 | .port_ops = &via_port_ops |
451 | }; | 447 | }; |
452 | /* VIA UDMA 66 devices */ | 448 | /* VIA UDMA 66 devices */ |
453 | static struct ata_port_info via_udma66_info = { | 449 | static const struct ata_port_info via_udma66_info = { |
454 | .sht = &via_sht, | 450 | .sht = &via_sht, |
455 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 451 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
456 | .pio_mask = 0x1f, | 452 | .pio_mask = 0x1f, |
@@ -459,7 +455,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
459 | .port_ops = &via_port_ops | 455 | .port_ops = &via_port_ops |
460 | }; | 456 | }; |
461 | /* VIA UDMA 100 devices */ | 457 | /* VIA UDMA 100 devices */ |
462 | static struct ata_port_info via_udma100_info = { | 458 | static const struct ata_port_info via_udma100_info = { |
463 | .sht = &via_sht, | 459 | .sht = &via_sht, |
464 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 460 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
465 | .pio_mask = 0x1f, | 461 | .pio_mask = 0x1f, |
@@ -468,7 +464,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
468 | .port_ops = &via_port_ops | 464 | .port_ops = &via_port_ops |
469 | }; | 465 | }; |
470 | /* UDMA133 with bad AST (All current 133) */ | 466 | /* UDMA133 with bad AST (All current 133) */ |
471 | static struct ata_port_info via_udma133_info = { | 467 | static const struct ata_port_info via_udma133_info = { |
472 | .sht = &via_sht, | 468 | .sht = &via_sht, |
473 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, | 469 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, |
474 | .pio_mask = 0x1f, | 470 | .pio_mask = 0x1f, |
@@ -476,7 +472,8 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
476 | .udma_mask = 0x7f, /* FIXME: should check north bridge */ | 472 | .udma_mask = 0x7f, /* FIXME: should check north bridge */ |
477 | .port_ops = &via_port_ops | 473 | .port_ops = &via_port_ops |
478 | }; | 474 | }; |
479 | struct ata_port_info *port_info[2], *type; | 475 | struct ata_port_info type; |
476 | const struct ata_port_info *ppi[] = { &type, NULL }; | ||
480 | struct pci_dev *isa = NULL; | 477 | struct pci_dev *isa = NULL; |
481 | const struct via_isa_bridge *config; | 478 | const struct via_isa_bridge *config; |
482 | static int printed_version; | 479 | static int printed_version; |
@@ -521,25 +518,25 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
521 | switch(config->flags & VIA_UDMA) { | 518 | switch(config->flags & VIA_UDMA) { |
522 | case VIA_UDMA_NONE: | 519 | case VIA_UDMA_NONE: |
523 | if (config->flags & VIA_NO_UNMASK) | 520 | if (config->flags & VIA_NO_UNMASK) |
524 | type = &via_mwdma_info_borked; | 521 | type = via_mwdma_info_borked; |
525 | else | 522 | else |
526 | type = &via_mwdma_info; | 523 | type = via_mwdma_info; |
527 | break; | 524 | break; |
528 | case VIA_UDMA_33: | 525 | case VIA_UDMA_33: |
529 | type = &via_udma33_info; | 526 | type = via_udma33_info; |
530 | break; | 527 | break; |
531 | case VIA_UDMA_66: | 528 | case VIA_UDMA_66: |
532 | type = &via_udma66_info; | 529 | type = via_udma66_info; |
533 | /* The 66 MHz devices require we enable the clock */ | 530 | /* The 66 MHz devices require we enable the clock */ |
534 | pci_read_config_dword(pdev, 0x50, &timing); | 531 | pci_read_config_dword(pdev, 0x50, &timing); |
535 | timing |= 0x80008; | 532 | timing |= 0x80008; |
536 | pci_write_config_dword(pdev, 0x50, timing); | 533 | pci_write_config_dword(pdev, 0x50, timing); |
537 | break; | 534 | break; |
538 | case VIA_UDMA_100: | 535 | case VIA_UDMA_100: |
539 | type = &via_udma100_info; | 536 | type = via_udma100_info; |
540 | break; | 537 | break; |
541 | case VIA_UDMA_133: | 538 | case VIA_UDMA_133: |
542 | type = &via_udma133_info; | 539 | type = via_udma133_info; |
543 | break; | 540 | break; |
544 | default: | 541 | default: |
545 | WARN_ON(1); | 542 | WARN_ON(1); |
@@ -554,10 +551,9 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
554 | } | 551 | } |
555 | 552 | ||
556 | /* We have established the device type, now fire it up */ | 553 | /* We have established the device type, now fire it up */ |
557 | type->private_data = (void *)config; | 554 | type.private_data = (void *)config; |
558 | 555 | ||
559 | port_info[0] = port_info[1] = type; | 556 | return ata_pci_init_one(pdev, ppi); |
560 | return ata_pci_init_one(pdev, port_info, 2); | ||
561 | } | 557 | } |
562 | 558 | ||
563 | #ifdef CONFIG_PM | 559 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index b3b62e985f19..bda5e7747c21 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c | |||
@@ -135,10 +135,6 @@ static struct scsi_host_template inic_sht = { | |||
135 | .slave_configure = inic_slave_config, | 135 | .slave_configure = inic_slave_config, |
136 | .slave_destroy = ata_scsi_slave_destroy, | 136 | .slave_destroy = ata_scsi_slave_destroy, |
137 | .bios_param = ata_std_bios_param, | 137 | .bios_param = ata_std_bios_param, |
138 | #ifdef CONFIG_PM | ||
139 | .suspend = ata_scsi_device_suspend, | ||
140 | .resume = ata_scsi_device_resume, | ||
141 | #endif | ||
142 | }; | 138 | }; |
143 | 139 | ||
144 | static const int scr_map[] = { | 140 | static const int scr_map[] = { |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index a097595d4dc7..4cea3ef75226 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -325,10 +325,6 @@ static struct scsi_host_template nv_sht = { | |||
325 | .slave_configure = ata_scsi_slave_config, | 325 | .slave_configure = ata_scsi_slave_config, |
326 | .slave_destroy = ata_scsi_slave_destroy, | 326 | .slave_destroy = ata_scsi_slave_destroy, |
327 | .bios_param = ata_std_bios_param, | 327 | .bios_param = ata_std_bios_param, |
328 | #ifdef CONFIG_PM | ||
329 | .suspend = ata_scsi_device_suspend, | ||
330 | .resume = ata_scsi_device_resume, | ||
331 | #endif | ||
332 | }; | 328 | }; |
333 | 329 | ||
334 | static struct scsi_host_template nv_adma_sht = { | 330 | static struct scsi_host_template nv_adma_sht = { |
@@ -347,10 +343,6 @@ static struct scsi_host_template nv_adma_sht = { | |||
347 | .slave_configure = nv_adma_slave_config, | 343 | .slave_configure = nv_adma_slave_config, |
348 | .slave_destroy = ata_scsi_slave_destroy, | 344 | .slave_destroy = ata_scsi_slave_destroy, |
349 | .bios_param = ata_std_bios_param, | 345 | .bios_param = ata_std_bios_param, |
350 | #ifdef CONFIG_PM | ||
351 | .suspend = ata_scsi_device_suspend, | ||
352 | .resume = ata_scsi_device_resume, | ||
353 | #endif | ||
354 | }; | 346 | }; |
355 | 347 | ||
356 | static const struct ata_port_operations nv_generic_ops = { | 348 | static const struct ata_port_operations nv_generic_ops = { |
@@ -465,7 +457,7 @@ static const struct ata_port_operations nv_adma_ops = { | |||
465 | .host_stop = nv_adma_host_stop, | 457 | .host_stop = nv_adma_host_stop, |
466 | }; | 458 | }; |
467 | 459 | ||
468 | static struct ata_port_info nv_port_info[] = { | 460 | static const struct ata_port_info nv_port_info[] = { |
469 | /* generic */ | 461 | /* generic */ |
470 | { | 462 | { |
471 | .sht = &nv_sht, | 463 | .sht = &nv_sht, |
@@ -1545,7 +1537,7 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1545 | static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 1537 | static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
1546 | { | 1538 | { |
1547 | static int printed_version = 0; | 1539 | static int printed_version = 0; |
1548 | const struct ata_port_info *ppi[2]; | 1540 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
1549 | struct ata_host *host; | 1541 | struct ata_host *host; |
1550 | struct nv_host_priv *hpriv; | 1542 | struct nv_host_priv *hpriv; |
1551 | int rc; | 1543 | int rc; |
@@ -1573,8 +1565,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1573 | type = ADMA; | 1565 | type = ADMA; |
1574 | } | 1566 | } |
1575 | 1567 | ||
1576 | ppi[0] = ppi[1] = &nv_port_info[type]; | 1568 | ppi[0] = &nv_port_info[type]; |
1577 | rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); | 1569 | rc = ata_pci_prepare_native_host(pdev, ppi, &host); |
1578 | if (rc) | 1570 | if (rc) |
1579 | return rc; | 1571 | return rc; |
1580 | 1572 | ||
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 0a1e417f309c..e8483aadd11b 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -182,10 +182,6 @@ static struct scsi_host_template sil_sht = { | |||
182 | .slave_configure = ata_scsi_slave_config, | 182 | .slave_configure = ata_scsi_slave_config, |
183 | .slave_destroy = ata_scsi_slave_destroy, | 183 | .slave_destroy = ata_scsi_slave_destroy, |
184 | .bios_param = ata_std_bios_param, | 184 | .bios_param = ata_std_bios_param, |
185 | #ifdef CONFIG_PM | ||
186 | .suspend = ata_scsi_device_suspend, | ||
187 | .resume = ata_scsi_device_resume, | ||
188 | #endif | ||
189 | }; | 185 | }; |
190 | 186 | ||
191 | static const struct ata_port_operations sil_ops = { | 187 | static const struct ata_port_operations sil_ops = { |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index b97ee9f31aec..a69d78cd8e9b 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -380,10 +380,6 @@ static struct scsi_host_template sil24_sht = { | |||
380 | .slave_configure = ata_scsi_slave_config, | 380 | .slave_configure = ata_scsi_slave_config, |
381 | .slave_destroy = ata_scsi_slave_destroy, | 381 | .slave_destroy = ata_scsi_slave_destroy, |
382 | .bios_param = ata_std_bios_param, | 382 | .bios_param = ata_std_bios_param, |
383 | #ifdef CONFIG_PM | ||
384 | .suspend = ata_scsi_device_suspend, | ||
385 | .resume = ata_scsi_device_resume, | ||
386 | #endif | ||
387 | }; | 383 | }; |
388 | 384 | ||
389 | static const struct ata_port_operations sil24_ops = { | 385 | static const struct ata_port_operations sil24_ops = { |
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index d8ee062e82fc..ee66c5fa7ac8 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c | |||
@@ -129,7 +129,7 @@ static const struct ata_port_operations sis_ops = { | |||
129 | .port_start = ata_port_start, | 129 | .port_start = ata_port_start, |
130 | }; | 130 | }; |
131 | 131 | ||
132 | static struct ata_port_info sis_port_info = { | 132 | static const struct ata_port_info sis_port_info = { |
133 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, | 133 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, |
134 | .pio_mask = 0x1f, | 134 | .pio_mask = 0x1f, |
135 | .mwdma_mask = 0x7, | 135 | .mwdma_mask = 0x7, |
@@ -255,7 +255,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
255 | { | 255 | { |
256 | static int printed_version; | 256 | static int printed_version; |
257 | struct ata_port_info pi = sis_port_info; | 257 | struct ata_port_info pi = sis_port_info; |
258 | const struct ata_port_info *ppi[2] = { &pi, &pi }; | 258 | const struct ata_port_info *ppi[] = { &pi, NULL }; |
259 | struct ata_host *host; | 259 | struct ata_host *host; |
260 | u32 genctl, val; | 260 | u32 genctl, val; |
261 | u8 pmr; | 261 | u8 pmr; |
@@ -335,7 +335,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
335 | break; | 335 | break; |
336 | } | 336 | } |
337 | 337 | ||
338 | rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); | 338 | rc = ata_pci_prepare_native_host(pdev, ppi, &host); |
339 | if (rc) | 339 | if (rc) |
340 | return rc; | 340 | return rc; |
341 | 341 | ||
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index f74e383de083..006f5e352658 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -125,7 +125,7 @@ static const struct ata_port_operations uli_ops = { | |||
125 | .port_start = ata_port_start, | 125 | .port_start = ata_port_start, |
126 | }; | 126 | }; |
127 | 127 | ||
128 | static struct ata_port_info uli_port_info = { | 128 | static const struct ata_port_info uli_port_info = { |
129 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 129 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
130 | ATA_FLAG_IGN_SIMPLEX, | 130 | ATA_FLAG_IGN_SIMPLEX, |
131 | .pio_mask = 0x1f, /* pio0-4 */ | 131 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -201,19 +201,33 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
201 | n_ports = 2; | 201 | n_ports = 2; |
202 | if (board_idx == uli_5287) | 202 | if (board_idx == uli_5287) |
203 | n_ports = 4; | 203 | n_ports = 4; |
204 | rc = ata_pci_prepare_native_host(pdev, ppi, n_ports, &host); | 204 | |
205 | if (rc) | 205 | /* allocate the host */ |
206 | return rc; | 206 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); |
207 | if (!host) | ||
208 | return -ENOMEM; | ||
207 | 209 | ||
208 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); | 210 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
209 | if (!hpriv) | 211 | if (!hpriv) |
210 | return -ENOMEM; | 212 | return -ENOMEM; |
211 | host->private_data = hpriv; | 213 | host->private_data = hpriv; |
212 | 214 | ||
215 | /* the first two ports are standard SFF */ | ||
216 | rc = ata_pci_init_native_host(host); | ||
217 | if (rc) | ||
218 | return rc; | ||
219 | |||
220 | rc = ata_pci_init_bmdma(host); | ||
221 | if (rc) | ||
222 | return rc; | ||
223 | |||
213 | iomap = host->iomap; | 224 | iomap = host->iomap; |
214 | 225 | ||
215 | switch (board_idx) { | 226 | switch (board_idx) { |
216 | case uli_5287: | 227 | case uli_5287: |
228 | /* If there are four, the last two live right after | ||
229 | * the standard SFF ports. | ||
230 | */ | ||
217 | hpriv->scr_cfg_addr[0] = ULI5287_BASE; | 231 | hpriv->scr_cfg_addr[0] = ULI5287_BASE; |
218 | hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; | 232 | hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; |
219 | 233 | ||
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index 939c9246fdd1..d105d2c189d2 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -116,10 +116,6 @@ static struct scsi_host_template svia_sht = { | |||
116 | .slave_configure = ata_scsi_slave_config, | 116 | .slave_configure = ata_scsi_slave_config, |
117 | .slave_destroy = ata_scsi_slave_destroy, | 117 | .slave_destroy = ata_scsi_slave_destroy, |
118 | .bios_param = ata_std_bios_param, | 118 | .bios_param = ata_std_bios_param, |
119 | #ifdef CONFIG_PM | ||
120 | .suspend = ata_scsi_device_suspend, | ||
121 | .resume = ata_scsi_device_resume, | ||
122 | #endif | ||
123 | }; | 119 | }; |
124 | 120 | ||
125 | static const struct ata_port_operations vt6420_sata_ops = { | 121 | static const struct ata_port_operations vt6420_sata_ops = { |
@@ -415,7 +411,7 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) | |||
415 | struct ata_host *host; | 411 | struct ata_host *host; |
416 | int rc; | 412 | int rc; |
417 | 413 | ||
418 | rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); | 414 | rc = ata_pci_prepare_native_host(pdev, ppi, &host); |
419 | if (rc) | 415 | if (rc) |
420 | return rc; | 416 | return rc; |
421 | *r_host = host; | 417 | *r_host = host; |
diff --git a/drivers/ata/sis.h b/drivers/ata/sis.h index 231da8fc2200..0f2208d8d5ef 100644 --- a/drivers/ata/sis.h +++ b/drivers/ata/sis.h | |||
@@ -2,4 +2,4 @@ | |||
2 | struct ata_port_info; | 2 | struct ata_port_info; |
3 | 3 | ||
4 | /* pata_sis.c */ | 4 | /* pata_sis.c */ |
5 | extern struct ata_port_info sis_info133; | 5 | extern const struct ata_port_info sis_info133; |
diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig index 33687454eb32..f5a47a48c3b4 100644 --- a/drivers/atm/Kconfig +++ b/drivers/atm/Kconfig | |||
@@ -2,19 +2,22 @@ | |||
2 | # ATM device configuration | 2 | # ATM device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "ATM drivers" | 5 | menuconfig ATM_DRIVERS |
6 | bool "ATM drivers" | ||
6 | depends on NETDEVICES && ATM | 7 | depends on NETDEVICES && ATM |
8 | default y | ||
9 | |||
10 | if ATM_DRIVERS | ||
7 | 11 | ||
8 | config ATM_DUMMY | 12 | config ATM_DUMMY |
9 | tristate "Dummy ATM driver" | 13 | tristate "Dummy ATM driver" |
10 | depends on ATM | ||
11 | help | 14 | help |
12 | Dummy ATM driver. Useful for proxy signalling, testing, | 15 | Dummy ATM driver. Useful for proxy signalling, testing, |
13 | and development. If unsure, say N. | 16 | and development. If unsure, say N. |
14 | 17 | ||
15 | config ATM_TCP | 18 | config ATM_TCP |
16 | tristate "ATM over TCP" | 19 | tristate "ATM over TCP" |
17 | depends on INET && ATM | 20 | depends on INET |
18 | help | 21 | help |
19 | ATM over TCP driver. Useful mainly for development and for | 22 | ATM over TCP driver. Useful mainly for development and for |
20 | experiments. If unsure, say N. | 23 | experiments. If unsure, say N. |
@@ -30,7 +33,7 @@ config ATM_LANAI | |||
30 | 33 | ||
31 | config ATM_ENI | 34 | config ATM_ENI |
32 | tristate "Efficient Networks ENI155P" | 35 | tristate "Efficient Networks ENI155P" |
33 | depends on PCI && ATM | 36 | depends on PCI |
34 | ---help--- | 37 | ---help--- |
35 | Driver for the Efficient Networks ENI155p series and SMC ATM | 38 | Driver for the Efficient Networks ENI155p series and SMC ATM |
36 | Power155 155 Mbps ATM adapters. Both, the versions with 512KB and | 39 | Power155 155 Mbps ATM adapters. Both, the versions with 512KB and |
@@ -139,7 +142,7 @@ config ATM_ENI_BURST_RX_2W | |||
139 | 142 | ||
140 | config ATM_FIRESTREAM | 143 | config ATM_FIRESTREAM |
141 | tristate "Fujitsu FireStream (FS50/FS155) " | 144 | tristate "Fujitsu FireStream (FS50/FS155) " |
142 | depends on PCI && ATM | 145 | depends on PCI |
143 | help | 146 | help |
144 | Driver for the Fujitsu FireStream 155 (MB86697) and | 147 | Driver for the Fujitsu FireStream 155 (MB86697) and |
145 | FireStream 50 (MB86695) ATM PCI chips. | 148 | FireStream 50 (MB86695) ATM PCI chips. |
@@ -149,7 +152,7 @@ config ATM_FIRESTREAM | |||
149 | 152 | ||
150 | config ATM_ZATM | 153 | config ATM_ZATM |
151 | tristate "ZeitNet ZN1221/ZN1225" | 154 | tristate "ZeitNet ZN1221/ZN1225" |
152 | depends on PCI && ATM | 155 | depends on PCI |
153 | help | 156 | help |
154 | Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM | 157 | Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM |
155 | adapters. | 158 | adapters. |
@@ -169,7 +172,7 @@ config ATM_ZATM_DEBUG | |||
169 | 172 | ||
170 | config ATM_NICSTAR | 173 | config ATM_NICSTAR |
171 | tristate "IDT 77201 (NICStAR) (ForeRunnerLE)" | 174 | tristate "IDT 77201 (NICStAR) (ForeRunnerLE)" |
172 | depends on PCI && ATM && !64BIT | 175 | depends on PCI && !64BIT |
173 | help | 176 | help |
174 | The NICStAR chipset family is used in a large number of ATM NICs for | 177 | The NICStAR chipset family is used in a large number of ATM NICs for |
175 | 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE | 178 | 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE |
@@ -202,7 +205,7 @@ config ATM_NICSTAR_USE_IDT77105 | |||
202 | 205 | ||
203 | config ATM_IDT77252 | 206 | config ATM_IDT77252 |
204 | tristate "IDT 77252 (NICStAR II)" | 207 | tristate "IDT 77252 (NICStAR II)" |
205 | depends on PCI && ATM | 208 | depends on PCI |
206 | help | 209 | help |
207 | Driver for the IDT 77252 ATM PCI chips. | 210 | Driver for the IDT 77252 ATM PCI chips. |
208 | 211 | ||
@@ -237,7 +240,7 @@ config ATM_IDT77252_USE_SUNI | |||
237 | 240 | ||
238 | config ATM_AMBASSADOR | 241 | config ATM_AMBASSADOR |
239 | tristate "Madge Ambassador (Collage PCI 155 Server)" | 242 | tristate "Madge Ambassador (Collage PCI 155 Server)" |
240 | depends on PCI && ATM | 243 | depends on PCI |
241 | select BITREVERSE | 244 | select BITREVERSE |
242 | help | 245 | help |
243 | This is a driver for ATMizer based ATM card produced by Madge | 246 | This is a driver for ATMizer based ATM card produced by Madge |
@@ -262,7 +265,7 @@ config ATM_AMBASSADOR_DEBUG | |||
262 | 265 | ||
263 | config ATM_HORIZON | 266 | config ATM_HORIZON |
264 | tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)" | 267 | tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)" |
265 | depends on PCI && ATM | 268 | depends on PCI |
266 | help | 269 | help |
267 | This is a driver for the Horizon chipset ATM adapter cards once | 270 | This is a driver for the Horizon chipset ATM adapter cards once |
268 | produced by Madge Networks Ltd. Say Y (or M to compile as a module | 271 | produced by Madge Networks Ltd. Say Y (or M to compile as a module |
@@ -286,7 +289,7 @@ config ATM_HORIZON_DEBUG | |||
286 | 289 | ||
287 | config ATM_IA | 290 | config ATM_IA |
288 | tristate "Interphase ATM PCI x575/x525/x531" | 291 | tristate "Interphase ATM PCI x575/x525/x531" |
289 | depends on PCI && ATM && !64BIT | 292 | depends on PCI && !64BIT |
290 | ---help--- | 293 | ---help--- |
291 | This is a driver for the Interphase (i)ChipSAR adapter cards | 294 | This is a driver for the Interphase (i)ChipSAR adapter cards |
292 | which include a variety of variants in term of the size of the | 295 | which include a variety of variants in term of the size of the |
@@ -319,7 +322,7 @@ config ATM_IA_DEBUG | |||
319 | 322 | ||
320 | config ATM_FORE200E_MAYBE | 323 | config ATM_FORE200E_MAYBE |
321 | tristate "FORE Systems 200E-series" | 324 | tristate "FORE Systems 200E-series" |
322 | depends on (PCI || SBUS) && ATM | 325 | depends on PCI || SBUS |
323 | ---help--- | 326 | ---help--- |
324 | This is a driver for the FORE Systems 200E-series ATM adapter | 327 | This is a driver for the FORE Systems 200E-series ATM adapter |
325 | cards. It simultaneously supports PCA-200E and SBA-200E models | 328 | cards. It simultaneously supports PCA-200E and SBA-200E models |
@@ -436,7 +439,7 @@ config ATM_FORE200E | |||
436 | 439 | ||
437 | config ATM_HE | 440 | config ATM_HE |
438 | tristate "ForeRunner HE Series" | 441 | tristate "ForeRunner HE Series" |
439 | depends on PCI && ATM | 442 | depends on PCI |
440 | help | 443 | help |
441 | This is a driver for the Marconi ForeRunner HE-series ATM adapter | 444 | This is a driver for the Marconi ForeRunner HE-series ATM adapter |
442 | cards. It simultaneously supports the 155 and 622 versions. | 445 | cards. It simultaneously supports the 155 and 622 versions. |
@@ -448,5 +451,4 @@ config ATM_HE_USE_SUNI | |||
448 | Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner | 451 | Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner |
449 | HE cards. This driver provides carrier detection some statistics. | 452 | HE cards. This driver provides carrier detection some statistics. |
450 | 453 | ||
451 | endmenu | 454 | endif # ATM |
452 | |||
diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig index 0300e7f54cc4..2e18a63ead36 100644 --- a/drivers/auxdisplay/Kconfig +++ b/drivers/auxdisplay/Kconfig | |||
@@ -6,6 +6,7 @@ | |||
6 | # | 6 | # |
7 | 7 | ||
8 | menu "Auxiliary Display support" | 8 | menu "Auxiliary Display support" |
9 | depends on PARPORT | ||
9 | 10 | ||
10 | config KS0108 | 11 | config KS0108 |
11 | tristate "KS0108 LCD Controller" | 12 | tristate "KS0108 LCD Controller" |
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 17ee97f3a99b..b4c8319138b2 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig | |||
@@ -444,8 +444,6 @@ config CDROM_PKTCDVD_WCACHE | |||
444 | this option is dangerous unless the CD-RW media is known good, as we | 444 | this option is dangerous unless the CD-RW media is known good, as we |
445 | don't do deferred write error handling yet. | 445 | don't do deferred write error handling yet. |
446 | 446 | ||
447 | source "drivers/s390/block/Kconfig" | ||
448 | |||
449 | config ATA_OVER_ETH | 447 | config ATA_OVER_ETH |
450 | tristate "ATA over Ethernet support" | 448 | tristate "ATA over Ethernet support" |
451 | depends on NET | 449 | depends on NET |
@@ -453,6 +451,8 @@ config ATA_OVER_ETH | |||
453 | This driver provides Support for ATA over Ethernet block | 451 | This driver provides Support for ATA over Ethernet block |
454 | devices like the Coraid EtherDrive (R) Storage Blade. | 452 | devices like the Coraid EtherDrive (R) Storage Blade. |
455 | 453 | ||
454 | source "drivers/s390/block/Kconfig" | ||
455 | |||
456 | endmenu | 456 | endmenu |
457 | 457 | ||
458 | endif | 458 | endif |
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 18cdd8c77626..5526eadb6592 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -1317,18 +1317,6 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a | |||
1317 | } | 1317 | } |
1318 | #endif | 1318 | #endif |
1319 | 1319 | ||
1320 | static struct loop_device *loop_find_dev(int number) | ||
1321 | { | ||
1322 | struct loop_device *lo; | ||
1323 | |||
1324 | list_for_each_entry(lo, &loop_devices, lo_list) { | ||
1325 | if (lo->lo_number == number) | ||
1326 | return lo; | ||
1327 | } | ||
1328 | return NULL; | ||
1329 | } | ||
1330 | |||
1331 | static struct loop_device *loop_init_one(int i); | ||
1332 | static int lo_open(struct inode *inode, struct file *file) | 1320 | static int lo_open(struct inode *inode, struct file *file) |
1333 | { | 1321 | { |
1334 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1322 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; |
@@ -1337,11 +1325,6 @@ static int lo_open(struct inode *inode, struct file *file) | |||
1337 | lo->lo_refcnt++; | 1325 | lo->lo_refcnt++; |
1338 | mutex_unlock(&lo->lo_ctl_mutex); | 1326 | mutex_unlock(&lo->lo_ctl_mutex); |
1339 | 1327 | ||
1340 | mutex_lock(&loop_devices_mutex); | ||
1341 | if (!loop_find_dev(lo->lo_number + 1)) | ||
1342 | loop_init_one(lo->lo_number + 1); | ||
1343 | mutex_unlock(&loop_devices_mutex); | ||
1344 | |||
1345 | return 0; | 1328 | return 0; |
1346 | } | 1329 | } |
1347 | 1330 | ||
@@ -1416,6 +1399,11 @@ static struct loop_device *loop_init_one(int i) | |||
1416 | struct loop_device *lo; | 1399 | struct loop_device *lo; |
1417 | struct gendisk *disk; | 1400 | struct gendisk *disk; |
1418 | 1401 | ||
1402 | list_for_each_entry(lo, &loop_devices, lo_list) { | ||
1403 | if (lo->lo_number == i) | ||
1404 | return lo; | ||
1405 | } | ||
1406 | |||
1419 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); | 1407 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); |
1420 | if (!lo) | 1408 | if (!lo) |
1421 | goto out; | 1409 | goto out; |
@@ -1448,7 +1436,7 @@ out_free_queue: | |||
1448 | out_free_dev: | 1436 | out_free_dev: |
1449 | kfree(lo); | 1437 | kfree(lo); |
1450 | out: | 1438 | out: |
1451 | return ERR_PTR(-ENOMEM); | 1439 | return NULL; |
1452 | } | 1440 | } |
1453 | 1441 | ||
1454 | static void loop_del_one(struct loop_device *lo) | 1442 | static void loop_del_one(struct loop_device *lo) |
@@ -1462,35 +1450,25 @@ static void loop_del_one(struct loop_device *lo) | |||
1462 | 1450 | ||
1463 | static struct kobject *loop_probe(dev_t dev, int *part, void *data) | 1451 | static struct kobject *loop_probe(dev_t dev, int *part, void *data) |
1464 | { | 1452 | { |
1465 | unsigned int number = dev & MINORMASK; | ||
1466 | struct loop_device *lo; | 1453 | struct loop_device *lo; |
1454 | struct kobject *kobj; | ||
1467 | 1455 | ||
1468 | mutex_lock(&loop_devices_mutex); | 1456 | mutex_lock(&loop_devices_mutex); |
1469 | lo = loop_find_dev(number); | 1457 | lo = loop_init_one(dev & MINORMASK); |
1470 | if (lo == NULL) | 1458 | kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM); |
1471 | lo = loop_init_one(number); | ||
1472 | mutex_unlock(&loop_devices_mutex); | 1459 | mutex_unlock(&loop_devices_mutex); |
1473 | 1460 | ||
1474 | *part = 0; | 1461 | *part = 0; |
1475 | if (IS_ERR(lo)) | 1462 | return kobj; |
1476 | return (void *)lo; | ||
1477 | else | ||
1478 | return &lo->lo_disk->kobj; | ||
1479 | } | 1463 | } |
1480 | 1464 | ||
1481 | static int __init loop_init(void) | 1465 | static int __init loop_init(void) |
1482 | { | 1466 | { |
1483 | struct loop_device *lo; | ||
1484 | |||
1485 | if (register_blkdev(LOOP_MAJOR, "loop")) | 1467 | if (register_blkdev(LOOP_MAJOR, "loop")) |
1486 | return -EIO; | 1468 | return -EIO; |
1487 | blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, | 1469 | blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, |
1488 | THIS_MODULE, loop_probe, NULL, NULL); | 1470 | THIS_MODULE, loop_probe, NULL, NULL); |
1489 | 1471 | ||
1490 | lo = loop_init_one(0); | ||
1491 | if (IS_ERR(lo)) | ||
1492 | goto out; | ||
1493 | |||
1494 | if (max_loop) { | 1472 | if (max_loop) { |
1495 | printk(KERN_INFO "loop: the max_loop option is obsolete " | 1473 | printk(KERN_INFO "loop: the max_loop option is obsolete " |
1496 | "and will be removed in March 2008\n"); | 1474 | "and will be removed in March 2008\n"); |
@@ -1498,11 +1476,6 @@ static int __init loop_init(void) | |||
1498 | } | 1476 | } |
1499 | printk(KERN_INFO "loop: module loaded\n"); | 1477 | printk(KERN_INFO "loop: module loaded\n"); |
1500 | return 0; | 1478 | return 0; |
1501 | |||
1502 | out: | ||
1503 | unregister_blkdev(LOOP_MAJOR, "loop"); | ||
1504 | printk(KERN_ERR "loop: ran out of memory\n"); | ||
1505 | return -ENOMEM; | ||
1506 | } | 1479 | } |
1507 | 1480 | ||
1508 | static void __exit loop_exit(void) | 1481 | static void __exit loop_exit(void) |
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 0f4203b499af..6055b9c0ac0f 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -307,7 +307,9 @@ static void hci_uart_tty_close(struct tty_struct *tty) | |||
307 | 307 | ||
308 | if (hu) { | 308 | if (hu) { |
309 | struct hci_dev *hdev = hu->hdev; | 309 | struct hci_dev *hdev = hu->hdev; |
310 | hci_uart_close(hdev); | 310 | |
311 | if (hdev) | ||
312 | hci_uart_close(hdev); | ||
311 | 313 | ||
312 | if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { | 314 | if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { |
313 | hu->proto->close(hu); | 315 | hu->proto->close(hu); |
@@ -473,12 +475,18 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, | |||
473 | tty->low_latency = 1; | 475 | tty->low_latency = 1; |
474 | } else | 476 | } else |
475 | return -EBUSY; | 477 | return -EBUSY; |
478 | break; | ||
476 | 479 | ||
477 | case HCIUARTGETPROTO: | 480 | case HCIUARTGETPROTO: |
478 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) | 481 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) |
479 | return hu->proto->id; | 482 | return hu->proto->id; |
480 | return -EUNATCH; | 483 | return -EUNATCH; |
481 | 484 | ||
485 | case HCIUARTGETDEVICE: | ||
486 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) | ||
487 | return hu->hdev->id; | ||
488 | return -EUNATCH; | ||
489 | |||
482 | default: | 490 | default: |
483 | err = n_tty_ioctl(tty, file, cmd, arg); | 491 | err = n_tty_ioctl(tty, file, cmd, arg); |
484 | break; | 492 | break; |
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index b250e6789dee..1097ce72393f 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h | |||
@@ -28,8 +28,9 @@ | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | /* Ioctls */ | 30 | /* Ioctls */ |
31 | #define HCIUARTSETPROTO _IOW('U', 200, int) | 31 | #define HCIUARTSETPROTO _IOW('U', 200, int) |
32 | #define HCIUARTGETPROTO _IOR('U', 201, int) | 32 | #define HCIUARTGETPROTO _IOR('U', 201, int) |
33 | #define HCIUARTGETDEVICE _IOR('U', 202, int) | ||
33 | 34 | ||
34 | /* UART protocols */ | 35 | /* UART protocols */ |
35 | #define HCI_UART_MAX_PROTO 4 | 36 | #define HCI_UART_MAX_PROTO 4 |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 2df42fdcdc91..abcafac64738 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -6,6 +6,7 @@ menu "Character devices" | |||
6 | 6 | ||
7 | config VT | 7 | config VT |
8 | bool "Virtual terminal" if EMBEDDED | 8 | bool "Virtual terminal" if EMBEDDED |
9 | depends on !S390 | ||
9 | select INPUT | 10 | select INPUT |
10 | default y if !VIOCONS | 11 | default y if !VIOCONS |
11 | ---help--- | 12 | ---help--- |
@@ -81,6 +82,7 @@ config VT_HW_CONSOLE_BINDING | |||
81 | 82 | ||
82 | config SERIAL_NONSTANDARD | 83 | config SERIAL_NONSTANDARD |
83 | bool "Non-standard serial port support" | 84 | bool "Non-standard serial port support" |
85 | depends on HAS_IOMEM | ||
84 | ---help--- | 86 | ---help--- |
85 | Say Y here if you have any non-standard serial boards -- boards | 87 | Say Y here if you have any non-standard serial boards -- boards |
86 | which aren't supported using the standard "dumb" serial driver. | 88 | which aren't supported using the standard "dumb" serial driver. |
@@ -765,7 +767,7 @@ config NVRAM | |||
765 | 767 | ||
766 | config RTC | 768 | config RTC |
767 | tristate "Enhanced Real Time Clock Support" | 769 | tristate "Enhanced Real Time Clock Support" |
768 | depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV && !ARM && !SUPERH | 770 | depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV && !ARM && !SUPERH && !S390 |
769 | ---help--- | 771 | ---help--- |
770 | If you say Y here and create a character special file /dev/rtc with | 772 | If you say Y here and create a character special file /dev/rtc with |
771 | major number 10 and minor number 135 using mknod ("man mknod"), you | 773 | major number 10 and minor number 135 using mknod ("man mknod"), you |
@@ -813,7 +815,7 @@ config SGI_IP27_RTC | |||
813 | 815 | ||
814 | config GEN_RTC | 816 | config GEN_RTC |
815 | tristate "Generic /dev/rtc emulation" | 817 | tristate "Generic /dev/rtc emulation" |
816 | depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV | 818 | depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV && !S390 |
817 | ---help--- | 819 | ---help--- |
818 | If you say Y here and create a character special file /dev/rtc with | 820 | If you say Y here and create a character special file /dev/rtc with |
819 | major number 10 and minor number 135 using mknod ("man mknod"), you | 821 | major number 10 and minor number 135 using mknod ("man mknod"), you |
@@ -858,6 +860,7 @@ config COBALT_LCD | |||
858 | 860 | ||
859 | config DTLK | 861 | config DTLK |
860 | tristate "Double Talk PC internal speech card support" | 862 | tristate "Double Talk PC internal speech card support" |
863 | depends on ISA | ||
861 | help | 864 | help |
862 | This driver is for the DoubleTalk PC, a speech synthesizer | 865 | This driver is for the DoubleTalk PC, a speech synthesizer |
863 | manufactured by RC Systems (<http://www.rcsys.com/>). It is also | 866 | manufactured by RC Systems (<http://www.rcsys.com/>). It is also |
@@ -1043,7 +1046,7 @@ config HPET_MMAP | |||
1043 | 1046 | ||
1044 | config HANGCHECK_TIMER | 1047 | config HANGCHECK_TIMER |
1045 | tristate "Hangcheck timer" | 1048 | tristate "Hangcheck timer" |
1046 | depends on X86 || IA64 || PPC64 | 1049 | depends on X86 || IA64 || PPC64 || S390 |
1047 | help | 1050 | help |
1048 | The hangcheck-timer module detects when the system has gone | 1051 | The hangcheck-timer module detects when the system has gone |
1049 | out to lunch past a certain margin. It can reboot the system | 1052 | out to lunch past a certain margin. It can reboot the system |
@@ -1078,5 +1081,7 @@ config DEVPORT | |||
1078 | depends on ISA || PCI | 1081 | depends on ISA || PCI |
1079 | default y | 1082 | default y |
1080 | 1083 | ||
1084 | source "drivers/s390/char/Kconfig" | ||
1085 | |||
1081 | endmenu | 1086 | endmenu |
1082 | 1087 | ||
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index c9f0f250d78f..801abdd29066 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -268,7 +268,7 @@ static int __devinit aperture_valid(u64 aper, u32 size) | |||
268 | printk(KERN_ERR PFX "Aperture too small (%d MB)\n", size>>20); | 268 | printk(KERN_ERR PFX "Aperture too small (%d MB)\n", size>>20); |
269 | return 0; | 269 | return 0; |
270 | } | 270 | } |
271 | if (aper + size > 0xffffffff) { | 271 | if ((u64)aper + size > 0x100000000ULL) { |
272 | printk(KERN_ERR PFX "Aperture out of bounds\n"); | 272 | printk(KERN_ERR PFX "Aperture out of bounds\n"); |
273 | return 0; | 273 | return 0; |
274 | } | 274 | } |
diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig index a6dcb2918157..b894f67fdf14 100644 --- a/drivers/char/ipmi/Kconfig +++ b/drivers/char/ipmi/Kconfig | |||
@@ -3,6 +3,8 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "IPMI" | 5 | menu "IPMI" |
6 | depends on HAS_IOMEM | ||
7 | |||
6 | config IPMI_HANDLER | 8 | config IPMI_HANDLER |
7 | tristate 'IPMI top-level message handler' | 9 | tristate 'IPMI top-level message handler' |
8 | help | 10 | help |
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 6c5d15de3317..78e1b962fe35 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -1915,10 +1915,10 @@ static __devinit int try_init_acpi(struct SPMITable *spmi) | |||
1915 | 1915 | ||
1916 | if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { | 1916 | if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { |
1917 | info->io_setup = mem_setup; | 1917 | info->io_setup = mem_setup; |
1918 | info->io.addr_type = IPMI_IO_ADDR_SPACE; | 1918 | info->io.addr_type = IPMI_MEM_ADDR_SPACE; |
1919 | } else if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_IO) { | 1919 | } else if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_IO) { |
1920 | info->io_setup = port_setup; | 1920 | info->io_setup = port_setup; |
1921 | info->io.addr_type = IPMI_MEM_ADDR_SPACE; | 1921 | info->io.addr_type = IPMI_IO_ADDR_SPACE; |
1922 | } else { | 1922 | } else { |
1923 | kfree(info); | 1923 | kfree(info); |
1924 | printk("ipmi_si: Unknown ACPI I/O Address type\n"); | 1924 | printk("ipmi_si: Unknown ACPI I/O Address type\n"); |
@@ -2974,6 +2974,10 @@ static __devinit int init_ipmi_si(void) | |||
2974 | #ifdef CONFIG_PCI | 2974 | #ifdef CONFIG_PCI |
2975 | pci_unregister_driver(&ipmi_pci_driver); | 2975 | pci_unregister_driver(&ipmi_pci_driver); |
2976 | #endif | 2976 | #endif |
2977 | |||
2978 | #ifdef CONFIG_PPC_OF | ||
2979 | of_unregister_platform_driver(&ipmi_of_platform_driver); | ||
2980 | #endif | ||
2977 | driver_unregister(&ipmi_driver); | 2981 | driver_unregister(&ipmi_driver); |
2978 | printk("ipmi_si: Unable to find any System Interface(s)\n"); | 2982 | printk("ipmi_si: Unable to find any System Interface(s)\n"); |
2979 | return -ENODEV; | 2983 | return -ENODEV; |
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 147c12047cf3..41f78e2c158f 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c | |||
@@ -50,18 +50,10 @@ | |||
50 | #include <linux/poll.h> | 50 | #include <linux/poll.h> |
51 | #include <linux/string.h> | 51 | #include <linux/string.h> |
52 | #include <linux/ctype.h> | 52 | #include <linux/ctype.h> |
53 | #include <linux/delay.h> | ||
54 | #include <asm/atomic.h> | 53 | #include <asm/atomic.h> |
55 | 54 | ||
56 | #ifdef CONFIG_X86 | 55 | #ifdef CONFIG_X86_LOCAL_APIC |
57 | /* This is ugly, but I've determined that x86 is the only architecture | 56 | #include <asm/apic.h> |
58 | that can reasonably support the IPMI NMI watchdog timeout at this | ||
59 | time. If another architecture adds this capability somehow, it | ||
60 | will have to be a somewhat different mechanism and I have no idea | ||
61 | how it will work. So in the unlikely event that another | ||
62 | architecture supports this, we can figure out a good generic | ||
63 | mechanism for it at that time. */ | ||
64 | #define HAVE_DIE_NMI_POST | ||
65 | #endif | 57 | #endif |
66 | 58 | ||
67 | #define PFX "IPMI Watchdog: " | 59 | #define PFX "IPMI Watchdog: " |
@@ -327,11 +319,6 @@ static unsigned char ipmi_version_minor; | |||
327 | /* If a pretimeout occurs, this is used to allow only one panic to happen. */ | 319 | /* If a pretimeout occurs, this is used to allow only one panic to happen. */ |
328 | static atomic_t preop_panic_excl = ATOMIC_INIT(-1); | 320 | static atomic_t preop_panic_excl = ATOMIC_INIT(-1); |
329 | 321 | ||
330 | #ifdef HAVE_DIE_NMI_POST | ||
331 | static int testing_nmi; | ||
332 | static int nmi_handler_registered; | ||
333 | #endif | ||
334 | |||
335 | static int ipmi_heartbeat(void); | 322 | static int ipmi_heartbeat(void); |
336 | static void panic_halt_ipmi_heartbeat(void); | 323 | static void panic_halt_ipmi_heartbeat(void); |
337 | 324 | ||
@@ -373,10 +360,6 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, | |||
373 | int hbnow = 0; | 360 | int hbnow = 0; |
374 | 361 | ||
375 | 362 | ||
376 | /* These can be cleared as we are setting the timeout. */ | ||
377 | ipmi_start_timer_on_heartbeat = 0; | ||
378 | pretimeout_since_last_heartbeat = 0; | ||
379 | |||
380 | data[0] = 0; | 363 | data[0] = 0; |
381 | WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); | 364 | WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); |
382 | 365 | ||
@@ -451,12 +434,13 @@ static int ipmi_set_timeout(int do_heartbeat) | |||
451 | 434 | ||
452 | wait_for_completion(&set_timeout_wait); | 435 | wait_for_completion(&set_timeout_wait); |
453 | 436 | ||
454 | mutex_unlock(&set_timeout_lock); | ||
455 | |||
456 | if ((do_heartbeat == IPMI_SET_TIMEOUT_FORCE_HB) | 437 | if ((do_heartbeat == IPMI_SET_TIMEOUT_FORCE_HB) |
457 | || ((send_heartbeat_now) | 438 | || ((send_heartbeat_now) |
458 | && (do_heartbeat == IPMI_SET_TIMEOUT_HB_IF_NECESSARY))) | 439 | && (do_heartbeat == IPMI_SET_TIMEOUT_HB_IF_NECESSARY))) |
440 | { | ||
459 | rv = ipmi_heartbeat(); | 441 | rv = ipmi_heartbeat(); |
442 | } | ||
443 | mutex_unlock(&set_timeout_lock); | ||
460 | 444 | ||
461 | out: | 445 | out: |
462 | return rv; | 446 | return rv; |
@@ -536,10 +520,12 @@ static int ipmi_heartbeat(void) | |||
536 | int rv; | 520 | int rv; |
537 | struct ipmi_system_interface_addr addr; | 521 | struct ipmi_system_interface_addr addr; |
538 | 522 | ||
539 | if (ipmi_ignore_heartbeat) | 523 | if (ipmi_ignore_heartbeat) { |
540 | return 0; | 524 | return 0; |
525 | } | ||
541 | 526 | ||
542 | if (ipmi_start_timer_on_heartbeat) { | 527 | if (ipmi_start_timer_on_heartbeat) { |
528 | ipmi_start_timer_on_heartbeat = 0; | ||
543 | ipmi_watchdog_state = action_val; | 529 | ipmi_watchdog_state = action_val; |
544 | return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); | 530 | return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); |
545 | } else if (pretimeout_since_last_heartbeat) { | 531 | } else if (pretimeout_since_last_heartbeat) { |
@@ -547,6 +533,7 @@ static int ipmi_heartbeat(void) | |||
547 | We don't want to set the action, though, we want to | 533 | We don't want to set the action, though, we want to |
548 | leave that alone (thus it can't be combined with the | 534 | leave that alone (thus it can't be combined with the |
549 | above operation. */ | 535 | above operation. */ |
536 | pretimeout_since_last_heartbeat = 0; | ||
550 | return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); | 537 | return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); |
551 | } | 538 | } |
552 | 539 | ||
@@ -934,45 +921,6 @@ static void ipmi_register_watchdog(int ipmi_intf) | |||
934 | printk(KERN_CRIT PFX "Unable to register misc device\n"); | 921 | printk(KERN_CRIT PFX "Unable to register misc device\n"); |
935 | } | 922 | } |
936 | 923 | ||
937 | #ifdef HAVE_DIE_NMI_POST | ||
938 | if (nmi_handler_registered) { | ||
939 | int old_pretimeout = pretimeout; | ||
940 | int old_timeout = timeout; | ||
941 | int old_preop_val = preop_val; | ||
942 | |||
943 | /* Set the pretimeout to go off in a second and give | ||
944 | ourselves plenty of time to stop the timer. */ | ||
945 | ipmi_watchdog_state = WDOG_TIMEOUT_RESET; | ||
946 | preop_val = WDOG_PREOP_NONE; /* Make sure nothing happens */ | ||
947 | pretimeout = 99; | ||
948 | timeout = 100; | ||
949 | |||
950 | testing_nmi = 1; | ||
951 | |||
952 | rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); | ||
953 | if (rv) { | ||
954 | printk(KERN_WARNING PFX "Error starting timer to" | ||
955 | " test NMI: 0x%x. The NMI pretimeout will" | ||
956 | " likely not work\n", rv); | ||
957 | rv = 0; | ||
958 | goto out_restore; | ||
959 | } | ||
960 | |||
961 | msleep(1500); | ||
962 | |||
963 | if (testing_nmi != 2) { | ||
964 | printk(KERN_WARNING PFX "IPMI NMI didn't seem to" | ||
965 | " occur. The NMI pretimeout will" | ||
966 | " likely not work\n"); | ||
967 | } | ||
968 | out_restore: | ||
969 | testing_nmi = 0; | ||
970 | preop_val = old_preop_val; | ||
971 | pretimeout = old_pretimeout; | ||
972 | timeout = old_timeout; | ||
973 | } | ||
974 | #endif | ||
975 | |||
976 | out: | 924 | out: |
977 | up_write(®ister_sem); | 925 | up_write(®ister_sem); |
978 | 926 | ||
@@ -982,10 +930,6 @@ static void ipmi_register_watchdog(int ipmi_intf) | |||
982 | ipmi_watchdog_state = action_val; | 930 | ipmi_watchdog_state = action_val; |
983 | ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); | 931 | ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); |
984 | printk(KERN_INFO PFX "Starting now!\n"); | 932 | printk(KERN_INFO PFX "Starting now!\n"); |
985 | } else { | ||
986 | /* Stop the timer now. */ | ||
987 | ipmi_watchdog_state = WDOG_TIMEOUT_NONE; | ||
988 | ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); | ||
989 | } | 933 | } |
990 | } | 934 | } |
991 | 935 | ||
@@ -1022,28 +966,17 @@ static void ipmi_unregister_watchdog(int ipmi_intf) | |||
1022 | up_write(®ister_sem); | 966 | up_write(®ister_sem); |
1023 | } | 967 | } |
1024 | 968 | ||
1025 | #ifdef HAVE_DIE_NMI_POST | 969 | #ifdef HAVE_NMI_HANDLER |
1026 | static int | 970 | static int |
1027 | ipmi_nmi(struct notifier_block *self, unsigned long val, void *data) | 971 | ipmi_nmi(void *dev_id, int cpu, int handled) |
1028 | { | 972 | { |
1029 | if (val != DIE_NMI_POST) | ||
1030 | return NOTIFY_OK; | ||
1031 | |||
1032 | if (testing_nmi) { | ||
1033 | testing_nmi = 2; | ||
1034 | return NOTIFY_STOP; | ||
1035 | } | ||
1036 | |||
1037 | /* If we are not expecting a timeout, ignore it. */ | 973 | /* If we are not expecting a timeout, ignore it. */ |
1038 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) | 974 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) |
1039 | return NOTIFY_OK; | 975 | return NOTIFY_DONE; |
1040 | |||
1041 | if (preaction_val != WDOG_PRETIMEOUT_NMI) | ||
1042 | return NOTIFY_OK; | ||
1043 | 976 | ||
1044 | /* If no one else handled the NMI, we assume it was the IPMI | 977 | /* If no one else handled the NMI, we assume it was the IPMI |
1045 | watchdog. */ | 978 | watchdog. */ |
1046 | if (preop_val == WDOG_PREOP_PANIC) { | 979 | if ((!handled) && (preop_val == WDOG_PREOP_PANIC)) { |
1047 | /* On some machines, the heartbeat will give | 980 | /* On some machines, the heartbeat will give |
1048 | an error and not work unless we re-enable | 981 | an error and not work unless we re-enable |
1049 | the timer. So do so. */ | 982 | the timer. So do so. */ |
@@ -1052,12 +985,18 @@ ipmi_nmi(struct notifier_block *self, unsigned long val, void *data) | |||
1052 | panic(PFX "pre-timeout"); | 985 | panic(PFX "pre-timeout"); |
1053 | } | 986 | } |
1054 | 987 | ||
1055 | return NOTIFY_STOP; | 988 | return NOTIFY_DONE; |
1056 | } | 989 | } |
1057 | 990 | ||
1058 | static struct notifier_block ipmi_nmi_handler = { | 991 | static struct nmi_handler ipmi_nmi_handler = |
1059 | .notifier_call = ipmi_nmi | 992 | { |
993 | .link = LIST_HEAD_INIT(ipmi_nmi_handler.link), | ||
994 | .dev_name = "ipmi_watchdog", | ||
995 | .dev_id = NULL, | ||
996 | .handler = ipmi_nmi, | ||
997 | .priority = 0, /* Call us last. */ | ||
1060 | }; | 998 | }; |
999 | int nmi_handler_registered; | ||
1061 | #endif | 1000 | #endif |
1062 | 1001 | ||
1063 | static int wdog_reboot_handler(struct notifier_block *this, | 1002 | static int wdog_reboot_handler(struct notifier_block *this, |
@@ -1174,7 +1113,7 @@ static int preaction_op(const char *inval, char *outval) | |||
1174 | preaction_val = WDOG_PRETIMEOUT_NONE; | 1113 | preaction_val = WDOG_PRETIMEOUT_NONE; |
1175 | else if (strcmp(inval, "pre_smi") == 0) | 1114 | else if (strcmp(inval, "pre_smi") == 0) |
1176 | preaction_val = WDOG_PRETIMEOUT_SMI; | 1115 | preaction_val = WDOG_PRETIMEOUT_SMI; |
1177 | #ifdef HAVE_DIE_NMI_POST | 1116 | #ifdef HAVE_NMI_HANDLER |
1178 | else if (strcmp(inval, "pre_nmi") == 0) | 1117 | else if (strcmp(inval, "pre_nmi") == 0) |
1179 | preaction_val = WDOG_PRETIMEOUT_NMI; | 1118 | preaction_val = WDOG_PRETIMEOUT_NMI; |
1180 | #endif | 1119 | #endif |
@@ -1208,7 +1147,7 @@ static int preop_op(const char *inval, char *outval) | |||
1208 | 1147 | ||
1209 | static void check_parms(void) | 1148 | static void check_parms(void) |
1210 | { | 1149 | { |
1211 | #ifdef HAVE_DIE_NMI_POST | 1150 | #ifdef HAVE_NMI_HANDLER |
1212 | int do_nmi = 0; | 1151 | int do_nmi = 0; |
1213 | int rv; | 1152 | int rv; |
1214 | 1153 | ||
@@ -1221,9 +1160,20 @@ static void check_parms(void) | |||
1221 | preop_op("preop_none", NULL); | 1160 | preop_op("preop_none", NULL); |
1222 | do_nmi = 0; | 1161 | do_nmi = 0; |
1223 | } | 1162 | } |
1163 | #ifdef CONFIG_X86_LOCAL_APIC | ||
1164 | if (nmi_watchdog == NMI_IO_APIC) { | ||
1165 | printk(KERN_WARNING PFX "nmi_watchdog is set to IO APIC" | ||
1166 | " mode (value is %d), that is incompatible" | ||
1167 | " with using NMI in the IPMI watchdog." | ||
1168 | " Disabling IPMI nmi pretimeout.\n", | ||
1169 | nmi_watchdog); | ||
1170 | preaction_val = WDOG_PRETIMEOUT_NONE; | ||
1171 | do_nmi = 0; | ||
1172 | } | ||
1173 | #endif | ||
1224 | } | 1174 | } |
1225 | if (do_nmi && !nmi_handler_registered) { | 1175 | if (do_nmi && !nmi_handler_registered) { |
1226 | rv = register_die_notifier(&ipmi_nmi_handler); | 1176 | rv = request_nmi(&ipmi_nmi_handler); |
1227 | if (rv) { | 1177 | if (rv) { |
1228 | printk(KERN_WARNING PFX | 1178 | printk(KERN_WARNING PFX |
1229 | "Can't register nmi handler\n"); | 1179 | "Can't register nmi handler\n"); |
@@ -1231,7 +1181,7 @@ static void check_parms(void) | |||
1231 | } else | 1181 | } else |
1232 | nmi_handler_registered = 1; | 1182 | nmi_handler_registered = 1; |
1233 | } else if (!do_nmi && nmi_handler_registered) { | 1183 | } else if (!do_nmi && nmi_handler_registered) { |
1234 | unregister_die_notifier(&ipmi_nmi_handler); | 1184 | release_nmi(&ipmi_nmi_handler); |
1235 | nmi_handler_registered = 0; | 1185 | nmi_handler_registered = 0; |
1236 | } | 1186 | } |
1237 | #endif | 1187 | #endif |
@@ -1267,9 +1217,9 @@ static int __init ipmi_wdog_init(void) | |||
1267 | 1217 | ||
1268 | rv = ipmi_smi_watcher_register(&smi_watcher); | 1218 | rv = ipmi_smi_watcher_register(&smi_watcher); |
1269 | if (rv) { | 1219 | if (rv) { |
1270 | #ifdef HAVE_DIE_NMI_POST | 1220 | #ifdef HAVE_NMI_HANDLER |
1271 | if (nmi_handler_registered) | 1221 | if (preaction_val == WDOG_PRETIMEOUT_NMI) |
1272 | unregister_die_notifier(&ipmi_nmi_handler); | 1222 | release_nmi(&ipmi_nmi_handler); |
1273 | #endif | 1223 | #endif |
1274 | atomic_notifier_chain_unregister(&panic_notifier_list, | 1224 | atomic_notifier_chain_unregister(&panic_notifier_list, |
1275 | &wdog_panic_notifier); | 1225 | &wdog_panic_notifier); |
@@ -1288,9 +1238,9 @@ static void __exit ipmi_wdog_exit(void) | |||
1288 | ipmi_smi_watcher_unregister(&smi_watcher); | 1238 | ipmi_smi_watcher_unregister(&smi_watcher); |
1289 | ipmi_unregister_watchdog(watchdog_ifnum); | 1239 | ipmi_unregister_watchdog(watchdog_ifnum); |
1290 | 1240 | ||
1291 | #ifdef HAVE_DIE_NMI_POST | 1241 | #ifdef HAVE_NMI_HANDLER |
1292 | if (nmi_handler_registered) | 1242 | if (nmi_handler_registered) |
1293 | unregister_die_notifier(&ipmi_nmi_handler); | 1243 | release_nmi(&ipmi_nmi_handler); |
1294 | #endif | 1244 | #endif |
1295 | 1245 | ||
1296 | atomic_notifier_chain_unregister(&panic_notifier_list, | 1246 | atomic_notifier_chain_unregister(&panic_notifier_list, |
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 6ac3ca4c723c..b3d4ccc33a47 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -1544,21 +1544,18 @@ static unsigned int normal_poll(struct tty_struct * tty, struct file * file, pol | |||
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | struct tty_ldisc tty_ldisc_N_TTY = { | 1546 | struct tty_ldisc tty_ldisc_N_TTY = { |
1547 | TTY_LDISC_MAGIC, /* magic */ | 1547 | .magic = TTY_LDISC_MAGIC, |
1548 | "n_tty", /* name */ | 1548 | .name = "n_tty", |
1549 | 0, /* num */ | 1549 | .open = n_tty_open, |
1550 | 0, /* flags */ | 1550 | .close = n_tty_close, |
1551 | n_tty_open, /* open */ | 1551 | .flush_buffer = n_tty_flush_buffer, |
1552 | n_tty_close, /* close */ | 1552 | .chars_in_buffer = n_tty_chars_in_buffer, |
1553 | n_tty_flush_buffer, /* flush_buffer */ | 1553 | .read = read_chan, |
1554 | n_tty_chars_in_buffer, /* chars_in_buffer */ | 1554 | .write = write_chan, |
1555 | read_chan, /* read */ | 1555 | .ioctl = n_tty_ioctl, |
1556 | write_chan, /* write */ | 1556 | .set_termios = n_tty_set_termios, |
1557 | n_tty_ioctl, /* ioctl */ | 1557 | .poll = normal_poll, |
1558 | n_tty_set_termios, /* set_termios */ | 1558 | .receive_buf = n_tty_receive_buf, |
1559 | normal_poll, /* poll */ | 1559 | .write_wakeup = n_tty_write_wakeup |
1560 | NULL, /* hangup */ | ||
1561 | n_tty_receive_buf, /* receive_buf */ | ||
1562 | n_tty_write_wakeup /* write_wakeup */ | ||
1563 | }; | 1560 | }; |
1564 | 1561 | ||
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c index 245f03195b7c..8cc60b693460 100644 --- a/drivers/char/rio/riocmd.c +++ b/drivers/char/rio/riocmd.c | |||
@@ -402,7 +402,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc | |||
402 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); | 402 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); |
403 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); | 403 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); |
404 | 404 | ||
405 | if (Rup >= (unsigned short) MAX_RUP) { | 405 | if (Rup < (unsigned short) MAX_RUP) { |
406 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); | 406 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); |
407 | } else | 407 | } else |
408 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); | 408 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); |
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index 61a63da420c2..a3fd7e7ba5a9 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c | |||
@@ -1014,9 +1014,6 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
1014 | /* | 1014 | /* |
1015 | * Info->count is now 1; so it's safe to sleep now. | 1015 | * Info->count is now 1; so it's safe to sleep now. |
1016 | */ | 1016 | */ |
1017 | info->session = process_session(current); | ||
1018 | info->pgrp = process_group(current); | ||
1019 | |||
1020 | if ((info->flags & ROCKET_INITIALIZED) == 0) { | 1017 | if ((info->flags & ROCKET_INITIALIZED) == 0) { |
1021 | cp = &info->channel; | 1018 | cp = &info->channel; |
1022 | sSetRxTrigger(cp, TRIG_1); | 1019 | sSetRxTrigger(cp, TRIG_1); |
diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h index 89b4d7b10d12..b4c53dfa7951 100644 --- a/drivers/char/rocket_int.h +++ b/drivers/char/rocket_int.h | |||
@@ -1158,8 +1158,6 @@ struct r_port { | |||
1158 | int xmit_head; | 1158 | int xmit_head; |
1159 | int xmit_tail; | 1159 | int xmit_tail; |
1160 | int xmit_cnt; | 1160 | int xmit_cnt; |
1161 | int session; | ||
1162 | int pgrp; | ||
1163 | int cd_status; | 1161 | int cd_status; |
1164 | int ignore_status_mask; | 1162 | int ignore_status_mask; |
1165 | int read_status_mask; | 1163 | int read_status_mask; |
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c index 2f56e8c54897..1b75b0b7d542 100644 --- a/drivers/char/snsc_event.c +++ b/drivers/char/snsc_event.c | |||
@@ -203,8 +203,6 @@ scdrv_dispatch_event(char *event, int len) | |||
203 | class = (code & EV_CLASS_MASK); | 203 | class = (code & EV_CLASS_MASK); |
204 | 204 | ||
205 | if (class == EV_CLASS_PWRD_NOTIFY || code == ENV_PWRDN_PEND) { | 205 | if (class == EV_CLASS_PWRD_NOTIFY || code == ENV_PWRDN_PEND) { |
206 | struct task_struct *p; | ||
207 | |||
208 | if (snsc_shutting_down) | 206 | if (snsc_shutting_down) |
209 | return; | 207 | return; |
210 | 208 | ||
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 2a7736b5f2f7..02b49bc00028 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -1171,6 +1171,112 @@ static int ioctl(struct tty_struct *tty, struct file *file, | |||
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | /* | 1173 | /* |
1174 | * support for 32 bit ioctl calls on 64 bit systems | ||
1175 | */ | ||
1176 | #ifdef CONFIG_COMPAT | ||
1177 | static long get_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *user_params) | ||
1178 | { | ||
1179 | struct MGSL_PARAMS32 tmp_params; | ||
1180 | |||
1181 | DBGINFO(("%s get_params32\n", info->device_name)); | ||
1182 | tmp_params.mode = (compat_ulong_t)info->params.mode; | ||
1183 | tmp_params.loopback = info->params.loopback; | ||
1184 | tmp_params.flags = info->params.flags; | ||
1185 | tmp_params.encoding = info->params.encoding; | ||
1186 | tmp_params.clock_speed = (compat_ulong_t)info->params.clock_speed; | ||
1187 | tmp_params.addr_filter = info->params.addr_filter; | ||
1188 | tmp_params.crc_type = info->params.crc_type; | ||
1189 | tmp_params.preamble_length = info->params.preamble_length; | ||
1190 | tmp_params.preamble = info->params.preamble; | ||
1191 | tmp_params.data_rate = (compat_ulong_t)info->params.data_rate; | ||
1192 | tmp_params.data_bits = info->params.data_bits; | ||
1193 | tmp_params.stop_bits = info->params.stop_bits; | ||
1194 | tmp_params.parity = info->params.parity; | ||
1195 | if (copy_to_user(user_params, &tmp_params, sizeof(struct MGSL_PARAMS32))) | ||
1196 | return -EFAULT; | ||
1197 | return 0; | ||
1198 | } | ||
1199 | |||
1200 | static long set_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *new_params) | ||
1201 | { | ||
1202 | struct MGSL_PARAMS32 tmp_params; | ||
1203 | |||
1204 | DBGINFO(("%s set_params32\n", info->device_name)); | ||
1205 | if (copy_from_user(&tmp_params, new_params, sizeof(struct MGSL_PARAMS32))) | ||
1206 | return -EFAULT; | ||
1207 | |||
1208 | spin_lock(&info->lock); | ||
1209 | info->params.mode = tmp_params.mode; | ||
1210 | info->params.loopback = tmp_params.loopback; | ||
1211 | info->params.flags = tmp_params.flags; | ||
1212 | info->params.encoding = tmp_params.encoding; | ||
1213 | info->params.clock_speed = tmp_params.clock_speed; | ||
1214 | info->params.addr_filter = tmp_params.addr_filter; | ||
1215 | info->params.crc_type = tmp_params.crc_type; | ||
1216 | info->params.preamble_length = tmp_params.preamble_length; | ||
1217 | info->params.preamble = tmp_params.preamble; | ||
1218 | info->params.data_rate = tmp_params.data_rate; | ||
1219 | info->params.data_bits = tmp_params.data_bits; | ||
1220 | info->params.stop_bits = tmp_params.stop_bits; | ||
1221 | info->params.parity = tmp_params.parity; | ||
1222 | spin_unlock(&info->lock); | ||
1223 | |||
1224 | change_params(info); | ||
1225 | |||
1226 | return 0; | ||
1227 | } | ||
1228 | |||
1229 | static long slgt_compat_ioctl(struct tty_struct *tty, struct file *file, | ||
1230 | unsigned int cmd, unsigned long arg) | ||
1231 | { | ||
1232 | struct slgt_info *info = tty->driver_data; | ||
1233 | int rc = -ENOIOCTLCMD; | ||
1234 | |||
1235 | if (sanity_check(info, tty->name, "compat_ioctl")) | ||
1236 | return -ENODEV; | ||
1237 | DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd)); | ||
1238 | |||
1239 | switch (cmd) { | ||
1240 | |||
1241 | case MGSL_IOCSPARAMS32: | ||
1242 | rc = set_params32(info, compat_ptr(arg)); | ||
1243 | break; | ||
1244 | |||
1245 | case MGSL_IOCGPARAMS32: | ||
1246 | rc = get_params32(info, compat_ptr(arg)); | ||
1247 | break; | ||
1248 | |||
1249 | case MGSL_IOCGPARAMS: | ||
1250 | case MGSL_IOCSPARAMS: | ||
1251 | case MGSL_IOCGTXIDLE: | ||
1252 | case MGSL_IOCGSTATS: | ||
1253 | case MGSL_IOCWAITEVENT: | ||
1254 | case MGSL_IOCGIF: | ||
1255 | case MGSL_IOCSGPIO: | ||
1256 | case MGSL_IOCGGPIO: | ||
1257 | case MGSL_IOCWAITGPIO: | ||
1258 | case TIOCGICOUNT: | ||
1259 | rc = ioctl(tty, file, cmd, (unsigned long)(compat_ptr(arg))); | ||
1260 | break; | ||
1261 | |||
1262 | case MGSL_IOCSTXIDLE: | ||
1263 | case MGSL_IOCTXENABLE: | ||
1264 | case MGSL_IOCRXENABLE: | ||
1265 | case MGSL_IOCTXABORT: | ||
1266 | case TIOCMIWAIT: | ||
1267 | case MGSL_IOCSIF: | ||
1268 | rc = ioctl(tty, file, cmd, arg); | ||
1269 | break; | ||
1270 | } | ||
1271 | |||
1272 | DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc)); | ||
1273 | return rc; | ||
1274 | } | ||
1275 | #else | ||
1276 | #define slgt_compat_ioctl NULL | ||
1277 | #endif /* ifdef CONFIG_COMPAT */ | ||
1278 | |||
1279 | /* | ||
1174 | * proc fs support | 1280 | * proc fs support |
1175 | */ | 1281 | */ |
1176 | static inline int line_info(char *buf, struct slgt_info *info) | 1282 | static inline int line_info(char *buf, struct slgt_info *info) |
@@ -3446,6 +3552,7 @@ static const struct tty_operations ops = { | |||
3446 | .chars_in_buffer = chars_in_buffer, | 3552 | .chars_in_buffer = chars_in_buffer, |
3447 | .flush_buffer = flush_buffer, | 3553 | .flush_buffer = flush_buffer, |
3448 | .ioctl = ioctl, | 3554 | .ioctl = ioctl, |
3555 | .compat_ioctl = slgt_compat_ioctl, | ||
3449 | .throttle = throttle, | 3556 | .throttle = throttle, |
3450 | .unthrottle = unthrottle, | 3557 | .unthrottle = unthrottle, |
3451 | .send_xchar = send_xchar, | 3558 | .send_xchar = send_xchar, |
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index 11089be0691b..dc4e1ff7f56f 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "TPM devices" | 5 | menu "TPM devices" |
6 | depends on HAS_IOMEM | ||
6 | 7 | ||
7 | config TCG_TPM | 8 | config TCG_TPM |
8 | tristate "TPM Hardware Support" | 9 | tristate "TPM Hardware Support" |
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h index c912d8691cbd..9363bcf0a402 100644 --- a/drivers/char/tpm/tpm_atmel.h +++ b/drivers/char/tpm/tpm_atmel.h | |||
@@ -23,6 +23,9 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifdef CONFIG_PPC64 | 25 | #ifdef CONFIG_PPC64 |
26 | |||
27 | #include <asm/prom.h> | ||
28 | |||
26 | #define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset); | 29 | #define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset); |
27 | #define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset) | 30 | #define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset) |
28 | #define atmel_request_region request_mem_region | 31 | #define atmel_request_region request_mem_region |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index fc662e4ce58a..75d2a46e106f 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -151,6 +151,12 @@ static int tty_open(struct inode *, struct file *); | |||
151 | static int tty_release(struct inode *, struct file *); | 151 | static int tty_release(struct inode *, struct file *); |
152 | int tty_ioctl(struct inode * inode, struct file * file, | 152 | int tty_ioctl(struct inode * inode, struct file * file, |
153 | unsigned int cmd, unsigned long arg); | 153 | unsigned int cmd, unsigned long arg); |
154 | #ifdef CONFIG_COMPAT | ||
155 | static long tty_compat_ioctl(struct file * file, unsigned int cmd, | ||
156 | unsigned long arg); | ||
157 | #else | ||
158 | #define tty_compat_ioctl NULL | ||
159 | #endif | ||
154 | static int tty_fasync(int fd, struct file * filp, int on); | 160 | static int tty_fasync(int fd, struct file * filp, int on); |
155 | static void release_tty(struct tty_struct *tty, int idx); | 161 | static void release_tty(struct tty_struct *tty, int idx); |
156 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); | 162 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); |
@@ -363,6 +369,29 @@ static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b) | |||
363 | } | 369 | } |
364 | 370 | ||
365 | /** | 371 | /** |
372 | * tty_buffer_flush - flush full tty buffers | ||
373 | * @tty: tty to flush | ||
374 | * | ||
375 | * flush all the buffers containing receive data | ||
376 | * | ||
377 | * Locking: none | ||
378 | */ | ||
379 | |||
380 | static void tty_buffer_flush(struct tty_struct *tty) | ||
381 | { | ||
382 | struct tty_buffer *thead; | ||
383 | unsigned long flags; | ||
384 | |||
385 | spin_lock_irqsave(&tty->buf.lock, flags); | ||
386 | while((thead = tty->buf.head) != NULL) { | ||
387 | tty->buf.head = thead->next; | ||
388 | tty_buffer_free(tty, thead); | ||
389 | } | ||
390 | tty->buf.tail = NULL; | ||
391 | spin_unlock_irqrestore(&tty->buf.lock, flags); | ||
392 | } | ||
393 | |||
394 | /** | ||
366 | * tty_buffer_find - find a free tty buffer | 395 | * tty_buffer_find - find a free tty buffer |
367 | * @tty: tty owning the buffer | 396 | * @tty: tty owning the buffer |
368 | * @size: characters wanted | 397 | * @size: characters wanted |
@@ -1143,8 +1172,8 @@ static unsigned int hung_up_tty_poll(struct file * filp, poll_table * wait) | |||
1143 | return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM; | 1172 | return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM; |
1144 | } | 1173 | } |
1145 | 1174 | ||
1146 | static int hung_up_tty_ioctl(struct inode * inode, struct file * file, | 1175 | static long hung_up_tty_ioctl(struct file * file, |
1147 | unsigned int cmd, unsigned long arg) | 1176 | unsigned int cmd, unsigned long arg) |
1148 | { | 1177 | { |
1149 | return cmd == TIOCSPGRP ? -ENOTTY : -EIO; | 1178 | return cmd == TIOCSPGRP ? -ENOTTY : -EIO; |
1150 | } | 1179 | } |
@@ -1155,6 +1184,7 @@ static const struct file_operations tty_fops = { | |||
1155 | .write = tty_write, | 1184 | .write = tty_write, |
1156 | .poll = tty_poll, | 1185 | .poll = tty_poll, |
1157 | .ioctl = tty_ioctl, | 1186 | .ioctl = tty_ioctl, |
1187 | .compat_ioctl = tty_compat_ioctl, | ||
1158 | .open = tty_open, | 1188 | .open = tty_open, |
1159 | .release = tty_release, | 1189 | .release = tty_release, |
1160 | .fasync = tty_fasync, | 1190 | .fasync = tty_fasync, |
@@ -1167,6 +1197,7 @@ static const struct file_operations ptmx_fops = { | |||
1167 | .write = tty_write, | 1197 | .write = tty_write, |
1168 | .poll = tty_poll, | 1198 | .poll = tty_poll, |
1169 | .ioctl = tty_ioctl, | 1199 | .ioctl = tty_ioctl, |
1200 | .compat_ioctl = tty_compat_ioctl, | ||
1170 | .open = ptmx_open, | 1201 | .open = ptmx_open, |
1171 | .release = tty_release, | 1202 | .release = tty_release, |
1172 | .fasync = tty_fasync, | 1203 | .fasync = tty_fasync, |
@@ -1179,6 +1210,7 @@ static const struct file_operations console_fops = { | |||
1179 | .write = redirected_tty_write, | 1210 | .write = redirected_tty_write, |
1180 | .poll = tty_poll, | 1211 | .poll = tty_poll, |
1181 | .ioctl = tty_ioctl, | 1212 | .ioctl = tty_ioctl, |
1213 | .compat_ioctl = tty_compat_ioctl, | ||
1182 | .open = tty_open, | 1214 | .open = tty_open, |
1183 | .release = tty_release, | 1215 | .release = tty_release, |
1184 | .fasync = tty_fasync, | 1216 | .fasync = tty_fasync, |
@@ -1189,7 +1221,8 @@ static const struct file_operations hung_up_tty_fops = { | |||
1189 | .read = hung_up_tty_read, | 1221 | .read = hung_up_tty_read, |
1190 | .write = hung_up_tty_write, | 1222 | .write = hung_up_tty_write, |
1191 | .poll = hung_up_tty_poll, | 1223 | .poll = hung_up_tty_poll, |
1192 | .ioctl = hung_up_tty_ioctl, | 1224 | .unlocked_ioctl = hung_up_tty_ioctl, |
1225 | .compat_ioctl = hung_up_tty_ioctl, | ||
1193 | .release = tty_release, | 1226 | .release = tty_release, |
1194 | }; | 1227 | }; |
1195 | 1228 | ||
@@ -1238,6 +1271,7 @@ void tty_ldisc_flush(struct tty_struct *tty) | |||
1238 | ld->flush_buffer(tty); | 1271 | ld->flush_buffer(tty); |
1239 | tty_ldisc_deref(ld); | 1272 | tty_ldisc_deref(ld); |
1240 | } | 1273 | } |
1274 | tty_buffer_flush(tty); | ||
1241 | } | 1275 | } |
1242 | 1276 | ||
1243 | EXPORT_SYMBOL_GPL(tty_ldisc_flush); | 1277 | EXPORT_SYMBOL_GPL(tty_ldisc_flush); |
@@ -3340,6 +3374,15 @@ int tty_ioctl(struct inode * inode, struct file * file, | |||
3340 | case TIOCMBIC: | 3374 | case TIOCMBIC: |
3341 | case TIOCMBIS: | 3375 | case TIOCMBIS: |
3342 | return tty_tiocmset(tty, file, cmd, p); | 3376 | return tty_tiocmset(tty, file, cmd, p); |
3377 | case TCFLSH: | ||
3378 | switch (arg) { | ||
3379 | case TCIFLUSH: | ||
3380 | case TCIOFLUSH: | ||
3381 | /* flush tty buffer and allow ldisc to process ioctl */ | ||
3382 | tty_buffer_flush(tty); | ||
3383 | break; | ||
3384 | } | ||
3385 | break; | ||
3343 | } | 3386 | } |
3344 | if (tty->driver->ioctl) { | 3387 | if (tty->driver->ioctl) { |
3345 | retval = (tty->driver->ioctl)(tty, file, cmd, arg); | 3388 | retval = (tty->driver->ioctl)(tty, file, cmd, arg); |
@@ -3357,6 +3400,32 @@ int tty_ioctl(struct inode * inode, struct file * file, | |||
3357 | return retval; | 3400 | return retval; |
3358 | } | 3401 | } |
3359 | 3402 | ||
3403 | #ifdef CONFIG_COMPAT | ||
3404 | static long tty_compat_ioctl(struct file * file, unsigned int cmd, | ||
3405 | unsigned long arg) | ||
3406 | { | ||
3407 | struct inode *inode = file->f_dentry->d_inode; | ||
3408 | struct tty_struct *tty = file->private_data; | ||
3409 | struct tty_ldisc *ld; | ||
3410 | int retval = -ENOIOCTLCMD; | ||
3411 | |||
3412 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | ||
3413 | return -EINVAL; | ||
3414 | |||
3415 | if (tty->driver->compat_ioctl) { | ||
3416 | retval = (tty->driver->compat_ioctl)(tty, file, cmd, arg); | ||
3417 | if (retval != -ENOIOCTLCMD) | ||
3418 | return retval; | ||
3419 | } | ||
3420 | |||
3421 | ld = tty_ldisc_ref_wait(tty); | ||
3422 | if (ld->compat_ioctl) | ||
3423 | retval = ld->compat_ioctl(tty, file, cmd, arg); | ||
3424 | tty_ldisc_deref(ld); | ||
3425 | |||
3426 | return retval; | ||
3427 | } | ||
3428 | #endif | ||
3360 | 3429 | ||
3361 | /* | 3430 | /* |
3362 | * This implements the "Secure Attention Key" --- the idea is to | 3431 | * This implements the "Secure Attention Key" --- the idea is to |
@@ -3689,6 +3758,7 @@ void tty_set_operations(struct tty_driver *driver, | |||
3689 | driver->write_room = op->write_room; | 3758 | driver->write_room = op->write_room; |
3690 | driver->chars_in_buffer = op->chars_in_buffer; | 3759 | driver->chars_in_buffer = op->chars_in_buffer; |
3691 | driver->ioctl = op->ioctl; | 3760 | driver->ioctl = op->ioctl; |
3761 | driver->compat_ioctl = op->compat_ioctl; | ||
3692 | driver->set_termios = op->set_termios; | 3762 | driver->set_termios = op->set_termios; |
3693 | driver->throttle = op->throttle; | 3763 | driver->throttle = op->throttle; |
3694 | driver->unthrottle = op->unthrottle; | 3764 | driver->unthrottle = op->unthrottle; |
@@ -3843,6 +3913,7 @@ void proc_clear_tty(struct task_struct *p) | |||
3843 | p->signal->tty = NULL; | 3913 | p->signal->tty = NULL; |
3844 | spin_unlock_irq(&p->sighand->siglock); | 3914 | spin_unlock_irq(&p->sighand->siglock); |
3845 | } | 3915 | } |
3916 | EXPORT_SYMBOL(proc_clear_tty); | ||
3846 | 3917 | ||
3847 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) | 3918 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) |
3848 | { | 3919 | { |
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index 60198a78974c..1cad32c62ed3 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig | |||
@@ -2,9 +2,7 @@ | |||
2 | # Watchdog device configuration | 2 | # Watchdog device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Watchdog Cards" | 5 | menuconfig WATCHDOG |
6 | |||
7 | config WATCHDOG | ||
8 | bool "Watchdog Timer Support" | 6 | bool "Watchdog Timer Support" |
9 | ---help--- | 7 | ---help--- |
10 | If you say Y here (and to one of the following options) and create a | 8 | If you say Y here (and to one of the following options) and create a |
@@ -28,9 +26,10 @@ config WATCHDOG | |||
28 | 26 | ||
29 | If unsure, say N. | 27 | If unsure, say N. |
30 | 28 | ||
29 | if WATCHDOG | ||
30 | |||
31 | config WATCHDOG_NOWAYOUT | 31 | config WATCHDOG_NOWAYOUT |
32 | bool "Disable watchdog shutdown on close" | 32 | bool "Disable watchdog shutdown on close" |
33 | depends on WATCHDOG | ||
34 | help | 33 | help |
35 | The default watchdog behaviour (which you get if you say N here) is | 34 | The default watchdog behaviour (which you get if you say N here) is |
36 | to stop the timer if the process managing it closes the file | 35 | to stop the timer if the process managing it closes the file |
@@ -43,13 +42,11 @@ config WATCHDOG_NOWAYOUT | |||
43 | # | 42 | # |
44 | 43 | ||
45 | comment "Watchdog Device Drivers" | 44 | comment "Watchdog Device Drivers" |
46 | depends on WATCHDOG | ||
47 | 45 | ||
48 | # Architecture Independent | 46 | # Architecture Independent |
49 | 47 | ||
50 | config SOFT_WATCHDOG | 48 | config SOFT_WATCHDOG |
51 | tristate "Software watchdog" | 49 | tristate "Software watchdog" |
52 | depends on WATCHDOG | ||
53 | help | 50 | help |
54 | A software monitoring watchdog. This will fail to reboot your system | 51 | A software monitoring watchdog. This will fail to reboot your system |
55 | from some situations that the hardware watchdog will recover | 52 | from some situations that the hardware watchdog will recover |
@@ -62,14 +59,14 @@ config SOFT_WATCHDOG | |||
62 | 59 | ||
63 | config AT91RM9200_WATCHDOG | 60 | config AT91RM9200_WATCHDOG |
64 | tristate "AT91RM9200 watchdog" | 61 | tristate "AT91RM9200 watchdog" |
65 | depends on WATCHDOG && ARCH_AT91RM9200 | 62 | depends on ARCH_AT91RM9200 |
66 | help | 63 | help |
67 | Watchdog timer embedded into AT91RM9200 chips. This will reboot your | 64 | Watchdog timer embedded into AT91RM9200 chips. This will reboot your |
68 | system when the timeout is reached. | 65 | system when the timeout is reached. |
69 | 66 | ||
70 | config 21285_WATCHDOG | 67 | config 21285_WATCHDOG |
71 | tristate "DC21285 watchdog" | 68 | tristate "DC21285 watchdog" |
72 | depends on WATCHDOG && FOOTBRIDGE | 69 | depends on FOOTBRIDGE |
73 | help | 70 | help |
74 | The Intel Footbridge chip contains a built-in watchdog circuit. Say Y | 71 | The Intel Footbridge chip contains a built-in watchdog circuit. Say Y |
75 | here if you wish to use this. Alternatively say M to compile the | 72 | here if you wish to use this. Alternatively say M to compile the |
@@ -83,7 +80,7 @@ config 21285_WATCHDOG | |||
83 | 80 | ||
84 | config 977_WATCHDOG | 81 | config 977_WATCHDOG |
85 | tristate "NetWinder WB83C977 watchdog" | 82 | tristate "NetWinder WB83C977 watchdog" |
86 | depends on WATCHDOG && FOOTBRIDGE && ARCH_NETWINDER | 83 | depends on FOOTBRIDGE && ARCH_NETWINDER |
87 | help | 84 | help |
88 | Say Y here to include support for the WB977 watchdog included in | 85 | Say Y here to include support for the WB977 watchdog included in |
89 | NetWinder machines. Alternatively say M to compile the driver as | 86 | NetWinder machines. Alternatively say M to compile the driver as |
@@ -93,7 +90,7 @@ config 977_WATCHDOG | |||
93 | 90 | ||
94 | config IXP2000_WATCHDOG | 91 | config IXP2000_WATCHDOG |
95 | tristate "IXP2000 Watchdog" | 92 | tristate "IXP2000 Watchdog" |
96 | depends on WATCHDOG && ARCH_IXP2000 | 93 | depends on ARCH_IXP2000 |
97 | help | 94 | help |
98 | Say Y here if to include support for the watchdog timer | 95 | Say Y here if to include support for the watchdog timer |
99 | in the Intel IXP2000(2400, 2800, 2850) network processors. | 96 | in the Intel IXP2000(2400, 2800, 2850) network processors. |
@@ -104,7 +101,7 @@ config IXP2000_WATCHDOG | |||
104 | 101 | ||
105 | config IXP4XX_WATCHDOG | 102 | config IXP4XX_WATCHDOG |
106 | tristate "IXP4xx Watchdog" | 103 | tristate "IXP4xx Watchdog" |
107 | depends on WATCHDOG && ARCH_IXP4XX | 104 | depends on ARCH_IXP4XX |
108 | help | 105 | help |
109 | Say Y here if to include support for the watchdog timer | 106 | Say Y here if to include support for the watchdog timer |
110 | in the Intel IXP4xx network processors. This driver can | 107 | in the Intel IXP4xx network processors. This driver can |
@@ -120,7 +117,7 @@ config IXP4XX_WATCHDOG | |||
120 | 117 | ||
121 | config S3C2410_WATCHDOG | 118 | config S3C2410_WATCHDOG |
122 | tristate "S3C2410 Watchdog" | 119 | tristate "S3C2410 Watchdog" |
123 | depends on WATCHDOG && ARCH_S3C2410 | 120 | depends on ARCH_S3C2410 |
124 | help | 121 | help |
125 | Watchdog timer block in the Samsung S3C2410 chips. This will | 122 | Watchdog timer block in the Samsung S3C2410 chips. This will |
126 | reboot the system when the timer expires with the watchdog | 123 | reboot the system when the timer expires with the watchdog |
@@ -136,7 +133,7 @@ config S3C2410_WATCHDOG | |||
136 | 133 | ||
137 | config SA1100_WATCHDOG | 134 | config SA1100_WATCHDOG |
138 | tristate "SA1100/PXA2xx watchdog" | 135 | tristate "SA1100/PXA2xx watchdog" |
139 | depends on WATCHDOG && ( ARCH_SA1100 || ARCH_PXA ) | 136 | depends on ARCH_SA1100 || ARCH_PXA |
140 | help | 137 | help |
141 | Watchdog timer embedded into SA11x0 and PXA2xx chips. This will | 138 | Watchdog timer embedded into SA11x0 and PXA2xx chips. This will |
142 | reboot your system when timeout is reached. | 139 | reboot your system when timeout is reached. |
@@ -148,7 +145,7 @@ config SA1100_WATCHDOG | |||
148 | 145 | ||
149 | config MPCORE_WATCHDOG | 146 | config MPCORE_WATCHDOG |
150 | tristate "MPcore watchdog" | 147 | tristate "MPcore watchdog" |
151 | depends on WATCHDOG && ARM_MPCORE_PLATFORM && LOCAL_TIMERS | 148 | depends on ARM_MPCORE_PLATFORM && LOCAL_TIMERS |
152 | help | 149 | help |
153 | Watchdog timer embedded into the MPcore system. | 150 | Watchdog timer embedded into the MPcore system. |
154 | 151 | ||
@@ -157,7 +154,7 @@ config MPCORE_WATCHDOG | |||
157 | 154 | ||
158 | config EP93XX_WATCHDOG | 155 | config EP93XX_WATCHDOG |
159 | tristate "EP93xx Watchdog" | 156 | tristate "EP93xx Watchdog" |
160 | depends on WATCHDOG && ARCH_EP93XX | 157 | depends on ARCH_EP93XX |
161 | help | 158 | help |
162 | Say Y here if to include support for the watchdog timer | 159 | Say Y here if to include support for the watchdog timer |
163 | embedded in the Cirrus Logic EP93xx family of devices. | 160 | embedded in the Cirrus Logic EP93xx family of devices. |
@@ -167,14 +164,14 @@ config EP93XX_WATCHDOG | |||
167 | 164 | ||
168 | config OMAP_WATCHDOG | 165 | config OMAP_WATCHDOG |
169 | tristate "OMAP Watchdog" | 166 | tristate "OMAP Watchdog" |
170 | depends on WATCHDOG && (ARCH_OMAP16XX || ARCH_OMAP24XX) | 167 | depends on ARCH_OMAP16XX || ARCH_OMAP24XX |
171 | help | 168 | help |
172 | Support for TI OMAP1610/OMAP1710/OMAP2420 watchdog. Say 'Y' here to | 169 | Support for TI OMAP1610/OMAP1710/OMAP2420 watchdog. Say 'Y' here to |
173 | enable the OMAP1610/OMAP1710 watchdog timer. | 170 | enable the OMAP1610/OMAP1710 watchdog timer. |
174 | 171 | ||
175 | config PNX4008_WATCHDOG | 172 | config PNX4008_WATCHDOG |
176 | tristate "PNX4008 Watchdog" | 173 | tristate "PNX4008 Watchdog" |
177 | depends on WATCHDOG && ARCH_PNX4008 | 174 | depends on ARCH_PNX4008 |
178 | help | 175 | help |
179 | Say Y here if to include support for the watchdog timer | 176 | Say Y here if to include support for the watchdog timer |
180 | in the PNX4008 processor. | 177 | in the PNX4008 processor. |
@@ -187,7 +184,7 @@ config PNX4008_WATCHDOG | |||
187 | 184 | ||
188 | config ACQUIRE_WDT | 185 | config ACQUIRE_WDT |
189 | tristate "Acquire SBC Watchdog Timer" | 186 | tristate "Acquire SBC Watchdog Timer" |
190 | depends on WATCHDOG && X86 | 187 | depends on X86 |
191 | ---help--- | 188 | ---help--- |
192 | This is the driver for the hardware watchdog on Single Board | 189 | This is the driver for the hardware watchdog on Single Board |
193 | Computers produced by Acquire Inc (and others). This watchdog | 190 | Computers produced by Acquire Inc (and others). This watchdog |
@@ -201,7 +198,7 @@ config ACQUIRE_WDT | |||
201 | 198 | ||
202 | config ADVANTECH_WDT | 199 | config ADVANTECH_WDT |
203 | tristate "Advantech SBC Watchdog Timer" | 200 | tristate "Advantech SBC Watchdog Timer" |
204 | depends on WATCHDOG && X86 | 201 | depends on X86 |
205 | help | 202 | help |
206 | If you are configuring a Linux kernel for the Advantech single-board | 203 | If you are configuring a Linux kernel for the Advantech single-board |
207 | computer, say `Y' here to support its built-in watchdog timer | 204 | computer, say `Y' here to support its built-in watchdog timer |
@@ -210,7 +207,7 @@ config ADVANTECH_WDT | |||
210 | 207 | ||
211 | config ALIM1535_WDT | 208 | config ALIM1535_WDT |
212 | tristate "ALi M1535 PMU Watchdog Timer" | 209 | tristate "ALi M1535 PMU Watchdog Timer" |
213 | depends on WATCHDOG && X86 && PCI | 210 | depends on X86 && PCI |
214 | ---help--- | 211 | ---help--- |
215 | This is the driver for the hardware watchdog on the ALi M1535 PMU. | 212 | This is the driver for the hardware watchdog on the ALi M1535 PMU. |
216 | 213 | ||
@@ -221,7 +218,7 @@ config ALIM1535_WDT | |||
221 | 218 | ||
222 | config ALIM7101_WDT | 219 | config ALIM7101_WDT |
223 | tristate "ALi M7101 PMU Computer Watchdog" | 220 | tristate "ALi M7101 PMU Computer Watchdog" |
224 | depends on WATCHDOG && X86 && PCI | 221 | depends on X86 && PCI |
225 | help | 222 | help |
226 | This is the driver for the hardware watchdog on the ALi M7101 PMU | 223 | This is the driver for the hardware watchdog on the ALi M7101 PMU |
227 | as used in the x86 Cobalt servers. | 224 | as used in the x86 Cobalt servers. |
@@ -233,7 +230,7 @@ config ALIM7101_WDT | |||
233 | 230 | ||
234 | config SC520_WDT | 231 | config SC520_WDT |
235 | tristate "AMD Elan SC520 processor Watchdog" | 232 | tristate "AMD Elan SC520 processor Watchdog" |
236 | depends on WATCHDOG && X86 | 233 | depends on X86 |
237 | help | 234 | help |
238 | This is the driver for the hardware watchdog built in to the | 235 | This is the driver for the hardware watchdog built in to the |
239 | AMD "Elan" SC520 microcomputer commonly used in embedded systems. | 236 | AMD "Elan" SC520 microcomputer commonly used in embedded systems. |
@@ -246,7 +243,7 @@ config SC520_WDT | |||
246 | 243 | ||
247 | config EUROTECH_WDT | 244 | config EUROTECH_WDT |
248 | tristate "Eurotech CPU-1220/1410 Watchdog Timer" | 245 | tristate "Eurotech CPU-1220/1410 Watchdog Timer" |
249 | depends on WATCHDOG && X86 | 246 | depends on X86 |
250 | help | 247 | help |
251 | Enable support for the watchdog timer on the Eurotech CPU-1220 and | 248 | Enable support for the watchdog timer on the Eurotech CPU-1220 and |
252 | CPU-1410 cards. These are PC/104 SBCs. Spec sheets and product | 249 | CPU-1410 cards. These are PC/104 SBCs. Spec sheets and product |
@@ -254,7 +251,7 @@ config EUROTECH_WDT | |||
254 | 251 | ||
255 | config IB700_WDT | 252 | config IB700_WDT |
256 | tristate "IB700 SBC Watchdog Timer" | 253 | tristate "IB700 SBC Watchdog Timer" |
257 | depends on WATCHDOG && X86 | 254 | depends on X86 |
258 | ---help--- | 255 | ---help--- |
259 | This is the driver for the hardware watchdog on the IB700 Single | 256 | This is the driver for the hardware watchdog on the IB700 Single |
260 | Board Computer produced by TMC Technology (www.tmc-uk.com). This watchdog | 257 | Board Computer produced by TMC Technology (www.tmc-uk.com). This watchdog |
@@ -270,7 +267,7 @@ config IB700_WDT | |||
270 | 267 | ||
271 | config IBMASR | 268 | config IBMASR |
272 | tristate "IBM Automatic Server Restart" | 269 | tristate "IBM Automatic Server Restart" |
273 | depends on WATCHDOG && X86 | 270 | depends on X86 |
274 | help | 271 | help |
275 | This is the driver for the IBM Automatic Server Restart watchdog | 272 | This is the driver for the IBM Automatic Server Restart watchdog |
276 | timer built-in into some eServer xSeries machines. | 273 | timer built-in into some eServer xSeries machines. |
@@ -280,7 +277,7 @@ config IBMASR | |||
280 | 277 | ||
281 | config WAFER_WDT | 278 | config WAFER_WDT |
282 | tristate "ICP Wafer 5823 Single Board Computer Watchdog" | 279 | tristate "ICP Wafer 5823 Single Board Computer Watchdog" |
283 | depends on WATCHDOG && X86 | 280 | depends on X86 |
284 | help | 281 | help |
285 | This is a driver for the hardware watchdog on the ICP Wafer 5823 | 282 | This is a driver for the hardware watchdog on the ICP Wafer 5823 |
286 | Single Board Computer (and probably other similar models). | 283 | Single Board Computer (and probably other similar models). |
@@ -290,7 +287,7 @@ config WAFER_WDT | |||
290 | 287 | ||
291 | config I6300ESB_WDT | 288 | config I6300ESB_WDT |
292 | tristate "Intel 6300ESB Timer/Watchdog" | 289 | tristate "Intel 6300ESB Timer/Watchdog" |
293 | depends on WATCHDOG && X86 && PCI | 290 | depends on X86 && PCI |
294 | ---help--- | 291 | ---help--- |
295 | Hardware driver for the watchdog timer built into the Intel | 292 | Hardware driver for the watchdog timer built into the Intel |
296 | 6300ESB controller hub. | 293 | 6300ESB controller hub. |
@@ -298,31 +295,9 @@ config I6300ESB_WDT | |||
298 | To compile this driver as a module, choose M here: the | 295 | To compile this driver as a module, choose M here: the |
299 | module will be called i6300esb. | 296 | module will be called i6300esb. |
300 | 297 | ||
301 | config I8XX_TCO | ||
302 | tristate "Intel i8xx TCO Timer/Watchdog" | ||
303 | depends on WATCHDOG && (X86 || IA64) && PCI | ||
304 | default n | ||
305 | ---help--- | ||
306 | Hardware driver for the TCO timer built into the Intel 82801 | ||
307 | I/O Controller Hub family. The TCO (Total Cost of Ownership) | ||
308 | timer is a watchdog timer that will reboot the machine after | ||
309 | its second expiration. The expiration time can be configured | ||
310 | with the "heartbeat" parameter. | ||
311 | |||
312 | On some motherboards the driver may fail to reset the chipset's | ||
313 | NO_REBOOT flag which prevents the watchdog from rebooting the | ||
314 | machine. If this is the case you will get a kernel message like | ||
315 | "failed to reset NO_REBOOT flag, reboot disabled by hardware". | ||
316 | |||
317 | To compile this driver as a module, choose M here: the | ||
318 | module will be called i8xx_tco. | ||
319 | |||
320 | Note: This driver will be removed in the near future. Please | ||
321 | use the Intel TCO Timer/Watchdog driver. | ||
322 | |||
323 | config ITCO_WDT | 298 | config ITCO_WDT |
324 | tristate "Intel TCO Timer/Watchdog" | 299 | tristate "Intel TCO Timer/Watchdog" |
325 | depends on WATCHDOG && (X86 || IA64) && PCI | 300 | depends on (X86 || IA64) && PCI |
326 | ---help--- | 301 | ---help--- |
327 | Hardware driver for the intel TCO timer based watchdog devices. | 302 | Hardware driver for the intel TCO timer based watchdog devices. |
328 | These drivers are included in the Intel 82801 I/O Controller | 303 | These drivers are included in the Intel 82801 I/O Controller |
@@ -351,7 +326,7 @@ config ITCO_VENDOR_SUPPORT | |||
351 | 326 | ||
352 | config SC1200_WDT | 327 | config SC1200_WDT |
353 | tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" | 328 | tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" |
354 | depends on WATCHDOG && X86 | 329 | depends on X86 |
355 | help | 330 | help |
356 | This is a driver for National Semiconductor PC87307/PC97307 hardware | 331 | This is a driver for National Semiconductor PC87307/PC97307 hardware |
357 | watchdog cards as found on the SC1200. This watchdog is mainly used | 332 | watchdog cards as found on the SC1200. This watchdog is mainly used |
@@ -365,7 +340,7 @@ config SC1200_WDT | |||
365 | 340 | ||
366 | config SCx200_WDT | 341 | config SCx200_WDT |
367 | tristate "National Semiconductor SCx200 Watchdog" | 342 | tristate "National Semiconductor SCx200 Watchdog" |
368 | depends on WATCHDOG && SCx200 && PCI | 343 | depends on SCx200 && PCI |
369 | help | 344 | help |
370 | Enable the built-in watchdog timer support on the National | 345 | Enable the built-in watchdog timer support on the National |
371 | Semiconductor SCx200 processors. | 346 | Semiconductor SCx200 processors. |
@@ -374,7 +349,7 @@ config SCx200_WDT | |||
374 | 349 | ||
375 | config PC87413_WDT | 350 | config PC87413_WDT |
376 | tristate "NS PC87413 watchdog" | 351 | tristate "NS PC87413 watchdog" |
377 | depends on WATCHDOG && X86 | 352 | depends on X86 |
378 | ---help--- | 353 | ---help--- |
379 | This is the driver for the hardware watchdog on the PC87413 chipset | 354 | This is the driver for the hardware watchdog on the PC87413 chipset |
380 | This watchdog simply watches your kernel to make sure it doesn't | 355 | This watchdog simply watches your kernel to make sure it doesn't |
@@ -388,7 +363,7 @@ config PC87413_WDT | |||
388 | 363 | ||
389 | config 60XX_WDT | 364 | config 60XX_WDT |
390 | tristate "SBC-60XX Watchdog Timer" | 365 | tristate "SBC-60XX Watchdog Timer" |
391 | depends on WATCHDOG && X86 | 366 | depends on X86 |
392 | help | 367 | help |
393 | This driver can be used with the watchdog timer found on some | 368 | This driver can be used with the watchdog timer found on some |
394 | single board computers, namely the 6010 PII based computer. | 369 | single board computers, namely the 6010 PII based computer. |
@@ -402,7 +377,7 @@ config 60XX_WDT | |||
402 | 377 | ||
403 | config SBC8360_WDT | 378 | config SBC8360_WDT |
404 | tristate "SBC8360 Watchdog Timer" | 379 | tristate "SBC8360 Watchdog Timer" |
405 | depends on WATCHDOG && X86 | 380 | depends on X86 |
406 | ---help--- | 381 | ---help--- |
407 | 382 | ||
408 | This is the driver for the hardware watchdog on the SBC8360 Single | 383 | This is the driver for the hardware watchdog on the SBC8360 Single |
@@ -415,7 +390,7 @@ config SBC8360_WDT | |||
415 | 390 | ||
416 | config CPU5_WDT | 391 | config CPU5_WDT |
417 | tristate "SMA CPU5 Watchdog" | 392 | tristate "SMA CPU5 Watchdog" |
418 | depends on WATCHDOG && X86 | 393 | depends on X86 |
419 | ---help--- | 394 | ---help--- |
420 | TBD. | 395 | TBD. |
421 | To compile this driver as a module, choose M here: the | 396 | To compile this driver as a module, choose M here: the |
@@ -423,7 +398,7 @@ config CPU5_WDT | |||
423 | 398 | ||
424 | config SMSC37B787_WDT | 399 | config SMSC37B787_WDT |
425 | tristate "Winbond SMsC37B787 Watchdog Timer" | 400 | tristate "Winbond SMsC37B787 Watchdog Timer" |
426 | depends on WATCHDOG && X86 | 401 | depends on X86 |
427 | ---help--- | 402 | ---help--- |
428 | This is the driver for the hardware watchdog component on the | 403 | This is the driver for the hardware watchdog component on the |
429 | Winbond SMsC37B787 chipset as used on the NetRunner Mainboard | 404 | Winbond SMsC37B787 chipset as used on the NetRunner Mainboard |
@@ -443,7 +418,7 @@ config SMSC37B787_WDT | |||
443 | 418 | ||
444 | config W83627HF_WDT | 419 | config W83627HF_WDT |
445 | tristate "W83627HF Watchdog Timer" | 420 | tristate "W83627HF Watchdog Timer" |
446 | depends on WATCHDOG && X86 | 421 | depends on X86 |
447 | ---help--- | 422 | ---help--- |
448 | This is the driver for the hardware watchdog on the W83627HF chipset | 423 | This is the driver for the hardware watchdog on the W83627HF chipset |
449 | as used in Advantech PC-9578 and Tyan S2721-533 motherboards | 424 | as used in Advantech PC-9578 and Tyan S2721-533 motherboards |
@@ -458,7 +433,7 @@ config W83627HF_WDT | |||
458 | 433 | ||
459 | config W83697HF_WDT | 434 | config W83697HF_WDT |
460 | tristate "W83697HF/W83697HG Watchdog Timer" | 435 | tristate "W83697HF/W83697HG Watchdog Timer" |
461 | depends on WATCHDOG && X86 | 436 | depends on X86 |
462 | ---help--- | 437 | ---help--- |
463 | This is the driver for the hardware watchdog on the W83697HF/HG | 438 | This is the driver for the hardware watchdog on the W83697HF/HG |
464 | chipset as used in Dedibox/VIA motherboards (and likely others). | 439 | chipset as used in Dedibox/VIA motherboards (and likely others). |
@@ -473,7 +448,7 @@ config W83697HF_WDT | |||
473 | 448 | ||
474 | config W83877F_WDT | 449 | config W83877F_WDT |
475 | tristate "W83877F (EMACS) Watchdog Timer" | 450 | tristate "W83877F (EMACS) Watchdog Timer" |
476 | depends on WATCHDOG && X86 | 451 | depends on X86 |
477 | ---help--- | 452 | ---help--- |
478 | This is the driver for the hardware watchdog on the W83877F chipset | 453 | This is the driver for the hardware watchdog on the W83877F chipset |
479 | as used in EMACS PC-104 motherboards (and likely others). This | 454 | as used in EMACS PC-104 motherboards (and likely others). This |
@@ -488,7 +463,7 @@ config W83877F_WDT | |||
488 | 463 | ||
489 | config W83977F_WDT | 464 | config W83977F_WDT |
490 | tristate "W83977F (PCM-5335) Watchdog Timer" | 465 | tristate "W83977F (PCM-5335) Watchdog Timer" |
491 | depends on WATCHDOG && X86 | 466 | depends on X86 |
492 | ---help--- | 467 | ---help--- |
493 | This is the driver for the hardware watchdog on the W83977F I/O chip | 468 | This is the driver for the hardware watchdog on the W83977F I/O chip |
494 | as used in AAEON's PCM-5335 SBC (and likely others). This | 469 | as used in AAEON's PCM-5335 SBC (and likely others). This |
@@ -501,7 +476,7 @@ config W83977F_WDT | |||
501 | 476 | ||
502 | config MACHZ_WDT | 477 | config MACHZ_WDT |
503 | tristate "ZF MachZ Watchdog" | 478 | tristate "ZF MachZ Watchdog" |
504 | depends on WATCHDOG && X86 | 479 | depends on X86 |
505 | ---help--- | 480 | ---help--- |
506 | If you are using a ZF Micro MachZ processor, say Y here, otherwise | 481 | If you are using a ZF Micro MachZ processor, say Y here, otherwise |
507 | N. This is the driver for the watchdog timer built-in on that | 482 | N. This is the driver for the watchdog timer built-in on that |
@@ -514,7 +489,7 @@ config MACHZ_WDT | |||
514 | 489 | ||
515 | config SBC_EPX_C3_WATCHDOG | 490 | config SBC_EPX_C3_WATCHDOG |
516 | tristate "Winsystems SBC EPX-C3 watchdog" | 491 | tristate "Winsystems SBC EPX-C3 watchdog" |
517 | depends on WATCHDOG && X86 | 492 | depends on X86 |
518 | ---help--- | 493 | ---help--- |
519 | This is the driver for the built-in watchdog timer on the EPX-C3 | 494 | This is the driver for the built-in watchdog timer on the EPX-C3 |
520 | Single-board computer made by Winsystems, Inc. | 495 | Single-board computer made by Winsystems, Inc. |
@@ -537,19 +512,19 @@ config SBC_EPX_C3_WATCHDOG | |||
537 | 512 | ||
538 | config 8xx_WDT | 513 | config 8xx_WDT |
539 | tristate "MPC8xx Watchdog Timer" | 514 | tristate "MPC8xx Watchdog Timer" |
540 | depends on WATCHDOG && 8xx | 515 | depends on 8xx |
541 | 516 | ||
542 | config 83xx_WDT | 517 | config 83xx_WDT |
543 | tristate "MPC83xx Watchdog Timer" | 518 | tristate "MPC83xx Watchdog Timer" |
544 | depends on WATCHDOG && PPC_83xx | 519 | depends on PPC_83xx |
545 | 520 | ||
546 | config MV64X60_WDT | 521 | config MV64X60_WDT |
547 | tristate "MV64X60 (Marvell Discovery) Watchdog Timer" | 522 | tristate "MV64X60 (Marvell Discovery) Watchdog Timer" |
548 | depends on WATCHDOG && MV64X60 | 523 | depends on MV64X60 |
549 | 524 | ||
550 | config BOOKE_WDT | 525 | config BOOKE_WDT |
551 | bool "PowerPC Book-E Watchdog Timer" | 526 | bool "PowerPC Book-E Watchdog Timer" |
552 | depends on WATCHDOG && (BOOKE || 4xx) | 527 | depends on BOOKE || 4xx |
553 | ---help--- | 528 | ---help--- |
554 | Please see Documentation/watchdog/watchdog-api.txt for | 529 | Please see Documentation/watchdog/watchdog-api.txt for |
555 | more information. | 530 | more information. |
@@ -558,7 +533,7 @@ config BOOKE_WDT | |||
558 | 533 | ||
559 | config WATCHDOG_RTAS | 534 | config WATCHDOG_RTAS |
560 | tristate "RTAS watchdog" | 535 | tristate "RTAS watchdog" |
561 | depends on WATCHDOG && PPC_RTAS | 536 | depends on PPC_RTAS |
562 | help | 537 | help |
563 | This driver adds watchdog support for the RTAS watchdog. | 538 | This driver adds watchdog support for the RTAS watchdog. |
564 | 539 | ||
@@ -569,16 +544,23 @@ config WATCHDOG_RTAS | |||
569 | 544 | ||
570 | config INDYDOG | 545 | config INDYDOG |
571 | tristate "Indy/I2 Hardware Watchdog" | 546 | tristate "Indy/I2 Hardware Watchdog" |
572 | depends on WATCHDOG && SGI_IP22 | 547 | depends on SGI_IP22 |
573 | help | 548 | help |
574 | Hardware driver for the Indy's/I2's watchdog. This is a | 549 | Hardware driver for the Indy's/I2's watchdog. This is a |
575 | watchdog timer that will reboot the machine after a 60 second | 550 | watchdog timer that will reboot the machine after a 60 second |
576 | timer expired and no process has written to /dev/watchdog during | 551 | timer expired and no process has written to /dev/watchdog during |
577 | that time. | 552 | that time. |
578 | 553 | ||
554 | config WDT_MTX1 | ||
555 | tristate "MTX-1 Hardware Watchdog" | ||
556 | depends on MIPS_MTX1 | ||
557 | help | ||
558 | Hardware driver for the MTX-1 boards. This is a watchdog timer that | ||
559 | will reboot the machine after a 100 seconds timer expired. | ||
560 | |||
579 | config WDT_RM9K_GPI | 561 | config WDT_RM9K_GPI |
580 | tristate "RM9000/GPI hardware watchdog" | 562 | tristate "RM9000/GPI hardware watchdog" |
581 | depends on WATCHDOG && CPU_RM9000 | 563 | depends on CPU_RM9000 |
582 | help | 564 | help |
583 | Watchdog implementation using the GPI hardware found on | 565 | Watchdog implementation using the GPI hardware found on |
584 | PMC-Sierra RM9xxx CPUs. | 566 | PMC-Sierra RM9xxx CPUs. |
@@ -590,7 +572,7 @@ config WDT_RM9K_GPI | |||
590 | 572 | ||
591 | config ZVM_WATCHDOG | 573 | config ZVM_WATCHDOG |
592 | tristate "z/VM Watchdog Timer" | 574 | tristate "z/VM Watchdog Timer" |
593 | depends on WATCHDOG && S390 | 575 | depends on S390 |
594 | help | 576 | help |
595 | IBM s/390 and zSeries machines running under z/VM 5.1 or later | 577 | IBM s/390 and zSeries machines running under z/VM 5.1 or later |
596 | provide a virtual watchdog timer to their guest that cause a | 578 | provide a virtual watchdog timer to their guest that cause a |
@@ -604,7 +586,7 @@ config ZVM_WATCHDOG | |||
604 | 586 | ||
605 | config SH_WDT | 587 | config SH_WDT |
606 | tristate "SuperH Watchdog" | 588 | tristate "SuperH Watchdog" |
607 | depends on WATCHDOG && SUPERH | 589 | depends on SUPERH |
608 | help | 590 | help |
609 | This driver adds watchdog support for the integrated watchdog in the | 591 | This driver adds watchdog support for the integrated watchdog in the |
610 | SuperH processors. If you have one of these processors and wish | 592 | SuperH processors. If you have one of these processors and wish |
@@ -631,7 +613,7 @@ config SH_WDT_MMAP | |||
631 | 613 | ||
632 | config WATCHDOG_CP1XXX | 614 | config WATCHDOG_CP1XXX |
633 | tristate "CP1XXX Hardware Watchdog support" | 615 | tristate "CP1XXX Hardware Watchdog support" |
634 | depends on WATCHDOG && SPARC64 && PCI | 616 | depends on SPARC64 && PCI |
635 | ---help--- | 617 | ---help--- |
636 | This is the driver for the hardware watchdog timers present on | 618 | This is the driver for the hardware watchdog timers present on |
637 | Sun Microsystems CompactPCI models CP1400 and CP1500. | 619 | Sun Microsystems CompactPCI models CP1400 and CP1500. |
@@ -645,7 +627,7 @@ config WATCHDOG_CP1XXX | |||
645 | 627 | ||
646 | config WATCHDOG_RIO | 628 | config WATCHDOG_RIO |
647 | tristate "RIO Hardware Watchdog support" | 629 | tristate "RIO Hardware Watchdog support" |
648 | depends on WATCHDOG && SPARC64 && PCI | 630 | depends on SPARC64 && PCI |
649 | help | 631 | help |
650 | Say Y here to support the hardware watchdog capability on Sun RIO | 632 | Say Y here to support the hardware watchdog capability on Sun RIO |
651 | machines. The watchdog timeout period is normally one minute but | 633 | machines. The watchdog timeout period is normally one minute but |
@@ -656,11 +638,11 @@ config WATCHDOG_RIO | |||
656 | # | 638 | # |
657 | 639 | ||
658 | comment "ISA-based Watchdog Cards" | 640 | comment "ISA-based Watchdog Cards" |
659 | depends on WATCHDOG && ISA | 641 | depends on ISA |
660 | 642 | ||
661 | config PCWATCHDOG | 643 | config PCWATCHDOG |
662 | tristate "Berkshire Products ISA-PC Watchdog" | 644 | tristate "Berkshire Products ISA-PC Watchdog" |
663 | depends on WATCHDOG && ISA | 645 | depends on ISA |
664 | ---help--- | 646 | ---help--- |
665 | This is the driver for the Berkshire Products ISA-PC Watchdog card. | 647 | This is the driver for the Berkshire Products ISA-PC Watchdog card. |
666 | This card simply watches your kernel to make sure it doesn't freeze, | 648 | This card simply watches your kernel to make sure it doesn't freeze, |
@@ -676,7 +658,7 @@ config PCWATCHDOG | |||
676 | 658 | ||
677 | config MIXCOMWD | 659 | config MIXCOMWD |
678 | tristate "Mixcom Watchdog" | 660 | tristate "Mixcom Watchdog" |
679 | depends on WATCHDOG && ISA | 661 | depends on ISA |
680 | ---help--- | 662 | ---help--- |
681 | This is a driver for the Mixcom hardware watchdog cards. This | 663 | This is a driver for the Mixcom hardware watchdog cards. This |
682 | watchdog simply watches your kernel to make sure it doesn't freeze, | 664 | watchdog simply watches your kernel to make sure it doesn't freeze, |
@@ -690,7 +672,7 @@ config MIXCOMWD | |||
690 | 672 | ||
691 | config WDT | 673 | config WDT |
692 | tristate "WDT Watchdog timer" | 674 | tristate "WDT Watchdog timer" |
693 | depends on WATCHDOG && ISA | 675 | depends on ISA |
694 | ---help--- | 676 | ---help--- |
695 | If you have a WDT500P or WDT501P watchdog board, say Y here, | 677 | If you have a WDT500P or WDT501P watchdog board, say Y here, |
696 | otherwise N. It is not possible to probe for this board, which means | 678 | otherwise N. It is not possible to probe for this board, which means |
@@ -720,11 +702,11 @@ config WDT_501 | |||
720 | # | 702 | # |
721 | 703 | ||
722 | comment "PCI-based Watchdog Cards" | 704 | comment "PCI-based Watchdog Cards" |
723 | depends on WATCHDOG && PCI | 705 | depends on PCI |
724 | 706 | ||
725 | config PCIPCWATCHDOG | 707 | config PCIPCWATCHDOG |
726 | tristate "Berkshire Products PCI-PC Watchdog" | 708 | tristate "Berkshire Products PCI-PC Watchdog" |
727 | depends on WATCHDOG && PCI | 709 | depends on PCI |
728 | ---help--- | 710 | ---help--- |
729 | This is the driver for the Berkshire Products PCI-PC Watchdog card. | 711 | This is the driver for the Berkshire Products PCI-PC Watchdog card. |
730 | This card simply watches your kernel to make sure it doesn't freeze, | 712 | This card simply watches your kernel to make sure it doesn't freeze, |
@@ -739,7 +721,7 @@ config PCIPCWATCHDOG | |||
739 | 721 | ||
740 | config WDTPCI | 722 | config WDTPCI |
741 | tristate "PCI-WDT500/501 Watchdog timer" | 723 | tristate "PCI-WDT500/501 Watchdog timer" |
742 | depends on WATCHDOG && PCI | 724 | depends on PCI |
743 | ---help--- | 725 | ---help--- |
744 | If you have a PCI-WDT500/501 watchdog board, say Y here, otherwise N. | 726 | If you have a PCI-WDT500/501 watchdog board, say Y here, otherwise N. |
745 | 727 | ||
@@ -766,11 +748,11 @@ config WDT_501_PCI | |||
766 | # | 748 | # |
767 | 749 | ||
768 | comment "USB-based Watchdog Cards" | 750 | comment "USB-based Watchdog Cards" |
769 | depends on WATCHDOG && USB | 751 | depends on USB |
770 | 752 | ||
771 | config USBPCWATCHDOG | 753 | config USBPCWATCHDOG |
772 | tristate "Berkshire Products USB-PC Watchdog" | 754 | tristate "Berkshire Products USB-PC Watchdog" |
773 | depends on WATCHDOG && USB | 755 | depends on USB |
774 | ---help--- | 756 | ---help--- |
775 | This is the driver for the Berkshire Products USB-PC Watchdog card. | 757 | This is the driver for the Berkshire Products USB-PC Watchdog card. |
776 | This card simply watches your kernel to make sure it doesn't freeze, | 758 | This card simply watches your kernel to make sure it doesn't freeze, |
@@ -783,4 +765,4 @@ config USBPCWATCHDOG | |||
783 | 765 | ||
784 | Most people will say N. | 766 | Most people will say N. |
785 | 767 | ||
786 | endmenu | 768 | endif # WATCHDOG |
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index 2cd8ff8d10ac..8bfc00cc7c2b 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile | |||
@@ -46,7 +46,6 @@ obj-$(CONFIG_IB700_WDT) += ib700wdt.o | |||
46 | obj-$(CONFIG_IBMASR) += ibmasr.o | 46 | obj-$(CONFIG_IBMASR) += ibmasr.o |
47 | obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o | 47 | obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o |
48 | obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o | 48 | obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o |
49 | obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o | ||
50 | obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o iTCO_vendor_support.o | 49 | obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o iTCO_vendor_support.o |
51 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o | 50 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o |
52 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o | 51 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o |
@@ -73,6 +72,7 @@ obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o | |||
73 | 72 | ||
74 | # MIPS Architecture | 73 | # MIPS Architecture |
75 | obj-$(CONFIG_INDYDOG) += indydog.o | 74 | obj-$(CONFIG_INDYDOG) += indydog.o |
75 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o | ||
76 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o | 76 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o |
77 | 77 | ||
78 | # S390 Architecture | 78 | # S390 Architecture |
diff --git a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c index bcd7e36ca0aa..d0d45a8b09f0 100644 --- a/drivers/char/watchdog/cpu5wdt.c +++ b/drivers/char/watchdog/cpu5wdt.c | |||
@@ -220,17 +220,17 @@ static int __devinit cpu5wdt_init(void) | |||
220 | if ( verbose ) | 220 | if ( verbose ) |
221 | printk(KERN_DEBUG PFX "port=0x%x, verbose=%i\n", port, verbose); | 221 | printk(KERN_DEBUG PFX "port=0x%x, verbose=%i\n", port, verbose); |
222 | 222 | ||
223 | if ( (err = misc_register(&cpu5wdt_misc)) < 0 ) { | ||
224 | printk(KERN_ERR PFX "misc_register failed\n"); | ||
225 | goto no_misc; | ||
226 | } | ||
227 | |||
228 | if ( !request_region(port, CPU5WDT_EXTENT, PFX) ) { | 223 | if ( !request_region(port, CPU5WDT_EXTENT, PFX) ) { |
229 | printk(KERN_ERR PFX "request_region failed\n"); | 224 | printk(KERN_ERR PFX "request_region failed\n"); |
230 | err = -EBUSY; | 225 | err = -EBUSY; |
231 | goto no_port; | 226 | goto no_port; |
232 | } | 227 | } |
233 | 228 | ||
229 | if ( (err = misc_register(&cpu5wdt_misc)) < 0 ) { | ||
230 | printk(KERN_ERR PFX "misc_register failed\n"); | ||
231 | goto no_misc; | ||
232 | } | ||
233 | |||
234 | /* watchdog reboot? */ | 234 | /* watchdog reboot? */ |
235 | val = inb(port + CPU5WDT_STATUS_REG); | 235 | val = inb(port + CPU5WDT_STATUS_REG); |
236 | val = (val >> 2) & 1; | 236 | val = (val >> 2) & 1; |
@@ -250,9 +250,9 @@ static int __devinit cpu5wdt_init(void) | |||
250 | 250 | ||
251 | return 0; | 251 | return 0; |
252 | 252 | ||
253 | no_port: | ||
254 | misc_deregister(&cpu5wdt_misc); | ||
255 | no_misc: | 253 | no_misc: |
254 | release_region(port, CPU5WDT_EXTENT); | ||
255 | no_port: | ||
256 | return err; | 256 | return err; |
257 | } | 257 | } |
258 | 258 | ||
diff --git a/drivers/char/watchdog/eurotechwdt.c b/drivers/char/watchdog/eurotechwdt.c index f70387f01b2b..b070324e27a6 100644 --- a/drivers/char/watchdog/eurotechwdt.c +++ b/drivers/char/watchdog/eurotechwdt.c | |||
@@ -413,17 +413,10 @@ static int __init eurwdt_init(void) | |||
413 | { | 413 | { |
414 | int ret; | 414 | int ret; |
415 | 415 | ||
416 | ret = misc_register(&eurwdt_miscdev); | ||
417 | if (ret) { | ||
418 | printk(KERN_ERR "eurwdt: can't misc_register on minor=%d\n", | ||
419 | WATCHDOG_MINOR); | ||
420 | goto out; | ||
421 | } | ||
422 | |||
423 | ret = request_irq(irq, eurwdt_interrupt, IRQF_DISABLED, "eurwdt", NULL); | 416 | ret = request_irq(irq, eurwdt_interrupt, IRQF_DISABLED, "eurwdt", NULL); |
424 | if(ret) { | 417 | if(ret) { |
425 | printk(KERN_ERR "eurwdt: IRQ %d is not free.\n", irq); | 418 | printk(KERN_ERR "eurwdt: IRQ %d is not free.\n", irq); |
426 | goto outmisc; | 419 | goto out; |
427 | } | 420 | } |
428 | 421 | ||
429 | if (!request_region(io, 2, "eurwdt")) { | 422 | if (!request_region(io, 2, "eurwdt")) { |
@@ -438,6 +431,13 @@ static int __init eurwdt_init(void) | |||
438 | goto outreg; | 431 | goto outreg; |
439 | } | 432 | } |
440 | 433 | ||
434 | ret = misc_register(&eurwdt_miscdev); | ||
435 | if (ret) { | ||
436 | printk(KERN_ERR "eurwdt: can't misc_register on minor=%d\n", | ||
437 | WATCHDOG_MINOR); | ||
438 | goto outreboot; | ||
439 | } | ||
440 | |||
441 | eurwdt_unlock_chip(); | 441 | eurwdt_unlock_chip(); |
442 | 442 | ||
443 | ret = 0; | 443 | ret = 0; |
@@ -448,14 +448,14 @@ static int __init eurwdt_init(void) | |||
448 | out: | 448 | out: |
449 | return ret; | 449 | return ret; |
450 | 450 | ||
451 | outreboot: | ||
452 | unregister_reboot_notifier(&eurwdt_notifier); | ||
453 | |||
451 | outreg: | 454 | outreg: |
452 | release_region(io, 2); | 455 | release_region(io, 2); |
453 | 456 | ||
454 | outirq: | 457 | outirq: |
455 | free_irq(irq, NULL); | 458 | free_irq(irq, NULL); |
456 | |||
457 | outmisc: | ||
458 | misc_deregister(&eurwdt_miscdev); | ||
459 | goto out; | 459 | goto out; |
460 | } | 460 | } |
461 | 461 | ||
diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c deleted file mode 100644 index a62ef48a15ae..000000000000 --- a/drivers/char/watchdog/i8xx_tco.c +++ /dev/null | |||
@@ -1,571 +0,0 @@ | |||
1 | /* | ||
2 | * i8xx_tco: TCO timer driver for i8xx chipsets | ||
3 | * | ||
4 | * (c) Copyright 2000 kernel concepts <nils@kernelconcepts.de>, All Rights Reserved. | ||
5 | * http://www.kernelconcepts.de | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * Neither kernel concepts nor Nils Faerber admit liability nor provide | ||
13 | * warranty for any of this software. This material is provided | ||
14 | * "AS-IS" and at no charge. | ||
15 | * | ||
16 | * (c) Copyright 2000 kernel concepts <nils@kernelconcepts.de> | ||
17 | * developed for | ||
18 | * Jentro AG, Haar/Munich (Germany) | ||
19 | * | ||
20 | * TCO timer driver for i8xx chipsets | ||
21 | * based on softdog.c by Alan Cox <alan@redhat.com> | ||
22 | * | ||
23 | * The TCO timer is implemented in the following I/O controller hubs: | ||
24 | * (See the intel documentation on http://developer.intel.com.) | ||
25 | * 82801AA (ICH) : document number 290655-003, 290677-014, | ||
26 | * 82801AB (ICHO) : document number 290655-003, 290677-014, | ||
27 | * 82801BA (ICH2) : document number 290687-002, 298242-027, | ||
28 | * 82801BAM (ICH2-M) : document number 290687-002, 298242-027, | ||
29 | * 82801CA (ICH3-S) : document number 290733-003, 290739-013, | ||
30 | * 82801CAM (ICH3-M) : document number 290716-001, 290718-007, | ||
31 | * 82801DB (ICH4) : document number 290744-001, 290745-020, | ||
32 | * 82801DBM (ICH4-M) : document number 252337-001, 252663-005, | ||
33 | * 82801E (C-ICH) : document number 273599-001, 273645-002, | ||
34 | * 82801EB (ICH5) : document number 252516-001, 252517-003, | ||
35 | * 82801ER (ICH5R) : document number 252516-001, 252517-003, | ||
36 | * | ||
37 | * 20000710 Nils Faerber | ||
38 | * Initial Version 0.01 | ||
39 | * 20000728 Nils Faerber | ||
40 | * 0.02 Fix for SMI_EN->TCO_EN bit, some cleanups | ||
41 | * 20011214 Matt Domsch <Matt_Domsch@dell.com> | ||
42 | * 0.03 Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT | ||
43 | * Didn't add timeout option as i810_margin already exists. | ||
44 | * 20020224 Joel Becker, Wim Van Sebroeck | ||
45 | * 0.04 Support for 82801CA(M) chipset, timer margin needs to be > 3, | ||
46 | * add support for WDIOC_SETTIMEOUT and WDIOC_GETTIMEOUT. | ||
47 | * 20020412 Rob Radez <rob@osinvestor.com>, Wim Van Sebroeck | ||
48 | * 0.05 Fix possible timer_alive race, add expect close support, | ||
49 | * clean up ioctls (WDIOC_GETSTATUS, WDIOC_GETBOOTSTATUS and | ||
50 | * WDIOC_SETOPTIONS), made i810tco_getdevice __init, | ||
51 | * removed boot_status, removed tco_timer_read, | ||
52 | * added support for 82801DB and 82801E chipset, | ||
53 | * added support for 82801EB and 8280ER chipset, | ||
54 | * general cleanup. | ||
55 | * 20030921 Wim Van Sebroeck <wim@iguana.be> | ||
56 | * 0.06 change i810_margin to heartbeat, use module_param, | ||
57 | * added notify system support, renamed module to i8xx_tco. | ||
58 | * 20050128 Wim Van Sebroeck <wim@iguana.be> | ||
59 | * 0.07 Added support for the ICH4-M, ICH6, ICH6R, ICH6-M, ICH6W and ICH6RW | ||
60 | * chipsets. Also added support for the "undocumented" ICH7 chipset. | ||
61 | * 20050807 Wim Van Sebroeck <wim@iguana.be> | ||
62 | * 0.08 Make sure that the watchdog is only "armed" when started. | ||
63 | * (Kernel Bug 4251) | ||
64 | * 20060416 Wim Van Sebroeck <wim@iguana.be> | ||
65 | * 0.09 Remove support for the ICH6, ICH6R, ICH6-M, ICH6W and ICH6RW and | ||
66 | * ICH7 chipsets. (See Kernel Bug 6031 - other code will support these | ||
67 | * chipsets) | ||
68 | */ | ||
69 | |||
70 | /* | ||
71 | * Includes, defines, variables, module parameters, ... | ||
72 | */ | ||
73 | |||
74 | #include <linux/module.h> | ||
75 | #include <linux/moduleparam.h> | ||
76 | #include <linux/types.h> | ||
77 | #include <linux/miscdevice.h> | ||
78 | #include <linux/watchdog.h> | ||
79 | #include <linux/notifier.h> | ||
80 | #include <linux/reboot.h> | ||
81 | #include <linux/init.h> | ||
82 | #include <linux/fs.h> | ||
83 | #include <linux/pci.h> | ||
84 | #include <linux/ioport.h> | ||
85 | |||
86 | #include <asm/uaccess.h> | ||
87 | #include <asm/io.h> | ||
88 | |||
89 | #include "i8xx_tco.h" | ||
90 | |||
91 | /* Module and version information */ | ||
92 | #define TCO_VERSION "0.09" | ||
93 | #define TCO_MODULE_NAME "i8xx TCO timer" | ||
94 | #define TCO_DRIVER_NAME TCO_MODULE_NAME ", v" TCO_VERSION | ||
95 | #define PFX TCO_MODULE_NAME ": " | ||
96 | |||
97 | /* internal variables */ | ||
98 | static unsigned int ACPIBASE; | ||
99 | static spinlock_t tco_lock; /* Guards the hardware */ | ||
100 | static unsigned long timer_alive; | ||
101 | static char tco_expect_close; | ||
102 | static struct pci_dev *i8xx_tco_pci; | ||
103 | |||
104 | /* module parameters */ | ||
105 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat (2<heartbeat<39) */ | ||
106 | static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ | ||
107 | module_param(heartbeat, int, 0); | ||
108 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); | ||
109 | |||
110 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
111 | module_param(nowayout, int, 0); | ||
112 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
113 | |||
114 | /* | ||
115 | * Some TCO specific functions | ||
116 | */ | ||
117 | |||
118 | static inline unsigned char seconds_to_ticks(int seconds) | ||
119 | { | ||
120 | /* the internal timer is stored as ticks which decrement | ||
121 | * every 0.6 seconds */ | ||
122 | return (seconds * 10) / 6; | ||
123 | } | ||
124 | |||
125 | static int tco_timer_start (void) | ||
126 | { | ||
127 | unsigned char val; | ||
128 | |||
129 | spin_lock(&tco_lock); | ||
130 | |||
131 | /* disable chipset's NO_REBOOT bit */ | ||
132 | pci_read_config_byte (i8xx_tco_pci, 0xd4, &val); | ||
133 | val &= 0xfd; | ||
134 | pci_write_config_byte (i8xx_tco_pci, 0xd4, val); | ||
135 | |||
136 | /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled to count */ | ||
137 | val = inb (TCO1_CNT + 1); | ||
138 | val &= 0xf7; | ||
139 | outb (val, TCO1_CNT + 1); | ||
140 | val = inb (TCO1_CNT + 1); | ||
141 | |||
142 | spin_unlock(&tco_lock); | ||
143 | |||
144 | if (val & 0x08) | ||
145 | return -1; | ||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | static int tco_timer_stop (void) | ||
150 | { | ||
151 | unsigned char val, val1; | ||
152 | |||
153 | spin_lock(&tco_lock); | ||
154 | /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */ | ||
155 | val = inb (TCO1_CNT + 1); | ||
156 | val |= 0x08; | ||
157 | outb (val, TCO1_CNT + 1); | ||
158 | val = inb (TCO1_CNT + 1); | ||
159 | |||
160 | /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ | ||
161 | pci_read_config_byte (i8xx_tco_pci, 0xd4, &val1); | ||
162 | val1 |= 0x02; | ||
163 | pci_write_config_byte (i8xx_tco_pci, 0xd4, val1); | ||
164 | |||
165 | spin_unlock(&tco_lock); | ||
166 | |||
167 | if ((val & 0x08) == 0) | ||
168 | return -1; | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | static int tco_timer_keepalive (void) | ||
173 | { | ||
174 | spin_lock(&tco_lock); | ||
175 | /* Reload the timer by writing to the TCO Timer Reload register */ | ||
176 | outb (0x01, TCO1_RLD); | ||
177 | spin_unlock(&tco_lock); | ||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static int tco_timer_set_heartbeat (int t) | ||
182 | { | ||
183 | unsigned char val; | ||
184 | unsigned char tmrval; | ||
185 | |||
186 | tmrval = seconds_to_ticks(t); | ||
187 | /* from the specs: */ | ||
188 | /* "Values of 0h-3h are ignored and should not be attempted" */ | ||
189 | if (tmrval > 0x3f || tmrval < 0x04) | ||
190 | return -EINVAL; | ||
191 | |||
192 | /* Write new heartbeat to watchdog */ | ||
193 | spin_lock(&tco_lock); | ||
194 | val = inb (TCO1_TMR); | ||
195 | val &= 0xc0; | ||
196 | val |= tmrval; | ||
197 | outb (val, TCO1_TMR); | ||
198 | val = inb (TCO1_TMR); | ||
199 | spin_unlock(&tco_lock); | ||
200 | |||
201 | if ((val & 0x3f) != tmrval) | ||
202 | return -EINVAL; | ||
203 | |||
204 | heartbeat = t; | ||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | static int tco_timer_get_timeleft (int *time_left) | ||
209 | { | ||
210 | unsigned char val; | ||
211 | |||
212 | spin_lock(&tco_lock); | ||
213 | |||
214 | /* read the TCO Timer */ | ||
215 | val = inb (TCO1_RLD); | ||
216 | val &= 0x3f; | ||
217 | |||
218 | spin_unlock(&tco_lock); | ||
219 | |||
220 | *time_left = (int)((val * 6) / 10); | ||
221 | |||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | /* | ||
226 | * /dev/watchdog handling | ||
227 | */ | ||
228 | |||
229 | static int i8xx_tco_open (struct inode *inode, struct file *file) | ||
230 | { | ||
231 | /* /dev/watchdog can only be opened once */ | ||
232 | if (test_and_set_bit(0, &timer_alive)) | ||
233 | return -EBUSY; | ||
234 | |||
235 | /* | ||
236 | * Reload and activate timer | ||
237 | */ | ||
238 | tco_timer_keepalive (); | ||
239 | tco_timer_start (); | ||
240 | return nonseekable_open(inode, file); | ||
241 | } | ||
242 | |||
243 | static int i8xx_tco_release (struct inode *inode, struct file *file) | ||
244 | { | ||
245 | /* | ||
246 | * Shut off the timer. | ||
247 | */ | ||
248 | if (tco_expect_close == 42) { | ||
249 | tco_timer_stop (); | ||
250 | } else { | ||
251 | printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); | ||
252 | tco_timer_keepalive (); | ||
253 | } | ||
254 | clear_bit(0, &timer_alive); | ||
255 | tco_expect_close = 0; | ||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static ssize_t i8xx_tco_write (struct file *file, const char __user *data, | ||
260 | size_t len, loff_t * ppos) | ||
261 | { | ||
262 | /* See if we got the magic character 'V' and reload the timer */ | ||
263 | if (len) { | ||
264 | if (!nowayout) { | ||
265 | size_t i; | ||
266 | |||
267 | /* note: just in case someone wrote the magic character | ||
268 | * five months ago... */ | ||
269 | tco_expect_close = 0; | ||
270 | |||
271 | /* scan to see whether or not we got the magic character */ | ||
272 | for (i = 0; i != len; i++) { | ||
273 | char c; | ||
274 | if(get_user(c, data+i)) | ||
275 | return -EFAULT; | ||
276 | if (c == 'V') | ||
277 | tco_expect_close = 42; | ||
278 | } | ||
279 | } | ||
280 | |||
281 | /* someone wrote to us, we should reload the timer */ | ||
282 | tco_timer_keepalive (); | ||
283 | } | ||
284 | return len; | ||
285 | } | ||
286 | |||
287 | static int i8xx_tco_ioctl (struct inode *inode, struct file *file, | ||
288 | unsigned int cmd, unsigned long arg) | ||
289 | { | ||
290 | int new_options, retval = -EINVAL; | ||
291 | int new_heartbeat; | ||
292 | int time_left; | ||
293 | void __user *argp = (void __user *)arg; | ||
294 | int __user *p = argp; | ||
295 | static struct watchdog_info ident = { | ||
296 | .options = WDIOF_SETTIMEOUT | | ||
297 | WDIOF_KEEPALIVEPING | | ||
298 | WDIOF_MAGICCLOSE, | ||
299 | .firmware_version = 0, | ||
300 | .identity = TCO_MODULE_NAME, | ||
301 | }; | ||
302 | |||
303 | switch (cmd) { | ||
304 | case WDIOC_GETSUPPORT: | ||
305 | return copy_to_user(argp, &ident, | ||
306 | sizeof (ident)) ? -EFAULT : 0; | ||
307 | |||
308 | case WDIOC_GETSTATUS: | ||
309 | case WDIOC_GETBOOTSTATUS: | ||
310 | return put_user (0, p); | ||
311 | |||
312 | case WDIOC_KEEPALIVE: | ||
313 | tco_timer_keepalive (); | ||
314 | return 0; | ||
315 | |||
316 | case WDIOC_SETOPTIONS: | ||
317 | { | ||
318 | if (get_user (new_options, p)) | ||
319 | return -EFAULT; | ||
320 | |||
321 | if (new_options & WDIOS_DISABLECARD) { | ||
322 | tco_timer_stop (); | ||
323 | retval = 0; | ||
324 | } | ||
325 | |||
326 | if (new_options & WDIOS_ENABLECARD) { | ||
327 | tco_timer_keepalive (); | ||
328 | tco_timer_start (); | ||
329 | retval = 0; | ||
330 | } | ||
331 | |||
332 | return retval; | ||
333 | } | ||
334 | |||
335 | case WDIOC_SETTIMEOUT: | ||
336 | { | ||
337 | if (get_user(new_heartbeat, p)) | ||
338 | return -EFAULT; | ||
339 | |||
340 | if (tco_timer_set_heartbeat(new_heartbeat)) | ||
341 | return -EINVAL; | ||
342 | |||
343 | tco_timer_keepalive (); | ||
344 | /* Fall */ | ||
345 | } | ||
346 | |||
347 | case WDIOC_GETTIMEOUT: | ||
348 | return put_user(heartbeat, p); | ||
349 | |||
350 | case WDIOC_GETTIMELEFT: | ||
351 | { | ||
352 | if (tco_timer_get_timeleft(&time_left)) | ||
353 | return -EINVAL; | ||
354 | |||
355 | return put_user(time_left, p); | ||
356 | } | ||
357 | |||
358 | default: | ||
359 | return -ENOTTY; | ||
360 | } | ||
361 | } | ||
362 | |||
363 | /* | ||
364 | * Notify system | ||
365 | */ | ||
366 | |||
367 | static int i8xx_tco_notify_sys (struct notifier_block *this, unsigned long code, void *unused) | ||
368 | { | ||
369 | if (code==SYS_DOWN || code==SYS_HALT) { | ||
370 | /* Turn the WDT off */ | ||
371 | tco_timer_stop (); | ||
372 | } | ||
373 | |||
374 | return NOTIFY_DONE; | ||
375 | } | ||
376 | |||
377 | /* | ||
378 | * Kernel Interfaces | ||
379 | */ | ||
380 | |||
381 | static const struct file_operations i8xx_tco_fops = { | ||
382 | .owner = THIS_MODULE, | ||
383 | .llseek = no_llseek, | ||
384 | .write = i8xx_tco_write, | ||
385 | .ioctl = i8xx_tco_ioctl, | ||
386 | .open = i8xx_tco_open, | ||
387 | .release = i8xx_tco_release, | ||
388 | }; | ||
389 | |||
390 | static struct miscdevice i8xx_tco_miscdev = { | ||
391 | .minor = WATCHDOG_MINOR, | ||
392 | .name = "watchdog", | ||
393 | .fops = &i8xx_tco_fops, | ||
394 | }; | ||
395 | |||
396 | static struct notifier_block i8xx_tco_notifier = { | ||
397 | .notifier_call = i8xx_tco_notify_sys, | ||
398 | }; | ||
399 | |||
400 | /* | ||
401 | * Data for PCI driver interface | ||
402 | * | ||
403 | * This data only exists for exporting the supported | ||
404 | * PCI ids via MODULE_DEVICE_TABLE. We do not actually | ||
405 | * register a pci_driver, because someone else might one day | ||
406 | * want to register another driver on the same PCI id. | ||
407 | */ | ||
408 | static struct pci_device_id i8xx_tco_pci_tbl[] = { | ||
409 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0) }, | ||
410 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_0) }, | ||
411 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0) }, | ||
412 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_10) }, | ||
413 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0) }, | ||
414 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12) }, | ||
415 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0) }, | ||
416 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12) }, | ||
417 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_0) }, | ||
418 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0) }, | ||
419 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1) }, | ||
420 | { }, /* End of list */ | ||
421 | }; | ||
422 | MODULE_DEVICE_TABLE (pci, i8xx_tco_pci_tbl); | ||
423 | |||
424 | /* | ||
425 | * Init & exit routines | ||
426 | */ | ||
427 | |||
428 | static unsigned char __init i8xx_tco_getdevice (void) | ||
429 | { | ||
430 | struct pci_dev *dev = NULL; | ||
431 | u8 val1, val2; | ||
432 | u16 badr; | ||
433 | /* | ||
434 | * Find the PCI device | ||
435 | */ | ||
436 | |||
437 | for_each_pci_dev(dev) | ||
438 | if (pci_match_id(i8xx_tco_pci_tbl, dev)) { | ||
439 | i8xx_tco_pci = dev; | ||
440 | break; | ||
441 | } | ||
442 | |||
443 | if (i8xx_tco_pci) { | ||
444 | /* | ||
445 | * Find the ACPI base I/O address which is the base | ||
446 | * for the TCO registers (TCOBASE=ACPIBASE + 0x60) | ||
447 | * ACPIBASE is bits [15:7] from 0x40-0x43 | ||
448 | */ | ||
449 | pci_read_config_byte (i8xx_tco_pci, 0x40, &val1); | ||
450 | pci_read_config_byte (i8xx_tco_pci, 0x41, &val2); | ||
451 | badr = ((val2 << 1) | (val1 >> 7)) << 7; | ||
452 | ACPIBASE = badr; | ||
453 | /* Something's wrong here, ACPIBASE has to be set */ | ||
454 | if (badr == 0x0001 || badr == 0x0000) { | ||
455 | printk (KERN_ERR PFX "failed to get TCOBASE address\n"); | ||
456 | pci_dev_put(i8xx_tco_pci); | ||
457 | return 0; | ||
458 | } | ||
459 | |||
460 | /* Check chipset's NO_REBOOT bit */ | ||
461 | pci_read_config_byte (i8xx_tco_pci, 0xd4, &val1); | ||
462 | if (val1 & 0x02) { | ||
463 | val1 &= 0xfd; | ||
464 | pci_write_config_byte (i8xx_tco_pci, 0xd4, val1); | ||
465 | pci_read_config_byte (i8xx_tco_pci, 0xd4, &val1); | ||
466 | if (val1 & 0x02) { | ||
467 | printk (KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); | ||
468 | pci_dev_put(i8xx_tco_pci); | ||
469 | return 0; /* Cannot reset NO_REBOOT bit */ | ||
470 | } | ||
471 | } | ||
472 | /* Disable reboots untill the watchdog starts */ | ||
473 | val1 |= 0x02; | ||
474 | pci_write_config_byte (i8xx_tco_pci, 0xd4, val1); | ||
475 | |||
476 | /* Set the TCO_EN bit in SMI_EN register */ | ||
477 | if (!request_region (SMI_EN + 1, 1, "i8xx TCO")) { | ||
478 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", | ||
479 | SMI_EN + 1); | ||
480 | pci_dev_put(i8xx_tco_pci); | ||
481 | return 0; | ||
482 | } | ||
483 | val1 = inb (SMI_EN + 1); | ||
484 | val1 &= 0xdf; | ||
485 | outb (val1, SMI_EN + 1); | ||
486 | release_region (SMI_EN + 1, 1); | ||
487 | return 1; | ||
488 | } | ||
489 | return 0; | ||
490 | } | ||
491 | |||
492 | static int __init watchdog_init (void) | ||
493 | { | ||
494 | int ret; | ||
495 | |||
496 | spin_lock_init(&tco_lock); | ||
497 | |||
498 | /* Check whether or not the hardware watchdog is there */ | ||
499 | if (!i8xx_tco_getdevice () || i8xx_tco_pci == NULL) | ||
500 | return -ENODEV; | ||
501 | |||
502 | if (!request_region (TCOBASE, 0x10, "i8xx TCO")) { | ||
503 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", | ||
504 | TCOBASE); | ||
505 | ret = -EIO; | ||
506 | goto out; | ||
507 | } | ||
508 | |||
509 | /* Clear out the (probably old) status */ | ||
510 | outb (0, TCO1_STS); | ||
511 | outb (3, TCO2_STS); | ||
512 | |||
513 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ | ||
514 | if (tco_timer_set_heartbeat (heartbeat)) { | ||
515 | heartbeat = WATCHDOG_HEARTBEAT; | ||
516 | tco_timer_set_heartbeat (heartbeat); | ||
517 | printk(KERN_INFO PFX "heartbeat value must be 2<heartbeat<39, using %d\n", | ||
518 | heartbeat); | ||
519 | } | ||
520 | |||
521 | ret = register_reboot_notifier(&i8xx_tco_notifier); | ||
522 | if (ret != 0) { | ||
523 | printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", | ||
524 | ret); | ||
525 | goto unreg_region; | ||
526 | } | ||
527 | |||
528 | ret = misc_register(&i8xx_tco_miscdev); | ||
529 | if (ret != 0) { | ||
530 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | ||
531 | WATCHDOG_MINOR, ret); | ||
532 | goto unreg_notifier; | ||
533 | } | ||
534 | |||
535 | tco_timer_stop (); | ||
536 | |||
537 | printk (KERN_INFO PFX "initialized (0x%04x). heartbeat=%d sec (nowayout=%d)\n", | ||
538 | TCOBASE, heartbeat, nowayout); | ||
539 | |||
540 | return 0; | ||
541 | |||
542 | unreg_notifier: | ||
543 | unregister_reboot_notifier(&i8xx_tco_notifier); | ||
544 | unreg_region: | ||
545 | release_region (TCOBASE, 0x10); | ||
546 | out: | ||
547 | pci_dev_put(i8xx_tco_pci); | ||
548 | return ret; | ||
549 | } | ||
550 | |||
551 | static void __exit watchdog_cleanup (void) | ||
552 | { | ||
553 | /* Stop the timer before we leave */ | ||
554 | if (!nowayout) | ||
555 | tco_timer_stop (); | ||
556 | |||
557 | /* Deregister */ | ||
558 | misc_deregister (&i8xx_tco_miscdev); | ||
559 | unregister_reboot_notifier(&i8xx_tco_notifier); | ||
560 | release_region (TCOBASE, 0x10); | ||
561 | |||
562 | pci_dev_put(i8xx_tco_pci); | ||
563 | } | ||
564 | |||
565 | module_init(watchdog_init); | ||
566 | module_exit(watchdog_cleanup); | ||
567 | |||
568 | MODULE_AUTHOR("Nils Faerber"); | ||
569 | MODULE_DESCRIPTION("TCO timer driver for i8xx chipsets"); | ||
570 | MODULE_LICENSE("GPL"); | ||
571 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/char/watchdog/i8xx_tco.h b/drivers/char/watchdog/i8xx_tco.h deleted file mode 100644 index cc14eb8ac3d6..000000000000 --- a/drivers/char/watchdog/i8xx_tco.h +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | /* | ||
2 | * i8xx_tco: TCO timer driver for i8xx chipsets | ||
3 | * | ||
4 | * (c) Copyright 2000 kernel concepts <nils@kernelconcepts.de>, All Rights Reserved. | ||
5 | * http://www.kernelconcepts.de | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * Neither kernel concepts nor Nils Faerber admit liability nor provide | ||
13 | * warranty for any of this software. This material is provided | ||
14 | * "AS-IS" and at no charge. | ||
15 | * | ||
16 | * (c) Copyright 2000 kernel concepts <nils@kernelconcepts.de> | ||
17 | * developed for | ||
18 | * Jentro AG, Haar/Munich (Germany) | ||
19 | * | ||
20 | * TCO timer driver for i8xx chipsets | ||
21 | * based on softdog.c by Alan Cox <alan@redhat.com> | ||
22 | * | ||
23 | * For history and the complete list of supported I/O Controller Hub's | ||
24 | * see i8xx_tco.c | ||
25 | */ | ||
26 | |||
27 | |||
28 | /* | ||
29 | * Some address definitions for the TCO | ||
30 | */ | ||
31 | |||
32 | #define TCOBASE ACPIBASE + 0x60 /* TCO base address */ | ||
33 | #define TCO1_RLD TCOBASE + 0x00 /* TCO Timer Reload and Current Value */ | ||
34 | #define TCO1_TMR TCOBASE + 0x01 /* TCO Timer Initial Value */ | ||
35 | #define TCO1_DAT_IN TCOBASE + 0x02 /* TCO Data In Register */ | ||
36 | #define TCO1_DAT_OUT TCOBASE + 0x03 /* TCO Data Out Register */ | ||
37 | #define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */ | ||
38 | #define TCO2_STS TCOBASE + 0x06 /* TCO2 Status Register */ | ||
39 | #define TCO1_CNT TCOBASE + 0x08 /* TCO1 Control Register */ | ||
40 | #define TCO2_CNT TCOBASE + 0x0a /* TCO2 Control Register */ | ||
41 | |||
42 | #define SMI_EN ACPIBASE + 0x30 /* SMI Control and Enable Register */ | ||
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c index 3c9684ccd2f9..eac4f9b9f007 100644 --- a/drivers/char/watchdog/iTCO_wdt.c +++ b/drivers/char/watchdog/iTCO_wdt.c | |||
@@ -571,7 +571,7 @@ static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent, | |||
571 | * ACPIBASE is bits [15:7] from 0x40-0x43 | 571 | * ACPIBASE is bits [15:7] from 0x40-0x43 |
572 | */ | 572 | */ |
573 | pci_read_config_dword(pdev, 0x40, &base_address); | 573 | pci_read_config_dword(pdev, 0x40, &base_address); |
574 | base_address &= 0x00007f80; | 574 | base_address &= 0x0000ff80; |
575 | if (base_address == 0x00000000) { | 575 | if (base_address == 0x00000000) { |
576 | /* Something's wrong here, ACPIBASE has to be set */ | 576 | /* Something's wrong here, ACPIBASE has to be set */ |
577 | printk(KERN_ERR PFX "failed to get TCOBASE address\n"); | 577 | printk(KERN_ERR PFX "failed to get TCOBASE address\n"); |
diff --git a/drivers/char/watchdog/ibmasr.c b/drivers/char/watchdog/ibmasr.c index 8195f5023d85..94155f6136c2 100644 --- a/drivers/char/watchdog/ibmasr.c +++ b/drivers/char/watchdog/ibmasr.c | |||
@@ -367,18 +367,17 @@ static int __init ibmasr_init(void) | |||
367 | if (!asr_type) | 367 | if (!asr_type) |
368 | return -ENODEV; | 368 | return -ENODEV; |
369 | 369 | ||
370 | rc = asr_get_base_address(); | ||
371 | if (rc) | ||
372 | return rc; | ||
373 | |||
370 | rc = misc_register(&asr_miscdev); | 374 | rc = misc_register(&asr_miscdev); |
371 | if (rc < 0) { | 375 | if (rc < 0) { |
376 | release_region(asr_base, asr_length); | ||
372 | printk(KERN_ERR PFX "failed to register misc device\n"); | 377 | printk(KERN_ERR PFX "failed to register misc device\n"); |
373 | return rc; | 378 | return rc; |
374 | } | 379 | } |
375 | 380 | ||
376 | rc = asr_get_base_address(); | ||
377 | if (rc) { | ||
378 | misc_deregister(&asr_miscdev); | ||
379 | return rc; | ||
380 | } | ||
381 | |||
382 | return 0; | 381 | return 0; |
383 | } | 382 | } |
384 | 383 | ||
diff --git a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c index 76c7fa37fa6c..a0d27160c80e 100644 --- a/drivers/char/watchdog/machzwd.c +++ b/drivers/char/watchdog/machzwd.c | |||
@@ -440,13 +440,6 @@ static int __init zf_init(void) | |||
440 | spin_lock_init(&zf_lock); | 440 | spin_lock_init(&zf_lock); |
441 | spin_lock_init(&zf_port_lock); | 441 | spin_lock_init(&zf_port_lock); |
442 | 442 | ||
443 | ret = misc_register(&zf_miscdev); | ||
444 | if (ret){ | ||
445 | printk(KERN_ERR "can't misc_register on minor=%d\n", | ||
446 | WATCHDOG_MINOR); | ||
447 | goto out; | ||
448 | } | ||
449 | |||
450 | if(!request_region(ZF_IOBASE, 3, "MachZ ZFL WDT")){ | 443 | if(!request_region(ZF_IOBASE, 3, "MachZ ZFL WDT")){ |
451 | printk(KERN_ERR "cannot reserve I/O ports at %d\n", | 444 | printk(KERN_ERR "cannot reserve I/O ports at %d\n", |
452 | ZF_IOBASE); | 445 | ZF_IOBASE); |
@@ -461,16 +454,23 @@ static int __init zf_init(void) | |||
461 | goto no_reboot; | 454 | goto no_reboot; |
462 | } | 455 | } |
463 | 456 | ||
457 | ret = misc_register(&zf_miscdev); | ||
458 | if (ret){ | ||
459 | printk(KERN_ERR "can't misc_register on minor=%d\n", | ||
460 | WATCHDOG_MINOR); | ||
461 | goto no_misc; | ||
462 | } | ||
463 | |||
464 | zf_set_status(0); | 464 | zf_set_status(0); |
465 | zf_set_control(0); | 465 | zf_set_control(0); |
466 | 466 | ||
467 | return 0; | 467 | return 0; |
468 | 468 | ||
469 | no_misc: | ||
470 | unregister_reboot_notifier(&zf_notifier); | ||
469 | no_reboot: | 471 | no_reboot: |
470 | release_region(ZF_IOBASE, 3); | 472 | release_region(ZF_IOBASE, 3); |
471 | no_region: | 473 | no_region: |
472 | misc_deregister(&zf_miscdev); | ||
473 | out: | ||
474 | return ret; | 474 | return ret; |
475 | } | 475 | } |
476 | 476 | ||
diff --git a/drivers/char/watchdog/mtx-1_wdt.c b/drivers/char/watchdog/mtx-1_wdt.c new file mode 100644 index 000000000000..419ab445c944 --- /dev/null +++ b/drivers/char/watchdog/mtx-1_wdt.c | |||
@@ -0,0 +1,238 @@ | |||
1 | /* | ||
2 | * Driver for the MTX-1 Watchdog. | ||
3 | * | ||
4 | * (C) Copyright 2005 4G Systems <info@4g-systems.biz>, All Rights Reserved. | ||
5 | * http://www.4g-systems.biz | ||
6 | * | ||
7 | * (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * as published by the Free Software Foundation; either version | ||
12 | * 2 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * Neither Michael Stickel nor 4G Systems admit liability nor provide | ||
15 | * warranty for any of this software. This material is provided | ||
16 | * "AS-IS" and at no charge. | ||
17 | * | ||
18 | * (c) Copyright 2005 4G Systems <info@4g-systems.biz> | ||
19 | * | ||
20 | * Release 0.01. | ||
21 | * Author: Michael Stickel michael.stickel@4g-systems.biz | ||
22 | * | ||
23 | * Release 0.02. | ||
24 | * Author: Florian Fainelli florian@openwrt.org | ||
25 | * use the Linux watchdog/timer APIs | ||
26 | * | ||
27 | * The Watchdog is configured to reset the MTX-1 | ||
28 | * if it is not triggered for 100 seconds. | ||
29 | * It should not be triggered more often than 1.6 seconds. | ||
30 | * | ||
31 | * A timer triggers the watchdog every 5 seconds, until | ||
32 | * it is opened for the first time. After the first open | ||
33 | * it MUST be triggered every 2..95 seconds. | ||
34 | */ | ||
35 | |||
36 | #include <linux/module.h> | ||
37 | #include <linux/moduleparam.h> | ||
38 | #include <linux/types.h> | ||
39 | #include <linux/errno.h> | ||
40 | #include <linux/miscdevice.h> | ||
41 | #include <linux/fs.h> | ||
42 | #include <linux/init.h> | ||
43 | #include <linux/ioport.h> | ||
44 | #include <linux/timer.h> | ||
45 | #include <linux/completion.h> | ||
46 | #include <linux/jiffies.h> | ||
47 | #include <linux/watchdog.h> | ||
48 | #include <asm/io.h> | ||
49 | #include <asm/uaccess.h> | ||
50 | |||
51 | #include <asm/mach-au1x00/au1000.h> | ||
52 | |||
53 | #define MTX1_WDT_INTERVAL (5 * HZ) | ||
54 | |||
55 | static int ticks = 100 * HZ; | ||
56 | |||
57 | static struct { | ||
58 | struct completion stop; | ||
59 | volatile int running; | ||
60 | struct timer_list timer; | ||
61 | volatile int queue; | ||
62 | int default_ticks; | ||
63 | unsigned long inuse; | ||
64 | } mtx1_wdt_device; | ||
65 | |||
66 | static void mtx1_wdt_trigger(unsigned long unused) | ||
67 | { | ||
68 | u32 tmp; | ||
69 | |||
70 | if (mtx1_wdt_device.running) | ||
71 | ticks--; | ||
72 | /* | ||
73 | * toggle GPIO2_15 | ||
74 | */ | ||
75 | tmp = au_readl(GPIO2_DIR); | ||
76 | tmp = (tmp & ~(1<<15)) | ((~tmp) & (1<<15)); | ||
77 | au_writel (tmp, GPIO2_DIR); | ||
78 | |||
79 | if (mtx1_wdt_device.queue && ticks) | ||
80 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); | ||
81 | else { | ||
82 | complete(&mtx1_wdt_device.stop); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | static void mtx1_wdt_reset(void) | ||
87 | { | ||
88 | ticks = mtx1_wdt_device.default_ticks; | ||
89 | } | ||
90 | |||
91 | |||
92 | static void mtx1_wdt_start(void) | ||
93 | { | ||
94 | if (!mtx1_wdt_device.queue) { | ||
95 | mtx1_wdt_device.queue = 1; | ||
96 | au_writel (au_readl(GPIO2_DIR) | (u32)(1<<15), GPIO2_DIR); | ||
97 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); | ||
98 | } | ||
99 | mtx1_wdt_device.running++; | ||
100 | } | ||
101 | |||
102 | static int mtx1_wdt_stop(void) | ||
103 | { | ||
104 | if (mtx1_wdt_device.queue) { | ||
105 | mtx1_wdt_device.queue = 0; | ||
106 | au_writel (au_readl(GPIO2_DIR) & ~((u32)(1<<15)), GPIO2_DIR); | ||
107 | } | ||
108 | |||
109 | ticks = mtx1_wdt_device.default_ticks; | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | /* Filesystem functions */ | ||
115 | |||
116 | static int mtx1_wdt_open(struct inode *inode, struct file *file) | ||
117 | { | ||
118 | if (test_and_set_bit(0, &mtx1_wdt_device.inuse)) | ||
119 | return -EBUSY; | ||
120 | |||
121 | return nonseekable_open(inode, file); | ||
122 | } | ||
123 | |||
124 | |||
125 | static int mtx1_wdt_release(struct inode *inode, struct file *file) | ||
126 | { | ||
127 | clear_bit(0, &mtx1_wdt_device.inuse); | ||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static int mtx1_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | ||
132 | { | ||
133 | void __user *argp = (void __user *)arg; | ||
134 | unsigned int value; | ||
135 | static struct watchdog_info ident = | ||
136 | { | ||
137 | .options = WDIOF_CARDRESET, | ||
138 | .identity = "MTX-1 WDT", | ||
139 | }; | ||
140 | |||
141 | switch(cmd) { | ||
142 | case WDIOC_KEEPALIVE: | ||
143 | mtx1_wdt_reset(); | ||
144 | break; | ||
145 | case WDIOC_GETSTATUS: | ||
146 | if ( copy_to_user(argp, &value, sizeof(int)) ) | ||
147 | return -EFAULT; | ||
148 | break; | ||
149 | case WDIOC_GETSUPPORT: | ||
150 | if ( copy_to_user(argp, &ident, sizeof(ident)) ) | ||
151 | return -EFAULT; | ||
152 | break; | ||
153 | case WDIOC_SETOPTIONS: | ||
154 | if ( copy_from_user(&value, argp, sizeof(int)) ) | ||
155 | return -EFAULT; | ||
156 | switch(value) { | ||
157 | case WDIOS_ENABLECARD: | ||
158 | mtx1_wdt_start(); | ||
159 | break; | ||
160 | case WDIOS_DISABLECARD: | ||
161 | return mtx1_wdt_stop(); | ||
162 | default: | ||
163 | return -EINVAL; | ||
164 | } | ||
165 | break; | ||
166 | default: | ||
167 | return -ENOTTY; | ||
168 | } | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | |||
173 | static ssize_t mtx1_wdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos) | ||
174 | { | ||
175 | if (!count) | ||
176 | return -EIO; | ||
177 | |||
178 | mtx1_wdt_reset(); | ||
179 | return count; | ||
180 | } | ||
181 | |||
182 | static struct file_operations mtx1_wdt_fops = { | ||
183 | .owner = THIS_MODULE, | ||
184 | .llseek = no_llseek, | ||
185 | .ioctl = mtx1_wdt_ioctl, | ||
186 | .open = mtx1_wdt_open, | ||
187 | .write = mtx1_wdt_write, | ||
188 | .release = mtx1_wdt_release | ||
189 | }; | ||
190 | |||
191 | |||
192 | static struct miscdevice mtx1_wdt_misc = { | ||
193 | .minor = WATCHDOG_MINOR, | ||
194 | .name = "watchdog", | ||
195 | .fops = &mtx1_wdt_fops | ||
196 | }; | ||
197 | |||
198 | |||
199 | static int __init mtx1_wdt_init(void) | ||
200 | { | ||
201 | int ret; | ||
202 | |||
203 | if ((ret = misc_register(&mtx1_wdt_misc)) < 0) { | ||
204 | printk(KERN_ERR " mtx-1_wdt : failed to register\n"); | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | init_completion(&mtx1_wdt_device.stop); | ||
209 | mtx1_wdt_device.queue = 0; | ||
210 | |||
211 | clear_bit(0, &mtx1_wdt_device.inuse); | ||
212 | |||
213 | setup_timer(&mtx1_wdt_device.timer, mtx1_wdt_trigger, 0L); | ||
214 | |||
215 | mtx1_wdt_device.default_ticks = ticks; | ||
216 | |||
217 | mtx1_wdt_start(); | ||
218 | |||
219 | printk(KERN_INFO "MTX-1 Watchdog driver\n"); | ||
220 | |||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static void __exit mtx1_wdt_exit(void) | ||
225 | { | ||
226 | if (mtx1_wdt_device.queue) { | ||
227 | mtx1_wdt_device.queue = 0; | ||
228 | wait_for_completion(&mtx1_wdt_device.stop); | ||
229 | } | ||
230 | misc_deregister(&mtx1_wdt_misc); | ||
231 | } | ||
232 | |||
233 | module_init(mtx1_wdt_init); | ||
234 | module_exit(mtx1_wdt_exit); | ||
235 | |||
236 | MODULE_AUTHOR("Michael Stickel, Florian Fainelli"); | ||
237 | MODULE_DESCRIPTION("Driver for the MTX-1 watchdog"); | ||
238 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c index 6e8b5705b5b7..7b41434fac8c 100644 --- a/drivers/char/watchdog/pcwd.c +++ b/drivers/char/watchdog/pcwd.c | |||
@@ -59,10 +59,10 @@ | |||
59 | #include <linux/jiffies.h> /* For jiffies stuff */ | 59 | #include <linux/jiffies.h> /* For jiffies stuff */ |
60 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ | 60 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ |
61 | #include <linux/watchdog.h> /* For the watchdog specific items */ | 61 | #include <linux/watchdog.h> /* For the watchdog specific items */ |
62 | #include <linux/notifier.h> /* For notifier support */ | 62 | #include <linux/reboot.h> /* For kernel_power_off() */ |
63 | #include <linux/reboot.h> /* For reboot_notifier stuff */ | ||
64 | #include <linux/init.h> /* For __init/__exit/... */ | 63 | #include <linux/init.h> /* For __init/__exit/... */ |
65 | #include <linux/fs.h> /* For file operations */ | 64 | #include <linux/fs.h> /* For file operations */ |
65 | #include <linux/isa.h> /* For isa devices */ | ||
66 | #include <linux/ioport.h> /* For io-port access */ | 66 | #include <linux/ioport.h> /* For io-port access */ |
67 | #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ | 67 | #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ |
68 | 68 | ||
@@ -70,8 +70,8 @@ | |||
70 | #include <asm/io.h> /* For inb/outb/... */ | 70 | #include <asm/io.h> /* For inb/outb/... */ |
71 | 71 | ||
72 | /* Module and version information */ | 72 | /* Module and version information */ |
73 | #define WATCHDOG_VERSION "1.18" | 73 | #define WATCHDOG_VERSION "1.20" |
74 | #define WATCHDOG_DATE "21 Jan 2007" | 74 | #define WATCHDOG_DATE "18 Feb 2007" |
75 | #define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" | 75 | #define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" |
76 | #define WATCHDOG_NAME "pcwd" | 76 | #define WATCHDOG_NAME "pcwd" |
77 | #define PFX WATCHDOG_NAME ": " | 77 | #define PFX WATCHDOG_NAME ": " |
@@ -89,6 +89,15 @@ | |||
89 | #define PCWD_REVISION_C 2 | 89 | #define PCWD_REVISION_C 2 |
90 | 90 | ||
91 | /* | 91 | /* |
92 | * These are the auto-probe addresses available. | ||
93 | * | ||
94 | * Revision A only uses ports 0x270 and 0x370. Revision C introduced 0x350. | ||
95 | * Revision A has an address range of 2 addresses, while Revision C has 4. | ||
96 | */ | ||
97 | #define PCWD_ISA_NR_CARDS 3 | ||
98 | static int pcwd_ioports[] = { 0x270, 0x350, 0x370, 0x000 }; | ||
99 | |||
100 | /* | ||
92 | * These are the defines that describe the control status bits for the | 101 | * These are the defines that describe the control status bits for the |
93 | * PCI-PC Watchdog card. | 102 | * PCI-PC Watchdog card. |
94 | */ | 103 | */ |
@@ -485,7 +494,7 @@ static int pcwd_get_status(int *status) | |||
485 | if (control_status & WD_T110) { | 494 | if (control_status & WD_T110) { |
486 | *status |= WDIOF_OVERHEAT; | 495 | *status |= WDIOF_OVERHEAT; |
487 | if (temp_panic) { | 496 | if (temp_panic) { |
488 | printk (KERN_INFO PFX "Temperature overheat trip!\n"); | 497 | printk(KERN_INFO PFX "Temperature overheat trip!\n"); |
489 | kernel_power_off(); | 498 | kernel_power_off(); |
490 | /* or should we just do a: panic(PFX "Temperature overheat trip!\n"); */ | 499 | /* or should we just do a: panic(PFX "Temperature overheat trip!\n"); */ |
491 | } | 500 | } |
@@ -497,7 +506,7 @@ static int pcwd_get_status(int *status) | |||
497 | if (control_status & WD_REVC_TTRP) { | 506 | if (control_status & WD_REVC_TTRP) { |
498 | *status |= WDIOF_OVERHEAT; | 507 | *status |= WDIOF_OVERHEAT; |
499 | if (temp_panic) { | 508 | if (temp_panic) { |
500 | printk (KERN_INFO PFX "Temperature overheat trip!\n"); | 509 | printk(KERN_INFO PFX "Temperature overheat trip!\n"); |
501 | kernel_power_off(); | 510 | kernel_power_off(); |
502 | /* or should we just do a: panic(PFX "Temperature overheat trip!\n"); */ | 511 | /* or should we just do a: panic(PFX "Temperature overheat trip!\n"); */ |
503 | } | 512 | } |
@@ -734,20 +743,6 @@ static int pcwd_temp_close(struct inode *inode, struct file *file) | |||
734 | } | 743 | } |
735 | 744 | ||
736 | /* | 745 | /* |
737 | * Notify system | ||
738 | */ | ||
739 | |||
740 | static int pcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) | ||
741 | { | ||
742 | if (code==SYS_DOWN || code==SYS_HALT) { | ||
743 | /* Turn the WDT off */ | ||
744 | pcwd_stop(); | ||
745 | } | ||
746 | |||
747 | return NOTIFY_DONE; | ||
748 | } | ||
749 | |||
750 | /* | ||
751 | * Kernel Interfaces | 746 | * Kernel Interfaces |
752 | */ | 747 | */ |
753 | 748 | ||
@@ -780,10 +775,6 @@ static struct miscdevice temp_miscdev = { | |||
780 | .fops = &pcwd_temp_fops, | 775 | .fops = &pcwd_temp_fops, |
781 | }; | 776 | }; |
782 | 777 | ||
783 | static struct notifier_block pcwd_notifier = { | ||
784 | .notifier_call = pcwd_notify_sys, | ||
785 | }; | ||
786 | |||
787 | /* | 778 | /* |
788 | * Init & exit routines | 779 | * Init & exit routines |
789 | */ | 780 | */ |
@@ -803,10 +794,67 @@ static inline int get_revision(void) | |||
803 | return r; | 794 | return r; |
804 | } | 795 | } |
805 | 796 | ||
806 | static int __devinit pcwatchdog_init(int base_addr) | 797 | /* |
798 | * The ISA cards have a heartbeat bit in one of the registers, which | ||
799 | * register is card dependent. The heartbeat bit is monitored, and if | ||
800 | * found, is considered proof that a Berkshire card has been found. | ||
801 | * The initial rate is once per second at board start up, then twice | ||
802 | * per second for normal operation. | ||
803 | */ | ||
804 | static int __devinit pcwd_isa_match(struct device *dev, unsigned int id) | ||
805 | { | ||
806 | int base_addr=pcwd_ioports[id]; | ||
807 | int port0, last_port0; /* Reg 0, in case it's REV A */ | ||
808 | int port1, last_port1; /* Register 1 for REV C cards */ | ||
809 | int i; | ||
810 | int retval; | ||
811 | |||
812 | if (debug >= DEBUG) | ||
813 | printk(KERN_DEBUG PFX "pcwd_isa_match id=%d\n", | ||
814 | id); | ||
815 | |||
816 | if (!request_region (base_addr, 4, "PCWD")) { | ||
817 | printk(KERN_INFO PFX "Port 0x%04x unavailable\n", base_addr); | ||
818 | return 0; | ||
819 | } | ||
820 | |||
821 | retval = 0; | ||
822 | |||
823 | port0 = inb_p(base_addr); /* For REV A boards */ | ||
824 | port1 = inb_p(base_addr + 1); /* For REV C boards */ | ||
825 | if (port0 != 0xff || port1 != 0xff) { | ||
826 | /* Not an 'ff' from a floating bus, so must be a card! */ | ||
827 | for (i = 0; i < 4; ++i) { | ||
828 | |||
829 | msleep(500); | ||
830 | |||
831 | last_port0 = port0; | ||
832 | last_port1 = port1; | ||
833 | |||
834 | port0 = inb_p(base_addr); | ||
835 | port1 = inb_p(base_addr + 1); | ||
836 | |||
837 | /* Has either hearbeat bit changed? */ | ||
838 | if ((port0 ^ last_port0) & WD_HRTBT || | ||
839 | (port1 ^ last_port1) & WD_REVC_HRBT) { | ||
840 | retval = 1; | ||
841 | break; | ||
842 | } | ||
843 | } | ||
844 | } | ||
845 | release_region (base_addr, 4); | ||
846 | |||
847 | return retval; | ||
848 | } | ||
849 | |||
850 | static int __devinit pcwd_isa_probe(struct device *dev, unsigned int id) | ||
807 | { | 851 | { |
808 | int ret; | 852 | int ret; |
809 | 853 | ||
854 | if (debug >= DEBUG) | ||
855 | printk(KERN_DEBUG PFX "pcwd_isa_probe id=%d\n", | ||
856 | id); | ||
857 | |||
810 | cards_found++; | 858 | cards_found++; |
811 | if (cards_found == 1) | 859 | if (cards_found == 1) |
812 | printk(KERN_INFO PFX "v%s Ken Hollis (kenji@bitgate.com)\n", WD_VER); | 860 | printk(KERN_INFO PFX "v%s Ken Hollis (kenji@bitgate.com)\n", WD_VER); |
@@ -816,11 +864,13 @@ static int __devinit pcwatchdog_init(int base_addr) | |||
816 | return -ENODEV; | 864 | return -ENODEV; |
817 | } | 865 | } |
818 | 866 | ||
819 | if (base_addr == 0x0000) { | 867 | if (pcwd_ioports[id] == 0x0000) { |
820 | printk(KERN_ERR PFX "No I/O-Address for card detected\n"); | 868 | printk(KERN_ERR PFX "No I/O-Address for card detected\n"); |
821 | return -ENODEV; | 869 | return -ENODEV; |
822 | } | 870 | } |
823 | pcwd_private.io_addr = base_addr; | 871 | pcwd_private.io_addr = pcwd_ioports[id]; |
872 | |||
873 | spin_lock_init(&pcwd_private.io_lock); | ||
824 | 874 | ||
825 | /* Check card's revision */ | 875 | /* Check card's revision */ |
826 | pcwd_private.revision = get_revision(); | 876 | pcwd_private.revision = get_revision(); |
@@ -828,8 +878,8 @@ static int __devinit pcwatchdog_init(int base_addr) | |||
828 | if (!request_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) { | 878 | if (!request_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) { |
829 | printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", | 879 | printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", |
830 | pcwd_private.io_addr); | 880 | pcwd_private.io_addr); |
831 | pcwd_private.io_addr = 0x0000; | 881 | ret=-EIO; |
832 | return -EIO; | 882 | goto error_request_region; |
833 | } | 883 | } |
834 | 884 | ||
835 | /* Initial variables */ | 885 | /* Initial variables */ |
@@ -865,24 +915,12 @@ static int __devinit pcwatchdog_init(int base_addr) | |||
865 | WATCHDOG_HEARTBEAT); | 915 | WATCHDOG_HEARTBEAT); |
866 | } | 916 | } |
867 | 917 | ||
868 | ret = register_reboot_notifier(&pcwd_notifier); | ||
869 | if (ret) { | ||
870 | printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", | ||
871 | ret); | ||
872 | release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); | ||
873 | pcwd_private.io_addr = 0x0000; | ||
874 | return ret; | ||
875 | } | ||
876 | |||
877 | if (pcwd_private.supports_temp) { | 918 | if (pcwd_private.supports_temp) { |
878 | ret = misc_register(&temp_miscdev); | 919 | ret = misc_register(&temp_miscdev); |
879 | if (ret) { | 920 | if (ret) { |
880 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | 921 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
881 | TEMP_MINOR, ret); | 922 | TEMP_MINOR, ret); |
882 | unregister_reboot_notifier(&pcwd_notifier); | 923 | goto error_misc_register_temp; |
883 | release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); | ||
884 | pcwd_private.io_addr = 0x0000; | ||
885 | return ret; | ||
886 | } | 924 | } |
887 | } | 925 | } |
888 | 926 | ||
@@ -890,22 +928,34 @@ static int __devinit pcwatchdog_init(int base_addr) | |||
890 | if (ret) { | 928 | if (ret) { |
891 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | 929 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
892 | WATCHDOG_MINOR, ret); | 930 | WATCHDOG_MINOR, ret); |
893 | if (pcwd_private.supports_temp) | 931 | goto error_misc_register_watchdog; |
894 | misc_deregister(&temp_miscdev); | ||
895 | unregister_reboot_notifier(&pcwd_notifier); | ||
896 | release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); | ||
897 | pcwd_private.io_addr = 0x0000; | ||
898 | return ret; | ||
899 | } | 932 | } |
900 | 933 | ||
901 | printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", | 934 | printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", |
902 | heartbeat, nowayout); | 935 | heartbeat, nowayout); |
903 | 936 | ||
904 | return 0; | 937 | return 0; |
938 | |||
939 | error_misc_register_watchdog: | ||
940 | if (pcwd_private.supports_temp) | ||
941 | misc_deregister(&temp_miscdev); | ||
942 | error_misc_register_temp: | ||
943 | release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); | ||
944 | error_request_region: | ||
945 | pcwd_private.io_addr = 0x0000; | ||
946 | cards_found--; | ||
947 | return ret; | ||
905 | } | 948 | } |
906 | 949 | ||
907 | static void __devexit pcwatchdog_exit(void) | 950 | static int __devexit pcwd_isa_remove(struct device *dev, unsigned int id) |
908 | { | 951 | { |
952 | if (debug >= DEBUG) | ||
953 | printk(KERN_DEBUG PFX "pcwd_isa_remove id=%d\n", | ||
954 | id); | ||
955 | |||
956 | if (!pcwd_private.io_addr) | ||
957 | return 1; | ||
958 | |||
909 | /* Disable the board */ | 959 | /* Disable the board */ |
910 | if (!nowayout) | 960 | if (!nowayout) |
911 | pcwd_stop(); | 961 | pcwd_stop(); |
@@ -914,102 +964,50 @@ static void __devexit pcwatchdog_exit(void) | |||
914 | misc_deregister(&pcwd_miscdev); | 964 | misc_deregister(&pcwd_miscdev); |
915 | if (pcwd_private.supports_temp) | 965 | if (pcwd_private.supports_temp) |
916 | misc_deregister(&temp_miscdev); | 966 | misc_deregister(&temp_miscdev); |
917 | unregister_reboot_notifier(&pcwd_notifier); | ||
918 | release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); | 967 | release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); |
919 | pcwd_private.io_addr = 0x0000; | 968 | pcwd_private.io_addr = 0x0000; |
920 | cards_found--; | 969 | cards_found--; |
970 | |||
971 | return 0; | ||
921 | } | 972 | } |
922 | 973 | ||
923 | /* | 974 | static void pcwd_isa_shutdown(struct device *dev, unsigned int id) |
924 | * The ISA cards have a heartbeat bit in one of the registers, which | ||
925 | * register is card dependent. The heartbeat bit is monitored, and if | ||
926 | * found, is considered proof that a Berkshire card has been found. | ||
927 | * The initial rate is once per second at board start up, then twice | ||
928 | * per second for normal operation. | ||
929 | */ | ||
930 | static int __init pcwd_checkcard(int base_addr) | ||
931 | { | 975 | { |
932 | int port0, last_port0; /* Reg 0, in case it's REV A */ | 976 | if (debug >= DEBUG) |
933 | int port1, last_port1; /* Register 1 for REV C cards */ | 977 | printk(KERN_DEBUG PFX "pcwd_isa_shutdown id=%d\n", |
934 | int i; | 978 | id); |
935 | int retval; | ||
936 | |||
937 | if (!request_region (base_addr, 4, "PCWD")) { | ||
938 | printk (KERN_INFO PFX "Port 0x%04x unavailable\n", base_addr); | ||
939 | return 0; | ||
940 | } | ||
941 | |||
942 | retval = 0; | ||
943 | |||
944 | port0 = inb_p(base_addr); /* For REV A boards */ | ||
945 | port1 = inb_p(base_addr + 1); /* For REV C boards */ | ||
946 | if (port0 != 0xff || port1 != 0xff) { | ||
947 | /* Not an 'ff' from a floating bus, so must be a card! */ | ||
948 | for (i = 0; i < 4; ++i) { | ||
949 | |||
950 | msleep(500); | ||
951 | |||
952 | last_port0 = port0; | ||
953 | last_port1 = port1; | ||
954 | |||
955 | port0 = inb_p(base_addr); | ||
956 | port1 = inb_p(base_addr + 1); | ||
957 | |||
958 | /* Has either hearbeat bit changed? */ | ||
959 | if ((port0 ^ last_port0) & WD_HRTBT || | ||
960 | (port1 ^ last_port1) & WD_REVC_HRBT) { | ||
961 | retval = 1; | ||
962 | break; | ||
963 | } | ||
964 | } | ||
965 | } | ||
966 | release_region (base_addr, 4); | ||
967 | 979 | ||
968 | return retval; | 980 | pcwd_stop(); |
969 | } | 981 | } |
970 | 982 | ||
971 | /* | 983 | static struct isa_driver pcwd_isa_driver = { |
972 | * These are the auto-probe addresses available. | 984 | .match = pcwd_isa_match, |
973 | * | 985 | .probe = pcwd_isa_probe, |
974 | * Revision A only uses ports 0x270 and 0x370. Revision C introduced 0x350. | 986 | .remove = __devexit_p(pcwd_isa_remove), |
975 | * Revision A has an address range of 2 addresses, while Revision C has 4. | 987 | .shutdown = pcwd_isa_shutdown, |
976 | */ | 988 | .driver = { |
977 | static int pcwd_ioports[] = { 0x270, 0x350, 0x370, 0x000 }; | 989 | .owner = THIS_MODULE, |
990 | .name = WATCHDOG_NAME, | ||
991 | }, | ||
992 | }; | ||
978 | 993 | ||
979 | static int __init pcwd_init_module(void) | 994 | static int __init pcwd_init_module(void) |
980 | { | 995 | { |
981 | int i, found = 0; | 996 | return isa_register_driver(&pcwd_isa_driver, PCWD_ISA_NR_CARDS); |
982 | |||
983 | spin_lock_init(&pcwd_private.io_lock); | ||
984 | |||
985 | for (i = 0; pcwd_ioports[i] != 0; i++) { | ||
986 | if (pcwd_checkcard(pcwd_ioports[i])) { | ||
987 | if (!(pcwatchdog_init(pcwd_ioports[i]))) | ||
988 | found++; | ||
989 | } | ||
990 | } | ||
991 | |||
992 | if (!found) { | ||
993 | printk (KERN_INFO PFX "No card detected, or port not available\n"); | ||
994 | return -ENODEV; | ||
995 | } | ||
996 | |||
997 | return 0; | ||
998 | } | 997 | } |
999 | 998 | ||
1000 | static void __exit pcwd_cleanup_module(void) | 999 | static void __exit pcwd_cleanup_module(void) |
1001 | { | 1000 | { |
1002 | if (pcwd_private.io_addr) | 1001 | isa_unregister_driver(&pcwd_isa_driver); |
1003 | pcwatchdog_exit(); | ||
1004 | |||
1005 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | 1002 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); |
1006 | } | 1003 | } |
1007 | 1004 | ||
1008 | module_init(pcwd_init_module); | 1005 | module_init(pcwd_init_module); |
1009 | module_exit(pcwd_cleanup_module); | 1006 | module_exit(pcwd_cleanup_module); |
1010 | 1007 | ||
1011 | MODULE_AUTHOR("Ken Hollis <kenji@bitgate.com>"); | 1008 | MODULE_AUTHOR("Ken Hollis <kenji@bitgate.com>, Wim Van Sebroeck <wim@iguana.be>"); |
1012 | MODULE_DESCRIPTION("Berkshire ISA-PC Watchdog driver"); | 1009 | MODULE_DESCRIPTION("Berkshire ISA-PC Watchdog driver"); |
1010 | MODULE_VERSION(WATCHDOG_VERSION); | ||
1013 | MODULE_LICENSE("GPL"); | 1011 | MODULE_LICENSE("GPL"); |
1014 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | 1012 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
1015 | MODULE_ALIAS_MISCDEV(TEMP_MINOR); | 1013 | MODULE_ALIAS_MISCDEV(TEMP_MINOR); |
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index 31037f9c9ffe..1e7a6719d5ba 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c | |||
@@ -146,7 +146,7 @@ struct usb_pcwd_private { | |||
146 | atomic_t cmd_received; /* true if we received a report after a command */ | 146 | atomic_t cmd_received; /* true if we received a report after a command */ |
147 | 147 | ||
148 | int exists; /* Wether or not the device exists */ | 148 | int exists; /* Wether or not the device exists */ |
149 | struct semaphore sem; /* locks this structure */ | 149 | struct mutex mtx; /* locks this structure */ |
150 | }; | 150 | }; |
151 | static struct usb_pcwd_private *usb_pcwd_device; | 151 | static struct usb_pcwd_private *usb_pcwd_device; |
152 | 152 | ||
@@ -635,7 +635,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi | |||
635 | 635 | ||
636 | usb_pcwd_device = usb_pcwd; | 636 | usb_pcwd_device = usb_pcwd; |
637 | 637 | ||
638 | init_MUTEX (&usb_pcwd->sem); | 638 | mutex_init(&usb_pcwd->mtx); |
639 | usb_pcwd->udev = udev; | 639 | usb_pcwd->udev = udev; |
640 | usb_pcwd->interface = interface; | 640 | usb_pcwd->interface = interface; |
641 | usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber; | 641 | usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber; |
@@ -763,7 +763,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface) | |||
763 | usb_pcwd = usb_get_intfdata (interface); | 763 | usb_pcwd = usb_get_intfdata (interface); |
764 | usb_set_intfdata (interface, NULL); | 764 | usb_set_intfdata (interface, NULL); |
765 | 765 | ||
766 | down (&usb_pcwd->sem); | 766 | mutex_lock(&usb_pcwd->mtx); |
767 | 767 | ||
768 | /* Stop the timer before we leave */ | 768 | /* Stop the timer before we leave */ |
769 | if (!nowayout) | 769 | if (!nowayout) |
@@ -777,7 +777,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface) | |||
777 | misc_deregister(&usb_pcwd_temperature_miscdev); | 777 | misc_deregister(&usb_pcwd_temperature_miscdev); |
778 | unregister_reboot_notifier(&usb_pcwd_notifier); | 778 | unregister_reboot_notifier(&usb_pcwd_notifier); |
779 | 779 | ||
780 | up (&usb_pcwd->sem); | 780 | mutex_unlock(&usb_pcwd->mtx); |
781 | 781 | ||
782 | /* Delete the USB PCWD device */ | 782 | /* Delete the USB PCWD device */ |
783 | usb_pcwd_delete(usb_pcwd); | 783 | usb_pcwd_delete(usb_pcwd); |
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index dff6cb5dc9a7..20fa29ca7404 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c | |||
@@ -379,14 +379,14 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
379 | 379 | ||
380 | DBG("probe: mapped wdt_base=%p\n", wdt_base); | 380 | DBG("probe: mapped wdt_base=%p\n", wdt_base); |
381 | 381 | ||
382 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 382 | wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
383 | if (res == NULL) { | 383 | if (wdt_irq == NULL) { |
384 | printk(KERN_INFO PFX "failed to get irq resource\n"); | 384 | printk(KERN_INFO PFX "failed to get irq resource\n"); |
385 | ret = -ENOENT; | 385 | ret = -ENOENT; |
386 | goto err_map; | 386 | goto err_map; |
387 | } | 387 | } |
388 | 388 | ||
389 | ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev); | 389 | ret = request_irq(wdt_irq->start, s3c2410wdt_irq, 0, pdev->name, pdev); |
390 | if (ret != 0) { | 390 | if (ret != 0) { |
391 | printk(KERN_INFO PFX "failed to install irq (%d)\n", ret); | 391 | printk(KERN_INFO PFX "failed to install irq (%d)\n", ret); |
392 | goto err_map; | 392 | goto err_map; |
diff --git a/drivers/char/watchdog/sbc8360.c b/drivers/char/watchdog/sbc8360.c index 67ae42685e75..285d85289532 100644 --- a/drivers/char/watchdog/sbc8360.c +++ b/drivers/char/watchdog/sbc8360.c | |||
@@ -333,18 +333,17 @@ static int __init sbc8360_init(void) | |||
333 | int res; | 333 | int res; |
334 | unsigned long int mseconds = 60000; | 334 | unsigned long int mseconds = 60000; |
335 | 335 | ||
336 | spin_lock_init(&sbc8360_lock); | 336 | if (timeout < 0 || timeout > 63) { |
337 | res = misc_register(&sbc8360_miscdev); | 337 | printk(KERN_ERR PFX "Invalid timeout index (must be 0-63).\n"); |
338 | if (res) { | 338 | res = -EINVAL; |
339 | printk(KERN_ERR PFX "failed to register misc device\n"); | 339 | goto out; |
340 | goto out_nomisc; | ||
341 | } | 340 | } |
342 | 341 | ||
343 | if (!request_region(SBC8360_ENABLE, 1, "SBC8360")) { | 342 | if (!request_region(SBC8360_ENABLE, 1, "SBC8360")) { |
344 | printk(KERN_ERR PFX "ENABLE method I/O %X is not available.\n", | 343 | printk(KERN_ERR PFX "ENABLE method I/O %X is not available.\n", |
345 | SBC8360_ENABLE); | 344 | SBC8360_ENABLE); |
346 | res = -EIO; | 345 | res = -EIO; |
347 | goto out_noenablereg; | 346 | goto out; |
348 | } | 347 | } |
349 | if (!request_region(SBC8360_BASETIME, 1, "SBC8360")) { | 348 | if (!request_region(SBC8360_BASETIME, 1, "SBC8360")) { |
350 | printk(KERN_ERR PFX | 349 | printk(KERN_ERR PFX |
@@ -360,10 +359,11 @@ static int __init sbc8360_init(void) | |||
360 | goto out_noreboot; | 359 | goto out_noreboot; |
361 | } | 360 | } |
362 | 361 | ||
363 | if (timeout < 0 || timeout > 63) { | 362 | spin_lock_init(&sbc8360_lock); |
364 | printk(KERN_ERR PFX "Invalid timeout index (must be 0-63).\n"); | 363 | res = misc_register(&sbc8360_miscdev); |
365 | res = -EINVAL; | 364 | if (res) { |
366 | goto out_noreboot; | 365 | printk(KERN_ERR PFX "failed to register misc device\n"); |
366 | goto out_nomisc; | ||
367 | } | 367 | } |
368 | 368 | ||
369 | wd_margin = wd_times[timeout][0]; | 369 | wd_margin = wd_times[timeout][0]; |
@@ -383,13 +383,13 @@ static int __init sbc8360_init(void) | |||
383 | 383 | ||
384 | return 0; | 384 | return 0; |
385 | 385 | ||
386 | out_nomisc: | ||
387 | unregister_reboot_notifier(&sbc8360_notifier); | ||
386 | out_noreboot: | 388 | out_noreboot: |
387 | release_region(SBC8360_ENABLE, 1); | ||
388 | release_region(SBC8360_BASETIME, 1); | 389 | release_region(SBC8360_BASETIME, 1); |
389 | out_noenablereg: | ||
390 | out_nobasetimereg: | 390 | out_nobasetimereg: |
391 | misc_deregister(&sbc8360_miscdev); | 391 | release_region(SBC8360_ENABLE, 1); |
392 | out_nomisc: | 392 | out: |
393 | return res; | 393 | return res; |
394 | } | 394 | } |
395 | 395 | ||
diff --git a/drivers/char/watchdog/w83627hf_wdt.c b/drivers/char/watchdog/w83627hf_wdt.c index 337ee42c90dd..b46e7f47d705 100644 --- a/drivers/char/watchdog/w83627hf_wdt.c +++ b/drivers/char/watchdog/w83627hf_wdt.c | |||
@@ -1,5 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * w83627hf WDT driver | 2 | * w83627hf/thf WDT driver |
3 | * | ||
4 | * (c) Copyright 2007 Vlad Drukker <vlad@storewiz.com> | ||
5 | * added support for W83627THF. | ||
3 | * | 6 | * |
4 | * (c) Copyright 2003 Pádraig Brady <P@draigBrady.com> | 7 | * (c) Copyright 2003 Pádraig Brady <P@draigBrady.com> |
5 | * | 8 | * |
@@ -39,7 +42,7 @@ | |||
39 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
40 | #include <asm/system.h> | 43 | #include <asm/system.h> |
41 | 44 | ||
42 | #define WATCHDOG_NAME "w83627hf WDT" | 45 | #define WATCHDOG_NAME "w83627hf/thf WDT" |
43 | #define PFX WATCHDOG_NAME ": " | 46 | #define PFX WATCHDOG_NAME ": " |
44 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ | 47 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ |
45 | 48 | ||
@@ -50,7 +53,7 @@ static spinlock_t io_lock; | |||
50 | /* You must set this - there is no sane way to probe for this board. */ | 53 | /* You must set this - there is no sane way to probe for this board. */ |
51 | static int wdt_io = 0x2E; | 54 | static int wdt_io = 0x2E; |
52 | module_param(wdt_io, int, 0); | 55 | module_param(wdt_io, int, 0); |
53 | MODULE_PARM_DESC(wdt_io, "w83627hf WDT io port (default 0x2E)"); | 56 | MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)"); |
54 | 57 | ||
55 | static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ | 58 | static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ |
56 | module_param(timeout, int, 0); | 59 | module_param(timeout, int, 0); |
@@ -71,9 +74,19 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" _ | |||
71 | static void | 74 | static void |
72 | w83627hf_select_wd_register(void) | 75 | w83627hf_select_wd_register(void) |
73 | { | 76 | { |
77 | unsigned char c; | ||
74 | outb_p(0x87, WDT_EFER); /* Enter extended function mode */ | 78 | outb_p(0x87, WDT_EFER); /* Enter extended function mode */ |
75 | outb_p(0x87, WDT_EFER); /* Again according to manual */ | 79 | outb_p(0x87, WDT_EFER); /* Again according to manual */ |
76 | 80 | ||
81 | outb(0x20, WDT_EFER); /* check chip version */ | ||
82 | c = inb(WDT_EFDR); | ||
83 | if (c == 0x82) { /* W83627THF */ | ||
84 | outb_p(0x2b, WDT_EFER); /* select GPIO3 */ | ||
85 | c = ((inb_p(WDT_EFDR) & 0xf7) | 0x04); /* select WDT0 */ | ||
86 | outb_p(0x2b, WDT_EFER); | ||
87 | outb_p(c, WDT_EFDR); /* set GPIO3 to WDT0 */ | ||
88 | } | ||
89 | |||
77 | outb_p(0x07, WDT_EFER); /* point to logical device number reg */ | 90 | outb_p(0x07, WDT_EFER); /* point to logical device number reg */ |
78 | outb_p(0x08, WDT_EFDR); /* select logical device 8 (GPIO2) */ | 91 | outb_p(0x08, WDT_EFDR); /* select logical device 8 (GPIO2) */ |
79 | outb_p(0x30, WDT_EFER); /* select CR30 */ | 92 | outb_p(0x30, WDT_EFER); /* select CR30 */ |
@@ -311,7 +324,7 @@ wdt_init(void) | |||
311 | 324 | ||
312 | spin_lock_init(&io_lock); | 325 | spin_lock_init(&io_lock); |
313 | 326 | ||
314 | printk(KERN_INFO "WDT driver for the Winbond(TM) W83627HF Super I/O chip initialising.\n"); | 327 | printk(KERN_INFO "WDT driver for the Winbond(TM) W83627HF/THF Super I/O chip initialising.\n"); |
315 | 328 | ||
316 | if (wdt_set_heartbeat(timeout)) { | 329 | if (wdt_set_heartbeat(timeout)) { |
317 | wdt_set_heartbeat(WATCHDOG_TIMEOUT); | 330 | wdt_set_heartbeat(WATCHDOG_TIMEOUT); |
@@ -367,5 +380,5 @@ module_exit(wdt_exit); | |||
367 | 380 | ||
368 | MODULE_LICENSE("GPL"); | 381 | MODULE_LICENSE("GPL"); |
369 | MODULE_AUTHOR("Pádraig Brady <P@draigBrady.com>"); | 382 | MODULE_AUTHOR("Pádraig Brady <P@draigBrady.com>"); |
370 | MODULE_DESCRIPTION("w83627hf WDT driver"); | 383 | MODULE_DESCRIPTION("w83627hf/thf WDT driver"); |
371 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | 384 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index f4c634504d1a..e678a33ea672 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig | |||
@@ -56,4 +56,26 @@ config CRYPTO_DEV_GEODE | |||
56 | To compile this driver as a module, choose M here: the module | 56 | To compile this driver as a module, choose M here: the module |
57 | will be called geode-aes. | 57 | will be called geode-aes. |
58 | 58 | ||
59 | config ZCRYPT | ||
60 | tristate "Support for PCI-attached cryptographic adapters" | ||
61 | depends on S390 | ||
62 | select ZCRYPT_MONOLITHIC if ZCRYPT="y" | ||
63 | default "m" | ||
64 | help | ||
65 | Select this option if you want to use a PCI-attached cryptographic | ||
66 | adapter like: | ||
67 | + PCI Cryptographic Accelerator (PCICA) | ||
68 | + PCI Cryptographic Coprocessor (PCICC) | ||
69 | + PCI-X Cryptographic Coprocessor (PCIXCC) | ||
70 | + Crypto Express2 Coprocessor (CEX2C) | ||
71 | + Crypto Express2 Accelerator (CEX2A) | ||
72 | |||
73 | config ZCRYPT_MONOLITHIC | ||
74 | bool "Monolithic zcrypt module" | ||
75 | depends on ZCRYPT="m" | ||
76 | help | ||
77 | Select this option if you want to have a single module z90crypt.ko | ||
78 | that contains all parts of the crypto device driver (ap bus, | ||
79 | request router and all the card drivers). | ||
80 | |||
59 | endmenu | 81 | endmenu |
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 30d021d1a07c..72be6c63edfc 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "DMA Engine support" | 5 | menu "DMA Engine support" |
6 | depends on !S390 | ||
6 | 7 | ||
7 | config DMA_ENGINE | 8 | config DMA_ENGINE |
8 | bool "Support for DMA engines" | 9 | bool "Support for DMA engines" |
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index 4f0898400c6d..807c402df049 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig | |||
@@ -7,6 +7,7 @@ | |||
7 | # | 7 | # |
8 | 8 | ||
9 | menu 'EDAC - error detection and reporting (RAS) (EXPERIMENTAL)' | 9 | menu 'EDAC - error detection and reporting (RAS) (EXPERIMENTAL)' |
10 | depends on HAS_IOMEM | ||
10 | 11 | ||
11 | config EDAC | 12 | config EDAC |
12 | tristate "EDAC core system error reporting (EXPERIMENTAL)" | 13 | tristate "EDAC core system error reporting (EXPERIMENTAL)" |
diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig new file mode 100644 index 000000000000..5932c72f9e42 --- /dev/null +++ b/drivers/firewire/Kconfig | |||
@@ -0,0 +1,61 @@ | |||
1 | # -*- shell-script -*- | ||
2 | |||
3 | comment "An alternative FireWire stack is available with EXPERIMENTAL=y" | ||
4 | depends on EXPERIMENTAL=n | ||
5 | |||
6 | config FIREWIRE | ||
7 | tristate "IEEE 1394 (FireWire) support (JUJU alternative stack, experimental)" | ||
8 | depends on EXPERIMENTAL | ||
9 | select CRC_ITU_T | ||
10 | help | ||
11 | IEEE 1394 describes a high performance serial bus, which is also | ||
12 | known as FireWire(tm) or i.Link(tm) and is used for connecting all | ||
13 | sorts of devices (most notably digital video cameras) to your | ||
14 | computer. | ||
15 | |||
16 | If you have FireWire hardware and want to use it, say Y here. This | ||
17 | is the core support only, you will also need to select a driver for | ||
18 | your IEEE 1394 adapter. | ||
19 | |||
20 | To compile this driver as a module, say M here: the module will be | ||
21 | called fw-core. | ||
22 | |||
23 | This is the "JUJU" FireWire stack, an alternative implementation | ||
24 | designed for robustness and simplicity. You can build either this | ||
25 | stack, or the classic stack (the ieee1394 driver, ohci1394 etc.) | ||
26 | or both. | ||
27 | |||
28 | config FIREWIRE_OHCI | ||
29 | tristate "Support for OHCI FireWire host controllers" | ||
30 | depends on PCI && FIREWIRE | ||
31 | help | ||
32 | Enable this driver if you have a FireWire controller based | ||
33 | on the OHCI specification. For all practical purposes, this | ||
34 | is the only chipset in use, so say Y here. | ||
35 | |||
36 | To compile this driver as a module, say M here: The module will be | ||
37 | called fw-ohci. | ||
38 | |||
39 | If you also build ohci1394 of the classic IEEE 1394 driver stack, | ||
40 | blacklist either ohci1394 or fw-ohci to let hotplug load the desired | ||
41 | driver. | ||
42 | |||
43 | config FIREWIRE_SBP2 | ||
44 | tristate "Support for storage devices (SBP-2 protocol driver)" | ||
45 | depends on FIREWIRE && SCSI | ||
46 | help | ||
47 | This option enables you to use SBP-2 devices connected to a | ||
48 | FireWire bus. SBP-2 devices include storage devices like | ||
49 | harddisks and DVD drives, also some other FireWire devices | ||
50 | like scanners. | ||
51 | |||
52 | To compile this driver as a module, say M here: The module will be | ||
53 | called fw-sbp2. | ||
54 | |||
55 | You should also enable support for disks, CD-ROMs, etc. in the SCSI | ||
56 | configuration section. | ||
57 | |||
58 | If you also build sbp2 of the classic IEEE 1394 driver stack, | ||
59 | blacklist either sbp2 or fw-sbp2 to let hotplug load the desired | ||
60 | driver. | ||
61 | |||
diff --git a/drivers/firewire/Makefile b/drivers/firewire/Makefile new file mode 100644 index 000000000000..fc7d59d4bce0 --- /dev/null +++ b/drivers/firewire/Makefile | |||
@@ -0,0 +1,10 @@ | |||
1 | # | ||
2 | # Makefile for the Linux IEEE 1394 implementation | ||
3 | # | ||
4 | |||
5 | fw-core-y += fw-card.o fw-topology.o fw-transaction.o fw-iso.o \ | ||
6 | fw-device.o fw-cdev.o | ||
7 | |||
8 | obj-$(CONFIG_FIREWIRE) += fw-core.o | ||
9 | obj-$(CONFIG_FIREWIRE_OHCI) += fw-ohci.o | ||
10 | obj-$(CONFIG_FIREWIRE_SBP2) += fw-sbp2.o | ||
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c new file mode 100644 index 000000000000..636151a64add --- /dev/null +++ b/drivers/firewire/fw-card.c | |||
@@ -0,0 +1,560 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software Foundation, | ||
16 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/module.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/mutex.h> | ||
23 | #include <linux/crc-itu-t.h> | ||
24 | #include "fw-transaction.h" | ||
25 | #include "fw-topology.h" | ||
26 | #include "fw-device.h" | ||
27 | |||
28 | int fw_compute_block_crc(u32 *block) | ||
29 | { | ||
30 | __be32 be32_block[256]; | ||
31 | int i, length; | ||
32 | |||
33 | length = (*block >> 16) & 0xff; | ||
34 | for (i = 0; i < length; i++) | ||
35 | be32_block[i] = cpu_to_be32(block[i + 1]); | ||
36 | *block |= crc_itu_t(0, (u8 *) be32_block, length * 4); | ||
37 | |||
38 | return length; | ||
39 | } | ||
40 | |||
41 | static DEFINE_MUTEX(card_mutex); | ||
42 | static LIST_HEAD(card_list); | ||
43 | |||
44 | static LIST_HEAD(descriptor_list); | ||
45 | static int descriptor_count; | ||
46 | |||
47 | #define BIB_CRC(v) ((v) << 0) | ||
48 | #define BIB_CRC_LENGTH(v) ((v) << 16) | ||
49 | #define BIB_INFO_LENGTH(v) ((v) << 24) | ||
50 | |||
51 | #define BIB_LINK_SPEED(v) ((v) << 0) | ||
52 | #define BIB_GENERATION(v) ((v) << 4) | ||
53 | #define BIB_MAX_ROM(v) ((v) << 8) | ||
54 | #define BIB_MAX_RECEIVE(v) ((v) << 12) | ||
55 | #define BIB_CYC_CLK_ACC(v) ((v) << 16) | ||
56 | #define BIB_PMC ((1) << 27) | ||
57 | #define BIB_BMC ((1) << 28) | ||
58 | #define BIB_ISC ((1) << 29) | ||
59 | #define BIB_CMC ((1) << 30) | ||
60 | #define BIB_IMC ((1) << 31) | ||
61 | |||
62 | static u32 * | ||
63 | generate_config_rom(struct fw_card *card, size_t *config_rom_length) | ||
64 | { | ||
65 | struct fw_descriptor *desc; | ||
66 | static u32 config_rom[256]; | ||
67 | int i, j, length; | ||
68 | |||
69 | /* | ||
70 | * Initialize contents of config rom buffer. On the OHCI | ||
71 | * controller, block reads to the config rom accesses the host | ||
72 | * memory, but quadlet read access the hardware bus info block | ||
73 | * registers. That's just crack, but it means we should make | ||
74 | * sure the contents of bus info block in host memory mathces | ||
75 | * the version stored in the OHCI registers. | ||
76 | */ | ||
77 | |||
78 | memset(config_rom, 0, sizeof(config_rom)); | ||
79 | config_rom[0] = BIB_CRC_LENGTH(4) | BIB_INFO_LENGTH(4) | BIB_CRC(0); | ||
80 | config_rom[1] = 0x31333934; | ||
81 | |||
82 | config_rom[2] = | ||
83 | BIB_LINK_SPEED(card->link_speed) | | ||
84 | BIB_GENERATION(card->config_rom_generation++ % 14 + 2) | | ||
85 | BIB_MAX_ROM(2) | | ||
86 | BIB_MAX_RECEIVE(card->max_receive) | | ||
87 | BIB_BMC | BIB_ISC | BIB_CMC | BIB_IMC; | ||
88 | config_rom[3] = card->guid >> 32; | ||
89 | config_rom[4] = card->guid; | ||
90 | |||
91 | /* Generate root directory. */ | ||
92 | i = 5; | ||
93 | config_rom[i++] = 0; | ||
94 | config_rom[i++] = 0x0c0083c0; /* node capabilities */ | ||
95 | j = i + descriptor_count; | ||
96 | |||
97 | /* Generate root directory entries for descriptors. */ | ||
98 | list_for_each_entry (desc, &descriptor_list, link) { | ||
99 | if (desc->immediate > 0) | ||
100 | config_rom[i++] = desc->immediate; | ||
101 | config_rom[i] = desc->key | (j - i); | ||
102 | i++; | ||
103 | j += desc->length; | ||
104 | } | ||
105 | |||
106 | /* Update root directory length. */ | ||
107 | config_rom[5] = (i - 5 - 1) << 16; | ||
108 | |||
109 | /* End of root directory, now copy in descriptors. */ | ||
110 | list_for_each_entry (desc, &descriptor_list, link) { | ||
111 | memcpy(&config_rom[i], desc->data, desc->length * 4); | ||
112 | i += desc->length; | ||
113 | } | ||
114 | |||
115 | /* Calculate CRCs for all blocks in the config rom. This | ||
116 | * assumes that CRC length and info length are identical for | ||
117 | * the bus info block, which is always the case for this | ||
118 | * implementation. */ | ||
119 | for (i = 0; i < j; i += length + 1) | ||
120 | length = fw_compute_block_crc(config_rom + i); | ||
121 | |||
122 | *config_rom_length = j; | ||
123 | |||
124 | return config_rom; | ||
125 | } | ||
126 | |||
127 | static void | ||
128 | update_config_roms(void) | ||
129 | { | ||
130 | struct fw_card *card; | ||
131 | u32 *config_rom; | ||
132 | size_t length; | ||
133 | |||
134 | list_for_each_entry (card, &card_list, link) { | ||
135 | config_rom = generate_config_rom(card, &length); | ||
136 | card->driver->set_config_rom(card, config_rom, length); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | int | ||
141 | fw_core_add_descriptor(struct fw_descriptor *desc) | ||
142 | { | ||
143 | size_t i; | ||
144 | |||
145 | /* | ||
146 | * Check descriptor is valid; the length of all blocks in the | ||
147 | * descriptor has to add up to exactly the length of the | ||
148 | * block. | ||
149 | */ | ||
150 | i = 0; | ||
151 | while (i < desc->length) | ||
152 | i += (desc->data[i] >> 16) + 1; | ||
153 | |||
154 | if (i != desc->length) | ||
155 | return -EINVAL; | ||
156 | |||
157 | mutex_lock(&card_mutex); | ||
158 | |||
159 | list_add_tail(&desc->link, &descriptor_list); | ||
160 | descriptor_count++; | ||
161 | if (desc->immediate > 0) | ||
162 | descriptor_count++; | ||
163 | update_config_roms(); | ||
164 | |||
165 | mutex_unlock(&card_mutex); | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | EXPORT_SYMBOL(fw_core_add_descriptor); | ||
170 | |||
171 | void | ||
172 | fw_core_remove_descriptor(struct fw_descriptor *desc) | ||
173 | { | ||
174 | mutex_lock(&card_mutex); | ||
175 | |||
176 | list_del(&desc->link); | ||
177 | descriptor_count--; | ||
178 | if (desc->immediate > 0) | ||
179 | descriptor_count--; | ||
180 | update_config_roms(); | ||
181 | |||
182 | mutex_unlock(&card_mutex); | ||
183 | } | ||
184 | EXPORT_SYMBOL(fw_core_remove_descriptor); | ||
185 | |||
186 | static const char gap_count_table[] = { | ||
187 | 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 | ||
188 | }; | ||
189 | |||
190 | struct bm_data { | ||
191 | struct fw_transaction t; | ||
192 | struct { | ||
193 | __be32 arg; | ||
194 | __be32 data; | ||
195 | } lock; | ||
196 | u32 old; | ||
197 | int rcode; | ||
198 | struct completion done; | ||
199 | }; | ||
200 | |||
201 | static void | ||
202 | complete_bm_lock(struct fw_card *card, int rcode, | ||
203 | void *payload, size_t length, void *data) | ||
204 | { | ||
205 | struct bm_data *bmd = data; | ||
206 | |||
207 | if (rcode == RCODE_COMPLETE) | ||
208 | bmd->old = be32_to_cpu(*(__be32 *) payload); | ||
209 | bmd->rcode = rcode; | ||
210 | complete(&bmd->done); | ||
211 | } | ||
212 | |||
213 | static void | ||
214 | fw_card_bm_work(struct work_struct *work) | ||
215 | { | ||
216 | struct fw_card *card = container_of(work, struct fw_card, work.work); | ||
217 | struct fw_device *root; | ||
218 | struct bm_data bmd; | ||
219 | unsigned long flags; | ||
220 | int root_id, new_root_id, irm_id, gap_count, generation, grace; | ||
221 | int do_reset = 0; | ||
222 | |||
223 | spin_lock_irqsave(&card->lock, flags); | ||
224 | |||
225 | generation = card->generation; | ||
226 | root = card->root_node->data; | ||
227 | root_id = card->root_node->node_id; | ||
228 | grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); | ||
229 | |||
230 | if (card->bm_generation + 1 == generation || | ||
231 | (card->bm_generation != generation && grace)) { | ||
232 | /* | ||
233 | * This first step is to figure out who is IRM and | ||
234 | * then try to become bus manager. If the IRM is not | ||
235 | * well defined (e.g. does not have an active link | ||
236 | * layer or does not responds to our lock request, we | ||
237 | * will have to do a little vigilante bus management. | ||
238 | * In that case, we do a goto into the gap count logic | ||
239 | * so that when we do the reset, we still optimize the | ||
240 | * gap count. That could well save a reset in the | ||
241 | * next generation. | ||
242 | */ | ||
243 | |||
244 | irm_id = card->irm_node->node_id; | ||
245 | if (!card->irm_node->link_on) { | ||
246 | new_root_id = card->local_node->node_id; | ||
247 | fw_notify("IRM has link off, making local node (%02x) root.\n", | ||
248 | new_root_id); | ||
249 | goto pick_me; | ||
250 | } | ||
251 | |||
252 | bmd.lock.arg = cpu_to_be32(0x3f); | ||
253 | bmd.lock.data = cpu_to_be32(card->local_node->node_id); | ||
254 | |||
255 | spin_unlock_irqrestore(&card->lock, flags); | ||
256 | |||
257 | init_completion(&bmd.done); | ||
258 | fw_send_request(card, &bmd.t, TCODE_LOCK_COMPARE_SWAP, | ||
259 | irm_id, generation, | ||
260 | SCODE_100, CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, | ||
261 | &bmd.lock, sizeof(bmd.lock), | ||
262 | complete_bm_lock, &bmd); | ||
263 | wait_for_completion(&bmd.done); | ||
264 | |||
265 | if (bmd.rcode == RCODE_GENERATION) { | ||
266 | /* | ||
267 | * Another bus reset happened. Just return, | ||
268 | * the BM work has been rescheduled. | ||
269 | */ | ||
270 | return; | ||
271 | } | ||
272 | |||
273 | if (bmd.rcode == RCODE_COMPLETE && bmd.old != 0x3f) | ||
274 | /* Somebody else is BM, let them do the work. */ | ||
275 | return; | ||
276 | |||
277 | spin_lock_irqsave(&card->lock, flags); | ||
278 | if (bmd.rcode != RCODE_COMPLETE) { | ||
279 | /* | ||
280 | * The lock request failed, maybe the IRM | ||
281 | * isn't really IRM capable after all. Let's | ||
282 | * do a bus reset and pick the local node as | ||
283 | * root, and thus, IRM. | ||
284 | */ | ||
285 | new_root_id = card->local_node->node_id; | ||
286 | fw_notify("BM lock failed, making local node (%02x) root.\n", | ||
287 | new_root_id); | ||
288 | goto pick_me; | ||
289 | } | ||
290 | } else if (card->bm_generation != generation) { | ||
291 | /* | ||
292 | * OK, we weren't BM in the last generation, and it's | ||
293 | * less than 100ms since last bus reset. Reschedule | ||
294 | * this task 100ms from now. | ||
295 | */ | ||
296 | spin_unlock_irqrestore(&card->lock, flags); | ||
297 | schedule_delayed_work(&card->work, DIV_ROUND_UP(HZ, 10)); | ||
298 | return; | ||
299 | } | ||
300 | |||
301 | /* | ||
302 | * We're bus manager for this generation, so next step is to | ||
303 | * make sure we have an active cycle master and do gap count | ||
304 | * optimization. | ||
305 | */ | ||
306 | card->bm_generation = generation; | ||
307 | |||
308 | if (root == NULL) { | ||
309 | /* | ||
310 | * Either link_on is false, or we failed to read the | ||
311 | * config rom. In either case, pick another root. | ||
312 | */ | ||
313 | new_root_id = card->local_node->node_id; | ||
314 | } else if (atomic_read(&root->state) != FW_DEVICE_RUNNING) { | ||
315 | /* | ||
316 | * If we haven't probed this device yet, bail out now | ||
317 | * and let's try again once that's done. | ||
318 | */ | ||
319 | spin_unlock_irqrestore(&card->lock, flags); | ||
320 | return; | ||
321 | } else if (root->config_rom[2] & BIB_CMC) { | ||
322 | /* | ||
323 | * FIXME: I suppose we should set the cmstr bit in the | ||
324 | * STATE_CLEAR register of this node, as described in | ||
325 | * 1394-1995, 8.4.2.6. Also, send out a force root | ||
326 | * packet for this node. | ||
327 | */ | ||
328 | new_root_id = root_id; | ||
329 | } else { | ||
330 | /* | ||
331 | * Current root has an active link layer and we | ||
332 | * successfully read the config rom, but it's not | ||
333 | * cycle master capable. | ||
334 | */ | ||
335 | new_root_id = card->local_node->node_id; | ||
336 | } | ||
337 | |||
338 | pick_me: | ||
339 | /* Now figure out what gap count to set. */ | ||
340 | if (card->topology_type == FW_TOPOLOGY_A && | ||
341 | card->root_node->max_hops < ARRAY_SIZE(gap_count_table)) | ||
342 | gap_count = gap_count_table[card->root_node->max_hops]; | ||
343 | else | ||
344 | gap_count = 63; | ||
345 | |||
346 | /* | ||
347 | * Finally, figure out if we should do a reset or not. If we've | ||
348 | * done less that 5 resets with the same physical topology and we | ||
349 | * have either a new root or a new gap count setting, let's do it. | ||
350 | */ | ||
351 | |||
352 | if (card->bm_retries++ < 5 && | ||
353 | (card->gap_count != gap_count || new_root_id != root_id)) | ||
354 | do_reset = 1; | ||
355 | |||
356 | spin_unlock_irqrestore(&card->lock, flags); | ||
357 | |||
358 | if (do_reset) { | ||
359 | fw_notify("phy config: card %d, new root=%x, gap_count=%d\n", | ||
360 | card->index, new_root_id, gap_count); | ||
361 | fw_send_phy_config(card, new_root_id, generation, gap_count); | ||
362 | fw_core_initiate_bus_reset(card, 1); | ||
363 | } | ||
364 | } | ||
365 | |||
366 | static void | ||
367 | flush_timer_callback(unsigned long data) | ||
368 | { | ||
369 | struct fw_card *card = (struct fw_card *)data; | ||
370 | |||
371 | fw_flush_transactions(card); | ||
372 | } | ||
373 | |||
374 | void | ||
375 | fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, | ||
376 | struct device *device) | ||
377 | { | ||
378 | static atomic_t index = ATOMIC_INIT(-1); | ||
379 | |||
380 | kref_init(&card->kref); | ||
381 | card->index = atomic_inc_return(&index); | ||
382 | card->driver = driver; | ||
383 | card->device = device; | ||
384 | card->current_tlabel = 0; | ||
385 | card->tlabel_mask = 0; | ||
386 | card->color = 0; | ||
387 | |||
388 | INIT_LIST_HEAD(&card->transaction_list); | ||
389 | spin_lock_init(&card->lock); | ||
390 | setup_timer(&card->flush_timer, | ||
391 | flush_timer_callback, (unsigned long)card); | ||
392 | |||
393 | card->local_node = NULL; | ||
394 | |||
395 | INIT_DELAYED_WORK(&card->work, fw_card_bm_work); | ||
396 | } | ||
397 | EXPORT_SYMBOL(fw_card_initialize); | ||
398 | |||
399 | int | ||
400 | fw_card_add(struct fw_card *card, | ||
401 | u32 max_receive, u32 link_speed, u64 guid) | ||
402 | { | ||
403 | u32 *config_rom; | ||
404 | size_t length; | ||
405 | |||
406 | card->max_receive = max_receive; | ||
407 | card->link_speed = link_speed; | ||
408 | card->guid = guid; | ||
409 | |||
410 | /* Activate link_on bit and contender bit in our self ID packets.*/ | ||
411 | if (card->driver->update_phy_reg(card, 4, 0, | ||
412 | PHY_LINK_ACTIVE | PHY_CONTENDER) < 0) | ||
413 | return -EIO; | ||
414 | |||
415 | /* | ||
416 | * The subsystem grabs a reference when the card is added and | ||
417 | * drops it when the driver calls fw_core_remove_card. | ||
418 | */ | ||
419 | fw_card_get(card); | ||
420 | |||
421 | mutex_lock(&card_mutex); | ||
422 | config_rom = generate_config_rom(card, &length); | ||
423 | list_add_tail(&card->link, &card_list); | ||
424 | mutex_unlock(&card_mutex); | ||
425 | |||
426 | return card->driver->enable(card, config_rom, length); | ||
427 | } | ||
428 | EXPORT_SYMBOL(fw_card_add); | ||
429 | |||
430 | |||
431 | /* | ||
432 | * The next few functions implements a dummy driver that use once a | ||
433 | * card driver shuts down an fw_card. This allows the driver to | ||
434 | * cleanly unload, as all IO to the card will be handled by the dummy | ||
435 | * driver instead of calling into the (possibly) unloaded module. The | ||
436 | * dummy driver just fails all IO. | ||
437 | */ | ||
438 | |||
439 | static int | ||
440 | dummy_enable(struct fw_card *card, u32 *config_rom, size_t length) | ||
441 | { | ||
442 | BUG(); | ||
443 | return -1; | ||
444 | } | ||
445 | |||
446 | static int | ||
447 | dummy_update_phy_reg(struct fw_card *card, int address, | ||
448 | int clear_bits, int set_bits) | ||
449 | { | ||
450 | return -ENODEV; | ||
451 | } | ||
452 | |||
453 | static int | ||
454 | dummy_set_config_rom(struct fw_card *card, | ||
455 | u32 *config_rom, size_t length) | ||
456 | { | ||
457 | /* | ||
458 | * We take the card out of card_list before setting the dummy | ||
459 | * driver, so this should never get called. | ||
460 | */ | ||
461 | BUG(); | ||
462 | return -1; | ||
463 | } | ||
464 | |||
465 | static void | ||
466 | dummy_send_request(struct fw_card *card, struct fw_packet *packet) | ||
467 | { | ||
468 | packet->callback(packet, card, -ENODEV); | ||
469 | } | ||
470 | |||
471 | static void | ||
472 | dummy_send_response(struct fw_card *card, struct fw_packet *packet) | ||
473 | { | ||
474 | packet->callback(packet, card, -ENODEV); | ||
475 | } | ||
476 | |||
477 | static int | ||
478 | dummy_cancel_packet(struct fw_card *card, struct fw_packet *packet) | ||
479 | { | ||
480 | return -ENOENT; | ||
481 | } | ||
482 | |||
483 | static int | ||
484 | dummy_enable_phys_dma(struct fw_card *card, | ||
485 | int node_id, int generation) | ||
486 | { | ||
487 | return -ENODEV; | ||
488 | } | ||
489 | |||
490 | static struct fw_card_driver dummy_driver = { | ||
491 | .name = "dummy", | ||
492 | .enable = dummy_enable, | ||
493 | .update_phy_reg = dummy_update_phy_reg, | ||
494 | .set_config_rom = dummy_set_config_rom, | ||
495 | .send_request = dummy_send_request, | ||
496 | .cancel_packet = dummy_cancel_packet, | ||
497 | .send_response = dummy_send_response, | ||
498 | .enable_phys_dma = dummy_enable_phys_dma, | ||
499 | }; | ||
500 | |||
501 | void | ||
502 | fw_core_remove_card(struct fw_card *card) | ||
503 | { | ||
504 | card->driver->update_phy_reg(card, 4, | ||
505 | PHY_LINK_ACTIVE | PHY_CONTENDER, 0); | ||
506 | fw_core_initiate_bus_reset(card, 1); | ||
507 | |||
508 | mutex_lock(&card_mutex); | ||
509 | list_del(&card->link); | ||
510 | mutex_unlock(&card_mutex); | ||
511 | |||
512 | /* Set up the dummy driver. */ | ||
513 | card->driver = &dummy_driver; | ||
514 | |||
515 | fw_flush_transactions(card); | ||
516 | |||
517 | fw_destroy_nodes(card); | ||
518 | |||
519 | fw_card_put(card); | ||
520 | } | ||
521 | EXPORT_SYMBOL(fw_core_remove_card); | ||
522 | |||
523 | struct fw_card * | ||
524 | fw_card_get(struct fw_card *card) | ||
525 | { | ||
526 | kref_get(&card->kref); | ||
527 | |||
528 | return card; | ||
529 | } | ||
530 | EXPORT_SYMBOL(fw_card_get); | ||
531 | |||
532 | static void | ||
533 | release_card(struct kref *kref) | ||
534 | { | ||
535 | struct fw_card *card = container_of(kref, struct fw_card, kref); | ||
536 | |||
537 | kfree(card); | ||
538 | } | ||
539 | |||
540 | /* | ||
541 | * An assumption for fw_card_put() is that the card driver allocates | ||
542 | * the fw_card struct with kalloc and that it has been shut down | ||
543 | * before the last ref is dropped. | ||
544 | */ | ||
545 | void | ||
546 | fw_card_put(struct fw_card *card) | ||
547 | { | ||
548 | kref_put(&card->kref, release_card); | ||
549 | } | ||
550 | EXPORT_SYMBOL(fw_card_put); | ||
551 | |||
552 | int | ||
553 | fw_core_initiate_bus_reset(struct fw_card *card, int short_reset) | ||
554 | { | ||
555 | int reg = short_reset ? 5 : 1; | ||
556 | int bit = short_reset ? PHY_BUS_SHORT_RESET : PHY_BUS_RESET; | ||
557 | |||
558 | return card->driver->update_phy_reg(card, reg, 0, bit); | ||
559 | } | ||
560 | EXPORT_SYMBOL(fw_core_initiate_bus_reset); | ||
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c new file mode 100644 index 000000000000..0fa5bd54c6a1 --- /dev/null +++ b/drivers/firewire/fw-cdev.c | |||
@@ -0,0 +1,961 @@ | |||
1 | /* | ||
2 | * Char device for device raw access | ||
3 | * | ||
4 | * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/wait.h> | ||
24 | #include <linux/errno.h> | ||
25 | #include <linux/device.h> | ||
26 | #include <linux/vmalloc.h> | ||
27 | #include <linux/poll.h> | ||
28 | #include <linux/delay.h> | ||
29 | #include <linux/mm.h> | ||
30 | #include <linux/idr.h> | ||
31 | #include <linux/compat.h> | ||
32 | #include <linux/firewire-cdev.h> | ||
33 | #include <asm/uaccess.h> | ||
34 | #include "fw-transaction.h" | ||
35 | #include "fw-topology.h" | ||
36 | #include "fw-device.h" | ||
37 | |||
38 | struct client; | ||
39 | struct client_resource { | ||
40 | struct list_head link; | ||
41 | void (*release)(struct client *client, struct client_resource *r); | ||
42 | u32 handle; | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | * dequeue_event() just kfree()'s the event, so the event has to be | ||
47 | * the first field in the struct. | ||
48 | */ | ||
49 | |||
50 | struct event { | ||
51 | struct { void *data; size_t size; } v[2]; | ||
52 | struct list_head link; | ||
53 | }; | ||
54 | |||
55 | struct bus_reset { | ||
56 | struct event event; | ||
57 | struct fw_cdev_event_bus_reset reset; | ||
58 | }; | ||
59 | |||
60 | struct response { | ||
61 | struct event event; | ||
62 | struct fw_transaction transaction; | ||
63 | struct client *client; | ||
64 | struct client_resource resource; | ||
65 | struct fw_cdev_event_response response; | ||
66 | }; | ||
67 | |||
68 | struct iso_interrupt { | ||
69 | struct event event; | ||
70 | struct fw_cdev_event_iso_interrupt interrupt; | ||
71 | }; | ||
72 | |||
73 | struct client { | ||
74 | u32 version; | ||
75 | struct fw_device *device; | ||
76 | spinlock_t lock; | ||
77 | u32 resource_handle; | ||
78 | struct list_head resource_list; | ||
79 | struct list_head event_list; | ||
80 | wait_queue_head_t wait; | ||
81 | u64 bus_reset_closure; | ||
82 | |||
83 | struct fw_iso_context *iso_context; | ||
84 | u64 iso_closure; | ||
85 | struct fw_iso_buffer buffer; | ||
86 | unsigned long vm_start; | ||
87 | |||
88 | struct list_head link; | ||
89 | }; | ||
90 | |||
91 | static inline void __user * | ||
92 | u64_to_uptr(__u64 value) | ||
93 | { | ||
94 | return (void __user *)(unsigned long)value; | ||
95 | } | ||
96 | |||
97 | static inline __u64 | ||
98 | uptr_to_u64(void __user *ptr) | ||
99 | { | ||
100 | return (__u64)(unsigned long)ptr; | ||
101 | } | ||
102 | |||
103 | static int fw_device_op_open(struct inode *inode, struct file *file) | ||
104 | { | ||
105 | struct fw_device *device; | ||
106 | struct client *client; | ||
107 | unsigned long flags; | ||
108 | |||
109 | device = fw_device_from_devt(inode->i_rdev); | ||
110 | if (device == NULL) | ||
111 | return -ENODEV; | ||
112 | |||
113 | client = kzalloc(sizeof(*client), GFP_KERNEL); | ||
114 | if (client == NULL) | ||
115 | return -ENOMEM; | ||
116 | |||
117 | client->device = fw_device_get(device); | ||
118 | INIT_LIST_HEAD(&client->event_list); | ||
119 | INIT_LIST_HEAD(&client->resource_list); | ||
120 | spin_lock_init(&client->lock); | ||
121 | init_waitqueue_head(&client->wait); | ||
122 | |||
123 | file->private_data = client; | ||
124 | |||
125 | spin_lock_irqsave(&device->card->lock, flags); | ||
126 | list_add_tail(&client->link, &device->client_list); | ||
127 | spin_unlock_irqrestore(&device->card->lock, flags); | ||
128 | |||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | static void queue_event(struct client *client, struct event *event, | ||
133 | void *data0, size_t size0, void *data1, size_t size1) | ||
134 | { | ||
135 | unsigned long flags; | ||
136 | |||
137 | event->v[0].data = data0; | ||
138 | event->v[0].size = size0; | ||
139 | event->v[1].data = data1; | ||
140 | event->v[1].size = size1; | ||
141 | |||
142 | spin_lock_irqsave(&client->lock, flags); | ||
143 | |||
144 | list_add_tail(&event->link, &client->event_list); | ||
145 | wake_up_interruptible(&client->wait); | ||
146 | |||
147 | spin_unlock_irqrestore(&client->lock, flags); | ||
148 | } | ||
149 | |||
150 | static int | ||
151 | dequeue_event(struct client *client, char __user *buffer, size_t count) | ||
152 | { | ||
153 | unsigned long flags; | ||
154 | struct event *event; | ||
155 | size_t size, total; | ||
156 | int i, retval; | ||
157 | |||
158 | retval = wait_event_interruptible(client->wait, | ||
159 | !list_empty(&client->event_list) || | ||
160 | fw_device_is_shutdown(client->device)); | ||
161 | if (retval < 0) | ||
162 | return retval; | ||
163 | |||
164 | if (list_empty(&client->event_list) && | ||
165 | fw_device_is_shutdown(client->device)) | ||
166 | return -ENODEV; | ||
167 | |||
168 | spin_lock_irqsave(&client->lock, flags); | ||
169 | event = container_of(client->event_list.next, struct event, link); | ||
170 | list_del(&event->link); | ||
171 | spin_unlock_irqrestore(&client->lock, flags); | ||
172 | |||
173 | total = 0; | ||
174 | for (i = 0; i < ARRAY_SIZE(event->v) && total < count; i++) { | ||
175 | size = min(event->v[i].size, count - total); | ||
176 | if (copy_to_user(buffer + total, event->v[i].data, size)) { | ||
177 | retval = -EFAULT; | ||
178 | goto out; | ||
179 | } | ||
180 | total += size; | ||
181 | } | ||
182 | retval = total; | ||
183 | |||
184 | out: | ||
185 | kfree(event); | ||
186 | |||
187 | return retval; | ||
188 | } | ||
189 | |||
190 | static ssize_t | ||
191 | fw_device_op_read(struct file *file, | ||
192 | char __user *buffer, size_t count, loff_t *offset) | ||
193 | { | ||
194 | struct client *client = file->private_data; | ||
195 | |||
196 | return dequeue_event(client, buffer, count); | ||
197 | } | ||
198 | |||
199 | static void | ||
200 | fill_bus_reset_event(struct fw_cdev_event_bus_reset *event, | ||
201 | struct client *client) | ||
202 | { | ||
203 | struct fw_card *card = client->device->card; | ||
204 | |||
205 | event->closure = client->bus_reset_closure; | ||
206 | event->type = FW_CDEV_EVENT_BUS_RESET; | ||
207 | event->node_id = client->device->node_id; | ||
208 | event->local_node_id = card->local_node->node_id; | ||
209 | event->bm_node_id = 0; /* FIXME: We don't track the BM. */ | ||
210 | event->irm_node_id = card->irm_node->node_id; | ||
211 | event->root_node_id = card->root_node->node_id; | ||
212 | event->generation = card->generation; | ||
213 | } | ||
214 | |||
215 | static void | ||
216 | for_each_client(struct fw_device *device, | ||
217 | void (*callback)(struct client *client)) | ||
218 | { | ||
219 | struct fw_card *card = device->card; | ||
220 | struct client *c; | ||
221 | unsigned long flags; | ||
222 | |||
223 | spin_lock_irqsave(&card->lock, flags); | ||
224 | |||
225 | list_for_each_entry(c, &device->client_list, link) | ||
226 | callback(c); | ||
227 | |||
228 | spin_unlock_irqrestore(&card->lock, flags); | ||
229 | } | ||
230 | |||
231 | static void | ||
232 | queue_bus_reset_event(struct client *client) | ||
233 | { | ||
234 | struct bus_reset *bus_reset; | ||
235 | |||
236 | bus_reset = kzalloc(sizeof(*bus_reset), GFP_ATOMIC); | ||
237 | if (bus_reset == NULL) { | ||
238 | fw_notify("Out of memory when allocating bus reset event\n"); | ||
239 | return; | ||
240 | } | ||
241 | |||
242 | fill_bus_reset_event(&bus_reset->reset, client); | ||
243 | |||
244 | queue_event(client, &bus_reset->event, | ||
245 | &bus_reset->reset, sizeof(bus_reset->reset), NULL, 0); | ||
246 | } | ||
247 | |||
248 | void fw_device_cdev_update(struct fw_device *device) | ||
249 | { | ||
250 | for_each_client(device, queue_bus_reset_event); | ||
251 | } | ||
252 | |||
253 | static void wake_up_client(struct client *client) | ||
254 | { | ||
255 | wake_up_interruptible(&client->wait); | ||
256 | } | ||
257 | |||
258 | void fw_device_cdev_remove(struct fw_device *device) | ||
259 | { | ||
260 | for_each_client(device, wake_up_client); | ||
261 | } | ||
262 | |||
263 | static int ioctl_get_info(struct client *client, void *buffer) | ||
264 | { | ||
265 | struct fw_cdev_get_info *get_info = buffer; | ||
266 | struct fw_cdev_event_bus_reset bus_reset; | ||
267 | |||
268 | client->version = get_info->version; | ||
269 | get_info->version = FW_CDEV_VERSION; | ||
270 | |||
271 | if (get_info->rom != 0) { | ||
272 | void __user *uptr = u64_to_uptr(get_info->rom); | ||
273 | size_t want = get_info->rom_length; | ||
274 | size_t have = client->device->config_rom_length * 4; | ||
275 | |||
276 | if (copy_to_user(uptr, client->device->config_rom, | ||
277 | min(want, have))) | ||
278 | return -EFAULT; | ||
279 | } | ||
280 | get_info->rom_length = client->device->config_rom_length * 4; | ||
281 | |||
282 | client->bus_reset_closure = get_info->bus_reset_closure; | ||
283 | if (get_info->bus_reset != 0) { | ||
284 | void __user *uptr = u64_to_uptr(get_info->bus_reset); | ||
285 | |||
286 | fill_bus_reset_event(&bus_reset, client); | ||
287 | if (copy_to_user(uptr, &bus_reset, sizeof(bus_reset))) | ||
288 | return -EFAULT; | ||
289 | } | ||
290 | |||
291 | get_info->card = client->device->card->index; | ||
292 | |||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | static void | ||
297 | add_client_resource(struct client *client, struct client_resource *resource) | ||
298 | { | ||
299 | unsigned long flags; | ||
300 | |||
301 | spin_lock_irqsave(&client->lock, flags); | ||
302 | list_add_tail(&resource->link, &client->resource_list); | ||
303 | resource->handle = client->resource_handle++; | ||
304 | spin_unlock_irqrestore(&client->lock, flags); | ||
305 | } | ||
306 | |||
307 | static int | ||
308 | release_client_resource(struct client *client, u32 handle, | ||
309 | struct client_resource **resource) | ||
310 | { | ||
311 | struct client_resource *r; | ||
312 | unsigned long flags; | ||
313 | |||
314 | spin_lock_irqsave(&client->lock, flags); | ||
315 | list_for_each_entry(r, &client->resource_list, link) { | ||
316 | if (r->handle == handle) { | ||
317 | list_del(&r->link); | ||
318 | break; | ||
319 | } | ||
320 | } | ||
321 | spin_unlock_irqrestore(&client->lock, flags); | ||
322 | |||
323 | if (&r->link == &client->resource_list) | ||
324 | return -EINVAL; | ||
325 | |||
326 | if (resource) | ||
327 | *resource = r; | ||
328 | else | ||
329 | r->release(client, r); | ||
330 | |||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | static void | ||
335 | release_transaction(struct client *client, struct client_resource *resource) | ||
336 | { | ||
337 | struct response *response = | ||
338 | container_of(resource, struct response, resource); | ||
339 | |||
340 | fw_cancel_transaction(client->device->card, &response->transaction); | ||
341 | } | ||
342 | |||
343 | static void | ||
344 | complete_transaction(struct fw_card *card, int rcode, | ||
345 | void *payload, size_t length, void *data) | ||
346 | { | ||
347 | struct response *response = data; | ||
348 | struct client *client = response->client; | ||
349 | unsigned long flags; | ||
350 | |||
351 | if (length < response->response.length) | ||
352 | response->response.length = length; | ||
353 | if (rcode == RCODE_COMPLETE) | ||
354 | memcpy(response->response.data, payload, | ||
355 | response->response.length); | ||
356 | |||
357 | spin_lock_irqsave(&client->lock, flags); | ||
358 | list_del(&response->resource.link); | ||
359 | spin_unlock_irqrestore(&client->lock, flags); | ||
360 | |||
361 | response->response.type = FW_CDEV_EVENT_RESPONSE; | ||
362 | response->response.rcode = rcode; | ||
363 | queue_event(client, &response->event, | ||
364 | &response->response, sizeof(response->response), | ||
365 | response->response.data, response->response.length); | ||
366 | } | ||
367 | |||
368 | static ssize_t ioctl_send_request(struct client *client, void *buffer) | ||
369 | { | ||
370 | struct fw_device *device = client->device; | ||
371 | struct fw_cdev_send_request *request = buffer; | ||
372 | struct response *response; | ||
373 | |||
374 | /* What is the biggest size we'll accept, really? */ | ||
375 | if (request->length > 4096) | ||
376 | return -EINVAL; | ||
377 | |||
378 | response = kmalloc(sizeof(*response) + request->length, GFP_KERNEL); | ||
379 | if (response == NULL) | ||
380 | return -ENOMEM; | ||
381 | |||
382 | response->client = client; | ||
383 | response->response.length = request->length; | ||
384 | response->response.closure = request->closure; | ||
385 | |||
386 | if (request->data && | ||
387 | copy_from_user(response->response.data, | ||
388 | u64_to_uptr(request->data), request->length)) { | ||
389 | kfree(response); | ||
390 | return -EFAULT; | ||
391 | } | ||
392 | |||
393 | response->resource.release = release_transaction; | ||
394 | add_client_resource(client, &response->resource); | ||
395 | |||
396 | fw_send_request(device->card, &response->transaction, | ||
397 | request->tcode & 0x1f, | ||
398 | device->node->node_id, | ||
399 | request->generation, | ||
400 | device->node->max_speed, | ||
401 | request->offset, | ||
402 | response->response.data, request->length, | ||
403 | complete_transaction, response); | ||
404 | |||
405 | if (request->data) | ||
406 | return sizeof(request) + request->length; | ||
407 | else | ||
408 | return sizeof(request); | ||
409 | } | ||
410 | |||
411 | struct address_handler { | ||
412 | struct fw_address_handler handler; | ||
413 | __u64 closure; | ||
414 | struct client *client; | ||
415 | struct client_resource resource; | ||
416 | }; | ||
417 | |||
418 | struct request { | ||
419 | struct fw_request *request; | ||
420 | void *data; | ||
421 | size_t length; | ||
422 | struct client_resource resource; | ||
423 | }; | ||
424 | |||
425 | struct request_event { | ||
426 | struct event event; | ||
427 | struct fw_cdev_event_request request; | ||
428 | }; | ||
429 | |||
430 | static void | ||
431 | release_request(struct client *client, struct client_resource *resource) | ||
432 | { | ||
433 | struct request *request = | ||
434 | container_of(resource, struct request, resource); | ||
435 | |||
436 | fw_send_response(client->device->card, request->request, | ||
437 | RCODE_CONFLICT_ERROR); | ||
438 | kfree(request); | ||
439 | } | ||
440 | |||
441 | static void | ||
442 | handle_request(struct fw_card *card, struct fw_request *r, | ||
443 | int tcode, int destination, int source, | ||
444 | int generation, int speed, | ||
445 | unsigned long long offset, | ||
446 | void *payload, size_t length, void *callback_data) | ||
447 | { | ||
448 | struct address_handler *handler = callback_data; | ||
449 | struct request *request; | ||
450 | struct request_event *e; | ||
451 | struct client *client = handler->client; | ||
452 | |||
453 | request = kmalloc(sizeof(*request), GFP_ATOMIC); | ||
454 | e = kmalloc(sizeof(*e), GFP_ATOMIC); | ||
455 | if (request == NULL || e == NULL) { | ||
456 | kfree(request); | ||
457 | kfree(e); | ||
458 | fw_send_response(card, r, RCODE_CONFLICT_ERROR); | ||
459 | return; | ||
460 | } | ||
461 | |||
462 | request->request = r; | ||
463 | request->data = payload; | ||
464 | request->length = length; | ||
465 | |||
466 | request->resource.release = release_request; | ||
467 | add_client_resource(client, &request->resource); | ||
468 | |||
469 | e->request.type = FW_CDEV_EVENT_REQUEST; | ||
470 | e->request.tcode = tcode; | ||
471 | e->request.offset = offset; | ||
472 | e->request.length = length; | ||
473 | e->request.handle = request->resource.handle; | ||
474 | e->request.closure = handler->closure; | ||
475 | |||
476 | queue_event(client, &e->event, | ||
477 | &e->request, sizeof(e->request), payload, length); | ||
478 | } | ||
479 | |||
480 | static void | ||
481 | release_address_handler(struct client *client, | ||
482 | struct client_resource *resource) | ||
483 | { | ||
484 | struct address_handler *handler = | ||
485 | container_of(resource, struct address_handler, resource); | ||
486 | |||
487 | fw_core_remove_address_handler(&handler->handler); | ||
488 | kfree(handler); | ||
489 | } | ||
490 | |||
491 | static int ioctl_allocate(struct client *client, void *buffer) | ||
492 | { | ||
493 | struct fw_cdev_allocate *request = buffer; | ||
494 | struct address_handler *handler; | ||
495 | struct fw_address_region region; | ||
496 | |||
497 | handler = kmalloc(sizeof(*handler), GFP_KERNEL); | ||
498 | if (handler == NULL) | ||
499 | return -ENOMEM; | ||
500 | |||
501 | region.start = request->offset; | ||
502 | region.end = request->offset + request->length; | ||
503 | handler->handler.length = request->length; | ||
504 | handler->handler.address_callback = handle_request; | ||
505 | handler->handler.callback_data = handler; | ||
506 | handler->closure = request->closure; | ||
507 | handler->client = client; | ||
508 | |||
509 | if (fw_core_add_address_handler(&handler->handler, ®ion) < 0) { | ||
510 | kfree(handler); | ||
511 | return -EBUSY; | ||
512 | } | ||
513 | |||
514 | handler->resource.release = release_address_handler; | ||
515 | add_client_resource(client, &handler->resource); | ||
516 | request->handle = handler->resource.handle; | ||
517 | |||
518 | return 0; | ||
519 | } | ||
520 | |||
521 | static int ioctl_deallocate(struct client *client, void *buffer) | ||
522 | { | ||
523 | struct fw_cdev_deallocate *request = buffer; | ||
524 | |||
525 | return release_client_resource(client, request->handle, NULL); | ||
526 | } | ||
527 | |||
528 | static int ioctl_send_response(struct client *client, void *buffer) | ||
529 | { | ||
530 | struct fw_cdev_send_response *request = buffer; | ||
531 | struct client_resource *resource; | ||
532 | struct request *r; | ||
533 | |||
534 | if (release_client_resource(client, request->handle, &resource) < 0) | ||
535 | return -EINVAL; | ||
536 | r = container_of(resource, struct request, resource); | ||
537 | if (request->length < r->length) | ||
538 | r->length = request->length; | ||
539 | if (copy_from_user(r->data, u64_to_uptr(request->data), r->length)) | ||
540 | return -EFAULT; | ||
541 | |||
542 | fw_send_response(client->device->card, r->request, request->rcode); | ||
543 | kfree(r); | ||
544 | |||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | static int ioctl_initiate_bus_reset(struct client *client, void *buffer) | ||
549 | { | ||
550 | struct fw_cdev_initiate_bus_reset *request = buffer; | ||
551 | int short_reset; | ||
552 | |||
553 | short_reset = (request->type == FW_CDEV_SHORT_RESET); | ||
554 | |||
555 | return fw_core_initiate_bus_reset(client->device->card, short_reset); | ||
556 | } | ||
557 | |||
558 | struct descriptor { | ||
559 | struct fw_descriptor d; | ||
560 | struct client_resource resource; | ||
561 | u32 data[0]; | ||
562 | }; | ||
563 | |||
564 | static void release_descriptor(struct client *client, | ||
565 | struct client_resource *resource) | ||
566 | { | ||
567 | struct descriptor *descriptor = | ||
568 | container_of(resource, struct descriptor, resource); | ||
569 | |||
570 | fw_core_remove_descriptor(&descriptor->d); | ||
571 | kfree(descriptor); | ||
572 | } | ||
573 | |||
574 | static int ioctl_add_descriptor(struct client *client, void *buffer) | ||
575 | { | ||
576 | struct fw_cdev_add_descriptor *request = buffer; | ||
577 | struct descriptor *descriptor; | ||
578 | int retval; | ||
579 | |||
580 | if (request->length > 256) | ||
581 | return -EINVAL; | ||
582 | |||
583 | descriptor = | ||
584 | kmalloc(sizeof(*descriptor) + request->length * 4, GFP_KERNEL); | ||
585 | if (descriptor == NULL) | ||
586 | return -ENOMEM; | ||
587 | |||
588 | if (copy_from_user(descriptor->data, | ||
589 | u64_to_uptr(request->data), request->length * 4)) { | ||
590 | kfree(descriptor); | ||
591 | return -EFAULT; | ||
592 | } | ||
593 | |||
594 | descriptor->d.length = request->length; | ||
595 | descriptor->d.immediate = request->immediate; | ||
596 | descriptor->d.key = request->key; | ||
597 | descriptor->d.data = descriptor->data; | ||
598 | |||
599 | retval = fw_core_add_descriptor(&descriptor->d); | ||
600 | if (retval < 0) { | ||
601 | kfree(descriptor); | ||
602 | return retval; | ||
603 | } | ||
604 | |||
605 | descriptor->resource.release = release_descriptor; | ||
606 | add_client_resource(client, &descriptor->resource); | ||
607 | request->handle = descriptor->resource.handle; | ||
608 | |||
609 | return 0; | ||
610 | } | ||
611 | |||
612 | static int ioctl_remove_descriptor(struct client *client, void *buffer) | ||
613 | { | ||
614 | struct fw_cdev_remove_descriptor *request = buffer; | ||
615 | |||
616 | return release_client_resource(client, request->handle, NULL); | ||
617 | } | ||
618 | |||
619 | static void | ||
620 | iso_callback(struct fw_iso_context *context, u32 cycle, | ||
621 | size_t header_length, void *header, void *data) | ||
622 | { | ||
623 | struct client *client = data; | ||
624 | struct iso_interrupt *interrupt; | ||
625 | |||
626 | interrupt = kzalloc(sizeof(*interrupt) + header_length, GFP_ATOMIC); | ||
627 | if (interrupt == NULL) | ||
628 | return; | ||
629 | |||
630 | interrupt->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT; | ||
631 | interrupt->interrupt.closure = client->iso_closure; | ||
632 | interrupt->interrupt.cycle = cycle; | ||
633 | interrupt->interrupt.header_length = header_length; | ||
634 | memcpy(interrupt->interrupt.header, header, header_length); | ||
635 | queue_event(client, &interrupt->event, | ||
636 | &interrupt->interrupt, | ||
637 | sizeof(interrupt->interrupt) + header_length, NULL, 0); | ||
638 | } | ||
639 | |||
640 | static int ioctl_create_iso_context(struct client *client, void *buffer) | ||
641 | { | ||
642 | struct fw_cdev_create_iso_context *request = buffer; | ||
643 | |||
644 | if (request->channel > 63) | ||
645 | return -EINVAL; | ||
646 | |||
647 | switch (request->type) { | ||
648 | case FW_ISO_CONTEXT_RECEIVE: | ||
649 | if (request->header_size < 4 || (request->header_size & 3)) | ||
650 | return -EINVAL; | ||
651 | |||
652 | break; | ||
653 | |||
654 | case FW_ISO_CONTEXT_TRANSMIT: | ||
655 | if (request->speed > SCODE_3200) | ||
656 | return -EINVAL; | ||
657 | |||
658 | break; | ||
659 | |||
660 | default: | ||
661 | return -EINVAL; | ||
662 | } | ||
663 | |||
664 | client->iso_closure = request->closure; | ||
665 | client->iso_context = fw_iso_context_create(client->device->card, | ||
666 | request->type, | ||
667 | request->channel, | ||
668 | request->speed, | ||
669 | request->header_size, | ||
670 | iso_callback, client); | ||
671 | if (IS_ERR(client->iso_context)) | ||
672 | return PTR_ERR(client->iso_context); | ||
673 | |||
674 | /* We only support one context at this time. */ | ||
675 | request->handle = 0; | ||
676 | |||
677 | return 0; | ||
678 | } | ||
679 | |||
680 | static int ioctl_queue_iso(struct client *client, void *buffer) | ||
681 | { | ||
682 | struct fw_cdev_queue_iso *request = buffer; | ||
683 | struct fw_cdev_iso_packet __user *p, *end, *next; | ||
684 | struct fw_iso_context *ctx = client->iso_context; | ||
685 | unsigned long payload, buffer_end, header_length; | ||
686 | int count; | ||
687 | struct { | ||
688 | struct fw_iso_packet packet; | ||
689 | u8 header[256]; | ||
690 | } u; | ||
691 | |||
692 | if (ctx == NULL || request->handle != 0) | ||
693 | return -EINVAL; | ||
694 | |||
695 | /* | ||
696 | * If the user passes a non-NULL data pointer, has mmap()'ed | ||
697 | * the iso buffer, and the pointer points inside the buffer, | ||
698 | * we setup the payload pointers accordingly. Otherwise we | ||
699 | * set them both to 0, which will still let packets with | ||
700 | * payload_length == 0 through. In other words, if no packets | ||
701 | * use the indirect payload, the iso buffer need not be mapped | ||
702 | * and the request->data pointer is ignored. | ||
703 | */ | ||
704 | |||
705 | payload = (unsigned long)request->data - client->vm_start; | ||
706 | buffer_end = client->buffer.page_count << PAGE_SHIFT; | ||
707 | if (request->data == 0 || client->buffer.pages == NULL || | ||
708 | payload >= buffer_end) { | ||
709 | payload = 0; | ||
710 | buffer_end = 0; | ||
711 | } | ||
712 | |||
713 | if (!access_ok(VERIFY_READ, request->packets, request->size)) | ||
714 | return -EFAULT; | ||
715 | |||
716 | p = (struct fw_cdev_iso_packet __user *)u64_to_uptr(request->packets); | ||
717 | end = (void __user *)p + request->size; | ||
718 | count = 0; | ||
719 | while (p < end) { | ||
720 | if (__copy_from_user(&u.packet, p, sizeof(*p))) | ||
721 | return -EFAULT; | ||
722 | |||
723 | if (ctx->type == FW_ISO_CONTEXT_TRANSMIT) { | ||
724 | header_length = u.packet.header_length; | ||
725 | } else { | ||
726 | /* | ||
727 | * We require that header_length is a multiple of | ||
728 | * the fixed header size, ctx->header_size. | ||
729 | */ | ||
730 | if (ctx->header_size == 0) { | ||
731 | if (u.packet.header_length > 0) | ||
732 | return -EINVAL; | ||
733 | } else if (u.packet.header_length % ctx->header_size != 0) { | ||
734 | return -EINVAL; | ||
735 | } | ||
736 | header_length = 0; | ||
737 | } | ||
738 | |||
739 | next = (struct fw_cdev_iso_packet __user *) | ||
740 | &p->header[header_length / 4]; | ||
741 | if (next > end) | ||
742 | return -EINVAL; | ||
743 | if (__copy_from_user | ||
744 | (u.packet.header, p->header, header_length)) | ||
745 | return -EFAULT; | ||
746 | if (u.packet.skip && ctx->type == FW_ISO_CONTEXT_TRANSMIT && | ||
747 | u.packet.header_length + u.packet.payload_length > 0) | ||
748 | return -EINVAL; | ||
749 | if (payload + u.packet.payload_length > buffer_end) | ||
750 | return -EINVAL; | ||
751 | |||
752 | if (fw_iso_context_queue(ctx, &u.packet, | ||
753 | &client->buffer, payload)) | ||
754 | break; | ||
755 | |||
756 | p = next; | ||
757 | payload += u.packet.payload_length; | ||
758 | count++; | ||
759 | } | ||
760 | |||
761 | request->size -= uptr_to_u64(p) - request->packets; | ||
762 | request->packets = uptr_to_u64(p); | ||
763 | request->data = client->vm_start + payload; | ||
764 | |||
765 | return count; | ||
766 | } | ||
767 | |||
768 | static int ioctl_start_iso(struct client *client, void *buffer) | ||
769 | { | ||
770 | struct fw_cdev_start_iso *request = buffer; | ||
771 | |||
772 | if (request->handle != 0) | ||
773 | return -EINVAL; | ||
774 | if (client->iso_context->type == FW_ISO_CONTEXT_RECEIVE) { | ||
775 | if (request->tags == 0 || request->tags > 15) | ||
776 | return -EINVAL; | ||
777 | |||
778 | if (request->sync > 15) | ||
779 | return -EINVAL; | ||
780 | } | ||
781 | |||
782 | return fw_iso_context_start(client->iso_context, request->cycle, | ||
783 | request->sync, request->tags); | ||
784 | } | ||
785 | |||
786 | static int ioctl_stop_iso(struct client *client, void *buffer) | ||
787 | { | ||
788 | struct fw_cdev_stop_iso *request = buffer; | ||
789 | |||
790 | if (request->handle != 0) | ||
791 | return -EINVAL; | ||
792 | |||
793 | return fw_iso_context_stop(client->iso_context); | ||
794 | } | ||
795 | |||
796 | static int (* const ioctl_handlers[])(struct client *client, void *buffer) = { | ||
797 | ioctl_get_info, | ||
798 | ioctl_send_request, | ||
799 | ioctl_allocate, | ||
800 | ioctl_deallocate, | ||
801 | ioctl_send_response, | ||
802 | ioctl_initiate_bus_reset, | ||
803 | ioctl_add_descriptor, | ||
804 | ioctl_remove_descriptor, | ||
805 | ioctl_create_iso_context, | ||
806 | ioctl_queue_iso, | ||
807 | ioctl_start_iso, | ||
808 | ioctl_stop_iso, | ||
809 | }; | ||
810 | |||
811 | static int | ||
812 | dispatch_ioctl(struct client *client, unsigned int cmd, void __user *arg) | ||
813 | { | ||
814 | char buffer[256]; | ||
815 | int retval; | ||
816 | |||
817 | if (_IOC_TYPE(cmd) != '#' || | ||
818 | _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers)) | ||
819 | return -EINVAL; | ||
820 | |||
821 | if (_IOC_DIR(cmd) & _IOC_WRITE) { | ||
822 | if (_IOC_SIZE(cmd) > sizeof(buffer) || | ||
823 | copy_from_user(buffer, arg, _IOC_SIZE(cmd))) | ||
824 | return -EFAULT; | ||
825 | } | ||
826 | |||
827 | retval = ioctl_handlers[_IOC_NR(cmd)](client, buffer); | ||
828 | if (retval < 0) | ||
829 | return retval; | ||
830 | |||
831 | if (_IOC_DIR(cmd) & _IOC_READ) { | ||
832 | if (_IOC_SIZE(cmd) > sizeof(buffer) || | ||
833 | copy_to_user(arg, buffer, _IOC_SIZE(cmd))) | ||
834 | return -EFAULT; | ||
835 | } | ||
836 | |||
837 | return 0; | ||
838 | } | ||
839 | |||
840 | static long | ||
841 | fw_device_op_ioctl(struct file *file, | ||
842 | unsigned int cmd, unsigned long arg) | ||
843 | { | ||
844 | struct client *client = file->private_data; | ||
845 | |||
846 | return dispatch_ioctl(client, cmd, (void __user *) arg); | ||
847 | } | ||
848 | |||
849 | #ifdef CONFIG_COMPAT | ||
850 | static long | ||
851 | fw_device_op_compat_ioctl(struct file *file, | ||
852 | unsigned int cmd, unsigned long arg) | ||
853 | { | ||
854 | struct client *client = file->private_data; | ||
855 | |||
856 | return dispatch_ioctl(client, cmd, compat_ptr(arg)); | ||
857 | } | ||
858 | #endif | ||
859 | |||
860 | static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) | ||
861 | { | ||
862 | struct client *client = file->private_data; | ||
863 | enum dma_data_direction direction; | ||
864 | unsigned long size; | ||
865 | int page_count, retval; | ||
866 | |||
867 | /* FIXME: We could support multiple buffers, but we don't. */ | ||
868 | if (client->buffer.pages != NULL) | ||
869 | return -EBUSY; | ||
870 | |||
871 | if (!(vma->vm_flags & VM_SHARED)) | ||
872 | return -EINVAL; | ||
873 | |||
874 | if (vma->vm_start & ~PAGE_MASK) | ||
875 | return -EINVAL; | ||
876 | |||
877 | client->vm_start = vma->vm_start; | ||
878 | size = vma->vm_end - vma->vm_start; | ||
879 | page_count = size >> PAGE_SHIFT; | ||
880 | if (size & ~PAGE_MASK) | ||
881 | return -EINVAL; | ||
882 | |||
883 | if (vma->vm_flags & VM_WRITE) | ||
884 | direction = DMA_TO_DEVICE; | ||
885 | else | ||
886 | direction = DMA_FROM_DEVICE; | ||
887 | |||
888 | retval = fw_iso_buffer_init(&client->buffer, client->device->card, | ||
889 | page_count, direction); | ||
890 | if (retval < 0) | ||
891 | return retval; | ||
892 | |||
893 | retval = fw_iso_buffer_map(&client->buffer, vma); | ||
894 | if (retval < 0) | ||
895 | fw_iso_buffer_destroy(&client->buffer, client->device->card); | ||
896 | |||
897 | return retval; | ||
898 | } | ||
899 | |||
900 | static int fw_device_op_release(struct inode *inode, struct file *file) | ||
901 | { | ||
902 | struct client *client = file->private_data; | ||
903 | struct event *e, *next_e; | ||
904 | struct client_resource *r, *next_r; | ||
905 | unsigned long flags; | ||
906 | |||
907 | if (client->buffer.pages) | ||
908 | fw_iso_buffer_destroy(&client->buffer, client->device->card); | ||
909 | |||
910 | if (client->iso_context) | ||
911 | fw_iso_context_destroy(client->iso_context); | ||
912 | |||
913 | list_for_each_entry_safe(r, next_r, &client->resource_list, link) | ||
914 | r->release(client, r); | ||
915 | |||
916 | /* | ||
917 | * FIXME: We should wait for the async tasklets to stop | ||
918 | * running before freeing the memory. | ||
919 | */ | ||
920 | |||
921 | list_for_each_entry_safe(e, next_e, &client->event_list, link) | ||
922 | kfree(e); | ||
923 | |||
924 | spin_lock_irqsave(&client->device->card->lock, flags); | ||
925 | list_del(&client->link); | ||
926 | spin_unlock_irqrestore(&client->device->card->lock, flags); | ||
927 | |||
928 | fw_device_put(client->device); | ||
929 | kfree(client); | ||
930 | |||
931 | return 0; | ||
932 | } | ||
933 | |||
934 | static unsigned int fw_device_op_poll(struct file *file, poll_table * pt) | ||
935 | { | ||
936 | struct client *client = file->private_data; | ||
937 | unsigned int mask = 0; | ||
938 | |||
939 | poll_wait(file, &client->wait, pt); | ||
940 | |||
941 | if (fw_device_is_shutdown(client->device)) | ||
942 | mask |= POLLHUP | POLLERR; | ||
943 | if (!list_empty(&client->event_list)) | ||
944 | mask |= POLLIN | POLLRDNORM; | ||
945 | |||
946 | return mask; | ||
947 | } | ||
948 | |||
949 | const struct file_operations fw_device_ops = { | ||
950 | .owner = THIS_MODULE, | ||
951 | .open = fw_device_op_open, | ||
952 | .read = fw_device_op_read, | ||
953 | .unlocked_ioctl = fw_device_op_ioctl, | ||
954 | .poll = fw_device_op_poll, | ||
955 | .release = fw_device_op_release, | ||
956 | .mmap = fw_device_op_mmap, | ||
957 | |||
958 | #ifdef CONFIG_COMPAT | ||
959 | .compat_ioctl = fw_device_op_compat_ioctl, | ||
960 | #endif | ||
961 | }; | ||
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c new file mode 100644 index 000000000000..c1ce465d9710 --- /dev/null +++ b/drivers/firewire/fw-device.c | |||
@@ -0,0 +1,813 @@ | |||
1 | /* | ||
2 | * Device probing and sysfs code. | ||
3 | * | ||
4 | * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/wait.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include <linux/kthread.h> | ||
25 | #include <linux/device.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/idr.h> | ||
28 | #include <linux/rwsem.h> | ||
29 | #include <asm/semaphore.h> | ||
30 | #include <linux/ctype.h> | ||
31 | #include "fw-transaction.h" | ||
32 | #include "fw-topology.h" | ||
33 | #include "fw-device.h" | ||
34 | |||
35 | void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 * p) | ||
36 | { | ||
37 | ci->p = p + 1; | ||
38 | ci->end = ci->p + (p[0] >> 16); | ||
39 | } | ||
40 | EXPORT_SYMBOL(fw_csr_iterator_init); | ||
41 | |||
42 | int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value) | ||
43 | { | ||
44 | *key = *ci->p >> 24; | ||
45 | *value = *ci->p & 0xffffff; | ||
46 | |||
47 | return ci->p++ < ci->end; | ||
48 | } | ||
49 | EXPORT_SYMBOL(fw_csr_iterator_next); | ||
50 | |||
51 | static int is_fw_unit(struct device *dev); | ||
52 | |||
53 | static int match_unit_directory(u32 * directory, const struct fw_device_id *id) | ||
54 | { | ||
55 | struct fw_csr_iterator ci; | ||
56 | int key, value, match; | ||
57 | |||
58 | match = 0; | ||
59 | fw_csr_iterator_init(&ci, directory); | ||
60 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
61 | if (key == CSR_VENDOR && value == id->vendor) | ||
62 | match |= FW_MATCH_VENDOR; | ||
63 | if (key == CSR_MODEL && value == id->model) | ||
64 | match |= FW_MATCH_MODEL; | ||
65 | if (key == CSR_SPECIFIER_ID && value == id->specifier_id) | ||
66 | match |= FW_MATCH_SPECIFIER_ID; | ||
67 | if (key == CSR_VERSION && value == id->version) | ||
68 | match |= FW_MATCH_VERSION; | ||
69 | } | ||
70 | |||
71 | return (match & id->match_flags) == id->match_flags; | ||
72 | } | ||
73 | |||
74 | static int fw_unit_match(struct device *dev, struct device_driver *drv) | ||
75 | { | ||
76 | struct fw_unit *unit = fw_unit(dev); | ||
77 | struct fw_driver *driver = fw_driver(drv); | ||
78 | int i; | ||
79 | |||
80 | /* We only allow binding to fw_units. */ | ||
81 | if (!is_fw_unit(dev)) | ||
82 | return 0; | ||
83 | |||
84 | for (i = 0; driver->id_table[i].match_flags != 0; i++) { | ||
85 | if (match_unit_directory(unit->directory, &driver->id_table[i])) | ||
86 | return 1; | ||
87 | } | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) | ||
93 | { | ||
94 | struct fw_device *device = fw_device(unit->device.parent); | ||
95 | struct fw_csr_iterator ci; | ||
96 | |||
97 | int key, value; | ||
98 | int vendor = 0; | ||
99 | int model = 0; | ||
100 | int specifier_id = 0; | ||
101 | int version = 0; | ||
102 | |||
103 | fw_csr_iterator_init(&ci, &device->config_rom[5]); | ||
104 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
105 | switch (key) { | ||
106 | case CSR_VENDOR: | ||
107 | vendor = value; | ||
108 | break; | ||
109 | case CSR_MODEL: | ||
110 | model = value; | ||
111 | break; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | fw_csr_iterator_init(&ci, unit->directory); | ||
116 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
117 | switch (key) { | ||
118 | case CSR_SPECIFIER_ID: | ||
119 | specifier_id = value; | ||
120 | break; | ||
121 | case CSR_VERSION: | ||
122 | version = value; | ||
123 | break; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | return snprintf(buffer, buffer_size, | ||
128 | "ieee1394:ven%08Xmo%08Xsp%08Xver%08X", | ||
129 | vendor, model, specifier_id, version); | ||
130 | } | ||
131 | |||
132 | static int | ||
133 | fw_unit_uevent(struct device *dev, char **envp, int num_envp, | ||
134 | char *buffer, int buffer_size) | ||
135 | { | ||
136 | struct fw_unit *unit = fw_unit(dev); | ||
137 | char modalias[64]; | ||
138 | int length = 0; | ||
139 | int i = 0; | ||
140 | |||
141 | get_modalias(unit, modalias, sizeof(modalias)); | ||
142 | |||
143 | if (add_uevent_var(envp, num_envp, &i, | ||
144 | buffer, buffer_size, &length, | ||
145 | "MODALIAS=%s", modalias)) | ||
146 | return -ENOMEM; | ||
147 | |||
148 | envp[i] = NULL; | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | struct bus_type fw_bus_type = { | ||
154 | .name = "firewire", | ||
155 | .match = fw_unit_match, | ||
156 | }; | ||
157 | EXPORT_SYMBOL(fw_bus_type); | ||
158 | |||
159 | struct fw_device *fw_device_get(struct fw_device *device) | ||
160 | { | ||
161 | get_device(&device->device); | ||
162 | |||
163 | return device; | ||
164 | } | ||
165 | |||
166 | void fw_device_put(struct fw_device *device) | ||
167 | { | ||
168 | put_device(&device->device); | ||
169 | } | ||
170 | |||
171 | static void fw_device_release(struct device *dev) | ||
172 | { | ||
173 | struct fw_device *device = fw_device(dev); | ||
174 | unsigned long flags; | ||
175 | |||
176 | /* | ||
177 | * Take the card lock so we don't set this to NULL while a | ||
178 | * FW_NODE_UPDATED callback is being handled. | ||
179 | */ | ||
180 | spin_lock_irqsave(&device->card->lock, flags); | ||
181 | device->node->data = NULL; | ||
182 | spin_unlock_irqrestore(&device->card->lock, flags); | ||
183 | |||
184 | fw_node_put(device->node); | ||
185 | fw_card_put(device->card); | ||
186 | kfree(device->config_rom); | ||
187 | kfree(device); | ||
188 | } | ||
189 | |||
190 | int fw_device_enable_phys_dma(struct fw_device *device) | ||
191 | { | ||
192 | return device->card->driver->enable_phys_dma(device->card, | ||
193 | device->node_id, | ||
194 | device->generation); | ||
195 | } | ||
196 | EXPORT_SYMBOL(fw_device_enable_phys_dma); | ||
197 | |||
198 | struct config_rom_attribute { | ||
199 | struct device_attribute attr; | ||
200 | u32 key; | ||
201 | }; | ||
202 | |||
203 | static ssize_t | ||
204 | show_immediate(struct device *dev, struct device_attribute *dattr, char *buf) | ||
205 | { | ||
206 | struct config_rom_attribute *attr = | ||
207 | container_of(dattr, struct config_rom_attribute, attr); | ||
208 | struct fw_csr_iterator ci; | ||
209 | u32 *dir; | ||
210 | int key, value; | ||
211 | |||
212 | if (is_fw_unit(dev)) | ||
213 | dir = fw_unit(dev)->directory; | ||
214 | else | ||
215 | dir = fw_device(dev)->config_rom + 5; | ||
216 | |||
217 | fw_csr_iterator_init(&ci, dir); | ||
218 | while (fw_csr_iterator_next(&ci, &key, &value)) | ||
219 | if (attr->key == key) | ||
220 | return snprintf(buf, buf ? PAGE_SIZE : 0, | ||
221 | "0x%06x\n", value); | ||
222 | |||
223 | return -ENOENT; | ||
224 | } | ||
225 | |||
226 | #define IMMEDIATE_ATTR(name, key) \ | ||
227 | { __ATTR(name, S_IRUGO, show_immediate, NULL), key } | ||
228 | |||
229 | static ssize_t | ||
230 | show_text_leaf(struct device *dev, struct device_attribute *dattr, char *buf) | ||
231 | { | ||
232 | struct config_rom_attribute *attr = | ||
233 | container_of(dattr, struct config_rom_attribute, attr); | ||
234 | struct fw_csr_iterator ci; | ||
235 | u32 *dir, *block = NULL, *p, *end; | ||
236 | int length, key, value, last_key = 0; | ||
237 | char *b; | ||
238 | |||
239 | if (is_fw_unit(dev)) | ||
240 | dir = fw_unit(dev)->directory; | ||
241 | else | ||
242 | dir = fw_device(dev)->config_rom + 5; | ||
243 | |||
244 | fw_csr_iterator_init(&ci, dir); | ||
245 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
246 | if (attr->key == last_key && | ||
247 | key == (CSR_DESCRIPTOR | CSR_LEAF)) | ||
248 | block = ci.p - 1 + value; | ||
249 | last_key = key; | ||
250 | } | ||
251 | |||
252 | if (block == NULL) | ||
253 | return -ENOENT; | ||
254 | |||
255 | length = min(block[0] >> 16, 256U); | ||
256 | if (length < 3) | ||
257 | return -ENOENT; | ||
258 | |||
259 | if (block[1] != 0 || block[2] != 0) | ||
260 | /* Unknown encoding. */ | ||
261 | return -ENOENT; | ||
262 | |||
263 | if (buf == NULL) | ||
264 | return length * 4; | ||
265 | |||
266 | b = buf; | ||
267 | end = &block[length + 1]; | ||
268 | for (p = &block[3]; p < end; p++, b += 4) | ||
269 | * (u32 *) b = (__force u32) __cpu_to_be32(*p); | ||
270 | |||
271 | /* Strip trailing whitespace and add newline. */ | ||
272 | while (b--, (isspace(*b) || *b == '\0') && b > buf); | ||
273 | strcpy(b + 1, "\n"); | ||
274 | |||
275 | return b + 2 - buf; | ||
276 | } | ||
277 | |||
278 | #define TEXT_LEAF_ATTR(name, key) \ | ||
279 | { __ATTR(name, S_IRUGO, show_text_leaf, NULL), key } | ||
280 | |||
281 | static struct config_rom_attribute config_rom_attributes[] = { | ||
282 | IMMEDIATE_ATTR(vendor, CSR_VENDOR), | ||
283 | IMMEDIATE_ATTR(hardware_version, CSR_HARDWARE_VERSION), | ||
284 | IMMEDIATE_ATTR(specifier_id, CSR_SPECIFIER_ID), | ||
285 | IMMEDIATE_ATTR(version, CSR_VERSION), | ||
286 | IMMEDIATE_ATTR(model, CSR_MODEL), | ||
287 | TEXT_LEAF_ATTR(vendor_name, CSR_VENDOR), | ||
288 | TEXT_LEAF_ATTR(model_name, CSR_MODEL), | ||
289 | TEXT_LEAF_ATTR(hardware_version_name, CSR_HARDWARE_VERSION), | ||
290 | }; | ||
291 | |||
292 | static void | ||
293 | init_fw_attribute_group(struct device *dev, | ||
294 | struct device_attribute *attrs, | ||
295 | struct fw_attribute_group *group) | ||
296 | { | ||
297 | struct device_attribute *attr; | ||
298 | int i, j; | ||
299 | |||
300 | for (j = 0; attrs[j].attr.name != NULL; j++) | ||
301 | group->attrs[j] = &attrs[j].attr; | ||
302 | |||
303 | for (i = 0; i < ARRAY_SIZE(config_rom_attributes); i++) { | ||
304 | attr = &config_rom_attributes[i].attr; | ||
305 | if (attr->show(dev, attr, NULL) < 0) | ||
306 | continue; | ||
307 | group->attrs[j++] = &attr->attr; | ||
308 | } | ||
309 | |||
310 | BUG_ON(j >= ARRAY_SIZE(group->attrs)); | ||
311 | group->attrs[j++] = NULL; | ||
312 | group->groups[0] = &group->group; | ||
313 | group->groups[1] = NULL; | ||
314 | group->group.attrs = group->attrs; | ||
315 | dev->groups = group->groups; | ||
316 | } | ||
317 | |||
318 | static ssize_t | ||
319 | modalias_show(struct device *dev, | ||
320 | struct device_attribute *attr, char *buf) | ||
321 | { | ||
322 | struct fw_unit *unit = fw_unit(dev); | ||
323 | int length; | ||
324 | |||
325 | length = get_modalias(unit, buf, PAGE_SIZE); | ||
326 | strcpy(buf + length, "\n"); | ||
327 | |||
328 | return length + 1; | ||
329 | } | ||
330 | |||
331 | static ssize_t | ||
332 | rom_index_show(struct device *dev, | ||
333 | struct device_attribute *attr, char *buf) | ||
334 | { | ||
335 | struct fw_device *device = fw_device(dev->parent); | ||
336 | struct fw_unit *unit = fw_unit(dev); | ||
337 | |||
338 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
339 | (int)(unit->directory - device->config_rom)); | ||
340 | } | ||
341 | |||
342 | static struct device_attribute fw_unit_attributes[] = { | ||
343 | __ATTR_RO(modalias), | ||
344 | __ATTR_RO(rom_index), | ||
345 | __ATTR_NULL, | ||
346 | }; | ||
347 | |||
348 | static ssize_t | ||
349 | config_rom_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
350 | { | ||
351 | struct fw_device *device = fw_device(dev); | ||
352 | |||
353 | memcpy(buf, device->config_rom, device->config_rom_length * 4); | ||
354 | |||
355 | return device->config_rom_length * 4; | ||
356 | } | ||
357 | |||
358 | static ssize_t | ||
359 | guid_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
360 | { | ||
361 | struct fw_device *device = fw_device(dev); | ||
362 | u64 guid; | ||
363 | |||
364 | guid = ((u64)device->config_rom[3] << 32) | device->config_rom[4]; | ||
365 | |||
366 | return snprintf(buf, PAGE_SIZE, "0x%016llx\n", | ||
367 | (unsigned long long)guid); | ||
368 | } | ||
369 | |||
370 | static struct device_attribute fw_device_attributes[] = { | ||
371 | __ATTR_RO(config_rom), | ||
372 | __ATTR_RO(guid), | ||
373 | __ATTR_NULL, | ||
374 | }; | ||
375 | |||
376 | struct read_quadlet_callback_data { | ||
377 | struct completion done; | ||
378 | int rcode; | ||
379 | u32 data; | ||
380 | }; | ||
381 | |||
382 | static void | ||
383 | complete_transaction(struct fw_card *card, int rcode, | ||
384 | void *payload, size_t length, void *data) | ||
385 | { | ||
386 | struct read_quadlet_callback_data *callback_data = data; | ||
387 | |||
388 | if (rcode == RCODE_COMPLETE) | ||
389 | callback_data->data = be32_to_cpu(*(__be32 *)payload); | ||
390 | callback_data->rcode = rcode; | ||
391 | complete(&callback_data->done); | ||
392 | } | ||
393 | |||
394 | static int read_rom(struct fw_device *device, int index, u32 * data) | ||
395 | { | ||
396 | struct read_quadlet_callback_data callback_data; | ||
397 | struct fw_transaction t; | ||
398 | u64 offset; | ||
399 | |||
400 | init_completion(&callback_data.done); | ||
401 | |||
402 | offset = 0xfffff0000400ULL + index * 4; | ||
403 | fw_send_request(device->card, &t, TCODE_READ_QUADLET_REQUEST, | ||
404 | device->node_id, | ||
405 | device->generation, SCODE_100, | ||
406 | offset, NULL, 4, complete_transaction, &callback_data); | ||
407 | |||
408 | wait_for_completion(&callback_data.done); | ||
409 | |||
410 | *data = callback_data.data; | ||
411 | |||
412 | return callback_data.rcode; | ||
413 | } | ||
414 | |||
415 | static int read_bus_info_block(struct fw_device *device) | ||
416 | { | ||
417 | static u32 rom[256]; | ||
418 | u32 stack[16], sp, key; | ||
419 | int i, end, length; | ||
420 | |||
421 | /* First read the bus info block. */ | ||
422 | for (i = 0; i < 5; i++) { | ||
423 | if (read_rom(device, i, &rom[i]) != RCODE_COMPLETE) | ||
424 | return -1; | ||
425 | /* | ||
426 | * As per IEEE1212 7.2, during power-up, devices can | ||
427 | * reply with a 0 for the first quadlet of the config | ||
428 | * rom to indicate that they are booting (for example, | ||
429 | * if the firmware is on the disk of a external | ||
430 | * harddisk). In that case we just fail, and the | ||
431 | * retry mechanism will try again later. | ||
432 | */ | ||
433 | if (i == 0 && rom[i] == 0) | ||
434 | return -1; | ||
435 | } | ||
436 | |||
437 | /* | ||
438 | * Now parse the config rom. The config rom is a recursive | ||
439 | * directory structure so we parse it using a stack of | ||
440 | * references to the blocks that make up the structure. We | ||
441 | * push a reference to the root directory on the stack to | ||
442 | * start things off. | ||
443 | */ | ||
444 | length = i; | ||
445 | sp = 0; | ||
446 | stack[sp++] = 0xc0000005; | ||
447 | while (sp > 0) { | ||
448 | /* | ||
449 | * Pop the next block reference of the stack. The | ||
450 | * lower 24 bits is the offset into the config rom, | ||
451 | * the upper 8 bits are the type of the reference the | ||
452 | * block. | ||
453 | */ | ||
454 | key = stack[--sp]; | ||
455 | i = key & 0xffffff; | ||
456 | if (i >= ARRAY_SIZE(rom)) | ||
457 | /* | ||
458 | * The reference points outside the standard | ||
459 | * config rom area, something's fishy. | ||
460 | */ | ||
461 | return -1; | ||
462 | |||
463 | /* Read header quadlet for the block to get the length. */ | ||
464 | if (read_rom(device, i, &rom[i]) != RCODE_COMPLETE) | ||
465 | return -1; | ||
466 | end = i + (rom[i] >> 16) + 1; | ||
467 | i++; | ||
468 | if (end > ARRAY_SIZE(rom)) | ||
469 | /* | ||
470 | * This block extends outside standard config | ||
471 | * area (and the array we're reading it | ||
472 | * into). That's broken, so ignore this | ||
473 | * device. | ||
474 | */ | ||
475 | return -1; | ||
476 | |||
477 | /* | ||
478 | * Now read in the block. If this is a directory | ||
479 | * block, check the entries as we read them to see if | ||
480 | * it references another block, and push it in that case. | ||
481 | */ | ||
482 | while (i < end) { | ||
483 | if (read_rom(device, i, &rom[i]) != RCODE_COMPLETE) | ||
484 | return -1; | ||
485 | if ((key >> 30) == 3 && (rom[i] >> 30) > 1 && | ||
486 | sp < ARRAY_SIZE(stack)) | ||
487 | stack[sp++] = i + rom[i]; | ||
488 | i++; | ||
489 | } | ||
490 | if (length < i) | ||
491 | length = i; | ||
492 | } | ||
493 | |||
494 | device->config_rom = kmalloc(length * 4, GFP_KERNEL); | ||
495 | if (device->config_rom == NULL) | ||
496 | return -1; | ||
497 | memcpy(device->config_rom, rom, length * 4); | ||
498 | device->config_rom_length = length; | ||
499 | |||
500 | return 0; | ||
501 | } | ||
502 | |||
503 | static void fw_unit_release(struct device *dev) | ||
504 | { | ||
505 | struct fw_unit *unit = fw_unit(dev); | ||
506 | |||
507 | kfree(unit); | ||
508 | } | ||
509 | |||
510 | static struct device_type fw_unit_type = { | ||
511 | .uevent = fw_unit_uevent, | ||
512 | .release = fw_unit_release, | ||
513 | }; | ||
514 | |||
515 | static int is_fw_unit(struct device *dev) | ||
516 | { | ||
517 | return dev->type == &fw_unit_type; | ||
518 | } | ||
519 | |||
520 | static void create_units(struct fw_device *device) | ||
521 | { | ||
522 | struct fw_csr_iterator ci; | ||
523 | struct fw_unit *unit; | ||
524 | int key, value, i; | ||
525 | |||
526 | i = 0; | ||
527 | fw_csr_iterator_init(&ci, &device->config_rom[5]); | ||
528 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
529 | if (key != (CSR_UNIT | CSR_DIRECTORY)) | ||
530 | continue; | ||
531 | |||
532 | /* | ||
533 | * Get the address of the unit directory and try to | ||
534 | * match the drivers id_tables against it. | ||
535 | */ | ||
536 | unit = kzalloc(sizeof(*unit), GFP_KERNEL); | ||
537 | if (unit == NULL) { | ||
538 | fw_error("failed to allocate memory for unit\n"); | ||
539 | continue; | ||
540 | } | ||
541 | |||
542 | unit->directory = ci.p + value - 1; | ||
543 | unit->device.bus = &fw_bus_type; | ||
544 | unit->device.type = &fw_unit_type; | ||
545 | unit->device.parent = &device->device; | ||
546 | snprintf(unit->device.bus_id, sizeof(unit->device.bus_id), | ||
547 | "%s.%d", device->device.bus_id, i++); | ||
548 | |||
549 | init_fw_attribute_group(&unit->device, | ||
550 | fw_unit_attributes, | ||
551 | &unit->attribute_group); | ||
552 | if (device_register(&unit->device) < 0) | ||
553 | goto skip_unit; | ||
554 | |||
555 | continue; | ||
556 | |||
557 | skip_unit: | ||
558 | kfree(unit); | ||
559 | } | ||
560 | } | ||
561 | |||
562 | static int shutdown_unit(struct device *device, void *data) | ||
563 | { | ||
564 | device_unregister(device); | ||
565 | |||
566 | return 0; | ||
567 | } | ||
568 | |||
569 | static DECLARE_RWSEM(idr_rwsem); | ||
570 | static DEFINE_IDR(fw_device_idr); | ||
571 | int fw_cdev_major; | ||
572 | |||
573 | struct fw_device *fw_device_from_devt(dev_t devt) | ||
574 | { | ||
575 | struct fw_device *device; | ||
576 | |||
577 | down_read(&idr_rwsem); | ||
578 | device = idr_find(&fw_device_idr, MINOR(devt)); | ||
579 | up_read(&idr_rwsem); | ||
580 | |||
581 | return device; | ||
582 | } | ||
583 | |||
584 | static void fw_device_shutdown(struct work_struct *work) | ||
585 | { | ||
586 | struct fw_device *device = | ||
587 | container_of(work, struct fw_device, work.work); | ||
588 | int minor = MINOR(device->device.devt); | ||
589 | |||
590 | down_write(&idr_rwsem); | ||
591 | idr_remove(&fw_device_idr, minor); | ||
592 | up_write(&idr_rwsem); | ||
593 | |||
594 | fw_device_cdev_remove(device); | ||
595 | device_for_each_child(&device->device, NULL, shutdown_unit); | ||
596 | device_unregister(&device->device); | ||
597 | } | ||
598 | |||
599 | static struct device_type fw_device_type = { | ||
600 | .release = fw_device_release, | ||
601 | }; | ||
602 | |||
603 | /* | ||
604 | * These defines control the retry behavior for reading the config | ||
605 | * rom. It shouldn't be necessary to tweak these; if the device | ||
606 | * doesn't respond to a config rom read within 10 seconds, it's not | ||
607 | * going to respond at all. As for the initial delay, a lot of | ||
608 | * devices will be able to respond within half a second after bus | ||
609 | * reset. On the other hand, it's not really worth being more | ||
610 | * aggressive than that, since it scales pretty well; if 10 devices | ||
611 | * are plugged in, they're all getting read within one second. | ||
612 | */ | ||
613 | |||
614 | #define MAX_RETRIES 10 | ||
615 | #define RETRY_DELAY (3 * HZ) | ||
616 | #define INITIAL_DELAY (HZ / 2) | ||
617 | |||
618 | static void fw_device_init(struct work_struct *work) | ||
619 | { | ||
620 | struct fw_device *device = | ||
621 | container_of(work, struct fw_device, work.work); | ||
622 | int minor, err; | ||
623 | |||
624 | /* | ||
625 | * All failure paths here set node->data to NULL, so that we | ||
626 | * don't try to do device_for_each_child() on a kfree()'d | ||
627 | * device. | ||
628 | */ | ||
629 | |||
630 | if (read_bus_info_block(device) < 0) { | ||
631 | if (device->config_rom_retries < MAX_RETRIES) { | ||
632 | device->config_rom_retries++; | ||
633 | schedule_delayed_work(&device->work, RETRY_DELAY); | ||
634 | } else { | ||
635 | fw_notify("giving up on config rom for node id %x\n", | ||
636 | device->node_id); | ||
637 | if (device->node == device->card->root_node) | ||
638 | schedule_delayed_work(&device->card->work, 0); | ||
639 | fw_device_release(&device->device); | ||
640 | } | ||
641 | return; | ||
642 | } | ||
643 | |||
644 | err = -ENOMEM; | ||
645 | down_write(&idr_rwsem); | ||
646 | if (idr_pre_get(&fw_device_idr, GFP_KERNEL)) | ||
647 | err = idr_get_new(&fw_device_idr, device, &minor); | ||
648 | up_write(&idr_rwsem); | ||
649 | if (err < 0) | ||
650 | goto error; | ||
651 | |||
652 | device->device.bus = &fw_bus_type; | ||
653 | device->device.type = &fw_device_type; | ||
654 | device->device.parent = device->card->device; | ||
655 | device->device.devt = MKDEV(fw_cdev_major, minor); | ||
656 | snprintf(device->device.bus_id, sizeof(device->device.bus_id), | ||
657 | "fw%d", minor); | ||
658 | |||
659 | init_fw_attribute_group(&device->device, | ||
660 | fw_device_attributes, | ||
661 | &device->attribute_group); | ||
662 | if (device_add(&device->device)) { | ||
663 | fw_error("Failed to add device.\n"); | ||
664 | goto error_with_cdev; | ||
665 | } | ||
666 | |||
667 | create_units(device); | ||
668 | |||
669 | /* | ||
670 | * Transition the device to running state. If it got pulled | ||
671 | * out from under us while we did the intialization work, we | ||
672 | * have to shut down the device again here. Normally, though, | ||
673 | * fw_node_event will be responsible for shutting it down when | ||
674 | * necessary. We have to use the atomic cmpxchg here to avoid | ||
675 | * racing with the FW_NODE_DESTROYED case in | ||
676 | * fw_node_event(). | ||
677 | */ | ||
678 | if (atomic_cmpxchg(&device->state, | ||
679 | FW_DEVICE_INITIALIZING, | ||
680 | FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) | ||
681 | fw_device_shutdown(&device->work.work); | ||
682 | else | ||
683 | fw_notify("created new fw device %s (%d config rom retries)\n", | ||
684 | device->device.bus_id, device->config_rom_retries); | ||
685 | |||
686 | /* | ||
687 | * Reschedule the IRM work if we just finished reading the | ||
688 | * root node config rom. If this races with a bus reset we | ||
689 | * just end up running the IRM work a couple of extra times - | ||
690 | * pretty harmless. | ||
691 | */ | ||
692 | if (device->node == device->card->root_node) | ||
693 | schedule_delayed_work(&device->card->work, 0); | ||
694 | |||
695 | return; | ||
696 | |||
697 | error_with_cdev: | ||
698 | down_write(&idr_rwsem); | ||
699 | idr_remove(&fw_device_idr, minor); | ||
700 | up_write(&idr_rwsem); | ||
701 | error: | ||
702 | put_device(&device->device); | ||
703 | } | ||
704 | |||
705 | static int update_unit(struct device *dev, void *data) | ||
706 | { | ||
707 | struct fw_unit *unit = fw_unit(dev); | ||
708 | struct fw_driver *driver = (struct fw_driver *)dev->driver; | ||
709 | |||
710 | if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) { | ||
711 | down(&dev->sem); | ||
712 | driver->update(unit); | ||
713 | up(&dev->sem); | ||
714 | } | ||
715 | |||
716 | return 0; | ||
717 | } | ||
718 | |||
719 | static void fw_device_update(struct work_struct *work) | ||
720 | { | ||
721 | struct fw_device *device = | ||
722 | container_of(work, struct fw_device, work.work); | ||
723 | |||
724 | fw_device_cdev_update(device); | ||
725 | device_for_each_child(&device->device, NULL, update_unit); | ||
726 | } | ||
727 | |||
728 | void fw_node_event(struct fw_card *card, struct fw_node *node, int event) | ||
729 | { | ||
730 | struct fw_device *device; | ||
731 | |||
732 | switch (event) { | ||
733 | case FW_NODE_CREATED: | ||
734 | case FW_NODE_LINK_ON: | ||
735 | if (!node->link_on) | ||
736 | break; | ||
737 | |||
738 | device = kzalloc(sizeof(*device), GFP_ATOMIC); | ||
739 | if (device == NULL) | ||
740 | break; | ||
741 | |||
742 | /* | ||
743 | * Do minimal intialization of the device here, the | ||
744 | * rest will happen in fw_device_init(). We need the | ||
745 | * card and node so we can read the config rom and we | ||
746 | * need to do device_initialize() now so | ||
747 | * device_for_each_child() in FW_NODE_UPDATED is | ||
748 | * doesn't freak out. | ||
749 | */ | ||
750 | device_initialize(&device->device); | ||
751 | atomic_set(&device->state, FW_DEVICE_INITIALIZING); | ||
752 | device->card = fw_card_get(card); | ||
753 | device->node = fw_node_get(node); | ||
754 | device->node_id = node->node_id; | ||
755 | device->generation = card->generation; | ||
756 | INIT_LIST_HEAD(&device->client_list); | ||
757 | |||
758 | /* | ||
759 | * Set the node data to point back to this device so | ||
760 | * FW_NODE_UPDATED callbacks can update the node_id | ||
761 | * and generation for the device. | ||
762 | */ | ||
763 | node->data = device; | ||
764 | |||
765 | /* | ||
766 | * Many devices are slow to respond after bus resets, | ||
767 | * especially if they are bus powered and go through | ||
768 | * power-up after getting plugged in. We schedule the | ||
769 | * first config rom scan half a second after bus reset. | ||
770 | */ | ||
771 | INIT_DELAYED_WORK(&device->work, fw_device_init); | ||
772 | schedule_delayed_work(&device->work, INITIAL_DELAY); | ||
773 | break; | ||
774 | |||
775 | case FW_NODE_UPDATED: | ||
776 | if (!node->link_on || node->data == NULL) | ||
777 | break; | ||
778 | |||
779 | device = node->data; | ||
780 | device->node_id = node->node_id; | ||
781 | device->generation = card->generation; | ||
782 | if (atomic_read(&device->state) == FW_DEVICE_RUNNING) { | ||
783 | PREPARE_DELAYED_WORK(&device->work, fw_device_update); | ||
784 | schedule_delayed_work(&device->work, 0); | ||
785 | } | ||
786 | break; | ||
787 | |||
788 | case FW_NODE_DESTROYED: | ||
789 | case FW_NODE_LINK_OFF: | ||
790 | if (!node->data) | ||
791 | break; | ||
792 | |||
793 | /* | ||
794 | * Destroy the device associated with the node. There | ||
795 | * are two cases here: either the device is fully | ||
796 | * initialized (FW_DEVICE_RUNNING) or we're in the | ||
797 | * process of reading its config rom | ||
798 | * (FW_DEVICE_INITIALIZING). If it is fully | ||
799 | * initialized we can reuse device->work to schedule a | ||
800 | * full fw_device_shutdown(). If not, there's work | ||
801 | * scheduled to read it's config rom, and we just put | ||
802 | * the device in shutdown state to have that code fail | ||
803 | * to create the device. | ||
804 | */ | ||
805 | device = node->data; | ||
806 | if (atomic_xchg(&device->state, | ||
807 | FW_DEVICE_SHUTDOWN) == FW_DEVICE_RUNNING) { | ||
808 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); | ||
809 | schedule_delayed_work(&device->work, 0); | ||
810 | } | ||
811 | break; | ||
812 | } | ||
813 | } | ||
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h new file mode 100644 index 000000000000..0ba9d64ccf4c --- /dev/null +++ b/drivers/firewire/fw-device.h | |||
@@ -0,0 +1,146 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software Foundation, | ||
16 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | */ | ||
18 | |||
19 | #ifndef __fw_device_h | ||
20 | #define __fw_device_h | ||
21 | |||
22 | #include <linux/fs.h> | ||
23 | #include <linux/cdev.h> | ||
24 | #include <asm/atomic.h> | ||
25 | |||
26 | enum fw_device_state { | ||
27 | FW_DEVICE_INITIALIZING, | ||
28 | FW_DEVICE_RUNNING, | ||
29 | FW_DEVICE_SHUTDOWN, | ||
30 | }; | ||
31 | |||
32 | struct fw_attribute_group { | ||
33 | struct attribute_group *groups[2]; | ||
34 | struct attribute_group group; | ||
35 | struct attribute *attrs[11]; | ||
36 | }; | ||
37 | |||
38 | struct fw_device { | ||
39 | atomic_t state; | ||
40 | struct fw_node *node; | ||
41 | int node_id; | ||
42 | int generation; | ||
43 | struct fw_card *card; | ||
44 | struct device device; | ||
45 | struct list_head link; | ||
46 | struct list_head client_list; | ||
47 | u32 *config_rom; | ||
48 | size_t config_rom_length; | ||
49 | int config_rom_retries; | ||
50 | struct delayed_work work; | ||
51 | struct fw_attribute_group attribute_group; | ||
52 | }; | ||
53 | |||
54 | static inline struct fw_device * | ||
55 | fw_device(struct device *dev) | ||
56 | { | ||
57 | return container_of(dev, struct fw_device, device); | ||
58 | } | ||
59 | |||
60 | static inline int | ||
61 | fw_device_is_shutdown(struct fw_device *device) | ||
62 | { | ||
63 | return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN; | ||
64 | } | ||
65 | |||
66 | struct fw_device *fw_device_get(struct fw_device *device); | ||
67 | void fw_device_put(struct fw_device *device); | ||
68 | int fw_device_enable_phys_dma(struct fw_device *device); | ||
69 | |||
70 | void fw_device_cdev_update(struct fw_device *device); | ||
71 | void fw_device_cdev_remove(struct fw_device *device); | ||
72 | |||
73 | struct fw_device *fw_device_from_devt(dev_t devt); | ||
74 | extern int fw_cdev_major; | ||
75 | |||
76 | struct fw_unit { | ||
77 | struct device device; | ||
78 | u32 *directory; | ||
79 | struct fw_attribute_group attribute_group; | ||
80 | }; | ||
81 | |||
82 | static inline struct fw_unit * | ||
83 | fw_unit(struct device *dev) | ||
84 | { | ||
85 | return container_of(dev, struct fw_unit, device); | ||
86 | } | ||
87 | |||
88 | #define CSR_OFFSET 0x40 | ||
89 | #define CSR_LEAF 0x80 | ||
90 | #define CSR_DIRECTORY 0xc0 | ||
91 | |||
92 | #define CSR_DESCRIPTOR 0x01 | ||
93 | #define CSR_VENDOR 0x03 | ||
94 | #define CSR_HARDWARE_VERSION 0x04 | ||
95 | #define CSR_NODE_CAPABILITIES 0x0c | ||
96 | #define CSR_UNIT 0x11 | ||
97 | #define CSR_SPECIFIER_ID 0x12 | ||
98 | #define CSR_VERSION 0x13 | ||
99 | #define CSR_DEPENDENT_INFO 0x14 | ||
100 | #define CSR_MODEL 0x17 | ||
101 | #define CSR_INSTANCE 0x18 | ||
102 | |||
103 | #define SBP2_COMMAND_SET_SPECIFIER 0x38 | ||
104 | #define SBP2_COMMAND_SET 0x39 | ||
105 | #define SBP2_COMMAND_SET_REVISION 0x3b | ||
106 | #define SBP2_FIRMWARE_REVISION 0x3c | ||
107 | |||
108 | struct fw_csr_iterator { | ||
109 | u32 *p; | ||
110 | u32 *end; | ||
111 | }; | ||
112 | |||
113 | void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 *p); | ||
114 | int fw_csr_iterator_next(struct fw_csr_iterator *ci, | ||
115 | int *key, int *value); | ||
116 | |||
117 | #define FW_MATCH_VENDOR 0x0001 | ||
118 | #define FW_MATCH_MODEL 0x0002 | ||
119 | #define FW_MATCH_SPECIFIER_ID 0x0004 | ||
120 | #define FW_MATCH_VERSION 0x0008 | ||
121 | |||
122 | struct fw_device_id { | ||
123 | u32 match_flags; | ||
124 | u32 vendor; | ||
125 | u32 model; | ||
126 | u32 specifier_id; | ||
127 | u32 version; | ||
128 | void *driver_data; | ||
129 | }; | ||
130 | |||
131 | struct fw_driver { | ||
132 | struct device_driver driver; | ||
133 | /* Called when the parent device sits through a bus reset. */ | ||
134 | void (*update) (struct fw_unit *unit); | ||
135 | const struct fw_device_id *id_table; | ||
136 | }; | ||
137 | |||
138 | static inline struct fw_driver * | ||
139 | fw_driver(struct device_driver *drv) | ||
140 | { | ||
141 | return container_of(drv, struct fw_driver, driver); | ||
142 | } | ||
143 | |||
144 | extern const struct file_operations fw_device_ops; | ||
145 | |||
146 | #endif /* __fw_device_h */ | ||
diff --git a/drivers/firewire/fw-iso.c b/drivers/firewire/fw-iso.c new file mode 100644 index 000000000000..2b640e9be6de --- /dev/null +++ b/drivers/firewire/fw-iso.c | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | * Isochronous IO functionality | ||
3 | * | ||
4 | * Copyright (C) 2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/dma-mapping.h> | ||
24 | #include <linux/vmalloc.h> | ||
25 | #include <linux/mm.h> | ||
26 | |||
27 | #include "fw-transaction.h" | ||
28 | #include "fw-topology.h" | ||
29 | #include "fw-device.h" | ||
30 | |||
31 | int | ||
32 | fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, | ||
33 | int page_count, enum dma_data_direction direction) | ||
34 | { | ||
35 | int i, j, retval = -ENOMEM; | ||
36 | dma_addr_t address; | ||
37 | |||
38 | buffer->page_count = page_count; | ||
39 | buffer->direction = direction; | ||
40 | |||
41 | buffer->pages = kmalloc(page_count * sizeof(buffer->pages[0]), | ||
42 | GFP_KERNEL); | ||
43 | if (buffer->pages == NULL) | ||
44 | goto out; | ||
45 | |||
46 | for (i = 0; i < buffer->page_count; i++) { | ||
47 | buffer->pages[i] = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); | ||
48 | if (buffer->pages[i] == NULL) | ||
49 | goto out_pages; | ||
50 | |||
51 | address = dma_map_page(card->device, buffer->pages[i], | ||
52 | 0, PAGE_SIZE, direction); | ||
53 | if (dma_mapping_error(address)) { | ||
54 | __free_page(buffer->pages[i]); | ||
55 | goto out_pages; | ||
56 | } | ||
57 | set_page_private(buffer->pages[i], address); | ||
58 | } | ||
59 | |||
60 | return 0; | ||
61 | |||
62 | out_pages: | ||
63 | for (j = 0; j < i; j++) { | ||
64 | address = page_private(buffer->pages[j]); | ||
65 | dma_unmap_page(card->device, address, | ||
66 | PAGE_SIZE, DMA_TO_DEVICE); | ||
67 | __free_page(buffer->pages[j]); | ||
68 | } | ||
69 | kfree(buffer->pages); | ||
70 | out: | ||
71 | buffer->pages = NULL; | ||
72 | return retval; | ||
73 | } | ||
74 | |||
75 | int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma) | ||
76 | { | ||
77 | unsigned long uaddr; | ||
78 | int i, retval; | ||
79 | |||
80 | uaddr = vma->vm_start; | ||
81 | for (i = 0; i < buffer->page_count; i++) { | ||
82 | retval = vm_insert_page(vma, uaddr, buffer->pages[i]); | ||
83 | if (retval) | ||
84 | return retval; | ||
85 | uaddr += PAGE_SIZE; | ||
86 | } | ||
87 | |||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, | ||
92 | struct fw_card *card) | ||
93 | { | ||
94 | int i; | ||
95 | dma_addr_t address; | ||
96 | |||
97 | for (i = 0; i < buffer->page_count; i++) { | ||
98 | address = page_private(buffer->pages[i]); | ||
99 | dma_unmap_page(card->device, address, | ||
100 | PAGE_SIZE, DMA_TO_DEVICE); | ||
101 | __free_page(buffer->pages[i]); | ||
102 | } | ||
103 | |||
104 | kfree(buffer->pages); | ||
105 | buffer->pages = NULL; | ||
106 | } | ||
107 | |||
108 | struct fw_iso_context * | ||
109 | fw_iso_context_create(struct fw_card *card, int type, | ||
110 | int channel, int speed, size_t header_size, | ||
111 | fw_iso_callback_t callback, void *callback_data) | ||
112 | { | ||
113 | struct fw_iso_context *ctx; | ||
114 | |||
115 | ctx = card->driver->allocate_iso_context(card, type, header_size); | ||
116 | if (IS_ERR(ctx)) | ||
117 | return ctx; | ||
118 | |||
119 | ctx->card = card; | ||
120 | ctx->type = type; | ||
121 | ctx->channel = channel; | ||
122 | ctx->speed = speed; | ||
123 | ctx->header_size = header_size; | ||
124 | ctx->callback = callback; | ||
125 | ctx->callback_data = callback_data; | ||
126 | |||
127 | return ctx; | ||
128 | } | ||
129 | EXPORT_SYMBOL(fw_iso_context_create); | ||
130 | |||
131 | void fw_iso_context_destroy(struct fw_iso_context *ctx) | ||
132 | { | ||
133 | struct fw_card *card = ctx->card; | ||
134 | |||
135 | card->driver->free_iso_context(ctx); | ||
136 | } | ||
137 | EXPORT_SYMBOL(fw_iso_context_destroy); | ||
138 | |||
139 | int | ||
140 | fw_iso_context_start(struct fw_iso_context *ctx, int cycle, int sync, int tags) | ||
141 | { | ||
142 | return ctx->card->driver->start_iso(ctx, cycle, sync, tags); | ||
143 | } | ||
144 | EXPORT_SYMBOL(fw_iso_context_start); | ||
145 | |||
146 | int | ||
147 | fw_iso_context_queue(struct fw_iso_context *ctx, | ||
148 | struct fw_iso_packet *packet, | ||
149 | struct fw_iso_buffer *buffer, | ||
150 | unsigned long payload) | ||
151 | { | ||
152 | struct fw_card *card = ctx->card; | ||
153 | |||
154 | return card->driver->queue_iso(ctx, packet, buffer, payload); | ||
155 | } | ||
156 | EXPORT_SYMBOL(fw_iso_context_queue); | ||
157 | |||
158 | int | ||
159 | fw_iso_context_stop(struct fw_iso_context *ctx) | ||
160 | { | ||
161 | return ctx->card->driver->stop_iso(ctx); | ||
162 | } | ||
163 | EXPORT_SYMBOL(fw_iso_context_stop); | ||
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c new file mode 100644 index 000000000000..1f5c70461b8b --- /dev/null +++ b/drivers/firewire/fw-ohci.c | |||
@@ -0,0 +1,1943 @@ | |||
1 | /* | ||
2 | * Driver for OHCI 1394 controllers | ||
3 | * | ||
4 | * Copyright (C) 2003-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/pci.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/poll.h> | ||
28 | #include <linux/dma-mapping.h> | ||
29 | |||
30 | #include <asm/uaccess.h> | ||
31 | #include <asm/semaphore.h> | ||
32 | |||
33 | #include "fw-transaction.h" | ||
34 | #include "fw-ohci.h" | ||
35 | |||
36 | #define DESCRIPTOR_OUTPUT_MORE 0 | ||
37 | #define DESCRIPTOR_OUTPUT_LAST (1 << 12) | ||
38 | #define DESCRIPTOR_INPUT_MORE (2 << 12) | ||
39 | #define DESCRIPTOR_INPUT_LAST (3 << 12) | ||
40 | #define DESCRIPTOR_STATUS (1 << 11) | ||
41 | #define DESCRIPTOR_KEY_IMMEDIATE (2 << 8) | ||
42 | #define DESCRIPTOR_PING (1 << 7) | ||
43 | #define DESCRIPTOR_YY (1 << 6) | ||
44 | #define DESCRIPTOR_NO_IRQ (0 << 4) | ||
45 | #define DESCRIPTOR_IRQ_ERROR (1 << 4) | ||
46 | #define DESCRIPTOR_IRQ_ALWAYS (3 << 4) | ||
47 | #define DESCRIPTOR_BRANCH_ALWAYS (3 << 2) | ||
48 | #define DESCRIPTOR_WAIT (3 << 0) | ||
49 | |||
50 | struct descriptor { | ||
51 | __le16 req_count; | ||
52 | __le16 control; | ||
53 | __le32 data_address; | ||
54 | __le32 branch_address; | ||
55 | __le16 res_count; | ||
56 | __le16 transfer_status; | ||
57 | } __attribute__((aligned(16))); | ||
58 | |||
59 | struct db_descriptor { | ||
60 | __le16 first_size; | ||
61 | __le16 control; | ||
62 | __le16 second_req_count; | ||
63 | __le16 first_req_count; | ||
64 | __le32 branch_address; | ||
65 | __le16 second_res_count; | ||
66 | __le16 first_res_count; | ||
67 | __le32 reserved0; | ||
68 | __le32 first_buffer; | ||
69 | __le32 second_buffer; | ||
70 | __le32 reserved1; | ||
71 | } __attribute__((aligned(16))); | ||
72 | |||
73 | #define CONTROL_SET(regs) (regs) | ||
74 | #define CONTROL_CLEAR(regs) ((regs) + 4) | ||
75 | #define COMMAND_PTR(regs) ((regs) + 12) | ||
76 | #define CONTEXT_MATCH(regs) ((regs) + 16) | ||
77 | |||
78 | struct ar_buffer { | ||
79 | struct descriptor descriptor; | ||
80 | struct ar_buffer *next; | ||
81 | __le32 data[0]; | ||
82 | }; | ||
83 | |||
84 | struct ar_context { | ||
85 | struct fw_ohci *ohci; | ||
86 | struct ar_buffer *current_buffer; | ||
87 | struct ar_buffer *last_buffer; | ||
88 | void *pointer; | ||
89 | u32 regs; | ||
90 | struct tasklet_struct tasklet; | ||
91 | }; | ||
92 | |||
93 | struct context; | ||
94 | |||
95 | typedef int (*descriptor_callback_t)(struct context *ctx, | ||
96 | struct descriptor *d, | ||
97 | struct descriptor *last); | ||
98 | struct context { | ||
99 | struct fw_ohci *ohci; | ||
100 | u32 regs; | ||
101 | |||
102 | struct descriptor *buffer; | ||
103 | dma_addr_t buffer_bus; | ||
104 | size_t buffer_size; | ||
105 | struct descriptor *head_descriptor; | ||
106 | struct descriptor *tail_descriptor; | ||
107 | struct descriptor *tail_descriptor_last; | ||
108 | struct descriptor *prev_descriptor; | ||
109 | |||
110 | descriptor_callback_t callback; | ||
111 | |||
112 | struct tasklet_struct tasklet; | ||
113 | }; | ||
114 | |||
115 | #define IT_HEADER_SY(v) ((v) << 0) | ||
116 | #define IT_HEADER_TCODE(v) ((v) << 4) | ||
117 | #define IT_HEADER_CHANNEL(v) ((v) << 8) | ||
118 | #define IT_HEADER_TAG(v) ((v) << 14) | ||
119 | #define IT_HEADER_SPEED(v) ((v) << 16) | ||
120 | #define IT_HEADER_DATA_LENGTH(v) ((v) << 16) | ||
121 | |||
122 | struct iso_context { | ||
123 | struct fw_iso_context base; | ||
124 | struct context context; | ||
125 | void *header; | ||
126 | size_t header_length; | ||
127 | }; | ||
128 | |||
129 | #define CONFIG_ROM_SIZE 1024 | ||
130 | |||
131 | struct fw_ohci { | ||
132 | struct fw_card card; | ||
133 | |||
134 | u32 version; | ||
135 | __iomem char *registers; | ||
136 | dma_addr_t self_id_bus; | ||
137 | __le32 *self_id_cpu; | ||
138 | struct tasklet_struct bus_reset_tasklet; | ||
139 | int node_id; | ||
140 | int generation; | ||
141 | int request_generation; | ||
142 | u32 bus_seconds; | ||
143 | |||
144 | /* | ||
145 | * Spinlock for accessing fw_ohci data. Never call out of | ||
146 | * this driver with this lock held. | ||
147 | */ | ||
148 | spinlock_t lock; | ||
149 | u32 self_id_buffer[512]; | ||
150 | |||
151 | /* Config rom buffers */ | ||
152 | __be32 *config_rom; | ||
153 | dma_addr_t config_rom_bus; | ||
154 | __be32 *next_config_rom; | ||
155 | dma_addr_t next_config_rom_bus; | ||
156 | u32 next_header; | ||
157 | |||
158 | struct ar_context ar_request_ctx; | ||
159 | struct ar_context ar_response_ctx; | ||
160 | struct context at_request_ctx; | ||
161 | struct context at_response_ctx; | ||
162 | |||
163 | u32 it_context_mask; | ||
164 | struct iso_context *it_context_list; | ||
165 | u32 ir_context_mask; | ||
166 | struct iso_context *ir_context_list; | ||
167 | }; | ||
168 | |||
169 | static inline struct fw_ohci *fw_ohci(struct fw_card *card) | ||
170 | { | ||
171 | return container_of(card, struct fw_ohci, card); | ||
172 | } | ||
173 | |||
174 | #define IT_CONTEXT_CYCLE_MATCH_ENABLE 0x80000000 | ||
175 | #define IR_CONTEXT_BUFFER_FILL 0x80000000 | ||
176 | #define IR_CONTEXT_ISOCH_HEADER 0x40000000 | ||
177 | #define IR_CONTEXT_CYCLE_MATCH_ENABLE 0x20000000 | ||
178 | #define IR_CONTEXT_MULTI_CHANNEL_MODE 0x10000000 | ||
179 | #define IR_CONTEXT_DUAL_BUFFER_MODE 0x08000000 | ||
180 | |||
181 | #define CONTEXT_RUN 0x8000 | ||
182 | #define CONTEXT_WAKE 0x1000 | ||
183 | #define CONTEXT_DEAD 0x0800 | ||
184 | #define CONTEXT_ACTIVE 0x0400 | ||
185 | |||
186 | #define OHCI1394_MAX_AT_REQ_RETRIES 0x2 | ||
187 | #define OHCI1394_MAX_AT_RESP_RETRIES 0x2 | ||
188 | #define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 | ||
189 | |||
190 | #define FW_OHCI_MAJOR 240 | ||
191 | #define OHCI1394_REGISTER_SIZE 0x800 | ||
192 | #define OHCI_LOOP_COUNT 500 | ||
193 | #define OHCI1394_PCI_HCI_Control 0x40 | ||
194 | #define SELF_ID_BUF_SIZE 0x800 | ||
195 | #define OHCI_TCODE_PHY_PACKET 0x0e | ||
196 | #define OHCI_VERSION_1_1 0x010010 | ||
197 | #define ISO_BUFFER_SIZE (64 * 1024) | ||
198 | #define AT_BUFFER_SIZE 4096 | ||
199 | |||
200 | static char ohci_driver_name[] = KBUILD_MODNAME; | ||
201 | |||
202 | static inline void reg_write(const struct fw_ohci *ohci, int offset, u32 data) | ||
203 | { | ||
204 | writel(data, ohci->registers + offset); | ||
205 | } | ||
206 | |||
207 | static inline u32 reg_read(const struct fw_ohci *ohci, int offset) | ||
208 | { | ||
209 | return readl(ohci->registers + offset); | ||
210 | } | ||
211 | |||
212 | static inline void flush_writes(const struct fw_ohci *ohci) | ||
213 | { | ||
214 | /* Do a dummy read to flush writes. */ | ||
215 | reg_read(ohci, OHCI1394_Version); | ||
216 | } | ||
217 | |||
218 | static int | ||
219 | ohci_update_phy_reg(struct fw_card *card, int addr, | ||
220 | int clear_bits, int set_bits) | ||
221 | { | ||
222 | struct fw_ohci *ohci = fw_ohci(card); | ||
223 | u32 val, old; | ||
224 | |||
225 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); | ||
226 | msleep(2); | ||
227 | val = reg_read(ohci, OHCI1394_PhyControl); | ||
228 | if ((val & OHCI1394_PhyControl_ReadDone) == 0) { | ||
229 | fw_error("failed to set phy reg bits.\n"); | ||
230 | return -EBUSY; | ||
231 | } | ||
232 | |||
233 | old = OHCI1394_PhyControl_ReadData(val); | ||
234 | old = (old & ~clear_bits) | set_bits; | ||
235 | reg_write(ohci, OHCI1394_PhyControl, | ||
236 | OHCI1394_PhyControl_Write(addr, old)); | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | static int ar_context_add_page(struct ar_context *ctx) | ||
242 | { | ||
243 | struct device *dev = ctx->ohci->card.device; | ||
244 | struct ar_buffer *ab; | ||
245 | dma_addr_t ab_bus; | ||
246 | size_t offset; | ||
247 | |||
248 | ab = (struct ar_buffer *) __get_free_page(GFP_ATOMIC); | ||
249 | if (ab == NULL) | ||
250 | return -ENOMEM; | ||
251 | |||
252 | ab_bus = dma_map_single(dev, ab, PAGE_SIZE, DMA_BIDIRECTIONAL); | ||
253 | if (dma_mapping_error(ab_bus)) { | ||
254 | free_page((unsigned long) ab); | ||
255 | return -ENOMEM; | ||
256 | } | ||
257 | |||
258 | memset(&ab->descriptor, 0, sizeof(ab->descriptor)); | ||
259 | ab->descriptor.control = cpu_to_le16(DESCRIPTOR_INPUT_MORE | | ||
260 | DESCRIPTOR_STATUS | | ||
261 | DESCRIPTOR_BRANCH_ALWAYS); | ||
262 | offset = offsetof(struct ar_buffer, data); | ||
263 | ab->descriptor.req_count = cpu_to_le16(PAGE_SIZE - offset); | ||
264 | ab->descriptor.data_address = cpu_to_le32(ab_bus + offset); | ||
265 | ab->descriptor.res_count = cpu_to_le16(PAGE_SIZE - offset); | ||
266 | ab->descriptor.branch_address = 0; | ||
267 | |||
268 | dma_sync_single_for_device(dev, ab_bus, PAGE_SIZE, DMA_BIDIRECTIONAL); | ||
269 | |||
270 | ctx->last_buffer->descriptor.branch_address = ab_bus | 1; | ||
271 | ctx->last_buffer->next = ab; | ||
272 | ctx->last_buffer = ab; | ||
273 | |||
274 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); | ||
275 | flush_writes(ctx->ohci); | ||
276 | |||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer) | ||
281 | { | ||
282 | struct fw_ohci *ohci = ctx->ohci; | ||
283 | struct fw_packet p; | ||
284 | u32 status, length, tcode; | ||
285 | |||
286 | p.header[0] = le32_to_cpu(buffer[0]); | ||
287 | p.header[1] = le32_to_cpu(buffer[1]); | ||
288 | p.header[2] = le32_to_cpu(buffer[2]); | ||
289 | |||
290 | tcode = (p.header[0] >> 4) & 0x0f; | ||
291 | switch (tcode) { | ||
292 | case TCODE_WRITE_QUADLET_REQUEST: | ||
293 | case TCODE_READ_QUADLET_RESPONSE: | ||
294 | p.header[3] = (__force __u32) buffer[3]; | ||
295 | p.header_length = 16; | ||
296 | p.payload_length = 0; | ||
297 | break; | ||
298 | |||
299 | case TCODE_READ_BLOCK_REQUEST : | ||
300 | p.header[3] = le32_to_cpu(buffer[3]); | ||
301 | p.header_length = 16; | ||
302 | p.payload_length = 0; | ||
303 | break; | ||
304 | |||
305 | case TCODE_WRITE_BLOCK_REQUEST: | ||
306 | case TCODE_READ_BLOCK_RESPONSE: | ||
307 | case TCODE_LOCK_REQUEST: | ||
308 | case TCODE_LOCK_RESPONSE: | ||
309 | p.header[3] = le32_to_cpu(buffer[3]); | ||
310 | p.header_length = 16; | ||
311 | p.payload_length = p.header[3] >> 16; | ||
312 | break; | ||
313 | |||
314 | case TCODE_WRITE_RESPONSE: | ||
315 | case TCODE_READ_QUADLET_REQUEST: | ||
316 | case OHCI_TCODE_PHY_PACKET: | ||
317 | p.header_length = 12; | ||
318 | p.payload_length = 0; | ||
319 | break; | ||
320 | } | ||
321 | |||
322 | p.payload = (void *) buffer + p.header_length; | ||
323 | |||
324 | /* FIXME: What to do about evt_* errors? */ | ||
325 | length = (p.header_length + p.payload_length + 3) / 4; | ||
326 | status = le32_to_cpu(buffer[length]); | ||
327 | |||
328 | p.ack = ((status >> 16) & 0x1f) - 16; | ||
329 | p.speed = (status >> 21) & 0x7; | ||
330 | p.timestamp = status & 0xffff; | ||
331 | p.generation = ohci->request_generation; | ||
332 | |||
333 | /* | ||
334 | * The OHCI bus reset handler synthesizes a phy packet with | ||
335 | * the new generation number when a bus reset happens (see | ||
336 | * section 8.4.2.3). This helps us determine when a request | ||
337 | * was received and make sure we send the response in the same | ||
338 | * generation. We only need this for requests; for responses | ||
339 | * we use the unique tlabel for finding the matching | ||
340 | * request. | ||
341 | */ | ||
342 | |||
343 | if (p.ack + 16 == 0x09) | ||
344 | ohci->request_generation = (buffer[2] >> 16) & 0xff; | ||
345 | else if (ctx == &ohci->ar_request_ctx) | ||
346 | fw_core_handle_request(&ohci->card, &p); | ||
347 | else | ||
348 | fw_core_handle_response(&ohci->card, &p); | ||
349 | |||
350 | return buffer + length + 1; | ||
351 | } | ||
352 | |||
353 | static void ar_context_tasklet(unsigned long data) | ||
354 | { | ||
355 | struct ar_context *ctx = (struct ar_context *)data; | ||
356 | struct fw_ohci *ohci = ctx->ohci; | ||
357 | struct ar_buffer *ab; | ||
358 | struct descriptor *d; | ||
359 | void *buffer, *end; | ||
360 | |||
361 | ab = ctx->current_buffer; | ||
362 | d = &ab->descriptor; | ||
363 | |||
364 | if (d->res_count == 0) { | ||
365 | size_t size, rest, offset; | ||
366 | |||
367 | /* | ||
368 | * This descriptor is finished and we may have a | ||
369 | * packet split across this and the next buffer. We | ||
370 | * reuse the page for reassembling the split packet. | ||
371 | */ | ||
372 | |||
373 | offset = offsetof(struct ar_buffer, data); | ||
374 | dma_unmap_single(ohci->card.device, | ||
375 | ab->descriptor.data_address - offset, | ||
376 | PAGE_SIZE, DMA_BIDIRECTIONAL); | ||
377 | |||
378 | buffer = ab; | ||
379 | ab = ab->next; | ||
380 | d = &ab->descriptor; | ||
381 | size = buffer + PAGE_SIZE - ctx->pointer; | ||
382 | rest = le16_to_cpu(d->req_count) - le16_to_cpu(d->res_count); | ||
383 | memmove(buffer, ctx->pointer, size); | ||
384 | memcpy(buffer + size, ab->data, rest); | ||
385 | ctx->current_buffer = ab; | ||
386 | ctx->pointer = (void *) ab->data + rest; | ||
387 | end = buffer + size + rest; | ||
388 | |||
389 | while (buffer < end) | ||
390 | buffer = handle_ar_packet(ctx, buffer); | ||
391 | |||
392 | free_page((unsigned long)buffer); | ||
393 | ar_context_add_page(ctx); | ||
394 | } else { | ||
395 | buffer = ctx->pointer; | ||
396 | ctx->pointer = end = | ||
397 | (void *) ab + PAGE_SIZE - le16_to_cpu(d->res_count); | ||
398 | |||
399 | while (buffer < end) | ||
400 | buffer = handle_ar_packet(ctx, buffer); | ||
401 | } | ||
402 | } | ||
403 | |||
404 | static int | ||
405 | ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 regs) | ||
406 | { | ||
407 | struct ar_buffer ab; | ||
408 | |||
409 | ctx->regs = regs; | ||
410 | ctx->ohci = ohci; | ||
411 | ctx->last_buffer = &ab; | ||
412 | tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx); | ||
413 | |||
414 | ar_context_add_page(ctx); | ||
415 | ar_context_add_page(ctx); | ||
416 | ctx->current_buffer = ab.next; | ||
417 | ctx->pointer = ctx->current_buffer->data; | ||
418 | |||
419 | reg_write(ctx->ohci, COMMAND_PTR(ctx->regs), ab.descriptor.branch_address); | ||
420 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN); | ||
421 | flush_writes(ctx->ohci); | ||
422 | |||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | static void context_tasklet(unsigned long data) | ||
427 | { | ||
428 | struct context *ctx = (struct context *) data; | ||
429 | struct fw_ohci *ohci = ctx->ohci; | ||
430 | struct descriptor *d, *last; | ||
431 | u32 address; | ||
432 | int z; | ||
433 | |||
434 | dma_sync_single_for_cpu(ohci->card.device, ctx->buffer_bus, | ||
435 | ctx->buffer_size, DMA_TO_DEVICE); | ||
436 | |||
437 | d = ctx->tail_descriptor; | ||
438 | last = ctx->tail_descriptor_last; | ||
439 | |||
440 | while (last->branch_address != 0) { | ||
441 | address = le32_to_cpu(last->branch_address); | ||
442 | z = address & 0xf; | ||
443 | d = ctx->buffer + (address - ctx->buffer_bus) / sizeof(*d); | ||
444 | last = (z == 2) ? d : d + z - 1; | ||
445 | |||
446 | if (!ctx->callback(ctx, d, last)) | ||
447 | break; | ||
448 | |||
449 | ctx->tail_descriptor = d; | ||
450 | ctx->tail_descriptor_last = last; | ||
451 | } | ||
452 | } | ||
453 | |||
454 | static int | ||
455 | context_init(struct context *ctx, struct fw_ohci *ohci, | ||
456 | size_t buffer_size, u32 regs, | ||
457 | descriptor_callback_t callback) | ||
458 | { | ||
459 | ctx->ohci = ohci; | ||
460 | ctx->regs = regs; | ||
461 | ctx->buffer_size = buffer_size; | ||
462 | ctx->buffer = kmalloc(buffer_size, GFP_KERNEL); | ||
463 | if (ctx->buffer == NULL) | ||
464 | return -ENOMEM; | ||
465 | |||
466 | tasklet_init(&ctx->tasklet, context_tasklet, (unsigned long)ctx); | ||
467 | ctx->callback = callback; | ||
468 | |||
469 | ctx->buffer_bus = | ||
470 | dma_map_single(ohci->card.device, ctx->buffer, | ||
471 | buffer_size, DMA_TO_DEVICE); | ||
472 | if (dma_mapping_error(ctx->buffer_bus)) { | ||
473 | kfree(ctx->buffer); | ||
474 | return -ENOMEM; | ||
475 | } | ||
476 | |||
477 | ctx->head_descriptor = ctx->buffer; | ||
478 | ctx->prev_descriptor = ctx->buffer; | ||
479 | ctx->tail_descriptor = ctx->buffer; | ||
480 | ctx->tail_descriptor_last = ctx->buffer; | ||
481 | |||
482 | /* | ||
483 | * We put a dummy descriptor in the buffer that has a NULL | ||
484 | * branch address and looks like it's been sent. That way we | ||
485 | * have a descriptor to append DMA programs to. Also, the | ||
486 | * ring buffer invariant is that it always has at least one | ||
487 | * element so that head == tail means buffer full. | ||
488 | */ | ||
489 | |||
490 | memset(ctx->head_descriptor, 0, sizeof(*ctx->head_descriptor)); | ||
491 | ctx->head_descriptor->control = cpu_to_le16(DESCRIPTOR_OUTPUT_LAST); | ||
492 | ctx->head_descriptor->transfer_status = cpu_to_le16(0x8011); | ||
493 | ctx->head_descriptor++; | ||
494 | |||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | static void | ||
499 | context_release(struct context *ctx) | ||
500 | { | ||
501 | struct fw_card *card = &ctx->ohci->card; | ||
502 | |||
503 | dma_unmap_single(card->device, ctx->buffer_bus, | ||
504 | ctx->buffer_size, DMA_TO_DEVICE); | ||
505 | kfree(ctx->buffer); | ||
506 | } | ||
507 | |||
508 | static struct descriptor * | ||
509 | context_get_descriptors(struct context *ctx, int z, dma_addr_t *d_bus) | ||
510 | { | ||
511 | struct descriptor *d, *tail, *end; | ||
512 | |||
513 | d = ctx->head_descriptor; | ||
514 | tail = ctx->tail_descriptor; | ||
515 | end = ctx->buffer + ctx->buffer_size / sizeof(*d); | ||
516 | |||
517 | if (d + z <= tail) { | ||
518 | goto has_space; | ||
519 | } else if (d > tail && d + z <= end) { | ||
520 | goto has_space; | ||
521 | } else if (d > tail && ctx->buffer + z <= tail) { | ||
522 | d = ctx->buffer; | ||
523 | goto has_space; | ||
524 | } | ||
525 | |||
526 | return NULL; | ||
527 | |||
528 | has_space: | ||
529 | memset(d, 0, z * sizeof(*d)); | ||
530 | *d_bus = ctx->buffer_bus + (d - ctx->buffer) * sizeof(*d); | ||
531 | |||
532 | return d; | ||
533 | } | ||
534 | |||
535 | static void context_run(struct context *ctx, u32 extra) | ||
536 | { | ||
537 | struct fw_ohci *ohci = ctx->ohci; | ||
538 | |||
539 | reg_write(ohci, COMMAND_PTR(ctx->regs), | ||
540 | le32_to_cpu(ctx->tail_descriptor_last->branch_address)); | ||
541 | reg_write(ohci, CONTROL_CLEAR(ctx->regs), ~0); | ||
542 | reg_write(ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN | extra); | ||
543 | flush_writes(ohci); | ||
544 | } | ||
545 | |||
546 | static void context_append(struct context *ctx, | ||
547 | struct descriptor *d, int z, int extra) | ||
548 | { | ||
549 | dma_addr_t d_bus; | ||
550 | |||
551 | d_bus = ctx->buffer_bus + (d - ctx->buffer) * sizeof(*d); | ||
552 | |||
553 | ctx->head_descriptor = d + z + extra; | ||
554 | ctx->prev_descriptor->branch_address = cpu_to_le32(d_bus | z); | ||
555 | ctx->prev_descriptor = z == 2 ? d : d + z - 1; | ||
556 | |||
557 | dma_sync_single_for_device(ctx->ohci->card.device, ctx->buffer_bus, | ||
558 | ctx->buffer_size, DMA_TO_DEVICE); | ||
559 | |||
560 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); | ||
561 | flush_writes(ctx->ohci); | ||
562 | } | ||
563 | |||
564 | static void context_stop(struct context *ctx) | ||
565 | { | ||
566 | u32 reg; | ||
567 | int i; | ||
568 | |||
569 | reg_write(ctx->ohci, CONTROL_CLEAR(ctx->regs), CONTEXT_RUN); | ||
570 | flush_writes(ctx->ohci); | ||
571 | |||
572 | for (i = 0; i < 10; i++) { | ||
573 | reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); | ||
574 | if ((reg & CONTEXT_ACTIVE) == 0) | ||
575 | break; | ||
576 | |||
577 | fw_notify("context_stop: still active (0x%08x)\n", reg); | ||
578 | msleep(1); | ||
579 | } | ||
580 | } | ||
581 | |||
582 | struct driver_data { | ||
583 | struct fw_packet *packet; | ||
584 | }; | ||
585 | |||
586 | /* | ||
587 | * This function apppends a packet to the DMA queue for transmission. | ||
588 | * Must always be called with the ochi->lock held to ensure proper | ||
589 | * generation handling and locking around packet queue manipulation. | ||
590 | */ | ||
591 | static int | ||
592 | at_context_queue_packet(struct context *ctx, struct fw_packet *packet) | ||
593 | { | ||
594 | struct fw_ohci *ohci = ctx->ohci; | ||
595 | dma_addr_t d_bus, payload_bus; | ||
596 | struct driver_data *driver_data; | ||
597 | struct descriptor *d, *last; | ||
598 | __le32 *header; | ||
599 | int z, tcode; | ||
600 | u32 reg; | ||
601 | |||
602 | d = context_get_descriptors(ctx, 4, &d_bus); | ||
603 | if (d == NULL) { | ||
604 | packet->ack = RCODE_SEND_ERROR; | ||
605 | return -1; | ||
606 | } | ||
607 | |||
608 | d[0].control = cpu_to_le16(DESCRIPTOR_KEY_IMMEDIATE); | ||
609 | d[0].res_count = cpu_to_le16(packet->timestamp); | ||
610 | |||
611 | /* | ||
612 | * The DMA format for asyncronous link packets is different | ||
613 | * from the IEEE1394 layout, so shift the fields around | ||
614 | * accordingly. If header_length is 8, it's a PHY packet, to | ||
615 | * which we need to prepend an extra quadlet. | ||
616 | */ | ||
617 | |||
618 | header = (__le32 *) &d[1]; | ||
619 | if (packet->header_length > 8) { | ||
620 | header[0] = cpu_to_le32((packet->header[0] & 0xffff) | | ||
621 | (packet->speed << 16)); | ||
622 | header[1] = cpu_to_le32((packet->header[1] & 0xffff) | | ||
623 | (packet->header[0] & 0xffff0000)); | ||
624 | header[2] = cpu_to_le32(packet->header[2]); | ||
625 | |||
626 | tcode = (packet->header[0] >> 4) & 0x0f; | ||
627 | if (TCODE_IS_BLOCK_PACKET(tcode)) | ||
628 | header[3] = cpu_to_le32(packet->header[3]); | ||
629 | else | ||
630 | header[3] = (__force __le32) packet->header[3]; | ||
631 | |||
632 | d[0].req_count = cpu_to_le16(packet->header_length); | ||
633 | } else { | ||
634 | header[0] = cpu_to_le32((OHCI1394_phy_tcode << 4) | | ||
635 | (packet->speed << 16)); | ||
636 | header[1] = cpu_to_le32(packet->header[0]); | ||
637 | header[2] = cpu_to_le32(packet->header[1]); | ||
638 | d[0].req_count = cpu_to_le16(12); | ||
639 | } | ||
640 | |||
641 | driver_data = (struct driver_data *) &d[3]; | ||
642 | driver_data->packet = packet; | ||
643 | packet->driver_data = driver_data; | ||
644 | |||
645 | if (packet->payload_length > 0) { | ||
646 | payload_bus = | ||
647 | dma_map_single(ohci->card.device, packet->payload, | ||
648 | packet->payload_length, DMA_TO_DEVICE); | ||
649 | if (dma_mapping_error(payload_bus)) { | ||
650 | packet->ack = RCODE_SEND_ERROR; | ||
651 | return -1; | ||
652 | } | ||
653 | |||
654 | d[2].req_count = cpu_to_le16(packet->payload_length); | ||
655 | d[2].data_address = cpu_to_le32(payload_bus); | ||
656 | last = &d[2]; | ||
657 | z = 3; | ||
658 | } else { | ||
659 | last = &d[0]; | ||
660 | z = 2; | ||
661 | } | ||
662 | |||
663 | last->control |= cpu_to_le16(DESCRIPTOR_OUTPUT_LAST | | ||
664 | DESCRIPTOR_IRQ_ALWAYS | | ||
665 | DESCRIPTOR_BRANCH_ALWAYS); | ||
666 | |||
667 | /* FIXME: Document how the locking works. */ | ||
668 | if (ohci->generation != packet->generation) { | ||
669 | packet->ack = RCODE_GENERATION; | ||
670 | return -1; | ||
671 | } | ||
672 | |||
673 | context_append(ctx, d, z, 4 - z); | ||
674 | |||
675 | /* If the context isn't already running, start it up. */ | ||
676 | reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); | ||
677 | if ((reg & CONTEXT_RUN) == 0) | ||
678 | context_run(ctx, 0); | ||
679 | |||
680 | return 0; | ||
681 | } | ||
682 | |||
683 | static int handle_at_packet(struct context *context, | ||
684 | struct descriptor *d, | ||
685 | struct descriptor *last) | ||
686 | { | ||
687 | struct driver_data *driver_data; | ||
688 | struct fw_packet *packet; | ||
689 | struct fw_ohci *ohci = context->ohci; | ||
690 | dma_addr_t payload_bus; | ||
691 | int evt; | ||
692 | |||
693 | if (last->transfer_status == 0) | ||
694 | /* This descriptor isn't done yet, stop iteration. */ | ||
695 | return 0; | ||
696 | |||
697 | driver_data = (struct driver_data *) &d[3]; | ||
698 | packet = driver_data->packet; | ||
699 | if (packet == NULL) | ||
700 | /* This packet was cancelled, just continue. */ | ||
701 | return 1; | ||
702 | |||
703 | payload_bus = le32_to_cpu(last->data_address); | ||
704 | if (payload_bus != 0) | ||
705 | dma_unmap_single(ohci->card.device, payload_bus, | ||
706 | packet->payload_length, DMA_TO_DEVICE); | ||
707 | |||
708 | evt = le16_to_cpu(last->transfer_status) & 0x1f; | ||
709 | packet->timestamp = le16_to_cpu(last->res_count); | ||
710 | |||
711 | switch (evt) { | ||
712 | case OHCI1394_evt_timeout: | ||
713 | /* Async response transmit timed out. */ | ||
714 | packet->ack = RCODE_CANCELLED; | ||
715 | break; | ||
716 | |||
717 | case OHCI1394_evt_flushed: | ||
718 | /* | ||
719 | * The packet was flushed should give same error as | ||
720 | * when we try to use a stale generation count. | ||
721 | */ | ||
722 | packet->ack = RCODE_GENERATION; | ||
723 | break; | ||
724 | |||
725 | case OHCI1394_evt_missing_ack: | ||
726 | /* | ||
727 | * Using a valid (current) generation count, but the | ||
728 | * node is not on the bus or not sending acks. | ||
729 | */ | ||
730 | packet->ack = RCODE_NO_ACK; | ||
731 | break; | ||
732 | |||
733 | case ACK_COMPLETE + 0x10: | ||
734 | case ACK_PENDING + 0x10: | ||
735 | case ACK_BUSY_X + 0x10: | ||
736 | case ACK_BUSY_A + 0x10: | ||
737 | case ACK_BUSY_B + 0x10: | ||
738 | case ACK_DATA_ERROR + 0x10: | ||
739 | case ACK_TYPE_ERROR + 0x10: | ||
740 | packet->ack = evt - 0x10; | ||
741 | break; | ||
742 | |||
743 | default: | ||
744 | packet->ack = RCODE_SEND_ERROR; | ||
745 | break; | ||
746 | } | ||
747 | |||
748 | packet->callback(packet, &ohci->card, packet->ack); | ||
749 | |||
750 | return 1; | ||
751 | } | ||
752 | |||
753 | #define HEADER_GET_DESTINATION(q) (((q) >> 16) & 0xffff) | ||
754 | #define HEADER_GET_TCODE(q) (((q) >> 4) & 0x0f) | ||
755 | #define HEADER_GET_OFFSET_HIGH(q) (((q) >> 0) & 0xffff) | ||
756 | #define HEADER_GET_DATA_LENGTH(q) (((q) >> 16) & 0xffff) | ||
757 | #define HEADER_GET_EXTENDED_TCODE(q) (((q) >> 0) & 0xffff) | ||
758 | |||
759 | static void | ||
760 | handle_local_rom(struct fw_ohci *ohci, struct fw_packet *packet, u32 csr) | ||
761 | { | ||
762 | struct fw_packet response; | ||
763 | int tcode, length, i; | ||
764 | |||
765 | tcode = HEADER_GET_TCODE(packet->header[0]); | ||
766 | if (TCODE_IS_BLOCK_PACKET(tcode)) | ||
767 | length = HEADER_GET_DATA_LENGTH(packet->header[3]); | ||
768 | else | ||
769 | length = 4; | ||
770 | |||
771 | i = csr - CSR_CONFIG_ROM; | ||
772 | if (i + length > CONFIG_ROM_SIZE) { | ||
773 | fw_fill_response(&response, packet->header, | ||
774 | RCODE_ADDRESS_ERROR, NULL, 0); | ||
775 | } else if (!TCODE_IS_READ_REQUEST(tcode)) { | ||
776 | fw_fill_response(&response, packet->header, | ||
777 | RCODE_TYPE_ERROR, NULL, 0); | ||
778 | } else { | ||
779 | fw_fill_response(&response, packet->header, RCODE_COMPLETE, | ||
780 | (void *) ohci->config_rom + i, length); | ||
781 | } | ||
782 | |||
783 | fw_core_handle_response(&ohci->card, &response); | ||
784 | } | ||
785 | |||
786 | static void | ||
787 | handle_local_lock(struct fw_ohci *ohci, struct fw_packet *packet, u32 csr) | ||
788 | { | ||
789 | struct fw_packet response; | ||
790 | int tcode, length, ext_tcode, sel; | ||
791 | __be32 *payload, lock_old; | ||
792 | u32 lock_arg, lock_data; | ||
793 | |||
794 | tcode = HEADER_GET_TCODE(packet->header[0]); | ||
795 | length = HEADER_GET_DATA_LENGTH(packet->header[3]); | ||
796 | payload = packet->payload; | ||
797 | ext_tcode = HEADER_GET_EXTENDED_TCODE(packet->header[3]); | ||
798 | |||
799 | if (tcode == TCODE_LOCK_REQUEST && | ||
800 | ext_tcode == EXTCODE_COMPARE_SWAP && length == 8) { | ||
801 | lock_arg = be32_to_cpu(payload[0]); | ||
802 | lock_data = be32_to_cpu(payload[1]); | ||
803 | } else if (tcode == TCODE_READ_QUADLET_REQUEST) { | ||
804 | lock_arg = 0; | ||
805 | lock_data = 0; | ||
806 | } else { | ||
807 | fw_fill_response(&response, packet->header, | ||
808 | RCODE_TYPE_ERROR, NULL, 0); | ||
809 | goto out; | ||
810 | } | ||
811 | |||
812 | sel = (csr - CSR_BUS_MANAGER_ID) / 4; | ||
813 | reg_write(ohci, OHCI1394_CSRData, lock_data); | ||
814 | reg_write(ohci, OHCI1394_CSRCompareData, lock_arg); | ||
815 | reg_write(ohci, OHCI1394_CSRControl, sel); | ||
816 | |||
817 | if (reg_read(ohci, OHCI1394_CSRControl) & 0x80000000) | ||
818 | lock_old = cpu_to_be32(reg_read(ohci, OHCI1394_CSRData)); | ||
819 | else | ||
820 | fw_notify("swap not done yet\n"); | ||
821 | |||
822 | fw_fill_response(&response, packet->header, | ||
823 | RCODE_COMPLETE, &lock_old, sizeof(lock_old)); | ||
824 | out: | ||
825 | fw_core_handle_response(&ohci->card, &response); | ||
826 | } | ||
827 | |||
828 | static void | ||
829 | handle_local_request(struct context *ctx, struct fw_packet *packet) | ||
830 | { | ||
831 | u64 offset; | ||
832 | u32 csr; | ||
833 | |||
834 | if (ctx == &ctx->ohci->at_request_ctx) { | ||
835 | packet->ack = ACK_PENDING; | ||
836 | packet->callback(packet, &ctx->ohci->card, packet->ack); | ||
837 | } | ||
838 | |||
839 | offset = | ||
840 | ((unsigned long long) | ||
841 | HEADER_GET_OFFSET_HIGH(packet->header[1]) << 32) | | ||
842 | packet->header[2]; | ||
843 | csr = offset - CSR_REGISTER_BASE; | ||
844 | |||
845 | /* Handle config rom reads. */ | ||
846 | if (csr >= CSR_CONFIG_ROM && csr < CSR_CONFIG_ROM_END) | ||
847 | handle_local_rom(ctx->ohci, packet, csr); | ||
848 | else switch (csr) { | ||
849 | case CSR_BUS_MANAGER_ID: | ||
850 | case CSR_BANDWIDTH_AVAILABLE: | ||
851 | case CSR_CHANNELS_AVAILABLE_HI: | ||
852 | case CSR_CHANNELS_AVAILABLE_LO: | ||
853 | handle_local_lock(ctx->ohci, packet, csr); | ||
854 | break; | ||
855 | default: | ||
856 | if (ctx == &ctx->ohci->at_request_ctx) | ||
857 | fw_core_handle_request(&ctx->ohci->card, packet); | ||
858 | else | ||
859 | fw_core_handle_response(&ctx->ohci->card, packet); | ||
860 | break; | ||
861 | } | ||
862 | |||
863 | if (ctx == &ctx->ohci->at_response_ctx) { | ||
864 | packet->ack = ACK_COMPLETE; | ||
865 | packet->callback(packet, &ctx->ohci->card, packet->ack); | ||
866 | } | ||
867 | } | ||
868 | |||
869 | static void | ||
870 | at_context_transmit(struct context *ctx, struct fw_packet *packet) | ||
871 | { | ||
872 | unsigned long flags; | ||
873 | int retval; | ||
874 | |||
875 | spin_lock_irqsave(&ctx->ohci->lock, flags); | ||
876 | |||
877 | if (HEADER_GET_DESTINATION(packet->header[0]) == ctx->ohci->node_id && | ||
878 | ctx->ohci->generation == packet->generation) { | ||
879 | spin_unlock_irqrestore(&ctx->ohci->lock, flags); | ||
880 | handle_local_request(ctx, packet); | ||
881 | return; | ||
882 | } | ||
883 | |||
884 | retval = at_context_queue_packet(ctx, packet); | ||
885 | spin_unlock_irqrestore(&ctx->ohci->lock, flags); | ||
886 | |||
887 | if (retval < 0) | ||
888 | packet->callback(packet, &ctx->ohci->card, packet->ack); | ||
889 | |||
890 | } | ||
891 | |||
892 | static void bus_reset_tasklet(unsigned long data) | ||
893 | { | ||
894 | struct fw_ohci *ohci = (struct fw_ohci *)data; | ||
895 | int self_id_count, i, j, reg; | ||
896 | int generation, new_generation; | ||
897 | unsigned long flags; | ||
898 | |||
899 | reg = reg_read(ohci, OHCI1394_NodeID); | ||
900 | if (!(reg & OHCI1394_NodeID_idValid)) { | ||
901 | fw_error("node ID not valid, new bus reset in progress\n"); | ||
902 | return; | ||
903 | } | ||
904 | ohci->node_id = reg & 0xffff; | ||
905 | |||
906 | /* | ||
907 | * The count in the SelfIDCount register is the number of | ||
908 | * bytes in the self ID receive buffer. Since we also receive | ||
909 | * the inverted quadlets and a header quadlet, we shift one | ||
910 | * bit extra to get the actual number of self IDs. | ||
911 | */ | ||
912 | |||
913 | self_id_count = (reg_read(ohci, OHCI1394_SelfIDCount) >> 3) & 0x3ff; | ||
914 | generation = (le32_to_cpu(ohci->self_id_cpu[0]) >> 16) & 0xff; | ||
915 | |||
916 | for (i = 1, j = 0; j < self_id_count; i += 2, j++) { | ||
917 | if (ohci->self_id_cpu[i] != ~ohci->self_id_cpu[i + 1]) | ||
918 | fw_error("inconsistent self IDs\n"); | ||
919 | ohci->self_id_buffer[j] = le32_to_cpu(ohci->self_id_cpu[i]); | ||
920 | } | ||
921 | |||
922 | /* | ||
923 | * Check the consistency of the self IDs we just read. The | ||
924 | * problem we face is that a new bus reset can start while we | ||
925 | * read out the self IDs from the DMA buffer. If this happens, | ||
926 | * the DMA buffer will be overwritten with new self IDs and we | ||
927 | * will read out inconsistent data. The OHCI specification | ||
928 | * (section 11.2) recommends a technique similar to | ||
929 | * linux/seqlock.h, where we remember the generation of the | ||
930 | * self IDs in the buffer before reading them out and compare | ||
931 | * it to the current generation after reading them out. If | ||
932 | * the two generations match we know we have a consistent set | ||
933 | * of self IDs. | ||
934 | */ | ||
935 | |||
936 | new_generation = (reg_read(ohci, OHCI1394_SelfIDCount) >> 16) & 0xff; | ||
937 | if (new_generation != generation) { | ||
938 | fw_notify("recursive bus reset detected, " | ||
939 | "discarding self ids\n"); | ||
940 | return; | ||
941 | } | ||
942 | |||
943 | /* FIXME: Document how the locking works. */ | ||
944 | spin_lock_irqsave(&ohci->lock, flags); | ||
945 | |||
946 | ohci->generation = generation; | ||
947 | context_stop(&ohci->at_request_ctx); | ||
948 | context_stop(&ohci->at_response_ctx); | ||
949 | reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset); | ||
950 | |||
951 | /* | ||
952 | * This next bit is unrelated to the AT context stuff but we | ||
953 | * have to do it under the spinlock also. If a new config rom | ||
954 | * was set up before this reset, the old one is now no longer | ||
955 | * in use and we can free it. Update the config rom pointers | ||
956 | * to point to the current config rom and clear the | ||
957 | * next_config_rom pointer so a new udpate can take place. | ||
958 | */ | ||
959 | |||
960 | if (ohci->next_config_rom != NULL) { | ||
961 | dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, | ||
962 | ohci->config_rom, ohci->config_rom_bus); | ||
963 | ohci->config_rom = ohci->next_config_rom; | ||
964 | ohci->config_rom_bus = ohci->next_config_rom_bus; | ||
965 | ohci->next_config_rom = NULL; | ||
966 | |||
967 | /* | ||
968 | * Restore config_rom image and manually update | ||
969 | * config_rom registers. Writing the header quadlet | ||
970 | * will indicate that the config rom is ready, so we | ||
971 | * do that last. | ||
972 | */ | ||
973 | reg_write(ohci, OHCI1394_BusOptions, | ||
974 | be32_to_cpu(ohci->config_rom[2])); | ||
975 | ohci->config_rom[0] = cpu_to_be32(ohci->next_header); | ||
976 | reg_write(ohci, OHCI1394_ConfigROMhdr, ohci->next_header); | ||
977 | } | ||
978 | |||
979 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
980 | |||
981 | fw_core_handle_bus_reset(&ohci->card, ohci->node_id, generation, | ||
982 | self_id_count, ohci->self_id_buffer); | ||
983 | } | ||
984 | |||
985 | static irqreturn_t irq_handler(int irq, void *data) | ||
986 | { | ||
987 | struct fw_ohci *ohci = data; | ||
988 | u32 event, iso_event, cycle_time; | ||
989 | int i; | ||
990 | |||
991 | event = reg_read(ohci, OHCI1394_IntEventClear); | ||
992 | |||
993 | if (!event) | ||
994 | return IRQ_NONE; | ||
995 | |||
996 | reg_write(ohci, OHCI1394_IntEventClear, event); | ||
997 | |||
998 | if (event & OHCI1394_selfIDComplete) | ||
999 | tasklet_schedule(&ohci->bus_reset_tasklet); | ||
1000 | |||
1001 | if (event & OHCI1394_RQPkt) | ||
1002 | tasklet_schedule(&ohci->ar_request_ctx.tasklet); | ||
1003 | |||
1004 | if (event & OHCI1394_RSPkt) | ||
1005 | tasklet_schedule(&ohci->ar_response_ctx.tasklet); | ||
1006 | |||
1007 | if (event & OHCI1394_reqTxComplete) | ||
1008 | tasklet_schedule(&ohci->at_request_ctx.tasklet); | ||
1009 | |||
1010 | if (event & OHCI1394_respTxComplete) | ||
1011 | tasklet_schedule(&ohci->at_response_ctx.tasklet); | ||
1012 | |||
1013 | iso_event = reg_read(ohci, OHCI1394_IsoRecvIntEventClear); | ||
1014 | reg_write(ohci, OHCI1394_IsoRecvIntEventClear, iso_event); | ||
1015 | |||
1016 | while (iso_event) { | ||
1017 | i = ffs(iso_event) - 1; | ||
1018 | tasklet_schedule(&ohci->ir_context_list[i].context.tasklet); | ||
1019 | iso_event &= ~(1 << i); | ||
1020 | } | ||
1021 | |||
1022 | iso_event = reg_read(ohci, OHCI1394_IsoXmitIntEventClear); | ||
1023 | reg_write(ohci, OHCI1394_IsoXmitIntEventClear, iso_event); | ||
1024 | |||
1025 | while (iso_event) { | ||
1026 | i = ffs(iso_event) - 1; | ||
1027 | tasklet_schedule(&ohci->it_context_list[i].context.tasklet); | ||
1028 | iso_event &= ~(1 << i); | ||
1029 | } | ||
1030 | |||
1031 | if (event & OHCI1394_cycle64Seconds) { | ||
1032 | cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer); | ||
1033 | if ((cycle_time & 0x80000000) == 0) | ||
1034 | ohci->bus_seconds++; | ||
1035 | } | ||
1036 | |||
1037 | return IRQ_HANDLED; | ||
1038 | } | ||
1039 | |||
1040 | static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) | ||
1041 | { | ||
1042 | struct fw_ohci *ohci = fw_ohci(card); | ||
1043 | struct pci_dev *dev = to_pci_dev(card->device); | ||
1044 | |||
1045 | /* | ||
1046 | * When the link is not yet enabled, the atomic config rom | ||
1047 | * update mechanism described below in ohci_set_config_rom() | ||
1048 | * is not active. We have to update ConfigRomHeader and | ||
1049 | * BusOptions manually, and the write to ConfigROMmap takes | ||
1050 | * effect immediately. We tie this to the enabling of the | ||
1051 | * link, so we have a valid config rom before enabling - the | ||
1052 | * OHCI requires that ConfigROMhdr and BusOptions have valid | ||
1053 | * values before enabling. | ||
1054 | * | ||
1055 | * However, when the ConfigROMmap is written, some controllers | ||
1056 | * always read back quadlets 0 and 2 from the config rom to | ||
1057 | * the ConfigRomHeader and BusOptions registers on bus reset. | ||
1058 | * They shouldn't do that in this initial case where the link | ||
1059 | * isn't enabled. This means we have to use the same | ||
1060 | * workaround here, setting the bus header to 0 and then write | ||
1061 | * the right values in the bus reset tasklet. | ||
1062 | */ | ||
1063 | |||
1064 | ohci->next_config_rom = | ||
1065 | dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, | ||
1066 | &ohci->next_config_rom_bus, GFP_KERNEL); | ||
1067 | if (ohci->next_config_rom == NULL) | ||
1068 | return -ENOMEM; | ||
1069 | |||
1070 | memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); | ||
1071 | fw_memcpy_to_be32(ohci->next_config_rom, config_rom, length * 4); | ||
1072 | |||
1073 | ohci->next_header = config_rom[0]; | ||
1074 | ohci->next_config_rom[0] = 0; | ||
1075 | reg_write(ohci, OHCI1394_ConfigROMhdr, 0); | ||
1076 | reg_write(ohci, OHCI1394_BusOptions, config_rom[2]); | ||
1077 | reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); | ||
1078 | |||
1079 | reg_write(ohci, OHCI1394_AsReqFilterHiSet, 0x80000000); | ||
1080 | |||
1081 | if (request_irq(dev->irq, irq_handler, | ||
1082 | IRQF_SHARED, ohci_driver_name, ohci)) { | ||
1083 | fw_error("Failed to allocate shared interrupt %d.\n", | ||
1084 | dev->irq); | ||
1085 | dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, | ||
1086 | ohci->config_rom, ohci->config_rom_bus); | ||
1087 | return -EIO; | ||
1088 | } | ||
1089 | |||
1090 | reg_write(ohci, OHCI1394_HCControlSet, | ||
1091 | OHCI1394_HCControl_linkEnable | | ||
1092 | OHCI1394_HCControl_BIBimageValid); | ||
1093 | flush_writes(ohci); | ||
1094 | |||
1095 | /* | ||
1096 | * We are ready to go, initiate bus reset to finish the | ||
1097 | * initialization. | ||
1098 | */ | ||
1099 | |||
1100 | fw_core_initiate_bus_reset(&ohci->card, 1); | ||
1101 | |||
1102 | return 0; | ||
1103 | } | ||
1104 | |||
1105 | static int | ||
1106 | ohci_set_config_rom(struct fw_card *card, u32 *config_rom, size_t length) | ||
1107 | { | ||
1108 | struct fw_ohci *ohci; | ||
1109 | unsigned long flags; | ||
1110 | int retval = 0; | ||
1111 | __be32 *next_config_rom; | ||
1112 | dma_addr_t next_config_rom_bus; | ||
1113 | |||
1114 | ohci = fw_ohci(card); | ||
1115 | |||
1116 | /* | ||
1117 | * When the OHCI controller is enabled, the config rom update | ||
1118 | * mechanism is a bit tricky, but easy enough to use. See | ||
1119 | * section 5.5.6 in the OHCI specification. | ||
1120 | * | ||
1121 | * The OHCI controller caches the new config rom address in a | ||
1122 | * shadow register (ConfigROMmapNext) and needs a bus reset | ||
1123 | * for the changes to take place. When the bus reset is | ||
1124 | * detected, the controller loads the new values for the | ||
1125 | * ConfigRomHeader and BusOptions registers from the specified | ||
1126 | * config rom and loads ConfigROMmap from the ConfigROMmapNext | ||
1127 | * shadow register. All automatically and atomically. | ||
1128 | * | ||
1129 | * Now, there's a twist to this story. The automatic load of | ||
1130 | * ConfigRomHeader and BusOptions doesn't honor the | ||
1131 | * noByteSwapData bit, so with a be32 config rom, the | ||
1132 | * controller will load be32 values in to these registers | ||
1133 | * during the atomic update, even on litte endian | ||
1134 | * architectures. The workaround we use is to put a 0 in the | ||
1135 | * header quadlet; 0 is endian agnostic and means that the | ||
1136 | * config rom isn't ready yet. In the bus reset tasklet we | ||
1137 | * then set up the real values for the two registers. | ||
1138 | * | ||
1139 | * We use ohci->lock to avoid racing with the code that sets | ||
1140 | * ohci->next_config_rom to NULL (see bus_reset_tasklet). | ||
1141 | */ | ||
1142 | |||
1143 | next_config_rom = | ||
1144 | dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, | ||
1145 | &next_config_rom_bus, GFP_KERNEL); | ||
1146 | if (next_config_rom == NULL) | ||
1147 | return -ENOMEM; | ||
1148 | |||
1149 | spin_lock_irqsave(&ohci->lock, flags); | ||
1150 | |||
1151 | if (ohci->next_config_rom == NULL) { | ||
1152 | ohci->next_config_rom = next_config_rom; | ||
1153 | ohci->next_config_rom_bus = next_config_rom_bus; | ||
1154 | |||
1155 | memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); | ||
1156 | fw_memcpy_to_be32(ohci->next_config_rom, config_rom, | ||
1157 | length * 4); | ||
1158 | |||
1159 | ohci->next_header = config_rom[0]; | ||
1160 | ohci->next_config_rom[0] = 0; | ||
1161 | |||
1162 | reg_write(ohci, OHCI1394_ConfigROMmap, | ||
1163 | ohci->next_config_rom_bus); | ||
1164 | } else { | ||
1165 | dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, | ||
1166 | next_config_rom, next_config_rom_bus); | ||
1167 | retval = -EBUSY; | ||
1168 | } | ||
1169 | |||
1170 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
1171 | |||
1172 | /* | ||
1173 | * Now initiate a bus reset to have the changes take | ||
1174 | * effect. We clean up the old config rom memory and DMA | ||
1175 | * mappings in the bus reset tasklet, since the OHCI | ||
1176 | * controller could need to access it before the bus reset | ||
1177 | * takes effect. | ||
1178 | */ | ||
1179 | if (retval == 0) | ||
1180 | fw_core_initiate_bus_reset(&ohci->card, 1); | ||
1181 | |||
1182 | return retval; | ||
1183 | } | ||
1184 | |||
1185 | static void ohci_send_request(struct fw_card *card, struct fw_packet *packet) | ||
1186 | { | ||
1187 | struct fw_ohci *ohci = fw_ohci(card); | ||
1188 | |||
1189 | at_context_transmit(&ohci->at_request_ctx, packet); | ||
1190 | } | ||
1191 | |||
1192 | static void ohci_send_response(struct fw_card *card, struct fw_packet *packet) | ||
1193 | { | ||
1194 | struct fw_ohci *ohci = fw_ohci(card); | ||
1195 | |||
1196 | at_context_transmit(&ohci->at_response_ctx, packet); | ||
1197 | } | ||
1198 | |||
1199 | static int ohci_cancel_packet(struct fw_card *card, struct fw_packet *packet) | ||
1200 | { | ||
1201 | struct fw_ohci *ohci = fw_ohci(card); | ||
1202 | struct context *ctx = &ohci->at_request_ctx; | ||
1203 | struct driver_data *driver_data = packet->driver_data; | ||
1204 | int retval = -ENOENT; | ||
1205 | |||
1206 | tasklet_disable(&ctx->tasklet); | ||
1207 | |||
1208 | if (packet->ack != 0) | ||
1209 | goto out; | ||
1210 | |||
1211 | driver_data->packet = NULL; | ||
1212 | packet->ack = RCODE_CANCELLED; | ||
1213 | packet->callback(packet, &ohci->card, packet->ack); | ||
1214 | retval = 0; | ||
1215 | |||
1216 | out: | ||
1217 | tasklet_enable(&ctx->tasklet); | ||
1218 | |||
1219 | return retval; | ||
1220 | } | ||
1221 | |||
1222 | static int | ||
1223 | ohci_enable_phys_dma(struct fw_card *card, int node_id, int generation) | ||
1224 | { | ||
1225 | struct fw_ohci *ohci = fw_ohci(card); | ||
1226 | unsigned long flags; | ||
1227 | int n, retval = 0; | ||
1228 | |||
1229 | /* | ||
1230 | * FIXME: Make sure this bitmask is cleared when we clear the busReset | ||
1231 | * interrupt bit. Clear physReqResourceAllBuses on bus reset. | ||
1232 | */ | ||
1233 | |||
1234 | spin_lock_irqsave(&ohci->lock, flags); | ||
1235 | |||
1236 | if (ohci->generation != generation) { | ||
1237 | retval = -ESTALE; | ||
1238 | goto out; | ||
1239 | } | ||
1240 | |||
1241 | /* | ||
1242 | * Note, if the node ID contains a non-local bus ID, physical DMA is | ||
1243 | * enabled for _all_ nodes on remote buses. | ||
1244 | */ | ||
1245 | |||
1246 | n = (node_id & 0xffc0) == LOCAL_BUS ? node_id & 0x3f : 63; | ||
1247 | if (n < 32) | ||
1248 | reg_write(ohci, OHCI1394_PhyReqFilterLoSet, 1 << n); | ||
1249 | else | ||
1250 | reg_write(ohci, OHCI1394_PhyReqFilterHiSet, 1 << (n - 32)); | ||
1251 | |||
1252 | flush_writes(ohci); | ||
1253 | out: | ||
1254 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
1255 | return retval; | ||
1256 | } | ||
1257 | |||
1258 | static u64 | ||
1259 | ohci_get_bus_time(struct fw_card *card) | ||
1260 | { | ||
1261 | struct fw_ohci *ohci = fw_ohci(card); | ||
1262 | u32 cycle_time; | ||
1263 | u64 bus_time; | ||
1264 | |||
1265 | cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer); | ||
1266 | bus_time = ((u64) ohci->bus_seconds << 32) | cycle_time; | ||
1267 | |||
1268 | return bus_time; | ||
1269 | } | ||
1270 | |||
1271 | static int handle_ir_dualbuffer_packet(struct context *context, | ||
1272 | struct descriptor *d, | ||
1273 | struct descriptor *last) | ||
1274 | { | ||
1275 | struct iso_context *ctx = | ||
1276 | container_of(context, struct iso_context, context); | ||
1277 | struct db_descriptor *db = (struct db_descriptor *) d; | ||
1278 | __le32 *ir_header; | ||
1279 | size_t header_length; | ||
1280 | void *p, *end; | ||
1281 | int i; | ||
1282 | |||
1283 | if (db->first_res_count > 0 && db->second_res_count > 0) | ||
1284 | /* This descriptor isn't done yet, stop iteration. */ | ||
1285 | return 0; | ||
1286 | |||
1287 | header_length = le16_to_cpu(db->first_req_count) - | ||
1288 | le16_to_cpu(db->first_res_count); | ||
1289 | |||
1290 | i = ctx->header_length; | ||
1291 | p = db + 1; | ||
1292 | end = p + header_length; | ||
1293 | while (p < end && i + ctx->base.header_size <= PAGE_SIZE) { | ||
1294 | /* | ||
1295 | * The iso header is byteswapped to little endian by | ||
1296 | * the controller, but the remaining header quadlets | ||
1297 | * are big endian. We want to present all the headers | ||
1298 | * as big endian, so we have to swap the first | ||
1299 | * quadlet. | ||
1300 | */ | ||
1301 | *(u32 *) (ctx->header + i) = __swab32(*(u32 *) (p + 4)); | ||
1302 | memcpy(ctx->header + i + 4, p + 8, ctx->base.header_size - 4); | ||
1303 | i += ctx->base.header_size; | ||
1304 | p += ctx->base.header_size + 4; | ||
1305 | } | ||
1306 | |||
1307 | ctx->header_length = i; | ||
1308 | |||
1309 | if (le16_to_cpu(db->control) & DESCRIPTOR_IRQ_ALWAYS) { | ||
1310 | ir_header = (__le32 *) (db + 1); | ||
1311 | ctx->base.callback(&ctx->base, | ||
1312 | le32_to_cpu(ir_header[0]) & 0xffff, | ||
1313 | ctx->header_length, ctx->header, | ||
1314 | ctx->base.callback_data); | ||
1315 | ctx->header_length = 0; | ||
1316 | } | ||
1317 | |||
1318 | return 1; | ||
1319 | } | ||
1320 | |||
1321 | static int handle_it_packet(struct context *context, | ||
1322 | struct descriptor *d, | ||
1323 | struct descriptor *last) | ||
1324 | { | ||
1325 | struct iso_context *ctx = | ||
1326 | container_of(context, struct iso_context, context); | ||
1327 | |||
1328 | if (last->transfer_status == 0) | ||
1329 | /* This descriptor isn't done yet, stop iteration. */ | ||
1330 | return 0; | ||
1331 | |||
1332 | if (le16_to_cpu(last->control) & DESCRIPTOR_IRQ_ALWAYS) | ||
1333 | ctx->base.callback(&ctx->base, le16_to_cpu(last->res_count), | ||
1334 | 0, NULL, ctx->base.callback_data); | ||
1335 | |||
1336 | return 1; | ||
1337 | } | ||
1338 | |||
1339 | static struct fw_iso_context * | ||
1340 | ohci_allocate_iso_context(struct fw_card *card, int type, size_t header_size) | ||
1341 | { | ||
1342 | struct fw_ohci *ohci = fw_ohci(card); | ||
1343 | struct iso_context *ctx, *list; | ||
1344 | descriptor_callback_t callback; | ||
1345 | u32 *mask, regs; | ||
1346 | unsigned long flags; | ||
1347 | int index, retval = -ENOMEM; | ||
1348 | |||
1349 | if (type == FW_ISO_CONTEXT_TRANSMIT) { | ||
1350 | mask = &ohci->it_context_mask; | ||
1351 | list = ohci->it_context_list; | ||
1352 | callback = handle_it_packet; | ||
1353 | } else { | ||
1354 | mask = &ohci->ir_context_mask; | ||
1355 | list = ohci->ir_context_list; | ||
1356 | callback = handle_ir_dualbuffer_packet; | ||
1357 | } | ||
1358 | |||
1359 | /* FIXME: We need a fallback for pre 1.1 OHCI. */ | ||
1360 | if (callback == handle_ir_dualbuffer_packet && | ||
1361 | ohci->version < OHCI_VERSION_1_1) | ||
1362 | return ERR_PTR(-EINVAL); | ||
1363 | |||
1364 | spin_lock_irqsave(&ohci->lock, flags); | ||
1365 | index = ffs(*mask) - 1; | ||
1366 | if (index >= 0) | ||
1367 | *mask &= ~(1 << index); | ||
1368 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
1369 | |||
1370 | if (index < 0) | ||
1371 | return ERR_PTR(-EBUSY); | ||
1372 | |||
1373 | if (type == FW_ISO_CONTEXT_TRANSMIT) | ||
1374 | regs = OHCI1394_IsoXmitContextBase(index); | ||
1375 | else | ||
1376 | regs = OHCI1394_IsoRcvContextBase(index); | ||
1377 | |||
1378 | ctx = &list[index]; | ||
1379 | memset(ctx, 0, sizeof(*ctx)); | ||
1380 | ctx->header_length = 0; | ||
1381 | ctx->header = (void *) __get_free_page(GFP_KERNEL); | ||
1382 | if (ctx->header == NULL) | ||
1383 | goto out; | ||
1384 | |||
1385 | retval = context_init(&ctx->context, ohci, ISO_BUFFER_SIZE, | ||
1386 | regs, callback); | ||
1387 | if (retval < 0) | ||
1388 | goto out_with_header; | ||
1389 | |||
1390 | return &ctx->base; | ||
1391 | |||
1392 | out_with_header: | ||
1393 | free_page((unsigned long)ctx->header); | ||
1394 | out: | ||
1395 | spin_lock_irqsave(&ohci->lock, flags); | ||
1396 | *mask |= 1 << index; | ||
1397 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
1398 | |||
1399 | return ERR_PTR(retval); | ||
1400 | } | ||
1401 | |||
1402 | static int ohci_start_iso(struct fw_iso_context *base, | ||
1403 | s32 cycle, u32 sync, u32 tags) | ||
1404 | { | ||
1405 | struct iso_context *ctx = container_of(base, struct iso_context, base); | ||
1406 | struct fw_ohci *ohci = ctx->context.ohci; | ||
1407 | u32 control, match; | ||
1408 | int index; | ||
1409 | |||
1410 | if (ctx->base.type == FW_ISO_CONTEXT_TRANSMIT) { | ||
1411 | index = ctx - ohci->it_context_list; | ||
1412 | match = 0; | ||
1413 | if (cycle >= 0) | ||
1414 | match = IT_CONTEXT_CYCLE_MATCH_ENABLE | | ||
1415 | (cycle & 0x7fff) << 16; | ||
1416 | |||
1417 | reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 1 << index); | ||
1418 | reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, 1 << index); | ||
1419 | context_run(&ctx->context, match); | ||
1420 | } else { | ||
1421 | index = ctx - ohci->ir_context_list; | ||
1422 | control = IR_CONTEXT_DUAL_BUFFER_MODE | IR_CONTEXT_ISOCH_HEADER; | ||
1423 | match = (tags << 28) | (sync << 8) | ctx->base.channel; | ||
1424 | if (cycle >= 0) { | ||
1425 | match |= (cycle & 0x07fff) << 12; | ||
1426 | control |= IR_CONTEXT_CYCLE_MATCH_ENABLE; | ||
1427 | } | ||
1428 | |||
1429 | reg_write(ohci, OHCI1394_IsoRecvIntEventClear, 1 << index); | ||
1430 | reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, 1 << index); | ||
1431 | reg_write(ohci, CONTEXT_MATCH(ctx->context.regs), match); | ||
1432 | context_run(&ctx->context, control); | ||
1433 | } | ||
1434 | |||
1435 | return 0; | ||
1436 | } | ||
1437 | |||
1438 | static int ohci_stop_iso(struct fw_iso_context *base) | ||
1439 | { | ||
1440 | struct fw_ohci *ohci = fw_ohci(base->card); | ||
1441 | struct iso_context *ctx = container_of(base, struct iso_context, base); | ||
1442 | int index; | ||
1443 | |||
1444 | if (ctx->base.type == FW_ISO_CONTEXT_TRANSMIT) { | ||
1445 | index = ctx - ohci->it_context_list; | ||
1446 | reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, 1 << index); | ||
1447 | } else { | ||
1448 | index = ctx - ohci->ir_context_list; | ||
1449 | reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, 1 << index); | ||
1450 | } | ||
1451 | flush_writes(ohci); | ||
1452 | context_stop(&ctx->context); | ||
1453 | |||
1454 | return 0; | ||
1455 | } | ||
1456 | |||
1457 | static void ohci_free_iso_context(struct fw_iso_context *base) | ||
1458 | { | ||
1459 | struct fw_ohci *ohci = fw_ohci(base->card); | ||
1460 | struct iso_context *ctx = container_of(base, struct iso_context, base); | ||
1461 | unsigned long flags; | ||
1462 | int index; | ||
1463 | |||
1464 | ohci_stop_iso(base); | ||
1465 | context_release(&ctx->context); | ||
1466 | free_page((unsigned long)ctx->header); | ||
1467 | |||
1468 | spin_lock_irqsave(&ohci->lock, flags); | ||
1469 | |||
1470 | if (ctx->base.type == FW_ISO_CONTEXT_TRANSMIT) { | ||
1471 | index = ctx - ohci->it_context_list; | ||
1472 | ohci->it_context_mask |= 1 << index; | ||
1473 | } else { | ||
1474 | index = ctx - ohci->ir_context_list; | ||
1475 | ohci->ir_context_mask |= 1 << index; | ||
1476 | } | ||
1477 | |||
1478 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
1479 | } | ||
1480 | |||
1481 | static int | ||
1482 | ohci_queue_iso_transmit(struct fw_iso_context *base, | ||
1483 | struct fw_iso_packet *packet, | ||
1484 | struct fw_iso_buffer *buffer, | ||
1485 | unsigned long payload) | ||
1486 | { | ||
1487 | struct iso_context *ctx = container_of(base, struct iso_context, base); | ||
1488 | struct descriptor *d, *last, *pd; | ||
1489 | struct fw_iso_packet *p; | ||
1490 | __le32 *header; | ||
1491 | dma_addr_t d_bus, page_bus; | ||
1492 | u32 z, header_z, payload_z, irq; | ||
1493 | u32 payload_index, payload_end_index, next_page_index; | ||
1494 | int page, end_page, i, length, offset; | ||
1495 | |||
1496 | /* | ||
1497 | * FIXME: Cycle lost behavior should be configurable: lose | ||
1498 | * packet, retransmit or terminate.. | ||
1499 | */ | ||
1500 | |||
1501 | p = packet; | ||
1502 | payload_index = payload; | ||
1503 | |||
1504 | if (p->skip) | ||
1505 | z = 1; | ||
1506 | else | ||
1507 | z = 2; | ||
1508 | if (p->header_length > 0) | ||
1509 | z++; | ||
1510 | |||
1511 | /* Determine the first page the payload isn't contained in. */ | ||
1512 | end_page = PAGE_ALIGN(payload_index + p->payload_length) >> PAGE_SHIFT; | ||
1513 | if (p->payload_length > 0) | ||
1514 | payload_z = end_page - (payload_index >> PAGE_SHIFT); | ||
1515 | else | ||
1516 | payload_z = 0; | ||
1517 | |||
1518 | z += payload_z; | ||
1519 | |||
1520 | /* Get header size in number of descriptors. */ | ||
1521 | header_z = DIV_ROUND_UP(p->header_length, sizeof(*d)); | ||
1522 | |||
1523 | d = context_get_descriptors(&ctx->context, z + header_z, &d_bus); | ||
1524 | if (d == NULL) | ||
1525 | return -ENOMEM; | ||
1526 | |||
1527 | if (!p->skip) { | ||
1528 | d[0].control = cpu_to_le16(DESCRIPTOR_KEY_IMMEDIATE); | ||
1529 | d[0].req_count = cpu_to_le16(8); | ||
1530 | |||
1531 | header = (__le32 *) &d[1]; | ||
1532 | header[0] = cpu_to_le32(IT_HEADER_SY(p->sy) | | ||
1533 | IT_HEADER_TAG(p->tag) | | ||
1534 | IT_HEADER_TCODE(TCODE_STREAM_DATA) | | ||
1535 | IT_HEADER_CHANNEL(ctx->base.channel) | | ||
1536 | IT_HEADER_SPEED(ctx->base.speed)); | ||
1537 | header[1] = | ||
1538 | cpu_to_le32(IT_HEADER_DATA_LENGTH(p->header_length + | ||
1539 | p->payload_length)); | ||
1540 | } | ||
1541 | |||
1542 | if (p->header_length > 0) { | ||
1543 | d[2].req_count = cpu_to_le16(p->header_length); | ||
1544 | d[2].data_address = cpu_to_le32(d_bus + z * sizeof(*d)); | ||
1545 | memcpy(&d[z], p->header, p->header_length); | ||
1546 | } | ||
1547 | |||
1548 | pd = d + z - payload_z; | ||
1549 | payload_end_index = payload_index + p->payload_length; | ||
1550 | for (i = 0; i < payload_z; i++) { | ||
1551 | page = payload_index >> PAGE_SHIFT; | ||
1552 | offset = payload_index & ~PAGE_MASK; | ||
1553 | next_page_index = (page + 1) << PAGE_SHIFT; | ||
1554 | length = | ||
1555 | min(next_page_index, payload_end_index) - payload_index; | ||
1556 | pd[i].req_count = cpu_to_le16(length); | ||
1557 | |||
1558 | page_bus = page_private(buffer->pages[page]); | ||
1559 | pd[i].data_address = cpu_to_le32(page_bus + offset); | ||
1560 | |||
1561 | payload_index += length; | ||
1562 | } | ||
1563 | |||
1564 | if (p->interrupt) | ||
1565 | irq = DESCRIPTOR_IRQ_ALWAYS; | ||
1566 | else | ||
1567 | irq = DESCRIPTOR_NO_IRQ; | ||
1568 | |||
1569 | last = z == 2 ? d : d + z - 1; | ||
1570 | last->control |= cpu_to_le16(DESCRIPTOR_OUTPUT_LAST | | ||
1571 | DESCRIPTOR_STATUS | | ||
1572 | DESCRIPTOR_BRANCH_ALWAYS | | ||
1573 | irq); | ||
1574 | |||
1575 | context_append(&ctx->context, d, z, header_z); | ||
1576 | |||
1577 | return 0; | ||
1578 | } | ||
1579 | |||
1580 | static int | ||
1581 | ohci_queue_iso_receive_dualbuffer(struct fw_iso_context *base, | ||
1582 | struct fw_iso_packet *packet, | ||
1583 | struct fw_iso_buffer *buffer, | ||
1584 | unsigned long payload) | ||
1585 | { | ||
1586 | struct iso_context *ctx = container_of(base, struct iso_context, base); | ||
1587 | struct db_descriptor *db = NULL; | ||
1588 | struct descriptor *d; | ||
1589 | struct fw_iso_packet *p; | ||
1590 | dma_addr_t d_bus, page_bus; | ||
1591 | u32 z, header_z, length, rest; | ||
1592 | int page, offset, packet_count, header_size; | ||
1593 | |||
1594 | /* | ||
1595 | * FIXME: Cycle lost behavior should be configurable: lose | ||
1596 | * packet, retransmit or terminate.. | ||
1597 | */ | ||
1598 | |||
1599 | if (packet->skip) { | ||
1600 | d = context_get_descriptors(&ctx->context, 2, &d_bus); | ||
1601 | if (d == NULL) | ||
1602 | return -ENOMEM; | ||
1603 | |||
1604 | db = (struct db_descriptor *) d; | ||
1605 | db->control = cpu_to_le16(DESCRIPTOR_STATUS | | ||
1606 | DESCRIPTOR_BRANCH_ALWAYS | | ||
1607 | DESCRIPTOR_WAIT); | ||
1608 | db->first_size = cpu_to_le16(ctx->base.header_size + 4); | ||
1609 | context_append(&ctx->context, d, 2, 0); | ||
1610 | } | ||
1611 | |||
1612 | p = packet; | ||
1613 | z = 2; | ||
1614 | |||
1615 | /* | ||
1616 | * The OHCI controller puts the status word in the header | ||
1617 | * buffer too, so we need 4 extra bytes per packet. | ||
1618 | */ | ||
1619 | packet_count = p->header_length / ctx->base.header_size; | ||
1620 | header_size = packet_count * (ctx->base.header_size + 4); | ||
1621 | |||
1622 | /* Get header size in number of descriptors. */ | ||
1623 | header_z = DIV_ROUND_UP(header_size, sizeof(*d)); | ||
1624 | page = payload >> PAGE_SHIFT; | ||
1625 | offset = payload & ~PAGE_MASK; | ||
1626 | rest = p->payload_length; | ||
1627 | |||
1628 | /* FIXME: OHCI 1.0 doesn't support dual buffer receive */ | ||
1629 | /* FIXME: make packet-per-buffer/dual-buffer a context option */ | ||
1630 | while (rest > 0) { | ||
1631 | d = context_get_descriptors(&ctx->context, | ||
1632 | z + header_z, &d_bus); | ||
1633 | if (d == NULL) | ||
1634 | return -ENOMEM; | ||
1635 | |||
1636 | db = (struct db_descriptor *) d; | ||
1637 | db->control = cpu_to_le16(DESCRIPTOR_STATUS | | ||
1638 | DESCRIPTOR_BRANCH_ALWAYS); | ||
1639 | db->first_size = cpu_to_le16(ctx->base.header_size + 4); | ||
1640 | db->first_req_count = cpu_to_le16(header_size); | ||
1641 | db->first_res_count = db->first_req_count; | ||
1642 | db->first_buffer = cpu_to_le32(d_bus + sizeof(*db)); | ||
1643 | |||
1644 | if (offset + rest < PAGE_SIZE) | ||
1645 | length = rest; | ||
1646 | else | ||
1647 | length = PAGE_SIZE - offset; | ||
1648 | |||
1649 | db->second_req_count = cpu_to_le16(length); | ||
1650 | db->second_res_count = db->second_req_count; | ||
1651 | page_bus = page_private(buffer->pages[page]); | ||
1652 | db->second_buffer = cpu_to_le32(page_bus + offset); | ||
1653 | |||
1654 | if (p->interrupt && length == rest) | ||
1655 | db->control |= cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS); | ||
1656 | |||
1657 | context_append(&ctx->context, d, z, header_z); | ||
1658 | offset = (offset + length) & ~PAGE_MASK; | ||
1659 | rest -= length; | ||
1660 | page++; | ||
1661 | } | ||
1662 | |||
1663 | return 0; | ||
1664 | } | ||
1665 | |||
1666 | static int | ||
1667 | ohci_queue_iso(struct fw_iso_context *base, | ||
1668 | struct fw_iso_packet *packet, | ||
1669 | struct fw_iso_buffer *buffer, | ||
1670 | unsigned long payload) | ||
1671 | { | ||
1672 | struct iso_context *ctx = container_of(base, struct iso_context, base); | ||
1673 | |||
1674 | if (base->type == FW_ISO_CONTEXT_TRANSMIT) | ||
1675 | return ohci_queue_iso_transmit(base, packet, buffer, payload); | ||
1676 | else if (ctx->context.ohci->version >= OHCI_VERSION_1_1) | ||
1677 | return ohci_queue_iso_receive_dualbuffer(base, packet, | ||
1678 | buffer, payload); | ||
1679 | else | ||
1680 | /* FIXME: Implement fallback for OHCI 1.0 controllers. */ | ||
1681 | return -EINVAL; | ||
1682 | } | ||
1683 | |||
1684 | static const struct fw_card_driver ohci_driver = { | ||
1685 | .name = ohci_driver_name, | ||
1686 | .enable = ohci_enable, | ||
1687 | .update_phy_reg = ohci_update_phy_reg, | ||
1688 | .set_config_rom = ohci_set_config_rom, | ||
1689 | .send_request = ohci_send_request, | ||
1690 | .send_response = ohci_send_response, | ||
1691 | .cancel_packet = ohci_cancel_packet, | ||
1692 | .enable_phys_dma = ohci_enable_phys_dma, | ||
1693 | .get_bus_time = ohci_get_bus_time, | ||
1694 | |||
1695 | .allocate_iso_context = ohci_allocate_iso_context, | ||
1696 | .free_iso_context = ohci_free_iso_context, | ||
1697 | .queue_iso = ohci_queue_iso, | ||
1698 | .start_iso = ohci_start_iso, | ||
1699 | .stop_iso = ohci_stop_iso, | ||
1700 | }; | ||
1701 | |||
1702 | static int software_reset(struct fw_ohci *ohci) | ||
1703 | { | ||
1704 | int i; | ||
1705 | |||
1706 | reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset); | ||
1707 | |||
1708 | for (i = 0; i < OHCI_LOOP_COUNT; i++) { | ||
1709 | if ((reg_read(ohci, OHCI1394_HCControlSet) & | ||
1710 | OHCI1394_HCControl_softReset) == 0) | ||
1711 | return 0; | ||
1712 | msleep(1); | ||
1713 | } | ||
1714 | |||
1715 | return -EBUSY; | ||
1716 | } | ||
1717 | |||
1718 | static int __devinit | ||
1719 | pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) | ||
1720 | { | ||
1721 | struct fw_ohci *ohci; | ||
1722 | u32 bus_options, max_receive, link_speed; | ||
1723 | u64 guid; | ||
1724 | int err; | ||
1725 | size_t size; | ||
1726 | |||
1727 | ohci = kzalloc(sizeof(*ohci), GFP_KERNEL); | ||
1728 | if (ohci == NULL) { | ||
1729 | fw_error("Could not malloc fw_ohci data.\n"); | ||
1730 | return -ENOMEM; | ||
1731 | } | ||
1732 | |||
1733 | fw_card_initialize(&ohci->card, &ohci_driver, &dev->dev); | ||
1734 | |||
1735 | err = pci_enable_device(dev); | ||
1736 | if (err) { | ||
1737 | fw_error("Failed to enable OHCI hardware.\n"); | ||
1738 | goto fail_put_card; | ||
1739 | } | ||
1740 | |||
1741 | pci_set_master(dev); | ||
1742 | pci_write_config_dword(dev, OHCI1394_PCI_HCI_Control, 0); | ||
1743 | pci_set_drvdata(dev, ohci); | ||
1744 | |||
1745 | spin_lock_init(&ohci->lock); | ||
1746 | |||
1747 | tasklet_init(&ohci->bus_reset_tasklet, | ||
1748 | bus_reset_tasklet, (unsigned long)ohci); | ||
1749 | |||
1750 | err = pci_request_region(dev, 0, ohci_driver_name); | ||
1751 | if (err) { | ||
1752 | fw_error("MMIO resource unavailable\n"); | ||
1753 | goto fail_disable; | ||
1754 | } | ||
1755 | |||
1756 | ohci->registers = pci_iomap(dev, 0, OHCI1394_REGISTER_SIZE); | ||
1757 | if (ohci->registers == NULL) { | ||
1758 | fw_error("Failed to remap registers\n"); | ||
1759 | err = -ENXIO; | ||
1760 | goto fail_iomem; | ||
1761 | } | ||
1762 | |||
1763 | if (software_reset(ohci)) { | ||
1764 | fw_error("Failed to reset ohci card.\n"); | ||
1765 | err = -EBUSY; | ||
1766 | goto fail_registers; | ||
1767 | } | ||
1768 | |||
1769 | /* | ||
1770 | * Now enable LPS, which we need in order to start accessing | ||
1771 | * most of the registers. In fact, on some cards (ALI M5251), | ||
1772 | * accessing registers in the SClk domain without LPS enabled | ||
1773 | * will lock up the machine. Wait 50msec to make sure we have | ||
1774 | * full link enabled. | ||
1775 | */ | ||
1776 | reg_write(ohci, OHCI1394_HCControlSet, | ||
1777 | OHCI1394_HCControl_LPS | | ||
1778 | OHCI1394_HCControl_postedWriteEnable); | ||
1779 | flush_writes(ohci); | ||
1780 | msleep(50); | ||
1781 | |||
1782 | reg_write(ohci, OHCI1394_HCControlClear, | ||
1783 | OHCI1394_HCControl_noByteSwapData); | ||
1784 | |||
1785 | reg_write(ohci, OHCI1394_LinkControlSet, | ||
1786 | OHCI1394_LinkControl_rcvSelfID | | ||
1787 | OHCI1394_LinkControl_cycleTimerEnable | | ||
1788 | OHCI1394_LinkControl_cycleMaster); | ||
1789 | |||
1790 | ar_context_init(&ohci->ar_request_ctx, ohci, | ||
1791 | OHCI1394_AsReqRcvContextControlSet); | ||
1792 | |||
1793 | ar_context_init(&ohci->ar_response_ctx, ohci, | ||
1794 | OHCI1394_AsRspRcvContextControlSet); | ||
1795 | |||
1796 | context_init(&ohci->at_request_ctx, ohci, AT_BUFFER_SIZE, | ||
1797 | OHCI1394_AsReqTrContextControlSet, handle_at_packet); | ||
1798 | |||
1799 | context_init(&ohci->at_response_ctx, ohci, AT_BUFFER_SIZE, | ||
1800 | OHCI1394_AsRspTrContextControlSet, handle_at_packet); | ||
1801 | |||
1802 | reg_write(ohci, OHCI1394_ATRetries, | ||
1803 | OHCI1394_MAX_AT_REQ_RETRIES | | ||
1804 | (OHCI1394_MAX_AT_RESP_RETRIES << 4) | | ||
1805 | (OHCI1394_MAX_PHYS_RESP_RETRIES << 8)); | ||
1806 | |||
1807 | reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0); | ||
1808 | ohci->it_context_mask = reg_read(ohci, OHCI1394_IsoRecvIntMaskSet); | ||
1809 | reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, ~0); | ||
1810 | size = sizeof(struct iso_context) * hweight32(ohci->it_context_mask); | ||
1811 | ohci->it_context_list = kzalloc(size, GFP_KERNEL); | ||
1812 | |||
1813 | reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0); | ||
1814 | ohci->ir_context_mask = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet); | ||
1815 | reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, ~0); | ||
1816 | size = sizeof(struct iso_context) * hweight32(ohci->ir_context_mask); | ||
1817 | ohci->ir_context_list = kzalloc(size, GFP_KERNEL); | ||
1818 | |||
1819 | if (ohci->it_context_list == NULL || ohci->ir_context_list == NULL) { | ||
1820 | fw_error("Out of memory for it/ir contexts.\n"); | ||
1821 | err = -ENOMEM; | ||
1822 | goto fail_registers; | ||
1823 | } | ||
1824 | |||
1825 | /* self-id dma buffer allocation */ | ||
1826 | ohci->self_id_cpu = dma_alloc_coherent(ohci->card.device, | ||
1827 | SELF_ID_BUF_SIZE, | ||
1828 | &ohci->self_id_bus, | ||
1829 | GFP_KERNEL); | ||
1830 | if (ohci->self_id_cpu == NULL) { | ||
1831 | fw_error("Out of memory for self ID buffer.\n"); | ||
1832 | err = -ENOMEM; | ||
1833 | goto fail_registers; | ||
1834 | } | ||
1835 | |||
1836 | reg_write(ohci, OHCI1394_SelfIDBuffer, ohci->self_id_bus); | ||
1837 | reg_write(ohci, OHCI1394_PhyUpperBound, 0x00010000); | ||
1838 | reg_write(ohci, OHCI1394_IntEventClear, ~0); | ||
1839 | reg_write(ohci, OHCI1394_IntMaskClear, ~0); | ||
1840 | reg_write(ohci, OHCI1394_IntMaskSet, | ||
1841 | OHCI1394_selfIDComplete | | ||
1842 | OHCI1394_RQPkt | OHCI1394_RSPkt | | ||
1843 | OHCI1394_reqTxComplete | OHCI1394_respTxComplete | | ||
1844 | OHCI1394_isochRx | OHCI1394_isochTx | | ||
1845 | OHCI1394_masterIntEnable | | ||
1846 | OHCI1394_cycle64Seconds); | ||
1847 | |||
1848 | bus_options = reg_read(ohci, OHCI1394_BusOptions); | ||
1849 | max_receive = (bus_options >> 12) & 0xf; | ||
1850 | link_speed = bus_options & 0x7; | ||
1851 | guid = ((u64) reg_read(ohci, OHCI1394_GUIDHi) << 32) | | ||
1852 | reg_read(ohci, OHCI1394_GUIDLo); | ||
1853 | |||
1854 | err = fw_card_add(&ohci->card, max_receive, link_speed, guid); | ||
1855 | if (err < 0) | ||
1856 | goto fail_self_id; | ||
1857 | |||
1858 | ohci->version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff; | ||
1859 | fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n", | ||
1860 | dev->dev.bus_id, ohci->version >> 16, ohci->version & 0xff); | ||
1861 | |||
1862 | return 0; | ||
1863 | |||
1864 | fail_self_id: | ||
1865 | dma_free_coherent(ohci->card.device, SELF_ID_BUF_SIZE, | ||
1866 | ohci->self_id_cpu, ohci->self_id_bus); | ||
1867 | fail_registers: | ||
1868 | kfree(ohci->it_context_list); | ||
1869 | kfree(ohci->ir_context_list); | ||
1870 | pci_iounmap(dev, ohci->registers); | ||
1871 | fail_iomem: | ||
1872 | pci_release_region(dev, 0); | ||
1873 | fail_disable: | ||
1874 | pci_disable_device(dev); | ||
1875 | fail_put_card: | ||
1876 | fw_card_put(&ohci->card); | ||
1877 | |||
1878 | return err; | ||
1879 | } | ||
1880 | |||
1881 | static void pci_remove(struct pci_dev *dev) | ||
1882 | { | ||
1883 | struct fw_ohci *ohci; | ||
1884 | |||
1885 | ohci = pci_get_drvdata(dev); | ||
1886 | reg_write(ohci, OHCI1394_IntMaskClear, ~0); | ||
1887 | flush_writes(ohci); | ||
1888 | fw_core_remove_card(&ohci->card); | ||
1889 | |||
1890 | /* | ||
1891 | * FIXME: Fail all pending packets here, now that the upper | ||
1892 | * layers can't queue any more. | ||
1893 | */ | ||
1894 | |||
1895 | software_reset(ohci); | ||
1896 | free_irq(dev->irq, ohci); | ||
1897 | dma_free_coherent(ohci->card.device, SELF_ID_BUF_SIZE, | ||
1898 | ohci->self_id_cpu, ohci->self_id_bus); | ||
1899 | kfree(ohci->it_context_list); | ||
1900 | kfree(ohci->ir_context_list); | ||
1901 | pci_iounmap(dev, ohci->registers); | ||
1902 | pci_release_region(dev, 0); | ||
1903 | pci_disable_device(dev); | ||
1904 | fw_card_put(&ohci->card); | ||
1905 | |||
1906 | fw_notify("Removed fw-ohci device.\n"); | ||
1907 | } | ||
1908 | |||
1909 | static struct pci_device_id pci_table[] = { | ||
1910 | { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_FIREWIRE_OHCI, ~0) }, | ||
1911 | { } | ||
1912 | }; | ||
1913 | |||
1914 | MODULE_DEVICE_TABLE(pci, pci_table); | ||
1915 | |||
1916 | static struct pci_driver fw_ohci_pci_driver = { | ||
1917 | .name = ohci_driver_name, | ||
1918 | .id_table = pci_table, | ||
1919 | .probe = pci_probe, | ||
1920 | .remove = pci_remove, | ||
1921 | }; | ||
1922 | |||
1923 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); | ||
1924 | MODULE_DESCRIPTION("Driver for PCI OHCI IEEE1394 controllers"); | ||
1925 | MODULE_LICENSE("GPL"); | ||
1926 | |||
1927 | /* Provide a module alias so root-on-sbp2 initrds don't break. */ | ||
1928 | #ifndef CONFIG_IEEE1394_OHCI1394_MODULE | ||
1929 | MODULE_ALIAS("ohci1394"); | ||
1930 | #endif | ||
1931 | |||
1932 | static int __init fw_ohci_init(void) | ||
1933 | { | ||
1934 | return pci_register_driver(&fw_ohci_pci_driver); | ||
1935 | } | ||
1936 | |||
1937 | static void __exit fw_ohci_cleanup(void) | ||
1938 | { | ||
1939 | pci_unregister_driver(&fw_ohci_pci_driver); | ||
1940 | } | ||
1941 | |||
1942 | module_init(fw_ohci_init); | ||
1943 | module_exit(fw_ohci_cleanup); | ||
diff --git a/drivers/firewire/fw-ohci.h b/drivers/firewire/fw-ohci.h new file mode 100644 index 000000000000..fa15706397d7 --- /dev/null +++ b/drivers/firewire/fw-ohci.h | |||
@@ -0,0 +1,153 @@ | |||
1 | #ifndef __fw_ohci_h | ||
2 | #define __fw_ohci_h | ||
3 | |||
4 | /* OHCI register map */ | ||
5 | |||
6 | #define OHCI1394_Version 0x000 | ||
7 | #define OHCI1394_GUID_ROM 0x004 | ||
8 | #define OHCI1394_ATRetries 0x008 | ||
9 | #define OHCI1394_CSRData 0x00C | ||
10 | #define OHCI1394_CSRCompareData 0x010 | ||
11 | #define OHCI1394_CSRControl 0x014 | ||
12 | #define OHCI1394_ConfigROMhdr 0x018 | ||
13 | #define OHCI1394_BusID 0x01C | ||
14 | #define OHCI1394_BusOptions 0x020 | ||
15 | #define OHCI1394_GUIDHi 0x024 | ||
16 | #define OHCI1394_GUIDLo 0x028 | ||
17 | #define OHCI1394_ConfigROMmap 0x034 | ||
18 | #define OHCI1394_PostedWriteAddressLo 0x038 | ||
19 | #define OHCI1394_PostedWriteAddressHi 0x03C | ||
20 | #define OHCI1394_VendorID 0x040 | ||
21 | #define OHCI1394_HCControlSet 0x050 | ||
22 | #define OHCI1394_HCControlClear 0x054 | ||
23 | #define OHCI1394_HCControl_BIBimageValid 0x80000000 | ||
24 | #define OHCI1394_HCControl_noByteSwapData 0x40000000 | ||
25 | #define OHCI1394_HCControl_programPhyEnable 0x00800000 | ||
26 | #define OHCI1394_HCControl_aPhyEnhanceEnable 0x00400000 | ||
27 | #define OHCI1394_HCControl_LPS 0x00080000 | ||
28 | #define OHCI1394_HCControl_postedWriteEnable 0x00040000 | ||
29 | #define OHCI1394_HCControl_linkEnable 0x00020000 | ||
30 | #define OHCI1394_HCControl_softReset 0x00010000 | ||
31 | #define OHCI1394_SelfIDBuffer 0x064 | ||
32 | #define OHCI1394_SelfIDCount 0x068 | ||
33 | #define OHCI1394_IRMultiChanMaskHiSet 0x070 | ||
34 | #define OHCI1394_IRMultiChanMaskHiClear 0x074 | ||
35 | #define OHCI1394_IRMultiChanMaskLoSet 0x078 | ||
36 | #define OHCI1394_IRMultiChanMaskLoClear 0x07C | ||
37 | #define OHCI1394_IntEventSet 0x080 | ||
38 | #define OHCI1394_IntEventClear 0x084 | ||
39 | #define OHCI1394_IntMaskSet 0x088 | ||
40 | #define OHCI1394_IntMaskClear 0x08C | ||
41 | #define OHCI1394_IsoXmitIntEventSet 0x090 | ||
42 | #define OHCI1394_IsoXmitIntEventClear 0x094 | ||
43 | #define OHCI1394_IsoXmitIntMaskSet 0x098 | ||
44 | #define OHCI1394_IsoXmitIntMaskClear 0x09C | ||
45 | #define OHCI1394_IsoRecvIntEventSet 0x0A0 | ||
46 | #define OHCI1394_IsoRecvIntEventClear 0x0A4 | ||
47 | #define OHCI1394_IsoRecvIntMaskSet 0x0A8 | ||
48 | #define OHCI1394_IsoRecvIntMaskClear 0x0AC | ||
49 | #define OHCI1394_InitialBandwidthAvailable 0x0B0 | ||
50 | #define OHCI1394_InitialChannelsAvailableHi 0x0B4 | ||
51 | #define OHCI1394_InitialChannelsAvailableLo 0x0B8 | ||
52 | #define OHCI1394_FairnessControl 0x0DC | ||
53 | #define OHCI1394_LinkControlSet 0x0E0 | ||
54 | #define OHCI1394_LinkControlClear 0x0E4 | ||
55 | #define OHCI1394_LinkControl_rcvSelfID (1 << 9) | ||
56 | #define OHCI1394_LinkControl_rcvPhyPkt (1 << 10) | ||
57 | #define OHCI1394_LinkControl_cycleTimerEnable (1 << 20) | ||
58 | #define OHCI1394_LinkControl_cycleMaster (1 << 21) | ||
59 | #define OHCI1394_LinkControl_cycleSource (1 << 22) | ||
60 | #define OHCI1394_NodeID 0x0E8 | ||
61 | #define OHCI1394_NodeID_idValid 0x80000000 | ||
62 | #define OHCI1394_PhyControl 0x0EC | ||
63 | #define OHCI1394_PhyControl_Read(addr) (((addr) << 8) | 0x00008000) | ||
64 | #define OHCI1394_PhyControl_ReadDone 0x80000000 | ||
65 | #define OHCI1394_PhyControl_ReadData(r) (((r) & 0x00ff0000) >> 16) | ||
66 | #define OHCI1394_PhyControl_Write(addr, data) (((addr) << 8) | (data) | 0x00004000) | ||
67 | #define OHCI1394_PhyControl_WriteDone 0x00004000 | ||
68 | #define OHCI1394_IsochronousCycleTimer 0x0F0 | ||
69 | #define OHCI1394_AsReqFilterHiSet 0x100 | ||
70 | #define OHCI1394_AsReqFilterHiClear 0x104 | ||
71 | #define OHCI1394_AsReqFilterLoSet 0x108 | ||
72 | #define OHCI1394_AsReqFilterLoClear 0x10C | ||
73 | #define OHCI1394_PhyReqFilterHiSet 0x110 | ||
74 | #define OHCI1394_PhyReqFilterHiClear 0x114 | ||
75 | #define OHCI1394_PhyReqFilterLoSet 0x118 | ||
76 | #define OHCI1394_PhyReqFilterLoClear 0x11C | ||
77 | #define OHCI1394_PhyUpperBound 0x120 | ||
78 | |||
79 | #define OHCI1394_AsReqTrContextBase 0x180 | ||
80 | #define OHCI1394_AsReqTrContextControlSet 0x180 | ||
81 | #define OHCI1394_AsReqTrContextControlClear 0x184 | ||
82 | #define OHCI1394_AsReqTrCommandPtr 0x18C | ||
83 | |||
84 | #define OHCI1394_AsRspTrContextBase 0x1A0 | ||
85 | #define OHCI1394_AsRspTrContextControlSet 0x1A0 | ||
86 | #define OHCI1394_AsRspTrContextControlClear 0x1A4 | ||
87 | #define OHCI1394_AsRspTrCommandPtr 0x1AC | ||
88 | |||
89 | #define OHCI1394_AsReqRcvContextBase 0x1C0 | ||
90 | #define OHCI1394_AsReqRcvContextControlSet 0x1C0 | ||
91 | #define OHCI1394_AsReqRcvContextControlClear 0x1C4 | ||
92 | #define OHCI1394_AsReqRcvCommandPtr 0x1CC | ||
93 | |||
94 | #define OHCI1394_AsRspRcvContextBase 0x1E0 | ||
95 | #define OHCI1394_AsRspRcvContextControlSet 0x1E0 | ||
96 | #define OHCI1394_AsRspRcvContextControlClear 0x1E4 | ||
97 | #define OHCI1394_AsRspRcvCommandPtr 0x1EC | ||
98 | |||
99 | /* Isochronous transmit registers */ | ||
100 | #define OHCI1394_IsoXmitContextBase(n) (0x200 + 16 * (n)) | ||
101 | #define OHCI1394_IsoXmitContextControlSet(n) (0x200 + 16 * (n)) | ||
102 | #define OHCI1394_IsoXmitContextControlClear(n) (0x204 + 16 * (n)) | ||
103 | #define OHCI1394_IsoXmitCommandPtr(n) (0x20C + 16 * (n)) | ||
104 | |||
105 | /* Isochronous receive registers */ | ||
106 | #define OHCI1394_IsoRcvContextBase(n) (0x400 + 32 * (n)) | ||
107 | #define OHCI1394_IsoRcvContextControlSet(n) (0x400 + 32 * (n)) | ||
108 | #define OHCI1394_IsoRcvContextControlClear(n) (0x404 + 32 * (n)) | ||
109 | #define OHCI1394_IsoRcvCommandPtr(n) (0x40C + 32 * (n)) | ||
110 | #define OHCI1394_IsoRcvContextMatch(n) (0x410 + 32 * (n)) | ||
111 | |||
112 | /* Interrupts Mask/Events */ | ||
113 | #define OHCI1394_reqTxComplete 0x00000001 | ||
114 | #define OHCI1394_respTxComplete 0x00000002 | ||
115 | #define OHCI1394_ARRQ 0x00000004 | ||
116 | #define OHCI1394_ARRS 0x00000008 | ||
117 | #define OHCI1394_RQPkt 0x00000010 | ||
118 | #define OHCI1394_RSPkt 0x00000020 | ||
119 | #define OHCI1394_isochTx 0x00000040 | ||
120 | #define OHCI1394_isochRx 0x00000080 | ||
121 | #define OHCI1394_postedWriteErr 0x00000100 | ||
122 | #define OHCI1394_lockRespErr 0x00000200 | ||
123 | #define OHCI1394_selfIDComplete 0x00010000 | ||
124 | #define OHCI1394_busReset 0x00020000 | ||
125 | #define OHCI1394_phy 0x00080000 | ||
126 | #define OHCI1394_cycleSynch 0x00100000 | ||
127 | #define OHCI1394_cycle64Seconds 0x00200000 | ||
128 | #define OHCI1394_cycleLost 0x00400000 | ||
129 | #define OHCI1394_cycleInconsistent 0x00800000 | ||
130 | #define OHCI1394_unrecoverableError 0x01000000 | ||
131 | #define OHCI1394_cycleTooLong 0x02000000 | ||
132 | #define OHCI1394_phyRegRcvd 0x04000000 | ||
133 | #define OHCI1394_masterIntEnable 0x80000000 | ||
134 | |||
135 | #define OHCI1394_evt_no_status 0x0 | ||
136 | #define OHCI1394_evt_long_packet 0x2 | ||
137 | #define OHCI1394_evt_missing_ack 0x3 | ||
138 | #define OHCI1394_evt_underrun 0x4 | ||
139 | #define OHCI1394_evt_overrun 0x5 | ||
140 | #define OHCI1394_evt_descriptor_read 0x6 | ||
141 | #define OHCI1394_evt_data_read 0x7 | ||
142 | #define OHCI1394_evt_data_write 0x8 | ||
143 | #define OHCI1394_evt_bus_reset 0x9 | ||
144 | #define OHCI1394_evt_timeout 0xa | ||
145 | #define OHCI1394_evt_tcode_err 0xb | ||
146 | #define OHCI1394_evt_reserved_b 0xc | ||
147 | #define OHCI1394_evt_reserved_c 0xd | ||
148 | #define OHCI1394_evt_unknown 0xe | ||
149 | #define OHCI1394_evt_flushed 0xf | ||
150 | |||
151 | #define OHCI1394_phy_tcode 0xe | ||
152 | |||
153 | #endif /* __fw_ohci_h */ | ||
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c new file mode 100644 index 000000000000..68300414e5f4 --- /dev/null +++ b/drivers/firewire/fw-sbp2.c | |||
@@ -0,0 +1,1147 @@ | |||
1 | /* | ||
2 | * SBP2 driver (SCSI over IEEE1394) | ||
3 | * | ||
4 | * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | * The basic structure of this driver is based on the old storage driver, | ||
23 | * drivers/ieee1394/sbp2.c, originally written by | ||
24 | * James Goodwin <jamesg@filanet.com> | ||
25 | * with later contributions and ongoing maintenance from | ||
26 | * Ben Collins <bcollins@debian.org>, | ||
27 | * Stefan Richter <stefanr@s5r6.in-berlin.de> | ||
28 | * and many others. | ||
29 | */ | ||
30 | |||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <linux/mod_devicetable.h> | ||
34 | #include <linux/device.h> | ||
35 | #include <linux/scatterlist.h> | ||
36 | #include <linux/dma-mapping.h> | ||
37 | #include <linux/timer.h> | ||
38 | |||
39 | #include <scsi/scsi.h> | ||
40 | #include <scsi/scsi_cmnd.h> | ||
41 | #include <scsi/scsi_dbg.h> | ||
42 | #include <scsi/scsi_device.h> | ||
43 | #include <scsi/scsi_host.h> | ||
44 | |||
45 | #include "fw-transaction.h" | ||
46 | #include "fw-topology.h" | ||
47 | #include "fw-device.h" | ||
48 | |||
49 | /* I don't know why the SCSI stack doesn't define something like this... */ | ||
50 | typedef void (*scsi_done_fn_t)(struct scsi_cmnd *); | ||
51 | |||
52 | static const char sbp2_driver_name[] = "sbp2"; | ||
53 | |||
54 | struct sbp2_device { | ||
55 | struct kref kref; | ||
56 | struct fw_unit *unit; | ||
57 | struct fw_address_handler address_handler; | ||
58 | struct list_head orb_list; | ||
59 | u64 management_agent_address; | ||
60 | u64 command_block_agent_address; | ||
61 | u32 workarounds; | ||
62 | int login_id; | ||
63 | |||
64 | /* | ||
65 | * We cache these addresses and only update them once we've | ||
66 | * logged in or reconnected to the sbp2 device. That way, any | ||
67 | * IO to the device will automatically fail and get retried if | ||
68 | * it happens in a window where the device is not ready to | ||
69 | * handle it (e.g. after a bus reset but before we reconnect). | ||
70 | */ | ||
71 | int node_id; | ||
72 | int address_high; | ||
73 | int generation; | ||
74 | |||
75 | int retries; | ||
76 | struct delayed_work work; | ||
77 | }; | ||
78 | |||
79 | #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 | ||
80 | #define SBP2_MAX_SECTORS 255 /* Max sectors supported */ | ||
81 | #define SBP2_ORB_TIMEOUT 2000 /* Timeout in ms */ | ||
82 | |||
83 | #define SBP2_ORB_NULL 0x80000000 | ||
84 | |||
85 | #define SBP2_DIRECTION_TO_MEDIA 0x0 | ||
86 | #define SBP2_DIRECTION_FROM_MEDIA 0x1 | ||
87 | |||
88 | /* Unit directory keys */ | ||
89 | #define SBP2_COMMAND_SET_SPECIFIER 0x38 | ||
90 | #define SBP2_COMMAND_SET 0x39 | ||
91 | #define SBP2_COMMAND_SET_REVISION 0x3b | ||
92 | #define SBP2_FIRMWARE_REVISION 0x3c | ||
93 | |||
94 | /* Flags for detected oddities and brokeness */ | ||
95 | #define SBP2_WORKAROUND_128K_MAX_TRANS 0x1 | ||
96 | #define SBP2_WORKAROUND_INQUIRY_36 0x2 | ||
97 | #define SBP2_WORKAROUND_MODE_SENSE_8 0x4 | ||
98 | #define SBP2_WORKAROUND_FIX_CAPACITY 0x8 | ||
99 | #define SBP2_WORKAROUND_OVERRIDE 0x100 | ||
100 | |||
101 | /* Management orb opcodes */ | ||
102 | #define SBP2_LOGIN_REQUEST 0x0 | ||
103 | #define SBP2_QUERY_LOGINS_REQUEST 0x1 | ||
104 | #define SBP2_RECONNECT_REQUEST 0x3 | ||
105 | #define SBP2_SET_PASSWORD_REQUEST 0x4 | ||
106 | #define SBP2_LOGOUT_REQUEST 0x7 | ||
107 | #define SBP2_ABORT_TASK_REQUEST 0xb | ||
108 | #define SBP2_ABORT_TASK_SET 0xc | ||
109 | #define SBP2_LOGICAL_UNIT_RESET 0xe | ||
110 | #define SBP2_TARGET_RESET_REQUEST 0xf | ||
111 | |||
112 | /* Offsets for command block agent registers */ | ||
113 | #define SBP2_AGENT_STATE 0x00 | ||
114 | #define SBP2_AGENT_RESET 0x04 | ||
115 | #define SBP2_ORB_POINTER 0x08 | ||
116 | #define SBP2_DOORBELL 0x10 | ||
117 | #define SBP2_UNSOLICITED_STATUS_ENABLE 0x14 | ||
118 | |||
119 | /* Status write response codes */ | ||
120 | #define SBP2_STATUS_REQUEST_COMPLETE 0x0 | ||
121 | #define SBP2_STATUS_TRANSPORT_FAILURE 0x1 | ||
122 | #define SBP2_STATUS_ILLEGAL_REQUEST 0x2 | ||
123 | #define SBP2_STATUS_VENDOR_DEPENDENT 0x3 | ||
124 | |||
125 | #define STATUS_GET_ORB_HIGH(v) ((v).status & 0xffff) | ||
126 | #define STATUS_GET_SBP_STATUS(v) (((v).status >> 16) & 0xff) | ||
127 | #define STATUS_GET_LEN(v) (((v).status >> 24) & 0x07) | ||
128 | #define STATUS_GET_DEAD(v) (((v).status >> 27) & 0x01) | ||
129 | #define STATUS_GET_RESPONSE(v) (((v).status >> 28) & 0x03) | ||
130 | #define STATUS_GET_SOURCE(v) (((v).status >> 30) & 0x03) | ||
131 | #define STATUS_GET_ORB_LOW(v) ((v).orb_low) | ||
132 | #define STATUS_GET_DATA(v) ((v).data) | ||
133 | |||
134 | struct sbp2_status { | ||
135 | u32 status; | ||
136 | u32 orb_low; | ||
137 | u8 data[24]; | ||
138 | }; | ||
139 | |||
140 | struct sbp2_pointer { | ||
141 | u32 high; | ||
142 | u32 low; | ||
143 | }; | ||
144 | |||
145 | struct sbp2_orb { | ||
146 | struct fw_transaction t; | ||
147 | dma_addr_t request_bus; | ||
148 | int rcode; | ||
149 | struct sbp2_pointer pointer; | ||
150 | void (*callback)(struct sbp2_orb * orb, struct sbp2_status * status); | ||
151 | struct list_head link; | ||
152 | }; | ||
153 | |||
154 | #define MANAGEMENT_ORB_LUN(v) ((v)) | ||
155 | #define MANAGEMENT_ORB_FUNCTION(v) ((v) << 16) | ||
156 | #define MANAGEMENT_ORB_RECONNECT(v) ((v) << 20) | ||
157 | #define MANAGEMENT_ORB_EXCLUSIVE ((1) << 28) | ||
158 | #define MANAGEMENT_ORB_REQUEST_FORMAT(v) ((v) << 29) | ||
159 | #define MANAGEMENT_ORB_NOTIFY ((1) << 31) | ||
160 | |||
161 | #define MANAGEMENT_ORB_RESPONSE_LENGTH(v) ((v)) | ||
162 | #define MANAGEMENT_ORB_PASSWORD_LENGTH(v) ((v) << 16) | ||
163 | |||
164 | struct sbp2_management_orb { | ||
165 | struct sbp2_orb base; | ||
166 | struct { | ||
167 | struct sbp2_pointer password; | ||
168 | struct sbp2_pointer response; | ||
169 | u32 misc; | ||
170 | u32 length; | ||
171 | struct sbp2_pointer status_fifo; | ||
172 | } request; | ||
173 | __be32 response[4]; | ||
174 | dma_addr_t response_bus; | ||
175 | struct completion done; | ||
176 | struct sbp2_status status; | ||
177 | }; | ||
178 | |||
179 | #define LOGIN_RESPONSE_GET_LOGIN_ID(v) ((v).misc & 0xffff) | ||
180 | #define LOGIN_RESPONSE_GET_LENGTH(v) (((v).misc >> 16) & 0xffff) | ||
181 | |||
182 | struct sbp2_login_response { | ||
183 | u32 misc; | ||
184 | struct sbp2_pointer command_block_agent; | ||
185 | u32 reconnect_hold; | ||
186 | }; | ||
187 | #define COMMAND_ORB_DATA_SIZE(v) ((v)) | ||
188 | #define COMMAND_ORB_PAGE_SIZE(v) ((v) << 16) | ||
189 | #define COMMAND_ORB_PAGE_TABLE_PRESENT ((1) << 19) | ||
190 | #define COMMAND_ORB_MAX_PAYLOAD(v) ((v) << 20) | ||
191 | #define COMMAND_ORB_SPEED(v) ((v) << 24) | ||
192 | #define COMMAND_ORB_DIRECTION(v) ((v) << 27) | ||
193 | #define COMMAND_ORB_REQUEST_FORMAT(v) ((v) << 29) | ||
194 | #define COMMAND_ORB_NOTIFY ((1) << 31) | ||
195 | |||
196 | struct sbp2_command_orb { | ||
197 | struct sbp2_orb base; | ||
198 | struct { | ||
199 | struct sbp2_pointer next; | ||
200 | struct sbp2_pointer data_descriptor; | ||
201 | u32 misc; | ||
202 | u8 command_block[12]; | ||
203 | } request; | ||
204 | struct scsi_cmnd *cmd; | ||
205 | scsi_done_fn_t done; | ||
206 | struct fw_unit *unit; | ||
207 | |||
208 | struct sbp2_pointer page_table[SG_ALL]; | ||
209 | dma_addr_t page_table_bus; | ||
210 | dma_addr_t request_buffer_bus; | ||
211 | }; | ||
212 | |||
213 | /* | ||
214 | * List of devices with known bugs. | ||
215 | * | ||
216 | * The firmware_revision field, masked with 0xffff00, is the best | ||
217 | * indicator for the type of bridge chip of a device. It yields a few | ||
218 | * false positives but this did not break correctly behaving devices | ||
219 | * so far. We use ~0 as a wildcard, since the 24 bit values we get | ||
220 | * from the config rom can never match that. | ||
221 | */ | ||
222 | static const struct { | ||
223 | u32 firmware_revision; | ||
224 | u32 model; | ||
225 | unsigned workarounds; | ||
226 | } sbp2_workarounds_table[] = { | ||
227 | /* DViCO Momobay CX-1 with TSB42AA9 bridge */ { | ||
228 | .firmware_revision = 0x002800, | ||
229 | .model = 0x001010, | ||
230 | .workarounds = SBP2_WORKAROUND_INQUIRY_36 | | ||
231 | SBP2_WORKAROUND_MODE_SENSE_8, | ||
232 | }, | ||
233 | /* Initio bridges, actually only needed for some older ones */ { | ||
234 | .firmware_revision = 0x000200, | ||
235 | .model = ~0, | ||
236 | .workarounds = SBP2_WORKAROUND_INQUIRY_36, | ||
237 | }, | ||
238 | /* Symbios bridge */ { | ||
239 | .firmware_revision = 0xa0b800, | ||
240 | .model = ~0, | ||
241 | .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, | ||
242 | }, | ||
243 | |||
244 | /* | ||
245 | * There are iPods (2nd gen, 3rd gen) with model_id == 0, but | ||
246 | * these iPods do not feature the read_capacity bug according | ||
247 | * to one report. Read_capacity behaviour as well as model_id | ||
248 | * could change due to Apple-supplied firmware updates though. | ||
249 | */ | ||
250 | |||
251 | /* iPod 4th generation. */ { | ||
252 | .firmware_revision = 0x0a2700, | ||
253 | .model = 0x000021, | ||
254 | .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, | ||
255 | }, | ||
256 | /* iPod mini */ { | ||
257 | .firmware_revision = 0x0a2700, | ||
258 | .model = 0x000023, | ||
259 | .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, | ||
260 | }, | ||
261 | /* iPod Photo */ { | ||
262 | .firmware_revision = 0x0a2700, | ||
263 | .model = 0x00007e, | ||
264 | .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, | ||
265 | } | ||
266 | }; | ||
267 | |||
268 | static void | ||
269 | sbp2_status_write(struct fw_card *card, struct fw_request *request, | ||
270 | int tcode, int destination, int source, | ||
271 | int generation, int speed, | ||
272 | unsigned long long offset, | ||
273 | void *payload, size_t length, void *callback_data) | ||
274 | { | ||
275 | struct sbp2_device *sd = callback_data; | ||
276 | struct sbp2_orb *orb; | ||
277 | struct sbp2_status status; | ||
278 | size_t header_size; | ||
279 | unsigned long flags; | ||
280 | |||
281 | if (tcode != TCODE_WRITE_BLOCK_REQUEST || | ||
282 | length == 0 || length > sizeof(status)) { | ||
283 | fw_send_response(card, request, RCODE_TYPE_ERROR); | ||
284 | return; | ||
285 | } | ||
286 | |||
287 | header_size = min(length, 2 * sizeof(u32)); | ||
288 | fw_memcpy_from_be32(&status, payload, header_size); | ||
289 | if (length > header_size) | ||
290 | memcpy(status.data, payload + 8, length - header_size); | ||
291 | if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) { | ||
292 | fw_notify("non-orb related status write, not handled\n"); | ||
293 | fw_send_response(card, request, RCODE_COMPLETE); | ||
294 | return; | ||
295 | } | ||
296 | |||
297 | /* Lookup the orb corresponding to this status write. */ | ||
298 | spin_lock_irqsave(&card->lock, flags); | ||
299 | list_for_each_entry(orb, &sd->orb_list, link) { | ||
300 | if (STATUS_GET_ORB_HIGH(status) == 0 && | ||
301 | STATUS_GET_ORB_LOW(status) == orb->request_bus && | ||
302 | orb->rcode == RCODE_COMPLETE) { | ||
303 | list_del(&orb->link); | ||
304 | break; | ||
305 | } | ||
306 | } | ||
307 | spin_unlock_irqrestore(&card->lock, flags); | ||
308 | |||
309 | if (&orb->link != &sd->orb_list) | ||
310 | orb->callback(orb, &status); | ||
311 | else | ||
312 | fw_error("status write for unknown orb\n"); | ||
313 | |||
314 | fw_send_response(card, request, RCODE_COMPLETE); | ||
315 | } | ||
316 | |||
317 | static void | ||
318 | complete_transaction(struct fw_card *card, int rcode, | ||
319 | void *payload, size_t length, void *data) | ||
320 | { | ||
321 | struct sbp2_orb *orb = data; | ||
322 | unsigned long flags; | ||
323 | |||
324 | orb->rcode = rcode; | ||
325 | if (rcode != RCODE_COMPLETE) { | ||
326 | spin_lock_irqsave(&card->lock, flags); | ||
327 | list_del(&orb->link); | ||
328 | spin_unlock_irqrestore(&card->lock, flags); | ||
329 | orb->callback(orb, NULL); | ||
330 | } | ||
331 | } | ||
332 | |||
333 | static void | ||
334 | sbp2_send_orb(struct sbp2_orb *orb, struct fw_unit *unit, | ||
335 | int node_id, int generation, u64 offset) | ||
336 | { | ||
337 | struct fw_device *device = fw_device(unit->device.parent); | ||
338 | struct sbp2_device *sd = unit->device.driver_data; | ||
339 | unsigned long flags; | ||
340 | |||
341 | orb->pointer.high = 0; | ||
342 | orb->pointer.low = orb->request_bus; | ||
343 | fw_memcpy_to_be32(&orb->pointer, &orb->pointer, sizeof(orb->pointer)); | ||
344 | |||
345 | spin_lock_irqsave(&device->card->lock, flags); | ||
346 | list_add_tail(&orb->link, &sd->orb_list); | ||
347 | spin_unlock_irqrestore(&device->card->lock, flags); | ||
348 | |||
349 | fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST, | ||
350 | node_id, generation, | ||
351 | device->node->max_speed, offset, | ||
352 | &orb->pointer, sizeof(orb->pointer), | ||
353 | complete_transaction, orb); | ||
354 | } | ||
355 | |||
356 | static int sbp2_cancel_orbs(struct fw_unit *unit) | ||
357 | { | ||
358 | struct fw_device *device = fw_device(unit->device.parent); | ||
359 | struct sbp2_device *sd = unit->device.driver_data; | ||
360 | struct sbp2_orb *orb, *next; | ||
361 | struct list_head list; | ||
362 | unsigned long flags; | ||
363 | int retval = -ENOENT; | ||
364 | |||
365 | INIT_LIST_HEAD(&list); | ||
366 | spin_lock_irqsave(&device->card->lock, flags); | ||
367 | list_splice_init(&sd->orb_list, &list); | ||
368 | spin_unlock_irqrestore(&device->card->lock, flags); | ||
369 | |||
370 | list_for_each_entry_safe(orb, next, &list, link) { | ||
371 | retval = 0; | ||
372 | if (fw_cancel_transaction(device->card, &orb->t) == 0) | ||
373 | continue; | ||
374 | |||
375 | orb->rcode = RCODE_CANCELLED; | ||
376 | orb->callback(orb, NULL); | ||
377 | } | ||
378 | |||
379 | return retval; | ||
380 | } | ||
381 | |||
382 | static void | ||
383 | complete_management_orb(struct sbp2_orb *base_orb, struct sbp2_status *status) | ||
384 | { | ||
385 | struct sbp2_management_orb *orb = | ||
386 | (struct sbp2_management_orb *)base_orb; | ||
387 | |||
388 | if (status) | ||
389 | memcpy(&orb->status, status, sizeof(*status)); | ||
390 | complete(&orb->done); | ||
391 | } | ||
392 | |||
393 | static int | ||
394 | sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation, | ||
395 | int function, int lun, void *response) | ||
396 | { | ||
397 | struct fw_device *device = fw_device(unit->device.parent); | ||
398 | struct sbp2_device *sd = unit->device.driver_data; | ||
399 | struct sbp2_management_orb *orb; | ||
400 | int retval = -ENOMEM; | ||
401 | |||
402 | orb = kzalloc(sizeof(*orb), GFP_ATOMIC); | ||
403 | if (orb == NULL) | ||
404 | return -ENOMEM; | ||
405 | |||
406 | /* | ||
407 | * The sbp2 device is going to send a block read request to | ||
408 | * read out the request from host memory, so map it for dma. | ||
409 | */ | ||
410 | orb->base.request_bus = | ||
411 | dma_map_single(device->card->device, &orb->request, | ||
412 | sizeof(orb->request), DMA_TO_DEVICE); | ||
413 | if (dma_mapping_error(orb->base.request_bus)) | ||
414 | goto out; | ||
415 | |||
416 | orb->response_bus = | ||
417 | dma_map_single(device->card->device, &orb->response, | ||
418 | sizeof(orb->response), DMA_FROM_DEVICE); | ||
419 | if (dma_mapping_error(orb->response_bus)) | ||
420 | goto out; | ||
421 | |||
422 | orb->request.response.high = 0; | ||
423 | orb->request.response.low = orb->response_bus; | ||
424 | |||
425 | orb->request.misc = | ||
426 | MANAGEMENT_ORB_NOTIFY | | ||
427 | MANAGEMENT_ORB_FUNCTION(function) | | ||
428 | MANAGEMENT_ORB_LUN(lun); | ||
429 | orb->request.length = | ||
430 | MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response)); | ||
431 | |||
432 | orb->request.status_fifo.high = sd->address_handler.offset >> 32; | ||
433 | orb->request.status_fifo.low = sd->address_handler.offset; | ||
434 | |||
435 | /* | ||
436 | * FIXME: Yeah, ok this isn't elegant, we hardwire exclusive | ||
437 | * login and 1 second reconnect time. The reconnect setting | ||
438 | * is probably fine, but the exclusive login should be an option. | ||
439 | */ | ||
440 | if (function == SBP2_LOGIN_REQUEST) { | ||
441 | orb->request.misc |= | ||
442 | MANAGEMENT_ORB_EXCLUSIVE | | ||
443 | MANAGEMENT_ORB_RECONNECT(0); | ||
444 | } | ||
445 | |||
446 | fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request)); | ||
447 | |||
448 | init_completion(&orb->done); | ||
449 | orb->base.callback = complete_management_orb; | ||
450 | |||
451 | sbp2_send_orb(&orb->base, unit, | ||
452 | node_id, generation, sd->management_agent_address); | ||
453 | |||
454 | wait_for_completion_timeout(&orb->done, | ||
455 | msecs_to_jiffies(SBP2_ORB_TIMEOUT)); | ||
456 | |||
457 | retval = -EIO; | ||
458 | if (sbp2_cancel_orbs(unit) == 0) { | ||
459 | fw_error("orb reply timed out, rcode=0x%02x\n", | ||
460 | orb->base.rcode); | ||
461 | goto out; | ||
462 | } | ||
463 | |||
464 | if (orb->base.rcode != RCODE_COMPLETE) { | ||
465 | fw_error("management write failed, rcode 0x%02x\n", | ||
466 | orb->base.rcode); | ||
467 | goto out; | ||
468 | } | ||
469 | |||
470 | if (STATUS_GET_RESPONSE(orb->status) != 0 || | ||
471 | STATUS_GET_SBP_STATUS(orb->status) != 0) { | ||
472 | fw_error("error status: %d:%d\n", | ||
473 | STATUS_GET_RESPONSE(orb->status), | ||
474 | STATUS_GET_SBP_STATUS(orb->status)); | ||
475 | goto out; | ||
476 | } | ||
477 | |||
478 | retval = 0; | ||
479 | out: | ||
480 | dma_unmap_single(device->card->device, orb->base.request_bus, | ||
481 | sizeof(orb->request), DMA_TO_DEVICE); | ||
482 | dma_unmap_single(device->card->device, orb->response_bus, | ||
483 | sizeof(orb->response), DMA_FROM_DEVICE); | ||
484 | |||
485 | if (response) | ||
486 | fw_memcpy_from_be32(response, | ||
487 | orb->response, sizeof(orb->response)); | ||
488 | kfree(orb); | ||
489 | |||
490 | return retval; | ||
491 | } | ||
492 | |||
493 | static void | ||
494 | complete_agent_reset_write(struct fw_card *card, int rcode, | ||
495 | void *payload, size_t length, void *data) | ||
496 | { | ||
497 | struct fw_transaction *t = data; | ||
498 | |||
499 | kfree(t); | ||
500 | } | ||
501 | |||
502 | static int sbp2_agent_reset(struct fw_unit *unit) | ||
503 | { | ||
504 | struct fw_device *device = fw_device(unit->device.parent); | ||
505 | struct sbp2_device *sd = unit->device.driver_data; | ||
506 | struct fw_transaction *t; | ||
507 | static u32 zero; | ||
508 | |||
509 | t = kzalloc(sizeof(*t), GFP_ATOMIC); | ||
510 | if (t == NULL) | ||
511 | return -ENOMEM; | ||
512 | |||
513 | fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, | ||
514 | sd->node_id, sd->generation, SCODE_400, | ||
515 | sd->command_block_agent_address + SBP2_AGENT_RESET, | ||
516 | &zero, sizeof(zero), complete_agent_reset_write, t); | ||
517 | |||
518 | return 0; | ||
519 | } | ||
520 | |||
521 | static void sbp2_reconnect(struct work_struct *work); | ||
522 | static struct scsi_host_template scsi_driver_template; | ||
523 | |||
524 | static void | ||
525 | release_sbp2_device(struct kref *kref) | ||
526 | { | ||
527 | struct sbp2_device *sd = container_of(kref, struct sbp2_device, kref); | ||
528 | struct Scsi_Host *host = | ||
529 | container_of((void *)sd, struct Scsi_Host, hostdata[0]); | ||
530 | |||
531 | sbp2_send_management_orb(sd->unit, sd->node_id, sd->generation, | ||
532 | SBP2_LOGOUT_REQUEST, sd->login_id, NULL); | ||
533 | |||
534 | scsi_remove_host(host); | ||
535 | fw_core_remove_address_handler(&sd->address_handler); | ||
536 | fw_notify("removed sbp2 unit %s\n", sd->unit->device.bus_id); | ||
537 | put_device(&sd->unit->device); | ||
538 | scsi_host_put(host); | ||
539 | } | ||
540 | |||
541 | static void sbp2_login(struct work_struct *work) | ||
542 | { | ||
543 | struct sbp2_device *sd = | ||
544 | container_of(work, struct sbp2_device, work.work); | ||
545 | struct Scsi_Host *host = | ||
546 | container_of((void *)sd, struct Scsi_Host, hostdata[0]); | ||
547 | struct fw_unit *unit = sd->unit; | ||
548 | struct fw_device *device = fw_device(unit->device.parent); | ||
549 | struct sbp2_login_response response; | ||
550 | int generation, node_id, local_node_id, lun, retval; | ||
551 | |||
552 | /* FIXME: Make this work for multi-lun devices. */ | ||
553 | lun = 0; | ||
554 | |||
555 | generation = device->card->generation; | ||
556 | node_id = device->node->node_id; | ||
557 | local_node_id = device->card->local_node->node_id; | ||
558 | |||
559 | if (sbp2_send_management_orb(unit, node_id, generation, | ||
560 | SBP2_LOGIN_REQUEST, lun, &response) < 0) { | ||
561 | if (sd->retries++ < 5) { | ||
562 | schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5)); | ||
563 | } else { | ||
564 | fw_error("failed to login to %s\n", | ||
565 | unit->device.bus_id); | ||
566 | kref_put(&sd->kref, release_sbp2_device); | ||
567 | } | ||
568 | return; | ||
569 | } | ||
570 | |||
571 | sd->generation = generation; | ||
572 | sd->node_id = node_id; | ||
573 | sd->address_high = local_node_id << 16; | ||
574 | |||
575 | /* Get command block agent offset and login id. */ | ||
576 | sd->command_block_agent_address = | ||
577 | ((u64) (response.command_block_agent.high & 0xffff) << 32) | | ||
578 | response.command_block_agent.low; | ||
579 | sd->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response); | ||
580 | |||
581 | fw_notify("logged in to sbp2 unit %s (%d retries)\n", | ||
582 | unit->device.bus_id, sd->retries); | ||
583 | fw_notify(" - management_agent_address: 0x%012llx\n", | ||
584 | (unsigned long long) sd->management_agent_address); | ||
585 | fw_notify(" - command_block_agent_address: 0x%012llx\n", | ||
586 | (unsigned long long) sd->command_block_agent_address); | ||
587 | fw_notify(" - status write address: 0x%012llx\n", | ||
588 | (unsigned long long) sd->address_handler.offset); | ||
589 | |||
590 | #if 0 | ||
591 | /* FIXME: The linux1394 sbp2 does this last step. */ | ||
592 | sbp2_set_busy_timeout(scsi_id); | ||
593 | #endif | ||
594 | |||
595 | PREPARE_DELAYED_WORK(&sd->work, sbp2_reconnect); | ||
596 | sbp2_agent_reset(unit); | ||
597 | |||
598 | /* FIXME: Loop over luns here. */ | ||
599 | lun = 0; | ||
600 | retval = scsi_add_device(host, 0, 0, lun); | ||
601 | if (retval < 0) { | ||
602 | sbp2_send_management_orb(unit, sd->node_id, sd->generation, | ||
603 | SBP2_LOGOUT_REQUEST, sd->login_id, | ||
604 | NULL); | ||
605 | /* | ||
606 | * Set this back to sbp2_login so we fall back and | ||
607 | * retry login on bus reset. | ||
608 | */ | ||
609 | PREPARE_DELAYED_WORK(&sd->work, sbp2_login); | ||
610 | } | ||
611 | kref_put(&sd->kref, release_sbp2_device); | ||
612 | } | ||
613 | |||
614 | static int sbp2_probe(struct device *dev) | ||
615 | { | ||
616 | struct fw_unit *unit = fw_unit(dev); | ||
617 | struct fw_device *device = fw_device(unit->device.parent); | ||
618 | struct sbp2_device *sd; | ||
619 | struct fw_csr_iterator ci; | ||
620 | struct Scsi_Host *host; | ||
621 | int i, key, value, err; | ||
622 | u32 model, firmware_revision; | ||
623 | |||
624 | err = -ENOMEM; | ||
625 | host = scsi_host_alloc(&scsi_driver_template, sizeof(*sd)); | ||
626 | if (host == NULL) | ||
627 | goto fail; | ||
628 | |||
629 | sd = (struct sbp2_device *) host->hostdata; | ||
630 | unit->device.driver_data = sd; | ||
631 | sd->unit = unit; | ||
632 | INIT_LIST_HEAD(&sd->orb_list); | ||
633 | kref_init(&sd->kref); | ||
634 | |||
635 | sd->address_handler.length = 0x100; | ||
636 | sd->address_handler.address_callback = sbp2_status_write; | ||
637 | sd->address_handler.callback_data = sd; | ||
638 | |||
639 | err = fw_core_add_address_handler(&sd->address_handler, | ||
640 | &fw_high_memory_region); | ||
641 | if (err < 0) | ||
642 | goto fail_host; | ||
643 | |||
644 | err = fw_device_enable_phys_dma(device); | ||
645 | if (err < 0) | ||
646 | goto fail_address_handler; | ||
647 | |||
648 | err = scsi_add_host(host, &unit->device); | ||
649 | if (err < 0) | ||
650 | goto fail_address_handler; | ||
651 | |||
652 | /* | ||
653 | * Scan unit directory to get management agent address, | ||
654 | * firmware revison and model. Initialize firmware_revision | ||
655 | * and model to values that wont match anything in our table. | ||
656 | */ | ||
657 | firmware_revision = 0xff000000; | ||
658 | model = 0xff000000; | ||
659 | fw_csr_iterator_init(&ci, unit->directory); | ||
660 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
661 | switch (key) { | ||
662 | case CSR_DEPENDENT_INFO | CSR_OFFSET: | ||
663 | sd->management_agent_address = | ||
664 | 0xfffff0000000ULL + 4 * value; | ||
665 | break; | ||
666 | case SBP2_FIRMWARE_REVISION: | ||
667 | firmware_revision = value; | ||
668 | break; | ||
669 | case CSR_MODEL: | ||
670 | model = value; | ||
671 | break; | ||
672 | } | ||
673 | } | ||
674 | |||
675 | for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) { | ||
676 | if (sbp2_workarounds_table[i].firmware_revision != | ||
677 | (firmware_revision & 0xffffff00)) | ||
678 | continue; | ||
679 | if (sbp2_workarounds_table[i].model != model && | ||
680 | sbp2_workarounds_table[i].model != ~0) | ||
681 | continue; | ||
682 | sd->workarounds |= sbp2_workarounds_table[i].workarounds; | ||
683 | break; | ||
684 | } | ||
685 | |||
686 | if (sd->workarounds) | ||
687 | fw_notify("Workarounds for node %s: 0x%x " | ||
688 | "(firmware_revision 0x%06x, model_id 0x%06x)\n", | ||
689 | unit->device.bus_id, | ||
690 | sd->workarounds, firmware_revision, model); | ||
691 | |||
692 | get_device(&unit->device); | ||
693 | |||
694 | /* | ||
695 | * We schedule work to do the login so we can easily | ||
696 | * reschedule retries. Always get the ref before scheduling | ||
697 | * work. | ||
698 | */ | ||
699 | INIT_DELAYED_WORK(&sd->work, sbp2_login); | ||
700 | if (schedule_delayed_work(&sd->work, 0)) | ||
701 | kref_get(&sd->kref); | ||
702 | |||
703 | return 0; | ||
704 | |||
705 | fail_address_handler: | ||
706 | fw_core_remove_address_handler(&sd->address_handler); | ||
707 | fail_host: | ||
708 | scsi_host_put(host); | ||
709 | fail: | ||
710 | return err; | ||
711 | } | ||
712 | |||
713 | static int sbp2_remove(struct device *dev) | ||
714 | { | ||
715 | struct fw_unit *unit = fw_unit(dev); | ||
716 | struct sbp2_device *sd = unit->device.driver_data; | ||
717 | |||
718 | kref_put(&sd->kref, release_sbp2_device); | ||
719 | |||
720 | return 0; | ||
721 | } | ||
722 | |||
723 | static void sbp2_reconnect(struct work_struct *work) | ||
724 | { | ||
725 | struct sbp2_device *sd = | ||
726 | container_of(work, struct sbp2_device, work.work); | ||
727 | struct fw_unit *unit = sd->unit; | ||
728 | struct fw_device *device = fw_device(unit->device.parent); | ||
729 | int generation, node_id, local_node_id; | ||
730 | |||
731 | generation = device->card->generation; | ||
732 | node_id = device->node->node_id; | ||
733 | local_node_id = device->card->local_node->node_id; | ||
734 | |||
735 | if (sbp2_send_management_orb(unit, node_id, generation, | ||
736 | SBP2_RECONNECT_REQUEST, | ||
737 | sd->login_id, NULL) < 0) { | ||
738 | if (sd->retries++ >= 5) { | ||
739 | fw_error("failed to reconnect to %s\n", | ||
740 | unit->device.bus_id); | ||
741 | /* Fall back and try to log in again. */ | ||
742 | sd->retries = 0; | ||
743 | PREPARE_DELAYED_WORK(&sd->work, sbp2_login); | ||
744 | } | ||
745 | schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5)); | ||
746 | return; | ||
747 | } | ||
748 | |||
749 | sd->generation = generation; | ||
750 | sd->node_id = node_id; | ||
751 | sd->address_high = local_node_id << 16; | ||
752 | |||
753 | fw_notify("reconnected to unit %s (%d retries)\n", | ||
754 | unit->device.bus_id, sd->retries); | ||
755 | sbp2_agent_reset(unit); | ||
756 | sbp2_cancel_orbs(unit); | ||
757 | kref_put(&sd->kref, release_sbp2_device); | ||
758 | } | ||
759 | |||
760 | static void sbp2_update(struct fw_unit *unit) | ||
761 | { | ||
762 | struct fw_device *device = fw_device(unit->device.parent); | ||
763 | struct sbp2_device *sd = unit->device.driver_data; | ||
764 | |||
765 | sd->retries = 0; | ||
766 | fw_device_enable_phys_dma(device); | ||
767 | if (schedule_delayed_work(&sd->work, 0)) | ||
768 | kref_get(&sd->kref); | ||
769 | } | ||
770 | |||
771 | #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e | ||
772 | #define SBP2_SW_VERSION_ENTRY 0x00010483 | ||
773 | |||
774 | static const struct fw_device_id sbp2_id_table[] = { | ||
775 | { | ||
776 | .match_flags = FW_MATCH_SPECIFIER_ID | FW_MATCH_VERSION, | ||
777 | .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY, | ||
778 | .version = SBP2_SW_VERSION_ENTRY, | ||
779 | }, | ||
780 | { } | ||
781 | }; | ||
782 | |||
783 | static struct fw_driver sbp2_driver = { | ||
784 | .driver = { | ||
785 | .owner = THIS_MODULE, | ||
786 | .name = sbp2_driver_name, | ||
787 | .bus = &fw_bus_type, | ||
788 | .probe = sbp2_probe, | ||
789 | .remove = sbp2_remove, | ||
790 | }, | ||
791 | .update = sbp2_update, | ||
792 | .id_table = sbp2_id_table, | ||
793 | }; | ||
794 | |||
795 | static unsigned int | ||
796 | sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data) | ||
797 | { | ||
798 | int sam_status; | ||
799 | |||
800 | sense_data[0] = 0x70; | ||
801 | sense_data[1] = 0x0; | ||
802 | sense_data[2] = sbp2_status[1]; | ||
803 | sense_data[3] = sbp2_status[4]; | ||
804 | sense_data[4] = sbp2_status[5]; | ||
805 | sense_data[5] = sbp2_status[6]; | ||
806 | sense_data[6] = sbp2_status[7]; | ||
807 | sense_data[7] = 10; | ||
808 | sense_data[8] = sbp2_status[8]; | ||
809 | sense_data[9] = sbp2_status[9]; | ||
810 | sense_data[10] = sbp2_status[10]; | ||
811 | sense_data[11] = sbp2_status[11]; | ||
812 | sense_data[12] = sbp2_status[2]; | ||
813 | sense_data[13] = sbp2_status[3]; | ||
814 | sense_data[14] = sbp2_status[12]; | ||
815 | sense_data[15] = sbp2_status[13]; | ||
816 | |||
817 | sam_status = sbp2_status[0] & 0x3f; | ||
818 | |||
819 | switch (sam_status) { | ||
820 | case SAM_STAT_GOOD: | ||
821 | case SAM_STAT_CHECK_CONDITION: | ||
822 | case SAM_STAT_CONDITION_MET: | ||
823 | case SAM_STAT_BUSY: | ||
824 | case SAM_STAT_RESERVATION_CONFLICT: | ||
825 | case SAM_STAT_COMMAND_TERMINATED: | ||
826 | return DID_OK << 16 | sam_status; | ||
827 | |||
828 | default: | ||
829 | return DID_ERROR << 16; | ||
830 | } | ||
831 | } | ||
832 | |||
833 | static void | ||
834 | complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status) | ||
835 | { | ||
836 | struct sbp2_command_orb *orb = (struct sbp2_command_orb *)base_orb; | ||
837 | struct fw_unit *unit = orb->unit; | ||
838 | struct fw_device *device = fw_device(unit->device.parent); | ||
839 | struct scatterlist *sg; | ||
840 | int result; | ||
841 | |||
842 | if (status != NULL) { | ||
843 | if (STATUS_GET_DEAD(*status)) | ||
844 | sbp2_agent_reset(unit); | ||
845 | |||
846 | switch (STATUS_GET_RESPONSE(*status)) { | ||
847 | case SBP2_STATUS_REQUEST_COMPLETE: | ||
848 | result = DID_OK << 16; | ||
849 | break; | ||
850 | case SBP2_STATUS_TRANSPORT_FAILURE: | ||
851 | result = DID_BUS_BUSY << 16; | ||
852 | break; | ||
853 | case SBP2_STATUS_ILLEGAL_REQUEST: | ||
854 | case SBP2_STATUS_VENDOR_DEPENDENT: | ||
855 | default: | ||
856 | result = DID_ERROR << 16; | ||
857 | break; | ||
858 | } | ||
859 | |||
860 | if (result == DID_OK << 16 && STATUS_GET_LEN(*status) > 1) | ||
861 | result = sbp2_status_to_sense_data(STATUS_GET_DATA(*status), | ||
862 | orb->cmd->sense_buffer); | ||
863 | } else { | ||
864 | /* | ||
865 | * If the orb completes with status == NULL, something | ||
866 | * went wrong, typically a bus reset happened mid-orb | ||
867 | * or when sending the write (less likely). | ||
868 | */ | ||
869 | result = DID_BUS_BUSY << 16; | ||
870 | } | ||
871 | |||
872 | dma_unmap_single(device->card->device, orb->base.request_bus, | ||
873 | sizeof(orb->request), DMA_TO_DEVICE); | ||
874 | |||
875 | if (orb->cmd->use_sg > 0) { | ||
876 | sg = (struct scatterlist *)orb->cmd->request_buffer; | ||
877 | dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg, | ||
878 | orb->cmd->sc_data_direction); | ||
879 | } | ||
880 | |||
881 | if (orb->page_table_bus != 0) | ||
882 | dma_unmap_single(device->card->device, orb->page_table_bus, | ||
883 | sizeof(orb->page_table_bus), DMA_TO_DEVICE); | ||
884 | |||
885 | if (orb->request_buffer_bus != 0) | ||
886 | dma_unmap_single(device->card->device, orb->request_buffer_bus, | ||
887 | sizeof(orb->request_buffer_bus), | ||
888 | DMA_FROM_DEVICE); | ||
889 | |||
890 | orb->cmd->result = result; | ||
891 | orb->done(orb->cmd); | ||
892 | kfree(orb); | ||
893 | } | ||
894 | |||
895 | static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb) | ||
896 | { | ||
897 | struct sbp2_device *sd = | ||
898 | (struct sbp2_device *)orb->cmd->device->host->hostdata; | ||
899 | struct fw_unit *unit = sd->unit; | ||
900 | struct fw_device *device = fw_device(unit->device.parent); | ||
901 | struct scatterlist *sg; | ||
902 | int sg_len, l, i, j, count; | ||
903 | size_t size; | ||
904 | dma_addr_t sg_addr; | ||
905 | |||
906 | sg = (struct scatterlist *)orb->cmd->request_buffer; | ||
907 | count = dma_map_sg(device->card->device, sg, orb->cmd->use_sg, | ||
908 | orb->cmd->sc_data_direction); | ||
909 | if (count == 0) | ||
910 | goto fail; | ||
911 | |||
912 | /* | ||
913 | * Handle the special case where there is only one element in | ||
914 | * the scatter list by converting it to an immediate block | ||
915 | * request. This is also a workaround for broken devices such | ||
916 | * as the second generation iPod which doesn't support page | ||
917 | * tables. | ||
918 | */ | ||
919 | if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) { | ||
920 | orb->request.data_descriptor.high = sd->address_high; | ||
921 | orb->request.data_descriptor.low = sg_dma_address(sg); | ||
922 | orb->request.misc |= | ||
923 | COMMAND_ORB_DATA_SIZE(sg_dma_len(sg)); | ||
924 | return 0; | ||
925 | } | ||
926 | |||
927 | /* | ||
928 | * Convert the scatterlist to an sbp2 page table. If any | ||
929 | * scatterlist entries are too big for sbp2, we split them as we | ||
930 | * go. Even if we ask the block I/O layer to not give us sg | ||
931 | * elements larger than 65535 bytes, some IOMMUs may merge sg elements | ||
932 | * during DMA mapping, and Linux currently doesn't prevent this. | ||
933 | */ | ||
934 | for (i = 0, j = 0; i < count; i++) { | ||
935 | sg_len = sg_dma_len(sg + i); | ||
936 | sg_addr = sg_dma_address(sg + i); | ||
937 | while (sg_len) { | ||
938 | l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH); | ||
939 | orb->page_table[j].low = sg_addr; | ||
940 | orb->page_table[j].high = (l << 16); | ||
941 | sg_addr += l; | ||
942 | sg_len -= l; | ||
943 | j++; | ||
944 | } | ||
945 | } | ||
946 | |||
947 | size = sizeof(orb->page_table[0]) * j; | ||
948 | |||
949 | /* | ||
950 | * The data_descriptor pointer is the one case where we need | ||
951 | * to fill in the node ID part of the address. All other | ||
952 | * pointers assume that the data referenced reside on the | ||
953 | * initiator (i.e. us), but data_descriptor can refer to data | ||
954 | * on other nodes so we need to put our ID in descriptor.high. | ||
955 | */ | ||
956 | |||
957 | orb->page_table_bus = | ||
958 | dma_map_single(device->card->device, orb->page_table, | ||
959 | size, DMA_TO_DEVICE); | ||
960 | if (dma_mapping_error(orb->page_table_bus)) | ||
961 | goto fail_page_table; | ||
962 | orb->request.data_descriptor.high = sd->address_high; | ||
963 | orb->request.data_descriptor.low = orb->page_table_bus; | ||
964 | orb->request.misc |= | ||
965 | COMMAND_ORB_PAGE_TABLE_PRESENT | | ||
966 | COMMAND_ORB_DATA_SIZE(j); | ||
967 | |||
968 | fw_memcpy_to_be32(orb->page_table, orb->page_table, size); | ||
969 | |||
970 | return 0; | ||
971 | |||
972 | fail_page_table: | ||
973 | dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg, | ||
974 | orb->cmd->sc_data_direction); | ||
975 | fail: | ||
976 | return -ENOMEM; | ||
977 | } | ||
978 | |||
979 | /* SCSI stack integration */ | ||
980 | |||
981 | static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | ||
982 | { | ||
983 | struct sbp2_device *sd = | ||
984 | (struct sbp2_device *)cmd->device->host->hostdata; | ||
985 | struct fw_unit *unit = sd->unit; | ||
986 | struct fw_device *device = fw_device(unit->device.parent); | ||
987 | struct sbp2_command_orb *orb; | ||
988 | |||
989 | /* | ||
990 | * Bidirectional commands are not yet implemented, and unknown | ||
991 | * transfer direction not handled. | ||
992 | */ | ||
993 | if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) { | ||
994 | fw_error("Cannot handle DMA_BIDIRECTIONAL - rejecting command"); | ||
995 | cmd->result = DID_ERROR << 16; | ||
996 | done(cmd); | ||
997 | return 0; | ||
998 | } | ||
999 | |||
1000 | orb = kzalloc(sizeof(*orb), GFP_ATOMIC); | ||
1001 | if (orb == NULL) { | ||
1002 | fw_notify("failed to alloc orb\n"); | ||
1003 | goto fail_alloc; | ||
1004 | } | ||
1005 | |||
1006 | /* Initialize rcode to something not RCODE_COMPLETE. */ | ||
1007 | orb->base.rcode = -1; | ||
1008 | orb->base.request_bus = | ||
1009 | dma_map_single(device->card->device, &orb->request, | ||
1010 | sizeof(orb->request), DMA_TO_DEVICE); | ||
1011 | if (dma_mapping_error(orb->base.request_bus)) | ||
1012 | goto fail_mapping; | ||
1013 | |||
1014 | orb->unit = unit; | ||
1015 | orb->done = done; | ||
1016 | orb->cmd = cmd; | ||
1017 | |||
1018 | orb->request.next.high = SBP2_ORB_NULL; | ||
1019 | orb->request.next.low = 0x0; | ||
1020 | /* | ||
1021 | * At speed 100 we can do 512 bytes per packet, at speed 200, | ||
1022 | * 1024 bytes per packet etc. The SBP-2 max_payload field | ||
1023 | * specifies the max payload size as 2 ^ (max_payload + 2), so | ||
1024 | * if we set this to max_speed + 7, we get the right value. | ||
1025 | */ | ||
1026 | orb->request.misc = | ||
1027 | COMMAND_ORB_MAX_PAYLOAD(device->node->max_speed + 7) | | ||
1028 | COMMAND_ORB_SPEED(device->node->max_speed) | | ||
1029 | COMMAND_ORB_NOTIFY; | ||
1030 | |||
1031 | if (cmd->sc_data_direction == DMA_FROM_DEVICE) | ||
1032 | orb->request.misc |= | ||
1033 | COMMAND_ORB_DIRECTION(SBP2_DIRECTION_FROM_MEDIA); | ||
1034 | else if (cmd->sc_data_direction == DMA_TO_DEVICE) | ||
1035 | orb->request.misc |= | ||
1036 | COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA); | ||
1037 | |||
1038 | if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0) | ||
1039 | goto fail_map_payload; | ||
1040 | |||
1041 | fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request)); | ||
1042 | |||
1043 | memset(orb->request.command_block, | ||
1044 | 0, sizeof(orb->request.command_block)); | ||
1045 | memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd)); | ||
1046 | |||
1047 | orb->base.callback = complete_command_orb; | ||
1048 | |||
1049 | sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation, | ||
1050 | sd->command_block_agent_address + SBP2_ORB_POINTER); | ||
1051 | |||
1052 | return 0; | ||
1053 | |||
1054 | fail_map_payload: | ||
1055 | dma_unmap_single(device->card->device, orb->base.request_bus, | ||
1056 | sizeof(orb->request), DMA_TO_DEVICE); | ||
1057 | fail_mapping: | ||
1058 | kfree(orb); | ||
1059 | fail_alloc: | ||
1060 | return SCSI_MLQUEUE_HOST_BUSY; | ||
1061 | } | ||
1062 | |||
1063 | static int sbp2_scsi_slave_alloc(struct scsi_device *sdev) | ||
1064 | { | ||
1065 | struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata; | ||
1066 | |||
1067 | sdev->allow_restart = 1; | ||
1068 | |||
1069 | if (sd->workarounds & SBP2_WORKAROUND_INQUIRY_36) | ||
1070 | sdev->inquiry_len = 36; | ||
1071 | return 0; | ||
1072 | } | ||
1073 | |||
1074 | static int sbp2_scsi_slave_configure(struct scsi_device *sdev) | ||
1075 | { | ||
1076 | struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata; | ||
1077 | struct fw_unit *unit = sd->unit; | ||
1078 | |||
1079 | sdev->use_10_for_rw = 1; | ||
1080 | |||
1081 | if (sdev->type == TYPE_ROM) | ||
1082 | sdev->use_10_for_ms = 1; | ||
1083 | if (sdev->type == TYPE_DISK && | ||
1084 | sd->workarounds & SBP2_WORKAROUND_MODE_SENSE_8) | ||
1085 | sdev->skip_ms_page_8 = 1; | ||
1086 | if (sd->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) { | ||
1087 | fw_notify("setting fix_capacity for %s\n", unit->device.bus_id); | ||
1088 | sdev->fix_capacity = 1; | ||
1089 | } | ||
1090 | |||
1091 | return 0; | ||
1092 | } | ||
1093 | |||
1094 | /* | ||
1095 | * Called by scsi stack when something has really gone wrong. Usually | ||
1096 | * called when a command has timed-out for some reason. | ||
1097 | */ | ||
1098 | static int sbp2_scsi_abort(struct scsi_cmnd *cmd) | ||
1099 | { | ||
1100 | struct sbp2_device *sd = | ||
1101 | (struct sbp2_device *)cmd->device->host->hostdata; | ||
1102 | struct fw_unit *unit = sd->unit; | ||
1103 | |||
1104 | fw_notify("sbp2_scsi_abort\n"); | ||
1105 | sbp2_agent_reset(unit); | ||
1106 | sbp2_cancel_orbs(unit); | ||
1107 | |||
1108 | return SUCCESS; | ||
1109 | } | ||
1110 | |||
1111 | static struct scsi_host_template scsi_driver_template = { | ||
1112 | .module = THIS_MODULE, | ||
1113 | .name = "SBP-2 IEEE-1394", | ||
1114 | .proc_name = (char *)sbp2_driver_name, | ||
1115 | .queuecommand = sbp2_scsi_queuecommand, | ||
1116 | .slave_alloc = sbp2_scsi_slave_alloc, | ||
1117 | .slave_configure = sbp2_scsi_slave_configure, | ||
1118 | .eh_abort_handler = sbp2_scsi_abort, | ||
1119 | .this_id = -1, | ||
1120 | .sg_tablesize = SG_ALL, | ||
1121 | .use_clustering = ENABLE_CLUSTERING, | ||
1122 | .cmd_per_lun = 1, | ||
1123 | .can_queue = 1, | ||
1124 | }; | ||
1125 | |||
1126 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); | ||
1127 | MODULE_DESCRIPTION("SCSI over IEEE1394"); | ||
1128 | MODULE_LICENSE("GPL"); | ||
1129 | MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); | ||
1130 | |||
1131 | /* Provide a module alias so root-on-sbp2 initrds don't break. */ | ||
1132 | #ifndef CONFIG_IEEE1394_SBP2_MODULE | ||
1133 | MODULE_ALIAS("sbp2"); | ||
1134 | #endif | ||
1135 | |||
1136 | static int __init sbp2_init(void) | ||
1137 | { | ||
1138 | return driver_register(&sbp2_driver.driver); | ||
1139 | } | ||
1140 | |||
1141 | static void __exit sbp2_cleanup(void) | ||
1142 | { | ||
1143 | driver_unregister(&sbp2_driver.driver); | ||
1144 | } | ||
1145 | |||
1146 | module_init(sbp2_init); | ||
1147 | module_exit(sbp2_cleanup); | ||
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c new file mode 100644 index 000000000000..7aebb8ae0efa --- /dev/null +++ b/drivers/firewire/fw-topology.c | |||
@@ -0,0 +1,537 @@ | |||
1 | /* | ||
2 | * Incremental bus scan, based on bus topology | ||
3 | * | ||
4 | * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/wait.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include "fw-transaction.h" | ||
25 | #include "fw-topology.h" | ||
26 | |||
27 | #define SELF_ID_PHY_ID(q) (((q) >> 24) & 0x3f) | ||
28 | #define SELF_ID_EXTENDED(q) (((q) >> 23) & 0x01) | ||
29 | #define SELF_ID_LINK_ON(q) (((q) >> 22) & 0x01) | ||
30 | #define SELF_ID_GAP_COUNT(q) (((q) >> 16) & 0x3f) | ||
31 | #define SELF_ID_PHY_SPEED(q) (((q) >> 14) & 0x03) | ||
32 | #define SELF_ID_CONTENDER(q) (((q) >> 11) & 0x01) | ||
33 | #define SELF_ID_PHY_INITIATOR(q) (((q) >> 1) & 0x01) | ||
34 | #define SELF_ID_MORE_PACKETS(q) (((q) >> 0) & 0x01) | ||
35 | |||
36 | #define SELF_ID_EXT_SEQUENCE(q) (((q) >> 20) & 0x07) | ||
37 | |||
38 | static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count) | ||
39 | { | ||
40 | u32 q; | ||
41 | int port_type, shift, seq; | ||
42 | |||
43 | *total_port_count = 0; | ||
44 | *child_port_count = 0; | ||
45 | |||
46 | shift = 6; | ||
47 | q = *sid; | ||
48 | seq = 0; | ||
49 | |||
50 | while (1) { | ||
51 | port_type = (q >> shift) & 0x03; | ||
52 | switch (port_type) { | ||
53 | case SELFID_PORT_CHILD: | ||
54 | (*child_port_count)++; | ||
55 | case SELFID_PORT_PARENT: | ||
56 | case SELFID_PORT_NCONN: | ||
57 | (*total_port_count)++; | ||
58 | case SELFID_PORT_NONE: | ||
59 | break; | ||
60 | } | ||
61 | |||
62 | shift -= 2; | ||
63 | if (shift == 0) { | ||
64 | if (!SELF_ID_MORE_PACKETS(q)) | ||
65 | return sid + 1; | ||
66 | |||
67 | shift = 16; | ||
68 | sid++; | ||
69 | q = *sid; | ||
70 | |||
71 | /* | ||
72 | * Check that the extra packets actually are | ||
73 | * extended self ID packets and that the | ||
74 | * sequence numbers in the extended self ID | ||
75 | * packets increase as expected. | ||
76 | */ | ||
77 | |||
78 | if (!SELF_ID_EXTENDED(q) || | ||
79 | seq != SELF_ID_EXT_SEQUENCE(q)) | ||
80 | return NULL; | ||
81 | |||
82 | seq++; | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
87 | static int get_port_type(u32 *sid, int port_index) | ||
88 | { | ||
89 | int index, shift; | ||
90 | |||
91 | index = (port_index + 5) / 8; | ||
92 | shift = 16 - ((port_index + 5) & 7) * 2; | ||
93 | return (sid[index] >> shift) & 0x03; | ||
94 | } | ||
95 | |||
96 | static struct fw_node *fw_node_create(u32 sid, int port_count, int color) | ||
97 | { | ||
98 | struct fw_node *node; | ||
99 | |||
100 | node = kzalloc(sizeof(*node) + port_count * sizeof(node->ports[0]), | ||
101 | GFP_ATOMIC); | ||
102 | if (node == NULL) | ||
103 | return NULL; | ||
104 | |||
105 | node->color = color; | ||
106 | node->node_id = LOCAL_BUS | SELF_ID_PHY_ID(sid); | ||
107 | node->link_on = SELF_ID_LINK_ON(sid); | ||
108 | node->phy_speed = SELF_ID_PHY_SPEED(sid); | ||
109 | node->port_count = port_count; | ||
110 | |||
111 | atomic_set(&node->ref_count, 1); | ||
112 | INIT_LIST_HEAD(&node->link); | ||
113 | |||
114 | return node; | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * Compute the maximum hop count for this node and it's children. The | ||
119 | * maximum hop count is the maximum number of connections between any | ||
120 | * two nodes in the subtree rooted at this node. We need this for | ||
121 | * setting the gap count. As we build the tree bottom up in | ||
122 | * build_tree() below, this is fairly easy to do: for each node we | ||
123 | * maintain the max hop count and the max depth, ie the number of hops | ||
124 | * to the furthest leaf. Computing the max hop count breaks down into | ||
125 | * two cases: either the path goes through this node, in which case | ||
126 | * the hop count is the sum of the two biggest child depths plus 2. | ||
127 | * Or it could be the case that the max hop path is entirely | ||
128 | * containted in a child tree, in which case the max hop count is just | ||
129 | * the max hop count of this child. | ||
130 | */ | ||
131 | static void update_hop_count(struct fw_node *node) | ||
132 | { | ||
133 | int depths[2] = { -1, -1 }; | ||
134 | int max_child_hops = 0; | ||
135 | int i; | ||
136 | |||
137 | for (i = 0; i < node->port_count; i++) { | ||
138 | if (node->ports[i].node == NULL) | ||
139 | continue; | ||
140 | |||
141 | if (node->ports[i].node->max_hops > max_child_hops) | ||
142 | max_child_hops = node->ports[i].node->max_hops; | ||
143 | |||
144 | if (node->ports[i].node->max_depth > depths[0]) { | ||
145 | depths[1] = depths[0]; | ||
146 | depths[0] = node->ports[i].node->max_depth; | ||
147 | } else if (node->ports[i].node->max_depth > depths[1]) | ||
148 | depths[1] = node->ports[i].node->max_depth; | ||
149 | } | ||
150 | |||
151 | node->max_depth = depths[0] + 1; | ||
152 | node->max_hops = max(max_child_hops, depths[0] + depths[1] + 2); | ||
153 | } | ||
154 | |||
155 | |||
156 | /** | ||
157 | * build_tree - Build the tree representation of the topology | ||
158 | * @self_ids: array of self IDs to create the tree from | ||
159 | * @self_id_count: the length of the self_ids array | ||
160 | * @local_id: the node ID of the local node | ||
161 | * | ||
162 | * This function builds the tree representation of the topology given | ||
163 | * by the self IDs from the latest bus reset. During the construction | ||
164 | * of the tree, the function checks that the self IDs are valid and | ||
165 | * internally consistent. On succcess this funtions returns the | ||
166 | * fw_node corresponding to the local card otherwise NULL. | ||
167 | */ | ||
168 | static struct fw_node *build_tree(struct fw_card *card, | ||
169 | u32 *sid, int self_id_count) | ||
170 | { | ||
171 | struct fw_node *node, *child, *local_node, *irm_node; | ||
172 | struct list_head stack, *h; | ||
173 | u32 *next_sid, *end, q; | ||
174 | int i, port_count, child_port_count, phy_id, parent_count, stack_depth; | ||
175 | int gap_count, topology_type; | ||
176 | |||
177 | local_node = NULL; | ||
178 | node = NULL; | ||
179 | INIT_LIST_HEAD(&stack); | ||
180 | stack_depth = 0; | ||
181 | end = sid + self_id_count; | ||
182 | phy_id = 0; | ||
183 | irm_node = NULL; | ||
184 | gap_count = SELF_ID_GAP_COUNT(*sid); | ||
185 | topology_type = 0; | ||
186 | |||
187 | while (sid < end) { | ||
188 | next_sid = count_ports(sid, &port_count, &child_port_count); | ||
189 | |||
190 | if (next_sid == NULL) { | ||
191 | fw_error("Inconsistent extended self IDs.\n"); | ||
192 | return NULL; | ||
193 | } | ||
194 | |||
195 | q = *sid; | ||
196 | if (phy_id != SELF_ID_PHY_ID(q)) { | ||
197 | fw_error("PHY ID mismatch in self ID: %d != %d.\n", | ||
198 | phy_id, SELF_ID_PHY_ID(q)); | ||
199 | return NULL; | ||
200 | } | ||
201 | |||
202 | if (child_port_count > stack_depth) { | ||
203 | fw_error("Topology stack underflow\n"); | ||
204 | return NULL; | ||
205 | } | ||
206 | |||
207 | /* | ||
208 | * Seek back from the top of our stack to find the | ||
209 | * start of the child nodes for this node. | ||
210 | */ | ||
211 | for (i = 0, h = &stack; i < child_port_count; i++) | ||
212 | h = h->prev; | ||
213 | child = fw_node(h); | ||
214 | |||
215 | node = fw_node_create(q, port_count, card->color); | ||
216 | if (node == NULL) { | ||
217 | fw_error("Out of memory while building topology."); | ||
218 | return NULL; | ||
219 | } | ||
220 | |||
221 | if (phy_id == (card->node_id & 0x3f)) | ||
222 | local_node = node; | ||
223 | |||
224 | if (SELF_ID_CONTENDER(q)) | ||
225 | irm_node = node; | ||
226 | |||
227 | if (node->phy_speed == SCODE_BETA) | ||
228 | topology_type |= FW_TOPOLOGY_B; | ||
229 | else | ||
230 | topology_type |= FW_TOPOLOGY_A; | ||
231 | |||
232 | parent_count = 0; | ||
233 | |||
234 | for (i = 0; i < port_count; i++) { | ||
235 | switch (get_port_type(sid, i)) { | ||
236 | case SELFID_PORT_PARENT: | ||
237 | /* | ||
238 | * Who's your daddy? We dont know the | ||
239 | * parent node at this time, so we | ||
240 | * temporarily abuse node->color for | ||
241 | * remembering the entry in the | ||
242 | * node->ports array where the parent | ||
243 | * node should be. Later, when we | ||
244 | * handle the parent node, we fix up | ||
245 | * the reference. | ||
246 | */ | ||
247 | parent_count++; | ||
248 | node->color = i; | ||
249 | break; | ||
250 | |||
251 | case SELFID_PORT_CHILD: | ||
252 | node->ports[i].node = child; | ||
253 | /* | ||
254 | * Fix up parent reference for this | ||
255 | * child node. | ||
256 | */ | ||
257 | child->ports[child->color].node = node; | ||
258 | child->color = card->color; | ||
259 | child = fw_node(child->link.next); | ||
260 | break; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | /* | ||
265 | * Check that the node reports exactly one parent | ||
266 | * port, except for the root, which of course should | ||
267 | * have no parents. | ||
268 | */ | ||
269 | if ((next_sid == end && parent_count != 0) || | ||
270 | (next_sid < end && parent_count != 1)) { | ||
271 | fw_error("Parent port inconsistency for node %d: " | ||
272 | "parent_count=%d\n", phy_id, parent_count); | ||
273 | return NULL; | ||
274 | } | ||
275 | |||
276 | /* Pop the child nodes off the stack and push the new node. */ | ||
277 | __list_del(h->prev, &stack); | ||
278 | list_add_tail(&node->link, &stack); | ||
279 | stack_depth += 1 - child_port_count; | ||
280 | |||
281 | /* | ||
282 | * If all PHYs does not report the same gap count | ||
283 | * setting, we fall back to 63 which will force a gap | ||
284 | * count reconfiguration and a reset. | ||
285 | */ | ||
286 | if (SELF_ID_GAP_COUNT(q) != gap_count) | ||
287 | gap_count = 63; | ||
288 | |||
289 | update_hop_count(node); | ||
290 | |||
291 | sid = next_sid; | ||
292 | phy_id++; | ||
293 | } | ||
294 | |||
295 | card->root_node = node; | ||
296 | card->irm_node = irm_node; | ||
297 | card->gap_count = gap_count; | ||
298 | card->topology_type = topology_type; | ||
299 | |||
300 | return local_node; | ||
301 | } | ||
302 | |||
303 | typedef void (*fw_node_callback_t)(struct fw_card * card, | ||
304 | struct fw_node * node, | ||
305 | struct fw_node * parent); | ||
306 | |||
307 | static void | ||
308 | for_each_fw_node(struct fw_card *card, struct fw_node *root, | ||
309 | fw_node_callback_t callback) | ||
310 | { | ||
311 | struct list_head list; | ||
312 | struct fw_node *node, *next, *child, *parent; | ||
313 | int i; | ||
314 | |||
315 | INIT_LIST_HEAD(&list); | ||
316 | |||
317 | fw_node_get(root); | ||
318 | list_add_tail(&root->link, &list); | ||
319 | parent = NULL; | ||
320 | list_for_each_entry(node, &list, link) { | ||
321 | node->color = card->color; | ||
322 | |||
323 | for (i = 0; i < node->port_count; i++) { | ||
324 | child = node->ports[i].node; | ||
325 | if (!child) | ||
326 | continue; | ||
327 | if (child->color == card->color) | ||
328 | parent = child; | ||
329 | else { | ||
330 | fw_node_get(child); | ||
331 | list_add_tail(&child->link, &list); | ||
332 | } | ||
333 | } | ||
334 | |||
335 | callback(card, node, parent); | ||
336 | } | ||
337 | |||
338 | list_for_each_entry_safe(node, next, &list, link) | ||
339 | fw_node_put(node); | ||
340 | } | ||
341 | |||
342 | static void | ||
343 | report_lost_node(struct fw_card *card, | ||
344 | struct fw_node *node, struct fw_node *parent) | ||
345 | { | ||
346 | fw_node_event(card, node, FW_NODE_DESTROYED); | ||
347 | fw_node_put(node); | ||
348 | } | ||
349 | |||
350 | static void | ||
351 | report_found_node(struct fw_card *card, | ||
352 | struct fw_node *node, struct fw_node *parent) | ||
353 | { | ||
354 | int b_path = (node->phy_speed == SCODE_BETA); | ||
355 | |||
356 | if (parent != NULL) { | ||
357 | /* min() macro doesn't work here with gcc 3.4 */ | ||
358 | node->max_speed = parent->max_speed < node->phy_speed ? | ||
359 | parent->max_speed : node->phy_speed; | ||
360 | node->b_path = parent->b_path && b_path; | ||
361 | } else { | ||
362 | node->max_speed = node->phy_speed; | ||
363 | node->b_path = b_path; | ||
364 | } | ||
365 | |||
366 | fw_node_event(card, node, FW_NODE_CREATED); | ||
367 | } | ||
368 | |||
369 | void fw_destroy_nodes(struct fw_card *card) | ||
370 | { | ||
371 | unsigned long flags; | ||
372 | |||
373 | spin_lock_irqsave(&card->lock, flags); | ||
374 | card->color++; | ||
375 | if (card->local_node != NULL) | ||
376 | for_each_fw_node(card, card->local_node, report_lost_node); | ||
377 | spin_unlock_irqrestore(&card->lock, flags); | ||
378 | } | ||
379 | |||
380 | static void move_tree(struct fw_node *node0, struct fw_node *node1, int port) | ||
381 | { | ||
382 | struct fw_node *tree; | ||
383 | int i; | ||
384 | |||
385 | tree = node1->ports[port].node; | ||
386 | node0->ports[port].node = tree; | ||
387 | for (i = 0; i < tree->port_count; i++) { | ||
388 | if (tree->ports[i].node == node1) { | ||
389 | tree->ports[i].node = node0; | ||
390 | break; | ||
391 | } | ||
392 | } | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * update_tree - compare the old topology tree for card with the new | ||
397 | * one specified by root. Queue the nodes and mark them as either | ||
398 | * found, lost or updated. Update the nodes in the card topology tree | ||
399 | * as we go. | ||
400 | */ | ||
401 | static void | ||
402 | update_tree(struct fw_card *card, struct fw_node *root) | ||
403 | { | ||
404 | struct list_head list0, list1; | ||
405 | struct fw_node *node0, *node1; | ||
406 | int i, event; | ||
407 | |||
408 | INIT_LIST_HEAD(&list0); | ||
409 | list_add_tail(&card->local_node->link, &list0); | ||
410 | INIT_LIST_HEAD(&list1); | ||
411 | list_add_tail(&root->link, &list1); | ||
412 | |||
413 | node0 = fw_node(list0.next); | ||
414 | node1 = fw_node(list1.next); | ||
415 | |||
416 | while (&node0->link != &list0) { | ||
417 | |||
418 | /* assert(node0->port_count == node1->port_count); */ | ||
419 | if (node0->link_on && !node1->link_on) | ||
420 | event = FW_NODE_LINK_OFF; | ||
421 | else if (!node0->link_on && node1->link_on) | ||
422 | event = FW_NODE_LINK_ON; | ||
423 | else | ||
424 | event = FW_NODE_UPDATED; | ||
425 | |||
426 | node0->node_id = node1->node_id; | ||
427 | node0->color = card->color; | ||
428 | node0->link_on = node1->link_on; | ||
429 | node0->initiated_reset = node1->initiated_reset; | ||
430 | node0->max_hops = node1->max_hops; | ||
431 | node1->color = card->color; | ||
432 | fw_node_event(card, node0, event); | ||
433 | |||
434 | if (card->root_node == node1) | ||
435 | card->root_node = node0; | ||
436 | if (card->irm_node == node1) | ||
437 | card->irm_node = node0; | ||
438 | |||
439 | for (i = 0; i < node0->port_count; i++) { | ||
440 | if (node0->ports[i].node && node1->ports[i].node) { | ||
441 | /* | ||
442 | * This port didn't change, queue the | ||
443 | * connected node for further | ||
444 | * investigation. | ||
445 | */ | ||
446 | if (node0->ports[i].node->color == card->color) | ||
447 | continue; | ||
448 | list_add_tail(&node0->ports[i].node->link, | ||
449 | &list0); | ||
450 | list_add_tail(&node1->ports[i].node->link, | ||
451 | &list1); | ||
452 | } else if (node0->ports[i].node) { | ||
453 | /* | ||
454 | * The nodes connected here were | ||
455 | * unplugged; unref the lost nodes and | ||
456 | * queue FW_NODE_LOST callbacks for | ||
457 | * them. | ||
458 | */ | ||
459 | |||
460 | for_each_fw_node(card, node0->ports[i].node, | ||
461 | report_lost_node); | ||
462 | node0->ports[i].node = NULL; | ||
463 | } else if (node1->ports[i].node) { | ||
464 | /* | ||
465 | * One or more node were connected to | ||
466 | * this port. Move the new nodes into | ||
467 | * the tree and queue FW_NODE_CREATED | ||
468 | * callbacks for them. | ||
469 | */ | ||
470 | move_tree(node0, node1, i); | ||
471 | for_each_fw_node(card, node0->ports[i].node, | ||
472 | report_found_node); | ||
473 | } | ||
474 | } | ||
475 | |||
476 | node0 = fw_node(node0->link.next); | ||
477 | node1 = fw_node(node1->link.next); | ||
478 | } | ||
479 | } | ||
480 | |||
481 | static void | ||
482 | update_topology_map(struct fw_card *card, u32 *self_ids, int self_id_count) | ||
483 | { | ||
484 | int node_count; | ||
485 | |||
486 | card->topology_map[1]++; | ||
487 | node_count = (card->root_node->node_id & 0x3f) + 1; | ||
488 | card->topology_map[2] = (node_count << 16) | self_id_count; | ||
489 | card->topology_map[0] = (self_id_count + 2) << 16; | ||
490 | memcpy(&card->topology_map[3], self_ids, self_id_count * 4); | ||
491 | fw_compute_block_crc(card->topology_map); | ||
492 | } | ||
493 | |||
494 | void | ||
495 | fw_core_handle_bus_reset(struct fw_card *card, | ||
496 | int node_id, int generation, | ||
497 | int self_id_count, u32 * self_ids) | ||
498 | { | ||
499 | struct fw_node *local_node; | ||
500 | unsigned long flags; | ||
501 | |||
502 | fw_flush_transactions(card); | ||
503 | |||
504 | spin_lock_irqsave(&card->lock, flags); | ||
505 | |||
506 | /* | ||
507 | * If the new topology has a different self_id_count the topology | ||
508 | * changed, either nodes were added or removed. In that case we | ||
509 | * reset the IRM reset counter. | ||
510 | */ | ||
511 | if (card->self_id_count != self_id_count) | ||
512 | card->bm_retries = 0; | ||
513 | |||
514 | card->node_id = node_id; | ||
515 | card->generation = generation; | ||
516 | card->reset_jiffies = jiffies; | ||
517 | schedule_delayed_work(&card->work, 0); | ||
518 | |||
519 | local_node = build_tree(card, self_ids, self_id_count); | ||
520 | |||
521 | update_topology_map(card, self_ids, self_id_count); | ||
522 | |||
523 | card->color++; | ||
524 | |||
525 | if (local_node == NULL) { | ||
526 | fw_error("topology build failed\n"); | ||
527 | /* FIXME: We need to issue a bus reset in this case. */ | ||
528 | } else if (card->local_node == NULL) { | ||
529 | card->local_node = local_node; | ||
530 | for_each_fw_node(card, local_node, report_found_node); | ||
531 | } else { | ||
532 | update_tree(card, local_node); | ||
533 | } | ||
534 | |||
535 | spin_unlock_irqrestore(&card->lock, flags); | ||
536 | } | ||
537 | EXPORT_SYMBOL(fw_core_handle_bus_reset); | ||
diff --git a/drivers/firewire/fw-topology.h b/drivers/firewire/fw-topology.h new file mode 100644 index 000000000000..363b6cbcd0b3 --- /dev/null +++ b/drivers/firewire/fw-topology.h | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2003-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software Foundation, | ||
16 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | */ | ||
18 | |||
19 | #ifndef __fw_topology_h | ||
20 | #define __fw_topology_h | ||
21 | |||
22 | enum { | ||
23 | FW_TOPOLOGY_A = 0x01, | ||
24 | FW_TOPOLOGY_B = 0x02, | ||
25 | FW_TOPOLOGY_MIXED = 0x03, | ||
26 | }; | ||
27 | |||
28 | enum { | ||
29 | FW_NODE_CREATED = 0x00, | ||
30 | FW_NODE_UPDATED = 0x01, | ||
31 | FW_NODE_DESTROYED = 0x02, | ||
32 | FW_NODE_LINK_ON = 0x03, | ||
33 | FW_NODE_LINK_OFF = 0x04, | ||
34 | }; | ||
35 | |||
36 | struct fw_port { | ||
37 | struct fw_node *node; | ||
38 | unsigned speed : 3; /* S100, S200, ... S3200 */ | ||
39 | }; | ||
40 | |||
41 | struct fw_node { | ||
42 | u16 node_id; | ||
43 | u8 color; | ||
44 | u8 port_count; | ||
45 | unsigned link_on : 1; | ||
46 | unsigned initiated_reset : 1; | ||
47 | unsigned b_path : 1; | ||
48 | u8 phy_speed : 3; /* As in the self ID packet. */ | ||
49 | u8 max_speed : 5; /* Minimum of all phy-speeds and port speeds on | ||
50 | * the path from the local node to this node. */ | ||
51 | u8 max_depth : 4; /* Maximum depth to any leaf node */ | ||
52 | u8 max_hops : 4; /* Max hops in this sub tree */ | ||
53 | atomic_t ref_count; | ||
54 | |||
55 | /* For serializing node topology into a list. */ | ||
56 | struct list_head link; | ||
57 | |||
58 | /* Upper layer specific data. */ | ||
59 | void *data; | ||
60 | |||
61 | struct fw_port ports[0]; | ||
62 | }; | ||
63 | |||
64 | static inline struct fw_node * | ||
65 | fw_node(struct list_head *l) | ||
66 | { | ||
67 | return list_entry(l, struct fw_node, link); | ||
68 | } | ||
69 | |||
70 | static inline struct fw_node * | ||
71 | fw_node_get(struct fw_node *node) | ||
72 | { | ||
73 | atomic_inc(&node->ref_count); | ||
74 | |||
75 | return node; | ||
76 | } | ||
77 | |||
78 | static inline void | ||
79 | fw_node_put(struct fw_node *node) | ||
80 | { | ||
81 | if (atomic_dec_and_test(&node->ref_count)) | ||
82 | kfree(node); | ||
83 | } | ||
84 | |||
85 | void | ||
86 | fw_destroy_nodes(struct fw_card *card); | ||
87 | |||
88 | int | ||
89 | fw_compute_block_crc(u32 *block); | ||
90 | |||
91 | |||
92 | #endif /* __fw_topology_h */ | ||
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c new file mode 100644 index 000000000000..80d0121463d0 --- /dev/null +++ b/drivers/firewire/fw-transaction.c | |||
@@ -0,0 +1,910 @@ | |||
1 | /* | ||
2 | * Core IEEE1394 transaction logic | ||
3 | * | ||
4 | * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/pci.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/poll.h> | ||
28 | #include <linux/list.h> | ||
29 | #include <linux/kthread.h> | ||
30 | #include <asm/uaccess.h> | ||
31 | #include <asm/semaphore.h> | ||
32 | |||
33 | #include "fw-transaction.h" | ||
34 | #include "fw-topology.h" | ||
35 | #include "fw-device.h" | ||
36 | |||
37 | #define HEADER_PRI(pri) ((pri) << 0) | ||
38 | #define HEADER_TCODE(tcode) ((tcode) << 4) | ||
39 | #define HEADER_RETRY(retry) ((retry) << 8) | ||
40 | #define HEADER_TLABEL(tlabel) ((tlabel) << 10) | ||
41 | #define HEADER_DESTINATION(destination) ((destination) << 16) | ||
42 | #define HEADER_SOURCE(source) ((source) << 16) | ||
43 | #define HEADER_RCODE(rcode) ((rcode) << 12) | ||
44 | #define HEADER_OFFSET_HIGH(offset_high) ((offset_high) << 0) | ||
45 | #define HEADER_DATA_LENGTH(length) ((length) << 16) | ||
46 | #define HEADER_EXTENDED_TCODE(tcode) ((tcode) << 0) | ||
47 | |||
48 | #define HEADER_GET_TCODE(q) (((q) >> 4) & 0x0f) | ||
49 | #define HEADER_GET_TLABEL(q) (((q) >> 10) & 0x3f) | ||
50 | #define HEADER_GET_RCODE(q) (((q) >> 12) & 0x0f) | ||
51 | #define HEADER_GET_DESTINATION(q) (((q) >> 16) & 0xffff) | ||
52 | #define HEADER_GET_SOURCE(q) (((q) >> 16) & 0xffff) | ||
53 | #define HEADER_GET_OFFSET_HIGH(q) (((q) >> 0) & 0xffff) | ||
54 | #define HEADER_GET_DATA_LENGTH(q) (((q) >> 16) & 0xffff) | ||
55 | #define HEADER_GET_EXTENDED_TCODE(q) (((q) >> 0) & 0xffff) | ||
56 | |||
57 | #define PHY_CONFIG_GAP_COUNT(gap_count) (((gap_count) << 16) | (1 << 22)) | ||
58 | #define PHY_CONFIG_ROOT_ID(node_id) ((((node_id) & 0x3f) << 24) | (1 << 23)) | ||
59 | #define PHY_IDENTIFIER(id) ((id) << 30) | ||
60 | |||
61 | static int | ||
62 | close_transaction(struct fw_transaction *transaction, | ||
63 | struct fw_card *card, int rcode, | ||
64 | u32 *payload, size_t length) | ||
65 | { | ||
66 | struct fw_transaction *t; | ||
67 | unsigned long flags; | ||
68 | |||
69 | spin_lock_irqsave(&card->lock, flags); | ||
70 | list_for_each_entry(t, &card->transaction_list, link) { | ||
71 | if (t == transaction) { | ||
72 | list_del(&t->link); | ||
73 | card->tlabel_mask &= ~(1 << t->tlabel); | ||
74 | break; | ||
75 | } | ||
76 | } | ||
77 | spin_unlock_irqrestore(&card->lock, flags); | ||
78 | |||
79 | if (&t->link != &card->transaction_list) { | ||
80 | t->callback(card, rcode, payload, length, t->callback_data); | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | return -ENOENT; | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * Only valid for transactions that are potentially pending (ie have | ||
89 | * been sent). | ||
90 | */ | ||
91 | int | ||
92 | fw_cancel_transaction(struct fw_card *card, | ||
93 | struct fw_transaction *transaction) | ||
94 | { | ||
95 | /* | ||
96 | * Cancel the packet transmission if it's still queued. That | ||
97 | * will call the packet transmission callback which cancels | ||
98 | * the transaction. | ||
99 | */ | ||
100 | |||
101 | if (card->driver->cancel_packet(card, &transaction->packet) == 0) | ||
102 | return 0; | ||
103 | |||
104 | /* | ||
105 | * If the request packet has already been sent, we need to see | ||
106 | * if the transaction is still pending and remove it in that case. | ||
107 | */ | ||
108 | |||
109 | return close_transaction(transaction, card, RCODE_CANCELLED, NULL, 0); | ||
110 | } | ||
111 | EXPORT_SYMBOL(fw_cancel_transaction); | ||
112 | |||
113 | static void | ||
114 | transmit_complete_callback(struct fw_packet *packet, | ||
115 | struct fw_card *card, int status) | ||
116 | { | ||
117 | struct fw_transaction *t = | ||
118 | container_of(packet, struct fw_transaction, packet); | ||
119 | |||
120 | switch (status) { | ||
121 | case ACK_COMPLETE: | ||
122 | close_transaction(t, card, RCODE_COMPLETE, NULL, 0); | ||
123 | break; | ||
124 | case ACK_PENDING: | ||
125 | t->timestamp = packet->timestamp; | ||
126 | break; | ||
127 | case ACK_BUSY_X: | ||
128 | case ACK_BUSY_A: | ||
129 | case ACK_BUSY_B: | ||
130 | close_transaction(t, card, RCODE_BUSY, NULL, 0); | ||
131 | break; | ||
132 | case ACK_DATA_ERROR: | ||
133 | close_transaction(t, card, RCODE_DATA_ERROR, NULL, 0); | ||
134 | break; | ||
135 | case ACK_TYPE_ERROR: | ||
136 | close_transaction(t, card, RCODE_TYPE_ERROR, NULL, 0); | ||
137 | break; | ||
138 | default: | ||
139 | /* | ||
140 | * In this case the ack is really a juju specific | ||
141 | * rcode, so just forward that to the callback. | ||
142 | */ | ||
143 | close_transaction(t, card, status, NULL, 0); | ||
144 | break; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | static void | ||
149 | fw_fill_request(struct fw_packet *packet, int tcode, int tlabel, | ||
150 | int node_id, int source_id, int generation, int speed, | ||
151 | unsigned long long offset, void *payload, size_t length) | ||
152 | { | ||
153 | int ext_tcode; | ||
154 | |||
155 | if (tcode > 0x10) { | ||
156 | ext_tcode = tcode - 0x10; | ||
157 | tcode = TCODE_LOCK_REQUEST; | ||
158 | } else | ||
159 | ext_tcode = 0; | ||
160 | |||
161 | packet->header[0] = | ||
162 | HEADER_RETRY(RETRY_X) | | ||
163 | HEADER_TLABEL(tlabel) | | ||
164 | HEADER_TCODE(tcode) | | ||
165 | HEADER_DESTINATION(node_id); | ||
166 | packet->header[1] = | ||
167 | HEADER_OFFSET_HIGH(offset >> 32) | HEADER_SOURCE(source_id); | ||
168 | packet->header[2] = | ||
169 | offset; | ||
170 | |||
171 | switch (tcode) { | ||
172 | case TCODE_WRITE_QUADLET_REQUEST: | ||
173 | packet->header[3] = *(u32 *)payload; | ||
174 | packet->header_length = 16; | ||
175 | packet->payload_length = 0; | ||
176 | break; | ||
177 | |||
178 | case TCODE_LOCK_REQUEST: | ||
179 | case TCODE_WRITE_BLOCK_REQUEST: | ||
180 | packet->header[3] = | ||
181 | HEADER_DATA_LENGTH(length) | | ||
182 | HEADER_EXTENDED_TCODE(ext_tcode); | ||
183 | packet->header_length = 16; | ||
184 | packet->payload = payload; | ||
185 | packet->payload_length = length; | ||
186 | break; | ||
187 | |||
188 | case TCODE_READ_QUADLET_REQUEST: | ||
189 | packet->header_length = 12; | ||
190 | packet->payload_length = 0; | ||
191 | break; | ||
192 | |||
193 | case TCODE_READ_BLOCK_REQUEST: | ||
194 | packet->header[3] = | ||
195 | HEADER_DATA_LENGTH(length) | | ||
196 | HEADER_EXTENDED_TCODE(ext_tcode); | ||
197 | packet->header_length = 16; | ||
198 | packet->payload_length = 0; | ||
199 | break; | ||
200 | } | ||
201 | |||
202 | packet->speed = speed; | ||
203 | packet->generation = generation; | ||
204 | packet->ack = 0; | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * This function provides low-level access to the IEEE1394 transaction | ||
209 | * logic. Most C programs would use either fw_read(), fw_write() or | ||
210 | * fw_lock() instead - those function are convenience wrappers for | ||
211 | * this function. The fw_send_request() function is primarily | ||
212 | * provided as a flexible, one-stop entry point for languages bindings | ||
213 | * and protocol bindings. | ||
214 | * | ||
215 | * FIXME: Document this function further, in particular the possible | ||
216 | * values for rcode in the callback. In short, we map ACK_COMPLETE to | ||
217 | * RCODE_COMPLETE, internal errors set errno and set rcode to | ||
218 | * RCODE_SEND_ERROR (which is out of range for standard ieee1394 | ||
219 | * rcodes). All other rcodes are forwarded unchanged. For all | ||
220 | * errors, payload is NULL, length is 0. | ||
221 | * | ||
222 | * Can not expect the callback to be called before the function | ||
223 | * returns, though this does happen in some cases (ACK_COMPLETE and | ||
224 | * errors). | ||
225 | * | ||
226 | * The payload is only used for write requests and must not be freed | ||
227 | * until the callback has been called. | ||
228 | * | ||
229 | * @param card the card from which to send the request | ||
230 | * @param tcode the tcode for this transaction. Do not use | ||
231 | * TCODE_LOCK_REQUEST directly, insted use TCODE_LOCK_MASK_SWAP | ||
232 | * etc. to specify tcode and ext_tcode. | ||
233 | * @param node_id the destination node ID (bus ID and PHY ID concatenated) | ||
234 | * @param generation the generation for which node_id is valid | ||
235 | * @param speed the speed to use for sending the request | ||
236 | * @param offset the 48 bit offset on the destination node | ||
237 | * @param payload the data payload for the request subaction | ||
238 | * @param length the length in bytes of the data to read | ||
239 | * @param callback function to be called when the transaction is completed | ||
240 | * @param callback_data pointer to arbitrary data, which will be | ||
241 | * passed to the callback | ||
242 | */ | ||
243 | void | ||
244 | fw_send_request(struct fw_card *card, struct fw_transaction *t, | ||
245 | int tcode, int node_id, int generation, int speed, | ||
246 | unsigned long long offset, | ||
247 | void *payload, size_t length, | ||
248 | fw_transaction_callback_t callback, void *callback_data) | ||
249 | { | ||
250 | unsigned long flags; | ||
251 | int tlabel, source; | ||
252 | |||
253 | /* | ||
254 | * Bump the flush timer up 100ms first of all so we | ||
255 | * don't race with a flush timer callback. | ||
256 | */ | ||
257 | |||
258 | mod_timer(&card->flush_timer, jiffies + DIV_ROUND_UP(HZ, 10)); | ||
259 | |||
260 | /* | ||
261 | * Allocate tlabel from the bitmap and put the transaction on | ||
262 | * the list while holding the card spinlock. | ||
263 | */ | ||
264 | |||
265 | spin_lock_irqsave(&card->lock, flags); | ||
266 | |||
267 | source = card->node_id; | ||
268 | tlabel = card->current_tlabel; | ||
269 | if (card->tlabel_mask & (1 << tlabel)) { | ||
270 | spin_unlock_irqrestore(&card->lock, flags); | ||
271 | callback(card, RCODE_SEND_ERROR, NULL, 0, callback_data); | ||
272 | return; | ||
273 | } | ||
274 | |||
275 | card->current_tlabel = (card->current_tlabel + 1) & 0x1f; | ||
276 | card->tlabel_mask |= (1 << tlabel); | ||
277 | |||
278 | list_add_tail(&t->link, &card->transaction_list); | ||
279 | |||
280 | spin_unlock_irqrestore(&card->lock, flags); | ||
281 | |||
282 | /* Initialize rest of transaction, fill out packet and send it. */ | ||
283 | t->node_id = node_id; | ||
284 | t->tlabel = tlabel; | ||
285 | t->callback = callback; | ||
286 | t->callback_data = callback_data; | ||
287 | |||
288 | fw_fill_request(&t->packet, tcode, t->tlabel, | ||
289 | node_id, source, generation, | ||
290 | speed, offset, payload, length); | ||
291 | t->packet.callback = transmit_complete_callback; | ||
292 | |||
293 | card->driver->send_request(card, &t->packet); | ||
294 | } | ||
295 | EXPORT_SYMBOL(fw_send_request); | ||
296 | |||
297 | static void | ||
298 | transmit_phy_packet_callback(struct fw_packet *packet, | ||
299 | struct fw_card *card, int status) | ||
300 | { | ||
301 | kfree(packet); | ||
302 | } | ||
303 | |||
304 | static void send_phy_packet(struct fw_card *card, u32 data, int generation) | ||
305 | { | ||
306 | struct fw_packet *packet; | ||
307 | |||
308 | packet = kzalloc(sizeof(*packet), GFP_ATOMIC); | ||
309 | if (packet == NULL) | ||
310 | return; | ||
311 | |||
312 | packet->header[0] = data; | ||
313 | packet->header[1] = ~data; | ||
314 | packet->header_length = 8; | ||
315 | packet->payload_length = 0; | ||
316 | packet->speed = SCODE_100; | ||
317 | packet->generation = generation; | ||
318 | packet->callback = transmit_phy_packet_callback; | ||
319 | |||
320 | card->driver->send_request(card, packet); | ||
321 | } | ||
322 | |||
323 | void fw_send_phy_config(struct fw_card *card, | ||
324 | int node_id, int generation, int gap_count) | ||
325 | { | ||
326 | u32 q; | ||
327 | |||
328 | q = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | | ||
329 | PHY_CONFIG_ROOT_ID(node_id) | | ||
330 | PHY_CONFIG_GAP_COUNT(gap_count); | ||
331 | |||
332 | send_phy_packet(card, q, generation); | ||
333 | } | ||
334 | |||
335 | void fw_flush_transactions(struct fw_card *card) | ||
336 | { | ||
337 | struct fw_transaction *t, *next; | ||
338 | struct list_head list; | ||
339 | unsigned long flags; | ||
340 | |||
341 | INIT_LIST_HEAD(&list); | ||
342 | spin_lock_irqsave(&card->lock, flags); | ||
343 | list_splice_init(&card->transaction_list, &list); | ||
344 | card->tlabel_mask = 0; | ||
345 | spin_unlock_irqrestore(&card->lock, flags); | ||
346 | |||
347 | list_for_each_entry_safe(t, next, &list, link) { | ||
348 | card->driver->cancel_packet(card, &t->packet); | ||
349 | |||
350 | /* | ||
351 | * At this point cancel_packet will never call the | ||
352 | * transaction callback, since we just took all the | ||
353 | * transactions out of the list. So do it here. | ||
354 | */ | ||
355 | t->callback(card, RCODE_CANCELLED, NULL, 0, t->callback_data); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | static struct fw_address_handler * | ||
360 | lookup_overlapping_address_handler(struct list_head *list, | ||
361 | unsigned long long offset, size_t length) | ||
362 | { | ||
363 | struct fw_address_handler *handler; | ||
364 | |||
365 | list_for_each_entry(handler, list, link) { | ||
366 | if (handler->offset < offset + length && | ||
367 | offset < handler->offset + handler->length) | ||
368 | return handler; | ||
369 | } | ||
370 | |||
371 | return NULL; | ||
372 | } | ||
373 | |||
374 | static struct fw_address_handler * | ||
375 | lookup_enclosing_address_handler(struct list_head *list, | ||
376 | unsigned long long offset, size_t length) | ||
377 | { | ||
378 | struct fw_address_handler *handler; | ||
379 | |||
380 | list_for_each_entry(handler, list, link) { | ||
381 | if (handler->offset <= offset && | ||
382 | offset + length <= handler->offset + handler->length) | ||
383 | return handler; | ||
384 | } | ||
385 | |||
386 | return NULL; | ||
387 | } | ||
388 | |||
389 | static DEFINE_SPINLOCK(address_handler_lock); | ||
390 | static LIST_HEAD(address_handler_list); | ||
391 | |||
392 | const struct fw_address_region fw_low_memory_region = | ||
393 | { .start = 0x000000000000ULL, .end = 0x000100000000ULL, }; | ||
394 | const struct fw_address_region fw_high_memory_region = | ||
395 | { .start = 0x000100000000ULL, .end = 0xffffe0000000ULL, }; | ||
396 | const struct fw_address_region fw_private_region = | ||
397 | { .start = 0xffffe0000000ULL, .end = 0xfffff0000000ULL, }; | ||
398 | const struct fw_address_region fw_csr_region = | ||
399 | { .start = 0xfffff0000000ULL, .end = 0xfffff0000800ULL, }; | ||
400 | const struct fw_address_region fw_unit_space_region = | ||
401 | { .start = 0xfffff0000900ULL, .end = 0x1000000000000ULL, }; | ||
402 | EXPORT_SYMBOL(fw_low_memory_region); | ||
403 | EXPORT_SYMBOL(fw_high_memory_region); | ||
404 | EXPORT_SYMBOL(fw_private_region); | ||
405 | EXPORT_SYMBOL(fw_csr_region); | ||
406 | EXPORT_SYMBOL(fw_unit_space_region); | ||
407 | |||
408 | /** | ||
409 | * Allocate a range of addresses in the node space of the OHCI | ||
410 | * controller. When a request is received that falls within the | ||
411 | * specified address range, the specified callback is invoked. The | ||
412 | * parameters passed to the callback give the details of the | ||
413 | * particular request | ||
414 | */ | ||
415 | int | ||
416 | fw_core_add_address_handler(struct fw_address_handler *handler, | ||
417 | const struct fw_address_region *region) | ||
418 | { | ||
419 | struct fw_address_handler *other; | ||
420 | unsigned long flags; | ||
421 | int ret = -EBUSY; | ||
422 | |||
423 | spin_lock_irqsave(&address_handler_lock, flags); | ||
424 | |||
425 | handler->offset = region->start; | ||
426 | while (handler->offset + handler->length <= region->end) { | ||
427 | other = | ||
428 | lookup_overlapping_address_handler(&address_handler_list, | ||
429 | handler->offset, | ||
430 | handler->length); | ||
431 | if (other != NULL) { | ||
432 | handler->offset += other->length; | ||
433 | } else { | ||
434 | list_add_tail(&handler->link, &address_handler_list); | ||
435 | ret = 0; | ||
436 | break; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | spin_unlock_irqrestore(&address_handler_lock, flags); | ||
441 | |||
442 | return ret; | ||
443 | } | ||
444 | EXPORT_SYMBOL(fw_core_add_address_handler); | ||
445 | |||
446 | /** | ||
447 | * Deallocate a range of addresses allocated with fw_allocate. This | ||
448 | * will call the associated callback one last time with a the special | ||
449 | * tcode TCODE_DEALLOCATE, to let the client destroy the registered | ||
450 | * callback data. For convenience, the callback parameters offset and | ||
451 | * length are set to the start and the length respectively for the | ||
452 | * deallocated region, payload is set to NULL. | ||
453 | */ | ||
454 | void fw_core_remove_address_handler(struct fw_address_handler *handler) | ||
455 | { | ||
456 | unsigned long flags; | ||
457 | |||
458 | spin_lock_irqsave(&address_handler_lock, flags); | ||
459 | list_del(&handler->link); | ||
460 | spin_unlock_irqrestore(&address_handler_lock, flags); | ||
461 | } | ||
462 | EXPORT_SYMBOL(fw_core_remove_address_handler); | ||
463 | |||
464 | struct fw_request { | ||
465 | struct fw_packet response; | ||
466 | u32 request_header[4]; | ||
467 | int ack; | ||
468 | u32 length; | ||
469 | u32 data[0]; | ||
470 | }; | ||
471 | |||
472 | static void | ||
473 | free_response_callback(struct fw_packet *packet, | ||
474 | struct fw_card *card, int status) | ||
475 | { | ||
476 | struct fw_request *request; | ||
477 | |||
478 | request = container_of(packet, struct fw_request, response); | ||
479 | kfree(request); | ||
480 | } | ||
481 | |||
482 | void | ||
483 | fw_fill_response(struct fw_packet *response, u32 *request_header, | ||
484 | int rcode, void *payload, size_t length) | ||
485 | { | ||
486 | int tcode, tlabel, extended_tcode, source, destination; | ||
487 | |||
488 | tcode = HEADER_GET_TCODE(request_header[0]); | ||
489 | tlabel = HEADER_GET_TLABEL(request_header[0]); | ||
490 | source = HEADER_GET_DESTINATION(request_header[0]); | ||
491 | destination = HEADER_GET_SOURCE(request_header[1]); | ||
492 | extended_tcode = HEADER_GET_EXTENDED_TCODE(request_header[3]); | ||
493 | |||
494 | response->header[0] = | ||
495 | HEADER_RETRY(RETRY_1) | | ||
496 | HEADER_TLABEL(tlabel) | | ||
497 | HEADER_DESTINATION(destination); | ||
498 | response->header[1] = | ||
499 | HEADER_SOURCE(source) | | ||
500 | HEADER_RCODE(rcode); | ||
501 | response->header[2] = 0; | ||
502 | |||
503 | switch (tcode) { | ||
504 | case TCODE_WRITE_QUADLET_REQUEST: | ||
505 | case TCODE_WRITE_BLOCK_REQUEST: | ||
506 | response->header[0] |= HEADER_TCODE(TCODE_WRITE_RESPONSE); | ||
507 | response->header_length = 12; | ||
508 | response->payload_length = 0; | ||
509 | break; | ||
510 | |||
511 | case TCODE_READ_QUADLET_REQUEST: | ||
512 | response->header[0] |= | ||
513 | HEADER_TCODE(TCODE_READ_QUADLET_RESPONSE); | ||
514 | if (payload != NULL) | ||
515 | response->header[3] = *(u32 *)payload; | ||
516 | else | ||
517 | response->header[3] = 0; | ||
518 | response->header_length = 16; | ||
519 | response->payload_length = 0; | ||
520 | break; | ||
521 | |||
522 | case TCODE_READ_BLOCK_REQUEST: | ||
523 | case TCODE_LOCK_REQUEST: | ||
524 | response->header[0] |= HEADER_TCODE(tcode + 2); | ||
525 | response->header[3] = | ||
526 | HEADER_DATA_LENGTH(length) | | ||
527 | HEADER_EXTENDED_TCODE(extended_tcode); | ||
528 | response->header_length = 16; | ||
529 | response->payload = payload; | ||
530 | response->payload_length = length; | ||
531 | break; | ||
532 | |||
533 | default: | ||
534 | BUG(); | ||
535 | return; | ||
536 | } | ||
537 | } | ||
538 | EXPORT_SYMBOL(fw_fill_response); | ||
539 | |||
540 | static struct fw_request * | ||
541 | allocate_request(struct fw_packet *p) | ||
542 | { | ||
543 | struct fw_request *request; | ||
544 | u32 *data, length; | ||
545 | int request_tcode, t; | ||
546 | |||
547 | request_tcode = HEADER_GET_TCODE(p->header[0]); | ||
548 | switch (request_tcode) { | ||
549 | case TCODE_WRITE_QUADLET_REQUEST: | ||
550 | data = &p->header[3]; | ||
551 | length = 4; | ||
552 | break; | ||
553 | |||
554 | case TCODE_WRITE_BLOCK_REQUEST: | ||
555 | case TCODE_LOCK_REQUEST: | ||
556 | data = p->payload; | ||
557 | length = HEADER_GET_DATA_LENGTH(p->header[3]); | ||
558 | break; | ||
559 | |||
560 | case TCODE_READ_QUADLET_REQUEST: | ||
561 | data = NULL; | ||
562 | length = 4; | ||
563 | break; | ||
564 | |||
565 | case TCODE_READ_BLOCK_REQUEST: | ||
566 | data = NULL; | ||
567 | length = HEADER_GET_DATA_LENGTH(p->header[3]); | ||
568 | break; | ||
569 | |||
570 | default: | ||
571 | BUG(); | ||
572 | return NULL; | ||
573 | } | ||
574 | |||
575 | request = kmalloc(sizeof(*request) + length, GFP_ATOMIC); | ||
576 | if (request == NULL) | ||
577 | return NULL; | ||
578 | |||
579 | t = (p->timestamp & 0x1fff) + 4000; | ||
580 | if (t >= 8000) | ||
581 | t = (p->timestamp & ~0x1fff) + 0x2000 + t - 8000; | ||
582 | else | ||
583 | t = (p->timestamp & ~0x1fff) + t; | ||
584 | |||
585 | request->response.speed = p->speed; | ||
586 | request->response.timestamp = t; | ||
587 | request->response.generation = p->generation; | ||
588 | request->response.ack = 0; | ||
589 | request->response.callback = free_response_callback; | ||
590 | request->ack = p->ack; | ||
591 | request->length = length; | ||
592 | if (data) | ||
593 | memcpy(request->data, data, length); | ||
594 | |||
595 | memcpy(request->request_header, p->header, sizeof(p->header)); | ||
596 | |||
597 | return request; | ||
598 | } | ||
599 | |||
600 | void | ||
601 | fw_send_response(struct fw_card *card, struct fw_request *request, int rcode) | ||
602 | { | ||
603 | /* | ||
604 | * Broadcast packets are reported as ACK_COMPLETE, so this | ||
605 | * check is sufficient to ensure we don't send response to | ||
606 | * broadcast packets or posted writes. | ||
607 | */ | ||
608 | if (request->ack != ACK_PENDING) | ||
609 | return; | ||
610 | |||
611 | if (rcode == RCODE_COMPLETE) | ||
612 | fw_fill_response(&request->response, request->request_header, | ||
613 | rcode, request->data, request->length); | ||
614 | else | ||
615 | fw_fill_response(&request->response, request->request_header, | ||
616 | rcode, NULL, 0); | ||
617 | |||
618 | card->driver->send_response(card, &request->response); | ||
619 | } | ||
620 | EXPORT_SYMBOL(fw_send_response); | ||
621 | |||
622 | void | ||
623 | fw_core_handle_request(struct fw_card *card, struct fw_packet *p) | ||
624 | { | ||
625 | struct fw_address_handler *handler; | ||
626 | struct fw_request *request; | ||
627 | unsigned long long offset; | ||
628 | unsigned long flags; | ||
629 | int tcode, destination, source; | ||
630 | |||
631 | if (p->payload_length > 2048) { | ||
632 | /* FIXME: send error response. */ | ||
633 | return; | ||
634 | } | ||
635 | |||
636 | if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE) | ||
637 | return; | ||
638 | |||
639 | request = allocate_request(p); | ||
640 | if (request == NULL) { | ||
641 | /* FIXME: send statically allocated busy packet. */ | ||
642 | return; | ||
643 | } | ||
644 | |||
645 | offset = | ||
646 | ((unsigned long long) | ||
647 | HEADER_GET_OFFSET_HIGH(p->header[1]) << 32) | p->header[2]; | ||
648 | tcode = HEADER_GET_TCODE(p->header[0]); | ||
649 | destination = HEADER_GET_DESTINATION(p->header[0]); | ||
650 | source = HEADER_GET_SOURCE(p->header[0]); | ||
651 | |||
652 | spin_lock_irqsave(&address_handler_lock, flags); | ||
653 | handler = lookup_enclosing_address_handler(&address_handler_list, | ||
654 | offset, request->length); | ||
655 | spin_unlock_irqrestore(&address_handler_lock, flags); | ||
656 | |||
657 | /* | ||
658 | * FIXME: lookup the fw_node corresponding to the sender of | ||
659 | * this request and pass that to the address handler instead | ||
660 | * of the node ID. We may also want to move the address | ||
661 | * allocations to fw_node so we only do this callback if the | ||
662 | * upper layers registered it for this node. | ||
663 | */ | ||
664 | |||
665 | if (handler == NULL) | ||
666 | fw_send_response(card, request, RCODE_ADDRESS_ERROR); | ||
667 | else | ||
668 | handler->address_callback(card, request, | ||
669 | tcode, destination, source, | ||
670 | p->generation, p->speed, offset, | ||
671 | request->data, request->length, | ||
672 | handler->callback_data); | ||
673 | } | ||
674 | EXPORT_SYMBOL(fw_core_handle_request); | ||
675 | |||
676 | void | ||
677 | fw_core_handle_response(struct fw_card *card, struct fw_packet *p) | ||
678 | { | ||
679 | struct fw_transaction *t; | ||
680 | unsigned long flags; | ||
681 | u32 *data; | ||
682 | size_t data_length; | ||
683 | int tcode, tlabel, destination, source, rcode; | ||
684 | |||
685 | tcode = HEADER_GET_TCODE(p->header[0]); | ||
686 | tlabel = HEADER_GET_TLABEL(p->header[0]); | ||
687 | destination = HEADER_GET_DESTINATION(p->header[0]); | ||
688 | source = HEADER_GET_SOURCE(p->header[1]); | ||
689 | rcode = HEADER_GET_RCODE(p->header[1]); | ||
690 | |||
691 | spin_lock_irqsave(&card->lock, flags); | ||
692 | list_for_each_entry(t, &card->transaction_list, link) { | ||
693 | if (t->node_id == source && t->tlabel == tlabel) { | ||
694 | list_del(&t->link); | ||
695 | card->tlabel_mask &= ~(1 << t->tlabel); | ||
696 | break; | ||
697 | } | ||
698 | } | ||
699 | spin_unlock_irqrestore(&card->lock, flags); | ||
700 | |||
701 | if (&t->link == &card->transaction_list) { | ||
702 | fw_notify("Unsolicited response (source %x, tlabel %x)\n", | ||
703 | source, tlabel); | ||
704 | return; | ||
705 | } | ||
706 | |||
707 | /* | ||
708 | * FIXME: sanity check packet, is length correct, does tcodes | ||
709 | * and addresses match. | ||
710 | */ | ||
711 | |||
712 | switch (tcode) { | ||
713 | case TCODE_READ_QUADLET_RESPONSE: | ||
714 | data = (u32 *) &p->header[3]; | ||
715 | data_length = 4; | ||
716 | break; | ||
717 | |||
718 | case TCODE_WRITE_RESPONSE: | ||
719 | data = NULL; | ||
720 | data_length = 0; | ||
721 | break; | ||
722 | |||
723 | case TCODE_READ_BLOCK_RESPONSE: | ||
724 | case TCODE_LOCK_RESPONSE: | ||
725 | data = p->payload; | ||
726 | data_length = HEADER_GET_DATA_LENGTH(p->header[3]); | ||
727 | break; | ||
728 | |||
729 | default: | ||
730 | /* Should never happen, this is just to shut up gcc. */ | ||
731 | data = NULL; | ||
732 | data_length = 0; | ||
733 | break; | ||
734 | } | ||
735 | |||
736 | t->callback(card, rcode, data, data_length, t->callback_data); | ||
737 | } | ||
738 | EXPORT_SYMBOL(fw_core_handle_response); | ||
739 | |||
740 | const struct fw_address_region topology_map_region = | ||
741 | { .start = 0xfffff0001000ull, .end = 0xfffff0001400ull, }; | ||
742 | |||
743 | static void | ||
744 | handle_topology_map(struct fw_card *card, struct fw_request *request, | ||
745 | int tcode, int destination, int source, | ||
746 | int generation, int speed, | ||
747 | unsigned long long offset, | ||
748 | void *payload, size_t length, void *callback_data) | ||
749 | { | ||
750 | int i, start, end; | ||
751 | u32 *map; | ||
752 | |||
753 | if (!TCODE_IS_READ_REQUEST(tcode)) { | ||
754 | fw_send_response(card, request, RCODE_TYPE_ERROR); | ||
755 | return; | ||
756 | } | ||
757 | |||
758 | if ((offset & 3) > 0 || (length & 3) > 0) { | ||
759 | fw_send_response(card, request, RCODE_ADDRESS_ERROR); | ||
760 | return; | ||
761 | } | ||
762 | |||
763 | start = (offset - topology_map_region.start) / 4; | ||
764 | end = start + length / 4; | ||
765 | map = payload; | ||
766 | |||
767 | for (i = 0; i < length / 4; i++) | ||
768 | map[i] = cpu_to_be32(card->topology_map[start + i]); | ||
769 | |||
770 | fw_send_response(card, request, RCODE_COMPLETE); | ||
771 | } | ||
772 | |||
773 | static struct fw_address_handler topology_map = { | ||
774 | .length = 0x200, | ||
775 | .address_callback = handle_topology_map, | ||
776 | }; | ||
777 | |||
778 | const struct fw_address_region registers_region = | ||
779 | { .start = 0xfffff0000000ull, .end = 0xfffff0000400ull, }; | ||
780 | |||
781 | static void | ||
782 | handle_registers(struct fw_card *card, struct fw_request *request, | ||
783 | int tcode, int destination, int source, | ||
784 | int generation, int speed, | ||
785 | unsigned long long offset, | ||
786 | void *payload, size_t length, void *callback_data) | ||
787 | { | ||
788 | int reg = offset - CSR_REGISTER_BASE; | ||
789 | unsigned long long bus_time; | ||
790 | __be32 *data = payload; | ||
791 | |||
792 | switch (reg) { | ||
793 | case CSR_CYCLE_TIME: | ||
794 | case CSR_BUS_TIME: | ||
795 | if (!TCODE_IS_READ_REQUEST(tcode) || length != 4) { | ||
796 | fw_send_response(card, request, RCODE_TYPE_ERROR); | ||
797 | break; | ||
798 | } | ||
799 | |||
800 | bus_time = card->driver->get_bus_time(card); | ||
801 | if (reg == CSR_CYCLE_TIME) | ||
802 | *data = cpu_to_be32(bus_time); | ||
803 | else | ||
804 | *data = cpu_to_be32(bus_time >> 25); | ||
805 | fw_send_response(card, request, RCODE_COMPLETE); | ||
806 | break; | ||
807 | |||
808 | case CSR_BUS_MANAGER_ID: | ||
809 | case CSR_BANDWIDTH_AVAILABLE: | ||
810 | case CSR_CHANNELS_AVAILABLE_HI: | ||
811 | case CSR_CHANNELS_AVAILABLE_LO: | ||
812 | /* | ||
813 | * FIXME: these are handled by the OHCI hardware and | ||
814 | * the stack never sees these request. If we add | ||
815 | * support for a new type of controller that doesn't | ||
816 | * handle this in hardware we need to deal with these | ||
817 | * transactions. | ||
818 | */ | ||
819 | BUG(); | ||
820 | break; | ||
821 | |||
822 | case CSR_BUSY_TIMEOUT: | ||
823 | /* FIXME: Implement this. */ | ||
824 | default: | ||
825 | fw_send_response(card, request, RCODE_ADDRESS_ERROR); | ||
826 | break; | ||
827 | } | ||
828 | } | ||
829 | |||
830 | static struct fw_address_handler registers = { | ||
831 | .length = 0x400, | ||
832 | .address_callback = handle_registers, | ||
833 | }; | ||
834 | |||
835 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); | ||
836 | MODULE_DESCRIPTION("Core IEEE1394 transaction logic"); | ||
837 | MODULE_LICENSE("GPL"); | ||
838 | |||
839 | static const u32 vendor_textual_descriptor[] = { | ||
840 | /* textual descriptor leaf () */ | ||
841 | 0x00060000, | ||
842 | 0x00000000, | ||
843 | 0x00000000, | ||
844 | 0x4c696e75, /* L i n u */ | ||
845 | 0x78204669, /* x F i */ | ||
846 | 0x72657769, /* r e w i */ | ||
847 | 0x72650000, /* r e */ | ||
848 | }; | ||
849 | |||
850 | static const u32 model_textual_descriptor[] = { | ||
851 | /* model descriptor leaf () */ | ||
852 | 0x00030000, | ||
853 | 0x00000000, | ||
854 | 0x00000000, | ||
855 | 0x4a756a75, /* J u j u */ | ||
856 | }; | ||
857 | |||
858 | static struct fw_descriptor vendor_id_descriptor = { | ||
859 | .length = ARRAY_SIZE(vendor_textual_descriptor), | ||
860 | .immediate = 0x03d00d1e, | ||
861 | .key = 0x81000000, | ||
862 | .data = vendor_textual_descriptor, | ||
863 | }; | ||
864 | |||
865 | static struct fw_descriptor model_id_descriptor = { | ||
866 | .length = ARRAY_SIZE(model_textual_descriptor), | ||
867 | .immediate = 0x17000001, | ||
868 | .key = 0x81000000, | ||
869 | .data = model_textual_descriptor, | ||
870 | }; | ||
871 | |||
872 | static int __init fw_core_init(void) | ||
873 | { | ||
874 | int retval; | ||
875 | |||
876 | retval = bus_register(&fw_bus_type); | ||
877 | if (retval < 0) | ||
878 | return retval; | ||
879 | |||
880 | fw_cdev_major = register_chrdev(0, "firewire", &fw_device_ops); | ||
881 | if (fw_cdev_major < 0) { | ||
882 | bus_unregister(&fw_bus_type); | ||
883 | return fw_cdev_major; | ||
884 | } | ||
885 | |||
886 | retval = fw_core_add_address_handler(&topology_map, | ||
887 | &topology_map_region); | ||
888 | BUG_ON(retval < 0); | ||
889 | |||
890 | retval = fw_core_add_address_handler(®isters, | ||
891 | ®isters_region); | ||
892 | BUG_ON(retval < 0); | ||
893 | |||
894 | /* Add the vendor textual descriptor. */ | ||
895 | retval = fw_core_add_descriptor(&vendor_id_descriptor); | ||
896 | BUG_ON(retval < 0); | ||
897 | retval = fw_core_add_descriptor(&model_id_descriptor); | ||
898 | BUG_ON(retval < 0); | ||
899 | |||
900 | return 0; | ||
901 | } | ||
902 | |||
903 | static void __exit fw_core_cleanup(void) | ||
904 | { | ||
905 | unregister_chrdev(fw_cdev_major, "firewire"); | ||
906 | bus_unregister(&fw_bus_type); | ||
907 | } | ||
908 | |||
909 | module_init(fw_core_init); | ||
910 | module_exit(fw_core_cleanup); | ||
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h new file mode 100644 index 000000000000..acdc3be38c61 --- /dev/null +++ b/drivers/firewire/fw-transaction.h | |||
@@ -0,0 +1,458 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2003-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software Foundation, | ||
16 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | */ | ||
18 | |||
19 | #ifndef __fw_transaction_h | ||
20 | #define __fw_transaction_h | ||
21 | |||
22 | #include <linux/device.h> | ||
23 | #include <linux/timer.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/list.h> | ||
26 | #include <linux/fs.h> | ||
27 | #include <linux/dma-mapping.h> | ||
28 | #include <linux/firewire-constants.h> | ||
29 | |||
30 | #define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) | ||
31 | #define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0) | ||
32 | #define TCODE_IS_REQUEST(tcode) (((tcode) & 2) == 0) | ||
33 | #define TCODE_IS_RESPONSE(tcode) (((tcode) & 2) != 0) | ||
34 | #define TCODE_HAS_REQUEST_DATA(tcode) (((tcode) & 12) != 4) | ||
35 | #define TCODE_HAS_RESPONSE_DATA(tcode) (((tcode) & 12) != 0) | ||
36 | |||
37 | #define LOCAL_BUS 0xffc0 | ||
38 | |||
39 | #define SELFID_PORT_CHILD 0x3 | ||
40 | #define SELFID_PORT_PARENT 0x2 | ||
41 | #define SELFID_PORT_NCONN 0x1 | ||
42 | #define SELFID_PORT_NONE 0x0 | ||
43 | |||
44 | #define PHY_PACKET_CONFIG 0x0 | ||
45 | #define PHY_PACKET_LINK_ON 0x1 | ||
46 | #define PHY_PACKET_SELF_ID 0x2 | ||
47 | |||
48 | /* Bit fields _within_ the PHY registers. */ | ||
49 | #define PHY_LINK_ACTIVE 0x80 | ||
50 | #define PHY_CONTENDER 0x40 | ||
51 | #define PHY_BUS_RESET 0x40 | ||
52 | #define PHY_BUS_SHORT_RESET 0x40 | ||
53 | |||
54 | #define CSR_REGISTER_BASE 0xfffff0000000ULL | ||
55 | |||
56 | /* register offsets relative to CSR_REGISTER_BASE */ | ||
57 | #define CSR_STATE_CLEAR 0x0 | ||
58 | #define CSR_STATE_SET 0x4 | ||
59 | #define CSR_NODE_IDS 0x8 | ||
60 | #define CSR_RESET_START 0xc | ||
61 | #define CSR_SPLIT_TIMEOUT_HI 0x18 | ||
62 | #define CSR_SPLIT_TIMEOUT_LO 0x1c | ||
63 | #define CSR_CYCLE_TIME 0x200 | ||
64 | #define CSR_BUS_TIME 0x204 | ||
65 | #define CSR_BUSY_TIMEOUT 0x210 | ||
66 | #define CSR_BUS_MANAGER_ID 0x21c | ||
67 | #define CSR_BANDWIDTH_AVAILABLE 0x220 | ||
68 | #define CSR_CHANNELS_AVAILABLE 0x224 | ||
69 | #define CSR_CHANNELS_AVAILABLE_HI 0x224 | ||
70 | #define CSR_CHANNELS_AVAILABLE_LO 0x228 | ||
71 | #define CSR_BROADCAST_CHANNEL 0x234 | ||
72 | #define CSR_CONFIG_ROM 0x400 | ||
73 | #define CSR_CONFIG_ROM_END 0x800 | ||
74 | #define CSR_FCP_COMMAND 0xB00 | ||
75 | #define CSR_FCP_RESPONSE 0xD00 | ||
76 | #define CSR_FCP_END 0xF00 | ||
77 | #define CSR_TOPOLOGY_MAP 0x1000 | ||
78 | #define CSR_TOPOLOGY_MAP_END 0x1400 | ||
79 | #define CSR_SPEED_MAP 0x2000 | ||
80 | #define CSR_SPEED_MAP_END 0x3000 | ||
81 | |||
82 | #define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args) | ||
83 | #define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) | ||
84 | #define fw_debug(s, args...) printk(KERN_DEBUG KBUILD_MODNAME ": " s, ## args) | ||
85 | |||
86 | static inline void | ||
87 | fw_memcpy_from_be32(void *_dst, void *_src, size_t size) | ||
88 | { | ||
89 | u32 *dst = _dst; | ||
90 | u32 *src = _src; | ||
91 | int i; | ||
92 | |||
93 | for (i = 0; i < size / 4; i++) | ||
94 | dst[i] = cpu_to_be32(src[i]); | ||
95 | } | ||
96 | |||
97 | static inline void | ||
98 | fw_memcpy_to_be32(void *_dst, void *_src, size_t size) | ||
99 | { | ||
100 | fw_memcpy_from_be32(_dst, _src, size); | ||
101 | } | ||
102 | |||
103 | struct fw_card; | ||
104 | struct fw_packet; | ||
105 | struct fw_node; | ||
106 | struct fw_request; | ||
107 | |||
108 | struct fw_descriptor { | ||
109 | struct list_head link; | ||
110 | size_t length; | ||
111 | u32 immediate; | ||
112 | u32 key; | ||
113 | const u32 *data; | ||
114 | }; | ||
115 | |||
116 | int fw_core_add_descriptor(struct fw_descriptor *desc); | ||
117 | void fw_core_remove_descriptor(struct fw_descriptor *desc); | ||
118 | |||
119 | typedef void (*fw_packet_callback_t)(struct fw_packet *packet, | ||
120 | struct fw_card *card, int status); | ||
121 | |||
122 | typedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode, | ||
123 | void *data, | ||
124 | size_t length, | ||
125 | void *callback_data); | ||
126 | |||
127 | typedef void (*fw_address_callback_t)(struct fw_card *card, | ||
128 | struct fw_request *request, | ||
129 | int tcode, int destination, int source, | ||
130 | int generation, int speed, | ||
131 | unsigned long long offset, | ||
132 | void *data, size_t length, | ||
133 | void *callback_data); | ||
134 | |||
135 | typedef void (*fw_bus_reset_callback_t)(struct fw_card *handle, | ||
136 | int node_id, int generation, | ||
137 | u32 *self_ids, | ||
138 | int self_id_count, | ||
139 | void *callback_data); | ||
140 | |||
141 | struct fw_packet { | ||
142 | int speed; | ||
143 | int generation; | ||
144 | u32 header[4]; | ||
145 | size_t header_length; | ||
146 | void *payload; | ||
147 | size_t payload_length; | ||
148 | u32 timestamp; | ||
149 | |||
150 | /* | ||
151 | * This callback is called when the packet transmission has | ||
152 | * completed; for successful transmission, the status code is | ||
153 | * the ack received from the destination, otherwise it's a | ||
154 | * negative errno: ENOMEM, ESTALE, ETIMEDOUT, ENODEV, EIO. | ||
155 | * The callback can be called from tasklet context and thus | ||
156 | * must never block. | ||
157 | */ | ||
158 | fw_packet_callback_t callback; | ||
159 | int ack; | ||
160 | struct list_head link; | ||
161 | void *driver_data; | ||
162 | }; | ||
163 | |||
164 | struct fw_transaction { | ||
165 | int node_id; /* The generation is implied; it is always the current. */ | ||
166 | int tlabel; | ||
167 | int timestamp; | ||
168 | struct list_head link; | ||
169 | |||
170 | struct fw_packet packet; | ||
171 | |||
172 | /* | ||
173 | * The data passed to the callback is valid only during the | ||
174 | * callback. | ||
175 | */ | ||
176 | fw_transaction_callback_t callback; | ||
177 | void *callback_data; | ||
178 | }; | ||
179 | |||
180 | static inline struct fw_packet * | ||
181 | fw_packet(struct list_head *l) | ||
182 | { | ||
183 | return list_entry(l, struct fw_packet, link); | ||
184 | } | ||
185 | |||
186 | struct fw_address_handler { | ||
187 | u64 offset; | ||
188 | size_t length; | ||
189 | fw_address_callback_t address_callback; | ||
190 | void *callback_data; | ||
191 | struct list_head link; | ||
192 | }; | ||
193 | |||
194 | |||
195 | struct fw_address_region { | ||
196 | u64 start; | ||
197 | u64 end; | ||
198 | }; | ||
199 | |||
200 | extern const struct fw_address_region fw_low_memory_region; | ||
201 | extern const struct fw_address_region fw_high_memory_region; | ||
202 | extern const struct fw_address_region fw_private_region; | ||
203 | extern const struct fw_address_region fw_csr_region; | ||
204 | extern const struct fw_address_region fw_unit_space_region; | ||
205 | |||
206 | int fw_core_add_address_handler(struct fw_address_handler *handler, | ||
207 | const struct fw_address_region *region); | ||
208 | void fw_core_remove_address_handler(struct fw_address_handler *handler); | ||
209 | void fw_fill_response(struct fw_packet *response, u32 *request_header, | ||
210 | int rcode, void *payload, size_t length); | ||
211 | void fw_send_response(struct fw_card *card, | ||
212 | struct fw_request *request, int rcode); | ||
213 | |||
214 | extern struct bus_type fw_bus_type; | ||
215 | |||
216 | struct fw_card { | ||
217 | const struct fw_card_driver *driver; | ||
218 | struct device *device; | ||
219 | struct kref kref; | ||
220 | |||
221 | int node_id; | ||
222 | int generation; | ||
223 | /* This is the generation used for timestamping incoming requests. */ | ||
224 | int request_generation; | ||
225 | int current_tlabel, tlabel_mask; | ||
226 | struct list_head transaction_list; | ||
227 | struct timer_list flush_timer; | ||
228 | unsigned long reset_jiffies; | ||
229 | |||
230 | unsigned long long guid; | ||
231 | int max_receive; | ||
232 | int link_speed; | ||
233 | int config_rom_generation; | ||
234 | |||
235 | /* | ||
236 | * We need to store up to 4 self ID for a maximum of 63 | ||
237 | * devices plus 3 words for the topology map header. | ||
238 | */ | ||
239 | int self_id_count; | ||
240 | u32 topology_map[252 + 3]; | ||
241 | |||
242 | spinlock_t lock; /* Take this lock when handling the lists in | ||
243 | * this struct. */ | ||
244 | struct fw_node *local_node; | ||
245 | struct fw_node *root_node; | ||
246 | struct fw_node *irm_node; | ||
247 | int color; | ||
248 | int gap_count; | ||
249 | int topology_type; | ||
250 | |||
251 | int index; | ||
252 | |||
253 | struct list_head link; | ||
254 | |||
255 | /* Work struct for BM duties. */ | ||
256 | struct delayed_work work; | ||
257 | int bm_retries; | ||
258 | int bm_generation; | ||
259 | }; | ||
260 | |||
261 | struct fw_card *fw_card_get(struct fw_card *card); | ||
262 | void fw_card_put(struct fw_card *card); | ||
263 | |||
264 | /* | ||
265 | * The iso packet format allows for an immediate header/payload part | ||
266 | * stored in 'header' immediately after the packet info plus an | ||
267 | * indirect payload part that is pointer to by the 'payload' field. | ||
268 | * Applications can use one or the other or both to implement simple | ||
269 | * low-bandwidth streaming (e.g. audio) or more advanced | ||
270 | * scatter-gather streaming (e.g. assembling video frame automatically). | ||
271 | */ | ||
272 | |||
273 | struct fw_iso_packet { | ||
274 | u16 payload_length; /* Length of indirect payload. */ | ||
275 | u32 interrupt : 1; /* Generate interrupt on this packet */ | ||
276 | u32 skip : 1; /* Set to not send packet at all. */ | ||
277 | u32 tag : 2; | ||
278 | u32 sy : 4; | ||
279 | u32 header_length : 8; /* Length of immediate header. */ | ||
280 | u32 header[0]; | ||
281 | }; | ||
282 | |||
283 | #define FW_ISO_CONTEXT_TRANSMIT 0 | ||
284 | #define FW_ISO_CONTEXT_RECEIVE 1 | ||
285 | |||
286 | #define FW_ISO_CONTEXT_MATCH_TAG0 1 | ||
287 | #define FW_ISO_CONTEXT_MATCH_TAG1 2 | ||
288 | #define FW_ISO_CONTEXT_MATCH_TAG2 4 | ||
289 | #define FW_ISO_CONTEXT_MATCH_TAG3 8 | ||
290 | #define FW_ISO_CONTEXT_MATCH_ALL_TAGS 15 | ||
291 | |||
292 | struct fw_iso_context; | ||
293 | |||
294 | typedef void (*fw_iso_callback_t)(struct fw_iso_context *context, | ||
295 | u32 cycle, | ||
296 | size_t header_length, | ||
297 | void *header, | ||
298 | void *data); | ||
299 | |||
300 | /* | ||
301 | * An iso buffer is just a set of pages mapped for DMA in the | ||
302 | * specified direction. Since the pages are to be used for DMA, they | ||
303 | * are not mapped into the kernel virtual address space. We store the | ||
304 | * DMA address in the page private. The helper function | ||
305 | * fw_iso_buffer_map() will map the pages into a given vma. | ||
306 | */ | ||
307 | |||
308 | struct fw_iso_buffer { | ||
309 | enum dma_data_direction direction; | ||
310 | struct page **pages; | ||
311 | int page_count; | ||
312 | }; | ||
313 | |||
314 | struct fw_iso_context { | ||
315 | struct fw_card *card; | ||
316 | int type; | ||
317 | int channel; | ||
318 | int speed; | ||
319 | size_t header_size; | ||
320 | fw_iso_callback_t callback; | ||
321 | void *callback_data; | ||
322 | }; | ||
323 | |||
324 | int | ||
325 | fw_iso_buffer_init(struct fw_iso_buffer *buffer, | ||
326 | struct fw_card *card, | ||
327 | int page_count, | ||
328 | enum dma_data_direction direction); | ||
329 | int | ||
330 | fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma); | ||
331 | void | ||
332 | fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card); | ||
333 | |||
334 | struct fw_iso_context * | ||
335 | fw_iso_context_create(struct fw_card *card, int type, | ||
336 | int channel, int speed, size_t header_size, | ||
337 | fw_iso_callback_t callback, void *callback_data); | ||
338 | |||
339 | void | ||
340 | fw_iso_context_destroy(struct fw_iso_context *ctx); | ||
341 | |||
342 | int | ||
343 | fw_iso_context_queue(struct fw_iso_context *ctx, | ||
344 | struct fw_iso_packet *packet, | ||
345 | struct fw_iso_buffer *buffer, | ||
346 | unsigned long payload); | ||
347 | |||
348 | int | ||
349 | fw_iso_context_start(struct fw_iso_context *ctx, | ||
350 | int cycle, int sync, int tags); | ||
351 | |||
352 | int | ||
353 | fw_iso_context_stop(struct fw_iso_context *ctx); | ||
354 | |||
355 | struct fw_card_driver { | ||
356 | const char *name; | ||
357 | |||
358 | /* | ||
359 | * Enable the given card with the given initial config rom. | ||
360 | * This function is expected to activate the card, and either | ||
361 | * enable the PHY or set the link_on bit and initiate a bus | ||
362 | * reset. | ||
363 | */ | ||
364 | int (*enable)(struct fw_card *card, u32 *config_rom, size_t length); | ||
365 | |||
366 | int (*update_phy_reg)(struct fw_card *card, int address, | ||
367 | int clear_bits, int set_bits); | ||
368 | |||
369 | /* | ||
370 | * Update the config rom for an enabled card. This function | ||
371 | * should change the config rom that is presented on the bus | ||
372 | * an initiate a bus reset. | ||
373 | */ | ||
374 | int (*set_config_rom)(struct fw_card *card, | ||
375 | u32 *config_rom, size_t length); | ||
376 | |||
377 | void (*send_request)(struct fw_card *card, struct fw_packet *packet); | ||
378 | void (*send_response)(struct fw_card *card, struct fw_packet *packet); | ||
379 | /* Calling cancel is valid once a packet has been submitted. */ | ||
380 | int (*cancel_packet)(struct fw_card *card, struct fw_packet *packet); | ||
381 | |||
382 | /* | ||
383 | * Allow the specified node ID to do direct DMA out and in of | ||
384 | * host memory. The card will disable this for all node when | ||
385 | * a bus reset happens, so driver need to reenable this after | ||
386 | * bus reset. Returns 0 on success, -ENODEV if the card | ||
387 | * doesn't support this, -ESTALE if the generation doesn't | ||
388 | * match. | ||
389 | */ | ||
390 | int (*enable_phys_dma)(struct fw_card *card, | ||
391 | int node_id, int generation); | ||
392 | |||
393 | u64 (*get_bus_time)(struct fw_card *card); | ||
394 | |||
395 | struct fw_iso_context * | ||
396 | (*allocate_iso_context)(struct fw_card *card, | ||
397 | int type, size_t header_size); | ||
398 | void (*free_iso_context)(struct fw_iso_context *ctx); | ||
399 | |||
400 | int (*start_iso)(struct fw_iso_context *ctx, | ||
401 | s32 cycle, u32 sync, u32 tags); | ||
402 | |||
403 | int (*queue_iso)(struct fw_iso_context *ctx, | ||
404 | struct fw_iso_packet *packet, | ||
405 | struct fw_iso_buffer *buffer, | ||
406 | unsigned long payload); | ||
407 | |||
408 | int (*stop_iso)(struct fw_iso_context *ctx); | ||
409 | }; | ||
410 | |||
411 | int | ||
412 | fw_core_initiate_bus_reset(struct fw_card *card, int short_reset); | ||
413 | |||
414 | void | ||
415 | fw_send_request(struct fw_card *card, struct fw_transaction *t, | ||
416 | int tcode, int node_id, int generation, int speed, | ||
417 | unsigned long long offset, | ||
418 | void *data, size_t length, | ||
419 | fw_transaction_callback_t callback, void *callback_data); | ||
420 | |||
421 | int fw_cancel_transaction(struct fw_card *card, | ||
422 | struct fw_transaction *transaction); | ||
423 | |||
424 | void fw_flush_transactions(struct fw_card *card); | ||
425 | |||
426 | void fw_send_phy_config(struct fw_card *card, | ||
427 | int node_id, int generation, int gap_count); | ||
428 | |||
429 | /* | ||
430 | * Called by the topology code to inform the device code of node | ||
431 | * activity; found, lost, or updated nodes. | ||
432 | */ | ||
433 | void | ||
434 | fw_node_event(struct fw_card *card, struct fw_node *node, int event); | ||
435 | |||
436 | /* API used by card level drivers */ | ||
437 | |||
438 | void | ||
439 | fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, | ||
440 | struct device *device); | ||
441 | int | ||
442 | fw_card_add(struct fw_card *card, | ||
443 | u32 max_receive, u32 link_speed, u64 guid); | ||
444 | |||
445 | void | ||
446 | fw_core_remove_card(struct fw_card *card); | ||
447 | |||
448 | void | ||
449 | fw_core_handle_bus_reset(struct fw_card *card, | ||
450 | int node_id, int generation, | ||
451 | int self_id_count, u32 *self_ids); | ||
452 | void | ||
453 | fw_core_handle_request(struct fw_card *card, struct fw_packet *request); | ||
454 | |||
455 | void | ||
456 | fw_core_handle_response(struct fw_card *card, struct fw_packet *packet); | ||
457 | |||
458 | #endif /* __fw_transaction_h */ | ||
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index a19b65ed3119..7f817897b178 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -240,11 +240,94 @@ static inline void hidinput_pb_setup(struct input_dev *input) | |||
240 | } | 240 | } |
241 | #endif | 241 | #endif |
242 | 242 | ||
243 | static inline int match_scancode(int code, int scancode) | ||
244 | { | ||
245 | if (scancode == 0) | ||
246 | return 1; | ||
247 | return ((code & (HID_USAGE_PAGE | HID_USAGE)) == scancode); | ||
248 | } | ||
249 | |||
250 | static inline int match_keycode(int code, int keycode) | ||
251 | { | ||
252 | if (keycode == 0) | ||
253 | return 1; | ||
254 | return (code == keycode); | ||
255 | } | ||
256 | |||
257 | static struct hid_usage *hidinput_find_key(struct hid_device *hid, | ||
258 | int scancode, int keycode) | ||
259 | { | ||
260 | int i, j, k; | ||
261 | struct hid_report *report; | ||
262 | struct hid_usage *usage; | ||
263 | |||
264 | for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) { | ||
265 | list_for_each_entry(report, &hid->report_enum[k].report_list, list) { | ||
266 | for (i = 0; i < report->maxfield; i++) { | ||
267 | for ( j = 0; j < report->field[i]->maxusage; j++) { | ||
268 | usage = report->field[i]->usage + j; | ||
269 | if (usage->type == EV_KEY && | ||
270 | match_scancode(usage->hid, scancode) && | ||
271 | match_keycode(usage->code, keycode)) | ||
272 | return usage; | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | return NULL; | ||
278 | } | ||
279 | |||
280 | static int hidinput_getkeycode(struct input_dev *dev, int scancode, | ||
281 | int *keycode) | ||
282 | { | ||
283 | struct hid_device *hid = dev->private; | ||
284 | struct hid_usage *usage; | ||
285 | |||
286 | usage = hidinput_find_key(hid, scancode, 0); | ||
287 | if (usage) { | ||
288 | *keycode = usage->code; | ||
289 | return 0; | ||
290 | } | ||
291 | return -EINVAL; | ||
292 | } | ||
293 | |||
294 | static int hidinput_setkeycode(struct input_dev *dev, int scancode, | ||
295 | int keycode) | ||
296 | { | ||
297 | struct hid_device *hid = dev->private; | ||
298 | struct hid_usage *usage; | ||
299 | int old_keycode; | ||
300 | |||
301 | if (keycode < 0 || keycode > KEY_MAX) | ||
302 | return -EINVAL; | ||
303 | |||
304 | usage = hidinput_find_key(hid, scancode, 0); | ||
305 | if (usage) { | ||
306 | old_keycode = usage->code; | ||
307 | usage->code = keycode; | ||
308 | |||
309 | clear_bit(old_keycode, dev->keybit); | ||
310 | set_bit(usage->code, dev->keybit); | ||
311 | #ifdef CONFIG_HID_DEBUG | ||
312 | printk (KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", keycode, scancode); | ||
313 | #endif | ||
314 | /* Set the keybit for the old keycode if the old keycode is used | ||
315 | * by another key */ | ||
316 | if (hidinput_find_key (hid, 0, old_keycode)) | ||
317 | set_bit(old_keycode, dev->keybit); | ||
318 | |||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | return -EINVAL; | ||
323 | } | ||
324 | |||
325 | |||
243 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, | 326 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, |
244 | struct hid_usage *usage) | 327 | struct hid_usage *usage) |
245 | { | 328 | { |
246 | struct input_dev *input = hidinput->input; | 329 | struct input_dev *input = hidinput->input; |
247 | struct hid_device *device = input->private; | 330 | struct hid_device *device = input_get_drvdata(input); |
248 | int max = 0, code; | 331 | int max = 0, code; |
249 | unsigned long *bit = NULL; | 332 | unsigned long *bit = NULL; |
250 | 333 | ||
@@ -553,6 +636,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
553 | case 0x1015: map_key_clear(KEY_RECORD); break; | 636 | case 0x1015: map_key_clear(KEY_RECORD); break; |
554 | case 0x1016: map_key_clear(KEY_PLAYER); break; | 637 | case 0x1016: map_key_clear(KEY_PLAYER); break; |
555 | case 0x1017: map_key_clear(KEY_EJECTCD); break; | 638 | case 0x1017: map_key_clear(KEY_EJECTCD); break; |
639 | case 0x1018: map_key_clear(KEY_MEDIA); break; | ||
556 | case 0x1019: map_key_clear(KEY_PROG1); break; | 640 | case 0x1019: map_key_clear(KEY_PROG1); break; |
557 | case 0x101a: map_key_clear(KEY_PROG2); break; | 641 | case 0x101a: map_key_clear(KEY_PROG2); break; |
558 | case 0x101b: map_key_clear(KEY_PROG3); break; | 642 | case 0x101b: map_key_clear(KEY_PROG3); break; |
@@ -560,9 +644,12 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
560 | case 0x1020: map_key_clear(KEY_ZOOMOUT); break; | 644 | case 0x1020: map_key_clear(KEY_ZOOMOUT); break; |
561 | case 0x1021: map_key_clear(KEY_ZOOMRESET); break; | 645 | case 0x1021: map_key_clear(KEY_ZOOMRESET); break; |
562 | case 0x1023: map_key_clear(KEY_CLOSE); break; | 646 | case 0x1023: map_key_clear(KEY_CLOSE); break; |
647 | case 0x1027: map_key_clear(KEY_MENU); break; | ||
563 | /* this one is marked as 'Rotate' */ | 648 | /* this one is marked as 'Rotate' */ |
564 | case 0x1028: map_key_clear(KEY_ANGLE); break; | 649 | case 0x1028: map_key_clear(KEY_ANGLE); break; |
565 | case 0x1029: map_key_clear(KEY_SHUFFLE); break; | 650 | case 0x1029: map_key_clear(KEY_SHUFFLE); break; |
651 | case 0x102a: map_key_clear(KEY_BACK); break; | ||
652 | case 0x102b: map_key_clear(KEY_CYCLEWINDOWS); break; | ||
566 | case 0x1041: map_key_clear(KEY_BATTERY); break; | 653 | case 0x1041: map_key_clear(KEY_BATTERY); break; |
567 | case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break; | 654 | case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break; |
568 | case 0x1043: map_key_clear(KEY_SPREADSHEET); break; | 655 | case 0x1043: map_key_clear(KEY_SPREADSHEET); break; |
@@ -855,13 +942,15 @@ EXPORT_SYMBOL_GPL(hidinput_find_field); | |||
855 | 942 | ||
856 | static int hidinput_open(struct input_dev *dev) | 943 | static int hidinput_open(struct input_dev *dev) |
857 | { | 944 | { |
858 | struct hid_device *hid = dev->private; | 945 | struct hid_device *hid = input_get_drvdata(dev); |
946 | |||
859 | return hid->hid_open(hid); | 947 | return hid->hid_open(hid); |
860 | } | 948 | } |
861 | 949 | ||
862 | static void hidinput_close(struct input_dev *dev) | 950 | static void hidinput_close(struct input_dev *dev) |
863 | { | 951 | { |
864 | struct hid_device *hid = dev->private; | 952 | struct hid_device *hid = input_get_drvdata(dev); |
953 | |||
865 | hid->hid_close(hid); | 954 | hid->hid_close(hid); |
866 | } | 955 | } |
867 | 956 | ||
@@ -909,10 +998,12 @@ int hidinput_connect(struct hid_device *hid) | |||
909 | return -1; | 998 | return -1; |
910 | } | 999 | } |
911 | 1000 | ||
912 | input_dev->private = hid; | 1001 | input_set_drvdata(input_dev, hid); |
913 | input_dev->event = hid->hidinput_input_event; | 1002 | input_dev->event = hid->hidinput_input_event; |
914 | input_dev->open = hidinput_open; | 1003 | input_dev->open = hidinput_open; |
915 | input_dev->close = hidinput_close; | 1004 | input_dev->close = hidinput_close; |
1005 | input_dev->setkeycode = hidinput_setkeycode; | ||
1006 | input_dev->getkeycode = hidinput_getkeycode; | ||
916 | 1007 | ||
917 | input_dev->name = hid->name; | 1008 | input_dev->name = hid->name; |
918 | input_dev->phys = hid->phys; | 1009 | input_dev->phys = hid->phys; |
@@ -921,7 +1012,7 @@ int hidinput_connect(struct hid_device *hid) | |||
921 | input_dev->id.vendor = hid->vendor; | 1012 | input_dev->id.vendor = hid->vendor; |
922 | input_dev->id.product = hid->product; | 1013 | input_dev->id.product = hid->product; |
923 | input_dev->id.version = hid->version; | 1014 | input_dev->id.version = hid->version; |
924 | input_dev->cdev.dev = hid->dev; | 1015 | input_dev->dev.parent = hid->dev; |
925 | hidinput->input = input_dev; | 1016 | hidinput->input = input_dev; |
926 | list_add_tail(&hidinput->list, &hid->inputs); | 1017 | list_add_tail(&hidinput->list, &hid->inputs); |
927 | } | 1018 | } |
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig index 7c87bdc538bc..1b4b572f899b 100644 --- a/drivers/hid/usbhid/Kconfig +++ b/drivers/hid/usbhid/Kconfig | |||
@@ -25,12 +25,12 @@ comment "Input core support is needed for USB HID input layer or HIDBP support" | |||
25 | depends on USB_HID && INPUT=n | 25 | depends on USB_HID && INPUT=n |
26 | 26 | ||
27 | config USB_HIDINPUT_POWERBOOK | 27 | config USB_HIDINPUT_POWERBOOK |
28 | bool "Enable support for iBook/PowerBook special keys" | 28 | bool "Enable support for iBook/PowerBook/MacBook/MacBookPro special keys" |
29 | default n | 29 | default n |
30 | depends on USB_HID | 30 | depends on USB_HID |
31 | help | 31 | help |
32 | Say Y here if you want support for the special keys (Fn, Numlock) on | 32 | Say Y here if you want support for the special keys (Fn, Numlock) on |
33 | Apple iBooks and PowerBooks. | 33 | Apple iBooks, PowerBooks, MacBooks and MacBook Pros. |
34 | 34 | ||
35 | If unsure, say N. | 35 | If unsure, say N. |
36 | 36 | ||
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 91d610358d57..d91b9dac6dff 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -446,7 +446,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns | |||
446 | 446 | ||
447 | static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 447 | static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
448 | { | 448 | { |
449 | struct hid_device *hid = dev->private; | 449 | struct hid_device *hid = input_get_drvdata(dev); |
450 | struct hid_field *field; | 450 | struct hid_field *field; |
451 | int offset; | 451 | int offset; |
452 | 452 | ||
@@ -626,14 +626,10 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) | |||
626 | { | 626 | { |
627 | struct usbhid_device *usbhid = hid->driver_data; | 627 | struct usbhid_device *usbhid = hid->driver_data; |
628 | 628 | ||
629 | if (usbhid->inbuf) | 629 | usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); |
630 | usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); | 630 | usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); |
631 | if (usbhid->outbuf) | 631 | usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma); |
632 | usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); | 632 | usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); |
633 | if (usbhid->cr) | ||
634 | usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma); | ||
635 | if (usbhid->ctrlbuf) | ||
636 | usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); | ||
637 | } | 633 | } |
638 | 634 | ||
639 | /* | 635 | /* |
@@ -692,6 +688,30 @@ static void hid_fixup_logitech_descriptor(unsigned char *rdesc, int rsize) | |||
692 | } | 688 | } |
693 | } | 689 | } |
694 | 690 | ||
691 | /* | ||
692 | * Some USB barcode readers from cypress have usage min and usage max in | ||
693 | * the wrong order | ||
694 | */ | ||
695 | static void hid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize) | ||
696 | { | ||
697 | short fixed = 0; | ||
698 | int i; | ||
699 | |||
700 | for (i = 0; i < rsize - 4; i++) { | ||
701 | if (rdesc[i] == 0x29 && rdesc [i+2] == 0x19) { | ||
702 | unsigned char tmp; | ||
703 | |||
704 | rdesc[i] = 0x19; rdesc[i+2] = 0x29; | ||
705 | tmp = rdesc[i+3]; | ||
706 | rdesc[i+3] = rdesc[i+1]; | ||
707 | rdesc[i+1] = tmp; | ||
708 | } | ||
709 | } | ||
710 | |||
711 | if (fixed) | ||
712 | info("Fixing up Cypress report descriptor"); | ||
713 | } | ||
714 | |||
695 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) | 715 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) |
696 | { | 716 | { |
697 | struct usb_host_interface *interface = intf->cur_altsetting; | 717 | struct usb_host_interface *interface = intf->cur_altsetting; |
@@ -758,6 +778,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
758 | if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR) | 778 | if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR) |
759 | hid_fixup_logitech_descriptor(rdesc, rsize); | 779 | hid_fixup_logitech_descriptor(rdesc, rsize); |
760 | 780 | ||
781 | if (quirks & HID_QUIRK_SWAPPED_MIN_MAX) | ||
782 | hid_fixup_cypress_descriptor(rdesc, rsize); | ||
783 | |||
761 | #ifdef CONFIG_HID_DEBUG | 784 | #ifdef CONFIG_HID_DEBUG |
762 | printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n); | 785 | printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n); |
763 | for (n = 0; n < rsize; n++) | 786 | for (n = 0; n < rsize; n++) |
diff --git a/drivers/hid/usbhid/hid-lgff.c b/drivers/hid/usbhid/hid-lgff.c index 92d2553f17b6..c5cd4107d6af 100644 --- a/drivers/hid/usbhid/hid-lgff.c +++ b/drivers/hid/usbhid/hid-lgff.c | |||
@@ -60,7 +60,7 @@ static const struct dev_type devices[] = { | |||
60 | 60 | ||
61 | static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect) | 61 | static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect) |
62 | { | 62 | { |
63 | struct hid_device *hid = dev->private; | 63 | struct hid_device *hid = input_get_drvdata(dev); |
64 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; | 64 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
65 | struct hid_report *report = list_entry(report_list->next, struct hid_report, list); | 65 | struct hid_report *report = list_entry(report_list->next, struct hid_report, list); |
66 | int x, y; | 66 | int x, y; |
diff --git a/drivers/hid/usbhid/hid-plff.c b/drivers/hid/usbhid/hid-plff.c index 76d2e6e14db4..d6a8f2b49bd2 100644 --- a/drivers/hid/usbhid/hid-plff.c +++ b/drivers/hid/usbhid/hid-plff.c | |||
@@ -37,7 +37,7 @@ struct plff_device { | |||
37 | static int hid_plff_play(struct input_dev *dev, void *data, | 37 | static int hid_plff_play(struct input_dev *dev, void *data, |
38 | struct ff_effect *effect) | 38 | struct ff_effect *effect) |
39 | { | 39 | { |
40 | struct hid_device *hid = dev->private; | 40 | struct hid_device *hid = input_get_drvdata(dev); |
41 | struct plff_device *plff = data; | 41 | struct plff_device *plff = data; |
42 | int left, right; | 42 | int left, right; |
43 | 43 | ||
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 17a87555e32f..f6c4145dc202 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -92,6 +92,8 @@ | |||
92 | #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 | 92 | #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 |
93 | #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 | 93 | #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 |
94 | #define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 | 94 | #define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 |
95 | #define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61 | ||
96 | #define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64 | ||
95 | 97 | ||
96 | #define USB_VENDOR_ID_DELL 0x413c | 98 | #define USB_VENDOR_ID_DELL 0x413c |
97 | #define USB_DEVICE_ID_DELL_W7658 0x2005 | 99 | #define USB_DEVICE_ID_DELL_W7658 0x2005 |
@@ -193,6 +195,7 @@ | |||
193 | 195 | ||
194 | #define USB_VENDOR_ID_LOGITECH 0x046d | 196 | #define USB_VENDOR_ID_LOGITECH 0x046d |
195 | #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 | 197 | #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 |
198 | #define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 | ||
196 | #define USB_DEVICE_ID_S510_RECEIVER 0xc50c | 199 | #define USB_DEVICE_ID_S510_RECEIVER 0xc50c |
197 | #define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 | 200 | #define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 |
198 | #define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 | 201 | #define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 |
@@ -422,6 +425,7 @@ static const struct hid_blacklist { | |||
422 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, | 425 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, |
423 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, | 426 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, |
424 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, | 427 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, |
428 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL, HID_QUIRK_NOGET }, | ||
425 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, | 429 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, |
426 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, | 430 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, |
427 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, | 431 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
@@ -445,6 +449,9 @@ static const struct hid_blacklist { | |||
445 | 449 | ||
446 | { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, | 450 | { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, |
447 | 451 | ||
452 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1, HID_QUIRK_SWAPPED_MIN_MAX }, | ||
453 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2, HID_QUIRK_SWAPPED_MIN_MAX }, | ||
454 | |||
448 | { 0, 0 } | 455 | { 0, 0 } |
449 | }; | 456 | }; |
450 | 457 | ||
diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/usbhid/hid-tmff.c index ab67331620d0..ab5ba6ef891c 100644 --- a/drivers/hid/usbhid/hid-tmff.c +++ b/drivers/hid/usbhid/hid-tmff.c | |||
@@ -59,7 +59,7 @@ static inline int hid_tmff_scale(unsigned int in, int minimum, int maximum) | |||
59 | 59 | ||
60 | static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) | 60 | static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) |
61 | { | 61 | { |
62 | struct hid_device *hid = dev->private; | 62 | struct hid_device *hid = input_get_drvdata(dev); |
63 | struct tmff_device *tmff = data; | 63 | struct tmff_device *tmff = data; |
64 | int left, right; /* Rumbling */ | 64 | int left, right; /* Rumbling */ |
65 | 65 | ||
diff --git a/drivers/hid/usbhid/hid-zpff.c b/drivers/hid/usbhid/hid-zpff.c index 7bd8238ca212..a7fbffcdaf36 100644 --- a/drivers/hid/usbhid/hid-zpff.c +++ b/drivers/hid/usbhid/hid-zpff.c | |||
@@ -37,7 +37,7 @@ struct zpff_device { | |||
37 | static int hid_zpff_play(struct input_dev *dev, void *data, | 37 | static int hid_zpff_play(struct input_dev *dev, void *data, |
38 | struct ff_effect *effect) | 38 | struct ff_effect *effect) |
39 | { | 39 | { |
40 | struct hid_device *hid = dev->private; | 40 | struct hid_device *hid = input_get_drvdata(dev); |
41 | struct zpff_device *zpff = data; | 41 | struct zpff_device *zpff = data; |
42 | int left, right; | 42 | int left, right; |
43 | 43 | ||
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index a8b3d66cd498..488d61bdbf2c 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c | |||
@@ -51,6 +51,7 @@ struct hiddev { | |||
51 | wait_queue_head_t wait; | 51 | wait_queue_head_t wait; |
52 | struct hid_device *hid; | 52 | struct hid_device *hid; |
53 | struct list_head list; | 53 | struct list_head list; |
54 | spinlock_t list_lock; | ||
54 | }; | 55 | }; |
55 | 56 | ||
56 | struct hiddev_list { | 57 | struct hiddev_list { |
@@ -161,7 +162,9 @@ static void hiddev_send_event(struct hid_device *hid, | |||
161 | { | 162 | { |
162 | struct hiddev *hiddev = hid->hiddev; | 163 | struct hiddev *hiddev = hid->hiddev; |
163 | struct hiddev_list *list; | 164 | struct hiddev_list *list; |
165 | unsigned long flags; | ||
164 | 166 | ||
167 | spin_lock_irqsave(&hiddev->list_lock, flags); | ||
165 | list_for_each_entry(list, &hiddev->list, node) { | 168 | list_for_each_entry(list, &hiddev->list, node) { |
166 | if (uref->field_index != HID_FIELD_INDEX_NONE || | 169 | if (uref->field_index != HID_FIELD_INDEX_NONE || |
167 | (list->flags & HIDDEV_FLAG_REPORT) != 0) { | 170 | (list->flags & HIDDEV_FLAG_REPORT) != 0) { |
@@ -171,6 +174,7 @@ static void hiddev_send_event(struct hid_device *hid, | |||
171 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 174 | kill_fasync(&list->fasync, SIGIO, POLL_IN); |
172 | } | 175 | } |
173 | } | 176 | } |
177 | spin_unlock_irqrestore(&hiddev->list_lock, flags); | ||
174 | 178 | ||
175 | wake_up_interruptible(&hiddev->wait); | 179 | wake_up_interruptible(&hiddev->wait); |
176 | } | 180 | } |
@@ -235,9 +239,13 @@ static int hiddev_fasync(int fd, struct file *file, int on) | |||
235 | static int hiddev_release(struct inode * inode, struct file * file) | 239 | static int hiddev_release(struct inode * inode, struct file * file) |
236 | { | 240 | { |
237 | struct hiddev_list *list = file->private_data; | 241 | struct hiddev_list *list = file->private_data; |
242 | unsigned long flags; | ||
238 | 243 | ||
239 | hiddev_fasync(-1, file, 0); | 244 | hiddev_fasync(-1, file, 0); |
245 | |||
246 | spin_lock_irqsave(&list->hiddev->list_lock, flags); | ||
240 | list_del(&list->node); | 247 | list_del(&list->node); |
248 | spin_unlock_irqrestore(&list->hiddev->list_lock, flags); | ||
241 | 249 | ||
242 | if (!--list->hiddev->open) { | 250 | if (!--list->hiddev->open) { |
243 | if (list->hiddev->exist) | 251 | if (list->hiddev->exist) |
@@ -257,6 +265,7 @@ static int hiddev_release(struct inode * inode, struct file * file) | |||
257 | static int hiddev_open(struct inode *inode, struct file *file) | 265 | static int hiddev_open(struct inode *inode, struct file *file) |
258 | { | 266 | { |
259 | struct hiddev_list *list; | 267 | struct hiddev_list *list; |
268 | unsigned long flags; | ||
260 | 269 | ||
261 | int i = iminor(inode) - HIDDEV_MINOR_BASE; | 270 | int i = iminor(inode) - HIDDEV_MINOR_BASE; |
262 | 271 | ||
@@ -267,7 +276,11 @@ static int hiddev_open(struct inode *inode, struct file *file) | |||
267 | return -ENOMEM; | 276 | return -ENOMEM; |
268 | 277 | ||
269 | list->hiddev = hiddev_table[i]; | 278 | list->hiddev = hiddev_table[i]; |
279 | |||
280 | spin_lock_irqsave(&list->hiddev->list_lock, flags); | ||
270 | list_add_tail(&list->node, &hiddev_table[i]->list); | 281 | list_add_tail(&list->node, &hiddev_table[i]->list); |
282 | spin_unlock_irqrestore(&list->hiddev->list_lock, flags); | ||
283 | |||
271 | file->private_data = list; | 284 | file->private_data = list; |
272 | 285 | ||
273 | if (!list->hiddev->open++) | 286 | if (!list->hiddev->open++) |
@@ -773,6 +786,7 @@ int hiddev_connect(struct hid_device *hid) | |||
773 | 786 | ||
774 | init_waitqueue_head(&hiddev->wait); | 787 | init_waitqueue_head(&hiddev->wait); |
775 | INIT_LIST_HEAD(&hiddev->list); | 788 | INIT_LIST_HEAD(&hiddev->list); |
789 | spin_lock_init(&hiddev->list_lock); | ||
776 | hiddev->hid = hid; | 790 | hiddev->hid = hid; |
777 | hiddev->exist = 1; | 791 | hiddev->exist = 1; |
778 | 792 | ||
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index 65aa12e8d7b3..130978780713 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c | |||
@@ -133,12 +133,11 @@ resubmit: | |||
133 | static int usb_kbd_event(struct input_dev *dev, unsigned int type, | 133 | static int usb_kbd_event(struct input_dev *dev, unsigned int type, |
134 | unsigned int code, int value) | 134 | unsigned int code, int value) |
135 | { | 135 | { |
136 | struct usb_kbd *kbd = dev->private; | 136 | struct usb_kbd *kbd = input_get_drvdata(dev); |
137 | 137 | ||
138 | if (type != EV_LED) | 138 | if (type != EV_LED) |
139 | return -1; | 139 | return -1; |
140 | 140 | ||
141 | |||
142 | kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | | 141 | kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | |
143 | (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | | 142 | (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | |
144 | (!!test_bit(LED_NUML, dev->led)); | 143 | (!!test_bit(LED_NUML, dev->led)); |
@@ -175,7 +174,7 @@ static void usb_kbd_led(struct urb *urb) | |||
175 | 174 | ||
176 | static int usb_kbd_open(struct input_dev *dev) | 175 | static int usb_kbd_open(struct input_dev *dev) |
177 | { | 176 | { |
178 | struct usb_kbd *kbd = dev->private; | 177 | struct usb_kbd *kbd = input_get_drvdata(dev); |
179 | 178 | ||
180 | kbd->irq->dev = kbd->usbdev; | 179 | kbd->irq->dev = kbd->usbdev; |
181 | if (usb_submit_urb(kbd->irq, GFP_KERNEL)) | 180 | if (usb_submit_urb(kbd->irq, GFP_KERNEL)) |
@@ -186,7 +185,7 @@ static int usb_kbd_open(struct input_dev *dev) | |||
186 | 185 | ||
187 | static void usb_kbd_close(struct input_dev *dev) | 186 | static void usb_kbd_close(struct input_dev *dev) |
188 | { | 187 | { |
189 | struct usb_kbd *kbd = dev->private; | 188 | struct usb_kbd *kbd = input_get_drvdata(dev); |
190 | 189 | ||
191 | usb_kill_urb(kbd->irq); | 190 | usb_kill_urb(kbd->irq); |
192 | } | 191 | } |
@@ -211,12 +210,9 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) | |||
211 | { | 210 | { |
212 | usb_free_urb(kbd->irq); | 211 | usb_free_urb(kbd->irq); |
213 | usb_free_urb(kbd->led); | 212 | usb_free_urb(kbd->led); |
214 | if (kbd->new) | 213 | usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); |
215 | usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); | 214 | usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma); |
216 | if (kbd->cr) | 215 | usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); |
217 | usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma); | ||
218 | if (kbd->leds) | ||
219 | usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); | ||
220 | } | 216 | } |
221 | 217 | ||
222 | static int usb_kbd_probe(struct usb_interface *iface, | 218 | static int usb_kbd_probe(struct usb_interface *iface, |
@@ -274,8 +270,9 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
274 | input_dev->name = kbd->name; | 270 | input_dev->name = kbd->name; |
275 | input_dev->phys = kbd->phys; | 271 | input_dev->phys = kbd->phys; |
276 | usb_to_input_id(dev, &input_dev->id); | 272 | usb_to_input_id(dev, &input_dev->id); |
277 | input_dev->cdev.dev = &iface->dev; | 273 | input_dev->dev.parent = &iface->dev; |
278 | input_dev->private = kbd; | 274 | |
275 | input_set_drvdata(input_dev, kbd); | ||
279 | 276 | ||
280 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 277 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); |
281 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | 278 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); |
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c index 573776d865e1..5345c73bcf62 100644 --- a/drivers/hid/usbhid/usbmouse.c +++ b/drivers/hid/usbhid/usbmouse.c | |||
@@ -96,7 +96,7 @@ resubmit: | |||
96 | 96 | ||
97 | static int usb_mouse_open(struct input_dev *dev) | 97 | static int usb_mouse_open(struct input_dev *dev) |
98 | { | 98 | { |
99 | struct usb_mouse *mouse = dev->private; | 99 | struct usb_mouse *mouse = input_get_drvdata(dev); |
100 | 100 | ||
101 | mouse->irq->dev = mouse->usbdev; | 101 | mouse->irq->dev = mouse->usbdev; |
102 | if (usb_submit_urb(mouse->irq, GFP_KERNEL)) | 102 | if (usb_submit_urb(mouse->irq, GFP_KERNEL)) |
@@ -107,7 +107,7 @@ static int usb_mouse_open(struct input_dev *dev) | |||
107 | 107 | ||
108 | static void usb_mouse_close(struct input_dev *dev) | 108 | static void usb_mouse_close(struct input_dev *dev) |
109 | { | 109 | { |
110 | struct usb_mouse *mouse = dev->private; | 110 | struct usb_mouse *mouse = input_get_drvdata(dev); |
111 | 111 | ||
112 | usb_kill_urb(mouse->irq); | 112 | usb_kill_urb(mouse->irq); |
113 | } | 113 | } |
@@ -171,7 +171,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i | |||
171 | input_dev->name = mouse->name; | 171 | input_dev->name = mouse->name; |
172 | input_dev->phys = mouse->phys; | 172 | input_dev->phys = mouse->phys; |
173 | usb_to_input_id(dev, &input_dev->id); | 173 | usb_to_input_id(dev, &input_dev->id); |
174 | input_dev->cdev.dev = &intf->dev; | 174 | input_dev->dev.parent = &intf->dev; |
175 | 175 | ||
176 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 176 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
177 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 177 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
@@ -179,7 +179,8 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i | |||
179 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 179 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
180 | input_dev->relbit[0] |= BIT(REL_WHEEL); | 180 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
181 | 181 | ||
182 | input_dev->private = mouse; | 182 | input_set_drvdata(input_dev, mouse); |
183 | |||
183 | input_dev->open = usb_mouse_open; | 184 | input_dev->open = usb_mouse_open; |
184 | input_dev->close = usb_mouse_close; | 185 | input_dev->close = usb_mouse_close; |
185 | 186 | ||
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 3ba3a5221c41..4d1cb5b855d1 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | menuconfig HWMON | 5 | menuconfig HWMON |
6 | tristate "Hardware Monitoring support" | 6 | tristate "Hardware Monitoring support" |
7 | depends on HAS_IOMEM | ||
7 | default y | 8 | default y |
8 | help | 9 | help |
9 | Hardware monitoring devices let you monitor the hardware health | 10 | Hardware monitoring devices let you monitor the hardware health |
diff --git a/drivers/hwmon/ams/ams-input.c b/drivers/hwmon/ams/ams-input.c index 18210164e307..ca7095d96ad0 100644 --- a/drivers/hwmon/ams/ams-input.c +++ b/drivers/hwmon/ams/ams-input.c | |||
@@ -87,7 +87,7 @@ static void ams_input_enable(void) | |||
87 | ams_info.idev->id.vendor = 0; | 87 | ams_info.idev->id.vendor = 0; |
88 | ams_info.idev->open = ams_input_open; | 88 | ams_info.idev->open = ams_input_open; |
89 | ams_info.idev->close = ams_input_close; | 89 | ams_info.idev->close = ams_input_close; |
90 | ams_info.idev->cdev.dev = &ams_info.of_dev->dev; | 90 | ams_info.idev->dev.parent = &ams_info.of_dev->dev; |
91 | 91 | ||
92 | input_set_abs_params(ams_info.idev, ABS_X, -50, 50, 3, 0); | 92 | input_set_abs_params(ams_info.idev, ABS_X, -50, 50, 3, 0); |
93 | input_set_abs_params(ams_info.idev, ABS_Y, -50, 50, 3, 0); | 93 | input_set_abs_params(ams_info.idev, ABS_Y, -50, 50, 3, 0); |
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index b51c104a28a2..0c160675b3ac 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c | |||
@@ -1100,7 +1100,7 @@ static int applesmc_create_accelerometer(void) | |||
1100 | /* initialize the input class */ | 1100 | /* initialize the input class */ |
1101 | applesmc_idev->name = "applesmc"; | 1101 | applesmc_idev->name = "applesmc"; |
1102 | applesmc_idev->id.bustype = BUS_HOST; | 1102 | applesmc_idev->id.bustype = BUS_HOST; |
1103 | applesmc_idev->cdev.dev = &pdev->dev; | 1103 | applesmc_idev->dev.parent = &pdev->dev; |
1104 | applesmc_idev->evbit[0] = BIT(EV_ABS); | 1104 | applesmc_idev->evbit[0] = BIT(EV_ABS); |
1105 | applesmc_idev->open = applesmc_idev_open; | 1105 | applesmc_idev->open = applesmc_idev_open; |
1106 | applesmc_idev->close = applesmc_idev_close; | 1106 | applesmc_idev->close = applesmc_idev_close; |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index f82fa2d23f95..e0cf5e6fe5bc 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -574,7 +574,7 @@ static int __init hdaps_init(void) | |||
574 | 574 | ||
575 | /* initialize the input class */ | 575 | /* initialize the input class */ |
576 | hdaps_idev->name = "hdaps"; | 576 | hdaps_idev->name = "hdaps"; |
577 | hdaps_idev->cdev.dev = &pdev->dev; | 577 | hdaps_idev->dev.parent = &pdev->dev; |
578 | hdaps_idev->evbit[0] = BIT(EV_ABS); | 578 | hdaps_idev->evbit[0] = BIT(EV_ABS); |
579 | input_set_abs_params(hdaps_idev, ABS_X, | 579 | input_set_abs_params(hdaps_idev, ABS_X, |
580 | -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT); | 580 | -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT); |
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 434a61b415a3..96867347bcbf 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | menuconfig I2C | 5 | menuconfig I2C |
6 | tristate "I2C support" | 6 | tristate "I2C support" |
7 | depends on HAS_IOMEM | ||
7 | ---help--- | 8 | ---help--- |
8 | I2C (pronounce: I-square-C) is a slow serial bus protocol used in | 9 | I2C (pronounce: I-square-C) is a slow serial bus protocol used in |
9 | many micro controller applications and developed by Philips. SMBus, | 10 | many micro controller applications and developed by Philips. SMBus, |
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index f35156c58922..9c8b6d5eaec9 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/version.h> | 17 | #include <linux/version.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/err.h> | ||
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | #include <linux/types.h> | 21 | #include <linux/types.h> |
21 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
@@ -226,13 +227,14 @@ static int __devinit at91_i2c_probe(struct platform_device *pdev) | |||
226 | adapter->algo = &at91_algorithm; | 227 | adapter->algo = &at91_algorithm; |
227 | adapter->class = I2C_CLASS_HWMON; | 228 | adapter->class = I2C_CLASS_HWMON; |
228 | adapter->dev.parent = &pdev->dev; | 229 | adapter->dev.parent = &pdev->dev; |
230 | /* adapter->id == 0 ... only one TWI controller for now */ | ||
229 | 231 | ||
230 | platform_set_drvdata(pdev, adapter); | 232 | platform_set_drvdata(pdev, adapter); |
231 | 233 | ||
232 | clk_enable(twi_clk); /* enable peripheral clock */ | 234 | clk_enable(twi_clk); /* enable peripheral clock */ |
233 | at91_twi_hwinit(); /* initialize TWI controller */ | 235 | at91_twi_hwinit(); /* initialize TWI controller */ |
234 | 236 | ||
235 | rc = i2c_add_adapter(adapter); | 237 | rc = i2c_add_numbered_adapter(adapter); |
236 | if (rc) { | 238 | if (rc) { |
237 | dev_err(&pdev->dev, "Adapter %s registration failed\n", | 239 | dev_err(&pdev->dev, "Adapter %s registration failed\n", |
238 | adapter->name); | 240 | adapter->name); |
@@ -295,6 +297,9 @@ static int at91_i2c_resume(struct platform_device *pdev) | |||
295 | #define at91_i2c_resume NULL | 297 | #define at91_i2c_resume NULL |
296 | #endif | 298 | #endif |
297 | 299 | ||
300 | /* work with "modprobe at91_i2c" from hotplugging or coldplugging */ | ||
301 | MODULE_ALIAS("at91_i2c"); | ||
302 | |||
298 | static struct platform_driver at91_i2c_driver = { | 303 | static struct platform_driver at91_i2c_driver = { |
299 | .probe = at91_i2c_probe, | 304 | .probe = at91_i2c_probe, |
300 | .remove = __devexit_p(at91_i2c_remove), | 305 | .remove = __devexit_p(at91_i2c_remove), |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 873544ab598e..8a0a99b93641 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -548,7 +548,7 @@ static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c) | |||
548 | */ | 548 | */ |
549 | icr = readl(_ICR(i2c)); | 549 | icr = readl(_ICR(i2c)); |
550 | icr &= ~(ICR_STOP | ICR_ACKNAK); | 550 | icr &= ~(ICR_STOP | ICR_ACKNAK); |
551 | writel(icr, _IRC(i2c)); | 551 | writel(icr, _ICR(i2c)); |
552 | } | 552 | } |
553 | 553 | ||
554 | /* | 554 | /* |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 1d06b415ede9..9040809d2c25 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -7,6 +7,7 @@ | |||
7 | if BLOCK | 7 | if BLOCK |
8 | 8 | ||
9 | menu "ATA/ATAPI/MFM/RLL support" | 9 | menu "ATA/ATAPI/MFM/RLL support" |
10 | depends on HAS_IOMEM | ||
10 | 11 | ||
11 | config IDE | 12 | config IDE |
12 | tristate "ATA/ATAPI/MFM/RLL support" | 13 | tristate "ATA/ATAPI/MFM/RLL support" |
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 1fe0457243db..66f826252aee 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -565,8 +565,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
565 | ide_hwif_t *hwif; | 565 | ide_hwif_t *hwif; |
566 | void __iomem *base; | 566 | void __iomem *base; |
567 | 567 | ||
568 | base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), | 568 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
569 | ecard_resource_len(ec, ECARD_RES_MEMC)); | ||
570 | if (!base) | 569 | if (!base) |
571 | return -ENOMEM; | 570 | return -ENOMEM; |
572 | 571 | ||
@@ -574,8 +573,8 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
574 | 573 | ||
575 | ec->irqaddr = base + ICS_ARCIN_V5_INTRSTAT; | 574 | ec->irqaddr = base + ICS_ARCIN_V5_INTRSTAT; |
576 | ec->irqmask = 1; | 575 | ec->irqmask = 1; |
577 | ec->irq_data = state; | 576 | |
578 | ec->ops = &icside_ops_arcin_v5; | 577 | ecard_setirq(ec, &icside_ops_arcin_v5, state); |
579 | 578 | ||
580 | /* | 579 | /* |
581 | * Be on the safe side - disable interrupts | 580 | * Be on the safe side - disable interrupts |
@@ -583,10 +582,8 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
583 | icside_irqdisable_arcin_v5(ec, 0); | 582 | icside_irqdisable_arcin_v5(ec, 0); |
584 | 583 | ||
585 | hwif = icside_setup(base, &icside_cardinfo_v5, ec); | 584 | hwif = icside_setup(base, &icside_cardinfo_v5, ec); |
586 | if (!hwif) { | 585 | if (!hwif) |
587 | iounmap(base); | ||
588 | return -ENODEV; | 586 | return -ENODEV; |
589 | } | ||
590 | 587 | ||
591 | state->hwif[0] = hwif; | 588 | state->hwif[0] = hwif; |
592 | 589 | ||
@@ -605,8 +602,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
605 | unsigned int sel = 0; | 602 | unsigned int sel = 0; |
606 | int ret; | 603 | int ret; |
607 | 604 | ||
608 | ioc_base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST), | 605 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
609 | ecard_resource_len(ec, ECARD_RES_IOCFAST)); | ||
610 | if (!ioc_base) { | 606 | if (!ioc_base) { |
611 | ret = -ENOMEM; | 607 | ret = -ENOMEM; |
612 | goto out; | 608 | goto out; |
@@ -615,11 +611,10 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
615 | easi_base = ioc_base; | 611 | easi_base = ioc_base; |
616 | 612 | ||
617 | if (ecard_resource_flags(ec, ECARD_RES_EASI)) { | 613 | if (ecard_resource_flags(ec, ECARD_RES_EASI)) { |
618 | easi_base = ioremap(ecard_resource_start(ec, ECARD_RES_EASI), | 614 | easi_base = ecardm_iomap(ec, ECARD_RES_EASI, 0, 0); |
619 | ecard_resource_len(ec, ECARD_RES_EASI)); | ||
620 | if (!easi_base) { | 615 | if (!easi_base) { |
621 | ret = -ENOMEM; | 616 | ret = -ENOMEM; |
622 | goto unmap_slot; | 617 | goto out; |
623 | } | 618 | } |
624 | 619 | ||
625 | /* | 620 | /* |
@@ -630,8 +625,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
630 | 625 | ||
631 | writeb(sel, ioc_base); | 626 | writeb(sel, ioc_base); |
632 | 627 | ||
633 | ec->irq_data = state; | 628 | ecard_setirq(ec, &icside_ops_arcin_v6, state); |
634 | ec->ops = &icside_ops_arcin_v6; | ||
635 | 629 | ||
636 | state->irq_port = easi_base; | 630 | state->irq_port = easi_base; |
637 | state->ioc_base = ioc_base; | 631 | state->ioc_base = ioc_base; |
@@ -649,7 +643,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
649 | 643 | ||
650 | if (!hwif || !mate) { | 644 | if (!hwif || !mate) { |
651 | ret = -ENODEV; | 645 | ret = -ENODEV; |
652 | goto unmap_port; | 646 | goto out; |
653 | } | 647 | } |
654 | 648 | ||
655 | state->hwif[0] = hwif; | 649 | state->hwif[0] = hwif; |
@@ -686,11 +680,6 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
686 | 680 | ||
687 | return 0; | 681 | return 0; |
688 | 682 | ||
689 | unmap_port: | ||
690 | if (easi_base != ioc_base) | ||
691 | iounmap(easi_base); | ||
692 | unmap_slot: | ||
693 | iounmap(ioc_base); | ||
694 | out: | 683 | out: |
695 | return ret; | 684 | return ret; |
696 | } | 685 | } |
@@ -716,8 +705,7 @@ icside_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
716 | state->type = ICS_TYPE_NOTYPE; | 705 | state->type = ICS_TYPE_NOTYPE; |
717 | state->dev = &ec->dev; | 706 | state->dev = &ec->dev; |
718 | 707 | ||
719 | idmem = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST), | 708 | idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
720 | ecard_resource_len(ec, ECARD_RES_IOCFAST)); | ||
721 | if (idmem) { | 709 | if (idmem) { |
722 | unsigned int type; | 710 | unsigned int type; |
723 | 711 | ||
@@ -725,7 +713,7 @@ icside_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
725 | type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1; | 713 | type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1; |
726 | type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2; | 714 | type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2; |
727 | type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3; | 715 | type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3; |
728 | iounmap(idmem); | 716 | ecardm_iounmap(ec, idmem); |
729 | 717 | ||
730 | state->type = type; | 718 | state->type = type; |
731 | } | 719 | } |
@@ -793,13 +781,6 @@ static void __devexit icside_remove(struct expansion_card *ec) | |||
793 | } | 781 | } |
794 | 782 | ||
795 | ecard_set_drvdata(ec, NULL); | 783 | ecard_set_drvdata(ec, NULL); |
796 | ec->ops = NULL; | ||
797 | ec->irq_data = NULL; | ||
798 | |||
799 | if (state->ioc_base) | ||
800 | iounmap(state->ioc_base); | ||
801 | if (state->ioc_base != state->irq_port) | ||
802 | iounmap(state->irq_port); | ||
803 | 784 | ||
804 | kfree(state); | 785 | kfree(state); |
805 | ecard_release_resources(ec); | 786 | ecard_release_resources(ec); |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index 890ea3fac3c6..83811af11610 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -63,8 +63,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
63 | if (ret) | 63 | if (ret) |
64 | goto out; | 64 | goto out; |
65 | 65 | ||
66 | base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), | 66 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
67 | ecard_resource_len(ec, ECARD_RES_MEMC)); | ||
68 | if (!base) { | 67 | if (!base) { |
69 | ret = -ENOMEM; | 68 | ret = -ENOMEM; |
70 | goto release; | 69 | goto release; |
@@ -81,7 +80,6 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
81 | goto out; | 80 | goto out; |
82 | } | 81 | } |
83 | 82 | ||
84 | iounmap(base); | ||
85 | release: | 83 | release: |
86 | ecard_release_resources(ec); | 84 | ecard_release_resources(ec); |
87 | out: | 85 | out: |
@@ -96,7 +94,6 @@ static void __devexit rapide_remove(struct expansion_card *ec) | |||
96 | 94 | ||
97 | /* there must be a better way */ | 95 | /* there must be a better way */ |
98 | ide_unregister(hwif - ide_hwifs); | 96 | ide_unregister(hwif - ide_hwifs); |
99 | iounmap(hwif->hwif_data); | ||
100 | ecard_release_resources(ec); | 97 | ecard_release_resources(ec); |
101 | } | 98 | } |
102 | 99 | ||
diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig index 61d7809a5a26..8012b3b0ce75 100644 --- a/drivers/ieee1394/Kconfig +++ b/drivers/ieee1394/Kconfig | |||
@@ -1,4 +1,7 @@ | |||
1 | menu "IEEE 1394 (FireWire) support" | 1 | menu "IEEE 1394 (FireWire) support" |
2 | depends on PCI || BROKEN | ||
3 | |||
4 | source "drivers/firewire/Kconfig" | ||
2 | 5 | ||
3 | config IEEE1394 | 6 | config IEEE1394 |
4 | tristate "IEEE 1394 (FireWire) support" | 7 | tristate "IEEE 1394 (FireWire) support" |
diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig index 37deaae49190..994decc7bcf2 100644 --- a/drivers/infiniband/Kconfig +++ b/drivers/infiniband/Kconfig | |||
@@ -1,4 +1,5 @@ | |||
1 | menu "InfiniBand support" | 1 | menu "InfiniBand support" |
2 | depends on HAS_IOMEM | ||
2 | 3 | ||
3 | config INFINIBAND | 4 | config INFINIBAND |
4 | depends on PCI || BROKEN | 5 | depends on PCI || BROKEN |
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 0e9b69535ad6..f814fb3a469d 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Input device support" | 5 | menu "Input device support" |
6 | depends on !S390 | ||
6 | 7 | ||
7 | config INPUT | 8 | config INPUT |
8 | tristate "Generic input layer (needed for keyboard, mouse, ...)" if EMBEDDED | 9 | tristate "Generic input layer (needed for keyboard, mouse, ...)" if EMBEDDED |
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 55a72592704c..b234729706be 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -336,7 +336,7 @@ static int bits_to_user(unsigned long *bits, unsigned int maxbit, | |||
336 | 336 | ||
337 | if (compat) { | 337 | if (compat) { |
338 | len = NBITS_COMPAT(maxbit) * sizeof(compat_long_t); | 338 | len = NBITS_COMPAT(maxbit) * sizeof(compat_long_t); |
339 | if (len < maxlen) | 339 | if (len > maxlen) |
340 | len = maxlen; | 340 | len = maxlen; |
341 | 341 | ||
342 | for (i = 0; i < len / sizeof(compat_long_t); i++) | 342 | for (i = 0; i < len / sizeof(compat_long_t); i++) |
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c index 3d4b619dadab..e759944041ab 100644 --- a/drivers/input/misc/ixp4xx-beeper.c +++ b/drivers/input/misc/ixp4xx-beeper.c | |||
@@ -51,7 +51,7 @@ static void ixp4xx_spkr_control(unsigned int pin, unsigned int count) | |||
51 | 51 | ||
52 | static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 52 | static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
53 | { | 53 | { |
54 | unsigned int pin = (unsigned int) input_get_drvdata(input_dev); | 54 | unsigned int pin = (unsigned int) input_get_drvdata(dev); |
55 | unsigned int count = 0; | 55 | unsigned int count = 0; |
56 | 56 | ||
57 | if (type != EV_SND) | 57 | if (type != EV_SND) |
diff --git a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig index c90afeea54aa..d42fe89cddf6 100644 --- a/drivers/isdn/Kconfig +++ b/drivers/isdn/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "ISDN subsystem" | 5 | menu "ISDN subsystem" |
6 | depends on !S390 | ||
6 | 7 | ||
7 | config ISDN | 8 | config ISDN |
8 | tristate "ISDN support" | 9 | tristate "ISDN support" |
diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig index 703cc88d1ef9..e8e37d826478 100644 --- a/drivers/kvm/Kconfig +++ b/drivers/kvm/Kconfig | |||
@@ -2,6 +2,7 @@ | |||
2 | # KVM configuration | 2 | # KVM configuration |
3 | # | 3 | # |
4 | menu "Virtualization" | 4 | menu "Virtualization" |
5 | depends on X86 | ||
5 | 6 | ||
6 | config KVM | 7 | config KVM |
7 | tristate "Kernel-based Virtual Machine (KVM) support" | 8 | tristate "Kernel-based Virtual Machine (KVM) support" |
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 80acd08f0e97..87d2046f866c 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -1,5 +1,6 @@ | |||
1 | 1 | ||
2 | menu "LED devices" | 2 | menu "LED devices" |
3 | depends on HAS_IOMEM | ||
3 | 4 | ||
4 | config NEW_LEDS | 5 | config NEW_LEDS |
5 | bool "LED Support" | 6 | bool "LED Support" |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 65814b0340cb..c10ce91b64e9 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -5103,7 +5103,7 @@ static int is_mddev_idle(mddev_t *mddev) | |||
5103 | * | 5103 | * |
5104 | * Note: the following is an unsigned comparison. | 5104 | * Note: the following is an unsigned comparison. |
5105 | */ | 5105 | */ |
5106 | if ((curr_events - rdev->last_events + 4096) > 8192) { | 5106 | if ((long)curr_events - (long)rdev->last_events > 4096) { |
5107 | rdev->last_events = curr_events; | 5107 | rdev->last_events = curr_events; |
5108 | idle = 0; | 5108 | idle = 0; |
5109 | } | 5109 | } |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 97ee870b265d..3a95cc5e029c 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -271,21 +271,25 @@ static int raid1_end_read_request(struct bio *bio, unsigned int bytes_done, int | |||
271 | */ | 271 | */ |
272 | update_head_pos(mirror, r1_bio); | 272 | update_head_pos(mirror, r1_bio); |
273 | 273 | ||
274 | if (uptodate || (conf->raid_disks - conf->mddev->degraded) <= 1) { | 274 | if (uptodate) |
275 | /* | 275 | set_bit(R1BIO_Uptodate, &r1_bio->state); |
276 | * Set R1BIO_Uptodate in our master bio, so that | 276 | else { |
277 | * we will return a good error code for to the higher | 277 | /* If all other devices have failed, we want to return |
278 | * levels even if IO on some other mirrored buffer fails. | 278 | * the error upwards rather than fail the last device. |
279 | * | 279 | * Here we redefine "uptodate" to mean "Don't want to retry" |
280 | * The 'master' represents the composite IO operation to | ||
281 | * user-side. So if something waits for IO, then it will | ||
282 | * wait for the 'master' bio. | ||
283 | */ | 280 | */ |
284 | if (uptodate) | 281 | unsigned long flags; |
285 | set_bit(R1BIO_Uptodate, &r1_bio->state); | 282 | spin_lock_irqsave(&conf->device_lock, flags); |
283 | if (r1_bio->mddev->degraded == conf->raid_disks || | ||
284 | (r1_bio->mddev->degraded == conf->raid_disks-1 && | ||
285 | !test_bit(Faulty, &conf->mirrors[mirror].rdev->flags))) | ||
286 | uptodate = 1; | ||
287 | spin_unlock_irqrestore(&conf->device_lock, flags); | ||
288 | } | ||
286 | 289 | ||
290 | if (uptodate) | ||
287 | raid_end_bio_io(r1_bio); | 291 | raid_end_bio_io(r1_bio); |
288 | } else { | 292 | else { |
289 | /* | 293 | /* |
290 | * oops, read error: | 294 | * oops, read error: |
291 | */ | 295 | */ |
@@ -992,13 +996,14 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev) | |||
992 | unsigned long flags; | 996 | unsigned long flags; |
993 | spin_lock_irqsave(&conf->device_lock, flags); | 997 | spin_lock_irqsave(&conf->device_lock, flags); |
994 | mddev->degraded++; | 998 | mddev->degraded++; |
999 | set_bit(Faulty, &rdev->flags); | ||
995 | spin_unlock_irqrestore(&conf->device_lock, flags); | 1000 | spin_unlock_irqrestore(&conf->device_lock, flags); |
996 | /* | 1001 | /* |
997 | * if recovery is running, make sure it aborts. | 1002 | * if recovery is running, make sure it aborts. |
998 | */ | 1003 | */ |
999 | set_bit(MD_RECOVERY_ERR, &mddev->recovery); | 1004 | set_bit(MD_RECOVERY_ERR, &mddev->recovery); |
1000 | } | 1005 | } else |
1001 | set_bit(Faulty, &rdev->flags); | 1006 | set_bit(Faulty, &rdev->flags); |
1002 | set_bit(MD_CHANGE_DEVS, &mddev->flags); | 1007 | set_bit(MD_CHANGE_DEVS, &mddev->flags); |
1003 | printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n" | 1008 | printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n" |
1004 | " Operation continuing on %d devices\n", | 1009 | " Operation continuing on %d devices\n", |
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index 91d25798ae4a..624b21cef5b3 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Multimedia devices" | 5 | menu "Multimedia devices" |
6 | depends on HAS_IOMEM | ||
6 | 7 | ||
7 | config VIDEO_DEV | 8 | config VIDEO_DEV |
8 | tristate "Video For Linux" | 9 | tristate "Video For Linux" |
@@ -86,6 +87,14 @@ config VIDEO_TVEEPROM | |||
86 | tristate | 87 | tristate |
87 | depends on I2C | 88 | depends on I2C |
88 | 89 | ||
90 | config DAB | ||
91 | boolean "DAB adapters" | ||
92 | default y | ||
93 | ---help--- | ||
94 | Allow selecting support for for Digital Audio Broadcasting (DAB) | ||
95 | Receiver adapters. | ||
96 | |||
97 | if DAB | ||
89 | config USB_DABUSB | 98 | config USB_DABUSB |
90 | tristate "DABUSB driver" | 99 | tristate "DABUSB driver" |
91 | depends on USB | 100 | depends on USB |
@@ -99,5 +108,6 @@ config USB_DABUSB | |||
99 | 108 | ||
100 | To compile this driver as a module, choose M here: the | 109 | To compile this driver as a module, choose M here: the |
101 | module will be called dabusb. | 110 | module will be called dabusb. |
111 | endif # DAB | ||
102 | 112 | ||
103 | endmenu | 113 | endmenu |
diff --git a/drivers/media/Makefile b/drivers/media/Makefile index c578a529e7a8..8fa19939c2b6 100644 --- a/drivers/media/Makefile +++ b/drivers/media/Makefile | |||
@@ -5,4 +5,4 @@ | |||
5 | obj-y := common/ | 5 | obj-y := common/ |
6 | obj-$(CONFIG_VIDEO_DEV) += video/ | 6 | obj-$(CONFIG_VIDEO_DEV) += video/ |
7 | obj-$(CONFIG_VIDEO_DEV) += radio/ | 7 | obj-$(CONFIG_VIDEO_DEV) += radio/ |
8 | obj-$(CONFIG_DVB) += dvb/ | 8 | obj-$(CONFIG_DVB_CORE) += dvb/ |
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index 86cbdbcf9d7d..ef3e54cd9407 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c | |||
@@ -136,28 +136,45 @@ char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa | |||
136 | char *mem = vmalloc_32(length); | 136 | char *mem = vmalloc_32(length); |
137 | int slen = 0; | 137 | int slen = 0; |
138 | 138 | ||
139 | if (NULL == mem) { | 139 | if (NULL == mem) |
140 | return NULL; | 140 | goto err_null; |
141 | } | ||
142 | 141 | ||
143 | if (!(pt->slist = vmalloc_to_sg(mem, pages))) { | 142 | if (!(pt->slist = vmalloc_to_sg(mem, pages))) |
144 | vfree(mem); | 143 | goto err_free_mem; |
145 | return NULL; | ||
146 | } | ||
147 | 144 | ||
148 | if (saa7146_pgtable_alloc(pci, pt)) { | 145 | if (saa7146_pgtable_alloc(pci, pt)) |
149 | kfree(pt->slist); | 146 | goto err_free_slist; |
150 | pt->slist = NULL; | ||
151 | vfree(mem); | ||
152 | return NULL; | ||
153 | } | ||
154 | 147 | ||
155 | slen = pci_map_sg(pci,pt->slist,pages,PCI_DMA_FROMDEVICE); | 148 | pt->nents = pages; |
156 | if (0 != saa7146_pgtable_build_single(pci, pt, pt->slist, slen)) { | 149 | slen = pci_map_sg(pci,pt->slist,pt->nents,PCI_DMA_FROMDEVICE); |
157 | return NULL; | 150 | if (0 == slen) |
158 | } | 151 | goto err_free_pgtable; |
152 | |||
153 | if (0 != saa7146_pgtable_build_single(pci, pt, pt->slist, slen)) | ||
154 | goto err_unmap_sg; | ||
159 | 155 | ||
160 | return mem; | 156 | return mem; |
157 | |||
158 | err_unmap_sg: | ||
159 | pci_unmap_sg(pci, pt->slist, pt->nents, PCI_DMA_FROMDEVICE); | ||
160 | err_free_pgtable: | ||
161 | saa7146_pgtable_free(pci, pt); | ||
162 | err_free_slist: | ||
163 | kfree(pt->slist); | ||
164 | pt->slist = NULL; | ||
165 | err_free_mem: | ||
166 | vfree(mem); | ||
167 | err_null: | ||
168 | return NULL; | ||
169 | } | ||
170 | |||
171 | void saa7146_vfree_destroy_pgtable(struct pci_dev *pci, char *mem, struct saa7146_pgtable *pt) | ||
172 | { | ||
173 | pci_unmap_sg(pci, pt->slist, pt->nents, PCI_DMA_FROMDEVICE); | ||
174 | saa7146_pgtable_free(pci, pt); | ||
175 | kfree(pt->slist); | ||
176 | pt->slist = NULL; | ||
177 | vfree(mem); | ||
161 | } | 178 | } |
162 | 179 | ||
163 | void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) | 180 | void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) |
@@ -166,8 +183,6 @@ void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) | |||
166 | return; | 183 | return; |
167 | pci_free_consistent(pci, pt->size, pt->cpu, pt->dma); | 184 | pci_free_consistent(pci, pt->size, pt->cpu, pt->dma); |
168 | pt->cpu = NULL; | 185 | pt->cpu = NULL; |
169 | kfree(pt->slist); | ||
170 | pt->slist = NULL; | ||
171 | } | 186 | } |
172 | 187 | ||
173 | int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) | 188 | int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) |
@@ -528,6 +543,7 @@ EXPORT_SYMBOL_GPL(saa7146_pgtable_alloc); | |||
528 | EXPORT_SYMBOL_GPL(saa7146_pgtable_free); | 543 | EXPORT_SYMBOL_GPL(saa7146_pgtable_free); |
529 | EXPORT_SYMBOL_GPL(saa7146_pgtable_build_single); | 544 | EXPORT_SYMBOL_GPL(saa7146_pgtable_build_single); |
530 | EXPORT_SYMBOL_GPL(saa7146_vmalloc_build_pgtable); | 545 | EXPORT_SYMBOL_GPL(saa7146_vmalloc_build_pgtable); |
546 | EXPORT_SYMBOL_GPL(saa7146_vfree_destroy_pgtable); | ||
531 | EXPORT_SYMBOL_GPL(saa7146_wait_for_debi_done); | 547 | EXPORT_SYMBOL_GPL(saa7146_wait_for_debi_done); |
532 | 548 | ||
533 | EXPORT_SYMBOL_GPL(saa7146_setgpio); | 549 | EXPORT_SYMBOL_GPL(saa7146_setgpio); |
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index c18a5da64934..b4770aecc01d 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c | |||
@@ -307,7 +307,6 @@ static int fops_release(struct inode *inode, struct file *file) | |||
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | 309 | ||
310 | int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg); | ||
311 | static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 310 | static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
312 | { | 311 | { |
313 | /* | 312 | /* |
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig index a97c8f5e9a5d..efd2b7468158 100644 --- a/drivers/media/dvb/Kconfig +++ b/drivers/media/dvb/Kconfig | |||
@@ -2,24 +2,16 @@ | |||
2 | # Multimedia device configuration | 2 | # Multimedia device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Digital Video Broadcasting Devices" | 5 | source "drivers/media/dvb/dvb-core/Kconfig" |
6 | 6 | ||
7 | config DVB | 7 | menuconfig DVB_CAPTURE_DRIVERS |
8 | bool "DVB For Linux" | 8 | bool "DVB/ATSC adapters" |
9 | depends on NET && INET | 9 | depends on DVB_CORE |
10 | default y | ||
10 | ---help--- | 11 | ---help--- |
11 | Support Digital Video Broadcasting hardware. Enable this if you | 12 | Say Y to select Digital TV adapters |
12 | own a DVB adapter and want to use it or if you compile Linux for | ||
13 | a digital SetTopBox. | ||
14 | |||
15 | API specs and user tools are available from <http://www.linuxtv.org/>. | ||
16 | 13 | ||
17 | Please report problems regarding this driver to the LinuxDVB | 14 | if DVB_CAPTURE_DRIVERS |
18 | mailing list. | ||
19 | |||
20 | If unsure say N. | ||
21 | |||
22 | source "drivers/media/dvb/dvb-core/Kconfig" | ||
23 | 15 | ||
24 | comment "Supported SAA7146 based PCI Adapters" | 16 | comment "Supported SAA7146 based PCI Adapters" |
25 | depends on DVB_CORE && PCI && I2C | 17 | depends on DVB_CORE && PCI && I2C |
@@ -48,4 +40,4 @@ comment "Supported DVB Frontends" | |||
48 | depends on DVB_CORE | 40 | depends on DVB_CORE |
49 | source "drivers/media/dvb/frontends/Kconfig" | 41 | source "drivers/media/dvb/frontends/Kconfig" |
50 | 42 | ||
51 | endmenu | 43 | endif # DVB_CAPTURE_DRIVERS |
diff --git a/drivers/media/dvb/dvb-core/Kconfig b/drivers/media/dvb/dvb-core/Kconfig index 1990eda10c46..e3e6839f8073 100644 --- a/drivers/media/dvb/dvb-core/Kconfig +++ b/drivers/media/dvb/dvb-core/Kconfig | |||
@@ -1,12 +1,22 @@ | |||
1 | config DVB_CORE | 1 | config DVB_CORE |
2 | tristate "DVB Core Support" | 2 | tristate "DVB for Linux" |
3 | depends on DVB | 3 | depends on NET && INET |
4 | select CRC32 | 4 | select CRC32 |
5 | help | 5 | help |
6 | Support Digital Video Broadcasting hardware. Enable this if you | ||
7 | own a DVB adapter and want to use it or if you compile Linux for | ||
8 | a digital SetTopBox. | ||
9 | |||
6 | DVB core utility functions for device handling, software fallbacks etc. | 10 | DVB core utility functions for device handling, software fallbacks etc. |
7 | Say Y when you have a DVB card and want to use it. Say Y if your want | 11 | Say Y when you have a DVB card and want to use it. Say Y if your want |
8 | to build your drivers outside the kernel, but need the DVB core. All | 12 | to build your drivers outside the kernel, but need the DVB core. All |
9 | in-kernel drivers will select this automatically if needed. | 13 | in-kernel drivers will select this automatically if needed. |
14 | |||
15 | API specs and user tools are available from <http://www.linuxtv.org/>. | ||
16 | |||
17 | Please report problems regarding this driver to the LinuxDVB | ||
18 | mailing list. | ||
19 | |||
10 | If unsure say N. | 20 | If unsure say N. |
11 | 21 | ||
12 | config DVB_CORE_ATTACH | 22 | config DVB_CORE_ATTACH |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 97715f7514d6..403081689de1 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -19,6 +19,7 @@ | |||
19 | #define USB_VID_COMPRO_UNK 0x145f | 19 | #define USB_VID_COMPRO_UNK 0x145f |
20 | #define USB_VID_CYPRESS 0x04b4 | 20 | #define USB_VID_CYPRESS 0x04b4 |
21 | #define USB_VID_DIBCOM 0x10b8 | 21 | #define USB_VID_DIBCOM 0x10b8 |
22 | #define USB_VID_DPOSH 0x1498 | ||
22 | #define USB_VID_DVICO 0x0fe9 | 23 | #define USB_VID_DVICO 0x0fe9 |
23 | #define USB_VID_EMPIA 0xeb1a | 24 | #define USB_VID_EMPIA 0xeb1a |
24 | #define USB_VID_GENPIX 0x09c0 | 25 | #define USB_VID_GENPIX 0x09c0 |
@@ -61,6 +62,8 @@ | |||
61 | #define USB_PID_DIBCOM_STK7700P 0x1e14 | 62 | #define USB_PID_DIBCOM_STK7700P 0x1e14 |
62 | #define USB_PID_DIBCOM_STK7700P_PC 0x1e78 | 63 | #define USB_PID_DIBCOM_STK7700P_PC 0x1e78 |
63 | #define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 | 64 | #define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 |
65 | #define USB_PID_DPOSH_M9206_COLD 0x9206 | ||
66 | #define USB_PID_DPOSH_M9206_WARM 0xa090 | ||
64 | #define USB_PID_UNIWILL_STK7700P 0x6003 | 67 | #define USB_PID_UNIWILL_STK7700P 0x6003 |
65 | #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 | 68 | #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 |
66 | #define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 | 69 | #define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 |
@@ -145,6 +148,8 @@ | |||
145 | #define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 | 148 | #define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 |
146 | #define USB_PID_OPERA1_COLD 0x2830 | 149 | #define USB_PID_OPERA1_COLD 0x2830 |
147 | #define USB_PID_OPERA1_WARM 0x3829 | 150 | #define USB_PID_OPERA1_WARM 0x3829 |
151 | #define USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD 0x0514 | ||
152 | #define USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM 0x0513 | ||
148 | 153 | ||
149 | 154 | ||
150 | #endif | 155 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index 0d721731a524..6f824a569e14 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h | |||
@@ -119,7 +119,7 @@ struct usb_data_stream_properties { | |||
119 | * @caps: capabilities of the DVB USB device. | 119 | * @caps: capabilities of the DVB USB device. |
120 | * @pid_filter_count: number of PID filter position in the optional hardware | 120 | * @pid_filter_count: number of PID filter position in the optional hardware |
121 | * PID-filter. | 121 | * PID-filter. |
122 | * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the | 122 | * @streaming_ctrl: called to start and stop the MPEG2-TS streaming of the |
123 | * device (not URB submitting/killing). | 123 | * device (not URB submitting/killing). |
124 | * @pid_filter_ctrl: called to en/disable the PID filter, if any. | 124 | * @pid_filter_ctrl: called to en/disable the PID filter, if any. |
125 | * @pid_filter: called to set/unset a PID for filtering. | 125 | * @pid_filter: called to set/unset a PID for filtering. |
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c index 45d7bc214c18..c546ddeda5d4 100644 --- a/drivers/media/dvb/dvb-usb/m920x.c +++ b/drivers/media/dvb/dvb-usb/m920x.c | |||
@@ -3,8 +3,8 @@ | |||
3 | * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org) | 3 | * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org) |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the Free | 6 | * under the terms of the GNU General Public License as published by the |
7 | * Software Foundation, version 2. | 7 | * Free Software Foundation, version 2. |
8 | * | 8 | * |
9 | * see Documentation/dvb/README.dvb-usb for more information | 9 | * see Documentation/dvb/README.dvb-usb for more information |
10 | */ | 10 | */ |
@@ -22,26 +22,7 @@ static int dvb_usb_m920x_debug; | |||
22 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); | 22 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); |
23 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); | 23 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
24 | 24 | ||
25 | static struct dvb_usb_rc_key megasky_rc_keys [] = { | 25 | static inline int m920x_read(struct usb_device *udev, u8 request, u16 value, |
26 | { 0x0, 0x12, KEY_POWER }, | ||
27 | { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */ | ||
28 | { 0x0, 0x02, KEY_CHANNELUP }, | ||
29 | { 0x0, 0x05, KEY_CHANNELDOWN }, | ||
30 | { 0x0, 0x03, KEY_VOLUMEUP }, | ||
31 | { 0x0, 0x06, KEY_VOLUMEDOWN }, | ||
32 | { 0x0, 0x04, KEY_MUTE }, | ||
33 | { 0x0, 0x07, KEY_OK }, /* TS */ | ||
34 | { 0x0, 0x08, KEY_STOP }, | ||
35 | { 0x0, 0x09, KEY_MENU }, /* swap */ | ||
36 | { 0x0, 0x0a, KEY_REWIND }, | ||
37 | { 0x0, 0x1b, KEY_PAUSE }, | ||
38 | { 0x0, 0x1f, KEY_FASTFORWARD }, | ||
39 | { 0x0, 0x0c, KEY_RECORD }, | ||
40 | { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */ | ||
41 | { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */ | ||
42 | }; | ||
43 | |||
44 | static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\ | ||
45 | u16 index, void *data, int size) | 26 | u16 index, void *data, int size) |
46 | { | 27 | { |
47 | int ret; | 28 | int ret; |
@@ -55,14 +36,14 @@ static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\ | |||
55 | } | 36 | } |
56 | 37 | ||
57 | if (ret != size) { | 38 | if (ret != size) { |
58 | deb_rc("m920x_read = no data\n"); | 39 | deb("m920x_read = no data\n"); |
59 | return -EIO; | 40 | return -EIO; |
60 | } | 41 | } |
61 | 42 | ||
62 | return 0; | 43 | return 0; |
63 | } | 44 | } |
64 | 45 | ||
65 | static inline int m9206_write(struct usb_device *udev, u8 request, | 46 | static inline int m920x_write(struct usb_device *udev, u8 request, |
66 | u16 value, u16 index) | 47 | u16 value, u16 index) |
67 | { | 48 | { |
68 | int ret; | 49 | int ret; |
@@ -74,32 +55,40 @@ static inline int m9206_write(struct usb_device *udev, u8 request, | |||
74 | return ret; | 55 | return ret; |
75 | } | 56 | } |
76 | 57 | ||
77 | static int m9206_init(struct dvb_usb_device *d) | 58 | static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq) |
78 | { | 59 | { |
79 | int ret = 0; | 60 | int ret = 0; |
80 | 61 | ||
81 | /* Remote controller init. */ | 62 | /* Remote controller init. */ |
82 | if (d->props.rc_query) { | 63 | if (d->props.rc_query) { |
83 | if ((ret = m9206_write(d->udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0) | 64 | deb("Initialising remote control\n"); |
84 | return ret; | 65 | while (rc_seq->address) { |
66 | if ((ret = m920x_write(d->udev, M9206_CORE, | ||
67 | rc_seq->data, | ||
68 | rc_seq->address)) != 0) { | ||
69 | deb("Initialising remote control failed\n"); | ||
70 | return ret; | ||
71 | } | ||
85 | 72 | ||
86 | if ((ret = m9206_write(d->udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0) | 73 | rc_seq++; |
87 | return ret; | 74 | } |
75 | |||
76 | deb("Initialising remote control success\n"); | ||
88 | } | 77 | } |
89 | 78 | ||
90 | return ret; | 79 | return ret; |
91 | } | 80 | } |
92 | 81 | ||
93 | static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | 82 | static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
94 | { | 83 | { |
95 | struct m9206_state *m = d->priv; | 84 | struct m920x_state *m = d->priv; |
96 | int i, ret = 0; | 85 | int i, ret = 0; |
97 | u8 rc_state[2]; | 86 | u8 rc_state[2]; |
98 | 87 | ||
99 | if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) | 88 | if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) |
100 | goto unlock; | 89 | goto unlock; |
101 | 90 | ||
102 | if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) | 91 | if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) |
103 | goto unlock; | 92 | goto unlock; |
104 | 93 | ||
105 | for (i = 0; i < d->props.rc_key_map_size; i++) | 94 | for (i = 0; i < d->props.rc_key_map_size; i++) |
@@ -111,6 +100,14 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
111 | *state = REMOTE_NO_KEY_PRESSED; | 100 | *state = REMOTE_NO_KEY_PRESSED; |
112 | goto unlock; | 101 | goto unlock; |
113 | 102 | ||
103 | case 0x88: /* framing error or "invalid code" */ | ||
104 | case 0x99: | ||
105 | case 0xc0: | ||
106 | case 0xd8: | ||
107 | *state = REMOTE_NO_KEY_PRESSED; | ||
108 | m->rep_count = 0; | ||
109 | goto unlock; | ||
110 | |||
114 | case 0x93: | 111 | case 0x93: |
115 | case 0x92: | 112 | case 0x92: |
116 | m->rep_count = 0; | 113 | m->rep_count = 0; |
@@ -118,31 +115,32 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
118 | goto unlock; | 115 | goto unlock; |
119 | 116 | ||
120 | case 0x91: | 117 | case 0x91: |
121 | /* For comfort. */ | 118 | /* prevent immediate auto-repeat */ |
122 | if (++m->rep_count > 2) | 119 | if (++m->rep_count > 2) |
123 | *state = REMOTE_KEY_REPEAT; | 120 | *state = REMOTE_KEY_REPEAT; |
121 | else | ||
122 | *state = REMOTE_NO_KEY_PRESSED; | ||
124 | goto unlock; | 123 | goto unlock; |
125 | 124 | ||
126 | default: | 125 | default: |
127 | deb_rc("Unexpected rc response %x\n", rc_state[0]); | 126 | deb("Unexpected rc state %02x\n", rc_state[0]); |
128 | *state = REMOTE_NO_KEY_PRESSED; | 127 | *state = REMOTE_NO_KEY_PRESSED; |
129 | goto unlock; | 128 | goto unlock; |
130 | } | 129 | } |
131 | } | 130 | } |
132 | 131 | ||
133 | if (rc_state[1] != 0) | 132 | if (rc_state[1] != 0) |
134 | deb_rc("Unknown rc key %x\n", rc_state[1]); | 133 | deb("Unknown rc key %02x\n", rc_state[1]); |
135 | 134 | ||
136 | *state = REMOTE_NO_KEY_PRESSED; | 135 | *state = REMOTE_NO_KEY_PRESSED; |
137 | 136 | ||
138 | unlock: | 137 | unlock: |
139 | 138 | ||
140 | return ret; | 139 | return ret; |
141 | } | 140 | } |
142 | 141 | ||
143 | /* I2C */ | 142 | /* I2C */ |
144 | static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | 143 | static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
145 | int num) | ||
146 | { | 144 | { |
147 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | 145 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
148 | int i, j; | 146 | int i, j; |
@@ -155,33 +153,40 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
155 | return -EAGAIN; | 153 | return -EAGAIN; |
156 | 154 | ||
157 | for (i = 0; i < num; i++) { | 155 | for (i = 0; i < num; i++) { |
158 | if (msg[i].flags & (I2C_M_NO_RD_ACK|I2C_M_IGNORE_NAK|I2C_M_TEN) || | 156 | if (msg[i].flags & (I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK | I2C_M_TEN) || msg[i].len == 0) { |
159 | msg[i].len == 0) { | 157 | /* For a 0 byte message, I think sending the address |
160 | /* For a 0 byte message, I think sending the address to index 0x80|0x40 | 158 | * to index 0x80|0x40 would be the correct thing to |
161 | * would be the correct thing to do. However, zero byte messages are | 159 | * do. However, zero byte messages are only used for |
162 | * only used for probing, and since we don't know how to get the slave's | 160 | * probing, and since we don't know how to get the |
163 | * ack, we can't probe. */ | 161 | * slave's ack, we can't probe. */ |
164 | ret = -ENOTSUPP; | 162 | ret = -ENOTSUPP; |
165 | goto unlock; | 163 | goto unlock; |
166 | } | 164 | } |
167 | /* Send START & address/RW bit */ | 165 | /* Send START & address/RW bit */ |
168 | if (!(msg[i].flags & I2C_M_NOSTART)) { | 166 | if (!(msg[i].flags & I2C_M_NOSTART)) { |
169 | if ((ret = m9206_write(d->udev, M9206_I2C, (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0), 0x80)) != 0) | 167 | if ((ret = m920x_write(d->udev, M9206_I2C, |
168 | (msg[i].addr << 1) | | ||
169 | (msg[i].flags & I2C_M_RD ? 0x01 : 0), 0x80)) != 0) | ||
170 | goto unlock; | 170 | goto unlock; |
171 | /* Should check for ack here, if we knew how. */ | 171 | /* Should check for ack here, if we knew how. */ |
172 | } | 172 | } |
173 | if (msg[i].flags & I2C_M_RD) { | 173 | if (msg[i].flags & I2C_M_RD) { |
174 | for (j = 0; j < msg[i].len; j++) { | 174 | for (j = 0; j < msg[i].len; j++) { |
175 | /* Last byte of transaction? Send STOP, otherwise send ACK. */ | 175 | /* Last byte of transaction? |
176 | int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x01; | 176 | * Send STOP, otherwise send ACK. */ |
177 | if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x20|stop, &msg[i].buf[j], 1)) != 0) | 177 | int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x01; |
178 | |||
179 | if ((ret = m920x_read(d->udev, M9206_I2C, 0x0, | ||
180 | 0x20 | stop, | ||
181 | &msg[i].buf[j], 1)) != 0) | ||
178 | goto unlock; | 182 | goto unlock; |
179 | } | 183 | } |
180 | } else { | 184 | } else { |
181 | for (j = 0; j < msg[i].len; j++) { | 185 | for (j = 0; j < msg[i].len; j++) { |
182 | /* Last byte of transaction? Then send STOP. */ | 186 | /* Last byte of transaction? Then send STOP. */ |
183 | int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x00; | 187 | int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x00; |
184 | if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0) | 188 | |
189 | if ((ret = m920x_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0) | ||
185 | goto unlock; | 190 | goto unlock; |
186 | /* Should check for ack here too. */ | 191 | /* Should check for ack here too. */ |
187 | } | 192 | } |
@@ -189,25 +194,25 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
189 | } | 194 | } |
190 | ret = num; | 195 | ret = num; |
191 | 196 | ||
192 | unlock: | 197 | unlock: |
193 | mutex_unlock(&d->i2c_mutex); | 198 | mutex_unlock(&d->i2c_mutex); |
194 | 199 | ||
195 | return ret; | 200 | return ret; |
196 | } | 201 | } |
197 | 202 | ||
198 | static u32 m9206_i2c_func(struct i2c_adapter *adapter) | 203 | static u32 m920x_i2c_func(struct i2c_adapter *adapter) |
199 | { | 204 | { |
200 | return I2C_FUNC_I2C; | 205 | return I2C_FUNC_I2C; |
201 | } | 206 | } |
202 | 207 | ||
203 | static struct i2c_algorithm m9206_i2c_algo = { | 208 | static struct i2c_algorithm m920x_i2c_algo = { |
204 | .master_xfer = m9206_i2c_xfer, | 209 | .master_xfer = m920x_i2c_xfer, |
205 | .functionality = m9206_i2c_func, | 210 | .functionality = m920x_i2c_func, |
206 | }; | 211 | }; |
207 | 212 | ||
208 | 213 | /* pid filter */ | |
209 | static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, | 214 | static int m920x_set_filter(struct dvb_usb_adapter *adap, |
210 | int pid) | 215 | int type, int idx, int pid) |
211 | { | 216 | { |
212 | int ret = 0; | 217 | int ret = 0; |
213 | 218 | ||
@@ -216,18 +221,18 @@ static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, | |||
216 | 221 | ||
217 | pid |= 0x8000; | 222 | pid |= 0x8000; |
218 | 223 | ||
219 | if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0) | 224 | if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0) |
220 | return ret; | 225 | return ret; |
221 | 226 | ||
222 | if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0) | 227 | if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0) |
223 | return ret; | 228 | return ret; |
224 | 229 | ||
225 | return ret; | 230 | return ret; |
226 | } | 231 | } |
227 | 232 | ||
228 | static int m9206_update_filters(struct dvb_usb_adapter *adap) | 233 | static int m920x_update_filters(struct dvb_usb_adapter *adap) |
229 | { | 234 | { |
230 | struct m9206_state *m = adap->dev->priv; | 235 | struct m920x_state *m = adap->dev->priv; |
231 | int enabled = m->filtering_enabled; | 236 | int enabled = m->filtering_enabled; |
232 | int i, ret = 0, filter = 0; | 237 | int i, ret = 0, filter = 0; |
233 | 238 | ||
@@ -236,14 +241,14 @@ static int m9206_update_filters(struct dvb_usb_adapter *adap) | |||
236 | enabled = 0; | 241 | enabled = 0; |
237 | 242 | ||
238 | /* Disable all filters */ | 243 | /* Disable all filters */ |
239 | if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0) | 244 | if ((ret = m920x_set_filter(adap, 0x81, 1, enabled)) != 0) |
240 | return ret; | 245 | return ret; |
241 | 246 | ||
242 | for (i = 0; i < M9206_MAX_FILTERS; i++) | 247 | for (i = 0; i < M9206_MAX_FILTERS; i++) |
243 | if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0) | 248 | if ((ret = m920x_set_filter(adap, 0x81, i + 2, 0)) != 0) |
244 | return ret; | 249 | return ret; |
245 | 250 | ||
246 | if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0) | 251 | if ((ret = m920x_set_filter(adap, 0x82, 0, 0x0)) != 0) |
247 | return ret; | 252 | return ret; |
248 | 253 | ||
249 | /* Set */ | 254 | /* Set */ |
@@ -252,40 +257,38 @@ static int m9206_update_filters(struct dvb_usb_adapter *adap) | |||
252 | if (m->filters[i] == 0) | 257 | if (m->filters[i] == 0) |
253 | continue; | 258 | continue; |
254 | 259 | ||
255 | if ((ret = m9206_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0) | 260 | if ((ret = m920x_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0) |
256 | return ret; | 261 | return ret; |
257 | 262 | ||
258 | filter++; | 263 | filter++; |
259 | } | 264 | } |
260 | } | 265 | } |
261 | 266 | ||
262 | if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0) | 267 | if ((ret = m920x_set_filter(adap, 0x82, 0, 0x02f5)) != 0) |
263 | return ret; | 268 | return ret; |
264 | 269 | ||
265 | return ret; | 270 | return ret; |
266 | } | 271 | } |
267 | 272 | ||
268 | static int m9206_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) | 273 | static int m920x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) |
269 | { | 274 | { |
270 | struct m9206_state *m = adap->dev->priv; | 275 | struct m920x_state *m = adap->dev->priv; |
271 | 276 | ||
272 | m->filtering_enabled = onoff ? 1 : 0; | 277 | m->filtering_enabled = onoff ? 1 : 0; |
273 | 278 | ||
274 | return m9206_update_filters(adap); | 279 | return m920x_update_filters(adap); |
275 | } | 280 | } |
276 | 281 | ||
277 | static int m9206_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, | 282 | static int m920x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff) |
278 | int onoff) | ||
279 | { | 283 | { |
280 | struct m9206_state *m = adap->dev->priv; | 284 | struct m920x_state *m = adap->dev->priv; |
281 | 285 | ||
282 | m->filters[index] = onoff ? pid : 0; | 286 | m->filters[index] = onoff ? pid : 0; |
283 | 287 | ||
284 | return m9206_update_filters(adap); | 288 | return m920x_update_filters(adap); |
285 | } | 289 | } |
286 | 290 | ||
287 | static int m9206_firmware_download(struct usb_device *udev, | 291 | static int m920x_firmware_download(struct usb_device *udev, const struct firmware *fw) |
288 | const struct firmware *fw) | ||
289 | { | 292 | { |
290 | u16 value, index, size; | 293 | u16 value, index, size; |
291 | u8 read[4], *buff; | 294 | u8 read[4], *buff; |
@@ -293,13 +296,13 @@ static int m9206_firmware_download(struct usb_device *udev, | |||
293 | 296 | ||
294 | buff = kmalloc(65536, GFP_KERNEL); | 297 | buff = kmalloc(65536, GFP_KERNEL); |
295 | 298 | ||
296 | if ((ret = m9206_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0) | 299 | if ((ret = m920x_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0) |
297 | goto done; | 300 | goto done; |
298 | deb_rc("%x %x %x %x\n", read[0], read[1], read[2], read[3]); | 301 | deb("%x %x %x %x\n", read[0], read[1], read[2], read[3]); |
299 | 302 | ||
300 | if ((ret = m9206_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0) | 303 | if ((ret = m920x_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0) |
301 | goto done; | 304 | goto done; |
302 | deb_rc("%x\n", read[0]); | 305 | deb("%x\n", read[0]); |
303 | 306 | ||
304 | for (pass = 0; pass < 2; pass++) { | 307 | for (pass = 0; pass < 2; pass++) { |
305 | for (i = 0; i + (sizeof(u16) * 3) < fw->size;) { | 308 | for (i = 0; i + (sizeof(u16) * 3) < fw->size;) { |
@@ -317,11 +320,11 @@ static int m9206_firmware_download(struct usb_device *udev, | |||
317 | memcpy(buff, fw->data + i, size); | 320 | memcpy(buff, fw->data + i, size); |
318 | 321 | ||
319 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0), | 322 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0), |
320 | M9206_FW, | 323 | M9206_FW, |
321 | USB_TYPE_VENDOR | USB_DIR_OUT, | 324 | USB_TYPE_VENDOR | USB_DIR_OUT, |
322 | value, index, buff, size, 20); | 325 | value, index, buff, size, 20); |
323 | if (ret != size) { | 326 | if (ret != size) { |
324 | deb_rc("error while uploading fw!\n"); | 327 | deb("error while uploading fw!\n"); |
325 | ret = -EIO; | 328 | ret = -EIO; |
326 | goto done; | 329 | goto done; |
327 | } | 330 | } |
@@ -330,7 +333,7 @@ static int m9206_firmware_download(struct usb_device *udev, | |||
330 | i += size; | 333 | i += size; |
331 | } | 334 | } |
332 | if (i != fw->size) { | 335 | if (i != fw->size) { |
333 | deb_rc("bad firmware file!\n"); | 336 | deb("bad firmware file!\n"); |
334 | ret = -EINVAL; | 337 | ret = -EINVAL; |
335 | goto done; | 338 | goto done; |
336 | } | 339 | } |
@@ -338,11 +341,11 @@ static int m9206_firmware_download(struct usb_device *udev, | |||
338 | 341 | ||
339 | msleep(36); | 342 | msleep(36); |
340 | 343 | ||
341 | /* m9206 will disconnect itself from the bus after this. */ | 344 | /* m920x will disconnect itself from the bus after this. */ |
342 | (void) m9206_write(udev, M9206_CORE, 0x01, M9206_FW_GO); | 345 | (void) m920x_write(udev, M9206_CORE, 0x01, M9206_FW_GO); |
343 | deb_rc("firmware uploaded!\n"); | 346 | deb("firmware uploaded!\n"); |
344 | 347 | ||
345 | done: | 348 | done: |
346 | kfree(buff); | 349 | kfree(buff); |
347 | 350 | ||
348 | return ret; | 351 | return ret; |
@@ -362,7 +365,8 @@ static int m920x_identify_state(struct usb_device *udev, | |||
362 | return 0; | 365 | return 0; |
363 | } | 366 | } |
364 | 367 | ||
365 | static int megasky_mt352_demod_init(struct dvb_frontend *fe) | 368 | /* demod configurations */ |
369 | static int m920x_mt352_demod_init(struct dvb_frontend *fe) | ||
366 | { | 370 | { |
367 | u8 config[] = { CONFIG, 0x3d }; | 371 | u8 config[] = { CONFIG, 0x3d }; |
368 | u8 clock[] = { CLOCK_CTL, 0x30 }; | 372 | u8 clock[] = { CLOCK_CTL, 0x30 }; |
@@ -382,74 +386,174 @@ static int megasky_mt352_demod_init(struct dvb_frontend *fe) | |||
382 | mt352_write(fe, unk1, ARRAY_SIZE(unk1)); | 386 | mt352_write(fe, unk1, ARRAY_SIZE(unk1)); |
383 | mt352_write(fe, unk2, ARRAY_SIZE(unk2)); | 387 | mt352_write(fe, unk2, ARRAY_SIZE(unk2)); |
384 | 388 | ||
385 | deb_rc("Demod init!\n"); | 389 | deb("Demod init!\n"); |
386 | 390 | ||
387 | return 0; | 391 | return 0; |
388 | } | 392 | } |
389 | 393 | ||
390 | static struct mt352_config megasky_mt352_config = { | 394 | static struct mt352_config m920x_mt352_config = { |
391 | .demod_address = 0x0f, | 395 | .demod_address = 0x0f, |
392 | .no_tuner = 1, | 396 | .no_tuner = 1, |
393 | .demod_init = megasky_mt352_demod_init, | 397 | .demod_init = m920x_mt352_demod_init, |
398 | }; | ||
399 | |||
400 | static struct tda1004x_config m920x_tda10046_08_config = { | ||
401 | .demod_address = 0x08, | ||
402 | .invert = 0, | ||
403 | .invert_oclk = 0, | ||
404 | .ts_mode = TDA10046_TS_SERIAL, | ||
405 | .xtal_freq = TDA10046_XTAL_16M, | ||
406 | .if_freq = TDA10046_FREQ_045, | ||
407 | .agc_config = TDA10046_AGC_TDA827X, | ||
408 | .gpio_config = TDA10046_GPTRI, | ||
409 | .request_firmware = NULL, | ||
410 | }; | ||
411 | |||
412 | static struct tda1004x_config m920x_tda10046_0b_config = { | ||
413 | .demod_address = 0x0b, | ||
414 | .invert = 0, | ||
415 | .invert_oclk = 0, | ||
416 | .ts_mode = TDA10046_TS_SERIAL, | ||
417 | .xtal_freq = TDA10046_XTAL_16M, | ||
418 | .if_freq = TDA10046_FREQ_045, | ||
419 | .agc_config = TDA10046_AGC_TDA827X, | ||
420 | .gpio_config = TDA10046_GPTRI, | ||
421 | .request_firmware = NULL, /* uses firmware EEPROM */ | ||
422 | }; | ||
423 | |||
424 | /* tuner configurations */ | ||
425 | static struct qt1010_config m920x_qt1010_config = { | ||
426 | .i2c_address = 0x62 | ||
394 | }; | 427 | }; |
395 | 428 | ||
396 | static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap) | 429 | /* Callbacks for DVB USB */ |
430 | static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) | ||
397 | { | 431 | { |
398 | deb_rc("megasky_frontend_attach!\n"); | 432 | deb("%s\n",__FUNCTION__); |
399 | 433 | ||
400 | if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL) | 434 | if ((adap->fe = dvb_attach(mt352_attach, |
435 | &m920x_mt352_config, | ||
436 | &adap->dev->i2c_adap)) == NULL) | ||
401 | return -EIO; | 437 | return -EIO; |
402 | 438 | ||
403 | return 0; | 439 | return 0; |
404 | } | 440 | } |
405 | 441 | ||
406 | static struct qt1010_config megasky_qt1010_config = { | 442 | static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap) |
407 | .i2c_address = 0x62 | ||
408 | }; | ||
409 | |||
410 | static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap) | ||
411 | { | 443 | { |
412 | if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, | 444 | deb("%s\n",__FUNCTION__); |
413 | &megasky_qt1010_config) == NULL) | 445 | |
414 | return -ENODEV; | 446 | if ((adap->fe = dvb_attach(tda10046_attach, |
447 | &m920x_tda10046_08_config, | ||
448 | &adap->dev->i2c_adap)) == NULL) | ||
449 | return -EIO; | ||
415 | 450 | ||
416 | return 0; | 451 | return 0; |
417 | } | 452 | } |
418 | 453 | ||
419 | static struct tda1004x_config digivox_tda10046_config = { | 454 | static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap) |
420 | .demod_address = 0x08, | ||
421 | .invert = 0, | ||
422 | .invert_oclk = 0, | ||
423 | .ts_mode = TDA10046_TS_SERIAL, | ||
424 | .xtal_freq = TDA10046_XTAL_16M, | ||
425 | .if_freq = TDA10046_FREQ_045, | ||
426 | .agc_config = TDA10046_AGC_TDA827X, | ||
427 | .gpio_config = TDA10046_GPTRI, | ||
428 | .request_firmware = NULL, | ||
429 | }; | ||
430 | |||
431 | static int digivox_tda10046_frontend_attach(struct dvb_usb_adapter *adap) | ||
432 | { | 455 | { |
433 | deb_rc("digivox_tda10046_frontend_attach!\n"); | 456 | deb("%s\n",__FUNCTION__); |
434 | 457 | ||
435 | if ((adap->fe = dvb_attach(tda10046_attach, &digivox_tda10046_config, | 458 | if ((adap->fe = dvb_attach(tda10046_attach, |
459 | &m920x_tda10046_0b_config, | ||
436 | &adap->dev->i2c_adap)) == NULL) | 460 | &adap->dev->i2c_adap)) == NULL) |
437 | return -EIO; | 461 | return -EIO; |
438 | 462 | ||
439 | return 0; | 463 | return 0; |
440 | } | 464 | } |
441 | 465 | ||
442 | static int digivox_tda8275_tuner_attach(struct dvb_usb_adapter *adap) | 466 | static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap) |
443 | { | 467 | { |
444 | if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, | 468 | deb("%s\n",__FUNCTION__); |
445 | NULL) == NULL) | 469 | |
470 | if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL) | ||
446 | return -ENODEV; | 471 | return -ENODEV; |
472 | |||
447 | return 0; | 473 | return 0; |
448 | } | 474 | } |
449 | 475 | ||
476 | static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap) | ||
477 | { | ||
478 | deb("%s\n",__FUNCTION__); | ||
479 | |||
480 | if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL) | ||
481 | return -ENODEV; | ||
482 | |||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap) | ||
487 | { | ||
488 | deb("%s\n",__FUNCTION__); | ||
489 | |||
490 | if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL) | ||
491 | return -ENODEV; | ||
492 | |||
493 | return 0; | ||
494 | } | ||
495 | |||
496 | /* device-specific initialization */ | ||
497 | static struct m920x_inits megasky_rc_init [] = { | ||
498 | { M9206_RC_INIT2, 0xa8 }, | ||
499 | { M9206_RC_INIT1, 0x51 }, | ||
500 | { } /* terminating entry */ | ||
501 | }; | ||
502 | |||
503 | static struct m920x_inits tvwalkertwin_rc_init [] = { | ||
504 | { M9206_RC_INIT2, 0x00 }, | ||
505 | { M9206_RC_INIT1, 0xef }, | ||
506 | { 0xff28, 0x00 }, | ||
507 | { 0xff23, 0x00 }, | ||
508 | { 0xff21, 0x30 }, | ||
509 | { } /* terminating entry */ | ||
510 | }; | ||
511 | |||
512 | /* ir keymaps */ | ||
513 | static struct dvb_usb_rc_key megasky_rc_keys [] = { | ||
514 | { 0x0, 0x12, KEY_POWER }, | ||
515 | { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */ | ||
516 | { 0x0, 0x02, KEY_CHANNELUP }, | ||
517 | { 0x0, 0x05, KEY_CHANNELDOWN }, | ||
518 | { 0x0, 0x03, KEY_VOLUMEUP }, | ||
519 | { 0x0, 0x06, KEY_VOLUMEDOWN }, | ||
520 | { 0x0, 0x04, KEY_MUTE }, | ||
521 | { 0x0, 0x07, KEY_OK }, /* TS */ | ||
522 | { 0x0, 0x08, KEY_STOP }, | ||
523 | { 0x0, 0x09, KEY_MENU }, /* swap */ | ||
524 | { 0x0, 0x0a, KEY_REWIND }, | ||
525 | { 0x0, 0x1b, KEY_PAUSE }, | ||
526 | { 0x0, 0x1f, KEY_FASTFORWARD }, | ||
527 | { 0x0, 0x0c, KEY_RECORD }, | ||
528 | { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */ | ||
529 | { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */ | ||
530 | }; | ||
531 | |||
532 | static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = { | ||
533 | { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */ | ||
534 | { 0x0, 0x02, KEY_CAMERA }, /* snapshot */ | ||
535 | { 0x0, 0x03, KEY_MUTE }, | ||
536 | { 0x0, 0x04, KEY_REWIND }, | ||
537 | { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */ | ||
538 | { 0x0, 0x06, KEY_FASTFORWARD }, | ||
539 | { 0x0, 0x07, KEY_RECORD }, | ||
540 | { 0x0, 0x08, KEY_STOP }, | ||
541 | { 0x0, 0x09, KEY_TIME }, /* Timeshift */ | ||
542 | { 0x0, 0x0c, KEY_COFFEE }, /* Recall */ | ||
543 | { 0x0, 0x0e, KEY_CHANNELUP }, | ||
544 | { 0x0, 0x12, KEY_POWER }, | ||
545 | { 0x0, 0x15, KEY_MENU }, /* source */ | ||
546 | { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */ | ||
547 | { 0x0, 0x1a, KEY_CHANNELDOWN }, | ||
548 | { 0x0, 0x1b, KEY_VOLUMEDOWN }, | ||
549 | { 0x0, 0x1e, KEY_VOLUMEUP }, | ||
550 | }; | ||
551 | |||
450 | /* DVB USB Driver stuff */ | 552 | /* DVB USB Driver stuff */ |
451 | static struct dvb_usb_device_properties megasky_properties; | 553 | static struct dvb_usb_device_properties megasky_properties; |
452 | static struct dvb_usb_device_properties digivox_mini_ii_properties; | 554 | static struct dvb_usb_device_properties digivox_mini_ii_properties; |
555 | static struct dvb_usb_device_properties tvwalkertwin_properties; | ||
556 | static struct dvb_usb_device_properties dposh_properties; | ||
453 | 557 | ||
454 | static int m920x_probe(struct usb_interface *intf, | 558 | static int m920x_probe(struct usb_interface *intf, |
455 | const struct usb_device_id *id) | 559 | const struct usb_device_id *id) |
@@ -457,19 +561,57 @@ static int m920x_probe(struct usb_interface *intf, | |||
457 | struct dvb_usb_device *d; | 561 | struct dvb_usb_device *d; |
458 | struct usb_host_interface *alt; | 562 | struct usb_host_interface *alt; |
459 | int ret; | 563 | int ret; |
564 | struct m920x_inits *rc_init_seq = NULL; | ||
565 | int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber; | ||
460 | 566 | ||
461 | deb_rc("Probed!\n"); | 567 | deb("Probing for m920x device at interface %d\n", bInterfaceNumber); |
462 | 568 | ||
463 | if (((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) || | 569 | if (bInterfaceNumber == 0) { |
464 | ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, THIS_MODULE, &d)) == 0)) | 570 | /* Single-tuner device, or first interface on |
465 | goto found; | 571 | * multi-tuner device |
572 | */ | ||
466 | 573 | ||
467 | return ret; | 574 | if ((ret = dvb_usb_device_init(intf, &megasky_properties, |
575 | THIS_MODULE, &d)) == 0) { | ||
576 | rc_init_seq = megasky_rc_init; | ||
577 | goto found; | ||
578 | } | ||
579 | |||
580 | if ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, | ||
581 | THIS_MODULE, &d)) == 0) { | ||
582 | /* No remote control, so no rc_init_seq */ | ||
583 | goto found; | ||
584 | } | ||
585 | |||
586 | /* This configures both tuners on the TV Walker Twin */ | ||
587 | if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties, | ||
588 | THIS_MODULE, &d)) == 0) { | ||
589 | rc_init_seq = tvwalkertwin_rc_init; | ||
590 | goto found; | ||
591 | } | ||
592 | |||
593 | if ((ret = dvb_usb_device_init(intf, &dposh_properties, | ||
594 | THIS_MODULE, &d)) == 0) { | ||
595 | /* Remote controller not supported yet. */ | ||
596 | goto found; | ||
597 | } | ||
598 | |||
599 | return ret; | ||
600 | } else { | ||
601 | /* Another interface on a multi-tuner device */ | ||
468 | 602 | ||
469 | found: | 603 | /* The LifeView TV Walker Twin gets here, but struct |
604 | * tvwalkertwin_properties already configured both | ||
605 | * tuners, so there is nothing for us to do here | ||
606 | */ | ||
607 | |||
608 | return -ENODEV; | ||
609 | } | ||
610 | |||
611 | found: | ||
470 | alt = usb_altnum_to_altsetting(intf, 1); | 612 | alt = usb_altnum_to_altsetting(intf, 1); |
471 | if (alt == NULL) { | 613 | if (alt == NULL) { |
472 | deb_rc("No alt found!\n"); | 614 | deb("No alt found!\n"); |
473 | return -ENODEV; | 615 | return -ENODEV; |
474 | } | 616 | } |
475 | 617 | ||
@@ -478,7 +620,7 @@ found: | |||
478 | if (ret < 0) | 620 | if (ret < 0) |
479 | return ret; | 621 | return ret; |
480 | 622 | ||
481 | if ((ret = m9206_init(d)) != 0) | 623 | if ((ret = m920x_init(d, rc_init_seq)) != 0) |
482 | return ret; | 624 | return ret; |
483 | 625 | ||
484 | return ret; | 626 | return ret; |
@@ -488,6 +630,12 @@ static struct usb_device_id m920x_table [] = { | |||
488 | { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, | 630 | { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, |
489 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, | 631 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, |
490 | USB_PID_MSI_DIGI_VOX_MINI_II) }, | 632 | USB_PID_MSI_DIGI_VOX_MINI_II) }, |
633 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, | ||
634 | USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) }, | ||
635 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, | ||
636 | USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) }, | ||
637 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) }, | ||
638 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) }, | ||
491 | { } /* Terminating entry */ | 639 | { } /* Terminating entry */ |
492 | }; | 640 | }; |
493 | MODULE_DEVICE_TABLE (usb, m920x_table); | 641 | MODULE_DEVICE_TABLE (usb, m920x_table); |
@@ -497,14 +645,14 @@ static struct dvb_usb_device_properties megasky_properties = { | |||
497 | 645 | ||
498 | .usb_ctrl = DEVICE_SPECIFIC, | 646 | .usb_ctrl = DEVICE_SPECIFIC, |
499 | .firmware = "dvb-usb-megasky-02.fw", | 647 | .firmware = "dvb-usb-megasky-02.fw", |
500 | .download_firmware = m9206_firmware_download, | 648 | .download_firmware = m920x_firmware_download, |
501 | 649 | ||
502 | .rc_interval = 100, | 650 | .rc_interval = 100, |
503 | .rc_key_map = megasky_rc_keys, | 651 | .rc_key_map = megasky_rc_keys, |
504 | .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys), | 652 | .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys), |
505 | .rc_query = m9206_rc_query, | 653 | .rc_query = m920x_rc_query, |
506 | 654 | ||
507 | .size_of_priv = sizeof(struct m9206_state), | 655 | .size_of_priv = sizeof(struct m920x_state), |
508 | 656 | ||
509 | .identify_state = m920x_identify_state, | 657 | .identify_state = m920x_identify_state, |
510 | .num_adapters = 1, | 658 | .num_adapters = 1, |
@@ -513,11 +661,11 @@ static struct dvb_usb_device_properties megasky_properties = { | |||
513 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | 661 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
514 | 662 | ||
515 | .pid_filter_count = 8, | 663 | .pid_filter_count = 8, |
516 | .pid_filter = m9206_pid_filter, | 664 | .pid_filter = m920x_pid_filter, |
517 | .pid_filter_ctrl = m9206_pid_filter_ctrl, | 665 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
518 | 666 | ||
519 | .frontend_attach = megasky_mt352_frontend_attach, | 667 | .frontend_attach = m920x_mt352_frontend_attach, |
520 | .tuner_attach = megasky_qt1010_tuner_attach, | 668 | .tuner_attach = m920x_qt1010_tuner_attach, |
521 | 669 | ||
522 | .stream = { | 670 | .stream = { |
523 | .type = USB_BULK, | 671 | .type = USB_BULK, |
@@ -530,7 +678,7 @@ static struct dvb_usb_device_properties megasky_properties = { | |||
530 | } | 678 | } |
531 | }, | 679 | }, |
532 | }}, | 680 | }}, |
533 | .i2c_algo = &m9206_i2c_algo, | 681 | .i2c_algo = &m920x_i2c_algo, |
534 | 682 | ||
535 | .num_device_descs = 1, | 683 | .num_device_descs = 1, |
536 | .devices = { | 684 | .devices = { |
@@ -546,22 +694,22 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = { | |||
546 | 694 | ||
547 | .usb_ctrl = DEVICE_SPECIFIC, | 695 | .usb_ctrl = DEVICE_SPECIFIC, |
548 | .firmware = "dvb-usb-digivox-02.fw", | 696 | .firmware = "dvb-usb-digivox-02.fw", |
549 | .download_firmware = m9206_firmware_download, | 697 | .download_firmware = m920x_firmware_download, |
550 | 698 | ||
551 | .size_of_priv = sizeof(struct m9206_state), | 699 | .size_of_priv = sizeof(struct m920x_state), |
552 | 700 | ||
553 | .identify_state = m920x_identify_state, | 701 | .identify_state = m920x_identify_state, |
554 | .num_adapters = 1, | 702 | .num_adapters = 1, |
555 | .adapter = {{ | 703 | .adapter = {{ |
556 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | 704 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
557 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | 705 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
558 | 706 | ||
559 | .pid_filter_count = 8, | 707 | .pid_filter_count = 8, |
560 | .pid_filter = m9206_pid_filter, | 708 | .pid_filter = m920x_pid_filter, |
561 | .pid_filter_ctrl = m9206_pid_filter_ctrl, | 709 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
562 | 710 | ||
563 | .frontend_attach = digivox_tda10046_frontend_attach, | 711 | .frontend_attach = m920x_tda10046_08_frontend_attach, |
564 | .tuner_attach = digivox_tda8275_tuner_attach, | 712 | .tuner_attach = m920x_tda8275_60_tuner_attach, |
565 | 713 | ||
566 | .stream = { | 714 | .stream = { |
567 | .type = USB_BULK, | 715 | .type = USB_BULK, |
@@ -574,7 +722,7 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = { | |||
574 | } | 722 | } |
575 | }, | 723 | }, |
576 | }}, | 724 | }}, |
577 | .i2c_algo = &m9206_i2c_algo, | 725 | .i2c_algo = &m920x_i2c_algo, |
578 | 726 | ||
579 | .num_device_descs = 1, | 727 | .num_device_descs = 1, |
580 | .devices = { | 728 | .devices = { |
@@ -585,6 +733,122 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = { | |||
585 | } | 733 | } |
586 | }; | 734 | }; |
587 | 735 | ||
736 | /* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net> | ||
737 | * | ||
738 | * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A | ||
739 | * TDA10046 #0 is located at i2c address 0x08 | ||
740 | * TDA10046 #1 is located at i2c address 0x0b (presently disabled - not yet working) | ||
741 | * TDA8275A #0 is located at i2c address 0x60 | ||
742 | * TDA8275A #1 is located at i2c address 0x61 (presently disabled - not yet working) | ||
743 | */ | ||
744 | static struct dvb_usb_device_properties tvwalkertwin_properties = { | ||
745 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
746 | |||
747 | .usb_ctrl = DEVICE_SPECIFIC, | ||
748 | .firmware = "dvb-usb-tvwalkert.fw", | ||
749 | .download_firmware = m920x_firmware_download, | ||
750 | |||
751 | .rc_interval = 100, | ||
752 | .rc_key_map = tvwalkertwin_rc_keys, | ||
753 | .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys), | ||
754 | .rc_query = m920x_rc_query, | ||
755 | |||
756 | .size_of_priv = sizeof(struct m920x_state), | ||
757 | |||
758 | .identify_state = m920x_identify_state, | ||
759 | .num_adapters = 1, | ||
760 | .adapter = {{ | ||
761 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
762 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
763 | |||
764 | .pid_filter_count = 8, | ||
765 | .pid_filter = m920x_pid_filter, | ||
766 | .pid_filter_ctrl = m920x_pid_filter_ctrl, | ||
767 | |||
768 | .frontend_attach = m920x_tda10046_08_frontend_attach, | ||
769 | .tuner_attach = m920x_tda8275_60_tuner_attach, | ||
770 | |||
771 | .stream = { | ||
772 | .type = USB_BULK, | ||
773 | .count = 8, | ||
774 | .endpoint = 0x81, | ||
775 | .u = { | ||
776 | .bulk = { | ||
777 | .buffersize = 512, | ||
778 | } | ||
779 | } | ||
780 | }},{ | ||
781 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
782 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
783 | |||
784 | .pid_filter_count = 8, | ||
785 | .pid_filter = m920x_pid_filter, | ||
786 | .pid_filter_ctrl = m920x_pid_filter_ctrl, | ||
787 | |||
788 | .frontend_attach = m920x_tda10046_0b_frontend_attach, | ||
789 | .tuner_attach = m920x_tda8275_61_tuner_attach, | ||
790 | |||
791 | .stream = { | ||
792 | .type = USB_BULK, | ||
793 | .count = 8, | ||
794 | .endpoint = 0x82, | ||
795 | .u = { | ||
796 | .bulk = { | ||
797 | .buffersize = 512, | ||
798 | } | ||
799 | } | ||
800 | }, | ||
801 | }}, | ||
802 | .i2c_algo = &m920x_i2c_algo, | ||
803 | |||
804 | .num_device_descs = 1, | ||
805 | .devices = { | ||
806 | { .name = "LifeView TV Walker Twin DVB-T USB2.0", | ||
807 | .cold_ids = { &m920x_table[2], NULL }, | ||
808 | .warm_ids = { &m920x_table[3], NULL }, | ||
809 | }, | ||
810 | } | ||
811 | }; | ||
812 | |||
813 | static struct dvb_usb_device_properties dposh_properties = { | ||
814 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
815 | |||
816 | .usb_ctrl = DEVICE_SPECIFIC, | ||
817 | .firmware = "dvb-usb-dposh-01.fw", | ||
818 | .download_firmware = m920x_firmware_download, | ||
819 | |||
820 | .size_of_priv = sizeof(struct m920x_state), | ||
821 | |||
822 | .identify_state = m920x_identify_state, | ||
823 | .num_adapters = 1, | ||
824 | .adapter = {{ | ||
825 | /* Hardware pid filters don't work with this device/firmware */ | ||
826 | |||
827 | .frontend_attach = m920x_mt352_frontend_attach, | ||
828 | .tuner_attach = m920x_qt1010_tuner_attach, | ||
829 | |||
830 | .stream = { | ||
831 | .type = USB_BULK, | ||
832 | .count = 8, | ||
833 | .endpoint = 0x81, | ||
834 | .u = { | ||
835 | .bulk = { | ||
836 | .buffersize = 512, | ||
837 | } | ||
838 | } | ||
839 | }, | ||
840 | }}, | ||
841 | .i2c_algo = &m920x_i2c_algo, | ||
842 | |||
843 | .num_device_descs = 1, | ||
844 | .devices = { | ||
845 | { .name = "Dposh DVB-T USB2.0", | ||
846 | .cold_ids = { &m920x_table[4], NULL }, | ||
847 | .warm_ids = { &m920x_table[5], NULL }, | ||
848 | }, | ||
849 | } | ||
850 | }; | ||
851 | |||
588 | static struct usb_driver m920x_driver = { | 852 | static struct usb_driver m920x_driver = { |
589 | .name = "dvb_usb_m920x", | 853 | .name = "dvb_usb_m920x", |
590 | .probe = m920x_probe, | 854 | .probe = m920x_probe, |
@@ -615,6 +879,11 @@ module_init (m920x_module_init); | |||
615 | module_exit (m920x_module_exit); | 879 | module_exit (m920x_module_exit); |
616 | 880 | ||
617 | MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>"); | 881 | MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>"); |
618 | MODULE_DESCRIPTION("Driver MSI Mega Sky 580 DVB-T USB2.0 / Uli m920x"); | 882 | MODULE_DESCRIPTION("DVB Driver for ULI M920x"); |
619 | MODULE_VERSION("0.1"); | 883 | MODULE_VERSION("0.1"); |
620 | MODULE_LICENSE("GPL"); | 884 | MODULE_LICENSE("GPL"); |
885 | |||
886 | /* | ||
887 | * Local variables: | ||
888 | * c-basic-offset: 8 | ||
889 | */ | ||
diff --git a/drivers/media/dvb/dvb-usb/m920x.h b/drivers/media/dvb/dvb-usb/m920x.h index 7dd3db65c80e..2c8942d04222 100644 --- a/drivers/media/dvb/dvb-usb/m920x.h +++ b/drivers/media/dvb/dvb-usb/m920x.h | |||
@@ -4,7 +4,7 @@ | |||
4 | #define DVB_USB_LOG_PREFIX "m920x" | 4 | #define DVB_USB_LOG_PREFIX "m920x" |
5 | #include "dvb-usb.h" | 5 | #include "dvb-usb.h" |
6 | 6 | ||
7 | #define deb_rc(args...) dprintk(dvb_usb_m920x_debug,0x01,args) | 7 | #define deb(args...) dprintk(dvb_usb_m920x_debug,0x01,args) |
8 | 8 | ||
9 | #define M9206_CORE 0x22 | 9 | #define M9206_CORE 0x22 |
10 | #define M9206_RC_STATE 0xff51 | 10 | #define M9206_RC_STATE 0xff51 |
@@ -59,9 +59,18 @@ What any other bits might mean, or how to get the slave's ACK/NACK | |||
59 | response to a write, is unknown. | 59 | response to a write, is unknown. |
60 | */ | 60 | */ |
61 | 61 | ||
62 | struct m9206_state { | 62 | struct m920x_state { |
63 | u16 filters[M9206_MAX_FILTERS]; | 63 | u16 filters[M9206_MAX_FILTERS]; |
64 | int filtering_enabled; | 64 | int filtering_enabled; |
65 | int rep_count; | 65 | int rep_count; |
66 | }; | 66 | }; |
67 | |||
68 | /* Initialisation data for the m920x | ||
69 | */ | ||
70 | |||
71 | struct m920x_inits { | ||
72 | u16 address; | ||
73 | u8 data; | ||
74 | }; | ||
75 | |||
67 | #endif | 76 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c index 3ecb2e0ce80f..c3fdc7cd094e 100644 --- a/drivers/media/dvb/dvb-usb/vp702x-fe.c +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c | |||
@@ -204,8 +204,8 @@ static int vp702x_fe_get_frontend(struct dvb_frontend* fe, | |||
204 | static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, | 204 | static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, |
205 | struct dvb_diseqc_master_cmd *m) | 205 | struct dvb_diseqc_master_cmd *m) |
206 | { | 206 | { |
207 | //struct vp702x_fe_state *st = fe->demodulator_priv; | 207 | struct vp702x_fe_state *st = fe->demodulator_priv; |
208 | u8 cmd[8];//,ibuf[10]; | 208 | u8 cmd[8],ibuf[10]; |
209 | memset(cmd,0,8); | 209 | memset(cmd,0,8); |
210 | 210 | ||
211 | deb_fe("%s\n",__FUNCTION__); | 211 | deb_fe("%s\n",__FUNCTION__); |
@@ -218,12 +218,12 @@ static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, | |||
218 | memcpy(&cmd[3], m->msg, m->msg_len); | 218 | memcpy(&cmd[3], m->msg, m->msg_len); |
219 | cmd[7] = vp702x_chksum(cmd,0,7); | 219 | cmd[7] = vp702x_chksum(cmd,0,7); |
220 | 220 | ||
221 | // vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); | 221 | vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); |
222 | 222 | ||
223 | // if (ibuf[2] == 0 && ibuf[3] == 0) | 223 | if (ibuf[2] == 0 && ibuf[3] == 0) |
224 | // deb_fe("diseqc cmd failed.\n"); | 224 | deb_fe("diseqc cmd failed.\n"); |
225 | // else | 225 | else |
226 | // deb_fe("diseqc cmd succeeded.\n"); | 226 | deb_fe("diseqc cmd succeeded.\n"); |
227 | 227 | ||
228 | return 0; | 228 | return 0; |
229 | } | 229 | } |
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c index 058df5c10034..08a2599ed74a 100644 --- a/drivers/media/dvb/pluto2/pluto2.c +++ b/drivers/media/dvb/pluto2/pluto2.c | |||
@@ -293,12 +293,20 @@ static void pluto_dma_end(struct pluto *pluto, unsigned int nbpackets) | |||
293 | * but no packets have been transfered. | 293 | * but no packets have been transfered. |
294 | * [2] Sometimes (actually very often) NBPACKETS stays at zero | 294 | * [2] Sometimes (actually very often) NBPACKETS stays at zero |
295 | * although one packet has been transfered. | 295 | * although one packet has been transfered. |
296 | * [3] Sometimes (actually rarely), the card gets into an erroneous | ||
297 | * mode where it continuously generates interrupts, claiming it | ||
298 | * has recieved nbpackets>TS_DMA_PACKETS packets, but no packet | ||
299 | * has been transfered. Only a reset seems to solve this | ||
296 | */ | 300 | */ |
297 | if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) { | 301 | if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) { |
298 | unsigned int i = 0; | 302 | unsigned int i = 0; |
299 | while (pluto->dma_buf[i] == 0x47) | 303 | while (pluto->dma_buf[i] == 0x47) |
300 | i += 188; | 304 | i += 188; |
301 | nbpackets = i / 188; | 305 | nbpackets = i / 188; |
306 | if (i == 0) { | ||
307 | pluto_reset_ts(pluto, 1); | ||
308 | dev_printk(KERN_DEBUG, &pluto->pdev->dev, "resetting TS because of invalid packet counter\n"); | ||
309 | } | ||
302 | } | 310 | } |
303 | 311 | ||
304 | dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets); | 312 | dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets); |
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index 67becdd4db60..ef1108c0bf11 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c | |||
@@ -1246,6 +1246,9 @@ static void vpeirq(unsigned long data) | |||
1246 | if (!budget->feeding1 || (newdma == olddma)) | 1246 | if (!budget->feeding1 || (newdma == olddma)) |
1247 | return; | 1247 | return; |
1248 | 1248 | ||
1249 | /* Ensure streamed PCI data is synced to CPU */ | ||
1250 | pci_dma_sync_sg_for_cpu(budget->dev->pci, budget->pt.slist, budget->pt.nents, PCI_DMA_FROMDEVICE); | ||
1251 | |||
1249 | #if 0 | 1252 | #if 0 |
1250 | /* track rps1 activity */ | 1253 | /* track rps1 activity */ |
1251 | printk("vpeirq: %02x Event Counter 1 0x%04x\n", | 1254 | printk("vpeirq: %02x Event Counter 1 0x%04x\n", |
@@ -2679,8 +2682,8 @@ err_iobuf_vfree_6: | |||
2679 | err_pci_free_5: | 2682 | err_pci_free_5: |
2680 | pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus); | 2683 | pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus); |
2681 | err_saa71466_vfree_4: | 2684 | err_saa71466_vfree_4: |
2682 | if (!av7110->grabbing) | 2685 | if (av7110->grabbing) |
2683 | saa7146_pgtable_free(pdev, &av7110->pt); | 2686 | saa7146_vfree_destroy_pgtable(pdev, av7110->grabbing, &av7110->pt); |
2684 | err_i2c_del_3: | 2687 | err_i2c_del_3: |
2685 | i2c_del_adapter(&av7110->i2c_adap); | 2688 | i2c_del_adapter(&av7110->i2c_adap); |
2686 | err_dvb_unregister_adapter_2: | 2689 | err_dvb_unregister_adapter_2: |
@@ -2710,7 +2713,7 @@ static int __devexit av7110_detach(struct saa7146_dev* saa) | |||
2710 | SAA7146_ISR_CLEAR(saa, MASK_10); | 2713 | SAA7146_ISR_CLEAR(saa, MASK_10); |
2711 | msleep(50); | 2714 | msleep(50); |
2712 | tasklet_kill(&av7110->vpe_tasklet); | 2715 | tasklet_kill(&av7110->vpe_tasklet); |
2713 | saa7146_pgtable_free(saa->pci, &av7110->pt); | 2716 | saa7146_vfree_destroy_pgtable(saa->pci, av7110->grabbing, &av7110->pt); |
2714 | } | 2717 | } |
2715 | av7110_exit_v4l(av7110); | 2718 | av7110_exit_v4l(av7110); |
2716 | 2719 | ||
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 4ed4599ce816..9d42f88ebb0e 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c | |||
@@ -904,7 +904,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc | |||
904 | band = 1; | 904 | band = 1; |
905 | } else if (tuner_frequency < 200000000) { | 905 | } else if (tuner_frequency < 200000000) { |
906 | cp = 6; | 906 | cp = 6; |
907 | band = 2; | 907 | band = 1; |
908 | } else if (tuner_frequency < 290000000) { | 908 | } else if (tuner_frequency < 290000000) { |
909 | cp = 3; | 909 | cp = 3; |
910 | band = 2; | 910 | band = 2; |
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c index 6b97dc1e6b65..2557ac9620d0 100644 --- a/drivers/media/dvb/ttpci/budget-core.c +++ b/drivers/media/dvb/ttpci/budget-core.c | |||
@@ -195,6 +195,9 @@ static void vpeirq(unsigned long data) | |||
195 | u32 newdma = saa7146_read(budget->dev, PCI_VDP3); | 195 | u32 newdma = saa7146_read(budget->dev, PCI_VDP3); |
196 | u32 count; | 196 | u32 count; |
197 | 197 | ||
198 | /* Ensure streamed PCI data is synced to CPU */ | ||
199 | pci_dma_sync_sg_for_cpu(budget->dev->pci, budget->pt.slist, budget->pt.nents, PCI_DMA_FROMDEVICE); | ||
200 | |||
198 | /* nearest lower position divisible by 188 */ | 201 | /* nearest lower position divisible by 188 */ |
199 | newdma -= newdma % 188; | 202 | newdma -= newdma % 188; |
200 | 203 | ||
@@ -504,16 +507,16 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, | |||
504 | strcpy(budget->i2c_adap.name, budget->card->name); | 507 | strcpy(budget->i2c_adap.name, budget->card->name); |
505 | 508 | ||
506 | if (i2c_add_adapter(&budget->i2c_adap) < 0) { | 509 | if (i2c_add_adapter(&budget->i2c_adap) < 0) { |
507 | dvb_unregister_adapter(&budget->dvb_adapter); | 510 | ret = -ENOMEM; |
508 | return -ENOMEM; | 511 | goto err_dvb_unregister; |
509 | } | 512 | } |
510 | 513 | ||
511 | ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac); | 514 | ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac); |
512 | 515 | ||
513 | if (NULL == | 516 | budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt); |
514 | (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt))) { | 517 | if (NULL == budget->grabbing) { |
515 | ret = -ENOMEM; | 518 | ret = -ENOMEM; |
516 | goto err; | 519 | goto err_del_i2c; |
517 | } | 520 | } |
518 | 521 | ||
519 | saa7146_write(dev, PCI_BT_V1, 0x001c0000); | 522 | saa7146_write(dev, PCI_BT_V1, 0x001c0000); |
@@ -526,14 +529,16 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, | |||
526 | if (bi->type != BUDGET_FS_ACTIVY) | 529 | if (bi->type != BUDGET_FS_ACTIVY) |
527 | saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); | 530 | saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); |
528 | 531 | ||
529 | if (budget_register(budget) == 0) { | 532 | if (budget_register(budget) == 0) |
530 | return 0; | 533 | return 0; /* Everything OK */ |
531 | } | 534 | |
532 | err: | 535 | /* An error occurred, cleanup resources */ |
533 | i2c_del_adapter(&budget->i2c_adap); | 536 | saa7146_vfree_destroy_pgtable(dev->pci, budget->grabbing, &budget->pt); |
534 | 537 | ||
535 | vfree(budget->grabbing); | 538 | err_del_i2c: |
539 | i2c_del_adapter(&budget->i2c_adap); | ||
536 | 540 | ||
541 | err_dvb_unregister: | ||
537 | dvb_unregister_adapter(&budget->dvb_adapter); | 542 | dvb_unregister_adapter(&budget->dvb_adapter); |
538 | 543 | ||
539 | return ret; | 544 | return ret; |
@@ -555,15 +560,13 @@ int ttpci_budget_deinit(struct budget *budget) | |||
555 | 560 | ||
556 | budget_unregister(budget); | 561 | budget_unregister(budget); |
557 | 562 | ||
558 | i2c_del_adapter(&budget->i2c_adap); | ||
559 | |||
560 | dvb_unregister_adapter(&budget->dvb_adapter); | ||
561 | |||
562 | tasklet_kill(&budget->vpe_tasklet); | 563 | tasklet_kill(&budget->vpe_tasklet); |
563 | 564 | ||
564 | saa7146_pgtable_free(dev->pci, &budget->pt); | 565 | saa7146_vfree_destroy_pgtable(dev->pci, budget->grabbing, &budget->pt); |
565 | 566 | ||
566 | vfree(budget->grabbing); | 567 | i2c_del_adapter(&budget->i2c_adap); |
568 | |||
569 | dvb_unregister_adapter(&budget->dvb_adapter); | ||
567 | 570 | ||
568 | return 0; | 571 | return 0; |
569 | } | 572 | } |
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index af66a5d5ecd8..a6ac82a609d4 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -2,8 +2,14 @@ | |||
2 | # Multimedia Video device configuration | 2 | # Multimedia Video device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Radio Adapters" | 5 | menuconfig RADIO_ADAPTERS |
6 | bool "Radio Adapters" | ||
6 | depends on VIDEO_DEV | 7 | depends on VIDEO_DEV |
8 | default y | ||
9 | ---help--- | ||
10 | Say Y here to enable selecting AM/FM radio adapters. | ||
11 | |||
12 | if RADIO_ADAPTERS | ||
7 | 13 | ||
8 | config RADIO_CADET | 14 | config RADIO_CADET |
9 | tristate "ADS Cadet AM/FM Tuner" | 15 | tristate "ADS Cadet AM/FM Tuner" |
@@ -328,4 +334,5 @@ config USB_DSBR | |||
328 | 334 | ||
329 | To compile this driver as a module, choose M here: the | 335 | To compile this driver as a module, choose M here: the |
330 | module will be called dsbr100. | 336 | module will be called dsbr100. |
331 | endmenu | 337 | |
338 | endif # RADIO_ADAPTERS | ||
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 449df1bb00d3..3bd07f7e3774 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -33,6 +33,10 @@ | |||
33 | 33 | ||
34 | History: | 34 | History: |
35 | 35 | ||
36 | Version 0.42: | ||
37 | Converted dsbr100 to use video_ioctl2 | ||
38 | by Douglas Landgraf <dougsland@gmail.com> | ||
39 | |||
36 | Version 0.41-ac1: | 40 | Version 0.41-ac1: |
37 | Alan Cox: Some cleanups and fixes | 41 | Alan Cox: Some cleanups and fixes |
38 | 42 | ||
@@ -121,8 +125,6 @@ devices, that would be 76 and 91. */ | |||
121 | static int usb_dsbr100_probe(struct usb_interface *intf, | 125 | static int usb_dsbr100_probe(struct usb_interface *intf, |
122 | const struct usb_device_id *id); | 126 | const struct usb_device_id *id); |
123 | static void usb_dsbr100_disconnect(struct usb_interface *intf); | 127 | static void usb_dsbr100_disconnect(struct usb_interface *intf); |
124 | static int usb_dsbr100_ioctl(struct inode *inode, struct file *file, | ||
125 | unsigned int cmd, unsigned long arg); | ||
126 | static int usb_dsbr100_open(struct inode *inode, struct file *file); | 128 | static int usb_dsbr100_open(struct inode *inode, struct file *file); |
127 | static int usb_dsbr100_close(struct inode *inode, struct file *file); | 129 | static int usb_dsbr100_close(struct inode *inode, struct file *file); |
128 | 130 | ||
@@ -142,26 +144,6 @@ struct dsbr100_device { | |||
142 | }; | 144 | }; |
143 | 145 | ||
144 | 146 | ||
145 | /* File system interface */ | ||
146 | static const struct file_operations usb_dsbr100_fops = { | ||
147 | .owner = THIS_MODULE, | ||
148 | .open = usb_dsbr100_open, | ||
149 | .release = usb_dsbr100_close, | ||
150 | .ioctl = usb_dsbr100_ioctl, | ||
151 | .compat_ioctl = v4l_compat_ioctl32, | ||
152 | .llseek = no_llseek, | ||
153 | }; | ||
154 | |||
155 | /* V4L interface */ | ||
156 | static struct video_device dsbr100_videodev_template= | ||
157 | { | ||
158 | .owner = THIS_MODULE, | ||
159 | .name = "D-Link DSB-R 100", | ||
160 | .type = VID_TYPE_TUNER, | ||
161 | .fops = &usb_dsbr100_fops, | ||
162 | .release = video_device_release, | ||
163 | }; | ||
164 | |||
165 | static struct usb_device_id usb_dsbr100_device_table [] = { | 147 | static struct usb_device_id usb_dsbr100_device_table [] = { |
166 | { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) }, | 148 | { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) }, |
167 | { } /* Terminating entry */ | 149 | { } /* Terminating entry */ |
@@ -252,37 +234,6 @@ static void dsbr100_getstat(struct dsbr100_device *radio) | |||
252 | 234 | ||
253 | /* USB subsystem interface begins here */ | 235 | /* USB subsystem interface begins here */ |
254 | 236 | ||
255 | /* check if the device is present and register with v4l and | ||
256 | usb if it is */ | ||
257 | static int usb_dsbr100_probe(struct usb_interface *intf, | ||
258 | const struct usb_device_id *id) | ||
259 | { | ||
260 | struct dsbr100_device *radio; | ||
261 | |||
262 | if (!(radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL))) | ||
263 | return -ENOMEM; | ||
264 | if (!(radio->videodev = video_device_alloc())) { | ||
265 | kfree(radio); | ||
266 | return -ENOMEM; | ||
267 | } | ||
268 | memcpy(radio->videodev, &dsbr100_videodev_template, | ||
269 | sizeof(dsbr100_videodev_template)); | ||
270 | radio->removed = 0; | ||
271 | radio->users = 0; | ||
272 | radio->usbdev = interface_to_usbdev(intf); | ||
273 | radio->curfreq = FREQ_MIN*FREQ_MUL; | ||
274 | video_set_drvdata(radio->videodev, radio); | ||
275 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO, | ||
276 | radio_nr)) { | ||
277 | warn("Could not register video device"); | ||
278 | video_device_release(radio->videodev); | ||
279 | kfree(radio); | ||
280 | return -EIO; | ||
281 | } | ||
282 | usb_set_intfdata(intf, radio); | ||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | /* handle unplugging of the device, release data structures | 237 | /* handle unplugging of the device, release data structures |
287 | if nothing keeps us from doing it. If something is still | 238 | if nothing keeps us from doing it. If something is still |
288 | keeping us busy, the release callback of v4l will take care | 239 | keeping us busy, the release callback of v4l will take care |
@@ -307,133 +258,147 @@ static void usb_dsbr100_disconnect(struct usb_interface *intf) | |||
307 | } | 258 | } |
308 | 259 | ||
309 | 260 | ||
310 | /* Video for Linux interface */ | 261 | static int vidioc_querycap(struct file *file, void *priv, |
262 | struct v4l2_capability *v) | ||
263 | { | ||
264 | strlcpy(v->driver, "dsbr100", sizeof(v->driver)); | ||
265 | strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof(v->card)); | ||
266 | sprintf(v->bus_info, "ISA"); | ||
267 | v->version = RADIO_VERSION; | ||
268 | v->capabilities = V4L2_CAP_TUNER; | ||
269 | return 0; | ||
270 | } | ||
311 | 271 | ||
312 | static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file, | 272 | static int vidioc_g_tuner(struct file *file, void *priv, |
313 | unsigned int cmd, void *arg) | 273 | struct v4l2_tuner *v) |
314 | { | 274 | { |
315 | struct dsbr100_device *radio=video_get_drvdata(video_devdata(file)); | 275 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); |
276 | |||
277 | if (v->index > 0) | ||
278 | return -EINVAL; | ||
279 | |||
280 | dsbr100_getstat(radio); | ||
281 | strcpy(v->name, "FM"); | ||
282 | v->type = V4L2_TUNER_RADIO; | ||
283 | v->rangelow = FREQ_MIN*FREQ_MUL; | ||
284 | v->rangehigh = FREQ_MAX*FREQ_MUL; | ||
285 | v->rxsubchans = V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; | ||
286 | v->capability = V4L2_TUNER_CAP_LOW; | ||
287 | if(radio->stereo) | ||
288 | v->audmode = V4L2_TUNER_MODE_STEREO; | ||
289 | else | ||
290 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
291 | v->signal = 0xffff; /* We can't get the signal strength */ | ||
292 | return 0; | ||
293 | } | ||
316 | 294 | ||
317 | if (!radio) | 295 | static int vidioc_s_tuner(struct file *file, void *priv, |
318 | return -EIO; | 296 | struct v4l2_tuner *v) |
297 | { | ||
298 | if (v->index > 0) | ||
299 | return -EINVAL; | ||
319 | 300 | ||
320 | switch(cmd) { | 301 | return 0; |
321 | case VIDIOC_QUERYCAP: | 302 | } |
322 | { | ||
323 | struct v4l2_capability *v = arg; | ||
324 | memset(v,0,sizeof(*v)); | ||
325 | strlcpy(v->driver, "dsbr100", sizeof (v->driver)); | ||
326 | strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof (v->card)); | ||
327 | sprintf(v->bus_info,"ISA"); | ||
328 | v->version = RADIO_VERSION; | ||
329 | v->capabilities = V4L2_CAP_TUNER; | ||
330 | 303 | ||
331 | return 0; | 304 | static int vidioc_s_frequency(struct file *file, void *priv, |
332 | } | 305 | struct v4l2_frequency *f) |
333 | case VIDIOC_G_TUNER: | 306 | { |
334 | { | 307 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); |
335 | struct v4l2_tuner *v = arg; | ||
336 | 308 | ||
337 | if (v->index > 0) | 309 | radio->curfreq = f->frequency; |
338 | return -EINVAL; | 310 | if (dsbr100_setfreq(radio, radio->curfreq)==-1) |
311 | warn("Set frequency failed"); | ||
312 | return 0; | ||
313 | } | ||
339 | 314 | ||
340 | dsbr100_getstat(radio); | 315 | static int vidioc_g_frequency(struct file *file, void *priv, |
316 | struct v4l2_frequency *f) | ||
317 | { | ||
318 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); | ||
341 | 319 | ||
342 | memset(v,0,sizeof(*v)); | 320 | f->type = V4L2_TUNER_RADIO; |
343 | strcpy(v->name, "FM"); | 321 | f->frequency = radio->curfreq; |
344 | v->type = V4L2_TUNER_RADIO; | 322 | return 0; |
323 | } | ||
345 | 324 | ||
346 | v->rangelow = FREQ_MIN*FREQ_MUL; | 325 | static int vidioc_queryctrl(struct file *file, void *priv, |
347 | v->rangehigh = FREQ_MAX*FREQ_MUL; | 326 | struct v4l2_queryctrl *qc) |
348 | v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; | 327 | { |
349 | v->capability=V4L2_TUNER_CAP_LOW; | 328 | int i; |
350 | if(radio->stereo) | ||
351 | v->audmode = V4L2_TUNER_MODE_STEREO; | ||
352 | else | ||
353 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
354 | v->signal = 0xFFFF; /* We can't get the signal strength */ | ||
355 | 329 | ||
330 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | ||
331 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
332 | memcpy(qc, &(radio_qctrl[i]), | ||
333 | sizeof(*qc)); | ||
356 | return 0; | 334 | return 0; |
357 | } | 335 | } |
358 | case VIDIOC_S_TUNER: | 336 | } |
359 | { | 337 | return -EINVAL; |
360 | struct v4l2_tuner *v = arg; | 338 | } |
361 | |||
362 | if (v->index > 0) | ||
363 | return -EINVAL; | ||
364 | 339 | ||
365 | return 0; | 340 | static int vidioc_g_ctrl(struct file *file, void *priv, |
366 | } | 341 | struct v4l2_control *ctrl) |
367 | case VIDIOC_S_FREQUENCY: | 342 | { |
368 | { | 343 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); |
369 | struct v4l2_frequency *f = arg; | ||
370 | 344 | ||
371 | radio->curfreq = f->frequency; | 345 | switch (ctrl->id) { |
372 | if (dsbr100_setfreq(radio, radio->curfreq)==-1) | 346 | case V4L2_CID_AUDIO_MUTE: |
373 | warn("Set frequency failed"); | 347 | ctrl->value = radio->muted; |
374 | return 0; | 348 | return 0; |
375 | } | 349 | } |
376 | case VIDIOC_G_FREQUENCY: | 350 | return -EINVAL; |
377 | { | 351 | } |
378 | struct v4l2_frequency *f = arg; | ||
379 | 352 | ||
380 | f->type = V4L2_TUNER_RADIO; | 353 | static int vidioc_s_ctrl(struct file *file, void *priv, |
381 | f->frequency = radio->curfreq; | 354 | struct v4l2_control *ctrl) |
355 | { | ||
356 | struct dsbr100_device *radio = video_get_drvdata(video_devdata(file)); | ||
382 | 357 | ||
383 | return 0; | 358 | switch (ctrl->id) { |
384 | } | 359 | case V4L2_CID_AUDIO_MUTE: |
385 | case VIDIOC_QUERYCTRL: | 360 | if (ctrl->value) { |
386 | { | 361 | if (dsbr100_stop(radio)==-1) |
387 | struct v4l2_queryctrl *qc = arg; | 362 | warn("Radio did not respond properly"); |
388 | int i; | 363 | } else { |
389 | 364 | if (dsbr100_start(radio)==-1) | |
390 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | 365 | warn("Radio did not respond properly"); |
391 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
392 | memcpy(qc, &(radio_qctrl[i]), | ||
393 | sizeof(*qc)); | ||
394 | return 0; | ||
395 | } | ||
396 | } | ||
397 | return -EINVAL; | ||
398 | } | ||
399 | case VIDIOC_G_CTRL: | ||
400 | { | ||
401 | struct v4l2_control *ctrl= arg; | ||
402 | |||
403 | switch (ctrl->id) { | ||
404 | case V4L2_CID_AUDIO_MUTE: | ||
405 | ctrl->value=radio->muted; | ||
406 | return 0; | ||
407 | } | ||
408 | return -EINVAL; | ||
409 | } | ||
410 | case VIDIOC_S_CTRL: | ||
411 | { | ||
412 | struct v4l2_control *ctrl= arg; | ||
413 | |||
414 | switch (ctrl->id) { | ||
415 | case V4L2_CID_AUDIO_MUTE: | ||
416 | if (ctrl->value) { | ||
417 | if (dsbr100_stop(radio)==-1) | ||
418 | warn("Radio did not respond properly"); | ||
419 | } else { | ||
420 | if (dsbr100_start(radio)==-1) | ||
421 | warn("Radio did not respond properly"); | ||
422 | } | ||
423 | return 0; | ||
424 | } | ||
425 | return -EINVAL; | ||
426 | } | 366 | } |
427 | default: | 367 | return 0; |
428 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, | ||
429 | usb_dsbr100_do_ioctl); | ||
430 | } | 368 | } |
369 | return -EINVAL; | ||
431 | } | 370 | } |
432 | 371 | ||
433 | static int usb_dsbr100_ioctl(struct inode *inode, struct file *file, | 372 | static int vidioc_g_audio(struct file *file, void *priv, |
434 | unsigned int cmd, unsigned long arg) | 373 | struct v4l2_audio *a) |
435 | { | 374 | { |
436 | return video_usercopy(inode, file, cmd, arg, usb_dsbr100_do_ioctl); | 375 | if (a->index > 1) |
376 | return -EINVAL; | ||
377 | |||
378 | strcpy(a->name, "Radio"); | ||
379 | a->capability = V4L2_AUDCAP_STEREO; | ||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) | ||
384 | { | ||
385 | *i = 0; | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | ||
390 | { | ||
391 | if (i != 0) | ||
392 | return -EINVAL; | ||
393 | return 0; | ||
394 | } | ||
395 | |||
396 | static int vidioc_s_audio(struct file *file, void *priv, | ||
397 | struct v4l2_audio *a) | ||
398 | { | ||
399 | if (a->index != 0) | ||
400 | return -EINVAL; | ||
401 | return 0; | ||
437 | } | 402 | } |
438 | 403 | ||
439 | static int usb_dsbr100_open(struct inode *inode, struct file *file) | 404 | static int usb_dsbr100_open(struct inode *inode, struct file *file) |
@@ -465,6 +430,68 @@ static int usb_dsbr100_close(struct inode *inode, struct file *file) | |||
465 | return 0; | 430 | return 0; |
466 | } | 431 | } |
467 | 432 | ||
433 | /* File system interface */ | ||
434 | static const struct file_operations usb_dsbr100_fops = { | ||
435 | .owner = THIS_MODULE, | ||
436 | .open = usb_dsbr100_open, | ||
437 | .release = usb_dsbr100_close, | ||
438 | .ioctl = video_ioctl2, | ||
439 | .compat_ioctl = v4l_compat_ioctl32, | ||
440 | .llseek = no_llseek, | ||
441 | }; | ||
442 | |||
443 | /* V4L2 interface */ | ||
444 | static struct video_device dsbr100_videodev_template = | ||
445 | { | ||
446 | .owner = THIS_MODULE, | ||
447 | .name = "D-Link DSB-R 100", | ||
448 | .type = VID_TYPE_TUNER, | ||
449 | .fops = &usb_dsbr100_fops, | ||
450 | .release = video_device_release, | ||
451 | .vidioc_querycap = vidioc_querycap, | ||
452 | .vidioc_g_tuner = vidioc_g_tuner, | ||
453 | .vidioc_s_tuner = vidioc_s_tuner, | ||
454 | .vidioc_g_frequency = vidioc_g_frequency, | ||
455 | .vidioc_s_frequency = vidioc_s_frequency, | ||
456 | .vidioc_queryctrl = vidioc_queryctrl, | ||
457 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
458 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
459 | .vidioc_g_audio = vidioc_g_audio, | ||
460 | .vidioc_s_audio = vidioc_s_audio, | ||
461 | .vidioc_g_input = vidioc_g_input, | ||
462 | .vidioc_s_input = vidioc_s_input, | ||
463 | }; | ||
464 | |||
465 | /* check if the device is present and register with v4l and | ||
466 | usb if it is */ | ||
467 | static int usb_dsbr100_probe(struct usb_interface *intf, | ||
468 | const struct usb_device_id *id) | ||
469 | { | ||
470 | struct dsbr100_device *radio; | ||
471 | |||
472 | if (!(radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL))) | ||
473 | return -ENOMEM; | ||
474 | if (!(radio->videodev = video_device_alloc())) { | ||
475 | kfree(radio); | ||
476 | return -ENOMEM; | ||
477 | } | ||
478 | memcpy(radio->videodev, &dsbr100_videodev_template, | ||
479 | sizeof(dsbr100_videodev_template)); | ||
480 | radio->removed = 0; | ||
481 | radio->users = 0; | ||
482 | radio->usbdev = interface_to_usbdev(intf); | ||
483 | radio->curfreq = FREQ_MIN*FREQ_MUL; | ||
484 | video_set_drvdata(radio->videodev, radio); | ||
485 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO,radio_nr)) { | ||
486 | warn("Could not register video device"); | ||
487 | video_device_release(radio->videodev); | ||
488 | kfree(radio); | ||
489 | return -EIO; | ||
490 | } | ||
491 | usb_set_intfdata(intf, radio); | ||
492 | return 0; | ||
493 | } | ||
494 | |||
468 | static int __init dsbr100_init(void) | 495 | static int __init dsbr100_init(void) |
469 | { | 496 | { |
470 | int retval = usb_register(&usb_dsbr100_driver); | 497 | int retval = usb_register(&usb_dsbr100_driver); |
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index 8fbf0d8bd278..8cf2e9df5c8a 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c | |||
@@ -48,6 +48,25 @@ | |||
48 | 48 | ||
49 | #define CADET_VERSION KERNEL_VERSION(0,3,3) | 49 | #define CADET_VERSION KERNEL_VERSION(0,3,3) |
50 | 50 | ||
51 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
52 | { | ||
53 | .id = V4L2_CID_AUDIO_MUTE, | ||
54 | .name = "Mute", | ||
55 | .minimum = 0, | ||
56 | .maximum = 1, | ||
57 | .default_value = 1, | ||
58 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
59 | },{ | ||
60 | .id = V4L2_CID_AUDIO_VOLUME, | ||
61 | .name = "Volume", | ||
62 | .minimum = 0, | ||
63 | .maximum = 0xff, | ||
64 | .step = 1, | ||
65 | .default_value = 0xff, | ||
66 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
67 | } | ||
68 | }; | ||
69 | |||
51 | static int io=-1; /* default to isapnp activation */ | 70 | static int io=-1; /* default to isapnp activation */ |
52 | static int radio_nr = -1; | 71 | static int radio_nr = -1; |
53 | static int users=0; | 72 | static int users=0; |
@@ -347,135 +366,165 @@ cadet_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | |||
347 | } | 366 | } |
348 | 367 | ||
349 | 368 | ||
369 | static int vidioc_querycap(struct file *file, void *priv, | ||
370 | struct v4l2_capability *v) | ||
371 | { | ||
372 | v->capabilities = | ||
373 | V4L2_CAP_TUNER | | ||
374 | V4L2_CAP_READWRITE; | ||
375 | v->version = CADET_VERSION; | ||
376 | strcpy(v->driver, "ADS Cadet"); | ||
377 | strcpy(v->card, "ADS Cadet"); | ||
378 | return 0; | ||
379 | } | ||
350 | 380 | ||
351 | static int cadet_do_ioctl(struct inode *inode, struct file *file, | 381 | static int vidioc_g_tuner(struct file *file, void *priv, |
352 | unsigned int cmd, void *arg) | 382 | struct v4l2_tuner *v) |
353 | { | 383 | { |
354 | switch(cmd) | 384 | v->type = V4L2_TUNER_RADIO; |
355 | { | 385 | switch (v->index) { |
356 | case VIDIOC_QUERYCAP: | 386 | case 0: |
357 | { | 387 | strcpy(v->name, "FM"); |
358 | struct v4l2_capability *cap = arg; | 388 | v->capability = V4L2_TUNER_CAP_STEREO; |
359 | memset(cap,0,sizeof(*cap)); | 389 | v->rangelow = 1400; /* 87.5 MHz */ |
360 | cap->capabilities = | 390 | v->rangehigh = 1728; /* 108.0 MHz */ |
361 | V4L2_CAP_TUNER | | 391 | v->rxsubchans=cadet_getstereo(); |
362 | V4L2_CAP_READWRITE; | 392 | switch (v->rxsubchans){ |
363 | cap->version = CADET_VERSION; | 393 | case V4L2_TUNER_SUB_MONO: |
364 | strcpy(cap->driver, "ADS Cadet"); | 394 | v->audmode = V4L2_TUNER_MODE_MONO; |
365 | strcpy(cap->card, "ADS Cadet"); | 395 | break; |
366 | return 0; | 396 | case V4L2_TUNER_SUB_STEREO: |
397 | v->audmode = V4L2_TUNER_MODE_STEREO; | ||
398 | break; | ||
399 | default: ; | ||
367 | } | 400 | } |
368 | case VIDIOC_G_TUNER: | 401 | break; |
369 | { | 402 | case 1: |
370 | struct v4l2_tuner *t = arg; | 403 | strcpy(v->name, "AM"); |
371 | memset(t,0,sizeof(*t)); | 404 | v->capability = V4L2_TUNER_CAP_LOW; |
372 | t->type = V4L2_TUNER_RADIO; | 405 | v->rangelow = 8320; /* 520 kHz */ |
373 | switch (t->index) | 406 | v->rangehigh = 26400; /* 1650 kHz */ |
374 | { | 407 | v->rxsubchans = V4L2_TUNER_SUB_MONO; |
375 | case 0: strcpy(t->name, "FM"); | 408 | v->audmode = V4L2_TUNER_MODE_MONO; |
376 | t->capability = V4L2_TUNER_CAP_STEREO; | 409 | break; |
377 | t->rangelow = 1400; /* 87.5 MHz */ | 410 | default: |
378 | t->rangehigh = 1728; /* 108.0 MHz */ | 411 | return -EINVAL; |
379 | t->rxsubchans=cadet_getstereo(); | 412 | } |
380 | switch (t->rxsubchans){ | 413 | v->signal = sigstrength; /* We might need to modify scaling of this */ |
381 | case V4L2_TUNER_SUB_MONO: | 414 | return 0; |
382 | t->audmode = V4L2_TUNER_MODE_MONO; | 415 | } |
383 | break; | ||
384 | case V4L2_TUNER_SUB_STEREO: | ||
385 | t->audmode = V4L2_TUNER_MODE_STEREO; | ||
386 | break; | ||
387 | default: ; | ||
388 | } | ||
389 | break; | ||
390 | case 1: strcpy(t->name, "AM"); | ||
391 | t->capability = V4L2_TUNER_CAP_LOW; | ||
392 | t->rangelow = 8320; /* 520 kHz */ | ||
393 | t->rangehigh = 26400; /* 1650 kHz */ | ||
394 | t->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
395 | t->audmode = V4L2_TUNER_MODE_MONO; | ||
396 | break; | ||
397 | default: | ||
398 | return -EINVAL; | ||
399 | } | ||
400 | 416 | ||
401 | t->signal = sigstrength; /* We might need to modify scaling of this */ | 417 | static int vidioc_s_tuner(struct file *file, void *priv, |
402 | return 0; | 418 | struct v4l2_tuner *v) |
403 | } | 419 | { |
404 | case VIDIOC_S_TUNER: | 420 | if((v->index != 0)&&(v->index != 1)) |
405 | { | 421 | return -EINVAL; |
406 | struct v4l2_tuner *t = arg; | 422 | curtuner = v->index; |
407 | if((t->index != 0)&&(t->index != 1)) | 423 | return 0; |
408 | return -EINVAL; | 424 | } |
409 | 425 | ||
410 | curtuner = t->index; | 426 | static int vidioc_g_frequency(struct file *file, void *priv, |
411 | return 0; | 427 | struct v4l2_frequency *f) |
412 | } | 428 | { |
413 | case VIDIOC_G_FREQUENCY: | 429 | f->tuner = curtuner; |
414 | { | 430 | f->type = V4L2_TUNER_RADIO; |
415 | struct v4l2_frequency *f = arg; | 431 | f->frequency = cadet_getfreq(); |
416 | memset(f,0,sizeof(*f)); | 432 | return 0; |
417 | f->tuner = curtuner; | 433 | } |
418 | f->type = V4L2_TUNER_RADIO; | 434 | |
419 | f->frequency = cadet_getfreq(); | 435 | |
420 | return 0; | 436 | static int vidioc_s_frequency(struct file *file, void *priv, |
421 | } | 437 | struct v4l2_frequency *f) |
422 | case VIDIOC_S_FREQUENCY: | 438 | { |
423 | { | 439 | if (f->type != V4L2_TUNER_RADIO) |
424 | struct v4l2_frequency *f = arg; | 440 | return -EINVAL; |
425 | if (f->type != V4L2_TUNER_RADIO){ | 441 | if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) |
426 | return -EINVAL; | 442 | return -EINVAL; |
427 | } | 443 | if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) |
428 | if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) { | 444 | return -EINVAL; |
429 | return -EINVAL; | 445 | cadet_setfreq(f->frequency); |
430 | } | 446 | return 0; |
431 | if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) { | 447 | } |
432 | return -EINVAL; | 448 | |
433 | } | 449 | static int vidioc_queryctrl(struct file *file, void *priv, |
434 | cadet_setfreq(f->frequency); | 450 | struct v4l2_queryctrl *qc) |
435 | return 0; | 451 | { |
436 | } | 452 | int i; |
437 | case VIDIOC_G_CTRL: | 453 | |
438 | { | 454 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
439 | struct v4l2_control *c = arg; | 455 | if (qc->id && qc->id == radio_qctrl[i].id) { |
440 | switch (c->id){ | 456 | memcpy(qc, &(radio_qctrl[i]), |
441 | case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ | 457 | sizeof(*qc)); |
442 | c->value = (cadet_getvol() == 0); | ||
443 | break; | ||
444 | case V4L2_CID_AUDIO_VOLUME: | ||
445 | c->value = cadet_getvol(); | ||
446 | break; | ||
447 | default: | ||
448 | return -EINVAL; | ||
449 | } | ||
450 | return 0; | ||
451 | } | ||
452 | case VIDIOC_S_CTRL: | ||
453 | { | ||
454 | struct v4l2_control *c = arg; | ||
455 | switch (c->id){ | ||
456 | case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ | ||
457 | if (c->value) cadet_setvol(0); | ||
458 | else cadet_setvol(0xffff); | ||
459 | break; | ||
460 | case V4L2_CID_AUDIO_VOLUME: | ||
461 | cadet_setvol(c->value); | ||
462 | break; | ||
463 | default: | ||
464 | return -EINVAL; | ||
465 | } | ||
466 | return 0; | 458 | return 0; |
467 | } | 459 | } |
460 | } | ||
461 | return -EINVAL; | ||
462 | } | ||
468 | 463 | ||
469 | default: | 464 | static int vidioc_g_ctrl(struct file *file, void *priv, |
470 | return -ENOIOCTLCMD; | 465 | struct v4l2_control *ctrl) |
466 | { | ||
467 | switch (ctrl->id){ | ||
468 | case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ | ||
469 | ctrl->value = (cadet_getvol() == 0); | ||
470 | break; | ||
471 | case V4L2_CID_AUDIO_VOLUME: | ||
472 | ctrl->value = cadet_getvol(); | ||
473 | break; | ||
474 | default: | ||
475 | return -EINVAL; | ||
471 | } | 476 | } |
477 | return 0; | ||
472 | } | 478 | } |
473 | 479 | ||
474 | static int | 480 | static int vidioc_s_ctrl(struct file *file, void *priv, |
475 | cadet_ioctl(struct inode *inode, struct file *file, | 481 | struct v4l2_control *ctrl) |
476 | unsigned int cmd, unsigned long arg) | ||
477 | { | 482 | { |
478 | return video_usercopy(inode, file, cmd, arg, cadet_do_ioctl); | 483 | switch (ctrl->id){ |
484 | case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ | ||
485 | if (ctrl->value) | ||
486 | cadet_setvol(0); | ||
487 | else | ||
488 | cadet_setvol(0xffff); | ||
489 | break; | ||
490 | case V4L2_CID_AUDIO_VOLUME: | ||
491 | cadet_setvol(ctrl->value); | ||
492 | break; | ||
493 | default: | ||
494 | return -EINVAL; | ||
495 | } | ||
496 | return 0; | ||
497 | } | ||
498 | |||
499 | static int vidioc_g_audio(struct file *file, void *priv, | ||
500 | struct v4l2_audio *a) | ||
501 | { | ||
502 | if (a->index > 1) | ||
503 | return -EINVAL; | ||
504 | strcpy(a->name, "Radio"); | ||
505 | a->capability = V4L2_AUDCAP_STEREO; | ||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) | ||
510 | { | ||
511 | *i = 0; | ||
512 | return 0; | ||
513 | } | ||
514 | |||
515 | static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | ||
516 | { | ||
517 | if (i != 0) | ||
518 | return -EINVAL; | ||
519 | return 0; | ||
520 | } | ||
521 | |||
522 | static int vidioc_s_audio(struct file *file, void *priv, | ||
523 | struct v4l2_audio *a) | ||
524 | { | ||
525 | if (a->index != 0) | ||
526 | return -EINVAL; | ||
527 | return 0; | ||
479 | } | 528 | } |
480 | 529 | ||
481 | static int | 530 | static int |
@@ -512,7 +561,7 @@ static const struct file_operations cadet_fops = { | |||
512 | .open = cadet_open, | 561 | .open = cadet_open, |
513 | .release = cadet_release, | 562 | .release = cadet_release, |
514 | .read = cadet_read, | 563 | .read = cadet_read, |
515 | .ioctl = cadet_ioctl, | 564 | .ioctl = video_ioctl2, |
516 | .poll = cadet_poll, | 565 | .poll = cadet_poll, |
517 | .compat_ioctl = v4l_compat_ioctl32, | 566 | .compat_ioctl = v4l_compat_ioctl32, |
518 | .llseek = no_llseek, | 567 | .llseek = no_llseek, |
@@ -524,6 +573,18 @@ static struct video_device cadet_radio= | |||
524 | .name = "Cadet radio", | 573 | .name = "Cadet radio", |
525 | .type = VID_TYPE_TUNER, | 574 | .type = VID_TYPE_TUNER, |
526 | .fops = &cadet_fops, | 575 | .fops = &cadet_fops, |
576 | .vidioc_querycap = vidioc_querycap, | ||
577 | .vidioc_g_tuner = vidioc_g_tuner, | ||
578 | .vidioc_s_tuner = vidioc_s_tuner, | ||
579 | .vidioc_g_frequency = vidioc_g_frequency, | ||
580 | .vidioc_s_frequency = vidioc_s_frequency, | ||
581 | .vidioc_queryctrl = vidioc_queryctrl, | ||
582 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
583 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
584 | .vidioc_g_audio = vidioc_g_audio, | ||
585 | .vidioc_s_audio = vidioc_s_audio, | ||
586 | .vidioc_g_input = vidioc_g_input, | ||
587 | .vidioc_s_input = vidioc_s_input, | ||
527 | }; | 588 | }; |
528 | 589 | ||
529 | static struct pnp_device_id cadet_pnp_devices[] = { | 590 | static struct pnp_device_id cadet_pnp_devices[] = { |
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c index 11f80cacd6ed..8e33a19a22a3 100644 --- a/drivers/media/radio/radio-maestro.c +++ b/drivers/media/radio/radio-maestro.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <asm/io.h> | 25 | #include <asm/io.h> |
26 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
27 | #include <linux/mutex.h> | ||
28 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
29 | #include <linux/videodev2.h> | 28 | #include <linux/videodev2.h> |
30 | #include <media/v4l2-common.h> | 29 | #include <media/v4l2-common.h> |
@@ -110,7 +109,6 @@ struct radio_device { | |||
110 | muted, /* VIDEO_AUDIO_MUTE */ | 109 | muted, /* VIDEO_AUDIO_MUTE */ |
111 | stereo, /* VIDEO_TUNER_STEREO_ON */ | 110 | stereo, /* VIDEO_TUNER_STEREO_ON */ |
112 | tuned; /* signal strength (0 or 0xffff) */ | 111 | tuned; /* signal strength (0 or 0xffff) */ |
113 | struct mutex lock; | ||
114 | }; | 112 | }; |
115 | 113 | ||
116 | static u32 radio_bits_get(struct radio_device *dev) | 114 | static u32 radio_bits_get(struct radio_device *dev) |
@@ -394,7 +392,6 @@ static int __devinit maestro_probe(struct pci_dev *pdev, | |||
394 | } | 392 | } |
395 | 393 | ||
396 | radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA; | 394 | radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA; |
397 | mutex_init(&radio_unit->lock); | ||
398 | 395 | ||
399 | maestro_radio_inst = video_device_alloc(); | 396 | maestro_radio_inst = video_device_alloc(); |
400 | if (maestro_radio_inst == NULL) { | 397 | if (maestro_radio_inst == NULL) { |
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c index a4715901512d..203f4373eeb8 100644 --- a/drivers/media/radio/radio-zoltrix.c +++ b/drivers/media/radio/radio-zoltrix.c | |||
@@ -410,7 +410,6 @@ static struct video_device zoltrix_radio = | |||
410 | .owner = THIS_MODULE, | 410 | .owner = THIS_MODULE, |
411 | .name = "Zoltrix Radio Plus", | 411 | .name = "Zoltrix Radio Plus", |
412 | .type = VID_TYPE_TUNER, | 412 | .type = VID_TYPE_TUNER, |
413 | .hardware = 0, | ||
414 | .fops = &zoltrix_fops, | 413 | .fops = &zoltrix_fops, |
415 | .vidioc_querycap = vidioc_querycap, | 414 | .vidioc_querycap = vidioc_querycap, |
416 | .vidioc_g_tuner = vidioc_g_tuner, | 415 | .vidioc_g_tuner = vidioc_g_tuner, |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index bc773781993a..5cb3f54b548b 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -2,14 +2,19 @@ | |||
2 | # Multimedia Video device configuration | 2 | # Multimedia Video device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Video Capture Adapters" | 5 | menuconfig VIDEO_CAPTURE_DRIVERS |
6 | bool "Video capture adapters" | ||
6 | depends on VIDEO_DEV | 7 | depends on VIDEO_DEV |
8 | default y | ||
9 | ---help--- | ||
10 | Say Y here to enable selecting the video adapters for | ||
11 | webcams, analog TV, and hybrid analog/digital TV. | ||
12 | Some of those devices also supports FM radio. | ||
7 | 13 | ||
8 | comment "Video Capture Adapters" | 14 | if VIDEO_CAPTURE_DRIVERS |
9 | 15 | ||
10 | config VIDEO_ADV_DEBUG | 16 | config VIDEO_ADV_DEBUG |
11 | bool "Enable advanced debug functionality" | 17 | bool "Enable advanced debug functionality" |
12 | depends on VIDEO_DEV | ||
13 | default n | 18 | default n |
14 | ---help--- | 19 | ---help--- |
15 | Say Y here to enable advanced debugging functionality on some | 20 | Say Y here to enable advanced debugging functionality on some |
@@ -34,7 +39,7 @@ config VIDEO_HELPER_CHIPS_AUTO | |||
34 | # | 39 | # |
35 | 40 | ||
36 | menu "Encoders/decoders and other helper chips" | 41 | menu "Encoders/decoders and other helper chips" |
37 | depends on VIDEO_DEV && !VIDEO_HELPER_CHIPS_AUTO | 42 | depends on !VIDEO_HELPER_CHIPS_AUTO |
38 | 43 | ||
39 | comment "Audio decoders" | 44 | comment "Audio decoders" |
40 | 45 | ||
@@ -61,7 +66,7 @@ config VIDEO_TDA7432 | |||
61 | 66 | ||
62 | config VIDEO_TDA9840 | 67 | config VIDEO_TDA9840 |
63 | tristate "Philips TDA9840 audio processor" | 68 | tristate "Philips TDA9840 audio processor" |
64 | depends on VIDEO_DEV && I2C | 69 | depends on I2C |
65 | ---help--- | 70 | ---help--- |
66 | Support for tda9840 audio decoder chip found on some Zoran boards. | 71 | Support for tda9840 audio decoder chip found on some Zoran boards. |
67 | 72 | ||
@@ -79,7 +84,7 @@ config VIDEO_TDA9875 | |||
79 | 84 | ||
80 | config VIDEO_TEA6415C | 85 | config VIDEO_TEA6415C |
81 | tristate "Philips TEA6415C audio processor" | 86 | tristate "Philips TEA6415C audio processor" |
82 | depends on VIDEO_DEV && I2C | 87 | depends on I2C |
83 | ---help--- | 88 | ---help--- |
84 | Support for tea6415c audio decoder chip found on some bt8xx boards. | 89 | Support for tea6415c audio decoder chip found on some bt8xx boards. |
85 | 90 | ||
@@ -88,7 +93,7 @@ config VIDEO_TEA6415C | |||
88 | 93 | ||
89 | config VIDEO_TEA6420 | 94 | config VIDEO_TEA6420 |
90 | tristate "Philips TEA6420 audio processor" | 95 | tristate "Philips TEA6420 audio processor" |
91 | depends on VIDEO_DEV && I2C | 96 | depends on I2C |
92 | ---help--- | 97 | ---help--- |
93 | Support for tea6420 audio decoder chip found on some bt8xx boards. | 98 | Support for tea6420 audio decoder chip found on some bt8xx boards. |
94 | 99 | ||
@@ -469,7 +474,7 @@ config VIDEO_SAA5246A | |||
469 | 474 | ||
470 | config VIDEO_SAA5249 | 475 | config VIDEO_SAA5249 |
471 | tristate "SAA5249 Teletext processor" | 476 | tristate "SAA5249 Teletext processor" |
472 | depends on VIDEO_DEV && I2C && VIDEO_V4L2 | 477 | depends on I2C && VIDEO_V4L2 |
473 | help | 478 | help |
474 | Support for I2C bus based teletext using the SAA5249 chip. At the | 479 | Support for I2C bus based teletext using the SAA5249 chip. At the |
475 | moment this is only useful on some European WinTV cards. | 480 | moment this is only useful on some European WinTV cards. |
@@ -479,7 +484,7 @@ config VIDEO_SAA5249 | |||
479 | 484 | ||
480 | config TUNER_3036 | 485 | config TUNER_3036 |
481 | tristate "SAB3036 tuner" | 486 | tristate "SAB3036 tuner" |
482 | depends on VIDEO_DEV && I2C && VIDEO_V4L1 | 487 | depends on I2C && VIDEO_V4L1 |
483 | help | 488 | help |
484 | Say Y here to include support for Philips SAB3036 compatible tuners. | 489 | Say Y here to include support for Philips SAB3036 compatible tuners. |
485 | If in doubt, say N. | 490 | If in doubt, say N. |
@@ -681,8 +686,12 @@ config VIDEO_CAFE_CCIC | |||
681 | # USB Multimedia device configuration | 686 | # USB Multimedia device configuration |
682 | # | 687 | # |
683 | 688 | ||
684 | menu "V4L USB devices" | 689 | menuconfig V4L_USB_DRIVERS |
685 | depends on USB && VIDEO_DEV | 690 | bool "V4L USB devices" |
691 | depends on USB | ||
692 | default y | ||
693 | |||
694 | if V4L_USB_DRIVERS | ||
686 | 695 | ||
687 | source "drivers/media/video/pvrusb2/Kconfig" | 696 | source "drivers/media/video/pvrusb2/Kconfig" |
688 | 697 | ||
@@ -707,7 +716,7 @@ config VIDEO_OVCAMCHIP | |||
707 | 716 | ||
708 | config USB_W9968CF | 717 | config USB_W9968CF |
709 | tristate "USB W996[87]CF JPEG Dual Mode Camera support" | 718 | tristate "USB W996[87]CF JPEG Dual Mode Camera support" |
710 | depends on USB && VIDEO_V4L1 && I2C | 719 | depends on VIDEO_V4L1 && I2C |
711 | select VIDEO_OVCAMCHIP | 720 | select VIDEO_OVCAMCHIP |
712 | ---help--- | 721 | ---help--- |
713 | Say Y here if you want support for cameras based on OV681 or | 722 | Say Y here if you want support for cameras based on OV681 or |
@@ -725,7 +734,7 @@ config USB_W9968CF | |||
725 | 734 | ||
726 | config USB_OV511 | 735 | config USB_OV511 |
727 | tristate "USB OV511 Camera support" | 736 | tristate "USB OV511 Camera support" |
728 | depends on USB && VIDEO_V4L1 | 737 | depends on VIDEO_V4L1 |
729 | ---help--- | 738 | ---help--- |
730 | Say Y here if you want to connect this type of camera to your | 739 | Say Y here if you want to connect this type of camera to your |
731 | computer's USB port. See <file:Documentation/video4linux/ov511.txt> | 740 | computer's USB port. See <file:Documentation/video4linux/ov511.txt> |
@@ -736,7 +745,7 @@ config USB_OV511 | |||
736 | 745 | ||
737 | config USB_SE401 | 746 | config USB_SE401 |
738 | tristate "USB SE401 Camera support" | 747 | tristate "USB SE401 Camera support" |
739 | depends on USB && VIDEO_V4L1 | 748 | depends on VIDEO_V4L1 |
740 | ---help--- | 749 | ---help--- |
741 | Say Y here if you want to connect this type of camera to your | 750 | Say Y here if you want to connect this type of camera to your |
742 | computer's USB port. See <file:Documentation/video4linux/se401.txt> | 751 | computer's USB port. See <file:Documentation/video4linux/se401.txt> |
@@ -749,7 +758,7 @@ source "drivers/media/video/sn9c102/Kconfig" | |||
749 | 758 | ||
750 | config USB_STV680 | 759 | config USB_STV680 |
751 | tristate "USB STV680 (Pencam) Camera support" | 760 | tristate "USB STV680 (Pencam) Camera support" |
752 | depends on USB && VIDEO_V4L1 | 761 | depends on VIDEO_V4L1 |
753 | ---help--- | 762 | ---help--- |
754 | Say Y here if you want to connect this type of camera to your | 763 | Say Y here if you want to connect this type of camera to your |
755 | computer's USB port. This includes the Pencam line of cameras. | 764 | computer's USB port. This includes the Pencam line of cameras. |
@@ -765,7 +774,7 @@ source "drivers/media/video/pwc/Kconfig" | |||
765 | 774 | ||
766 | config USB_ZR364XX | 775 | config USB_ZR364XX |
767 | tristate "USB ZR364XX Camera support" | 776 | tristate "USB ZR364XX Camera support" |
768 | depends on USB && VIDEO_V4L2 | 777 | depends on VIDEO_V4L2 |
769 | ---help--- | 778 | ---help--- |
770 | Say Y here if you want to connect this type of camera to your | 779 | Say Y here if you want to connect this type of camera to your |
771 | computer's USB port. | 780 | computer's USB port. |
@@ -775,6 +784,6 @@ config USB_ZR364XX | |||
775 | To compile this driver as a module, choose M here: the | 784 | To compile this driver as a module, choose M here: the |
776 | module will be called zr364xx. | 785 | module will be called zr364xx. |
777 | 786 | ||
778 | endmenu # V4L USB devices | 787 | endif # V4L_USB_DRIVERS |
779 | 788 | ||
780 | endmenu | 789 | endif # VIDEO_CAPTURE_DRIVERS |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 1757a588970f..67bda9f9a44b 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -555,7 +555,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) | |||
555 | { | 555 | { |
556 | struct v4l2_pix_format *pix; | 556 | struct v4l2_pix_format *pix; |
557 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; | 557 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; |
558 | int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_NTSC); | 558 | int is_50Hz = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60); |
559 | 559 | ||
560 | switch (fmt->type) { | 560 | switch (fmt->type) { |
561 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 561 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
@@ -567,7 +567,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) | |||
567 | Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4; | 567 | Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4; |
568 | Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4; | 568 | Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4; |
569 | 569 | ||
570 | Vlines = pix->height + (is_pal ? 4 : 7); | 570 | Vlines = pix->height + (is_50Hz ? 4 : 7); |
571 | 571 | ||
572 | if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) || | 572 | if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) || |
573 | (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { | 573 | (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { |
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index 2ebde2fdbcbe..543b05ebc0e7 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/dma-mapping.h> | 29 | #include <linux/dma-mapping.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/dma-mapping.h> | ||
31 | #include <asm/delay.h> | 32 | #include <asm/delay.h> |
32 | 33 | ||
33 | #include "cx88.h" | 34 | #include "cx88.h" |
@@ -612,7 +613,7 @@ struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board | |||
612 | } | 613 | } |
613 | 614 | ||
614 | /* Driver asked for hardware access. */ | 615 | /* Driver asked for hardware access. */ |
615 | int cx8802_request_acquire(struct cx8802_driver *drv) | 616 | static int cx8802_request_acquire(struct cx8802_driver *drv) |
616 | { | 617 | { |
617 | struct cx88_core *core = drv->core; | 618 | struct cx88_core *core = drv->core; |
618 | 619 | ||
@@ -632,7 +633,7 @@ int cx8802_request_acquire(struct cx8802_driver *drv) | |||
632 | } | 633 | } |
633 | 634 | ||
634 | /* Driver asked to release hardware. */ | 635 | /* Driver asked to release hardware. */ |
635 | int cx8802_request_release(struct cx8802_driver *drv) | 636 | static int cx8802_request_release(struct cx8802_driver *drv) |
636 | { | 637 | { |
637 | struct cx88_core *core = drv->core; | 638 | struct cx88_core *core = drv->core; |
638 | 639 | ||
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index b94ef8ab28c1..98fa35421bdd 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/dma-mapping.h> | 36 | #include <linux/dma-mapping.h> |
37 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
38 | #include <linux/kthread.h> | 38 | #include <linux/kthread.h> |
39 | #include <linux/dma-mapping.h> | ||
39 | #include <asm/div64.h> | 40 | #include <asm/div64.h> |
40 | 41 | ||
41 | #include "cx88.h" | 42 | #include "cx88.h" |
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c index 6068c9bf82cd..82bc3a28aa22 100644 --- a/drivers/media/video/cx88/cx88-vp3054-i2c.c +++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c | |||
@@ -111,10 +111,6 @@ static struct i2c_adapter vp3054_i2c_adap_template = { | |||
111 | .id = I2C_HW_B_CX2388x, | 111 | .id = I2C_HW_B_CX2388x, |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static struct i2c_client vp3054_i2c_client_template = { | ||
115 | .name = "VP-3054", | ||
116 | }; | ||
117 | |||
118 | int vp3054_i2c_probe(struct cx8802_dev *dev) | 114 | int vp3054_i2c_probe(struct cx8802_dev *dev) |
119 | { | 115 | { |
120 | struct cx88_core *core = dev->core; | 116 | struct cx88_core *core = dev->core; |
@@ -133,8 +129,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
133 | sizeof(vp3054_i2c->adap)); | 129 | sizeof(vp3054_i2c->adap)); |
134 | memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, | 130 | memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, |
135 | sizeof(vp3054_i2c->algo)); | 131 | sizeof(vp3054_i2c->algo)); |
136 | memcpy(&vp3054_i2c->client, &vp3054_i2c_client_template, | ||
137 | sizeof(vp3054_i2c->client)); | ||
138 | 132 | ||
139 | vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL; | 133 | vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL; |
140 | 134 | ||
@@ -144,7 +138,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
144 | vp3054_i2c->algo.data = dev; | 138 | vp3054_i2c->algo.data = dev; |
145 | i2c_set_adapdata(&vp3054_i2c->adap, dev); | 139 | i2c_set_adapdata(&vp3054_i2c->adap, dev); |
146 | vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; | 140 | vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; |
147 | vp3054_i2c->client.adapter = &vp3054_i2c->adap; | ||
148 | 141 | ||
149 | vp3054_bit_setscl(dev,1); | 142 | vp3054_bit_setscl(dev,1); |
150 | vp3054_bit_setsda(dev,1); | 143 | vp3054_bit_setsda(dev,1); |
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.h b/drivers/media/video/cx88/cx88-vp3054-i2c.h index b7a0a04d2423..637a7d232238 100644 --- a/drivers/media/video/cx88/cx88-vp3054-i2c.h +++ b/drivers/media/video/cx88/cx88-vp3054-i2c.h | |||
@@ -26,7 +26,6 @@ | |||
26 | struct vp3054_i2c_state { | 26 | struct vp3054_i2c_state { |
27 | struct i2c_adapter adap; | 27 | struct i2c_adapter adap; |
28 | struct i2c_algo_bit_data algo; | 28 | struct i2c_algo_bit_data algo; |
29 | struct i2c_client client; | ||
30 | u32 state; | 29 | u32 state; |
31 | }; | 30 | }; |
32 | 31 | ||
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig index 9285a58e47aa..3823b62da4a4 100644 --- a/drivers/media/video/em28xx/Kconfig +++ b/drivers/media/video/em28xx/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config VIDEO_EM28XX | 1 | config VIDEO_EM28XX |
2 | tristate "Empia EM2800/2820/2840 USB video capture support" | 2 | tristate "Empia EM2800/2820/2840 USB video capture support" |
3 | depends on VIDEO_V4L1 && USB && I2C | 3 | depends on VIDEO_V4L1 && I2C |
4 | select VIDEO_BUF | 4 | select VIDEO_BUF |
5 | select VIDEO_TUNER | 5 | select VIDEO_TUNER |
6 | select VIDEO_TVEEPROM | 6 | select VIDEO_TVEEPROM |
diff --git a/drivers/media/video/et61x251/Kconfig b/drivers/media/video/et61x251/Kconfig index c6bff705688d..664676f44068 100644 --- a/drivers/media/video/et61x251/Kconfig +++ b/drivers/media/video/et61x251/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USB_ET61X251 | 1 | config USB_ET61X251 |
2 | tristate "USB ET61X[12]51 PC Camera Controller support" | 2 | tristate "USB ET61X[12]51 PC Camera Controller support" |
3 | depends on USB && VIDEO_V4L1 | 3 | depends on VIDEO_V4L1 |
4 | ---help--- | 4 | ---help--- |
5 | Say Y here if you want support for cameras based on Etoms ET61X151 | 5 | Say Y here if you want support for cameras based on Etoms ET61X151 |
6 | or ET61X251 PC Camera Controllers. | 6 | or ET61X251 PC Camera Controllers. |
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index 45b9328a538f..e29f949adf57 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -74,7 +74,7 @@ int ivtv_first_minor = 0; | |||
74 | struct ivtv *ivtv_cards[IVTV_MAX_CARDS]; | 74 | struct ivtv *ivtv_cards[IVTV_MAX_CARDS]; |
75 | 75 | ||
76 | /* Protects ivtv_cards_active */ | 76 | /* Protects ivtv_cards_active */ |
77 | spinlock_t ivtv_cards_lock = SPIN_LOCK_UNLOCKED; | 77 | DEFINE_SPINLOCK(ivtv_cards_lock); |
78 | 78 | ||
79 | /* add your revision and whatnot here */ | 79 | /* add your revision and whatnot here */ |
80 | static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { | 80 | static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index 1637097ddec7..8976487a65f3 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -804,7 +804,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp) | |||
804 | struct ivtv_open_id *item; | 804 | struct ivtv_open_id *item; |
805 | struct ivtv *itv = NULL; | 805 | struct ivtv *itv = NULL; |
806 | struct ivtv_stream *s = NULL; | 806 | struct ivtv_stream *s = NULL; |
807 | int minor = MINOR(inode->i_rdev); | 807 | int minor = iminor(inode); |
808 | 808 | ||
809 | /* Find which card this open was on */ | 809 | /* Find which card this open was on */ |
810 | spin_lock(&ivtv_cards_lock); | 810 | spin_lock(&ivtv_cards_lock); |
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig index 5645c9318890..d0c2cd785430 100644 --- a/drivers/media/video/pvrusb2/Kconfig +++ b/drivers/media/video/pvrusb2/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config VIDEO_PVRUSB2 | 1 | config VIDEO_PVRUSB2 |
2 | tristate "Hauppauge WinTV-PVR USB2 support" | 2 | tristate "Hauppauge WinTV-PVR USB2 support" |
3 | depends on VIDEO_V4L2 && USB && I2C && EXPERIMENTAL | 3 | depends on VIDEO_V4L2 && I2C && EXPERIMENTAL |
4 | select FW_LOADER | 4 | select FW_LOADER |
5 | select VIDEO_TUNER | 5 | select VIDEO_TUNER |
6 | select VIDEO_TVEEPROM | 6 | select VIDEO_TVEEPROM |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c index 5669c8ca9ca3..20b614436d2c 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c +++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c | |||
@@ -391,22 +391,29 @@ static int pvr2_encoder_prep_config(struct pvr2_hdw *hdw) | |||
391 | int pvr2_encoder_configure(struct pvr2_hdw *hdw) | 391 | int pvr2_encoder_configure(struct pvr2_hdw *hdw) |
392 | { | 392 | { |
393 | int ret; | 393 | int ret; |
394 | int val; | ||
394 | pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure" | 395 | pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure" |
395 | " (cx2341x module)"); | 396 | " (cx2341x module)"); |
396 | hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING; | 397 | hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING; |
397 | hdw->enc_ctl_state.width = hdw->res_hor_val; | 398 | hdw->enc_ctl_state.width = hdw->res_hor_val; |
398 | hdw->enc_ctl_state.height = hdw->res_ver_val; | 399 | hdw->enc_ctl_state.height = hdw->res_ver_val; |
399 | hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur & | 400 | hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur & V4L2_STD_525_60) ? |
400 | (V4L2_STD_NTSC|V4L2_STD_PAL_M)) ? | ||
401 | 0 : 1); | 401 | 0 : 1); |
402 | 402 | ||
403 | ret = 0; | 403 | ret = 0; |
404 | 404 | ||
405 | ret |= pvr2_encoder_prep_config(hdw); | 405 | ret |= pvr2_encoder_prep_config(hdw); |
406 | 406 | ||
407 | /* saa7115: 0xf0 */ | ||
408 | val = 0xf0; | ||
409 | if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { | ||
410 | /* ivtv cx25840: 0x140 */ | ||
411 | val = 0x140; | ||
412 | } | ||
413 | |||
407 | if (!ret) ret = pvr2_encoder_vcmd( | 414 | if (!ret) ret = pvr2_encoder_vcmd( |
408 | hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, | 415 | hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, |
409 | 0xf0, 0xf0); | 416 | val, val); |
410 | 417 | ||
411 | /* setup firmware to notify us about some events (don't know why...) */ | 418 | /* setup firmware to notify us about some events (don't know why...) */ |
412 | if (!ret) ret = pvr2_encoder_vcmd( | 419 | if (!ret) ret = pvr2_encoder_vcmd( |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index acf651e01f94..1311891e7ee3 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -83,7 +83,7 @@ static struct pvr2_string_table pvr2_client_lists[] = { | |||
83 | }; | 83 | }; |
84 | 84 | ||
85 | static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; | 85 | static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; |
86 | static DECLARE_MUTEX(pvr2_unit_sem); | 86 | static DEFINE_MUTEX(pvr2_unit_mtx); |
87 | 87 | ||
88 | static int ctlchg = 0; | 88 | static int ctlchg = 0; |
89 | static int initusbreset = 1; | 89 | static int initusbreset = 1; |
@@ -2076,14 +2076,14 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
2076 | hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); | 2076 | hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); |
2077 | if (!hdw->ctl_read_urb) goto fail; | 2077 | if (!hdw->ctl_read_urb) goto fail; |
2078 | 2078 | ||
2079 | down(&pvr2_unit_sem); do { | 2079 | mutex_lock(&pvr2_unit_mtx); do { |
2080 | for (idx = 0; idx < PVR_NUM; idx++) { | 2080 | for (idx = 0; idx < PVR_NUM; idx++) { |
2081 | if (unit_pointers[idx]) continue; | 2081 | if (unit_pointers[idx]) continue; |
2082 | hdw->unit_number = idx; | 2082 | hdw->unit_number = idx; |
2083 | unit_pointers[idx] = hdw; | 2083 | unit_pointers[idx] = hdw; |
2084 | break; | 2084 | break; |
2085 | } | 2085 | } |
2086 | } while (0); up(&pvr2_unit_sem); | 2086 | } while (0); mutex_unlock(&pvr2_unit_mtx); |
2087 | 2087 | ||
2088 | cnt1 = 0; | 2088 | cnt1 = 0; |
2089 | cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); | 2089 | cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); |
@@ -2186,13 +2186,13 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw) | |||
2186 | } | 2186 | } |
2187 | pvr2_i2c_core_done(hdw); | 2187 | pvr2_i2c_core_done(hdw); |
2188 | pvr2_hdw_remove_usb_stuff(hdw); | 2188 | pvr2_hdw_remove_usb_stuff(hdw); |
2189 | down(&pvr2_unit_sem); do { | 2189 | mutex_lock(&pvr2_unit_mtx); do { |
2190 | if ((hdw->unit_number >= 0) && | 2190 | if ((hdw->unit_number >= 0) && |
2191 | (hdw->unit_number < PVR_NUM) && | 2191 | (hdw->unit_number < PVR_NUM) && |
2192 | (unit_pointers[hdw->unit_number] == hdw)) { | 2192 | (unit_pointers[hdw->unit_number] == hdw)) { |
2193 | unit_pointers[hdw->unit_number] = NULL; | 2193 | unit_pointers[hdw->unit_number] = NULL; |
2194 | } | 2194 | } |
2195 | } while (0); up(&pvr2_unit_sem); | 2195 | } while (0); mutex_unlock(&pvr2_unit_mtx); |
2196 | kfree(hdw->controls); | 2196 | kfree(hdw->controls); |
2197 | kfree(hdw->mpeg_ctrl_info); | 2197 | kfree(hdw->mpeg_ctrl_info); |
2198 | kfree(hdw->std_defs); | 2198 | kfree(hdw->std_defs); |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c index 58fc3c730fe1..6786d3c0c98b 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c +++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "pvrusb2-hdw-internal.h" | 23 | #include "pvrusb2-hdw-internal.h" |
24 | #include "pvrusb2-debug.h" | 24 | #include "pvrusb2-debug.h" |
25 | #include "pvrusb2-fx2-cmd.h" | 25 | #include "pvrusb2-fx2-cmd.h" |
26 | #include "pvrusb2.h" | ||
26 | 27 | ||
27 | #define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) | 28 | #define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) |
28 | 29 | ||
@@ -38,6 +39,10 @@ static unsigned int i2c_scan = 0; | |||
38 | module_param(i2c_scan, int, S_IRUGO|S_IWUSR); | 39 | module_param(i2c_scan, int, S_IRUGO|S_IWUSR); |
39 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); | 40 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); |
40 | 41 | ||
42 | static int ir_mode[PVR_NUM] = { [0 ... PVR_NUM-1] = 1 }; | ||
43 | module_param_array(ir_mode, int, NULL, 0444); | ||
44 | MODULE_PARM_DESC(ir_mode,"specify: 0=disable IR reception, 1=normal IR"); | ||
45 | |||
41 | static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp, | 46 | static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp, |
42 | unsigned int detail, | 47 | unsigned int detail, |
43 | char *buf,unsigned int maxlen); | 48 | char *buf,unsigned int maxlen); |
@@ -273,6 +278,15 @@ static int i2c_hack_wm8775(struct pvr2_hdw *hdw, | |||
273 | return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen); | 278 | return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen); |
274 | } | 279 | } |
275 | 280 | ||
281 | /* This is an entry point designed to always fail any attempt to perform a | ||
282 | transfer. We use this to cause certain I2C addresses to not be | ||
283 | probed. */ | ||
284 | static int i2c_black_hole(struct pvr2_hdw *hdw, | ||
285 | u8 i2c_addr,u8 *wdata,u16 wlen,u8 *rdata,u16 rlen) | ||
286 | { | ||
287 | return -EIO; | ||
288 | } | ||
289 | |||
276 | /* This is a special entry point that is entered if an I2C operation is | 290 | /* This is a special entry point that is entered if an I2C operation is |
277 | attempted to a cx25840 chip on model 24xxx hardware. This chip can | 291 | attempted to a cx25840 chip on model 24xxx hardware. This chip can |
278 | sometimes wedge itself. Worse still, when this happens msp3400 can | 292 | sometimes wedge itself. Worse still, when this happens msp3400 can |
@@ -994,10 +1008,17 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw) | |||
994 | } | 1008 | } |
995 | 1009 | ||
996 | /* However, deal with various special cases for 24xxx hardware. */ | 1010 | /* However, deal with various special cases for 24xxx hardware. */ |
1011 | if (ir_mode[hdw->unit_number] == 0) { | ||
1012 | printk(KERN_INFO "%s: IR disabled\n",hdw->name); | ||
1013 | hdw->i2c_func[0x18] = i2c_black_hole; | ||
1014 | } else if (ir_mode[hdw->unit_number] == 1) { | ||
1015 | if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { | ||
1016 | hdw->i2c_func[0x18] = i2c_24xxx_ir; | ||
1017 | } | ||
1018 | } | ||
997 | if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { | 1019 | if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { |
998 | hdw->i2c_func[0x1b] = i2c_hack_wm8775; | 1020 | hdw->i2c_func[0x1b] = i2c_hack_wm8775; |
999 | hdw->i2c_func[0x44] = i2c_hack_cx25840; | 1021 | hdw->i2c_func[0x44] = i2c_hack_cx25840; |
1000 | hdw->i2c_func[0x18] = i2c_24xxx_ir; | ||
1001 | } | 1022 | } |
1002 | 1023 | ||
1003 | // Configure the adapter and set up everything else related to it. | 1024 | // Configure the adapter and set up everything else related to it. |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c index a741c556a39a..7ab79baa1c8c 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c +++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c | |||
@@ -518,40 +518,32 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id) | |||
518 | } | 518 | } |
519 | sfp->item_last = cip; | 519 | sfp->item_last = cip; |
520 | 520 | ||
521 | cip->attr_name.attr.owner = THIS_MODULE; | ||
522 | cip->attr_name.attr.name = "name"; | 521 | cip->attr_name.attr.name = "name"; |
523 | cip->attr_name.attr.mode = S_IRUGO; | 522 | cip->attr_name.attr.mode = S_IRUGO; |
524 | cip->attr_name.show = fp->show_name; | 523 | cip->attr_name.show = fp->show_name; |
525 | 524 | ||
526 | cip->attr_type.attr.owner = THIS_MODULE; | ||
527 | cip->attr_type.attr.name = "type"; | 525 | cip->attr_type.attr.name = "type"; |
528 | cip->attr_type.attr.mode = S_IRUGO; | 526 | cip->attr_type.attr.mode = S_IRUGO; |
529 | cip->attr_type.show = fp->show_type; | 527 | cip->attr_type.show = fp->show_type; |
530 | 528 | ||
531 | cip->attr_min.attr.owner = THIS_MODULE; | ||
532 | cip->attr_min.attr.name = "min_val"; | 529 | cip->attr_min.attr.name = "min_val"; |
533 | cip->attr_min.attr.mode = S_IRUGO; | 530 | cip->attr_min.attr.mode = S_IRUGO; |
534 | cip->attr_min.show = fp->show_min; | 531 | cip->attr_min.show = fp->show_min; |
535 | 532 | ||
536 | cip->attr_max.attr.owner = THIS_MODULE; | ||
537 | cip->attr_max.attr.name = "max_val"; | 533 | cip->attr_max.attr.name = "max_val"; |
538 | cip->attr_max.attr.mode = S_IRUGO; | 534 | cip->attr_max.attr.mode = S_IRUGO; |
539 | cip->attr_max.show = fp->show_max; | 535 | cip->attr_max.show = fp->show_max; |
540 | 536 | ||
541 | cip->attr_val.attr.owner = THIS_MODULE; | ||
542 | cip->attr_val.attr.name = "cur_val"; | 537 | cip->attr_val.attr.name = "cur_val"; |
543 | cip->attr_val.attr.mode = S_IRUGO; | 538 | cip->attr_val.attr.mode = S_IRUGO; |
544 | 539 | ||
545 | cip->attr_custom.attr.owner = THIS_MODULE; | ||
546 | cip->attr_custom.attr.name = "custom_val"; | 540 | cip->attr_custom.attr.name = "custom_val"; |
547 | cip->attr_custom.attr.mode = S_IRUGO; | 541 | cip->attr_custom.attr.mode = S_IRUGO; |
548 | 542 | ||
549 | cip->attr_enum.attr.owner = THIS_MODULE; | ||
550 | cip->attr_enum.attr.name = "enum_val"; | 543 | cip->attr_enum.attr.name = "enum_val"; |
551 | cip->attr_enum.attr.mode = S_IRUGO; | 544 | cip->attr_enum.attr.mode = S_IRUGO; |
552 | cip->attr_enum.show = fp->show_enum; | 545 | cip->attr_enum.show = fp->show_enum; |
553 | 546 | ||
554 | cip->attr_bits.attr.owner = THIS_MODULE; | ||
555 | cip->attr_bits.attr.name = "bit_val"; | 547 | cip->attr_bits.attr.name = "bit_val"; |
556 | cip->attr_bits.attr.mode = S_IRUGO; | 548 | cip->attr_bits.attr.mode = S_IRUGO; |
557 | cip->attr_bits.show = fp->show_bits; | 549 | cip->attr_bits.show = fp->show_bits; |
@@ -616,12 +608,10 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp) | |||
616 | 608 | ||
617 | dip = kzalloc(sizeof(*dip),GFP_KERNEL); | 609 | dip = kzalloc(sizeof(*dip),GFP_KERNEL); |
618 | if (!dip) return; | 610 | if (!dip) return; |
619 | dip->attr_debugcmd.attr.owner = THIS_MODULE; | ||
620 | dip->attr_debugcmd.attr.name = "debugcmd"; | 611 | dip->attr_debugcmd.attr.name = "debugcmd"; |
621 | dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP; | 612 | dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP; |
622 | dip->attr_debugcmd.show = debugcmd_show; | 613 | dip->attr_debugcmd.show = debugcmd_show; |
623 | dip->attr_debugcmd.store = debugcmd_store; | 614 | dip->attr_debugcmd.store = debugcmd_store; |
624 | dip->attr_debuginfo.attr.owner = THIS_MODULE; | ||
625 | dip->attr_debuginfo.attr.name = "debuginfo"; | 615 | dip->attr_debuginfo.attr.name = "debuginfo"; |
626 | dip->attr_debuginfo.attr.mode = S_IRUGO; | 616 | dip->attr_debuginfo.attr.mode = S_IRUGO; |
627 | dip->attr_debuginfo.show = debuginfo_show; | 617 | dip->attr_debuginfo.show = debuginfo_show; |
@@ -811,7 +801,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
811 | return; | 801 | return; |
812 | } | 802 | } |
813 | 803 | ||
814 | sfp->attr_v4l_minor_number.attr.owner = THIS_MODULE; | ||
815 | sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; | 804 | sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; |
816 | sfp->attr_v4l_minor_number.attr.mode = S_IRUGO; | 805 | sfp->attr_v4l_minor_number.attr.mode = S_IRUGO; |
817 | sfp->attr_v4l_minor_number.show = v4l_minor_number_show; | 806 | sfp->attr_v4l_minor_number.show = v4l_minor_number_show; |
@@ -825,7 +814,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
825 | sfp->v4l_minor_number_created_ok = !0; | 814 | sfp->v4l_minor_number_created_ok = !0; |
826 | } | 815 | } |
827 | 816 | ||
828 | sfp->attr_v4l_radio_minor_number.attr.owner = THIS_MODULE; | ||
829 | sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number"; | 817 | sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number"; |
830 | sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO; | 818 | sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO; |
831 | sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show; | 819 | sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show; |
@@ -839,7 +827,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
839 | sfp->v4l_radio_minor_number_created_ok = !0; | 827 | sfp->v4l_radio_minor_number_created_ok = !0; |
840 | } | 828 | } |
841 | 829 | ||
842 | sfp->attr_unit_number.attr.owner = THIS_MODULE; | ||
843 | sfp->attr_unit_number.attr.name = "unit_number"; | 830 | sfp->attr_unit_number.attr.name = "unit_number"; |
844 | sfp->attr_unit_number.attr.mode = S_IRUGO; | 831 | sfp->attr_unit_number.attr.mode = S_IRUGO; |
845 | sfp->attr_unit_number.show = unit_number_show; | 832 | sfp->attr_unit_number.show = unit_number_show; |
@@ -852,7 +839,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
852 | sfp->unit_number_created_ok = !0; | 839 | sfp->unit_number_created_ok = !0; |
853 | } | 840 | } |
854 | 841 | ||
855 | sfp->attr_bus_info.attr.owner = THIS_MODULE; | ||
856 | sfp->attr_bus_info.attr.name = "bus_info_str"; | 842 | sfp->attr_bus_info.attr.name = "bus_info_str"; |
857 | sfp->attr_bus_info.attr.mode = S_IRUGO; | 843 | sfp->attr_bus_info.attr.mode = S_IRUGO; |
858 | sfp->attr_bus_info.show = bus_info_show; | 844 | sfp->attr_bus_info.show = bus_info_show; |
diff --git a/drivers/media/video/pwc/Kconfig b/drivers/media/video/pwc/Kconfig index 8fdf7101d3bf..7298cf2e1650 100644 --- a/drivers/media/video/pwc/Kconfig +++ b/drivers/media/video/pwc/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USB_PWC | 1 | config USB_PWC |
2 | tristate "USB Philips Cameras" | 2 | tristate "USB Philips Cameras" |
3 | depends on USB && VIDEO_V4L1 | 3 | depends on VIDEO_V4L1 |
4 | ---help--- | 4 | ---help--- |
5 | Say Y or M here if you want to use one of these Philips & OEM | 5 | Say Y or M here if you want to use one of these Philips & OEM |
6 | webcams: | 6 | webcams: |
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 4ea479baee74..50f15adfa7c8 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -1170,6 +1170,42 @@ struct saa7134_board saa7134_boards[] = { | |||
1170 | .amux = LINE2, | 1170 | .amux = LINE2, |
1171 | }, | 1171 | }, |
1172 | }, | 1172 | }, |
1173 | [SAA7134_BOARD_ECS_TVP3XP_4CB6] = { | ||
1174 | /* Barry Scott <barry.scott@onelan.co.uk> */ | ||
1175 | .name = "Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM)", | ||
1176 | .audio_clock = 0x187de7, | ||
1177 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
1178 | .radio_type = UNSET, | ||
1179 | .tuner_addr = ADDR_UNSET, | ||
1180 | .radio_addr = ADDR_UNSET, | ||
1181 | .inputs = {{ | ||
1182 | .name = name_tv, | ||
1183 | .vmux = 1, | ||
1184 | .amux = TV, | ||
1185 | .tv = 1, | ||
1186 | },{ | ||
1187 | .name = name_tv_mono, | ||
1188 | .vmux = 1, | ||
1189 | .amux = LINE2, | ||
1190 | .tv = 1, | ||
1191 | },{ | ||
1192 | .name = name_comp1, | ||
1193 | .vmux = 3, | ||
1194 | .amux = LINE1, | ||
1195 | },{ | ||
1196 | .name = name_svideo, | ||
1197 | .vmux = 8, | ||
1198 | .amux = LINE1, | ||
1199 | },{ | ||
1200 | .name = "CVid over SVid", | ||
1201 | .vmux = 0, | ||
1202 | .amux = LINE1, | ||
1203 | }}, | ||
1204 | .radio = { | ||
1205 | .name = name_radio, | ||
1206 | .amux = LINE2, | ||
1207 | }, | ||
1208 | }, | ||
1173 | [SAA7134_BOARD_AVACSSMARTTV] = { | 1209 | [SAA7134_BOARD_AVACSSMARTTV] = { |
1174 | /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */ | 1210 | /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */ |
1175 | .name = "AVACS SmartTV", | 1211 | .name = "AVACS SmartTV", |
@@ -2754,6 +2790,35 @@ struct saa7134_board saa7134_boards[] = { | |||
2754 | .amux = LINE1, | 2790 | .amux = LINE1, |
2755 | }, | 2791 | }, |
2756 | }, | 2792 | }, |
2793 | [SAA7134_BOARD_KWORLD_DVBT_210] = { | ||
2794 | .name = "KWorld DVB-T 210", | ||
2795 | .audio_clock = 0x00187de7, | ||
2796 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
2797 | .radio_type = UNSET, | ||
2798 | .tuner_addr = ADDR_UNSET, | ||
2799 | .radio_addr = ADDR_UNSET, | ||
2800 | .mpeg = SAA7134_MPEG_DVB, | ||
2801 | .gpiomask = 1 << 21, | ||
2802 | .inputs = {{ | ||
2803 | .name = name_tv, | ||
2804 | .vmux = 1, | ||
2805 | .amux = TV, | ||
2806 | .tv = 1, | ||
2807 | },{ | ||
2808 | .name = name_comp1, | ||
2809 | .vmux = 3, | ||
2810 | .amux = LINE1, | ||
2811 | },{ | ||
2812 | .name = name_svideo, | ||
2813 | .vmux = 8, | ||
2814 | .amux = LINE1, | ||
2815 | }}, | ||
2816 | .radio = { | ||
2817 | .name = name_radio, | ||
2818 | .amux = TV, | ||
2819 | .gpio = 0x0200000, | ||
2820 | }, | ||
2821 | }, | ||
2757 | [SAA7134_BOARD_KWORLD_ATSC110] = { | 2822 | [SAA7134_BOARD_KWORLD_ATSC110] = { |
2758 | .name = "Kworld ATSC110", | 2823 | .name = "Kworld ATSC110", |
2759 | .audio_clock = 0x00187de7, | 2824 | .audio_clock = 0x00187de7, |
@@ -3407,6 +3472,36 @@ struct saa7134_board saa7134_boards[] = { | |||
3407 | .gpio = 0x0200000, | 3472 | .gpio = 0x0200000, |
3408 | }, | 3473 | }, |
3409 | }, | 3474 | }, |
3475 | [SAA7134_BOARD_SABRENT_TV_PCB05] = { | ||
3476 | .name = "Sabrent PCMCIA TV-PCB05", | ||
3477 | .audio_clock = 0x00187de7, | ||
3478 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
3479 | .radio_type = UNSET, | ||
3480 | .tuner_addr = ADDR_UNSET, | ||
3481 | .radio_addr = ADDR_UNSET, | ||
3482 | .inputs = {{ | ||
3483 | .name = name_tv, | ||
3484 | .vmux = 1, | ||
3485 | .amux = TV, | ||
3486 | .tv = 1, | ||
3487 | },{ | ||
3488 | .name = name_comp1, | ||
3489 | .vmux = 3, | ||
3490 | .amux = LINE1, | ||
3491 | },{ | ||
3492 | .name = name_comp2, | ||
3493 | .vmux = 0, | ||
3494 | .amux = LINE1, | ||
3495 | },{ | ||
3496 | .name = name_svideo, | ||
3497 | .vmux = 8, | ||
3498 | .amux = LINE1, | ||
3499 | }}, | ||
3500 | .mute = { | ||
3501 | .name = name_mute, | ||
3502 | .amux = TV, | ||
3503 | }, | ||
3504 | }, | ||
3410 | }; | 3505 | }; |
3411 | 3506 | ||
3412 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); | 3507 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); |
@@ -3515,7 +3610,13 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
3515 | .vendor = PCI_VENDOR_ID_PHILIPS, | 3610 | .vendor = PCI_VENDOR_ID_PHILIPS, |
3516 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | 3611 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, |
3517 | .subvendor = 0x5168, /* Animation Technologies (LifeView) */ | 3612 | .subvendor = 0x5168, /* Animation Technologies (LifeView) */ |
3518 | .subdevice = 0x0214, /* Standard PCI, LR214WF */ | 3613 | .subdevice = 0x0214, /* Standard PCI, LR214 Rev E and earlier (SAA7135) */ |
3614 | .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, | ||
3615 | },{ | ||
3616 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
3617 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
3618 | .subvendor = 0x5168, /* Animation Technologies (LifeView) */ | ||
3619 | .subdevice = 0x5214, /* Standard PCI, LR214 Rev F onwards (SAA7131) */ | ||
3519 | .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, | 3620 | .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, |
3520 | },{ | 3621 | },{ |
3521 | .vendor = PCI_VENDOR_ID_PHILIPS, | 3622 | .vendor = PCI_VENDOR_ID_PHILIPS, |
@@ -3689,6 +3790,12 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
3689 | .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5, | 3790 | .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5, |
3690 | },{ | 3791 | },{ |
3691 | .vendor = PCI_VENDOR_ID_PHILIPS, | 3792 | .vendor = PCI_VENDOR_ID_PHILIPS, |
3793 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, | ||
3794 | .subvendor = 0x1019, | ||
3795 | .subdevice = 0x4cb6, | ||
3796 | .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB6, | ||
3797 | },{ | ||
3798 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
3692 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | 3799 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, |
3693 | .subvendor = 0x12ab, | 3800 | .subvendor = 0x12ab, |
3694 | .subdevice = 0x0800, | 3801 | .subdevice = 0x0800, |
@@ -3915,6 +4022,12 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
3915 | .driver_data = SAA7134_BOARD_TEVION_DVBT_220RF, | 4022 | .driver_data = SAA7134_BOARD_TEVION_DVBT_220RF, |
3916 | },{ | 4023 | },{ |
3917 | .vendor = PCI_VENDOR_ID_PHILIPS, | 4024 | .vendor = PCI_VENDOR_ID_PHILIPS, |
4025 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
4026 | .subvendor = 0x17de, | ||
4027 | .subdevice = 0x7250, | ||
4028 | .driver_data = SAA7134_BOARD_KWORLD_DVBT_210, | ||
4029 | },{ | ||
4030 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
3918 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA7135HL */ | 4031 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA7135HL */ |
3919 | .subvendor = 0x17de, | 4032 | .subvendor = 0x17de, |
3920 | .subdevice = 0x7350, | 4033 | .subdevice = 0x7350, |
@@ -4100,6 +4213,12 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
4100 | .subdevice = 0x4857, | 4213 | .subdevice = 0x4857, |
4101 | .driver_data = SAA7134_BOARD_ASUSTeK_P7131_DUAL, | 4214 | .driver_data = SAA7134_BOARD_ASUSTeK_P7131_DUAL, |
4102 | },{ | 4215 | },{ |
4216 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
4217 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, | ||
4218 | .subvendor = 0x0919, /* SinoVideo PCI 2309 Proteus (7134) */ | ||
4219 | .subdevice = 0x2003, /* OEM cardbus */ | ||
4220 | .driver_data = SAA7134_BOARD_SABRENT_TV_PCB05, | ||
4221 | },{ | ||
4103 | /* --- boards without eeprom + subsystem ID --- */ | 4222 | /* --- boards without eeprom + subsystem ID --- */ |
4104 | .vendor = PCI_VENDOR_ID_PHILIPS, | 4223 | .vendor = PCI_VENDOR_ID_PHILIPS, |
4105 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, | 4224 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, |
@@ -4178,6 +4297,7 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
4178 | case SAA7134_BOARD_CINERGY600_MK3: | 4297 | case SAA7134_BOARD_CINERGY600_MK3: |
4179 | case SAA7134_BOARD_ECS_TVP3XP: | 4298 | case SAA7134_BOARD_ECS_TVP3XP: |
4180 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: | 4299 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: |
4300 | case SAA7134_BOARD_ECS_TVP3XP_4CB6: | ||
4181 | case SAA7134_BOARD_MD2819: | 4301 | case SAA7134_BOARD_MD2819: |
4182 | case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: | 4302 | case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: |
4183 | case SAA7134_BOARD_KWORLD_XPERT: | 4303 | case SAA7134_BOARD_KWORLD_XPERT: |
@@ -4426,6 +4546,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4426 | } | 4546 | } |
4427 | break; | 4547 | break; |
4428 | case SAA7134_BOARD_PINNACLE_PCTV_310i: | 4548 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
4549 | case SAA7134_BOARD_KWORLD_DVBT_210: | ||
4429 | case SAA7134_BOARD_TEVION_DVBT_220RF: | 4550 | case SAA7134_BOARD_TEVION_DVBT_220RF: |
4430 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: | 4551 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
4431 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: | 4552 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 65aec881bbde..e0eec80088c7 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -887,6 +887,20 @@ static struct tda1004x_config asus_p7131_hybrid_lna_config = { | |||
887 | .antenna_switch= 2, | 887 | .antenna_switch= 2, |
888 | .request_firmware = philips_tda1004x_request_firmware | 888 | .request_firmware = philips_tda1004x_request_firmware |
889 | }; | 889 | }; |
890 | static struct tda1004x_config kworld_dvb_t_210_config = { | ||
891 | .demod_address = 0x08, | ||
892 | .invert = 1, | ||
893 | .invert_oclk = 0, | ||
894 | .xtal_freq = TDA10046_XTAL_16M, | ||
895 | .agc_config = TDA10046_AGC_TDA827X, | ||
896 | .gpio_config = TDA10046_GP11_I, | ||
897 | .if_freq = TDA10046_FREQ_045, | ||
898 | .i2c_gate = 0x4b, | ||
899 | .tuner_address = 0x61, | ||
900 | .tuner_config = 2, | ||
901 | .antenna_switch= 1, | ||
902 | .request_firmware = philips_tda1004x_request_firmware | ||
903 | }; | ||
890 | /* ------------------------------------------------------------------ | 904 | /* ------------------------------------------------------------------ |
891 | * special case: this card uses saa713x GPIO22 for the mode switch | 905 | * special case: this card uses saa713x GPIO22 for the mode switch |
892 | */ | 906 | */ |
@@ -1039,6 +1053,9 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1039 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; | 1053 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; |
1040 | } | 1054 | } |
1041 | break; | 1055 | break; |
1056 | case SAA7134_BOARD_KWORLD_DVBT_210: | ||
1057 | configure_tda827x_fe(dev, &kworld_dvb_t_210_config); | ||
1058 | break; | ||
1042 | case SAA7134_BOARD_PHILIPS_TIGER: | 1059 | case SAA7134_BOARD_PHILIPS_TIGER: |
1043 | configure_tda827x_fe(dev, &philips_tiger_config); | 1060 | configure_tda827x_fe(dev, &philips_tiger_config); |
1044 | break; | 1061 | break; |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 62224cc958f1..15623b27ad2e 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -235,6 +235,9 @@ struct saa7134_format { | |||
235 | #define SAA7134_BOARD_AVERMEDIA_M102 110 | 235 | #define SAA7134_BOARD_AVERMEDIA_M102 110 |
236 | #define SAA7134_BOARD_ASUS_P7131_4871 111 | 236 | #define SAA7134_BOARD_ASUS_P7131_4871 111 |
237 | #define SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA 112 | 237 | #define SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA 112 |
238 | #define SAA7134_BOARD_ECS_TVP3XP_4CB6 113 | ||
239 | #define SAA7134_BOARD_KWORLD_DVBT_210 114 | ||
240 | #define SAA7134_BOARD_SABRENT_TV_PCB05 115 | ||
238 | 241 | ||
239 | #define SAA7134_MAXBOARDS 8 | 242 | #define SAA7134_MAXBOARDS 8 |
240 | #define SAA7134_INPUT_MAX 8 | 243 | #define SAA7134_INPUT_MAX 8 |
diff --git a/drivers/media/video/sn9c102/Kconfig b/drivers/media/video/sn9c102/Kconfig index 19204f5686e1..f71f272776de 100644 --- a/drivers/media/video/sn9c102/Kconfig +++ b/drivers/media/video/sn9c102/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USB_SN9C102 | 1 | config USB_SN9C102 |
2 | tristate "USB SN9C1xx PC Camera Controller support" | 2 | tristate "USB SN9C1xx PC Camera Controller support" |
3 | depends on USB && VIDEO_V4L2 | 3 | depends on VIDEO_V4L2 |
4 | ---help--- | 4 | ---help--- |
5 | Say Y here if you want support for cameras based on SONiX SN9C101, | 5 | Say Y here if you want support for cameras based on SONiX SN9C101, |
6 | SN9C102, SN9C103, SN9C105 and SN9C120 PC Camera Controllers. | 6 | SN9C102, SN9C103, SN9C105 and SN9C120 PC Camera Controllers. |
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h index 680e74634527..11fcb49f5b99 100644 --- a/drivers/media/video/sn9c102/sn9c102.h +++ b/drivers/media/video/sn9c102/sn9c102.h | |||
@@ -141,7 +141,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id) | |||
141 | 141 | ||
142 | void | 142 | void |
143 | sn9c102_attach_sensor(struct sn9c102_device* cam, | 143 | sn9c102_attach_sensor(struct sn9c102_device* cam, |
144 | struct sn9c102_sensor* sensor) | 144 | const struct sn9c102_sensor* sensor) |
145 | { | 145 | { |
146 | memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); | 146 | memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); |
147 | } | 147 | } |
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index 89f83354de3b..74a204f8ebc8 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c | |||
@@ -48,8 +48,8 @@ | |||
48 | #define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia" | 48 | #define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia" |
49 | #define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" | 49 | #define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" |
50 | #define SN9C102_MODULE_LICENSE "GPL" | 50 | #define SN9C102_MODULE_LICENSE "GPL" |
51 | #define SN9C102_MODULE_VERSION "1:1.39" | 51 | #define SN9C102_MODULE_VERSION "1:1.44" |
52 | #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 39) | 52 | #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 44) |
53 | 53 | ||
54 | /*****************************************************************************/ | 54 | /*****************************************************************************/ |
55 | 55 | ||
@@ -209,38 +209,41 @@ static void sn9c102_queue_unusedframes(struct sn9c102_device* cam) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | /*****************************************************************************/ | 211 | /*****************************************************************************/ |
212 | |||
212 | /* | 213 | /* |
213 | * Write a sequence of count value/register pairs. Returns -1 after the | 214 | Write a sequence of count value/register pairs. Returns -1 after the first |
214 | * first failed write, or 0 for no errors. | 215 | failed write, or 0 for no errors. |
215 | */ | 216 | */ |
216 | int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2], | 217 | int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2], |
217 | int count) | 218 | int count) |
218 | { | 219 | { |
219 | struct usb_device* udev = cam->usbdev; | 220 | struct usb_device* udev = cam->usbdev; |
220 | u8* value = cam->control_buffer; /* Needed for DMA'able memory */ | 221 | u8* buff = cam->control_buffer; |
221 | int i, res; | 222 | int i, res; |
222 | 223 | ||
223 | for (i = 0; i < count; i++) { | 224 | for (i = 0; i < count; i++) { |
224 | u8 index = valreg[i][1]; | 225 | u8 index = valreg[i][1]; |
225 | 226 | ||
226 | /* | 227 | /* |
227 | * index is a u8, so it must be <256 and can't be out of range. | 228 | index is a u8, so it must be <256 and can't be out of range. |
228 | * If we put in a check anyway, gcc annoys us with a warning | 229 | If we put in a check anyway, gcc annoys us with a warning |
229 | * that our check is useless. People get all uppity when they | 230 | hat our check is useless. People get all uppity when they |
230 | * see warnings in the kernel compile. | 231 | see warnings in the kernel compile. |
231 | */ | 232 | */ |
232 | 233 | ||
233 | *value = valreg[i][0]; | 234 | *buff = valreg[i][0]; |
234 | res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 235 | |
235 | 0x08, 0x41, index, 0, | 236 | res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, |
236 | value, 1, SN9C102_CTRL_TIMEOUT); | 237 | 0x41, index, 0, buff, 1, |
238 | SN9C102_CTRL_TIMEOUT); | ||
239 | |||
237 | if (res < 0) { | 240 | if (res < 0) { |
238 | DBG(3, "Failed to write a register (value 0x%02X, " | 241 | DBG(3, "Failed to write a register (value 0x%02X, " |
239 | "index 0x%02X, error %d)", *value, index, res); | 242 | "index 0x%02X, error %d)", *buff, index, res); |
240 | return -1; | 243 | return -1; |
241 | } | 244 | } |
242 | 245 | ||
243 | cam->reg[index] = *value; | 246 | cam->reg[index] = *buff; |
244 | } | 247 | } |
245 | 248 | ||
246 | return 0; | 249 | return 0; |
@@ -272,8 +275,8 @@ int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index) | |||
272 | } | 275 | } |
273 | 276 | ||
274 | 277 | ||
275 | /* NOTE: reading some registers always returns 0 */ | 278 | /* NOTE: with the SN9C10[123] reading some registers always returns 0 */ |
276 | static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index) | 279 | int sn9c102_read_reg(struct sn9c102_device* cam, u16 index) |
277 | { | 280 | { |
278 | struct usb_device* udev = cam->usbdev; | 281 | struct usb_device* udev = cam->usbdev; |
279 | u8* buff = cam->control_buffer; | 282 | u8* buff = cam->control_buffer; |
@@ -299,7 +302,8 @@ int sn9c102_pread_reg(struct sn9c102_device* cam, u16 index) | |||
299 | 302 | ||
300 | 303 | ||
301 | static int | 304 | static int |
302 | sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor) | 305 | sn9c102_i2c_wait(struct sn9c102_device* cam, |
306 | const struct sn9c102_sensor* sensor) | ||
303 | { | 307 | { |
304 | int i, r; | 308 | int i, r; |
305 | 309 | ||
@@ -320,7 +324,7 @@ sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor) | |||
320 | 324 | ||
321 | static int | 325 | static int |
322 | sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, | 326 | sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, |
323 | struct sn9c102_sensor* sensor) | 327 | const struct sn9c102_sensor* sensor) |
324 | { | 328 | { |
325 | int r , err = 0; | 329 | int r , err = 0; |
326 | 330 | ||
@@ -342,7 +346,7 @@ sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, | |||
342 | 346 | ||
343 | static int | 347 | static int |
344 | sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, | 348 | sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, |
345 | struct sn9c102_sensor* sensor) | 349 | const struct sn9c102_sensor* sensor) |
346 | { | 350 | { |
347 | int r; | 351 | int r; |
348 | r = sn9c102_read_reg(cam, 0x08); | 352 | r = sn9c102_read_reg(cam, 0x08); |
@@ -352,12 +356,12 @@ sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, | |||
352 | 356 | ||
353 | int | 357 | int |
354 | sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, | 358 | sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, |
355 | struct sn9c102_sensor* sensor, u8 data0, u8 data1, | 359 | const struct sn9c102_sensor* sensor, u8 data0, |
356 | u8 n, u8 buffer[]) | 360 | u8 data1, u8 n, u8 buffer[]) |
357 | { | 361 | { |
358 | struct usb_device* udev = cam->usbdev; | 362 | struct usb_device* udev = cam->usbdev; |
359 | u8* data = cam->control_buffer; | 363 | u8* data = cam->control_buffer; |
360 | int err = 0, res; | 364 | int i = 0, err = 0, res; |
361 | 365 | ||
362 | /* Write cycle */ | 366 | /* Write cycle */ |
363 | data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | | 367 | data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | |
@@ -402,7 +406,8 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, | |||
402 | } | 406 | } |
403 | 407 | ||
404 | if (buffer) | 408 | if (buffer) |
405 | memcpy(buffer, data, sizeof(buffer)); | 409 | for (i = 0; i < n && i < 5; i++) |
410 | buffer[n-i-1] = data[4-i]; | ||
406 | 411 | ||
407 | return (int)data[4]; | 412 | return (int)data[4]; |
408 | } | 413 | } |
@@ -410,7 +415,7 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, | |||
410 | 415 | ||
411 | int | 416 | int |
412 | sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, | 417 | sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, |
413 | struct sn9c102_sensor* sensor, u8 n, u8 data0, | 418 | const struct sn9c102_sensor* sensor, u8 n, u8 data0, |
414 | u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) | 419 | u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) |
415 | { | 420 | { |
416 | struct usb_device* udev = cam->usbdev; | 421 | struct usb_device* udev = cam->usbdev; |
@@ -449,7 +454,7 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, | |||
449 | 454 | ||
450 | int | 455 | int |
451 | sn9c102_i2c_try_read(struct sn9c102_device* cam, | 456 | sn9c102_i2c_try_read(struct sn9c102_device* cam, |
452 | struct sn9c102_sensor* sensor, u8 address) | 457 | const struct sn9c102_sensor* sensor, u8 address) |
453 | { | 458 | { |
454 | return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, | 459 | return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, |
455 | address, 1, NULL); | 460 | address, 1, NULL); |
@@ -458,7 +463,7 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam, | |||
458 | 463 | ||
459 | int | 464 | int |
460 | sn9c102_i2c_try_write(struct sn9c102_device* cam, | 465 | sn9c102_i2c_try_write(struct sn9c102_device* cam, |
461 | struct sn9c102_sensor* sensor, u8 address, u8 value) | 466 | const struct sn9c102_sensor* sensor, u8 address, u8 value) |
462 | { | 467 | { |
463 | return sn9c102_i2c_try_raw_write(cam, sensor, 3, | 468 | return sn9c102_i2c_try_raw_write(cam, sensor, 3, |
464 | sensor->i2c_slave_id, address, | 469 | sensor->i2c_slave_id, address, |
@@ -657,16 +662,6 @@ sn9c102_write_jpegheader(struct sn9c102_device* cam, struct sn9c102_frame_t* f) | |||
657 | } | 662 | } |
658 | 663 | ||
659 | 664 | ||
660 | static void | ||
661 | sn9c102_write_eoimarker(struct sn9c102_device* cam, struct sn9c102_frame_t* f) | ||
662 | { | ||
663 | static const u8 eoi_marker[2] = {0xff, 0xd9}; | ||
664 | |||
665 | memcpy(f->bufmem + f->buf.bytesused, eoi_marker, sizeof(eoi_marker)); | ||
666 | f->buf.bytesused += sizeof(eoi_marker); | ||
667 | } | ||
668 | |||
669 | |||
670 | static void sn9c102_urb_complete(struct urb *urb) | 665 | static void sn9c102_urb_complete(struct urb *urb) |
671 | { | 666 | { |
672 | struct sn9c102_device* cam = urb->context; | 667 | struct sn9c102_device* cam = urb->context; |
@@ -3181,14 +3176,14 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp, | |||
3181 | 3176 | ||
3182 | static const struct file_operations sn9c102_fops = { | 3177 | static const struct file_operations sn9c102_fops = { |
3183 | .owner = THIS_MODULE, | 3178 | .owner = THIS_MODULE, |
3184 | .open = sn9c102_open, | 3179 | .open = sn9c102_open, |
3185 | .release = sn9c102_release, | 3180 | .release = sn9c102_release, |
3186 | .ioctl = sn9c102_ioctl, | 3181 | .ioctl = sn9c102_ioctl, |
3187 | .compat_ioctl = v4l_compat_ioctl32, | 3182 | .compat_ioctl = v4l_compat_ioctl32, |
3188 | .read = sn9c102_read, | 3183 | .read = sn9c102_read, |
3189 | .poll = sn9c102_poll, | 3184 | .poll = sn9c102_poll, |
3190 | .mmap = sn9c102_mmap, | 3185 | .mmap = sn9c102_mmap, |
3191 | .llseek = no_llseek, | 3186 | .llseek = no_llseek, |
3192 | }; | 3187 | }; |
3193 | 3188 | ||
3194 | /*****************************************************************************/ | 3189 | /*****************************************************************************/ |
@@ -3251,7 +3246,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3251 | break; | 3246 | break; |
3252 | } | 3247 | } |
3253 | 3248 | ||
3254 | for (i = 0; sn9c102_sensor_table[i]; i++) { | 3249 | for (i = 0; i < ARRAY_SIZE(sn9c102_sensor_table); i++) { |
3255 | err = sn9c102_sensor_table[i](cam); | 3250 | err = sn9c102_sensor_table[i](cam); |
3256 | if (!err) | 3251 | if (!err) |
3257 | break; | 3252 | break; |
@@ -3262,7 +3257,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3262 | DBG(3, "Support for %s maintained by %s", | 3257 | DBG(3, "Support for %s maintained by %s", |
3263 | cam->sensor.name, cam->sensor.maintainer); | 3258 | cam->sensor.name, cam->sensor.maintainer); |
3264 | } else { | 3259 | } else { |
3265 | DBG(1, "No supported image sensor detected"); | 3260 | DBG(1, "No supported image sensor detected for this bridge"); |
3266 | err = -ENODEV; | 3261 | err = -ENODEV; |
3267 | goto fail; | 3262 | goto fail; |
3268 | } | 3263 | } |
diff --git a/drivers/media/video/sn9c102/sn9c102_devtable.h b/drivers/media/video/sn9c102/sn9c102_devtable.h index f49bd8c5b86e..916054faf9be 100644 --- a/drivers/media/video/sn9c102/sn9c102_devtable.h +++ b/drivers/media/video/sn9c102/sn9c102_devtable.h | |||
@@ -86,6 +86,8 @@ static const struct usb_device_id sn9c102_id_table[] = { | |||
86 | { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, | 86 | { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, |
87 | { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, | 87 | { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, |
88 | /* SN9C105 */ | 88 | /* SN9C105 */ |
89 | { SN9C102_USB_DEVICE(0x045e, 0x00f5, BRIDGE_SN9C105), }, | ||
90 | { SN9C102_USB_DEVICE(0x045e, 0x00f7, BRIDGE_SN9C105), }, | ||
89 | { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, | 91 | { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, |
90 | { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, | 92 | { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, |
91 | { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, | 93 | { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, |
@@ -100,6 +102,7 @@ static const struct usb_device_id sn9c102_id_table[] = { | |||
100 | { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, | 102 | { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, |
101 | { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, | 103 | { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, |
102 | /* SN9C120 */ | 104 | /* SN9C120 */ |
105 | { SN9C102_USB_DEVICE(0x0458, 0x7025, BRIDGE_SN9C120), }, | ||
103 | { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, | 106 | { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, |
104 | { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, | 107 | { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, |
105 | { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, | 108 | { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, |
@@ -148,7 +151,6 @@ static int (*sn9c102_sensor_table[])(struct sn9c102_device*) = { | |||
148 | &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ | 151 | &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ |
149 | &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */ | 152 | &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */ |
150 | &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ | 153 | &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ |
151 | NULL, | ||
152 | }; | 154 | }; |
153 | 155 | ||
154 | #endif /* _SN9C102_DEVTABLE_H_ */ | 156 | #endif /* _SN9C102_DEVTABLE_H_ */ |
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131d.c b/drivers/media/video/sn9c102/sn9c102_hv7131d.c index 28a861aed044..eaf9ad0dc8a6 100644 --- a/drivers/media/video/sn9c102/sn9c102_hv7131d.c +++ b/drivers/media/video/sn9c102/sn9c102_hv7131d.c | |||
@@ -144,7 +144,7 @@ static int hv7131d_set_pix_format(struct sn9c102_device* cam, | |||
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | static struct sn9c102_sensor hv7131d = { | 147 | static const struct sn9c102_sensor hv7131d = { |
148 | .name = "HV7131D", | 148 | .name = "HV7131D", |
149 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 149 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
150 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 150 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
@@ -248,12 +248,10 @@ int sn9c102_probe_hv7131d(struct sn9c102_device* cam) | |||
248 | 248 | ||
249 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, | 249 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, |
250 | {0x28, 0x17}); | 250 | {0x28, 0x17}); |
251 | if (err) | ||
252 | return -EIO; | ||
253 | 251 | ||
254 | r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00); | 252 | r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00); |
255 | r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01); | 253 | r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01); |
256 | if (r0 < 0 || r1 < 0) | 254 | if (err || r0 < 0 || r1 < 0) |
257 | return -EIO; | 255 | return -EIO; |
258 | 256 | ||
259 | if (r0 != 0x00 || r1 != 0x04) | 257 | if (r0 != 0x00 || r1 != 0x04) |
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131r.c b/drivers/media/video/sn9c102/sn9c102_hv7131r.c index 5a495baa5f95..0fc401223cfc 100644 --- a/drivers/media/video/sn9c102/sn9c102_hv7131r.c +++ b/drivers/media/video/sn9c102/sn9c102_hv7131r.c | |||
@@ -44,7 +44,6 @@ static int hv7131r_init(struct sn9c102_device* cam) | |||
44 | {0xb0, 0x2b}, {0xc0, 0x2c}, | 44 | {0xb0, 0x2b}, {0xc0, 0x2c}, |
45 | {0xd0, 0x2d}, {0xe0, 0x2e}, | 45 | {0xd0, 0x2d}, {0xe0, 0x2e}, |
46 | {0xf0, 0x2f}, {0xff, 0x30}); | 46 | {0xf0, 0x2f}, {0xff, 0x30}); |
47 | |||
48 | break; | 47 | break; |
49 | case BRIDGE_SN9C105: | 48 | case BRIDGE_SN9C105: |
50 | case BRIDGE_SN9C120: | 49 | case BRIDGE_SN9C120: |
@@ -254,7 +253,7 @@ static int hv7131r_set_pix_format(struct sn9c102_device* cam, | |||
254 | } | 253 | } |
255 | 254 | ||
256 | 255 | ||
257 | static struct sn9c102_sensor hv7131r = { | 256 | static const struct sn9c102_sensor hv7131r = { |
258 | .name = "HV7131R", | 257 | .name = "HV7131R", |
259 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 258 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
260 | .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, | 259 | .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, |
@@ -350,11 +349,8 @@ int sn9c102_probe_hv7131r(struct sn9c102_device* cam) | |||
350 | {0x34, 0x01}, {0x20, 0x17}, | 349 | {0x34, 0x01}, {0x20, 0x17}, |
351 | {0x34, 0x01}, {0x46, 0x01}); | 350 | {0x34, 0x01}, {0x46, 0x01}); |
352 | 351 | ||
353 | if (err) | ||
354 | return -EIO; | ||
355 | |||
356 | devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00); | 352 | devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00); |
357 | if (devid < 0) | 353 | if (err || devid < 0) |
358 | return -EIO; | 354 | return -EIO; |
359 | 355 | ||
360 | if (devid != 0x02) | 356 | if (devid != 0x02) |
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c index 9200845d011b..00b134ca0a3d 100644 --- a/drivers/media/video/sn9c102/sn9c102_mi0343.c +++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c | |||
@@ -55,45 +55,45 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam, | |||
55 | struct v4l2_control* ctrl) | 55 | struct v4l2_control* ctrl) |
56 | { | 56 | { |
57 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 57 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
58 | u8 data[5+1]; | 58 | u8 data[2]; |
59 | 59 | ||
60 | switch (ctrl->id) { | 60 | switch (ctrl->id) { |
61 | case V4L2_CID_EXPOSURE: | 61 | case V4L2_CID_EXPOSURE: |
62 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, | 62 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2, |
63 | 2+1, data) < 0) | 63 | data) < 0) |
64 | return -EIO; | 64 | return -EIO; |
65 | ctrl->value = data[2]; | 65 | ctrl->value = data[0]; |
66 | return 0; | 66 | return 0; |
67 | case V4L2_CID_GAIN: | 67 | case V4L2_CID_GAIN: |
68 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, | 68 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2, |
69 | 2+1, data) < 0) | 69 | data) < 0) |
70 | return -EIO; | 70 | return -EIO; |
71 | break; | 71 | break; |
72 | case V4L2_CID_HFLIP: | 72 | case V4L2_CID_HFLIP: |
73 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, | 73 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
74 | 2+1, data) < 0) | 74 | data) < 0) |
75 | return -EIO; | 75 | return -EIO; |
76 | ctrl->value = data[3] & 0x20 ? 1 : 0; | 76 | ctrl->value = data[1] & 0x20 ? 1 : 0; |
77 | return 0; | 77 | return 0; |
78 | case V4L2_CID_VFLIP: | 78 | case V4L2_CID_VFLIP: |
79 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, | 79 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
80 | 2+1, data) < 0) | 80 | data) < 0) |
81 | return -EIO; | 81 | return -EIO; |
82 | ctrl->value = data[3] & 0x80 ? 1 : 0; | 82 | ctrl->value = data[1] & 0x80 ? 1 : 0; |
83 | return 0; | 83 | return 0; |
84 | case V4L2_CID_RED_BALANCE: | 84 | case V4L2_CID_RED_BALANCE: |
85 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, | 85 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2, |
86 | 2+1, data) < 0) | 86 | data) < 0) |
87 | return -EIO; | 87 | return -EIO; |
88 | break; | 88 | break; |
89 | case V4L2_CID_BLUE_BALANCE: | 89 | case V4L2_CID_BLUE_BALANCE: |
90 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, | 90 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2, |
91 | 2+1, data) < 0) | 91 | data) < 0) |
92 | return -EIO; | 92 | return -EIO; |
93 | break; | 93 | break; |
94 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 94 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
95 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, | 95 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2, |
96 | 2+1, data) < 0) | 96 | data) < 0) |
97 | return -EIO; | 97 | return -EIO; |
98 | break; | 98 | break; |
99 | default: | 99 | default: |
@@ -105,7 +105,7 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam, | |||
105 | case V4L2_CID_RED_BALANCE: | 105 | case V4L2_CID_RED_BALANCE: |
106 | case V4L2_CID_BLUE_BALANCE: | 106 | case V4L2_CID_BLUE_BALANCE: |
107 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 107 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
108 | ctrl->value = data[3] | (data[2] << 8); | 108 | ctrl->value = data[1] | (data[0] << 8); |
109 | if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) | 109 | if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) |
110 | ctrl->value -= 0x10; | 110 | ctrl->value -= 0x10; |
111 | else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) | 111 | else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) |
@@ -223,7 +223,7 @@ static int mi0343_set_pix_format(struct sn9c102_device* cam, | |||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | static struct sn9c102_sensor mi0343 = { | 226 | static const struct sn9c102_sensor mi0343 = { |
227 | .name = "MI-0343", | 227 | .name = "MI-0343", |
228 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 228 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
229 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 229 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
@@ -332,20 +332,17 @@ static struct sn9c102_sensor mi0343 = { | |||
332 | 332 | ||
333 | int sn9c102_probe_mi0343(struct sn9c102_device* cam) | 333 | int sn9c102_probe_mi0343(struct sn9c102_device* cam) |
334 | { | 334 | { |
335 | u8 data[5+1]; | 335 | u8 data[2]; |
336 | int err = 0; | ||
337 | |||
338 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, | ||
339 | {0x28, 0x17}); | ||
340 | 336 | ||
341 | if (err) | 337 | if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, |
338 | {0x28, 0x17})) | ||
342 | return -EIO; | 339 | return -EIO; |
343 | 340 | ||
344 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, | 341 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, |
345 | 2, data) < 0) | 342 | 2, data) < 0) |
346 | return -EIO; | 343 | return -EIO; |
347 | 344 | ||
348 | if (data[4] != 0x32 || data[3] != 0xe3) | 345 | if (data[1] != 0x42 || data[0] != 0xe3) |
349 | return -ENODEV; | 346 | return -ENODEV; |
350 | 347 | ||
351 | sn9c102_attach_sensor(cam, &mi0343); | 348 | sn9c102_attach_sensor(cam, &mi0343); |
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0360.c b/drivers/media/video/sn9c102/sn9c102_mi0360.c index 64698acb0b15..f8d81d82e8d5 100644 --- a/drivers/media/video/sn9c102/sn9c102_mi0360.c +++ b/drivers/media/video/sn9c102/sn9c102_mi0360.c | |||
@@ -27,20 +27,105 @@ static int mi0360_init(struct sn9c102_device* cam) | |||
27 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 27 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
28 | int err = 0; | 28 | int err = 0; |
29 | 29 | ||
30 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, | 30 | switch (sn9c102_get_bridge(cam)) { |
31 | {0x0a, 0x14}, {0x40, 0x01}, | 31 | case BRIDGE_SN9C103: |
32 | {0x20, 0x17}, {0x07, 0x18}, | 32 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, |
33 | {0xa0, 0x19}, {0x02, 0x1c}, | 33 | {0x0a, 0x14}, {0x40, 0x01}, |
34 | {0x03, 0x1d}, {0x0f, 0x1e}, | 34 | {0x20, 0x17}, {0x07, 0x18}, |
35 | {0x0c, 0x1f}, {0x00, 0x20}, | 35 | {0xa0, 0x19}, {0x02, 0x1c}, |
36 | {0x10, 0x21}, {0x20, 0x22}, | 36 | {0x03, 0x1d}, {0x0f, 0x1e}, |
37 | {0x30, 0x23}, {0x40, 0x24}, | 37 | {0x0c, 0x1f}, {0x00, 0x20}, |
38 | {0x50, 0x25}, {0x60, 0x26}, | 38 | {0x10, 0x21}, {0x20, 0x22}, |
39 | {0x70, 0x27}, {0x80, 0x28}, | 39 | {0x30, 0x23}, {0x40, 0x24}, |
40 | {0x90, 0x29}, {0xa0, 0x2a}, | 40 | {0x50, 0x25}, {0x60, 0x26}, |
41 | {0xb0, 0x2b}, {0xc0, 0x2c}, | 41 | {0x70, 0x27}, {0x80, 0x28}, |
42 | {0xd0, 0x2d}, {0xe0, 0x2e}, | 42 | {0x90, 0x29}, {0xa0, 0x2a}, |
43 | {0xf0, 0x2f}, {0xff, 0x30}); | 43 | {0xb0, 0x2b}, {0xc0, 0x2c}, |
44 | {0xd0, 0x2d}, {0xe0, 0x2e}, | ||
45 | {0xf0, 0x2f}, {0xff, 0x30}); | ||
46 | break; | ||
47 | case BRIDGE_SN9C105: | ||
48 | case BRIDGE_SN9C120: | ||
49 | err = sn9c102_write_const_regs(cam, {0x44, 0x01}, {0x40, 0x02}, | ||
50 | {0x00, 0x03}, {0x1a, 0x04}, | ||
51 | {0x50, 0x05}, {0x20, 0x06}, | ||
52 | {0x10, 0x07}, {0x03, 0x10}, | ||
53 | {0x08, 0x14}, {0xa2, 0x17}, | ||
54 | {0x47, 0x18}, {0x00, 0x19}, | ||
55 | {0x1d, 0x1a}, {0x10, 0x1b}, | ||
56 | {0x02, 0x1c}, {0x03, 0x1d}, | ||
57 | {0x0f, 0x1e}, {0x0c, 0x1f}, | ||
58 | {0x00, 0x20}, {0x29, 0x21}, | ||
59 | {0x40, 0x22}, {0x54, 0x23}, | ||
60 | {0x66, 0x24}, {0x76, 0x25}, | ||
61 | {0x85, 0x26}, {0x94, 0x27}, | ||
62 | {0xa1, 0x28}, {0xae, 0x29}, | ||
63 | {0xbb, 0x2a}, {0xc7, 0x2b}, | ||
64 | {0xd3, 0x2c}, {0xde, 0x2d}, | ||
65 | {0xea, 0x2e}, {0xf4, 0x2f}, | ||
66 | {0xff, 0x30}, {0x00, 0x3F}, | ||
67 | {0xC7, 0x40}, {0x01, 0x41}, | ||
68 | {0x44, 0x42}, {0x00, 0x43}, | ||
69 | {0x44, 0x44}, {0x00, 0x45}, | ||
70 | {0x44, 0x46}, {0x00, 0x47}, | ||
71 | {0xC7, 0x48}, {0x01, 0x49}, | ||
72 | {0xC7, 0x4A}, {0x01, 0x4B}, | ||
73 | {0xC7, 0x4C}, {0x01, 0x4D}, | ||
74 | {0x44, 0x4E}, {0x00, 0x4F}, | ||
75 | {0x44, 0x50}, {0x00, 0x51}, | ||
76 | {0x44, 0x52}, {0x00, 0x53}, | ||
77 | {0xC7, 0x54}, {0x01, 0x55}, | ||
78 | {0xC7, 0x56}, {0x01, 0x57}, | ||
79 | {0xC7, 0x58}, {0x01, 0x59}, | ||
80 | {0x44, 0x5A}, {0x00, 0x5B}, | ||
81 | {0x44, 0x5C}, {0x00, 0x5D}, | ||
82 | {0x44, 0x5E}, {0x00, 0x5F}, | ||
83 | {0xC7, 0x60}, {0x01, 0x61}, | ||
84 | {0xC7, 0x62}, {0x01, 0x63}, | ||
85 | {0xC7, 0x64}, {0x01, 0x65}, | ||
86 | {0x44, 0x66}, {0x00, 0x67}, | ||
87 | {0x44, 0x68}, {0x00, 0x69}, | ||
88 | {0x44, 0x6A}, {0x00, 0x6B}, | ||
89 | {0xC7, 0x6C}, {0x01, 0x6D}, | ||
90 | {0xC7, 0x6E}, {0x01, 0x6F}, | ||
91 | {0xC7, 0x70}, {0x01, 0x71}, | ||
92 | {0x44, 0x72}, {0x00, 0x73}, | ||
93 | {0x44, 0x74}, {0x00, 0x75}, | ||
94 | {0x44, 0x76}, {0x00, 0x77}, | ||
95 | {0xC7, 0x78}, {0x01, 0x79}, | ||
96 | {0xC7, 0x7A}, {0x01, 0x7B}, | ||
97 | {0xC7, 0x7C}, {0x01, 0x7D}, | ||
98 | {0x44, 0x7E}, {0x00, 0x7F}, | ||
99 | {0x14, 0x84}, {0x00, 0x85}, | ||
100 | {0x27, 0x86}, {0x00, 0x87}, | ||
101 | {0x07, 0x88}, {0x00, 0x89}, | ||
102 | {0xEC, 0x8A}, {0x0f, 0x8B}, | ||
103 | {0xD8, 0x8C}, {0x0f, 0x8D}, | ||
104 | {0x3D, 0x8E}, {0x00, 0x8F}, | ||
105 | {0x3D, 0x90}, {0x00, 0x91}, | ||
106 | {0xCD, 0x92}, {0x0f, 0x93}, | ||
107 | {0xf7, 0x94}, {0x0f, 0x95}, | ||
108 | {0x0C, 0x96}, {0x00, 0x97}, | ||
109 | {0x00, 0x98}, {0x66, 0x99}, | ||
110 | {0x05, 0x9A}, {0x00, 0x9B}, | ||
111 | {0x04, 0x9C}, {0x00, 0x9D}, | ||
112 | {0x08, 0x9E}, {0x00, 0x9F}, | ||
113 | {0x2D, 0xC0}, {0x2D, 0xC1}, | ||
114 | {0x3A, 0xC2}, {0x05, 0xC3}, | ||
115 | {0x04, 0xC4}, {0x3F, 0xC5}, | ||
116 | {0x00, 0xC6}, {0x00, 0xC7}, | ||
117 | {0x50, 0xC8}, {0x3C, 0xC9}, | ||
118 | {0x28, 0xCA}, {0xD8, 0xCB}, | ||
119 | {0x14, 0xCC}, {0xEC, 0xCD}, | ||
120 | {0x32, 0xCE}, {0xDD, 0xCF}, | ||
121 | {0x32, 0xD0}, {0xDD, 0xD1}, | ||
122 | {0x6A, 0xD2}, {0x50, 0xD3}, | ||
123 | {0x00, 0xD4}, {0x00, 0xD5}, | ||
124 | {0x00, 0xD6}); | ||
125 | break; | ||
126 | default: | ||
127 | break; | ||
128 | } | ||
44 | 129 | ||
45 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, | 130 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, |
46 | 0x00, 0x01, 0, 0); | 131 | 0x00, 0x01, 0, 0); |
@@ -65,50 +150,50 @@ static int mi0360_get_ctrl(struct sn9c102_device* cam, | |||
65 | struct v4l2_control* ctrl) | 150 | struct v4l2_control* ctrl) |
66 | { | 151 | { |
67 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 152 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
68 | u8 data[5+1]; | 153 | u8 data[2]; |
69 | 154 | ||
70 | switch (ctrl->id) { | 155 | switch (ctrl->id) { |
71 | case V4L2_CID_EXPOSURE: | 156 | case V4L2_CID_EXPOSURE: |
72 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, | 157 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2, |
73 | 2+1, data) < 0) | 158 | data) < 0) |
74 | return -EIO; | 159 | return -EIO; |
75 | ctrl->value = data[2]; | 160 | ctrl->value = data[0]; |
76 | return 0; | 161 | return 0; |
77 | case V4L2_CID_GAIN: | 162 | case V4L2_CID_GAIN: |
78 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, | 163 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2, |
79 | 2+1, data) < 0) | 164 | data) < 0) |
80 | return -EIO; | 165 | return -EIO; |
81 | ctrl->value = data[3]; | 166 | ctrl->value = data[1]; |
82 | return 0; | 167 | return 0; |
83 | case V4L2_CID_RED_BALANCE: | 168 | case V4L2_CID_RED_BALANCE: |
84 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, | 169 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2, |
85 | 2+1, data) < 0) | 170 | data) < 0) |
86 | return -EIO; | 171 | return -EIO; |
87 | ctrl->value = data[3]; | 172 | ctrl->value = data[1]; |
88 | return 0; | 173 | return 0; |
89 | case V4L2_CID_BLUE_BALANCE: | 174 | case V4L2_CID_BLUE_BALANCE: |
90 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, | 175 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2, |
91 | 2+1, data) < 0) | 176 | data) < 0) |
92 | return -EIO; | 177 | return -EIO; |
93 | ctrl->value = data[3]; | 178 | ctrl->value = data[1]; |
94 | return 0; | 179 | return 0; |
95 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 180 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
96 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, | 181 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2, |
97 | 2+1, data) < 0) | 182 | data) < 0) |
98 | return -EIO; | 183 | return -EIO; |
99 | ctrl->value = data[3]; | 184 | ctrl->value = data[1]; |
100 | return 0; | 185 | return 0; |
101 | case V4L2_CID_HFLIP: | 186 | case V4L2_CID_HFLIP: |
102 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, | 187 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
103 | 2+1, data) < 0) | 188 | data) < 0) |
104 | return -EIO; | 189 | return -EIO; |
105 | ctrl->value = data[3] & 0x20 ? 1 : 0; | 190 | ctrl->value = data[1] & 0x20 ? 1 : 0; |
106 | return 0; | 191 | return 0; |
107 | case V4L2_CID_VFLIP: | 192 | case V4L2_CID_VFLIP: |
108 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, | 193 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
109 | 2+1, data) < 0) | 194 | data) < 0) |
110 | return -EIO; | 195 | return -EIO; |
111 | ctrl->value = data[3] & 0x80 ? 1 : 0; | 196 | ctrl->value = data[1] & 0x80 ? 1 : 0; |
112 | return 0; | 197 | return 0; |
113 | default: | 198 | default: |
114 | return -EINVAL; | 199 | return -EINVAL; |
@@ -178,8 +263,19 @@ static int mi0360_set_crop(struct sn9c102_device* cam, | |||
178 | { | 263 | { |
179 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 264 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
180 | int err = 0; | 265 | int err = 0; |
181 | u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0, | 266 | u8 h_start = 0, v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; |
182 | v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; | 267 | |
268 | switch (sn9c102_get_bridge(cam)) { | ||
269 | case BRIDGE_SN9C103: | ||
270 | h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0; | ||
271 | break; | ||
272 | case BRIDGE_SN9C105: | ||
273 | case BRIDGE_SN9C120: | ||
274 | h_start = (u8)(rect->left - s->cropcap.bounds.left) + 1; | ||
275 | break; | ||
276 | default: | ||
277 | break; | ||
278 | } | ||
183 | 279 | ||
184 | err += sn9c102_write_reg(cam, h_start, 0x12); | 280 | err += sn9c102_write_reg(cam, h_start, 0x12); |
185 | err += sn9c102_write_reg(cam, v_start, 0x13); | 281 | err += sn9c102_write_reg(cam, v_start, 0x13); |
@@ -194,24 +290,30 @@ static int mi0360_set_pix_format(struct sn9c102_device* cam, | |||
194 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | 290 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
195 | int err = 0; | 291 | int err = 0; |
196 | 292 | ||
197 | if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { | 293 | if (pix->pixelformat == V4L2_PIX_FMT_SBGGR8) { |
198 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, | ||
199 | 0x0a, 0x00, 0x02, 0, 0); | ||
200 | err += sn9c102_write_reg(cam, 0x20, 0x19); | ||
201 | } else { | ||
202 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, | 294 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
203 | 0x0a, 0x00, 0x05, 0, 0); | 295 | 0x0a, 0x00, 0x05, 0, 0); |
204 | err += sn9c102_write_reg(cam, 0x60, 0x19); | 296 | err += sn9c102_write_reg(cam, 0x60, 0x19); |
297 | if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 || | ||
298 | sn9c102_get_bridge(cam) == BRIDGE_SN9C120) | ||
299 | err += sn9c102_write_reg(cam, 0xa6, 0x17); | ||
300 | } else { | ||
301 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, | ||
302 | 0x0a, 0x00, 0x02, 0, 0); | ||
303 | err += sn9c102_write_reg(cam, 0x20, 0x19); | ||
304 | if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 || | ||
305 | sn9c102_get_bridge(cam) == BRIDGE_SN9C120) | ||
306 | err += sn9c102_write_reg(cam, 0xa2, 0x17); | ||
205 | } | 307 | } |
206 | 308 | ||
207 | return err; | 309 | return err; |
208 | } | 310 | } |
209 | 311 | ||
210 | 312 | ||
211 | static struct sn9c102_sensor mi0360 = { | 313 | static const struct sn9c102_sensor mi0360 = { |
212 | .name = "MI-0360", | 314 | .name = "MI-0360", |
213 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 315 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
214 | .supported_bridge = BRIDGE_SN9C103, | 316 | .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, |
215 | .frequency = SN9C102_I2C_100KHZ, | 317 | .frequency = SN9C102_I2C_100KHZ, |
216 | .interface = SN9C102_I2C_2WIRES, | 318 | .interface = SN9C102_I2C_2WIRES, |
217 | .i2c_slave_id = 0x5d, | 319 | .i2c_slave_id = 0x5d, |
@@ -317,19 +419,31 @@ static struct sn9c102_sensor mi0360 = { | |||
317 | 419 | ||
318 | int sn9c102_probe_mi0360(struct sn9c102_device* cam) | 420 | int sn9c102_probe_mi0360(struct sn9c102_device* cam) |
319 | { | 421 | { |
320 | u8 data[5+1]; | ||
321 | int err; | ||
322 | 422 | ||
323 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, | 423 | u8 data[2]; |
324 | {0x28, 0x17}); | 424 | |
325 | if (err) | 425 | switch (sn9c102_get_bridge(cam)) { |
326 | return -EIO; | 426 | case BRIDGE_SN9C103: |
427 | if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, | ||
428 | {0x28, 0x17})) | ||
429 | return -EIO; | ||
430 | break; | ||
431 | case BRIDGE_SN9C105: | ||
432 | case BRIDGE_SN9C120: | ||
433 | if (sn9c102_write_const_regs(cam, {0x01, 0xf1}, {0x00, 0xf1}, | ||
434 | {0x01, 0x01}, {0x00, 0x01}, | ||
435 | {0x28, 0x17})) | ||
436 | return -EIO; | ||
437 | break; | ||
438 | default: | ||
439 | break; | ||
440 | } | ||
327 | 441 | ||
328 | if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00, | 442 | if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00, |
329 | 2+1, data) < 0) | 443 | 2, data) < 0) |
330 | return -EIO; | 444 | return -EIO; |
331 | 445 | ||
332 | if (data[2] != 0x82 || data[3] != 0x43) | 446 | if (data[0] != 0x82 || data[1] != 0x43) |
333 | return -ENODEV; | 447 | return -ENODEV; |
334 | 448 | ||
335 | sn9c102_attach_sensor(cam, &mi0360); | 449 | sn9c102_attach_sensor(cam, &mi0360); |
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7630.c b/drivers/media/video/sn9c102/sn9c102_ov7630.c index 31b6080b0615..e6832347894f 100644 --- a/drivers/media/video/sn9c102/sn9c102_ov7630.c +++ b/drivers/media/video/sn9c102/sn9c102_ov7630.c | |||
@@ -29,9 +29,8 @@ static int ov7630_init(struct sn9c102_device* cam) | |||
29 | switch (sn9c102_get_bridge(cam)) { | 29 | switch (sn9c102_get_bridge(cam)) { |
30 | case BRIDGE_SN9C101: | 30 | case BRIDGE_SN9C101: |
31 | case BRIDGE_SN9C102: | 31 | case BRIDGE_SN9C102: |
32 | err = sn9c102_write_const_regs(cam, {0x00, 0x14}, | 32 | err = sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, |
33 | {0x60, 0x17}, {0x0f, 0x18}, | 33 | {0x0f, 0x18}, {0x50, 0x19}); |
34 | {0x50, 0x19}); | ||
35 | 34 | ||
36 | err += sn9c102_i2c_write(cam, 0x12, 0x8d); | 35 | err += sn9c102_i2c_write(cam, 0x12, 0x8d); |
37 | err += sn9c102_i2c_write(cam, 0x12, 0x0d); | 36 | err += sn9c102_i2c_write(cam, 0x12, 0x0d); |
@@ -61,7 +60,6 @@ static int ov7630_init(struct sn9c102_device* cam) | |||
61 | err += sn9c102_i2c_write(cam, 0x71, 0x00); | 60 | err += sn9c102_i2c_write(cam, 0x71, 0x00); |
62 | err += sn9c102_i2c_write(cam, 0x74, 0x21); | 61 | err += sn9c102_i2c_write(cam, 0x74, 0x21); |
63 | err += sn9c102_i2c_write(cam, 0x7d, 0xf7); | 62 | err += sn9c102_i2c_write(cam, 0x7d, 0xf7); |
64 | |||
65 | break; | 63 | break; |
66 | case BRIDGE_SN9C103: | 64 | case BRIDGE_SN9C103: |
67 | err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, | 65 | err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, |
@@ -253,7 +251,7 @@ static int ov7630_set_pix_format(struct sn9c102_device* cam, | |||
253 | } | 251 | } |
254 | 252 | ||
255 | 253 | ||
256 | static struct sn9c102_sensor ov7630 = { | 254 | static const struct sn9c102_sensor ov7630 = { |
257 | .name = "OV7630", | 255 | .name = "OV7630", |
258 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 256 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
259 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, | 257 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, |
@@ -408,19 +406,16 @@ int sn9c102_probe_ov7630(struct sn9c102_device* cam) | |||
408 | switch (sn9c102_get_bridge(cam)) { | 406 | switch (sn9c102_get_bridge(cam)) { |
409 | case BRIDGE_SN9C101: | 407 | case BRIDGE_SN9C101: |
410 | case BRIDGE_SN9C102: | 408 | case BRIDGE_SN9C102: |
411 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, | 409 | err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, |
412 | {0x00, 0x01}, {0x28, 0x17}); | 410 | {0x28, 0x17}); |
413 | |||
414 | break; | 411 | break; |
415 | case BRIDGE_SN9C103: /* do _not_ change anything! */ | 412 | case BRIDGE_SN9C103: /* do _not_ change anything! */ |
416 | err = sn9c102_write_const_regs(cam, {0x09, 0x01}, | 413 | err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x42, 0x01}, |
417 | {0x42, 0x01}, {0x28, 0x17}, | 414 | {0x28, 0x17}, {0x44, 0x02}); |
418 | {0x44, 0x02}); | ||
419 | pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a); | 415 | pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a); |
420 | if (err || pid < 0) { /* try a different initialization */ | 416 | if (err || pid < 0) /* try a different initialization */ |
421 | err = sn9c102_write_reg(cam, 0x01, 0x01); | 417 | err += sn9c102_write_const_regs(cam, {0x01, 0x01}, |
422 | err += sn9c102_write_reg(cam, 0x00, 0x01); | 418 | {0x00, 0x01}); |
423 | } | ||
424 | break; | 419 | break; |
425 | default: | 420 | default: |
426 | break; | 421 | break; |
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7660.c b/drivers/media/video/sn9c102/sn9c102_ov7660.c index c898e948fe8d..4b6474048a72 100644 --- a/drivers/media/video/sn9c102/sn9c102_ov7660.c +++ b/drivers/media/video/sn9c102/sn9c102_ov7660.c | |||
@@ -104,8 +104,8 @@ static int ov7660_init(struct sn9c102_device* cam) | |||
104 | err += sn9c102_i2c_write(cam, 0x12, 0x80); | 104 | err += sn9c102_i2c_write(cam, 0x12, 0x80); |
105 | err += sn9c102_i2c_write(cam, 0x11, 0x09); | 105 | err += sn9c102_i2c_write(cam, 0x11, 0x09); |
106 | err += sn9c102_i2c_write(cam, 0x00, 0x0A); | 106 | err += sn9c102_i2c_write(cam, 0x00, 0x0A); |
107 | err += sn9c102_i2c_write(cam, 0x01, 0x78); | 107 | err += sn9c102_i2c_write(cam, 0x01, 0x80); |
108 | err += sn9c102_i2c_write(cam, 0x02, 0x90); | 108 | err += sn9c102_i2c_write(cam, 0x02, 0x80); |
109 | err += sn9c102_i2c_write(cam, 0x03, 0x00); | 109 | err += sn9c102_i2c_write(cam, 0x03, 0x00); |
110 | err += sn9c102_i2c_write(cam, 0x04, 0x00); | 110 | err += sn9c102_i2c_write(cam, 0x04, 0x00); |
111 | err += sn9c102_i2c_write(cam, 0x05, 0x08); | 111 | err += sn9c102_i2c_write(cam, 0x05, 0x08); |
@@ -122,7 +122,7 @@ static int ov7660_init(struct sn9c102_device* cam) | |||
122 | err += sn9c102_i2c_write(cam, 0x10, 0x20); | 122 | err += sn9c102_i2c_write(cam, 0x10, 0x20); |
123 | err += sn9c102_i2c_write(cam, 0x11, 0x03); | 123 | err += sn9c102_i2c_write(cam, 0x11, 0x03); |
124 | err += sn9c102_i2c_write(cam, 0x12, 0x05); | 124 | err += sn9c102_i2c_write(cam, 0x12, 0x05); |
125 | err += sn9c102_i2c_write(cam, 0x13, 0xF8); | 125 | err += sn9c102_i2c_write(cam, 0x13, 0xC7); |
126 | err += sn9c102_i2c_write(cam, 0x14, 0x2C); | 126 | err += sn9c102_i2c_write(cam, 0x14, 0x2C); |
127 | err += sn9c102_i2c_write(cam, 0x15, 0x00); | 127 | err += sn9c102_i2c_write(cam, 0x15, 0x00); |
128 | err += sn9c102_i2c_write(cam, 0x16, 0x02); | 128 | err += sn9c102_i2c_write(cam, 0x16, 0x02); |
@@ -162,7 +162,7 @@ static int ov7660_init(struct sn9c102_device* cam) | |||
162 | err += sn9c102_i2c_write(cam, 0x38, 0x02); | 162 | err += sn9c102_i2c_write(cam, 0x38, 0x02); |
163 | err += sn9c102_i2c_write(cam, 0x39, 0x43); | 163 | err += sn9c102_i2c_write(cam, 0x39, 0x43); |
164 | err += sn9c102_i2c_write(cam, 0x3A, 0x00); | 164 | err += sn9c102_i2c_write(cam, 0x3A, 0x00); |
165 | err += sn9c102_i2c_write(cam, 0x3B, 0x02); | 165 | err += sn9c102_i2c_write(cam, 0x3B, 0x0A); |
166 | err += sn9c102_i2c_write(cam, 0x3C, 0x6C); | 166 | err += sn9c102_i2c_write(cam, 0x3C, 0x6C); |
167 | err += sn9c102_i2c_write(cam, 0x3D, 0x99); | 167 | err += sn9c102_i2c_write(cam, 0x3D, 0x99); |
168 | err += sn9c102_i2c_write(cam, 0x3E, 0x0E); | 168 | err += sn9c102_i2c_write(cam, 0x3E, 0x0E); |
@@ -281,25 +281,34 @@ static int ov7660_get_ctrl(struct sn9c102_device* cam, | |||
281 | return -EIO; | 281 | return -EIO; |
282 | break; | 282 | break; |
283 | case V4L2_CID_DO_WHITE_BALANCE: | 283 | case V4L2_CID_DO_WHITE_BALANCE: |
284 | ctrl->value = sn9c102_pread_reg(cam, 0x02); | 284 | if ((ctrl->value = sn9c102_read_reg(cam, 0x02)) < 0) |
285 | return -EIO; | ||
285 | ctrl->value = (ctrl->value & 0x04) ? 1 : 0; | 286 | ctrl->value = (ctrl->value & 0x04) ? 1 : 0; |
286 | break; | 287 | break; |
287 | case V4L2_CID_RED_BALANCE: | 288 | case V4L2_CID_RED_BALANCE: |
288 | ctrl->value = sn9c102_pread_reg(cam, 0x05); | 289 | if ((ctrl->value = sn9c102_read_reg(cam, 0x05)) < 0) |
290 | return -EIO; | ||
289 | ctrl->value &= 0x7f; | 291 | ctrl->value &= 0x7f; |
290 | break; | 292 | break; |
291 | case V4L2_CID_BLUE_BALANCE: | 293 | case V4L2_CID_BLUE_BALANCE: |
292 | ctrl->value = sn9c102_pread_reg(cam, 0x06); | 294 | if ((ctrl->value = sn9c102_read_reg(cam, 0x06)) < 0) |
295 | return -EIO; | ||
293 | ctrl->value &= 0x7f; | 296 | ctrl->value &= 0x7f; |
294 | break; | 297 | break; |
295 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 298 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
296 | ctrl->value = sn9c102_pread_reg(cam, 0x07); | 299 | if ((ctrl->value = sn9c102_read_reg(cam, 0x07)) < 0) |
300 | return -EIO; | ||
297 | ctrl->value &= 0x7f; | 301 | ctrl->value &= 0x7f; |
298 | break; | 302 | break; |
303 | case SN9C102_V4L2_CID_BAND_FILTER: | ||
304 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x3b)) < 0) | ||
305 | return -EIO; | ||
306 | ctrl->value &= 0x08; | ||
307 | break; | ||
299 | case V4L2_CID_GAIN: | 308 | case V4L2_CID_GAIN: |
300 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0) | 309 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0) |
301 | return -EIO; | 310 | return -EIO; |
302 | ctrl->value &= 0x7f; | 311 | ctrl->value &= 0x1f; |
303 | break; | 312 | break; |
304 | case V4L2_CID_AUTOGAIN: | 313 | case V4L2_CID_AUTOGAIN: |
305 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0) | 314 | if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0) |
@@ -335,12 +344,15 @@ static int ov7660_set_ctrl(struct sn9c102_device* cam, | |||
335 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 344 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
336 | err += sn9c102_write_reg(cam, ctrl->value, 0x07); | 345 | err += sn9c102_write_reg(cam, ctrl->value, 0x07); |
337 | break; | 346 | break; |
347 | case SN9C102_V4L2_CID_BAND_FILTER: | ||
348 | err += sn9c102_i2c_write(cam, ctrl->value << 3, 0x3b); | ||
349 | break; | ||
338 | case V4L2_CID_GAIN: | 350 | case V4L2_CID_GAIN: |
339 | err += sn9c102_i2c_write(cam, 0x00, ctrl->value); | 351 | err += sn9c102_i2c_write(cam, 0x00, 0x60 + ctrl->value); |
340 | break; | 352 | break; |
341 | case V4L2_CID_AUTOGAIN: | 353 | case V4L2_CID_AUTOGAIN: |
342 | err += sn9c102_i2c_write(cam, 0x13, 0xf0 | ctrl->value | | 354 | err += sn9c102_i2c_write(cam, 0x13, 0xc0 | |
343 | (ctrl->value << 1)); | 355 | (ctrl->value * 0x07)); |
344 | break; | 356 | break; |
345 | default: | 357 | default: |
346 | return -EINVAL; | 358 | return -EINVAL; |
@@ -386,7 +398,7 @@ static int ov7660_set_pix_format(struct sn9c102_device* cam, | |||
386 | } | 398 | } |
387 | 399 | ||
388 | 400 | ||
389 | static struct sn9c102_sensor ov7660 = { | 401 | static const struct sn9c102_sensor ov7660 = { |
390 | .name = "OV7660", | 402 | .name = "OV7660", |
391 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 403 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
392 | .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120, | 404 | .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120, |
@@ -401,9 +413,9 @@ static struct sn9c102_sensor ov7660 = { | |||
401 | .type = V4L2_CTRL_TYPE_INTEGER, | 413 | .type = V4L2_CTRL_TYPE_INTEGER, |
402 | .name = "global gain", | 414 | .name = "global gain", |
403 | .minimum = 0x00, | 415 | .minimum = 0x00, |
404 | .maximum = 0x7f, | 416 | .maximum = 0x1f, |
405 | .step = 0x01, | 417 | .step = 0x01, |
406 | .default_value = 0x0a, | 418 | .default_value = 0x09, |
407 | .flags = 0, | 419 | .flags = 0, |
408 | }, | 420 | }, |
409 | { | 421 | { |
@@ -413,7 +425,7 @@ static struct sn9c102_sensor ov7660 = { | |||
413 | .minimum = 0x00, | 425 | .minimum = 0x00, |
414 | .maximum = 0xff, | 426 | .maximum = 0xff, |
415 | .step = 0x01, | 427 | .step = 0x01, |
416 | .default_value = 0x50, | 428 | .default_value = 0x27, |
417 | .flags = 0, | 429 | .flags = 0, |
418 | }, | 430 | }, |
419 | { | 431 | { |
@@ -433,7 +445,7 @@ static struct sn9c102_sensor ov7660 = { | |||
433 | .minimum = 0x00, | 445 | .minimum = 0x00, |
434 | .maximum = 0x7f, | 446 | .maximum = 0x7f, |
435 | .step = 0x01, | 447 | .step = 0x01, |
436 | .default_value = 0x1f, | 448 | .default_value = 0x14, |
437 | .flags = 0, | 449 | .flags = 0, |
438 | }, | 450 | }, |
439 | { | 451 | { |
@@ -443,7 +455,7 @@ static struct sn9c102_sensor ov7660 = { | |||
443 | .minimum = 0x00, | 455 | .minimum = 0x00, |
444 | .maximum = 0x7f, | 456 | .maximum = 0x7f, |
445 | .step = 0x01, | 457 | .step = 0x01, |
446 | .default_value = 0x1e, | 458 | .default_value = 0x14, |
447 | .flags = 0, | 459 | .flags = 0, |
448 | }, | 460 | }, |
449 | { | 461 | { |
@@ -453,7 +465,7 @@ static struct sn9c102_sensor ov7660 = { | |||
453 | .minimum = 0x00, | 465 | .minimum = 0x00, |
454 | .maximum = 0x01, | 466 | .maximum = 0x01, |
455 | .step = 0x01, | 467 | .step = 0x01, |
456 | .default_value = 0x00, | 468 | .default_value = 0x01, |
457 | .flags = 0, | 469 | .flags = 0, |
458 | }, | 470 | }, |
459 | { | 471 | { |
@@ -463,7 +475,17 @@ static struct sn9c102_sensor ov7660 = { | |||
463 | .minimum = 0x00, | 475 | .minimum = 0x00, |
464 | .maximum = 0x7f, | 476 | .maximum = 0x7f, |
465 | .step = 0x01, | 477 | .step = 0x01, |
466 | .default_value = 0x20, | 478 | .default_value = 0x14, |
479 | .flags = 0, | ||
480 | }, | ||
481 | { | ||
482 | .id = SN9C102_V4L2_CID_BAND_FILTER, | ||
483 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
484 | .name = "band filter", | ||
485 | .minimum = 0x00, | ||
486 | .maximum = 0x01, | ||
487 | .step = 0x01, | ||
488 | .default_value = 0x00, | ||
467 | .flags = 0, | 489 | .flags = 0, |
468 | }, | 490 | }, |
469 | }, | 491 | }, |
@@ -508,6 +530,7 @@ int sn9c102_probe_ov7660(struct sn9c102_device* cam) | |||
508 | return -EIO; | 530 | return -EIO; |
509 | if (pid != 0x76 || ver != 0x60) | 531 | if (pid != 0x76 || ver != 0x60) |
510 | return -ENODEV; | 532 | return -ENODEV; |
533 | |||
511 | sn9c102_attach_sensor(cam, &ov7660); | 534 | sn9c102_attach_sensor(cam, &ov7660); |
512 | 535 | ||
513 | return 0; | 536 | return 0; |
diff --git a/drivers/media/video/sn9c102/sn9c102_pas106b.c b/drivers/media/video/sn9c102/sn9c102_pas106b.c index 67151964801f..360f2a848bc0 100644 --- a/drivers/media/video/sn9c102/sn9c102_pas106b.c +++ b/drivers/media/video/sn9c102/sn9c102_pas106b.c | |||
@@ -163,7 +163,7 @@ static int pas106b_set_pix_format(struct sn9c102_device* cam, | |||
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | static struct sn9c102_sensor pas106b = { | 166 | static const struct sn9c102_sensor pas106b = { |
167 | .name = "PAS106B", | 167 | .name = "PAS106B", |
168 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 168 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
169 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 169 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
@@ -273,23 +273,21 @@ static struct sn9c102_sensor pas106b = { | |||
273 | 273 | ||
274 | int sn9c102_probe_pas106b(struct sn9c102_device* cam) | 274 | int sn9c102_probe_pas106b(struct sn9c102_device* cam) |
275 | { | 275 | { |
276 | int r0 = 0, r1 = 0, err; | 276 | int r0 = 0, r1 = 0; |
277 | unsigned int pid = 0; | 277 | unsigned int pid = 0; |
278 | 278 | ||
279 | /* | 279 | /* |
280 | Minimal initialization to enable the I2C communication | 280 | Minimal initialization to enable the I2C communication |
281 | NOTE: do NOT change the values! | 281 | NOTE: do NOT change the values! |
282 | */ | 282 | */ |
283 | err = sn9c102_write_const_regs(cam, | 283 | if (sn9c102_write_const_regs(cam, |
284 | {0x01, 0x01}, /* sensor power down */ | 284 | {0x01, 0x01}, /* sensor power down */ |
285 | {0x00, 0x01}, /* sensor power on */ | 285 | {0x00, 0x01}, /* sensor power on */ |
286 | {0x28, 0x17});/* sensor clock 24 MHz */ | 286 | {0x28, 0x17})) /* sensor clock at 24 MHz */ |
287 | if (err) | ||
288 | return -EIO; | 287 | return -EIO; |
289 | 288 | ||
290 | r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00); | 289 | r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00); |
291 | r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01); | 290 | r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01); |
292 | |||
293 | if (r0 < 0 || r1 < 0) | 291 | if (r0 < 0 || r1 < 0) |
294 | return -EIO; | 292 | return -EIO; |
295 | 293 | ||
diff --git a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c index c1b8d6b63b47..ca4a1506ed3d 100644 --- a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c +++ b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c | |||
@@ -35,29 +35,28 @@ static int pas202bcb_init(struct sn9c102_device* cam) | |||
35 | switch (sn9c102_get_bridge(cam)) { | 35 | switch (sn9c102_get_bridge(cam)) { |
36 | case BRIDGE_SN9C101: | 36 | case BRIDGE_SN9C101: |
37 | case BRIDGE_SN9C102: | 37 | case BRIDGE_SN9C102: |
38 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, | 38 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, |
39 | {0x00, 0x11}, {0x00, 0x14}, | 39 | {0x00, 0x14}, {0x20, 0x17}, |
40 | {0x20, 0x17}, {0x30, 0x19}, | 40 | {0x30, 0x19}, {0x09, 0x18}); |
41 | {0x09, 0x18}); | ||
42 | break; | 41 | break; |
43 | case BRIDGE_SN9C103: | 42 | case BRIDGE_SN9C103: |
44 | err = sn9c102_write_const_regs(cam, {0x00, 0x02}, | 43 | err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, |
45 | {0x00, 0x03}, {0x1a, 0x04}, | 44 | {0x1a, 0x04}, {0x20, 0x05}, |
46 | {0x20, 0x05}, {0x20, 0x06}, | 45 | {0x20, 0x06}, {0x20, 0x07}, |
47 | {0x20, 0x07}, {0x00, 0x10}, | 46 | {0x00, 0x10}, {0x00, 0x11}, |
48 | {0x00, 0x11}, {0x00, 0x14}, | 47 | {0x00, 0x14}, {0x20, 0x17}, |
49 | {0x20, 0x17}, {0x30, 0x19}, | 48 | {0x30, 0x19}, {0x09, 0x18}, |
50 | {0x09, 0x18}, {0x02, 0x1c}, | 49 | {0x02, 0x1c}, {0x03, 0x1d}, |
51 | {0x03, 0x1d}, {0x0f, 0x1e}, | 50 | {0x0f, 0x1e}, {0x0c, 0x1f}, |
52 | {0x0c, 0x1f}, {0x00, 0x20}, | 51 | {0x00, 0x20}, {0x10, 0x21}, |
53 | {0x10, 0x21}, {0x20, 0x22}, | 52 | {0x20, 0x22}, {0x30, 0x23}, |
54 | {0x30, 0x23}, {0x40, 0x24}, | 53 | {0x40, 0x24}, {0x50, 0x25}, |
55 | {0x50, 0x25}, {0x60, 0x26}, | 54 | {0x60, 0x26}, {0x70, 0x27}, |
56 | {0x70, 0x27}, {0x80, 0x28}, | 55 | {0x80, 0x28}, {0x90, 0x29}, |
57 | {0x90, 0x29}, {0xa0, 0x2a}, | 56 | {0xa0, 0x2a}, {0xb0, 0x2b}, |
58 | {0xb0, 0x2b}, {0xc0, 0x2c}, | 57 | {0xc0, 0x2c}, {0xd0, 0x2d}, |
59 | {0xd0, 0x2d}, {0xe0, 0x2e}, | 58 | {0xe0, 0x2e}, {0xf0, 0x2f}, |
60 | {0xf0, 0x2f}, {0xff, 0x30}); | 59 | {0xff, 0x30}); |
61 | break; | 60 | break; |
62 | default: | 61 | default: |
63 | break; | 62 | break; |
@@ -197,7 +196,7 @@ static int pas202bcb_set_crop(struct sn9c102_device* cam, | |||
197 | } | 196 | } |
198 | 197 | ||
199 | 198 | ||
200 | static struct sn9c102_sensor pas202bcb = { | 199 | static const struct sn9c102_sensor pas202bcb = { |
201 | .name = "PAS202BCB", | 200 | .name = "PAS202BCB", |
202 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 201 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
203 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, | 202 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, |
@@ -313,9 +312,8 @@ int sn9c102_probe_pas202bcb(struct sn9c102_device* cam) | |||
313 | {0x28, 0x17});/* clock 24 MHz */ | 312 | {0x28, 0x17});/* clock 24 MHz */ |
314 | break; | 313 | break; |
315 | case BRIDGE_SN9C103: /* do _not_ change anything! */ | 314 | case BRIDGE_SN9C103: /* do _not_ change anything! */ |
316 | err = sn9c102_write_const_regs(cam, {0x09, 0x01}, | 315 | err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x44, 0x01}, |
317 | {0x44, 0x01}, {0x44, 0x02}, | 316 | {0x44, 0x02}, {0x29, 0x17}); |
318 | {0x29, 0x17}); | ||
319 | break; | 317 | break; |
320 | default: | 318 | default: |
321 | break; | 319 | break; |
diff --git a/drivers/media/video/sn9c102/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h index 1bbf64c897a2..2d7d786b8430 100644 --- a/drivers/media/video/sn9c102/sn9c102_sensor.h +++ b/drivers/media/video/sn9c102/sn9c102_sensor.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #define _SN9C102_SENSOR_H_ | 22 | #define _SN9C102_SENSOR_H_ |
23 | 23 | ||
24 | #include <linux/usb.h> | 24 | #include <linux/usb.h> |
25 | #include <linux/videodev.h> | 25 | #include <linux/videodev2.h> |
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/stddef.h> | 27 | #include <linux/stddef.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
@@ -74,7 +74,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id); | |||
74 | /* Attach a probed sensor to the camera. */ | 74 | /* Attach a probed sensor to the camera. */ |
75 | extern void | 75 | extern void |
76 | sn9c102_attach_sensor(struct sn9c102_device* cam, | 76 | sn9c102_attach_sensor(struct sn9c102_device* cam, |
77 | struct sn9c102_sensor* sensor); | 77 | const struct sn9c102_sensor* sensor); |
78 | 78 | ||
79 | /* | 79 | /* |
80 | Read/write routines: they always return -1 on error, 0 or the read value | 80 | Read/write routines: they always return -1 on error, 0 or the read value |
@@ -85,10 +85,11 @@ sn9c102_attach_sensor(struct sn9c102_device* cam, | |||
85 | */ | 85 | */ |
86 | 86 | ||
87 | /* The "try" I2C I/O versions are used when probing the sensor */ | 87 | /* The "try" I2C I/O versions are used when probing the sensor */ |
88 | extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*, | 88 | extern int sn9c102_i2c_try_write(struct sn9c102_device*, |
89 | u8 address, u8 value); | 89 | const struct sn9c102_sensor*, u8 address, |
90 | extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, | 90 | u8 value); |
91 | u8 address); | 91 | extern int sn9c102_i2c_try_read(struct sn9c102_device*, |
92 | const struct sn9c102_sensor*, u8 address); | ||
92 | 93 | ||
93 | /* | 94 | /* |
94 | These must be used if and only if the sensor doesn't implement the standard | 95 | These must be used if and only if the sensor doesn't implement the standard |
@@ -102,29 +103,31 @@ extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, | |||
102 | byte. | 103 | byte. |
103 | */ | 104 | */ |
104 | extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, | 105 | extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, |
105 | struct sn9c102_sensor* sensor, u8 n, | 106 | const struct sn9c102_sensor* sensor, u8 n, |
106 | u8 data0, u8 data1, u8 data2, u8 data3, | 107 | u8 data0, u8 data1, u8 data2, u8 data3, |
107 | u8 data4, u8 data5); | 108 | u8 data4, u8 data5); |
108 | extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, | 109 | extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, |
109 | struct sn9c102_sensor* sensor, u8 data0, | 110 | const struct sn9c102_sensor* sensor, |
110 | u8 data1, u8 n, u8 buffer[]); | 111 | u8 data0, u8 data1, u8 n, u8 buffer[]); |
111 | 112 | ||
112 | /* To be used after the sensor struct has been attached to the camera struct */ | 113 | /* To be used after the sensor struct has been attached to the camera struct */ |
113 | extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); | 114 | extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); |
114 | extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); | 115 | extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); |
115 | 116 | ||
116 | /* I/O on registers in the bridge. Could be used by the sensor methods too */ | 117 | /* I/O on registers in the bridge. Could be used by the sensor methods too */ |
118 | extern int sn9c102_read_reg(struct sn9c102_device*, u16 index); | ||
117 | extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); | 119 | extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); |
118 | extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); | 120 | extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); |
119 | extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2], | 121 | extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2], |
120 | int count); | 122 | int count); |
121 | /* | 123 | /* |
122 | * Write multiple registers with constant values. For example: | 124 | Write multiple registers with constant values. For example: |
123 | * sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); | 125 | sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); |
124 | */ | 126 | Register adresses must be < 256. |
125 | #define sn9c102_write_const_regs(device, data...) \ | 127 | */ |
126 | ({ const static u8 _data[][2] = {data}; \ | 128 | #define sn9c102_write_const_regs(sn9c102_device, data...) \ |
127 | sn9c102_write_regs(device, _data, ARRAY_SIZE(_data)); }) | 129 | ({ const static u8 _valreg[][2] = {data}; \ |
130 | sn9c102_write_regs(sn9c102_device, _valreg, ARRAY_SIZE(_valreg)); }) | ||
128 | 131 | ||
129 | /*****************************************************************************/ | 132 | /*****************************************************************************/ |
130 | 133 | ||
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c index 0e7ec8662c70..e7d2de2bace1 100644 --- a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c +++ b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c | |||
@@ -88,7 +88,7 @@ static int tas5110c1b_set_pix_format(struct sn9c102_device* cam, | |||
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | static struct sn9c102_sensor tas5110c1b = { | 91 | static const struct sn9c102_sensor tas5110c1b = { |
92 | .name = "TAS5110C1B", | 92 | .name = "TAS5110C1B", |
93 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 93 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
94 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 94 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110d.c b/drivers/media/video/sn9c102/sn9c102_tas5110d.c index 83a39e8b5e71..d32fdbccdc5e 100644 --- a/drivers/media/video/sn9c102/sn9c102_tas5110d.c +++ b/drivers/media/video/sn9c102/sn9c102_tas5110d.c | |||
@@ -68,7 +68,7 @@ static int tas5110d_set_pix_format(struct sn9c102_device* cam, | |||
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | static struct sn9c102_sensor tas5110d = { | 71 | static const struct sn9c102_sensor tas5110d = { |
72 | .name = "TAS5110D", | 72 | .name = "TAS5110D", |
73 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 73 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
74 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 74 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c index 50406503fc40..56fb1d575a8a 100644 --- a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c +++ b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c | |||
@@ -89,7 +89,7 @@ static int tas5130d1b_set_pix_format(struct sn9c102_device* cam, | |||
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | static struct sn9c102_sensor tas5130d1b = { | 92 | static const struct sn9c102_sensor tas5130d1b = { |
93 | .name = "TAS5130D1B", | 93 | .name = "TAS5130D1B", |
94 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 94 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
95 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, | 95 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
diff --git a/drivers/media/video/usbvideo/Kconfig b/drivers/media/video/usbvideo/Kconfig index a0fd82b924f2..e4cb99c1f94b 100644 --- a/drivers/media/video/usbvideo/Kconfig +++ b/drivers/media/video/usbvideo/Kconfig | |||
@@ -3,7 +3,7 @@ config VIDEO_USBVIDEO | |||
3 | 3 | ||
4 | config USB_VICAM | 4 | config USB_VICAM |
5 | tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)" | 5 | tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)" |
6 | depends on USB && VIDEO_DEV && VIDEO_V4L1 && EXPERIMENTAL | 6 | depends on VIDEO_V4L1 && EXPERIMENTAL |
7 | select VIDEO_USBVIDEO | 7 | select VIDEO_USBVIDEO |
8 | ---help--- | 8 | ---help--- |
9 | Say Y here if you have 3com homeconnect camera (vicam). | 9 | Say Y here if you have 3com homeconnect camera (vicam). |
@@ -13,7 +13,7 @@ config USB_VICAM | |||
13 | 13 | ||
14 | config USB_IBMCAM | 14 | config USB_IBMCAM |
15 | tristate "USB IBM (Xirlink) C-it Camera support" | 15 | tristate "USB IBM (Xirlink) C-it Camera support" |
16 | depends on USB && VIDEO_DEV && VIDEO_V4L1 | 16 | depends on VIDEO_V4L1 |
17 | select VIDEO_USBVIDEO | 17 | select VIDEO_USBVIDEO |
18 | ---help--- | 18 | ---help--- |
19 | Say Y here if you want to connect a IBM "C-It" camera, also known as | 19 | Say Y here if you want to connect a IBM "C-It" camera, also known as |
@@ -28,7 +28,7 @@ config USB_IBMCAM | |||
28 | 28 | ||
29 | config USB_KONICAWC | 29 | config USB_KONICAWC |
30 | tristate "USB Konica Webcam support" | 30 | tristate "USB Konica Webcam support" |
31 | depends on USB && VIDEO_DEV && VIDEO_V4L1 | 31 | depends on VIDEO_V4L1 |
32 | select VIDEO_USBVIDEO | 32 | select VIDEO_USBVIDEO |
33 | ---help--- | 33 | ---help--- |
34 | Say Y here if you want support for webcams based on a Konica | 34 | Say Y here if you want support for webcams based on a Konica |
@@ -39,7 +39,7 @@ config USB_KONICAWC | |||
39 | 39 | ||
40 | config USB_QUICKCAM_MESSENGER | 40 | config USB_QUICKCAM_MESSENGER |
41 | tristate "USB Logitech Quickcam Messenger" | 41 | tristate "USB Logitech Quickcam Messenger" |
42 | depends on USB && VIDEO_DEV && VIDEO_V4L1 | 42 | depends on VIDEO_V4L1 |
43 | select VIDEO_USBVIDEO | 43 | select VIDEO_USBVIDEO |
44 | ---help--- | 44 | ---help--- |
45 | Say Y or M here to enable support for the USB Logitech Quickcam | 45 | Say Y or M here to enable support for the USB Logitech Quickcam |
diff --git a/drivers/media/video/usbvision/Kconfig b/drivers/media/video/usbvision/Kconfig index c43a5d899091..fc24ef05b3f3 100644 --- a/drivers/media/video/usbvision/Kconfig +++ b/drivers/media/video/usbvision/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config VIDEO_USBVISION | 1 | config VIDEO_USBVISION |
2 | tristate "USB video devices based on Nogatech NT1003/1004/1005" | 2 | tristate "USB video devices based on Nogatech NT1003/1004/1005" |
3 | depends on I2C && VIDEO_V4L2 && USB | 3 | depends on I2C && VIDEO_V4L2 |
4 | select VIDEO_TUNER | 4 | select VIDEO_TUNER |
5 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO | 5 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO |
6 | ---help--- | 6 | ---help--- |
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index a861e150865e..ede8543818bf 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c | |||
@@ -127,7 +127,7 @@ set_v4l_control(struct inode *inode, | |||
127 | 127 | ||
128 | /* ----------------------------------------------------------------- */ | 128 | /* ----------------------------------------------------------------- */ |
129 | 129 | ||
130 | static int palette2pixelformat[] = { | 130 | const static unsigned int palette2pixelformat[] = { |
131 | [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY, | 131 | [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY, |
132 | [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555, | 132 | [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555, |
133 | [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565, | 133 | [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565, |
@@ -145,7 +145,7 @@ static int palette2pixelformat[] = { | |||
145 | [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P, | 145 | [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P, |
146 | }; | 146 | }; |
147 | 147 | ||
148 | static unsigned int | 148 | static unsigned int __attribute_pure__ |
149 | palette_to_pixelformat(unsigned int palette) | 149 | palette_to_pixelformat(unsigned int palette) |
150 | { | 150 | { |
151 | if (palette < ARRAY_SIZE(palette2pixelformat)) | 151 | if (palette < ARRAY_SIZE(palette2pixelformat)) |
@@ -154,8 +154,8 @@ palette_to_pixelformat(unsigned int palette) | |||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | static unsigned int | 157 | static unsigned int __attribute_const__ |
158 | pixelformat_to_palette(int pixelformat) | 158 | pixelformat_to_palette(unsigned int pixelformat) |
159 | { | 159 | { |
160 | int palette = 0; | 160 | int palette = 0; |
161 | switch (pixelformat) | 161 | switch (pixelformat) |
@@ -616,6 +616,8 @@ v4l_compat_translate_ioctl(struct inode *inode, | |||
616 | case VIDIOCSPICT: /* set tone controls & partial capture format */ | 616 | case VIDIOCSPICT: /* set tone controls & partial capture format */ |
617 | { | 617 | { |
618 | struct video_picture *pict = arg; | 618 | struct video_picture *pict = arg; |
619 | int mem_err = 0, ovl_err = 0; | ||
620 | |||
619 | memset(&fbuf2, 0, sizeof(fbuf2)); | 621 | memset(&fbuf2, 0, sizeof(fbuf2)); |
620 | 622 | ||
621 | set_v4l_control(inode, file, | 623 | set_v4l_control(inode, file, |
@@ -628,33 +630,59 @@ v4l_compat_translate_ioctl(struct inode *inode, | |||
628 | V4L2_CID_SATURATION, pict->colour, drv); | 630 | V4L2_CID_SATURATION, pict->colour, drv); |
629 | set_v4l_control(inode, file, | 631 | set_v4l_control(inode, file, |
630 | V4L2_CID_WHITENESS, pict->whiteness, drv); | 632 | V4L2_CID_WHITENESS, pict->whiteness, drv); |
633 | /* | ||
634 | * V4L1 uses this ioctl to set both memory capture and overlay | ||
635 | * pixel format, while V4L2 has two different ioctls for this. | ||
636 | * Some cards may not support one or the other, and may support | ||
637 | * different pixel formats for memory vs overlay. | ||
638 | */ | ||
631 | 639 | ||
632 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); | 640 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
633 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 641 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
634 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | 642 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); |
635 | if (err < 0) | 643 | /* If VIDIOC_G_FMT failed, then the driver likely doesn't |
644 | support memory capture. Trying to set the memory capture | ||
645 | parameters would be pointless. */ | ||
646 | if (err < 0) { | ||
636 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err); | 647 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err); |
637 | if (fmt2->fmt.pix.pixelformat != | 648 | mem_err = -1000; /* didn't even try */ |
638 | palette_to_pixelformat(pict->palette)) { | 649 | } else if (fmt2->fmt.pix.pixelformat != |
650 | palette_to_pixelformat(pict->palette)) { | ||
639 | fmt2->fmt.pix.pixelformat = palette_to_pixelformat( | 651 | fmt2->fmt.pix.pixelformat = palette_to_pixelformat( |
640 | pict->palette); | 652 | pict->palette); |
641 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | 653 | mem_err = drv(inode, file, VIDIOC_S_FMT, fmt2); |
642 | if (err < 0) | 654 | if (mem_err < 0) |
643 | dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",err); | 655 | dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n", |
656 | mem_err); | ||
644 | } | 657 | } |
645 | 658 | ||
646 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); | 659 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); |
647 | if (err < 0) | 660 | /* If VIDIOC_G_FBUF failed, then the driver likely doesn't |
661 | support overlay. Trying to set the overlay parameters | ||
662 | would be quite pointless. */ | ||
663 | if (err < 0) { | ||
648 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err); | 664 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err); |
649 | if (fbuf2.fmt.pixelformat != | 665 | ovl_err = -1000; /* didn't even try */ |
650 | palette_to_pixelformat(pict->palette)) { | 666 | } else if (fbuf2.fmt.pixelformat != |
667 | palette_to_pixelformat(pict->palette)) { | ||
651 | fbuf2.fmt.pixelformat = palette_to_pixelformat( | 668 | fbuf2.fmt.pixelformat = palette_to_pixelformat( |
652 | pict->palette); | 669 | pict->palette); |
653 | err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); | 670 | ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); |
654 | if (err < 0) | 671 | if (ovl_err < 0) |
655 | dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",err); | 672 | dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n", |
656 | err = 0; /* likely fails for non-root */ | 673 | ovl_err); |
657 | } | 674 | } |
675 | if (ovl_err < 0 && mem_err < 0) | ||
676 | /* ioctl failed, couldn't set either parameter */ | ||
677 | if (mem_err != -1000) { | ||
678 | err = mem_err; | ||
679 | } else if (ovl_err == -EPERM) { | ||
680 | err = 0; | ||
681 | } else { | ||
682 | err = ovl_err; | ||
683 | } | ||
684 | else | ||
685 | err = 0; | ||
658 | break; | 686 | break; |
659 | } | 687 | } |
660 | case VIDIOCGTUNER: /* get tuner information */ | 688 | case VIDIOCGTUNER: /* get tuner information */ |
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c index 459786ff459a..a32dfbe0585a 100644 --- a/drivers/media/video/video-buf.c +++ b/drivers/media/video/video-buf.c | |||
@@ -702,9 +702,7 @@ videobuf_qbuf(struct videobuf_queue *q, | |||
702 | dprintk(1,"qbuf: memory type is wrong.\n"); | 702 | dprintk(1,"qbuf: memory type is wrong.\n"); |
703 | goto done; | 703 | goto done; |
704 | } | 704 | } |
705 | if (buf->state == STATE_QUEUED || | 705 | if (buf->state != STATE_NEEDS_INIT && buf->state != STATE_IDLE) { |
706 | buf->state == STATE_PREPARED || | ||
707 | buf->state == STATE_ACTIVE) { | ||
708 | dprintk(1,"qbuf: buffer is already queued or active.\n"); | 706 | dprintk(1,"qbuf: buffer is already queued or active.\n"); |
709 | goto done; | 707 | goto done; |
710 | } | 708 | } |
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 5263b50463e1..b876aca69c73 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -433,13 +433,43 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
433 | int ret = -EINVAL; | 433 | int ret = -EINVAL; |
434 | 434 | ||
435 | if ( (vfd->debug & V4L2_DEBUG_IOCTL) && | 435 | if ( (vfd->debug & V4L2_DEBUG_IOCTL) && |
436 | !(vfd->debug | V4L2_DEBUG_IOCTL_ARG)) { | 436 | !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { |
437 | v4l_print_ioctl(vfd->name, cmd); | 437 | v4l_print_ioctl(vfd->name, cmd); |
438 | } | 438 | } |
439 | 439 | ||
440 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
441 | /*********************************************************** | ||
442 | Handles calls to the obsoleted V4L1 API | ||
443 | Due to the nature of VIDIOCGMBUF, each driver that supports | ||
444 | V4L1 should implement its own handler for this ioctl. | ||
445 | ***********************************************************/ | ||
446 | |||
447 | /* --- streaming capture ------------------------------------- */ | ||
448 | if (cmd == VIDIOCGMBUF) { | ||
449 | struct video_mbuf *p=arg; | ||
450 | |||
451 | memset(p,0,sizeof(p)); | ||
452 | |||
453 | if (!vfd->vidiocgmbuf) | ||
454 | return ret; | ||
455 | ret=vfd->vidiocgmbuf(file, fh, p); | ||
456 | if (!ret) | ||
457 | dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n", | ||
458 | p->size, p->frames, | ||
459 | (unsigned long)p->offsets); | ||
460 | return ret; | ||
461 | } | ||
462 | |||
463 | /******************************************************** | ||
464 | All other V4L1 calls are handled by v4l1_compat module. | ||
465 | Those calls will be translated into V4L2 calls, and | ||
466 | __video_do_ioctl will be called again, with one or more | ||
467 | V4L2 ioctls. | ||
468 | ********************************************************/ | ||
440 | if (_IOC_TYPE(cmd)=='v') | 469 | if (_IOC_TYPE(cmd)=='v') |
441 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, | 470 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, |
442 | __video_do_ioctl); | 471 | __video_do_ioctl); |
472 | #endif | ||
443 | 473 | ||
444 | switch(cmd) { | 474 | switch(cmd) { |
445 | /* --- capabilities ------------------------------------------ */ | 475 | /* --- capabilities ------------------------------------------ */ |
@@ -791,24 +821,6 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
791 | ret=vfd->vidioc_overlay(file, fh, *i); | 821 | ret=vfd->vidioc_overlay(file, fh, *i); |
792 | break; | 822 | break; |
793 | } | 823 | } |
794 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
795 | /* --- streaming capture ------------------------------------- */ | ||
796 | case VIDIOCGMBUF: | ||
797 | { | ||
798 | struct video_mbuf *p=arg; | ||
799 | |||
800 | memset(p,0,sizeof(p)); | ||
801 | |||
802 | if (!vfd->vidiocgmbuf) | ||
803 | break; | ||
804 | ret=vfd->vidiocgmbuf(file, fh, p); | ||
805 | if (!ret) | ||
806 | dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n", | ||
807 | p->size, p->frames, | ||
808 | (unsigned long)p->offsets); | ||
809 | break; | ||
810 | } | ||
811 | #endif | ||
812 | case VIDIOC_G_FBUF: | 824 | case VIDIOC_G_FBUF: |
813 | { | 825 | { |
814 | struct v4l2_framebuffer *p=arg; | 826 | struct v4l2_framebuffer *p=arg; |
diff --git a/drivers/media/video/zc0301/Kconfig b/drivers/media/video/zc0301/Kconfig index a859a6920189..47cd93f9c7de 100644 --- a/drivers/media/video/zc0301/Kconfig +++ b/drivers/media/video/zc0301/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config USB_ZC0301 | 1 | config USB_ZC0301 |
2 | tristate "USB ZC0301[P] Image Processor and Control Chip support" | 2 | tristate "USB ZC0301[P] Image Processor and Control Chip support" |
3 | depends on USB && VIDEO_V4L1 | 3 | depends on VIDEO_V4L1 |
4 | ---help--- | 4 | ---help--- |
5 | Say Y here if you want support for cameras based on the ZC0301 or | 5 | Say Y here if you want support for cameras based on the ZC0301 or |
6 | ZC0301P Image Processors and Control Chips. | 6 | ZC0301P Image Processors and Control Chips. |
diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig index 71037f91c222..c88cc75ab49b 100644 --- a/drivers/message/fusion/Kconfig +++ b/drivers/message/fusion/Kconfig | |||
@@ -1,5 +1,6 @@ | |||
1 | 1 | ||
2 | menu "Fusion MPT device support" | 2 | menu "Fusion MPT device support" |
3 | depends on PCI | ||
3 | 4 | ||
4 | config FUSION | 5 | config FUSION |
5 | bool | 6 | bool |
diff --git a/drivers/message/i2o/Kconfig b/drivers/message/i2o/Kconfig index 6443392bffff..f4ac21e5771e 100644 --- a/drivers/message/i2o/Kconfig +++ b/drivers/message/i2o/Kconfig | |||
@@ -1,5 +1,6 @@ | |||
1 | 1 | ||
2 | menu "I2O device support" | 2 | menu "I2O device support" |
3 | depends on PCI | ||
3 | 4 | ||
4 | config I2O | 5 | config I2O |
5 | tristate "I2O support" | 6 | tristate "I2O support" |
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index ab6e985275b2..a20a51efe118 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Multifunction device drivers" | 5 | menu "Multifunction device drivers" |
6 | depends on HAS_IOMEM | ||
6 | 7 | ||
7 | config MFD_SM501 | 8 | config MFD_SM501 |
8 | tristate "Support for Silicon Motion SM501" | 9 | tristate "Support for Silicon Motion SM501" |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 877e7909a0e5..2f2fbffafbe0 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -130,7 +130,7 @@ config SONY_LAPTOP | |||
130 | 130 | ||
131 | Read <file:Documentation/sony-laptop.txt> for more information. | 131 | Read <file:Documentation/sony-laptop.txt> for more information. |
132 | 132 | ||
133 | config SONY_LAPTOP_OLD | 133 | config SONYPI_COMPAT |
134 | bool "Sonypi compatibility" | 134 | bool "Sonypi compatibility" |
135 | depends on SONY_LAPTOP | 135 | depends on SONY_LAPTOP |
136 | ---help--- | 136 | ---help--- |
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index 65c32a95e121..4f9060a2a2f2 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c | |||
@@ -30,7 +30,7 @@ | |||
30 | * Eric Burghard - LED display support for W1N | 30 | * Eric Burghard - LED display support for W1N |
31 | * Josh Green - Light Sens support | 31 | * Josh Green - Light Sens support |
32 | * Thomas Tuttle - His first patch for led support was very helpfull | 32 | * Thomas Tuttle - His first patch for led support was very helpfull |
33 | * | 33 | * Sam Lin - GPS support |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <linux/autoconf.h> | 36 | #include <linux/autoconf.h> |
@@ -48,7 +48,7 @@ | |||
48 | #include <acpi/acpi_bus.h> | 48 | #include <acpi/acpi_bus.h> |
49 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
50 | 50 | ||
51 | #define ASUS_LAPTOP_VERSION "0.41" | 51 | #define ASUS_LAPTOP_VERSION "0.42" |
52 | 52 | ||
53 | #define ASUS_HOTK_NAME "Asus Laptop Support" | 53 | #define ASUS_HOTK_NAME "Asus Laptop Support" |
54 | #define ASUS_HOTK_CLASS "hotkey" | 54 | #define ASUS_HOTK_CLASS "hotkey" |
@@ -83,6 +83,7 @@ | |||
83 | #define PLED_ON 0x20 //Phone LED | 83 | #define PLED_ON 0x20 //Phone LED |
84 | #define GLED_ON 0x40 //Gaming LED | 84 | #define GLED_ON 0x40 //Gaming LED |
85 | #define LCD_ON 0x80 //LCD backlight | 85 | #define LCD_ON 0x80 //LCD backlight |
86 | #define GPS_ON 0x100 //GPS | ||
86 | 87 | ||
87 | #define ASUS_LOG ASUS_HOTK_FILE ": " | 88 | #define ASUS_LOG ASUS_HOTK_FILE ": " |
88 | #define ASUS_ERR KERN_ERR ASUS_LOG | 89 | #define ASUS_ERR KERN_ERR ASUS_LOG |
@@ -148,7 +149,7 @@ ASUS_HANDLE(display_set, ASUS_HOTK_PREFIX "SDSP"); | |||
148 | ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L4R M6R A3G | 149 | ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L4R M6R A3G |
149 | M6A M6V VX-1 V6J V6V W3Z */ | 150 | M6A M6V VX-1 V6J V6V W3Z */ |
150 | "\\_SB.PCI0.P0P2.VGA.GETD", /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V | 151 | "\\_SB.PCI0.P0P2.VGA.GETD", /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V |
151 | S5A M5A z33A W1Jc W2V */ | 152 | S5A M5A z33A W1Jc W2V G1 */ |
152 | "\\_SB.PCI0.P0P3.VGA.GETD", /* A6V A6Q */ | 153 | "\\_SB.PCI0.P0P3.VGA.GETD", /* A6V A6Q */ |
153 | "\\_SB.PCI0.P0PA.VGA.GETD", /* A6T, A6M */ | 154 | "\\_SB.PCI0.P0PA.VGA.GETD", /* A6T, A6M */ |
154 | "\\_SB.PCI0.PCI1.VGAC.NMAP", /* L3C */ | 155 | "\\_SB.PCI0.PCI1.VGAC.NMAP", /* L3C */ |
@@ -162,6 +163,12 @@ ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L | |||
162 | ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */ | 163 | ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */ |
163 | ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */ | 164 | ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */ |
164 | 165 | ||
166 | /* GPS */ | ||
167 | /* R2H use different handle for GPS on/off */ | ||
168 | ASUS_HANDLE(gps_on, ASUS_HOTK_PREFIX "SDON"); /* R2H */ | ||
169 | ASUS_HANDLE(gps_off, ASUS_HOTK_PREFIX "SDOF"); /* R2H */ | ||
170 | ASUS_HANDLE(gps_status, ASUS_HOTK_PREFIX "GPST"); | ||
171 | |||
165 | /* | 172 | /* |
166 | * This is the main structure, we can use it to store anything interesting | 173 | * This is the main structure, we can use it to store anything interesting |
167 | * about the hotk device | 174 | * about the hotk device |
@@ -278,12 +285,28 @@ static int read_wireless_status(int mask) | |||
278 | return (hotk->status & mask) ? 1 : 0; | 285 | return (hotk->status & mask) ? 1 : 0; |
279 | } | 286 | } |
280 | 287 | ||
288 | static int read_gps_status(void) | ||
289 | { | ||
290 | ulong status; | ||
291 | acpi_status rv = AE_OK; | ||
292 | |||
293 | rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status); | ||
294 | if (ACPI_FAILURE(rv)) | ||
295 | printk(ASUS_WARNING "Error reading GPS status\n"); | ||
296 | else | ||
297 | return status ? 1 : 0; | ||
298 | |||
299 | return (hotk->status & GPS_ON) ? 1 : 0; | ||
300 | } | ||
301 | |||
281 | /* Generic LED functions */ | 302 | /* Generic LED functions */ |
282 | static int read_status(int mask) | 303 | static int read_status(int mask) |
283 | { | 304 | { |
284 | /* There is a special method for both wireless devices */ | 305 | /* There is a special method for both wireless devices */ |
285 | if (mask == BT_ON || mask == WL_ON) | 306 | if (mask == BT_ON || mask == WL_ON) |
286 | return read_wireless_status(mask); | 307 | return read_wireless_status(mask); |
308 | else if (mask == GPS_ON) | ||
309 | return read_gps_status(); | ||
287 | 310 | ||
288 | return (hotk->status & mask) ? 1 : 0; | 311 | return (hotk->status & mask) ? 1 : 0; |
289 | } | 312 | } |
@@ -299,6 +322,10 @@ static void write_status(acpi_handle handle, int out, int mask) | |||
299 | case GLED_ON: | 322 | case GLED_ON: |
300 | out = (out & 0x1) + 1; | 323 | out = (out & 0x1) + 1; |
301 | break; | 324 | break; |
325 | case GPS_ON: | ||
326 | handle = (out) ? gps_on_handle : gps_off_handle; | ||
327 | out = 0x02; | ||
328 | break; | ||
302 | default: | 329 | default: |
303 | out &= 0x1; | 330 | out &= 0x1; |
304 | break; | 331 | break; |
@@ -667,6 +694,21 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, | |||
667 | return rv; | 694 | return rv; |
668 | } | 695 | } |
669 | 696 | ||
697 | /* | ||
698 | * GPS | ||
699 | */ | ||
700 | static ssize_t show_gps(struct device *dev, | ||
701 | struct device_attribute *attr, char *buf) | ||
702 | { | ||
703 | return sprintf(buf, "%d\n", read_status(GPS_ON)); | ||
704 | } | ||
705 | |||
706 | static ssize_t store_gps(struct device *dev, struct device_attribute *attr, | ||
707 | const char *buf, size_t count) | ||
708 | { | ||
709 | return store_status(buf, count, NULL, GPS_ON); | ||
710 | } | ||
711 | |||
670 | static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) | 712 | static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) |
671 | { | 713 | { |
672 | /* TODO Find a better way to handle events count. */ | 714 | /* TODO Find a better way to handle events count. */ |
@@ -715,6 +757,7 @@ static ASUS_CREATE_DEVICE_ATTR(display); | |||
715 | static ASUS_CREATE_DEVICE_ATTR(ledd); | 757 | static ASUS_CREATE_DEVICE_ATTR(ledd); |
716 | static ASUS_CREATE_DEVICE_ATTR(ls_switch); | 758 | static ASUS_CREATE_DEVICE_ATTR(ls_switch); |
717 | static ASUS_CREATE_DEVICE_ATTR(ls_level); | 759 | static ASUS_CREATE_DEVICE_ATTR(ls_level); |
760 | static ASUS_CREATE_DEVICE_ATTR(gps); | ||
718 | 761 | ||
719 | static struct attribute *asuspf_attributes[] = { | 762 | static struct attribute *asuspf_attributes[] = { |
720 | &dev_attr_infos.attr, | 763 | &dev_attr_infos.attr, |
@@ -724,6 +767,7 @@ static struct attribute *asuspf_attributes[] = { | |||
724 | &dev_attr_ledd.attr, | 767 | &dev_attr_ledd.attr, |
725 | &dev_attr_ls_switch.attr, | 768 | &dev_attr_ls_switch.attr, |
726 | &dev_attr_ls_level.attr, | 769 | &dev_attr_ls_level.attr, |
770 | &dev_attr_gps.attr, | ||
727 | NULL | 771 | NULL |
728 | }; | 772 | }; |
729 | 773 | ||
@@ -763,6 +807,9 @@ static void asus_hotk_add_fs(void) | |||
763 | ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl); | 807 | ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl); |
764 | ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw); | 808 | ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw); |
765 | } | 809 | } |
810 | |||
811 | if (gps_status_handle && gps_on_handle && gps_off_handle) | ||
812 | ASUS_SET_DEVICE_ATTR(gps, 0644, show_gps, store_gps); | ||
766 | } | 813 | } |
767 | 814 | ||
768 | static int asus_handle_init(char *name, acpi_handle * handle, | 815 | static int asus_handle_init(char *name, acpi_handle * handle, |
@@ -890,9 +937,13 @@ static int asus_hotk_get_info(void) | |||
890 | 937 | ||
891 | /* There is a lot of models with "ALSL", but a few get | 938 | /* There is a lot of models with "ALSL", but a few get |
892 | a real light sens, so we need to check it. */ | 939 | a real light sens, so we need to check it. */ |
893 | if (ASUS_HANDLE_INIT(ls_switch)) | 940 | if (!ASUS_HANDLE_INIT(ls_switch)) |
894 | ASUS_HANDLE_INIT(ls_level); | 941 | ASUS_HANDLE_INIT(ls_level); |
895 | 942 | ||
943 | ASUS_HANDLE_INIT(gps_on); | ||
944 | ASUS_HANDLE_INIT(gps_off); | ||
945 | ASUS_HANDLE_INIT(gps_status); | ||
946 | |||
896 | kfree(model); | 947 | kfree(model); |
897 | 948 | ||
898 | return AE_OK; | 949 | return AE_OK; |
@@ -950,7 +1001,7 @@ static int asus_hotk_add(struct acpi_device *device) | |||
950 | * We install the handler, it will receive the hotk in parameter, so, we | 1001 | * We install the handler, it will receive the hotk in parameter, so, we |
951 | * could add other data to the hotk struct | 1002 | * could add other data to the hotk struct |
952 | */ | 1003 | */ |
953 | status = acpi_install_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY, | 1004 | status = acpi_install_notify_handler(hotk->handle, ACPI_ALL_NOTIFY, |
954 | asus_hotk_notify, hotk); | 1005 | asus_hotk_notify, hotk); |
955 | if (ACPI_FAILURE(status)) | 1006 | if (ACPI_FAILURE(status)) |
956 | printk(ASUS_ERR "Error installing notify handler\n"); | 1007 | printk(ASUS_ERR "Error installing notify handler\n"); |
@@ -981,6 +1032,9 @@ static int asus_hotk_add(struct acpi_device *device) | |||
981 | if (ls_level_handle) | 1032 | if (ls_level_handle) |
982 | set_light_sens_level(hotk->light_level); | 1033 | set_light_sens_level(hotk->light_level); |
983 | 1034 | ||
1035 | /* GPS is on by default */ | ||
1036 | write_status(NULL, 1, GPS_ON); | ||
1037 | |||
984 | end: | 1038 | end: |
985 | if (result) { | 1039 | if (result) { |
986 | kfree(hotk->name); | 1040 | kfree(hotk->name); |
@@ -997,7 +1051,7 @@ static int asus_hotk_remove(struct acpi_device *device, int type) | |||
997 | if (!device || !acpi_driver_data(device)) | 1051 | if (!device || !acpi_driver_data(device)) |
998 | return -EINVAL; | 1052 | return -EINVAL; |
999 | 1053 | ||
1000 | status = acpi_remove_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY, | 1054 | status = acpi_remove_notify_handler(hotk->handle, ACPI_ALL_NOTIFY, |
1001 | asus_hotk_notify); | 1055 | asus_hotk_notify); |
1002 | if (ACPI_FAILURE(status)) | 1056 | if (ACPI_FAILURE(status)) |
1003 | printk(ASUS_ERR "Error removing notify handler\n"); | 1057 | printk(ASUS_ERR "Error removing notify handler\n"); |
diff --git a/drivers/misc/msi-laptop.c b/drivers/misc/msi-laptop.c index 68c4b58525ba..41e901f53e7c 100644 --- a/drivers/misc/msi-laptop.c +++ b/drivers/misc/msi-laptop.c | |||
@@ -85,7 +85,7 @@ static int set_lcd_level(int level) | |||
85 | buf[0] = 0x80; | 85 | buf[0] = 0x80; |
86 | buf[1] = (u8) (level*31); | 86 | buf[1] = (u8) (level*31); |
87 | 87 | ||
88 | return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, buf, sizeof(buf), NULL, 0); | 88 | return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, buf, sizeof(buf), NULL, 0, 1); |
89 | } | 89 | } |
90 | 90 | ||
91 | static int get_lcd_level(void) | 91 | static int get_lcd_level(void) |
@@ -93,7 +93,7 @@ static int get_lcd_level(void) | |||
93 | u8 wdata = 0, rdata; | 93 | u8 wdata = 0, rdata; |
94 | int result; | 94 | int result; |
95 | 95 | ||
96 | result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, &rdata, 1); | 96 | result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, &rdata, 1, 1); |
97 | if (result < 0) | 97 | if (result < 0) |
98 | return result; | 98 | return result; |
99 | 99 | ||
@@ -105,7 +105,7 @@ static int get_auto_brightness(void) | |||
105 | u8 wdata = 4, rdata; | 105 | u8 wdata = 4, rdata; |
106 | int result; | 106 | int result; |
107 | 107 | ||
108 | result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, &rdata, 1); | 108 | result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, &rdata, 1, 1); |
109 | if (result < 0) | 109 | if (result < 0) |
110 | return result; | 110 | return result; |
111 | 111 | ||
@@ -119,14 +119,14 @@ static int set_auto_brightness(int enable) | |||
119 | 119 | ||
120 | wdata[0] = 4; | 120 | wdata[0] = 4; |
121 | 121 | ||
122 | result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 1, &rdata, 1); | 122 | result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 1, &rdata, 1, 1); |
123 | if (result < 0) | 123 | if (result < 0) |
124 | return result; | 124 | return result; |
125 | 125 | ||
126 | wdata[0] = 0x84; | 126 | wdata[0] = 0x84; |
127 | wdata[1] = (rdata & 0xF7) | (enable ? 8 : 0); | 127 | wdata[1] = (rdata & 0xF7) | (enable ? 8 : 0); |
128 | 128 | ||
129 | return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 2, NULL, 0); | 129 | return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 2, NULL, 0, 1); |
130 | } | 130 | } |
131 | 131 | ||
132 | static int get_wireless_state(int *wlan, int *bluetooth) | 132 | static int get_wireless_state(int *wlan, int *bluetooth) |
@@ -134,7 +134,7 @@ static int get_wireless_state(int *wlan, int *bluetooth) | |||
134 | u8 wdata = 0, rdata; | 134 | u8 wdata = 0, rdata; |
135 | int result; | 135 | int result; |
136 | 136 | ||
137 | result = ec_transaction(MSI_EC_COMMAND_WIRELESS, &wdata, 1, &rdata, 1); | 137 | result = ec_transaction(MSI_EC_COMMAND_WIRELESS, &wdata, 1, &rdata, 1, 1); |
138 | if (result < 0) | 138 | if (result < 0) |
139 | return -1; | 139 | return -1; |
140 | 140 | ||
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c index c15c1f61bd1b..8ee0321ef1c8 100644 --- a/drivers/misc/sony-laptop.c +++ b/drivers/misc/sony-laptop.c | |||
@@ -63,7 +63,7 @@ | |||
63 | #include <asm/uaccess.h> | 63 | #include <asm/uaccess.h> |
64 | #include <linux/sonypi.h> | 64 | #include <linux/sonypi.h> |
65 | #include <linux/sony-laptop.h> | 65 | #include <linux/sony-laptop.h> |
66 | #ifdef CONFIG_SONY_LAPTOP_OLD | 66 | #ifdef CONFIG_SONYPI_COMPAT |
67 | #include <linux/poll.h> | 67 | #include <linux/poll.h> |
68 | #include <linux/miscdevice.h> | 68 | #include <linux/miscdevice.h> |
69 | #endif | 69 | #endif |
@@ -114,7 +114,7 @@ MODULE_PARM_DESC(camera, | |||
114 | "set this to 1 to enable Motion Eye camera controls " | 114 | "set this to 1 to enable Motion Eye camera controls " |
115 | "(only use it if you have a C1VE or C1VN model)"); | 115 | "(only use it if you have a C1VE or C1VN model)"); |
116 | 116 | ||
117 | #ifdef CONFIG_SONY_LAPTOP_OLD | 117 | #ifdef CONFIG_SONYPI_COMPAT |
118 | static int minor = -1; | 118 | static int minor = -1; |
119 | module_param(minor, int, 0); | 119 | module_param(minor, int, 0); |
120 | MODULE_PARM_DESC(minor, | 120 | MODULE_PARM_DESC(minor, |
@@ -1504,7 +1504,7 @@ static struct attribute_group spic_attribute_group = { | |||
1504 | }; | 1504 | }; |
1505 | 1505 | ||
1506 | /******** SONYPI compatibility **********/ | 1506 | /******** SONYPI compatibility **********/ |
1507 | #ifdef CONFIG_SONY_LAPTOP_OLD | 1507 | #ifdef CONFIG_SONYPI_COMPAT |
1508 | 1508 | ||
1509 | /* battery / brightness / temperature addresses */ | 1509 | /* battery / brightness / temperature addresses */ |
1510 | #define SONYPI_BAT_FLAGS 0x81 | 1510 | #define SONYPI_BAT_FLAGS 0x81 |
@@ -1798,7 +1798,7 @@ static void sonypi_compat_exit(void) | |||
1798 | static int sonypi_compat_init(void) { return 0; } | 1798 | static int sonypi_compat_init(void) { return 0; } |
1799 | static void sonypi_compat_exit(void) { } | 1799 | static void sonypi_compat_exit(void) { } |
1800 | static void sonypi_compat_report_event(u8 event) { } | 1800 | static void sonypi_compat_report_event(u8 event) { } |
1801 | #endif /* CONFIG_SONY_LAPTOP_OLD */ | 1801 | #endif /* CONFIG_SONYPI_COMPAT */ |
1802 | 1802 | ||
1803 | /* | 1803 | /* |
1804 | * ACPI callbacks | 1804 | * ACPI callbacks |
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 45b7d53b949c..c0b41e8bcd9d 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | menuconfig MMC | 5 | menuconfig MMC |
6 | tristate "MMC/SD card support" | 6 | tristate "MMC/SD card support" |
7 | depends on HAS_IOMEM | ||
7 | help | 8 | help |
8 | MMC is the "multi-media card" bus protocol. | 9 | MMC is the "multi-media card" bus protocol. |
9 | 10 | ||
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index d24ab234394c..a7562f7fc0b3 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -45,8 +45,6 @@ | |||
45 | */ | 45 | */ |
46 | #define MMC_SHIFT 3 | 46 | #define MMC_SHIFT 3 |
47 | 47 | ||
48 | static int major; | ||
49 | |||
50 | /* | 48 | /* |
51 | * There is one mmc_blk_data per slot. | 49 | * There is one mmc_blk_data per slot. |
52 | */ | 50 | */ |
@@ -466,7 +464,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) | |||
466 | md->queue.issue_fn = mmc_blk_issue_rq; | 464 | md->queue.issue_fn = mmc_blk_issue_rq; |
467 | md->queue.data = md; | 465 | md->queue.data = md; |
468 | 466 | ||
469 | md->disk->major = major; | 467 | md->disk->major = MMC_BLOCK_MAJOR; |
470 | md->disk->first_minor = devidx << MMC_SHIFT; | 468 | md->disk->first_minor = devidx << MMC_SHIFT; |
471 | md->disk->fops = &mmc_bdops; | 469 | md->disk->fops = &mmc_bdops; |
472 | md->disk->private_data = md; | 470 | md->disk->private_data = md; |
@@ -634,14 +632,9 @@ static int __init mmc_blk_init(void) | |||
634 | { | 632 | { |
635 | int res = -ENOMEM; | 633 | int res = -ENOMEM; |
636 | 634 | ||
637 | res = register_blkdev(major, "mmc"); | 635 | res = register_blkdev(MMC_BLOCK_MAJOR, "mmc"); |
638 | if (res < 0) { | 636 | if (res) |
639 | printk(KERN_WARNING "Unable to get major %d for MMC media: %d\n", | ||
640 | major, res); | ||
641 | goto out; | 637 | goto out; |
642 | } | ||
643 | if (major == 0) | ||
644 | major = res; | ||
645 | 638 | ||
646 | return mmc_register_driver(&mmc_driver); | 639 | return mmc_register_driver(&mmc_driver); |
647 | 640 | ||
@@ -652,7 +645,7 @@ static int __init mmc_blk_init(void) | |||
652 | static void __exit mmc_blk_exit(void) | 645 | static void __exit mmc_blk_exit(void) |
653 | { | 646 | { |
654 | mmc_unregister_driver(&mmc_driver); | 647 | mmc_unregister_driver(&mmc_driver); |
655 | unregister_blkdev(major, "mmc"); | 648 | unregister_blkdev(MMC_BLOCK_MAJOR, "mmc"); |
656 | } | 649 | } |
657 | 650 | ||
658 | module_init(mmc_blk_init); | 651 | module_init(mmc_blk_init); |
@@ -661,5 +654,3 @@ module_exit(mmc_blk_exit); | |||
661 | MODULE_LICENSE("GPL"); | 654 | MODULE_LICENSE("GPL"); |
662 | MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver"); | 655 | MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver"); |
663 | 656 | ||
664 | module_param(major, int, 0444); | ||
665 | MODULE_PARM_DESC(major, "specify the major device number for MMC block driver"); | ||
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index b7156a4555b5..f967226d7505 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c | |||
@@ -187,9 +187,8 @@ static void au1xmmc_tasklet_finish(unsigned long param) | |||
187 | } | 187 | } |
188 | 188 | ||
189 | static int au1xmmc_send_command(struct au1xmmc_host *host, int wait, | 189 | static int au1xmmc_send_command(struct au1xmmc_host *host, int wait, |
190 | struct mmc_command *cmd) | 190 | struct mmc_command *cmd, unsigned int flags) |
191 | { | 191 | { |
192 | |||
193 | u32 mmccmd = (cmd->opcode << SD_CMD_CI_SHIFT); | 192 | u32 mmccmd = (cmd->opcode << SD_CMD_CI_SHIFT); |
194 | 193 | ||
195 | switch (mmc_resp_type(cmd)) { | 194 | switch (mmc_resp_type(cmd)) { |
@@ -213,24 +212,16 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait, | |||
213 | return MMC_ERR_INVALID; | 212 | return MMC_ERR_INVALID; |
214 | } | 213 | } |
215 | 214 | ||
216 | switch(cmd->opcode) { | 215 | if (flags & MMC_DATA_READ) { |
217 | case MMC_READ_SINGLE_BLOCK: | 216 | if (flags & MMC_DATA_MULTI) |
218 | case SD_APP_SEND_SCR: | 217 | mmccmd |= SD_CMD_CT_4; |
219 | mmccmd |= SD_CMD_CT_2; | 218 | else |
220 | break; | 219 | mmccmd |= SD_CMD_CT_2; |
221 | case MMC_READ_MULTIPLE_BLOCK: | 220 | } else if (flags & MMC_DATA_WRITE) { |
222 | mmccmd |= SD_CMD_CT_4; | 221 | if (flags & MMC_DATA_MULTI) |
223 | break; | 222 | mmccmd |= SD_CMD_CT_3; |
224 | case MMC_WRITE_BLOCK: | 223 | else |
225 | mmccmd |= SD_CMD_CT_1; | 224 | mmccmd |= SD_CMD_CT_1; |
226 | break; | ||
227 | |||
228 | case MMC_WRITE_MULTIPLE_BLOCK: | ||
229 | mmccmd |= SD_CMD_CT_3; | ||
230 | break; | ||
231 | case MMC_STOP_TRANSMISSION: | ||
232 | mmccmd |= SD_CMD_CT_7; | ||
233 | break; | ||
234 | } | 225 | } |
235 | 226 | ||
236 | au_writel(cmd->arg, HOST_CMDARG(host)); | 227 | au_writel(cmd->arg, HOST_CMDARG(host)); |
@@ -665,6 +656,7 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq) | |||
665 | { | 656 | { |
666 | 657 | ||
667 | struct au1xmmc_host *host = mmc_priv(mmc); | 658 | struct au1xmmc_host *host = mmc_priv(mmc); |
659 | unsigned int flags = 0; | ||
668 | int ret = MMC_ERR_NONE; | 660 | int ret = MMC_ERR_NONE; |
669 | 661 | ||
670 | WARN_ON(irqs_disabled()); | 662 | WARN_ON(irqs_disabled()); |
@@ -677,11 +669,12 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq) | |||
677 | 669 | ||
678 | if (mrq->data) { | 670 | if (mrq->data) { |
679 | FLUSH_FIFO(host); | 671 | FLUSH_FIFO(host); |
672 | flags = mrq->data->flags; | ||
680 | ret = au1xmmc_prepare_data(host, mrq->data); | 673 | ret = au1xmmc_prepare_data(host, mrq->data); |
681 | } | 674 | } |
682 | 675 | ||
683 | if (ret == MMC_ERR_NONE) | 676 | if (ret == MMC_ERR_NONE) |
684 | ret = au1xmmc_send_command(host, 0, mrq->cmd); | 677 | ret = au1xmmc_send_command(host, 0, mrq->cmd, flags); |
685 | 678 | ||
686 | if (ret != MMC_ERR_NONE) { | 679 | if (ret != MMC_ERR_NONE) { |
687 | mrq->cmd->error = ret; | 680 | mrq->cmd->error = ret; |
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index d97d3864b57f..f8985c508bb9 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -232,20 +232,14 @@ static int pxamci_cmd_done(struct pxamci_host *host, unsigned int stat) | |||
232 | /* | 232 | /* |
233 | * workaround for erratum #42: | 233 | * workaround for erratum #42: |
234 | * Intel PXA27x Family Processor Specification Update Rev 001 | 234 | * Intel PXA27x Family Processor Specification Update Rev 001 |
235 | * A bogus CRC error can appear if the msb of a 136 bit | ||
236 | * response is a one. | ||
235 | */ | 237 | */ |
236 | if (cmd->opcode == MMC_ALL_SEND_CID || | 238 | if (cmd->flags & MMC_RSP_136 && cmd->resp[0] & 0x80000000) { |
237 | cmd->opcode == MMC_SEND_CSD || | 239 | pr_debug("ignoring CRC from command %d - *risky*\n", cmd->opcode); |
238 | cmd->opcode == MMC_SEND_CID) { | 240 | } else |
239 | /* a bogus CRC error can appear if the msb of | ||
240 | the 15 byte response is a one */ | ||
241 | if ((cmd->resp[0] & 0x80000000) == 0) | ||
242 | cmd->error = MMC_ERR_BADCRC; | ||
243 | } else { | ||
244 | pr_debug("ignoring CRC from command %d - *risky*\n",cmd->opcode); | ||
245 | } | ||
246 | #else | ||
247 | cmd->error = MMC_ERR_BADCRC; | ||
248 | #endif | 241 | #endif |
242 | cmd->error = MMC_ERR_BADCRC; | ||
249 | } | 243 | } |
250 | 244 | ||
251 | pxamci_disable_irq(host, END_CMD_RES); | 245 | pxamci_disable_irq(host, END_CMD_RES); |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ff5bf73cdd25..a359efdd77eb 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -963,6 +963,15 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) | |||
963 | if (intmask & (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL)) | 963 | if (intmask & (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL)) |
964 | sdhci_transfer_pio(host); | 964 | sdhci_transfer_pio(host); |
965 | 965 | ||
966 | /* | ||
967 | * We currently don't do anything fancy with DMA | ||
968 | * boundaries, but as we can't disable the feature | ||
969 | * we need to at least restart the transfer. | ||
970 | */ | ||
971 | if (intmask & SDHCI_INT_DMA_END) | ||
972 | writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS), | ||
973 | host->ioaddr + SDHCI_DMA_ADDRESS); | ||
974 | |||
966 | if (intmask & SDHCI_INT_DATA_END) | 975 | if (intmask & SDHCI_INT_DATA_END) |
967 | sdhci_finish_data(host); | 976 | sdhci_finish_data(host); |
968 | } | 977 | } |
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index c1b47db29bd2..fbec8cd55e38 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | menuconfig MTD | 3 | menuconfig MTD |
4 | tristate "Memory Technology Device (MTD) support" | 4 | tristate "Memory Technology Device (MTD) support" |
5 | depends on HAS_IOMEM | ||
5 | help | 6 | help |
6 | Memory Technology Devices are flash, RAM and similar chips, often | 7 | Memory Technology Devices are flash, RAM and similar chips, often |
7 | used for solid state file systems on embedded devices. This option | 8 | used for solid state file systems on embedded devices. This option |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index b3f4ffa89d02..c5baa197bc08 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -1898,8 +1898,12 @@ endmenu | |||
1898 | # Gigabit Ethernet | 1898 | # Gigabit Ethernet |
1899 | # | 1899 | # |
1900 | 1900 | ||
1901 | menu "Ethernet (1000 Mbit)" | 1901 | menuconfig NETDEV_1000 |
1902 | bool "Ethernet (1000 Mbit)" | ||
1902 | depends on !UML | 1903 | depends on !UML |
1904 | default y | ||
1905 | |||
1906 | if NETDEV_1000 | ||
1903 | 1907 | ||
1904 | config ACENIC | 1908 | config ACENIC |
1905 | tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support" | 1909 | tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support" |
@@ -2299,7 +2303,7 @@ config UGETH_TX_ON_DEMAND | |||
2299 | 2303 | ||
2300 | config MV643XX_ETH | 2304 | config MV643XX_ETH |
2301 | tristate "MV-643XX Ethernet support" | 2305 | tristate "MV-643XX Ethernet support" |
2302 | depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || MOMENCO_OCELOT_3 || (PPC_MULTIPLATFORM && PPC32) | 2306 | depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || MV64X60 || MOMENCO_OCELOT_3 || (PPC_MULTIPLATFORM && PPC32) |
2303 | select MII | 2307 | select MII |
2304 | help | 2308 | help |
2305 | This driver supports the gigabit Ethernet on the Marvell MV643XX | 2309 | This driver supports the gigabit Ethernet on the Marvell MV643XX |
@@ -2326,14 +2330,18 @@ config ATL1 | |||
2326 | To compile this driver as a module, choose M here. The module | 2330 | To compile this driver as a module, choose M here. The module |
2327 | will be called atl1. | 2331 | will be called atl1. |
2328 | 2332 | ||
2329 | endmenu | 2333 | endif # NETDEV_1000 |
2330 | 2334 | ||
2331 | # | 2335 | # |
2332 | # 10 Gigabit Ethernet | 2336 | # 10 Gigabit Ethernet |
2333 | # | 2337 | # |
2334 | 2338 | ||
2335 | menu "Ethernet (10000 Mbit)" | 2339 | menuconfig NETDEV_10000 |
2340 | bool "Ethernet (10000 Mbit)" | ||
2336 | depends on !UML | 2341 | depends on !UML |
2342 | default y | ||
2343 | |||
2344 | if NETDEV_10000 | ||
2337 | 2345 | ||
2338 | config CHELSIO_T1 | 2346 | config CHELSIO_T1 |
2339 | tristate "Chelsio 10Gb Ethernet support" | 2347 | tristate "Chelsio 10Gb Ethernet support" |
@@ -2508,7 +2516,7 @@ config MLX4_DEBUG | |||
2508 | debug_level module parameter (which can also be set after | 2516 | debug_level module parameter (which can also be set after |
2509 | the driver is loaded through sysfs). | 2517 | the driver is loaded through sysfs). |
2510 | 2518 | ||
2511 | endmenu | 2519 | endif # NETDEV_10000 |
2512 | 2520 | ||
2513 | source "drivers/net/tokenring/Kconfig" | 2521 | source "drivers/net/tokenring/Kconfig" |
2514 | 2522 | ||
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c index f075cebe84ad..f21148e7b579 100644 --- a/drivers/net/arm/ether1.c +++ b/drivers/net/arm/ether1.c | |||
@@ -1014,8 +1014,7 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
1014 | SET_NETDEV_DEV(dev, &ec->dev); | 1014 | SET_NETDEV_DEV(dev, &ec->dev); |
1015 | 1015 | ||
1016 | dev->irq = ec->irq; | 1016 | dev->irq = ec->irq; |
1017 | priv(dev)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST), | 1017 | priv(dev)->base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
1018 | ecard_resource_len(ec, ECARD_RES_IOCFAST)); | ||
1019 | if (!priv(dev)->base) { | 1018 | if (!priv(dev)->base) { |
1020 | ret = -ENOMEM; | 1019 | ret = -ENOMEM; |
1021 | goto free; | 1020 | goto free; |
@@ -1056,8 +1055,6 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
1056 | return 0; | 1055 | return 0; |
1057 | 1056 | ||
1058 | free: | 1057 | free: |
1059 | if (priv(dev)->base) | ||
1060 | iounmap(priv(dev)->base); | ||
1061 | free_netdev(dev); | 1058 | free_netdev(dev); |
1062 | release: | 1059 | release: |
1063 | ecard_release_resources(ec); | 1060 | ecard_release_resources(ec); |
@@ -1072,7 +1069,6 @@ static void __devexit ether1_remove(struct expansion_card *ec) | |||
1072 | ecard_set_drvdata(ec, NULL); | 1069 | ecard_set_drvdata(ec, NULL); |
1073 | 1070 | ||
1074 | unregister_netdev(dev); | 1071 | unregister_netdev(dev); |
1075 | iounmap(priv(dev)->base); | ||
1076 | free_netdev(dev); | 1072 | free_netdev(dev); |
1077 | ecard_release_resources(ec); | 1073 | ecard_release_resources(ec); |
1078 | } | 1074 | } |
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c index 32da2eb9bcee..da713500654d 100644 --- a/drivers/net/arm/ether3.c +++ b/drivers/net/arm/ether3.c | |||
@@ -793,8 +793,7 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
793 | SET_MODULE_OWNER(dev); | 793 | SET_MODULE_OWNER(dev); |
794 | SET_NETDEV_DEV(dev, &ec->dev); | 794 | SET_NETDEV_DEV(dev, &ec->dev); |
795 | 795 | ||
796 | priv(dev)->base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), | 796 | priv(dev)->base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
797 | ecard_resource_len(ec, ECARD_RES_MEMC)); | ||
798 | if (!priv(dev)->base) { | 797 | if (!priv(dev)->base) { |
799 | ret = -ENOMEM; | 798 | ret = -ENOMEM; |
800 | goto free; | 799 | goto free; |
@@ -869,8 +868,6 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
869 | return 0; | 868 | return 0; |
870 | 869 | ||
871 | free: | 870 | free: |
872 | if (priv(dev)->base) | ||
873 | iounmap(priv(dev)->base); | ||
874 | free_netdev(dev); | 871 | free_netdev(dev); |
875 | release: | 872 | release: |
876 | ecard_release_resources(ec); | 873 | ecard_release_resources(ec); |
@@ -885,7 +882,6 @@ static void __devexit ether3_remove(struct expansion_card *ec) | |||
885 | ecard_set_drvdata(ec, NULL); | 882 | ecard_set_drvdata(ec, NULL); |
886 | 883 | ||
887 | unregister_netdev(dev); | 884 | unregister_netdev(dev); |
888 | iounmap(priv(dev)->base); | ||
889 | free_netdev(dev); | 885 | free_netdev(dev); |
890 | ecard_release_resources(ec); | 886 | ecard_release_resources(ec); |
891 | } | 887 | } |
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c index 61f574aa3a99..769ba69451f4 100644 --- a/drivers/net/arm/etherh.c +++ b/drivers/net/arm/etherh.c | |||
@@ -686,7 +686,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
686 | eh->supported = data->supported; | 686 | eh->supported = data->supported; |
687 | eh->ctrl = 0; | 687 | eh->ctrl = 0; |
688 | eh->id = ec->cid.product; | 688 | eh->id = ec->cid.product; |
689 | eh->memc = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), PAGE_SIZE); | 689 | eh->memc = ecardm_iomap(ec, ECARD_RES_MEMC, 0, PAGE_SIZE); |
690 | if (!eh->memc) { | 690 | if (!eh->memc) { |
691 | ret = -ENOMEM; | 691 | ret = -ENOMEM; |
692 | goto free; | 692 | goto free; |
@@ -694,7 +694,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
694 | 694 | ||
695 | eh->ctrl_port = eh->memc; | 695 | eh->ctrl_port = eh->memc; |
696 | if (data->ctrl_ioc) { | 696 | if (data->ctrl_ioc) { |
697 | eh->ioc_fast = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST), PAGE_SIZE); | 697 | eh->ioc_fast = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, PAGE_SIZE); |
698 | if (!eh->ioc_fast) { | 698 | if (!eh->ioc_fast) { |
699 | ret = -ENOMEM; | 699 | ret = -ENOMEM; |
700 | goto free; | 700 | goto free; |
@@ -710,8 +710,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
710 | * IRQ and control port handling - only for non-NIC slot cards. | 710 | * IRQ and control port handling - only for non-NIC slot cards. |
711 | */ | 711 | */ |
712 | if (ec->slot_no != 8) { | 712 | if (ec->slot_no != 8) { |
713 | ec->ops = ðerh_ops; | 713 | ecard_setirq(ec, ðerh_ops, eh); |
714 | ec->irq_data = eh; | ||
715 | } else { | 714 | } else { |
716 | /* | 715 | /* |
717 | * If we're in the NIC slot, make sure the IRQ is enabled | 716 | * If we're in the NIC slot, make sure the IRQ is enabled |
@@ -759,10 +758,6 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
759 | return 0; | 758 | return 0; |
760 | 759 | ||
761 | free: | 760 | free: |
762 | if (eh->ioc_fast) | ||
763 | iounmap(eh->ioc_fast); | ||
764 | if (eh->memc) | ||
765 | iounmap(eh->memc); | ||
766 | free_netdev(dev); | 761 | free_netdev(dev); |
767 | release: | 762 | release: |
768 | ecard_release_resources(ec); | 763 | ecard_release_resources(ec); |
@@ -773,16 +768,10 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
773 | static void __devexit etherh_remove(struct expansion_card *ec) | 768 | static void __devexit etherh_remove(struct expansion_card *ec) |
774 | { | 769 | { |
775 | struct net_device *dev = ecard_get_drvdata(ec); | 770 | struct net_device *dev = ecard_get_drvdata(ec); |
776 | struct etherh_priv *eh = etherh_priv(dev); | ||
777 | 771 | ||
778 | ecard_set_drvdata(ec, NULL); | 772 | ecard_set_drvdata(ec, NULL); |
779 | 773 | ||
780 | unregister_netdev(dev); | 774 | unregister_netdev(dev); |
781 | ec->ops = NULL; | ||
782 | |||
783 | if (eh->ioc_fast) | ||
784 | iounmap(eh->ioc_fast); | ||
785 | iounmap(eh->memc); | ||
786 | 775 | ||
787 | free_netdev(dev); | 776 | free_netdev(dev); |
788 | 777 | ||
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c index d0f28981b55a..7540966687ec 100644 --- a/drivers/net/fs_enet/mac-scc.c +++ b/drivers/net/fs_enet/mac-scc.c | |||
@@ -167,7 +167,7 @@ static int allocate_bd(struct net_device *dev) | |||
167 | 167 | ||
168 | fep->ring_mem_addr = cpm_dpalloc((fpi->tx_ring + fpi->rx_ring) * | 168 | fep->ring_mem_addr = cpm_dpalloc((fpi->tx_ring + fpi->rx_ring) * |
169 | sizeof(cbd_t), 8); | 169 | sizeof(cbd_t), 8); |
170 | if (IS_DPERR(fep->ring_mem_addr)) | 170 | if (IS_ERR_VALUE(fep->ring_mem_addr)) |
171 | return -ENOMEM; | 171 | return -ENOMEM; |
172 | 172 | ||
173 | fep->ring_base = cpm_dpram_addr(fep->ring_mem_addr); | 173 | fep->ring_base = cpm_dpram_addr(fep->ring_mem_addr); |
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig index 7c8ccc09b601..829da9a1d113 100644 --- a/drivers/net/irda/Kconfig +++ b/drivers/net/irda/Kconfig | |||
@@ -141,6 +141,20 @@ config ACT200L_DONGLE | |||
141 | To activate support for ACTiSYS IR-200L dongle you will have to | 141 | To activate support for ACTiSYS IR-200L dongle you will have to |
142 | start irattach like this: "irattach -d act200l". | 142 | start irattach like this: "irattach -d act200l". |
143 | 143 | ||
144 | config KINGSUN_DONGLE | ||
145 | tristate "KingSun/DonShine DS-620 IrDA-USB dongle" | ||
146 | depends on IRDA && USB && EXPERIMENTAL | ||
147 | help | ||
148 | Say Y or M here if you want to build support for the KingSun/DonShine | ||
149 | DS-620 IrDA-USB bridge device driver. | ||
150 | |||
151 | This USB bridge does not conform to the IrDA-USB device class | ||
152 | specification, and therefore needs its own specific driver. This | ||
153 | dongle supports SIR speed only (9600 bps). | ||
154 | |||
155 | To compile it as a module, choose M here: the module will be called | ||
156 | kingsun-sir. | ||
157 | |||
144 | comment "Old SIR device drivers" | 158 | comment "Old SIR device drivers" |
145 | 159 | ||
146 | config IRPORT_SIR | 160 | config IRPORT_SIR |
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile index 5be09f1b9ee2..233a2f923730 100644 --- a/drivers/net/irda/Makefile +++ b/drivers/net/irda/Makefile | |||
@@ -45,6 +45,7 @@ obj-$(CONFIG_MCP2120_DONGLE) += mcp2120-sir.o | |||
45 | obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o | 45 | obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o |
46 | obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o | 46 | obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o |
47 | obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o | 47 | obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o |
48 | obj-$(CONFIG_KINGSUN_DONGLE) += kingsun-sir.o | ||
48 | 49 | ||
49 | # The SIR helper module | 50 | # The SIR helper module |
50 | sir-dev-objs := sir_dev.o sir_dongle.o | 51 | sir-dev-objs := sir_dev.o sir_dongle.o |
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c new file mode 100644 index 000000000000..217429122e79 --- /dev/null +++ b/drivers/net/irda/kingsun-sir.c | |||
@@ -0,0 +1,657 @@ | |||
1 | /***************************************************************************** | ||
2 | * | ||
3 | * Filename: kingsun-sir.c | ||
4 | * Version: 0.1.1 | ||
5 | * Description: Irda KingSun/DonShine USB Dongle | ||
6 | * Status: Experimental | ||
7 | * Author: Alex Villac�s Lasso <a_villacis@palosanto.com> | ||
8 | * | ||
9 | * Based on stir4200 and mcs7780 drivers, with (strange?) differences | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | *****************************************************************************/ | ||
25 | |||
26 | /* | ||
27 | * This is my current (2007-04-25) understanding of how this dongle is supposed | ||
28 | * to work. This is based on reverse-engineering and examination of the packet | ||
29 | * data sent and received by the WinXP driver using USBSnoopy. Feel free to | ||
30 | * update here as more of this dongle is known: | ||
31 | * | ||
32 | * General: Unlike the other USB IrDA dongles, this particular dongle exposes, | ||
33 | * not two bulk (in and out) endpoints, but two *interrupt* ones. This dongle, | ||
34 | * like the bulk based ones (stir4200.c and mcs7780.c), requires polling in | ||
35 | * order to receive data. | ||
36 | * Transmission: Just like stir4200, this dongle uses a raw stream of data, | ||
37 | * which needs to be wrapped and escaped in a similar way as in stir4200.c. | ||
38 | * Reception: Poll-based, as in stir4200. Each read returns the contents of a | ||
39 | * 8-byte buffer, of which the first byte (LSB) indicates the number of bytes | ||
40 | * (1-7) of valid data contained within the remaining 7 bytes. For example, if | ||
41 | * the buffer had the following contents: | ||
42 | * 06 ff ff ff c0 01 04 aa | ||
43 | * This means that (06) there are 6 bytes of valid data. The byte 0xaa at the | ||
44 | * end is garbage (left over from a previous reception) and is discarded. | ||
45 | * If a read returns an "impossible" value as the length of valid data (such as | ||
46 | * 0x36) in the first byte, then the buffer is uninitialized (as is the case of | ||
47 | * first plug-in) and its contents should be discarded. There is currently no | ||
48 | * evidence that the top 5 bits of the 1st byte of the buffer can have values | ||
49 | * other than 0 once reception begins. | ||
50 | * Once valid bytes are collected, the assembled stream is a sequence of | ||
51 | * wrapped IrDA frames that is unwrapped and unescaped as in stir4200.c. | ||
52 | * BIG FAT WARNING: the dongle does *not* reset the RX buffer in any way after | ||
53 | * a successful read from the host, which means that in absence of further | ||
54 | * reception, repeated reads from the dongle will return the exact same | ||
55 | * contents repeatedly. Attempts to be smart and cache a previous read seem | ||
56 | * to result in corrupted packets, so this driver depends on the unwrap logic | ||
57 | * to sort out any repeated reads. | ||
58 | * Speed change: no commands observed so far to change speed, assumed fixed | ||
59 | * 9600bps (SIR). | ||
60 | */ | ||
61 | |||
62 | #include <linux/module.h> | ||
63 | #include <linux/moduleparam.h> | ||
64 | #include <linux/kernel.h> | ||
65 | #include <linux/types.h> | ||
66 | #include <linux/errno.h> | ||
67 | #include <linux/init.h> | ||
68 | #include <linux/slab.h> | ||
69 | #include <linux/module.h> | ||
70 | #include <linux/kref.h> | ||
71 | #include <linux/usb.h> | ||
72 | #include <linux/device.h> | ||
73 | #include <linux/crc32.h> | ||
74 | |||
75 | #include <asm/unaligned.h> | ||
76 | #include <asm/byteorder.h> | ||
77 | #include <asm/uaccess.h> | ||
78 | |||
79 | #include <net/irda/irda.h> | ||
80 | #include <net/irda/wrapper.h> | ||
81 | #include <net/irda/crc.h> | ||
82 | |||
83 | /* | ||
84 | * According to lsusb, 0x07c0 is assigned to | ||
85 | * "Code Mercenaries Hard- und Software GmbH" | ||
86 | */ | ||
87 | #define KING_VENDOR_ID 0x07c0 | ||
88 | #define KING_PRODUCT_ID 0x4200 | ||
89 | |||
90 | /* These are the currently known USB ids */ | ||
91 | static struct usb_device_id dongles[] = { | ||
92 | /* KingSun Co,Ltd IrDA/USB Bridge */ | ||
93 | { USB_DEVICE(KING_VENDOR_ID, KING_PRODUCT_ID) }, | ||
94 | { } | ||
95 | }; | ||
96 | |||
97 | MODULE_DEVICE_TABLE(usb, dongles); | ||
98 | |||
99 | #define KINGSUN_MTT 0x07 | ||
100 | |||
101 | #define KINGSUN_FIFO_SIZE 4096 | ||
102 | #define KINGSUN_EP_IN 0 | ||
103 | #define KINGSUN_EP_OUT 1 | ||
104 | |||
105 | struct kingsun_cb { | ||
106 | struct usb_device *usbdev; /* init: probe_irda */ | ||
107 | struct net_device *netdev; /* network layer */ | ||
108 | struct irlap_cb *irlap; /* The link layer we are binded to */ | ||
109 | struct net_device_stats stats; /* network statistics */ | ||
110 | struct qos_info qos; | ||
111 | |||
112 | __u8 *in_buf; /* receive buffer */ | ||
113 | __u8 *out_buf; /* transmit buffer */ | ||
114 | __u8 max_rx; /* max. atomic read from dongle | ||
115 | (usually 8), also size of in_buf */ | ||
116 | __u8 max_tx; /* max. atomic write to dongle | ||
117 | (usually 8) */ | ||
118 | |||
119 | iobuff_t rx_buff; /* receive unwrap state machine */ | ||
120 | struct timeval rx_time; | ||
121 | spinlock_t lock; | ||
122 | int receiving; | ||
123 | |||
124 | __u8 ep_in; | ||
125 | __u8 ep_out; | ||
126 | |||
127 | struct urb *tx_urb; | ||
128 | struct urb *rx_urb; | ||
129 | }; | ||
130 | |||
131 | /* Callback transmission routine */ | ||
132 | static void kingsun_send_irq(struct urb *urb) | ||
133 | { | ||
134 | struct kingsun_cb *kingsun = urb->context; | ||
135 | struct net_device *netdev = kingsun->netdev; | ||
136 | |||
137 | /* in process of stopping, just drop data */ | ||
138 | if (!netif_running(kingsun->netdev)) { | ||
139 | err("kingsun_send_irq: Network not running!"); | ||
140 | return; | ||
141 | } | ||
142 | |||
143 | /* unlink, shutdown, unplug, other nasties */ | ||
144 | if (urb->status != 0) { | ||
145 | err("kingsun_send_irq: urb asynchronously failed - %d", | ||
146 | urb->status); | ||
147 | } | ||
148 | netif_wake_queue(netdev); | ||
149 | } | ||
150 | |||
151 | /* | ||
152 | * Called from net/core when new frame is available. | ||
153 | */ | ||
154 | static int kingsun_hard_xmit(struct sk_buff *skb, struct net_device *netdev) | ||
155 | { | ||
156 | struct kingsun_cb *kingsun; | ||
157 | int wraplen; | ||
158 | int ret = 0; | ||
159 | |||
160 | if (skb == NULL || netdev == NULL) | ||
161 | return -EINVAL; | ||
162 | |||
163 | netif_stop_queue(netdev); | ||
164 | |||
165 | /* the IRDA wrapping routines don't deal with non linear skb */ | ||
166 | SKB_LINEAR_ASSERT(skb); | ||
167 | |||
168 | kingsun = netdev_priv(netdev); | ||
169 | |||
170 | spin_lock(&kingsun->lock); | ||
171 | |||
172 | /* Append data to the end of whatever data remains to be transmitted */ | ||
173 | wraplen = async_wrap_skb(skb, | ||
174 | kingsun->out_buf, | ||
175 | KINGSUN_FIFO_SIZE); | ||
176 | |||
177 | /* Calculate how much data can be transmitted in this urb */ | ||
178 | usb_fill_int_urb(kingsun->tx_urb, kingsun->usbdev, | ||
179 | usb_sndintpipe(kingsun->usbdev, kingsun->ep_out), | ||
180 | kingsun->out_buf, wraplen, kingsun_send_irq, | ||
181 | kingsun, 1); | ||
182 | |||
183 | if ((ret = usb_submit_urb(kingsun->tx_urb, GFP_ATOMIC))) { | ||
184 | err("kingsun_hard_xmit: failed tx_urb submit: %d", ret); | ||
185 | switch (ret) { | ||
186 | case -ENODEV: | ||
187 | case -EPIPE: | ||
188 | break; | ||
189 | default: | ||
190 | kingsun->stats.tx_errors++; | ||
191 | netif_start_queue(netdev); | ||
192 | } | ||
193 | } else { | ||
194 | kingsun->stats.tx_packets++; | ||
195 | kingsun->stats.tx_bytes += skb->len; | ||
196 | } | ||
197 | |||
198 | dev_kfree_skb(skb); | ||
199 | spin_unlock(&kingsun->lock); | ||
200 | |||
201 | return ret; | ||
202 | } | ||
203 | |||
204 | /* Receive callback function */ | ||
205 | static void kingsun_rcv_irq(struct urb *urb) | ||
206 | { | ||
207 | struct kingsun_cb *kingsun = urb->context; | ||
208 | int ret; | ||
209 | |||
210 | /* in process of stopping, just drop data */ | ||
211 | if (!netif_running(kingsun->netdev)) { | ||
212 | kingsun->receiving = 0; | ||
213 | return; | ||
214 | } | ||
215 | |||
216 | /* unlink, shutdown, unplug, other nasties */ | ||
217 | if (urb->status != 0) { | ||
218 | err("kingsun_rcv_irq: urb asynchronously failed - %d", | ||
219 | urb->status); | ||
220 | kingsun->receiving = 0; | ||
221 | return; | ||
222 | } | ||
223 | |||
224 | if (urb->actual_length == kingsun->max_rx) { | ||
225 | __u8 *bytes = urb->transfer_buffer; | ||
226 | int i; | ||
227 | |||
228 | /* The very first byte in the buffer indicates the length of | ||
229 | valid data in the read. This byte must be in the range | ||
230 | 1..kingsun->max_rx -1 . Values outside this range indicate | ||
231 | an uninitialized Rx buffer when the dongle has just been | ||
232 | plugged in. */ | ||
233 | if (bytes[0] >= 1 && bytes[0] < kingsun->max_rx) { | ||
234 | for (i = 1; i <= bytes[0]; i++) { | ||
235 | async_unwrap_char(kingsun->netdev, | ||
236 | &kingsun->stats, | ||
237 | &kingsun->rx_buff, bytes[i]); | ||
238 | } | ||
239 | kingsun->netdev->last_rx = jiffies; | ||
240 | do_gettimeofday(&kingsun->rx_time); | ||
241 | kingsun->receiving = | ||
242 | (kingsun->rx_buff.state != OUTSIDE_FRAME) | ||
243 | ? 1 : 0; | ||
244 | } | ||
245 | } else if (urb->actual_length > 0) { | ||
246 | err("%s(): Unexpected response length, expected %d got %d", | ||
247 | __FUNCTION__, kingsun->max_rx, urb->actual_length); | ||
248 | } | ||
249 | /* This urb has already been filled in kingsun_net_open */ | ||
250 | ret = usb_submit_urb(urb, GFP_ATOMIC); | ||
251 | } | ||
252 | |||
253 | /* | ||
254 | * Function kingsun_net_open (dev) | ||
255 | * | ||
256 | * Network device is taken up. Usually this is done by "ifconfig irda0 up" | ||
257 | */ | ||
258 | static int kingsun_net_open(struct net_device *netdev) | ||
259 | { | ||
260 | struct kingsun_cb *kingsun = netdev_priv(netdev); | ||
261 | int err = -ENOMEM; | ||
262 | char hwname[16]; | ||
263 | |||
264 | /* At this point, urbs are NULL, and skb is NULL (see kingsun_probe) */ | ||
265 | kingsun->receiving = 0; | ||
266 | |||
267 | /* Initialize for SIR to copy data directly into skb. */ | ||
268 | kingsun->rx_buff.in_frame = FALSE; | ||
269 | kingsun->rx_buff.state = OUTSIDE_FRAME; | ||
270 | kingsun->rx_buff.truesize = IRDA_SKB_MAX_MTU; | ||
271 | kingsun->rx_buff.skb = dev_alloc_skb(IRDA_SKB_MAX_MTU); | ||
272 | if (!kingsun->rx_buff.skb) | ||
273 | goto free_mem; | ||
274 | |||
275 | skb_reserve(kingsun->rx_buff.skb, 1); | ||
276 | kingsun->rx_buff.head = kingsun->rx_buff.skb->data; | ||
277 | do_gettimeofday(&kingsun->rx_time); | ||
278 | |||
279 | kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
280 | if (!kingsun->rx_urb) | ||
281 | goto free_mem; | ||
282 | |||
283 | kingsun->tx_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
284 | if (!kingsun->tx_urb) | ||
285 | goto free_mem; | ||
286 | |||
287 | /* | ||
288 | * Now that everything should be initialized properly, | ||
289 | * Open new IrLAP layer instance to take care of us... | ||
290 | */ | ||
291 | sprintf(hwname, "usb#%d", kingsun->usbdev->devnum); | ||
292 | kingsun->irlap = irlap_open(netdev, &kingsun->qos, hwname); | ||
293 | if (!kingsun->irlap) { | ||
294 | err("kingsun-sir: irlap_open failed"); | ||
295 | goto free_mem; | ||
296 | } | ||
297 | |||
298 | /* Start first reception */ | ||
299 | usb_fill_int_urb(kingsun->rx_urb, kingsun->usbdev, | ||
300 | usb_rcvintpipe(kingsun->usbdev, kingsun->ep_in), | ||
301 | kingsun->in_buf, kingsun->max_rx, | ||
302 | kingsun_rcv_irq, kingsun, 1); | ||
303 | kingsun->rx_urb->status = 0; | ||
304 | err = usb_submit_urb(kingsun->rx_urb, GFP_KERNEL); | ||
305 | if (err) { | ||
306 | err("kingsun-sir: first urb-submit failed: %d", err); | ||
307 | goto close_irlap; | ||
308 | } | ||
309 | |||
310 | netif_start_queue(netdev); | ||
311 | |||
312 | /* Situation at this point: | ||
313 | - all work buffers allocated | ||
314 | - urbs allocated and ready to fill | ||
315 | - max rx packet known (in max_rx) | ||
316 | - unwrap state machine initialized, in state outside of any frame | ||
317 | - receive request in progress | ||
318 | - IrLAP layer started, about to hand over packets to send | ||
319 | */ | ||
320 | |||
321 | return 0; | ||
322 | |||
323 | close_irlap: | ||
324 | irlap_close(kingsun->irlap); | ||
325 | free_mem: | ||
326 | if (kingsun->tx_urb) { | ||
327 | usb_free_urb(kingsun->tx_urb); | ||
328 | kingsun->tx_urb = NULL; | ||
329 | } | ||
330 | if (kingsun->rx_urb) { | ||
331 | usb_free_urb(kingsun->rx_urb); | ||
332 | kingsun->rx_urb = NULL; | ||
333 | } | ||
334 | if (kingsun->rx_buff.skb) { | ||
335 | kfree_skb(kingsun->rx_buff.skb); | ||
336 | kingsun->rx_buff.skb = NULL; | ||
337 | kingsun->rx_buff.head = NULL; | ||
338 | } | ||
339 | return err; | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * Function kingsun_net_close (kingsun) | ||
344 | * | ||
345 | * Network device is taken down. Usually this is done by | ||
346 | * "ifconfig irda0 down" | ||
347 | */ | ||
348 | static int kingsun_net_close(struct net_device *netdev) | ||
349 | { | ||
350 | struct kingsun_cb *kingsun = netdev_priv(netdev); | ||
351 | |||
352 | /* Stop transmit processing */ | ||
353 | netif_stop_queue(netdev); | ||
354 | |||
355 | /* Mop up receive && transmit urb's */ | ||
356 | usb_kill_urb(kingsun->tx_urb); | ||
357 | usb_kill_urb(kingsun->rx_urb); | ||
358 | |||
359 | usb_free_urb(kingsun->tx_urb); | ||
360 | usb_free_urb(kingsun->rx_urb); | ||
361 | |||
362 | kingsun->tx_urb = NULL; | ||
363 | kingsun->rx_urb = NULL; | ||
364 | |||
365 | kfree_skb(kingsun->rx_buff.skb); | ||
366 | kingsun->rx_buff.skb = NULL; | ||
367 | kingsun->rx_buff.head = NULL; | ||
368 | kingsun->rx_buff.in_frame = FALSE; | ||
369 | kingsun->rx_buff.state = OUTSIDE_FRAME; | ||
370 | kingsun->receiving = 0; | ||
371 | |||
372 | /* Stop and remove instance of IrLAP */ | ||
373 | if (kingsun->irlap) | ||
374 | irlap_close(kingsun->irlap); | ||
375 | |||
376 | kingsun->irlap = NULL; | ||
377 | |||
378 | return 0; | ||
379 | } | ||
380 | |||
381 | /* | ||
382 | * IOCTLs : Extra out-of-band network commands... | ||
383 | */ | ||
384 | static int kingsun_net_ioctl(struct net_device *netdev, struct ifreq *rq, | ||
385 | int cmd) | ||
386 | { | ||
387 | struct if_irda_req *irq = (struct if_irda_req *) rq; | ||
388 | struct kingsun_cb *kingsun = netdev_priv(netdev); | ||
389 | int ret = 0; | ||
390 | |||
391 | switch (cmd) { | ||
392 | case SIOCSBANDWIDTH: /* Set bandwidth */ | ||
393 | if (!capable(CAP_NET_ADMIN)) | ||
394 | return -EPERM; | ||
395 | |||
396 | /* Check if the device is still there */ | ||
397 | if (netif_device_present(kingsun->netdev)) | ||
398 | /* No observed commands for speed change */ | ||
399 | ret = -EOPNOTSUPP; | ||
400 | break; | ||
401 | |||
402 | case SIOCSMEDIABUSY: /* Set media busy */ | ||
403 | if (!capable(CAP_NET_ADMIN)) | ||
404 | return -EPERM; | ||
405 | |||
406 | /* Check if the IrDA stack is still there */ | ||
407 | if (netif_running(kingsun->netdev)) | ||
408 | irda_device_set_media_busy(kingsun->netdev, TRUE); | ||
409 | break; | ||
410 | |||
411 | case SIOCGRECEIVING: | ||
412 | /* Only approximately true */ | ||
413 | irq->ifr_receiving = kingsun->receiving; | ||
414 | break; | ||
415 | |||
416 | default: | ||
417 | ret = -EOPNOTSUPP; | ||
418 | } | ||
419 | |||
420 | return ret; | ||
421 | } | ||
422 | |||
423 | /* | ||
424 | * Get device stats (for /proc/net/dev and ifconfig) | ||
425 | */ | ||
426 | static struct net_device_stats * | ||
427 | kingsun_net_get_stats(struct net_device *netdev) | ||
428 | { | ||
429 | struct kingsun_cb *kingsun = netdev_priv(netdev); | ||
430 | return &kingsun->stats; | ||
431 | } | ||
432 | |||
433 | /* | ||
434 | * This routine is called by the USB subsystem for each new device | ||
435 | * in the system. We need to check if the device is ours, and in | ||
436 | * this case start handling it. | ||
437 | */ | ||
438 | static int kingsun_probe(struct usb_interface *intf, | ||
439 | const struct usb_device_id *id) | ||
440 | { | ||
441 | struct usb_host_interface *interface; | ||
442 | struct usb_endpoint_descriptor *endpoint; | ||
443 | |||
444 | struct usb_device *dev = interface_to_usbdev(intf); | ||
445 | struct kingsun_cb *kingsun = NULL; | ||
446 | struct net_device *net = NULL; | ||
447 | int ret = -ENOMEM; | ||
448 | int pipe, maxp_in, maxp_out; | ||
449 | __u8 ep_in; | ||
450 | __u8 ep_out; | ||
451 | |||
452 | /* Check that there really are two interrupt endpoints. | ||
453 | Check based on the one in drivers/usb/input/usbmouse.c | ||
454 | */ | ||
455 | interface = intf->cur_altsetting; | ||
456 | if (interface->desc.bNumEndpoints != 2) { | ||
457 | err("kingsun-sir: expected 2 endpoints, found %d", | ||
458 | interface->desc.bNumEndpoints); | ||
459 | return -ENODEV; | ||
460 | } | ||
461 | endpoint = &interface->endpoint[KINGSUN_EP_IN].desc; | ||
462 | if (!usb_endpoint_is_int_in(endpoint)) { | ||
463 | err("kingsun-sir: endpoint 0 is not interrupt IN"); | ||
464 | return -ENODEV; | ||
465 | } | ||
466 | |||
467 | ep_in = endpoint->bEndpointAddress; | ||
468 | pipe = usb_rcvintpipe(dev, ep_in); | ||
469 | maxp_in = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | ||
470 | if (maxp_in > 255 || maxp_in <= 1) { | ||
471 | err("%s: endpoint 0 has max packet size %d not in range", | ||
472 | __FILE__, maxp_in); | ||
473 | return -ENODEV; | ||
474 | } | ||
475 | |||
476 | endpoint = &interface->endpoint[KINGSUN_EP_OUT].desc; | ||
477 | if (!usb_endpoint_is_int_out(endpoint)) { | ||
478 | err("kingsun-sir: endpoint 1 is not interrupt OUT"); | ||
479 | return -ENODEV; | ||
480 | } | ||
481 | |||
482 | ep_out = endpoint->bEndpointAddress; | ||
483 | pipe = usb_sndintpipe(dev, ep_out); | ||
484 | maxp_out = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | ||
485 | |||
486 | /* Allocate network device container. */ | ||
487 | net = alloc_irdadev(sizeof(*kingsun)); | ||
488 | if(!net) | ||
489 | goto err_out1; | ||
490 | |||
491 | SET_MODULE_OWNER(net); | ||
492 | SET_NETDEV_DEV(net, &intf->dev); | ||
493 | kingsun = netdev_priv(net); | ||
494 | kingsun->irlap = NULL; | ||
495 | kingsun->tx_urb = NULL; | ||
496 | kingsun->rx_urb = NULL; | ||
497 | kingsun->ep_in = ep_in; | ||
498 | kingsun->ep_out = ep_out; | ||
499 | kingsun->in_buf = NULL; | ||
500 | kingsun->out_buf = NULL; | ||
501 | kingsun->max_rx = (__u8)maxp_in; | ||
502 | kingsun->max_tx = (__u8)maxp_out; | ||
503 | kingsun->netdev = net; | ||
504 | kingsun->usbdev = dev; | ||
505 | kingsun->rx_buff.in_frame = FALSE; | ||
506 | kingsun->rx_buff.state = OUTSIDE_FRAME; | ||
507 | kingsun->rx_buff.skb = NULL; | ||
508 | kingsun->receiving = 0; | ||
509 | spin_lock_init(&kingsun->lock); | ||
510 | |||
511 | /* Allocate input buffer */ | ||
512 | kingsun->in_buf = (__u8 *)kmalloc(kingsun->max_rx, GFP_KERNEL); | ||
513 | if (!kingsun->in_buf) | ||
514 | goto free_mem; | ||
515 | |||
516 | /* Allocate output buffer */ | ||
517 | kingsun->out_buf = (__u8 *)kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL); | ||
518 | if (!kingsun->out_buf) | ||
519 | goto free_mem; | ||
520 | |||
521 | printk(KERN_INFO "KingSun/DonShine IRDA/USB found at address %d, " | ||
522 | "Vendor: %x, Product: %x\n", | ||
523 | dev->devnum, le16_to_cpu(dev->descriptor.idVendor), | ||
524 | le16_to_cpu(dev->descriptor.idProduct)); | ||
525 | |||
526 | /* Initialize QoS for this device */ | ||
527 | irda_init_max_qos_capabilies(&kingsun->qos); | ||
528 | |||
529 | /* That's the Rx capability. */ | ||
530 | kingsun->qos.baud_rate.bits &= IR_9600; | ||
531 | kingsun->qos.min_turn_time.bits &= KINGSUN_MTT; | ||
532 | irda_qos_bits_to_value(&kingsun->qos); | ||
533 | |||
534 | /* Override the network functions we need to use */ | ||
535 | net->hard_start_xmit = kingsun_hard_xmit; | ||
536 | net->open = kingsun_net_open; | ||
537 | net->stop = kingsun_net_close; | ||
538 | net->get_stats = kingsun_net_get_stats; | ||
539 | net->do_ioctl = kingsun_net_ioctl; | ||
540 | |||
541 | ret = register_netdev(net); | ||
542 | if (ret != 0) | ||
543 | goto free_mem; | ||
544 | |||
545 | info("IrDA: Registered KingSun/DonShine device %s", net->name); | ||
546 | |||
547 | usb_set_intfdata(intf, kingsun); | ||
548 | |||
549 | /* Situation at this point: | ||
550 | - all work buffers allocated | ||
551 | - urbs not allocated, set to NULL | ||
552 | - max rx packet known (in max_rx) | ||
553 | - unwrap state machine (partially) initialized, but skb == NULL | ||
554 | */ | ||
555 | |||
556 | return 0; | ||
557 | |||
558 | free_mem: | ||
559 | if (kingsun->out_buf) kfree(kingsun->out_buf); | ||
560 | if (kingsun->in_buf) kfree(kingsun->in_buf); | ||
561 | free_netdev(net); | ||
562 | err_out1: | ||
563 | return ret; | ||
564 | } | ||
565 | |||
566 | /* | ||
567 | * The current device is removed, the USB layer tell us to shut it down... | ||
568 | */ | ||
569 | static void kingsun_disconnect(struct usb_interface *intf) | ||
570 | { | ||
571 | struct kingsun_cb *kingsun = usb_get_intfdata(intf); | ||
572 | |||
573 | if (!kingsun) | ||
574 | return; | ||
575 | |||
576 | unregister_netdev(kingsun->netdev); | ||
577 | |||
578 | /* Mop up receive && transmit urb's */ | ||
579 | if (kingsun->tx_urb != NULL) { | ||
580 | usb_kill_urb(kingsun->tx_urb); | ||
581 | usb_free_urb(kingsun->tx_urb); | ||
582 | kingsun->tx_urb = NULL; | ||
583 | } | ||
584 | if (kingsun->rx_urb != NULL) { | ||
585 | usb_kill_urb(kingsun->rx_urb); | ||
586 | usb_free_urb(kingsun->rx_urb); | ||
587 | kingsun->rx_urb = NULL; | ||
588 | } | ||
589 | |||
590 | kfree(kingsun->out_buf); | ||
591 | kfree(kingsun->in_buf); | ||
592 | free_netdev(kingsun->netdev); | ||
593 | |||
594 | usb_set_intfdata(intf, NULL); | ||
595 | } | ||
596 | |||
597 | #ifdef CONFIG_PM | ||
598 | /* USB suspend, so power off the transmitter/receiver */ | ||
599 | static int kingsun_suspend(struct usb_interface *intf, pm_message_t message) | ||
600 | { | ||
601 | struct kingsun_cb *kingsun = usb_get_intfdata(intf); | ||
602 | |||
603 | netif_device_detach(kingsun->netdev); | ||
604 | if (kingsun->tx_urb != NULL) usb_kill_urb(kingsun->tx_urb); | ||
605 | if (kingsun->rx_urb != NULL) usb_kill_urb(kingsun->rx_urb); | ||
606 | return 0; | ||
607 | } | ||
608 | |||
609 | /* Coming out of suspend, so reset hardware */ | ||
610 | static int kingsun_resume(struct usb_interface *intf) | ||
611 | { | ||
612 | struct kingsun_cb *kingsun = usb_get_intfdata(intf); | ||
613 | |||
614 | if (kingsun->rx_urb != NULL) | ||
615 | usb_submit_urb(kingsun->rx_urb, GFP_KERNEL); | ||
616 | netif_device_attach(kingsun->netdev); | ||
617 | |||
618 | return 0; | ||
619 | } | ||
620 | #endif | ||
621 | |||
622 | /* | ||
623 | * USB device callbacks | ||
624 | */ | ||
625 | static struct usb_driver irda_driver = { | ||
626 | .name = "kingsun-sir", | ||
627 | .probe = kingsun_probe, | ||
628 | .disconnect = kingsun_disconnect, | ||
629 | .id_table = dongles, | ||
630 | #ifdef CONFIG_PM | ||
631 | .suspend = kingsun_suspend, | ||
632 | .resume = kingsun_resume, | ||
633 | #endif | ||
634 | }; | ||
635 | |||
636 | /* | ||
637 | * Module insertion | ||
638 | */ | ||
639 | static int __init kingsun_init(void) | ||
640 | { | ||
641 | return usb_register(&irda_driver); | ||
642 | } | ||
643 | module_init(kingsun_init); | ||
644 | |||
645 | /* | ||
646 | * Module removal | ||
647 | */ | ||
648 | static void __exit kingsun_cleanup(void) | ||
649 | { | ||
650 | /* Deregister the driver and remove all pending instances */ | ||
651 | usb_deregister(&irda_driver); | ||
652 | } | ||
653 | module_exit(kingsun_cleanup); | ||
654 | |||
655 | MODULE_AUTHOR("Alex Villac�s Lasso <a_villacis@palosanto.com>"); | ||
656 | MODULE_DESCRIPTION("IrDA-USB Dongle Driver for KingSun/DonShine"); | ||
657 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c index acf1c801a1b8..af016d0ea1c6 100644 --- a/drivers/net/mlx4/eq.c +++ b/drivers/net/mlx4/eq.c | |||
@@ -623,7 +623,7 @@ int __devinit mlx4_init_eq_table(struct mlx4_dev *dev) | |||
623 | priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1; | 623 | priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1; |
624 | } else { | 624 | } else { |
625 | err = request_irq(dev->pdev->irq, mlx4_interrupt, | 625 | err = request_irq(dev->pdev->irq, mlx4_interrupt, |
626 | SA_SHIRQ, DRV_NAME, dev); | 626 | IRQF_SHARED, DRV_NAME, dev); |
627 | if (err) | 627 | if (err) |
628 | goto err_out_async; | 628 | goto err_out_async; |
629 | 629 | ||
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 4e32bb678ea9..2c5c6d20e6e9 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -735,7 +735,7 @@ static int netxen_nic_open(struct net_device *netdev) | |||
735 | } | 735 | } |
736 | adapter->irq = adapter->ahw.pdev->irq; | 736 | adapter->irq = adapter->ahw.pdev->irq; |
737 | err = request_irq(adapter->ahw.pdev->irq, netxen_intr, | 737 | err = request_irq(adapter->ahw.pdev->irq, netxen_intr, |
738 | SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, | 738 | IRQF_SHARED|IRQF_SAMPLE_RANDOM, netdev->name, |
739 | adapter); | 739 | adapter); |
740 | if (err) { | 740 | if (err) { |
741 | printk(KERN_ERR "request_irq failed with: %d\n", err); | 741 | printk(KERN_ERR "request_irq failed with: %d\n", err); |
diff --git a/drivers/net/pcmcia/Kconfig b/drivers/net/pcmcia/Kconfig index 74f862001247..5d658bc9791c 100644 --- a/drivers/net/pcmcia/Kconfig +++ b/drivers/net/pcmcia/Kconfig | |||
@@ -2,11 +2,9 @@ | |||
2 | # PCMCIA Network device configuration | 2 | # PCMCIA Network device configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "PCMCIA network device support" | 5 | menuconfig NET_PCMCIA |
6 | depends on NETDEVICES && PCMCIA!=n | ||
7 | |||
8 | config NET_PCMCIA | ||
9 | bool "PCMCIA network device support" | 6 | bool "PCMCIA network device support" |
7 | depends on PCMCIA | ||
10 | ---help--- | 8 | ---help--- |
11 | Say Y if you would like to include support for any PCMCIA or CardBus | 9 | Say Y if you would like to include support for any PCMCIA or CardBus |
12 | network adapters, then say Y to the driver for your particular card | 10 | network adapters, then say Y to the driver for your particular card |
@@ -21,9 +19,10 @@ config NET_PCMCIA | |||
21 | 19 | ||
22 | If unsure, say N. | 20 | If unsure, say N. |
23 | 21 | ||
22 | if NET_PCMCIA | ||
23 | |||
24 | config PCMCIA_3C589 | 24 | config PCMCIA_3C589 |
25 | tristate "3Com 3c589 PCMCIA support" | 25 | tristate "3Com 3c589 PCMCIA support" |
26 | depends on NET_PCMCIA && PCMCIA | ||
27 | help | 26 | help |
28 | Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA | 27 | Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA |
29 | (PC-card) Ethernet card to your computer. | 28 | (PC-card) Ethernet card to your computer. |
@@ -33,7 +32,6 @@ config PCMCIA_3C589 | |||
33 | 32 | ||
34 | config PCMCIA_3C574 | 33 | config PCMCIA_3C574 |
35 | tristate "3Com 3c574 PCMCIA support" | 34 | tristate "3Com 3c574 PCMCIA support" |
36 | depends on NET_PCMCIA && PCMCIA | ||
37 | help | 35 | help |
38 | Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA | 36 | Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA |
39 | (PC-card) Fast Ethernet card to your computer. | 37 | (PC-card) Fast Ethernet card to your computer. |
@@ -43,7 +41,6 @@ config PCMCIA_3C574 | |||
43 | 41 | ||
44 | config PCMCIA_FMVJ18X | 42 | config PCMCIA_FMVJ18X |
45 | tristate "Fujitsu FMV-J18x PCMCIA support" | 43 | tristate "Fujitsu FMV-J18x PCMCIA support" |
46 | depends on NET_PCMCIA && PCMCIA | ||
47 | select CRC32 | 44 | select CRC32 |
48 | help | 45 | help |
49 | Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible | 46 | Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible |
@@ -54,7 +51,6 @@ config PCMCIA_FMVJ18X | |||
54 | 51 | ||
55 | config PCMCIA_PCNET | 52 | config PCMCIA_PCNET |
56 | tristate "NE2000 compatible PCMCIA support" | 53 | tristate "NE2000 compatible PCMCIA support" |
57 | depends on NET_PCMCIA && PCMCIA | ||
58 | select CRC32 | 54 | select CRC32 |
59 | help | 55 | help |
60 | Say Y here if you intend to attach an NE2000 compatible PCMCIA | 56 | Say Y here if you intend to attach an NE2000 compatible PCMCIA |
@@ -65,7 +61,6 @@ config PCMCIA_PCNET | |||
65 | 61 | ||
66 | config PCMCIA_NMCLAN | 62 | config PCMCIA_NMCLAN |
67 | tristate "New Media PCMCIA support" | 63 | tristate "New Media PCMCIA support" |
68 | depends on NET_PCMCIA && PCMCIA | ||
69 | help | 64 | help |
70 | Say Y here if you intend to attach a New Media Ethernet or LiveWire | 65 | Say Y here if you intend to attach a New Media Ethernet or LiveWire |
71 | PCMCIA (PC-card) Ethernet card to your computer. | 66 | PCMCIA (PC-card) Ethernet card to your computer. |
@@ -75,7 +70,6 @@ config PCMCIA_NMCLAN | |||
75 | 70 | ||
76 | config PCMCIA_SMC91C92 | 71 | config PCMCIA_SMC91C92 |
77 | tristate "SMC 91Cxx PCMCIA support" | 72 | tristate "SMC 91Cxx PCMCIA support" |
78 | depends on NET_PCMCIA && PCMCIA | ||
79 | select CRC32 | 73 | select CRC32 |
80 | select MII | 74 | select MII |
81 | help | 75 | help |
@@ -87,7 +81,6 @@ config PCMCIA_SMC91C92 | |||
87 | 81 | ||
88 | config PCMCIA_XIRC2PS | 82 | config PCMCIA_XIRC2PS |
89 | tristate "Xircom 16-bit PCMCIA support" | 83 | tristate "Xircom 16-bit PCMCIA support" |
90 | depends on NET_PCMCIA && PCMCIA | ||
91 | help | 84 | help |
92 | Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card) | 85 | Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card) |
93 | Ethernet or Fast Ethernet card to your computer. | 86 | Ethernet or Fast Ethernet card to your computer. |
@@ -97,7 +90,6 @@ config PCMCIA_XIRC2PS | |||
97 | 90 | ||
98 | config PCMCIA_AXNET | 91 | config PCMCIA_AXNET |
99 | tristate "Asix AX88190 PCMCIA support" | 92 | tristate "Asix AX88190 PCMCIA support" |
100 | depends on NET_PCMCIA && PCMCIA | ||
101 | ---help--- | 93 | ---help--- |
102 | Say Y here if you intend to attach an Asix AX88190-based PCMCIA | 94 | Say Y here if you intend to attach an Asix AX88190-based PCMCIA |
103 | (PC-card) Fast Ethernet card to your computer. These cards are | 95 | (PC-card) Fast Ethernet card to your computer. These cards are |
@@ -109,7 +101,7 @@ config PCMCIA_AXNET | |||
109 | 101 | ||
110 | config ARCNET_COM20020_CS | 102 | config ARCNET_COM20020_CS |
111 | tristate "COM20020 ARCnet PCMCIA support" | 103 | tristate "COM20020 ARCnet PCMCIA support" |
112 | depends on NET_PCMCIA && ARCNET_COM20020 && PCMCIA | 104 | depends on ARCNET_COM20020 |
113 | help | 105 | help |
114 | Say Y here if you intend to attach this type of ARCnet PCMCIA card | 106 | Say Y here if you intend to attach this type of ARCnet PCMCIA card |
115 | to your computer. | 107 | to your computer. |
@@ -119,7 +111,7 @@ config ARCNET_COM20020_CS | |||
119 | 111 | ||
120 | config PCMCIA_IBMTR | 112 | config PCMCIA_IBMTR |
121 | tristate "IBM PCMCIA tokenring adapter support" | 113 | tristate "IBM PCMCIA tokenring adapter support" |
122 | depends on NET_PCMCIA && IBMTR!=y && TR && PCMCIA && !64BIT | 114 | depends on IBMTR!=y && TR && !64BIT |
123 | help | 115 | help |
124 | Say Y here if you intend to attach this type of Token Ring PCMCIA | 116 | Say Y here if you intend to attach this type of Token Ring PCMCIA |
125 | card to your computer. You then also need to say Y to "Token Ring | 117 | card to your computer. You then also need to say Y to "Token Ring |
@@ -128,5 +120,4 @@ config PCMCIA_IBMTR | |||
128 | To compile this driver as a module, choose M here: the module will be | 120 | To compile this driver as a module, choose M here: the module will be |
129 | called ibmtr_cs. | 121 | called ibmtr_cs. |
130 | 122 | ||
131 | endmenu | 123 | endif # NET_PCMCIA |
132 | |||
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index f994f129f3d8..09b6f259eb92 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
@@ -2,69 +2,61 @@ | |||
2 | # PHY Layer Configuration | 2 | # PHY Layer Configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "PHY device support" | 5 | menuconfig PHYLIB |
6 | |||
7 | config PHYLIB | ||
8 | tristate "PHY Device support and infrastructure" | 6 | tristate "PHY Device support and infrastructure" |
7 | depends on !S390 | ||
9 | depends on NET_ETHERNET && (BROKEN || !S390) | 8 | depends on NET_ETHERNET && (BROKEN || !S390) |
10 | help | 9 | help |
11 | Ethernet controllers are usually attached to PHY | 10 | Ethernet controllers are usually attached to PHY |
12 | devices. This option provides infrastructure for | 11 | devices. This option provides infrastructure for |
13 | managing PHY devices. | 12 | managing PHY devices. |
14 | 13 | ||
14 | if PHYLIB | ||
15 | |||
15 | comment "MII PHY device drivers" | 16 | comment "MII PHY device drivers" |
16 | depends on PHYLIB | ||
17 | 17 | ||
18 | config MARVELL_PHY | 18 | config MARVELL_PHY |
19 | tristate "Drivers for Marvell PHYs" | 19 | tristate "Drivers for Marvell PHYs" |
20 | depends on PHYLIB | ||
21 | ---help--- | 20 | ---help--- |
22 | Currently has a driver for the 88E1011S | 21 | Currently has a driver for the 88E1011S |
23 | 22 | ||
24 | config DAVICOM_PHY | 23 | config DAVICOM_PHY |
25 | tristate "Drivers for Davicom PHYs" | 24 | tristate "Drivers for Davicom PHYs" |
26 | depends on PHYLIB | ||
27 | ---help--- | 25 | ---help--- |
28 | Currently supports dm9161e and dm9131 | 26 | Currently supports dm9161e and dm9131 |
29 | 27 | ||
30 | config QSEMI_PHY | 28 | config QSEMI_PHY |
31 | tristate "Drivers for Quality Semiconductor PHYs" | 29 | tristate "Drivers for Quality Semiconductor PHYs" |
32 | depends on PHYLIB | ||
33 | ---help--- | 30 | ---help--- |
34 | Currently supports the qs6612 | 31 | Currently supports the qs6612 |
35 | 32 | ||
36 | config LXT_PHY | 33 | config LXT_PHY |
37 | tristate "Drivers for the Intel LXT PHYs" | 34 | tristate "Drivers for the Intel LXT PHYs" |
38 | depends on PHYLIB | ||
39 | ---help--- | 35 | ---help--- |
40 | Currently supports the lxt970, lxt971 | 36 | Currently supports the lxt970, lxt971 |
41 | 37 | ||
42 | config CICADA_PHY | 38 | config CICADA_PHY |
43 | tristate "Drivers for the Cicada PHYs" | 39 | tristate "Drivers for the Cicada PHYs" |
44 | depends on PHYLIB | ||
45 | ---help--- | 40 | ---help--- |
46 | Currently supports the cis8204 | 41 | Currently supports the cis8204 |
42 | |||
47 | config VITESSE_PHY | 43 | config VITESSE_PHY |
48 | tristate "Drivers for the Vitesse PHYs" | 44 | tristate "Drivers for the Vitesse PHYs" |
49 | depends on PHYLIB | ||
50 | ---help--- | 45 | ---help--- |
51 | Currently supports the vsc8244 | 46 | Currently supports the vsc8244 |
52 | 47 | ||
53 | config SMSC_PHY | 48 | config SMSC_PHY |
54 | tristate "Drivers for SMSC PHYs" | 49 | tristate "Drivers for SMSC PHYs" |
55 | depends on PHYLIB | ||
56 | ---help--- | 50 | ---help--- |
57 | Currently supports the LAN83C185 PHY | 51 | Currently supports the LAN83C185 PHY |
58 | 52 | ||
59 | config BROADCOM_PHY | 53 | config BROADCOM_PHY |
60 | tristate "Drivers for Broadcom PHYs" | 54 | tristate "Drivers for Broadcom PHYs" |
61 | depends on PHYLIB | ||
62 | ---help--- | 55 | ---help--- |
63 | Currently supports the BCM5411, BCM5421 and BCM5461 PHYs. | 56 | Currently supports the BCM5411, BCM5421 and BCM5461 PHYs. |
64 | 57 | ||
65 | config FIXED_PHY | 58 | config FIXED_PHY |
66 | tristate "Drivers for PHY emulation on fixed speed/link" | 59 | tristate "Drivers for PHY emulation on fixed speed/link" |
67 | depends on PHYLIB | ||
68 | ---help--- | 60 | ---help--- |
69 | Adds the driver to PHY layer to cover the boards that do not have any PHY bound, | 61 | Adds the driver to PHY layer to cover the boards that do not have any PHY bound, |
70 | but with the ability to manipulate the speed/link in software. The relevant MII | 62 | but with the ability to manipulate the speed/link in software. The relevant MII |
@@ -79,5 +71,4 @@ config FIXED_MII_100_FDX | |||
79 | bool "Emulation for 100M Fdx fixed PHY behavior" | 71 | bool "Emulation for 100M Fdx fixed PHY behavior" |
80 | depends on FIXED_PHY | 72 | depends on FIXED_PHY |
81 | 73 | ||
82 | endmenu | 74 | endif # PHYLIB |
83 | |||
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c index 519baa38be8d..7ed632db00d7 100644 --- a/drivers/net/phy/davicom.c +++ b/drivers/net/phy/davicom.c | |||
@@ -139,7 +139,7 @@ static int dm9161_ack_interrupt(struct phy_device *phydev) | |||
139 | return (err < 0) ? err : 0; | 139 | return (err < 0) ? err : 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | static struct phy_driver dm9161_driver = { | 142 | static struct phy_driver dm9161e_driver = { |
143 | .phy_id = 0x0181b880, | 143 | .phy_id = 0x0181b880, |
144 | .name = "Davicom DM9161E", | 144 | .name = "Davicom DM9161E", |
145 | .phy_id_mask = 0x0ffffff0, | 145 | .phy_id_mask = 0x0ffffff0, |
@@ -147,7 +147,18 @@ static struct phy_driver dm9161_driver = { | |||
147 | .config_init = dm9161_config_init, | 147 | .config_init = dm9161_config_init, |
148 | .config_aneg = dm9161_config_aneg, | 148 | .config_aneg = dm9161_config_aneg, |
149 | .read_status = genphy_read_status, | 149 | .read_status = genphy_read_status, |
150 | .driver = { .owner = THIS_MODULE,}, | 150 | .driver = { .owner = THIS_MODULE,}, |
151 | }; | ||
152 | |||
153 | static struct phy_driver dm9161a_driver = { | ||
154 | .phy_id = 0x0181b8a0, | ||
155 | .name = "Davicom DM9161A", | ||
156 | .phy_id_mask = 0x0ffffff0, | ||
157 | .features = PHY_BASIC_FEATURES, | ||
158 | .config_init = dm9161_config_init, | ||
159 | .config_aneg = dm9161_config_aneg, | ||
160 | .read_status = genphy_read_status, | ||
161 | .driver = { .owner = THIS_MODULE,}, | ||
151 | }; | 162 | }; |
152 | 163 | ||
153 | static struct phy_driver dm9131_driver = { | 164 | static struct phy_driver dm9131_driver = { |
@@ -160,31 +171,38 @@ static struct phy_driver dm9131_driver = { | |||
160 | .read_status = genphy_read_status, | 171 | .read_status = genphy_read_status, |
161 | .ack_interrupt = dm9161_ack_interrupt, | 172 | .ack_interrupt = dm9161_ack_interrupt, |
162 | .config_intr = dm9161_config_intr, | 173 | .config_intr = dm9161_config_intr, |
163 | .driver = { .owner = THIS_MODULE,}, | 174 | .driver = { .owner = THIS_MODULE,}, |
164 | }; | 175 | }; |
165 | 176 | ||
166 | static int __init davicom_init(void) | 177 | static int __init davicom_init(void) |
167 | { | 178 | { |
168 | int ret; | 179 | int ret; |
169 | 180 | ||
170 | ret = phy_driver_register(&dm9161_driver); | 181 | ret = phy_driver_register(&dm9161e_driver); |
171 | if (ret) | 182 | if (ret) |
172 | goto err1; | 183 | goto err1; |
173 | 184 | ||
174 | ret = phy_driver_register(&dm9131_driver); | 185 | ret = phy_driver_register(&dm9161a_driver); |
175 | if (ret) | 186 | if (ret) |
176 | goto err2; | 187 | goto err2; |
188 | |||
189 | ret = phy_driver_register(&dm9131_driver); | ||
190 | if (ret) | ||
191 | goto err3; | ||
177 | return 0; | 192 | return 0; |
178 | 193 | ||
179 | err2: | 194 | err3: |
180 | phy_driver_unregister(&dm9161_driver); | 195 | phy_driver_unregister(&dm9161a_driver); |
196 | err2: | ||
197 | phy_driver_unregister(&dm9161e_driver); | ||
181 | err1: | 198 | err1: |
182 | return ret; | 199 | return ret; |
183 | } | 200 | } |
184 | 201 | ||
185 | static void __exit davicom_exit(void) | 202 | static void __exit davicom_exit(void) |
186 | { | 203 | { |
187 | phy_driver_unregister(&dm9161_driver); | 204 | phy_driver_unregister(&dm9161e_driver); |
205 | phy_driver_unregister(&dm9161a_driver); | ||
188 | phy_driver_unregister(&dm9131_driver); | 206 | phy_driver_unregister(&dm9131_driver); |
189 | } | 207 | } |
190 | 208 | ||
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 290e1c1f30c6..e3e6d410d72c 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -84,7 +84,7 @@ | |||
84 | #include "s2io.h" | 84 | #include "s2io.h" |
85 | #include "s2io-regs.h" | 85 | #include "s2io-regs.h" |
86 | 86 | ||
87 | #define DRV_VERSION "2.0.22.1" | 87 | #define DRV_VERSION "2.0.23.1" |
88 | 88 | ||
89 | /* S2io Driver name & version. */ | 89 | /* S2io Driver name & version. */ |
90 | static char s2io_driver_name[] = "Neterion"; | 90 | static char s2io_driver_name[] = "Neterion"; |
@@ -281,6 +281,28 @@ static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = { | |||
281 | ("lro_out_of_sequence_pkts"), | 281 | ("lro_out_of_sequence_pkts"), |
282 | ("lro_flush_due_to_max_pkts"), | 282 | ("lro_flush_due_to_max_pkts"), |
283 | ("lro_avg_aggr_pkts"), | 283 | ("lro_avg_aggr_pkts"), |
284 | ("mem_alloc_fail_cnt"), | ||
285 | ("watchdog_timer_cnt"), | ||
286 | ("mem_allocated"), | ||
287 | ("mem_freed"), | ||
288 | ("link_up_cnt"), | ||
289 | ("link_down_cnt"), | ||
290 | ("link_up_time"), | ||
291 | ("link_down_time"), | ||
292 | ("tx_tcode_buf_abort_cnt"), | ||
293 | ("tx_tcode_desc_abort_cnt"), | ||
294 | ("tx_tcode_parity_err_cnt"), | ||
295 | ("tx_tcode_link_loss_cnt"), | ||
296 | ("tx_tcode_list_proc_err_cnt"), | ||
297 | ("rx_tcode_parity_err_cnt"), | ||
298 | ("rx_tcode_abort_cnt"), | ||
299 | ("rx_tcode_parity_abort_cnt"), | ||
300 | ("rx_tcode_rda_fail_cnt"), | ||
301 | ("rx_tcode_unkn_prot_cnt"), | ||
302 | ("rx_tcode_fcs_err_cnt"), | ||
303 | ("rx_tcode_buf_size_err_cnt"), | ||
304 | ("rx_tcode_rxd_corrupt_cnt"), | ||
305 | ("rx_tcode_unkn_err_cnt") | ||
284 | }; | 306 | }; |
285 | 307 | ||
286 | #define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN | 308 | #define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN |
@@ -490,6 +512,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
490 | 512 | ||
491 | struct mac_info *mac_control; | 513 | struct mac_info *mac_control; |
492 | struct config_param *config; | 514 | struct config_param *config; |
515 | unsigned long long mem_allocated = 0; | ||
493 | 516 | ||
494 | mac_control = &nic->mac_control; | 517 | mac_control = &nic->mac_control; |
495 | config = &nic->config; | 518 | config = &nic->config; |
@@ -519,6 +542,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
519 | "Malloc failed for list_info\n"); | 542 | "Malloc failed for list_info\n"); |
520 | return -ENOMEM; | 543 | return -ENOMEM; |
521 | } | 544 | } |
545 | mem_allocated += list_holder_size; | ||
522 | memset(mac_control->fifos[i].list_info, 0, list_holder_size); | 546 | memset(mac_control->fifos[i].list_info, 0, list_holder_size); |
523 | } | 547 | } |
524 | for (i = 0; i < config->tx_fifo_num; i++) { | 548 | for (i = 0; i < config->tx_fifo_num; i++) { |
@@ -565,6 +589,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
565 | DBG_PRINT(INFO_DBG, "failed for TxDL\n"); | 589 | DBG_PRINT(INFO_DBG, "failed for TxDL\n"); |
566 | return -ENOMEM; | 590 | return -ENOMEM; |
567 | } | 591 | } |
592 | mem_allocated += PAGE_SIZE; | ||
568 | } | 593 | } |
569 | while (k < lst_per_page) { | 594 | while (k < lst_per_page) { |
570 | int l = (j * lst_per_page) + k; | 595 | int l = (j * lst_per_page) + k; |
@@ -582,6 +607,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
582 | nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL); | 607 | nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL); |
583 | if (!nic->ufo_in_band_v) | 608 | if (!nic->ufo_in_band_v) |
584 | return -ENOMEM; | 609 | return -ENOMEM; |
610 | mem_allocated += (size * sizeof(u64)); | ||
585 | 611 | ||
586 | /* Allocation and initialization of RXDs in Rings */ | 612 | /* Allocation and initialization of RXDs in Rings */ |
587 | size = 0; | 613 | size = 0; |
@@ -639,6 +665,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
639 | rx_blocks->block_virt_addr = tmp_v_addr; | 665 | rx_blocks->block_virt_addr = tmp_v_addr; |
640 | return -ENOMEM; | 666 | return -ENOMEM; |
641 | } | 667 | } |
668 | mem_allocated += size; | ||
642 | memset(tmp_v_addr, 0, size); | 669 | memset(tmp_v_addr, 0, size); |
643 | rx_blocks->block_virt_addr = tmp_v_addr; | 670 | rx_blocks->block_virt_addr = tmp_v_addr; |
644 | rx_blocks->block_dma_addr = tmp_p_addr; | 671 | rx_blocks->block_dma_addr = tmp_p_addr; |
@@ -647,6 +674,8 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
647 | GFP_KERNEL); | 674 | GFP_KERNEL); |
648 | if (!rx_blocks->rxds) | 675 | if (!rx_blocks->rxds) |
649 | return -ENOMEM; | 676 | return -ENOMEM; |
677 | mem_allocated += | ||
678 | (sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]); | ||
650 | for (l=0; l<rxd_count[nic->rxd_mode];l++) { | 679 | for (l=0; l<rxd_count[nic->rxd_mode];l++) { |
651 | rx_blocks->rxds[l].virt_addr = | 680 | rx_blocks->rxds[l].virt_addr = |
652 | rx_blocks->block_virt_addr + | 681 | rx_blocks->block_virt_addr + |
@@ -689,6 +718,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
689 | GFP_KERNEL); | 718 | GFP_KERNEL); |
690 | if (!mac_control->rings[i].ba) | 719 | if (!mac_control->rings[i].ba) |
691 | return -ENOMEM; | 720 | return -ENOMEM; |
721 | mem_allocated +=(sizeof(struct buffAdd *) * blk_cnt); | ||
692 | for (j = 0; j < blk_cnt; j++) { | 722 | for (j = 0; j < blk_cnt; j++) { |
693 | int k = 0; | 723 | int k = 0; |
694 | mac_control->rings[i].ba[j] = | 724 | mac_control->rings[i].ba[j] = |
@@ -697,6 +727,8 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
697 | GFP_KERNEL); | 727 | GFP_KERNEL); |
698 | if (!mac_control->rings[i].ba[j]) | 728 | if (!mac_control->rings[i].ba[j]) |
699 | return -ENOMEM; | 729 | return -ENOMEM; |
730 | mem_allocated += (sizeof(struct buffAdd) * \ | ||
731 | (rxd_count[nic->rxd_mode] + 1)); | ||
700 | while (k != rxd_count[nic->rxd_mode]) { | 732 | while (k != rxd_count[nic->rxd_mode]) { |
701 | ba = &mac_control->rings[i].ba[j][k]; | 733 | ba = &mac_control->rings[i].ba[j][k]; |
702 | 734 | ||
@@ -704,6 +736,8 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
704 | (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); | 736 | (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); |
705 | if (!ba->ba_0_org) | 737 | if (!ba->ba_0_org) |
706 | return -ENOMEM; | 738 | return -ENOMEM; |
739 | mem_allocated += | ||
740 | (BUF0_LEN + ALIGN_SIZE); | ||
707 | tmp = (unsigned long)ba->ba_0_org; | 741 | tmp = (unsigned long)ba->ba_0_org; |
708 | tmp += ALIGN_SIZE; | 742 | tmp += ALIGN_SIZE; |
709 | tmp &= ~((unsigned long) ALIGN_SIZE); | 743 | tmp &= ~((unsigned long) ALIGN_SIZE); |
@@ -713,6 +747,8 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
713 | (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); | 747 | (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); |
714 | if (!ba->ba_1_org) | 748 | if (!ba->ba_1_org) |
715 | return -ENOMEM; | 749 | return -ENOMEM; |
750 | mem_allocated | ||
751 | += (BUF1_LEN + ALIGN_SIZE); | ||
716 | tmp = (unsigned long) ba->ba_1_org; | 752 | tmp = (unsigned long) ba->ba_1_org; |
717 | tmp += ALIGN_SIZE; | 753 | tmp += ALIGN_SIZE; |
718 | tmp &= ~((unsigned long) ALIGN_SIZE); | 754 | tmp &= ~((unsigned long) ALIGN_SIZE); |
@@ -736,6 +772,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
736 | */ | 772 | */ |
737 | return -ENOMEM; | 773 | return -ENOMEM; |
738 | } | 774 | } |
775 | mem_allocated += size; | ||
739 | mac_control->stats_mem_sz = size; | 776 | mac_control->stats_mem_sz = size; |
740 | 777 | ||
741 | tmp_v_addr = mac_control->stats_mem; | 778 | tmp_v_addr = mac_control->stats_mem; |
@@ -743,7 +780,7 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
743 | memset(tmp_v_addr, 0, size); | 780 | memset(tmp_v_addr, 0, size); |
744 | DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name, | 781 | DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name, |
745 | (unsigned long long) tmp_p_addr); | 782 | (unsigned long long) tmp_p_addr); |
746 | 783 | mac_control->stats_info->sw_stat.mem_allocated += mem_allocated; | |
747 | return SUCCESS; | 784 | return SUCCESS; |
748 | } | 785 | } |
749 | 786 | ||
@@ -757,12 +794,14 @@ static int init_shared_mem(struct s2io_nic *nic) | |||
757 | static void free_shared_mem(struct s2io_nic *nic) | 794 | static void free_shared_mem(struct s2io_nic *nic) |
758 | { | 795 | { |
759 | int i, j, blk_cnt, size; | 796 | int i, j, blk_cnt, size; |
797 | u32 ufo_size = 0; | ||
760 | void *tmp_v_addr; | 798 | void *tmp_v_addr; |
761 | dma_addr_t tmp_p_addr; | 799 | dma_addr_t tmp_p_addr; |
762 | struct mac_info *mac_control; | 800 | struct mac_info *mac_control; |
763 | struct config_param *config; | 801 | struct config_param *config; |
764 | int lst_size, lst_per_page; | 802 | int lst_size, lst_per_page; |
765 | struct net_device *dev = nic->dev; | 803 | struct net_device *dev = nic->dev; |
804 | int page_num = 0; | ||
766 | 805 | ||
767 | if (!nic) | 806 | if (!nic) |
768 | return; | 807 | return; |
@@ -774,8 +813,9 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
774 | lst_per_page = PAGE_SIZE / lst_size; | 813 | lst_per_page = PAGE_SIZE / lst_size; |
775 | 814 | ||
776 | for (i = 0; i < config->tx_fifo_num; i++) { | 815 | for (i = 0; i < config->tx_fifo_num; i++) { |
777 | int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, | 816 | ufo_size += config->tx_cfg[i].fifo_len; |
778 | lst_per_page); | 817 | page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, |
818 | lst_per_page); | ||
779 | for (j = 0; j < page_num; j++) { | 819 | for (j = 0; j < page_num; j++) { |
780 | int mem_blks = (j * lst_per_page); | 820 | int mem_blks = (j * lst_per_page); |
781 | if (!mac_control->fifos[i].list_info) | 821 | if (!mac_control->fifos[i].list_info) |
@@ -790,6 +830,8 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
790 | mac_control->fifos[i]. | 830 | mac_control->fifos[i]. |
791 | list_info[mem_blks]. | 831 | list_info[mem_blks]. |
792 | list_phy_addr); | 832 | list_phy_addr); |
833 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
834 | += PAGE_SIZE; | ||
793 | } | 835 | } |
794 | /* If we got a zero DMA address during allocation, | 836 | /* If we got a zero DMA address during allocation, |
795 | * free the page now | 837 | * free the page now |
@@ -803,8 +845,12 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
803 | dev->name); | 845 | dev->name); |
804 | DBG_PRINT(INIT_DBG, "Virtual address %p\n", | 846 | DBG_PRINT(INIT_DBG, "Virtual address %p\n", |
805 | mac_control->zerodma_virt_addr); | 847 | mac_control->zerodma_virt_addr); |
848 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
849 | += PAGE_SIZE; | ||
806 | } | 850 | } |
807 | kfree(mac_control->fifos[i].list_info); | 851 | kfree(mac_control->fifos[i].list_info); |
852 | nic->mac_control.stats_info->sw_stat.mem_freed += | ||
853 | (nic->config.tx_cfg[i].fifo_len *sizeof(struct list_info_hold)); | ||
808 | } | 854 | } |
809 | 855 | ||
810 | size = SIZE_OF_BLOCK; | 856 | size = SIZE_OF_BLOCK; |
@@ -819,7 +865,10 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
819 | break; | 865 | break; |
820 | pci_free_consistent(nic->pdev, size, | 866 | pci_free_consistent(nic->pdev, size, |
821 | tmp_v_addr, tmp_p_addr); | 867 | tmp_v_addr, tmp_p_addr); |
868 | nic->mac_control.stats_info->sw_stat.mem_freed += size; | ||
822 | kfree(mac_control->rings[i].rx_blocks[j].rxds); | 869 | kfree(mac_control->rings[i].rx_blocks[j].rxds); |
870 | nic->mac_control.stats_info->sw_stat.mem_freed += | ||
871 | ( sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]); | ||
823 | } | 872 | } |
824 | } | 873 | } |
825 | 874 | ||
@@ -836,12 +885,20 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
836 | struct buffAdd *ba = | 885 | struct buffAdd *ba = |
837 | &mac_control->rings[i].ba[j][k]; | 886 | &mac_control->rings[i].ba[j][k]; |
838 | kfree(ba->ba_0_org); | 887 | kfree(ba->ba_0_org); |
888 | nic->mac_control.stats_info->sw_stat.\ | ||
889 | mem_freed += (BUF0_LEN + ALIGN_SIZE); | ||
839 | kfree(ba->ba_1_org); | 890 | kfree(ba->ba_1_org); |
891 | nic->mac_control.stats_info->sw_stat.\ | ||
892 | mem_freed += (BUF1_LEN + ALIGN_SIZE); | ||
840 | k++; | 893 | k++; |
841 | } | 894 | } |
842 | kfree(mac_control->rings[i].ba[j]); | 895 | kfree(mac_control->rings[i].ba[j]); |
896 | nic->mac_control.stats_info->sw_stat.mem_freed += (sizeof(struct buffAdd) * | ||
897 | (rxd_count[nic->rxd_mode] + 1)); | ||
843 | } | 898 | } |
844 | kfree(mac_control->rings[i].ba); | 899 | kfree(mac_control->rings[i].ba); |
900 | nic->mac_control.stats_info->sw_stat.mem_freed += | ||
901 | (sizeof(struct buffAdd *) * blk_cnt); | ||
845 | } | 902 | } |
846 | } | 903 | } |
847 | 904 | ||
@@ -850,9 +907,14 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
850 | mac_control->stats_mem_sz, | 907 | mac_control->stats_mem_sz, |
851 | mac_control->stats_mem, | 908 | mac_control->stats_mem, |
852 | mac_control->stats_mem_phy); | 909 | mac_control->stats_mem_phy); |
910 | nic->mac_control.stats_info->sw_stat.mem_freed += | ||
911 | mac_control->stats_mem_sz; | ||
853 | } | 912 | } |
854 | if (nic->ufo_in_band_v) | 913 | if (nic->ufo_in_band_v) { |
855 | kfree(nic->ufo_in_band_v); | 914 | kfree(nic->ufo_in_band_v); |
915 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
916 | += (ufo_size * sizeof(u64)); | ||
917 | } | ||
856 | } | 918 | } |
857 | 919 | ||
858 | /** | 920 | /** |
@@ -2122,10 +2184,12 @@ static void free_tx_buffers(struct s2io_nic *nic) | |||
2122 | 2184 | ||
2123 | for (i = 0; i < config->tx_fifo_num; i++) { | 2185 | for (i = 0; i < config->tx_fifo_num; i++) { |
2124 | for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { | 2186 | for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { |
2125 | txdp = (struct TxD *) mac_control->fifos[i].list_info[j]. | 2187 | txdp = (struct TxD *) \ |
2126 | list_virt_addr; | 2188 | mac_control->fifos[i].list_info[j].list_virt_addr; |
2127 | skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); | 2189 | skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); |
2128 | if (skb) { | 2190 | if (skb) { |
2191 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
2192 | += skb->truesize; | ||
2129 | dev_kfree_skb(skb); | 2193 | dev_kfree_skb(skb); |
2130 | cnt++; | 2194 | cnt++; |
2131 | } | 2195 | } |
@@ -2186,11 +2250,14 @@ static int fill_rxd_3buf(struct s2io_nic *nic, struct RxD_t *rxdp, struct \ | |||
2186 | /* skb_shinfo(skb)->frag_list will have L4 data payload */ | 2250 | /* skb_shinfo(skb)->frag_list will have L4 data payload */ |
2187 | skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE); | 2251 | skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE); |
2188 | if (skb_shinfo(skb)->frag_list == NULL) { | 2252 | if (skb_shinfo(skb)->frag_list == NULL) { |
2253 | nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; | ||
2189 | DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name); | 2254 | DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name); |
2190 | return -ENOMEM ; | 2255 | return -ENOMEM ; |
2191 | } | 2256 | } |
2192 | frag_list = skb_shinfo(skb)->frag_list; | 2257 | frag_list = skb_shinfo(skb)->frag_list; |
2193 | skb->truesize += frag_list->truesize; | 2258 | skb->truesize += frag_list->truesize; |
2259 | nic->mac_control.stats_info->sw_stat.mem_allocated | ||
2260 | += frag_list->truesize; | ||
2194 | frag_list->next = NULL; | 2261 | frag_list->next = NULL; |
2195 | tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1); | 2262 | tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1); |
2196 | frag_list->data = tmp; | 2263 | frag_list->data = tmp; |
@@ -2319,8 +2386,12 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2319 | wmb(); | 2386 | wmb(); |
2320 | first_rxdp->Control_1 |= RXD_OWN_XENA; | 2387 | first_rxdp->Control_1 |= RXD_OWN_XENA; |
2321 | } | 2388 | } |
2389 | nic->mac_control.stats_info->sw_stat. \ | ||
2390 | mem_alloc_fail_cnt++; | ||
2322 | return -ENOMEM ; | 2391 | return -ENOMEM ; |
2323 | } | 2392 | } |
2393 | nic->mac_control.stats_info->sw_stat.mem_allocated | ||
2394 | += skb->truesize; | ||
2324 | if (nic->rxd_mode == RXD_MODE_1) { | 2395 | if (nic->rxd_mode == RXD_MODE_1) { |
2325 | /* 1 buffer mode - normal operation mode */ | 2396 | /* 1 buffer mode - normal operation mode */ |
2326 | memset(rxdp, 0, sizeof(struct RxD1)); | 2397 | memset(rxdp, 0, sizeof(struct RxD1)); |
@@ -2328,7 +2399,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2328 | ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single | 2399 | ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single |
2329 | (nic->pdev, skb->data, size - NET_IP_ALIGN, | 2400 | (nic->pdev, skb->data, size - NET_IP_ALIGN, |
2330 | PCI_DMA_FROMDEVICE); | 2401 | PCI_DMA_FROMDEVICE); |
2331 | rxdp->Control_2 = SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); | 2402 | rxdp->Control_2 = |
2403 | SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); | ||
2332 | 2404 | ||
2333 | } else if (nic->rxd_mode >= RXD_MODE_3A) { | 2405 | } else if (nic->rxd_mode >= RXD_MODE_3A) { |
2334 | /* | 2406 | /* |
@@ -2342,7 +2414,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2342 | * payload | 2414 | * payload |
2343 | */ | 2415 | */ |
2344 | 2416 | ||
2345 | /* save the buffer pointers to avoid frequent dma mapping */ | 2417 | /* save buffer pointers to avoid frequent dma mapping */ |
2346 | Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr; | 2418 | Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr; |
2347 | Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr; | 2419 | Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr; |
2348 | memset(rxdp, 0, sizeof(struct RxD3)); | 2420 | memset(rxdp, 0, sizeof(struct RxD3)); |
@@ -2364,7 +2436,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2364 | PCI_DMA_FROMDEVICE); | 2436 | PCI_DMA_FROMDEVICE); |
2365 | else | 2437 | else |
2366 | pci_dma_sync_single_for_device(nic->pdev, | 2438 | pci_dma_sync_single_for_device(nic->pdev, |
2367 | (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, | 2439 | (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, |
2368 | BUF0_LEN, PCI_DMA_FROMDEVICE); | 2440 | BUF0_LEN, PCI_DMA_FROMDEVICE); |
2369 | rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); | 2441 | rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); |
2370 | if (nic->rxd_mode == RXD_MODE_3B) { | 2442 | if (nic->rxd_mode == RXD_MODE_3B) { |
@@ -2391,6 +2463,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2391 | } else { | 2463 | } else { |
2392 | /* 3 buffer mode */ | 2464 | /* 3 buffer mode */ |
2393 | if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) { | 2465 | if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) { |
2466 | nic->mac_control.stats_info->sw_stat.\ | ||
2467 | mem_freed += skb->truesize; | ||
2394 | dev_kfree_skb_irq(skb); | 2468 | dev_kfree_skb_irq(skb); |
2395 | if (first_rxdp) { | 2469 | if (first_rxdp) { |
2396 | wmb(); | 2470 | wmb(); |
@@ -2491,6 +2565,7 @@ static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk) | |||
2491 | PCI_DMA_FROMDEVICE); | 2565 | PCI_DMA_FROMDEVICE); |
2492 | memset(rxdp, 0, sizeof(struct RxD3)); | 2566 | memset(rxdp, 0, sizeof(struct RxD3)); |
2493 | } | 2567 | } |
2568 | sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; | ||
2494 | dev_kfree_skb(skb); | 2569 | dev_kfree_skb(skb); |
2495 | atomic_dec(&sp->rx_bufs_left[ring_no]); | 2570 | atomic_dec(&sp->rx_bufs_left[ring_no]); |
2496 | } | 2571 | } |
@@ -2820,13 +2895,35 @@ static void tx_intr_handler(struct fifo_info *fifo_data) | |||
2820 | nic->mac_control.stats_info->sw_stat. | 2895 | nic->mac_control.stats_info->sw_stat. |
2821 | parity_err_cnt++; | 2896 | parity_err_cnt++; |
2822 | } | 2897 | } |
2823 | if ((err >> 48) == 0xA) { | 2898 | |
2824 | DBG_PRINT(TX_DBG, "TxD returned due \ | 2899 | /* update t_code statistics */ |
2825 | to loss of link\n"); | 2900 | err >>= 48; |
2826 | } | 2901 | switch(err) { |
2827 | else { | 2902 | case 2: |
2828 | DBG_PRINT(ERR_DBG, "***TxD error %llx\n", err); | 2903 | nic->mac_control.stats_info->sw_stat. |
2829 | } | 2904 | tx_buf_abort_cnt++; |
2905 | break; | ||
2906 | |||
2907 | case 3: | ||
2908 | nic->mac_control.stats_info->sw_stat. | ||
2909 | tx_desc_abort_cnt++; | ||
2910 | break; | ||
2911 | |||
2912 | case 7: | ||
2913 | nic->mac_control.stats_info->sw_stat. | ||
2914 | tx_parity_err_cnt++; | ||
2915 | break; | ||
2916 | |||
2917 | case 10: | ||
2918 | nic->mac_control.stats_info->sw_stat. | ||
2919 | tx_link_loss_cnt++; | ||
2920 | break; | ||
2921 | |||
2922 | case 15: | ||
2923 | nic->mac_control.stats_info->sw_stat. | ||
2924 | tx_list_proc_err_cnt++; | ||
2925 | break; | ||
2926 | } | ||
2830 | } | 2927 | } |
2831 | 2928 | ||
2832 | skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); | 2929 | skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); |
@@ -2839,6 +2936,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data) | |||
2839 | 2936 | ||
2840 | /* Updating the statistics block */ | 2937 | /* Updating the statistics block */ |
2841 | nic->stats.tx_bytes += skb->len; | 2938 | nic->stats.tx_bytes += skb->len; |
2939 | nic->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; | ||
2842 | dev_kfree_skb_irq(skb); | 2940 | dev_kfree_skb_irq(skb); |
2843 | 2941 | ||
2844 | get_info.offset++; | 2942 | get_info.offset++; |
@@ -3314,7 +3412,9 @@ static void s2io_reset(struct s2io_nic * sp) | |||
3314 | u16 subid, pci_cmd; | 3412 | u16 subid, pci_cmd; |
3315 | int i; | 3413 | int i; |
3316 | u16 val16; | 3414 | u16 val16; |
3317 | unsigned long long reset_cnt = 0; | 3415 | unsigned long long up_cnt, down_cnt, up_time, down_time, reset_cnt; |
3416 | unsigned long long mem_alloc_cnt, mem_free_cnt, watchdog_cnt; | ||
3417 | |||
3318 | DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n", | 3418 | DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n", |
3319 | __FUNCTION__, sp->dev->name); | 3419 | __FUNCTION__, sp->dev->name); |
3320 | 3420 | ||
@@ -3380,11 +3480,26 @@ new_way: | |||
3380 | 3480 | ||
3381 | /* Reset device statistics maintained by OS */ | 3481 | /* Reset device statistics maintained by OS */ |
3382 | memset(&sp->stats, 0, sizeof (struct net_device_stats)); | 3482 | memset(&sp->stats, 0, sizeof (struct net_device_stats)); |
3383 | /* save reset count */ | 3483 | |
3484 | up_cnt = sp->mac_control.stats_info->sw_stat.link_up_cnt; | ||
3485 | down_cnt = sp->mac_control.stats_info->sw_stat.link_down_cnt; | ||
3486 | up_time = sp->mac_control.stats_info->sw_stat.link_up_time; | ||
3487 | down_time = sp->mac_control.stats_info->sw_stat.link_down_time; | ||
3384 | reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt; | 3488 | reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt; |
3489 | mem_alloc_cnt = sp->mac_control.stats_info->sw_stat.mem_allocated; | ||
3490 | mem_free_cnt = sp->mac_control.stats_info->sw_stat.mem_freed; | ||
3491 | watchdog_cnt = sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt; | ||
3492 | /* save link up/down time/cnt, reset/memory/watchdog cnt */ | ||
3385 | memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block)); | 3493 | memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block)); |
3386 | /* restore reset count */ | 3494 | /* restore link up/down time/cnt, reset/memory/watchdog cnt */ |
3495 | sp->mac_control.stats_info->sw_stat.link_up_cnt = up_cnt; | ||
3496 | sp->mac_control.stats_info->sw_stat.link_down_cnt = down_cnt; | ||
3497 | sp->mac_control.stats_info->sw_stat.link_up_time = up_time; | ||
3498 | sp->mac_control.stats_info->sw_stat.link_down_time = down_time; | ||
3387 | sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt; | 3499 | sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt; |
3500 | sp->mac_control.stats_info->sw_stat.mem_allocated = mem_alloc_cnt; | ||
3501 | sp->mac_control.stats_info->sw_stat.mem_freed = mem_free_cnt; | ||
3502 | sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt = watchdog_cnt; | ||
3388 | 3503 | ||
3389 | /* SXE-002: Configure link and activity LED to turn it off */ | 3504 | /* SXE-002: Configure link and activity LED to turn it off */ |
3390 | subid = sp->pdev->subsystem_device; | 3505 | subid = sp->pdev->subsystem_device; |
@@ -3672,19 +3787,29 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) | |||
3672 | nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), | 3787 | nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), |
3673 | GFP_KERNEL); | 3788 | GFP_KERNEL); |
3674 | if (nic->entries == NULL) { | 3789 | if (nic->entries == NULL) { |
3675 | DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); | 3790 | DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \ |
3791 | __FUNCTION__); | ||
3792 | nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; | ||
3676 | return -ENOMEM; | 3793 | return -ENOMEM; |
3677 | } | 3794 | } |
3678 | memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | 3795 | nic->mac_control.stats_info->sw_stat.mem_allocated |
3796 | += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3797 | memset(nic->entries, 0,MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3679 | 3798 | ||
3680 | nic->s2io_entries = | 3799 | nic->s2io_entries = |
3681 | kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), | 3800 | kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), |
3682 | GFP_KERNEL); | 3801 | GFP_KERNEL); |
3683 | if (nic->s2io_entries == NULL) { | 3802 | if (nic->s2io_entries == NULL) { |
3684 | DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); | 3803 | DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", |
3804 | __FUNCTION__); | ||
3805 | nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; | ||
3685 | kfree(nic->entries); | 3806 | kfree(nic->entries); |
3807 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
3808 | += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3686 | return -ENOMEM; | 3809 | return -ENOMEM; |
3687 | } | 3810 | } |
3811 | nic->mac_control.stats_info->sw_stat.mem_allocated | ||
3812 | += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); | ||
3688 | memset(nic->s2io_entries, 0, | 3813 | memset(nic->s2io_entries, 0, |
3689 | MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); | 3814 | MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); |
3690 | 3815 | ||
@@ -3708,7 +3833,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) | |||
3708 | rx_mat = readq(&bar0->rx_mat); | 3833 | rx_mat = readq(&bar0->rx_mat); |
3709 | for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { | 3834 | for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { |
3710 | rx_mat |= RX_MAT_SET(j, msix_indx); | 3835 | rx_mat |= RX_MAT_SET(j, msix_indx); |
3711 | nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; | 3836 | nic->s2io_entries[msix_indx].arg |
3837 | = &nic->mac_control.rings[j]; | ||
3712 | nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; | 3838 | nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; |
3713 | nic->s2io_entries[msix_indx].in_use = MSIX_FLG; | 3839 | nic->s2io_entries[msix_indx].in_use = MSIX_FLG; |
3714 | } | 3840 | } |
@@ -3717,7 +3843,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) | |||
3717 | tx_mat = readq(&bar0->tx_mat0_n[7]); | 3843 | tx_mat = readq(&bar0->tx_mat0_n[7]); |
3718 | for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { | 3844 | for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { |
3719 | tx_mat |= TX_MAT_SET(i, msix_indx); | 3845 | tx_mat |= TX_MAT_SET(i, msix_indx); |
3720 | nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; | 3846 | nic->s2io_entries[msix_indx].arg |
3847 | = &nic->mac_control.rings[j]; | ||
3721 | nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; | 3848 | nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; |
3722 | nic->s2io_entries[msix_indx].in_use = MSIX_FLG; | 3849 | nic->s2io_entries[msix_indx].in_use = MSIX_FLG; |
3723 | } | 3850 | } |
@@ -3734,7 +3861,11 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) | |||
3734 | if (ret) { | 3861 | if (ret) { |
3735 | DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); | 3862 | DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); |
3736 | kfree(nic->entries); | 3863 | kfree(nic->entries); |
3864 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
3865 | += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3737 | kfree(nic->s2io_entries); | 3866 | kfree(nic->s2io_entries); |
3867 | nic->mac_control.stats_info->sw_stat.mem_freed | ||
3868 | += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); | ||
3738 | nic->entries = NULL; | 3869 | nic->entries = NULL; |
3739 | nic->s2io_entries = NULL; | 3870 | nic->s2io_entries = NULL; |
3740 | nic->avail_msix_vectors = 0; | 3871 | nic->avail_msix_vectors = 0; |
@@ -3802,10 +3933,16 @@ static int s2io_open(struct net_device *dev) | |||
3802 | 3933 | ||
3803 | hw_init_failed: | 3934 | hw_init_failed: |
3804 | if (sp->intr_type == MSI_X) { | 3935 | if (sp->intr_type == MSI_X) { |
3805 | if (sp->entries) | 3936 | if (sp->entries) { |
3806 | kfree(sp->entries); | 3937 | kfree(sp->entries); |
3807 | if (sp->s2io_entries) | 3938 | sp->mac_control.stats_info->sw_stat.mem_freed |
3939 | += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); | ||
3940 | } | ||
3941 | if (sp->s2io_entries) { | ||
3808 | kfree(sp->s2io_entries); | 3942 | kfree(sp->s2io_entries); |
3943 | sp->mac_control.stats_info->sw_stat.mem_freed | ||
3944 | += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); | ||
3945 | } | ||
3809 | } | 3946 | } |
3810 | return err; | 3947 | return err; |
3811 | } | 3948 | } |
@@ -3866,6 +4003,13 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3866 | config = &sp->config; | 4003 | config = &sp->config; |
3867 | 4004 | ||
3868 | DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name); | 4005 | DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name); |
4006 | |||
4007 | if (unlikely(skb->len <= 0)) { | ||
4008 | DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); | ||
4009 | dev_kfree_skb_any(skb); | ||
4010 | return 0; | ||
4011 | } | ||
4012 | |||
3869 | spin_lock_irqsave(&sp->tx_lock, flags); | 4013 | spin_lock_irqsave(&sp->tx_lock, flags); |
3870 | if (atomic_read(&sp->card_state) == CARD_DOWN) { | 4014 | if (atomic_read(&sp->card_state) == CARD_DOWN) { |
3871 | DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", | 4015 | DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", |
@@ -3876,7 +4020,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3876 | } | 4020 | } |
3877 | 4021 | ||
3878 | queue = 0; | 4022 | queue = 0; |
3879 | |||
3880 | /* Get Fifo number to Transmit based on vlan priority */ | 4023 | /* Get Fifo number to Transmit based on vlan priority */ |
3881 | if (sp->vlgrp && vlan_tx_tag_present(skb)) { | 4024 | if (sp->vlgrp && vlan_tx_tag_present(skb)) { |
3882 | vlan_tag = vlan_tx_tag_get(skb); | 4025 | vlan_tag = vlan_tx_tag_get(skb); |
@@ -3900,14 +4043,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3900 | return 0; | 4043 | return 0; |
3901 | } | 4044 | } |
3902 | 4045 | ||
3903 | /* A buffer with no data will be dropped */ | ||
3904 | if (!skb->len) { | ||
3905 | DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); | ||
3906 | dev_kfree_skb(skb); | ||
3907 | spin_unlock_irqrestore(&sp->tx_lock, flags); | ||
3908 | return 0; | ||
3909 | } | ||
3910 | |||
3911 | offload_type = s2io_offload_type(skb); | 4046 | offload_type = s2io_offload_type(skb); |
3912 | if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { | 4047 | if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { |
3913 | txdp->Control_1 |= TXD_TCP_LSO_EN; | 4048 | txdp->Control_1 |= TXD_TCP_LSO_EN; |
@@ -4003,7 +4138,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4003 | put_off, get_off); | 4138 | put_off, get_off); |
4004 | netif_stop_queue(dev); | 4139 | netif_stop_queue(dev); |
4005 | } | 4140 | } |
4006 | 4141 | mac_control->stats_info->sw_stat.mem_allocated += skb->truesize; | |
4007 | dev->trans_start = jiffies; | 4142 | dev->trans_start = jiffies; |
4008 | spin_unlock_irqrestore(&sp->tx_lock, flags); | 4143 | spin_unlock_irqrestore(&sp->tx_lock, flags); |
4009 | 4144 | ||
@@ -4775,6 +4910,40 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data) | |||
4775 | return 0; | 4910 | return 0; |
4776 | } | 4911 | } |
4777 | 4912 | ||
4913 | static void s2io_ethtool_gringparam(struct net_device *dev, | ||
4914 | struct ethtool_ringparam *ering) | ||
4915 | { | ||
4916 | struct s2io_nic *sp = dev->priv; | ||
4917 | int i,tx_desc_count=0,rx_desc_count=0; | ||
4918 | |||
4919 | if (sp->rxd_mode == RXD_MODE_1) | ||
4920 | ering->rx_max_pending = MAX_RX_DESC_1; | ||
4921 | else if (sp->rxd_mode == RXD_MODE_3B) | ||
4922 | ering->rx_max_pending = MAX_RX_DESC_2; | ||
4923 | else if (sp->rxd_mode == RXD_MODE_3A) | ||
4924 | ering->rx_max_pending = MAX_RX_DESC_3; | ||
4925 | |||
4926 | ering->tx_max_pending = MAX_TX_DESC; | ||
4927 | for (i = 0 ; i < sp->config.tx_fifo_num ; i++) { | ||
4928 | tx_desc_count += sp->config.tx_cfg[i].fifo_len; | ||
4929 | } | ||
4930 | DBG_PRINT(INFO_DBG,"\nmax txds : %d\n",sp->config.max_txds); | ||
4931 | ering->tx_pending = tx_desc_count; | ||
4932 | rx_desc_count = 0; | ||
4933 | for (i = 0 ; i < sp->config.rx_ring_num ; i++) { | ||
4934 | rx_desc_count += sp->config.rx_cfg[i].num_rxd; | ||
4935 | } | ||
4936 | ering->rx_pending = rx_desc_count; | ||
4937 | |||
4938 | ering->rx_mini_max_pending = 0; | ||
4939 | ering->rx_mini_pending = 0; | ||
4940 | if(sp->rxd_mode == RXD_MODE_1) | ||
4941 | ering->rx_jumbo_max_pending = MAX_RX_DESC_1; | ||
4942 | else if (sp->rxd_mode == RXD_MODE_3B) | ||
4943 | ering->rx_jumbo_max_pending = MAX_RX_DESC_2; | ||
4944 | ering->rx_jumbo_pending = rx_desc_count; | ||
4945 | } | ||
4946 | |||
4778 | /** | 4947 | /** |
4779 | * s2io_ethtool_getpause_data -Pause frame frame generation and reception. | 4948 | * s2io_ethtool_getpause_data -Pause frame frame generation and reception. |
4780 | * @sp : private member of the device structure, which is a pointer to the | 4949 | * @sp : private member of the device structure, which is a pointer to the |
@@ -4981,8 +5150,11 @@ static void s2io_vpd_read(struct s2io_nic *nic) | |||
4981 | strcpy(nic->serial_num, "NOT AVAILABLE"); | 5150 | strcpy(nic->serial_num, "NOT AVAILABLE"); |
4982 | 5151 | ||
4983 | vpd_data = kmalloc(256, GFP_KERNEL); | 5152 | vpd_data = kmalloc(256, GFP_KERNEL); |
4984 | if (!vpd_data) | 5153 | if (!vpd_data) { |
5154 | nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; | ||
4985 | return; | 5155 | return; |
5156 | } | ||
5157 | nic->mac_control.stats_info->sw_stat.mem_allocated += 256; | ||
4986 | 5158 | ||
4987 | for (i = 0; i < 256; i +=4 ) { | 5159 | for (i = 0; i < 256; i +=4 ) { |
4988 | pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); | 5160 | pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); |
@@ -5022,6 +5194,7 @@ static void s2io_vpd_read(struct s2io_nic *nic) | |||
5022 | memcpy(nic->product_name, &vpd_data[3], vpd_data[1]); | 5194 | memcpy(nic->product_name, &vpd_data[3], vpd_data[1]); |
5023 | } | 5195 | } |
5024 | kfree(vpd_data); | 5196 | kfree(vpd_data); |
5197 | nic->mac_control.stats_info->sw_stat.mem_freed += 256; | ||
5025 | } | 5198 | } |
5026 | 5199 | ||
5027 | /** | 5200 | /** |
@@ -5742,6 +5915,30 @@ static void s2io_get_ethtool_stats(struct net_device *dev, | |||
5742 | } | 5915 | } |
5743 | else | 5916 | else |
5744 | tmp_stats[i++] = 0; | 5917 | tmp_stats[i++] = 0; |
5918 | tmp_stats[i++] = stat_info->sw_stat.mem_alloc_fail_cnt; | ||
5919 | tmp_stats[i++] = stat_info->sw_stat.watchdog_timer_cnt; | ||
5920 | tmp_stats[i++] = stat_info->sw_stat.mem_allocated; | ||
5921 | tmp_stats[i++] = stat_info->sw_stat.mem_freed; | ||
5922 | tmp_stats[i++] = stat_info->sw_stat.link_up_cnt; | ||
5923 | tmp_stats[i++] = stat_info->sw_stat.link_down_cnt; | ||
5924 | tmp_stats[i++] = stat_info->sw_stat.link_up_time; | ||
5925 | tmp_stats[i++] = stat_info->sw_stat.link_down_time; | ||
5926 | |||
5927 | tmp_stats[i++] = stat_info->sw_stat.tx_buf_abort_cnt; | ||
5928 | tmp_stats[i++] = stat_info->sw_stat.tx_desc_abort_cnt; | ||
5929 | tmp_stats[i++] = stat_info->sw_stat.tx_parity_err_cnt; | ||
5930 | tmp_stats[i++] = stat_info->sw_stat.tx_link_loss_cnt; | ||
5931 | tmp_stats[i++] = stat_info->sw_stat.tx_list_proc_err_cnt; | ||
5932 | |||
5933 | tmp_stats[i++] = stat_info->sw_stat.rx_parity_err_cnt; | ||
5934 | tmp_stats[i++] = stat_info->sw_stat.rx_abort_cnt; | ||
5935 | tmp_stats[i++] = stat_info->sw_stat.rx_parity_abort_cnt; | ||
5936 | tmp_stats[i++] = stat_info->sw_stat.rx_rda_fail_cnt; | ||
5937 | tmp_stats[i++] = stat_info->sw_stat.rx_unkn_prot_cnt; | ||
5938 | tmp_stats[i++] = stat_info->sw_stat.rx_fcs_err_cnt; | ||
5939 | tmp_stats[i++] = stat_info->sw_stat.rx_buf_size_err_cnt; | ||
5940 | tmp_stats[i++] = stat_info->sw_stat.rx_rxd_corrupt_cnt; | ||
5941 | tmp_stats[i++] = stat_info->sw_stat.rx_unkn_err_cnt; | ||
5745 | } | 5942 | } |
5746 | 5943 | ||
5747 | static int s2io_ethtool_get_regs_len(struct net_device *dev) | 5944 | static int s2io_ethtool_get_regs_len(struct net_device *dev) |
@@ -5854,6 +6051,7 @@ static const struct ethtool_ops netdev_ethtool_ops = { | |||
5854 | .get_eeprom_len = s2io_get_eeprom_len, | 6051 | .get_eeprom_len = s2io_get_eeprom_len, |
5855 | .get_eeprom = s2io_ethtool_geeprom, | 6052 | .get_eeprom = s2io_ethtool_geeprom, |
5856 | .set_eeprom = s2io_ethtool_seeprom, | 6053 | .set_eeprom = s2io_ethtool_seeprom, |
6054 | .get_ringparam = s2io_ethtool_gringparam, | ||
5857 | .get_pauseparam = s2io_ethtool_getpause_data, | 6055 | .get_pauseparam = s2io_ethtool_getpause_data, |
5858 | .set_pauseparam = s2io_ethtool_setpause_data, | 6056 | .set_pauseparam = s2io_ethtool_setpause_data, |
5859 | .get_rx_csum = s2io_ethtool_get_rx_csum, | 6057 | .get_rx_csum = s2io_ethtool_get_rx_csum, |
@@ -5962,7 +6160,7 @@ static void s2io_tasklet(unsigned long dev_addr) | |||
5962 | if (ret == -ENOMEM) { | 6160 | if (ret == -ENOMEM) { |
5963 | DBG_PRINT(INFO_DBG, "%s: Out of ", | 6161 | DBG_PRINT(INFO_DBG, "%s: Out of ", |
5964 | dev->name); | 6162 | dev->name); |
5965 | DBG_PRINT(ERR_DBG, "memory in tasklet\n"); | 6163 | DBG_PRINT(INFO_DBG, "memory in tasklet\n"); |
5966 | break; | 6164 | break; |
5967 | } else if (ret == -EFILL) { | 6165 | } else if (ret == -EFILL) { |
5968 | DBG_PRINT(INFO_DBG, | 6166 | DBG_PRINT(INFO_DBG, |
@@ -6077,9 +6275,14 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6077 | *skb = dev_alloc_skb(size); | 6275 | *skb = dev_alloc_skb(size); |
6078 | if (!(*skb)) { | 6276 | if (!(*skb)) { |
6079 | DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); | 6277 | DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); |
6080 | DBG_PRINT(INFO_DBG, "memory to allocate SKBs\n"); | 6278 | DBG_PRINT(INFO_DBG, "memory to allocate "); |
6279 | DBG_PRINT(INFO_DBG, "1 buf mode SKBs\n"); | ||
6280 | sp->mac_control.stats_info->sw_stat. \ | ||
6281 | mem_alloc_fail_cnt++; | ||
6081 | return -ENOMEM ; | 6282 | return -ENOMEM ; |
6082 | } | 6283 | } |
6284 | sp->mac_control.stats_info->sw_stat.mem_allocated | ||
6285 | += (*skb)->truesize; | ||
6083 | /* storing the mapped addr in a temp variable | 6286 | /* storing the mapped addr in a temp variable |
6084 | * such it will be used for next rxd whose | 6287 | * such it will be used for next rxd whose |
6085 | * Host Control is NULL | 6288 | * Host Control is NULL |
@@ -6099,10 +6302,15 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6099 | } else { | 6302 | } else { |
6100 | *skb = dev_alloc_skb(size); | 6303 | *skb = dev_alloc_skb(size); |
6101 | if (!(*skb)) { | 6304 | if (!(*skb)) { |
6102 | DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", | 6305 | DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); |
6103 | dev->name); | 6306 | DBG_PRINT(INFO_DBG, "memory to allocate "); |
6307 | DBG_PRINT(INFO_DBG, "2 buf mode SKBs\n"); | ||
6308 | sp->mac_control.stats_info->sw_stat. \ | ||
6309 | mem_alloc_fail_cnt++; | ||
6104 | return -ENOMEM; | 6310 | return -ENOMEM; |
6105 | } | 6311 | } |
6312 | sp->mac_control.stats_info->sw_stat.mem_allocated | ||
6313 | += (*skb)->truesize; | ||
6106 | ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 = | 6314 | ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 = |
6107 | pci_map_single(sp->pdev, (*skb)->data, | 6315 | pci_map_single(sp->pdev, (*skb)->data, |
6108 | dev->mtu + 4, | 6316 | dev->mtu + 4, |
@@ -6126,10 +6334,15 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6126 | } else { | 6334 | } else { |
6127 | *skb = dev_alloc_skb(size); | 6335 | *skb = dev_alloc_skb(size); |
6128 | if (!(*skb)) { | 6336 | if (!(*skb)) { |
6129 | DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", | 6337 | DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); |
6130 | dev->name); | 6338 | DBG_PRINT(INFO_DBG, "memory to allocate "); |
6339 | DBG_PRINT(INFO_DBG, "3 buf mode SKBs\n"); | ||
6340 | sp->mac_control.stats_info->sw_stat. \ | ||
6341 | mem_alloc_fail_cnt++; | ||
6131 | return -ENOMEM; | 6342 | return -ENOMEM; |
6132 | } | 6343 | } |
6344 | sp->mac_control.stats_info->sw_stat.mem_allocated | ||
6345 | += (*skb)->truesize; | ||
6133 | ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 = | 6346 | ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 = |
6134 | pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, | 6347 | pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, |
6135 | PCI_DMA_FROMDEVICE); | 6348 | PCI_DMA_FROMDEVICE); |
@@ -6147,10 +6360,14 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6147 | if (skb_shinfo(*skb)->frag_list == NULL) { | 6360 | if (skb_shinfo(*skb)->frag_list == NULL) { |
6148 | DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \ | 6361 | DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \ |
6149 | failed\n ", dev->name); | 6362 | failed\n ", dev->name); |
6363 | sp->mac_control.stats_info->sw_stat. \ | ||
6364 | mem_alloc_fail_cnt++; | ||
6150 | return -ENOMEM ; | 6365 | return -ENOMEM ; |
6151 | } | 6366 | } |
6152 | frag_list = skb_shinfo(*skb)->frag_list; | 6367 | frag_list = skb_shinfo(*skb)->frag_list; |
6153 | frag_list->next = NULL; | 6368 | frag_list->next = NULL; |
6369 | sp->mac_control.stats_info->sw_stat.mem_allocated | ||
6370 | += frag_list->truesize; | ||
6154 | /* | 6371 | /* |
6155 | * Buffer-2 receives L4 data payload | 6372 | * Buffer-2 receives L4 data payload |
6156 | */ | 6373 | */ |
@@ -6566,6 +6783,7 @@ static void s2io_tx_watchdog(struct net_device *dev) | |||
6566 | struct s2io_nic *sp = dev->priv; | 6783 | struct s2io_nic *sp = dev->priv; |
6567 | 6784 | ||
6568 | if (netif_carrier_ok(dev)) { | 6785 | if (netif_carrier_ok(dev)) { |
6786 | sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt++; | ||
6569 | schedule_work(&sp->rst_timer_task); | 6787 | schedule_work(&sp->rst_timer_task); |
6570 | sp->mac_control.stats_info->sw_stat.soft_reset_cnt++; | 6788 | sp->mac_control.stats_info->sw_stat.soft_reset_cnt++; |
6571 | } | 6789 | } |
@@ -6606,7 +6824,53 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) | |||
6606 | if (err & 0x1) { | 6824 | if (err & 0x1) { |
6607 | sp->mac_control.stats_info->sw_stat.parity_err_cnt++; | 6825 | sp->mac_control.stats_info->sw_stat.parity_err_cnt++; |
6608 | } | 6826 | } |
6827 | err >>= 48; | ||
6828 | switch(err) { | ||
6829 | case 1: | ||
6830 | sp->mac_control.stats_info->sw_stat. | ||
6831 | rx_parity_err_cnt++; | ||
6832 | break; | ||
6609 | 6833 | ||
6834 | case 2: | ||
6835 | sp->mac_control.stats_info->sw_stat. | ||
6836 | rx_abort_cnt++; | ||
6837 | break; | ||
6838 | |||
6839 | case 3: | ||
6840 | sp->mac_control.stats_info->sw_stat. | ||
6841 | rx_parity_abort_cnt++; | ||
6842 | break; | ||
6843 | |||
6844 | case 4: | ||
6845 | sp->mac_control.stats_info->sw_stat. | ||
6846 | rx_rda_fail_cnt++; | ||
6847 | break; | ||
6848 | |||
6849 | case 5: | ||
6850 | sp->mac_control.stats_info->sw_stat. | ||
6851 | rx_unkn_prot_cnt++; | ||
6852 | break; | ||
6853 | |||
6854 | case 6: | ||
6855 | sp->mac_control.stats_info->sw_stat. | ||
6856 | rx_fcs_err_cnt++; | ||
6857 | break; | ||
6858 | |||
6859 | case 7: | ||
6860 | sp->mac_control.stats_info->sw_stat. | ||
6861 | rx_buf_size_err_cnt++; | ||
6862 | break; | ||
6863 | |||
6864 | case 8: | ||
6865 | sp->mac_control.stats_info->sw_stat. | ||
6866 | rx_rxd_corrupt_cnt++; | ||
6867 | break; | ||
6868 | |||
6869 | case 15: | ||
6870 | sp->mac_control.stats_info->sw_stat. | ||
6871 | rx_unkn_err_cnt++; | ||
6872 | break; | ||
6873 | } | ||
6610 | /* | 6874 | /* |
6611 | * Drop the packet if bad transfer code. Exception being | 6875 | * Drop the packet if bad transfer code. Exception being |
6612 | * 0x5, which could be due to unsupported IPv6 extension header. | 6876 | * 0x5, which could be due to unsupported IPv6 extension header. |
@@ -6614,10 +6878,12 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) | |||
6614 | * Note that in this case, since checksum will be incorrect, | 6878 | * Note that in this case, since checksum will be incorrect, |
6615 | * stack will validate the same. | 6879 | * stack will validate the same. |
6616 | */ | 6880 | */ |
6617 | if (err && ((err >> 48) != 0x5)) { | 6881 | if (err != 0x5) { |
6618 | DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n", | 6882 | DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n", |
6619 | dev->name, err); | 6883 | dev->name, err); |
6620 | sp->stats.rx_crc_errors++; | 6884 | sp->stats.rx_crc_errors++; |
6885 | sp->mac_control.stats_info->sw_stat.mem_freed | ||
6886 | += skb->truesize; | ||
6621 | dev_kfree_skb(skb); | 6887 | dev_kfree_skb(skb); |
6622 | atomic_dec(&sp->rx_bufs_left[ring_no]); | 6888 | atomic_dec(&sp->rx_bufs_left[ring_no]); |
6623 | rxdp->Host_Control = 0; | 6889 | rxdp->Host_Control = 0; |
@@ -6627,7 +6893,6 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) | |||
6627 | 6893 | ||
6628 | /* Updating statistics */ | 6894 | /* Updating statistics */ |
6629 | rxdp->Host_Control = 0; | 6895 | rxdp->Host_Control = 0; |
6630 | sp->stats.rx_packets++; | ||
6631 | if (sp->rxd_mode == RXD_MODE_1) { | 6896 | if (sp->rxd_mode == RXD_MODE_1) { |
6632 | int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); | 6897 | int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); |
6633 | 6898 | ||
@@ -6731,7 +6996,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) | |||
6731 | } else { | 6996 | } else { |
6732 | skb->ip_summed = CHECKSUM_NONE; | 6997 | skb->ip_summed = CHECKSUM_NONE; |
6733 | } | 6998 | } |
6734 | 6999 | sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; | |
6735 | if (!sp->lro) { | 7000 | if (!sp->lro) { |
6736 | skb->protocol = eth_type_trans(skb, dev); | 7001 | skb->protocol = eth_type_trans(skb, dev); |
6737 | if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) && | 7002 | if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) && |
@@ -6780,12 +7045,21 @@ static void s2io_link(struct s2io_nic * sp, int link) | |||
6780 | if (link == LINK_DOWN) { | 7045 | if (link == LINK_DOWN) { |
6781 | DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name); | 7046 | DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name); |
6782 | netif_carrier_off(dev); | 7047 | netif_carrier_off(dev); |
7048 | if(sp->mac_control.stats_info->sw_stat.link_up_cnt) | ||
7049 | sp->mac_control.stats_info->sw_stat.link_up_time = | ||
7050 | jiffies - sp->start_time; | ||
7051 | sp->mac_control.stats_info->sw_stat.link_down_cnt++; | ||
6783 | } else { | 7052 | } else { |
6784 | DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name); | 7053 | DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name); |
7054 | if (sp->mac_control.stats_info->sw_stat.link_down_cnt) | ||
7055 | sp->mac_control.stats_info->sw_stat.link_down_time = | ||
7056 | jiffies - sp->start_time; | ||
7057 | sp->mac_control.stats_info->sw_stat.link_up_cnt++; | ||
6785 | netif_carrier_on(dev); | 7058 | netif_carrier_on(dev); |
6786 | } | 7059 | } |
6787 | } | 7060 | } |
6788 | sp->last_link_state = link; | 7061 | sp->last_link_state = link; |
7062 | sp->start_time = jiffies; | ||
6789 | } | 7063 | } |
6790 | 7064 | ||
6791 | /** | 7065 | /** |
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h index a656d18b33df..54baa0b8ec7c 100644 --- a/drivers/net/s2io.h +++ b/drivers/net/s2io.h | |||
@@ -95,6 +95,32 @@ struct swStat { | |||
95 | unsigned long long flush_max_pkts; | 95 | unsigned long long flush_max_pkts; |
96 | unsigned long long sum_avg_pkts_aggregated; | 96 | unsigned long long sum_avg_pkts_aggregated; |
97 | unsigned long long num_aggregations; | 97 | unsigned long long num_aggregations; |
98 | /* Other statistics */ | ||
99 | unsigned long long mem_alloc_fail_cnt; | ||
100 | unsigned long long watchdog_timer_cnt; | ||
101 | unsigned long long mem_allocated; | ||
102 | unsigned long long mem_freed; | ||
103 | unsigned long long link_up_cnt; | ||
104 | unsigned long long link_down_cnt; | ||
105 | unsigned long long link_up_time; | ||
106 | unsigned long long link_down_time; | ||
107 | |||
108 | /* Transfer Code statistics */ | ||
109 | unsigned long long tx_buf_abort_cnt; | ||
110 | unsigned long long tx_desc_abort_cnt; | ||
111 | unsigned long long tx_parity_err_cnt; | ||
112 | unsigned long long tx_link_loss_cnt; | ||
113 | unsigned long long tx_list_proc_err_cnt; | ||
114 | |||
115 | unsigned long long rx_parity_err_cnt; | ||
116 | unsigned long long rx_abort_cnt; | ||
117 | unsigned long long rx_parity_abort_cnt; | ||
118 | unsigned long long rx_rda_fail_cnt; | ||
119 | unsigned long long rx_unkn_prot_cnt; | ||
120 | unsigned long long rx_fcs_err_cnt; | ||
121 | unsigned long long rx_buf_size_err_cnt; | ||
122 | unsigned long long rx_rxd_corrupt_cnt; | ||
123 | unsigned long long rx_unkn_err_cnt; | ||
98 | }; | 124 | }; |
99 | 125 | ||
100 | /* Xpak releated alarm and warnings */ | 126 | /* Xpak releated alarm and warnings */ |
@@ -308,6 +334,11 @@ struct stat_block { | |||
308 | #define MAX_TX_FIFOS 8 | 334 | #define MAX_TX_FIFOS 8 |
309 | #define MAX_RX_RINGS 8 | 335 | #define MAX_RX_RINGS 8 |
310 | 336 | ||
337 | #define MAX_RX_DESC_1 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 127 ) | ||
338 | #define MAX_RX_DESC_2 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 ) | ||
339 | #define MAX_RX_DESC_3 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 ) | ||
340 | #define MAX_TX_DESC (MAX_AVAILABLE_TXDS) | ||
341 | |||
311 | /* FIFO mappings for all possible number of fifos configured */ | 342 | /* FIFO mappings for all possible number of fifos configured */ |
312 | static int fifo_map[][MAX_TX_FIFOS] = { | 343 | static int fifo_map[][MAX_TX_FIFOS] = { |
313 | {0, 0, 0, 0, 0, 0, 0, 0}, | 344 | {0, 0, 0, 0, 0, 0, 0, 0}, |
@@ -819,6 +850,7 @@ struct s2io_nic { | |||
819 | #define LINK_UP 2 | 850 | #define LINK_UP 2 |
820 | 851 | ||
821 | int task_flag; | 852 | int task_flag; |
853 | unsigned long long start_time; | ||
822 | #define CARD_DOWN 1 | 854 | #define CARD_DOWN 1 |
823 | #define CARD_UP 2 | 855 | #define CARD_UP 2 |
824 | atomic_t card_state; | 856 | atomic_t card_state; |
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c index 1fc77300b055..2106becf6990 100644 --- a/drivers/net/sgiseeq.c +++ b/drivers/net/sgiseeq.c | |||
@@ -16,11 +16,13 @@ | |||
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/netdevice.h> | 18 | #include <linux/netdevice.h> |
19 | #include <linux/platform_device.h> | ||
19 | #include <linux/etherdevice.h> | 20 | #include <linux/etherdevice.h> |
20 | #include <linux/skbuff.h> | 21 | #include <linux/skbuff.h> |
21 | 22 | ||
22 | #include <asm/sgi/hpc3.h> | 23 | #include <asm/sgi/hpc3.h> |
23 | #include <asm/sgi/ip22.h> | 24 | #include <asm/sgi/ip22.h> |
25 | #include <asm/sgi/seeq.h> | ||
24 | 26 | ||
25 | #include "sgiseeq.h" | 27 | #include "sgiseeq.h" |
26 | 28 | ||
@@ -92,13 +94,9 @@ struct sgiseeq_private { | |||
92 | 94 | ||
93 | struct net_device_stats stats; | 95 | struct net_device_stats stats; |
94 | 96 | ||
95 | struct net_device *next_module; | ||
96 | spinlock_t tx_lock; | 97 | spinlock_t tx_lock; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | /* A list of all installed seeq devices, for removing the driver module. */ | ||
100 | static struct net_device *root_sgiseeq_dev; | ||
101 | |||
102 | static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) | 100 | static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) |
103 | { | 101 | { |
104 | hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ; | 102 | hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ; |
@@ -624,9 +622,12 @@ static inline void setup_rx_ring(struct sgiseeq_rx_desc *buf, int nbufs) | |||
624 | 622 | ||
625 | #define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf)) | 623 | #define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf)) |
626 | 624 | ||
627 | static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) | 625 | static int __init sgiseeq_probe(struct platform_device *pdev) |
628 | { | 626 | { |
627 | struct sgiseeq_platform_data *pd = pdev->dev.platform_data; | ||
628 | struct hpc3_regs *hpcregs = pd->hpc; | ||
629 | struct sgiseeq_init_block *sr; | 629 | struct sgiseeq_init_block *sr; |
630 | unsigned int irq = pd->irq; | ||
630 | struct sgiseeq_private *sp; | 631 | struct sgiseeq_private *sp; |
631 | struct net_device *dev; | 632 | struct net_device *dev; |
632 | int err, i; | 633 | int err, i; |
@@ -637,6 +638,8 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) | |||
637 | err = -ENOMEM; | 638 | err = -ENOMEM; |
638 | goto err_out; | 639 | goto err_out; |
639 | } | 640 | } |
641 | |||
642 | platform_set_drvdata(pdev, dev); | ||
640 | sp = netdev_priv(dev); | 643 | sp = netdev_priv(dev); |
641 | 644 | ||
642 | /* Make private data page aligned */ | 645 | /* Make private data page aligned */ |
@@ -648,15 +651,7 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) | |||
648 | } | 651 | } |
649 | sp->srings = sr; | 652 | sp->srings = sr; |
650 | 653 | ||
651 | #define EADDR_NVOFS 250 | 654 | memcpy(dev->dev_addr, pd->mac, ETH_ALEN); |
652 | for (i = 0; i < 3; i++) { | ||
653 | unsigned short tmp = has_eeprom ? | ||
654 | ip22_eeprom_read(&hpcregs->eeprom, EADDR_NVOFS / 2+i) : | ||
655 | ip22_nvram_read(EADDR_NVOFS / 2+i); | ||
656 | |||
657 | dev->dev_addr[2 * i] = tmp >> 8; | ||
658 | dev->dev_addr[2 * i + 1] = tmp & 0xff; | ||
659 | } | ||
660 | 655 | ||
661 | #ifdef DEBUG | 656 | #ifdef DEBUG |
662 | gpriv = sp; | 657 | gpriv = sp; |
@@ -720,9 +715,6 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) | |||
720 | for (i = 0; i < 6; i++) | 715 | for (i = 0; i < 6; i++) |
721 | printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':'); | 716 | printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':'); |
722 | 717 | ||
723 | sp->next_module = root_sgiseeq_dev; | ||
724 | root_sgiseeq_dev = dev; | ||
725 | |||
726 | return 0; | 718 | return 0; |
727 | 719 | ||
728 | err_out_free_page: | 720 | err_out_free_page: |
@@ -734,43 +726,42 @@ err_out: | |||
734 | return err; | 726 | return err; |
735 | } | 727 | } |
736 | 728 | ||
737 | static int __init sgiseeq_probe(void) | 729 | static void __exit sgiseeq_remove(struct platform_device *pdev) |
738 | { | 730 | { |
739 | unsigned int tmp, ret1, ret2 = 0; | 731 | struct net_device *dev = platform_get_drvdata(pdev); |
740 | 732 | struct sgiseeq_private *sp = netdev_priv(dev); | |
741 | /* On board adapter on 1st HPC is always present */ | ||
742 | ret1 = sgiseeq_init(hpc3c0, SGI_ENET_IRQ, 0); | ||
743 | /* Let's see if second HPC is there */ | ||
744 | if (!(ip22_is_fullhouse()) && | ||
745 | get_dbe(tmp, (unsigned int *)&hpc3c1->pbdma[1]) == 0) { | ||
746 | sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | | ||
747 | SGIMC_GIOPAR_EXP164 | | ||
748 | SGIMC_GIOPAR_HPC264; | ||
749 | hpc3c1->pbus_piocfg[0][0] = 0x3ffff; | ||
750 | /* interrupt/config register on Challenge S Mezz board */ | ||
751 | hpc3c1->pbus_extregs[0][0] = 0x30; | ||
752 | ret2 = sgiseeq_init(hpc3c1, SGI_GIO_0_IRQ, 1); | ||
753 | } | ||
754 | 733 | ||
755 | return (ret1 & ret2) ? ret1 : 0; | 734 | unregister_netdev(dev); |
735 | free_page((unsigned long) sp->srings); | ||
736 | free_netdev(dev); | ||
737 | platform_set_drvdata(pdev, NULL); | ||
756 | } | 738 | } |
757 | 739 | ||
758 | static void __exit sgiseeq_exit(void) | 740 | static struct platform_driver sgiseeq_driver = { |
759 | { | 741 | .probe = sgiseeq_probe, |
760 | struct net_device *next, *dev; | 742 | .remove = __devexit_p(sgiseeq_remove), |
761 | struct sgiseeq_private *sp; | 743 | .driver = { |
744 | .name = "sgiseeq" | ||
745 | } | ||
746 | }; | ||
762 | 747 | ||
763 | for (dev = root_sgiseeq_dev; dev; dev = next) { | 748 | static int __init sgiseeq_module_init(void) |
764 | sp = (struct sgiseeq_private *) netdev_priv(dev); | 749 | { |
765 | next = sp->next_module; | 750 | if (platform_driver_register(&sgiseeq_driver)) { |
766 | unregister_netdev(dev); | 751 | printk(KERN_ERR "Driver registration failed\n"); |
767 | free_page((unsigned long) sp->srings); | 752 | return -ENODEV; |
768 | free_netdev(dev); | ||
769 | } | 753 | } |
754 | |||
755 | return 0; | ||
756 | } | ||
757 | |||
758 | static void __exit sgiseeq_module_exit(void) | ||
759 | { | ||
760 | platform_driver_unregister(&sgiseeq_driver); | ||
770 | } | 761 | } |
771 | 762 | ||
772 | module_init(sgiseeq_probe); | 763 | module_init(sgiseeq_module_init); |
773 | module_exit(sgiseeq_exit); | 764 | module_exit(sgiseeq_module_exit); |
774 | 765 | ||
775 | MODULE_DESCRIPTION("SGI Seeq 8003 driver"); | 766 | MODULE_DESCRIPTION("SGI Seeq 8003 driver"); |
776 | MODULE_AUTHOR("Linux/MIPS Mailing List <linux-mips@linux-mips.org>"); | 767 | MODULE_AUTHOR("Linux/MIPS Mailing List <linux-mips@linux-mips.org>"); |
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index e0489578945d..776692946562 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -3802,6 +3802,9 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state) | |||
3802 | struct skge_hw *hw = pci_get_drvdata(pdev); | 3802 | struct skge_hw *hw = pci_get_drvdata(pdev); |
3803 | int i, err, wol = 0; | 3803 | int i, err, wol = 0; |
3804 | 3804 | ||
3805 | if (!hw) | ||
3806 | return 0; | ||
3807 | |||
3805 | err = pci_save_state(pdev); | 3808 | err = pci_save_state(pdev); |
3806 | if (err) | 3809 | if (err) |
3807 | return err; | 3810 | return err; |
@@ -3830,6 +3833,9 @@ static int skge_resume(struct pci_dev *pdev) | |||
3830 | struct skge_hw *hw = pci_get_drvdata(pdev); | 3833 | struct skge_hw *hw = pci_get_drvdata(pdev); |
3831 | int i, err; | 3834 | int i, err; |
3832 | 3835 | ||
3836 | if (!hw) | ||
3837 | return 0; | ||
3838 | |||
3833 | err = pci_set_power_state(pdev, PCI_D0); | 3839 | err = pci_set_power_state(pdev, PCI_D0); |
3834 | if (err) | 3840 | if (err) |
3835 | goto out; | 3841 | goto out; |
@@ -3868,6 +3874,9 @@ static void skge_shutdown(struct pci_dev *pdev) | |||
3868 | struct skge_hw *hw = pci_get_drvdata(pdev); | 3874 | struct skge_hw *hw = pci_get_drvdata(pdev); |
3869 | int i, wol = 0; | 3875 | int i, wol = 0; |
3870 | 3876 | ||
3877 | if (!hw) | ||
3878 | return; | ||
3879 | |||
3871 | for (i = 0; i < hw->ports; i++) { | 3880 | for (i = 0; i < hw->ports; i++) { |
3872 | struct net_device *dev = hw->dev[i]; | 3881 | struct net_device *dev = hw->dev[i]; |
3873 | struct skge_port *skge = netdev_priv(dev); | 3882 | struct skge_port *skge = netdev_priv(dev); |
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index a307310f13f5..104e20456e6f 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/if_vlan.h> | 40 | #include <linux/if_vlan.h> |
41 | #include <linux/prefetch.h> | 41 | #include <linux/prefetch.h> |
42 | #include <linux/mii.h> | 42 | #include <linux/mii.h> |
43 | #include <linux/dmi.h> | ||
43 | 44 | ||
44 | #include <asm/irq.h> | 45 | #include <asm/irq.h> |
45 | 46 | ||
@@ -130,7 +131,7 @@ static const struct pci_device_id sky2_id_table[] = { | |||
130 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ | 131 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ |
131 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */ | 132 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */ |
132 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */ | 133 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */ |
133 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ | 134 | // { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ |
134 | { 0 } | 135 | { 0 } |
135 | }; | 136 | }; |
136 | 137 | ||
@@ -150,6 +151,8 @@ static const char *yukon2_name[] = { | |||
150 | "FE", /* 0xb7 */ | 151 | "FE", /* 0xb7 */ |
151 | }; | 152 | }; |
152 | 153 | ||
154 | static int dmi_blacklisted; | ||
155 | |||
153 | /* Access to external PHY */ | 156 | /* Access to external PHY */ |
154 | static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) | 157 | static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) |
155 | { | 158 | { |
@@ -2531,6 +2534,17 @@ static int __devinit sky2_init(struct sky2_hw *hw) | |||
2531 | return -EOPNOTSUPP; | 2534 | return -EOPNOTSUPP; |
2532 | } | 2535 | } |
2533 | 2536 | ||
2537 | |||
2538 | /* Some Gigabyte motherboards have 88e8056 but cause problems | ||
2539 | * There is some unresolved hardware related problem that causes | ||
2540 | * descriptor errors and receive data corruption. | ||
2541 | */ | ||
2542 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && dmi_blacklisted) { | ||
2543 | dev_err(&hw->pdev->dev, | ||
2544 | "88E8056 on this motherboard not supported\n"); | ||
2545 | return -EOPNOTSUPP; | ||
2546 | } | ||
2547 | |||
2534 | hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); | 2548 | hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); |
2535 | hw->ports = 1; | 2549 | hw->ports = 1; |
2536 | t8 = sky2_read8(hw, B2_Y2_HW_RES); | 2550 | t8 = sky2_read8(hw, B2_Y2_HW_RES); |
@@ -3578,17 +3592,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3578 | goto err_out; | 3592 | goto err_out; |
3579 | } | 3593 | } |
3580 | 3594 | ||
3581 | /* Some Gigabyte motherboards have 88e8056 but cause problems | ||
3582 | * There is some unresolved hardware related problem that causes | ||
3583 | * descriptor errors and receive data corruption. | ||
3584 | */ | ||
3585 | if (pdev->vendor == PCI_VENDOR_ID_MARVELL && | ||
3586 | pdev->device == 0x4364 && pdev->subsystem_vendor == 0x1458) { | ||
3587 | dev_err(&pdev->dev, | ||
3588 | "88E8056 on Gigabyte motherboards not supported\n"); | ||
3589 | goto err_out_disable; | ||
3590 | } | ||
3591 | |||
3592 | err = pci_request_regions(pdev, DRV_NAME); | 3595 | err = pci_request_regions(pdev, DRV_NAME); |
3593 | if (err) { | 3596 | if (err) { |
3594 | dev_err(&pdev->dev, "cannot obtain PCI resources\n"); | 3597 | dev_err(&pdev->dev, "cannot obtain PCI resources\n"); |
@@ -3732,6 +3735,7 @@ err_out_free_regions: | |||
3732 | err_out_disable: | 3735 | err_out_disable: |
3733 | pci_disable_device(pdev); | 3736 | pci_disable_device(pdev); |
3734 | err_out: | 3737 | err_out: |
3738 | pci_set_drvdata(pdev, NULL); | ||
3735 | return err; | 3739 | return err; |
3736 | } | 3740 | } |
3737 | 3741 | ||
@@ -3784,6 +3788,9 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) | |||
3784 | struct sky2_hw *hw = pci_get_drvdata(pdev); | 3788 | struct sky2_hw *hw = pci_get_drvdata(pdev); |
3785 | int i, wol = 0; | 3789 | int i, wol = 0; |
3786 | 3790 | ||
3791 | if (!hw) | ||
3792 | return 0; | ||
3793 | |||
3787 | del_timer_sync(&hw->idle_timer); | 3794 | del_timer_sync(&hw->idle_timer); |
3788 | netif_poll_disable(hw->dev[0]); | 3795 | netif_poll_disable(hw->dev[0]); |
3789 | 3796 | ||
@@ -3815,6 +3822,9 @@ static int sky2_resume(struct pci_dev *pdev) | |||
3815 | struct sky2_hw *hw = pci_get_drvdata(pdev); | 3822 | struct sky2_hw *hw = pci_get_drvdata(pdev); |
3816 | int i, err; | 3823 | int i, err; |
3817 | 3824 | ||
3825 | if (!hw) | ||
3826 | return 0; | ||
3827 | |||
3818 | err = pci_set_power_state(pdev, PCI_D0); | 3828 | err = pci_set_power_state(pdev, PCI_D0); |
3819 | if (err) | 3829 | if (err) |
3820 | goto out; | 3830 | goto out; |
@@ -3861,6 +3871,9 @@ static void sky2_shutdown(struct pci_dev *pdev) | |||
3861 | struct sky2_hw *hw = pci_get_drvdata(pdev); | 3871 | struct sky2_hw *hw = pci_get_drvdata(pdev); |
3862 | int i, wol = 0; | 3872 | int i, wol = 0; |
3863 | 3873 | ||
3874 | if (!hw) | ||
3875 | return; | ||
3876 | |||
3864 | del_timer_sync(&hw->idle_timer); | 3877 | del_timer_sync(&hw->idle_timer); |
3865 | netif_poll_disable(hw->dev[0]); | 3878 | netif_poll_disable(hw->dev[0]); |
3866 | 3879 | ||
@@ -3897,8 +3910,24 @@ static struct pci_driver sky2_driver = { | |||
3897 | .shutdown = sky2_shutdown, | 3910 | .shutdown = sky2_shutdown, |
3898 | }; | 3911 | }; |
3899 | 3912 | ||
3913 | static struct dmi_system_id __initdata broken_dmi_table[] = { | ||
3914 | { | ||
3915 | .ident = "Gigabyte 965P-S3", | ||
3916 | .matches = { | ||
3917 | DMI_MATCH(DMI_SYS_VENDOR, "Gigabyte Technology Co., Ltd."), | ||
3918 | DMI_MATCH(DMI_PRODUCT_NAME, "965P-S3"), | ||
3919 | |||
3920 | }, | ||
3921 | }, | ||
3922 | { } | ||
3923 | }; | ||
3924 | |||
3900 | static int __init sky2_init_module(void) | 3925 | static int __init sky2_init_module(void) |
3901 | { | 3926 | { |
3927 | /* Look for sick motherboards */ | ||
3928 | if (dmi_check_system(broken_dmi_table)) | ||
3929 | dmi_blacklisted = 1; | ||
3930 | |||
3902 | return pci_register_driver(&sky2_driver); | 3931 | return pci_register_driver(&sky2_driver); |
3903 | } | 3932 | } |
3904 | 3933 | ||
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index c15e97253ede..108adbf5b5eb 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -175,12 +175,10 @@ spider_net_setup_aneg(struct spider_net_card *card) | |||
175 | { | 175 | { |
176 | struct mii_phy *phy = &card->phy; | 176 | struct mii_phy *phy = &card->phy; |
177 | u32 advertise = 0; | 177 | u32 advertise = 0; |
178 | u16 bmcr, bmsr, stat1000, estat; | 178 | u16 bmsr, estat; |
179 | 179 | ||
180 | bmcr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMCR); | 180 | bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); |
181 | bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); | 181 | estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); |
182 | stat1000 = spider_net_read_phy(card->netdev, phy->mii_id, MII_STAT1000); | ||
183 | estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); | ||
184 | 182 | ||
185 | if (bmsr & BMSR_10HALF) | 183 | if (bmsr & BMSR_10HALF) |
186 | advertise |= ADVERTISED_10baseT_Half; | 184 | advertise |= ADVERTISED_10baseT_Half; |
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index d7aff8189377..0f667652fda9 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -293,7 +293,7 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth, | |||
293 | else { | 293 | else { |
294 | init_enet_offset = | 294 | init_enet_offset = |
295 | qe_muram_alloc(thread_size, thread_alignment); | 295 | qe_muram_alloc(thread_size, thread_alignment); |
296 | if (IS_MURAM_ERR(init_enet_offset)) { | 296 | if (IS_ERR_VALUE(init_enet_offset)) { |
297 | ugeth_err | 297 | ugeth_err |
298 | ("fill_init_enet_entries: Can not allocate DPRAM memory."); | 298 | ("fill_init_enet_entries: Can not allocate DPRAM memory."); |
299 | qe_put_snum((u8) snum); | 299 | qe_put_snum((u8) snum); |
@@ -2594,7 +2594,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2594 | ugeth->tx_bd_ring_offset[j] = | 2594 | ugeth->tx_bd_ring_offset[j] = |
2595 | qe_muram_alloc(length, | 2595 | qe_muram_alloc(length, |
2596 | UCC_GETH_TX_BD_RING_ALIGNMENT); | 2596 | UCC_GETH_TX_BD_RING_ALIGNMENT); |
2597 | if (!IS_MURAM_ERR(ugeth->tx_bd_ring_offset[j])) | 2597 | if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j])) |
2598 | ugeth->p_tx_bd_ring[j] = | 2598 | ugeth->p_tx_bd_ring[j] = |
2599 | (u8 *) qe_muram_addr(ugeth-> | 2599 | (u8 *) qe_muram_addr(ugeth-> |
2600 | tx_bd_ring_offset[j]); | 2600 | tx_bd_ring_offset[j]); |
@@ -2629,7 +2629,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2629 | ugeth->rx_bd_ring_offset[j] = | 2629 | ugeth->rx_bd_ring_offset[j] = |
2630 | qe_muram_alloc(length, | 2630 | qe_muram_alloc(length, |
2631 | UCC_GETH_RX_BD_RING_ALIGNMENT); | 2631 | UCC_GETH_RX_BD_RING_ALIGNMENT); |
2632 | if (!IS_MURAM_ERR(ugeth->rx_bd_ring_offset[j])) | 2632 | if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j])) |
2633 | ugeth->p_rx_bd_ring[j] = | 2633 | ugeth->p_rx_bd_ring[j] = |
2634 | (u8 *) qe_muram_addr(ugeth-> | 2634 | (u8 *) qe_muram_addr(ugeth-> |
2635 | rx_bd_ring_offset[j]); | 2635 | rx_bd_ring_offset[j]); |
@@ -2713,7 +2713,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2713 | ugeth->tx_glbl_pram_offset = | 2713 | ugeth->tx_glbl_pram_offset = |
2714 | qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram), | 2714 | qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram), |
2715 | UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT); | 2715 | UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT); |
2716 | if (IS_MURAM_ERR(ugeth->tx_glbl_pram_offset)) { | 2716 | if (IS_ERR_VALUE(ugeth->tx_glbl_pram_offset)) { |
2717 | ugeth_err | 2717 | ugeth_err |
2718 | ("%s: Can not allocate DPRAM memory for p_tx_glbl_pram.", | 2718 | ("%s: Can not allocate DPRAM memory for p_tx_glbl_pram.", |
2719 | __FUNCTION__); | 2719 | __FUNCTION__); |
@@ -2735,7 +2735,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2735 | sizeof(struct ucc_geth_thread_data_tx) + | 2735 | sizeof(struct ucc_geth_thread_data_tx) + |
2736 | 32 * (numThreadsTxNumerical == 1), | 2736 | 32 * (numThreadsTxNumerical == 1), |
2737 | UCC_GETH_THREAD_DATA_ALIGNMENT); | 2737 | UCC_GETH_THREAD_DATA_ALIGNMENT); |
2738 | if (IS_MURAM_ERR(ugeth->thread_dat_tx_offset)) { | 2738 | if (IS_ERR_VALUE(ugeth->thread_dat_tx_offset)) { |
2739 | ugeth_err | 2739 | ugeth_err |
2740 | ("%s: Can not allocate DPRAM memory for p_thread_data_tx.", | 2740 | ("%s: Can not allocate DPRAM memory for p_thread_data_tx.", |
2741 | __FUNCTION__); | 2741 | __FUNCTION__); |
@@ -2763,7 +2763,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2763 | qe_muram_alloc(ug_info->numQueuesTx * | 2763 | qe_muram_alloc(ug_info->numQueuesTx * |
2764 | sizeof(struct ucc_geth_send_queue_qd), | 2764 | sizeof(struct ucc_geth_send_queue_qd), |
2765 | UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT); | 2765 | UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT); |
2766 | if (IS_MURAM_ERR(ugeth->send_q_mem_reg_offset)) { | 2766 | if (IS_ERR_VALUE(ugeth->send_q_mem_reg_offset)) { |
2767 | ugeth_err | 2767 | ugeth_err |
2768 | ("%s: Can not allocate DPRAM memory for p_send_q_mem_reg.", | 2768 | ("%s: Can not allocate DPRAM memory for p_send_q_mem_reg.", |
2769 | __FUNCTION__); | 2769 | __FUNCTION__); |
@@ -2806,7 +2806,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2806 | ugeth->scheduler_offset = | 2806 | ugeth->scheduler_offset = |
2807 | qe_muram_alloc(sizeof(struct ucc_geth_scheduler), | 2807 | qe_muram_alloc(sizeof(struct ucc_geth_scheduler), |
2808 | UCC_GETH_SCHEDULER_ALIGNMENT); | 2808 | UCC_GETH_SCHEDULER_ALIGNMENT); |
2809 | if (IS_MURAM_ERR(ugeth->scheduler_offset)) { | 2809 | if (IS_ERR_VALUE(ugeth->scheduler_offset)) { |
2810 | ugeth_err | 2810 | ugeth_err |
2811 | ("%s: Can not allocate DPRAM memory for p_scheduler.", | 2811 | ("%s: Can not allocate DPRAM memory for p_scheduler.", |
2812 | __FUNCTION__); | 2812 | __FUNCTION__); |
@@ -2854,7 +2854,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2854 | qe_muram_alloc(sizeof | 2854 | qe_muram_alloc(sizeof |
2855 | (struct ucc_geth_tx_firmware_statistics_pram), | 2855 | (struct ucc_geth_tx_firmware_statistics_pram), |
2856 | UCC_GETH_TX_STATISTICS_ALIGNMENT); | 2856 | UCC_GETH_TX_STATISTICS_ALIGNMENT); |
2857 | if (IS_MURAM_ERR(ugeth->tx_fw_statistics_pram_offset)) { | 2857 | if (IS_ERR_VALUE(ugeth->tx_fw_statistics_pram_offset)) { |
2858 | ugeth_err | 2858 | ugeth_err |
2859 | ("%s: Can not allocate DPRAM memory for" | 2859 | ("%s: Can not allocate DPRAM memory for" |
2860 | " p_tx_fw_statistics_pram.", __FUNCTION__); | 2860 | " p_tx_fw_statistics_pram.", __FUNCTION__); |
@@ -2893,7 +2893,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2893 | ugeth->rx_glbl_pram_offset = | 2893 | ugeth->rx_glbl_pram_offset = |
2894 | qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram), | 2894 | qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram), |
2895 | UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT); | 2895 | UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT); |
2896 | if (IS_MURAM_ERR(ugeth->rx_glbl_pram_offset)) { | 2896 | if (IS_ERR_VALUE(ugeth->rx_glbl_pram_offset)) { |
2897 | ugeth_err | 2897 | ugeth_err |
2898 | ("%s: Can not allocate DPRAM memory for p_rx_glbl_pram.", | 2898 | ("%s: Can not allocate DPRAM memory for p_rx_glbl_pram.", |
2899 | __FUNCTION__); | 2899 | __FUNCTION__); |
@@ -2914,7 +2914,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2914 | qe_muram_alloc(numThreadsRxNumerical * | 2914 | qe_muram_alloc(numThreadsRxNumerical * |
2915 | sizeof(struct ucc_geth_thread_data_rx), | 2915 | sizeof(struct ucc_geth_thread_data_rx), |
2916 | UCC_GETH_THREAD_DATA_ALIGNMENT); | 2916 | UCC_GETH_THREAD_DATA_ALIGNMENT); |
2917 | if (IS_MURAM_ERR(ugeth->thread_dat_rx_offset)) { | 2917 | if (IS_ERR_VALUE(ugeth->thread_dat_rx_offset)) { |
2918 | ugeth_err | 2918 | ugeth_err |
2919 | ("%s: Can not allocate DPRAM memory for p_thread_data_rx.", | 2919 | ("%s: Can not allocate DPRAM memory for p_thread_data_rx.", |
2920 | __FUNCTION__); | 2920 | __FUNCTION__); |
@@ -2937,7 +2937,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2937 | qe_muram_alloc(sizeof | 2937 | qe_muram_alloc(sizeof |
2938 | (struct ucc_geth_rx_firmware_statistics_pram), | 2938 | (struct ucc_geth_rx_firmware_statistics_pram), |
2939 | UCC_GETH_RX_STATISTICS_ALIGNMENT); | 2939 | UCC_GETH_RX_STATISTICS_ALIGNMENT); |
2940 | if (IS_MURAM_ERR(ugeth->rx_fw_statistics_pram_offset)) { | 2940 | if (IS_ERR_VALUE(ugeth->rx_fw_statistics_pram_offset)) { |
2941 | ugeth_err | 2941 | ugeth_err |
2942 | ("%s: Can not allocate DPRAM memory for" | 2942 | ("%s: Can not allocate DPRAM memory for" |
2943 | " p_rx_fw_statistics_pram.", __FUNCTION__); | 2943 | " p_rx_fw_statistics_pram.", __FUNCTION__); |
@@ -2959,7 +2959,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
2959 | qe_muram_alloc(ug_info->numQueuesRx * | 2959 | qe_muram_alloc(ug_info->numQueuesRx * |
2960 | sizeof(struct ucc_geth_rx_interrupt_coalescing_entry) | 2960 | sizeof(struct ucc_geth_rx_interrupt_coalescing_entry) |
2961 | + 4, UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT); | 2961 | + 4, UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT); |
2962 | if (IS_MURAM_ERR(ugeth->rx_irq_coalescing_tbl_offset)) { | 2962 | if (IS_ERR_VALUE(ugeth->rx_irq_coalescing_tbl_offset)) { |
2963 | ugeth_err | 2963 | ugeth_err |
2964 | ("%s: Can not allocate DPRAM memory for" | 2964 | ("%s: Can not allocate DPRAM memory for" |
2965 | " p_rx_irq_coalescing_tbl.", __FUNCTION__); | 2965 | " p_rx_irq_coalescing_tbl.", __FUNCTION__); |
@@ -3027,7 +3027,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
3027 | (sizeof(struct ucc_geth_rx_bd_queues_entry) + | 3027 | (sizeof(struct ucc_geth_rx_bd_queues_entry) + |
3028 | sizeof(struct ucc_geth_rx_prefetched_bds)), | 3028 | sizeof(struct ucc_geth_rx_prefetched_bds)), |
3029 | UCC_GETH_RX_BD_QUEUES_ALIGNMENT); | 3029 | UCC_GETH_RX_BD_QUEUES_ALIGNMENT); |
3030 | if (IS_MURAM_ERR(ugeth->rx_bd_qs_tbl_offset)) { | 3030 | if (IS_ERR_VALUE(ugeth->rx_bd_qs_tbl_offset)) { |
3031 | ugeth_err | 3031 | ugeth_err |
3032 | ("%s: Can not allocate DPRAM memory for p_rx_bd_qs_tbl.", | 3032 | ("%s: Can not allocate DPRAM memory for p_rx_bd_qs_tbl.", |
3033 | __FUNCTION__); | 3033 | __FUNCTION__); |
@@ -3116,7 +3116,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
3116 | ugeth->exf_glbl_param_offset = | 3116 | ugeth->exf_glbl_param_offset = |
3117 | qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram), | 3117 | qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram), |
3118 | UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT); | 3118 | UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT); |
3119 | if (IS_MURAM_ERR(ugeth->exf_glbl_param_offset)) { | 3119 | if (IS_ERR_VALUE(ugeth->exf_glbl_param_offset)) { |
3120 | ugeth_err | 3120 | ugeth_err |
3121 | ("%s: Can not allocate DPRAM memory for" | 3121 | ("%s: Can not allocate DPRAM memory for" |
3122 | " p_exf_glbl_param.", __FUNCTION__); | 3122 | " p_exf_glbl_param.", __FUNCTION__); |
@@ -3258,7 +3258,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
3258 | 3258 | ||
3259 | /* Allocate InitEnet command parameter structure */ | 3259 | /* Allocate InitEnet command parameter structure */ |
3260 | init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4); | 3260 | init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4); |
3261 | if (IS_MURAM_ERR(init_enet_pram_offset)) { | 3261 | if (IS_ERR_VALUE(init_enet_pram_offset)) { |
3262 | ugeth_err | 3262 | ugeth_err |
3263 | ("%s: Can not allocate DPRAM memory for p_init_enet_pram.", | 3263 | ("%s: Can not allocate DPRAM memory for p_init_enet_pram.", |
3264 | __FUNCTION__); | 3264 | __FUNCTION__); |
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig index 8897f538a7c7..4fc8681bc110 100644 --- a/drivers/net/wan/Kconfig +++ b/drivers/net/wan/Kconfig | |||
@@ -2,10 +2,7 @@ | |||
2 | # wan devices configuration | 2 | # wan devices configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Wan interfaces" | 5 | menuconfig WAN |
6 | depends on NETDEVICES | ||
7 | |||
8 | config WAN | ||
9 | bool "Wan interfaces support" | 6 | bool "Wan interfaces support" |
10 | ---help--- | 7 | ---help--- |
11 | Wide Area Networks (WANs), such as X.25, Frame Relay and leased | 8 | Wide Area Networks (WANs), such as X.25, Frame Relay and leased |
@@ -23,10 +20,12 @@ config WAN | |||
23 | 20 | ||
24 | If unsure, say N. | 21 | If unsure, say N. |
25 | 22 | ||
23 | if WAN | ||
24 | |||
26 | # There is no way to detect a comtrol sv11 - force it modular for now. | 25 | # There is no way to detect a comtrol sv11 - force it modular for now. |
27 | config HOSTESS_SV11 | 26 | config HOSTESS_SV11 |
28 | tristate "Comtrol Hostess SV-11 support" | 27 | tristate "Comtrol Hostess SV-11 support" |
29 | depends on WAN && ISA && m && ISA_DMA_API && INET | 28 | depends on ISA && m && ISA_DMA_API && INET |
30 | help | 29 | help |
31 | Driver for Comtrol Hostess SV-11 network card which | 30 | Driver for Comtrol Hostess SV-11 network card which |
32 | operates on low speed synchronous serial links at up to | 31 | operates on low speed synchronous serial links at up to |
@@ -38,7 +37,7 @@ config HOSTESS_SV11 | |||
38 | # The COSA/SRP driver has not been tested as non-modular yet. | 37 | # The COSA/SRP driver has not been tested as non-modular yet. |
39 | config COSA | 38 | config COSA |
40 | tristate "COSA/SRP sync serial boards support" | 39 | tristate "COSA/SRP sync serial boards support" |
41 | depends on WAN && ISA && m && ISA_DMA_API | 40 | depends on ISA && m && ISA_DMA_API |
42 | ---help--- | 41 | ---help--- |
43 | Driver for COSA and SRP synchronous serial boards. | 42 | Driver for COSA and SRP synchronous serial boards. |
44 | 43 | ||
@@ -62,7 +61,7 @@ config COSA | |||
62 | # | 61 | # |
63 | config LANMEDIA | 62 | config LANMEDIA |
64 | tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards" | 63 | tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards" |
65 | depends on WAN && PCI | 64 | depends on PCI |
66 | ---help--- | 65 | ---help--- |
67 | Driver for the following Lan Media family of serial boards: | 66 | Driver for the following Lan Media family of serial boards: |
68 | 67 | ||
@@ -89,7 +88,7 @@ config LANMEDIA | |||
89 | # There is no way to detect a Sealevel board. Force it modular | 88 | # There is no way to detect a Sealevel board. Force it modular |
90 | config SEALEVEL_4021 | 89 | config SEALEVEL_4021 |
91 | tristate "Sealevel Systems 4021 support" | 90 | tristate "Sealevel Systems 4021 support" |
92 | depends on WAN && ISA && m && ISA_DMA_API && INET | 91 | depends on ISA && m && ISA_DMA_API && INET |
93 | help | 92 | help |
94 | This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. | 93 | This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. |
95 | 94 | ||
@@ -99,7 +98,6 @@ config SEALEVEL_4021 | |||
99 | # Generic HDLC | 98 | # Generic HDLC |
100 | config HDLC | 99 | config HDLC |
101 | tristate "Generic HDLC layer" | 100 | tristate "Generic HDLC layer" |
102 | depends on WAN | ||
103 | help | 101 | help |
104 | Say Y to this option if your Linux box contains a WAN (Wide Area | 102 | Say Y to this option if your Linux box contains a WAN (Wide Area |
105 | Network) card supported by this driver and you are planning to | 103 | Network) card supported by this driver and you are planning to |
@@ -167,7 +165,7 @@ config HDLC_X25 | |||
167 | If unsure, say N. | 165 | If unsure, say N. |
168 | 166 | ||
169 | comment "X.25/LAPB support is disabled" | 167 | comment "X.25/LAPB support is disabled" |
170 | depends on WAN && HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y | 168 | depends on HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y |
171 | 169 | ||
172 | config PCI200SYN | 170 | config PCI200SYN |
173 | tristate "Goramo PCI200SYN support" | 171 | tristate "Goramo PCI200SYN support" |
@@ -230,10 +228,10 @@ config PC300_MLPPP | |||
230 | Multilink PPP over the PC300 synchronous communication boards. | 228 | Multilink PPP over the PC300 synchronous communication boards. |
231 | 229 | ||
232 | comment "Cyclades-PC300 MLPPP support is disabled." | 230 | comment "Cyclades-PC300 MLPPP support is disabled." |
233 | depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) | 231 | depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) |
234 | 232 | ||
235 | comment "Refer to the file README.mlppp, provided by PC300 package." | 233 | comment "Refer to the file README.mlppp, provided by PC300 package." |
236 | depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) | 234 | depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) |
237 | 235 | ||
238 | config PC300TOO | 236 | config PC300TOO |
239 | tristate "Cyclades PC300 RSV/X21 alternative support" | 237 | tristate "Cyclades PC300 RSV/X21 alternative support" |
@@ -338,7 +336,6 @@ config DSCC4_PCI_RST | |||
338 | 336 | ||
339 | config DLCI | 337 | config DLCI |
340 | tristate "Frame Relay DLCI support" | 338 | tristate "Frame Relay DLCI support" |
341 | depends on WAN | ||
342 | ---help--- | 339 | ---help--- |
343 | Support for the Frame Relay protocol. | 340 | Support for the Frame Relay protocol. |
344 | 341 | ||
@@ -385,7 +382,7 @@ config SDLA | |||
385 | # Wan router core. | 382 | # Wan router core. |
386 | config WAN_ROUTER_DRIVERS | 383 | config WAN_ROUTER_DRIVERS |
387 | tristate "WAN router drivers" | 384 | tristate "WAN router drivers" |
388 | depends on WAN && WAN_ROUTER | 385 | depends on WAN_ROUTER |
389 | ---help--- | 386 | ---help--- |
390 | Connect LAN to WAN via Linux box. | 387 | Connect LAN to WAN via Linux box. |
391 | 388 | ||
@@ -440,7 +437,7 @@ config CYCLOMX_X25 | |||
440 | # X.25 network drivers | 437 | # X.25 network drivers |
441 | config LAPBETHER | 438 | config LAPBETHER |
442 | tristate "LAPB over Ethernet driver (EXPERIMENTAL)" | 439 | tristate "LAPB over Ethernet driver (EXPERIMENTAL)" |
443 | depends on WAN && LAPB && X25 | 440 | depends on LAPB && X25 |
444 | ---help--- | 441 | ---help--- |
445 | Driver for a pseudo device (typically called /dev/lapb0) which allows | 442 | Driver for a pseudo device (typically called /dev/lapb0) which allows |
446 | you to open an LAPB point-to-point connection to some other computer | 443 | you to open an LAPB point-to-point connection to some other computer |
@@ -456,7 +453,7 @@ config LAPBETHER | |||
456 | 453 | ||
457 | config X25_ASY | 454 | config X25_ASY |
458 | tristate "X.25 async driver (EXPERIMENTAL)" | 455 | tristate "X.25 async driver (EXPERIMENTAL)" |
459 | depends on WAN && LAPB && X25 | 456 | depends on LAPB && X25 |
460 | ---help--- | 457 | ---help--- |
461 | Send and receive X.25 frames over regular asynchronous serial | 458 | Send and receive X.25 frames over regular asynchronous serial |
462 | lines such as telephone lines equipped with ordinary modems. | 459 | lines such as telephone lines equipped with ordinary modems. |
@@ -471,7 +468,7 @@ config X25_ASY | |||
471 | 468 | ||
472 | config SBNI | 469 | config SBNI |
473 | tristate "Granch SBNI12 Leased Line adapter support" | 470 | tristate "Granch SBNI12 Leased Line adapter support" |
474 | depends on WAN && X86 | 471 | depends on X86 |
475 | ---help--- | 472 | ---help--- |
476 | Driver for ISA SBNI12-xx cards which are low cost alternatives to | 473 | Driver for ISA SBNI12-xx cards which are low cost alternatives to |
477 | leased line modems. | 474 | leased line modems. |
@@ -497,5 +494,4 @@ config SBNI_MULTILINE | |||
497 | 494 | ||
498 | If unsure, say N. | 495 | If unsure, say N. |
499 | 496 | ||
500 | endmenu | 497 | endif # WAN |
501 | |||
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index e273347dc606..e3f5bb0fe603 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Wireless LAN" | 5 | menu "Wireless LAN" |
6 | depends on !S390 | ||
6 | 7 | ||
7 | config WLAN_PRE80211 | 8 | config WLAN_PRE80211 |
8 | bool "Wireless LAN (pre-802.11)" | 9 | bool "Wireless LAN (pre-802.11)" |
diff --git a/drivers/net/wireless/libertas/Makefile b/drivers/net/wireless/libertas/Makefile index 19c935071d8e..56a8ea1fbf04 100644 --- a/drivers/net/wireless/libertas/Makefile +++ b/drivers/net/wireless/libertas/Makefile | |||
@@ -1,5 +1,3 @@ | |||
1 | # EXTRA_CFLAGS += -Wpacked | ||
2 | |||
3 | usb8xxx-objs := main.o fw.o wext.o \ | 1 | usb8xxx-objs := main.o fw.o wext.o \ |
4 | rx.o tx.o cmd.o \ | 2 | rx.o tx.o cmd.o \ |
5 | cmdresp.o scan.o \ | 3 | cmdresp.o scan.o \ |
@@ -7,13 +5,6 @@ usb8xxx-objs := main.o fw.o wext.o \ | |||
7 | ioctl.o debugfs.o \ | 5 | ioctl.o debugfs.o \ |
8 | ethtool.o assoc.o | 6 | ethtool.o assoc.o |
9 | 7 | ||
10 | ifeq ($(CONFIG_LIBERTAS_USB_DEBUG), y) | ||
11 | EXTRA_CFLAGS += -DDEBUG -DPROC_DEBUG | ||
12 | endif | ||
13 | |||
14 | |||
15 | # This is needed to support the newer boot2 bootloader (v >= 3104) | ||
16 | EXTRA_CFLAGS += -DSUPPORT_BOOT_COMMAND | ||
17 | usb8xxx-objs += if_bootcmd.o | 8 | usb8xxx-objs += if_bootcmd.o |
18 | usb8xxx-objs += if_usb.o | 9 | usb8xxx-objs += if_usb.o |
19 | 10 | ||
diff --git a/drivers/net/wireless/libertas/README b/drivers/net/wireless/libertas/README index 688da4c784b1..378577200b56 100644 --- a/drivers/net/wireless/libertas/README +++ b/drivers/net/wireless/libertas/README | |||
@@ -40,64 +40,11 @@ NAME | |||
40 | SYNOPSIS | 40 | SYNOPSIS |
41 | iwpriv <ethX> <command> [sub-command] ... | 41 | iwpriv <ethX> <command> [sub-command] ... |
42 | 42 | ||
43 | iwpriv ethX version | ||
44 | iwpriv ethX scantype [sub-command] | ||
45 | iwpriv ethX getSNR <n> | ||
46 | iwpriv ethX getNF <n> | ||
47 | iwpriv ethX getRSSI <n> | ||
48 | iwpriv ethX setrxant <n> | ||
49 | iwpriv ethX getrxant | ||
50 | iwpriv ethX settxant <n> | ||
51 | iwpriv ethX gettxant | ||
52 | iwpriv ethX authalgs <n> | ||
53 | iwpriv ethX pre-TBTT <n> | ||
54 | iwpriv ethX 8021xauthalgs <n> | ||
55 | iwpriv ethX encryptionmode <n> | ||
56 | iwpriv ethX setregioncode <n> | 43 | iwpriv ethX setregioncode <n> |
57 | iwpriv ethX getregioncode | 44 | iwpriv ethX getregioncode |
58 | iwpriv ethX setbcnavg <n> | ||
59 | iwpriv ethX getbcnavg | ||
60 | iwpriv ethX setdataavg <n> | ||
61 | iwpriv ethX setlisteninter <n> | ||
62 | iwpriv ethX getlisteninter | ||
63 | iwpriv ethX setmultipledtim <n> | ||
64 | iwpriv ethX getmultipledtim | ||
65 | iwpriv ethX atimwindow <n> | ||
66 | iwpriv ethX deauth | ||
67 | iwpriv ethX adhocstop | ||
68 | iwpriv ethX radioon | ||
69 | iwpriv ethX radiooff | ||
70 | iwpriv ethX reasso-on | ||
71 | iwpriv ethX reasso-off | ||
72 | iwpriv ethX scanmode [sub-command] | ||
73 | iwpriv ethX setwpaie <n> | ||
74 | iwpriv ethX wlanidle-off | ||
75 | iwpriv ethX wlanidle-on | ||
76 | iwpriv ethX getcis | ||
77 | iwpriv ethX getlog | ||
78 | iwpriv ethX getadhocstatus | ||
79 | iwpriv ethX adhocgrate <n> | ||
80 | |||
81 | Version 4 Command: | ||
82 | iwpriv ethX inactvityto <n> | ||
83 | iwpriv ethX sleeppd <n> | ||
84 | iwpriv ethX enable11d <n> | ||
85 | iwpriv ethX tpccfg <n> | ||
86 | iwpriv ethX powercfg <n> | ||
87 | iwpriv ethX setafc <n> | ||
88 | iwpriv ethX getafc | ||
89 | 45 | ||
90 | Version 5 Command: | 46 | Version 5 Command: |
91 | iwpriv ethX ledgpio <n> | 47 | iwpriv ethX ledgpio <n> |
92 | iwpriv ethX scanprobes <n> | ||
93 | iwpriv ethX lolisteninter <n> | ||
94 | iwpriv ethX rateadapt <n> <m> | ||
95 | iwpriv ethX txcontrol <n> | ||
96 | iwpriv ethX psnullinterval <n> | ||
97 | iwpriv ethX prescan <n> | ||
98 | iwpriv ethX getrxinfo | ||
99 | iwpriv ethX gettxrate | ||
100 | iwpriv ethX beaconinterval | ||
101 | 48 | ||
102 | BT Commands: | 49 | BT Commands: |
103 | The blinding table (BT) contains a list of mac addresses that should be | 50 | The blinding table (BT) contains a list of mac addresses that should be |
@@ -150,114 +97,6 @@ DESCRIPTION | |||
150 | The ethX parameter specifies the network device that is to be used to | 97 | The ethX parameter specifies the network device that is to be used to |
151 | perform this command on. it could be eth0, eth1 etc. | 98 | perform this command on. it could be eth0, eth1 etc. |
152 | 99 | ||
153 | version | ||
154 | This is used to get the current version of the driver and the firmware. | ||
155 | |||
156 | scantype | ||
157 | This command is used to set the scan type to be used by the driver in | ||
158 | the scan command. This setting will not be used while performing a scan | ||
159 | for a specific SSID, as it is always done with scan type being active. | ||
160 | |||
161 | where the sub-commands are: - | ||
162 | active -- to set the scan type to active | ||
163 | passive -- to set the scan type to passive | ||
164 | get -- to get the scan type set in the driver | ||
165 | |||
166 | getSNR | ||
167 | This command gets the average and non average value of Signal to Noise | ||
168 | Ratio of Beacon and Data. | ||
169 | |||
170 | where value is:- | ||
171 | 0 -- Beacon non-average. | ||
172 | 1 -- Beacon average. | ||
173 | 2 -- Data non-average. | ||
174 | 3 -- Data average. | ||
175 | |||
176 | If no value is given, all four values are returned in the order mentioned | ||
177 | above. | ||
178 | |||
179 | Note: This command is available only when STA is connected. | ||
180 | |||
181 | getRSSI | ||
182 | This command gets the average and non average value os Receive Signal | ||
183 | Strength of Beacon and Data. | ||
184 | |||
185 | where value is:- | ||
186 | 0 -- Beacon non-average. | ||
187 | 1 -- Beacon average. | ||
188 | 2 -- Data non-average. | ||
189 | 3 -- Data average. | ||
190 | |||
191 | Note: This command is available only when STA is connected. | ||
192 | |||
193 | getNF | ||
194 | This command gets the average and non average value of Noise Floor of | ||
195 | Beacon and Data. | ||
196 | |||
197 | where value is:- | ||
198 | 0 -- Beacon non-average. | ||
199 | 1 -- Beacon average. | ||
200 | 2 -- Data non-average. | ||
201 | 3 -- Data average. | ||
202 | |||
203 | Note: This command is available only when STA is connected. | ||
204 | |||
205 | setrxant | ||
206 | This command is used to set the mode for Rx antenna. | ||
207 | |||
208 | The options that can be sent are:- | ||
209 | 1 -- Antenna 1. | ||
210 | 2 -- Antenna 2. | ||
211 | 0xFFFF -- Diversity. | ||
212 | |||
213 | Usage: | ||
214 | iwpriv ethX setrxant 0x01: select Antenna 1. | ||
215 | |||
216 | getrxant | ||
217 | This command is used to get the mode for Rx antenna. | ||
218 | |||
219 | |||
220 | settxant | ||
221 | This command is used to set the mode for Tx antenna. | ||
222 | The options that can be sent are:- | ||
223 | 1 -- Antenna 1. | ||
224 | 2 -- Antenna 2. | ||
225 | 0xFFFF -- Diversity. | ||
226 | Usage: | ||
227 | iwpriv ethX settxant 0x01: select Antenna 1. | ||
228 | |||
229 | gettxant | ||
230 | This command is used to get the mode for Tx antenna. | ||
231 | |||
232 | authalgs | ||
233 | This command is used by the WPA supplicant to set the authentication | ||
234 | algorithms in the station. | ||
235 | |||
236 | 8021xauthalgs | ||
237 | This command is used by the WPA supplicant to set the 8021.x authentication algorithm type | ||
238 | station. | ||
239 | |||
240 | where values can be:- | ||
241 | 1 -- None | ||
242 | 2 -- LEAP | ||
243 | 4 -- TLS | ||
244 | 8 -- TTLs | ||
245 | 16 -- MD5 | ||
246 | |||
247 | |||
248 | encryptionmode | ||
249 | This command is used by the WPA supplicant to set the encryption algorithm. | ||
250 | |||
251 | where values can be:- | ||
252 | 0 -- NONE | ||
253 | 1 -- WEP40 | ||
254 | 2 -- TKIP | ||
255 | 3 -- CCMP | ||
256 | 4 -- WEP104 | ||
257 | |||
258 | pre-TBTT | ||
259 | This command is used to set pre-TBTT time period where value is in microseconds. | ||
260 | |||
261 | setregioncode | 100 | setregioncode |
262 | This command is used to set the region code in the station. | 101 | This command is used to set the region code in the station. |
263 | where value is 'region code' for various regions like | 102 | where value is 'region code' for various regions like |
@@ -270,114 +109,6 @@ getregioncode | |||
270 | This command is used to get the region code information set in the | 109 | This command is used to get the region code information set in the |
271 | station. | 110 | station. |
272 | 111 | ||
273 | setbcnavg | ||
274 | Set the weighting factor for calculating RSSI. | ||
275 | |||
276 | getbcnavg | ||
277 | Get weighting factor for calculating RSSI. | ||
278 | |||
279 | setdataavg | ||
280 | Set the weighting factor for calculating SNR. | ||
281 | |||
282 | setlisteninter | ||
283 | This command is used to set the listen interval in the | ||
284 | station. | ||
285 | |||
286 | where the value ranges between 1 - 255 | ||
287 | |||
288 | getlisteninter | ||
289 | This command is used to get the listen interval value set in the | ||
290 | station. | ||
291 | |||
292 | setmultipledtim | ||
293 | This command is used to set the multiple dtim value in the | ||
294 | station. | ||
295 | where the value is 1,2,3,4,5,0xfffe | ||
296 | 0xfffe means the firmware will use listen interval in association | ||
297 | command for waking up | ||
298 | |||
299 | getmultipledtim | ||
300 | This command is used to get the multiple dtim value set in the station. | ||
301 | |||
302 | atimwindow | ||
303 | This command is used to set the atim value in the | ||
304 | station. | ||
305 | |||
306 | where the value ranges between 0 - 50 | ||
307 | |||
308 | deauth | ||
309 | This command is used to send the de-authentication to the AP with which | ||
310 | the station is associated. This command is valid only when | ||
311 | station is in Infrastructure mode. | ||
312 | |||
313 | Note: This command is available only when STA is connected. | ||
314 | |||
315 | adhocstop | ||
316 | This command is used to stop beacon transmission from the station and | ||
317 | go into idle state in ad-hoc mode. | ||
318 | |||
319 | Note: This command is available only when STA is connected. | ||
320 | |||
321 | radioon | ||
322 | This command is used to turn on the RF antenna. | ||
323 | |||
324 | radiooff | ||
325 | This command is sued to turn off the RF antenna. | ||
326 | |||
327 | scanmode | ||
328 | This command is used to set the station to scan for either IBSS | ||
329 | networks or BSS networks or both BSS and IBSS networks. This | ||
330 | command can be used with sub commands, | ||
331 | |||
332 | where the value for | ||
333 | bss -- Scan All the BSS networks. | ||
334 | ibss -- Scan All the IBSS networks. | ||
335 | any -- Scan both BSS and IBSS networks. | ||
336 | |||
337 | |||
338 | |||
339 | setwpaie | ||
340 | This command is used by WPA supplicant to send the WPA-IE to the driver. | ||
341 | |||
342 | wlanidle-off | ||
343 | This command is used to get into idle state. | ||
344 | |||
345 | Note: This command is available only when STA is connected. | ||
346 | |||
347 | wlanidle-on | ||
348 | This command is used to get off the idle state. | ||
349 | |||
350 | Note: This command is available only when STA is connected. | ||
351 | |||
352 | |||
353 | getlog | ||
354 | This command is used to get the 802.11 statistics available in the | ||
355 | station. | ||
356 | |||
357 | Note: This command is available only when STA is connected. | ||
358 | |||
359 | getadhocstatus | ||
360 | This command is used to get the ad-hoc Network Status. | ||
361 | |||
362 | The various status codes are: | ||
363 | AdhocStarted | ||
364 | AdhocJoined | ||
365 | AdhocIdle | ||
366 | InfraMode | ||
367 | AutoUnknownMode | ||
368 | |||
369 | Note: This command is available only when STA is connected. | ||
370 | |||
371 | adhocgrate | ||
372 | This command is used to enable(1) g_rate, Disable(0) g_rate | ||
373 | and request(2) the status which g_rate is disabled/enabled, | ||
374 | for Ad-hoc creator. | ||
375 | |||
376 | where value is:- | ||
377 | 0 -- Disabled | ||
378 | 1 -- Enabled | ||
379 | 2 -- Get | ||
380 | |||
381 | ledgpio | 112 | ledgpio |
382 | This command is used to set/get LEDs. | 113 | This command is used to set/get LEDs. |
383 | 114 | ||
@@ -400,253 +131,6 @@ ledgpio | |||
400 | Note: LED0 is invalid | 131 | Note: LED0 is invalid |
401 | Note: Maximum Number of LEDs are 16. | 132 | Note: Maximum Number of LEDs are 16. |
402 | 133 | ||
403 | inactivityto | ||
404 | This command is used by the host to set/get the inactivity timeout value, | ||
405 | which specifies when WLAN device is put to sleep. | ||
406 | |||
407 | Usage: | ||
408 | iwpriv ethX inactivityto [<timeout>] | ||
409 | |||
410 | where the parameter are: | ||
411 | timeout: timeout value in milliseconds. | ||
412 | |||
413 | Example: | ||
414 | iwpriv eth1 inactivityto | ||
415 | "get the timeout value" | ||
416 | |||
417 | iwpriv eth1 inactivityto X | ||
418 | "set timeout value to X ms" | ||
419 | |||
420 | |||
421 | sleeppd | ||
422 | This command is used to configure the sleep period of the WLAN device. | ||
423 | |||
424 | Usage: | ||
425 | iwpriv ethX sleeppd [<sleep period>] | ||
426 | |||
427 | where the parameter are: | ||
428 | Period: sleep period in milliseconds. Range 10~60. | ||
429 | |||
430 | Example: | ||
431 | iwpriv eth1 sleeppd 10 | ||
432 | "set period as 10 ms" | ||
433 | iwpriv eth1 sleeppd | ||
434 | "get the sleep period configuration" | ||
435 | |||
436 | enable11d | ||
437 | This command is used to control 11d | ||
438 | where value is:- | ||
439 | 1 -- Enabled | ||
440 | 0 -- Disabled | ||
441 | 2 -- Get | ||
442 | |||
443 | |||
444 | |||
445 | |||
446 | tpccfg | ||
447 | Enables or disables automatic transmit power control. | ||
448 | |||
449 | The first parameter turns this feature on (1) or off (0). When turning | ||
450 | on, the user must also supply four more parameters in the following | ||
451 | order: | ||
452 | -UseSNR (Use SNR (in addition to PER) for TPC algorithm), | ||
453 | -P0 (P0 power level for TPC), | ||
454 | -P1 (P1 power level for TPC), | ||
455 | -P2 (P2 power level for TPC). | ||
456 | |||
457 | Usage: | ||
458 | iwpriv ethX tpccfg: Get current configuration | ||
459 | iwpriv ethX tpccfg 0: disable auto TPC | ||
460 | iwpriv ethX tpccfg 0x01 0x00 0x05 0x0a 0x0d: enable auto TPC; do not use SNR; | ||
461 | P0=0x05; P1=0x0a; P2=0x0d; | ||
462 | iwpriv ethX tpccfg 0x01 0x01 0x05 0x0a 0x0d: enable auto TPC; use SNR; | ||
463 | P0=0x05; P1=0x0a; P2=0x0d. | ||
464 | |||
465 | powercfg | ||
466 | Enables or disables power adaptation. | ||
467 | |||
468 | The first parameter turns this feature on (1) or off (0). When turning | ||
469 | on, the user must also supply three more parameters in the following | ||
470 | order: | ||
471 | -P0 (P0 power level for Power Adaptation), | ||
472 | -P1 (P1 power level for Power Adaptation), | ||
473 | -P2 (P2 power level for Power Adaptation). | ||
474 | |||
475 | Usage: | ||
476 | iwpriv ethX powercfg: Get current configuration | ||
477 | iwpriv ethX powercfg 0: disable power adaptation | ||
478 | iwpriv ethX powercfg 1 0x0d 0x0f 0x12: enable power adaptation; | ||
479 | P0=0x0d; P1=0x0f; P2=0x12. | ||
480 | |||
481 | getafc | ||
482 | This command returns automatic frequency control parameters. It returns | ||
483 | three integers: | ||
484 | -P0: automatic is on (1), or off (0), | ||
485 | -P1: current timing offset in PPM (part per million), and | ||
486 | -P2: current frequency offset in PPM. | ||
487 | |||
488 | setafc | ||
489 | Set automatic frequency control options. | ||
490 | |||
491 | The first parameter turns automatic on (1) or off (0). | ||
492 | The user must supply two more parameters in either case, in the following | ||
493 | order: | ||
494 | |||
495 | When auto is on: | ||
496 | |||
497 | -P0 (automatic adjustment frequency threshold in PPM), | ||
498 | -P1 (automatic adjustment period in beacon period), | ||
499 | |||
500 | When auto is off: | ||
501 | |||
502 | -P0 (manual adjustment timing offset in PPM), and | ||
503 | -P1 (manual adjustment frequency offset in PPM). | ||
504 | |||
505 | Usage: | ||
506 | iwpriv ethX setafc 0 10 10: manual adjustment, both timing and frequcncy | ||
507 | offset are 10 PPM. | ||
508 | |||
509 | iwpriv ethX setafc 1 10 10 enable afc, automatic adjustment, | ||
510 | frequency threshold 10 PPM, for every 10 beacon periods. | ||
511 | |||
512 | |||
513 | |||
514 | scanprobes | ||
515 | This command sets number of probe requests per channel. | ||
516 | |||
517 | Usage: | ||
518 | iwpriv ethX scanprobes 3 (set scan probes to 3) | ||
519 | iwpriv ethX scanprobes (get scan probes) | ||
520 | |||
521 | lolisteninter | ||
522 | This command sets the value of listen interval. | ||
523 | |||
524 | Usage: | ||
525 | iwpriv ethX lolisteninter 234 (set the lolisteninter to 234) | ||
526 | iwpriv ethX lolisteninter (get the lolisteninter value) | ||
527 | |||
528 | rateadapt | ||
529 | This command sets the data rates bitmap. | ||
530 | Where <n> | ||
531 | 0: Disable auto rate adapt | ||
532 | 1: Enable auto rate adapt | ||
533 | |||
534 | <m> | ||
535 | data rate bitmap | ||
536 | Bit Data rate | ||
537 | 0 1 Mbps | ||
538 | 1 2 Mbps | ||
539 | 2 5.5 Mbps | ||
540 | 3 11 Mbps | ||
541 | 4 Reserved | ||
542 | 5 6 Mbps | ||
543 | 6 9 Mbps | ||
544 | 7 12 Mbps | ||
545 | 8 18 Mbps | ||
546 | 9 24 Mbps | ||
547 | 10 36 Mbps | ||
548 | 11 48 Mbps | ||
549 | 12 54 Mbps | ||
550 | 12-15 Reserved | ||
551 | |||
552 | Usage: | ||
553 | iwpriv ethX rateadapt | ||
554 | read the currect data rate setting | ||
555 | iwpriv ethX rateadapt 1 0x07 | ||
556 | enable auto data rate adapt and | ||
557 | data rates are 1Mbps, 2Mbsp and 5.5Mbps | ||
558 | |||
559 | |||
560 | txcontrol | ||
561 | This command is used to set the Tx rate, ack policy, and retry limit on a per packet basis. | ||
562 | |||
563 | Where value <n> is: | ||
564 | if bit[4] == 1: | ||
565 | bit[3:0] -- 0 1 2 3 4 5 6 7 8 9 10 11 12 13-16 | ||
566 | Data Rate(Mbps) -- 1 2 5.5 11 Rsv 6 9 12 18 24 36 48 54 Rsv | ||
567 | |||
568 | bit[12:8] | ||
569 | if bit[12] == 1, bit[11:8] specifies the Tx retry limit. | ||
570 | |||
571 | bit[14:13] specifies per packet ack policy: | ||
572 | bit[14:13] | ||
573 | 1 0 use immediate ack policy for this packet | ||
574 | 1 1 use no ack policy for this packet | ||
575 | 0 x use the per-packet ack policy setting | ||
576 | |||
577 | Usage: | ||
578 | iwpriv ethX txcontrol 0x7513 | ||
579 | Use no-ack policy, 5 retires for Tx, 11Mbps rate | ||
580 | |||
581 | |||
582 | |||
583 | psnullinterval | ||
584 | This command is used to set/request NULL package interval for Power Save | ||
585 | under infrastructure mode. | ||
586 | |||
587 | where value is:- | ||
588 | -1 -- Disabled | ||
589 | n>0 -- Set interval as n (seconds) | ||
590 | |||
591 | prescan | ||
592 | This command is used to enable (1)/disable(0) auto prescan before assoicate to the ap | ||
593 | |||
594 | where value is:- | ||
595 | 0 -- Disabled | ||
596 | 1 -- Enabled | ||
597 | 2 -- Get | ||
598 | |||
599 | getrxinfo | ||
600 | This command gets non average value of Signal to Noise Ratio of Data and rate index. | ||
601 | |||
602 | The following table shows RateIndex and Rate | ||
603 | |||
604 | RateIndex Data rate | ||
605 | 0 1 Mbps | ||
606 | 1 2 Mbps | ||
607 | 2 5.5 Mbps | ||
608 | 3 11 Mbps | ||
609 | 4 Reserved | ||
610 | 5 6 Mbps | ||
611 | 6 9 Mbps | ||
612 | 7 12 Mbps | ||
613 | 8 18 Mbps | ||
614 | 9 24 Mbps | ||
615 | 10 36 Mbps | ||
616 | 11 48 Mbps | ||
617 | 12 54 Mbps | ||
618 | 13-15 Reserved | ||
619 | |||
620 | gettxrate | ||
621 | This command gets current Tx rate index of the first packet associated with Rate Adaptation. | ||
622 | |||
623 | The following table shows RateIndex and Rate | ||
624 | |||
625 | RateIndex Data rate | ||
626 | 0 1 Mbps | ||
627 | 1 2 Mbps | ||
628 | 2 5.5 Mbps | ||
629 | 3 11 Mbps | ||
630 | 4 Reserved | ||
631 | 5 6 Mbps | ||
632 | 6 9 Mbps | ||
633 | 7 12 Mbps | ||
634 | 8 18 Mbps | ||
635 | 9 24 Mbps | ||
636 | 10 36 Mbps | ||
637 | 11 48 Mbps | ||
638 | 12 54 Mbps | ||
639 | 13-15 Reserved | ||
640 | |||
641 | bcninterval | ||
642 | This command is used to sets beacon interval in adhoc mode when an argument is given, and gets current adhoc | ||
643 | beacon interval when no argument is given. The valid beacon interval is between 20 - 1000, | ||
644 | default beacon interval is 100. | ||
645 | |||
646 | Usage: | ||
647 | iwpriv ethX bcninterval 100 (set adhoc beacon interval to 100) | ||
648 | iwpriv ethX bcninterval (get adhoc beacon interval) | ||
649 | |||
650 | fwt_add | 134 | fwt_add |
651 | This command is used to insert an entry into the FWT table. The list of | 135 | This command is used to insert an entry into the FWT table. The list of |
652 | parameters must follow the following structure: | 136 | parameters must follow the following structure: |
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c index b55c7f57aca8..c260bd1b3d46 100644 --- a/drivers/net/wireless/libertas/assoc.c +++ b/drivers/net/wireless/libertas/assoc.c | |||
@@ -23,13 +23,13 @@ static int assoc_helper_essid(wlan_private *priv, | |||
23 | ENTER(); | 23 | ENTER(); |
24 | 24 | ||
25 | lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid); | 25 | lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid); |
26 | if (assoc_req->mode == wlan802_11infrastructure) { | 26 | if (assoc_req->mode == IW_MODE_INFRA) { |
27 | if (adapter->prescan) { | 27 | if (adapter->prescan) { |
28 | libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); | 28 | libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); |
29 | } | 29 | } |
30 | 30 | ||
31 | i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, | 31 | i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, |
32 | NULL, wlan802_11infrastructure); | 32 | NULL, IW_MODE_INFRA); |
33 | if (i >= 0) { | 33 | if (i >= 0) { |
34 | lbs_pr_debug(1, | 34 | lbs_pr_debug(1, |
35 | "SSID found in scan list ... associating...\n"); | 35 | "SSID found in scan list ... associating...\n"); |
@@ -44,7 +44,7 @@ static int assoc_helper_essid(wlan_private *priv, | |||
44 | lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n", | 44 | lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n", |
45 | assoc_req->ssid.ssid); | 45 | assoc_req->ssid.ssid); |
46 | } | 46 | } |
47 | } else if (assoc_req->mode == wlan802_11ibss) { | 47 | } else if (assoc_req->mode == IW_MODE_ADHOC) { |
48 | /* Scan for the network, do not save previous results. Stale | 48 | /* Scan for the network, do not save previous results. Stale |
49 | * scan data will cause us to join a non-existant adhoc network | 49 | * scan data will cause us to join a non-existant adhoc network |
50 | */ | 50 | */ |
@@ -52,7 +52,7 @@ static int assoc_helper_essid(wlan_private *priv, | |||
52 | 52 | ||
53 | /* Search for the requested SSID in the scan table */ | 53 | /* Search for the requested SSID in the scan table */ |
54 | i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, | 54 | i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, |
55 | wlan802_11ibss); | 55 | IW_MODE_ADHOC); |
56 | if (i >= 0) { | 56 | if (i >= 0) { |
57 | lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret); | 57 | lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret); |
58 | libertas_join_adhoc_network(priv, &adapter->scantable[i]); | 58 | libertas_join_adhoc_network(priv, &adapter->scantable[i]); |
@@ -90,10 +90,10 @@ static int assoc_helper_bssid(wlan_private *priv, | |||
90 | goto out; | 90 | goto out; |
91 | } | 91 | } |
92 | 92 | ||
93 | if (assoc_req->mode == wlan802_11infrastructure) { | 93 | if (assoc_req->mode == IW_MODE_INFRA) { |
94 | ret = wlan_associate(priv, &adapter->scantable[i]); | 94 | ret = wlan_associate(priv, &adapter->scantable[i]); |
95 | lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret); | 95 | lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret); |
96 | } else if (assoc_req->mode == wlan802_11ibss) { | 96 | } else if (assoc_req->mode == IW_MODE_ADHOC) { |
97 | libertas_join_adhoc_network(priv, &adapter->scantable[i]); | 97 | libertas_join_adhoc_network(priv, &adapter->scantable[i]); |
98 | } | 98 | } |
99 | memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid, | 99 | memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid, |
@@ -142,23 +142,23 @@ static int assoc_helper_mode(wlan_private *priv, | |||
142 | 142 | ||
143 | ENTER(); | 143 | ENTER(); |
144 | 144 | ||
145 | if (assoc_req->mode == adapter->inframode) { | 145 | if (assoc_req->mode == adapter->mode) { |
146 | LEAVE(); | 146 | LEAVE(); |
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | 149 | ||
150 | if (assoc_req->mode == wlan802_11infrastructure) { | 150 | if (assoc_req->mode == IW_MODE_INFRA) { |
151 | if (adapter->psstate != PS_STATE_FULL_POWER) | 151 | if (adapter->psstate != PS_STATE_FULL_POWER) |
152 | libertas_ps_wakeup(priv, cmd_option_waitforrsp); | 152 | libertas_ps_wakeup(priv, cmd_option_waitforrsp); |
153 | adapter->psmode = wlan802_11powermodecam; | 153 | adapter->psmode = wlan802_11powermodecam; |
154 | } | 154 | } |
155 | 155 | ||
156 | adapter->inframode = assoc_req->mode; | 156 | adapter->mode = assoc_req->mode; |
157 | ret = libertas_prepare_and_send_command(priv, | 157 | ret = libertas_prepare_and_send_command(priv, |
158 | cmd_802_11_snmp_mib, | 158 | cmd_802_11_snmp_mib, |
159 | 0, cmd_option_waitforrsp, | 159 | 0, cmd_option_waitforrsp, |
160 | OID_802_11_INFRASTRUCTURE_MODE, | 160 | OID_802_11_INFRASTRUCTURE_MODE, |
161 | (void *) assoc_req->mode); | 161 | (void *) (size_t) assoc_req->mode); |
162 | 162 | ||
163 | LEAVE(); | 163 | LEAVE(); |
164 | return ret; | 164 | return ret; |
@@ -196,7 +196,7 @@ static int assoc_helper_wep_keys(wlan_private *priv, | |||
196 | goto out; | 196 | goto out; |
197 | 197 | ||
198 | /* enable/disable the MAC's WEP packet filter */ | 198 | /* enable/disable the MAC's WEP packet filter */ |
199 | if (assoc_req->secinfo.WEPstatus == wlan802_11WEPenabled) | 199 | if (assoc_req->secinfo.wep_enabled) |
200 | adapter->currentpacketfilter |= cmd_act_mac_wep_enable; | 200 | adapter->currentpacketfilter |= cmd_act_mac_wep_enable; |
201 | else | 201 | else |
202 | adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable; | 202 | adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable; |
@@ -300,8 +300,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter, | |||
300 | } | 300 | } |
301 | 301 | ||
302 | if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { | 302 | if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { |
303 | if (adapter->secinfo.authmode != | 303 | if (adapter->secinfo.auth_mode != assoc_req->secinfo.auth_mode) { |
304 | assoc_req->secinfo.authmode) { | ||
305 | lbs_pr_debug(1, "Deauthenticating due to updated security " | 304 | lbs_pr_debug(1, "Deauthenticating due to updated security " |
306 | "info in configuration request.\n"); | 305 | "info in configuration request.\n"); |
307 | return 1; | 306 | return 1; |
@@ -316,7 +315,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter, | |||
316 | 315 | ||
317 | /* FIXME: deal with 'auto' mode somehow */ | 316 | /* FIXME: deal with 'auto' mode somehow */ |
318 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { | 317 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
319 | if (assoc_req->mode != wlan802_11infrastructure) | 318 | if (assoc_req->mode != IW_MODE_INFRA) |
320 | return 1; | 319 | return 1; |
321 | } | 320 | } |
322 | 321 | ||
@@ -333,12 +332,12 @@ static int should_stop_adhoc(wlan_adapter *adapter, | |||
333 | if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) | 332 | if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) |
334 | return 1; | 333 | return 1; |
335 | if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, | 334 | if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, |
336 | sizeof(struct WLAN_802_11_SSID))) | 335 | adapter->curbssparams.ssid.ssidlength)) |
337 | return 1; | 336 | return 1; |
338 | 337 | ||
339 | /* FIXME: deal with 'auto' mode somehow */ | 338 | /* FIXME: deal with 'auto' mode somehow */ |
340 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { | 339 | if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { |
341 | if (assoc_req->mode != wlan802_11ibss) | 340 | if (assoc_req->mode != IW_MODE_ADHOC) |
342 | return 1; | 341 | return 1; |
343 | } | 342 | } |
344 | 343 | ||
@@ -382,7 +381,7 @@ void wlan_association_worker(struct work_struct *work) | |||
382 | } | 381 | } |
383 | 382 | ||
384 | if (find_any_ssid) { | 383 | if (find_any_ssid) { |
385 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode; | 384 | u8 new_mode; |
386 | 385 | ||
387 | ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, | 386 | ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, |
388 | assoc_req->mode, &new_mode); | 387 | assoc_req->mode, &new_mode); |
@@ -393,7 +392,7 @@ void wlan_association_worker(struct work_struct *work) | |||
393 | } | 392 | } |
394 | 393 | ||
395 | /* Ensure we switch to the mode of the AP */ | 394 | /* Ensure we switch to the mode of the AP */ |
396 | if (assoc_req->mode == wlan802_11autounknown) { | 395 | if (assoc_req->mode == IW_MODE_AUTO) { |
397 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); | 396 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); |
398 | assoc_req->mode = new_mode; | 397 | assoc_req->mode = new_mode; |
399 | } | 398 | } |
@@ -403,7 +402,7 @@ void wlan_association_worker(struct work_struct *work) | |||
403 | * Check if the attributes being changing require deauthentication | 402 | * Check if the attributes being changing require deauthentication |
404 | * from the currently associated infrastructure access point. | 403 | * from the currently associated infrastructure access point. |
405 | */ | 404 | */ |
406 | if (adapter->inframode == wlan802_11infrastructure) { | 405 | if (adapter->mode == IW_MODE_INFRA) { |
407 | if (should_deauth_infrastructure(adapter, assoc_req)) { | 406 | if (should_deauth_infrastructure(adapter, assoc_req)) { |
408 | ret = libertas_send_deauthentication(priv); | 407 | ret = libertas_send_deauthentication(priv); |
409 | if (ret) { | 408 | if (ret) { |
@@ -412,7 +411,7 @@ void wlan_association_worker(struct work_struct *work) | |||
412 | ret); | 411 | ret); |
413 | } | 412 | } |
414 | } | 413 | } |
415 | } else if (adapter->inframode == wlan802_11ibss) { | 414 | } else if (adapter->mode == IW_MODE_ADHOC) { |
416 | if (should_stop_adhoc(adapter, assoc_req)) { | 415 | if (should_stop_adhoc(adapter, assoc_req)) { |
417 | ret = libertas_stop_adhoc_network(priv); | 416 | ret = libertas_stop_adhoc_network(priv); |
418 | if (ret) { | 417 | if (ret) { |
@@ -543,7 +542,7 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter) | |||
543 | assoc_req->channel = adapter->curbssparams.channel; | 542 | assoc_req->channel = adapter->curbssparams.channel; |
544 | 543 | ||
545 | if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) | 544 | if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) |
546 | assoc_req->mode = adapter->inframode; | 545 | assoc_req->mode = adapter->mode; |
547 | 546 | ||
548 | if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { | 547 | if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { |
549 | memcpy(&assoc_req->bssid, adapter->curbssparams.bssid, | 548 | memcpy(&assoc_req->bssid, adapter->curbssparams.bssid, |
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index bfdac58b5c06..de9cb46a70ff 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -381,15 +381,16 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv, | |||
381 | switch (cmd_oid) { | 381 | switch (cmd_oid) { |
382 | case OID_802_11_INFRASTRUCTURE_MODE: | 382 | case OID_802_11_INFRASTRUCTURE_MODE: |
383 | { | 383 | { |
384 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode = | 384 | u8 mode = (u8) (size_t) pdata_buf; |
385 | (enum WLAN_802_11_NETWORK_INFRASTRUCTURE) pdata_buf; | ||
386 | pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); | 385 | pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); |
387 | pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i); | 386 | pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i); |
388 | pSNMPMIB->bufsize = sizeof(u8); | 387 | pSNMPMIB->bufsize = sizeof(u8); |
389 | if (mode == wlan802_11infrastructure) | 388 | if (mode == IW_MODE_ADHOC) { |
390 | ucTemp = SNMP_MIB_VALUE_INFRA; | ||
391 | else | ||
392 | ucTemp = SNMP_MIB_VALUE_ADHOC; | 389 | ucTemp = SNMP_MIB_VALUE_ADHOC; |
390 | } else { | ||
391 | /* Infra and Auto modes */ | ||
392 | ucTemp = SNMP_MIB_VALUE_INFRA; | ||
393 | } | ||
393 | 394 | ||
394 | memmove(pSNMPMIB->value, &ucTemp, sizeof(u8)); | 395 | memmove(pSNMPMIB->value, &ucTemp, sizeof(u8)); |
395 | 396 | ||
@@ -947,8 +948,8 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u | |||
947 | 948 | ||
948 | spin_unlock_irqrestore(&adapter->driver_lock, flags); | 949 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
949 | 950 | ||
950 | lbs_pr_debug(1, "QUEUE_CMD: Inserted node=0x%x, cmd=0x%x in cmdpendingq\n", | 951 | lbs_pr_debug(1, "QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n", |
951 | (u32) cmdnode, | 952 | cmdnode, |
952 | ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); | 953 | ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); |
953 | 954 | ||
954 | done: | 955 | done: |
@@ -976,8 +977,8 @@ static int DownloadcommandToStation(wlan_private * priv, | |||
976 | ENTER(); | 977 | ENTER(); |
977 | 978 | ||
978 | if (!adapter || !cmdnode) { | 979 | if (!adapter || !cmdnode) { |
979 | lbs_pr_debug(1, "DNLD_CMD: adapter = %#x, cmdnode = %#x\n", | 980 | lbs_pr_debug(1, "DNLD_CMD: adapter = %p, cmdnode = %p\n", |
980 | (int)adapter, (int)cmdnode); | 981 | adapter, cmdnode); |
981 | if (cmdnode) { | 982 | if (cmdnode) { |
982 | spin_lock_irqsave(&adapter->driver_lock, flags); | 983 | spin_lock_irqsave(&adapter->driver_lock, flags); |
983 | __libertas_cleanup_and_insert_cmd(priv, cmdnode); | 984 | __libertas_cleanup_and_insert_cmd(priv, cmdnode); |
@@ -1174,8 +1175,8 @@ int libertas_prepare_and_send_command(wlan_private * priv, | |||
1174 | 1175 | ||
1175 | cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; | 1176 | cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; |
1176 | 1177 | ||
1177 | lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr =0x%x, command=0x%X\n", | 1178 | lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr=%p, command=0x%X\n", |
1178 | (u32) cmdptr, cmd_no); | 1179 | cmdptr, cmd_no); |
1179 | 1180 | ||
1180 | if (!cmdptr) { | 1181 | if (!cmdptr) { |
1181 | lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); | 1182 | lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); |
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index cdb012c7e9cf..c86454034b58 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c | |||
@@ -72,8 +72,6 @@ void libertas_mac_event_disconnected(wlan_private * priv) | |||
72 | adapter->secinfo.WPAenabled = 0; | 72 | adapter->secinfo.WPAenabled = 0; |
73 | adapter->secinfo.WPA2enabled = 0; | 73 | adapter->secinfo.WPA2enabled = 0; |
74 | adapter->wpa_ie_len = 0; | 74 | adapter->wpa_ie_len = 0; |
75 | adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE; | ||
76 | adapter->secinfo.Encryptionmode = CIPHER_NONE; | ||
77 | 75 | ||
78 | adapter->connect_status = libertas_disconnected; | 76 | adapter->connect_status = libertas_disconnected; |
79 | 77 | ||
@@ -811,7 +809,7 @@ int libertas_process_rx_command(wlan_private * priv) | |||
811 | if (result) { | 809 | if (result) { |
812 | lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n", | 810 | lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n", |
813 | resp->result); | 811 | resp->result); |
814 | if (adapter->inframode == wlan802_11ibss) { | 812 | if (adapter->mode == IW_MODE_ADHOC) { |
815 | /* | 813 | /* |
816 | * We should not re-try enter-ps command in | 814 | * We should not re-try enter-ps command in |
817 | * ad-hoc mode. It takes place in | 815 | * ad-hoc mode. It takes place in |
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c index 51dfd202f558..7d7bc5e86a56 100644 --- a/drivers/net/wireless/libertas/debugfs.c +++ b/drivers/net/wireless/libertas/debugfs.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "dev.h" | 7 | #include "dev.h" |
8 | #include "decl.h" | 8 | #include "decl.h" |
9 | #include "host.h" | 9 | #include "host.h" |
10 | #include "debugfs.h" | ||
10 | 11 | ||
11 | static struct dentry *libertas_dir = NULL; | 12 | static struct dentry *libertas_dir = NULL; |
12 | static char *szStates[] = { | 13 | static char *szStates[] = { |
@@ -276,7 +277,7 @@ static void libertas_parse_ssid(char *buf, size_t count, | |||
276 | if (!end) | 277 | if (!end) |
277 | end = buf + count - 1; | 278 | end = buf + count - 1; |
278 | 279 | ||
279 | size = min(IW_ESSID_MAX_SIZE, end - hold); | 280 | size = min((size_t)IW_ESSID_MAX_SIZE, (size_t) (end - hold)); |
280 | strncpy(scan_cfg->specificSSID, hold, size); | 281 | strncpy(scan_cfg->specificSSID, hold, size); |
281 | 282 | ||
282 | return; | 283 | return; |
@@ -1648,7 +1649,7 @@ struct libertas_debugfs_files { | |||
1648 | struct file_operations fops; | 1649 | struct file_operations fops; |
1649 | }; | 1650 | }; |
1650 | 1651 | ||
1651 | struct libertas_debugfs_files debugfs_files[] = { | 1652 | static struct libertas_debugfs_files debugfs_files[] = { |
1652 | { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), }, | 1653 | { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), }, |
1653 | { "getscantable", 0444, FOPS(libertas_getscantable, | 1654 | { "getscantable", 0444, FOPS(libertas_getscantable, |
1654 | write_file_dummy), }, | 1655 | write_file_dummy), }, |
@@ -1658,7 +1659,7 @@ struct libertas_debugfs_files debugfs_files[] = { | |||
1658 | { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), }, | 1659 | { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), }, |
1659 | }; | 1660 | }; |
1660 | 1661 | ||
1661 | struct libertas_debugfs_files debugfs_events_files[] = { | 1662 | static struct libertas_debugfs_files debugfs_events_files[] = { |
1662 | {"low_rssi", 0644, FOPS(libertas_lowrssi_read, | 1663 | {"low_rssi", 0644, FOPS(libertas_lowrssi_read, |
1663 | libertas_lowrssi_write), }, | 1664 | libertas_lowrssi_write), }, |
1664 | {"low_snr", 0644, FOPS(libertas_lowsnr_read, | 1665 | {"low_snr", 0644, FOPS(libertas_lowsnr_read, |
@@ -1673,7 +1674,7 @@ struct libertas_debugfs_files debugfs_events_files[] = { | |||
1673 | libertas_highsnr_write), }, | 1674 | libertas_highsnr_write), }, |
1674 | }; | 1675 | }; |
1675 | 1676 | ||
1676 | struct libertas_debugfs_files debugfs_regs_files[] = { | 1677 | static struct libertas_debugfs_files debugfs_regs_files[] = { |
1677 | {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), }, | 1678 | {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), }, |
1678 | {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), }, | 1679 | {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), }, |
1679 | {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), }, | 1680 | {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), }, |
@@ -1778,7 +1779,7 @@ void libertas_debugfs_remove_one(wlan_private *priv) | |||
1778 | struct debug_data { | 1779 | struct debug_data { |
1779 | char name[32]; | 1780 | char name[32]; |
1780 | u32 size; | 1781 | u32 size; |
1781 | u32 addr; | 1782 | size_t addr; |
1782 | }; | 1783 | }; |
1783 | 1784 | ||
1784 | /* To debug any member of wlan_adapter, simply add one line here. | 1785 | /* To debug any member of wlan_adapter, simply add one line here. |
@@ -1825,6 +1826,8 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf, | |||
1825 | val = *((u16 *) d[i].addr); | 1826 | val = *((u16 *) d[i].addr); |
1826 | else if (d[i].size == 4) | 1827 | else if (d[i].size == 4) |
1827 | val = *((u32 *) d[i].addr); | 1828 | val = *((u32 *) d[i].addr); |
1829 | else if (d[i].size == 8) | ||
1830 | val = *((u64 *) d[i].addr); | ||
1828 | 1831 | ||
1829 | pos += sprintf(p + pos, "%s=%d\n", d[i].name, val); | 1832 | pos += sprintf(p + pos, "%s=%d\n", d[i].name, val); |
1830 | } | 1833 | } |
@@ -1844,7 +1847,7 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf, | |||
1844 | * @param data data to write | 1847 | * @param data data to write |
1845 | * @return number of data | 1848 | * @return number of data |
1846 | */ | 1849 | */ |
1847 | static int wlan_debugfs_write(struct file *f, const char __user *buf, | 1850 | static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf, |
1848 | size_t cnt, loff_t *ppos) | 1851 | size_t cnt, loff_t *ppos) |
1849 | { | 1852 | { |
1850 | int r, i; | 1853 | int r, i; |
@@ -1886,12 +1889,14 @@ static int wlan_debugfs_write(struct file *f, const char __user *buf, | |||
1886 | *((u16 *) d[i].addr) = (u16) r; | 1889 | *((u16 *) d[i].addr) = (u16) r; |
1887 | else if (d[i].size == 4) | 1890 | else if (d[i].size == 4) |
1888 | *((u32 *) d[i].addr) = (u32) r; | 1891 | *((u32 *) d[i].addr) = (u32) r; |
1892 | else if (d[i].size == 8) | ||
1893 | *((u64 *) d[i].addr) = (u64) r; | ||
1889 | break; | 1894 | break; |
1890 | } while (1); | 1895 | } while (1); |
1891 | } | 1896 | } |
1892 | kfree(pdata); | 1897 | kfree(pdata); |
1893 | 1898 | ||
1894 | return cnt; | 1899 | return (ssize_t)cnt; |
1895 | } | 1900 | } |
1896 | 1901 | ||
1897 | static struct file_operations libertas_debug_fops = { | 1902 | static struct file_operations libertas_debug_fops = { |
@@ -1916,20 +1921,10 @@ void libertas_debug_init(wlan_private * priv, struct net_device *dev) | |||
1916 | return; | 1921 | return; |
1917 | 1922 | ||
1918 | for (i = 0; i < num_of_items; i++) | 1923 | for (i = 0; i < num_of_items; i++) |
1919 | items[i].addr += (u32) priv->adapter; | 1924 | items[i].addr += (size_t) priv->adapter; |
1920 | 1925 | ||
1921 | priv->debugfs_debug = debugfs_create_file("debug", 0644, | 1926 | priv->debugfs_debug = debugfs_create_file("debug", 0644, |
1922 | priv->debugfs_dir, &items[0], | 1927 | priv->debugfs_dir, &items[0], |
1923 | &libertas_debug_fops); | 1928 | &libertas_debug_fops); |
1924 | } | 1929 | } |
1925 | 1930 | ||
1926 | /** | ||
1927 | * @brief remove proc file | ||
1928 | * | ||
1929 | * @param priv pointer wlan_private | ||
1930 | * @return N/A | ||
1931 | */ | ||
1932 | void libertas_debug_remove(wlan_private * priv) | ||
1933 | { | ||
1934 | debugfs_remove(priv->debugfs_debug); | ||
1935 | } | ||
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h index fb1478c1b87d..80dd9ea19c8e 100644 --- a/drivers/net/wireless/libertas/defs.h +++ b/drivers/net/wireless/libertas/defs.h | |||
@@ -9,6 +9,11 @@ | |||
9 | 9 | ||
10 | extern unsigned int libertas_debug; | 10 | extern unsigned int libertas_debug; |
11 | 11 | ||
12 | #ifdef CONFIG_LIBERTAS_DEBUG | ||
13 | #define DEBUG | ||
14 | #define PROC_DEBUG | ||
15 | #endif | ||
16 | |||
12 | #define DRV_NAME "usb8xxx" | 17 | #define DRV_NAME "usb8xxx" |
13 | 18 | ||
14 | #define lbs_pr_info(format, args...) \ | 19 | #define lbs_pr_info(format, args...) \ |
@@ -223,31 +228,6 @@ enum SNRNF_DATA { | |||
223 | MAX_TYPE_AVG | 228 | MAX_TYPE_AVG |
224 | }; | 229 | }; |
225 | 230 | ||
226 | /** WLAN_802_11_AUTH_ALG*/ | ||
227 | enum WLAN_802_11_AUTH_ALG { | ||
228 | AUTH_ALG_OPEN_SYSTEM = 1, | ||
229 | AUTH_ALG_SHARED_KEY = 2, | ||
230 | AUTH_ALG_NETWORK_EAP = 8, | ||
231 | }; | ||
232 | |||
233 | /** WLAN_802_1X_AUTH_ALG */ | ||
234 | enum WLAN_802_1X_AUTH_ALG { | ||
235 | WLAN_1X_AUTH_ALG_NONE = 1, | ||
236 | WLAN_1X_AUTH_ALG_LEAP = 2, | ||
237 | WLAN_1X_AUTH_ALG_TLS = 4, | ||
238 | WLAN_1X_AUTH_ALG_TTLS = 8, | ||
239 | WLAN_1X_AUTH_ALG_MD5 = 16, | ||
240 | }; | ||
241 | |||
242 | /** WLAN_802_11_ENCRYPTION_MODE */ | ||
243 | enum WLAN_802_11_ENCRYPTION_MODE { | ||
244 | CIPHER_NONE, | ||
245 | CIPHER_WEP40, | ||
246 | CIPHER_TKIP, | ||
247 | CIPHER_CCMP, | ||
248 | CIPHER_WEP104, | ||
249 | }; | ||
250 | |||
251 | /** WLAN_802_11_POWER_MODE */ | 231 | /** WLAN_802_11_POWER_MODE */ |
252 | enum WLAN_802_11_POWER_MODE { | 232 | enum WLAN_802_11_POWER_MODE { |
253 | wlan802_11powermodecam, | 233 | wlan802_11powermodecam, |
@@ -292,28 +272,6 @@ enum mv_ms_type { | |||
292 | MVMS_EVENT | 272 | MVMS_EVENT |
293 | }; | 273 | }; |
294 | 274 | ||
295 | /** WLAN_802_11_NETWORK_INFRASTRUCTURE */ | ||
296 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE { | ||
297 | wlan802_11ibss, | ||
298 | wlan802_11infrastructure, | ||
299 | wlan802_11autounknown, | ||
300 | /*defined as upper bound */ | ||
301 | wlan802_11infrastructuremax | ||
302 | }; | ||
303 | |||
304 | /** WLAN_802_11_AUTHENTICATION_MODE */ | ||
305 | enum WLAN_802_11_AUTHENTICATION_MODE { | ||
306 | wlan802_11authmodeopen = 0x00, | ||
307 | wlan802_11authmodeshared = 0x01, | ||
308 | wlan802_11authmodenetworkEAP = 0x80, | ||
309 | }; | ||
310 | |||
311 | /** WLAN_802_11_WEP_STATUS */ | ||
312 | enum WLAN_802_11_WEP_STATUS { | ||
313 | wlan802_11WEPenabled, | ||
314 | wlan802_11WEPdisabled, | ||
315 | }; | ||
316 | |||
317 | /** SNMP_MIB_INDEX_e */ | 275 | /** SNMP_MIB_INDEX_e */ |
318 | enum SNMP_MIB_INDEX_e { | 276 | enum SNMP_MIB_INDEX_e { |
319 | desired_bsstype_i = 0, | 277 | desired_bsstype_i = 0, |
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h index b1f876f9693b..e8b9020f9bd6 100644 --- a/drivers/net/wireless/libertas/dev.h +++ b/drivers/net/wireless/libertas/dev.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/wireless.h> | 10 | #include <linux/wireless.h> |
11 | #include <linux/ethtool.h> | 11 | #include <linux/ethtool.h> |
12 | #include <linux/debugfs.h> | 12 | #include <linux/debugfs.h> |
13 | #include <net/ieee80211.h> | ||
13 | 14 | ||
14 | #include "defs.h" | 15 | #include "defs.h" |
15 | #include "scan.h" | 16 | #include "scan.h" |
@@ -56,10 +57,8 @@ struct region_channel { | |||
56 | struct wlan_802_11_security { | 57 | struct wlan_802_11_security { |
57 | u8 WPAenabled; | 58 | u8 WPAenabled; |
58 | u8 WPA2enabled; | 59 | u8 WPA2enabled; |
59 | enum WLAN_802_11_WEP_STATUS WEPstatus; | 60 | u8 wep_enabled; |
60 | enum WLAN_802_11_AUTHENTICATION_MODE authmode; | 61 | u8 auth_mode; |
61 | enum WLAN_802_1X_AUTH_ALG auth1xalg; | ||
62 | enum WLAN_802_11_ENCRYPTION_MODE Encryptionmode; | ||
63 | }; | 62 | }; |
64 | 63 | ||
65 | /** Current Basic Service Set State Structure */ | 64 | /** Current Basic Service Set State Structure */ |
@@ -184,7 +183,7 @@ struct assoc_request { | |||
184 | 183 | ||
185 | struct WLAN_802_11_SSID ssid; | 184 | struct WLAN_802_11_SSID ssid; |
186 | u8 channel; | 185 | u8 channel; |
187 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode; | 186 | u8 mode; |
188 | u8 bssid[ETH_ALEN]; | 187 | u8 bssid[ETH_ALEN]; |
189 | 188 | ||
190 | /** WEP keys */ | 189 | /** WEP keys */ |
@@ -198,7 +197,6 @@ struct assoc_request { | |||
198 | struct wlan_802_11_security secinfo; | 197 | struct wlan_802_11_security secinfo; |
199 | 198 | ||
200 | /** WPA Information Elements*/ | 199 | /** WPA Information Elements*/ |
201 | #define MAX_WPA_IE_LEN 64 | ||
202 | u8 wpa_ie[MAX_WPA_IE_LEN]; | 200 | u8 wpa_ie[MAX_WPA_IE_LEN]; |
203 | u8 wpa_ie_len; | 201 | u8 wpa_ie_len; |
204 | }; | 202 | }; |
@@ -254,7 +252,8 @@ struct _wlan_adapter { | |||
254 | /** current ssid/bssid related parameters*/ | 252 | /** current ssid/bssid related parameters*/ |
255 | struct current_bss_params curbssparams; | 253 | struct current_bss_params curbssparams; |
256 | 254 | ||
257 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; | 255 | /* IW_MODE_* */ |
256 | u8 mode; | ||
258 | 257 | ||
259 | struct bss_descriptor *pattemptedbssdesc; | 258 | struct bss_descriptor *pattemptedbssdesc; |
260 | 259 | ||
@@ -339,7 +338,6 @@ struct _wlan_adapter { | |||
339 | struct WLAN_802_11_KEY wpa_unicast_key; | 338 | struct WLAN_802_11_KEY wpa_unicast_key; |
340 | 339 | ||
341 | /** WPA Information Elements*/ | 340 | /** WPA Information Elements*/ |
342 | #define MAX_WPA_IE_LEN 64 | ||
343 | u8 wpa_ie[MAX_WPA_IE_LEN]; | 341 | u8 wpa_ie[MAX_WPA_IE_LEN]; |
344 | u8 wpa_ie_len; | 342 | u8 wpa_ie_len; |
345 | 343 | ||
diff --git a/drivers/net/wireless/libertas/fw.c b/drivers/net/wireless/libertas/fw.c index b194a4570791..441123c85e62 100644 --- a/drivers/net/wireless/libertas/fw.c +++ b/drivers/net/wireless/libertas/fw.c | |||
@@ -194,16 +194,13 @@ static void wlan_init_adapter(wlan_private * priv) | |||
194 | adapter->scanmode = cmd_bss_type_any; | 194 | adapter->scanmode = cmd_bss_type_any; |
195 | 195 | ||
196 | /* 802.11 specific */ | 196 | /* 802.11 specific */ |
197 | adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; | 197 | adapter->secinfo.wep_enabled = 0; |
198 | for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]); | 198 | for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]); |
199 | i++) | 199 | i++) |
200 | memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY)); | 200 | memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY)); |
201 | adapter->wep_tx_keyidx = 0; | 201 | adapter->wep_tx_keyidx = 0; |
202 | adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; | 202 | adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
203 | adapter->secinfo.authmode = wlan802_11authmodeopen; | 203 | adapter->mode = IW_MODE_INFRA; |
204 | adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE; | ||
205 | adapter->secinfo.Encryptionmode = CIPHER_NONE; | ||
206 | adapter->inframode = wlan802_11infrastructure; | ||
207 | 204 | ||
208 | adapter->assoc_req = NULL; | 205 | adapter->assoc_req = NULL; |
209 | 206 | ||
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index 695fb6a66ffe..ae6f72a6cdf3 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c | |||
@@ -388,7 +388,7 @@ static int __if_usb_submit_rx_urb(wlan_private * priv, | |||
388 | usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, | 388 | usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, |
389 | usb_rcvbulkpipe(cardp->udev, | 389 | usb_rcvbulkpipe(cardp->udev, |
390 | cardp->bulk_in_endpointAddr), | 390 | cardp->bulk_in_endpointAddr), |
391 | skb->tail + IPFIELD_ALIGN_OFFSET, | 391 | (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET), |
392 | MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, | 392 | MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, |
393 | rinfo); | 393 | rinfo); |
394 | 394 | ||
@@ -626,6 +626,7 @@ static void if_usb_receive(struct urb *urb) | |||
626 | cardp->usb_event_cause); | 626 | cardp->usb_event_cause); |
627 | if (cardp->usb_event_cause & 0xffff0000) { | 627 | if (cardp->usb_event_cause & 0xffff0000) { |
628 | libertas_send_tx_feedback(priv); | 628 | libertas_send_tx_feedback(priv); |
629 | spin_unlock(&priv->adapter->driver_lock); | ||
629 | break; | 630 | break; |
630 | } | 631 | } |
631 | cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3; | 632 | cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3; |
@@ -775,7 +776,6 @@ restart: | |||
775 | return -1; | 776 | return -1; |
776 | } | 777 | } |
777 | 778 | ||
778 | #ifdef SUPPORT_BOOT_COMMAND | ||
779 | cardp->bootcmdresp = 0; | 779 | cardp->bootcmdresp = 0; |
780 | do { | 780 | do { |
781 | int j = 0; | 781 | int j = 0; |
@@ -796,7 +796,6 @@ restart: | |||
796 | } | 796 | } |
797 | return -1; | 797 | return -1; |
798 | } | 798 | } |
799 | #endif | ||
800 | 799 | ||
801 | i = 0; | 800 | i = 0; |
802 | priv->adapter->fw_ready = 0; | 801 | priv->adapter->fw_ready = 0; |
diff --git a/drivers/net/wireless/libertas/if_usb.h b/drivers/net/wireless/libertas/if_usb.h index 785116720bc6..170dfe6809f5 100644 --- a/drivers/net/wireless/libertas/if_usb.h +++ b/drivers/net/wireless/libertas/if_usb.h | |||
@@ -12,7 +12,6 @@ | |||
12 | #define USB8388_VID_2 0x05a3 | 12 | #define USB8388_VID_2 0x05a3 |
13 | #define USB8388_PID_2 0x8388 | 13 | #define USB8388_PID_2 0x8388 |
14 | 14 | ||
15 | #ifdef SUPPORT_BOOT_COMMAND | ||
16 | #define BOOT_CMD_FW_BY_USB 0x01 | 15 | #define BOOT_CMD_FW_BY_USB 0x01 |
17 | #define BOOT_CMD_FW_IN_EEPROM 0x02 | 16 | #define BOOT_CMD_FW_IN_EEPROM 0x02 |
18 | #define BOOT_CMD_UPDATE_BOOT2 0x03 | 17 | #define BOOT_CMD_UPDATE_BOOT2 0x03 |
@@ -36,7 +35,6 @@ struct bootcmdrespStr | |||
36 | u8 u8result; | 35 | u8 u8result; |
37 | u8 au8dumy[2]; | 36 | u8 au8dumy[2]; |
38 | }; | 37 | }; |
39 | #endif /* SUPPORT_BOOT_COMMAND */ | ||
40 | 38 | ||
41 | /* read callback private data */ | 39 | /* read callback private data */ |
42 | struct read_cb_info { | 40 | struct read_cb_info { |
diff --git a/drivers/net/wireless/libertas/ioctl.c b/drivers/net/wireless/libertas/ioctl.c index 82b39642423a..a8f76c358992 100644 --- a/drivers/net/wireless/libertas/ioctl.c +++ b/drivers/net/wireless/libertas/ioctl.c | |||
@@ -27,95 +27,6 @@ | |||
27 | 27 | ||
28 | #define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) | 28 | #define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) |
29 | 29 | ||
30 | static int setrxantenna(wlan_private * priv, int mode) | ||
31 | { | ||
32 | int ret = 0; | ||
33 | wlan_adapter *adapter = priv->adapter; | ||
34 | |||
35 | if (mode != RF_ANTENNA_1 && mode != RF_ANTENNA_2 | ||
36 | && mode != RF_ANTENNA_AUTO) { | ||
37 | return -EINVAL; | ||
38 | } | ||
39 | |||
40 | adapter->rxantennamode = mode; | ||
41 | |||
42 | lbs_pr_debug(1, "SET RX Antenna mode to 0x%04x\n", adapter->rxantennamode); | ||
43 | |||
44 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
45 | cmd_act_set_rx, | ||
46 | cmd_option_waitforrsp, 0, | ||
47 | &adapter->rxantennamode); | ||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | static int settxantenna(wlan_private * priv, int mode) | ||
52 | { | ||
53 | int ret = 0; | ||
54 | wlan_adapter *adapter = priv->adapter; | ||
55 | |||
56 | if ((mode != RF_ANTENNA_1) && (mode != RF_ANTENNA_2) | ||
57 | && (mode != RF_ANTENNA_AUTO)) { | ||
58 | return -EINVAL; | ||
59 | } | ||
60 | |||
61 | adapter->txantennamode = mode; | ||
62 | |||
63 | lbs_pr_debug(1, "SET TX Antenna mode to 0x%04x\n", adapter->txantennamode); | ||
64 | |||
65 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
66 | cmd_act_set_tx, | ||
67 | cmd_option_waitforrsp, 0, | ||
68 | &adapter->txantennamode); | ||
69 | |||
70 | return ret; | ||
71 | } | ||
72 | |||
73 | static int getrxantenna(wlan_private * priv, char *buf) | ||
74 | { | ||
75 | int ret = 0; | ||
76 | wlan_adapter *adapter = priv->adapter; | ||
77 | |||
78 | // clear it, so we will know if the value | ||
79 | // returned below is correct or not. | ||
80 | adapter->rxantennamode = 0; | ||
81 | |||
82 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
83 | cmd_act_get_rx, | ||
84 | cmd_option_waitforrsp, 0, NULL); | ||
85 | |||
86 | if (ret) { | ||
87 | LEAVE(); | ||
88 | return ret; | ||
89 | } | ||
90 | |||
91 | lbs_pr_debug(1, "Get Rx Antenna mode:0x%04x\n", adapter->rxantennamode); | ||
92 | |||
93 | return sprintf(buf, "0x%04x", adapter->rxantennamode) + 1; | ||
94 | } | ||
95 | |||
96 | static int gettxantenna(wlan_private * priv, char *buf) | ||
97 | { | ||
98 | int ret = 0; | ||
99 | wlan_adapter *adapter = priv->adapter; | ||
100 | |||
101 | // clear it, so we will know if the value | ||
102 | // returned below is correct or not. | ||
103 | adapter->txantennamode = 0; | ||
104 | |||
105 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
106 | cmd_act_get_tx, | ||
107 | cmd_option_waitforrsp, 0, NULL); | ||
108 | |||
109 | if (ret) { | ||
110 | LEAVE(); | ||
111 | return ret; | ||
112 | } | ||
113 | |||
114 | lbs_pr_debug(1, "Get Tx Antenna mode:0x%04x\n", adapter->txantennamode); | ||
115 | |||
116 | return sprintf(buf, "0x%04x", adapter->txantennamode) + 1; | ||
117 | } | ||
118 | |||
119 | static int wlan_set_region(wlan_private * priv, u16 region_code) | 30 | static int wlan_set_region(wlan_private * priv, u16 region_code) |
120 | { | 31 | { |
121 | int i; | 32 | int i; |
@@ -144,998 +55,6 @@ static int wlan_set_region(wlan_private * priv, u16 region_code) | |||
144 | return 0; | 55 | return 0; |
145 | } | 56 | } |
146 | 57 | ||
147 | /** | ||
148 | * @brief Get/Set Firmware wakeup method | ||
149 | * | ||
150 | * @param priv A pointer to wlan_private structure | ||
151 | * @param wrq A pointer to user data | ||
152 | * @return 0--success, otherwise fail | ||
153 | */ | ||
154 | static int wlan_txcontrol(wlan_private * priv, struct iwreq *wrq) | ||
155 | { | ||
156 | wlan_adapter *adapter = priv->adapter; | ||
157 | int data; | ||
158 | ENTER(); | ||
159 | |||
160 | if ((int)wrq->u.data.length == 0) { | ||
161 | if (copy_to_user | ||
162 | (wrq->u.data.pointer, &adapter->pkttxctrl, sizeof(u32))) { | ||
163 | lbs_pr_alert("copy_to_user failed!\n"); | ||
164 | return -EFAULT; | ||
165 | } | ||
166 | } else { | ||
167 | if ((int)wrq->u.data.length > 1) { | ||
168 | lbs_pr_alert("ioctl too many args!\n"); | ||
169 | return -EFAULT; | ||
170 | } | ||
171 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
172 | lbs_pr_alert("Copy from user failed\n"); | ||
173 | return -EFAULT; | ||
174 | } | ||
175 | |||
176 | adapter->pkttxctrl = (u32) data; | ||
177 | } | ||
178 | |||
179 | wrq->u.data.length = 1; | ||
180 | |||
181 | LEAVE(); | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * @brief Get/Set NULL Package generation interval | ||
187 | * | ||
188 | * @param priv A pointer to wlan_private structure | ||
189 | * @param wrq A pointer to user data | ||
190 | * @return 0--success, otherwise fail | ||
191 | */ | ||
192 | static int wlan_null_pkt_interval(wlan_private * priv, struct iwreq *wrq) | ||
193 | { | ||
194 | wlan_adapter *adapter = priv->adapter; | ||
195 | int data; | ||
196 | ENTER(); | ||
197 | |||
198 | if ((int)wrq->u.data.length == 0) { | ||
199 | data = adapter->nullpktinterval; | ||
200 | |||
201 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) { | ||
202 | lbs_pr_alert( "copy_to_user failed!\n"); | ||
203 | return -EFAULT; | ||
204 | } | ||
205 | } else { | ||
206 | if ((int)wrq->u.data.length > 1) { | ||
207 | lbs_pr_alert( "ioctl too many args!\n"); | ||
208 | return -EFAULT; | ||
209 | } | ||
210 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
211 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
212 | return -EFAULT; | ||
213 | } | ||
214 | |||
215 | adapter->nullpktinterval = data; | ||
216 | } | ||
217 | |||
218 | wrq->u.data.length = 1; | ||
219 | |||
220 | LEAVE(); | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int wlan_get_rxinfo(wlan_private * priv, struct iwreq *wrq) | ||
225 | { | ||
226 | wlan_adapter *adapter = priv->adapter; | ||
227 | int data[2]; | ||
228 | ENTER(); | ||
229 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
230 | data[1] = adapter->rxpd_rate; | ||
231 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) { | ||
232 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
233 | return -EFAULT; | ||
234 | } | ||
235 | wrq->u.data.length = 2; | ||
236 | LEAVE(); | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int wlan_get_snr(wlan_private * priv, struct iwreq *wrq) | ||
241 | { | ||
242 | int ret = 0; | ||
243 | wlan_adapter *adapter = priv->adapter; | ||
244 | int data[4]; | ||
245 | |||
246 | ENTER(); | ||
247 | memset(data, 0, sizeof(data)); | ||
248 | if (wrq->u.data.length) { | ||
249 | if (copy_from_user(data, wrq->u.data.pointer, | ||
250 | min_t(size_t, wrq->u.data.length, 4) * sizeof(int))) | ||
251 | return -EFAULT; | ||
252 | } | ||
253 | if ((wrq->u.data.length == 0) || (data[0] == 0) || (data[0] == 1)) { | ||
254 | if (adapter->connect_status == libertas_connected) { | ||
255 | ret = libertas_prepare_and_send_command(priv, | ||
256 | cmd_802_11_rssi, | ||
257 | 0, | ||
258 | cmd_option_waitforrsp, | ||
259 | 0, NULL); | ||
260 | |||
261 | if (ret) { | ||
262 | LEAVE(); | ||
263 | return ret; | ||
264 | } | ||
265 | } | ||
266 | } | ||
267 | |||
268 | if (wrq->u.data.length == 0) { | ||
269 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG]; | ||
270 | data[1] = adapter->SNR[TYPE_BEACON][TYPE_AVG]; | ||
271 | data[2] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
272 | data[3] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
273 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 4)) | ||
274 | return -EFAULT; | ||
275 | wrq->u.data.length = 4; | ||
276 | } else if (data[0] == 0) { | ||
277 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG]; | ||
278 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
279 | return -EFAULT; | ||
280 | wrq->u.data.length = 1; | ||
281 | } else if (data[0] == 1) { | ||
282 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_AVG]; | ||
283 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
284 | return -EFAULT; | ||
285 | wrq->u.data.length = 1; | ||
286 | } else if (data[0] == 2) { | ||
287 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
288 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
289 | return -EFAULT; | ||
290 | wrq->u.data.length = 1; | ||
291 | } else if (data[0] == 3) { | ||
292 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
293 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
294 | return -EFAULT; | ||
295 | wrq->u.data.length = 1; | ||
296 | } else | ||
297 | return -ENOTSUPP; | ||
298 | |||
299 | LEAVE(); | ||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | static int wlan_beacon_interval(wlan_private * priv, struct iwreq *wrq) | ||
304 | { | ||
305 | int data; | ||
306 | wlan_adapter *adapter = priv->adapter; | ||
307 | |||
308 | if (wrq->u.data.length > 0) { | ||
309 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) | ||
310 | return -EFAULT; | ||
311 | |||
312 | lbs_pr_debug(1, "WLAN SET BEACON INTERVAL: %d\n", data); | ||
313 | if ((data > MRVDRV_MAX_BEACON_INTERVAL) | ||
314 | || (data < MRVDRV_MIN_BEACON_INTERVAL)) | ||
315 | return -ENOTSUPP; | ||
316 | adapter->beaconperiod = data; | ||
317 | } | ||
318 | data = adapter->beaconperiod; | ||
319 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) | ||
320 | return -EFAULT; | ||
321 | |||
322 | wrq->u.data.length = 1; | ||
323 | |||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static int wlan_get_rssi(wlan_private * priv, struct iwreq *wrq) | ||
328 | { | ||
329 | int ret = 0; | ||
330 | wlan_adapter *adapter = priv->adapter; | ||
331 | int temp; | ||
332 | int data = 0; | ||
333 | int *val; | ||
334 | |||
335 | ENTER(); | ||
336 | data = SUBCMD_DATA(wrq); | ||
337 | if ((data == 0) || (data == 1)) { | ||
338 | ret = libertas_prepare_and_send_command(priv, | ||
339 | cmd_802_11_rssi, | ||
340 | 0, cmd_option_waitforrsp, | ||
341 | 0, NULL); | ||
342 | if (ret) { | ||
343 | LEAVE(); | ||
344 | return ret; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | switch (data) { | ||
349 | case 0: | ||
350 | |||
351 | temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG], | ||
352 | adapter->NF[TYPE_BEACON][TYPE_NOAVG]); | ||
353 | break; | ||
354 | case 1: | ||
355 | temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG], | ||
356 | adapter->NF[TYPE_BEACON][TYPE_AVG]); | ||
357 | break; | ||
358 | case 2: | ||
359 | temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_NOAVG], | ||
360 | adapter->NF[TYPE_RXPD][TYPE_NOAVG]); | ||
361 | break; | ||
362 | case 3: | ||
363 | temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, | ||
364 | adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); | ||
365 | break; | ||
366 | default: | ||
367 | return -ENOTSUPP; | ||
368 | } | ||
369 | val = (int *)wrq->u.name; | ||
370 | *val = temp; | ||
371 | |||
372 | LEAVE(); | ||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | static int wlan_get_nf(wlan_private * priv, struct iwreq *wrq) | ||
377 | { | ||
378 | int ret = 0; | ||
379 | wlan_adapter *adapter = priv->adapter; | ||
380 | int temp; | ||
381 | int data = 0; | ||
382 | int *val; | ||
383 | |||
384 | data = SUBCMD_DATA(wrq); | ||
385 | if ((data == 0) || (data == 1)) { | ||
386 | ret = libertas_prepare_and_send_command(priv, | ||
387 | cmd_802_11_rssi, | ||
388 | 0, cmd_option_waitforrsp, | ||
389 | 0, NULL); | ||
390 | |||
391 | if (ret) { | ||
392 | LEAVE(); | ||
393 | return ret; | ||
394 | } | ||
395 | } | ||
396 | |||
397 | switch (data) { | ||
398 | case 0: | ||
399 | temp = adapter->NF[TYPE_BEACON][TYPE_NOAVG]; | ||
400 | break; | ||
401 | case 1: | ||
402 | temp = adapter->NF[TYPE_BEACON][TYPE_AVG]; | ||
403 | break; | ||
404 | case 2: | ||
405 | temp = adapter->NF[TYPE_RXPD][TYPE_NOAVG]; | ||
406 | break; | ||
407 | case 3: | ||
408 | temp = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
409 | break; | ||
410 | default: | ||
411 | return -ENOTSUPP; | ||
412 | } | ||
413 | |||
414 | temp = CAL_NF(temp); | ||
415 | |||
416 | lbs_pr_debug(1, "%s: temp = %d\n", __FUNCTION__, temp); | ||
417 | val = (int *)wrq->u.name; | ||
418 | *val = temp; | ||
419 | return 0; | ||
420 | } | ||
421 | |||
422 | static int wlan_get_txrate_ioctl(wlan_private * priv, struct ifreq *req) | ||
423 | { | ||
424 | wlan_adapter *adapter = priv->adapter; | ||
425 | int *pdata; | ||
426 | struct iwreq *wrq = (struct iwreq *)req; | ||
427 | int ret = 0; | ||
428 | adapter->txrate = 0; | ||
429 | lbs_pr_debug(1, "wlan_get_txrate_ioctl\n"); | ||
430 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_tx_rate_query, | ||
431 | cmd_act_get, cmd_option_waitforrsp, | ||
432 | 0, NULL); | ||
433 | if (ret) | ||
434 | return ret; | ||
435 | |||
436 | pdata = (int *)wrq->u.name; | ||
437 | *pdata = (int)adapter->txrate; | ||
438 | return 0; | ||
439 | } | ||
440 | |||
441 | static int wlan_get_adhoc_status_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
442 | { | ||
443 | char status[64]; | ||
444 | wlan_adapter *adapter = priv->adapter; | ||
445 | |||
446 | memset(status, 0, sizeof(status)); | ||
447 | |||
448 | switch (adapter->inframode) { | ||
449 | case wlan802_11ibss: | ||
450 | if (adapter->connect_status == libertas_connected) { | ||
451 | if (adapter->adhoccreate) | ||
452 | memcpy(&status, "AdhocStarted", sizeof(status)); | ||
453 | else | ||
454 | memcpy(&status, "AdhocJoined", sizeof(status)); | ||
455 | } else { | ||
456 | memcpy(&status, "AdhocIdle", sizeof(status)); | ||
457 | } | ||
458 | break; | ||
459 | case wlan802_11infrastructure: | ||
460 | memcpy(&status, "Inframode", sizeof(status)); | ||
461 | break; | ||
462 | default: | ||
463 | memcpy(&status, "AutoUnknownmode", sizeof(status)); | ||
464 | break; | ||
465 | } | ||
466 | |||
467 | lbs_pr_debug(1, "status = %s\n", status); | ||
468 | wrq->u.data.length = strlen(status) + 1; | ||
469 | |||
470 | if (wrq->u.data.pointer) { | ||
471 | if (copy_to_user(wrq->u.data.pointer, | ||
472 | &status, wrq->u.data.length)) | ||
473 | return -EFAULT; | ||
474 | } | ||
475 | |||
476 | LEAVE(); | ||
477 | return 0; | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * @brief Set/Get WPA IE | ||
482 | * @param priv A pointer to wlan_private structure | ||
483 | * @param req A pointer to ifreq structure | ||
484 | * @return 0 --success, otherwise fail | ||
485 | */ | ||
486 | static int wlan_setwpaie_ioctl(wlan_private * priv, struct ifreq *req) | ||
487 | { | ||
488 | struct iwreq *wrq = (struct iwreq *)req; | ||
489 | wlan_adapter *adapter = priv->adapter; | ||
490 | int ret = 0; | ||
491 | |||
492 | ENTER(); | ||
493 | |||
494 | if (wrq->u.data.length) { | ||
495 | if (wrq->u.data.length > sizeof(adapter->wpa_ie)) { | ||
496 | lbs_pr_debug(1, "failed to copy WPA IE, too big \n"); | ||
497 | return -EFAULT; | ||
498 | } | ||
499 | if (copy_from_user(adapter->wpa_ie, wrq->u.data.pointer, | ||
500 | wrq->u.data.length)) { | ||
501 | lbs_pr_debug(1, "failed to copy WPA IE \n"); | ||
502 | return -EFAULT; | ||
503 | } | ||
504 | adapter->wpa_ie_len = wrq->u.data.length; | ||
505 | lbs_pr_debug(1, "Set wpa_ie_len=%d IE=%#x\n", adapter->wpa_ie_len, | ||
506 | adapter->wpa_ie[0]); | ||
507 | lbs_dbg_hex("wpa_ie", adapter->wpa_ie, adapter->wpa_ie_len); | ||
508 | if (adapter->wpa_ie[0] == WPA_IE) | ||
509 | adapter->secinfo.WPAenabled = 1; | ||
510 | else if (adapter->wpa_ie[0] == WPA2_IE) | ||
511 | adapter->secinfo.WPA2enabled = 1; | ||
512 | else { | ||
513 | adapter->secinfo.WPAenabled = 0; | ||
514 | adapter->secinfo.WPA2enabled = 0; | ||
515 | } | ||
516 | } else { | ||
517 | memset(adapter->wpa_ie, 0, sizeof(adapter->wpa_ie)); | ||
518 | adapter->wpa_ie_len = wrq->u.data.length; | ||
519 | lbs_pr_debug(1, "Reset wpa_ie_len=%d IE=%#x\n", | ||
520 | adapter->wpa_ie_len, adapter->wpa_ie[0]); | ||
521 | adapter->secinfo.WPAenabled = 0; | ||
522 | adapter->secinfo.WPA2enabled = 0; | ||
523 | } | ||
524 | |||
525 | // enable/disable RSN in firmware if WPA is enabled/disabled | ||
526 | // depending on variable adapter->secinfo.WPAenabled is set or not | ||
527 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_enable_rsn, | ||
528 | cmd_act_set, cmd_option_waitforrsp, | ||
529 | 0, NULL); | ||
530 | |||
531 | LEAVE(); | ||
532 | return ret; | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * @brief Set Auto prescan | ||
537 | * @param priv A pointer to wlan_private structure | ||
538 | * @param wrq A pointer to iwreq structure | ||
539 | * @return 0 --success, otherwise fail | ||
540 | */ | ||
541 | static int wlan_subcmd_setprescan_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
542 | { | ||
543 | int data; | ||
544 | wlan_adapter *adapter = priv->adapter; | ||
545 | int *val; | ||
546 | |||
547 | data = SUBCMD_DATA(wrq); | ||
548 | lbs_pr_debug(1, "WLAN_SUBCMD_SET_PRESCAN %d\n", data); | ||
549 | adapter->prescan = data; | ||
550 | |||
551 | val = (int *)wrq->u.name; | ||
552 | *val = data; | ||
553 | return 0; | ||
554 | } | ||
555 | |||
556 | static int wlan_set_multiple_dtim_ioctl(wlan_private * priv, struct ifreq *req) | ||
557 | { | ||
558 | struct iwreq *wrq = (struct iwreq *)req; | ||
559 | u32 mdtim; | ||
560 | int idata; | ||
561 | int ret = -EINVAL; | ||
562 | |||
563 | ENTER(); | ||
564 | |||
565 | idata = SUBCMD_DATA(wrq); | ||
566 | mdtim = (u32) idata; | ||
567 | if (((mdtim >= MRVDRV_MIN_MULTIPLE_DTIM) | ||
568 | && (mdtim <= MRVDRV_MAX_MULTIPLE_DTIM)) | ||
569 | || (mdtim == MRVDRV_IGNORE_MULTIPLE_DTIM)) { | ||
570 | priv->adapter->multipledtim = mdtim; | ||
571 | ret = 0; | ||
572 | } | ||
573 | if (ret) | ||
574 | lbs_pr_debug(1, "Invalid parameter, multipledtim not changed.\n"); | ||
575 | |||
576 | LEAVE(); | ||
577 | return ret; | ||
578 | } | ||
579 | |||
580 | /** | ||
581 | * @brief Set authentication mode | ||
582 | * @param priv A pointer to wlan_private structure | ||
583 | * @param req A pointer to ifreq structure | ||
584 | * @return 0 --success, otherwise fail | ||
585 | */ | ||
586 | static int wlan_setauthalg_ioctl(wlan_private * priv, struct ifreq *req) | ||
587 | { | ||
588 | int alg; | ||
589 | struct iwreq *wrq = (struct iwreq *)req; | ||
590 | wlan_adapter *adapter = priv->adapter; | ||
591 | |||
592 | if (wrq->u.data.flags == 0) { | ||
593 | //from iwpriv subcmd | ||
594 | alg = SUBCMD_DATA(wrq); | ||
595 | } else { | ||
596 | //from wpa_supplicant subcmd | ||
597 | if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(alg))) { | ||
598 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
599 | return -EFAULT; | ||
600 | } | ||
601 | } | ||
602 | |||
603 | lbs_pr_debug(1, "auth alg is %#x\n", alg); | ||
604 | |||
605 | switch (alg) { | ||
606 | case AUTH_ALG_SHARED_KEY: | ||
607 | adapter->secinfo.authmode = wlan802_11authmodeshared; | ||
608 | break; | ||
609 | case AUTH_ALG_NETWORK_EAP: | ||
610 | adapter->secinfo.authmode = | ||
611 | wlan802_11authmodenetworkEAP; | ||
612 | break; | ||
613 | case AUTH_ALG_OPEN_SYSTEM: | ||
614 | default: | ||
615 | adapter->secinfo.authmode = wlan802_11authmodeopen; | ||
616 | break; | ||
617 | } | ||
618 | return 0; | ||
619 | } | ||
620 | |||
621 | /** | ||
622 | * @brief Set 802.1x authentication mode | ||
623 | * @param priv A pointer to wlan_private structure | ||
624 | * @param req A pointer to ifreq structure | ||
625 | * @return 0 --success, otherwise fail | ||
626 | */ | ||
627 | static int wlan_set8021xauthalg_ioctl(wlan_private * priv, struct ifreq *req) | ||
628 | { | ||
629 | int alg; | ||
630 | struct iwreq *wrq = (struct iwreq *)req; | ||
631 | |||
632 | if (wrq->u.data.flags == 0) { | ||
633 | //from iwpriv subcmd | ||
634 | alg = SUBCMD_DATA(wrq); | ||
635 | } else { | ||
636 | //from wpa_supplicant subcmd | ||
637 | if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(int))) { | ||
638 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
639 | return -EFAULT; | ||
640 | } | ||
641 | } | ||
642 | lbs_pr_debug(1, "802.1x auth alg is %#x\n", alg); | ||
643 | priv->adapter->secinfo.auth1xalg = alg; | ||
644 | return 0; | ||
645 | } | ||
646 | |||
647 | static int wlan_setencryptionmode_ioctl(wlan_private * priv, struct ifreq *req) | ||
648 | { | ||
649 | int mode; | ||
650 | struct iwreq *wrq = (struct iwreq *)req; | ||
651 | |||
652 | ENTER(); | ||
653 | |||
654 | if (wrq->u.data.flags == 0) { | ||
655 | //from iwpriv subcmd | ||
656 | mode = SUBCMD_DATA(wrq); | ||
657 | } else { | ||
658 | //from wpa_supplicant subcmd | ||
659 | if (copy_from_user(&mode, wrq->u.data.pointer, sizeof(int))) { | ||
660 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
661 | return -EFAULT; | ||
662 | } | ||
663 | } | ||
664 | lbs_pr_debug(1, "encryption mode is %#x\n", mode); | ||
665 | priv->adapter->secinfo.Encryptionmode = mode; | ||
666 | |||
667 | LEAVE(); | ||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | static void adjust_mtu(wlan_private * priv) | ||
672 | { | ||
673 | int mtu_increment = 0; | ||
674 | |||
675 | if (priv->adapter->linkmode == WLAN_LINKMODE_802_11) | ||
676 | mtu_increment += sizeof(struct ieee80211_hdr_4addr); | ||
677 | |||
678 | if (priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP) | ||
679 | mtu_increment += max(sizeof(struct tx_radiotap_hdr), | ||
680 | sizeof(struct rx_radiotap_hdr)); | ||
681 | priv->wlan_dev.netdev->mtu = ETH_FRAME_LEN | ||
682 | - sizeof(struct ethhdr) | ||
683 | + mtu_increment; | ||
684 | } | ||
685 | |||
686 | /** | ||
687 | * @brief Set Link-Layer Layer mode | ||
688 | * @param priv A pointer to wlan_private structure | ||
689 | * @param req A pointer to ifreq structure | ||
690 | * @return 0 --success, otherwise fail | ||
691 | */ | ||
692 | static int wlan_set_linkmode_ioctl(wlan_private * priv, struct ifreq *req) | ||
693 | { | ||
694 | int mode; | ||
695 | |||
696 | mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data; | ||
697 | |||
698 | switch (mode) { | ||
699 | case WLAN_LINKMODE_802_3: | ||
700 | priv->adapter->linkmode = mode; | ||
701 | break; | ||
702 | case WLAN_LINKMODE_802_11: | ||
703 | priv->adapter->linkmode = mode; | ||
704 | break; | ||
705 | default: | ||
706 | lbs_pr_info("usb8388-5: invalid link-layer mode (%#x)\n", | ||
707 | mode); | ||
708 | return -EINVAL; | ||
709 | break; | ||
710 | } | ||
711 | lbs_pr_debug(1, "usb8388-5: link-layer mode is %#x\n", mode); | ||
712 | |||
713 | adjust_mtu(priv); | ||
714 | |||
715 | return 0; | ||
716 | } | ||
717 | |||
718 | /** | ||
719 | * @brief Set Radio header mode | ||
720 | * @param priv A pointer to wlan_private structure | ||
721 | * @param req A pointer to ifreq structure | ||
722 | * @return 0 --success, otherwise fail | ||
723 | */ | ||
724 | static int wlan_set_radiomode_ioctl(wlan_private * priv, struct ifreq *req) | ||
725 | { | ||
726 | int mode; | ||
727 | |||
728 | mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data; | ||
729 | |||
730 | switch (mode) { | ||
731 | case WLAN_RADIOMODE_NONE: | ||
732 | priv->adapter->radiomode = mode; | ||
733 | break; | ||
734 | case WLAN_RADIOMODE_RADIOTAP: | ||
735 | priv->adapter->radiomode = mode; | ||
736 | break; | ||
737 | default: | ||
738 | lbs_pr_debug(1, "usb8388-5: invalid radio header mode (%#x)\n", | ||
739 | mode); | ||
740 | return -EINVAL; | ||
741 | } | ||
742 | lbs_pr_debug(1, "usb8388-5: radio-header mode is %#x\n", mode); | ||
743 | |||
744 | adjust_mtu(priv); | ||
745 | return 0; | ||
746 | } | ||
747 | |||
748 | /** | ||
749 | * @brief Set Debug header mode | ||
750 | * @param priv A pointer to wlan_private structure | ||
751 | * @param req A pointer to ifreq structure | ||
752 | * @return 0 --success, otherwise fail | ||
753 | */ | ||
754 | static int wlan_set_debugmode_ioctl(wlan_private * priv, struct ifreq *req) | ||
755 | { | ||
756 | priv->adapter->debugmode = (int)((struct ifreq *) | ||
757 | ((u8 *) req + 4))->ifr_data; | ||
758 | return 0; | ||
759 | } | ||
760 | |||
761 | static int wlan_subcmd_getrxantenna_ioctl(wlan_private * priv, | ||
762 | struct ifreq *req) | ||
763 | { | ||
764 | int len; | ||
765 | char buf[8]; | ||
766 | struct iwreq *wrq = (struct iwreq *)req; | ||
767 | |||
768 | lbs_pr_debug(1, "WLAN_SUBCMD_GETRXANTENNA\n"); | ||
769 | len = getrxantenna(priv, buf); | ||
770 | |||
771 | wrq->u.data.length = len; | ||
772 | if (wrq->u.data.pointer) { | ||
773 | if (copy_to_user(wrq->u.data.pointer, &buf, len)) { | ||
774 | lbs_pr_debug(1, "CopyToUser failed\n"); | ||
775 | return -EFAULT; | ||
776 | } | ||
777 | } | ||
778 | |||
779 | return 0; | ||
780 | } | ||
781 | |||
782 | static int wlan_subcmd_gettxantenna_ioctl(wlan_private * priv, | ||
783 | struct ifreq *req) | ||
784 | { | ||
785 | int len; | ||
786 | char buf[8]; | ||
787 | struct iwreq *wrq = (struct iwreq *)req; | ||
788 | |||
789 | lbs_pr_debug(1, "WLAN_SUBCMD_GETTXANTENNA\n"); | ||
790 | len = gettxantenna(priv, buf); | ||
791 | |||
792 | wrq->u.data.length = len; | ||
793 | if (wrq->u.data.pointer) { | ||
794 | if (copy_to_user(wrq->u.data.pointer, &buf, len)) { | ||
795 | lbs_pr_debug(1, "CopyToUser failed\n"); | ||
796 | return -EFAULT; | ||
797 | } | ||
798 | } | ||
799 | return 0; | ||
800 | } | ||
801 | |||
802 | /** | ||
803 | * @brief Get the MAC TSF value from the firmware | ||
804 | * | ||
805 | * @param priv A pointer to wlan_private structure | ||
806 | * @param wrq A pointer to iwreq structure containing buffer | ||
807 | * space to store a TSF value retrieved from the firmware | ||
808 | * | ||
809 | * @return 0 if successful; IOCTL error code otherwise | ||
810 | */ | ||
811 | static int wlan_get_tsf_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
812 | { | ||
813 | u64 tsfval; | ||
814 | int ret; | ||
815 | |||
816 | ret = libertas_prepare_and_send_command(priv, | ||
817 | cmd_get_tsf, | ||
818 | 0, cmd_option_waitforrsp, 0, &tsfval); | ||
819 | |||
820 | lbs_pr_debug(1, "IOCTL: Get TSF = 0x%016llx\n", tsfval); | ||
821 | |||
822 | if (ret != 0) { | ||
823 | lbs_pr_debug(1, "IOCTL: Get TSF; command exec failed\n"); | ||
824 | ret = -EFAULT; | ||
825 | } else { | ||
826 | if (copy_to_user(wrq->u.data.pointer, | ||
827 | &tsfval, | ||
828 | min_t(size_t, wrq->u.data.length, | ||
829 | sizeof(tsfval))) != 0) { | ||
830 | |||
831 | lbs_pr_debug(1, "IOCTL: Get TSF; Copy to user failed\n"); | ||
832 | ret = -EFAULT; | ||
833 | } else { | ||
834 | ret = 0; | ||
835 | } | ||
836 | } | ||
837 | return ret; | ||
838 | } | ||
839 | |||
840 | /** | ||
841 | * @brief Get/Set adapt rate | ||
842 | * @param priv A pointer to wlan_private structure | ||
843 | * @param wrq A pointer to iwreq structure | ||
844 | * @return 0 --success, otherwise fail | ||
845 | */ | ||
846 | static int wlan_adapt_rateset(wlan_private * priv, struct iwreq *wrq) | ||
847 | { | ||
848 | int ret; | ||
849 | wlan_adapter *adapter = priv->adapter; | ||
850 | int data[2]; | ||
851 | |||
852 | memset(data, 0, sizeof(data)); | ||
853 | if (!wrq->u.data.length) { | ||
854 | lbs_pr_debug(1, "Get ADAPT RATE SET\n"); | ||
855 | ret = libertas_prepare_and_send_command(priv, | ||
856 | cmd_802_11_rate_adapt_rateset, | ||
857 | cmd_act_get, | ||
858 | cmd_option_waitforrsp, 0, NULL); | ||
859 | data[0] = adapter->enablehwauto; | ||
860 | data[1] = adapter->ratebitmap; | ||
861 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) { | ||
862 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
863 | return -EFAULT; | ||
864 | } | ||
865 | #define GET_TWO_INT 2 | ||
866 | wrq->u.data.length = GET_TWO_INT; | ||
867 | } else { | ||
868 | lbs_pr_debug(1, "Set ADAPT RATE SET\n"); | ||
869 | if (wrq->u.data.length > 2) | ||
870 | return -EINVAL; | ||
871 | if (copy_from_user | ||
872 | (data, wrq->u.data.pointer, | ||
873 | sizeof(int) * wrq->u.data.length)) { | ||
874 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
875 | return -EFAULT; | ||
876 | } | ||
877 | |||
878 | adapter->enablehwauto = data[0]; | ||
879 | adapter->ratebitmap = data[1]; | ||
880 | ret = libertas_prepare_and_send_command(priv, | ||
881 | cmd_802_11_rate_adapt_rateset, | ||
882 | cmd_act_set, | ||
883 | cmd_option_waitforrsp, 0, NULL); | ||
884 | } | ||
885 | return ret; | ||
886 | } | ||
887 | |||
888 | /** | ||
889 | * @brief Get/Set inactivity timeout | ||
890 | * @param priv A pointer to wlan_private structure | ||
891 | * @param wrq A pointer to iwreq structure | ||
892 | * @return 0 --success, otherwise fail | ||
893 | */ | ||
894 | static int wlan_inactivity_timeout(wlan_private * priv, struct iwreq *wrq) | ||
895 | { | ||
896 | int ret; | ||
897 | int data = 0; | ||
898 | u16 timeout = 0; | ||
899 | |||
900 | ENTER(); | ||
901 | if (wrq->u.data.length > 1) | ||
902 | return -ENOTSUPP; | ||
903 | |||
904 | if (wrq->u.data.length == 0) { | ||
905 | /* Get */ | ||
906 | ret = libertas_prepare_and_send_command(priv, | ||
907 | cmd_802_11_inactivity_timeout, | ||
908 | cmd_act_get, | ||
909 | cmd_option_waitforrsp, 0, | ||
910 | &timeout); | ||
911 | data = timeout; | ||
912 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) { | ||
913 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
914 | return -EFAULT; | ||
915 | } | ||
916 | } else { | ||
917 | /* Set */ | ||
918 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
919 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
920 | return -EFAULT; | ||
921 | } | ||
922 | |||
923 | timeout = data; | ||
924 | ret = libertas_prepare_and_send_command(priv, | ||
925 | cmd_802_11_inactivity_timeout, | ||
926 | cmd_act_set, | ||
927 | cmd_option_waitforrsp, 0, | ||
928 | &timeout); | ||
929 | } | ||
930 | |||
931 | wrq->u.data.length = 1; | ||
932 | |||
933 | LEAVE(); | ||
934 | return ret; | ||
935 | } | ||
936 | |||
937 | static int wlan_do_getlog_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
938 | { | ||
939 | int ret; | ||
940 | char buf[GETLOG_BUFSIZE - 1]; | ||
941 | wlan_adapter *adapter = priv->adapter; | ||
942 | |||
943 | lbs_pr_debug(1, " GET STATS\n"); | ||
944 | |||
945 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_get_log, | ||
946 | 0, cmd_option_waitforrsp, 0, NULL); | ||
947 | |||
948 | if (ret) { | ||
949 | return ret; | ||
950 | } | ||
951 | |||
952 | if (wrq->u.data.pointer) { | ||
953 | sprintf(buf, "\n mcasttxframe %u failed %u retry %u " | ||
954 | "multiretry %u framedup %u " | ||
955 | "rtssuccess %u rtsfailure %u ackfailure %u\n" | ||
956 | "rxfrag %u mcastrxframe %u fcserror %u " | ||
957 | "txframe %u wepundecryptable %u ", | ||
958 | adapter->logmsg.mcasttxframe, | ||
959 | adapter->logmsg.failed, | ||
960 | adapter->logmsg.retry, | ||
961 | adapter->logmsg.multiretry, | ||
962 | adapter->logmsg.framedup, | ||
963 | adapter->logmsg.rtssuccess, | ||
964 | adapter->logmsg.rtsfailure, | ||
965 | adapter->logmsg.ackfailure, | ||
966 | adapter->logmsg.rxfrag, | ||
967 | adapter->logmsg.mcastrxframe, | ||
968 | adapter->logmsg.fcserror, | ||
969 | adapter->logmsg.txframe, | ||
970 | adapter->logmsg.wepundecryptable); | ||
971 | wrq->u.data.length = strlen(buf) + 1; | ||
972 | if (copy_to_user(wrq->u.data.pointer, buf, wrq->u.data.length)) { | ||
973 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
974 | return -EFAULT; | ||
975 | } | ||
976 | } | ||
977 | |||
978 | return 0; | ||
979 | } | ||
980 | |||
981 | static int wlan_scan_type_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
982 | { | ||
983 | u8 buf[12]; | ||
984 | u8 *option[] = { "active", "passive", "get", }; | ||
985 | int i, max_options = (sizeof(option) / sizeof(option[0])); | ||
986 | int ret = 0; | ||
987 | wlan_adapter *adapter = priv->adapter; | ||
988 | |||
989 | if (priv->adapter->enable11d) { | ||
990 | lbs_pr_debug(1, "11D: Cannot set scantype when 11D enabled\n"); | ||
991 | return -EFAULT; | ||
992 | } | ||
993 | |||
994 | memset(buf, 0, sizeof(buf)); | ||
995 | |||
996 | if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf), | ||
997 | wrq->u.data.length))) | ||
998 | return -EFAULT; | ||
999 | |||
1000 | lbs_pr_debug(1, "Scan type Option = %s\n", buf); | ||
1001 | |||
1002 | buf[sizeof(buf) - 1] = '\0'; | ||
1003 | |||
1004 | for (i = 0; i < max_options; i++) { | ||
1005 | if (!strcmp(buf, option[i])) | ||
1006 | break; | ||
1007 | } | ||
1008 | |||
1009 | switch (i) { | ||
1010 | case 0: | ||
1011 | adapter->scantype = cmd_scan_type_active; | ||
1012 | break; | ||
1013 | case 1: | ||
1014 | adapter->scantype = cmd_scan_type_passive; | ||
1015 | break; | ||
1016 | case 2: | ||
1017 | wrq->u.data.length = strlen(option[adapter->scantype]) + 1; | ||
1018 | |||
1019 | if (copy_to_user(wrq->u.data.pointer, | ||
1020 | option[adapter->scantype], | ||
1021 | wrq->u.data.length)) { | ||
1022 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
1023 | ret = -EFAULT; | ||
1024 | } | ||
1025 | |||
1026 | break; | ||
1027 | default: | ||
1028 | lbs_pr_debug(1, "Invalid Scan type Ioctl Option\n"); | ||
1029 | ret = -EINVAL; | ||
1030 | break; | ||
1031 | } | ||
1032 | |||
1033 | return ret; | ||
1034 | } | ||
1035 | |||
1036 | static int wlan_scan_mode_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
1037 | { | ||
1038 | wlan_adapter *adapter = priv->adapter; | ||
1039 | u8 buf[12]; | ||
1040 | u8 *option[] = { "bss", "ibss", "any", "get" }; | ||
1041 | int i, max_options = (sizeof(option) / sizeof(option[0])); | ||
1042 | int ret = 0; | ||
1043 | |||
1044 | ENTER(); | ||
1045 | |||
1046 | memset(buf, 0, sizeof(buf)); | ||
1047 | |||
1048 | if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf), | ||
1049 | wrq->u.data.length))) { | ||
1050 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
1051 | return -EFAULT; | ||
1052 | } | ||
1053 | |||
1054 | lbs_pr_debug(1, "Scan mode Option = %s\n", buf); | ||
1055 | |||
1056 | buf[sizeof(buf) - 1] = '\0'; | ||
1057 | |||
1058 | for (i = 0; i < max_options; i++) { | ||
1059 | if (!strcmp(buf, option[i])) | ||
1060 | break; | ||
1061 | } | ||
1062 | |||
1063 | switch (i) { | ||
1064 | |||
1065 | case 0: | ||
1066 | adapter->scanmode = cmd_bss_type_bss; | ||
1067 | break; | ||
1068 | case 1: | ||
1069 | adapter->scanmode = cmd_bss_type_ibss; | ||
1070 | break; | ||
1071 | case 2: | ||
1072 | adapter->scanmode = cmd_bss_type_any; | ||
1073 | break; | ||
1074 | case 3: | ||
1075 | |||
1076 | wrq->u.data.length = strlen(option[adapter->scanmode - 1]) + 1; | ||
1077 | |||
1078 | lbs_pr_debug(1, "Get Scan mode Option = %s\n", | ||
1079 | option[adapter->scanmode - 1]); | ||
1080 | |||
1081 | lbs_pr_debug(1, "Scan mode length %d\n", wrq->u.data.length); | ||
1082 | |||
1083 | if (copy_to_user(wrq->u.data.pointer, | ||
1084 | option[adapter->scanmode - 1], | ||
1085 | wrq->u.data.length)) { | ||
1086 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
1087 | ret = -EFAULT; | ||
1088 | } | ||
1089 | lbs_pr_debug(1, "GET Scan type Option after copy = %s\n", | ||
1090 | (char *)wrq->u.data.pointer); | ||
1091 | |||
1092 | break; | ||
1093 | |||
1094 | default: | ||
1095 | lbs_pr_debug(1, "Invalid Scan mode Ioctl Option\n"); | ||
1096 | ret = -EINVAL; | ||
1097 | break; | ||
1098 | } | ||
1099 | |||
1100 | LEAVE(); | ||
1101 | return ret; | ||
1102 | } | ||
1103 | |||
1104 | /** | ||
1105 | * @brief Get/Set Adhoc G Rate | ||
1106 | * | ||
1107 | * @param priv A pointer to wlan_private structure | ||
1108 | * @param wrq A pointer to user data | ||
1109 | * @return 0--success, otherwise fail | ||
1110 | */ | ||
1111 | static int wlan_do_set_grate_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
1112 | { | ||
1113 | wlan_adapter *adapter = priv->adapter; | ||
1114 | int data, data1; | ||
1115 | int *val; | ||
1116 | |||
1117 | ENTER(); | ||
1118 | |||
1119 | data1 = SUBCMD_DATA(wrq); | ||
1120 | switch (data1) { | ||
1121 | case 0: | ||
1122 | adapter->adhoc_grate_enabled = 0; | ||
1123 | break; | ||
1124 | case 1: | ||
1125 | adapter->adhoc_grate_enabled = 1; | ||
1126 | break; | ||
1127 | case 2: | ||
1128 | break; | ||
1129 | default: | ||
1130 | return -EINVAL; | ||
1131 | } | ||
1132 | data = adapter->adhoc_grate_enabled; | ||
1133 | val = (int *)wrq->u.name; | ||
1134 | *val = data; | ||
1135 | LEAVE(); | ||
1136 | return 0; | ||
1137 | } | ||
1138 | |||
1139 | static inline int hex2int(char c) | 58 | static inline int hex2int(char c) |
1140 | { | 59 | { |
1141 | if (c >= '0' && c <= '9') | 60 | if (c >= '0' && c <= '9') |
@@ -1761,6 +680,7 @@ static int wlan_fwt_list_neighbor_ioctl(wlan_private * priv, struct ifreq *req) | |||
1761 | */ | 680 | */ |
1762 | static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) | 681 | static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) |
1763 | { | 682 | { |
683 | struct iwreq *wrq = (struct iwreq *)req; | ||
1764 | static struct cmd_ds_fwt_access fwt_access; | 684 | static struct cmd_ds_fwt_access fwt_access; |
1765 | int ret; | 685 | int ret; |
1766 | 686 | ||
@@ -1776,7 +696,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) | |||
1776 | (void *)&fwt_access); | 696 | (void *)&fwt_access); |
1777 | 697 | ||
1778 | if (ret == 0) | 698 | if (ret == 0) |
1779 | req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); | 699 | wrq->u.param.value = le32_to_cpu(fwt_access.references); |
1780 | else | 700 | else |
1781 | return -EFAULT; | 701 | return -EFAULT; |
1782 | 702 | ||
@@ -1792,6 +712,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) | |||
1792 | */ | 712 | */ |
1793 | static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) | 713 | static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) |
1794 | { | 714 | { |
715 | struct iwreq *wrq = (struct iwreq *)req; | ||
1795 | static struct cmd_ds_fwt_access fwt_access; | 716 | static struct cmd_ds_fwt_access fwt_access; |
1796 | int ret; | 717 | int ret; |
1797 | 718 | ||
@@ -1807,7 +728,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) | |||
1807 | (void *)&fwt_access); | 728 | (void *)&fwt_access); |
1808 | 729 | ||
1809 | if (ret == 0) | 730 | if (ret == 0) |
1810 | req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); | 731 | wrq->u.param.value = le32_to_cpu(fwt_access.references); |
1811 | else | 732 | else |
1812 | return -EFAULT; | 733 | return -EFAULT; |
1813 | 734 | ||
@@ -1823,6 +744,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) | |||
1823 | */ | 744 | */ |
1824 | static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) | 745 | static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) |
1825 | { | 746 | { |
747 | struct iwreq *wrq = (struct iwreq *)req; | ||
1826 | struct cmd_ds_mesh_access mesh_access; | 748 | struct cmd_ds_mesh_access mesh_access; |
1827 | int ret; | 749 | int ret; |
1828 | 750 | ||
@@ -1835,9 +757,8 @@ static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) | |||
1835 | cmd_option_waitforrsp, 0, | 757 | cmd_option_waitforrsp, 0, |
1836 | (void *)&mesh_access); | 758 | (void *)&mesh_access); |
1837 | 759 | ||
1838 | if (ret == 0) { | 760 | if (ret == 0) |
1839 | req->ifr_data = (char *)(le32_to_cpu(mesh_access.data[0])); | 761 | wrq->u.param.value = le32_to_cpu(mesh_access.data[0]); |
1840 | } | ||
1841 | else | 762 | else |
1842 | return -EFAULT; | 763 | return -EFAULT; |
1843 | 764 | ||
@@ -1898,36 +819,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1898 | 819 | ||
1899 | lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); | 820 | lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); |
1900 | switch (cmd) { | 821 | switch (cmd) { |
1901 | case WLANSCAN_TYPE: | ||
1902 | lbs_pr_debug(1, "Scan type Ioctl\n"); | ||
1903 | ret = wlan_scan_type_ioctl(priv, wrq); | ||
1904 | break; | ||
1905 | |||
1906 | case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ | 822 | case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ |
1907 | switch (wrq->u.data.flags) { | 823 | switch (wrq->u.data.flags) { |
1908 | case WLANDEAUTH: | ||
1909 | lbs_pr_debug(1, "Deauth\n"); | ||
1910 | libertas_send_deauth(priv); | ||
1911 | break; | ||
1912 | |||
1913 | case WLANADHOCSTOP: | ||
1914 | lbs_pr_debug(1, "Adhoc stop\n"); | ||
1915 | ret = libertas_do_adhocstop_ioctl(priv); | ||
1916 | break; | ||
1917 | |||
1918 | case WLANRADIOON: | ||
1919 | wlan_radio_ioctl(priv, 1); | ||
1920 | break; | ||
1921 | |||
1922 | case WLANRADIOOFF: | ||
1923 | wlan_radio_ioctl(priv, 0); | ||
1924 | break; | ||
1925 | case WLANWLANIDLEON: | ||
1926 | libertas_idle_on(priv); | ||
1927 | break; | ||
1928 | case WLANWLANIDLEOFF: | ||
1929 | libertas_idle_off(priv); | ||
1930 | break; | ||
1931 | case WLAN_SUBCMD_BT_RESET: /* bt_reset */ | 824 | case WLAN_SUBCMD_BT_RESET: /* bt_reset */ |
1932 | wlan_bt_reset_ioctl(priv); | 825 | wlan_bt_reset_ioctl(priv); |
1933 | break; | 826 | break; |
@@ -1937,162 +830,19 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1937 | } /* End of switch */ | 830 | } /* End of switch */ |
1938 | break; | 831 | break; |
1939 | 832 | ||
1940 | case WLANSETWPAIE: | ||
1941 | ret = wlan_setwpaie_ioctl(priv, req); | ||
1942 | break; | ||
1943 | case WLAN_SETINT_GETINT: | ||
1944 | /* The first 4 bytes of req->ifr_data is sub-ioctl number | ||
1945 | * after 4 bytes sits the payload. | ||
1946 | */ | ||
1947 | subcmd = (int)req->ifr_data; //from iwpriv subcmd | ||
1948 | switch (subcmd) { | ||
1949 | case WLANNF: | ||
1950 | ret = wlan_get_nf(priv, wrq); | ||
1951 | break; | ||
1952 | case WLANRSSI: | ||
1953 | ret = wlan_get_rssi(priv, wrq); | ||
1954 | break; | ||
1955 | case WLANENABLE11D: | ||
1956 | ret = libertas_cmd_enable_11d(priv, wrq); | ||
1957 | break; | ||
1958 | case WLANADHOCGRATE: | ||
1959 | ret = wlan_do_set_grate_ioctl(priv, wrq); | ||
1960 | break; | ||
1961 | case WLAN_SUBCMD_SET_PRESCAN: | ||
1962 | ret = wlan_subcmd_setprescan_ioctl(priv, wrq); | ||
1963 | break; | ||
1964 | } | ||
1965 | break; | ||
1966 | |||
1967 | case WLAN_SETONEINT_GETONEINT: | ||
1968 | switch (wrq->u.data.flags) { | ||
1969 | case WLAN_BEACON_INTERVAL: | ||
1970 | ret = wlan_beacon_interval(priv, wrq); | ||
1971 | break; | ||
1972 | |||
1973 | case WLAN_LISTENINTRVL: | ||
1974 | if (!wrq->u.data.length) { | ||
1975 | int data; | ||
1976 | lbs_pr_debug(1, "Get locallisteninterval value\n"); | ||
1977 | #define GET_ONE_INT 1 | ||
1978 | data = adapter->locallisteninterval; | ||
1979 | if (copy_to_user(wrq->u.data.pointer, | ||
1980 | &data, sizeof(int))) { | ||
1981 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
1982 | return -EFAULT; | ||
1983 | } | ||
1984 | |||
1985 | wrq->u.data.length = GET_ONE_INT; | ||
1986 | } else { | ||
1987 | int data; | ||
1988 | if (copy_from_user | ||
1989 | (&data, wrq->u.data.pointer, sizeof(int))) { | ||
1990 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
1991 | return -EFAULT; | ||
1992 | } | ||
1993 | |||
1994 | lbs_pr_debug(1, "Set locallisteninterval = %d\n", | ||
1995 | data); | ||
1996 | #define MAX_U16_VAL 65535 | ||
1997 | if (data > MAX_U16_VAL) { | ||
1998 | lbs_pr_debug(1, "Exceeds U16 value\n"); | ||
1999 | return -EINVAL; | ||
2000 | } | ||
2001 | adapter->locallisteninterval = data; | ||
2002 | } | ||
2003 | break; | ||
2004 | case WLAN_TXCONTROL: | ||
2005 | ret = wlan_txcontrol(priv, wrq); //adds for txcontrol ioctl | ||
2006 | break; | ||
2007 | |||
2008 | case WLAN_NULLPKTINTERVAL: | ||
2009 | ret = wlan_null_pkt_interval(priv, wrq); | ||
2010 | break; | ||
2011 | |||
2012 | default: | ||
2013 | ret = -EOPNOTSUPP; | ||
2014 | break; | ||
2015 | } | ||
2016 | break; | ||
2017 | |||
2018 | case WLAN_SETONEINT_GETNONE: | 833 | case WLAN_SETONEINT_GETNONE: |
2019 | /* The first 4 bytes of req->ifr_data is sub-ioctl number | 834 | /* The first 4 bytes of req->ifr_data is sub-ioctl number |
2020 | * after 4 bytes sits the payload. | 835 | * after 4 bytes sits the payload. |
2021 | */ | 836 | */ |
2022 | subcmd = wrq->u.data.flags; //from wpa_supplicant subcmd | 837 | subcmd = wrq->u.data.flags; |
2023 | |||
2024 | if (!subcmd) | 838 | if (!subcmd) |
2025 | subcmd = (int)req->ifr_data; //from iwpriv subcmd | 839 | subcmd = (int)wrq->u.param.value; |
2026 | 840 | ||
2027 | switch (subcmd) { | 841 | switch (subcmd) { |
2028 | case WLAN_SUBCMD_SETRXANTENNA: /* SETRXANTENNA */ | ||
2029 | idata = SUBCMD_DATA(wrq); | ||
2030 | ret = setrxantenna(priv, idata); | ||
2031 | break; | ||
2032 | case WLAN_SUBCMD_SETTXANTENNA: /* SETTXANTENNA */ | ||
2033 | idata = SUBCMD_DATA(wrq); | ||
2034 | ret = settxantenna(priv, idata); | ||
2035 | break; | ||
2036 | case WLAN_SET_ATIM_WINDOW: | ||
2037 | adapter->atimwindow = SUBCMD_DATA(wrq); | ||
2038 | adapter->atimwindow = min_t(__u16, adapter->atimwindow, 50); | ||
2039 | break; | ||
2040 | case WLANSETBCNAVG: | ||
2041 | adapter->bcn_avg_factor = SUBCMD_DATA(wrq); | ||
2042 | if (adapter->bcn_avg_factor == 0) | ||
2043 | adapter->bcn_avg_factor = | ||
2044 | DEFAULT_BCN_AVG_FACTOR; | ||
2045 | if (adapter->bcn_avg_factor > DEFAULT_BCN_AVG_FACTOR) | ||
2046 | adapter->bcn_avg_factor = | ||
2047 | DEFAULT_BCN_AVG_FACTOR; | ||
2048 | break; | ||
2049 | case WLANSETDATAAVG: | ||
2050 | adapter->data_avg_factor = SUBCMD_DATA(wrq); | ||
2051 | if (adapter->data_avg_factor == 0) | ||
2052 | adapter->data_avg_factor = | ||
2053 | DEFAULT_DATA_AVG_FACTOR; | ||
2054 | if (adapter->data_avg_factor > DEFAULT_DATA_AVG_FACTOR) | ||
2055 | adapter->data_avg_factor = | ||
2056 | DEFAULT_DATA_AVG_FACTOR; | ||
2057 | break; | ||
2058 | case WLANSETREGION: | 842 | case WLANSETREGION: |
2059 | idata = SUBCMD_DATA(wrq); | 843 | idata = SUBCMD_DATA(wrq); |
2060 | ret = wlan_set_region(priv, (u16) idata); | 844 | ret = wlan_set_region(priv, (u16) idata); |
2061 | break; | 845 | break; |
2062 | |||
2063 | case WLAN_SET_LISTEN_INTERVAL: | ||
2064 | idata = SUBCMD_DATA(wrq); | ||
2065 | adapter->listeninterval = (u16) idata; | ||
2066 | break; | ||
2067 | |||
2068 | case WLAN_SET_MULTIPLE_DTIM: | ||
2069 | ret = wlan_set_multiple_dtim_ioctl(priv, req); | ||
2070 | break; | ||
2071 | |||
2072 | case WLANSETAUTHALG: | ||
2073 | ret = wlan_setauthalg_ioctl(priv, req); | ||
2074 | break; | ||
2075 | |||
2076 | case WLANSET8021XAUTHALG: | ||
2077 | ret = wlan_set8021xauthalg_ioctl(priv, req); | ||
2078 | break; | ||
2079 | |||
2080 | case WLANSETENCRYPTIONMODE: | ||
2081 | ret = wlan_setencryptionmode_ioctl(priv, req); | ||
2082 | break; | ||
2083 | |||
2084 | case WLAN_SET_LINKMODE: | ||
2085 | ret = wlan_set_linkmode_ioctl(priv, req); | ||
2086 | break; | ||
2087 | |||
2088 | case WLAN_SET_RADIOMODE: | ||
2089 | ret = wlan_set_radiomode_ioctl(priv, req); | ||
2090 | break; | ||
2091 | |||
2092 | case WLAN_SET_DEBUGMODE: | ||
2093 | ret = wlan_set_debugmode_ioctl(priv, req); | ||
2094 | break; | ||
2095 | |||
2096 | case WLAN_SUBCMD_MESH_SET_TTL: | 846 | case WLAN_SUBCMD_MESH_SET_TTL: |
2097 | idata = SUBCMD_DATA(wrq); | 847 | idata = SUBCMD_DATA(wrq); |
2098 | ret = wlan_mesh_set_ttl_ioctl(priv, idata); | 848 | ret = wlan_mesh_set_ttl_ioctl(priv, idata); |
@@ -2105,38 +855,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2105 | 855 | ||
2106 | break; | 856 | break; |
2107 | 857 | ||
2108 | case WLAN_SETNONE_GETTWELVE_CHAR: /* Get Antenna settings */ | ||
2109 | /* | ||
2110 | * We've not used IW_PRIV_TYPE_FIXED so sub-ioctl number is | ||
2111 | * in flags of iwreq structure, otherwise it will be in | ||
2112 | * mode member of iwreq structure. | ||
2113 | */ | ||
2114 | switch ((int)wrq->u.data.flags) { | ||
2115 | case WLAN_SUBCMD_GETRXANTENNA: /* Get Rx Antenna */ | ||
2116 | ret = wlan_subcmd_getrxantenna_ioctl(priv, req); | ||
2117 | break; | ||
2118 | |||
2119 | case WLAN_SUBCMD_GETTXANTENNA: /* Get Tx Antenna */ | ||
2120 | ret = wlan_subcmd_gettxantenna_ioctl(priv, req); | ||
2121 | break; | ||
2122 | |||
2123 | case WLAN_GET_TSF: | ||
2124 | ret = wlan_get_tsf_ioctl(priv, wrq); | ||
2125 | break; | ||
2126 | } | ||
2127 | break; | ||
2128 | |||
2129 | case WLAN_SET128CHAR_GET128CHAR: | 858 | case WLAN_SET128CHAR_GET128CHAR: |
2130 | switch ((int)wrq->u.data.flags) { | 859 | switch ((int)wrq->u.data.flags) { |
2131 | |||
2132 | case WLANSCAN_MODE: | ||
2133 | lbs_pr_debug(1, "Scan mode Ioctl\n"); | ||
2134 | ret = wlan_scan_mode_ioctl(priv, wrq); | ||
2135 | break; | ||
2136 | |||
2137 | case WLAN_GET_ADHOC_STATUS: | ||
2138 | ret = wlan_get_adhoc_status_ioctl(priv, wrq); | ||
2139 | break; | ||
2140 | case WLAN_SUBCMD_BT_ADD: | 860 | case WLAN_SUBCMD_BT_ADD: |
2141 | ret = wlan_bt_add_ioctl(priv, req); | 861 | ret = wlan_bt_add_ioctl(priv, req); |
2142 | break; | 862 | break; |
@@ -2168,41 +888,11 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2168 | break; | 888 | break; |
2169 | 889 | ||
2170 | case WLAN_SETNONE_GETONEINT: | 890 | case WLAN_SETNONE_GETONEINT: |
2171 | switch ((int)req->ifr_data) { | 891 | switch (wrq->u.param.value) { |
2172 | case WLANGETBCNAVG: | ||
2173 | pdata = (int *)wrq->u.name; | ||
2174 | *pdata = (int)adapter->bcn_avg_factor; | ||
2175 | break; | ||
2176 | |||
2177 | case WLANGETREGION: | 892 | case WLANGETREGION: |
2178 | pdata = (int *)wrq->u.name; | 893 | pdata = (int *)wrq->u.name; |
2179 | *pdata = (int)adapter->regioncode; | 894 | *pdata = (int)adapter->regioncode; |
2180 | break; | 895 | break; |
2181 | |||
2182 | case WLAN_GET_LISTEN_INTERVAL: | ||
2183 | pdata = (int *)wrq->u.name; | ||
2184 | *pdata = (int)adapter->listeninterval; | ||
2185 | break; | ||
2186 | |||
2187 | case WLAN_GET_LINKMODE: | ||
2188 | req->ifr_data = (char *)((u32) adapter->linkmode); | ||
2189 | break; | ||
2190 | |||
2191 | case WLAN_GET_RADIOMODE: | ||
2192 | req->ifr_data = (char *)((u32) adapter->radiomode); | ||
2193 | break; | ||
2194 | |||
2195 | case WLAN_GET_DEBUGMODE: | ||
2196 | req->ifr_data = (char *)((u32) adapter->debugmode); | ||
2197 | break; | ||
2198 | |||
2199 | case WLAN_GET_MULTIPLE_DTIM: | ||
2200 | pdata = (int *)wrq->u.name; | ||
2201 | *pdata = (int)adapter->multipledtim; | ||
2202 | break; | ||
2203 | case WLAN_GET_TX_RATE: | ||
2204 | ret = wlan_get_txrate_ioctl(priv, req); | ||
2205 | break; | ||
2206 | case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ | 896 | case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ |
2207 | ret = wlan_fwt_cleanup_ioctl(priv, req); | 897 | ret = wlan_fwt_cleanup_ioctl(priv, req); |
2208 | break; | 898 | break; |
@@ -2222,196 +912,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2222 | 912 | ||
2223 | break; | 913 | break; |
2224 | 914 | ||
2225 | case WLANGETLOG: | ||
2226 | ret = wlan_do_getlog_ioctl(priv, wrq); | ||
2227 | break; | ||
2228 | |||
2229 | case WLAN_SET_GET_SIXTEEN_INT: | 915 | case WLAN_SET_GET_SIXTEEN_INT: |
2230 | switch ((int)wrq->u.data.flags) { | 916 | switch ((int)wrq->u.data.flags) { |
2231 | case WLAN_TPCCFG: | ||
2232 | { | ||
2233 | int data[5]; | ||
2234 | struct cmd_ds_802_11_tpc_cfg cfg; | ||
2235 | memset(&cfg, 0, sizeof(cfg)); | ||
2236 | if ((wrq->u.data.length > 1) | ||
2237 | && (wrq->u.data.length != 5)) | ||
2238 | return -1; | ||
2239 | |||
2240 | if (wrq->u.data.length == 0) { | ||
2241 | cfg.action = | ||
2242 | cpu_to_le16 | ||
2243 | (cmd_act_get); | ||
2244 | } else { | ||
2245 | if (copy_from_user | ||
2246 | (data, wrq->u.data.pointer, | ||
2247 | sizeof(int) * 5)) { | ||
2248 | lbs_pr_debug(1, | ||
2249 | "Copy from user failed\n"); | ||
2250 | return -EFAULT; | ||
2251 | } | ||
2252 | |||
2253 | cfg.action = | ||
2254 | cpu_to_le16 | ||
2255 | (cmd_act_set); | ||
2256 | cfg.enable = data[0]; | ||
2257 | cfg.usesnr = data[1]; | ||
2258 | cfg.P0 = data[2]; | ||
2259 | cfg.P1 = data[3]; | ||
2260 | cfg.P2 = data[4]; | ||
2261 | } | ||
2262 | |||
2263 | ret = | ||
2264 | libertas_prepare_and_send_command(priv, | ||
2265 | cmd_802_11_tpc_cfg, | ||
2266 | 0, | ||
2267 | cmd_option_waitforrsp, | ||
2268 | 0, (void *)&cfg); | ||
2269 | |||
2270 | data[0] = cfg.enable; | ||
2271 | data[1] = cfg.usesnr; | ||
2272 | data[2] = cfg.P0; | ||
2273 | data[3] = cfg.P1; | ||
2274 | data[4] = cfg.P2; | ||
2275 | if (copy_to_user | ||
2276 | (wrq->u.data.pointer, data, | ||
2277 | sizeof(int) * 5)) { | ||
2278 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2279 | return -EFAULT; | ||
2280 | } | ||
2281 | |||
2282 | wrq->u.data.length = 5; | ||
2283 | } | ||
2284 | break; | ||
2285 | |||
2286 | case WLAN_POWERCFG: | ||
2287 | { | ||
2288 | int data[4]; | ||
2289 | struct cmd_ds_802_11_pwr_cfg cfg; | ||
2290 | memset(&cfg, 0, sizeof(cfg)); | ||
2291 | if ((wrq->u.data.length > 1) | ||
2292 | && (wrq->u.data.length != 4)) | ||
2293 | return -1; | ||
2294 | if (wrq->u.data.length == 0) { | ||
2295 | cfg.action = | ||
2296 | cpu_to_le16 | ||
2297 | (cmd_act_get); | ||
2298 | } else { | ||
2299 | if (copy_from_user | ||
2300 | (data, wrq->u.data.pointer, | ||
2301 | sizeof(int) * 4)) { | ||
2302 | lbs_pr_debug(1, | ||
2303 | "Copy from user failed\n"); | ||
2304 | return -EFAULT; | ||
2305 | } | ||
2306 | |||
2307 | cfg.action = | ||
2308 | cpu_to_le16 | ||
2309 | (cmd_act_set); | ||
2310 | cfg.enable = data[0]; | ||
2311 | cfg.PA_P0 = data[1]; | ||
2312 | cfg.PA_P1 = data[2]; | ||
2313 | cfg.PA_P2 = data[3]; | ||
2314 | } | ||
2315 | ret = | ||
2316 | libertas_prepare_and_send_command(priv, | ||
2317 | cmd_802_11_pwr_cfg, | ||
2318 | 0, | ||
2319 | cmd_option_waitforrsp, | ||
2320 | 0, (void *)&cfg); | ||
2321 | data[0] = cfg.enable; | ||
2322 | data[1] = cfg.PA_P0; | ||
2323 | data[2] = cfg.PA_P1; | ||
2324 | data[3] = cfg.PA_P2; | ||
2325 | if (copy_to_user | ||
2326 | (wrq->u.data.pointer, data, | ||
2327 | sizeof(int) * 4)) { | ||
2328 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2329 | return -EFAULT; | ||
2330 | } | ||
2331 | |||
2332 | wrq->u.data.length = 4; | ||
2333 | } | ||
2334 | break; | ||
2335 | case WLAN_AUTO_FREQ_SET: | ||
2336 | { | ||
2337 | int data[3]; | ||
2338 | struct cmd_ds_802_11_afc afc; | ||
2339 | memset(&afc, 0, sizeof(afc)); | ||
2340 | if (wrq->u.data.length != 3) | ||
2341 | return -1; | ||
2342 | if (copy_from_user | ||
2343 | (data, wrq->u.data.pointer, | ||
2344 | sizeof(int) * 3)) { | ||
2345 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
2346 | return -EFAULT; | ||
2347 | } | ||
2348 | afc.afc_auto = data[0]; | ||
2349 | |||
2350 | if (afc.afc_auto != 0) { | ||
2351 | afc.threshold = data[1]; | ||
2352 | afc.period = data[2]; | ||
2353 | } else { | ||
2354 | afc.timing_offset = data[1]; | ||
2355 | afc.carrier_offset = data[2]; | ||
2356 | } | ||
2357 | ret = | ||
2358 | libertas_prepare_and_send_command(priv, | ||
2359 | cmd_802_11_set_afc, | ||
2360 | 0, | ||
2361 | cmd_option_waitforrsp, | ||
2362 | 0, (void *)&afc); | ||
2363 | } | ||
2364 | break; | ||
2365 | case WLAN_AUTO_FREQ_GET: | ||
2366 | { | ||
2367 | int data[3]; | ||
2368 | struct cmd_ds_802_11_afc afc; | ||
2369 | memset(&afc, 0, sizeof(afc)); | ||
2370 | ret = | ||
2371 | libertas_prepare_and_send_command(priv, | ||
2372 | cmd_802_11_get_afc, | ||
2373 | 0, | ||
2374 | cmd_option_waitforrsp, | ||
2375 | 0, (void *)&afc); | ||
2376 | data[0] = afc.afc_auto; | ||
2377 | data[1] = afc.timing_offset; | ||
2378 | data[2] = afc.carrier_offset; | ||
2379 | if (copy_to_user | ||
2380 | (wrq->u.data.pointer, data, | ||
2381 | sizeof(int) * 3)) { | ||
2382 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2383 | return -EFAULT; | ||
2384 | } | ||
2385 | |||
2386 | wrq->u.data.length = 3; | ||
2387 | } | ||
2388 | break; | ||
2389 | case WLAN_SCANPROBES: | ||
2390 | { | ||
2391 | int data; | ||
2392 | if (wrq->u.data.length > 0) { | ||
2393 | if (copy_from_user | ||
2394 | (&data, wrq->u.data.pointer, | ||
2395 | sizeof(int))) { | ||
2396 | lbs_pr_debug(1, | ||
2397 | "Copy from user failed\n"); | ||
2398 | return -EFAULT; | ||
2399 | } | ||
2400 | |||
2401 | adapter->scanprobes = data; | ||
2402 | } else { | ||
2403 | data = adapter->scanprobes; | ||
2404 | if (copy_to_user | ||
2405 | (wrq->u.data.pointer, &data, | ||
2406 | sizeof(int))) { | ||
2407 | lbs_pr_debug(1, | ||
2408 | "Copy to user failed\n"); | ||
2409 | return -EFAULT; | ||
2410 | } | ||
2411 | } | ||
2412 | wrq->u.data.length = 1; | ||
2413 | } | ||
2414 | break; | ||
2415 | case WLAN_LED_GPIO_CTRL: | 917 | case WLAN_LED_GPIO_CTRL: |
2416 | { | 918 | { |
2417 | int i; | 919 | int i; |
@@ -2475,17 +977,6 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2475 | wrq->u.data.length = gpio->header.len; | 977 | wrq->u.data.length = gpio->header.len; |
2476 | } | 978 | } |
2477 | break; | 979 | break; |
2478 | case WLAN_ADAPT_RATESET: | ||
2479 | ret = wlan_adapt_rateset(priv, wrq); | ||
2480 | break; | ||
2481 | case WLAN_INACTIVITY_TIMEOUT: | ||
2482 | ret = wlan_inactivity_timeout(priv, wrq); | ||
2483 | break; | ||
2484 | case WLANSNR: | ||
2485 | ret = wlan_get_snr(priv, wrq); | ||
2486 | break; | ||
2487 | case WLAN_GET_RXINFO: | ||
2488 | ret = wlan_get_rxinfo(priv, wrq); | ||
2489 | } | 980 | } |
2490 | break; | 981 | break; |
2491 | 982 | ||
diff --git a/drivers/net/wireless/libertas/join.c b/drivers/net/wireless/libertas/join.c index 11682cbe752b..d4926b83e145 100644 --- a/drivers/net/wireless/libertas/join.c +++ b/drivers/net/wireless/libertas/join.c | |||
@@ -15,6 +15,8 @@ | |||
15 | #include "join.h" | 15 | #include "join.h" |
16 | #include "dev.h" | 16 | #include "dev.h" |
17 | 17 | ||
18 | #define AD_HOC_CAP_PRIVACY_ON 1 | ||
19 | |||
18 | /** | 20 | /** |
19 | * @brief This function finds out the common rates between rate1 and rate2. | 21 | * @brief This function finds out the common rates between rate1 and rate2. |
20 | * | 22 | * |
@@ -85,7 +87,7 @@ int libertas_send_deauth(wlan_private * priv) | |||
85 | wlan_adapter *adapter = priv->adapter; | 87 | wlan_adapter *adapter = priv->adapter; |
86 | int ret = 0; | 88 | int ret = 0; |
87 | 89 | ||
88 | if (adapter->inframode == wlan802_11infrastructure && | 90 | if (adapter->mode == IW_MODE_INFRA && |
89 | adapter->connect_status == libertas_connected) | 91 | adapter->connect_status == libertas_connected) |
90 | ret = libertas_send_deauthentication(priv); | 92 | ret = libertas_send_deauthentication(priv); |
91 | else | 93 | else |
@@ -94,20 +96,6 @@ int libertas_send_deauth(wlan_private * priv) | |||
94 | return ret; | 96 | return ret; |
95 | } | 97 | } |
96 | 98 | ||
97 | int libertas_do_adhocstop_ioctl(wlan_private * priv) | ||
98 | { | ||
99 | wlan_adapter *adapter = priv->adapter; | ||
100 | int ret = 0; | ||
101 | |||
102 | if (adapter->inframode == wlan802_11ibss && | ||
103 | adapter->connect_status == libertas_connected) | ||
104 | ret = libertas_stop_adhoc_network(priv); | ||
105 | else | ||
106 | ret = -ENOTSUPP; | ||
107 | |||
108 | return ret; | ||
109 | } | ||
110 | |||
111 | /** | 99 | /** |
112 | * @brief Associate to a specific BSS discovered in a scan | 100 | * @brief Associate to a specific BSS discovered in a scan |
113 | * | 101 | * |
@@ -207,8 +195,7 @@ int libertas_join_adhoc_network(wlan_private * priv, struct bss_descriptor * pbs | |||
207 | /* check if the requested SSID is already joined */ | 195 | /* check if the requested SSID is already joined */ |
208 | if (adapter->curbssparams.ssid.ssidlength | 196 | if (adapter->curbssparams.ssid.ssidlength |
209 | && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid) | 197 | && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid) |
210 | && (adapter->curbssparams.bssdescriptor.inframode == | 198 | && (adapter->mode == IW_MODE_ADHOC)) { |
211 | wlan802_11ibss)) { | ||
212 | 199 | ||
213 | lbs_pr_debug(1, | 200 | lbs_pr_debug(1, |
214 | "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " | 201 | "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " |
@@ -261,130 +248,6 @@ int libertas_send_deauthentication(wlan_private * priv) | |||
261 | } | 248 | } |
262 | 249 | ||
263 | /** | 250 | /** |
264 | * @brief Set Idle Off | ||
265 | * | ||
266 | * @param priv A pointer to wlan_private structure | ||
267 | * @return 0 --success, otherwise fail | ||
268 | */ | ||
269 | int libertas_idle_off(wlan_private * priv) | ||
270 | { | ||
271 | wlan_adapter *adapter = priv->adapter; | ||
272 | int ret = 0; | ||
273 | const u8 zeromac[] = { 0, 0, 0, 0, 0, 0 }; | ||
274 | int i; | ||
275 | |||
276 | ENTER(); | ||
277 | |||
278 | if (adapter->connect_status == libertas_disconnected) { | ||
279 | if (adapter->inframode == wlan802_11infrastructure) { | ||
280 | if (memcmp(adapter->previousbssid, zeromac, | ||
281 | sizeof(zeromac)) != 0) { | ||
282 | |||
283 | lbs_pr_debug(1, "Previous SSID = %s\n", | ||
284 | adapter->previousssid.ssid); | ||
285 | lbs_pr_debug(1, "Previous BSSID = " | ||
286 | "%02x:%02x:%02x:%02x:%02x:%02x:\n", | ||
287 | adapter->previousbssid[0], | ||
288 | adapter->previousbssid[1], | ||
289 | adapter->previousbssid[2], | ||
290 | adapter->previousbssid[3], | ||
291 | adapter->previousbssid[4], | ||
292 | adapter->previousbssid[5]); | ||
293 | |||
294 | i = libertas_find_SSID_in_list(adapter, | ||
295 | &adapter->previousssid, | ||
296 | adapter->previousbssid, | ||
297 | adapter->inframode); | ||
298 | |||
299 | if (i < 0) { | ||
300 | libertas_send_specific_BSSID_scan(priv, | ||
301 | adapter-> | ||
302 | previousbssid, | ||
303 | 1); | ||
304 | i = libertas_find_SSID_in_list(adapter, | ||
305 | &adapter-> | ||
306 | previousssid, | ||
307 | adapter-> | ||
308 | previousbssid, | ||
309 | adapter-> | ||
310 | inframode); | ||
311 | } | ||
312 | |||
313 | if (i < 0) { | ||
314 | /* If the BSSID could not be found, try just the SSID */ | ||
315 | i = libertas_find_SSID_in_list(adapter, | ||
316 | &adapter-> | ||
317 | previousssid, NULL, | ||
318 | adapter-> | ||
319 | inframode); | ||
320 | } | ||
321 | |||
322 | if (i < 0) { | ||
323 | libertas_send_specific_SSID_scan(priv, | ||
324 | &adapter-> | ||
325 | previousssid, | ||
326 | 1); | ||
327 | i = libertas_find_SSID_in_list(adapter, | ||
328 | &adapter-> | ||
329 | previousssid, NULL, | ||
330 | adapter-> | ||
331 | inframode); | ||
332 | } | ||
333 | |||
334 | if (i >= 0) { | ||
335 | ret = | ||
336 | wlan_associate(priv, | ||
337 | &adapter-> | ||
338 | scantable[i]); | ||
339 | } | ||
340 | } | ||
341 | } else if (adapter->inframode == wlan802_11ibss) { | ||
342 | ret = libertas_prepare_and_send_command(priv, | ||
343 | cmd_802_11_ad_hoc_start, | ||
344 | 0, | ||
345 | cmd_option_waitforrsp, | ||
346 | 0, &adapter->previousssid); | ||
347 | } | ||
348 | } | ||
349 | /* else it is connected */ | ||
350 | |||
351 | lbs_pr_debug(1, "\nwlanidle is off"); | ||
352 | LEAVE(); | ||
353 | return ret; | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * @brief Set Idle On | ||
358 | * | ||
359 | * @param priv A pointer to wlan_private structure | ||
360 | * @return 0 --success, otherwise fail | ||
361 | */ | ||
362 | int libertas_idle_on(wlan_private * priv) | ||
363 | { | ||
364 | wlan_adapter *adapter = priv->adapter; | ||
365 | int ret = 0; | ||
366 | |||
367 | if (adapter->connect_status == libertas_connected) { | ||
368 | if (adapter->inframode == wlan802_11infrastructure) { | ||
369 | lbs_pr_debug(1, "Previous SSID = %s\n", | ||
370 | adapter->previousssid.ssid); | ||
371 | memmove(&adapter->previousssid, | ||
372 | &adapter->curbssparams.ssid, | ||
373 | sizeof(struct WLAN_802_11_SSID)); | ||
374 | libertas_send_deauth(priv); | ||
375 | |||
376 | } else if (adapter->inframode == wlan802_11ibss) { | ||
377 | ret = libertas_stop_adhoc_network(priv); | ||
378 | } | ||
379 | |||
380 | } | ||
381 | |||
382 | lbs_pr_debug(1, "\nwlanidle is on"); | ||
383 | |||
384 | return ret; | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * @brief This function prepares command of authenticate. | 251 | * @brief This function prepares command of authenticate. |
389 | * | 252 | * |
390 | * @param priv A pointer to wlan_private structure | 253 | * @param priv A pointer to wlan_private structure |
@@ -398,22 +261,39 @@ int libertas_cmd_80211_authenticate(wlan_private * priv, | |||
398 | void *pdata_buf) | 261 | void *pdata_buf) |
399 | { | 262 | { |
400 | wlan_adapter *adapter = priv->adapter; | 263 | wlan_adapter *adapter = priv->adapter; |
401 | struct cmd_ds_802_11_authenticate *pauthenticate = | 264 | struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth; |
402 | &cmd->params.auth; | 265 | int ret = -1; |
403 | u8 *bssid = pdata_buf; | 266 | u8 *bssid = pdata_buf; |
404 | 267 | ||
405 | cmd->command = cpu_to_le16(cmd_802_11_authenticate); | 268 | cmd->command = cpu_to_le16(cmd_802_11_authenticate); |
406 | cmd->size = | 269 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) |
407 | cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) | 270 | + S_DS_GEN); |
408 | + S_DS_GEN); | 271 | |
272 | /* translate auth mode to 802.11 defined wire value */ | ||
273 | switch (adapter->secinfo.auth_mode) { | ||
274 | case IW_AUTH_ALG_OPEN_SYSTEM: | ||
275 | pauthenticate->authtype = 0x00; | ||
276 | break; | ||
277 | case IW_AUTH_ALG_SHARED_KEY: | ||
278 | pauthenticate->authtype = 0x01; | ||
279 | break; | ||
280 | case IW_AUTH_ALG_LEAP: | ||
281 | pauthenticate->authtype = 0x80; | ||
282 | break; | ||
283 | default: | ||
284 | lbs_pr_debug(1, "AUTH_CMD: invalid auth alg 0x%X\n", | ||
285 | adapter->secinfo.auth_mode); | ||
286 | goto out; | ||
287 | } | ||
409 | 288 | ||
410 | pauthenticate->authtype = adapter->secinfo.authmode; | ||
411 | memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); | 289 | memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); |
412 | 290 | ||
413 | lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n", | 291 | lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n", |
414 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); | 292 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); |
293 | ret = 0; | ||
415 | 294 | ||
416 | return 0; | 295 | out: |
296 | return ret; | ||
417 | } | 297 | } |
418 | 298 | ||
419 | int libertas_cmd_80211_deauthenticate(wlan_private * priv, | 299 | int libertas_cmd_80211_deauthenticate(wlan_private * priv, |
@@ -550,7 +430,7 @@ int libertas_cmd_80211_associate(wlan_private * priv, | |||
550 | lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len); | 430 | lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len); |
551 | 431 | ||
552 | /* set IBSS field */ | 432 | /* set IBSS field */ |
553 | if (pbssdesc->inframode == wlan802_11infrastructure) { | 433 | if (pbssdesc->mode == IW_MODE_INFRA) { |
554 | #define CAPINFO_ESS_MODE 1 | 434 | #define CAPINFO_ESS_MODE 1 |
555 | passo->capinfo.ess = CAPINFO_ESS_MODE; | 435 | passo->capinfo.ess = CAPINFO_ESS_MODE; |
556 | } | 436 | } |
@@ -624,7 +504,7 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, | |||
624 | 504 | ||
625 | /* set the BSS type */ | 505 | /* set the BSS type */ |
626 | adhs->bsstype = cmd_bss_type_ibss; | 506 | adhs->bsstype = cmd_bss_type_ibss; |
627 | pbssdesc->inframode = wlan802_11ibss; | 507 | pbssdesc->mode = IW_MODE_ADHOC; |
628 | adhs->beaconperiod = adapter->beaconperiod; | 508 | adhs->beaconperiod = adapter->beaconperiod; |
629 | 509 | ||
630 | /* set Physical param set */ | 510 | /* set Physical param set */ |
@@ -666,15 +546,12 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, | |||
666 | adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); | 546 | adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); |
667 | 547 | ||
668 | /* set up privacy in adapter->scantable[i] */ | 548 | /* set up privacy in adapter->scantable[i] */ |
669 | if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { | 549 | if (adapter->secinfo.wep_enabled) { |
670 | 550 | lbs_pr_debug(1, "ADHOC_S_CMD: WEP enabled, setting privacy on\n"); | |
671 | #define AD_HOC_CAP_PRIVACY_ON 1 | ||
672 | lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus set, privacy to WEP\n"); | ||
673 | pbssdesc->privacy = wlan802_11privfilter8021xWEP; | 551 | pbssdesc->privacy = wlan802_11privfilter8021xWEP; |
674 | adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON; | 552 | adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON; |
675 | } else { | 553 | } else { |
676 | lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus NOT set, Setting " | 554 | lbs_pr_debug(1, "ADHOC_S_CMD: WEP disabled, setting privacy off\n"); |
677 | "privacy to ACCEPT ALL\n"); | ||
678 | pbssdesc->privacy = wlan802_11privfilteracceptall; | 555 | pbssdesc->privacy = wlan802_11privfilteracceptall; |
679 | } | 556 | } |
680 | 557 | ||
@@ -786,9 +663,6 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv, | |||
786 | padhocjoin->bssdescriptor.BSSID[5], | 663 | padhocjoin->bssdescriptor.BSSID[5], |
787 | padhocjoin->bssdescriptor.SSID); | 664 | padhocjoin->bssdescriptor.SSID); |
788 | 665 | ||
789 | lbs_pr_debug(1, "ADHOC_J_CMD: Data Rate = %x\n", | ||
790 | (u32) padhocjoin->bssdescriptor.datarates); | ||
791 | |||
792 | /* failtimeout */ | 666 | /* failtimeout */ |
793 | padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); | 667 | padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); |
794 | 668 | ||
@@ -832,7 +706,7 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv, | |||
832 | padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow = | 706 | padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow = |
833 | cpu_to_le16(pbssdesc->atimwindow); | 707 | cpu_to_le16(pbssdesc->atimwindow); |
834 | 708 | ||
835 | if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { | 709 | if (adapter->secinfo.wep_enabled) { |
836 | padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON; | 710 | padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON; |
837 | } | 711 | } |
838 | 712 | ||
diff --git a/drivers/net/wireless/libertas/join.h b/drivers/net/wireless/libertas/join.h index 8efa2455af9a..115f5a8ba346 100644 --- a/drivers/net/wireless/libertas/join.h +++ b/drivers/net/wireless/libertas/join.h | |||
@@ -1,6 +1,3 @@ | |||
1 | /* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ | ||
2 | /* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ | ||
3 | |||
4 | /** | 1 | /** |
5 | * Interface for the wlan infrastructure and adhoc join routines | 2 | * Interface for the wlan infrastructure and adhoc join routines |
6 | * | 3 | * |
@@ -40,10 +37,6 @@ extern int libertas_ret_80211_disassociate(wlan_private * priv, | |||
40 | extern int libertas_ret_80211_associate(wlan_private * priv, | 37 | extern int libertas_ret_80211_associate(wlan_private * priv, |
41 | struct cmd_ds_command *resp); | 38 | struct cmd_ds_command *resp); |
42 | 39 | ||
43 | extern int libertas_idle_on(wlan_private * priv); | ||
44 | extern int libertas_idle_off(wlan_private * priv); | ||
45 | |||
46 | extern int libertas_do_adhocstop_ioctl(wlan_private * priv); | ||
47 | extern int libertas_reassociation_thread(void *data); | 40 | extern int libertas_reassociation_thread(void *data); |
48 | 41 | ||
49 | struct WLAN_802_11_SSID; | 42 | struct WLAN_802_11_SSID; |
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index dcbf102a057e..b9b25ce65919 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c | |||
@@ -21,6 +21,13 @@ | |||
21 | #include "debugfs.h" | 21 | #include "debugfs.h" |
22 | #include "assoc.h" | 22 | #include "assoc.h" |
23 | 23 | ||
24 | #define DRIVER_RELEASE_VERSION "320.p0" | ||
25 | const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION | ||
26 | #ifdef DEBUG | ||
27 | "-dbg" | ||
28 | #endif | ||
29 | ""; | ||
30 | |||
24 | #ifdef ENABLE_PM | 31 | #ifdef ENABLE_PM |
25 | static struct pm_dev *wlan_pm_dev = NULL; | 32 | static struct pm_dev *wlan_pm_dev = NULL; |
26 | #endif | 33 | #endif |
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c index 7e3f78f092dc..d17924f764e5 100644 --- a/drivers/net/wireless/libertas/rx.c +++ b/drivers/net/wireless/libertas/rx.c | |||
@@ -210,7 +210,7 @@ int libertas_process_rxed_packet(wlan_private * priv, struct sk_buff *skb) | |||
210 | goto done; | 210 | goto done; |
211 | } | 211 | } |
212 | 212 | ||
213 | lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", | 213 | lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n", |
214 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); | 214 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); |
215 | 215 | ||
216 | lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr, | 216 | lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr, |
@@ -364,7 +364,7 @@ static int process_rxed_802_11_packet(wlan_private * priv, struct sk_buff *skb) | |||
364 | priv->stats.rx_errors++; | 364 | priv->stats.rx_errors++; |
365 | } | 365 | } |
366 | 366 | ||
367 | lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", | 367 | lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n", |
368 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); | 368 | skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); |
369 | 369 | ||
370 | /* create the exported radio header */ | 370 | /* create the exported radio header */ |
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c index e18706238951..3c0b1a2a1727 100644 --- a/drivers/net/wireless/libertas/scan.c +++ b/drivers/net/wireless/libertas/scan.c | |||
@@ -1,6 +1,3 @@ | |||
1 | /* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ | ||
2 | /* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ | ||
3 | |||
4 | /** | 1 | /** |
5 | * Functions implementing wlan scan IOCTL and firmware command APIs | 2 | * Functions implementing wlan scan IOCTL and firmware command APIs |
6 | * | 3 | * |
@@ -87,118 +84,95 @@ | |||
87 | * | 84 | * |
88 | * @return Index in scantable, or error code if negative | 85 | * @return Index in scantable, or error code if negative |
89 | */ | 86 | */ |
90 | static int is_network_compatible(wlan_adapter * adapter, int index, int mode) | 87 | static int is_network_compatible(wlan_adapter * adapter, int index, u8 mode) |
91 | { | 88 | { |
92 | ENTER(); | 89 | ENTER(); |
93 | 90 | ||
94 | if (adapter->scantable[index].inframode == mode) { | 91 | if (adapter->scantable[index].mode == mode) { |
95 | if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled | 92 | if ( !adapter->secinfo.wep_enabled |
96 | && !adapter->secinfo.WPAenabled | 93 | && !adapter->secinfo.WPAenabled |
97 | && !adapter->secinfo.WPA2enabled | 94 | && !adapter->secinfo.WPA2enabled |
98 | && adapter->scantable[index].wpa_supplicant.wpa_ie[0] != | 95 | && adapter->scantable[index].wpa_ie[0] != WPA_IE |
99 | WPA_IE | 96 | && adapter->scantable[index].rsn_ie[0] != WPA2_IE |
100 | && adapter->scantable[index].wpa2_supplicant.wpa_ie[0] != | ||
101 | WPA2_IE && adapter->secinfo.Encryptionmode == CIPHER_NONE | ||
102 | && !adapter->scantable[index].privacy) { | 97 | && !adapter->scantable[index].privacy) { |
103 | /* no security */ | 98 | /* no security */ |
104 | LEAVE(); | 99 | LEAVE(); |
105 | return index; | 100 | return index; |
106 | } else if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled | 101 | } else if ( adapter->secinfo.wep_enabled |
107 | && !adapter->secinfo.WPAenabled | 102 | && !adapter->secinfo.WPAenabled |
108 | && !adapter->secinfo.WPA2enabled | 103 | && !adapter->secinfo.WPA2enabled |
109 | && adapter->scantable[index].privacy) { | 104 | && adapter->scantable[index].privacy) { |
110 | /* static WEP enabled */ | 105 | /* static WEP enabled */ |
111 | LEAVE(); | 106 | LEAVE(); |
112 | return index; | 107 | return index; |
113 | } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled | 108 | } else if ( !adapter->secinfo.wep_enabled |
114 | && adapter->secinfo.WPAenabled | 109 | && adapter->secinfo.WPAenabled |
115 | && !adapter->secinfo.WPA2enabled | 110 | && !adapter->secinfo.WPA2enabled |
116 | && (adapter->scantable[index].wpa_supplicant. | 111 | && (adapter->scantable[index].wpa_ie[0] == WPA_IE) |
117 | wpa_ie[0] | ||
118 | == WPA_IE) | ||
119 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G | 112 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
120 | && adapter->scantable[index].privacy */ | 113 | && adapter->scantable[index].privacy */ |
121 | ) { | 114 | ) { |
122 | /* WPA enabled */ | 115 | /* WPA enabled */ |
123 | lbs_pr_debug(1, | 116 | lbs_pr_debug(1, |
124 | "is_network_compatible() WPA: index=%d wpa_ie=%#x " | 117 | "is_network_compatible() WPA: index=%d wpa_ie=%#x " |
125 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " | 118 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " |
126 | "privacy=%#x\n", index, | 119 | "privacy=%#x\n", index, |
127 | adapter->scantable[index].wpa_supplicant. | 120 | adapter->scantable[index].wpa_ie[0], |
128 | wpa_ie[0], | 121 | adapter->scantable[index].rsn_ie[0], |
129 | adapter->scantable[index].wpa2_supplicant. | 122 | adapter->secinfo.wep_enabled ? "e" : "d", |
130 | wpa_ie[0], | 123 | adapter->secinfo.WPAenabled ? "e" : "d", |
131 | (adapter->secinfo.WEPstatus == | 124 | adapter->secinfo.WPA2enabled ? "e" : "d", |
132 | wlan802_11WEPenabled) ? "e" : "d", | ||
133 | (adapter->secinfo.WPAenabled) ? "e" : "d", | ||
134 | (adapter->secinfo.WPA2enabled) ? "e" : "d", | ||
135 | adapter->secinfo.Encryptionmode, | ||
136 | adapter->scantable[index].privacy); | 125 | adapter->scantable[index].privacy); |
137 | LEAVE(); | 126 | LEAVE(); |
138 | return index; | 127 | return index; |
139 | } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled | 128 | } else if ( !adapter->secinfo.wep_enabled |
140 | && !adapter->secinfo.WPAenabled | 129 | && !adapter->secinfo.WPAenabled |
141 | && adapter->secinfo.WPA2enabled | 130 | && adapter->secinfo.WPA2enabled |
142 | && (adapter->scantable[index].wpa2_supplicant. | 131 | && (adapter->scantable[index].rsn_ie[0] == WPA2_IE) |
143 | wpa_ie[0] | ||
144 | == WPA2_IE) | ||
145 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G | 132 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
146 | && adapter->scantable[index].privacy */ | 133 | && adapter->scantable[index].privacy */ |
147 | ) { | 134 | ) { |
148 | /* WPA2 enabled */ | 135 | /* WPA2 enabled */ |
149 | lbs_pr_debug(1, | 136 | lbs_pr_debug(1, |
150 | "is_network_compatible() WPA2: index=%d wpa_ie=%#x " | 137 | "is_network_compatible() WPA2: index=%d wpa_ie=%#x " |
151 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " | 138 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " |
152 | "privacy=%#x\n", index, | 139 | "privacy=%#x\n", index, |
153 | adapter->scantable[index].wpa_supplicant. | 140 | adapter->scantable[index].wpa_ie[0], |
154 | wpa_ie[0], | 141 | adapter->scantable[index].rsn_ie[0], |
155 | adapter->scantable[index].wpa2_supplicant. | 142 | adapter->secinfo.wep_enabled ? "e" : "d", |
156 | wpa_ie[0], | 143 | adapter->secinfo.WPAenabled ? "e" : "d", |
157 | (adapter->secinfo.WEPstatus == | 144 | adapter->secinfo.WPA2enabled ? "e" : "d", |
158 | wlan802_11WEPenabled) ? "e" : "d", | ||
159 | (adapter->secinfo.WPAenabled) ? "e" : "d", | ||
160 | (adapter->secinfo.WPA2enabled) ? "e" : "d", | ||
161 | adapter->secinfo.Encryptionmode, | ||
162 | adapter->scantable[index].privacy); | 145 | adapter->scantable[index].privacy); |
163 | LEAVE(); | 146 | LEAVE(); |
164 | return index; | 147 | return index; |
165 | } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled | 148 | } else if ( !adapter->secinfo.wep_enabled |
166 | && !adapter->secinfo.WPAenabled | 149 | && !adapter->secinfo.WPAenabled |
167 | && !adapter->secinfo.WPA2enabled | 150 | && !adapter->secinfo.WPA2enabled |
168 | && (adapter->scantable[index].wpa_supplicant. | 151 | && (adapter->scantable[index].wpa_ie[0] != WPA_IE) |
169 | wpa_ie[0] | 152 | && (adapter->scantable[index].rsn_ie[0] != WPA2_IE) |
170 | != WPA_IE) | ||
171 | && (adapter->scantable[index].wpa2_supplicant. | ||
172 | wpa_ie[0] | ||
173 | != WPA2_IE) | ||
174 | && adapter->secinfo.Encryptionmode != CIPHER_NONE | ||
175 | && adapter->scantable[index].privacy) { | 153 | && adapter->scantable[index].privacy) { |
176 | /* dynamic WEP enabled */ | 154 | /* dynamic WEP enabled */ |
177 | lbs_pr_debug(1, | 155 | lbs_pr_debug(1, |
178 | "is_network_compatible() dynamic WEP: index=%d " | 156 | "is_network_compatible() dynamic WEP: index=%d " |
179 | "wpa_ie=%#x wpa2_ie=%#x Encmode=%#x privacy=%#x\n", | 157 | "wpa_ie=%#x wpa2_ie=%#x privacy=%#x\n", |
180 | index, | 158 | index, |
181 | adapter->scantable[index].wpa_supplicant. | 159 | adapter->scantable[index].wpa_ie[0], |
182 | wpa_ie[0], | 160 | adapter->scantable[index].rsn_ie[0], |
183 | adapter->scantable[index].wpa2_supplicant. | ||
184 | wpa_ie[0], adapter->secinfo.Encryptionmode, | ||
185 | adapter->scantable[index].privacy); | 161 | adapter->scantable[index].privacy); |
186 | LEAVE(); | 162 | LEAVE(); |
187 | return index; | 163 | return index; |
188 | } | 164 | } |
189 | 165 | ||
190 | /* security doesn't match */ | 166 | /* security doesn't match */ |
191 | lbs_pr_debug(1, | 167 | lbs_pr_debug(1, |
192 | "is_network_compatible() FAILED: index=%d wpa_ie=%#x " | 168 | "is_network_compatible() FAILED: index=%d wpa_ie=%#x " |
193 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x privacy=%#x\n", | 169 | "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s privacy=%#x\n", |
194 | index, | 170 | index, |
195 | adapter->scantable[index].wpa_supplicant.wpa_ie[0], | 171 | adapter->scantable[index].wpa_ie[0], |
196 | adapter->scantable[index].wpa2_supplicant.wpa_ie[0], | 172 | adapter->scantable[index].rsn_ie[0], |
197 | (adapter->secinfo.WEPstatus == | 173 | adapter->secinfo.wep_enabled ? "e" : "d", |
198 | wlan802_11WEPenabled) ? "e" : "d", | 174 | adapter->secinfo.WPAenabled ? "e" : "d", |
199 | (adapter->secinfo.WPAenabled) ? "e" : "d", | 175 | adapter->secinfo.WPA2enabled ? "e" : "d", |
200 | (adapter->secinfo.WPA2enabled) ? "e" : "d", | ||
201 | adapter->secinfo.Encryptionmode, | ||
202 | adapter->scantable[index].privacy); | 176 | adapter->scantable[index].privacy); |
203 | LEAVE(); | 177 | LEAVE(); |
204 | return -ECONNREFUSED; | 178 | return -ECONNREFUSED; |
@@ -924,8 +898,6 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
924 | u8 founddatarateie; | 898 | u8 founddatarateie; |
925 | int bytesleftforcurrentbeacon; | 899 | int bytesleftforcurrentbeacon; |
926 | 900 | ||
927 | struct WPA_SUPPLICANT *pwpa_supplicant; | ||
928 | struct WPA_SUPPLICANT *pwpa2_supplicant; | ||
929 | struct IE_WPA *pIe; | 901 | struct IE_WPA *pIe; |
930 | const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 }; | 902 | const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 }; |
931 | 903 | ||
@@ -962,9 +934,6 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
962 | 934 | ||
963 | bytesleftforcurrentbeacon = beaconsize; | 935 | bytesleftforcurrentbeacon = beaconsize; |
964 | 936 | ||
965 | pwpa_supplicant = &pBSSEntry->wpa_supplicant; | ||
966 | pwpa2_supplicant = &pBSSEntry->wpa2_supplicant; | ||
967 | |||
968 | memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN); | 937 | memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN); |
969 | lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n", | 938 | lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n", |
970 | pBSSEntry->macaddress[0], pBSSEntry->macaddress[1], | 939 | pBSSEntry->macaddress[0], pBSSEntry->macaddress[1], |
@@ -1027,9 +996,9 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
1027 | } | 996 | } |
1028 | 997 | ||
1029 | if (pcap->ibss == 1) { | 998 | if (pcap->ibss == 1) { |
1030 | pBSSEntry->inframode = wlan802_11ibss; | 999 | pBSSEntry->mode = IW_MODE_ADHOC; |
1031 | } else { | 1000 | } else { |
1032 | pBSSEntry->inframode = wlan802_11infrastructure; | 1001 | pBSSEntry->mode = IW_MODE_INFRA; |
1033 | } | 1002 | } |
1034 | 1003 | ||
1035 | /* process variable IE */ | 1004 | /* process variable IE */ |
@@ -1116,7 +1085,7 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
1116 | sizeof(pcountryinfo->countrycode) | 1085 | sizeof(pcountryinfo->countrycode) |
1117 | || pcountryinfo->len > 254) { | 1086 | || pcountryinfo->len > 254) { |
1118 | lbs_pr_debug(1, "InterpretIE: 11D- Err " | 1087 | lbs_pr_debug(1, "InterpretIE: 11D- Err " |
1119 | "CountryInfo len =%d min=%d max=254\n", | 1088 | "CountryInfo len =%d min=%zd max=254\n", |
1120 | pcountryinfo->len, | 1089 | pcountryinfo->len, |
1121 | sizeof(pcountryinfo->countrycode)); | 1090 | sizeof(pcountryinfo->countrycode)); |
1122 | LEAVE(); | 1091 | LEAVE(); |
@@ -1160,27 +1129,27 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, | |||
1160 | #define IE_ID_LEN_FIELDS_BYTES 2 | 1129 | #define IE_ID_LEN_FIELDS_BYTES 2 |
1161 | pIe = (struct IE_WPA *)pcurrentptr; | 1130 | pIe = (struct IE_WPA *)pcurrentptr; |
1162 | 1131 | ||
1163 | if (!memcmp(pIe->oui, oui01, sizeof(oui01))) { | 1132 | if (memcmp(pIe->oui, oui01, sizeof(oui01))) |
1164 | pwpa_supplicant->wpa_ie_len | 1133 | break; |
1165 | = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES, | 1134 | |
1166 | sizeof(pwpa_supplicant->wpa_ie)); | 1135 | pBSSEntry->wpa_ie_len = min_t(size_t, |
1167 | memcpy(pwpa_supplicant->wpa_ie, | 1136 | elemlen + IE_ID_LEN_FIELDS_BYTES, |
1168 | pcurrentptr, | 1137 | sizeof(pBSSEntry->wpa_ie)); |
1169 | pwpa_supplicant->wpa_ie_len); | 1138 | memcpy(pBSSEntry->wpa_ie, pcurrentptr, |
1170 | lbs_dbg_hex("InterpretIE: Resp WPA_IE", | 1139 | pBSSEntry->wpa_ie_len); |
1171 | pwpa_supplicant->wpa_ie, elemlen); | 1140 | lbs_dbg_hex("InterpretIE: Resp WPA_IE", |
1172 | } | 1141 | pBSSEntry->wpa_ie, elemlen); |
1173 | break; | 1142 | break; |
1174 | case WPA2_IE: | 1143 | case WPA2_IE: |
1175 | pIe = (struct IE_WPA *)pcurrentptr; | 1144 | pIe = (struct IE_WPA *)pcurrentptr; |
1176 | pwpa2_supplicant->wpa_ie_len | ||
1177 | = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES, | ||
1178 | sizeof(pwpa2_supplicant->wpa_ie)); | ||
1179 | memcpy(pwpa2_supplicant->wpa_ie, | ||
1180 | pcurrentptr, pwpa2_supplicant->wpa_ie_len); | ||
1181 | 1145 | ||
1146 | pBSSEntry->rsn_ie_len = min_t(size_t, | ||
1147 | elemlen + IE_ID_LEN_FIELDS_BYTES, | ||
1148 | sizeof(pBSSEntry->rsn_ie)); | ||
1149 | memcpy(pBSSEntry->rsn_ie, pcurrentptr, | ||
1150 | pBSSEntry->rsn_ie_len); | ||
1182 | lbs_dbg_hex("InterpretIE: Resp WPA2_IE", | 1151 | lbs_dbg_hex("InterpretIE: Resp WPA2_IE", |
1183 | pwpa2_supplicant->wpa_ie, elemlen); | 1152 | pBSSEntry->rsn_ie, elemlen); |
1184 | break; | 1153 | break; |
1185 | case TIM: | 1154 | case TIM: |
1186 | break; | 1155 | break; |
@@ -1227,7 +1196,7 @@ int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, struct WLAN_802_11_SSID *s | |||
1227 | * | 1196 | * |
1228 | * @return index in BSSID list, or error return code (< 0) | 1197 | * @return index in BSSID list, or error return code (< 0) |
1229 | */ | 1198 | */ |
1230 | int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) | 1199 | int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode) |
1231 | { | 1200 | { |
1232 | int ret = -ENETUNREACH; | 1201 | int ret = -ENETUNREACH; |
1233 | int i; | 1202 | int i; |
@@ -1247,8 +1216,8 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) | |||
1247 | for (i = 0; ret < 0 && i < adapter->numinscantable; i++) { | 1216 | for (i = 0; ret < 0 && i < adapter->numinscantable; i++) { |
1248 | if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) { | 1217 | if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) { |
1249 | switch (mode) { | 1218 | switch (mode) { |
1250 | case wlan802_11infrastructure: | 1219 | case IW_MODE_INFRA: |
1251 | case wlan802_11ibss: | 1220 | case IW_MODE_ADHOC: |
1252 | ret = is_network_compatible(adapter, i, mode); | 1221 | ret = is_network_compatible(adapter, i, mode); |
1253 | break; | 1222 | break; |
1254 | default: | 1223 | default: |
@@ -1272,7 +1241,7 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) | |||
1272 | * @return index in BSSID list | 1241 | * @return index in BSSID list |
1273 | */ | 1242 | */ |
1274 | int libertas_find_SSID_in_list(wlan_adapter * adapter, | 1243 | int libertas_find_SSID_in_list(wlan_adapter * adapter, |
1275 | struct WLAN_802_11_SSID *ssid, u8 * bssid, int mode) | 1244 | struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode) |
1276 | { | 1245 | { |
1277 | int net = -ENETUNREACH; | 1246 | int net = -ENETUNREACH; |
1278 | u8 bestrssi = 0; | 1247 | u8 bestrssi = 0; |
@@ -1287,8 +1256,8 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, | |||
1287 | !memcmp(adapter->scantable[i]. | 1256 | !memcmp(adapter->scantable[i]. |
1288 | macaddress, bssid, ETH_ALEN))) { | 1257 | macaddress, bssid, ETH_ALEN))) { |
1289 | switch (mode) { | 1258 | switch (mode) { |
1290 | case wlan802_11infrastructure: | 1259 | case IW_MODE_INFRA: |
1291 | case wlan802_11ibss: | 1260 | case IW_MODE_ADHOC: |
1292 | j = is_network_compatible(adapter, i, mode); | 1261 | j = is_network_compatible(adapter, i, mode); |
1293 | 1262 | ||
1294 | if (j >= 0) { | 1263 | if (j >= 0) { |
@@ -1311,7 +1280,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, | |||
1311 | } | 1280 | } |
1312 | } | 1281 | } |
1313 | break; | 1282 | break; |
1314 | case wlan802_11autounknown: | 1283 | case IW_MODE_AUTO: |
1315 | default: | 1284 | default: |
1316 | if (SCAN_RSSI(adapter->scantable[i].rssi) | 1285 | if (SCAN_RSSI(adapter->scantable[i].rssi) |
1317 | > bestrssi) { | 1286 | > bestrssi) { |
@@ -1338,8 +1307,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, | |||
1338 | * | 1307 | * |
1339 | * @return index in BSSID list | 1308 | * @return index in BSSID list |
1340 | */ | 1309 | */ |
1341 | int libertas_find_best_SSID_in_list(wlan_adapter * adapter, | 1310 | int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode) |
1342 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode) | ||
1343 | { | 1311 | { |
1344 | int bestnet = -ENETUNREACH; | 1312 | int bestnet = -ENETUNREACH; |
1345 | u8 bestrssi = 0; | 1313 | u8 bestrssi = 0; |
@@ -1351,8 +1319,8 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, | |||
1351 | 1319 | ||
1352 | for (i = 0; i < adapter->numinscantable; i++) { | 1320 | for (i = 0; i < adapter->numinscantable; i++) { |
1353 | switch (mode) { | 1321 | switch (mode) { |
1354 | case wlan802_11infrastructure: | 1322 | case IW_MODE_INFRA: |
1355 | case wlan802_11ibss: | 1323 | case IW_MODE_ADHOC: |
1356 | if (is_network_compatible(adapter, i, mode) >= 0) { | 1324 | if (is_network_compatible(adapter, i, mode) >= 0) { |
1357 | if (SCAN_RSSI(adapter->scantable[i].rssi) > | 1325 | if (SCAN_RSSI(adapter->scantable[i].rssi) > |
1358 | bestrssi) { | 1326 | bestrssi) { |
@@ -1363,7 +1331,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, | |||
1363 | } | 1331 | } |
1364 | } | 1332 | } |
1365 | break; | 1333 | break; |
1366 | case wlan802_11autounknown: | 1334 | case IW_MODE_AUTO: |
1367 | default: | 1335 | default: |
1368 | if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { | 1336 | if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { |
1369 | bestrssi = | 1337 | bestrssi = |
@@ -1388,8 +1356,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, | |||
1388 | */ | 1356 | */ |
1389 | int libertas_find_best_network_SSID(wlan_private * priv, | 1357 | int libertas_find_best_network_SSID(wlan_private * priv, |
1390 | struct WLAN_802_11_SSID *pSSID, | 1358 | struct WLAN_802_11_SSID *pSSID, |
1391 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, | 1359 | u8 preferred_mode, u8 *out_mode) |
1392 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode) | ||
1393 | { | 1360 | { |
1394 | wlan_adapter *adapter = priv->adapter; | 1361 | wlan_adapter *adapter = priv->adapter; |
1395 | int ret = 0; | 1362 | int ret = 0; |
@@ -1414,7 +1381,7 @@ int libertas_find_best_network_SSID(wlan_private * priv, | |||
1414 | preqbssid = &adapter->scantable[i]; | 1381 | preqbssid = &adapter->scantable[i]; |
1415 | memcpy(pSSID, &preqbssid->ssid, | 1382 | memcpy(pSSID, &preqbssid->ssid, |
1416 | sizeof(struct WLAN_802_11_SSID)); | 1383 | sizeof(struct WLAN_802_11_SSID)); |
1417 | *out_mode = preqbssid->inframode; | 1384 | *out_mode = preqbssid->mode; |
1418 | 1385 | ||
1419 | if (!pSSID->ssidlength) { | 1386 | if (!pSSID->ssidlength) { |
1420 | ret = -1; | 1387 | ret = -1; |
@@ -1584,7 +1551,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1584 | for (i = 0; i < adapter->numinscantable; i++) { | 1551 | for (i = 0; i < adapter->numinscantable; i++) { |
1585 | if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) { | 1552 | if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) { |
1586 | lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p " | 1553 | lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p " |
1587 | "MAX_SCAN_CELL_SIZE=%d\n", | 1554 | "MAX_SCAN_CELL_SIZE=%zd\n", |
1588 | i, current_ev, end_buf, MAX_SCAN_CELL_SIZE); | 1555 | i, current_ev, end_buf, MAX_SCAN_CELL_SIZE); |
1589 | break; | 1556 | break; |
1590 | } | 1557 | } |
@@ -1632,7 +1599,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1632 | 1599 | ||
1633 | //Add mode | 1600 | //Add mode |
1634 | iwe.cmd = SIOCGIWMODE; | 1601 | iwe.cmd = SIOCGIWMODE; |
1635 | iwe.u.mode = adapter->scantable[i].inframode + 1; | 1602 | iwe.u.mode = adapter->scantable[i].mode; |
1636 | iwe.len = IW_EV_UINT_LEN; | 1603 | iwe.len = IW_EV_UINT_LEN; |
1637 | current_ev = | 1604 | current_ev = |
1638 | iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); | 1605 | iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); |
@@ -1666,7 +1633,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1666 | iwe.u.qual.noise = | 1633 | iwe.u.qual.noise = |
1667 | CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); | 1634 | CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); |
1668 | } | 1635 | } |
1669 | if ((adapter->inframode == wlan802_11ibss) && | 1636 | if ((adapter->mode == IW_MODE_ADHOC) && |
1670 | !libertas_SSID_cmp(&adapter->curbssparams.ssid, | 1637 | !libertas_SSID_cmp(&adapter->curbssparams.ssid, |
1671 | &adapter->scantable[i].ssid) | 1638 | &adapter->scantable[i].ssid) |
1672 | && adapter->adhoccreate) { | 1639 | && adapter->adhoccreate) { |
@@ -1731,7 +1698,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1731 | end_buf, &iwe, iwe.len); | 1698 | end_buf, &iwe, iwe.len); |
1732 | 1699 | ||
1733 | } | 1700 | } |
1734 | if ((adapter->scantable[i].inframode == wlan802_11ibss) | 1701 | if ((adapter->scantable[i].mode == IW_MODE_ADHOC) |
1735 | && !libertas_SSID_cmp(&adapter->curbssparams.ssid, | 1702 | && !libertas_SSID_cmp(&adapter->curbssparams.ssid, |
1736 | &adapter->scantable[i].ssid) | 1703 | &adapter->scantable[i].ssid) |
1737 | && adapter->adhoccreate) { | 1704 | && adapter->adhoccreate) { |
@@ -1745,30 +1712,24 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1745 | /* Add new value to event */ | 1712 | /* Add new value to event */ |
1746 | current_val = current_ev + IW_EV_LCP_LEN; | 1713 | current_val = current_ev + IW_EV_LCP_LEN; |
1747 | 1714 | ||
1748 | if (adapter->scantable[i].wpa2_supplicant.wpa_ie[0] == WPA2_IE) { | 1715 | if (adapter->scantable[i].rsn_ie[0] == WPA2_IE) { |
1749 | memset(&iwe, 0, sizeof(iwe)); | 1716 | memset(&iwe, 0, sizeof(iwe)); |
1750 | memset(buf, 0, sizeof(buf)); | 1717 | memset(buf, 0, sizeof(buf)); |
1751 | memcpy(buf, adapter->scantable[i]. | 1718 | memcpy(buf, adapter->scantable[i].rsn_ie, |
1752 | wpa2_supplicant.wpa_ie, | 1719 | adapter->scantable[i].rsn_ie_len); |
1753 | adapter->scantable[i].wpa2_supplicant. | ||
1754 | wpa_ie_len); | ||
1755 | iwe.cmd = IWEVGENIE; | 1720 | iwe.cmd = IWEVGENIE; |
1756 | iwe.u.data.length = adapter->scantable[i]. | 1721 | iwe.u.data.length = adapter->scantable[i].rsn_ie_len; |
1757 | wpa2_supplicant.wpa_ie_len; | ||
1758 | iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; | 1722 | iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; |
1759 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 1723 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
1760 | &iwe, buf); | 1724 | &iwe, buf); |
1761 | } | 1725 | } |
1762 | if (adapter->scantable[i].wpa_supplicant.wpa_ie[0] == WPA_IE) { | 1726 | if (adapter->scantable[i].wpa_ie[0] == WPA_IE) { |
1763 | memset(&iwe, 0, sizeof(iwe)); | 1727 | memset(&iwe, 0, sizeof(iwe)); |
1764 | memset(buf, 0, sizeof(buf)); | 1728 | memset(buf, 0, sizeof(buf)); |
1765 | memcpy(buf, adapter->scantable[i]. | 1729 | memcpy(buf, adapter->scantable[i].wpa_ie, |
1766 | wpa_supplicant.wpa_ie, | 1730 | adapter->scantable[i].wpa_ie_len); |
1767 | adapter->scantable[i].wpa_supplicant. | ||
1768 | wpa_ie_len); | ||
1769 | iwe.cmd = IWEVGENIE; | 1731 | iwe.cmd = IWEVGENIE; |
1770 | iwe.u.data.length = adapter->scantable[i]. | 1732 | iwe.u.data.length = adapter->scantable[i].wpa_ie_len; |
1771 | wpa_supplicant.wpa_ie_len; | ||
1772 | iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; | 1733 | iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; |
1773 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 1734 | current_ev = iwe_stream_add_point(current_ev, end_buf, |
1774 | &iwe, buf); | 1735 | &iwe, buf); |
diff --git a/drivers/net/wireless/libertas/scan.h b/drivers/net/wireless/libertas/scan.h index d93aa7fa44fd..405f4f0fe575 100644 --- a/drivers/net/wireless/libertas/scan.h +++ b/drivers/net/wireless/libertas/scan.h | |||
@@ -1,6 +1,3 @@ | |||
1 | /* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ | ||
2 | /* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ | ||
3 | |||
4 | /** | 1 | /** |
5 | * Interface for the wlan network scan routines | 2 | * Interface for the wlan network scan routines |
6 | * | 3 | * |
@@ -10,6 +7,7 @@ | |||
10 | #ifndef _WLAN_SCAN_H | 7 | #ifndef _WLAN_SCAN_H |
11 | #define _WLAN_SCAN_H | 8 | #define _WLAN_SCAN_H |
12 | 9 | ||
10 | #include <net/ieee80211.h> | ||
13 | #include "hostcmd.h" | 11 | #include "hostcmd.h" |
14 | 12 | ||
15 | /** | 13 | /** |
@@ -155,7 +153,7 @@ struct bss_descriptor { | |||
155 | 153 | ||
156 | u32 atimwindow; | 154 | u32 atimwindow; |
157 | 155 | ||
158 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; | 156 | u8 mode; |
159 | u8 libertas_supported_rates[WLAN_SUPPORTED_RATES]; | 157 | u8 libertas_supported_rates[WLAN_SUPPORTED_RATES]; |
160 | 158 | ||
161 | int extra_ie; | 159 | int extra_ie; |
@@ -170,22 +168,22 @@ struct bss_descriptor { | |||
170 | 168 | ||
171 | struct ieeetypes_countryinfofullset countryinfo; | 169 | struct ieeetypes_countryinfofullset countryinfo; |
172 | 170 | ||
173 | struct WPA_SUPPLICANT wpa_supplicant; | 171 | u8 wpa_ie[MAX_WPA_IE_LEN]; |
174 | struct WPA_SUPPLICANT wpa2_supplicant; | 172 | size_t wpa_ie_len; |
175 | 173 | u8 rsn_ie[MAX_WPA_IE_LEN]; | |
174 | size_t rsn_ie_len; | ||
176 | }; | 175 | }; |
177 | 176 | ||
178 | extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, | 177 | extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, |
179 | struct WLAN_802_11_SSID *ssid2); | 178 | struct WLAN_802_11_SSID *ssid2); |
180 | extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid, | 179 | extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid, |
181 | u8 * bssid, int mode); | 180 | u8 * bssid, u8 mode); |
182 | int libertas_find_best_SSID_in_list(wlan_adapter * adapter, enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode); | 181 | int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode); |
183 | extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode); | 182 | extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode); |
184 | 183 | ||
185 | int libertas_find_best_network_SSID(wlan_private * priv, | 184 | int libertas_find_best_network_SSID(wlan_private * priv, |
186 | struct WLAN_802_11_SSID *pSSID, | 185 | struct WLAN_802_11_SSID *pSSID, |
187 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, | 186 | u8 preferred_mode, u8 *out_mode); |
188 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode); | ||
189 | 187 | ||
190 | extern int libertas_send_specific_SSID_scan(wlan_private * priv, | 188 | extern int libertas_send_specific_SSID_scan(wlan_private * priv, |
191 | struct WLAN_802_11_SSID *prequestedssid, | 189 | struct WLAN_802_11_SSID *prequestedssid, |
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c index 82d06223043e..d4b13478c9a7 100644 --- a/drivers/net/wireless/libertas/tx.c +++ b/drivers/net/wireless/libertas/tx.c | |||
@@ -78,7 +78,7 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb) | |||
78 | min_t(unsigned int, skb->len, 100)); | 78 | min_t(unsigned int, skb->len, 100)); |
79 | 79 | ||
80 | if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { | 80 | if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { |
81 | lbs_pr_debug(1, "Tx error: Bad skb length %d : %d\n", | 81 | lbs_pr_debug(1, "Tx error: Bad skb length %d : %zd\n", |
82 | skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE); | 82 | skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE); |
83 | ret = -1; | 83 | ret = -1; |
84 | goto done; | 84 | goto done; |
diff --git a/drivers/net/wireless/libertas/version.h b/drivers/net/wireless/libertas/version.h index e86f65ae79b8..8b137891791f 100644 --- a/drivers/net/wireless/libertas/version.h +++ b/drivers/net/wireless/libertas/version.h | |||
@@ -1,8 +1 @@ | |||
1 | #define DRIVER_RELEASE_VERSION "320.p0" | ||
2 | const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION | ||
3 | #ifdef DEBUG | ||
4 | "-dbg" | ||
5 | #endif | ||
6 | ""; | ||
7 | |||
8 | |||
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index 4a52336bc0f6..69f52b6e59c8 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include "defs.h" | 17 | #include "defs.h" |
18 | #include "dev.h" | 18 | #include "dev.h" |
19 | #include "join.h" | 19 | #include "join.h" |
20 | #include "version.h" | ||
21 | #include "wext.h" | 20 | #include "wext.h" |
22 | #include "assoc.h" | 21 | #include "assoc.h" |
23 | 22 | ||
@@ -233,7 +232,7 @@ static int changeadhocchannel(wlan_private * priv, int channel) | |||
233 | 232 | ||
234 | // find out the BSSID that matches the current SSID | 233 | // find out the BSSID that matches the current SSID |
235 | i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL, | 234 | i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL, |
236 | wlan802_11ibss); | 235 | IW_MODE_ADHOC); |
237 | 236 | ||
238 | if (i >= 0) { | 237 | if (i >= 0) { |
239 | lbs_pr_debug(1, "SSID found at %d in List," | 238 | lbs_pr_debug(1, "SSID found at %d in List," |
@@ -316,13 +315,11 @@ static int get_active_data_rates(wlan_adapter * adapter, | |||
316 | ENTER(); | 315 | ENTER(); |
317 | 316 | ||
318 | if (adapter->connect_status != libertas_connected) { | 317 | if (adapter->connect_status != libertas_connected) { |
319 | if (adapter->inframode == wlan802_11infrastructure) { | 318 | if (adapter->mode == IW_MODE_INFRA) { |
320 | //Infra. mode | ||
321 | lbs_pr_debug(1, "Infra\n"); | 319 | lbs_pr_debug(1, "Infra\n"); |
322 | k = copyrates(rates, k, libertas_supported_rates, | 320 | k = copyrates(rates, k, libertas_supported_rates, |
323 | sizeof(libertas_supported_rates)); | 321 | sizeof(libertas_supported_rates)); |
324 | } else { | 322 | } else { |
325 | //ad-hoc mode | ||
326 | lbs_pr_debug(1, "Adhoc G\n"); | 323 | lbs_pr_debug(1, "Adhoc G\n"); |
327 | k = copyrates(rates, k, libertas_adhoc_rates_g, | 324 | k = copyrates(rates, k, libertas_adhoc_rates_g, |
328 | sizeof(libertas_adhoc_rates_g)); | 325 | sizeof(libertas_adhoc_rates_g)); |
@@ -586,20 +583,7 @@ static int wlan_get_mode(struct net_device *dev, | |||
586 | 583 | ||
587 | ENTER(); | 584 | ENTER(); |
588 | 585 | ||
589 | switch (adapter->inframode) { | 586 | *uwrq = adapter->mode; |
590 | case wlan802_11ibss: | ||
591 | *uwrq = IW_MODE_ADHOC; | ||
592 | break; | ||
593 | |||
594 | case wlan802_11infrastructure: | ||
595 | *uwrq = IW_MODE_INFRA; | ||
596 | break; | ||
597 | |||
598 | default: | ||
599 | case wlan802_11autounknown: | ||
600 | *uwrq = IW_MODE_AUTO; | ||
601 | break; | ||
602 | } | ||
603 | 587 | ||
604 | LEAVE(); | 588 | LEAVE(); |
605 | return 0; | 589 | return 0; |
@@ -1002,149 +986,18 @@ static const struct iw_priv_args wlan_private_args[] = { | |||
1002 | /* | 986 | /* |
1003 | * { cmd, set_args, get_args, name } | 987 | * { cmd, set_args, get_args, name } |
1004 | */ | 988 | */ |
1005 | { | ||
1006 | WLANSCAN_TYPE, | ||
1007 | IW_PRIV_TYPE_CHAR | 8, | ||
1008 | IW_PRIV_TYPE_CHAR | 8, | ||
1009 | "scantype"}, | ||
1010 | |||
1011 | { | ||
1012 | WLAN_SETINT_GETINT, | ||
1013 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1014 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1015 | ""}, | ||
1016 | { | ||
1017 | WLANNF, | ||
1018 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1019 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1020 | "getNF"}, | ||
1021 | { | ||
1022 | WLANRSSI, | ||
1023 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1024 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1025 | "getRSSI"}, | ||
1026 | { | ||
1027 | WLANENABLE11D, | ||
1028 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1029 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1030 | "enable11d"}, | ||
1031 | { | ||
1032 | WLANADHOCGRATE, | ||
1033 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1034 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1035 | "adhocgrate"}, | ||
1036 | |||
1037 | { | ||
1038 | WLAN_SUBCMD_SET_PRESCAN, | ||
1039 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1040 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1041 | "prescan"}, | ||
1042 | { | ||
1043 | WLAN_SETONEINT_GETONEINT, | ||
1044 | IW_PRIV_TYPE_INT | 1, | ||
1045 | IW_PRIV_TYPE_INT | 1, | ||
1046 | ""}, | ||
1047 | { | ||
1048 | WLAN_BEACON_INTERVAL, | ||
1049 | IW_PRIV_TYPE_INT | 1, | ||
1050 | IW_PRIV_TYPE_INT | 1, | ||
1051 | "bcninterval"}, | ||
1052 | { | ||
1053 | WLAN_LISTENINTRVL, | ||
1054 | IW_PRIV_TYPE_INT | 1, | ||
1055 | IW_PRIV_TYPE_INT | 1, | ||
1056 | "lolisteninter"}, | ||
1057 | { | ||
1058 | WLAN_TXCONTROL, | ||
1059 | IW_PRIV_TYPE_INT | 1, | ||
1060 | IW_PRIV_TYPE_INT | 1, | ||
1061 | "txcontrol"}, | ||
1062 | { | ||
1063 | WLAN_NULLPKTINTERVAL, | ||
1064 | IW_PRIV_TYPE_INT | 1, | ||
1065 | IW_PRIV_TYPE_INT | 1, | ||
1066 | "psnullinterval"}, | ||
1067 | /* Using iwpriv sub-command feature */ | 989 | /* Using iwpriv sub-command feature */ |
1068 | { | 990 | { |
1069 | WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */ | 991 | WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */ |
1070 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 992 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1071 | IW_PRIV_TYPE_NONE, | 993 | IW_PRIV_TYPE_NONE, |
1072 | ""}, | 994 | ""}, |
1073 | |||
1074 | { | ||
1075 | WLAN_SUBCMD_SETRXANTENNA, | ||
1076 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1077 | IW_PRIV_TYPE_NONE, | ||
1078 | "setrxant"}, | ||
1079 | { | ||
1080 | WLAN_SUBCMD_SETTXANTENNA, | ||
1081 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1082 | IW_PRIV_TYPE_NONE, | ||
1083 | "settxant"}, | ||
1084 | { | ||
1085 | WLANSETAUTHALG, | ||
1086 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1087 | IW_PRIV_TYPE_NONE, | ||
1088 | "authalgs", | ||
1089 | }, | ||
1090 | { | ||
1091 | WLANSET8021XAUTHALG, | ||
1092 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1093 | IW_PRIV_TYPE_NONE, | ||
1094 | "8021xauthalgs", | ||
1095 | }, | ||
1096 | { | ||
1097 | WLANSETENCRYPTIONMODE, | ||
1098 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1099 | IW_PRIV_TYPE_NONE, | ||
1100 | "encryptionmode", | ||
1101 | }, | ||
1102 | { | 995 | { |
1103 | WLANSETREGION, | 996 | WLANSETREGION, |
1104 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 997 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1105 | IW_PRIV_TYPE_NONE, | 998 | IW_PRIV_TYPE_NONE, |
1106 | "setregioncode"}, | 999 | "setregioncode"}, |
1107 | { | 1000 | { |
1108 | WLAN_SET_LISTEN_INTERVAL, | ||
1109 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1110 | IW_PRIV_TYPE_NONE, | ||
1111 | "setlisteninter"}, | ||
1112 | { | ||
1113 | WLAN_SET_MULTIPLE_DTIM, | ||
1114 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1115 | IW_PRIV_TYPE_NONE, | ||
1116 | "setmultipledtim"}, | ||
1117 | { | ||
1118 | WLAN_SET_ATIM_WINDOW, | ||
1119 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1120 | IW_PRIV_TYPE_NONE, | ||
1121 | "atimwindow"}, | ||
1122 | { | ||
1123 | WLANSETBCNAVG, | ||
1124 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1125 | IW_PRIV_TYPE_NONE, | ||
1126 | "setbcnavg"}, | ||
1127 | { | ||
1128 | WLANSETDATAAVG, | ||
1129 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1130 | IW_PRIV_TYPE_NONE, | ||
1131 | "setdataavg"}, | ||
1132 | { | ||
1133 | WLAN_SET_LINKMODE, | ||
1134 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1135 | IW_PRIV_TYPE_NONE, | ||
1136 | "linkmode"}, | ||
1137 | { | ||
1138 | WLAN_SET_RADIOMODE, | ||
1139 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1140 | IW_PRIV_TYPE_NONE, | ||
1141 | "radiomode"}, | ||
1142 | { | ||
1143 | WLAN_SET_DEBUGMODE, | ||
1144 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1145 | IW_PRIV_TYPE_NONE, | ||
1146 | "debugmode"}, | ||
1147 | { | ||
1148 | WLAN_SUBCMD_MESH_SET_TTL, | 1001 | WLAN_SUBCMD_MESH_SET_TTL, |
1149 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 1002 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1150 | IW_PRIV_TYPE_NONE, | 1003 | IW_PRIV_TYPE_NONE, |
@@ -1160,41 +1013,6 @@ static const struct iw_priv_args wlan_private_args[] = { | |||
1160 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 1013 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1161 | "getregioncode"}, | 1014 | "getregioncode"}, |
1162 | { | 1015 | { |
1163 | WLAN_GET_LISTEN_INTERVAL, | ||
1164 | IW_PRIV_TYPE_NONE, | ||
1165 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1166 | "getlisteninter"}, | ||
1167 | { | ||
1168 | WLAN_GET_MULTIPLE_DTIM, | ||
1169 | IW_PRIV_TYPE_NONE, | ||
1170 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1171 | "getmultipledtim"}, | ||
1172 | { | ||
1173 | WLAN_GET_TX_RATE, | ||
1174 | IW_PRIV_TYPE_NONE, | ||
1175 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1176 | "gettxrate"}, | ||
1177 | { | ||
1178 | WLANGETBCNAVG, | ||
1179 | IW_PRIV_TYPE_NONE, | ||
1180 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1181 | "getbcnavg"}, | ||
1182 | { | ||
1183 | WLAN_GET_LINKMODE, | ||
1184 | IW_PRIV_TYPE_NONE, | ||
1185 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1186 | "get_linkmode"}, | ||
1187 | { | ||
1188 | WLAN_GET_RADIOMODE, | ||
1189 | IW_PRIV_TYPE_NONE, | ||
1190 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1191 | "get_radiomode"}, | ||
1192 | { | ||
1193 | WLAN_GET_DEBUGMODE, | ||
1194 | IW_PRIV_TYPE_NONE, | ||
1195 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | ||
1196 | "get_debugmode"}, | ||
1197 | { | ||
1198 | WLAN_SUBCMD_FWT_CLEANUP, | 1016 | WLAN_SUBCMD_FWT_CLEANUP, |
1199 | IW_PRIV_TYPE_NONE, | 1017 | IW_PRIV_TYPE_NONE, |
1200 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 1018 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
@@ -1210,61 +1028,11 @@ static const struct iw_priv_args wlan_private_args[] = { | |||
1210 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 1028 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
1211 | "mesh_get_ttl"}, | 1029 | "mesh_get_ttl"}, |
1212 | { | 1030 | { |
1213 | WLAN_SETNONE_GETTWELVE_CHAR, | ||
1214 | IW_PRIV_TYPE_NONE, | ||
1215 | IW_PRIV_TYPE_CHAR | 12, | ||
1216 | ""}, | ||
1217 | { | ||
1218 | WLAN_SUBCMD_GETRXANTENNA, | ||
1219 | IW_PRIV_TYPE_NONE, | ||
1220 | IW_PRIV_TYPE_CHAR | 12, | ||
1221 | "getrxant"}, | ||
1222 | { | ||
1223 | WLAN_SUBCMD_GETTXANTENNA, | ||
1224 | IW_PRIV_TYPE_NONE, | ||
1225 | IW_PRIV_TYPE_CHAR | 12, | ||
1226 | "gettxant"}, | ||
1227 | { | ||
1228 | WLAN_GET_TSF, | ||
1229 | IW_PRIV_TYPE_NONE, | ||
1230 | IW_PRIV_TYPE_CHAR | 12, | ||
1231 | "gettsf"}, | ||
1232 | { | ||
1233 | WLAN_SETNONE_GETNONE, | 1031 | WLAN_SETNONE_GETNONE, |
1234 | IW_PRIV_TYPE_NONE, | 1032 | IW_PRIV_TYPE_NONE, |
1235 | IW_PRIV_TYPE_NONE, | 1033 | IW_PRIV_TYPE_NONE, |
1236 | ""}, | 1034 | ""}, |
1237 | { | 1035 | { |
1238 | WLANDEAUTH, | ||
1239 | IW_PRIV_TYPE_NONE, | ||
1240 | IW_PRIV_TYPE_NONE, | ||
1241 | "deauth"}, | ||
1242 | { | ||
1243 | WLANADHOCSTOP, | ||
1244 | IW_PRIV_TYPE_NONE, | ||
1245 | IW_PRIV_TYPE_NONE, | ||
1246 | "adhocstop"}, | ||
1247 | { | ||
1248 | WLANRADIOON, | ||
1249 | IW_PRIV_TYPE_NONE, | ||
1250 | IW_PRIV_TYPE_NONE, | ||
1251 | "radioon"}, | ||
1252 | { | ||
1253 | WLANRADIOOFF, | ||
1254 | IW_PRIV_TYPE_NONE, | ||
1255 | IW_PRIV_TYPE_NONE, | ||
1256 | "radiooff"}, | ||
1257 | { | ||
1258 | WLANWLANIDLEON, | ||
1259 | IW_PRIV_TYPE_NONE, | ||
1260 | IW_PRIV_TYPE_NONE, | ||
1261 | "wlanidle-on"}, | ||
1262 | { | ||
1263 | WLANWLANIDLEOFF, | ||
1264 | IW_PRIV_TYPE_NONE, | ||
1265 | IW_PRIV_TYPE_NONE, | ||
1266 | "wlanidle-off"}, | ||
1267 | { | ||
1268 | WLAN_SUBCMD_FWT_RESET, | 1036 | WLAN_SUBCMD_FWT_RESET, |
1269 | IW_PRIV_TYPE_NONE, | 1037 | IW_PRIV_TYPE_NONE, |
1270 | IW_PRIV_TYPE_NONE, | 1038 | IW_PRIV_TYPE_NONE, |
@@ -1327,90 +1095,15 @@ static const struct iw_priv_args wlan_private_args[] = { | |||
1327 | IW_PRIV_TYPE_CHAR | 128, | 1095 | IW_PRIV_TYPE_CHAR | 128, |
1328 | "fwt_list_route"}, | 1096 | "fwt_list_route"}, |
1329 | { | 1097 | { |
1330 | WLANSCAN_MODE, | ||
1331 | IW_PRIV_TYPE_CHAR | 128, | ||
1332 | IW_PRIV_TYPE_CHAR | 128, | ||
1333 | "scanmode"}, | ||
1334 | { | ||
1335 | WLAN_GET_ADHOC_STATUS, | ||
1336 | IW_PRIV_TYPE_CHAR | 128, | ||
1337 | IW_PRIV_TYPE_CHAR | 128, | ||
1338 | "getadhocstatus"}, | ||
1339 | { | ||
1340 | WLAN_SETNONE_GETWORDCHAR, | ||
1341 | IW_PRIV_TYPE_NONE, | ||
1342 | IW_PRIV_TYPE_CHAR | 128, | ||
1343 | ""}, | ||
1344 | { | ||
1345 | WLANSETWPAIE, | ||
1346 | IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 24, | ||
1347 | IW_PRIV_TYPE_NONE, | ||
1348 | "setwpaie"}, | ||
1349 | { | ||
1350 | WLANGETLOG, | ||
1351 | IW_PRIV_TYPE_NONE, | ||
1352 | IW_PRIV_TYPE_CHAR | GETLOG_BUFSIZE, | ||
1353 | "getlog"}, | ||
1354 | { | ||
1355 | WLAN_SET_GET_SIXTEEN_INT, | 1098 | WLAN_SET_GET_SIXTEEN_INT, |
1356 | IW_PRIV_TYPE_INT | 16, | 1099 | IW_PRIV_TYPE_INT | 16, |
1357 | IW_PRIV_TYPE_INT | 16, | 1100 | IW_PRIV_TYPE_INT | 16, |
1358 | ""}, | 1101 | ""}, |
1359 | { | 1102 | { |
1360 | WLAN_TPCCFG, | ||
1361 | IW_PRIV_TYPE_INT | 16, | ||
1362 | IW_PRIV_TYPE_INT | 16, | ||
1363 | "tpccfg"}, | ||
1364 | { | ||
1365 | WLAN_POWERCFG, | ||
1366 | IW_PRIV_TYPE_INT | 16, | ||
1367 | IW_PRIV_TYPE_INT | 16, | ||
1368 | "powercfg"}, | ||
1369 | { | ||
1370 | WLAN_AUTO_FREQ_SET, | ||
1371 | IW_PRIV_TYPE_INT | 16, | ||
1372 | IW_PRIV_TYPE_INT | 16, | ||
1373 | "setafc"}, | ||
1374 | { | ||
1375 | WLAN_AUTO_FREQ_GET, | ||
1376 | IW_PRIV_TYPE_INT | 16, | ||
1377 | IW_PRIV_TYPE_INT | 16, | ||
1378 | "getafc"}, | ||
1379 | { | ||
1380 | WLAN_SCANPROBES, | ||
1381 | IW_PRIV_TYPE_INT | 16, | ||
1382 | IW_PRIV_TYPE_INT | 16, | ||
1383 | "scanprobes"}, | ||
1384 | { | ||
1385 | WLAN_LED_GPIO_CTRL, | 1103 | WLAN_LED_GPIO_CTRL, |
1386 | IW_PRIV_TYPE_INT | 16, | 1104 | IW_PRIV_TYPE_INT | 16, |
1387 | IW_PRIV_TYPE_INT | 16, | 1105 | IW_PRIV_TYPE_INT | 16, |
1388 | "ledgpio"}, | 1106 | "ledgpio"}, |
1389 | { | ||
1390 | WLAN_ADAPT_RATESET, | ||
1391 | IW_PRIV_TYPE_INT | 16, | ||
1392 | IW_PRIV_TYPE_INT | 16, | ||
1393 | "rateadapt"}, | ||
1394 | { | ||
1395 | WLAN_INACTIVITY_TIMEOUT, | ||
1396 | IW_PRIV_TYPE_INT | 16, | ||
1397 | IW_PRIV_TYPE_INT | 16, | ||
1398 | "inactivityto"}, | ||
1399 | { | ||
1400 | WLANSNR, | ||
1401 | IW_PRIV_TYPE_INT | 16, | ||
1402 | IW_PRIV_TYPE_INT | 16, | ||
1403 | "getSNR"}, | ||
1404 | { | ||
1405 | WLAN_GET_RATE, | ||
1406 | IW_PRIV_TYPE_INT | 16, | ||
1407 | IW_PRIV_TYPE_INT | 16, | ||
1408 | "getrate"}, | ||
1409 | { | ||
1410 | WLAN_GET_RXINFO, | ||
1411 | IW_PRIV_TYPE_INT | 16, | ||
1412 | IW_PRIV_TYPE_INT | 16, | ||
1413 | "getrxinfo"}, | ||
1414 | }; | 1107 | }; |
1415 | 1108 | ||
1416 | static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) | 1109 | static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) |
@@ -1434,7 +1127,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) | |||
1434 | 1127 | ||
1435 | ENTER(); | 1128 | ENTER(); |
1436 | 1129 | ||
1437 | priv->wstats.status = adapter->inframode; | 1130 | priv->wstats.status = adapter->mode; |
1438 | 1131 | ||
1439 | /* If we're not associated, all quality values are meaningless */ | 1132 | /* If we're not associated, all quality values are meaningless */ |
1440 | if (adapter->connect_status != libertas_connected) | 1133 | if (adapter->connect_status != libertas_connected) |
@@ -1568,13 +1261,12 @@ static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info, | |||
1568 | if (!cfp) { | 1261 | if (!cfp) { |
1569 | rc = -EINVAL; | 1262 | rc = -EINVAL; |
1570 | } else { | 1263 | } else { |
1571 | if (adapter->inframode == wlan802_11ibss) { | 1264 | if (adapter->mode == IW_MODE_ADHOC) { |
1572 | rc = changeadhocchannel(priv, channel); | 1265 | rc = changeadhocchannel(priv, channel); |
1573 | /* If station is WEP enabled, send the | 1266 | /* If station is WEP enabled, send the |
1574 | * command to set WEP in firmware | 1267 | * command to set WEP in firmware |
1575 | */ | 1268 | */ |
1576 | if (adapter->secinfo.WEPstatus == | 1269 | if (adapter->secinfo.wep_enabled) { |
1577 | wlan802_11WEPenabled) { | ||
1578 | lbs_pr_debug(1, "set_freq: WEP enabled\n"); | 1270 | lbs_pr_debug(1, "set_freq: WEP enabled\n"); |
1579 | ret = libertas_prepare_and_send_command(priv, | 1271 | ret = libertas_prepare_and_send_command(priv, |
1580 | cmd_802_11_set_wep, | 1272 | cmd_802_11_set_wep, |
@@ -1716,49 +1408,31 @@ static int wlan_set_mode(struct net_device *dev, | |||
1716 | wlan_private *priv = dev->priv; | 1408 | wlan_private *priv = dev->priv; |
1717 | wlan_adapter *adapter = priv->adapter; | 1409 | wlan_adapter *adapter = priv->adapter; |
1718 | struct assoc_request * assoc_req; | 1410 | struct assoc_request * assoc_req; |
1719 | enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode; | ||
1720 | 1411 | ||
1721 | ENTER(); | 1412 | ENTER(); |
1722 | 1413 | ||
1723 | switch (*uwrq) { | 1414 | if ( (*uwrq != IW_MODE_ADHOC) |
1724 | case IW_MODE_ADHOC: | 1415 | && (*uwrq != IW_MODE_INFRA) |
1725 | lbs_pr_debug(1, "Wanted mode is ad-hoc: current datarate=%#x\n", | 1416 | && (*uwrq != IW_MODE_AUTO)) { |
1726 | adapter->datarate); | 1417 | lbs_pr_debug(1, "Invalid mode: 0x%x\n", *uwrq); |
1727 | new_mode = wlan802_11ibss; | 1418 | ret = -EINVAL; |
1728 | adapter->adhocchannel = DEFAULT_AD_HOC_CHANNEL; | 1419 | goto out; |
1729 | break; | ||
1730 | |||
1731 | case IW_MODE_INFRA: | ||
1732 | lbs_pr_debug(1, "Wanted mode is Infrastructure\n"); | ||
1733 | new_mode = wlan802_11infrastructure; | ||
1734 | break; | ||
1735 | |||
1736 | case IW_MODE_AUTO: | ||
1737 | lbs_pr_debug(1, "Wanted mode is Auto\n"); | ||
1738 | new_mode = wlan802_11autounknown; | ||
1739 | break; | ||
1740 | |||
1741 | default: | ||
1742 | lbs_pr_debug(1, "Wanted mode is Unknown: 0x%x\n", *uwrq); | ||
1743 | return -EINVAL; | ||
1744 | } | 1420 | } |
1745 | 1421 | ||
1746 | mutex_lock(&adapter->lock); | 1422 | mutex_lock(&adapter->lock); |
1747 | assoc_req = wlan_get_association_request(adapter); | 1423 | assoc_req = wlan_get_association_request(adapter); |
1748 | if (!assoc_req) { | 1424 | if (!assoc_req) { |
1749 | ret = -ENOMEM; | 1425 | ret = -ENOMEM; |
1426 | wlan_cancel_association_work(priv); | ||
1750 | } else { | 1427 | } else { |
1751 | assoc_req->mode = new_mode; | 1428 | assoc_req->mode = *uwrq; |
1752 | } | ||
1753 | |||
1754 | if (ret == 0) { | ||
1755 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); | 1429 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); |
1756 | wlan_postpone_association_work(priv); | 1430 | wlan_postpone_association_work(priv); |
1757 | } else { | 1431 | lbs_pr_debug(1, "Switching to mode: 0x%x\n", *uwrq); |
1758 | wlan_cancel_association_work(priv); | ||
1759 | } | 1432 | } |
1760 | mutex_unlock(&adapter->lock); | 1433 | mutex_unlock(&adapter->lock); |
1761 | 1434 | ||
1435 | out: | ||
1762 | LEAVE(); | 1436 | LEAVE(); |
1763 | return ret; | 1437 | return ret; |
1764 | } | 1438 | } |
@@ -1789,13 +1463,13 @@ static int wlan_get_encode(struct net_device *dev, | |||
1789 | dwrq->flags = 0; | 1463 | dwrq->flags = 0; |
1790 | 1464 | ||
1791 | /* Authentication method */ | 1465 | /* Authentication method */ |
1792 | switch (adapter->secinfo.authmode) { | 1466 | switch (adapter->secinfo.auth_mode) { |
1793 | case wlan802_11authmodeopen: | 1467 | case IW_AUTH_ALG_OPEN_SYSTEM: |
1794 | dwrq->flags = IW_ENCODE_OPEN; | 1468 | dwrq->flags = IW_ENCODE_OPEN; |
1795 | break; | 1469 | break; |
1796 | 1470 | ||
1797 | case wlan802_11authmodeshared: | 1471 | case IW_AUTH_ALG_SHARED_KEY: |
1798 | case wlan802_11authmodenetworkEAP: | 1472 | case IW_AUTH_ALG_LEAP: |
1799 | dwrq->flags = IW_ENCODE_RESTRICTED; | 1473 | dwrq->flags = IW_ENCODE_RESTRICTED; |
1800 | break; | 1474 | break; |
1801 | default: | 1475 | default: |
@@ -1803,8 +1477,9 @@ static int wlan_get_encode(struct net_device *dev, | |||
1803 | break; | 1477 | break; |
1804 | } | 1478 | } |
1805 | 1479 | ||
1806 | if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) | 1480 | if ( adapter->secinfo.wep_enabled |
1807 | || adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) { | 1481 | || adapter->secinfo.WPAenabled |
1482 | || adapter->secinfo.WPA2enabled) { | ||
1808 | dwrq->flags &= ~IW_ENCODE_DISABLED; | 1483 | dwrq->flags &= ~IW_ENCODE_DISABLED; |
1809 | } else { | 1484 | } else { |
1810 | dwrq->flags |= IW_ENCODE_DISABLED; | 1485 | dwrq->flags |= IW_ENCODE_DISABLED; |
@@ -1818,8 +1493,7 @@ static int wlan_get_encode(struct net_device *dev, | |||
1818 | if (index < 0) | 1493 | if (index < 0) |
1819 | index = adapter->wep_tx_keyidx; | 1494 | index = adapter->wep_tx_keyidx; |
1820 | 1495 | ||
1821 | if ((adapter->wep_keys[index].len) && | 1496 | if ((adapter->wep_keys[index].len) && adapter->secinfo.wep_enabled) { |
1822 | (adapter->secinfo.WEPstatus == wlan802_11WEPenabled)) { | ||
1823 | memcpy(extra, adapter->wep_keys[index].key, | 1497 | memcpy(extra, adapter->wep_keys[index].key, |
1824 | adapter->wep_keys[index].len); | 1498 | adapter->wep_keys[index].len); |
1825 | dwrq->length = adapter->wep_keys[index].len; | 1499 | dwrq->length = adapter->wep_keys[index].len; |
@@ -1903,7 +1577,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req, | |||
1903 | assoc_req->wep_tx_keyidx = index; | 1577 | assoc_req->wep_tx_keyidx = index; |
1904 | } | 1578 | } |
1905 | 1579 | ||
1906 | assoc_req->secinfo.WEPstatus = wlan802_11WEPenabled; | 1580 | assoc_req->secinfo.wep_enabled = 1; |
1907 | 1581 | ||
1908 | LEAVE(); | 1582 | LEAVE(); |
1909 | return 0; | 1583 | return 0; |
@@ -1932,10 +1606,10 @@ static void disable_wep(struct assoc_request *assoc_req) | |||
1932 | int i; | 1606 | int i; |
1933 | 1607 | ||
1934 | /* Set Open System auth mode */ | 1608 | /* Set Open System auth mode */ |
1935 | assoc_req->secinfo.authmode = wlan802_11authmodeopen; | 1609 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
1936 | 1610 | ||
1937 | /* Clear WEP keys and mark WEP as disabled */ | 1611 | /* Clear WEP keys and mark WEP as disabled */ |
1938 | assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; | 1612 | assoc_req->secinfo.wep_enabled = 0; |
1939 | for (i = 0; i < 4; i++) | 1613 | for (i = 0; i < 4; i++) |
1940 | assoc_req->wep_keys[i].len = 0; | 1614 | assoc_req->wep_keys[i].len = 0; |
1941 | 1615 | ||
@@ -1987,8 +1661,7 @@ static int wlan_set_encode(struct net_device *dev, | |||
1987 | /* If WEP isn't enabled, or if there is no key data but a valid | 1661 | /* If WEP isn't enabled, or if there is no key data but a valid |
1988 | * index, set the TX key. | 1662 | * index, set the TX key. |
1989 | */ | 1663 | */ |
1990 | if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) | 1664 | if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default)) |
1991 | || (dwrq->length == 0 && !is_default)) | ||
1992 | set_tx_key = 1; | 1665 | set_tx_key = 1; |
1993 | 1666 | ||
1994 | ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); | 1667 | ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); |
@@ -2001,9 +1674,9 @@ static int wlan_set_encode(struct net_device *dev, | |||
2001 | set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); | 1674 | set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); |
2002 | 1675 | ||
2003 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { | 1676 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { |
2004 | assoc_req->secinfo.authmode = wlan802_11authmodeshared; | 1677 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
2005 | } else if (dwrq->flags & IW_ENCODE_OPEN) { | 1678 | } else if (dwrq->flags & IW_ENCODE_OPEN) { |
2006 | assoc_req->secinfo.authmode = wlan802_11authmodeopen; | 1679 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2007 | } | 1680 | } |
2008 | 1681 | ||
2009 | out: | 1682 | out: |
@@ -2056,30 +1729,31 @@ static int wlan_get_encodeext(struct net_device *dev, | |||
2056 | 1729 | ||
2057 | if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY && | 1730 | if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY && |
2058 | ext->alg != IW_ENCODE_ALG_WEP) { | 1731 | ext->alg != IW_ENCODE_ALG_WEP) { |
2059 | if (index != 0 || adapter->inframode != wlan802_11infrastructure) | 1732 | if (index != 0 || adapter->mode != IW_MODE_INFRA) |
2060 | goto out; | 1733 | goto out; |
2061 | } | 1734 | } |
2062 | 1735 | ||
2063 | dwrq->flags = index + 1; | 1736 | dwrq->flags = index + 1; |
2064 | memset(ext, 0, sizeof(*ext)); | 1737 | memset(ext, 0, sizeof(*ext)); |
2065 | 1738 | ||
2066 | if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) | 1739 | if ( !adapter->secinfo.wep_enabled |
2067 | && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled) { | 1740 | && !adapter->secinfo.WPAenabled |
1741 | && !adapter->secinfo.WPA2enabled) { | ||
2068 | ext->alg = IW_ENCODE_ALG_NONE; | 1742 | ext->alg = IW_ENCODE_ALG_NONE; |
2069 | ext->key_len = 0; | 1743 | ext->key_len = 0; |
2070 | dwrq->flags |= IW_ENCODE_DISABLED; | 1744 | dwrq->flags |= IW_ENCODE_DISABLED; |
2071 | } else { | 1745 | } else { |
2072 | u8 *key = NULL; | 1746 | u8 *key = NULL; |
2073 | 1747 | ||
2074 | if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) | 1748 | if ( adapter->secinfo.wep_enabled |
2075 | && !adapter->secinfo.WPAenabled | 1749 | && !adapter->secinfo.WPAenabled |
2076 | && !adapter->secinfo.WPA2enabled) { | 1750 | && !adapter->secinfo.WPA2enabled) { |
2077 | ext->alg = IW_ENCODE_ALG_WEP; | 1751 | ext->alg = IW_ENCODE_ALG_WEP; |
2078 | ext->key_len = adapter->wep_keys[index].len; | 1752 | ext->key_len = adapter->wep_keys[index].len; |
2079 | key = &adapter->wep_keys[index].key[0]; | 1753 | key = &adapter->wep_keys[index].key[0]; |
2080 | } else if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) && | 1754 | } else if ( !adapter->secinfo.wep_enabled |
2081 | (adapter->secinfo.WPAenabled || | 1755 | && (adapter->secinfo.WPAenabled || |
2082 | adapter->secinfo.WPA2enabled)) { | 1756 | adapter->secinfo.WPA2enabled)) { |
2083 | /* WPA */ | 1757 | /* WPA */ |
2084 | ext->alg = IW_ENCODE_ALG_TKIP; | 1758 | ext->alg = IW_ENCODE_ALG_TKIP; |
2085 | ext->key_len = 0; | 1759 | ext->key_len = 0; |
@@ -2149,7 +1823,7 @@ static int wlan_set_encodeext(struct net_device *dev, | |||
2149 | /* If WEP isn't enabled, or if there is no key data but a valid | 1823 | /* If WEP isn't enabled, or if there is no key data but a valid |
2150 | * index, or if the set-TX-key flag was passed, set the TX key. | 1824 | * index, or if the set-TX-key flag was passed, set the TX key. |
2151 | */ | 1825 | */ |
2152 | if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) | 1826 | if ( !assoc_req->secinfo.wep_enabled |
2153 | || (dwrq->length == 0 && !is_default) | 1827 | || (dwrq->length == 0 && !is_default) |
2154 | || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) | 1828 | || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) |
2155 | set_tx_key = 1; | 1829 | set_tx_key = 1; |
@@ -2161,11 +1835,9 @@ static int wlan_set_encodeext(struct net_device *dev, | |||
2161 | goto out; | 1835 | goto out; |
2162 | 1836 | ||
2163 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { | 1837 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { |
2164 | assoc_req->secinfo.authmode = | 1838 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
2165 | wlan802_11authmodeshared; | ||
2166 | } else if (dwrq->flags & IW_ENCODE_OPEN) { | 1839 | } else if (dwrq->flags & IW_ENCODE_OPEN) { |
2167 | assoc_req->secinfo.authmode = | 1840 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2168 | wlan802_11authmodeopen; | ||
2169 | } | 1841 | } |
2170 | 1842 | ||
2171 | /* Mark the various WEP bits as modified */ | 1843 | /* Mark the various WEP bits as modified */ |
@@ -2350,15 +2022,13 @@ static int wlan_set_auth(struct net_device *dev, | |||
2350 | } | 2022 | } |
2351 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { | 2023 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { |
2352 | assoc_req->secinfo.WPAenabled = 1; | 2024 | assoc_req->secinfo.WPAenabled = 1; |
2353 | assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; | 2025 | assoc_req->secinfo.wep_enabled = 0; |
2354 | assoc_req->secinfo.authmode = | 2026 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2355 | wlan802_11authmodeopen; | ||
2356 | } | 2027 | } |
2357 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { | 2028 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { |
2358 | assoc_req->secinfo.WPA2enabled = 1; | 2029 | assoc_req->secinfo.WPA2enabled = 1; |
2359 | assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; | 2030 | assoc_req->secinfo.wep_enabled = 0; |
2360 | assoc_req->secinfo.authmode = | 2031 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2361 | wlan802_11authmodeopen; | ||
2362 | } | 2032 | } |
2363 | updated = 1; | 2033 | updated = 1; |
2364 | break; | 2034 | break; |
@@ -2376,14 +2046,11 @@ static int wlan_set_auth(struct net_device *dev, | |||
2376 | 2046 | ||
2377 | case IW_AUTH_80211_AUTH_ALG: | 2047 | case IW_AUTH_80211_AUTH_ALG: |
2378 | if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { | 2048 | if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { |
2379 | assoc_req->secinfo.authmode = | 2049 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
2380 | wlan802_11authmodeshared; | ||
2381 | } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { | 2050 | } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { |
2382 | assoc_req->secinfo.authmode = | 2051 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2383 | wlan802_11authmodeopen; | ||
2384 | } else if (dwrq->value & IW_AUTH_ALG_LEAP) { | 2052 | } else if (dwrq->value & IW_AUTH_ALG_LEAP) { |
2385 | assoc_req->secinfo.authmode = | 2053 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP; |
2386 | wlan802_11authmodenetworkEAP; | ||
2387 | } else { | 2054 | } else { |
2388 | ret = -EINVAL; | 2055 | ret = -EINVAL; |
2389 | } | 2056 | } |
@@ -2396,9 +2063,8 @@ static int wlan_set_auth(struct net_device *dev, | |||
2396 | !assoc_req->secinfo.WPA2enabled) { | 2063 | !assoc_req->secinfo.WPA2enabled) { |
2397 | assoc_req->secinfo.WPAenabled = 1; | 2064 | assoc_req->secinfo.WPAenabled = 1; |
2398 | assoc_req->secinfo.WPA2enabled = 1; | 2065 | assoc_req->secinfo.WPA2enabled = 1; |
2399 | assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; | 2066 | assoc_req->secinfo.wep_enabled = 0; |
2400 | assoc_req->secinfo.authmode = | 2067 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
2401 | wlan802_11authmodeopen; | ||
2402 | } | 2068 | } |
2403 | } else { | 2069 | } else { |
2404 | assoc_req->secinfo.WPAenabled = 0; | 2070 | assoc_req->secinfo.WPAenabled = 0; |
@@ -2455,19 +2121,7 @@ static int wlan_get_auth(struct net_device *dev, | |||
2455 | break; | 2121 | break; |
2456 | 2122 | ||
2457 | case IW_AUTH_80211_AUTH_ALG: | 2123 | case IW_AUTH_80211_AUTH_ALG: |
2458 | switch (adapter->secinfo.authmode) { | 2124 | dwrq->value = adapter->secinfo.auth_mode; |
2459 | case wlan802_11authmodeshared: | ||
2460 | dwrq->value = IW_AUTH_ALG_SHARED_KEY; | ||
2461 | break; | ||
2462 | case wlan802_11authmodeopen: | ||
2463 | dwrq->value = IW_AUTH_ALG_OPEN_SYSTEM; | ||
2464 | break; | ||
2465 | case wlan802_11authmodenetworkEAP: | ||
2466 | dwrq->value = IW_AUTH_ALG_LEAP; | ||
2467 | break; | ||
2468 | default: | ||
2469 | break; | ||
2470 | } | ||
2471 | break; | 2125 | break; |
2472 | 2126 | ||
2473 | case IW_AUTH_WPA_ENABLED: | 2127 | case IW_AUTH_WPA_ENABLED: |
diff --git a/drivers/net/wireless/libertas/wext.h b/drivers/net/wireless/libertas/wext.h index 39f367c38d90..15cfaaf0797f 100644 --- a/drivers/net/wireless/libertas/wext.h +++ b/drivers/net/wireless/libertas/wext.h | |||
@@ -10,88 +10,22 @@ | |||
10 | /** PRIVATE CMD ID */ | 10 | /** PRIVATE CMD ID */ |
11 | #define WLANIOCTL SIOCIWFIRSTPRIV | 11 | #define WLANIOCTL SIOCIWFIRSTPRIV |
12 | 12 | ||
13 | #define WLANSETWPAIE (WLANIOCTL + 0) | ||
14 | |||
15 | #define WLAN_SETINT_GETINT (WLANIOCTL + 7) | ||
16 | #define WLANNF 1 | ||
17 | #define WLANRSSI 2 | ||
18 | #define WLANENABLE11D 5 | ||
19 | #define WLANADHOCGRATE 6 | ||
20 | #define WLAN_SUBCMD_SET_PRESCAN 11 | ||
21 | |||
22 | #define WLAN_SETNONE_GETNONE (WLANIOCTL + 8) | 13 | #define WLAN_SETNONE_GETNONE (WLANIOCTL + 8) |
23 | #define WLANDEAUTH 1 | ||
24 | #define WLANRADIOON 2 | ||
25 | #define WLANRADIOOFF 3 | ||
26 | #define WLANREMOVEADHOCAES 4 | ||
27 | #define WLANADHOCSTOP 5 | ||
28 | #define WLANCIPHERTEST 6 | ||
29 | #define WLANCRYPTOTEST 7 | ||
30 | |||
31 | #define WLANWLANIDLEON 10 | ||
32 | #define WLANWLANIDLEOFF 11 | ||
33 | #define WLAN_SUBCMD_BT_RESET 13 | 14 | #define WLAN_SUBCMD_BT_RESET 13 |
34 | #define WLAN_SUBCMD_FWT_RESET 14 | 15 | #define WLAN_SUBCMD_FWT_RESET 14 |
35 | 16 | ||
36 | #define WLANGETLOG (WLANIOCTL + 9) | ||
37 | #define GETLOG_BUFSIZE 300 | ||
38 | |||
39 | #define WLANSCAN_TYPE (WLANIOCTL + 11) | ||
40 | |||
41 | #define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15) | 17 | #define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15) |
42 | #define WLANGETREGION 1 | 18 | #define WLANGETREGION 1 |
43 | #define WLAN_GET_LISTEN_INTERVAL 2 | ||
44 | #define WLAN_GET_MULTIPLE_DTIM 3 | ||
45 | #define WLAN_GET_TX_RATE 4 | ||
46 | #define WLANGETBCNAVG 5 | ||
47 | 19 | ||
48 | #define WLAN_GET_LINKMODE 6 | ||
49 | #define WLAN_GET_RADIOMODE 7 | ||
50 | #define WLAN_GET_DEBUGMODE 8 | ||
51 | #define WLAN_SUBCMD_FWT_CLEANUP 15 | 20 | #define WLAN_SUBCMD_FWT_CLEANUP 15 |
52 | #define WLAN_SUBCMD_FWT_TIME 16 | 21 | #define WLAN_SUBCMD_FWT_TIME 16 |
53 | #define WLAN_SUBCMD_MESH_GET_TTL 17 | 22 | #define WLAN_SUBCMD_MESH_GET_TTL 17 |
54 | 23 | ||
55 | #define WLANREGCFRDWR (WLANIOCTL + 18) | ||
56 | |||
57 | #define WLAN_SETNONE_GETTWELVE_CHAR (WLANIOCTL + 19) | ||
58 | #define WLAN_SUBCMD_GETRXANTENNA 1 | ||
59 | #define WLAN_SUBCMD_GETTXANTENNA 2 | ||
60 | #define WLAN_GET_TSF 3 | ||
61 | |||
62 | #define WLAN_SETNONE_GETWORDCHAR (WLANIOCTL + 21) | ||
63 | #define WLANGETADHOCAES 1 | ||
64 | |||
65 | #define WLAN_SETONEINT_GETONEINT (WLANIOCTL + 23) | ||
66 | #define WLAN_BEACON_INTERVAL 1 | ||
67 | #define WLAN_LISTENINTRVL 4 | ||
68 | |||
69 | #define WLAN_TXCONTROL 6 | ||
70 | #define WLAN_NULLPKTINTERVAL 7 | ||
71 | |||
72 | #define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24) | 24 | #define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24) |
73 | #define WLAN_SUBCMD_SETRXANTENNA 1 | ||
74 | #define WLAN_SUBCMD_SETTXANTENNA 2 | ||
75 | #define WLANSETAUTHALG 5 | ||
76 | #define WLANSET8021XAUTHALG 6 | ||
77 | #define WLANSETENCRYPTIONMODE 7 | ||
78 | #define WLANSETREGION 8 | 25 | #define WLANSETREGION 8 |
79 | #define WLAN_SET_LISTEN_INTERVAL 9 | ||
80 | |||
81 | #define WLAN_SET_MULTIPLE_DTIM 10 | ||
82 | #define WLAN_SET_ATIM_WINDOW 11 | ||
83 | #define WLANSETBCNAVG 13 | ||
84 | #define WLANSETDATAAVG 14 | ||
85 | #define WLAN_SET_LINKMODE 15 | ||
86 | #define WLAN_SET_RADIOMODE 16 | ||
87 | #define WLAN_SET_DEBUGMODE 17 | ||
88 | #define WLAN_SUBCMD_MESH_SET_TTL 18 | 26 | #define WLAN_SUBCMD_MESH_SET_TTL 18 |
89 | 27 | ||
90 | #define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25) | 28 | #define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25) |
91 | #define WLANSCAN_MODE 6 | ||
92 | |||
93 | #define WLAN_GET_ADHOC_STATUS 9 | ||
94 | |||
95 | #define WLAN_SUBCMD_BT_ADD 18 | 29 | #define WLAN_SUBCMD_BT_ADD 18 |
96 | #define WLAN_SUBCMD_BT_DEL 19 | 30 | #define WLAN_SUBCMD_BT_DEL 19 |
97 | #define WLAN_SUBCMD_BT_LIST 20 | 31 | #define WLAN_SUBCMD_BT_LIST 20 |
@@ -103,27 +37,8 @@ | |||
103 | #define WLAN_SUBCMD_FWT_LIST_ROUTE 26 | 37 | #define WLAN_SUBCMD_FWT_LIST_ROUTE 26 |
104 | 38 | ||
105 | #define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29) | 39 | #define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29) |
106 | #define WLAN_TPCCFG 1 | ||
107 | #define WLAN_POWERCFG 2 | ||
108 | |||
109 | #define WLAN_AUTO_FREQ_SET 3 | ||
110 | #define WLAN_AUTO_FREQ_GET 4 | ||
111 | #define WLAN_LED_GPIO_CTRL 5 | 40 | #define WLAN_LED_GPIO_CTRL 5 |
112 | #define WLAN_SCANPROBES 6 | ||
113 | #define WLAN_ADAPT_RATESET 8 | ||
114 | #define WLAN_INACTIVITY_TIMEOUT 9 | ||
115 | #define WLANSNR 10 | ||
116 | #define WLAN_GET_RATE 11 | ||
117 | #define WLAN_GET_RXINFO 12 | ||
118 | |||
119 | #define WLANCMD52RDWR (WLANIOCTL + 30) | ||
120 | #define WLANCMD53RDWR (WLANIOCTL + 31) | ||
121 | #define CMD53BUFLEN 32 | ||
122 | 41 | ||
123 | #define REG_MAC 0x19 | ||
124 | #define REG_BBP 0x1a | ||
125 | #define REG_RF 0x1b | ||
126 | #define REG_EEPROM 0x59 | ||
127 | #define WLAN_LINKMODE_802_3 0 | 42 | #define WLAN_LINKMODE_802_3 0 |
128 | #define WLAN_LINKMODE_802_11 2 | 43 | #define WLAN_LINKMODE_802_11 2 |
129 | #define WLAN_RADIOMODE_NONE 0 | 44 | #define WLAN_RADIOMODE_NONE 0 |
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig index 36c6a1bfe558..f46c69e4ed82 100644 --- a/drivers/parport/Kconfig +++ b/drivers/parport/Kconfig | |||
@@ -6,6 +6,7 @@ | |||
6 | # | 6 | # |
7 | 7 | ||
8 | menu "Parallel port support" | 8 | menu "Parallel port support" |
9 | depends on HAS_IOMEM | ||
9 | 10 | ||
10 | config PARPORT | 11 | config PARPORT |
11 | tristate "Parallel port support" | 12 | tristate "Parallel port support" |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index 78cf0711d1fa..ef07c36bccf7 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -249,19 +249,19 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, | |||
249 | 249 | ||
250 | 250 | ||
251 | if (rc == PCI_SLOT_ALREADY_UP) { | 251 | if (rc == PCI_SLOT_ALREADY_UP) { |
252 | dev_dbg(slot->pci_bus->self, "is already active\n"); | 252 | dev_dbg(&slot->pci_bus->self->dev, "is already active\n"); |
253 | return 1; /* return 1 to user */ | 253 | return 1; /* return 1 to user */ |
254 | } | 254 | } |
255 | 255 | ||
256 | if (rc == PCI_L1_ERR) { | 256 | if (rc == PCI_L1_ERR) { |
257 | dev_dbg(slot->pci_bus->self, | 257 | dev_dbg(&slot->pci_bus->self->dev, |
258 | "L1 failure %d with message: %s", | 258 | "L1 failure %d with message: %s", |
259 | resp.resp_sub_errno, resp.resp_l1_msg); | 259 | resp.resp_sub_errno, resp.resp_l1_msg); |
260 | return -EPERM; | 260 | return -EPERM; |
261 | } | 261 | } |
262 | 262 | ||
263 | if (rc) { | 263 | if (rc) { |
264 | dev_dbg(slot->pci_bus->self, | 264 | dev_dbg(&slot->pci_bus->self->dev, |
265 | "insert failed with error %d sub-error %d\n", | 265 | "insert failed with error %d sub-error %d\n", |
266 | rc, resp.resp_sub_errno); | 266 | rc, resp.resp_sub_errno); |
267 | return -EIO; | 267 | return -EIO; |
@@ -287,25 +287,25 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, | |||
287 | 287 | ||
288 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && | 288 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && |
289 | (rc == PCI_SLOT_ALREADY_DOWN)) { | 289 | (rc == PCI_SLOT_ALREADY_DOWN)) { |
290 | dev_dbg(slot->pci_bus->self, "Slot %s already inactive\n"); | 290 | dev_dbg(&slot->pci_bus->self->dev, "Slot %s already inactive\n", slot->physical_path); |
291 | return 1; /* return 1 to user */ | 291 | return 1; /* return 1 to user */ |
292 | } | 292 | } |
293 | 293 | ||
294 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { | 294 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { |
295 | dev_dbg(slot->pci_bus->self, | 295 | dev_dbg(&slot->pci_bus->self->dev, |
296 | "Cannot remove last 33MHz card\n"); | 296 | "Cannot remove last 33MHz card\n"); |
297 | return -EPERM; | 297 | return -EPERM; |
298 | } | 298 | } |
299 | 299 | ||
300 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { | 300 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { |
301 | dev_dbg(slot->pci_bus->self, | 301 | dev_dbg(&slot->pci_bus->self->dev, |
302 | "L1 failure %d with message \n%s\n", | 302 | "L1 failure %d with message \n%s\n", |
303 | resp.resp_sub_errno, resp.resp_l1_msg); | 303 | resp.resp_sub_errno, resp.resp_l1_msg); |
304 | return -EPERM; | 304 | return -EPERM; |
305 | } | 305 | } |
306 | 306 | ||
307 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { | 307 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { |
308 | dev_dbg(slot->pci_bus->self, | 308 | dev_dbg(&slot->pci_bus->self->dev, |
309 | "remove failed with error %d sub-error %d\n", | 309 | "remove failed with error %d sub-error %d\n", |
310 | rc, resp.resp_sub_errno); | 310 | rc, resp.resp_sub_errno); |
311 | return -EIO; | 311 | return -EIO; |
@@ -317,12 +317,12 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, | |||
317 | if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { | 317 | if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { |
318 | pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); | 318 | pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); |
319 | pcibus_info->pbi_enabled_devices &= ~(1 << device_num); | 319 | pcibus_info->pbi_enabled_devices &= ~(1 << device_num); |
320 | dev_dbg(slot->pci_bus->self, "remove successful\n"); | 320 | dev_dbg(&slot->pci_bus->self->dev, "remove successful\n"); |
321 | return 0; | 321 | return 0; |
322 | } | 322 | } |
323 | 323 | ||
324 | if ((action == PCI_REQ_SLOT_DISABLE) && rc) { | 324 | if ((action == PCI_REQ_SLOT_DISABLE) && rc) { |
325 | dev_dbg(slot->pci_bus->self,"remove failed rc = %d\n", rc); | 325 | dev_dbg(&slot->pci_bus->self->dev,"remove failed rc = %d\n", rc); |
326 | } | 326 | } |
327 | 327 | ||
328 | return rc; | 328 | return rc; |
@@ -375,7 +375,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
375 | num_funcs = pci_scan_slot(slot->pci_bus, | 375 | num_funcs = pci_scan_slot(slot->pci_bus, |
376 | PCI_DEVFN(slot->device_num + 1, 0)); | 376 | PCI_DEVFN(slot->device_num + 1, 0)); |
377 | if (!num_funcs) { | 377 | if (!num_funcs) { |
378 | dev_dbg(slot->pci_bus->self, "no device in slot\n"); | 378 | dev_dbg(&slot->pci_bus->self->dev, "no device in slot\n"); |
379 | mutex_unlock(&sn_hotplug_mutex); | 379 | mutex_unlock(&sn_hotplug_mutex); |
380 | return -ENODEV; | 380 | return -ENODEV; |
381 | } | 381 | } |
@@ -427,7 +427,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
427 | phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle; | 427 | phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle; |
428 | 428 | ||
429 | if (acpi_bus_get_device(phandle, &pdevice)) { | 429 | if (acpi_bus_get_device(phandle, &pdevice)) { |
430 | dev_dbg(slot->pci_bus->self, | 430 | dev_dbg(&slot->pci_bus->self->dev, |
431 | "no parent device, assuming NULL\n"); | 431 | "no parent device, assuming NULL\n"); |
432 | pdevice = NULL; | 432 | pdevice = NULL; |
433 | } | 433 | } |
@@ -479,10 +479,10 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
479 | mutex_unlock(&sn_hotplug_mutex); | 479 | mutex_unlock(&sn_hotplug_mutex); |
480 | 480 | ||
481 | if (rc == 0) | 481 | if (rc == 0) |
482 | dev_dbg(slot->pci_bus->self, | 482 | dev_dbg(&slot->pci_bus->self->dev, |
483 | "insert operation successful\n"); | 483 | "insert operation successful\n"); |
484 | else | 484 | else |
485 | dev_dbg(slot->pci_bus->self, | 485 | dev_dbg(&slot->pci_bus->self->dev, |
486 | "insert operation failed rc = %d\n", rc); | 486 | "insert operation failed rc = %d\n", rc); |
487 | 487 | ||
488 | return rc; | 488 | return rc; |
@@ -659,16 +659,16 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) | |||
659 | if (rc) | 659 | if (rc) |
660 | goto register_err; | 660 | goto register_err; |
661 | } | 661 | } |
662 | dev_dbg(pci_bus->self, "Registered bus with hotplug\n"); | 662 | dev_dbg(&pci_bus->self->dev, "Registered bus with hotplug\n"); |
663 | return rc; | 663 | return rc; |
664 | 664 | ||
665 | register_err: | 665 | register_err: |
666 | dev_dbg(pci_bus->self, "bus failed to register with err = %d\n", | 666 | dev_dbg(&pci_bus->self->dev, "bus failed to register with err = %d\n", |
667 | rc); | 667 | rc); |
668 | 668 | ||
669 | alloc_err: | 669 | alloc_err: |
670 | if (rc == -ENOMEM) | 670 | if (rc == -ENOMEM) |
671 | dev_dbg(pci_bus->self, "Memory allocation error\n"); | 671 | dev_dbg(&pci_bus->self->dev, "Memory allocation error\n"); |
672 | 672 | ||
673 | /* destroy THIS element */ | 673 | /* destroy THIS element */ |
674 | if (bss_hotplug_slot) | 674 | if (bss_hotplug_slot) |
@@ -701,10 +701,10 @@ static int sn_pci_hotplug_init(void) | |||
701 | 701 | ||
702 | rc = sn_pci_bus_valid(pci_bus); | 702 | rc = sn_pci_bus_valid(pci_bus); |
703 | if (rc != 1) { | 703 | if (rc != 1) { |
704 | dev_dbg(pci_bus->self, "not a valid hotplug bus\n"); | 704 | dev_dbg(&pci_bus->self->dev, "not a valid hotplug bus\n"); |
705 | continue; | 705 | continue; |
706 | } | 706 | } |
707 | dev_dbg(pci_bus->self, "valid hotplug bus\n"); | 707 | dev_dbg(&pci_bus->self->dev, "valid hotplug bus\n"); |
708 | 708 | ||
709 | rc = sn_hotplug_slot_register(pci_bus); | 709 | rc = sn_hotplug_slot_register(pci_bus); |
710 | if (!rc) { | 710 | if (!rc) { |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index e6740d1a0824..d9cbd586ae4b 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -549,8 +549,10 @@ static int msi_free_irqs(struct pci_dev* dev) | |||
549 | { | 549 | { |
550 | struct msi_desc *entry, *tmp; | 550 | struct msi_desc *entry, *tmp; |
551 | 551 | ||
552 | list_for_each_entry(entry, &dev->msi_list, list) | 552 | list_for_each_entry(entry, &dev->msi_list, list) { |
553 | BUG_ON(irq_has_action(entry->irq)); | 553 | if (entry->irq) |
554 | BUG_ON(irq_has_action(entry->irq)); | ||
555 | } | ||
554 | 556 | ||
555 | arch_teardown_msi_irqs(dev); | 557 | arch_teardown_msi_irqs(dev); |
556 | 558 | ||
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 147d86f8edbf..6ccc2e95930a 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -875,6 +875,7 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev) | |||
875 | } | 875 | } |
876 | } | 876 | } |
877 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); | 877 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); |
878 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_sb600_sata); | ||
878 | 879 | ||
879 | /* | 880 | /* |
880 | * Serverworks CSB5 IDE does not fully support native mode | 881 | * Serverworks CSB5 IDE does not fully support native mode |
diff --git a/drivers/pnp/Kconfig b/drivers/pnp/Kconfig index c5143201419a..1959cef8e9de 100644 --- a/drivers/pnp/Kconfig +++ b/drivers/pnp/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Plug and Play support" | 5 | menu "Plug and Play support" |
6 | depends on HAS_IOMEM | ||
6 | 7 | ||
7 | config PNP | 8 | config PNP |
8 | bool "Plug and Play support" | 9 | bool "Plug and Play support" |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 76422eded36e..95ce8f49e382 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Real Time Clock" | 5 | menu "Real Time Clock" |
6 | depends on !S390 | ||
6 | 7 | ||
7 | config RTC_LIB | 8 | config RTC_LIB |
8 | tristate | 9 | tristate |
@@ -245,7 +246,7 @@ comment "Platform RTC drivers" | |||
245 | config RTC_DRV_CMOS | 246 | config RTC_DRV_CMOS |
246 | tristate "PC-style 'CMOS'" | 247 | tristate "PC-style 'CMOS'" |
247 | depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \ | 248 | depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \ |
248 | || M32R || ATARI || POWERPC) | 249 | || M32R || ATARI || POWERPC || MIPS) |
249 | help | 250 | help |
250 | Say "yes" here to get direct support for the real time clock | 251 | Say "yes" here to get direct support for the real time clock |
251 | found in every PC or ACPI-based system, and some other boards. | 252 | found in every PC or ACPI-based system, and some other boards. |
@@ -396,7 +397,7 @@ config RTC_DRV_BFIN | |||
396 | 397 | ||
397 | config RTC_DRV_RS5C313 | 398 | config RTC_DRV_RS5C313 |
398 | tristate "Ricoh RS5C313" | 399 | tristate "Ricoh RS5C313" |
399 | depends on RTC_CLASS && BROKEN | 400 | depends on RTC_CLASS && SH_LANDISK |
400 | help | 401 | help |
401 | If you say yes here you get support for the Ricoh RS5C313 RTC chips. | 402 | If you say yes here you get support for the Ricoh RS5C313 RTC chips. |
402 | 403 | ||
diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index 9d6de371495b..66eb133bf5fd 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c | |||
@@ -126,7 +126,7 @@ static void rs5c313_write_data(unsigned char data) | |||
126 | static unsigned char rs5c313_read_data(void) | 126 | static unsigned char rs5c313_read_data(void) |
127 | { | 127 | { |
128 | int i; | 128 | int i; |
129 | unsigned char data; | 129 | unsigned char data = 0; |
130 | 130 | ||
131 | for (i = 0; i < 8; i++) { | 131 | for (i = 0; i < 8; i++) { |
132 | ndelay(700); | 132 | ndelay(700); |
@@ -194,7 +194,7 @@ static void rs5c313_write_reg(unsigned char addr, unsigned char data) | |||
194 | return; | 194 | return; |
195 | } | 195 | } |
196 | 196 | ||
197 | static inline unsigned char rs5c313_read_cntreg(unsigned char addr) | 197 | static inline unsigned char rs5c313_read_cntreg(void) |
198 | { | 198 | { |
199 | return rs5c313_read_reg(RS5C313_ADDR_CNTREG); | 199 | return rs5c313_read_reg(RS5C313_ADDR_CNTREG); |
200 | } | 200 | } |
@@ -212,7 +212,9 @@ static inline void rs5c313_write_intintvreg(unsigned char data) | |||
212 | static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) | 212 | static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) |
213 | { | 213 | { |
214 | int data; | 214 | int data; |
215 | int cnt; | ||
215 | 216 | ||
217 | cnt = 0; | ||
216 | while (1) { | 218 | while (1) { |
217 | RS5C313_CEENABLE; /* CE:H */ | 219 | RS5C313_CEENABLE; /* CE:H */ |
218 | 220 | ||
@@ -225,6 +227,10 @@ static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
225 | RS5C313_CEDISABLE; | 227 | RS5C313_CEDISABLE; |
226 | ndelay(700); /* CE:L */ | 228 | ndelay(700); /* CE:L */ |
227 | 229 | ||
230 | if (cnt++ > 100) { | ||
231 | dev_err(dev, "%s: timeout error\n", __FUNCTION__); | ||
232 | return -EIO; | ||
233 | } | ||
228 | } | 234 | } |
229 | 235 | ||
230 | data = rs5c313_read_reg(RS5C313_ADDR_SEC); | 236 | data = rs5c313_read_reg(RS5C313_ADDR_SEC); |
@@ -266,7 +272,9 @@ static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
266 | static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | 272 | static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) |
267 | { | 273 | { |
268 | int data; | 274 | int data; |
275 | int cnt; | ||
269 | 276 | ||
277 | cnt = 0; | ||
270 | /* busy check. */ | 278 | /* busy check. */ |
271 | while (1) { | 279 | while (1) { |
272 | RS5C313_CEENABLE; /* CE:H */ | 280 | RS5C313_CEENABLE; /* CE:H */ |
@@ -279,6 +287,11 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
279 | RS5C313_MISCOP; | 287 | RS5C313_MISCOP; |
280 | RS5C313_CEDISABLE; | 288 | RS5C313_CEDISABLE; |
281 | ndelay(700); /* CE:L */ | 289 | ndelay(700); /* CE:L */ |
290 | |||
291 | if (cnt++ > 100) { | ||
292 | dev_err(dev, "%s: timeout error\n", __FUNCTION__); | ||
293 | return -EIO; | ||
294 | } | ||
282 | } | 295 | } |
283 | 296 | ||
284 | data = BIN2BCD(tm->tm_sec); | 297 | data = BIN2BCD(tm->tm_sec); |
@@ -317,6 +330,7 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
317 | static void rs5c313_check_xstp_bit(void) | 330 | static void rs5c313_check_xstp_bit(void) |
318 | { | 331 | { |
319 | struct rtc_time tm; | 332 | struct rtc_time tm; |
333 | int cnt; | ||
320 | 334 | ||
321 | RS5C313_CEENABLE; /* CE:H */ | 335 | RS5C313_CEENABLE; /* CE:H */ |
322 | if (rs5c313_read_cntreg() & RS5C313_CNTREG_WTEN_XSTP) { | 336 | if (rs5c313_read_cntreg() & RS5C313_CNTREG_WTEN_XSTP) { |
@@ -326,12 +340,16 @@ static void rs5c313_check_xstp_bit(void) | |||
326 | rs5c313_write_cntreg(0x07); | 340 | rs5c313_write_cntreg(0x07); |
327 | 341 | ||
328 | /* busy check. */ | 342 | /* busy check. */ |
329 | while (rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY) | 343 | for (cnt = 0; cnt < 100; cnt++) { |
344 | if (!(rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY)) | ||
345 | break; | ||
330 | RS5C313_MISCOP; | 346 | RS5C313_MISCOP; |
347 | } | ||
331 | 348 | ||
332 | memset(&tm, 0, sizeof(struct rtc_time)); | 349 | memset(&tm, 0, sizeof(struct rtc_time)); |
333 | tm.tm_mday = 1; | 350 | tm.tm_mday = 1; |
334 | tm.tm_mon = 1; | 351 | tm.tm_mon = 1 - 1; |
352 | tm.tm_year = 2000 - 1900; | ||
335 | 353 | ||
336 | rs5c313_rtc_set_time(NULL, &tm); | 354 | rs5c313_rtc_set_time(NULL, &tm); |
337 | printk(KERN_ERR "RICHO RS5C313: invalid value, resetting to " | 355 | printk(KERN_ERR "RICHO RS5C313: invalid value, resetting to " |
@@ -356,7 +374,7 @@ static int rs5c313_rtc_probe(struct platform_device *pdev) | |||
356 | 374 | ||
357 | platform_set_drvdata(pdev, rtc); | 375 | platform_set_drvdata(pdev, rtc); |
358 | 376 | ||
359 | return err; | 377 | return 0; |
360 | } | 378 | } |
361 | 379 | ||
362 | static int __devexit rs5c313_rtc_remove(struct platform_device *pdev) | 380 | static int __devexit rs5c313_rtc_remove(struct platform_device *pdev) |
diff --git a/drivers/s390/block/Kconfig b/drivers/s390/block/Kconfig index b250c5354503..e879b212cf43 100644 --- a/drivers/s390/block/Kconfig +++ b/drivers/s390/block/Kconfig | |||
@@ -1,11 +1,9 @@ | |||
1 | if S390 && BLOCK | ||
2 | |||
3 | comment "S/390 block device drivers" | 1 | comment "S/390 block device drivers" |
4 | depends on S390 | 2 | depends on S390 && BLOCK |
5 | 3 | ||
6 | config BLK_DEV_XPRAM | 4 | config BLK_DEV_XPRAM |
7 | tristate "XPRAM disk support" | 5 | tristate "XPRAM disk support" |
8 | depends on S390 | 6 | depends on S390 && BLOCK |
9 | help | 7 | help |
10 | Select this option if you want to use your expanded storage on S/390 | 8 | Select this option if you want to use your expanded storage on S/390 |
11 | or zSeries as a disk. This is useful as a _fast_ swap device if you | 9 | or zSeries as a disk. This is useful as a _fast_ swap device if you |
@@ -15,12 +13,13 @@ config BLK_DEV_XPRAM | |||
15 | 13 | ||
16 | config DCSSBLK | 14 | config DCSSBLK |
17 | tristate "DCSSBLK support" | 15 | tristate "DCSSBLK support" |
16 | depends on S390 && BLOCK | ||
18 | help | 17 | help |
19 | Support for dcss block device | 18 | Support for dcss block device |
20 | 19 | ||
21 | config DASD | 20 | config DASD |
22 | tristate "Support for DASD devices" | 21 | tristate "Support for DASD devices" |
23 | depends on CCW | 22 | depends on CCW && BLOCK |
24 | help | 23 | help |
25 | Enable this option if you want to access DASDs directly utilizing | 24 | Enable this option if you want to access DASDs directly utilizing |
26 | S/390s channel subsystem commands. This is necessary for running | 25 | S/390s channel subsystem commands. This is necessary for running |
@@ -62,5 +61,3 @@ config DASD_EER | |||
62 | This driver provides a character device interface to the | 61 | This driver provides a character device interface to the |
63 | DASD extended error reporting. This is only needed if you want to | 62 | DASD extended error reporting. This is only needed if you want to |
64 | use applications written for the EER facility. | 63 | use applications written for the EER facility. |
65 | |||
66 | endif | ||
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 977521013fe8..bfeca57098fa 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c | |||
@@ -2174,9 +2174,10 @@ dasd_generic_notify(struct ccw_device *cdev, int event) | |||
2174 | return ret; | 2174 | return ret; |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | struct dasd_ccw_req * dasd_generic_build_rdc(struct dasd_device *device, | 2177 | static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device, |
2178 | void *rdc_buffer, | 2178 | void *rdc_buffer, |
2179 | int rdc_buffer_size, char *magic) | 2179 | int rdc_buffer_size, |
2180 | char *magic) | ||
2180 | { | 2181 | { |
2181 | struct dasd_ccw_req *cqr; | 2182 | struct dasd_ccw_req *cqr; |
2182 | struct ccw1 *ccw; | 2183 | struct ccw1 *ccw; |
@@ -2219,6 +2220,7 @@ int dasd_generic_read_dev_chars(struct dasd_device *device, char *magic, | |||
2219 | dasd_sfree_request(cqr, cqr->device); | 2220 | dasd_sfree_request(cqr, cqr->device); |
2220 | return ret; | 2221 | return ret; |
2221 | } | 2222 | } |
2223 | EXPORT_SYMBOL_GPL(dasd_generic_read_dev_chars); | ||
2222 | 2224 | ||
2223 | static int __init | 2225 | static int __init |
2224 | dasd_init(void) | 2226 | dasd_init(void) |
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c index e810e4a44ed4..eccac1c3b71b 100644 --- a/drivers/s390/block/dasd_diag.c +++ b/drivers/s390/block/dasd_diag.c | |||
@@ -50,6 +50,7 @@ struct dasd_diag_private { | |||
50 | struct dasd_diag_rw_io iob; | 50 | struct dasd_diag_rw_io iob; |
51 | struct dasd_diag_init_io iib; | 51 | struct dasd_diag_init_io iib; |
52 | blocknum_t pt_block; | 52 | blocknum_t pt_block; |
53 | struct ccw_dev_id dev_id; | ||
53 | }; | 54 | }; |
54 | 55 | ||
55 | struct dasd_diag_req { | 56 | struct dasd_diag_req { |
@@ -102,7 +103,7 @@ mdsk_init_io(struct dasd_device *device, unsigned int blocksize, | |||
102 | iib = &private->iib; | 103 | iib = &private->iib; |
103 | memset(iib, 0, sizeof (struct dasd_diag_init_io)); | 104 | memset(iib, 0, sizeof (struct dasd_diag_init_io)); |
104 | 105 | ||
105 | iib->dev_nr = _ccw_device_get_device_number(device->cdev); | 106 | iib->dev_nr = private->dev_id.devno; |
106 | iib->block_size = blocksize; | 107 | iib->block_size = blocksize; |
107 | iib->offset = offset; | 108 | iib->offset = offset; |
108 | iib->flaga = DASD_DIAG_FLAGA_DEFAULT; | 109 | iib->flaga = DASD_DIAG_FLAGA_DEFAULT; |
@@ -127,7 +128,7 @@ mdsk_term_io(struct dasd_device * device) | |||
127 | private = (struct dasd_diag_private *) device->private; | 128 | private = (struct dasd_diag_private *) device->private; |
128 | iib = &private->iib; | 129 | iib = &private->iib; |
129 | memset(iib, 0, sizeof (struct dasd_diag_init_io)); | 130 | memset(iib, 0, sizeof (struct dasd_diag_init_io)); |
130 | iib->dev_nr = _ccw_device_get_device_number(device->cdev); | 131 | iib->dev_nr = private->dev_id.devno; |
131 | rc = dia250(iib, TERM_BIO); | 132 | rc = dia250(iib, TERM_BIO); |
132 | return rc; | 133 | return rc; |
133 | } | 134 | } |
@@ -166,7 +167,7 @@ dasd_start_diag(struct dasd_ccw_req * cqr) | |||
166 | private = (struct dasd_diag_private *) device->private; | 167 | private = (struct dasd_diag_private *) device->private; |
167 | dreq = (struct dasd_diag_req *) cqr->data; | 168 | dreq = (struct dasd_diag_req *) cqr->data; |
168 | 169 | ||
169 | private->iob.dev_nr = _ccw_device_get_device_number(device->cdev); | 170 | private->iob.dev_nr = private->dev_id.devno; |
170 | private->iob.key = 0; | 171 | private->iob.key = 0; |
171 | private->iob.flags = DASD_DIAG_RWFLAG_ASYNC; | 172 | private->iob.flags = DASD_DIAG_RWFLAG_ASYNC; |
172 | private->iob.block_count = dreq->block_count; | 173 | private->iob.block_count = dreq->block_count; |
@@ -323,11 +324,12 @@ dasd_diag_check_device(struct dasd_device *device) | |||
323 | "memory allocation failed for private data"); | 324 | "memory allocation failed for private data"); |
324 | return -ENOMEM; | 325 | return -ENOMEM; |
325 | } | 326 | } |
327 | ccw_device_get_id(device->cdev, &private->dev_id); | ||
326 | device->private = (void *) private; | 328 | device->private = (void *) private; |
327 | } | 329 | } |
328 | /* Read Device Characteristics */ | 330 | /* Read Device Characteristics */ |
329 | rdc_data = (void *) &(private->rdc_data); | 331 | rdc_data = (void *) &(private->rdc_data); |
330 | rdc_data->dev_nr = _ccw_device_get_device_number(device->cdev); | 332 | rdc_data->dev_nr = private->dev_id.devno; |
331 | rdc_data->rdc_len = sizeof (struct dasd_diag_characteristics); | 333 | rdc_data->rdc_len = sizeof (struct dasd_diag_characteristics); |
332 | 334 | ||
333 | rc = diag210((struct diag210 *) rdc_data); | 335 | rc = diag210((struct diag210 *) rdc_data); |
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index c9583fbc2a7d..418b4e63a4fa 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c | |||
@@ -450,9 +450,9 @@ dasd_eckd_generate_uid(struct dasd_device *device, struct dasd_uid *uid) | |||
450 | return 0; | 450 | return 0; |
451 | } | 451 | } |
452 | 452 | ||
453 | struct dasd_ccw_req * dasd_eckd_build_rcd_lpm(struct dasd_device *device, | 453 | static struct dasd_ccw_req *dasd_eckd_build_rcd_lpm(struct dasd_device *device, |
454 | void *rcd_buffer, | 454 | void *rcd_buffer, |
455 | struct ciw *ciw, __u8 lpm) | 455 | struct ciw *ciw, __u8 lpm) |
456 | { | 456 | { |
457 | struct dasd_ccw_req *cqr; | 457 | struct dasd_ccw_req *cqr; |
458 | struct ccw1 *ccw; | 458 | struct ccw1 *ccw; |
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index 758cfb542865..672eb0a3dd0b 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c | |||
@@ -255,6 +255,7 @@ dasd_ioctl_information(struct dasd_device *device, | |||
255 | unsigned long flags; | 255 | unsigned long flags; |
256 | int rc; | 256 | int rc; |
257 | struct ccw_device *cdev; | 257 | struct ccw_device *cdev; |
258 | struct ccw_dev_id dev_id; | ||
258 | 259 | ||
259 | if (!device->discipline->fill_info) | 260 | if (!device->discipline->fill_info) |
260 | return -EINVAL; | 261 | return -EINVAL; |
@@ -270,8 +271,9 @@ dasd_ioctl_information(struct dasd_device *device, | |||
270 | } | 271 | } |
271 | 272 | ||
272 | cdev = device->cdev; | 273 | cdev = device->cdev; |
274 | ccw_device_get_id(cdev, &dev_id); | ||
273 | 275 | ||
274 | dasd_info->devno = _ccw_device_get_device_number(device->cdev); | 276 | dasd_info->devno = dev_id.devno; |
275 | dasd_info->schid = _ccw_device_get_subchannel_number(device->cdev); | 277 | dasd_info->schid = _ccw_device_get_subchannel_number(device->cdev); |
276 | dasd_info->cu_type = cdev->id.cu_type; | 278 | dasd_info->cu_type = cdev->id.cu_type; |
277 | dasd_info->cu_model = cdev->id.cu_model; | 279 | dasd_info->cu_model = cdev->id.cu_model; |
diff --git a/drivers/s390/Kconfig b/drivers/s390/char/Kconfig index 165af398fdea..66102a184322 100644 --- a/drivers/s390/Kconfig +++ b/drivers/s390/char/Kconfig | |||
@@ -1,69 +1,9 @@ | |||
1 | config CCW | ||
2 | bool | ||
3 | default y | ||
4 | |||
5 | source "drivers/block/Kconfig" | ||
6 | |||
7 | source "drivers/md/Kconfig" | ||
8 | |||
9 | |||
10 | menu "Character device drivers" | ||
11 | |||
12 | config UNIX98_PTYS | ||
13 | bool "Unix98 PTY support" | ||
14 | ---help--- | ||
15 | A pseudo terminal (PTY) is a software device consisting of two | ||
16 | halves: a master and a slave. The slave device behaves identical to | ||
17 | a physical terminal; the master device is used by a process to | ||
18 | read data from and write data to the slave, thereby emulating a | ||
19 | terminal. Typical programs for the master side are telnet servers | ||
20 | and xterms. | ||
21 | |||
22 | Linux has traditionally used the BSD-like names /dev/ptyxx for | ||
23 | masters and /dev/ttyxx for slaves of pseudo terminals. This scheme | ||
24 | has a number of problems. The GNU C library glibc 2.1 and later, | ||
25 | however, supports the Unix98 naming standard: in order to acquire a | ||
26 | pseudo terminal, a process opens /dev/ptmx; the number of the pseudo | ||
27 | terminal is then made available to the process and the pseudo | ||
28 | terminal slave can be accessed as /dev/pts/<number>. What was | ||
29 | traditionally /dev/ttyp2 will then be /dev/pts/2, for example. | ||
30 | |||
31 | The entries in /dev/pts/ are created on the fly by a virtual | ||
32 | file system; therefore, if you say Y here you should say Y to | ||
33 | "/dev/pts file system for Unix98 PTYs" as well. | ||
34 | |||
35 | If you want to say Y here, you need to have the C library glibc 2.1 | ||
36 | or later (equal to libc-6.1, check with "ls -l /lib/libc.so.*"). | ||
37 | Read the instructions in <file:Documentation/Changes> pertaining to | ||
38 | pseudo terminals. It's safe to say N. | ||
39 | |||
40 | config UNIX98_PTY_COUNT | ||
41 | int "Maximum number of Unix98 PTYs in use (0-2048)" | ||
42 | depends on UNIX98_PTYS | ||
43 | default "256" | ||
44 | help | ||
45 | The maximum number of Unix98 PTYs that can be used at any one time. | ||
46 | The default is 256, and should be enough for desktop systems. Server | ||
47 | machines which support incoming telnet/rlogin/ssh connections and/or | ||
48 | serve several X terminals may want to increase this: every incoming | ||
49 | connection and every xterm uses up one PTY. | ||
50 | |||
51 | When not in use, each additional set of 256 PTYs occupy | ||
52 | approximately 8 KB of kernel memory on 32-bit architectures. | ||
53 | |||
54 | config HANGCHECK_TIMER | ||
55 | tristate "Hangcheck timer" | ||
56 | help | ||
57 | The hangcheck-timer module detects when the system has gone | ||
58 | out to lunch past a certain margin. It can reboot the system | ||
59 | or merely print a warning. | ||
60 | |||
61 | source "drivers/char/watchdog/Kconfig" | ||
62 | |||
63 | comment "S/390 character device drivers" | 1 | comment "S/390 character device drivers" |
2 | depends on S390 | ||
64 | 3 | ||
65 | config TN3270 | 4 | config TN3270 |
66 | tristate "Support for locally attached 3270 terminals" | 5 | tristate "Support for locally attached 3270 terminals" |
6 | depends on CCW | ||
67 | help | 7 | help |
68 | Include support for IBM 3270 terminals. | 8 | Include support for IBM 3270 terminals. |
69 | 9 | ||
@@ -88,6 +28,7 @@ config TN3270_CONSOLE | |||
88 | 28 | ||
89 | config TN3215 | 29 | config TN3215 |
90 | bool "Support for 3215 line mode terminal" | 30 | bool "Support for 3215 line mode terminal" |
31 | depends on CCW | ||
91 | help | 32 | help |
92 | Include support for IBM 3215 line-mode terminals. | 33 | Include support for IBM 3215 line-mode terminals. |
93 | 34 | ||
@@ -99,12 +40,19 @@ config TN3215_CONSOLE | |||
99 | Linux system console. | 40 | Linux system console. |
100 | 41 | ||
101 | config CCW_CONSOLE | 42 | config CCW_CONSOLE |
102 | bool | 43 | bool |
103 | depends on TN3215_CONSOLE || TN3270_CONSOLE | 44 | depends on TN3215_CONSOLE || TN3270_CONSOLE |
104 | default y | 45 | default y |
105 | 46 | ||
47 | config SCLP | ||
48 | bool "Support for SCLP" | ||
49 | depends on S390 | ||
50 | help | ||
51 | Include support for the SCLP interface to the service element. | ||
52 | |||
106 | config SCLP_TTY | 53 | config SCLP_TTY |
107 | bool "Support for SCLP line mode terminal" | 54 | bool "Support for SCLP line mode terminal" |
55 | depends on SCLP | ||
108 | help | 56 | help |
109 | Include support for IBM SCLP line-mode terminals. | 57 | Include support for IBM SCLP line-mode terminals. |
110 | 58 | ||
@@ -117,6 +65,7 @@ config SCLP_CONSOLE | |||
117 | 65 | ||
118 | config SCLP_VT220_TTY | 66 | config SCLP_VT220_TTY |
119 | bool "Support for SCLP VT220-compatible terminal" | 67 | bool "Support for SCLP VT220-compatible terminal" |
68 | depends on SCLP | ||
120 | help | 69 | help |
121 | Include support for an IBM SCLP VT220-compatible terminal. | 70 | Include support for an IBM SCLP VT220-compatible terminal. |
122 | 71 | ||
@@ -129,6 +78,7 @@ config SCLP_VT220_CONSOLE | |||
129 | 78 | ||
130 | config SCLP_CPI | 79 | config SCLP_CPI |
131 | tristate "Control-Program Identification" | 80 | tristate "Control-Program Identification" |
81 | depends on SCLP | ||
132 | help | 82 | help |
133 | This option enables the hardware console interface for system | 83 | This option enables the hardware console interface for system |
134 | identification. This is commonly used for workload management and | 84 | identification. This is commonly used for workload management and |
@@ -140,6 +90,7 @@ config SCLP_CPI | |||
140 | 90 | ||
141 | config S390_TAPE | 91 | config S390_TAPE |
142 | tristate "S/390 tape device support" | 92 | tristate "S/390 tape device support" |
93 | depends on CCW | ||
143 | help | 94 | help |
144 | Select this option if you want to access channel-attached tape | 95 | Select this option if you want to access channel-attached tape |
145 | devices on IBM S/390 or zSeries. | 96 | devices on IBM S/390 or zSeries. |
@@ -194,6 +145,7 @@ config VMLOGRDR | |||
194 | 145 | ||
195 | config VMCP | 146 | config VMCP |
196 | tristate "Support for the z/VM CP interface (VM only)" | 147 | tristate "Support for the z/VM CP interface (VM only)" |
148 | depends on S390 | ||
197 | help | 149 | help |
198 | Select this option if you want to be able to interact with the control | 150 | Select this option if you want to be able to interact with the control |
199 | program on z/VM | 151 | program on z/VM |
@@ -207,33 +159,8 @@ config MONREADER | |||
207 | 159 | ||
208 | config MONWRITER | 160 | config MONWRITER |
209 | tristate "API for writing z/VM monitor service records" | 161 | tristate "API for writing z/VM monitor service records" |
162 | depends on S390 | ||
210 | default "m" | 163 | default "m" |
211 | help | 164 | help |
212 | Character device driver for writing z/VM monitor service records | 165 | Character device driver for writing z/VM monitor service records |
213 | 166 | ||
214 | endmenu | ||
215 | |||
216 | menu "Cryptographic devices" | ||
217 | |||
218 | config ZCRYPT | ||
219 | tristate "Support for PCI-attached cryptographic adapters" | ||
220 | select ZCRYPT_MONOLITHIC if ZCRYPT="y" | ||
221 | default "m" | ||
222 | help | ||
223 | Select this option if you want to use a PCI-attached cryptographic | ||
224 | adapter like: | ||
225 | + PCI Cryptographic Accelerator (PCICA) | ||
226 | + PCI Cryptographic Coprocessor (PCICC) | ||
227 | + PCI-X Cryptographic Coprocessor (PCIXCC) | ||
228 | + Crypto Express2 Coprocessor (CEX2C) | ||
229 | + Crypto Express2 Accelerator (CEX2A) | ||
230 | |||
231 | config ZCRYPT_MONOLITHIC | ||
232 | bool "Monolithic zcrypt module" | ||
233 | depends on ZCRYPT="m" | ||
234 | help | ||
235 | Select this option if you want to have a single module z90crypt.ko | ||
236 | that contains all parts of the crypto device driver (ap bus, | ||
237 | request router and all the card drivers). | ||
238 | |||
239 | endmenu | ||
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c index 8df7b1323c05..67009bfa093e 100644 --- a/drivers/s390/char/monreader.c +++ b/drivers/s390/char/monreader.c | |||
@@ -97,7 +97,7 @@ static u8 user_data_sever[16] = { | |||
97 | * Create the 8 bytes EBCDIC DCSS segment name from | 97 | * Create the 8 bytes EBCDIC DCSS segment name from |
98 | * an ASCII name, incl. padding | 98 | * an ASCII name, incl. padding |
99 | */ | 99 | */ |
100 | static inline void dcss_mkname(char *ascii_name, char *ebcdic_name) | 100 | static void dcss_mkname(char *ascii_name, char *ebcdic_name) |
101 | { | 101 | { |
102 | int i; | 102 | int i; |
103 | 103 | ||
@@ -191,7 +191,7 @@ static inline u32 mon_rec_end(struct mon_msg *monmsg) | |||
191 | return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 8)); | 191 | return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 8)); |
192 | } | 192 | } |
193 | 193 | ||
194 | static inline int mon_check_mca(struct mon_msg *monmsg) | 194 | static int mon_check_mca(struct mon_msg *monmsg) |
195 | { | 195 | { |
196 | if ((mon_rec_end(monmsg) <= mon_rec_start(monmsg)) || | 196 | if ((mon_rec_end(monmsg) <= mon_rec_start(monmsg)) || |
197 | (mon_rec_start(monmsg) < mon_dcss_start) || | 197 | (mon_rec_start(monmsg) < mon_dcss_start) || |
@@ -209,8 +209,8 @@ static inline int mon_check_mca(struct mon_msg *monmsg) | |||
209 | return 0; | 209 | return 0; |
210 | } | 210 | } |
211 | 211 | ||
212 | static inline int mon_send_reply(struct mon_msg *monmsg, | 212 | static int mon_send_reply(struct mon_msg *monmsg, |
213 | struct mon_private *monpriv) | 213 | struct mon_private *monpriv) |
214 | { | 214 | { |
215 | int rc; | 215 | int rc; |
216 | 216 | ||
@@ -236,7 +236,7 @@ static inline int mon_send_reply(struct mon_msg *monmsg, | |||
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | 238 | ||
239 | static inline void mon_free_mem(struct mon_private *monpriv) | 239 | static void mon_free_mem(struct mon_private *monpriv) |
240 | { | 240 | { |
241 | int i; | 241 | int i; |
242 | 242 | ||
@@ -246,7 +246,7 @@ static inline void mon_free_mem(struct mon_private *monpriv) | |||
246 | kfree(monpriv); | 246 | kfree(monpriv); |
247 | } | 247 | } |
248 | 248 | ||
249 | static inline struct mon_private *mon_alloc_mem(void) | 249 | static struct mon_private *mon_alloc_mem(void) |
250 | { | 250 | { |
251 | int i; | 251 | int i; |
252 | struct mon_private *monpriv; | 252 | struct mon_private *monpriv; |
@@ -307,7 +307,7 @@ static inline void mon_next_mca(struct mon_msg *monmsg) | |||
307 | monmsg->pos = 0; | 307 | monmsg->pos = 0; |
308 | } | 308 | } |
309 | 309 | ||
310 | static inline struct mon_msg *mon_next_message(struct mon_private *monpriv) | 310 | static struct mon_msg *mon_next_message(struct mon_private *monpriv) |
311 | { | 311 | { |
312 | struct mon_msg *monmsg; | 312 | struct mon_msg *monmsg; |
313 | 313 | ||
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c index 8facd14adb7c..f6ef90ee3e7d 100644 --- a/drivers/s390/char/raw3270.c +++ b/drivers/s390/char/raw3270.c | |||
@@ -589,9 +589,10 @@ static int | |||
589 | __raw3270_size_device_vm(struct raw3270 *rp) | 589 | __raw3270_size_device_vm(struct raw3270 *rp) |
590 | { | 590 | { |
591 | int rc, model; | 591 | int rc, model; |
592 | struct ccw_dev_id dev_id; | ||
592 | 593 | ||
593 | raw3270_init_diag210.vrdcdvno = | 594 | ccw_device_get_id(rp->cdev, &dev_id); |
594 | _ccw_device_get_device_number(rp->cdev); | 595 | raw3270_init_diag210.vrdcdvno = dev_id.devno; |
595 | raw3270_init_diag210.vrdclen = sizeof(struct diag210); | 596 | raw3270_init_diag210.vrdclen = sizeof(struct diag210); |
596 | rc = diag210(&raw3270_init_diag210); | 597 | rc = diag210(&raw3270_init_diag210); |
597 | if (rc) | 598 | if (rc) |
diff --git a/drivers/s390/char/sclp.h b/drivers/s390/char/sclp.h index 87ac4a3ad49d..dbb99d1b6f57 100644 --- a/drivers/s390/char/sclp.h +++ b/drivers/s390/char/sclp.h | |||
@@ -132,6 +132,9 @@ int sclp_deactivate(void); | |||
132 | int sclp_reactivate(void); | 132 | int sclp_reactivate(void); |
133 | int sclp_service_call(sclp_cmdw_t command, void *sccb); | 133 | int sclp_service_call(sclp_cmdw_t command, void *sccb); |
134 | 134 | ||
135 | int sclp_sdias_init(void); | ||
136 | void sclp_sdias_exit(void); | ||
137 | |||
135 | /* useful inlines */ | 138 | /* useful inlines */ |
136 | 139 | ||
137 | /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */ | 140 | /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */ |
diff --git a/drivers/s390/char/sclp_sdias.c b/drivers/s390/char/sclp_sdias.c index 52283daddaef..1c064976b32b 100644 --- a/drivers/s390/char/sclp_sdias.c +++ b/drivers/s390/char/sclp_sdias.c | |||
@@ -66,9 +66,9 @@ static DEFINE_MUTEX(sdias_mutex); | |||
66 | 66 | ||
67 | static void sdias_callback(struct sclp_req *request, void *data) | 67 | static void sdias_callback(struct sclp_req *request, void *data) |
68 | { | 68 | { |
69 | struct sdias_sccb *sccb; | 69 | struct sdias_sccb *cbsccb; |
70 | 70 | ||
71 | sccb = (struct sdias_sccb *) request->sccb; | 71 | cbsccb = (struct sdias_sccb *) request->sccb; |
72 | sclp_req_done = 1; | 72 | sclp_req_done = 1; |
73 | wake_up(&sdias_wq); /* Inform caller, that request is complete */ | 73 | wake_up(&sdias_wq); /* Inform caller, that request is complete */ |
74 | TRACE("callback done\n"); | 74 | TRACE("callback done\n"); |
@@ -229,7 +229,7 @@ out: | |||
229 | return rc; | 229 | return rc; |
230 | } | 230 | } |
231 | 231 | ||
232 | int __init sdias_init(void) | 232 | int __init sclp_sdias_init(void) |
233 | { | 233 | { |
234 | int rc; | 234 | int rc; |
235 | 235 | ||
@@ -248,7 +248,7 @@ int __init sdias_init(void) | |||
248 | return 0; | 248 | return 0; |
249 | } | 249 | } |
250 | 250 | ||
251 | void __exit sdias_exit(void) | 251 | void __exit sclp_sdias_exit(void) |
252 | { | 252 | { |
253 | debug_unregister(sdias_dbf); | 253 | debug_unregister(sdias_dbf); |
254 | sclp_unregister(&sclp_sdias_register); | 254 | sclp_unregister(&sclp_sdias_register); |
diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c index 89d439316a53..66eb0688d523 100644 --- a/drivers/s390/char/zcore.c +++ b/drivers/s390/char/zcore.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/debug.h> | 21 | #include <asm/debug.h> |
22 | #include <asm/processor.h> | 22 | #include <asm/processor.h> |
23 | #include <asm/irqflags.h> | 23 | #include <asm/irqflags.h> |
24 | #include "sclp.h" | ||
24 | 25 | ||
25 | #define TRACE(x...) debug_sprintf_event(zcore_dbf, 1, x) | 26 | #define TRACE(x...) debug_sprintf_event(zcore_dbf, 1, x) |
26 | #define MSG(x...) printk( KERN_ALERT x ) | 27 | #define MSG(x...) printk( KERN_ALERT x ) |
@@ -564,8 +565,6 @@ static void __init zcore_header_init(int arch, struct zcore_header *hdr) | |||
564 | get_cpu_id(&hdr->cpu_id); | 565 | get_cpu_id(&hdr->cpu_id); |
565 | } | 566 | } |
566 | 567 | ||
567 | extern int sdias_init(void); | ||
568 | |||
569 | static int __init zcore_init(void) | 568 | static int __init zcore_init(void) |
570 | { | 569 | { |
571 | unsigned char arch; | 570 | unsigned char arch; |
@@ -582,7 +581,7 @@ static int __init zcore_init(void) | |||
582 | TRACE("wwpn: %llx\n", (unsigned long long) ipl_info.data.fcp.wwpn); | 581 | TRACE("wwpn: %llx\n", (unsigned long long) ipl_info.data.fcp.wwpn); |
583 | TRACE("lun: %llx\n", (unsigned long long) ipl_info.data.fcp.lun); | 582 | TRACE("lun: %llx\n", (unsigned long long) ipl_info.data.fcp.lun); |
584 | 583 | ||
585 | rc = sdias_init(); | 584 | rc = sclp_sdias_init(); |
586 | if (rc) | 585 | if (rc) |
587 | goto fail; | 586 | goto fail; |
588 | 587 | ||
@@ -634,12 +633,10 @@ fail: | |||
634 | return rc; | 633 | return rc; |
635 | } | 634 | } |
636 | 635 | ||
637 | extern void sdias_exit(void); | ||
638 | |||
639 | static void __exit zcore_exit(void) | 636 | static void __exit zcore_exit(void) |
640 | { | 637 | { |
641 | debug_unregister(zcore_dbf); | 638 | debug_unregister(zcore_dbf); |
642 | sdias_exit(); | 639 | sclp_sdias_exit(); |
643 | diag308(DIAG308_REL_HSA, NULL); | 640 | diag308(DIAG308_REL_HSA, NULL); |
644 | } | 641 | } |
645 | 642 | ||
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 27c6d9e55b23..dfca0ef139fd 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c | |||
@@ -191,8 +191,7 @@ static int css_register_subchannel(struct subchannel *sch) | |||
191 | return ret; | 191 | return ret; |
192 | } | 192 | } |
193 | 193 | ||
194 | int | 194 | static int css_probe_device(struct subchannel_id schid) |
195 | css_probe_device(struct subchannel_id schid) | ||
196 | { | 195 | { |
197 | int ret; | 196 | int ret; |
198 | struct subchannel *sch; | 197 | struct subchannel *sch; |
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h index 71fcfdc42800..ed7977531c3f 100644 --- a/drivers/s390/cio/css.h +++ b/drivers/s390/cio/css.h | |||
@@ -138,9 +138,7 @@ struct css_driver { | |||
138 | * all css_drivers have the css_bus_type | 138 | * all css_drivers have the css_bus_type |
139 | */ | 139 | */ |
140 | extern struct bus_type css_bus_type; | 140 | extern struct bus_type css_bus_type; |
141 | extern struct css_driver io_subchannel_driver; | ||
142 | 141 | ||
143 | extern int css_probe_device(struct subchannel_id); | ||
144 | extern int css_sch_device_register(struct subchannel *); | 142 | extern int css_sch_device_register(struct subchannel *); |
145 | extern void css_sch_device_unregister(struct subchannel *); | 143 | extern void css_sch_device_unregister(struct subchannel *); |
146 | extern struct subchannel * get_subchannel_by_schid(struct subchannel_id); | 144 | extern struct subchannel * get_subchannel_by_schid(struct subchannel_id); |
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index a23ff582db9d..a8b373f69cf0 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c | |||
@@ -129,7 +129,7 @@ static void io_subchannel_verify(struct device *); | |||
129 | static void io_subchannel_ioterm(struct device *); | 129 | static void io_subchannel_ioterm(struct device *); |
130 | static void io_subchannel_shutdown(struct subchannel *); | 130 | static void io_subchannel_shutdown(struct subchannel *); |
131 | 131 | ||
132 | struct css_driver io_subchannel_driver = { | 132 | static struct css_driver io_subchannel_driver = { |
133 | .subchannel_type = SUBCHANNEL_TYPE_IO, | 133 | .subchannel_type = SUBCHANNEL_TYPE_IO, |
134 | .drv = { | 134 | .drv = { |
135 | .name = "io_subchannel", | 135 | .name = "io_subchannel", |
@@ -546,7 +546,7 @@ static struct attribute_group ccwdev_attr_group = { | |||
546 | .attrs = ccwdev_attrs, | 546 | .attrs = ccwdev_attrs, |
547 | }; | 547 | }; |
548 | 548 | ||
549 | struct attribute_group *ccwdev_attr_groups[] = { | 549 | static struct attribute_group *ccwdev_attr_groups[] = { |
550 | &ccwdev_attr_group, | 550 | &ccwdev_attr_group, |
551 | NULL, | 551 | NULL, |
552 | }; | 552 | }; |
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c index 16f59fcb66b1..a5d263fb55ae 100644 --- a/drivers/s390/cio/device_ops.c +++ b/drivers/s390/cio/device_ops.c | |||
@@ -616,6 +616,17 @@ ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no) | |||
616 | return chp_get_chp_desc(chpid); | 616 | return chp_get_chp_desc(chpid); |
617 | } | 617 | } |
618 | 618 | ||
619 | /** | ||
620 | * ccw_device_get_id - obtain a ccw device id | ||
621 | * @cdev: device to obtain the id for | ||
622 | * @dev_id: where to fill in the values | ||
623 | */ | ||
624 | void ccw_device_get_id(struct ccw_device *cdev, struct ccw_dev_id *dev_id) | ||
625 | { | ||
626 | *dev_id = cdev->private->dev_id; | ||
627 | } | ||
628 | EXPORT_SYMBOL(ccw_device_get_id); | ||
629 | |||
619 | // FIXME: these have to go: | 630 | // FIXME: these have to go: |
620 | 631 | ||
621 | int | 632 | int |
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index f770018fe1d5..e70aeb7a3781 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c | |||
@@ -1983,6 +1983,7 @@ qdio_handle_pci(struct qdio_irq *irq_ptr) | |||
1983 | if (q->is_input_q&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT) | 1983 | if (q->is_input_q&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT) |
1984 | qdio_mark_q(q); | 1984 | qdio_mark_q(q); |
1985 | else { | 1985 | else { |
1986 | qdio_perf_stat_dec(&perf_stats.tl_runs); | ||
1986 | __qdio_inbound_processing(q); | 1987 | __qdio_inbound_processing(q); |
1987 | } | 1988 | } |
1988 | } | 1989 | } |
diff --git a/drivers/s390/net/Kconfig b/drivers/s390/net/Kconfig index f98fa465df0a..eada69dec4fe 100644 --- a/drivers/s390/net/Kconfig +++ b/drivers/s390/net/Kconfig | |||
@@ -3,7 +3,7 @@ menu "S/390 network device drivers" | |||
3 | 3 | ||
4 | config LCS | 4 | config LCS |
5 | tristate "Lan Channel Station Interface" | 5 | tristate "Lan Channel Station Interface" |
6 | depends on NETDEVICES && (NET_ETHERNET || TR || FDDI) | 6 | depends on CCW && NETDEVICES && (NET_ETHERNET || TR || FDDI) |
7 | help | 7 | help |
8 | Select this option if you want to use LCS networking on IBM S/390 | 8 | Select this option if you want to use LCS networking on IBM S/390 |
9 | or zSeries. This device driver supports Token Ring (IEEE 802.5), | 9 | or zSeries. This device driver supports Token Ring (IEEE 802.5), |
@@ -13,7 +13,7 @@ config LCS | |||
13 | 13 | ||
14 | config CTC | 14 | config CTC |
15 | tristate "CTC device support" | 15 | tristate "CTC device support" |
16 | depends on NETDEVICES | 16 | depends on CCW && NETDEVICES |
17 | help | 17 | help |
18 | Select this option if you want to use channel-to-channel networking | 18 | Select this option if you want to use channel-to-channel networking |
19 | on IBM S/390 or zSeries. This device driver supports real CTC | 19 | on IBM S/390 or zSeries. This device driver supports real CTC |
@@ -42,7 +42,7 @@ config SMSGIUCV | |||
42 | 42 | ||
43 | config CLAW | 43 | config CLAW |
44 | tristate "CLAW device support" | 44 | tristate "CLAW device support" |
45 | depends on NETDEVICES | 45 | depends on CCW && NETDEVICES |
46 | help | 46 | help |
47 | This driver supports channel attached CLAW devices. | 47 | This driver supports channel attached CLAW devices. |
48 | CLAW is Common Link Access for Workstation. Common devices | 48 | CLAW is Common Link Access for Workstation. Common devices |
@@ -52,7 +52,7 @@ config CLAW | |||
52 | 52 | ||
53 | config QETH | 53 | config QETH |
54 | tristate "Gigabit Ethernet device support" | 54 | tristate "Gigabit Ethernet device support" |
55 | depends on NETDEVICES && IP_MULTICAST && QDIO | 55 | depends on CCW && NETDEVICES && IP_MULTICAST && QDIO |
56 | help | 56 | help |
57 | This driver supports the IBM S/390 and zSeries OSA Express adapters | 57 | This driver supports the IBM S/390 and zSeries OSA Express adapters |
58 | in QDIO mode (all media types), HiperSockets interfaces and VM GuestLAN | 58 | in QDIO mode (all media types), HiperSockets interfaces and VM GuestLAN |
diff --git a/drivers/s390/net/qeth_mpc.c b/drivers/s390/net/qeth_mpc.c index f54fdfdbf06f..f29a4bc4f6f2 100644 --- a/drivers/s390/net/qeth_mpc.c +++ b/drivers/s390/net/qeth_mpc.c | |||
@@ -162,7 +162,7 @@ struct ipa_rc_msg { | |||
162 | char *msg; | 162 | char *msg; |
163 | }; | 163 | }; |
164 | 164 | ||
165 | struct ipa_rc_msg qeth_ipa_rc_msg[] = { | 165 | static struct ipa_rc_msg qeth_ipa_rc_msg[] = { |
166 | {IPA_RC_SUCCESS, "success"}, | 166 | {IPA_RC_SUCCESS, "success"}, |
167 | {IPA_RC_NOTSUPP, "Command not supported"}, | 167 | {IPA_RC_NOTSUPP, "Command not supported"}, |
168 | {IPA_RC_IP_TABLE_FULL, "Add Addr IP Table Full - ipv6"}, | 168 | {IPA_RC_IP_TABLE_FULL, "Add Addr IP Table Full - ipv6"}, |
@@ -226,7 +226,7 @@ struct ipa_cmd_names { | |||
226 | char *name; | 226 | char *name; |
227 | }; | 227 | }; |
228 | 228 | ||
229 | struct ipa_cmd_names qeth_ipa_cmd_names[] = { | 229 | static struct ipa_cmd_names qeth_ipa_cmd_names[] = { |
230 | {IPA_CMD_STARTLAN, "startlan"}, | 230 | {IPA_CMD_STARTLAN, "startlan"}, |
231 | {IPA_CMD_STOPLAN, "stoplan"}, | 231 | {IPA_CMD_STOPLAN, "stoplan"}, |
232 | {IPA_CMD_SETVMAC, "setvmac"}, | 232 | {IPA_CMD_SETVMAC, "setvmac"}, |
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index 324899c96efe..ddff40c4212c 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c | |||
@@ -607,8 +607,7 @@ zfcp_sg_list_free(struct zfcp_sg_list *sg_list) | |||
607 | * @sg_count: elements in array | 607 | * @sg_count: elements in array |
608 | * Return: size of entire scatter-gather list | 608 | * Return: size of entire scatter-gather list |
609 | */ | 609 | */ |
610 | size_t | 610 | static size_t zfcp_sg_size(struct scatterlist *sg, unsigned int sg_count) |
611 | zfcp_sg_size(struct scatterlist *sg, unsigned int sg_count) | ||
612 | { | 611 | { |
613 | unsigned int i; | 612 | unsigned int i; |
614 | struct scatterlist *p; | 613 | struct scatterlist *p; |
@@ -975,8 +974,7 @@ zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter) | |||
975 | mempool_destroy(adapter->pool.data_gid_pn); | 974 | mempool_destroy(adapter->pool.data_gid_pn); |
976 | } | 975 | } |
977 | 976 | ||
978 | void | 977 | static void zfcp_dummy_release(struct device *dev) |
979 | zfcp_dummy_release(struct device *dev) | ||
980 | { | 978 | { |
981 | return; | 979 | return; |
982 | } | 980 | } |
@@ -1336,7 +1334,7 @@ zfcp_nameserver_enqueue(struct zfcp_adapter *adapter) | |||
1336 | 1334 | ||
1337 | #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FC | 1335 | #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FC |
1338 | 1336 | ||
1339 | void | 1337 | static void |
1340 | zfcp_fsf_incoming_els_rscn(struct zfcp_adapter *adapter, | 1338 | zfcp_fsf_incoming_els_rscn(struct zfcp_adapter *adapter, |
1341 | struct fsf_status_read_buffer *status_buffer) | 1339 | struct fsf_status_read_buffer *status_buffer) |
1342 | { | 1340 | { |
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index d8191d115c14..5f3212440f68 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c | |||
@@ -478,7 +478,7 @@ static struct debug_view zfcp_hba_dbf_view = { | |||
478 | NULL | 478 | NULL |
479 | }; | 479 | }; |
480 | 480 | ||
481 | void | 481 | static void |
482 | _zfcp_san_dbf_event_common_ct(const char *tag, struct zfcp_fsf_req *fsf_req, | 482 | _zfcp_san_dbf_event_common_ct(const char *tag, struct zfcp_fsf_req *fsf_req, |
483 | u32 s_id, u32 d_id, void *buffer, int buflen) | 483 | u32 s_id, u32 d_id, void *buffer, int buflen) |
484 | { | 484 | { |
diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c index 8410587348f1..178155bf9db6 100644 --- a/drivers/sbus/char/bbc_i2c.c +++ b/drivers/sbus/char/bbc_i2c.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <asm/ebus.h> | 18 | #include <asm/ebus.h> |
19 | #include <asm/spitfire.h> | 19 | #include <asm/spitfire.h> |
20 | #include <asm/bbc.h> | 20 | #include <asm/bbc.h> |
21 | #include <asm/io.h> | ||
21 | 22 | ||
22 | #include "bbc_i2c.h" | 23 | #include "bbc_i2c.h" |
23 | 24 | ||
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index 2d14a29effe4..3279a1b6501d 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <asm/ebus.h> /* EBus device */ | 20 | #include <asm/ebus.h> /* EBus device */ |
21 | #include <asm/oplib.h> /* OpenProm Library */ | 21 | #include <asm/oplib.h> /* OpenProm Library */ |
22 | #include <asm/uaccess.h> /* put_/get_user */ | 22 | #include <asm/uaccess.h> /* put_/get_user */ |
23 | #include <asm/io.h> | ||
23 | 24 | ||
24 | #include <asm/display7seg.h> | 25 | #include <asm/display7seg.h> |
25 | 26 | ||
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index f2be2ead8742..8328acab47fd 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <asm/ebus.h> | 30 | #include <asm/ebus.h> |
31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
32 | #include <asm/envctrl.h> | 32 | #include <asm/envctrl.h> |
33 | #include <asm/io.h> | ||
33 | 34 | ||
34 | #define ENVCTRL_MINOR 162 | 35 | #define ENVCTRL_MINOR 162 |
35 | 36 | ||
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index e62d23f65180..d28c14e23c32 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -1757,6 +1757,14 @@ config SCSI_ESP_CORE | |||
1757 | tristate "ESP Scsi Driver Core" | 1757 | tristate "ESP Scsi Driver Core" |
1758 | depends on SCSI | 1758 | depends on SCSI |
1759 | select SCSI_SPI_ATTRS | 1759 | select SCSI_SPI_ATTRS |
1760 | help | ||
1761 | This is a core driver for NCR53c9x based scsi chipsets, | ||
1762 | also known as "ESP" for Emulex Scsi Processor or | ||
1763 | Enhanced Scsi Processor. This driver does not exist by | ||
1764 | itself, there are front-end drivers which, when enabled, | ||
1765 | select and enable this driver. One example is SCSI_SUNESP. | ||
1766 | These front-end drivers provide probing, DMA, and register | ||
1767 | access support for the core driver. | ||
1760 | 1768 | ||
1761 | config SCSI_SUNESP | 1769 | config SCSI_SUNESP |
1762 | tristate "Sparc ESP Scsi Driver" | 1770 | tristate "Sparc ESP Scsi Driver" |
diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c index 7e132c5bacf8..2836fe248df9 100644 --- a/drivers/scsi/arm/arxescsi.c +++ b/drivers/scsi/arm/arxescsi.c | |||
@@ -281,7 +281,6 @@ arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
281 | { | 281 | { |
282 | struct Scsi_Host *host; | 282 | struct Scsi_Host *host; |
283 | struct arxescsi_info *info; | 283 | struct arxescsi_info *info; |
284 | unsigned long resbase, reslen; | ||
285 | void __iomem *base; | 284 | void __iomem *base; |
286 | int ret; | 285 | int ret; |
287 | 286 | ||
@@ -289,9 +288,7 @@ arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
289 | if (ret) | 288 | if (ret) |
290 | goto out; | 289 | goto out; |
291 | 290 | ||
292 | resbase = ecard_resource_start(ec, ECARD_RES_MEMC); | 291 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
293 | reslen = ecard_resource_len(ec, ECARD_RES_MEMC); | ||
294 | base = ioremap(resbase, reslen); | ||
295 | if (!base) { | 292 | if (!base) { |
296 | ret = -ENOMEM; | 293 | ret = -ENOMEM; |
297 | goto out_region; | 294 | goto out_region; |
@@ -300,7 +297,7 @@ arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
300 | host = scsi_host_alloc(&arxescsi_template, sizeof(struct arxescsi_info)); | 297 | host = scsi_host_alloc(&arxescsi_template, sizeof(struct arxescsi_info)); |
301 | if (!host) { | 298 | if (!host) { |
302 | ret = -ENOMEM; | 299 | ret = -ENOMEM; |
303 | goto out_unmap; | 300 | goto out_region; |
304 | } | 301 | } |
305 | 302 | ||
306 | info = (struct arxescsi_info *)host->hostdata; | 303 | info = (struct arxescsi_info *)host->hostdata; |
@@ -337,8 +334,6 @@ arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
337 | fas216_release(host); | 334 | fas216_release(host); |
338 | out_unregister: | 335 | out_unregister: |
339 | scsi_host_put(host); | 336 | scsi_host_put(host); |
340 | out_unmap: | ||
341 | iounmap(base); | ||
342 | out_region: | 337 | out_region: |
343 | ecard_release_resources(ec); | 338 | ecard_release_resources(ec); |
344 | out: | 339 | out: |
@@ -348,13 +343,10 @@ arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
348 | static void __devexit arxescsi_remove(struct expansion_card *ec) | 343 | static void __devexit arxescsi_remove(struct expansion_card *ec) |
349 | { | 344 | { |
350 | struct Scsi_Host *host = ecard_get_drvdata(ec); | 345 | struct Scsi_Host *host = ecard_get_drvdata(ec); |
351 | struct arxescsi_info *info = (struct arxescsi_info *)host->hostdata; | ||
352 | 346 | ||
353 | ecard_set_drvdata(ec, NULL); | 347 | ecard_set_drvdata(ec, NULL); |
354 | fas216_remove(host); | 348 | fas216_remove(host); |
355 | 349 | ||
356 | iounmap(info->base); | ||
357 | |||
358 | fas216_release(host); | 350 | fas216_release(host); |
359 | scsi_host_put(host); | 351 | scsi_host_put(host); |
360 | ecard_release_resources(ec); | 352 | ecard_release_resources(ec); |
diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c index 82add77ad131..68a64123af8f 100644 --- a/drivers/scsi/arm/cumana_2.c +++ b/drivers/scsi/arm/cumana_2.c | |||
@@ -401,7 +401,6 @@ cumanascsi2_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
401 | { | 401 | { |
402 | struct Scsi_Host *host; | 402 | struct Scsi_Host *host; |
403 | struct cumanascsi2_info *info; | 403 | struct cumanascsi2_info *info; |
404 | unsigned long resbase, reslen; | ||
405 | void __iomem *base; | 404 | void __iomem *base; |
406 | int ret; | 405 | int ret; |
407 | 406 | ||
@@ -409,9 +408,7 @@ cumanascsi2_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
409 | if (ret) | 408 | if (ret) |
410 | goto out; | 409 | goto out; |
411 | 410 | ||
412 | resbase = ecard_resource_start(ec, ECARD_RES_MEMC); | 411 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
413 | reslen = ecard_resource_len(ec, ECARD_RES_MEMC); | ||
414 | base = ioremap(resbase, reslen); | ||
415 | if (!base) { | 412 | if (!base) { |
416 | ret = -ENOMEM; | 413 | ret = -ENOMEM; |
417 | goto out_region; | 414 | goto out_region; |
@@ -421,7 +418,7 @@ cumanascsi2_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
421 | sizeof(struct cumanascsi2_info)); | 418 | sizeof(struct cumanascsi2_info)); |
422 | if (!host) { | 419 | if (!host) { |
423 | ret = -ENOMEM; | 420 | ret = -ENOMEM; |
424 | goto out_unmap; | 421 | goto out_region; |
425 | } | 422 | } |
426 | 423 | ||
427 | ecard_set_drvdata(ec, host); | 424 | ecard_set_drvdata(ec, host); |
@@ -450,8 +447,8 @@ cumanascsi2_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
450 | 447 | ||
451 | ec->irqaddr = info->base + CUMANASCSI2_STATUS; | 448 | ec->irqaddr = info->base + CUMANASCSI2_STATUS; |
452 | ec->irqmask = STATUS_INT; | 449 | ec->irqmask = STATUS_INT; |
453 | ec->irq_data = info; | 450 | |
454 | ec->ops = &cumanascsi_2_ops; | 451 | ecard_setirq(ec, &cumanascsi_2_ops, info); |
455 | 452 | ||
456 | ret = fas216_init(host); | 453 | ret = fas216_init(host); |
457 | if (ret) | 454 | if (ret) |
@@ -490,9 +487,6 @@ cumanascsi2_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
490 | out_free: | 487 | out_free: |
491 | scsi_host_put(host); | 488 | scsi_host_put(host); |
492 | 489 | ||
493 | out_unmap: | ||
494 | iounmap(base); | ||
495 | |||
496 | out_region: | 490 | out_region: |
497 | ecard_release_resources(ec); | 491 | ecard_release_resources(ec); |
498 | 492 | ||
@@ -512,8 +506,6 @@ static void __devexit cumanascsi2_remove(struct expansion_card *ec) | |||
512 | free_dma(info->info.scsi.dma); | 506 | free_dma(info->info.scsi.dma); |
513 | free_irq(ec->irq, info); | 507 | free_irq(ec->irq, info); |
514 | 508 | ||
515 | iounmap(info->base); | ||
516 | |||
517 | fas216_release(host); | 509 | fas216_release(host); |
518 | scsi_host_put(host); | 510 | scsi_host_put(host); |
519 | ecard_release_resources(ec); | 511 | ecard_release_resources(ec); |
diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c index ed06a8c19ad6..bb2477b3fb0b 100644 --- a/drivers/scsi/arm/eesox.c +++ b/drivers/scsi/arm/eesox.c | |||
@@ -519,7 +519,6 @@ eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
519 | { | 519 | { |
520 | struct Scsi_Host *host; | 520 | struct Scsi_Host *host; |
521 | struct eesoxscsi_info *info; | 521 | struct eesoxscsi_info *info; |
522 | unsigned long resbase, reslen; | ||
523 | void __iomem *base; | 522 | void __iomem *base; |
524 | int ret; | 523 | int ret; |
525 | 524 | ||
@@ -527,9 +526,7 @@ eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
527 | if (ret) | 526 | if (ret) |
528 | goto out; | 527 | goto out; |
529 | 528 | ||
530 | resbase = ecard_resource_start(ec, ECARD_RES_IOCFAST); | 529 | base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
531 | reslen = ecard_resource_len(ec, ECARD_RES_IOCFAST); | ||
532 | base = ioremap(resbase, reslen); | ||
533 | if (!base) { | 530 | if (!base) { |
534 | ret = -ENOMEM; | 531 | ret = -ENOMEM; |
535 | goto out_region; | 532 | goto out_region; |
@@ -539,7 +536,7 @@ eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
539 | sizeof(struct eesoxscsi_info)); | 536 | sizeof(struct eesoxscsi_info)); |
540 | if (!host) { | 537 | if (!host) { |
541 | ret = -ENOMEM; | 538 | ret = -ENOMEM; |
542 | goto out_unmap; | 539 | goto out_region; |
543 | } | 540 | } |
544 | 541 | ||
545 | ecard_set_drvdata(ec, host); | 542 | ecard_set_drvdata(ec, host); |
@@ -569,8 +566,8 @@ eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
569 | 566 | ||
570 | ec->irqaddr = base + EESOX_DMASTAT; | 567 | ec->irqaddr = base + EESOX_DMASTAT; |
571 | ec->irqmask = EESOX_STAT_INTR; | 568 | ec->irqmask = EESOX_STAT_INTR; |
572 | ec->irq_data = info; | 569 | |
573 | ec->ops = &eesoxscsi_ops; | 570 | ecard_setirq(ec, &eesoxscsi_ops, info); |
574 | 571 | ||
575 | device_create_file(&ec->dev, &dev_attr_bus_term); | 572 | device_create_file(&ec->dev, &dev_attr_bus_term); |
576 | 573 | ||
@@ -612,9 +609,6 @@ eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
612 | device_remove_file(&ec->dev, &dev_attr_bus_term); | 609 | device_remove_file(&ec->dev, &dev_attr_bus_term); |
613 | scsi_host_put(host); | 610 | scsi_host_put(host); |
614 | 611 | ||
615 | out_unmap: | ||
616 | iounmap(base); | ||
617 | |||
618 | out_region: | 612 | out_region: |
619 | ecard_release_resources(ec); | 613 | ecard_release_resources(ec); |
620 | 614 | ||
@@ -636,8 +630,6 @@ static void __devexit eesoxscsi_remove(struct expansion_card *ec) | |||
636 | 630 | ||
637 | device_remove_file(&ec->dev, &dev_attr_bus_term); | 631 | device_remove_file(&ec->dev, &dev_attr_bus_term); |
638 | 632 | ||
639 | iounmap(info->base); | ||
640 | |||
641 | fas216_release(host); | 633 | fas216_release(host); |
642 | scsi_host_put(host); | 634 | scsi_host_put(host); |
643 | ecard_release_resources(ec); | 635 | ecard_release_resources(ec); |
diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c index 159047a34997..d9a546d1917c 100644 --- a/drivers/scsi/arm/powertec.c +++ b/drivers/scsi/arm/powertec.c | |||
@@ -313,7 +313,6 @@ powertecscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
313 | { | 313 | { |
314 | struct Scsi_Host *host; | 314 | struct Scsi_Host *host; |
315 | struct powertec_info *info; | 315 | struct powertec_info *info; |
316 | unsigned long resbase, reslen; | ||
317 | void __iomem *base; | 316 | void __iomem *base; |
318 | int ret; | 317 | int ret; |
319 | 318 | ||
@@ -321,9 +320,7 @@ powertecscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
321 | if (ret) | 320 | if (ret) |
322 | goto out; | 321 | goto out; |
323 | 322 | ||
324 | resbase = ecard_resource_start(ec, ECARD_RES_IOCFAST); | 323 | base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
325 | reslen = ecard_resource_len(ec, ECARD_RES_IOCFAST); | ||
326 | base = ioremap(resbase, reslen); | ||
327 | if (!base) { | 324 | if (!base) { |
328 | ret = -ENOMEM; | 325 | ret = -ENOMEM; |
329 | goto out_region; | 326 | goto out_region; |
@@ -333,7 +330,7 @@ powertecscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
333 | sizeof (struct powertec_info)); | 330 | sizeof (struct powertec_info)); |
334 | if (!host) { | 331 | if (!host) { |
335 | ret = -ENOMEM; | 332 | ret = -ENOMEM; |
336 | goto out_unmap; | 333 | goto out_region; |
337 | } | 334 | } |
338 | 335 | ||
339 | ecard_set_drvdata(ec, host); | 336 | ecard_set_drvdata(ec, host); |
@@ -361,8 +358,8 @@ powertecscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
361 | 358 | ||
362 | ec->irqaddr = base + POWERTEC_INTR_STATUS; | 359 | ec->irqaddr = base + POWERTEC_INTR_STATUS; |
363 | ec->irqmask = POWERTEC_INTR_BIT; | 360 | ec->irqmask = POWERTEC_INTR_BIT; |
364 | ec->irq_data = info; | 361 | |
365 | ec->ops = &powertecscsi_ops; | 362 | ecard_setirq(ec, &powertecscsi_ops, info); |
366 | 363 | ||
367 | device_create_file(&ec->dev, &dev_attr_bus_term); | 364 | device_create_file(&ec->dev, &dev_attr_bus_term); |
368 | 365 | ||
@@ -404,9 +401,6 @@ powertecscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
404 | device_remove_file(&ec->dev, &dev_attr_bus_term); | 401 | device_remove_file(&ec->dev, &dev_attr_bus_term); |
405 | scsi_host_put(host); | 402 | scsi_host_put(host); |
406 | 403 | ||
407 | out_unmap: | ||
408 | iounmap(base); | ||
409 | |||
410 | out_region: | 404 | out_region: |
411 | ecard_release_resources(ec); | 405 | ecard_release_resources(ec); |
412 | 406 | ||
@@ -428,8 +422,6 @@ static void __devexit powertecscsi_remove(struct expansion_card *ec) | |||
428 | free_dma(info->info.scsi.dma); | 422 | free_dma(info->info.scsi.dma); |
429 | free_irq(ec->irq, info); | 423 | free_irq(ec->irq, info); |
430 | 424 | ||
431 | iounmap(info->base); | ||
432 | |||
433 | fas216_release(host); | 425 | fas216_release(host); |
434 | scsi_host_put(host); | 426 | scsi_host_put(host); |
435 | ecard_release_resources(ec); | 427 | ecard_release_resources(ec); |
diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c index a15752b37990..eef82758d047 100644 --- a/drivers/scsi/sgiwd93.c +++ b/drivers/scsi/sgiwd93.c | |||
@@ -6,87 +6,49 @@ | |||
6 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | 6 | * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) |
7 | * Copyright (C) 1999 Andrew R. Baker (andrewb@uab.edu) | 7 | * Copyright (C) 1999 Andrew R. Baker (andrewb@uab.edu) |
8 | * Copyright (C) 2001 Florian Lohoff (flo@rfc822.org) | 8 | * Copyright (C) 2001 Florian Lohoff (flo@rfc822.org) |
9 | * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org) | 9 | * Copyright (C) 2003, 07 Ralf Baechle (ralf@linux-mips.org) |
10 | * | 10 | * |
11 | * (In all truth, Jed Schimmel wrote all this code.) | 11 | * (In all truth, Jed Schimmel wrote all this code.) |
12 | */ | 12 | */ |
13 | #include <linux/init.h> | 13 | |
14 | #include <linux/interrupt.h> | 14 | #undef DEBUG |
15 | #include <linux/types.h> | 15 | |
16 | #include <linux/mm.h> | ||
17 | #include <linux/blkdev.h> | ||
18 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
19 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
18 | #include <linux/gfp.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/types.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/platform_device.h> | ||
20 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
21 | 26 | ||
22 | #include <asm/page.h> | ||
23 | #include <asm/pgtable.h> | ||
24 | #include <asm/sgialib.h> | ||
25 | #include <asm/sgi/sgi.h> | ||
26 | #include <asm/sgi/mc.h> | ||
27 | #include <asm/sgi/hpc3.h> | 27 | #include <asm/sgi/hpc3.h> |
28 | #include <asm/sgi/ip22.h> | 28 | #include <asm/sgi/ip22.h> |
29 | #include <asm/irq.h> | 29 | #include <asm/sgi/wd.h> |
30 | #include <asm/io.h> | ||
31 | 30 | ||
32 | #include "scsi.h" | 31 | #include "scsi.h" |
33 | #include <scsi/scsi_host.h> | ||
34 | #include "wd33c93.h" | 32 | #include "wd33c93.h" |
35 | 33 | ||
36 | #include <linux/stat.h> | ||
37 | |||
38 | #if 0 | ||
39 | #define DPRINTK(args...) printk(args) | ||
40 | #else | ||
41 | #define DPRINTK(args...) | ||
42 | #endif | ||
43 | |||
44 | #define HDATA(ptr) ((struct ip22_hostdata *)((ptr)->hostdata)) | ||
45 | |||
46 | struct ip22_hostdata { | 34 | struct ip22_hostdata { |
47 | struct WD33C93_hostdata wh; | 35 | struct WD33C93_hostdata wh; |
48 | struct hpc_data { | 36 | struct hpc_data { |
49 | dma_addr_t dma; | 37 | dma_addr_t dma; |
50 | void * cpu; | 38 | void *cpu; |
51 | } hd; | 39 | } hd; |
52 | }; | 40 | }; |
53 | 41 | ||
42 | #define host_to_hostdata(host) ((struct ip22_hostdata *)((host)->hostdata)) | ||
43 | |||
54 | struct hpc_chunk { | 44 | struct hpc_chunk { |
55 | struct hpc_dma_desc desc; | 45 | struct hpc_dma_desc desc; |
56 | u32 _padding; /* align to quadword boundary */ | 46 | u32 _padding; /* align to quadword boundary */ |
57 | }; | 47 | }; |
58 | 48 | ||
59 | struct Scsi_Host *sgiwd93_host; | ||
60 | struct Scsi_Host *sgiwd93_host1; | ||
61 | |||
62 | /* Wuff wuff, wuff, wd33c93.c, wuff wuff, object oriented, bow wow. */ | ||
63 | static inline void write_wd33c93_count(const wd33c93_regs regs, | ||
64 | unsigned long value) | ||
65 | { | ||
66 | *regs.SASR = WD_TRANSFER_COUNT_MSB; | ||
67 | mb(); | ||
68 | *regs.SCMD = ((value >> 16) & 0xff); | ||
69 | *regs.SCMD = ((value >> 8) & 0xff); | ||
70 | *regs.SCMD = ((value >> 0) & 0xff); | ||
71 | mb(); | ||
72 | } | ||
73 | |||
74 | static inline unsigned long read_wd33c93_count(const wd33c93_regs regs) | ||
75 | { | ||
76 | unsigned long value; | ||
77 | |||
78 | *regs.SASR = WD_TRANSFER_COUNT_MSB; | ||
79 | mb(); | ||
80 | value = ((*regs.SCMD & 0xff) << 16); | ||
81 | value |= ((*regs.SCMD & 0xff) << 8); | ||
82 | value |= ((*regs.SCMD & 0xff) << 0); | ||
83 | mb(); | ||
84 | return value; | ||
85 | } | ||
86 | |||
87 | static irqreturn_t sgiwd93_intr(int irq, void *dev_id) | 49 | static irqreturn_t sgiwd93_intr(int irq, void *dev_id) |
88 | { | 50 | { |
89 | struct Scsi_Host * host = (struct Scsi_Host *) dev_id; | 51 | struct Scsi_Host * host = dev_id; |
90 | unsigned long flags; | 52 | unsigned long flags; |
91 | 53 | ||
92 | spin_lock_irqsave(host->host_lock, flags); | 54 | spin_lock_irqsave(host->host_lock, flags); |
@@ -131,12 +93,12 @@ void fill_hpc_entries(struct hpc_chunk *hcp, struct scsi_cmnd *cmd, int datainp) | |||
131 | 93 | ||
132 | static int dma_setup(struct scsi_cmnd *cmd, int datainp) | 94 | static int dma_setup(struct scsi_cmnd *cmd, int datainp) |
133 | { | 95 | { |
134 | struct ip22_hostdata *hdata = HDATA(cmd->device->host); | 96 | struct ip22_hostdata *hdata = host_to_hostdata(cmd->device->host); |
135 | struct hpc3_scsiregs *hregs = | 97 | struct hpc3_scsiregs *hregs = |
136 | (struct hpc3_scsiregs *) cmd->device->host->base; | 98 | (struct hpc3_scsiregs *) cmd->device->host->base; |
137 | struct hpc_chunk *hcp = (struct hpc_chunk *) hdata->hd.cpu; | 99 | struct hpc_chunk *hcp = (struct hpc_chunk *) hdata->hd.cpu; |
138 | 100 | ||
139 | DPRINTK("dma_setup: datainp<%d> hcp<%p> ", datainp, hcp); | 101 | pr_debug("dma_setup: datainp<%d> hcp<%p> ", datainp, hcp); |
140 | 102 | ||
141 | hdata->wh.dma_dir = datainp; | 103 | hdata->wh.dma_dir = datainp; |
142 | 104 | ||
@@ -151,7 +113,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int datainp) | |||
151 | 113 | ||
152 | fill_hpc_entries(hcp, cmd, datainp); | 114 | fill_hpc_entries(hcp, cmd, datainp); |
153 | 115 | ||
154 | DPRINTK(" HPCGO\n"); | 116 | pr_debug(" HPCGO\n"); |
155 | 117 | ||
156 | /* Start up the HPC. */ | 118 | /* Start up the HPC. */ |
157 | hregs->ndptr = hdata->hd.dma; | 119 | hregs->ndptr = hdata->hd.dma; |
@@ -166,7 +128,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int datainp) | |||
166 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | 128 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, |
167 | int status) | 129 | int status) |
168 | { | 130 | { |
169 | struct ip22_hostdata *hdata = HDATA(instance); | 131 | struct ip22_hostdata *hdata = host_to_hostdata(instance); |
170 | struct hpc3_scsiregs *hregs; | 132 | struct hpc3_scsiregs *hregs; |
171 | 133 | ||
172 | if (!SCpnt) | 134 | if (!SCpnt) |
@@ -174,7 +136,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | |||
174 | 136 | ||
175 | hregs = (struct hpc3_scsiregs *) SCpnt->device->host->base; | 137 | hregs = (struct hpc3_scsiregs *) SCpnt->device->host->base; |
176 | 138 | ||
177 | DPRINTK("dma_stop: status<%d> ", status); | 139 | pr_debug("dma_stop: status<%d> ", status); |
178 | 140 | ||
179 | /* First stop the HPC and flush it's FIFO. */ | 141 | /* First stop the HPC and flush it's FIFO. */ |
180 | if (hdata->wh.dma_dir) { | 142 | if (hdata->wh.dma_dir) { |
@@ -186,7 +148,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | |||
186 | dma_unmap_single(NULL, SCpnt->SCp.dma_handle, SCpnt->SCp.this_residual, | 148 | dma_unmap_single(NULL, SCpnt->SCp.dma_handle, SCpnt->SCp.this_residual, |
187 | SCpnt->sc_data_direction); | 149 | SCpnt->sc_data_direction); |
188 | 150 | ||
189 | DPRINTK("\n"); | 151 | pr_debug("\n"); |
190 | } | 152 | } |
191 | 153 | ||
192 | void sgiwd93_reset(unsigned long base) | 154 | void sgiwd93_reset(unsigned long base) |
@@ -216,29 +178,71 @@ static inline void init_hpc_chain(struct hpc_data *hd) | |||
216 | hcp->desc.pnext = hd->dma; | 178 | hcp->desc.pnext = hd->dma; |
217 | } | 179 | } |
218 | 180 | ||
219 | static struct Scsi_Host * __init sgiwd93_setup_scsi( | 181 | static int sgiwd93_bus_reset(struct scsi_cmnd *cmd) |
220 | struct scsi_host_template *SGIblows, int unit, int irq, | 182 | { |
221 | struct hpc3_scsiregs *hregs, unsigned char *wdregs) | 183 | /* FIXME perform bus-specific reset */ |
184 | |||
185 | /* FIXME 2: kill this function, and let midlayer fallback | ||
186 | to the same result, calling wd33c93_host_reset() */ | ||
187 | |||
188 | spin_lock_irq(cmd->device->host->host_lock); | ||
189 | wd33c93_host_reset(cmd); | ||
190 | spin_unlock_irq(cmd->device->host->host_lock); | ||
191 | |||
192 | return SUCCESS; | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * Kludge alert - the SCSI code calls the abort and reset method with int | ||
197 | * arguments not with pointers. So this is going to blow up beautyfully | ||
198 | * on 64-bit systems with memory outside the compat address spaces. | ||
199 | */ | ||
200 | static struct scsi_host_template sgiwd93_template = { | ||
201 | .module = THIS_MODULE, | ||
202 | .proc_name = "SGIWD93", | ||
203 | .name = "SGI WD93", | ||
204 | .queuecommand = wd33c93_queuecommand, | ||
205 | .eh_abort_handler = wd33c93_abort, | ||
206 | .eh_bus_reset_handler = sgiwd93_bus_reset, | ||
207 | .eh_host_reset_handler = wd33c93_host_reset, | ||
208 | .can_queue = 16, | ||
209 | .this_id = 7, | ||
210 | .sg_tablesize = SG_ALL, | ||
211 | .cmd_per_lun = 8, | ||
212 | .use_clustering = DISABLE_CLUSTERING, | ||
213 | }; | ||
214 | |||
215 | static int __init sgiwd93_probe(struct platform_device *pdev) | ||
222 | { | 216 | { |
217 | struct sgiwd93_platform_data *pd = pdev->dev.platform_data; | ||
218 | unsigned char *wdregs = pd->wdregs; | ||
219 | struct hpc3_scsiregs *hregs = pd->hregs; | ||
223 | struct ip22_hostdata *hdata; | 220 | struct ip22_hostdata *hdata; |
224 | struct Scsi_Host *host; | 221 | struct Scsi_Host *host; |
225 | wd33c93_regs regs; | 222 | wd33c93_regs regs; |
226 | 223 | unsigned int unit = pd->unit; | |
227 | host = scsi_register(SGIblows, sizeof(struct ip22_hostdata)); | 224 | unsigned int irq = pd->irq; |
228 | if (!host) | 225 | int err; |
229 | return NULL; | 226 | |
227 | host = scsi_host_alloc(&sgiwd93_template, sizeof(struct ip22_hostdata)); | ||
228 | if (!host) { | ||
229 | err = -ENOMEM; | ||
230 | goto out; | ||
231 | } | ||
230 | 232 | ||
231 | host->base = (unsigned long) hregs; | 233 | host->base = (unsigned long) hregs; |
232 | host->irq = irq; | 234 | host->irq = irq; |
233 | 235 | ||
234 | hdata = HDATA(host); | 236 | hdata = host_to_hostdata(host); |
235 | hdata->hd.cpu = dma_alloc_coherent(NULL, PAGE_SIZE, &hdata->hd.dma, | 237 | hdata->hd.cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, |
236 | GFP_KERNEL); | 238 | &hdata->hd.dma, GFP_KERNEL); |
237 | if (!hdata->hd.cpu) { | 239 | if (!hdata->hd.cpu) { |
238 | printk(KERN_WARNING "sgiwd93: Could not allocate memory for " | 240 | printk(KERN_WARNING "sgiwd93: Could not allocate memory for " |
239 | "host %d buffer.\n", unit); | 241 | "host %d buffer.\n", unit); |
240 | goto out_unregister; | 242 | err = -ENOMEM; |
243 | goto out_put; | ||
241 | } | 244 | } |
245 | |||
242 | init_hpc_chain(&hdata->hd); | 246 | init_hpc_chain(&hdata->hd); |
243 | 247 | ||
244 | regs.SASR = wdregs + 3; | 248 | regs.SASR = wdregs + 3; |
@@ -249,95 +253,67 @@ static struct Scsi_Host * __init sgiwd93_setup_scsi( | |||
249 | if (hdata->wh.no_sync == 0xff) | 253 | if (hdata->wh.no_sync == 0xff) |
250 | hdata->wh.no_sync = 0; | 254 | hdata->wh.no_sync = 0; |
251 | 255 | ||
252 | if (request_irq(irq, sgiwd93_intr, 0, "SGI WD93", (void *) host)) { | 256 | err = request_irq(irq, sgiwd93_intr, 0, "SGI WD93", host); |
257 | if (err) { | ||
253 | printk(KERN_WARNING "sgiwd93: Could not register irq %d " | 258 | printk(KERN_WARNING "sgiwd93: Could not register irq %d " |
254 | "for host %d.\n", irq, unit); | 259 | "for host %d.\n", irq, unit); |
255 | goto out_free; | 260 | goto out_free; |
256 | } | 261 | } |
257 | return host; | ||
258 | 262 | ||
259 | out_free: | 263 | platform_set_drvdata(pdev, host); |
260 | dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); | ||
261 | wd33c93_release(); | ||
262 | 264 | ||
263 | out_unregister: | 265 | err = scsi_add_host(host, NULL); |
264 | scsi_unregister(host); | 266 | if (err) |
267 | goto out_irq; | ||
265 | 268 | ||
266 | return NULL; | 269 | scsi_scan_host(host); |
267 | } | ||
268 | |||
269 | static int __init sgiwd93_detect(struct scsi_host_template *SGIblows) | ||
270 | { | ||
271 | int found = 0; | ||
272 | |||
273 | SGIblows->proc_name = "SGIWD93"; | ||
274 | sgiwd93_host = sgiwd93_setup_scsi(SGIblows, 0, SGI_WD93_0_IRQ, | ||
275 | &hpc3c0->scsi_chan0, | ||
276 | (unsigned char *)hpc3c0->scsi0_ext); | ||
277 | if (sgiwd93_host) | ||
278 | found++; | ||
279 | |||
280 | /* Set up second controller on the Indigo2 */ | ||
281 | if (ip22_is_fullhouse()) { | ||
282 | sgiwd93_host1 = sgiwd93_setup_scsi(SGIblows, 1, SGI_WD93_1_IRQ, | ||
283 | &hpc3c0->scsi_chan1, | ||
284 | (unsigned char *)hpc3c0->scsi1_ext); | ||
285 | if (sgiwd93_host1) | ||
286 | found++; | ||
287 | } | ||
288 | |||
289 | return found; | ||
290 | } | ||
291 | 270 | ||
292 | static int sgiwd93_release(struct Scsi_Host *instance) | 271 | return 0; |
293 | { | ||
294 | struct ip22_hostdata *hdata = HDATA(instance); | ||
295 | int irq = 0; | ||
296 | |||
297 | if (sgiwd93_host && sgiwd93_host == instance) | ||
298 | irq = SGI_WD93_0_IRQ; | ||
299 | else if (sgiwd93_host1 && sgiwd93_host1 == instance) | ||
300 | irq = SGI_WD93_1_IRQ; | ||
301 | 272 | ||
302 | free_irq(irq, sgiwd93_intr); | 273 | out_irq: |
274 | free_irq(irq, host); | ||
275 | out_free: | ||
303 | dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); | 276 | dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); |
304 | wd33c93_release(); | 277 | out_put: |
278 | scsi_host_put(host); | ||
279 | out: | ||
305 | 280 | ||
306 | return 1; | 281 | return err; |
307 | } | 282 | } |
308 | 283 | ||
309 | static int sgiwd93_bus_reset(struct scsi_cmnd *cmd) | 284 | static void __exit sgiwd93_remove(struct platform_device *pdev) |
310 | { | 285 | { |
311 | /* FIXME perform bus-specific reset */ | 286 | struct Scsi_Host *host = platform_get_drvdata(pdev); |
287 | struct ip22_hostdata *hdata = (struct ip22_hostdata *) host->hostdata; | ||
288 | struct sgiwd93_platform_data *pd = pdev->dev.platform_data; | ||
289 | |||
290 | scsi_remove_host(host); | ||
291 | free_irq(pd->irq, host); | ||
292 | dma_free_coherent(&pdev->dev, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); | ||
293 | scsi_host_put(host); | ||
294 | } | ||
312 | 295 | ||
313 | /* FIXME 2: kill this function, and let midlayer fallback | 296 | static struct platform_driver sgiwd93_driver = { |
314 | to the same result, calling wd33c93_host_reset() */ | 297 | .probe = sgiwd93_probe, |
298 | .remove = __devexit_p(sgiwd93_remove), | ||
299 | .driver = { | ||
300 | .name = "sgiwd93" | ||
301 | } | ||
302 | }; | ||
315 | 303 | ||
316 | spin_lock_irq(cmd->device->host->host_lock); | 304 | static int __init sgiwd93_module_init(void) |
317 | wd33c93_host_reset(cmd); | 305 | { |
318 | spin_unlock_irq(cmd->device->host->host_lock); | 306 | return platform_driver_register(&sgiwd93_driver); |
307 | } | ||
319 | 308 | ||
320 | return SUCCESS; | 309 | static void __exit sgiwd93_module_exit(void) |
310 | { | ||
311 | return platform_driver_unregister(&sgiwd93_driver); | ||
321 | } | 312 | } |
322 | 313 | ||
323 | /* | 314 | module_init(sgiwd93_module_init); |
324 | * Kludge alert - the SCSI code calls the abort and reset method with int | 315 | module_exit(sgiwd93_module_exit); |
325 | * arguments not with pointers. So this is going to blow up beautyfully | 316 | |
326 | * on 64-bit systems with memory outside the compat address spaces. | 317 | MODULE_DESCRIPTION("SGI WD33C93 driver"); |
327 | */ | 318 | MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>"); |
328 | static struct scsi_host_template driver_template = { | 319 | MODULE_LICENSE("GPL"); |
329 | .proc_name = "SGIWD93", | ||
330 | .name = "SGI WD93", | ||
331 | .detect = sgiwd93_detect, | ||
332 | .release = sgiwd93_release, | ||
333 | .queuecommand = wd33c93_queuecommand, | ||
334 | .eh_abort_handler = wd33c93_abort, | ||
335 | .eh_bus_reset_handler = sgiwd93_bus_reset, | ||
336 | .eh_host_reset_handler = wd33c93_host_reset, | ||
337 | .can_queue = 16, | ||
338 | .this_id = 7, | ||
339 | .sg_tablesize = SG_ALL, | ||
340 | .cmd_per_lun = 8, | ||
341 | .use_clustering = DISABLE_CLUSTERING, | ||
342 | }; | ||
343 | #include "scsi_module.c" | ||
diff --git a/drivers/serial/8250_acorn.c b/drivers/serial/8250_acorn.c index 562ba745a044..b0ce8c56f1a4 100644 --- a/drivers/serial/8250_acorn.c +++ b/drivers/serial/8250_acorn.c | |||
@@ -54,7 +54,7 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
54 | info->num_ports = type->num_ports; | 54 | info->num_ports = type->num_ports; |
55 | 55 | ||
56 | bus_addr = ecard_resource_start(ec, type->type); | 56 | bus_addr = ecard_resource_start(ec, type->type); |
57 | info->vaddr = ioremap(bus_addr, ecard_resource_len(ec, type->type)); | 57 | info->vaddr = ecardm_iomap(ec, type->type, 0, 0); |
58 | if (!info->vaddr) { | 58 | if (!info->vaddr) { |
59 | kfree(info); | 59 | kfree(info); |
60 | return -ENOMEM; | 60 | return -ENOMEM; |
@@ -91,7 +91,6 @@ static void __devexit serial_card_remove(struct expansion_card *ec) | |||
91 | if (info->ports[i] > 0) | 91 | if (info->ports[i] > 0) |
92 | serial8250_unregister_port(info->ports[i]); | 92 | serial8250_unregister_port(info->ports[i]); |
93 | 93 | ||
94 | iounmap(info->vaddr); | ||
95 | kfree(info); | 94 | kfree(info); |
96 | } | 95 | } |
97 | 96 | ||
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index e8efe938c4e7..315ea9916456 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -5,6 +5,7 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | menu "Serial drivers" | 7 | menu "Serial drivers" |
8 | depends on HAS_IOMEM | ||
8 | 9 | ||
9 | # | 10 | # |
10 | # The new 8250/16550 serial drivers | 11 | # The new 8250/16550 serial drivers |
@@ -358,6 +359,23 @@ config SERIAL_ATMEL_TTYAT | |||
358 | 359 | ||
359 | Say Y if you have an external 8250/16C550 UART. If unsure, say N. | 360 | Say Y if you have an external 8250/16C550 UART. If unsure, say N. |
360 | 361 | ||
362 | config SERIAL_KS8695 | ||
363 | bool "Micrel KS8695 (Centaur) serial port support" | ||
364 | depends on ARCH_KS8695 | ||
365 | select SERIAL_CORE | ||
366 | help | ||
367 | This selects the Micrel Centaur KS8695 UART. Say Y here. | ||
368 | |||
369 | config SERIAL_KS8695_CONSOLE | ||
370 | bool "Support for console on KS8695 (Centaur) serial port" | ||
371 | depends on SERIAL_KS8695=y | ||
372 | select SERIAL_CORE_CONSOLE | ||
373 | help | ||
374 | Say Y here if you wish to use a KS8695 (Centaur) UART as the | ||
375 | system console (the system console is the device which | ||
376 | receives all kernel messages and warnings and which allows | ||
377 | logins in single user mode). | ||
378 | |||
361 | config SERIAL_CLPS711X | 379 | config SERIAL_CLPS711X |
362 | tristate "CLPS711X serial port support" | 380 | tristate "CLPS711X serial port support" |
363 | depends on ARM && ARCH_CLPS711X | 381 | depends on ARM && ARCH_CLPS711X |
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 4959bcb8d1ef..08ad0d978183 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile | |||
@@ -61,3 +61,4 @@ obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o | |||
61 | obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o | 61 | obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o |
62 | obj-$(CONFIG_SERIAL_NETX) += netx-serial.o | 62 | obj-$(CONFIG_SERIAL_NETX) += netx-serial.o |
63 | obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o | 63 | obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o |
64 | obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h index 69715e556506..a8f894c78194 100644 --- a/drivers/serial/cpm_uart/cpm_uart.h +++ b/drivers/serial/cpm_uart/cpm_uart.h | |||
@@ -88,7 +88,7 @@ extern struct uart_cpm_port cpm_uart_ports[UART_NR]; | |||
88 | 88 | ||
89 | /* these are located in their respective files */ | 89 | /* these are located in their respective files */ |
90 | void cpm_line_cr_cmd(int line, int cmd); | 90 | void cpm_line_cr_cmd(int line, int cmd); |
91 | int __init cpm_uart_init_portdesc(void); | 91 | int cpm_uart_init_portdesc(void); |
92 | int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con); | 92 | int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con); |
93 | void cpm_uart_freebuf(struct uart_cpm_port *pinfo); | 93 | void cpm_uart_freebuf(struct uart_cpm_port *pinfo); |
94 | 94 | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index f23972bc00c0..b63ff8dd7304 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c | |||
@@ -482,7 +482,8 @@ static void cpm_uart_shutdown(struct uart_port *port) | |||
482 | } | 482 | } |
483 | 483 | ||
484 | static void cpm_uart_set_termios(struct uart_port *port, | 484 | static void cpm_uart_set_termios(struct uart_port *port, |
485 | struct termios *termios, struct termios *old) | 485 | struct ktermios *termios, |
486 | struct ktermios *old) | ||
486 | { | 487 | { |
487 | int baud; | 488 | int baud; |
488 | unsigned long flags; | 489 | unsigned long flags; |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c index 925fb607d8c4..8c6324ed0202 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c | |||
@@ -125,7 +125,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
125 | { | 125 | { |
126 | int dpmemsz, memsz; | 126 | int dpmemsz, memsz; |
127 | u8 *dp_mem; | 127 | u8 *dp_mem; |
128 | uint dp_offset; | 128 | unsigned long dp_offset; |
129 | u8 *mem_addr; | 129 | u8 *mem_addr; |
130 | dma_addr_t dma_addr = 0; | 130 | dma_addr_t dma_addr = 0; |
131 | 131 | ||
@@ -133,7 +133,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
133 | 133 | ||
134 | dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos); | 134 | dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos); |
135 | dp_offset = cpm_dpalloc(dpmemsz, 8); | 135 | dp_offset = cpm_dpalloc(dpmemsz, 8); |
136 | if (IS_DPERR(dp_offset)) { | 136 | if (IS_ERR_VALUE(dp_offset)) { |
137 | printk(KERN_ERR | 137 | printk(KERN_ERR |
138 | "cpm_uart_cpm1.c: could not allocate buffer descriptors\n"); | 138 | "cpm_uart_cpm1.c: could not allocate buffer descriptors\n"); |
139 | return -ENOMEM; | 139 | return -ENOMEM; |
@@ -185,7 +185,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | /* Setup any dynamic params in the uart desc */ | 187 | /* Setup any dynamic params in the uart desc */ |
188 | int __init cpm_uart_init_portdesc(void) | 188 | int cpm_uart_init_portdesc(void) |
189 | { | 189 | { |
190 | pr_debug("CPM uart[-]:init portdesc\n"); | 190 | pr_debug("CPM uart[-]:init portdesc\n"); |
191 | 191 | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index fa455996ad8f..7b61d805ebe9 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c | |||
@@ -222,7 +222,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
222 | { | 222 | { |
223 | int dpmemsz, memsz; | 223 | int dpmemsz, memsz; |
224 | u8 *dp_mem; | 224 | u8 *dp_mem; |
225 | uint dp_offset; | 225 | unsigned long dp_offset; |
226 | u8 *mem_addr; | 226 | u8 *mem_addr; |
227 | dma_addr_t dma_addr = 0; | 227 | dma_addr_t dma_addr = 0; |
228 | 228 | ||
@@ -230,7 +230,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
230 | 230 | ||
231 | dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos); | 231 | dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos); |
232 | dp_offset = cpm_dpalloc(dpmemsz, 8); | 232 | dp_offset = cpm_dpalloc(dpmemsz, 8); |
233 | if (IS_DPERR(dp_offset)) { | 233 | if (IS_ERR_VALUE(dp_offset)) { |
234 | printk(KERN_ERR | 234 | printk(KERN_ERR |
235 | "cpm_uart_cpm.c: could not allocate buffer descriptors\n"); | 235 | "cpm_uart_cpm.c: could not allocate buffer descriptors\n"); |
236 | return -ENOMEM; | 236 | return -ENOMEM; |
@@ -282,7 +282,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo) | |||
282 | } | 282 | } |
283 | 283 | ||
284 | /* Setup any dynamic params in the uart desc */ | 284 | /* Setup any dynamic params in the uart desc */ |
285 | int __init cpm_uart_init_portdesc(void) | 285 | int cpm_uart_init_portdesc(void) |
286 | { | 286 | { |
287 | #if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2) | 287 | #if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2) |
288 | u16 *addr; | 288 | u16 *addr; |
diff --git a/drivers/serial/serial_ks8695.c b/drivers/serial/serial_ks8695.c new file mode 100644 index 000000000000..c5346d677315 --- /dev/null +++ b/drivers/serial/serial_ks8695.c | |||
@@ -0,0 +1,657 @@ | |||
1 | /* | ||
2 | * drivers/serial/serial_ks8695.c | ||
3 | * | ||
4 | * Driver for KS8695 serial ports | ||
5 | * | ||
6 | * Based on drivers/serial/serial_amba.c, by Kam Lee. | ||
7 | * | ||
8 | * Copyright 2002-2005 Micrel Inc. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | */ | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/tty.h> | ||
18 | #include <linux/ioport.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/serial.h> | ||
21 | #include <linux/console.h> | ||
22 | #include <linux/sysrq.h> | ||
23 | #include <linux/device.h> | ||
24 | |||
25 | #include <asm/io.h> | ||
26 | #include <asm/irq.h> | ||
27 | #include <asm/mach/irq.h> | ||
28 | |||
29 | #include <asm/arch/regs-uart.h> | ||
30 | #include <asm/arch/regs-irq.h> | ||
31 | |||
32 | #if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | ||
33 | #define SUPPORT_SYSRQ | ||
34 | #endif | ||
35 | |||
36 | #include <linux/serial_core.h> | ||
37 | |||
38 | |||
39 | #define SERIAL_KS8695_MAJOR 204 | ||
40 | #define SERIAL_KS8695_MINOR 16 | ||
41 | #define SERIAL_KS8695_DEVNAME "ttyAM" | ||
42 | |||
43 | #define SERIAL_KS8695_NR 1 | ||
44 | |||
45 | /* | ||
46 | * Access macros for the KS8695 UART | ||
47 | */ | ||
48 | #define UART_GET_CHAR(p) (__raw_readl((p)->membase + KS8695_URRB) & 0xFF) | ||
49 | #define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + KS8695_URTH) | ||
50 | #define UART_GET_FCR(p) __raw_readl((p)->membase + KS8695_URFC) | ||
51 | #define UART_PUT_FCR(p, c) __raw_writel((c), (p)->membase + KS8695_URFC) | ||
52 | #define UART_GET_MSR(p) __raw_readl((p)->membase + KS8695_URMS) | ||
53 | #define UART_GET_LSR(p) __raw_readl((p)->membase + KS8695_URLS) | ||
54 | #define UART_GET_LCR(p) __raw_readl((p)->membase + KS8695_URLC) | ||
55 | #define UART_PUT_LCR(p, c) __raw_writel((c), (p)->membase + KS8695_URLC) | ||
56 | #define UART_GET_MCR(p) __raw_readl((p)->membase + KS8695_URMC) | ||
57 | #define UART_PUT_MCR(p, c) __raw_writel((c), (p)->membase + KS8695_URMC) | ||
58 | #define UART_GET_BRDR(p) __raw_readl((p)->membase + KS8695_URBD) | ||
59 | #define UART_PUT_BRDR(p, c) __raw_writel((c), (p)->membase + KS8695_URBD) | ||
60 | |||
61 | #define KS8695_CLR_TX_INT() __raw_writel(1 << KS8695_IRQ_UART_TX, KS8695_IRQ_VA + KS8695_INTST) | ||
62 | |||
63 | #define UART_DUMMY_LSR_RX 0x100 | ||
64 | #define UART_PORT_SIZE (KS8695_USR - KS8695_URRB + 4) | ||
65 | |||
66 | #define tx_enabled(port) ((port)->unused[0]) | ||
67 | #define rx_enabled(port) ((port)->unused[1]) | ||
68 | |||
69 | |||
70 | #ifdef SUPPORT_SYSRQ | ||
71 | static struct console ks8695_console; | ||
72 | #endif | ||
73 | |||
74 | static void ks8695uart_stop_tx(struct uart_port *port) | ||
75 | { | ||
76 | if (tx_enabled(port)) { | ||
77 | disable_irq(KS8695_IRQ_UART_TX); | ||
78 | tx_enabled(port) = 0; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static void ks8695uart_start_tx(struct uart_port *port) | ||
83 | { | ||
84 | if (!tx_enabled(port)) { | ||
85 | enable_irq(KS8695_IRQ_UART_TX); | ||
86 | tx_enabled(port) = 1; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | static void ks8695uart_stop_rx(struct uart_port *port) | ||
91 | { | ||
92 | if (rx_enabled(port)) { | ||
93 | disable_irq(KS8695_IRQ_UART_RX); | ||
94 | rx_enabled(port) = 0; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | static void ks8695uart_enable_ms(struct uart_port *port) | ||
99 | { | ||
100 | enable_irq(KS8695_IRQ_UART_MODEM_STATUS); | ||
101 | } | ||
102 | |||
103 | static void ks8695uart_disable_ms(struct uart_port *port) | ||
104 | { | ||
105 | disable_irq(KS8695_IRQ_UART_MODEM_STATUS); | ||
106 | } | ||
107 | |||
108 | static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) | ||
109 | { | ||
110 | struct uart_port *port = dev_id; | ||
111 | struct tty_struct *tty = port->info->tty; | ||
112 | unsigned int status, ch, lsr, flg, max_count = 256; | ||
113 | |||
114 | status = UART_GET_LSR(port); /* clears pending LSR interrupts */ | ||
115 | while ((status & URLS_URDR) && max_count--) { | ||
116 | ch = UART_GET_CHAR(port); | ||
117 | flg = TTY_NORMAL; | ||
118 | |||
119 | port->icount.rx++; | ||
120 | |||
121 | /* | ||
122 | * Note that the error handling code is | ||
123 | * out of the main execution path | ||
124 | */ | ||
125 | lsr = UART_GET_LSR(port) | UART_DUMMY_LSR_RX; | ||
126 | if (unlikely(lsr & (URLS_URBI | URLS_URPE | URLS_URFE | URLS_URROE))) { | ||
127 | if (lsr & URLS_URBI) { | ||
128 | lsr &= ~(URLS_URFE | URLS_URPE); | ||
129 | port->icount.brk++; | ||
130 | if (uart_handle_break(port)) | ||
131 | goto ignore_char; | ||
132 | } | ||
133 | if (lsr & URLS_URPE) | ||
134 | port->icount.parity++; | ||
135 | if (lsr & URLS_URFE) | ||
136 | port->icount.frame++; | ||
137 | if (lsr & URLS_URROE) | ||
138 | port->icount.overrun++; | ||
139 | |||
140 | lsr &= port->read_status_mask; | ||
141 | |||
142 | if (lsr & URLS_URBI) | ||
143 | flg = TTY_BREAK; | ||
144 | else if (lsr & URLS_URPE) | ||
145 | flg = TTY_PARITY; | ||
146 | else if (lsr & URLS_URFE) | ||
147 | flg = TTY_FRAME; | ||
148 | } | ||
149 | |||
150 | if (uart_handle_sysrq_char(port, ch)) | ||
151 | goto ignore_char; | ||
152 | |||
153 | uart_insert_char(port, lsr, URLS_URROE, ch, flg); | ||
154 | |||
155 | ignore_char: | ||
156 | status = UART_GET_LSR(port); | ||
157 | } | ||
158 | tty_flip_buffer_push(tty); | ||
159 | |||
160 | return IRQ_HANDLED; | ||
161 | } | ||
162 | |||
163 | |||
164 | static irqreturn_t ks8695uart_tx_chars(int irq, void *dev_id) | ||
165 | { | ||
166 | struct uart_port *port = dev_id; | ||
167 | struct circ_buf *xmit = &port->info->xmit; | ||
168 | unsigned int count; | ||
169 | |||
170 | if (port->x_char) { | ||
171 | KS8695_CLR_TX_INT(); | ||
172 | UART_PUT_CHAR(port, port->x_char); | ||
173 | port->icount.tx++; | ||
174 | port->x_char = 0; | ||
175 | return IRQ_HANDLED; | ||
176 | } | ||
177 | |||
178 | if (uart_tx_stopped(port) || uart_circ_empty(xmit)) { | ||
179 | ks8695uart_stop_tx(port); | ||
180 | return IRQ_HANDLED; | ||
181 | } | ||
182 | |||
183 | count = 16; /* fifo size */ | ||
184 | while (!uart_circ_empty(xmit) && (count-- > 0)) { | ||
185 | KS8695_CLR_TX_INT(); | ||
186 | UART_PUT_CHAR(port, xmit->buf[xmit->tail]); | ||
187 | |||
188 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | ||
189 | port->icount.tx++; | ||
190 | } | ||
191 | |||
192 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | ||
193 | uart_write_wakeup(port); | ||
194 | |||
195 | if (uart_circ_empty(xmit)) | ||
196 | ks8695uart_stop_tx(port); | ||
197 | |||
198 | return IRQ_HANDLED; | ||
199 | } | ||
200 | |||
201 | static irqreturn_t ks8695uart_modem_status(int irq, void *dev_id) | ||
202 | { | ||
203 | struct uart_port *port = dev_id; | ||
204 | unsigned int status; | ||
205 | |||
206 | /* | ||
207 | * clear modem interrupt by reading MSR | ||
208 | */ | ||
209 | status = UART_GET_MSR(port); | ||
210 | |||
211 | if (status & URMS_URDDCD) | ||
212 | uart_handle_dcd_change(port, status & URMS_URDDCD); | ||
213 | |||
214 | if (status & URMS_URDDST) | ||
215 | port->icount.dsr++; | ||
216 | |||
217 | if (status & URMS_URDCTS) | ||
218 | uart_handle_cts_change(port, status & URMS_URDCTS); | ||
219 | |||
220 | if (status & URMS_URTERI) | ||
221 | port->icount.rng++; | ||
222 | |||
223 | wake_up_interruptible(&port->info->delta_msr_wait); | ||
224 | |||
225 | return IRQ_HANDLED; | ||
226 | } | ||
227 | |||
228 | static unsigned int ks8695uart_tx_empty(struct uart_port *port) | ||
229 | { | ||
230 | return (UART_GET_LSR(port) & URLS_URTE) ? TIOCSER_TEMT : 0; | ||
231 | } | ||
232 | |||
233 | static unsigned int ks8695uart_get_mctrl(struct uart_port *port) | ||
234 | { | ||
235 | unsigned int result = 0; | ||
236 | unsigned int status; | ||
237 | |||
238 | status = UART_GET_MSR(port); | ||
239 | if (status & URMS_URDCD) | ||
240 | result |= TIOCM_CAR; | ||
241 | if (status & URMS_URDSR) | ||
242 | result |= TIOCM_DSR; | ||
243 | if (status & URMS_URCTS) | ||
244 | result |= TIOCM_CTS; | ||
245 | if (status & URMS_URRI) | ||
246 | result |= TIOCM_RI; | ||
247 | |||
248 | return result; | ||
249 | } | ||
250 | |||
251 | static void ks8695uart_set_mctrl(struct uart_port *port, u_int mctrl) | ||
252 | { | ||
253 | unsigned int mcr; | ||
254 | |||
255 | mcr = UART_GET_MCR(port); | ||
256 | if (mctrl & TIOCM_RTS) | ||
257 | mcr |= URMC_URRTS; | ||
258 | else | ||
259 | mcr &= ~URMC_URRTS; | ||
260 | |||
261 | if (mctrl & TIOCM_DTR) | ||
262 | mcr |= URMC_URDTR; | ||
263 | else | ||
264 | mcr &= ~URMC_URDTR; | ||
265 | |||
266 | UART_PUT_MCR(port, mcr); | ||
267 | } | ||
268 | |||
269 | static void ks8695uart_break_ctl(struct uart_port *port, int break_state) | ||
270 | { | ||
271 | unsigned int lcr; | ||
272 | |||
273 | lcr = UART_GET_LCR(port); | ||
274 | |||
275 | if (break_state == -1) | ||
276 | lcr |= URLC_URSBC; | ||
277 | else | ||
278 | lcr &= ~URLC_URSBC; | ||
279 | |||
280 | UART_PUT_LCR(port, lcr); | ||
281 | } | ||
282 | |||
283 | static int ks8695uart_startup(struct uart_port *port) | ||
284 | { | ||
285 | int retval; | ||
286 | |||
287 | set_irq_flags(KS8695_IRQ_UART_TX, IRQF_VALID | IRQF_NOAUTOEN); | ||
288 | tx_enabled(port) = 0; | ||
289 | rx_enabled(port) = 1; | ||
290 | |||
291 | /* | ||
292 | * Allocate the IRQ | ||
293 | */ | ||
294 | retval = request_irq(KS8695_IRQ_UART_TX, ks8695uart_tx_chars, IRQF_DISABLED, "UART TX", port); | ||
295 | if (retval) | ||
296 | goto err_tx; | ||
297 | |||
298 | retval = request_irq(KS8695_IRQ_UART_RX, ks8695uart_rx_chars, IRQF_DISABLED, "UART RX", port); | ||
299 | if (retval) | ||
300 | goto err_rx; | ||
301 | |||
302 | retval = request_irq(KS8695_IRQ_UART_LINE_STATUS, ks8695uart_rx_chars, IRQF_DISABLED, "UART LineStatus", port); | ||
303 | if (retval) | ||
304 | return err_ls; | ||
305 | |||
306 | retval = request_irq(KS8695_IRQ_UART_MODEM_STATUS, ks8695uart_modem_status, IRQF_DISABLED, "UART ModemStatus", port); | ||
307 | if (retval) | ||
308 | return err_ms; | ||
309 | |||
310 | return 0; | ||
311 | |||
312 | err_ms: | ||
313 | free_irq(KS8695_IRQ_UART_LINE_STATUS, port); | ||
314 | err_ls: | ||
315 | free_irq(KS8695_IRQ_UART_RX, port); | ||
316 | err_rx: | ||
317 | free_irq(KS8695_IRQ_UART_TX, port); | ||
318 | err_tx: | ||
319 | return retval; | ||
320 | } | ||
321 | |||
322 | static void ks8695uart_shutdown(struct uart_port *port) | ||
323 | { | ||
324 | /* | ||
325 | * Free the interrupt | ||
326 | */ | ||
327 | free_irq(KS8695_IRQ_UART_RX, port); | ||
328 | free_irq(KS8695_IRQ_UART_TX, port); | ||
329 | free_irq(KS8695_IRQ_UART_MODEM_STATUS, port); | ||
330 | free_irq(KS8695_IRQ_UART_LINE_STATUS, port); | ||
331 | |||
332 | /* disable break condition and fifos */ | ||
333 | UART_PUT_LCR(port, UART_GET_LCR(port) & ~URLC_URSBC); | ||
334 | UART_PUT_FCR(port, UART_GET_FCR(port) & ~URFC_URFE); | ||
335 | } | ||
336 | |||
337 | static void ks8695uart_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) | ||
338 | { | ||
339 | unsigned int lcr, fcr = 0; | ||
340 | unsigned long flags; | ||
341 | unsigned int baud, quot; | ||
342 | |||
343 | /* | ||
344 | * Ask the core to calculate the divisor for us. | ||
345 | */ | ||
346 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); | ||
347 | quot = uart_get_divisor(port, baud); | ||
348 | |||
349 | switch (termios->c_cflag & CSIZE) { | ||
350 | case CS5: | ||
351 | lcr = URCL_5; | ||
352 | break; | ||
353 | case CS6: | ||
354 | lcr = URCL_6; | ||
355 | break; | ||
356 | case CS7: | ||
357 | lcr = URCL_7; | ||
358 | break; | ||
359 | default: | ||
360 | lcr = URCL_8; | ||
361 | break; | ||
362 | } | ||
363 | |||
364 | /* stop bits */ | ||
365 | if (termios->c_cflag & CSTOPB) | ||
366 | lcr |= URLC_URSB; | ||
367 | |||
368 | /* parity */ | ||
369 | if (termios->c_cflag & PARENB) { | ||
370 | if (termios->c_cflag & CMSPAR) { /* Mark or Space parity */ | ||
371 | if (termios->c_cflag & PARODD) | ||
372 | lcr |= URPE_MARK; | ||
373 | else | ||
374 | lcr |= URPE_SPACE; | ||
375 | } | ||
376 | else if (termios->c_cflag & PARODD) | ||
377 | lcr |= URPE_ODD; | ||
378 | else | ||
379 | lcr |= URPE_EVEN; | ||
380 | } | ||
381 | |||
382 | if (port->fifosize > 1) | ||
383 | fcr = URFC_URFRT_8 | URFC_URTFR | URFC_URRFR | URFC_URFE; | ||
384 | |||
385 | spin_lock_irqsave(&port->lock, flags); | ||
386 | |||
387 | /* | ||
388 | * Update the per-port timeout. | ||
389 | */ | ||
390 | uart_update_timeout(port, termios->c_cflag, baud); | ||
391 | |||
392 | port->read_status_mask = URLS_URROE; | ||
393 | if (termios->c_iflag & INPCK) | ||
394 | port->read_status_mask |= (URLS_URFE | URLS_URPE); | ||
395 | if (termios->c_iflag & (BRKINT | PARMRK)) | ||
396 | port->read_status_mask |= URLS_URBI; | ||
397 | |||
398 | /* | ||
399 | * Characters to ignore | ||
400 | */ | ||
401 | port->ignore_status_mask = 0; | ||
402 | if (termios->c_iflag & IGNPAR) | ||
403 | port->ignore_status_mask |= (URLS_URFE | URLS_URPE); | ||
404 | if (termios->c_iflag & IGNBRK) { | ||
405 | port->ignore_status_mask |= URLS_URBI; | ||
406 | /* | ||
407 | * If we're ignoring parity and break indicators, | ||
408 | * ignore overruns too (for real raw support). | ||
409 | */ | ||
410 | if (termios->c_iflag & IGNPAR) | ||
411 | port->ignore_status_mask |= URLS_URROE; | ||
412 | } | ||
413 | |||
414 | /* | ||
415 | * Ignore all characters if CREAD is not set. | ||
416 | */ | ||
417 | if ((termios->c_cflag & CREAD) == 0) | ||
418 | port->ignore_status_mask |= UART_DUMMY_LSR_RX; | ||
419 | |||
420 | /* first, disable everything */ | ||
421 | if (UART_ENABLE_MS(port, termios->c_cflag)) | ||
422 | ks8695uart_enable_ms(port); | ||
423 | else | ||
424 | ks8695uart_disable_ms(port); | ||
425 | |||
426 | /* Set baud rate */ | ||
427 | UART_PUT_BRDR(port, quot); | ||
428 | |||
429 | UART_PUT_LCR(port, lcr); | ||
430 | UART_PUT_FCR(port, fcr); | ||
431 | |||
432 | spin_unlock_irqrestore(&port->lock, flags); | ||
433 | } | ||
434 | |||
435 | static const char *ks8695uart_type(struct uart_port *port) | ||
436 | { | ||
437 | return port->type == PORT_KS8695 ? "KS8695" : NULL; | ||
438 | } | ||
439 | |||
440 | /* | ||
441 | * Release the memory region(s) being used by 'port' | ||
442 | */ | ||
443 | static void ks8695uart_release_port(struct uart_port *port) | ||
444 | { | ||
445 | release_mem_region(port->mapbase, UART_PORT_SIZE); | ||
446 | } | ||
447 | |||
448 | /* | ||
449 | * Request the memory region(s) being used by 'port' | ||
450 | */ | ||
451 | static int ks8695uart_request_port(struct uart_port *port) | ||
452 | { | ||
453 | return request_mem_region(port->mapbase, UART_PORT_SIZE, | ||
454 | "serial_ks8695") != NULL ? 0 : -EBUSY; | ||
455 | } | ||
456 | |||
457 | /* | ||
458 | * Configure/autoconfigure the port. | ||
459 | */ | ||
460 | static void ks8695uart_config_port(struct uart_port *port, int flags) | ||
461 | { | ||
462 | if (flags & UART_CONFIG_TYPE) { | ||
463 | port->type = PORT_KS8695; | ||
464 | ks8695uart_request_port(port); | ||
465 | } | ||
466 | } | ||
467 | |||
468 | /* | ||
469 | * verify the new serial_struct (for TIOCSSERIAL). | ||
470 | */ | ||
471 | static int ks8695uart_verify_port(struct uart_port *port, struct serial_struct *ser) | ||
472 | { | ||
473 | int ret = 0; | ||
474 | |||
475 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_KS8695) | ||
476 | ret = -EINVAL; | ||
477 | if (ser->irq != port->irq) | ||
478 | ret = -EINVAL; | ||
479 | if (ser->baud_base < 9600) | ||
480 | ret = -EINVAL; | ||
481 | return ret; | ||
482 | } | ||
483 | |||
484 | static struct uart_ops ks8695uart_pops = { | ||
485 | .tx_empty = ks8695uart_tx_empty, | ||
486 | .set_mctrl = ks8695uart_set_mctrl, | ||
487 | .get_mctrl = ks8695uart_get_mctrl, | ||
488 | .stop_tx = ks8695uart_stop_tx, | ||
489 | .start_tx = ks8695uart_start_tx, | ||
490 | .stop_rx = ks8695uart_stop_rx, | ||
491 | .enable_ms = ks8695uart_enable_ms, | ||
492 | .break_ctl = ks8695uart_break_ctl, | ||
493 | .startup = ks8695uart_startup, | ||
494 | .shutdown = ks8695uart_shutdown, | ||
495 | .set_termios = ks8695uart_set_termios, | ||
496 | .type = ks8695uart_type, | ||
497 | .release_port = ks8695uart_release_port, | ||
498 | .request_port = ks8695uart_request_port, | ||
499 | .config_port = ks8695uart_config_port, | ||
500 | .verify_port = ks8695uart_verify_port, | ||
501 | }; | ||
502 | |||
503 | static struct uart_port ks8695uart_ports[SERIAL_KS8695_NR] = { | ||
504 | { | ||
505 | .membase = (void *) KS8695_UART_VA, | ||
506 | .mapbase = KS8695_UART_VA, | ||
507 | .iotype = SERIAL_IO_MEM, | ||
508 | .irq = KS8695_IRQ_UART_TX, | ||
509 | .uartclk = CLOCK_TICK_RATE * 16, | ||
510 | .fifosize = 16, | ||
511 | .ops = &ks8695uart_pops, | ||
512 | .flags = ASYNC_BOOT_AUTOCONF, | ||
513 | .line = 0, | ||
514 | } | ||
515 | }; | ||
516 | |||
517 | #ifdef CONFIG_SERIAL_KS8695_CONSOLE | ||
518 | static void ks8695_console_putchar(struct uart_port *port, int ch) | ||
519 | { | ||
520 | while (!(UART_GET_LSR(port) & URLS_URTHRE)) | ||
521 | barrier(); | ||
522 | |||
523 | UART_PUT_CHAR(port, ch); | ||
524 | } | ||
525 | |||
526 | static void ks8695_console_write(struct console *co, const char *s, u_int count) | ||
527 | { | ||
528 | struct uart_port *port = ks8695uart_ports + co->index; | ||
529 | |||
530 | uart_console_write(port, s, count, ks8695_console_putchar); | ||
531 | } | ||
532 | |||
533 | static void __init ks8695_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits) | ||
534 | { | ||
535 | unsigned int lcr; | ||
536 | |||
537 | lcr = UART_GET_LCR(port); | ||
538 | |||
539 | switch (lcr & URLC_PARITY) { | ||
540 | case URPE_ODD: | ||
541 | *parity = 'o'; | ||
542 | break; | ||
543 | case URPE_EVEN: | ||
544 | *parity = 'e'; | ||
545 | break; | ||
546 | default: | ||
547 | *parity = 'n'; | ||
548 | } | ||
549 | |||
550 | switch (lcr & URLC_URCL) { | ||
551 | case URCL_5: | ||
552 | *bits = 5; | ||
553 | break; | ||
554 | case URCL_6: | ||
555 | *bits = 6; | ||
556 | break; | ||
557 | case URCL_7: | ||
558 | *bits = 7; | ||
559 | break; | ||
560 | default: | ||
561 | *bits = 8; | ||
562 | } | ||
563 | |||
564 | *baud = port->uartclk / (UART_GET_BRDR(port) & 0x0FFF); | ||
565 | *baud /= 16; | ||
566 | *baud &= 0xFFFFFFF0; | ||
567 | } | ||
568 | |||
569 | static int __init ks8695_console_setup(struct console *co, char *options) | ||
570 | { | ||
571 | struct uart_port *port; | ||
572 | int baud = 115200; | ||
573 | int bits = 8; | ||
574 | int parity = 'n'; | ||
575 | int flow = 'n'; | ||
576 | |||
577 | /* | ||
578 | * Check whether an invalid uart number has been specified, and | ||
579 | * if so, search for the first available port that does have | ||
580 | * console support. | ||
581 | */ | ||
582 | port = uart_get_console(ks8695uart_ports, SERIAL_KS8695_NR, co); | ||
583 | |||
584 | if (options) | ||
585 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
586 | else | ||
587 | ks8695_console_get_options(port, &baud, &parity, &bits); | ||
588 | |||
589 | return uart_set_options(port, co, baud, parity, bits, flow); | ||
590 | } | ||
591 | |||
592 | extern struct uart_driver ks8695_reg; | ||
593 | |||
594 | static struct console ks8695_console = { | ||
595 | .name = SERIAL_KS8695_DEVNAME, | ||
596 | .write = ks8695_console_write, | ||
597 | .device = uart_console_device, | ||
598 | .setup = ks8695_console_setup, | ||
599 | .flags = CON_PRINTBUFFER, | ||
600 | .index = -1, | ||
601 | .data = &ks8695_reg, | ||
602 | }; | ||
603 | |||
604 | static int __init ks8695_console_init(void) | ||
605 | { | ||
606 | register_console(&ks8695_console); | ||
607 | return 0; | ||
608 | } | ||
609 | |||
610 | console_initcall(ks8695_console_init); | ||
611 | |||
612 | #define KS8695_CONSOLE &ks8695_console | ||
613 | #else | ||
614 | #define KS8695_CONSOLE NULL | ||
615 | #endif | ||
616 | |||
617 | static struct uart_driver ks8695_reg = { | ||
618 | .owner = THIS_MODULE, | ||
619 | .driver_name = "serial_ks8695", | ||
620 | .dev_name = SERIAL_KS8695_DEVNAME, | ||
621 | .major = SERIAL_KS8695_MAJOR, | ||
622 | .minor = SERIAL_KS8695_MINOR, | ||
623 | .nr = SERIAL_KS8695_NR, | ||
624 | .cons = KS8695_CONSOLE, | ||
625 | }; | ||
626 | |||
627 | static int __init ks8695uart_init(void) | ||
628 | { | ||
629 | int i, ret; | ||
630 | |||
631 | printk(KERN_INFO "Serial: Micrel KS8695 UART driver\n"); | ||
632 | |||
633 | ret = uart_register_driver(&ks8695_reg); | ||
634 | if (ret) | ||
635 | return ret; | ||
636 | |||
637 | for (i = 0; i < SERIAL_KS8695_NR; i++) | ||
638 | uart_add_one_port(&ks8695_reg, &ks8695uart_ports[0]); | ||
639 | |||
640 | return 0; | ||
641 | } | ||
642 | |||
643 | static void __exit ks8695uart_exit(void) | ||
644 | { | ||
645 | int i; | ||
646 | |||
647 | for (i = 0; i < SERIAL_KS8695_NR; i++) | ||
648 | uart_remove_one_port(&ks8695_reg, &ks8695uart_ports[0]); | ||
649 | uart_unregister_driver(&ks8695_reg); | ||
650 | } | ||
651 | |||
652 | module_init(ks8695uart_init); | ||
653 | module_exit(ks8695uart_exit); | ||
654 | |||
655 | MODULE_DESCRIPTION("KS8695 serial port driver"); | ||
656 | MODULE_AUTHOR("Micrel Inc."); | ||
657 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c index 40d48566215c..c3a6bd2e7950 100644 --- a/drivers/serial/sunhv.c +++ b/drivers/serial/sunhv.c | |||
@@ -493,6 +493,10 @@ static struct of_device_id hv_match[] = { | |||
493 | .name = "console", | 493 | .name = "console", |
494 | .compatible = "qcn", | 494 | .compatible = "qcn", |
495 | }, | 495 | }, |
496 | { | ||
497 | .name = "console", | ||
498 | .compatible = "SUNW,sun4v-console", | ||
499 | }, | ||
496 | {}, | 500 | {}, |
497 | }; | 501 | }; |
498 | MODULE_DEVICE_TABLE(of, hv_match); | 502 | MODULE_DEVICE_TABLE(of, hv_match); |
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index da73205e54cd..0985193dc57d 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -92,6 +92,8 @@ struct uart_sunzilog_port { | |||
92 | #define SUNZILOG_FLAG_REGS_HELD 0x00000040 | 92 | #define SUNZILOG_FLAG_REGS_HELD 0x00000040 |
93 | #define SUNZILOG_FLAG_TX_STOPPED 0x00000080 | 93 | #define SUNZILOG_FLAG_TX_STOPPED 0x00000080 |
94 | #define SUNZILOG_FLAG_TX_ACTIVE 0x00000100 | 94 | #define SUNZILOG_FLAG_TX_ACTIVE 0x00000100 |
95 | #define SUNZILOG_FLAG_ESCC 0x00000200 | ||
96 | #define SUNZILOG_FLAG_ISR_HANDLER 0x00000400 | ||
95 | 97 | ||
96 | unsigned int cflag; | 98 | unsigned int cflag; |
97 | 99 | ||
@@ -174,9 +176,11 @@ static void sunzilog_clear_fifo(struct zilog_channel __iomem *channel) | |||
174 | /* This function must only be called when the TX is not busy. The UART | 176 | /* This function must only be called when the TX is not busy. The UART |
175 | * port lock must be held and local interrupts disabled. | 177 | * port lock must be held and local interrupts disabled. |
176 | */ | 178 | */ |
177 | static void __load_zsregs(struct zilog_channel __iomem *channel, unsigned char *regs) | 179 | static int __load_zsregs(struct zilog_channel __iomem *channel, unsigned char *regs) |
178 | { | 180 | { |
179 | int i; | 181 | int i; |
182 | int escc; | ||
183 | unsigned char r15; | ||
180 | 184 | ||
181 | /* Let pending transmits finish. */ | 185 | /* Let pending transmits finish. */ |
182 | for (i = 0; i < 1000; i++) { | 186 | for (i = 0; i < 1000; i++) { |
@@ -229,11 +233,25 @@ static void __load_zsregs(struct zilog_channel __iomem *channel, unsigned char * | |||
229 | write_zsreg(channel, R14, regs[R14]); | 233 | write_zsreg(channel, R14, regs[R14]); |
230 | 234 | ||
231 | /* External status interrupt control. */ | 235 | /* External status interrupt control. */ |
232 | write_zsreg(channel, R15, regs[R15]); | 236 | write_zsreg(channel, R15, (regs[R15] | WR7pEN) & ~FIFOEN); |
237 | |||
238 | /* ESCC Extension Register */ | ||
239 | r15 = read_zsreg(channel, R15); | ||
240 | if (r15 & 0x01) { | ||
241 | write_zsreg(channel, R7, regs[R7p]); | ||
242 | |||
243 | /* External status interrupt and FIFO control. */ | ||
244 | write_zsreg(channel, R15, regs[R15] & ~WR7pEN); | ||
245 | escc = 1; | ||
246 | } else { | ||
247 | /* Clear FIFO bit case it is an issue */ | ||
248 | regs[R15] &= ~FIFOEN; | ||
249 | escc = 0; | ||
250 | } | ||
233 | 251 | ||
234 | /* Reset external status interrupts. */ | 252 | /* Reset external status interrupts. */ |
235 | write_zsreg(channel, R0, RES_EXT_INT); | 253 | write_zsreg(channel, R0, RES_EXT_INT); /* First Latch */ |
236 | write_zsreg(channel, R0, RES_EXT_INT); | 254 | write_zsreg(channel, R0, RES_EXT_INT); /* Second Latch */ |
237 | 255 | ||
238 | /* Rewrite R3/R5, this time without enables masked. */ | 256 | /* Rewrite R3/R5, this time without enables masked. */ |
239 | write_zsreg(channel, R3, regs[R3]); | 257 | write_zsreg(channel, R3, regs[R3]); |
@@ -241,6 +259,8 @@ static void __load_zsregs(struct zilog_channel __iomem *channel, unsigned char * | |||
241 | 259 | ||
242 | /* Rewrite R1, this time without IRQ enabled masked. */ | 260 | /* Rewrite R1, this time without IRQ enabled masked. */ |
243 | write_zsreg(channel, R1, regs[R1]); | 261 | write_zsreg(channel, R1, regs[R1]); |
262 | |||
263 | return escc; | ||
244 | } | 264 | } |
245 | 265 | ||
246 | /* Reprogram the Zilog channel HW registers with the copies found in the | 266 | /* Reprogram the Zilog channel HW registers with the copies found in the |
@@ -731,7 +751,7 @@ static void sunzilog_enable_ms(struct uart_port *port) | |||
731 | up->curregs[R15] = new_reg; | 751 | up->curregs[R15] = new_reg; |
732 | 752 | ||
733 | /* NOTE: Not subject to 'transmitter active' rule. */ | 753 | /* NOTE: Not subject to 'transmitter active' rule. */ |
734 | write_zsreg(channel, R15, up->curregs[R15]); | 754 | write_zsreg(channel, R15, up->curregs[R15] & ~WR7pEN); |
735 | } | 755 | } |
736 | } | 756 | } |
737 | 757 | ||
@@ -861,44 +881,44 @@ sunzilog_convert_to_zs(struct uart_sunzilog_port *up, unsigned int cflag, | |||
861 | up->curregs[R14] = BRSRC | BRENAB; | 881 | up->curregs[R14] = BRSRC | BRENAB; |
862 | 882 | ||
863 | /* Character size, stop bits, and parity. */ | 883 | /* Character size, stop bits, and parity. */ |
864 | up->curregs[3] &= ~RxN_MASK; | 884 | up->curregs[R3] &= ~RxN_MASK; |
865 | up->curregs[5] &= ~TxN_MASK; | 885 | up->curregs[R5] &= ~TxN_MASK; |
866 | switch (cflag & CSIZE) { | 886 | switch (cflag & CSIZE) { |
867 | case CS5: | 887 | case CS5: |
868 | up->curregs[3] |= Rx5; | 888 | up->curregs[R3] |= Rx5; |
869 | up->curregs[5] |= Tx5; | 889 | up->curregs[R5] |= Tx5; |
870 | up->parity_mask = 0x1f; | 890 | up->parity_mask = 0x1f; |
871 | break; | 891 | break; |
872 | case CS6: | 892 | case CS6: |
873 | up->curregs[3] |= Rx6; | 893 | up->curregs[R3] |= Rx6; |
874 | up->curregs[5] |= Tx6; | 894 | up->curregs[R5] |= Tx6; |
875 | up->parity_mask = 0x3f; | 895 | up->parity_mask = 0x3f; |
876 | break; | 896 | break; |
877 | case CS7: | 897 | case CS7: |
878 | up->curregs[3] |= Rx7; | 898 | up->curregs[R3] |= Rx7; |
879 | up->curregs[5] |= Tx7; | 899 | up->curregs[R5] |= Tx7; |
880 | up->parity_mask = 0x7f; | 900 | up->parity_mask = 0x7f; |
881 | break; | 901 | break; |
882 | case CS8: | 902 | case CS8: |
883 | default: | 903 | default: |
884 | up->curregs[3] |= Rx8; | 904 | up->curregs[R3] |= Rx8; |
885 | up->curregs[5] |= Tx8; | 905 | up->curregs[R5] |= Tx8; |
886 | up->parity_mask = 0xff; | 906 | up->parity_mask = 0xff; |
887 | break; | 907 | break; |
888 | }; | 908 | }; |
889 | up->curregs[4] &= ~0x0c; | 909 | up->curregs[R4] &= ~0x0c; |
890 | if (cflag & CSTOPB) | 910 | if (cflag & CSTOPB) |
891 | up->curregs[4] |= SB2; | 911 | up->curregs[R4] |= SB2; |
892 | else | 912 | else |
893 | up->curregs[4] |= SB1; | 913 | up->curregs[R4] |= SB1; |
894 | if (cflag & PARENB) | 914 | if (cflag & PARENB) |
895 | up->curregs[4] |= PAR_ENAB; | 915 | up->curregs[R4] |= PAR_ENAB; |
896 | else | 916 | else |
897 | up->curregs[4] &= ~PAR_ENAB; | 917 | up->curregs[R4] &= ~PAR_ENAB; |
898 | if (!(cflag & PARODD)) | 918 | if (!(cflag & PARODD)) |
899 | up->curregs[4] |= PAR_EVEN; | 919 | up->curregs[R4] |= PAR_EVEN; |
900 | else | 920 | else |
901 | up->curregs[4] &= ~PAR_EVEN; | 921 | up->curregs[R4] &= ~PAR_EVEN; |
902 | 922 | ||
903 | up->port.read_status_mask = Rx_OVR; | 923 | up->port.read_status_mask = Rx_OVR; |
904 | if (iflag & INPCK) | 924 | if (iflag & INPCK) |
@@ -952,7 +972,9 @@ sunzilog_set_termios(struct uart_port *port, struct ktermios *termios, | |||
952 | 972 | ||
953 | static const char *sunzilog_type(struct uart_port *port) | 973 | static const char *sunzilog_type(struct uart_port *port) |
954 | { | 974 | { |
955 | return "zs"; | 975 | struct uart_sunzilog_port *up = UART_ZILOG(port); |
976 | |||
977 | return (up->flags & SUNZILOG_FLAG_ESCC) ? "zs (ESCC)" : "zs"; | ||
956 | } | 978 | } |
957 | 979 | ||
958 | /* We do not request/release mappings of the registers here, this | 980 | /* We do not request/release mappings of the registers here, this |
@@ -1170,7 +1192,7 @@ static int __init sunzilog_console_setup(struct console *con, char *options) | |||
1170 | 1192 | ||
1171 | spin_lock_irqsave(&up->port.lock, flags); | 1193 | spin_lock_irqsave(&up->port.lock, flags); |
1172 | 1194 | ||
1173 | up->curregs[R15] = BRKIE; | 1195 | up->curregs[R15] |= BRKIE; |
1174 | sunzilog_convert_to_zs(up, con->cflag, 0, brg); | 1196 | sunzilog_convert_to_zs(up, con->cflag, 0, brg); |
1175 | 1197 | ||
1176 | sunzilog_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); | 1198 | sunzilog_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); |
@@ -1229,7 +1251,7 @@ static void __init sunzilog_init_kbdms(struct uart_sunzilog_port *up, int channe | |||
1229 | baud = 4800; | 1251 | baud = 4800; |
1230 | } | 1252 | } |
1231 | 1253 | ||
1232 | up->curregs[R15] = BRKIE; | 1254 | up->curregs[R15] |= BRKIE; |
1233 | brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR); | 1255 | brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR); |
1234 | sunzilog_convert_to_zs(up, up->cflag, 0, brg); | 1256 | sunzilog_convert_to_zs(up, up->cflag, 0, brg); |
1235 | sunzilog_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); | 1257 | sunzilog_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); |
@@ -1283,8 +1305,18 @@ static void __devinit sunzilog_init_hw(struct uart_sunzilog_port *up) | |||
1283 | 1305 | ||
1284 | if (up->flags & (SUNZILOG_FLAG_CONS_KEYB | | 1306 | if (up->flags & (SUNZILOG_FLAG_CONS_KEYB | |
1285 | SUNZILOG_FLAG_CONS_MOUSE)) { | 1307 | SUNZILOG_FLAG_CONS_MOUSE)) { |
1308 | up->curregs[R1] = EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB; | ||
1309 | up->curregs[R4] = PAR_EVEN | X16CLK | SB1; | ||
1310 | up->curregs[R3] = RxENAB | Rx8; | ||
1311 | up->curregs[R5] = TxENAB | Tx8; | ||
1312 | up->curregs[R6] = 0x00; /* SDLC Address */ | ||
1313 | up->curregs[R7] = 0x7E; /* SDLC Flag */ | ||
1314 | up->curregs[R9] = NV; | ||
1315 | up->curregs[R7p] = 0x00; | ||
1286 | sunzilog_init_kbdms(up, up->port.line); | 1316 | sunzilog_init_kbdms(up, up->port.line); |
1287 | up->curregs[R9] |= (NV | MIE); | 1317 | /* Only enable interrupts if an ISR handler available */ |
1318 | if (up->flags & SUNZILOG_FLAG_ISR_HANDLER) | ||
1319 | up->curregs[R9] |= MIE; | ||
1288 | write_zsreg(channel, R9, up->curregs[R9]); | 1320 | write_zsreg(channel, R9, up->curregs[R9]); |
1289 | } else { | 1321 | } else { |
1290 | /* Normal serial TTY. */ | 1322 | /* Normal serial TTY. */ |
@@ -1293,7 +1325,9 @@ static void __devinit sunzilog_init_hw(struct uart_sunzilog_port *up) | |||
1293 | up->curregs[R4] = PAR_EVEN | X16CLK | SB1; | 1325 | up->curregs[R4] = PAR_EVEN | X16CLK | SB1; |
1294 | up->curregs[R3] = RxENAB | Rx8; | 1326 | up->curregs[R3] = RxENAB | Rx8; |
1295 | up->curregs[R5] = TxENAB | Tx8; | 1327 | up->curregs[R5] = TxENAB | Tx8; |
1296 | up->curregs[R9] = NV | MIE; | 1328 | up->curregs[R6] = 0x00; /* SDLC Address */ |
1329 | up->curregs[R7] = 0x7E; /* SDLC Flag */ | ||
1330 | up->curregs[R9] = NV; | ||
1297 | up->curregs[R10] = NRZ; | 1331 | up->curregs[R10] = NRZ; |
1298 | up->curregs[R11] = TCBR | RCBR; | 1332 | up->curregs[R11] = TCBR | RCBR; |
1299 | baud = 9600; | 1333 | baud = 9600; |
@@ -1301,7 +1335,14 @@ static void __devinit sunzilog_init_hw(struct uart_sunzilog_port *up) | |||
1301 | up->curregs[R12] = (brg & 0xff); | 1335 | up->curregs[R12] = (brg & 0xff); |
1302 | up->curregs[R13] = (brg >> 8) & 0xff; | 1336 | up->curregs[R13] = (brg >> 8) & 0xff; |
1303 | up->curregs[R14] = BRSRC | BRENAB; | 1337 | up->curregs[R14] = BRSRC | BRENAB; |
1304 | __load_zsregs(channel, up->curregs); | 1338 | up->curregs[R15] = FIFOEN; /* Use FIFO if on ESCC */ |
1339 | up->curregs[R7p] = TxFIFO_LVL | RxFIFO_LVL; | ||
1340 | if (__load_zsregs(channel, up->curregs)) { | ||
1341 | up->flags |= SUNZILOG_FLAG_ESCC; | ||
1342 | } | ||
1343 | /* Only enable interrupts if an ISR handler available */ | ||
1344 | if (up->flags & SUNZILOG_FLAG_ISR_HANDLER) | ||
1345 | up->curregs[R9] |= MIE; | ||
1305 | write_zsreg(channel, R9, up->curregs[R9]); | 1346 | write_zsreg(channel, R9, up->curregs[R9]); |
1306 | } | 1347 | } |
1307 | 1348 | ||
@@ -1390,12 +1431,14 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m | |||
1390 | return err; | 1431 | return err; |
1391 | } | 1432 | } |
1392 | } else { | 1433 | } else { |
1393 | printk(KERN_INFO "%s: Keyboard at MMIO %lx (irq = %d) " | 1434 | printk(KERN_INFO "%s: Keyboard at MMIO 0x%lx (irq = %d) " |
1394 | "is a zs\n", | 1435 | "is a %s\n", |
1395 | op->dev.bus_id, up[0].port.mapbase, op->irqs[0]); | 1436 | op->dev.bus_id, up[0].port.mapbase, op->irqs[0], |
1396 | printk(KERN_INFO "%s: Mouse at MMIO %lx (irq = %d) " | 1437 | sunzilog_type (&up[0].port)); |
1397 | "is a zs\n", | 1438 | printk(KERN_INFO "%s: Mouse at MMIO 0x%lx (irq = %d) " |
1398 | op->dev.bus_id, up[1].port.mapbase, op->irqs[0]); | 1439 | "is a %s\n", |
1440 | op->dev.bus_id, up[1].port.mapbase, op->irqs[0], | ||
1441 | sunzilog_type (&up[1].port)); | ||
1399 | } | 1442 | } |
1400 | 1443 | ||
1401 | dev_set_drvdata(&op->dev, &up[0]); | 1444 | dev_set_drvdata(&op->dev, &up[0]); |
@@ -1487,10 +1530,23 @@ static int __init sunzilog_init(void) | |||
1487 | goto out_unregister_uart; | 1530 | goto out_unregister_uart; |
1488 | 1531 | ||
1489 | if (zilog_irq != -1) { | 1532 | if (zilog_irq != -1) { |
1533 | struct uart_sunzilog_port *up = sunzilog_irq_chain; | ||
1490 | err = request_irq(zilog_irq, sunzilog_interrupt, IRQF_SHARED, | 1534 | err = request_irq(zilog_irq, sunzilog_interrupt, IRQF_SHARED, |
1491 | "zs", sunzilog_irq_chain); | 1535 | "zs", sunzilog_irq_chain); |
1492 | if (err) | 1536 | if (err) |
1493 | goto out_unregister_driver; | 1537 | goto out_unregister_driver; |
1538 | |||
1539 | /* Enable Interrupts */ | ||
1540 | while (up) { | ||
1541 | struct zilog_channel __iomem *channel; | ||
1542 | |||
1543 | /* printk (KERN_INFO "Enable IRQ for ZILOG Hardware %p\n", up); */ | ||
1544 | channel = ZILOG_CHANNEL_FROM_PORT(&up->port); | ||
1545 | up->flags |= SUNZILOG_FLAG_ISR_HANDLER; | ||
1546 | up->curregs[R9] |= MIE; | ||
1547 | write_zsreg(channel, R9, up->curregs[R9]); | ||
1548 | up = up->next; | ||
1549 | } | ||
1494 | } | 1550 | } |
1495 | 1551 | ||
1496 | out: | 1552 | out: |
@@ -1515,6 +1571,20 @@ static void __exit sunzilog_exit(void) | |||
1515 | of_unregister_driver(&zs_driver); | 1571 | of_unregister_driver(&zs_driver); |
1516 | 1572 | ||
1517 | if (zilog_irq != -1) { | 1573 | if (zilog_irq != -1) { |
1574 | struct uart_sunzilog_port *up = sunzilog_irq_chain; | ||
1575 | |||
1576 | /* Disable Interrupts */ | ||
1577 | while (up) { | ||
1578 | struct zilog_channel __iomem *channel; | ||
1579 | |||
1580 | /* printk (KERN_INFO "Disable IRQ for ZILOG Hardware %p\n", up); */ | ||
1581 | channel = ZILOG_CHANNEL_FROM_PORT(&up->port); | ||
1582 | up->flags &= ~SUNZILOG_FLAG_ISR_HANDLER; | ||
1583 | up->curregs[R9] &= ~MIE; | ||
1584 | write_zsreg(channel, R9, up->curregs[R9]); | ||
1585 | up = up->next; | ||
1586 | } | ||
1587 | |||
1518 | free_irq(zilog_irq, sunzilog_irq_chain); | 1588 | free_irq(zilog_irq, sunzilog_irq_chain); |
1519 | zilog_irq = -1; | 1589 | zilog_irq = -1; |
1520 | } | 1590 | } |
diff --git a/drivers/serial/sunzilog.h b/drivers/serial/sunzilog.h index 7939b6d71270..5dec7b47cc38 100644 --- a/drivers/serial/sunzilog.h +++ b/drivers/serial/sunzilog.h | |||
@@ -13,7 +13,8 @@ struct zilog_layout { | |||
13 | struct zilog_channel channelA; | 13 | struct zilog_channel channelA; |
14 | }; | 14 | }; |
15 | 15 | ||
16 | #define NUM_ZSREGS 16 | 16 | #define NUM_ZSREGS 17 |
17 | #define R7p 16 /* Written as R7 with P15 bit 0 set */ | ||
17 | 18 | ||
18 | /* Conversion routines to/from brg time constants from/to bits | 19 | /* Conversion routines to/from brg time constants from/to bits |
19 | * per second. | 20 | * per second. |
@@ -127,6 +128,15 @@ struct zilog_layout { | |||
127 | 128 | ||
128 | /* Write Register 7 (Sync bits 8-15/SDLC 01111110) */ | 129 | /* Write Register 7 (Sync bits 8-15/SDLC 01111110) */ |
129 | 130 | ||
131 | /* Write Register 7' (ESCC Only) */ | ||
132 | #define AUTO_TxFLAG 1 /* Automatic Tx SDLC Flag */ | ||
133 | #define AUTO_EOM_RST 2 /* Automatic EOM Reset */ | ||
134 | #define AUTOnRTS 4 /* Automatic /RTS pin deactivation */ | ||
135 | #define RxFIFO_LVL 8 /* Receive FIFO interrupt level */ | ||
136 | #define nDTRnREQ 0x10 /* /DTR/REQ timing */ | ||
137 | #define TxFIFO_LVL 0x20 /* Transmit FIFO interrupt level */ | ||
138 | #define EXT_RD_EN 0x40 /* Extended read register enable */ | ||
139 | |||
130 | /* Write Register 8 (transmit buffer) */ | 140 | /* Write Register 8 (transmit buffer) */ |
131 | 141 | ||
132 | /* Write Register 9 (Master interrupt control) */ | 142 | /* Write Register 9 (Master interrupt control) */ |
@@ -135,6 +145,7 @@ struct zilog_layout { | |||
135 | #define DLC 4 /* Disable Lower Chain */ | 145 | #define DLC 4 /* Disable Lower Chain */ |
136 | #define MIE 8 /* Master Interrupt Enable */ | 146 | #define MIE 8 /* Master Interrupt Enable */ |
137 | #define STATHI 0x10 /* Status high */ | 147 | #define STATHI 0x10 /* Status high */ |
148 | #define SWIACK 0x20 /* Software Interrupt Ack (not on NMOS) */ | ||
138 | #define NORESET 0 /* No reset on write to R9 */ | 149 | #define NORESET 0 /* No reset on write to R9 */ |
139 | #define CHRB 0x40 /* Reset channel B */ | 150 | #define CHRB 0x40 /* Reset channel B */ |
140 | #define CHRA 0x80 /* Reset channel A */ | 151 | #define CHRA 0x80 /* Reset channel A */ |
@@ -187,7 +198,9 @@ struct zilog_layout { | |||
187 | #define SNRZI 0xe0 /* Set NRZI mode */ | 198 | #define SNRZI 0xe0 /* Set NRZI mode */ |
188 | 199 | ||
189 | /* Write Register 15 (external/status interrupt control) */ | 200 | /* Write Register 15 (external/status interrupt control) */ |
201 | #define WR7pEN 1 /* WR7' Enable (ESCC only) */ | ||
190 | #define ZCIE 2 /* Zero count IE */ | 202 | #define ZCIE 2 /* Zero count IE */ |
203 | #define FIFOEN 4 /* FIFO Enable (ESCC only) */ | ||
191 | #define DCDIE 8 /* DCD IE */ | 204 | #define DCDIE 8 /* DCD IE */ |
192 | #define SYNCIE 0x10 /* Sync/hunt IE */ | 205 | #define SYNCIE 0x10 /* Sync/hunt IE */ |
193 | #define CTSIE 0x20 /* CTS IE */ | 206 | #define CTSIE 0x20 /* CTS IE */ |
@@ -241,6 +254,10 @@ struct zilog_layout { | |||
241 | #define CHATxIP 0x10 /* Channel A Tx IP */ | 254 | #define CHATxIP 0x10 /* Channel A Tx IP */ |
242 | #define CHARxIP 0x20 /* Channel A Rx IP */ | 255 | #define CHARxIP 0x20 /* Channel A Rx IP */ |
243 | 256 | ||
257 | /* Read Register 6 (LSB frame byte count [Not on NMOS]) */ | ||
258 | |||
259 | /* Read Register 7 (MSB frame byte count and FIFO status [Not on NMOS]) */ | ||
260 | |||
244 | /* Read Register 8 (receive data register) */ | 261 | /* Read Register 8 (receive data register) */ |
245 | 262 | ||
246 | /* Read Register 10 (misc status bits) */ | 263 | /* Read Register 10 (misc status bits) */ |
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 07c587ec71be..5e3f748f2693 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -6,6 +6,7 @@ | |||
6 | # fully appropriate there, so it'd need some thought to do well. | 6 | # fully appropriate there, so it'd need some thought to do well. |
7 | # | 7 | # |
8 | menu "SPI support" | 8 | menu "SPI support" |
9 | depends on HAS_IOMEM | ||
9 | 10 | ||
10 | config SPI | 11 | config SPI |
11 | bool "SPI support" | 12 | bool "SPI support" |
@@ -106,6 +107,13 @@ config SPI_IMX | |||
106 | This enables using the Freescale iMX SPI controller in master | 107 | This enables using the Freescale iMX SPI controller in master |
107 | mode. | 108 | mode. |
108 | 109 | ||
110 | config SPI_MPC52xx_PSC | ||
111 | tristate "Freescale MPC52xx PSC SPI controller" | ||
112 | depends on SPI_MASTER && PPC_MPC52xx && EXPERIMENTAL | ||
113 | help | ||
114 | This enables using the Freescale MPC52xx Programmable Serial | ||
115 | Controller in master SPI mode. | ||
116 | |||
109 | config SPI_MPC83xx | 117 | config SPI_MPC83xx |
110 | tristate "Freescale MPC83xx SPI controller" | 118 | tristate "Freescale MPC83xx SPI controller" |
111 | depends on SPI_MASTER && PPC_83xx && EXPERIMENTAL | 119 | depends on SPI_MASTER && PPC_83xx && EXPERIMENTAL |
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 624b6363f490..5788d867de84 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile | |||
@@ -19,6 +19,7 @@ obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o | |||
19 | obj-$(CONFIG_SPI_IMX) += spi_imx.o | 19 | obj-$(CONFIG_SPI_IMX) += spi_imx.o |
20 | obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o | 20 | obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o |
21 | obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o | 21 | obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o |
22 | obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o | ||
22 | obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o | 23 | obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o |
23 | obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o | 24 | obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o |
24 | obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o | 25 | obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o |
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c new file mode 100644 index 000000000000..052359fc41ee --- /dev/null +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
@@ -0,0 +1,654 @@ | |||
1 | /* | ||
2 | * MPC52xx SPC in SPI mode driver. | ||
3 | * | ||
4 | * Maintainer: Dragos Carp | ||
5 | * | ||
6 | * Copyright (C) 2006 TOPTICA Photonics AG. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | |||
19 | #if defined(CONFIG_PPC_MERGE) | ||
20 | #include <asm/of_platform.h> | ||
21 | #else | ||
22 | #include <linux/platform_device.h> | ||
23 | #endif | ||
24 | |||
25 | #include <linux/workqueue.h> | ||
26 | #include <linux/completion.h> | ||
27 | #include <linux/io.h> | ||
28 | #include <linux/delay.h> | ||
29 | #include <linux/spi/spi.h> | ||
30 | #include <linux/fsl_devices.h> | ||
31 | |||
32 | #include <asm/mpc52xx.h> | ||
33 | #include <asm/mpc52xx_psc.h> | ||
34 | |||
35 | #define MCLK 20000000 /* PSC port MClk in hz */ | ||
36 | |||
37 | struct mpc52xx_psc_spi { | ||
38 | /* fsl_spi_platform data */ | ||
39 | void (*activate_cs)(u8, u8); | ||
40 | void (*deactivate_cs)(u8, u8); | ||
41 | u32 sysclk; | ||
42 | |||
43 | /* driver internal data */ | ||
44 | struct mpc52xx_psc __iomem *psc; | ||
45 | unsigned int irq; | ||
46 | u8 bits_per_word; | ||
47 | u8 busy; | ||
48 | |||
49 | struct workqueue_struct *workqueue; | ||
50 | struct work_struct work; | ||
51 | |||
52 | struct list_head queue; | ||
53 | spinlock_t lock; | ||
54 | |||
55 | struct completion done; | ||
56 | }; | ||
57 | |||
58 | /* controller state */ | ||
59 | struct mpc52xx_psc_spi_cs { | ||
60 | int bits_per_word; | ||
61 | int speed_hz; | ||
62 | }; | ||
63 | |||
64 | /* set clock freq, clock ramp, bits per work | ||
65 | * if t is NULL then reset the values to the default values | ||
66 | */ | ||
67 | static int mpc52xx_psc_spi_transfer_setup(struct spi_device *spi, | ||
68 | struct spi_transfer *t) | ||
69 | { | ||
70 | struct mpc52xx_psc_spi_cs *cs = spi->controller_state; | ||
71 | |||
72 | cs->speed_hz = (t && t->speed_hz) | ||
73 | ? t->speed_hz : spi->max_speed_hz; | ||
74 | cs->bits_per_word = (t && t->bits_per_word) | ||
75 | ? t->bits_per_word : spi->bits_per_word; | ||
76 | cs->bits_per_word = ((cs->bits_per_word + 7) / 8) * 8; | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi) | ||
81 | { | ||
82 | struct mpc52xx_psc_spi_cs *cs = spi->controller_state; | ||
83 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
84 | struct mpc52xx_psc __iomem *psc = mps->psc; | ||
85 | u32 sicr; | ||
86 | u16 ccr; | ||
87 | |||
88 | sicr = in_be32(&psc->sicr); | ||
89 | |||
90 | /* Set clock phase and polarity */ | ||
91 | if (spi->mode & SPI_CPHA) | ||
92 | sicr |= 0x00001000; | ||
93 | else | ||
94 | sicr &= ~0x00001000; | ||
95 | if (spi->mode & SPI_CPOL) | ||
96 | sicr |= 0x00002000; | ||
97 | else | ||
98 | sicr &= ~0x00002000; | ||
99 | |||
100 | if (spi->mode & SPI_LSB_FIRST) | ||
101 | sicr |= 0x10000000; | ||
102 | else | ||
103 | sicr &= ~0x10000000; | ||
104 | out_be32(&psc->sicr, sicr); | ||
105 | |||
106 | /* Set clock frequency and bits per word | ||
107 | * Because psc->ccr is defined as 16bit register instead of 32bit | ||
108 | * just set the lower byte of BitClkDiv | ||
109 | */ | ||
110 | ccr = in_be16(&psc->ccr); | ||
111 | ccr &= 0xFF00; | ||
112 | if (cs->speed_hz) | ||
113 | ccr |= (MCLK / cs->speed_hz - 1) & 0xFF; | ||
114 | else /* by default SPI Clk 1MHz */ | ||
115 | ccr |= (MCLK / 1000000 - 1) & 0xFF; | ||
116 | out_be16(&psc->ccr, ccr); | ||
117 | mps->bits_per_word = cs->bits_per_word; | ||
118 | |||
119 | if (mps->activate_cs) | ||
120 | mps->activate_cs(spi->chip_select, | ||
121 | (spi->mode & SPI_CS_HIGH) ? 1 : 0); | ||
122 | } | ||
123 | |||
124 | static void mpc52xx_psc_spi_deactivate_cs(struct spi_device *spi) | ||
125 | { | ||
126 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
127 | |||
128 | if (mps->deactivate_cs) | ||
129 | mps->deactivate_cs(spi->chip_select, | ||
130 | (spi->mode & SPI_CS_HIGH) ? 1 : 0); | ||
131 | } | ||
132 | |||
133 | #define MPC52xx_PSC_BUFSIZE (MPC52xx_PSC_RFNUM_MASK + 1) | ||
134 | /* wake up when 80% fifo full */ | ||
135 | #define MPC52xx_PSC_RFALARM (MPC52xx_PSC_BUFSIZE * 20 / 100) | ||
136 | |||
137 | static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi, | ||
138 | struct spi_transfer *t) | ||
139 | { | ||
140 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
141 | struct mpc52xx_psc __iomem *psc = mps->psc; | ||
142 | unsigned rb = 0; /* number of bytes receieved */ | ||
143 | unsigned sb = 0; /* number of bytes sent */ | ||
144 | unsigned char *rx_buf = (unsigned char *)t->rx_buf; | ||
145 | unsigned char *tx_buf = (unsigned char *)t->tx_buf; | ||
146 | unsigned rfalarm; | ||
147 | unsigned send_at_once = MPC52xx_PSC_BUFSIZE; | ||
148 | unsigned recv_at_once; | ||
149 | unsigned bpw = mps->bits_per_word / 8; | ||
150 | |||
151 | if (!t->tx_buf && !t->rx_buf && t->len) | ||
152 | return -EINVAL; | ||
153 | |||
154 | /* enable transmiter/receiver */ | ||
155 | out_8(&psc->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE); | ||
156 | while (rb < t->len) { | ||
157 | if (t->len - rb > MPC52xx_PSC_BUFSIZE) { | ||
158 | rfalarm = MPC52xx_PSC_RFALARM; | ||
159 | } else { | ||
160 | send_at_once = t->len - sb; | ||
161 | rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb); | ||
162 | } | ||
163 | |||
164 | dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); | ||
165 | if (tx_buf) { | ||
166 | for (; send_at_once; sb++, send_at_once--) { | ||
167 | /* set EOF flag */ | ||
168 | if (mps->bits_per_word | ||
169 | && (sb + 1) % bpw == 0) | ||
170 | out_8(&psc->ircr2, 0x01); | ||
171 | out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]); | ||
172 | } | ||
173 | } else { | ||
174 | for (; send_at_once; sb++, send_at_once--) { | ||
175 | /* set EOF flag */ | ||
176 | if (mps->bits_per_word | ||
177 | && ((sb + 1) % bpw) == 0) | ||
178 | out_8(&psc->ircr2, 0x01); | ||
179 | out_8(&psc->mpc52xx_psc_buffer_8, 0); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | |||
184 | /* enable interupts and wait for wake up | ||
185 | * if just one byte is expected the Rx FIFO genererates no | ||
186 | * FFULL interrupt, so activate the RxRDY interrupt | ||
187 | */ | ||
188 | out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1); | ||
189 | if (t->len - rb == 1) { | ||
190 | out_8(&psc->mode, 0); | ||
191 | } else { | ||
192 | out_8(&psc->mode, MPC52xx_PSC_MODE_FFULL); | ||
193 | out_be16(&psc->rfalarm, rfalarm); | ||
194 | } | ||
195 | out_be16(&psc->mpc52xx_psc_imr, MPC52xx_PSC_IMR_RXRDY); | ||
196 | wait_for_completion(&mps->done); | ||
197 | recv_at_once = in_be16(&psc->rfnum); | ||
198 | dev_dbg(&spi->dev, "%d bytes received\n", recv_at_once); | ||
199 | |||
200 | send_at_once = recv_at_once; | ||
201 | if (rx_buf) { | ||
202 | for (; recv_at_once; rb++, recv_at_once--) | ||
203 | rx_buf[rb] = in_8(&psc->mpc52xx_psc_buffer_8); | ||
204 | } else { | ||
205 | for (; recv_at_once; rb++, recv_at_once--) | ||
206 | in_8(&psc->mpc52xx_psc_buffer_8); | ||
207 | } | ||
208 | } | ||
209 | /* disable transmiter/receiver */ | ||
210 | out_8(&psc->command, MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE); | ||
211 | |||
212 | return 0; | ||
213 | } | ||
214 | |||
215 | static void mpc52xx_psc_spi_work(struct work_struct *work) | ||
216 | { | ||
217 | struct mpc52xx_psc_spi *mps = | ||
218 | container_of(work, struct mpc52xx_psc_spi, work); | ||
219 | |||
220 | spin_lock_irq(&mps->lock); | ||
221 | mps->busy = 1; | ||
222 | while (!list_empty(&mps->queue)) { | ||
223 | struct spi_message *m; | ||
224 | struct spi_device *spi; | ||
225 | struct spi_transfer *t = NULL; | ||
226 | unsigned cs_change; | ||
227 | int status; | ||
228 | |||
229 | m = container_of(mps->queue.next, struct spi_message, queue); | ||
230 | list_del_init(&m->queue); | ||
231 | spin_unlock_irq(&mps->lock); | ||
232 | |||
233 | spi = m->spi; | ||
234 | cs_change = 1; | ||
235 | status = 0; | ||
236 | list_for_each_entry (t, &m->transfers, transfer_list) { | ||
237 | if (t->bits_per_word || t->speed_hz) { | ||
238 | status = mpc52xx_psc_spi_transfer_setup(spi, t); | ||
239 | if (status < 0) | ||
240 | break; | ||
241 | } | ||
242 | |||
243 | if (cs_change) | ||
244 | mpc52xx_psc_spi_activate_cs(spi); | ||
245 | cs_change = t->cs_change; | ||
246 | |||
247 | status = mpc52xx_psc_spi_transfer_rxtx(spi, t); | ||
248 | if (status) | ||
249 | break; | ||
250 | m->actual_length += t->len; | ||
251 | |||
252 | if (t->delay_usecs) | ||
253 | udelay(t->delay_usecs); | ||
254 | |||
255 | if (cs_change) | ||
256 | mpc52xx_psc_spi_deactivate_cs(spi); | ||
257 | } | ||
258 | |||
259 | m->status = status; | ||
260 | m->complete(m->context); | ||
261 | |||
262 | if (status || !cs_change) | ||
263 | mpc52xx_psc_spi_deactivate_cs(spi); | ||
264 | |||
265 | mpc52xx_psc_spi_transfer_setup(spi, NULL); | ||
266 | |||
267 | spin_lock_irq(&mps->lock); | ||
268 | } | ||
269 | mps->busy = 0; | ||
270 | spin_unlock_irq(&mps->lock); | ||
271 | } | ||
272 | |||
273 | static int mpc52xx_psc_spi_setup(struct spi_device *spi) | ||
274 | { | ||
275 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
276 | struct mpc52xx_psc_spi_cs *cs = spi->controller_state; | ||
277 | unsigned long flags; | ||
278 | |||
279 | if (spi->bits_per_word%8) | ||
280 | return -EINVAL; | ||
281 | |||
282 | if (!cs) { | ||
283 | cs = kzalloc(sizeof *cs, GFP_KERNEL); | ||
284 | if (!cs) | ||
285 | return -ENOMEM; | ||
286 | spi->controller_state = cs; | ||
287 | } | ||
288 | |||
289 | cs->bits_per_word = spi->bits_per_word; | ||
290 | cs->speed_hz = spi->max_speed_hz; | ||
291 | |||
292 | spin_lock_irqsave(&mps->lock, flags); | ||
293 | if (!mps->busy) | ||
294 | mpc52xx_psc_spi_deactivate_cs(spi); | ||
295 | spin_unlock_irqrestore(&mps->lock, flags); | ||
296 | |||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static int mpc52xx_psc_spi_transfer(struct spi_device *spi, | ||
301 | struct spi_message *m) | ||
302 | { | ||
303 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | ||
304 | unsigned long flags; | ||
305 | |||
306 | m->actual_length = 0; | ||
307 | m->status = -EINPROGRESS; | ||
308 | |||
309 | spin_lock_irqsave(&mps->lock, flags); | ||
310 | list_add_tail(&m->queue, &mps->queue); | ||
311 | queue_work(mps->workqueue, &mps->work); | ||
312 | spin_unlock_irqrestore(&mps->lock, flags); | ||
313 | |||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | static void mpc52xx_psc_spi_cleanup(struct spi_device *spi) | ||
318 | { | ||
319 | kfree(spi->controller_state); | ||
320 | } | ||
321 | |||
322 | static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) | ||
323 | { | ||
324 | struct mpc52xx_cdm __iomem *cdm; | ||
325 | struct mpc52xx_gpio __iomem *gpio; | ||
326 | struct mpc52xx_psc __iomem *psc = mps->psc; | ||
327 | u32 ul; | ||
328 | u32 mclken_div; | ||
329 | int ret = 0; | ||
330 | |||
331 | #if defined(CONFIG_PPC_MERGE) | ||
332 | cdm = mpc52xx_find_and_map("mpc52xx-cdm"); | ||
333 | gpio = mpc52xx_find_and_map("mpc52xx-gpio"); | ||
334 | #else | ||
335 | cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE); | ||
336 | gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE); | ||
337 | #endif | ||
338 | if (!cdm || !gpio) { | ||
339 | printk(KERN_ERR "Error mapping CDM/GPIO\n"); | ||
340 | ret = -EFAULT; | ||
341 | goto unmap_regs; | ||
342 | } | ||
343 | |||
344 | /* default sysclk is 512MHz */ | ||
345 | mclken_div = 0x8000 | | ||
346 | (((mps->sysclk ? mps->sysclk : 512000000) / MCLK) & 0x1FF); | ||
347 | |||
348 | switch (psc_id) { | ||
349 | case 1: | ||
350 | ul = in_be32(&gpio->port_config); | ||
351 | ul &= 0xFFFFFFF8; | ||
352 | ul |= 0x00000006; | ||
353 | out_be32(&gpio->port_config, ul); | ||
354 | out_be16(&cdm->mclken_div_psc1, mclken_div); | ||
355 | ul = in_be32(&cdm->clk_enables); | ||
356 | ul |= 0x00000020; | ||
357 | out_be32(&cdm->clk_enables, ul); | ||
358 | break; | ||
359 | case 2: | ||
360 | ul = in_be32(&gpio->port_config); | ||
361 | ul &= 0xFFFFFF8F; | ||
362 | ul |= 0x00000060; | ||
363 | out_be32(&gpio->port_config, ul); | ||
364 | out_be16(&cdm->mclken_div_psc2, mclken_div); | ||
365 | ul = in_be32(&cdm->clk_enables); | ||
366 | ul |= 0x00000040; | ||
367 | out_be32(&cdm->clk_enables, ul); | ||
368 | break; | ||
369 | case 3: | ||
370 | ul = in_be32(&gpio->port_config); | ||
371 | ul &= 0xFFFFF0FF; | ||
372 | ul |= 0x00000600; | ||
373 | out_be32(&gpio->port_config, ul); | ||
374 | out_be16(&cdm->mclken_div_psc3, mclken_div); | ||
375 | ul = in_be32(&cdm->clk_enables); | ||
376 | ul |= 0x00000080; | ||
377 | out_be32(&cdm->clk_enables, ul); | ||
378 | break; | ||
379 | case 6: | ||
380 | ul = in_be32(&gpio->port_config); | ||
381 | ul &= 0xFF8FFFFF; | ||
382 | ul |= 0x00700000; | ||
383 | out_be32(&gpio->port_config, ul); | ||
384 | out_be16(&cdm->mclken_div_psc6, mclken_div); | ||
385 | ul = in_be32(&cdm->clk_enables); | ||
386 | ul |= 0x00000010; | ||
387 | out_be32(&cdm->clk_enables, ul); | ||
388 | break; | ||
389 | default: | ||
390 | ret = -EINVAL; | ||
391 | goto unmap_regs; | ||
392 | } | ||
393 | |||
394 | /* Reset the PSC into a known state */ | ||
395 | out_8(&psc->command, MPC52xx_PSC_RST_RX); | ||
396 | out_8(&psc->command, MPC52xx_PSC_RST_TX); | ||
397 | out_8(&psc->command, MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE); | ||
398 | |||
399 | /* Disable interrupts, interrupts are based on alarm level */ | ||
400 | out_be16(&psc->mpc52xx_psc_imr, 0); | ||
401 | out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1); | ||
402 | out_8(&psc->rfcntl, 0); | ||
403 | out_8(&psc->mode, MPC52xx_PSC_MODE_FFULL); | ||
404 | |||
405 | /* Configure 8bit codec mode as a SPI master and use EOF flags */ | ||
406 | /* SICR_SIM_CODEC8|SICR_GENCLK|SICR_SPI|SICR_MSTR|SICR_USEEOF */ | ||
407 | out_be32(&psc->sicr, 0x0180C800); | ||
408 | out_be16(&psc->ccr, 0x070F); /* by default SPI Clk 1MHz */ | ||
409 | |||
410 | /* Set 2ms DTL delay */ | ||
411 | out_8(&psc->ctur, 0x00); | ||
412 | out_8(&psc->ctlr, 0x84); | ||
413 | |||
414 | mps->bits_per_word = 8; | ||
415 | |||
416 | unmap_regs: | ||
417 | if (cdm) | ||
418 | iounmap(cdm); | ||
419 | if (gpio) | ||
420 | iounmap(gpio); | ||
421 | |||
422 | return ret; | ||
423 | } | ||
424 | |||
425 | static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) | ||
426 | { | ||
427 | struct mpc52xx_psc_spi *mps = (struct mpc52xx_psc_spi *)dev_id; | ||
428 | struct mpc52xx_psc __iomem *psc = mps->psc; | ||
429 | |||
430 | /* disable interrupt and wake up the work queue */ | ||
431 | if (in_be16(&psc->mpc52xx_psc_isr) & MPC52xx_PSC_IMR_RXRDY) { | ||
432 | out_be16(&psc->mpc52xx_psc_imr, 0); | ||
433 | complete(&mps->done); | ||
434 | return IRQ_HANDLED; | ||
435 | } | ||
436 | return IRQ_NONE; | ||
437 | } | ||
438 | |||
439 | /* bus_num is used only for the case dev->platform_data == NULL */ | ||
440 | static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | ||
441 | u32 size, unsigned int irq, s16 bus_num) | ||
442 | { | ||
443 | struct fsl_spi_platform_data *pdata = dev->platform_data; | ||
444 | struct mpc52xx_psc_spi *mps; | ||
445 | struct spi_master *master; | ||
446 | int ret; | ||
447 | |||
448 | if (pdata == NULL) | ||
449 | return -ENODEV; | ||
450 | |||
451 | master = spi_alloc_master(dev, sizeof *mps); | ||
452 | if (master == NULL) | ||
453 | return -ENOMEM; | ||
454 | |||
455 | dev_set_drvdata(dev, master); | ||
456 | mps = spi_master_get_devdata(master); | ||
457 | |||
458 | mps->irq = irq; | ||
459 | if (pdata == NULL) { | ||
460 | dev_warn(dev, "probe called without platform data, no " | ||
461 | "(de)activate_cs function will be called\n"); | ||
462 | mps->activate_cs = NULL; | ||
463 | mps->deactivate_cs = NULL; | ||
464 | mps->sysclk = 0; | ||
465 | master->bus_num = bus_num; | ||
466 | master->num_chipselect = 255; | ||
467 | } else { | ||
468 | mps->activate_cs = pdata->activate_cs; | ||
469 | mps->deactivate_cs = pdata->deactivate_cs; | ||
470 | mps->sysclk = pdata->sysclk; | ||
471 | master->bus_num = pdata->bus_num; | ||
472 | master->num_chipselect = pdata->max_chipselect; | ||
473 | } | ||
474 | master->setup = mpc52xx_psc_spi_setup; | ||
475 | master->transfer = mpc52xx_psc_spi_transfer; | ||
476 | master->cleanup = mpc52xx_psc_spi_cleanup; | ||
477 | |||
478 | mps->psc = ioremap(regaddr, size); | ||
479 | if (!mps->psc) { | ||
480 | dev_err(dev, "could not ioremap I/O port range\n"); | ||
481 | ret = -EFAULT; | ||
482 | goto free_master; | ||
483 | } | ||
484 | |||
485 | ret = request_irq(mps->irq, mpc52xx_psc_spi_isr, 0, "mpc52xx-psc-spi", | ||
486 | mps); | ||
487 | if (ret) | ||
488 | goto free_master; | ||
489 | |||
490 | ret = mpc52xx_psc_spi_port_config(master->bus_num, mps); | ||
491 | if (ret < 0) | ||
492 | goto free_irq; | ||
493 | |||
494 | spin_lock_init(&mps->lock); | ||
495 | init_completion(&mps->done); | ||
496 | INIT_WORK(&mps->work, mpc52xx_psc_spi_work); | ||
497 | INIT_LIST_HEAD(&mps->queue); | ||
498 | |||
499 | mps->workqueue = create_singlethread_workqueue( | ||
500 | master->cdev.dev->bus_id); | ||
501 | if (mps->workqueue == NULL) { | ||
502 | ret = -EBUSY; | ||
503 | goto free_irq; | ||
504 | } | ||
505 | |||
506 | ret = spi_register_master(master); | ||
507 | if (ret < 0) | ||
508 | goto unreg_master; | ||
509 | |||
510 | return ret; | ||
511 | |||
512 | unreg_master: | ||
513 | destroy_workqueue(mps->workqueue); | ||
514 | free_irq: | ||
515 | free_irq(mps->irq, mps); | ||
516 | free_master: | ||
517 | if (mps->psc) | ||
518 | iounmap(mps->psc); | ||
519 | spi_master_put(master); | ||
520 | |||
521 | return ret; | ||
522 | } | ||
523 | |||
524 | static int __exit mpc52xx_psc_spi_do_remove(struct device *dev) | ||
525 | { | ||
526 | struct spi_master *master = dev_get_drvdata(dev); | ||
527 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(master); | ||
528 | |||
529 | flush_workqueue(mps->workqueue); | ||
530 | destroy_workqueue(mps->workqueue); | ||
531 | spi_unregister_master(master); | ||
532 | free_irq(mps->irq, mps); | ||
533 | if (mps->psc) | ||
534 | iounmap(mps->psc); | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
539 | #if !defined(CONFIG_PPC_MERGE) | ||
540 | static int __init mpc52xx_psc_spi_probe(struct platform_device *dev) | ||
541 | { | ||
542 | switch(dev->id) { | ||
543 | case 1: | ||
544 | case 2: | ||
545 | case 3: | ||
546 | case 6: | ||
547 | return mpc52xx_psc_spi_do_probe(&dev->dev, | ||
548 | MPC52xx_PA(MPC52xx_PSCx_OFFSET(dev->id)), | ||
549 | MPC52xx_PSC_SIZE, platform_get_irq(dev, 0), dev->id); | ||
550 | default: | ||
551 | return -EINVAL; | ||
552 | } | ||
553 | } | ||
554 | |||
555 | static int __exit mpc52xx_psc_spi_remove(struct platform_device *dev) | ||
556 | { | ||
557 | return mpc52xx_psc_spi_do_remove(&dev->dev); | ||
558 | } | ||
559 | |||
560 | static struct platform_driver mpc52xx_psc_spi_platform_driver = { | ||
561 | .remove = __exit_p(mpc52xx_psc_spi_remove), | ||
562 | .driver = { | ||
563 | .name = "mpc52xx-psc-spi", | ||
564 | .owner = THIS_MODULE, | ||
565 | }, | ||
566 | }; | ||
567 | |||
568 | static int __init mpc52xx_psc_spi_init(void) | ||
569 | { | ||
570 | return platform_driver_probe(&mpc52xx_psc_spi_platform_driver, | ||
571 | mpc52xx_psc_spi_probe); | ||
572 | } | ||
573 | module_init(mpc52xx_psc_spi_init); | ||
574 | |||
575 | static void __exit mpc52xx_psc_spi_exit(void) | ||
576 | { | ||
577 | platform_driver_unregister(&mpc52xx_psc_spi_platform_driver); | ||
578 | } | ||
579 | module_exit(mpc52xx_psc_spi_exit); | ||
580 | |||
581 | #else /* defined(CONFIG_PPC_MERGE) */ | ||
582 | |||
583 | static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | ||
584 | const struct of_device_id *match) | ||
585 | { | ||
586 | const u32 *regaddr_p; | ||
587 | u64 regaddr64, size64; | ||
588 | s16 id = -1; | ||
589 | |||
590 | regaddr_p = of_get_address(op->node, 0, &size64, NULL); | ||
591 | if (!regaddr_p) { | ||
592 | printk(KERN_ERR "Invalid PSC address\n"); | ||
593 | return -EINVAL; | ||
594 | } | ||
595 | regaddr64 = of_translate_address(op->node, regaddr_p); | ||
596 | |||
597 | if (op->dev.platform_data == NULL) { | ||
598 | struct device_node *np; | ||
599 | int i = 0; | ||
600 | |||
601 | for_each_node_by_type(np, "spi") { | ||
602 | if (of_find_device_by_node(np) == op) { | ||
603 | id = i; | ||
604 | break; | ||
605 | } | ||
606 | i++; | ||
607 | } | ||
608 | } | ||
609 | |||
610 | return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, | ||
611 | irq_of_parse_and_map(op->node, 0), id); | ||
612 | } | ||
613 | |||
614 | static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) | ||
615 | { | ||
616 | return mpc52xx_psc_spi_do_remove(&op->dev); | ||
617 | } | ||
618 | |||
619 | static struct of_device_id mpc52xx_psc_spi_of_match[] = { | ||
620 | { .type = "spi", .compatible = "mpc52xx-psc-spi", }, | ||
621 | {}, | ||
622 | }; | ||
623 | |||
624 | MODULE_DEVICE_TABLE(of, mpc52xx_psc_spi_of_match); | ||
625 | |||
626 | static struct of_platform_driver mpc52xx_psc_spi_of_driver = { | ||
627 | .owner = THIS_MODULE, | ||
628 | .name = "mpc52xx-psc-spi", | ||
629 | .match_table = mpc52xx_psc_spi_of_match, | ||
630 | .probe = mpc52xx_psc_spi_of_probe, | ||
631 | .remove = __exit_p(mpc52xx_psc_spi_of_remove), | ||
632 | .driver = { | ||
633 | .name = "mpc52xx-psc-spi", | ||
634 | .owner = THIS_MODULE, | ||
635 | }, | ||
636 | }; | ||
637 | |||
638 | static int __init mpc52xx_psc_spi_init(void) | ||
639 | { | ||
640 | return of_register_platform_driver(&mpc52xx_psc_spi_of_driver); | ||
641 | } | ||
642 | module_init(mpc52xx_psc_spi_init); | ||
643 | |||
644 | static void __exit mpc52xx_psc_spi_exit(void) | ||
645 | { | ||
646 | of_unregister_platform_driver(&mpc52xx_psc_spi_of_driver); | ||
647 | } | ||
648 | module_exit(mpc52xx_psc_spi_exit); | ||
649 | |||
650 | #endif /* defined(CONFIG_PPC_MERGE) */ | ||
651 | |||
652 | MODULE_AUTHOR("Dragos Carp"); | ||
653 | MODULE_DESCRIPTION("MPC52xx PSC SPI Driver"); | ||
654 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/telephony/Kconfig b/drivers/telephony/Kconfig index 7625b1816baf..dd1d6a53f3c0 100644 --- a/drivers/telephony/Kconfig +++ b/drivers/telephony/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Telephony Support" | 5 | menu "Telephony Support" |
6 | depends on HAS_IOMEM | ||
6 | 7 | ||
7 | config PHONE | 8 | config PHONE |
8 | tristate "Linux telephony support" | 9 | tristate "Linux telephony support" |
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 278a22cea5bf..15499b7e33f4 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "USB support" | 5 | menu "USB support" |
6 | depends on HAS_IOMEM | ||
6 | 7 | ||
7 | # Host-side USB depends on having a host controller | 8 | # Host-side USB depends on having a host controller |
8 | # NOTE: dummy_hcd is always an option, but it's ignored here ... | 9 | # NOTE: dummy_hcd is always an option, but it's ignored here ... |
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 8065f2b53701..f771a7cae9ec 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -210,7 +210,7 @@ config USB_OTG | |||
210 | 210 | ||
211 | config USB_GADGET_AT91 | 211 | config USB_GADGET_AT91 |
212 | boolean "AT91 USB Device Port" | 212 | boolean "AT91 USB Device Port" |
213 | depends on ARCH_AT91 | 213 | depends on ARCH_AT91 && !ARCH_AT91SAM9RL |
214 | select USB_GADGET_SELECTED | 214 | select USB_GADGET_SELECTED |
215 | help | 215 | help |
216 | Many Atmel AT91 processors (such as the AT91RM2000) have a | 216 | Many Atmel AT91 processors (such as the AT91RM2000) have a |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 9a256d2ff9dc..4d7485fa553f 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Graphics support" | 5 | menu "Graphics support" |
6 | depends on HAS_IOMEM | ||
6 | 7 | ||
7 | source "drivers/video/backlight/Kconfig" | 8 | source "drivers/video/backlight/Kconfig" |
8 | source "drivers/video/display/Kconfig" | 9 | source "drivers/video/display/Kconfig" |
@@ -747,6 +748,22 @@ config FB_S1D13XXX | |||
747 | working with S1D13806). Product specs at | 748 | working with S1D13806). Product specs at |
748 | <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> | 749 | <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> |
749 | 750 | ||
751 | config FB_ATMEL | ||
752 | tristate "AT91/AT32 LCD Controller support" | ||
753 | depends on FB && (ARCH_AT91SAM9261 || ARCH_AT91SAM9263 || AVR32) | ||
754 | select FB_CFB_FILLRECT | ||
755 | select FB_CFB_COPYAREA | ||
756 | select FB_CFB_IMAGEBLIT | ||
757 | help | ||
758 | This enables support for the AT91/AT32 LCD Controller. | ||
759 | |||
760 | config FB_INTSRAM | ||
761 | bool "Frame Buffer in internal SRAM" | ||
762 | depends on FB_ATMEL && ARCH_AT91SAM9261 | ||
763 | help | ||
764 | Say Y if you want to map Frame Buffer in internal SRAM. Say N if you want | ||
765 | to let frame buffer in external SDRAM. | ||
766 | |||
750 | config FB_NVIDIA | 767 | config FB_NVIDIA |
751 | tristate "nVidia Framebuffer Support" | 768 | tristate "nVidia Framebuffer Support" |
752 | depends on FB && PCI | 769 | depends on FB && PCI |
@@ -779,6 +796,15 @@ config FB_NVIDIA_I2C | |||
779 | independently validate video mode parameters, you should say Y | 796 | independently validate video mode parameters, you should say Y |
780 | here. | 797 | here. |
781 | 798 | ||
799 | config FB_NVIDIA_DEBUG | ||
800 | bool "Lots of debug output" | ||
801 | depends on FB_NVIDIA | ||
802 | default n | ||
803 | help | ||
804 | Say Y here if you want the nVidia driver to output all sorts | ||
805 | of debugging information to provide to the maintainer when | ||
806 | something goes wrong. | ||
807 | |||
782 | config FB_NVIDIA_BACKLIGHT | 808 | config FB_NVIDIA_BACKLIGHT |
783 | bool "Support for backlight control" | 809 | bool "Support for backlight control" |
784 | depends on FB_NVIDIA | 810 | depends on FB_NVIDIA |
@@ -818,7 +844,7 @@ config FB_RIVA_I2C | |||
818 | here. | 844 | here. |
819 | 845 | ||
820 | config FB_RIVA_DEBUG | 846 | config FB_RIVA_DEBUG |
821 | bool "Lots of debug output from Riva(nVidia) driver" | 847 | bool "Lots of debug output" |
822 | depends on FB_RIVA | 848 | depends on FB_RIVA |
823 | default n | 849 | default n |
824 | help | 850 | help |
@@ -1430,8 +1456,11 @@ config FB_ARK | |||
1430 | and ICS 5342 RAMDAC. | 1456 | and ICS 5342 RAMDAC. |
1431 | 1457 | ||
1432 | config FB_PM3 | 1458 | config FB_PM3 |
1433 | tristate "Permedia3 support" | 1459 | tristate "Permedia3 support (EXPERIMENTAL)" |
1434 | depends on FB && PCI && BROKEN | 1460 | depends on FB && PCI && EXPERIMENTAL |
1461 | select FB_CFB_FILLRECT | ||
1462 | select FB_CFB_COPYAREA | ||
1463 | select FB_CFB_IMAGEBLIT | ||
1435 | help | 1464 | help |
1436 | This is the frame buffer device driver for the 3DLabs Permedia3 | 1465 | This is the frame buffer device driver for the 3DLabs Permedia3 |
1437 | chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 & | 1466 | chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 & |
@@ -1506,7 +1535,7 @@ config FB_LEO | |||
1506 | 1535 | ||
1507 | config FB_XVR500 | 1536 | config FB_XVR500 |
1508 | bool "Sun XVR-500 3DLABS Wildcat support" | 1537 | bool "Sun XVR-500 3DLABS Wildcat support" |
1509 | depends on FB && PCI && SPARC64 | 1538 | depends on (FB = y) && PCI && SPARC64 |
1510 | select FB_CFB_FILLRECT | 1539 | select FB_CFB_FILLRECT |
1511 | select FB_CFB_COPYAREA | 1540 | select FB_CFB_COPYAREA |
1512 | select FB_CFB_IMAGEBLIT | 1541 | select FB_CFB_IMAGEBLIT |
@@ -1519,7 +1548,7 @@ config FB_XVR500 | |||
1519 | 1548 | ||
1520 | config FB_XVR2500 | 1549 | config FB_XVR2500 |
1521 | bool "Sun XVR-2500 3DLABS Wildcat support" | 1550 | bool "Sun XVR-2500 3DLABS Wildcat support" |
1522 | depends on FB && PCI && SPARC64 | 1551 | depends on (FB = y) && PCI && SPARC64 |
1523 | select FB_CFB_FILLRECT | 1552 | select FB_CFB_FILLRECT |
1524 | select FB_CFB_COPYAREA | 1553 | select FB_CFB_COPYAREA |
1525 | select FB_CFB_IMAGEBLIT | 1554 | select FB_CFB_IMAGEBLIT |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 0b70567458fb..bd8b05229500 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -87,6 +87,7 @@ obj-$(CONFIG_FB_G364) += g364fb.o | |||
87 | obj-$(CONFIG_FB_SA1100) += sa1100fb.o | 87 | obj-$(CONFIG_FB_SA1100) += sa1100fb.o |
88 | obj-$(CONFIG_FB_HIT) += hitfb.o | 88 | obj-$(CONFIG_FB_HIT) += hitfb.o |
89 | obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o | 89 | obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o |
90 | obj-$(CONFIG_FB_ATMEL) += atmel_lcdfb.o | ||
90 | obj-$(CONFIG_FB_PVR2) += pvr2fb.o | 91 | obj-$(CONFIG_FB_PVR2) += pvr2fb.o |
91 | obj-$(CONFIG_FB_VOODOO1) += sstfb.o | 92 | obj-$(CONFIG_FB_VOODOO1) += sstfb.o |
92 | obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o | 93 | obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o |
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c new file mode 100644 index 000000000000..e1d5bd0c98c4 --- /dev/null +++ b/drivers/video/atmel_lcdfb.c | |||
@@ -0,0 +1,752 @@ | |||
1 | /* | ||
2 | * Driver for AT91/AT32 LCD Controller | ||
3 | * | ||
4 | * Copyright (C) 2007 Atmel Corporation | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive for | ||
8 | * more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/platform_device.h> | ||
13 | #include <linux/dma-mapping.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/fb.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/delay.h> | ||
19 | |||
20 | #include <asm/arch/board.h> | ||
21 | #include <asm/arch/cpu.h> | ||
22 | #include <asm/arch/gpio.h> | ||
23 | |||
24 | #include <video/atmel_lcdc.h> | ||
25 | |||
26 | #define lcdc_readl(sinfo, reg) __raw_readl((sinfo)->mmio+(reg)) | ||
27 | #define lcdc_writel(sinfo, reg, val) __raw_writel((val), (sinfo)->mmio+(reg)) | ||
28 | |||
29 | /* configurable parameters */ | ||
30 | #define ATMEL_LCDC_CVAL_DEFAULT 0xc8 | ||
31 | #define ATMEL_LCDC_DMA_BURST_LEN 8 | ||
32 | |||
33 | #if defined(CONFIG_ARCH_AT91SAM9263) | ||
34 | #define ATMEL_LCDC_FIFO_SIZE 2048 | ||
35 | #else | ||
36 | #define ATMEL_LCDC_FIFO_SIZE 512 | ||
37 | #endif | ||
38 | |||
39 | #if defined(CONFIG_ARCH_AT91) | ||
40 | #define ATMEL_LCDFB_FBINFO_DEFAULT FBINFO_DEFAULT | ||
41 | |||
42 | static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo, | ||
43 | struct fb_var_screeninfo *var) | ||
44 | { | ||
45 | |||
46 | } | ||
47 | #elif defined(CONFIG_AVR32) | ||
48 | #define ATMEL_LCDFB_FBINFO_DEFAULT (FBINFO_DEFAULT \ | ||
49 | | FBINFO_PARTIAL_PAN_OK \ | ||
50 | | FBINFO_HWACCEL_XPAN \ | ||
51 | | FBINFO_HWACCEL_YPAN) | ||
52 | |||
53 | static void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo, | ||
54 | struct fb_var_screeninfo *var) | ||
55 | { | ||
56 | u32 dma2dcfg; | ||
57 | u32 pixeloff; | ||
58 | |||
59 | pixeloff = (var->xoffset * var->bits_per_pixel) & 0x1f; | ||
60 | |||
61 | dma2dcfg = ((var->xres_virtual - var->xres) * var->bits_per_pixel) / 8; | ||
62 | dma2dcfg |= pixeloff << ATMEL_LCDC_PIXELOFF_OFFSET; | ||
63 | lcdc_writel(sinfo, ATMEL_LCDC_DMA2DCFG, dma2dcfg); | ||
64 | |||
65 | /* Update configuration */ | ||
66 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, | ||
67 | lcdc_readl(sinfo, ATMEL_LCDC_DMACON) | ||
68 | | ATMEL_LCDC_DMAUPDT); | ||
69 | } | ||
70 | #endif | ||
71 | |||
72 | |||
73 | static struct fb_fix_screeninfo atmel_lcdfb_fix __initdata = { | ||
74 | .type = FB_TYPE_PACKED_PIXELS, | ||
75 | .visual = FB_VISUAL_TRUECOLOR, | ||
76 | .xpanstep = 0, | ||
77 | .ypanstep = 0, | ||
78 | .ywrapstep = 0, | ||
79 | .accel = FB_ACCEL_NONE, | ||
80 | }; | ||
81 | |||
82 | |||
83 | static void atmel_lcdfb_update_dma(struct fb_info *info, | ||
84 | struct fb_var_screeninfo *var) | ||
85 | { | ||
86 | struct atmel_lcdfb_info *sinfo = info->par; | ||
87 | struct fb_fix_screeninfo *fix = &info->fix; | ||
88 | unsigned long dma_addr; | ||
89 | |||
90 | dma_addr = (fix->smem_start + var->yoffset * fix->line_length | ||
91 | + var->xoffset * var->bits_per_pixel / 8); | ||
92 | |||
93 | dma_addr &= ~3UL; | ||
94 | |||
95 | /* Set framebuffer DMA base address and pixel offset */ | ||
96 | lcdc_writel(sinfo, ATMEL_LCDC_DMABADDR1, dma_addr); | ||
97 | |||
98 | atmel_lcdfb_update_dma2d(sinfo, var); | ||
99 | } | ||
100 | |||
101 | static inline void atmel_lcdfb_free_video_memory(struct atmel_lcdfb_info *sinfo) | ||
102 | { | ||
103 | struct fb_info *info = sinfo->info; | ||
104 | |||
105 | dma_free_writecombine(info->device, info->fix.smem_len, | ||
106 | info->screen_base, info->fix.smem_start); | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * atmel_lcdfb_alloc_video_memory - Allocate framebuffer memory | ||
111 | * @sinfo: the frame buffer to allocate memory for | ||
112 | */ | ||
113 | static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo) | ||
114 | { | ||
115 | struct fb_info *info = sinfo->info; | ||
116 | struct fb_var_screeninfo *var = &info->var; | ||
117 | |||
118 | info->fix.smem_len = (var->xres_virtual * var->yres_virtual | ||
119 | * ((var->bits_per_pixel + 7) / 8)); | ||
120 | |||
121 | info->screen_base = dma_alloc_writecombine(info->device, info->fix.smem_len, | ||
122 | (dma_addr_t *)&info->fix.smem_start, GFP_KERNEL); | ||
123 | |||
124 | if (!info->screen_base) { | ||
125 | return -ENOMEM; | ||
126 | } | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * atmel_lcdfb_check_var - Validates a var passed in. | ||
133 | * @var: frame buffer variable screen structure | ||
134 | * @info: frame buffer structure that represents a single frame buffer | ||
135 | * | ||
136 | * Checks to see if the hardware supports the state requested by | ||
137 | * var passed in. This function does not alter the hardware | ||
138 | * state!!! This means the data stored in struct fb_info and | ||
139 | * struct atmel_lcdfb_info do not change. This includes the var | ||
140 | * inside of struct fb_info. Do NOT change these. This function | ||
141 | * can be called on its own if we intent to only test a mode and | ||
142 | * not actually set it. The stuff in modedb.c is a example of | ||
143 | * this. If the var passed in is slightly off by what the | ||
144 | * hardware can support then we alter the var PASSED in to what | ||
145 | * we can do. If the hardware doesn't support mode change a | ||
146 | * -EINVAL will be returned by the upper layers. You don't need | ||
147 | * to implement this function then. If you hardware doesn't | ||
148 | * support changing the resolution then this function is not | ||
149 | * needed. In this case the driver would just provide a var that | ||
150 | * represents the static state the screen is in. | ||
151 | * | ||
152 | * Returns negative errno on error, or zero on success. | ||
153 | */ | ||
154 | static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, | ||
155 | struct fb_info *info) | ||
156 | { | ||
157 | struct device *dev = info->device; | ||
158 | struct atmel_lcdfb_info *sinfo = info->par; | ||
159 | unsigned long clk_value_khz; | ||
160 | |||
161 | clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000; | ||
162 | |||
163 | dev_dbg(dev, "%s:\n", __func__); | ||
164 | dev_dbg(dev, " resolution: %ux%u\n", var->xres, var->yres); | ||
165 | dev_dbg(dev, " pixclk: %lu KHz\n", PICOS2KHZ(var->pixclock)); | ||
166 | dev_dbg(dev, " bpp: %u\n", var->bits_per_pixel); | ||
167 | dev_dbg(dev, " clk: %lu KHz\n", clk_value_khz); | ||
168 | |||
169 | if ((PICOS2KHZ(var->pixclock) * var->bits_per_pixel / 8) > clk_value_khz) { | ||
170 | dev_err(dev, "%lu KHz pixel clock is too fast\n", PICOS2KHZ(var->pixclock)); | ||
171 | return -EINVAL; | ||
172 | } | ||
173 | |||
174 | /* Force same alignment for each line */ | ||
175 | var->xres = (var->xres + 3) & ~3UL; | ||
176 | var->xres_virtual = (var->xres_virtual + 3) & ~3UL; | ||
177 | |||
178 | var->red.msb_right = var->green.msb_right = var->blue.msb_right = 0; | ||
179 | var->transp.msb_right = 0; | ||
180 | var->transp.offset = var->transp.length = 0; | ||
181 | var->xoffset = var->yoffset = 0; | ||
182 | |||
183 | switch (var->bits_per_pixel) { | ||
184 | case 2: | ||
185 | case 4: | ||
186 | case 8: | ||
187 | var->red.offset = var->green.offset = var->blue.offset = 0; | ||
188 | var->red.length = var->green.length = var->blue.length | ||
189 | = var->bits_per_pixel; | ||
190 | break; | ||
191 | case 15: | ||
192 | case 16: | ||
193 | var->red.offset = 0; | ||
194 | var->green.offset = 5; | ||
195 | var->blue.offset = 10; | ||
196 | var->red.length = var->green.length = var->blue.length = 5; | ||
197 | break; | ||
198 | case 24: | ||
199 | case 32: | ||
200 | var->red.offset = 0; | ||
201 | var->green.offset = 8; | ||
202 | var->blue.offset = 16; | ||
203 | var->red.length = var->green.length = var->blue.length = 8; | ||
204 | break; | ||
205 | default: | ||
206 | dev_err(dev, "color depth %d not supported\n", | ||
207 | var->bits_per_pixel); | ||
208 | return -EINVAL; | ||
209 | } | ||
210 | |||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | /** | ||
215 | * atmel_lcdfb_set_par - Alters the hardware state. | ||
216 | * @info: frame buffer structure that represents a single frame buffer | ||
217 | * | ||
218 | * Using the fb_var_screeninfo in fb_info we set the resolution | ||
219 | * of the this particular framebuffer. This function alters the | ||
220 | * par AND the fb_fix_screeninfo stored in fb_info. It doesn't | ||
221 | * not alter var in fb_info since we are using that data. This | ||
222 | * means we depend on the data in var inside fb_info to be | ||
223 | * supported by the hardware. atmel_lcdfb_check_var is always called | ||
224 | * before atmel_lcdfb_set_par to ensure this. Again if you can't | ||
225 | * change the resolution you don't need this function. | ||
226 | * | ||
227 | */ | ||
228 | static int atmel_lcdfb_set_par(struct fb_info *info) | ||
229 | { | ||
230 | struct atmel_lcdfb_info *sinfo = info->par; | ||
231 | unsigned long value; | ||
232 | unsigned long clk_value_khz; | ||
233 | |||
234 | dev_dbg(info->device, "%s:\n", __func__); | ||
235 | dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n", | ||
236 | info->var.xres, info->var.yres, | ||
237 | info->var.xres_virtual, info->var.yres_virtual); | ||
238 | |||
239 | /* Turn off the LCD controller and the DMA controller */ | ||
240 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET); | ||
241 | |||
242 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); | ||
243 | |||
244 | if (info->var.bits_per_pixel <= 8) | ||
245 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
246 | else | ||
247 | info->fix.visual = FB_VISUAL_TRUECOLOR; | ||
248 | |||
249 | info->fix.line_length = info->var.xres_virtual * (info->var.bits_per_pixel / 8); | ||
250 | |||
251 | /* Re-initialize the DMA engine... */ | ||
252 | dev_dbg(info->device, " * update DMA engine\n"); | ||
253 | atmel_lcdfb_update_dma(info, &info->var); | ||
254 | |||
255 | /* ...set frame size and burst length = 8 words (?) */ | ||
256 | value = (info->var.yres * info->var.xres * info->var.bits_per_pixel) / 32; | ||
257 | value |= ((ATMEL_LCDC_DMA_BURST_LEN - 1) << ATMEL_LCDC_BLENGTH_OFFSET); | ||
258 | lcdc_writel(sinfo, ATMEL_LCDC_DMAFRMCFG, value); | ||
259 | |||
260 | /* Now, the LCDC core... */ | ||
261 | |||
262 | /* Set pixel clock */ | ||
263 | clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000; | ||
264 | |||
265 | value = clk_value_khz / PICOS2KHZ(info->var.pixclock); | ||
266 | |||
267 | if (clk_value_khz % PICOS2KHZ(info->var.pixclock)) | ||
268 | value++; | ||
269 | |||
270 | value = (value / 2) - 1; | ||
271 | |||
272 | if (value <= 0) { | ||
273 | dev_notice(info->device, "Bypassing pixel clock divider\n"); | ||
274 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS); | ||
275 | } else | ||
276 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET); | ||
277 | |||
278 | /* Initialize control register 2 */ | ||
279 | value = sinfo->default_lcdcon2; | ||
280 | |||
281 | if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) | ||
282 | value |= ATMEL_LCDC_INVLINE_INVERTED; | ||
283 | if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) | ||
284 | value |= ATMEL_LCDC_INVFRAME_INVERTED; | ||
285 | |||
286 | switch (info->var.bits_per_pixel) { | ||
287 | case 1: value |= ATMEL_LCDC_PIXELSIZE_1; break; | ||
288 | case 2: value |= ATMEL_LCDC_PIXELSIZE_2; break; | ||
289 | case 4: value |= ATMEL_LCDC_PIXELSIZE_4; break; | ||
290 | case 8: value |= ATMEL_LCDC_PIXELSIZE_8; break; | ||
291 | case 15: /* fall through */ | ||
292 | case 16: value |= ATMEL_LCDC_PIXELSIZE_16; break; | ||
293 | case 24: value |= ATMEL_LCDC_PIXELSIZE_24; break; | ||
294 | case 32: value |= ATMEL_LCDC_PIXELSIZE_32; break; | ||
295 | default: BUG(); break; | ||
296 | } | ||
297 | dev_dbg(info->device, " * LCDCON2 = %08lx\n", value); | ||
298 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON2, value); | ||
299 | |||
300 | /* Vertical timing */ | ||
301 | value = (info->var.vsync_len - 1) << ATMEL_LCDC_VPW_OFFSET; | ||
302 | value |= info->var.upper_margin << ATMEL_LCDC_VBP_OFFSET; | ||
303 | value |= info->var.lower_margin; | ||
304 | dev_dbg(info->device, " * LCDTIM1 = %08lx\n", value); | ||
305 | lcdc_writel(sinfo, ATMEL_LCDC_TIM1, value); | ||
306 | |||
307 | /* Horizontal timing */ | ||
308 | value = (info->var.right_margin - 1) << ATMEL_LCDC_HFP_OFFSET; | ||
309 | value |= (info->var.hsync_len - 1) << ATMEL_LCDC_HPW_OFFSET; | ||
310 | value |= (info->var.left_margin - 1); | ||
311 | dev_dbg(info->device, " * LCDTIM2 = %08lx\n", value); | ||
312 | lcdc_writel(sinfo, ATMEL_LCDC_TIM2, value); | ||
313 | |||
314 | /* Display size */ | ||
315 | value = (info->var.xres - 1) << ATMEL_LCDC_HOZVAL_OFFSET; | ||
316 | value |= info->var.yres - 1; | ||
317 | lcdc_writel(sinfo, ATMEL_LCDC_LCDFRMCFG, value); | ||
318 | |||
319 | /* FIFO Threshold: Use formula from data sheet */ | ||
320 | value = ATMEL_LCDC_FIFO_SIZE - (2 * ATMEL_LCDC_DMA_BURST_LEN + 3); | ||
321 | lcdc_writel(sinfo, ATMEL_LCDC_FIFO, value); | ||
322 | |||
323 | /* Toggle LCD_MODE every frame */ | ||
324 | lcdc_writel(sinfo, ATMEL_LCDC_MVAL, 0); | ||
325 | |||
326 | /* Disable all interrupts */ | ||
327 | lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL); | ||
328 | |||
329 | /* Set contrast */ | ||
330 | value = ATMEL_LCDC_PS_DIV8 | ATMEL_LCDC_POL_POSITIVE | ATMEL_LCDC_ENA_PWMENABLE; | ||
331 | lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, value); | ||
332 | lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, ATMEL_LCDC_CVAL_DEFAULT); | ||
333 | /* ...wait for DMA engine to become idle... */ | ||
334 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) | ||
335 | msleep(10); | ||
336 | |||
337 | dev_dbg(info->device, " * re-enable DMA engine\n"); | ||
338 | /* ...and enable it with updated configuration */ | ||
339 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon); | ||
340 | |||
341 | dev_dbg(info->device, " * re-enable LCDC core\n"); | ||
342 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, | ||
343 | (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET) | ATMEL_LCDC_PWR); | ||
344 | |||
345 | dev_dbg(info->device, " * DONE\n"); | ||
346 | |||
347 | return 0; | ||
348 | } | ||
349 | |||
350 | static inline unsigned int chan_to_field(unsigned int chan, const struct fb_bitfield *bf) | ||
351 | { | ||
352 | chan &= 0xffff; | ||
353 | chan >>= 16 - bf->length; | ||
354 | return chan << bf->offset; | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * atmel_lcdfb_setcolreg - Optional function. Sets a color register. | ||
359 | * @regno: Which register in the CLUT we are programming | ||
360 | * @red: The red value which can be up to 16 bits wide | ||
361 | * @green: The green value which can be up to 16 bits wide | ||
362 | * @blue: The blue value which can be up to 16 bits wide. | ||
363 | * @transp: If supported the alpha value which can be up to 16 bits wide. | ||
364 | * @info: frame buffer info structure | ||
365 | * | ||
366 | * Set a single color register. The values supplied have a 16 bit | ||
367 | * magnitude which needs to be scaled in this function for the hardware. | ||
368 | * Things to take into consideration are how many color registers, if | ||
369 | * any, are supported with the current color visual. With truecolor mode | ||
370 | * no color palettes are supported. Here a psuedo palette is created | ||
371 | * which we store the value in pseudo_palette in struct fb_info. For | ||
372 | * pseudocolor mode we have a limited color palette. To deal with this | ||
373 | * we can program what color is displayed for a particular pixel value. | ||
374 | * DirectColor is similar in that we can program each color field. If | ||
375 | * we have a static colormap we don't need to implement this function. | ||
376 | * | ||
377 | * Returns negative errno on error, or zero on success. In an | ||
378 | * ideal world, this would have been the case, but as it turns | ||
379 | * out, the other drivers return 1 on failure, so that's what | ||
380 | * we're going to do. | ||
381 | */ | ||
382 | static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red, | ||
383 | unsigned int green, unsigned int blue, | ||
384 | unsigned int transp, struct fb_info *info) | ||
385 | { | ||
386 | struct atmel_lcdfb_info *sinfo = info->par; | ||
387 | unsigned int val; | ||
388 | u32 *pal; | ||
389 | int ret = 1; | ||
390 | |||
391 | if (info->var.grayscale) | ||
392 | red = green = blue = (19595 * red + 38470 * green | ||
393 | + 7471 * blue) >> 16; | ||
394 | |||
395 | switch (info->fix.visual) { | ||
396 | case FB_VISUAL_TRUECOLOR: | ||
397 | if (regno < 16) { | ||
398 | pal = info->pseudo_palette; | ||
399 | |||
400 | val = chan_to_field(red, &info->var.red); | ||
401 | val |= chan_to_field(green, &info->var.green); | ||
402 | val |= chan_to_field(blue, &info->var.blue); | ||
403 | |||
404 | pal[regno] = val; | ||
405 | ret = 0; | ||
406 | } | ||
407 | break; | ||
408 | |||
409 | case FB_VISUAL_PSEUDOCOLOR: | ||
410 | if (regno < 256) { | ||
411 | val = ((red >> 11) & 0x001f); | ||
412 | val |= ((green >> 6) & 0x03e0); | ||
413 | val |= ((blue >> 1) & 0x7c00); | ||
414 | |||
415 | /* | ||
416 | * TODO: intensity bit. Maybe something like | ||
417 | * ~(red[10] ^ green[10] ^ blue[10]) & 1 | ||
418 | */ | ||
419 | |||
420 | lcdc_writel(sinfo, ATMEL_LCDC_LUT(regno), val); | ||
421 | ret = 0; | ||
422 | } | ||
423 | break; | ||
424 | } | ||
425 | |||
426 | return ret; | ||
427 | } | ||
428 | |||
429 | static int atmel_lcdfb_pan_display(struct fb_var_screeninfo *var, | ||
430 | struct fb_info *info) | ||
431 | { | ||
432 | dev_dbg(info->device, "%s\n", __func__); | ||
433 | |||
434 | atmel_lcdfb_update_dma(info, var); | ||
435 | |||
436 | return 0; | ||
437 | } | ||
438 | |||
439 | static struct fb_ops atmel_lcdfb_ops = { | ||
440 | .owner = THIS_MODULE, | ||
441 | .fb_check_var = atmel_lcdfb_check_var, | ||
442 | .fb_set_par = atmel_lcdfb_set_par, | ||
443 | .fb_setcolreg = atmel_lcdfb_setcolreg, | ||
444 | .fb_pan_display = atmel_lcdfb_pan_display, | ||
445 | .fb_fillrect = cfb_fillrect, | ||
446 | .fb_copyarea = cfb_copyarea, | ||
447 | .fb_imageblit = cfb_imageblit, | ||
448 | }; | ||
449 | |||
450 | static irqreturn_t atmel_lcdfb_interrupt(int irq, void *dev_id) | ||
451 | { | ||
452 | struct fb_info *info = dev_id; | ||
453 | struct atmel_lcdfb_info *sinfo = info->par; | ||
454 | u32 status; | ||
455 | |||
456 | status = lcdc_readl(sinfo, ATMEL_LCDC_ISR); | ||
457 | lcdc_writel(sinfo, ATMEL_LCDC_IDR, status); | ||
458 | return IRQ_HANDLED; | ||
459 | } | ||
460 | |||
461 | static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo) | ||
462 | { | ||
463 | struct fb_info *info = sinfo->info; | ||
464 | int ret = 0; | ||
465 | |||
466 | memset_io(info->screen_base, 0, info->fix.smem_len); | ||
467 | info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW; | ||
468 | |||
469 | dev_info(info->device, | ||
470 | "%luKiB frame buffer at %08lx (mapped at %p)\n", | ||
471 | (unsigned long)info->fix.smem_len / 1024, | ||
472 | (unsigned long)info->fix.smem_start, | ||
473 | info->screen_base); | ||
474 | |||
475 | /* Allocate colormap */ | ||
476 | ret = fb_alloc_cmap(&info->cmap, 256, 0); | ||
477 | if (ret < 0) | ||
478 | dev_err(info->device, "Alloc color map failed\n"); | ||
479 | |||
480 | return ret; | ||
481 | } | ||
482 | |||
483 | static void atmel_lcdfb_start_clock(struct atmel_lcdfb_info *sinfo) | ||
484 | { | ||
485 | if (sinfo->bus_clk) | ||
486 | clk_enable(sinfo->bus_clk); | ||
487 | clk_enable(sinfo->lcdc_clk); | ||
488 | } | ||
489 | |||
490 | static void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info *sinfo) | ||
491 | { | ||
492 | if (sinfo->bus_clk) | ||
493 | clk_disable(sinfo->bus_clk); | ||
494 | clk_disable(sinfo->lcdc_clk); | ||
495 | } | ||
496 | |||
497 | |||
498 | static int __init atmel_lcdfb_probe(struct platform_device *pdev) | ||
499 | { | ||
500 | struct device *dev = &pdev->dev; | ||
501 | struct fb_info *info; | ||
502 | struct atmel_lcdfb_info *sinfo; | ||
503 | struct atmel_lcdfb_info *pdata_sinfo; | ||
504 | struct resource *regs = NULL; | ||
505 | struct resource *map = NULL; | ||
506 | int ret; | ||
507 | |||
508 | dev_dbg(dev, "%s BEGIN\n", __func__); | ||
509 | |||
510 | ret = -ENOMEM; | ||
511 | info = framebuffer_alloc(sizeof(struct atmel_lcdfb_info), dev); | ||
512 | if (!info) { | ||
513 | dev_err(dev, "cannot allocate memory\n"); | ||
514 | goto out; | ||
515 | } | ||
516 | |||
517 | sinfo = info->par; | ||
518 | |||
519 | if (dev->platform_data) { | ||
520 | pdata_sinfo = (struct atmel_lcdfb_info *)dev->platform_data; | ||
521 | sinfo->default_bpp = pdata_sinfo->default_bpp; | ||
522 | sinfo->default_dmacon = pdata_sinfo->default_dmacon; | ||
523 | sinfo->default_lcdcon2 = pdata_sinfo->default_lcdcon2; | ||
524 | sinfo->default_monspecs = pdata_sinfo->default_monspecs; | ||
525 | sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control; | ||
526 | sinfo->guard_time = pdata_sinfo->guard_time; | ||
527 | } else { | ||
528 | dev_err(dev, "cannot get default configuration\n"); | ||
529 | goto free_info; | ||
530 | } | ||
531 | sinfo->info = info; | ||
532 | sinfo->pdev = pdev; | ||
533 | |||
534 | strcpy(info->fix.id, sinfo->pdev->name); | ||
535 | info->flags = ATMEL_LCDFB_FBINFO_DEFAULT; | ||
536 | info->pseudo_palette = sinfo->pseudo_palette; | ||
537 | info->fbops = &atmel_lcdfb_ops; | ||
538 | |||
539 | memcpy(&info->monspecs, sinfo->default_monspecs, sizeof(info->monspecs)); | ||
540 | info->fix = atmel_lcdfb_fix; | ||
541 | |||
542 | /* Enable LCDC Clocks */ | ||
543 | if (cpu_is_at91sam9261() || cpu_is_at32ap7000()) { | ||
544 | sinfo->bus_clk = clk_get(dev, "hck1"); | ||
545 | if (IS_ERR(sinfo->bus_clk)) { | ||
546 | ret = PTR_ERR(sinfo->bus_clk); | ||
547 | goto free_info; | ||
548 | } | ||
549 | } | ||
550 | sinfo->lcdc_clk = clk_get(dev, "lcdc_clk"); | ||
551 | if (IS_ERR(sinfo->lcdc_clk)) { | ||
552 | ret = PTR_ERR(sinfo->lcdc_clk); | ||
553 | goto put_bus_clk; | ||
554 | } | ||
555 | atmel_lcdfb_start_clock(sinfo); | ||
556 | |||
557 | ret = fb_find_mode(&info->var, info, NULL, info->monspecs.modedb, | ||
558 | info->monspecs.modedb_len, info->monspecs.modedb, | ||
559 | sinfo->default_bpp); | ||
560 | if (!ret) { | ||
561 | dev_err(dev, "no suitable video mode found\n"); | ||
562 | goto stop_clk; | ||
563 | } | ||
564 | |||
565 | |||
566 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
567 | if (!regs) { | ||
568 | dev_err(dev, "resources unusable\n"); | ||
569 | ret = -ENXIO; | ||
570 | goto stop_clk; | ||
571 | } | ||
572 | |||
573 | sinfo->irq_base = platform_get_irq(pdev, 0); | ||
574 | if (sinfo->irq_base < 0) { | ||
575 | dev_err(dev, "unable to get irq\n"); | ||
576 | ret = sinfo->irq_base; | ||
577 | goto stop_clk; | ||
578 | } | ||
579 | |||
580 | /* Initialize video memory */ | ||
581 | map = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
582 | if (map) { | ||
583 | /* use a pre-allocated memory buffer */ | ||
584 | info->fix.smem_start = map->start; | ||
585 | info->fix.smem_len = map->end - map->start + 1; | ||
586 | if (!request_mem_region(info->fix.smem_start, | ||
587 | info->fix.smem_len, pdev->name)) { | ||
588 | ret = -EBUSY; | ||
589 | goto stop_clk; | ||
590 | } | ||
591 | |||
592 | info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); | ||
593 | if (!info->screen_base) | ||
594 | goto release_intmem; | ||
595 | } else { | ||
596 | /* alocate memory buffer */ | ||
597 | ret = atmel_lcdfb_alloc_video_memory(sinfo); | ||
598 | if (ret < 0) { | ||
599 | dev_err(dev, "cannot allocate framebuffer: %d\n", ret); | ||
600 | goto stop_clk; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | /* LCDC registers */ | ||
605 | info->fix.mmio_start = regs->start; | ||
606 | info->fix.mmio_len = regs->end - regs->start + 1; | ||
607 | |||
608 | if (!request_mem_region(info->fix.mmio_start, | ||
609 | info->fix.mmio_len, pdev->name)) { | ||
610 | ret = -EBUSY; | ||
611 | goto free_fb; | ||
612 | } | ||
613 | |||
614 | sinfo->mmio = ioremap(info->fix.mmio_start, info->fix.mmio_len); | ||
615 | if (!sinfo->mmio) { | ||
616 | dev_err(dev, "cannot map LCDC registers\n"); | ||
617 | goto release_mem; | ||
618 | } | ||
619 | |||
620 | /* interrupt */ | ||
621 | ret = request_irq(sinfo->irq_base, atmel_lcdfb_interrupt, 0, pdev->name, info); | ||
622 | if (ret) { | ||
623 | dev_err(dev, "request_irq failed: %d\n", ret); | ||
624 | goto unmap_mmio; | ||
625 | } | ||
626 | |||
627 | ret = atmel_lcdfb_init_fbinfo(sinfo); | ||
628 | if (ret < 0) { | ||
629 | dev_err(dev, "init fbinfo failed: %d\n", ret); | ||
630 | goto unregister_irqs; | ||
631 | } | ||
632 | |||
633 | /* | ||
634 | * This makes sure that our colour bitfield | ||
635 | * descriptors are correctly initialised. | ||
636 | */ | ||
637 | atmel_lcdfb_check_var(&info->var, info); | ||
638 | |||
639 | ret = fb_set_var(info, &info->var); | ||
640 | if (ret) { | ||
641 | dev_warn(dev, "unable to set display parameters\n"); | ||
642 | goto free_cmap; | ||
643 | } | ||
644 | |||
645 | dev_set_drvdata(dev, info); | ||
646 | |||
647 | /* | ||
648 | * Tell the world that we're ready to go | ||
649 | */ | ||
650 | ret = register_framebuffer(info); | ||
651 | if (ret < 0) { | ||
652 | dev_err(dev, "failed to register framebuffer device: %d\n", ret); | ||
653 | goto free_cmap; | ||
654 | } | ||
655 | |||
656 | /* Power up the LCDC screen */ | ||
657 | if (sinfo->atmel_lcdfb_power_control) | ||
658 | sinfo->atmel_lcdfb_power_control(1); | ||
659 | |||
660 | dev_info(dev, "fb%d: Atmel LCDC at 0x%08lx (mapped at %p), irq %lu\n", | ||
661 | info->node, info->fix.mmio_start, sinfo->mmio, sinfo->irq_base); | ||
662 | |||
663 | return 0; | ||
664 | |||
665 | |||
666 | free_cmap: | ||
667 | fb_dealloc_cmap(&info->cmap); | ||
668 | unregister_irqs: | ||
669 | free_irq(sinfo->irq_base, info); | ||
670 | unmap_mmio: | ||
671 | iounmap(sinfo->mmio); | ||
672 | release_mem: | ||
673 | release_mem_region(info->fix.mmio_start, info->fix.mmio_len); | ||
674 | free_fb: | ||
675 | if (map) | ||
676 | iounmap(info->screen_base); | ||
677 | else | ||
678 | atmel_lcdfb_free_video_memory(sinfo); | ||
679 | |||
680 | release_intmem: | ||
681 | if (map) | ||
682 | release_mem_region(info->fix.smem_start, info->fix.smem_len); | ||
683 | stop_clk: | ||
684 | atmel_lcdfb_stop_clock(sinfo); | ||
685 | clk_put(sinfo->lcdc_clk); | ||
686 | put_bus_clk: | ||
687 | if (sinfo->bus_clk) | ||
688 | clk_put(sinfo->bus_clk); | ||
689 | free_info: | ||
690 | framebuffer_release(info); | ||
691 | out: | ||
692 | dev_dbg(dev, "%s FAILED\n", __func__); | ||
693 | return ret; | ||
694 | } | ||
695 | |||
696 | static int __exit atmel_lcdfb_remove(struct platform_device *pdev) | ||
697 | { | ||
698 | struct device *dev = &pdev->dev; | ||
699 | struct fb_info *info = dev_get_drvdata(dev); | ||
700 | struct atmel_lcdfb_info *sinfo = info->par; | ||
701 | |||
702 | if (!sinfo) | ||
703 | return 0; | ||
704 | |||
705 | if (sinfo->atmel_lcdfb_power_control) | ||
706 | sinfo->atmel_lcdfb_power_control(0); | ||
707 | unregister_framebuffer(info); | ||
708 | atmel_lcdfb_stop_clock(sinfo); | ||
709 | clk_put(sinfo->lcdc_clk); | ||
710 | if (sinfo->bus_clk) | ||
711 | clk_put(sinfo->bus_clk); | ||
712 | fb_dealloc_cmap(&info->cmap); | ||
713 | free_irq(sinfo->irq_base, info); | ||
714 | iounmap(sinfo->mmio); | ||
715 | release_mem_region(info->fix.mmio_start, info->fix.mmio_len); | ||
716 | if (platform_get_resource(pdev, IORESOURCE_MEM, 1)) { | ||
717 | iounmap(info->screen_base); | ||
718 | release_mem_region(info->fix.smem_start, info->fix.smem_len); | ||
719 | } else { | ||
720 | atmel_lcdfb_free_video_memory(sinfo); | ||
721 | } | ||
722 | |||
723 | dev_set_drvdata(dev, NULL); | ||
724 | framebuffer_release(info); | ||
725 | |||
726 | return 0; | ||
727 | } | ||
728 | |||
729 | static struct platform_driver atmel_lcdfb_driver = { | ||
730 | .remove = __exit_p(atmel_lcdfb_remove), | ||
731 | .driver = { | ||
732 | .name = "atmel_lcdfb", | ||
733 | .owner = THIS_MODULE, | ||
734 | }, | ||
735 | }; | ||
736 | |||
737 | static int __init atmel_lcdfb_init(void) | ||
738 | { | ||
739 | return platform_driver_probe(&atmel_lcdfb_driver, atmel_lcdfb_probe); | ||
740 | } | ||
741 | |||
742 | static void __exit atmel_lcdfb_exit(void) | ||
743 | { | ||
744 | platform_driver_unregister(&atmel_lcdfb_driver); | ||
745 | } | ||
746 | |||
747 | module_init(atmel_lcdfb_init); | ||
748 | module_exit(atmel_lcdfb_exit); | ||
749 | |||
750 | MODULE_DESCRIPTION("AT91/AT32 LCD Controller framebuffer driver"); | ||
751 | MODULE_AUTHOR("Nicolas Ferre <nicolas.ferre@rfo.atmel.com>"); | ||
752 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index aa3935df852a..63b85bf81a65 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig | |||
@@ -19,13 +19,6 @@ config VGA_CONSOLE | |||
19 | 19 | ||
20 | Say Y. | 20 | Say Y. |
21 | 21 | ||
22 | # if [ "$CONFIG_PCI" = "y" -a "$CONFIG_VGA_CONSOLE" = "y" ]; then | ||
23 | # bool ' Allow VGA on any bus?' CONFIG_VGA_HOSE | ||
24 | # if [ "$CONFIG_VGA_HOSE" = "y" ]; then | ||
25 | # define_bool CONFIG_DUMMY_CONSOLE y | ||
26 | # fi | ||
27 | # fi | ||
28 | |||
29 | config VGACON_SOFT_SCROLLBACK | 22 | config VGACON_SOFT_SCROLLBACK |
30 | bool "Enable Scrollback Buffer in System RAM" | 23 | bool "Enable Scrollback Buffer in System RAM" |
31 | depends on VGA_CONSOLE | 24 | depends on VGA_CONSOLE |
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c index c627955aa124..aff11bbf59a7 100644 --- a/drivers/video/nvidia/nv_hw.c +++ b/drivers/video/nvidia/nv_hw.c | |||
@@ -149,7 +149,9 @@ static void nvGetClocks(struct nvidia_par *par, unsigned int *MClk, | |||
149 | pll = NV_RD32(par->PMC, 0x4024); | 149 | pll = NV_RD32(par->PMC, 0x4024); |
150 | M = pll & 0xFF; | 150 | M = pll & 0xFF; |
151 | N = (pll >> 8) & 0xFF; | 151 | N = (pll >> 8) & 0xFF; |
152 | if (((par->Chipset & 0xfff0) == 0x0290) || ((par->Chipset & 0xfff0) == 0x0390) || ((par->Chipset & 0xfff0) == 0x02E0)) { | 152 | if (((par->Chipset & 0xfff0) == 0x0290) || |
153 | ((par->Chipset & 0xfff0) == 0x0390) || | ||
154 | ((par->Chipset & 0xfff0) == 0x02E0)) { | ||
153 | MB = 1; | 155 | MB = 1; |
154 | NB = 1; | 156 | NB = 1; |
155 | } else { | 157 | } else { |
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c index f85edf084da3..41f63658572f 100644 --- a/drivers/video/nvidia/nvidia.c +++ b/drivers/video/nvidia/nvidia.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include "nv_proto.h" | 37 | #include "nv_proto.h" |
38 | #include "nv_dma.h" | 38 | #include "nv_dma.h" |
39 | 39 | ||
40 | #undef CONFIG_FB_NVIDIA_DEBUG | ||
41 | #ifdef CONFIG_FB_NVIDIA_DEBUG | 40 | #ifdef CONFIG_FB_NVIDIA_DEBUG |
42 | #define NVTRACE printk | 41 | #define NVTRACE printk |
43 | #else | 42 | #else |
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c index 1ac5264bb2c1..ab5e66890e4e 100644 --- a/drivers/video/pm2fb.c +++ b/drivers/video/pm2fb.c | |||
@@ -204,17 +204,6 @@ static inline void WAIT_FIFO(struct pm2fb_par* p, u32 a) | |||
204 | } | 204 | } |
205 | #endif | 205 | #endif |
206 | 206 | ||
207 | static void wait_pm2(struct pm2fb_par* par) { | ||
208 | |||
209 | WAIT_FIFO(par, 1); | ||
210 | pm2_WR(par, PM2R_SYNC, 0); | ||
211 | mb(); | ||
212 | do { | ||
213 | while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0); | ||
214 | rmb(); | ||
215 | } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC)); | ||
216 | } | ||
217 | |||
218 | /* | 207 | /* |
219 | * partial products for the supported horizontal resolutions. | 208 | * partial products for the supported horizontal resolutions. |
220 | */ | 209 | */ |
@@ -1050,13 +1039,30 @@ static int pm2fb_blank(int blank_mode, struct fb_info *info) | |||
1050 | return 0; | 1039 | return 0; |
1051 | } | 1040 | } |
1052 | 1041 | ||
1042 | static int pm2fb_sync(struct fb_info *info) | ||
1043 | { | ||
1044 | struct pm2fb_par *par = info->par; | ||
1045 | |||
1046 | WAIT_FIFO(par, 1); | ||
1047 | pm2_WR(par, PM2R_SYNC, 0); | ||
1048 | mb(); | ||
1049 | do { | ||
1050 | while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0) | ||
1051 | udelay(10); | ||
1052 | rmb(); | ||
1053 | } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC)); | ||
1054 | |||
1055 | return 0; | ||
1056 | } | ||
1057 | |||
1053 | /* | 1058 | /* |
1054 | * block operation. copy=0: rectangle fill, copy=1: rectangle copy. | 1059 | * block operation. copy=0: rectangle fill, copy=1: rectangle copy. |
1055 | */ | 1060 | */ |
1056 | static void pm2fb_block_op(struct pm2fb_par* par, int copy, | 1061 | static void pm2fb_block_op(struct fb_info* info, int copy, |
1057 | s32 xsrc, s32 ysrc, | 1062 | s32 xsrc, s32 ysrc, |
1058 | s32 x, s32 y, s32 w, s32 h, | 1063 | s32 x, s32 y, s32 w, s32 h, |
1059 | u32 color) { | 1064 | u32 color) { |
1065 | struct pm2fb_par *par = info->par; | ||
1060 | 1066 | ||
1061 | if (!w || !h) | 1067 | if (!w || !h) |
1062 | return; | 1068 | return; |
@@ -1076,13 +1082,11 @@ static void pm2fb_block_op(struct pm2fb_par* par, int copy, | |||
1076 | (x<xsrc ? PM2F_INCREASE_X : 0) | | 1082 | (x<xsrc ? PM2F_INCREASE_X : 0) | |
1077 | (y<ysrc ? PM2F_INCREASE_Y : 0) | | 1083 | (y<ysrc ? PM2F_INCREASE_Y : 0) | |
1078 | (copy ? 0 : PM2F_RENDER_FASTFILL)); | 1084 | (copy ? 0 : PM2F_RENDER_FASTFILL)); |
1079 | wait_pm2(par); | ||
1080 | } | 1085 | } |
1081 | 1086 | ||
1082 | static void pm2fb_fillrect (struct fb_info *info, | 1087 | static void pm2fb_fillrect (struct fb_info *info, |
1083 | const struct fb_fillrect *region) | 1088 | const struct fb_fillrect *region) |
1084 | { | 1089 | { |
1085 | struct pm2fb_par *par = info->par; | ||
1086 | struct fb_fillrect modded; | 1090 | struct fb_fillrect modded; |
1087 | int vxres, vyres; | 1091 | int vxres, vyres; |
1088 | u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? | 1092 | u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? |
@@ -1116,7 +1120,7 @@ static void pm2fb_fillrect (struct fb_info *info, | |||
1116 | color |= color << 16; | 1120 | color |= color << 16; |
1117 | 1121 | ||
1118 | if(info->var.bits_per_pixel != 24) | 1122 | if(info->var.bits_per_pixel != 24) |
1119 | pm2fb_block_op(par, 0, 0, 0, | 1123 | pm2fb_block_op(info, 0, 0, 0, |
1120 | modded.dx, modded.dy, | 1124 | modded.dx, modded.dy, |
1121 | modded.width, modded.height, color); | 1125 | modded.width, modded.height, color); |
1122 | else | 1126 | else |
@@ -1126,7 +1130,6 @@ static void pm2fb_fillrect (struct fb_info *info, | |||
1126 | static void pm2fb_copyarea(struct fb_info *info, | 1130 | static void pm2fb_copyarea(struct fb_info *info, |
1127 | const struct fb_copyarea *area) | 1131 | const struct fb_copyarea *area) |
1128 | { | 1132 | { |
1129 | struct pm2fb_par *par = info->par; | ||
1130 | struct fb_copyarea modded; | 1133 | struct fb_copyarea modded; |
1131 | u32 vxres, vyres; | 1134 | u32 vxres, vyres; |
1132 | 1135 | ||
@@ -1156,7 +1159,7 @@ static void pm2fb_copyarea(struct fb_info *info, | |||
1156 | if(modded.dy + modded.height > vyres) | 1159 | if(modded.dy + modded.height > vyres) |
1157 | modded.height = vyres - modded.dy; | 1160 | modded.height = vyres - modded.dy; |
1158 | 1161 | ||
1159 | pm2fb_block_op(par, 1, modded.sx, modded.sy, | 1162 | pm2fb_block_op(info, 1, modded.sx, modded.sy, |
1160 | modded.dx, modded.dy, | 1163 | modded.dx, modded.dy, |
1161 | modded.width, modded.height, 0); | 1164 | modded.width, modded.height, 0); |
1162 | } | 1165 | } |
@@ -1177,6 +1180,7 @@ static struct fb_ops pm2fb_ops = { | |||
1177 | .fb_fillrect = pm2fb_fillrect, | 1180 | .fb_fillrect = pm2fb_fillrect, |
1178 | .fb_copyarea = pm2fb_copyarea, | 1181 | .fb_copyarea = pm2fb_copyarea, |
1179 | .fb_imageblit = cfb_imageblit, | 1182 | .fb_imageblit = cfb_imageblit, |
1183 | .fb_sync = pm2fb_sync, | ||
1180 | }; | 1184 | }; |
1181 | 1185 | ||
1182 | /* | 1186 | /* |
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c index bd787e80177d..c77a1a1fd46b 100644 --- a/drivers/video/pm3fb.c +++ b/drivers/video/pm3fb.c | |||
@@ -1,55 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device | 2 | * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device |
3 | * | 3 | * |
4 | * Copyright (C) 2001 Romain Dolbeau <dolbeau@irisa.fr> | 4 | * Copyright (C) 2001 Romain Dolbeau <romain@dolbeau.org>. |
5 | * | ||
6 | * Ported to 2.6 kernel on 1 May 2007 by Krzysztof Helt <krzysztof.h1@wp.pl> | ||
7 | * based on pm2fb.c | ||
8 | * | ||
5 | * Based on code written by: | 9 | * Based on code written by: |
6 | * Sven Luther, <luther@dpt-info.u-strasbg.fr> | 10 | * Sven Luther, <luther@dpt-info.u-strasbg.fr> |
7 | * Alan Hourihane, <alanh@fairlite.demon.co.uk> | 11 | * Alan Hourihane, <alanh@fairlite.demon.co.uk> |
8 | * Russell King, <rmk@arm.linux.org.uk> | 12 | * Russell King, <rmk@arm.linux.org.uk> |
9 | * Based on linux/drivers/video/skeletonfb.c: | 13 | * Based on linux/drivers/video/skeletonfb.c: |
10 | * Copyright (C) 1997 Geert Uytterhoeven | 14 | * Copyright (C) 1997 Geert Uytterhoeven |
11 | * Based on linux/driver/video/pm2fb.c: | 15 | * Based on linux/driver/video/pm2fb.c: |
12 | * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT) | 16 | * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT) |
13 | * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com) | 17 | * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com) |
14 | * | 18 | * |
15 | * This file is subject to the terms and conditions of the GNU General Public | 19 | * This file is subject to the terms and conditions of the GNU General Public |
16 | * License. See the file COPYING in the main directory of this archive for | 20 | * License. See the file COPYING in the main directory of this archive for |
17 | * more details. | 21 | * more details. |
18 | * | 22 | * |
19 | * $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $ | ||
20 | * | ||
21 | * CHANGELOG: | ||
22 | * Mon Feb 11 10:35:48 MET 2002, v 1.4.11B: Cosmetic update. | ||
23 | * Wed Jan 23 14:16:59 MET 2002, v 1.4.11: Preliminary 2.5.x support, patch for 2.5.2. | ||
24 | * Wed Nov 28 11:08:29 MET 2001, v 1.4.10: potential bug fix for SDRAM-based board, patch for 2.4.16. | ||
25 | * Thu Sep 20 10:24:42 MET DST 2001, v 1.4.9: sync bug fix, preliminary flatpanel support, better timings. | ||
26 | * Tue Aug 28 10:13:01 MET DST 2001, v 1.4.8: memory timings check, minor bug fixes. | ||
27 | * Wed Jul 18 19:06:14 CEST 2001, v 1.4.7: Mode fix (800x600-100, 1024x768-100 changed), using HW panning + accel bug fix. | ||
28 | * Mon Jun 25 10:33:56 MET DST 2001, v 1.4.6: Depth 12 fix, chip reset ioctl, moved memory erase ioctl to DEBUG. | ||
29 | * Wed Jun 20 11:13:08 MET DST 2001, v 1.4.5: Fixed missing blinking cursor in 8bpp, code cleaning, memory erase IOCTL. | ||
30 | * Mon Jun 18 16:00:27 CEST 2001, v 1.4.4: Depth 12 (RGBA 4444) support, code cleaning. | ||
31 | * Fri Jun 15 13:53:01 CEST 2001, v 1.4.3: Removed warnings, depth 15 support, add 'depth' option. | ||
32 | * Thu Jun 14 10:13:52 MET DST 2001, v 1.4.2: Fixed depth switching bug, preliminary 15bpp (RGB5551) support. | ||
33 | * Thu Apr 12 11:16:45 MET DST 2001, v 1.4.1B: Doc updates. | ||
34 | * Fri Apr 6 11:12:53 MET DST 2001, v 1.4.1: Configure.help, minor cleanup | ||
35 | * Thu Mar 29 10:56:50 MET DST 2001, v 1.4.0: Module & module options support (note: linux patch changed, 2.2.19 added). | ||
36 | * Thu Mar 15 15:30:31 MET 2001, v 1.3.2: Fixed mirroring bug on little-endian. | ||
37 | * Wed Mar 14 21:25:54 CET 2001, v 1.3.1: Fixed bug in BlockMove (_bmov). | ||
38 | * Tue Mar 13 10:53:19 MET 2001, v 1.3.0: Character drawing hardware support (in all width between 1 and 16), fixes. | ||
39 | * Thu Mar 8 10:20:16 MET 2001, v 1.2.2: Better J2000 support, "font:" option. | ||
40 | * Tue Mar 6 21:25:04 CET 2001, v 1.2.1: Better acceleration support. | ||
41 | * Mon Mar 5 21:54:17 CET 2001, v 1.2.0: Partial acceleration support (clear & bmove) | ||
42 | * Mon Mar 5 12:52:15 CET 2001, v 1.1.3: Big pan_display fix. | ||
43 | * Sun Mar 4 22:21:50 CET 2001, v 1.1.2: (numerous) bug fixes. | ||
44 | * Fri Mar 2 15:54:07 CET 2001, v 1.1.1: Might have Appian J2000 support, resource mangement in 2.4 | ||
45 | * Wed Feb 28 18:21:35 CET 2001, v 1.1.0: Might have multiple boards support (added, but not yest tested) | ||
46 | * Tue Feb 27 17:31:12 CET 2001, v 1.0.6: fixes boot-time mode select, add more default mode | ||
47 | * Tue Feb 27 14:01:36 CET 2001, v 1.0.5: fixes (1.0.4 was broken for 2.2), cleaning up | ||
48 | * Mon Feb 26 23:17:36 CET 2001, v 1.0.4: preliminary 2.4.x support, dropped (useless on pm3) partial product, more OF fix | ||
49 | * Mon Feb 26 20:59:05 CET 2001, v 1.0.3: No more shadow register (and wasted memory), endianess fix, use OF-preset resolution by default | ||
50 | * Wed Feb 21 22:09:30 CET 2001, v 1.0.2: Code cleaning for future multiboard support, better OF support, bugs fix | ||
51 | * Wed Feb 21 19:58:56 CET 2001, v 1.0.1: OpenFirmware support, fixed memory detection, better debug support, code cleaning | ||
52 | * Wed Feb 21 14:47:06 CET 2001, v 1.0.0: First working version | ||
53 | */ | 23 | */ |
54 | 24 | ||
55 | #include <linux/module.h> | 25 | #include <linux/module.h> |
@@ -58,856 +28,155 @@ | |||
58 | #include <linux/string.h> | 28 | #include <linux/string.h> |
59 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
60 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
61 | #include <linux/vmalloc.h> | ||
62 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
63 | #include <linux/interrupt.h> | ||
64 | #include <linux/fb.h> | 32 | #include <linux/fb.h> |
65 | #include <linux/init.h> | 33 | #include <linux/init.h> |
66 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
67 | #include <linux/ioport.h> | ||
68 | #include <linux/ctype.h> | ||
69 | |||
70 | #include <video/fbcon.h> | ||
71 | #include <video/fbcon-mfb.h> | ||
72 | #include <video/fbcon-cfb2.h> | ||
73 | #include <video/fbcon-cfb4.h> | ||
74 | #include <video/fbcon-cfb8.h> | ||
75 | #include <video/fbcon-cfb16.h> | ||
76 | #include <video/fbcon-cfb24.h> | ||
77 | #include <video/fbcon-cfb32.h> | ||
78 | #include <video/pm3fb.h> | ||
79 | 35 | ||
80 | #include <asm/io.h> | 36 | #include <video/pm3fb.h> |
81 | #include <asm/uaccess.h> | ||
82 | 37 | ||
83 | #ifdef CONFIG_FB_OF | 38 | #if !defined(CONFIG_PCI) |
84 | #include <asm/prom.h> | 39 | #error "Only generic PCI cards supported." |
85 | #endif | 40 | #endif |
86 | 41 | ||
87 | /* ************************************* */ | 42 | #undef PM3FB_MASTER_DEBUG |
88 | /* ***** The various "global" data ***** */ | 43 | #ifdef PM3FB_MASTER_DEBUG |
89 | /* ************************************* */ | 44 | #define DPRINTK(a,b...) printk(KERN_DEBUG "pm3fb: %s: " a, __FUNCTION__ , ## b) |
90 | 45 | #else | |
91 | /* those will need a rework for multiple board support */ | 46 | #define DPRINTK(a,b...) |
92 | /* Driver name */ | ||
93 | static const char permedia3_name[16] = "Permedia3"; | ||
94 | |||
95 | /* the fb_par struct, mandatory */ | ||
96 | struct pm3fb_par { | ||
97 | u32 pixclock; /* pixclock in KHz */ | ||
98 | |||
99 | u32 width; /* width of virtual screen */ | ||
100 | u32 height; /* height of virtual screen */ | ||
101 | |||
102 | u32 hsstart; /* horiz. sync start */ | ||
103 | u32 hsend; /* horiz. sync end */ | ||
104 | u32 hbend; /* horiz. blank end (also gate end) */ | ||
105 | u32 htotal; /* total width (w/ sync & blank) */ | ||
106 | |||
107 | u32 vsstart; /* vert. sync start */ | ||
108 | u32 vsend; /* vert. sync end */ | ||
109 | u32 vbend; /* vert. blank end */ | ||
110 | u32 vtotal; /* total height (w/ sync & blank) */ | ||
111 | |||
112 | u32 stride; /* screen stride */ | ||
113 | u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */ | ||
114 | /* NOTE : unlike other pm3 stuff above, stored *after* shiftbpp. don't ask */ | ||
115 | u32 depth; /* screen depth (8, 12, 15, 16 or 32) */ | ||
116 | u32 video; /* video control (hsync,vsync) */ | ||
117 | }; | ||
118 | |||
119 | /* memory timings */ | ||
120 | struct pm3fb_timings | ||
121 | { | ||
122 | unsigned long caps; | ||
123 | unsigned long timings; | ||
124 | unsigned long control; | ||
125 | unsigned long refresh; | ||
126 | unsigned long powerdown; | ||
127 | }; | ||
128 | typedef enum pm3fb_timing_result { pm3fb_timing_ok, pm3fb_timing_problem, pm3fb_timing_retry } pm3fb_timing_result; | ||
129 | #define PM3FB_UNKNOWN_TIMING_VALUE ((unsigned long)-1) | ||
130 | #define PM3FB_UNKNOWN_TIMINGS { PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE } | ||
131 | |||
132 | /* the fb_info struct, mandatory */ | ||
133 | struct pm3fb_info { | ||
134 | struct fb_info_gen gen; | ||
135 | unsigned long board_num; /* internal board number */ | ||
136 | unsigned long use_current; | ||
137 | struct pm3fb_par *current_par; | ||
138 | struct pci_dev *dev; /* PCI device */ | ||
139 | unsigned long board_type; /* index in the cardbase */ | ||
140 | unsigned char *fb_base; /* framebuffer memory base */ | ||
141 | u32 fb_size; /* framebuffer memory size */ | ||
142 | unsigned char *p_fb; /* physical address of frame buffer */ | ||
143 | unsigned char *v_fb; /* virtual address of frame buffer */ | ||
144 | unsigned char *pIOBase; /* physical address of registers region, must be rg_base or rg_base+PM2_REGS_SIZE depending on the host endianness */ | ||
145 | unsigned char *vIOBase; /* address of registers after ioremap() */ | ||
146 | struct { | ||
147 | u8 transp; | ||
148 | u8 red; | ||
149 | u8 green; | ||
150 | u8 blue; | ||
151 | } palette[256]; | ||
152 | union { | ||
153 | #ifdef FBCON_HAS_CFB16 | ||
154 | u16 cmap12[16]; /* RGBA 4444 */ | ||
155 | u16 cmap15[16]; /* RGBA 5551 */ | ||
156 | u16 cmap16[16]; /* RGBA 5650 */ | ||
157 | #endif | ||
158 | #ifdef FBCON_HAS_CFB32 | ||
159 | u32 cmap32[16]; | ||
160 | #endif | 47 | #endif |
161 | } cmap; | ||
162 | struct pm3fb_timings memt; | ||
163 | }; | ||
164 | 48 | ||
165 | /* regular resolution database*/ | 49 | /* |
166 | static struct { | 50 | * Driver data |
167 | char name[16]; | 51 | */ |
168 | struct pm3fb_par user_mode; | 52 | static char *mode_option __devinitdata; |
169 | } mode_base[] __initdata = { | ||
170 | { | ||
171 | "default-800x600", { | ||
172 | 49500, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625, | ||
173 | 800, 0, 8, | ||
174 | PM3VideoControl_ENABLE | | ||
175 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
176 | | | ||
177 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
178 | | PM3VideoControl_PIXELSIZE_8BIT}}, { | ||
179 | "1024x768-74", { | ||
180 | 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38, | ||
181 | 806, 1024, 0, 8, | ||
182 | PM3VideoControl_ENABLE | | ||
183 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
184 | | | ||
185 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
186 | | PM3VideoControl_PIXELSIZE_8BIT}}, { | ||
187 | "1024x768-74-32", { | ||
188 | 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38, | ||
189 | 806, 1024, 0, 32, | ||
190 | PM3VideoControl_ENABLE | | ||
191 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
192 | | | ||
193 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
194 | | PM3VideoControl_PIXELSIZE_32BIT}}, | ||
195 | /* Generated mode : "1600x1024", for the SGI 1600SW flat panel*/ | ||
196 | { | ||
197 | "SGI1600SW", { | ||
198 | 108000, 1600, 1024, 16, 56, 104, 1704, 3, 6, 32, | ||
199 | 1056, 1600, 0, 8, | ||
200 | PM3VideoControl_ENABLE| | ||
201 | PM3VideoControl_HSYNC_ACTIVE_LOW|PM3VideoControl_VSYNC_ACTIVE_LOW| | ||
202 | PM3VideoControl_PIXELSIZE_32BIT}}, | ||
203 | /* ##### auto-generated mode, by fbtimings2pm3 */ | ||
204 | /* Generated mode : "640x480-60" */ | ||
205 | { | ||
206 | "640x480-60", { | ||
207 | 25174, 640, 480, 16, 112, 160, 800, 10, 12, 45, | ||
208 | 525, 640, 0, 8, | ||
209 | PM3VideoControl_ENABLE | | ||
210 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
211 | | | ||
212 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
213 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
214 | /* Generated mode : "640x480-72" */ | ||
215 | { | ||
216 | "640x480-72", { | ||
217 | 31199, 640, 480, 24, 64, 192, 832, 9, 12, 40, 520, | ||
218 | 640, 0, 8, | ||
219 | PM3VideoControl_ENABLE | | ||
220 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
221 | | | ||
222 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
223 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
224 | /* Generated mode : "640x480-75" */ | ||
225 | { | ||
226 | "640x480-75", { | ||
227 | 31499, 640, 480, 16, 80, 200, 840, 1, 4, 20, 500, | ||
228 | 640, 0, 8, | ||
229 | PM3VideoControl_ENABLE | | ||
230 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
231 | | | ||
232 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
233 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
234 | /* Generated mode : "640x480-90" */ | ||
235 | { | ||
236 | "640x480-90", { | ||
237 | 39909, 640, 480, 32, 72, 192, 832, 25, 39, 53, 533, | ||
238 | 640, 0, 8, | ||
239 | PM3VideoControl_ENABLE | | ||
240 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
241 | | | ||
242 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
243 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
244 | /* Generated mode : "640x480-100" */ | ||
245 | { | ||
246 | "640x480-100", { | ||
247 | 44899, 640, 480, 32, 160, 208, 848, 22, 34, 51, | ||
248 | 531, 640, 0, 8, | ||
249 | PM3VideoControl_ENABLE | | ||
250 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
251 | | | ||
252 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
253 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
254 | /* Generated mode : "800x600-48-lace" */ | ||
255 | /* INTERLACED NOT SUPPORTED | ||
256 | {"800x600-48-lace", {35999, 800, 600, 80, 208, 264, 1064, 11, 23, 102, 702, 800, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
257 | INTERLACED NOT SUPPORTED */ | ||
258 | /* Generated mode : "800x600-56" */ | ||
259 | { | ||
260 | "800x600-56", { | ||
261 | 35999, 800, 600, 24, 96, 224, 1024, 1, 3, 25, 625, | ||
262 | 800, 0, 8, | ||
263 | PM3VideoControl_ENABLE | | ||
264 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
265 | | | ||
266 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
267 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
268 | /* Generated mode : "800x600-60" */ | ||
269 | { | ||
270 | "800x600-60", { | ||
271 | 40000, 800, 600, 40, 168, 256, 1056, 1, 5, 28, 628, | ||
272 | 800, 0, 8, | ||
273 | PM3VideoControl_ENABLE | | ||
274 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
275 | | | ||
276 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
277 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
278 | /* Generated mode : "800x600-70" */ | ||
279 | { | ||
280 | "800x600-70", { | ||
281 | 44899, 800, 600, 24, 168, 208, 1008, 9, 21, 36, | ||
282 | 636, 800, 0, 8, | ||
283 | PM3VideoControl_ENABLE | | ||
284 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
285 | | | ||
286 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
287 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
288 | /* Generated mode : "800x600-72" */ | ||
289 | { | ||
290 | "800x600-72", { | ||
291 | 50000, 800, 600, 56, 176, 240, 1040, 37, 43, 66, | ||
292 | 666, 800, 0, 8, | ||
293 | PM3VideoControl_ENABLE | | ||
294 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
295 | | | ||
296 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
297 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
298 | /* Generated mode : "800x600-75" */ | ||
299 | { | ||
300 | "800x600-75", { | ||
301 | 49497, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625, | ||
302 | 800, 0, 8, | ||
303 | PM3VideoControl_ENABLE | | ||
304 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
305 | | | ||
306 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
307 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
308 | /* Generated mode : "800x600-90" */ | ||
309 | { | ||
310 | "800x600-90", { | ||
311 | 56637, 800, 600, 8, 72, 192, 992, 8, 19, 35, 635, | ||
312 | 800, 0, 8, | ||
313 | PM3VideoControl_ENABLE | | ||
314 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
315 | | | ||
316 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
317 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
318 | /* Generated mode : "800x600-100", from /etc/fb.modes */ | ||
319 | /* DISABLED, hsstart == 0 | ||
320 | { | ||
321 | "800x600-100", { | ||
322 | 67499, 800, 600, 0, 64, 280, 1080, 7, 11, 25, 625, | ||
323 | 800, 0, 8, | ||
324 | PM3VideoControl_ENABLE | | ||
325 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
326 | | | ||
327 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
328 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
329 | */ | ||
330 | /* Generated mode : "800x600-100", from ??? */ | ||
331 | { | ||
332 | "800x600-100", { | ||
333 | 69650, 800, 600, 64, 128, 288, 1088, 4, 10, 40, 640, 800, 0, 8, | ||
334 | PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW| | ||
335 | PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
336 | /* Generated mode : "1024x768-43-lace" */ | ||
337 | /* INTERLACED NOT SUPPORTED | ||
338 | {"1024x768-43-lace", {44899, 1024, 768, 8, 184, 240, 1264, 1, 9, 49, 817, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
339 | INTERLACED NOT SUPPORTED */ | ||
340 | /* Generated mode : "1024x768-60" */ | ||
341 | { | ||
342 | "1024x768-60", { | ||
343 | 64998, 1024, 768, 24, 160, 320, 1344, 3, 9, 38, | ||
344 | 806, 1024, 0, 8, | ||
345 | PM3VideoControl_ENABLE | | ||
346 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
347 | | | ||
348 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
349 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
350 | /* Generated mode : "1024x768-70" */ | ||
351 | { | ||
352 | "1024x768-70", { | ||
353 | 74996, 1024, 768, 24, 160, 304, 1328, 3, 9, 38, | ||
354 | 806, 1024, 0, 8, | ||
355 | PM3VideoControl_ENABLE | | ||
356 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
357 | | | ||
358 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
359 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
360 | /* Generated mode : "1024x768-72" */ | ||
361 | { | ||
362 | "1024x768-72", { | ||
363 | 74996, 10224, 768, 24, 160, 264, 10488, 3, 9, 38, | ||
364 | 806, 10224, 0, 8, | ||
365 | PM3VideoControl_ENABLE | | ||
366 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
367 | | | ||
368 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
369 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
370 | /* Generated mode : "1024x768-75" */ | ||
371 | { | ||
372 | "1024x768-75", { | ||
373 | 78746, 1024, 768, 16, 112, 288, 1312, 1, 4, 32, | ||
374 | 800, 1024, 0, 8, | ||
375 | PM3VideoControl_ENABLE | | ||
376 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
377 | | | ||
378 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
379 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
380 | /* Generated mode : "1024x768-90" */ | ||
381 | { | ||
382 | "1024x768-90", { | ||
383 | 100000, 1024, 768, 0, 96, 288, 1312, 21, 36, 77, | ||
384 | 845, 1024, 0, 8, | ||
385 | PM3VideoControl_ENABLE | | ||
386 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
387 | | | ||
388 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
389 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
390 | /* Generated mode : "1024x768-100", from /etc/fb.modes */ | ||
391 | /* DISABLED, vsstart == 0 | ||
392 | { | ||
393 | "1024x768-100", { | ||
394 | 109998, 1024, 768, 0, 88, 368, 1392, 0, 8, 24, 792, | ||
395 | 1024, 0, 8, | ||
396 | PM3VideoControl_ENABLE | | ||
397 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
398 | | | ||
399 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
400 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
401 | */ | ||
402 | /* Generated mode : "1024x768-100", from ??? */ | ||
403 | { | ||
404 | "1024x768-100", { | ||
405 | 115500, 1024, 768, 32, 224, 416, 1440, 3, 13, 34, 802, 1024, 0, 8, | ||
406 | PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW| | ||
407 | PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
408 | /* Generated mode : "1152x864-43-lace" */ | ||
409 | /* INTERLACED NOT SUPPORTED | ||
410 | {"1152x864-43-lace", {64998, 1152, 864, 72, 200, 264, 1416, 78, 87, 191, 1055, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
411 | INTERLACED NOT SUPPORTED */ | ||
412 | /* Generated mode : "1152x864-47-lace" */ | ||
413 | /* INTERLACED NOT SUPPORTED | ||
414 | {"1152x864-47-lace", {64998, 1152, 864, 88, 216, 296, 1448, 30, 39, 83, 947, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
415 | INTERLACED NOT SUPPORTED */ | ||
416 | /* Generated mode : "1152x864-60" */ | ||
417 | { | ||
418 | "1152x864-60", { | ||
419 | 80000, 1152, 864, 64, 176, 304, 1456, 6, 11, 52, | ||
420 | 916, 1152, 0, 8, | ||
421 | PM3VideoControl_ENABLE | | ||
422 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
423 | | | ||
424 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
425 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
426 | /* Generated mode : "1152x864-70" */ | ||
427 | { | ||
428 | "1152x864-70", { | ||
429 | 100000, 1152, 864, 40, 192, 360, 1512, 13, 24, 81, | ||
430 | 945, 1152, 0, 8, | ||
431 | PM3VideoControl_ENABLE | | ||
432 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
433 | | | ||
434 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
435 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
436 | /* Generated mode : "1152x864-75" */ | ||
437 | { | ||
438 | "1152x864-75", { | ||
439 | 109998, 1152, 864, 24, 168, 312, 1464, 45, 53, 138, | ||
440 | 1002, 1152, 0, 8, | ||
441 | PM3VideoControl_ENABLE | | ||
442 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
443 | | | ||
444 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
445 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
446 | /* Generated mode : "1152x864-80" */ | ||
447 | { | ||
448 | "1152x864-80", { | ||
449 | 109998, 1152, 864, 16, 128, 288, 1440, 30, 37, 94, | ||
450 | 958, 1152, 0, 8, | ||
451 | PM3VideoControl_ENABLE | | ||
452 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
453 | | | ||
454 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
455 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
456 | /* Generated mode : "1280x1024-43-lace" */ | ||
457 | /* INTERLACED NOT SUPPORTED | ||
458 | {"1280x1024-43-lace", {80000, 1024, 1024, 80, 160, 320, 1344, 50, 60, 125, 1149, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
459 | INTERLACED NOT SUPPORTED */ | ||
460 | /* Generated mode : "1280x1024-47-lace" */ | ||
461 | /* INTERLACED NOT SUPPORTED | ||
462 | {"1280x1024-47-lace", {80000, 1280, 1024, 80, 160, 320, 1600, 1, 11, 29, 1053, 1280, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}}, | ||
463 | INTERLACED NOT SUPPORTED */ | ||
464 | /* Generated mode : "1280x1024-60" */ | ||
465 | { | ||
466 | "1280x1024-60", { | ||
467 | 107991, 1280, 1024, 48, 160, 408, 1688, 1, 4, 42, | ||
468 | 1066, 1280, 0, 8, | ||
469 | PM3VideoControl_ENABLE | | ||
470 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
471 | | | ||
472 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
473 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
474 | /* Generated mode : "1280x1024-70" */ | ||
475 | { | ||
476 | "1280x1024-70", { | ||
477 | 125992, 1280, 1024, 80, 192, 408, 1688, 1, 6, 42, | ||
478 | 1066, 1280, 0, 8, | ||
479 | PM3VideoControl_ENABLE | | ||
480 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
481 | | | ||
482 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
483 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
484 | /* Generated mode : "1280x1024-74" */ | ||
485 | { | ||
486 | "1280x1024-74", { | ||
487 | 134989, 1280, 1024, 32, 176, 432, 1712, 0, 30, 40, | ||
488 | 1064, 1280, 0, 8, | ||
489 | PM3VideoControl_ENABLE | | ||
490 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
491 | | | ||
492 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
493 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
494 | /* Generated mode : "1280x1024-75" */ | ||
495 | { | ||
496 | "1280x1024-75", { | ||
497 | 134989, 1280, 1024, 16, 160, 408, 1688, 1, 4, 42, | ||
498 | 1066, 1280, 0, 8, | ||
499 | PM3VideoControl_ENABLE | | ||
500 | PM3VideoControl_HSYNC_ACTIVE_HIGH | ||
501 | | | ||
502 | PM3VideoControl_VSYNC_ACTIVE_HIGH | ||
503 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
504 | /* Generated mode : "1600x1200-60" */ | ||
505 | { | ||
506 | "1600x1200-60", { | ||
507 | 155981, 1600, 1200, 32, 192, 448, 2048, 10, 18, 70, | ||
508 | 1270, 1600, 0, 8, | ||
509 | PM3VideoControl_ENABLE | | ||
510 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
511 | | | ||
512 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
513 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
514 | /* Generated mode : "1600x1200-66" */ | ||
515 | { | ||
516 | "1600x1200-66", { | ||
517 | 171998, 1600, 1200, 40, 176, 480, 2080, 3, 6, 53, | ||
518 | 1253, 1600, 0, 8, | ||
519 | PM3VideoControl_ENABLE | | ||
520 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
521 | | | ||
522 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
523 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
524 | /* Generated mode : "1600x1200-76" */ | ||
525 | { | ||
526 | "1600x1200-76", { | ||
527 | 197980, 1600, 1200, 40, 176, 480, 2080, 3, 8, 50, | ||
528 | 1250, 1600, 0, 8, | ||
529 | PM3VideoControl_ENABLE | | ||
530 | PM3VideoControl_HSYNC_ACTIVE_LOW | ||
531 | | | ||
532 | PM3VideoControl_VSYNC_ACTIVE_LOW | ||
533 | | PM3VideoControl_PIXELSIZE_8BIT}}, | ||
534 | /* ##### end of auto-generated mode */ | ||
535 | { | ||
536 | "\0",} | ||
537 | }; | ||
538 | |||
539 | /* more mandatory stuff (see skeletonfb.c + framebuffer driver HOWTO */ | ||
540 | static struct pm3fb_info fb_info[PM3_MAX_BOARD]; | ||
541 | static struct pm3fb_par current_par[PM3_MAX_BOARD]; | ||
542 | static int current_par_valid[PM3_MAX_BOARD]; | ||
543 | /* to allow explicit filtering of board */ | ||
544 | short bus[PM3_MAX_BOARD]; | ||
545 | short slot[PM3_MAX_BOARD]; | ||
546 | short func[PM3_MAX_BOARD]; | ||
547 | short disable[PM3_MAX_BOARD]; | ||
548 | short noaccel[PM3_MAX_BOARD]; | ||
549 | char fontn[PM3_MAX_BOARD][PM3_FONTNAME_SIZE]; | ||
550 | short depth[PM3_MAX_BOARD]; | ||
551 | short flatpanel[PM3_MAX_BOARD]; | ||
552 | static struct display disp[PM3_MAX_BOARD]; | ||
553 | static char g_options[PM3_OPTIONS_SIZE] __initdata = "pm3fb,dummy"; | ||
554 | short printtimings = 0; | ||
555 | short forcesize[PM3_MAX_BOARD]; | ||
556 | |||
557 | /* ********************* */ | ||
558 | /* ***** prototype ***** */ | ||
559 | /* ********************* */ | ||
560 | /* card-specific */ | ||
561 | static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info); | ||
562 | /* permedia3-specific */ | ||
563 | static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info); | ||
564 | static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info); | ||
565 | static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info); | ||
566 | static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info, | ||
567 | unsigned long r); | ||
568 | static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */ | ||
569 | unsigned long refclock, /* In kHz units */ | ||
570 | unsigned char *prescale, /* ClkPreScale */ | ||
571 | unsigned char *feedback, /* ClkFeedBackScale */ | ||
572 | unsigned char *postscale | ||
573 | /* ClkPostScale */ ); | ||
574 | static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc); | ||
575 | static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b); | ||
576 | static void pm3fb_common_init(struct pm3fb_info *l_fb_info); | ||
577 | static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info, | ||
578 | unsigned long depth, int v); | ||
579 | static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info, | ||
580 | unsigned long depth, int v); | ||
581 | static void pm3fb_mapIO(struct pm3fb_info *l_fb_info); | ||
582 | static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info); | ||
583 | #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) | ||
584 | static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info); | ||
585 | #endif | ||
586 | static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info); | ||
587 | static void pm3fb_write_mode(struct pm3fb_info *l_fb_info); | ||
588 | static void pm3fb_read_mode(struct pm3fb_info *l_fb_info, | ||
589 | struct pm3fb_par *curpar); | ||
590 | static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info); | ||
591 | /* accelerated permedia3-specific */ | ||
592 | #ifdef PM3FB_USE_ACCEL | ||
593 | static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info); | ||
594 | static void pm3fb_init_engine(struct pm3fb_info *l_fb_info); | ||
595 | #ifdef FBCON_HAS_CFB32 | ||
596 | static void pm3fb_cfb32_clear(struct vc_data *conp, | ||
597 | struct display *p, | ||
598 | int sy, int sx, int height, int width); | ||
599 | static void pm3fb_cfb32_clear_margins(struct vc_data *conp, | ||
600 | struct display *p, int bottom_only); | ||
601 | #endif /* FBCON_HAS_CFB32 */ | ||
602 | #ifdef FBCON_HAS_CFB16 | ||
603 | static void pm3fb_cfb16_clear(struct vc_data *conp, | ||
604 | struct display *p, | ||
605 | int sy, int sx, int height, int width); | ||
606 | static void pm3fb_cfb16_clear_margins(struct vc_data *conp, | ||
607 | struct display *p, int bottom_only); | ||
608 | #endif /* FBCON_HAS_CFB16 */ | ||
609 | #ifdef FBCON_HAS_CFB8 | ||
610 | static void pm3fb_cfb8_clear(struct vc_data *conp, | ||
611 | struct display *p, | ||
612 | int sy, int sx, int height, int width); | ||
613 | static void pm3fb_cfb8_clear_margins(struct vc_data *conp, | ||
614 | struct display *p, int bottom_only); | ||
615 | #endif /* FBCON_HAS_CFB8 */ | ||
616 | #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32) | ||
617 | static void pm3fb_cfbX_bmove(struct display *p, | ||
618 | int sy, int sx, | ||
619 | int dy, int dx, int height, int width); | ||
620 | static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p, | ||
621 | int c, int yy, int xx); | ||
622 | static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p, | ||
623 | const unsigned short *s, int count, int yy, | ||
624 | int xx); | ||
625 | static void pm3fb_cfbX_revc(struct display *p, int xx, int yy); | ||
626 | #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */ | ||
627 | #endif /* PM3FB_USE_ACCEL */ | ||
628 | /* pre-init */ | ||
629 | static void pm3fb_mode_setup(char *mode, unsigned long board_num); | ||
630 | static void pm3fb_pciid_setup(char *pciid, unsigned long board_num); | ||
631 | static char *pm3fb_boardnum_setup(char *options, unsigned long *bn); | ||
632 | static void pm3fb_real_setup(char *options); | ||
633 | /* fbdev */ | ||
634 | static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix, | ||
635 | const void *par, struct fb_info_gen *info); | ||
636 | static int pm3fb_decode_var(const struct fb_var_screeninfo *var, | ||
637 | void *par, struct fb_info_gen *info); | ||
638 | static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d); | ||
639 | static int pm3fb_encode_var(struct fb_var_screeninfo *var, | ||
640 | const void *par, struct fb_info_gen *info); | ||
641 | static void pm3fb_get_par(void *par, struct fb_info_gen *info); | ||
642 | static void pm3fb_set_par(const void *par, struct fb_info_gen *info); | ||
643 | static void pm3fb_set_color(struct pm3fb_info *l_fb_info, | ||
644 | unsigned char regno, unsigned char r, | ||
645 | unsigned char g, unsigned char b); | ||
646 | static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green, | ||
647 | unsigned *blue, unsigned *transp, | ||
648 | struct fb_info *info); | ||
649 | static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green, | ||
650 | unsigned blue, unsigned transp, | ||
651 | struct fb_info *info); | ||
652 | static int pm3fb_blank(int blank_mode, struct fb_info_gen *info); | ||
653 | static void pm3fb_set_disp(const void *par, struct display *disp, | ||
654 | struct fb_info_gen *info); | ||
655 | static void pm3fb_detect(void); | ||
656 | static int pm3fb_pan_display(const struct fb_var_screeninfo *var, | ||
657 | struct fb_info_gen *info); | ||
658 | static int pm3fb_ioctl(struct fb_info *info, u_int cmd, u_long arg); | ||
659 | |||
660 | |||
661 | /* the struct that hold them together */ | ||
662 | struct fbgen_hwswitch pm3fb_switch = { | ||
663 | pm3fb_detect, pm3fb_encode_fix, pm3fb_decode_var, pm3fb_encode_var, | ||
664 | pm3fb_get_par, pm3fb_set_par, pm3fb_getcolreg, | ||
665 | pm3fb_pan_display, pm3fb_blank, pm3fb_set_disp | ||
666 | }; | ||
667 | 53 | ||
668 | static struct fb_ops pm3fb_ops = { | 54 | /* |
669 | .owner = THIS_MODULE, | 55 | * If your driver supports multiple boards, you should make the |
670 | .fb_get_fix = fbgen_get_fix, | 56 | * below data types arrays, or allocate them dynamically (using kmalloc()). |
671 | .fb_get_var = fbgen_get_var, | 57 | */ |
672 | .fb_set_var = fbgen_set_var, | ||
673 | .fb_get_cmap = fbgen_get_cmap, | ||
674 | .fb_set_cmap = fbgen_set_cmap, | ||
675 | .fb_setcolreg = pm3fb_setcolreg, | ||
676 | .fb_pan_display =fbgen_pan_display, | ||
677 | .fb_blank = fbgen_blank, | ||
678 | .fb_ioctl = pm3fb_ioctl, | ||
679 | }; | ||
680 | 58 | ||
681 | #ifdef PM3FB_USE_ACCEL | 59 | /* |
682 | #ifdef FBCON_HAS_CFB32 | 60 | * This structure defines the hardware state of the graphics card. Normally |
683 | static struct display_switch pm3fb_cfb32 = { | 61 | * you place this in a header file in linux/include/video. This file usually |
684 | fbcon_cfb32_setup, pm3fb_cfbX_bmove, pm3fb_cfb32_clear, | 62 | * also includes register information. That allows other driver subsystems |
685 | pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc, | 63 | * and userland applications the ability to use the same header file to |
686 | NULL /* cursor() */ , NULL /* set_font() */ , | 64 | * avoid duplicate work and easy porting of software. |
687 | pm3fb_cfb32_clear_margins, | 65 | */ |
688 | FONTWIDTHRANGE(1, 16) /* true only if accelerated... */ | 66 | struct pm3_par { |
689 | }; | 67 | unsigned char __iomem *v_regs;/* virtual address of p_regs */ |
690 | #endif /* FBCON_HAS_CFB32 */ | 68 | u32 video; /* video flags before blanking */ |
691 | #ifdef FBCON_HAS_CFB16 | 69 | u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */ |
692 | static struct display_switch pm3fb_cfb16 = { | 70 | u32 palette[16]; |
693 | fbcon_cfb16_setup, pm3fb_cfbX_bmove, pm3fb_cfb16_clear, | ||
694 | pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc, | ||
695 | NULL /* cursor() */ , NULL /* set_font() */ , | ||
696 | pm3fb_cfb16_clear_margins, | ||
697 | FONTWIDTHRANGE(1, 16) /* true only if accelerated... */ | ||
698 | }; | ||
699 | #endif /* FBCON_HAS_CFB16 */ | ||
700 | #ifdef FBCON_HAS_CFB8 | ||
701 | static struct display_switch pm3fb_cfb8 = { | ||
702 | fbcon_cfb8_setup, pm3fb_cfbX_bmove, pm3fb_cfb8_clear, | ||
703 | pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc, | ||
704 | NULL /* cursor() */ , NULL /* set_font() */ , | ||
705 | pm3fb_cfb8_clear_margins, | ||
706 | FONTWIDTHRANGE(1, 16) /* true only if accelerated... */ | ||
707 | }; | ||
708 | #endif /* FBCON_HAS_CFB8 */ | ||
709 | #endif /* PM3FB_USE_ACCEL */ | ||
710 | |||
711 | /* ****************************** */ | ||
712 | /* ***** card-specific data ***** */ | ||
713 | /* ****************************** */ | ||
714 | struct pm3fb_card_timings { | ||
715 | unsigned long memsize; /* 0 for last value (i.e. default) */ | ||
716 | struct pm3fb_timings memt; | ||
717 | }; | 71 | }; |
718 | 72 | ||
719 | static struct pm3fb_card_timings t_FormacProFormance3[] = { | 73 | /* |
720 | { 16, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} }, | 74 | * Here we define the default structs fb_fix_screeninfo and fb_var_screeninfo |
721 | { 0, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} } /* from 16 MB PF3 */ | 75 | * if we don't use modedb. If we do use modedb see pm3fb_init how to use it |
76 | * to get a fb_var_screeninfo. Otherwise define a default var as well. | ||
77 | */ | ||
78 | static struct fb_fix_screeninfo pm3fb_fix __devinitdata = { | ||
79 | .id = "Permedia3", | ||
80 | .type = FB_TYPE_PACKED_PIXELS, | ||
81 | .visual = FB_VISUAL_PSEUDOCOLOR, | ||
82 | .xpanstep = 1, | ||
83 | .ypanstep = 1, | ||
84 | .ywrapstep = 0, | ||
85 | .accel = FB_ACCEL_NONE, | ||
722 | }; | 86 | }; |
723 | 87 | ||
724 | static struct pm3fb_card_timings t_AppianJeronimo2000[] = { | 88 | /* |
725 | { 32, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} }, | 89 | * Utility functions |
726 | { 0, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} } /* from 32MB J2000 */ | 90 | */ |
727 | }; | ||
728 | 91 | ||
729 | static struct pm3fb_card_timings t_3DLabsOxygenVX1[] = { | 92 | static inline u32 PM3_READ_REG(struct pm3_par *par, s32 off) |
730 | { 32, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} }, | 93 | { |
731 | { 0, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} } /* from 32MB VX1 */ | 94 | return fb_readl(par->v_regs + off); |
732 | }; | 95 | } |
733 | 96 | ||
734 | static struct { | 97 | static inline void PM3_WRITE_REG(struct pm3_par *par, s32 off, u32 v) |
735 | char cardname[32]; /* recognized card name */ | 98 | { |
736 | u16 subvendor; /* subvendor of the card */ | 99 | fb_writel(v, par->v_regs + off); |
737 | u16 subdevice; /* subdevice of the card */ | 100 | } |
738 | u8 func; /* function of the card to which the extra init apply */ | ||
739 | void (*specific_setup)(struct pm3fb_info *l_fb_info); /* card/func specific setup, done before _any_ FB access */ | ||
740 | struct pm3fb_card_timings *c_memt; /* defauls timings for the boards */ | ||
741 | } cardbase[] = { | ||
742 | { "Unknown Permedia3 board", 0xFFFF, 0xFFFF, 0xFF, NULL, NULL }, | ||
743 | { "Appian Jeronimo 2000 head 1", 0x1097, 0x3d32, 1, NULL, | ||
744 | t_AppianJeronimo2000 | ||
745 | }, | ||
746 | { "Appian Jeronimo 2000 head 2", 0x1097, 0x3d32, 2, pm3fb_j2000_setup, | ||
747 | t_AppianJeronimo2000 | ||
748 | }, | ||
749 | { "Formac ProFormance 3", PCI_VENDOR_ID_3DLABS, 0x000a, 0, NULL, /* Formac use 3DLabs ID ?!? */ | ||
750 | t_FormacProFormance3 | ||
751 | }, | ||
752 | { "3DLabs Permedia3 Create!", PCI_VENDOR_ID_3DLABS, 0x0127, 0, NULL, NULL }, | ||
753 | { "3DLabs Oxygen VX1 PCI", PCI_VENDOR_ID_3DLABS, 0x0121, 0, NULL, | ||
754 | t_3DLabsOxygenVX1 | ||
755 | }, | ||
756 | { "3DLabs Oxygen VX1 AGP", PCI_VENDOR_ID_3DLABS, 0x0125, 0, NULL, NULL }, | ||
757 | { "3DLabs Oxygen VX1-16 AGP", PCI_VENDOR_ID_3DLABS, 0x0140, 0, NULL, NULL }, | ||
758 | { "3DLabs Oxygen VX1-1600SW PCI", PCI_VENDOR_ID_3DLABS, 0x0800, 0, NULL, NULL }, | ||
759 | { "\0", 0x0, 0x0, 0, NULL, NULL } | ||
760 | }; | ||
761 | 101 | ||
762 | /* ********************************** */ | 102 | static inline void PM3_WAIT(struct pm3_par *par, u32 n) |
763 | /* ***** card-specific function ***** */ | 103 | { |
764 | /* ********************************** */ | 104 | while (PM3_READ_REG(par, PM3InFIFOSpace) < n); |
765 | static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info) | ||
766 | { /* the appian j2000 require more initialization of the second head */ | ||
767 | /* l_fb_info must point to the _second_ head of the J2000 */ | ||
768 | |||
769 | DTRACE; | ||
770 | |||
771 | l_fb_info->memt = t_AppianJeronimo2000[0].memt; /* 32 MB, first and only j2000 ? */ | ||
772 | |||
773 | pm3fb_write_memory_timings(l_fb_info); | ||
774 | } | 105 | } |
775 | 106 | ||
776 | /* *************************************** */ | 107 | static inline void PM3_SLOW_WRITE_REG(struct pm3_par *par, s32 off, u32 v) |
777 | /* ***** permedia3-specific function ***** */ | ||
778 | /* *************************************** */ | ||
779 | static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info) | ||
780 | { | 108 | { |
781 | l_fb_info->memt.caps = PM3_READ_REG(PM3LocalMemCaps); | 109 | if (par->v_regs) { |
782 | l_fb_info->memt.timings = PM3_READ_REG(PM3LocalMemTimings); | 110 | mb(); |
783 | l_fb_info->memt.control = PM3_READ_REG(PM3LocalMemControl); | 111 | PM3_WAIT(par, 1); |
784 | l_fb_info->memt.refresh = PM3_READ_REG(PM3LocalMemRefresh); | 112 | wmb(); |
785 | l_fb_info->memt.powerdown = PM3_READ_REG(PM3LocalMemPowerDown); | 113 | PM3_WRITE_REG(par, off, v); |
786 | |||
787 | if ((l_fb_info->memt.caps == PM3FB_UNKNOWN_TIMING_VALUE) || | ||
788 | (l_fb_info->memt.timings == PM3FB_UNKNOWN_TIMING_VALUE) || | ||
789 | (l_fb_info->memt.control == PM3FB_UNKNOWN_TIMING_VALUE) || | ||
790 | (l_fb_info->memt.refresh == PM3FB_UNKNOWN_TIMING_VALUE) || | ||
791 | (l_fb_info->memt.powerdown == PM3FB_UNKNOWN_TIMING_VALUE)) | ||
792 | { | ||
793 | printk(KERN_ERR "pm3fb: invalid memory timings in permedia3 board #%ld\n", l_fb_info->board_num); | ||
794 | return(pm3fb_try_memory_timings(l_fb_info)); | ||
795 | } | 114 | } |
796 | return(pm3fb_timing_ok); | ||
797 | } | 115 | } |
798 | 116 | ||
799 | static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info) | 117 | static inline void PM3_SET_INDEX(struct pm3_par *par, unsigned index) |
800 | { | 118 | { |
801 | if (cardbase[l_fb_info->board_type].c_memt) | 119 | PM3_SLOW_WRITE_REG(par, PM3RD_IndexHigh, (index >> 8) & 0xff); |
802 | { | 120 | PM3_SLOW_WRITE_REG(par, PM3RD_IndexLow, index & 0xff); |
803 | int i = 0, done = 0; | 121 | } |
804 | while (!done) | 122 | |
805 | { | 123 | static inline void PM3_WRITE_DAC_REG(struct pm3_par *par, unsigned r, u8 v) |
806 | if ((cardbase[l_fb_info->board_type].c_memt[i].memsize == l_fb_info->fb_size) | 124 | { |
807 | || !(cardbase[l_fb_info->board_type].c_memt[i].memsize)) | 125 | PM3_SET_INDEX(par, r); |
808 | { /* will use the 0-sized timings by default */ | 126 | wmb(); |
809 | done = 1; | 127 | PM3_WRITE_REG(par, PM3RD_IndexedData, v); |
810 | l_fb_info->memt = cardbase[l_fb_info->board_type].c_memt[i].memt; | ||
811 | printk(KERN_WARNING "pm3fb: trying to use predefined memory timings for permedia3 board #%ld (%s, %ld MB)\n", | ||
812 | l_fb_info->board_num, | ||
813 | cardbase[l_fb_info->board_type].cardname, | ||
814 | cardbase[l_fb_info->board_type].c_memt[i].memsize); | ||
815 | pm3fb_write_memory_timings(l_fb_info); | ||
816 | return(pm3fb_timing_retry); | ||
817 | } | ||
818 | i++; | ||
819 | } | ||
820 | } else | ||
821 | return(pm3fb_timing_problem); | ||
822 | return(pm3fb_timing_ok); | ||
823 | } | 128 | } |
824 | 129 | ||
825 | static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info) | 130 | static inline void pm3fb_set_color(struct pm3_par *par, unsigned char regno, |
131 | unsigned char r, unsigned char g, unsigned char b) | ||
826 | { | 132 | { |
827 | unsigned char m, n, p; | 133 | PM3_SLOW_WRITE_REG(par, PM3RD_PaletteWriteAddress, regno); |
828 | unsigned long clockused; | 134 | PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, r); |
829 | 135 | PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, g); | |
830 | PM3_SLOW_WRITE_REG(PM3LocalMemCaps, l_fb_info->memt.caps); | 136 | PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, b); |
831 | PM3_SLOW_WRITE_REG(PM3LocalMemTimings, l_fb_info->memt.timings); | ||
832 | PM3_SLOW_WRITE_REG(PM3LocalMemControl, l_fb_info->memt.control); | ||
833 | PM3_SLOW_WRITE_REG(PM3LocalMemRefresh, l_fb_info->memt.refresh); | ||
834 | PM3_SLOW_WRITE_REG(PM3LocalMemPowerDown, l_fb_info->memt.powerdown); | ||
835 | |||
836 | clockused = | ||
837 | pm3fb_CalculateClock(l_fb_info, 2 * 105000, PM3_REF_CLOCK, &m, | ||
838 | &n, &p); | ||
839 | |||
840 | PM3_WRITE_DAC_REG(PM3RD_KClkPreScale, m); | ||
841 | PM3_WRITE_DAC_REG(PM3RD_KClkFeedbackScale, n); | ||
842 | PM3_WRITE_DAC_REG(PM3RD_KClkPostScale, p); | ||
843 | PM3_WRITE_DAC_REG(PM3RD_KClkControl, | ||
844 | PM3RD_KClkControl_STATE_RUN | | ||
845 | PM3RD_KClkControl_SOURCE_PLL | | ||
846 | PM3RD_KClkControl_ENABLE); | ||
847 | PM3_WRITE_DAC_REG(PM3RD_MClkControl, | ||
848 | PM3RD_MClkControl_STATE_RUN | | ||
849 | PM3RD_MClkControl_SOURCE_KCLK | | ||
850 | PM3RD_MClkControl_ENABLE); | ||
851 | PM3_WRITE_DAC_REG(PM3RD_SClkControl, | ||
852 | PM3RD_SClkControl_STATE_RUN | | ||
853 | PM3RD_SClkControl_SOURCE_PCLK | | ||
854 | PM3RD_SClkControl_ENABLE); | ||
855 | } | 137 | } |
856 | 138 | ||
857 | static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info, | 139 | static void pm3fb_clear_colormap(struct pm3_par *par, |
858 | unsigned long r) | 140 | unsigned char r, unsigned char g, unsigned char b) |
859 | { | 141 | { |
860 | DASSERT((l_fb_info->vIOBase != (unsigned char *) (-1)), | 142 | int i; |
861 | "l_fb_info->vIOBase mapped in read dac reg\n"); | 143 | |
862 | PM3_SET_INDEX(r); | 144 | for (i = 0; i < 256 ; i++) /* fill color map with white */ |
863 | mb(); | 145 | pm3fb_set_color(par, i, r, g, b); |
864 | return (PM3_READ_REG(PM3RD_IndexedData)); | 146 | |
865 | } | 147 | } |
866 | 148 | ||
867 | /* Calculating various clock parameter */ | 149 | /* Calculating various clock parameter */ |
868 | static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */ | 150 | static void pm3fb_calculate_clock(unsigned long reqclock, |
869 | unsigned long refclock, /* In kHz units */ | 151 | unsigned char *prescale, |
870 | unsigned char *prescale, /* ClkPreScale */ | 152 | unsigned char *feedback, |
871 | unsigned char *feedback, /* ClkFeedBackScale */ | 153 | unsigned char *postscale) |
872 | unsigned char *postscale | ||
873 | /* ClkPostScale */ ) | ||
874 | { | 154 | { |
875 | int f, pre, post; | 155 | int f, pre, post; |
876 | unsigned long freq; | 156 | unsigned long freq; |
877 | long freqerr = 1000; | 157 | long freqerr = 1000; |
878 | unsigned long actualclock = 0; | 158 | long currerr; |
879 | |||
880 | DTRACE; | ||
881 | 159 | ||
882 | for (f = 1; f < 256; f++) { | 160 | for (f = 1; f < 256; f++) { |
883 | for (pre = 1; pre < 256; pre++) { | 161 | for (pre = 1; pre < 256; pre++) { |
884 | for (post = 0; post < 5; post++) { | 162 | for (post = 0; post < 5; post++) { |
885 | freq = | 163 | freq = ((2*PM3_REF_CLOCK * f) >> post) / pre; |
886 | ((2 * refclock * f) / | 164 | currerr = (reqclock > freq) |
887 | (pre * (1 << post))); | 165 | ? reqclock - freq |
888 | if ((reqclock > freq - freqerr) | 166 | : freq - reqclock; |
889 | && (reqclock < freq + freqerr)) { | 167 | if (currerr < freqerr) { |
890 | freqerr = | 168 | freqerr = currerr; |
891 | (reqclock > | ||
892 | freq) ? reqclock - | ||
893 | freq : freq - reqclock; | ||
894 | *feedback = f; | 169 | *feedback = f; |
895 | *prescale = pre; | 170 | *prescale = pre; |
896 | *postscale = post; | 171 | *postscale = post; |
897 | actualclock = freq; | ||
898 | } | 172 | } |
899 | } | 173 | } |
900 | } | 174 | } |
901 | } | 175 | } |
902 | |||
903 | return (actualclock); | ||
904 | } | 176 | } |
905 | 177 | ||
906 | static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info, | 178 | static inline int pm3fb_shift_bpp(unsigned long depth, int v) |
907 | unsigned long depth, int v) | ||
908 | { | 179 | { |
909 | DTRACE; | ||
910 | |||
911 | switch (depth) { | 180 | switch (depth) { |
912 | case 8: | 181 | case 8: |
913 | return (v >> 4); | 182 | return (v >> 4); |
@@ -918,181 +187,59 @@ static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info, | |||
918 | case 32: | 187 | case 32: |
919 | return (v >> 2); | 188 | return (v >> 2); |
920 | } | 189 | } |
921 | DPRINTK(1, "Unsupported depth %ld\n", depth); | 190 | DPRINTK("Unsupported depth %ld\n", depth); |
922 | return (0); | 191 | return 0; |
923 | } | ||
924 | |||
925 | static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info, | ||
926 | unsigned long depth, int v) | ||
927 | { | ||
928 | DTRACE; | ||
929 | |||
930 | switch (depth) { | ||
931 | case 8: | ||
932 | return (v << 4); | ||
933 | case 12: | ||
934 | case 15: | ||
935 | case 16: | ||
936 | return (v << 3); | ||
937 | case 32: | ||
938 | return (v << 2); | ||
939 | } | ||
940 | DPRINTK(1, "Unsupported depth %ld\n", depth); | ||
941 | return (0); | ||
942 | } | ||
943 | |||
944 | static void pm3fb_mapIO(struct pm3fb_info *l_fb_info) | ||
945 | { | ||
946 | DTRACE; | ||
947 | |||
948 | l_fb_info->vIOBase = | ||
949 | ioremap((unsigned long) l_fb_info->pIOBase, PM3_REGS_SIZE); | ||
950 | l_fb_info->v_fb = | ||
951 | ioremap((unsigned long) l_fb_info->p_fb, l_fb_info->fb_size); | ||
952 | DPRINTK(2, "IO mapping : IOBase %lx / %lx, fb %lx / %lx\n", | ||
953 | (unsigned long) l_fb_info->pIOBase, | ||
954 | (unsigned long) l_fb_info->vIOBase, | ||
955 | (unsigned long) l_fb_info->p_fb, | ||
956 | (unsigned long) l_fb_info->v_fb); | ||
957 | } | ||
958 | |||
959 | static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info) | ||
960 | { | ||
961 | DTRACE; | ||
962 | |||
963 | iounmap(l_fb_info->vIOBase); | ||
964 | iounmap(l_fb_info->v_fb); | ||
965 | l_fb_info->vIOBase = (unsigned char *) -1; | ||
966 | l_fb_info->v_fb = (unsigned char *) -1; | ||
967 | } | ||
968 | |||
969 | #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) | ||
970 | static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info) | ||
971 | { | ||
972 | DPRINTK(2, "PM3Aperture0: 0x%08x\n", PM3_READ_REG(PM3Aperture0)); | ||
973 | DPRINTK(2, "PM3Aperture1: 0x%08x\n", PM3_READ_REG(PM3Aperture1)); | ||
974 | DPRINTK(2, "PM3ByAperture1Mode: 0x%08x\n", | ||
975 | PM3_READ_REG(PM3ByAperture1Mode)); | ||
976 | DPRINTK(2, "PM3ByAperture2Mode: 0x%08x\n", | ||
977 | PM3_READ_REG(PM3ByAperture2Mode)); | ||
978 | DPRINTK(2, "PM3ChipConfig: 0x%08x\n", PM3_READ_REG(PM3ChipConfig)); | ||
979 | DPRINTK(2, "PM3FIFODis: 0x%08x\n", PM3_READ_REG(PM3FIFODis)); | ||
980 | DPRINTK(2, "PM3HTotal: 0x%08x\n", PM3_READ_REG(PM3HTotal)); | ||
981 | DPRINTK(2, "PM3HbEnd: 0x%08x\n", PM3_READ_REG(PM3HbEnd)); | ||
982 | DPRINTK(2, "PM3HgEnd: 0x%08x\n", PM3_READ_REG(PM3HgEnd)); | ||
983 | DPRINTK(2, "PM3HsEnd: 0x%08x\n", PM3_READ_REG(PM3HsEnd)); | ||
984 | DPRINTK(2, "PM3HsStart: 0x%08x\n", PM3_READ_REG(PM3HsStart)); | ||
985 | DPRINTK(2, "PM3MemBypassWriteMask: 0x%08x\n", | ||
986 | PM3_READ_REG(PM3MemBypassWriteMask)); | ||
987 | DPRINTK(2, "PM3RD_IndexControl: 0x%08x\n", | ||
988 | PM3_READ_REG(PM3RD_IndexControl)); | ||
989 | DPRINTK(2, "PM3ScreenBase: 0x%08x\n", PM3_READ_REG(PM3ScreenBase)); | ||
990 | DPRINTK(2, "PM3ScreenStride: 0x%08x\n", | ||
991 | PM3_READ_REG(PM3ScreenStride)); | ||
992 | DPRINTK(2, "PM3VClkCtl: 0x%08x\n", PM3_READ_REG(PM3VClkCtl)); | ||
993 | DPRINTK(2, "PM3VTotal: 0x%08x\n", PM3_READ_REG(PM3VTotal)); | ||
994 | DPRINTK(2, "PM3VbEnd: 0x%08x\n", PM3_READ_REG(PM3VbEnd)); | ||
995 | DPRINTK(2, "PM3VideoControl: 0x%08x\n", | ||
996 | PM3_READ_REG(PM3VideoControl)); | ||
997 | DPRINTK(2, "PM3VsEnd: 0x%08x\n", PM3_READ_REG(PM3VsEnd)); | ||
998 | DPRINTK(2, "PM3VsStart: 0x%08x\n", PM3_READ_REG(PM3VsStart)); | ||
999 | |||
1000 | DPRINTK(2, "PM3RD_ColorFormat: %ld\n", | ||
1001 | PM3_READ_DAC_REG(PM3RD_ColorFormat)); | ||
1002 | DPRINTK(2, "PM3RD_DACControl: %ld\n", | ||
1003 | PM3_READ_DAC_REG(PM3RD_DACControl)); | ||
1004 | DPRINTK(2, "PM3RD_DClk0FeedbackScale: %ld\n", | ||
1005 | PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale)); | ||
1006 | DPRINTK(2, "PM3RD_DClk0PostScale: %ld\n", | ||
1007 | PM3_READ_DAC_REG(PM3RD_DClk0PostScale)); | ||
1008 | DPRINTK(2, "PM3RD_DClk0PreScale: %ld\n", | ||
1009 | PM3_READ_DAC_REG(PM3RD_DClk0PreScale)); | ||
1010 | DPRINTK(2, "[not set] PM3RD_IndexControl: %ld\n", | ||
1011 | PM3_READ_DAC_REG(PM3RD_IndexControl)); | ||
1012 | DPRINTK(2, "PM3RD_MiscControl: %ld\n", | ||
1013 | PM3_READ_DAC_REG(PM3RD_MiscControl)); | ||
1014 | DPRINTK(2, "PM3RD_PixelSize: %ld\n", | ||
1015 | PM3_READ_DAC_REG(PM3RD_PixelSize)); | ||
1016 | DPRINTK(2, "PM3RD_SyncControl: %ld\n", | ||
1017 | PM3_READ_DAC_REG(PM3RD_SyncControl)); | ||
1018 | } | ||
1019 | |||
1020 | #endif /* defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) */ | ||
1021 | static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info) | ||
1022 | { | ||
1023 | u16 subvendor, subdevice; | ||
1024 | |||
1025 | if ((!pci_read_config_word | ||
1026 | (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor)) | ||
1027 | && | ||
1028 | (!pci_read_config_word | ||
1029 | (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) { | ||
1030 | /* well, nothing... */ | ||
1031 | } else { | ||
1032 | subvendor = subdevice = (u16)-1; | ||
1033 | } | ||
1034 | |||
1035 | printk(KERN_INFO "pm3fb: memory timings for board #%ld (subvendor: 0x%hx, subdevice: 0x%hx)\n", l_fb_info->board_num, subvendor, subdevice); | ||
1036 | printk(KERN_INFO " PM3LocalMemCaps: 0x%08x\n", | ||
1037 | PM3_READ_REG(PM3LocalMemCaps)); | ||
1038 | printk(KERN_INFO " PM3LocalMemTimings: 0x%08x\n", | ||
1039 | PM3_READ_REG(PM3LocalMemTimings)); | ||
1040 | printk(KERN_INFO " PM3LocalMemControl: 0x%08x\n", | ||
1041 | PM3_READ_REG(PM3LocalMemControl)); | ||
1042 | printk(KERN_INFO " PM3LocalMemRefresh: 0x%08x\n", | ||
1043 | PM3_READ_REG(PM3LocalMemRefresh)); | ||
1044 | printk(KERN_INFO " PM3LocalMemPowerDown: 0x%08x\n", | ||
1045 | PM3_READ_REG(PM3LocalMemPowerDown)); | ||
1046 | } | 192 | } |
1047 | 193 | ||
1048 | /* write the mode to registers */ | 194 | /* write the mode to registers */ |
1049 | static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | 195 | static void pm3fb_write_mode(struct fb_info *info) |
1050 | { | 196 | { |
197 | struct pm3_par *par = info->par; | ||
1051 | char tempsync = 0x00, tempmisc = 0x00; | 198 | char tempsync = 0x00, tempmisc = 0x00; |
1052 | DTRACE; | 199 | const u32 hsstart = info->var.right_margin; |
1053 | 200 | const u32 hsend = hsstart + info->var.hsync_len; | |
1054 | PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xffffffff); | 201 | const u32 hbend = hsend + info->var.left_margin; |
1055 | PM3_SLOW_WRITE_REG(PM3Aperture0, 0x00000000); | 202 | const u32 xres = (info->var.xres + 31) & ~31; |
1056 | PM3_SLOW_WRITE_REG(PM3Aperture1, 0x00000000); | 203 | const u32 htotal = xres + hbend; |
1057 | PM3_SLOW_WRITE_REG(PM3FIFODis, 0x00000007); | 204 | const u32 vsstart = info->var.lower_margin; |
1058 | 205 | const u32 vsend = vsstart + info->var.vsync_len; | |
1059 | PM3_SLOW_WRITE_REG(PM3HTotal, | 206 | const u32 vbend = vsend + info->var.upper_margin; |
1060 | pm3fb_Shiftbpp(l_fb_info, | 207 | const u32 vtotal = info->var.yres + vbend; |
1061 | l_fb_info->current_par->depth, | 208 | const u32 width = (info->var.xres_virtual + 7) & ~7; |
1062 | l_fb_info->current_par->htotal - | 209 | |
1063 | 1)); | 210 | PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, 0xffffffff); |
1064 | PM3_SLOW_WRITE_REG(PM3HsEnd, | 211 | PM3_SLOW_WRITE_REG(par, PM3Aperture0, 0x00000000); |
1065 | pm3fb_Shiftbpp(l_fb_info, | 212 | PM3_SLOW_WRITE_REG(par, PM3Aperture1, 0x00000000); |
1066 | l_fb_info->current_par->depth, | 213 | PM3_SLOW_WRITE_REG(par, PM3FIFODis, 0x00000007); |
1067 | l_fb_info->current_par->hsend)); | 214 | |
1068 | PM3_SLOW_WRITE_REG(PM3HsStart, | 215 | PM3_SLOW_WRITE_REG(par, PM3HTotal, |
1069 | pm3fb_Shiftbpp(l_fb_info, | 216 | pm3fb_shift_bpp(info->var.bits_per_pixel, |
1070 | l_fb_info->current_par->depth, | 217 | htotal - 1)); |
1071 | l_fb_info->current_par-> | 218 | PM3_SLOW_WRITE_REG(par, PM3HsEnd, |
219 | pm3fb_shift_bpp(info->var.bits_per_pixel, | ||
220 | hsend)); | ||
221 | PM3_SLOW_WRITE_REG(par, PM3HsStart, | ||
222 | pm3fb_shift_bpp(info->var.bits_per_pixel, | ||
1072 | hsstart)); | 223 | hsstart)); |
1073 | PM3_SLOW_WRITE_REG(PM3HbEnd, | 224 | PM3_SLOW_WRITE_REG(par, PM3HbEnd, |
1074 | pm3fb_Shiftbpp(l_fb_info, | 225 | pm3fb_shift_bpp(info->var.bits_per_pixel, |
1075 | l_fb_info->current_par->depth, | 226 | hbend)); |
1076 | l_fb_info->current_par->hbend)); | 227 | PM3_SLOW_WRITE_REG(par, PM3HgEnd, |
1077 | PM3_SLOW_WRITE_REG(PM3HgEnd, | 228 | pm3fb_shift_bpp(info->var.bits_per_pixel, |
1078 | pm3fb_Shiftbpp(l_fb_info, | 229 | hbend)); |
1079 | l_fb_info->current_par->depth, | 230 | PM3_SLOW_WRITE_REG(par, PM3ScreenStride, |
1080 | l_fb_info->current_par->hbend)); | 231 | pm3fb_shift_bpp(info->var.bits_per_pixel, |
1081 | PM3_SLOW_WRITE_REG(PM3ScreenStride, | 232 | width)); |
1082 | pm3fb_Shiftbpp(l_fb_info, | 233 | PM3_SLOW_WRITE_REG(par, PM3VTotal, vtotal - 1); |
1083 | l_fb_info->current_par->depth, | 234 | PM3_SLOW_WRITE_REG(par, PM3VsEnd, vsend - 1); |
1084 | l_fb_info->current_par->stride)); | 235 | PM3_SLOW_WRITE_REG(par, PM3VsStart, vsstart - 1); |
1085 | PM3_SLOW_WRITE_REG(PM3VTotal, l_fb_info->current_par->vtotal - 1); | 236 | PM3_SLOW_WRITE_REG(par, PM3VbEnd, vbend); |
1086 | PM3_SLOW_WRITE_REG(PM3VsEnd, l_fb_info->current_par->vsend - 1); | 237 | |
1087 | PM3_SLOW_WRITE_REG(PM3VsStart, | 238 | switch (info->var.bits_per_pixel) { |
1088 | l_fb_info->current_par->vsstart - 1); | ||
1089 | PM3_SLOW_WRITE_REG(PM3VbEnd, l_fb_info->current_par->vbend); | ||
1090 | |||
1091 | switch (l_fb_info->current_par->depth) { | ||
1092 | case 8: | 239 | case 8: |
1093 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 240 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1094 | PM3ByApertureMode_PIXELSIZE_8BIT); | 241 | PM3ByApertureMode_PIXELSIZE_8BIT); |
1095 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 242 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1096 | PM3ByApertureMode_PIXELSIZE_8BIT); | 243 | PM3ByApertureMode_PIXELSIZE_8BIT); |
1097 | break; | 244 | break; |
1098 | 245 | ||
@@ -1100,15 +247,15 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | |||
1100 | case 15: | 247 | case 15: |
1101 | case 16: | 248 | case 16: |
1102 | #ifndef __BIG_ENDIAN | 249 | #ifndef __BIG_ENDIAN |
1103 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 250 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1104 | PM3ByApertureMode_PIXELSIZE_16BIT); | 251 | PM3ByApertureMode_PIXELSIZE_16BIT); |
1105 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 252 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1106 | PM3ByApertureMode_PIXELSIZE_16BIT); | 253 | PM3ByApertureMode_PIXELSIZE_16BIT); |
1107 | #else | 254 | #else |
1108 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 255 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1109 | PM3ByApertureMode_PIXELSIZE_16BIT | | 256 | PM3ByApertureMode_PIXELSIZE_16BIT | |
1110 | PM3ByApertureMode_BYTESWAP_BADC); | 257 | PM3ByApertureMode_BYTESWAP_BADC); |
1111 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 258 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1112 | PM3ByApertureMode_PIXELSIZE_16BIT | | 259 | PM3ByApertureMode_PIXELSIZE_16BIT | |
1113 | PM3ByApertureMode_BYTESWAP_BADC); | 260 | PM3ByApertureMode_BYTESWAP_BADC); |
1114 | #endif /* ! __BIG_ENDIAN */ | 261 | #endif /* ! __BIG_ENDIAN */ |
@@ -1116,23 +263,23 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | |||
1116 | 263 | ||
1117 | case 32: | 264 | case 32: |
1118 | #ifndef __BIG_ENDIAN | 265 | #ifndef __BIG_ENDIAN |
1119 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 266 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1120 | PM3ByApertureMode_PIXELSIZE_32BIT); | 267 | PM3ByApertureMode_PIXELSIZE_32BIT); |
1121 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 268 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1122 | PM3ByApertureMode_PIXELSIZE_32BIT); | 269 | PM3ByApertureMode_PIXELSIZE_32BIT); |
1123 | #else | 270 | #else |
1124 | PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, | 271 | PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode, |
1125 | PM3ByApertureMode_PIXELSIZE_32BIT | | 272 | PM3ByApertureMode_PIXELSIZE_32BIT | |
1126 | PM3ByApertureMode_BYTESWAP_DCBA); | 273 | PM3ByApertureMode_BYTESWAP_DCBA); |
1127 | PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, | 274 | PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode, |
1128 | PM3ByApertureMode_PIXELSIZE_32BIT | | 275 | PM3ByApertureMode_PIXELSIZE_32BIT | |
1129 | PM3ByApertureMode_BYTESWAP_DCBA); | 276 | PM3ByApertureMode_BYTESWAP_DCBA); |
1130 | #endif /* ! __BIG_ENDIAN */ | 277 | #endif /* ! __BIG_ENDIAN */ |
1131 | break; | 278 | break; |
1132 | 279 | ||
1133 | default: | 280 | default: |
1134 | DPRINTK(1, "Unsupported depth %d\n", | 281 | DPRINTK("Unsupported depth %d\n", |
1135 | l_fb_info->current_par->depth); | 282 | info->var.bits_per_pixel); |
1136 | break; | 283 | break; |
1137 | } | 284 | } |
1138 | 285 | ||
@@ -1143,95 +290,86 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | |||
1143 | * sync options in PM3RD_SyncControl. --rmk | 290 | * sync options in PM3RD_SyncControl. --rmk |
1144 | */ | 291 | */ |
1145 | { | 292 | { |
1146 | unsigned int video = l_fb_info->current_par->video; | 293 | unsigned int video = par->video; |
1147 | 294 | ||
1148 | video &= ~(PM3VideoControl_HSYNC_MASK | | 295 | video &= ~(PM3VideoControl_HSYNC_MASK | |
1149 | PM3VideoControl_VSYNC_MASK); | 296 | PM3VideoControl_VSYNC_MASK); |
1150 | video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | | 297 | video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | |
1151 | PM3VideoControl_VSYNC_ACTIVE_HIGH; | 298 | PM3VideoControl_VSYNC_ACTIVE_HIGH; |
1152 | PM3_SLOW_WRITE_REG(PM3VideoControl, video); | 299 | PM3_SLOW_WRITE_REG(par, PM3VideoControl, video); |
1153 | } | 300 | } |
1154 | PM3_SLOW_WRITE_REG(PM3VClkCtl, | 301 | PM3_SLOW_WRITE_REG(par, PM3VClkCtl, |
1155 | (PM3_READ_REG(PM3VClkCtl) & 0xFFFFFFFC)); | 302 | (PM3_READ_REG(par, PM3VClkCtl) & 0xFFFFFFFC)); |
1156 | PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base); | 303 | PM3_SLOW_WRITE_REG(par, PM3ScreenBase, par->base); |
1157 | PM3_SLOW_WRITE_REG(PM3ChipConfig, | 304 | PM3_SLOW_WRITE_REG(par, PM3ChipConfig, |
1158 | (PM3_READ_REG(PM3ChipConfig) & 0xFFFFFFFD)); | 305 | (PM3_READ_REG(par, PM3ChipConfig) & 0xFFFFFFFD)); |
1159 | 306 | ||
1160 | { | 307 | { |
1161 | unsigned char m; /* ClkPreScale */ | 308 | unsigned char uninitialized_var(m); /* ClkPreScale */ |
1162 | unsigned char n; /* ClkFeedBackScale */ | 309 | unsigned char uninitialized_var(n); /* ClkFeedBackScale */ |
1163 | unsigned char p; /* ClkPostScale */ | 310 | unsigned char uninitialized_var(p); /* ClkPostScale */ |
1164 | (void)pm3fb_CalculateClock(l_fb_info, l_fb_info->current_par->pixclock, PM3_REF_CLOCK, &m, &n, &p); | 311 | unsigned long pixclock = PICOS2KHZ(info->var.pixclock); |
1165 | 312 | ||
1166 | DPRINTK(2, | 313 | (void)pm3fb_calculate_clock(pixclock, &m, &n, &p); |
1167 | "Pixclock: %d, Pre: %d, Feedback: %d, Post: %d\n", | 314 | |
1168 | l_fb_info->current_par->pixclock, (int) m, (int) n, | 315 | DPRINTK("Pixclock: %ld, Pre: %d, Feedback: %d, Post: %d\n", |
1169 | (int) p); | 316 | pixclock, (int) m, (int) n, (int) p); |
1170 | 317 | ||
1171 | PM3_WRITE_DAC_REG(PM3RD_DClk0PreScale, m); | 318 | PM3_WRITE_DAC_REG(par, PM3RD_DClk0PreScale, m); |
1172 | PM3_WRITE_DAC_REG(PM3RD_DClk0FeedbackScale, n); | 319 | PM3_WRITE_DAC_REG(par, PM3RD_DClk0FeedbackScale, n); |
1173 | PM3_WRITE_DAC_REG(PM3RD_DClk0PostScale, p); | 320 | PM3_WRITE_DAC_REG(par, PM3RD_DClk0PostScale, p); |
1174 | } | 321 | } |
1175 | /* | 322 | /* |
1176 | PM3_WRITE_DAC_REG(PM3RD_IndexControl, 0x00); | 323 | PM3_WRITE_DAC_REG(par, PM3RD_IndexControl, 0x00); |
1177 | */ | 324 | */ |
1178 | /* | 325 | /* |
1179 | PM3_SLOW_WRITE_REG(PM3RD_IndexControl, 0x00); | 326 | PM3_SLOW_WRITE_REG(par, PM3RD_IndexControl, 0x00); |
1180 | */ | 327 | */ |
1181 | if ((l_fb_info->current_par->video & PM3VideoControl_HSYNC_MASK) == | 328 | if ((par->video & PM3VideoControl_HSYNC_MASK) == |
1182 | PM3VideoControl_HSYNC_ACTIVE_HIGH) | 329 | PM3VideoControl_HSYNC_ACTIVE_HIGH) |
1183 | tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH; | 330 | tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH; |
1184 | if ((l_fb_info->current_par->video & PM3VideoControl_VSYNC_MASK) == | 331 | if ((par->video & PM3VideoControl_VSYNC_MASK) == |
1185 | PM3VideoControl_VSYNC_ACTIVE_HIGH) | 332 | PM3VideoControl_VSYNC_ACTIVE_HIGH) |
1186 | tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH; | 333 | tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH; |
1187 | |||
1188 | PM3_WRITE_DAC_REG(PM3RD_SyncControl, tempsync); | ||
1189 | DPRINTK(2, "PM3RD_SyncControl: %d\n", tempsync); | ||
1190 | |||
1191 | if (flatpanel[l_fb_info->board_num]) | ||
1192 | { | ||
1193 | PM3_WRITE_DAC_REG(PM3RD_DACControl, PM3RD_DACControl_BLANK_PEDESTAL_ENABLE); | ||
1194 | PM3_WAIT(2); | ||
1195 | PM3_WRITE_REG(PM3VSConfiguration, 0x06); | ||
1196 | PM3_WRITE_REG(0x5a00, 1 << 14); /* black magic... */ | ||
1197 | tempmisc = PM3RD_MiscControl_VSB_OUTPUT_ENABLE; | ||
1198 | } | ||
1199 | else | ||
1200 | PM3_WRITE_DAC_REG(PM3RD_DACControl, 0x00); | ||
1201 | 334 | ||
1202 | switch (l_fb_info->current_par->depth) { | 335 | PM3_WRITE_DAC_REG(par, PM3RD_SyncControl, tempsync); |
336 | DPRINTK("PM3RD_SyncControl: %d\n", tempsync); | ||
337 | |||
338 | PM3_WRITE_DAC_REG(par, PM3RD_DACControl, 0x00); | ||
339 | |||
340 | switch (info->var.bits_per_pixel) { | ||
1203 | case 8: | 341 | case 8: |
1204 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 342 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1205 | PM3RD_PixelSize_8_BIT_PIXELS); | 343 | PM3RD_PixelSize_8_BIT_PIXELS); |
1206 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 344 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1207 | PM3RD_ColorFormat_CI8_COLOR | | 345 | PM3RD_ColorFormat_CI8_COLOR | |
1208 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); | 346 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); |
1209 | tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 347 | tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1210 | break; | 348 | break; |
1211 | case 12: | 349 | case 12: |
1212 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 350 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1213 | PM3RD_PixelSize_16_BIT_PIXELS); | 351 | PM3RD_PixelSize_16_BIT_PIXELS); |
1214 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 352 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1215 | PM3RD_ColorFormat_4444_COLOR | | 353 | PM3RD_ColorFormat_4444_COLOR | |
1216 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | | 354 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | |
1217 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); | 355 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); |
1218 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | | 356 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | |
1219 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 357 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1220 | break; | 358 | break; |
1221 | case 15: | 359 | case 15: |
1222 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 360 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1223 | PM3RD_PixelSize_16_BIT_PIXELS); | 361 | PM3RD_PixelSize_16_BIT_PIXELS); |
1224 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 362 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1225 | PM3RD_ColorFormat_5551_FRONT_COLOR | | 363 | PM3RD_ColorFormat_5551_FRONT_COLOR | |
1226 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | | 364 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | |
1227 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); | 365 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); |
1228 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | | 366 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | |
1229 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 367 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1230 | break; | 368 | break; |
1231 | case 16: | 369 | case 16: |
1232 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 370 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1233 | PM3RD_PixelSize_16_BIT_PIXELS); | 371 | PM3RD_PixelSize_16_BIT_PIXELS); |
1234 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 372 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1235 | PM3RD_ColorFormat_565_FRONT_COLOR | | 373 | PM3RD_ColorFormat_565_FRONT_COLOR | |
1236 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | | 374 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | |
1237 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); | 375 | PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); |
@@ -1239,1936 +377,280 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) | |||
1239 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 377 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1240 | break; | 378 | break; |
1241 | case 32: | 379 | case 32: |
1242 | PM3_WRITE_DAC_REG(PM3RD_PixelSize, | 380 | PM3_WRITE_DAC_REG(par, PM3RD_PixelSize, |
1243 | PM3RD_PixelSize_32_BIT_PIXELS); | 381 | PM3RD_PixelSize_32_BIT_PIXELS); |
1244 | PM3_WRITE_DAC_REG(PM3RD_ColorFormat, | 382 | PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat, |
1245 | PM3RD_ColorFormat_8888_COLOR | | 383 | PM3RD_ColorFormat_8888_COLOR | |
1246 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); | 384 | PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); |
1247 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | | 385 | tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | |
1248 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; | 386 | PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; |
1249 | break; | 387 | break; |
1250 | } | 388 | } |
1251 | PM3_WRITE_DAC_REG(PM3RD_MiscControl, tempmisc); | 389 | PM3_WRITE_DAC_REG(par, PM3RD_MiscControl, tempmisc); |
1252 | |||
1253 | PM3_SHOW_CUR_MODE; | ||
1254 | } | 390 | } |
1255 | 391 | ||
1256 | static void pm3fb_read_mode(struct pm3fb_info *l_fb_info, | 392 | /* |
1257 | struct pm3fb_par *curpar) | 393 | * hardware independent functions |
1258 | { | 394 | */ |
1259 | unsigned long pixsize1, pixsize2, clockused; | 395 | int pm3fb_init(void); |
1260 | unsigned long pre, feedback, post; | 396 | int pm3fb_setup(char*); |
1261 | |||
1262 | DTRACE; | ||
1263 | |||
1264 | clockused = PM3_READ_REG(PM3VClkCtl); | ||
1265 | 397 | ||
1266 | switch (clockused) { | 398 | static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
1267 | case 3: | 399 | { |
1268 | pre = PM3_READ_DAC_REG(PM3RD_DClk3PreScale); | 400 | u32 lpitch; |
1269 | feedback = PM3_READ_DAC_REG(PM3RD_DClk3FeedbackScale); | ||
1270 | post = PM3_READ_DAC_REG(PM3RD_DClk3PostScale); | ||
1271 | 401 | ||
1272 | DPRINTK(2, | 402 | var->transp.offset = 0; |
1273 | "DClk3 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", | 403 | var->transp.length = 0; |
1274 | pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, | 404 | switch(var->bits_per_pixel) { |
1275 | feedback, | 405 | case 8: |
1276 | post)); | 406 | var->red.length = var->green.length = var->blue.length = 8; |
407 | var->red.offset = var->green.offset = var->blue.offset = 0; | ||
1277 | break; | 408 | break; |
1278 | case 2: | 409 | case 12: |
1279 | pre = PM3_READ_DAC_REG(PM3RD_DClk2PreScale); | 410 | var->red.offset = 8; |
1280 | feedback = PM3_READ_DAC_REG(PM3RD_DClk2FeedbackScale); | 411 | var->red.length = 4; |
1281 | post = PM3_READ_DAC_REG(PM3RD_DClk2PostScale); | 412 | var->green.offset = 4; |
1282 | 413 | var->green.length = 4; | |
1283 | DPRINTK(2, | 414 | var->blue.offset = 0; |
1284 | "DClk2 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", | 415 | var->blue.length = 4; |
1285 | pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, | 416 | var->transp.offset = 12; |
1286 | feedback, | 417 | var->transp.length = 4; |
1287 | post)); | 418 | case 15: |
419 | var->red.offset = 10; | ||
420 | var->red.length = 5; | ||
421 | var->green.offset = 5; | ||
422 | var->green.length = 5; | ||
423 | var->blue.offset = 0; | ||
424 | var->blue.length = 5; | ||
425 | var->transp.offset = 15; | ||
426 | var->transp.length = 1; | ||
1288 | break; | 427 | break; |
1289 | case 1: | 428 | case 16: |
1290 | pre = PM3_READ_DAC_REG(PM3RD_DClk1PreScale); | 429 | var->red.offset = 11; |
1291 | feedback = PM3_READ_DAC_REG(PM3RD_DClk1FeedbackScale); | 430 | var->red.length = 5; |
1292 | post = PM3_READ_DAC_REG(PM3RD_DClk1PostScale); | 431 | var->green.offset = 5; |
1293 | 432 | var->green.length = 6; | |
1294 | DPRINTK(2, | 433 | var->blue.offset = 0; |
1295 | "DClk1 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", | 434 | var->blue.length = 5; |
1296 | pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, | ||
1297 | feedback, | ||
1298 | post)); | ||
1299 | break; | 435 | break; |
1300 | case 0: | 436 | case 32: |
1301 | pre = PM3_READ_DAC_REG(PM3RD_DClk0PreScale); | 437 | var->transp.offset = 24; |
1302 | feedback = PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale); | 438 | var->transp.length = 8; |
1303 | post = PM3_READ_DAC_REG(PM3RD_DClk0PostScale); | 439 | var->red.offset = 16; |
1304 | 440 | var->green.offset = 8; | |
1305 | DPRINTK(2, | 441 | var->blue.offset = 0; |
1306 | "DClk0 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", | 442 | var->red.length = var->green.length = var->blue.length = 8; |
1307 | pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, | ||
1308 | feedback, | ||
1309 | post)); | ||
1310 | break; | 443 | break; |
1311 | default: | 444 | default: |
1312 | pre = feedback = post = 0; | 445 | DPRINTK("depth not supported: %u\n", var->bits_per_pixel); |
1313 | DPRINTK(1, "Unknowk D clock used : %ld\n", clockused); | 446 | return -EINVAL; |
1314 | break; | ||
1315 | } | ||
1316 | |||
1317 | curpar->pixclock = PM3_SCALE_TO_CLOCK(pre, feedback, post); | ||
1318 | |||
1319 | pixsize1 = | ||
1320 | PM3ByApertureMode_PIXELSIZE_MASK & | ||
1321 | (PM3_READ_REG(PM3ByAperture1Mode)); | ||
1322 | pixsize2 = | ||
1323 | PM3ByApertureMode_PIXELSIZE_MASK & | ||
1324 | (PM3_READ_REG(PM3ByAperture2Mode)); | ||
1325 | |||
1326 | DASSERT((pixsize1 == pixsize2), | ||
1327 | "pixsize the same in both aperture\n"); | ||
1328 | |||
1329 | if (pixsize1 & PM3ByApertureMode_PIXELSIZE_32BIT) | ||
1330 | curpar->depth = 32; | ||
1331 | else if (pixsize1 & PM3ByApertureMode_PIXELSIZE_16BIT) | ||
1332 | { | ||
1333 | curpar->depth = 16; | ||
1334 | } | ||
1335 | else | ||
1336 | curpar->depth = 8; | ||
1337 | |||
1338 | /* not sure if I need to add one on the next ; it give better result with */ | ||
1339 | curpar->htotal = | ||
1340 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1341 | 1 + PM3_READ_REG(PM3HTotal)); | ||
1342 | curpar->hsend = | ||
1343 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1344 | PM3_READ_REG(PM3HsEnd)); | ||
1345 | curpar->hsstart = | ||
1346 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1347 | PM3_READ_REG(PM3HsStart)); | ||
1348 | curpar->hbend = | ||
1349 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1350 | PM3_READ_REG(PM3HbEnd)); | ||
1351 | |||
1352 | curpar->stride = | ||
1353 | pm3fb_Unshiftbpp(l_fb_info, curpar->depth, | ||
1354 | PM3_READ_REG(PM3ScreenStride)); | ||
1355 | |||
1356 | curpar->vtotal = 1 + PM3_READ_REG(PM3VTotal); | ||
1357 | curpar->vsend = 1 + PM3_READ_REG(PM3VsEnd); | ||
1358 | curpar->vsstart = 1 + PM3_READ_REG(PM3VsStart); | ||
1359 | curpar->vbend = PM3_READ_REG(PM3VbEnd); | ||
1360 | |||
1361 | curpar->video = PM3_READ_REG(PM3VideoControl); | ||
1362 | |||
1363 | curpar->base = PM3_READ_REG(PM3ScreenBase); | ||
1364 | curpar->width = curpar->htotal - curpar->hbend; /* make virtual == displayed resolution */ | ||
1365 | curpar->height = curpar->vtotal - curpar->vbend; | ||
1366 | |||
1367 | DPRINTK(2, "Found : %d * %d, %d Khz, stride is %08x\n", | ||
1368 | curpar->width, curpar->height, curpar->pixclock, | ||
1369 | curpar->stride); | ||
1370 | } | ||
1371 | |||
1372 | static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info) | ||
1373 | { | ||
1374 | unsigned long memsize = 0, tempBypass, i, temp1, temp2; | ||
1375 | u16 subvendor, subdevice; | ||
1376 | pm3fb_timing_result ptr; | ||
1377 | |||
1378 | DTRACE; | ||
1379 | |||
1380 | l_fb_info->fb_size = 64 * 1024 * 1024; /* pm3 aperture always 64 MB */ | ||
1381 | pm3fb_mapIO(l_fb_info); /* temporary map IO */ | ||
1382 | |||
1383 | DASSERT((l_fb_info->vIOBase != NULL), | ||
1384 | "IO successfully mapped before mem detect\n"); | ||
1385 | DASSERT((l_fb_info->v_fb != NULL), | ||
1386 | "FB successfully mapped before mem detect\n"); | ||
1387 | |||
1388 | /* card-specific stuff, *before* accessing *any* FB memory */ | ||
1389 | if ((!pci_read_config_word | ||
1390 | (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor)) | ||
1391 | && | ||
1392 | (!pci_read_config_word | ||
1393 | (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) { | ||
1394 | i = 0; l_fb_info->board_type = 0; | ||
1395 | while ((cardbase[i].cardname[0]) && !(l_fb_info->board_type)) { | ||
1396 | if ((cardbase[i].subvendor == subvendor) && | ||
1397 | (cardbase[i].subdevice == subdevice) && | ||
1398 | (cardbase[i].func == PCI_FUNC(l_fb_info->dev->devfn))) { | ||
1399 | DPRINTK(2, "Card #%ld is an %s\n", | ||
1400 | l_fb_info->board_num, | ||
1401 | cardbase[i].cardname); | ||
1402 | if (cardbase[i].specific_setup) | ||
1403 | cardbase[i].specific_setup(l_fb_info); | ||
1404 | l_fb_info->board_type = i; | ||
1405 | } | ||
1406 | i++; | ||
1407 | } | ||
1408 | if (!l_fb_info->board_type) { | ||
1409 | DPRINTK(1, "Card #%ld is an unknown 0x%04x / 0x%04x\n", | ||
1410 | l_fb_info->board_num, subvendor, subdevice); | ||
1411 | } | ||
1412 | } else { | ||
1413 | printk(KERN_ERR "pm3fb: Error: pci_read_config_word failed, board #%ld\n", | ||
1414 | l_fb_info->board_num); | ||
1415 | } | ||
1416 | |||
1417 | if (printtimings) | ||
1418 | pm3fb_show_cur_timing(l_fb_info); | ||
1419 | |||
1420 | /* card-specific setup is done, we preserve the final | ||
1421 | memory timing for future reference */ | ||
1422 | if ((ptr = pm3fb_preserve_memory_timings(l_fb_info)) == pm3fb_timing_problem) { /* memory timings were wrong ! oops.... */ | ||
1423 | return(0); | ||
1424 | } | ||
1425 | |||
1426 | tempBypass = PM3_READ_REG(PM3MemBypassWriteMask); | ||
1427 | |||
1428 | DPRINTK(2, "PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass); | ||
1429 | |||
1430 | PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xFFFFFFFF); | ||
1431 | |||
1432 | /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */ | ||
1433 | for (i = 0; i < 32; i++) { | ||
1434 | fb_writel(i * 0x00345678, | ||
1435 | (l_fb_info->v_fb + (i * 1048576))); | ||
1436 | mb(); | ||
1437 | temp1 = fb_readl((l_fb_info->v_fb + (i * 1048576))); | ||
1438 | |||
1439 | /* Let's check for wrapover, write will fail at 16MB boundary */ | ||
1440 | if (temp1 == (i * 0x00345678)) | ||
1441 | memsize = i; | ||
1442 | else | ||
1443 | break; | ||
1444 | } | ||
1445 | |||
1446 | DPRINTK(2, "First detect pass already got %ld MB\n", memsize + 1); | ||
1447 | |||
1448 | if (memsize == i) { | ||
1449 | for (i = 0; i < 32; i++) { | ||
1450 | /* Clear first 32MB ; 0 is 0, no need to byteswap */ | ||
1451 | writel(0x0000000, | ||
1452 | (l_fb_info->v_fb + (i * 1048576))); | ||
1453 | mb(); | ||
1454 | } | ||
1455 | |||
1456 | for (i = 32; i < 64; i++) { | ||
1457 | fb_writel(i * 0x00345678, | ||
1458 | (l_fb_info->v_fb + (i * 1048576))); | ||
1459 | mb(); | ||
1460 | temp1 = | ||
1461 | fb_readl((l_fb_info->v_fb + (i * 1048576))); | ||
1462 | temp2 = | ||
1463 | fb_readl((l_fb_info->v_fb + | ||
1464 | ((i - 32) * 1048576))); | ||
1465 | if ((temp1 == (i * 0x00345678)) && (temp2 == 0)) /* different value, different RAM... */ | ||
1466 | memsize = i; | ||
1467 | else | ||
1468 | break; | ||
1469 | } | ||
1470 | } | ||
1471 | |||
1472 | DPRINTK(2, "Second detect pass got %ld MB\n", memsize + 1); | ||
1473 | |||
1474 | PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, tempBypass); | ||
1475 | |||
1476 | pm3fb_unmapIO(l_fb_info); | ||
1477 | memsize = 1048576 * (memsize + 1); | ||
1478 | |||
1479 | DPRINTK(2, "Returning 0x%08lx bytes\n", memsize); | ||
1480 | |||
1481 | if (forcesize[l_fb_info->board_num] && ((forcesize[l_fb_info->board_num] * 1048576) != memsize)) | ||
1482 | { | ||
1483 | printk(KERN_WARNING "pm3fb: mismatch between probed (%ld MB) and specified (%hd MB) memory size, using SPECIFIED !\n", memsize, forcesize[l_fb_info->board_num]); | ||
1484 | memsize = 1048576 * forcesize[l_fb_info->board_num]; | ||
1485 | } | ||
1486 | |||
1487 | l_fb_info->fb_size = memsize; | ||
1488 | |||
1489 | if (ptr == pm3fb_timing_retry) | ||
1490 | { | ||
1491 | printk(KERN_WARNING "pm3fb: retrying memory timings check"); | ||
1492 | if (pm3fb_try_memory_timings(l_fb_info) == pm3fb_timing_problem) | ||
1493 | return(0); | ||
1494 | } | ||
1495 | |||
1496 | return (memsize); | ||
1497 | } | ||
1498 | |||
1499 | static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc) | ||
1500 | { | ||
1501 | int i; | ||
1502 | |||
1503 | DTRACE; | ||
1504 | |||
1505 | for (i = 0; i < (l_fb_info->fb_size / sizeof(u32)) ; i++) /* clear entire FB memory to black */ | ||
1506 | { | ||
1507 | fb_writel(cc, (l_fb_info->v_fb + (i * sizeof(u32)))); | ||
1508 | } | 447 | } |
1509 | } | 448 | var->height = var->width = -1; |
1510 | |||
1511 | static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b) | ||
1512 | { | ||
1513 | int i; | ||
1514 | |||
1515 | DTRACE; | ||
1516 | |||
1517 | for (i = 0; i < 256 ; i++) /* fill color map with white */ | ||
1518 | pm3fb_set_color(l_fb_info, i, r, g, b); | ||
1519 | |||
1520 | } | ||
1521 | |||
1522 | /* common initialisation */ | ||
1523 | static void pm3fb_common_init(struct pm3fb_info *l_fb_info) | ||
1524 | { | ||
1525 | DTRACE; | ||
1526 | |||
1527 | DPRINTK(2, "Initializing board #%ld @ %lx\n", l_fb_info->board_num, | ||
1528 | (unsigned long) l_fb_info); | ||
1529 | |||
1530 | strcpy(l_fb_info->gen.info.modename, permedia3_name); | ||
1531 | disp[l_fb_info->board_num].scrollmode = 0; /* SCROLL_YNOMOVE; *//* 0 means "let fbcon choose" */ | ||
1532 | l_fb_info->gen.parsize = sizeof(struct pm3fb_par); | ||
1533 | l_fb_info->gen.info.changevar = NULL; | ||
1534 | l_fb_info->gen.info.fbops = &pm3fb_ops; | ||
1535 | l_fb_info->gen.info.disp = &(disp[l_fb_info->board_num]); | ||
1536 | if (fontn[l_fb_info->board_num][0]) | ||
1537 | strcpy(l_fb_info->gen.info.fontname, | ||
1538 | fontn[l_fb_info->board_num]); | ||
1539 | l_fb_info->gen.info.switch_con = &fbgen_switch; | ||
1540 | l_fb_info->gen.info.updatevar = &fbgen_update_var; /* */ | ||
1541 | l_fb_info->gen.info.flags = FBINFO_FLAG_DEFAULT; | ||
1542 | |||
1543 | pm3fb_mapIO(l_fb_info); | ||
1544 | |||
1545 | pm3fb_clear_memory(l_fb_info, 0); | ||
1546 | pm3fb_clear_colormap(l_fb_info, 0, 0, 0); | ||
1547 | |||
1548 | (void) fbgen_get_var(&(disp[l_fb_info->board_num]).var, -1, | ||
1549 | &l_fb_info->gen.info); | ||
1550 | 449 | ||
1551 | if (depth[l_fb_info->board_num]) /* override mode-defined depth */ | 450 | if (var->xres != var->xres_virtual) { |
1552 | { | 451 | DPRINTK("virtual x resolution != physical x resolution not supported\n"); |
1553 | pm3fb_encode_depth(&(disp[l_fb_info->board_num]).var, depth[l_fb_info->board_num]); | 452 | return -EINVAL; |
1554 | (disp[l_fb_info->board_num]).var.bits_per_pixel = depth2bpp(depth[l_fb_info->board_num]); | ||
1555 | } | 453 | } |
1556 | 454 | ||
1557 | (void) fbgen_do_set_var(&(disp[l_fb_info->board_num]).var, 1, | 455 | if (var->yres > var->yres_virtual) { |
1558 | &l_fb_info->gen); | 456 | DPRINTK("virtual y resolution < physical y resolution not possible\n"); |
1559 | 457 | return -EINVAL; | |
1560 | fbgen_set_disp(-1, &l_fb_info->gen); | ||
1561 | |||
1562 | do_install_cmap(0, &l_fb_info->gen.info); | ||
1563 | |||
1564 | if (register_framebuffer(&l_fb_info->gen.info) < 0) { | ||
1565 | DPRINTK(1, "Couldn't register framebuffer\n"); | ||
1566 | return; | ||
1567 | } | 458 | } |
1568 | 459 | ||
1569 | PM3_WRITE_DAC_REG(PM3RD_CursorMode, | 460 | if (var->xoffset) { |
1570 | PM3RD_CursorMode_CURSOR_DISABLE); | 461 | DPRINTK("xoffset not supported\n"); |
1571 | 462 | return -EINVAL; | |
1572 | PM3_SHOW_CUR_MODE; | ||
1573 | |||
1574 | pm3fb_write_mode(l_fb_info); | ||
1575 | |||
1576 | printk("fb%d: %s, using %uK of video memory (%s)\n", | ||
1577 | l_fb_info->gen.info.node, | ||
1578 | permedia3_name, (u32) (l_fb_info->fb_size >> 10), | ||
1579 | cardbase[l_fb_info->board_type].cardname); | ||
1580 | } | ||
1581 | |||
1582 | /* **************************************************** */ | ||
1583 | /* ***** accelerated permedia3-specific functions ***** */ | ||
1584 | /* **************************************************** */ | ||
1585 | #ifdef PM3FB_USE_ACCEL | ||
1586 | static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info) | ||
1587 | { | ||
1588 | DTRACE; | ||
1589 | |||
1590 | PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync); | ||
1591 | PM3_SLOW_WRITE_REG(PM3Sync, 0); | ||
1592 | mb(); | ||
1593 | do { | ||
1594 | while ((PM3_READ_REG(PM3OutFIFOWords)) == 0); | ||
1595 | rmb(); | ||
1596 | } while ((PM3_READ_REG(PM3OutputFifo)) != PM3Sync_Tag); | ||
1597 | } | ||
1598 | |||
1599 | static void pm3fb_init_engine(struct pm3fb_info *l_fb_info) | ||
1600 | { | ||
1601 | PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync); | ||
1602 | PM3_SLOW_WRITE_REG(PM3StatisticMode, 0x0); | ||
1603 | PM3_SLOW_WRITE_REG(PM3DeltaMode, 0x0); | ||
1604 | PM3_SLOW_WRITE_REG(PM3RasterizerMode, 0x0); | ||
1605 | PM3_SLOW_WRITE_REG(PM3ScissorMode, 0x0); | ||
1606 | PM3_SLOW_WRITE_REG(PM3LineStippleMode, 0x0); | ||
1607 | PM3_SLOW_WRITE_REG(PM3AreaStippleMode, 0x0); | ||
1608 | PM3_SLOW_WRITE_REG(PM3GIDMode, 0x0); | ||
1609 | PM3_SLOW_WRITE_REG(PM3DepthMode, 0x0); | ||
1610 | PM3_SLOW_WRITE_REG(PM3StencilMode, 0x0); | ||
1611 | PM3_SLOW_WRITE_REG(PM3StencilData, 0x0); | ||
1612 | PM3_SLOW_WRITE_REG(PM3ColorDDAMode, 0x0); | ||
1613 | PM3_SLOW_WRITE_REG(PM3TextureCoordMode, 0x0); | ||
1614 | PM3_SLOW_WRITE_REG(PM3TextureIndexMode0, 0x0); | ||
1615 | PM3_SLOW_WRITE_REG(PM3TextureIndexMode1, 0x0); | ||
1616 | PM3_SLOW_WRITE_REG(PM3TextureReadMode, 0x0); | ||
1617 | PM3_SLOW_WRITE_REG(PM3LUTMode, 0x0); | ||
1618 | PM3_SLOW_WRITE_REG(PM3TextureFilterMode, 0x0); | ||
1619 | PM3_SLOW_WRITE_REG(PM3TextureCompositeMode, 0x0); | ||
1620 | PM3_SLOW_WRITE_REG(PM3TextureApplicationMode, 0x0); | ||
1621 | PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode1, 0x0); | ||
1622 | PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode1, 0x0); | ||
1623 | PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode0, 0x0); | ||
1624 | PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode0, 0x0); | ||
1625 | PM3_SLOW_WRITE_REG(PM3FogMode, 0x0); | ||
1626 | PM3_SLOW_WRITE_REG(PM3ChromaTestMode, 0x0); | ||
1627 | PM3_SLOW_WRITE_REG(PM3AlphaTestMode, 0x0); | ||
1628 | PM3_SLOW_WRITE_REG(PM3AntialiasMode, 0x0); | ||
1629 | PM3_SLOW_WRITE_REG(PM3YUVMode, 0x0); | ||
1630 | PM3_SLOW_WRITE_REG(PM3AlphaBlendColorMode, 0x0); | ||
1631 | PM3_SLOW_WRITE_REG(PM3AlphaBlendAlphaMode, 0x0); | ||
1632 | PM3_SLOW_WRITE_REG(PM3DitherMode, 0x0); | ||
1633 | PM3_SLOW_WRITE_REG(PM3LogicalOpMode, 0x0); | ||
1634 | PM3_SLOW_WRITE_REG(PM3RouterMode, 0x0); | ||
1635 | PM3_SLOW_WRITE_REG(PM3Window, 0x0); | ||
1636 | |||
1637 | PM3_SLOW_WRITE_REG(PM3Config2D, 0x0); | ||
1638 | |||
1639 | PM3_SLOW_WRITE_REG(PM3SpanColorMask, 0xffffffff); | ||
1640 | |||
1641 | PM3_SLOW_WRITE_REG(PM3XBias, 0x0); | ||
1642 | PM3_SLOW_WRITE_REG(PM3YBias, 0x0); | ||
1643 | PM3_SLOW_WRITE_REG(PM3DeltaControl, 0x0); | ||
1644 | |||
1645 | PM3_SLOW_WRITE_REG(PM3BitMaskPattern, 0xffffffff); | ||
1646 | |||
1647 | PM3_SLOW_WRITE_REG(PM3FBDestReadEnables, | ||
1648 | PM3FBDestReadEnables_E(0xff) | | ||
1649 | PM3FBDestReadEnables_R(0xff) | | ||
1650 | PM3FBDestReadEnables_ReferenceAlpha(0xff)); | ||
1651 | PM3_SLOW_WRITE_REG(PM3FBDestReadBufferAddr0, 0x0); | ||
1652 | PM3_SLOW_WRITE_REG(PM3FBDestReadBufferOffset0, 0x0); | ||
1653 | PM3_SLOW_WRITE_REG(PM3FBDestReadBufferWidth0, | ||
1654 | PM3FBDestReadBufferWidth_Width(l_fb_info-> | ||
1655 | current_par-> | ||
1656 | width)); | ||
1657 | |||
1658 | PM3_SLOW_WRITE_REG(PM3FBDestReadMode, | ||
1659 | PM3FBDestReadMode_ReadEnable | | ||
1660 | PM3FBDestReadMode_Enable0); | ||
1661 | PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferAddr, 0x0); | ||
1662 | PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferOffset, 0x0); | ||
1663 | PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferWidth, | ||
1664 | PM3FBSourceReadBufferWidth_Width(l_fb_info-> | ||
1665 | current_par-> | ||
1666 | width)); | ||
1667 | PM3_SLOW_WRITE_REG(PM3FBSourceReadMode, | ||
1668 | PM3FBSourceReadMode_Blocking | | ||
1669 | PM3FBSourceReadMode_ReadEnable); | ||
1670 | |||
1671 | { | ||
1672 | unsigned long rm = 1; | ||
1673 | switch (l_fb_info->current_par->depth) { | ||
1674 | case 8: | ||
1675 | PM3_SLOW_WRITE_REG(PM3PixelSize, | ||
1676 | PM3PixelSize_GLOBAL_8BIT); | ||
1677 | break; | ||
1678 | case 12: | ||
1679 | case 15: | ||
1680 | case 16: | ||
1681 | PM3_SLOW_WRITE_REG(PM3PixelSize, | ||
1682 | PM3PixelSize_GLOBAL_16BIT); | ||
1683 | break; | ||
1684 | case 32: | ||
1685 | PM3_SLOW_WRITE_REG(PM3PixelSize, | ||
1686 | PM3PixelSize_GLOBAL_32BIT); | ||
1687 | break; | ||
1688 | default: | ||
1689 | DPRINTK(1, "Unsupported depth %d\n", | ||
1690 | l_fb_info->current_par->depth); | ||
1691 | break; | ||
1692 | } | ||
1693 | PM3_SLOW_WRITE_REG(PM3RasterizerMode, rm); | ||
1694 | } | 463 | } |
1695 | 464 | ||
1696 | PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xffffffff); | 465 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { |
1697 | PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xffffffff); | 466 | DPRINTK("interlace not supported\n"); |
1698 | PM3_SLOW_WRITE_REG(PM3FBWriteMode, | 467 | return -EINVAL; |
1699 | PM3FBWriteMode_WriteEnable | | ||
1700 | PM3FBWriteMode_OpaqueSpan | | ||
1701 | PM3FBWriteMode_Enable0); | ||
1702 | PM3_SLOW_WRITE_REG(PM3FBWriteBufferAddr0, 0x0); | ||
1703 | PM3_SLOW_WRITE_REG(PM3FBWriteBufferOffset0, 0x0); | ||
1704 | PM3_SLOW_WRITE_REG(PM3FBWriteBufferWidth0, | ||
1705 | PM3FBWriteBufferWidth_Width(l_fb_info-> | ||
1706 | current_par-> | ||
1707 | width)); | ||
1708 | |||
1709 | PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 0x0); | ||
1710 | { | ||
1711 | unsigned long sofb = (8UL * l_fb_info->fb_size) / | ||
1712 | ((depth2bpp(l_fb_info->current_par->depth)) | ||
1713 | * l_fb_info->current_par->width); /* size in lines of FB */ | ||
1714 | if (sofb > 4095) | ||
1715 | PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 4095); | ||
1716 | else | ||
1717 | PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, sofb); | ||
1718 | |||
1719 | switch (l_fb_info->current_par->depth) { | ||
1720 | case 8: | ||
1721 | PM3_SLOW_WRITE_REG(PM3DitherMode, | ||
1722 | (1 << 10) | (2 << 3)); | ||
1723 | break; | ||
1724 | case 12: | ||
1725 | case 15: | ||
1726 | case 16: | ||
1727 | PM3_SLOW_WRITE_REG(PM3DitherMode, | ||
1728 | (1 << 10) | (1 << 3)); | ||
1729 | break; | ||
1730 | case 32: | ||
1731 | PM3_SLOW_WRITE_REG(PM3DitherMode, | ||
1732 | (1 << 10) | (0 << 3)); | ||
1733 | break; | ||
1734 | default: | ||
1735 | DPRINTK(1, "Unsupported depth %d\n", | ||
1736 | l_fb_info->current_par->depth); | ||
1737 | break; | ||
1738 | } | ||
1739 | } | 468 | } |
1740 | 469 | ||
1741 | PM3_SLOW_WRITE_REG(PM3dXDom, 0x0); | 470 | var->xres = (var->xres + 31) & ~31; /* could sometimes be 8 */ |
1742 | PM3_SLOW_WRITE_REG(PM3dXSub, 0x0); | 471 | lpitch = var->xres * ((var->bits_per_pixel + 7)>>3); |
1743 | PM3_SLOW_WRITE_REG(PM3dY, (1 << 16)); | ||
1744 | PM3_SLOW_WRITE_REG(PM3StartXDom, 0x0); | ||
1745 | PM3_SLOW_WRITE_REG(PM3StartXSub, 0x0); | ||
1746 | PM3_SLOW_WRITE_REG(PM3StartY, 0x0); | ||
1747 | PM3_SLOW_WRITE_REG(PM3Count, 0x0); | ||
1748 | |||
1749 | /* Disable LocalBuffer. better safe than sorry */ | ||
1750 | PM3_SLOW_WRITE_REG(PM3LBDestReadMode, 0x0); | ||
1751 | PM3_SLOW_WRITE_REG(PM3LBDestReadEnables, 0x0); | ||
1752 | PM3_SLOW_WRITE_REG(PM3LBSourceReadMode, 0x0); | ||
1753 | PM3_SLOW_WRITE_REG(PM3LBWriteMode, 0x0); | ||
1754 | |||
1755 | pm3fb_wait_pm3(l_fb_info); | ||
1756 | } | ||
1757 | 472 | ||
1758 | #ifdef FBCON_HAS_CFB32 | 473 | if (var->xres < 200 || var->xres > 2048) { |
1759 | static void pm3fb_cfb32_clear(struct vc_data *conp, | 474 | DPRINTK("width not supported: %u\n", var->xres); |
1760 | struct display *p, | 475 | return -EINVAL; |
1761 | int sy, int sx, int height, int width) | ||
1762 | { | ||
1763 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
1764 | u32 c; | ||
1765 | |||
1766 | DTRACE; | ||
1767 | |||
1768 | sx = sx * fontwidth(p); | ||
1769 | width = width * fontwidth(p); | ||
1770 | sy = sy * fontheight(p); | ||
1771 | height = height * fontheight(p); | ||
1772 | c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)]; | ||
1773 | |||
1774 | /* block fills in 32bpp are hard, but in low res (width <= 1600 :-) | ||
1775 | we can use 16bpp operations, but not if NoWriteMask is on (SDRAM) */ | ||
1776 | if ((l_fb_info->current_par->width > 1600) || | ||
1777 | (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)) { | ||
1778 | PM3_WAIT(4); | ||
1779 | |||
1780 | PM3_WRITE_REG(PM3Config2D, | ||
1781 | PM3Config2D_UseConstantSource | | ||
1782 | PM3Config2D_ForegroundROPEnable | | ||
1783 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1784 | PM3Config2D_FBWriteEnable); | ||
1785 | |||
1786 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1787 | |||
1788 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1789 | (PM3RectanglePosition_XOffset(sx)) | | ||
1790 | (PM3RectanglePosition_YOffset(sy))); | ||
1791 | |||
1792 | PM3_WRITE_REG(PM3Render2D, | ||
1793 | PM3Render2D_XPositive | | ||
1794 | PM3Render2D_YPositive | | ||
1795 | PM3Render2D_Operation_Normal | | ||
1796 | PM3Render2D_SpanOperation | | ||
1797 | (PM3Render2D_Width(width)) | | ||
1798 | (PM3Render2D_Height(height))); | ||
1799 | } else { | ||
1800 | PM3_WAIT(8); | ||
1801 | |||
1802 | PM3_WRITE_REG(PM3FBBlockColor, c); | ||
1803 | |||
1804 | PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_16BIT); | ||
1805 | |||
1806 | PM3_WRITE_REG(PM3FBWriteBufferWidth0, | ||
1807 | PM3FBWriteBufferWidth_Width(l_fb_info-> | ||
1808 | current_par-> | ||
1809 | width << 1)); | ||
1810 | |||
1811 | PM3_WRITE_REG(PM3Config2D, | ||
1812 | PM3Config2D_UseConstantSource | | ||
1813 | PM3Config2D_ForegroundROPEnable | | ||
1814 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1815 | PM3Config2D_FBWriteEnable); | ||
1816 | |||
1817 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1818 | (PM3RectanglePosition_XOffset(sx << 1)) | | ||
1819 | (PM3RectanglePosition_YOffset(sy))); | ||
1820 | |||
1821 | PM3_WRITE_REG(PM3Render2D, | ||
1822 | PM3Render2D_XPositive | | ||
1823 | PM3Render2D_YPositive | | ||
1824 | PM3Render2D_Operation_Normal | | ||
1825 | (PM3Render2D_Width(width << 1)) | | ||
1826 | (PM3Render2D_Height(height))); | ||
1827 | |||
1828 | PM3_WRITE_REG(PM3FBWriteBufferWidth0, | ||
1829 | PM3FBWriteBufferWidth_Width(l_fb_info-> | ||
1830 | current_par-> | ||
1831 | width)); | ||
1832 | |||
1833 | PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_32BIT); | ||
1834 | } | 476 | } |
1835 | 477 | ||
1836 | pm3fb_wait_pm3(l_fb_info); | 478 | if (var->yres < 200 || var->yres > 4095) { |
1837 | } | 479 | DPRINTK("height not supported: %u\n", var->yres); |
1838 | 480 | return -EINVAL; | |
1839 | static void pm3fb_cfb32_clear_margins(struct vc_data *conp, | ||
1840 | struct display *p, int bottom_only) | ||
1841 | { | ||
1842 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
1843 | int sx, sy; | ||
1844 | u32 c; | ||
1845 | |||
1846 | DTRACE; | ||
1847 | |||
1848 | sx = conp->vc_cols * fontwidth(p); /* right margin */ | ||
1849 | sy = conp->vc_rows * fontheight(p); /* bottom margin */ | ||
1850 | c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)]; | ||
1851 | |||
1852 | if (!bottom_only) { /* right margin top->bottom */ | ||
1853 | PM3_WAIT(4); | ||
1854 | |||
1855 | PM3_WRITE_REG(PM3Config2D, | ||
1856 | PM3Config2D_UseConstantSource | | ||
1857 | PM3Config2D_ForegroundROPEnable | | ||
1858 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1859 | PM3Config2D_FBWriteEnable); | ||
1860 | |||
1861 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1862 | |||
1863 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1864 | (PM3RectanglePosition_XOffset | ||
1865 | (p->var.xoffset + | ||
1866 | sx)) | (PM3RectanglePosition_YOffset(p-> | ||
1867 | var. | ||
1868 | yoffset))); | ||
1869 | |||
1870 | PM3_WRITE_REG(PM3Render2D, | ||
1871 | PM3Render2D_XPositive | | ||
1872 | PM3Render2D_YPositive | | ||
1873 | PM3Render2D_Operation_Normal | | ||
1874 | PM3Render2D_SpanOperation | | ||
1875 | (PM3Render2D_Width(p->var.xres - sx)) | | ||
1876 | (PM3Render2D_Height(p->var.yres))); | ||
1877 | } | 481 | } |
1878 | 482 | ||
1879 | /* bottom margin left -> right */ | 483 | if (lpitch * var->yres_virtual > info->fix.smem_len) { |
1880 | PM3_WAIT(4); | 484 | DPRINTK("no memory for screen (%ux%ux%u)\n", |
1881 | 485 | var->xres, var->yres_virtual, var->bits_per_pixel); | |
1882 | PM3_WRITE_REG(PM3Config2D, | 486 | return -EINVAL; |
1883 | PM3Config2D_UseConstantSource | | ||
1884 | PM3Config2D_ForegroundROPEnable | | ||
1885 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1886 | PM3Config2D_FBWriteEnable); | ||
1887 | |||
1888 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1889 | |||
1890 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1891 | (PM3RectanglePosition_XOffset(p->var.xoffset)) | | ||
1892 | (PM3RectanglePosition_YOffset(p->var.yoffset + sy))); | ||
1893 | |||
1894 | PM3_WRITE_REG(PM3Render2D, | ||
1895 | PM3Render2D_XPositive | | ||
1896 | PM3Render2D_YPositive | | ||
1897 | PM3Render2D_Operation_Normal | | ||
1898 | PM3Render2D_SpanOperation | | ||
1899 | (PM3Render2D_Width(p->var.xres)) | | ||
1900 | (PM3Render2D_Height(p->var.yres - sy))); | ||
1901 | |||
1902 | pm3fb_wait_pm3(l_fb_info); | ||
1903 | } | ||
1904 | #endif /* FBCON_HAS_CFB32 */ | ||
1905 | #ifdef FBCON_HAS_CFB16 | ||
1906 | static void pm3fb_cfb16_clear(struct vc_data *conp, | ||
1907 | struct display *p, | ||
1908 | int sy, int sx, int height, int width) | ||
1909 | { | ||
1910 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
1911 | u32 c; | ||
1912 | |||
1913 | DTRACE; | ||
1914 | |||
1915 | sx = sx * fontwidth(p); | ||
1916 | width = width * fontwidth(p); | ||
1917 | sy = sy * fontheight(p); | ||
1918 | height = height * fontheight(p); | ||
1919 | c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)]; | ||
1920 | c = c | (c << 16); | ||
1921 | |||
1922 | PM3_WAIT(4); | ||
1923 | |||
1924 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
1925 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1926 | else | ||
1927 | PM3_WRITE_REG(PM3FBBlockColor, c); | ||
1928 | |||
1929 | PM3_WRITE_REG(PM3Config2D, | ||
1930 | PM3Config2D_UseConstantSource | | ||
1931 | PM3Config2D_ForegroundROPEnable | | ||
1932 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1933 | PM3Config2D_FBWriteEnable); | ||
1934 | |||
1935 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1936 | (PM3RectanglePosition_XOffset(sx)) | | ||
1937 | (PM3RectanglePosition_YOffset(sy))); | ||
1938 | |||
1939 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
1940 | PM3_WRITE_REG(PM3Render2D, | ||
1941 | PM3Render2D_XPositive | | ||
1942 | PM3Render2D_YPositive | | ||
1943 | PM3Render2D_Operation_Normal | | ||
1944 | PM3Render2D_SpanOperation | | ||
1945 | (PM3Render2D_Width(width)) | | ||
1946 | (PM3Render2D_Height(height))); | ||
1947 | else | ||
1948 | PM3_WRITE_REG(PM3Render2D, | ||
1949 | PM3Render2D_XPositive | | ||
1950 | PM3Render2D_YPositive | | ||
1951 | PM3Render2D_Operation_Normal | | ||
1952 | (PM3Render2D_Width(width)) | | ||
1953 | (PM3Render2D_Height(height))); | ||
1954 | |||
1955 | pm3fb_wait_pm3(l_fb_info); | ||
1956 | } | ||
1957 | |||
1958 | static void pm3fb_cfb16_clear_margins(struct vc_data *conp, | ||
1959 | struct display *p, int bottom_only) | ||
1960 | { | ||
1961 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
1962 | int sx, sy; | ||
1963 | u32 c; | ||
1964 | |||
1965 | DTRACE; | ||
1966 | |||
1967 | sx = conp->vc_cols * fontwidth(p); /* right margin */ | ||
1968 | sy = conp->vc_rows * fontheight(p); /* bottom margin */ | ||
1969 | c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)]; | ||
1970 | c = c | (c << 16); | ||
1971 | |||
1972 | if (!bottom_only) { /* right margin top->bottom */ | ||
1973 | PM3_WAIT(4); | ||
1974 | |||
1975 | PM3_WRITE_REG(PM3Config2D, | ||
1976 | PM3Config2D_UseConstantSource | | ||
1977 | PM3Config2D_ForegroundROPEnable | | ||
1978 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
1979 | PM3Config2D_FBWriteEnable); | ||
1980 | |||
1981 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
1982 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
1983 | else | ||
1984 | PM3_WRITE_REG(PM3FBBlockColor, c); | ||
1985 | |||
1986 | PM3_WRITE_REG(PM3RectanglePosition, | ||
1987 | (PM3RectanglePosition_XOffset | ||
1988 | (p->var.xoffset + | ||
1989 | sx)) | (PM3RectanglePosition_YOffset(p-> | ||
1990 | var. | ||
1991 | yoffset))); | ||
1992 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
1993 | PM3_WRITE_REG(PM3Render2D, | ||
1994 | PM3Render2D_XPositive | | ||
1995 | PM3Render2D_YPositive | | ||
1996 | PM3Render2D_Operation_Normal | | ||
1997 | PM3Render2D_SpanOperation | | ||
1998 | (PM3Render2D_Width(p->var.xres - sx)) | | ||
1999 | (PM3Render2D_Height(p->var.yres))); | ||
2000 | else | ||
2001 | PM3_WRITE_REG(PM3Render2D, | ||
2002 | PM3Render2D_XPositive | | ||
2003 | PM3Render2D_YPositive | | ||
2004 | PM3Render2D_Operation_Normal | | ||
2005 | (PM3Render2D_Width(p->var.xres - sx)) | | ||
2006 | (PM3Render2D_Height(p->var.yres))); | ||
2007 | } | 487 | } |
2008 | |||
2009 | /* bottom margin left -> right */ | ||
2010 | PM3_WAIT(4); | ||
2011 | |||
2012 | PM3_WRITE_REG(PM3Config2D, | ||
2013 | PM3Config2D_UseConstantSource | | ||
2014 | PM3Config2D_ForegroundROPEnable | | ||
2015 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2016 | PM3Config2D_FBWriteEnable); | ||
2017 | |||
2018 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
2019 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
2020 | else | ||
2021 | PM3_WRITE_REG(PM3FBBlockColor, c); | ||
2022 | |||
2023 | |||
2024 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2025 | (PM3RectanglePosition_XOffset(p->var.xoffset)) | | ||
2026 | (PM3RectanglePosition_YOffset(p->var.yoffset + sy))); | ||
2027 | |||
2028 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
2029 | PM3_WRITE_REG(PM3Render2D, | ||
2030 | PM3Render2D_XPositive | | ||
2031 | PM3Render2D_YPositive | | ||
2032 | PM3Render2D_Operation_Normal | | ||
2033 | PM3Render2D_SpanOperation | | ||
2034 | (PM3Render2D_Width(p->var.xres)) | | ||
2035 | (PM3Render2D_Height(p->var.yres - sy))); | ||
2036 | else | ||
2037 | PM3_WRITE_REG(PM3Render2D, | ||
2038 | PM3Render2D_XPositive | | ||
2039 | PM3Render2D_YPositive | | ||
2040 | PM3Render2D_Operation_Normal | | ||
2041 | (PM3Render2D_Width(p->var.xres)) | | ||
2042 | (PM3Render2D_Height(p->var.yres - sy))); | ||
2043 | |||
2044 | pm3fb_wait_pm3(l_fb_info); | ||
2045 | } | ||
2046 | #endif /* FBCON_HAS_CFB16 */ | ||
2047 | #ifdef FBCON_HAS_CFB8 | ||
2048 | static void pm3fb_cfb8_clear(struct vc_data *conp, | ||
2049 | struct display *p, | ||
2050 | int sy, int sx, int height, int width) | ||
2051 | { | ||
2052 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2053 | u32 c; | ||
2054 | |||
2055 | DTRACE; | ||
2056 | |||
2057 | sx = sx * fontwidth(p); | ||
2058 | width = width * fontwidth(p); | ||
2059 | sy = sy * fontheight(p); | ||
2060 | height = height * fontheight(p); | ||
2061 | |||
2062 | c = attr_bgcol_ec(p, conp); | ||
2063 | c |= c << 8; | ||
2064 | c |= c << 16; | ||
2065 | 488 | ||
2066 | PM3_WAIT(4); | 489 | if (PICOS2KHZ(var->pixclock) > PM3_MAX_PIXCLOCK) { |
2067 | 490 | DPRINTK("pixclock too high (%ldKHz)\n", PICOS2KHZ(var->pixclock)); | |
2068 | PM3_WRITE_REG(PM3Config2D, | 491 | return -EINVAL; |
2069 | PM3Config2D_UseConstantSource | | ||
2070 | PM3Config2D_ForegroundROPEnable | | ||
2071 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2072 | PM3Config2D_FBWriteEnable); | ||
2073 | |||
2074 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
2075 | |||
2076 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2077 | (PM3RectanglePosition_XOffset(sx)) | | ||
2078 | (PM3RectanglePosition_YOffset(sy))); | ||
2079 | |||
2080 | PM3_WRITE_REG(PM3Render2D, | ||
2081 | PM3Render2D_XPositive | | ||
2082 | PM3Render2D_YPositive | | ||
2083 | PM3Render2D_Operation_Normal | | ||
2084 | PM3Render2D_SpanOperation | | ||
2085 | (PM3Render2D_Width(width)) | | ||
2086 | (PM3Render2D_Height(height))); | ||
2087 | |||
2088 | pm3fb_wait_pm3(l_fb_info); | ||
2089 | } | ||
2090 | |||
2091 | static void pm3fb_cfb8_clear_margins(struct vc_data *conp, | ||
2092 | struct display *p, int bottom_only) | ||
2093 | { | ||
2094 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2095 | int sx, sy; | ||
2096 | u32 c; | ||
2097 | |||
2098 | DTRACE; | ||
2099 | |||
2100 | sx = conp->vc_cols * fontwidth(p); /* right margin */ | ||
2101 | sy = conp->vc_rows * fontheight(p); /* bottom margin */ | ||
2102 | c = attr_bgcol_ec(p, conp); | ||
2103 | c |= c << 8; | ||
2104 | c |= c << 16; | ||
2105 | |||
2106 | if (!bottom_only) { /* right margin top->bottom */ | ||
2107 | PM3_WAIT(4); | ||
2108 | |||
2109 | PM3_WRITE_REG(PM3Config2D, | ||
2110 | PM3Config2D_UseConstantSource | | ||
2111 | PM3Config2D_ForegroundROPEnable | | ||
2112 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2113 | PM3Config2D_FBWriteEnable); | ||
2114 | |||
2115 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
2116 | |||
2117 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2118 | (PM3RectanglePosition_XOffset | ||
2119 | (p->var.xoffset + | ||
2120 | sx)) | (PM3RectanglePosition_YOffset(p-> | ||
2121 | var. | ||
2122 | yoffset))); | ||
2123 | |||
2124 | PM3_WRITE_REG(PM3Render2D, | ||
2125 | PM3Render2D_XPositive | | ||
2126 | PM3Render2D_YPositive | | ||
2127 | PM3Render2D_Operation_Normal | | ||
2128 | PM3Render2D_SpanOperation | | ||
2129 | (PM3Render2D_Width(p->var.xres - sx)) | | ||
2130 | (PM3Render2D_Height(p->var.yres))); | ||
2131 | } | 492 | } |
2132 | 493 | ||
2133 | /* bottom margin left -> right */ | 494 | var->accel_flags = 0; /* Can't mmap if this is on */ |
2134 | PM3_WAIT(4); | ||
2135 | |||
2136 | PM3_WRITE_REG(PM3Config2D, | ||
2137 | PM3Config2D_UseConstantSource | | ||
2138 | PM3Config2D_ForegroundROPEnable | | ||
2139 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2140 | PM3Config2D_FBWriteEnable); | ||
2141 | |||
2142 | PM3_WRITE_REG(PM3ForegroundColor, c); | ||
2143 | 495 | ||
2144 | PM3_WRITE_REG(PM3RectanglePosition, | 496 | DPRINTK("Checking graphics mode at %dx%d depth %d\n", |
2145 | (PM3RectanglePosition_XOffset(p->var.xoffset)) | | 497 | var->xres, var->yres, var->bits_per_pixel); |
2146 | (PM3RectanglePosition_YOffset(p->var.yoffset + sy))); | 498 | return 0; |
2147 | |||
2148 | PM3_WRITE_REG(PM3Render2D, | ||
2149 | PM3Render2D_XPositive | | ||
2150 | PM3Render2D_YPositive | | ||
2151 | PM3Render2D_Operation_Normal | | ||
2152 | PM3Render2D_SpanOperation | | ||
2153 | (PM3Render2D_Width(p->var.xres)) | | ||
2154 | (PM3Render2D_Height(p->var.yres - sy))); | ||
2155 | |||
2156 | pm3fb_wait_pm3(l_fb_info); | ||
2157 | } | ||
2158 | #endif /* FBCON_HAS_CFB8 */ | ||
2159 | #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32) | ||
2160 | static void pm3fb_cfbX_bmove(struct display *p, | ||
2161 | int sy, int sx, | ||
2162 | int dy, int dx, int height, int width) | ||
2163 | { | ||
2164 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2165 | int x_align, o_x, o_y; | ||
2166 | |||
2167 | DTRACE; | ||
2168 | |||
2169 | sx = sx * fontwidth(p); | ||
2170 | dx = dx * fontwidth(p); | ||
2171 | width = width * fontwidth(p); | ||
2172 | sy = sy * fontheight(p); | ||
2173 | dy = dy * fontheight(p); | ||
2174 | height = height * fontheight(p); | ||
2175 | |||
2176 | o_x = sx - dx; /*(sx > dx ) ? (sx - dx) : (dx - sx); */ | ||
2177 | o_y = sy - dy; /*(sy > dy ) ? (sy - dy) : (dy - sy); */ | ||
2178 | |||
2179 | x_align = (sx & 0x1f); | ||
2180 | |||
2181 | PM3_WAIT(6); | ||
2182 | |||
2183 | PM3_WRITE_REG(PM3Config2D, | ||
2184 | PM3Config2D_UserScissorEnable | | ||
2185 | PM3Config2D_ForegroundROPEnable | | ||
2186 | PM3Config2D_Blocking | | ||
2187 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2188 | PM3Config2D_FBWriteEnable); | ||
2189 | |||
2190 | PM3_WRITE_REG(PM3ScissorMinXY, | ||
2191 | ((dy & 0x0fff) << 16) | (dx & 0x0fff)); | ||
2192 | PM3_WRITE_REG(PM3ScissorMaxXY, | ||
2193 | (((dy + height) & 0x0fff) << 16) | | ||
2194 | ((dx + width) & 0x0fff)); | ||
2195 | |||
2196 | PM3_WRITE_REG(PM3FBSourceReadBufferOffset, | ||
2197 | PM3FBSourceReadBufferOffset_XOffset(o_x) | | ||
2198 | PM3FBSourceReadBufferOffset_YOffset(o_y)); | ||
2199 | |||
2200 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2201 | (PM3RectanglePosition_XOffset(dx - x_align)) | | ||
2202 | (PM3RectanglePosition_YOffset(dy))); | ||
2203 | |||
2204 | PM3_WRITE_REG(PM3Render2D, | ||
2205 | ((sx > dx) ? PM3Render2D_XPositive : 0) | | ||
2206 | ((sy > dy) ? PM3Render2D_YPositive : 0) | | ||
2207 | PM3Render2D_Operation_Normal | | ||
2208 | PM3Render2D_SpanOperation | | ||
2209 | PM3Render2D_FBSourceReadEnable | | ||
2210 | (PM3Render2D_Width(width + x_align)) | | ||
2211 | (PM3Render2D_Height(height))); | ||
2212 | |||
2213 | pm3fb_wait_pm3(l_fb_info); | ||
2214 | } | 499 | } |
2215 | 500 | ||
2216 | static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p, | 501 | static int pm3fb_set_par(struct fb_info *info) |
2217 | int c, int yy, int xx) | ||
2218 | { | 502 | { |
2219 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | 503 | struct pm3_par *par = info->par; |
2220 | u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0; | 504 | const u32 xres = (info->var.xres + 31) & ~31; |
2221 | u32 fgx, bgx, ldat; | 505 | const int depth = (info->var.bits_per_pixel + 7) & ~7; |
2222 | int sx, sy, i; | ||
2223 | |||
2224 | DTRACE; | ||
2225 | |||
2226 | if (l_fb_info->current_par->depth == 8) | ||
2227 | fgx = attr_fgcol(p, c); | ||
2228 | else if (depth2bpp(l_fb_info->current_par->depth) == 16) | ||
2229 | fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, c)]; | ||
2230 | else | ||
2231 | fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, c)]; | ||
2232 | |||
2233 | PM3_COLOR(fgx); | ||
2234 | |||
2235 | if (l_fb_info->current_par->depth == 8) | ||
2236 | bgx = attr_bgcol(p, c); | ||
2237 | else if (depth2bpp(l_fb_info->current_par->depth) == 16) | ||
2238 | bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, c)]; | ||
2239 | else | ||
2240 | bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, c)]; | ||
2241 | |||
2242 | PM3_COLOR(bgx); | ||
2243 | |||
2244 | PM3_WAIT(4); | ||
2245 | |||
2246 | PM3_WRITE_REG(PM3Config2D, | ||
2247 | PM3Config2D_UseConstantSource | | ||
2248 | PM3Config2D_ForegroundROPEnable | | ||
2249 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2250 | PM3Config2D_FBWriteEnable | PM3Config2D_OpaqueSpan); | ||
2251 | |||
2252 | PM3_WRITE_REG(PM3ForegroundColor, fgx); | ||
2253 | PM3_WRITE_REG(PM3FillBackgroundColor, bgx); | ||
2254 | |||
2255 | /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */ | ||
2256 | /* and 16 bits for fontwidth <= 16 */ | ||
2257 | /* same in _putcs, same for Y and fontheight */ | ||
2258 | if (fontwidth(p) <= 8) | ||
2259 | asx = 2; | ||
2260 | else if (fontwidth(p) <= 16) | ||
2261 | asx = 3; /* look OK */ | ||
2262 | if (fontheight(p) <= 8) | ||
2263 | asy = 2; | ||
2264 | else if (fontheight(p) <= 16) | ||
2265 | asy = 3; /* look OK */ | ||
2266 | else if (fontheight(p) <= 32) | ||
2267 | asy = 4; /* look OK */ | ||
2268 | |||
2269 | sx = xx * fontwidth(p); | ||
2270 | sy = yy * fontheight(p); | ||
2271 | |||
2272 | if (fontwidth(p) <= 8) | ||
2273 | o_x = (8 - (sx & 0x7)) & 0x7; | ||
2274 | else if (fontwidth(p) <= 16) | ||
2275 | o_x = (16 - (sx & 0xF)) & 0xF; | ||
2276 | if (fontheight(p) <= 8) | ||
2277 | o_y = (8 - (sy & 0x7)) & 0x7; | ||
2278 | else if (fontheight(p) <= 16) | ||
2279 | o_y = (16 - (sy & 0xF)) & 0xF; | ||
2280 | else if (fontheight(p) <= 32) | ||
2281 | o_y = (32 - (sy & 0x1F)) & 0x1F; | ||
2282 | |||
2283 | PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */ | ||
2284 | (1 << 18) | /* BE */ | ||
2285 | 1 | (asx << 1) | (asy << 4) | /* address select x/y */ | ||
2286 | (1 << 20)); /* OpaqueSpan */ | ||
2287 | |||
2288 | if (fontwidth(p) <= 8) { | ||
2289 | cdat = p->fontdata + (c & p->charmask) * fontheight(p); | ||
2290 | } else { | ||
2291 | cdat = | ||
2292 | p->fontdata + | ||
2293 | ((c & p->charmask) * (fontheight(p) << 1)); | ||
2294 | } | ||
2295 | |||
2296 | PM3_WAIT(2 + fontheight(p)); | ||
2297 | |||
2298 | for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */ | ||
2299 | if (fontwidth(p) <= 8) { | ||
2300 | ldat = *cdat++; | ||
2301 | } else { /* assume fontwidth <= 16 ATM */ | ||
2302 | |||
2303 | ldat = ((*cdat++) << 8); | ||
2304 | ldat |= *cdat++; | ||
2305 | } | ||
2306 | PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat); | ||
2307 | } | ||
2308 | 506 | ||
2309 | PM3_WRITE_REG(PM3RectanglePosition, | 507 | par->base = pm3fb_shift_bpp(info->var.bits_per_pixel, |
2310 | (PM3RectanglePosition_XOffset(sx)) | | 508 | (info->var.yoffset * xres) |
2311 | (PM3RectanglePosition_YOffset(sy))); | 509 | + info->var.xoffset); |
510 | par->video = 0; | ||
2312 | 511 | ||
2313 | PM3_WRITE_REG(PM3Render2D, | 512 | if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) |
2314 | PM3Render2D_AreaStippleEnable | | 513 | par->video |= PM3VideoControl_HSYNC_ACTIVE_HIGH; |
2315 | PM3Render2D_XPositive | | ||
2316 | PM3Render2D_YPositive | | ||
2317 | PM3Render2D_Operation_Normal | | ||
2318 | PM3Render2D_SpanOperation | | ||
2319 | (PM3Render2D_Width(fontwidth(p))) | | ||
2320 | (PM3Render2D_Height(fontheight(p)))); | ||
2321 | |||
2322 | pm3fb_wait_pm3(l_fb_info); | ||
2323 | } | ||
2324 | |||
2325 | static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p, | ||
2326 | const unsigned short *s, int count, int yy, | ||
2327 | int xx) | ||
2328 | { | ||
2329 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2330 | u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0; | ||
2331 | u32 fgx, bgx, ldat; | ||
2332 | int sx, sy, i, j; | ||
2333 | u16 sc; | ||
2334 | |||
2335 | DTRACE; | ||
2336 | |||
2337 | sc = scr_readw(s); | ||
2338 | if (l_fb_info->current_par->depth == 8) | ||
2339 | fgx = attr_fgcol(p, sc); | ||
2340 | else if (depth2bpp(l_fb_info->current_par->depth) == 16) | ||
2341 | fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, sc)]; | ||
2342 | else | ||
2343 | fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, sc)]; | ||
2344 | |||
2345 | PM3_COLOR(fgx); | ||
2346 | |||
2347 | if (l_fb_info->current_par->depth == 8) | ||
2348 | bgx = attr_bgcol(p, sc); | ||
2349 | else if (depth2bpp(l_fb_info->current_par->depth) == 16) | ||
2350 | bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, sc)]; | ||
2351 | else | 514 | else |
2352 | bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, sc)]; | 515 | par->video |= PM3VideoControl_HSYNC_ACTIVE_LOW; |
2353 | |||
2354 | PM3_COLOR(bgx); | ||
2355 | |||
2356 | PM3_WAIT(4); | ||
2357 | |||
2358 | PM3_WRITE_REG(PM3Config2D, | ||
2359 | PM3Config2D_UseConstantSource | | ||
2360 | PM3Config2D_ForegroundROPEnable | | ||
2361 | (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */ | ||
2362 | PM3Config2D_FBWriteEnable | | ||
2363 | PM3Config2D_OpaqueSpan); | ||
2364 | |||
2365 | PM3_WRITE_REG(PM3ForegroundColor, fgx); | ||
2366 | PM3_WRITE_REG(PM3FillBackgroundColor, bgx); | ||
2367 | |||
2368 | /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */ | ||
2369 | /* and 16 bits for fontwidth <= 16 */ | ||
2370 | /* same in _putc, same for Y and fontheight */ | ||
2371 | if (fontwidth(p) <= 8) | ||
2372 | asx = 2; | ||
2373 | else if (fontwidth(p) <= 16) | ||
2374 | asx = 3; /* look OK */ | ||
2375 | if (fontheight(p) <= 8) | ||
2376 | asy = 2; | ||
2377 | else if (fontheight(p) <= 16) | ||
2378 | asy = 3; /* look OK */ | ||
2379 | else if (fontheight(p) <= 32) | ||
2380 | asy = 4; /* look OK */ | ||
2381 | |||
2382 | sy = yy * fontheight(p); | ||
2383 | |||
2384 | if (fontheight(p) <= 8) | ||
2385 | o_y = (8 - (sy & 0x7)) & 0x7; | ||
2386 | else if (fontheight(p) <= 16) | ||
2387 | o_y = (16 - (sy & 0xF)) & 0xF; | ||
2388 | else if (fontheight(p) <= 32) | ||
2389 | o_y = (32 - (sy & 0x1F)) & 0x1F; | ||
2390 | |||
2391 | for (j = 0; j < count; j++) { | ||
2392 | sc = scr_readw(s + j); | ||
2393 | if (fontwidth(p) <= 8) | ||
2394 | cdat = p->fontdata + | ||
2395 | (sc & p->charmask) * fontheight(p); | ||
2396 | else | ||
2397 | cdat = p->fontdata + | ||
2398 | ((sc & p->charmask) * fontheight(p) << 1); | ||
2399 | |||
2400 | sx = (xx + j) * fontwidth(p); | ||
2401 | |||
2402 | if (fontwidth(p) <= 8) | ||
2403 | o_x = (8 - (sx & 0x7)) & 0x7; | ||
2404 | else if (fontwidth(p) <= 16) | ||
2405 | o_x = (16 - (sx & 0xF)) & 0xF; | ||
2406 | |||
2407 | PM3_WAIT(3 + fontheight(p)); | ||
2408 | |||
2409 | PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */ | ||
2410 | (1 << 18) | /* BE */ | ||
2411 | 1 | (asx << 1) | (asy << 4) | /* address select x/y */ | ||
2412 | (1 << 20)); /* OpaqueSpan */ | ||
2413 | |||
2414 | for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */ | ||
2415 | if (fontwidth(p) <= 8) { | ||
2416 | ldat = *cdat++; | ||
2417 | } else { /* assume fontwidth <= 16 ATM */ | ||
2418 | ldat = ((*cdat++) << 8); | ||
2419 | ldat |= *cdat++; | ||
2420 | } | ||
2421 | PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat); | ||
2422 | } | ||
2423 | |||
2424 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2425 | (PM3RectanglePosition_XOffset(sx)) | | ||
2426 | (PM3RectanglePosition_YOffset(sy))); | ||
2427 | |||
2428 | PM3_WRITE_REG(PM3Render2D, | ||
2429 | PM3Render2D_AreaStippleEnable | | ||
2430 | PM3Render2D_XPositive | | ||
2431 | PM3Render2D_YPositive | | ||
2432 | PM3Render2D_Operation_Normal | | ||
2433 | PM3Render2D_SpanOperation | | ||
2434 | (PM3Render2D_Width(fontwidth(p))) | | ||
2435 | (PM3Render2D_Height(fontheight(p)))); | ||
2436 | } | ||
2437 | pm3fb_wait_pm3(l_fb_info); | ||
2438 | } | ||
2439 | |||
2440 | static void pm3fb_cfbX_revc(struct display *p, int xx, int yy) | ||
2441 | { | ||
2442 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; | ||
2443 | |||
2444 | xx = xx * fontwidth(p); | ||
2445 | yy = yy * fontheight(p); | ||
2446 | |||
2447 | if (l_fb_info->current_par->depth == 8) | ||
2448 | { | ||
2449 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
2450 | PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0x0F0F0F0F); | ||
2451 | else | ||
2452 | PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0x0F0F0F0F); | ||
2453 | } | ||
2454 | |||
2455 | PM3_WAIT(3); | ||
2456 | |||
2457 | PM3_WRITE_REG(PM3Config2D, | ||
2458 | PM3Config2D_UseConstantSource | | ||
2459 | PM3Config2D_ForegroundROPEnable | | ||
2460 | (PM3Config2D_ForegroundROP(0xa)) | /* Oxa is GXinvert */ | ||
2461 | PM3Config2D_FBDestReadEnable | | ||
2462 | PM3Config2D_FBWriteEnable); | ||
2463 | |||
2464 | PM3_WRITE_REG(PM3RectanglePosition, | ||
2465 | (PM3RectanglePosition_XOffset(xx)) | | ||
2466 | (PM3RectanglePosition_YOffset(yy))); | ||
2467 | |||
2468 | PM3_WRITE_REG(PM3Render2D, | ||
2469 | PM3Render2D_XPositive | | ||
2470 | PM3Render2D_YPositive | | ||
2471 | PM3Render2D_Operation_Normal | | ||
2472 | PM3Render2D_SpanOperation | | ||
2473 | (PM3Render2D_Width(fontwidth(p))) | | ||
2474 | (PM3Render2D_Height(fontheight(p)))); | ||
2475 | |||
2476 | pm3fb_wait_pm3(l_fb_info); | ||
2477 | |||
2478 | if (l_fb_info->current_par->depth == 8) | ||
2479 | { | ||
2480 | if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask) | ||
2481 | PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xFFFFFFFF); | ||
2482 | else | ||
2483 | PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xFFFFFFFF); | ||
2484 | } | ||
2485 | } | ||
2486 | |||
2487 | #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */ | ||
2488 | #endif /* PM3FB_USE_ACCEL */ | ||
2489 | /* *********************************** */ | ||
2490 | /* ***** pre-init board(s) setup ***** */ | ||
2491 | /* *********************************** */ | ||
2492 | |||
2493 | static void pm3fb_mode_setup(char *mode, unsigned long board_num) | ||
2494 | { | ||
2495 | struct pm3fb_info *l_fb_info = &(fb_info[board_num]); | ||
2496 | struct pm3fb_par *l_fb_par = &(current_par[board_num]); | ||
2497 | unsigned long i = 0; | ||
2498 | |||
2499 | current_par_valid[board_num] = 0; | ||
2500 | |||
2501 | if (!strncmp(mode, "current", 7)) { | ||
2502 | l_fb_info->use_current = 1; /* default w/ OpenFirmware */ | ||
2503 | } else { | ||
2504 | while ((mode_base[i].name[0]) | ||
2505 | && (!current_par_valid[board_num])) { | ||
2506 | if (! | ||
2507 | (strncmp | ||
2508 | (mode, mode_base[i].name, | ||
2509 | strlen(mode_base[i].name)))) { | ||
2510 | memcpy(l_fb_par, &(mode_base[i].user_mode), | ||
2511 | sizeof(struct pm3fb_par)); | ||
2512 | current_par_valid[board_num] = 1; | ||
2513 | DPRINTK(2, "Mode set to %s\n", | ||
2514 | mode_base[i].name); | ||
2515 | } | ||
2516 | i++; | ||
2517 | } | ||
2518 | DASSERT(current_par_valid[board_num], | ||
2519 | "Valid mode on command line\n"); | ||
2520 | } | ||
2521 | } | ||
2522 | |||
2523 | static void pm3fb_pciid_setup(char *pciid, unsigned long board_num) | ||
2524 | { | ||
2525 | short l_bus = -1, l_slot = -1, l_func = -1; | ||
2526 | char *next; | ||
2527 | |||
2528 | if (pciid) { | ||
2529 | l_bus = simple_strtoul(pciid, &next, 10); | ||
2530 | if (next && (next[0] == ':')) { | ||
2531 | pciid = next + 1; | ||
2532 | l_slot = simple_strtoul(pciid, &next, 10); | ||
2533 | if (next && (next[0] == ':')) { | ||
2534 | pciid = next + 1; | ||
2535 | l_func = | ||
2536 | simple_strtoul(pciid, (char **) NULL, | ||
2537 | 10); | ||
2538 | } | ||
2539 | } | ||
2540 | } else | ||
2541 | return; | ||
2542 | |||
2543 | if ((l_bus >= 0) && (l_slot >= 0) && (l_func >= 0)) { | ||
2544 | bus[board_num] = l_bus; | ||
2545 | slot[board_num] = l_slot; | ||
2546 | func[board_num] = l_func; | ||
2547 | DPRINTK(2, "Board #%ld will be PciId: %hd:%hd:%hd\n", | ||
2548 | board_num, l_bus, l_slot, l_func); | ||
2549 | } else { | ||
2550 | DPRINTK(1, "Invalid PciId: %hd:%hd:%hd for board #%ld\n", | ||
2551 | l_bus, l_slot, l_func, board_num); | ||
2552 | } | ||
2553 | } | ||
2554 | |||
2555 | static void pm3fb_font_setup(char *lf, unsigned long board_num) | ||
2556 | { | ||
2557 | unsigned long lfs = strlen(lf); | ||
2558 | |||
2559 | if (lfs > (PM3_FONTNAME_SIZE - 1)) { | ||
2560 | DPRINTK(1, "Fontname %s too long\n", lf); | ||
2561 | return; | ||
2562 | } | ||
2563 | strlcpy(fontn[board_num], lf, lfs + 1); | ||
2564 | } | ||
2565 | |||
2566 | static void pm3fb_bootdepth_setup(char *bds, unsigned long board_num) | ||
2567 | { | ||
2568 | unsigned long bd = simple_strtoul(bds, (char **) NULL, 10); | ||
2569 | |||
2570 | if (!(depth_supported(bd))) { | ||
2571 | printk(KERN_WARNING "pm3fb: ignoring invalid depth %s for board #%ld\n", | ||
2572 | bds, board_num); | ||
2573 | return; | ||
2574 | } | ||
2575 | depth[board_num] = bd; | ||
2576 | } | ||
2577 | |||
2578 | static void pm3fb_forcesize_setup(char *bds, unsigned long board_num) | ||
2579 | { | ||
2580 | unsigned long bd = simple_strtoul(bds, (char **) NULL, 10); | ||
2581 | |||
2582 | if (bd > 64) { | ||
2583 | printk(KERN_WARNING "pm3fb: ignoring invalid memory size %s for board #%ld\n", | ||
2584 | bds, board_num); | ||
2585 | return; | ||
2586 | } | ||
2587 | forcesize[board_num] = bd; | ||
2588 | } | ||
2589 | |||
2590 | static char *pm3fb_boardnum_setup(char *options, unsigned long *bn) | ||
2591 | { | ||
2592 | char *next; | ||
2593 | |||
2594 | if (!(isdigit(options[0]))) { | ||
2595 | (*bn) = 0; | ||
2596 | return (options); | ||
2597 | } | ||
2598 | |||
2599 | (*bn) = simple_strtoul(options, &next, 10); | ||
2600 | 516 | ||
2601 | if (next && (next[0] == ':') && ((*bn) >= 0) | 517 | if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) |
2602 | && ((*bn) <= PM3_MAX_BOARD)) { | 518 | par->video |= PM3VideoControl_VSYNC_ACTIVE_HIGH; |
2603 | DPRINTK(2, "Board_num seen as %ld\n", (*bn)); | ||
2604 | return (next + 1); | ||
2605 | } else { | ||
2606 | (*bn) = 0; | ||
2607 | DPRINTK(2, "Board_num default to %ld\n", (*bn)); | ||
2608 | return (options); | ||
2609 | } | ||
2610 | } | ||
2611 | |||
2612 | static void pm3fb_real_setup(char *options) | ||
2613 | { | ||
2614 | char *next; | ||
2615 | unsigned long i, bn; | ||
2616 | struct pm3fb_info *l_fb_info; | ||
2617 | |||
2618 | DTRACE; | ||
2619 | |||
2620 | DPRINTK(2, "Options : %s\n", options); | ||
2621 | |||
2622 | for (i = 0; i < PM3_MAX_BOARD; i++) { | ||
2623 | l_fb_info = &(fb_info[i]); | ||
2624 | memset(l_fb_info, 0, sizeof(struct pm3fb_info)); | ||
2625 | l_fb_info->gen.fbhw = &pm3fb_switch; | ||
2626 | l_fb_info->board_num = i; | ||
2627 | current_par_valid[i] = 0; | ||
2628 | slot[i] = -1; | ||
2629 | func[i] = -1; | ||
2630 | bus[i] = -1; | ||
2631 | disable[i] = 0; | ||
2632 | noaccel[i] = 0; | ||
2633 | fontn[i][0] = '\0'; | ||
2634 | depth[i] = 0; | ||
2635 | l_fb_info->current_par = &(current_par[i]); | ||
2636 | } | ||
2637 | |||
2638 | /* eat up prefix pm3fb and whatever is used as separator i.e. :,= */ | ||
2639 | if (!strncmp(options, "pm3fb", 5)) { | ||
2640 | options += 5; | ||
2641 | while (((*options) == ',') || ((*options) == ':') | ||
2642 | || ((*options) == '=')) | ||
2643 | options++; | ||
2644 | } | ||
2645 | |||
2646 | while (options) { | ||
2647 | bn = 0; | ||
2648 | if ((next = strchr(options, ','))) { | ||
2649 | (*next) = '\0'; | ||
2650 | next++; | ||
2651 | } | ||
2652 | |||
2653 | if (!strncmp(options, "mode:", 5)) { | ||
2654 | options = pm3fb_boardnum_setup(options + 5, &bn); | ||
2655 | DPRINTK(2, "Setting mode for board #%ld\n", bn); | ||
2656 | pm3fb_mode_setup(options, bn); | ||
2657 | } else if (!strncmp(options, "off:", 4)) { | ||
2658 | options = pm3fb_boardnum_setup(options + 4, &bn); | ||
2659 | DPRINTK(2, "Disabling board #%ld\n", bn); | ||
2660 | disable[bn] = 1; | ||
2661 | } else if (!strncmp(options, "off", 3)) { /* disable everything */ | ||
2662 | for (i = 0; i < PM3_MAX_BOARD; i++) | ||
2663 | disable[i] = 1; | ||
2664 | } else if (!strncmp(options, "disable:", 8)) { | ||
2665 | options = pm3fb_boardnum_setup(options + 8, &bn); | ||
2666 | DPRINTK(2, "Disabling board #%ld\n", bn); | ||
2667 | disable[bn] = 1; | ||
2668 | } else if (!strncmp(options, "pciid:", 6)) { | ||
2669 | options = pm3fb_boardnum_setup(options + 6, &bn); | ||
2670 | DPRINTK(2, "Setting PciID for board #%ld\n", bn); | ||
2671 | pm3fb_pciid_setup(options, bn); | ||
2672 | } else if (!strncmp(options, "noaccel:", 8)) { | ||
2673 | options = pm3fb_boardnum_setup(options + 8, &bn); | ||
2674 | noaccel[bn] = 1; | ||
2675 | } else if (!strncmp(options, "font:", 5)) { | ||
2676 | options = pm3fb_boardnum_setup(options + 5, &bn); | ||
2677 | pm3fb_font_setup(options, bn); | ||
2678 | } else if (!strncmp(options, "depth:", 6)) { | ||
2679 | options = pm3fb_boardnum_setup(options + 6, &bn); | ||
2680 | pm3fb_bootdepth_setup(options, bn); | ||
2681 | } else if (!strncmp(options, "printtimings", 12)) { | ||
2682 | printtimings = 1; | ||
2683 | } else if (!strncmp(options, "flatpanel:", 10)) { | ||
2684 | options = pm3fb_boardnum_setup(options + 10, &bn); | ||
2685 | flatpanel[bn] = 1; | ||
2686 | } else if (!strncmp(options, "forcesize:", 10)) { | ||
2687 | options = pm3fb_boardnum_setup(options + 10, &bn); | ||
2688 | pm3fb_forcesize_setup(options, bn); | ||
2689 | } | ||
2690 | options = next; | ||
2691 | } | ||
2692 | } | ||
2693 | |||
2694 | /* ********************************************** */ | ||
2695 | /* ***** framebuffer API standard functions ***** */ | ||
2696 | /* ********************************************** */ | ||
2697 | |||
2698 | static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix, | ||
2699 | const void *par, struct fb_info_gen *info) | ||
2700 | { | ||
2701 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
2702 | struct pm3fb_par *p = (struct pm3fb_par *) par; | ||
2703 | |||
2704 | DTRACE; | ||
2705 | |||
2706 | strcpy(fix->id, permedia3_name); | ||
2707 | fix->smem_start = (unsigned long)l_fb_info->p_fb; | ||
2708 | fix->smem_len = l_fb_info->fb_size; | ||
2709 | fix->mmio_start = (unsigned long)l_fb_info->pIOBase; | ||
2710 | fix->mmio_len = PM3_REGS_SIZE; | ||
2711 | #ifdef PM3FB_USE_ACCEL | ||
2712 | if (!(noaccel[l_fb_info->board_num])) | ||
2713 | fix->accel = FB_ACCEL_3DLABS_PERMEDIA3; | ||
2714 | else | ||
2715 | #endif /* PM3FB_USE_ACCEL */ | ||
2716 | fix->accel = FB_ACCEL_NONE; | ||
2717 | fix->type = FB_TYPE_PACKED_PIXELS; | ||
2718 | fix->visual = | ||
2719 | (p->depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; | ||
2720 | if (current_par_valid[l_fb_info->board_num]) | ||
2721 | fix->line_length = | ||
2722 | l_fb_info->current_par->width * | ||
2723 | depth2ByPP(l_fb_info->current_par->depth); | ||
2724 | else | 519 | else |
2725 | fix->line_length = 0; | 520 | par->video |= PM3VideoControl_VSYNC_ACTIVE_LOW; |
2726 | fix->xpanstep = 64 / depth2bpp(p->depth); | ||
2727 | fix->ypanstep = 1; | ||
2728 | fix->ywrapstep = 0; | ||
2729 | return (0); | ||
2730 | } | ||
2731 | |||
2732 | static int pm3fb_decode_var(const struct fb_var_screeninfo *var, | ||
2733 | void *par, struct fb_info_gen *info) | ||
2734 | { | ||
2735 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
2736 | struct pm3fb_par *p = (struct pm3fb_par *) par; | ||
2737 | struct pm3fb_par temp_p; | ||
2738 | u32 xres; | ||
2739 | |||
2740 | DTRACE; | ||
2741 | |||
2742 | DASSERT((var != NULL), "fb_var_screeninfo* not NULL"); | ||
2743 | DASSERT((p != NULL), "pm3fb_par* not NULL"); | ||
2744 | DASSERT((l_fb_info != NULL), "pm3fb_info* not NULL"); | ||
2745 | 521 | ||
2746 | memset(&temp_p, 0, sizeof(struct pm3fb_par)); | 522 | if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) |
2747 | temp_p.width = (var->xres_virtual + 7) & ~7; | 523 | par->video |= PM3VideoControl_LINE_DOUBLE_ON; |
2748 | temp_p.height = var->yres_virtual; | ||
2749 | |||
2750 | if (!(depth_supported(var->bits_per_pixel))) /* round unsupported up to a multiple of 8 */ | ||
2751 | temp_p.depth = depth2bpp(var->bits_per_pixel); | ||
2752 | else | 524 | else |
2753 | temp_p.depth = var->bits_per_pixel; | 525 | par->video |= PM3VideoControl_LINE_DOUBLE_OFF; |
2754 | |||
2755 | temp_p.depth = (temp_p.depth > 32) ? 32 : temp_p.depth; /* max 32 */ | ||
2756 | temp_p.depth = (temp_p.depth == 24) ? 32 : temp_p.depth; /* 24 unsupported, round-up to 32 */ | ||
2757 | |||
2758 | if ((temp_p.depth == 16) && (var->red.length == 5) && (var->green.length == 5) && (var->blue.length == 5)) | ||
2759 | temp_p.depth = 15; /* RGBA 5551 is stored as depth 15 */ | ||
2760 | |||
2761 | if ((temp_p.depth == 16) && (var->red.length == 4) && (var->green.length == 4) && (var->blue.length == 4)) | ||
2762 | temp_p.depth = 12; /* RGBA 4444 is stored as depth 12 */ | ||
2763 | |||
2764 | |||
2765 | DPRINTK(2, | ||
2766 | "xres: %d, yres: %d, vxres: %d, vyres: %d ; xoffset:%d, yoffset: %d\n", | ||
2767 | var->xres, var->yres, var->xres_virtual, var->yres_virtual, | ||
2768 | var->xoffset, var->yoffset); | ||
2769 | |||
2770 | xres = (var->xres + 31) & ~31; | ||
2771 | if (temp_p.width < xres + var->xoffset) | ||
2772 | temp_p.width = xres + var->xoffset; | ||
2773 | if (temp_p.height < var->yres + var->yoffset) | ||
2774 | temp_p.height = var->yres + var->yoffset; | ||
2775 | |||
2776 | if (temp_p.width > 2048) { | ||
2777 | DPRINTK(1, "virtual width not supported: %u\n", | ||
2778 | temp_p.width); | ||
2779 | return (-EINVAL); | ||
2780 | } | ||
2781 | if (var->yres < 200) { | ||
2782 | DPRINTK(1, "height not supported: %u\n", (u32) var->yres); | ||
2783 | return (-EINVAL); | ||
2784 | } | ||
2785 | if (temp_p.height < 200 || temp_p.height > 4095) { | ||
2786 | DPRINTK(1, "virtual height not supported: %u\n", | ||
2787 | temp_p.height); | ||
2788 | return (-EINVAL); | ||
2789 | } | ||
2790 | if (!(depth_supported(temp_p.depth))) { | ||
2791 | DPRINTK(1, "depth not supported: %u\n", temp_p.depth); | ||
2792 | return (-EINVAL); | ||
2793 | } | ||
2794 | if ((temp_p.width * temp_p.height * depth2ByPP(temp_p.depth)) > | ||
2795 | l_fb_info->fb_size) { | ||
2796 | DPRINTK(1, "no memory for screen (%ux%ux%u)\n", | ||
2797 | temp_p.width, temp_p.height, temp_p.depth); | ||
2798 | return (-EINVAL); | ||
2799 | } | ||
2800 | |||
2801 | if ((!var->pixclock) || | ||
2802 | (!var->right_margin) || | ||
2803 | (!var->hsync_len) || | ||
2804 | (!var->left_margin) || | ||
2805 | (!var->lower_margin) || | ||
2806 | (!var->vsync_len) || (!var->upper_margin) | ||
2807 | ) { | ||
2808 | unsigned long i = 0, done = 0; | ||
2809 | printk(KERN_WARNING "pm3fb: refusing to use a likely wrong timing\n"); | ||
2810 | |||
2811 | while ((mode_base[i].user_mode.width) && !done) { | ||
2812 | if ((mode_base[i].user_mode.width == temp_p.width) | ||
2813 | && (mode_base[i].user_mode.height == | ||
2814 | temp_p.height)) { | ||
2815 | printk(KERN_NOTICE "pm3fb: using close match %s\n", | ||
2816 | mode_base[i].name); | ||
2817 | temp_p = mode_base[i].user_mode; | ||
2818 | done = 1; | ||
2819 | } | ||
2820 | i++; | ||
2821 | } | ||
2822 | if (!done) | ||
2823 | return (-EINVAL); | ||
2824 | } else { | ||
2825 | temp_p.pixclock = PICOS2KHZ(var->pixclock); | ||
2826 | if (temp_p.pixclock > PM3_MAX_PIXCLOCK) { | ||
2827 | DPRINTK(1, "pixclock too high (%uKHz)\n", | ||
2828 | temp_p.pixclock); | ||
2829 | return (-EINVAL); | ||
2830 | } | ||
2831 | |||
2832 | temp_p.hsstart = var->right_margin; | ||
2833 | temp_p.hsend = var->right_margin + var->hsync_len; | ||
2834 | temp_p.hbend = | ||
2835 | var->right_margin + var->hsync_len + var->left_margin; | ||
2836 | temp_p.htotal = xres + temp_p.hbend; | ||
2837 | |||
2838 | temp_p.vsstart = var->lower_margin; | ||
2839 | temp_p.vsend = var->lower_margin + var->vsync_len; | ||
2840 | temp_p.vbend = | ||
2841 | var->lower_margin + var->vsync_len + var->upper_margin; | ||
2842 | temp_p.vtotal = var->yres + temp_p.vbend; | ||
2843 | |||
2844 | temp_p.stride = temp_p.width; | ||
2845 | |||
2846 | DPRINTK(2, "Using %d * %d, %d Khz, stride is %08x\n", | ||
2847 | temp_p.width, temp_p.height, temp_p.pixclock, | ||
2848 | temp_p.stride); | ||
2849 | |||
2850 | temp_p.base = | ||
2851 | pm3fb_Shiftbpp(l_fb_info, temp_p.depth, | ||
2852 | (var->yoffset * xres) + var->xoffset); | ||
2853 | 526 | ||
2854 | temp_p.video = 0; | 527 | if (info->var.activate == FB_ACTIVATE_NOW) |
2855 | 528 | par->video |= PM3VideoControl_ENABLE; | |
2856 | if (var->sync & FB_SYNC_HOR_HIGH_ACT) | 529 | else { |
2857 | temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_HIGH; | 530 | par->video |= PM3VideoControl_DISABLE; |
2858 | else | 531 | DPRINTK("PM3Video disabled\n"); |
2859 | temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_LOW; | ||
2860 | |||
2861 | if (var->sync & FB_SYNC_VERT_HIGH_ACT) | ||
2862 | temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_HIGH; | ||
2863 | else | ||
2864 | temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_LOW; | ||
2865 | |||
2866 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { | ||
2867 | DPRINTK(1, "Interlaced mode not supported\n\n"); | ||
2868 | return (-EINVAL); | ||
2869 | } | ||
2870 | |||
2871 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) | ||
2872 | temp_p.video |= PM3VideoControl_LINE_DOUBLE_ON; | ||
2873 | else | ||
2874 | temp_p.video |= PM3VideoControl_LINE_DOUBLE_OFF; | ||
2875 | |||
2876 | if (var->activate == FB_ACTIVATE_NOW) | ||
2877 | temp_p.video |= PM3VideoControl_ENABLE; | ||
2878 | else { | ||
2879 | temp_p.video |= PM3VideoControl_DISABLE; | ||
2880 | DPRINTK(2, "PM3Video disabled\n"); | ||
2881 | } | ||
2882 | |||
2883 | switch (temp_p.depth) { | ||
2884 | case 8: | ||
2885 | temp_p.video |= PM3VideoControl_PIXELSIZE_8BIT; | ||
2886 | break; | ||
2887 | case 12: | ||
2888 | case 15: | ||
2889 | case 16: | ||
2890 | temp_p.video |= PM3VideoControl_PIXELSIZE_16BIT; | ||
2891 | break; | ||
2892 | case 32: | ||
2893 | temp_p.video |= PM3VideoControl_PIXELSIZE_32BIT; | ||
2894 | break; | ||
2895 | default: | ||
2896 | DPRINTK(1, "Unsupported depth\n"); | ||
2897 | break; | ||
2898 | } | ||
2899 | } | 532 | } |
2900 | (*p) = temp_p; | 533 | switch (depth) { |
2901 | |||
2902 | #ifdef PM3FB_USE_ACCEL | ||
2903 | if (var->accel_flags & FB_ACCELF_TEXT) | ||
2904 | noaccel[l_fb_info->board_num] = 0; | ||
2905 | else | ||
2906 | noaccel[l_fb_info->board_num] = 1; | ||
2907 | #endif /* PM3FB_USE_ACCEL */ | ||
2908 | |||
2909 | return (0); | ||
2910 | } | ||
2911 | |||
2912 | static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d) | ||
2913 | { | ||
2914 | switch (d) { | ||
2915 | case 8: | 534 | case 8: |
2916 | var->red.length = var->green.length = var->blue.length = 8; | 535 | par->video |= PM3VideoControl_PIXELSIZE_8BIT; |
2917 | var->red.offset = var->green.offset = var->blue.offset = 0; | ||
2918 | var->transp.offset = var->transp.length = 0; | ||
2919 | break; | 536 | break; |
2920 | |||
2921 | case 12: | 537 | case 12: |
2922 | var->red.offset = 8; | ||
2923 | var->red.length = 4; | ||
2924 | var->green.offset = 4; | ||
2925 | var->green.length = 4; | ||
2926 | var->blue.offset = 0; | ||
2927 | var->blue.length = 4; | ||
2928 | var->transp.offset = 12; | ||
2929 | var->transp.length = 4; | ||
2930 | break; | ||
2931 | |||
2932 | case 15: | 538 | case 15: |
2933 | var->red.offset = 10; | ||
2934 | var->red.length = 5; | ||
2935 | var->green.offset = 5; | ||
2936 | var->green.length = 5; | ||
2937 | var->blue.offset = 0; | ||
2938 | var->blue.length = 5; | ||
2939 | var->transp.offset = 15; | ||
2940 | var->transp.length = 1; | ||
2941 | break; | ||
2942 | |||
2943 | case 16: | 539 | case 16: |
2944 | var->red.offset = 11; | 540 | par->video |= PM3VideoControl_PIXELSIZE_16BIT; |
2945 | var->red.length = 5; | ||
2946 | var->green.offset = 5; | ||
2947 | var->green.length = 6; | ||
2948 | var->blue.offset = 0; | ||
2949 | var->blue.length = 5; | ||
2950 | var->transp.offset = var->transp.length = 0; | ||
2951 | break; | 541 | break; |
2952 | |||
2953 | case 32: | 542 | case 32: |
2954 | var->transp.offset = 24; | 543 | par->video |= PM3VideoControl_PIXELSIZE_32BIT; |
2955 | var->red.offset = 16; | ||
2956 | var->green.offset = 8; | ||
2957 | var->blue.offset = 0; | ||
2958 | var->red.length = var->green.length = | ||
2959 | var->blue.length = var->transp.length = 8; | ||
2960 | break; | 544 | break; |
2961 | |||
2962 | default: | 545 | default: |
2963 | DPRINTK(1, "Unsupported depth %ld\n", d); | 546 | DPRINTK("Unsupported depth\n"); |
2964 | break; | 547 | break; |
2965 | } | 548 | } |
2966 | } | ||
2967 | |||
2968 | static int pm3fb_encode_var(struct fb_var_screeninfo *var, | ||
2969 | const void *par, struct fb_info_gen *info) | ||
2970 | { | ||
2971 | struct pm3fb_par *p = (struct pm3fb_par *) par; | ||
2972 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
2973 | |||
2974 | u32 base; | ||
2975 | |||
2976 | DTRACE; | ||
2977 | |||
2978 | DASSERT((var != NULL), "fb_var_screeninfo* not NULL"); | ||
2979 | DASSERT((p != NULL), "pm3fb_par* not NULL"); | ||
2980 | DASSERT((info != NULL), "fb_info_gen* not NULL"); | ||
2981 | |||
2982 | memset(var, 0, sizeof(struct fb_var_screeninfo)); | ||
2983 | |||
2984 | #ifdef PM3FB_USE_ACCEL | ||
2985 | if (!(noaccel[l_fb_info->board_num])) | ||
2986 | var->accel_flags |= FB_ACCELF_TEXT; | ||
2987 | #endif /* PM3FB_USE_ACCEL */ | ||
2988 | |||
2989 | var->xres_virtual = p->width; | ||
2990 | var->yres_virtual = p->height; | ||
2991 | var->xres = p->htotal - p->hbend; | ||
2992 | var->yres = p->vtotal - p->vbend; | ||
2993 | |||
2994 | DPRINTK(2, "xres = %d, yres : %d\n", var->xres, var->yres); | ||
2995 | |||
2996 | var->right_margin = p->hsstart; | ||
2997 | var->hsync_len = p->hsend - p->hsstart; | ||
2998 | var->left_margin = p->hbend - p->hsend; | ||
2999 | var->lower_margin = p->vsstart; | ||
3000 | var->vsync_len = p->vsend - p->vsstart; | ||
3001 | var->upper_margin = p->vbend - p->vsend; | ||
3002 | var->bits_per_pixel = depth2bpp(p->depth); | ||
3003 | |||
3004 | pm3fb_encode_depth(var, p->depth); | ||
3005 | |||
3006 | base = pm3fb_Unshiftbpp(l_fb_info, p->depth, p->base); | ||
3007 | |||
3008 | var->xoffset = base % var->xres; | ||
3009 | var->yoffset = base / var->xres; | ||
3010 | |||
3011 | var->height = var->width = -1; | ||
3012 | |||
3013 | var->pixclock = KHZ2PICOS(p->pixclock); | ||
3014 | |||
3015 | if ((p->video & PM3VideoControl_HSYNC_MASK) == | ||
3016 | PM3VideoControl_HSYNC_ACTIVE_HIGH) | ||
3017 | var->sync |= FB_SYNC_HOR_HIGH_ACT; | ||
3018 | if ((p->video & PM3VideoControl_VSYNC_MASK) == | ||
3019 | PM3VideoControl_VSYNC_ACTIVE_HIGH) | ||
3020 | var->sync |= FB_SYNC_VERT_HIGH_ACT; | ||
3021 | if (p->video & PM3VideoControl_LINE_DOUBLE_ON) | ||
3022 | var->vmode = FB_VMODE_DOUBLE; | ||
3023 | |||
3024 | return (0); | ||
3025 | } | ||
3026 | |||
3027 | static void pm3fb_get_par(void *par, struct fb_info_gen *info) | ||
3028 | { | ||
3029 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3030 | |||
3031 | DTRACE; | ||
3032 | |||
3033 | if (!current_par_valid[l_fb_info->board_num]) { | ||
3034 | if (l_fb_info->use_current) | ||
3035 | pm3fb_read_mode(l_fb_info, l_fb_info->current_par); | ||
3036 | else | ||
3037 | memcpy(l_fb_info->current_par, | ||
3038 | &(mode_base[0].user_mode), | ||
3039 | sizeof(struct pm3fb_par)); | ||
3040 | current_par_valid[l_fb_info->board_num] = 1; | ||
3041 | } | ||
3042 | *((struct pm3fb_par *) par) = *(l_fb_info->current_par); | ||
3043 | } | ||
3044 | |||
3045 | static void pm3fb_set_par(const void *par, struct fb_info_gen *info) | ||
3046 | { | ||
3047 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3048 | |||
3049 | DTRACE; | ||
3050 | 549 | ||
3051 | *(l_fb_info->current_par) = *((struct pm3fb_par *) par); | 550 | info->fix.visual = |
3052 | current_par_valid[l_fb_info->board_num] = 1; | 551 | (depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
552 | info->fix.line_length = ((info->var.xres_virtual + 7) & ~7) | ||
553 | * depth / 8; | ||
3053 | 554 | ||
3054 | pm3fb_write_mode(l_fb_info); | 555 | /* pm3fb_clear_memory(info, 0);*/ |
3055 | 556 | pm3fb_clear_colormap(par, 0, 0, 0); | |
3056 | #ifdef PM3FB_USE_ACCEL | 557 | PM3_WRITE_DAC_REG(par, PM3RD_CursorMode, |
3057 | pm3fb_init_engine(l_fb_info); | 558 | PM3RD_CursorMode_CURSOR_DISABLE); |
3058 | #endif /* PM3FB_USE_ACCEL */ | 559 | pm3fb_write_mode(info); |
3059 | } | 560 | return 0; |
3060 | |||
3061 | static void pm3fb_set_color(struct pm3fb_info *l_fb_info, | ||
3062 | unsigned char regno, unsigned char r, | ||
3063 | unsigned char g, unsigned char b) | ||
3064 | { | ||
3065 | DTRACE; | ||
3066 | |||
3067 | PM3_SLOW_WRITE_REG(PM3RD_PaletteWriteAddress, regno); | ||
3068 | PM3_SLOW_WRITE_REG(PM3RD_PaletteData, r); | ||
3069 | PM3_SLOW_WRITE_REG(PM3RD_PaletteData, g); | ||
3070 | PM3_SLOW_WRITE_REG(PM3RD_PaletteData, b); | ||
3071 | } | ||
3072 | |||
3073 | static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green, | ||
3074 | unsigned *blue, unsigned *transp, | ||
3075 | struct fb_info *info) | ||
3076 | { | ||
3077 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3078 | |||
3079 | DTRACE; | ||
3080 | |||
3081 | if (regno < 256) { | ||
3082 | *red = | ||
3083 | l_fb_info->palette[regno].red << 8 | l_fb_info-> | ||
3084 | palette[regno].red; | ||
3085 | *green = | ||
3086 | l_fb_info->palette[regno].green << 8 | l_fb_info-> | ||
3087 | palette[regno].green; | ||
3088 | *blue = | ||
3089 | l_fb_info->palette[regno].blue << 8 | l_fb_info-> | ||
3090 | palette[regno].blue; | ||
3091 | *transp = | ||
3092 | l_fb_info->palette[regno].transp << 8 | l_fb_info-> | ||
3093 | palette[regno].transp; | ||
3094 | } | ||
3095 | return (regno > 255); | ||
3096 | } | 561 | } |
3097 | 562 | ||
3098 | static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green, | 563 | static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green, |
3099 | unsigned blue, unsigned transp, | 564 | unsigned blue, unsigned transp, |
3100 | struct fb_info *info) | 565 | struct fb_info *info) |
3101 | { | 566 | { |
3102 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | 567 | struct pm3_par *par = info->par; |
3103 | 568 | ||
3104 | DTRACE; | 569 | if (regno >= 256) /* no. of hw registers */ |
570 | return -EINVAL; | ||
571 | |||
572 | /* grayscale works only partially under directcolor */ | ||
573 | if (info->var.grayscale) { | ||
574 | /* grayscale = 0.30*R + 0.59*G + 0.11*B */ | ||
575 | red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; | ||
576 | } | ||
577 | |||
578 | /* Directcolor: | ||
579 | * var->{color}.offset contains start of bitfield | ||
580 | * var->{color}.length contains length of bitfield | ||
581 | * {hardwarespecific} contains width of DAC | ||
582 | * pseudo_palette[X] is programmed to (X << red.offset) | | ||
583 | * (X << green.offset) | | ||
584 | * (X << blue.offset) | ||
585 | * RAMDAC[X] is programmed to (red, green, blue) | ||
586 | * color depth = SUM(var->{color}.length) | ||
587 | * | ||
588 | * Pseudocolor: | ||
589 | * var->{color}.offset is 0 | ||
590 | * var->{color}.length contains width of DAC or the number of unique | ||
591 | * colors available (color depth) | ||
592 | * pseudo_palette is not used | ||
593 | * RAMDAC[X] is programmed to (red, green, blue) | ||
594 | * color depth = var->{color}.length | ||
595 | */ | ||
3105 | 596 | ||
3106 | if (regno < 16) { | 597 | /* |
3107 | switch (l_fb_info->current_par->depth) { | 598 | * This is the point where the color is converted to something that |
3108 | #ifdef FBCON_HAS_CFB8 | 599 | * is acceptable by the hardware. |
600 | */ | ||
601 | #define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16) | ||
602 | red = CNVT_TOHW(red, info->var.red.length); | ||
603 | green = CNVT_TOHW(green, info->var.green.length); | ||
604 | blue = CNVT_TOHW(blue, info->var.blue.length); | ||
605 | transp = CNVT_TOHW(transp, info->var.transp.length); | ||
606 | #undef CNVT_TOHW | ||
607 | |||
608 | if (info->fix.visual == FB_VISUAL_TRUECOLOR || | ||
609 | info->fix.visual == FB_VISUAL_DIRECTCOLOR) { | ||
610 | u32 v; | ||
611 | |||
612 | if (regno >= 16) | ||
613 | return -EINVAL; | ||
614 | |||
615 | v = (red << info->var.red.offset) | | ||
616 | (green << info->var.green.offset) | | ||
617 | (blue << info->var.blue.offset) | | ||
618 | (transp << info->var.transp.offset); | ||
619 | |||
620 | switch (info->var.bits_per_pixel) { | ||
3109 | case 8: | 621 | case 8: |
3110 | break; | 622 | break; |
3111 | #endif | ||
3112 | #ifdef FBCON_HAS_CFB16 | ||
3113 | case 12: | ||
3114 | l_fb_info->cmap.cmap12[regno] = | ||
3115 | (((u32) red & 0xf000) >> 4) | | ||
3116 | (((u32) green & 0xf000) >> 8) | | ||
3117 | (((u32) blue & 0xf000) >> 12); | ||
3118 | break; | ||
3119 | |||
3120 | case 15: | ||
3121 | l_fb_info->cmap.cmap15[regno] = | ||
3122 | (((u32) red & 0xf800) >> 1) | | ||
3123 | (((u32) green & 0xf800) >> 6) | | ||
3124 | (((u32) blue & 0xf800) >> 11); | ||
3125 | break; | ||
3126 | |||
3127 | case 16: | 623 | case 16: |
3128 | l_fb_info->cmap.cmap16[regno] = | 624 | case 24: |
3129 | ((u32) red & 0xf800) | | ||
3130 | (((u32) green & 0xfc00) >> 5) | | ||
3131 | (((u32) blue & 0xf800) >> 11); | ||
3132 | break; | ||
3133 | #endif | ||
3134 | #ifdef FBCON_HAS_CFB32 | ||
3135 | case 32: | 625 | case 32: |
3136 | l_fb_info->cmap.cmap32[regno] = | 626 | ((u32*)(info->pseudo_palette))[regno] = v; |
3137 | (((u32) transp & 0xff00) << 16) | | ||
3138 | (((u32) red & 0xff00) << 8) | | ||
3139 | (((u32) green & 0xff00)) | | ||
3140 | (((u32) blue & 0xff00) >> 8); | ||
3141 | break; | ||
3142 | #endif | ||
3143 | default: | ||
3144 | DPRINTK(1, "bad depth %u\n", | ||
3145 | l_fb_info->current_par->depth); | ||
3146 | break; | 627 | break; |
3147 | } | 628 | } |
629 | return 0; | ||
3148 | } | 630 | } |
3149 | if (regno < 256) { | 631 | else if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) |
3150 | l_fb_info->palette[regno].red = red >> 8; | 632 | pm3fb_set_color(par, regno, red, green, blue); |
3151 | l_fb_info->palette[regno].green = green >> 8; | 633 | |
3152 | l_fb_info->palette[regno].blue = blue >> 8; | 634 | return 0; |
3153 | l_fb_info->palette[regno].transp = transp >> 8; | ||
3154 | if (l_fb_info->current_par->depth == 8) | ||
3155 | pm3fb_set_color(l_fb_info, regno, red >> 8, | ||
3156 | green >> 8, blue >> 8); | ||
3157 | } | ||
3158 | return (regno > 255); | ||
3159 | } | 635 | } |
3160 | 636 | ||
3161 | static int pm3fb_blank(int blank_mode, struct fb_info_gen *info) | 637 | static int pm3fb_pan_display(struct fb_var_screeninfo *var, |
638 | struct fb_info *info) | ||
3162 | { | 639 | { |
3163 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | 640 | struct pm3_par *par = info->par; |
3164 | u32 video; | 641 | const u32 xres = (var->xres + 31) & ~31; |
3165 | |||
3166 | DTRACE; | ||
3167 | 642 | ||
3168 | if (!current_par_valid[l_fb_info->board_num]) | 643 | par->base = pm3fb_shift_bpp(var->bits_per_pixel, |
3169 | return (1); | 644 | (var->yoffset * xres) |
645 | + var->xoffset); | ||
646 | PM3_SLOW_WRITE_REG(par, PM3ScreenBase, par->base); | ||
647 | return 0; | ||
648 | } | ||
3170 | 649 | ||
3171 | video = l_fb_info->current_par->video; | 650 | static int pm3fb_blank(int blank_mode, struct fb_info *info) |
651 | { | ||
652 | struct pm3_par *par = info->par; | ||
653 | u32 video = par->video; | ||
3172 | 654 | ||
3173 | /* | 655 | /* |
3174 | * Oxygen VX1 - it appears that setting PM3VideoControl and | 656 | * Oxygen VX1 - it appears that setting PM3VideoControl and |
@@ -3181,454 +663,345 @@ static int pm3fb_blank(int blank_mode, struct fb_info_gen *info) | |||
3181 | video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | | 663 | video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | |
3182 | PM3VideoControl_VSYNC_ACTIVE_HIGH; | 664 | PM3VideoControl_VSYNC_ACTIVE_HIGH; |
3183 | 665 | ||
3184 | if (blank_mode > 0) { | 666 | switch (blank_mode) { |
3185 | switch (blank_mode - 1) { | 667 | case FB_BLANK_UNBLANK: |
3186 | 668 | video = video | PM3VideoControl_ENABLE; | |
3187 | case VESA_NO_BLANKING: /* FIXME */ | ||
3188 | video = video & ~(PM3VideoControl_ENABLE); | ||
3189 | break; | ||
3190 | |||
3191 | case VESA_HSYNC_SUSPEND: | ||
3192 | video = video & ~(PM3VideoControl_HSYNC_MASK | | ||
3193 | PM3VideoControl_BLANK_ACTIVE_LOW); | ||
3194 | break; | ||
3195 | case VESA_VSYNC_SUSPEND: | ||
3196 | video = video & ~(PM3VideoControl_VSYNC_MASK | | ||
3197 | PM3VideoControl_BLANK_ACTIVE_LOW); | ||
3198 | break; | ||
3199 | case VESA_POWERDOWN: | ||
3200 | video = video & ~(PM3VideoControl_HSYNC_MASK | | ||
3201 | PM3VideoControl_VSYNC_MASK | | ||
3202 | PM3VideoControl_BLANK_ACTIVE_LOW); | ||
3203 | break; | ||
3204 | default: | ||
3205 | DPRINTK(1, "Unsupported blanking %d\n", | ||
3206 | blank_mode); | ||
3207 | return (1); | ||
3208 | break; | ||
3209 | } | ||
3210 | } | ||
3211 | |||
3212 | PM3_SLOW_WRITE_REG(PM3VideoControl, video); | ||
3213 | |||
3214 | return (0); | ||
3215 | } | ||
3216 | |||
3217 | static void pm3fb_set_disp(const void *par, struct display *disp, | ||
3218 | struct fb_info_gen *info) | ||
3219 | { | ||
3220 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3221 | struct pm3fb_par *p = (struct pm3fb_par *) par; | ||
3222 | u32 flags; | ||
3223 | |||
3224 | DTRACE; | ||
3225 | |||
3226 | local_irq_save(flags); | ||
3227 | info->info.screen_base = l_fb_info->v_fb; | ||
3228 | switch (p->depth) { | ||
3229 | #ifdef FBCON_HAS_CFB8 | ||
3230 | case 8: | ||
3231 | #ifdef PM3FB_USE_ACCEL | ||
3232 | if (!(noaccel[l_fb_info->board_num])) | ||
3233 | disp->dispsw = &pm3fb_cfb8; | ||
3234 | else | ||
3235 | #endif /* PM3FB_USE_ACCEL */ | ||
3236 | disp->dispsw = &fbcon_cfb8; | ||
3237 | break; | 669 | break; |
3238 | #endif | 670 | case FB_BLANK_NORMAL: /* FIXME */ |
3239 | #ifdef FBCON_HAS_CFB16 | 671 | video = video & ~(PM3VideoControl_ENABLE); |
3240 | case 12: | ||
3241 | #ifdef PM3FB_USE_ACCEL | ||
3242 | if (!(noaccel[l_fb_info->board_num])) | ||
3243 | disp->dispsw = &pm3fb_cfb16; | ||
3244 | else | ||
3245 | #endif /* PM3FB_USE_ACCEL */ | ||
3246 | disp->dispsw = &fbcon_cfb16; | ||
3247 | disp->dispsw_data = l_fb_info->cmap.cmap12; | ||
3248 | break; | 672 | break; |
3249 | case 15: | 673 | case FB_BLANK_HSYNC_SUSPEND: |
3250 | #ifdef PM3FB_USE_ACCEL | 674 | video = video & ~(PM3VideoControl_HSYNC_MASK | |
3251 | if (!(noaccel[l_fb_info->board_num])) | 675 | PM3VideoControl_BLANK_ACTIVE_LOW); |
3252 | disp->dispsw = &pm3fb_cfb16; | ||
3253 | else | ||
3254 | #endif /* PM3FB_USE_ACCEL */ | ||
3255 | disp->dispsw = &fbcon_cfb16; | ||
3256 | disp->dispsw_data = l_fb_info->cmap.cmap15; | ||
3257 | break; | 676 | break; |
3258 | case 16: | 677 | case FB_BLANK_VSYNC_SUSPEND: |
3259 | #ifdef PM3FB_USE_ACCEL | 678 | video = video & ~(PM3VideoControl_VSYNC_MASK | |
3260 | if (!(noaccel[l_fb_info->board_num])) | 679 | PM3VideoControl_BLANK_ACTIVE_LOW); |
3261 | disp->dispsw = &pm3fb_cfb16; | ||
3262 | else | ||
3263 | #endif /* PM3FB_USE_ACCEL */ | ||
3264 | disp->dispsw = &fbcon_cfb16; | ||
3265 | disp->dispsw_data = l_fb_info->cmap.cmap16; | ||
3266 | break; | 680 | break; |
3267 | #endif | 681 | case FB_BLANK_POWERDOWN: |
3268 | #ifdef FBCON_HAS_CFB32 | 682 | video = video & ~(PM3VideoControl_HSYNC_MASK | |
3269 | case 32: | 683 | PM3VideoControl_VSYNC_MASK | |
3270 | #ifdef PM3FB_USE_ACCEL | 684 | PM3VideoControl_BLANK_ACTIVE_LOW); |
3271 | if (!(noaccel[l_fb_info->board_num])) | ||
3272 | disp->dispsw = &pm3fb_cfb32; | ||
3273 | else | ||
3274 | #endif /* PM3FB_USE_ACCEL */ | ||
3275 | disp->dispsw = &fbcon_cfb32; | ||
3276 | disp->dispsw_data = l_fb_info->cmap.cmap32; | ||
3277 | break; | 685 | break; |
3278 | #endif /* FBCON_HAS_CFB32 */ | ||
3279 | default: | 686 | default: |
3280 | disp->dispsw = &fbcon_dummy; | 687 | DPRINTK("Unsupported blanking %d\n", blank_mode); |
3281 | DPRINTK(1, "Invalid depth, using fbcon_dummy\n"); | 688 | return 1; |
3282 | break; | ||
3283 | } | 689 | } |
3284 | local_irq_restore(flags); | 690 | |
691 | PM3_SLOW_WRITE_REG(par,PM3VideoControl, video); | ||
692 | |||
693 | return 0; | ||
3285 | } | 694 | } |
3286 | 695 | ||
3287 | /* */ | 696 | /* |
3288 | static void pm3fb_detect(void) | 697 | * Frame buffer operations |
3289 | { | 698 | */ |
3290 | struct pci_dev *dev_array[PM3_MAX_BOARD]; | ||
3291 | struct pci_dev *dev = NULL; | ||
3292 | struct pm3fb_info *l_fb_info = &(fb_info[0]); | ||
3293 | unsigned long i, j, done; | ||
3294 | 699 | ||
3295 | DTRACE; | 700 | static struct fb_ops pm3fb_ops = { |
701 | .owner = THIS_MODULE, | ||
702 | .fb_check_var = pm3fb_check_var, | ||
703 | .fb_set_par = pm3fb_set_par, | ||
704 | .fb_setcolreg = pm3fb_setcolreg, | ||
705 | .fb_pan_display = pm3fb_pan_display, | ||
706 | .fb_fillrect = cfb_fillrect, /* Needed !!! */ | ||
707 | .fb_copyarea = cfb_copyarea, /* Needed !!! */ | ||
708 | .fb_imageblit = cfb_imageblit, /* Needed !!! */ | ||
709 | .fb_blank = pm3fb_blank, | ||
710 | }; | ||
3296 | 711 | ||
3297 | for (i = 0; i < PM3_MAX_BOARD; i++) { | 712 | /* ------------------------------------------------------------------------- */ |
3298 | dev_array[i] = NULL; | ||
3299 | fb_info[i].dev = NULL; | ||
3300 | } | ||
3301 | 713 | ||
3302 | dev = pci_get_device(PCI_VENDOR_ID_3DLABS, | 714 | /* |
3303 | PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); | 715 | * Initialization |
716 | */ | ||
3304 | 717 | ||
3305 | for (i = 0; ((i < PM3_MAX_BOARD) && dev); i++) { | 718 | /* mmio register are already mapped when this function is called */ |
3306 | dev_array[i] = dev; | 719 | /* the pm3fb_fix.smem_start is also set */ |
3307 | dev = pci_get_device(PCI_VENDOR_ID_3DLABS, | 720 | static unsigned long pm3fb_size_memory(struct pm3_par *par) |
3308 | PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); | 721 | { |
3309 | } | 722 | unsigned long memsize = 0, tempBypass, i, temp1, temp2; |
723 | unsigned char __iomem *screen_mem; | ||
3310 | 724 | ||
3311 | if (dev) { /* more than PM3_MAX_BOARD */ | 725 | pm3fb_fix.smem_len = 64 * 1024 * 1024; /* request full aperture size */ |
3312 | printk(KERN_WARNING "pm3fb: Warning: more than %d boards found\n", | 726 | /* Linear frame buffer - request region and map it. */ |
3313 | PM3_MAX_BOARD); | 727 | if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len, |
728 | "pm3fb smem")) { | ||
729 | printk(KERN_WARNING "pm3fb: Can't reserve smem.\n"); | ||
730 | return 0; | ||
3314 | } | 731 | } |
3315 | 732 | screen_mem = | |
3316 | if (!dev_array[0]) { /* not a single board, abort */ | 733 | ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len); |
3317 | return; | 734 | if (!screen_mem) { |
735 | printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n"); | ||
736 | release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
737 | return 0; | ||
3318 | } | 738 | } |
3319 | 739 | ||
3320 | /* allocate user-defined boards */ | 740 | /* TODO: card-specific stuff, *before* accessing *any* FB memory */ |
3321 | for (i = 0; i < PM3_MAX_BOARD; i++) { | 741 | /* For Appian Jeronimo 2000 board second head */ |
3322 | if ((bus[i] >= 0) && (slot[i] >= 0) && (func[i] >= 0)) { | 742 | |
3323 | for (j = 0; j < PM3_MAX_BOARD; j++) { | 743 | tempBypass = PM3_READ_REG(par, PM3MemBypassWriteMask); |
3324 | if ((dev_array[j] != NULL) && | 744 | |
3325 | (dev_array[j]->bus->number == bus[i]) | 745 | DPRINTK("PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass); |
3326 | && (PCI_SLOT(dev_array[j]->devfn) == | 746 | |
3327 | slot[i]) | 747 | PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, 0xFFFFFFFF); |
3328 | && (PCI_FUNC(dev_array[j]->devfn) == | 748 | |
3329 | func[i])) { | 749 | /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */ |
3330 | fb_info[i].dev = dev_array[j]; | 750 | for (i = 0; i < 32; i++) { |
3331 | dev_array[j] = NULL; | 751 | fb_writel(i * 0x00345678, |
3332 | } | 752 | (screen_mem + (i * 1048576))); |
3333 | } | 753 | mb(); |
3334 | } | 754 | temp1 = fb_readl((screen_mem + (i * 1048576))); |
755 | |||
756 | /* Let's check for wrapover, write will fail at 16MB boundary */ | ||
757 | if (temp1 == (i * 0x00345678)) | ||
758 | memsize = i; | ||
759 | else | ||
760 | break; | ||
3335 | } | 761 | } |
3336 | /* allocate remaining boards */ | 762 | |
3337 | for (i = 0; i < PM3_MAX_BOARD; i++) { | 763 | DPRINTK("First detect pass already got %ld MB\n", memsize + 1); |
3338 | if (fb_info[i].dev == NULL) { | 764 | |
3339 | done = 0; | 765 | if (memsize + 1 == i) { |
3340 | for (j = 0; ((j < PM3_MAX_BOARD) && (!done)); j++) { | 766 | for (i = 0; i < 32; i++) { |
3341 | if (dev_array[j] != NULL) { | 767 | /* Clear first 32MB ; 0 is 0, no need to byteswap */ |
3342 | fb_info[i].dev = dev_array[j]; | 768 | writel(0x0000000, |
3343 | dev_array[j] = NULL; | 769 | (screen_mem + (i * 1048576))); |
3344 | done = 1; | 770 | mb(); |
3345 | } | ||
3346 | } | ||
3347 | } | 771 | } |
3348 | } | ||
3349 | 772 | ||
3350 | /* at that point, all PCI Permedia3 are detected and allocated */ | 773 | for (i = 32; i < 64; i++) { |
3351 | /* now, initialize... or not */ | 774 | fb_writel(i * 0x00345678, |
3352 | for (i = 0; i < PM3_MAX_BOARD; i++) { | 775 | (screen_mem + (i * 1048576))); |
3353 | l_fb_info = &(fb_info[i]); | 776 | mb(); |
3354 | if (l_fb_info->dev && !disable[i]) { /* PCI device was found and not disabled by user */ | 777 | temp1 = |
3355 | DPRINTK(2, | 778 | fb_readl((screen_mem + (i * 1048576))); |
3356 | "found @%lx Vendor %lx Device %lx ; base @ : %lx - %lx - %lx - %lx - %lx - %lx, irq %ld\n", | 779 | temp2 = |
3357 | (unsigned long) l_fb_info->dev, | 780 | fb_readl((screen_mem + ((i - 32) * 1048576))); |
3358 | (unsigned long) l_fb_info->dev->vendor, | 781 | /* different value, different RAM... */ |
3359 | (unsigned long) l_fb_info->dev->device, | 782 | if ((temp1 == (i * 0x00345678)) && (temp2 == 0)) |
3360 | (unsigned long) | 783 | memsize = i; |
3361 | pci_resource_start(l_fb_info->dev, 0), | 784 | else |
3362 | (unsigned long) | 785 | break; |
3363 | pci_resource_start(l_fb_info->dev, 1), | ||
3364 | (unsigned long) | ||
3365 | pci_resource_start(l_fb_info->dev, 2), | ||
3366 | (unsigned long) | ||
3367 | pci_resource_start(l_fb_info->dev, 3), | ||
3368 | (unsigned long) | ||
3369 | pci_resource_start(l_fb_info->dev, 4), | ||
3370 | (unsigned long) | ||
3371 | pci_resource_start(l_fb_info->dev, 5), | ||
3372 | (unsigned long) l_fb_info->dev->irq); | ||
3373 | |||
3374 | l_fb_info->pIOBase = | ||
3375 | (unsigned char *) | ||
3376 | pci_resource_start(l_fb_info->dev, 0); | ||
3377 | #ifdef __BIG_ENDIAN | ||
3378 | l_fb_info->pIOBase += PM3_REGS_SIZE; | ||
3379 | #endif | ||
3380 | l_fb_info->vIOBase = (unsigned char *) -1; | ||
3381 | l_fb_info->p_fb = | ||
3382 | (unsigned char *) | ||
3383 | pci_resource_start(l_fb_info->dev, 1); | ||
3384 | l_fb_info->v_fb = (unsigned char *) -1; | ||
3385 | |||
3386 | if (!request_mem_region | ||
3387 | ((unsigned long)l_fb_info->p_fb, 64 * 1024 * 1024, /* request full aperture size */ | ||
3388 | "pm3fb")) { | ||
3389 | printk | ||
3390 | (KERN_ERR "pm3fb: Error: couldn't request framebuffer memory, board #%ld\n", | ||
3391 | l_fb_info->board_num); | ||
3392 | continue; | ||
3393 | } | ||
3394 | if (!request_mem_region | ||
3395 | ((unsigned long)l_fb_info->pIOBase, PM3_REGS_SIZE, | ||
3396 | "pm3fb I/O regs")) { | ||
3397 | printk | ||
3398 | (KERN_ERR "pm3fb: Error: couldn't request IObase memory, board #%ld\n", | ||
3399 | l_fb_info->board_num); | ||
3400 | continue; | ||
3401 | } | ||
3402 | if (forcesize[l_fb_info->board_num]) | ||
3403 | l_fb_info->fb_size = forcesize[l_fb_info->board_num]; | ||
3404 | |||
3405 | l_fb_info->fb_size = | ||
3406 | pm3fb_size_memory(l_fb_info); | ||
3407 | if (l_fb_info->fb_size) { | ||
3408 | (void) pci_enable_device(l_fb_info->dev); | ||
3409 | pm3fb_common_init(l_fb_info); | ||
3410 | } else | ||
3411 | printk(KERN_ERR "pm3fb: memory problem, not enabling board #%ld\n", l_fb_info->board_num); | ||
3412 | } | 786 | } |
3413 | } | 787 | } |
3414 | } | 788 | DPRINTK("Second detect pass got %ld MB\n", memsize + 1); |
3415 | 789 | ||
3416 | static int pm3fb_pan_display(const struct fb_var_screeninfo *var, | 790 | PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, tempBypass); |
3417 | struct fb_info_gen *info) | ||
3418 | { | ||
3419 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | ||
3420 | 791 | ||
3421 | DTRACE; | 792 | iounmap(screen_mem); |
793 | release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
794 | memsize = 1048576 * (memsize + 1); | ||
3422 | 795 | ||
3423 | if (!current_par_valid[l_fb_info->board_num]) | 796 | DPRINTK("Returning 0x%08lx bytes\n", memsize); |
3424 | return -EINVAL; | ||
3425 | 797 | ||
3426 | l_fb_info->current_par->base = /* in 128 bits chunk - i.e. AFTER Shiftbpp */ | 798 | return memsize; |
3427 | pm3fb_Shiftbpp(l_fb_info, | ||
3428 | l_fb_info->current_par->depth, | ||
3429 | (var->yoffset * l_fb_info->current_par->width) + | ||
3430 | var->xoffset); | ||
3431 | PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base); | ||
3432 | return 0; | ||
3433 | } | 799 | } |
3434 | 800 | ||
3435 | static int pm3fb_ioctl(struct fb_info *info, u_int cmd, u_long arg) | 801 | static int __devinit pm3fb_probe(struct pci_dev *dev, |
802 | const struct pci_device_id *ent) | ||
3436 | { | 803 | { |
3437 | struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; | 804 | struct fb_info *info; |
3438 | u32 cm, i; | 805 | struct pm3_par *par; |
3439 | #ifdef PM3FB_MASTER_DEBUG | 806 | struct device* device = &dev->dev; /* for pci drivers */ |
3440 | char cc[3]; | 807 | int err, retval = -ENXIO; |
3441 | #endif /* PM3FB_MASTER_DEBUG */ | ||
3442 | 808 | ||
3443 | switch(cmd) | 809 | err = pci_enable_device(dev); |
3444 | { | 810 | if (err) { |
3445 | #ifdef PM3FB_MASTER_DEBUG | 811 | printk(KERN_WARNING "pm3fb: Can't enable PCI dev: %d\n", err); |
3446 | case PM3FBIO_CLEARMEMORY: | 812 | return err; |
3447 | if (copy_from_user(&cm, (void *)arg, sizeof(u32))) | 813 | } |
3448 | return(-EFAULT); | 814 | /* |
3449 | pm3fb_clear_memory(l_fb_info, cm); | 815 | * Dynamically allocate info and par |
3450 | return(0); | 816 | */ |
3451 | break; | 817 | info = framebuffer_alloc(sizeof(struct pm3_par), device); |
3452 | 818 | ||
3453 | case PM3FBIO_CLEARCMAP: | 819 | if (!info) |
3454 | if (copy_from_user(cc, (void*)arg, 3 * sizeof(char))) | 820 | return -ENOMEM; |
3455 | return(-EFAULT); | 821 | par = info->par; |
3456 | pm3fb_clear_colormap(l_fb_info, cc[0], cc[1], cc[2]); | ||
3457 | return(0); | ||
3458 | break; | ||
3459 | #endif /* PM3FB_MASTER_DEBUG */ | ||
3460 | |||
3461 | case PM3FBIO_RESETCHIP: | ||
3462 | cm = 1; | ||
3463 | PM3_SLOW_WRITE_REG(PM3ResetStatus, 1); | ||
3464 | for (i = 0 ; (i < 10000) && cm ; i++) | ||
3465 | { | ||
3466 | PM3_DELAY(10); | ||
3467 | cm = PM3_READ_REG(PM3ResetStatus); | ||
3468 | } | ||
3469 | if (cm) | ||
3470 | { | ||
3471 | printk(KERN_ERR "pm3fb: chip reset failed with status 0x%x\n", cm); | ||
3472 | return(-EIO); | ||
3473 | } | ||
3474 | /* first thing first, reload memory timings */ | ||
3475 | pm3fb_write_memory_timings(l_fb_info); | ||
3476 | #ifdef PM3FB_USE_ACCEL | ||
3477 | pm3fb_init_engine(l_fb_info); | ||
3478 | #endif /* PM3FB_USE_ACCEL */ | ||
3479 | pm3fb_write_mode(l_fb_info); | ||
3480 | return(0); | ||
3481 | break; | ||
3482 | 822 | ||
3483 | default: | 823 | /* |
3484 | DPRINTK(2, "unknown ioctl: %d (%x)\n", cmd, cmd); | 824 | * Here we set the screen_base to the virtual memory address |
3485 | return(-EINVAL); | 825 | * for the framebuffer. |
826 | */ | ||
827 | pm3fb_fix.mmio_start = pci_resource_start(dev, 0); | ||
828 | pm3fb_fix.mmio_len = PM3_REGS_SIZE; | ||
829 | |||
830 | /* Registers - request region and map it. */ | ||
831 | if (!request_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len, | ||
832 | "pm3fb regbase")) { | ||
833 | printk(KERN_WARNING "pm3fb: Can't reserve regbase.\n"); | ||
834 | goto err_exit_neither; | ||
835 | } | ||
836 | par->v_regs = | ||
837 | ioremap_nocache(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len); | ||
838 | if (!par->v_regs) { | ||
839 | printk(KERN_WARNING "pm3fb: Can't remap %s register area.\n", | ||
840 | pm3fb_fix.id); | ||
841 | release_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len); | ||
842 | goto err_exit_neither; | ||
843 | } | ||
844 | |||
845 | #if defined(__BIG_ENDIAN) | ||
846 | pm3fb_fix.mmio_start += PM3_REGS_SIZE; | ||
847 | DPRINTK("Adjusting register base for big-endian.\n"); | ||
848 | #endif | ||
849 | /* Linear frame buffer - request region and map it. */ | ||
850 | pm3fb_fix.smem_start = pci_resource_start(dev, 1); | ||
851 | pm3fb_fix.smem_len = pm3fb_size_memory(par); | ||
852 | if (!pm3fb_fix.smem_len) | ||
853 | { | ||
854 | printk(KERN_WARNING "pm3fb: Can't find memory on board.\n"); | ||
855 | goto err_exit_mmio; | ||
3486 | } | 856 | } |
3487 | } | 857 | if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len, |
858 | "pm3fb smem")) { | ||
859 | printk(KERN_WARNING "pm3fb: Can't reserve smem.\n"); | ||
860 | goto err_exit_mmio; | ||
861 | } | ||
862 | info->screen_base = | ||
863 | ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
864 | if (!info->screen_base) { | ||
865 | printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n"); | ||
866 | release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
867 | goto err_exit_mmio; | ||
868 | } | ||
869 | info->screen_size = pm3fb_fix.smem_len; | ||
3488 | 870 | ||
3489 | /* ****************************************** */ | 871 | info->fbops = &pm3fb_ops; |
3490 | /* ***** standard FB API init functions ***** */ | ||
3491 | /* ****************************************** */ | ||
3492 | 872 | ||
3493 | int __init pm3fb_setup(char *options) | 873 | par->video = PM3_READ_REG(par, PM3VideoControl); |
3494 | { | ||
3495 | long opsi = strlen(options); | ||
3496 | 874 | ||
3497 | DTRACE; | 875 | info->fix = pm3fb_fix; |
876 | info->pseudo_palette = par->palette; | ||
877 | info->flags = FBINFO_DEFAULT;/* | FBINFO_HWACCEL_YPAN;*/ | ||
3498 | 878 | ||
3499 | memcpy(g_options, options, | 879 | /* |
3500 | ((opsi + 1) > | 880 | * This should give a reasonable default video mode. The following is |
3501 | PM3_OPTIONS_SIZE) ? PM3_OPTIONS_SIZE : (opsi + 1)); | 881 | * done when we can set a video mode. |
3502 | g_options[PM3_OPTIONS_SIZE - 1] = 0; | 882 | */ |
883 | if (!mode_option) | ||
884 | mode_option = "640x480@60"; | ||
885 | |||
886 | retval = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8); | ||
887 | |||
888 | if (!retval || retval == 4) { | ||
889 | retval = -EINVAL; | ||
890 | goto err_exit_both; | ||
891 | } | ||
892 | |||
893 | /* This has to been done !!! */ | ||
894 | if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { | ||
895 | retval = -ENOMEM; | ||
896 | goto err_exit_both; | ||
897 | } | ||
3503 | 898 | ||
3504 | return (0); | 899 | /* |
900 | * For drivers that can... | ||
901 | */ | ||
902 | pm3fb_check_var(&info->var, info); | ||
903 | |||
904 | if (register_framebuffer(info) < 0) { | ||
905 | retval = -EINVAL; | ||
906 | goto err_exit_all; | ||
907 | } | ||
908 | printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, | ||
909 | info->fix.id); | ||
910 | pci_set_drvdata(dev, info); /* or dev_set_drvdata(device, info) */ | ||
911 | return 0; | ||
912 | |||
913 | err_exit_all: | ||
914 | fb_dealloc_cmap(&info->cmap); | ||
915 | err_exit_both: | ||
916 | iounmap(info->screen_base); | ||
917 | release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); | ||
918 | err_exit_mmio: | ||
919 | iounmap(par->v_regs); | ||
920 | release_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len); | ||
921 | err_exit_neither: | ||
922 | framebuffer_release(info); | ||
923 | return retval; | ||
3505 | } | 924 | } |
3506 | 925 | ||
3507 | int __init pm3fb_init(void) | 926 | /* |
927 | * Cleanup | ||
928 | */ | ||
929 | static void __devexit pm3fb_remove(struct pci_dev *dev) | ||
3508 | { | 930 | { |
3509 | DTRACE; | 931 | struct fb_info *info = pci_get_drvdata(dev); |
3510 | 932 | ||
3511 | DPRINTK(2, "This is pm3fb.c, CVS version: $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $"); | 933 | if (info) { |
934 | struct fb_fix_screeninfo *fix = &info->fix; | ||
935 | struct pm3_par *par = info->par; | ||
3512 | 936 | ||
3513 | pm3fb_real_setup(g_options); | 937 | unregister_framebuffer(info); |
938 | fb_dealloc_cmap(&info->cmap); | ||
3514 | 939 | ||
3515 | pm3fb_detect(); | 940 | iounmap(info->screen_base); |
941 | release_mem_region(fix->smem_start, fix->smem_len); | ||
942 | iounmap(par->v_regs); | ||
943 | release_mem_region(fix->mmio_start, fix->mmio_len); | ||
3516 | 944 | ||
3517 | if (!fb_info[0].dev) { /* not even one board ??? */ | 945 | pci_set_drvdata(dev, NULL); |
3518 | DPRINTK(1, "No PCI Permedia3 board detected\n"); | 946 | framebuffer_release(info); |
3519 | } | 947 | } |
3520 | return (0); | ||
3521 | } | 948 | } |
3522 | 949 | ||
3523 | /* ************************* */ | 950 | static struct pci_device_id pm3fb_id_table[] = { |
3524 | /* **** Module support ***** */ | 951 | { PCI_VENDOR_ID_3DLABS, 0x0a, |
3525 | /* ************************* */ | 952 | PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16, |
3526 | 953 | 0xff0000, 0 }, | |
3527 | #ifdef MODULE | 954 | { 0, } |
3528 | MODULE_AUTHOR("Romain Dolbeau"); | 955 | }; |
3529 | MODULE_DESCRIPTION("Permedia3 framebuffer device driver"); | ||
3530 | static char *mode[PM3_MAX_BOARD]; | ||
3531 | module_param_array(mode, charp, NULL, 0); | ||
3532 | MODULE_PARM_DESC(mode,"video mode"); | ||
3533 | module_param_array(disable, short, NULL, 0); | ||
3534 | MODULE_PARM_DESC(disable,"disable board"); | ||
3535 | static short off[PM3_MAX_BOARD]; | ||
3536 | module_param_array(off, short, NULL, 0); | ||
3537 | MODULE_PARM_DESC(off,"disable board"); | ||
3538 | static char *pciid[PM3_MAX_BOARD]; | ||
3539 | module_param_array(pciid, charp, NULL, 0); | ||
3540 | MODULE_PARM_DESC(pciid,"board PCI Id"); | ||
3541 | module_param_array(noaccel, short, NULL, 0); | ||
3542 | MODULE_PARM_DESC(noaccel,"disable accel"); | ||
3543 | static char *font[PM3_MAX_BOARD]; | ||
3544 | module_param_array(font, charp, NULL, 0); | ||
3545 | MODULE_PARM_DESC(font,"choose font"); | ||
3546 | module_param(depth, short, NULL, 0); | ||
3547 | MODULE_PARM_DESC(depth,"boot-time depth"); | ||
3548 | module_param(printtimings, short, NULL, 0); | ||
3549 | MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)"); | ||
3550 | module_param(forcesize, short, NULL, 0); | ||
3551 | MODULE_PARM_DESC(forcesize, "force specified memory size"); | ||
3552 | /* | ||
3553 | MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards") | ||
3554 | MODULE_GENERIC_TABLE(gtype,name) | ||
3555 | MODULE_DEVICE_TABLE(type,name) | ||
3556 | */ | ||
3557 | 956 | ||
3558 | void pm3fb_build_options(void) | 957 | /* For PCI drivers */ |
3559 | { | 958 | static struct pci_driver pm3fb_driver = { |
3560 | int i; | 959 | .name = "pm3fb", |
3561 | char ts[128]; | 960 | .id_table = pm3fb_id_table, |
961 | .probe = pm3fb_probe, | ||
962 | .remove = __devexit_p(pm3fb_remove), | ||
963 | }; | ||
3562 | 964 | ||
3563 | strcpy(g_options, "pm3fb"); | 965 | MODULE_DEVICE_TABLE(pci, pm3fb_id_table); |
3564 | for (i = 0; i < PM3_MAX_BOARD ; i++) | ||
3565 | { | ||
3566 | if (mode[i]) | ||
3567 | { | ||
3568 | sprintf(ts, ",mode:%d:%s", i, mode[i]); | ||
3569 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3570 | } | ||
3571 | if (disable[i] || off[i]) | ||
3572 | { | ||
3573 | sprintf(ts, ",disable:%d:", i); | ||
3574 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3575 | } | ||
3576 | if (pciid[i]) | ||
3577 | { | ||
3578 | sprintf(ts, ",pciid:%d:%s", i, pciid[i]); | ||
3579 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3580 | } | ||
3581 | if (noaccel[i]) | ||
3582 | { | ||
3583 | sprintf(ts, ",noaccel:%d:", i); | ||
3584 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3585 | } | ||
3586 | if (font[i]) | ||
3587 | { | ||
3588 | sprintf(ts, ",font:%d:%s", i, font[i]); | ||
3589 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3590 | } | ||
3591 | if (depth[i]) | ||
3592 | { | ||
3593 | sprintf(ts, ",depth:%d:%d", i, depth[i]); | ||
3594 | strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options)); | ||
3595 | } | ||
3596 | } | ||
3597 | g_options[PM3_OPTIONS_SIZE - 1] = '\0'; | ||
3598 | DPRINTK(1, "pm3fb use options: %s\n", g_options); | ||
3599 | } | ||
3600 | 966 | ||
3601 | int init_module(void) | 967 | int __init pm3fb_init(void) |
3602 | { | 968 | { |
3603 | DTRACE; | 969 | /* |
970 | * For kernel boot options (in 'video=pm3fb:<options>' format) | ||
971 | */ | ||
972 | #ifndef MODULE | ||
973 | char *option = NULL; | ||
3604 | 974 | ||
3605 | pm3fb_build_options(); | 975 | if (fb_get_options("pm3fb", &option)) |
976 | return -ENODEV; | ||
977 | pm3fb_setup(option); | ||
978 | #endif | ||
3606 | 979 | ||
3607 | pm3fb_init(); | 980 | return pci_register_driver(&pm3fb_driver); |
981 | } | ||
3608 | 982 | ||
3609 | return 0; | 983 | static void __exit pm3fb_exit(void) |
984 | { | ||
985 | pci_unregister_driver(&pm3fb_driver); | ||
3610 | } | 986 | } |
3611 | 987 | ||
3612 | void cleanup_module(void) | 988 | #ifndef MODULE |
989 | /* | ||
990 | * Setup | ||
991 | */ | ||
992 | |||
993 | /* | ||
994 | * Only necessary if your driver takes special options, | ||
995 | * otherwise we fall back on the generic fb_setup(). | ||
996 | */ | ||
997 | int __init pm3fb_setup(char *options) | ||
3613 | { | 998 | { |
3614 | DTRACE; | 999 | /* Parse user speficied options (`video=pm3fb:') */ |
3615 | { | 1000 | return 0; |
3616 | unsigned long i; | ||
3617 | struct pm3fb_info *l_fb_info; | ||
3618 | for (i = 0; i < PM3_MAX_BOARD; i++) { | ||
3619 | l_fb_info = &(fb_info[i]); | ||
3620 | pci_dev_put(l_fb_info->dev); | ||
3621 | if (l_fb_info->dev != NULL && !(disable[l_fb_info->board_num])) { | ||
3622 | if (l_fb_info->vIOBase != (unsigned char *) -1) { | ||
3623 | pm3fb_unmapIO(l_fb_info); | ||
3624 | release_mem_region(l_fb_info->p_fb, | ||
3625 | l_fb_info->fb_size); | ||
3626 | release_mem_region(l_fb_info->pIOBase, | ||
3627 | PM3_REGS_SIZE); | ||
3628 | } | ||
3629 | unregister_framebuffer(&l_fb_info->gen.info); | ||
3630 | } | ||
3631 | } | ||
3632 | } | ||
3633 | } | 1001 | } |
3634 | #endif /* MODULE */ | 1002 | #endif /* MODULE */ |
1003 | |||
1004 | module_init(pm3fb_init); | ||
1005 | module_exit(pm3fb_exit); | ||
1006 | |||
1007 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c index 76e6ce353c8e..a0e22ac483a3 100644 --- a/drivers/video/riva/rivafb-i2c.c +++ b/drivers/video/riva/rivafb-i2c.c | |||
@@ -70,8 +70,6 @@ static int riva_gpio_getscl(void* data) | |||
70 | if (VGA_RD08(par->riva.PCIO, 0x3d5) & 0x04) | 70 | if (VGA_RD08(par->riva.PCIO, 0x3d5) & 0x04) |
71 | val = 1; | 71 | val = 1; |
72 | 72 | ||
73 | val = VGA_RD08(par->riva.PCIO, 0x3d5); | ||
74 | |||
75 | return val; | 73 | return val; |
76 | } | 74 | } |
77 | 75 | ||
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig index c287a9ae4fdd..ca75b3ad3a2e 100644 --- a/drivers/w1/Kconfig +++ b/drivers/w1/Kconfig | |||
@@ -1,4 +1,5 @@ | |||
1 | menu "Dallas's 1-wire bus" | 1 | menu "Dallas's 1-wire bus" |
2 | depends on HAS_IOMEM | ||
2 | 3 | ||
3 | config W1 | 4 | config W1 |
4 | tristate "Dallas's 1-wire support" | 5 | tristate "Dallas's 1-wire support" |